Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
tyfkda edited this page Sep 9, 2018 · 18 revisions

memo

fs

  • Block size(BSIZE): 512B
  • inodestart = 32, ninodes = 200
    • inode info: 0x4000~ (= inodestart * BSIZE)
  • bmapstart: 57, size=1 (= FSSIZE / (BSIZE * 8) + 1)
  • freeblock: 58~

Boot process

Process switch

  1. Timer interrupt (100ms)
  2. trap.c trap(), case T_IRQ0 + IRQ_TIMER:
  3. proc.c yield()
  4. proc.c shed()
  5. swtch.S swtch

write to stdout

Kernel:

  • sysfile.c: sys_write()
  • file.c: filewrite()
  • fs.c: writei() => return devsw[ip->major].write(ip, src, n);
    • console.c: consoleinit() => devsw[1].write = consolewrite
  • console.c: consolewrite()
  • console.c: consputc()
  • uart.c: uartputc()
  • console.c: cgaputc()

Pipe

Creation:

  • User space:
    • usys.S: pipe(int*)
  • Kernel space:
    • vectors.S: vector64 (T_SYSCALL=64)
    • trapasm.S: alltraps
    • trap.c: trap()
    • syscall.c: syscall()
    • sysfile.c: sys_pipe()
    • pipe.c: pipealloc()
      • filealloc x 2, 1 for read, 1 for write
      • kalloc x 1, used to keep pipe struct.

Write:

  • sysfile.c: sys_write()
  • file.c: filewrite()
  • pipe.c: pipewrite()

Read:

  • sysfile.c: sys_read()
  • file.c: fileread()
  • pipe.c: piperead()

TODOs

  • Sleep/wakeup mechanism
  • Fork/exec mechanism
  • Support >> in shell
    • Add file append mode
  • Add mtime to file info
    • RTC
  • Analyze ELF execution sequence (How to allocate memory, etc.)
  • Use .text, .rodata, .data, .bss sections
  • POSIX

Memory map

$ memmap
execelf: /bin/memmap
  vaddr=0, memsz=2908, filesz=18d1, sz=2908
  sz=2908
  sp=5000
main: 0x0
bss: 0x18e0
const_data: 0x1800
rw_data: 0x13e0
stack: 0x4f6c
sbrk: 0x5000
  • User stack: 1 x PGSIZE = 4096

Memory Map (kernel)

Address Entity
0x80100000- Kernel program

.

Clone this wiki locally