As we have the kernel almost compiled now it is time to check what is missing to have it linked. By checking header files and adding stubs into main.c we will get linked with very small changes as:

Changes to main.c:

 1#include "u.h"
 2#include "../port/lib.h"
 3#include "dat.h"
 4#include "mem.h"
 5
 6Conf conf;
 7Mach *m = (Mach*)MACHADDR;
 8Proc *up = 0;
 9
10#include "../port/uart.h"
11PhysUart* physuart[1];
12
13int     waserror(void) { return 0; }
14int     splhi(void) { return 0; }
15void    splx(int) { return; }
16int     spllo(void) { return 0; }
17void    splxpc(int) { return; }
18int     islo(void) { return 0; }
19int     setlabel(Label*) { return 0; }
20void    gotolabel(Label*) { return; }
21ulong   getcallerpc(void*) { return 0; }
22int     segflush(void*, ulong) { return 0; }
23void    idlehands(void) { return; }
24void    kprocchild(Proc *p, void (*func)(void*), void *arg) { return; }
25ulong   _tas(ulong*) { return 0; }
26ulong   _div(ulong*) { return 0; }
27ulong   _divu(ulong*) { return 0; }
28ulong   _mod(ulong*) { return 0; }
29ulong   _modu(ulong*) { return 0; }
30
31void    setpanic(void) { return; }
32void    dumpstack(void) { return; }
33void    exit(int) { return; }
34void    reboot(void) { return; }
35void    halt(void) { return; }
36
37Timer*  addclock0link(void (*)(void), int) { return 0; }
38void    clockcheck(void) { return; }
39
40void    fpinit(void) {}
41void    FPsave(void*) {}
42void    FPrestore(void*) {}

Changes to fns.h:

1#define coherence()     /* nothing needed for uniprocessor */
2#define procsave(p)     /* Save the mach part of the current */ 
3                        /* process state, no need for one cpu */

This list of functions defines very clear what are scopes of functionality is required to implement. For example, fpinit, FPsave, FPrestore are related to have floating point operations, “clock” functions to have system clocks to be programmed and tested. Some functions for rebooting, halting, dumping stack – say they are “util” functions. And finally block of functions (which is first in list) is to be implemented in assembler to have kernel to use R-Pi platform.

You see that we make “empty” defines for coherence() and procsave(), so probably in future for graphics codes, the coherence() should have something on board, but for our current state it is fine.

My plan for a next lab is to describe memory model and initial initializations for memory pools.

FILES: