Import backup from 2003-08-13
This commit is contained in:
parent
4e4baeba63
commit
75c132cbd4
14
gdt.inc
14
gdt.inc
@ -34,6 +34,20 @@ VESA_DATA equ $-gdt
|
||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||
db 0x00 ;base 31:24
|
||||
VIDEO_TEXT equ $-gdt
|
||||
dw 0x7FFF ;limit 15:0
|
||||
dw 0x8000 ;base 15:0
|
||||
db 0x0B ;base 23:16
|
||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||
db 0x00 ;base 31:24
|
||||
VIDEO_GRAPHICS equ $-gdt
|
||||
dw 0xFFFF ;limit 15:0
|
||||
dw 0x0000 ;base 15:0
|
||||
db 0x0A ;base 23:16
|
||||
db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||
db 0x00 ;base 31:24
|
||||
USER_CODE equ $-gdt
|
||||
dw 0xffff ;limit 15:0
|
||||
dw 0x0000 ;base 15:0
|
||||
|
10
idt.inc
10
idt.inc
@ -1,10 +1,8 @@
|
||||
|
||||
idt_entry:
|
||||
dw 0 ;offset 15:0
|
||||
dw KERNEL_CODE ;base 15:0
|
||||
db 0 ;0
|
||||
db 0x8E ;[P][DPL][0][TYPE]
|
||||
dw 0 ;offset 31:16
|
||||
idtr:
|
||||
dw 49*8-1 ;size of idt
|
||||
dd IDT ;address of idt
|
||||
|
||||
|
||||
%macro isr_label 1
|
||||
isr_%1:
|
||||
|
76
kernel.asm
76
kernel.asm
@ -5,51 +5,55 @@
|
||||
%define IDT 0x150000
|
||||
|
||||
[global start]
|
||||
extern _isr
|
||||
[extern _isr]
|
||||
[extern _k_init]
|
||||
|
||||
bits 32
|
||||
|
||||
start:
|
||||
call cls
|
||||
|
||||
mov esi, msg
|
||||
mov edi, 0xb8000
|
||||
|
||||
msg_loop:
|
||||
cli ;if they weren't already off
|
||||
mov edi, GDT
|
||||
mov esi, gdt
|
||||
mov ecx, gdt_end-gdt
|
||||
copy_gdt:
|
||||
lodsb
|
||||
or al, al
|
||||
jz msg_done
|
||||
stosb
|
||||
mov al, 15
|
||||
stosb
|
||||
jmp msg_loop
|
||||
loop copy_gdt
|
||||
|
||||
msg_done:
|
||||
|
||||
jmp $
|
||||
|
||||
cls:
|
||||
push eax
|
||||
push ecx
|
||||
push edi
|
||||
|
||||
mov edi, 0xb8000
|
||||
mov ecx, 2000
|
||||
mov eax, 0x0700
|
||||
cls_loop:
|
||||
stosw
|
||||
loop cls_loop
|
||||
|
||||
pop edi
|
||||
pop ecx
|
||||
pop eax
|
||||
|
||||
ret
|
||||
|
||||
msg:
|
||||
db "This kernel is located at 0x100000! Aren't you glad?", 0
|
||||
mov edi, IDT ;destination
|
||||
mov esi, isr_0 ;address of isr0
|
||||
mov edx, isr_1-isr_0 ;distance between isr labels
|
||||
mov ecx, 49 ;number of isrlabels
|
||||
fill_idt:
|
||||
mov ebx, esi
|
||||
mov ax, si
|
||||
stosw ;0 offset 15:0
|
||||
mov ax, KERNEL_CODE
|
||||
stosw ;2 selector 15:0
|
||||
mov ax, 0x8E00
|
||||
stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
|
||||
shr esi, 16
|
||||
mov ax, si
|
||||
stosw ;6 offset 31:16
|
||||
mov esi, ebx
|
||||
add esi, edx
|
||||
loop fill_idt
|
||||
|
||||
lgdt [gdtr] ;load gdt
|
||||
jmp KERNEL_CODE:newgdtcontinue
|
||||
newgdtcontinue:
|
||||
mov ax, KERNEL_DATA
|
||||
mov es, ax
|
||||
mov ds, ax
|
||||
mov gs, ax
|
||||
mov fs, ax
|
||||
mov ss, ax
|
||||
mov esp, 0x1ffffc ;stack just under 2mb, moves downward
|
||||
lidt [idtr] ;load idt
|
||||
|
||||
jmp _k_init
|
||||
hlt ;halt processor when k_init is done
|
||||
jmp $ ;shouldn't get here...
|
||||
|
||||
%include "gdt.inc"
|
||||
%include "idt.inc"
|
||||
|
16
kernel.c
16
kernel.c
@ -1,4 +1,20 @@
|
||||
|
||||
void isr(int num);
|
||||
void k_init();
|
||||
|
||||
void k_init()
|
||||
{
|
||||
char *vidmem = (char *) 0xB8000;
|
||||
char welcome[] = "Welcome to HOS kernel. You are now in protected mode.";
|
||||
char *chrptr = welcome;
|
||||
while (*chrptr != 0)
|
||||
{
|
||||
*vidmem++ = *chrptr++;
|
||||
*vidmem++ = 15;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void isr(int num)
|
||||
{
|
||||
|
||||
|
@ -243,6 +243,7 @@ vesa_good:
|
||||
stosb
|
||||
mov al, bl
|
||||
call puthex
|
||||
add di, 4
|
||||
cmp bh, 2
|
||||
jge vesa_good2
|
||||
xor ax, ax
|
||||
|
Loading…
x
Reference in New Issue
Block a user