-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.h
84 lines (70 loc) · 3.07 KB
/
system.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*****************************************************************************/
/* File: system.h */
/* */
/* Description: Header file for x86 system information. */
/* Contains E820 map and VGA buffer address. */
/* */
/* Author: Shoily O Rahman <[email protected]> */
/* */
/* Date: Mar 28, 2020 */
/* */
/*****************************************************************************/
#ifndef _SYSTEM_H
#define _SYSTEM_H
#include "type.h"
#include "krnlconst.h"
#include "apic.h"
#define MAX_NUM_SMPS 32
#define VIRT_TO_PHYS_ADDR_LINEAR(x) ((long)(x)-KERNEL_VIRT_ADDR)
#define VIDEO_VIRT_BUFFER (KERNEL_VIRT_ADDR+VIDEO_BUFFER)
#define E820_MAP_VIRT_ADDRESS (KERNEL_VIRT_ADDR+E820_MAP_ADDRESS)
#define E820_MAP_VIRT_COUNT (KERNEL_VIRT_ADDR+E820_MAP_COUNT)
#define PIT_CRYSTAL_FREQUENCY 1193182
#define PIT_HZ (PIT_CRYSTAL_FREQUENCY/1000)
#define MAX_SUPPORTED_MEMORY ((u64)4*1024*1024*1024)
#define MFENCE __asm__ __volatile__("mfence;" \
: \
: \
: "memory" \
); \
#define CLI __asm__ __volatile__("cli;" \
: \
: \
: \
); \
#define STI __asm__ __volatile__("sti;" \
: \
: \
: \
); \
/*
#define clear_tlb(pfn) __asm__ __volatile__("movl $%0, %%eax;" \
"invlpg (%%eax);" \
: \
: "m" ((pfn)) \
: "%eax" \
); \
*/
extern int lapic_present;
#define CUR_CPU (lapic_present ? (lapic_read_register(LAPIC_ID_REG) >> 24) : 0)
struct e820_map {
u64 base;
u64 length;
u32 type;
u32 ACPI;
}__attribute__((packed));
void dump_e820();
void mask_pic_8259();
void init_pic_8259();
void init_pit_frequency();
void pit_wait(int cycles);
void pit_wait_ms(int ms);
void vga_init();
void devices_init();
void device_enable_interrupts();
void print_vga(char *c);
void print_vga_fixed(char *c, int col, int row);
void bda_read_table();
void read_msr(int msr, int *eax, int *edx);
void write_msr(int msr, int eax, int edx);
#endif