clang-format

This commit is contained in:
2024-09-10 13:03:02 -04:00
parent 53c617d779
commit d66450e427
381 changed files with 28864 additions and 34170 deletions

View File

@@ -34,13 +34,11 @@
* Address space structure and operations.
*/
#include <vm.h>
#include "opt-dumbvm.h"
struct vnode;
/*
* Address space - data structure associated with the virtual memory
* space of a process.
@@ -50,15 +48,15 @@ struct vnode;
struct addrspace {
#if OPT_DUMBVM
vaddr_t as_vbase1;
paddr_t as_pbase1;
size_t as_npages1;
vaddr_t as_vbase2;
paddr_t as_pbase2;
size_t as_npages2;
paddr_t as_stackpbase;
vaddr_t as_vbase1;
paddr_t as_pbase1;
size_t as_npages1;
vaddr_t as_vbase2;
paddr_t as_pbase2;
size_t as_npages2;
paddr_t as_stackpbase;
#else
/* Put stuff here for your VM system */
/* Put stuff here for your VM system */
#endif
};
@@ -104,20 +102,16 @@ struct addrspace {
*/
struct addrspace *as_create(void);
int as_copy(struct addrspace *src, struct addrspace **ret);
void as_activate(void);
void as_deactivate(void);
void as_destroy(struct addrspace *);
int as_define_region(struct addrspace *as,
vaddr_t vaddr, size_t sz,
int readable,
int writeable,
int executable);
int as_prepare_load(struct addrspace *as);
int as_complete_load(struct addrspace *as);
int as_define_stack(struct addrspace *as, vaddr_t *initstackptr);
int as_copy(struct addrspace *src, struct addrspace **ret);
void as_activate(void);
void as_deactivate(void);
void as_destroy(struct addrspace *);
int as_define_region(struct addrspace *as, vaddr_t vaddr, size_t sz,
int readable, int writeable, int executable);
int as_prepare_load(struct addrspace *as);
int as_complete_load(struct addrspace *as);
int as_define_stack(struct addrspace *as, vaddr_t *initstackptr);
/*
* Functions in loadelf.c
@@ -128,5 +122,4 @@ int as_define_stack(struct addrspace *as, vaddr_t *initstackptr);
int load_elf(struct vnode *v, vaddr_t *entrypoint);
#endif /* _ADDRSPACE_H_ */

View File

@@ -68,8 +68,8 @@
*/
struct array {
void **v;
unsigned num, max;
void **v;
unsigned num, max;
};
struct array *array_create(void);
@@ -88,42 +88,32 @@ void array_remove(struct array *, unsigned index);
* Inlining for base operations
*/
ARRAYINLINE unsigned
array_num(const struct array *a)
{
return a->num;
ARRAYINLINE unsigned array_num(const struct array *a) { return a->num; }
ARRAYINLINE void *array_get(const struct array *a, unsigned index) {
ARRAYASSERT(index < a->num);
return a->v[index];
}
ARRAYINLINE void *
array_get(const struct array *a, unsigned index)
{
ARRAYASSERT(index < a->num);
return a->v[index];
ARRAYINLINE void array_set(const struct array *a, unsigned index, void *val) {
ARRAYASSERT(index < a->num);
a->v[index] = val;
}
ARRAYINLINE void
array_set(const struct array *a, unsigned index, void *val)
{
ARRAYASSERT(index < a->num);
a->v[index] = val;
}
ARRAYINLINE int array_add(struct array *a, void *val, unsigned *index_ret) {
unsigned index;
int ret;
ARRAYINLINE int
array_add(struct array *a, void *val, unsigned *index_ret)
{
unsigned index;
int ret;
index = a->num;
ret = array_setsize(a, index+1);
if (ret) {
return ret;
}
a->v[index] = val;
if (index_ret != NULL) {
*index_ret = index;
}
return 0;
index = a->num;
ret = array_setsize(a, index + 1);
if (ret) {
return ret;
}
a->v[index] = val;
if (index_ret != NULL) {
*index_ret = index;
}
return 0;
}
/*
@@ -165,95 +155,69 @@ array_add(struct array *a, void *val, unsigned *index_ret)
* the base array, except typed.
*/
#define DECLARRAY_BYTYPE(ARRAY, T, INLINE) \
struct ARRAY { \
struct array arr; \
}; \
\
INLINE struct ARRAY *ARRAY##_create(void); \
INLINE void ARRAY##_destroy(struct ARRAY *a); \
INLINE void ARRAY##_init(struct ARRAY *a); \
INLINE void ARRAY##_cleanup(struct ARRAY *a); \
INLINE unsigned ARRAY##_num(const struct ARRAY *a); \
INLINE T *ARRAY##_get(const struct ARRAY *a, unsigned index); \
INLINE void ARRAY##_set(struct ARRAY *a, unsigned index, T *val); \
INLINE int ARRAY##_preallocate(struct ARRAY *a, unsigned num); \
INLINE int ARRAY##_setsize(struct ARRAY *a, unsigned num); \
INLINE int ARRAY##_add(struct ARRAY *a, T *val, unsigned *index_ret); \
INLINE void ARRAY##_remove(struct ARRAY *a, unsigned index)
#define DECLARRAY_BYTYPE(ARRAY, T, INLINE) \
struct ARRAY { \
struct array arr; \
}; \
\
INLINE struct ARRAY *ARRAY##_create(void); \
INLINE void ARRAY##_destroy(struct ARRAY *a); \
INLINE void ARRAY##_init(struct ARRAY *a); \
INLINE void ARRAY##_cleanup(struct ARRAY *a); \
INLINE unsigned ARRAY##_num(const struct ARRAY *a); \
INLINE T *ARRAY##_get(const struct ARRAY *a, unsigned index); \
INLINE void ARRAY##_set(struct ARRAY *a, unsigned index, T *val); \
INLINE int ARRAY##_preallocate(struct ARRAY *a, unsigned num); \
INLINE int ARRAY##_setsize(struct ARRAY *a, unsigned num); \
INLINE int ARRAY##_add(struct ARRAY *a, T *val, unsigned *index_ret); \
INLINE void ARRAY##_remove(struct ARRAY *a, unsigned index)
#define DEFARRAY_BYTYPE(ARRAY, T, INLINE) \
INLINE struct ARRAY * \
ARRAY##_create(void) \
{ \
struct ARRAY *a = kmalloc(sizeof(*a)); \
if (a == NULL) { \
return NULL; \
} \
array_init(&a->arr); \
return a; \
} \
\
INLINE void \
ARRAY##_destroy(struct ARRAY *a) \
{ \
array_cleanup(&a->arr); \
kfree(a); \
} \
\
INLINE void \
ARRAY##_init(struct ARRAY *a) \
{ \
array_init(&a->arr); \
} \
\
INLINE void \
ARRAY##_cleanup(struct ARRAY *a) \
{ \
array_cleanup(&a->arr); \
} \
\
INLINE unsigned \
ARRAY##_num(const struct ARRAY *a) \
{ \
return array_num(&a->arr); \
} \
\
INLINE T * \
ARRAY##_get(const struct ARRAY *a, unsigned index) \
{ \
return (T *)array_get(&a->arr, index); \
} \
\
INLINE void \
ARRAY##_set(struct ARRAY *a, unsigned index, T *val) \
{ \
array_set(&a->arr, index, (void *)val); \
} \
\
INLINE int \
ARRAY##_preallocate(struct ARRAY *a, unsigned num) \
{ \
return array_preallocate(&a->arr, num); \
} \
\
INLINE int \
ARRAY##_setsize(struct ARRAY *a, unsigned num) \
{ \
return array_setsize(&a->arr, num); \
} \
\
INLINE int \
ARRAY##_add(struct ARRAY *a, T *val, unsigned *index_ret) \
{ \
return array_add(&a->arr, (void *)val, index_ret); \
} \
\
INLINE void \
ARRAY##_remove(struct ARRAY *a, unsigned index) \
{ \
array_remove(&a->arr, index); \
}
#define DEFARRAY_BYTYPE(ARRAY, T, INLINE) \
INLINE struct ARRAY *ARRAY##_create(void) { \
struct ARRAY *a = kmalloc(sizeof(*a)); \
if (a == NULL) { \
return NULL; \
} \
array_init(&a->arr); \
return a; \
} \
\
INLINE void ARRAY##_destroy(struct ARRAY *a) { \
array_cleanup(&a->arr); \
kfree(a); \
} \
\
INLINE void ARRAY##_init(struct ARRAY *a) { array_init(&a->arr); } \
\
INLINE void ARRAY##_cleanup(struct ARRAY *a) { array_cleanup(&a->arr); } \
\
INLINE unsigned ARRAY##_num(const struct ARRAY *a) { \
return array_num(&a->arr); \
} \
\
INLINE T *ARRAY##_get(const struct ARRAY *a, unsigned index) { \
return (T *)array_get(&a->arr, index); \
} \
\
INLINE void ARRAY##_set(struct ARRAY *a, unsigned index, T *val) { \
array_set(&a->arr, index, (void *)val); \
} \
\
INLINE int ARRAY##_preallocate(struct ARRAY *a, unsigned num) { \
return array_preallocate(&a->arr, num); \
} \
\
INLINE int ARRAY##_setsize(struct ARRAY *a, unsigned num) { \
return array_setsize(&a->arr, num); \
} \
\
INLINE int ARRAY##_add(struct ARRAY *a, T *val, unsigned *index_ret) { \
return array_add(&a->arr, (void *)val, index_ret); \
} \
\
INLINE void ARRAY##_remove(struct ARRAY *a, unsigned index) { \
array_remove(&a->arr, index); \
}
#define DECLARRAY(T, INLINE) DECLARRAY_BYTYPE(T##array, struct T, INLINE)
#define DEFARRAY(T, INLINE) DEFARRAY_BYTYPE(T##array, struct T, INLINE)
@@ -265,5 +229,4 @@ array_add(struct array *a, void *val, unsigned *index_ret)
DECLARRAY_BYTYPE(stringarray, char, ARRAYINLINE);
DEFARRAY_BYTYPE(stringarray, char, ARRAYINLINE);
#endif /* ARRAY_H */

View File

@@ -44,16 +44,14 @@
* bitmap_destroy - destroy bitmap.
*/
struct bitmap; /* Opaque. */
struct bitmap; /* Opaque. */
struct bitmap *bitmap_create(unsigned nbits);
void *bitmap_getdata(struct bitmap *);
int bitmap_alloc(struct bitmap *, unsigned *index);
void bitmap_mark(struct bitmap *, unsigned index);
void bitmap_unmark(struct bitmap *, unsigned index);
int bitmap_isset(struct bitmap *, unsigned index);
void bitmap_destroy(struct bitmap *);
void *bitmap_getdata(struct bitmap *);
int bitmap_alloc(struct bitmap *, unsigned *index);
void bitmap_mark(struct bitmap *, unsigned index);
void bitmap_unmark(struct bitmap *, unsigned index);
int bitmap_isset(struct bitmap *, unsigned index);
void bitmap_destroy(struct bitmap *);
#endif /* _BITMAP_H_ */

View File

@@ -34,36 +34,32 @@
* Some miscellaneous C language definitions and related matters.
*/
/*
* Build-time assertion. Doesn't generate any code. The error message
* on failure is less than ideal, but you can't have everything.
*/
#define COMPILE_ASSERT(x) ((void)sizeof(struct { unsigned : ((x)?1:-1); }))
#define COMPILE_ASSERT(x) ((void)sizeof(struct { unsigned : ((x) ? 1 : -1); }))
/*
* Handy macro for the number of elements in a static array.
*/
#define ARRAYCOUNT(arr) (sizeof(arr) / sizeof((arr)[0]))
/*
* Tell GCC how to check printf formats. Also tell it about functions
* that don't return, as this is helpful for avoiding bogus warnings
* about uninitialized variables.
*/
#ifdef __GNUC__
#define __PF(a,b) __attribute__((__format__(__printf__, a, b)))
#define __DEAD __attribute__((__noreturn__))
#define __UNUSED __attribute__((__unused__))
#define __PF(a, b) __attribute__((__format__(__printf__, a, b)))
#define __DEAD __attribute__((__noreturn__))
#define __UNUSED __attribute__((__unused__))
#else
#define __PF(a,b)
#define __PF(a, b)
#define __DEAD
#define __UNUSED
#endif
/*
* Material for supporting inline functions.
*
@@ -137,5 +133,4 @@
#define INLINE static __UNUSED inline
#endif
#endif /* _CDEFS_H_ */

View File

@@ -36,14 +36,13 @@
#include <kern/time.h>
/*
* hardclock() is called on every CPU HZ times a second, possibly only
* when the CPU is not idle, for scheduling.
*/
/* hardclocks per second */
#define HZ 100
#define HZ 100
void hardclock_bootstrap(void);
void hardclock(void);
@@ -66,12 +65,10 @@ void gettime(struct timespec *ret);
* sub: ret = t1 - t2
*/
void timespec_add(const struct timespec *t1,
const struct timespec *t2,
struct timespec *ret);
void timespec_sub(const struct timespec *t1,
const struct timespec *t2,
struct timespec *ret);
void timespec_add(const struct timespec *t1, const struct timespec *t2,
struct timespec *ret);
void timespec_sub(const struct timespec *t1, const struct timespec *t2,
struct timespec *ret);
/*
* clocksleep() suspends execution for the requested number of seconds,
@@ -79,5 +76,4 @@ void timespec_sub(const struct timespec *t1,
*/
void clocksleep(int seconds);
#endif /* _CLOCK_H_ */

View File

@@ -30,7 +30,6 @@
#ifndef _COPYINOUT_H_
#define _COPYINOUT_H_
/*
* copyin/copyout/copyinstr/copyoutstr are standard BSD kernel functions.
*
@@ -69,5 +68,4 @@ int copyout(const void *src, userptr_t userdest, size_t len);
int copyinstr(const_userptr_t usersrc, char *dest, size_t len, size_t *got);
int copyoutstr(const char *src, userptr_t userdest, size_t len, size_t *got);
#endif /* _COPYINOUT_H_ */

View File

@@ -30,11 +30,9 @@
#ifndef _CPU_H_
#define _CPU_H_
#include <spinlock.h>
#include <threadlist.h>
#include <machine/vm.h> /* for TLBSHOOTDOWN_MAX */
#include <machine/vm.h> /* for TLBSHOOTDOWN_MAX */
/*
* Per-cpu structure
@@ -47,51 +45,51 @@
*/
struct cpu {
/*
* Fixed after allocation.
*/
struct cpu *c_self; /* Canonical address of this struct */
unsigned c_number; /* This cpu's cpu number */
unsigned c_hardware_number; /* Hardware-defined cpu number */
/*
* Fixed after allocation.
*/
struct cpu *c_self; /* Canonical address of this struct */
unsigned c_number; /* This cpu's cpu number */
unsigned c_hardware_number; /* Hardware-defined cpu number */
/*
* Accessed only by this cpu.
*/
struct thread *c_curthread; /* Current thread on cpu */
struct threadlist c_zombies; /* List of exited threads */
unsigned c_hardclocks; /* Counter of hardclock() calls */
unsigned c_spinlocks; /* Counter of spinlocks held */
/*
* Accessed only by this cpu.
*/
struct thread *c_curthread; /* Current thread on cpu */
struct threadlist c_zombies; /* List of exited threads */
unsigned c_hardclocks; /* Counter of hardclock() calls */
unsigned c_spinlocks; /* Counter of spinlocks held */
/*
* Accessed by other cpus.
* Protected by the runqueue lock.
*/
bool c_isidle; /* True if this cpu is idle */
struct threadlist c_runqueue; /* Run queue for this cpu */
struct spinlock c_runqueue_lock;
/*
* Accessed by other cpus.
* Protected by the runqueue lock.
*/
bool c_isidle; /* True if this cpu is idle */
struct threadlist c_runqueue; /* Run queue for this cpu */
struct spinlock c_runqueue_lock;
/*
* Accessed by other cpus.
* Protected by the IPI lock.
*
* TLB shootdown requests made to this CPU are queued in
* c_shootdown[], with c_numshootdown holding the number of
* requests. TLBSHOOTDOWN_MAX is the maximum number that can
* be queued at once, which is machine-dependent.
*
* The contents of struct tlbshootdown are also machine-
* dependent and might reasonably be either an address space
* and vaddr pair, or a paddr, or something else.
*/
uint32_t c_ipi_pending; /* One bit for each IPI number */
struct tlbshootdown c_shootdown[TLBSHOOTDOWN_MAX];
unsigned c_numshootdown;
struct spinlock c_ipi_lock;
/*
* Accessed by other cpus.
* Protected by the IPI lock.
*
* TLB shootdown requests made to this CPU are queued in
* c_shootdown[], with c_numshootdown holding the number of
* requests. TLBSHOOTDOWN_MAX is the maximum number that can
* be queued at once, which is machine-dependent.
*
* The contents of struct tlbshootdown are also machine-
* dependent and might reasonably be either an address space
* and vaddr pair, or a paddr, or something else.
*/
uint32_t c_ipi_pending; /* One bit for each IPI number */
struct tlbshootdown c_shootdown[TLBSHOOTDOWN_MAX];
unsigned c_numshootdown;
struct spinlock c_ipi_lock;
/*
* Accessed by other cpus. Protected inside hangman.c.
*/
HANGMAN_ACTOR(c_hangman);
/*
* Accessed by other cpus. Protected inside hangman.c.
*/
HANGMAN_ACTOR(c_hangman);
};
/*
@@ -161,10 +159,10 @@ void cpu_halt(void);
*/
/* IPI types */
#define IPI_PANIC 0 /* System has called panic() */
#define IPI_OFFLINE 1 /* CPU is requested to go offline */
#define IPI_UNIDLE 2 /* Runnable threads are available */
#define IPI_TLBSHOOTDOWN 3 /* MMU mapping(s) need invalidation */
#define IPI_PANIC 0 /* System has called panic() */
#define IPI_OFFLINE 1 /* CPU is requested to go offline */
#define IPI_UNIDLE 2 /* Runnable threads are available */
#define IPI_TLBSHOOTDOWN 3 /* MMU mapping(s) need invalidation */
void ipi_send(struct cpu *target, int code);
void ipi_broadcast(int code);
@@ -172,5 +170,4 @@ void ipi_tlbshootdown(struct cpu *target, const struct tlbshootdown *mapping);
void interprocessor_interrupt(void);
#endif /* _CPU_H_ */

