slkern/defs.h

191 lines
6.0 KiB
C
Raw Permalink Normal View History

// TODO: CHECK/REPLACE/UPDATE OLD CODE (this file is based on xv6)
#include "sched.h"
#include "fsinstance.h"
#include "mkfs/fsformat.h"
#include "diskio.h"
struct context;
struct file;
struct pipe;
struct proc;
struct stat;
struct fsinstance;
#ifdef _ZCC
void __sync_synchronize();
#endif
void _entry(); // Only invoked at boot, indicates start of kernel image
// bio.c
void binit(void);
diskio_buffer_t* bread(uint, uint);
void diskio_buffer_release(diskio_buffer_t*);
void diskio_buffer_write(diskio_buffer_t*);
void diskio_buffer_reference(diskio_buffer_t*);
void diskio_buffer_dereference(diskio_buffer_t*);
// console.c
void consoleinit(void);
void consoleintr(int);
void consputc(int);
// exec.c
int execve(char*, char**, char**);
// file.c
struct file* filealloc(void);
void fileclose(struct file*);
struct file* filedup(struct file*);
void fileinit(void);
int fileread(struct file*, uint64, int n);
int filestat(struct file*, uint64 addr);
int filewrite(struct file*, uint64, int n);
// fs.c
void* fsinit(struct fsinstance*, unsigned int);
int namecmp(const char*, const char*);
// ramdisk.c
void ramdiskinit(void);
void ramdiskintr(void);
void ramdiskrw(diskio_buffer_t*);
// physpg.c
#define PHYSPG_FREERAM 1001
#define PHYSPG_METADATA 1002
#define PHYSPG_KALLOC 1003
void physpg_initbegin();
void physpg_initend();
uint64 physpg_freeram();
uint64 physpg_totalram();
void* physpg_alloc1(int mode);
void physpg_free1(int mode, void* physpg);
void physpg_setrange(int mode, void* start, void* end);
#define kalloc() physpg_alloc1(PHYSPG_KALLOC)
#define kfree(p) physpg_free1(PHYSPG_KALLOC,p)
// log.c
void initlog(struct fsinstance*, int, fsformat_superblock_t*);
// pipe.c
int pipealloc(struct file**, struct file**);
void pipeclose(struct pipe*, int);
int piperead(struct pipe*, uint64, int);
int pipewrite(struct pipe*, uint64, int);
// proc.c
int cpuid(void);
void exit(int);
int fork(void);
int thrd(uint64 fnc, uint64 stk, uint64 arg);
int affin(uint64 mask);
int growproc(int);
void proc_mapstacks(pagetable_t);
pagetable_t proc_pagetable(struct proc *);
void proc_freepagetable(pagetable_t, uint64, int);
int kill(int);
int killed(struct proc*);
void setkilled(struct proc*);
struct proc* myproc();
void procinit(void);
#ifdef _ZCC
void scheduler(void);
#else
void scheduler(void) __attribute__((noreturn));
#endif
void sched(void);
void sleep(void*, sched_spinlock_t*);
void userinit(void);
int wait(uint64);
void yield(void);
int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
void procdump(void);
// swtch.S
void swtch(struct context*, struct context*);
// spinlock.c
void acquire(sched_spinlock_t*);
int holding(sched_spinlock_t*);
void initlock(sched_spinlock_t*, char*);
void release(sched_spinlock_t*);
void push_off(void);
void pop_off(void);
// sleeplock.c
void acquiresleep(sched_sleeplock_t*);
void releasesleep(sched_sleeplock_t*);
int holdingsleep(sched_sleeplock_t*);
void initsleeplock(sched_sleeplock_t*, char*);
// string.c
int memcmp(const void*, const void*, uint);
void* memmove(void*, const void*, uint);
void* memset(void*, int, unsigned long long);
char* safestrcpy(char*, const char*, int);
int strlen(const char*);
int strncmp(const char*, const char*, uint);
char* strncpy(char*, const char*, int);
// syscall.c
void argint(int, int*);
int argstr(int, char*, int);
void argaddr(int, uint64 *);
int fetchstr(uint64, char*, int);
int fetchaddr(uint64, uint64*);
void syscall();
// trap.c
extern uint ticks;
void trapinit(void);
void trapinithart(void);
extern sched_spinlock_t tickslock;
void usertrapret(void);
// uart.c
void uartinit(void);
void uartintr(void);
void uartputc(int);
void uartputc_sync(int);
int uartgetc(void);
// vm.c
void kvminit(void);
void kvminithart(void);
void kvmmap(pagetable_t, uint64, uint64, uint64, int);
int mappages(pagetable_t, uint64, uint64, uint64, int);
pagetable_t uvmcreate(void);
void uvmfirst(pagetable_t, uchar *, uint);
uint64 uvmalloc(pagetable_t, uint64, uint64, int);
uint64 uvmdealloc(pagetable_t, uint64, uint64);
int uvmcopy(pagetable_t, pagetable_t, uint64);
int uvmcopyshallow(pagetable_t, pagetable_t, uint64);
void uvmfree(pagetable_t, uint64, int);
void uvmunmap(pagetable_t, uint64, uint64, int);
void uvmclear(pagetable_t, uint64);
pte_t * walk(pagetable_t, uint64, int);
uint64 walkaddr(pagetable_t, uint64);
int copyout(pagetable_t, uint64, char *, uint64);
int copyin(pagetable_t, char *, uint64, uint64);
int copyinstr(pagetable_t, char *, uint64, uint64);
// plic.c
void plicinit(void);
void plicinithart(void);
int plic_claim(void);
void plic_complete(int);
// virtio_disk.c
void virtio_disk_init(void);
void virtio_disk_rw(diskio_buffer_t *, int);
void virtio_disk_intr(void);
// number of elements in fixed-size array
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
extern char end[]; // first address after kernel.
// defined by kernel.ld.
#define MB (1024ULL*1024ULL)