how to load fiels and kernal from boot loader

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
sagar474
Posts: 6
Joined: Mon May 09, 2011 11:15 pm

how to load fiels and kernal from boot loader

Post 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
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: how to load fiels and kernal from boot loader

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: how to load fiels and kernal from boot loader

Post by Solar »

sagar474 wrote:if I use CD/DVD.
Every good solution is obvious once you've found it.
Igor1024
Member
Member
Posts: 32
Joined: Mon Apr 11, 2011 12:19 am

Re: how to load fiels and kernal from boot loader

Post 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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: how to load fiels and kernal from boot loader

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: how to load fiels and kernal from boot loader

Post 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
Post Reply