View File

@@ -89,5 +89,4 @@
#define curproc (curthread->t_proc)
#endif /* _CURRENT_H_ */

View File

@@ -34,21 +34,20 @@
* Devices.
*/
struct uio; /* in <uio.h> */
struct uio; /* in <uio.h> */
/*
* Filesystem-namespace-accessible device.
*/
struct device {
const struct device_ops *d_ops;
const struct device_ops *d_ops;
blkcnt_t d_blocks;
blksize_t d_blocksize;
blkcnt_t d_blocks;
blksize_t d_blocksize;
dev_t d_devnumber; /* serial number for this device */
dev_t d_devnumber; /* serial number for this device */
void *d_data; /* device-specific data */
void *d_data; /* device-specific data */
};
/*
@@ -58,18 +57,17 @@ struct device {
* devop_ioctl - miscellaneous control operations
*/
struct device_ops {
int (*devop_eachopen)(struct device *, int flags_from_open);
int (*devop_io)(struct device *, struct uio *);
int (*devop_ioctl)(struct device *, int op, userptr_t data);
int (*devop_eachopen)(struct device *, int flags_from_open);
int (*devop_io)(struct device *, struct uio *);
int (*devop_ioctl)(struct device *, int op, userptr_t data);
};
/*
* Macros to shorten the calling sequences.
*/
#define DEVOP_EACHOPEN(d, f) ((d)->d_ops->devop_eachopen(d, f))
#define DEVOP_IO(d, u) ((d)->d_ops->devop_io(d, u))
#define DEVOP_IOCTL(d, op, p) ((d)->d_ops->devop_ioctl(d, op, p))
#define DEVOP_EACHOPEN(d, f) ((d)->d_ops->devop_eachopen(d, f))
#define DEVOP_IO(d, u) ((d)->d_ops->devop_io(d, u))
#define DEVOP_IOCTL(d, op, p) ((d)->d_ops->devop_ioctl(d, op, p))
/* Create vnode for a vfs-level device. */
struct vnode *dev_create_vnode(struct device *dev);
@@ -83,5 +81,4 @@ void devnull_create(void);
/* Function that kicks off device probe and attach. */
void dev_bootstrap(void);
#endif /* _DEVICE_H_ */

View File

@@ -30,7 +30,6 @@
#ifndef _ELF_H_
#define _ELF_H_
/*
* Simplified ELF definitions for OS/161 and System/161.
*
@@ -43,121 +42,118 @@
/* Get MD bits */
#include <machine/elf.h>
/*
* ELF file header. This appears at the very beginning of an ELF file.
*/
#define ELF_NIDENT 16
#define ELF_NIDENT 16
typedef struct {
unsigned char e_ident[ELF_NIDENT]; /* magic number et al. */
uint16_t e_type; /* type of file this is */
uint16_t e_machine; /* processor type file is for */
uint32_t e_version; /* ELF version */
uint32_t e_entry; /* address of program entry point */
uint32_t e_phoff; /* location in file of phdrs */
uint32_t e_shoff; /* ignore */
uint32_t e_flags; /* ignore */
uint16_t e_ehsize; /* actual size of file header */
uint16_t e_phentsize; /* actual size of phdr */
uint16_t e_phnum; /* number of phdrs */
uint16_t e_shentsize; /* ignore */
uint16_t e_shnum; /* ignore */
uint16_t e_shstrndx; /* ignore */
unsigned char e_ident[ELF_NIDENT]; /* magic number et al. */
uint16_t e_type; /* type of file this is */
uint16_t e_machine; /* processor type file is for */
uint32_t e_version; /* ELF version */
uint32_t e_entry; /* address of program entry point */
uint32_t e_phoff; /* location in file of phdrs */
uint32_t e_shoff; /* ignore */
uint32_t e_flags; /* ignore */
uint16_t e_ehsize; /* actual size of file header */
uint16_t e_phentsize; /* actual size of phdr */
uint16_t e_phnum; /* number of phdrs */
uint16_t e_shentsize; /* ignore */
uint16_t e_shnum; /* ignore */
uint16_t e_shstrndx; /* ignore */
} Elf32_Ehdr;
/* Offsets for the 1-byte fields within e_ident[] */
#define EI_MAG0 0 /* '\177' */
#define EI_MAG1 1 /* 'E' */
#define EI_MAG2 2 /* 'L' */
#define EI_MAG3 3 /* 'F' */
#define EI_CLASS 4 /* File class - always ELFCLASS32 */
#define EI_DATA 5 /* Data encoding - ELFDATA2LSB or ELFDATA2MSB*/
#define EI_VERSION 6 /* ELF version - EV_CURRENT*/
#define EI_OSABI 7 /* OS/syscall ABI identification */
#define EI_ABIVERSION 8 /* syscall ABI version */
#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
#define EI_MAG0 0 /* '\177' */
#define EI_MAG1 1 /* 'E' */
#define EI_MAG2 2 /* 'L' */
#define EI_MAG3 3 /* 'F' */
#define EI_CLASS 4 /* File class - always ELFCLASS32 */
#define EI_DATA 5 /* Data encoding - ELFDATA2LSB or ELFDATA2MSB*/
#define EI_VERSION 6 /* ELF version - EV_CURRENT*/
#define EI_OSABI 7 /* OS/syscall ABI identification */
#define EI_ABIVERSION 8 /* syscall ABI version */
#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/
/* Values for these fields */
/* For e_ident[EI_MAG0..3] */
#define ELFMAG0 0x7f
#define ELFMAG1 'E'
#define ELFMAG2 'L'
#define ELFMAG3 'F'
#define ELFMAG0 0x7f
#define ELFMAG1 'E'
#define ELFMAG2 'L'
#define ELFMAG3 'F'
/* For e_ident[EI_CLASS] */
#define ELFCLASSNONE 0 /* Invalid class */
#define ELFCLASS32 1 /* 32-bit objects */
#define ELFCLASS64 2 /* 64-bit objects */
#define ELFCLASSNONE 0 /* Invalid class */
#define ELFCLASS32 1 /* 32-bit objects */
#define ELFCLASS64 2 /* 64-bit objects */
/* e_ident[EI_DATA] */
#define ELFDATANONE 0 /* Invalid data encoding */
#define ELFDATA2LSB 1 /* 2's complement values, LSB first */
#define ELFDATA2MSB 2 /* 2's complement values, MSB first */
#define ELFDATANONE 0 /* Invalid data encoding */
#define ELFDATA2LSB 1 /* 2's complement values, LSB first */
#define ELFDATA2MSB 2 /* 2's complement values, MSB first */
/* e_ident[EI_VERSION] */
#define EV_NONE 0 /* Invalid version */
#define EV_CURRENT 1 /* Current version */
#define EV_NONE 0 /* Invalid version */
#define EV_CURRENT 1 /* Current version */
/* e_ident[EI_OSABI] */
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
#define ELFOSABI_HPUX 1 /* HP-UX operating system */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
/*
* Values for e_type
*/
#define ET_NONE 0 /* No file type */
#define ET_REL 1 /* Relocatable file */
#define ET_EXEC 2 /* Executable file */
#define ET_DYN 3 /* Shared object file */
#define ET_CORE 4 /* Core file */
#define ET_NUM 5
#define ET_NONE 0 /* No file type */
#define ET_REL 1 /* Relocatable file */
#define ET_EXEC 2 /* Executable file */
#define ET_DYN 3 /* Shared object file */
#define ET_CORE 4 /* Core file */
#define ET_NUM 5
/*
* Values for e_machine
*/
#define EM_NONE 0 /* No machine */
#define EM_M32 1 /* AT&T WE 32100 */
#define EM_SPARC 2 /* SPARC */
#define EM_386 3 /* Intel 80386 */
#define EM_68K 4 /* Motorola 68000 */
#define EM_88K 5 /* Motorola 88000 */
#define EM_486 6 /* Intel 80486 */
#define EM_860 7 /* Intel 80860 */
#define EM_MIPS 8 /* MIPS I Architecture */
#define EM_S370 9 /* Amdahl UTS on System/370 */
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
#define EM_NCUBE 16 /* NCube XXX reserved */
#define EM_VPP500 17 /* Fujitsu VPP500 */
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
#define EM_960 19 /* Intel 80960 */
#define EM_PPC 20 /* PowerPC */
#define EM_V800 36 /* NEC V800 */
#define EM_FR20 37 /* Fujitsu FR20 */
#define EM_RH32 38 /* TRW RH-32 */
#define EM_RCE 39 /* Motorola RCE */
#define EM_ARM 40 /* Advanced RISC Machines ARM */
#define EM_ALPHA 41 /* DIGITAL Alpha */
#define EM_SH 42 /* Hitachi Super-H */
#define EM_SPARCV9 43 /* SPARC Version 9 */
#define EM_TRICORE 44 /* Siemens Tricore */
#define EM_ARC 45 /* Argonaut RISC Core */
#define EM_H8_300 46 /* Hitachi H8/300 */
#define EM_H8_300H 47 /* Hitachi H8/300H */
#define EM_H8S 48 /* Hitachi H8S */
#define EM_H8_500 49 /* Hitachi H8/500 */
#define EM_IA_64 50 /* Intel Merced Processor */
#define EM_MIPS_X 51 /* Stanford MIPS-X */
#define EM_COLDFIRE 52 /* Motorola Coldfire */
#define EM_68HC12 53 /* Motorola MC68HC12 */
#define EM_VAX 75 /* DIGITAL VAX */
#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
#define EM_NUM 36903
#define EM_NONE 0 /* No machine */
#define EM_M32 1 /* AT&T WE 32100 */
#define EM_SPARC 2 /* SPARC */
#define EM_386 3 /* Intel 80386 */
#define EM_68K 4 /* Motorola 68000 */
#define EM_88K 5 /* Motorola 88000 */
#define EM_486 6 /* Intel 80486 */
#define EM_860 7 /* Intel 80860 */
#define EM_MIPS 8 /* MIPS I Architecture */
#define EM_S370 9 /* Amdahl UTS on System/370 */
#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */
#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */
#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */
#define EM_NCUBE 16 /* NCube XXX reserved */
#define EM_VPP500 17 /* Fujitsu VPP500 */
#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
#define EM_960 19 /* Intel 80960 */
#define EM_PPC 20 /* PowerPC */
#define EM_V800 36 /* NEC V800 */
#define EM_FR20 37 /* Fujitsu FR20 */
#define EM_RH32 38 /* TRW RH-32 */
#define EM_RCE 39 /* Motorola RCE */
#define EM_ARM 40 /* Advanced RISC Machines ARM */
#define EM_ALPHA 41 /* DIGITAL Alpha */
#define EM_SH 42 /* Hitachi Super-H */
#define EM_SPARCV9 43 /* SPARC Version 9 */
#define EM_TRICORE 44 /* Siemens Tricore */
#define EM_ARC 45 /* Argonaut RISC Core */
#define EM_H8_300 46 /* Hitachi H8/300 */
#define EM_H8_300H 47 /* Hitachi H8/300H */
#define EM_H8S 48 /* Hitachi H8S */
#define EM_H8_500 49 /* Hitachi H8/500 */
#define EM_IA_64 50 /* Intel Merced Processor */
#define EM_MIPS_X 51 /* Stanford MIPS-X */
#define EM_COLDFIRE 52 /* Motorola Coldfire */
#define EM_68HC12 53 /* Motorola MC68HC12 */
#define EM_VAX 75 /* DIGITAL VAX */
#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */
#define EM_NUM 36903
/*
* "Program Header" - runtime segment header.
@@ -166,35 +162,33 @@ typedef struct {
* Note: if p_memsz > p_filesz, the leftover space should be zero-filled.
*/
typedef struct {
uint32_t p_type; /* Type of segment */
uint32_t p_offset; /* Location of data within file */
uint32_t p_vaddr; /* Virtual address */
uint32_t p_paddr; /* Ignore */
uint32_t p_filesz; /* Size of data within file */
uint32_t p_memsz; /* Size of data to be loaded into memory*/
uint32_t p_flags; /* Flags */
uint32_t p_align; /* Required alignment - can ignore */
uint32_t p_type; /* Type of segment */
uint32_t p_offset; /* Location of data within file */
uint32_t p_vaddr; /* Virtual address */
uint32_t p_paddr; /* Ignore */
uint32_t p_filesz; /* Size of data within file */
uint32_t p_memsz; /* Size of data to be loaded into memory*/
uint32_t p_flags; /* Flags */
uint32_t p_align; /* Required alignment - can ignore */
} Elf32_Phdr;
/* values for p_type */
#define PT_NULL 0 /* Program header table entry unused */
#define PT_LOAD 1 /* Loadable program segment */
#define PT_DYNAMIC 2 /* Dynamic linking information */
#define PT_INTERP 3 /* Program interpreter */
#define PT_NOTE 4 /* Auxiliary information */
#define PT_SHLIB 5 /* Reserved, unspecified semantics */
#define PT_PHDR 6 /* Entry for header table itself */
#define PT_NUM 7
#define PT_MIPS_REGINFO 0x70000000
#define PT_NULL 0 /* Program header table entry unused */
#define PT_LOAD 1 /* Loadable program segment */
#define PT_DYNAMIC 2 /* Dynamic linking information */
#define PT_INTERP 3 /* Program interpreter */
#define PT_NOTE 4 /* Auxiliary information */
#define PT_SHLIB 5 /* Reserved, unspecified semantics */
#define PT_PHDR 6 /* Entry for header table itself */
#define PT_NUM 7
#define PT_MIPS_REGINFO 0x70000000
/* values for p_flags */
#define PF_R 0x4 /* Segment is readable */
#define PF_W 0x2 /* Segment is writable */
#define PF_X 0x1 /* Segment is executable */
#define PF_R 0x4 /* Segment is readable */
#define PF_W 0x2 /* Segment is writable */
#define PF_X 0x1 /* Segment is executable */
typedef Elf32_Ehdr Elf_Ehdr;
typedef Elf32_Phdr Elf_Phdr;
#endif /* _ELF_H_ */

View File

@@ -30,7 +30,6 @@
#ifndef _EMUFS_H_
#define _EMUFS_H_
/*
* Get abstract structure definitions
*/
@@ -42,17 +41,16 @@
*/
struct emufs_vnode {
struct vnode ev_v; /* abstract vnode structure */
struct emu_softc *ev_emu; /* device */
uint32_t ev_handle; /* file handle */
struct vnode ev_v; /* abstract vnode structure */
struct emu_softc *ev_emu; /* device */
uint32_t ev_handle; /* file handle */
};
struct emufs_fs {
struct fs ef_fs; /* abstract filesystem structure */
struct emu_softc *ef_emu; /* device */
struct emufs_vnode *ef_root; /* root vnode */
struct vnodearray *ef_vnodes; /* table of loaded vnodes */
struct fs ef_fs; /* abstract filesystem structure */
struct emu_softc *ef_emu; /* device */
struct emufs_vnode *ef_root; /* root vnode */
struct vnodearray *ef_vnodes; /* table of loaded vnodes */
};
#endif /* _EMUFS_H_ */

View File

@@ -51,5 +51,4 @@ uint64_t htonll(uint64_t);
void join32to64(uint32_t x1, uint32_t x2, uint64_t *y2);
void split64to32(uint64_t x, uint32_t *y1, uint32_t *y2);
#endif /* _ENDIAN_H_ */

View File

@@ -32,7 +32,6 @@
struct vnode; /* in vnode.h */
/*
* Abstract file system. (Or device accessible as a file.)
*
@@ -40,8 +39,8 @@ struct vnode; /* in vnode.h */
*/
struct fs {
void *fs_data;
const struct fs_ops *fs_ops;
void *fs_data;
const struct fs_ops *fs_ops;
};
/*
@@ -70,22 +69,21 @@ struct fs {
* filesystem should have been discarded/released.
*/
struct fs_ops {
int (*fsop_sync)(struct fs *);
const char *(*fsop_getvolname)(struct fs *);
int (*fsop_getroot)(struct fs *, struct vnode **);
int (*fsop_unmount)(struct fs *);
int (*fsop_sync)(struct fs *);
const char *(*fsop_getvolname)(struct fs *);
int (*fsop_getroot)(struct fs *, struct vnode **);
int (*fsop_unmount)(struct fs *);
};
/*
* Macros to shorten the calling sequences.
*/
#define FSOP_SYNC(fs) ((fs)->fs_ops->fsop_sync(fs))
#define FSOP_GETVOLNAME(fs) ((fs)->fs_ops->fsop_getvolname(fs))
#define FSOP_SYNC(fs) ((fs)->fs_ops->fsop_sync(fs))
#define FSOP_GETVOLNAME(fs) ((fs)->fs_ops->fsop_getvolname(fs))
#define FSOP_GETROOT(fs, ret) ((fs)->fs_ops->fsop_getroot(fs, ret))
#define FSOP_UNMOUNT(fs) ((fs)->fs_ops->fsop_unmount(fs))
#define FSOP_UNMOUNT(fs) ((fs)->fs_ops->fsop_unmount(fs))
/* Initialization functions for builtin fake file systems. */
void semfs_bootstrap(void);
#endif /* _FS_H_ */

