Kernel release notes

Memory map

Function Virtual address Physical address Size
User Flash 7d00 0000 + BMXPUPBA1d00 0000 + BMXPUPBA 512 kb - BMXPUPBA = 380 kb
User code RAM 7f00 0000 + BMXDUPBA1f00 0000 + BMXDUPBA 128 kb - BMXDUPBA = 96 kb
User data RAM 7f00 0000 + BMXDUDBA1f00 0000 + BMXDUDBA BMXDUPBA - BMXDUDBA = 0 kb
Kernel RAM 8000 0000 0000 0000 BMXDKPBA = 32 kb
Kernel Flash 9d00 0000 1d00 0000 BMXPUPBA = 192 kb
Peripheral bf00 0000 1f00 0000 1 Mb
Peripheral 2 bf80 0000 1f80 0000 1 Mb
Bootloader Flash bfc0 0000 1fc0 0000 12 kb
  • BMXPUPBA=192kb - kernel Flash memory size.
  • BMXDKPBA=32kb - kernel RAM size.
  • BMXDUDBA=BMXDKPBA - no kernel executable RAM.
  • BMXDUPBA=BMXDUDBA - all user RAM is executable.

File system

Block size is 1 kbyte = 1024 bytes. Block number (daddr_t) is 32-bit. Triple block indexing scheme is used, resulting in max file size of 16 GBytes.

Filesystem structure with size of K blocks, N inode blocks and S-kbyte swap file:

Block 0 Superblock
Blocks 1 … N Inodes, 16 per block
Blocks N+1 … N+S Swap file, immutable
Blocks N+S+1 … K-1 Data

Inodes are numbered starting from 1. Some inodes have special meaning:

  • Inode 1 - list of free blocks,
  • Inode 2 - root directory.
  • Inode 3 - lost+found directory.

Inode consists of 64 bytes, or 16 words:

  • Word 0: mode, nlink
  • Word 1: uid
  • Word 2: gid
  • Word 3: size
  • Words 4-7: direct blocks
  • Word 8: indirect block
  • Word 9: double indirect block
  • Word 10: triple indirect block
  • Word 11: unused
  • Word 12: flags
  • Word 13: atime
  • Word 14: mtime
  • Word 15: ctime

Directories must have a size multiple of 1024. Last directory entry should be extended to the end of block. Directory record:

4 bytes Inode number
2 bytes Record length
2 bytes Name length
4*K bytes Name, where K = (name length + 4) / 4

Context switch

For every process, there are three state save areas for saving and restoring a process context:

  • u_qsave - For switching from user process to a swapper. Also used for interrupted syscalls.
  • u_rsave - For switching from swapper to user process.
  • u_ssave - For starting forked process.

u_rsave:

N File Function Action
Save 1 kern_synch.c swtch() Switching from user process to swapper (proc 0).
Save 2 kern_synch.c swtch() Switching from swapper to any process.
Restore kern_synch.c swtch() Switching from swapper to a regular process (not starting one).

u_ssave:

Save kern_fork.c newproc() Creating a new process.
Restore kern_synch.c swtch() Switching from swapper to a starting forked process.

u_qsave:

Save 1 kern_synch.c swtch() Switching from swapper to a user process.
Save 2 sys_generic.c rwuio() Before starting file read/write.
Save 3 sys_inode.c ino_ioctl() Before calling inode d_ioctl().
Save 4 sys_inode.c closei() Before calling inode d_close().
Save 5 vfs_vnops.c vn_open() Before calling openi().
Save 6 exception.c syscall() Before calling syscall function.
Restore 1 kern_synch.c swtch() Switching from user process to swapper (proc 0).
Restore 2 kern_synch.c sleep() Timeout interrupted by signal.