comparison cos/kernel/kernel.h @ 17:f3e3e0e9c4bc

First attempt IDT loader 64 bits. INT13 occurs
author windel
date Sat, 19 Nov 2011 20:01:28 +0100
parents a58904747019
children b1fed2171e1a
comparison
equal deleted inserted replaced
16:ddefe6d97cd7 17:f3e3e0e9c4bc
3 3
4 // Include common functions, available to all! 4 // Include common functions, available to all!
5 #define NULL ((void*)0) 5 #define NULL ((void*)0)
6 6
7 // Type defs: 7 // Type defs:
8 typedef unsigned char uint8_t;
9 typedef unsigned short uint16_t;
8 typedef unsigned int uint32_t; 10 typedef unsigned int uint32_t;
9 typedef unsigned long long uint64_t; 11 typedef unsigned long int uint64_t;
10 typedef unsigned short ushort_t;
11 typedef unsigned char uchar_t;
12 typedef unsigned int uint_t;
13 typedef unsigned long ulong_t;
14 typedef unsigned long long ulonglong_t;
15 typedef unsigned long off_t;
16 typedef unsigned long size_t;
17 12
13 // IDT related structures:
14 typedef struct {
15 uint16_t baseLow;
16 uint16_t selector;
17 uint8_t reserved1;
18 uint8_t flags;
19 uint16_t baseMid;
20 uint32_t baseHigh;
21 uint32_t reserved2;
22 } __attribute__((packed)) IDT_entry;
23
24 typedef struct {
25 uint16_t limit;
26 uint64_t base;
27 } __attribute__((packed)) idtPointer;
28
29 // memory alloc functions:
30 void* malloc(uint64_t size);
31 void free(void* ptr);
32
33 // STDout funcs:
18 void printf(const char* fmt, ... ); 34 void printf(const char* fmt, ... );
19 void memset(void* ptr, uint32_t value, uint32_t num); 35 void memset(void* ptr, uint32_t value, uint32_t num);
20 void memcpy(void* dst, void* src, uint32_t num); 36 void memcpy(void* dst, void* src, uint32_t num);
21 37
22 struct IDT_entry { 38 // Screen related:
23 unsigned char b[8];
24 };
25
26 // memory alloc functions:
27 void* malloc(size_t size);
28 void free(void* ptr);
29
30 void clear_screen(); 39 void clear_screen();
31 void init_screen(); 40 void init_screen();
32 void print_string(const char *); 41 void print_string(const char *);
33 42
34 // For IO ports: 43 // For IO ports:
35 unsigned char inb(unsigned short); 44 uint8_t inb(uint16_t);
36 void outb(unsigned short, unsigned char); 45 uint16_t inw(uint16_t);
46 void outb(uint16_t, uint8_t);
47
48 // Interrupt functions:
49 void setupIDT(void);
50 void PICremap(void);
37 51
38 // ASM helper: 52 // ASM helper:
39 int loadIDT(struct IDT_entry *table, unsigned short size); 53 void loadIDT(void);
54
55 // Panic exit:
40 void halt(void); 56 void halt(void);
41 57
42 void setupIDT(void); 58 // Bochs xchg bx,bx breakpoint:
43 void PICremap(void); 59 void magicBochsBreak();
60
44 // Assembler util functions: 61 // Assembler util functions:
45 void enableinterrupts(void);
46 void callint49(void);
47 void doCPUID(int eax, int *ebx, int *ecx, int *edx); 62 void doCPUID(int eax, int *ebx, int *ecx, int *edx);
48 63
49 // Keyboard driver: 64 // Keyboard driver:
50 void keyboardDriverUpdate(unsigned char scancode); 65 void keyboardDriverUpdate(unsigned char scancode);
51 void timerDriverUpdate(void); 66 void timerDriverUpdate(void);
52 67
53 // Memory functions: 68 // Memory functions:
54 void mappage(uint32_t address); 69 void mappage(uint64_t address);
55 70
56 int querymode(void); 71 int querymode(void);
57 int getcs(void); 72 int getcs(void);
58 void loadPageTable(void* tableAddress); 73 void loadPageTable(void* tableAddress);
59 void enablePaging(void); 74 void enablePaging(void);