Page 1 of 1
Bootloader , TextFiles
Posted: Sat Apr 28, 2012 9:48 am
by LindusSystem
I have my bootloader somewhat working, it can read Files form a FAT12,16 FS from a Floppy.
It is 2stage, bootsector loads the 2nd stage.
I can open a file named abc.abc from the root dir, I have some text in it and I wish to read what is in it, how can I do that?
Exactly what I mean is to read a text form a file after it is loaded to memory.
EDIT:
What I am trying is to read a text file containg information wheather to load the kernel in real mode or in protected mode ,paging?,etc
I just want to load the string and look whats in it.
Re: Bootloader , TextFiles
Posted: Sat Apr 28, 2012 10:54 am
by Yoda
What do you mean under "reading"?
Displaying the text on the screen?
If so, you need to load executable code by your loader which will print the text on the screen.
Download the archive with OS Boot Tools from the link in my signature, there you'll find the source of very simple demo kernel. That kernel may be loaded at any location and it prints a couple details about your system. There you may find some useful printing utilities.
Re: Bootloader , TextFiles
Posted: Sat Apr 28, 2012 11:06 am
by LindusSystem
Mine can print text but I wanted to load a text file from the root, which I can.Then I just want to take the text and compare.
But i have no idea how to get the text.
I was looking at your tool, nice, but a bit complex for me.
Thank You
Re: Bootloader , TextFiles
Posted: Sat Apr 28, 2012 11:08 am
by egos
Load and parse the file.
Re: Bootloader , TextFiles
Posted: Sat Apr 28, 2012 11:13 am
by Yoda
LindusSystem wrote:Mine can print text but I wanted to load a text file from the root, which I can.Then I just want to take the text and compare.
For this you need to add the device drive to you kernel, then file system driver. After that you'll be able to parse disk structures and load files.
Re: Bootloader , TextFiles
Posted: Sat Apr 28, 2012 9:42 pm
by LindusSystem
Mine supports FAT12/16,Floppy and I am able to start my kernel(Kernel is a blank printing just text), What I am trying is to edit my bootloader and keep a configuration file which will contain the kernel environment details according to which the bootloader must setup.
So ,till now I have loaded my config file into memory at 0x7C10.But my question is how can I read it?(Read the text and perform the tasks accordingly.
Yoda, You told you need FS Driver, those things I know before reading a file, I have read so much theory in my studies/ but I have ever done any thing in practical.
Re: Bootloader , TextFiles
Posted: Sun Apr 29, 2012 1:10 am
by LindusSystem
Currently I am loading my textfile @ 0x1000...(1MB), I want to take the text from that locaton and look fo a word PMode and if present i wish to go to pmode.
I am still stuck up.
Re: Bootloader , TextFiles
Posted: Sun Apr 29, 2012 3:37 am
by Brendan
Hi,
LindusSystem wrote:Currently I am loading my textfile @ 0x1000...(1MB), I want to take the text from that locaton and look fo a word PMode and if present i wish to go to pmode.
If your problem is accessing data you've loaded above 0x00100000 in real mode, then how did you get the text file at 0x00100000 in the first place?
If your problem is searching an area of memory for a sequence of bytes (e.g. searching for the substring 'PMode' within an array of char); then break it into 2 problems:
- An outer loop that searches for the first byte (e.g. find each occurrence of the byte 'P')
- An inner loop that that checks if the bytes after the first byte are what the should be
Note: the inner loop could be simplified in this specific case, by doing something like "cmp [esi+1],'Mode' " to check 4 bytes at once.
If your problem is implementing a more complete parser, then break it up into many smaller problems - e.g. a piece of code to skip white space, a piece of code to extract/validate a string, a piece of code to extract/validate an integer, etc. Then have a "while(address < end_address)" loop that calls these routines.
If your problem is figuring out how to turn something simple (text parsing) into a hideously over-complicated and bloated nightmare, just use XML.
If your problem is something else, provide a more accurate description of the problem...
Cheers,
Brendan
Re: Bootloader , TextFiles
Posted: Sun Apr 29, 2012 3:47 am
by bluemoon
Re: Bootloader , TextFiles
Posted: Mon Apr 30, 2012 11:17 pm
by LindusSystem
I made a easier solution ,now I am searching for KRNMODE File in the disk for loading kernel in PMode ,if the file is not found then I will load the kernel in RealMode with nothing, same as the BIOS loading the bootsector(except GDT,etc).
If I get a solution to read my text files, I will post the solution here.