gauthier@ntmtv.UUCP (Jay Gauthier) (11/23/89)
OK, so we're writing a device driver for the MAC. We use MPW 3.0 Pascal. This is our first driver attempt. We've heard miscellaneous rumors about the dreaded 32K boundary. For the first six months, things were great, we coded away and the driver was running great. But then ... We hit the limit. No bells rang, no whistles blew, the MAC police didn't come and arrest us. The only sign that something was amiss was a link message: ### Segment: MyDrvr, size = 32924 In ResEdit I verified that the DRVR resource was indeed that length, everything looked okay. Being a rebel and a daredevil, I went ahead and ran the thing. Everything looks okay. Question: Is everything really okay? Was something truncated to 32K? And if there is a problem, what can we do about it? Thanks in advance, Jay -- Jay Gauthier BNR, Mountain View CA (415) 940-2101 uucp: {hplabs,amdahl,ames}!bnrmtv!gauthier
allanh@netcom.UUCP (Allan N. Hessenflow) (11/24/89)
In article <363@ntmtv.UUCP>, gauthier@ntmtv.UUCP (Jay Gauthier) writes: > > OK, so we're writing a device driver for the MAC. We use MPW 3.0 > Pascal. This is our first driver attempt. We've heard miscellaneous > rumors about the dreaded 32K boundary. For the first six months, > things were great, we coded away and the driver was running great. > > But then ... > > We hit the limit. No bells rang, no whistles blew, the MAC police > didn't come and arrest us. The only sign that something was amiss was > a link message: > > ### Segment: MyDrvr, size = 32924 > Everything should indeed be OK. The 32k limit is due to the use of 16 bit offsets (+-32k) for both code and a5 relative data. The restriction you're most likely to run into with a driver is the jump table which points at the various driver entry points. As long as the link completed, they are in range. If you end up with one of the routines out of range, you can simply move the offending routine closer to the beginning of the code. See the MPW 3.0 Release Notes, page 21, for more information. -- apple!netcom!allanh allanh@netcom.uucp
oster@dewey.soe.berkeley.edu (David Phillip Oster) (11/24/89)
Here are the problems with a device driver over 32k: 1.) a bug in the original Mac ROMS (circa '84) prevented resources from being larger than 32k. This is fixed in every machine since the the Mac512KE. Does your driver work on ALL macs? 2.) Many compilers use 16 bit signed offsets from the program counter for branches and procedure. This means, if you attempt to call or go to a spot more than 32767 bytes away from the present one, it will crash (if you are lucky. If you are unlucky, it will jump into your hard disk reformat routine.) (You can extend things a little by jumping to carefully placed "islands" of jump instructions, than in turn jump to the destination.) 3.) The format of a device driver includes a preamble with offsets to the entry points for the open, close, control, status & prime (read/write) routines. These offsets are signed 16 bit numbers. and interpreted relative to the beginning of the driver. See note 2 above. 4.) Some linker authors, knowing about the above problems, designed linkers that produce buggy code above 32k, on the silly grounds that nobody would do such a thing anyway. I don't know if MPW is one of these. THINK C just gives you an error message and refuses to link. --- According to the Constitution, the Constitution is unconstitutional: --- David Phillip Oster --U.S.Constitution I.10.1: "No State shall Arpa: oster@dewey.soe.berkeley.edu --enter into any treaty, alliance, or Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu -- confederation..."
earleh@eleazar.dartmouth.edu (Earle R. Horton) (11/24/89)
In article <32784@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) writes: >Here are the problems with a device driver over 32k: >1.) a bug in the original Mac ROMS (circa '84) prevented resources from >being larger than 32k. This is fixed in every machine since the the >Mac512KE. Does your driver work on ALL macs? I believe this bug only affects writing resources over 32k, and not reading. I remember using old versions of MacKermit, compiled with the Sumacc compiler, where the CODE resource was well over 32k, and having no problems on 64k ROM machines. Earle R. Horton