[comp.sys.cbm] memory management

bowen@cs.Buffalo.EDU (Devon E Bowen) (08/15/89)

I'm having some trouble shutting down the kernel area for the project I
am working on. I was hoping someone had experience in this area and
could help me out. I'm using a 128 in 64 mode.

I'm working under C Power which seems to shut down the BASIC ROM for
extra program space, but it leaves the I/O section and the kernal ROM.
I need some extra buffer space for my code and I don't need any of the
kernal functions, so I want to shut down that ROM area. I grab byte
$01, and it with $fd (to clear the kernel ROM bit) and put it back.
Now before I do this, I set up the system hardware vectors at the top
and I can tell that they work great with the new vectors, so I know
the ROM is getting shut off. The problem is that the program hangs in
one of my functions that writes to the 80 column chip. This function
has been fully tested and I know it's not a bug in the function. Now
what I *think* is happening is that when I shut off the kernel ROM,
I'm also somehow shutting off the I/O area! This would make the 80
column chip invisible and the function would hang. Now I don't know
how this could happen since all I touched was the kernel ROM bit in
that byte. Maybe an undocumented feature? Or a documented feature I
missed in my reading? Maybe having both the BASIC ROM and kernal ROMs
shut off automatically shuts off the I/O area? Can I get it back (I
would even be will to short out some leads on the expansion bus if
need be)?

Any help would be *greatly* appreciated...


Devon Bowen (KA2NRC)		FAX:	   (716) 636-3464
University at Buffalo		BITNET:    bowen@sunybcs.BITNET
				Internet:  bowen@cs.Buffalo.EDU
UUCP: ...!{watmath,boulder,decvax,rutgers}!sunybcs!bowen

ecarroll@csvax1.cs.tcd.ie (Eddy Carroll) (08/21/89)

In article <9313@cs.Buffalo.EDU>, bowen@cs.Buffalo.EDU (Devon E Bowen) writes:
> I'm working under C Power which seems to shut down the BASIC ROM for
> extra program space, but it leaves the I/O section and the kernal ROM.
> I need some extra buffer space for my code and I don't need any of the
> kernal functions, so I want to shut down that ROM area. I grab byte
> $01, and it with $fd (to clear the kernel ROM bit) and put it back.

[ Goes on to describe how accessing the 80-column chip locks up the system ]

> Maybe having both the BASIC ROM and kernal ROMs
> shut off automatically shuts off the I/O area?

Hi there, your last comment above is exactly what is happening. When you
switch out the Kernal ROM, this ALWAYS switches out the BASIC ROM as well.
In this situation, Bit 0 of loc $01 now controls whether RAM or I/O is mapped
into the $D000 area. With the bit set, the I/O area is mapped in, with the
bit clear, RAM is mapped in. Since C-Power is clearing that bit, and you then
clear the Kernal bit, you end up with a full 64K of continuous RAM. The
solution is very simple: After ANDing the contents of $01 with $FD, just
OR it with $01 before storing it back.

BTW, as an aside: be very careful if you are accessing the 80 column chip
from within interrupts as well as from your main code. (This caused me some
trouble in a comms package I did 18 months go, which had an onscreen clock).
You need to setup a semaphore to guarantee exclusive access to the registers,
otherwise weird things will happen.

Eddy
-- 
Eddy Carroll               ----* Genuine MUD Wizard  | "You haven't lived until
INTER: ecarroll@cs.tcd.ie                            |    you've died in MUD!"
 UUCP: {..uunet}!mcvax!ukc!cs.tcd.ie!csvax1!ecarroll |  -- Richard Bartle