Skip to content

Latest commit

 

History

History
482 lines (439 loc) · 16.4 KB

pad.txt

File metadata and controls

482 lines (439 loc) · 16.4 KB

-*- org -*-

was in readme.txt

Open source programs are good, but clean and well documented programs are even better! Principia softwarica is a serie of books explaining essential “meta” programs (programs dealing with other programs. a.k.a system software):

  • kernel/shell/windows = programs that manage and launch other programs
  • network = programs to help other programs communicate with each other
  • editor = program to write programs
  • compiler/assembler/linker/generators = programs that generate other programs
  • interpreter = program that interprets and run another program
  • machine = program that emulates the hardware and run another (binary) program
  • debugger = program that commands and inspect another program
  • profiler = program that generates statistics about another program
  • builder = program to help build programs (calling compiler/asm/linker/…)
  • vcs = program to store the history and manage evolutions of your program
  • libc/libxx = programs to be used by other programs
  • browser = program to help you find information on how to write programs :)
  • games = programs to help you relax between two coding sessions

We chose to present mostly programs from the Plan 9 operating system because they are small, elegant, open source, and portable.

In many of those programs there are support for both the x86 and ARM architectures. We chose x86 because it’s the most common desktop machine. We chose ARM because it is far simpler and elegant than x86 (RISC are simpler than CISC) and we chose ARM over MIPS because ARM is almost as simple as MIPS but it’s alive as it is the most common mobile machine (it’s in every phone and also in the raspberry PI!).

related work:

Here are other series of software (application software) not covered by principa softwarica:

  • office: word processor, spreadsheet, presentations, pixel or vectorized drawing programs, publishing, database (Alto Bravo, appleII Visicalc, Powerpoint?, MacPaint, Publisher?, ingres?)
  • personal information manager: contact, calendar, alarm, notes, calc, … (Newton)
  • digital art revolution: photo, music, video, books (iLife)
  • communication: email, chat, forums, social network (???)
  • information/digital age: web browser/server, digital store, search engine (???)
  • mobile software: maps, weather, camera, chat, phone, … (iPhone)
  • games: arcade, shooter, rts, …
  • virtual reality? (occulus)

A few other meta programs are included in a separate project (pfff):

  • codemap/codegraph/codequery: programs to help understand other programs
  • sgrep/spatch: programs to search and transform other programs
  • scheck: program to verify other programs

(Re)Organization

I’ve removed support for many architectures. The goal is to have enough, and not more, for running plan9 under qemu/x86 and the Raspberri Pi. I’ve also reorganized the directories to be less flat by grouping together related commands. I’ve also moved all the source at the toplevel. I’ve simplified the way to build a distribution by relying on kencc and cross compilation from a Mac. See the toplevel Makefile.

History

In Dec 2013 I got interested again in plan9. I read about plan9 a long time ago while working on LFS and especially on the filesystem bibliography because of plan9 dump filesystem where one could do cd 1998/april.... I then printed the papers on 8 1/2 and Rio in 2013. Why I printed that? I was looking at xv6 for xix but always had the problem of the windowing system. MiniX, or Microwindows could have been good candidates, but the projects were not maintained. I think I remembered 8 1/2 or after looking at a list of windowing system on wikipedia I remembered it again and looked also at Rio. It seemed a cleaner model to start from and according to Pike in his paper a cleaner and very small codebase too. Then what was under Rio seemed also more elegant (plan9) and after looking at plan9 whole codebase with codemap I realized the code was not that big. Independently, for graph_code_clang I was also running my tool on plan9port thinking this was a good candidate to test on. All of this led gradually to consider plan9 as a serious candidate for xix, and not just for the windowing system part but also for the kernel, compiler, debugger, profiler, linker, etc. It had it all! And the code looked small and elegant!

Principia softwarica

Finally!

Note that it’s not principia informatica but softwarica. An informatica would be more on essential data structure, algorithms, etc.

Implanter pour mieux comprendre!

Critique coding style

