####   system constant physical addresses

# the low k of memory can be used for, uh, uh...
#  	a jump-zero catcher?					<<==
#	addressless constants? 
#		zero B
#		= @ 16 B to A		# 0x0000ffff   perhaps
#	just leave the wake-up vexors there for reference?      <<--

#### 	BIOS data area


		   BDA=0x400
	      BDserial=0x400
	    BDparallel=0x408
	    BDhardware=0x410
	       BDvmode=0x449
            BDvcolumns=0x44a
	       BDvport=0x463
	       BDvrows=0x484
	  BDfontheight=0x485


	     IDT=0x1000    	# to 0x17ff, 2k up. IDT8, pmode, the default.
	IDT32unP=$((IDT+k1+k1))  	# Fourreal Mode, USE32, 4-byte vexors
#	IDT32unP=$((0xb8000))		# Fourreal Mode, USE32, 4-byte vexors
	   IDT16=$((IDT32unP+k1))  	# real mode IDT.
	  IDT16P=$((IDT16+k1))   	# Veal Mode	
	 legvecs=$((IDT16P+k1+k1))	# copy of wake-up vexor table


	     	   sty=0x3400	# Squeal Mode Code sty
				#   to 0x3bff should suffice
		wallow=0x3c00	#     Squealers like to wallow.

## basic buffers
#  mouse

	      auxring=0x5000	# 1k-aligned for easy masking
	  auxringmask=1023	# value, not address
	    auxlubber=0x5400	# pointer into ring
	auxpacketbyte=0x5408	# which byte of the 8 in a mousepacket
	   auxcounter=0x540c	# total bytes ringed for lap comparisons

# kbd
	      keyring=0x5600	# bytepage-aligned for easy masking
	  keyringmask=255	# value, not address
	    keylubber=0x5700	# pointer into ring
	       was_e0=0x5708
	   keycounter=0x570c	# total bytes ringed for lap comparisons
	      numlock=0x5710




	# Counter and lubber are somewhat redundant
	#   and need to be reset at every other blue moon.

# begin system miscellaneous data area

		  megs=0x7000		# RAM on the box		
		 ticks=0x7010		# NMI counter, 64 bits 

# end system miscellaneous data area

		   IPL=0x7c00

# real mode event handlers have to be in legmeg. It looks like at least
#  the jumps to Forreal Mode event handlers have to reside in legmeg.















echo "
		# size-aligned system buffers in low end of meg 1
		# Size-alignment is at data 0, with strand metadata 
		# immediately below in lower addresses.
		# That means allocate the big ones with little ones
		# below them, which makes for a treeish thingy.


smno=$((cell*8))	# strand metadata negative offset from data0

	ring64a=$((meg+k64-smno))
		ring16a1=$((meg+k16-smno))
		ring16a2=$((meg+k16+k16+k16-smno))

	ring64b=$((meg+k64+k64+k64-smno))
		ring16b1=$((meg+k64+k64+k16-smno))
		ring16b2=$((meg+k64+k64+k16+k16+k16-smno))

	ring64c=$((meg+k64+k64+k64+k64+k64-smno))
		ring16c1=$((meg+k64+k64+k64+k64+k16-smno))
		ring16c2=$((meg+k64+k64+k64+k64+k16+k16+k16-smno))

NMIring=$((ring64a+smno))


# meg, k1 and bitN globals went into osimplay. 
#    They aren't even 386-specific.


#########################################################################

#echo first byte past ring buffers is ...
#bases $((ring16c2+k16+smno))

# Instantiate a ring during init at e.g. ring64c and data0 of that ring is
# at ring64c+smno, which is 64k-aligned. With the stack right above the
# rings, 16k or so past the last ring might be a good place to check for
# SP underrun once in a while at odd times,  and shriek if an SP gets
# there.

A PC has things mapped in it's physical memory space that you can't or
don't want to clobber, like BIOS ROMS. The ones that interest me are
listed below from Ralf Brown's, with Ha3sm considerations and stationary
memory items interlaced.

Stuff that wants to interact with PC legacy stuff like BIOS code MUST be
in the low meg. Basically. The Pentium memmaps the IOAPIC to the high half
of the address-space.



Ralf sez...
MEM 0000h:0000h R - INTERRUPT VECTOR TABLE
Size:   1024 BYTEs
_____Keep this and convert it to 32-bit and keep that. 


BDA=0x400
MEM 0000h:0400h - BIOS DATA AREA
Size:   256 BYTEs
BIOSserial=0x400
	MEM 0040h:0000h - BASE I/O ADDRESS OF FIRST SERIAL I/O PORT
	MEM 0040h:0002h - BASE I/O ADDRESS OF SECOND SERIAL I/O PORT
	MEM 0040h:0004h - BASE I/O ADDRESS OF THIRD SERIAL I/O PORT
	MEM 0040h:0006h - BASE I/O ADDRESS OF FOURTH SERIAL I/O PORT
BIOSparallel=0x408
	MEM 0040h:0008h - BASE I/O ADDRESS OF FIRST PARALLEL I/O PORT
	MEM 0040h:000Ah - BASE I/O ADDRESS OF SECOND PARALLEL I/O PORT
	MEM 0040h:000Ch - BASE I/O ADDRESS OF THIRD PARALLEL I/O PORT
	MEM 0040h:000Eh - BASE I/O ADDRESS OF FOURTH PARALLEL I/O PORT 
			(pre-PS/2)
	MEM 0040h:000Eh - SEGMENT OF EXTENDED BIOS DATA SEGMENT 
			(PS/2, newer BIOSes)
