Initial revision
This commit is contained in:
162
lib/syslib/Makefile
Executable file
162
lib/syslib/Makefile
Executable file
@@ -0,0 +1,162 @@
|
||||
# Makefile for lib/syslib.
|
||||
|
||||
CFLAGS = -O -D_MINIX -D_POSIX_SOURCE
|
||||
CC1 = $(CC) $(CFLAGS) -c
|
||||
|
||||
LIBSYS = ../libsys.a
|
||||
all: $(LIBSYS)
|
||||
|
||||
OBJECTS = \
|
||||
$(LIBSYS)(kmalloc.o) \
|
||||
$(LIBSYS)(kprintf.o) \
|
||||
$(LIBSYS)(kputc.o) \
|
||||
$(LIBSYS)(sys_times.o) \
|
||||
$(LIBSYS)(sys_getuptm.o) \
|
||||
$(LIBSYS)(sys_abort.o) \
|
||||
$(LIBSYS)(sys_copy.o) \
|
||||
$(LIBSYS)(sys_exec.o) \
|
||||
$(LIBSYS)(sys_fork.o) \
|
||||
$(LIBSYS)(sys_kill.o) \
|
||||
$(LIBSYS)(sys_newmap.o) \
|
||||
$(LIBSYS)(sys_sigctl.o) \
|
||||
$(LIBSYS)(sys_svrctl.o) \
|
||||
$(LIBSYS)(sys_trace.o) \
|
||||
$(LIBSYS)(sys_xit.o) \
|
||||
$(LIBSYS)(sys_sdevio.o) \
|
||||
$(LIBSYS)(sys_getinfo.o) \
|
||||
$(LIBSYS)(sys_kmalloc.o) \
|
||||
$(LIBSYS)(sys_irqctl.o) \
|
||||
$(LIBSYS)(sys_eniop.o) \
|
||||
$(LIBSYS)(sys_ph2sg.o) \
|
||||
$(LIBSYS)(sys_umap.o) \
|
||||
$(LIBSYS)(sys_exit.o) \
|
||||
$(LIBSYS)(sys_physcp.o) \
|
||||
$(LIBSYS)(sys_vircp.o) \
|
||||
$(LIBSYS)(sys_in.o) \
|
||||
$(LIBSYS)(sys_out.o) \
|
||||
$(LIBSYS)(sys_vinb.o) \
|
||||
$(LIBSYS)(sys_vinw.o) \
|
||||
$(LIBSYS)(sys_vinl.o) \
|
||||
$(LIBSYS)(sys_voutb.o) \
|
||||
$(LIBSYS)(sys_voutw.o) \
|
||||
$(LIBSYS)(sys_voutl.o) \
|
||||
$(LIBSYS)(sys_signalrm.o) \
|
||||
$(LIBSYS)(sys_flagalrm.o) \
|
||||
$(LIBSYS)(sys_syncalrm.o) \
|
||||
$(LIBSYS)(taskcall.o) \
|
||||
|
||||
$(LIBSYS): $(OBJECTS)
|
||||
aal cr $@ *.o
|
||||
rm *.o
|
||||
|
||||
$(LIBSYS)(kmalloc.o): kmalloc.c
|
||||
$(CC1) kmalloc.c
|
||||
|
||||
$(LIBSYS)(kprintf.o): kprintf.c
|
||||
$(CC1) kprintf.c
|
||||
|
||||
$(LIBSYS)(kputc.o): kputc.c
|
||||
$(CC1) kputc.c
|
||||
|
||||
$(LIBSYS)(sys_times.o): sys_times.c
|
||||
$(CC1) sys_times.c
|
||||
|
||||
$(LIBSYS)(sys_getuptm.o): sys_getuptm.c
|
||||
$(CC1) sys_getuptm.c
|
||||
|
||||
$(LIBSYS)(sys_abort.o): sys_abort.c
|
||||
$(CC1) sys_abort.c
|
||||
|
||||
$(LIBSYS)(sys_copy.o): sys_copy.c
|
||||
$(CC1) sys_copy.c
|
||||
|
||||
$(LIBSYS)(sys_exec.o): sys_exec.c
|
||||
$(CC1) sys_exec.c
|
||||
|
||||
$(LIBSYS)(sys_fork.o): sys_fork.c
|
||||
$(CC1) sys_fork.c
|
||||
|
||||
$(LIBSYS)(sys_kill.o): sys_kill.c
|
||||
$(CC1) sys_kill.c
|
||||
|
||||
$(LIBSYS)(sys_newmap.o): sys_newmap.c
|
||||
$(CC1) sys_newmap.c
|
||||
|
||||
$(LIBSYS)(sys_svrctl.o): sys_svrctl.c
|
||||
$(CC1) sys_svrctl.c
|
||||
|
||||
$(LIBSYS)(sys_trace.o): sys_trace.c
|
||||
$(CC1) sys_trace.c
|
||||
|
||||
$(LIBSYS)(sys_xit.o): sys_xit.c
|
||||
$(CC1) sys_xit.c
|
||||
|
||||
$(LIBSYS)(sys_sdevio.o): sys_sdevio.c
|
||||
$(CC1) sys_sdevio.c
|
||||
|
||||
$(LIBSYS)(sys_getinfo.o): sys_getinfo.c
|
||||
$(CC1) sys_getinfo.c
|
||||
|
||||
$(LIBSYS)(sys_kmalloc.o): sys_kmalloc.c
|
||||
$(CC1) sys_kmalloc.c
|
||||
|
||||
$(LIBSYS)(sys_irqctl.o): sys_irqctl.c
|
||||
$(CC1) sys_irqctl.c
|
||||
|
||||
$(LIBSYS)(sys_eniop.o): sys_eniop.c
|
||||
$(CC1) sys_eniop.c
|
||||
|
||||
$(LIBSYS)(sys_ph2sg.o): sys_ph2sg.c
|
||||
$(CC1) sys_ph2sg.c
|
||||
|
||||
$(LIBSYS)(sys_umap.o): sys_umap.c
|
||||
$(CC1) sys_umap.c
|
||||
|
||||
$(LIBSYS)(sys_exit.o): sys_exit.c
|
||||
$(CC1) sys_exit.c
|
||||
|
||||
$(LIBSYS)(sys_sigctl.o): sys_sigctl.c
|
||||
$(CC1) sys_sigctl.c
|
||||
|
||||
$(LIBSYS)(sys_physcp.o): sys_physcp.c
|
||||
$(CC1) sys_physcp.c
|
||||
|
||||
$(LIBSYS)(sys_vircp.o): sys_vircp.c
|
||||
$(CC1) sys_vircp.c
|
||||
|
||||
$(LIBSYS)(sys_out.o): sys_out.c
|
||||
$(CC1) sys_out.c
|
||||
|
||||
$(LIBSYS)(sys_in.o): sys_in.c
|
||||
$(CC1) sys_in.c
|
||||
|
||||
$(LIBSYS)(sys_voutb.o): sys_voutb.c
|
||||
$(CC1) sys_voutb.c
|
||||
|
||||
$(LIBSYS)(sys_voutw.o): sys_voutw.c
|
||||
$(CC1) sys_voutw.c
|
||||
|
||||
$(LIBSYS)(sys_voutl.o): sys_voutl.c
|
||||
$(CC1) sys_voutl.c
|
||||
|
||||
$(LIBSYS)(sys_vinb.o): sys_vinb.c
|
||||
$(CC1) sys_vinb.c
|
||||
|
||||
$(LIBSYS)(sys_vinw.o): sys_vinw.c
|
||||
$(CC1) sys_vinw.c
|
||||
|
||||
$(LIBSYS)(sys_vinl.o): sys_vinl.c
|
||||
$(CC1) sys_vinl.c
|
||||
|
||||
$(LIBSYS)(sys_signalrm.o): sys_signalrm.c
|
||||
$(CC1) sys_signalrm.c
|
||||
|
||||
$(LIBSYS)(sys_flagalrm.o): sys_flagalrm.c
|
||||
$(CC1) sys_flagalrm.c
|
||||
|
||||
$(LIBSYS)(sys_syncalrm.o): sys_syncalrm.c
|
||||
$(CC1) sys_syncalrm.c
|
||||
|
||||
$(LIBSYS)(taskcall.o): taskcall.c
|
||||
$(CC1) taskcall.c
|
||||
|
||||
177
lib/syslib/kmalloc.c
Executable file
177
lib/syslib/kmalloc.c
Executable file
@@ -0,0 +1,177 @@
|
||||
/* malloc(), realloc(), free() - simple memory allocation routines
|
||||
*
|
||||
* This is a very small and simple minded malloc Author: Kees J. Bot
|
||||
* implementation. Ideal for things like a 29 Jan 1994
|
||||
* bootstrap program, or for debugging. Six times
|
||||
* slower than any good malloc.
|
||||
*/
|
||||
#define nil 0
|
||||
|
||||
#define sbrk _sbrk
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#if !DEBUG
|
||||
#define NDEBUG 1
|
||||
#define debug(expr) ((void) 0)
|
||||
#else
|
||||
#define debug(expr) expr
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct cell {
|
||||
size_t size; /* Size of a malloc()'ed object. */
|
||||
#if DEBUG
|
||||
unsigned magic; /* To recognize a cell. */
|
||||
#endif
|
||||
struct cell *next; /* Next cell on the free list. */
|
||||
#if DEBUG
|
||||
unsigned sacred; /* Don't touch while unallocated. */
|
||||
#endif
|
||||
} cell_t;
|
||||
|
||||
#if UINT_MAX <= 0xFFFF
|
||||
#define MAGIC 0x537B
|
||||
#else
|
||||
#define MAGIC 0x537BC0D8
|
||||
#endif
|
||||
|
||||
/* Size of the header of an object. */
|
||||
#define HDR_SIZE offsetof(cell_t, next)
|
||||
|
||||
/* An offset from a cell pointer to a next cell. */
|
||||
#define offset(cp, size) ((cell_t *) ((char *) (cp) + (size)))
|
||||
|
||||
/* Address of the object in a cell and back. */
|
||||
#define cell2obj(cp) ((void *) ((char *) (cp) + HDR_SIZE))
|
||||
#define obj2cell(op) ((cell_t *) ((char *) (op) - HDR_SIZE))
|
||||
|
||||
/* The free list. */
|
||||
static cell_t *freelist;
|
||||
|
||||
void *malloc(size_t size)
|
||||
/* Allocate an object of at least the given size. */
|
||||
{
|
||||
cell_t **pcp, *cp;
|
||||
|
||||
size += HDR_SIZE;
|
||||
if (size < sizeof(cell_t)) size= sizeof(cell_t);
|
||||
|
||||
/* Align to a word. Use a real malloc if you need better alignment. */
|
||||
size= (size + sizeof(int) - 1) & ~(sizeof(int) - 1);
|
||||
|
||||
/* Space for a magic number at the end of the chunk. */
|
||||
debug(size += sizeof(unsigned));
|
||||
|
||||
for (;;) {
|
||||
/* Do a first fit search. */
|
||||
pcp= &freelist;
|
||||
while ((cp= *pcp) != nil) {
|
||||
cell_t *next= cp->next;
|
||||
|
||||
assert(cp->magic == MAGIC);
|
||||
assert(cp->sacred == MAGIC);
|
||||
|
||||
if (offset(cp, cp->size) == next) {
|
||||
/* Join adjacent free cells. */
|
||||
assert(next->magic == MAGIC);
|
||||
assert(next->sacred == MAGIC);
|
||||
|
||||
cp->size+= next->size;
|
||||
cp->next= next->next;
|
||||
|
||||
continue; /* Try again. */
|
||||
}
|
||||
if (size <= cp->size) break; /* Big enough. */
|
||||
|
||||
/* Next cell. */
|
||||
pcp= &cp->next;
|
||||
}
|
||||
|
||||
if (cp != nil) break; /* Found a big enough chunk. */
|
||||
|
||||
/* Allocate a new chunk at the break. */
|
||||
if ((cp= (cell_t *) sbrk(size)) == (cell_t *) -1) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
cp->size= size;
|
||||
cp->next= nil;
|
||||
debug(cp->magic= MAGIC);
|
||||
debug(cp->sacred= MAGIC);
|
||||
*pcp= cp;
|
||||
}
|
||||
|
||||
/* We've got a cell that is big enough. Can we break it up? */
|
||||
if (cp->size >= size + sizeof(cell_t)) {
|
||||
cell_t *next= offset(cp, size);
|
||||
|
||||
next->size= cp->size - size;
|
||||
next->next= cp->next;
|
||||
debug(next->magic= MAGIC);
|
||||
debug(next->sacred= MAGIC);
|
||||
cp->size= size;
|
||||
cp->next= next;
|
||||
}
|
||||
|
||||
/* Unchain the cell we've found and return an address in it. */
|
||||
*pcp= cp->next;
|
||||
debug(memset(cell2obj(cp), 0xAA, cp->size - HDR_SIZE));
|
||||
debug(((unsigned *) offset(cp, cp->size))[-1]= MAGIC);
|
||||
|
||||
return cell2obj(cp);
|
||||
}
|
||||
|
||||
void free(void *op)
|
||||
/* Deallocate an object. */
|
||||
{
|
||||
cell_t **prev, *next, *cp;
|
||||
|
||||
if (op == nil) return; /* Aaargh. */
|
||||
|
||||
cp= obj2cell(op);
|
||||
assert(cp->magic == MAGIC);
|
||||
assert(((unsigned *) offset(cp, cp->size))[-1] == MAGIC);
|
||||
debug(cp->sacred= MAGIC);
|
||||
|
||||
/* Find the spot where the object belongs. */
|
||||
prev= &freelist;
|
||||
while ((next= *prev) != nil && next < cp) {
|
||||
assert(next->magic == MAGIC);
|
||||
assert(next->sacred == MAGIC);
|
||||
prev= &next->next;
|
||||
}
|
||||
|
||||
/* Put the new free cell in the list. */
|
||||
*prev= cp;
|
||||
cp->next= next;
|
||||
|
||||
#if DEBUG
|
||||
/* Check the rest of the list. */
|
||||
while (next != nil) {
|
||||
assert(next->magic == MAGIC);
|
||||
assert(next->sacred == MAGIC);
|
||||
next= next->next;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void *realloc(void *op, size_t size)
|
||||
/* Change the size of an object. Don't bother being smart, just copy it. */
|
||||
{
|
||||
size_t oldsize;
|
||||
void *new;
|
||||
|
||||
oldsize= op == nil ? 0 : obj2cell(op)->size - HDR_SIZE;
|
||||
|
||||
new= malloc(size);
|
||||
memcpy(new, op, oldsize > size ? size : oldsize);
|
||||
free(op);
|
||||
return new;
|
||||
}
|
||||
|
||||
/*
|
||||
* $PchId: malloc.c,v 1.4 1996/02/22 09:15:56 philip Exp $
|
||||
*/
|
||||
189
lib/syslib/kprintf.c
Executable file
189
lib/syslib/kprintf.c
Executable file
@@ -0,0 +1,189 @@
|
||||
/* printf() - kernel printf() Author: Kees J. Bot
|
||||
* 15 Jan 1994
|
||||
*/
|
||||
#define nil 0
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define isdigit(c) ((unsigned) ((c) - '0') < (unsigned) 10)
|
||||
|
||||
#if !__STDC__
|
||||
/* Classic C stuff, ignore. */
|
||||
void kputc();
|
||||
int printf(fmt) char *fmt;
|
||||
#else
|
||||
|
||||
/* Printf() uses kputc() to print characters. */
|
||||
void kputc(int c);
|
||||
|
||||
int printf(const char *fmt, ...)
|
||||
#endif
|
||||
{
|
||||
int c;
|
||||
enum { LEFT, RIGHT } adjust;
|
||||
enum { LONG, INT } intsize;
|
||||
int fill;
|
||||
int width, max, len, base;
|
||||
static char X2C_tab[]= "0123456789ABCDEF";
|
||||
static char x2c_tab[]= "0123456789abcdef";
|
||||
char *x2c;
|
||||
char *p;
|
||||
long i;
|
||||
unsigned long u;
|
||||
char temp[8 * sizeof(long) / 3 + 2];
|
||||
|
||||
va_list argp;
|
||||
|
||||
va_start(argp, fmt);
|
||||
|
||||
while ((c= *fmt++) != 0) {
|
||||
if (c != '%') {
|
||||
/* Ordinary character. */
|
||||
kputc(c);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Format specifier of the form:
|
||||
* %[adjust][fill][width][.max]keys
|
||||
*/
|
||||
c= *fmt++;
|
||||
|
||||
adjust= RIGHT;
|
||||
if (c == '-') {
|
||||
adjust= LEFT;
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
fill= ' ';
|
||||
if (c == '0') {
|
||||
fill= '0';
|
||||
c= *fmt++;
|
||||
}
|
||||
|
||||
width= 0;
|
||||
if (c == '*') {
|
||||
/* Width is specified as an argument, e.g. %*d. */
|
||||
width= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
/* A number tells the width, e.g. %10d. */
|
||||
do {
|
||||
width= width * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
|
||||
max= INT_MAX;
|
||||
if (c == '.') {
|
||||
/* Max field length coming up. */
|
||||
if ((c= *fmt++) == '*') {
|
||||
max= va_arg(argp, int);
|
||||
c= *fmt++;
|
||||
} else
|
||||
if (isdigit(c)) {
|
||||
max= 0;
|
||||
do {
|
||||
max= max * 10 + (c - '0');
|
||||
} while (isdigit(c= *fmt++));
|
||||
}
|
||||
}
|
||||
|
||||
/* Set a few flags to the default. */
|
||||
x2c= x2c_tab;
|
||||
i= 0;
|
||||
base= 10;
|
||||
intsize= INT;
|
||||
if (c == 'l' || c == 'L') {
|
||||
/* "Long" key, e.g. %ld. */
|
||||
intsize= LONG;
|
||||
c= *fmt++;
|
||||
}
|
||||
if (c == 0) break;
|
||||
|
||||
switch (c) {
|
||||
/* Decimal. */
|
||||
case 'd':
|
||||
i= intsize == LONG ? va_arg(argp, long)
|
||||
: va_arg(argp, int);
|
||||
u= i < 0 ? -i : i;
|
||||
goto int2ascii;
|
||||
|
||||
/* Octal. */
|
||||
case 'o':
|
||||
base= 010;
|
||||
goto getint;
|
||||
|
||||
/* Pointer, interpret as %X or %lX. */
|
||||
case 'p':
|
||||
if (sizeof(char *) > sizeof(int)) intsize= LONG;
|
||||
|
||||
/* Hexadecimal. %X prints upper case A-F, not %lx. */
|
||||
case 'X':
|
||||
x2c= X2C_tab;
|
||||
case 'x':
|
||||
base= 0x10;
|
||||
goto getint;
|
||||
|
||||
/* Unsigned decimal. */
|
||||
case 'u':
|
||||
getint:
|
||||
u= intsize == LONG ? va_arg(argp, unsigned long)
|
||||
: va_arg(argp, unsigned int);
|
||||
int2ascii:
|
||||
p= temp + sizeof(temp)-1;
|
||||
*p= 0;
|
||||
do {
|
||||
*--p= x2c[(ptrdiff_t) (u % base)];
|
||||
} while ((u /= base) > 0);
|
||||
goto string_length;
|
||||
|
||||
/* A character. */
|
||||
case 'c':
|
||||
p= temp;
|
||||
*p= va_arg(argp, int);
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* Simply a percent. */
|
||||
case '%':
|
||||
p= temp;
|
||||
*p= '%';
|
||||
len= 1;
|
||||
goto string_print;
|
||||
|
||||
/* A string. The other cases will join in here. */
|
||||
case 's':
|
||||
p= va_arg(argp, char *);
|
||||
|
||||
string_length:
|
||||
for (len= 0; p[len] != 0 && len < max; len++) {}
|
||||
|
||||
string_print:
|
||||
width -= len;
|
||||
if (i < 0) width--;
|
||||
if (fill == '0' && i < 0) kputc('-');
|
||||
if (adjust == RIGHT) {
|
||||
while (width > 0) { kputc(fill); width--; }
|
||||
}
|
||||
if (fill == ' ' && i < 0) kputc('-');
|
||||
while (len > 0) { kputc((unsigned char) *p++); len--; }
|
||||
while (width > 0) { kputc(fill); width--; }
|
||||
break;
|
||||
|
||||
/* Unrecognized format key, echo it back. */
|
||||
default:
|
||||
kputc('%');
|
||||
kputc(c);
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the end with a null (should be something else, like -1). */
|
||||
kputc(0);
|
||||
va_end(argp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* $PchId: kprintf.c,v 1.5 1996/04/11 06:59:05 philip Exp $
|
||||
*/
|
||||
47
lib/syslib/kputc.c
Normal file
47
lib/syslib/kputc.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* A server must occasionally print some message. It uses a simple version of
|
||||
* printf() found in the system lib that calls kputc() to output characters.
|
||||
* Printing is done with a call to the kernel, and not by going through FS.
|
||||
* This way system messages end up in the kernel messages buffer and can be
|
||||
* reviewed at a later time.
|
||||
*
|
||||
* This routine can only be used by servers and device drivers. The kernel
|
||||
* must define its own kputc(). Note that the IS also defines its own kputc()
|
||||
* to directly call the TTY instead of the kernel, because it does not want
|
||||
* to pollute the kernel message buffer with its debug dumps.
|
||||
*/
|
||||
|
||||
#include "syslib.h"
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/minlib.h>
|
||||
|
||||
/*===========================================================================*
|
||||
* kputc *
|
||||
*===========================================================================*/
|
||||
void kputc(c)
|
||||
int c;
|
||||
{
|
||||
/* Accumulate another character. If 0 or buffer full, print it. */
|
||||
|
||||
static int buf_count; /* # characters in the buffer */
|
||||
static char print_buf[80]; /* output is buffered here */
|
||||
message m;
|
||||
|
||||
if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
|
||||
/* Send the buffer to the system task, or, if this process is not a
|
||||
* server yet, to standard error.
|
||||
*/
|
||||
m.DIAG_BUF_COUNT = buf_count;
|
||||
m.DIAG_PRINT_BUF = print_buf;
|
||||
m.DIAG_PROC_NR = SELF;
|
||||
m.m_type = DIAGNOSTICS;
|
||||
if (_sendrec(TTY, &m) != 0) {
|
||||
m.m1_i1 = 2;
|
||||
m.m1_i2 = buf_count;
|
||||
m.m1_p1 = print_buf;
|
||||
m.m_type = WRITE;
|
||||
(void) _sendrec(FS, &m);
|
||||
}
|
||||
buf_count = 0;
|
||||
}
|
||||
if (c != 0) print_buf[buf_count++] = c;
|
||||
}
|
||||
21
lib/syslib/sys_abort.c
Executable file
21
lib/syslib/sys_abort.c
Executable file
@@ -0,0 +1,21 @@
|
||||
#include "syslib.h"
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
PUBLIC int sys_abort(int how, ...)
|
||||
{
|
||||
/* Something awful has happened. Abandon ship. */
|
||||
|
||||
message m;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, how);
|
||||
if ((m.ABRT_HOW = how) == RBT_MONITOR) {
|
||||
m.ABRT_MON_PROC = va_arg(ap, int);
|
||||
m.ABRT_MON_ADDR = va_arg(ap, char *);
|
||||
m.ABRT_MON_LEN = va_arg(ap, size_t);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return(_taskcall(SYSTASK, SYS_ABORT, &m));
|
||||
}
|
||||
31
lib/syslib/sys_copy.c
Executable file
31
lib/syslib/sys_copy.c
Executable file
@@ -0,0 +1,31 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_copy(src_proc, src_seg, src_vir,
|
||||
dst_proc, dst_seg, dst_vir, bytes)
|
||||
int src_proc; /* source process */
|
||||
int src_seg; /* source segment: T, D, or S */
|
||||
phys_bytes src_vir; /* source virtual address (phys addr for ABS)*/
|
||||
int dst_proc; /* dest process */
|
||||
int dst_seg; /* dest segment: T, D, or S */
|
||||
phys_bytes dst_vir; /* dest virtual address (phys addr for ABS) */
|
||||
phys_bytes bytes; /* how many bytes */
|
||||
{
|
||||
/* Transfer a block of data. The source and destination can each either be a
|
||||
* process number, SELF (to set own process number), or ABS (to indicate the
|
||||
* use of an absolute memory address).
|
||||
*/
|
||||
|
||||
message copy_mess;
|
||||
|
||||
if (bytes == 0L) return(OK);
|
||||
copy_mess.CP_SRC_SPACE = src_seg;
|
||||
copy_mess.CP_SRC_PROC_NR = src_proc;
|
||||
copy_mess.CP_SRC_ADDR = (long) src_vir;
|
||||
|
||||
copy_mess.CP_DST_SPACE = dst_seg;
|
||||
copy_mess.CP_DST_PROC_NR = dst_proc;
|
||||
copy_mess.CP_DST_ADDR = (long) dst_vir;
|
||||
|
||||
copy_mess.CP_NR_BYTES = (long) bytes;
|
||||
return(_taskcall(SYSTASK, SYS_COPY, ©_mess));
|
||||
}
|
||||
10
lib/syslib/sys_endsig.c
Executable file
10
lib/syslib/sys_endsig.c
Executable file
@@ -0,0 +1,10 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_endsig(proc)
|
||||
int proc;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = proc;
|
||||
return(_taskcall(SYSTASK, SYS_ENDSIG, &m));
|
||||
}
|
||||
14
lib/syslib/sys_eniop.c
Normal file
14
lib/syslib/sys_eniop.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_enable_iop *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_enable_iop(proc_nr)
|
||||
int proc_nr; /* number of process to allow I/O */
|
||||
{
|
||||
message m_iop;
|
||||
m_iop.PROC_NR = proc_nr;
|
||||
return _taskcall(SYSTASK, SYS_IOPENABLE, &m_iop);
|
||||
}
|
||||
|
||||
|
||||
14
lib/syslib/sys_enirq.c
Normal file
14
lib/syslib/sys_enirq.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_enable_irq *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_enable_irq(int irq_nr)
|
||||
{
|
||||
message m_irq;
|
||||
m_irq.IRQ_NR = irq_nr;
|
||||
m_irq.IRQ_CTL_OP = IRQ_ENABLE;
|
||||
return _taskcall(SYSTASK, SYS_IRQCTL, &m_irq);
|
||||
}
|
||||
|
||||
|
||||
20
lib/syslib/sys_exec.c
Executable file
20
lib/syslib/sys_exec.c
Executable file
@@ -0,0 +1,20 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_exec(proc, ptr, traced, prog_name, initpc)
|
||||
int proc; /* process that did exec */
|
||||
char *ptr; /* new stack pointer */
|
||||
int traced; /* is tracing enabled? */
|
||||
char *prog_name; /* name of the new program */
|
||||
vir_bytes initpc;
|
||||
{
|
||||
/* A process has exec'd. Tell the kernel. */
|
||||
|
||||
message m;
|
||||
|
||||
m.PR_PROC_NR = proc;
|
||||
m.PR_TRACING = traced;
|
||||
m.PR_STACK_PTR = ptr;
|
||||
m.PR_NAME_PTR = prog_name;
|
||||
m.PR_IP_PTR = (char *)initpc;
|
||||
return(_taskcall(SYSTASK, SYS_EXEC, &m));
|
||||
}
|
||||
15
lib/syslib/sys_exit.c
Normal file
15
lib/syslib/sys_exit.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_exit *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_exit(int status)
|
||||
{
|
||||
/* A server wants to exit. The exit status is passed on, possibly a panic.
|
||||
*/
|
||||
message m;
|
||||
m.EXIT_STATUS = status;
|
||||
return(_taskcall(SYSTASK, SYS_EXIT, &m));
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
28
lib/syslib/sys_findproc.c
Executable file
28
lib/syslib/sys_findproc.c
Executable file
@@ -0,0 +1,28 @@
|
||||
#include "syslib.h"
|
||||
#include <string.h>
|
||||
|
||||
int sys_findproc(name, tasknr, flags)
|
||||
char *name;
|
||||
int *tasknr;
|
||||
int flags;
|
||||
{
|
||||
/* Map a task name to a task number. */
|
||||
message m;
|
||||
int r;
|
||||
|
||||
strncpy(m.m3_ca1, name, M3_STRING);
|
||||
m.m3_i1= flags;
|
||||
|
||||
/* Clear unused fields */
|
||||
m.m3_i2 = 0;
|
||||
m.m3_p1= NULL;
|
||||
|
||||
r= _taskcall(SYSTASK, SYS_FINDPROC, &m);
|
||||
|
||||
*tasknr= m.m3_i1;
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* $PchId: sys_findproc.c,v 1.2 1996/04/11 05:46:27 philip Exp $
|
||||
*/
|
||||
23
lib/syslib/sys_flagalrm.c
Normal file
23
lib/syslib/sys_flagalrm.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_flagalrm *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_flagalrm(ticks, flag_ptr)
|
||||
clock_t ticks; /* number of ticks until the flag is set */
|
||||
int *flag_ptr; /* pointer to timeout flag to be set */
|
||||
{
|
||||
/* Make a call to the clock to schedule a timeout flag alarm for the caller. */
|
||||
message m;
|
||||
|
||||
if (flag_ptr != NULL) /* expect the worst */
|
||||
*flag_ptr = 0; /* reset timeout flag first */
|
||||
m.m_type = SYS_FLAGALRM; /* alarm type requested */
|
||||
m.ALRM_PROC_NR = SELF; /* m_source will be used */
|
||||
m.ALRM_EXP_TIME = ticks; /* alarm is due after ticks */
|
||||
m.ALRM_ABS_TIME = 0; /* ticks are relative to now */
|
||||
m.ALRM_FLAG_PTR = (char *) flag_ptr;
|
||||
return _taskcall(SYSTASK, SYS_FLAGALRM, &m);
|
||||
}
|
||||
|
||||
|
||||
16
lib/syslib/sys_fork.c
Executable file
16
lib/syslib/sys_fork.c
Executable file
@@ -0,0 +1,16 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_fork(parent, child, pid)
|
||||
int parent; /* process doing the fork */
|
||||
int child; /* which proc has been created by the fork */
|
||||
int pid; /* process id assigned by MM */
|
||||
{
|
||||
/* A process has forked. Tell the kernel. */
|
||||
|
||||
message m;
|
||||
|
||||
m.PR_PPROC_NR = parent;
|
||||
m.PR_PROC_NR = child;
|
||||
m.PR_PID = pid;
|
||||
return(_taskcall(SYSTASK, SYS_FORK, &m));
|
||||
}
|
||||
14
lib/syslib/sys_fwdirq.c
Normal file
14
lib/syslib/sys_fwdirq.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_forward_irq *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_forward_irq(int irq_nr)
|
||||
{
|
||||
message m_irq;
|
||||
m_irq.IRQ_NR = irq_nr;
|
||||
m_irq.IRQ_CTL_OP = IRQ_DO_FWD;
|
||||
return _taskcall(SYSTASK, SYS_IRQCTL, &m_irq);
|
||||
}
|
||||
|
||||
|
||||
25
lib/syslib/sys_getinfo.c
Normal file
25
lib/syslib/sys_getinfo.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_getinfo *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_getinfo(request, val_ptr, val_len, key_ptr, key_len)
|
||||
int request; /* system info requested */
|
||||
void *val_ptr; /* pointer where to store it */
|
||||
int val_len; /* max length of value to get */
|
||||
void *key_ptr; /* pointer to key requested */
|
||||
int key_len; /* length of key */
|
||||
{
|
||||
message m;
|
||||
|
||||
m.I_REQUEST = request;
|
||||
m.I_PROC_NR = SELF; /* always store values at caller */
|
||||
m.I_VAL_PTR = val_ptr;
|
||||
m.I_VAL_LEN = val_len;
|
||||
m.I_KEY_PTR = key_ptr;
|
||||
m.I_KEY_LEN = key_len;
|
||||
|
||||
return(_taskcall(SYSTASK, SYS_GETINFO, &m));
|
||||
}
|
||||
|
||||
|
||||
14
lib/syslib/sys_getmap.c
Executable file
14
lib/syslib/sys_getmap.c
Executable file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_getmap(proc, ptr)
|
||||
int proc; /* process whose map is to be fetched */
|
||||
struct mem_map *ptr; /* pointer to new map */
|
||||
{
|
||||
/* Want to know map of a process, ask the kernel. */
|
||||
|
||||
message m;
|
||||
|
||||
m.m1_i1 = proc;
|
||||
m.m1_p1 = (char *) ptr;
|
||||
return(_taskcall(SYSTASK, SYS_GETMAP, &m));
|
||||
}
|
||||
16
lib/syslib/sys_getsp.c
Executable file
16
lib/syslib/sys_getsp.c
Executable file
@@ -0,0 +1,16 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_getsp(proc, newsp)
|
||||
int proc; /* process whose sp is wanted */
|
||||
vir_bytes *newsp; /* place to put sp read from kernel */
|
||||
{
|
||||
/* Ask the kernel what the sp is. */
|
||||
|
||||
message m;
|
||||
int r;
|
||||
|
||||
m.m1_i1 = proc;
|
||||
r = _taskcall(SYSTASK, SYS_GETSP, &m);
|
||||
*newsp = (vir_bytes) m.STACK_PTR;
|
||||
return(r);
|
||||
}
|
||||
14
lib/syslib/sys_getuptm.c
Normal file
14
lib/syslib/sys_getuptm.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_getuptime(ticks)
|
||||
clock_t *ticks; /* pointer to store ticks */
|
||||
{
|
||||
/* Fetch the system time. */
|
||||
message m;
|
||||
int r;
|
||||
|
||||
m.T_PROC_NR = NONE;
|
||||
r = _taskcall(SYSTASK, SYS_TIMES, &m);
|
||||
*ticks = m.T_BOOT_TICKS;
|
||||
return(r);
|
||||
}
|
||||
22
lib/syslib/sys_in.c
Normal file
22
lib/syslib/sys_in.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_in *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_in(port, value, type)
|
||||
int port; /* port address to read from */
|
||||
unsigned long *value; /* pointer where to store value */
|
||||
int type; /* byte, word, long */
|
||||
{
|
||||
message m_io;
|
||||
int result;
|
||||
|
||||
m_io.DIO_TYPE = type;
|
||||
m_io.DIO_REQUEST = DIO_INPUT;
|
||||
m_io.DIO_PORT = port;
|
||||
|
||||
result = _taskcall(SYSTASK, SYS_DEVIO, &m_io);
|
||||
*value = m_io.DIO_VALUE;
|
||||
return(result);
|
||||
}
|
||||
|
||||
30
lib/syslib/sys_irqctl.c
Normal file
30
lib/syslib/sys_irqctl.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_irqctl *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_irqctl(req, irq_vec, policy, proc_nr, port, val_ptr, mask_val)
|
||||
int req; /* IRQ control request */
|
||||
int irq_vec; /* IRQ vector to control */
|
||||
int policy; /* bit mask for policy flags */
|
||||
int proc_nr; /* process number to notify */
|
||||
long port; /* port to read or write */
|
||||
void *val_ptr; /* address store value read */
|
||||
long mask_val; /* strobe mask or value to write */
|
||||
{
|
||||
message m_irq;
|
||||
int s;
|
||||
|
||||
m_irq.m_type = SYS_IRQCTL;
|
||||
m_irq.IRQ_REQUEST = req;
|
||||
m_irq.IRQ_VECTOR = irq_vec;
|
||||
m_irq.IRQ_POLICY = policy;
|
||||
m_irq.IRQ_PROC_NR = proc_nr;
|
||||
m_irq.IRQ_PORT = port;
|
||||
m_irq.IRQ_VIR_ADDR = (vir_bytes) val_ptr;
|
||||
m_irq.IRQ_MASK_VAL = mask_val;
|
||||
|
||||
return _taskcall(SYSTASK, SYS_IRQCTL, &m_irq);
|
||||
}
|
||||
|
||||
|
||||
14
lib/syslib/sys_kill.c
Executable file
14
lib/syslib/sys_kill.c
Executable file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_kill(proc, signr)
|
||||
int proc; /* which proc has exited */
|
||||
int signr; /* signal number: 1 - 16 */
|
||||
{
|
||||
/* A proc has to be signaled via MM. Tell the kernel. */
|
||||
message m;
|
||||
|
||||
m.SIG_PROC = proc;
|
||||
m.SIG_NUMBER = signr;
|
||||
return(_taskcall(SYSTASK, SYS_KILL, &m));
|
||||
}
|
||||
|
||||
19
lib/syslib/sys_kmalloc.c
Normal file
19
lib/syslib/sys_kmalloc.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_kmalloc *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_kmalloc(size, phys_base)
|
||||
size_t size; /* size in bytes */
|
||||
phys_bytes *phys_base; /* return physical base address */
|
||||
{
|
||||
message m;
|
||||
int result;
|
||||
|
||||
m.MEM_CHUNK_SIZE = size;
|
||||
|
||||
if (OK == (result = _taskcall(SYSTASK, SYS_KMALLOC, &m)))
|
||||
*phys_base = (phys_bytes) m.MEM_CHUNK_BASE;
|
||||
return(result);
|
||||
}
|
||||
|
||||
14
lib/syslib/sys_newmap.c
Executable file
14
lib/syslib/sys_newmap.c
Executable file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_newmap(proc, ptr)
|
||||
int proc; /* process whose map is to be changed */
|
||||
struct mem_map *ptr; /* pointer to new map */
|
||||
{
|
||||
/* A process has been assigned a new memory map. Tell the kernel. */
|
||||
|
||||
message m;
|
||||
|
||||
m.PR_PROC_NR = proc;
|
||||
m.PR_MEM_PTR = (char *) ptr;
|
||||
return(_taskcall(SYSTASK, SYS_NEWMAP, &m));
|
||||
}
|
||||
16
lib/syslib/sys_oldsig.c
Executable file
16
lib/syslib/sys_oldsig.c
Executable file
@@ -0,0 +1,16 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_oldsig(proc, sig, sighandler)
|
||||
int proc; /* process to be signaled */
|
||||
int sig; /* signal number: 1 to _NSIG */
|
||||
sighandler_t sighandler; /* pointer to signal handler in user space */
|
||||
{
|
||||
/* A proc has to be signaled. Tell the kernel. This function is obsolete. */
|
||||
|
||||
message m;
|
||||
|
||||
m.m6_i1 = proc;
|
||||
m.m6_i2 = sig;
|
||||
m.m6_f1 = sighandler;
|
||||
return(_taskcall(SYSTASK, SYS_OLDSIG, &m));
|
||||
}
|
||||
20
lib/syslib/sys_out.c
Normal file
20
lib/syslib/sys_out.c
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_out *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_out(port, value, type)
|
||||
int port; /* port address to write to */
|
||||
unsigned long value; /* value to write */
|
||||
int type; /* byte, word, long */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = type;
|
||||
m_io.DIO_REQUEST = DIO_OUTPUT;
|
||||
m_io.DIO_PORT = port;
|
||||
m_io.DIO_VALUE = value;
|
||||
|
||||
return _taskcall(SYSTASK, SYS_DEVIO, &m_io);
|
||||
}
|
||||
|
||||
22
lib/syslib/sys_ph2sg.c
Normal file
22
lib/syslib/sys_ph2sg.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_phys2seg *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_phys2seg(seg, off, phys, size)
|
||||
u16_t *seg; /* return segment selector here */
|
||||
vir_bytes *off; /* return offset in segment here */
|
||||
phys_bytes phys; /* physical address to convert */
|
||||
vir_bytes size; /* size of segment */
|
||||
{
|
||||
message m;
|
||||
int s;
|
||||
m.SEG_PHYS = phys;
|
||||
m.SEG_SIZE = size;
|
||||
s = _taskcall(SYSTASK, SYS_PHYS2SEG, &m);
|
||||
*seg = (u16_t) m.SEG_SELECT;
|
||||
*off = (vir_bytes) m.SEG_OFFSET;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
18
lib/syslib/sys_physcp.c
Normal file
18
lib/syslib/sys_physcp.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_physcopy(src_phys, dst_phys, bytes)
|
||||
phys_bytes src_phys; /* source physical address */
|
||||
phys_bytes dst_phys; /* destination physical address */
|
||||
phys_bytes bytes; /* how many bytes */
|
||||
{
|
||||
/* Transfer a block of data. This uses absolute memory addresses only. Use
|
||||
* sys_umap to convert a virtual address into a physical address if needed.
|
||||
*/
|
||||
message copy_mess;
|
||||
|
||||
if (bytes == 0L) return(OK);
|
||||
copy_mess.CP_SRC_ADDR = (long) src_phys;
|
||||
copy_mess.CP_DST_ADDR = (long) dst_phys;
|
||||
copy_mess.CP_NR_BYTES = (long) bytes;
|
||||
return(_taskcall(SYSTASK, SYS_PHYSCOPY, ©_mess));
|
||||
}
|
||||
26
lib/syslib/sys_sdevio.c
Normal file
26
lib/syslib/sys_sdevio.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_sdevio *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_sdevio(req, port, type, proc_nr, buffer, count)
|
||||
int req; /* request: DIO_INPUT/ DIO_OUTPUT */
|
||||
long port; /* port address to read from */
|
||||
int type; /* byte, word, long */
|
||||
int proc_nr; /* process where buffer is */
|
||||
void *buffer; /* pointer to buffer */
|
||||
int count; /* number of elements */
|
||||
{
|
||||
message m_io;
|
||||
int result;
|
||||
|
||||
m_io.DIO_REQUEST = req;
|
||||
m_io.DIO_TYPE = type;
|
||||
m_io.DIO_PORT = port;
|
||||
m_io.DIO_VEC_PROC = proc_nr;
|
||||
m_io.DIO_VEC_ADDR = buffer;
|
||||
m_io.DIO_VEC_SIZE = count;
|
||||
|
||||
return(_taskcall(SYSTASK, SYS_SDEVIO, &m_io));
|
||||
}
|
||||
|
||||
12
lib/syslib/sys_sendsig.c
Executable file
12
lib/syslib/sys_sendsig.c
Executable file
@@ -0,0 +1,12 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_sendsig(proc, smp)
|
||||
int proc;
|
||||
struct sigmsg *smp;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = proc;
|
||||
m.m1_p1 = (char *) smp;
|
||||
return(_taskcall(SYSTASK, SYS_SENDSIG, &m));
|
||||
}
|
||||
29
lib/syslib/sys_sigctl.c
Normal file
29
lib/syslib/sys_sigctl.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_sigctl *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_sigctl(request, proc_nr, sig_ctxt, flags, k_proc_nr, k_sig_map)
|
||||
int request; /* control operation requested */
|
||||
int proc_nr; /* for which process */
|
||||
struct sigmsg *sig_ctxt; /* POSIX style handling */
|
||||
int flags; /* flags for POSIX handling */
|
||||
int *k_proc_nr; /* return process number here */
|
||||
sigset_t *k_sig_map; /* return signal map here */
|
||||
{
|
||||
message m;
|
||||
int result;
|
||||
|
||||
m.m_type = SYS_SIGCTL;
|
||||
m.SIG_REQUEST = request;
|
||||
m.SIG_PROC = proc_nr;
|
||||
m.SIG_FLAGS = flags;
|
||||
m.SIG_CTXT_PTR = (char *) sig_ctxt;
|
||||
result = _taskcall(SYSTASK, SYS_SIGCTL, &m);
|
||||
if (request == S_GETSIG && k_proc_nr != 0 && k_sig_map != 0) {
|
||||
*k_proc_nr = m.SIG_PROC;
|
||||
*k_sig_map = (sigset_t) m.SIG_MAP;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
26
lib/syslib/sys_signalrm.c
Normal file
26
lib/syslib/sys_signalrm.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_signalrm *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_signalrm(proc_nr, ticks)
|
||||
int proc_nr; /* process to send SYN_ALARM message to */
|
||||
clock_t *ticks; /* how many ticks / return ticks left here */
|
||||
{
|
||||
/* Ask the clock to schedule a synchronous alarm for the caller. The process
|
||||
* number can be SELF if the caller doesn't know its process number.
|
||||
*/
|
||||
message m;
|
||||
int s;
|
||||
|
||||
m.m_type= SYS_SIGNALRM; /* the alarm type requested */
|
||||
m.ALRM_PROC_NR = proc_nr; /* receiving process */
|
||||
m.ALRM_EXP_TIME = *ticks; /* the expiration time */
|
||||
m.ALRM_ABS_TIME = 0; /* ticks are relative to now */
|
||||
|
||||
s = _taskcall(SYSTASK, SYS_SIGNALRM, &m);
|
||||
|
||||
*ticks = m.ALRM_TIME_LEFT; /* returned by SYSTEM task */
|
||||
return s;
|
||||
}
|
||||
|
||||
14
lib/syslib/sys_sigret.c
Executable file
14
lib/syslib/sys_sigret.c
Executable file
@@ -0,0 +1,14 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_sigreturn(proc, scp, flags)
|
||||
int proc;
|
||||
vir_bytes scp;
|
||||
int flags;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = proc;
|
||||
m.m1_i2 = flags;
|
||||
m.m1_p1 = (char *) scp;
|
||||
return(_taskcall(SYSTASK, SYS_SIGRETURN, &m));
|
||||
}
|
||||
13
lib/syslib/sys_svrctl.c
Normal file
13
lib/syslib/sys_svrctl.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "syslib.h"
|
||||
|
||||
int sys_svrctl(int proc, int request, int priv, vir_bytes argp)
|
||||
{
|
||||
message m;
|
||||
|
||||
m.CTL_PROC_NR = proc;
|
||||
m.CTL_REQUEST = request;
|
||||
m.CTL_MM_PRIV = priv;
|
||||
m.CTL_ARG_PTR = (char *) argp;
|
||||
|
||||
return _taskcall(SYSTASK, SYS_SVRCTL, &m);
|
||||
}
|
||||
22
lib/syslib/sys_syncalrm.c
Normal file
22
lib/syslib/sys_syncalrm.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_syncalrm *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_syncalrm(proc_nr, exp_time, abs_time)
|
||||
int proc_nr; /* process to send SYN_ALARM message to */
|
||||
clock_t exp_time; /* expiration time for the alarm */
|
||||
int abs_time; /* use absolute or relative expiration time */
|
||||
{
|
||||
/* Ask the SYSTEM schedule a synchronous alarm for the caller. The process
|
||||
* number can be SELF if the caller doesn't know its process number.
|
||||
*/
|
||||
message m;
|
||||
|
||||
m.m_type= SYS_SYNCALRM; /* the alarm type requested */
|
||||
m.ALRM_PROC_NR = proc_nr; /* receiving process */
|
||||
m.ALRM_EXP_TIME = exp_time; /* the expiration time */
|
||||
m.ALRM_ABS_TIME = abs_time; /* time is absolute? */
|
||||
return _taskcall(SYSTASK, SYS_SYNCALRM, &m);
|
||||
}
|
||||
|
||||
13
lib/syslib/sys_sysctl.c
Executable file
13
lib/syslib/sys_sysctl.c
Executable file
@@ -0,0 +1,13 @@
|
||||
#include "syslib.h"
|
||||
|
||||
int sys_sysctl(int proc, int request, int priv, vir_bytes argp)
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m2_i1 = proc;
|
||||
m.m2_i2 = request;
|
||||
m.m2_i3 = priv;
|
||||
m.m2_p1 = (char *) argp;
|
||||
|
||||
return _taskcall(SYSTASK, SYS_SYSCTL, &m);
|
||||
}
|
||||
19
lib/syslib/sys_times.c
Executable file
19
lib/syslib/sys_times.c
Executable file
@@ -0,0 +1,19 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_times(proc, ptr)
|
||||
int proc; /* proc whose times are needed */
|
||||
clock_t ptr[5]; /* pointer to time buffer */
|
||||
{
|
||||
/* Fetch the accounting info for a proc. */
|
||||
message m;
|
||||
int r;
|
||||
|
||||
m.T_PROC_NR = proc;
|
||||
r = _taskcall(SYSTASK, SYS_TIMES, &m);
|
||||
ptr[0] = m.T_USER_TIME;
|
||||
ptr[1] = m.T_SYSTEM_TIME;
|
||||
ptr[2] = m.T_CHILD_UTIME;
|
||||
ptr[3] = m.T_CHILD_STIME;
|
||||
ptr[4] = m.T_BOOT_TICKS;
|
||||
return(r);
|
||||
}
|
||||
17
lib/syslib/sys_trace.c
Executable file
17
lib/syslib/sys_trace.c
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_trace(req, proc_nr, addr, data_p)
|
||||
int req, proc_nr;
|
||||
long addr, *data_p;
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
m.CTL_PROC_NR = proc_nr;
|
||||
m.CTL_REQUEST = req;
|
||||
m.CTL_ADDRESS = addr;
|
||||
if (data_p) m.CTL_DATA = *data_p;
|
||||
r = _taskcall(SYSTASK, SYS_TRACE, &m);
|
||||
if (data_p) *data_p = m.CTL_DATA;
|
||||
return(r);
|
||||
}
|
||||
25
lib/syslib/sys_umap.c
Normal file
25
lib/syslib/sys_umap.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_umap *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_umap(proc_nr, seg, vir_addr, bytes, phys_addr)
|
||||
int proc_nr; /* process number to do umap for */
|
||||
int seg; /* T, D, or S segment */
|
||||
vir_bytes vir_addr; /* address in bytes with segment*/
|
||||
vir_bytes bytes; /* number of bytes to be copied */
|
||||
phys_bytes *phys_addr; /* placeholder for result */
|
||||
{
|
||||
message m;
|
||||
int result;
|
||||
|
||||
m.CP_SRC_PROC_NR = proc_nr;
|
||||
m.CP_SRC_SPACE = seg;
|
||||
m.CP_SRC_ADDR = vir_addr;
|
||||
m.CP_NR_BYTES = bytes;
|
||||
|
||||
result = _taskcall(SYSTASK, SYS_UMAP, &m);
|
||||
*phys_addr = m.CP_DST_ADDR;
|
||||
return(result);
|
||||
}
|
||||
|
||||
22
lib/syslib/sys_vidcp.c
Normal file
22
lib/syslib/sys_vidcp.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_vidcopy *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_vidcopy(request, src_mem, src_vid, dst_vid, count)
|
||||
int request; /* MEM_VID_COPY or VID_VID_COPY */
|
||||
u16_t *src_mem; /* source address in memory */
|
||||
unsigned src_vid; /* source address in video memory */
|
||||
unsigned dst_vid; /* destination address in video */
|
||||
unsigned count; /* number of words to copy */
|
||||
{
|
||||
/* Console wants to display something on the screen. */
|
||||
message m;
|
||||
m.VID_REQUEST = request;
|
||||
m.VID_SRC_ADDR = src_mem;
|
||||
m.VID_SRC_OFFSET = src_vid;
|
||||
m.VID_DST_OFFSET = dst_vid;
|
||||
m.VID_CP_COUNT = count;
|
||||
return(_taskcall(SYSTASK, SYS_VIDCOPY, &m));
|
||||
}
|
||||
|
||||
18
lib/syslib/sys_vinb.c
Normal file
18
lib/syslib/sys_vinb.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_vinb *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_vinb(pvb_pairs, nr_ports)
|
||||
pvb_pair_t *pvb_pairs; /* (port,byte-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = DIO_BYTE;
|
||||
m_io.DIO_REQUEST = DIO_INPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvb_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
18
lib/syslib/sys_vinl.c
Normal file
18
lib/syslib/sys_vinl.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_vinl *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_vinl(pvl_pairs, nr_ports)
|
||||
pvl_pair_t *pvl_pairs; /* (port,long-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = DIO_LONG;
|
||||
m_io.DIO_REQUEST = DIO_INPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvl_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
19
lib/syslib/sys_vinw.c
Normal file
19
lib/syslib/sys_vinw.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "syslib.h"
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_vinw *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_vinw(pvw_pairs, nr_ports)
|
||||
pvw_pair_t *pvw_pairs; /* (port,word-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = DIO_WORD;
|
||||
m_io.DIO_REQUEST = DIO_INPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvw_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
29
lib/syslib/sys_vircp.c
Normal file
29
lib/syslib/sys_vircp.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "syslib.h"
|
||||
|
||||
PUBLIC int sys_vircopy(src_proc, src_seg, src_vir,
|
||||
dst_proc, dst_seg, dst_vir, bytes)
|
||||
int src_proc; /* source process */
|
||||
int src_seg; /* source memory segment */
|
||||
vir_bytes src_vir; /* source virtual address */
|
||||
int dst_proc; /* destination process */
|
||||
int dst_seg; /* destination memory segment */
|
||||
vir_bytes dst_vir; /* destination virtual address */
|
||||
phys_bytes bytes; /* how many bytes */
|
||||
{
|
||||
/* Transfer a block of data. The source and destination can each either be a
|
||||
* process number or SELF (to set own process number). The virtual address is
|
||||
* in the data segment (D).
|
||||
*/
|
||||
|
||||
message copy_mess;
|
||||
|
||||
if (bytes == 0L) return(OK);
|
||||
copy_mess.CP_SRC_PROC_NR = src_proc;
|
||||
copy_mess.CP_SRC_SPACE = src_seg;
|
||||
copy_mess.CP_SRC_ADDR = (long) src_vir;
|
||||
copy_mess.CP_DST_PROC_NR = dst_proc;
|
||||
copy_mess.CP_DST_SPACE = dst_seg;
|
||||
copy_mess.CP_DST_ADDR = (long) dst_vir;
|
||||
copy_mess.CP_NR_BYTES = (long) bytes;
|
||||
return(_taskcall(SYSTASK, SYS_VIRCOPY, ©_mess));
|
||||
}
|
||||
18
lib/syslib/sys_voutb.c
Normal file
18
lib/syslib/sys_voutb.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_voutb *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_voutb(pvb_pairs, nr_ports)
|
||||
pvb_pair_t *pvb_pairs; /* (port,byte-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
m_io.DIO_TYPE = DIO_BYTE;
|
||||
m_io.DIO_REQUEST = DIO_OUTPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvb_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
|
||||
18
lib/syslib/sys_voutl.c
Normal file
18
lib/syslib/sys_voutl.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_voutl *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_voutl(pvl_pairs, nr_ports)
|
||||
pvl_pair_t *pvl_pairs; /* (port,long-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = DIO_LONG;
|
||||
m_io.DIO_REQUEST = DIO_OUTPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvl_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
19
lib/syslib/sys_voutw.c
Normal file
19
lib/syslib/sys_voutw.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "syslib.h"
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_voutw *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_voutw(pvw_pairs, nr_ports)
|
||||
pvw_pair_t *pvw_pairs; /* (port,word-value)-pairs */
|
||||
int nr_ports; /* nr of pairs to be processed */
|
||||
{
|
||||
message m_io;
|
||||
|
||||
m_io.DIO_TYPE = DIO_WORD;
|
||||
m_io.DIO_REQUEST = DIO_OUTPUT;
|
||||
m_io.DIO_VEC_ADDR = (char *) pvw_pairs;
|
||||
m_io.DIO_VEC_SIZE = nr_ports;
|
||||
return _taskcall(SYSTASK, SYS_VDEVIO, &m_io);
|
||||
}
|
||||
|
||||
17
lib/syslib/sys_xit.c
Executable file
17
lib/syslib/sys_xit.c
Executable file
@@ -0,0 +1,17 @@
|
||||
#include "syslib.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* sys_xit *
|
||||
*===========================================================================*/
|
||||
PUBLIC int sys_xit(parent, proc)
|
||||
int parent; /* parent of exiting process */
|
||||
int proc; /* which process has exited */
|
||||
{
|
||||
/* A process has exited. Tell the kernel. */
|
||||
|
||||
message m;
|
||||
|
||||
m.PR_PPROC_NR = parent;
|
||||
m.PR_PROC_NR = proc;
|
||||
return(_taskcall(SYSTASK, SYS_XIT, &m));
|
||||
}
|
||||
7
lib/syslib/syslib.h
Executable file
7
lib/syslib/syslib.h
Executable file
@@ -0,0 +1,7 @@
|
||||
/* syslib.h - System library common definitions. */
|
||||
|
||||
#define _SYSTEM
|
||||
|
||||
#include <lib.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/syslib.h>
|
||||
20
lib/syslib/taskcall.c
Executable file
20
lib/syslib/taskcall.c
Executable file
@@ -0,0 +1,20 @@
|
||||
/* _taskcall() is the same as _syscall() except it returns negative error
|
||||
* codes directly and not in errno. This is a better interface for MM and
|
||||
* FS.
|
||||
*/
|
||||
|
||||
#include <lib.h>
|
||||
#include <minix/syslib.h>
|
||||
|
||||
PUBLIC int _taskcall(who, syscallnr, msgptr)
|
||||
int who;
|
||||
int syscallnr;
|
||||
register message *msgptr;
|
||||
{
|
||||
int status;
|
||||
|
||||
msgptr->m_type = syscallnr;
|
||||
status = _sendrec(who, msgptr);
|
||||
if (status != 0) return(status);
|
||||
return(msgptr->m_type);
|
||||
}
|
||||
Reference in New Issue
Block a user