Modestus Moon OS  R4
CS 450 project
system.h
Go to the documentation of this file.
1 #ifndef _SYSTEM_H
2 #define _SYSTEM_H
3 
4 #define NULL 0
5 
6 // Suppress 'unused parameter' warnings/errors
7 #define no_warn(p) if (p) while (1) break
8 
9 // Allows compilation with gcc -std=c89
10 // May also help avoid naming conflicts
11 #define asm __asm__
12 #define volatile __volatile__
13 
14 #define sti() asm volatile ("sti"::) //turn irqs off
15 #define cli() asm volatile ("cli"::) //turn irqs on
16 #define nop() asm volatile ("nop"::) //skip cycle
17 #define hlt() asm volatile ("hlt"::) //halt
18 #define iret() asm volatile ("iret"::) //interrupt return
19 
20 #define GDT_CS_ID 0x01 //kernel code segment ID
21 #define GDT_DS_ID 0x02 //kernel data segment ID
22 
23 /* System Types */
24 typedef unsigned int size_t;
25 typedef unsigned char u8int;
26 typedef unsigned short u16int;
27 typedef unsigned long u32int;
28 
29 typedef unsigned char uint8_t;
30 typedef unsigned short uint16_t;
31 typedef unsigned long uint32_t;
32 
33 /* Time */
34 typedef struct {
35  int sec;
36  int min;
37  int hour;
38  int day_w;
39  int day_m;
40  int day_y;
41  int mon;
42  int year;
43 } date_time;
44 
45 /* Test if interrupts are on */
46 static inline int irq_on()
47 {
48  int f;
49  asm volatile ("pushf\n\t"
50  "popl %0"
51  : "=g"(f));
52  return f & (1 << 9);
53 }
54 
55 void klogv(const char *msg);
56 void kpanic(const char *msg);
57 
58 
66 
72 {
76 }__attribute__((packed));
77 
78 
79 
80 #endif
u32int eflags
Definition: system.h:75
void klogv(const char *msg)
Definition: system.c:11
void kpanic(const char *msg)
Definition: system.c:24
u32int gs
Definition: system.h:73
u32int eax
Definition: system.h:74
int hour
Definition: system.h:37
struct s_processContext __attribute__((packed))
The s_processContext struct defines the context that each process stores .
Definition: system.h:71
u32int ecx
Definition: system.h:74
u32int esp
Definition: system.h:74
u32int esi
Definition: system.h:74
unsigned char u8int
Definition: system.h:25
u32int edx
Definition: system.h:74
unsigned short uint16_t
Definition: system.h:30
unsigned char uint8_t
Definition: system.h:29
int day_w
Definition: system.h:38
u32int fs
Definition: system.h:73
int day_y
Definition: system.h:40
u32int ebx
Definition: system.h:74
u32int es
Definition: system.h:73
int min
Definition: system.h:36
unsigned long uint32_t
Definition: system.h:31
u32int cs
Definition: system.h:75
int mon
Definition: system.h:41
u32int ebp
Definition: system.h:74
unsigned int size_t
Definition: system.h:24
u32int edi
Definition: system.h:74
int sec
Definition: system.h:35
int year
Definition: system.h:42
unsigned long u32int
Definition: system.h:27
int day_m
Definition: system.h:39
u32int eip
Definition: system.h:75
unsigned short u16int
Definition: system.h:26
u32int ds
Definition: system.h:73