summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefrag.am5
-rw-r--r--device/device_init.c4
-rw-r--r--device/ds_routines.c2
-rw-r--r--doc/mach.texi29
-rw-r--r--i386/Makefrag.am9
-rw-r--r--i386/configfrag.ac16
-rw-r--r--i386/i386/db_interface.h16
-rw-r--r--i386/i386/locore.S57
-rw-r--r--i386/i386/xen.h6
-rw-r--r--i386/i386at/com.c23
-rw-r--r--i386/i386at/conf.c2
-rw-r--r--i386/i386at/cons_conf.c4
-rw-r--r--i386/i386at/immc.c2
-rw-r--r--i386/i386at/interrupt.S19
-rw-r--r--i386/i386at/kd.c121
-rw-r--r--i386/i386at/kd.h2
-rw-r--r--i386/i386at/kd_event.c3
-rw-r--r--i386/i386at/model_dep.c86
-rw-r--r--i386/i386at/pic_isa.c4
-rw-r--r--i386/intel/pmap.c11
-rw-r--r--i386/xen/xen_boothdr.S13
-rw-r--r--include/mach/mach_traps.h20
-rw-r--r--include/mach/message.h32
-rw-r--r--include/string.h4
-rw-r--r--ipc/ipc_entry.c1
-rw-r--r--ipc/ipc_init.c2
-rw-r--r--ipc/mach_port.c22
-rw-r--r--kern/kalloc.c2
-rw-r--r--kern/printf.h9
-rw-r--r--kern/startup.c24
-rw-r--r--linux/dev/arch/i386/kernel/irq.c4
-rw-r--r--linux/dev/include/linux/skbuff.h10
-rw-r--r--linux/src/drivers/block/triton.c8
-rw-r--r--linux/src/drivers/scsi/ultrastor.c2
-rw-r--r--linux/src/include/linux/skbuff.h8
-rw-r--r--vm/vm_kern.c9
-rw-r--r--vm/vm_map.c15
-rw-r--r--vm/vm_resident.c2
-rw-r--r--xen/block.c52
-rw-r--r--xen/net.c70
-rw-r--r--xen/xen.c12
-rw-r--r--xen/xen.h3
42 files changed, 458 insertions, 287 deletions
diff --git a/Makefrag.am b/Makefrag.am
index 176d4459..cc5a01ea 100644
--- a/Makefrag.am
+++ b/Makefrag.am
@@ -28,14 +28,18 @@ libkernel_a_SOURCES += \
ddb/db_command.c \
ddb/db_command.h \
ddb/db_cond.c \
+ ddb/db_cond.h \
ddb/db_examine.c \
+ ddb/db_examine.h \
ddb/db_expr.c \
ddb/db_expr.h \
ddb/db_ext_symtab.c \
ddb/db_input.c \
+ ddb/db_input.h \
ddb/db_lex.c \
ddb/db_lex.h \
ddb/db_macro.c \
+ ddb/db_macro.h \
ddb/db_mp.c \
ddb/db_output.c \
ddb/db_output.h \
@@ -48,6 +52,7 @@ libkernel_a_SOURCES += \
ddb/db_task_thread.c \
ddb/db_task_thread.h \
ddb/db_trap.c \
+ ddb/db_trap.h \
ddb/db_variables.c \
ddb/db_variables.h \
ddb/db_watch.c \
diff --git a/device/device_init.c b/device/device_init.c
index 1da2a6fe..e43a2a95 100644
--- a/device/device_init.c
+++ b/device/device_init.c
@@ -33,6 +33,7 @@
#include <ipc/ipc_space.h>
#include <kern/debug.h>
#include <kern/task.h>
+#include <xen/xen.h>
#include <device/device_types.h>
#include <device/device_port.h>
@@ -57,6 +58,9 @@ device_service_create()
panic("can't allocate master device port");
mach_device_init();
+#ifdef MACH_HYP
+ hyp_dev_init();
+#endif
dev_lookup_init();
net_io_init();
device_pager_init();
diff --git a/device/ds_routines.c b/device/ds_routines.c
index d0f0879d..93569f28 100644
--- a/device/ds_routines.c
+++ b/device/ds_routines.c
@@ -1537,7 +1537,7 @@ void io_done_thread()
/*NOTREACHED*/
}
-#define DEVICE_IO_MAP_SIZE (2 * 1024 * 1024)
+#define DEVICE_IO_MAP_SIZE (16 * 1024 * 1024)
static void mach_device_trap_init(void); /* forward */
diff --git a/doc/mach.texi b/doc/mach.texi
index 858880ad..e93fdb8b 100644
--- a/doc/mach.texi
+++ b/doc/mach.texi
@@ -6493,7 +6493,7 @@ device port or the device is dead or not completely open.
@deftypefun kern_return_t device_set_filter (@w{device_t @var{device}}, @w{mach_port_t @var{receive_port}}, @w{mach_msg_type_name_t @var{receive_port_type}}, @w{int @var{priority}}, @w{filter_array_t @var{filter}}, @w{mach_msg_type_number_t @var{filter_count}})
The function @code{device_set_filter} makes it possible to filter out
-selected data arriving at the device and forward it to a port.
+selected data arriving at or leaving the device and forward it to a port.
@var{filter} is a list of filter commands, which are applied to incoming
data to determine if the data should be sent to @var{receive_port}. The
IPC type of the send right is specified by @var{receive_port_right}, it
@@ -6507,6 +6507,33 @@ purpose of the filter test, an internal stack is provided. After all
commands have been processed, the value on the top of the stack
determines if the data is forwarded or the next filter is tried.
+The first command is a header which contains two fields: one for flags
+and the other for the type of interpreter used to run the rest of the
+commands.
+
+Any combination of the following flags is allowed but at least one of them
+must be specified.
+
+@table @code
+@item NETF_IN
+The filter will be applied to data received by the device.
+
+@item NETF_OUT
+The filter will be applied to data transmitted by the device.
+@end table
+
+Unless the type is given explicitly the native NETF interpreter will be used.
+To select an alternative implementation use one of the following types:
+
+@table @code
+@item NETF_BPF
+Use Berkeley Packet Filter.
+@end table
+
+For the listener to know what kind of packet is being received, when the
+filter code accepts a packet the message sent to @var{receive_port} is
+tagged with either NETF_IN or NETF_OUT.
+
@c XXX The following description was taken verbatim from the
@c kernel_interface.pdf document.
Each word of the command list specifies a data (push) operation (high
diff --git a/i386/Makefrag.am b/i386/Makefrag.am
index 755b4be2..db58c9c6 100644
--- a/i386/Makefrag.am
+++ b/i386/Makefrag.am
@@ -23,10 +23,6 @@ libkernel_a_SOURCES += \
i386/i386at/conf.c \
i386/i386at/cons_conf.c \
i386/i386at/idt.h \
- i386/i386at/kd_event.c \
- i386/i386at/kd_event.h \
- i386/i386at/kd_queue.c \
- i386/i386at/kd_queue.h \
i386/i386at/model_dep.c \
i386/include/mach/sa/stdarg.h
@@ -45,6 +41,10 @@ libkernel_a_SOURCES += \
i386/i386at/interrupt.S \
i386/i386at/kd.c \
i386/i386at/kd.h \
+ i386/i386at/kd_event.c \
+ i386/i386at/kd_event.h \
+ i386/i386at/kd_queue.c \
+ i386/i386at/kd_queue.h \
i386/i386at/kd_mouse.c \
i386/i386at/kd_mouse.h \
i386/i386at/kdasm.S \
@@ -78,6 +78,7 @@ libkernel_a_SOURCES += \
i386/i386/cswitch.S \
i386/i386/db_disasm.c \
i386/i386/db_interface.c \
+ i386/i386/db_interface.h \
i386/i386/db_machdep.h \
i386/i386/db_trace.c \
i386/i386/debug.h \
diff --git a/i386/configfrag.ac b/i386/configfrag.ac
index 1132b695..e4ce97ef 100644
--- a/i386/configfrag.ac
+++ b/i386/configfrag.ac
@@ -66,22 +66,6 @@ AC_DEFINE_UNQUOTED([NCOM], [$ncom], [NCOM])
# i386/bogus/lpr.h
AC_DEFINE_UNQUOTED([NLPR], [$nlpr], [NLPR])
-
-# i386/bogus/rc.h
-#
-# This controls whether or not we use a serial line for the console
-# (ie, remote console).
-#
-#
-# Values for RCLINE:
-# -1 = disable
-# 0 = port 0x3f8/irq 4 (DOS COM1)
-# 1 = port 0x2f8/irq 3 (DOS COM2)
-# 2 = port 0x3e8/irq 5 (DOS COM3)
-# 3 = port 0x2e8/irq 9 (DOS COM4)
-#
-AC_DEFINE([RCLINE], [-1], [com port for the remote console])
-AC_DEFINE([RCADDR], [0x3f8], [where is the com port for the remote console])
#
# Options.
diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h
index 8cd16909..a81c8eec 100644
--- a/i386/i386/db_interface.h
+++ b/i386/i386/db_interface.h
@@ -55,4 +55,20 @@ extern boolean_t db_phys_eq (
extern void db_task_name (task_t task);
+#define I386_DB_TYPE_X 0
+#define I386_DB_TYPE_W 1
+#define I386_DB_TYPE_RW 3
+
+#define I386_DB_LEN_1 0
+#define I386_DB_LEN_2 1
+#define I386_DB_LEN_4 3
+
+#define I386_DB_LOCAL 1
+#define I386_DB_GLOBAL 2
+
+extern unsigned long dr0 (vm_offset_t linear_addr, int type, int len, int persistence);
+extern unsigned long dr1 (vm_offset_t linear_addr, int type, int len, int persistence);
+extern unsigned long dr2 (vm_offset_t linear_addr, int type, int len, int persistence);
+extern unsigned long dr3 (vm_offset_t linear_addr, int type, int len, int persistence);
+
#endif /* _I386_DB_INTERFACE_H_ */
diff --git a/i386/i386/locore.S b/i386/i386/locore.S
index 847aa985..11214e25 100644
--- a/i386/i386/locore.S
+++ b/i386/i386/locore.S
@@ -609,6 +609,7 @@ ENTRY(call_continuation)
addl $(-3-IKS_SIZE),%ecx
movl %ecx,%esp /* pop the stack */
xorl %ebp,%ebp /* zero frame pointer */
+ pushl $0 /* Dummy return address */
jmp *%eax /* goto continuation */
@@ -715,6 +716,8 @@ LEXT(return_to_iret) /* ( label for kdb_kintr and hardclock) */
iret /* return to caller */
int_from_intstack:
+ cmpl $EXT(_intstack),%esp /* seemingly looping? */
+ jb stack_overflowed /* if not: */
call EXT(interrupt) /* call interrupt routine */
_return_to_iret_i: /* ( label for kdb_kintr) */
pop %edx /* must have been on kernel segs */
@@ -722,6 +725,9 @@ _return_to_iret_i: /* ( label for kdb_kintr) */
pop %eax /* no ASTs */
iret
+stack_overflowed:
+ ud2
+
/*
* Take an AST from an interrupt.
* On PCB stack.
@@ -816,7 +822,7 @@ ast_from_interrupt:
#ifdef MACH_XEN
#define RET_OFFSET 8
#else /* MACH_XEN */
-#define RET_OFFSET 16
+#define RET_OFFSET 20
#endif /* MACH_XEN */
ENTRY(kdb_kintr)
@@ -1430,7 +1436,14 @@ _inst_fetch_fault:
ENTRY(dr6)
+#ifdef MACH_XEN
+ pushl %ebx
+ movl $6, %ebx
+ call __hyp_get_debugreg
+ popl %ebx
+#else /* MACH_XEN */
movl %db6, %eax
+#endif /* MACH_XEN */
ret
/* dr<i>(address, type, len, persistence)
@@ -1438,33 +1451,67 @@ ENTRY(dr6)
ENTRY(dr0)
movl S_ARG0, %eax
movl %eax,EXT(dr_addr)
+#ifdef MACH_XEN
+ pushl %ebx
+ movl $0,%ebx
+ movl %eax,%ecx
+ call __hyp_set_debugreg
+#else /* MACH_XEN */
movl %eax, %db0
+#endif /* MACH_XEN */
movl $0, %ecx
jmp 0f
ENTRY(dr1)
movl S_ARG0, %eax
movl %eax,EXT(dr_addr)+1*4
+#ifdef MACH_XEN
+ pushl %ebx
+ movl $1,%ebx
+ movl %eax,%ecx
+ call __hyp_set_debugreg
+#else /* MACH_XEN */
movl %eax, %db1
+#endif /* MACH_XEN */
movl $2, %ecx
jmp 0f
ENTRY(dr2)
movl S_ARG0, %eax
movl %eax,EXT(dr_addr)+2*4
+#ifdef MACH_XEN
+ pushl %ebx
+ movl $2,%ebx
+ movl %eax,%ecx
+ call __hyp_set_debugreg
+#else /* MACH_XEN */
movl %eax, %db2
+#endif /* MACH_XEN */
movl $4, %ecx
jmp 0f
ENTRY(dr3)
movl S_ARG0, %eax
movl %eax,EXT(dr_addr)+3*4
+#ifdef MACH_XEN
+ pushl %ebx
+ movl $3,%ebx
+ movl %eax,%ecx
+ call __hyp_set_debugreg
+#else /* MACH_XEN */
movl %eax, %db3
+#endif /* MACH_XEN */
movl $6, %ecx
0:
pushl %ebp
movl %esp, %ebp
+#ifdef MACH_XEN
+ movl $7,%ebx
+ call __hyp_get_debugreg
+ movl %eax, %edx
+#else /* MACH_XEN */
movl %db7, %edx
+#endif /* MACH_XEN */
movl %edx,EXT(dr_addr)+4*4
andl dr_msk(,%ecx,2),%edx /* clear out new entry */
movl %edx,EXT(dr_addr)+5*4
@@ -1475,6 +1522,7 @@ ENTRY(dr3)
movzbl B_ARG1, %eax
andb $3, %al
+ addb %cl, %cl
addb $0x10, %cl
shll %cl, %eax
orl %eax, %edx
@@ -1485,7 +1533,14 @@ ENTRY(dr3)
shll %cl, %eax
orl %eax, %edx
+#ifdef MACH_XEN
+ movl $7,%ebx
+ movl %edx, %ecx
+ call __hyp_set_debugreg
+ popl %ebx
+#else /* MACH_XEN */
movl %edx, %db7
+#endif /* MACH_XEN */
movl %edx,EXT(dr_addr)+7*4
movl %edx, %eax
leave
diff --git a/i386/i386/xen.h b/i386/i386/xen.h
index 1377a14c..731e5a2f 100644
--- a/i386/i386/xen.h
+++ b/i386/i386/xen.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2006, 2009, 2010, 2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -263,7 +263,6 @@ MACH_INLINE void hyp_set_ldt(void *ldt, unsigned long nbentries) {
if (!count)
panic("couldn't set LDT\n");
}
-/* TODO: use xen_pfn_to_cr3/xen_cr3_to_pfn to cope with pdp above 4GB */
#define hyp_set_cr3(value) hyp_mmuext_op_mfn(MMUEXT_NEW_BASEPTR, pa_to_mfn(value))
MACH_INLINE void hyp_invlpg(vm_offset_t lin) {
struct mmuext_op ops;
@@ -346,6 +345,9 @@ MACH_INLINE void __attribute__((noreturn)) hyp_reboot(void)
for(;;);
}
+_hypcall2(int, set_debugreg, int, reg, unsigned long, value);
+_hypcall1(unsigned long, get_debugreg, int, reg);
+
/* x86-specific */
MACH_INLINE unsigned64_t hyp_cpu_clock(void) {
unsigned64_t tsc;
diff --git a/i386/i386at/com.c b/i386/i386at/com.c
index 2099a285..325e0991 100644
--- a/i386/i386at/com.c
+++ b/i386/i386at/com.c
@@ -26,6 +26,9 @@
#if NCOM > 0
+#include <string.h>
+#include <util/atoi.h>
+
#include <mach/std_types.h>
#include <sys/types.h>
#include <kern/printf.h>
@@ -64,14 +67,16 @@ boolean_t comfifo[NCOM];
boolean_t comtimer_active;
int comtimer_state[NCOM];
-#if RCLINE >= 0
#define RCBAUD B9600
+static int rcline = -1;
static struct bus_device *comcndev;
int comcnprobe(struct consdev *cp);
int comcninit(struct consdev *cp);
int comcngetc(dev_t dev, int wait);
int comcnputc(dev_t dev, int c);
-#endif
+
+/* XX */
+extern char *kernel_cmdline;
#ifndef PORTSELECTOR
#define ISPEED B9600
@@ -177,7 +182,6 @@ comprobe(int port, struct bus_device *dev)
return comprobe_general(dev, /*noisy*/ 0);
}
-#if RCLINE >= 0
/*
* Probe routine for use by the console
*/
@@ -187,13 +191,19 @@ comcnprobe(struct consdev *cp)
struct bus_device *b;
int maj, unit, pri;
+#define CONSOLE_PARAMETER " console=com"
+ u_char *console = (u_char *) strstr(kernel_cmdline, CONSOLE_PARAMETER);
+
+ if (console)
+ mach_atoi(console + strlen(CONSOLE_PARAMETER), &rcline);
+
maj = 0;
unit = -1;
pri = CN_DEAD;
for (b = bus_device_init; b->driver; b++)
if (strcmp(b->name, "com") == 0
- && b->unit == RCLINE
+ && b->unit == rcline
&& comprobe_general(b, /*quiet*/ 0))
{
/* Found one */
@@ -206,7 +216,6 @@ comcnprobe(struct consdev *cp)
cp->cn_dev = makedev(maj, unit);
cp->cn_pri = pri;
}
-#endif
/*
@@ -237,7 +246,6 @@ comattach(struct bus_device *dev)
}
}
-#if RCLINE >= 0
/*
* Attach/init routine for console. This isn't called by
* configure_bus_device which sets the alive, adaptor, and minfo
@@ -280,7 +288,6 @@ comcninit(struct consdev *cp)
}
}
-#endif
/*
* Probe for COM<dev> after autoconfiguration.
@@ -861,7 +868,6 @@ comgetc(int unit)
return c;
}
-#if RCLINE >= 0 || MACH_GDB_STUB
/*
* Routines for the console
*/
@@ -893,6 +899,5 @@ comcngetc(dev_t dev, int wait)
c = inb(TXRX(addr));
return c & 0x7f;
}
-#endif /* RCLINE */
#endif /* NCOM */
diff --git a/i386/i386at/conf.c b/i386/i386at/conf.c
index d51b5ee2..83c8dbfc 100644
--- a/i386/i386at/conf.c
+++ b/i386/i386at/conf.c
@@ -123,14 +123,12 @@ struct dev_ops dev_name_list[] =
nodev, mousegetstat, nulldev, nomap,
nodev, nulldev, nulldev, 0,
nodev },
-#endif /* MACH_HYP */
{ kbdname, kbdopen, kbdclose, kbdread,
nodev, kbdgetstat, kbdsetstat, nomap,
nodev, nulldev, nulldev, 0,
nodev },
-#ifndef MACH_HYP
{ memname, nulldev, nulldev, nodev,
nodev, nodev, nodev, memmmap,
nodev, nulldev, nulldev, 0,
diff --git a/i386/i386at/cons_conf.c b/i386/i386at/cons_conf.c
index ea8ccb56..8a4b37c5 100644
--- a/i386/i386at/cons_conf.c
+++ b/i386/i386at/cons_conf.c
@@ -34,7 +34,7 @@
extern int hypcnprobe(), hypcninit(), hypcngetc(), hypcnputc();
#else /* MACH_HYP */
extern int kdcnprobe(), kdcninit(), kdcngetc(), kdcnputc();
-#if NCOM > 0 && RCLINE >= 0
+#if NCOM > 0
extern int comcnprobe(), comcninit(), comcngetc(), comcnputc();
#endif
#endif /* MACH_HYP */
@@ -48,7 +48,7 @@ struct consdev constab[] = {
{"hyp", hypcnprobe, hypcninit, hypcngetc, hypcnputc},
#else /* MACH_HYP */
{"kd", kdcnprobe, kdcninit, kdcngetc, kdcnputc},
-#if NCOM > 0 && RCLINE >= 0 && 1
+#if NCOM > 0
{"com", comcnprobe, comcninit, comcngetc, comcnputc},
#endif
#endif /* MACH_HYP */
diff --git a/i386/i386at/immc.c b/i386/i386at/immc.c
index e4571621..db64620e 100644
--- a/i386/i386at/immc.c
+++ b/i386/i386at/immc.c
@@ -49,7 +49,7 @@ immc_cnputc(unsigned char c)
}
else if (c == '\n')
{
- memcpy(0xb8000, 0xb8000+80*2, 80*2*24);
+ memmove(0xb8000, 0xb8000+80*2, 80*2*24);
memset(0xb8000+80*2*24, 0, 80*2);
ofs = 0;
}
diff --git a/i386/i386at/interrupt.S b/i386/i386at/interrupt.S
index 4916903f..e238ea44 100644
--- a/i386/i386at/interrupt.S
+++ b/i386/i386at/interrupt.S
@@ -27,13 +27,8 @@
* On entry, %eax contains the irq number.
*/
ENTRY(interrupt)
- movl %eax,%ecx /* save irq number */
- movb $(NON_SPEC_EOI),%al /* non-specific EOI */
- outb %al,$(PIC_MASTER_ICW) /* ack interrupt to master */
- cmpl $8,%ecx /* do we need to ack slave? */
- jl 1f /* no, skip it */
- outb %al,$(PIC_SLAVE_ICW)
-1:
+ pushl %eax /* save irq number */
+ movl %eax,%ecx /* copy irq number */
shll $2,%ecx /* irq * 4 */
movl EXT(intpri)(%ecx),%edx /* get new ipl */
call spl /* set ipl */
@@ -43,6 +38,14 @@ ENTRY(interrupt)
call *EXT(ivect)(%ecx) /* call interrupt handler */
addl $4,%esp /* pop unit number */
call splx_cli /* restore previous ipl */
- cli /* XXX no more nested interrupts */
addl $4,%esp /* pop previous ipl */
+ cli /* XXX no more nested interrupts */
+ popl %eax /* restore irq number */
+ movl %eax,%ecx /* copy irq number */
+ movb $(NON_SPEC_EOI),%al /* non-specific EOI */
+ outb %al,$(PIC_MASTER_ICW) /* ack interrupt to master */
+ cmpl $8,%ecx /* do we need to ack slave? */
+ jl 1f /* no, skip it */
+ outb %al,$(PIC_SLAVE_ICW)
+1:
ret /* return */
diff --git a/i386/i386at/kd.c b/i386/i386at/kd.c
index ad155953..e4ac8325 100644
--- a/i386/i386at/kd.c
+++ b/i386/i386at/kd.c
@@ -225,63 +225,63 @@ u_char *esc_spt = (u_char *)0;
unsigned char key_map[NUMKEYS][WIDTH_KMAP] = {
{NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC},
{K_ESC,NC,NC, K_ESC,NC,NC, K_ESC,NC,NC, 0x1b,K_ESC,NC, K_ESC,NC,NC},
-{K_ONE,NC,NC, K_BANG,NC,NC, K_ONE,NC,NC, 0x1b,0x31,NC, 0x1b,0x4e,0x21},
-{K_TWO,NC,NC, K_ATSN,NC,NC, K_NUL,NC,NC, 0x1b,0x32,NC, 0x1b,0x4e,0x40},
-{K_THREE,NC,NC, K_POUND,NC,NC, K_THREE,NC,NC, 0x1b,0x33,NC, 0x1b,0x4e,0x23},
-{K_FOUR,NC,NC, K_DOLLAR,NC,NC, K_FOUR,NC,NC, 0x1b,0x34,NC, 0x1b,0x4e,0x24},
-{K_FIVE,NC,NC, K_PERC,NC,NC, K_FIVE,NC,NC, 0x1b,0x35,NC, 0x1b,0x4e,0x25},
-{K_SIX,NC,NC, K_CARET,NC,NC, K_RS,NC,NC, 0x1b,0x36,NC, 0x1b,0x4e,0x5e},
-{K_SEVEN,NC,NC, K_AMPER,NC,NC, K_SEVEN,NC,NC, 0x1b,0x37,NC, 0x1b,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,0x1b,K_PERIOD,NC, 0x1b,0x4e,K_GTHN},
+{K_SLASH,NC,NC, K_QUES,NC,NC, K_SLASH,NC,NC, 0x1b,K_SLASH,NC, 0x1b,0x4e,K_QUES},
{K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC,
K_SCAN,K_RSHSC,NC},
-{K_ASTER,NC,NC, K_ASTER,NC,NC, K_ASTER,NC,NC, 0x1b,0x4e,0x2a,0x1b,0x4e,0x2a},
+{K_ASTER,NC,NC, K_ASTER,NC,NC, K_ASTER,NC,NC, 0x1b,K_ASTER,NC, 0x1b,0x4e,K_ASTER},
{K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC,
K_SCAN,K_ALTSC,NC},
{K_SPACE,NC,NC, K_SPACE,NC,NC, K_NUL,NC,NC, 0x1b,K_SPACE,NC, K_SPACE,NC,NC},
@@ -300,22 +300,22 @@ unsigned char key_map[NUMKEYS][WIDTH_KMAP] = {
{K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC,
K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC},
{K_SCRL, K_NUL,NC,NC, K_SCRL, K_SCRL, K_NUL,NC,NC},
-{K_HOME, K_SEVEN,NC,NC, K_HOME, K_HOME, 0x1b,0x4e,0x37},
-{K_UA, K_EIGHT,NC,NC, K_UA, K_UA, 0x1b,0x4e,0x38},
-{K_PUP, K_NINE,NC,NC, K_PUP, K_PUP, 0x1b,0x4e,0x39},
+{K_HOME, K_SEVEN,NC,NC, K_HOME, K_HOME, 0x1b,0x4e,K_SEVEN},
+{K_UA, K_EIGHT,NC,NC, K_UA, K_UA, 0x1b,0x4e,K_EIGHT},
+{K_PUP, K_NINE,NC,NC, K_PUP, K_PUP, 0x1b,0x4e,K_NINE},
{0x1b,0x5b,0x53, K_MINUS,NC,NC, 0x1b,0x5b,0x53, 0x1b,0x5b,0x53,
0x1b,0x4e,0x2d},
-{K_LA, K_FOUR,NC,NC, K_LA, K_LA, 0x1b,0x4e,0x34},
+{K_LA, K_FOUR,NC,NC, K_LA, K_LA, 0x1b,0x4e,K_FOUR},
{0x1b,0x5b,0x47, K_FIVE,NC,NC, 0x1b,0x5b,0x47, 0x1b,0x5b,0x47,
0x1b,0x4e,0x35},
-{K_RA, K_SIX,NC,NC, K_RA, K_RA, 0x1b,0x4e,0x36},
+{K_RA, K_SIX,NC,NC, K_RA, K_RA, 0x1b,0x4e,K_SIX},
{0x1b,0x5b,0x54, K_PLUS,NC,NC, 0x1b,0x5b,0x54, 0x1b,0x5b,0x54,
0x1b,0x4e,0x2b},
-{K_END, K_ONE,NC,NC, K_END, K_END, 0x1b,0x4e,0x31},
-{K_DA, K_TWO,NC,NC, K_DA, K_DA, 0x1b,0x4e,0x32},
-{K_PDN, K_THREE,NC,NC, K_PDN, K_PDN, 0x1b,0x4e,0x33},
-{K_INS, K_ZERO,NC,NC, K_INS, K_INS, 0x1b,0x4e,0x30},
-{0x1b,0x5b,0x39, K_PERIOD,NC,NC, K_DEL,NC,NC, K_DEL,NC,NC, 0x1b,0x4e,0x2e},
+{K_END, K_ONE,NC,NC, K_END, K_END, 0x1b,0x4e,K_ONE},
+{K_DA, K_TWO,NC,NC, K_DA, K_DA, 0x1b,0x4e,K_TWO},
+{K_PDN, K_THREE,NC,NC, K_PDN, K_PDN, 0x1b,0x4e,K_THREE},
+{K_INS, K_ZERO,NC,NC, K_INS, K_INS, 0x1b,0x4e,K_ZERO},
+{0x1b,0x5b,0x39, K_PERIOD,NC,NC, K_DEL,NC,NC, K_DEL,NC,NC, 0x1b,0x4e,K_PERIOD},
{NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC},
{NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC},
{NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC},
@@ -748,6 +748,9 @@ int regs;
if (kd_pollc)
return; /* kdb polling kbd */
+ if (!kd_initialized)
+ return;
+
tp = &kd_tty;
#ifdef old
while ((inb(K_STATUS) & K_OBUF_FUL) == 0); /* this should never loop */
@@ -2360,7 +2363,9 @@ kd_setleds1(val)
u_char val;
{
if (kd_ack != NOT_WAITING) {
+#ifdef MACH_KBD
printf("kd_setleds1: unexpected state (%d)\n", kd_ack);
+#endif
return;
}
diff --git a/i386/i386at/kd.h b/i386/i386at/kd.h
index 9048ce50..98c8bfee 100644
--- a/i386/i386at/kd.h
+++ b/i386/i386at/kd.h
@@ -238,7 +238,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define CURRENT_COLUMN(pos) (((pos) % ONE_LINE) / ONE_SPACE)
#define NUMKEYS 89
-#define NUMSTATES 5 /* NORMAL_STATE, ... */
+#define NUMSTATES 5 /* NORM_STATE, ... */
#define NUMOUTPUT 3 /* max size of byte seq from key */
#define WIDTH_KMAP (NUMSTATES * NUMOUTPUT)
diff --git a/i386/i386at/kd_event.c b/i386/i386at/kd_event.c
index 5d8d5637..3983a118 100644
--- a/i386/i386at/kd_event.c
+++ b/i386/i386at/kd_event.c
@@ -142,6 +142,9 @@ kbdopen(dev, flags)
dev_t dev;
int flags;
{
+ spl_t o_pri = spltty();
+ kdinit();
+ splx(o_pri);
kbdinit();
#ifdef MACH_KERNEL
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index ca000786..04b8228f 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -128,14 +128,12 @@ extern void setup_main();
void halt_all_cpus (boolean_t reboot) __attribute__ ((noreturn));
void halt_cpu (void) __attribute__ ((noreturn));
+int discover_x86_cpu_type (void);
+
void inittodr(); /* forward */
int rebootflag = 0; /* exported to kdintr */
-#if ! MACH_KBD
-boolean_t reboot_on_panic = 1;
-#endif
-
/* XX interrupt stack pointer and highwater mark, for locore.S. */
vm_offset_t int_stack_top, int_stack_high;
@@ -319,6 +317,8 @@ i386at_init(void)
{
/* XXX move to intel/pmap.h */
extern pt_entry_t *kernel_page_dir;
+ int nb_direct, i;
+ vm_offset_t addr;
/*
* Initialize the PIC prior to any possible call to an spl.
@@ -340,7 +340,6 @@ i386at_init(void)
/* Copy content pointed by boot_info before losing access to it when it
* is too far in physical memory. */
if (boot_info.flags & MULTIBOOT_CMDLINE) {
- vm_offset_t addr;
int len = strlen ((char*)phystokv(boot_info.cmdline)) + 1;
assert(init_alloc_aligned(round_page(len), &addr));
kernel_cmdline = (char*) phystokv(addr);
@@ -350,7 +349,6 @@ i386at_init(void)
if (boot_info.flags & MULTIBOOT_MODS) {
struct multiboot_module *m;
- vm_offset_t addr;
int i;
assert(init_alloc_aligned(round_page(boot_info.mods_count * sizeof(*m)), &addr));
@@ -386,19 +384,15 @@ i386at_init(void)
* We'll have to temporarily install a direct mapping
* between physical memory and low linear memory,
* until we start using our new kernel segment descriptors.
- * One page table (4MB) should do the trick.
* Also, set the WP bit so that on 486 or better processors
* page-level write protection works in kernel mode.
*/
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS)] =
- kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS)];
-#if PAE
- /* PAE page tables are 2MB only */
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 1] =
- kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS) + 1];
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 2] =
- kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS) + 2];
-#endif /* PAE */
+ init_alloc_aligned(0, &addr);
+ nb_direct = (addr + NPTES * PAGE_SIZE - 1) / (NPTES * PAGE_SIZE);
+ for (i = 0; i < nb_direct; i++)
+ kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + i] =
+ kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS) + i];
+
#ifdef MACH_XEN
{
int i;
@@ -420,10 +414,11 @@ i386at_init(void)
set_cr3((unsigned)_kvtophys(kernel_page_dir));
#endif /* PAE */
#ifndef MACH_HYP
- if (CPU_HAS_FEATURE(CPU_FEATURE_PGE))
- set_cr4(get_cr4() | CR4_PGE);
/* already set by Hypervisor */
set_cr0(get_cr0() | CR0_PG | CR0_WP);
+ set_cr0(get_cr0() & ~(CR0_CD | CR0_NW));
+ if (CPU_HAS_FEATURE(CPU_FEATURE_PGE))
+ set_cr4(get_cr4() | CR4_PGE);
#endif /* MACH_HYP */
flush_instr_queue();
#ifdef MACH_XEN
@@ -447,35 +442,24 @@ i386at_init(void)
ktss_init();
/* Get rid of the temporary direct mapping and flush it out of the TLB. */
+ for (i = 0 ; i < nb_direct; i++) {
#ifdef MACH_XEN
#ifdef MACH_PSEUDO_PHYS
- if (!hyp_mmu_update_pte(kv_to_ma(&kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS)]), 0))
-#else /* MACH_PSEUDO_PHYS */
- if (hyp_do_update_va_mapping(VM_MIN_KERNEL_ADDRESS, 0, UVMF_INVLPG | UVMF_ALL))
-#endif /* MACH_PSEUDO_PHYS */
- printf("couldn't unmap frame 0\n");
-#if PAE
-#ifdef MACH_PSEUDO_PHYS
- if (!hyp_mmu_update_pte(kv_to_ma(&kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 1]), 0))
+ if (!hyp_mmu_update_pte(kv_to_ma(&kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + i]), 0))
#else /* MACH_PSEUDO_PHYS */
- if (hyp_do_update_va_mapping(VM_MIN_KERNEL_ADDRESS + INTEL_PGBYTES, 0, UVMF_INVLPG | UVMF_ALL))
+ if (hyp_do_update_va_mapping(VM_MIN_KERNEL_ADDRESS + i * INTEL_PGBYTES, 0, UVMF_INVLPG | UVMF_ALL))
#endif /* MACH_PSEUDO_PHYS */
- printf("couldn't unmap frame 1\n");
-#ifdef MACH_PSEUDO_PHYS
- if (!hyp_mmu_update_pte(kv_to_ma(&kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 2]), 0))
-#else /* MACH_PSEUDO_PHYS */
- if (hyp_do_update_va_mapping(VM_MIN_KERNEL_ADDRESS + 2*INTEL_PGBYTES, 0, UVMF_INVLPG | UVMF_ALL))
-#endif /* MACH_PSEUDO_PHYS */
- printf("couldn't unmap frame 2\n");
-#endif /* PAE */
- hyp_free_page(0, (void*) VM_MIN_KERNEL_ADDRESS);
+ printf("couldn't unmap frame %d\n", i);
#else /* MACH_XEN */
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS)] = 0;
-#if PAE
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 1] = 0;
- kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 2] = 0;
-#endif /* PAE */
+ kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + i] = 0;
#endif /* MACH_XEN */
+ }
+
+ /* Not used after boot, better give it back. */
+#ifdef MACH_XEN
+ hyp_free_page(0, (void*) VM_MIN_KERNEL_ADDRESS);
+#endif /* MACH_XEN */
+
flush_tlb();
#ifdef MACH_XEN
@@ -551,22 +535,6 @@ void c_boot_entry(vm_offset_t bi)
{
aout_db_sym_init(kern_sym_start, kern_sym_end, "mach", 0);
}
-
- /*
- * Cause a breakpoint trap to the debugger before proceeding
- * any further if the proper option flag was specified
- * on the kernel's command line.
- * XXX check for surrounding spaces.
- */
- if (strstr(kernel_cmdline, "-d ")) {
- cninit(); /* need console for debugger */
- SoftDebugger("init");
- }
-#else
- if (strstr (kernel_cmdline, "-H "))
- {
- reboot_on_panic = 0;
- }
#endif /* MACH_KDB */
machine_slot[0].is_cpu = TRUE;
@@ -575,8 +543,9 @@ void c_boot_entry(vm_offset_t bi)
switch (cpu_type)
{
- case 3:
default:
+ printf("warning: unknown cpu type %d, assuming i386\n", cpu_type);
+ case 3:
machine_slot[0].cpu_type = CPU_TYPE_I386;
break;
case 4:
@@ -586,6 +555,7 @@ void c_boot_entry(vm_offset_t bi)
machine_slot[0].cpu_type = CPU_TYPE_PENTIUM;
break;
case 6:
+ case 15:
machine_slot[0].cpu_type = CPU_TYPE_PENTIUMPRO;
break;
}
diff --git a/i386/i386at/pic_isa.c b/i386/i386at/pic_isa.c
index 811ee1c5..ef7d84c7 100644
--- a/i386/i386at/pic_isa.c
+++ b/i386/i386at/pic_isa.c
@@ -35,11 +35,7 @@ extern void prtnull();
void (*ivect[NINTR])() = {
/* 00 */ hardclock, /* always */
-#if RCLINE < 0
/* 01 */ kdintr, /* kdintr, ... */
-#else
- /* 01 */ intnull, /* kdintr, ... */
-#endif
/* 02 */ intnull,
/* 03 */ intnull, /* lnpoll, comintr, ... */
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index 3ee6338d..0b8ae903 100644
--- a/i386/intel/pmap.c
+++ b/i386/intel/pmap.c
@@ -156,7 +156,7 @@ vm_offset_t kernel_virtual_start;
vm_offset_t kernel_virtual_end;
/* XXX stupid fixed limit - get rid */
-vm_size_t morevm = 40 * 1024 * 1024; /* VM space for kernel map */
+vm_size_t morevm = 128 * 1024 * 1024; /* VM space for kernel map */
/*
* Index into pv_head table, its lock bits, and the modify/reference
@@ -654,6 +654,8 @@ void pmap_bootstrap()
}
#ifdef MACH_XEN
+ /* We don't actually deal with the CR3 register content at all */
+ hyp_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
/*
* Xen may only provide as few as 512KB extra bootstrap linear memory,
* which is far from enough to map all available memory, so we need to
@@ -762,11 +764,14 @@ void pmap_bootstrap()
else
{
#ifdef MACH_XEN
+ /* Keep supplementary L1 pages read-only */
int i;
for (i = 0; i < NSUP_L1; i++)
- if (va == (vm_offset_t) l1_map[i])
+ if (va == (vm_offset_t) l1_map[i]) {
WRITE_PTE(pte, pa_to_pte(_kvtophys(va))
| INTEL_PTE_VALID | global);
+ break;
+ }
if (i == NSUP_L1)
#endif /* MACH_XEN */
WRITE_PTE(pte, pa_to_pte(_kvtophys(va))
@@ -1750,8 +1755,10 @@ if (pmap_debug) printf("pmap(%x, %x)\n", v, pa);
if (pmap == PMAP_NULL)
return;
+#if !MACH_KDB
if (pmap == kernel_pmap && (v < kernel_virtual_start || v >= kernel_virtual_end))
panic("pmap_enter(%p, %p) falls in physical memory area!\n", v, pa);
+#endif
if (pmap == kernel_pmap && (prot & VM_PROT_WRITE) == 0
&& !wired /* hack for io_wire */ ) {
/*
diff --git a/i386/xen/xen_boothdr.S b/i386/xen/xen_boothdr.S
index 604e13b6..1b32efb8 100644
--- a/i386/xen/xen_boothdr.S
+++ b/i386/xen/xen_boothdr.S
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2006, 2009, 2010, 2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,9 @@
.ascii ",PAE=no"
#endif
.ascii ",LOADER=generic"
-#ifndef MACH_PSEUDO_PHYS
+#ifdef MACH_PSEUDO_PHYS
+ .ascii ",FEATURES=pae_pgdir_above_4gb"
+#else /* MACH_PSEUDO_PHYS */
.ascii ",FEATURES=!auto_translated_physmap"
#endif
.byte 0
@@ -63,8 +65,10 @@
#endif
ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, ""
-#ifndef MACH_PSEUDO_PHYS
- "!auto_translated_physmap"
+#ifdef MACH_PSEUDO_PHYS
+ "pae_pgdir_above_4gb"
+#else /* MACH_PSEUDO_PHYS */
+ "!auto_translated_physmap|"
#endif
)
@@ -120,6 +124,7 @@ hyp_shared_info:
/* Labels just for debuggers */
#define hypcall(name, n) \
.org hypcalls + n*32 ; \
+.globl __hyp_##name ; \
__hyp_##name:
hypcalls:
diff --git a/include/mach/mach_traps.h b/include/mach/mach_traps.h
index e6ea3a05..0433707a 100644
--- a/include/mach/mach_traps.h
+++ b/include/mach/mach_traps.h
@@ -36,38 +36,18 @@
#include <mach/port.h>
mach_port_t mach_reply_port
-#ifdef LINTLIBRARY
- ()
- { return MACH_PORT_NULL; }
-#else /* LINTLIBRARY */
(void);
-#endif /* LINTLIBRARY */
mach_port_t mach_thread_self
-#ifdef LINTLIBRARY
- ()
- { return MACH_PORT_NULL; }
-#else /* LINTLIBRARY */
(void);
-#endif /* LINTLIBRARY */
#ifdef __386BSD__
#undef mach_task_self
#endif
mach_port_t mach_task_self
-#ifdef LINTLIBRARY
- ()
- { return MACH_PORT_NULL; }
-#else /* LINTLIBRARY */
(void);
-#endif /* LINTLIBRARY */
mach_port_t mach_host_self
-#ifdef LINTLIBRARY
- ()
- { return MACH_PORT_NULL; }
-#else /* LINTLIBRARY */
(void);
-#endif /* LINTLIBRARY */
#endif /* _MACH_MACH_TRAPS_H_ */
diff --git a/include/mach/message.h b/include/mach/message.h
index 89c3df37..f78e9780 100644
--- a/include/mach/message.h
+++ b/include/mach/message.h
@@ -384,7 +384,6 @@ typedef kern_return_t mach_msg_return_t;
extern mach_msg_return_t
mach_msg_trap
-#if defined(c_plusplus) || defined(__STDC__)
(mach_msg_header_t *msg,
mach_msg_option_t option,
mach_msg_size_t send_size,
@@ -392,25 +391,9 @@ mach_msg_trap
mach_port_t rcv_name,
mach_msg_timeout_t timeout,
mach_port_t notify);
-#else /* c_plusplus || __STDC__ */
-#ifdef LINTLIBRARY
- (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
- mach_msg_header_t *msg;
- mach_msg_option_t option;
- mach_msg_size_t send_size;
- mach_msg_size_t rcv_size
- mach_port_t rcv_name;
- mach_msg_timeout_t timeout;
- mach_port_t notify;
-{ return MACH_RCV_SUCCESS; }
-#else /* LINTLIBRARY */
- ();
-#endif /* LINTLIBRARY */
-#endif /* c_plusplus || __STDC__ */
extern mach_msg_return_t
mach_msg
-#if defined(c_plusplus) || defined(__STDC__)
(mach_msg_header_t *msg,
mach_msg_option_t option,
mach_msg_size_t send_size,
@@ -418,21 +401,6 @@ mach_msg
mach_port_t rcv_name,
mach_msg_timeout_t timeout,
mach_port_t notify);
-#else /* c_plusplus || __STDC__ */
-#ifdef LINTLIBRARY
- (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
- mach_msg_header_t *msg;
- mach_msg_option_t option;
- mach_msg_size_t send_size;
- mach_msg_size_t rcv_size
- mach_port_t rcv_name;
- mach_msg_timeout_t timeout;
- mach_port_t notify;
-{ return MACH_RCV_SUCCESS; }
-#else /* LINTLIBRARY */
- ();
-#endif /* LINTLIBRARY */
-#endif /* c_plusplus || __STDC__ */
extern __typeof (mach_msg) __mach_msg;
extern __typeof (mach_msg_trap) __mach_msg_trap;
diff --git a/include/string.h b/include/string.h
index 34423dff..8059bedb 100644
--- a/include/string.h
+++ b/include/string.h
@@ -30,6 +30,8 @@
extern void *memcpy (void *dest, const void *src, size_t n);
+extern void *memmove (void *dest, const void *src, size_t n);
+
extern int *memcmp (const void *s1, const void *s2, size_t n);
extern void *memset (void *s, int c, size_t n);
@@ -50,4 +52,6 @@ extern int strncmp (const char *s1, const char *s2, size_t n);
extern size_t strlen (const char *s);
+extern char *strstr(const char *haystack, const char *needle);
+
#endif /* _MACH_SA_SYS_STRING_H_ */
diff --git a/ipc/ipc_entry.c b/ipc/ipc_entry.c
index 90844118..42e8dd8e 100644
--- a/ipc/ipc_entry.c
+++ b/ipc/ipc_entry.c
@@ -577,6 +577,7 @@ ipc_entry_grow_table(space)
if (osize == size) {
is_write_unlock(space);
+ printf_once("no more room for ipc_entry_grow_table in space %p\n", space);
return KERN_NO_SPACE;
}
diff --git a/ipc/ipc_init.c b/ipc/ipc_init.c
index 464e0e3e..90e6b783 100644
--- a/ipc/ipc_init.c
+++ b/ipc/ipc_init.c
@@ -53,7 +53,7 @@
vm_map_t ipc_kernel_map;
-vm_size_t ipc_kernel_map_size = 1024 * 1024;
+vm_size_t ipc_kernel_map_size = 8 * 1024 * 1024;
int ipc_space_max = SPACE_MAX;
int ipc_tree_entry_max = ITE_MAX;
diff --git a/ipc/mach_port.c b/ipc/mach_port.c
index d902e220..c5688c90 100644
--- a/ipc/mach_port.c
+++ b/ipc/mach_port.c
@@ -205,11 +205,14 @@ mach_port_names(
size = size_needed;
kr = vm_allocate(ipc_kernel_map, &addr1, size, TRUE);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
return KERN_RESOURCE_SHORTAGE;
+ }
kr = vm_allocate(ipc_kernel_map, &addr2, size, TRUE);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
kmem_free(ipc_kernel_map, addr1, size);
return KERN_RESOURCE_SHORTAGE;
}
@@ -552,6 +555,8 @@ mach_port_allocate(space, right, namep)
* KERN_INVALID_NAME The name doesn't denote a right.
*/
+static volatile int mach_port_deallocate_debug = 0;
+
kern_return_t
mach_port_destroy(
ipc_space_t space,
@@ -564,8 +569,14 @@ mach_port_destroy(
return KERN_INVALID_TASK;
kr = ipc_right_lookup_write(space, name, &entry);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
+ printf("task %p destroying an invalid port %u, most probably a bug.\n", current_task(), name);
+ if (mach_port_deallocate_debug)
+ SoftDebugger("mach_port_deallocate");
+ }
return kr;
+ }
/* space is write-locked and active */
kr = ipc_right_destroy(space, name, entry); /* unlocks space */
@@ -590,7 +601,6 @@ mach_port_destroy(
* KERN_INVALID_RIGHT The right isn't correct.
*/
-static volatile int mach_port_deallocate_debug = 0;
kern_return_t
mach_port_deallocate(
ipc_space_t space,
@@ -604,7 +614,7 @@ mach_port_deallocate(
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS) {
- if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD) {
+ if (name != MACH_PORT_NULL && name != MACH_PORT_DEAD && space == current_space()) {
printf("task %p deallocating an invalid port %u, most probably a bug.\n", current_task(), name);
if (mach_port_deallocate_debug)
SoftDebugger("mach_port_deallocate");
@@ -975,8 +985,10 @@ mach_port_get_set_status(
ipc_pset_t pset;
kr = vm_allocate(ipc_kernel_map, &addr, size, TRUE);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room in ipc_kernel_map\n");
return KERN_RESOURCE_SHORTAGE;
+ }
/* can't fault while we hold locks */
diff --git a/kern/kalloc.c b/kern/kalloc.c
index 4460d597..8256305b 100644
--- a/kern/kalloc.c
+++ b/kern/kalloc.c
@@ -48,7 +48,7 @@
vm_map_t kalloc_map;
-vm_size_t kalloc_map_size = 8 * 1024 * 1024;
+vm_size_t kalloc_map_size = 64 * 1024 * 1024;
vm_size_t kalloc_max;
/*
diff --git a/kern/printf.h b/kern/printf.h
index 13831986..c5effe5d 100644
--- a/kern/printf.h
+++ b/kern/printf.h
@@ -43,6 +43,15 @@ extern int sprintf (char *buf, const char *fmt, ...);
extern int printf (const char *fmt, ...);
+#define printf_once(fmt, ...) \
+ MACRO_BEGIN \
+ static int __once = 0; \
+ if (!__once) { \
+ printf(fmt, ##__VA_ARGS__); \
+ __once = 1; \
+ } \
+ MACRO_END
+
extern int indent;
extern void iprintf (const char *fmt, ...);
diff --git a/kern/startup.c b/kern/startup.c
index 81626dbf..75a05b0e 100644
--- a/kern/startup.c
+++ b/kern/startup.c
@@ -27,6 +27,8 @@
* Mach kernel startup.
*/
+#include <string.h>
+
#include <mach/boolean.h>
#include <mach/machine.h>
#include <mach/task_special_ports.h>
@@ -76,6 +78,10 @@ extern void device_service_create();
void cpu_launch_first_thread(); /* forward */
void start_kernel_threads(); /* forward */
+#if ! MACH_KBD
+boolean_t reboot_on_panic = 1;
+#endif
+
#if NCPUS > 1
extern void start_other_cpus();
extern void action_thread();
@@ -83,6 +89,7 @@ extern void action_thread();
/* XX */
extern vm_offset_t phys_first_addr, phys_last_addr;
+extern char *kernel_cmdline;
/*
* Running in virtual memory, on the interrupt stack.
@@ -94,6 +101,23 @@ void setup_main()
{
thread_t startup_thread;
+#if MACH_KDB
+ /*
+ * Cause a breakpoint trap to the debugger before proceeding
+ * any further if the proper option flag was specified
+ * on the kernel's command line.
+ * XXX check for surrounding spaces.
+ */
+ if (strstr(kernel_cmdline, "-d ")) {
+ cninit(); /* need console for debugger */
+ SoftDebugger("init");
+ }
+#else /* MACH_KDB */
+ if (strstr (kernel_cmdline, "-H ")) {
+ reboot_on_panic = 0;
+ }
+#endif /* MACH_KDB */
+
panic_init();
printf_init();
diff --git a/linux/dev/arch/i386/kernel/irq.c b/linux/dev/arch/i386/kernel/irq.c
index 8966dea1..7faaa62c 100644
--- a/linux/dev/arch/i386/kernel/irq.c
+++ b/linux/dev/arch/i386/kernel/irq.c
@@ -229,6 +229,10 @@ setup_x86_irq (int irq, struct linux_action *new)
if ((old->flags ^ new->flags) & SA_INTERRUPT)
return (-LINUX_EBUSY);
+ /* Can't share at different levels */
+ if (intpri[irq] && linux_intr_pri != intpri[irq])
+ return (-LINUX_EBUSY);
+
/* add new interrupt at end of irq queue */
do
{
diff --git a/linux/dev/include/linux/skbuff.h b/linux/dev/include/linux/skbuff.h
index cbaba20a..c55e5297 100644
--- a/linux/dev/include/linux/skbuff.h
+++ b/linux/dev/include/linux/skbuff.h
@@ -404,10 +404,7 @@ extern __inline__ unsigned char *skb_put(struct sk_buff *skb, int len)
skb->len+=len;
if(skb->tail>skb->end)
{
- __label__ here;
- panic("skput:over: %p:%d", &&here,len);
-here:
- ;
+ panic("skput:over: %d", len);
}
return tmp;
}
@@ -418,10 +415,7 @@ extern __inline__ unsigned char *skb_push(struct sk_buff *skb, int len)
skb->len+=len;
if(skb->data<skb->head)
{
- __label__ here;
- panic("skpush:under: %p:%d", &&here,len);
-here:
- ;
+ panic("skpush:under: %d", len);
}
return skb->data;
}
diff --git a/linux/src/drivers/block/triton.c b/linux/src/drivers/block/triton.c
index 2e3d1878..3ed069d9 100644
--- a/linux/src/drivers/block/triton.c
+++ b/linux/src/drivers/block/triton.c
@@ -129,13 +129,7 @@
const char *good_dma_drives[] = {"Micropolis 2112A",
"CONNER CTMA 4000",
"CONNER CTT8000-A",
- // Should work, but kvm/qemu seem to produce
- // issues:
- // hd1 irq timeout: status=0xd8 { Busy }
- // hd0: disabled DMA
- // hd1: disabled DMA
- // ide0: reset: success
- //"QEMU HARDDISK",
+ "QEMU HARDDISK",
NULL};
/*
diff --git a/linux/src/drivers/scsi/ultrastor.c b/linux/src/drivers/scsi/ultrastor.c
index 3d9b4118..a1a1982d 100644
--- a/linux/src/drivers/scsi/ultrastor.c
+++ b/linux/src/drivers/scsi/ultrastor.c
@@ -306,7 +306,7 @@ static inline int find_and_clear_bit_16(unsigned short *field)
cli();
if (*field == 0) panic("No free mscp");
asm("xorl %0,%0\n0:\tbsfw %1,%w0\n\tbtr %0,%1\n\tjnc 0b"
- : "=&r" (rv), "=m" (*field) : "1" (*field));
+ : "=&r" (rv), "+m" (*field));
restore_flags(flags);
return rv;
}
diff --git a/linux/src/include/linux/skbuff.h b/linux/src/include/linux/skbuff.h
index cf05129b..e4c77b48 100644
--- a/linux/src/include/linux/skbuff.h
+++ b/linux/src/include/linux/skbuff.h
@@ -405,9 +405,7 @@ extern __inline__ unsigned char *skb_put(struct sk_buff *skb, int len)
skb->len+=len;
if(skb->tail>skb->end)
{
- __label__ here;
- panic("skput:over: %p:%d", &&here,len);
-here:
+ panic("skput:over: %d", len);
}
return tmp;
}
@@ -418,9 +416,7 @@ extern __inline__ unsigned char *skb_push(struct sk_buff *skb, int len)
skb->len+=len;
if(skb->data<skb->head)
{
- __label__ here;
- panic("skpush:under: %p:%d", &&here,len);
-here:
+ panic("skpush:under: %d", len);
}
return skb->data;
}
diff --git a/vm/vm_kern.c b/vm/vm_kern.c
index dc7f7e4b..cfa33ff8 100644
--- a/vm/vm_kern.c
+++ b/vm/vm_kern.c
@@ -43,6 +43,7 @@
#include <kern/debug.h>
#include <kern/lock.h>
#include <kern/thread.h>
+#include <kern/printf.h>
#include <vm/pmap.h>
#include <vm/vm_fault.h>
#include <vm/vm_kern.h>
@@ -387,6 +388,7 @@ kmem_alloc(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
VM_OBJECT_NULL, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc in %p\n", map);
vm_map_unlock(map);
vm_object_deallocate(object);
return kr;
@@ -453,6 +455,7 @@ kern_return_t kmem_realloc(map, oldaddr, oldsize, newaddrp, newsize)
VM_OBJECT_NULL, &newentry);
if (kr != KERN_SUCCESS) {
vm_map_unlock(map);
+ printf_once("no more room for kmem_realloc in %p\n", map);
return kr;
}
@@ -537,6 +540,7 @@ kmem_alloc_wired(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, (vm_offset_t) 0,
kernel_object, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc_wired in %p\n", map);
vm_map_unlock(map);
return kr;
}
@@ -611,6 +615,7 @@ kmem_alloc_aligned(map, addrp, size)
kr = vm_map_find_entry(map, &addr, size, size - 1,
kernel_object, &entry);
if (kr != KERN_SUCCESS) {
+ printf_once("no more rooom for kmem_alloc_aligned in %p\n", map);
vm_map_unlock(map);
return kr;
}
@@ -672,8 +677,10 @@ kmem_alloc_pageable(map, addrp, size)
(vm_offset_t) 0, TRUE,
VM_OBJECT_NULL, (vm_offset_t) 0, FALSE,
VM_PROT_DEFAULT, VM_PROT_ALL, VM_INHERIT_DEFAULT);
- if (kr != KERN_SUCCESS)
+ if (kr != KERN_SUCCESS) {
+ printf_once("no more room for kmem_alloc_pageable in %p\n", map);
return kr;
+ }
*addrp = addr;
return KERN_SUCCESS;
diff --git a/vm/vm_map.c b/vm/vm_map.c
index dc2388d7..751e0314 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -534,13 +534,17 @@ kern_return_t vm_map_find_entry(map, address, size, mask, object, o_entry)
* wrap around the address.
*/
- if (((start + mask) & ~mask) < start)
+ if (((start + mask) & ~mask) < start) {
+ printf_once("no more room for vm_map_find_entry in %p\n", map);
return(KERN_NO_SPACE);
+ }
start = ((start + mask) & ~mask);
end = start + size;
- if ((end > map->max_offset) || (end < start))
+ if ((end > map->max_offset) || (end < start)) {
+ printf_once("no more room for vm_map_find_entry in %p\n", map);
return(KERN_NO_SPACE);
+ }
/*
* If there are no more entries, we must win.
@@ -797,8 +801,10 @@ kern_return_t vm_map_enter(
* wrap around the address.
*/
- if (((start + mask) & ~mask) < start)
+ if (((start + mask) & ~mask) < start) {
+ printf_once("no more room for vm_map_enter in %p\n", map);
RETURN(KERN_NO_SPACE);
+ }
start = ((start + mask) & ~mask);
end = start + size;
@@ -813,6 +819,7 @@ kern_return_t vm_map_enter(
}
}
+ printf_once("no more room for vm_map_enter in %p\n", map);
RETURN(KERN_NO_SPACE);
}
@@ -2486,6 +2493,7 @@ kern_return_t vm_map_copyout(dst_map, dst_addr, copy)
}
}
vm_map_unlock(dst_map);
+ printf_once("no more room for vm_map_copyout in %p\n", dst_map);
return(KERN_NO_SPACE);
}
@@ -2730,6 +2738,7 @@ StartAgain:
}
}
vm_map_unlock(dst_map);
+ printf_once("no more room for vm_map_copyout_page_list in %p\n", dst_map);
return(KERN_NO_SPACE);
}
diff --git a/vm/vm_resident.c b/vm/vm_resident.c
index b23e0f35..a6334989 100644
--- a/vm/vm_resident.c
+++ b/vm/vm_resident.c
@@ -976,6 +976,7 @@ vm_page_grab_contiguous_pages(
if ((vm_page_free_count < vm_page_free_reserved)
|| (vm_page_external_count >= vm_page_external_limit)) {
+ printf_once("no more room for vm_page_grab_contiguous_pages");
simple_unlock(&vm_page_queue_free_lock);
return KERN_RESOURCE_SHORTAGE;
}
@@ -1064,6 +1065,7 @@ count_ones:
*/
simple_unlock(&vm_page_queue_free_lock);
+ printf_once("no contiguous room for vm_page_grab_contiguous_pages");
ret = KERN_RESOURCE_SHORTAGE;
goto out;
diff --git a/xen/block.c b/xen/block.c
index 3c188bff..4718891d 100644
--- a/xen/block.c
+++ b/xen/block.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2006-2009, 2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -158,16 +158,59 @@ void hyp_block_init(void) {
prefix = "sd";
disk = (i >> 4) & ((1 << 4) - 1);
partition = i & ((1 << 4) - 1);
+ } else if ((i >> 8) == 3) {
+ /* IDE primary */
+ prefix = "hd";
+ disk = (i >> 6) & ((1 << 2) - 1);
+ partition = i & ((1 << 6) - 1);
} else if ((i >> 8) == 22) {
/* IDE secondary */
prefix = "hd";
disk = ((i >> 6) & ((1 << 2) - 1)) + 2;
partition = i & ((1 << 6) - 1);
- } else if ((i >> 8) == 3) {
- /* IDE primary */
+ } else if ((i >> 8) == 33) {
+ /* IDE 3 */
prefix = "hd";
- disk = (i >> 6) & ((1 << 2) - 1);
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 4;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 34) {
+ /* IDE 4 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 6;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 56) {
+ /* IDE 5 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 8;
partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 57) {
+ /* IDE 6 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 10;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 88) {
+ /* IDE 7 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 12;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 89) {
+ /* IDE 8 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 14;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 90) {
+ /* IDE 9 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 16;
+ partition = i & ((1 << 6) - 1);
+ } else if ((i >> 8) == 91) {
+ /* IDE 10 */
+ prefix = "hd";
+ disk = ((i >> 6) & ((1 << 2) - 1)) + 18;
+ partition = i & ((1 << 6) - 1);
+ } else {
+ printf("unsupported VBD number %d\n", i);
+ continue;
}
if (partition)
sprintf(device_name, "%s%us%u", prefix, disk, partition);
@@ -213,6 +256,7 @@ void hyp_block_init(void) {
panic("%s: couldn't store state (%s)", device_name, hyp_store_error);
kfree((vm_offset_t) c, strlen(c)+1);
} while (!hyp_store_transaction_stop(t));
+ /* TODO randomly wait? */
c = hyp_store_read(0, 5, VBD_PATH, "/", vbds[n], "/", "backend");
if (!c)
diff --git a/xen/net.c b/xen/net.c
index 1bb217ba..dd903eda 100644
--- a/xen/net.c
+++ b/xen/net.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2006-2009, 2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,8 +46,6 @@
#define ADDRESS_SIZE 6
#define WINDOW __RING_SIZE((netif_rx_sring_t*)0, PAGE_SIZE)
-/* TODO: use rx-copy instead, since we're memcpying anyway */
-
/* Are we paranoid enough to not leak anything to backend? */
static const int paranoia = 0;
@@ -66,6 +64,7 @@ struct net_data {
void *rx_buf[WINDOW];
grant_ref_t rx_buf_gnt[WINDOW];
unsigned long rx_buf_pfn[WINDOW];
+ int rx_copy;
evtchn_port_t evt;
simple_lock_data_t lock;
simple_lock_data_t pushlock;
@@ -100,14 +99,22 @@ int hextoi(char *cp, int *nump)
static void enqueue_rx_buf(struct net_data *nd, int number) {
unsigned reqn = nd->rx.req_prod_pvt++;
netif_rx_request_t *req = RING_GET_REQUEST(&nd->rx, reqn);
+ grant_ref_t gref;
assert(number < WINDOW);
req->id = number;
- req->gref = nd->rx_buf_gnt[number] = hyp_grant_accept_transfer(nd->domid, nd->rx_buf_pfn[number]);
+ if (nd->rx_copy) {
+ /* Let domD write the data */
+ gref = hyp_grant_give(nd->domid, nd->rx_buf_pfn[number], 0);
+ } else {
+ /* Accept pages from domD */
+ gref = hyp_grant_accept_transfer(nd->domid, nd->rx_buf_pfn[number]);
+ /* give back page */
+ hyp_free_page(nd->rx_buf_pfn[number], nd->rx_buf[number]);
+ }
- /* give back page */
- hyp_free_page(nd->rx_buf_pfn[number], nd->rx_buf[number]);
+ req->gref = nd->rx_buf_gnt[number] = gref;
}
static void hyp_net_intr(int unit) {
@@ -131,12 +138,15 @@ static void hyp_net_intr(int unit) {
unsigned number = rx_rsp->id;
assert(number < WINDOW);
- unsigned long mfn = hyp_grant_finish_transfer(nd->rx_buf_gnt[number]);
-
+ if (nd->rx_copy) {
+ hyp_grant_takeback(nd->rx_buf_gnt[number]);
+ } else {
+ unsigned long mfn = hyp_grant_finish_transfer(nd->rx_buf_gnt[number]);
#ifdef MACH_PSEUDO_PHYS
- mfn_list[nd->rx_buf_pfn[number]] = mfn;
+ mfn_list[nd->rx_buf_pfn[number]] = mfn;
#endif /* MACH_PSEUDO_PHYS */
- pmap_map_mfn(nd->rx_buf[number], mfn);
+ pmap_map_mfn(nd->rx_buf[number], mfn);
+ }
kmsg = net_kmsg_get();
if (!kmsg)
@@ -147,15 +157,16 @@ static void hyp_net_intr(int unit) {
switch (rx_rsp->status) {
case NETIF_RSP_DROPPED:
printf("Packet dropped\n");
- goto drop;
+ goto drop_kmsg;
case NETIF_RSP_ERROR:
- panic("Packet error");
+ printf("Packet error\n");
+ goto drop_kmsg;
case 0:
printf("nul packet\n");
- goto drop;
+ goto drop_kmsg;
default:
printf("Unknown error %d\n", rx_rsp->status);
- goto drop;
+ goto drop_kmsg;
}
data = nd->rx_buf[number] + rx_rsp->offset;
@@ -175,6 +186,8 @@ static void hyp_net_intr(int unit) {
net_packet(&nd->ifnet, kmsg, ph->length, ethernet_priority(kmsg));
continue;
+drop_kmsg:
+ net_kmsg_put(kmsg);
drop:
RING_FINAL_CHECK_FOR_RESPONSES(&nd->rx, more);
enqueue_rx_buf(nd, number);
@@ -198,15 +211,15 @@ drop:
printf("Packet dropped\n");
break;
case NETIF_RSP_ERROR:
- panic("Packet error");
+ printf("Packet error\n");
+ break;
case NETIF_RSP_OKAY:
break;
default:
printf("Unknown error %d\n", tx_rsp->status);
- goto drop_tx;
+ break;
}
thread_wakeup((event_t) hyp_grant_address(tx_rsp->id));
-drop_tx:
thread_wakeup_one(nd);
RING_FINAL_CHECK_FOR_RESPONSES(&nd->tx, more);
}
@@ -359,19 +372,38 @@ void hyp_net_init(void) {
}
printf("\n");
+ nd->rx_copy = hyp_store_read_int(0, 3, nd->backend, "/", "feature-rx-copy");
+ if (nd->rx_copy == 1) {
+ c = hyp_store_write(0, "1", 5, VIF_PATH, "/", vifs[n], "/", "request-rx-copy");
+ if (!c)
+ panic("eth: couldn't request rx copy feature for VIF %s (%s)", vifs[n], hyp_store_error);
+ } else
+ nd->rx_copy = 0;
+
c = hyp_store_write(0, hyp_store_state_connected, 5, VIF_PATH, "/", nd->vif, "/", "state");
if (!c)
panic("couldn't store state for eth%d (%s)", nd - vif_data, hyp_store_error);
kfree((vm_offset_t) c, strlen(c)+1);
+ while(1) {
+ i = hyp_store_read_int(0, 3, nd->backend, "/", "state");
+ if (i == MACH_ATOI_DEFAULT)
+ panic("can't read state from %s", nd->backend);
+ if (i == XenbusStateConnected)
+ break;
+ hyp_yield();
+ }
+
/* Get a page for packet reception */
for (i= 0; i<WINDOW; i++) {
if (kmem_alloc_wired(kernel_map, &addr, PAGE_SIZE) != KERN_SUCCESS)
panic("eth: couldn't allocate space for store tx_ring");
nd->rx_buf[i] = (void*)phystokv(kvtophys(addr));
nd->rx_buf_pfn[i] = atop(kvtophys((vm_offset_t)nd->rx_buf[i]));
- if (hyp_do_update_va_mapping(kvtolin(addr), 0, UVMF_INVLPG|UVMF_ALL))
- panic("eth: couldn't clear rx kv buf %d at %p", i, addr);
+ if (!nd->rx_copy) {
+ if (hyp_do_update_va_mapping(kvtolin(addr), 0, UVMF_INVLPG|UVMF_ALL))
+ panic("eth: couldn't clear rx kv buf %d at %p", i, addr);
+ }
/* and enqueue it to backend. */
enqueue_rx_buf(nd, i);
}
diff --git a/xen/xen.c b/xen/xen.c
index 062ee4d5..f8f964eb 100644
--- a/xen/xen.c
+++ b/xen/xen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2007-2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -46,13 +46,17 @@ void hyp_init(void)
{
hyp_grant_init();
hyp_store_init();
- /* these depend on the above */
- hyp_block_init();
- hyp_net_init();
evtchn_port_t port = hyp_event_channel_bind_virq(VIRQ_DEBUG, 0);
hyp_evt_handler(port, hyp_debug, 0, SPL7);
}
+void hyp_dev_init(void)
+{
+ /* these depend on hyp_init() and working threads */
+ hyp_block_init();
+ hyp_net_init();
+}
+
void _hyp_halt(void)
{
hyp_halt();
diff --git a/xen/xen.h b/xen/xen.h
index 87e1256c..6eeb350e 100644
--- a/xen/xen.h
+++ b/xen/xen.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Samuel Thibault <samuel.thibault@ens-lyon.org>
+ * Copyright (C) 2006-2010, 2011 Samuel Thibault <samuel.thibault@ens-lyon.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
#define XEN_XEN_H
void hyp_init(void);
+void hyp_dev_init(void);
void hyp_invalidate_pte(pt_entry_t *pte);
void hyp_idle(void);
void hyp_p2m_init(void);