From owner-p4-projects@FreeBSD.ORG Mon Aug 20 16:52:24 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 948E716A421; Mon, 20 Aug 2007 16:52:24 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5185616A41B for ; Mon, 20 Aug 2007 16:52:24 +0000 (UTC) (envelope-from fabio@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3259D13C4A3 for ; Mon, 20 Aug 2007 16:52:24 +0000 (UTC) (envelope-from fabio@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7KGqOOB038712 for ; Mon, 20 Aug 2007 16:52:24 GMT (envelope-from fabio@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7KGqNJT038706 for perforce@freebsd.org; Mon, 20 Aug 2007 16:52:23 GMT (envelope-from fabio@FreeBSD.org) Date: Mon, 20 Aug 2007 16:52:23 GMT Message-Id: <200708201652.l7KGqNJT038706@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to fabio@FreeBSD.org using -f From: Fabio Checconi To: Perforce Change Reviews Cc: Subject: PERFORCE change 125426 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Aug 2007 16:52:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=125426 Change 125426 by fabio@fabio_gror on 2007/08/20 16:51:50 Update the perforce repository with the snapshot that will be reviewed for the SoC evaluation. The project is tracked with git: http://feanor.sssup.it/~fabio/git/?p=soc07.git Affected files ... .. //depot/projects/soc2007/fabio-lkvm/README#1 add .. //depot/projects/soc2007/fabio-lkvm/kvm-17/configure#2 edit .. //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/configure#2 edit .. //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/exec.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/vl.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/kvm-17/user/configure#2 edit .. //depot/projects/soc2007/fabio-lkvm/kvm-17/user/kvmctl.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/bitops.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/bug.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/current.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/desc.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/highmem.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/io.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/msr.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/processor.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/segment.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/semaphore.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/system.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/topology.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/types.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/ldev_stub.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/ldev_stub.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/dcache.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/file.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/fs.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/gfp.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/interrupt.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/mm.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/module.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/mutex.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/page.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/sched.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/signal.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/smp.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/spinlock.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/vmalloc.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/linux_compat/linux_compat.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/Makefile.kld#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/include/linux/kvm.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/kvm.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/kvm_main.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/mmu.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/paging_tmpl.h#2 edit .. //depot/projects/soc2007/fabio-lkvm/lkvm/svm.c#2 edit .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-90_security#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-Makefile#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-PRId64#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-aa#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-audio-4#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-audio::ossaudio.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bc#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bd#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-be#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bf#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bg#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bh#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bk#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-block-qcow2.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-block-raw.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-block.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bsdusb.patch#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-bt#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-fbsd#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-fpu-softfloat-native.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-libmath#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-libmath2#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-libmath4#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-osdep.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-qemu-img.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-qemu-img.texi#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-target-mips-cpu.h#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-vl.c#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-vl.c-nographic#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-vl.c-ppbus#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-vl.c-serial#1 add .. //depot/projects/soc2007/fabio-lkvm/patches/qemu/patch-x_keymap.c#1 add Differences ... ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/configure#2 (xtext/text+ko) ==== ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/configure#2 (xtext/text+ko) ==== ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/exec.c#2 (text+ko) ==== @@ -42,6 +42,7 @@ //#define DEBUG_FLUSH //#define DEBUG_TLB //#define DEBUG_UNASSIGNED +#define DEBUG_IOPORT /* make various TB consistency checks */ //#define DEBUG_TB_CHECK ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/qemu/vl.c#2 (text+ko) ==== @@ -106,8 +106,8 @@ #endif #endif -//#define DEBUG_UNUSED_IOPORT -//#define DEBUG_IOPORT +#define DEBUG_UNUSED_IOPORT +#define DEBUG_IOPORT #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024) ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/user/configure#2 (xtext/text+ko) ==== ==== //depot/projects/soc2007/fabio-lkvm/kvm-17/user/kvmctl.c#2 (text+ko) ==== @@ -36,6 +36,36 @@ /* FIXME: or dynamically alloc/realloc regions */ #define KVM_MAX_NUM_MEM_REGIONS 4u +#ifndef __FreeBSD__ +#define kvm_mmap mmap +#else +/* + * On FreeBSD we cannot hook the mmap call, so we turn it into + * something else... + */ +static inline void * +kvm_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t pos) +{ + struct kvm_mmap_args args; + int r; + + args.addr = addr; + args.len = len; + args.prot = prot; + args.flags = flags; + args.fd = fd; + args.pos = pos; + + r = ioctl(fd, KVM_VM_MMAP, &args); + + if (r == 0) + return args.retval; + + errno = r; + return MAP_FAILED; +} +#endif + /** * \brief The KVM context * @@ -268,7 +298,7 @@ kvm_memory_region_save_params(kvm, &low_memory); kvm_memory_region_save_params(kvm, &extended_memory); - *vm_mem = mmap(0, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + *vm_mem = kvm_mmap(0, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (*vm_mem == MAP_FAILED) { fprintf(stderr, "mmap: %m\n"); return -1; @@ -312,7 +342,7 @@ if (writable) prot |= PROT_WRITE; - ptr = mmap(0, len, prot, MAP_SHARED, fd, phys_start); + ptr = kvm_mmap(0, len, prot, MAP_SHARED, fd, phys_start); if (ptr == MAP_FAILED) return 0; return ptr; @@ -338,7 +368,7 @@ log.u.dirty_bitmap = buf; - r = ioctl(kvm->vm_fd, ioctl_num, &log); + r = ioctl(kvm->vm_fd, (unsigned long)ioctl_num, &log); if (r == -1) return -errno; return 0; @@ -538,19 +568,23 @@ sizer.nmsrs = 0; r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, &sizer); -#ifndef __FreeBSD__ +#ifdef __FreeBSD__ + if (sizer.error != 0) { + r = -1; + errno = -sizer.error; + } +#endif if (r == -1 && errno != E2BIG) return 0; -#else - if (r == -1 || sizer.error != E2BIG) - return 0; -#endif msrs = malloc(sizeof *msrs + sizer.nmsrs * sizeof *msrs->indices); if (!msrs) { errno = ENOMEM; return 0; } msrs->nmsrs = sizer.nmsrs; +#ifdef __FreeBSD__ + msrs->indices = (__u32 *)&msrs[1]; +#endif r = ioctl(kvm->fd, KVM_GET_MSR_INDEX_LIST, msrs); if (r == -1) { e = errno; @@ -773,6 +807,14 @@ kvm_run.emulated = 0; kvm_run.mmio_completed = 0; + +#ifdef __FreeBSD__ + if (kvm_run.error != 0) { + r = -1; + errno = -kvm_run.error; + } +#endif + if (r == -1 && errno != EINTR) { r = -errno; printf("kvm_run: %m\n"); ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/bitops.h#2 (text+ko) ==== @@ -1,26 +1,41 @@ #ifndef _LINUX_ASM_BITOPS_H #define _LINUX_ASM_BITOPS_H +#include + +/* + * In Linux (at least i386/amd64) this is undefined if word is zero. + */ static inline unsigned long __ffs(unsigned long word) { - return 0; + int i; + + for (i = 0; i < sizeof(word) * 8; i++) + if (word & (1UL << i)) + break; + + return i; } -static inline void set_bit(int nr, volatile unsigned long *addr) -{ -} +/* + * XXX this should be atomic (so it should be defined in an + * arch-dependent way) + */ +#define set_bit(nr, addr) __set_bit(nr, addr) static inline void __set_bit(int nr, volatile unsigned long *addr) { + addr[nr / __LONG_BIT] |= 1UL << (nr % __LONG_BIT); } -static inline int test_bit(int nr, const volatile void *addr) +static inline int test_bit(int nr, const volatile unsigned long *addr) { - return 0; + return (addr[nr / __LONG_BIT] & (1UL << (nr % __LONG_BIT))) != 0; } static inline void clear_bit(int nr, volatile unsigned long *addr) { + addr[nr / __LONG_BIT] &= ~(1UL << (nr % __LONG_BIT)); } #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/bug.h#2 (text+ko) ==== @@ -1,6 +1,9 @@ #ifndef _LINUX_ASM_BUG_H #define _LINUX_ASM_BUG_H -#define BUG_ON(condition) +#define BUG_ON(condition) do { \ + if ((condition)) \ + panic("BUG\n"); \ +} while(0) #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/current.h#2 (text+ko) ==== @@ -1,11 +1,15 @@ #ifndef _LINUX_CURRENT_H #define _LINUX_CURRENT_H -struct task_struct; +/* + * XXX should really do something better, this makes little or no + * sense when we have more than one caller... + */ +extern struct task_struct __current; static inline struct task_struct *get_current(void) { - return 0; + return &__current; } #define current get_current() ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/desc.h#2 (text+ko) ==== @@ -2,6 +2,7 @@ #define _LINUX_ASM_DESC_H #include +#include struct Xgt_desc_struct { unsigned short size; @@ -9,6 +10,12 @@ unsigned short pad; } __attribute__((packed)); -#define load_TR_desc() +static inline void load_TR_desc(void) +{ + int gsel_tss; + + gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); + ltr(gsel_tss); +} #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/highmem.h#2 (text+ko) ==== @@ -3,10 +3,11 @@ #include #include +#include static inline void *kmap_atomic(struct page *page, enum km_type type) { - return 0; + return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page->vm_page)); } static inline void kunmap_atomic(void *kvaddr, enum km_type type) ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/io.h#2 (text+ko) ==== @@ -1,9 +1,8 @@ #ifndef _LINUX_ASM_IO_H #define _LINUX_ASM_IO_H -static inline unsigned long virt_to_phys(volatile void *address) -{ - return 0; -} +#include + +#define virt_to_phys(address) __pa(address) #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/msr.h#2 (text+ko) ==== @@ -13,33 +13,35 @@ * pointer indirection), this allows gcc to optimize better */ -#define rdmsr_compat(msr,val1,val2) \ - __asm__ __volatile__("rdmsr" \ - : "=a" (val1), "=d" (val2) \ - : "c" (msr)) +#define rdmsr_compat(msr,val1,val2) \ + __asm__ __volatile__("rdmsr" \ + : "=a" (val1), "=d" (val2) \ + : "c" (msr)) -#define wrmsr_compat(msr,val1,val2) \ - __asm__ __volatile__("wrmsr" \ - : /* no outputs */ \ - : "c" (msr), "a" (val1), "d" (val2)) +#define wrmsr_compat(msr,val1,val2) \ + __asm__ __volatile__("wrmsr" \ + : /* no outputs */ \ + : "c" (msr), "a" (val1), "d" (val2)) #define rdmsrl(msr, val) ((val) = rdmsr(msr)) #define wrmsrl(msr, val) wrmsr(msr, val) /* wrmsr with exception handling */ -#define wrmsr_safe(msr,a,b) ({ int ret__; \ - asm volatile("2: wrmsr ; xorl %0,%0\n" \ - "1:\n\t" \ - ".section .fixup,\"ax\"\n\t" \ - "3: movl %4,%0 ; jmp 1b\n\t" \ - ".previous\n\t" \ - ".section __ex_table,\"a\"\n" \ - " .align 4\n\t" \ - " .long 2b,3b\n\t" \ - ".previous" \ - : "=a" (ret__) \ - : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT));\ - ret__; }) +static inline int wrmsr_safe(u_int msr, u_int32_t low, u_int32_t high) +{ + int ret = -EFAULT; + + __asm__ __volatile__("movq $1f, %4\n" + "wrmsr\n" + "movl $0, %0\n" + "1:\n" + : "=m"(ret) + : "a"(low), "c"(msr), "d"(high), + "m"(PCPU_GET(curpcb)->pcb_onfault)); + + PCPU_GET(curpcb)->pcb_onfault = NULL; + return ret; +} /* rdmsr with exception handling */ static inline int rdmsr_safe(u_int msr, u_int32_t *low, u_int32_t *high) @@ -47,12 +49,12 @@ int ret = -EFAULT; __asm__ __volatile__("movq $1f, %4\n" - "rdmsr\n" - "movl $0, %3\n" - "1:\n" - : "=a"(*low), "=d"(*high) - : "c"(msr), "m"(ret), - "m"(PCPU_GET(curpcb)->pcb_onfault)); + "rdmsr\n" + "movl $0, %2\n" + "1:\n" + : "=a"(*low), "=d"(*high), "=m"(ret) + : "c"(msr), + "m"(PCPU_GET(curpcb)->pcb_onfault)); PCPU_GET(curpcb)->pcb_onfault = NULL; return ret; ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/processor.h#2 (text+ko) ==== @@ -41,8 +41,8 @@ #define boot_cpu_data (get_boot_cpu_data()) static inline void cpuid(unsigned int op, unsigned int *eax, - unsigned int *ebx, unsigned int *ecx, - unsigned int *edx) + unsigned int *ebx, unsigned int *ecx, + unsigned int *edx) { __asm __volatile("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) @@ -51,12 +51,18 @@ static inline unsigned int cpuid_ebx(unsigned int op) { - return 0; + unsigned int r[4]; + + cpuid(op, &r[0], &r[1], &r[2], &r[3]); + return r[1]; } static inline unsigned int cpuid_ecx(unsigned int op) { - return 0; + unsigned int r[4]; + + cpuid(op, &r[0], &r[1], &r[2], &r[3]); + return r[2]; } static inline void set_debugreg(int regno, unsigned long value) @@ -64,7 +70,7 @@ } struct desc_struct { - unsigned long a, b; + unsigned int a, b; }; #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/segment.h#2 (text+ko) ==== @@ -1,10 +1,12 @@ #ifndef _LINUX_ASM_SEGMENT_H #define _LINUX_ASM_SEGMENT_H -#define GDT_ENTRY_TSS 0 +#include + +#define GDT_ENTRY_TSS GPROC0_SEL -#define __KERNEL_CS 0 -#define __KERNEL_DS 0 -#define __USER_DS 0 +#define __KERNEL_CS GSEL(GCODE_SEL, SEL_KPL) +#define __KERNEL_DS GSEL(GDATA_SEL, SEL_KPL) +#define __USER_DS GSEL(GUDATA_SEL, SEL_UPL) #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/semaphore.h#2 (text+ko) ==== @@ -1,26 +1,30 @@ -/* - * stub for asm/semaphore.h - */ - #ifndef _LINUX_ASM_SEMAPHORE_H #define _LINUX_ASM_SEMAPHORE_H -#include -#if 1 /* freebsd semaphores */ +#include +#include +#include -#include +/* + * We don't know when the semaphore object is destroyed, since in + * Linux there is no explicit call to notify this, so or we modify + * drivers to include a destructor code, or we leak some memory. + * We have the same problem with spinlocks. + * + * XXX By now just ignore that. + */ struct semaphore { - struct mtx m; + struct sema sema; }; static inline void init_MUTEX(struct semaphore *sem) { - mtx_init(&sem->m, "ldev", NULL, MTX_DEF); + //sema_init(&sem->sema, 1, "lkc-mutex"); } static inline void down(struct semaphore *sem) { - mtx_lock(&sem->m); + //sema_wait(&sem->sema); } static inline int down_interruptible(struct semaphore *sem) @@ -31,57 +35,7 @@ static inline void up(struct semaphore *sem) { - mtx_unlock(&sem->m); -} - -#else /* linux semaphores */ -/* from asm/semaphore.h */ -struct semaphore { - atomic_t count; - int sleepers; - wait_queue_head_t wait; -}; - -static inline void sema_init (struct semaphore *sem, int val) -{ -/* - * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); - * - * i'd rather use the more flexible initialization above, but sadly - * GCC 2.7.2.3 emits a bogus warning. EGCS doesn't. Oh well. - */ - atomic_set(&sem->count, val); - sem->sleepers = 0; - init_waitqueue_head(&sem->wait); -} - -static inline void init_MUTEX (struct semaphore *sem) -{ - sema_init(sem, 1); -} - -static inline void up(struct semaphore *sem) -{ - // XXX to be filled + //sema_post(&sem->sema); } -static inline void down(struct semaphore *sem) -{ - // XXX to be filled -} - -static inline int down_interruptible(struct semaphore *sem) -{ - down(sem); - return 0; -} - -/* these are fake implementation to be fixed */ -#define spin_lock(sem) do {} while (0) -#define spin_lock_irq(sem) do {} while (0) -#define spin_lock_irqsave(sem, flags) do {flags = 0;} while (0) -#define spin_unlock_irqrestore(sem, flags) do {} while (0) -#define spin_unlock(sem) do {} while (0) -#define spin_unlock_irq(sem) do {} while (0) -#endif #endif /* _LINUX_ASM_SEMAPHORE_H */ ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/system.h#2 (text+ko) ==== @@ -1,22 +1,12 @@ #ifndef _LINUX_ASM_SYSTEM_H #define _LINUX_ASM_SYSTEM_H -static inline void write_cr4(unsigned int val) -{ -} +#include -static inline unsigned long read_cr0(void) -{ - return 0; -} +#define write_cr4(val) load_cr4(val) -static inline unsigned long read_cr3(void) -{ - return 0; -} -static inline unsigned long read_cr4(void) -{ - return 0; -} +#define read_cr0() rcr0() +#define read_cr3() rcr3() +#define read_cr4() rcr4() #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/topology.h#2 (text+ko) ==== @@ -1,9 +1,6 @@ #ifndef _LINUX_ASM_TOPOLOGY_H #define _LINUX_ASM_TOPOLOGY_H -static inline int cpu_to_node(int cpu) -{ - return 0; -} +#define cpu_to_node(cpu) (cpu) #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/asm/types.h#2 (text+ko) ==== @@ -1,6 +1,8 @@ #ifndef _I386_TYPES_H #define _I386_TYPES_H +#include + #ifndef __ASSEMBLY__ typedef unsigned short umode_t; @@ -31,7 +33,7 @@ */ #ifdef __KERNEL__ -#define BITS_PER_LONG 32 +#define BITS_PER_LONG __LONG_BIT #ifndef __ASSEMBLY__ ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/ldev_stub.c#2 (text+ko) ==== @@ -275,7 +275,7 @@ sc->sc_dev_t = make_dev(&ldev_cdevsw, unit, UID_ROOT, GID_OPERATOR, 0666, "%s%d", DEV_NAME, unit); /* call the attach routine (where ???) */ - usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->udev,USBDEV(sc->sc_dev)); + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->udev,sc->sc_dev); return 0; /* success */ } @@ -294,7 +294,7 @@ selwakeuppri(&sc->rsel,PZERO); } device_printf(sc->sc_dev, "Disconnected while device is in use!\n"); - usb_detach_wait(USBDEV(sc->sc_dev)); + usb_detach_wait(sc->sc_dev); } /* free resources etc. */ if (sc->l_u_d.mem) /* memory allocated for linux emulation */ @@ -304,12 +304,12 @@ mtx_destroy(&sc->ptrlock); /* free memory ? */ - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->udev,USBDEV(sc->sc_dev)); + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->udev,sc->sc_dev); return 0; } static int -ldev_open(struct cdev *dev, int flag, int mode, usb_proc_ptr p) +ldev_open(struct cdev *dev, int flag, int mode, struct thread *p) { int err = 0; int unit = LDEVUNIT(dev); @@ -340,7 +340,7 @@ /* Watch out for races between close and detach */ static int -ldev_close(struct cdev *dev, int flag, int mode, usb_proc_ptr p) +ldev_close(struct cdev *dev, int flag, int mode, struct thread *p) { int unit = LDEVUNIT(dev); struct ldev_softc *sc = devclass_get_softc(ldev_devclass, unit); @@ -352,7 +352,7 @@ err = -sc->l_u_d.fops->release((struct inode *)sc, &sc->l_u_d.file); sc->vopen = 0; - usb_detach_wakeup(USBDEV(sc->sc_dev)); /* if a detach is pending */ + usb_detach_wakeup(sc->sc_dev); /* if a detach is pending */ return err; } @@ -405,7 +405,8 @@ #include static int -ldev_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, usb_proc_ptr p) +ldev_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, + struct thread *p) { int unit = LDEVUNIT(dev); struct ldev_softc *sc = devclass_get_softc(ldev_devclass, unit); @@ -434,7 +435,7 @@ /* XXX this is still incomplete */ static int -ldev_poll(struct cdev *dev, int events, usb_proc_ptr p) +ldev_poll(struct cdev *dev, int events, struct thread *p) { int unit = LDEVUNIT(dev); struct ldev_softc *sc = devclass_get_softc(ldev_devclass, unit); ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/ldev_stub.h#2 (text+ko) ==== @@ -64,6 +64,7 @@ // #include #include +#include #include #include ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/dcache.h#2 (text+ko) ==== @@ -3,12 +3,12 @@ #include +struct inode; + struct dentry { + struct inode *d_inode; }; -static inline struct dentry *d_alloc_anon(struct inode *ino) -{ - return 0; -} +#define d_alloc_anon(inode) kzalloc(sizeof(struct dentry), GFP_KERNEL) #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/file.h#2 (text+ko) ==== @@ -1,19 +1,13 @@ #ifndef _LINUX_FILE_H #define _LINUX_FILE_H -struct file; +#include -static inline void fput(struct file *filp) +static inline void fput(struct linux_file *filp) { } -static inline int get_unused_fd(void) -{ - return 0; -} - -static inline void fd_install(unsigned int fd, struct file *filp) -{ -} +int get_unused_fd(void); +void fd_install(int fd, struct linux_file *filp); #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/fs.h#2 (text+ko) ==== @@ -33,6 +33,9 @@ #include #include +#include +#include + /* * $Id: fs.h,v 1.4 2007/01/27 16:52:28 luigi Exp $ * Prototype of the struct file_operations used in device drivers. @@ -45,7 +48,7 @@ struct address_space; /* from file.h */ -struct file { +struct linux_file { struct path f_path; const struct file_operations *f_op; atomic_t f_count; @@ -57,6 +60,13 @@ void *private_data; }; +/* + * XXX that's quite dirty, from now on all `file' identifiers will be + * replaced with linux_file. this may cause *a lot* of nasty things + * and hard to find errors, but should work for KVM. + */ +#define file linux_file + // struct kiocb; /* in aio.h */ struct poll_table_struct; // XXX dummy // struct dentry; // XXX dummy @@ -128,10 +138,7 @@ { } -static inline struct file *get_empty_filp(void) -{ - return 0; -} +#define get_empty_filp() kzalloc(sizeof(struct file), GFP_KERNEL) struct super_block; struct super_operations; @@ -164,10 +171,7 @@ return 0; } -static inline struct inode *new_inode(struct super_block *sb) -{ - return 0; -} +#define new_inode(sb) kzalloc(sizeof(struct inode), GFP_KERNEL) static inline struct vfsmount *kern_mount(struct file_system_type *fs_type) { ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/gfp.h#2 (text+ko) ==== @@ -16,9 +16,9 @@ struct page *alloc_pages(gfp_t gfp_mask, unsigned int order); static inline struct page *alloc_pages_node(int nid, gfp_t gfp_mask, - unsigned int order) + unsigned int order) { - return 0; + return alloc_pages(gfp_mask, order); } static inline void free_pages(unsigned long addr, unsigned int order) ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/interrupt.h#2 (text+ko) ==== @@ -1,12 +1,9 @@ #ifndef _LINUX_INTERRUPT_H #define _LINUX_INTERRUPT_H -static inline void local_irq_enable(void) -{ -} +#include -static inline void local_irq_disable(void) -{ -} +#define local_irq_enable() enable_intr() +#define local_irq_disable() disable_intr() #endif ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/mm.h#2 (text+ko) ==== @@ -95,14 +95,33 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t); -#define page_address(page) ((void *)__va(VM_PAGE_TO_PHYS(page->vm_page))) +static inline void *page_address(struct page *page) +{ +#ifdef DEBUG_ADDR + KASSERT(pfn_to_page(page_to_pfn(page)) == page, ("page_address")); +#endif + return __va(VM_PAGE_TO_PHYS(page->vm_page)); +} static inline void get_page(struct page *page) { } -#define page_private(page) ((unsigned long)page) -#define set_page_private(page, v) ((page)->private = (v)) +static inline unsigned long page_private(struct page *page) +{ +#ifdef DEBUG_ADDR + KASSERT(pfn_to_page(page_to_pfn(page)) == page, ("page_private")); +#endif + return page->private; +} + +static inline void set_page_private(struct page *page, unsigned long v) +{ +#ifdef DEBUG_ADDR + KASSERT(pfn_to_page(page_to_pfn(page)) == page, ("set_page_private")); +#endif + page->private = v; +} /* XXX this should not be done so late! */ #include ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/module.h#2 (text+ko) ==== @@ -145,7 +145,7 @@ dev->priv = data; } -struct file; +#include struct inode; struct video_device* video_devdata(struct file*); @@ -208,13 +208,18 @@ /* make this non blocking */ #define kmalloc(siz,opt) malloc(siz, M_USBDEV, M_NOWAIT) -#define kfree(pt) free(pt, M_USBDEV) +#define kfree(pt) do { \ + if (curthread->td_critnest == 0) \ + free(pt, M_USBDEV); \ +} while (0) #define HZ hz // on freebsd... #define udelay(t) DELAY(t) void linux_msleep(int ms); #define msleep_compat(ms) linux_msleep(ms) +#undef msleep +#define msleep(ms) linux_msleep(ms) // #define mdelay(ms) linux_msleep(ms) // maybe DELAY... */ #define mdelay(ms) DELAY(ms) // maybe DELAY... */ ==== //depot/projects/soc2007/fabio-lkvm/linux_compat/linux/mutex.h#2 (text+ko) ==== @@ -9,16 +9,16 @@ struct mtx m; }; -#define mutex_init(_m) mtx_init(&(_m)->m, "ldev", NULL, MTX_DEF) -#define mutex_lock(_m) mtx_lock(&(_m)->m) +#define mutex_init(_m) //mtx_init(&(_m)->m, "ldev", NULL, MTX_DEF) +#define mutex_lock(_m) //mtx_lock(&(_m)->m) static inline int mutex_lock_interruptible(struct mutex *_m) { >>> TRUNCATED FOR MAIL (1000 lines) <<<