Formatted *.h files

feat/start
hheik 2024-04-30 00:59:43 +03:00
parent d9faacecaf
commit 8d44d9c964
18 changed files with 555 additions and 649 deletions

View File

@ -9,4 +9,3 @@ struct buf {
struct buf *next;
uchar data[BSIZE];
};

View File

@ -11,11 +11,11 @@ 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*);
struct buf *bread(uint, uint);
void brelse(struct buf *);
void bwrite(struct buf *);
void bpin(struct buf *);
void bunpin(struct buf *);
// console.c
void consoleinit(void);
@ -23,62 +23,62 @@ void consoleintr(int);
void consputc(int);
// exec.c
int exec(char*, char**);
int exec(char *, char **);
// file.c
struct file* filealloc(void);
void fileclose(struct file*);
struct file* filedup(struct file*);
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);
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*);
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*);
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*);
void ramdiskrw(struct buf *);
// kalloc.c
void* kalloc(void);
void *kalloc(void);
void kfree(void *);
void kinit(void);
// log.c
void initlog(int, struct superblock*);
void log_write(struct buf*);
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**);
void pipeclose(struct pipe*, int);
int piperead(struct pipe*, uint64, int);
int pipewrite(struct pipe*, uint64, int);
int pipealloc(struct file **, struct file **);
void pipeclose(struct pipe *, int);
int piperead(struct pipe *, uint64, int);
int pipewrite(struct pipe *, uint64, int);
// printf.c
void printf(char*, ...);
void panic(char*) __attribute__((noreturn));
void printf(char *, ...);
void panic(char *) __attribute__((noreturn));
void printfinit(void);
// proc.c
@ -90,55 +90,55 @@ void proc_mapstacks(pagetable_t);
pagetable_t proc_pagetable(struct proc *);
void proc_freepagetable(pagetable_t, uint64);
int kill(int);
int killed(struct proc*);
void setkilled(struct proc*);
struct cpu* mycpu(void);
struct cpu* getmycpu(void);
struct proc* myproc();
int killed(struct proc *);
void setkilled(struct proc *);
struct cpu *mycpu(void);
struct cpu *getmycpu(void);
struct proc *myproc();
void procinit(void);
void scheduler(void) __attribute__((noreturn));
void sched(void);
void sleep(void*, struct spinlock*);
void sleep(void *, struct spinlock *);
void userinit(void);
int wait(uint64);
void wakeup(void*);
void wakeup(void *);
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*);
void swtch(struct context *, struct context *);
// spinlock.c
void acquire(struct spinlock*);
int holding(struct spinlock*);
void initlock(struct spinlock*, char*);
void release(struct spinlock*);
void acquire(struct spinlock *);
int holding(struct spinlock *);
void initlock(struct spinlock *, char *);
void release(struct spinlock *);
void push_off(void);
void pop_off(void);
// sleeplock.c
void acquiresleep(struct sleeplock*);
void releasesleep(struct sleeplock*);
int holdingsleep(struct sleeplock*);
void initsleeplock(struct sleeplock*, char*);
void acquiresleep(struct sleeplock *);
void releasesleep(struct sleeplock *);
int holdingsleep(struct sleeplock *);
void initsleeplock(struct sleeplock *, char *);
// string.c
int memcmp(const void*, const void*, uint);
void* memmove(void*, const void*, uint);
void* memset(void*, int, uint);
char* safestrcpy(char*, const char*, int);
int strlen(const char*);
int strncmp(const char*, const char*, uint);
char* strncpy(char*, const char*, int);
int memcmp(const void *, const void *, uint);
void *memmove(void *, const void *, uint);
void *memset(void *, int, uint);
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 argint(int, int *);
int argstr(int, char *, int);
void argaddr(int, uint64 *);
int fetchstr(uint64, char*, int);
int fetchaddr(uint64, uint64*);
int fetchstr(uint64, char *, int);
int fetchaddr(uint64, uint64 *);
void syscall();
// trap.c
@ -168,7 +168,7 @@ int uvmcopy(pagetable_t, pagetable_t, uint64);
void uvmfree(pagetable_t, uint64);
void uvmunmap(pagetable_t, uint64, uint64, int);
void uvmclear(pagetable_t, uint64);
pte_t * walk(pagetable_t, uint64, int);
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);
@ -186,4 +186,4 @@ 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]))
#define NELEM(x) (sizeof(x) / sizeof((x)[0]))

