OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:09 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: how to load fiels and kernal from boot loader
PostPosted: Tue May 10, 2011 2:56 am 
Offline

Joined: Mon May 09, 2011 11:15 pm
Posts: 6
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:

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


Top
 Profile  
 
 Post subject: Re: how to load fiels and kernal from boot loader
PostPosted: Tue May 10, 2011 3:34 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: how to load fiels and kernal from boot loader
PostPosted: Tue May 10, 2011 5:36 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
sagar474 wrote:
if I use CD/DVD.

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: how to load fiels and kernal from boot loader
PostPosted: Tue May 10, 2011 2:13 pm 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: how to load fiels and kernal from boot loader
PostPosted: Wed May 11, 2011 5:08 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: how to load fiels and kernal from boot loader
PostPosted: Wed May 11, 2011 5:30 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], cloudapio, DotBot [Bot], Google [Bot] and 78 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group