View File

@@ -40,30 +40,30 @@
#if OPT_HANGMAN
struct hangman_actor {
const char *a_name;
const struct hangman_lockable *a_waiting;
const char *a_name;
const struct hangman_lockable *a_waiting;
};
struct hangman_lockable {
const char *l_name;
const struct hangman_actor *l_holding;
const char *l_name;
const struct hangman_actor *l_holding;
};
void hangman_wait(struct hangman_actor *a, struct hangman_lockable *l);
void hangman_acquire(struct hangman_actor *a, struct hangman_lockable *l);
void hangman_release(struct hangman_actor *a, struct hangman_lockable *l);
#define HANGMAN_ACTOR(sym) struct hangman_actor sym
#define HANGMAN_LOCKABLE(sym) struct hangman_lockable sym
#define HANGMAN_ACTOR(sym) struct hangman_actor sym
#define HANGMAN_LOCKABLE(sym) struct hangman_lockable sym
#define HANGMAN_ACTORINIT(a, n) ((a)->a_name = (n), (a)->a_waiting = NULL)
#define HANGMAN_LOCKABLEINIT(l, n) ((l)->l_name = (n), (l)->l_holding = NULL)
#define HANGMAN_ACTORINIT(a, n) ((a)->a_name = (n), (a)->a_waiting = NULL)
#define HANGMAN_LOCKABLEINIT(l, n) ((l)->l_name = (n), (l)->l_holding = NULL)
#define HANGMAN_LOCKABLE_INITIALIZER { "spinlock", NULL }
#define HANGMAN_LOCKABLE_INITIALIZER {"spinlock", NULL}
#define HANGMAN_WAIT(a, l) hangman_wait(a, l)
#define HANGMAN_ACQUIRE(a, l) hangman_acquire(a, l)
#define HANGMAN_RELEASE(a, l) hangman_release(a, l)
#define HANGMAN_WAIT(a, l) hangman_wait(a, l)
#define HANGMAN_ACQUIRE(a, l) hangman_acquire(a, l)
#define HANGMAN_RELEASE(a, l) hangman_release(a, l)
#else

View File

@@ -40,11 +40,10 @@
*/
#define _LITTLE_ENDIAN 1234
#define _BIG_ENDIAN 4321
#define _PDP_ENDIAN 3412
#define _BIG_ENDIAN 4321
#define _PDP_ENDIAN 3412
/* This defines _BYTE_ORDER to one of the above. */
#include <kern/machine/endian.h>
#endif /* _KERN_ENDIAN_H_ */

View File

@@ -39,76 +39,76 @@
* lib/misc.c; for userland it's lib/libc/strerror.c.
*/
const char *const sys_errlist[] = {
"Operation succeeded", /* 0 */
"Function not implemented", /* ENOSYS */
"(undefined error 2)", /* unused */
"Out of memory", /* ENOMEM */
"Operation would block", /* EAGAIN (also EWOULDBLOCK) */
"Interrupted system call", /* EINTR */
"Bad memory reference", /* EFAULT */
"String too long", /* ENAMETOOLONG */
"Invalid argument", /* EINVAL */
"Operation not permitted", /* EPERM */
"Permission denied", /* EACCES */
"Too many processes", /* EMPROC (EPROCLIM in Unix) */
"Too many processes in system",/* ENPROC */
"File is not executable", /* ENOEXEC */
"Argument list too long", /* E2BIG */
"No such process", /* ESRCH */
"No child processes", /* ECHILD */
"Not a directory", /* ENOTDIR */
"Is a directory", /* EISDIR */
"No such file or directory", /* ENOENT */
"Too many levels of symbolic links",/* ELOOP */
"Directory not empty", /* ENOTEMPTY */
"File or object exists", /* EEXIST */
"Too many hard links", /* EMLINK */
"Cross-device link", /* EXDEV */
"No such device", /* ENODEV */
"Device not available", /* ENXIO */
"Device or resource busy", /* EBUSY */
"Too many open files", /* EMFILE */
"Too many open files in system",/* ENFILE */
"Bad file number", /* EBADF */
"Invalid or inappropriate ioctl",/* EIOCTL (ENOTTY in Unix) */
"Input/output error", /* EIO */
"Illegal seek", /* ESPIPE */
"Broken pipe", /* EPIPE */
"Read-only file system", /* EROFS */
"No space left on device", /* ENOSPC */
"Disc quota exceeded", /* EDQUOT */
"File too large", /* EFBIG */
"Invalid file type or format",/* EFTYPE */
"Argument out of range", /* EDOM */
"Result out of range", /* ERANGE */
"Invalid multibyte character sequence",/* EILSEQ */
"Not a socket", /* ENOTSOCK */
"Is a socket", /* EISSOCK (EOPNOTSUPP in Unix) */
"Socket is already connected",/* EISCONN */
"Socket is not connected", /* ENOTCONN */
"Socket has been shut down", /* ESHUTDOWN */
"Protocol family not supported",/* EPFNOSUPPORT */
"Socket type not supported", /* ESOCKTNOSUPPORT */
"Protocol not supported", /* EPROTONOSUPPORT */
"Protocol wrong type for socket",/* EPROTOTYPE */
"Address family not supported by protocol family",/* EAFNOSUPPORT */
"Protocol option not available",/* ENOPROTOOPT */
"Address already in use", /* EADDRINUSE */
"Cannot assign requested address",/* EADDRNOTAVAIL */
"Network is down", /* ENETDOWN */
"Network is unreachable", /* ENETUNREACH */
"Host is down", /* EHOSTDOWN */
"Host is unreachable", /* EHOSTUNREACH */
"Connection refused", /* ECONNREFUSED */
"Connection timed out", /* ETIMEDOUT */
"Connection reset by peer", /* ECONNRESET */
"Message too large", /* EMSGSIZE */
"Threads operation not supported",/* ENOTSUP */
"Operation succeeded", /* 0 */
"Function not implemented", /* ENOSYS */
"(undefined error 2)", /* unused */
"Out of memory", /* ENOMEM */
"Operation would block", /* EAGAIN (also EWOULDBLOCK) */
"Interrupted system call", /* EINTR */
"Bad memory reference", /* EFAULT */
"String too long", /* ENAMETOOLONG */
"Invalid argument", /* EINVAL */
"Operation not permitted", /* EPERM */
"Permission denied", /* EACCES */
"Too many processes", /* EMPROC (EPROCLIM in Unix) */
"Too many processes in system", /* ENPROC */
"File is not executable", /* ENOEXEC */
"Argument list too long", /* E2BIG */
"No such process", /* ESRCH */
"No child processes", /* ECHILD */
"Not a directory", /* ENOTDIR */
"Is a directory", /* EISDIR */
"No such file or directory", /* ENOENT */
"Too many levels of symbolic links", /* ELOOP */
"Directory not empty", /* ENOTEMPTY */
"File or object exists", /* EEXIST */
"Too many hard links", /* EMLINK */
"Cross-device link", /* EXDEV */
"No such device", /* ENODEV */
"Device not available", /* ENXIO */
"Device or resource busy", /* EBUSY */
"Too many open files", /* EMFILE */
"Too many open files in system", /* ENFILE */
"Bad file number", /* EBADF */
"Invalid or inappropriate ioctl", /* EIOCTL (ENOTTY in Unix) */
"Input/output error", /* EIO */
"Illegal seek", /* ESPIPE */
"Broken pipe", /* EPIPE */
"Read-only file system", /* EROFS */
"No space left on device", /* ENOSPC */
"Disc quota exceeded", /* EDQUOT */
"File too large", /* EFBIG */
"Invalid file type or format", /* EFTYPE */
"Argument out of range", /* EDOM */
"Result out of range", /* ERANGE */
"Invalid multibyte character sequence", /* EILSEQ */
"Not a socket", /* ENOTSOCK */
"Is a socket", /* EISSOCK (EOPNOTSUPP in Unix) */
"Socket is already connected", /* EISCONN */
"Socket is not connected", /* ENOTCONN */
"Socket has been shut down", /* ESHUTDOWN */
"Protocol family not supported", /* EPFNOSUPPORT */
"Socket type not supported", /* ESOCKTNOSUPPORT */
"Protocol not supported", /* EPROTONOSUPPORT */
"Protocol wrong type for socket", /* EPROTOTYPE */
"Address family not supported by protocol family", /* EAFNOSUPPORT */
"Protocol option not available", /* ENOPROTOOPT */
"Address already in use", /* EADDRINUSE */
"Cannot assign requested address", /* EADDRNOTAVAIL */
"Network is down", /* ENETDOWN */
"Network is unreachable", /* ENETUNREACH */
"Host is down", /* EHOSTDOWN */
"Host is unreachable", /* EHOSTUNREACH */
"Connection refused", /* ECONNREFUSED */
"Connection timed out", /* ETIMEDOUT */
"Connection reset by peer", /* ECONNRESET */
"Message too large", /* EMSGSIZE */
"Threads operation not supported", /* ENOTSUP */
};
/*
* Number of entries in sys_errlist.
*/
const int sys_nerr = sizeof(sys_errlist)/sizeof(const char *);
const int sys_nerr = sizeof(sys_errlist) / sizeof(const char *);
#endif /* _KERN_ERRMSG_H_ */

View File

@@ -42,70 +42,69 @@
* contain only symbolic constants.
*/
#define ENOSYS 1 /* Function not implemented */
#define ENOSYS 1 /* Function not implemented */
/* unused 2 */
#define ENOMEM 3 /* Out of memory */
#define EAGAIN 4 /* Operation would block */
#define EINTR 5 /* Interrupted system call */
#define EFAULT 6 /* Bad memory reference */
#define ENAMETOOLONG 7 /* String too long */
#define EINVAL 8 /* Invalid argument */
#define EPERM 9 /* Operation not permitted */
#define EACCES 10 /* Permission denied */
#define EMPROC 11 /* Too many processes */
#define ENPROC 12 /* Too many processes in system */
#define ENOEXEC 13 /* File is not executable */
#define E2BIG 14 /* Argument list too long */
#define ESRCH 15 /* No such process */
#define ECHILD 16 /* No child processes */
#define ENOTDIR 17 /* Not a directory */
#define EISDIR 18 /* Is a directory */
#define ENOENT 19 /* No such file or directory */
#define ELOOP 20 /* Too many levels of symbolic links */
#define ENOTEMPTY 21 /* Directory not empty */
#define EEXIST 22 /* File or object exists */
#define EMLINK 23 /* Too many hard links */
#define EXDEV 24 /* Cross-device link */
#define ENODEV 25 /* No such device */
#define ENXIO 26 /* Device not available */
#define EBUSY 27 /* Device or resource busy */
#define EMFILE 28 /* Too many open files */
#define ENFILE 29 /* Too many open files in system */
#define EBADF 30 /* Bad file number */
#define EIOCTL 31 /* Invalid or inappropriate ioctl */
#define EIO 32 /* Input/output error */
#define ESPIPE 33 /* Illegal seek */
#define EPIPE 34 /* Broken pipe */
#define EROFS 35 /* Read-only file system */
#define ENOSPC 36 /* No space left on device */
#define EDQUOT 37 /* Disc quota exceeded */
#define EFBIG 38 /* File too large */
#define EFTYPE 39 /* Invalid file type or format */
#define EDOM 40 /* Argument out of range */
#define ERANGE 41 /* Result out of range */
#define EILSEQ 42 /* Invalid multibyte character sequence */
#define ENOTSOCK 43 /* Not a socket */
#define EISSOCK 44 /* Is a socket */
#define EISCONN 45 /* Socket is already connected */
#define ENOTCONN 46 /* Socket is not connected */
#define ESHUTDOWN 47 /* Socket has been shut down */
#define EPFNOSUPPORT 48 /* Protocol family not supported */
#define ESOCKTNOSUPPORT 49 /* Socket type not supported */
#define EPROTONOSUPPORT 50 /* Protocol not supported */
#define EPROTOTYPE 51 /* Protocol wrong type for socket */
#define EAFNOSUPPORT 52 /* Address family not supported by protocol family */
#define ENOPROTOOPT 53 /* Protocol option not available */
#define EADDRINUSE 54 /* Address already in use */
#define EADDRNOTAVAIL 55 /* Cannot assign requested address */
#define ENETDOWN 56 /* Network is down */
#define ENETUNREACH 57 /* Network is unreachable */
#define EHOSTDOWN 58 /* Host is down */
#define EHOSTUNREACH 59 /* Host is unreachable */
#define ECONNREFUSED 60 /* Connection refused */
#define ETIMEDOUT 61 /* Connection timed out */
#define ECONNRESET 62 /* Connection reset by peer */
#define EMSGSIZE 63 /* Message too large */
#define ENOTSUP 64 /* Threads operation not supported */
#define ENOMEM 3 /* Out of memory */
#define EAGAIN 4 /* Operation would block */
#define EINTR 5 /* Interrupted system call */
#define EFAULT 6 /* Bad memory reference */
#define ENAMETOOLONG 7 /* String too long */
#define EINVAL 8 /* Invalid argument */
#define EPERM 9 /* Operation not permitted */
#define EACCES 10 /* Permission denied */
#define EMPROC 11 /* Too many processes */
#define ENPROC 12 /* Too many processes in system */
#define ENOEXEC 13 /* File is not executable */
#define E2BIG 14 /* Argument list too long */
#define ESRCH 15 /* No such process */
#define ECHILD 16 /* No child processes */
#define ENOTDIR 17 /* Not a directory */
#define EISDIR 18 /* Is a directory */
#define ENOENT 19 /* No such file or directory */
#define ELOOP 20 /* Too many levels of symbolic links */
#define ENOTEMPTY 21 /* Directory not empty */
#define EEXIST 22 /* File or object exists */
#define EMLINK 23 /* Too many hard links */
#define EXDEV 24 /* Cross-device link */
#define ENODEV 25 /* No such device */
#define ENXIO 26 /* Device not available */
#define EBUSY 27 /* Device or resource busy */
#define EMFILE 28 /* Too many open files */
#define ENFILE 29 /* Too many open files in system */
#define EBADF 30 /* Bad file number */
#define EIOCTL 31 /* Invalid or inappropriate ioctl */
#define EIO 32 /* Input/output error */
#define ESPIPE 33 /* Illegal seek */
#define EPIPE 34 /* Broken pipe */
#define EROFS 35 /* Read-only file system */
#define ENOSPC 36 /* No space left on device */
#define EDQUOT 37 /* Disc quota exceeded */
#define EFBIG 38 /* File too large */
#define EFTYPE 39 /* Invalid file type or format */
#define EDOM 40 /* Argument out of range */
#define ERANGE 41 /* Result out of range */
#define EILSEQ 42 /* Invalid multibyte character sequence */
#define ENOTSOCK 43 /* Not a socket */
#define EISSOCK 44 /* Is a socket */
#define EISCONN 45 /* Socket is already connected */
#define ENOTCONN 46 /* Socket is not connected */
#define ESHUTDOWN 47 /* Socket has been shut down */
#define EPFNOSUPPORT 48 /* Protocol family not supported */
#define ESOCKTNOSUPPORT 49 /* Socket type not supported */
#define EPROTONOSUPPORT 50 /* Protocol not supported */
#define EPROTOTYPE 51 /* Protocol wrong type for socket */
#define EAFNOSUPPORT 52 /* Address family not supported by protocol family */
#define ENOPROTOOPT 53 /* Protocol option not available */
#define EADDRINUSE 54 /* Address already in use */
#define EADDRNOTAVAIL 55 /* Cannot assign requested address */
#define ENETDOWN 56 /* Network is down */
#define ENETUNREACH 57 /* Network is unreachable */
#define EHOSTDOWN 58 /* Host is down */
#define EHOSTUNREACH 59 /* Host is unreachable */
#define ECONNREFUSED 60 /* Connection refused */
#define ETIMEDOUT 61 /* Connection timed out */
#define ECONNRESET 62 /* Connection reset by peer */
#define EMSGSIZE 63 /* Message too large */
#define ENOTSUP 64 /* Threads operation not supported */
#endif /* _KERN_ERRNO_H_ */

View File

