Basic VM and other minor improvements.

Not complete, probably not fully debugged or optimized.
This commit is contained in:
Ben Gras
2008-11-19 12:26:10 +00:00
parent c888305e21
commit c078ec0331
273 changed files with 10814 additions and 4305 deletions

View File

@@ -36,13 +36,15 @@
/* User-space processes, that is, device drivers, servers, and INIT. */
#define PM_PROC_NR 0 /* process manager */
#define FS_PROC_NR 1 /* file system */
#define RS_PROC_NR 2 /* reincarnation server */
#define VFS_PROC_NR FS_PROC_NR /* FS has been renamed to VFS. */
#define RS_PROC_NR 2 /* memory driver (RAM disk, null, etc.) */
#define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */
#define LOG_PROC_NR 4 /* log device driver */
#define TTY_PROC_NR 5 /* terminal (TTY) driver */
#define DS_PROC_NR 6 /* data store server */
#define MFS_PROC_NR 7 /* minix root filesystem */
#define INIT_PROC_NR 8 /* init -- goes multiuser */
#define VM_PROC_NR 8 /* memory server */
#define INIT_PROC_NR 9 /* init -- goes multiuser */
/* Number of processes contained in the system image. */
#define NR_BOOT_PROCS (NR_TASKS + INIT_PROC_NR + 1)
@@ -166,6 +168,7 @@
#define DEV_SCATTER_S (DEV_RQ_BASE + 22) /* (safecopy) write from a vector */
#define DEV_GATHER_S (DEV_RQ_BASE + 23) /* (safecopy) read into a vector */
#define DEV_IOCTL_S (DEV_RQ_BASE + 24) /* (safecopy) I/O control code */
#define DEV_MMAP_S (DEV_RQ_BASE + 25) /* (safecopy) mmap interface */
#define DEV_REPLY (DEV_RS_BASE + 0) /* general task reply */
#define DEV_CLONED (DEV_RS_BASE + 1) /* return cloned minor */
@@ -309,7 +312,6 @@
# define SYS_ABORT (KERNEL_CALL + 27) /* sys_abort() */
# define SYS_IOPENABLE (KERNEL_CALL + 28) /* sys_enable_iop() */
# define SYS_VM_SETBUF (KERNEL_CALL + 29) /* sys_vm_setbuf() */
# define SYS_VM_MAP (KERNEL_CALL + 30) /* sys_vm_map() */
# define SYS_SAFECOPYFROM (KERNEL_CALL + 31) /* sys_safecopyfrom() */
# define SYS_SAFECOPYTO (KERNEL_CALL + 32) /* sys_safecopyto() */
# define SYS_VSAFECOPY (KERNEL_CALL + 33) /* sys_vsafecopy() */
@@ -323,8 +325,9 @@
# define SYS_STIME (KERNEL_CALL + 39) /* sys_stime() */
# define SYS_MAPDMA (KERNEL_CALL + 42) /* sys_mapdma() */
# define SYS_VMCTL (KERNEL_CALL + 43) /* sys_vmctl() */
#define NR_SYS_CALLS 43 /* number of system calls */
#define NR_SYS_CALLS 44 /* number of system calls */
/* Pseudo call for use in kernel/table.c. */
#define SYS_ALL_CALLS (NR_SYS_CALLS)
@@ -455,12 +458,18 @@
# define GET_LOADINFO 15 /* get load average information */
# define GET_IRQACTIDS 16 /* get the IRQ masks */
# define GET_PRIVID 17 /* get ID of privilege structure */
# define GET_HZ 18 /* get HZ value */
# define GET_WHOAMI 19 /* get own name and endpoint */
#define I_ENDPT m7_i4 /* calling process */
#define I_VAL_PTR m7_p1 /* virtual address at caller */
#define I_VAL_LEN m7_i1 /* max length of value */
#define I_VAL_PTR2 m7_p2 /* second virtual address */
#define I_VAL_LEN2_E m7_i2 /* second length, or proc nr */
/* GET_WHOAMI fields. */
#define GIWHO_EP m3_i1
#define GIWHO_NAME m3_ca1
/* Field names for SYS_TIMES. */
#define T_ENDPT m4_l1 /* process to request time info for */
#define T_USER_TIME m4_l1 /* user time consumed by process */
@@ -514,10 +523,14 @@
#define PR_MEM_PTR m1_p1 /* tells where memory map is for sys_newmap
* and sys_fork
*/
#define PR_FORK_FLAGS m1_i3
/* Field names for SYS_INT86 */
#define INT86_REG86 m1_p1 /* pointer to registers */
/* Flags for PR_FORK_FLAGS. */
#define PFF_VMINHIBIT 0x01 /* Don't schedule until release by VM. */
/* Field names for SYS_SAFECOPY* */
#define SCP_FROM_TO m2_i1 /* from/to whom? */
#define SCP_INFO m2_i2 /* byte: DDDDSSSS Dest and Src seg */
@@ -559,6 +572,26 @@
#define RDB_ADDR m2_l1
#define RDB_BUF m2_p1
/* Field names for SYS_VMCTL. */
#define SVMCTL_WHO m1_i1
#define SVMCTL_PARAM m1_i2 /* All SYS_VMCTL requests. */
#define SVMCTL_VALUE m1_i3
#define SVMCTL_PF_WHO m1_i1 /* GET_PAGEFAULT reply: process ep */
#define SVMCTL_PF_I386_CR2 m1_i2 /* GET_PAGEFAULT reply: CR2 */
#define SVMCTL_PF_I386_ERR m1_i3 /* GET_PAGEFAULT reply: error code */
#define SVMCTL_MRG_ADDR m1_p1 /* MEMREQ_GET reply: address */
#define SVMCTL_MRG_LEN m1_i1 /* MEMREQ_GET reply: length */
#define SVMCTL_MRG_WRITE m1_i2 /* MEMREQ_GET reply: writeflag */
#define SVMCTL_MRG_EP m1_i3 /* MEMREQ_GET reply: process */
/* Values for SVMCTL_PARAM. */
#define VMCTL_I386_SETCR3 10
#define VMCTL_GET_PAGEFAULT 11
#define VMCTL_CLEAR_PAGEFAULT 12
#define VMCTL_I386_GETCR3 13
#define VMCTL_MEMREQ_GET 14
#define VMCTL_MEMREQ_REPLY 15
/*===========================================================================*
* Messages for the Reincarnation Server *
*===========================================================================*/
@@ -626,6 +659,7 @@
# define GETKM_PTR m1_p1
#define GET_KMESS_S (DIAG_BASE+4) /* get kmess from TTY */
# define GETKM_GRANT m1_i1
#define ASYN_DIAGNOSTICS (DIAG_BASE+5) /* grant-based, replyless DIAGNOSTICS */
#define DIAG_REPL (DIAG_BASE+0x80+0) /* reply to DIAGNOSTICS(_S) */
@@ -695,6 +729,7 @@
* FS to update its uid and gid
* fields.
*/
#define EXC_NM_RF_FULLVM 4
/* Parameters for the EXEC_RESTART call */
#define EXC_RS_PROC m1_i1 /* process that needs to be restarted */
@@ -704,4 +739,115 @@
* implementations. See <minix/vfsif.h>
*/
/* Requests sent by VM to VFS, done on behalf of a user process. */
#define VM_VFS_BASE 0xB00
#define VM_VFS_OPEN (VM_VFS_BASE+0) /* open() on behalf of user process. */
# define VMVO_NAME_GRANT m2_i1 /* 0-terminated */
# define VMVO_NAME_LENGTH m2_i2 /* name length including 0 */
# define VMVO_FLAGS m2_i3
# define VMVO_MODE m2_l1
# define VMVO_ENDPOINT m2_l2
#define VM_VFS_MMAP (VM_VFS_BASE+1) /* mmap() */
#define VM_VFS_CLOSE (VM_VFS_BASE+2) /* close() */
# define VMVC_FD m1_i1
# define VMVC_ENDPOINT m1_i2
/*===========================================================================*
* Messages for VM server *
*===========================================================================*/
#define VM_RQ_BASE 0xC00
/* Calls from PM */
#define VM_EXIT (VM_RQ_BASE+0)
# define VME_ENDPOINT m1_i1
#define VM_FORK (VM_RQ_BASE+1)
# define VMF_ENDPOINT m1_i1
# define VMF_SLOTNO m1_i2
# define VMF_CHILD_ENDPOINT m1_i3 /* result */
#define VM_BRK (VM_RQ_BASE+2)
# define VMB_ENDPOINT m1_i1
# define VMB_ADDR m1_p1
# define VMB_RETADDR m1_p2 /* result */
#define VM_EXEC_NEWMEM (VM_RQ_BASE+3)
# define VMEN_ENDPOINT m1_i1
# define VMEN_ARGSPTR m1_p1
# define VMEN_ARGSSIZE m1_i2
# define VMEN_FLAGS m1_i3 /* result */
# define VMEN_STACK_TOP m1_p2 /* result */
#define VM_PUSH_SIG (VM_RQ_BASE+4)
# define VMPS_ENDPOINT m1_i1
# define VMPS_OLD_SP m1_p1 /* result */
#define VM_WILLEXIT (VM_RQ_BASE+5)
# define VMWE_ENDPOINT m1_i1
/* General calls. */
#define VM_MMAP (VM_RQ_BASE+10)
# define VMM_ADDR m5_l1
# define VMM_LEN m5_l2
# define VMM_PROT m5_c1
# define VMM_FLAGS m5_c2
# define VMM_FD m5_i1
# define VMM_OFFSET m5_i2
# define VMM_RETADDR m5_l1 /* result */
#define VM_UMAP (VM_RQ_BASE+11)
# define VMU_SEG m1_i1
# define VMU_OFFSET m1_p1
# define VMU_LENGTH m1_p2
# define VMU_RETADDR m1_p3
/* to VM: inform VM about a region of memory that is used for
* bus-master DMA
*/
#define VM_ADDDMA (VM_RQ_BASE+12)
# define VMAD_REQ m2_i2
# define VMAD_EP m2_i1
# define VMAD_START m2_l1
# define VMAD_SIZE m2_l2
/* to VM: inform VM that a region of memory that is no longer
* used for bus-master DMA
*/
#define VM_DELDMA (VM_RQ_BASE+13)
# define VMDD_REQ m2_i2
# define VMDD_EP m2_i1
# define VMDD_START m2_l1
# define VMDD_SIZE m2_l2
/* to VM: ask VM for a region of memory that should not
* be used for bus-master DMA any longer
*/
#define VM_GETDMA (VM_RQ_BASE+14)
# define VMGD_REQ m2_i2
# define VMGD_PROCP m2_i1
# define VMGD_BASEP m2_l1
# define VMGD_SIZEP m2_l2
#define VM_MAP_PHYS (VM_RQ_BASE+15)
# define VMMP_EP m1_i1
# define VMMP_PHADDR m1_p2
# define VMMP_LEN m1_i2
# define VMMP_VADDR_REPLY m1_p3
#define VM_UNMAP_PHYS (VM_RQ_BASE+16)
# define VMUP_EP m1_i1
# define VMUP_VADDR m1_p1
#define VM_UNMAP (VM_RQ_BASE+17)
# define VMUM_ADDR m1_p1
# define VMUM_LEN m1_i1
#define VM_ALLOCMEM (VM_RQ_BASE+18)
# define VMAM_CLICKS m1_p1
# define VMAM_MEMBASE m1_i1
/* Calls from VFS. */
# define VMV_ENDPOINT m1_i1 /* for all VM_VFS_REPLY_* */
#define VM_VFS_REPLY_OPEN (VM_RQ_BASE+30)
# define VMVRO_FD m1_i2
#define VM_VFS_REPLY_MMAP (VM_RQ_BASE+31)
#define VM_VFS_REPLY_CLOSE (VM_RQ_BASE+32)
/* Total. */
#define VM_NCALLS 33
#endif /* _MINIX_COM_H */

