120 likes | 272 Views
A Smart Port Card Tutorial --- SPC Utilities Edward Spitznagel Washington University ews1@arl.wustl.edu. Utilities - Overview. Purpose of SPC Utilities: glue between various software components simplify other parts of the system solve miscellaneous problems encountered
E N D
A Smart Port Card Tutorial --- SPC Utilities Edward Spitznagel Washington University ews1@arl.wustl.edu
Utilities - Overview • Purpose of SPC Utilities: • glue between various software components • simplify other parts of the system • solve miscellaneous problems encountered • There aren’t as many as there used to be. • Utilities that are still useful: • mkimg - make image • mknl - make namelist
mkimg - overview • Creates a kernel image suitable for downloading to the SPC • Removes some of the burden from the bootloader
This is what the NetBSD kernel in a.out format looks like on the disk e.g. the file /netbsdon most systems Kernel Image On Disk: exec header text segment initialized data symbol table (optional) string table (optional)
Kernel Image On Disk: (e.g. the file /netbsd) In Memory: (as loaded by bootloader) • This is what the kernel image looks like when loaded into memory. • What’s different? • BSS segment has been inserted in the middle. exec header exec header text segment text segment initialized data initialized data symbol table (optional) BSS segment (uninitialized data) string table (optional) symbol table (optional) string table (optional)
mkimg - summary • Kernel requires BSS segment for execution. • Normal PC: done at boot time (by the bootloader) • SPC: done by mkimg, after kernel build • mkimg creates a copy of the kernel file with the BSS segment included. • mkimg is invoked by “make” from the mk.3 script
mknl - purpose • Certain system tools need a kernel namelist: • ps, netstat, top, uptime, etc. • Normally, this is read from kernel file (/netbsd) • Problem: kernel too large to fit on filesystem • Solution: • create a file that we can put on the filesystem, to hold the namelist information • file should look as much like the real kernel as possible
mknl utility: input: kernel in a.out format output: the “symbols only” file approach: open input and output files copy exec header lseek past text and data segments copy symbol table and string table close files Kernel Image On Disk: (e.g. the file /netbsd) exec header text segment initialized data symbol table (optional) string table (optional)
a file with a hole • mknl creates a file with a hole • unneeded blocks are not allocated • Example of a file with a hole: block array for the file: disk block disk block null null null null disk block disk block . . .
This is what the symbols-only netbsd file looks like This is what we put into our filesystem as /netbsd Doesn’t require much space typically around 150kB Example: from a 24MB kernel: output from mknl Output file from mknl: exec header hole (used to be text segment) hole (used to be initialized data) 152 -rw-r--r-- 1 root wheel 24624114 /netbsd symbol table string table
mknl - implications • Implication of a files with holes: • Copying can produce undesirable results: holes look like blocks full of zeroes... • new file will be as large as the original kernel • defeats purpose of mknl • Need to mknl directly into the filesystem. • Need to mknl after any changes are made to the kernel. • mknl is invoked by mk.2 script
Conclusion • Utilities • mkimg - make a kernel image suitable for downloading to SPC • mknl - makes a “symbols-only” file to reside on the SPC filesystem • The End