@@ -34,67 +34,65 @@
* Constants for libc's <fcntl.h>.
*/
/*
* Important
*/
/* Flags for open: choose one of these: */
#define O_RDONLY 0 /* Open for read */
#define O_WRONLY 1 /* Open for write */
#define O_RDWR 2 /* Open for read and write */
#define O_RDONLY 0 /* Open for read */
#define O_WRONLY 1 /* Open for write */
#define O_RDWR 2 /* Open for read and write */
/* then or in any of these: */
#define O_CREAT 4 /* Create file if it doesn't exist */
#define O_EXCL 8 /* With O_CREAT, fail if file already exists */
#define O_TRUNC 16 /* Truncate file upon open */
#define O_APPEND 32 /* All writes happen at EOF (optional feature) */
#define O_NOCTTY 64 /* Required by POSIX, != 0, but does nothing */
#define O_CREAT 4 /* Create file if it doesn't exist */
#define O_EXCL 8 /* With O_CREAT, fail if file already exists */
#define O_TRUNC 16 /* Truncate file upon open */
#define O_APPEND 32 /* All writes happen at EOF (optional feature) */
#define O_NOCTTY 64 /* Required by POSIX, != 0, but does nothing */
/* Additional related definition */
#define O_ACCMODE 3 /* mask for O_RDONLY/O_WRONLY/O_RDWR */
#define O_ACCMODE 3 /* mask for O_RDONLY/O_WRONLY/O_RDWR */
/*
* Not so important
*/
/* operation codes for flock() */
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
#define LOCK_UN 3 /* release the lock */
#define LOCK_NB 4 /* flag: don't block */
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
#define LOCK_UN 3 /* release the lock */
#define LOCK_NB 4 /* flag: don't block */
/*
* Mostly pretty useless
*/
/* fcntl() operations */
#define F_DUPFD 0 /* like dup() but not quite */
#define F_GETFD 1 /* get per-handle flags */
#define F_SETFD 2 /* set per-handle flags */
#define F_GETFL 3 /* get per-file flags (O_* open flags) */
#define F_SETFL 4 /* set per-file flags (O_* open flags) */
#define F_GETOWN 5 /* get process/pgroup for SIGURG and SIGIO */
#define F_SETOWN 6 /* set process/pgroup for SIGURG and SIGIO */
#define F_GETLK 7 /* inspect record locks */
#define F_SETLK 8 /* acquire record locks nonblocking */
#define F_SETLKW 9 /* acquire record locks and wait */
#define F_DUPFD 0 /* like dup() but not quite */
#define F_GETFD 1 /* get per-handle flags */
#define F_SETFD 2 /* set per-handle flags */
#define F_GETFL 3 /* get per-file flags (O_* open flags) */
#define F_SETFL 4 /* set per-file flags (O_* open flags) */
#define F_GETOWN 5 /* get process/pgroup for SIGURG and SIGIO */
#define F_SETOWN 6 /* set process/pgroup for SIGURG and SIGIO */
#define F_GETLK 7 /* inspect record locks */
#define F_SETLK 8 /* acquire record locks nonblocking */
#define F_SETLKW 9 /* acquire record locks and wait */
/* flag for F_GETFD and F_SETFD */
#define FD_CLOEXEC 1 /* close-on-exec */
#define FD_CLOEXEC 1 /* close-on-exec */
/* modes for fcntl (F_GETLK/SETLK) locking */
#define F_RDLCK 0 /* shared lock */
#define F_WRLCK 1 /* exclusive lock */
#define F_UNLCK 2 /* unlock */
#define F_RDLCK 0 /* shared lock */
#define F_WRLCK 1 /* exclusive lock */
#define F_UNLCK 2 /* unlock */
/* struct for fcntl (F_GETLK/SETLK) locking */
struct flock {
off_t l_start; /* place in file */
int l_whence; /* SEEK_SET, SEEK_CUR, or SEEK_END */
int l_type; /* F_RDLCK or F_WRLCK */
off_t l_len; /* length of locked region */
pid_t l_pid; /* process that holds the lock */
off_t l_start; /* place in file */
int l_whence; /* SEEK_SET, SEEK_CUR, or SEEK_END */
int l_type; /* F_RDLCK or F_WRLCK */
off_t l_len; /* length of locked region */
pid_t l_pid; /* process that holds the lock */
};
#endif /* _KERN_FCNTL_H_ */

View File

@@ -36,33 +36,33 @@
*/
struct iovec {
/*
* For maximum type safety, when in the kernel, distinguish
* user pointers from kernel pointers.
*
* (A pointer is a user pointer if it *came* from userspace,
* not necessarily if it *points* to userspace. If a system
* call passes 0xdeadbeef, it points to the kernel, but it's
* still a user pointer.)
*
* In userspace, there are only user pointers; also, the name
* iov_base is defined by POSIX.
*
* Note that to work properly (without extra unwanted fiddling
* around) this scheme requires that void* and userptr_t have
* the same machine representation. Machines where this isn't
* true are theoretically possible under the C standard, but
* do not exist in practice.
*/
/*
* For maximum type safety, when in the kernel, distinguish
* user pointers from kernel pointers.
*
* (A pointer is a user pointer if it *came* from userspace,
* not necessarily if it *points* to userspace. If a system
* call passes 0xdeadbeef, it points to the kernel, but it's
* still a user pointer.)
*
* In userspace, there are only user pointers; also, the name
* iov_base is defined by POSIX.
*
* Note that to work properly (without extra unwanted fiddling
* around) this scheme requires that void* and userptr_t have
* the same machine representation. Machines where this isn't
* true are theoretically possible under the C standard, but
* do not exist in practice.
*/
#ifdef _KERNEL
union {
userptr_t iov_ubase; /* user-supplied pointer */
void *iov_kbase; /* kernel-supplied pointer */
};
union {
userptr_t iov_ubase; /* user-supplied pointer */
void *iov_kbase; /* kernel-supplied pointer */
};
#else
void *iov_base; /* user-supplied pointer */
void *iov_base; /* user-supplied pointer */
#endif
size_t iov_len; /* Length of data */
size_t iov_len; /* Length of data */
};
#endif /* _KERN_IOVEC_H_ */

View File

@@ -47,7 +47,6 @@
* implementation.
*/
/*
* Important, both as part of the system call API and for system behavior.
*
@@ -57,14 +56,13 @@
*/
/* Longest filename (without directory) not including null terminator */
#define __NAME_MAX 255
#define __NAME_MAX 255
/* Longest full path name */
#define __PATH_MAX 1024
#define __PATH_MAX 1024
/* Max bytes for an exec function (should be at least 16K) */
#define __ARG_MAX (64 * 1024)
#define __ARG_MAX (64 * 1024)
/*
* Important for system behavior, but not a big part of the API.
@@ -74,17 +72,16 @@
*/
/* Min value for a process ID (that can be assigned to a user process) */
#define __PID_MIN 2
#define __PID_MIN 2
/* Max value for a process ID (change this to match your implementation) */
#define __PID_MAX 32767
#define __PID_MAX 32767
/* Max open files per process */
#define __OPEN_MAX 128
#define __OPEN_MAX 128
/* Max bytes for atomic pipe I/O -- see description in the pipe() man page */
#define __PIPE_BUF 512
#define __PIPE_BUF 512
/*
* Not so important parts of the API. (Especially in OS/161 where we
@@ -92,18 +89,16 @@
*/
/* Max number of supplemental group IDs in process credentials */
#define __NGROUPS_MAX 32
#define __NGROUPS_MAX 32
/* Max login name size (for setlogin/getlogin), incl. null */
#define __LOGIN_NAME_MAX 17
/*
* Not very important at all.
*/
/* Max number of iovec structures at once for readv/writev/preadv/pwritev */
#define __IOV_MAX 1024
#define __IOV_MAX 1024
#endif /* _KERN_LIMITS_H_ */

View File

@@ -35,11 +35,9 @@
* (Not all that important.)
*/
/* Codes for reboot */
#define RB_REBOOT 0 /* Reboot system */
#define RB_HALT 1 /* Halt system and do not reboot */
#define RB_POWEROFF 2 /* Halt system and power off */
#define RB_REBOOT 0 /* Reboot system */
#define RB_HALT 1 /* Halt system and do not reboot */
#define RB_POWEROFF 2 /* Halt system and power off */
#endif /* _KERN_REBOOT_H_ */

View File

@@ -36,57 +36,56 @@
* Not very important.
*/
/* priorities for setpriority() */
#define PRIO_MIN (-20)
#define PRIO_MAX 20
#define PRIO_MIN (-20)
#define PRIO_MAX 20
/* "which" codes for setpriority() */
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
/* flags for getrusage() */
#define RUSAGE_SELF 0
#define RUSAGE_CHILDREN (-1)
#define RUSAGE_SELF 0
#define RUSAGE_CHILDREN (-1)
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
__size_t ru_maxrss; /* maximum RSS during lifespan (kb) */
__counter_t ru_ixrss; /* text memory usage (kb-ticks) */
__counter_t ru_idrss; /* data memory usage (kb-ticks) */
__counter_t ru_isrss; /* stack memory usage (kb-ticks) */
__counter_t ru_minflt; /* minor VM faults (count) */
__counter_t ru_majflt; /* major VM faults (count) */
__counter_t ru_nswap; /* whole-process swaps (count) */
__counter_t ru_inblock; /* file blocks read (count) */
__counter_t ru_oublock; /* file blocks written (count) */
__counter_t ru_msgrcv; /* socket/pipe packets rcv'd (count) */
__counter_t ru_msgsnd; /* socket/pipe packets sent (count) */
__counter_t ru_nsignals; /* signals delivered (count) */
__counter_t ru_nvcsw; /* voluntary context switches (count)*/
__counter_t ru_nivcsw; /* involuntary ditto (count) */
struct timeval ru_utime;
struct timeval ru_stime;
__size_t ru_maxrss; /* maximum RSS during lifespan (kb) */
__counter_t ru_ixrss; /* text memory usage (kb-ticks) */
__counter_t ru_idrss; /* data memory usage (kb-ticks) */
__counter_t ru_isrss; /* stack memory usage (kb-ticks) */
__counter_t ru_minflt; /* minor VM faults (count) */
__counter_t ru_majflt; /* major VM faults (count) */
__counter_t ru_nswap; /* whole-process swaps (count) */
__counter_t ru_inblock; /* file blocks read (count) */
__counter_t ru_oublock; /* file blocks written (count) */
__counter_t ru_msgrcv; /* socket/pipe packets rcv'd (count) */
__counter_t ru_msgsnd; /* socket/pipe packets sent (count) */
__counter_t ru_nsignals; /* signals delivered (count) */
__counter_t ru_nvcsw; /* voluntary context switches (count)*/
__counter_t ru_nivcsw; /* involuntary ditto (count) */
};
/* limit codes for getrusage/setrusage */
#define RLIMIT_NPROC 0 /* max procs per user (count) */
#define RLIMIT_NOFILE 1 /* max open files per proc (count) */
#define RLIMIT_CPU 2 /* cpu usage (seconds) */
#define RLIMIT_DATA 3 /* max .data/sbrk size (bytes) */
#define RLIMIT_STACK 4 /* max stack size (bytes) */
#define RLIMIT_MEMLOCK 5 /* max locked memory region (bytes) */
#define RLIMIT_RSS 6 /* max RSS (bytes) */
#define RLIMIT_CORE 7 /* core file size (bytes) */
#define RLIMIT_FSIZE 8 /* max file size (bytes) */
#define __RLIMIT_NUM 9 /* number of limits */
#define RLIMIT_NPROC 0 /* max procs per user (count) */
#define RLIMIT_NOFILE 1 /* max open files per proc (count) */
#define RLIMIT_CPU 2 /* cpu usage (seconds) */
#define RLIMIT_DATA 3 /* max .data/sbrk size (bytes) */
#define RLIMIT_STACK 4 /* max stack size (bytes) */
#define RLIMIT_MEMLOCK 5 /* max locked memory region (bytes) */
#define RLIMIT_RSS 6 /* max RSS (bytes) */
#define RLIMIT_CORE 7 /* core file size (bytes) */
#define RLIMIT_FSIZE 8 /* max file size (bytes) */
#define __RLIMIT_NUM 9 /* number of limits */
struct rlimit {
__rlim_t rlim_cur; /* soft limit */
__rlim_t rlim_max; /* hard limit */
__rlim_t rlim_cur; /* soft limit */
__rlim_t rlim_max; /* hard limit */
};
#define RLIM_INFINITY (~(__rlim_t)0)
#define RLIM_INFINITY (~(__rlim_t)0)
#endif /* _KERN_RESOURCE_H_ */

View File

@@ -39,9 +39,8 @@
* really not recommended.
*/
#define SEEK_SET 0 /* Seek relative to beginning of file */
#define SEEK_CUR 1 /* Seek relative to current position in file */
#define SEEK_END 2 /* Seek relative to end of file */
#define SEEK_SET 0 /* Seek relative to beginning of file */
#define SEEK_CUR 1 /* Seek relative to current position in file */
#define SEEK_END 2 /* Seek relative to end of file */
#endif /* _KERN_SEEK_H_ */

View File

@@ -30,72 +30,70 @@
#ifndef _KERN_SFS_H_
#define _KERN_SFS_H_
/*
* SFS definitions visible to userspace. This covers the on-disk format
* and is used by tools that work on SFS volumes, such as mksfs.
*/
#define SFS_MAGIC 0xabadf001 /* magic number identifying us */
#define SFS_BLOCKSIZE 512 /* size of our blocks */
#define SFS_VOLNAME_SIZE 32 /* max length of volume name */
#define SFS_NDIRECT 15 /* # of direct blocks in inode */
#define SFS_NINDIRECT 1 /* # of indirect blocks in inode */
#define SFS_NDINDIRECT 0 /* # of 2x indirect blocks in inode */
#define SFS_NTINDIRECT 0 /* # of 3x indirect blocks in inode */
#define SFS_DBPERIDB 128 /* # direct blks per indirect blk */
#define SFS_NAMELEN 60 /* max length of filename */
#define SFS_SUPER_BLOCK 0 /* block the superblock lives in */
#define SFS_FREEMAP_START 2 /* 1st block of the freemap */
#define SFS_NOINO 0 /* inode # for free dir entry */
#define SFS_ROOTDIR_INO 1 /* loc'n of the root dir inode */
#define SFS_MAGIC 0xabadf001 /* magic number identifying us */
#define SFS_BLOCKSIZE 512 /* size of our blocks */
#define SFS_VOLNAME_SIZE 32 /* max length of volume name */
#define SFS_NDIRECT 15 /* # of direct blocks in inode */
#define SFS_NINDIRECT 1 /* # of indirect blocks in inode */
#define SFS_NDINDIRECT 0 /* # of 2x indirect blocks in inode */
#define SFS_NTINDIRECT 0 /* # of 3x indirect blocks in inode */
#define SFS_DBPERIDB 128 /* # direct blks per indirect blk */
#define SFS_NAMELEN 60 /* max length of filename */
#define SFS_SUPER_BLOCK 0 /* block the superblock lives in */
#define SFS_FREEMAP_START 2 /* 1st block of the freemap */
#define SFS_NOINO 0 /* inode # for free dir entry */
#define SFS_ROOTDIR_INO 1 /* loc'n of the root dir inode */
/* Number of bits in a block */
#define SFS_BITSPERBLOCK (SFS_BLOCKSIZE * CHAR_BIT)
/* Utility macro */
#define SFS_ROUNDUP(a,b) ((((a)+(b)-1)/(b))*b)
#define SFS_ROUNDUP(a, b) ((((a) + (b) - 1) / (b)) * b)
/* Size of free block bitmap (in bits) */
#define SFS_FREEMAPBITS(nblocks) SFS_ROUNDUP(nblocks, SFS_BITSPERBLOCK)
/* Size of free block bitmap (in blocks) */
#define SFS_FREEMAPBLOCKS(nblocks) (SFS_FREEMAPBITS(nblocks)/SFS_BITSPERBLOCK)
#define SFS_FREEMAPBLOCKS(nblocks) (SFS_FREEMAPBITS(nblocks) / SFS_BITSPERBLOCK)
/* File types for sfi_type */
#define SFS_TYPE_INVAL 0 /* Should not appear on disk */
#define SFS_TYPE_FILE 1
#define SFS_TYPE_DIR 2
#define SFS_TYPE_INVAL 0 /* Should not appear on disk */
#define SFS_TYPE_FILE 1
#define SFS_TYPE_DIR 2
/*
* On-disk superblock
*/
struct sfs_superblock {
uint32_t sb_magic; /* Magic number; should be SFS_MAGIC */
uint32_t sb_nblocks; /* Number of blocks in fs */
char sb_volname[SFS_VOLNAME_SIZE]; /* Name of this volume */
uint32_t reserved[118]; /* unused, set to 0 */
uint32_t sb_magic; /* Magic number; should be SFS_MAGIC */
uint32_t sb_nblocks; /* Number of blocks in fs */
char sb_volname[SFS_VOLNAME_SIZE]; /* Name of this volume */
uint32_t reserved[118]; /* unused, set to 0 */
};
/*
* On-disk inode
*/
struct sfs_dinode {
uint32_t sfi_size; /* Size of this file (bytes) */
uint16_t sfi_type; /* One of SFS_TYPE_* above */
uint16_t sfi_linkcount; /* # hard links to this file */
uint32_t sfi_direct[SFS_NDIRECT]; /* Direct blocks */
uint32_t sfi_indirect; /* Indirect block */
uint32_t sfi_waste[128-3-SFS_NDIRECT]; /* unused space, set to 0 */
uint32_t sfi_size; /* Size of this file (bytes) */
uint16_t sfi_type; /* One of SFS_TYPE_* above */
uint16_t sfi_linkcount; /* # hard links to this file */
uint32_t sfi_direct[SFS_NDIRECT]; /* Direct blocks */
uint32_t sfi_indirect; /* Indirect block */
uint32_t sfi_waste[128 - 3 - SFS_NDIRECT]; /* unused space, set to 0 */
};
/*
* On-disk directory entry
*/
struct sfs_direntry {
uint32_t sfd_ino; /* Inode number */
char sfd_name[SFS_NAMELEN]; /* Filename */
uint32_t sfd_ino; /* Inode number */
char sfd_name[SFS_NAMELEN]; /* Filename */
};
#endif /* _KERN_SFS_H_ */

View File

