Import backup from 2005-01-05
This commit is contained in:
parent
d8580a9393
commit
05183a3949
@ -1,7 +1,7 @@
|
|||||||
// kernel.h
|
// kernel.h
|
||||||
// Author: Josh Holtrop
|
// Author: Josh Holtrop
|
||||||
// Date: 08/16/04
|
// Date: 08/16/04
|
||||||
// Modified: 08/28/04
|
// Modified: 01/04/05
|
||||||
|
|
||||||
#ifndef __HOS_KERNEL_H__
|
#ifndef __HOS_KERNEL_H__
|
||||||
#define __HOS_KERNEL_H__ __HOS_KERNEL_H__
|
#define __HOS_KERNEL_H__ __HOS_KERNEL_H__
|
||||||
@ -14,7 +14,7 @@ typedef struct {
|
|||||||
u32_t width; // width in pixels or columns if vid_mem == 0
|
u32_t width; // width in pixels or columns if vid_mem == 0
|
||||||
u32_t height; // height in pixels or columns if vid_mem == 0
|
u32_t height; // height in pixels or columns if vid_mem == 0
|
||||||
u32_t vid_mem; // amount of memory for video buffer
|
u32_t vid_mem; // amount of memory for video buffer
|
||||||
u32_t bpp; // bits per pixel - 16/24/32
|
u32_t bpp; // bits per pixel - 15/16/24/32
|
||||||
} __attribute__ ((packed)) real_mode_param_t;
|
} __attribute__ ((packed)) real_mode_param_t;
|
||||||
|
|
||||||
/* returns true to callee if we should jump to a real mode module */
|
/* returns true to callee if we should jump to a real mode module */
|
||||||
|
122
rmmod/conio.inc
Normal file
122
rmmod/conio.inc
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
; conio.inc
|
||||||
|
; real mode console input / output functions
|
||||||
|
; Author: Josh Holtrop
|
||||||
|
; Date: 01/04/05
|
||||||
|
; Modified: 01/04/05
|
||||||
|
|
||||||
|
|
||||||
|
con_getkey:
|
||||||
|
xor ax, ax
|
||||||
|
int 0x16
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_move_cursor: ;con_move_cursor(word location)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
push ax
|
||||||
|
|
||||||
|
mov ax, [bp + 4]
|
||||||
|
mov [cursor], ax
|
||||||
|
call con_write_cursor
|
||||||
|
|
||||||
|
pop ax
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_clear:
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov ax, 0xB800
|
||||||
|
mov es, ax
|
||||||
|
mov di, 0
|
||||||
|
mov ax, 0x0720
|
||||||
|
mov cx, 2000
|
||||||
|
rep stosw
|
||||||
|
mov [cursor], word 0
|
||||||
|
call con_write_cursor
|
||||||
|
|
||||||
|
popa
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_putstring: ;con_putstring(char *str)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov si, [bp + 4]
|
||||||
|
putstring_loop:
|
||||||
|
lodsb
|
||||||
|
or al, al
|
||||||
|
jz putstring_done
|
||||||
|
mov ah, 0x07
|
||||||
|
push ax
|
||||||
|
call con_putc
|
||||||
|
add sp, 2
|
||||||
|
jmp putstring_loop
|
||||||
|
|
||||||
|
putstring_done:
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_putc: ;con_putc(char chr)
|
||||||
|
push bp
|
||||||
|
mov bp, sp
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov ax, 0xB800
|
||||||
|
mov es, ax
|
||||||
|
mov di, [cursor]
|
||||||
|
mov ax, [bp + 4]
|
||||||
|
cmp al, 10
|
||||||
|
jz putc_return
|
||||||
|
stosw
|
||||||
|
jmp putc_update
|
||||||
|
putc_return:
|
||||||
|
mov ax, di
|
||||||
|
mov bl, 160
|
||||||
|
div bl ; quotient in al, remainder in ah
|
||||||
|
shr ax, 8
|
||||||
|
sub di, ax
|
||||||
|
add di, 160
|
||||||
|
putc_update:
|
||||||
|
mov [cursor], di
|
||||||
|
call con_write_cursor
|
||||||
|
popa
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
con_write_cursor:
|
||||||
|
pusha
|
||||||
|
|
||||||
|
mov ax, [cursor]
|
||||||
|
shr ax, 1
|
||||||
|
|
||||||
|
mov bl, al
|
||||||
|
mov dx, 0x03D4
|
||||||
|
mov al, 0x0E
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
inc dx
|
||||||
|
mov al, ah
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
dec dx
|
||||||
|
mov al, 0x0F
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
inc dx
|
||||||
|
mov al, bl
|
||||||
|
out dx, al
|
||||||
|
|
||||||
|
popa
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
cursor: dw 0
|
||||||
|
|
@ -2,9 +2,12 @@
|
|||||||
; real mode module for HOS
|
; real mode module for HOS
|
||||||
; Author: Josh Holtrop
|
; Author: Josh Holtrop
|
||||||
; Date: 09/20/04
|
; Date: 09/20/04
|
||||||
|
; Modified: 01/04/05
|
||||||
|
|
||||||
%define VIRT_OFFSET 0xC0000000
|
%define VIRT_OFFSET 0xC0000000
|
||||||
|
|
||||||
|
%include "rmmod.inc"
|
||||||
|
|
||||||
; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it
|
; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it
|
||||||
[org 0x5000]
|
[org 0x5000]
|
||||||
[bits 16]
|
[bits 16]
|
||||||
@ -29,15 +32,39 @@ start_refreshed:
|
|||||||
|
|
||||||
; begin real-mode code initialization, etc...
|
; begin real-mode code initialization, etc...
|
||||||
|
|
||||||
|
call con_clear
|
||||||
|
|
||||||
|
mov ax, 0x4F00
|
||||||
|
mov di, vbe_info_block
|
||||||
|
int 0x10
|
||||||
|
cmp ax, 0x004F
|
||||||
|
jz vesa_present
|
||||||
|
jmp no_vesa
|
||||||
|
|
||||||
|
vesa_present:
|
||||||
|
ccall con_putstring, txt_vesa
|
||||||
|
mov ax, [VideoModePtr]
|
||||||
|
mov es, ax
|
||||||
|
mov si, [VideoModePtr + 2]
|
||||||
|
|
||||||
|
jmp end_rmmod
|
||||||
|
|
||||||
|
no_vesa:
|
||||||
|
ccall con_putstring, txt_novesa
|
||||||
|
|
||||||
|
|
||||||
; get ready to go back to pmode and return to kernel initialization
|
|
||||||
|
|
||||||
|
|
||||||
|
end_rmmod: ; get ready to go back to pmode and return to kernel initialization
|
||||||
|
call con_getkey
|
||||||
mov ebx, [dat_retn]
|
mov ebx, [dat_retn]
|
||||||
lgdt [gdtrlin32]
|
lgdt [gdtrlin32]
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
or eax, 0x01
|
or eax, 0x01
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
jmp KERNEL_CODE_LIN32:segmented_start
|
jmp KERNEL_CODE_LIN32:segmented_start
|
||||||
|
|
||||||
[bits 32]
|
[bits 32]
|
||||||
segmented_start:
|
segmented_start:
|
||||||
lgdt [gdtrbs32]
|
lgdt [gdtrbs32]
|
||||||
@ -53,43 +80,8 @@ offset_continue:
|
|||||||
|
|
||||||
|
|
||||||
[bits 16]
|
[bits 16]
|
||||||
; putString(int position, char *str)
|
|
||||||
putString:
|
|
||||||
push bp
|
|
||||||
mov bp, sp
|
|
||||||
push ds
|
|
||||||
push es
|
|
||||||
push edi
|
|
||||||
push esi
|
|
||||||
push eax
|
|
||||||
|
|
||||||
mov ax, 0xb800
|
%include "conio.inc"
|
||||||
mov es, ax
|
|
||||||
xor ax, ax
|
|
||||||
mov ds, ax
|
|
||||||
mov ax, [bp + 4]
|
|
||||||
mov di, ax
|
|
||||||
shl di, 1
|
|
||||||
mov ax, [bp + 6]
|
|
||||||
mov si, ax
|
|
||||||
|
|
||||||
putString_loop:
|
|
||||||
lodsb
|
|
||||||
stosb
|
|
||||||
cmp al, 0
|
|
||||||
jz putString_loop_done
|
|
||||||
mov al, 0x07
|
|
||||||
stosb
|
|
||||||
jmp putString_loop
|
|
||||||
putString_loop_done:
|
|
||||||
|
|
||||||
pop eax
|
|
||||||
pop esi
|
|
||||||
pop edi
|
|
||||||
pop es
|
|
||||||
pop ds
|
|
||||||
pop bp
|
|
||||||
ret
|
|
||||||
|
|
||||||
;-------------------------------------------------------
|
;-------------------------------------------------------
|
||||||
gdtrlin32:
|
gdtrlin32:
|
||||||
@ -154,6 +146,22 @@ KERNEL_DATA_BS32 equ $-gdtbs32
|
|||||||
gdt_endbs32:
|
gdt_endbs32:
|
||||||
|
|
||||||
|
|
||||||
dat_rmadd dd 0
|
txt_vesa: db "VESA found. Please select:", 10, 0
|
||||||
dat_initrd dd 0
|
txt_novesa: db "VESA not found, using 80x25 console mode... press any key", 10, 0
|
||||||
dat_retn dd 0
|
|
||||||
|
dat_rmadd: dd 0
|
||||||
|
dat_initrd: dd 0
|
||||||
|
dat_retn: dd 0
|
||||||
|
|
||||||
|
vbe_info_block:
|
||||||
|
VbeSignature: db "VBE2"
|
||||||
|
VbeVersion: dw 0
|
||||||
|
OemStringPtr dd 0
|
||||||
|
Capabilities: times 4 db 0
|
||||||
|
VideoModePtr: dd 0
|
||||||
|
TotalMemory: dw 0
|
||||||
|
OemSoftwareRev: dw 0
|
||||||
|
OemVendorName: dd 0
|
||||||
|
OemProductName: dd 0
|
||||||
|
OemProductRev: dd 0
|
||||||
|
Reserved: times 478 db 0
|
||||||
|
47
rmmod/rmmod.inc
Normal file
47
rmmod/rmmod.inc
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
; rmmod.inc
|
||||||
|
; Author: Josh Holtrop
|
||||||
|
; Date: 01/04/05
|
||||||
|
; Modified: 01/04/05
|
||||||
|
|
||||||
|
%macro jzfar 1
|
||||||
|
jnz %%skip
|
||||||
|
jmp %1
|
||||||
|
%%skip:
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro jnzfar 1
|
||||||
|
jz %%skip
|
||||||
|
jmp %1
|
||||||
|
%%skip:
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro ccall 2
|
||||||
|
push %2
|
||||||
|
call %1
|
||||||
|
add esp, 2
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro ccall 3
|
||||||
|
push %3
|
||||||
|
push %2
|
||||||
|
call %1
|
||||||
|
add esp, 4
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro ccall 4
|
||||||
|
push %4
|
||||||
|
push %3
|
||||||
|
push %2
|
||||||
|
call %1
|
||||||
|
add esp, 6
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro ccall 5
|
||||||
|
push %5
|
||||||
|
push %4
|
||||||
|
push %3
|
||||||
|
push %2
|
||||||
|
call %1
|
||||||
|
add esp, 8
|
||||||
|
%endmacro
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user