View File

@@ -39,45 +39,9 @@
#define NR_PROCS _NR_PROCS
#define NR_SYS_PROCS _NR_SYS_PROCS
#if _MINIX_SMALL
#define NR_BUFS 100
#define NR_BUF_HASH 128
#else
/* The buffer cache should be made as large as you can afford. */
#if (MACHINE == IBM_PC && _WORD_SIZE == 2)
#define NR_BUFS 40 /* # blocks in the buffer cache */
#define NR_BUF_HASH 64 /* size of buf hash table; MUST BE POWER OF 2*/
#endif
#if (MACHINE == IBM_PC && _WORD_SIZE == 4)
#define NR_BUFS 1200 /* # blocks in the buffer cache */
#define NR_BUF_HASH 2048 /* size of buf hash table; MUST BE POWER OF 2*/
#endif
#if (MACHINE == SUN_4_60)
#define NR_BUFS 512 /* # blocks in the buffer cache (<=1536) */
#define NR_BUF_HASH 512 /* size of buf hash table; MUST BE POWER OF 2*/
#endif
#endif /* _MINIX_SMALL */
/* Number of controller tasks (/dev/cN device classes). */
#define NR_CTRLRS 2
/* Enable or disable the second level file system cache on the RAM disk. */
#define ENABLE_CACHE2 0
/* Enable or disable swapping processes to disk. */
#define ENABLE_SWAP 0
/* Include or exclude an image of /dev/boot in the boot image.
* Please update the makefile in /usr/src/tools/ as well.
*/
#define ENABLE_BOOTDEV 0 /* load image of /dev/boot at boot time */
/* DMA_SECTORS may be increased to speed up DMA based drivers. */
#define DMA_SECTORS 1 /* DMA buffer size (must be >= 1) */