@@ -41,7 +41,6 @@
* Machine-independent definitions for signals.
*/
/*
* The signals.
*
@@ -53,68 +52,67 @@
* ways. It is gross.
*/
#define SIGHUP 1 /* Hangup */
#define SIGINT 2 /* Interrupt (^C) */
#define SIGQUIT 3 /* Quit (typically ^\) */
#define SIGILL 4 /* Illegal instruction */
#define SIGTRAP 5 /* Breakpoint trap */
#define SIGABRT 6 /* abort() call */
#define SIGEMT 7 /* Emulator trap */
#define SIGFPE 8 /* Floating point exception */
#define SIGKILL 9 /* Hard kill (unblockable) */
#define SIGBUS 10 /* Bus error, typically bad pointer alignment*/
#define SIGSEGV 11 /* Segmentation fault */
#define SIGSYS 12 /* Bad system call */
#define SIGPIPE 13 /* Broken pipe */
#define SIGALRM 14 /* alarm() expired */
#define SIGTERM 15 /* Termination requested (default kill) */
#define SIGURG 16 /* Urgent data on socket */
#define SIGSTOP 17 /* Hard process stop (unblockable) */
#define SIGTSTP 18 /* Terminal stop (^Z) */
#define SIGCONT 19 /* Time to continue after stop */
#define SIGCHLD 20 /* Child process exited */
#define SIGTTIN 21 /* Stop on tty read while in background */
#define SIGTTOU 22 /* Stop on tty write while in background */
#define SIGIO 23 /* Nonblocking or async I/O is now ready */
#define SIGXCPU 24 /* CPU time resource limit exceeded */
#define SIGXFSZ 25 /* File size resource limit exceeded */
#define SIGVTALRM 26 /* Like SIGALRM but in virtual time */
#define SIGPROF 27 /* Profiling timer */
#define SIGWINCH 28 /* Window size change on tty */
#define SIGINFO 29 /* Information request (typically ^T) */
#define SIGUSR1 20 /* Application-defined */
#define SIGUSR2 31 /* Application-defined */
#define SIGPWR 32 /* Power failure */
#define _NSIG 32
#define SIGHUP 1 /* Hangup */
#define SIGINT 2 /* Interrupt (^C) */
#define SIGQUIT 3 /* Quit (typically ^\) */
#define SIGILL 4 /* Illegal instruction */
#define SIGTRAP 5 /* Breakpoint trap */
#define SIGABRT 6 /* abort() call */
#define SIGEMT 7 /* Emulator trap */
#define SIGFPE 8 /* Floating point exception */
#define SIGKILL 9 /* Hard kill (unblockable) */
#define SIGBUS 10 /* Bus error, typically bad pointer alignment*/
#define SIGSEGV 11 /* Segmentation fault */
#define SIGSYS 12 /* Bad system call */
#define SIGPIPE 13 /* Broken pipe */
#define SIGALRM 14 /* alarm() expired */
#define SIGTERM 15 /* Termination requested (default kill) */
#define SIGURG 16 /* Urgent data on socket */
#define SIGSTOP 17 /* Hard process stop (unblockable) */
#define SIGTSTP 18 /* Terminal stop (^Z) */
#define SIGCONT 19 /* Time to continue after stop */
#define SIGCHLD 20 /* Child process exited */
#define SIGTTIN 21 /* Stop on tty read while in background */
#define SIGTTOU 22 /* Stop on tty write while in background */
#define SIGIO 23 /* Nonblocking or async I/O is now ready */
#define SIGXCPU 24 /* CPU time resource limit exceeded */
#define SIGXFSZ 25 /* File size resource limit exceeded */
#define SIGVTALRM 26 /* Like SIGALRM but in virtual time */
#define SIGPROF 27 /* Profiling timer */
#define SIGWINCH 28 /* Window size change on tty */
#define SIGINFO 29 /* Information request (typically ^T) */
#define SIGUSR1 20 /* Application-defined */
#define SIGUSR2 31 /* Application-defined */
#define SIGPWR 32 /* Power failure */
#define _NSIG 32
/* Type for a set of signals; used by e.g. sigprocmask(). */
typedef __u32 sigset_t;
/* flags for sigaction.sa_flags */
#define SA_ONSTACK 1 /* Use sigaltstack() stack. */
#define SA_RESTART 2 /* Restart syscall instead of interrupting. */
#define SA_RESETHAND 4 /* Clear handler after one usage. */
#define SA_ONSTACK 1 /* Use sigaltstack() stack. */
#define SA_RESTART 2 /* Restart syscall instead of interrupting. */
#define SA_RESETHAND 4 /* Clear handler after one usage. */
/* codes for sigprocmask() */
#define SIG_BLOCK 1 /* Block selected signals. */
#define SIG_UNBLOCK 2 /* Unblock selected signals. */
#define SIG_SETMASK 3 /* Set mask to the selected signals. */
#define SIG_BLOCK 1 /* Block selected signals. */
#define SIG_UNBLOCK 2 /* Unblock selected signals. */
#define SIG_SETMASK 3 /* Set mask to the selected signals. */
/* Type for a signal handler function. */
typedef void (*__sigfunc)(int);
/* Magic values for signal handlers. */
#define SIG_DFL ((__sigfunc) 0) /* Default behavior. */
#define SIG_IGN ((__sigfunc) 1) /* Ignore the signal. */
#define SIG_DFL ((__sigfunc)0) /* Default behavior. */
#define SIG_IGN ((__sigfunc)1) /* Ignore the signal. */
/*
* Struct for sigaction().
*/
struct sigaction {
__sigfunc sa_handler;
sigset_t sa_mask;
unsigned sa_flags;
__sigfunc sa_handler;
sigset_t sa_mask;
unsigned sa_flags;
};
/*
@@ -122,10 +120,9 @@ struct sigaction {
* (not very important)
*/
struct sigaltstack {
void *ss_sp;
size_t ss_size;
unsigned ss_flags;
void *ss_sp;
size_t ss_size;
unsigned ss_flags;
};
#endif /* _KERN_SIGNAL_H_ */

View File

