dmi: check both the AC and ID flags at the same time
[syslinux/sherbszt.git] / dos / mystuff.h
blob2d9574d6feda4cc56c93839fe3f1d13c0e05ed34
1 #ifndef MYSTUFF_H
2 #define MYSTUFF_H
4 #include <inttypes.h>
5 #include <stddef.h>
7 unsigned int skip_atou(const char **s);
8 unsigned int atou(const char *s);
10 static inline int isdigit(int ch)
12 return (ch >= '0') && (ch <= '9');
15 struct diskio {
16 uint32_t startsector;
17 uint16_t sectors;
18 uint16_t bufoffs, bufseg;
19 } __attribute__ ((packed));
20 int int25_read_sector(unsigned char drive, struct diskio *dio);
21 int int26_write_sector(unsigned char drive, struct diskio *dio);
23 struct psp {
24 uint16_t int20;
25 uint16_t nextpara;
26 uint8_t resv1;
27 uint8_t dispatcher[5];
28 uint32_t termvector;
29 uint32_t ctrlcvector;
30 uint32_t criterrvector;
31 uint16_t resv2[11];
32 uint16_t environment;
33 uint16_t resv3[23];
34 uint8_t fcb[2][16];
35 uint32_t resv4;
36 uint8_t cmdlen;
37 char cmdtail[127];
38 } __attribute__((packed));
40 extern struct psp _PSP;
42 static inline __attribute__((const))
43 uint16_t ds(void)
45 uint16_t v;
46 asm("movw %%ds,%0":"=rm"(v));
47 return v;
50 static inline void set_fs(uint16_t seg)
52 asm volatile("movw %0,%%fs"::"rm" (seg));
55 static inline uint8_t get_8_fs(size_t offs)
57 uint8_t v;
58 asm volatile("movb %%fs:%1,%0"
59 : "=q" (v) : "m" (*(const uint8_t *)offs));
60 return v;
63 static inline uint16_t get_16_fs(size_t offs)
65 uint16_t v;
66 asm volatile("movw %%fs:%1,%0"
67 : "=r" (v) : "m" (*(const uint16_t *)offs));
68 return v;
71 static inline uint32_t get_32_fs(size_t offs)
73 uint32_t v;
74 asm volatile("movl %%fs:%1,%0"
75 : "=r" (v) : "m" (*(const uint32_t *)offs));
76 return v;
79 #endif /* MYSTUFF_H */