Re: Generic bootloader
Posted: Sun Dec 09, 2012 3:25 am
You should not rely on custom MBR as part of the boot sequence. AFAIK It will be overwritten by installing Windows, FreeBSD and whatnot.
For the API, due to the limited space I suggest to squeeze a bit out of it:
There is only open and read (ie. no close), an example interface (from my boot code) would then look like this:
The above code is not suitable for generic boot loader without cleaning up, but should be enough for inspiration.
For SPACE vs TAB, this can never end, so I would suggest just let the code formatter do the job (manually or automatically)
For the API, due to the limited space I suggest to squeeze a bit out of it:
There is only open and read (ie. no close), an example interface (from my boot code) would then look like this:
Code: Select all
; HANDLE OpenFile(const char* filename);
; INPUT
; si -> filename
; OUTPUT
; eax = HANLDE of file, 0 if not found
; HANDLE ReadFile(HANDLE handle);
; INPUT
; eax = HANLDE of file
; di -> Data Buffer (must be big enough)
; OUTPUT
; eax = HANLDE of file (May be changed), 0 if end of file
; ecx = bytes read
Note : Assume CS,DS,ES are zero
For example, on FAT, EAX is used as cluster number internally, and each read return a cluster-size data.
The usage would be:
handle = FileOpen(filename);
while ( (handle=FileRead(handle,buffer)) != 0 ) {
copy buffer to high address
}
For SPACE vs TAB, this can never end, so I would suggest just let the code formatter do the job (manually or automatically)