@@ -34,27 +34,26 @@
* Socket-related definitions, for <sys/socket.h>.
*/
/*
* Important
*/
/* Socket types that we (might) support. */
#define SOCK_STREAM 1 /* stream */
#define SOCK_DGRAM 2 /* packet */
#define SOCK_RAW 3 /* raw packet */
#define SOCK_STREAM 1 /* stream */
#define SOCK_DGRAM 2 /* packet */
#define SOCK_RAW 3 /* raw packet */
/* Address families that we (might) support. */
#define AF_UNSPEC 0
#define AF_UNIX 1
#define AF_INET 2
#define AF_INET6 3
#define AF_UNSPEC 0
#define AF_UNIX 1
#define AF_INET 2
#define AF_INET6 3
/* Protocol families. Pointless layer of indirection in the standard API. */
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_INET AF_INET
#define PF_INET6 AF_INET6
/*
* Socket address structures. Socket addresses are polymorphic, and
@@ -71,22 +70,21 @@
*/
struct sockaddr {
__u8 sa_len;
__u8 sa_family;
__u8 sa_len;
__u8 sa_family;
};
#define _SS_SIZE 128
#define _SS_SIZE 128
struct sockaddr_storage {
__u8 ss_len;
__u8 ss_family;
__u8 __ss_pad1;
__u8 __ss_pad2;
__u32 __ss_pad3;
__u64 __ss_pad4;
char __ss_pad5[_SS_SIZE - sizeof(__u64) - sizeof(__u32) - 4*sizeof(__u8)];
__u8 ss_len;
__u8 ss_family;
__u8 __ss_pad1;
__u8 __ss_pad2;
__u32 __ss_pad3;
__u64 __ss_pad4;
char __ss_pad5[_SS_SIZE - sizeof(__u64) - sizeof(__u32) - 4 * sizeof(__u8)];
};
/*
* Not very important.
*/
@@ -96,21 +94,20 @@ struct sockaddr_storage {
*/
struct msghdr {
void *msg_name; /* really sockaddr; address, or null */
socklen_t msg_namelen; /* size of msg_name object, or 0 */
struct iovec *msg_iov; /* I/O buffers */
int msg_iovlen; /* number of iovecs */
void *msg_control; /* auxiliary data area, or null */
socklen_t msg_controllen; /* size of msg_control area */
int msg_flags; /* flags */
void *msg_name; /* really sockaddr; address, or null */
socklen_t msg_namelen; /* size of msg_name object, or 0 */
struct iovec *msg_iov; /* I/O buffers */
int msg_iovlen; /* number of iovecs */
void *msg_control; /* auxiliary data area, or null */
socklen_t msg_controllen; /* size of msg_control area */
int msg_flags; /* flags */
};
struct cmsghdr {
socklen_t cmsg_len; /* length of control data, including header */
int cmsg_level; /* protocol layer item originates from */
int cmsg_type; /* protocol-specific message type */
/* char cmsg_data[];*/ /* data follows the header */
socklen_t cmsg_len; /* length of control data, including header */
int cmsg_level; /* protocol layer item originates from */
int cmsg_type; /* protocol-specific message type */
/* char cmsg_data[];*/ /* data follows the header */
};
#endif /* _KERN_SOCKET_H_ */

View File

@@ -40,32 +40,32 @@
* The file types are in kern/stattypes.h.
*/
struct stat {
/* Essential fields */
off_t st_size; /* file size in bytes */
mode_t st_mode; /* file type and protection mode */
nlink_t st_nlink; /* number of hard links */
blkcnt_t st_blocks; /* number of blocks file is using */
/* Essential fields */
off_t st_size; /* file size in bytes */
mode_t st_mode; /* file type and protection mode */
nlink_t st_nlink; /* number of hard links */
blkcnt_t st_blocks; /* number of blocks file is using */
/* Identity */
dev_t st_dev; /* device object lives on */
ino_t st_ino; /* inode number (serial number) of object */
dev_t st_rdev; /* device object is (if a device) */
/* Identity */
dev_t st_dev; /* device object lives on */
ino_t st_ino; /* inode number (serial number) of object */
dev_t st_rdev; /* device object is (if a device) */
/* Timestamps */
time_t st_atime; /* last access time: seconds */
time_t st_ctime; /* inode change time: seconds */
time_t st_mtime; /* modification time: seconds */
__u32 st_atimensec; /* last access time: nanoseconds */
__u32 st_ctimensec; /* inode change time: nanoseconds */
__u32 st_mtimensec; /* modification time: nanoseconds */
/* Timestamps */
time_t st_atime; /* last access time: seconds */
time_t st_ctime; /* inode change time: seconds */
time_t st_mtime; /* modification time: seconds */
__u32 st_atimensec; /* last access time: nanoseconds */
__u32 st_ctimensec; /* inode change time: nanoseconds */
__u32 st_mtimensec; /* modification time: nanoseconds */
/* Permissions (also st_mode) */
uid_t st_uid; /* owner */
gid_t st_gid; /* group */
/* Permissions (also st_mode) */
uid_t st_uid; /* owner */
gid_t st_gid; /* group */
/* Other */
__u32 st_gen; /* file generation number (root only) */
blksize_t st_blksize; /* recommended I/O block size */
/* Other */
__u32 st_gen; /* file generation number (root only) */
blksize_t st_blksize; /* recommended I/O block size */
};
#endif /* _KERN_STAT_H_ */

View File

@@ -42,14 +42,13 @@
* (kernel) or <sys/stat.h> (userland).
*/
#define _S_IFMT 070000 /* mask for type of file */
#define _S_IFREG 010000 /* ordinary regular file */
#define _S_IFDIR 020000 /* directory */
#define _S_IFLNK 030000 /* symbolic link */
#define _S_IFIFO 040000 /* pipe or named pipe */
#define _S_IFSOCK 050000 /* socket */
#define _S_IFCHR 060000 /* character device */
#define _S_IFBLK 070000 /* block device */
#define _S_IFMT 070000 /* mask for type of file */
#define _S_IFREG 010000 /* ordinary regular file */
#define _S_IFDIR 020000 /* directory */
#define _S_IFLNK 030000 /* symbolic link */
#define _S_IFIFO 040000 /* pipe or named pipe */
#define _S_IFSOCK 050000 /* socket */
#define _S_IFCHR 060000 /* character device */
#define _S_IFBLK 070000 /* block device */
#endif /* _KERN_STATTYPES_H_ */

View File

@@ -47,157 +47,155 @@
/*CALLBEGIN*/
// -- Process-related --
#define SYS_fork 0
#define SYS_vfork 1
#define SYS_execv 2
#define SYS__exit 3
#define SYS_waitpid 4
#define SYS_getpid 5
#define SYS_getppid 6
#define SYS_fork 0
#define SYS_vfork 1
#define SYS_execv 2
#define SYS__exit 3
#define SYS_waitpid 4
#define SYS_getpid 5
#define SYS_getppid 6
// (virtual memory)
#define SYS_sbrk 7
#define SYS_mmap 8
#define SYS_munmap 9
#define SYS_mprotect 10
//#define SYS_madvise 11
//#define SYS_mincore 12
//#define SYS_mlock 13
//#define SYS_munlock 14
//#define SYS_munlockall 15
//#define SYS_minherit 16
// (security/credentials)
#define SYS_umask 17
#define SYS_issetugid 18
#define SYS_getresuid 19
#define SYS_setresuid 20
#define SYS_getresgid 21
#define SYS_setresgid 22
#define SYS_getgroups 23
#define SYS_setgroups 24
#define SYS___getlogin 25
#define SYS___setlogin 26
#define SYS_sbrk 7
#define SYS_mmap 8
#define SYS_munmap 9
#define SYS_mprotect 10
// #define SYS_madvise 11
// #define SYS_mincore 12
// #define SYS_mlock 13
// #define SYS_munlock 14
// #define SYS_munlockall 15
// #define SYS_minherit 16
// (security/credentials)
#define SYS_umask 17
#define SYS_issetugid 18
#define SYS_getresuid 19
#define SYS_setresuid 20
#define SYS_getresgid 21
#define SYS_setresgid 22
#define SYS_getgroups 23
#define SYS_setgroups 24
#define SYS___getlogin 25
#define SYS___setlogin 26
// (signals)
#define SYS_kill 27
#define SYS_sigaction 28
#define SYS_sigpending 29
#define SYS_sigprocmask 30
#define SYS_sigsuspend 31
#define SYS_sigreturn 32
//#define SYS_sigaltstack 33
// (resource tracking and usage)
//#define SYS_wait4 34
//#define SYS_getrusage 35
// (resource limits)
//#define SYS_getrlimit 36
//#define SYS_setrlimit 37
// (process priority control)
//#define SYS_getpriority 38
//#define SYS_setpriority 39
// (process groups, sessions, and job control)
//#define SYS_getpgid 40
//#define SYS_setpgid 41
//#define SYS_getsid 42
//#define SYS_setsid 43
// (userlevel debugging)
//#define SYS_ptrace 44
#define SYS_kill 27
#define SYS_sigaction 28
#define SYS_sigpending 29
#define SYS_sigprocmask 30
#define SYS_sigsuspend 31
#define SYS_sigreturn 32
// #define SYS_sigaltstack 33
// (resource tracking and usage)
// #define SYS_wait4 34
// #define SYS_getrusage 35
// (resource limits)
// #define SYS_getrlimit 36
// #define SYS_setrlimit 37
// (process priority control)
// #define SYS_getpriority 38
// #define SYS_setpriority 39
// (process groups, sessions, and job control)
// #define SYS_getpgid 40
// #define SYS_setpgid 41
// #define SYS_getsid 42
// #define SYS_setsid 43
// (userlevel debugging)
// #define SYS_ptrace 44
// -- File-handle-related --
#define SYS_open 45
#define SYS_pipe 46
#define SYS_dup 47
#define SYS_dup2 48
#define SYS_close 49
#define SYS_read 50
#define SYS_pread 51
//#define SYS_readv 52
//#define SYS_preadv 53
#define SYS_getdirentry 54
#define SYS_write 55
#define SYS_pwrite 56
//#define SYS_writev 57
//#define SYS_pwritev 58
#define SYS_lseek 59
#define SYS_flock 60
#define SYS_ftruncate 61
#define SYS_fsync 62
#define SYS_fcntl 63
#define SYS_ioctl 64
#define SYS_select 65
#define SYS_poll 66
#define SYS_open 45
#define SYS_pipe 46
#define SYS_dup 47
#define SYS_dup2 48
#define SYS_close 49
#define SYS_read 50
#define SYS_pread 51
// #define SYS_readv 52
// #define SYS_preadv 53
#define SYS_getdirentry 54
#define SYS_write 55
#define SYS_pwrite 56
// #define SYS_writev 57
// #define SYS_pwritev 58
#define SYS_lseek 59
#define SYS_flock 60
#define SYS_ftruncate 61
#define SYS_fsync 62
#define SYS_fcntl 63
#define SYS_ioctl 64
#define SYS_select 65
#define SYS_poll 66
// -- Pathname-related --
#define SYS_link 67
#define SYS_remove 68
#define SYS_mkdir 69
#define SYS_rmdir 70
#define SYS_mkfifo 71
#define SYS_rename 72
#define SYS_access 73
#define SYS_link 67
#define SYS_remove 68
#define SYS_mkdir 69
#define SYS_rmdir 70
#define SYS_mkfifo 71
#define SYS_rename 72
#define SYS_access 73
// (current directory)
#define SYS_chdir 74
#define SYS_fchdir 75
#define SYS___getcwd 76
#define SYS_chdir 74
#define SYS_fchdir 75
#define SYS___getcwd 76
// (symbolic links)
#define SYS_symlink 77
#define SYS_readlink 78
#define SYS_symlink 77
#define SYS_readlink 78
// (mount)
#define SYS_mount 79
#define SYS_unmount 80
#define SYS_mount 79
#define SYS_unmount 80
// -- Any-file-related --
#define SYS_stat 81
#define SYS_fstat 82
#define SYS_lstat 83
#define SYS_stat 81
#define SYS_fstat 82
#define SYS_lstat 83
// (timestamps)
#define SYS_utimes 84
#define SYS_futimes 85
#define SYS_lutimes 86
#define SYS_utimes 84
#define SYS_futimes 85
#define SYS_lutimes 86
// (security/permissions)
#define SYS_chmod 87
#define SYS_chown 88
#define SYS_fchmod 89
#define SYS_fchown 90
#define SYS_lchmod 91
#define SYS_lchown 92
#define SYS_chmod 87
#define SYS_chown 88
#define SYS_fchmod 89
#define SYS_fchown 90
#define SYS_lchmod 91
#define SYS_lchown 92
// (file system info)
//#define SYS_statfs 93
//#define SYS_fstatfs 94
//#define SYS_getfsstat 95
// #define SYS_statfs 93
// #define SYS_fstatfs 94
// #define SYS_getfsstat 95
// (POSIX dynamic system limits stuff)
//#define SYS_pathconf 96
//#define SYS_fpathconf 97
// #define SYS_pathconf 96
// #define SYS_fpathconf 97
// -- Sockets and networking --
#define SYS_socket 98
#define SYS_bind 99
#define SYS_connect 100
#define SYS_listen 101
#define SYS_accept 102
//#define SYS_socketpair 103
#define SYS_shutdown 104
#define SYS_getsockname 105
#define SYS_getpeername 106
#define SYS_getsockopt 107
#define SYS_setsockopt 108
//#define SYS_recvfrom 109
//#define SYS_sendto 110
//#define SYS_recvmsg 111
//#define SYS_sendmsg 112
#define SYS_socket 98
#define SYS_bind 99
#define SYS_connect 100
#define SYS_listen 101
#define SYS_accept 102
// #define SYS_socketpair 103
#define SYS_shutdown 104
#define SYS_getsockname 105
#define SYS_getpeername 106
#define SYS_getsockopt 107
#define SYS_setsockopt 108
// #define SYS_recvfrom 109
// #define SYS_sendto 110
// #define SYS_recvmsg 111
// #define SYS_sendmsg 112
// -- Time-related --
#define SYS___time 113
#define SYS___settime 114
#define SYS_nanosleep 115
//#define SYS_getitimer 116
//#define SYS_setitimer 117
#define SYS___time 113
#define SYS___settime 114
#define SYS_nanosleep 115
// #define SYS_getitimer 116
// #define SYS_setitimer 117
// -- Other --
#define SYS_sync 118
#define SYS_reboot 119
//#define SYS___sysctl 120
#define SYS_sync 118
#define SYS_reboot 119
// #define SYS___sysctl 120
/*CALLEND*/
#endif /* _KERN_SYSCALL_H_ */

View File

@@ -34,37 +34,34 @@
* Time-related definitions, for <sys/time.h> and others.
*/
/*
* Time with fractional seconds. Important. Unfortunately, to be
* compatible, we need both timeval and timespec.
*/
struct timeval {
__time_t tv_sec; /* seconds */
__i32 tv_usec; /* microseconds */
__time_t tv_sec; /* seconds */
__i32 tv_usec; /* microseconds */
};
struct timespec {
__time_t tv_sec; /* seconds */
__i32 tv_nsec; /* nanoseconds */
__time_t tv_sec; /* seconds */
__i32 tv_nsec; /* nanoseconds */
};
/*
* Bits for interval timers. Obscure and not really that important.
*/
/* codes for the various timers */
#define ITIMER_REAL 0 /* Real (wall-clock) time. */
#define ITIMER_VIRTUAL 1 /* Virtual (when process is executing) time. */
#define ITIMER_PROF 2 /* For execution profiling. */
#define ITIMER_REAL 0 /* Real (wall-clock) time. */
#define ITIMER_VIRTUAL 1 /* Virtual (when process is executing) time. */
#define ITIMER_PROF 2 /* For execution profiling. */
/* structure for setitimer/getitimer */
struct itimerval {
struct timeval it_interval; /* Time to reload after expiry. */
struct timeval it_value; /* Time to count. */
struct timeval it_interval; /* Time to reload after expiry. */
struct timeval it_value; /* Time to count. */
};
#endif /* _KERN_TIME_H_ */

View File

@@ -61,32 +61,31 @@
* and also various other places as per relevant standards.
*/
typedef __u32 __blkcnt_t; /* Count of blocks */
typedef __u32 __blksize_t; /* Size of an I/O block */
typedef __u64 __counter_t; /* Event counter */
typedef __u32 __daddr_t; /* Disk block number */
typedef __u32 __dev_t; /* Hardware device ID */
typedef __u32 __fsid_t; /* Filesystem ID */
typedef __i32 __gid_t; /* Group ID */
typedef __u32 __in_addr_t; /* Internet address */
typedef __u32 __in_port_t; /* Internet port number */
typedef __u32 __ino_t; /* Inode number */
typedef __u32 __mode_t; /* File access mode */
typedef __u16 __nlink_t; /* Number of links (intentionally only 16 bits) */
typedef __i64 __off_t; /* Offset within file */
typedef __i32 __pid_t; /* Process ID */
typedef __u64 __rlim_t; /* Resource limit quantity */
typedef __u8 __sa_family_t;/* Socket address family */
typedef __i64 __time_t; /* Time in seconds */
typedef __i32 __uid_t; /* User ID */
typedef __u32 __blkcnt_t; /* Count of blocks */
typedef __u32 __blksize_t; /* Size of an I/O block */
typedef __u64 __counter_t; /* Event counter */
typedef __u32 __daddr_t; /* Disk block number */
typedef __u32 __dev_t; /* Hardware device ID */
typedef __u32 __fsid_t; /* Filesystem ID */
typedef __i32 __gid_t; /* Group ID */
typedef __u32 __in_addr_t; /* Internet address */
typedef __u32 __in_port_t; /* Internet port number */
typedef __u32 __ino_t; /* Inode number */
typedef __u32 __mode_t; /* File access mode */
typedef __u16 __nlink_t; /* Number of links (intentionally only 16 bits) */
typedef __i64 __off_t; /* Offset within file */
typedef __i32 __pid_t; /* Process ID */
typedef __u64 __rlim_t; /* Resource limit quantity */
typedef __u8 __sa_family_t; /* Socket address family */
typedef __i64 __time_t; /* Time in seconds */
typedef __i32 __uid_t; /* User ID */
typedef int __nfds_t; /* Number of file handles */
typedef int __socklen_t; /* Socket-related length */
typedef int __socklen_t; /* Socket-related length */
/* See note in <stdarg.h> */
#ifdef __GNUC__
typedef __builtin_va_list __va_list;
#endif
#endif /* _KERN_TYPES_H_ */

View File

@@ -31,9 +31,8 @@
#define _KERN_UNISTD_H_
/* Constants for read/write/etc: special file handles */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error */
#endif /* _KERN_UNISTD_H_ */

View File

@@ -34,14 +34,13 @@
* Definitions for wait().
*/
/* Flags for waitpid() and equivalent. */
#define WNOHANG 1 /* Nonblocking. */
#define WUNTRACED 2 /* Report stopping as well as exiting processes. */
#define WNOHANG 1 /* Nonblocking. */
#define WUNTRACED 2 /* Report stopping as well as exiting processes. */
/* Special "pids" to wait for. */
#define WAIT_ANY (-1) /* Any child process. */
#define WAIT_MYPGRP 0 /* Any process in the same process group. */
#define WAIT_ANY (-1) /* Any child process. */
#define WAIT_MYPGRP 0 /* Any process in the same process group. */
/*
* Result encoding.
@@ -51,29 +50,29 @@
* is different, wastes most of the bits and can only transmit 8 bits
* of exit code...
*/
#define _WWHAT(x) ((x)&3) /* lower two bits say what happened */
#define _WVAL(x) ((x)>>2) /* the rest is the value */
#define _MKWVAL(x) ((x)<<2) /* encode a value */
#define _WWHAT(x) ((x) & 3) /* lower two bits say what happened */
#define _WVAL(x) ((x) >> 2) /* the rest is the value */
#define _MKWVAL(x) ((x) << 2) /* encode a value */
/* Four things can happen... */
#define __WEXITED 0 /* Process exited by calling _exit(). */
#define __WSIGNALED 1 /* Process received a fatal signal. */
#define __WCORED 2 /* Process dumped core on a fatal signal. */
#define __WSTOPPED 3 /* Process stopped (and didn't exit). */
#define __WEXITED 0 /* Process exited by calling _exit(). */
#define __WSIGNALED 1 /* Process received a fatal signal. */
#define __WCORED 2 /* Process dumped core on a fatal signal. */
#define __WSTOPPED 3 /* Process stopped (and didn't exit). */
/* Test macros, used by applications. */
#define WIFEXITED(x) (_WWHAT(x)==__WEXITED)
#define WIFSIGNALED(x) (_WWHAT(x)==__WSIGNALED || _WWHAT(x)==__WCORED)
#define WIFSTOPPED(x) (_WWHAT(x)==__WSTOPPED)
#define WIFEXITED(x) (_WWHAT(x) == __WEXITED)
#define WIFSIGNALED(x) (_WWHAT(x) == __WSIGNALED || _WWHAT(x) == __WCORED)
#define WIFSTOPPED(x) (_WWHAT(x) == __WSTOPPED)
#define WEXITSTATUS(x) (_WVAL(x))
#define WTERMSIG(x) (_WVAL(x))
#define WSTOPSIG(x) (_WVAL(x))
#define WCOREDUMP(x) (_WWHAT(x)==__WCORED)
#define WTERMSIG(x) (_WVAL(x))
#define WSTOPSIG(x) (_WVAL(x))
#define WCOREDUMP(x) (_WWHAT(x) == __WCORED)
/* Encoding macros, used by the kernel to generate the wait result. */
#define _MKWAIT_EXIT(x) (_MKWVAL(x)|__WEXITED)
#define _MKWAIT_SIG(x) (_MKWVAL(x)|__WSIGNALED)
#define _MKWAIT_CORE(x) (_MKWVAL(x)|__WCORED)
#define _MKWAIT_STOP(x) (_MKWVAL(x)|__WSTOPPED)
#define _MKWAIT_EXIT(x) (_MKWVAL(x) | __WEXITED)
#define _MKWAIT_SIG(x) (_MKWVAL(x) | __WSIGNALED)
#define _MKWAIT_CORE(x) (_MKWVAL(x) | __WCORED)
#define _MKWAIT_STOP(x) (_MKWVAL(x) | __WSTOPPED)
#endif /* _KERN_WAIT_H_ */

View File

@@ -37,7 +37,6 @@
* Note: setjmp and longjmp are in <setjmp.h>.
*/
#include <cdefs.h>
/*
@@ -62,33 +61,33 @@
#if OPT_NOASSERTS
#define KASSERT(expr) ((void)(expr))
#else
#define KASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#define KASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#endif
#if 1 /* no debug asserts */
#define DEBUGASSERT(expr) ((void)(expr))
#else
#define DEBUGASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#define DEBUGASSERT(expr) \
((expr) ? (void)0 : badassert(#expr, __FILE__, __LINE__, __func__))
#endif
/*
* Bit flags for DEBUG()
*/
#define DB_LOCORE 0x0001
#define DB_SYSCALL 0x0002
#define DB_INTERRUPT 0x0004
#define DB_DEVICE 0x0008
#define DB_THREADS 0x0010
#define DB_VM 0x0020
#define DB_EXEC 0x0040
#define DB_VFS 0x0080
#define DB_SEMFS 0x0100
#define DB_SFS 0x0200
#define DB_NET 0x0400
#define DB_NETFS 0x0800
#define DB_KMALLOC 0x1000
#define DB_LOCORE 0x0001
#define DB_SYSCALL 0x0002
#define DB_INTERRUPT 0x0004
#define DB_DEVICE 0x0008
#define DB_THREADS 0x0010
#define DB_VM 0x0020
#define DB_EXEC 0x0040
#define DB_VFS 0x0080
#define DB_SEMFS 0x0100
#define DB_SFS 0x0200
#define DB_NET 0x0400
#define DB_NETFS 0x0800
#define DB_KMALLOC 0x1000
extern uint32_t dbflags;
@@ -154,7 +153,7 @@ void *memset(void *block, int ch, size_t len);
void bzero(void *ptr, size_t len);
int atoi(const char *str);
int snprintf(char *buf, size_t maxlen, const char *fmt, ...) __PF(3,4);
int snprintf(char *buf, size_t maxlen, const char *fmt, ...) __PF(3, 4);
const char *strerror(int errcode);
@@ -178,10 +177,10 @@ void beep(void);
* during boot once malloc is available and before any additional
* threads are created.
*/
int kprintf(const char *format, ...) __PF(1,2);
__DEAD void panic(const char *format, ...) __PF(1,2);
__DEAD void badassert(const char *expr, const char *file,
int line, const char *func);
int kprintf(const char *format, ...) __PF(1, 2);
__DEAD void panic(const char *format, ...) __PF(1, 2);
__DEAD void badassert(const char *expr, const char *file, int line,
const char *func);
void kgets(char *buf, size_t maxbuflen);
@@ -191,8 +190,7 @@ void kprintf_bootstrap(void);
* Other miscellaneous stuff
*/
#define DIVROUNDUP(a,b) (((a)+(b)-1)/(b))
#define ROUNDUP(a,b) (DIVROUNDUP(a,b)*(b))
#define DIVROUNDUP(a, b) (((a) + (b) - 1) / (b))
#define ROUNDUP(a, b) (DIVROUNDUP(a, b) * (b))
#endif /* _LIB_H_ */

View File

@@ -38,15 +38,15 @@
#include <kern/limits.h>
/* Provide the real names */
#define NAME_MAX __NAME_MAX
#define PATH_MAX __PATH_MAX
#define ARG_MAX __ARG_MAX
#define PID_MIN __PID_MIN
#define PID_MAX __PID_MAX
#define PIPE_BUF __PIPE_BUF
#define NGROUPS_MAX __NGROUPS_MAX
#define LOGIN_NAME_MAX __LOGIN_NAME_MAX
#define OPEN_MAX __OPEN_MAX
#define IOV_MAX __IOV_MAX
#define NAME_MAX __NAME_MAX
#define PATH_MAX __PATH_MAX
#define ARG_MAX __ARG_MAX
#define PID_MIN __PID_MIN
#define PID_MAX __PID_MAX
#define PIPE_BUF __PIPE_BUF
#define NGROUPS_MAX __NGROUPS_MAX
#define LOGIN_NAME_MAX __LOGIN_NAME_MAX
#define OPEN_MAX __OPEN_MAX
#define IOV_MAX __IOV_MAX
#endif /* _LIMITS_H_ */

View File

@@ -34,11 +34,9 @@
* Abstract system bus interface.
*/
struct cpu; /* from <cpu.h> */
struct trapframe; /* from <machine/trapframe.h> */
/* Initialize the system bus and probe and attach hardware devices. */
void mainbus_bootstrap(void);
@@ -69,5 +67,4 @@ void mainbus_poweroff(void);
void mainbus_reboot(void);
void mainbus_panic(void);
#endif /* _MAINBUS_H_ */

View File

@@ -60,17 +60,17 @@ struct vnode;
* without sleeping.
*/
struct proc {
char *p_name; /* Name of this process */
struct spinlock p_lock; /* Lock for this structure */
unsigned p_numthreads; /* Number of threads in this process */
char *p_name; /* Name of this process */
struct spinlock p_lock; /* Lock for this structure */
unsigned p_numthreads; /* Number of threads in this process */
/* VM */
struct addrspace *p_addrspace; /* virtual address space */
/* VM */
struct addrspace *p_addrspace; /* virtual address space */
/* VFS */
struct vnode *p_cwd; /* current working directory */
/* VFS */
struct vnode *p_cwd; /* current working directory */
/* add more material here as needed */
/* add more material here as needed */
};
/* This is the process structure for the kernel and for kernel-only threads. */
@@ -97,5 +97,4 @@ struct addrspace *proc_getas(void);
/* Change the address space of the current process, and return the old one. */
struct addrspace *proc_setas(struct addrspace *);
#endif /* _PROC_H_ */

View File

@@ -40,5 +40,4 @@
int setjmp(jmp_buf jb);
void longjmp(jmp_buf jb, int retval);
#endif /* _SETJMP_H_ */

View File

@@ -30,12 +30,10 @@
#ifndef _SFS_H_
#define _SFS_H_
/*
* Header for SFS, the Simple File System.
*/
/*
* Get abstract structure definitions
*/
@@ -52,23 +50,23 @@
* In-memory inode
*/
struct sfs_vnode {
struct vnode sv_absvn; /* abstract vnode structure */
struct sfs_dinode sv_i; /* copy of on-disk inode */
uint32_t sv_ino; /* inode number */
bool sv_dirty; /* true if sv_i modified */
struct vnode sv_absvn; /* abstract vnode structure */
struct sfs_dinode sv_i; /* copy of on-disk inode */
uint32_t sv_ino; /* inode number */
bool sv_dirty; /* true if sv_i modified */
};
/*
* In-memory info for a whole fs volume
*/
struct sfs_fs {
struct fs sfs_absfs; /* abstract filesystem structure */
struct sfs_superblock sfs_sb; /* copy of on-disk superblock */
bool sfs_superdirty; /* true if superblock modified */
struct device *sfs_device; /* device mounted on */
struct vnodearray *sfs_vnodes; /* vnodes loaded into memory */
struct bitmap *sfs_freemap; /* blocks in use are marked 1 */
bool sfs_freemapdirty; /* true if freemap modified */
struct fs sfs_absfs; /* abstract filesystem structure */
struct sfs_superblock sfs_sb; /* copy of on-disk superblock */
bool sfs_superdirty; /* true if superblock modified */
struct device *sfs_device; /* device mounted on */
struct vnodearray *sfs_vnodes; /* vnodes loaded into memory */
struct bitmap *sfs_freemap; /* blocks in use are marked 1 */
bool sfs_freemapdirty; /* true if freemap modified */
};
/*
@@ -76,5 +74,4 @@ struct sfs_fs {
*/
int sfs_mount(const char *device);
#endif /* _SFS_H_ */

View File

@@ -35,5 +35,4 @@
#include <kern/machine/signal.h>
#include <kern/signal.h>
#endif /* _SIGNAL_H_ */

View File

@@ -56,19 +56,19 @@
* the structure directly but always use the spinlock API functions.
*/
struct spinlock {
volatile spinlock_data_t splk_lock; /* Memory word where we spin. */
struct cpu *splk_holder; /* CPU holding this lock. */
HANGMAN_LOCKABLE(splk_hangman); /* Deadlock detector hook. */
volatile spinlock_data_t splk_lock; /* Memory word where we spin. */
struct cpu *splk_holder; /* CPU holding this lock. */
HANGMAN_LOCKABLE(splk_hangman); /* Deadlock detector hook. */
};
/*
* Initializer for cases where a spinlock needs to be static or global.
*/
#ifdef OPT_HANGMAN
#define SPINLOCK_INITIALIZER { SPINLOCK_DATA_INITIALIZER, NULL, \
HANGMAN_LOCKABLE_INITIALIZER }
#define SPINLOCK_INITIALIZER \
{SPINLOCK_DATA_INITIALIZER, NULL, HANGMAN_LOCKABLE_INITIALIZER}
#else
#define SPINLOCK_INITIALIZER { SPINLOCK_DATA_INITIALIZER, NULL }
#define SPINLOCK_INITIALIZER {SPINLOCK_DATA_INITIALIZER, NULL}
#endif
/*
@@ -91,5 +91,4 @@ void spinlock_release(struct spinlock *lk);
bool spinlock_do_i_hold(struct spinlock *lk);
#endif /* _SPINLOCK_H_ */

View File

@@ -74,8 +74,8 @@ int splx(int);
/*
* Integer interrupt priority levels.
*/
#define IPL_NONE 0
#define IPL_HIGH 1
#define IPL_NONE 0
#define IPL_HIGH 1
/*
* Lower-level functions for explicitly raising and lowering
@@ -92,18 +92,9 @@ void spllower(int oldipl, int newipl);
////////////////////////////////////////////////////////////
SPL_INLINE
int
spl0(void)
{
return splx(IPL_NONE);
}
int spl0(void) { return splx(IPL_NONE); }
SPL_INLINE
int
splhigh(void)
{
return splx(IPL_HIGH);
}
int splhigh(void) { return splx(IPL_HIGH); }
#endif /* _SPL_H_ */

View File

@@ -37,14 +37,13 @@
#include <kern/stattypes.h>
/* Provide non-underscore names. */
#define S_IFMT _S_IFMT
#define S_IFREG _S_IFREG
#define S_IFDIR _S_IFDIR
#define S_IFLNK _S_IFLNK
#define S_IFIFO _S_IFIFO
#define S_IFMT _S_IFMT
#define S_IFREG _S_IFREG
#define S_IFDIR _S_IFDIR
#define S_IFLNK _S_IFLNK
#define S_IFIFO _S_IFIFO
#define S_IFSOCK _S_IFSOCK
#define S_IFCHR _S_IFCHR
#define S_IFBLK _S_IFBLK
#define S_IFCHR _S_IFCHR
#define S_IFBLK _S_IFBLK
#endif /* _STAT_H */

View File

@@ -30,7 +30,6 @@
#ifndef _STDARG_H_
#define _STDARG_H_
/* Get __PF() for declaring printf-like functions. */
#include <cdefs.h>
@@ -46,13 +45,13 @@
typedef __va_list va_list;
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
#define va_start(ap, fmt) __builtin_stdarg_start(ap, fmt)
#define va_start(ap, fmt) __builtin_stdarg_start(ap, fmt)
#else
#define va_start(ap, fmt) __builtin_va_start(ap, fmt)
#define va_start(ap, fmt) __builtin_va_start(ap, fmt)
#endif
#define va_arg(ap,t) __builtin_va_arg(ap, t)
#define va_copy(ap1, ap2) __builtin_va_copy(ap1, ap2)
#define va_end(ap) __builtin_va_end(ap)
#define va_arg(ap, t) __builtin_va_arg(ap, t)
#define va_copy(ap1, ap2) __builtin_va_copy(ap1, ap2)
#define va_end(ap) __builtin_va_end(ap)
#endif
/*
@@ -62,8 +61,8 @@ typedef __va_list va_list;
* or split the definition of va_list into another header file, none
* of which seems entirely desirable.
*/
void vkprintf(const char *fmt, va_list ap) __PF(1,0);
int vsnprintf(char *buf, size_t maxlen, const char *fmt, va_list ap) __PF(3,0);
void vkprintf(const char *fmt, va_list ap) __PF(1, 0);
int vsnprintf(char *buf, size_t maxlen, const char *fmt, va_list ap) __PF(3, 0);
/*
* The printf driver function (shared with libc).
@@ -73,7 +72,6 @@ int vsnprintf(char *buf, size_t maxlen, const char *fmt, va_list ap) __PF(3,0);
* supplied length should be used explicitly.
*/
int __vprintf(void (*func)(void *clientdata, const char *str, size_t len),
void *clientdata, const char *format, va_list ap) __PF(3,0);
void *clientdata, const char *format, va_list ap) __PF(3, 0);
#endif /* _STDARG_H_ */

View File

@@ -34,7 +34,6 @@
* Header file for synchronization primitives.
*/
#include <spinlock.h>
/*
@@ -44,10 +43,10 @@
* internally.
*/
struct semaphore {
char *sem_name;
struct wchan *sem_wchan;
struct spinlock sem_lock;
volatile unsigned sem_count;
char *sem_name;
struct wchan *sem_wchan;
struct spinlock sem_lock;
volatile unsigned sem_count;
};
struct semaphore *sem_create(const char *name, unsigned initial_count);
@@ -62,7 +61,6 @@ void sem_destroy(struct semaphore *);
void P(struct semaphore *);
void V(struct semaphore *);
/*
* Simple lock for mutual exclusion.
*
@@ -73,10 +71,10 @@ void V(struct semaphore *);
* (should be) made internally.
*/
struct lock {
char *lk_name;
HANGMAN_LOCKABLE(lk_hangman); /* Deadlock detector hook. */
// add what you need here
// (don't forget to mark things volatile as needed)
char *lk_name;
HANGMAN_LOCKABLE(lk_hangman); /* Deadlock detector hook. */
// add what you need here
// (don't forget to mark things volatile as needed)
};
struct lock *lock_create(const char *name);
@@ -97,7 +95,6 @@ void lock_acquire(struct lock *);
void lock_release(struct lock *);
bool lock_do_i_hold(struct lock *);
/*
* Condition variable.
*
@@ -113,9 +110,9 @@ bool lock_do_i_hold(struct lock *);
*/
struct cv {
char *cv_name;
// add what you need here
// (don't forget to mark things volatile as needed)
char *cv_name;
// add what you need here
// (don't forget to mark things volatile as needed)
};
struct cv *cv_create(const char *name);
@@ -138,5 +135,4 @@ void cv_wait(struct cv *cv, struct lock *lock);
void cv_signal(struct cv *cv, struct lock *lock);
void cv_broadcast(struct cv *cv, struct lock *lock);
#endif /* _SYNCH_H_ */

View File

@@ -30,9 +30,8 @@
#ifndef _SYSCALL_H_
#define _SYSCALL_H_
#include <cdefs.h> /* for __DEAD */
struct trapframe; /* from <machine/trapframe.h> */
struct trapframe; /* from <machine/trapframe.h> */
/*
* The system call dispatcher.
@@ -49,8 +48,7 @@ void enter_forked_process(struct trapframe *tf);
/* Enter user mode. Does not return. */
__DEAD void enter_new_process(int argc, userptr_t argv, userptr_t env,
vaddr_t stackptr, vaddr_t entrypoint);
vaddr_t stackptr, vaddr_t entrypoint);
/*
* Prototypes for IN-KERNEL entry points for system call implementations.

View File

@@ -35,7 +35,6 @@
* functions.
*/
/*
* Test code.
*/
@@ -104,5 +103,4 @@ void menu(char *argstr);
/* The main function, called from start.S. */
void kmain(char *bootstring);
#endif /* _TEST_H_ */

