Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.
tyfkda edited this page Aug 27, 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

.

Clone this wiki locally