-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.c
More file actions
119 lines (88 loc) · 2.22 KB
/
startup.c
File metadata and controls
119 lines (88 loc) · 2.22 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// #define KERNEL_FUNC __attribute__((__section__(".kernel")))
#include <stdint.h>
void startup(uint32_t magic, uint32_t addr);
#define OS_VERSION "ReichelOS i386 v0.1"
#include "vga.h"
#include "conio.h"
#include "mem.h"
#include "interrupt.h"
#include "timer.h"
#include "multiboot.h"
#include "8042.h"
#include "floppy.h"
#include "kcmd.h"
#include "kmalloc.h"
void clrscr_pre(void);
void print_pre(char *dest, char *src);
const char *init_kernel_msg = "Initializing Kernel...";
void dummy2(void) {
printf("hallo %s", "blabla");
}
const char *ticksymb = "-/|\\";
// char buffer[256];
char command[256];
uint32_t cmd_idx;
void clear_command(void)
{
rmemset(command, 0, 256);
cmd_idx = 0;
}
void startup(uint32_t magic, uint32_t addr)
{
multiboot_info_t *mbi;
mbi = (multiboot_info_t *)addr;
vga_init();
clrscr();
printf(init_kernel_msg);
if (magic == 0x2BADB002)
printf("Multiboot magic ok\n");
mem_init();
printf("IRQs 0-15 remapped to ISRs 0x20-0x2F\n");
init_interrupts();
printf("PIT 8254 initialized to generate IRQ0 with 1 kHz\n");
init_timer();
if (mbi->flags & 2)
{
printf("mem_lower = %dKB, mem_upper = %dKB\n", mbi->mem_lower,\
mbi->mem_upper);
}
if (CHECK_FLAG (mbi->flags, 6))
{
multiboot_memory_map_t *mmap;
printf("mmap_addr = 0x%x, length = 0x%x\n",
mbi->mmap_addr, mbi->mmap_length);
for (mmap = (multiboot_memory_map_t *) mbi->mmap_addr;
(uint32_t) mmap < mbi->mmap_addr + mbi->mmap_length;
mmap = (multiboot_memory_map_t *) ((uint32_t) mmap
+ mmap->size + sizeof (mmap->size)))
{
printf(" size = 0x%x, base = 0x%x, len = 0x%x, type = 0%u\n",
mmap->size, mmap->addr0 & 0xFFFFFFFF,
mmap->len0 & 0xFFFFFFFF, mmap->type);
}
}
init_8042();
asm volatile("sti");
fdd_init();
heap_init();
printf("\n%s\n", OS_VERSION);
DMA_floppy_init_mem(0x8000, 512);
DMA_floppy_read();
kcmdloop();
}
void clrscr_pre(void)
{
unsigned short *scrmem = (unsigned short *)VIDEO;
for (unsigned long i = 0; i < 80*25; i++) {
*scrmem = 0x0720;
scrmem++;
}
}
void print_pre(char *dest, char *src)
{
while (*src) {
*dest = *src;
dest += 2;
src++;
}
}