a few core -> CPU

get rid of PDF generating support
This commit is contained in:
Robert Morris 2019-07-23 11:14:10 -04:00
parent b8a31c494c
commit 55bc96d419
10 changed files with 7 additions and 560 deletions

View file

@ -143,16 +143,6 @@ clean:
$U/usys.S \ $U/usys.S \
$(UPROGS) $(UPROGS)
# make a printout
FILES = $(shell grep -v '^\#' runoff.list)
PRINT = runoff.list runoff.spec README toc.hdr toc.ftr $(FILES)
xv6.pdf: $(PRINT)
./runoff
ls -l xv6.pdf
print: xv6.pdf
# try to generate a unique GDB port # try to generate a unique GDB port
GDBPORT = $(shell expr `id -u` % 5000 + 25000) GDBPORT = $(shell expr `id -u` % 5000 + 25000)
# QEMU's gdb stub command line changed in 0.11 # QEMU's gdb stub command line changed in 0.11
@ -185,7 +175,7 @@ EXTRA=\
mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c\ mkfs.c ulib.c user.h cat.c echo.c forktest.c grep.c kill.c\
ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c\ ln.c ls.c mkdir.c rm.c stressfs.c usertests.c wc.c zombie.c\
printf.c umalloc.c\ printf.c umalloc.c\
README dot-bochsrc *.pl toc.* runoff runoff1 runoff.list\ README dot-bochsrc *.pl \
.gdbinit.tmpl gdbutil\ .gdbinit.tmpl gdbutil\
dist: dist:

View file

@ -2,7 +2,7 @@
# there seem to be provided by qemu, as if it # there seem to be provided by qemu, as if it
# were a ROM. the code at 0x1000 jumps to # were a ROM. the code at 0x1000 jumps to
# 0x8000000, the _start function here, # 0x8000000, the _start function here,
# in machine mode. # in machine mode. each CPU starts here.
.section .data .section .data
.globl stack0 .globl stack0
.section .text .section .text
@ -11,8 +11,9 @@
.globl _entry .globl _entry
_entry: _entry:
# set up a stack for C. # set up a stack for C.
# stack0 is declared in start, # stack0 is declared in start.c,
# with 4096 bytes per CPU. # with a 4096-byte stack per CPU.
# sp = stack0 + (hartid * 4096)
la sp, stack0 la sp, stack0
li a0, 1024*4 li a0, 1024*4
csrr a1, mhartid csrr a1, mhartid

View file

