Lots of const correctness.

This commit is contained in:
Kees van Reeuwijk 2010-03-27 14:31:00 +00:00
parent 9192dbecc9
commit 98493805fd
41 changed files with 180 additions and 182 deletions

View file

@ -743,7 +743,7 @@ static void sfree(char *s)
if (s != nil && s != null) free(s); if (s != nil && s != null) free(s);
} }
static char *copystr(char *s) static char *copystr(const char *s)
/* Copy a non-null string using malloc. */ /* Copy a non-null string using malloc. */
{ {
char *c; char *c;
@ -754,12 +754,12 @@ static char *copystr(char *s)
return c; return c;
} }
static int is_default(environment *e) static int is_default(const environment *e)
{ {
return (e->flags & E_SPECIAL) && e->defval == nil; return (e->flags & E_SPECIAL) && e->defval == nil;
} }
static environment **searchenv(char *name) static environment **searchenv(const char *name)
{ {
environment **aenv= &env; environment **aenv= &env;
@ -1538,7 +1538,7 @@ int expired(void)
return (Thandler != nil && milli_since(Tbase) >= Tcount); return (Thandler != nil && milli_since(Tbase) >= Tcount);
} }
void delay(char *msec) void delay(const char *msec)
/* Delay for a given time. */ /* Delay for a given time. */
{ {
u32_t base, count; u32_t base, count;
@ -1553,7 +1553,7 @@ void delay(char *msec)
} while (!interrupt() && !expired() && milli_since(base) < count); } while (!interrupt() && !expired() && milli_since(base) < count);
} }
static enum whatfun { NOFUN, SELECT, DEFFUN, USERFUN } menufun(environment *e) static enum whatfun { NOFUN, SELECT, DEFFUN, USERFUN } menufun(const environment *e)
{ {
if (!(e->flags & E_FUNCTION) || e->arg[0] == 0) return NOFUN; if (!(e->flags & E_FUNCTION) || e->arg[0] == 0) return NOFUN;
if (e->arg[1] != ',') return SELECT; if (e->arg[1] != ',') return SELECT;

View file

@ -213,7 +213,7 @@ EXTERN char *drun; /* Initial command from DOS command line. */
#endif #endif
void readblock(off_t, char *, int); void readblock(off_t, char *, int);
void delay(char *); void delay(const char *);
/* /*
* $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $ * $PchId: boot.h,v 1.12 2002/02/27 19:42:45 philip Exp $

View file

@ -84,7 +84,7 @@ int n_procs; /* Number of processes. */
#define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a))) #define between(a, c, z) ((unsigned) ((c) - (a)) <= ((z) - (a)))
void pretty_image(char *image) void pretty_image(const char *image)
/* Pretty print the name of the image to load. Translate '/' and '_' to /* Pretty print the name of the image to load. Translate '/' and '_' to
* space, first letter goes uppercase. An 'r' before a digit prints as * space, first letter goes uppercase. An 'r' before a digit prints as
* 'revision'. E.g. 'minix/1.6.16r10' -> 'Minix 1.6.16 revision 10'. * 'revision'. E.g. 'minix/1.6.16r10' -> 'Minix 1.6.16 revision 10'.
@ -234,7 +234,7 @@ void patch_sizes(void)
put_word(process[FS].data + P_INIT_OFF+4, data_size); put_word(process[FS].data + P_INIT_OFF+4, data_size);
} }
int selected(char *name) int selected(const char *name)
/* True iff name has no label or the proper label. */ /* True iff name has no label or the proper label. */
{ {
char *colon, *label; char *colon, *label;
@ -249,7 +249,7 @@ int selected(char *name)
return cmp == 0; return cmp == 0;
} }
u32_t proc_size(struct image_header *hdr) static u32_t proc_size(const struct image_header *hdr)
/* Return the size of a process in sectors as found in an image. */ /* Return the size of a process in sectors as found in an image. */
{ {
u32_t len= hdr->process.a_text; u32_t len= hdr->process.a_text;

View file

@ -40,13 +40,13 @@
#define BOOT_BLOCK_SIZE 1024 #define BOOT_BLOCK_SIZE 1024
void report(char *label) static void report(const char *label)
/* installboot: label: No such file or directory */ /* installboot: label: No such file or directory */
{ {
fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno)); fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno));
} }
void fatal(char *label) static void fatal(const char *label)
{ {
report(label); report(label);
exit(1); exit(1);
@ -75,7 +75,7 @@ char *basename(char *name)
return base; return base;
} }
void bread(FILE *f, char *name, void *buf, size_t len) static void bread(FILE *f, char *name, void *buf, size_t len)
/* Read len bytes. Don't dare return without them. */ /* Read len bytes. Don't dare return without them. */
{ {
if (len > 0 && fread(buf, len, 1, f) != 1) { if (len > 0 && fread(buf, len, 1, f) != 1) {
@ -85,7 +85,7 @@ void bread(FILE *f, char *name, void *buf, size_t len)
} }
} }
void bwrite(FILE *f, char *name, void *buf, size_t len) static void bwrite(FILE *f, char *name, const void *buf, size_t len)
{ {
if (len > 0 && fwrite(buf, len, 1, f) != 1) fatal(name); if (len > 0 && fwrite(buf, len, 1, f) != 1) fatal(name);
} }
@ -351,7 +351,7 @@ void readblock(off_t blk, char *buf, int block_size)
} }
} }
void writeblock(off_t blk, char *buf, int block_size) void writeblock(off_t blk, const char *buf, int block_size)
/* Add a function to write blocks for local use. */ /* Add a function to write blocks for local use. */
{ {
if (lseek(rawfd, blk * block_size, SEEK_SET) < 0 if (lseek(rawfd, blk * block_size, SEEK_SET) < 0
@ -685,7 +685,7 @@ void make_bootable(enum howto how, char *device, char *bootblock,
} }
} }
void install_master(char *device, char *masterboot, char **guide) static void install_master(char *device, char *masterboot, char **guide)
/* Booting a hard disk is a two stage process: The master bootstrap in sector /* Booting a hard disk is a two stage process: The master bootstrap in sector
* 0 loads the bootstrap from sector 0 of the active partition which in turn * 0 loads the bootstrap from sector 0 of the active partition which in turn
* starts the operating system. This code installs such a master bootstrap * starts the operating system. This code installs such a master bootstrap
@ -727,8 +727,8 @@ void install_master(char *device, char *masterboot, char **guide)
if (guide[0] != nil) { if (guide[0] != nil) {
/* Fixate partition to boot. */ /* Fixate partition to boot. */
char *keys= guide[0]; const char *keys= guide[0];
char *logical= guide[1]; const char *logical= guide[1];
size_t i; size_t i;
int logfd; int logfd;
u32_t offset; u32_t offset;
@ -782,7 +782,7 @@ void install_master(char *device, char *masterboot, char **guide)
writeblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE); writeblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE);
} }
void usage(void) static void usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"Usage: installboot -i(mage) image kernel mm fs ... init\n" "Usage: installboot -i(mage) image kernel mm fs ... init\n"
@ -793,7 +793,7 @@ void usage(void)
exit(1); exit(1);
} }
int isoption(char *option, char *test) static int isoption(const char *option, char *test)
/* Check if the option argument is equals "test". Also accept -i as short /* Check if the option argument is equals "test". Also accept -i as short
* for -image, and the special case -x for -extract. * for -image, and the special case -x for -extract.
*/ */

View file

@ -286,7 +286,7 @@ off_t r_vir2abs(off_t virblk)
return z; return z;
} }
ino_t r_lookup(Ino_t cwd, char *path) ino_t r_lookup(Ino_t cwd, const char *path)
/* Translates a pathname to an inode number. This is just a nice utility /* Translates a pathname to an inode number. This is just a nice utility
* function, it only needs r_stat and r_readdir. * function, it only needs r_stat and r_readdir.
*/ */

View file

