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. */
{
char *c;
return c;
}
-static int is_default(environment *e)
+static int is_default(const environment *e)
{
return (e->flags & E_SPECIAL) && e->defval == nil;
}
-static environment **searchenv(char *name)
+static environment **searchenv(const char *name)
{
environment **aenv= &env;
return (Thandler != nil && milli_since(Tbase) >= Tcount);
}
-void delay(char *msec)
+void delay(const char *msec)
/* Delay for a given time. */
{
u32_t 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->arg[1] != ',') return SELECT;
#endif
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 $
#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
* 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'.
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. */
{
char *colon, *label;
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. */
{
u32_t len= hdr->process.a_text;
#define BOOT_BLOCK_SIZE 1024
-void report(char *label)
+static void report(const char *label)
/* installboot: label: No such file or directory */
{
fprintf(stderr, "installboot: %s: %s\n", label, strerror(errno));
}
-void fatal(char *label)
+static void fatal(const char *label)
{
report(label);
exit(1);
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. */
{
if (len > 0 && fread(buf, len, 1, f) != 1) {
}
}
-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);
}
}
}
-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. */
{
if (lseek(rawfd, blk * block_size, SEEK_SET) < 0
}
}
-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
* 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
if (guide[0] != nil) {
/* Fixate partition to boot. */
- char *keys= guide[0];
- char *logical= guide[1];
+ const char *keys= guide[0];
+ const char *logical= guide[1];
size_t i;
int logfd;
u32_t offset;
writeblock(BOOTBLOCK, buf, BOOT_BLOCK_SIZE);
}
-void usage(void)
+static void usage(void)
{
fprintf(stderr,
"Usage: installboot -i(mage) image kernel mm fs ... init\n"
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
* for -image, and the special case -x for -extract.
*/
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
* function, it only needs r_stat and r_readdir.
*/
* Return next directory entry or 0 if there are no more.
* 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
* inode number. It starts from directory "cwd" unless
* path starts with a '/', then from ROOT_INO.
extern void r_stat(Ino_t file, struct stat *stp);
extern off_t r_vir2abs(off_t virblockno);
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 $
STATIC void setalias(char *, char *);
STATIC int unalias(char *);
-STATIC struct alias **hashalias(char *);
+STATIC struct alias **hashalias(const char *);
STATIC
void
}
STATIC struct alias **
-hashalias(char *p)
+hashalias(const char *p)
{
unsigned int hashval;
#include "cd.h"
STATIC int cdlogical(char *);
-STATIC int cdphysical(char *);
+STATIC int cdphysical(const char *);
STATIC int docd(char *, int, int);
STATIC char *getcomponent(void);
-STATIC int updatepwd(char *);
+STATIC int updatepwd(const char *);
STATIC char *curdir = NULL; /* current working directory */
STATIC char *prevdir; /* previous working directory */
}
STATIC int
-cdphysical(char *dest)
+cdphysical(const char *dest)
{
INTOFF;
* that the current directory has changed.
*/
STATIC int
-updatepwd(char *dir)
+updatepwd(const char *dir)
{
char *new;
char *p;
}
}
-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 */
{
int b, lp;
extern char *cclenter(const char *);
extern void overflo(const char *);
extern void cfoll(fa *, Node *);
-extern int first(Node *);
+extern int first(const Node *);
extern void follow(Node *);
extern int member(int, const char *);
extern int match(fa *, const char *);
extern void arginit(int, char **);
extern void envinit(char **);
extern Array *makesymtab(int);
-extern void freesymtab(Cell *);
-extern void freeelem(Cell *, const char *);
+extern void freesymtab(const Cell *);
+extern void freeelem(const Cell *, const char *);
extern Cell *setsymtab(const char *, const char *, double, unsigned int, Array *);
extern int hash(const char *, int);
extern void rehash(Array *);
-extern Cell *lookup(const char *, Array *);
+extern Cell *lookup(const char *, const Array *);
extern double setfval(Cell *, double);
extern void funnyvar(Cell *, const char *);
extern char *setsval(Cell *, const char *);
return(ap);
}
-void freesymtab(Cell *ap) /* free a symbol table */
+void freesymtab(const Cell *ap) /* free a symbol table */
{
Cell *cp, *temp;
Array *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;
Cell *p, *prev = NULL;
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;
int h;
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 */
double dtemp;
static enum { ADD, DEL } action;
static void usage(void);
-static int name_to_ip(char *name, ipaddr_t *addr);
-static int parse_cidr(char *cidr, ipaddr_t *addr, ipaddr_t *mask);
+static int name_to_ip(const char *name, ipaddr_t *addr);
+static int parse_cidr(const char *cidr, ipaddr_t *addr, ipaddr_t *mask);
int main(int argc, char *argv[])
{
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
* with gethostbyname(). (The latter can also recognize an IP address,
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;
ipaddr_t a;
static void do_set(char *hostname, char *ethername, int temp, int pub,
int optdelete);
static ipaddr_t nametoipaddr(char *hostname);
-static void fatal(char *fmt, ...);
+static void fatal(const char *fmt, ...);
static void usage(void);
int main(int argc, char *argv[])
}
#endif
-static void fatal(char *fmt, ...)
+static void fatal(const char *fmt, ...)
{
va_list ap;
static char *op = obuf;
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 fatal(const char *label);
}
}
-static void output(char *buf, size_t count)
+static void output(const char *buf, size_t count)
{
ssize_t n;
struct stat st;
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(void usage, (void));
/* 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;
char action;
/* Main module. The single option possible (-R) does not warrant a call to
* the getopt() stuff.
*/
-int main(argc, argv)
-int argc;
-char *argv[];
+int main(int argc, char *argv[])
{
int ex_code = 0;
char *path; /* Path name constructed in 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)
* The index where the current path ends is stored in *pdi.
*/
struct file *ignore_list[1024];
size_t n_ignored= 0;
-unsigned ihash(char *name)
+unsigned ihash(const char *name)
/* A simple hashing function on a file name. */
{
unsigned h= 0;
#define PATH_MAX 1024
#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
* earlier by this function under a different name. If not return a
}
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. */
{
char *olddst;
}
}
-void remove1(const char *src, struct stat *srcst)
+void remove1(const char *src, const struct stat *srcst)
{
if (iflag || (!fflag && !writable(srcst))) {
fprintf(stderr, "Remove %s? (mode = %03o) ", src,
}
}
-void link1(const char *src, const char *dst, struct stat *srcst,
- struct stat *dstst)
+void link1(const char *src, const char *dst, const struct stat *srcst,
+ const struct stat *dstst)
{
pathname_t sym;
const char *p;
} *mtab= NULL;
struct mtab *searchtab(char *name);
-void readmtab(char *type);
+static void readmtab(const char *type);
int df(const struct mtab *mt);
bit_t bit_count(unsigned blocks, bit_t bits, int fd, int bs);
exit(ex);
}
-void readmtab(char *type)
+static void readmtab(const char *type)
/* Turn the mounted file table into a list. */
{
struct mtab **amt= &mtab, *new;
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;
static int fs_block_size = -1, fs_dev = -1;
char *prog = 0, *processing = 0;
-_PROTOTYPE(int main, (int argc, char **argv));
_PROTOTYPE(char *getline, (FILE *fp, char *b));
_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(void fatal, (char *s, ...));
+_PROTOTYPE(void fatal, (const char *s, ...));
_PROTOTYPE(int strwcmp, (char *s1, char *s2));
_PROTOTYPE(int whitespace, (int ch));
char *
- getline(fp, b)
-FILE *fp;
-char *b;
+getline(FILE *fp, char *b)
{
if (fgets(b, LINELEN, fp) == NULL) fatal("unexpected eof");
#define copy(str) printf("%s", str)
-int main(argc, argv)
-int argc;
-char **argv;
+int main(int argc, char **argv)
{
char cmd, *fl, *fd, obuf[LINELEN], nbuf[LINELEN];
int o1, o2, n1, n2, here;
}
#ifdef __STDC__
-void fatal(char *s, ...)
+void fatal(const char *s, ...)
{
va_list args;
#else
/* the K&R lib does not have vfprintf */
void fatal(s, a)
-char *s, *a;
+const char *s, *a;
{
fprintf(stderr, "%s: processing: %s fatal: ", prog, processing);
fprintf(stderr, s, a);
/* Crude indication of a tty being physically secure: */
#define securetty(dev) ((unsigned) ((dev) - 0x0400) < (unsigned) 8)
-void std_out(char *s)
+void std_out(const char *s)
{
write(1, s, strlen(s));
}
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 */
u32_t lvtt;
u32_t ticks_per_us;
- u8_t cpu = cpuid;
+ const u8_t cpu = cpuid;
ticks_per_us = lapic_bus_freq[cpu] / 1000000;
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 */
u32_t lvtt;
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;
#endif
/* 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.
*/
#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;
/*===========================================================================*
* 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,
* and register the CLOCK task's interrupt handler to be run
}
}
-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
if (lapic_addr) {
/*===========================================================================*
* 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
* only done in protected mode, in real mode we don't touch the 8259s, but
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)));
}
-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)));
}
* for actual use by phys_copy or phys_memset.
*/
PRIVATE phys_bytes createpde(
- struct proc *pr, /* Requested process, NULL for physical. */
- phys_bytes linaddr, /* Address after segment translation. */
+ const struct proc *pr, /* Requested process, NULL for physical. */
+ const phys_bytes linaddr,/* Address after segment translation. */
phys_bytes *bytes, /* Size of chunk, function may truncate it. */
int pde, /* freepde number to use for the mapping. */
int *changed /* If mapping is made, this is set to 1. */
PRIVATE u32_t phys_get32(phys_bytes addr)
{
- u32_t v;
+ const u32_t v;
int r;
if(!vm_running) {
}
PUBLIC vir_bytes alloc_remote_segment(u32_t *selector,
- segframe_t *segments, int index, phys_bytes phys, vir_bytes size,
- int priv)
+ segframe_t *segments, const int index, phys_bytes phys,
+ vir_bytes size, int priv)
{
phys_bytes offset = 0;
/* Check if the segment size can be recorded in bytes, that is, check
return offset;
}
-PUBLIC phys_bytes umap_remote(struct proc* rp, int seg,
- vir_bytes vir_addr, vir_bytes bytes)
+PUBLIC phys_bytes umap_remote(const struct proc* rp, const int seg,
+ const vir_bytes vir_addr, const vir_bytes bytes)
{
/* Calculate the physical memory address for a given virtual address. */
struct far_mem *fm;
/*===========================================================================*
* 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;
int pde, pte;
/*===========================================================================*
* vm_suspend *
*===========================================================================*/
-PRIVATE void vm_suspend(struct proc *caller, struct proc *target,
- vir_bytes linaddr, vir_bytes len, int type)
+PRIVATE void vm_suspend(struct proc *caller, const struct proc *target,
+ const vir_bytes linaddr, const vir_bytes len, const int type)
{
/* This range is not OK for this process. Set parameters
* of the request and notify VM about the pending request.
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];
strcpy(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 col = 0;
/*===========================================================================*
* 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;
NOREC_ENTER(physmemset);
/*===========================================================================*
* data_copy *
*===========================================================================*/
-PUBLIC int data_copy(endpoint_t from_proc, vir_bytes from_addr,
- endpoint_t to_proc, vir_bytes to_addr,
+PUBLIC int data_copy(const endpoint_t from_proc, const vir_bytes from_addr,
+ const endpoint_t to_proc, const vir_bytes to_addr,
size_t bytes)
{
struct vir_addr src, dst;
* data_copy_vmcheck *
*===========================================================================*/
PUBLIC int data_copy_vmcheck(struct proc * caller,
- endpoint_t from_proc, vir_bytes from_addr,
- endpoint_t to_proc, vir_bytes to_addr,
+ const endpoint_t from_proc, const vir_bytes from_addr,
+ const endpoint_t to_proc, const vir_bytes to_addr,
size_t bytes)
{
struct vir_addr src, dst;
/*===========================================================================*
* 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. */
memset(pr->p_seg.p_ldt + EXTRA_LDT_INDEX, 0,
}
/* 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)
return;
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
/* map the local APIC if enabled */
#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
/* if local APIC is enabled */
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;
int r;
/*===========================================================================*
* 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
* register, or a 286/386 segment selector.
* init_dataseg *
*===========================================================================*/
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. */
sdesc(segdp, base, size);
* int_gate *
*===========================================================================*/
PUBLIC void int_gate(vec_nr, offset, dpl_type)
-unsigned vec_nr;
-vir_bytes offset;
-unsigned dpl_type;
+const unsigned vec_nr;
+const vir_bytes offset;
+const unsigned dpl_type;
{
/* Build descriptor for an interrupt gate. */
register struct gatedesc_s *idp;
/*===========================================================================*
* 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;
struct segdesc_s *desc;
/*===========================================================================*
* 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;
int orig_click;
PUBLIC int cpu_has_tsc;
-PUBLIC void arch_shutdown(int how)
+PUBLIC void arch_shutdown(const int how)
{
/* Mask all interrupts, including the clock. */
outb( INT_CTLMASK, ~0);
if(minix_panicing) {
int source, dest;
static char mybuffer[sizeof(params_buffer)];
- char *lead = "echo \\n*** kernel messages:\\n";
- int leadlen = strlen(lead);
+ const char *lead = "echo \\n*** kernel messages:\\n";
+ const int leadlen = strlen(lead);
strcpy(mybuffer, lead);
#define DECSOURCE source = (source - 1 + _KMESS_BUF_SIZE) % _KMESS_BUF_SIZE
DECSOURCE;
while(dest >= leadlen) {
- char c = kmess.km_buf[source];
+ const char c = kmess.km_buf[source];
if(c == '\n') {
mybuffer[dest--] = 'n';
mybuffer[dest] = '\\';
/* address of a.out headers, set in mpx386.s */
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
* absolute address 'aout'. Get one element to h.
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
}
}
-PRIVATE void ser_debug(int c)
+PRIVATE void ser_debug(const int c)
{
serial_debug_active = 1;
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;
endpoint_t dep;
#if SPROFILE
-PUBLIC int arch_init_profile_clock(u32_t freq)
+PUBLIC int arch_init_profile_clock(const u32_t freq)
{
int r;
/* Set CMOS timer frequency. */
#define COLOR_BASE 0xB8000L
-PRIVATE void cons_setc(int pos, int c)
+PRIVATE void cons_setc(const int pos, const int c)
{
char ch;
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);
ia32_msr_write(MSR_PERFMON_CRT0, 0, -watchdog->resetval);
return 0;
}
-void arch_watchdog_lockup(struct nmi_frame * frame)
+void arch_watchdog_lockup(const struct nmi_frame * frame)
{
printf("KERNEL LOCK UP\n"
"eax 0x%08x\n"
* user's system time.
*/
- unsigned ticks = 1;
+ const unsigned ticks = 1;
struct proc * p, * billp;
#ifdef CONFIG_WATCHDOG
return 0;
}
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) {
printf("xp out of range\n");
return 0;
}
PUBLIC char *
-rtsflagstr(int flags)
+rtsflagstr(const int flags)
{
static char str[100];
str[0] = '\0';
}
PUBLIC char *
-miscflagstr(int flags)
+miscflagstr(const int flags)
{
static char str[100];
str[0] = '\0';
* put_irq_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;
irq_hook_t **line;
* rm_irq_handler *
*===========================================================================*/
/* Unregister an interrupt handler. */
-PUBLIC void rm_irq_handler( irq_hook_t* hook ) {
- int irq = hook->irq;
- int id = hook->id;
+PUBLIC void rm_irq_handler( const irq_hook_t* hook ) {
+ const int irq = hook->irq;
+ const int id = hook->id;
irq_hook_t **line;
if( irq < 0 || irq >= NR_IRQ_VECTORS )
}
/* Enable/Disable a interrupt line. */
-PUBLIC void enable_irq(hook)
-irq_hook_t* hook;
+PUBLIC void enable_irq(const irq_hook_t *hook)
{
if((irq_actids[hook->irq] &= ~hook->id) == 0) {
hw_intr_unmask(hook->irq);
}
/* Return true if the interrupt was enabled before call. */
-PUBLIC int disable_irq(hook)
-irq_hook_t* hook;
+PUBLIC int disable_irq(const irq_hook_t *hook)
{
if(irq_actids[hook->irq] & hook->id) /* already disabled */
return 0;
/*===========================================================================*
* prepare_shutdown *
*===========================================================================*/
-PUBLIC void prepare_shutdown(how)
-int how;
+PUBLIC void prepare_shutdown(const int how)
{
/* This function prepares to shutdown MINIX. */
static timer_t shutdown_timer;
/*===========================================================================*
* shutdown *
*===========================================================================*/
-PUBLIC void minix_shutdown(tp)
-timer_t *tp;
+PUBLIC void minix_shutdown(timer_t *tp)
{
/* 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
* 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'.
*/
- 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 src_dst_p; /* Process slot number */
size_t msg_size;
register struct proc *caller_ptr; /* who is trying to send a message? */
int dst_e; /* to whom is message being sent? */
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
* for this message, copy the message to it and unblock 'dst'. If 'dst' is
register struct proc *caller_ptr; /* process trying to get message */
int src_e; /* which message source is wanted */
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,
* acquire it and deblock the sender. If no message from the desired source
/*===========================================================================*
* mini_notify *
*===========================================================================*/
-PUBLIC int mini_notify(caller_ptr, dst_e)
-register struct proc *caller_ptr; /* sender of the notification */
-endpoint_t dst_e; /* which process to notify */
+PUBLIC int mini_notify(
+ const struct proc *caller_ptr, /* sender of the notification */
+ endpoint_t dst_e /* which process to notify */
+)
{
register struct proc *dst_ptr;
int src_id; /* source id for late delivery */
struct proc *dst_ptr;
struct priv *privp;
asynmsg_t tabent;
- vir_bytes table_v = (vir_bytes) table;
+ const vir_bytes table_v = (vir_bytes) table;
vir_bytes linaddr;
privp= priv(caller_ptr);
/*===========================================================================*
* enqueue *
*===========================================================================*/
-PUBLIC void enqueue(rp)
-register struct proc *rp; /* this process is now runnable */
+PUBLIC void enqueue(
+ register struct proc *rp /* this process is now runnable */
+)
{
/* Add 'rp' to one of the queues of runnable processes. This function is
* responsible for inserting a process into one of the scheduling queues.
*/
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_is_runnable(rp));
/*===========================================================================*
* dequeue *
*===========================================================================*/
-PUBLIC void dequeue(rp)
-register struct proc *rp; /* this process is no longer runnable */
+PUBLIC void dequeue(const struct proc *rp)
+/* this process is no longer runnable */
{
/* 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
* 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.
*/
- 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
* and lower the process' priority, unless the process already is in the
* balance_queues *
*===========================================================================*/
#define Q_BALANCE_TICKS 100
-PUBLIC void balance_queues(tp)
-timer_t *tp; /* watchdog timer pointer */
+PUBLIC void balance_queues(
+ timer_t *tp /* watchdog timer pointer */
+)
{
/* 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
*===========================================================================*/
#if DEBUG_ENABLE_IPC_WARNINGS
PUBLIC int isokendpt_f(file, line, e, p, fatalflag)
-char *file;
+const char *file;
int line;
#else
PUBLIC int isokendpt_f(e, p, fatalflag)
#endif
endpoint_t e;
-int *p, fatalflag;
+int *p;
+const int fatalflag;
{
int ok = 0;
/* Convert an endpoint number into a process number.
/* Set flag and dequeue if the process was runnable. */
#define RTS_SET(rp, f) \
do { \
- int rts = (rp)->p_rts_flags; \
+ const int rts = (rp)->p_rts_flags; \
(rp)->p_rts_flags |= (f); \
if(rts_f_is_runnable(rts) && !proc_is_runnable(rp)) { \
dequeue(rp); \
/*===========================================================================*
* profile_clock_handler *
*===========================================================================*/
-PRIVATE int profile_clock_handler(hook)
-irq_hook_t *hook;
+PRIVATE int profile_clock_handler(irq_hook_t *hook)
{
/* This executes on every tick of the CMOS timer. */
/* proc.c */
_PROTOTYPE( int do_ipc, (int call_nr, int src_dst,
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 dequeue, (struct proc *rp) );
+_PROTOTYPE( void dequeue, (const struct proc *rp) );
_PROTOTYPE( void balance_queues, (struct timer *tp) );
_PROTOTYPE( struct proc * schedcheck, (void) );
_PROTOTYPE( struct proc * arch_finish_schedcheck, (void) );
_PROTOTYPE( struct proc *endpoint_lookup, (endpoint_t ep) );
#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))
#else
_PROTOTYPE( int isokendpt_f, (endpoint_t e, int *p, int f) );
/* system.c */
_PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) );
-_PROTOTYPE( void set_sendto_bit, (struct proc *rc, int id) );
-_PROTOTYPE( void unset_sendto_bit, (struct proc *rc, int id) );
+_PROTOTYPE( void set_sendto_bit, (const 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 cause_sig, (proc_nr_t proc_nr, int sig_nr) );
_PROTOTYPE( void sig_delay_done, (struct proc *rp) );
/* interrupt.c */
_PROTOTYPE( void put_irq_handler, (irq_hook_t *hook, int irq,
irq_handler_t handler) );
-_PROTOTYPE( void rm_irq_handler, (irq_hook_t *hook) );
-_PROTOTYPE( void enable_irq, (irq_hook_t *hook) );
-_PROTOTYPE( int disable_irq, (irq_hook_t *hook) );
+_PROTOTYPE( void rm_irq_handler, (const irq_hook_t *hook) );
+_PROTOTYPE( void enable_irq, (const irq_hook_t *hook) );
+_PROTOTYPE( int disable_irq, (const irq_hook_t *hook) );
/* debug.c */
_PROTOTYPE( int runqueues_ok, (void) );
vir_bytes vir_addr, vir_bytes bytes));
_PROTOTYPE( void cp_mess, (int src,phys_clicks src_clicks,
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) );
_PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
int seg, vir_bytes vir_addr, vir_bytes bytes) );
_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( 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( void arch_do_syscall, (struct proc *proc) );
_PROTOTYPE( int arch_phys_map, (int index, phys_bytes *addr,
phys_bytes *len, int *flags));
_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,
message * dst));
#include "watchdog.h"
#endif
-FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key));
+FORWARD _PROTOTYPE( char *get_value, (const char *params, const char *key));
/*===========================================================================*
* cstart *
*===========================================================================*/
*===========================================================================*/
PRIVATE char *get_value(params, name)
-_CONST char *params; /* boot monitor parameters */
-_CONST char *name; /* key to look up */
+ const char *params; /* boot monitor parameters */
+ const char *name; /* key to look up */
{
/* Get environment value - kernel version of getenv to avoid setting up the
* usual environment array.
*/
- register _CONST char *namep;
+ register const char *namep;
register char *envp;
for (envp = (char *) params; *envp != 0;) {
/*===========================================================================*
* 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
* system privilege structure with the given ID.
/*===========================================================================*
* 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
* symmetry by also unsetting the bit for the other direction.
/* let the arch code do whatever it needs to setup the watchdog */
int arch_watchdog_init(void);
/* 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
* specific low level handler dumped CPU information and can be inspected by the
}
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);
}
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 firstday, tmpday;