Import backup from 2005-03-21

This commit is contained in:
josh committed 2017-07-25 22:23:50 -04:00
1 parent bb8ff09e3f
commit 14792ef954
24 files changed
+671 -197

No files matched your search

+91 -4
View File
@@ -27,6 +27,8 @@ con_move_cursor: ;con_move_cursor(word location)
con_clear:
pusha
push es
push ds
mov ax, 0xB800
mov es, ax
@@ -37,6 +39,8 @@ con_clear:
mov [cursor], word 0
call con_write_cursor
pop ds
pop es
popa
ret
@@ -52,9 +56,7 @@ putstring_loop:
or al, al
jz putstring_done
mov ah, 0x07
push ax
call con_putc
add sp, 2
ccall con_putc, ax
jmp putstring_loop
putstring_done:
@@ -63,10 +65,93 @@ putstring_done:
ret
con_putHex: ;con_putHex(word hexVal)
push bp
mov bp, sp
pusha
mov ax, [bp + 4]
mov cx, 12
mov dl, 0
con_putHex_loop:
push ax
shr ax, cl
and ax, 0xF
cmp ax, 0
jnz con_putHex_putc
cmp cx, 0
jz con_putHex_putc
cmp dl, 0
jz con_putHex_loop_done
con_putHex_putc:
add ax, '0'
cmp ax, '9'
jbe con_putHex_putc_goon
add ax, 'A'-'9'-1
con_putHex_putc_goon:
mov ah, 0x07
ccall con_putc, ax
mov dl, 1
con_putHex_loop_done:
pop ax
cmp cx, 0
jz con_putHex_done
sub cx, 4
jmp con_putHex_loop
con_putHex_done:
popa
pop bp
ret
con_putDec: ;con_putDec(word dec)
push bp
mov bp, sp
pusha
mov ax, [bp + 4]
mov cx, 10000
mov di, 0
con_putDec_loop:
xor dx, dx
div cx ;remainder in dx, quotient in ax
mov bx, ax
mov ax, dx ;new value is ax % mod
push ax
mov ax, bx
cmp ax, 0
jnz con_putDec_putc
cmp cx, 1
jz con_putDec_putc
cmp di, 0
jz con_putDec_loop_done
con_putDec_putc:
add ax, 0x0730
ccall con_putc, ax
mov di, 1
con_putDec_loop_done:
mov ax, cx
xor dx, dx
mov bx, 10
div bx
mov cx, ax
pop ax
cmp cx, 0
jnz con_putDec_loop
popa
pop bp
ret
con_putc: ;con_putc(char chr)
push bp
mov bp, sp
pusha
push es
mov ax, 0xB800
mov es, ax
@@ -79,13 +164,15 @@ con_putc: ;con_putc(char chr)
putc_return:
mov ax, di
mov bl, 160
div bl ; quotient in al, remainder in ah
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
pop es
popa
pop bp
ret
+158 -14
View File
@@ -5,7 +5,7 @@
; Modified: 01/04/05
%define VIRT_OFFSET 0xC0000000
%define SIZEOF_RMPARAMS 20
%include "rmmod.inc"
; the bootstrap process will jump us to 0x0:0x5010 so we'd better be ready for it
@@ -21,6 +21,10 @@
; ecx = where to store real mode parameter table
start:
jmp 0:start_refreshed
%include "conio.inc"
%include "vesa.inc"
start_refreshed:
mov ax, cs ; 0
mov ds, ax
@@ -30,30 +34,144 @@ start_refreshed:
mov [dat_rmadd], ecx
mov [dat_retn], ebx
mov ebx, ecx ; clear the rm_params
mov cx, SIZEOF_RMPARAMS
mov ax, 0
clear_rmparams_loop:
mov [ebx], al
inc ebx
loop clear_rmparams_loop
; begin real-mode code initialization, etc...
call con_clear
; ccall vesa_get_info, es, vbe_info_block
jmp no_vesa
ccall vesa_get_info, es, vbe_info_block
cmp ax, 0
jnzfar no_vesa
vesa_present:
ccall con_putstring, txt_vesa
mov ax, [VideoModePtr]
mov es, ax
mov si, [VideoModePtr + 2]
xor ax, ax
mov al, [VbeVersion + 1]
ccall con_putHex, ax
ccall con_putc, '.' | 0x0700
xor ax, ax
mov al, [VbeVersion]
ccall con_putHex, ax
ccall con_putc, 10
xor ax, ax ; clear the scratch mem
mov cx, 129
mov di, scratch_mem
rep stosw
push ds
mov ax, [OemStringPtr + 2]
mov si, [OemStringPtr]
mov ds, ax
mov di, scratch_mem
mov cx, 128
rep movsw ; and copy the string there for display
pop ds
ccall con_putstring, scratch_mem ; write OEM string
ccall con_putc, 10
mov ax, [VideoModePtr + 2]
mov es, ax
mov si, [VideoModePtr]
xor dx, dx
vesa_mode_loop:
mov ax, [es:si] ; get next mode number
cmp ax, 0xFFFF
jzfar vesa_mode_loop_done
ccall vesa_get_mode_info, ds, vbe_mode_info_block, ax
cmp ax, 0
jnzfar vesa_mode_loop_next
mov ax, [ModeAttributes]
and ax, VESA_MODE_SUPPORTED | VESA_MODE_COLOR | VESA_MODE_GRAPHICS | VESA_MODE_LFB
cmp ax, VESA_MODE_SUPPORTED | VESA_MODE_COLOR | VESA_MODE_GRAPHICS | VESA_MODE_LFB
jnzfar vesa_mode_loop_next
mov al, [BitsPerPixel]
cmp al, 15
jz vesa_mode_good
cmp al, 16
jz vesa_mode_good
cmp al, 24
jz vesa_mode_good
cmp al, 32
jnzfar vesa_mode_loop_next
vesa_mode_good:
mov ax, dx
add ax, 0x0700 | 'a'
ccall con_putc, ax
ccall con_putstring, txt_vesa_mode1
ccall con_putDec, word [XResolution]
ccall con_putc, 'x' | 0x0700
ccall con_putDec, word [YResolution]
ccall con_putc, 'x' | 0x0700
xor ax, ax
mov al, [BitsPerPixel]
ccall con_putDec, ax
ccall con_putstring, txt_vesa_mode2
mov ax, [es:si] ; mode number
ccall con_putHex, ax
ccall con_putc, 10
mov bx, dx
shl bx, 1
mov [scratch_mem + bx], ax ; store modes in scratch_mem array
inc dx
vesa_mode_loop_next:
add si, 2
jmp vesa_mode_loop
vesa_mode_loop_done:
ccall con_putstring, txt_vesa_end
vesa_get_key_loop:
call con_getkey
mov ah, 0
cmp ax, '0'
jz vesa_the_end
cmp ax, 'a' ; first choice
jb vesa_get_key_loop
add dx, 'a'
cmp ax, dx ; one past last choice
jae vesa_get_key_loop
; ok, we have a valid video mode selection
sub ax, 'a'
shl ax, 1
mov bx, ax
mov cx, [scratch_mem + bx]
ccall vesa_get_mode_info, ds, vbe_mode_info_block, cx
or cx, 0x4000 ; enable LFB
ccall vesa_set_mode, cx ; turn on mode
mov ebx, [dat_rmadd] ; pass mode info to kernel
mov eax, [PhysBasePtr]
mov [ebx + 0], eax
xor eax, eax
mov al, [BitsPerPixel]
mov [ebx + 12], eax
mov ax, [XResolution]
mov [ebx + 4], eax
mov ax, [YResolution]
mov [ebx + 8], eax
jmp vesa_the_end
jmp end_rmmod
no_vesa:
ccall con_putstring, txt_novesa
call con_getkey
vesa_the_end:
end_rmmod: ; get ready to go back to pmode and return to kernel initialization
; call con_getkey
mov ebx, [dat_retn]
lgdt [gdtrlin32]
mov eax, cr0
@@ -77,8 +195,6 @@ offset_continue:
[bits 16]
%include "conio.inc"
;-------------------------------------------------------
gdtrlin32:
dw gdt_endlin32-gdtlin32-1
@@ -142,7 +258,10 @@ KERNEL_DATA_BS32 equ $-gdtbs32
gdt_endbs32:
txt_vesa: db "VESA found. Please select:", 10, 0
txt_vesa: db "VESA found. VBE Version: ", 0
txt_vesa_mode1 db ". ", 0
txt_vesa_mode2 db ", mode 0x", 0
txt_vesa_end: db "Enter the letter of your selection or 0 for console mode:", 0
txt_novesa: db "VESA not found, using 80x25 console mode... press any key", 10, 0
dat_rmadd: dd 0
@@ -162,4 +281,29 @@ OemProductName: dd 0
OemProductRev: dd 0
Reserved: times 478 db 0
vbe_mode_info_block:
ModeAttributes: dw 0
WinAAttributes: db 0
WinBAttributes: db 0
WinGranularity: dw 0
WinSize: dw 0
WinASegment: dw 0
WinBSegment: dw 0
WinFuncPtr: dd 0
BytesPerScanline: dw 0
XResolution: dw 0
YResolution: dw 0
XCharSize: db 0
YCharSize: db 0
NumberOfPlanes: db 0
BitsPerPixel: db 0
NumberOfBanks: db 0
MemoryModel: db 0
BankSize: db 0
NumberOfImagePages: db 0
Reserved2: times 10 db 0
PhysBasePtr: dd 0
Reserved3: times 212 db 0
scratch_mem:
+62 -10
View File
@@ -4,30 +4,82 @@
; Modified: 01/04/05
; real mode vesa functions
; sample bochs VBE modes:
;0x000c6a86 <bogus+ 0>: 0x0100 0x0101 0x0102 0x0103 0x0105 0x0110 0x0111 0x0112
;0x000c6a96 <bogus+ 16>: 0x0113 0x0114 0x0115 0x0116 0x0117 0x0118 0x0142 0x0143
;0x000c6aa6 <bogus+ 32>: 0x0144 0x0146 0xffff
%define VESA_MODE_SUPPORTED 0x01
%define VESA_MODE_COLOR 0x08
%define VESA_MODE_GRAPHICS 0x10
%define VESA_MODE_LFB 0x80
vesa_return: dw 0
vesa_get_info: ;vesa_get_info(word seg, word offset)
push bp
mov bp, sp
pusha
push es
push ds
mov ax, [bp + 4]
mov es, ax
mov di, [bp + 6]
mov ax, 0x4F00
int 0x10
cmp ax, 0x004F
jz vesa_got_info
sub ax, 0x004F
mov [vesa_return], ax
mov [vesa_return], word 1
jmp vesa_get_info_done
vesa_got_info:
mov [vesa_return], word 0
vesa_got_info_done:
pop ds
pop es
popa
pop bp
mov ax, [vesa_return]
ret
vesa_return: dw 0
vesa_get_mode_info: ;vesa_get_info(word seg, word offset, word mode)
push bp
mov bp, sp
pusha
push es
push ds
mov ax, [bp + 4]
mov es, ax
mov di, [bp + 6]
mov cx, [bp + 8]
mov ax, 0x4F01
int 0x10
sub ax, 0x004F
mov [vesa_return], ax
pop ds
pop es
popa
pop bp
mov ax, [vesa_return]
ret
vesa_set_mode: ;vesa_set_mode(word mode)
push bp
mov bp, sp
pusha
push es
push ds
mov bx, [bp + 4]
mov ax, 0x4F02
int 0x10
sub ax, 0x004F
mov [vesa_return], ax
pop ds
pop es
popa
pop bp
mov ax, [vesa_return]
ret