Memory sizing in NitroOS 9 - nealcrook/multicomp6809 GitHub Wiki

Q: How does the code determine how much (how many pages) of memory are available, and how does it restrict MMU page allocation to memory that actually exists?

A: It is done in krn.asm -- "Setup system memory map" refers to:

  • D.BlkMap 4 bytes "memory block map ptr" - points to start and end of map
  • D.SysMem 2 bytes "system memory map ptr"
  • D.CCStk 2 bytes "pointer to top of CC Memory ($A7)"
  • D.MemSz 1 byte either "# 8k mem blocks that exist" or "128/512 memory flag (CC)"

Q: How are these initialised? How and where is memory assigned for the BlkMap?

A: As follows:

  • D.CCStk is initialised to $2000 in krn (around L001C) - the top of the 1st 8K page, "global memory".
  • D.BlkMap+0 is initialised in krn (around L001C)
  • D.BlkMap+2 is initialised in krn (around L0111).

Each entry represents one 8Kbyte physical block. The end point is set by the memory sizing routine; up to 2MBytes can be accommodated, corresponding to $100 physical blocks.

I found and fixed a benign kernel bug in the way that BlkMap+2 was set.

D.SysMem has 256 entries - represents a map of 256, 256-byte pages in the processor address space -- ie, a total of 64Kbytes that the processor can address directly.

The mc09 MMU can accommodate a 7-bit physical block number (128, 8K pages -> 1MByte)