View File

@@ -45,68 +45,66 @@ struct cpu;
/* get machine-dependent defs */
#include <machine/thread.h>
/* Size of kernel stacks; must be power of 2 */
#define STACK_SIZE 4096
/* Mask for extracting the stack base address of a kernel stack pointer */
#define STACK_MASK (~(vaddr_t)(STACK_SIZE-1))
#define STACK_MASK (~(vaddr_t)(STACK_SIZE - 1))
/* Macro to test if two addresses are on the same kernel stack */
#define SAME_STACK(p1, p2) (((p1) & STACK_MASK) == ((p2) & STACK_MASK))
#define SAME_STACK(p1, p2) (((p1) & STACK_MASK) == ((p2) & STACK_MASK))
/* States a thread can be in. */
typedef enum {
S_RUN, /* running */
S_READY, /* ready to run */
S_SLEEP, /* sleeping */
S_ZOMBIE, /* zombie; exited but not yet deleted */
S_RUN, /* running */
S_READY, /* ready to run */
S_SLEEP, /* sleeping */
S_ZOMBIE, /* zombie; exited but not yet deleted */
} threadstate_t;
/* Thread structure. */
struct thread {
/*
* These go up front so they're easy to get to even if the
* debugger is messed up.
*/
char *t_name; /* Name of this thread */
const char *t_wchan_name; /* Name of wait channel, if sleeping */
threadstate_t t_state; /* State this thread is in */
/*
* These go up front so they're easy to get to even if the
* debugger is messed up.
*/
char *t_name; /* Name of this thread */
const char *t_wchan_name; /* Name of wait channel, if sleeping */
threadstate_t t_state; /* State this thread is in */
/*
* Thread subsystem internal fields.
*/
struct thread_machdep t_machdep; /* Any machine-dependent goo */
struct threadlistnode t_listnode; /* Link for run/sleep/zombie lists */
void *t_stack; /* Kernel-level stack */
struct switchframe *t_context; /* Saved register context (on stack) */
struct cpu *t_cpu; /* CPU thread runs on */
struct proc *t_proc; /* Process thread belongs to */
HANGMAN_ACTOR(t_hangman); /* Deadlock detector hook */
/*
* Thread subsystem internal fields.
*/
struct thread_machdep t_machdep; /* Any machine-dependent goo */
struct threadlistnode t_listnode; /* Link for run/sleep/zombie lists */
void *t_stack; /* Kernel-level stack */
struct switchframe *t_context; /* Saved register context (on stack) */
struct cpu *t_cpu; /* CPU thread runs on */
struct proc *t_proc; /* Process thread belongs to */
HANGMAN_ACTOR(t_hangman); /* Deadlock detector hook */
/*
* Interrupt state fields.
*
* t_in_interrupt is true if current execution is in an
* interrupt handler, which means the thread's normal context
* of execution is stopped somewhere in the middle of doing
* something else. This makes assorted operations unsafe.
*
* See notes in spinlock.c regarding t_curspl and t_iplhigh_count.
*
* Exercise for the student: why is this material per-thread
* rather than per-cpu or global?
*/
bool t_in_interrupt; /* Are we in an interrupt? */
int t_curspl; /* Current spl*() state */
int t_iplhigh_count; /* # of times IPL has been raised */
/*
* Interrupt state fields.
*
* t_in_interrupt is true if current execution is in an
* interrupt handler, which means the thread's normal context
* of execution is stopped somewhere in the middle of doing
* something else. This makes assorted operations unsafe.
*
* See notes in spinlock.c regarding t_curspl and t_iplhigh_count.
*
* Exercise for the student: why is this material per-thread
* rather than per-cpu or global?
*/
bool t_in_interrupt; /* Are we in an interrupt? */
int t_curspl; /* Current spl*() state */
int t_iplhigh_count; /* # of times IPL has been raised */
/*
* Public fields
*/
/*
* Public fields
*/
/* add more here as needed */
/* add more here as needed */
};
/*
@@ -142,8 +140,8 @@ void thread_shutdown(void);
* disappear at any time without notice.
*/
int thread_fork(const char *name, struct proc *proc,
void (*func)(void *, unsigned long),
void *data1, unsigned long data2);
void (*func)(void *, unsigned long), void *data1,
unsigned long data2);
/*
* Cause the current thread to exit.
@@ -169,5 +167,4 @@ void schedule(void);
*/
void thread_consider_migration(void);
#endif /* _THREAD_H_ */

View File

@@ -30,8 +30,7 @@
#ifndef _THREADLIST_H_
#define _THREADLIST_H_
struct thread; /* from <thread.h> */
struct thread; /* from <thread.h> */
/*
* AmigaOS-style linked list of threads.
@@ -55,15 +54,15 @@ struct thread; /* from <thread.h> */
*/
struct threadlistnode {
struct threadlistnode *tln_prev;
struct threadlistnode *tln_next;
struct thread *tln_self;
struct threadlistnode *tln_prev;
struct threadlistnode *tln_next;
struct thread *tln_self;
};
struct threadlist {
struct threadlistnode tl_head;
struct threadlistnode tl_tail;
unsigned tl_count;
struct threadlistnode tl_head;
struct threadlistnode tl_tail;
unsigned tl_count;
};
/* Initialize and clean up a thread list node. */
@@ -84,22 +83,19 @@ struct thread *threadlist_remhead(struct threadlist *tl);
struct thread *threadlist_remtail(struct threadlist *tl);
/* Add and remove: in middle. (TL is needed to maintain ->tl_count.) */
void threadlist_insertafter(struct threadlist *tl,
struct thread *onlist, struct thread *addee);
void threadlist_insertbefore(struct threadlist *tl,
struct thread *addee, struct thread *onlist);
void threadlist_insertafter(struct threadlist *tl, struct thread *onlist,
struct thread *addee);
void threadlist_insertbefore(struct threadlist *tl, struct thread *addee,
struct thread *onlist);
void threadlist_remove(struct threadlist *tl, struct thread *t);
/* Iteration; itervar should previously be declared as (struct thread *) */
#define THREADLIST_FORALL(itervar, tl) \
for ((itervar) = (tl).tl_head.tln_next->tln_self; \
(itervar) != NULL; \
(itervar) = (itervar)->t_listnode.tln_next->tln_self)
#define THREADLIST_FORALL_REV(itervar, tl) \
for ((itervar) = (tl).tl_tail.tln_prev->tln_self; \
(itervar) != NULL; \
(itervar) = (itervar)->t_listnode.tln_prev->tln_self)
#define THREADLIST_FORALL(itervar, tl) \
for ((itervar) = (tl).tl_head.tln_next->tln_self; (itervar) != NULL; \
(itervar) = (itervar)->t_listnode.tln_next->tln_self)
#define THREADLIST_FORALL_REV(itervar, tl) \
for ((itervar) = (tl).tl_tail.tln_prev->tln_self; (itervar) != NULL; \
(itervar) = (itervar)->t_listnode.tln_prev->tln_self)
#endif /* _THREADLIST_H_ */

View File

@@ -30,10 +30,9 @@
#ifndef _THREADPRIVATE_H_
#define _THREADPRIVATE_H_
struct thread; /* from <thread.h> */
struct thread_machdep; /* from <machine/thread.h> */
struct switchframe; /* from <machine/switchframe.h> */
struct thread; /* from <thread.h> */
struct thread_machdep; /* from <machine/thread.h> */
struct switchframe; /* from <machine/switchframe.h> */
/*
* Subsystem-private thread defs.
@@ -46,14 +45,13 @@ struct switchframe; /* from <machine/switchframe.h> */
* interfaces.
*/
/*
* Private thread functions.
*/
/* Entry point for new threads. */
void thread_startup(void (*entrypoint)(void *data1, unsigned long data2),
void *data1, unsigned long data2);
void *data1, unsigned long data2);
/* Initialize or clean up the machine-dependent portion of struct thread */
void thread_machdep_init(struct thread_machdep *tm);
@@ -71,8 +69,7 @@ void switchframe_switch(struct switchframe **prev, struct switchframe **next);
/* Thread initialization */
void switchframe_init(struct thread *,
void (*entrypoint)(void *data1, unsigned long data2),
void *data1, unsigned long data2);
void (*entrypoint)(void *data1, unsigned long data2),
void *data1, unsigned long data2);
#endif /* _THREADPRIVATE_H_ */

View File

@@ -75,7 +75,6 @@
* this principle produces a workable result.
*/
/* Get types visible to userland, both MI and MD. */
#include <kern/types.h>
@@ -87,7 +86,9 @@
* with other pointers.
*/
struct __userptr { char _dummy; };
struct __userptr {
char _dummy;
};
typedef struct __userptr *userptr_t;
typedef const struct __userptr *const_userptr_t;
@@ -149,7 +150,7 @@ typedef __socklen_t socklen_t;
* Boolean.
*/
typedef _Bool bool;
#define true 1
#define true 1
#define false 0
#endif /* _TYPES_H_ */