BIOShardware=0x410
	MEM 0040h:0010h - INSTALLED HARDWARE
	Size:   WORD
	SeeAlso: INT 11

	Bitfields for BIOS-detected installed hardware:
	Bit(s)  Description     (Table M0006)
	 15-14  number of parallel devices
	        00 or 11 sometimes used to indicate four LPT ports
	 13     (Convertible, PS/2-55LS) internal modem
	 12     game port installed
	 11-9   number of serial devices
	        000 or 111 sometimes used to indicate eight COM ports
	 8      reserved
	 7-6    number of floppy disk drives (minus 1)
	 5-4    initial video mode
	        00 EGA,VGA,PGA, or other with on-board video BIOS
	        01 40x25 CGA color
	        10 80x25 CGA color
	        11 80x25 mono text
	 3-2    (PC only) RAM on motherboard
	        00 = 16K, 01 = 32K, 10 = 48K, 11 = 64K
	        (some XTs) RAM on motherboard
	        00 = 64K, 01 = 128K, 10 = 192K, 11 = 256K
	 2      (pre-PS/2 except PC) reserved
	        (PS/2, some XT clones, newer BIOSes) 
			pointing device installed
	 1      math coprocessor installed
	 0      floppy disk drives are installed
	        booted from floppy

	MEM 0040h:0041h - DISKETTE - LAST OPERATION STATUS
	Size:   BYTE
	SeeAlso: MEM 0040h:003Eh,MEM 0040h:0042h,INT 13/AH=01h

	Bitfields for diskette last operation status:
	Bit(s)  Description     (Table M0014)
	 7      drive not ready
	 6      seek error
	 5      general controller failure
	 4-0    error reason
	        00h no error
	        01h invalid request/parameter
	        02h address mark not found
	        03h write-protect error
	        04h sector not found
	        06h diskette change line active
	        08h DMA overrun
	        09h DMA across 64k boundary
	        0Ch media type unknown
	        10h CRC error on read
	Note:   the following values for this byte differ somewhat from the
	          bitfield definition above:
	            30h drive does not support media sense
	            31h no media in drive
	            32h drive does not support media type
	            AAh diskette drive not ready
BIOSvmode=0x449
	MEM 0040h:0049h - VIDEO - CURRENT VIDEO MODE
BIOSvcolumns=0x44a
	MEM 0040h:004Ah - VIDEO - COLUMNS ON SCREEN
	MEM 0040h:004Ch - VIDEO - PAGE (REGEN BUFFER) SIZE IN BYTES
	MEM 0040h:004Eh - VIDEO - CURRENT PAGE START ADDRESS IN REGEN BUFFER
	MEM 0040h:0050h - VIDEO - CURSOR POSITIONS
	MEM 0040h:0060h - VIDEO - CURSOR TYPE
	MEM 0040h:0062h - VIDEO - CURRENT PAGE NUMBER
BIOSvport=0x463
	MEM 0040h:0063h - VIDEO - CRT CONTROLLER BASE I/O PORT ADDRESS
	MEM 0040h:0067h - RESET RESTART ADDRESS
	MEM 0040h:0074h - FIXED DISK LAST OPERATION STATUS (except ESDI drives)
	MEM 0040h:0074h - WD1002-27X SuperBIOS - TOTAL DRIVES, FIRST CONTROLLER ONLY
	MEM 0040h:0075h - FIXED DISK - NUMBER OF FIXED DISK DRIVES
	MEM 0040h:0078h - PARALLEL DEVICE 1 TIME-OUT COUNTER
	MEM 0040h:0079h - PARALLEL DEVICE 2 TIME-OUT COUNTER
	MEM 0040h:007Ah - PARALLEL DEVICE 3 TIME-OUT COUNTER
	MEM 0040h:007Ch - SERIAL DEVICE 1 TIMEOUT COUNTER
BIOSvrows=0x484
	MEM 0040h:0084h - VIDEO (EGA/MCGA/VGA) - ROWS ON SCREEN MINUS ONE
BIOSfontvertical=0x485
	MEM 0040h:0085h - VIDEO (EGA/MCGA/VGA) - CHARACTER HEIGHT IN SCAN-LINES
	MEM 0040h:00A2h - RESERVED FOR NETWORK ADAPTERS
	Size:   6 BYTEs


MEM 0000h:0500h - DATA AREA
	Size:   256 BYTEs
__not much specific on this, but leave it alone anyway


0x1000  4k, start Ha3sm stuff here. 
**********************************

IDT=0x1000 
pmode IDT
0x1000 to 0x17ff
2k

BGDT=0x1800
big Global Descriptor Table, when we're a real OS
8k, to 0x28ff

legmegIDT=0x3000 

IPL=0x7c00
0x7c00 to 0xffff	
33k
initial program (stage 2) load area
  MEM 0x7c00 Address of initial OS/program load on all PCs. size=512 bytes.
  One floppy cylinder is typically 18k. Initial GDT will be in there
  somewhere I guess.

BGDT=0x10000
  

these two could speed things up
RBIOS=0xe0000
Copy 0xf0000->fffff  to 0xe0000
RVDBIOS=0xd0000
Copy 0xc0000->cffff  to 0xd0000
	
MEM A000h:0000h - EGA+ GRAPHICS BUFFER
	
MEM B800h:0000h - CGA TEXT/GRAPHICS BUFFER
	
MEM C000h:0000h - VIDEO BIOS (EGA and newer)

MEM C800h:0000h - HARD DISK BIOS
	Size:   varies (usually 8K or 16K)
___HANdy. Is the BIOS code segment BASED at c800:?

MEM F000h:E000h - ORIGINAL IBM PC ROM BIOS
	
MEM F000h:FFF0h - RESET JUMP00h of FAR function: Get ???
	
MEM F000h:FFF5h - ASCII BIOS DATE
	Size:   8 BYTEs

openRAM=0x100000
begin contiguous RAM

Don't decide on much else 'till it comes up. 

" > /dev/null
