Bootloader , TextFiles

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
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Bootloader , TextFiles

Post 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.
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: Bootloader , TextFiles

Post 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.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Re: Bootloader , TextFiles

Post 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
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Bootloader , TextFiles

Post by egos »

Load and parse the file.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: Bootloader , TextFiles

Post 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.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Re: Bootloader , TextFiles

Post 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. :)
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Re: Bootloader , TextFiles

Post 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. :D

I am still stuck up.
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Bootloader , TextFiles

Post 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. :D
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Bootloader , TextFiles

Post by bluemoon »

If you want an interpreter in the boot loader to run the text script; then break it into 4 problems:
  • Lex parser that parse the text into object tree
  • JIT engine that turn tree into intermediate code
  • Runtime support for the intermediate code
  • interpreter that maintain the execution context of the intermediate code
I'm trolling :twisted: :twisted: :twisted:
LindusSystem
Member
Member
Posts: 63
Joined: Sat Apr 28, 2012 9:41 am
Location: Earth -> Asia

Re: Bootloader , TextFiles

Post 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).

:D
:D

If I get a solution to read my text files, I will post the solution here.
Anyone has a idea of making a ntfs bootsector?if yes PM me , plz.
Post Reply