View File

@@ -11,7 +11,7 @@
#define TRUE 1 /* used for turning integers into Booleans */
#define FALSE 0 /* used for turning integers into Booleans */
#define HZ 60 /* clock freq (software settable on IBM-PC) */
#define HZ 600 /* clock freq (software settable on IBM-PC) */
#define SUPER_USER (uid_t) 0 /* uid_t of superuser */
@@ -19,7 +19,7 @@
#define CPVEC_NR 16 /* max # of entries in a SYS_VCOPY request */
#define CPVVEC_NR 64 /* max # of entries in a SYS_VCOPY request */
#define SCPVEC_NR 64 /* max # of entries in a SYS_VSAFECOPY* request */
#define NR_IOREQS MIN(NR_BUFS, 64)
#define NR_IOREQS 64
/* maximum number of entries in an iorequest */
/* Message passing constants. */
@@ -46,6 +46,12 @@
#define GRANT_SEG 0x0800 /* flag indicating grant for umap */
#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 */
@@ -77,6 +83,13 @@
#define CLICK_SHIFT 12 /* log2 of CLICK_SIZE */
#endif
/* 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 8
/* Click to byte conversions (and vice versa). */
#define HCLICK_SHIFT 4 /* log2 of HCLICK_SIZE */
#define HCLICK_SIZE 16 /* hardware segment conversion magic */
@@ -108,8 +121,6 @@
#define I_NOT_ALLOC 0000000 /* this inode is free */
/* Some limits. */
#define MAX_BLOCK_NR ((block_t) 077777777) /* largest block number */
#define HIGHEST_ZONE ((zone_t) 077777777) /* largest zone number */
#define MAX_INODE_NR ((ino_t) 037777777777) /* largest inode number */
#define MAX_FILE_POS ((off_t) 0x7FFFFFFF) /* largest legal file offset */