A critique of plan9 coding style! “The Practice of Programming” book is IMHO incomplete or not up to date with the latest development in software engineering and programming languages!

  • they abuse int a lot instead of using bool, errorcode, fdt, enums (in fact in Go they have a bool type)
  • inconsistent error code convention (ERROR_0, ERROR_1, ERROR_NEG1)
  • they abuse pointers for everything (option, list, hash, ref, ref_own)
  • untyped collections, they should use generics for list, hashtbl, sets
  • duplicated reusable code (buffered IO, memory, conversions)
  • duplicated code where they could use more libraries (aa/, cpplib, ) instead of sometimes abusing cpp (e.g. macdef uglyness), or copy pasting lots of code between different assembler, compiler, linker
  • they could use lex more
  • they abuse a lot continue, break, return, where there could just use if-then-else and the right condition
  • they should use a language with ADTs, more precise types,
  • they could use marshalling instead of implementing many specific binary formats
  • they could use ‘deriving show’ instead of lots of hardcoded pretty printers
  • they should use GC when can, instead of reimplementing it with reference counting
  • they use really lots of globals when could instead write functions that take more parameters and return more results (instead of returning void)
  • lots of dead functions, dead fields, dead structures
  • very few comments (but good man pages and good research articles, and the few comments are pretty good e.g. on opcode in rc)
  • no unit tests, very few tests

last

compile correctly with parse_c and graph_code_c:

assembler (but need libmach too) builder compiler debuggers PB generators kernel lib_core SEMI lib_graphics lib_math lib_misc lib_networking PB linkers SEMI machine PB misc-apps PB profilers PB security PB shells windows

Test network

ip/ipconfig ndb/dns -r

cat /net/ndb ndb/dnsquery > www.google.com works!!

**

9fs atom then look in /n/atom/patch, or /n/atom/patch/applied, or /n/atom/patch/applied$year.

for 9fs .... case atom srv -n -q tcp!atom.9atom.org atom && mount $nflag /srv/atom /n/atom atom

Fork

see current_diff

Could do overlay and create symlinks to original positions. This makes it easier to incorporate new fixes.

Could do opposite and move things around but make symlinks that imitate the original structure?

Todo

less: fix kencc to support va_args macro

Later

try run it on raspberry pi

try run it on TECS simulator

Original trace