@ -46,7 +46,7 @@ cpuid()
return id; return id;
} }
// Return this core's cpu struct. // Return this CPU's cpu struct.
// Interrupts must be disabled. // Interrupts must be disabled.
struct cpu* struct cpu*
mycpu(void) { mycpu(void) {

View file

@ -52,7 +52,7 @@ release(struct spinlock *lk)
// Tell the C compiler and the CPU to not move loads or stores // Tell the C compiler and the CPU to not move loads or stores
// past this point, to ensure that all the stores in the critical // past this point, to ensure that all the stores in the critical
// section are visible to other cores before the lock is released. // section are visible to other CPUs before the lock is released.
// On RISC-V, this turns into a fence instruction. // On RISC-V, this turns into a fence instruction.
__sync_synchronize(); __sync_synchronize();

249
runoff
View file

@ -1,249 +0,0 @@
#!/bin/sh
echo This script takes a minute to run. Be patient. 1>&2
LC_CTYPE=C export LC_CTYPE
# pad stdin to multiple of 120 lines
pad()
{
awk '{print} END{for(; NR%120!=0; NR++) print ""}'
}
# create formatted (numbered) files
mkdir -p fmt
mkdir -p fmt/kernel
mkdir -p fmt/user
rm -f fmt/kernel/*
rm -f fmt/user/*
cp README fmt
echo > fmt/blank
files=`grep -v '^#' runoff.list | awk '{print $1}'`
n=99
for i in $files
do
./runoff1 -n $n $i >fmt/$i
nn=`tail -1 fmt/$i | sed 's/ .*//; s/^0*//'`
if [ "x$nn" != x ]; then
n=$nn
fi
done
# create table of contents
cat toc.hdr >fmt/toc
pr -e8 -t runoff.list | awk '
/^[a-z0-9]/ {
s=$0
f="fmt/"$1
getline<f
close(f)
n=$1
printf("%02d %s\n", n/100, s);
printf("TOC: %04d %s\n", n, s) >"fmt/tocdata"
next
}
{
print
}' | pr -3 -t >>fmt/toc
cat toc.ftr >>fmt/toc
# check for bad alignments
perl -e '
$leftwarn = 0;
while(<>){
chomp;
s!#.*!!;
s!\s+! !g;
s! +$!!;
next if /^$/;
if(/TOC: (\d+) (.*)/){
$toc{$2} = $1;
next;
}
if(/sheet1: (left|right)$/){
print STDERR "assuming that sheet 1 is a $1 page. double-check!\n";
$left = $1 eq "left" ? "13579" : "02468";
$right = $1 eq "left" ? "02468" : "13579";
next;
}
if(/even: (.*)/){
$file = $1;
if(!defined($toc{$file})){
print STDERR "Have no toc for $file\n";
next;
}
if($toc{$file} =~ /^\d\d[^0]/){
print STDERR "$file does not start on a fresh page.\n";
}
next;
}
if(/odd: (.*)/){
$file = $1;
if(!defined($toc{$file})){
print STDERR "Have no toc for $file\n";
next;
}
if($toc{$file} !~ /^\d\d5/){
print STDERR "$file does not start on a second half page.\n";
}
next;
}
if(/(left|right): (.*)/){
$what = $1;
$file = $2;
if(!defined($toc{$file})){
print STDERR "Have no toc for $file\n";
next;
}
if($what eq "left" && !($toc{$file} =~ /^\d[$left][05]/)){
print STDERR "$file does not start on a left page [$toc{$file}]\n";
}
# why does this not work if I inline $x in the if?
$x = ($toc{$file} =~ /^\d[$right][05]/);
if($what eq "right" && !$x){
print STDERR "$file does not start on a right page [$toc{$file}] [$x]\n";
}
next;
}
print STDERR "Unknown spec: $_\n";
}
' fmt/tocdata runoff.spec
# make definition list
cd fmt
perl -e '
while(<>) {
chomp;
s!//.*!!;
s!/\*([^*]|[*][^/])*\*/!!g;
s!\s! !g;
s! +$!!;
# look for declarations like char* x;
if (/^[0-9]+ typedef .* u(int|short|long|char);/) {
next;
}
if (/^[0-9]+ extern/) {
next;
}
if (/^[0-9]+ struct [a-zA-Z0-9_]+;/) {
next;
}
if (/^([0-9]+) #define +([A-za-z0-9_]+) +?\(.*/) {
print "$1 $2\n"
}
elsif (/^([0-9]+) #define +([A-Za-z0-9_]+) +([^ ]+)/) {
print "$1 $2 $3\n";
}
elsif (/^([0-9]+) #define +([A-Za-z0-9_]+)/) {
print "$1 $2\n";
}
if(/^^([0-9]+) \.globl ([a-zA-Z0-9_]+)/){
$isglobl{$2} = 1;
}
if(/^^([0-9]+) ([a-zA-Z0-9_]+):$/ && $isglobl{$2}){
print "$1 $2\n";
}
if (/\(/) {
next;
}
if (/^([0-9]+) (((static|struct|extern|union|enum) +)*([A-Za-z0-9_]+))( .*)? +([A-Za-z_][A-Za-z0-9_]*)(,|;|=| =)/) {
print "$1 $7\n";
}
elsif(/^([0-9]+) (enum|struct|union) +([A-Za-z0-9_]+) +{/){
print "$1 $3\n";
}
# TODO: enum members
}
' $files >defs
(for i in $files
do
case "$i" in
*.S)
cat $i | sed 's;#.*;;; s;//.*;;;'
;;
*)
cat $i | sed 's;//.*;;; s;"([^"\\]|\\.)*";;;'
esac
done
) >alltext
perl -n -e 'print if s/^([0-9]+ [a-zA-Z0-9_]+)\(.*$/\1/;' alltext |
egrep -v ' (STUB|usage|main|if|for)$' >>defs
#perl -n -e 'print if s/^([0-9]+) STUB\(([a-zA-Z0-9_]+)\)$/\1 \2/;' alltext \
# >>defs
(
>s.defs
# make reference list
for i in `awk '{print $2}' defs | sort -f | uniq`
do
defs=`egrep '^[0-9]+ '$i'( |$)' defs | awk '{print $1}'`
echo $i $defs >>s.defs
uses=`egrep -h '([^a-zA-Z_0-9])'$i'($|[^a-zA-Z_0-9])' alltext | awk '{print $1}'`
if [ "x$defs" != "x$uses" ]; then
echo $i $defs
echo $uses |fmt -29 | sed 's/^/ /'
# else
# echo $i defined but not used >&2
fi
done
) >refs
# build defs list
awk '
{
printf("%04d %s\n", $2, $1);
for(i=3; i<=NF; i++)
printf("%04d \" \n", $i);
}
' s.defs > t.defs
# format the whole thing
(
../pr.pl README
../pr.pl -h "table of contents" toc
# pr -t -2 t.defs | ../pr.pl -h "definitions" | pad
pr -t -l50 -2 refs | ../pr.pl -h "cross-references" | pad
# pr.pl -h "definitions" -2 t.defs | pad
# pr.pl -h "cross-references" -2 refs | pad
../pr.pl blank # make sheet 1 start on left page
../pr.pl blank
for i in $files
do
../pr.pl -h "xv6/$i" $i
done
) | mpage -m50t50b -o -bLetter -T -t -2 -FCourier -L60 >all.ps
grep Pages: all.ps
# if we have the nice font, use it
nicefont=LucidaSans-Typewriter83
if [ ! -f ../$nicefont ]
then
if git cat-file blob font:$nicefont > ../$nicefont~; then
mv ../$nicefont~ ../$nicefont
fi
fi
if [ -f ../$nicefont ]
then
echo nicefont
(sed 1q all.ps; cat ../$nicefont; sed "1d; s/Courier/$nicefont/" all.ps) >allf.ps
else
echo ugly font!
cp all.ps allf.ps
fi
ps2pdf allf.ps ../xv6.pdf
# cd ..
# pdftops xv6.pdf xv6.ps

View file

@ -1,66 +0,0 @@
# basic headers
kernel/types.h
kernel/param.h
kernel/memlayout.h
kernel/defs.h
kernel/riscv.h
kernel/elf.h
kernel/date.h
# entering xv6
kernel/entry.S
kernel/start.c
kernel/main.c
# locks
kernel/spinlock.h
kernel/spinlock.c
# processes
kernel/vm.c
kernel/proc.h
kernel/proc.c
kernel/swtch.S
kernel/kalloc.c
# system calls
user/usys.pl
kernel/kernelvec.S
kernel/trap.c
kernel/syscall.h
kernel/syscall.c
kernel/sysproc.c
# file system
kernel/buf.h
kernel/sleeplock.h
kernel/fcntl.h
kernel/stat.h
kernel/fs.h
kernel/file.h
kernel/virtio_disk.c
kernel/bio.c
kernel/sleeplock.c
kernel/log.c
kernel/fs.c
kernel/file.c
kernel/sysfile.c
kernel/exec.c
# pipes
kernel/pipe.c
# string operations
kernel/string.c
# low-level hardware
kernel/uart.c
# user-level
user/initcode.S
user/usys.S
user/init.c
user/sh.c
# link
kernel/kernel.ld

View file

@ -1,102 +0,0 @@
# Is sheet 01 (after the TOC) a left sheet or a right sheet?
sheet1: left
# "left" and "right" specify which page of a two-page spread a file
# must start on. "left" means that a file must start on the first of
# the two pages. "right" means it must start on the second of the two
# pages. The file may start in either column.
#
# "even" and "odd" specify which column a file must start on. "even"
# means it must start in the left of the two columns (00). "odd" means it
# must start in the right of the two columns (50).
#
# You'd think these would be the other way around.
# types.h either
# param.h either
# defs.h either
# x86.h either
# asm.h either
# mmu.h either
# elf.h either
# mp.h either
even: entry.S # mild preference
even: entryother.S # mild preference
even: main.c
# mp.c don't care at all
# even: initcode.S
# odd: init.c
left: spinlock.h
even: spinlock.h
# This gets struct proc and allocproc on the same spread
left: proc.h
even: proc.h
# goal is to have two action-packed 2-page spreads,
# one with
# userinit growproc fork exit wait
# and another with
# scheduler sched yield forkret sleep wakeup1 wakeup
right: proc.c # VERY important
even: proc.c # VERY important
# A few more action packed spreads
# page table creation and process loading
# walkpgdir mappages setupkvm switch[ku]vm inituvm (loaduvm)
# process memory management
# allocuvm deallocuvm freevm
left: vm.c
even: kalloc.c # mild preference
# syscall.h either
# trapasm.S either
# traps.h either
# even: trap.c
# vectors.pl either
# syscall.c either
# sysproc.c either
# buf.h either
# dev.h either
# fcntl.h either
# stat.h either
# file.h either
# fs.h either
# fsvar.h either
# left: ide.c # mild preference
even: ide.c
# odd: bio.c
# log.c fits nicely in a spread
even: log.c
left: log.c
# with fs.c starting on 2nd column of a left page, we get these 2-page spreads:
# ialloc iupdate iget idup ilock iunlock iput iunlockput
# bmap itrunc stati readi writei
# namecmp dirlookup dirlink skipelem namex namei
# fileinit filealloc filedup fileclose filestat fileread filewrite
# starting on 2nd column of a right page is not terrible either
odd: fs.c # VERY important
left: fs.c # mild preference
# file.c either
# exec.c either
# sysfile.c either
# Mild preference, but makes spreads of mp.c, lapic.c, and ioapic.c+picirq.c
even: mp.c
left: mp.c
# even: pipe.c # mild preference
# string.c either
# left: kbd.h # mild preference
even: kbd.h
even: console.c
odd: sh.c
even: bootasm.S # mild preference
even: bootmain.c # mild preference

108
runoff1
View file

@ -1,108 +0,0 @@
#!/usr/bin/perl
$n = 0;
$v = 0;
if($ARGV[0] eq "-v") {
$v = 1;
shift @ARGV;
}
if($ARGV[0] eq "-n") {
$n = $ARGV[1];
shift @ARGV;
shift @ARGV;
}
$n = int(($n+49)/50)*50 - 1;
$file = $ARGV[0];
@lines = <>;
$linenum = 0;
foreach (@lines) {
$linenum++;
chomp;
s/\s+$//;
if(length() >= 75){
print STDERR "$file:$linenum: line too long\n";
}
}
@outlines = ();
$nextout = 0;
for($i=0; $i<@lines; ){
# Skip leading blank lines.
$i++ while $i<@lines && $lines[$i] =~ /^$/;
last if $i>=@lines;
# If the rest of the file fits, use the whole thing.
if(@lines <= $i+50 && !grep { /PAGEBREAK/ } @lines){
$breakbefore = @lines;
}else{
# Find a good next page break;
# Hope for end of function.
# but settle for a blank line (but not first blank line
# in function, which comes after variable declarations).
$breakbefore = $i;
$lastblank = $i;
$sawbrace = 0;
$breaksize = 15; # 15 lines to get to function
for($j=$i; $j<$i+50 && $j < @lines; $j++){
if($lines[$j] =~ /PAGEBREAK!/){
$lines[$j] = "";
$breakbefore = $j;
$breaksize = 100;
last;
}
if($lines[$j] =~ /PAGEBREAK:\s*([0-9]+)/){
$breaksize = $1;
$breakbefore = $j;
$lines[$j] = "";
}
if($lines[$j] =~ /^};?$/){
$breakbefore = $j+1;
$breaksize = 15;
}
if($lines[$j] =~ /^{$/){
$sawbrace = 1;
}
if($lines[$j] =~ /^$/){
if($sawbrace){
$sawbrace = 0;
}else{
$lastblank = $j;
}
}
}
if($j<@lines && $lines[$j] =~ /^$/){
$lastblank = $j;
}
# If we are not putting enough on a page, try a blank line.
if($breakbefore - $i < 50 - $breaksize && $lastblank > $breakbefore && $lastblank >= $i+50 - 5){
if($v){
print STDERR "breakbefore $breakbefore i $i breaksize $breaksize\n";
}
$breakbefore = $lastblank;
$breaksize = 5; # only 5 lines to get to blank line
}
# If we are not putting enough on a page, force a full page.
if($breakbefore - $i < 50 - $breaksize && $breakbefore != @lines){
$breakbefore = $i + 50;
$breakbefore = @lines if @lines < $breakbefore;
}
if($breakbefore < $i+2){
$breakbefore = $i+2;
}
}
# Emit the page.
$i50 = $i + 50;
for(; $i<$breakbefore; $i++){
printf "%04d %s\n", ++$n, $lines[$i];
}
# Finish page
for($j=$i; $j<$i50; $j++){
printf "%04d \n", ++$n;
}
}

13
toc.ftr
View file

@ -1,13 +0,0 @@
The source listing is preceded by a cross-reference that lists every defined
constant, struct, global variable, and function in xv6. Each entry gives,
on the same line as the name, the line number (or, in a few cases, numbers)
where the name is defined. Successive lines in an entry list the line
numbers where the name is used. For example, this entry:
swtch 2658
0374 2428 2466 2657 2658
indicates that swtch is defined on line 2658 and is mentioned on five lines
on sheets 03, 24, and 26.

View file

@ -1,6 +0,0 @@
The numbers to the left of the file names in the table are sheet numbers.
The source code has been printed in a double column format with fifty
lines per column, giving one hundred lines per sheet (or page).
Thus there is a convenient relationship between line numbers and sheet numbers.