feat: add signal handling support (not tested!)
[lunaix-os.git] / lunaix-os / includes / lunaix / common.h
1 #ifndef __LUNAIX_CONSTANTS_H
2 #define __LUNAIX_CONSTANTS_H
3
4 #define KSTACK_SIZE             (64 << 10)
5 #define KSTACK_START            ((0xFFBFFFFFU - KSTACK_SIZE) + 1)
6 #define KSTACK_TOP              0xffbffff0
7 #define HIGHER_HLF_BASE         0xC0000000
8 #define MEM_1MB                 0x100000
9
10 #define VGA_BUFFER_VADDR        0xB0000000
11 #define VGA_BUFFER_PADDR        0xB8000
12 #define VGA_BUFFER_SIZE         4096
13
14 #define KCODE_SEG              0x08
15 #define KDATA_SEG              0x10
16 #define UCODE_SEG              0x1B
17 #define UDATA_SEG              0x23
18 #define TSS_SEG                0x28
19
20 #define USER_START             0x400000
21 #define USTACK_SIZE            0x100000
22 #define USTACK_TOP             0x9fffffff
23 #define USTACK_END             (USTACK_TOP - USTACK_SIZE + 1)
24 #define UMMAP_AREA             0x4D000000
25
26 #define SYS_TIMER_FREQUENCY_HZ  2048
27
28 #ifndef __ASM__
29 #include <stddef.h>
30 // From Linux kernel v2.6.0 <kernel.h:194>
31 /**
32  * container_of - cast a member of a structure out to the containing structure
33  *
34  * @ptr:        the pointer to the member.
35  * @type:       the type of the container struct this is embedded in.
36  * @member:     the name of the member within the struct.
37  *
38  */
39 #define container_of(ptr, type, member) ({                      \
40         const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
41         (type *)( (char *)__mptr - offsetof(type,member) );})
42
43 #endif
44 #endif /* __LUNAIX_CONSTANTS_H */