Interesting point we missed in lab10. Those are stubs that we have in main(): _div, _divu, _mod, _modu

Amazingly, I do not know what it is :),

Plan9/Inferno people, can you give a help regarding purpose of these references and way how they affect? (I will update the lab as I get more info about this)

It is clear that without them fixed you can not have print() call working and other stuff in the kernel. By checking/compiling/running/checking, we reveal that in other arm ports it is fixed in next way in l.s(load.s):

1	...
2	BL      ,main(SB)
3dead:
4	B       dead
5	B       ,0(PC)
6	BL      _div(SB)    /* hack to load _div, etc. */

As we have such code in load.s, then print() call can be used after we initialize serwrite variable. Also let’s add little more tracing to main() call to see more information:

 1pl011_puts("Entered main() at ");
 2pl011_addr(&main;, 0);
 3pl011_puts(" with SP=");
 4pl011_addr((void *)getsp(), 1.);
 5
 6pl011_puts("Clearing Mach:  ");
 7memset(m, 0, sizeof(Mach));
 8pl011_addr((char *)m,		0); pl011_puts("-");
 9pl011_addr((char *)(m+1),	1);
10
11pl011_puts("Clearing edata: ");
12memset(edata, 0, end-edata);
13pl011_addr((char *)&edata;,	0); pl011_puts("-");
14pl011_addr((char *)&end;,	1);
15
16conf.nmach = 1;
17serwrite = &pl011;_serputs;
18
19confinit();
20xinit();
21poolinit();
22poolsizeinit();
23
24pl011_puts("to inifinite loop\n\n");
25for (;;);

Function pl011_addr() was created in the way that it can print address even when you have data segment broken (would be useful in debugging/tracing):

 1void
 2pl011_addr(void *a, int nl)
 3{
 4	int i;
 5	unsigned char *ca = (unsigned char *)&a;
 6	unsigned char h,l;
 7
 8	for (i=3;i>=0;--i) {
 9		h = ca[i]/16;
10		l = ca[i]%16;
11		pl011_putc(h<10 ? h+0x30 : h-10+0x41);
12		pl011_putc(l<10 ? l+0x30 : l-10+0x41);
13	}
14	if (nl) {
15		pl011_putc(13);
16		pl011_putc(10);
17	}
18}

So, that was a small lab to test everything that coded before with some small polishing.

Executing:

...
TFTP from server 10.0.55.112; our IP address is 10.0.55.105
Filename 'irpi'.
Load address: 0x7fe0
Loading: T #T #####################################
done
Bytes transferred = 543966 (84cde hex)
## Starting application at 0x00008000 ...
Entered main() at 00008404 with SP=00002FEC
Clearing Mach:  00002000-00002018
Clearing edata: 00064638-0006B760
Conf: top=134217728, npage0=32660, ialloc=26755072, nproc=735
to inifinite loop

FILES: