9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] delay and aamloop
@ 2002-01-27 13:55 Lucio De Re
  0 siblings, 0 replies; 3+ messages in thread
From: Lucio De Re @ 2002-01-27 13:55 UTC (permalink / raw)
  To: 9fans mailing list

It all started with an Am97c690 controller :-(

Now I have to get Plan 9 to run on the PCD-4Lsx because I want to
finish off the PCnet driver and the only version of the controller
I have access to is on one particular motherboard.

I've narrowed down _a_ boot problem to the execution of delay(10)
within floppyrevive() in /sys/src/boot/pc/devfloppy.c but I have
trouble making head or tail of the symptoms: mp->name is no longer
pointing to the "fd0" value assigned to it in floppyinitdev() once
the first delay(10) is executed.

Now, delay() is a simple procedure in /sys/src/boot/pc/clock.c
which in turn uses aamloop() in /sys/src/boot/pc/l.s and reduces
to a very simple loop.  The AAM instruction means precisely nothing
to me, my knowledge of Intel assembler stopped at the 80186, but
given that it does not explicitly change the value of mp->name, I
wonder how it could conceivably cause it to change indirectly and
the only explanation seems that it causes some changes in memory
mappings.  I am aware that this type of flight of fancy on my part
generally causes me to be publicly embarrassed, still, I can't
think of anything else.

I have replaced the delay(10) calls with C loops and the mp->name
value is now left undamaged.  There could be something strange in
the operation or design of the PCD-4Lsx (made by Fujitsu, it was
marketed in Europe by Siemens-Nixdorf; my particular unit has a
486SX-25 and 32Meg of RAM), I'm sure I'll come across further
oddities, but I would like an opinion from the bits-n-bytes folks
here how AAM can conceivably cause memory to shift underfoot.

Hazarding a totally uninformed opinion, is it possible that at the
time floppyrevive() is called within 9load the memory management
is not yet stable and AAM causes it to misbehave?

Are there any experiments I ought to conduct to assist in diagnosing
and curing the problem?  The most obvious visible sign is the
display by 9load of a very ugly "using" message that does not
include "fd0" anywhere in it.

My next step is to install the modified 9load on an installation
floppy and see if I make any progress towards getting the kernel to
run.

++L


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] delay and aamloop
  2002-01-27 19:20 Russ Cox
@ 2002-01-28  5:50 ` Lucio De Re
  0 siblings, 0 replies; 3+ messages in thread
From: Lucio De Re @ 2002-01-28  5:50 UTC (permalink / raw)
  To: 9fans

On Sun, Jan 27, 2002 at 02:20:30PM -0500, Russ Cox wrote:
>
> AAM is "ascii adjust AX after multiply", which may
> well have been on the 80186.  It fools with AX but
> that's about it.
>
Yes, I realised with further mucking about that the actual contents of
the delay() function has nothing to do with the problem and/or the
symptoms.

By looping 100000 times (10^5) instead of 10^4, I managed to stall the
entire loading process, where 10^3 seems to work fine for
boot/pc/9load but I haven't been able to try it on 9/pc/9pcdisk.gz,
for example.

Something is dependent on timing in the most intractable fashion.  I
have to confess that I do not like the PC startup code at all, not
Plan 9's nor anyone else's.  It looks like a whole lot of compromises
waiting to bite one.

And, sadly, once the hurdle is overcome things behave themselves very
nicely, so there's little reason to go back and apply a more pervasive
fix.

But I'm hoping to put some effort into a bootstrap procedure that is
more robust than we have now, even if I have to lift it from Linux or
NetBSD (or, most likely, the IBM PC/XT BIOS code from the
long-cherished Technical Reference Manual).

Thank you for confirming what I already suspected.

++L


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] delay and aamloop
@ 2002-01-27 19:20 Russ Cox
  2002-01-28  5:50 ` Lucio De Re
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2002-01-27 19:20 UTC (permalink / raw)
  To: 9fans

AAM is "ascii adjust AX after multiply", which may
well have been on the 80186.  It fools with AX but
that's about it.

You didn't actually replace AAM, you replaced the
entire call to delay(), which does some other stuff
first.

I bet if you replace AAM with some other
hopefully-single-cycle instruction, like XOR AX, AX,
you'll still get the memory changing behavior,
which will clear AAM's good name.

However, it could be that the Medium structure
has somehow gotten in the way of the stack,
and calling delay is just enough to overwrite the name.

In floppyinitdev try adding

	print("floppy name %s=%lux\n", mp->name, mp->name);

and in floppyrevive:

	print("floppyrevive stack at &dp=%lux\n", &dp);

and see if the two numbers are dangerously close.

Russ


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-01-28  5:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-27 13:55 [9fans] delay and aamloop Lucio De Re
2002-01-27 19:20 Russ Cox
2002-01-28  5:50 ` Lucio De Re

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).