View File

@ -11,7 +11,7 @@ struct file {
#define major(dev) ((dev) >> 16 & 0xFFFF)
#define minor(dev) ((dev) & 0xFFFF)
#define mkdev(m,n) ((uint)((m)<<16| (n)))
#define mkdev(m, n) ((uint)((m) << 16 | (n)))
// in-memory copy of an inode
struct inode {
@ -26,7 +26,7 @@ struct inode {
short minor;
short nlink;
uint size;
uint addrs[NDIRECT+1];
uint addrs[NDIRECT + 1];
};
// map major device number to device functions.

View File

@ -1,7 +1,6 @@
// On-disk file system format.
// Both the kernel and user programs use this header file.
#define ROOTINO 1 // root i-number
#define BSIZE 1024 // block size
@ -35,7 +34,7 @@ struct dinode {
short minor; // Minor device number (T_DEVICE only)
short nlink; // Number of links to inode in file system
uint size; // Size of file (bytes)
uint addrs[NDIRECT+1]; // Data block addresses
uint addrs[NDIRECT + 1]; // Data block addresses
};
// Inodes per block.
@ -45,10 +44,10 @@ struct dinode {
#define IBLOCK(i, sb) ((i) / IPB + sb.inodestart)
// Bitmap bits per block
#define BPB (BSIZE*8)
#define BPB (BSIZE * 8)
// Block of free map containing bit for block b
#define BBLOCK(b, sb) ((b)/BPB + sb.bmapstart)
#define BBLOCK(b, sb) ((b) / BPB + sb.bmapstart)
// Directory is a file containing a sequence of dirent structures.
#define DIRSIZ 14
@ -57,4 +56,3 @@ struct dirent {
ushort inum;
char name[DIRSIZ];
};

View File

@ -3,9 +3,7 @@
#include "memlayout.h"
#include "riscv.h"
#include "defs.h"
#include <stdint.h>
extern int32_t add(int32_t right, int32_t left);
#include "rust.h"
volatile static int started = 0;

View File

@ -27,25 +27,25 @@
// core local interruptor (CLINT), which contains the timer.
#define CLINT 0x2000000L
#define CLINT_MTIMECMP(hartid) (CLINT + 0x4000 + 8*(hartid))
#define CLINT_MTIMECMP(hartid) (CLINT + 0x4000 + 8 * (hartid))
#define CLINT_MTIME (CLINT + 0xBFF8) // cycles since boot.
// qemu puts platform-level interrupt controller (PLIC) here.
#define PLIC 0x0c000000L
#define PLIC_PRIORITY (PLIC + 0x0)
#define PLIC_PENDING (PLIC + 0x1000)
#define PLIC_MENABLE(hart) (PLIC + 0x2000 + (hart)*0x100)
#define PLIC_SENABLE(hart) (PLIC + 0x2080 + (hart)*0x100)
#define PLIC_MPRIORITY(hart) (PLIC + 0x200000 + (hart)*0x2000)
#define PLIC_SPRIORITY(hart) (PLIC + 0x201000 + (hart)*0x2000)
#define PLIC_MCLAIM(hart) (PLIC + 0x200004 + (hart)*0x2000)
#define PLIC_SCLAIM(hart) (PLIC + 0x201004 + (hart)*0x2000)
#define PLIC_MENABLE(hart) (PLIC + 0x2000 + (hart) * 0x100)
#define PLIC_SENABLE(hart) (PLIC + 0x2080 + (hart) * 0x100)
#define PLIC_MPRIORITY(hart) (PLIC + 0x200000 + (hart) * 0x2000)
#define PLIC_SPRIORITY(hart) (PLIC + 0x201000 + (hart) * 0x2000)
#define PLIC_MCLAIM(hart) (PLIC + 0x200004 + (hart) * 0x2000)
#define PLIC_SCLAIM(hart) (PLIC + 0x201004 + (hart) * 0x2000)
// the kernel expects there to be RAM
// for use by the kernel and user pages
// from physical address 0x80000000 to PHYSTOP.
#define KERNBASE 0x80000000L
#define PHYSTOP (KERNBASE + 128*1024*1024)
#define PHYSTOP (KERNBASE + 128 * 1024 * 1024)
// map the trampoline page to the highest address,
// in both user and kernel space.
@ -53,7 +53,7 @@
// map kernel stacks beneath the trampoline,
// each surrounded by invalid guard pages.
#define KSTACK(p) (TRAMPOLINE - ((p)+1)* 2*PGSIZE)
#define KSTACK(p) (TRAMPOLINE - ((p) + 1) * 2 * PGSIZE)
// User memory layout.
// Address zero first:

View File

@ -7,7 +7,7 @@
#define ROOTDEV 1 // device number of file system root disk
#define MAXARG 32 // max exec arguments
#define MAXOPBLOCKS 10 // max # of blocks any FS op writes
#define LOGSIZE (MAXOPBLOCKS*3) // max data blocks in on-disk log
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
#define LOGSIZE (MAXOPBLOCKS * 3) // max data blocks in on-disk log
#define NBUF (MAXOPBLOCKS * 3) // size of disk block cache
#define FSSIZE 2000 // size of file system in blocks
#define MAXPATH 128 // maximum file path name

View File

@ -1,11 +1,9 @@
#ifndef __ASSEMBLER__
// which hart (core) is this?
static inline uint64
r_mhartid()
{
static inline uint64 r_mhartid() {
uint64 x;
asm volatile("csrr %0, mhartid" : "=r" (x) );
asm volatile("csrr %0, mhartid" : "=r"(x));
return x;
}
@ -17,27 +15,21 @@ r_mhartid()
#define MSTATUS_MPP_U (0L << 11)
#define MSTATUS_MIE (1L << 3) // machine-mode interrupt enable.
static inline uint64
r_mstatus()
{
static inline uint64 r_mstatus() {
uint64 x;
asm volatile("csrr %0, mstatus" : "=r" (x) );
asm volatile("csrr %0, mstatus" : "=r"(x));
return x;
}
static inline void
w_mstatus(uint64 x)
{
asm volatile("csrw mstatus, %0" : : "r" (x));
static inline void w_mstatus(uint64 x) {
asm volatile("csrw mstatus, %0" : : "r"(x));
}
// machine exception program counter, holds the
// instruction address to which a return from
// exception will go.
static inline void
w_mepc(uint64 x)
{
asm volatile("csrw mepc, %0" : : "r" (x));
static inline void w_mepc(uint64 x) {
asm volatile("csrw mepc, %0" : : "r"(x));
}
// Supervisor Status Register, sstatus
@ -48,152 +40,108 @@ w_mepc(uint64 x)
#define SSTATUS_SIE (1L << 1) // Supervisor Interrupt Enable
#define SSTATUS_UIE (1L << 0) // User Interrupt Enable
static inline uint64
r_sstatus()
{
static inline uint64 r_sstatus() {
uint64 x;
asm volatile("csrr %0, sstatus" : "=r" (x) );
asm volatile("csrr %0, sstatus" : "=r"(x));
return x;
}
static inline void
w_sstatus(uint64 x)
{
asm volatile("csrw sstatus, %0" : : "r" (x));
static inline void w_sstatus(uint64 x) {
asm volatile("csrw sstatus, %0" : : "r"(x));
}
// Supervisor Interrupt Pending
static inline uint64
r_sip()
{
static inline uint64 r_sip() {
uint64 x;
asm volatile("csrr %0, sip" : "=r" (x) );
asm volatile("csrr %0, sip" : "=r"(x));
return x;
}
static inline void
w_sip(uint64 x)
{
asm volatile("csrw sip, %0" : : "r" (x));
}
static inline void w_sip(uint64 x) { asm volatile("csrw sip, %0" : : "r"(x)); }
// Supervisor Interrupt Enable
#define SIE_SEIE (1L << 9) // external
#define SIE_STIE (1L << 5) // timer
#define SIE_SSIE (1L << 1) // software
static inline uint64
r_sie()
{
static inline uint64 r_sie() {
uint64 x;
asm volatile("csrr %0, sie" : "=r" (x) );
asm volatile("csrr %0, sie" : "=r"(x));
return x;
}
static inline void
w_sie(uint64 x)
{
asm volatile("csrw sie, %0" : : "r" (x));
}
static inline void w_sie(uint64 x) { asm volatile("csrw sie, %0" : : "r"(x)); }
// Machine-mode Interrupt Enable
#define MIE_MEIE (1L << 11) // external
#define MIE_MTIE (1L << 7) // timer
#define MIE_MSIE (1L << 3) // software
static inline uint64
r_mie()
{
static inline uint64 r_mie() {
uint64 x;
asm volatile("csrr %0, mie" : "=r" (x) );
asm volatile("csrr %0, mie" : "=r"(x));
return x;
}
static inline void
w_mie(uint64 x)
{
asm volatile("csrw mie, %0" : : "r" (x));
}
static inline void w_mie(uint64 x) { asm volatile("csrw mie, %0" : : "r"(x)); }
// supervisor exception program counter, holds the
// instruction address to which a return from
// exception will go.
static inline void
w_sepc(uint64 x)
{
asm volatile("csrw sepc, %0" : : "r" (x));
static inline void w_sepc(uint64 x) {
asm volatile("csrw sepc, %0" : : "r"(x));
}
static inline uint64
r_sepc()
{
static inline uint64 r_sepc() {
uint64 x;
asm volatile("csrr %0, sepc" : "=r" (x) );
asm volatile("csrr %0, sepc" : "=r"(x));
return x;
}
// Machine Exception Delegation
static inline uint64
r_medeleg()
{
static inline uint64 r_medeleg() {
uint64 x;
asm volatile("csrr %0, medeleg" : "=r" (x) );
asm volatile("csrr %0, medeleg" : "=r"(x));
return x;
}
static inline void
w_medeleg(uint64 x)
{
asm volatile("csrw medeleg, %0" : : "r" (x));
static inline void w_medeleg(uint64 x) {
asm volatile("csrw medeleg, %0" : : "r"(x));
}
// Machine Interrupt Delegation
static inline uint64
r_mideleg()
{
static inline uint64 r_mideleg() {
uint64 x;
asm volatile("csrr %0, mideleg" : "=r" (x) );
asm volatile("csrr %0, mideleg" : "=r"(x));
return x;
}
static inline void
w_mideleg(uint64 x)
{
asm volatile("csrw mideleg, %0" : : "r" (x));
static inline void w_mideleg(uint64 x) {
asm volatile("csrw mideleg, %0" : : "r"(x));
}
// Supervisor Trap-Vector Base Address
// low two bits are mode.
static inline void
w_stvec(uint64 x)
{
asm volatile("csrw stvec, %0" : : "r" (x));
static inline void w_stvec(uint64 x) {
asm volatile("csrw stvec, %0" : : "r"(x));
}
static inline uint64
r_stvec()
{
static inline uint64 r_stvec() {
uint64 x;
asm volatile("csrr %0, stvec" : "=r" (x) );
asm volatile("csrr %0, stvec" : "=r"(x));
return x;
}
// Machine-mode interrupt vector
static inline void
w_mtvec(uint64 x)
{
asm volatile("csrw mtvec, %0" : : "r" (x));
static inline void w_mtvec(uint64 x) {
asm volatile("csrw mtvec, %0" : : "r"(x));
}
// Physical Memory Protection
static inline void
w_pmpcfg0(uint64 x)
{
asm volatile("csrw pmpcfg0, %0" : : "r" (x));
static inline void w_pmpcfg0(uint64 x) {
asm volatile("csrw pmpcfg0, %0" : : "r"(x));
}
static inline void
w_pmpaddr0(uint64 x)
{
asm volatile("csrw pmpaddr0, %0" : : "r" (x));
static inline void w_pmpaddr0(uint64 x) {
asm volatile("csrw pmpaddr0, %0" : : "r"(x));
}
// use riscv's sv39 page table scheme.
@ -203,126 +151,88 @@ w_pmpaddr0(uint64 x)
// supervisor address translation and protection;
// holds the address of the page table.
static inline void
w_satp(uint64 x)
{
asm volatile("csrw satp, %0" : : "r" (x));
static inline void w_satp(uint64 x) {
asm volatile("csrw satp, %0" : : "r"(x));
}
static inline uint64
r_satp()
{
static inline uint64 r_satp() {
uint64 x;
asm volatile("csrr %0, satp" : "=r" (x) );
asm volatile("csrr %0, satp" : "=r"(x));
return x;
}
static inline void
w_mscratch(uint64 x)
{
asm volatile("csrw mscratch, %0" : : "r" (x));
static inline void w_mscratch(uint64 x) {
asm volatile("csrw mscratch, %0" : : "r"(x));
}
// Supervisor Trap Cause
static inline uint64
r_scause()
{
static inline uint64 r_scause() {
uint64 x;
asm volatile("csrr %0, scause" : "=r" (x) );
asm volatile("csrr %0, scause" : "=r"(x));
return x;
}
// Supervisor Trap Value
static inline uint64
r_stval()
{
static inline uint64 r_stval() {
uint64 x;
asm volatile("csrr %0, stval" : "=r" (x) );
asm volatile("csrr %0, stval" : "=r"(x));
return x;
}
// Machine-mode Counter-Enable
static inline void
w_mcounteren(uint64 x)
{
asm volatile("csrw mcounteren, %0" : : "r" (x));
static inline void w_mcounteren(uint64 x) {
asm volatile("csrw mcounteren, %0" : : "r"(x));
}
static inline uint64
r_mcounteren()
{
static inline uint64 r_mcounteren() {
uint64 x;
asm volatile("csrr %0, mcounteren" : "=r" (x) );
asm volatile("csrr %0, mcounteren" : "=r"(x));
return x;
}
// machine-mode cycle counter
static inline uint64
r_time()
{
static inline uint64 r_time() {
uint64 x;
asm volatile("csrr %0, time" : "=r" (x) );
asm volatile("csrr %0, time" : "=r"(x));
return x;
}
// enable device interrupts
static inline void
intr_on()
{
w_sstatus(r_sstatus() | SSTATUS_SIE);
}
static inline void intr_on() { w_sstatus(r_sstatus() | SSTATUS_SIE); }
// disable device interrupts
static inline void
intr_off()
{
w_sstatus(r_sstatus() & ~SSTATUS_SIE);
}
static inline void intr_off() { w_sstatus(r_sstatus() & ~SSTATUS_SIE); }
// are device interrupts enabled?
static inline int
intr_get()
{
static inline int intr_get() {
uint64 x = r_sstatus();
return (x & SSTATUS_SIE) != 0;
}
static inline uint64
r_sp()
{
static inline uint64 r_sp() {
uint64 x;
asm volatile("mv %0, sp" : "=r" (x) );
asm volatile("mv %0, sp" : "=r"(x));
return x;
}
// read and write tp, the thread pointer, which xv6 uses to hold
// this core's hartid (core number), the index into cpus[].
static inline uint64
r_tp()
{
static inline uint64 r_tp() {
uint64 x;
asm volatile("mv %0, tp" : "=r" (x) );
asm volatile("mv %0, tp" : "=r"(x));
return x;
}
static inline void
w_tp(uint64 x)
{
asm volatile("mv tp, %0" : : "r" (x));
}
static inline void w_tp(uint64 x) { asm volatile("mv tp, %0" : : "r"(x)); }
static inline uint64
r_ra()
{
static inline uint64 r_ra() {
uint64 x;
asm volatile("mv %0, ra" : "=r" (x) );
asm volatile("mv %0, ra" : "=r"(x));
return x;
}
// flush the TLB.
static inline void
sfence_vma()
{
static inline void sfence_vma() {
// the zero, zero means flush all TLB entries.
asm volatile("sfence.vma zero, zero");
}
@ -335,8 +245,8 @@ typedef uint64 *pagetable_t; // 512 PTEs
#define PGSIZE 4096 // bytes per page
#define PGSHIFT 12 // bits of offset within a page
#define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1))
#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1))
#define PGROUNDUP(sz) (((sz) + PGSIZE - 1) & ~(PGSIZE - 1))
#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE - 1))
#define PTE_V (1L << 0) // valid
#define PTE_R (1L << 1)
@ -353,8 +263,8 @@ typedef uint64 *pagetable_t; // 512 PTEs
// extract the three 9-bit page table indices from a virtual address.
#define PXMASK 0x1FF // 9 bits
#define PXSHIFT(level) (PGSHIFT+(9*(level)))
#define PX(level, va) ((((uint64) (va)) >> PXSHIFT(level)) & PXMASK)
#define PXSHIFT(level) (PGSHIFT + (9 * (level)))
#define PX(level, va) ((((uint64)(va)) >> PXSHIFT(level)) & PXMASK)
// one beyond the highest possible virtual address.
// MAXVA is actually one bit less than the max allowed by

View File

@ -7,4 +7,3 @@ struct sleeplock {
char *name; // Name of lock.
int pid; // Process holding lock
};

View File

@ -6,4 +6,3 @@ struct spinlock {
char *name; // Name of lock.
struct cpu *cpu; // The cpu holding the lock.
};

View File

@ -23,11 +23,14 @@
#define VIRTIO_MMIO_INTERRUPT_STATUS 0x060 // read-only
#define VIRTIO_MMIO_INTERRUPT_ACK 0x064 // write-only
#define VIRTIO_MMIO_STATUS 0x070 // read/write
#define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080 // physical address for descriptor table, write-only
#define VIRTIO_MMIO_QUEUE_DESC_LOW \
0x080 // physical address for descriptor table, write-only
#define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084
#define VIRTIO_MMIO_DRIVER_DESC_LOW 0x090 // physical address for available ring, write-only
#define VIRTIO_MMIO_DRIVER_DESC_LOW \
0x090 // physical address for available ring, write-only
#define VIRTIO_MMIO_DRIVER_DESC_HIGH 0x094
#define VIRTIO_MMIO_DEVICE_DESC_LOW 0x0a0 // physical address for used ring, write-only
#define VIRTIO_MMIO_DEVICE_DESC_LOW \
0x0a0 // physical address for used ring, write-only
#define VIRTIO_MMIO_DEVICE_DESC_HIGH 0x0a4
// status register bits, from qemu virtio_config.h

View File

@ -3,39 +3,39 @@ struct stat;
// system calls
int fork(void);
int exit(int) __attribute__((noreturn));
int wait(int*);
int pipe(int*);
int write(int, const void*, int);
int read(int, void*, int);
int wait(int *);
int pipe(int *);
int write(int, const void *, int);
int read(int, void *, int);
int close(int);
int kill(int);
int exec(const char*, char**);
int open(const char*, int);
int mknod(const char*, short, short);
int unlink(const char*);
int fstat(int fd, struct stat*);
int link(const char*, const char*);
int mkdir(const char*);
int chdir(const char*);
int exec(const char *, char **);
int open(const char *, int);
int mknod(const char *, short, short);
int unlink(const char *);
int fstat(int fd, struct stat *);
int link(const char *, const char *);
int mkdir(const char *);
int chdir(const char *);
int dup(int);
int getpid(void);
char* sbrk(int);
char *sbrk(int);
int sleep(int);
int uptime(void);
// ulib.c
int stat(const char*, struct stat*);
char* strcpy(char*, const char*);
void *memmove(void*, const void*, int);
char* strchr(const char*, char c);
int strcmp(const char*, const char*);
void fprintf(int, const char*, ...);
void printf(const char*, ...);
char* gets(char*, int max);
uint strlen(const char*);
void* memset(void*, int, uint);
void* malloc(uint);
void free(void*);
int atoi(const char*);
int stat(const char *, struct stat *);
char *strcpy(char *, const char *);
void *memmove(void *, const void *, int);
char *strchr(const char *, char c);
int strcmp(const char *, const char *);
void fprintf(int, const char *, ...);
void printf(const char *, ...);
char *gets(char *, int max);
uint strlen(const char *);
void *memset(void *, int, uint);
void *malloc(uint);
void free(void *);
int atoi(const char *);
int memcmp(const void *, const void *, uint);
void *memcpy(void *, const void *, uint);