Header guards (#pragma once) for all kernel headers

This commit is contained in:
Imbus 2024-08-07 06:35:06 +02:00
parent ada9625a1b
commit a14ba848b3
17 changed files with 68 additions and 1 deletions

View file

@ -1,3 +1,9 @@
#pragma once
#include "types.h"
#include "sleeplock.h"
#include "fs.h"
struct buf { struct buf {
int valid; // has data been read from disk? int valid; // has data been read from disk?
int disk; // does disk "own" buf? int disk; // does disk "own" buf?

View file

@ -1,3 +1,8 @@
#pragma once
#include "riscv.h"
#include "types.h"
struct buf; struct buf;
struct context; struct context;
struct file; struct file;

View file

@ -1,3 +1,7 @@
#pragma once
#include "types.h"
// Format of an ELF executable file // Format of an ELF executable file
#define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian #define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian

View file

@ -1,3 +1,5 @@
#pragma once
#define O_RDONLY 0x000 #define O_RDONLY 0x000
#define O_WRONLY 0x001 #define O_WRONLY 0x001
#define O_RDWR 0x002 #define O_RDWR 0x002

View file

@ -1,3 +1,9 @@
#pragma once
#include "types.h"
#include "sleeplock.h"
#include "fs.h"
struct file { struct file {
enum { FD_NONE, FD_PIPE, FD_INODE, FD_DEVICE } type; enum { FD_NONE, FD_PIPE, FD_INODE, FD_DEVICE } type;
int ref; // reference count int ref; // reference count

View file

@ -1,3 +1,7 @@
#pragma once
#include "types.h"
// On-disk file system format. // On-disk file system format.
// Both the kernel and user programs use this header file. // Both the kernel and user programs use this header file.

View file

@ -1,3 +1,5 @@
#pragma once
// Physical memory layout // Physical memory layout
// qemu -machine virt is set up like this, // qemu -machine virt is set up like this,

View file

@ -1,3 +1,5 @@
#pragma once
#define NPROC 64 // maximum number of processes #define NPROC 64 // maximum number of processes
#define NCPU 8 // maximum number of CPUs #define NCPU 8 // maximum number of CPUs
#define NOFILE 16 // open files per process #define NOFILE 16 // open files per process

View file

@ -1,3 +1,10 @@
#pragma once
#include "types.h"
#include "param.h"
#include "riscv.h"
#include "spinlock.h"
// Saved registers for kernel context switches. // Saved registers for kernel context switches.
struct context { struct context {
u64 ra; u64 ra;

View file

@ -1,3 +1,7 @@
#pragma once
#include "types.h"
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__
// which hart (core) is this? // which hart (core) is this?

View file

@ -1,3 +1,8 @@
#pragma once
#include "types.h"
#include "spinlock.h"
// Long-term locks for processes // Long-term locks for processes
struct sleeplock { struct sleeplock {
u32 locked; // Is the lock held? u32 locked; // Is the lock held?

View file

@ -1,3 +1,7 @@
#pragma once
#include "types.h"
// Mutual exclusion lock. // Mutual exclusion lock.
struct spinlock { struct spinlock {
u32 locked; // Is the lock held? u32 locked; // Is the lock held?

View file

@ -1,3 +1,7 @@
#pragma once
#include "types.h"
#define T_DIR 1 // Directory #define T_DIR 1 // Directory
#define T_FILE 2 // File #define T_FILE 2 // File
#define T_DEVICE 3 // Device #define T_DEVICE 3 // Device

View file

@ -1,3 +1,5 @@
#pragma once
// System call numbers // System call numbers
#define SYS_fork 1 #define SYS_fork 1
#define SYS_exit 2 #define SYS_exit 2

View file

@ -1,3 +1,5 @@
#pragma once
typedef unsigned char u8; typedef unsigned char u8;
typedef unsigned short u16; typedef unsigned short u16;
typedef unsigned int u32; typedef unsigned int u32;

View file

@ -1,4 +1,7 @@
// #pragma once
#include "types.h"
// virtio device definitions. // virtio device definitions.
// for both the mmio interface, and virtio descriptors. // for both the mmio interface, and virtio descriptors.
// only tested with qemu. // only tested with qemu.

View file

@ -1,3 +1,7 @@
#pragma once
#include "../kernel/types.h"
struct stat; struct stat;
// system calls // system calls
@ -22,6 +26,7 @@ int getpid(void);
char *sbrk(int); char *sbrk(int);
int sleep(int); int sleep(int);
int uptime(void); int uptime(void);
int trace(int);
// ulib.c // ulib.c
int stat(const char *, struct stat *); int stat(const char *, struct stat *);