Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Management

Status
Not open for further replies.

adholioshake

Programmer
Feb 9, 2003
136
Hi tek people.

I have been trying to write a simple operating system for a while and I am stuck on the memory management. The problem is how memory is organized after 1Mb.
The first thing that has to be done is enable the A20 line, and I have done that. But what does that actually do?
To access memory above 1Mb I am sure I have to do some page swapping for the EMS, but I am not sure how to do this.

Anyone have any ideas?


The mind is like a parachute - it works better when open...
 
adholioshake,

I haven't done this before. So I might be wrong here :)

Just from what I know (read), A20 only to enable/disable access to High Memory Area (HMA). To access memory above 1 meg you can try to look here. I am not sure whether it helps or not

Look for INT 67:

Regards

-- AirCon --
 
I wouldn't bother. All that the A20 address line thing is is this: In theory the idea of 16-bit mode addressing was that by shifting the segment register 4 bits you could create a 20bit address (1Mbyte). But then some bright spark realised that if you add $FFFF0 to $FFFF you get more than $FFFFF, the original intended limit. You can in fact address a little more than the Mbyte. This means a carry-over on the addition into a 21st bit of address. But bits are numbered from 0, so this is address bit 20, hence A20. The correct behaviour of a machine with only just enough register space to hold the number would be to wrap-around and confine the result to 20 bits. But of course as machines developed more than 20 bits of address, a decision had to be made about whether to wrap around or set the 21st bit. That is what A20 decides.

If you are writing for a dos environment, then depending on config.sys the extra space up the top has probably already been used by dos, so you can't use it anyway. If you want to get your hands on lots more memory, you are quite right to think about EMS or XMS, or of course moving to a 32bit system where the memory is addressable without further ado.
 
Looking at Intel architecture documentation, I think the way to do it is by using a GDT or LDT and use the extra control registers (CR0, CR2, CR3, CR4).


The mind is like a parachute - it works better when open...
 
Sorry, yes, I failed to read that you are actually trying to do the operating system from scratch. In that case yes, you absolutely need to decide whether you are aiming to use the processor in 16bit or 32bit protected modes. If you are in 32bit mode then you need to know all about those extra registers and tables, and that a segment register is now an entry into a table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top