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 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
|
||||||
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
|
||||||
db 0x00 ;base 31:24
|
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
|
USER_CODE equ $-gdt
|
||||||
dw 0xffff ;limit 15:0
|
dw 0xffff ;limit 15:0
|
||||||
dw 0x0000 ;base 15:0
|
dw 0x0000 ;base 15:0
|
||||||
|
10
idt.inc
10
idt.inc
@ -1,10 +1,8 @@
|
|||||||
|
|
||||||
idt_entry:
|
idtr:
|
||||||
dw 0 ;offset 15:0
|
dw 49*8-1 ;size of idt
|
||||||
dw KERNEL_CODE ;base 15:0
|
dd IDT ;address of idt
|
||||||
db 0 ;0
|
|
||||||
db 0x8E ;[P][DPL][0][TYPE]
|
|
||||||
dw 0 ;offset 31:16
|
|
||||||
|
|
||||||
%macro isr_label 1
|
%macro isr_label 1
|
||||||
isr_%1:
|
isr_%1:
|
||||||
|
76
kernel.asm
76
kernel.asm
@ -5,51 +5,55 @@
|
|||||||
%define IDT 0x150000
|
%define IDT 0x150000
|
||||||
|
|
||||||
[global start]
|
[global start]
|
||||||
extern _isr
|
[extern _isr]
|
||||||
|
[extern _k_init]
|
||||||
|
|
||||||
bits 32
|
bits 32
|
||||||
|
|
||||||
start:
|
start:
|
||||||
call cls
|
cli ;if they weren't already off
|
||||||
|
mov edi, GDT
|
||||||
mov esi, msg
|
mov esi, gdt
|
||||||
mov edi, 0xb8000
|
mov ecx, gdt_end-gdt
|
||||||
|
copy_gdt:
|
||||||
msg_loop:
|
|
||||||
lodsb
|
lodsb
|
||||||
or al, al
|
|
||||||
jz msg_done
|
|
||||||
stosb
|
stosb
|
||||||
mov al, 15
|
loop copy_gdt
|
||||||
stosb
|
|
||||||
jmp msg_loop
|
|
||||||
|
|
||||||
msg_done:
|
mov edi, IDT ;destination
|
||||||
|
mov esi, isr_0 ;address of isr0
|
||||||
jmp $
|
mov edx, isr_1-isr_0 ;distance between isr labels
|
||||||
|
mov ecx, 49 ;number of isrlabels
|
||||||
cls:
|
fill_idt:
|
||||||
push eax
|
mov ebx, esi
|
||||||
push ecx
|
mov ax, si
|
||||||
push edi
|
stosw ;0 offset 15:0
|
||||||
|
mov ax, KERNEL_CODE
|
||||||
mov edi, 0xb8000
|
stosw ;2 selector 15:0
|
||||||
mov ecx, 2000
|
mov ax, 0x8E00
|
||||||
mov eax, 0x0700
|
stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
|
||||||
cls_loop:
|
shr esi, 16
|
||||||
stosw
|
mov ax, si
|
||||||
loop cls_loop
|
stosw ;6 offset 31:16
|
||||||
|
mov esi, ebx
|
||||||
pop edi
|
add esi, edx
|
||||||
pop ecx
|
loop fill_idt
|
||||||
pop eax
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
msg:
|
|
||||||
db "This kernel is located at 0x100000! Aren't you glad?", 0
|
|
||||||
|
|
||||||
|
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 "gdt.inc"
|
||||||
%include "idt.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)
|
void isr(int num)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -243,6 +243,7 @@ vesa_good:
|
|||||||
stosb
|
stosb
|
||||||
mov al, bl
|
mov al, bl
|
||||||
call puthex
|
call puthex
|
||||||
|
add di, 4
|
||||||
cmp bh, 2
|
cmp bh, 2
|
||||||
jge vesa_good2
|
jge vesa_good2
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
|
Loading…
x
Reference in New Issue
Block a user