-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_32cc.h
More file actions
63 lines (54 loc) · 1.51 KB
/
utils_32cc.h
File metadata and controls
63 lines (54 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************************
> File Name: utils_32cc.h
> Author: sillyplus
> Mail: oi_boy@sina.cn
> Created Time: Tue Apr 7 08:23:58 2015
******************************************************************************/
#ifndef _UTILS_32CC_H_
#define _UTILS_32CC_H_
#include "stdint.h"
char get_kb_char();
void clear_scn();
void write_str(const char *, uint16_t, uint16_t);
void write_char(char);
void set_char(char, uint16_t);
void read_disk(void *, uint8_t, uint16_t, uint8_t);
void sleep(uint16_t);
void move_cursor(uint16_t);
uint16_t get_cursor();
char get_char();
uint32_t add_int_handler(uint8_t, void *);
static inline void write_str_current(const char *p_str, uint16_t len) {
while(len--)
write_char(*p_str++);
}
static inline char * strchr_(char *p_str, char c) {
while(*p_str != c && *p_str != '\0')
++p_str;
return p_str;
}
static inline void strncpy_(char *dest, const char *source, uint16_t len) {
__asm__ volatile(
".intel_syntax noprefix;"
"cld;"
"rep movsb;"
".att_syntax prefix;"
: /* no output */
: "c"(len), "D"(dest), "S"(source)
: "memory"
);
dest[len] = '\0';
}
static inline char strncmp_(const char *a, const char *b, uint16_t len) {
__asm__ volatile(
".intel_syntax noprefix;"
"cld;"
"rep cmpsb;"
".att_syntax prefix;"
: "=c"(len)
: "c"(len+1), "D"(a), "S"(b)
: "cc"
);
return len;
}
#endif