Page 1 of 1

how to load fiels and kernal from boot loader

Posted: Tue May 10, 2011 2:56 am
by sagar474
I have written the following code, this is my first boot sector program code.
and it works fine, but now how can i load other files and kernel. if I use CD/DVD.

Code: Select all

 
BITS 16

jmp start			;jump to actual executing code

;------------------------------message set to display on the screen--------------
wellcome_msg db 'wellcome to Sagar cool new operating system',13,10,0,
reboot_msg db   'Your system is going to reboot now....',0,
reboot_key	db 'Press any key to reboot',13,10,0,


;------------------------------Main Boot loading process starts hear---------------
	start:
	mov ax, 07C0h		; Set data segment to where we're loaded
	mov ds, ax		; 
	mov ax,9000h		;initialize the stack 
	mov ss,ax		;
	mov sp,100h		;
	
	mov si,wellcome_msg	;source index register (SI) points to the wellcome_message offset
	call print		;call the print subroutine. 
	
	

	mov si,reboot_key	; SI points to the off set of the string with label reboot_key
	call print		;call the print subroutine.
	
	call getkey
	
	mov si,reboot_msg	;SI points to offset of the string with label reboot_msg
	call print		;call the print subroutine.
	
	call reboot		;reboots the system.
	jmp $			; jump hear ie., infinite loop

;------------------------sub rotine---------------------------------------------
;----------------------to print string ------------------------------------------	
	print:			;print subroutine
	mov ah,0eh;		;loads ah with 0eh function for print char in BIOS int 10h
	repet:			;
	lodsb			;al<-----[si] and si=si+1 
	cmp al,0		;compare al and 0
	je done			;if al=0 then jump to lable don
	int 10h;		;call BIOS interrupt 10h video services
	jmp repet		;unconditional jump to label repit:
	done:
	ret			;return to main program.
;-------------------------------------------------------------------------------------		

;------------------------key board input------------------------------------------------
getkey:
mov ah,0			;function for keyboard char input stors ASCII value in al
int 16h				;BIOS keyboard interrupt 
ret
;-------------------------------------------------------------------------------------

;---------------------------reboot-----------------------------------------------------
     reboot:

                db 0EAh                 ; machine language to jump to FFFF:0000 (reboot)
                dw 0000h
                dw 0FFFFh
                ; no ret required; we're rebooting! (Hey, I just saved a byte :)
;--------------------------------------------------------------------------------------


	
times 510-($-$$) db 0	; Pad remainder of boot sector with 0s
	dw 0xAA55		; The standard PC boot signature


please help
thank you

Re: how to load fiels and kernal from boot loader

Posted: Tue May 10, 2011 3:34 am
by Igor1024
You have just helloworld and less than 512 bytes of space for code...
I taught it by KOLIBRI OS bootloader. Read FAT specification and try to get familiar with KOLIBRI bootloader. In general details... you should calculate where is ROOT_DIRECTORY (if it's FAT), try to find there name of your file, then read FAT table and load your kernel.

Re: how to load fiels and kernal from boot loader

Posted: Tue May 10, 2011 5:36 am
by Solar
sagar474 wrote:if I use CD/DVD.

Re: how to load fiels and kernal from boot loader

Posted: Tue May 10, 2011 2:13 pm
by Igor1024
So, you can use BIOS functions: int 13h, proc # 4Ah. It just emulates CD/DVD data. There are no special BIOS procs for direct CD/DVD programming, but you can program CD/DVD controller on your own.

Re: how to load fiels and kernal from boot loader

Posted: Wed May 11, 2011 5:08 am
by egos
No. Function 42h allows to read data from CD/DVD.

To load file topic starter should parse FS structure to find this file. Or he should know beforehand where this file is located.

Re: how to load fiels and kernal from boot loader

Posted: Wed May 11, 2011 5:30 am
by AJ
Hi,

See the El-Torito wiki article which has pointers to articals about ISO9660 etc... Information on extended read BIOS services (int 0x13, AH=0x42) are fairly well documented elsewhere, including in Ralph Brown's interrupt list.

Cheers,
Adam