revert to yiyus that might work. - vx32 - Local 9vx git repository for patches.
       
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 69e8094cbddde4d3a6a81a947ae5e0937891fc8a
 (DIR) parent f355b3ad7a021ebcf86258d7b3e2b1fc957aee66
 (HTM) Author: rminnich@gmail.com <none@none>
       Date:   Sun, 12 Sep 2010 18:51:11 -0700
       
       revert to yiyus that might work.
       
       Diffstat:
         CONTRIBUTORS                        |       3 ++-
         src/9vx/Makefrag                    |      12 +++++++++---
         src/9vx/a/mem.h                     |     102 ++-----------------------------
         src/9vx/ethertap.c                  |      18 ++++++++++++++++++
         src/9vx/main.c                      |       2 +-
         src/9vx/stub.c                      |       3 ++-
         src/Makefrag                        |       7 ++++++-
         src/libvx32/Makefrag                |       1 +
       
       8 files changed, 44 insertions(+), 104 deletions(-)
       ---
 (DIR) diff --git a/CONTRIBUTORS b/CONTRIBUTORS
       @@ -3,10 +3,11 @@ The following people have contributed source code to vx32.
        Bryan Ford <baford@pdos.csail.mit.edu>
        Michael Teichgräber <mt4swm@googlemail.com>
        Russ Cox <rsc@swtch.com>
       -Charles Forsyth <forsyth@terzarima.net>
       +Charles Forsyth
        Jesus Galan Lopez <yiyu.jgl@gmail.com>
        Tuly Gray
        Devon H. O'Dell
       +Prem Mallappa
        Ron Minnich
        Erik Quantrom
        Brian L. Stuart
 (DIR) diff --git a/src/9vx/Makefrag b/src/9vx/Makefrag
       @@ -2,18 +2,24 @@ ifeq ($(OS),linux)
        PLAN9VX=1
        PLAN9GUI=x11
        PLAN9AUDIO=unix
       +PLAN9PCAP=nopcap
       +PLAN9TAP=ethertap
        endif
        
        ifeq ($(OS),darwin)
        PLAN9VX=1
        PLAN9GUI=osx
        PLAN9AUDIO=none
       +PLAN9PCAP=nopcap
       +PLAN9TAP=ethertap
        endif
        
        ifeq ($(OS),freebsd)
        PLAN9VX=1
        PLAN9GUI=x11
        PLAN9AUDIO=unix
       +PLAN9PCAP=nopcap
       +PLAN9TAP=notap
        endif
        
        # If you don't have/want X11
       @@ -21,8 +27,8 @@ endif
        
        # Virtual ethernet devices
        #PLAN9PCAP=etherpcap
       -PLAN9PCAP=nopcap
       -PLAN9TAP=ethertap
       +#PLAN9PCAP=nopcap
       +#PLAN9TAP=ethertap
        #PLAN9TAP=notap
        
        ifeq ($(PLAN9VX),1)
       @@ -205,7 +211,7 @@ PLAN9_DEPS = \
                libvx32/libvx32.a \
        
        9vx/9vx: $(PLAN9_DEPS)
       -        $(HOST_CC) -o $@ $(PLAN9_DEPS) $(PLAN9_GUI_LIBS) $(PLAN9_IP_LIBS) -lpthread
       +        $(HOST_CC) -o $@ $(HOST_LDFLAGS) $(PLAN9_DEPS) $(PLAN9_GUI_LIBS) $(PLAN9_IP_LIBS) -lpthread 
        
        9vx/a/%.o: 9vx/a/%.c
                $(HOST_CC) $(HOST_CFLAGS) -I. -I9vx -I9vx/a -Wall -Wno-missing-braces -c -o $@ $<
 (DIR) diff --git a/src/9vx/a/mem.h b/src/9vx/a/mem.h
       @@ -18,109 +18,24 @@
        #define        BLOCKALIGN        8
        
        #define        MAXMACH                128                        /* max # cpus system can run */
       -#define        KSTACK                65536                        /* Size of kernel stack */
       +#define        KSTACK                (1024*1024)                        /* Size of kernel stack */
        
        /*
         * Time
         */
       -#define        HZ                (100)                        /* clock frequency */
       +#define        HZ                (1000)                        /* clock frequency */
        #define        MS2HZ                (1000/HZ)                /* millisec per clock tick */
        #define        TK2SEC(t)        ((t)/HZ)                /* ticks to seconds */
        
        /*
       - *  Address spaces
       + *  Address spaces - only user code!
         */
       -#define        KZERO                0x80000000                /* base of kernel address space */
       -#define        KTZERO                (KZERO+0x100000)                /* first address in kernel text - 9load sits below */
       -#define        VPT                        (KZERO-VPTSIZE)
       -#define        VPTSIZE                BY2XPG
       -#define        NVPT                (VPTSIZE/BY2WD)
       -#define        KMAP                (VPT-KMAPSIZE)
       -#define        KMAPSIZE        BY2XPG
       -#define        VMAP                (KMAP-VMAPSIZE)
       -#define        VMAPSIZE        (0x10000000-VPTSIZE-KMAPSIZE)
        #define        UZERO                0                        /* base of user address space */
        #define        UTZERO                (UZERO+BY2PG)                /* first address in user text */
       -#define        USTKTOP                (0x8000000)                /* byte just beyond user stack */
       +#define        USTKTOP                (0x10000000)                /* byte just beyond user stack */
        #define        USTKSIZE        (16*1024*1024)                /* size of user stack */
        #define        TSTKTOP                (USTKTOP-USTKSIZE)        /* end of new stack in sysexec */
       -#define        TSTKSIZ         100        /* pages in new stack; limits exec args */
       -
       -/*
       - * Fundamental addresses - bottom 64kB saved for return to real mode
       - */
       -#define        CONFADDR        (KZERO+0x1200)                /* info passed from boot loader */
       -#define        TMPADDR                (KZERO+0x2000)                /* used for temporary mappings */
       -#define        APBOOTSTRAP        (KZERO+0x3000)                /* AP bootstrap code */
       -#define        RMUADDR                (KZERO+0x7C00)                /* real mode Ureg */
       -#define        RMCODE                (KZERO+0x8000)                /* copy of first page of KTEXT */
       -#define        RMBUF                (KZERO+0x9000)                /* buffer for user space - known to vga */
       -#define        IDTADDR                (KZERO+0x10800)                /* idt */
       -#define        REBOOTADDR        (0x11000)                /* reboot code - physical address */
       -#define        CPU0PDB                (KZERO+0x12000)                /* bootstrap processor PDB */
       -#define        CPU0PTE                (KZERO+0x13000)                /* bootstrap processor PTE's for 0-4MB */
       -#define        CPU0GDT                (KZERO+0x14000)                /* bootstrap processor GDT */
       -#define        MACHADDR        (KZERO+0x15000)                /* as seen by current processor */
       -#define        CPU0MACH        (KZERO+0x16000)                /* Mach for bootstrap processor */
       -#define        MACHSIZE        BY2PG
       -#define CPU0PTE1        (KZERO+0x17000)                /* bootstrap processor PTE's for 4MB-8MB */
       -#define CPU0END                (CPU0PTE1+BY2PG)
       -/*
       - * N.B.  ramscan knows that CPU0END is the end of reserved data
       - * N.B.  _startPADDR knows that CPU0PDB is the first reserved page
       - * and that there are 6 of them.
       - */
       -
       -/*
       - *  known x86 segments (in GDT) and their selectors
       - */
       -#define        NULLSEG        0        /* null segment */
       -#define        KDSEG        1        /* kernel data/stack */
       -#define        KESEG        2        /* kernel executable */        
       -#define        UDSEG        3        /* user data/stack */
       -#define        UESEG        4        /* user executable */
       -#define        TSSSEG        5        /* task segment */
       -#define        APMCSEG                6        /* APM code segment */
       -#define        APMCSEG16        7        /* APM 16-bit code segment */
       -#define        APMDSEG                8        /* APM data segment */
       -#define        KESEG16                9        /* kernel executable 16-bit */
       -#define        NGDT                10        /* number of GDT entries required */
       -
       -#define        SELGDT        (0<<2)        /* selector is in gdt */
       -#define        SELLDT        (1<<2)        /* selector is in ldt */
       -
       -#define        SELECTOR(i, t, p)        (((i)<<3) | (t) | (p))
       -
       -#define        NULLSEL        SELECTOR(NULLSEG, SELGDT, 0)
       -#define        KDSEL        SELECTOR(KDSEG, SELGDT, 0)
       -#define        KESEL        SELECTOR(KESEG, SELGDT, 0)
       -#define        UESEL        SELECTOR(UESEG, SELGDT, 3)
       -#define        UDSEL        SELECTOR(UDSEG, SELGDT, 3)
       -#define        TSSSEL        SELECTOR(TSSSEG, SELGDT, 0)
       -#define        APMCSEL         SELECTOR(APMCSEG, SELGDT, 0)
       -#define        APMCSEL16        SELECTOR(APMCSEG16, SELGDT, 0)
       -#define        APMDSEL                SELECTOR(APMDSEG, SELGDT, 0)
       -/* #define        APM40SEL        SELECTOR(APM40SEG, SELGDT, 0) */
       -
       -/*
       - *  fields in segment descriptors
       - */
       -#define        SEGDATA        (0x10<<8)        /* data/stack segment */
       -#define        SEGEXEC        (0x18<<8)        /* executable segment */
       -#define        SEGTSS        (0x9<<8)        /* TSS segment */
       -#define        SEGCG        (0x0C<<8)        /* call gate */
       -#define        SEGIG        (0x0E<<8)        /* interrupt gate */
       -#define        SEGTG        (0x0F<<8)        /* trap gate */
       -#define        SEGTYPE        (0x1F<<8)
       -
       -#define        SEGP        (1<<15)                /* segment present */
       -#define        SEGPL(x) ((x)<<13)        /* priority level */
       -#define        SEGB        (1<<22)                /* granularity 1==4k (for expand-down) */
       -#define        SEGG        (1<<23)                /* granularity 1==4k (for other) */
       -#define        SEGE        (1<<10)                /* expand down */
       -#define        SEGW        (1<<9)                /* writable (for data/stack) */
       -#define        SEGR        (1<<9)                /* readable (for code) */
       -#define        SEGD        (1<<22)                /* default 1==32bit (for code) */
       +#define        TSTKSIZ         100
        
        /*
         *  virtual MMU
       @@ -144,12 +59,5 @@
        #define        PTESIZE                (1<<7)
        #define        PTEGLOBAL        (1<<8)
        
       -/*
       - * Macros for calculating offsets within the page directory base
       - * and page tables. 
       - */
       -#define        PDX(va)                ((((ulong)(va))>>22) & 0x03FF)
       -#define        PTX(va)                ((((ulong)(va))>>12) & 0x03FF)
       -
        #define        getpgcolor(a)        0
        
 (DIR) diff --git a/src/9vx/ethertap.c b/src/9vx/ethertap.c
       @@ -16,6 +16,9 @@
        #include "etherif.h"
        #include "vether.h"
        
       +#if defined(__APPLE__)
       +#include <sys/socket.h>
       +#endif
        #include <net/if.h>
        #include <sys/ioctl.h>
        
       @@ -67,6 +70,21 @@ opentap(char *dev)
                        return -1;
                return fd;
        }
       +#elif defined(__APPLE__)
       +static int
       +opentap(char *dev)
       +{
       +        int fd;
       +        char *tap0 = "/dev/tap0";
       +
       +        if(dev == nil)
       +                dev = tap0;
       +        if((fd = open(dev, O_RDWR)) < 0) {
       +                iprint("tap: open failed with: %d\n", errno);
       +                return -1;
       +        }
       +        return fd;
       +}
        #endif
        
        static int
 (DIR) diff --git a/src/9vx/main.c b/src/9vx/main.c
       @@ -196,7 +196,7 @@ main(int argc, char **argv)
                 * bootargs have preference over -r
                 * if localroot is -, keep it for printconfig
                 */
       -        if(bootargc > 0 && strcmp(localroot, "-") != 0)
       +        if(bootargc > 0 && localroot && strcmp(localroot, "-") != 0)
                        localroot = nil;
        
                inifields(&iniopt);
 (DIR) diff --git a/src/9vx/stub.c b/src/9vx/stub.c
       @@ -433,7 +433,8 @@ rebootcmd(int argc, char **argv)
                restoretty();
                for(i = 0; i < argc; i++)
                        iprint("%s%s", argv[i], argc - i > 1 ? " " : "");
       -        iprint("\n");
       +        if(argc > 0)
       +                iprint("\n");
                exit(0);
                error(Egreg);
        }
 (DIR) diff --git a/src/Makefrag b/src/Makefrag
       @@ -4,7 +4,12 @@
        COMMON_CFLAGS = -g -O2 -MD -std=gnu99 -I. -fno-stack-protector $(CFLAGS)
        COMMON_LDFLAGS = -g -L. $(LDFLAGS)
        
       -# Host environment compiler options
       +ifeq ($(OS),darwin)
       +COMMON_CFLAGS += -m32 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE
       +COMMON_LDFLAGS += -m32
       +endif
       +
       + # Host environment compiler options
        HOST_CC                := $(CC) -fno-inline
        HOST_LD                := $(LD)
        HOST_AR                := $(AR)
 (DIR) diff --git a/src/libvx32/Makefrag b/src/libvx32/Makefrag
       @@ -9,6 +9,7 @@ endif
        endif
        
        ifeq ($(OS),darwin)
       +VX32_RUN = run32.o
        VX32_RUN := $(VX32_RUN) darwin-asm.o
        endif