8

I tried to run v5root.gz on simh V3.8 (unix research version 5). This works insofar as I get a login prompt.

If I though look at the source code of main.c (line 55) of the kernel in that image, then I see the following:

    printf("mem = %l\n", maxmem*10/32);

I checked in prf.c that printf (via putchar) goes to the serial console device (I believe it is called KL11). Yet, I don't see that "mem = ..." message during boot in simh.

What could be the cause of that? I'm asking as my own emulator does show that message (but crashes (goes into an infinite loop) later on).

2

2 Answers 2

10

The key is that you need to set a non-zero value on the console switches. Otherwise putchar does nothing.

if(KL->csw == 0)
    return;

The anonymous struct in prf.c is used to overlay the four KL11 registers and the console switch register, which is conveniently located immediately after the KL11 in the address space.

The symbol KL is defined to point to the base of the KL11, so any KL->foo reference is to the actual device register 'foo'.

#define KL  0177560

struct  {
    int rsr;
    int rbr;
    int xsr;
    int xbr;
    int csw;
};

No further setup is needed. The device is accessed directly, it's simple enough to not need any initialization, and no inode is involved.


Relevant addresses; this from the 11/40 handbook, though pretty much any PDP-11 handbook has the same info. Note this uses 18-bit Unibus addresses.

777570   CONSOLE SWITCH REGISTER  
777566   KL11 TTY OUT DBR  
777564   KL11 TTY OUT CSR  
777562   KL11 TTY IN DBR  
777560   KL11 TTY IN CSR  
6

What could be the cause of that?

Can't be certain without a deeper dive into the code but my initial thought is that it may be too early in the boot process for output devices to be ready.

This is at least supported by this piece of code after the printf in question:

    /*
     * set up 'known' i-nodes
     */

    sureg();
    *lks = 0115;
    cinit();
    binit();

That cinit and binit are almost certainly intitalisation routines for the character and block devices, the first of which may include the console itself. The cinit code can be found in dmr's area in tty.c.

Attempts to write before that's done may just result in your data going into the bit bucket.

If you can actually recompile this beast, it would be instructive to place a printf on either side of the cinit and see if the second one shows up but not the first.


Alternatively, you may want to look into this code at the start of putchar:

if(KL->csw == 0)
    return;

That allows for a path where you can print whatever you want and never see it appear on the terminal. Whether that csw member is related to the character switches of the KL11 I'm not sure. But, if it's yet to be set to anything (other than zero), your output will never be delivered.

2
  • 1
    Definitely is the switch register. The PDP-11 console switch register is at the address immediately after the console terminal KL-11. So you'll need to make sure the switches are non-zero. I wrote up a separate answer, not to steal your thunder, but to emphasize no other init was needed. Apr 12 at 22:58
  • 1
    @another-dave, I have no issue with you posting another answer since mine was less certain, having only been surmised from the code and general experience. Always happy to defer to those with more specific knowlegde.
    – paxdiablo
    Apr 13 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.