@ -17,7 +17,7 @@
* Return next directory entry or 0 if there are no more. * Return next directory entry or 0 if there are no more.
* Returns -1 and sets errno on error. * Returns -1 and sets errno on error.
* *
* ino_t r_lookup(ino_t cwd, char *path); * ino_t r_lookup(ino_t cwd, const char *path);
* A utility function that translates a pathname to an * A utility function that translates a pathname to an
* inode number. It starts from directory "cwd" unless * inode number. It starts from directory "cwd" unless
* path starts with a '/', then from ROOT_INO. * path starts with a '/', then from ROOT_INO.
@ -39,7 +39,7 @@ extern off_t r_super(int *);
extern void r_stat(Ino_t file, struct stat *stp); extern void r_stat(Ino_t file, struct stat *stp);
extern off_t r_vir2abs(off_t virblockno); extern off_t r_vir2abs(off_t virblockno);
extern ino_t r_readdir(char *name); extern ino_t r_readdir(char *name);
extern ino_t r_lookup(Ino_t cwd, char *path); extern ino_t r_lookup(Ino_t cwd, const char *path);
/* /*
* $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $ * $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $

View file

@ -57,7 +57,7 @@ STATIC struct alias *atab[ATABSIZE];
STATIC void setalias(char *, char *); STATIC void setalias(char *, char *);
STATIC int unalias(char *); STATIC int unalias(char *);
STATIC struct alias **hashalias(char *); STATIC struct alias **hashalias(const char *);
STATIC STATIC
void void
@ -250,7 +250,7 @@ unaliascmd(int argc __unused, char **argv __unused)
} }
STATIC struct alias ** STATIC struct alias **
hashalias(char *p) hashalias(const char *p)
{ {
unsigned int hashval; unsigned int hashval;

View file

@ -68,10 +68,10 @@ __FBSDID("$FreeBSD: src/bin/sh/cd.c,v 1.34 2004/04/06 20:06:51 markm Exp $");
#include "cd.h" #include "cd.h"
STATIC int cdlogical(char *); STATIC int cdlogical(char *);
STATIC int cdphysical(char *); STATIC int cdphysical(const char *);
STATIC int docd(char *, int, int); STATIC int docd(char *, int, int);
STATIC char *getcomponent(void); STATIC char *getcomponent(void);
STATIC int updatepwd(char *); STATIC int updatepwd(const char *);
STATIC char *curdir = NULL; /* current working directory */ STATIC char *curdir = NULL; /* current working directory */
STATIC char *prevdir; /* previous working directory */ STATIC char *prevdir; /* previous working directory */
@ -212,7 +212,7 @@ cdlogical(char *dest)
} }
STATIC int STATIC int
cdphysical(char *dest) cdphysical(const char *dest)
{ {
INTOFF; INTOFF;
@ -255,7 +255,7 @@ getcomponent(void)
* that the current directory has changed. * that the current directory has changed.
*/ */
STATIC int STATIC int
updatepwd(char *dir) updatepwd(const char *dir)
{ {
char *new; char *new;
char *p; char *p;

View file

@ -378,7 +378,7 @@ void cfoll(fa *f, Node *v) /* enter follow set of each leaf of vertex v into lfo
} }
} }
int first(Node *p) /* collects initially active leaves of p into setvec */ int first(const Node *p) /* collects initially active leaves of p into setvec */
/* returns 0 if p matches empty string */ /* returns 0 if p matches empty string */
{ {
int b, lp; int b, lp;

View file

@ -48,7 +48,7 @@ extern int quoted(char **);
extern char *cclenter(const char *); extern char *cclenter(const char *);
extern void overflo(const char *); extern void overflo(const char *);
extern void cfoll(fa *, Node *); extern void cfoll(fa *, Node *);
extern int first(Node *); extern int first(const Node *);
extern void follow(Node *); extern void follow(Node *);
extern int member(int, const char *); extern int member(int, const char *);
extern int match(fa *, const char *); extern int match(fa *, const char *);
@ -97,12 +97,12 @@ extern void syminit(void);
extern void arginit(int, char **); extern void arginit(int, char **);
extern void envinit(char **); extern void envinit(char **);
extern Array *makesymtab(int); extern Array *makesymtab(int);
extern void freesymtab(Cell *); extern void freesymtab(const Cell *);
extern void freeelem(Cell *, const char *); extern void freeelem(const Cell *, const char *);
extern Cell *setsymtab(const char *, const char *, double, unsigned int, Array *); extern Cell *setsymtab(const char *, const char *, double, unsigned int, Array *);
extern int hash(const char *, int); extern int hash(const char *, int);
extern void rehash(Array *); extern void rehash(Array *);
extern Cell *lookup(const char *, Array *); extern Cell *lookup(const char *, const Array *);
extern double setfval(Cell *, double); extern double setfval(Cell *, double);
extern void funnyvar(Cell *, const char *); extern void funnyvar(Cell *, const char *);
extern char *setsval(Cell *, const char *); extern char *setsval(Cell *, const char *);

View file

@ -154,7 +154,7 @@ Array *makesymtab(int n) /* make a new symbol table */
return(ap); return(ap);
} }
void freesymtab(Cell *ap) /* free a symbol table */ void freesymtab(const Cell *ap) /* free a symbol table */
{ {
Cell *cp, *temp; Cell *cp, *temp;
Array *tp; Array *tp;
@ -182,7 +182,8 @@ void freesymtab(Cell *ap) /* free a symbol table */
free(tp); free(tp);
} }
void freeelem(Cell *ap, const char *s) /* free elem s from ap (i.e., ap["s"] */ void freeelem(const Cell *ap, const char *s)
/* free elem s from ap (i.e., ap["s"] */
{ {
Array *tp; Array *tp;
Cell *p, *prev = NULL; Cell *p, *prev = NULL;
@ -266,7 +267,7 @@ void rehash(Array *tp) /* rehash items in small table into big one */
tp->size = nsz; tp->size = nsz;
} }
Cell *lookup(const char *s, Array *tp) /* look for s in tp */ Cell *lookup(const char *s, const Array *tp) /* look for s in tp */
{ {
Cell *p; Cell *p;
int h; int h;
@ -359,7 +360,8 @@ Awkfloat getfval(Cell *vp) /* get float val of a Cell */
return(vp->fval); return(vp->fval);
} }
static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */ static char *get_str_val(Cell *vp, char **fmt)
/* get string val of a Cell */
{ {
char s[100]; /* BUG: unchecked */ char s[100]; /* BUG: unchecked */
double dtemp; double dtemp;

View file

@ -28,8 +28,8 @@ static char *prog_name;
static enum { ADD, DEL } action; static enum { ADD, DEL } action;
static void usage(void); static void usage(void);
static int name_to_ip(char *name, ipaddr_t *addr); static int name_to_ip(const char *name, ipaddr_t *addr);
static int parse_cidr(char *cidr, ipaddr_t *addr, ipaddr_t *mask); static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -297,7 +297,7 @@ static void usage(void)
exit(1); exit(1);
} }
static int name_to_ip(char *name, ipaddr_t *addr) static int name_to_ip(const char *name, ipaddr_t *addr)
{ {
/* Translate a name to an IP address. Try first with inet_aton(), then /* Translate a name to an IP address. Try first with inet_aton(), then
* with gethostbyname(). (The latter can also recognize an IP address, * with gethostbyname(). (The latter can also recognize an IP address,
@ -314,7 +314,7 @@ static int name_to_ip(char *name, ipaddr_t *addr)
return 1; return 1;
} }
static int parse_cidr(char *cidr, ipaddr_t *addr, ipaddr_t *mask) static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask)
{ {
char *slash, *check; char *slash, *check;
ipaddr_t a; ipaddr_t a;

View file

@ -43,7 +43,7 @@ static void delete(char *hostname);
static void do_set(char *hostname, char *ethername, int temp, int pub, static void do_set(char *hostname, char *ethername, int temp, int pub,
int optdelete); int optdelete);
static ipaddr_t nametoipaddr(char *hostname); static ipaddr_t nametoipaddr(char *hostname);
static void fatal(char *fmt, ...); static void fatal(const char *fmt, ...);
static void usage(void); static void usage(void);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -444,7 +444,7 @@ static char *ether_ntoa(struct ether_addr *eap)
} }
#endif #endif
static void fatal(char *fmt, ...) static void fatal(const char *fmt, ...)
{ {
va_list ap; va_list ap;

View file

@ -21,7 +21,7 @@ static char obuf[CHUNK_SIZE];
static char *op = obuf; static char *op = obuf;
static void copyout(const char *file, int fd); static void copyout(const char *file, int fd);
static void output(char *buf, size_t count); static void output(const char *buf, size_t count);
static void report(const char *label); static void report(const char *label);
static void fatal(const char *label); static void fatal(const char *label);
@ -103,7 +103,7 @@ static void copyout(const char *file, int fd)
} }
} }
static void output(char *buf, size_t count) static void output(const char *buf, size_t count)
{ {
ssize_t n; ssize_t n;

View file

@ -39,13 +39,11 @@ int rflag, errors;
struct stat st; struct stat st;
char path[PATH_MAX + 1]; char path[PATH_MAX + 1];
_PROTOTYPE(int main, (int argc, char **argv));
_PROTOTYPE(mode_t parsemode, (char *symbolic, mode_t oldmode));
_PROTOTYPE(int do_change, (char *name)); _PROTOTYPE(int do_change, (char *name));
_PROTOTYPE(void usage, (void)); _PROTOTYPE(void usage, (void));
/* Parse a P1003.2 4.7.7-conformant symbolic mode. */ /* Parse a P1003.2 4.7.7-conformant symbolic mode. */
mode_t parsemode(char *symbolic, mode_t oldmode) mode_t parsemode(const char *symbolic, mode_t oldmode)
{ {
mode_t who, mask, newmode, tmpmask; mode_t who, mask, newmode, tmpmask;
char action; char action;
@ -160,9 +158,7 @@ mode_t parsemode(char *symbolic, mode_t oldmode)
/* Main module. The single option possible (-R) does not warrant a call to /* Main module. The single option possible (-R) does not warrant a call to
* the getopt() stuff. * the getopt() stuff.
*/ */
int main(argc, argv) int main(int argc, char *argv[])
int argc;
char *argv[];
{ {
int ex_code = 0; int ex_code = 0;

View file

@ -83,7 +83,7 @@ void days2time(unsigned long days, time_t *retired, time_t *dotretired)
char *path; /* Path name constructed in path[]. */ char *path; /* Path name constructed in path[]. */
int plen= 0, pidx= 0; /* Lenght/index for path[]. */ int plen= 0, pidx= 0; /* Lenght/index for path[]. */
void addpath(int *didx, char *name) void addpath(int *didx, const char *name)
/* Add a component to path. (name may also be a full path at the first call) /* Add a component to path. (name may also be a full path at the first call)
* The index where the current path ends is stored in *pdi. * The index where the current path ends is stored in *pdi.
*/ */
@ -171,7 +171,7 @@ struct file *shorten(struct file *list)
struct file *ignore_list[1024]; struct file *ignore_list[1024];
size_t n_ignored= 0; size_t n_ignored= 0;
unsigned ihash(char *name) unsigned ihash(const char *name)
/* A simple hashing function on a file name. */ /* A simple hashing function on a file name. */
{ {
unsigned h= 0; unsigned h= 0;

View file

@ -238,7 +238,7 @@ int writable(const struct stat *stp)
#define PATH_MAX 1024 #define PATH_MAX 1024
#endif #endif
static char *link_islink(struct stat *stp, const char *file) static char *link_islink(const struct stat *stp, const char *file)
{ {
/* Tell if a file, which stat(2) information in '*stp', has been seen /* Tell if a file, which stat(2) information in '*stp', has been seen
* earlier by this function under a different name. If not return a * earlier by this function under a different name. If not return a
@ -347,7 +347,7 @@ static char *link_islink(struct stat *stp, const char *file)
} }
int trylink(const char *src, const char *dst, struct stat *srcst, int trylink(const char *src, const char *dst, struct stat *srcst,
struct stat *dstst) const struct stat *dstst)
/* Keep the link structure intact if src has been seen before. */ /* Keep the link structure intact if src has been seen before. */
{ {
char *olddst; char *olddst;
@ -679,7 +679,7 @@ void copy1(const char *src, const char *dst, struct stat *srcst,
} }
} }
void remove1(const char *src, struct stat *srcst) void remove1(const char *src, const struct stat *srcst)
{ {
if (iflag || (!fflag && !writable(srcst))) { if (iflag || (!fflag && !writable(srcst))) {
fprintf(stderr, "Remove %s? (mode = %03o) ", src, fprintf(stderr, "Remove %s? (mode = %03o) ", src,
@ -693,8 +693,8 @@ void remove1(const char *src, struct stat *srcst)
} }
} }
void link1(const char *src, const char *dst, struct stat *srcst, void link1(const char *src, const char *dst, const struct stat *srcst,
struct stat *dstst) const struct stat *dstst)
{ {
pathname_t sym; pathname_t sym;
const char *p; const char *p;

View file

@ -55,7 +55,7 @@ struct mtab { /* List of mounted devices from /etc/mtab. */
} *mtab= NULL; } *mtab= NULL;
struct mtab *searchtab(char *name); struct mtab *searchtab(char *name);
void readmtab(char *type); static void readmtab(const char *type);
int df(const struct mtab *mt); int df(const struct mtab *mt);
bit_t bit_count(unsigned blocks, bit_t bits, int fd, int bs); bit_t bit_count(unsigned blocks, bit_t bits, int fd, int bs);
@ -132,7 +132,7 @@ Filesystem Files Free Used % BUsed% Mounted on"
exit(ex); exit(ex);
} }
void readmtab(char *type) static void readmtab(const char *type)
/* Turn the mounted file table into a list. */ /* Turn the mounted file table into a list. */
{ {
struct mtab **amt= &mtab, *new; struct mtab **amt= &mtab, *new;

View file

@ -138,7 +138,7 @@ nlink_t nlink;
return(0); return(0);
} }
int get_block_size(char *dir, struct stat *st) int get_block_size(const char *dir, const struct stat *st)
{ {
struct statfs stfs; struct statfs stfs;
static int fs_block_size = -1, fs_dev = -1; static int fs_block_size = -1, fs_dev = -1;

View file

@ -38,18 +38,15 @@
char *prog = 0, *processing = 0; char *prog = 0, *processing = 0;
_PROTOTYPE(int main, (int argc, char **argv));
_PROTOTYPE(char *getline, (FILE *fp, char *b)); _PROTOTYPE(char *getline, (FILE *fp, char *b));
_PROTOTYPE(char *range, (char *s, int *p1, int *p2)); _PROTOTYPE(char *range, (char *s, int *p1, int *p2));
_PROTOTYPE(int getcommand, (FILE *fp, int *o1, int *o2, char *pcmd, int *n1, int *n2)); _PROTOTYPE(int getcommand, (FILE *fp, int *o1, int *o2, char *pcmd, int *n1, int *n2));
_PROTOTYPE(void fatal, (char *s, ...)); _PROTOTYPE(void fatal, (const char *s, ...));
_PROTOTYPE(int strwcmp, (char *s1, char *s2)); _PROTOTYPE(int strwcmp, (char *s1, char *s2));
_PROTOTYPE(int whitespace, (int ch)); _PROTOTYPE(int whitespace, (int ch));
char * char *
getline(fp, b) getline(FILE *fp, char *b)
FILE *fp;
char *b;
{ {
if (fgets(b, LINELEN, fp) == NULL) fatal("unexpected eof"); if (fgets(b, LINELEN, fp) == NULL) fatal("unexpected eof");
@ -58,9 +55,7 @@ char *b;
#define copy(str) printf("%s", str) #define copy(str) printf("%s", str)
int main(argc, argv) int main(int argc, char **argv)
int argc;
char **argv;
{ {
char cmd, *fl, *fd, obuf[LINELEN], nbuf[LINELEN]; char cmd, *fl, *fd, obuf[LINELEN], nbuf[LINELEN];
int o1, o2, n1, n2, here; int o1, o2, n1, n2, here;
@ -155,7 +150,7 @@ char *pcmd;
} }
#ifdef __STDC__ #ifdef __STDC__
void fatal(char *s, ...) void fatal(const char *s, ...)
{ {
va_list args; va_list args;
@ -169,7 +164,7 @@ void fatal(char *s, ...)
#else #else
/* the K&R lib does not have vfprintf */ /* the K&R lib does not have vfprintf */
void fatal(s, a) void fatal(s, a)
char *s, *a; const char *s, *a;
{ {
fprintf(stderr, "%s: processing: %s fatal: ", prog, processing); fprintf(stderr, "%s: processing: %s fatal: ", prog, processing);
fprintf(stderr, s, a); fprintf(stderr, s, a);

View file

@ -47,7 +47,7 @@ char *tty_name; /* name of the line */
/* Crude indication of a tty being physically secure: */ /* Crude indication of a tty being physically secure: */
#define securetty(dev) ((unsigned) ((dev) - 0x0400) < (unsigned) 8) #define securetty(dev) ((unsigned) ((dev) - 0x0400) < (unsigned) 8)
void std_out(char *s) void std_out(const char *s)
{ {
write(1, s, strlen(s)); write(1, s, strlen(s));
} }

View file

@ -167,12 +167,12 @@ PUBLIC void apic_calibrate_clocks(void)
cpu_set_freq(cpuid, cpu_freq); cpu_set_freq(cpuid, cpu_freq);
} }
PRIVATE void lapic_set_timer_one_shot(u32_t value) PRIVATE void lapic_set_timer_one_shot(const u32_t value)
{ {
/* sleep in micro seconds */ /* sleep in micro seconds */
u32_t lvtt; u32_t lvtt;
u32_t ticks_per_us; u32_t ticks_per_us;
u8_t cpu = cpuid; const u8_t cpu = cpuid;
ticks_per_us = lapic_bus_freq[cpu] / 1000000; ticks_per_us = lapic_bus_freq[cpu] / 1000000;
@ -187,12 +187,12 @@ PRIVATE void lapic_set_timer_one_shot(u32_t value)
lapic_write(LAPIC_TIMER_ICR, value * ticks_per_us); lapic_write(LAPIC_TIMER_ICR, value * ticks_per_us);
} }
PUBLIC void lapic_set_timer_periodic(unsigned freq) PUBLIC void lapic_set_timer_periodic(const unsigned freq)
{ {
/* sleep in micro seconds */ /* sleep in micro seconds */
u32_t lvtt; u32_t lvtt;
u32_t lapic_ticks_per_clock_tick; u32_t lapic_ticks_per_clock_tick;
u8_t cpu = cpuid; const u8_t cpu = cpuid;
lapic_ticks_per_clock_tick = lapic_bus_freq[cpu] / freq; lapic_ticks_per_clock_tick = lapic_bus_freq[cpu] / freq;
@ -432,7 +432,7 @@ PRIVATE void lapic_set_dummy_handlers(void)
#endif #endif
/* Build descriptors for interrupt gates in IDT. */ /* Build descriptors for interrupt gates in IDT. */
PUBLIC void apic_idt_init(int reset) PUBLIC void apic_idt_init(const int reset)
{ {
/* Set up idt tables for smp mode. /* Set up idt tables for smp mode.
*/ */

View file

@ -3,7 +3,7 @@
#include "debugreg.h" #include "debugreg.h"
int breakpoint_set(phys_bytes linaddr, int bp, int flags) int breakpoint_set(phys_bytes linaddr, int bp, const int flags)
{ {
u32_t dr7, dr7flags; u32_t dr7, dr7flags;

View file

@ -33,7 +33,7 @@ PRIVATE irq_hook_t pic_timer_hook; /* interrupt handler hook */
/*===========================================================================* /*===========================================================================*
* init_8235A_timer * * init_8235A_timer *
*===========================================================================*/ *===========================================================================*/
PUBLIC int init_8253A_timer(unsigned freq) PUBLIC int init_8253A_timer(const unsigned freq)
{ {
/* Initialize channel 0 of the 8253A timer to, e.g., 60 Hz, /* Initialize channel 0 of the 8253A timer to, e.g., 60 Hz,
* and register the CLOCK task's interrupt handler to be run * and register the CLOCK task's interrupt handler to be run
@ -107,7 +107,7 @@ PUBLIC void arch_stop_local_timer(void)
} }
} }
PUBLIC int arch_register_local_timer_handler(irq_handler_t handler) PUBLIC int arch_register_local_timer_handler(const irq_handler_t handler)
{ {
#ifdef CONFIG_APIC #ifdef CONFIG_APIC
if (lapic_addr) { if (lapic_addr) {

View file

@ -26,7 +26,7 @@
/*===========================================================================* /*===========================================================================*
* intr_init * * intr_init *
*===========================================================================*/ *===========================================================================*/
PUBLIC int intr_init(int mine, int auto_eoi) PUBLIC int intr_init(const int mine, const int auto_eoi)
{ {
/* Initialize the 8259s, finishing with all interrupts disabled. This is /* Initialize the 8259s, finishing with all interrupts disabled. This is
* only done in protected mode, in real mode we don't touch the 8259s, but * only done in protected mode, in real mode we don't touch the 8259s, but
@ -83,15 +83,15 @@ PUBLIC int intr_disabled(void)
return 0; return 0;
} }
PUBLIC void irq_8259_unmask(int irq) PUBLIC void irq_8259_unmask(const int irq)
{ {
unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; const unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK;
outb(ctl_mask, inb(ctl_mask) & ~(1 << (irq & 0x7))); outb(ctl_mask, inb(ctl_mask) & ~(1 << (irq & 0x7)));
} }
PUBLIC void irq_8259_mask(int irq) PUBLIC void irq_8259_mask(const int irq)
{ {
unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK; const unsigned ctl_mask = irq < 8 ? INT_CTLMASK : INT2_CTLMASK;
outb(ctl_mask, inb(ctl_mask) | (1 << (irq & 0x7))); outb(ctl_mask, inb(ctl_mask) | (1 << (irq & 0x7)));
} }

View file

@ -78,8 +78,8 @@ PUBLIC void vm_init(struct proc *newptproc)
* for actual use by phys_copy or phys_memset. * for actual use by phys_copy or phys_memset.
*/ */
PRIVATE phys_bytes createpde( PRIVATE phys_bytes createpde(
struct proc *pr, /* Requested process, NULL for physical. */ const struct proc *pr, /* Requested process, NULL for physical. */
phys_bytes linaddr, /* Address after segment translation. */ const phys_bytes linaddr,/* Address after segment translation. */
phys_bytes *bytes, /* Size of chunk, function may truncate it. */ phys_bytes *bytes, /* Size of chunk, function may truncate it. */
int pde, /* freepde number to use for the mapping. */ int pde, /* freepde number to use for the mapping. */
int *changed /* If mapping is made, this is set to 1. */ int *changed /* If mapping is made, this is set to 1. */
@ -199,7 +199,7 @@ PRIVATE int lin_lin_copy(struct proc *srcproc, vir_bytes srclinaddr,
PRIVATE u32_t phys_get32(phys_bytes addr) PRIVATE u32_t phys_get32(phys_bytes addr)
{ {
u32_t v; const u32_t v;
int r; int r;
if(!vm_running) { if(!vm_running) {
@ -285,8 +285,8 @@ PRIVATE void vm_enable_paging(void)
} }
PUBLIC vir_bytes alloc_remote_segment(u32_t *selector, PUBLIC vir_bytes alloc_remote_segment(u32_t *selector,
segframe_t *segments, int index, phys_bytes phys, vir_bytes size, segframe_t *segments, const int index, phys_bytes phys,
int priv) vir_bytes size, int priv)
{ {
phys_bytes offset = 0; phys_bytes offset = 0;
/* Check if the segment size can be recorded in bytes, that is, check /* Check if the segment size can be recorded in bytes, that is, check
@ -309,8 +309,8 @@ PUBLIC vir_bytes alloc_remote_segment(u32_t *selector,
return offset; return offset;
} }
PUBLIC phys_bytes umap_remote(struct proc* rp, int seg, PUBLIC phys_bytes umap_remote(const struct proc* rp, const int seg,
vir_bytes vir_addr, vir_bytes bytes) const vir_bytes vir_addr, const vir_bytes bytes)
{ {
/* Calculate the physical memory address for a given virtual address. */ /* Calculate the physical memory address for a given virtual address. */
struct far_mem *fm; struct far_mem *fm;
@ -423,7 +423,8 @@ vir_bytes bytes; /* # of bytes to be copied */
/*===========================================================================* /*===========================================================================*
* vm_lookup * * vm_lookup *
*===========================================================================*/ *===========================================================================*/
PUBLIC int vm_lookup(struct proc *proc, vir_bytes virtual, vir_bytes *physical, u32_t *ptent) PUBLIC int vm_lookup(const struct proc *proc, const vir_bytes virtual,
vir_bytes *physical, u32_t *ptent)
{ {
u32_t *root, *pt; u32_t *root, *pt;
int pde, pte; int pde, pte;
@ -535,8 +536,8 @@ PUBLIC int vm_contiguous(struct proc *targetproc, u32_t vir_buf, size_t bytes)
/*===========================================================================* /*===========================================================================*
* vm_suspend * * vm_suspend *
*===========================================================================*/ *===========================================================================*/
PRIVATE void vm_suspend(struct proc *caller, struct proc *target, PRIVATE void vm_suspend(struct proc *caller, const struct proc *target,
vir_bytes linaddr, vir_bytes len, int type) const vir_bytes linaddr, const vir_bytes len, const int type)
{ {
/* This range is not OK for this process. Set parameters /* This range is not OK for this process. Set parameters
* of the request and notify VM about the pending request. * of the request and notify VM about the pending request.
@ -593,7 +594,7 @@ int delivermsg(struct proc *rp)
NOREC_RETURN(deliver, r); NOREC_RETURN(deliver, r);
} }
PRIVATE char *flagstr(u32_t e, int dir) PRIVATE char *flagstr(u32_t e, const int dir)
{ {
static char str[80]; static char str[80];
strcpy(str, ""); strcpy(str, "");
@ -610,7 +611,7 @@ PRIVATE char *flagstr(u32_t e, int dir)
return str; return str;
} }
PRIVATE void vm_pt_print(u32_t *pagetable, u32_t v) PRIVATE void vm_pt_print(u32_t *pagetable, const u32_t v)
{ {
int pte; int pte;
int col = 0; int col = 0;
@ -667,7 +668,7 @@ PRIVATE void vm_print(u32_t *root)
/*===========================================================================* /*===========================================================================*
* lin_memset * * lin_memset *
*===========================================================================*/ *===========================================================================*/
int vm_phys_memset(phys_bytes ph, u8_t c, phys_bytes bytes) int vm_phys_memset(phys_bytes ph, const u8_t c, phys_bytes bytes)
{ {
u32_t p; u32_t p;
NOREC_ENTER(physmemset); NOREC_ENTER(physmemset);
@ -857,8 +858,8 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
/*===========================================================================* /*===========================================================================*
* data_copy * * data_copy *
*===========================================================================*/ *===========================================================================*/
PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr, PUBLIC int data_copy(const endpoint_t from_proc, const vir_bytes from_addr,
endpoint_t to_proc, vir_bytes to_addr, const endpoint_t to_proc, const vir_bytes to_addr,
size_t bytes) size_t bytes)
{ {
struct vir_addr src, dst; struct vir_addr src, dst;
@ -876,8 +877,8 @@ PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr,
* data_copy_vmcheck * * data_copy_vmcheck *
*===========================================================================*/ *===========================================================================*/
PUBLIC int data_copy_vmcheck(struct proc * caller, PUBLIC int data_copy_vmcheck(struct proc * caller,
endpoint_t from_proc, vir_bytes from_addr, const endpoint_t from_proc, const vir_bytes from_addr,
endpoint_t to_proc, vir_bytes to_addr, const endpoint_t to_proc, const vir_bytes to_addr,
size_t bytes) size_t bytes)
{ {
struct vir_addr src, dst; struct vir_addr src, dst;
@ -894,7 +895,7 @@ PUBLIC int data_copy_vmcheck(struct proc * caller,
/*===========================================================================* /*===========================================================================*
* arch_pre_exec * * arch_pre_exec *
*===========================================================================*/ *===========================================================================*/
PUBLIC void arch_pre_exec(struct proc *pr, u32_t ip, u32_t sp) PUBLIC void arch_pre_exec(struct proc *pr, const u32_t ip, const u32_t sp)
{ {
/* wipe extra LDT entries, set program counter, and stack pointer. */ /* wipe extra LDT entries, set program counter, and stack pointer. */
memset(pr->p_seg.p_ldt + EXTRA_LDT_INDEX, 0, memset(pr->p_seg.p_ldt + EXTRA_LDT_INDEX, 0,
@ -923,14 +924,15 @@ PUBLIC int arch_umap(struct proc *pr, vir_bytes offset, vir_bytes count,
} }
/* VM reports page directory slot we're allowed to use freely. */ /* VM reports page directory slot we're allowed to use freely. */
void i386_freepde(int pde) void i386_freepde(const int pde)
{ {
if(nfreepdes >= MAX_FREEPDES) if(nfreepdes >= MAX_FREEPDES)
return; return;
freepdes[nfreepdes++] = pde; freepdes[nfreepdes++] = pde;
} }
PUBLIC int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int *flags) PUBLIC int arch_phys_map(const int index, phys_bytes *addr,
phys_bytes *len, int *flags)
{ {
#ifdef CONFIG_APIC #ifdef CONFIG_APIC
/* map the local APIC if enabled */ /* map the local APIC if enabled */
@ -947,7 +949,7 @@ PUBLIC int arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int *flag
#endif #endif
} }
PUBLIC int arch_phys_map_reply(int index, vir_bytes addr) PUBLIC int arch_phys_map_reply(const int index, const vir_bytes addr)
{ {
#ifdef CONFIG_APIC #ifdef CONFIG_APIC
/* if local APIC is enabled */ /* if local APIC is enabled */
@ -958,7 +960,7 @@ PUBLIC int arch_phys_map_reply(int index, vir_bytes addr)
return OK; return OK;
} }
PUBLIC int arch_enable_paging(struct proc * caller, message * m_ptr) PUBLIC int arch_enable_paging(struct proc * caller, const message * m_ptr)
{ {
struct vm_ep_data ep_data; struct vm_ep_data ep_data;
int r; int r;

View file

@ -48,7 +48,7 @@ PUBLIC void enable_iop(struct proc *pp)
/*===========================================================================* /*===========================================================================*
* seg2phys * * seg2phys *
*===========================================================================*/ *===========================================================================*/
PUBLIC phys_bytes seg2phys(U16_t seg) PUBLIC phys_bytes seg2phys(const U16_t seg)
{ {
/* Return the base address of a segment, with seg being a /* Return the base address of a segment, with seg being a
* register, or a 286/386 segment selector. * register, or a 286/386 segment selector.
@ -79,7 +79,7 @@ PRIVATE void phys2seg(u16_t *seg, vir_bytes *off, phys_bytes phys)
* init_dataseg * * init_dataseg *
*===========================================================================*/ *===========================================================================*/
PUBLIC void init_dataseg(register struct segdesc_s *segdp, PUBLIC void init_dataseg(register struct segdesc_s *segdp,
phys_bytes base, vir_bytes size, int privilege) phys_bytes base, vir_bytes size, const int privilege)
{ {
/* Build descriptor for a data segment. */ /* Build descriptor for a data segment. */
sdesc(segdp, base, size); sdesc(segdp, base, size);
@ -247,9 +247,9 @@ vir_bytes size;
* int_gate * * int_gate *
*===========================================================================*/ *===========================================================================*/
PUBLIC void int_gate(vec_nr, offset, dpl_type) PUBLIC void int_gate(vec_nr, offset, dpl_type)
unsigned vec_nr; const unsigned vec_nr;
vir_bytes offset; const vir_bytes offset;
unsigned dpl_type; const unsigned dpl_type;
{ {
/* Build descriptor for an interrupt gate. */ /* Build descriptor for an interrupt gate. */
register struct gatedesc_s *idp; register struct gatedesc_s *idp;
@ -337,7 +337,8 @@ for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; ++rp) {
/*===========================================================================* /*===========================================================================*
* printseg * * printseg *
*===========================================================================*/ *===========================================================================*/
PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector) PUBLIC void printseg(char *banner, const int iscs, struct proc *pr,
const u32_t selector)
{ {
u32_t base, limit, index, dpl; u32_t base, limit, index, dpl;
struct segdesc_s *desc; struct segdesc_s *desc;
@ -424,7 +425,7 @@ PUBLIC void printseg(char *banner, int iscs, struct proc *pr, u32_t selector)
/*===========================================================================* /*===========================================================================*
* prot_set_kern_seg_limit * * prot_set_kern_seg_limit *
*===========================================================================*/ *===========================================================================*/
PUBLIC int prot_set_kern_seg_limit(vir_bytes limit) PUBLIC int prot_set_kern_seg_limit(const vir_bytes limit)
{ {
struct proc *rp; struct proc *rp;
int orig_click; int orig_click;

View file

@ -36,7 +36,7 @@ PUBLIC void arch_monitor(void)
PUBLIC int cpu_has_tsc; PUBLIC int cpu_has_tsc;
PUBLIC void arch_shutdown(int how) PUBLIC void arch_shutdown(const int how)
{ {
/* Mask all interrupts, including the clock. */ /* Mask all interrupts, including the clock. */
outb( INT_CTLMASK, ~0); outb( INT_CTLMASK, ~0);
@ -66,8 +66,8 @@ PUBLIC void arch_shutdown(int how)
if(minix_panicing) { if(minix_panicing) {
int source, dest; int source, dest;
static char mybuffer[sizeof(params_buffer)]; static char mybuffer[sizeof(params_buffer)];
char *lead = "echo \\n*** kernel messages:\\n"; const char *lead = "echo \\n*** kernel messages:\\n";
int leadlen = strlen(lead); const int leadlen = strlen(lead);
strcpy(mybuffer, lead); strcpy(mybuffer, lead);
#define DECSOURCE source = (source - 1 + _KMESS_BUF_SIZE) % _KMESS_BUF_SIZE #define DECSOURCE source = (source - 1 + _KMESS_BUF_SIZE) % _KMESS_BUF_SIZE
@ -79,7 +79,7 @@ PUBLIC void arch_shutdown(int how)
DECSOURCE; DECSOURCE;
while(dest >= leadlen) { while(dest >= leadlen) {
char c = kmess.km_buf[source]; const char c = kmess.km_buf[source];
if(c == '\n') { if(c == '\n') {
mybuffer[dest--] = 'n'; mybuffer[dest--] = 'n';
mybuffer[dest] = '\\'; mybuffer[dest] = '\\';
@ -110,7 +110,7 @@ PUBLIC void arch_shutdown(int how)
/* address of a.out headers, set in mpx386.s */ /* address of a.out headers, set in mpx386.s */
phys_bytes aout; phys_bytes aout;
PUBLIC void arch_get_aout_headers(int i, struct exec *h) PUBLIC void arch_get_aout_headers(const int i, struct exec *h)
{ {
/* The bootstrap loader created an array of the a.out headers at /* The bootstrap loader created an array of the a.out headers at
* absolute address 'aout'. Get one element to h. * absolute address 'aout'. Get one element to h.
@ -118,7 +118,8 @@ PUBLIC void arch_get_aout_headers(int i, struct exec *h)
phys_copy(aout + i * A_MINHDR, vir2phys(h), (phys_bytes) A_MINHDR); phys_copy(aout + i * A_MINHDR, vir2phys(h), (phys_bytes) A_MINHDR);
} }
PRIVATE void tss_init(struct tss_s * tss, void * kernel_stack, unsigned cpu) PRIVATE void tss_init(struct tss_s * tss, void * kernel_stack,
const unsigned cpu)
{ {
/* /*
* make space for process pointer and cpu id and point to the first * make space for process pointer and cpu id and point to the first
@ -275,7 +276,7 @@ PRIVATE void ser_dump_segs(void)
} }
} }
PRIVATE void ser_debug(int c) PRIVATE void ser_debug(const int c)
{ {
serial_debug_active = 1; serial_debug_active = 1;
@ -312,7 +313,7 @@ PRIVATE void ser_debug(int c)
serial_debug_active = 0; serial_debug_active = 0;
} }
PRIVATE void printslot(struct proc *pp, int level) PRIVATE void printslot(struct proc *pp, const int level)
{ {
struct proc *depproc = NULL; struct proc *depproc = NULL;
endpoint_t dep; endpoint_t dep;
@ -376,7 +377,7 @@ PUBLIC void ser_dump_proc()
#if SPROFILE #if SPROFILE
PUBLIC int arch_init_profile_clock(u32_t freq) PUBLIC int arch_init_profile_clock(const u32_t freq)
{ {
int r; int r;
/* Set CMOS timer frequency. */ /* Set CMOS timer frequency. */
@ -415,7 +416,7 @@ PUBLIC void arch_ack_profile_clock(void)
#define COLOR_BASE 0xB8000L #define COLOR_BASE 0xB8000L
PRIVATE void cons_setc(int pos, int c) PRIVATE void cons_setc(const int pos, const int c)
{ {
char ch; char ch;

View file

@ -44,7 +44,7 @@ PRIVATE void intel_arch_watchdog_init(int cpu)
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
} }
PRIVATE void intel_arch_watchdog_reinit(int cpu) PRIVATE void intel_arch_watchdog_reinit(const int cpu)
{ {
lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI);
ia32_msr_write(MSR_PERFMON_CRT0, 0, -watchdog->resetval); ia32_msr_write(MSR_PERFMON_CRT0, 0, -watchdog->resetval);
@ -86,7 +86,7 @@ int arch_watchdog_init(void)
return 0; return 0;
} }
void arch_watchdog_lockup(struct nmi_frame * frame) void arch_watchdog_lockup(const struct nmi_frame * frame)
{ {
printf("KERNEL LOCK UP\n" printf("KERNEL LOCK UP\n"
"eax 0x%08x\n" "eax 0x%08x\n"

View file

@ -185,7 +185,7 @@ PUBLIC int ap_timer_int_handler(void)
* user's system time. * user's system time.
*/ */
unsigned ticks = 1; const unsigned ticks = 1;
struct proc * p, * billp; struct proc * p, * billp;
#ifdef CONFIG_WATCHDOG #ifdef CONFIG_WATCHDOG

View file

@ -38,7 +38,8 @@ runqueues_ok(void)
return 0; return 0;
} }
for(xp = rdy_head[q]; xp != NIL_PROC; xp = xp->p_nextready) { for(xp = rdy_head[q]; xp != NIL_PROC; xp = xp->p_nextready) {
vir_bytes vxp = (vir_bytes) xp, dxp; const vir_bytes vxp = (vir_bytes) xp;
vir_bytes dxp;
if(vxp < (vir_bytes) BEG_PROC_ADDR || vxp >= (vir_bytes) END_PROC_ADDR) { if(vxp < (vir_bytes) BEG_PROC_ADDR || vxp >= (vir_bytes) END_PROC_ADDR) {
printf("xp out of range\n"); printf("xp out of range\n");
return 0; return 0;
@ -108,7 +109,7 @@ runqueues_ok(void)
} }
PUBLIC char * PUBLIC char *
rtsflagstr(int flags) rtsflagstr(const int flags)
{ {
static char str[100]; static char str[100];
str[0] = '\0'; str[0] = '\0';
@ -135,7 +136,7 @@ rtsflagstr(int flags)
} }
PUBLIC char * PUBLIC char *
miscflagstr(int flags) miscflagstr(const int flags)
{ {
static char str[100]; static char str[100];
str[0] = '\0'; str[0] = '\0';

View file

@ -27,7 +27,8 @@ PUBLIC irq_hook_t* irq_handlers[NR_IRQ_VECTORS] = {0};
* put_irq_handler * * put_irq_handler *
*===========================================================================*/ *===========================================================================*/
/* Register an interrupt handler. */ /* Register an interrupt handler. */
PUBLIC void put_irq_handler( irq_hook_t* hook, int irq, irq_handler_t handler) PUBLIC void put_irq_handler( irq_hook_t* hook, int irq,
const irq_handler_t handler)
{ {
int id; int id;
irq_hook_t **line; irq_hook_t **line;
@ -72,9 +73,9 @@ PUBLIC void put_irq_handler( irq_hook_t* hook, int irq, irq_handler_t handler)
* rm_irq_handler * * rm_irq_handler *
*===========================================================================*/ *===========================================================================*/
/* Unregister an interrupt handler. */ /* Unregister an interrupt handler. */
PUBLIC void rm_irq_handler( irq_hook_t* hook ) { PUBLIC void rm_irq_handler( const irq_hook_t* hook ) {
int irq = hook->irq; const int irq = hook->irq;
int id = hook->id; const int id = hook->id;
irq_hook_t **line; irq_hook_t **line;
if( irq < 0 || irq >= NR_IRQ_VECTORS ) if( irq < 0 || irq >= NR_IRQ_VECTORS )
@ -155,8 +156,7 @@ PUBLIC void irq_handle(int irq)
} }
/* Enable/Disable a interrupt line. */ /* Enable/Disable a interrupt line. */
PUBLIC void enable_irq(hook) PUBLIC void enable_irq(const irq_hook_t *hook)
irq_hook_t* hook;
{ {
if((irq_actids[hook->irq] &= ~hook->id) == 0) { if((irq_actids[hook->irq] &= ~hook->id) == 0) {
hw_intr_unmask(hook->irq); hw_intr_unmask(hook->irq);
@ -164,8 +164,7 @@ irq_hook_t* hook;
} }
/* Return true if the interrupt was enabled before call. */ /* Return true if the interrupt was enabled before call. */
PUBLIC int disable_irq(hook) PUBLIC int disable_irq(const irq_hook_t *hook)
irq_hook_t* hook;
{ {
if(irq_actids[hook->irq] & hook->id) /* already disabled */ if(irq_actids[hook->irq] & hook->id) /* already disabled */
return 0; return 0;

View file

@ -283,8 +283,7 @@ PRIVATE void announce(void)
/*===========================================================================* /*===========================================================================*
* prepare_shutdown * * prepare_shutdown *
*===========================================================================*/ *===========================================================================*/
PUBLIC void prepare_shutdown(how) PUBLIC void prepare_shutdown(const int how)
int how;
{ {
/* This function prepares to shutdown MINIX. */ /* This function prepares to shutdown MINIX. */
static timer_t shutdown_timer; static timer_t shutdown_timer;
@ -301,8 +300,7 @@ int how;
/*===========================================================================* /*===========================================================================*
* shutdown * * shutdown *
*===========================================================================*/ *===========================================================================*/
PUBLIC void minix_shutdown(tp) PUBLIC void minix_shutdown(timer_t *tp)
timer_t *tp;
{ {
/* This function is called from prepare_shutdown or stop_sequence to bring /* This function is called from prepare_shutdown or stop_sequence to bring
* down MINIX. How to shutdown is in the argument: RBT_HALT (return to the * down MINIX. How to shutdown is in the argument: RBT_HALT (return to the

View file

@ -279,7 +279,7 @@ long bit_map; /* notification event set or flags */
* The trap is caught and sys_call() is called to send or receive a message * The trap is caught and sys_call() is called to send or receive a message
* (or both). The caller is always given by 'proc_ptr'. * (or both). The caller is always given by 'proc_ptr'.
*/ */
register struct proc *caller_ptr = proc_ptr; /* get pointer to caller */ struct proc *const caller_ptr = proc_ptr; /* get pointer to caller */
int result; /* the system call's result */ int result; /* the system call's result */
int src_dst_p; /* Process slot number */ int src_dst_p; /* Process slot number */
size_t msg_size; size_t msg_size;
@ -537,7 +537,7 @@ PRIVATE int mini_send(caller_ptr, dst_e, m_ptr, flags)
register struct proc *caller_ptr; /* who is trying to send a message? */ register struct proc *caller_ptr; /* who is trying to send a message? */
int dst_e; /* to whom is message being sent? */ int dst_e; /* to whom is message being sent? */
message *m_ptr; /* pointer to message buffer */ message *m_ptr; /* pointer to message buffer */
int flags; const int flags;
{ {
/* Send a message from 'caller_ptr' to 'dst'. If 'dst' is blocked waiting /* Send a message from 'caller_ptr' to 'dst'. If 'dst' is blocked waiting
* for this message, copy the message to it and unblock 'dst'. If 'dst' is * for this message, copy the message to it and unblock 'dst'. If 'dst' is
@ -609,7 +609,7 @@ PRIVATE int mini_receive(caller_ptr, src_e, m_ptr, flags)
register struct proc *caller_ptr; /* process trying to get message */ register struct proc *caller_ptr; /* process trying to get message */
int src_e; /* which message source is wanted */ int src_e; /* which message source is wanted */
message *m_ptr; /* pointer to message buffer */ message *m_ptr; /* pointer to message buffer */
int flags; const int flags;
{ {
/* A process or task wants to get a message. If a message is already queued, /* A process or task wants to get a message. If a message is already queued,
* acquire it and deblock the sender. If no message from the desired source * acquire it and deblock the sender. If no message from the desired source
@ -742,9 +742,10 @@ int flags;
/*===========================================================================* /*===========================================================================*
* mini_notify * * mini_notify *
*===========================================================================*/ *===========================================================================*/
PUBLIC int mini_notify(caller_ptr, dst_e) PUBLIC int mini_notify(
register struct proc *caller_ptr; /* sender of the notification */ const struct proc *caller_ptr, /* sender of the notification */
endpoint_t dst_e; /* which process to notify */ endpoint_t dst_e /* which process to notify */
)
{ {
register struct proc *dst_ptr; register struct proc *dst_ptr;
int src_id; /* source id for late delivery */ int src_id; /* source id for late delivery */
@ -821,7 +822,7 @@ PRIVATE int mini_senda(struct proc *caller_ptr, asynmsg_t *table, size_t size)
struct proc *dst_ptr; struct proc *dst_ptr;
struct priv *privp; struct priv *privp;
asynmsg_t tabent; asynmsg_t tabent;
vir_bytes table_v = (vir_bytes) table; const vir_bytes table_v = (vir_bytes) table;
vir_bytes linaddr; vir_bytes linaddr;
privp= priv(caller_ptr); privp= priv(caller_ptr);
@ -1133,8 +1134,9 @@ PRIVATE int try_one(struct proc *src_ptr, struct proc *dst_ptr, int *postponed)
/*===========================================================================* /*===========================================================================*
* enqueue * * enqueue *
*===========================================================================*/ *===========================================================================*/
PUBLIC void enqueue(rp) PUBLIC void enqueue(
register struct proc *rp; /* this process is now runnable */ register struct proc *rp /* this process is now runnable */
)
{ {
/* Add 'rp' to one of the queues of runnable processes. This function is /* Add 'rp' to one of the queues of runnable processes. This function is
* responsible for inserting a process into one of the scheduling queues. * responsible for inserting a process into one of the scheduling queues.
@ -1196,7 +1198,7 @@ register struct proc *rp; /* this process is now runnable */
*/ */
PRIVATE void enqueue_head(struct proc *rp) PRIVATE void enqueue_head(struct proc *rp)
{ {
int q = rp->p_priority; /* scheduling queue to use */ const int q = rp->p_priority; /* scheduling queue to use */
assert(proc_ptr_ok(rp)); assert(proc_ptr_ok(rp));
assert(proc_is_runnable(rp)); assert(proc_is_runnable(rp));
@ -1229,8 +1231,8 @@ PRIVATE void enqueue_head(struct proc *rp)
/*===========================================================================* /*===========================================================================*
* dequeue * * dequeue *
*===========================================================================*/ *===========================================================================*/
PUBLIC void dequeue(rp) PUBLIC void dequeue(const struct proc *rp)
register struct proc *rp; /* this process is no longer runnable */ /* this process is no longer runnable */
{ {
/* A process must be removed from the scheduling queues, for example, because /* A process must be removed from the scheduling queues, for example, because
* it has blocked. If the currently active process is removed, a new process * it has blocked. If the currently active process is removed, a new process
@ -1284,7 +1286,7 @@ int *front; /* return: front or back */
* process must be added to one of the scheduling queues to decide where to * process must be added to one of the scheduling queues to decide where to
* insert it. As a side-effect the process' priority may be updated. * insert it. As a side-effect the process' priority may be updated.
*/ */
int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed */ const int time_left = (rp->p_ticks_left > 0); /* quantum fully consumed? */
/* Check whether the process has time left. Otherwise give a new quantum /* Check whether the process has time left. Otherwise give a new quantum
* and lower the process' priority, unless the process already is in the * and lower the process' priority, unless the process already is in the
@ -1340,8 +1342,9 @@ PRIVATE struct proc * pick_proc(void)
* balance_queues * * balance_queues *
*===========================================================================*/ *===========================================================================*/
#define Q_BALANCE_TICKS 100 #define Q_BALANCE_TICKS 100
PUBLIC void balance_queues(tp) PUBLIC void balance_queues(
timer_t *tp; /* watchdog timer pointer */ timer_t *tp /* watchdog timer pointer */
)
{ {
/* Check entire process table and give all process a higher priority. This /* Check entire process table and give all process a higher priority. This
* effectively means giving a new quantum. If a process already is at its * effectively means giving a new quantum. If a process already is at its
@ -1398,13 +1401,14 @@ PUBLIC struct proc *endpoint_lookup(endpoint_t e)
*===========================================================================*/ *===========================================================================*/
#if DEBUG_ENABLE_IPC_WARNINGS #if DEBUG_ENABLE_IPC_WARNINGS
PUBLIC int isokendpt_f(file, line, e, p, fatalflag) PUBLIC int isokendpt_f(file, line, e, p, fatalflag)
char *file; const char *file;
int line; int line;
#else #else
PUBLIC int isokendpt_f(e, p, fatalflag) PUBLIC int isokendpt_f(e, p, fatalflag)
#endif #endif
endpoint_t e; endpoint_t e;
int *p, fatalflag; int *p;
const int fatalflag;
{ {
int ok = 0; int ok = 0;
/* Convert an endpoint number into a process number. /* Convert an endpoint number into a process number.

View file

@ -176,7 +176,7 @@ struct proc {
/* Set flag and dequeue if the process was runnable. */ /* Set flag and dequeue if the process was runnable. */
#define RTS_SET(rp, f) \ #define RTS_SET(rp, f) \
do { \ do { \
int rts = (rp)->p_rts_flags; \ const int rts = (rp)->p_rts_flags; \
(rp)->p_rts_flags |= (f); \ (rp)->p_rts_flags |= (f); \
if(rts_f_is_runnable(rts) && !proc_is_runnable(rp)) { \ if(rts_f_is_runnable(rts) && !proc_is_runnable(rp)) { \
dequeue(rp); \ dequeue(rp); \

View file

@ -69,8 +69,7 @@ PUBLIC void stop_profile_clock()
/*===========================================================================* /*===========================================================================*
* profile_clock_handler * * profile_clock_handler *
*===========================================================================*/ *===========================================================================*/
PRIVATE int profile_clock_handler(hook) PRIVATE int profile_clock_handler(irq_hook_t *hook)
irq_hook_t *hook;
{ {
/* This executes on every tick of the CMOS timer. */ /* This executes on every tick of the CMOS timer. */

View file

@ -38,15 +38,15 @@ _PROTOTYPE( void minix_shutdown, (struct timer *tp) );
/* proc.c */ /* proc.c */
_PROTOTYPE( int do_ipc, (int call_nr, int src_dst, _PROTOTYPE( int do_ipc, (int call_nr, int src_dst,
message *m_ptr, long bit_map) ); message *m_ptr, long bit_map) );
_PROTOTYPE( int mini_notify, (struct proc *src, endpoint_t dst) ); _PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) );
_PROTOTYPE( void enqueue, (struct proc *rp) ); _PROTOTYPE( void enqueue, (struct proc *rp) );
_PROTOTYPE( void dequeue, (struct proc *rp) ); _PROTOTYPE( void dequeue, (const struct proc *rp) );
_PROTOTYPE( void balance_queues, (struct timer *tp) ); _PROTOTYPE( void balance_queues, (struct timer *tp) );
_PROTOTYPE( struct proc * schedcheck, (void) ); _PROTOTYPE( struct proc * schedcheck, (void) );
_PROTOTYPE( struct proc * arch_finish_schedcheck, (void) ); _PROTOTYPE( struct proc * arch_finish_schedcheck, (void) );
_PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) ); _PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) );
#if DEBUG_ENABLE_IPC_WARNINGS #if DEBUG_ENABLE_IPC_WARNINGS
_PROTOTYPE( int isokendpt_f, (char *file, int line, endpoint_t e, int *p, int f)); _PROTOTYPE( int isokendpt_f, (const char *file, int line, endpoint_t e, int *p, int f));
#define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f)) #define isokendpt_d(e, p, f) isokendpt_f(__FILE__, __LINE__, (e), (p), (f))
#else #else
_PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) ); _PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) );
@ -59,8 +59,8 @@ _PROTOTYPE( void cstart, (U16_t cs, U16_t ds, U16_t mds,
/* system.c */ /* system.c */
_PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) ); _PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) );
_PROTOTYPE( void set_sendto_bit, (struct proc *rc, int id) ); _PROTOTYPE( void set_sendto_bit, (const struct proc *rc, int id) );
_PROTOTYPE( void unset_sendto_bit, (struct proc *rc, int id) ); _PROTOTYPE( void unset_sendto_bit, (const struct proc *rc, int id) );
_PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) ); _PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) );
_PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) ); _PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) );
_PROTOTYPE( void sig_delay_done, (struct proc *rp) ); _PROTOTYPE( void sig_delay_done, (struct proc *rp) );
@ -83,9 +83,9 @@ _PROTOTYPE( void vtimer_check, (struct proc *rp) );
/* interrupt.c */ /* interrupt.c */
_PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq, _PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq,
irq_handler_t handler) ); irq_handler_t handler) );
_PROTOTYPE( void rm_irq_handler, (irq_hook_t *hook) ); _PROTOTYPE( void rm_irq_handler, (const irq_hook_t *hook) );
_PROTOTYPE( void enable_irq, (irq_hook_t *hook) ); _PROTOTYPE( void enable_irq, (const irq_hook_t *hook) );
_PROTOTYPE( int disable_irq, (irq_hook_t *hook) ); _PROTOTYPE( int disable_irq, (const irq_hook_t *hook) );
/* debug.c */ /* debug.c */
_PROTOTYPE( int runqueues_ok, (void) ); _PROTOTYPE( int runqueues_ok, (void) );
@ -136,7 +136,7 @@ _PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
vir_bytes vir_addr, vir_bytes bytes)); vir_bytes vir_addr, vir_bytes bytes));
_PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks, _PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,
vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset)); vir_bytes src_offset, phys_clicks dst_clicks, vir_bytes dst_offset));
_PROTOTYPE( phys_bytes umap_remote, (struct proc* rp, int seg, _PROTOTYPE( phys_bytes umap_remote, (const struct proc* rp, int seg,
vir_bytes vir_addr, vir_bytes bytes) ); vir_bytes vir_addr, vir_bytes bytes) );
_PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp, _PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
int seg, vir_bytes vir_addr, vir_bytes bytes) ); int seg, vir_bytes vir_addr, vir_bytes bytes) );
@ -167,13 +167,13 @@ _PROTOTYPE( int arch_umap, (struct proc *pr, vir_bytes, vir_bytes,
_PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p)); _PROTOTYPE( int arch_do_vmctl, (message *m_ptr, struct proc *p));
_PROTOTYPE( int vm_contiguous, (struct proc *targetproc, u32_t vir_buf, size_t count)); _PROTOTYPE( int vm_contiguous, (struct proc *targetproc, u32_t vir_buf, size_t count));
_PROTOTYPE( void proc_stacktrace, (struct proc *proc) ); _PROTOTYPE( void proc_stacktrace, (struct proc *proc) );
_PROTOTYPE( int vm_lookup, (struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent)); _PROTOTYPE( int vm_lookup, (const struct proc *proc, vir_bytes virtual, vir_bytes *result, u32_t *ptent));
_PROTOTYPE( int delivermsg, (struct proc *target)); _PROTOTYPE( int delivermsg, (struct proc *target));
_PROTOTYPE( void arch_do_syscall, (struct proc *proc) ); _PROTOTYPE( void arch_do_syscall, (struct proc *proc) );
_PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr, _PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr,
phys_bytes *len, int *flags)); phys_bytes *len, int *flags));
_PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr)); _PROTOTYPE( int arch_phys_map_reply, (int index, vir_bytes addr));
_PROTOTYPE( int arch_enable_paging, (struct proc * caller, message * m_ptr)); _PROTOTYPE( int arch_enable_paging, (struct proc * caller, const message * m_ptr));
_PROTOTYPE( int copy_msg_from_user, (struct proc * p, message * user_mbuf, _PROTOTYPE( int copy_msg_from_user, (struct proc * p, message * user_mbuf,
message * dst)); message * dst));

View file

@ -11,7 +11,7 @@
#include "watchdog.h" #include "watchdog.h"
#endif #endif
FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key)); FORWARD _PROTOTYPE( char *get_value, (const char *params, const char *key));
/*===========================================================================* /*===========================================================================*
* cstart * * cstart *
*===========================================================================*/ *===========================================================================*/
@ -112,13 +112,13 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
*===========================================================================*/ *===========================================================================*/
PRIVATE char *get_value(params, name) PRIVATE char *get_value(params, name)
_CONST char *params; /* boot monitor parameters */ const char *params; /* boot monitor parameters */
_CONST char *name; /* key to look up */ const char *name; /* key to look up */
{ {
/* Get environment value - kernel version of getenv to avoid setting up the /* Get environment value - kernel version of getenv to avoid setting up the
* usual environment array. * usual environment array.
*/ */
register _CONST char *namep; register const char *namep;
register char *envp; register char *envp;
for (envp = (char *) params; *envp != 0;) { for (envp = (char *) params; *envp != 0;) {

View file

@ -281,7 +281,7 @@ int priv_id; /* privilege id */
/*===========================================================================* /*===========================================================================*
* set_sendto_bit * * set_sendto_bit *
*===========================================================================*/ *===========================================================================*/
PUBLIC void set_sendto_bit(struct proc *rp, int id) PUBLIC void set_sendto_bit(const struct proc *rp, int id)
{ {
/* Allow a process to send messages to the process(es) associated with the /* Allow a process to send messages to the process(es) associated with the
* system privilege structure with the given ID. * system privilege structure with the given ID.
@ -309,7 +309,7 @@ PUBLIC void set_sendto_bit(struct proc *rp, int id)
/*===========================================================================* /*===========================================================================*
* unset_sendto_bit * * unset_sendto_bit *
*===========================================================================*/ *===========================================================================*/
PUBLIC void unset_sendto_bit(struct proc *rp, int id) PUBLIC void unset_sendto_bit(const struct proc *rp, int id)
{ {
/* Prevent a process from sending to another process. Retain the send mask /* Prevent a process from sending to another process. Retain the send mask
* symmetry by also unsetting the bit for the other direction. * symmetry by also unsetting the bit for the other direction.

View file

@ -26,7 +26,7 @@ extern struct arch_watchdog *watchdog;
/* let the arch code do whatever it needs to setup the watchdog */ /* let the arch code do whatever it needs to setup the watchdog */
int arch_watchdog_init(void); int arch_watchdog_init(void);
/* if the watchdog detects lockup, let the arch code to handle it */ /* if the watchdog detects lockup, let the arch code to handle it */
void arch_watchdog_lockup(struct nmi_frame * frame); void arch_watchdog_lockup(const struct nmi_frame * frame);
/* generic NMI handler. Takes one agument which points to where the arch /* generic NMI handler. Takes one agument which points to where the arch
* specific low level handler dumped CPU information and can be inspected by the * specific low level handler dumped CPU information and can be inspected by the

View file

@ -188,7 +188,7 @@ parseRule(register char *buf, register const char *p)
} }
static int static int
last_sunday(register int day, register struct tm *timep) last_sunday(register int day, const register struct tm *timep)
{ {
int first = FIRSTSUNDAY(timep); int first = FIRSTSUNDAY(timep);
@ -198,7 +198,7 @@ last_sunday(register int day, register struct tm *timep)
} }
static int static int
date_of(register struct dsttype *dst, struct tm *timep) date_of(const register struct dsttype *dst, const struct tm *timep)
{ {
int leap = LEAPYEAR(YEAR0 + timep->tm_year); int leap = LEAPYEAR(YEAR0 + timep->tm_year);
int firstday, tmpday; int firstday, tmpday;