LisaList2

Advanced search  

News:

2022.06.03 added links to LisaList1 and LisaFAQ to the General Category

Pages: [1]   Go Down

Author Topic: MacWorks XL ROM serial drivers  (Read 14107 times)

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
MacWorks XL ROM serial drivers
« on: May 11, 2020, 04:51:10 pm »

I'm writing an application that uses the Macintosh ROM serial drivers, following Inside Macintosh volume II. Anyone know if there are any gotchas to using these drivers in MacWorks? Do they actually exist in the 64K ROM image that MacWorks provides?

I know about SERD, the RAM-based serial drivers, but would prefer to use the ROM drivers if possible.
Logged

sigma7

  • Administrator
  • Sr. Member
  • *****
  • Karma: +150/-1
  • Offline Offline
  • Posts: 398
  • Warning: Memory errors found. Verify comments.
Re: MacWorks XL ROM serial drivers
« Reply #1 on: May 12, 2020, 08:55:50 pm »

From memory...

Yes, the SERD is available in the MW/MW+/MW+II ROM.

It is patched to make it work with the (slightly) different Lisa hardware.

IIRC, the later versions of MW+/II had updated SERD in ROM, as they couldn't rely on being able to patch a disk based SERD at runtime to work with the Lisa hardware. ie. they would prevent a disk based SERD from replacing the ROM version (but the ROM version wasn't as old as the one in the MacPlus ROM, so no real need to load a disk based version).

As for gotcha's, I think things like external clocking and directly accessing the serial hardware to do handshaking won't work without special-casing the Lisa hardware. Handshaking through the SERD does work.

Also note that the Lisa can't process data as quickly as the MacPlus, so a performance intensive test suite that runs on the Plus and fails on the Lisa doesn't necessarily indicate a bug.

HTH
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

rayarachelian

  • Administrator
  • Hero Member
  • *****
  • Karma: +105/-0
  • Offline Offline
  • Posts: 772
  • writing the code,writing the code,writing the code
    • LisaEm
Re: MacWorks XL ROM serial drivers
« Reply #2 on: May 13, 2020, 10:23:15 am »

So a note of clarification for other readers who may not understand how MacWorks functions, when you guys say in ROM, you really mean the ROM Toolbox from the point of view of the macos old world ROMs on 68k machines.

The ROM toolbox ships as part of the first MacWorks disk (boot) and is mapped by MacWorks using the Lisa's MMU to the same space as the ROM toolbox on an actual Mac Plus/512K(e), but physically lives in the Lisa's RAM and isn't actually in the Lisa Boot ROM. (And of course has been modified so that the I/O drivers in it account for the Lisa's actual hardware rather than the Mac's and QuickDraw has been updated to support the Lisa's larger display size)


There are good resources about MacWorks here:

* http://ruby.he.net/~sigma/mwplus2.html
* http://lisa.sunder.net/MacWorks_Plus_Technical_Overview_by_Chuck_Lukaszewski3.pdf
* http://lisa.sunder.net/Mac_128K_ROM_Globals_Index_compiled_by_Chuck_Lukaszewski.pdf
* https://en.wikipedia.org/wiki/MacWorks_XL
* https://en.wikipedia.org/wiki/MacWorks_Plus
* https://en.wikipedia.org/wiki/Macintosh_Toolbox
* https://en.wikipedia.org/wiki/Old_World_ROM
Logged
You don't know what it's like, you don't have a clue, if you did you'd find yourselves doing the same thing, too, Writing the code, Writing the code

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #3 on: May 13, 2020, 03:06:05 pm »

Thanks, both of you. Yes, I realize that in MacWorks, ROM is in RAM. And Ray you are correct in that I am referring to the serial drivers which are in ROM in a conventional Macintosh (512K, Plus, etc).

I am writing a networking application that targets the Mac 128K, 512K, and Macintosh XL, so I want to keep RAM usage to a minimum for the Mac 128K. This means I want to use the built-in serial driver on that Mac.

I've read over a handful of documents, including Software Supplements from 1985, and haven't found anything that explicitly says that there are no ROM serial drivers under MacWorks. But the problem may actually be Printer vs Modem port. I'm using the Modem port, but on a Mac XL the ports are not the same.

