[comp.os.minix] need test site for expanded memory

tholm@uvicctr.UUCP (Terrence W. Holm) (05/19/88)

EFTH Minix request  - May 1988 -  need test site for expanded memory


We are looking for Minix users who would like to test
our "expanded" memory handler on their PC/XT.

We converted to "expanded" memory because our two AT clone
keyboards would not work with "extended" memory. (Yes,
its true.)

The following code has been tested on AT's with real
Intel Above Board "expanded" memory. We want someone
with a PC/XT to try this code. If you know about the
real hardware for the expanded memory, then please tell
us - or fix up this code to the standard. [We had to
reverse engineer the card and disassemble LIM 4.0 to
obtain what we have so far.]

If you are not willing to operate as a Beta test site,
then ignore this posting. Hopefully some people will
be able to help us all obtain a general extended/expanded 
interface for the RAM disk.

[I have tried to contact Bob Eager and Dr. Tanenbaum 
concerning this code, but the network must have dropped
the email to never-never land.]

		----------------------

To install this you must do all of Tanenbaum's updates for
"extended" memory, then insert this routine into klib88.s
INSTEAD of his "em_xfer".

Note that you must update definitions for where the i/o
location is (see the switches on your memory card) and
where to place the mapped-in pages into memory. Only
the stretches C0000-CFFFF or D0000-DFFFF can be used (see
if there is anything else in the way, like a disk controller).


------------------------------cut here-----------------------------

|===========================================================================
|                		em_xfer
|===========================================================================
|
|              (Changed from extended memory,    1988-May-1  efth)
|
|
|  status = em_xfer( source, destination, count );
|
|
|    Where:
|       source      : Address (000000-09fffe, 100000-2ffffe)
|	destination : Address (000000-09fffe, 100000-2ffffe)
|       count       : Number of words to transfer (0-2000) [16Kb max]
|	status      : Always 0 (OK)
|
|
|  Execute a transfer between user memory and expanded memory.
|
|  The source and destination can be in either the lower 640K, or on
|  the first 2Mb expanded memory card, they must be on a word boundary.
|  Two 16Kb pages are mapped in for an expanded memory reference, so
|  that up to 16Kb can be transferred without worrying about the page
|  boundary.
|
|  Note "EXP_PORT" must be changed to match the strapping on your expanded
|  memory card. "MAP_PAGE" and the "MAP_DATA" table must be set for either
|  0xc000 or 0xd000.


EXP_PORT  = 0x0258		|  First i/o port to control expanded memory
NEXT_PORT = 0x4000		|  Offset to higher ports

MAP_PAGE  = 0xc000		|  Where the expanded memory appears
NEXT_PAGE = 0x0400		|  Pages are 16K

MAP_DATA:			|  Tells mem. card where to map in pages
	.byte	0x80		|  Change to 0x80,0,0x80,0 for
	.byte	0		|          MAP_PAGE = 0xd000
	.byte	0
	.byte	0

|
_em_xfer:
	push	bp		|  Save registers
	mov	bp,sp
	push	bx
	push	cx
	push	dx
	push	si
	push	di
	push	ds
	push	es

	pushf			|  Save DF flag
	cld			|  Auto increment (DF = 0)


|  Load the 4 bit mapping data into the expanded memory card, so
|  that it knows which set of addresses to use to map in the pages.

	mov	si,#MAP_DATA
	mov	cx,#4
	mov	dx,#EXP_PORT+1	|  i/o addrs of map registers

set_up:
	lodb			|  Load from MAP_DATA vector
	outb			|  Only the top bit is used
	add	dx,#NEXT_PORT
	loop	set_up


|  Process the source address

	mov 	ax,6(bp)	|  Source msb
	testb	al,*0xf0	|  Test if in low memory
	jnz	s_exp		|  Jump if not

	movb	cl,*12
	shl	ax,cl		|  Make into segment + offset
	mov 	bx,4(bp)	|  Source lsw
	movb	cl,*4
	shr	bx,cl
	add	ax,bx
	mov	ds,ax		|  Source segment
	mov	si,4(bp)
	and	si,#0x000f	|  Source start address
	jmp	get_dest

s_exp:				|  Source is in expanded memory
	subb	al,*0x10	|  Addr. 100000 is 0 on card
	shlb	al,*1
	shlb	al,*1
	mov	bx,4(bp)	|  Source lsw
	movb	cl,*14
	shr	bx,cl
	addb	al,bl		|  7 bit page selection (128 * 16K = 2Mb)
	orb	al,*0x80	|  Set the enable bit
	mov	dx,#EXP_PORT
	outb			|  Map in the page
	incb	al
	add	dx,#NEXT_PORT
	outb			|  Map in the following page
	mov	ax,#MAP_PAGE
	mov	ds,ax		|  Source segment
	mov	si,4(bp)
	and	si,#0x3fff	|  Source start address


|  Process the destination address

get_dest:
	mov 	ax,10(bp)	|  Destination msb
	testb	al,*0xf0	|  Test if in low memory
	jnz	d_exp		|  Jump if not

	movb	cl,*12
	shl	ax,cl		|  Make into segment + offset
	mov 	bx,8(bp)	|  Destination lsw
	movb	cl,*4
	shr	bx,cl
	add	ax,bx
	mov	es,ax		|  Destination segment
	mov	di,8(bp)
	and	di,#0x000f	|  Destination start address
	jmp	copy

d_exp:				|  Destination is in expanded memory
	subb	al,*0x10	|  Addr. 100000 is 0 on card
	shlb	al,*1
	shlb	al,*1
	mov	bx,8(bp)	|  Destination lsw
	movb	cl,*14
	shr	bx,cl
	addb	al,bl		|  7 bit page selection (128 * 16K = 2Mb)
	orb	al,*0x80	|  Set the enable bit
	mov	dx,#EXP_PORT+NEXT_PORT+NEXT_PORT
	outb			|  Map in the page
	incb	al
	add	dx,#NEXT_PORT
	outb			|  Map in the following page
	mov	ax,#MAP_PAGE+NEXT_PAGE+NEXT_PAGE
	mov	es,ax		|  Destination segment
	mov	di,8(bp)
	and	di,#0x3fff	|  Destination start address


|  Execute the copy

copy:
	mov 	cx,12(bp)	|  Number of words to copy

	rep			|  CX times
	movw			|  DS:SI  ->  ES:DI


|  Restore registers

	popf
	pop	es
	pop	ds
	pop	di
	pop	si
	pop	dx
	pop	cx
	pop	bx
	pop	bp

	mov	ax,#0		|  Return code = 0
	ret

------------------------------cut here-----------------------------

               Terrence W. Holm
                  {uw-beaver,ubc-cs}!uvicctr!sirius!tholm