提交 8b32de47 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Merge c++ stuff

......@@ -14,16 +14,19 @@ HW ?= qemu
O = o.$(HW)
CC = $(TOOLPREFIX)gcc
CXX = $(TOOLPREFIX)g++
AS = $(TOOLPREFIX)gas
LD = $(TOOLPREFIX)ld
NM = $(TOOLPREFIX)nm
OBJCOPY = $(TOOLPREFIX)objcopy
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb \
-m64 -Werror -std=c99 -fms-extensions -mno-sse -mcmodel=large -mno-red-zone \
-I$(QEMUSRC) \
-fno-omit-frame-pointer -DHW_$(HW) -include param.h -include compiler.h
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
COMFLAGS := -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall \
-MD -ggdb -m64 -Werror -fms-extensions -mno-sse \
-mcmodel=large -mno-red-zone -I$(QEMUSRC) -fno-omit-frame-pointer \
-DHW_$(HW) -include param.h -include compiler.h -DXV6
COMFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
CFLAGS := $(COMFLAGS) -std=c99
CXXFLAGS := $(COMFLAGS) -std=c++0x -Wno-sign-compare
ASFLAGS = -m64 -gdwarf-2 -MD
LDFLAGS += -m elf_x86_64
......@@ -115,6 +118,10 @@ $(O)/%.o: %.c
@echo " CC $@"
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
$(O)/%.o: %.cc
@echo " CXX $@"
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $<
$(O)/incbin.o: ASFLAGS+=-DMAKE_OUT=$(O)
$(O)/incbin.o: $(O)/initcode $(O)/bootother $(O)/fs.img
$(O)/%.o: %.S
......
......@@ -21,11 +21,13 @@
// * B_DIRTY: the buffer data has been modified
// and needs to be written to disk.
extern "C" {
#include "types.h"
#include "kernel.h"
#include "spinlock.h"
#include "condvar.h"
#include "buf.h"
}
static struct ns *bufns;
......@@ -34,7 +36,7 @@ enum { writeback = 0 };
static void *
evict(void *vkey, void *bp, void *arg)
{
struct buf *b = bp;
struct buf *b = (buf*) bp;
acquire(&b->lock);
if ((b->flags & (B_BUSY | B_DIRTY | B_VALID)) == 0)
return b;
......@@ -45,7 +47,7 @@ evict(void *vkey, void *bp, void *arg)
static void *
evict_valid(void *vkey, void *bp, void *arg)
{
struct buf *b = bp;
struct buf *b = (buf*) bp;
acquire(&b->lock);
if ((b->flags & (B_BUSY | B_DIRTY)) == 0)
return b;
......@@ -65,7 +67,7 @@ bget(u32 dev, u64 sector, int *writer)
// Try for cached block.
// XXX ignore dev
gc_begin_epoch();
b = ns_lookup(bufns, KII(dev, sector));
b = (buf*) ns_lookup(bufns, KII(dev, sector));
if (b) {
if (b->dev != dev || b->sector != sector)
panic("block mismatch");
......@@ -89,9 +91,9 @@ bget(u32 dev, u64 sector, int *writer)
gc_end_epoch();
// Allocate fresh block.
struct buf *victim = ns_enumerate(bufns, evict, 0);
struct buf *victim = (buf*) ns_enumerate(bufns, evict, 0);
if (victim == 0)
victim = ns_enumerate(bufns, evict_valid, 0);
victim = (buf*) ns_enumerate(bufns, evict_valid, 0);
if (victim == 0)
panic("bget all busy");
victim->flags |= B_BUSY;
......@@ -100,7 +102,7 @@ bget(u32 dev, u64 sector, int *writer)
destroylock(&victim->lock);
gc_delayed(victim, kmfree);
b = kmalloc(sizeof(*b));
b = (buf*) kmalloc(sizeof(*b));
b->dev = dev;
b->sector = sector;
b->flags = B_BUSY;
......@@ -166,7 +168,7 @@ initbio(void)
bufns = nsalloc(0);
for (u64 i = 0; i < NBUF; i++) {
struct buf *b = kmalloc(sizeof(*b));
struct buf *b = (buf*) kmalloc(sizeof(*b));
b->dev = 0xdeadbeef;
b->sector = -i; /* dummy to pre-allocate NBUF spaces for evict */
b->flags = 0;
......
extern "C" {
#include "types.h"
#include "kernel.h"
#include "amd64.h"
}
#define BACKSPACE 0x100
#define CRTPORT 0x3d4
......@@ -42,7 +44,7 @@ cgaputc(int c)
void
initcga(void)
{
char *p;
const char *p;
int i;
for (i = 0; i < 80*25; i++)
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "mmu.h"
......@@ -7,6 +8,7 @@
#include "proc.h"
#include "kernel.h"
#include "cpu.h"
}
struct spinlock tickslock __mpalign__;
struct condvar cv_ticks __mpalign__;
......
......@@ -2,6 +2,7 @@
// Input is from the keyboard or serial port.
// Output is written to the screen and serial port.
extern "C" {
#include "types.h"
#include "cpu.h"
#include "kernel.h"
......@@ -17,6 +18,7 @@
#include <stdarg.h>
#include "fmt.h"
#include <stddef.h>
}
#define BACKSPACE 0x100
......@@ -69,7 +71,7 @@ struct bufstate {
static void
writebuf(int c, void *arg)
{
struct bufstate *bs = arg;
struct bufstate *bs = (bufstate*) arg;
if (bs->p < bs->e) {
bs->p[0] = c;
bs->p++;
......@@ -77,7 +79,7 @@ writebuf(int c, void *arg)
}
void
vsnprintf(char *buf, u32 n, char *fmt, va_list ap)
vsnprintf(char *buf, u32 n, const char *fmt, va_list ap)
{
struct bufstate bs = { buf, buf+n-1 };
vprintfmt(writebuf, (void*) &bs, fmt, ap);
......@@ -85,7 +87,7 @@ vsnprintf(char *buf, u32 n, char *fmt, va_list ap)
}
void
snprintf(char *buf, u32 n, char *fmt, ...)
snprintf(char *buf, u32 n, const char *fmt, ...)
{
va_list ap;
......@@ -147,7 +149,6 @@ printtrace(u64 rbp)
void __noret__
kerneltrap(struct trapframe *tf)
{
extern void sys_halt();
const char *name = "(no name)";
void *kstack = NULL;
int pid = 0;
......@@ -178,7 +179,6 @@ kerneltrap(struct trapframe *tf)
void
panic(const char *fmt, ...)
{
extern void sys_halt();
va_list ap;
cli();
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
#include "pci.h"
#include "spinlock.h"
#include "e1000reg.h"
}
#define TX_RING_SIZE 64
#define RX_RING_SIZE 64
......@@ -34,7 +36,7 @@ static inline u32
erd(u32 reg)
{
paddr pa = e1000.membase + reg;
volatile u32 *ptr = p2v(pa);
volatile u32 *ptr = (u32*) p2v(pa);
return *ptr;
}
......@@ -42,7 +44,7 @@ static inline void
ewr(u32 reg, u32 val)
{
paddr pa = e1000.membase + reg;
volatile u32 *ptr = p2v(pa);
volatile u32 *ptr = (u32*) p2v(pa);
*ptr = val;
}
......
extern "C" {
#include "types.h"
#include "mmu.h"
#include "spinlock.h"
......@@ -14,6 +15,7 @@
#include "vm.h"
#include "prof.h"
#include <stddef.h>
}
#define USTACKPAGES 2
#define BRK (USERTOP >> 1)
......@@ -31,8 +33,7 @@ struct eargs {
static void
dosegment(uptr a0, u64 a1)
{
static DEFINE_PROFCTR(dosegment_prof);
struct eargs *args = (void*) a0;
struct eargs *args = (eargs*) a0;
u64 off = a1;
struct vmnode *vmn = NULL;
struct proghdr ph;
......@@ -50,26 +51,28 @@ dosegment(uptr a0, u64 a1)
goto bad;
}
uptr va_start = PGROUNDDOWN(ph.vaddr);
uptr va_end = PGROUNDUP(ph.vaddr + ph.memsz);
{
uptr va_start = PGROUNDDOWN(ph.vaddr);
uptr va_end = PGROUNDUP(ph.vaddr + ph.memsz);
int npg = (va_end - va_start) / PGSIZE;
if (odp) {
if ((vmn = vmn_alloc(npg, ONDEMAND)) == 0)
goto bad;
} else {
if ((vmn = vmn_allocpg(npg)) == 0)
int npg = (va_end - va_start) / PGSIZE;
if (odp) {
if ((vmn = vmn_alloc(npg, ONDEMAND)) == 0)
goto bad;
} else {
if ((vmn = vmn_allocpg(npg)) == 0)
goto bad;
}
if(vmn_load(vmn, args->ip, ph.offset, ph.filesz) < 0)
goto bad;
}
if(vmn_load(vmn, args->ip, ph.offset, ph.filesz) < 0)
goto bad;
if(vmap_insert(args->vmap, vmn, ph.vaddr) < 0)
goto bad;
if(vmap_insert(args->vmap, vmn, ph.vaddr) < 0)
goto bad;
prof_end(dosegment_prof);
return;
prof_end(dosegment_prof);
return;
}
bad:
panic("dosegment: Oops");
......@@ -77,9 +80,8 @@ bad:
static void dostack(uptr a0, u64 a1)
{
static DEFINE_PROFCTR(dostack_prof);
struct vmnode *vmn = NULL;
struct eargs *args = (void*) a0;
struct eargs *args = (eargs*) a0;
int argc;
uptr sp;
uptr ustack[1+MAXARG+1];
......@@ -132,9 +134,8 @@ bad:
static void doheap(uptr a0, u64 a1)
{
static DEFINE_PROFCTR(doheap_prof);
struct vmnode *vmn = NULL;
struct eargs *args = (void*) a0;
struct eargs *args = (eargs*) a0;
prof_start(doheap_prof);
// Allocate a vmnode for the heap.
......@@ -155,7 +156,6 @@ bad:
int
exec(char *path, char **argv)
{
static DEFINE_PROFCTR(exec_prof);
struct inode *ip = NULL;
struct vmap *vmap = NULL;
struct vmnode *vmn = NULL;
......
extern "C" {
#include "types.h"
#include "spinlock.h"
#include "condvar.h"
......@@ -5,6 +6,8 @@
#include "fs.h"
#include "file.h"
#include "stat.h"
#include "net.h"
}
struct devsw __mpalign__ devsw[NDEV];
......@@ -12,7 +15,7 @@ struct devsw __mpalign__ devsw[NDEV];
struct file*
filealloc(void)
{
struct file *f = kmalloc(sizeof(struct file));
struct file *f = (file*) kmalloc(sizeof(struct file));
f->ref = 1;
return f;
}
......@@ -30,16 +33,14 @@ filedup(struct file *f)
void
fileclose(struct file *f)
{
extern void netclose(int sock);
if (subfetch(&f->ref, 1) > 0)
return;
if(f->type == FD_PIPE)
if(f->type == file::FD_PIPE)
pipeclose(f->pipe, f->writable);
else if(f->type == FD_INODE)
else if(f->type == file::FD_INODE)
iput(f->ip);
else if(f->type == FD_SOCKET)
else if(f->type == file::FD_SOCKET)
netclose(f->socket);
else
panic("fileclose bad type");
......@@ -50,7 +51,7 @@ fileclose(struct file *f)
int
filestat(struct file *f, struct stat *st)
{
if(f->type == FD_INODE){
if(f->type == file::FD_INODE){
ilock(f->ip, 0);
if(f->ip->type == 0)
panic("filestat");
......@@ -65,14 +66,13 @@ filestat(struct file *f, struct stat *st)
int
fileread(struct file *f, char *addr, int n)
{
extern int netread(int, char *, int);
int r;
if(f->readable == 0)
return -1;
if(f->type == FD_PIPE)
if(f->type == file::FD_PIPE)
return piperead(f->pipe, addr, n);
if(f->type == FD_INODE){
if(f->type == file::FD_INODE){
ilock(f->ip, 0);
if(f->ip->type == 0)
panic("fileread");
......@@ -81,7 +81,7 @@ fileread(struct file *f, char *addr, int n)
iunlock(f->ip);
return r;
}
if(f->type == FD_SOCKET)
if(f->type == file::FD_SOCKET)
return netread(f->socket, addr, n);
panic("fileread");
}
......@@ -90,14 +90,13 @@ fileread(struct file *f, char *addr, int n)
int
filewrite(struct file *f, char *addr, int n)
{
extern int netwrite(int, char *, int);
int r;
if(f->writable == 0)
return -1;
if(f->type == FD_PIPE)
if(f->type == file::FD_PIPE)
return pipewrite(f->pipe, addr, n);
if(f->type == FD_INODE){
if(f->type == file::FD_INODE){
ilock(f->ip, 1);
if(f->ip->type == 0 || f->ip->type == T_DIR)
panic("filewrite but 0 or T_DIR");
......@@ -106,7 +105,7 @@ filewrite(struct file *f, char *addr, int n)
iunlock(f->ip);
return r;
}
if(f->type == FD_SOCKET)
if(f->type == file::FD_SOCKET)
return netwrite(f->socket, addr, n);
panic("filewrite");
}
extern "C" {
#include "types.h"
#include "kernel.h"
#include <stddef.h>
#include <stdarg.h>
#include "fmt.h"
}
//
// Print a number (base <= 16) in reverse order,
......
......@@ -18,7 +18,7 @@ execbench(void)
exit();
}
if (pid == 0) {
char *av[] = { "forkexecbench", "x", 0 };
const char *av[] = { "forkexecbench", "x", 0 };
exec("forkexecbench", av);
printf(1, "exec failed\n");
exit();
......
......@@ -28,7 +28,7 @@ forktree(int depth)
depth++;
char depthbuf[16];
snprintf(depthbuf, sizeof(depthbuf), "%d", depth);
char *av[] = { "forkexectree", depthbuf };
const char *av[] = { "forkexectree", depthbuf };
exec("forkexectree", av);
}
}
......
......@@ -10,6 +10,7 @@
// routines. The (higher-level) system call implementations
// are in sysfile.c.
extern "C" {
#include "types.h"
#include "stat.h"
#include "mmu.h"
......@@ -22,6 +23,7 @@
#include "fs.h"
#include "file.h"
#include "cpu.h"
}
#define min(a, b) ((a) < (b) ? (a) : (b))
static void itrunc(struct inode*);
......@@ -204,7 +206,7 @@ iupdate(struct inode *ip)
static void *
evict(void *vkey, void *p, void *arg)
{
struct inode *ip = p;
struct inode *ip = (inode*) p;
if (ip->ref || ip->type == T_DIR)
return 0;
......@@ -225,7 +227,7 @@ evict(void *vkey, void *p, void *arg)
static void
ifree(void *arg)
{
struct inode *ip = arg;
struct inode *ip = (inode*) arg;
if (ip->dir) {
ns_remove(ip->dir, KD("."), 0);
......@@ -246,7 +248,7 @@ iget(u32 dev, u32 inum)
retry:
// Try for cached inode.
gc_begin_epoch();
ip = ns_lookup(ins, KII(dev, inum));
ip = (inode*) ns_lookup(ins, KII(dev, inum));
if (ip) {
// tricky: first bump ref, then check free flag
__sync_fetch_and_add(&ip->ref, 1);
......@@ -271,7 +273,7 @@ iget(u32 dev, u32 inum)
(void) 0;
u32 cur_free = icache_free[mycpu()->id].x;
if (cur_free == 0) {
struct inode *victim = ns_enumerate(ins, evict, 0);
struct inode *victim = (inode*) ns_enumerate(ins, evict, 0);
if (!victim)
panic("iget out of space");
// tricky: first flag as free, then check refcnt, then remove from ns
......@@ -289,7 +291,7 @@ iget(u32 dev, u32 inum)
goto retry_evict;
}
ip = kmalloc(sizeof(*ip));
ip = (inode*) kmalloc(sizeof(*ip));
ip->dev = dev;
ip->inum = inum;
ip->ref = 1;
......@@ -613,8 +615,8 @@ struct flush_state {
static void *
dir_flush_cb(void *key, void *val, void *arg)
{
struct flush_state *fs = arg;
char *name = key;
struct flush_state *fs = (flush_state*) arg;
char *name = (char*) key;
u32 inum = (u64) val;
struct dirent de;
......@@ -658,7 +660,7 @@ dirlookup(struct inode *dp, char *name)
// Write a new directory entry (name, inum) into the directory dp.
int
dirlink(struct inode *dp, char *name, u32 inum)
dirlink(struct inode *dp, const char *name, u32 inum)
{
dir_init(dp);
......@@ -684,10 +686,10 @@ dirlink(struct inode *dp, char *name, u32 inum)
// skipelem("", name) = skipelem("////", name) = 0
//
static int
skipelem(char **rpath, char *name)
skipelem(const char **rpath, char *name)
{
char *path = *rpath;
char *s;
const char *path = *rpath;
const char *s;
int len;
while(*path == '/')
......@@ -714,7 +716,7 @@ skipelem(char **rpath, char *name)
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
static struct inode*
namex(char *path, int nameiparent, char *name)
namex(const char *path, int nameiparent, char *name)
{
struct inode *ip, *next;
int r;
......@@ -759,7 +761,7 @@ namex(char *path, int nameiparent, char *name)
}
struct inode*
namei(char *path)
namei(const char *path)
{
char name[DIRSIZ];
struct inode *r = namex(path, 0, name);
......
extern "C" {
#include "types.h"
#include "kernel.h"
#include "mmu.h"
......@@ -7,6 +8,7 @@
#include "queue.h"
#include "proc.h"
#include "cpu.h"
}
// GC scheme based on Fraser's:
// a machine has a global_epoch
......@@ -61,7 +63,7 @@ u64 global_epoch __mpalign__;
struct gc *
gc_alloc()
{
struct gc *r = kmalloc(sizeof(struct gc));
struct gc *r = (gc*) kmalloc(sizeof(struct gc));
assert(r);
__sync_fetch_and_add(&gc_state[mycpu()->id].ndelayed, 1);
return r;
......@@ -69,7 +71,7 @@ gc_alloc()
static void *
gc_min(void *vkey, void *v, void *arg){
u64 *min_epoch_p = arg;
u64 *min_epoch_p = (u64*) arg;
struct proc *p = (struct proc *) v;
// Some threads may never call begin/end_epoch(), and never update
// p->epoch, so gc_thread does it for them. XXX get rid off lock?
......@@ -175,7 +177,7 @@ gc_delayfreelist(void)
u64 min = global;
// make that global_epoch doesn't run into a core's min_epoch
for (int c = 0; c < ncpu; c++) {
int w = gc_state[c].min_epoch + NEPOCH-1;
u64 w = gc_state[c].min_epoch + NEPOCH-1;
if (w < min) {
min = w;
}
......@@ -322,7 +324,7 @@ initgc(void)
initcondvar(&gc_state[i].cv, "gc_cv");
}
for (u32 c = 0; c < ncpu; c++) {
for (int c = 0; c < ncpu; c++) {
struct proc *gcp;
gcp = threadalloc(gc_worker, NULL);
......
extern "C" {
#include "types.h"
#include "user.h"
}
int
main(int argc, char *argv[])
......
......@@ -19,7 +19,7 @@ static int xwrite(int fd, const void *buf, u64 n)
printf(1, "xwrite: failed %d\n", r);
return -1;
}
buf += r;
buf = (char *) buf + r;
n -= r;
}
......@@ -208,7 +208,7 @@ parse(const char *b, char **rurl)
b++;
len = b - url;
r = malloc(len+1);
r = (char *) malloc(len+1);
if (r == NULL)
return -1;
memmove(r, url, len);
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "mmu.h"
......@@ -11,6 +12,7 @@
#include "proc.h"
#include "vm.h"
#include <stddef.h>
}
extern pml4e_t kpml4[];
......@@ -24,7 +26,7 @@ retry:
dir = &dir[PX(level, va)];
entry = *dir;
if (entry & PTE_P) {
next = p2v(PTE_ADDR(entry));
next = (pme_t*) p2v(PTE_ADDR(entry));
} else {
if (!create)
return NULL;
......@@ -69,8 +71,8 @@ updatepages(pme_t *pml4, void *begin, void *end, int perm)
char *a, *last;
pme_t *pte;
a = PGROUNDDOWN(begin);
last = PGROUNDDOWN(end);
a = (char*) PGROUNDDOWN(begin);
last = (char*) PGROUNDDOWN(end);
for (;;) {
pte = walkpgdir(pml4, a, 1);
if(pte != 0) {
......@@ -85,7 +87,7 @@ updatepages(pme_t *pml4, void *begin, void *end, int perm)
// Map from 0 to 128Gbytes starting at KBASE.
void
initpg(char* (*alloc)(void))
initpg(void)
{
extern char end[];
void *va = (void*)KBASE;
......@@ -100,7 +102,7 @@ initpg(char* (*alloc)(void))
if (va >= (void*) end)
flags |= PTE_NX;
*sp = pa | flags;
va += PGSIZE*512;
va = (char*)va + PGSIZE*512;
pa += PGSIZE*512;
}
}
......@@ -124,7 +126,7 @@ int
setupkshared(pml4e_t *pml4, char *kshared)
{
for (u64 off = 0; off < KSHAREDSIZE; off+=4096) {
pme_t *pte = walkpgdir(pml4, (void*)KSHARED+off, 1);
pme_t *pte = walkpgdir(pml4, (void*)(KSHARED+off), 1);
if (pte == NULL)
panic("setupkshared: oops");
*pte = v2p(kshared+off) | PTE_P | PTE_U | PTE_W;
......@@ -166,7 +168,7 @@ freepm(pme_t *pm, int level)
if (level != 0) {
for (i = 0; i < 512; i++) {
if (pm[i] & PTE_P)
freepm(p2v(PTE_ADDR(pm[i])), level - 1);
freepm((pme_t*) p2v(PTE_ADDR(pm[i])), level - 1);
}
}
......@@ -188,7 +190,7 @@ freevm(pml4e_t *pml4)
k = PX(3, KBASE);
for (i = 0; i < k; i++) {
if (pml4[i] & PTE_P) {
freepm(p2v(PTE_ADDR(pml4[i])), 2);
freepm((pme_t*) p2v(PTE_ADDR(pml4[i])), 2);
}
}
......
// Intel 8253/8254/82C54 Programmable Interval Timer (PIT).
// http://en.wikipedia.org/wiki/Intel_8253
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
}
#define IO_TIMER1 0x040 // 8253 Timer #1
#define TIMER_FREQ 1193182
......
......@@ -6,8 +6,8 @@
#include "fcntl.h"
#include "lib.h"
static char *sh_argv[] = { "sh", 0 };
static char *app_argv[][MAXARG] = {
static const char *sh_argv[] = { "sh", 0 };
static const char *app_argv[][MAXARG] = {
#ifdef LWIP
{ "telnetd", 0 },
{ "httpd", 0 },
......@@ -15,7 +15,7 @@ static char *app_argv[][MAXARG] = {
};
static int
startone(char **argv)
startone(const char **argv)
{
int pid;
......@@ -52,7 +52,7 @@ main(void)
if (mknod("/dev/lockstat", 4, 1) < 0)
printf(2, "init: mknod lockstat failed\n");
for (int i = 0; i < NELEM(app_argv); i++)
for (u32 i = 0; i < NELEM(app_argv); i++)
startone(app_argv[i]);
for(;;){
......
......@@ -2,9 +2,11 @@
// http://www.intel.com/design/chipsets/datashts/29056601.pdf
// See also picirq.c.
extern "C" {
#include "types.h"
#include "traps.h"
#include "kernel.h"
}
#define IOAPIC (KBASE + 0xFEC00000) // Default physical address of IO APIC
......
......@@ -39,7 +39,6 @@ extern char end[]; // first address after kernel loaded from ELF file
char *newend;
static int kinited __mpalign__;
extern void kminit();
static struct Mbmem *
memsearch(paddr pa)
......
......@@ -9,7 +9,7 @@
#define KDSEG (3<<3) /* kernel data segment */
static inline uptr v2p(void *a) { return (uptr) a - KBASE; }
static inline void *p2v(uptr a) { return (void *) a + KBASE; }
static inline void *p2v(uptr a) { return (u8 *) a + KBASE; }
struct trapframe;
struct cilkframe;
......@@ -50,7 +50,7 @@ void cprintf(const char*, ...) __attribute__((format(printf, 1, 2)));
void panic(const char*, ...)
__noret__ __attribute__((format(printf, 1, 2)));
void kerneltrap(struct trapframe *tf) __noret__;
void snprintf(char *buf, u32 n, char *fmt, ...);
void snprintf(char *buf, u32 n, const char *fmt, ...);
void consoleintr(int(*)(void));
#define assert(c) if (!(c)) { cprintf("%s:%d: ", __FILE__, __LINE__); panic("assertion failure"); }
......@@ -101,7 +101,7 @@ int filewrite(struct file*, char*, int n);
int namecmp(const char*, const char*);
struct inode* dirlookup(struct inode*, char*);
struct inode* ialloc(u32, short);
struct inode* namei(char*);
struct inode* namei(const char*);
void iput(struct inode*);
struct inode* iget(u32 dev, u32 inum);
void ilock(struct inode*, int writer);
......@@ -113,7 +113,7 @@ void stati(struct inode*, struct stat*);
int writei(struct inode*, char*, u32, u32);
struct inode* idup(struct inode*);
struct inode* nameiparent(char*, char*);
int dirlink(struct inode*, char*, u32);
int dirlink(struct inode*, const char*, u32);
void dir_init(struct inode *dp);
void dir_flush(struct inode *dp);
......@@ -135,6 +135,7 @@ pme_t * walkpgdir(pml4e_t*, const void*, int);
// hz.c
void microdelay(u64);
u64 nsectime(void);
void inithz(void);
// ide.c
void ideinit(void);
......@@ -159,6 +160,7 @@ void kmfree(void*);
int kmalign(void **p, int align, u64 size);
void kmalignfree(void *);
void verifyfree(char *ptr, u64 nbytes);
void kminit(void);
// kbd.c
void kbdintr(void);
......@@ -200,7 +202,7 @@ struct nskey {
u64 b;
} ii;
char *s;
char *dirname;
const char *dirname;
struct {
u64 a;
u64 b;
......@@ -209,10 +211,10 @@ struct nskey {
} u;
};
#define KI(v) (struct nskey){.type=nskey_int,.u.i=v}
#define KII(x,y) (struct nskey){.type=nskey_ii,.u.ii.a=x,.u.ii.b=y}
#define KI(v) (struct nskey){type: nskey_int, u: { i: v }}
#define KII(x,y) (struct nskey){type: nskey_ii, u: {ii: {a:x, b:y}}}
#define KS(v) (struct nskey){.type=nskey_str,.u.s=v}
#define KD(v) (struct nskey){.type=nskey_dirname,.u.dirname=v}
#define KD(v) (struct nskey){type: nskey_dirname, u: { dirname: v }}
#define KIIS(x,y,z) (struct nskey){.type=nskey_iis,.u.iis.a=x, \
.u.iis.b=y, \
.u.iis.s=z}
......@@ -291,10 +293,11 @@ void syscall(void);
int memcmp(const void*, const void*, u32);
void* memmove(void*, const void*, u32);
void* memset(void*, int, u32);
char* safestrcpy(char*, const char*, int);
void* memcpy(void*, const void *, u32);
char* safestrcpy(char*, const char*, u32);
int strlen(const char*);
int strncmp(const char*, const char*, u32);
char* strncpy(char*, const char*, int);
char* strncpy(char*, const char*, u32);
int strcmp(const char *p, const char *q);
// swtch.S
......@@ -311,8 +314,10 @@ void uartputc(char c);
void uartintr(void);
// vm.c
enum vmntype { EAGER, ONDEMAND };
struct vmap * vmap_alloc(void);
struct vmnode* vmn_alloc(u64, u32);
struct vmnode* vmn_alloc(u64, enum vmntype);
struct vmnode* vmn_allocpg(u64);
int vmap_insert(struct vmap*, struct vmnode *, uptr);
struct vma * vmap_lookup(struct vmap*, uptr, uptr);
......@@ -352,3 +357,70 @@ void initcilkframe(struct cilkframe *wq);
#define cilk_trywork() 0
#define initcilkframe(x) do { } while (0)
#endif
// various init functions
void initpic(void);
void initioapic(void);
void inituart(void);
void initcga(void);
void initconsole(void);
void initpg(void);
void initmp(void);
void initlapic(void);
void inittls(void);
void inittrap(void);
void initseg(void);
void initkalloc(u64 mbaddr);
void initrcu(void);
void initproc(void);
void initbio(void);
void initinode(void);
void initdisk(void);
void inituser(void);
void initcilk(void);
void initsamp(void);
void initpci(void);
void initnet(void);
void initsched(void);
void initlockstat(void);
void initwq(void);
// syscalls
long sys_chdir(void);
long sys_close(void);
long sys_dup(void);
long sys_exec(void);
long sys_exit(void);
long sys_fork(void);
long sys_fstat(void);
long sys_getpid(void);
long sys_kill(void);
long sys_link(void);
long sys_mkdir(void);
long sys_mknod(void);
long sys_open(void);
long sys_pipe(void);
long sys_read(void);
long sys_sbrk(void);
long sys_sleep(void);
long sys_unlink(void);
long sys_wait(void);
long sys_write(void);
long sys_uptime(void);
long sys_map(void);
long sys_unmap(void);
long sys_halt(void);
long sys_socket(int, int, int);
long sys_bind(int, void*, int);
long sys_listen(int, int);
long sys_accept(int, void*, void*);
long sys_pread(int fd, void *ubuf, size_t count, off_t offset);
long sys_kernlet(int, size_t, off_t);
// other exported/imported functions
void cmain(u64 mbmagic, u64 mbaddr);
void mpboot(void);
void trapret(void);
void threadstub(void);
void threadhelper(void (*fn)(void *), void *arg);
extern "C" {
#include "types.h"
#include "stat.h"
#include "user.h"
}
int
main(int argc, char **argv)
......
......@@ -2,6 +2,7 @@
// Allocate objects smaller than a page.
//
extern "C" {
#include "types.h"
#include "mmu.h"
#include "kernel.h"
......@@ -9,6 +10,7 @@
#include "kalloc.h"
#include "mtrace.h"
#include "cpu.h"
}
// allocate in power-of-two sizes up to 2^KMMAX
// must be < 12
......@@ -78,7 +80,7 @@ kmalloc(u64 nbytes)
if(h){
freelists[c].buckets[b] = h->next;
r = h + 1;
h->next = (void *) (long) b;
h->next = (header*) (long) b;
}
release(&freelists[c].lock);
......@@ -103,7 +105,7 @@ kmfree(void *ap)
if(b < 0 || b > KMMAX)
panic("kmfree bad bucket");
verifyfree(ap, (1<<b) - sizeof(struct header));
verifyfree((char*) ap, (1<<b) - sizeof(struct header));
if (ALLOC_MEMSET)
memset(ap, 3, (1<<b) - sizeof(struct header));
......
// The local APIC manages internal (non-I/O) interrupts.
// See Chapter 8 & Appendix C of Intel processor manual volume 3.
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
#include "traps.h"
#include "bits.h"
}
// Local APIC registers, divided by 4 for use as uint[] indices.
#define ID (0x0020/4) // ID
......
......@@ -50,7 +50,7 @@ stats(void)
}
int
main(int ac, char *av[])
main(int ac, const char *av[])
{
int fd = open("/dev/lockstat", O_RDWR);
if (fd < 0)
......
......@@ -3,11 +3,11 @@
#include "user.h"
#include "fs.h"
char*
fmtname(char *path)
const char*
fmtname(const char *path)
{
static char buf[DIRSIZ+1];
char *p;
const char *p;
// Find first character after last slash.
for(p=path+strlen(path); p >= path && *p != '/'; p--)
......@@ -23,7 +23,7 @@ fmtname(char *path)
}
void
ls(char *path)
ls(const char *path)
{
char buf[512], *p;
int fd;
......
extern "C" {
#include "types.h"
#include "multiboot.h"
#include "kernel.h"
#include "cpu.h"
#include "amd64.h"
extern void initpic(void);
extern void initioapic(void);
extern void inituart(void);
extern void initcga(void);
extern void initconsole(void);
extern void initpg(void);
extern void initmp(void);
extern void initlapic(void);
extern void inittls(void);
extern void inittrap(void);
extern void initseg(void);
extern void initkalloc(u64 mbaddr);
extern void initrcu(void);
extern void initproc(void);
extern void initbio(void);
extern void initinode(void);
extern void initdisk(void);
extern void inituser(void);
extern void inithz(void);
extern void initwq(void);
extern void initcilk(void);
extern void initsamp(void);
extern void initpci(void);
extern void initnet(void);
extern void initsched(void);
extern void initlockstat(void);
}
static volatile int bstate;
......@@ -57,7 +32,7 @@ bootothers(void)
// Write bootstrap code to unused memory at 0x7000.
// The linker has placed the image of bootother.S in
// _binary_bootother_start.
code = p2v(0x7000);
code = (u8*) p2v(0x7000);
memmove(code, _bootother_start, _bootother_size);
for(c = cpus; c < cpus+ncpu; c++){
......@@ -67,7 +42,7 @@ bootothers(void)
// Tell bootother.S what stack to use and the address of apstart;
// it expects to find these two addresses stored just before
// its first instruction.
stack = ksalloc(slab_stack);
stack = (char*) ksalloc(slab_stack);
*(u32*)(code-4) = (u32)v2p(&apstart);
*(u64*)(code-12) = (u64)stack + KSTACKSIZE;
......
......@@ -13,8 +13,8 @@ void
thr(void *arg)
{
u64 tid = (u64)arg;
for (int i = 0; i < 100; i++) {
for (int i = 0; i < 10000; i++) {
volatile char *p = (char*) (0x40000UL + tid * 8 * 4096);
if (map((void *) p, 8 * 4096) < 0) {
printf(1, "%d: map failed\n", tid);
......@@ -57,7 +57,7 @@ main(int ac, char **av)
sbrk(8192);
void *tstack = sbrk(0);
// printf(1, "tstack %lx\n", tstack);
int tid = forkt(tstack, thr, (void *)(u64)i);
int tid = forkt(tstack, (void*) thr, (void *)(u64)i);
if (0) printf(1, "mapbench[%d]: child %d\n", getpid(), tid);
}
......@@ -68,7 +68,7 @@ main(int ac, char **av)
if(lastc==nthread)
break;
while(tcount==lastc)
__asm __volatile("");
__asm __volatile("":::"memory");
acquire(&l);
}
release(&l);
......
......@@ -55,7 +55,7 @@ main(void)
}
sbrk(4096);
forkt(sbrk(0), thr, 0);
forkt(sbrk(0), (void*) thr, 0);
acquire(&l);
state = 1;
......
// Fake IDE disk; stores blocks in memory.
// Useful for running kernel without scratch disk.
extern "C" {
#include "types.h"
#include "mmu.h"
#include "kernel.h"
......@@ -11,6 +12,7 @@
#include "amd64.h"
#include "traps.h"
#include "buf.h"
}
extern u8 _fs_img_start[];
extern u64 _fs_img_size;
......
......@@ -39,17 +39,17 @@ struct segdesc {
// SEGDESC constructs a segment descriptor literal
// with the given, base, limit, and type bits.
#define SEGDESC(base, limit, bits) { \
(limit)&0xffff, (base)&0xffff, \
((base)>>16)&0xff, \
(limit)&0xffff, (u16) ((base)&0xffff), \
(u8) (((base)>>16)&0xff), \
(bits)&0xff, \
(((bits)>>4)&0xf0) | ((limit>>16)&0xf), \
((base)>>24)&0xff, \
(u8) (((base)>>24)&0xff), \
}
// SEGDESCHI constructs an extension segment descriptor
// literal that records the high bits of base.
#define SEGDESCHI(base) { \
((base)>>32)&0xffff, ((base)>>48)&0xffff, \
(u16) (((base)>>32)&0xffff), (u16) (((base)>>48)&0xffff), \
}
// Segment selectors (indexes) in our GDTs.
......
......@@ -2,11 +2,13 @@
// Search memory for MP description structures.
// http://developer.intel.com/design/pentium/datashts/24201606.pdf
extern "C" {
#include "types.h"
#include "amd64.h"
#include "mp.h"
#include "kernel.h"
#include "cpu.h"
}
struct cpu cpus[NCPU];
static struct cpu *bcpu __mpalign__;
......@@ -37,7 +39,7 @@ mpsearch1(u8 *addr, int len)
{
u8 *e, *p;
addr = p2v((uptr) addr);
addr = (u8*) p2v((uptr) addr);
e = addr+len;
for(p = addr; p < e; p += sizeof(struct mp))
if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0)
......
#ifdef LWIP
extern "C" {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#include "lwip/tcp_impl.h"
......@@ -9,8 +10,10 @@
#include "lwip/sockets.h"
#include "netif/etharp.h"
#pragma GCC diagnostic pop
}
#endif
extern "C" {
#include "types.h"
#include "kernel.h"
#include "queue.h"
......@@ -21,6 +24,11 @@
#include "proc.h"
#include "fs.h"
#include "file.h"
#include "net.h"
err_t if_init(struct netif *netif);
void if_input(struct netif *netif, void *buf, u16 len);
}
void
netfree(void *va)
......@@ -66,8 +74,6 @@ int errno;
void
netrx(void *va, u16 len)
{
extern void if_input(struct netif *netif, void *buf, u16 len);
lwip_core_lock();
if_input(&nif, va, len);
lwip_core_unlock();
......@@ -114,8 +120,6 @@ static void
lwip_init(struct netif *nif, void *if_state,
u32 init_addr, u32 init_mask, u32 init_gw)
{
extern err_t if_init(struct netif *netif);
struct ip_addr ipaddr, netmask, gateway;
ipaddr.addr = init_addr;
netmask.addr = init_mask;
......@@ -134,7 +138,7 @@ lwip_init(struct netif *nif, void *if_state,
static void
tcpip_init_done(void *arg)
{
volatile long *tcpip_done = arg;
volatile long *tcpip_done = (volatile long*) arg;
*tcpip_done = 1;
}
......@@ -289,7 +293,7 @@ netbind(int sock, void *xaddr, int xaddrlen)
return -1;
lwip_core_lock();
r = lwip_bind(sock, addr, xaddrlen);
r = lwip_bind(sock, (const sockaddr*) addr, xaddrlen);
lwip_core_unlock();
kmfree(addr);
return r;
......@@ -309,7 +313,7 @@ netlisten(int sock, int backlog)
long
netaccept(int sock, void *xaddr, void *xaddrlen)
{
socklen_t *lenptr = xaddrlen;
socklen_t *lenptr = (socklen_t*) xaddrlen;
socklen_t len;
void *addr;
int ss;
......@@ -322,7 +326,7 @@ netaccept(int sock, void *xaddr, void *xaddrlen)
return -1;
lwip_core_lock();
ss = lwip_accept(sock, addr, &len);
ss = lwip_accept(sock, (sockaddr*) addr, &len);
lwip_core_unlock();
if (ss < 0) {
kmfree(addr);
......
#pragma once
void netclose(int sock);
int netread(int, char *, int);
int netwrite(int, char *, int);
long netsocket(int, int, int);
long netbind(int, void *, int);
long netlisten(int, int);
long netaccept(int, void *, void *);
......@@ -13,12 +13,13 @@ UPROGS += \
$(O)/_telnetd \
$(O)/_httpd
CFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
CFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
CXXFLAGS += -Ilwip/src/include -Inet -Ilwip/src/include/ipv4 -I. -DLWIP
LWIP_CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb \
-m64 -Werror -std=c99 -fms-extensions -mno-sse -mcmodel=large -I$(QEMUSRC) \
-fno-omit-frame-pointer -DHW_$(HW) -include param.h -include compiler.h \
-Wno-attributes -Wno-address -Wno-char-subscripts \
-DXV6 -Wno-attributes -Wno-address -Wno-char-subscripts \
-Wno-unused-but-set-variable -Wno-format
LWIP_CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
......
extern "C" {
#include "types.h"
#include "kernel.h"
#include "spinlock.h"
#include "fs.h"
#include <stddef.h>
}
// name spaces
// XXX maybe use open hash table, no chain, better cache locality
......@@ -54,7 +56,7 @@ nsalloc(int allowdup)
{
struct ns *ns = 0;
ns = kmalloc(sizeof(struct ns));
ns = (struct ns*) kmalloc(sizeof(struct ns));
if (ns == 0)
panic("nsalloc");
memset(ns, 0, sizeof(struct ns));
......@@ -102,7 +104,7 @@ elemalloc(struct nskey *k)
panic("key type");
}
e = kmalloc(sz);
e = (elem*) kmalloc(sz);
if (e == 0)
return 0;
memset(e, 0, sz);
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
#include "pci.h"
#include "pcireg.h"
}
extern int e1000attach(struct pci_func *pcif);
extern int e1000eattach(struct pci_func *pcif);
......@@ -45,26 +47,26 @@ struct pci_driver pci_attach_vendor[] = {
static const char *pci_class[] =
{
[0x0] = "Unknown",
[0x1] = "Storage controller",
[0x2] = "Network controller",
[0x3] = "Display controller",
[0x4] = "Multimedia device",
[0x5] = "Memory controller",
[0x6] = "Bridge device",
"Unknown",
"Storage controller",
"Network controller",
"Display controller",
"Multimedia device",
"Memory controller",
"Bridge device",
};
static void
pci_print_func(struct pci_func *f)
{
const char *class = pci_class[0];
const char *classname = pci_class[0];
if (PCI_CLASS(f->dev_class) < sizeof(pci_class) / sizeof(pci_class[0]))
class = pci_class[PCI_CLASS(f->dev_class)];
classname = pci_class[PCI_CLASS(f->dev_class)];
cprintf("PCI: %x:%x.%d: %x:%x: class: %x.%x (%s) irq: %d\n",
f->bus->busno, f->dev, f->func,
PCI_VENDOR(f->dev_id), PCI_PRODUCT(f->dev_id),
PCI_CLASS(f->dev_class), PCI_SUBCLASS(f->dev_class), class,
PCI_CLASS(f->dev_class), PCI_SUBCLASS(f->dev_class), classname,
f->irq_line);
}
......
// Intel 8259A programmable interrupt controllers.
extern "C" {
#include "types.h"
#include "amd64.h"
#include "traps.h"
#include "kernel.h"
}
// I/O Addresses of the two programmable interrupt controllers
#define IO_PIC1 0x20 // Master (IRQs 0-7)
......
extern "C" {
#include "types.h"
#include "mmu.h"
#include "kernel.h"
......@@ -8,6 +9,7 @@
#include "fs.h"
#include "file.h"
#include "cpu.h"
}
#define PIPESIZE 512
......@@ -38,11 +40,11 @@ pipealloc(struct file **f0, struct file **f1)
p->nread = 0;
initlock(&p->lock, "pipe", LOCKSTAT_PIPE);
initcondvar(&p->cv, "pipe");
(*f0)->type = FD_PIPE;
(*f0)->type = file::FD_PIPE;
(*f0)->readable = 1;
(*f0)->writable = 0;
(*f0)->pipe = p;
(*f1)->type = FD_PIPE;
(*f1)->type = file::FD_PIPE;
(*f1)->readable = 0;
(*f1)->writable = 1;
(*f1)->pipe = p;
......
......@@ -37,7 +37,7 @@ void
vprintfmt(void (*putch) (void*, char), void *putarg,
const char *fmt, va_list ap)
{
char *s;
const char *s;
int c, i, state;
state = 0;
......@@ -58,7 +58,7 @@ vprintfmt(void (*putch) (void*, char), void *putarg,
state = 'l';
continue;
} else if(c == 's'){
s = (char*) va_arg(ap, char*);
s = (const char*) va_arg(ap, const char*);
if(s == 0)
s = "(null)";
while(*s != 0){
......@@ -101,7 +101,7 @@ writec(void *arg, char c)
}
void
printf(int fd, char *fmt, ...)
printf(int fd, const char *fmt, ...)
{
va_list ap;
......@@ -119,7 +119,7 @@ struct bufstate {
static void
writebuf(void *arg, char c)
{
struct bufstate *bs = arg;
struct bufstate *bs = (bufstate*) arg;
if (bs->p < bs->e) {
bs->p[0] = c;
bs->p++;
......@@ -127,7 +127,7 @@ writebuf(void *arg, char c)
}
void
vsnprintf(char *buf, u32 n, char *fmt, va_list ap)
vsnprintf(char *buf, u32 n, const char *fmt, va_list ap)
{
struct bufstate bs = { buf, buf+n-1 };
vprintfmt(writebuf, (void*) &bs, fmt, ap);
......@@ -135,7 +135,7 @@ vsnprintf(char *buf, u32 n, char *fmt, va_list ap)
}
void
snprintf(char *buf, u32 n, char *fmt, ...)
snprintf(char *buf, u32 n, const char *fmt, ...)
{
va_list ap;
......
extern "C" {
#include "types.h"
#include "kernel.h"
#include "mmu.h"
......@@ -11,8 +12,7 @@
#include "kmtrace.h"
#include "vm.h"
#include "sched.h"
extern void threadstub(void);
}
int __mpalign__ idle[NCPU];
struct ns *nspid __mpalign__;
......@@ -139,7 +139,7 @@ exit(void)
// Kernel threads might not have a cwd
if (myproc()->cwd != NULL) {
iput(myproc()->cwd);
myproc()->cwd = NULL;
myproc()->cwd = 0;
}
// Pass abandoned children to init.
......@@ -185,11 +185,10 @@ freeproc(struct proc *p)
static struct proc*
allocproc(void)
{
extern void trapret(void);
struct proc *p;
char *sp;
p = kmalloc(sizeof(struct proc));
p = (proc*) kmalloc(sizeof(struct proc));
if (p == 0) return 0;
memset(p, 0, sizeof(*p));
......@@ -212,7 +211,7 @@ allocproc(void)
panic("allocproc: ns_insert");
// Allocate kernel stack if possible.
if((p->kstack = ksalloc(slab_stack)) == NULL){
if((p->kstack = (char*) ksalloc(slab_stack)) == 0){
if (ns_remove(nspid, KI(p->pid), p) == 0)
panic("allocproc: ns_remove");
freeproc(p);
......@@ -272,7 +271,7 @@ inituser(void)
p->tf->rip = 0x0; // beginning of initcode.S
safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = NULL; // forkret will fix in the process's context
p->cwd = 0; // forkret will fix in the process's context
acquire(&p->lock);
addrun(p);
release(&p->lock);
......@@ -496,13 +495,13 @@ kill(int pid)
void *procdump(void *vk, void *v, void *arg)
{
static char *states[] = {
[UNUSED] = "unused",
[EMBRYO] = "embryo",
[SLEEPING] = "sleep ",
[RUNNABLE] = "runble",
[RUNNING] = "run ",
[ZOMBIE] = "zombie"
static const char *states[] = {
/* [UNUSED] = */ "unused",
/* [EMBRYO] = */ "embryo",
/* [SLEEPING] = */ "sleep ",
/* [RUNNABLE] = */ "runble",
/* [RUNNING] = */ "run ",
/* [ZOMBIE] = */ "zombie"
};
struct proc *p = (struct proc *) v;
const char *name = "(no name)";
......@@ -556,7 +555,7 @@ fork(int flags)
// Copy process state from p.
if((np->vmap = vmap_copy(myproc()->vmap, cow)) == 0){
ksfree(slab_stack, np->kstack);
np->kstack = NULL;
np->kstack = 0;
np->state = UNUSED;
if (ns_remove(nspid, KI(np->pid), np) == 0)
panic("fork: ns_remove");
......@@ -617,7 +616,7 @@ wait(void)
SLIST_REMOVE(&myproc()->childq, p, proc, child_next);
release(&myproc()->lock);
ksfree(slab_stack, p->kstack);
p->kstack = NULL;
p->kstack = 0;
vmap_decref(p->vmap);
p->state = UNUSED;
if (ns_remove(nspid, KI(p->pid), p) == 0)
......@@ -661,18 +660,18 @@ threadalloc(void (*fn)(void *), void *arg)
p = allocproc();
if (p == NULL)
return NULL;
return 0;
p->vmap = vmap_alloc();
if (p->vmap == NULL) {
freeproc(p);
return NULL;
return 0;
}
p->context->rip = (u64)threadstub;
p->context->r12 = (u64)fn;
p->context->r13 = (u64)arg;
p->parent = myproc();
p->cwd = NULL;
p->cwd = 0;
return p;
}
extern "C" {
#include "types.h"
#include "kernel.h"
#include "spinlock.h"
......@@ -7,6 +8,7 @@
#include "prof.h"
#include "bits.h"
#include "amd64.h"
}
extern profctr_t sprof[];
extern profctr_t eprof[];
......
......@@ -10,6 +10,7 @@ typedef struct profctr {
__padout__;
} profctr_t;
#if 0 /* not for c++ */
#define DEFINE_PROFCTR(xname) \
profctr_t xname __attribute__((section(".prof"))) = { .name = #xname };
......@@ -24,3 +25,8 @@ typedef struct profctr {
name.rec[__profid].cnt++; \
} \
} while (0)
#else
#define DEFINE_PROFCTR(x)
#define prof_start(x)
#define prof_end(x)
#endif
......@@ -209,7 +209,7 @@ struct { \
(varp) = &SLIST_NEXT((var), field))
#define SLIST_INIT(head) do { \
SLIST_FIRST((head)) = NULL; \
SLIST_FIRST((head)) = 0; \
} while (0)
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
......@@ -403,7 +403,7 @@ struct { \
(var) = (tvar))
#define LIST_INIT(head) do { \
LIST_FIRST((head)) = NULL; \
LIST_FIRST((head)) = 0; \
} while (0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
......
extern "C" {
#include "types.h"
#include "stat.h"
#include "user.h"
}
int
main(int argc, char *argv[])
......
extern "C" {
#include "param.h"
#include "types.h"
#include "kernel.h"
#include "cpu.h"
}
struct seed {
u64 v;
......
extern "C" {
#include "types.h"
#include "spinlock.h"
#include "condvar.h"
......@@ -8,6 +9,7 @@
#include "amd64.h"
#include "cpu.h"
#include "sampler.h"
}
static const u64 debug_sel =
0UL << 32 |
......@@ -47,10 +49,7 @@ amdconfig(u64 ctr, u64 sel, u64 val)
writemsr(MSR_AMD_PERF_SEL0 | ctr, sel);
}
struct pmu amdpmu = {
.config = amdconfig,
.cntval_bits = 48,
};
struct pmu amdpmu = { amdconfig, 48 };
//
// Intel stuff
......@@ -64,10 +63,7 @@ intelconfig(u64 ctr, u64 sel, u64 val)
}
// XXX
struct pmu intelpmu = {
.config = intelconfig,
.cntval_bits = 48,
};
struct pmu intelpmu = { intelconfig, 48 };
void
sampdump(void)
......@@ -177,7 +173,7 @@ sampread(struct inode *ip, char *dst, u32 off, u32 n)
u64 len = hdrlen;
u64 cc;
hdr = kmalloc(len);
hdr = (logheader*) kmalloc(len);
if (hdr == NULL)
return -1;
hdr->ncpus = NCPU;
......@@ -189,7 +185,7 @@ sampread(struct inode *ip, char *dst, u32 off, u32 n)
}
cc = MIN(hdrlen-off, n);
memmove(dst, (void*)hdr + off, cc);
memmove(dst, (char*)hdr + off, cc);
kmfree(hdr);
n -= cc;
......@@ -229,9 +225,9 @@ initsamp(void)
void *p = ksalloc(slab_perf);
if (p == NULL)
panic("initprof: ksalloc");
pmulog[cpunum()].event = p;
pmulog[cpunum()].event = (pmuevent*) p;
pmulog[cpunum()].capacity = PERFSIZE / sizeof(struct pmuevent);
devsw[SAMPLER].write = NULL;
devsw[SAMPLER].write = 0;
devsw[SAMPLER].read = sampread;
}
extern "C" {
#include "types.h"
#include "kernel.h"
#include "mmu.h"
......@@ -12,6 +13,7 @@
#include "vm.h"
#include "sched.h"
#include <stddef.h>
}
enum { sched_debug = 0 };
......
......@@ -19,7 +19,7 @@ struct cmd {
struct execcmd {
int type;
char *argv[MAXARGS];
const char *argv[MAXARGS];
char *eargv[MAXARGS];
};
......@@ -50,7 +50,7 @@ struct backcmd {
};
int fork1(void); // Fork but panics on failure.
void panic(char*);
void panic(const char*);
struct cmd *parsecmd(char*);
// Execute cmd. Never returns.
......@@ -173,7 +173,7 @@ main(void)
}
void
panic(char *s)
panic(const char *s)
{
printf(2, "%s\n", s);
exit();
......@@ -198,7 +198,7 @@ execcmd(void)
{
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
cmd = (struct execcmd *) malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = EXEC;
return (struct cmd*)cmd;
......@@ -209,7 +209,7 @@ redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
cmd = (struct redircmd *) malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = REDIR;
cmd->cmd = subcmd;
......@@ -225,7 +225,7 @@ pipecmd(struct cmd *left, struct cmd *right)
{
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
cmd = (struct pipecmd *) malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = PIPE;
cmd->left = left;
......@@ -238,7 +238,7 @@ listcmd(struct cmd *left, struct cmd *right)
{
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
cmd = (struct listcmd *) malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = LIST;
cmd->left = left;
......@@ -251,7 +251,7 @@ backcmd(struct cmd *subcmd)
{
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
cmd = (struct backcmd *) malloc(sizeof(*cmd));
memset(cmd, 0, sizeof(*cmd));
cmd->type = BACK;
cmd->cmd = subcmd;
......@@ -309,7 +309,7 @@ gettoken(char **ps, char *es, char **q, char **eq)
}
int
peek(char **ps, char *es, char *toks)
peek(char **ps, char *es, const char *toks)
{
char *s;
......
// Mutual exclusion spin locks.
extern "C" {
#include "types.h"
#include "kernel.h"
#include "amd64.h"
......@@ -10,6 +11,7 @@
#include "condvar.h"
#include "fs.h"
#include "file.h"
}
#if LOCKSTAT
static int lockstat_enable;
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
}
void*
memset(void *dst, int c, u32 n)
......@@ -13,8 +16,8 @@ memcmp(const void *v1, const void *v2, u32 n)
{
const u8 *s1, *s2;
s1 = v1;
s2 = v2;
s1 = (const u8*) v1;
s2 = (const u8*) v2;
while(n-- > 0){
if(*s1 != *s2)
return *s1 - *s2;
......@@ -30,8 +33,8 @@ memmove(void *dst, const void *src, u32 n)
const char *s;
char *d;
s = src;
d = dst;
s = (const char*) src;
d = (char*) dst;
if(s < d && s + n > d){
s += n;
d += n;
......
......@@ -146,37 +146,6 @@ kmemcpy(void *umem, void *src, u64 size)
return 0;
}
extern long sys_chdir(void);
extern long sys_close(void);
extern long sys_dup(void);
extern long sys_exec(void);
extern long sys_exit(void);
extern long sys_fork(void);
extern long sys_fstat(void);
extern long sys_getpid(void);
extern long sys_kill(void);
extern long sys_link(void);
extern long sys_mkdir(void);
extern long sys_mknod(void);
extern long sys_open(void);
extern long sys_pipe(void);
extern long sys_read(void);
extern long sys_sbrk(void);
extern long sys_sleep(void);
extern long sys_unlink(void);
extern long sys_wait(void);
extern long sys_write(void);
extern long sys_uptime(void);
extern long sys_map(void);
extern long sys_unmap(void);
extern long sys_halt(void);
extern long sys_socket(int, int, int);
extern long sys_bind(int, void*, int);
extern long sys_listen(int, int);
extern long sys_accept(int, void*, void*);
extern long sys_pread(int fd, void *ubuf, size_t count, off_t offset);
extern long sys_kernlet(int, size_t, off_t);
#define SYSCALL(name) [SYS_##name] = (void*)sys_##name
static long (*syscalls[])(u64, u64, u64, u64, u64, u64) = {
......
extern "C" {
#include "types.h"
#include "stat.h"
#include "mmu.h"
......@@ -10,6 +11,8 @@
#include "file.h"
#include "fcntl.h"
#include "cpu.h"
#include "net.h"
}
// Fetch the nth word-sized system call argument as a file descriptor
// and return both the descriptor and the corresponding struct file.
......@@ -82,11 +85,11 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
return -1;
// XXX(sbw) assuming ubuf is ok
if(f->type == FD_INODE){
if(f->type == file::FD_INODE){
ilock(f->ip, 0);
if(f->ip->type == 0)
panic("fileread");
r = readi(f->ip, ubuf, offset, count);
r = readi(f->ip, (char*)ubuf, offset, count);
iunlock(f->ip);
return r;
}
......@@ -124,7 +127,7 @@ sys_fstat(void)
struct file *f;
struct stat *st;
if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
if(argfd(0, 0, &f) < 0 || argptr(1, (char**)&st, sizeof(*st)) < 0)
return -1;
return filestat(f, st);
}
......@@ -133,10 +136,10 @@ sys_fstat(void)
long
sys_link(void)
{
char name[DIRSIZ], *new, *old;
char name[DIRSIZ], *newn, *old;
struct inode *dp, *ip;
if(argstr(0, &old) < 0 || argstr(1, &new) < 0)
if(argstr(0, &old) < 0 || argstr(1, &newn) < 0)
return -1;
if((ip = namei(old)) == 0)
return -1;
......@@ -149,7 +152,7 @@ sys_link(void)
iupdate(ip);
iunlock(ip);
if((dp = nameiparent(new, name)) == 0)
if((dp = nameiparent(newn, name)) == 0)
goto bad;
if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0)
goto bad;
......@@ -170,7 +173,7 @@ bad:
static void*
check_empty(void *k, void *v, void *arg)
{
char *name = k;
char *name = (char*) k;
if (strcmp(name, ".") && strcmp(name, ".."))
return (void*)1;
return 0;
......@@ -331,7 +334,7 @@ sys_open(void)
}
iunlock(ip);
f->type = FD_INODE;
f->type = file::FD_INODE;
f->ip = ip;
f->off = 0;
f->readable = !(omode & O_WRONLY);
......@@ -421,7 +424,7 @@ sys_pipe(void)
struct file *rf, *wf;
int fd0, fd1;
if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0)
if(argptr(0, (char**)&fd, 2*sizeof(fd[0])) < 0)
return -1;
if(pipealloc(&rf, &wf) < 0)
return -1;
......@@ -451,7 +454,7 @@ getsocket(int fd, struct file **ret)
struct file *f;
if (fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
return -1;
if (f->type != FD_SOCKET)
if (f->type != file::FD_SOCKET)
return -1;
*ret = f;
......@@ -474,7 +477,7 @@ allocsocket(struct file **rf, int *rfd)
return fd;
}
f->type = FD_SOCKET;
f->type = file::FD_SOCKET;
f->off = 0;
f->readable = 1;
f->writable = 1;
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "kernel.h"
......@@ -8,6 +9,7 @@
#include "proc.h"
#include "cpu.h"
#include "vm.h"
}
long
sys_fork(void)
......
......@@ -46,7 +46,7 @@ main(void)
continue;
}
if (pid == 0) {
static char *argv[] = { "sh", 0 };
static const char *argv[] = { "sh", 0 };
close(0);
close(1);
close(2);
......
......@@ -28,7 +28,7 @@ main(void)
for(int i = 0; i < nthread; i++) {
sbrk(8192);
void *tstack = sbrk(0);
int tid = forkt(tstack, thr, (void*)(u64)(0xc0ffee00|i));
int tid = forkt(tstack, (void*) thr, (void*)(u64)(0xc0ffee00|i));
printf(1, "thrtest[%d]: child %d\n", getpid(), tid);
}
......
......@@ -5,7 +5,7 @@
#include "amd64.h"
int
main(int ac, char *av[])
main(int ac, const char *av[])
{
u64 t0 = rdtsc();
......
......@@ -13,7 +13,9 @@ typedef uptr paddr;
typedef u64 pme_t;
typedef pme_t pml4e_t;
#ifdef XV6
// POSIX types
typedef s64 ssize_t;
typedef u64 size_t;
typedef u64 off_t;
#endif
// Intel 8250 serial port (UART).
// http://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming
extern "C" {
#include "types.h"
#include "kernel.h"
#include "amd64.h"
#include "traps.h"
}
#define COM2 0x2f8
#define COM1 0x3f8
......@@ -48,9 +51,9 @@ inituart(void)
int irq;
} conf[] = {
// Try COM2 (aka ttyS1) first, because it usually does SOL for IPMI.
{ .com = COM2, .irq = IRQ_COM2 },
{ COM2, IRQ_COM2 },
// Still try COM1 (aka ttyS0), because it is what QEMU emulates.
{ .com = COM1, .irq = IRQ_COM1 }
{ COM1, IRQ_COM1 }
};
int i;
......@@ -87,6 +90,6 @@ inituart(void)
ioapicenable(irq_com, 0);
// Announce that we're here.
for (char *p="uart..\n"; *p; p++)
for (const char *p="uart..\n"; *p; p++)
uartputc(*p);
}
......@@ -15,7 +15,7 @@ strncpy(char *s, const char *t, int n)
}
char*
strcpy(char *s, char *t)
strcpy(char *s, const char *t)
{
char *os;
......@@ -124,8 +124,8 @@ memmove(void *vdst, const void *vsrc, int n)
const char *src;
char *dst;
dst = vdst;
src = vsrc;
dst = (char*) vdst;
src = (const char*) vsrc;
while(n-- > 0)
*dst++ = *src++;
return vdst;
......
#ifdef LWIP
extern "C" {
#include "lwip/sockets.h"
// system calls
......@@ -7,6 +8,7 @@ extern int bind(int sockfd, const struct sockaddr *addr,
socklen_t addrlen);
extern int listen(int sockfd, int backlog);
extern int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
}
static inline const char *
ipaddr(struct sockaddr_in *sin)
......
struct stat;
// system calls
extern "C" {
int fork(int);
int exit(void) __attribute__((noreturn));
int wait(void);
......@@ -9,14 +10,14 @@ int write(int, const void*, int);
int read(int, void*, int);
int close(int);
int kill(int);
int exec(char*, char**);
int exec(const char*, const char**);
int open(const char*, int);
int mknod(char*, short, short);
int unlink(char*);
int mknod(const char*, short, short);
int unlink(const char*);
int fstat(int fd, struct stat*);
int link(char*, char*);
int mkdir(char*);
int chdir(char*);
int link(const char*, const char*);
int mkdir(const char*);
int chdir(const char*);
int dup(int);
int getpid(void);
char* sbrk(int);
......@@ -27,10 +28,11 @@ int unmap(void *addr, int len);
void halt(void);
ssize_t pread(int, void*, size_t, off_t);
int kernlet(int, size_t, off_t);
}
// ulib.c
int stat(char*, struct stat*);
char* strcpy(char*, char*);
char* strcpy(char*, const char*);
void *memmove(void*, const void*, int);
char* strchr(const char*, char c);
int strcmp(const char*, const char*);
......@@ -44,9 +46,11 @@ void free(void*);
int atoi(const char*);
// uthread.S
extern "C" {
int forkt(void *sp, void *pc, void *arg);
}
// printf.c
void printf(int, char*, ...);
void snprintf(char *buf, unsigned int n, char *fmt, ...);
void printf(int, const char*, ...);
void snprintf(char *buf, unsigned int n, const char *fmt, ...);
void die(const char* errstr, ...) __attribute__((noreturn));
......@@ -8,7 +8,7 @@
char buf[2048];
char name[3];
char *echoargv[] = { "echo", "ALL", "TESTS", "PASSED", 0 };
const char *echoargv[] = { "echo", "ALL", "TESTS", "PASSED", 0 };
int stdout = 1;
// simple file system tests
......@@ -85,7 +85,7 @@ writetest(void)
void
writetest1(void)
{
int i, fd, n;
int fd, n;
printf(stdout, "big files test\n");
......@@ -95,7 +95,7 @@ writetest1(void)
exit();
}
for(i = 0; i < MAXFILE; i++){
for(u32 i = 0; i < MAXFILE; i++){
((int*)buf)[0] = i;
if(write(fd, buf, 512) != 512){
printf(stdout, "error: write big file failed\n", i);
......@@ -113,7 +113,7 @@ writetest1(void)
n = 0;
for(;;){
i = read(fd, buf, 512);
u32 i = read(fd, buf, 512);
if(i == 0){
if(n == MAXFILE - 1){
printf(stdout, "read only %d blocks from big", n);
......@@ -331,7 +331,7 @@ mem(void)
if((pid = fork(0)) == 0){
m1 = 0;
while((m2 = malloc(10001)) != 0){
*(char**)m2 = m1;
*(char**)m2 = (char*) m1;
m1 = m2;
}
while(m1){
......@@ -410,7 +410,7 @@ void
twofiles(void)
{
int fd, pid, i, j, n, total;
char *fname;
const char *fname;
printf(1, "twofiles test\n");
......@@ -1450,7 +1450,7 @@ bigargtest(void)
pid = fork(0);
if(pid == 0){
char *args[32+1];
const char *args[32+1];
int i;
for(i = 0; i < 32; i++)
args[i] = "bigargs test: failed\n ";
......@@ -1467,7 +1467,7 @@ bigargtest(void)
}
void
uox(char *name, char *data)
uox(char *name, const char *data)
{
int fd = open(name, O_CREATE|O_RDWR);
if(fd < 0){
......
extern "C" {
#include "types.h"
#include "amd64.h"
#include "mmu.h"
......@@ -10,6 +11,7 @@
#include "condvar.h"
#include "proc.h"
#include "vm.h"
}
static void vmap_free(void *p);
......@@ -18,7 +20,7 @@ enum { vm_debug = 0 };
static struct vma *
vma_alloc(void)
{
struct vma *e = kmalloc(sizeof(struct vma));
struct vma *e = (struct vma *) kmalloc(sizeof(struct vma));
if (e == 0)
return 0;
memset(e, 0, sizeof(struct vma));
......@@ -103,7 +105,7 @@ vmap_decref(struct vmap *m)
struct vmap *
vmap_alloc(void)
{
struct vmap *m = kmalloc(sizeof(struct vmap));
struct vmap *m = (struct vmap *) kmalloc(sizeof(struct vmap));
if (m == 0)
return 0;
memset(m, 0, sizeof(struct vmap));
......@@ -117,7 +119,7 @@ vmap_alloc(void)
kmfree(m);
return 0;
}
m->kshared = ksalloc(slab_kshared);
m->kshared = (char*)ksalloc(slab_kshared);
if (m->kshared == NULL || setupkshared(m->pml4, m->kshared)) {
cprintf("vmap_alloc: kshared out of memory\n");
freevm(m->pml4);
......@@ -138,7 +140,7 @@ vmn_doload(struct vmnode *vmn, struct inode *ip, u64 offset, u64 sz)
{
for(u64 i = 0; i < sz; i += PGSIZE){
char *p = vmn->page[i / PGSIZE];
u64 n;
s64 n;
if(sz - i < PGSIZE)
n = sz - i;
else
......@@ -303,7 +305,7 @@ copyout(struct vmap *vmap, uptr va, void *p, u64 len)
struct vmnode *
vmn_alloc(u64 npg, enum vmntype type)
{
struct vmnode *n = kmalloc(sizeof(struct vmnode));
struct vmnode *n = (struct vmnode *) kmalloc(sizeof(struct vmnode));
if (n == 0) {
cprintf("out of vmnodes");
return 0;
......@@ -435,17 +437,15 @@ vmap_copy(struct vmap *m, int share)
return 0;
acquire(&m->lock);
struct state *st = kmalloc(sizeof(struct state));
st->share = share;
st->pml4 = m->pml4;
st->cr = c->cr;
if (!crange_foreach(m->cr, vmap_copy_vma, st)) {
struct state st;
st.share = share;
st.pml4 = m->pml4;
st.cr = c->cr;
if (!crange_foreach(m->cr, vmap_copy_vma, &st)) {
vmap_free(c);
release(&m->lock);
kmfree(st);
return 0;
}
kmfree(st);
if (share)
lcr3(v2p(m->pml4)); // Reload hardware page table
......@@ -552,7 +552,7 @@ vmap_copy(struct vmap *m, int share)
return 0;
acquire(&m->lock);
for(int i = 0; i < NELEM(m->e); i++) {
for(u32 i = 0; i < NELEM(m->e); i++) {
if(m->e[i] == 0)
continue;
c->e[i] = vma_alloc();
......@@ -594,7 +594,7 @@ vmap_remove(struct vmap *m, uptr va_start, u64 len)
{
acquire(&m->lock);
uptr va_end = va_start + len;
for(int i = 0; i < NELEM(m->e); i++) {
for(u32 i = 0; i < NELEM(m->e); i++) {
if(m->e[i] && (m->e[i]->va_start < va_end && m->e[i]->va_end > va_start)) {
if(m->e[i]->va_start != va_start || m->e[i]->va_end != va_end) {
release(&m->lock);
......
......@@ -13,7 +13,6 @@ struct vma {
};
// A memory object (physical pages or inode).
enum vmntype { EAGER, ONDEMAND};
struct vmnode {
u64 npages;
char *page[128];
......
extern "C" {
#include "types.h"
#include "kernel.h"
#include "spinlock.h"
#include "amd64.h"
#include "cpu.h"
#include "wq.h"
}
#define NSLOTS (1 << WQSHIFT)
......@@ -84,7 +86,7 @@ wq_push1(void (*fn)(struct work *w, void *a0), void *a0)
struct work *w = allocwork();
if (w == NULL)
return -1;
w->rip = fn;
w->rip = (void*) fn;
w->arg0 = a0;
if (wq_push(w) < 0) {
freework(w);
......@@ -99,7 +101,7 @@ wq_push2(void (*fn)(struct work*, void*, void*), void *a0, void *a1)
struct work *w = allocwork();
if (w == NULL)
return -1;
w->rip = fn;
w->rip = (void*) fn;
w->arg0 = a0;
w->arg1 = a1;
if (wq_push(w) < 0) {
......@@ -121,7 +123,7 @@ __wq_pop(int c)
i = wq->head;
if ((i - wq->tail) == 0) {
release(&wq->lock);
return NULL;
return 0;
}
i = (i-1) & (NSLOTS-1);
w = wq->w[i];
......@@ -144,7 +146,7 @@ __wq_steal(int c)
i = wq->tail;
if ((i - wq->head) == 0) {
release(&wq->lock);
return NULL;
return 0;
}
i = i & (NSLOTS-1);
w = wq->w[i];
......@@ -158,7 +160,7 @@ __wq_steal(int c)
static void
__wq_run(struct work *w)
{
void (*fn)(struct work*, void*, void*, void*, void*) = w->rip;
void (*fn)(struct work*, void*, void*, void*, void*) = (void(*)(work*,void*,void*,void*,void*))w->rip;
fn(w, w->arg0, w->arg1, w->arg2, w->arg3);
freework(w);
}
......@@ -207,7 +209,7 @@ __test_stub(struct work *w, void *a0, void *a1)
{
//long i = (long)a0;
//cprintf("%u: %lu\n", cpunum(), i);
volatile int *running = a1;
volatile int *running = (volatile int*) a1;
subfetch(running, 1);
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论