(Actually, they're not the same on a conventional Macintosh, as Modem port has a higher interrupt priority than Printer, but I understand that the two ports are more similar than on a Mac XL)
Logged

sigma7

  • Administrator
  • Sr. Member
  • *****
  • Karma: +150/-1
  • Offline Offline
  • Posts: 398
  • Warning: Memory errors found. Verify comments.
Re: MacWorks XL ROM serial drivers
« Reply #4 on: May 13, 2020, 06:48:22 pm »

Quote
they're not the same on a conventional Macintosh, as Modem port has a higher interrupt priority than Printer, but I understand that the two ports are more similar than on a Mac XL

This is also true under MacWorks. In particular, during floppy disk access, the floppy driver disables interrupts and polls (only) the modem port for data. Incoming data on the printer port can be lost. This feature was/is quite evident when downloading a file from the printer port to a floppy disk.

Rick recently asked me if the PFG can affect the modem port when using an environment other than MW+II (currently the only environment that recognizes the PFG)... and yes it does, breaking the baud rate setting. So if you have a PFG installed (in the SCC socket on the I/O Board) and are trying to use the Modem Port under eg. MacWorks XL, it probably doesn't work.

See this thread for details...

Serial A Baud Rate correction when PFG installed but NOT using MacWorks Plus II

It would certainly be nice if your software could compensate for the PFG when using a non MW+II environment. I think this would be relatively straightforward in that you would need to directly access the hardware to determine if the PFG is there, and over-ride the baud rate generator time constant accordingly (by writing your own value after the SERD sets it). Let me know if you'd like me to document how to do this. (In the meantime, probably wise to get it working without the PFG first rather than waiting for me.)

« Last Edit: May 13, 2020, 07:02:24 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

rayarachelian

  • Administrator
  • Hero Member
  • *****
  • Karma: +105/-0
  • Offline Offline
  • Posts: 772
  • writing the code,writing the code,writing the code
    • LisaEm
Re: MacWorks XL ROM serial drivers
« Reply #5 on: May 13, 2020, 09:23:18 pm »

Meta: Yeah, I know you guys know, I just wanted to clarify this for future visitors who don't have our background about MacWorks who may mistakenly take away that the Mac toolbox ROM is part of the Lisa's hardware. :) Part of my goals for posts on this forum is to provide a reference guide for future folks who've never seen a Lisa but are interested in it, and another part is to harvest these posts for future LisaFAQ updates. In 20-40 years from now the pool of people who own an actual working Lisa will be very tiny, though perhaps replicas will be possible.
Logged
You don't know what it's like, you don't have a clue, if you did you'd find yourselves doing the same thing, too, Writing the code, Writing the code

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #6 on: May 14, 2020, 02:53:52 pm »


It would certainly be nice if your software could compensate for the PFG when using a non MW+II environment. I think this would be relatively straightforward in that you would need to directly access the hardware to determine if the PFG is there, and over-ride the baud rate generator time constant accordingly (by writing your own value after the SERD sets it). Let me know if you'd like me to document how to do this. (In the meantime, probably wise to get it working without the PFG first rather than waiting for me.)
If you can tell me how to detect the PFG, I think I can work out the rest. I already know how to access the SCC directly.

By the way, I wonder if baud rate is the problem. I'm configuring the Modem port for 57600 baud. Is that too much for the Mac XL to handle?
Logged

sigma7

  • Administrator
  • Sr. Member
  • *****
  • Karma: +150/-1
  • Offline Offline
  • Posts: 398
  • Warning: Memory errors found. Verify comments.
Re: MacWorks XL ROM serial drivers
« Reply #7 on: May 14, 2020, 03:42:23 pm »

Quote
57600 baud. Is that too much for the Mac XL to handle?

Not inherently, but it depends.

AppleTalk/LocalTalk, for example, is about 230k baud. The stock Mac XL was able to handle this well up to ATP v52 (IIRC, maybe some other version. "ATP " is the AppleTalk Transfer Protocol DRVR), but at ~v57 (or...?), features were added to the packet protocol that made the handler too slow in some cases.

This was quite obvious when attempting to use System 7 file sharing: The stock XL worked fine as a client but could not serve files at all. If an XLerator was added, it could serve files fine.

In some tests, replacing the 8530 SCC with the 85230 ESCC (the difference being that the ESCC has a 5 byte receive buffer, two more than the SCC) seemed to also fix the issue (without the XLerator), but I've heard from Rick that his tests didn't show the same result, so it may be dependent on other machines and software versions, or it might be an outright fallacy that I have unintentionally propagated.