View File

@@ -29,8 +29,8 @@ typedef struct { u16_t port; u32_t value; } pvl_pair_t;
(pv).port = _p; \
(pv).value = _v; \
if((pv).port != _p || (pv).value != _v) { \
printf("%s:%d: actual port: %x != %x || " \
"actual value: %x != %x\n", \
printf("%s:%d: actual port: 0x%x != 0x%lx || " \
"actual value: 0x%x != 0x%lx\n", \
__FILE__, __LINE__, (pv).port, _p, (pv).value, _v); \
panic(__FILE__, "pv_set(" #pv ", " #p ", " #v ")", NO_NUM); \
} \

View File

@@ -1,6 +1,8 @@
#ifndef _IPC_H
#define _IPC_H
#include <minix/type.h>
/*==========================================================================*
* Types relating to messages. *
*==========================================================================*/

View File

@@ -20,7 +20,6 @@
#define _NR_PROCS 100
#define _NR_SYS_PROCS 32
#define _NR_HOLES (2*_NR_PROCS+4) /* No. of memory holes maintained by PM */
/* 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
@@ -71,4 +70,6 @@ error "_MINIX_MACHINE has incorrect value (0)"
/* Kernel debug checks */
#define DEBUG_LOCK_CHECK 1 /* Interrupt Lock/unlock sanity checking. */
#define _KMESS_BUF_SIZE 30000
#endif /* _MINIX_SYS_CONFIG_H */

View File

@@ -34,7 +34,8 @@ _PROTOTYPE( int sys_abort, (int how, ...));
_PROTOTYPE( int sys_enable_iop, (endpoint_t proc));
_PROTOTYPE( int sys_exec, (endpoint_t proc, char *ptr,
char *aout, vir_bytes initpc));
_PROTOTYPE( int sys_fork, (int parent, int child, int *, struct mem_map *ptr));
_PROTOTYPE( int sys_fork, (endpoint_t parent, endpoint_t child, int *,
struct mem_map *ptr, u32_t vm));
_PROTOTYPE( int sys_newmap, (endpoint_t proc, struct mem_map *ptr));
_PROTOTYPE( int sys_exit, (endpoint_t proc));
_PROTOTYPE( int sys_trace, (int req, endpoint_t proc, long addr, long *data_p));
@@ -48,6 +49,13 @@ _PROTOTYPE( int sys_vm_setbuf, (phys_bytes base, phys_bytes size,
phys_bytes high));
_PROTOTYPE( int sys_vm_map, (endpoint_t proc_nr, 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_pagefault_i386, (endpoint_t *who, u32_t *cr2, u32_t *err));
_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) );
_PROTOTYPE( int sys_readbios, (phys_bytes address, void *buf, size_t size));
_PROTOTYPE( int sys_stime, (time_t boottime));
@@ -71,6 +79,9 @@ _PROTOTYPE( int sys_stime, (time_t boottime));
sys_sdevio(DIO_SAFE_OUTPUT_WORD, port, ept, (void*)grant, count, offset)
_PROTOTYPE( int sys_sdevio, (int req, long port, endpoint_t proc_nr,
void *buffer, int count, vir_bytes offset));
_PROTOTYPE(void *alloc_contig, (size_t len, int flags, phys_bytes *phys));
#define AC_ALIGN4K 0x01
#define AC_LOWER16M 0x02
/* Clock functionality: get system times or (un)schedule an alarm call. */
_PROTOTYPE( int sys_times, (endpoint_t proc_nr, clock_t *user_time,
@@ -128,6 +139,8 @@ _PROTOTYPE(int sys_physvcopy, (phys_cp_req *vec_ptr,int vec_size,int *nr_ok));
_PROTOTYPE(int sys_umap, (endpoint_t proc_nr, int seg, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_umap_data_fb, (endpoint_t proc_nr, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
phys_bytes phys, vir_bytes size));
@@ -151,6 +164,7 @@ _PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
#define sys_getprivid(nr) sys_getinfo(GET_PRIVID, 0, 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));
/* Signal control. */
_PROTOTYPE(int sys_kill, (endpoint_t proc, int sig) );

View File

@@ -1,6 +1,8 @@
#ifndef _MINIX_SYSUTIL_H
#define _MINIX_SYSUTIL_H 1
#include <minix/ipc.h>
/* Extra system library definitions to support device drivers and servers.
*
* Created:
@@ -48,9 +50,15 @@ _PROTOTYPE( int getuptime, (clock_t *ticks));
_PROTOTYPE( int getuptime2, (clock_t *ticks, time_t *boottime));
_PROTOTYPE( int tickdelay, (clock_t ticks));
_PROTOTYPE( int micro_delay_calibrate, (void));
_PROTOTYPE( u32_t sys_hz, (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 micros_to_ticks, (u32_t micros));
_PROTOTYPE( int asynsend, (endpoint_t ep, message *msg));
#define MICROS_TO_TICKS(m) (((m)*HZ/1000000)+1)
#define ASSERT(c) if(!(c)) { panic(__FILE__, "assert " #c " failed at line", __LINE__); }
#endif /* _MINIX_SYSUTIL_H */

28
include/minix/tty.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef _MINIX_TTY_H
#define _MINIX_TTY_H
#include <sys/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

View File

@@ -16,7 +16,7 @@ typedef unsigned int phys_clicks; /* physical addr/length in clicks */
typedef int endpoint_t; /* process identifier */
#if (_MINIX_CHIP == _CHIP_INTEL)
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
typedef long unsigned int vir_bytes; /* virtual addresses/lengths in bytes */
#endif
#if (_MINIX_CHIP == _CHIP_M68000)
@@ -48,19 +48,6 @@ struct vir_addr {
vir_bytes offset;
};
/* Memory allocation by PM. */
struct hole {
struct hole *h_next; /* pointer to next entry on the list */
phys_clicks h_base; /* where does the hole begin? */
phys_clicks h_len; /* how big is the hole? */
};
/* Memory info from PM. */
struct pm_mem_info {
struct hole pmi_holes[_NR_HOLES];/* memory (un)allocations */
u32_t pmi_hi_watermark; /* highest ever-used click + 1 */
};
#define phys_cp_req vir_cp_req
struct vir_cp_req {
struct vir_addr src;
@@ -98,14 +85,14 @@ struct kinfo {
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 _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;
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 */
@@ -176,4 +163,21 @@ struct memory {
phys_bytes size;
};
#define STATICINIT(v, n) \
if(!(v)) { \
phys_bytes myph; \
if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, &myph))) { \
panic(__FILE__, "allocating " #v " failed", 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 */
};
#endif /* _TYPE_H */

29
include/minix/vm.h Executable file
View File

@@ -0,0 +1,29 @@
/* Prototypes and definitions for VM interface. */
#ifndef _MINIX_VM_H
#define _MINIX_VM_H
#include <sys/types.h>
#include <minix/endpoint.h>
_PROTOTYPE( int vm_exit, (endpoint_t ep));
_PROTOTYPE( int vm_fork, (endpoint_t ep, int slotno, int *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 req_e, endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE( int vm_deldma, (endpoint_t req_e, endpoint_t proc_e,
phys_bytes start, phys_bytes size) );
_PROTOTYPE( int vm_getdma, (endpoint_t req_e, endpoint_t *procp,
phys_bytes *basep, phys_bytes *sizep) );
_PROTOTYPE( void *vm_map_phys, (endpoint_t who, size_t len, void *physaddr));
_PROTOTYPE( int vm_unmap_phys, (endpoint_t who, void *vaddr, size_t len));
_PROTOTYPE( int vm_allocmem, (phys_clicks memclicks, phys_clicks *retmembase));
#endif /* _MINIX_VM_H */

View File

@@ -36,4 +36,8 @@
#define KIOCSLEDS _IOW('k', 2, struct kio_leds)
#define KIOCSMAP _IOW('k', 3, keymap_t)
/* /dev/video ioctls. */
#define TIOCMAPMEM _IORW('v', 1, struct mapreqvm)
#define TIOCUNMAPMEM _IORW('v', 2, struct mapreqvm)
#endif /* _S_I_TTY_H */

29
include/sys/mman.h Executable file
View File

@@ -0,0 +1,29 @@
#ifndef _MMAN_H
#define _MMAN_H
#ifndef _TYPES_H
#include <sys/types.h>
#endif
/* prot argument for mmap() */
#define PROT_NONE 0x00 /* no permissions */
#define PROT_READ 0x01 /* pages can be read */
#define PROT_WRITE 0x02 /* pages can be written */
#define PROT_EXEC 0x04 /* pages can be executed */
/* flags argument for mmap() */
#define MAP_SHARED 0x0001 /* share changes */
#define MAP_PRIVATE 0x0002 /* changes are private */
#define MAP_ANON 0x0004 /* anonymous memory */
#define MAP_PREALLOC 0x0008 /* not on-demand */
#define MAP_CONTIG 0x0010 /* contiguous in physical memory */
#define MAP_LOWER16M 0x0020 /* physically below 16MB */
/* mmap() error return */
#define MAP_FAILED ((void *)-1)
_PROTOTYPE( void *mmap, (void *, size_t, int, int, int, off_t));
_PROTOTYPE( int munmap, (void *, size_t));
#endif /* _MMAN_H */

39
include/sys/video.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef _SYS_VIDEO_H
#define _SYS_VIDEO_H 1
/* Definitions used by the console driver. */
#define MONO_BASE 0xB0000L /* base of mono video memory */
#define COLOR_BASE 0xB8000L /* base of color video memory */
#define MONO_SIZE 0x1000 /* 4K mono video memory */
#define COLOR_SIZE 0x4000 /* 16K color video memory */
#define EGA_SIZE 0x8000 /* EGA & VGA have at least 32K */
#define BLANK_COLOR 0x0700 /* determines cursor color on blank screen */
#define SCROLL_UP 0 /* scroll forward */
#define SCROLL_DOWN 1 /* scroll backward */
#define BLANK_MEM ((u16_t *) 0) /* tells mem_vid_copy() to blank the screen */
#define CONS_RAM_WORDS 80 /* video ram buffer size */
#define MAX_ESC_PARMS 4 /* number of escape sequence params allowed */
/* Constants relating to the controller chips. */
#define M_6845 0x3B4 /* port for 6845 mono */
#define C_6845 0x3D4 /* port for 6845 color */
#define INDEX 0 /* 6845's index register */
#define DATA 1 /* 6845's data register */
#define STATUS 6 /* 6845's status register */
#define VID_ORG 12 /* 6845's origin register */
#define CURSOR 14 /* 6845's cursor register */
/* Beeper. */
#define BEEP_FREQ 0x0533 /* value to put into timer to set beep freq */
#define B_TIME 3 /* length of CTRL-G beep is ticks */
/* definitions used for font management */
#define GA_SEQUENCER_INDEX 0x3C4
#define GA_SEQUENCER_DATA 0x3C5
#define GA_GRAPHICS_INDEX 0x3CE
#define GA_GRAPHICS_DATA 0x3CF
#define GA_VIDEO_ADDRESS 0xA0000L
#define GA_FONT_SIZE 8192
#endif

View File

@@ -2,8 +2,6 @@
sys/vm.h
*/
#define PAGE_SIZE 4096
/* MIOCMAP */
struct mapreq
{
@@ -13,18 +11,14 @@ struct mapreq
int readonly;
};
/* i386 paging constants */
#define I386_VM_PRESENT 0x001 /* Page is present */
#define I386_VM_WRITE 0x002 /* Read/write access allowed */
#define I386_VM_USER 0x004 /* User access allowed */
#define I386_VM_PWT 0x008 /* Write through */
#define I386_VM_PCD 0x010 /* Cache disable */
#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
#define I386_CR0_PG 0x80000000 /* Enable paging */
/* MIOCMAPVM */
struct mapreqvm
{
int flags; /* reserved, must be 0 */
off_t phys_offset;
size_t size;
int readonly;
char reserved[40]; /* reserved, must be 0 */
void *vaddr_ret; /* result vaddr */
};

45
include/sys/vm_i386.h Normal file
View File

@@ -0,0 +1,45 @@
/*
sys/vm_i386.h
*/
#define I386_PAGE_SIZE 4096
/* i386 paging constants */
#define I386_VM_PRESENT 0x001 /* Page is present */
#define I386_VM_WRITE 0x002 /* Read/write access allowed */
#define I386_VM_USER 0x004 /* User access allowed */
#define I386_VM_PWT 0x008 /* Write through */
#define I386_VM_PCD 0x010 /* Cache disable */
#define I386_VM_ACC 0x020 /* Accessed */
#define I386_VM_ADDR_MASK 0xFFFFF000 /* physical address */
/* Page directory specific flags. */
#define I386_VM_BIGPAGE 0x080 /* 4MB page */
/* Page table specific flags. */
#define I386_VM_DIRTY 0x040 /* Dirty */
#define I386_VM_PTAVAIL1 0x080 /* Available for use. */
#define I386_VM_PTAVAIL2 0x100 /* Available for use. */
#define I386_VM_PT_ENT_SIZE 4 /* Size of a page table entry */
#define I386_VM_DIR_ENTRIES 1024 /* Number of entries in a page dir */
#define I386_VM_DIR_ENT_SHIFT 22 /* Shift to get entry in page dir. */
#define I386_VM_PT_ENT_SHIFT 12 /* Shift to get entry in page table */
#define I386_VM_PT_ENT_MASK 0x3FF /* Mask to get entry in page table */
#define I386_VM_PT_ENTRIES 1024 /* Number of entries in a page table */
#define I386_VM_PFA_SHIFT 22 /* Page frame address shift */
#define I386_CR0_PG 0x80000000 /* Enable paging */
/* i386 paging 'functions' */
#define I386_VM_PTE(v) (((v) >> I386_VM_PT_ENT_SHIFT) & I386_VM_PT_ENT_MASK)
#define I386_VM_PDE(v) ( (v) >> I386_VM_DIR_ENT_SHIFT)
#define I386_VM_PFA(e) ( (e) & I386_VM_ADDR_MASK)
#define I386_VM_PAGE(v) ( (v) >> I386_VM_PFA_SHIFT)
/* i386 pagefault error code bits */
#define I386_VM_PFE_P 0x01 /* Pagefault caused by non-present page.
* (otherwise protection violation.)
*/
#define I386_VM_PFE_W 0x02 /* Caused by write (otherwise read) */
#define I386_VM_PFE_U 0x04 /* CPU in user mode (otherwise supervisor) */

View File

@@ -9,7 +9,7 @@
#ifndef _TIME_H
#define _TIME_H
#define CLOCKS_PER_SEC 60 /* MINIX always uses 60 Hz, even in Europe */
#define CLOCKS_PER_SEC 60
#ifdef _POSIX_SOURCE
#define CLK_TCK CLOCKS_PER_SEC /* obsolescent mame for CLOCKS_PER_SEC */

View File

@@ -1,3 +1,6 @@
#ifndef _INCLUDE_TOOLS_H
#define _INCLUDE_TOOLS_H 1
/* Constants describing the disk */
#define SECTOR_SIZE 512
#define SECTOR_SHIFT 9
@@ -121,3 +124,4 @@ _PROTOTYPE( void relocate, (void));
_PROTOTYPE( int writesectors, (int _off, int _seg, off_t _adr, int _ct));
#endif
#endif