News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Where is BIOS?

Started by dncprogrammer, February 25, 2006, 03:16:15 PM

Previous topic - Next topic

dncprogrammer

Good morning,
I have been still working on my no-OS loader. I am booting from drive 0, which loads to 07c00h. Boot works fine, displays message and such. The boot then read a few sectors which contain my loader program which right now is just a simple options program. I have been reading my RBIL memory map and trying to tighten up exactly where I want my loader to reside in order to leave maximum area for my transient programs to load in the future. It appears from the memory map that the last useful information leaves off around 080c0h, so is a byte after that a safe starting area to load my code and assume that anything up to my stack area at the top of that segment is fair game for loading transient code?

jon

MichaelW

Except for very old systems, you can generally depend on being able to use anything above the BIOS data area and below 'A' block. IIRC depending on the system configuration the BIOS may use some memory directly below 'A' block, I think not more than about 1 KB. So the usable absolute address range should be 500h to 9fbffh. Have you considered using the HMA?

eschew obfuscation

dncprogrammer

Hi Michael,
When you refer to the 'A' block you are talking about video memory, right? What about 'HMA', is that high memory you are talking about?
jon

MichaelW

Hi Jon,

Yes and yes. The 'A' is the first hex digit of the address of the 64KB block of address space into which the graphics display buffer is mapped. "B" block is also used for video memory (the alphanumeric display buffer, font storage, and at one time mono graphics), and 'C' block contains the VGA BIOS. The High Memory Area (HMA) is a 65520-byte block of "extended" memory that can be accessed from real mode in the address range FFFF:0010 to FFFF:FFFF. To use it you basically just enable the A20 address line and use FFFFh for the segment address.

eschew obfuscation

dncprogrammer

Hello Michael,
I am familiar with what you are talking about, that is a good thing! At this time I am still working on getting the basics put into place; the loader, and a transient of some sort, and a consistent way to return to the loader once the transient is done. Something along the lines of a really simple int20h or dos's 04ch/21h. I still have to write some ISRs for my file handling so that the experimenting is easier, hacking sectors into memory works but its time consuming without any closed system. Two notes ago you made a mention of high memory. What do you suggest I use the HMA for? My loader? or an extra segment? There is about 64k up there, right?
thank you so much!
jon

PBrennick

You cannot move the loader, the need for it to be at 07c00h is hardcoded. Or you could probably do a bootstrap from 07c00h to HMA.  As soon as you set the A20 line it will switch on the address Michael told you and the rest of your loader could be programmed to resume there.  But the loader is done and working, why screw around with it.
Paul
The GeneSys Project is available from:
The Repository or My crappy website

dncprogrammer

Hi Paul,
I think you are missing what we were talking about, my "loader" isn't the bootstrap code, it is more like what you would call the kernel. I have chosen to call it the loader because when the system is running it will be the process that loads user processes. I have no desire to try to change anything about the bootstrap process, it gets up, puts my loader in place, and and goes away. Im talking about options for where to put my "loader" as not to take up any valuable space.
jon

PBrennick

Sorry, your terminology confused me.  Michael is the one who really knows this stuff, anyway.  My knowledge is really too old these days, senile decay and all that rot.

EDIT:  I can't help it, I gotta say something.  Now that I know what your loader is and what your intentions are.  If you move it into the HMA and then load transients into both lower and upper you will play havoc and have to watch you don't trash your loader.  I still say leave it where it is, the memory is NOT precious because you still have the same amount free either way.  Of course, if you are going to load transients only into lower memory...

Paul
The GeneSys Project is available from:
The Repository or My crappy website

dncprogrammer

Hi Paul,
I was sure that I hadn't defined my "loader" as the non traditional so I appologize for making this thread somewhat confusing. I looked up some info on the A20 gate and found that there are quite a few ways to deal with it but Im sure that with the equipment I am working on there will be a BIOS routine for testing and/or setting. I will get to that a little later.
I wanted to comment on one thing that you said that gave me a laugh. You asked, "why screw with it", and it occured to me that the question could be an oxymoron for any assembly language programmer. Thats what we do.

jon

PBrennick

... and we love it.  You are right.   The A20 line is on the processor so it is available in the BIOS if the BIOS allows you to modify it.  Now for the fun part.  If it does not allow that, then learn how to write a BIOS Flash Update.  NOW THAT WOULD BE SCREWING WITH IT!

Paul
The GeneSys Project is available from:
The Repository or My crappy website

dncprogrammer

Well done Paul,
I am just on the tip of the iceberg here. I have been reading like crazy but I have so much to test yet. I have successfully implemented most of what we have been talking about, with the exception of messing with high memory. I realized that I my code was like a tennisball in a an open room and that just won't do. I want to understand how to read these memory maps so that I can put my code in all of the right places. I tried to put the loader in too low and I had problems that I couldn't justify by my documentation so I came here for some insight. I am trying the low area of 0000:0500h for my loader (kernel) code to see if it runs over anything. If that is successful then I will move it up 1K and implement my little data area for the loader. Then Im set for now. The loader hangs around just over it's data area and I take commands from the user loading their code just above the loader. Maybe it becomes clear why I decided to call it the loader. I just need to decide how to implement my disk handling ISRs. Im getting there, slowly. One brick at a time, right.
jon

dncprogrammer

Here is how it lays out on paper: (very simple, don't make fun)


0000:0000h to 0000:04FEh     BIOS area (somewhat machine specific)
0000:0500h to 0000:0900h     My loader's data area
0000:0901h to 0000:1501h     My loader code (stays resident)
0000:1502h to 0000:FDFEh     Transient program area
0000:FDFFh to 0000:FFFEh      Stack (512Bytes)

That is my simple single-segment (16bit) setup. I will venture out from there. Where could I put my ISR's ?
jon

MichaelW

Jon,

There is some A20 address line stuff here:

http://www.masmforum.com/simple/index.php?topic=339.15

The low memory area from absolute address 000 to 3FFh is the interrupt vector table, the lower half of which is pretty much essential, and from 400h to 4FFh is the BIOS data area, essential for BIOS operation, some of it even if you do not call any BIOS functions.

The complete source code (including device drivers, memory manager, etc) for a 32-bit protected mode operating system is available here:

http://www.sensorypublishing.com/mmurtl.html


eschew obfuscation

dncprogrammer

Wow Michael,
Good stuff. I just got my loader back on line. It didn't like that way that I was addressing. Im still new at this. Thank you for all of your help.
jon

dncprogrammer

Michael,
Did you have a chance to see my post a few replies ago, the memory map? Is that solid? It worked, but Im no so sure that my stack was in the right place, and was it large enough?
jon