Skip to content

Machine dependent headers

Dmitry Zavalishin edited this page May 18, 2017 · 4 revisions

Headers with machine-dependent stuff

Headers placed in include/ARCH_NAME/arch

For example, include/e2k/arch/ for Elbrus 2000

arch-flags.h

See kernel/boot.h

Parameters for ARCH_HAS_FLAG() and ARCH_SET_FLAG() macros, global info about CPU/HW abilities kernel needds to take in account.

arch-config.h and board-$(BOARD)-config.h

These are forced to be included in every file during compilation, can be used to configure kernel for specific architecture. Supposed to modify global kernel/config.h defines ('casue included after).

Default board config file name is board-$(ARCH)_default-config.h

arch-cpu_state.h

Defines struct cpu_state_save and corresponding macros to access it's fields from assembler.

Used in CPU state save during context (thread) switch.

arch-elf.h

Architecture dependent definitions for ELF file loader.

arch-limits.h

Just limits.h for this arch.

arch-page.h

Memory (MMU) page size, shift value and mask.

arch-types.h

Basic C types definitions.

arch_endian.h

Selects endianness.

Headers placed in misc places

TODO: need to move them to ARCH specific subtree too

$(ARCH)/asm.h

Definitions used all around the assembly code, such as ENTRY(x) (function entry point definition), etc.

$(ARCH)/trap.h

For example, e2k/trap.h.

  • struct trap_state - structure where trap/interrupt state is saved, either by CPU hardware and/or low level trap handler code.
  • TS_PROGRAM_COUNTER - name of field that contains saved instruction pointer

kernel/trap.h

Must include $(ARCH)/trap.h

kernel/interrupts.h

#define         MAX_IRQ_COUNT

setjmp.h

Jump buffer size

#define _JBLEN 10

phantom/user/SYS.h

Defines system call assembly source for Unix subsystem.

Example for ARM

#define	SYSCALL(x)	ENTRY(x); ldr r12, = SYS_##x; swi  0x0;

varargs.h

May need attention too.

$(ARCH)/proc_reg.h

Defines and access methods for CPU registers. Mostly talk about special ones, such as Intel CR3, debug registers, etc. Inline assembly wrappers used to execute special CPU instructions are usually come here too.

Clone this wiki locally