View File

@@ -59,28 +59,27 @@
/* Direction. */
enum uio_rw {
UIO_READ, /* From kernel to uio_seg */
UIO_WRITE, /* From uio_seg to kernel */
UIO_READ, /* From kernel to uio_seg */
UIO_WRITE, /* From uio_seg to kernel */
};
/* Source/destination. */
enum uio_seg {
UIO_USERISPACE, /* User process code. */
UIO_USERSPACE, /* User process data. */
UIO_SYSSPACE, /* Kernel. */
UIO_USERISPACE, /* User process code. */
UIO_USERSPACE, /* User process data. */
UIO_SYSSPACE, /* Kernel. */
};
struct uio {
struct iovec *uio_iov; /* Data blocks */
unsigned uio_iovcnt; /* Number of iovecs */
off_t uio_offset; /* Desired offset into object */
size_t uio_resid; /* Remaining amt of data to xfer */
enum uio_seg uio_segflg; /* What kind of pointer we have */
enum uio_rw uio_rw; /* Whether op is a read or write */
struct addrspace *uio_space; /* Address space for user pointer */
struct iovec *uio_iov; /* Data blocks */
unsigned uio_iovcnt; /* Number of iovecs */
off_t uio_offset; /* Desired offset into object */
size_t uio_resid; /* Remaining amt of data to xfer */
enum uio_seg uio_segflg; /* What kind of pointer we have */
enum uio_rw uio_rw; /* Whether op is a read or write */
struct addrspace *uio_space; /* Address space for user pointer */
};
/*
* Copy data from a kernel buffer to a data region defined by a uio struct,
* updating the uio struct's offset and resid fields. May alter the iovec
@@ -135,8 +134,7 @@ int uiomovezeros(size_t len, struct uio *uio);
* result = VOP_READ(vn, &myuio);
* ...
*/
void uio_kinit(struct iovec *, struct uio *,
void *kbuf, size_t len, off_t pos, enum uio_rw rw);
void uio_kinit(struct iovec *, struct uio *, void *kbuf, size_t len, off_t pos,
enum uio_rw rw);
#endif /* _UIO_H_ */

View File

@@ -34,12 +34,11 @@
* Leave this alone, so we can tell what version of the OS/161 base
* code we gave you.
*/
#define BASE_VERSION "2.0.3"
#define BASE_VERSION "2.0.3"
/*
* Change this as you see fit in the course of hacking the system.
*/
#define GROUP_VERSION "0"
#define GROUP_VERSION "0"
#endif /* _VERSION_H_ */

View File

@@ -30,10 +30,8 @@
#ifndef _VFS_H_
#define _VFS_H_
#include <array.h>
/*
* Virtual File System layer functions.
*
@@ -78,8 +76,7 @@ const char *vfs_getdevname(struct fs *fs);
*/
int vfs_lookup(char *path, struct vnode **result);
int vfs_lookparent(char *path, struct vnode **result,
char *buf, size_t buflen);
int vfs_lookparent(char *path, struct vnode **result, char *buf, size_t buflen);
/*
* VFS layer high-level operations on pathnames
@@ -175,9 +172,8 @@ int vfs_adddev(const char *devname, struct device *dev, int mountable);
int vfs_addfs(const char *devname, struct fs *fs);
int vfs_mount(const char *devname, void *data,
int (*mountfunc)(void *data,
struct device *dev,
struct fs **result));
int (*mountfunc)(void *data, struct device *dev,
struct fs **result));
int vfs_unmount(const char *devname);
int vfs_swapon(const char *devname, struct vnode **result);
int vfs_swapoff(const char *devname);
@@ -201,5 +197,4 @@ void vfs_biglock_acquire(void);
void vfs_biglock_release(void);
bool vfs_biglock_do_i_hold(void);
#endif /* _VFS_H_ */

View File

@@ -36,14 +36,12 @@
* You'll probably want to add stuff here.
*/
#include <machine/vm.h>
/* Fault-type arguments to vm_fault() */
#define VM_FAULT_READ 0 /* A read was attempted */
#define VM_FAULT_WRITE 1 /* A write was attempted */
#define VM_FAULT_READONLY 2 /* A write to a readonly page was attempted*/
#define VM_FAULT_READ 0 /* A read was attempted */
#define VM_FAULT_WRITE 1 /* A write was attempted */
#define VM_FAULT_READONLY 2 /* A write to a readonly page was attempted*/
/* Initialization function */
void vm_bootstrap(void);
@@ -58,5 +56,4 @@ void free_kpages(vaddr_t addr);
/* TLB shootdown handling called from interprocessor_interrupt */
void vm_tlbshootdown(const struct tlbshootdown *);
#endif /* _VM_H_ */

View File

@@ -34,7 +34,6 @@
struct uio;
struct stat;
/*
* A struct vnode is an abstract representation of a file.
*
@@ -49,14 +48,14 @@ struct stat;
* Note: vn_fs may be null if the vnode refers to a device.
*/
struct vnode {
int vn_refcount; /* Reference count */
struct spinlock vn_countlock; /* Lock for vn_refcount */
int vn_refcount; /* Reference count */
struct spinlock vn_countlock; /* Lock for vn_refcount */
struct fs *vn_fs; /* Filesystem vnode belongs to */
struct fs *vn_fs; /* Filesystem vnode belongs to */
void *vn_data; /* Filesystem-specific data */
void *vn_data; /* Filesystem-specific data */
const struct vnode_ops *vn_ops; /* Functions on this vnode */
const struct vnode_ops *vn_ops; /* Functions on this vnode */
};
/*
@@ -175,82 +174,74 @@ struct vnode {
* vnode handed back.
*/
#define VOP_MAGIC 0xa2b3c4d5
#define VOP_MAGIC 0xa2b3c4d5
struct vnode_ops {
unsigned long vop_magic; /* should always be VOP_MAGIC */
unsigned long vop_magic; /* should always be VOP_MAGIC */
int (*vop_eachopen)(struct vnode *object, int flags_from_open);
int (*vop_reclaim)(struct vnode *vnode);
int (*vop_eachopen)(struct vnode *object, int flags_from_open);
int (*vop_reclaim)(struct vnode *vnode);
int (*vop_read)(struct vnode *file, struct uio *uio);
int (*vop_readlink)(struct vnode *link, struct uio *uio);
int (*vop_getdirentry)(struct vnode *dir, struct uio *uio);
int (*vop_write)(struct vnode *file, struct uio *uio);
int (*vop_ioctl)(struct vnode *object, int op, userptr_t data);
int (*vop_stat)(struct vnode *object, struct stat *statbuf);
int (*vop_gettype)(struct vnode *object, mode_t *result);
bool (*vop_isseekable)(struct vnode *object);
int (*vop_fsync)(struct vnode *object);
int (*vop_mmap)(struct vnode *file /* add stuff */);
int (*vop_truncate)(struct vnode *file, off_t len);
int (*vop_namefile)(struct vnode *file, struct uio *uio);
int (*vop_read)(struct vnode *file, struct uio *uio);
int (*vop_readlink)(struct vnode *link, struct uio *uio);
int (*vop_getdirentry)(struct vnode *dir, struct uio *uio);
int (*vop_write)(struct vnode *file, struct uio *uio);
int (*vop_ioctl)(struct vnode *object, int op, userptr_t data);
int (*vop_stat)(struct vnode *object, struct stat *statbuf);
int (*vop_gettype)(struct vnode *object, mode_t *result);
bool (*vop_isseekable)(struct vnode *object);
int (*vop_fsync)(struct vnode *object);
int (*vop_mmap)(struct vnode *file /* add stuff */);
int (*vop_truncate)(struct vnode *file, off_t len);
int (*vop_namefile)(struct vnode *file, struct uio *uio);
int (*vop_creat)(struct vnode *dir, const char *name, bool excl, mode_t mode,
struct vnode **result);
int (*vop_symlink)(struct vnode *dir, const char *contents, const char *name);
int (*vop_mkdir)(struct vnode *parentdir, const char *name, mode_t mode);
int (*vop_link)(struct vnode *dir, const char *name, struct vnode *file);
int (*vop_remove)(struct vnode *dir, const char *name);
int (*vop_rmdir)(struct vnode *dir, const char *name);
int (*vop_rename)(struct vnode *vn1, const char *name1, struct vnode *vn2,
const char *name2);
int (*vop_creat)(struct vnode *dir,
const char *name, bool excl, mode_t mode,
struct vnode **result);
int (*vop_symlink)(struct vnode *dir,
const char *contents, const char *name);
int (*vop_mkdir)(struct vnode *parentdir,
const char *name, mode_t mode);
int (*vop_link)(struct vnode *dir,
const char *name, struct vnode *file);
int (*vop_remove)(struct vnode *dir,
const char *name);
int (*vop_rmdir)(struct vnode *dir,
const char *name);
int (*vop_rename)(struct vnode *vn1, const char *name1,
struct vnode *vn2, const char *name2);
int (*vop_lookup)(struct vnode *dir,
char *pathname, struct vnode **result);
int (*vop_lookparent)(struct vnode *dir,
char *pathname, struct vnode **result,
char *buf, size_t len);
int (*vop_lookup)(struct vnode *dir, char *pathname, struct vnode **result);
int (*vop_lookparent)(struct vnode *dir, char *pathname,
struct vnode **result, char *buf, size_t len);
};
#define __VOP(vn, sym) (vnode_check(vn, #sym), (vn)->vn_ops->vop_##sym)
#define VOP_EACHOPEN(vn, flags) (__VOP(vn, eachopen)(vn, flags))
#define VOP_RECLAIM(vn) (__VOP(vn, reclaim)(vn))
#define VOP_EACHOPEN(vn, flags) (__VOP(vn, eachopen)(vn, flags))
#define VOP_RECLAIM(vn) (__VOP(vn, reclaim)(vn))
#define VOP_READ(vn, uio) (__VOP(vn, read)(vn, uio))
#define VOP_READLINK(vn, uio) (__VOP(vn, readlink)(vn, uio))
#define VOP_GETDIRENTRY(vn, uio) (__VOP(vn,getdirentry)(vn, uio))
#define VOP_WRITE(vn, uio) (__VOP(vn, write)(vn, uio))
#define VOP_IOCTL(vn, code, buf) (__VOP(vn, ioctl)(vn,code,buf))
#define VOP_STAT(vn, ptr) (__VOP(vn, stat)(vn, ptr))
#define VOP_GETTYPE(vn, result) (__VOP(vn, gettype)(vn, result))
#define VOP_ISSEEKABLE(vn) (__VOP(vn, isseekable)(vn))
#define VOP_FSYNC(vn) (__VOP(vn, fsync)(vn))
#define VOP_MMAP(vn /*add stuff */) (__VOP(vn, mmap)(vn /*add stuff */))
#define VOP_TRUNCATE(vn, pos) (__VOP(vn, truncate)(vn, pos))
#define VOP_NAMEFILE(vn, uio) (__VOP(vn, namefile)(vn, uio))
#define VOP_READ(vn, uio) (__VOP(vn, read)(vn, uio))
#define VOP_READLINK(vn, uio) (__VOP(vn, readlink)(vn, uio))
#define VOP_GETDIRENTRY(vn, uio) (__VOP(vn, getdirentry)(vn, uio))
#define VOP_WRITE(vn, uio) (__VOP(vn, write)(vn, uio))
#define VOP_IOCTL(vn, code, buf) (__VOP(vn, ioctl)(vn, code, buf))
#define VOP_STAT(vn, ptr) (__VOP(vn, stat)(vn, ptr))
#define VOP_GETTYPE(vn, result) (__VOP(vn, gettype)(vn, result))
#define VOP_ISSEEKABLE(vn) (__VOP(vn, isseekable)(vn))
#define VOP_FSYNC(vn) (__VOP(vn, fsync)(vn))
#define VOP_MMAP(vn /*add stuff */) (__VOP(vn, mmap)(vn /*add stuff */))
#define VOP_TRUNCATE(vn, pos) (__VOP(vn, truncate)(vn, pos))
#define VOP_NAMEFILE(vn, uio) (__VOP(vn, namefile)(vn, uio))
#define VOP_CREAT(vn,nm,excl,mode,res) (__VOP(vn, creat)(vn,nm,excl,mode,res))
#define VOP_SYMLINK(vn, name, content) (__VOP(vn, symlink)(vn, name, content))
#define VOP_MKDIR(vn, name, mode) (__VOP(vn, mkdir)(vn, name, mode))
#define VOP_LINK(vn, name, vn2) (__VOP(vn, link)(vn, name, vn2))
#define VOP_REMOVE(vn, name) (__VOP(vn, remove)(vn, name))
#define VOP_RMDIR(vn, name) (__VOP(vn, rmdir)(vn, name))
#define VOP_RENAME(vn1,name1,vn2,name2)(__VOP(vn1,rename)(vn1,name1,vn2,name2))
#define VOP_CREAT(vn, nm, excl, mode, res) \
(__VOP(vn, creat)(vn, nm, excl, mode, res))
#define VOP_SYMLINK(vn, name, content) (__VOP(vn, symlink)(vn, name, content))
#define VOP_MKDIR(vn, name, mode) (__VOP(vn, mkdir)(vn, name, mode))
#define VOP_LINK(vn, name, vn2) (__VOP(vn, link)(vn, name, vn2))
#define VOP_REMOVE(vn, name) (__VOP(vn, remove)(vn, name))
#define VOP_RMDIR(vn, name) (__VOP(vn, rmdir)(vn, name))
#define VOP_RENAME(vn1, name1, vn2, name2) \
(__VOP(vn1, rename)(vn1, name1, vn2, name2))
#define VOP_LOOKUP(vn, name, res) (__VOP(vn, lookup)(vn, name, res))
#define VOP_LOOKPARENT(vn,nm,res,bf,ln) (__VOP(vn,lookparent)(vn,nm,res,bf,ln))
#define VOP_LOOKUP(vn, name, res) (__VOP(vn, lookup)(vn, name, res))
#define VOP_LOOKPARENT(vn, nm, res, bf, ln) \
(__VOP(vn, lookparent)(vn, nm, res, bf, ln))
/*
* Consistency check
@@ -263,15 +254,15 @@ void vnode_check(struct vnode *, const char *op);
void vnode_incref(struct vnode *);
void vnode_decref(struct vnode *);
#define VOP_INCREF(vn) vnode_incref(vn)
#define VOP_DECREF(vn) vnode_decref(vn)
#define VOP_INCREF(vn) vnode_incref(vn)
#define VOP_DECREF(vn) vnode_decref(vn)
/*
* Vnode initialization (intended for use by filesystem code)
* The reference count is initialized to 1.
*/
int vnode_init(struct vnode *, const struct vnode_ops *ops,
struct fs *fs, void *fsdata);
int vnode_init(struct vnode *, const struct vnode_ops *ops, struct fs *fs,
void *fsdata);
/*
* Vnode final cleanup (intended for use by filesystem code)
@@ -291,26 +282,24 @@ int vopfail_mmap_perm(struct vnode *vn /* add stuff */);
int vopfail_mmap_nosys(struct vnode *vn /* add stuff */);
int vopfail_truncate_isdir(struct vnode *vn, off_t pos);
int vopfail_creat_notdir(struct vnode *vn, const char *name, bool excl,
mode_t mode, struct vnode **result);
mode_t mode, struct vnode **result);
int vopfail_symlink_notdir(struct vnode *vn, const char *contents,
const char *name);
const char *name);
int vopfail_symlink_nosys(struct vnode *vn, const char *contents,
const char *name);
const char *name);
int vopfail_mkdir_notdir(struct vnode *vn, const char *name, mode_t mode);
int vopfail_mkdir_nosys(struct vnode *vn, const char *name, mode_t mode);
int vopfail_link_notdir(struct vnode *dir, const char *name,
struct vnode *file);
int vopfail_link_nosys(struct vnode *dir, const char *name,
struct vnode *file);
struct vnode *file);
int vopfail_link_nosys(struct vnode *dir, const char *name, struct vnode *file);
int vopfail_string_notdir(struct vnode *vn, const char *name);
int vopfail_string_nosys(struct vnode *vn, const char *name);
int vopfail_rename_notdir(struct vnode *fromdir, const char *fromname,
struct vnode *todir, const char *toname);
struct vnode *todir, const char *toname);
int vopfail_rename_nosys(struct vnode *fromdir, const char *fromname,
struct vnode *todir, const char *toname);
struct vnode *todir, const char *toname);
int vopfail_lookup_notdir(struct vnode *vn, char *path, struct vnode **result);
int vopfail_lookparent_notdir(struct vnode *vn, char *path,
struct vnode **result, char *buf, size_t len);
struct vnode **result, char *buf, size_t len);
#endif /* _VNODE_H_ */

View File

@@ -34,9 +34,8 @@
* Wait channel.
*/
struct spinlock; /* in spinlock.h */
struct wchan; /* Opaque */
struct wchan; /* Opaque */
/*
* Create a wait channel. Use NAME as a symbolic name for the channel.
@@ -76,5 +75,4 @@ void wchan_sleep(struct wchan *wc, struct spinlock *lk);
void wchan_wakeone(struct wchan *wc, struct spinlock *lk);
void wchan_wakeall(struct wchan *wc, struct spinlock *lk);
#endif /* _WCHAN_H_ */