The way ATP works (as far as I can tell/recall/imagine), is to detect the start of a frame and then mask all interrupts while the whole data portion of the frame is collected in a dedicated timing sensitive polling loop.

If you design your software such that it knows when to pay full attention to receiving data, then 57600 is likely to be fine. If you are calculating a CRC or something, it will need to be efficient, or done after the data packet is received. (This was an issue with BLU receiving XModem-CRC at high rates.)

If software were to rely on interrupts to collect all the data at 57600, then I would suspect there could be issues depending on what else was happening on the XL. Perhaps it would work fine if nothing else were happening, but I suppose it depends on what one does with the data when/after receiving it.

Probably not the issue you are having, but note the stock XL's nominal baud rate of 57600 has an error about 0.8% (at an actual baud rate of 57143). The lower baud rates don't have such large errors. For more info, see post 3 of Serial A Baud Rate correction when PFG installed but NOT using MacWorks Plus II.

Edit: (I note that my memory is no longer very reliable, so verify)
« Last Edit: May 14, 2020, 03:46:50 pm by sigma7 »
Logged
Warning: Memory errors found. ECC non-functional. Verify comments if accuracy is important to you.

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #8 on: May 14, 2020, 05:41:35 pm »

What I'm doing now is to give the serial driver a large buffer on the order of 1,000 bytes using SerSetBuf. I'm also making a call as part of my initialization to disable hardware and software flow control.

Then in my application's main event loop, I just poll the serial driver with a _Control call to SerGetBuf. If SerGetBuf reports any unread bytes in the buffer, I then issue a _Read to copy the data into my application's buffer for processing.

All this works well enough on a conventional Macintosh, though my intent is to refactor the code to be completely interrupt-driven using async IO, a VBL task, and a completion routine.

So I'm scratching my head on why the same working application acts like a deaf-mute on the Mac XL with MacWorks Plus. It doesn't flag any errors, it doesn't crash... It just hears nothing and speaks nothing.

The only variables I can think of to test which may be affecting things are:
- handshaking?
- Modem vs Printer port?
- baud?

But maybe there's something else that's at fault.
Logged

stepleton

  • Sr. Member
  • ****
  • Karma: +127/-0
  • Offline Offline
  • Posts: 425
Re: MacWorks XL ROM serial drivers
« Reply #9 on: May 14, 2020, 05:49:17 pm »

Silly question, but do you know your serial ports to be in working condition on your XL? We've had one person here in the past month or so find that their Serial B port did not work, and mine also was inoperative until I replaced one of the ICs on the I/O board.
Logged

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #10 on: May 14, 2020, 06:20:08 pm »

Silly question, but do you know your serial ports to be in working condition on your XL?
Silly answer: I don't own a Mac XL!  :P But I have two beta testers and they reported that LisaTerminal works, so we're presuming that the cable and port are both working, and it's my software that's at fault.
« Last Edit: May 15, 2020, 01:24:21 pm by D.Finni »
Logged

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #11 on: May 21, 2020, 08:54:19 pm »

The plot thickens! When I changed to using the Printer port, it works at 57600 baud. So this is good news, but still leaves the question unanswered: why not on the Modem port?
Logged

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #12 on: July 14, 2020, 01:29:23 pm »

A few days ago I read the Async AppleTalk article in Dr Dobbs October 1987. Source code accompanied the article, and the source says that configuring the Lisa's port A for 19,200 baud can't be done. Another note says that Lisa port B works from Xtal, not PCLK.

So my conclusion is that Lisa's port A can't be configured for high baud rates. Does this ring any bells for anyone?
Logged

stepleton

  • Sr. Member
  • ****
  • Karma: +127/-0
  • Offline Offline
  • Posts: 425
Re: MacWorks XL ROM serial drivers
« Reply #13 on: July 14, 2020, 01:44:36 pm »

Yes, I think this is detailed in some of the Workshop manuals. I don't have a page number for the information, but here is a place where I put this knowledge to some use:

https://github.com/stepleton-xx/lisabbs/blob/master/LIBPORT.TEXT#L331
Logged

D.Finni

  • Sr. Member
  • ****
  • Karma: +38/-0
  • Offline Offline
  • Posts: 135
Re: MacWorks XL ROM serial drivers
« Reply #14 on: July 14, 2020, 02:20:50 pm »

Well there we go. It looks like my problem was trying to configure too high of a baud rate for the serial port. Thanks for the link.
Logged
Pages: [1]   Go Up