../boot/libboot.a8 doesn’t exist: assuming it will be an archive rc ../port/mkdevc pcf > pcf.c {echo ‘uchar configfile[]={’ xd -1x pcf | sed -e ‘s/^[0-9a-f]+ //’ -e ‘s/ ([0-9a-f][0-9a-f])/0x\1,/g’ echo 0, echo ‘};’} >> pcf.c 8a $AFLAGS l.s 8a $AFLAGS plan9l.s 8c -FTVw cga.c 8c -FTVw i8253.c 8c -FTVw i8259.c 8c -FTVw kbd.c 8c ../port/initcode.c 8c init9.c 8l -l -R1 -s -o init.out init9.8 initcode.8 /386/lib/libc.a {echo ‘uchar initcode[]={’ xd -1x <init.out | sed -e ‘s/^[0-9a-f]+ //’ -e ‘s/ ([0-9a-f][0-9a-f])/0x\1,/g’ echo ‘};’} > init.h 8a rebootcode.s 8l -l -s -T0x11000 -R4 -o reboot.out rebootcode.8 {echo ‘uchar rebootcode[]={’ xd -1x reboot.out | sed -e ‘1,2d’ -e ‘s/^[0-9a-f]+ //’ -e ‘s/ ([0-9a-f][0-9a-f])/0x\1,/g’ echo ‘};’} > reboot.h 8c -FTVw memory.c 8c -FTVw mmu.c 8c -FTVw -I. ../port/random.c 8c -FTVw -I. ../port/syscallfmt.c 8c -FTVw trap.c 8c -FTVw -I. ../port/print.c 8c -I../boot -FTVw ../boot/bootauth.c 8c -I../boot -FTVw ../boot/aux.c 8c -I../boot -FTVw ../boot/boot.c 8c -I../boot -FTVw ../boot/bootcache.c 8c -I../boot -FTVw ../boot/bootip.c 8c -I../boot -FTVw ../boot/local.c 8c -I../boot -FTVw ../boot/embed.c 8c -I../boot -FTVw ../boot/settime.c 8c -I../boot -FTVw ../boot/paq.c 8c -I../boot -FTVw ../boot/parts.c 8c -I../boot -FTVw ../boot/printstub.c 8c -I../boot -FTVw ../boot/usb.c 8c -FTVw ether82557.c 8c -FTVw uarti8250.c 8c -FTVw etherwavelan.c 8c -FTVw usbohci.c 8c -FTVw ether2000.c 8c -FTVw -I. ../port/devtls.c 8c -FTVw etherec2t.c 8c -FTVw vgax.c 8c -FTVw etherelnk3.c 8c -FTVw vgamga4xx.c 8c -FTVw vgabt485.c 8c -FTVw ether79c970.c 8c -FTVw -I. ../port/devmouse.c 8c -FTVw dma.c 8c -FTVw -I. ../port/devpnp.c 8c -FTVw -I. ../ip/arp.c 8c -FTVw -I. ../port/devaoe.c 8c -FTVw ether8169.c 8c -FTVw vgacyber938x.c 8c -FTVw vgaclgd542x.c 8c -FTVw ether83815.c 8c -FTVw screen.c 8c -FTVw -I. ../port/cis.c 8c -FTVw -I. ../ip/loopbackmedium.c 8c -FTVw usbehcipc.c 8c -FTVw -I. ../ip/ipmux.c 8c -FTVw mouse.c 8c -FTVw pci.c 8c -FTVw etherigbe.c 8c -FTVw vga.c 8c -FTVw ether2114x.c 8c -FTVw wavelan.c 8c -FTVw -I. ../port/devkbin.c 8c -FTVw vgargb524.c 8c -FTVw devi82365.c 8c -FTVw ether8139.c 8c -FTVw -I. ../port/devenv.c 8c -FTVw -I. ../ip/tcp.c 8c -FTVw ethersink.c 8c -FTVw vgaet4000.c 8c -FTVw vga3dfx.c 8c -FTVw devarch.c 8c -FTVw mpacpi.c 8c -FTVw -I. ../port/devcons.c 8c -FTVw apic.c 8c -FTVw sdmylex.c 8c -FTVw vgavesa.c 8c -FTVw -I. ../port/devaudio.c 8a $AFLAGS ptclbsum386.s 8c -FTVw vgaark2000pv.c 8c -FTVw -I. ../ip/pktmedium.c 8c -FTVw vgamach64xx.c 8c -FTVw -I. ../port/devfs.c 8c -FTVw vganeomagic.c 8c -FTVw -I. ../port/usbehci.c 8c -FTVw -I. ../port/devssl.c 8c -FTVw -I. ../ip/icmp6.c 8c -FTVw realmode.c 8c -FTVw -I. ../ip/esp.c 8c -FTVw sdata.c 8c -FTVw -I. ../port/devmnt.c 8c -FTVw mtrr.c 8c -FTVw vgas3.c 8c -FTVw etherdp83820.c 8c -FTVw -I. ../port/devdup.c 8c -FTVw usbuhci.c 8c -FTVw -I. ../ip/ipifc.c 8c -FTVw ether82543gc.c 8c -FTVw pcmciamodem.c 8c -FTVw -I. ../port/devsrv.c 8c -FTVw -I. ../ip/chandial.c 8c -FTVw ethervgbe.c 8c -FTVw -I. ../port/devproc.c 8c -FTVw ethersmc.c 8c -FTVw -I. ../ip/ethermedium.c 8c -FTVw devrtc.c 8c -FTVw devfloppy.c 8c -FTVw vgatvp3026.c 8c -FTVw -I. ../ip/ipv6.c 8c -FTVw devpccard.c 8c -FTVw vganvidia.c 8c -FTVw -I. ../port/devuart.c 8c -FTVw vgact65545.c 8c -FTVw devusb.c 8c -FTVw ether589.c 8a apbootstrap.s mem.h 8l -o apbootstrap.out -T0xF0003000 -R4 -l -s apbootstrap.8 {echo ‘uchar apbootstrap[]={’ xd -1x apbootstrap.out | sed -e ‘1,2d’ -e ‘s/^[0-9a-f]+ //’ -e ‘s/ ([0-9a-f][0-9a-f])/0x\1,/g’ echo ‘};’} > apbootstrap.h apbootstrap.s: mem.h: 8c -FTVw -I. ../port/devkprof.c 8c -FTVw -I. ../port/devpipe.c 8a $AFLAGS apmjump.s 8c -FTVw sdiahci.c 8c -FTVw -I. ../ip/netlog.c 8c -FTVw -I. ../port/devdraw.c 8c -FTVw ethervt6105m.c 8c -FTVw -I. ../port/netif.c 8c -FTVw ether82563.c 8c -FTVw vgamga2164w.c 8c -FTVw vgasavage.c 8c -FTVw -I. ../port/devkbmap.c 8c -FTVw vgatvp3020.c 8c -FTVw -I. ../ip/iproute.c 8c -FTVw -I. ../port/devsd.c 8c -FTVw apm.c 8c -FTVw vgaradeon.c 8c -FTVw devether.c 8c -FTVw devlpt.c 8c -FTVw etherga620.c 8c -FTVw -I. ../ip/icmp.c 8c -FTVw -I. ../port/devcap.c 8c -FTVw vgai81x.c 8c -FTVw -I. ../ip/ip.c 8c -FTVw vgat2r4.c 8c -FTVw -I. ../ip/udp.c 8c -FTVw ethervt6102.c 8c -FTVw uartpci.c 8c -FTVw -I. ../ip/gre.c 8c -FTVw -I. ../ip/devip.c 8c -FTVw -I. ../ip/rudp.c 8c -FTVw vgahiqvideo.c 8c -FTVw -I. ../ip/ipaux.c 8c -FTVw -I. ../port/sdaoe.c 8c -FTVw vgaclgd546x.c rc ../port/mkerrstr > errstr.h 8c -FTVw -I. ../ip/inferno.c 8c -FTVw ethermii.c 8c -FTVw -I. ../port/sdscsi.c 8c -FTVw ether8390.c 8c -FTVw ether8003.c 8c -FTVw devvga.c 8c -FTVw vgavmware.c 8c -FTVw -I. ../ip/nullmedium.c 8c -FTVw sd53c8xx.c 8c -FTVw -I. ../ip/netdevmedium.c 8c -FTVw bios32.c 8c -FTVw -I. ../port/alarm.c 8c -FTVw -I. ../port/alloc.c 8c -FTVw -I. ../port/allocb.c 8c -FTVw -I. ../port/auth.c 8c -FTVw -I. ../port/cache.c 8c -FTVw -I. ../port/chan.c 8c -FTVw -I. ../port/dev.c 8c -FTVw -I. ../port/edf.c 8c -FTVw -I. ../port/fault.c 8c -FTVw -I. ../port/latin1.c 8c -FTVw -I. ../port/page.c 8c -FTVw -I. ../port/parse.c 8c -FTVw -I. ../port/pgrp.c 8c -FTVw -I. ../port/portclock.c 8c -FTVw -I. ../port/qio.c 8c -FTVw -I. ../port/qlock.c 8c -FTVw -I. ../port/rdb.c 8c -FTVw -I. ../port/rebootcmd.c 8c -FTVw -I. ../port/segment.c 8c -FTVw -I. ../port/swap.c 8c -FTVw -I. ../port/sysfile.c 8c -FTVw -I. ../port/sysproc.c 8c -FTVw -I. ../port/taslock.c 8c -FTVw -I. ../port/tod.c 8c -FTVw -I. ../port/xalloc.c 8c -FTVw main.c names=`{membername $newprereq} ar vu ../boot/libboot.a8 $names rm $names a - bootauth.8 a - aux.8 a - boot.8 a - bootcache.8 a - bootip.8 a - local.8 a - embed.8 a - settime.8 a - paq.8 a - parts.8 a - printstub.8 a - usb.8 8c -FTVw mp.c 8c -FTVw archmp.c 8c -FTVw -I. ../port/devroot.c 8c -FTVw -I. ../port/proc.c ../boot/mkboot pcf > bootpcf.c 8c -FTVw bootpcf.c 8c -FTVw ../boot/printstub.c 8l -o bootpcf.out bootpcf.8 ../boot/libboot.a8 printstub.8 ../port/mkrootall \ boot boot_CONF_out bootpcf.out\ ipconfig _386_bin_ip_ipconfig /386/bin/ip/ipconfig\ factotum _386_bin_auth_factotum /386/bin/auth/factotum\ fossil _386_bin_fossil_fossil /386/bin/fossil/fossil\ venti _386_bin_venti_venti /386/bin/venti/venti\ usbd _386_bin_usb_usbd /386/bin/usb/usbd\ partfs _386_bin_disk_partfs /386/bin/disk/partfs\ >pcf.root.s ../port/mkrootc \ boot boot_CONF_out bootpcf.out\ ipconfig _386_bin_ip_ipconfig /386/bin/ip/ipconfig\ factotum _386_bin_auth_factotum /386/bin/auth/factotum\ fossil _386_bin_fossil_fossil /386/bin/fossil/fossil\ venti _386_bin_venti_venti /386/bin/venti/venti\ usbd _386_bin_usb_usbd /386/bin/usb/usbd\ partfs _386_bin_disk_partfs /386/bin/disk/partfs\ >pcf.rootc.c 8a $AFLAGS pcf.root.s 8c -FTVw pcf.rootc.c 8c -FTVw ‘-DKERNDATE=’`{date -n} pcf.c 8l -o 9pcf -T0xF0100020 -l l.8 plan9l.8 cga.8 i8253.8 i8259.8 kbd.8 main.8 memory.8 mmu.8 random.8 syscallfmt.8 trap.8 pcf.root.8 pcf.rootc.8 ether82557.8 uarti8250.8 etherwavelan.8 usbohci.8 ether2000.8 devtls.8 etherec2t.8 vgax.8 etherelnk3.8 vgamga4xx.8 vgabt485.8 ether79c970.8 devmouse.8 dma.8 devpnp.8 arp.8 devaoe.8 ether8169.8 vgacyber938x.8 vgaclgd542x.8 ether83815.8 screen.8 cis.8 loopbackmedium.8 usbehcipc.8 ipmux.8 mouse.8 pci.8 etherigbe.8 vga.8 ether2114x.8 wavelan.8 devkbin.8 vgargb524.8 devi82365.8 ether8139.8 devenv.8 tcp.8 ethersink.8 vgaet4000.8 vga3dfx.8 devarch.8 mpacpi.8 devcons.8 apic.8 sdmylex.8 vgavesa.8 devaudio.8 ptclbsum386.8 vgaark2000pv.8 pktmedium.8 vgamach64xx.8 devfs.8 vganeomagic.8 usbehci.8 devssl.8 icmp6.8 realmode.8 esp.8 sdata.8 devmnt.8 mtrr.8 vgas3.8 etherdp83820.8 devdup.8 usbuhci.8 ipifc.8 ether82543gc.8 pcmciamodem.8 devsrv.8 chandial.8 ethervgbe.8 devproc.8 ethersmc.8 ethermedium.8 devrtc.8 devfloppy.8 vgatvp3026.8 ipv6.8 devpccard.8 vganvidia.8 devuart.8 vgact65545.8 devusb.8 ether589.8 mp.8 devkprof.8 devpipe.8 apmjump.8 sdiahci.8 netlog.8 devdraw.8 ethervt6105m.8 archmp.8 netif.8 ether82563.8 vgamga2164w.8 vgasavage.8 devkbmap.8 vgatvp3020.8 iproute.8 devsd.8 apm.8 vgaradeon.8 devether.8 devlpt.8 etherga620.8 icmp.8 devcap.8 vgai81x.8 ip.8 vgat2r4.8 udp.8 ethervt6102.8 uartpci.8 gre.8 devip.8 rudp.8 vgahiqvideo.8 ipaux.8 sdaoe.8 vgaclgd546x.8 devroot.8 inferno.8 ethermii.8 sdscsi.8 ether8390.8 ether8003.8 devvga.8 vgavmware.8 nullmedium.8 sd53c8xx.8 netdevmedium.8 bios32.8 alarm.8 alloc.8 allocb.8 auth.8 cache.8 chan.8 dev.8 edf.8 fault.8 latin1.8 page.8 parse.8 pgrp.8 portclock.8 print.8 proc.8 qio.8 qlock.8 rdb.8 rebootcmd.8 segment.8 swap.8 sysfile.8 sysproc.8 taslock.8 tod.8 xalloc.8 pcf.8 /386/lib/libmemlayer.a /386/lib/libmemdraw.a /386/lib/libdraw.a /386/lib/libip.a /386/lib/libc.a /386/lib/libsec.a /386/lib/libmp.a size 9pcf 1119077t + 2020272d + 457544b = 3596893 9pcf