Compare commits

..

No commits in common. "9d0123f43ef3595278649fdc68114293fa1a52fe" and "eccdaeeaaa27de06f240726281abd5fe53d5d8cf" have entirely different histories.

20 changed files with 7 additions and 85 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,10 +1,3 @@
#pragma once
#include "types.h"
#include "param.h"
#include "riscv.h"
#include "spinlock.h"
// Saved registers for kernel context switches.
struct context {
u64 ra;
@ -111,5 +104,4 @@ struct proc {
struct file *ofile[NOFILE]; // Open files
struct inode *cwd; // Current directory
char name[16]; // Process name (debugging)
int mask; // Process mask
};

View file

@ -1,9 +1,5 @@
#pragma once
#ifndef __ASSEMBLER__
#include "types.h"
// which hart (core) is this?
static inline u64
r_mhartid()

View file

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

View file

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

View file

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

View file

@ -101,17 +101,16 @@ extern u64 sys_unlink(void);
extern u64 sys_link(void);
extern u64 sys_mkdir(void);
extern u64 sys_close(void);
extern u64 sys_trace(void);
// An array mapping syscall numbers from syscall.h
// to the function that handles the system call.
static u64 (*syscalls[])(void) = {
[SYS_fork] = sys_fork, [SYS_exit] = sys_exit, [SYS_wait] = sys_wait, [SYS_pipe] = sys_pipe,
[SYS_read] = sys_read, [SYS_kill] = sys_kill, [SYS_exec] = sys_exec, [SYS_fstat] = sys_fstat,
[SYS_chdir] = sys_chdir, [SYS_dup] = sys_dup, [SYS_getpid] = sys_getpid, [SYS_sbrk] = sys_sbrk,
[SYS_sleep] = sys_sleep, [SYS_uptime] = sys_uptime, [SYS_open] = sys_open, [SYS_write] = sys_write,
[SYS_mknod] = sys_mknod, [SYS_unlink] = sys_unlink, [SYS_link] = sys_link, [SYS_mkdir] = sys_mkdir,
[SYS_close] = sys_close, [SYS_trace] = sys_trace,
[SYS_fork] sys_fork, [SYS_exit] sys_exit, [SYS_wait] sys_wait, [SYS_pipe] sys_pipe,
[SYS_read] sys_read, [SYS_kill] sys_kill, [SYS_exec] sys_exec, [SYS_fstat] sys_fstat,
[SYS_chdir] sys_chdir, [SYS_dup] sys_dup, [SYS_getpid] sys_getpid, [SYS_sbrk] sys_sbrk,
[SYS_sleep] sys_sleep, [SYS_uptime] sys_uptime, [SYS_open] sys_open, [SYS_write] sys_write,
[SYS_mknod] sys_mknod, [SYS_unlink] sys_unlink, [SYS_link] sys_link, [SYS_mkdir] sys_mkdir,
[SYS_close] sys_close,
};
void

View file

@ -1,5 +1,3 @@
#pragma once
// System call numbers
#define SYS_fork 1
#define SYS_exit 2
@ -22,4 +20,3 @@
#define SYS_link 19
#define SYS_mkdir 20
#define SYS_close 21
#define SYS_trace 22

View file

@ -89,10 +89,3 @@ sys_uptime(void)
release(&tickslock);
return xticks;
}
u64
sys_trace(void)
{
/* TODO: Implement sys_trace */
return 0;
}

View file

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

View file

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

View file

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

View file

@ -36,4 +36,3 @@ entry("getpid");
entry("sbrk");
entry("sleep");
entry("uptime");
entry("trace");