Skip to content
forked from GrassLab/osc2021

Homework submission for student

License

Notifications You must be signed in to change notification settings

tl455047/osc2021

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Operating-System-Capstone 2021

Author

學號 GitHub 帳號 姓名 Email
309555003 tl455047 楊晨佑 tl455047.cs09@nycu.edu.tw

Goal

  • Implement an simple OS on Raspberry pi3 B+.

Content

  • Lab1: Hello World!
  • Lab2: Booting(Bootloader)
  • Lab3: Allocator
  • Lab4: Exception and Interrupt Handling
  • Lab5: Thread and User Process(Mult-task scheduling and Syscall)
  • Lab6: Virtual File System(tmpfs)
  • Lab7: File System Meets Hardware(FAT32)
  • Lab8: Virtual Memory

Implemented Feature

  • Lab1: Hello World!
    • required 1: Initialize rpi3 after booted by bootloader.
    • required 2: Following UART to set up mini UART.
    • required 3: Implement a simple shell supporting the listed commands.
    • elective 1: Add command.
  • Lab2: Booting
    • required 1: Implement UART bootloader that loads kernel images through UART.
    • required 2: Parse New ASCII Format Cpio archive, and read file’s content given file’s pathname.
    • elective 1: Add self-relocation to your UART bootloader, so you don’t need kernel_address= option in config.txt.
    • elective 2: Implement a parser that can iterate the device tree.
  • Lab3: Allocator
    • required 1: Implement the buddy system for contiguous page frames allocation.
    • required 2: Implement a dynamic memory allocator.
    • elective 1: Implement a startup allocator.
  • Lab4: Exception and Interrupt Handling
    • required 1-1: Switch from EL2 to EL1 .
    • required 1-2: Add a command that can load a user program in the initramfs. Then, use eret to jump to the start address.
    • required 1-3: Set the vector table and implement the exception handler.
    • required 1-4: Save the user program’s context before executing the exception handler.
    • required 2: Enable the core timer’s interrupt. The interrupt handler should print the seconds after booting and set the next timeout to 2 seconds later.
    • elective 1: Implement the asynchronous UART read/write by interrupt handlers.
    • elective 2: Implement the setTimeout command with the timer API.
    • elective 3-1: Implement a task queue mechanism, so interrupt handlers can add its processing tasks to it.
    • elective 3-2: Execute the tasks in the queue before returning to the user program with interrupts enabled.
    • elective 3-3: Implement the task queue’s preemption mechanism.
  • Lab5: Thread and User Process
    • required 1: Implement the thread mechanism.
    • required 2: Implement the the user process related mechanisms.
    • elective 1: Implement sleep() and uart_read() by wait queues.
    • elective 2: Implement kernel preemption.
    • elective 3: Implement POSIX signal.
  • Lab6: Virtual File System
    • required 1: Populate the root file system with initramfs using the VFS APIs and the tmpfs.
    • required 2: Implement the file descriptor table and the system calls so user processes can access the file system.
    • elective 1: Implement the ls program to list the target directory.
    • elective 2: Implement multi-levels VFS and pass the test.
    • elective 3-1: The procfs creates switch and hello file in its root directory. Users can access them by open, read, and write.
    • elective 3-2: The procfs lazily updates the per-process directories and files. Users can read process’s status by reading <process's id>/status.
  • Lab7: File System Meets Hardware (Only on qemu)
    • required 1-1: Get the FAT32 partition.
    • required 1-2: Parse the FAT32’s metadata and set up the mount.
    • required 2-1: Look up and open a file in FAT32.
    • required 2-2: Read/Write a file in FAT32.
    • elective 1: Create a file in FAT32.
    • elective 2: Implement a FAT32 with LFN support. You should create/lookup a file with special characters(e.g. Chinese) in its name.
    • elective 3: Create a UART device file as the console so users can get/print characters from/to the console by reading or writing its device file.
    • elective 4-1: Implement a component name cache mechanism for faster pathname lookup.
    • elective 4-2: Implement a page cache mechanism for faster file read and write.
    • elective 4-3: Implement the sync API to write back the cache data.
  • Lab8: Virtual Memory (Only on qemu)
    • required 1-1: Set up TCR_EL1.
    • required 1-2: Set up mair_el1.
    • required 1-3: Set up identity paging.
    • required 1-4: Modify the linker script, and map the kernel space.
    • required 1-5: Linear map kernel with finer granularity and map RAM as normal memory.
    • required 2-1: Implement user space paging.
    • required 2-2: Revisit fork() and exec() to map the same virtual address to different physical addresses for different processes.
    • required 2-3: Set ttbr0_el1 to switch the address space in context switches.
    • required 2-4: Implement a simple page fault handler.
    • elective 1: Implement mmap().
    • elective 2-1: Parse the ELF header.
    • elective 2-2: Implement ELF mapping.
    • elective 3: Implement demand paging.
    • elective 4: Implement copy-on-write.
  • ...

Environment

  • cross compiler GNU aarch64-linux-gnu-gcc.
  • qemu qemu-system-aarch64.
  • gdb-multiarch

How to build

  • cd lab*
    
  • Build the kernel.elf and kernel8.img.
  • make
    

How to run

Run on Raspberry pi3

  • See the output on terminal.
  • sudo screen /dev/ttyUSB0 115200
    

Run on qemu

  • Launch qemu.
  • make debug
    
  • To see the output of kernel, open another terminal. * is determined by make debug output.
  • sudo screen /dev/pts/* 
    
  • Launch gdb-multiarch, open another terminal.
  • gdb-multiarch
    
  • file kernel.elf 
    target remote :1234
    c
    

About

Homework submission for student

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 94.1%
  • Assembly 4.2%
  • Makefile 1.6%
  • Shell 0.1%