1 /* ----------------------------------------------------------------------- *
2 * Not Copyright 2002 H. Peter Anvin
3 * This file is in the public domain.
4 * ----------------------------------------------------------------------- */
9 * Common declarations for com32 programs.
16 #include <klibc/compiler.h> /* For __cdecl */
19 * This structure defines the register frame used by the
20 * system call interface.
22 * The syscall interface is:
24 * __intcall(interrupt_#, source_regs, return_regs)
25 * __farcall(seg, offs, source_regs, return_regs)
34 uint16_t gs; /* Offset 0 */
35 uint16_t fs; /* Offset 2 */
36 uint16_t es; /* Offset 4 */
37 uint16_t ds; /* Offset 6 */
39 reg32_t edi; /* Offset 8 */
40 reg32_t esi; /* Offset 12 */
41 reg32_t ebp; /* Offset 16 */
42 reg32_t _unused; /* Offset 20 */
43 reg32_t ebx; /* Offset 24 */
44 reg32_t edx; /* Offset 28 */
45 reg32_t ecx; /* Offset 32 */
46 reg32_t eax; /* Offset 36 */
48 reg32_t eflags; /* Offset 40 */
51 /* EFLAGS definitions */
52 #define EFLAGS_CF 0x00000001
53 #define EFLAGS_PF 0x00000004
54 #define EFLAGS_AF 0x00000010
55 #define EFLAGS_ZF 0x00000040
56 #define EFLAGS_SF 0x00000080
57 #define EFLAGS_TF 0x00000100
58 #define EFLAGS_IF 0x00000200
59 #define EFLAGS_DF 0x00000400
60 #define EFLAGS_OF 0x00000800
61 #define EFLAGS_IOPL 0x00003000
62 #define EFLAGS_NT 0x00004000
63 #define EFLAGS_RF 0x00010000
64 #define EFLAGS_VM 0x00020000
65 #define EFLAGS_AC 0x00040000
66 #define EFLAGS_VIF 0x00080000
67 #define EFLAGS_VIP 0x00100000
68 #define EFLAGS_ID 0x00200000
70 extern struct com32_sys_args {
73 void __cdecl (*cs_intcall)(uint8_t, const com32sys_t *, com32sys_t *);
75 uint32_t cs_bounce_size;
76 void __cdecl (*cs_farcall)(uint32_t, const com32sys_t *, com32sys_t *);
83 __intcall(uint8_t __i, const com32sys_t *__sr, com32sys_t *__dr)
85 __com32.cs_intcall(__i, __sr, __dr);
89 __farcall(uint16_t __es, uint16_t __eo,
90 const com32sys_t *__sr, com32sys_t *__dr)
92 __com32.cs_farcall((__es << 16) + __eo, __sr, __dr);
96 * These functions convert between linear pointers in the range
97 * 0..0xFFFFF and real-mode style SEG:OFFS pointers. Note that a
98 * 32-bit linear pointer is not compatible with a SEG:OFFS pointer
99 * stored in two consecutive 16-bit words.
101 static inline uint16_t SEG(void *__p)
103 return (uint16_t)(((uintptr_t)__p) >> 4);
106 static inline uint16_t OFFS(void *__p)
108 /* The double cast here is to shut up gcc */
109 return (uint16_t)(uintptr_t)__p & 0x000F;
112 static inline void *MK_PTR(uint16_t __seg, uint16_t __offs)
114 return (void *)((__seg << 4) + __offs);
117 #endif /* _COM32_H */