Full switch to clang/ELF. Drop ack. Simplify.

There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
This commit is contained in:
Ben Gras
2012-02-14 14:52:02 +01:00
parent 2487445f5f
commit 2fe8fb192f
5056 changed files with 16204 additions and 133157 deletions
+12
View File
@@ -0,0 +1,12 @@
NOOBJ= # defined
.include <bsd.own.mk>
INCSDIR= /usr/include/minix
INCS+= dirent.h paths.h types.h
.include "${MINIXSRCDIR}/common/include/sys/Makefile.mount.inc"
.include "${MINIXSRCDIR}/common/include/Makefile.termios.inc"
.include <bsd.kinc.mk>
-118
View File
@@ -1,118 +0,0 @@
/* The <a.out> header file describes the format of executable files. */
#ifndef _AOUT_H
#define _AOUT_H
struct exec { /* a.out header */
unsigned char a_magic[2]; /* magic number */
unsigned char a_flags; /* flags, see below */
unsigned char a_cpu; /* cpu id */
unsigned char a_hdrlen; /* length of header */
unsigned char a_unused; /* reserved for future use */
unsigned short a_version; /* version stamp (not used at present) */
long a_text; /* size of text segement in bytes */
long a_data; /* size of data segment in bytes */
long a_bss; /* size of bss segment in bytes */
long a_entry; /* entry point */
long a_total; /* total memory allocated */
long a_syms; /* size of symbol table */
/* SHORT FORM ENDS HERE */
long a_trsize; /* text relocation size */
long a_drsize; /* data relocation size */
long a_tbase; /* text relocation base */
long a_dbase; /* data relocation base */
};
#define A_MAGIC0 (unsigned char) 0x01
#define A_MAGIC1 (unsigned char) 0x03
#define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1)
/* CPU Id of TARGET machine (byte order coded in low order two bits) */
#define A_NONE 0x00 /* unknown */
#define A_I8086 0x04 /* intel i8086/8088 */
#define A_M68K 0x0B /* motorola m68000 */
#define A_NS16K 0x0C /* national semiconductor 16032 */
#define A_I80386 0x10 /* intel i80386 */
#define A_SPARC 0x17 /* Sun SPARC */
#define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
#define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */
/* Flags. */
#define A_UZP 0x01 /* unmapped zero page (pages) */
#define A_PAL 0x02 /* page aligned executable */
#define A_NSYM 0x04 /* new style symbol table */
#define A_IMG 0x08 /* image instead of executable (e.g. root FS) */
#define A_EXEC 0x10 /* executable */
#define A_SEP 0x20 /* separate I/D */
#define A_PURE 0x40 /* pure text */ /* not used */
#define A_TOVLY 0x80 /* text overlay */ /* not used */
/* Offsets of various things. */
#define A_MINHDR 32
#define A_TEXTPOS(X) ((long)(X).a_hdrlen)
#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text)
#define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR)
#define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8))
#define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
#define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
#define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data)
#define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize)
#define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \
((X).a_trsize + (X).a_drsize) : 0))
struct reloc {
long r_vaddr; /* virtual address of reference */
unsigned short r_symndx; /* internal segnum or extern symbol num */
unsigned short r_type; /* relocation type */
};
/* r_type values: */
#define R_ABBS 0
#define R_RELLBYTE 2
#define R_PCRBYTE 3
#define R_RELWORD 4
#define R_PCRWORD 5
#define R_RELLONG 6
#define R_PCRLONG 7
#define R_REL3BYTE 8
#define R_KBRANCHE 9
/* r_symndx for internal segments */
#define S_ABS ((unsigned short)-1)
#define S_TEXT ((unsigned short)-2)
#define S_DATA ((unsigned short)-3)
#define S_BSS ((unsigned short)-4)
struct nlist { /* symbol table entry */
char n_name[8]; /* symbol name */
long n_value; /* value */
unsigned char n_sclass; /* storage class */
unsigned char n_numaux; /* number of auxiliary entries (not used) */
unsigned short n_type; /* language base and derived type (not used) */
};
/* Low bits of storage class (section). */
#define N_SECT 07 /* section mask */
#define N_UNDF 00 /* undefined */
#define N_ABS 01 /* absolute */
#define N_TEXT 02 /* text */
#define N_DATA 03 /* data */
#define N_BSS 04 /* bss */
#define N_COMM 05 /* (common) */
/* High bits of storage class. */
#define N_CLASS 0370 /* storage class mask */
#define C_NULL
#define C_EXT 0020 /* external symbol */
#define C_STAT 0030 /* static */
/* Function prototypes. */
#ifndef _MINIX_ANSI_H
#include <minix/ansi.h>
#endif
_PROTOTYPE( int nlist, (char *_file, struct nlist *_nl) );
#endif /* _AOUT_H */
+44
View File
@@ -0,0 +1,44 @@
#include <minix/types.h>
#include <minix/ipc.h>
#define ACPI_REQ_GET_IRQ 1
#define ACPI_REQ_MAP_BRIDGE 2
struct acpi_request_hdr {
endpoint_t m_source; /* message header */
u32_t request;
};
/*
* Message to request dev/pin translation to IRQ by acpi using the acpi routing
* tables
*/
struct acpi_get_irq_req {
struct acpi_request_hdr hdr;
u32_t bus;
u32_t dev;
u32_t pin;
u32_t __padding[4];
};
/* response from acpi to acpi_get_irq_req */
struct acpi_get_irq_resp {
endpoint_t m_source; /* message header */
i32_t irq;
u32_t __padding[7];
};
/* message format for pci bridge mappings to acpi */
struct acpi_map_bridge_req {
struct acpi_request_hdr hdr;
u32_t primary_bus;
u32_t secondary_bus;
u32_t device;
u32_t __padding[4];
};
struct acpi_map_bridge_resp {
endpoint_t m_source; /* message header */
int err;
u32_t __padding[7];
};
+86
View File
@@ -0,0 +1,86 @@
/* The <minix/ansi.h> header attempts to decide whether the compiler has enough
* conformance to Standard C for Minix to take advantage of. If so, the
* symbol _ANSI is defined (as 31459). Otherwise _ANSI is not defined
* here, but it may be defined by applications that want to bend the rules.
* The magic number in the definition is to inhibit unnecessary bending
* of the rules. (For consistency with the new '#ifdef _ANSI" tests in
* the headers, _ANSI should really be defined as nothing, but that would
* break many library routines that use "#if _ANSI".)
* If _ANSI ends up being defined, a macro
*
* _PROTOTYPE(function, params)
*
* is defined. This macro expands in different ways, generating either
* ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie)
* prototypes, as needed. Finally, some programs use _CONST, _VOIDSTAR etc
* in such a way that they are portable over both ANSI and K&R compilers.
* The appropriate macros are defined here.
*/
#ifndef _MINIX_ANSI_H
#define _MINIX_ANSI_H
#if __STDC__ == 1
#define _ANSI 31459 /* compiler claims full ANSI conformance */
#endif
#ifdef __GNUC__
#define _ANSI 31459 /* gcc conforms enough even in non-ANSI mode */
#endif
#define _VOIDSTAR void *
#define _VOID void
#ifdef _ANSI
/* Keep everything for ANSI prototypes. */
#define _PROTOTYPE(function, params) function params
#define _ARGS(params) params
#define _CONST const
#define _VOLATILE volatile
#define _SIZET size_t
#else
/* Throw away the parameters for K&R prototypes. */
#define _PROTOTYPE(function, params) function()
#define _ARGS(params) ()
#define _CONST
#define _VOLATILE
#define _SIZET int
#endif /* _ANSI */
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
#define __LONG_LONG_SUPPORTED 1
#endif
/* This should be defined as restrict when a C99 compiler is used. */
#define _RESTRICT
#ifdef __NBSD_LIBC
/* Setting of _POSIX_SOURCE (or _NETBSD_SOURCE) in NBSD headers is
* done in <sys/featuretest.h> */
#include <sys/featuretest.h>
/* Also, do not redefine _BSD_VA_LIST */
#else /* !__NBSD_LIBC */
/* Setting any of _MINIX, _POSIX_C_SOURCE or _POSIX2_SOURCE implies
* _POSIX_SOURCE. (Seems wrong to put this here in ANSI space.)
*/
#if defined(_MINIX) || _POSIX_C_SOURCE > 0 || defined(_POSIX2_SOURCE)
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#endif
/* What is a va_list? */
#include <stdarg.h>
#define _BSD_VA_LIST_ va_list
#endif /* !__NBSD_LIBC */
#endif /* _MINIX_ANSI_H */
+90
View File
@@ -0,0 +1,90 @@
#ifndef AUDIO_FW_H
#define AUDIO_FW_H
#include <minix/drivers.h>
#include <minix/chardriver.h>
#include <sys/ioc_sound.h>
_PROTOTYPE( int drv_init, (void) );
_PROTOTYPE( int drv_init_hw, (void) );
_PROTOTYPE( int drv_reset, (void) );
_PROTOTYPE( int drv_start, (int sub_dev, int DmaMode) );
_PROTOTYPE( int drv_stop, (int sub_dev) );
_PROTOTYPE( int drv_set_dma, (u32_t dma, u32_t length, int chan) );
_PROTOTYPE( int drv_reenable_int, (int chan) );
_PROTOTYPE( int drv_int_sum, (void) );
_PROTOTYPE( int drv_int, (int sub_dev) );
_PROTOTYPE( int drv_pause, (int chan) );
_PROTOTYPE( int drv_resume, (int chan) );
_PROTOTYPE( int drv_io_ctl, (int request, void * val, int * len, int sub_dev) );
_PROTOTYPE( int drv_get_irq, (char *irq) );
_PROTOTYPE( int drv_get_frag_size, (u32_t *frag_size, int sub_dev) );
/* runtime status fields */
typedef struct {
int readable;
int writable;
int DmaSize;
int NrOfDmaFragments;
int MinFragmentSize;
int NrOfExtraBuffers;
int Nr; /* sub device number */
int Opened; /* sub device opened */
int DmaBusy; /* is dma busy? */
int DmaMode; /* DEV_WRITE / DEV_READ */
int DmaReadNext; /* current dma buffer */
int DmaFillNext; /* next dma buffer to fill */
int DmaLength;
int BufReadNext; /* start of extra circular buffer */
int BufFillNext; /* end of extra circular buffer */
int BufLength;
int RevivePending; /* process waiting for this dev? */
int ReviveStatus; /* return val when proc unblocked */
endpoint_t ReviveProcNr; /* the process to unblock */
cp_grant_id_t ReviveGrant; /* grant id associated with io */
void *UserBuf; /* address of user's data buffer */
int ReadyToRevive; /* are we ready to revive process?*/
endpoint_t SourceProcNr; /* process to send notify to (FS) */
u32_t FragSize; /* dma fragment size */
char *DmaBuf; /* the dma buffer; extra space for
page alignment */
phys_bytes DmaPhys; /* physical address of dma buffer */
char* DmaPtr; /* pointer to aligned dma buffer */
int OutOfData; /* all buffers empty? */
char *ExtraBuf; /* don't use extra buffer;just
declare a pointer to supress
error messages */
} sub_dev_t;
typedef struct {
int minor_dev_nr;
int read_chan;
int write_chan;
int io_ctl;
} special_file_t;
typedef struct {
char* DriverName;
int NrOfSubDevices;
int NrOfSpecialFiles;
} drv_t;
EXTERN drv_t drv;
EXTERN sub_dev_t sub_dev[];
EXTERN special_file_t special_file[];
/* Number of bytes you can DMA before hitting a 64K boundary: */
#define dma_bytes_left(phys) \
((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
#define NO_CHANNEL -1
#define TRUE 1
#define FALSE 0
#define NO_DMA 0
#endif /* AUDIO_FW_H */
+45
View File
@@ -0,0 +1,45 @@
#ifndef _MINIX_BDEV_H
#define _MINIX_BDEV_H
/* Common API. */
extern void bdev_driver(dev_t dev, char *label);
/* Synchronous API. */
extern int bdev_open(dev_t dev, int access);
extern int bdev_close(dev_t dev);
extern ssize_t bdev_read(dev_t dev, u64_t pos, char *buf, size_t count,
int flags);
extern ssize_t bdev_write(dev_t dev, u64_t pos, char *buf, size_t count,
int flags);
extern ssize_t bdev_gather(dev_t dev, u64_t pos, iovec_t *vec, int count,
int flags);
extern ssize_t bdev_scatter(dev_t dev, u64_t pos, iovec_t *vec, int count,
int flags);
extern int bdev_ioctl(dev_t dev, int request, void *buf);
/* Asynchronous API. */
typedef int bdev_id_t;
typedef void *bdev_param_t;
typedef void (*bdev_callback_t)(dev_t dev, bdev_id_t id, bdev_param_t param,
int result);
extern void bdev_flush_asyn(dev_t dev);
extern bdev_id_t bdev_read_asyn(dev_t dev, u64_t pos, char *buf, size_t count,
int flags, bdev_callback_t callback, bdev_param_t param);
extern bdev_id_t bdev_write_asyn(dev_t dev, u64_t pos, char *buf, size_t count,
int flags, bdev_callback_t callback, bdev_param_t param);
extern bdev_id_t bdev_gather_asyn(dev_t dev, u64_t pos, iovec_t *vec,
int count, int flags, bdev_callback_t callback, bdev_param_t param);
extern bdev_id_t bdev_scatter_asyn(dev_t dev, u64_t pos, iovec_t *vec,
int count, int flags, bdev_callback_t callback, bdev_param_t param);
extern bdev_id_t bdev_ioctl_asyn(dev_t dev, int request, void *buf,
bdev_callback_t callback, bdev_param_t param);
extern int bdev_wait_asyn(bdev_id_t id);
extern void bdev_reply_asyn(message *m);
#endif /* _MINIX_BDEV_H */
+34
View File
@@ -0,0 +1,34 @@
#ifndef _BITMAP_H
#define _BITMAP_H
/* Bit map operations to manipulate bits of a simple mask variable. */
#define bit_set(mask, n) ((mask) |= (1 << (n)))
#define bit_unset(mask, n) ((mask) &= ~(1 << (n)))
#define bit_isset(mask, n) ((mask) & (1 << (n)))
#define bit_empty(mask) ((mask) = 0)
#define bit_fill(mask) ((mask) = ~0)
/* Definitions previously in kernel/const.h */
#define BITCHUNK_BITS (sizeof(bitchunk_t) * CHAR_BIT)
#define BITMAP_CHUNKS(nr_bits) (((nr_bits)+BITCHUNK_BITS-1)/BITCHUNK_BITS)
#define MAP_CHUNK(map,bit) (map)[((bit)/BITCHUNK_BITS)]
#define CHUNK_OFFSET(bit) ((bit)%BITCHUNK_BITS)
#define GET_BIT(map,bit) ( MAP_CHUNK(map,bit) & (1 << CHUNK_OFFSET(bit) ))
#define SET_BIT(map,bit) ( MAP_CHUNK(map,bit) |= (1 << CHUNK_OFFSET(bit) ))
#define UNSET_BIT(map,bit) ( MAP_CHUNK(map,bit) &= ~(1 << CHUNK_OFFSET(bit) ))
#if defined(CONFIG_SMP) && defined(__GNUC__)
#ifndef __ASSEMBLY__
static inline bits_fill(bitchunk_t * chunks, unsigned bits)
{
unsigned c, cnt;
cnt = BITMAP_CHUNKS(bits);
for (c = 0; c < cnt; c++)
bit_fill(chunks[c]);
}
#endif
#endif
#endif /* _BITMAP_H */
+62
View File
@@ -0,0 +1,62 @@
#ifndef _MINIX_BLOCKDRIVER_H
#define _MINIX_BLOCKDRIVER_H
#include <minix/driver.h>
typedef int device_id_t;
typedef int thread_id_t;
/* Types supported for the 'type' field of struct blockdriver. */
typedef enum {
BLOCKDRIVER_TYPE_DISK, /* handle partition requests */
BLOCKDRIVER_TYPE_OTHER /* do not handle partition requests */
} blockdriver_type_t;
/* Entry points into the device dependent code of block drivers. */
struct blockdriver {
blockdriver_type_t bdr_type;
_PROTOTYPE( int (*bdr_open), (dev_t minor, int access) );
_PROTOTYPE( int (*bdr_close), (dev_t minor) );
_PROTOTYPE( ssize_t (*bdr_transfer), (dev_t minor, int do_write, u64_t pos,
endpoint_t endpt, iovec_t *iov, unsigned count, int flags) );
_PROTOTYPE( int (*bdr_ioctl), (dev_t minor, unsigned int request,
endpoint_t endpt, cp_grant_id_t grant) );
_PROTOTYPE( void (*bdr_cleanup), (void) );
_PROTOTYPE( struct device *(*bdr_part), (dev_t minor) );
_PROTOTYPE( void (*bdr_geometry), (dev_t minor, struct partition *part) );
_PROTOTYPE( void (*bdr_intr), (unsigned int irqs) );
_PROTOTYPE( void (*bdr_alarm), (clock_t stamp) );
_PROTOTYPE( int (*bdr_other), (message *m_ptr) );
_PROTOTYPE( int (*bdr_device), (dev_t minor, device_id_t *id) );
};
/* Functions defined by libblockdriver. These can be used for both
* singlethreaded and multithreaded drivers.
*/
_PROTOTYPE( void blockdriver_announce, (int type) );
#ifndef _BLOCKDRIVER_MT_API
/* Additional functions for the singlethreaded version. These allow the driver
* to either use the stock driver_task(), or implement its own message loop.
* To avoid accidents, these functions are not exposed when minix/driver_mt.h
* has been included previously.
*/
_PROTOTYPE( int blockdriver_receive_mq, (message *m_ptr, int *status_ptr) );
_PROTOTYPE( void blockdriver_process, (struct blockdriver *dp, message *m_ptr,
int ipc_status) );
_PROTOTYPE( void blockdriver_terminate, (void) );
_PROTOTYPE( void blockdriver_task, (struct blockdriver *bdp) );
_PROTOTYPE( int blockdriver_mq_queue, (message *m_ptr, int status) );
#endif /* !_BLOCKDRIVER_MT_API */
/* Parameters for the disk drive. */
#define SECTOR_SIZE 512 /* physical sector size in bytes */
#define SECTOR_SHIFT 9 /* for division */
#define SECTOR_MASK 511 /* and remainder */
#define CD_SECTOR_SIZE 2048 /* sector size of a CD-ROM in bytes */
/* Size of the DMA buffer buffer in bytes. */
#define DMA_BUF_SIZE (DMA_SECTORS * SECTOR_SIZE)
#endif /* _MINIX_BLOCKDRIVER_H */
+14
View File
@@ -0,0 +1,14 @@
#ifndef _MINIX_BLOCKDRIVER_MT_H
#define _MINIX_BLOCKDRIVER_MT_H
#define BLOCKDRIVER_MT_API 1 /* do not expose the singlethreaded API */
#include <minix/blockdriver.h>
_PROTOTYPE( void blockdriver_mt_task, (struct blockdriver *driver_tab) );
_PROTOTYPE( void blockdriver_mt_sleep, (void) );
_PROTOTYPE( void blockdriver_mt_wakeup, (thread_id_t id) );
_PROTOTYPE( void blockdriver_mt_terminate, (void) );
_PROTOTYPE( void blockdriver_mt_set_workers, (device_id_t id, int workers) );
_PROTOTYPE( thread_id_t blockdriver_mt_get_tid, (void) );
#endif /* _MINIX_BLOCKDRIVER_MT_H */
+40
View File
@@ -0,0 +1,40 @@
#ifndef _MINIX_BTRACE_H
#define _MINIX_BTRACE_H
/* Control directives. */
enum {
BTCTL_START,
BTCTL_STOP
};
/* Request codes. */
enum {
BTREQ_OPEN,
BTREQ_CLOSE,
BTREQ_READ,
BTREQ_WRITE,
BTREQ_GATHER,
BTREQ_SCATTER,
BTREQ_IOCTL
};
/* Special result codes. */
#define BTRES_INPROGRESS (-997)
/* Block trace entry. */
typedef struct {
u32_t request; /* request code; one of BTR_xxx */
u32_t size; /* request size, ioctl request, or access */
u64_t position; /* starting disk position */
u32_t flags; /* transfer flags */
i32_t result; /* request result; OK, bytes, or error */
u32_t start_time; /* request service start time (us) */
u32_t finish_time; /* request service completion time (us) */
} btrace_entry; /* (32 bytes) */
/* This is the number of btrace_entry structures copied out at once using the
* BIOCTRACEGET ioctl call.
*/
#define BTBUF_SIZE 1024
#endif /* _MINIX_BTRACE_H */
+117
View File
@@ -0,0 +1,117 @@
#define NCALLS 114 /* number of system calls allowed */
/* In case it isn't obvious enough: this list is sorted numerically. */
#define EXIT 1
#define FORK 2
#define READ 3
#define WRITE 4
#define OPEN 5
#define CLOSE 6
#define WAIT 7
#define CREAT 8
#define LINK 9
#define UNLINK 10
#define WAITPID 11
#define CHDIR 12
#define TIME 13
#define MKNOD 14
#define CHMOD 15
#define CHOWN 16
#define BRK 17
#define PREV_STAT 18
#define LSEEK 19
#define MINIX_GETPID 20
#define MOUNT 21
#define UMOUNT 22
#define SETUID 23
#define GETUID 24
#define STIME 25
#define PTRACE 26
#define ALARM 27
#define PREV_FSTAT 28
#define PAUSE 29
#define UTIME 30
#define GETEPINFO 31
#define SETGROUPS 32
#define ACCESS 33
#define GETGROUPS 34
#define SYNC 36
#define KILL 37
#define RENAME 38
#define MKDIR 39
#define RMDIR 40
#define DUP 41
#define PIPE 42
#define TIMES 43
#define SYMLINK 45
#define SETGID 46
#define GETGID 47
#define SIGNAL 48
#define RDLNK 49
#define PREV_LSTAT 50
#define STAT 51
#define FSTAT 52
#define LSTAT 53
#define IOCTL 54
#define FCNTL 55
#define FS_READY 57
#define EXEC 59
#define UMASK 60
#define CHROOT 61
#define SETSID 62
#define GETPGRP 63
#define ITIMER 64
#define GETGROUPS_O 65
#define SETGROUPS_O 66
#define GETMCONTEXT 67
#define SETMCONTEXT 68
/* Posix signal handling. */
#define SIGACTION 71
#define SIGSUSPEND 72
#define SIGPENDING 73
#define SIGPROCMASK 74
#define SIGRETURN 75
#define REBOOT 76
#define SVRCTL 77
#define SYSUNAME 78
#define GETDENTS 80 /* to VFS */
#define LLSEEK 81 /* to VFS */
#define FSTATFS 82 /* to VFS */
#define STATVFS 83 /* to VFS */
#define FSTATVFS 84 /* to VFS */
#define SELECT 85 /* to VFS */
#define FCHDIR 86 /* to VFS */
#define FSYNC 87 /* to VFS */
#define GETPRIORITY 88 /* to PM */
#define SETPRIORITY 89 /* to PM */
#define GETTIMEOFDAY 90 /* to PM */
#define SETEUID 91 /* to PM */
#define SETEGID 92 /* to PM */
#define TRUNCATE 93 /* to VFS */
#define FTRUNCATE 94 /* to VFS */
#define FCHMOD 95 /* to VFS */
#define FCHOWN 96 /* to VFS */
#define SPROF 98 /* to PM */
#define CPROF 99 /* to PM */
/* Calls provided by PM and FS that are not part of the API */
#define EXEC_NEWMEM 100 /* from VFS or RS to PM: new memory map for
* exec
*/
#define SRV_FORK 101 /* to PM: special fork call for RS */
#define EXEC_RESTART 102 /* to PM: final part of exec for RS */
#define GETPROCNR 104 /* to PM */
#define ISSETUGID 106 /* to PM: ask if process is tainted */
#define GETEPINFO_O 107 /* to PM: get pid/uid/gid of an endpoint */
#define SRV_KILL 111 /* to PM: special kill call for RS */
#define GCOV_FLUSH 112 /* flush gcov data from server to gcov files */
#define PM_GETSID 113 /* PM getsid() */
#define TASK_REPLY 121 /* to VFS: reply code from drivers, not
* really a standalone call.
*/
#define MAPDRIVER 122 /* to VFS, map a device */
-39
View File
@@ -1,39 +0,0 @@
/* This file contains some structures used by the Mitsumi cdrom driver.
*
* Feb 13 1995 Author: Michel R. Prevenier
*/
/* Index into the mss arrays */
#define MINUTES 0
#define SECONDS 1
#define SECTOR 2
struct cd_play_mss
{
u8_t begin_mss[3];
u8_t end_mss[3];
};
struct cd_play_track
{
u8_t begin_track;
u8_t end_track;
};
struct cd_disk_info
{
u8_t first_track;
u8_t last_track;
u8_t disk_length_mss[3];
u8_t first_track_mss[3];
};
struct cd_toc_entry
{
u8_t control_address;
u8_t track_nr;
u8_t index_nr;
u8_t track_time_mss[3];
u8_t reserved;
u8_t position_mss[3];
};
+41
View File
@@ -0,0 +1,41 @@
#ifndef _MINIX_CHARDRIVER_H
#define _MINIX_CHARDRIVER_H
#include <minix/driver.h>
/* Entry points into the device dependent code of character drivers. */
struct chardriver {
_PROTOTYPE( int (*cdr_open), (message *m_ptr) );
_PROTOTYPE( int (*cdr_close), (message *m_ptr) );
_PROTOTYPE( int (*cdr_ioctl), (message *m_ptr) );
_PROTOTYPE( struct device *(*cdr_prepare), (dev_t device) );
_PROTOTYPE( int (*cdr_transfer), (endpoint_t endpt, int opcode,
u64_t position, iovec_t *iov, unsigned int nr_req,
endpoint_t user_endpt) );
_PROTOTYPE( void (*cdr_cleanup), (void) );
_PROTOTYPE( void (*cdr_alarm), (message *m_ptr) );
_PROTOTYPE( int (*cdr_cancel), (message *m_ptr) );
_PROTOTYPE( int (*cdr_select), (message *m_ptr) );
_PROTOTYPE( int (*cdr_other), (message *m_ptr) );
};
#define CHARDRIVER_SYNC 0 /* use the synchronous protocol */
#define CHARDRIVER_ASYNC 1 /* use the asynchronous protocol */
#define IS_CDEV_MINOR_RQ(type) (IS_DEV_RQ(type) && (type) != DEV_STATUS)
/* Functions defined by libchardriver. */
_PROTOTYPE( void chardriver_announce, (void) );
_PROTOTYPE( void chardriver_process, (struct chardriver *cdp, int driver_type,
message *m_ptr, int ipc_status) );
_PROTOTYPE( void chardriver_terminate, (void) );
_PROTOTYPE( void chardriver_task, (struct chardriver *cdp, int driver_type) );
_PROTOTYPE( int do_nop, (message *m_ptr) );
_PROTOTYPE( void nop_cleanup, (void) );
_PROTOTYPE( void nop_alarm, (message *m_ptr) );
_PROTOTYPE( int nop_cancel, (message *m_ptr) );
_PROTOTYPE( int nop_select, (message *m_ptr) );
_PROTOTYPE( int nop_ioctl, (message *m_ptr) );
#endif /* _MINIX_CHARDRIVER_H */
+1263
View File
File diff suppressed because it is too large Load Diff
-20
View File
@@ -1,20 +0,0 @@
/* Definitions for ACK-specific features. */
#ifndef _MINIX_COMPILER_ACK_H
#define _MINIX_COMPILER_ACK_H
/* ACK expects the caller to pop the hidden pointer on struct return. */
#define BYTES_TO_POP_ON_STRUCT_RETURN
/*
* ACK doesn't move the last argument of a variadic arguments function
* anywhere, once it's on the stack as a function parameter. Thus, it is
* possible to make strong assumption on the immutability of the stack
* layout and use the address of that argument as the start of an array.
*
* If you're curious, just look at lib/libc/posix/_execl*.c ;-)
*/
#define FUNC_ARGS_ARRAY 1
#endif /* _MINIX_COMPILER_ACK_H */
+49
View File
@@ -0,0 +1,49 @@
/* Definitions for compiler-specific features. */
#ifndef _MINIX_COMPILER_H
#define _MINIX_COMPILER_H
/*===========================================================================*
* Compiler overrides *
*===========================================================================*/
/* ACK */
#ifdef __ACK__
#include <minix/compiler-ack.h>
#endif
/*===========================================================================*
* Default values *
*===========================================================================*/
/*
* cdecl calling convention expects the callee to pop the hidden pointer on
* struct return. For example, GCC and LLVM comply with this (tested on IA32).
*/
#ifndef BYTES_TO_POP_ON_STRUCT_RETURN
#define BYTES_TO_POP_ON_STRUCT_RETURN $4
#endif
/*
* cdecl calling convention requires to push arguments on the stack in a
* reverse order to easily support variadic arguments. Thus, instead of
* using the proper stdarg.h macros (that nowadays are
* compiler-dependant), it may be tempting to directly take the address of
* the last argument and considering it as the start of an array. This is
* a shortcut that avoid looping to get all the arguments as the CPU
* already pushed them on the stack before the call to the function.
*
* Unfortunately, such an assumption is strictly compiler-dependant and
* compilers are free to move the last argument on the stack, as a local
* variable, and return the address of the location where the argument was
* stored, if asked for. This will break things as the rest of the array's
* argument are stored elsewhere (typically, a couple of words above the
* location where the argument was stored).
*
* Conclusion: if unsure on what the compiler may do, do not make any
* assumption and use the right (typically compiler-dependant) macros.
*/
#ifndef FUNC_ARGS_ARRAY
#define FUNC_ARGS_ARRAY 0
#endif
#endif /* _MINIX_COMPILER_H */
+114
View File
@@ -0,0 +1,114 @@
#ifndef _CONFIG_H
#define _CONFIG_H
/* Minix release and version numbers. */
#define OS_RELEASE "3"
#define OS_VERSION "2.0"
/* This file sets configuration parameters for the MINIX kernel, FS, and PM.
* It is divided up into two main sections. The first section contains
* user-settable parameters. In the second section, various internal system
* parameters are set based on the user-settable parameters.
*
* Parts of config.h have been moved to sys_config.h, which can be included
* by other include files that wish to get at the configuration data, but
* don't want to pollute the users namespace. Some editable values have
* gone there.
*
*/
/* The MACHINE (called _MINIX_MACHINE) setting can be done
* in <minix/machine.h>.
*/
#include <minix/sys_config.h>
#define MACHINE _MINIX_MACHINE
#define IBM_PC _MACHINE_IBM_PC
/* Number of slots in the process table for non-kernel processes. The number
* of system processes defines how many processes with special privileges
* there can be. User processes share the same properties and count for one.
*
* These can be changed in sys_config.h.
*/
#define NR_PROCS _NR_PROCS
#define NR_SYS_PROCS _NR_SYS_PROCS
#define NR_SYS_CHUNKS BITMAP_CHUNKS(NR_SYS_PROCS)
/* Number of controller tasks (/dev/cN device classes). */
#define NR_CTRLRS 2
/* DMA_SECTORS may be increased to speed up DMA based drivers. */
#define DMA_SECTORS 1 /* DMA buffer size (must be >= 1) */
/* Which processes should receive diagnostics from the kernel and system?
* Directly sending it to TTY only displays the output. Sending it to the
* log driver will cause the diagnostics to be buffered and displayed.
* Messages are sent by src/lib/sysutil/kputc.c to these processes, in
* the order of this array, which must be terminated by NONE. This is used
* by drivers and servers that printf().
* The kernel does this for its own kprintf() in kernel/utility.c, also using
* this array, but a slightly different mechanism.
*/
#define OUTPUT_PROCS_ARRAY { TTY_PROC_NR, LOG_PROC_NR, NONE }
/* NR_CONS, NR_RS_LINES, and NR_PTYS determine the number of terminals the
* system can handle.
*/
#define NR_CONS 4 /* # system consoles (1 to 8) */
#define NR_RS_LINES 4 /* # rs232 terminals (0 to 4) */
#define NR_PTYS 32 /* # pseudo terminals (0 to 64) */
/* This feature enable the counting of system calls in PM and FS */
#define ENABLE_SYSCALL_STATS 0
/* Max. number of I/O ranges that can be assigned to a process */
#define NR_IO_RANGE 64
/* Max. number of device memory ranges that can be assigned to a process */
#define NR_MEM_RANGE 20
/* Max. number of IRQs that can be assigned to a process */
#define NR_IRQ 8
/* Scheduling priorities. Values must start at zero (highest
* priority) and increment.
*/
#define NR_SCHED_QUEUES 16 /* MUST equal minimum priority + 1 */
#define TASK_Q 0 /* highest, used for kernel tasks */
#define MAX_USER_Q 0 /* highest priority for user processes */
#define USER_Q ((MIN_USER_Q - MAX_USER_Q) / 2 + MAX_USER_Q) /* default
(should correspond to nice 0) */
#define MIN_USER_Q (NR_SCHED_QUEUES - 1) /* minimum priority for user
processes */
/* default scheduling quanta */
#define USER_QUANTUM 200
/* defualt user process cpu */
#define USER_DEFAULT_CPU -1 /* use the default cpu or do not change the
current one */
/*===========================================================================*
* There are no user-settable parameters after this line *
*===========================================================================*/
/* Set the FP_FORMAT type based on the machine selected, either hw or sw */
#define FP_NONE _FP_NONE /* no floating point support */
#define FP_IEEE _FP_IEEE /* conform IEEE floating point standard */
/* _MINIX_FP_FORMAT is defined in sys_config.h. */
#define FP_FORMAT _MINIX_FP_FORMAT
/* _ASKDEV and _FASTLOAD are defined in sys_config.h. */
#define ASKDEV _ASKDEV
#define FASTLOAD _FASTLOAD
/* Enable or disable system profiling. */
#define SPROFILE 0 /* statistical profiling */
#define CPROFILE 0 /* call profiling */
/* PCI configuration parameters */
#define NR_PCIBUS 40
#define NR_PCIDEV 50
#endif /* _CONFIG_H */
+192
View File
@@ -0,0 +1,192 @@
#ifndef _MINIX_CONST_H
#define _MINIX_CONST_H
#ifndef _MINIX_CHIP
#error _MINIX_CHIP is not defined
#endif
/* The UNUSED annotation tells the compiler or lint not to complain
* about an unused variable or function parameter.
*
* A number of different annotations are used, depending on the
* compiler or checker that is looking at the code.
*
* Note that some variants rename the parameter, so if you use
* the parameter after all, you'll get a complaint about a missing
* variable.
*
* You use it like this:
*
* void foo(int UNUSED(x)){}
*/
#ifndef UNUSED
#if defined _lint
# define UNUSED(v) /*lint -e(715,818)*/ v
#elif defined(__GNUC__)
# define UNUSED(v) UNUSED_ ## v __attribute((unused))
#elif defined __LCLINT__
# define UNUSED(v) /*@unused@*/ v
#else
# define UNUSED(v) _UNUSED_ ## v
#endif
#endif
#define EXTERN extern /* used in *.h files */
#define PRIVATE static /* PRIVATE x limits the scope of x */
#define PUBLIC /* PUBLIC is the opposite of PRIVATE */
#define FORWARD static /* some compilers require this to be 'static'*/
#define TRUE 1 /* used for turning integers into Booleans */
#define FALSE 0 /* used for turning integers into Booleans */
#define DEFAULT_HZ 60 /* clock freq (software settable on IBM-PC) */
#define SUPER_USER ((uid_t) 0) /* uid_t of superuser */
#include <sys/null.h> /* NULL Pointer */
#define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY* request */
#define NR_IOREQS 64
/* maximum number of entries in an iorequest */
/* Message passing constants. */
#define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */
/* Memory related constants. */
#define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */
#define SEGMENT_INDEX 0x00FF /* bit mask to get segment index */
#define LOCAL_SEG 0x0000 /* flags indicating local memory segment */
#define NR_LOCAL_SEGS 3 /* # local segments per process (fixed) */
#define T 0 /* proc[i].mem_map[T] is for text */
#define D 1 /* proc[i].mem_map[D] is for data */
#define S 2 /* proc[i].mem_map[S] is for stack */
#define BIOS_SEG 0x0200 /* flags indicating BIOS memory segment */
#define PHYS_SEG 0x0400 /* flag indicating entire physical memory */
#define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */
#define VM_D (LOCAL_VM_SEG | D)
#define VM_T (LOCAL_VM_SEG | T)
#define MEM_GRANT 3
#define VM_GRANT (LOCAL_VM_SEG | MEM_GRANT)
/* Labels used to disable code sections for different reasons. */
#define DEAD_CODE 0 /* unused code in normal configuration */
#define FUTURE_CODE 0 /* new code to be activated + tested later */
#define TEMP_CODE 1 /* active code to be removed later */
/* Process name length in the PM process table, including '\0'. */
#define PROC_NAME_LEN 16
/* Miscellaneous */
#define BYTE 0377 /* mask for 8 bits */
#define READING 0 /* copy data to user */
#define WRITING 1 /* copy data from user */
#define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */
/* Memory is allocated in clicks. */
#if (_MINIX_CHIP == _CHIP_INTEL)
#define CLICK_SIZE 4096 /* unit in which memory is allocated */
#define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */
#else
#error No reasonable CHIP setting.
#endif
/* Click alignment macros. */
#define CLICK_FLOOR(n) (((vir_bytes)(n) / CLICK_SIZE) * CLICK_SIZE)
#define CLICK_CEIL(n) CLICK_FLOOR((vir_bytes)(n) + CLICK_SIZE-1)
/* Sizes of memory tables. The boot monitor distinguishes three memory areas,
* namely low mem below 1M, 1M-16M, and mem after 16M. More chunks are needed
* for DOS MINIX.
*/
#define NR_MEMS 16
/* Click to byte conversions (and vice versa). */
#define HCLICK_SHIFT 4 /* log2 of HCLICK_SIZE */
#define HCLICK_SIZE 16 /* hardware segment conversion magic */
#if CLICK_SIZE >= HCLICK_SIZE
#define click_to_hclick(n) ((n) << (CLICK_SHIFT - HCLICK_SHIFT))
#else
#define click_to_hclick(n) ((n) >> (HCLICK_SHIFT - CLICK_SHIFT))
#endif
#define hclick_to_physb(n) ((phys_bytes) (n) << HCLICK_SHIFT)
#define physb_to_hclick(n) ((n) >> HCLICK_SHIFT)
#define CLICK2ABS(v) ((v) << CLICK_SHIFT)
#define ABS2CLICK(a) ((a) >> CLICK_SHIFT)
#define ABS -999 /* this process means absolute memory */
/* Flag bits for i_mode in the inode. */
#define I_TYPE 0170000 /* this field gives inode type */
#define I_UNIX_SOCKET 0140000 /* unix domain socket */
#define I_SYMBOLIC_LINK 0120000 /* file is a symbolic link */
#define I_REGULAR 0100000 /* regular file, not dir or special */
#define I_BLOCK_SPECIAL 0060000 /* block special file */
#define I_DIRECTORY 0040000 /* file is a directory */
#define I_CHAR_SPECIAL 0020000 /* character special file */
#define I_NAMED_PIPE 0010000 /* named pipe (FIFO) */
#define I_SET_UID_BIT 0004000 /* set effective uid_t on exec */
#define I_SET_GID_BIT 0002000 /* set effective gid_t on exec */
#define I_SET_STCKY_BIT 0001000 /* sticky bit */
#define ALL_MODES 0007777 /* all bits for user, group and others */
#define RWX_MODES 0000777 /* mode bits for RWX only */
#define R_BIT 0000004 /* Rwx protection bit */
#define W_BIT 0000002 /* rWx protection bit */
#define X_BIT 0000001 /* rwX protection bit */
#define I_NOT_ALLOC 0000000 /* this inode is free */
/* Some limits. */
#define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */
#define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */
#define UMAX_FILE_POS ((unsigned) 0x7FFFFFFF) /* largest legal file offset */
#define MAX_SYM_LOOPS 8 /* how many symbolic links are recursed */
#define NO_BLOCK ((block_t) 0) /* absence of a block number */
#define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */
#define NO_ZONE ((zone_t) 0) /* absence of a zone number */
#define NO_DEV ((dev_t) 0) /* absence of a device numb */
#define NO_LINK ((nlink_t) 0) /* absence of incoming links */
#define INVAL_UID ((uid_t) -1) /* invalid uid value */
#define INVAL_GID ((gid_t) -1) /* invalid gid value */
#define SERVARNAME "cttyline"
#define SERBAUDVARNAME "cttybaud"
/* Bits for the system property flags in boot image processes. */
#define PROC_FULLVM 0x100 /* VM sets and manages full pagetable */
/* Bits for s_flags in the privilege structure. */
#define PREEMPTIBLE 0x002 /* kernel tasks are not preemptible */
#define BILLABLE 0x004 /* some processes are not billable */
#define DYN_PRIV_ID 0x008 /* privilege id assigned dynamically */
#define SYS_PROC 0x010 /* system processes have own priv structure */
#define CHECK_IO_PORT 0x020 /* check if I/O request is allowed */
#define CHECK_IRQ 0x040 /* check if IRQ can be used */
#define CHECK_MEM 0x080 /* check if (VM) mem map request is allowed */
#define ROOT_SYS_PROC 0x100 /* this is a root system process instance */
#define VM_SYS_PROC 0x200 /* this is a vm system process instance */
#define LU_SYS_PROC 0x400 /* this is a live updated sys proc instance */
#define RST_SYS_PROC 0x800 /* this is a restarted sys proc instance */
/* Bits for device driver flags managed by RS and VFS. */
#define DRV_FORCED 0x01 /* driver is mapped even if not alive yet */
/* Values for the "verbose" boot monitor variable */
#define VERBOSEBOOT_QUIET 0
#define VERBOSEBOOT_BASIC 1
#define VERBOSEBOOT_EXTRA 2
#define VERBOSEBOOT_MAX 3
#define VERBOSEBOOTVARNAME "verbose"
/* magic value to put in struct proc entries for sanity checks. */
#define PMAGIC 0xC0FFEE1
#endif /* _MINIX_CONST_H */
+26
View File
@@ -0,0 +1,26 @@
#ifndef _MINIX_CPUFEATURE_H
#define _MINIX_CPUFEATURE_H 1
#define _CPUF_I386_FPU 0 /* FPU-x87 FPU on Chip */
#define _CPUF_I386_PSE 1 /* Page Size Extension */
#define _CPUF_I386_PGE 2 /* Page Global Enable */
#define _CPUF_I386_APIC_ON_CHIP 3 /* APIC is present on the chip */
#define _CPUF_I386_TSC 4 /* Timestamp counter present */
#define _CPUF_I386_SSE1234_12 5 /* Support for SSE/SSE2/SSE3/SSSE3/SSE4
* Extensions and FXSR
*/
#define _CPUF_I386_FXSR 6
#define _CPUF_I386_SSE 7
#define _CPUF_I386_SSE2 8
#define _CPUF_I386_SSE3 9
#define _CPUF_I386_SSSE3 10
#define _CPUF_I386_SSE4_1 11
#define _CPUF_I386_SSE4_2 12
#define _CPUF_I386_HTT 13 /* Supports HTT */
#define _CPUF_I386_HTT_MAX_NUM 14 /* Maximal num of threads */
_PROTOTYPE(int _cpufeature, (int featureno));
#endif
+8
View File
@@ -0,0 +1,8 @@
/* Prototypes for crtso.s. */
#ifndef _MINIX_CRTSO_H
#define _MINIX_CRTSO_H
_PROTOTYPE( void _minix_unmapzero, (void));
#endif
+22
View File
@@ -0,0 +1,22 @@
#ifndef _MINIX_DEBUG_H
#define _MINIX_DEBUG_H 1
/* For reminders of things to be fixed. */
#define FIXME(str) { static int fixme_warned = 0; \
if(!fixme_warned) { \
printf("FIXME: %s:%d: %s\n", __FILE__, __LINE__, str);\
fixme_warned = 1; \
} \
}
#define NOT_REACHABLE do { \
panic("NOT_REACHABLE at %s:%d", __FILE__, __LINE__); \
for(;;); \
} while(0)
#define NOT_IMPLEMENTED do { \
panic("NOT_IMPLEMENTED at %s:%d", __FILE__, __LINE__); \
} while(0)
#endif /* _MINIX_DEBUG_H */
+68
View File
@@ -0,0 +1,68 @@
/* This file provides basic types and some constants for the
* SYS_DEVIO and SYS_VDEVIO system calls, which allow user-level
* processes to perform device I/O.
*
* Created:
* Apr 08, 2004 by Jorrit N. Herder
*/
#ifndef _DEVIO_H
#define _DEVIO_H
#include <minix/sys_config.h> /* needed to include <minix/type.h> */
#include <minix/types.h> /* u8_t, u16_t, u32_t needed */
typedef u16_t port_t;
/* We have different granularities of port I/O: 8, 16, 32 bits.
* Also see <ibm/portio.h>, which has functions for bytes, words,
* and longs. Hence, we need different (port,value)-pair types.
*/
typedef struct { u16_t port; u8_t value; } pvb_pair_t;
typedef struct { u16_t port; u16_t value; } pvw_pair_t;
typedef struct { u16_t port; u32_t value; } pvl_pair_t;
/* Macro shorthand to set (port,value)-pair. */
#define pv_set(pv, p, v) do { \
u32_t _p = (p), _v = (v); \
(pv).port = _p; \
(pv).value = _v; \
if((pv).port != _p || (pv).value != _v) { \
printf("%s:%d: actual port: 0x%x != 0x%x || " \
"actual value: 0x%x != 0x%x\n", \
__FILE__, __LINE__, (pv).port, _p, (pv).value, _v); \
panic("pv_set(" #pv ", " #p ", " #v ")"); \
} \
} while(0)
#if 0 /* no longer in use !!! */
/* Define a number of flags to indicate granularity we are using. */
#define MASK_GRANULARITY 0x000F /* not in use! does not match flags */
#define PVB_FLAG 'b'
#define PVW_FLAG 'w'
#define PVL_FLAG 'l'
/* Flags indicating whether request wants to do input or output. */
#define MASK_IN_OR_OUT 0x00F0
#define DEVIO_INPUT 0x0010
#define DEVIO_OUTPUT 0x0020
#endif /* 0 */
#if 0 /* no longer used !!! */
/* Define how large the (port,value)-pair buffer in the kernel is.
* This buffer is used to copy the (port,value)-pairs in kernel space.
*/
#define PV_BUF_SIZE 64 /* creates char pv_buf[PV_BUF_SIZE] */
/* Note that SYS_VDEVIO sends a pointer to a vector of (port,value)-pairs,
* whereas SYS_DEVIO includes a single (port,value)-pair in the messages.
* Calculate maximum number of (port,value)-pairs that can be handled
* in a single SYS_VDEVIO system call with above struct definitions.
*/
#define MAX_PVB_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvb_pair_t))
#define MAX_PVW_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvw_pair_t))
#define MAX_PVL_PAIRS ((PV_BUF_SIZE * sizeof(char)) / sizeof(pvl_pair_t))
#endif /* 0 */
#endif /* _DEVIO_H */
+72
View File
@@ -0,0 +1,72 @@
#ifndef MINIX_LIBDEVMAN_H
#define MINIX_LIBDEVMAN_H
#include <minix/com.h>
#include <minix/ipc.h>
#include <minix/usb_ch9.h>
/* used for serializing */
struct devman_device_info {
int count;
int parent_dev_id;
unsigned name_offset;
unsigned subsystem_offset;
};
struct devman_device_info_entry {
unsigned type;
unsigned name_offset;
unsigned data_offset;
unsigned req_nr;
};
#ifndef DEVMAN_SERVER
struct devman_usb_bind_cb_data {
int dev_id;
int interface;
};
struct devman_usb_interface {
struct devman_dev *dev;
struct devman_usb_dev *usb_dev;
usb_interface_descriptor_t *desc;
/* used by the lib */
struct devman_usb_bind_cb_data cb_data;
};
struct devman_usb_dev {
struct devman_dev *dev;
int dev_id; /* The ID identifying the device
on server side */
usb_device_descriptor_t *desc;
int configuration; /* the configuration used for this
device */
char *manufacturer;
char *product;
char *serial;
int intf_count; /* the number of interfaces in the current
configuration */
struct devman_usb_interface interfaces[32];
/* used by the lib */
struct devman_usb_bind_cb_data cb_data;
};
typedef int (*devman_usb_bind_cb_t)(struct devman_usb_bind_cb_data *data, endpoint_t ep);
_PROTOTYPE( int devman_add_device, (struct devman_dev *dev));
_PROTOTYPE( int devman_del_device, (struct devman_dev *dev));
_PROTOTYPE( int devman_init, (void));
_PROTOTYPE( struct devman_usb_dev* devman_usb_device_new, (int dev_id));
_PROTOTYPE( int devman_usb_device_add, (struct devman_usb_dev *dev));
_PROTOTYPE( int devman_usb_device_remove, (struct devman_usb_dev *dev));
_PROTOTYPE( void devman_usb_device_delete, (struct devman_usb_dev *udev));
_PROTOTYPE( int devman_handle_msg, (message *m));
_PROTOTYPE( void devman_usb_init, (devman_usb_bind_cb_t bind_cb,
devman_usb_bind_cb_t unbind_cb) );
#endif
#endif
+1 -40
View File
@@ -11,9 +11,7 @@
#ifndef _DIRENT_H
#define _DIRENT_H
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#include <sys/cdefs.h>
/* Name of length len needs _EXTENT(len) extra slots. */
#define _EXTENT(len) (((len) + 5) >> 3)
@@ -33,41 +31,4 @@
/* This is the block size for the fixed versions of the filesystem (V1/V2) */
#define _STATIC_BLOCK_SIZE 1024
/* Definitions for the directory(3) routines: */
typedef struct {
int _fd; /* Filedescriptor of open directory */
unsigned _count; /* This many bytes in _buf */
unsigned _pos; /* Position in _buf */
char _buf[_MAX_BLOCK_SIZE]; /* The size does not really
* matter as long as the
* buffer is big enough
* to contain at least one
* entry.
*/
} DIR;
struct dirent { /* Largest entry (8 slots) */
ino_t d_ino; /* I-node number */
off_t d_off; /* Offset in directory */
unsigned short d_reclen; /* Length of this record */
char d_name[1]; /* Null terminated name */
};
/* Function Prototypes. */
_PROTOTYPE( int closedir, (DIR *_dirp) );
_PROTOTYPE( DIR *opendir, (const char *_dirname) );
_PROTOTYPE( struct dirent *readdir, (DIR *_dirp) );
_PROTOTYPE( void rewinddir, (DIR *_dirp) );
#ifdef _MINIX
_PROTOTYPE( int seekdir, (DIR *_dirp, off_t _loc) );
_PROTOTYPE( off_t telldir, (DIR *_dirp) );
#define dirfd(dirp) ((dirp)->_fd)
_PROTOTYPE( int getdents, (int _fildes, struct dirent *_buf,
size_t _nbyte) );
#endif
#endif /* _DIRENT_H */
-26
View File
@@ -1,26 +0,0 @@
/* The eth_stat struct is used in a DL_GETSTAT request the the ehw_task. */
#ifndef _ETH_HW_H
#define _ETH_HW_H
typedef struct eth_stat
{
unsigned long ets_recvErr, /* # receive errors */
ets_sendErr, /* # send error */
ets_OVW, /* # buffer overwrite warnings */
ets_CRCerr, /* # crc errors of read */
ets_frameAll, /* # frames not alligned (# bits % 8 != 0) */
ets_missedP, /* # packets missed due to slow processing */
ets_packetR, /* # packets received */
ets_packetT, /* # packets transmitted */
ets_transDef, /* # transmission defered (Tx was busy) */
ets_collision, /* # collissions */
ets_transAb, /* # Tx aborted due to excess collisions */
ets_carrSense, /* # carrier sense lost */
ets_fifoUnder, /* # FIFO underruns (processor too busy) */
ets_fifoOver, /* # FIFO overruns (processor too busy) */
ets_CDheartbeat, /* # times unable to transmit collision sig*/
ets_OWC; /* # times out of window collision */
} eth_stat_t;
#endif /* _ETH_HW_H */
+60
View File
@@ -0,0 +1,60 @@
#ifndef _DMAP_H
#define _DMAP_H
#include <minix/sys_config.h>
#include <minix/ipc.h>
enum dev_style { STYLE_NDEV, STYLE_DEV, STYLE_DEVA, STYLE_TTY, STYLE_CTTY,
STYLE_CLONE, STYLE_CLONE_A };
#define IS_DEV_STYLE(s) (s>=STYLE_NDEV && s<=STYLE_CLONE_A)
/*===========================================================================*
* Major and minor device numbers *
*===========================================================================*/
/* Total number of different devices. */
#define NR_DEVICES NR_SYS_PROCS /* number of (major) devices */
/* Major device numbers. */
#define NONE_MAJOR 0 /* 0 = not used */
#define MEMORY_MAJOR 1 /* 1 = /dev/mem (memory devices) */
#define FLOPPY_MAJOR 2 /* 2 = /dev/fd0 (floppy disks) */
/* 3 = /dev/c0 */
#define TTY_MAJOR 4 /* 4 = /dev/tty00 (ttys) */
#define CTTY_MAJOR 5 /* 5 = /dev/tty */
#define PRINTER_MAJOR 6 /* 6 = /dev/lp (printer driver) */
#define INET_MAJOR 7 /* 7 = /dev/ip (inet) */
/* 8 = /dev/c1 */
/* 9 = not used */
/* 10 = /dev/c2 */
#define FILTER_MAJOR 11 /* 11 = /dev/filter (filter driver) */
/* 12 = /dev/c3 */
#define AUDIO_MAJOR 13 /* 13 = /dev/audio (audio driver) */
#define FBD_MAJOR 14 /* 14 = /dev/fbd (faulty block dev)*/
#define LOG_MAJOR 15 /* 15 = /dev/klog (log driver) */
#define RANDOM_MAJOR 16 /* 16 = /dev/random (random driver) */
#define HELLO_MAJOR 17 /* 17 = /dev/hello (hello driver) */
#define UDS_MAJOR 18 /* 18 = /dev/uds (pfs) */
/* Minor device numbers for memory driver. */
# define RAM_DEV_OLD 0 /* minor device for /dev/ram */
# define MEM_DEV 1 /* minor device for /dev/mem */
# define KMEM_DEV 2 /* minor device for /dev/kmem */
# define NULL_DEV 3 /* minor device for /dev/null */
# define BOOT_DEV 4 /* minor device for /dev/boot */
# define ZERO_DEV 5 /* minor device for /dev/zero */
# define IMGRD_DEV 6 /* minor device for /dev/imgrd */
# define RAM_DEV_FIRST 7 /* first minor device for /dev/ram* */
#define CTRLR(n) ((n)==0 ? 3 : (8 + 2*((n)-1))) /* magic formula */
/* Minor device numbers for log driver. */
# define IS_KLOG_DEV 0 /* minor device for /dev/klog */
/* Full device numbers that are special to the boot monitor and FS. */
# define DEV_RAM ((dev_t) 0x0100) /* device number of /dev/ram */
# define DEV_IMGRD ((dev_t) 0x0106) /* device number of /dev/imgrd */
#endif /* _DMAP_H */
+44
View File
@@ -0,0 +1,44 @@
#ifndef _MINIX_DRIVER_H
#define _MINIX_DRIVER_H
/* Types and constants shared between block and character drivers. */
#define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */
#define _MINIX 1 /* tell headers to include MINIX stuff */
#define _SYSTEM 1 /* get negative error number in <errno.h> */
/* The following are so basic, all the *.c files get them automatically. */
#include <minix/config.h> /* MUST be first */
#include <minix/ansi.h> /* MUST be second */
#include <minix/type.h>
#include <minix/ipc.h>
#include <minix/com.h>
#include <minix/callnr.h>
#include <sys/types.h>
#include <minix/const.h>
#include <minix/syslib.h>
#include <minix/sysutil.h>
#include <minix/endpoint.h>
#include <string.h>
#include <limits.h>
#include <stddef.h>
#include <errno.h>
#include <sys/param.h>
#include <minix/u64.h>
#include <minix/partition.h>
/* Base and size of a partition in bytes. */
struct device {
u64_t dv_base;
u64_t dv_size;
};
/* Generic receive function for all drivers. */
#ifndef driver_receive
#define driver_receive sef_receive_status
#endif
/* Maximum supported number of concurrently opened minor devices. */
#define MAX_NR_OPEN_DEVICES 256
#endif /* _MINIX_DRIVER_H */
+41
View File
@@ -0,0 +1,41 @@
/* This is the master header for all device drivers. It includes some other
* files and defines the principal constants.
*/
#ifndef _INC_DRIVERS_H
#define _INC_DRIVERS_H
#define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */
#define _MINIX 1 /* tell headers to include MINIX stuff */
#define _SYSTEM 1 /* get negative error number in <errno.h> */
/* The following are so basic, all the *.c files get them automatically. */
#include <minix/config.h> /* MUST be first */
#include <minix/ansi.h> /* MUST be second */
#include <minix/type.h>
#include <minix/com.h>
#include <minix/dmap.h>
#include <minix/callnr.h>
#include <sys/types.h>
#include <minix/const.h>
#include <minix/devio.h>
#include <minix/syslib.h>
#include <minix/sysutil.h>
#include <minix/timers.h>
#include <minix/spin.h>
#include <minix/bitmap.h>
#include <machine/interrupt.h> /* IRQ vectors and miscellaneous ports */
#include <machine/bios.h> /* BIOS index numbers */
#include <machine/ports.h> /* Well-known ports */
#include <string.h>
#include <signal.h>
#include <stdlib.h>
#include <limits.h>
#include <stddef.h>
#include <errno.h>
#include <unistd.h>
#include <sys/param.h>
#endif
+17
View File
@@ -0,0 +1,17 @@
/* IBM device driver definitions Author: Kees J. Bot
* 7 Dec 1995
*/
#include <machine/partition.h>
_PROTOTYPE( void partition, (struct blockdriver *bdr, int device, int style,
int atapi) );
#define DEV_PER_DRIVE (1 + NR_PARTITIONS)
#define MINOR_t0 64
#define MINOR_r0 120
#define MINOR_d0p0s0 128
#define MINOR_fd0p0 (28<<2)
#define P_FLOPPY 0
#define P_PRIMARY 1
#define P_SUB 2
+77
View File
@@ -0,0 +1,77 @@
/* Prototypes and definitions for DS interface. */
#ifndef _MINIX_DS_H
#define _MINIX_DS_H
#include <minix/types.h>
#include <minix/endpoint.h>
/* Flags. */
#define DSF_IN_USE 0x001 /* entry is in use */
#define DSF_PRIV_RETRIEVE 0x002 /* only owner can retrieve */
#define DSF_PRIV_OVERWRITE 0x004 /* only owner can overwrite */
#define DSF_PRIV_SNAPSHOT 0x004 /* only owner can take a snapshot */
#define DSF_PRIV_SUBSCRIBE 0x008 /* only owner can subscribe */
#define DSF_TYPE_U32 0x010 /* u32 data type */
#define DSF_TYPE_STR 0x020 /* string data type */
#define DSF_TYPE_MEM 0x040 /* memory range data type */
#define DSF_TYPE_MAP 0x080 /* mapped memory range data type */
#define DSF_TYPE_LABEL 0x100 /* label data type */
#define DSF_MASK_TYPE 0xFF0 /* mask for type flags. */
#define DSF_MASK_INTERNAL 0xFFF /* mask for internal flags. */
#define DSF_OVERWRITE 0x01000 /* overwrite if entry exists */
#define DSF_INITIAL 0x02000 /* check subscriptions immediately */
#define DSMF_MAP_MAPPED 0x10000 /* map mapped memory range */
#define DSMF_COPY_MAPPED 0x20000 /* copy mapped memory range */
#define DSMF_COPY_SNAPSHOT 0x40000 /* copy snapshot */
/* DS constants. */
#define DS_MAX_KEYLEN 80 /* Max length of a key, including '\0'. */
/* DS events. */
#define DS_DRIVER_UP 1
/* ds.c */
/* U32 */
_PROTOTYPE( int ds_publish_u32, (const char *name, u32_t val, int flags));
_PROTOTYPE( int ds_retrieve_u32, (const char *name, u32_t *val));
_PROTOTYPE( int ds_delete_u32, (const char *ds_name));
/* STRING */
_PROTOTYPE( int ds_publish_str, (const char *name, char *val, int flags));
_PROTOTYPE( int ds_retrieve_str, (const char *name, char *val, size_t len));
_PROTOTYPE( int ds_delete_str, (const char *ds_name));
/* MEM */
_PROTOTYPE( int ds_publish_mem, (const char *ds_name, void *vaddr,
size_t length, int flags));
_PROTOTYPE( int ds_retrieve_mem, (const char *ds_name, char *vaddr,
size_t *length));
_PROTOTYPE( int ds_delete_mem, (const char *ds_name));
/* MAP */
_PROTOTYPE( int ds_publish_map, (const char *ds_name, void *vaddr,
size_t length, int flags));
_PROTOTYPE( int ds_snapshot_map, (const char *ds_name, int *nr_snapshot));
_PROTOTYPE( int ds_retrieve_map, (const char *ds_name, char *vaddr,
size_t *length, int nr_snapshot, int flags));
_PROTOTYPE( int ds_delete_map, (const char *ds_name));
/* LABEL */
_PROTOTYPE( int ds_publish_label, (const char *ds_name, endpoint_t endpoint,
int flags));
_PROTOTYPE( int ds_retrieve_label_name, (char *ds_name, endpoint_t endpoint));
_PROTOTYPE( int ds_retrieve_label_endpt, (const char *ds_name,
endpoint_t *endpoint));
_PROTOTYPE( int ds_delete_label, (const char *ds_name));
/* Subscribe and check. */
_PROTOTYPE( int ds_subscribe, (const char *regex, int flags));
_PROTOTYPE( int ds_check, (char *ds_name, int *type, endpoint_t *owner_e));
#endif /* _MINIX_DS_H */
+28
View File
@@ -0,0 +1,28 @@
#ifndef _MINIX_ENDPOINT_H
#define _MINIX_ENDPOINT_H 1
#include <minix/sys_config.h>
#include <minix/com.h>
#include <limits.h>
#include <minix/type.h>
/* The point of the padding in 'generation size' is to
* allow for certain bogus endpoint numbers such as NONE, ANY, etc.
*
* The _MAX_MAGIC_PROC is defined by <minix/com.h>. That include
* file defines some magic process numbers such as ANY and NONE,
* and must never be a valid endpoint number. Therefore we make sure
* the generation size is big enough to start the next generation
* above the highest magic number.
*/
#define _ENDPOINT_GENERATION_SIZE (MAX_NR_TASKS+_MAX_MAGIC_PROC+1)
#define _ENDPOINT_MAX_GENERATION (INT_MAX/_ENDPOINT_GENERATION_SIZE-1)
/* Generation + Process slot number <-> endpoint. */
#define _ENDPOINT(g, p) ((endpoint_t)((g) * _ENDPOINT_GENERATION_SIZE + (p)))
#define _ENDPOINT_G(e) (((e)+MAX_NR_TASKS) / _ENDPOINT_GENERATION_SIZE)
#define _ENDPOINT_P(e) \
((((e)+MAX_NR_TASKS) % _ENDPOINT_GENERATION_SIZE) - MAX_NR_TASKS)
#endif
+11
View File
@@ -0,0 +1,11 @@
/* V1 and V2 file system disk to/from memory support functions. */
_PROTOTYPE( int bitmapsize, (bit_t _nr_bits, int block_size) );
_PROTOTYPE( unsigned conv2, (int _norm, int _w) );
_PROTOTYPE( long conv4, (int _norm, long _x) );
_PROTOTYPE( void conv_inode, (struct inode *_rip, d1_inode *_dip,
d2_inode *_dip2, int _rw_flag, int _magic) );
_PROTOTYPE( void old_icopy, (struct inode *_rip, d1_inode *_dip,
int _direction, int _norm));
_PROTOTYPE( void new_icopy, (struct inode *_rip, d2_inode *_dip,
int _direction, int _norm));
+16
View File
@@ -0,0 +1,16 @@
#include <sys/types.h>
#include <lib.h>
#include <stdlib.h>
#include <minix/syslib.h>
/* opcodes for use in gcov buffer */
#define GCOVOP_OPEN 23
#define GCOVOP_WRITE 24
#define GCOVOP_CLOSE 25
#define GCOVOP_END 26
/* More information on the GCOV Minix Wiki page. */
int gcov_flush_svr(char *buff, int buff_sz, int server_nr);
extern void __gcov_flush (void);
int do_gcov_flush_impl(message *msg);
+49
View File
@@ -0,0 +1,49 @@
#ifndef _MINIX_HASH_H
#define _MINIX_HASH_H 1
#include <stdint.h>
/* This code is taken from:
* lookup3.c, by Bob Jenkins, May 2006, Public Domain.
* (macro names modified)
*/
#define hash_rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
#define hash_mix(a,b,c) \
{ \
a -= c; a ^= hash_rot(c, 4); c += b; \
b -= a; b ^= hash_rot(a, 6); a += c; \
c -= b; c ^= hash_rot(b, 8); b += a; \
a -= c; a ^= hash_rot(c,16); c += b; \
b -= a; b ^= hash_rot(a,19); a += c; \
c -= b; c ^= hash_rot(b, 4); b += a; \
}
#define hash_final(a,b,c) \
{ \
c ^= b; c -= hash_rot(b,14); \
a ^= c; a -= hash_rot(c,11); \
b ^= a; b -= hash_rot(a,25); \
c ^= b; c -= hash_rot(b,16); \
a ^= c; a -= hash_rot(c,4); \
b ^= a; b -= hash_rot(a,14); \
c ^= b; c -= hash_rot(b,24); \
}
#define hash_i_64(a, u, v) { \
u32_t i1 = (a), i2 = ex64lo(u), i3 = ex64hi(u); \
hash_mix(i1, i2, i3); \
hash_final(i1, i2, i3); \
(v) = i3; \
}
#define hash_32(n, v) { \
u32_t i1 = 0xa5a5a5a5, i2 = 0x12345678, i3 = n; \
hash_mix(i1, i2, i3); \
hash_final(i1, i2, i3); \
(v) = i3; \
}
#endif
+66
View File
@@ -0,0 +1,66 @@
/* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
#ifndef _HGFS_H
#define _HGFS_H
#include <sys/types.h>
#include <minix/u64.h>
typedef void *hgfs_file_t; /* handle to open file */
typedef void *hgfs_dir_t; /* handle to directory search */
struct hgfs_attr {
u32_t a_mask; /* which fields to retrieve/set */
mode_t a_mode; /* file type and permissions */
u64_t a_size; /* file size */
time_t a_crtime; /* file creation time */
time_t a_atime; /* file access time */
time_t a_mtime; /* file modification time */
time_t a_ctime; /* file change time */
};
#define HGFS_ATTR_SIZE 0x01 /* get/set file size */
#define HGFS_ATTR_CRTIME 0x02 /* get/set file creation time */
#define HGFS_ATTR_ATIME 0x04 /* get/set file access time */
#define HGFS_ATTR_MTIME 0x08 /* get/set file modification time */
#define HGFS_ATTR_CTIME 0x10 /* get/set file change time */
#define HGFS_ATTR_MODE 0x20 /* get/set file mode */
#define HGFS_ATTR_ATIME_SET 0x40 /* set specific file access time */
#define HGFS_ATTR_MTIME_SET 0x80 /* set specific file modify time */
#define HGFS_ATTR_ALL \
(HGFS_ATTR_SIZE | HGFS_ATTR_CRTIME | HGFS_ATTR_ATIME | \
HGFS_ATTR_MTIME | HGFS_ATTR_CTIME | HGFS_ATTR_MODE | \
HGFS_ATTR_ATIME_SET | HGFS_ATTR_MTIME_SET)
_PROTOTYPE( int hgfs_init, (void) );
_PROTOTYPE( void hgfs_cleanup, (void) );
_PROTOTYPE( int hgfs_enabled, (void) );
_PROTOTYPE( int hgfs_open, (char *path, int flags, int mode,
hgfs_file_t *handle) );
_PROTOTYPE( int hgfs_read, (hgfs_file_t handle, char *buf, size_t size,
u64_t offset) );
_PROTOTYPE( int hgfs_write, (hgfs_file_t handle, const char *buf,
size_t len, u64_t offset, int append) );
_PROTOTYPE( int hgfs_close, (hgfs_file_t handle) );
_PROTOTYPE( size_t hgfs_readbuf, (char **ptr) );
_PROTOTYPE( size_t hgfs_writebuf, (char **ptr) );
_PROTOTYPE( int hgfs_opendir, (char *path, hgfs_dir_t *handle) );
_PROTOTYPE( int hgfs_readdir, (hgfs_dir_t handle, unsigned int index,
char *buf, size_t size, struct hgfs_attr *attr) );
_PROTOTYPE( int hgfs_closedir, (hgfs_dir_t handle) );
_PROTOTYPE( int hgfs_getattr, (char *path, struct hgfs_attr *attr) );
_PROTOTYPE( int hgfs_setattr, (char *path, struct hgfs_attr *attr) );
_PROTOTYPE( int hgfs_mkdir, (char *path, int mode) );
_PROTOTYPE( int hgfs_unlink, (char *path) );
_PROTOTYPE( int hgfs_rmdir, (char *path) );
_PROTOTYPE( int hgfs_rename, (char *opath, char *npath) );
_PROTOTYPE( int hgfs_queryvol, (char *path, u64_t *free, u64_t *total) );
#endif /* _HGFS_H */
+8
View File
@@ -0,0 +1,8 @@
#ifndef _MINIX_INPUT_H
#define _MINIX_INPUT_H
#define INPUT_EV_KEY 0x1
#define INPUT_EV_REL 0x2
#define INPUT_EV_ABS 0x3
#endif
+72
View File
@@ -0,0 +1,72 @@
/* minix/ioctl.h - Ioctl helper definitions. Author: Kees J. Bot
* 23 Nov 2002
*
* This file is included by every header file that defines ioctl codes.
*/
#ifndef _M_IOCTL_H
#define _M_IOCTL_H
#include <sys/cdefs.h>
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#if _EM_WSIZE >= 4
/* Ioctls have the command encoded in the low-order word, and the size
* of the parameter in the high-order word. The 3 high bits of the high-
* order word are used to encode the in/out/void status of the parameter.
*/
#define _IOCPARM_MASK 0x0FFF
#define _IOCPARM_MASK_BIG 0x0FFFFF
#define _IOC_VOID 0x20000000
#define _IOCTYPE_MASK 0xFFFF
#define _IOC_IN 0x40000000
#define _IOC_OUT 0x80000000
#define _IOC_INOUT (_IOC_IN | _IOC_OUT)
/* Flag indicating ioctl format with only one type field, and more bits
* for the size field (using mask _IOCPARM_MASK_BIG).
*/
#define _IOC_BIG 0x10000000
#define _IO(x,y) ((x << 8) | y | _IOC_VOID)
#define _IOR(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
_IOC_OUT)
#define _IOW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
_IOC_IN)
#define _IORW(x,y,t) ((x << 8) | y | ((sizeof(t) & _IOCPARM_MASK) << 16) |\
_IOC_INOUT)
#define _IOW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
| _IOC_IN | _IOC_BIG)
#define _IOR_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
| _IOC_OUT | _IOC_BIG)
#define _IORW_BIG(y,t) (y | ((sizeof(t) & _IOCPARM_MASK_BIG) << 8) \
| _IOC_INOUT | _IOC_BIG)
/* Decode an ioctl call. */
#define _MINIX_IOCTL_SIZE(i) (((i) >> 16) & _IOCPARM_MASK)
#define _MINIX_IOCTL_IOR(i) ((i) & _IOC_OUT)
#define _MINIX_IOCTL_IORW(i) ((i) & _IOC_INOUT)
#define _MINIX_IOCTL_IOW(i) ((i) & _IOC_IN)
/* Recognize and decode size of a 'big' ioctl call. */
#define _MINIX_IOCTL_BIG(i) ((i) & _IOC_BIG)
#define _MINIX_IOCTL_SIZE_BIG(i) (((i) >> 8) & _IOCPARM_MASK_BIG)
#else
/* No fancy encoding on a 16-bit machine. */
#define _IO(x,y) ((x << 8) | y)
#define _IOR(x,y,t) _IO(x,y)
#define _IOW(x,y,t) _IO(x,y)
#define _IORW(x,y,t) _IO(x,y)
#endif
__BEGIN_DECLS
int ioctl(int _fd, int _request, void *_data);
__END_DECLS
#endif /* _M_IOCTL_H */
+175
View File
@@ -0,0 +1,175 @@
#ifndef _IPC_H
#define _IPC_H
#ifdef __NBSD_LIBC
#include <minix/ansi.h>
#endif
#include <minix/ipcconst.h>
#include <minix/type.h>
/*==========================================================================*
* Types relating to messages. *
*==========================================================================*/
#define M1 1
#define M3 3
#define M4 4
#define M3_STRING 14 /* legacy m3_ca1 size (must not be changed) */
#define M3_LONG_STRING 16 /* current m3_ca1 size (may be increased) */
typedef struct {int m1i1, m1i2, m1i3; char *m1p1, *m1p2, *m1p3;} mess_1;
typedef struct {int m2i1, m2i2, m2i3; long m2l1, m2l2; char *m2p1;
short m2s1;} mess_2;
typedef struct {int m3i1, m3i2; char *m3p1; char m3ca1[M3_LONG_STRING];} mess_3;
typedef struct {long m4l1, m4l2, m4l3, m4l4, m4l5;} mess_4;
typedef struct {short m5s1, m5s2; int m5i1, m5i2; long m5l1, m5l2, m5l3;}mess_5;
typedef struct {long m6l1, m6l2, m6l3; short m6s1, m6s2, m6s3; char m6c1, m6c2;
char *m6p1, *m6p2;} mess_6;
typedef struct {int m7i1, m7i2, m7i3, m7i4, m7i5; char *m7p1, *m7p2;} mess_7;
typedef struct {int m8i1, m8i2; char *m8p1, *m8p2, *m8p3, *m8p4;} mess_8;
typedef struct {long m9l1, m9l2, m9l3, m9l4, m9l5;
short m9s1, m9s2, m9s3, m9s4; } mess_9;
typedef struct {int m10i1, m10i2, m10i3, m10i4;
long m10l1, m10l2, m10l3; } mess_10;
typedef struct {
endpoint_t m_source; /* who sent the message */
int m_type; /* what kind of message is it */
union {
mess_1 m_m1;
mess_2 m_m2;
mess_3 m_m3;
mess_4 m_m4;
mess_5 m_m5;
mess_7 m_m7;
mess_8 m_m8;
mess_6 m_m6;
mess_9 m_m9;
mess_10 m_m10;
} m_u;
} message;
/* The following defines provide names for useful members. */
#define m1_i1 m_u.m_m1.m1i1
#define m1_i2 m_u.m_m1.m1i2
#define m1_i3 m_u.m_m1.m1i3
#define m1_p1 m_u.m_m1.m1p1
#define m1_p2 m_u.m_m1.m1p2
#define m1_p3 m_u.m_m1.m1p3
#define m2_i1 m_u.m_m2.m2i1
#define m2_i2 m_u.m_m2.m2i2
#define m2_i3 m_u.m_m2.m2i3
#define m2_l1 m_u.m_m2.m2l1
#define m2_l2 m_u.m_m2.m2l2
#define m2_p1 m_u.m_m2.m2p1
#define m2_s1 m_u.m_m2.m2s1
#define m3_i1 m_u.m_m3.m3i1
#define m3_i2 m_u.m_m3.m3i2
#define m3_p1 m_u.m_m3.m3p1
#define m3_ca1 m_u.m_m3.m3ca1
#define m4_l1 m_u.m_m4.m4l1
#define m4_l2 m_u.m_m4.m4l2
#define m4_l3 m_u.m_m4.m4l3
#define m4_l4 m_u.m_m4.m4l4
#define m4_l5 m_u.m_m4.m4l5
#define m5_s1 m_u.m_m5.m5s1
#define m5_s2 m_u.m_m5.m5s2
#define m5_i1 m_u.m_m5.m5i1
#define m5_i2 m_u.m_m5.m5i2
#define m5_l1 m_u.m_m5.m5l1
#define m5_l2 m_u.m_m5.m5l2
#define m5_l3 m_u.m_m5.m5l3
#define m6_l1 m_u.m_m6.m6l1
#define m6_l2 m_u.m_m6.m6l2
#define m6_l3 m_u.m_m6.m6l3
#define m6_s1 m_u.m_m6.m6s1
#define m6_s2 m_u.m_m6.m6s2
#define m6_s3 m_u.m_m6.m6s3
#define m6_c1 m_u.m_m6.m6c1
#define m6_c2 m_u.m_m6.m6c2
#define m6_p1 m_u.m_m6.m6p1
#define m6_p2 m_u.m_m6.m6p2
#define m7_i1 m_u.m_m7.m7i1
#define m7_i2 m_u.m_m7.m7i2
#define m7_i3 m_u.m_m7.m7i3
#define m7_i4 m_u.m_m7.m7i4
#define m7_i5 m_u.m_m7.m7i5
#define m7_p1 m_u.m_m7.m7p1
#define m7_p2 m_u.m_m7.m7p2
#define m8_i1 m_u.m_m8.m8i1
#define m8_i2 m_u.m_m8.m8i2
#define m8_p1 m_u.m_m8.m8p1
#define m8_p2 m_u.m_m8.m8p2
#define m8_p3 m_u.m_m8.m8p3
#define m8_p4 m_u.m_m8.m8p4
#define m9_l1 m_u.m_m9.m9l1
#define m9_l2 m_u.m_m9.m9l2
#define m9_l3 m_u.m_m9.m9l3
#define m9_l4 m_u.m_m9.m9l4
#define m9_l5 m_u.m_m9.m9l5
#define m9_s1 m_u.m_m9.m9s1
#define m9_s2 m_u.m_m9.m9s2
#define m9_s3 m_u.m_m9.m9s3
#define m9_s4 m_u.m_m9.m9s4
#define m10_i1 m_u.m_m10.m10i1
#define m10_i2 m_u.m_m10.m10i2
#define m10_i3 m_u.m_m10.m10i3
#define m10_i4 m_u.m_m10.m10i4
#define m10_l1 m_u.m_m10.m10l1
#define m10_l2 m_u.m_m10.m10l2
#define m10_l3 m_u.m_m10.m10l3
/*==========================================================================*
* Minix run-time system (IPC). *
*==========================================================================*/
/* Datastructure for asynchronous sends */
typedef struct asynmsg
{
unsigned flags;
endpoint_t dst;
int result;
message msg;
} asynmsg_t;
/* Defines for flags field */
#define AMF_EMPTY 000 /* slot is not inuse */
#define AMF_VALID 001 /* slot contains message */
#define AMF_DONE 002 /* Kernel has processed the message. The
* result is stored in 'result'
*/
#define AMF_NOTIFY 004 /* Send a notification when AMF_DONE is set */
#define AMF_NOREPLY 010 /* Not a reply message for a SENDREC */
#define AMF_NOTIFY_ERR 020 /* Send a notification when AMF_DONE is set and
* delivery of the message failed */
/* Hide names to avoid name space pollution. */
#define echo _echo
#define notify _notify
#define sendrec _sendrec
#define receive _receive
#define send _send
#define sendnb _sendnb
#define senda _senda
_PROTOTYPE( int echo, (message *m_ptr) );
_PROTOTYPE( int notify, (endpoint_t dest) );
_PROTOTYPE( int sendrec, (endpoint_t src_dest, message *m_ptr) );
_PROTOTYPE( int receive, (endpoint_t src, message *m_ptr, int *status_ptr));
_PROTOTYPE( int send, (endpoint_t dest, message *m_ptr) );
_PROTOTYPE( int sendnb, (endpoint_t dest, message *m_ptr) );
_PROTOTYPE( int senda, (asynmsg_t *table, size_t count) );
_PROTOTYPE( int _do_kernel_call, (message *m_ptr) );
#endif /* _IPC_H */
+29
View File
@@ -0,0 +1,29 @@
#ifndef _IPC_CONST_H
#define _IPC_CONST_H
/* System call numbers that are passed when trapping to the kernel. */
#define SEND 1 /* blocking send */
#define RECEIVE 2 /* blocking receive */
#define SENDREC 3 /* SEND + RECEIVE */
#define NOTIFY 4 /* asynchronous notify */
#define SENDNB 5 /* nonblocking send */
#define SENDA 16 /* asynchronous send */
#define IPCNO_HIGHEST SENDA
/* Macros for IPC status code manipulation. */
#define IPC_STATUS_CALL_SHIFT 0
#define IPC_STATUS_CALL_MASK 0x3F
#define IPC_STATUS_CALL(status) \
(((status) >> IPC_STATUS_CALL_SHIFT) & IPC_STATUS_CALL_MASK)
#define IPC_STATUS_CALL_TO(call) \
(((call) & IPC_STATUS_CALL_MASK) << IPC_STATUS_CALL_SHIFT)
#define IPC_FLG_MSG_FROM_KERNEL 1 /* this message originated in the kernel on
behalf of a process, this is a trusted
message, never reply to the sender
*/
#define IPC_STATUS_FLAGS_SHIFT 16
#define IPC_STATUS_FLAGS(flgs) ((flgs) << IPC_STATUS_FLAGS_SHIFT)
#define IPC_STATUS_FLAGS_TEST(status, flgs) \
(((status) >> IPC_STATUS_FLAGS_SHIFT) & (flgs))
#endif /* IPC_CONST_H */
+146
View File
@@ -0,0 +1,146 @@
/* keymap.h - defines for keymapping Author: Marcus Hampel
*/
#ifndef _SYS__KEYMAP_H
#define _SYS__KEYMAP_H
#define C(c) ((c) & 0x1F) /* Map to control code */
#define A(c) ((c) | 0x80) /* Set eight bit (ALT) */
#define CA(c) A(C(c)) /* Control-Alt */
#define L(c) ((c) | HASCAPS) /* Add "Caps Lock has effect" attribute */
#define EXT 0x0100 /* Normal function keys */
#define CTRL 0x0200 /* Control key */
#define SHIFT 0x0400 /* Shift key */
#define ALT 0x0800 /* Alternate key */
#define EXTKEY 0x1000 /* extended keycode */
#define HASCAPS 0x8000 /* Caps Lock has effect */
/* Scan code conversion. */
#define KEY_RELEASE 0200
#define ASCII_MASK 0177
/* Numeric keypad */
#define HOME (0x01 + EXT)
#define END (0x02 + EXT)
#define UP (0x03 + EXT)
#define DOWN (0x04 + EXT)
#define LEFT (0x05 + EXT)
#define RIGHT (0x06 + EXT)
#define PGUP (0x07 + EXT)
#define PGDN (0x08 + EXT)
#define MID (0x09 + EXT)
#define NMIN (0x0A + EXT)
#define PLUS (0x0B + EXT)
#define INSRT (0x0C + EXT)
/* Alt + Numeric keypad */
#define AHOME (0x01 + ALT)
#define AEND (0x02 + ALT)
#define AUP (0x03 + ALT)
#define ADOWN (0x04 + ALT)
#define ALEFT (0x05 + ALT)
#define ARIGHT (0x06 + ALT)
#define APGUP (0x07 + ALT)
#define APGDN (0x08 + ALT)
#define AMID (0x09 + ALT)
#define ANMIN (0x0A + ALT)
#define APLUS (0x0B + ALT)
#define AINSRT (0x0C + ALT)
/* Ctrl + Numeric keypad */
#define CHOME (0x01 + CTRL)
#define CEND (0x02 + CTRL)
#define CUP (0x03 + CTRL)
#define CDOWN (0x04 + CTRL)
#define CLEFT (0x05 + CTRL)
#define CRIGHT (0x06 + CTRL)
#define CPGUP (0x07 + CTRL)
#define CPGDN (0x08 + CTRL)
#define CMID (0x09 + CTRL)
#define CNMIN (0x0A + CTRL)
#define CPLUS (0x0B + CTRL)
#define CINSRT (0x0C + CTRL)
/* Lock keys */
#define CALOCK (0x0D + EXT) /* caps lock */
#define NLOCK (0x0E + EXT) /* number lock */
#define SLOCK (0x0F + EXT) /* scroll lock */
/* Function keys */
#define F1 (0x10 + EXT)
#define F2 (0x11 + EXT)
#define F3 (0x12 + EXT)
#define F4 (0x13 + EXT)
#define F5 (0x14 + EXT)
#define F6 (0x15 + EXT)
#define F7 (0x16 + EXT)
#define F8 (0x17 + EXT)
#define F9 (0x18 + EXT)
#define F10 (0x19 + EXT)
#define F11 (0x1A + EXT)
#define F12 (0x1B + EXT)
/* Alt+Fn */
#define AF1 (0x10 + ALT)
#define AF2 (0x11 + ALT)
#define AF3 (0x12 + ALT)
#define AF4 (0x13 + ALT)
#define AF5 (0x14 + ALT)
#define AF6 (0x15 + ALT)
#define AF7 (0x16 + ALT)
#define AF8 (0x17 + ALT)
#define AF9 (0x18 + ALT)
#define AF10 (0x19 + ALT)
#define AF11 (0x1A + ALT)
#define AF12 (0x1B + ALT)
/* Ctrl+Fn */
#define CF1 (0x10 + CTRL)
#define CF2 (0x11 + CTRL)
#define CF3 (0x12 + CTRL)
#define CF4 (0x13 + CTRL)
#define CF5 (0x14 + CTRL)
#define CF6 (0x15 + CTRL)
#define CF7 (0x16 + CTRL)
#define CF8 (0x17 + CTRL)
#define CF9 (0x18 + CTRL)
#define CF10 (0x19 + CTRL)
#define CF11 (0x1A + CTRL)
#define CF12 (0x1B + CTRL)
/* Shift+Fn */
#define SF1 (0x10 + SHIFT)
#define SF2 (0x11 + SHIFT)
#define SF3 (0x12 + SHIFT)
#define SF4 (0x13 + SHIFT)
#define SF5 (0x14 + SHIFT)
#define SF6 (0x15 + SHIFT)
#define SF7 (0x16 + SHIFT)
#define SF8 (0x17 + SHIFT)
#define SF9 (0x18 + SHIFT)
#define SF10 (0x19 + SHIFT)
#define SF11 (0x1A + SHIFT)
#define SF12 (0x1B + SHIFT)
/* Alt+Shift+Fn */
#define ASF1 (0x10 + ALT + SHIFT)
#define ASF2 (0x11 + ALT + SHIFT)
#define ASF3 (0x12 + ALT + SHIFT)
#define ASF4 (0x13 + ALT + SHIFT)
#define ASF5 (0x14 + ALT + SHIFT)
#define ASF6 (0x15 + ALT + SHIFT)
#define ASF7 (0x16 + ALT + SHIFT)
#define ASF8 (0x17 + ALT + SHIFT)
#define ASF9 (0x18 + ALT + SHIFT)
#define ASF10 (0x19 + ALT + SHIFT)
#define ASF11 (0x1A + ALT + SHIFT)
#define ASF12 (0x1B + ALT + SHIFT)
#define MAP_COLS 6 /* Number of columns in keymap */
#define NR_SCAN_CODES 0x80 /* Number of scan codes (rows in keymap) */
typedef unsigned short keymap_t[NR_SCAN_CODES * MAP_COLS];
#define KEY_MAGIC "KMAZ" /* Magic number of keymap file */
#endif /* _SYS__KEYMAP_H */
+16
View File
@@ -0,0 +1,16 @@
/* Prototypes for -lminixfs. */
#ifndef _MINIX_FSLIB_H
#define _MINIX_FSLIB_H
#include <minix/safecopies.h>
#include <minix/sef.h>
#include <minix/vfsif.h>
int fs_lookup_credentials(vfs_ucred_t *credentials,
uid_t *caller_uid, gid_t *caller_gid, cp_grant_id_t grant2, size_t cred_size);
u32_t fs_bufs_heuristic(int minbufs, u32_t btotal, u32_t bfree,
int blocksize, dev_t majordev);
#endif /* _MINIX_FSLIB_H */
+12
View File
@@ -0,0 +1,12 @@
/* The <minix/limits.h> header defines the Minix values for some MINIX
* constants. Both the MINIX constants and the non-posix constants
* refer to these underlying definitions.
*/
#ifndef _MINIX_LIMITS_H
#define _MINIX_LIMITS_H
#define __MINIX_OPEN_MAX 255 /* a process may have 255 files open */
#define __MINIX_PATH_MAX 1024/* a pathname may contain 1023 chars (+ '\0')*/
#endif /* _MINIX_LIMITS_H */
-54
View File
@@ -1,54 +0,0 @@
/* $NetBSD: md5.h,v 1.5 2008/10/08 14:28:14 joerg Exp $ */
/*
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
* Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.ORG>
* for portability and formatting.
*/
/*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#ifndef _NBCOMPAT_SYS_MD5_H_
#define _NBCOMPAT_SYS_MD5_H_
#include <stdint.h>
#define MD5_DIGEST_LENGTH 16
#define MD5_DIGEST_STRING_LENGTH 33
/* MD5 context. */
typedef struct MD5Context {
uint32_t state[4]; /* state (ABCD) */
uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void MD5Init(MD5_CTX *);
void MD5Update(MD5_CTX *, const unsigned char *, unsigned int);
void MD5Final(unsigned char[16], MD5_CTX *);
char *MD5End(MD5_CTX *, char *);
char *MD5File(const char *, char *);
char *MD5Data(const unsigned char *, unsigned int, char *);
#endif /* !_NBCOMPAT_SYS_MD5_H_ */
+38
View File
@@ -0,0 +1,38 @@
#ifndef _MINLIB
#define _MINLIB
#ifndef _MINIX_ANSI_H
#include <minix/ansi.h>
#endif
/* Miscellaneous BSD. */
_PROTOTYPE(char *itoa, (int _n));
#ifndef __NBSD_LIBC
_PROTOTYPE(char *getpass, (const char *_prompt));
#ifdef __ACK__
_PROTOTYPE(void swab, (char *_from, char *_to, int _count));
#endif
#endif /* !_NBSD_LIBC */
/* Miscellaneous MINIX. */
_PROTOTYPE(void std_err, (const char *_s));
_PROTOTYPE(void prints, (const char *_s, ...));
_PROTOTYPE(int fsversion, (char *_dev, char *_prog));
_PROTOTYPE(int getprocessor, (void));
_PROTOTYPE(void _cpuid, (u32_t *eax, u32_t *ebx, u32_t *ecx, u32_t *edx));
_PROTOTYPE(int load_mtab, (char *_prog_name));
_PROTOTYPE(int rewrite_mtab, (char *_prog_name));
_PROTOTYPE(int get_mtab_entry, (char *_s1, char *_s2, char *_s3, char *_s4));
_PROTOTYPE(int put_mtab_entry, (char *_s1, char *_s2, char *_s3, char *_s4));
/* read_tsc() and friends */
_PROTOTYPE(void read_tsc, (u32_t *hi, u32_t *lo));
_PROTOTYPE(void read_tsc_64, (u64_t *t));
/* return values for fsversion */
#define FSVERSION_MFS1 0x00001
#define FSVERSION_MFS2 0x00002
#define FSVERSION_MFS3 0x00003
#define FSVERSION_EXT2 0x10002
#endif
+156
View File
@@ -0,0 +1,156 @@
#ifndef _MTHREAD_H
#define _MTHREAD_H
#include <minix/config.h> /* MUST be first */
#include <minix/ansi.h> /* MUST be second */
#include <minix/const.h>
#include <sys/types.h>
#include <stdio.h>
#include <ucontext.h>
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#ifdef __NBSD_LIBC
#include <sys/signal.h>
#endif
typedef int mthread_thread_t;
typedef int mthread_once_t;
typedef int mthread_key_t;
typedef void * mthread_condattr_t;
typedef void * mthread_mutexattr_t;
struct __mthread_tcb;
typedef struct {
struct __mthread_tcb *mq_head;
struct __mthread_tcb *mq_tail;
} mthread_queue_t;
struct __mthread_mutex {
mthread_queue_t mm_queue; /* Queue of threads blocked on this mutex */
mthread_thread_t mm_owner; /* Thread ID that currently owns mutex */
#ifdef MTHREAD_STRICT
struct __mthread_mutex *mm_prev;
struct __mthread_mutex *mm_next;
#endif
unsigned int mm_magic;
};
typedef struct __mthread_mutex *mthread_mutex_t;
struct __mthread_cond {
struct __mthread_mutex *mc_mutex; /* Associate mutex with condition */
#ifdef MTHREAD_STRICT
struct __mthread_cond *mc_prev;
struct __mthread_cond *mc_next;
#endif
unsigned int mc_magic;
};
typedef struct __mthread_cond *mthread_cond_t;
struct __mthread_attr {
size_t ma_stacksize;
char *ma_stackaddr;
int ma_detachstate;
struct __mthread_attr *ma_prev;
struct __mthread_attr *ma_next;
};
typedef struct __mthread_attr *mthread_attr_t;
typedef struct {
mthread_mutex_t mutex;
mthread_cond_t cond;
} mthread_event_t;
typedef struct {
unsigned int readers;
mthread_thread_t writer;
mthread_mutex_t queue;
mthread_event_t drain;
} mthread_rwlock_t;
#define MTHREAD_CREATE_JOINABLE 001
#define MTHREAD_CREATE_DETACHED 002
#define MTHREAD_ONCE_INIT 0
#define MTHREAD_STACK_MIN MINSIGSTKSZ
#define MTHREAD_KEYS_MAX 128
/* allocate.c */
_PROTOTYPE( int mthread_create, (mthread_thread_t *thread,
mthread_attr_t *tattr,
void *(*proc)(void *), void *arg) );
_PROTOTYPE( int mthread_detach, (mthread_thread_t thread) );
_PROTOTYPE( int mthread_equal, (mthread_thread_t l, mthread_thread_t r) );
_PROTOTYPE( void mthread_exit, (void *value) );
_PROTOTYPE( int mthread_join, (mthread_thread_t thread, void **value) );
_PROTOTYPE( int mthread_once, (mthread_once_t *once,
void (*proc)(void)) );
_PROTOTYPE( mthread_thread_t mthread_self, (void) );
/* attribute.c */
_PROTOTYPE( int mthread_attr_destroy, (mthread_attr_t *tattr) );
_PROTOTYPE( int mthread_attr_getdetachstate, (mthread_attr_t *tattr,
int *detachstate) );
_PROTOTYPE( int mthread_attr_getstack, (mthread_attr_t *tattr,
void **stackaddr,
size_t *stacksize) );
_PROTOTYPE( int mthread_attr_getstacksize, (mthread_attr_t *tattr,
size_t *stacksize) );
_PROTOTYPE( int mthread_attr_init, (mthread_attr_t *tattr) );
_PROTOTYPE( int mthread_attr_setdetachstate, (mthread_attr_t *tattr,
int detachstate) );
_PROTOTYPE( int mthread_attr_setstack, (mthread_attr_t *tattr,
void *stackaddr,
size_t stacksize) );
_PROTOTYPE( int mthread_attr_setstacksize, (mthread_attr_t *tattr,
size_t stacksize) );
/* condition.c */
_PROTOTYPE( int mthread_cond_broadcast, (mthread_cond_t *cond) );
_PROTOTYPE( int mthread_cond_destroy, (mthread_cond_t *cond) );
_PROTOTYPE( int mthread_cond_init, (mthread_cond_t *cond,
mthread_condattr_t *cattr) );
_PROTOTYPE( int mthread_cond_signal, (mthread_cond_t *cond) );
_PROTOTYPE( int mthread_cond_wait, (mthread_cond_t *cond,
mthread_mutex_t *mutex) );
/* key.c */
_PROTOTYPE( int mthread_key_create, (mthread_key_t *key,
void (*destructor)(void *)) );
_PROTOTYPE( int mthread_key_delete, (mthread_key_t key) );
_PROTOTYPE( void *mthread_getspecific, (mthread_key_t key) );
_PROTOTYPE( int mthread_setspecific, (mthread_key_t key, void *value) );
/* misc.c */
_PROTOTYPE( void mthread_stats, (void) );
_PROTOTYPE( void mthread_verify_f, (char *f, int l) );
#define mthread_verify() mthread_verify_f(__FILE__, __LINE__)
/* mutex.c */
_PROTOTYPE( int mthread_mutex_destroy, (mthread_mutex_t *mutex) );
_PROTOTYPE( int mthread_mutex_init, (mthread_mutex_t *mutex,
mthread_mutexattr_t *mattr) );
_PROTOTYPE( int mthread_mutex_lock, (mthread_mutex_t *mutex) );
_PROTOTYPE( int mthread_mutex_trylock, (mthread_mutex_t *mutex) );
_PROTOTYPE( int mthread_mutex_unlock, (mthread_mutex_t *mutex) );
/* event.c */
_PROTOTYPE( int mthread_event_destroy, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_init, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_wait, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_fire, (mthread_event_t *event) );
_PROTOTYPE( int mthread_event_fire_all, (mthread_event_t *event));
/* rwlock.c */
_PROTOTYPE( int mthread_rwlock_destroy, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_init, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_rdlock, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_wrlock, (mthread_rwlock_t *rwlock) );
_PROTOTYPE( int mthread_rwlock_unlock, (mthread_rwlock_t *rwlock) );
/* schedule.c */
_PROTOTYPE( void mthread_init, (void) );
_PROTOTYPE( int mthread_yield, (void) );
_PROTOTYPE( void mthread_yield_all, (void) );
#endif
+14
View File
@@ -0,0 +1,14 @@
/* Prototypes and definitions for network drivers. */
#ifndef _MINIX_NETDRIVER_H
#define _MINIX_NETDRIVER_H
#include <minix/endpoint.h>
#include <minix/ipc.h>
/* Functions defined by netdriver.c: */
_PROTOTYPE( void netdriver_announce, (void) );
_PROTOTYPE( int netdriver_receive, (endpoint_t src, message *m_ptr,
int *status_ptr) );
#endif /* _MINIX_NETDRIVER_H */
+30
View File
@@ -0,0 +1,30 @@
#ifndef _MINIX_OPTSET_H
#define _MINIX_OPTSET_H
typedef enum {
OPT_BOOL,
OPT_STRING,
OPT_INT
} optset_type;
/* An entry for the parser of an options set. The 'os_name' field must point
* to a string, which is treated case-insensitively; the last entry of a table
* must have NULL name. The 'os_type' field must be set to one of the OPT_
* values defined above. The 'os_ptr' field must point to the field that is to
* receive the value of a recognized option. For OPT_STRING, it must point to a
* string of a size set in 'os_val'; the resulting string may be truncated, but
* will always be null-terminated. For OPT_BOOL, it must point to an int which
* will be set to the value in 'os_val' if the option is present. For OPT_INT,
* it must point to an int which will be set to the provided option value;
* 'os_val' is then a base passed to strtol().
*/
struct optset {
char *os_name;
optset_type os_type;
void *os_ptr;
int os_val;
};
_PROTOTYPE( void optset_parse, (struct optset *table, char *string) );
#endif /* _MINIX_OPTSET_H */
+25
View File
@@ -0,0 +1,25 @@
/* minix/partition.h Author: Kees J. Bot
* 7 Dec 1995
* Place of a partition on disk and the disk geometry,
* for use with the DIOCGETP and DIOCSETP ioctl's.
*/
#ifndef _MINIX__PARTITION_H
#define _MINIX__PARTITION_H
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#include <minix/u64.h>
int minix_sizeup(char *name, u64_t *bytes);
struct partition {
u64_t base; /* byte offset to the partition start */
u64_t size; /* number of bytes in the partition */
unsigned cylinders; /* disk geometry */
unsigned heads;
unsigned sectors;
};
#endif /* _MINIX__PARTITION_H */
+20
View File
@@ -0,0 +1,20 @@
#ifndef _MINIX_PATHS_H_
#define _MINIX_PATHS_H_
#define _PATH_SERVICE "/bin/service"
#define _PATH_PROC "/proc/"
#define _PATH_SYSTEM_CONF "/etc/system.conf"
#define _PATH_SYSTEM_CONF_DIR "/etc/system.conf.d"
#define _PATH_SYSTEM_CONF_PKG_DIR "/usr/pkg/etc/system.conf.d"
#define _PATH_DHCPCONF "/etc/dhcp.conf"
#define _PATH_DHCPPID "/usr/run/dhcpd.pid"
#define _PATH_DHCPCACHE "/usr/adm/dhcp.cache"
#define _PATH_DHCPPOOL "/usr/adm/dhcp.pool"
#define _PATH_MOTD "/etc/motd"
#define _PATH_RAMDISK "/dev/ram"
#endif /* _MINIX_PATHS_H_ */
+23
View File
@@ -0,0 +1,23 @@
/*
minix/portio.h
Created: Jan 15, 1992 by Philip Homburg
*/
#ifndef _PORTIO_H_
#define _PORTIO_H_
#ifndef _TYPES_H
#include <minix/types.h>
#endif
unsigned inb(u16_t _port);
unsigned inw(u16_t _port);
unsigned inl(u16_t _port);
void outb(u16_t _port, u8_t _value);
void outw(u16_t _port, u16_t _value);
void outl(u16_t _port, u32_t _value);
void intr_disable(void);
void intr_enable(void);
#endif /* _PORTIO_H_ */
+99
View File
@@ -0,0 +1,99 @@
/* Privilege-related definitions. */
#ifndef _MINIX_PRIV_H
#define _MINIX_PRIV_H
#include <minix/com.h>
#include <minix/config.h>
/* Static privilege id definitions. */
#define NR_STATIC_PRIV_IDS NR_BOOT_PROCS
#define is_static_priv_id(id) (id >= 0 && id < NR_STATIC_PRIV_IDS)
#define static_priv_id(n) (NR_TASKS + (n))
/* Unprivileged user processes all share the privilege structure of the
* user processesess.
* This id must be fixed because it is used to check send mask entries.
*/
#define USER_PRIV_ID static_priv_id(ROOT_USR_PROC_NR)
/* Specifies a null privilege id.
*/
#define NULL_PRIV_ID (-1)
/* Allowed targets. */
#define NO_M (-1) /* no targets allowed */
#define ALL_M (-2) /* all targets allowed */
/* Allowed calls. */
#define NO_C (-1) /* no calls allowed */
#define ALL_C (-2) /* all calls allowed */
#define NULL_C (-3) /* null call entry */
/*
* Default privilege settings used in the system
*/
/* privilege flags */
#define IDL_F (SYS_PROC | BILLABLE) /* idle task is not preemptible as we
* don't want it to interfere with the
* timer tick interrupt handler code.
* Unlike other processes idle task is
* handled in a special way and is
* preempted always if timer tick occurs
* and there is another runnable process
*/
#define TSK_F (SYS_PROC) /* other kernel tasks */
#define SRV_F (SYS_PROC | PREEMPTIBLE) /* system services */
#define DSRV_F (SRV_F | DYN_PRIV_ID) /* dynamic system services */
#define RSYS_F (SRV_F | ROOT_SYS_PROC) /* root sys proc */
#define VM_F (SYS_PROC | VM_SYS_PROC) /* vm */
#define USR_F (BILLABLE | PREEMPTIBLE) /* user processes */
#define IMM_F (ROOT_SYS_PROC | VM_SYS_PROC | PREEMPTIBLE) /* immutable */
/* allowed traps */
#define CSK_T (1 << RECEIVE) /* clock and system */
#define TSK_T 0 /* other kernel tasks */
#define SRV_T (~0) /* system services */
#define DSRV_T (~0) /* dynamic system services */
#define USR_T (1 << SENDREC) /* user processes */
/* allowed targets */
#define TSK_M NO_M /* all kernel tasks */
#define SRV_M ALL_M /* system services */
#define DSRV_M ALL_M /* dynamic system services */
#define USR_M ALL_M /* user processes */
/* allowed kernel calls */
#define TSK_KC NO_C /* all kernel tasks */
#define SRV_KC ALL_C /* dynamic system services */
#define DSRV_KC ALL_C /* default sys proc */
#define USR_KC NO_C /* user processes */
/* allowed vm calls */
#define SRV_VC ALL_C /* dynamic system services */
#define DSRV_VC ALL_C /* default sys proc */
#define USR_VC ALL_C /* user processes */
/* signal manager */
#define SRV_SM ROOT_SYS_PROC_NR /* system services */
#define DSRV_SM ROOT_SYS_PROC_NR /* dynamic system services */
#define USR_SM PM_PROC_NR /* user processes */
/* scheduler */
#define SRV_SCH KERNEL /* system services */
#define DSRV_SCH SCHED_PROC_NR /* dynamic system services */
#define USR_SCH NONE /* user processes */
/* scheduling priority queue. */
#define SRV_Q USER_Q /* system services */
#define DSRV_Q USER_Q /* dynamic system services */
#define USR_Q USER_Q /* user processes */
/* scheduling quantum. */
#define SRV_QT USER_QUANTUM /* system services */
#define DSRV_QT USER_QUANTUM /* dynamic system services */
#define USR_QT USER_QUANTUM /* user processes */
/* default CPU */
#define DSRV_CPU USER_DEFAULT_CPU
#endif /* _MINIX_PRIV_H */
+42
View File
@@ -0,0 +1,42 @@
#ifndef _MINIX_PROCFS_H
#define _MINIX_PROCFS_H
/* The compatibility model is as follows. The current format should be retained
* for as long as possible; new fields can be added at the end of the line,
* because ps/top only read as much as they know of from the start of the line.
* Once fields (really) have to be removed, or the whole line becomes too big
* of a mess, a completely new format string can be put in, but with an
* increased PSINFO_VERSION at the beginning. That way, older ps/top copies
* will not misinterpret the new fields, but rather fail cleanly.
*/
#define PSINFO_VERSION 0
/* Process types. */
#define TYPE_TASK 'T'
#define TYPE_SYSTEM 'S'
#define TYPE_USER 'U'
/* General process states. */
#define STATE_SLEEP 'S'
#define STATE_WAIT 'W'
#define STATE_ZOMBIE 'Z'
#define STATE_RUN 'R'
#define STATE_STOP 'T'
/* PM sleep states. */
#define PSTATE_NONE '-'
#define PSTATE_PAUSED 'P'
#define PSTATE_WAITING 'W'
#define PSTATE_SIGSUSP 'S'
/* VFS block states. */
#define FSTATE_NONE '-'
#define FSTATE_PIPE 'P'
#define FSTATE_LOCK 'L'
#define FSTATE_POPEN 'O'
#define FSTATE_SELECT 'S'
#define FSTATE_DOPEN 'D'
#define FSTATE_TASK 'T'
#define FSTATE_UNKNOWN '?'
#endif /* _MINIX_PROCFS_H */
+109
View File
@@ -0,0 +1,109 @@
#ifndef _PROFILE_H
#define _PROFILE_H
#include <minix/ansi.h>
#include <minix/type.h>
/*
* Types relating to system profiling. Types are supplied for both
* statistical profiling and call profiling.
*/
# define PROF_START 0 /* start statistical profiling */
# define PROF_STOP 1 /* stop statistical profiling */
#define PROF_RTC 0 /* RTC based profiling */
#define PROF_NMI 1 /* NMI based profiling, profiles kernel too */
/* Info struct to be copied to from kernel to user program. */
struct sprof_info_s {
int mem_used;
int total_samples;
int idle_samples;
int system_samples;
int user_samples;
} sprof_info_inst;
/* What a profiling sample looks like (used for sizeof()). */
struct sprof_sample {
endpoint_t proc;
void * pc;
};
struct sprof_proc {
endpoint_t proc;
char name[8];
};
#include <minix/types.h>
# define PROF_GET 2 /* get call profiling tables */
# define PROF_RESET 3 /* reset call profiling tables */
/* Hash table size in each profiled process is table size + index size.
*
* Table size = CPROF_TABLE_SIZE * (CPROF_CPATH_MAX_LEN + 16).
* Index size = CPROF_INDEX_SIZE * 4;
*
* Making CPROF_CPATH_MAX_LEN too small may cause call path overruns.
* Making CPROF_TABLE_SIZE too small may cause table overruns.
*
* There are some restrictions: processes in the boot image are loaded
* below 16 MB and the kernel is loaded in lower memory (below 640 kB). The
* latter is reason to use a different size for the kernel table.
*/
#define CPROF_TABLE_SIZE_OTHER 3000 /* nr of slots in hash table */
#define CPROF_TABLE_SIZE_KERNEL 1500 /* kernel has a smaller table */
#define CPROF_CPATH_MAX_LEN 256 /* len of cpath string field: */
/* MUST BE MULTIPLE OF WORDSIZE */
#define CPROF_INDEX_SIZE (10*1024)/* size of index to hash table */
#define CPROF_STACK_SIZE 24 /* size of call stack */
#define CPROF_PROCNAME_LEN 8 /* len of proc name field */
#define CPROF_CPATH_OVERRUN 0x1 /* call path overrun */
#define CPROF_STACK_OVERRUN 0x2 /* call stack overrun */
#define CPROF_TABLE_OVERRUN 0x4 /* hash table overrun */
#define CPROF_ANNOUNCE_OTHER 1 /* processes announce their profiling
* data on n-th entry of procentry */
#define CPROF_ACCOUNCE_KERNEL 10000 /* kernel announces not directly */
/* Prototype for function called by procentry to get size of table. */
_PROTOTYPE(int profile_get_tbl_size, (void) );
/* Prototype for function called by procentry to get announce number. */
_PROTOTYPE(int profile_get_announce, (void) );
/* Prototype for function called by procentry to announce control struct
* and table locations to the kernel. */
_PROTOTYPE(void profile_register, (void *ctl_ptr, void *tbl_ptr) );
/* Info struct to be copied from kernel to user program. */
struct cprof_info_s {
int mem_used;
int err;
} cprof_info_inst;
/* Data structures for control structure and profiling data table in the
* in the profiled processes.
*/
struct cprof_ctl_s {
int reset; /* kernel sets to have table reset */
int slots_used; /* proc writes nr slots used in table */
int err; /* proc writes errors that occurred */
} cprof_ctl_inst;
struct cprof_tbl_s {
struct cprof_tbl_s *next; /* next in chain */
char cpath[CPROF_CPATH_MAX_LEN]; /* string with call path */
int calls; /* nr of executions of path */
u64_t cycles; /* execution time of path, in cycles */
} cprof_tbl_inst;
_PROTOTYPE( int sprofile, (int action, int size, int freq, int type,
void *ctl_ptr, void *mem_ptr) );
_PROTOTYPE( int cprofile, (int action, int size, void *ctl_ptr,
void *mem_ptr) );
#endif /* PROFILE_H */
+45
View File
@@ -0,0 +1,45 @@
/* queryparam.h - query program parameters Author: Kees J. Bot
* 22 Apr 1994
*/
#ifndef _MINIX__QUERYPARAM_H
#define _MINIX__QUERYPARAM_H
#include <minix/ansi.h>
typedef size_t _mnx_size_t;
struct export_param_list {
char *name; /* "variable", "[", ".field", or NULL. */
void *offset; /* Address of a variable or field offset. */
size_t size; /* Size of the resulting object. */
};
struct export_params {
struct export_param_list *list; /* List of exported parameters. */
struct export_params *next; /* Link several sets of parameters. */
};
#ifdef __STDC__
#define qp_stringize(var) #var
#define qp_dotstringize(var) "." #var
#else
#define qp_stringize(var) "var"
#define qp_dotstringize(var) ".var"
#endif
#define QP_VARIABLE(var) { qp_stringize(var), &(var), sizeof(var) }
#define QP_ARRAY(var) { "[", 0, sizeof((var)[0]) }
#define QP_VECTOR(var,ptr,len) { qp_stringize(var), &(ptr), -1 },\
{ "[", &(len), sizeof(*(ptr)) }
#define QP_FIELD(field, type) { qp_dotstringize(field), \
(void *)offsetof(type, field), \
sizeof(((type *)0)->field) }
#define QP_END() { 0, 0, 0 }
void qp_export _ARGS((struct export_params *_ex_params));
int queryparam _ARGS((int (*_qgetc) _ARGS((void)), void **_paddress,
_mnx_size_t *_psize));
_mnx_size_t paramvalue _ARGS((char **_value, void *_address,
_mnx_size_t _size));
#endif /* _MINIX__QUERYPARAM_H */
/* $PchId: queryparam.h,v 1.1 2005/06/28 14:31:26 philip Exp $ */
+123
View File
@@ -0,0 +1,123 @@
#ifndef RS_H
#define RS_H
/*
minix/rs.h
Interface to the reincarnation server
*/
#include <minix/bitmap.h>
#include <minix/com.h>
#define SERVICE_LOGIN "service" /* passwd file entry for services */
/* RSS definitions. */
#define RSS_NR_IRQ 16
#define RSS_NR_IO 16
#define RSS_IRQ_ALL (RSS_NR_IRQ+1)
#define RSS_IO_ALL (RSS_NR_IO+1)
#define RSS_IPC_ALL "IPC_ALL"
#define RSS_IPC_ALL_SYS "IPC_ALL_SYS"
/* RSS flags. */
#define RSS_COPY 0x01 /* keep an in-memory copy of the binary */
#define RSS_REUSE 0x04 /* Try to reuse previously copied binary */
#define RSS_NOBLOCK 0x08 /* unblock caller immediately */
#define RSS_REPLICA 0x10 /* keep a replica of the service */
#define RSS_SELF_LU 0x20 /* perform self update */
#define RSS_SYS_BASIC_CALLS 0x40 /* include basic kernel calls */
#define RSS_VM_BASIC_CALLS 0x80 /* include basic vm calls */
/* Common definitions. */
#define RS_NR_CONTROL 8
#define RS_NR_PCI_DEVICE 32
#define RS_NR_PCI_CLASS 4
#define RS_MAX_LABEL_LEN 16
/* CPU special values */
#define RS_CPU_DEFAULT -1 /* use the default cpu or do not change the current one */
#define RS_CPU_BSP -2 /* use the bootstrap cpu */
/* Labels are copied over separately. */
struct rss_label
{
char *l_addr;
size_t l_len;
};
/* Arguments needed to start a new driver or server */
struct rs_start
{
unsigned rss_flags;
char *rss_cmd;
size_t rss_cmdlen;
uid_t rss_uid;
endpoint_t rss_sigmgr;
endpoint_t rss_scheduler;
int rss_priority;
int rss_quantum;
int rss_major;
int rss_dev_style;
long rss_period;
char *rss_script;
size_t rss_scriptlen;
int rss_nr_irq;
int rss_irq[RSS_NR_IRQ];
int rss_nr_io;
struct { unsigned base; unsigned len; } rss_io[RSS_NR_IO];
int rss_nr_pci_id;
struct { u16_t vid; u16_t did; } rss_pci_id[RS_NR_PCI_DEVICE];
int rss_nr_pci_class;
struct { u32_t pciclass; u32_t mask; } rss_pci_class[RS_NR_PCI_CLASS];
bitchunk_t rss_system[SYS_CALL_MASK_SIZE];
struct rss_label rss_label;
char *rss_ipc;
size_t rss_ipclen;
bitchunk_t rss_vm[VM_CALL_MASK_SIZE];
int rss_nr_control;
struct rss_label rss_control[RS_NR_CONTROL];
int devman_id;
/*
* SMP specific data
*
* must be at the end of the structure for binary compatibility with
* non-smp sysytems
*/
int rss_cpu;
};
/* ACL information for access to PCI devices */
struct rs_pci
{
char rsp_label[RS_MAX_LABEL_LEN];
int rsp_endpoint;
int rsp_nr_device;
struct { u16_t vid; u16_t did; } rsp_device[RS_NR_PCI_DEVICE];
int rsp_nr_class;
struct { u32_t pciclass; u32_t mask; } rsp_class[RS_NR_PCI_CLASS];
};
/* Definition of a public entry of the system process table. */
struct rprocpub {
short in_use; /* set when the entry is in use */
unsigned sys_flags; /* sys flags */
endpoint_t endpoint; /* process endpoint number */
int dev_flags; /* device flags */
dev_t dev_nr; /* major device number */
int dev_style; /* device style */
int dev_style2; /* device style for next major dev number */
char label[RS_MAX_LABEL_LEN]; /* label of this service */
char proc_name[RS_MAX_LABEL_LEN]; /* process name of this service */
bitchunk_t vm_call_mask[VM_CALL_MASK_SIZE]; /* vm call mask */
struct rs_pci pci_acl; /* pci acl */
int devman_id;
};
_PROTOTYPE( int minix_rs_lookup, (const char *name, endpoint_t *value));
#endif
+90
View File
@@ -0,0 +1,90 @@
#ifndef _MINIX_SAFECOPIES_H
#define _MINIX_SAFECOPIES_H 1
#include <minix/sys_config.h>
#include <minix/types.h>
#include <minix/vm.h>
#include <stdint.h>
typedef struct {
int cp_flags; /* CPF_* below */
union {
struct {
/* CPF_DIRECT */
endpoint_t cp_who_to; /* grantee */
vir_bytes cp_start; /* memory */
size_t cp_len; /* size in bytes */
char cp_reserved[8]; /* future use */
} cp_direct;
struct {
/* CPF_INDIRECT */
endpoint_t cp_who_to; /* grantee */
endpoint_t cp_who_from; /* previous granter */
cp_grant_id_t cp_grant; /* previous grant */
char cp_reserved[8];/* future use */
} cp_indirect;
struct {
/* CPF_MAGIC */
endpoint_t cp_who_from; /* granter */
endpoint_t cp_who_to; /* grantee */
vir_bytes cp_start; /* memory */
size_t cp_len; /* size in bytes */
char cp_reserved[8]; /* future use */
} cp_magic;
} cp_u;
char cp_reserved[8]; /* future use */
} cp_grant_t;
/* Vectored safecopy. */
struct vscp_vec {
/* Exactly one of the following must be SELF. */
endpoint_t v_from; /* source */
endpoint_t v_to; /* destination */
cp_grant_id_t v_gid; /* grant id of other process */
size_t v_offset; /* offset in other grant */
vir_bytes v_addr; /* address in copier's space */
size_t v_bytes; /* no. of bytes */
};
/* Invalid grant number. */
#define GRANT_INVALID ((cp_grant_id_t) -1)
#define GRANT_VALID(g) ((g) > GRANT_INVALID)
/* Operations: any combination is ok. */
#define CPF_READ 0x000001 /* Granted process may read. */
#define CPF_WRITE 0x000002 /* Granted process may write. */
#define CPF_MAP 0x000004 /* Granted process may map. */
/* Internal flags. */
#define CPF_USED 0x000100 /* Grant slot in use. */
#define CPF_DIRECT 0x000200 /* Grant from this process to another. */
#define CPF_INDIRECT 0x000400 /* Grant from grant to another. */
#define CPF_MAGIC 0x000800 /* Grant from any to any. */
#define CPF_VALID 0x001000 /* Grant slot contains valid grant. */
/* Prototypes for functions in libsys. */
_PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int));
_PROTOTYPE( cp_grant_id_t cpf_grant_indirect, (endpoint_t, endpoint_t, cp_grant_id_t));
_PROTOTYPE( cp_grant_id_t cpf_grant_magic, (endpoint_t, endpoint_t, vir_bytes, size_t, int));
_PROTOTYPE( int cpf_revoke, (cp_grant_id_t grant_id));
_PROTOTYPE( int cpf_lookup, (cp_grant_id_t g, endpoint_t *ep, endpoint_t *ep2));
_PROTOTYPE( int cpf_getgrants, (cp_grant_id_t *grant_ids, int n));
_PROTOTYPE( int cpf_setgrant_direct, (cp_grant_id_t g, endpoint_t who,
vir_bytes addr, size_t size, int access));
_PROTOTYPE( int cpf_setgrant_indirect, (cp_grant_id_t g, endpoint_t who_to,
endpoint_t who_from, cp_grant_id_t his_g));
_PROTOTYPE( int cpf_setgrant_magic, (cp_grant_id_t g, endpoint_t who_to,
endpoint_t who_from, vir_bytes addr, size_t bytes, int access));
_PROTOTYPE( int cpf_setgrant_disable, (cp_grant_id_t grant_id));
_PROTOTYPE( void cpf_reload, (void));
/* Set a process' grant table location and size (in-kernel only). */
#define _K_SET_GRANT_TABLE(rp, ptr, entries) \
priv(rp)->s_grant_table= (ptr); \
priv(rp)->s_grant_entries= (entries);
#endif /* _MINIX_SAFECOPIES_H */
+14
View File
@@ -0,0 +1,14 @@
#ifndef _MINIX_SCHED_H
#define _MINIX_SCHED_H
#include <minix/ipc.h>
_PROTOTYPE(int sched_stop, (endpoint_t scheduler_e, endpoint_t schedulee_e));
_PROTOTYPE(int sched_start, (endpoint_t scheduler_e, endpoint_t schedulee_e,
endpoint_t parent_e, int maxprio, int quantum, int cpu,
endpoint_t *newscheduler_e));
_PROTOTYPE(int sched_inherit, (endpoint_t scheduler_e,
endpoint_t schedulee_e, endpoint_t parent_e, unsigned maxprio,
endpoint_t *newscheduler_e));
#endif /* _MINIX_SCHED_H */
+241
View File
@@ -0,0 +1,241 @@
/* Prototypes for System Event Framework (SEF) functions. */
#ifndef _SEF_H
#define _SEF_H
#include <minix/ipc.h>
/* SEF entry points for system processes. */
_PROTOTYPE( void sef_startup, (void) );
_PROTOTYPE( int sef_receive_status, (endpoint_t src, message *m_ptr,
int *status_ptr) );
_PROTOTYPE( void sef_exit, (int status) );
#define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL)
/* SEF Debug. */
#include <stdio.h>
#define sef_dprint printf
#define sef_debug_begin() (void)(NULL)
#define sef_debug_end() (void)(NULL)
/*===========================================================================*
* SEF Init *
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_INIT_REQUESTS 1
#define IS_SEF_INIT_REQUEST(mp) ((mp)->m_type == RS_INIT \
&& (mp)->m_source == RS_PROC_NR)
/* Type definitions. */
typedef struct {
cp_grant_id_t rproctab_gid;
endpoint_t endpoint;
endpoint_t old_endpoint;
} sef_init_info_t;
/* Callback type definitions. */
typedef int(*sef_cb_init_t)(int type, sef_init_info_t *info);
typedef int(*sef_cb_init_response_t)(message *m_ptr);
/* Callback registration helpers. */
_PROTOTYPE( void sef_setcb_init_fresh, (sef_cb_init_t cb));
_PROTOTYPE( void sef_setcb_init_lu, (sef_cb_init_t cb));
_PROTOTYPE( void sef_setcb_init_restart, (sef_cb_init_t cb));
_PROTOTYPE( void sef_setcb_init_response, (sef_cb_init_response_t cb) );
/* Predefined callback implementations. */
_PROTOTYPE( int sef_cb_init_null, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_response_null, (message *m_ptr) );
_PROTOTYPE( int sef_cb_init_fail, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_reset, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_crash, (int type, sef_init_info_t *info) );
_PROTOTYPE( int sef_cb_init_response_rs_reply, (message *m_ptr) );
/* Macros for predefined callback implementations. */
#define SEF_CB_INIT_FRESH_NULL sef_cb_init_null
#define SEF_CB_INIT_LU_NULL sef_cb_init_null
#define SEF_CB_INIT_RESTART_NULL sef_cb_init_null
#define SEF_CB_INIT_RESPONSE_NULL sef_cb_init_response_null
#define SEF_CB_INIT_FRESH_DEFAULT sef_cb_init_null
#define SEF_CB_INIT_LU_DEFAULT sef_cb_init_null
#define SEF_CB_INIT_RESTART_DEFAULT sef_cb_init_reset
#define SEF_CB_INIT_RESPONSE_DEFAULT sef_cb_init_response_rs_reply
/* Init types. */
#define SEF_INIT_FRESH 0 /* init fresh */
#define SEF_INIT_LU 1 /* init after live update */
#define SEF_INIT_RESTART 2 /* init after restart */
/* Debug. */
#define SEF_INIT_DEBUG_DEFAULT 0
#ifndef SEF_INIT_DEBUG
#define SEF_INIT_DEBUG SEF_INIT_DEBUG_DEFAULT
#endif
#define sef_init_dprint sef_dprint
#define sef_init_debug_begin sef_debug_begin
#define sef_init_debug_end sef_debug_end
/*===========================================================================*
* SEF Ping *
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_PING_REQUESTS 1
#define IS_SEF_PING_REQUEST(mp, status) (is_ipc_notify(status) \
&& (mp)->m_source == RS_PROC_NR)
/* Callback type definitions. */
typedef void(*sef_cb_ping_reply_t)(endpoint_t source);
/* Callback registration helpers. */
_PROTOTYPE( void sef_setcb_ping_reply, (sef_cb_ping_reply_t cb));
/* Predefined callback implementations. */
_PROTOTYPE( void sef_cb_ping_reply_null, (endpoint_t source) );
_PROTOTYPE( void sef_cb_ping_reply_pong, (endpoint_t source) );
/* Macros for predefined callback implementations. */
#define SEF_CB_PING_REPLY_NULL sef_cb_ping_reply_null
#define SEF_CB_PING_REPLY_DEFAULT sef_cb_ping_reply_pong
/* Debug. */
#define SEF_PING_DEBUG_DEFAULT 0
#ifndef SEF_PING_DEBUG
#define SEF_PING_DEBUG SEF_PING_DEBUG_DEFAULT
#endif
#define sef_ping_dprint sef_dprint
#define sef_ping_debug_begin sef_debug_begin
#define sef_ping_debug_end sef_debug_end
/*===========================================================================*
* SEF Live update *
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_LU_REQUESTS 1
#define IS_SEF_LU_REQUEST(mp, status) ((mp)->m_type == RS_LU_PREPARE \
&& (mp)->m_source == RS_PROC_NR)
/* Callback type definitions. */
typedef int(*sef_cb_lu_prepare_t)(int);
typedef int(*sef_cb_lu_state_isvalid_t)(int);
typedef void(*sef_cb_lu_state_changed_t)(int, int);
typedef void(*sef_cb_lu_state_dump_t)(int);
typedef int(*sef_cb_lu_state_save_t)(int);
typedef int(*sef_cb_lu_response_t)(message *m_ptr);
/* Callback registration helpers. */
_PROTOTYPE( void sef_setcb_lu_prepare, (sef_cb_lu_prepare_t cb) );
_PROTOTYPE( void sef_setcb_lu_state_isvalid, (sef_cb_lu_state_isvalid_t cb) );
_PROTOTYPE( void sef_setcb_lu_state_changed, (sef_cb_lu_state_changed_t cb) );
_PROTOTYPE( void sef_setcb_lu_state_dump, (sef_cb_lu_state_dump_t cb) );
_PROTOTYPE( void sef_setcb_lu_state_save, (sef_cb_lu_state_save_t cb) );
_PROTOTYPE( void sef_setcb_lu_response, (sef_cb_lu_response_t cb) );
/* Predefined callback implementations. */
_PROTOTYPE( int sef_cb_lu_prepare_null, (int state) );
_PROTOTYPE( int sef_cb_lu_state_isvalid_null, (int state) );
_PROTOTYPE( void sef_cb_lu_state_changed_null, (int old_state, int state) );
_PROTOTYPE( void sef_cb_lu_state_dump_null, (int state) );
_PROTOTYPE( int sef_cb_lu_state_save_null, (int state) );
_PROTOTYPE( int sef_cb_lu_response_null, (message *m_ptr) );
_PROTOTYPE( int sef_cb_lu_prepare_always_ready, (int state) );
_PROTOTYPE( int sef_cb_lu_prepare_never_ready, (int state) );
_PROTOTYPE( int sef_cb_lu_prepare_crash, (int state) );
_PROTOTYPE( int sef_cb_lu_state_isvalid_standard, (int state) );
_PROTOTYPE( int sef_cb_lu_state_isvalid_workfree, (int state) );
_PROTOTYPE( int sef_cb_lu_response_rs_reply, (message *m_ptr) );
/* Macros for predefined callback implementations. */
#define SEF_CB_LU_PREPARE_NULL sef_cb_lu_prepare_null
#define SEF_CB_LU_STATE_ISVALID_NULL sef_cb_lu_state_isvalid_null
#define SEF_CB_LU_STATE_CHANGED_NULL sef_cb_lu_state_changed_null
#define SEF_CB_LU_STATE_DUMP_NULL sef_cb_lu_state_dump_null
#define SEF_CB_LU_STATE_SAVE_NULL sef_cb_lu_state_save_null
#define SEF_CB_LU_RESPONSE_NULL sef_cb_lu_response_null
#define SEF_CB_LU_PREPARE_DEFAULT sef_cb_lu_prepare_null
#define SEF_CB_LU_STATE_ISVALID_DEFAULT sef_cb_lu_state_isvalid_null
#define SEF_CB_LU_STATE_CHANGED_DEFAULT sef_cb_lu_state_changed_null
#define SEF_CB_LU_STATE_DUMP_DEFAULT sef_cb_lu_state_dump_null
#define SEF_CB_LU_STATE_SAVE_DEFAULT sef_cb_lu_state_save_null
#define SEF_CB_LU_RESPONSE_DEFAULT sef_cb_lu_response_rs_reply
/* Standard live update states. */
#define SEF_LU_STATE_NULL 0 /* null state */
#define SEF_LU_STATE_WORK_FREE 1 /* no work in progress */
#define SEF_LU_STATE_REQUEST_FREE 2 /* no request in progress */
#define SEF_LU_STATE_PROTOCOL_FREE 3 /* no protocol in progress */
#define SEF_LU_STATE_CUSTOM_BASE (SEF_LU_STATE_PROTOCOL_FREE+1)
#define SEF_LU_STATE_IS_STANDARD(s) ((s) > SEF_LU_STATE_NULL \
&& (s) < SEF_LU_STATE_CUSTOM_BASE)
/* Debug. */
#define SEF_LU_DEBUG_DEFAULT 1
#ifndef SEF_LU_DEBUG
#define SEF_LU_DEBUG SEF_LU_DEBUG_DEFAULT
#endif
#define sef_lu_dprint sef_dprint
#define sef_lu_debug_begin sef_debug_begin
#define sef_lu_debug_end sef_debug_end
/*===========================================================================*
* SEF Signal *
*===========================================================================*/
/* What to intercept. */
#define INTERCEPT_SEF_SIGNAL_REQUESTS 1
#define IS_SEF_SIGNAL_REQUEST(mp, status) \
(((mp)->m_type == SIGS_SIGNAL_RECEIVED && (mp)->m_source < INIT_PROC_NR) \
|| (is_ipc_notify(status) && (mp)->m_source == SYSTEM))
/* Callback type definitions. */
typedef void(*sef_cb_signal_handler_t)(int signo);
typedef int(*sef_cb_signal_manager_t)(endpoint_t target, int signo);
typedef int(*sef_cb_gcov_t)(message *msg);
/* Callback registration helpers. */
_PROTOTYPE( void sef_setcb_signal_handler, (sef_cb_signal_handler_t cb));
_PROTOTYPE( void sef_setcb_signal_manager, (sef_cb_signal_manager_t cb));
_PROTOTYPE( void sef_setcb_gcov, (sef_cb_gcov_t cb));
/* Predefined callback implementations. */
_PROTOTYPE( void sef_cb_signal_handler_null, (int signo) );
_PROTOTYPE( int sef_cb_signal_manager_null, (endpoint_t target, int signo) );
_PROTOTYPE( void sef_cb_signal_handler_term, (int signo) );
_PROTOTYPE( void sef_cb_signal_handler_posix_default, (int signo) );
/* Macros for predefined callback implementations. */
#define SEF_CB_SIGNAL_HANDLER_NULL sef_cb_signal_handler_null
#define SEF_CB_SIGNAL_MANAGER_NULL sef_cb_signal_manager_null
#define SEF_CB_SIGNAL_HANDLER_DEFAULT sef_cb_signal_handler_null
#define SEF_CB_SIGNAL_MANAGER_DEFAULT sef_cb_signal_manager_null
/* Debug. */
#define SEF_SIGNAL_DEBUG_DEFAULT 0
#ifndef SEF_SIGNAL_DEBUG
#define SEF_SIGNAL_DEBUG SEF_SIGNAL_DEBUG_DEFAULT
#endif
#define sef_signal_dprint sef_dprint
#define sef_signal_debug_begin sef_debug_begin
#define sef_signal_debug_end sef_debug_end
#if !defined(USE_LIVEUPDATE)
#undef INTERCEPT_SEF_LU_REQUESTS
#undef SEF_LU_DEBUG
#endif
#endif /* _SEF_H */
-31
View File
@@ -1,31 +0,0 @@
/* $NetBSD: sha1.h,v 1.6 2008/10/08 14:28:14 joerg Exp $ */
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*/
#ifndef _NBCOMPAT_SYS_SHA1_H_
#define _NBCOMPAT_SYS_SHA1_H_
#include <stdint.h>
#define SHA1_DIGEST_LENGTH 20
#define SHA1_DIGEST_STRING_LENGTH 41
typedef struct {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} SHA1_CTX;
void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX *context);
void SHA1Update(SHA1_CTX *context, const unsigned char *data, unsigned int len);
void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
char *SHA1End(SHA1_CTX *, char *);
char *SHA1File(char *, char *);
char *SHA1Data(const unsigned char *, size_t, char *);
#endif /* _NBCOMPAT_SYS_SHA1_H_ */
-127
View File
@@ -1,127 +0,0 @@
/* $FreeBSD: src/sys/crypto/sha2/sha2.h,v 1.1.2.1 2001/07/03 11:01:36 ume Exp $ */
/* $KAME: sha2.h,v 1.3 2001/03/12 08:27:48 itojun Exp $ */
/*
* sha2.h
*
* Version 1.0.0beta1
*
* Written by Aaron D. Gifford <me@aarongifford.com>
*
* Copyright 2000 Aaron D. Gifford. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef __SHA2_H__
#define __SHA2_H__
#define SHA2_BYTE_ORDER 0x04030201
#define SHA2_LITTLE_ENDIAN 0x04030201
#define SHA2_BIG_ENDIAN 0x01020204
#ifdef __cplusplus
extern "C" {
#endif
/*** SHA-256/384/512 Various Length Definitions ***********************/
#define SHA256_BLOCK_LENGTH 64
#define SHA256_DIGEST_LENGTH 32
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
#define SHA384_BLOCK_LENGTH 128
#define SHA384_DIGEST_LENGTH 48
#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
#define SHA512_BLOCK_LENGTH 128
#define SHA512_DIGEST_LENGTH 64
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
#ifdef __minix
#include <assert.h>
#include <string.h>
#include <sys/types.h>
#include <minix/u64.h>
typedef u8_t u_int8_t; /* 1-byte (8-bits) */
typedef u32_t u_int32_t; /* 4-bytes (32-bits) */
typedef u64_t u_int64_t; /* 8-bytes (64-bits) */
#if !defined(__LONG_LONG_SUPPORTED)
#define MINIX_64BIT 1
#endif
#define SHA2_BYTE_ORDER 0x04030201
#define SHA2_LITTLE_ENDIAN 0x04030201
#define SHA2_BIG_ENDIAN 0x01020204
#endif
/*** SHA-256/384/512 Context Structures *******************************/
typedef struct _SHA256_CTX {
u_int32_t state[8];
u_int64_t bitcount;
u_int8_t buffer[SHA256_BLOCK_LENGTH];
} SHA256_CTX;
typedef struct _SHA512_CTX {
u_int64_t state[8];
u_int64_t bitcount[2];
u_int8_t buffer[SHA512_BLOCK_LENGTH];
} SHA512_CTX;
typedef SHA512_CTX SHA384_CTX;
/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX*, const u_int8_t*, size_t);
void SHA256_Final(u_int8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const u_int8_t*, size_t, u_int8_t *);
char *SHA256_File(char *, char *);
void SHA384_Init(SHA384_CTX*);
void SHA384_Update(SHA384_CTX*, const u_int8_t*, size_t);
void SHA384_Final(u_int8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const u_int8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
char *SHA384_File(char *, char *);
void SHA512_Init(SHA512_CTX*);
void SHA512_Update(SHA512_CTX*, const u_int8_t*, size_t);
void SHA512_Final(u_int8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const u_int8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
char *SHA512_File(char *, char *);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SHA2_H__ */
/*
* $PchId: sha2.h,v 1.1 2005/06/28 14:29:33 philip Exp $
*/
+45
View File
@@ -0,0 +1,45 @@
/* Definitions used by /dev/audio and /dev/mixer.
*
* Feb 13 1995 Author: Michel R. Prevenier
*/
#ifndef SOUND_H
#define SOUND_H
/* ------- Mixer stuff ------- */
/* Available devices */
enum Device
{
Master, /* Master volume */
Dac, /* DSP, digitized sound */
Fm, /* Fm synthesized sound */
Cd, /* Compact */
Line, /* Line in */
Mic, /* Microphone */
Speaker, /* Pc speaker */
Treble, /* Treble */
Bass /* Bass */
};
enum InputState
{
ON, OFF
};
/* Volume levels range from 0 to 31, bass & treble range from 0 to 15 */
struct volume_level
{
enum Device device;
int left;
int right;
};
struct inout_ctrl
{
enum Device device;
enum InputState left;
enum InputState right;
};
#endif /* SOUND_H */
+38
View File
@@ -0,0 +1,38 @@
/* Prototypes for condition spinning helper functions (part of libsys). */
#ifndef _MINIX_SPIN_H
#define _MINIX_SPIN_H
/* Opaque spin state structure. */
typedef struct {
int s_state;
u32_t s_usecs;
u64_t s_base_tsc;
clock_t s_base_uptime;
int s_timeout;
} spin_t;
/* Functions. */
_PROTOTYPE( void spin_init, (spin_t *s, u32_t usecs) );
_PROTOTYPE( int spin_check, (spin_t *s) );
/* Macros. */
/* Execute a loop for at least 'u' microseconds, using spin object 's'.
* The body of the loop is guaranteed to be executed at least once.
*/
#define SPIN_FOR(s,u) \
for (spin_init((s), (u)); spin_check((s)); )
/* Return whether spin object 's' timed out after a loop. */
#define SPIN_TIMEOUT(s) ((s)->s_timeout)
/* Spin until the given condition becomes true, or 'u' microseconds expired.
* The condition is guaranteed to be checked at least once.
*/
#define SPIN_UNTIL(c,u) do { \
spin_t s; \
SPIN_FOR(&s,(u)) \
if (c) break; \
} while (0)
#endif /* _MINIX_SPIN_H */
+57
View File
@@ -0,0 +1,57 @@
#ifndef _MINIX_SYS_CONFIG_H
#define _MINIX_SYS_CONFIG_H 1
/*===========================================================================*
* This section contains user-settable parameters *
*===========================================================================*/
#define _MINIX_MACHINE _MACHINE_IBM_PC
#define _MACHINE_IBM_PC 1 /* any 8088 or 80x86-based system */
/* Word size in bytes (a constant equal to sizeof(int)). */
#if __ACK__ || __GNUC__
#define _WORD_SIZE _EM_WSIZE
#define _PTR_SIZE _EM_WSIZE
#endif
#define _NR_PROCS 256
#define _NR_SYS_PROCS 64
/* Set the CHIP type based on the machine selected. The symbol CHIP is actually
* indicative of more than just the CPU. For example, machines for which
* CHIP == INTEL are expected to have 8259A interrrupt controllers and the
* other properties of IBM PC/XT/AT/386 types machines in general. */
#define _CHIP_INTEL 1 /* CHIP type for PC, XT, AT, 386 and clones */
#define _CHIP_M68000 2 /* CHIP type for Atari, Amiga, Macintosh */
#define _CHIP_SPARC 3 /* CHIP type for SUN-4 (e.g. SPARCstation) */
/* Set the FP_FORMAT type based on the machine selected, either hw or sw */
#define _FP_NONE 0 /* no floating point support */
#define _FP_IEEE 1 /* conform IEEE floating point standard */
#if (_MINIX_MACHINE == _MACHINE_IBM_PC)
#define _MINIX_CHIP _CHIP_INTEL
#endif
#ifndef _MINIX_FP_FORMAT
#define _MINIX_FP_FORMAT _FP_NONE
#endif
#ifndef _MINIX_MACHINE
error "In <minix/sys_config.h> please define _MINIX_MACHINE"
#endif
#ifndef _MINIX_CHIP
error "In <minix/sys_config.h> please define _MINIX_MACHINE to have a legal value"
#endif
#if (_MINIX_MACHINE == 0)
error "_MINIX_MACHINE has incorrect value (0)"
#endif
/* Kernel debug checks */
#define DEBUG_LOCK_CHECK 1 /* Interrupt Lock/unlock sanity checking. */
#define _KMESS_BUF_SIZE 10000
#endif /* _MINIX_SYS_CONFIG_H */
+19
View File
@@ -0,0 +1,19 @@
#ifndef _MINIX_SYSINFO_H
#define _MINIX_SYSINFO_H
#include <minix/endpoint.h>
#include <minix/type.h>
_PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where,
size_t size) );
/* What system info to retrieve with sysgetinfo(). */
#define SI_PROC_TAB 2 /* copy of entire process table */
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */
#define SI_DATA_STORE 5 /* get copy of data store mappings */
#define SI_CALL_STATS 9 /* system call statistics */
#define SI_PROCPUB_TAB 11 /* copy of public entries of process table */
#endif
+277
View File
@@ -0,0 +1,277 @@
/* Prototypes for system library functions. */
#ifndef _SYSLIB_H
#define _SYSLIB_H
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#ifndef _IPC_H
#include <minix/ipc.h>
#endif
#include <minix/u64.h>
#ifndef _DEVIO_H
#include <minix/devio.h>
#endif
#include <minix/safecopies.h>
#include <minix/sef.h>
#include <machine/mcontext.h>
/* Forward declaration */
struct reg86u;
struct rs_pci;
#define SYSTASK SYSTEM
/*==========================================================================*
* Minix system library. *
*==========================================================================*/
_PROTOTYPE( int _taskcall, (endpoint_t who, int syscallnr, message *msgptr));
_PROTOTYPE( int _kernel_call, (int syscallnr, message *msgptr));
_PROTOTYPE( int sys_abort, (int how, ...));
_PROTOTYPE( int sys_enable_iop, (endpoint_t proc_ep));
_PROTOTYPE( int sys_exec, (endpoint_t proc_ep, char *ptr,
char *aout, vir_bytes initpc));
_PROTOTYPE( int sys_fork, (endpoint_t parent, endpoint_t child, endpoint_t *,
struct mem_map *ptr, u32_t vm, vir_bytes *));
_PROTOTYPE( int sys_newmap, (endpoint_t proc_ep, struct mem_map *ptr));
_PROTOTYPE( int sys_clear, (endpoint_t proc_ep));
_PROTOTYPE( int sys_exit, (void));
_PROTOTYPE( int sys_trace, (int req, endpoint_t proc_ep, long addr, long *data_p));
_PROTOTYPE( int sys_schedule, (endpoint_t proc_ep, int priority,
int quantum, int cpu));
_PROTOTYPE( int sys_schedctl, (unsigned flags, endpoint_t proc_ep,
int priority, int quantum, int cpu));
/* Shorthands for sys_runctl() system call. */
#define sys_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, 0)
#define sys_delay_stop(proc_ep) sys_runctl(proc_ep, RC_STOP, RC_DELAY)
#define sys_resume(proc_ep) sys_runctl(proc_ep, RC_RESUME, 0)
_PROTOTYPE( int sys_runctl, (endpoint_t proc_ep, int action, int flags));
_PROTOTYPE( int sys_update, (endpoint_t src_ep, endpoint_t dst_ep));
_PROTOTYPE( int sys_statectl, (int request));
_PROTOTYPE( int sys_privctl, (endpoint_t proc_ep, int req, void *p));
_PROTOTYPE( int sys_privquery_mem, (endpoint_t proc_ep,
phys_bytes physstart, phys_bytes physlen));
_PROTOTYPE( int sys_setgrant, (cp_grant_t *grants, int ngrants));
_PROTOTYPE( int sys_int86, (struct reg86u *reg86p));
_PROTOTYPE( int sys_vm_setbuf, (phys_bytes base, phys_bytes size,
phys_bytes high));
_PROTOTYPE( int sys_vm_map, (endpoint_t proc_ep, int do_map,
phys_bytes base, phys_bytes size, phys_bytes offset));
_PROTOTYPE( int sys_vmctl, (endpoint_t who, int param, u32_t value));
_PROTOTYPE( int sys_vmctl_get_cr3_i386, (endpoint_t who, u32_t *cr3) );
_PROTOTYPE( int sys_vmctl_get_memreq, (endpoint_t *who, vir_bytes *mem,
vir_bytes *len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s,
endpoint_t *) );
_PROTOTYPE( int sys_vmctl_enable_paging, (void * data));
_PROTOTYPE( int sys_readbios, (phys_bytes address, void *buf, size_t size));
_PROTOTYPE( int sys_stime, (time_t boottime));
_PROTOTYPE( int sys_sysctl, (int ctl, char *arg1, int arg2));
_PROTOTYPE( int sys_sysctl_stacktrace, (endpoint_t who));
_PROTOTYPE( int sys_vmctl_get_mapping, (int index, phys_bytes *addr,
phys_bytes *len, int *flags));
_PROTOTYPE( int sys_vmctl_reply_mapping, (int index, vir_bytes addr));
_PROTOTYPE( int sys_vmctl_set_addrspace, (endpoint_t who,
phys_bytes ptroot, void *ptroot_v));
/* Shorthands for sys_sdevio() system call. */
#define sys_insb(port, proc_ep, buffer, count) \
sys_sdevio(DIO_INPUT_BYTE, port, proc_ep, buffer, count, 0)
#define sys_insw(port, proc_ep, buffer, count) \
sys_sdevio(DIO_INPUT_WORD, port, proc_ep, buffer, count, 0)
#define sys_outsb(port, proc_ep, buffer, count) \
sys_sdevio(DIO_OUTPUT_BYTE, port, proc_ep, buffer, count, 0)
#define sys_outsw(port, proc_ep, buffer, count) \
sys_sdevio(DIO_OUTPUT_WORD, port, proc_ep, buffer, count, 0)
#define sys_safe_insb(port, ept, grant, offset, count) \
sys_sdevio(DIO_SAFE_INPUT_BYTE, port, ept, (void*)grant, count, offset)
#define sys_safe_outsb(port, ept, grant, offset, count) \
sys_sdevio(DIO_SAFE_OUTPUT_BYTE, port, ept, (void*)grant, count, offset)
#define sys_safe_insw(port, ept, grant, offset, count) \
sys_sdevio(DIO_SAFE_INPUT_WORD, port, ept, (void*)grant, count, offset)
#define sys_safe_outsw(port, ept, grant, offset, count) \
sys_sdevio(DIO_SAFE_OUTPUT_WORD, port, ept, (void*)grant, count, offset)
_PROTOTYPE( int sys_sdevio, (int req, long port, endpoint_t proc_ep,
void *buffer, int count, vir_bytes offset));
_PROTOTYPE(void *alloc_contig, (size_t len, int flags, phys_bytes *phys));
_PROTOTYPE(int free_contig, (void *addr, size_t len));
#define AC_ALIGN4K 0x01
#define AC_LOWER16M 0x02
#define AC_ALIGN64K 0x04
#define AC_LOWER1M 0x08
/* Clock functionality: get system times, (un)schedule an alarm call, or
* retrieve/set a process-virtual timer.
*/
_PROTOTYPE( int sys_times, (endpoint_t proc_ep, clock_t *user_time,
clock_t *sys_time, clock_t *uptime, time_t *boottime));
_PROTOTYPE(int sys_setalarm, (clock_t exp_time, int abs_time));
_PROTOTYPE( int sys_vtimer, (endpoint_t proc_nr, int which, clock_t *newval,
clock_t *oldval));
/* Shorthands for sys_irqctl() system call. */
#define sys_irqdisable(hook_id) \
sys_irqctl(IRQ_DISABLE, 0, 0, hook_id)
#define sys_irqenable(hook_id) \
sys_irqctl(IRQ_ENABLE, 0, 0, hook_id)
#define sys_irqsetpolicy(irq_vec, policy, hook_id) \
sys_irqctl(IRQ_SETPOLICY, irq_vec, policy, hook_id)
#define sys_irqrmpolicy(hook_id) \
sys_irqctl(IRQ_RMPOLICY, 0, 0, hook_id)
_PROTOTYPE ( int sys_irqctl, (int request, int irq_vec, int policy,
int *irq_hook_id) );
/* Shorthands for sys_vircopy() and sys_physcopy() system calls. */
#define sys_biosin(bios_vir, dst_vir, bytes) \
sys_vircopy(SELF, BIOS_SEG, bios_vir, SELF, D, dst_vir, bytes)
#define sys_biosout(src_vir, bios_vir, bytes) \
sys_vircopy(SELF, D, src_vir, SELF, BIOS_SEG, bios_vir, bytes)
#define sys_datacopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
sys_vircopy(src_proc, D, src_vir, dst_proc, D, dst_vir, bytes)
#define sys_textcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
sys_vircopy(src_proc, T, src_vir, dst_proc, T, dst_vir, bytes)
#define sys_stackcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \
sys_vircopy(src_proc, S, src_vir, dst_proc, S, dst_vir, bytes)
_PROTOTYPE(int sys_vircopy, (endpoint_t src_proc, int src_s, vir_bytes src_v,
endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
#define sys_abscopy(src_phys, dst_phys, bytes) \
sys_physcopy(NONE, PHYS_SEG, src_phys, NONE, PHYS_SEG, dst_phys, bytes)
_PROTOTYPE(int sys_physcopy, (endpoint_t src_proc, int src_seg, vir_bytes src_vir,
endpoint_t dst_proc, int dst_seg, vir_bytes dst_vir, phys_bytes bytes));
/* Grant-based copy functions. */
_PROTOTYPE(int sys_safecopyfrom, (endpoint_t source, cp_grant_id_t grant,
vir_bytes grant_offset, vir_bytes my_address, size_t bytes, int my_seg));
_PROTOTYPE(int sys_safecopyto, (endpoint_t dest, cp_grant_id_t grant,
vir_bytes grant_offset, vir_bytes my_address, size_t bytes, int my_seg));
_PROTOTYPE(int sys_vsafecopy, (struct vscp_vec *copyvec, int elements));
_PROTOTYPE(int sys_memset, (unsigned long pattern,
phys_bytes base, phys_bytes bytes));
/* Grant-based map functions. */
_PROTOTYPE(int sys_safemap, (endpoint_t grantor, cp_grant_id_t grant,
vir_bytes grant_offset, vir_bytes my_address, size_t bytes, int my_seg,
int writable));
_PROTOTYPE(int sys_saferevmap_gid, (cp_grant_id_t grant));
_PROTOTYPE(int sys_saferevmap_addr, (vir_bytes addr));
_PROTOTYPE(int sys_safeunmap, (int my_seg, vir_bytes my_address));
_PROTOTYPE(int sys_umap, (endpoint_t proc_ep, int seg, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_umap_data_fb, (endpoint_t proc_ep, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_umap_remote, (endpoint_t proc_ep, endpoint_t grantee,
int seg, vir_bytes vir_addr, vir_bytes bytes, phys_bytes *phys_addr));
/* Shorthands for sys_getinfo() system call. */
#define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0)
#define sys_getkinfo(dst) sys_getinfo(GET_KINFO, dst, 0,0,0)
#define sys_getloadinfo(dst) sys_getinfo(GET_LOADINFO, dst, 0,0,0)
#define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
#define sys_getcpuinfo(dst) sys_getinfo(GET_CPUINFO, dst, 0,0,0)
#define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0)
#define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0)
#define sys_getproc(dst,nr) sys_getinfo(GET_PROC, dst, 0,0, nr)
#define sys_getrandomness(dst) sys_getinfo(GET_RANDOMNESS, dst, 0,0,0)
#define sys_getrandom_bin(d,b) sys_getinfo(GET_RANDOMNESS_BIN, d, 0,0,b)
#define sys_getimage(dst) sys_getinfo(GET_IMAGE, dst, 0,0,0)
#define sys_getirqhooks(dst) sys_getinfo(GET_IRQHOOKS, dst, 0,0,0)
#define sys_getirqactids(dst) sys_getinfo(GET_IRQACTIDS, dst, 0,0,0)
#define sys_getmonparams(v,vl) sys_getinfo(GET_MONPARAMS, v,vl, 0,0)
#define sys_getschedinfo(v1,v2) sys_getinfo(GET_SCHEDINFO, v1,0, v2,0)
#define sys_getpriv(dst, nr) sys_getinfo(GET_PRIV, dst, 0,0, nr)
#define sys_getidletsc(dst) sys_getinfo(GET_IDLETSC, dst, 0,0,0)
#if !defined(__ELF__)
#define sys_getaoutheader(dst,nr) sys_getinfo(GET_AOUTHEADER, dst, 0,0,nr)
#endif
#define sys_getregs(dst,nr) sys_getinfo(GET_REGS, dst, 0,0, nr)
_PROTOTYPE(int sys_getinfo, (int request, void *val_ptr, int val_len,
void *val_ptr2, int val_len2) );
_PROTOTYPE(int sys_whoami, (endpoint_t *ep, char *name, int namelen,
int *priv_flags));
/* Signal control. */
_PROTOTYPE(int sys_kill, (endpoint_t proc_ep, int sig) );
_PROTOTYPE(int sys_sigsend, (endpoint_t proc_ep, struct sigmsg *sig_ctxt) );
_PROTOTYPE(int sys_sigreturn, (endpoint_t proc_ep, struct sigmsg *sig_ctxt) );
_PROTOTYPE(int sys_getksig, (endpoint_t *proc_ep, sigset_t *k_sig_map) );
_PROTOTYPE(int sys_endksig, (endpoint_t proc_ep) );
/* NOTE: two different approaches were used to distinguish the device I/O
* types 'byte', 'word', 'long': the latter uses #define and results in a
* smaller implementation, but looses the static type checking.
*/
_PROTOTYPE(int sys_voutb, (pvb_pair_t *pvb_pairs, int nr_ports) );
_PROTOTYPE(int sys_voutw, (pvw_pair_t *pvw_pairs, int nr_ports) );
_PROTOTYPE(int sys_voutl, (pvl_pair_t *pvl_pairs, int nr_ports) );
_PROTOTYPE(int sys_vinb, (pvb_pair_t *pvb_pairs, int nr_ports) );
_PROTOTYPE(int sys_vinw, (pvw_pair_t *pvw_pairs, int nr_ports) );
_PROTOTYPE(int sys_vinl, (pvl_pair_t *pvl_pairs, int nr_ports) );
/* Shorthands for sys_out() system call. */
#define sys_outb(p,v) sys_out((p), (unsigned long) (v), _DIO_BYTE)
#define sys_outw(p,v) sys_out((p), (unsigned long) (v), _DIO_WORD)
#define sys_outl(p,v) sys_out((p), (unsigned long) (v), _DIO_LONG)
_PROTOTYPE(int sys_out, (int port, unsigned long value, int type) );
/* Shorthands for sys_in() system call. */
#define sys_inb(p,v) sys_in((p), (v), _DIO_BYTE)
#define sys_inw(p,v) sys_in((p), (v), _DIO_WORD)
#define sys_inl(p,v) sys_in((p), (v), _DIO_LONG)
_PROTOTYPE(int sys_in, (int port, unsigned long *value, int type) );
/* pci.c */
_PROTOTYPE( void pci_init, (void) );
_PROTOTYPE( void pci_init1, (char *name) );
_PROTOTYPE( int pci_first_dev, (int *devindp, u16_t *vidp, u16_t *didp) );
_PROTOTYPE( int pci_next_dev, (int *devindp, u16_t *vidp, u16_t *didp) );
_PROTOTYPE( int pci_find_dev, (u8_t bus, u8_t dev, u8_t func,
int *devindp) );
_PROTOTYPE( void pci_reserve, (int devind) );
_PROTOTYPE( int pci_reserve_ok, (int devind) );
_PROTOTYPE( void pci_ids, (int devind, u16_t *vidp, u16_t *didp) );
_PROTOTYPE( void pci_rescan_bus, (u8_t busnr) );
_PROTOTYPE( u8_t pci_attr_r8, (int devind, int port) );
_PROTOTYPE( u16_t pci_attr_r16, (int devind, int port) );
_PROTOTYPE( u32_t pci_attr_r32, (int devind, int port) );
_PROTOTYPE( void pci_attr_w8, (int devind, int port, u8_t value) );
_PROTOTYPE( void pci_attr_w16, (int devind, int port, u16_t value) );
_PROTOTYPE( void pci_attr_w32, (int devind, int port, u32_t value) );
_PROTOTYPE( char *pci_dev_name, (u16_t vid, u16_t did) );
_PROTOTYPE( char *pci_slot_name, (int devind) );
_PROTOTYPE( int pci_set_acl, (struct rs_pci *rs_pci) );
_PROTOTYPE( int pci_del_acl, (endpoint_t proc_ep) );
_PROTOTYPE( int pci_get_bar, (int devind, int port, u32_t *base,
u32_t *size, int *ioflag) );
/* Profiling. */
_PROTOTYPE( int sys_sprof, (int action, int size, int freq, int type,
endpoint_t endpt, void *ctl_ptr, void *mem_ptr) );
_PROTOTYPE( int sys_cprof, (int action, int size, endpoint_t endpt,
void *ctl_ptr, void *mem_ptr) );
_PROTOTYPE( int sys_profbuf, (void *ctl_ptr, void *mem_ptr) );
/* machine context */
_PROTOTYPE( int sys_getmcontext, (endpoint_t proc, mcontext_t *mcp) );
_PROTOTYPE( int sys_setmcontext, (endpoint_t proc, mcontext_t *mcp) );
/* input */
_PROTOTYPE( int tty_input_inject, (int type, int code, int val) );
#endif /* _SYSLIB_H */
+94
View File
@@ -0,0 +1,94 @@
#ifndef _MINIX_SYSUTIL_H
#define _MINIX_SYSUTIL_H 1
#include <minix/ipc.h>
#include <sys/cdefs.h>
/* Extra system library definitions to support device drivers and servers.
*
* Created:
* Mar 15, 2004 by Jorrit N. Herder
*
* Changes:
* May 31, 2005: added printf, kputc (relocated from syslib)
* May 31, 2005: added getuptime
* Mar 18, 2005: added tickdelay
* Oct 01, 2004: added env_parse, env_prefix, env_panic
* Jul 13, 2004: added fkey_ctl
* Apr 28, 2004: added report, panic
* Mar 31, 2004: setup like other libraries, such as syslib
*/
/*==========================================================================*
* Miscellaneous helper functions.
*==========================================================================*/
/* Environment parsing return values. */
#define EP_BUF_SIZE 128 /* local buffer for env value */
#define EP_UNSET 0 /* variable not set */
#define EP_OFF 1 /* var = off */
#define EP_ON 2 /* var = on (or field left blank) */
#define EP_SET 3 /* var = 1:2:3 (nonblank field) */
#define EP_EGETKENV 4 /* sys_getkenv() failed ... */
extern int env_argc;
extern char **env_argv;
_PROTOTYPE( void env_setargs, (int argc, char *argv[]) );
_PROTOTYPE( int env_get_param, (char *key, char *value, int max_size) );
_PROTOTYPE( int env_prefix, (char *env, char *prefix) );
_PROTOTYPE( void env_panic, (char *key) );
_PROTOTYPE( int env_parse, (char *env, char *fmt, int field, long *param,
long min, long max) );
#define fkey_map(fkeys, sfkeys) fkey_ctl(FKEY_MAP, (fkeys), (sfkeys))
#define fkey_unmap(fkeys, sfkeys) fkey_ctl(FKEY_UNMAP, (fkeys), (sfkeys))
#define fkey_events(fkeys, sfkeys) fkey_ctl(FKEY_EVENTS, (fkeys), (sfkeys))
_PROTOTYPE( int fkey_ctl, (int req, int *fkeys, int *sfkeys) );
_PROTOTYPE( int printf, (const char *fmt, ...));
_PROTOTYPE( void kputc, (int c));
_PROTOTYPE( __dead void panic, (const char *fmt, ...));
_PROTOTYPE( int getuptime, (clock_t *ticks));
_PROTOTYPE( int getuptime2, (clock_t *ticks, time_t *boottime));
_PROTOTYPE( int tickdelay, (clock_t ticks));
_PROTOTYPE( int tsc_calibrate, (void));
_PROTOTYPE( u32_t sys_hz, (void));
_PROTOTYPE( double getidle, (void));
_PROTOTYPE( void util_stacktrace, (void));
_PROTOTYPE( void util_nstrcat, (char *str, unsigned long n) );
_PROTOTYPE( void util_stacktrace_strcat, (char *));
_PROTOTYPE( int micro_delay, (u32_t micros));
_PROTOTYPE( u32_t tsc_64_to_micros, (u64_t tsc));
_PROTOTYPE( u32_t tsc_to_micros, (u32_t low, u32_t high));
_PROTOTYPE( u32_t tsc_get_khz, (void));
_PROTOTYPE( u32_t micros_to_ticks, (u32_t micros));
_PROTOTYPE( void ser_putc, (char c));
_PROTOTYPE( void get_randomness, (struct k_randomness *, int));
_PROTOTYPE( u32_t sqrt_approx, (u32_t));
#define asynsend(ep, msg) asynsend3(ep, msg, 0)
_PROTOTYPE( int asynsend3, (endpoint_t ep, message *msg, int flags));
_PROTOTYPE( int asyn_geterror, (endpoint_t *dst, message *msg, int *err));
#define ASSERT(c) if(!(c)) { panic("%s:%d: assert %s failed", __FILE__, __LINE__, #c); }
/* timing library */
#define TIMING_CATEGORIES 20
#define TIMING_POINTS 20 /* timing resolution */
#define TIMING_CATEGORIES 20
#define TIMING_NAME 10
struct util_timingdata {
char names[TIMING_NAME];
unsigned long lock_timings[TIMING_POINTS];
unsigned long lock_timings_range[2];
unsigned long binsize, resets, misses, measurements;
unsigned long starttimes[2]; /* nonzero if running */
};
typedef struct util_timingdata util_timingdata_t;
#endif /* _MINIX_SYSUTIL_H */
+16
View File
@@ -0,0 +1,16 @@
#ifndef _MINIX_TIMERS_H
#define _MINIX_TIMERS_H
/* Timers abstraction for system processes. This would be in minix/sysutil.h
* if it weren't for naming conflicts.
*/
#include <timers.h>
_PROTOTYPE( void init_timer, (timer_t *tp));
_PROTOTYPE( void set_timer, (timer_t *tp, int ticks, tmr_func_t watchdog,
int arg));
_PROTOTYPE( void cancel_timer, (timer_t *tp));
_PROTOTYPE( void expire_timers, (clock_t now));
#endif /* _MINIX_TIMERS_H */
+28
View File
@@ -0,0 +1,28 @@
#ifndef _MINIX_TTY_H
#define _MINIX_TTY_H
#include <minix/types.h>
#define TTYMAGIC 0xb105
/* A struct that the tty driver can use to pass values to the boot monitor.
* Currently only the value of the origin of the first vty (console), so the
* boot monitor can properly display it when panicing (tty isn't scheduled
* to switch to the first vty). It's written at the end of video memory
* (video memory base + video memory size - sizeof(struct boot_tty_info).
*/
struct boot_tty_info {
u16_t reserved[30]; /* reserved, set to 0 */
u16_t consorigin; /* origin in video memory of console */
u16_t conscursor; /* position of cursor of console */
u16_t flags; /* flags indicating which fields are valid */
u16_t magic; /* magic number indicating struct is valid */
};
#define BTIF_CONSORIGIN 0x01 /* consorigin is set */
#define BTIF_CONSCURSOR 0x02 /* conscursor is set */
#endif
+211
View File
@@ -0,0 +1,211 @@
#ifndef _TYPE_H
#define _TYPE_H
#ifndef _MINIX_SYS_CONFIG_H
#include <minix/sys_config.h>
#endif
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#include <stdint.h>
/* Type definitions. */
typedef unsigned int vir_clicks; /* virtual addr/length in clicks */
typedef unsigned long phys_bytes; /* physical addr/length in bytes */
typedef unsigned int phys_clicks; /* physical addr/length in clicks */
typedef int endpoint_t; /* process identifier */
typedef int32_t cp_grant_id_t; /* A grant ID. */
#if (_MINIX_CHIP == _CHIP_INTEL)
typedef long unsigned int vir_bytes; /* virtual addresses/lengths in bytes */
#endif
#if (_MINIX_CHIP == _CHIP_M68000)
typedef unsigned long vir_bytes;/* virtual addresses and lengths in bytes */
#endif
#if (_MINIX_CHIP == _CHIP_SPARC)
typedef unsigned long vir_bytes;/* virtual addresses and lengths in bytes */
#endif
/* Memory map for local text, stack, data segments. */
struct mem_map {
vir_clicks mem_vir; /* virtual address */
phys_clicks mem_phys; /* physical address */
vir_clicks mem_len; /* length */
};
/* Memory map for remote memory areas, e.g., for the RAM disk. */
struct far_mem {
int in_use; /* entry in use, unless zero */
phys_clicks mem_phys; /* physical address */
vir_clicks mem_len; /* length */
};
/* Structure for virtual copying by means of a vector with requests. */
struct vir_addr {
endpoint_t proc_nr_e;
int segment;
vir_bytes offset;
};
#define phys_cp_req vir_cp_req
struct vir_cp_req {
struct vir_addr src;
struct vir_addr dst;
phys_bytes count;
};
typedef struct {
vir_bytes iov_addr; /* address of an I/O buffer */
vir_bytes iov_size; /* sizeof an I/O buffer */
} iovec_t;
typedef struct {
cp_grant_id_t iov_grant; /* grant ID of an I/O buffer */
vir_bytes iov_size; /* sizeof an I/O buffer */
} iovec_s_t;
/* PM passes the address of a structure of this type to KERNEL when
* sys_sigsend() is invoked as part of the signal catching mechanism.
* The structure contain all the information that KERNEL needs to build
* the signal stack.
*/
struct sigmsg {
int sm_signo; /* signal number being caught */
unsigned long sm_mask; /* mask to restore when handler returns */
vir_bytes sm_sighandler; /* address of handler */
vir_bytes sm_sigreturn; /* address of _sigreturn in C library */
vir_bytes sm_stkptr; /* user stack pointer */
};
/* This is used to obtain system information through SYS_GETINFO. */
struct kinfo {
phys_bytes code_base; /* base of kernel code */
phys_bytes code_size;
phys_bytes data_base; /* base of kernel data */
phys_bytes data_size;
vir_bytes proc_addr; /* virtual address of process table */
phys_bytes _kmem_base; /* kernel memory layout (/dev/kmem) */
phys_bytes _kmem_size;
phys_bytes bootdev_base; /* boot device from boot image (/dev/boot) */
phys_bytes bootdev_size;
phys_bytes ramdev_base; /* boot device from boot image (/dev/boot) */
phys_bytes ramdev_size;
phys_bytes _params_base; /* parameters passed by boot monitor */
phys_bytes _params_size;
int nr_procs; /* number of user processes */
int nr_tasks; /* number of kernel tasks */
char release[6]; /* kernel release number */
char version[6]; /* kernel version number */
};
/* Load data accounted every this no. of seconds. */
#define _LOAD_UNIT_SECS 6 /* Changing this breaks ABI. */
/* Load data history is kept for this long. */
#define _LOAD_HISTORY_MINUTES 15 /* Changing this breaks ABI. */
#define _LOAD_HISTORY_SECONDS (60*_LOAD_HISTORY_MINUTES)
/* We need this many slots to store the load history. */
#define _LOAD_HISTORY (_LOAD_HISTORY_SECONDS/_LOAD_UNIT_SECS)
/* Runnable processes and other load-average information. */
struct loadinfo {
u16_t proc_load_history[_LOAD_HISTORY]; /* history of proc_s_cur */
u16_t proc_last_slot;
clock_t last_clock;
};
struct cpu_info {
u8_t vendor;
u8_t family;
u8_t model;
u8_t stepping;
u32_t freq; /* in MHz */
u32_t flags[2];
};
struct machine {
unsigned processors_count; /* how many cpus are available */
unsigned bsp_id; /* id of the bootstrap cpu */
int padding; /* used to be protected */
int apic_enabled; /* does the kernel use APIC or not? */
phys_bytes acpi_rsdp; /* where is the acpi RSDP */
};
struct io_range
{
unsigned ior_base; /* Lowest I/O port in range */
unsigned ior_limit; /* Highest I/O port in range */
};
struct mem_range
{
phys_bytes mr_base; /* Lowest memory address in range */
phys_bytes mr_limit; /* Highest memory address in range */
};
/* For EXEC_NEWMEM */
struct exec_newmem
{
vir_bytes text_addr; /* Starting address of text section */
vir_bytes text_bytes; /* Length of text section (in bytes) */
vir_bytes data_addr; /* Starting address of data section */
vir_bytes data_bytes; /* Length of data section (in bytes) */
vir_bytes tot_bytes; /* Minimum stack region size (in bytes) */
vir_bytes args_bytes; /* Arguments/environ size on stack (in bytes) */
int sep_id; /* Separate I&D? */
int is_elf; /* Is ELF exe? */
dev_t st_dev; /* Device holding executable file */
ino_t st_ino; /* Inode of executable file */
time_t enst_ctime; /* Last changed time of executable file */
uid_t new_uid; /* Process UID after exec */
gid_t new_gid; /* Process GID after exec */
int setugid; /* Process is setuid or setgid */
char progname[16]; /* Should be at least PROC_NAME_LEN */
};
/* Memory chunks. */
struct memory {
phys_bytes base;
phys_bytes size;
};
#define STATICINIT(v, n) \
if(!(v)) { \
if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, NULL))) { \
panic("allocating " #v " failed: %d", n); \
} \
}
/* The kernel outputs diagnostic messages in a circular buffer. */
struct kmessages {
int km_next; /* next index to write */
int km_size; /* current size in buffer */
char km_buf[_KMESS_BUF_SIZE]; /* buffer for messages */
};
#include <minix/config.h>
#include <machine/interrupt.h>
/* randomness struct: random sources after interrupts: */
#define RANDOM_SOURCES 16
#define RANDOM_ELEMENTS 64
typedef unsigned short rand_t;
struct k_randomness {
int random_elements, random_sources;
struct k_randomness_bin {
int r_next; /* next index to write */
int r_size; /* number of random elements */
rand_t r_buf[RANDOM_ELEMENTS]; /* buffer for random info */
} bin[RANDOM_SOURCES];
};
#endif /* _TYPE_H */
+6 -156
View File
@@ -1,159 +1,9 @@
/* The <sys/types.h> header contains important data type definitions.
* It is considered good programming practice to use these definitions,
* instead of the underlying base type. By convention, all type names end
* with _t.
*/
#ifndef _MINIX_TYPES_H_
#define _MINIX_TYPES_H_
#ifndef _TYPES_H
#define _TYPES_H
#ifndef _MINIX_ANSI_H
/* Dummy file used in legacy (and shared) minix includes. */
#include <minix/ansi.h>
#include <sys/types.h>
#include <sys/sigtypes.h>
#endif
typedef unsigned char u8_t; /* 8 bit type */
typedef unsigned short u16_t; /* 16 bit type */
typedef signed char i8_t; /* 8 bit signed type */
typedef short i16_t; /* 16 bit signed type */
#if __SIZEOF_LONG__ > 4
/* compiling with gcc on some (e.g. x86-64) platforms */
typedef unsigned int u32_t; /* 32 bit type */
typedef int i32_t; /* 32 bit signed type */
#else
/* default for ACK or gcc on 32 bit platforms */
typedef unsigned long u32_t; /* 32 bit type */
typedef long i32_t; /* 32 bit signed type */
#endif
#if !defined(__LONG_LONG_SUPPORTED)
typedef struct {
u32_t lo;
u32_t hi;
} u64_t;
#else
#if __SIZEOF_LONG__ > 4
typedef unsigned long u64_t;
#else
typedef unsigned long long u64_t;
#endif
#endif
/* some Minix specific types that do not conflict with posix */
typedef u32_t zone_t; /* zone number */
typedef u32_t block_t; /* block number */
typedef u32_t bit_t; /* bit number in a bit map */
typedef u16_t zone1_t; /* zone number for V1 file systems */
typedef u32_t bitchunk_t; /* collection of bits in a bitmap */
/* ANSI C makes writing down the promotion of unsigned types very messy. When
* sizeof(short) == sizeof(int), there is no promotion, so the type stays
* unsigned. When the compiler is not ANSI, there is usually no loss of
* unsignedness, and there are usually no prototypes so the promoted type
* doesn't matter. The use of types like Ino_t is an attempt to use ints
* (which are not promoted) while providing information to the reader.
*/
typedef unsigned long Ino_t;
#if defined(_MINIX) || defined(__minix)
/* The type size_t holds all results of the sizeof operator. At first glance,
* it seems obvious that it should be an unsigned int, but this is not always
* the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit
* integers. When one asks for the size of a 70K struct or array, the result
* requires 17 bits to express, so size_t must be a long type. The type
* ssize_t is the signed version of size_t.
*/
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int size_t;
#endif
#ifndef _SSIZE_T
#define _SSIZE_T
typedef int ssize_t;
#endif
#ifndef _TIME_T
#define _TIME_T
typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */
#endif
#ifndef _CLOCK_T
#define _CLOCK_T
typedef long clock_t; /* unit for system accounting */
#endif
#ifndef _SIGSET_T
#define _SIGSET_T
typedef unsigned long sigset_t;
#endif
#ifndef _KEY_T
#define _KEY_T
typedef long key_t;
#endif
/* Open Group Base Specifications Issue 6 (not complete) */
typedef long useconds_t; /* Time in microseconds */
typedef u32_t dev_t; /* holds (major|minor) device pair */
typedef u32_t big_dev_t;
/* Types used in disk, inode, etc. data structures.
* Some u64_t should be i64_t, but anyway with old libc we use .lo only.
*/
typedef u32_t gid_t; /* group id */
typedef u32_t big_gid_t; /* group id */
typedef unsigned long ino_t; /* i-node number (V3 filesystem) */
typedef u64_t big_ino_t; /* i-node number (V3 filesystem) */
typedef unsigned short mode_t; /* file type and permissions bits */
typedef u32_t big_mode_t; /* file type and permissions bits */
typedef short nlink_t; /* number of links to a file */
typedef u32_t big_nlink_t;/* number of links to a file */
typedef long off_t; /* offset within a file */
typedef u64_t big_off_t; /* offset within a file */
typedef int pid_t; /* process id (must be signed) */
typedef u32_t uid_t; /* user id */
typedef u32_t big_uid_t; /* user id */
typedef unsigned long fsblkcnt_t; /* File system block count */
typedef unsigned long fsfilcnt_t; /* File system file count */
typedef u32_t blkcnt_t; /* File system block count */
typedef unsigned long blksize_t; /* File system block size */
/* Signal handler type, e.g. SIG_IGN */
typedef void _PROTOTYPE( (*sighandler_t), (int) );
typedef sighandler_t sig_t;
/* Compatibility with other systems */
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef char *caddr_t;
/* Devices. */
#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */
#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */
#ifndef minor
#define minor(dev) (((dev) >> MINOR) & 0xff)
#endif
#ifndef major
#define major(dev) (((dev) >> MAJOR) & 0xff)
#endif
#ifndef makedev
#define makedev(major, minor) \
((dev_t) (((major) << MAJOR) | ((minor) << MINOR)))
#endif
#endif /* _MINIX || __minix */
#if defined(_MINIX)
typedef unsigned int uint; /* Sys V compatibility */
#endif
#endif /* _TYPES_H */
+220
View File
@@ -0,0 +1,220 @@
/* minix/u64.h Author: Kees J. Bot
* 7 Dec 1995
* Functions to manipulate 64 bit disk addresses.
*/
#ifndef _MINIX__U64_H
#define _MINIX__U64_H
#ifndef _TYPES_H
#include <minix/types.h>
#endif
#if !defined(__LONG_LONG_SUPPORTED)
u64_t add64(u64_t i, u64_t j);
u64_t add64u(u64_t i, unsigned j);
u64_t add64ul(u64_t i, unsigned long j);
u64_t sub64(u64_t i, u64_t j);
u64_t sub64u(u64_t i, unsigned j);
u64_t sub64ul(u64_t i, unsigned long j);
int bsr64(u64_t i);
unsigned diff64(u64_t i, u64_t j);
u64_t cvu64(unsigned i);
u64_t cvul64(unsigned long i);
unsigned cv64u(u64_t i);
unsigned long cv64ul(u64_t i);
u64_t div64(u64_t i, u64_t j);
unsigned long div64u(u64_t i, unsigned j);
u64_t div64u64(u64_t i, unsigned j);
u64_t rem64(u64_t i, u64_t j);
unsigned rem64u(u64_t i, unsigned j);
u64_t mul64(u64_t i, u64_t j);
u64_t mul64u(unsigned long i, unsigned j);
int cmp64(u64_t i, u64_t j);
int cmp64u(u64_t i, unsigned j);
int cmp64ul(u64_t i, unsigned long j);
unsigned long ex64lo(u64_t i);
unsigned long ex64hi(u64_t i);
u64_t make64(unsigned long lo, unsigned long hi);
#define is_zero64(i) ((i).lo == 0 && (i).hi == 0)
#define make_zero64(i) do { (i).lo = (i).hi = 0; } while(0)
#define neg64(i) do { \
(i).lo = ~(i).lo; \
(i).hi = ~(i).hi; \
(i) = add64u((i), 1); \
} while(0)
#else
#include <limits.h>
#define is_zero64(i) ((i) == 0)
#define make_zero64(i) ((i) = 0)
#define neg64(i) ((i) = -(i))
static inline u64_t add64(u64_t i, u64_t j)
{
return i + j;
}
static inline u64_t add64u(u64_t i, unsigned j)
{
return i + j;
}
static inline u64_t add64ul(u64_t i, unsigned long j)
{
return i + j;
}
static inline int bsr64(u64_t i)
{
int index;
u64_t mask;
for (index = 63, mask = 1ULL << 63; index >= 0; --index, mask >>= 1) {
if (i & mask)
return index;
}
return -1;
}
static inline int cmp64(u64_t i, u64_t j)
{
if (i > j)
return 1;
else if (i < j)
return -1;
else /* (i == j) */
return 0;
}
static inline int cmp64u(u64_t i, unsigned j)
{
if (i > j)
return 1;
else if (i < j)
return -1;
else /* (i == j) */
return 0;
}
static inline int cmp64ul(u64_t i, unsigned long j)
{
if (i > j)
return 1;
else if (i < j)
return -1;
else /* (i == j) */
return 0;
}
static inline unsigned cv64u(u64_t i)
{
/* return ULONG_MAX if really big */
if (i>>32)
return ULONG_MAX;
return (unsigned)i;
}
static inline unsigned long cv64ul(u64_t i)
{
/* return ULONG_MAX if really big */
if (i>>32)
return ULONG_MAX;
return (unsigned long)i;
}
static inline u64_t cvu64(unsigned i)
{
return i;
}
static inline u64_t cvul64(unsigned long i)
{
return i;
}
static inline unsigned diff64(u64_t i, u64_t j)
{
return (unsigned)(i - j);
}
static inline u64_t div64(u64_t i, u64_t j)
{
return i / j;
}
static inline u64_t rem64(u64_t i, u64_t j)
{
return i % j;
}
static inline unsigned long div64u(u64_t i, unsigned j)
{
return (unsigned long)(i / j);
}
static inline u64_t div64u64(u64_t i, unsigned j)
{
return i / j;
}
static inline unsigned rem64u(u64_t i, unsigned j)
{
return (unsigned)(i % j);
}
static inline unsigned long ex64lo(u64_t i)
{
return (unsigned long)i;
}
static inline unsigned long ex64hi(u64_t i)
{
return (unsigned long)(i>>32);
}
static inline u64_t make64(unsigned long lo, unsigned long hi)
{
return ((u64_t)hi << 32) | (u64_t)lo;
}
static inline u64_t mul64(u64_t i, u64_t j)
{
return i * j;
}
static inline u64_t mul64u(unsigned long i, unsigned j)
{
return (u64_t)i * j;
}
static inline u64_t sub64(u64_t i, u64_t j)
{
return i - j;
}
static inline u64_t sub64u(u64_t i, unsigned j)
{
return i - j;
}
static inline u64_t sub64ul(u64_t i, unsigned long j)
{
return i - j;
}
#endif
u64_t rrotate64(u64_t x, unsigned short b);
u64_t rshift64(u64_t x, unsigned short b);
u64_t xor64(u64_t a, u64_t b);
u64_t and64(u64_t a, u64_t b);
u64_t not64(u64_t a);
#endif /* _MINIX__U64_H */
+155
View File
@@ -0,0 +1,155 @@
#ifndef _MINIX_USB_H
#define _MINIX_USB_H
#include <minix/com.h>
#include <minix/ipc.h>
#include <minix/types.h>
#include <stdio.h>
#define USB_URBSIZE(data_size, iso_count) \
(data_size + sizeof(struct usb_urb) + iso_count * \
sizeof(struct usb_iso_packet_desc))
#define USB_PREPARE_URB(urb, data_size, iso_count) \
do { \
if(iso_count)\
urb->iso_data.iso_desc = data_size;\
urb->urb_size = data_size+sizeof(struct usb_urb)+iso_count * \
sizeof(struct usb_iso_packet_desc); \
} while (0)
struct usb_urb;
struct usb_driver {
void (*urb_completion)(struct usb_urb *urb);
void (*connect_device)(unsigned dev_id, unsigned int interfaces);
void (*disconnect_device)(unsigned dev_id);
};
struct usb_device_id {
u16_t idVendor;
u16_t idProduct;
u32_t bcdDevice;
u8_t bDeviceClass;
u8_t bDeviceSubClass;
u8_t bDeviceProtocol;
u8_t bInterfaceClass;
u8_t bInterfaceSubClass;
u8_t bInterfaceProtocol;
};
struct usb_iso_packet_desc {
unsigned int offset;
unsigned int length; /* expected length */
unsigned int actual_length;
unsigned int status;
};
/** isochronous transfer */
#define USB_TRANSFER_ISO 0
/** interrupt transfer */
#define USB_TRANSFER_INT 1
/** control transfer */
#define USB_TRANSFER_CTL 2
/** bulk transfer */
#define USB_TRANSFER_BLK 3
#define USB_IN 0
#define USB_OUT 1
#define USB_INVALID_URB_ID 0
struct usb_urb {
/* private */
struct usb_urb *next;
/** ID identifying the device on HCD side */
int dev_id;
int type;
int endpoint;
int direction;
int status;
int error_count;
size_t size;
size_t actual_length;
void *priv;
int interval;
unsigned long transfer_flags;
/* housekeeping information needed by usb library */
unsigned urb_id;
size_t urb_size;
cp_grant_id_t gid;
size_t iso_desc_offset;
int number_of_packets;
int start_frame;
char setup_packet[8];
/* data allways starts here */
char buffer[1];
};
struct usb_ctrlrequest {
u8_t bRequestType;
u8_t bRequest;
u16_t wValue;
u16_t wIndex;
u16_t wLength;
} __attribute__ ((packed));
#ifdef DEBUG
static void dump_urb(struct usb_urb *urb) {
printf("================\n");
printf("DUMP: urb (0x%p)\n", urb);
printf("================\n");
printf("= dev_id: %d\n", urb->dev_id);
printf("= type: %d\n", urb->type);
printf("= endpoint: %d\n", urb->endpoint);
printf("= direction: %d\n", urb->direction);
printf("= status: %d\n", urb->status);
printf("= error_count: %d\n", urb->error_count);
printf("= size: %d\n", urb->size);
printf("= actual_length: %d\n", urb->actual_length);
printf("= interval %d\n", urb->interval);
printf("= transfer_flags %x\n", urb->transfer_flags);
printf("= urb_id = %d\n", urb->urb_id);
printf("= urb_size = 0x%x\n", urb->urb_size);
printf("= setup_packet: \n");
printf("= bRequestType: 0x%x \n",
((struct usb_ctrlrequest *)urb->setup_packet)->bRequestType);
printf("= bRequest 0x%x \n",
((struct usb_ctrlrequest *)urb->setup_packet)->bRequest);
printf("= wValue: 0x%x \n",
((struct usb_ctrlrequest *)urb->setup_packet)->wValue);
printf("= wIndex: 0x%x \n",
((struct usb_ctrlrequest *)urb->setup_packet)->wIndex);
printf("= wLength: 0x%x \n",
((struct usb_ctrlrequest *)urb->setup_packet)->wLength);
printf("===============\n");
}
#else
#define dumb_urb(x)
#endif
/** Submit a URB */
int usb_send_urb(struct usb_urb* urb);
/** Cancels an URB */
int usb_cancle_urb(struct usb_urb* urb);
/** Gets the USB device ID of an USB device **/
int usb_get_device_id(int dev_id, struct usb_device_id *usb_device_id);
/* this initializes a session with the HCD */
int usb_init(char *name);
/** This functions handles a message from the HCD */
int usb_handle_msg(struct usb_driver *ubd, message *msg);
#endif /* _MINIX_USB_H */
+217
View File
@@ -0,0 +1,217 @@
#ifndef MINIX_USB_CH9_H
#define MINIX_USB_CH9_H
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Lennart Augustsson (lennart@augustsson.net) at
* Carlstedt Research & Technology.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* USB DESCRIPTORS */
/*
* The USB records contain some unaligned little-endian word
* components. The U[SG]ETW macros take care of both the alignment
* and endian problem and should always be used to access non-byte
* values.
*/
#include <minix/types.h>
typedef u8_t uByte;
typedef u8_t uWord[2];
typedef u8_t uDWord[4];
#define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
#if 1
#define UGETW(w) ((w)[0] | ((w)[1] << 8))
#define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
#define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
(w)[1] = (u_int8_t)((v) >> 8), \
(w)[2] = (u_int8_t)((v) >> 16), \
(w)[3] = (u_int8_t)((v) >> 24))
#else
/*
* On little-endian machines that can handle unanliged accesses
* (e.g. i386) these macros can be replaced by the following.
*/
#define UGETW(w) (*(u_int16_t *)(w))
#define USETW(w,v) (*(u_int16_t *)(w) = (v))
#define UGETDW(w) (*(u_int32_t *)(w))
#define USETDW(w,v) (*(u_int32_t *)(w) = (v))
#endif
#define UPACKED __attribute__((__packed__))
/* Requests */
#define UR_GET_STATUS 0x00
#define UR_CLEAR_FEATURE 0x01
#define UR_SET_FEATURE 0x03
#define UR_SET_ADDRESS 0x05
#define UR_GET_DESCRIPTOR 0x06
#define UDESC_DEVICE 0x01
#define UDESC_CONFIG 0x02
#define UDESC_STRING 0x03
#define USB_LANGUAGE_TABLE 0x00 /* language ID string index */
#define UDESC_INTERFACE 0x04
#define UDESC_ENDPOINT 0x05
#define UDESC_DEVICE_QUALIFIER 0x06
#define UDESC_OTHER_SPEED_CONFIGURATION 0x07
#define UDESC_INTERFACE_POWER 0x08
#define UDESC_OTG 0x09
#define UDESC_DEBUG 0x0A
#define UDESC_IFACE_ASSOC 0x0B /* interface association */
#define UDESC_BOS 0x0F /* binary object store */
#define UDESC_DEVICE_CAPABILITY 0x10
#define UDESC_CS_DEVICE 0x21 /* class specific */
#define UDESC_CS_CONFIG 0x22
#define UDESC_CS_STRING 0x23
#define UDESC_CS_INTERFACE 0x24
#define UDESC_CS_ENDPOINT 0x25
#define UDESC_HUB 0x29
#define UDESC_ENDPOINT_SS_COMP 0x30 /* super speed */
#define UR_SET_DESCRIPTOR 0x07
#define UR_GET_CONFIG 0x08
#define UR_SET_CONFIG 0x09
#define UR_GET_INTERFACE 0x0a
#define UR_SET_INTERFACE 0x0b
#define UR_SYNCH_FRAME 0x0c
#define UR_SET_SEL 0x30
#define UR_ISOCH_DELAY 0x31
typedef struct {
uByte bLength;
uByte bDescriptorType;
uByte bDescriptorSubtype;
} UPACKED usb_descriptor_t;
typedef struct {
uByte bLength;
uByte bDescriptorType;
uWord bcdUSB;
#define UD_USB_2_0 0x0200
#define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
uByte bDeviceClass;
uByte bDeviceSubClass;
uByte bDeviceProtocol;
uByte bMaxPacketSize;
/* The fields below are not part of the initial descriptor. */
uWord idVendor;
uWord idProduct;
uWord bcdDevice;
uByte iManufacturer;
uByte iProduct;
uByte iSerialNumber;
uByte bNumConfigurations;
} UPACKED usb_device_descriptor_t;
#define USB_DEVICE_DESCRIPTOR_SIZE 18
typedef struct {
uByte bLength;
uByte bDescriptorType;
uWord wTotalLength;
uByte bNumInterface;
uByte bConfigurationValue;
uByte iConfiguration;
uByte bmAttributes;
#define UC_BUS_POWERED 0x80
#define UC_SELF_POWERED 0x40
#define UC_REMOTE_WAKEUP 0x20
uByte bMaxPower; /* max current in 2 mA units */
#define UC_POWER_FACTOR 2
} UPACKED usb_config_descriptor_t;
#define USB_CONFIG_DESCRIPTOR_SIZE 9
typedef struct {
uByte bLength;
uByte bDescriptorType;
uByte bInterfaceNumber;
uByte bAlternateSetting;
uByte bNumEndpoints;
uByte bInterfaceClass;
uByte bInterfaceSubClass;
uByte bInterfaceProtocol;
uByte iInterface;
} UPACKED usb_interface_descriptor_t;
#define USB_INTERFACE_DESCRIPTOR_SIZE 9
typedef struct {
uByte bLength;
uByte bDescriptorType;
uByte bEndpointAddress;
#define UE_GET_DIR(a) ((a) & 0x80)
#define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
#define UE_DIR_IN 0x80
#define UE_DIR_OUT 0x00
#define UE_ADDR 0x0f
#define UE_GET_ADDR(a) ((a) & UE_ADDR)
uByte bmAttributes;
#define UE_XFERTYPE 0x03
#define UE_CONTROL 0x00
#define UE_ISOCHRONOUS 0x01
#define UE_BULK 0x02
#define UE_INTERRUPT 0x03
#define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
#define UE_ISO_TYPE 0x0c
#define UE_ISO_ASYNC 0x04
#define UE_ISO_ADAPT 0x08
#define UE_ISO_SYNC 0x0c
#define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
uWord wMaxPacketSize;
uByte bInterval;
} UPACKED usb_endpoint_descriptor_t;
#define USB_ENDPOINT_DESCRIPTOR_SIZE 7
typedef struct {
uByte bLength;
uByte bDescriptorType;
uWord bString[127];
} UPACKED usb_string_descriptor_t;
#define USB_MAX_STRING_LEN 128
#define USB_MAX_ENCODED_STRING_LEN (USB_MAX_STRING_LEN * 3) /* UTF8 */
struct usb_device_request {
uByte bmRequestType;
uByte bRequest;
uWord wValue;
uWord wIndex;
uWord wLength;
} UPACKED;
typedef struct usb_device_request usb_device_request_t;
#endif
+151
View File
@@ -0,0 +1,151 @@
#ifndef __MINIX_VFSIF_H
#define __MINIX_VFSIF_H
#include <sys/types.h>
#include <limits.h>
/* VFS/FS request fields */
#define REQ_ACTIME m9_l2
#define REQ_COUNT m9_l2
#define REQ_DEV m9_l5
#define REQ_DEV2 m9_l1
#define REQ_DIR_INO m9_l3
#define REQ_FLAGS m9_s3
#define REQ_GID m9_s1
#define REQ_GRANT m9_l2
#define REQ_GRANT2 m9_l1
#define REQ_GRANT3 m9_l3
#define REQ_INODE_NR m9_l1
#define REQ_MEM_SIZE m9_l5
#define REQ_MODE m9_s3
#define REQ_MODTIME m9_l3
#define REQ_NBYTES m9_l5
#define REQ_PATH_LEN m9_s2
#define REQ_PATH_SIZE m9_l5
#define REQ_REN_GRANT_NEW m9_l1
#define REQ_REN_GRANT_OLD m9_l2
#define REQ_REN_LEN_NEW m9_s2
#define REQ_REN_LEN_OLD m9_s1
#define REQ_REN_NEW_DIR m9_l4
#define REQ_REN_OLD_DIR m9_l3
#define REQ_ROOT_INO m9_l4
#define REQ_SEEK_POS_HI m9_l3
#define REQ_SEEK_POS_LO m9_l4
#define REQ_TRC_END_HI m9_l4
#define REQ_TRC_END_LO m9_l5
#define REQ_TRC_START_HI m9_l2
#define REQ_TRC_START_LO m9_l3
#define REQ_UCRED_SIZE m9_s4
#define REQ_UID m9_s4
/* VFS/FS reply fields */
#define RES_DEV m9_l4
#define RES_GID m9_s1
#define RES_INODE_NR m9_l1
#define RES_FILE_SIZE_HI m9_l2
#define RES_FILE_SIZE_LO m9_l3
#define RES_MODE m9_s2
#define RES_NBYTES m9_l5
#define RES_OFFSET m9_s2
#define RES_SEEK_POS_HI m9_l3
#define RES_SEEK_POS_LO m9_l4
#define RES_SYMLOOP m9_s3
#define RES_UID m9_s4
#define RES_CONREQS m9_s3
/* VFS/FS flags */
#define REQ_RDONLY 001
#define REQ_ISROOT 002
#define PATH_NOFLAGS 000
#define PATH_RET_SYMLINK 010 /* Return a symlink object (i.e.
* do not continue with the contents
* of the symlink if it is the last
* component in a path). */
#define PATH_GET_UCRED 020 /* Request provides a grant ID in m9_l1
* and struct ucred size in m9_s4 (as
* opposed to a REQ_UID). */
/* VFS/FS error messages */
#define EENTERMOUNT (-301)
#define ELEAVEMOUNT (-302)
#define ESYMLINK (-303)
/* VFS/FS types */
/* User credential structure */
typedef struct {
uid_t vu_uid;
gid_t vu_gid;
int vu_ngroups;
gid_t vu_sgroups[NGROUPS_MAX];
} vfs_ucred_t;
#define NGROUPS_MAX_OLD 8
/* User credential structure before increasing
* uid_t and gid_t u8_t */
typedef struct {
short vu_uid;
char vu_gid;
int vu_ngroups;
char vu_sgroups[NGROUPS_MAX_OLD];
} vfs_ucred_old_t;
/* Request numbers */
#define REQ_GETNODE (VFS_BASE + 1) /* Should be removed */
#define REQ_PUTNODE (VFS_BASE + 2)
#define REQ_SLINK (VFS_BASE + 3)
#define REQ_FTRUNC (VFS_BASE + 4)
#define REQ_CHOWN (VFS_BASE + 5)
#define REQ_CHMOD (VFS_BASE + 6)
#define REQ_INHIBREAD (VFS_BASE + 7)
#define REQ_STAT (VFS_BASE + 8)
#define REQ_UTIME (VFS_BASE + 9)
#define REQ_FSTATFS (VFS_BASE + 10)
#define REQ_BREAD (VFS_BASE + 11)
#define REQ_BWRITE (VFS_BASE + 12)
#define REQ_UNLINK (VFS_BASE + 13)
#define REQ_RMDIR (VFS_BASE + 14)
#define REQ_UNMOUNT (VFS_BASE + 15)
#define REQ_SYNC (VFS_BASE + 16)
#define REQ_NEW_DRIVER (VFS_BASE + 17)
#define REQ_FLUSH (VFS_BASE + 18)
#define REQ_READ (VFS_BASE + 19)
#define REQ_WRITE (VFS_BASE + 20)
#define REQ_MKNOD (VFS_BASE + 21)
#define REQ_MKDIR (VFS_BASE + 22)
#define REQ_CREATE (VFS_BASE + 23)
#define REQ_LINK (VFS_BASE + 24)
#define REQ_RENAME (VFS_BASE + 25)
#define REQ_LOOKUP (VFS_BASE + 26)
#define REQ_MOUNTPOINT (VFS_BASE + 27)
#define REQ_READSUPER (VFS_BASE + 28)
#define REQ_NEWNODE (VFS_BASE + 29)
#define REQ_RDLINK (VFS_BASE + 30)
#define REQ_GETDENTS (VFS_BASE + 31)
#define REQ_STATVFS (VFS_BASE + 32)
#define NREQS 33
#define IS_VFS_RQ(type) (((type) & ~0xff) == VFS_BASE)
#define TRNS_GET_ID(t) ((t) & 0xFFFF)
#define TRNS_ADD_ID(t,id) (((t) << 16) | ((id) & 0xFFFF))
#define TRNS_DEL_ID(t) ((short)((t) >> 16))
#define PFS_BASE (VFS_BASE + 100)
#define PFS_REQ_CHECK_PERMS (PFS_BASE + 1)
#define PFS_REQ_VERIFY_FD (PFS_BASE + 2)
#define PFS_REQ_SET_FILP (PFS_BASE + 3)
#define PFS_REQ_COPY_FILP (PFS_BASE + 4)
#define PFS_REQ_PUT_FILP (PFS_BASE + 5)
#define PFS_REQ_CANCEL_FD (PFS_BASE + 6)
#define PFS_NREQS 7
#define IS_PFS_VFS_RQ(type) (type >= PFS_BASE && \
type < (PFS_BASE + PFS_NREQS))
#endif
+79
View File
@@ -0,0 +1,79 @@
/* Prototypes and definitions for VM interface. */
#ifndef _MINIX_VM_H
#define _MINIX_VM_H
#include <minix/types.h>
#include <minix/endpoint.h>
_PROTOTYPE( int vm_exit, (endpoint_t ep));
_PROTOTYPE( int vm_fork, (endpoint_t ep, int slotno, endpoint_t *child_ep));
_PROTOTYPE( int vm_brk, (endpoint_t ep, char *newaddr));
_PROTOTYPE( int vm_exec_newmem, (endpoint_t ep, struct exec_newmem *args,
int args_bytes, char **ret_stack_top, int *ret_flags));
_PROTOTYPE( int vm_push_sig, (endpoint_t ep, vir_bytes *old_sp));
_PROTOTYPE( int vm_willexit, (endpoint_t ep));
_PROTOTYPE( int vm_adddma, (endpoint_t proc_e, phys_bytes start,
phys_bytes size));
_PROTOTYPE( int vm_deldma, (endpoint_t proc_e, phys_bytes start,
phys_bytes size));
_PROTOTYPE( int vm_getdma, (endpoint_t *procp, phys_bytes *basep,
phys_bytes *sizep));
_PROTOTYPE( void *vm_map_phys, (endpoint_t who, void *physaddr, size_t len));
_PROTOTYPE( int vm_unmap_phys, (endpoint_t who, void *vaddr, size_t len));
_PROTOTYPE( int vm_notify_sig, (endpoint_t ep, endpoint_t ipc_ep));
_PROTOTYPE( int vm_set_priv, (int procnr, void *buf));
_PROTOTYPE( int vm_update, (endpoint_t src_e, endpoint_t dst_e));
_PROTOTYPE( int vm_memctl, (endpoint_t ep, int req));
_PROTOTYPE( int vm_query_exit, (endpoint_t *endpt));
_PROTOTYPE( int vm_watch_exit, (endpoint_t ep));
_PROTOTYPE( int vm_forgetblock, (u64_t id));
_PROTOTYPE( void vm_forgetblocks, (void));
_PROTOTYPE( int vm_yield_block_get_block, (u64_t yieldid, u64_t getid,
void *mem, vir_bytes len));
/* Invalid ID with special meaning for the vm_yield_block_get_block
* interface.
*/
#define VM_BLOCKID_NONE make64(ULONG_MAX, ULONG_MAX)
/* VM kernel request types. */
#define VMPTYPE_NONE 0
#define VMPTYPE_CHECK 1
#define VMPTYPE_COWMAP 2
#define VMPTYPE_SMAP 3
#define VMPTYPE_SUNMAP 4
struct vm_stats_info {
unsigned int vsi_pagesize; /* page size */
unsigned long vsi_total; /* total number of memory pages */
unsigned long vsi_free; /* number of free pages */
unsigned long vsi_largest; /* largest number of consecutive free pages */
unsigned long vsi_cached; /* number of pages cached for file systems */
};
struct vm_usage_info {
vir_bytes vui_total; /* total amount of process memory */
vir_bytes vui_common; /* part of memory mapped in more than once */
vir_bytes vui_shared; /* shared (non-COW) part of common memory */
};
struct vm_region_info {
int vri_seg; /* segment of virtual region (T or D) */
vir_bytes vri_addr; /* base address of region */
vir_bytes vri_length; /* length of region */
int vri_prot; /* protection flags (PROT_) */
int vri_flags; /* memory flags (subset of MAP_) */
};
#define MAX_VRI_COUNT 64 /* max. number of regions provided at once */
_PROTOTYPE( int vm_info_stats, (struct vm_stats_info *vfi) );
_PROTOTYPE( int vm_info_usage, (endpoint_t who,
struct vm_usage_info *vui) );
_PROTOTYPE( int vm_info_region, (endpoint_t who,
struct vm_region_info *vri, int count, vir_bytes *next) );
#endif /* _MINIX_VM_H */
+57
View File
@@ -0,0 +1,57 @@
#ifndef _MINIX_VTREEFS_H
#define _MINIX_VTREEFS_H
struct inode;
typedef int index_t;
typedef void *cbdata_t;
#define NO_INDEX ((index_t) -1)
/* Maximum file name length, excluding terminating null character. It is set
* to a low value to limit memory usage, but can be changed to any value.
*/
#define PNAME_MAX 24
struct inode_stat {
mode_t mode; /* file mode (type and permissions) */
uid_t uid; /* user ID */
gid_t gid; /* group ID */
off_t size; /* file size */
dev_t dev; /* device number (for char/block type files) */
};
struct fs_hooks {
void (*init_hook)(void);
void (*cleanup_hook)(void);
int (*lookup_hook)(struct inode *inode, char *name, cbdata_t cbdata);
int (*getdents_hook)(struct inode *inode, cbdata_t cbdata);
int (*read_hook)(struct inode *inode, off_t offset, char **ptr,
size_t *len, cbdata_t cbdata);
int (*rdlink_hook)(struct inode *inode, char *ptr, size_t max,
cbdata_t cbdata);
int (*message_hook)(message *m);
};
extern struct inode *add_inode(struct inode *parent, char *name, index_t index,
struct inode_stat *stat, index_t nr_indexed_entries, cbdata_t cbdata);
extern void delete_inode(struct inode *inode);
extern struct inode *get_inode_by_name(struct inode *parent, char *name);
extern struct inode *get_inode_by_index(struct inode *parent, index_t index);
extern char const *get_inode_name(struct inode *inode);
extern index_t get_inode_index(struct inode *inode);
extern cbdata_t get_inode_cbdata(struct inode *inode);
extern struct inode *get_root_inode(void);
extern struct inode *get_parent_inode(struct inode *inode);
extern struct inode *get_first_inode(struct inode *parent);
extern struct inode *get_next_inode(struct inode *previous);
extern void get_inode_stat(struct inode *inode, struct inode_stat *stat);
extern void set_inode_stat(struct inode *inode, struct inode_stat *stat);
extern void start_vtreefs(struct fs_hooks *hooks, unsigned int nr_inodes,
struct inode_stat *stat, index_t nr_indexed_entries);
#endif /* _MINIX_VTREEFS_H */