xv6-riscv/kernel/defs.h

139 lines
3.3 KiB
C

#pragma once
#include "types.h"
#include "riscv.h"
#define PIPESIZE 512
struct buf;
struct context;
struct file;
struct inode;
struct spinlock;
struct pipe;
struct proc;
struct sleeplock;
struct stat;
struct superblock;
// bio.c
void binit(void);
struct buf *bread(uint, uint);
void brelse(struct buf *);
void bwrite(struct buf *);
void bpin(struct buf *);
void bunpin(struct buf *);
// exec.c
int exec(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(int);
int dirlink(struct inode *, char *, uint);
struct inode *dirlookup(struct inode *, char *, uint *);
struct inode *ialloc(uint, short);
struct inode *idup(struct inode *);
void iinit();
void ilock(struct inode *);
void iput(struct inode *);
void iunlock(struct inode *);
void iunlockput(struct inode *);
void iupdate(struct inode *);
int namecmp(const char *, const char *);
struct inode *namei(char *);
struct inode *nameiparent(char *, char *);
int readi(struct inode *, int, uint64, uint, uint);
void stati(struct inode *, struct stat *);
int writei(struct inode *, int, uint64, uint, uint);
void itrunc(struct inode *);
// ramdisk.c
void ramdiskinit(void);
void ramdiskintr(void);
void ramdiskrw(struct buf *);
// kalloc.c
void *kalloc(void);
void kfree(void *);
// log.c
void initlog(int, struct superblock *);
void log_write(struct buf *);
void begin_op(void);
void end_op(void);
// pipe.c
int pipealloc(struct file **, struct file **);
// printf.c
__attribute__((noreturn)) void panic(char *s);
void printstr(char *s);
void printint(int n);
// proc.c
void proc_mapstacks(pagetable_t);
pagetable_t proc_pagetable(struct proc *);
void proc_freepagetable(pagetable_t, uint64);
struct cpu *mycpu(void);
struct proc *myproc();
void procinit(void);
void sleep_lock(void *, struct spinlock *);
void userinit(void);
void wakeup(void *chan);
int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
// swtch.S
void swtch(struct context *, struct context *);
// spinlock.rs
void acquire(struct spinlock *);
void initlock(struct spinlock *, char *);
void release(struct spinlock *);
// sleeplock.c
void acquiresleep(struct sleeplock *);
void releasesleep(struct sleeplock *);
void initsleeplock(struct sleeplock *, char *);
// string.c
void *memmove(void *, const void *, uint);
void *memset(void *, uint8, uint64);
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 *);
// trap.c
void usertrapret(void);
// vm.c
uint64 uvmalloc(pagetable_t, uint64, uint64, int);
void uvmclear(pagetable_t, uint64);
uint64 walkaddr(pagetable_t, uint64);
int copyout(pagetable_t, uint64, char *, uint64);
int copyin(pagetable_t, char *, uint64, uint64);
// virtio_disk.c
void virtio_disk_init(void);
void virtio_disk_rw(struct buf *, int);
void virtio_disk_intr(void);
// number of elements in fixed-size array
#define NELEM(x) (sizeof(x) / sizeof((x)[0]))