kernel.c

void _putchar(char c)

Implements a putchar function. Sends a single char value to the UART port.

Parameters
  • c – the char value

Since

v0.1

void uart_write_string(char *str)

Writes a string of an arbitrary length to the UART port.

Parameters
  • str – the char pointer

Since

v0.1

void kinit_hart(u64 hartid)

Performs a kernel init for a given hardware thread by its id. The other hardware threads start their execution here.

Parameters
  • hartid – uint64; obtained in an assembly code

Since

v0.1

void trap_hang_kernel(u64 epc, u64 tval, u64 cause, u64 hart, u64 status, TrapFrame *frame)

This function is used to perform system calls and switch tasks.

It is called by the assembly code in trap.s, when a hart experiences a trap event and after the processor state is stored in memory.

Parameters
  • epc – the program counter before the trap event (tells which instruction we were on)

  • tval – the value that caused the trap if there was a value involved (a segmentation fault for instance)

  • cause – what type of trap it was

  • hart – hardware thread that is trapping

  • status – TODO

  • frame – a TrapFrame pointer; the state of all the cpu registers

Since

v0.1

u64 m_trap(u64 epc, u64 tval, u64 cause, u64 hart, u64 status, TrapFrame *frame)

TODO

Parameters
  • epc – TODO

  • tval – TODO

  • cause – TODO

  • hart – TODO

  • status – TODO

  • frame – a TrapFrame pointer; the state of all the cpu registers

Returns

u64 TODO

Since

v0.1