Restructure kernel to use 1-segment COM convention
This commit is contained in:
		
							parent
							
								
									71c89387fc
								
							
						
					
					
						commit
						84b754551c
					
				
					 7 changed files with 369 additions and 448 deletions
				
			
		
							
								
								
									
										107
									
								
								boot/kernel.asm
									
										
									
									
									
								
							
							
						
						
									
										107
									
								
								boot/kernel.asm
									
										
									
									
									
								
							|  | @ -1,107 +0,0 @@ | |||
| 		cpu 8086 | ||||
| 		org 0x0700 | ||||
| 
 | ||||
| %include	"inc/bpb.asm" | ||||
| %include	"inc/mbr.asm" | ||||
| %include	"inc/dpt.asm" | ||||
| 
 | ||||
| init:		cli | ||||
| 		xor ax, ax | ||||
| 		mov ds, ax | ||||
| 		mov es, ax | ||||
| 		mov ss, ax | ||||
| 		mov sp, ax | ||||
| 
 | ||||
| 		mov si, 0x7C00 | ||||
| 		; relocate to 00700 | ||||
| 		mov di, text_start | ||||
| 		mov cx, text_length + rodata_length + data_length | ||||
| 		rep movsb | ||||
| 		; clear out bss section | ||||
| 		mov cx, bss_length | ||||
| 		rep stosb | ||||
| 		; jump to copy | ||||
| 		call 0:relinit | ||||
| 
 | ||||
| section .rodata | ||||
| 
 | ||||
| %define V 0x %+ VERSION | ||||
| version:	dd V | ||||
| 
 | ||||
| section .text | ||||
| 
 | ||||
| relinit:	; print banner | ||||
| 		push word [version] | ||||
| 		push word [version+2] | ||||
| 		call printf | ||||
| 		db "RDOS ",2,2, 0x0A, 0x0D, 0 | ||||
| 		; initialize the disk i/o | ||||
| 		call dinit | ||||
| 		; init 21h vector | ||||
| 		mov word [0x21*4], int21 | ||||
| 		mov word [0x21*4+2], cs | ||||
| 		; set current PSP, directly after us | ||||
| 		mov ax, stack | ||||
| 		mov cl, 4 | ||||
| 		shr ax, cl | ||||
| 		mov word [curpsp], ax | ||||
| 		; also the DTA | ||||
| 		mov bx, dta | ||||
| 		call setdta | ||||
| 		; set current drive to boot drive | ||||
| 		mov al, dl | ||||
| 		rol al, 1 | ||||
| 		rol al, 1 | ||||
| 		or dl, al | ||||
| 		and dl, 3 | ||||
| 		call setdd | ||||
| 
 | ||||
| 		mov bx, testfcb | ||||
| 		call fndfst | ||||
| 
 | ||||
| restart: | ||||
| hlt:		hlt | ||||
| 		jmp hlt | ||||
| 
 | ||||
| %include	"kernel/psp.asm" | ||||
| %include	"kernel/syscall.asm" | ||||
| %include	"kernel/char.asm" | ||||
| %include	"kernel/fcb.asm" | ||||
| %include	"kernel/drive.asm" | ||||
| %include	"kernel/printf.asm" | ||||
| 
 | ||||
| section .bss | ||||
| 
 | ||||
| dta:		resb 128 | ||||
| 
 | ||||
| section .data | ||||
| 
 | ||||
| testfcb:	db 0 | ||||
| 		db "HELLO   ", "COM" | ||||
| 		times 30 db 0 | ||||
| 
 | ||||
| section .text | ||||
| 
 | ||||
| text_start	equ  $$ | ||||
| text_length	equ  $-$$ | ||||
| 
 | ||||
| section .rodata | ||||
| 
 | ||||
| rodata_start	equ  $$ | ||||
| rodata_length	equ  $-$$ | ||||
| 
 | ||||
| section .data | ||||
| 
 | ||||
| data_start	equ  $$ | ||||
| data_length	equ  $-$$ | ||||
| 
 | ||||
| section .bss | ||||
| 
 | ||||
| 		resw 256 ; 512b kern stack | ||||
| 		alignb 16 | ||||
| stack:		; stack grows into this ^ | ||||
| 		; this is also the end marker | ||||
| 		; programs with their psp start here | ||||
| 
 | ||||
| bss_start	equ  $$ | ||||
| bss_length	equ  $-$$ | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue