Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'ramdisk' into devel
Jack Lange [Thu, 2 Oct 2008 22:05:59 +0000 (17:05 -0500)]
Conflicts:
palacios/include/devices/generic.h
palacios/include/geekos/timer.h
palacios/include/palacios/vmcs.h
palacios/include/palacios/vmcs_gen.h
palacios/src/devices/generic.c
palacios/src/palacios/vmm_config.c

127 files changed:
palacios/build/Makefile
palacios/build/NOTES-QEMU.TXT
palacios/build/iso/boot/grub/menu.lst [new file with mode: 0644]
palacios/build/iso/boot/grub/stage2_eltorito [new file with mode: 0644]
palacios/include/devices/cdrom.h
palacios/include/devices/generic.h
palacios/include/devices/ide.h [new file with mode: 0644]
palacios/include/devices/ramdisk.h
palacios/include/geekos/synch.h
palacios/include/geekos/timer.h
palacios/include/lwip/arch/cc.h [moved from palacios/src/lwip/include/lwip/err.h with 52% similarity]
palacios/include/lwip/arch/perf.h [moved from palacios/src/lwip/include/ipv4/lwip/inet_chksum.h with 58% similarity]
palacios/include/lwip/arch/sys_arch.h [moved from palacios/src/lwip/include/lwip/def.h with 78% similarity]
palacios/include/lwip/include/lwip/arch.h [deleted file]
palacios/include/lwip/include/lwip/sockets.h [deleted file]
palacios/include/lwip/ipv4/lwip/autoip.h [moved from palacios/include/lwip/include/ipv4/lwip/autoip.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/icmp.h [moved from palacios/include/lwip/include/ipv4/lwip/icmp.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/igmp.h [moved from palacios/include/lwip/include/ipv4/lwip/igmp.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/inet.h [moved from palacios/include/lwip/include/ipv4/lwip/inet.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/inet_chksum.h [moved from palacios/include/lwip/include/ipv4/lwip/inet_chksum.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/ip.h [moved from palacios/include/lwip/include/ipv4/lwip/ip.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/ip.h~ [moved from palacios/src/lwip/include/ipv4/lwip/ip.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/ip_addr.h [moved from palacios/include/lwip/include/ipv4/lwip/ip_addr.h with 100% similarity]
palacios/include/lwip/ipv4/lwip/ip_frag.h [moved from palacios/include/lwip/include/ipv4/lwip/ip_frag.h with 100% similarity]
palacios/include/lwip/ipv6/lwip/icmp.h [moved from palacios/include/lwip/include/ipv6/lwip/icmp.h with 100% similarity]
palacios/include/lwip/ipv6/lwip/inet.h [moved from palacios/include/lwip/include/ipv6/lwip/inet.h with 100% similarity]
palacios/include/lwip/ipv6/lwip/ip.h [moved from palacios/include/lwip/include/ipv6/lwip/ip.h with 100% similarity]
palacios/include/lwip/ipv6/lwip/ip_addr.h [moved from palacios/include/lwip/include/ipv6/lwip/ip_addr.h with 100% similarity]
palacios/include/lwip/lwip/api.h [moved from palacios/include/lwip/include/lwip/api.h with 100% similarity]
palacios/include/lwip/lwip/api_msg.h [moved from palacios/include/lwip/include/lwip/api_msg.h with 100% similarity]
palacios/include/lwip/lwip/arch.h [moved from palacios/src/lwip/include/lwip/arch.h with 98% similarity]
palacios/include/lwip/lwip/debug.h [moved from palacios/include/lwip/include/lwip/debug.h with 100% similarity]
palacios/include/lwip/lwip/def.h [moved from palacios/include/lwip/include/lwip/def.h with 100% similarity]
palacios/include/lwip/lwip/dhcp.h [moved from palacios/include/lwip/include/lwip/dhcp.h with 100% similarity]
palacios/include/lwip/lwip/dns.h [moved from palacios/include/lwip/include/lwip/dns.h with 100% similarity]
palacios/include/lwip/lwip/err.h [moved from palacios/include/lwip/include/lwip/err.h with 100% similarity]
palacios/include/lwip/lwip/init.h [moved from palacios/include/lwip/include/lwip/init.h with 100% similarity]
palacios/include/lwip/lwip/mem.h [moved from palacios/include/lwip/include/lwip/mem.h with 100% similarity]
palacios/include/lwip/lwip/memp.h [moved from palacios/include/lwip/include/lwip/memp.h with 100% similarity]
palacios/include/lwip/lwip/memp_std.h [moved from palacios/include/lwip/include/lwip/memp_std.h with 100% similarity]
palacios/include/lwip/lwip/netbuf.h [moved from palacios/include/lwip/include/lwip/netbuf.h with 100% similarity]
palacios/include/lwip/lwip/netdb.h [moved from palacios/include/lwip/include/lwip/netdb.h with 100% similarity]
palacios/include/lwip/lwip/netif.h [moved from palacios/include/lwip/include/lwip/netif.h with 100% similarity]
palacios/include/lwip/lwip/netifapi.h [moved from palacios/include/lwip/include/lwip/netifapi.h with 100% similarity]
palacios/include/lwip/lwip/opt.h [moved from palacios/include/lwip/include/lwip/opt.h with 100% similarity]
palacios/include/lwip/lwip/pbuf.h [moved from palacios/include/lwip/include/lwip/pbuf.h with 100% similarity]
palacios/include/lwip/lwip/raw.h [moved from palacios/include/lwip/include/lwip/raw.h with 100% similarity]
palacios/include/lwip/lwip/sio.h [moved from palacios/include/lwip/include/lwip/sio.h with 100% similarity]
palacios/include/lwip/lwip/snmp.h [moved from palacios/include/lwip/include/lwip/snmp.h with 100% similarity]
palacios/include/lwip/lwip/snmp_asn1.h [moved from palacios/include/lwip/include/lwip/snmp_asn1.h with 100% similarity]
palacios/include/lwip/lwip/snmp_msg.h [moved from palacios/include/lwip/include/lwip/snmp_msg.h with 100% similarity]
palacios/include/lwip/lwip/snmp_structs.h [moved from palacios/include/lwip/include/lwip/snmp_structs.h with 100% similarity]
palacios/include/lwip/lwip/sockets.h [moved from palacios/src/lwip/include/lwip/sockets.h with 93% similarity]
palacios/include/lwip/lwip/stats.h [moved from palacios/include/lwip/include/lwip/stats.h with 100% similarity]
palacios/include/lwip/lwip/sys.h [moved from palacios/include/lwip/include/lwip/sys.h with 100% similarity]
palacios/include/lwip/lwip/tcp.h [moved from palacios/include/lwip/include/lwip/tcp.h with 100% similarity]
palacios/include/lwip/lwip/tcpip.h [moved from palacios/include/lwip/include/lwip/tcpip.h with 100% similarity]
palacios/include/lwip/lwip/udp.h [moved from palacios/include/lwip/include/lwip/udp.h with 100% similarity]
palacios/include/lwip/lwipopts.h [new file with mode: 0644]
palacios/include/lwip/netif/etharp.h [moved from palacios/include/lwip/include/netif/etharp.h with 100% similarity]
palacios/include/lwip/netif/loopif.h [moved from palacios/include/lwip/include/netif/loopif.h with 100% similarity]
palacios/include/lwip/netif/ppp_oe.h [moved from palacios/include/lwip/include/netif/ppp_oe.h with 100% similarity]
palacios/include/lwip/netif/slipif.h [moved from palacios/include/lwip/include/netif/slipif.h with 100% similarity]
palacios/include/palacios/vmcs.h
palacios/include/palacios/vmcs_gen.h
palacios/include/palacios/vmm.h
palacios/include/palacios/vmm_types.h
palacios/src/common/string.c
palacios/src/devices/cdrom.c
palacios/src/devices/generic.c
palacios/src/devices/nvram.c
palacios/src/devices/ramdisk.c
palacios/src/geekos/mem.c
palacios/src/geekos/timer.c
palacios/src/lwip/FILES [deleted file]
palacios/src/lwip/api/sockets.c
palacios/src/lwip/arch/sys_arch.c [new file with mode: 0644]
palacios/src/lwip/build/Makefile [new file with mode: 0644]
palacios/src/lwip/include/ipv4/lwip/autoip.h [deleted file]
palacios/src/lwip/include/ipv4/lwip/icmp.h [deleted file]
palacios/src/lwip/include/ipv4/lwip/igmp.h [deleted file]
palacios/src/lwip/include/ipv4/lwip/inet.h [deleted file]
palacios/src/lwip/include/ipv4/lwip/ip_addr.h [deleted file]
palacios/src/lwip/include/ipv4/lwip/ip_frag.h [deleted file]
palacios/src/lwip/include/ipv6/lwip/icmp.h [deleted file]
palacios/src/lwip/include/ipv6/lwip/inet.h [deleted file]
palacios/src/lwip/include/ipv6/lwip/ip.h [deleted file]
palacios/src/lwip/include/ipv6/lwip/ip_addr.h [deleted file]
palacios/src/lwip/include/lwip/api.h [deleted file]
palacios/src/lwip/include/lwip/api_msg.h [deleted file]
palacios/src/lwip/include/lwip/debug.h [deleted file]
palacios/src/lwip/include/lwip/dhcp.h [deleted file]
palacios/src/lwip/include/lwip/dns.h [deleted file]
palacios/src/lwip/include/lwip/init.h [deleted file]
palacios/src/lwip/include/lwip/mem.h [deleted file]
palacios/src/lwip/include/lwip/memp.h [deleted file]
palacios/src/lwip/include/lwip/memp_std.h [deleted file]
palacios/src/lwip/include/lwip/netbuf.h [deleted file]
palacios/src/lwip/include/lwip/netdb.h [deleted file]
palacios/src/lwip/include/lwip/netif.h [deleted file]
palacios/src/lwip/include/lwip/netifapi.h [deleted file]
palacios/src/lwip/include/lwip/opt.h [deleted file]
palacios/src/lwip/include/lwip/pbuf.h [deleted file]
palacios/src/lwip/include/lwip/raw.h [deleted file]
palacios/src/lwip/include/lwip/sio.h [deleted file]
palacios/src/lwip/include/lwip/snmp.h [deleted file]
palacios/src/lwip/include/lwip/snmp_asn1.h [deleted file]
palacios/src/lwip/include/lwip/snmp_msg.h [deleted file]
palacios/src/lwip/include/lwip/snmp_structs.h [deleted file]
palacios/src/lwip/include/lwip/stats.h [deleted file]
palacios/src/lwip/include/lwip/sys.h [deleted file]
palacios/src/lwip/include/lwip/tcp.h [deleted file]
palacios/src/lwip/include/lwip/tcpip.h [deleted file]
palacios/src/lwip/include/lwip/udp.h [deleted file]
palacios/src/lwip/include/netif/etharp.h [deleted file]
palacios/src/lwip/include/netif/loopif.h [deleted file]
palacios/src/lwip/include/netif/ppp_oe.h [deleted file]
palacios/src/lwip/include/netif/slipif.h [deleted file]
palacios/src/lwip/netif/ppp/chap.h
palacios/src/lwip/netif/ppp/chpms.h
palacios/src/lwip/netif/ppp/fsm.h
palacios/src/lwip/netif/ppp/ipcp.h
palacios/src/lwip/netif/ppp/lcp.h
palacios/src/lwip/netif/ppp/magic.h
palacios/src/lwip/netif/ppp/vj.h
palacios/src/palacios/vmm_config.c
palacios/src/palacios/vmm_intr.c

index 12ae684..b01fc50 100644 (file)
@@ -183,16 +183,6 @@ endif
 #
 TCPSTACK=UIP
 
-#
-#RAMDISK
-#
-RAMDISK_SRCS=
-BOOT_FLAGS=
-
-ifeq ($(RAMDISK_BOOT),1)
-BOOT_FLAGS := $(BOOT_FLAGS) -DRAMDISK_BOOT
-RAMDISK_SRCS := ramdisk.c cdrom.c
-endif
 
 
 
@@ -295,7 +285,7 @@ VMM_OBJS := $(VMM_C_OBJS) $(VMM_ASM_OBJS)
 
 
 
-DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c $(RAMDISK_SRCS)
+DEVICE_C_SRCS := generic.c keyboard.c nvram.c timer.c simple_pic.c 8259a.c 8254.c serial.c ramdisk.c cdrom.c
 
 DEVICE_C_OBJS := $(DEVICE_C_SRCS:%.c=devices/%.o)
 
@@ -439,7 +429,7 @@ devices/%.o : devices/%.asm
        $(NASM) $(NASM_VMM_OPTS) $< -o devices/$*.o
 
 net/%.o : net/%.c
-       $(TARGET_CC) -c $(CC_GENERAL_OPTS) $(CC_VMM_OPTS)  $(CC_USER_OPTS) $< -o net/$*.o
+       $(TARGET_CC) -c $(CC_GENERAL_OPTS)  $(CC_USER_OPTS) $< -o net/$*.o
 
 # ----------------------------------------------------------------------
 # Targets -
@@ -498,6 +488,9 @@ pxe:        vmm.img
 run: vmm.img
        /usr/local/qemu/bin/qemu-system-x86_64 -m 1024 -serial file:serial.out -cdrom puppy.iso -fda vmm.img 
 
+iso: vmm.img
+       cp vmm.img iso/vmm.img
+       mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso
 
 
 
index 92227e2..fbd3d60 100644 (file)
@@ -25,3 +25,15 @@ mkisofs -pad -b <floppy_image> -R -o <iso_output_image> <floppy_image>
 
 
 /usr/local/qemu/bin/qemu-system-x86_64 -serial file:serial.out -m 1024 -fda vmm.img  -cdrom guest_no_timer.iso
+
+
+
+Creating a grub based bootable cd ISO image:
+
+mkidr iso
+mkdir -p iso/boot/grub
+
+get "menu.lst" and "stage2_eltorito" from the grub files located in vmm-tools/others
+copy menu.lst and stage2_eltorito into iso/boot/grub
+
+mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o test.iso iso 
diff --git a/palacios/build/iso/boot/grub/menu.lst b/palacios/build/iso/boot/grub/menu.lst
new file mode 100644 (file)
index 0000000..f3ed635
--- /dev/null
@@ -0,0 +1,9 @@
+default=0
+timeout=0
+title V3VEE 
+color light-green/brown blink-red/blue
+foreground bbbbbb
+background 000000
+root (cd)
+kernel /vmm.img
+initrd /puppy.iso
diff --git a/palacios/build/iso/boot/grub/stage2_eltorito b/palacios/build/iso/boot/grub/stage2_eltorito
new file mode 100644 (file)
index 0000000..9e1617c
Binary files /dev/null and b/palacios/build/iso/boot/grub/stage2_eltorito differ
index 4546f4f..fb49ad9 100644 (file)
@@ -7,17 +7,12 @@
 #ifndef __DEVICES_CDROM_H_
 #define __DEVICES_CDROM_H_
 
-#include <geekos/ktypes.h>
+#include <devices/ramdisk.h>
+#include <devices/ide.h>
+#include <palacios/vmm_types.h>
+
 
-typedef unsigned int rd_bool;
-typedef uchar_t Bit8u;
-typedef ushort_t Bit16u;
-typedef uint_t Bit32u;
-typedef ullong_t Bit64u;
 
-#define uint8 Bit8u 
-#define uint16 Bit16u 
-#define uint32 Bit32u 
 
 struct cdrom_interface;
 
@@ -38,17 +33,17 @@ struct cdrom_ops {
   /* 
    * Read CD TOC. Returns false if start track is out of bounds.
    */
-  rd_bool (*read_toc)(struct cdrom_interface *cdrom, uint8* buf, int* length, rd_bool msf, int start_track);
+  rd_bool (*read_toc)(struct cdrom_interface * cdrom, uint8_t * buf, int* length, rd_bool msf, int start_track);
   
   /* 
    * Return CD-ROM capacity (in 2048 byte frames)
    */
-  uint32 (*capacity)(struct cdrom_interface *cdrom);
+  uint32_t (*capacity)(struct cdrom_interface *cdrom);
   
   /*
    * Read a single block from the CD
    */
-  void (*read_block)(struct cdrom_interface *cdrom, uint8* buf, int lba);
+  void (*read_block)(struct cdrom_interface *cdrom, uint8_t* buf, int lba);
   
   /*
    * Start (spin up) the CD.
index c4a38b6..7a43e81 100644 (file)
@@ -1,8 +1,10 @@
 /* (c) 2008, Peter Dinda <pdinda@northwestern.edu> */
+/* (c) 2008, Jack Lange <jarusl@northwestern.edu> */
 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
 
-#ifndef __GENERIC_H
-#define __GENERIC_H
+#ifndef __GENERIC_H__
+#define __GENERIC_H__
+
 
 #include <palacios/vm_dev.h>
 
 #define GENERIC_PRINT_AND_PASSTHROUGH 0
 #define GENERIC_PRINT_AND_IGNORE      1
 
-// A port range is low..high, inclusive, third value is one of the above
-typedef uint_t generic_port_range_type[3];
-// A memory range is low..high, inclusive, flags
-typedef void *generic_address_range_type[3];
-// An interrupt ory map range is low..high, inclusive, flags
-typedef uint_t generic_irq_range_type[3];
+
+int v3_generic_add_port_range(struct vm_device * dev, uint_t start, uint_t end, uint_t type);
+int v3_generic_add_mem_range(struct vm_device * dev, void * start, void * end, uint_t type);
+int v3_generic_add_irq_range(struct vm_device * dev, uint_t start, uint_t end, uint_t type);
 
 // The lists given are null terminated
-struct vm_device *create_generic(generic_port_range_type    port_ranges[], 
-                                generic_address_range_type addess_ranges[],
-                                generic_irq_range_type     irq_ranges[]);  
+struct vm_device * create_generic();  
 
 #endif
diff --git a/palacios/include/devices/ide.h b/palacios/include/devices/ide.h
new file mode 100644 (file)
index 0000000..d35dfe8
--- /dev/null
@@ -0,0 +1,205 @@
+#ifndef __IDE_H__
+#define __IDE_H__
+
+
+#ifdef __V3VEE__
+#include <palacios/vmm_types.h>
+
+#ifdef __V3_32BIT__
+typedef long off_t;
+typedef sint32_t ssize_t;
+typedef unsigned int rd_bool;
+typedef uchar_t Bit8u;
+typedef ushort_t Bit16u;
+typedef uint32_t Bit32u;
+typedef uint64_t Bit64u;
+#endif
+
+
+#define MAX_ATA_CHANNEL 4
+
+typedef enum _sense {
+      SENSE_NONE = 0, 
+      SENSE_NOT_READY = 2, 
+      SENSE_ILLEGAL_REQUEST = 5,
+      SENSE_UNIT_ATTENTION = 6
+} sense_t ;
+
+typedef enum _asc {
+      ASC_INV_FIELD_IN_CMD_PACKET = 0x24,
+      ASC_MEDIUM_NOT_PRESENT = 0x3a,
+      ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39,
+      ASC_LOGICAL_BLOCK_OOR = 0x21
+} asc_t ;
+
+
+
+typedef struct  {
+  unsigned cylinders;
+  unsigned heads;
+  unsigned sectors;
+} device_image_t;
+
+
+
+
+struct interrupt_reason_t {
+  unsigned  c_d : 1; 
+  unsigned  i_o : 1; 
+  unsigned  rel : 1; 
+  unsigned  tag : 5; 
+};
+
+
+struct controller_status {
+  rd_bool busy;
+  rd_bool drive_ready;
+  rd_bool write_fault;
+  rd_bool seek_complete;
+  rd_bool drq;
+  rd_bool corrected_data;
+  rd_bool index_pulse;
+  unsigned int index_pulse_count;
+  rd_bool err;
+};
+
+
+
+
+
+struct  sense_info_t {
+  sense_t sense_key;
+
+  struct  {
+    Bit8u arr[4];
+  } information;
+
+  struct  {
+    Bit8u arr[4];
+  } specific_inf;
+
+  struct  {
+    Bit8u arr[3];
+  } key_spec;
+
+  Bit8u fruc;
+  Bit8u asc;
+  Bit8u ascq;
+};
+
+
+struct  error_recovery_t {
+  unsigned char data[8];
+};
+
+struct  cdrom_t {
+  rd_bool ready;
+  rd_bool locked;
+
+  struct cdrom_interface * cd;
+
+  uint32_t capacity;
+  int next_lba;
+  int remaining_blocks;
+
+  struct  currentStruct {
+    struct error_recovery_t error_recovery;
+  } current;
+
+};
+
+struct  atapi_t {
+  uint8_t command;
+  int drq_bytes;
+  int total_bytes_remaining;
+};
+
+
+typedef enum { IDE_NONE, IDE_DISK, IDE_CDROM } device_type_t;
+
+struct controller_t  {
+  struct controller_status status;
+  Bit8u    error_register;
+  Bit8u    head_no;
+
+  union {
+    Bit8u    sector_count;
+    struct interrupt_reason_t interrupt_reason;
+  };
+
+
+  Bit8u    sector_no;
+
+  union  {
+    Bit16u   cylinder_no;
+    Bit16u   byte_count;
+  };
+
+  Bit8u    buffer[2048]; 
+  Bit32u   buffer_index;
+  Bit32u   drq_index;
+  Bit8u    current_command;
+  Bit8u    sectors_per_block;
+  Bit8u    lba_mode;
+
+  struct  {
+    rd_bool reset;       // 0=normal, 1=reset controller
+    rd_bool disable_irq;     // 0=allow irq, 1=disable irq
+  } control;
+
+  Bit8u    reset_in_progress;
+  Bit8u    features;
+};
+
+
+
+
+struct  drive_t {
+  device_image_t  hard_drive;
+  device_type_t device_type;
+  // 512 byte buffer for ID drive command
+  // These words are stored in native word endian format, as
+  // they are fetched and returned via a return(), so
+  // there's no need to keep them in x86 endian format.
+  Bit16u id_drive[256];
+  
+  struct controller_t controller;
+  struct cdrom_t cdrom;
+  struct sense_info_t sense;
+  struct atapi_t atapi;
+  
+  Bit8u model_no[41];
+};
+
+
+// FIXME:
+// For each ATA channel we should have one controller struct
+// and an array of two drive structs
+struct  channel_t {
+  struct drive_t drives[2];
+  unsigned drive_select;
+  
+  Bit16u ioaddr1;
+  Bit16u ioaddr2;
+  Bit8u  irq;
+};
+
+
+
+struct  ramdisk_t {
+  struct channel_t channels[MAX_ATA_CHANNEL];
+};
+
+
+
+
+
+
+
+
+
+#endif // ! __V3VEE__
+
+
+#endif
+
index 2ecfe04..77eb44d 100644 (file)
 #ifndef __DEVICES_RAMDISK_H_
 #define __DEVICES_RAMDISK_H_
 
-#include <stddef.h> //for off_t in C99
-#include <sys/types.h> //for size_t 
-#include <geekos/ktypes.h>
-#include <devices/cdrom.h>
+#include <palacios/vmm_types.h>
 #include <palacios/vm_dev.h>
 
-#define INDEX_PULSE_CYCLE 10
 
-#define MAX_ATA_CHANNEL 4
-#define RD_LITTLE_ENDIAN
 
 
-#define INTR_REASON_BIT_ERR           0x01
-#define UNABLE_FIND_TAT_CHANNEL_ERR   0x02
-#define DRQ_ERR                       0x03
-#define READ_BUF_GT_512               0x04
 
 
-typedef enum _sense {
-      SENSE_NONE = 0, SENSE_NOT_READY = 2, SENSE_ILLEGAL_REQUEST = 5,
-      SENSE_UNIT_ATTENTION = 6
-} sense_t ;
-
-typedef enum _asc {
-      ASC_INV_FIELD_IN_CMD_PACKET = 0x24,
-      ASC_MEDIUM_NOT_PRESENT = 0x3a,
-      ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39,
-      ASC_LOGICAL_BLOCK_OOR = 0x21
-} asc_t ;
-
-
-// FLAT MODE
-// Open a image. Returns non-negative if successful.
-//int open (const char* pathname);
-
-// Open an image with specific flags. Returns non-negative if successful.
-int rd_open (const char* pathname, int flags);
-
-// Close the image.
-void rd_close ();
-
-// Position ourselves. Return the resulting offset from the
-// beginning of the file.
-off_t rd_lseek (off_t offset, int whence);
-
-// Read count bytes to the buffer buf. Return the number of
-// bytes read (count).
-ssize_t rd_read (void* buf, size_t count);
-
-// Write count bytes from buf. Return the number of bytes
-// written (count).
-ssize_t rd_write (const void* buf, size_t count);
-
-
-typedef struct  {
-
-      unsigned cylinders               ;
-      unsigned heads                   ;
-      unsigned sectors                 ;
-
-  //iso file descriptor
-      int fd                           ;
-} device_image_t;
-
-
-
-struct  controller_t {
-  struct  {
-    rd_bool busy                       ;
-    rd_bool drive_ready                ;
-    rd_bool write_fault                ;
-    rd_bool seek_complete              ;
-    rd_bool drq                        ;
-    rd_bool corrected_data             ;
-    rd_bool index_pulse                ;
-    unsigned int index_pulse_count     ;
-    rd_bool err                        ;
-    } status;
-  Bit8u    error_register              ;
-  Bit8u    head_no                     ;
-  union  {
-    Bit8u    sector_count              ;
-    struct  {
-#ifdef RD_LITTLE_ENDIAN
-      unsigned  c_d : 1; 
-      unsigned  i_o : 1; 
-      unsigned  rel : 1; 
-      unsigned  tag : 5; 
-
-#else  /* RD_BIG_ENDIAN */
-      unsigned tag : 5;
-      unsigned rel : 1;
-      unsigned i_o : 1;
-      unsigned c_d : 1;
-#endif
-      
-    } interrupt_reason;
-  };
-  Bit8u    sector_no                   ;
-  union  {
-    Bit16u   cylinder_no               ;
-    Bit16u   byte_count                ;
-  };
-  Bit8u    buffer[2048];               ; 
-  Bit32u   buffer_index                ;
-  Bit32u   drq_index                   ;
-  Bit8u    current_command             ;
-  Bit8u    sectors_per_block           ;
-  Bit8u    lba_mode                    ;
-  struct  {
-    // 0=normal, 1=reset controller
-    rd_bool reset                      ;       
-    // 0=allow irq, 1=disable irq
-    rd_bool disable_irq                ; 
-    } control;
-  Bit8u    reset_in_progress           ;
-  Bit8u    features                    ;
-  };
-
-struct  sense_info_t{
-  sense_t sense_key                    ;
-  struct  {
-    Bit8u arr[4]                       ;
-  } information;
-  struct  {
-    Bit8u arr[4]                       ;
-  } specific_inf;
-  struct  {
-    Bit8u arr[3]                       ;
-  } key_spec;
-  Bit8u fruc                           ;
-  Bit8u asc                            ;
-  Bit8u ascq                           ;
-};
-
-struct  error_recovery_t {
-  unsigned char data[8]                ;
-
-  //  error_recovery_t ();
-};
-
-uint16 rd_read_16bit(const uint8* buf); //__attribute__(regparm(1))
-uint32 rd_read_32bit(const uint8* buf); //__attribute__(regparm(1))
-
-struct  cdrom_t {
-  rd_bool ready                                      ;
-  rd_bool locked                                     ;
-
-
-  struct cdrom_interface *cd                         ;
-
-  uint32 capacity                                    ;
-  int next_lba                                       ;
-  int remaining_blocks                               ;
-  struct  currentStruct {
-    struct error_recovery_t error_recovery           ;
-  } current;
-};
-
-struct  atapi_t {
-  uint8 command                                      ;
-  int drq_bytes                                      ;
-  int total_bytes_remaining                          ;
-};
-
-
-typedef enum {
-      IDE_NONE, IDE_DISK, IDE_CDROM
-} device_type_t ;
-
-
-  // FIXME:
-  // For each ATA channel we should have one controller struct
-  // and an array of two drive structs
-struct  channel_t {
-    struct  drive_t {
-      device_image_t  hard_drive                     ;
-      device_type_t device_type                      ;
-      // 512 byte buffer for ID drive command
-      // These words are stored in native word endian format, as
-      // they are fetched and returned via a return(), so
-      // there's no need to keep them in x86 endian format.
-      Bit16u id_drive[256]                           ;
-
-      struct controller_t controller                 ;
-      struct cdrom_t cdrom                           ;
-      struct sense_info_t sense                      ;
-      struct atapi_t atapi                           ;
-
-      Bit8u model_no[41]                             ;
-      } drives[2];
-    unsigned drive_select                            ;
-
-    Bit16u ioaddr1                                   ;
-    Bit16u ioaddr2                                   ;
-    Bit8u  irq                                       ;
-};
-
-struct ramdisk_t;
-
-struct ramdisk_ctrl_ops {
-  Bit32u (*init)(struct ramdisk_t *ramdisk,
-                struct vm_device *dev);
-  void   (*close)(struct ramdisk_t *ramdisk);
-  void   (*reset)(struct ramdisk_t *ramdisk, unsigned type);
-
-};
-
-struct ramdisk_emu_ops {
-
-  uint_t (*read_port)(ushort_t port,
-                     void *src,
-                     uint_t length,
-                     struct vm_device *dev);
-
-  uint_t (*write_port)(ushort_t port,
-                      void *src,
-                      uint_t length,
-                      struct vm_device *dev);
-
-  uint_t (*read_port_ignore)(ushort_t port,
-                            void *src,
-                            uint_t length,
-                            struct vm_device *dev);
-
-  uint_t (*write_port_ignore)(ushort_t port,
-                             void *src,
-                             uint_t length,
-                             struct vm_device *dev);
-};
-
-
-struct  ramdisk_t {
-  
-  struct channel_t channels[MAX_ATA_CHANNEL]         ;
-
-  struct ramdisk_ctrl_ops cops;
-
-  struct ramdisk_emu_ops eops;
-
-  void *private_data                                 ;
-  //  struct vm_device *dev;
-};
-
-struct ramdisk_t * create_ramdisk(void);
+struct vm_device * create_ramdisk(void);
 
 #endif
index b1ad875..31bad01 100644 (file)
@@ -32,12 +32,14 @@ struct Condition {
 void Mutex_Init(struct Mutex* mutex);
 void Mutex_Lock(struct Mutex* mutex);
 void Mutex_Unlock(struct Mutex* mutex);
+void Mutex_Destroy(struct Mutex *mutex);  
 
 void Cond_Init(struct Condition* cond);
 void Cond_Wait(struct Condition* cond, struct Mutex* mutex);
 int Cond_Wait_Timeout(struct Condition * cond, struct Mutex * mutex, uint_t ms);
 void Cond_Signal(struct Condition* cond);
 void Cond_Broadcast(struct Condition* cond);
+void Cond_Destroy(struct Condition *cond); 
 
 #define IS_HELD(mutex) \
     ((mutex)->state == MUTEX_LOCKED && (mutex)->owner == g_currentThread)
index 9b08713..f6add16 100644 (file)
@@ -36,12 +36,12 @@ int Start_Timer_Secs(int seconds, timerCallback cb, void * arg);
 int Start_Timer_MSecs(int msecs, timerCallback cb, void * arg);
 int Start_Timer(int ticks, timerCallback, void * arg);
 
+
 double Get_Remaining_Timer_Secs(int id);
 int Get_Remaining_Timer_MSecs(int id);
 int Get_Remaining_Timer_Ticks(int id);
 int Cancel_Timer(int id);
 
-
 void Micro_Delay(int us);
 
 #endif  /* GEEKOS_TIMER_H */
similarity index 52%
rename from palacios/src/lwip/include/lwip/err.h
rename to palacios/include/lwip/arch/cc.h
index e506323..73eb7d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
  * All rights reserved. 
  * 
  * Redistribution and use in source and binary forms, with or without modification, 
  * Author: Adam Dunkels <adam@sics.se>
  *
  */
-#ifndef __LWIP_ERR_H__
-#define __LWIP_ERR_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef s8_t err_t;
-
-/* Definitions for error constants. */
-
-#define ERR_OK          0    /* No error, everything OK. */
-#define ERR_MEM        -1    /* Out of memory error.     */
-#define ERR_BUF        -2    /* Buffer error.            */
-#define ERR_RTE        -3    /* Routing problem.         */
-
-#define ERR_IS_FATAL(e) ((e) < ERR_RTE)
-
-#define ERR_ABRT       -4    /* Connection aborted.      */
-#define ERR_RST        -5    /* Connection reset.        */
-#define ERR_CLSD       -6    /* Connection closed.       */
-#define ERR_CONN       -7    /* Not connected.           */
-
-#define ERR_VAL        -8    /* Illegal value.           */
-
-#define ERR_ARG        -9    /* Illegal argument.        */
-
-#define ERR_USE        -10   /* Address in use.          */
-
-#define ERR_IF         -11   /* Low-level netif error    */
-#define ERR_ISCONN     -12   /* Already connected.       */
-
-#define ERR_TIMEOUT    -13   /* Timeout.                 */
-
-#define ERR_INPROGRESS -14   /* Operation in progress    */
-
-
-#ifdef LWIP_DEBUG
-extern const char *lwip_strerr(err_t err);
-#else
-#define lwip_strerr(x) ""
-#endif /* LWIP_DEBUG */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_ERR_H__ */
+#ifndef __ARCH_CC_H__
+#define __ARCH_CC_H__
+
+/* Include some files for defining library routines */
+
+#include <string.h>
+
+extern int fflush(FILE *file);
+extern int printf(char *fmt, ...);
+extern void abort (void);
+
+
+/* Define platform endianness */
+#ifndef BYTE_ORDER
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif /* BYTE_ORDER */
+
+/* Define generic types used in lwIP */
+typedef unsigned   char    u8_t;
+typedef signed     char    s8_t;
+typedef unsigned   short   u16_t;
+typedef signed     short   s16_t;
+typedef unsigned   long    u32_t;
+typedef signed     long    s32_t;
+
+typedef u32_t mem_ptr_t;
+
+/* Define (sn)printf formatters for these lwIP types */
+#define U16_F "hu"
+#define S16_F "hd"
+#define X16_F "hx"
+#define U32_F "lu"
+#define S32_F "ld"
+#define X32_F "lx"
+
+/* Compiler hints for packing structures */
+#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
+#define PACK_STRUCT_STRUCT __attribute__((packed))
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_END
+
+/* prototypes for printf() and abort() */
+//#include <stdio.h>
+//#include <stdlib.h>
+/* Plaform specific diagnostic output */
+#define LWIP_PLATFORM_DIAG(x)  //do {printf x;} while(0)
+
+#define LWIP_PLATFORM_ASSERT(x)   do {printf("Assertion \"%s\" failed at line %d in %s\n", \
+                                   x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) 
+                                    
+#endif /* __ARCH_CC_H__ */
similarity index 58%
rename from palacios/src/lwip/include/ipv4/lwip/inet_chksum.h
rename to palacios/include/lwip/arch/perf.h
index d7c7492..1daebac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
  * All rights reserved. 
  * 
  * Redistribution and use in source and binary forms, with or without modification, 
  * Author: Adam Dunkels <adam@sics.se>
  *
  */
-#ifndef __LWIP_INET_CHKSUM_H__
-#define __LWIP_INET_CHKSUM_H__
+#ifndef __ARCH_PERF_H__
+#define __ARCH_PERF_H__
 
-#include "lwip/opt.h"
+//#include <sys/times.h>
 
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
+#ifdef PERF
+#define PERF_START  { \
+                         unsigned long __c1l, __c1h, __c2l, __c2h; \
+                         __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h))
+#define PERF_STOP(x)   __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \
+                       perf_print(__c1l, __c1h, __c2l, __c2h, x);}
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+/*#define PERF_START do { \
+                     struct tms __perf_start, __perf_end; \
+                     times(&__perf_start)
+#define PERF_STOP(x) times(&__perf_end); \
+                     perf_print_times(&__perf_start, &__perf_end, x);\
+                     } while(0)*/
+#else /* PERF */
+#define PERF_START    /* null definition */
+#define PERF_STOP(x)  /* null definition */
+#endif /* PERF */
 
-u16_t inet_chksum(void *dataptr, u16_t len);
-u16_t inet_chksum_pbuf(struct pbuf *p);
-u16_t inet_chksum_pseudo(struct pbuf *p,
-       struct ip_addr *src, struct ip_addr *dest,
-       u8_t proto, u16_t proto_len);
-u16_t inet_chksum_pseudo_partial(struct pbuf *p,
-       struct ip_addr *src, struct ip_addr *dest,
-       u8_t proto, u16_t proto_len, u16_t chksum_len);
+void perf_print(unsigned long c1l, unsigned long c1h,
+               unsigned long c2l, unsigned long c2h,
+               char *key);
 
-#ifdef __cplusplus
-}
-#endif
+void perf_print_times(struct tms *start, struct tms *end, char *key);
 
-#endif /* __LWIP_INET_H__ */
+void perf_init(char *fname);
 
+#endif /* __ARCH_PERF_H__ */
similarity index 78%
rename from palacios/src/lwip/include/lwip/def.h
rename to palacios/include/lwip/arch/sys_arch.h
index d2ed251..99757be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
  * All rights reserved. 
  * 
  * Redistribution and use in source and binary forms, with or without modification, 
  * Author: Adam Dunkels <adam@sics.se>
  *
  */
-#ifndef __LWIP_DEF_H__
-#define __LWIP_DEF_H__
+#ifndef __ARCH_SYS_ARCH_H__
+#define __ARCH_SYS_ARCH_H__
 
-/* this might define NULL already */
-#include "lwip/arch.h"
+//#include <errno.h>
 
-#define LWIP_MAX(x , y)  (((x) > (y)) ? (x) : (y))
-#define LWIP_MIN(x , y)  (((x) < (y)) ? (x) : (y))
+#define SYS_MBOX_NULL NULL
+#define SYS_SEM_NULL  NULL
 
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
+typedef u32_t sys_prot_t;
 
+struct sys_sem;
+typedef struct sys_sem * sys_sem_t;
 
-#endif /* __LWIP_DEF_H__ */
+struct sys_mbox;
+typedef struct sys_mbox *sys_mbox_t;
+
+struct sys_thread;
+typedef struct sys_thread * sys_thread_t;
+
+#endif /* __ARCH_SYS_ARCH_H__ */
 
diff --git a/palacios/include/lwip/include/lwip/arch.h b/palacios/include/lwip/include/lwip/arch.h
deleted file mode 100644 (file)
index 7d1400b..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_ARCH_H__
-#define __LWIP_ARCH_H__
-
-#ifndef LITTLE_ENDIAN
-#define LITTLE_ENDIAN 1234
-#endif
-
-#ifndef BIG_ENDIAN
-#define BIG_ENDIAN 4321
-#endif
-
-#include "arch/cc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef PACK_STRUCT_BEGIN
-#define PACK_STRUCT_BEGIN
-#endif /* PACK_STRUCT_BEGIN */
-
-#ifndef PACK_STRUCT_END
-#define PACK_STRUCT_END
-#endif /* PACK_STRUCT_END */
-
-#ifndef PACK_STRUCT_FIELD
-#define PACK_STRUCT_FIELD(x) x
-#endif /* PACK_STRUCT_FIELD */
-
-
-#ifndef LWIP_UNUSED_ARG
-#define LWIP_UNUSED_ARG(x) (void)x
-#endif /* LWIP_UNUSED_ARG */ 
-
-
-#ifdef LWIP_PROVIDE_ERRNO
-
-#define  EPERM     1  /* Operation not permitted */
-#define  ENOENT     2  /* No such file or directory */
-#define  ESRCH     3  /* No such process */
-#define  EINTR     4  /* Interrupted system call */
-#define  EIO     5  /* I/O error */
-#define  ENXIO     6  /* No such device or address */
-#define  E2BIG     7  /* Arg list too long */
-#define  ENOEXEC     8  /* Exec format error */
-#define  EBADF     9  /* Bad file number */
-#define  ECHILD    10  /* No child processes */
-#define  EAGAIN    11  /* Try again */
-#define  ENOMEM    12  /* Out of memory */
-#define  EACCES    13  /* Permission denied */
-#define  EFAULT    14  /* Bad address */
-#define  ENOTBLK    15  /* Block device required */
-#define  EBUSY    16  /* Device or resource busy */
-#define  EEXIST    17  /* File exists */
-#define  EXDEV    18  /* Cross-device link */
-#define  ENODEV    19  /* No such device */
-#define  ENOTDIR    20  /* Not a directory */
-#define  EISDIR    21  /* Is a directory */
-#define  EINVAL    22  /* Invalid argument */
-#define  ENFILE    23  /* File table overflow */
-#define  EMFILE    24  /* Too many open files */
-#define  ENOTTY    25  /* Not a typewriter */
-#define  ETXTBSY    26  /* Text file busy */
-#define  EFBIG    27  /* File too large */
-#define  ENOSPC    28  /* No space left on device */
-#define  ESPIPE    29  /* Illegal seek */
-#define  EROFS    30  /* Read-only file system */
-#define  EMLINK    31  /* Too many links */
-#define  EPIPE    32  /* Broken pipe */
-#define  EDOM    33  /* Math argument out of domain of func */
-#define  ERANGE    34  /* Math result not representable */
-#define  EDEADLK    35  /* Resource deadlock would occur */
-#define  ENAMETOOLONG  36  /* File name too long */
-#define  ENOLCK    37  /* No record locks available */
-#define  ENOSYS    38  /* Function not implemented */
-#define  ENOTEMPTY  39  /* Directory not empty */
-#define  ELOOP    40  /* Too many symbolic links encountered */
-#define  EWOULDBLOCK  EAGAIN  /* Operation would block */
-#define  ENOMSG    42  /* No message of desired type */
-#define  EIDRM    43  /* Identifier removed */
-#define  ECHRNG    44  /* Channel number out of range */
-#define  EL2NSYNC  45  /* Level 2 not synchronized */
-#define  EL3HLT    46  /* Level 3 halted */
-#define  EL3RST    47  /* Level 3 reset */
-#define  ELNRNG    48  /* Link number out of range */
-#define  EUNATCH    49  /* Protocol driver not attached */
-#define  ENOCSI    50  /* No CSI structure available */
-#define  EL2HLT    51  /* Level 2 halted */
-#define  EBADE    52  /* Invalid exchange */
-#define  EBADR    53  /* Invalid request descriptor */
-#define  EXFULL    54  /* Exchange full */
-#define  ENOANO    55  /* No anode */
-#define  EBADRQC    56  /* Invalid request code */
-#define  EBADSLT    57  /* Invalid slot */
-
-#define  EDEADLOCK  EDEADLK
-
-#define  EBFONT    59  /* Bad font file format */
-#define  ENOSTR    60  /* Device not a stream */
-#define  ENODATA    61  /* No data available */
-#define  ETIME    62  /* Timer expired */
-#define  ENOSR    63  /* Out of streams resources */
-#define  ENONET    64  /* Machine is not on the network */
-#define  ENOPKG    65  /* Package not installed */
-#define  EREMOTE    66  /* Object is remote */
-#define  ENOLINK    67  /* Link has been severed */
-#define  EADV    68  /* Advertise error */
-#define  ESRMNT    69  /* Srmount error */
-#define  ECOMM    70  /* Communication error on send */
-#define  EPROTO    71  /* Protocol error */
-#define  EMULTIHOP  72  /* Multihop attempted */
-#define  EDOTDOT    73  /* RFS specific error */
-#define  EBADMSG    74  /* Not a data message */
-#define  EOVERFLOW  75  /* Value too large for defined data type */
-#define  ENOTUNIQ  76  /* Name not unique on network */
-#define  EBADFD    77  /* File descriptor in bad state */
-#define  EREMCHG    78  /* Remote address changed */
-#define  ELIBACC    79  /* Can not access a needed shared library */
-#define  ELIBBAD    80  /* Accessing a corrupted shared library */
-#define  ELIBSCN    81  /* .lib section in a.out corrupted */
-#define  ELIBMAX    82  /* Attempting to link in too many shared libraries */
-#define  ELIBEXEC  83  /* Cannot exec a shared library directly */
-#define  EILSEQ    84  /* Illegal byte sequence */
-#define  ERESTART  85  /* Interrupted system call should be restarted */
-#define  ESTRPIPE  86  /* Streams pipe error */
-#define  EUSERS    87  /* Too many users */
-#define  ENOTSOCK  88  /* Socket operation on non-socket */
-#define  EDESTADDRREQ  89  /* Destination address required */
-#define  EMSGSIZE  90  /* Message too long */
-#define  EPROTOTYPE  91  /* Protocol wrong type for socket */
-#define  ENOPROTOOPT  92  /* Protocol not available */
-#define  EPROTONOSUPPORT  93  /* Protocol not supported */
-#define  ESOCKTNOSUPPORT  94  /* Socket type not supported */
-#define  EOPNOTSUPP  95  /* Operation not supported on transport endpoint */
-#define  EPFNOSUPPORT  96  /* Protocol family not supported */
-#define  EAFNOSUPPORT  97  /* Address family not supported by protocol */
-#define  EADDRINUSE  98  /* Address already in use */
-#define  EADDRNOTAVAIL  99  /* Cannot assign requested address */
-#define  ENETDOWN  100  /* Network is down */
-#define  ENETUNREACH  101  /* Network is unreachable */
-#define  ENETRESET  102  /* Network dropped connection because of reset */
-#define  ECONNABORTED  103  /* Software caused connection abort */
-#define  ECONNRESET  104  /* Connection reset by peer */
-#define  ENOBUFS    105  /* No buffer space available */
-#define  EISCONN    106  /* Transport endpoint is already connected */
-#define  ENOTCONN  107  /* Transport endpoint is not connected */
-#define  ESHUTDOWN  108  /* Cannot send after transport endpoint shutdown */
-#define  ETOOMANYREFS  109  /* Too many references: cannot splice */
-#define  ETIMEDOUT  110  /* Connection timed out */
-#define  ECONNREFUSED  111  /* Connection refused */
-#define  EHOSTDOWN  112  /* Host is down */
-#define  EHOSTUNREACH  113  /* No route to host */
-#define  EALREADY  114  /* Operation already in progress */
-#define  EINPROGRESS  115  /* Operation now in progress */
-#define  ESTALE    116  /* Stale NFS file handle */
-#define  EUCLEAN    117  /* Structure needs cleaning */
-#define  ENOTNAM    118  /* Not a XENIX named type file */
-#define  ENAVAIL    119  /* No XENIX semaphores available */
-#define  EISNAM    120  /* Is a named type file */
-#define  EREMOTEIO  121  /* Remote I/O error */
-#define  EDQUOT    122  /* Quota exceeded */
-
-#define  ENOMEDIUM  123  /* No medium found */
-#define  EMEDIUMTYPE  124  /* Wrong medium type */
-
-
-#define ENSROK    0 /* DNS server returned answer with no data */
-#define ENSRNODATA  160 /* DNS server returned answer with no data */
-#define ENSRFORMERR 161 /* DNS server claims query was misformatted */
-#define ENSRSERVFAIL 162  /* DNS server returned general failure */
-#define ENSRNOTFOUND 163  /* Domain name not found */
-#define ENSRNOTIMP  164 /* DNS server does not implement requested operation */
-#define ENSRREFUSED 165 /* DNS server refused query */
-#define ENSRBADQUERY 166  /* Misformatted DNS query */
-#define ENSRBADNAME 167 /* Misformatted domain name */
-#define ENSRBADFAMILY 168 /* Unsupported address family */
-#define ENSRBADRESP 169 /* Misformatted DNS reply */
-#define ENSRCONNREFUSED 170 /* Could not contact DNS servers */
-#define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */
-#define ENSROF    172 /* End of file */
-#define ENSRFILE  173 /* Error reading file */
-#define ENSRNOMEM 174 /* Out of memory */
-#define ENSRDESTRUCTION 175 /* Application terminated lookup */
-#define ENSRQUERYDOMAINTOOLONG  176 /* Domain name is too long */
-#define ENSRCNAMELOOP 177 /* Domain name is too long */
-
-#ifndef errno
-extern int errno;
-#endif
-
-#endif /* LWIP_PROVIDE_ERRNO */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_ARCH_H__ */
diff --git a/palacios/include/lwip/include/lwip/sockets.h b/palacios/include/lwip/include/lwip/sockets.h
deleted file mode 100644 (file)
index 603b62f..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-
-
-#ifndef __LWIP_SOCKETS_H__
-#define __LWIP_SOCKETS_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/ip_addr.h"
-#include "lwip/inet.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* members are in network byte order */
-struct sockaddr_in {
-  u8_t sin_len;
-  u8_t sin_family;
-  u16_t sin_port;
-  struct in_addr sin_addr;
-  char sin_zero[8];
-};
-
-struct sockaddr {
-  u8_t sa_len;
-  u8_t sa_family;
-  char sa_data[14];
-};
-
-#ifndef socklen_t
-#  define socklen_t u32_t
-#endif
-
-/* Socket protocol types (TCP/UDP/RAW) */
-#define SOCK_STREAM     1
-#define SOCK_DGRAM      2
-#define SOCK_RAW        3
-
-/*
- * Option flags per-socket. These must match the SOF_ flags in ip.h!
- */
-#define  SO_DEBUG       0x0001 /* Unimplemented: turn on debugging info recording */
-#define  SO_ACCEPTCONN  0x0002 /* socket has had listen() */
-#define  SO_REUSEADDR   0x0004 /* Unimplemented: allow local address reuse */
-#define  SO_KEEPALIVE   0x0008 /* keep connections alive */
-#define  SO_DONTROUTE   0x0010 /* Unimplemented: just use interface addresses */
-#define  SO_BROADCAST   0x0020 /* Unimplemented: permit sending of broadcast msgs */
-#define  SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */
-#define  SO_LINGER      0x0080 /* linger on close if data present */
-#define  SO_OOBINLINE   0x0100 /* Unimplemented: leave received OOB data in line */
-#define  SO_REUSEPORT   0x0200 /* Unimplemented: allow local address & port reuse */
-
-#define SO_DONTLINGER   ((int)(~SO_LINGER))
-
-/*
- * Additional options, not kept in so_options.
- */
-#define SO_SNDBUF    0x1001    /* Unimplemented: send buffer size */
-#define SO_RCVBUF    0x1002    /* receive buffer size */
-#define SO_SNDLOWAT  0x1003    /* Unimplemented: send low-water mark */
-#define SO_RCVLOWAT  0x1004    /* Unimplemented: receive low-water mark */
-#define SO_SNDTIMEO  0x1005    /* Unimplemented: send timeout */
-#define SO_RCVTIMEO  0x1006    /* receive timeout */
-#define SO_ERROR     0x1007    /* get error status and clear */
-#define SO_TYPE      0x1008    /* get socket type */
-#define SO_CONTIMEO  0x1009    /* Unimplemented: connect timeout */
-#define SO_NO_CHECK  0x100a    /* don't create UDP checksum */
-
-
-/*
- * Structure used for manipulating linger option.
- */
-struct linger {
-       int l_onoff;                /* option on/off */
-       int l_linger;               /* linger time */
-};
-
-/*
- * Level number for (get/set)sockopt() to apply to socket itself.
- */
-#define  SOL_SOCKET  0xfff    /* options for socket level */
-
-
-#define AF_UNSPEC       0
-#define AF_INET         2
-#define PF_INET         AF_INET
-#define PF_UNSPEC       AF_UNSPEC
-
-#define IPPROTO_IP      0
-#define IPPROTO_TCP     6
-#define IPPROTO_UDP     17
-#define IPPROTO_UDPLITE 136
-
-#define INADDR_ANY       0
-#define INADDR_BROADCAST 0xffffffff
-
-/* Flags we can use with send and recv. */
-#define MSG_PEEK       0x01    /* Peeks at an incoming message */
-#define MSG_WAITALL    0x02    /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */
-#define MSG_OOB        0x04    /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */
-#define MSG_DONTWAIT   0x08    /* Nonblocking i/o for this operation only */
-#define MSG_MORE       0x10    /* Sender will send more */
-
-
-/*
- * Options for level IPPROTO_IP
- */
-#define IP_TOS             1
-#define IP_TTL             2
-
-#if LWIP_TCP
-/*
- * Options for level IPPROTO_TCP
- */
-#define TCP_NODELAY    0x01    /* don't delay send to coalesce packets */
-#define TCP_KEEPALIVE  0x02    /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
-#define TCP_KEEPIDLE   0x03    /* set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
-#define TCP_KEEPINTVL  0x04    /* set pcb->keep_intvl - Use seconds for get/setsockopt */
-#define TCP_KEEPCNT    0x05    /* set pcb->keep_cnt   - Use number of probes sent for get/setsockopt */
-#endif /* LWIP_TCP */
-
-#if LWIP_UDP && LWIP_UDPLITE
-/*
- * Options for level IPPROTO_UDPLITE
- */
-#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */
-#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */
-#endif /* LWIP_UDP && LWIP_UDPLITE*/
-
-
-#if LWIP_IGMP
-/*
- * Options and types for UDP multicast traffic handling
- */
-#define IP_ADD_MEMBERSHIP  3
-#define IP_DROP_MEMBERSHIP 4
-#define IP_MULTICAST_TTL   5
-#define IP_MULTICAST_IF    6
-#define IP_MULTICAST_LOOP  7
-
-typedef struct ip_mreq {
-    struct in_addr imr_multiaddr; /* IP multicast address of group */
-    struct in_addr imr_interface; /* local IP address of interface */
-} ip_mreq;
-#endif /* LWIP_IGMP */
-
-/* Unimplemented for now... */
-#define IPTOS_TOS_MASK          0x1E
-#define IPTOS_TOS(tos)          ((tos) & IPTOS_TOS_MASK)
-#define IPTOS_LOWDELAY          0x10
-#define IPTOS_THROUGHPUT        0x08
-#define IPTOS_RELIABILITY       0x04
-#define IPTOS_LOWCOST           0x02
-#define IPTOS_MINCOST           IPTOS_LOWCOST
-
-/*
- * Definitions for IP precedence (also in ip_tos) (Unimplemented)
- */
-#define IPTOS_PREC_MASK                 0xe0
-#define IPTOS_PREC(tos)                ((tos) & IPTOS_PREC_MASK)
-#define IPTOS_PREC_NETCONTROL           0xe0
-#define IPTOS_PREC_INTERNETCONTROL      0xc0
-#define IPTOS_PREC_CRITIC_ECP           0xa0
-#define IPTOS_PREC_FLASHOVERRIDE        0x80
-#define IPTOS_PREC_FLASH                0x60
-#define IPTOS_PREC_IMMEDIATE            0x40
-#define IPTOS_PREC_PRIORITY             0x20
-#define IPTOS_PREC_ROUTINE              0x00
-
-
-/*
- * Commands for ioctlsocket(),  taken from the BSD file fcntl.h.
- * lwip_ioctl only supports FIONREAD and FIONBIO, for now
- *
- * Ioctl's have the command encoded in the lower word,
- * and the size of any in or out parameters in the upper
- * word.  The high 2 bits of the upper word are used
- * to encode the in/out status of the parameter; for now
- * we restrict parameters to at most 128 bytes.
- */
-#if !defined(FIONREAD) || !defined(FIONBIO)
-#define IOCPARM_MASK    0x7fU           /* parameters must be < 128 bytes */
-#define IOC_VOID        0x20000000UL    /* no parameters */
-#define IOC_OUT         0x40000000UL    /* copy out parameters */
-#define IOC_IN          0x80000000UL    /* copy in parameters */
-#define IOC_INOUT       (IOC_IN|IOC_OUT)
-                                        /* 0x20000000 distinguishes new &
-                                           old ioctl's */
-#define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
-
-#define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
-
-#define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
-#endif /* !defined(FIONREAD) || !defined(FIONBIO) */
-
-#ifndef FIONREAD
-#define FIONREAD    _IOR('f', 127, unsigned long) /* get # bytes to read */
-#endif
-#ifndef FIONBIO
-#define FIONBIO     _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */
-#endif
-
-/* Socket I/O Controls: unimplemented */
-#ifndef SIOCSHIWAT
-#define SIOCSHIWAT  _IOW('s',  0, unsigned long)  /* set high watermark */
-#define SIOCGHIWAT  _IOR('s',  1, unsigned long)  /* get high watermark */
-#define SIOCSLOWAT  _IOW('s',  2, unsigned long)  /* set low watermark */
-#define SIOCGLOWAT  _IOR('s',  3, unsigned long)  /* get low watermark */
-#define SIOCATMARK  _IOR('s',  7, unsigned long)  /* at oob mark? */
-#endif
-
-/* Socket flags: */
-#ifndef O_NONBLOCK
-#define O_NONBLOCK    04000U
-#endif
-
-/* FD_SET used for lwip_select */
-#ifndef FD_SET
-  #undef  FD_SETSIZE
-  /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
-  #define FD_SETSIZE    MEMP_NUM_NETCONN
-  #define FD_SET(n, p)  ((p)->fd_bits[(n)/8] |=  (1 << ((n) & 7)))
-  #define FD_CLR(n, p)  ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
-  #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] &   (1 << ((n) & 7)))
-  #define FD_ZERO(p)    memset((void*)(p),0,sizeof(*(p)))
-
-  typedef struct fd_set {
-          unsigned char fd_bits [(FD_SETSIZE+7)/8];
-        } fd_set;
-
-#endif /* FD_SET */
-
-/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided
- * by your system, set this to 0 and include <sys/time.h> in cc.h */ 
-#ifndef LWIP_TIMEVAL_PRIVATE
-#define LWIP_TIMEVAL_PRIVATE 1
-#endif
-
-#if LWIP_TIMEVAL_PRIVATE
-struct timeval {
-  long    tv_sec;         /* seconds */
-  long    tv_usec;        /* and microseconds */
-};
-#endif /* LWIP_TIMEVAL_PRIVATE */
-
-void lwip_socket_init(void);
-
-int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
-int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
-int lwip_shutdown(int s, int how);
-int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen);
-int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen);
-int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen);
-int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen);
-int lwip_close(int s);
-int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen);
-int lwip_listen(int s, int backlog);
-int lwip_recv(int s, void *mem, int len, unsigned int flags);
-int lwip_read(int s, void *mem, int len);
-int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
-      struct sockaddr *from, socklen_t *fromlen);
-int lwip_send(int s, const void *dataptr, int size, unsigned int flags);
-int lwip_sendto(int s, const void *dataptr, int size, unsigned int flags,
-    struct sockaddr *to, socklen_t tolen);
-int lwip_socket(int domain, int type, int protocol);
-int lwip_write(int s, const void *dataptr, int size);
-int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
-                struct timeval *timeout);
-int lwip_ioctl(int s, long cmd, void *argp);
-
-#if LWIP_COMPAT_SOCKETS
-#define accept(a,b,c)         lwip_accept(a,b,c)
-#define bind(a,b,c)           lwip_bind(a,b,c)
-#define shutdown(a,b)         lwip_shutdown(a,b)
-#define closesocket(s)        lwip_close(s)
-#define connect(a,b,c)        lwip_connect(a,b,c)
-#define getsockname(a,b,c)    lwip_getsockname(a,b,c)
-#define getpeername(a,b,c)    lwip_getpeername(a,b,c)
-#define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e)
-#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e)
-#define listen(a,b)           lwip_listen(a,b)
-#define recv(a,b,c,d)         lwip_recv(a,b,c,d)
-#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
-#define send(a,b,c,d)         lwip_send(a,b,c,d)
-#define sendto(a,b,c,d,e,f)   lwip_sendto(a,b,c,d,e,f)
-#define socket(a,b,c)         lwip_socket(a,b,c)
-#define select(a,b,c,d,e)     lwip_select(a,b,c,d,e)
-#define ioctlsocket(a,b,c)    lwip_ioctl(a,b,c)
-
-#if LWIP_POSIX_SOCKETS_IO_NAMES
-#define read(a,b,c)           lwip_read(a,b,c)
-#define write(a,b,c)          lwip_write(a,b,c)
-#define close(s)              lwip_close(s)
-#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
-
-#endif /* LWIP_COMPAT_SOCKETS */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_SOCKET */
-
-#endif /* __LWIP_SOCKETS_H__ */
similarity index 98%
rename from palacios/src/lwip/include/lwip/arch.h
rename to palacios/include/lwip/lwip/arch.h
index 7d1400b..67d8ee1 100644 (file)
@@ -42,6 +42,8 @@
 
 #include "arch/cc.h"
 
+#include "lwip/opt.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -63,6 +65,8 @@ extern "C" {
 #define LWIP_UNUSED_ARG(x) (void)x
 #endif /* LWIP_UNUSED_ARG */ 
 
+//weird thing, I already defined it in lwipopts.h, does not work? Lei
+#define LWIP_PROVIDE_ERRNO 1
 
 #ifdef LWIP_PROVIDE_ERRNO
 
similarity index 93%
rename from palacios/src/lwip/include/lwip/sockets.h
rename to palacios/include/lwip/lwip/sockets.h
index 603b62f..b870399 100644 (file)
@@ -68,7 +68,24 @@ struct sockaddr {
 #define SOCK_STREAM     1
 #define SOCK_DGRAM      2
 #define SOCK_RAW        3
-
+       
+#if 0  /* already defined in lwip/arch.h */
+/* added by Lei */
+#define ENOOK          0      /* No error, everything OK. */
+#define ENOMEM        -1      /* Out of memory error.     */
+#define ENOBUFS       -2      /* Buffer error.            */
+#define EHOSTUNREACH  -3      /* Routing problem.         */
+#define ECONNABORTED  -4      /* Connection aborted.      */
+#define ECONNRESET    -5      /* Connection reset.        */
+#define ESHUTDOWN     -6      /* Connection closed.       */
+#define ENOTCONN      -7      /* Not connected.           */
+#define EINVAL        -8      /* Illegal value.           */
+#define EIO           -9      /* Illegal argument.        */
+#define EADDRINUSE    -10     /* Address in use.          */
+#define ETIMEDOUT     -13     /* Timeout                  */
+#define EINPROGRESS   -14     /* Operation in progress    */
+#endif
+       
 /*
  * Option flags per-socket. These must match the SOF_ flags in ip.h!
  */
@@ -297,8 +314,7 @@ int lwip_sendto(int s, const void *dataptr, int size, unsigned int flags,
     struct sockaddr *to, socklen_t tolen);
 int lwip_socket(int domain, int type, int protocol);
 int lwip_write(int s, const void *dataptr, int size);
-int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
-                struct timeval *timeout);
+int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout);
 int lwip_ioctl(int s, long cmd, void *argp);
 
 #if LWIP_COMPAT_SOCKETS
diff --git a/palacios/include/lwip/lwipopts.h b/palacios/include/lwip/lwipopts.h
new file mode 100644 (file)
index 0000000..0c73919
--- /dev/null
@@ -0,0 +1,425 @@
+/**
+ * @file
+ *
+ * lwIP Options Configuration
+ */
+
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+#ifndef __LWIPOPTS_H__
+#define __LWIPOPTS_H__
+
+/*
+ * Include user defined options first. Anything not defined in these files
+ * will be set to standard values. Override anything you dont like!
+ */
+#include "lwipopts.h"
+#include "lwip/debug.h"
+
+/*
+   -----------------------------------------------
+   ---------- Platform specific locking ----------
+   -----------------------------------------------
+*/
+
+/**
+ * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
+ * critical regions during buffer allocation, deallocation and memory
+ * allocation and deallocation.
+ */
+#define SYS_LIGHTWEIGHT_PROT            0
+
+/** 
+ * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
+ * use lwIP facilities.
+ */
+#define NO_SYS                          0
+
+/*
+   ------------------------------------
+   ---------- Memory options ----------
+   ------------------------------------
+*/
+
+/**
+ * MEM_ALIGNMENT: should be set to the alignment of the CPU
+ *    4 byte alignment -> #define MEM_ALIGNMENT 4
+ *    2 byte alignment -> #define MEM_ALIGNMENT 2
+ */
+#define MEM_ALIGNMENT                   1
+
+/**
+ * MEM_SIZE: the size of the heap memory. If the application will send
+ * a lot of data that needs to be copied, this should be set high.
+ */
+#define MEM_SIZE                        1600
+
+/*
+   ------------------------------------------------
+   ---------- Internal Memory Pool Sizes ----------
+   ------------------------------------------------
+*/
+/**
+ * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
+ * If the application sends a lot of data out of ROM (or other static memory),
+ * this should be set high.
+ */
+#define MEMP_NUM_PBUF                   16
+
+/**
+ * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
+ * (requires the LWIP_RAW option)
+ */
+#define MEMP_NUM_RAW_PCB                4
+
+/**
+ * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
+ * per active UDP "connection".
+ * (requires the LWIP_UDP option)
+ */
+#define MEMP_NUM_UDP_PCB                4
+
+/**
+ * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_PCB                4
+
+/**
+ * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_PCB_LISTEN         4
+
+/**
+ * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
+ * (requires the LWIP_TCP option)
+ */
+#define MEMP_NUM_TCP_SEG                16
+
+/**
+ * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
+ * reassembly (whole packets, not fragments!)
+ */
+#define MEMP_NUM_REASSDATA              1
+
+/**
+ * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing
+ * packets (pbufs) that are waiting for an ARP request (to resolve
+ * their destination address) to finish.
+ * (requires the ARP_QUEUEING option)
+ */
+#define MEMP_NUM_ARP_QUEUE              2
+
+/**
+ * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
+ * (requires NO_SYS==0)
+ */
+#define MEMP_NUM_SYS_TIMEOUT            3
+
+/**
+ * MEMP_NUM_NETBUF: the number of struct netbufs.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
+#define MEMP_NUM_NETBUF                 2
+
+/**
+ * MEMP_NUM_NETCONN: the number of struct netconns.
+ * (only needed if you use the sequential API, like api_lib.c)
+ */
+#define MEMP_NUM_NETCONN                4
+
+/**
+ * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
+ * for callback/timeout API communication. 
+ * (only needed if you use tcpip.c)
+ */
+#define MEMP_NUM_TCPIP_MSG_API          8
+
+/**
+ * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
+ * for incoming packets. 
+ * (only needed if you use tcpip.c)
+ */
+#define MEMP_NUM_TCPIP_MSG_INPKT        8
+
+/**
+ * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
+ */
+#define PBUF_POOL_SIZE                  8
+
+/*
+   ---------------------------------
+   ---------- ARP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_ARP==1: Enable ARP functionality.
+ */
+#define LWIP_ARP                        1
+
+/*
+   --------------------------------
+   ---------- IP options ----------
+   --------------------------------
+*/
+/**
+ * IP_FORWARD==1: Enables the ability to forward IP packets across network
+ * interfaces. If you are going to run lwIP on a device with only one network
+ * interface, define this to 0.
+ */
+#define IP_FORWARD                      0
+
+/**
+ * IP_OPTIONS: Defines the behavior for IP options.
+ *      IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped.
+ *      IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed).
+ */
+#define IP_OPTIONS_ALLOWED              1
+
+/**
+ * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
+ * this option does not affect outgoing packet sizes, which can be controlled
+ * via IP_FRAG.
+ */
+#define IP_REASSEMBLY                   1
+
+/**
+ * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
+ * that this option does not affect incoming packet sizes, which can be
+ * controlled via IP_REASSEMBLY.
+ */
+#define IP_FRAG                         1
+
+/**
+ * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
+ * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
+ * in this time, the whole packet is discarded.
+ */
+#define IP_REASS_MAXAGE                 3
+
+/**
+ * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
+ * Since the received pbufs are enqueued, be sure to configure
+ * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
+ * packets even if the maximum amount of fragments is enqueued for reassembly!
+ */
+#define IP_REASS_MAX_PBUFS              4
+
+/**
+ * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP
+ * fragmentation. Otherwise pbufs are allocated and reference the original
+    * packet data to be fragmented.
+*/
+#define IP_FRAG_USES_STATIC_BUF         0
+
+/**
+ * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
+ */
+#define IP_DEFAULT_TTL                  255
+
+/*
+   ----------------------------------
+   ---------- ICMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_ICMP==1: Enable ICMP module inside the IP stack.
+ * Be careful, disable that make your product non-compliant to RFC1122
+ */
+#define LWIP_ICMP                       1
+
+/*
+   ---------------------------------
+   ---------- RAW options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
+ */
+#define LWIP_RAW                        1
+
+/*
+   ----------------------------------
+   ---------- DHCP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_DHCP==1: Enable DHCP module.
+ */
+#define LWIP_DHCP                       0
+
+
+/*
+   ------------------------------------
+   ---------- AUTOIP options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_AUTOIP==1: Enable AUTOIP module.
+ */
+#define LWIP_AUTOIP                     0
+
+/*
+   ----------------------------------
+   ---------- SNMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
+ * transport.
+ */
+#define LWIP_SNMP                       0
+
+/*
+   ----------------------------------
+   ---------- IGMP options ----------
+   ----------------------------------
+*/
+/**
+ * LWIP_IGMP==1: Turn on IGMP module. 
+ */
+#define LWIP_IGMP                       0
+
+/*
+   ----------------------------------
+   ---------- DNS options -----------
+   ----------------------------------
+*/
+/**
+ * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
+ * transport.
+ */
+#define LWIP_DNS                        0
+
+/*
+   ---------------------------------
+   ---------- UDP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_UDP==1: Turn on UDP.
+ */
+#define LWIP_UDP                        1
+
+/*
+   ---------------------------------
+   ---------- TCP options ----------
+   ---------------------------------
+*/
+/**
+ * LWIP_TCP==1: Turn on TCP.
+ */
+#define LWIP_TCP                        1
+
+#define LWIP_LISTEN_BACKLOG             0
+
+/*
+   ----------------------------------
+   ---------- Pbuf options ----------
+   ----------------------------------
+*/
+/**
+ * PBUF_LINK_HLEN: the number of bytes that should be allocated for a
+ * link level header. The default is 14, the standard value for
+ * Ethernet.
+ */
+#define PBUF_LINK_HLEN                  16
+
+/**
+ * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
+ * designed to accomodate single full size TCP frame in one pbuf, including
+ * TCP_MSS, IP header, and link header.
+*
+ */
+#define PBUF_POOL_BUFSIZE               LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN)
+
+/*
+   ------------------------------------
+   ---------- LOOPIF options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
+ */
+#define LWIP_HAVE_LOOPIF                0
+
+/*
+   ----------------------------------------------
+   ---------- Sequential layer options ----------
+   ----------------------------------------------
+*/
+
+/**
+ * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
+ */
+#define LWIP_NETCONN                    1
+
+/*
+   ------------------------------------
+   ---------- Socket options ----------
+   ------------------------------------
+*/
+/**
+ * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
+ */
+#define LWIP_SOCKET                     1
+
+/*
+   ----------------------------------------
+   ---------- Statistics options ----------
+   ----------------------------------------
+*/
+/**
+ * LWIP_STATS==1: Enable statistics collection in lwip_stats.
+ */
+#define LWIP_STATS                      0
+/*
+   ---------------------------------
+   ---------- PPP options ----------
+   ---------------------------------
+*/
+/**
+ * PPP_SUPPORT==1: Enable PPP.
+ */
+#define PPP_SUPPORT                     0
+       
+
+/* use errno provided by lwip, Lei */
+#define LWIP_PROVIDE_ERRNO    1
+
+
+/* Misc */
+
+#define LWIP_TIMEVAL_PRIVATE 1
+
+#endif /* __LWIPOPTS_H__ */
index 337099c..8851bae 100644 (file)
@@ -2,11 +2,13 @@
 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
 
+
 #ifndef __VMCS_H__
 #define __VMCS_H__
 
 #ifdef __V3VEE__
 
+
 #include <palacios/vmm_types.h>
 
 
index 42af92e..fa941b4 100644 (file)
@@ -1,11 +1,10 @@
 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
-
-
 #ifndef __VMCS_GEN__
 #define __VMCS_GEN__
 
 #ifdef __V3VEE__
 
+
 #include <palacios/vmcs.h>
 #include <palacios/vmm.h>
 
index 737ec35..c648692 100644 (file)
 
 
 
-#define PrintError(fmt, args...)                       \
-  do {                                                 \
-    extern struct vmm_os_hooks * os_hooks;             \
-    if ((os_hooks) && (os_hooks)->print_debug) {       \
-      (os_hooks)->print_debug((fmt), ##args);          \
-    }                                                  \
+#define PrintError(fmt, args...)                                       \
+  do {                                                                 \
+    extern struct vmm_os_hooks * os_hooks;                             \
+    if ((os_hooks) && (os_hooks)->print_debug) {                       \
+      (os_hooks)->print_debug("%s(%d): " fmt, __FILE__, __LINE__, ##args); \
+    }                                                                  \
   } while (0)                                          
 
 
 
 
 #if VMM_TRACE
-#define PrintTrace(fmt, args...)                       \
-  do {                                                 \
-    extern struct vmm_os_hooks * os_hooks;             \
-    if ((os_hooks) && (os_hooks)->print_trace) {       \
-      (os_hooks)->print_trace((fmt), ##args);          \
-    }                                                  \
+#define PrintTrace(fmt, args...)                                       \
+  do {                                                                 \
+    extern struct vmm_os_hooks * os_hooks;                             \
+    if ((os_hooks) && (os_hooks)->print_trace) {                       \
+      (os_hooks)->print_trace(fmt, ##args);                            \
+    }                                                                  \
   } while (0)                                          
 #else
 #define PrintTrace(fmt, args...)
index 4e073be..504b520 100644 (file)
@@ -49,3 +49,5 @@ typedef ulong_t addr_t;
 #endif // ! __V3VEE__
 
 #endif
+
+#endif
index 7415067..41f4b8a 100644 (file)
@@ -294,12 +294,20 @@ int fprintf(FILE *file, char *fmt, ...)
 
 }
 
-/* int fflush(FILE *stream)
+int printf(char *fmt, ...)
 {
-    PrintDebug("In fflush!!\n");
+   // PrintDebug("In fprintf!!\n");
+
+   return 0;
+
+}
+
+int fflush(FILE *stream)
+{
+    //PrintDebug("In fflush!!\n");
 
     return 0;
-}*/
+}
 
 void abort(void)
 {
index cfcd7bb..fc833a8 100644 (file)
@@ -25,6 +25,7 @@ void cdrom_init(struct cdrom_interface * cdrom)
   Ramdisk_Print_CD("[cdrom_init]\n");
   V3_ASSERT(g_ramdiskImage);
   cdrom->fd = g_ramdiskImage;
+  PrintDebug("CDIMAGE located at: %x\n", cdrom->fd);
   cdrom->capacity_B = s_ramdiskSize; 
   //FIXME:lba
   cdrom->lba = 1; 
@@ -56,7 +57,7 @@ void cdrom_eject(struct cdrom_interface *cdrom)
  * Read CD TOC. Returns false if start track is out of bounds.
  */
 static
-rd_bool cdrom_read_toc(struct cdrom_interface *cdrom, uint8* buf, int* length, rd_bool msf, int start_track)
+rd_bool cdrom_read_toc(struct cdrom_interface *cdrom, uint8_t* buf, int* length, rd_bool msf, int start_track)
 {
   Ramdisk_Print_CD("[cdrom_read_toc]\n");
   return 1;
@@ -66,7 +67,7 @@ rd_bool cdrom_read_toc(struct cdrom_interface *cdrom, uint8* buf, int* length, r
  * Return CD-ROM capacity (in 2048 byte frames)
  */
 static
-uint32 cdrom_capacity(struct cdrom_interface *cdrom)
+uint32_t cdrom_capacity(struct cdrom_interface *cdrom)
 {
   Ramdisk_Print_CD("[cdrom_capacity] s_ramdiskSize = %d\n", cdrom->capacity_B);
   if (cdrom->lba) {
@@ -87,13 +88,14 @@ uint32 cdrom_capacity(struct cdrom_interface *cdrom)
  * Read a single block from the CD
  */
 static
-void cdrom_read_block(struct cdrom_interface *cdrom, uint8* buf, int lba)// __attribute__(regparm(2));
+void cdrom_read_block(struct cdrom_interface *cdrom, uint8_t* buf, int lba)// __attribute__(regparm(2));
 {
 
   V3_ASSERT(lba != 0);
-    
-  Ramdisk_Print_CD("[cdrom_read_block] lba = %d\n", lba);
-  memcpy(buf, (uint8 *)(cdrom->fd + lba*2048), 2048);
+  
+  Ramdisk_Print_CD("[cdrom_read_block] lba = %d (cdrom_image_start=%x)\n", lba, cdrom->fd);
+  memcpy(buf, (uint8_t *)(cdrom->fd + lba * 2048), 2048);
+  PrintDebug("Returning from read block\n");
     return;
 }
 
index 20ff37f..dc018ab 100644 (file)
@@ -1,10 +1,13 @@
 /* (c) 2008, Peter Dinda <pdinda@northwestern.edu> */
 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
 
+
+
+
 #include <devices/generic.h>
 #include <palacios/vmm.h>
 #include <palacios/vmm_types.h>
-
+#include <palacios/vmm_list.h>
 
 
 
 #define MEM_HOOKS  0   // not yet implmented in device model
 #define IRQ_HOOKS  0   // not yet implemented in device model
 
+
 struct generic_internal {
-  generic_port_range_type    *port_ranges;
-  uint_t                     num_port_ranges;
-  generic_address_range_type *address_ranges;
-  uint_t                     num_address_ranges;
-  generic_irq_range_type     *irq_ranges;
-  uint_t                     num_irq_ranges;
+  struct list_head port_list;
+  uint_t num_port_ranges;
+  struct list_head mem_list;
+  uint_t num_mem_ranges;
+  struct list_head irq_list;
+  uint_t num_irq_ranges;
 };
 
 
-  
-#ifdef RAMDISK_BOOT
-#include <devices/ramdisk.h>
-//ramdisk_state
-static struct ramdisk_t *ramdisk_state;
-#endif    
+struct port_range {
+  uint_t start;
+  uint_t end;
+  uint_t type;
+  struct list_head range_link;
+};
+
+struct mem_range {
+  void * start;
+  void * end;
+  uint_t type;
+  struct list_head range_link;
+};
 
+struct irq_range {
+  uint_t start;
+  uint_t end;
+  uint_t type;
+  struct list_head range_link;
+};
 
 
 
@@ -50,14 +67,14 @@ int generic_reset_device(struct vm_device * dev)
 
 
 
-int generic_start_device(struct vm_device *dev)
+int generic_start_device(struct vm_device * dev)
 {
   PrintDebug("generic: start device\n");
   return 0;
 }
 
 
-int generic_stop_device(struct vm_device *dev)
+int generic_stop_device(struct vm_device * dev)
 {
   PrintDebug("generic: stop device\n");
   return 0;
@@ -81,21 +98,13 @@ int generic_write_port_passthrough(ushort_t port,
   
   PrintDebug(" to port 0x%x ... ", port);
 
-#ifdef RAMDISK_BOOT
-
-  uint_t err;
-
-  if (((port >= 0x170 && port <= 0x177) || port == 0x376 || port == 0x377)
-      && (dev->vm->cpu_mode == REAL)) {
-
-    
-    err = ramdisk_state->eops.write_port(port, src, length, dev);
-
-  }else{
-#endif
 
   switch (length) {
   case 1:
+<<<<<<< HEAD:palacios/src/devices/generic.c
+=======
+
+>>>>>>> ramdisk:palacios/src/devices/generic.c
     v3_outb(port,((uchar_t*)src)[0]);
     break;
   case 2:
@@ -103,15 +112,18 @@ int generic_write_port_passthrough(ushort_t port,
     break;
   case 4:
     v3_outdw(port,((uint_t*)src)[0]);
+<<<<<<< HEAD:palacios/src/devices/generic.c
+=======
+
+>>>>>>> ramdisk:palacios/src/devices/generic.c
     break;
   default:
     for (i = 0; i < length; i++) { 
       v3_outb(port, ((uchar_t*)src)[i]);
     }
   } //switch length
-#ifdef RAMDISK_BOOT
-  }//else not ramdisk
-#endif
+
+
   PrintDebug(" done\n");
   
   return length;
@@ -126,17 +138,6 @@ int generic_read_port_passthrough(ushort_t port,
 
   PrintDebug("generic: reading 0x%x bytes from port 0x%x ...", length, port);
 
-#ifdef RAMDISK_BOOT
-
-  uint_t err;
-
-  if (((port >= 0x170 && port <= 0x177) || port == 0x376 || port == 0x377)
-      && (dev->vm->cpu_mode == REAL)) {
-
-    err = ramdisk_state->eops.read_port(port, src, length, dev);
-
-  }else{
-#endif
 
     switch (length) {
     case 1:
@@ -153,9 +154,6 @@ int generic_read_port_passthrough(ushort_t port,
        ((uchar_t*)src)[i] = v3_inb(port);
       }
     }//switch length
-#ifdef RAMDISK_BOOT
-  }//else not ramdisk
-#endif
 
   PrintDebug(" done ... read 0x");
 
@@ -181,21 +179,7 @@ int generic_write_port_ignore(ushort_t port,
     PrintDebug("%x", ((uchar_t*)src)[i]);
   }
   
-  PrintDebug(" to port 0x%x ... ", port);
-
-  PrintDebug(" ignored\n");
-#ifdef RAMDISK_BOOT
-
-  uint_t err;
-
-  if (((port >= 0x3e8 && port <= 0x3ef) || 
-       (port >= 0x2e8 && port <= 0x2ef))
-      && (dev->vm->cpu_mode == REAL)) {
-
-    err = ramdisk_state->eops.write_port_ignore(port, src, length, dev);
-  }
-#endif
+  PrintDebug(" to port 0x%x ... ignored\n", port);
  
   return length;
 }
@@ -208,165 +192,190 @@ int generic_read_port_ignore(ushort_t port,
 
   PrintDebug("generic: reading 0x%x bytes from port 0x%x ...", length, port);
 
-  memset((char*)src,0,length);
+  memset((char*)src, 0, length);
   PrintDebug(" ignored (return zeroed buffer)\n");
 
-#ifdef RAMDISK_BOOT
-
-  uint_t err;
-
-  if (((port >= 0x3e8 && port <= 0x3ef) || 
-       (port >= 0x2e8 && port <= 0x2ef))
-      && (dev->vm->cpu_mode == REAL)) {
-
-    err = ramdisk_state->eops.read_port_ignore(port, src, length, dev);
-  }
-#endif
-
   return length;
 }
 
 
 
-int generic_interrupt(uint_t irq,
-                     struct vm_device * dev) 
-{
+int generic_interrupt(uint_t irq, struct vm_device * dev) {
   PrintDebug("generic: interrupt 0x%x - injecting into VM\n", irq);
 
   dev->vm->vm_ops.raise_irq(dev->vm, irq);
 
   return 0;
-
 }
 
 
-int generic_init_device(struct vm_device * dev) 
-{
-  struct generic_internal *state = (struct generic_internal *)(dev->private_data);
-  uint_t i, j;
+int generic_init_device(struct vm_device * dev) {
+  struct generic_internal * state = (struct generic_internal *)(dev->private_data);
 
   PrintDebug("generic: init_device\n");
-
-  // Would read state here
-
   generic_reset_device(dev);
 
-  for (i = 0; i < state->num_port_ranges; i++) { 
-    PrintDebug("generic: hooking ports 0x%x to 0x%x as %x\n", state->port_ranges[i][0], state->port_ranges[i][1], state->port_ranges[i][2]==GENERIC_PRINT_AND_PASSTHROUGH ? "print-and-passthrough" : "print-and-ignore");
 
-#if PORT_HOOKS
-    for (j = state->port_ranges[i][0]; j <= state->port_ranges[i][1]; j++) { 
-      if (state->port_ranges[i][2]==GENERIC_PRINT_AND_PASSTHROUGH) { 
-       if (dev_hook_io(dev, j, &generic_read_port_passthrough, &generic_write_port_passthrough)) { 
-         PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", j);
-       }
-      } else if (state->port_ranges[i][2]==GENERIC_PRINT_AND_IGNORE) { 
-       if (dev_hook_io(dev, j, &generic_read_port_ignore, &generic_write_port_ignore)) { 
-         PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", j);
-       }
-      } 
+  if (PORT_HOOKS) { // This is a runtime conditional on a #define
+    struct port_range * tmp = NULL;
+
+    list_for_each_entry(tmp, &(state->port_list), range_link) {
+      uint_t i = 0;
+      
+      PrintDebug("generic: hooking ports 0x%x to 0x%x as %x\n", 
+                tmp->start, tmp->end, 
+                (tmp->type == GENERIC_PRINT_AND_PASSTHROUGH) ? "print-and-passthrough" : "print-and-ignore");
+      
+      for (i = tmp->start; i <= tmp->end; i++) { 
+       if (tmp->type == GENERIC_PRINT_AND_PASSTHROUGH) { 
+         
+         if (dev_hook_io(dev, i, &generic_read_port_passthrough, &generic_write_port_passthrough)) { 
+           PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", i);
+         }
+         
+       } else if (tmp->type == GENERIC_PRINT_AND_IGNORE) { 
+         
+         if (dev_hook_io(dev, i, &generic_read_port_ignore, &generic_write_port_ignore)) { 
+           PrintDebug("generic: can't hook port 0x%x (already hooked?)\n", i);
+         }
+       } 
+      }
+
     }
-#else
+  } else {
     PrintDebug("generic: hooking ports not supported\n");
-#endif
-
   }
 
-  for (i = 0; i < state->num_address_ranges; i++) { 
-    PrintDebug("generic: hooking addresses 0x%x to 0x%x\n",state->address_ranges[i][0],state->address_ranges[i][1]); 
 
-#if MEM_HOOKS
-    if (dev_hook_mem(dev, state->address_ranges[i][0], state->address_ranges[i][1])) {
-      PrintDebug("generic: Can't hook addresses 0x%x to 0x%x (already hooked?)\n",
-                 state->address_ranges[i][0], state->address_ranges[i][1]); 
+
+  if (MEM_HOOKS) { // This is a runtime conditional on a #define
+    struct mem_range * tmp;
+
+    list_for_each_entry(tmp, &(state->mem_list), range_link) {
+
+      PrintDebug("generic: hooking addresses 0x%x to 0x%x\n", 
+                tmp->start, tmp->end); 
+      
+      
+      if (dev_hook_mem(dev, tmp->start, tmp->end)) {
+       PrintDebug("generic: Can't hook addresses 0x%x to 0x%x (already hooked?)\n",
+                  tmp->start, tmp->end); 
+      }
     }
-#else
+  } else {
     PrintDebug("generic: hooking addresses not supported\n");
-#endif
-
   }
 
-  for (i = 0; i < state->num_irq_ranges; i++) { 
-    PrintDebug("generic: hooking irqs 0x%x to 0x%x\n",state->irq_ranges[i][0],state->irq_ranges[i][1]);
 
-#if IRQ_HOOKS
-    for (j = state->irq_ranges[i][0]; j <= state->irq_ranges[i][1]; j++) { 
-      if (dev_hook_irq(dev, j, &generic_interrupt)) { 
-       PrintDebug("generic: can't hook irq  0x%x (already hooked?)\n", j);
+
+
+  if (IRQ_HOOKS) { // This is a runtime conditional on a #define
+    struct irq_range * tmp;
+    
+    list_for_each_entry(tmp, &(state->irq_list), range_link) {
+      uint_t i;
+
+      PrintDebug("generic: hooking irqs 0x%x to 0x%x\n",
+                tmp->start, tmp->end);
+      
+      for (i = tmp->start; i <= tmp->end; i++) { 
+       if (dev_hook_irq(dev, i, &generic_interrupt)) { 
+         PrintDebug("generic: can't hook irq  0x%x (already hooked?)\n", i);
+       }
       }
+
     }
-#else
+  } else {
     PrintDebug("generic: hooking irqs not supported\n");
-#endif
-
   }
 
-#ifdef RAMDISK_BOOT
 
-  ramdisk_state->cops.init(ramdisk_state, dev);
-
-#endif
 
   return 0;
 }
 
-int generic_deinit_device(struct vm_device *dev)
-{
-  struct generic_internal *state = (struct generic_internal *)(dev->private_data);
-  uint_t i, j;
+int generic_deinit_device(struct vm_device * dev) {
+  struct generic_internal * state = (struct generic_internal *)(dev->private_data);
+
 
   PrintDebug("generic: deinit_device\n");
 
-#ifdef RAMDISK_BOOT
 
-  ramdisk_state->cops.close(ramdisk_state);
-  
-#endif
+  if (IRQ_HOOKS) { // This is a runtime conditional on a #define
+    struct irq_range * tmp;
+    struct irq_range * cur;
+    
+    list_for_each_entry_safe(cur, tmp, &(state->irq_list), range_link) {
+      uint_t i;
 
-  for (i = 0; i < state->num_irq_ranges; i++) { 
-    PrintDebug("generic: unhooking irqs 0x%x to 0x%x\n", state->irq_ranges[i][0], state->irq_ranges[i][1]);
+      PrintDebug("generic: unhooking irqs 0x%x to 0x%x\n", 
+                cur->start, cur->end);
+      
 
-#if IRQ_HOOKS
-    for (j = state->irq_ranges[i][0]; j <= state->irq_ranges[i][1]; j++) { 
-      if (dev_unhook_irq(dev, j)) {
-       PrintDebug("generic: can't unhook irq 0x%x (already unhooked?)\n",j);
+      for (i = cur->start; i <= cur->end; i++) { 
+       if (dev_unhook_irq(dev, i)) {
+         PrintDebug("generic: can't unhook irq 0x%x (already unhooked?)\n", i);
+       }
       }
+
+      list_del(&(cur->range_link));
+      state->num_irq_ranges--;
+      V3_Free(cur);
     }
-#else
+  } else {
     PrintDebug("generic: unhooking irqs not supported\n");
-#endif
-
   }
 
-  for (i = 0; i < state->num_address_ranges; i++) { 
-    PrintDebug("generic: unhooking addresses 0x%x to 0x%x\n",state->address_ranges[i][0],state->address_ranges[i][1]); 
 
-#if MEM_HOOKS
-    if (dev_unhook_mem(dev, state->address_ranges[i][0], state->address_ranges[i][1])) {
-      PrintDebug("generic: Can't unhook addresses 0x%x to 0x%x (already unhooked?)\n",
-                 state->address_ranges[i][0], state->address_ranges[i][1]); 
+  if (MEM_HOOKS) {
+    struct mem_range * tmp;
+    struct mem_range * cur;
+    
+    list_for_each_entry_safe(cur, tmp, &(state->mem_list), range_link) {
+
+      PrintDebug("generic: unhooking addresses 0x%x to 0x%x\n",
+                cur->start, cur->end); 
+
+      if (dev_unhook_mem(dev, cur->start, cur->end)) {
+       PrintDebug("generic: Can't unhook addresses 0x%x to 0x%x (already unhooked?)\n",
+                  cur->start, cur->end); 
+      }
+
+      list_del(&(cur->range_link));
+      state->num_mem_ranges--;
+      V3_Free(cur);
     }
-#else
+  } else {
     PrintDebug("generic: unhooking addresses not supported\n");
-#endif
-
   }
+  
 
-  for (i = 0; i < state->num_port_ranges; i++) { 
-    PrintDebug("generic: unhooking ports 0x%x to 0x%x\n",state->port_ranges[i][0],state->port_ranges[i][1]);
-
-#if PORT_HOOKS
-    for (j = state->port_ranges[i][0]; j <= state->port_ranges[i][1]; j++) { 
-      if (dev_unhook_io(dev, j)) {
-       PrintDebug("generic: can't unhook port 0x%x (already unhooked?)\n", j);
+  if (PORT_HOOKS) {
+    struct port_range * tmp;
+    struct port_range * cur;
+    
+    list_for_each_entry_safe(cur, tmp, &(state->port_list), range_link) {
+      uint_t i;
+
+      PrintDebug("generic: unhooking ports 0x%x to 0x%x\n",
+                  cur->start, cur->end);
+               
+      for (i = cur->start; i <= cur->end; i++) {
+       if (dev_unhook_io(dev, i)) {
+         PrintDebug("generic: can't unhook port 0x%x (already unhooked?)\n", i);
+       }
       }
+
+      list_del(&(cur->range_link));
+      state->num_port_ranges--;
+      V3_Free(cur);
     }
-#else
+  } else {
     PrintDebug("generic: unhooking ports not supported\n");
-#endif
-
   }
 
+
+
   generic_reset_device(dev);
   return 0;
 }
@@ -386,77 +395,86 @@ static struct vm_device_ops dev_ops = {
 
 
 
-struct vm_device *create_generic(generic_port_range_type    port_ranges[], 
-                                generic_address_range_type address_ranges[],
-                                generic_irq_range_type     irq_ranges[])
-{
-  struct generic_internal * generic_state = (struct generic_internal *)V3_Malloc(sizeof(struct generic_internal));
-  int i;
-  uint_t num_port_ranges, num_address_ranges, num_irq_ranges;
-
-  num_port_ranges=0;
-  if (port_ranges!=NULL) { 
-    i=0;
-    while (port_ranges[i]!=NULL && 
-          !(port_ranges[i][0]==0 && port_ranges[i][1]==0 && port_ranges[i][2]==0)) 
-      { num_port_ranges++; i++; }
-  }
+int v3_generic_add_port_range(struct vm_device * dev, uint_t start, uint_t end, uint_t type) {
 
-  
-  num_address_ranges=0;
-  if (address_ranges!=NULL) { 
-    i=0;
-    while (address_ranges[i]!=NULL  && 
-          !(address_ranges[i][0]==0 && address_ranges[i][1]==0 && address_ranges[i][2]==0)) 
-      { num_address_ranges++; i++; }
-  }
+  if (PORT_HOOKS) {
+    struct generic_internal * state = (struct generic_internal *)(dev->private_data);
 
-  num_irq_ranges=0;
-  if (irq_ranges!=NULL) { 
-    i=0;
-    while (irq_ranges[i]!=NULL && 
-          !(irq_ranges[i][0]==0 && irq_ranges[i][1]==0 && irq_ranges[i][2]==0) ) 
-      { num_irq_ranges++; i++; }
-  }
+    struct port_range * range = (struct port_range *)V3_Malloc(sizeof(struct port_range));
+    range->start = start;
+    range->end = end;
+    range->type = type;
     
-
-  generic_state->num_port_ranges = num_port_ranges;
-
-  if (num_port_ranges > 0) { 
-    generic_state->port_ranges = V3_Malloc(sizeof(generic_address_range_type) * num_port_ranges);
-    memcpy(generic_state->port_ranges, port_ranges, sizeof(generic_port_range_type) * num_port_ranges);
+      
+    PrintDebug("generic: Adding Port Range: 0x%x to 0x%x as %x\n", 
+              range->start, range->end, 
+              (range->type == GENERIC_PRINT_AND_PASSTHROUGH) ? "print-and-passthrough" : "print-and-ignore");
+    
+    list_add(&(range->range_link), &(state->port_list));
+    state->num_port_ranges++;
   } else {
-    generic_state->port_ranges = NULL;
+    PrintDebug("generic: hooking IO ports not supported\n");
+    return -1;
   }
 
+  return 0;
+}
 
-  generic_state->num_address_ranges = num_address_ranges;
+int v3_generic_add_mem_range(struct vm_device * dev, void * start, void * end, uint_t type) {
 
-  if (num_address_ranges > 0) { 
-    generic_state->address_ranges = V3_Malloc(sizeof(generic_address_range_type) * num_address_ranges);
-    memcpy(generic_state->address_ranges, address_ranges, sizeof(generic_address_range_type) * num_address_ranges);
+  if (MEM_HOOKS) {
+    struct generic_internal * state = (struct generic_internal *)(dev->private_data);
+    
+    struct mem_range * range = (struct mem_range *)V3_Malloc(sizeof(struct mem_range));
+    range->start = start;
+    range->end = end;
+    range->type = type;
+    
+    list_add(&(range->range_link), &(state->port_list));
+    state->num_mem_ranges++;
   } else {
-    generic_state->address_ranges = NULL;
+    PrintDebug("generic: hooking memory not supported\n");
+    return -1;
   }
 
+  return 0;
+}
+
 
-  generic_state->num_irq_ranges = num_irq_ranges;
+int v3_generic_add_irq_range(struct vm_device * dev, uint_t start, uint_t end, uint_t type) {
 
-  if (num_irq_ranges > 0) { 
-    generic_state->irq_ranges = V3_Malloc(sizeof(generic_address_range_type) * num_irq_ranges);
-    memcpy(generic_state->irq_ranges, irq_ranges, sizeof(generic_irq_range_type) * num_port_ranges);
+  if (IRQ_HOOKS) {
+    struct generic_internal * state = (struct generic_internal *)(dev->private_data);
+    
+    struct irq_range * range = (struct irq_range *)V3_Malloc(sizeof(struct irq_range));
+    range->start = start;
+    range->end = end;
+    range->type = type;
+    
+    list_add(&(range->range_link), &(state->port_list));
+    state->num_irq_ranges++;
   } else {
-    generic_state->irq_ranges = NULL;
+    PrintDebug("generic: hooking IRQs not supported\n");
+    return -1;
   }
 
-#ifdef RAMDISK_BOOT
+  return 0;
+}
 
-  ramdisk_state = create_ramdisk();
-  V3_ASSERT(ramdisk_state != NULL);
 
-#endif
 
-  struct vm_device *device = create_device("GENERIC", &dev_ops, generic_state);
+struct vm_device * create_generic() {
+  struct generic_internal * generic_state = (struct generic_internal *)V3_Malloc(sizeof(struct generic_internal));
+  
+  generic_state->num_port_ranges = 0;
+  generic_state->num_mem_ranges = 0;
+  generic_state->num_irq_ranges = 0;
+
+  INIT_LIST_HEAD(&(generic_state->port_list));
+  INIT_LIST_HEAD(&(generic_state->mem_list));
+  INIT_LIST_HEAD(&(generic_state->irq_list));
+    
+  struct vm_device * device = create_device("GENERIC", &dev_ops, generic_state);
 
   return device;
 }
index da76b67..6c2b9ec 100644 (file)
@@ -117,12 +117,14 @@ struct rtc_statd {
 
 struct vm_device * thedev = NULL;
 
+/*JRL: A hack and a fatal bug 
 static struct vm_device * demultiplex_timer_interrupt(uint_t period_us)
 {
   // hack
   return thedev;
 }
-
+*/
+/* JRL: Doesn't work
 struct bcd_num {
   uchar_t bot : 4;
   uchar_t top : 4;
@@ -406,9 +408,9 @@ static void update_time(struct vm_device *dev, uint_t period_us)
   }
 }
 
+*/
 
-
-
+/* JRL: This is completely broken...
 void deliver_timer_interrupt_to_vmm(uint_t period_us)
 {
   struct vm_device * dev = demultiplex_timer_interrupt(period_us);
@@ -418,7 +420,7 @@ void deliver_timer_interrupt_to_vmm(uint_t period_us)
   }
   
 }
-
+*/
 
 static int set_nvram_defaults(struct vm_device * dev)
 {
index 9455798..05d9333 100644 (file)
@@ -6,22 +6,87 @@
 
 #include <devices/ramdisk.h>
 #include <palacios/vmm.h>
-#include <string.h>
+#include <devices/cdrom.h>
+#include <devices/ide.h>
+#include <devices/atapi.h>
 
-#ifdef DEBUG_RAMDISK
-#define Ramdisk_Print(_f, _a...) PrintTrace("\nramdisk.c(%d) " _f, __LINE__, ## _a)
-#else 
-#define Ramdisk_Print(_f, _a...)
+#ifndef DEBUG_RAMDISK
+#undef PrintDebug
+#define PrintDebug(_f, _a...)
 #endif
+                                                 
+
+/*
+ * Data type definitions
+ *
+ */
+#define INDEX_PULSE_CYCLE 10
+
+
+
+
+#define INTR_REASON_BIT_ERR           0x01
+#define UNABLE_FIND_TAT_CHANNEL_ERR   0x02
+#define DRQ_ERR                       0x03
+#define READ_BUF_GT_512               0x04
+
+
+
+#define PRI_DATA_PORT         0x1f0
+#define PRI_FEATURES_PORT     0x1f1
+#define PRI_SECT_CNT_PORT     0x1f2
+#define PRI_SECT_ADDR1_PORT   0x1f3
+#define PRI_SECT_ADDR2_PORT   0x1f4
+#define PRI_SECT_ADDR3_PORT   0x1f5
+#define PRI_DRV_SEL_PORT      0x1f6
+#define PRI_CMD_PORT          0x1f7
+#define PRI_CTRL_PORT         0x3f6
+#define PRI_ADDR_REG_PORT     0x3f7
+
+#define SEC_DATA_PORT         0x170
+#define SEC_FEATURES_PORT     0x171
+#define SEC_SECT_CNT_PORT     0x172
+#define SEC_SECT_ADDR1_PORT   0x173
+#define SEC_SECT_ADDR2_PORT   0x174
+#define SEC_SECT_ADDR3_PORT   0x175
+#define SEC_DRV_SEL_PORT      0x176
+#define SEC_CMD_PORT          0x177
+#define SEC_CTRL_PORT         0x376
+#define SEC_ADDR_REG_PORT     0x377
+
+
+
+
+
+#define PACKET_SIZE 12
+
+
+
+// FLAT MODE
+// Open a image. Returns non-negative if successful.
+//int open (const char* pathname);
+
+// Open an image with specific flags. Returns non-negative if successful.
+int rd_open (const char* pathname, int flags);
+
+// Close the image.
+void rd_close ();
+
+// Position ourselves. Return the resulting offset from the
+// beginning of the file.
+off_t rd_lseek (off_t offset, int whence);
+
+// Read count bytes to the buffer buf. Return the number of
+// bytes read (count).
+ssize_t rd_read (void* buf, size_t count);
+
+// Write count bytes from buf. Return the number of bytes
+// written (count).
+ssize_t rd_write (const void* buf, size_t count);
+
+
+
 
-#define RD_PANIC(_f, _a...)     \
-  do {                       \
-    PrintDebug("ramdisk.c(%d) " _f, __LINE__, ## _a);  \
-      while(1);              \
-    }                        \
-   while(0)                                                            
-    
-#define RD_ERROR(_f, _a...) PrintTrace("\nramdisk.c(%d) " _f, __LINE__, ## _a)
 
 /*
  * Debug facilities
 #define INT13_ELTORITO                 0xe2 //0x2fa
 #define INT13_DISKETTE_FUNCTION        0xe3 //0x2fb
 
-// some packet handling macros
-#define EXTRACT_FIELD(arr,byte,start,num_bits) (((arr)[(byte)] >> (start)) & ((1 << (num_bits)) - 1))
-#define get_packet_field(c,b,s,n) (EXTRACT_FIELD((SELECTED_CONTROLLER((c)).buffer),(b),(s),(n)))
-#define get_packet_byte(c,b) (SELECTED_CONTROLLER((c)).buffer[(b)])
-#define get_packet_word(c,b) (((uint16)SELECTED_CONTROLLER((c)).buffer[(b)] << 8) | SELECTED_CONTROLLER((c)).buffer[(b)+1])
-
 
-#define CONTROLLER(c,a) (channels[(c)].drives[(a)]).controller
-#define DRIVE(c,a) (channels[(c)].drives[(a)])
-#define SELECTED_CONTROLLER(c) (CONTROLLER((c), channels[(c)].drive_select))
-#define SELECTED_DRIVE(c) (DRIVE((c), channels[(c)].drive_select))
 
 
-#define DRIVE_IS_PRESENT(c,a) (channels[(c)].drives[(a)].device_type != IDE_NONE)
-#define DRIVE_IS_HD(c,a) (channels[(c)].drives[(a)].device_type == IDE_DISK)
-#define DRIVE_IS_CD(c,a) (channels[(c)].drives[(a)].device_type == IDE_CDROM)
-#define SELECTED_MODEL(c) (channels[(c)].drives[channels[(c)].drive_select].model_no)
-
-#define MASTER_SELECTED(c) (!channels[(c)].drive_select)
-#define SLAVE_SELECTED(c)  (channels[(c)].drive_select)
-
-#define SELECTED_IS_PRESENT(c) (DRIVE_IS_PRESENT((c),SLAVE_SELECTED((c))))
-#define SELECTED_IS_HD(c) (DRIVE_IS_HD((c),SLAVE_SELECTED((c))))
-#define SELECTED_IS_CD(c) (DRIVE_IS_CD((c),SLAVE_SELECTED((c))))
-
-#define ANY_IS_PRESENT(c) (DRIVE_IS_PRESENT((c),0) || DRIVE_IS_PRESENT((c),1))
-#define SELECTED_TYPE_STRING(channel) ((SELECTED_IS_CD(channel)) ? "CD-ROM" : "NONE")
-
-#define WRITE_FEATURES(c,a) do { uint8 _a = a; CONTROLLER((c),0).features = _a; CONTROLLER((c),1).features = _a; } while(0)
-#define WRITE_SECTOR_COUNT(c,a) do { uint8 _a = a; CONTROLLER((c),0).sector_count = _a; CONTROLLER((c),1).sector_count = _a; } while(0)
-#define WRITE_SECTOR_NUMBER(c,a) do { uint8 _a = a; CONTROLLER((c),0).sector_no = _a; CONTROLLER((c),1).sector_no = _a; } while(0)
-#define WRITE_CYLINDER_LOW(c,a) do { uint8 _a = a; CONTROLLER((c),0).cylinder_no = (CONTROLLER((c),0).cylinder_no & 0xff00) | _a; CONTROLLER((c),1).cylinder_no = (CONTROLLER((c),1).cylinder_no & 0xff00) | _a; } while(0)
-#define WRITE_CYLINDER_HIGH(c,a) do { uint16 _a = a; CONTROLLER((c),0).cylinder_no = (_a << 8) | (CONTROLLER((c),0).cylinder_no & 0xff); CONTROLLER((c),1).cylinder_no = (_a << 8) | (CONTROLLER((c),1).cylinder_no & 0xff); } while(0)
-#define WRITE_HEAD_NO(c,a) do { uint8 _a = a; CONTROLLER((c),0).head_no = _a; CONTROLLER((c),1).head_no = _a; } while(0)
-#define WRITE_LBA_MODE(c,a) do { uint8 _a = a; CONTROLLER((c),0).lba_mode = _a; CONTROLLER((c),1).lba_mode = _a; } while(0)
-
-
-
-#define GOTO_RETURN_VALUE  if(io_len==4){\
-                             goto return_value32;\
-                             }\
-                           else if(io_len==2){\
-                             value16=(Bit16u)value32;\
-                             goto return_value16;\
-                             }\
-                           else{\
-                             value8=(Bit8u)value32;\
-                             goto return_value8;\
-                             }
-
-#define UNUSED(x) ((void)x)
-
-#define PACKET_SIZE 12
-
-static struct ramdisk_t *ramdisk_state;
-
+static const char cdrom_str[] = "CD-ROM";
+static const char harddisk_str[] = "HARDDISK";
+static const char none_str[] = "NONE";
 
 
+static inline const char * device_type_to_str(device_type_t type) {
+  switch (type) {
+  case IDE_DISK:
+    return harddisk_str;
+  case IDE_CDROM:
+    return cdrom_str;
+  case IDE_NONE:
+    return none_str;
+  default:
+    return NULL;
+  }
+}
 
 
+static inline void write_features(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.features = value;
+  channel->drives[1].controller.features = value;
+}
 
-////////////////////////////////////////////////////////////////////////////
 
-/*
- * Static routines
- */
+static inline void write_sector_count(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.sector_count = value;
+  channel->drives[1].controller.sector_count = value;
+}
 
-static
-uint_t ramdisk_read_port(ushort_t port,
-                        void *src,
-                        uint_t length,
-                        struct vm_device *dev);
+static inline void write_sector_number(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.sector_no = value;
+  channel->drives[1].controller.sector_no = value;
+}
 
-static
-uint_t ramdisk_write_port(ushort_t port,
-                         void *src,
-                         uint_t length,
-                         struct vm_device *dev);
 
-static
-uint_t ramdisk_read_port_ignore(ushort_t port,
-                               void *src,
-                               uint_t length,
-                               struct vm_device *dev);
+static inline void write_cylinder_low(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.cylinder_no &= 0xff00;
+  channel->drives[0].controller.cylinder_no |= value;
+  channel->drives[1].controller.cylinder_no &= 0xff00;
+  channel->drives[1].controller.cylinder_no |= value;
+}
 
-static
-uint_t ramdisk_write_port_ignore(ushort_t port,
-                                void *src,
-                                uint_t length,
-                                struct vm_device *dev);
+static inline void write_cylinder_high(struct channel_t * channel, uchar_t value) {
+  ushort_t val2 = value;
+  val2 = val2 << 8;
+  channel->drives[0].controller.cylinder_no &= 0x00ff;
+  channel->drives[0].controller.cylinder_no |= (val2 & 0xff00);
 
+  channel->drives[1].controller.cylinder_no &= 0x00ff;
+  channel->drives[1].controller.cylinder_no |= (val2 & 0xff00);
+}
 
-static
-Bit32u rd_read_handler(struct channel_t *channels, Bit32u address, unsigned io_len);
+static inline void write_head_no(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.head_no = value;
+  channel->drives[1].controller.head_no = value;
+}
 
-static
-void rd_write_handler(struct channel_t *channels, Bit32u address, 
-                     Bit32u value, unsigned io_len);
+static inline void write_lba_mode(struct channel_t * channel, uchar_t value) {
+  channel->drives[0].controller.lba_mode = value;
+  channel->drives[1].controller.lba_mode = value;
+}
 
 
+static inline uint_t get_channel_no(struct ramdisk_t * ramdisk, struct channel_t * channel) {
+  return (((uchar_t *)channel - (uchar_t *)(ramdisk->channels)) / sizeof(struct channel_t));
+}
 
-/*
- * ATAPI routines
- */
+static inline uint_t get_drive_no(struct channel_t * channel, struct drive_t * drive) {
+  return (((uchar_t *)drive - (uchar_t*)(channel->drives)) /  sizeof(struct drive_t));
+}
 
-static 
-void rd_identify_ATAPI_drive(struct channel_t *channels, Bit8u channel);
+static inline struct drive_t * get_selected_drive(struct channel_t * channel) {
+  return &(channel->drives[channel->drive_select]);
+}
 
 
-static 
-void rd_init_send_atapi_command(struct channel_t *channels, Bit8u channel, Bit8u command, int req_length, int alloc_length, bool lazy /*= false*/);
+static inline int is_primary_port(struct ramdisk_t * ramdisk, ushort_t port) {
+  switch(port) 
+    {
+    case PRI_DATA_PORT:
+    case PRI_FEATURES_PORT:
+    case PRI_SECT_CNT_PORT:
+    case PRI_SECT_ADDR1_PORT:
+    case PRI_SECT_ADDR2_PORT:
+    case PRI_SECT_ADDR3_PORT:
+    case PRI_DRV_SEL_PORT:
+    case PRI_CMD_PORT:
+    case PRI_CTRL_PORT:
+      return 1;
+    default:
+      return 0;
+    }
+}
 
-static 
-void rd_ready_to_send_atapi(struct channel_t *channels, Bit8u channel);
 
 
-static 
-void rd_atapi_cmd_error(struct channel_t *channels, Bit8u channel, sense_t sense_key, asc_t asc);
+static inline int is_secondary_port(struct ramdisk_t * ramdisk, ushort_t port) {
+  switch(port) 
+    {
+    case SEC_DATA_PORT:
+    case SEC_FEATURES_PORT:
+    case SEC_SECT_CNT_PORT:
+    case SEC_SECT_ADDR1_PORT:
+    case SEC_SECT_ADDR2_PORT:
+    case SEC_SECT_ADDR3_PORT:
+    case SEC_DRV_SEL_PORT:
+    case SEC_CMD_PORT:
+    case SEC_CTRL_PORT:
+      return 1;
+    default:
+      return 0;
+    }
+}
 
-static 
-void rd_init_mode_sense_single(struct channel_t *channels, Bit8u channel, const void* src, int size);
+static inline int num_drives_on_channel(struct channel_t * channel) {
+  if ((channel->drives[0].device_type == IDE_NONE) &&
+      (channel->drives[1].device_type == IDE_NONE)) {
+    return 0;
+  } else if ((channel->drives[0].device_type != IDE_NONE) &&
+            (channel->drives[1].device_type != IDE_NONE)) {
+    return 2;
+  } else {
+    return 1;
+  }
+}
 
-static 
-void rd_atapi_cmd_nop(struct channel_t *channels, Bit8u channel);
 
-static
-void rd_command_aborted(struct channel_t *channels, Bit8u channel, unsigned value);
 
+static inline uchar_t extract_bits(uchar_t * buf, uint_t buf_offset, uint_t bit_offset, uint_t num_bits) {
+  uchar_t val = buf[buf_offset];
+  val = val >> bit_offset;
+  val &= ((1 << num_bits) -1);
+  return val;
+}
 
-/*
- * Interrupt handling
- */
 
-static 
-void rd_raise_interrupt(struct channel_t *channels, Bit8u channel);
+static inline uchar_t get_packet_field(struct channel_t * channel, uint_t packet_offset, uint_t bit_offset, uint_t num_bits) {
+  struct drive_t * drive = get_selected_drive(channel);
+  return extract_bits(drive->controller.buffer, packet_offset, bit_offset, num_bits);
+}
 
-static 
-void rd_lower_irq(struct vm_device *dev, Bit32u irq);
 
+static inline uchar_t get_packet_byte(struct channel_t * channel, uint_t offset) {
+  struct drive_t * drive = get_selected_drive(channel);
+  return drive->controller.buffer[offset];
+}
 
+static inline uint16_t get_packet_word(struct channel_t * channel, uint_t offset) {
+  struct drive_t * drive = get_selected_drive(channel);
+  uint16_t val = drive->controller.buffer[offset];
+  val = val << 8;
+  val |= drive->controller.buffer[offset + 1];
+  return val;
+}
 
-/*
- * Helper routines
- */
 
-uint16 rd_read_16bit(const uint8* buf) 
-{
+static inline uint16_t rd_read_16bit(const uint8_t* buf) {
   return (buf[0] << 8) | buf[1];
 }
 
 
 
-uint32 rd_read_32bit(const uint8* buf) 
-{
+static inline uint32_t rd_read_32bit(const uint8_t* buf) {
   return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
 }
 
-////////////////////////////////////////////////////////////////////
-
-
-void rd_print_state(struct ramdisk_t *ramdisk, 
-                        struct vm_device *dev)
-//Bit32u   rd_init_harddrive(struct channel_t *channels)
-{
-
-  uchar_t channel; 
-  uchar_t device;
-  struct channel_t *channels = (struct channel_t *)(&(ramdisk->channels));
+////////////////////////////////////////////////////////////////////////////
 
-  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++)
-    memset((char *)(channels + channel), 0, sizeof(struct channel_t));
 
-  Ramdisk_Print("sizeof(*channels) = %d\n", sizeof((*channels)));
-  Ramdisk_Print("sizeof(channles->drives[0].controller) = %d\n", sizeof((channels->drives[0].controller)));
-  Ramdisk_Print("sizeof(channles->drives[0].cdrom) = %d\n", sizeof((channels->drives[0].cdrom)));
-  Ramdisk_Print("sizeof(channles->drives[0].sense) = %d\n", sizeof((channels->drives[0].sense)));
-  Ramdisk_Print("sizeof(channles->drives[0].atapi) = %d\n", sizeof((channels->drives[0].atapi)));
+/*
+ * ATAPI routines
+ */
 
 
-  Ramdisk_Print("sizeof(channles->drives[0].controller.status) = %d\n", sizeof((channels->drives[0].controller.status)));
-  Ramdisk_Print("sizeof(channles->drives[0].controller.sector_count) = %d\n", sizeof((channels->drives[0].controller.sector_count)));
-  Ramdisk_Print("sizeof(channles->drives[0].controller.interrupt_reason) = %d\n", sizeof((channels->drives[0].controller.interrupt_reason)));
+static void rd_init_mode_sense_single(struct vm_device * dev, struct channel_t * channel, const void * src, int size);
 
-  Ramdisk_Print("sizeof(channles->drives[0].controller.cylinder_no) = %d\n", sizeof((channels->drives[0].controller.cylinder_no)));
-  Ramdisk_Print("sizeof(channles->drives[0].controller.byte_count) = %d\n", sizeof((channels->drives[0].controller.byte_count)));
+static void rd_command_aborted(struct vm_device * dev, struct channel_t * channel, unsigned value);
 
 
-  Ramdisk_Print("sizeof(channles->drives[0].controller.control) = %d\n", sizeof((channels->drives[0].controller.control)));
 
 
-  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++){
-  
-    for (device = 0; device < 2; device++){
-                  
-      // Initialize controller state, even if device is not present
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.busy = %d\n",channel, device, channels[channel].drives[device].controller.status.busy);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.drive_ready = %d\n", channel, device, channels[channel].drives[device].controller.status.drive_ready);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.write_fault = %d\n", channel, device, channels[channel].drives[device].controller.status.write_fault);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.seek_complete = %d\n", channel, device, channels[channel].drives[device].controller.status.seek_complete);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.drq = %d\n", channel, device, channels[channel].drives[device].controller.status.drq);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.corrected_data = %d\n", channel, device, channels[channel].drives[device].controller.status.corrected_data);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.index_pulse = %d\n", channel, device, channels[channel].drives[device].controller.status.index_pulse);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.index_pulse_count = %d\n", channel, device, channels[channel].drives[device].controller.status.index_pulse_count);
-      Ramdisk_Print("channels[%d].drives[%d].controller.status.err = %d\n", channel, device, channels[channel].drives[device].controller.status.err);
+static int handle_atapi_packet_command(struct vm_device * dev, 
+                                      struct channel_t * channel, 
+                                      ushort_t val);
 
+static int rd_init_send_atapi_command(struct vm_device * dev, 
+                                     struct channel_t * channel, 
+                                     Bit8u command, int req_length, 
+                                     int alloc_length, bool lazy);
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.error_register = %d\n", channel, device, channels[channel].drives[device].controller.error_register);
-      Ramdisk_Print("channels[%d].drives[%d].controller.head_no = %d\n", channel, device, channels[channel].drives[device].controller.head_no);
-      Ramdisk_Print("channels[%d].drives[%d].controller.sector_count = %d\n", channel, device, channels[channel].drives[device].controller.sector_count);
-      Ramdisk_Print("channels[%d].drives[%d].controller.sector_no = %d\n", channel, device, channels[channel].drives[device].controller.sector_no);
-      Ramdisk_Print("channels[%d].drives[%d].controller.cylinder_no = %d\n", channel, device, channels[channel].drives[device].controller.cylinder_no);
-      Ramdisk_Print("channels[%d].drives[%d].controller.current_command = %02x\n", channel, device, channels[channel].drives[device].controller.current_command);
-      Ramdisk_Print("channels[%d].drives[%d].controller.buffer_index = %d\n", channel, device, channels[channel].drives[device].controller.buffer_index);
+static void rd_ready_to_send_atapi(struct vm_device * dev, 
+                                  struct channel_t * channel);
 
+static void rd_atapi_cmd_error(struct vm_device * dev, 
+                              struct channel_t * channel, 
+                              sense_t sense_key, asc_t asc);
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.control.reset = %d\n", channel, device, channels[channel].drives[device].controller.control.reset);
-      Ramdisk_Print("channels[%d].drives[%d].controller.control.disable_irq = %d\n", channel, device, channels[channel].drives[device].controller.control.disable_irq);
+static void rd_atapi_cmd_nop(struct vm_device * dev, struct channel_t * channel);
+static void rd_identify_ATAPI_drive(struct vm_device * dev, struct channel_t * channel);
 
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.reset_in_progress = %d\n", channel, device, channels[channel].drives[device].controller.reset_in_progress);
-      Ramdisk_Print("channels[%d].drives[%d].controller.sectors_per_block = %02x\n", channel, device, channels[channel].drives[device].controller.sectors_per_block); 
-      Ramdisk_Print("channels[%d].drives[%d].controller.lba_mode = %d\n", channel, device, channels[channel].drives[device].controller.lba_mode); 
-      Ramdisk_Print("channels[%d].drives[%d].controller.features = %d\n", channel, device, channels[channel].drives[device].controller.features); 
 
+/*
+ * Interrupt handling
+ */
+static void rd_raise_interrupt(struct vm_device * dev, struct channel_t * channel);
+static void rd_lower_irq(struct vm_device *dev, Bit32u irq);
 
-      Ramdisk_Print("channels[%d].drives[%d].model_no = %s\n", channel, device, channels[channel].drives[device].model_no); 
-      Ramdisk_Print("channels[%d].drives[%d].device_type = %d\n", channel, device, channels[channel].drives[device].device_type); 
-      Ramdisk_Print("channels[%d].drives[%d].cdrom.locked = %d\n", channel, device, channels[channel].drives[device].cdrom.locked); 
-      Ramdisk_Print("channels[%d].drives[%d].sense.sense_key = %d\n", channel, device, channels[channel].drives[device].sense.sense_key); 
-      Ramdisk_Print("channels[%d].drives[%d].sense.asc = %d\n", channel, device, channels[channel].drives[device].sense.asc); 
-      Ramdisk_Print("channels[%d].drives[%d].sense.ascq = %d\n", channel, device, channels[channel].drives[device].sense.ascq); 
 
 
+/*
+ * Helper routines
+ */
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.c_d = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.c_d);
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.i_o = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.i_o);
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.rel = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.rel);
+#ifdef DEBUG_RAMDISK
+static void rd_print_state(struct ramdisk_t *ramdisk);
+static int check_bit_fields(struct controller_t * controller);
+#endif
+////////////////////////////////////////////////////////////////////
 
-      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.tag = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.tag);
 
-      Ramdisk_Print("channels[%d].drives[%d].cdrom.ready = %d\n", channel, device, channels[channel].drives[device].cdrom.ready);
-      
-    }//for device
-  }//for channel
-  
-  return;
-}
 
 
-Bit32u rd_init_harddrive(struct ramdisk_t *ramdisk, 
-                        struct vm_device *dev)
-{
 
-  
-  uchar_t channel; 
-  uchar_t device;
+static Bit32u rd_init_hardware(struct ramdisk_t *ramdisk) {
+  uint_t channel_num; 
+  uint_t device;
   struct channel_t *channels = (struct channel_t *)(&(ramdisk->channels));
 
-  Ramdisk_Print("[rd_init_harddrive]\n");
-  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++)
-    memset((char *)(channels + channel), 0, sizeof(struct channel_t));
+  PrintDebug("[rd_init_harddrive]\n");
 
+  for (channel_num = 0; channel_num < MAX_ATA_CHANNEL; channel_num++) {
+    memset((char *)(channels + channel_num), 0, sizeof(struct channel_t));
+  }
 
-  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++){
-  
-    channels[channel].ioaddr1 = 0x0;
-    channels[channel].ioaddr2 = 0x0;
-    channels[channel].irq = 0;
+  for (channel_num = 0; channel_num < MAX_ATA_CHANNEL; channel_num++){
+    struct channel_t * channel = &(channels[channel_num]);
+
+    channel->ioaddr1 = 0x0;
+    channel->ioaddr2 = 0x0;
+    channel->irq = 0;
 
     for (device = 0; device < 2; device++){
+      struct drive_t * drive = &(channel->drives[device]);
+      struct controller_t * controller = &(drive->controller);
+
+      controller->status.busy = 0;
+      controller->status.drive_ready = 1;
+      controller->status.write_fault = 0;
+      controller->status.seek_complete = 1;
+      controller->status.drq = 0;
+      controller->status.corrected_data = 0;
+      controller->status.index_pulse = 0;
+      controller->status.index_pulse_count = 0;
+      controller->status.err = 0;
+
+      controller->error_register = 0x01; // diagnostic code: no error
+      controller->head_no = 0;
+      controller->sector_count = 1;
+      controller->sector_no = 1;
+      controller->cylinder_no = 0;
+      controller->current_command = 0x00;
+      controller->buffer_index = 0;
+
+      controller->control.reset = 0;
+      controller->control.disable_irq = 0;
+      controller->reset_in_progress = 0;
+
+      controller->sectors_per_block = 0x80;
+      controller->lba_mode = 0;
       
-
-      CONTROLLER(channel,device).status.busy           = 0;
-      CONTROLLER(channel,device).status.drive_ready    = 1;
-      CONTROLLER(channel,device).status.write_fault    = 0;
-      CONTROLLER(channel,device).status.seek_complete  = 1;
-      CONTROLLER(channel,device).status.drq            = 0;
-      CONTROLLER(channel,device).status.corrected_data = 0;
-      CONTROLLER(channel,device).status.index_pulse    = 0;
-      CONTROLLER(channel,device).status.index_pulse_count = 0;
-      CONTROLLER(channel,device).status.err            = 0;
-
-      CONTROLLER(channel,device).error_register = 0x01; // diagnostic code: no error
-      CONTROLLER(channel,device).head_no        = 0;
-      CONTROLLER(channel,device).sector_count   = 1;
-      CONTROLLER(channel,device).sector_no      = 1;
-      CONTROLLER(channel,device).cylinder_no    = 0;
-      CONTROLLER(channel,device).current_command = 0x00;
-      CONTROLLER(channel,device).buffer_index = 0;
-
-      CONTROLLER(channel,device).control.reset       = 0;
-      CONTROLLER(channel,device).control.disable_irq = 0;
-      CONTROLLER(channel,device).reset_in_progress   = 0;
-
-      CONTROLLER(channel,device).sectors_per_block   = 0x80;
-      CONTROLLER(channel,device).lba_mode            = 0;
       
-      CONTROLLER(channel,device).features            = 0;
+      controller->features = 0;
        
-         // If not present
-      channels[channel].drives[device].device_type           = IDE_NONE;
+      // If not present
+      drive->device_type = IDE_NONE;
 
       // Make model string
-      strncpy((char*)channels[channel].drives[device].model_no, 
-             "", 40);
-      while(strlen((char *)channels[channel].drives[device].model_no) < 40) {
-        strcat ((char*)channels[channel].drives[device].model_no, " ");
+      strncpy((char*)(drive->model_no), "", 40);
+      while(strlen((char *)(drive->model_no)) < 40) {
+        strcat ((char*)(drive->model_no), " ");
       }
 
-//      Ramdisk_Print("channels[%d].drives[%d].controller.current_command = %02x\n", channel, device, channels[channel].drives[device].controller.current_command);
-//      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.c_d = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.c_d);
-
-//      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.i_o = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.i_o);
 
-//      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.rel = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.rel);
-
-//      Ramdisk_Print("channels[%d].drives[%d].controller.interrupt_reason.tag = %02x\n", channel, device, channels[channel].drives[device].controller.interrupt_reason.tag);
-      
-//      Ramdisk_Print("channels[%d].drives[%d].controller.control.disable_irq = %d\n", channel, device, channels[channel].drives[device].controller.control.disable_irq);
       
       
-      
-      if (channel == 1) {
+      if (channel_num == 1) {
 
-       channels[channel].ioaddr1 = 0x170;
-       channels[channel].ioaddr2 = 0x370;
-       channels[channel].irq =  15;
-       channels[channel].drive_select = 0;
+       channel->ioaddr1 = 0x170;
+       channel->ioaddr2 = 0x370;
+       channel->irq =  15;
+       channel->drive_select = 0;
        
        if (device == 0) {
          // Make model string
-         strncpy((char*)channels[channel].drives[device].model_no, 
-                 "Zheng's Ramdisk", 40);
-         while (strlen((char *)channels[channel].drives[device].model_no) < 40) {
-           strcat ((char*)channels[channel].drives[device].model_no, " ");
+         strncpy((char*)(drive->model_no), "V3VEE Ramdisk", 40);
+         while (strlen((char *)(drive->model_no)) < 40) {
+           strcat ((char*)(drive->model_no), " ");
          }
-
-         Ramdisk_Print("CDROM on target %d/%d\n", channel, device);
          
-         channels[channel].drives[device].device_type = IDE_CDROM;
-         channels[channel].drives[device].cdrom.locked = 0;
-         channels[channel].drives[device].sense.sense_key = SENSE_NONE;
-         channels[channel].drives[device].sense.asc = 0;
-         channels[channel].drives[device].sense.ascq = 0;
+         PrintDebug("CDROM on target %d/%d\n", channel_num, device);
          
-
-         //Check bit fields
-         channels[channel].drives[device].controller.sector_count = 0;
-         channels[channel].drives[device].controller.interrupt_reason.c_d = 1;
-         if (channels[channel].drives[device].controller.sector_count != 0x01) {
-           Ramdisk_Print("interrupt reason bit field error\n");
-           return INTR_REASON_BIT_ERR;
-         }
-
-         channels[channel].drives[device].controller.sector_count = 0;
-         channels[channel].drives[device].controller.interrupt_reason.i_o = 1;
-         if (channels[channel].drives[device].controller.sector_count != 0x02) {
-           Ramdisk_Print("interrupt reason bit field error\n");
-           return INTR_REASON_BIT_ERR;
-         }
+         drive->device_type = IDE_CDROM;
+         drive->cdrom.locked = 0;
+         drive->sense.sense_key = SENSE_NONE;
+         drive->sense.asc = 0;
+         drive->sense.ascq = 0;
          
-         channels[channel].drives[device].controller.sector_count = 0;
-         channels[channel].drives[device].controller.interrupt_reason.rel = 1;
-         if (channels[channel].drives[device].controller.sector_count != 0x04) {
-           Ramdisk_Print("interrupt reason bit field error\n");
-           return INTR_REASON_BIT_ERR;
-         }
-       
-         channels[channel].drives[device].controller.sector_count = 0;
-         channels[channel].drives[device].controller.interrupt_reason.tag = 3;
-         if (channels[channel].drives[device].controller.sector_count != 0x18) {
-           Ramdisk_Print("interrupt reason bit field error\n");
+#ifdef DEBUG_RAMDISK
+         if (check_bit_fields(controller) == INTR_REASON_BIT_ERR) {
+           PrintDebug("interrupt reason: bit field error\n");
            return INTR_REASON_BIT_ERR;
          }
+#endif
          
-         
-         channels[channel].drives[device].controller.sector_count = 0;
+         controller->sector_count = 0;
 
          // allocate low level driver
-         channels[channel].drives[device].cdrom.cd = (struct cdrom_interface*)V3_Malloc(sizeof(struct cdrom_interface));
-         Ramdisk_Print("cd = %x\n", channels[channel].drives[device].cdrom.cd);
-         V3_ASSERT(channels[channel].drives[device].cdrom.cd != NULL);
+         drive->cdrom.cd = (struct cdrom_interface *)V3_Malloc(sizeof(struct cdrom_interface));
+         PrintDebug("cd = %x\n", drive->cdrom.cd);
+         V3_ASSERT(drive->cdrom.cd != NULL);
          
-         struct cdrom_interface *cdif = channels[channel].drives[device].cdrom.cd;
+         struct cdrom_interface * cdif = drive->cdrom.cd;
          memset(cdif, 0, sizeof(struct cdrom_interface));
          init_cdrom(cdif);
          cdif->ops.init(cdif);
 
-         Ramdisk_Print("\t\tCD on ata%d-%d: '%s'\n",channel, device, "");
+         PrintDebug("\t\tCD on ata%d-%d: '%s'\n", 
+                    channel_num, 
+                    device, "");
          
-         if((channels[channel].drives[device].cdrom.cd->ops).insert_cdrom(cdif, NULL)) {
-           Ramdisk_Print("\t\tMedia present in CD-ROM drive\n");
-           channels[channel].drives[device].cdrom.ready = 1;
-           channels[channel].drives[device].cdrom.capacity = channels[channel].drives[device].cdrom.cd->ops.capacity(cdif);
+         if((drive->cdrom.cd->ops).insert_cdrom(cdif, NULL)) {
+           PrintDebug("\t\tMedia present in CD-ROM drive\n");
+           drive->cdrom.ready = 1;
+           drive->cdrom.capacity = drive->cdrom.cd->ops.capacity(cdif);
          } else {                  
-           Ramdisk_Print("\t\tCould not locate CD-ROM, continuing with media not present\n");
-           channels[channel].drives[device].cdrom.ready = 0;
+           PrintDebug("\t\tCould not locate CD-ROM, continuing with media not present\n");
+           drive->cdrom.ready = 0;
          }
          
        }//if device = 0
@@ -460,23 +470,20 @@ Bit32u rd_init_harddrive(struct ramdisk_t *ramdisk,
     }//for device
   }//for channel
 
-  ramdisk->private_data = dev;
-  ramdisk_state = ramdisk;
-  Ramdisk_Print("ramdisk_state = %x\n", ramdisk_state);
-  Ramdisk_Print("ramdisk = %x\n", ramdisk);
-  //  rd_print_state(ramdisk, dev);
+#ifdef DEBUG_RAMDISK
+  rd_print_state(ramdisk);
+#endif
   return 0;
 }
 
 
-void   rd_reset_harddrive(struct ramdisk_t *ramdisk, unsigned type)
-{
+/*
+  static void rd_reset_harddrive(struct ramdisk_t *ramdisk, unsigned type) {
   return;
-}
-
+  }
 
-void   rd_close_harddrive(struct ramdisk_t *ramdisk)
-{
+*/
+static void rd_close_harddrive(struct ramdisk_t *ramdisk) {
   return;
 }
 
@@ -484,1141 +491,1662 @@ void   rd_close_harddrive(struct ramdisk_t *ramdisk)
 ////////////////////////////////////////////////////////////////////
 
 
-static
-Bit32u rd_read_handler(struct channel_t *channels, Bit32u address, unsigned io_len)
-{
-  Bit8u value8;
-  Bit16u value16;
-  Bit32u value32;
-
-  unsigned drive_select;
-  unsigned index;      
-  unsigned increment = 0;
-
-  Bit8u  channel = MAX_ATA_CHANNEL;
-  Bit32u port = 0xff; // undefined
 
-  Ramdisk_Print("[rd_read_handler]\n");
+static int read_data_port(ushort_t port, void * dst, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
 
-  for (channel=0; channel<MAX_ATA_CHANNEL; channel++) {
-    if ((address & 0xfff8) == channels[channel].ioaddr1) {
-      port = address - channels[channel].ioaddr1;
-      break;
-      }
-    else if ((address & 0xfff8) == channels[channel].ioaddr2) {
-      port = address - channels[channel].ioaddr2 + 0x10;
-      break;
-      }
-    }
 
-  if (channel == MAX_ATA_CHANNEL) {
-    if ((address < 0x03f6) || (address > 0x03f7)) {
-      RD_PANIC("Error: read: unable to find ATA channel, ioport=0x%04x\n", address);
-      return 0;
-    } else {
-      channel = 0;
-      port = address - 0x03e0;
-    }
-  }
 
-  drive_select = channels[channel].drive_select;
-  if (port != 0x00){
-    Ramdisk_Print("[R_handler] IO read addr at %x, on drive %d/%d, curcmd = %02x\n", address, channel, drive_select, SELECTED_CONTROLLER(channel).current_command);
-  }else{
-    
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
   }
+  
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
 
 
-  struct cdrom_interface *cdif = channels[channel].drives[drive_select].cdrom.cd;
-  switch (port) {
+  PrintDebug("[read_data_handler] IO Read at 0x%x, on drive %d/%d (current_cmd = 0x%02x)\n", 
+            port, 
+            get_channel_no(ramdisk, channel),
+            get_drive_no(channel, drive),
+            controller->current_command);
 
-  case 0x00: // hard disk data (16bit) 0x1f0
+  switch (controller->current_command) {
+  case 0xec:    // IDENTIFY DEVICE
+  case 0xa1:
+    {
 
-    switch (SELECTED_CONTROLLER(channel).current_command) {
-    case 0xec:    // IDENTIFY DEVICE
-    case 0xa1:
 
-      index = 0;
-      SELECTED_CONTROLLER(channel).status.busy = 0;
-      SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-      SELECTED_CONTROLLER(channel).status.write_fault = 0;
-      SELECTED_CONTROLLER(channel).status.seek_complete = 1;
-      SELECTED_CONTROLLER(channel).status.corrected_data = 0;
-      SELECTED_CONTROLLER(channel).status.err = 0;
+      controller->status.busy = 0;
+      controller->status.drive_ready = 1;
+      controller->status.write_fault = 0;
+      controller->status.seek_complete = 1;
+      controller->status.corrected_data = 0;
+      controller->status.err = 0;
+      
+      /*
+       value32 = controller->buffer[index];
+       index++;
        
-      index = SELECTED_CONTROLLER(channel).buffer_index;
-      value32 = SELECTED_CONTROLLER(channel).buffer[index];
-      index++;
-
-      if (io_len >= 2) {
-       value32 |= (SELECTED_CONTROLLER(channel).buffer[index] << 8);
+       if (io_len >= 2) {
+       value32 |= (controller->buffer[index] << 8);
        index++;
-      }
-      if (io_len == 4) {
-       value32 |= (SELECTED_CONTROLLER(channel).buffer[index] << 16);
-       value32 |= (SELECTED_CONTROLLER(channel).buffer[index+1] << 24);
+       }
+       
+       if (io_len == 4) {
+       value32 |= (controller->buffer[index] << 16);
+       value32 |= (controller->buffer[index+1] << 24);
        index += 2;
-      }
-      SELECTED_CONTROLLER(channel).buffer_index = index;
-      
-      if (SELECTED_CONTROLLER(channel).buffer_index >= 512) {
+       }
        
-       SELECTED_CONTROLLER(channel).status.drq = 0;
+       controller->buffer_index = index;
+      */
+      /* JRL */
+      memcpy(dst, controller->buffer + controller->buffer_index, length);
+      controller->buffer_index += length;
+      
+      if (controller->buffer_index >= 512) {
+       controller->status.drq = 0;
       }
-      GOTO_RETURN_VALUE;
-
-    case 0xa0: //send packet cmd 
+      
+      return length;
+    }
+  case 0xa0: //send packet cmd 
+    {
+      uint_t index = controller->buffer_index;
 
-       index = SELECTED_CONTROLLER(channel).buffer_index;
-       increment = 0;
-       Ramdisk_Print("\t\tatapi.command(%02x), index(%d), cdrom.remaining_blocks(%d)\n", SELECTED_DRIVE(channel).atapi.command, index, SELECTED_DRIVE(channel).cdrom.remaining_blocks);
-       // Load block if necessary
-       if (index >= 2048) {
-         if (index > 2048)
-           RD_PANIC("\t\tindex > 2048 : 0x%x\n",index);
-         switch (SELECTED_DRIVE(channel).atapi.command) {
-         case 0x28: // read (10)
-         case 0xa8: // read (12)
-
-           if (!SELECTED_DRIVE(channel).cdrom.ready) {
-             RD_PANIC("\t\tRead with CDROM not ready\n");
+      
+      PrintDebug("\t\tatapi.command(%02x), index(%d), cdrom.remaining_blocks(%d)\n", 
+                   drive->atapi.command, 
+                   index, 
+                   drive->cdrom.remaining_blocks);
+      
+      // Load block if necessary
+      if (index >= 2048) {
+       
+       if (index > 2048) {
+         PrintError("\t\tindex > 2048 : 0x%x\n", index);
+         return -1;
+       }
+       
+       switch (drive->atapi.command) {
+       case 0x28: // read (10)
+       case 0xa8: // read (12)
+         {
+           struct cdrom_interface * cdif = drive->cdrom.cd;
+           
+           if (!(drive->cdrom.ready)) {
+             PrintError("\t\tRead with CDROM not ready\n");
+             return -1;
            } 
-           SELECTED_DRIVE(channel).cdrom.cd->ops.read_block(cdif, SELECTED_CONTROLLER(channel).buffer,
-                                                           SELECTED_DRIVE(channel).cdrom.next_lba);
-           SELECTED_DRIVE(channel).cdrom.next_lba++;
-           SELECTED_DRIVE(channel).cdrom.remaining_blocks--;
+           
+           drive->cdrom.cd->ops.read_block(cdif, controller->buffer,
+                                           drive->cdrom.next_lba);
+           drive->cdrom.next_lba++;
+           drive->cdrom.remaining_blocks--;
            
            
-           if (!SELECTED_DRIVE(channel).cdrom.remaining_blocks)
-             Ramdisk_Print("\t\tLast READ block loaded {CDROM}\n");
-           else
-             Ramdisk_Print("\t\tREAD block loaded (%d remaining) {CDROM}\n",
-                           SELECTED_DRIVE(channel).cdrom.remaining_blocks);
+           if (!(drive->cdrom.remaining_blocks)) {
+             PrintDebug("\t\tLast READ block loaded {CDROM}\n");
+           } else {
+             PrintDebug("\t\tREAD block loaded (%d remaining) {CDROM}\n",
+                        drive->cdrom.remaining_blocks);
+           }
            
            // one block transfered, start at beginning
            index = 0;
            break;
-           
-         default: // no need to load a new block
-           break;
          }
+       default: // no need to load a new block
+         break;
        }
+      }
+    
 
-       value32 = SELECTED_CONTROLLER(channel).buffer[index+increment];
+      /*
+       increment = 0;
+       value32 = controller->buffer[index + increment];
        increment++;
+       
        if (io_len >= 2) {
-         value32 |= (SELECTED_CONTROLLER(channel).buffer[index+increment] << 8);
-         increment++;
+       value32 |= (controller->buffer[index + increment] << 8);
+       increment++;
        }
+       
        if (io_len == 4) {
-         value32 |= (SELECTED_CONTROLLER(channel).buffer[index+increment] << 16);
-         value32 |= (SELECTED_CONTROLLER(channel).buffer[index+increment+1] << 24);
-         increment += 2;
+       value32 |= (controller->buffer[index + increment] << 16);
+       value32 |= (controller->buffer[index + increment + 1] << 24);
+       increment += 2;
        }
-       SELECTED_CONTROLLER(channel).buffer_index = index + increment;
-       SELECTED_CONTROLLER(channel).drq_index += increment;
+
+       controller->buffer_index = index + increment;
+       controller->drq_index += increment;
+
+      */
+      /* JRL: CHECK THAT there is enough data in the buffer to copy.... */
+      {      
+       memcpy(dst, controller->buffer + index, length);
+       
+       controller->buffer_index  = index + length;
+       controller->drq_index += length;
+      }
+      
+      /* *** */
+      
+      if (controller->drq_index >= (unsigned)drive->atapi.drq_bytes) {
+       controller->status.drq = 0;
+       controller->drq_index = 0;
+       
+       drive->atapi.total_bytes_remaining -= drive->atapi.drq_bytes;
        
-       if (SELECTED_CONTROLLER(channel).drq_index >= (unsigned)SELECTED_DRIVE(channel).atapi.drq_bytes) {
-         SELECTED_CONTROLLER(channel).status.drq = 0;
-         SELECTED_CONTROLLER(channel).drq_index = 0;
+       if (drive->atapi.total_bytes_remaining > 0) {
+         // one or more blocks remaining (works only for single block commands)
          
-         SELECTED_DRIVE(channel).atapi.total_bytes_remaining -= SELECTED_DRIVE(channel).atapi.drq_bytes;
+         PrintDebug("\t\tPACKET drq bytes read\n");
+         controller->interrupt_reason.i_o = 1;
+         controller->status.busy = 0;
+         controller->status.drq = 1;
+         controller->interrupt_reason.c_d = 0;
          
-         if (SELECTED_DRIVE(channel).atapi.total_bytes_remaining > 0) {
-           // one or more blocks remaining (works only for single block commands)
-
-           Ramdisk_Print("\t\tPACKET drq bytes read\n");
-           SELECTED_CONTROLLER(channel).interrupt_reason.i_o = 1;
-           SELECTED_CONTROLLER(channel).status.busy = 0;
-           SELECTED_CONTROLLER(channel).status.drq = 1;
-           SELECTED_CONTROLLER(channel).interrupt_reason.c_d = 0;
-           
-           // set new byte count if last block
-           if (SELECTED_DRIVE(channel).atapi.total_bytes_remaining < SELECTED_CONTROLLER(channel).byte_count) {
-             SELECTED_CONTROLLER(channel).byte_count = SELECTED_DRIVE(channel).atapi.total_bytes_remaining;
-           }
-           SELECTED_DRIVE(channel).atapi.drq_bytes = SELECTED_CONTROLLER(channel).byte_count;
-           
-           rd_raise_interrupt(channels, channel);
-         } else {
-           // all bytes read
-           Ramdisk_Print("\t\tPACKET all bytes read\n");
-           SELECTED_CONTROLLER(channel).interrupt_reason.i_o = 1;
-           SELECTED_CONTROLLER(channel).interrupt_reason.c_d = 1;
-           SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-           SELECTED_CONTROLLER(channel).interrupt_reason.rel = 0;
-           SELECTED_CONTROLLER(channel).status.busy = 0;
-           SELECTED_CONTROLLER(channel).status.drq = 0;
-           SELECTED_CONTROLLER(channel).status.err = 0;
-           
-           rd_raise_interrupt(channels, channel);
+         // set new byte count if last block
+         if (drive->atapi.total_bytes_remaining < controller->byte_count) {
+           controller->byte_count = drive->atapi.total_bytes_remaining;
          }
+         drive->atapi.drq_bytes = controller->byte_count;
+         
+         rd_raise_interrupt(dev, channel);
+       } else {
+         // all bytes read
+         PrintDebug("\t\tPACKET all bytes read\n");
+         
+         controller->interrupt_reason.i_o = 1;
+         controller->interrupt_reason.c_d = 1;
+         controller->status.drive_ready = 1;
+         controller->interrupt_reason.rel = 0;
+         controller->status.busy = 0;
+         controller->status.drq = 0;
+         controller->status.err = 0;
+         
+         rd_raise_interrupt(dev, channel);
        }
-       GOTO_RETURN_VALUE;
-       break;
-      
-    default:
-      Ramdisk_Print("\t\tread need support more command: %02x\n", SELECTED_CONTROLLER(channel).current_command);
+      }
+      return length;
       break;
     }
-    ///////////////////////////////////////////
-
-  case 0x01: // hard disk error register 0x1f1
 
-    SELECTED_CONTROLLER(channel).status.err = 0;
-    value8 = (!SELECTED_IS_PRESENT(channel)) ? 0 : SELECTED_CONTROLLER(channel).error_register;
-    goto return_value8;
-    break;
-  case 0x02: // hard disk sector count / interrupt reason 0x1f2
-    value8 = (!SELECTED_IS_PRESENT(channel)) ? 0 : SELECTED_CONTROLLER(channel).sector_count;
-    goto return_value8;
+  default:
+    PrintDebug("\t\tread need support more command: %02x\n", controller->current_command);
     break;
-  case 0x03: // sector number 0x1f3
-    value8 = (!SELECTED_IS_PRESENT(channel)) ? 0 : SELECTED_CONTROLLER(channel).sector_no;
-    goto return_value8;
-  case 0x04: // cylinder low 0x1f4  
-    // -- WARNING : On real hardware the controller registers are shared between drives. 
-    // So we must respond even if the select device is not present. Some OS uses this fact 
-    // to detect the disks.... minix2 for example
-    value8 = (!ANY_IS_PRESENT(channel)) ? 0 : (SELECTED_CONTROLLER(channel).cylinder_no & 0x00ff);
-    goto return_value8;
-  case 0x05: // cylinder high 0x1f5
-    // -- WARNING : On real hardware the controller registers are shared between drives. 
-    // So we must respond even if the select device is not present. Some OS uses this fact 
-    // to detect the disks.... minix2 for example
-    value8 = (!ANY_IS_PRESENT(channel)) ? 0 : SELECTED_CONTROLLER(channel).cylinder_no >> 8;
-    goto return_value8;
+  }
+
+  return -1;
+}
+
+
+
+
+static int write_data_port(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
+
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+  
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
+
+  PrintDebug("[write_data_handler] IO write at 0x%x, current_cmd = 0x%02x\n", 
+            port, controller->current_command);
+  
+  switch (controller->current_command) {
+  case 0x30: // WRITE SECTORS
+    PrintError("\t\tneed to implement 0x30(write sector) to port 0x%x\n", port);
+    return -1;
     
-  case 0x06: // hard disk drive and head register 0x1f6
-    // b7 Extended data field for ECC
-    // b6/b5: Used to be sector size.  00=256,01=512,10=1024,11=128
-    //   Since 512 was always used, bit 6 was taken to mean LBA mode:
-    //     b6 1=LBA mode, 0=CHS mode
-    //     b5 1
-    // b4: DRV
-    // b3..0 HD3..HD0
-    value8 = (1 << 7) |
-      ((SELECTED_CONTROLLER(channel).lba_mode>0) << 6) |
-      (1 << 5) | // 01b = 512 sector size
-      (channels[channel].drive_select << 4) |
-      (SELECTED_CONTROLLER(channel).head_no << 0);
-    goto return_value8;
-    break;
-    //CONTROLLER(channel,0).lba_mode
+  case 0xa0: // PACKET
     
-  case 0x07: // Hard Disk Status 0x1f7
-  case 0x16: // Hard Disk Alternate Status 0x3f6
-    if (!ANY_IS_PRESENT(channel)) {
-      // (mch) Just return zero for these registers
-      value8 = 0;
-    } else {
-      value8 = (
-               (SELECTED_CONTROLLER(channel).status.busy << 7) |
-               (SELECTED_CONTROLLER(channel).status.drive_ready << 6) |
-               (SELECTED_CONTROLLER(channel).status.write_fault << 5) |
-               (SELECTED_CONTROLLER(channel).status.seek_complete << 4) |
-               (SELECTED_CONTROLLER(channel).status.drq << 3) |
-               (SELECTED_CONTROLLER(channel).status.corrected_data << 2) |
-               (SELECTED_CONTROLLER(channel).status.index_pulse << 1) |
-               (SELECTED_CONTROLLER(channel).status.err) );
-      SELECTED_CONTROLLER(channel).status.index_pulse_count++;
-      SELECTED_CONTROLLER(channel).status.index_pulse = 0;
-      if (SELECTED_CONTROLLER(channel).status.index_pulse_count >= INDEX_PULSE_CYCLE) {
-        SELECTED_CONTROLLER(channel).status.index_pulse = 1;
-        SELECTED_CONTROLLER(channel).status.index_pulse_count = 0;
-      }
+    if (handle_atapi_packet_command(dev, channel, *(ushort_t *)src) == -1) {
+      return -1;
     }
-    if (port == 0x07) {
-      rd_lower_irq((struct vm_device *)(ramdisk_state->private_data), channels[channel].irq);
-    }
-    goto return_value8;
-    break;
-    
-  case 0x17: // Hard Disk Address Register 0x3f7
-    // Obsolete and unsupported register.  Not driven by hard
-    // disk controller.  Report all 1's.  If floppy controller
-    // is handling this address, it will call this function
-    // set/clear D7 (the only bit it handles), then return
-    // the combined value
-    value8 = 0xff;
-    goto return_value8;
-    break;
+
+    return length;
     
   default:
-    RD_PANIC("hard drive: io read to address %x unsupported\n",
-             (unsigned) address);
-    
-    
-    ////////////////////////////////////////////
+    PrintError("\t\tIO write(0x%x): current command is %02xh\n", 
+              port, controller->current_command);
+
+    return -1;
+  }
+}
+
+
+
+
+
+
+
+static int read_status_port(ushort_t port, void * dst, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
+
+
+  if (length != 1) {
+    PrintError("Invalid Status port read length: %d (port=%d)\n", length, port);
+    return -1;
+  }
+
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
   }
   
-  Ramdisk_Print("\t\tError: hard drive: shouldnt get here!\n");
-  return 0;
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
+
+  PrintDebug("[read_status_handler] IO read at 0x%x, on drive %d/%d\n", 
+            port, get_channel_no(ramdisk, channel), 
+            channel->drive_select);
+
+
+  if (num_drives_on_channel(channel) == 0) {
+    // (mch) Just return zero for these registers
+    memset(dst, 0, length);
+
+  } else {
+    uchar_t val = (
+                  (controller->status.busy << 7)            |
+                  (controller->status.drive_ready << 6)     |
+                  (controller->status.write_fault << 5)     |
+                  (controller->status.seek_complete << 4)   |
+                  (controller->status.drq << 3)             |
+                  (controller->status.corrected_data << 2)  |
+                  (controller->status.index_pulse << 1)     |
+                  (controller->status.err) );
+   
+    memcpy(dst, &val, length);
+
+    controller->status.index_pulse_count++;
+    controller->status.index_pulse = 0;
+    
+    if (controller->status.index_pulse_count >= INDEX_PULSE_CYCLE) {
+      controller->status.index_pulse = 1;
+      controller->status.index_pulse_count = 0;
+    }
+  }
   
-return_value32:
-  Ramdisk_Print("\t\t32-bit read from %04x = %08x {%s}\n",
-           (unsigned) address, value32, SELECTED_TYPE_STRING(channel));
-  return value32;
+  if ((port == SEC_CMD_PORT) || (port == PRI_CMD_PORT)) {
+    rd_lower_irq(dev, channel->irq);
+  }
   
- return_value16:
-  Ramdisk_Print("\t\t16-bit read from %04x = %04x {%s}\n",
-           (unsigned) address, value16, SELECTED_TYPE_STRING(channel));
-  return value16;
+  return length;
   
- return_value8:
-  Ramdisk_Print("\t\t8-bit read from %x = %02x {%s}\n",
-           (unsigned) address, value8, SELECTED_TYPE_STRING(channel));
-  return value8;
 }
 
 
-static
-void rd_write_handler(struct channel_t *channels, Bit32u address, 
-                     Bit32u value, unsigned io_len)
-{
+static int write_cmd_port(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
+  uchar_t value = *(uchar_t *)src;
+
+  if (length != 1) {
+    PrintError("Invalid Command port write length: %d (port=%d)\n", length, port);
+    return -1;
+  }
 
-  //  off_t logical_sector;
-  //  off_t ret;
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+  
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
+
+
+  PrintDebug("[write_command_handler] IO write at 0x%x, on drive %d/%d (val = 0x%x)\n", 
+            port, get_channel_no(ramdisk, channel), 
+            channel->drive_select, 
+            value);
+
+  switch (value) {
+    // ATAPI commands
+  case 0xa1: // IDENTIFY PACKET DEVICE
+    {
+      if (drive->device_type == IDE_CDROM) {
+       controller->current_command = value;
+       controller->error_register = 0;
+       
+       controller->status.busy = 0;
+       controller->status.drive_ready = 1;
+       controller->status.write_fault = 0;
+       controller->status.drq   = 1;
+       controller->status.err   = 0;
+       
+       controller->status.seek_complete = 1;
+       controller->status.corrected_data = 0;
+       
+       controller->buffer_index = 0;
+       rd_raise_interrupt(dev, channel);
+       rd_identify_ATAPI_drive(dev, channel);
+      } else {
+       rd_command_aborted(dev, channel, 0xa1);
+      }
+      break;
+    }
+  case 0xa0: // SEND PACKET (atapi)
+    {
+      if (drive->device_type == IDE_CDROM) {
+       // PACKET
+       
+       if (controller->features & (1 << 0)) {
+         PrintError("\t\tPACKET-DMA not supported");
+         return -1;
+       }
+       
+       if (controller->features & (1 << 1)) {
+         PrintError("\t\tPACKET-overlapped not supported");
+         return -1;
+       }
+       
+       // We're already ready!
+       controller->sector_count = 1;
+       controller->status.busy = 0;
+       controller->status.write_fault = 0;
+
+       // serv bit??
+       controller->status.drq = 1;
+       controller->status.err = 0;
+       
+       // NOTE: no interrupt here
+       controller->current_command = value;
+       controller->buffer_index = 0;
+      } else {
+       rd_command_aborted (dev, channel, 0xa0);
+      }
+      break;
+    }
+  default:
+    PrintError("\t\tneed translate command %2x\n", value);
+    return -1;
+
+  }
+  return length;
+}
+
+
+static int write_ctrl_port(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * master_drive = NULL;
+  struct drive_t * slave_drive = NULL;
+  struct controller_t * controller = NULL;
+  uchar_t value = *(uchar_t *)src;
   rd_bool prev_control_reset;
 
-  Bit32u id;
-  int toc_length;
+  if (length != 1) {
+    PrintError("Invalid Status port read length: %d (port=%d)\n", length, port);
+    return -1;
+  }
+
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+
+  master_drive = &(channel->drives[0]);
+  slave_drive = &(channel->drives[1]);
+
+  controller = &(get_selected_drive(channel)->controller);
+
+
+  PrintDebug("[write_control_handler] IO write at 0x%x, on drive %d/%d (val = 0x%x)\n", 
+            port, get_channel_no(ramdisk, channel), 
+            channel->drive_select, 
+            value);
+
+  // (mch) Even if device 1 was selected, a write to this register
+  // goes to device 0 (if device 1 is absent)
+  
+  prev_control_reset = controller->control.reset;
+
+  master_drive->controller.control.reset         = value & 0x04;
+  slave_drive->controller.control.reset         = value & 0x04;
+
+  // CGS: was: SELECTED_CONTROLLER(channel).control.disable_irq    = value & 0x02;
+  master_drive->controller.control.disable_irq = value & 0x02;
+  slave_drive->controller.control.disable_irq = value & 0x02;
+  
+  PrintDebug("\t\tadpater control reg: reset controller = %d\n",
+               (unsigned) (controller->control.reset) ? 1 : 0);
+  PrintDebug("\t\tadpater control reg: disable_irq(X) = %d\n",
+               (unsigned) (controller->control.disable_irq) ? 1 : 0);
+  
+  if ((!prev_control_reset) && (controller->control.reset)) {
+    uint_t id = 0;
+
+    // transition from 0 to 1 causes all drives to reset
+    PrintDebug("\t\thard drive: RESET\n");
+    
+    // (mch) Set BSY, drive not ready
+    for (id = 0; id < 2; id++) {
+      struct controller_t * ctrl = NULL;
+
+      if (id == 0) {
+       ctrl = &(master_drive->controller);
+      } else if (id == 1) {
+       ctrl = &(slave_drive->controller);
+      }
+
+      ctrl->status.busy           = 1;
+      ctrl->status.drive_ready    = 0;
+      ctrl->reset_in_progress     = 1;
+      
+      ctrl->status.write_fault    = 0;
+      ctrl->status.seek_complete  = 1;
+      ctrl->status.drq            = 0;
+      ctrl->status.corrected_data = 0;
+      ctrl->status.err            = 0;
+      
+      ctrl->error_register = 0x01; // diagnostic code: no error
+      
+      ctrl->current_command = 0x00;
+      ctrl->buffer_index = 0;
+      
+      ctrl->sectors_per_block = 0x80;
+      ctrl->lba_mode          = 0;
+      
+      ctrl->control.disable_irq = 0;
+    }
+
+    rd_lower_irq(dev, channel->irq);
+
+  } else if ((controller->reset_in_progress) &&
+            (!controller->control.reset)) {
+    uint_t id;
+    // Clear BSY and DRDY
+    PrintDebug("\t\tReset complete {%s}\n", device_type_to_str(get_selected_drive(channel)->device_type));
+
+    for (id = 0; id < 2; id++) {
+      struct controller_t * ctrl = NULL;
+      struct drive_t * drv = NULL;
+
+      if (id == 0) {
+       ctrl = &(master_drive->controller);
+       drv = master_drive;
+      } else if (id == 1) {
+       ctrl = &(slave_drive->controller);
+       drv = slave_drive;
+      }
+
+      ctrl->status.busy           = 0;
+      ctrl->status.drive_ready    = 1;
+      ctrl->reset_in_progress     = 0;
+      
+      // Device signature
+      if (drv->device_type == IDE_DISK) {
+       PrintDebug("\t\tdrive %d/%d is harddrive\n", get_channel_no(ramdisk, channel), id);
+       ctrl->head_no        = 0;
+       ctrl->sector_count   = 1;
+       ctrl->sector_no      = 1;
+       ctrl->cylinder_no    = 0;
+      } else {
+       ctrl->head_no        = 0;
+       ctrl->sector_count   = 1;
+       ctrl->sector_no      = 1;
+       ctrl->cylinder_no    = 0xeb14;
+      }
+    }
+  }
+
+  PrintDebug("\t\ts[0].controller.control.disable_irq = %02x\n", 
+            master_drive->controller.control.disable_irq);
+  PrintDebug("\t\ts[1].controller.control.disable_irq = %02x\n", 
+            slave_drive->controller.control.disable_irq);
+  return length;
+}
+
+
+static int read_general_port(ushort_t port, void * dst, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
 
-  Bit8u  channel = MAX_ATA_CHANNEL;
-  Bit32u port = 0xff; // undefined
 
-  Ramdisk_Print("[rd_write_handler]\n");
-  //  Bit8u atapi_command;
-  //int alloc_length;
+  if (length != 1) {
+    PrintError("Invalid Status port read length: %d (port=%d)\n", length, port);
+    return -1;
+  }
+
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+  
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
+
+
+  PrintDebug("[read_general_handler] IO read addr at %x, on drive %d/%d, curcmd = %02x\n", 
+            port, get_channel_no(ramdisk, channel), 
+            channel->drive_select, 
+            controller->current_command);
+  
 
-  for (channel=0; channel<MAX_ATA_CHANNEL; channel++) {
-    if ((address & 0xfff8) == channels[channel].ioaddr1) {
-      port = address - channels[channel].ioaddr1;
+  switch (port) {
+  case PRI_FEATURES_PORT:
+  case SEC_FEATURES_PORT: // hard disk error register 0x1f1
+    {    
+      uchar_t val = (drive->device_type == IDE_NONE) ? 0 : controller->error_register;
+      
+      controller->status.err = 0;
+      
+      *(uchar_t *)dst = val;
+      return length;
+      
       break;
     }
-    else if ((address & 0xfff8) == channels[channel].ioaddr2) {
-      port = address - channels[channel].ioaddr2 + 0x10;
+
+  case PRI_SECT_CNT_PORT:
+  case SEC_SECT_CNT_PORT:  // hard disk sector count / interrupt reason 0x1f2
+    {
+      uchar_t val = (drive->device_type == IDE_NONE) ? 0 : controller->sector_count;
+
+      *(uchar_t *)dst = val;
+      return length;
+
       break;
-      }
     }
+  case PRI_SECT_ADDR1_PORT:
+  case SEC_SECT_ADDR1_PORT: // sector number 0x1f3
+    {
+      uchar_t val = (drive->device_type == IDE_NONE) ? 0 : controller->sector_no;
+
+      *(uchar_t *)dst = val;
+      return length;
 
-  if (channel == MAX_ATA_CHANNEL) {
-    if (address != 0x03f6) {
-      RD_PANIC("Panic: write: unable to find ATA channel, ioport=0x%04x\n", address);
-    } else {
-      channel = 0;
-      port = address - 0x03e0;
+      break;
     }
+
+  case PRI_SECT_ADDR2_PORT:
+  case SEC_SECT_ADDR2_PORT:  // cylinder low 0x1f4  
+    {
+      // -- WARNING : On real hardware the controller registers are shared between drives. 
+      // So we must respond even if the select device is not present. Some OS uses this fact 
+      // to detect the disks.... minix2 for example
+      uchar_t val = (num_drives_on_channel(channel) == 0) ? 0 : (controller->cylinder_no & 0x00ff);
+
+      *(uchar_t *)dst = val;
+      return length;
+
+      break;      
   }
 
-  Ramdisk_Print("[W_handler] IO write to %x = %02x, channel = %d\n", (unsigned) address, (unsigned) value, channel);
+  case PRI_SECT_ADDR3_PORT:
+  case SEC_SECT_ADDR3_PORT: // cylinder high 0x1f5
+    {
+      // -- WARNING : On real hardware the controller registers are shared between drives. 
+      // So we must respond even if the select device is not present. Some OS uses this fact 
+      // to detect the disks.... minix2 for example
+      uchar_t val = (num_drives_on_channel(channel) == 0) ? 0 : (controller->cylinder_no >> 8);
 
-  struct cdrom_interface *cdif = SELECTED_DRIVE(channel).cdrom.cd;
+      *(uchar_t *)dst = val;
+      return length;
 
-  switch (port) {
+      break;    
+    }
+  case PRI_DRV_SEL_PORT:
+  case SEC_DRV_SEL_PORT:  // hard disk drive and head register 0x1f6
+    {
+      // b7 Extended data field for ECC
+      // b6/b5: Used to be sector size.  00=256,01=512,10=1024,11=128
+      //   Since 512 was always used, bit 6 was taken to mean LBA mode:
+      //     b6 1=LBA mode, 0=CHS mode
+      //     b5 1
+      // b4: DRV
+      // b3..0 HD3..HD0
+      uchar_t val = ((1 << 7)                          |
+                    ((controller->lba_mode > 0) << 6) |
+                    (1 << 5)                          |            // 01b = 512 sector size
+                    (channel->drive_select << 4)      |
+                    (controller->head_no << 0));
+      
+      *(uchar_t *)dst = val;
+      return length;
+
+      break;
+    }
+ case PRI_ADDR_REG_PORT:
+ case SEC_ADDR_REG_PORT: // Hard Disk Address Register 0x3f7
+   {
+     // Obsolete and unsupported register.  Not driven by hard
+     // disk controller.  Report all 1's.  If floppy controller
+     // is handling this address, it will call this function
+     // set/clear D7 (the only bit it handles), then return
+     // the combined value
+     *(uchar_t *)dst = 0xff;
+     return length;
+    }
+
+  default:
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+}
+
+
+
+
+static int write_general_port(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
+  struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct channel_t * channel = NULL;
+  struct drive_t * drive = NULL;
+  struct controller_t * controller = NULL;
+  uchar_t value = *(uchar_t *)src;
+
+  if (length != 1) {
+    PrintError("Invalid Status port read length: %d (port=%d)\n", length, port);
+    return -1;
+  }
 
-  case 0x00: // 0x1f0
-    Ramdisk_Print("\t\twrite port 170\n");
+  if (is_primary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[0]);
+  } else if (is_secondary_port(ramdisk, port)) {
+    channel = &(ramdisk->channels[1]);
+  } else {
+    PrintError("Invalid Port: %d\n", port);
+    return -1;
+  }
+  
+  drive = get_selected_drive(channel);
+  controller = &(drive->controller);
+
+
+  PrintDebug("[write_general_handler] IO write to port %x (val=0x%02x), channel = %d\n", 
+            port,  value, get_channel_no(ramdisk, channel));
+
+  switch (port) {
 
-    //////////////////////////////////////////////////////////
-    switch (SELECTED_CONTROLLER(channel).current_command) {
-    case 0x30: // WRITE SECTORS
-      RD_PANIC("\t\tneed to implement 0x30(write sector) to port 0x170\n");
+  case PRI_FEATURES_PORT:
+  case SEC_FEATURES_PORT: // hard disk write precompensation 0x1f1
+    {
+      write_features(channel, value);
       break;
+    }
+  case PRI_SECT_CNT_PORT:
+  case SEC_SECT_CNT_PORT: // hard disk sector count 0x1f2
+    {
+      write_sector_count(channel, value);
+      break;
+    }
+  case PRI_SECT_ADDR1_PORT:
+  case SEC_SECT_ADDR1_PORT: // hard disk sector number 0x1f3
+    {
+      write_sector_number(channel, value);
+      break;
+    }
+  case PRI_SECT_ADDR2_PORT:
+  case SEC_SECT_ADDR2_PORT: // hard disk cylinder low 0x1f4
+    {
+      write_cylinder_low(channel, value);
+      break;
+    }
+  case PRI_SECT_ADDR3_PORT:
+  case SEC_SECT_ADDR3_PORT: // hard disk cylinder high 0x1f5
+    {
+      write_cylinder_high(channel, value);
+      break;
+    }
+  case PRI_DRV_SEL_PORT:
+  case SEC_DRV_SEL_PORT: // hard disk drive and head register 0x1f6
+    {
+      // b7 Extended data field for ECC
+      // b6/b5: Used to be sector size.  00=256,01=512,10=1024,11=128
+      //   Since 512 was always used, bit 6 was taken to mean LBA mode:
+      //     b6 1=LBA mode, 0=CHS mode
+      //     b5 1
+      // b4: DRV
+      // b3..0 HD3..HD0
+
+      // 1x1xxxxx
+
+      PrintDebug("\tDrive Select value=%x\n", value);
+
+      if ((value & 0xa0) != 0xa0) { 
+       PrintDebug("\t\tIO write 0x%x (%02x): not 1x1xxxxxb\n", port, (unsigned) value);
+      }
       
-    case 0xa0: // PACKET
-      if (SELECTED_CONTROLLER(channel).buffer_index >= PACKET_SIZE)
-       RD_PANIC("IO write(0x%04x): buffer_index >= PACKET_SIZE", address);
-      SELECTED_CONTROLLER(channel).buffer[SELECTED_CONTROLLER(channel).buffer_index] = value;
-      SELECTED_CONTROLLER(channel).buffer[SELECTED_CONTROLLER(channel).buffer_index+1] = (value >> 8);
-      SELECTED_CONTROLLER(channel).buffer_index += 2;
+      write_head_no(channel, value & 0xf);
+      if ((controller->lba_mode == 0) && (((value >> 6) & 1) == 1)) {
+       PrintDebug("\t\tenabling LBA mode\n");
+      }
+
+      write_lba_mode(channel, (value >> 6) & 1);
+      drive->cdrom.cd->lba = (value >> 6) & 1;
+      
+      
+      channel->drive_select = (value >> 4) & 0x01;
+      drive = get_selected_drive(channel);
+
+      if (drive->device_type == IDE_NONE) {
+       PrintDebug("\t\tError: device set to %d which does not exist! channel = 0x%x\n",
+                  channel->drive_select, get_channel_no(ramdisk, channel));
+
+       controller->error_register = 0x04; // aborted
+       controller->status.err = 1;
+      }
       
-      /* if packet completely writtten */
-      if (SELECTED_CONTROLLER(channel).buffer_index >= PACKET_SIZE) {
-       // complete command received
-       Bit8u atapi_command = SELECTED_CONTROLLER(channel).buffer[0];
+      break;
+    }
+  default:
+    PrintError("\t\thard drive: io write to unhandled port 0x%x  (value = %c)\n", port, value);
+    return -1;
+  }
+
+  return length;
+}
+
+
+
+
+static void rd_raise_interrupt(struct vm_device * dev, struct channel_t * channel) {
+  Bit32u irq;
+  //  struct ramdisk_t * ramdisk = (struct ramdisk_t *)(dev->private_data);
+  struct drive_t * drive = get_selected_drive(channel);
+  struct controller_t * controller = &(drive->controller);
+
+  PrintDebug("[raise_interrupt] disable_irq = %02x\n", controller->control.disable_irq);
+
+  if (!(controller->control.disable_irq)) {
+    irq = channel->irq; 
+    PrintDebug("\t\tRaising interrupt %d {%s}\n\n", irq, device_type_to_str(drive->device_type));
+
+    dev->vm->vm_ops.raise_irq(dev->vm, irq);
+  } else {
+    PrintDebug("\t\tirq is disabled\n");
+  }
+  
+  return;
+}
+
+static void rd_lower_irq(struct vm_device *dev, Bit32u irq)  // __attribute__(regparm(1))
+{
+  PrintDebug("[lower_irq] irq = %d\n", irq);
+  dev->vm->vm_ops.lower_irq(dev->vm, irq);
+}
+
+
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////
+
+/*
+ * ATAPI subroutines
+ */
+
+
+
+int handle_atapi_packet_command(struct vm_device * dev, struct channel_t * channel, ushort_t value) {
+  //struct ramdisk_t * ramdisk  = (struct ramdisk_t *)(dev->private_data);
+  struct drive_t * drive = get_selected_drive(channel);
+  struct controller_t * controller = &(drive->controller);
+
+  if (controller->buffer_index >= PACKET_SIZE) {
+    PrintError("ATAPI packet exceeded maximum length: buffer_index (%d) >= PACKET_SIZE\n", 
+              controller->buffer_index);
+    return -1;
+  }
+
+  controller->buffer[controller->buffer_index] = value;
+  controller->buffer[controller->buffer_index + 1] = (value >> 8);
+  controller->buffer_index += 2;
+  
+  
+  /* if packet completely writtten */
+  if (controller->buffer_index >= PACKET_SIZE) {
+    // complete command received
+    Bit8u atapi_command = controller->buffer[0];
+    
+    PrintDebug("\t\tcdrom: ATAPI command 0x%x started\n", atapi_command);
+    
+    switch (atapi_command) {
+    case 0x00: // test unit ready
+      {
+       if (drive->cdrom.ready) {
+         rd_atapi_cmd_nop(dev, channel);
+       } else {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+       }
        
-       Ramdisk_Print("\t\tcdrom: ATAPI command 0x%x started\n", atapi_command);
-
-       switch (atapi_command) {
-       case 0x00: // test unit ready
-         if (SELECTED_DRIVE(channel).cdrom.ready) {
-           rd_atapi_cmd_nop(channels, channel);
-         } else {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-         }
-         rd_raise_interrupt(channels, channel);
-         break;
-         
-       case 0x03: { // request sense
-         int alloc_length = SELECTED_CONTROLLER(channel).buffer[4];
-         rd_init_send_atapi_command(channels, channel, atapi_command, 18, alloc_length, false);
-                                   
-         // sense data
-         SELECTED_CONTROLLER(channel).buffer[0] = 0x70 | (1 << 7);
-         SELECTED_CONTROLLER(channel).buffer[1] = 0;
-         SELECTED_CONTROLLER(channel).buffer[2] = SELECTED_DRIVE(channel).sense.sense_key;
-         SELECTED_CONTROLLER(channel).buffer[3] = SELECTED_DRIVE(channel).sense.information.arr[0];
-         SELECTED_CONTROLLER(channel).buffer[4] = SELECTED_DRIVE(channel).sense.information.arr[1];
-         SELECTED_CONTROLLER(channel).buffer[5] = SELECTED_DRIVE(channel).sense.information.arr[2];
-         SELECTED_CONTROLLER(channel).buffer[6] = SELECTED_DRIVE(channel).sense.information.arr[3];
-         SELECTED_CONTROLLER(channel).buffer[7] = 17-7;
-         SELECTED_CONTROLLER(channel).buffer[8] = SELECTED_DRIVE(channel).sense.specific_inf.arr[0];
-         SELECTED_CONTROLLER(channel).buffer[9] = SELECTED_DRIVE(channel).sense.specific_inf.arr[1];
-         SELECTED_CONTROLLER(channel).buffer[10] = SELECTED_DRIVE(channel).sense.specific_inf.arr[2];
-         SELECTED_CONTROLLER(channel).buffer[11] = SELECTED_DRIVE(channel).sense.specific_inf.arr[3];
-         SELECTED_CONTROLLER(channel).buffer[12] = SELECTED_DRIVE(channel).sense.asc;
-         SELECTED_CONTROLLER(channel).buffer[13] = SELECTED_DRIVE(channel).sense.ascq;
-         SELECTED_CONTROLLER(channel).buffer[14] = SELECTED_DRIVE(channel).sense.fruc;
-         SELECTED_CONTROLLER(channel).buffer[15] = SELECTED_DRIVE(channel).sense.key_spec.arr[0];
-         SELECTED_CONTROLLER(channel).buffer[16] = SELECTED_DRIVE(channel).sense.key_spec.arr[1];
-         SELECTED_CONTROLLER(channel).buffer[17] = SELECTED_DRIVE(channel).sense.key_spec.arr[2];
-         
-         rd_ready_to_send_atapi(channels, channel);
+       rd_raise_interrupt(dev, channel);
+       
+       break;
+      }
+    case 0x03:  // request sense
+      {
+       int alloc_length = controller->buffer[4];
+
+       if (rd_init_send_atapi_command(dev, channel, atapi_command, 18, alloc_length, false) == -1) {
+         return -1;
        }
-         break;
+       
+       // sense data
+       controller->buffer[0] = 0x70 | (1 << 7);
+       controller->buffer[1] = 0;
+       controller->buffer[2] = drive->sense.sense_key;
+       controller->buffer[3] = drive->sense.information.arr[0];
+       controller->buffer[4] = drive->sense.information.arr[1];
+       controller->buffer[5] = drive->sense.information.arr[2];
+       controller->buffer[6] = drive->sense.information.arr[3];
+       controller->buffer[7] = 17 - 7;
+       controller->buffer[8] = drive->sense.specific_inf.arr[0];
+       controller->buffer[9] = drive->sense.specific_inf.arr[1];
+       controller->buffer[10] = drive->sense.specific_inf.arr[2];
+       controller->buffer[11] = drive->sense.specific_inf.arr[3];
+       controller->buffer[12] = drive->sense.asc;
+       controller->buffer[13] = drive->sense.ascq;
+       controller->buffer[14] = drive->sense.fruc;
+       controller->buffer[15] = drive->sense.key_spec.arr[0];
+       controller->buffer[16] = drive->sense.key_spec.arr[1];
+       controller->buffer[17] = drive->sense.key_spec.arr[2];
+       
+       rd_ready_to_send_atapi(dev, channel);
+       break;
+      }
+    case 0x1b:  // start stop unit
+      {
+       //bx_bool Immed = (controller->buffer[1] >> 0) & 1;
+       rd_bool LoEj = (controller->buffer[4] >> 1) & 1;
+       rd_bool Start = (controller->buffer[4] >> 0) & 1;
+
+       // stop the disc
+       if ((!LoEj) && (!Start)) { 
+         PrintError("FIXME: Stop disc not implemented\n");
+
+         rd_atapi_cmd_nop(dev, channel);
+         rd_raise_interrupt(dev, channel);
+       } else if (!LoEj && Start) { // start (spin up) the disc
          
-       case 0x1b: { // start stop unit
-         //bx_bool Immed = (SELECTED_CONTROLLER(channel).buffer[1] >> 0) & 1;
-         rd_bool LoEj = (SELECTED_CONTROLLER(channel).buffer[4] >> 1) & 1;
-         rd_bool Start = (SELECTED_CONTROLLER(channel).buffer[4] >> 0) & 1;
+         drive->cdrom.cd->ops.start_cdrom(drive->cdrom.cd);
          
-         if (!LoEj && !Start) { // stop the disc
-           RD_ERROR("FIXME: Stop disc not implemented\n");
-           rd_atapi_cmd_nop(channels, channel);
-           rd_raise_interrupt(channels, channel);
-         } else if (!LoEj && Start) { // start (spin up) the disc
-
-           SELECTED_DRIVE(channel).cdrom.cd->ops.start_cdrom(cdif);
-
-           RD_ERROR("FIXME: ATAPI start disc not reading TOC\n");
-           rd_atapi_cmd_nop(channels, channel);
-           rd_raise_interrupt(channels, channel);
-         } else if (LoEj && !Start) { // Eject the disc
-           rd_atapi_cmd_nop(channels, channel);
+         PrintError("FIXME: ATAPI start disc not reading TOC\n");
+         rd_atapi_cmd_nop(dev, channel);
+         rd_raise_interrupt(dev, channel);
+       } else if (LoEj && !Start) { // Eject the disc
+         rd_atapi_cmd_nop(dev, channel);
+         
+         if (drive->cdrom.ready) {
            
-           if (SELECTED_DRIVE(channel).cdrom.ready) {
-
-             SELECTED_DRIVE(channel).cdrom.cd->ops.eject_cdrom(cdif);
-
-             SELECTED_DRIVE(channel).cdrom.ready = 0;
-             //bx_options.atadevice[channel][SLAVE_SELECTED(channel)].Ostatus->set(EJECTED);
-             //bx_gui->update_drive_status_buttons();
-           }
-           rd_raise_interrupt(channels, channel);
-         } else { // Load the disc
-           // My guess is that this command only closes the tray, that's a no-op for us
-           rd_atapi_cmd_nop(channels, channel);
-           rd_raise_interrupt(channels, channel);
+           drive->cdrom.cd->ops.eject_cdrom(drive->cdrom.cd);
+           
+           drive->cdrom.ready = 0;
+           //bx_options.atadevice[channel][SLAVE_SELECTED(channel)].Ostatus->set(EJECTED);
+           //bx_gui->update_drive_status_buttons();
          }
+         rd_raise_interrupt(dev, channel);
+       } else { // Load the disc
+         // My guess is that this command only closes the tray, that's a no-op for us
+         rd_atapi_cmd_nop(dev, channel);
+         rd_raise_interrupt(dev, channel);
        }
-         break;
-         
-       case 0xbd: { // mechanism status
-         uint16 alloc_length = rd_read_16bit(SELECTED_CONTROLLER(channel).buffer + 8);
-         
-         if (alloc_length == 0)
-           RD_PANIC("Zero allocation length to MECHANISM STATUS not impl.\n");
-         
-         rd_init_send_atapi_command(channels, channel, atapi_command, 8, alloc_length, false);
-         
-         SELECTED_CONTROLLER(channel).buffer[0] = 0; // reserved for non changers
-         SELECTED_CONTROLLER(channel).buffer[1] = 0; // reserved for non changers
-         
-         SELECTED_CONTROLLER(channel).buffer[2] = 0; // Current LBA (TODO!)
-         SELECTED_CONTROLLER(channel).buffer[3] = 0; // Current LBA (TODO!)
-         SELECTED_CONTROLLER(channel).buffer[4] = 0; // Current LBA (TODO!)
-         
-         SELECTED_CONTROLLER(channel).buffer[5] = 1; // one slot
-         
-         SELECTED_CONTROLLER(channel).buffer[6] = 0; // slot table length
-         SELECTED_CONTROLLER(channel).buffer[7] = 0; // slot table length
-         
-         rd_ready_to_send_atapi(channels, channel);
+       break;
+      }
+    case 0xbd: // mechanism status
+      {
+       uint16_t alloc_length = rd_read_16bit(controller->buffer + 8);
+       
+       if (alloc_length == 0) {
+         PrintError("Zero allocation length to MECHANISM STATUS not impl.\n");
+         return -1;
        }
-         break;
-         
-       case 0x5a: { // mode sense
-         uint16 alloc_length = rd_read_16bit(SELECTED_CONTROLLER(channel).buffer + 7);
-         
-         Bit8u PC = SELECTED_CONTROLLER(channel).buffer[2] >> 6;
-         Bit8u PageCode = SELECTED_CONTROLLER(channel).buffer[2] & 0x3f;
-         
-         switch (PC) {
-         case 0x0: // current values
+       
+       if (rd_init_send_atapi_command(dev, channel, atapi_command, 8, alloc_length, false) == -1) {
+         return -1;
+       }
+       
+       controller->buffer[0] = 0; // reserved for non changers
+       controller->buffer[1] = 0; // reserved for non changers
+       
+       controller->buffer[2] = 0; // Current LBA (TODO!)
+       controller->buffer[3] = 0; // Current LBA (TODO!)
+       controller->buffer[4] = 0; // Current LBA (TODO!)
+       
+       controller->buffer[5] = 1; // one slot
+       
+       controller->buffer[6] = 0; // slot table length
+       controller->buffer[7] = 0; // slot table length
+       
+       rd_ready_to_send_atapi(dev, channel);
+       break;
+      }
+    case 0x5a:  // mode sense
+      {
+       uint16_t alloc_length = rd_read_16bit(controller->buffer + 7);
+       
+       Bit8u PC = controller->buffer[2] >> 6;
+       Bit8u PageCode = controller->buffer[2] & 0x3f;
+       
+       switch (PC) {
+       case 0x0: // current values
+         {
            switch (PageCode) {
            case 0x01: // error recovery
-             rd_init_send_atapi_command(channels, channel, atapi_command, sizeof(struct error_recovery_t) + 8, alloc_length, false);
-             
-             rd_init_mode_sense_single(channels, channel, &SELECTED_DRIVE(channel).cdrom.current.error_recovery,
-                                    sizeof(struct error_recovery_t));
-             rd_ready_to_send_atapi(channels, channel);
-             break;
-             
+             {
+               
+               if (rd_init_send_atapi_command(dev, channel, atapi_command, sizeof(struct error_recovery_t) + 8, alloc_length, false) == -1) {
+                 return -1;
+               }
+               
+               rd_init_mode_sense_single(dev, channel, &(drive->cdrom.current.error_recovery),
+                                         sizeof(struct error_recovery_t));
+               rd_ready_to_send_atapi(dev, channel);
+               break;
+             }
            case 0x2a: // CD-ROM capabilities & mech. status
-             rd_init_send_atapi_command(channels, channel, atapi_command, 28, alloc_length, false);
-             rd_init_mode_sense_single(channels, channel, &SELECTED_CONTROLLER(channel).buffer[8], 28);
-             SELECTED_CONTROLLER(channel).buffer[8] = 0x2a;
-             SELECTED_CONTROLLER(channel).buffer[9] = 0x12;
-             SELECTED_CONTROLLER(channel).buffer[10] = 0x00;
-             SELECTED_CONTROLLER(channel).buffer[11] = 0x00;
-             // Multisession, Mode 2 Form 2, Mode 2 Form 1
-             SELECTED_CONTROLLER(channel).buffer[12] = 0x70; 
-             SELECTED_CONTROLLER(channel).buffer[13] = (3 << 5);
-             SELECTED_CONTROLLER(channel).buffer[14] = (unsigned char)
-               (1 |
-                (SELECTED_DRIVE(channel).cdrom.locked ? (1 << 1) : 0) |
-                (1 << 3) |
-                (1 << 5));
-             SELECTED_CONTROLLER(channel).buffer[15] = 0x00;
-             SELECTED_CONTROLLER(channel).buffer[16] = (706 >> 8) & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[17] = 706 & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[18] = 0;
-             SELECTED_CONTROLLER(channel).buffer[19] = 2;
-             SELECTED_CONTROLLER(channel).buffer[20] = (512 >> 8) & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[21] = 512 & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[22] = (706 >> 8) & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[23] = 706 & 0xff;
-             SELECTED_CONTROLLER(channel).buffer[24] = 0;
-             SELECTED_CONTROLLER(channel).buffer[25] = 0;
-             SELECTED_CONTROLLER(channel).buffer[26] = 0;
-             SELECTED_CONTROLLER(channel).buffer[27] = 0;
-             rd_ready_to_send_atapi(channels, channel);
-             break;
-             
+             {
+
+               if (rd_init_send_atapi_command(dev, channel, atapi_command, 28, alloc_length, false) == -1) {
+                 return -1;
+               }
+
+               rd_init_mode_sense_single(dev, channel, &(controller->buffer[8]), 28);
+               
+               controller->buffer[8] = 0x2a;
+               controller->buffer[9] = 0x12;
+               controller->buffer[10] = 0x00;
+               controller->buffer[11] = 0x00;
+               // Multisession, Mode 2 Form 2, Mode 2 Form 1
+               controller->buffer[12] = 0x70; 
+               controller->buffer[13] = (3 << 5);
+               controller->buffer[14] = (unsigned char) (1 |
+                                                         (drive->cdrom.locked ? (1 << 1) : 0) |
+                                                         (1 << 3) |
+                                                         (1 << 5));
+               controller->buffer[15] = 0x00;
+               controller->buffer[16] = (706 >> 8) & 0xff;
+               controller->buffer[17] = 706 & 0xff;
+               controller->buffer[18] = 0;
+               controller->buffer[19] = 2;
+               controller->buffer[20] = (512 >> 8) & 0xff;
+               controller->buffer[21] = 512 & 0xff;
+               controller->buffer[22] = (706 >> 8) & 0xff;
+               controller->buffer[23] = 706 & 0xff;
+               controller->buffer[24] = 0;
+               controller->buffer[25] = 0;
+               controller->buffer[26] = 0;
+               controller->buffer[27] = 0;
+               rd_ready_to_send_atapi(dev, channel);
+               break;
+             }
            case 0x0d: // CD-ROM
            case 0x0e: // CD-ROM audio control
            case 0x3f: // all
-             RD_ERROR("cdrom: MODE SENSE (curr), code=%x not implemented yet\n",
-                       PageCode);
-           rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                           ASC_INV_FIELD_IN_CMD_PACKET);
-           rd_raise_interrupt(channels, channel);
-           break;
-             
-         default:
-           // not implemeted by this device
-           Ramdisk_Print("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
-                    PC, PageCode);
-           rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                           ASC_INV_FIELD_IN_CMD_PACKET);
-           rd_raise_interrupt(channels, channel);
+             {
+               PrintError("Ramdisk: cdrom: MODE SENSE (curr), code=%x not implemented yet\n",
+                        PageCode);
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+           default:
+             {
+               // not implemeted by this device
+               PrintDebug("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
+                             PC, PageCode);
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+           }
            break;
          }
-         break;
-           
-         case 0x1: // changeable values
+       case 0x1: // changeable values
+         {
            switch (PageCode) {
            case 0x01: // error recovery
            case 0x0d: // CD-ROM
            case 0x0e: // CD-ROM audio control
            case 0x2a: // CD-ROM capabilities & mech. status
            case 0x3f: // all
-             RD_ERROR("cdrom: MODE SENSE (chg), code=%x not implemented yet\n",
-                      PageCode);
-           rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                             ASC_INV_FIELD_IN_CMD_PACKET);
-           rd_raise_interrupt(channels, channel);
+             {
+               PrintError("cdrom: MODE SENSE (chg), code=%x not implemented yet\n",
+                          PageCode);
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+           default:
+             {
+               // not implemeted by this device
+               PrintDebug("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
+                          PC, PageCode);
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+           }
            break;
-           
-         default:
-             // not implemeted by this device
-           Ramdisk_Print("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
-                         PC, PageCode);
-         rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                            ASC_INV_FIELD_IN_CMD_PACKET);
-         rd_raise_interrupt(channels, channel);
-         break;
-       }
-         break;
-         
+         }
        case 0x2: // default values
-         switch (PageCode) {
-         case 0x01: // error recovery
-         case 0x0d: // CD-ROM
-         case 0x0e: // CD-ROM audio control
-         case 0x2a: // CD-ROM capabilities & mech. status
-         case 0x3f: // all
-           RD_PANIC("cdrom: MODE SENSE (dflt), code=%x\n",
-                    PageCode);
-           break;
-           
+         {
+           switch (PageCode) {
+           case 0x01: // error recovery
+           case 0x0d: // CD-ROM
+           case 0x0e: // CD-ROM audio control
+           case 0x2a: // CD-ROM capabilities & mech. status
+           case 0x3f: // all
+             PrintError("cdrom: MODE SENSE (dflt), code=%x\n",
+                      PageCode);
+             return -1;
+             
            default:
-             // not implemeted by this device
-             Ramdisk_Print("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
-                     PC, PageCode);
-             rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                                ASC_INV_FIELD_IN_CMD_PACKET);
-             rd_raise_interrupt(channels, channel);
-             break;
+             {
+               // not implemeted by this device
+               PrintDebug("\t\tcdrom: MODE SENSE PC=%x, PageCode=%x, not implemented by device\n",
+                             PC, PageCode);
+               rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                  ASC_INV_FIELD_IN_CMD_PACKET);
+               rd_raise_interrupt(dev, channel);
+               break;
+             }
+           }
+           break;
          }
-         break;
-         
        case 0x3: // saved values not implemented
-         rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_SAVING_PARAMETERS_NOT_SUPPORTED);
-         rd_raise_interrupt(channels, channel);
-         break;
-         
+         {
+           rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_SAVING_PARAMETERS_NOT_SUPPORTED);
+           rd_raise_interrupt(dev, channel);
+           break;
+         }
        default:
-         RD_PANIC("Should not get here!\n");
-         break;
+         {
+           PrintError("Should not get here!\n");
+           return -1;
+           break;
+         }
        }
+       break;
       }
-      break;
-      
-    case 0x12: { // inquiry
-      uint8 alloc_length = SELECTED_CONTROLLER(channel).buffer[4];
-      
-      rd_init_send_atapi_command(channels, channel, atapi_command, 36, alloc_length, false);
-      
-      SELECTED_CONTROLLER(channel).buffer[0] = 0x05; // CD-ROM
-      SELECTED_CONTROLLER(channel).buffer[1] = 0x80; // Removable
-      SELECTED_CONTROLLER(channel).buffer[2] = 0x00; // ISO, ECMA, ANSI version
-      SELECTED_CONTROLLER(channel).buffer[3] = 0x21; // ATAPI-2, as specified
-      SELECTED_CONTROLLER(channel).buffer[4] = 31; // additional length (total 36)
-      SELECTED_CONTROLLER(channel).buffer[5] = 0x00; // reserved
-      SELECTED_CONTROLLER(channel).buffer[6] = 0x00; // reserved
-      SELECTED_CONTROLLER(channel).buffer[7] = 0x00; // reserved
-      
-      // Vendor ID
-      const char* vendor_id = "VTAB    ";
-      int i;
-      for (i = 0; i < 8; i++)
-       SELECTED_CONTROLLER(channel).buffer[8+i] = vendor_id[i];
-      
-      // Product ID
-      const char* product_id = "Turbo CD-ROM    ";
-      for (i = 0; i < 16; i++)
-       SELECTED_CONTROLLER(channel).buffer[16+i] = product_id[i];
-      
-      // Product Revision level
-      const char* rev_level = "1.0 ";
-      for (i = 0; i < 4; i++)
-       SELECTED_CONTROLLER(channel).buffer[32+i] = rev_level[i];
-      
-      rd_ready_to_send_atapi(channels, channel);
-    }
-      break;
-      
-       case 0x25: { // read cd-rom capacity
-         // no allocation length???
-         rd_init_send_atapi_command(channels, channel, atapi_command, 8, 8, false);
-      
-         if (SELECTED_DRIVE(channel).cdrom.ready) {
-           uint32 capacity = SELECTED_DRIVE(channel).cdrom.capacity;
-           Ramdisk_Print("\t\tCapacity is %d sectors (%d bytes)\n", capacity, capacity * 2048);
-           SELECTED_CONTROLLER(channel).buffer[0] = (capacity >> 24) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[1] = (capacity >> 16) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[2] = (capacity >> 8) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[3] = (capacity >> 0) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[4] = (2048 >> 24) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[5] = (2048 >> 16) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[6] = (2048 >> 8) & 0xff;
-           SELECTED_CONTROLLER(channel).buffer[7] = (2048 >> 0) & 0xff;
-           rd_ready_to_send_atapi(channels, channel);
-         } else {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-           rd_raise_interrupt(channels, channel);
-         }
+    case 0x12: // inquiry
+      { 
+       uint8_t alloc_length = controller->buffer[4];
+       
+       if (rd_init_send_atapi_command(dev, channel, atapi_command, 36, alloc_length, false) == -1) {
+         return -1;
        }
-         break;
-      
-       case 0xbe: { // read cd
-         if (SELECTED_DRIVE(channel).cdrom.ready) {
-           RD_ERROR("Read CD with CD present not implemented\n");
-           rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
-           rd_raise_interrupt(channels, channel);
-         } else {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-           rd_raise_interrupt(channels, channel);
-         }
+       
+       controller->buffer[0] = 0x05; // CD-ROM
+       controller->buffer[1] = 0x80; // Removable
+       controller->buffer[2] = 0x00; // ISO, ECMA, ANSI version
+       controller->buffer[3] = 0x21; // ATAPI-2, as specified
+       controller->buffer[4] = 31; // additional length (total 36)
+       controller->buffer[5] = 0x00; // reserved
+       controller->buffer[6] = 0x00; // reserved
+       controller->buffer[7] = 0x00; // reserved
+       
+       // Vendor ID
+       const char* vendor_id = "VTAB    ";
+       int i;
+       for (i = 0; i < 8; i++) {
+         controller->buffer[8+i] = vendor_id[i];
        }
-         break;
-      
-       case 0x43: { // read toc
-         if (SELECTED_DRIVE(channel).cdrom.ready) {
-           
-           bool msf = (SELECTED_CONTROLLER(channel).buffer[1] >> 1) & 1;
-           uint8 starting_track = SELECTED_CONTROLLER(channel).buffer[6];
-           
-           uint16 alloc_length = rd_read_16bit(SELECTED_CONTROLLER(channel).buffer + 7);
-           
-           uint8 format = (SELECTED_CONTROLLER(channel).buffer[9] >> 6);
-           int i;
-           switch (format) {
-           case 0:
-             
-             if (!(SELECTED_DRIVE(channel).cdrom.cd->ops.read_toc(cdif, SELECTED_CONTROLLER(channel).buffer,
-                                                              &toc_length, msf, starting_track))) {
-               rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                                  ASC_INV_FIELD_IN_CMD_PACKET);
-               rd_raise_interrupt(channels, channel);
-             } else {
-               rd_init_send_atapi_command(channels, channel, atapi_command, toc_length, alloc_length, false);
-               rd_ready_to_send_atapi(channels, channel);
-             }
-             break;
-             
-           case 1:
-             // multi session stuff. we ignore this and emulate a single session only
-             rd_init_send_atapi_command(channels, channel, atapi_command, 12, alloc_length, false);
-             
-             SELECTED_CONTROLLER(channel).buffer[0] = 0;
-             SELECTED_CONTROLLER(channel).buffer[1] = 0x0a;
-             SELECTED_CONTROLLER(channel).buffer[2] = 1;
-             SELECTED_CONTROLLER(channel).buffer[3] = 1;
-             for (i = 0; i < 8; i++)
-               SELECTED_CONTROLLER(channel).buffer[4+i] = 0;
-             
-             rd_ready_to_send_atapi(channels, channel);
-             break;
-             
-           case 2:
-           default:
-             RD_PANIC("(READ TOC) Format %d not supported\n", format);
-             break;
-           }
-         } else {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-           rd_raise_interrupt(channels, channel);
-         }
+
+       // Product ID
+       const char* product_id = "Turbo CD-ROM    ";
+       for (i = 0; i < 16; i++) {
+         controller->buffer[16+i] = product_id[i];
+       }
+
+       // Product Revision level
+       const char* rev_level = "1.0 "; 
+       for (i = 0; i < 4; i++) {
+         controller->buffer[32 + i] = rev_level[i];
+       }
+
+       rd_ready_to_send_atapi(dev, channel);
+       break;
+      }
+    case 0x25:  // read cd-rom capacity
+      {
+       // no allocation length???
+       if (rd_init_send_atapi_command(dev, channel, atapi_command, 8, 8, false) == -1) {
+         return -1;
        }
-         break;
-      
-       case 0x28: // read (10)
-       case 0xa8: // read (12)
-         { 
        
-           uint32 transfer_length;
-           if (atapi_command == 0x28)
-             transfer_length = rd_read_16bit(SELECTED_CONTROLLER(channel).buffer + 7);
-           else
-             transfer_length = rd_read_32bit(SELECTED_CONTROLLER(channel).buffer + 6);
-           
-           uint32 lba = rd_read_32bit(SELECTED_CONTROLLER(channel).buffer + 2);
+       if (drive->cdrom.ready) {
+         uint32_t capacity = drive->cdrom.capacity;
+
+         PrintDebug("\t\tCapacity is %d sectors (%d bytes)\n", capacity, capacity * 2048);
+
+         controller->buffer[0] = (capacity >> 24) & 0xff;
+         controller->buffer[1] = (capacity >> 16) & 0xff;
+         controller->buffer[2] = (capacity >> 8) & 0xff;
+         controller->buffer[3] = (capacity >> 0) & 0xff;
+         controller->buffer[4] = (2048 >> 24) & 0xff;
+         controller->buffer[5] = (2048 >> 16) & 0xff;
+         controller->buffer[6] = (2048 >> 8) & 0xff;
+         controller->buffer[7] = (2048 >> 0) & 0xff;
+
+         rd_ready_to_send_atapi(dev, channel);
+       } else {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
+       }
+       break;
+      }
+      
+      
+    case 0xbe:  // read cd
+      {
+       if (drive->cdrom.ready) {
+         PrintError("Read CD with CD present not implemented\n");
+         rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
+         rd_raise_interrupt(dev, channel);
+       } else {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
+       }
+       break;
+      }
+    case 0x43: // read toc
+      { 
+       if (drive->cdrom.ready) {
+         int toc_length;  
+         bool msf = (controller->buffer[1] >> 1) & 1;
+         uint8_t starting_track = controller->buffer[6];
+         
+         uint16_t alloc_length = rd_read_16bit(controller->buffer + 7);
+         
+         uint8_t format = (controller->buffer[9] >> 6);
+         int i;
+         switch (format) {
+         case 0:
            
-           if (!SELECTED_DRIVE(channel).cdrom.ready) {
-             rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-             rd_raise_interrupt(channels, channel);
-             break;
+           if (!(drive->cdrom.cd->ops.read_toc(drive->cdrom.cd, controller->buffer,
+                                               &toc_length, msf, starting_track))) {
+             rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                                ASC_INV_FIELD_IN_CMD_PACKET);
+             rd_raise_interrupt(dev, channel);
+           } else {
+             if (rd_init_send_atapi_command(dev, channel, atapi_command, toc_length, alloc_length, false) == -1) {
+               return -1;
+             }
+             rd_ready_to_send_atapi(dev, channel);
            }
+           break;
            
-           if (transfer_length == 0) {
-             rd_atapi_cmd_nop(channels, channel);
-             rd_raise_interrupt(channels, channel);
-             Ramdisk_Print("\t\tREAD(%d) with transfer length 0, ok\n", atapi_command==0x28?10:12);
-             break;
+         case 1:
+           // multi session stuff. we ignore this and emulate a single session only
+           if (rd_init_send_atapi_command(dev, channel, atapi_command, 12, alloc_length, false) == -1) {
+             return -1;
            }
            
-           if (lba + transfer_length > SELECTED_DRIVE(channel).cdrom.capacity) {
-             rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
-             rd_raise_interrupt(channels, channel);
-             break;
+           controller->buffer[0] = 0;
+           controller->buffer[1] = 0x0a;
+           controller->buffer[2] = 1;
+           controller->buffer[3] = 1;
+
+           for (i = 0; i < 8; i++) {
+             controller->buffer[4 + i] = 0;
            }
-           
-           Ramdisk_Print("\t\tcdrom: READ (%d) LBA=%d LEN=%d\n", atapi_command==0x28?10:12, lba, transfer_length);
-           
-           // handle command
-           rd_init_send_atapi_command(channels, channel, atapi_command, transfer_length * 2048,
-                                      transfer_length * 2048, true);
-           SELECTED_DRIVE(channel).cdrom.remaining_blocks = transfer_length;
-           SELECTED_DRIVE(channel).cdrom.next_lba = lba;
-           rd_ready_to_send_atapi(channels, channel);
-         }
-         break;
-         
-       case 0x2b: { // seek
-         uint32 lba = rd_read_32bit(SELECTED_CONTROLLER(channel).buffer + 2);
-         if (!SELECTED_DRIVE(channel).cdrom.ready) {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-           rd_raise_interrupt(channels, channel);
-           break;
-         }
-         
-         if (lba > SELECTED_DRIVE(channel).cdrom.capacity) {
-           rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
-           rd_raise_interrupt(channels, channel);
+
+           rd_ready_to_send_atapi(dev, channel);
            break;
+           
+         case 2:
+         default:
+           PrintError("(READ TOC) Format %d not supported\n", format);
+           return -1;
          }
-         Ramdisk_Print("\t\tcdrom: SEEK (ignored)\n");
-         rd_atapi_cmd_nop(channels, channel);
-         rd_raise_interrupt(channels, channel);
+       } else {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
+       }
+       break;
+      }  
+    case 0x28: // read (10)
+    case 0xa8: // read (12)
+      { 
+       
+       uint32_t transfer_length;
+       if (atapi_command == 0x28) {
+         transfer_length = rd_read_16bit(controller->buffer + 7);
+       } else {
+         transfer_length = rd_read_32bit(controller->buffer + 6);
        }
+
+       uint32_t lba = rd_read_32bit(controller->buffer + 2);
+       
+       if (!(drive->cdrom.ready)) {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
          break;
-      
-       case 0x1e: { // prevent/allow medium removal
-         if (SELECTED_DRIVE(channel).cdrom.ready) {
-           SELECTED_DRIVE(channel).cdrom.locked = SELECTED_CONTROLLER(channel).buffer[4] & 1;
-           rd_atapi_cmd_nop(channels, channel);
-         } else {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-         }
-         rd_raise_interrupt(channels, channel);
        }
+       
+       if (transfer_length == 0) {
+         rd_atapi_cmd_nop(dev, channel);
+         rd_raise_interrupt(dev, channel);
+         PrintDebug("\t\tREAD(%d) with transfer length 0, ok\n", (atapi_command == 0x28) ? 10 : 12);
          break;
-      
-       case 0x42: { // read sub-channel
-         bool msf = get_packet_field(channel,1, 1, 1);
-         bool sub_q = get_packet_field(channel,2, 6, 1);
-         uint8 data_format = get_packet_byte(channel,3);
-         uint8 track_number = get_packet_byte(channel,6);
-         uint16 alloc_length = get_packet_word(channel,7);
-         UNUSED(msf);
-         UNUSED(data_format);
-         UNUSED(track_number);
-         
-         if (!SELECTED_DRIVE(channel).cdrom.ready) {
-           rd_atapi_cmd_error(channels, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
-           rd_raise_interrupt(channels, channel);
-         } else {
-           SELECTED_CONTROLLER(channel).buffer[0] = 0;
-           SELECTED_CONTROLLER(channel).buffer[1] = 0; // audio not supported
-           SELECTED_CONTROLLER(channel).buffer[2] = 0;
-           SELECTED_CONTROLLER(channel).buffer[3] = 0;
+       }
        
-           int ret_len = 4; // header size
+       if (lba + transfer_length > drive->cdrom.capacity) {
+         rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
+         rd_raise_interrupt(dev, channel);
+         break;
+       }
        
-           if (sub_q) { // !sub_q == header only
-             RD_ERROR("Read sub-channel with SubQ not implemented\n");
-             rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST,
-                                ASC_INV_FIELD_IN_CMD_PACKET);
-             rd_raise_interrupt(channels, channel);
-           }
+       PrintDebug("\t\tcdrom: READ (%d) LBA=%d LEN=%d\n", 
+                  (atapi_command == 0x28) ? 10 : 12, 
+                  lba, transfer_length);
        
-           rd_init_send_atapi_command(channels, channel, atapi_command, ret_len, alloc_length, false);
-           rd_ready_to_send_atapi(channels, channel);
-         }
+       // handle command
+       if (rd_init_send_atapi_command(dev, channel, atapi_command, transfer_length * 2048,
+                                      transfer_length * 2048, true) == -1) {
+         return -1;
        }
+       drive->cdrom.remaining_blocks = transfer_length;
+       drive->cdrom.next_lba = lba;
+       rd_ready_to_send_atapi(dev, channel);
+       break;
+      }
+    case 0x2b:  // seek
+      {
+       uint32_t lba = rd_read_32bit(controller->buffer + 2);
+
+       if (!(drive->cdrom.ready)) {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
          break;
-      
-       case 0x51: { // read disc info
-         // no-op to keep the Linux CD-ROM driver happy
-         rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
-         rd_raise_interrupt(channels, channel);
        }
-         break;
-      
-       case 0x55: // mode select
-       case 0xa6: // load/unload cd
-       case 0x4b: // pause/resume
-       case 0x45: // play audio
-       case 0x47: // play audio msf
-       case 0xbc: // play cd
-       case 0xb9: // read cd msf
-       case 0x44: // read header
-       case 0xba: // scan
-       case 0xbb: // set cd speed
-       case 0x4e: // stop play/scan
-       case 0x46: // ???
-       case 0x4a: // ???
-         RD_ERROR("ATAPI command 0x%x not implemented yet\n",
-                  atapi_command);
-         rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
-         rd_raise_interrupt(channels, channel);
-         break;
-       default:
-         RD_PANIC("Unknown ATAPI command 0x%x (%d)\n",
-                  atapi_command, atapi_command);
-         // We'd better signal the error if the user chose to continue
-         rd_atapi_cmd_error(channels, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
-         rd_raise_interrupt(channels, channel);
+       
+       if (lba > drive->cdrom.capacity) {
+         rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_LOGICAL_BLOCK_OOR);
+         rd_raise_interrupt(dev, channel);
          break;
        }
-      }
-      
-      break;
-      
-      
-    default:
-      RD_PANIC("\t\tIO write(0x%x): current command is %02xh\n", address,
-              (unsigned) SELECTED_CONTROLLER(channel).current_command);
-    }
+       
+       PrintDebug("\t\tcdrom: SEEK (ignored)\n");
 
-/////////////////////////////////////////////////////////
-    break;
-  case 0x01: // hard disk write precompensation 0x1f1
-    WRITE_FEATURES(channel,value);
-    break;
+       rd_atapi_cmd_nop(dev, channel);
+       rd_raise_interrupt(dev, channel);
 
-  case 0x02: // hard disk sector count 0x1f2
-    WRITE_SECTOR_COUNT(channel,value);
-    break;
-    
-  case 0x03: // hard disk sector number 0x1f3
-    WRITE_SECTOR_NUMBER(channel,value);
-    break;
-    
-  case 0x04: // hard disk cylinder low 0x1f4
-    WRITE_CYLINDER_LOW(channel,value);
-    break;
-    
-  case 0x05: // hard disk cylinder high 0x1f5
-    WRITE_CYLINDER_HIGH(channel,value);
-    break;
-    
-  case 0x06: // hard disk drive and head register 0x1f6
-    // b7 Extended data field for ECC
-    // b6/b5: Used to be sector size.  00=256,01=512,10=1024,11=128
-    //   Since 512 was always used, bit 6 was taken to mean LBA mode:
-    //     b6 1=LBA mode, 0=CHS mode
-    //     b5 1
-    // b4: DRV
-    // b3..0 HD3..HD0
-    
-    if ( (value & 0xa0) != 0xa0 ) // 1x1xxxxx
-      Ramdisk_Print("\t\tIO write 0x%x (%02x): not 1x1xxxxxb\n", address, (unsigned) value);
-    
-    Bit32u drvsel = channels[channel].drive_select = (value >> 4) & 0x01;
-    WRITE_HEAD_NO(channel,value & 0xf);
-    if (SELECTED_CONTROLLER(channel).lba_mode == 0 && ((value >> 6) & 1) == 1){
-      Ramdisk_Print("\t\tenabling LBA mode\n");
+       break;
+      }
+    case 0x1e:  // prevent/allow medium removal
+      {
+
+       if (drive->cdrom.ready) {
+         drive->cdrom.locked = controller->buffer[4] & 1;
+         rd_atapi_cmd_nop(dev, channel);
+       } else {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
        }
-    WRITE_LBA_MODE(channel,(value >> 6) & 1);
-    SELECTED_DRIVE(channel).cdrom.cd->lba = (value >> 6) & 1;
-    
-    
-    if (!SELECTED_IS_PRESENT(channel)) {
-      Ramdisk_Print ("\t\tError: device set to %d which does not exist! channel = %d\n",drvsel, channel);
-      SELECTED_CONTROLLER(channel).error_register = 0x04; // aborted
-      SELECTED_CONTROLLER(channel).status.err = 1;
-    }
-    
-    break;
-    
-    
-  case 0x07: // hard disk command 0x1f7
-
-      switch (value) {
-        // ATAPI commands
-        case 0xa1: // IDENTIFY PACKET DEVICE
-             if (SELECTED_IS_CD(channel)) {
-                   SELECTED_CONTROLLER(channel).current_command = value;
-                   SELECTED_CONTROLLER(channel).error_register = 0;
-
-                   SELECTED_CONTROLLER(channel).status.busy = 0;
-                   SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-                   SELECTED_CONTROLLER(channel).status.write_fault = 0;
-                   SELECTED_CONTROLLER(channel).status.drq   = 1;
-                   SELECTED_CONTROLLER(channel).status.err   = 0;
-
-                   SELECTED_CONTROLLER(channel).status.seek_complete = 1;
-                   SELECTED_CONTROLLER(channel).status.corrected_data = 0;
-
-                   SELECTED_CONTROLLER(channel).buffer_index = 0;
-                   rd_raise_interrupt(channels, channel);
-                   rd_identify_ATAPI_drive(channels, channel);
-             } else {
-               rd_command_aborted(channels, channel, 0xa1);
-             }
-             break;
-
-        case 0xa0: // SEND PACKET (atapi)
-             if (SELECTED_IS_CD(channel)) {
-                   // PACKET
-                   if (SELECTED_CONTROLLER(channel).features & (1 << 0))
-                         RD_PANIC("\t\tPACKET-DMA not supported");
-                   if (SELECTED_CONTROLLER(channel).features & (1 << 1))
-                         RD_PANIC("\t\tPACKET-overlapped not supported");
-
-                   // We're already ready!
-                   SELECTED_CONTROLLER(channel).sector_count = 1;
-                   SELECTED_CONTROLLER(channel).status.busy = 0;
-                   SELECTED_CONTROLLER(channel).status.write_fault = 0;
-                   // serv bit??
-                   SELECTED_CONTROLLER(channel).status.drq = 1;
-                   SELECTED_CONTROLLER(channel).status.err = 0;
-
-                   // NOTE: no interrupt here
-                   SELECTED_CONTROLLER(channel).current_command = value;
-                   SELECTED_CONTROLLER(channel).buffer_index = 0;
-             } else {
-               rd_command_aborted (channels, channel, 0xa0);
-             }
-             break;
 
-      default:
-       Ramdisk_Print("\t\tneed translate command %2x\n", value);
-       break;
-      }//switch(value)
+       rd_raise_interrupt(dev, channel);
 
-    
-  case 0x16: // hard disk adapter control 0x3f6 
-    // (mch) Even if device 1 was selected, a write to this register
-    // goes to device 0 (if device 1 is absent)
-
-    prev_control_reset = SELECTED_CONTROLLER(channel).control.reset;
-    channels[channel].drives[0].controller.control.reset         = value & 0x04;
-    channels[channel].drives[1].controller.control.reset         = value & 0x04;
-    // CGS: was: SELECTED_CONTROLLER(channel).control.disable_irq    = value & 0x02;
-    channels[channel].drives[0].controller.control.disable_irq = value & 0x02;
-    channels[channel].drives[1].controller.control.disable_irq = value & 0x02;
-    
-    Ramdisk_Print("\t\tadpater control reg: reset controller = %d\n",
-                 (unsigned) (SELECTED_CONTROLLER(channel).control.reset) ? 1 : 0);
-    Ramdisk_Print("\t\tadpater control reg: disable_irq(X) = %d\n",
-                 (unsigned) (SELECTED_CONTROLLER(channel).control.disable_irq) ? 1 : 0);
-    
-    if (!prev_control_reset && SELECTED_CONTROLLER(channel).control.reset) {
-      // transition from 0 to 1 causes all drives to reset
-      Ramdisk_Print("\t\thard drive: RESET\n");
-      
-      // (mch) Set BSY, drive not ready
-      for (id = 0; id < 2; id++) {
-       CONTROLLER(channel,id).status.busy           = 1;
-       CONTROLLER(channel,id).status.drive_ready    = 0;
-       CONTROLLER(channel,id).reset_in_progress     = 1;
-       
-       CONTROLLER(channel,id).status.write_fault    = 0;
-       CONTROLLER(channel,id).status.seek_complete  = 1;
-       CONTROLLER(channel,id).status.drq            = 0;
-       CONTROLLER(channel,id).status.corrected_data = 0;
-       CONTROLLER(channel,id).status.err            = 0;
-       
-       CONTROLLER(channel,id).error_register = 0x01; // diagnostic code: no error
-       
-       CONTROLLER(channel,id).current_command = 0x00;
-       CONTROLLER(channel,id).buffer_index = 0;
-       
-       CONTROLLER(channel,id).sectors_per_block = 0x80;
-       CONTROLLER(channel,id).lba_mode          = 0;
-       
-       CONTROLLER(channel,id).control.disable_irq = 0;
-       rd_lower_irq((struct vm_device *)(ramdisk_state->private_data), channels[channel].irq);
+       break;
       }
-    } else if (SELECTED_CONTROLLER(channel).reset_in_progress &&
-              !SELECTED_CONTROLLER(channel).control.reset) {
-      // Clear BSY and DRDY
-      Ramdisk_Print("\t\tReset complete {%s}\n", SELECTED_TYPE_STRING(channel));
-      for (id = 0; id < 2; id++) {
-       CONTROLLER(channel,id).status.busy           = 0;
-       CONTROLLER(channel,id).status.drive_ready    = 1;
-       CONTROLLER(channel,id).reset_in_progress     = 0;
+    case 0x42:  // read sub-channel
+      {
+       //bool msf = get_packet_field(channel,1, 1, 1);
+       bool sub_q = get_packet_field(channel,2, 6, 1);
+       //uint8_t data_format = get_packet_byte(channel,3);
+       //uint8_t track_number = get_packet_byte(channel,6);
+       uint16_t alloc_length = get_packet_word(channel,7);
        
-       // Device signature
-       if (DRIVE_IS_HD(channel,id)) {
-         Ramdisk_Print("\t\tdrive %d/%d is harddrive\n", channel, id);
-         CONTROLLER(channel,id).head_no        = 0;
-         CONTROLLER(channel,id).sector_count   = 1;
-         CONTROLLER(channel,id).sector_no      = 1;
-         CONTROLLER(channel,id).cylinder_no    = 0;
+
+       /*
+         UNUSED(msf);
+         UNUSED(data_format);
+         UNUSED(track_number);
+       */
+       if (!(drive->cdrom.ready)) {
+         rd_atapi_cmd_error(dev, channel, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT);
+         rd_raise_interrupt(dev, channel);
        } else {
-         CONTROLLER(channel,id).head_no        = 0;
-         CONTROLLER(channel,id).sector_count   = 1;
-         CONTROLLER(channel,id).sector_no      = 1;
-         CONTROLLER(channel,id).cylinder_no    = 0xeb14;
+         controller->buffer[0] = 0;
+         controller->buffer[1] = 0; // audio not supported
+         controller->buffer[2] = 0;
+         controller->buffer[3] = 0;
+         
+         int ret_len = 4; // header size
+         
+         if (sub_q) { // !sub_q == header only
+           PrintError("Read sub-channel with SubQ not implemented\n");
+           rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST,
+                              ASC_INV_FIELD_IN_CMD_PACKET);
+           rd_raise_interrupt(dev, channel);
+         }
+         
+         if (rd_init_send_atapi_command(dev, channel, atapi_command, ret_len, alloc_length, false) == -1) {
+           return -1;
+         }
+         rd_ready_to_send_atapi(dev, channel);
        }
+       break;
       }
+    case 0x51:  // read disc info
+      {
+       // no-op to keep the Linux CD-ROM driver happy
+       rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
+       rd_raise_interrupt(dev, channel);
+       break;
+      }
+    case 0x55: // mode select
+    case 0xa6: // load/unload cd
+    case 0x4b: // pause/resume
+    case 0x45: // play audio
+    case 0x47: // play audio msf
+    case 0xbc: // play cd
+    case 0xb9: // read cd msf
+    case 0x44: // read header
+    case 0xba: // scan
+    case 0xbb: // set cd speed
+    case 0x4e: // stop play/scan
+    case 0x46: // ???
+    case 0x4a: // ???
+      PrintError("ATAPI command 0x%x not implemented yet\n",
+              atapi_command);
+      rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
+      rd_raise_interrupt(dev, channel);
+      break;
+    default:
+      PrintError("Unknown ATAPI command 0x%x (%d)\n",
+                atapi_command, atapi_command);
+      // We'd better signal the error if the user chose to continue
+      rd_atapi_cmd_error(dev, channel, SENSE_ILLEGAL_REQUEST, ASC_INV_FIELD_IN_CMD_PACKET);
+      rd_raise_interrupt(dev, channel);
+      break;
     }
-    Ramdisk_Print("\t\ts[0].controller.control.disable_irq = %02x\n", (channels[channel].drives[0]).controller.control.disable_irq);
-    Ramdisk_Print("\t\ts[1].controller.control.disable_irq = %02x\n", (channels[channel].drives[1]).controller.control.disable_irq);
-    break;
+  }
+  return 0;
+}
+
+
+
+
+int rd_init_send_atapi_command(struct vm_device * dev, struct channel_t * channel, Bit8u command, int req_length, int alloc_length, bool lazy)
+{
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
+
+  // controller->byte_count is a union of controller->cylinder_no;
+  // lazy is used to force a data read in the buffer at the next read.
+  
+  PrintDebug("[rd_init_send_atapi_cmd]\n");
+
+  if (controller->byte_count == 0xffff) {
+    controller->byte_count = 0xfffe;
+  }
+
+  if ((controller->byte_count & 1) && 
+      !(alloc_length <= controller->byte_count)) {
+      
+    PrintDebug("\t\tOdd byte count (0x%04x) to ATAPI command 0x%02x, using 0x%x\n", 
+                 controller->byte_count, 
+                 command, 
+                 controller->byte_count - 1);
     
-  default:
-    RD_PANIC("\t\thard drive: io write to address %x = %02x\n",
-                 (unsigned) address, (unsigned) value);
+    controller->byte_count -= 1;
+  }
+  
+  if (controller->byte_count == 0) {
+    PrintError("\t\tATAPI command with zero byte count\n");
+    return -1;
+  }
+
+  if (alloc_length < 0) {
+    PrintError("\t\tAllocation length < 0\n");
+    return -1;
+  }
+
+  if (alloc_length == 0) {
+    alloc_length = controller->byte_count;
+  }
+  
+  controller->interrupt_reason.i_o = 1;
+  controller->interrupt_reason.c_d = 0;
+  controller->status.busy = 0;
+  controller->status.drq = 1;
+  controller->status.err = 0;
+  
+  // no bytes transfered yet
+  if (lazy) {
+    controller->buffer_index = 2048;
+  } else {
+    controller->buffer_index = 0;
+  }
+
+  controller->drq_index = 0;
+  
+  if (controller->byte_count > req_length) {
+    controller->byte_count = req_length;
+  }
+
+  if (controller->byte_count > alloc_length) {
+    controller->byte_count = alloc_length;
   }  
+
+  drive->atapi.command = command;
+  drive->atapi.drq_bytes = controller->byte_count;
+  drive->atapi.total_bytes_remaining = (req_length < alloc_length) ? req_length : alloc_length;
   
-  return;
+  // if (lazy) {
+  // // bias drq_bytes and total_bytes_remaining
+  // SELECTED_DRIVE(channel).atapi.drq_bytes += 2048;
+  // SELECTED_DRIVE(channel).atapi.total_bytes_remaining += 2048;
+  // }
+
+  return 0;
 }
 
 
-static 
-void rd_identify_ATAPI_drive(struct channel_t *channels, Bit8u channel)
+
+ void rd_ready_to_send_atapi(struct vm_device * dev, struct channel_t * channel) {
+  PrintDebug("[rd_ready_to_send_atapi]\n");
+
+  rd_raise_interrupt(dev, channel);
+}
+
+
+
+
+
+void rd_atapi_cmd_error(struct vm_device * dev, struct channel_t * channel, sense_t sense_key, asc_t asc)
 {
-  unsigned i;
+  struct ramdisk_t *ramdisk = (struct ramdisk_t *)(dev->private_data);
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
+
+  PrintDebug("[rd_atapi_cmd_error]\n");
+  PrintDebug("Error: atapi_cmd_error channel=%02x key=%02x asc=%02x\n", 
+            get_channel_no(ramdisk, channel), sense_key, asc);
+
+  controller->error_register = sense_key << 4;
+  controller->interrupt_reason.i_o = 1;
+  controller->interrupt_reason.c_d = 1;
+  controller->interrupt_reason.rel = 0;
+  controller->status.busy = 0;
+  controller->status.drive_ready = 1;
+  controller->status.write_fault = 0;
+  controller->status.drq = 0;
+  controller->status.err = 1;
+  
+  drive->sense.sense_key = sense_key;
+  drive->sense.asc = asc;
+  drive->sense.ascq = 0;
+}
+
+
+
+void rd_atapi_cmd_nop(struct vm_device * dev, struct channel_t * channel)
+{
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
+
+  PrintDebug("[rd_atapi_cmd_nop]\n");
+  controller->interrupt_reason.i_o = 1;
+  controller->interrupt_reason.c_d = 1;
+  controller->interrupt_reason.rel = 0;
+  controller->status.busy = 0;
+  controller->status.drive_ready = 1;
+  controller->status.drq = 0;
+  controller->status.err = 0;
+}
+
+
+
+
+void rd_identify_ATAPI_drive(struct vm_device * dev, struct channel_t * channel)
+{
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
+
+
+  uint_t i;
   const char* serial_number = " VT00001\0\0\0\0\0\0\0\0\0\0\0\0";
   const char* firmware = "ALPHA1  ";
 
-  SELECTED_DRIVE(channel).id_drive[0] = (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0); // Removable CDROM, 50us response, 12 byte packets
-
-  for (i = 1; i <= 9; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
+  drive->id_drive[0] = (2 << 14) | (5 << 8) | (1 << 7) | (2 << 5) | (0 << 0); // Removable CDROM, 50us response, 12 byte packets
 
+  for (i = 1; i <= 9; i++) {
+    drive->id_drive[i] = 0;
+  }
 
   for (i = 0; i < 10; i++) {
-       SELECTED_DRIVE(channel).id_drive[10+i] = (serial_number[i*2] << 8) |
-             serial_number[i*2 + 1];
+    drive->id_drive[10 + i] = ((serial_number[i * 2] << 8) |
+                              (serial_number[(i * 2) + 1]));
   }
 
-  for (i = 20; i <= 22; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
-
+  for (i = 20; i <= 22; i++) {
+    drive->id_drive[i] = 0;
+  }
 
   for (i = 0; i < strlen(firmware)/2; i++) {
-       SELECTED_DRIVE(channel).id_drive[23+i] = (firmware[i*2] << 8) |
-             firmware[i*2 + 1];
+    drive->id_drive[23 + i] = ((firmware[i * 2] << 8) |
+                              (firmware[(i * 2) + 1]));
   }
-  V3_ASSERT((23+i) == 27);
+  V3_ASSERT((23 + i) == 27);
   
-  for (i = 0; i < strlen((char *) SELECTED_MODEL(channel))/2; i++) {
-       SELECTED_DRIVE(channel).id_drive[27+i] = (SELECTED_MODEL(channel)[i*2] << 8) |
-             SELECTED_MODEL(channel)[i*2 + 1];
+  for (i = 0; i < strlen((char *)(drive->model_no)) / 2; i++) {
+    drive->id_drive[27 + i] = ((drive->model_no[i * 2] << 8) |
+                              (drive->model_no[(i * 2) + 1]));
   }
-  V3_ASSERT((27+i) == 47);
+  V3_ASSERT((27 + i) == 47);
 
-  SELECTED_DRIVE(channel).id_drive[47] = 0;
-  SELECTED_DRIVE(channel).id_drive[48] = 1; // 32 bits access
+  drive->id_drive[47] = 0;
+  drive->id_drive[48] = 1; // 32 bits access
 
-  SELECTED_DRIVE(channel).id_drive[49] = (1 << 9); // LBA supported
+  drive->id_drive[49] = (1 << 9); // LBA supported
 
-  SELECTED_DRIVE(channel).id_drive[50] = 0;
-  SELECTED_DRIVE(channel).id_drive[51] = 0;
-  SELECTED_DRIVE(channel).id_drive[52] = 0;
+  drive->id_drive[50] = 0;
+  drive->id_drive[51] = 0;
+  drive->id_drive[52] = 0;
 
-  SELECTED_DRIVE(channel).id_drive[53] = 3; // words 64-70, 54-58 valid
+  drive->id_drive[53] = 3; // words 64-70, 54-58 valid
 
-  for (i = 54; i <= 62; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
+  for (i = 54; i <= 62; i++) {
+    drive->id_drive[i] = 0;
+  }
 
   // copied from CFA540A
-  SELECTED_DRIVE(channel).id_drive[63] = 0x0103; // variable (DMA stuff)
-  SELECTED_DRIVE(channel).id_drive[64] = 0x0001; // PIO
-  SELECTED_DRIVE(channel).id_drive[65] = 0x00b4;
-  SELECTED_DRIVE(channel).id_drive[66] = 0x00b4;
-  SELECTED_DRIVE(channel).id_drive[67] = 0x012c;
-  SELECTED_DRIVE(channel).id_drive[68] = 0x00b4;
-
-  SELECTED_DRIVE(channel).id_drive[69] = 0;
-  SELECTED_DRIVE(channel).id_drive[70] = 0;
-  SELECTED_DRIVE(channel).id_drive[71] = 30; // faked
-  SELECTED_DRIVE(channel).id_drive[72] = 30; // faked
-  SELECTED_DRIVE(channel).id_drive[73] = 0;
-  SELECTED_DRIVE(channel).id_drive[74] = 0;
-
-  SELECTED_DRIVE(channel).id_drive[75] = 0;
-
-  for (i = 76; i <= 79; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
-
-  SELECTED_DRIVE(channel).id_drive[80] = 0x1e; // supports up to ATA/ATAPI-4
-  SELECTED_DRIVE(channel).id_drive[81] = 0;
-  SELECTED_DRIVE(channel).id_drive[82] = 0;
-  SELECTED_DRIVE(channel).id_drive[83] = 0;
-  SELECTED_DRIVE(channel).id_drive[84] = 0;
-  SELECTED_DRIVE(channel).id_drive[85] = 0;
-  SELECTED_DRIVE(channel).id_drive[86] = 0;
-  SELECTED_DRIVE(channel).id_drive[87] = 0;
-  SELECTED_DRIVE(channel).id_drive[88] = 0;
-
-  for (i = 89; i <= 126; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
-
-  SELECTED_DRIVE(channel).id_drive[127] = 0;
-  SELECTED_DRIVE(channel).id_drive[128] = 0;
-
-  for (i = 129; i <= 159; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
-
-  for (i = 160; i <= 255; i++)
-       SELECTED_DRIVE(channel).id_drive[i] = 0;
+  drive->id_drive[63] = 0x0103; // variable (DMA stuff)
+  drive->id_drive[64] = 0x0001; // PIO
+  drive->id_drive[65] = 0x00b4;
+  drive->id_drive[66] = 0x00b4;
+  drive->id_drive[67] = 0x012c;
+  drive->id_drive[68] = 0x00b4;
+
+  drive->id_drive[69] = 0;
+  drive->id_drive[70] = 0;
+  drive->id_drive[71] = 30; // faked
+  drive->id_drive[72] = 30; // faked
+  drive->id_drive[73] = 0;
+  drive->id_drive[74] = 0;
+
+  drive->id_drive[75] = 0;
+
+  for (i = 76; i <= 79; i++) {
+    drive->id_drive[i] = 0;
+  }
+
+  drive->id_drive[80] = 0x1e; // supports up to ATA/ATAPI-4
+  drive->id_drive[81] = 0;
+  drive->id_drive[82] = 0;
+  drive->id_drive[83] = 0;
+  drive->id_drive[84] = 0;
+  drive->id_drive[85] = 0;
+  drive->id_drive[86] = 0;
+  drive->id_drive[87] = 0;
+  drive->id_drive[88] = 0;
+
+  for (i = 89; i <= 126; i++) {
+    drive->id_drive[i] = 0;
+  }
+
+  drive->id_drive[127] = 0;
+  drive->id_drive[128] = 0;
+
+  for (i = 129; i <= 159; i++) {
+    drive->id_drive[i] = 0;
+  }
+
+  for (i = 160; i <= 255; i++) {
+    drive->id_drive[i] = 0;
+  }
 
   // now convert the id_drive array (native 256 word format) to
   // the controller buffer (512 bytes)
   Bit16u temp16;
   for (i = 0; i <= 255; i++) {
-       temp16 = SELECTED_DRIVE(channel).id_drive[i];
-       SELECTED_CONTROLLER(channel).buffer[i*2] = temp16 & 0x00ff;
-       SELECTED_CONTROLLER(channel).buffer[i*2+1] = temp16 >> 8;
+    temp16 = drive->id_drive[i];
+    controller->buffer[i * 2] = temp16 & 0x00ff;
+    controller->buffer[i * 2 + 1] = temp16 >> 8;
   }
 
   return;
@@ -1626,208 +2154,422 @@ void rd_identify_ATAPI_drive(struct channel_t *channels, Bit8u channel)
 
 
 
+
+
+
+
 static 
-void rd_raise_interrupt(struct channel_t *channels, Bit8u channel)
+void rd_init_mode_sense_single(struct vm_device * dev, 
+                              struct channel_t * channel, const void* src, int size)
 {
-  Bit32u irq;
-  struct vm_device *dev;
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
 
-  Ramdisk_Print("[raise_interrupt] disable_irq = %02x\n", SELECTED_CONTROLLER(channel).control.disable_irq);
+  PrintDebug("[rd_init_mode_sense_single]\n");
 
-  if (!SELECTED_CONTROLLER(channel).control.disable_irq) { 
-    Ramdisk_Print("\t\traising interrupt\n"); 
-  } else { 
-    Ramdisk_Print("\t\tNot raising interrupt\n"); 
-  }
-  if (!SELECTED_CONTROLLER(channel).control.disable_irq) {
-    irq = channels[channel].irq; 
-    Ramdisk_Print("\t\tRaising interrupt %d {%s}\n\n", irq, SELECTED_TYPE_STRING(channel));
-    //        DEV_pic_raise_irq(irq);
-    dev = (struct vm_device*) ramdisk_state->private_data;
-    Ramdisk_Print("\t\tdev = %x\n", dev);
-    dev->vm->vm_ops.raise_irq(dev->vm, irq);
-  } else {
-    Ramdisk_Print("\t\tirq is disabled\n");
-  }
+  // Header
+  controller->buffer[0] = (size + 6) >> 8;
+  controller->buffer[1] = (size + 6) & 0xff;
+  controller->buffer[2] = 0x70; // no media present
+  controller->buffer[3] = 0; // reserved
+  controller->buffer[4] = 0; // reserved
+  controller->buffer[5] = 0; // reserved
+  controller->buffer[6] = 0; // reserved
+  controller->buffer[7] = 0; // reserved
   
-  return;
+  // Data
+  memcpy(controller->buffer + 8, src, size);
 }
 
-static
-void rd_lower_irq(struct vm_device *dev, Bit32u irq)// __attribute__(regparm(1))
-{
-  Ramdisk_Print("[lower_irq] irq = %d\n", irq);
-  dev->vm->vm_ops.lower_irq(dev->vm, irq);
+
+
+static void rd_command_aborted(struct vm_device * dev, 
+                              struct channel_t * channel, unsigned value) {
+  struct drive_t * drive = &(channel->drives[channel->drive_select]);
+  struct controller_t * controller = &(drive->controller);
+
+  PrintDebug("[rd_command_aborted]\n");
+  PrintDebug("\t\taborting on command 0x%02x {%s}\n", value, device_type_to_str(drive->device_type));
+
+  controller->current_command = 0;
+  controller->status.busy = 0;
+  controller->status.drive_ready = 1;
+  controller->status.err = 1;
+  controller->error_register = 0x04; // command ABORTED
+  controller->status.drq = 0;
+  controller->status.seek_complete = 0;
+  controller->status.corrected_data = 0;
+  controller->buffer_index = 0;
+
+  rd_raise_interrupt(dev, channel);
 }
 
 
-/*
- * Public Routines
- */
-static
-uint_t ramdisk_read_port(ushort_t port,
-                        void *src,
-                        uint_t length,
-                        struct vm_device *dev)
-{
-  uint_t i;
-  Ramdisk_Print("[ramdisk_read_port] port = %x, length = %d\n", port, length);
-    switch (length) {
-    case 1:
-      ((uchar_t*)src)[0] = rd_read_handler(ramdisk_state->channels, port, length);
-      break;
-    case 2:
-      ((ushort_t*)src)[0] = rd_read_handler(ramdisk_state->channels, port, length);
-      break;
-    case 4:
-      ((uint_t*)src)[0] = rd_read_handler(ramdisk_state->channels, port, length);
-      break;
-    default:
-      for (i = 0; i < length; i++) { 
-       ((uchar_t*)src)[i] = rd_read_handler(ramdisk_state->channels, port, 1);
-      }
-    }//switch length
+static int ramdisk_init_device(struct vm_device *dev) {
+  struct ramdisk_t *ramdisk= (struct ramdisk_t *)dev->private_data;
+
+  PrintDebug("Initializing Ramdisk\n");
+
+
+  rd_init_hardware(ramdisk);
+
+
+  dev_hook_io(dev, PRI_CTRL_PORT, 
+             &read_status_port, &write_ctrl_port);
+
+  dev_hook_io(dev, PRI_DATA_PORT, 
+             &read_data_port, &write_data_port);
+  dev_hook_io(dev, PRI_FEATURES_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_SECT_CNT_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_SECT_ADDR1_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_SECT_ADDR2_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_SECT_ADDR3_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_DRV_SEL_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, PRI_CMD_PORT, 
+             &read_status_port, &write_cmd_port);
+
+
+  dev_hook_io(dev, SEC_CTRL_PORT, 
+             &read_status_port, &write_ctrl_port);
+
+  dev_hook_io(dev, SEC_DATA_PORT, 
+             &read_data_port, &write_data_port);
+  dev_hook_io(dev, SEC_FEATURES_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_SECT_CNT_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_SECT_ADDR1_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_SECT_ADDR2_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_SECT_ADDR3_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_DRV_SEL_PORT, 
+             &read_general_port, &write_general_port);
+  dev_hook_io(dev, SEC_CMD_PORT, 
+             &read_status_port, &write_cmd_port);
+
+  
+
+  dev_hook_io(dev, SEC_ADDR_REG_PORT, 
+             &read_general_port, &write_general_port);
+
+  dev_hook_io(dev, PRI_ADDR_REG_PORT, 
+             &read_general_port, &write_general_port);
+
+
+
+  return 0;
 
-  return length;
 }
 
 
-static
-uint_t ramdisk_write_port(ushort_t port,
-                        void *src,
-                        uint_t length,
-                        struct vm_device *dev)
+static int ramdisk_deinit_device(struct vm_device *dev) {
+  struct ramdisk_t *ramdisk = (struct ramdisk_t *)(dev->private_data);
+  rd_close_harddrive(ramdisk);
+  return 0;
+}
+
+static struct vm_device_ops dev_ops = {
+  .init = ramdisk_init_device,
+  .deinit = ramdisk_deinit_device,
+  .reset = NULL,
+  .start = NULL,
+  .stop = NULL,
+};
+
+
+
+
+struct vm_device *create_ramdisk()
 {
-  Ramdisk_Print("[ramdisk_write_port] port = %x, length = %d\n", port, length);
-  /*
-  uint_t i;
 
-  for (i = 0; i < length; i++)
-    Ramdisk_Print("\t\tsrc[%d] = 0x%02x\n", i, ((uchar_t*)src)[i]);
-  */
+  struct ramdisk_t *ramdisk;
+  ramdisk = (struct ramdisk_t *)V3_Malloc(sizeof(struct ramdisk_t));  
+  V3_ASSERT(ramdisk != NULL);  
 
-  switch(length) {
-  case 1:
-    rd_write_handler(ramdisk_state->channels, port, *((uchar_t *)src), length);
-    break;
-  case 2:
-    rd_write_handler(ramdisk_state->channels, port, *((ushort_t *)src), length);
-    break;
-  case 4:
-    rd_write_handler(ramdisk_state->channels, port, *((uint_t *)src), length);
-    break;
-  default:
-    rd_write_handler(ramdisk_state->channels, port, *((uchar_t *)src), length);
-    break;
+  PrintDebug("[create_ramdisk]\n");
+
+  struct vm_device *device = create_device("RAMDISK", &dev_ops, ramdisk);
+
+  return device;
+}
+
+
+
+
+#ifdef DEBUG_RAMDISK
+
+static void rd_print_state(struct ramdisk_t * ramdisk) {
+  uchar_t channel; 
+  uchar_t device;
+  struct channel_t * channels = (struct channel_t *)(&(ramdisk->channels));
+
+  /*
+  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++) {
+    memset((char *)(channels + channel), 0, sizeof(struct channel_t));
   }
+  */
+  PrintDebug("sizeof(*channels) = %d\n", sizeof(*channels));
+  PrintDebug("sizeof(channles->drives[0].controller) = %d\n", sizeof((channels->drives[0].controller)));
+  PrintDebug("sizeof(channles->drives[0].cdrom) = %d\n", sizeof((channels->drives[0].cdrom)));
+  PrintDebug("sizeof(channles->drives[0].sense) = %d\n", sizeof((channels->drives[0].sense)));
+  PrintDebug("sizeof(channles->drives[0].atapi) = %d\n", sizeof((channels->drives[0].atapi)));
+
 
-  return 1;
+  PrintDebug("sizeof(channles->drives[0].controller.status) = %d\n", 
+               sizeof((channels->drives[0].controller.status)));
+  PrintDebug("sizeof(channles->drives[0].controller.sector_count) = %d\n", 
+               sizeof((channels->drives[0].controller.sector_count)));
+  PrintDebug("sizeof(channles->drives[0].controller.interrupt_reason) = %d\n", 
+               sizeof((channels->drives[0].controller.interrupt_reason)));
+
+  PrintDebug("sizeof(channles->drives[0].controller.cylinder_no) = %d\n", 
+               sizeof((channels->drives[0].controller.cylinder_no)));
+  PrintDebug("sizeof(channles->drives[0].controller.byte_count) = %d\n", 
+               sizeof((channels->drives[0].controller.byte_count)));
+
+
+  PrintDebug("sizeof(channles->drives[0].controller.control) = %d\n", 
+               sizeof((channels->drives[0].controller.control)));
+
+
+  for (channel = 0; channel < MAX_ATA_CHANNEL; channel++){
+  
+    for (device = 0; device < 2; device++){
+                  
+      // Initialize controller state, even if device is not present
+      PrintDebug("channels[%d].drives[%d].controller.status.busy = %d\n",
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.busy);
+      PrintDebug("channels[%d].drives[%d].controller.status.drive_ready = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.drive_ready);
+      PrintDebug("channels[%d].drives[%d].controller.status.write_fault = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.write_fault);
+      PrintDebug("channels[%d].drives[%d].controller.status.seek_complete = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.seek_complete);
+      PrintDebug("channels[%d].drives[%d].controller.status.drq = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.drq);
+      PrintDebug("channels[%d].drives[%d].controller.status.corrected_data = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.corrected_data);
+      PrintDebug("channels[%d].drives[%d].controller.status.index_pulse = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.index_pulse);
+      PrintDebug("channels[%d].drives[%d].controller.status.index_pulse_count = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.index_pulse_count);
+      PrintDebug("channels[%d].drives[%d].controller.status.err = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.status.err);
+
+
+      PrintDebug("channels[%d].drives[%d].controller.error_register = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.error_register);
+      PrintDebug("channels[%d].drives[%d].controller.head_no = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.head_no);
+      PrintDebug("channels[%d].drives[%d].controller.sector_count = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.sector_count);
+      PrintDebug("channels[%d].drives[%d].controller.sector_no = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.sector_no);
+      PrintDebug("channels[%d].drives[%d].controller.cylinder_no = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.cylinder_no);
+      PrintDebug("channels[%d].drives[%d].controller.current_command = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.current_command);
+      PrintDebug("channels[%d].drives[%d].controller.buffer_index = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.buffer_index);
+
+
+      PrintDebug("channels[%d].drives[%d].controller.control.reset = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.control.reset);
+      PrintDebug("channels[%d].drives[%d].controller.control.disable_irq = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.control.disable_irq);
+
+
+      PrintDebug("channels[%d].drives[%d].controller.reset_in_progress = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.reset_in_progress);
+      PrintDebug("channels[%d].drives[%d].controller.sectors_per_block = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.sectors_per_block); 
+      PrintDebug("channels[%d].drives[%d].controller.lba_mode = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.lba_mode); 
+      PrintDebug("channels[%d].drives[%d].controller.features = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.features); 
+
+
+      PrintDebug("channels[%d].drives[%d].model_no = %s\n", 
+                   channel, device, 
+                   channels[channel].drives[device].model_no); 
+      PrintDebug("channels[%d].drives[%d].device_type = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].device_type); 
+      PrintDebug("channels[%d].drives[%d].cdrom.locked = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].cdrom.locked); 
+      PrintDebug("channels[%d].drives[%d].sense.sense_key = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].sense.sense_key); 
+      PrintDebug("channels[%d].drives[%d].sense.asc = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].sense.asc); 
+      PrintDebug("channels[%d].drives[%d].sense.ascq = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].sense.ascq); 
+
+
+
+      PrintDebug("channels[%d].drives[%d].controller.interrupt_reason.c_d = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.interrupt_reason.c_d);
+
+      PrintDebug("channels[%d].drives[%d].controller.interrupt_reason.i_o = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.interrupt_reason.i_o);
+
+      PrintDebug("channels[%d].drives[%d].controller.interrupt_reason.rel = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.interrupt_reason.rel);
+
+      PrintDebug("channels[%d].drives[%d].controller.interrupt_reason.tag = %02x\n", 
+                   channel, device, 
+                   channels[channel].drives[device].controller.interrupt_reason.tag);
+
+      PrintDebug("channels[%d].drives[%d].cdrom.ready = %d\n", 
+                   channel, device, 
+                   channels[channel].drives[device].cdrom.ready);
+      
+    }  //for device
+  }  //for channel
+  
+  return;
 }
 
+#if 0
+static void trace_info(ushort_t port, void *src, uint_t length) {
 
-static void trace_info(ushort_t port, void *src, uint_t length)
-{
   switch(port){
 
   case 0x3e8:
     if (length == 1 && *((uchar_t*) src) == ATA_DETECT)
-      Ramdisk_Print("ata_dectect()\n");
+      PrintDebug("ata_detect()\n");
     break;
 
   case 0x3e9:
     if (length == 1 && *((uchar_t*) src) == ATA_RESET)
-      Ramdisk_Print("ata_reset()\n");
+      PrintDebug("ata_reset()\n");
     break;
 
   case 0x3ea:
     if (length == 1 && *((uchar_t*) src) == ATA_CMD_DATA_IN)
-      Ramdisk_Print("ata_cmd_data_in()\n");
+      PrintDebug("ata_cmd_data_in()\n");
     break;
 
   case 0x3eb:
     if (length == 1 && *((uchar_t*) src) == ATA_CMD_DATA_OUT)
-      Ramdisk_Print("ata_cmd_data_out()\n");
+      PrintDebug("ata_cmd_data_out()\n");
     break;
 
   case 0x3ec:
     if (length == 1 && *((uchar_t*) src) == ATA_CMD_PACKET)
-      Ramdisk_Print("ata_cmd_packet()\n");
+      PrintDebug("ata_cmd_packet()\n");
     break;
 
   case 0x3ed:
     if (length == 1 && *((uchar_t*) src) == ATAPI_GET_SENSE)
-      Ramdisk_Print("atapi_get_sense()\n");
+      PrintDebug("atapi_get_sense()\n");
     break;
 
   case 0x3ee:
     if (length == 1 && *((uchar_t*) src) == ATAPI_IS_READY)
-      Ramdisk_Print("atapi_is_ready()\n");
+      PrintDebug("atapi_is_ready()\n");
     break;
 
   case 0x3ef:
     if (length == 1 && *((uchar_t*) src) == ATAPI_IS_CDROM)
-      Ramdisk_Print("atapi_is_cdrom()\n");
+      PrintDebug("atapi_is_cdrom()\n");
     break;
 
 
   case 0x2e8:
     if (length == 1 && *((uchar_t*) src) == CDEMU_INIT)
-      Ramdisk_Print("cdemu_init()\n");
+      PrintDebug("cdemu_init()\n");
     break;
 
   case 0x2e9:
     if (length == 1 && *((uchar_t*) src) == CDEMU_ISACTIVE)
-      Ramdisk_Print("cdemu_isactive()\n");
+      PrintDebug("cdemu_isactive()\n");
     break;
 
   case 0x2ea:
     if (length == 1 && *((uchar_t*) src) == CDEMU_EMULATED_DRIVE)
-      Ramdisk_Print("cdemu_emulated_drive()\n");
+      PrintDebug("cdemu_emulated_drive()\n");
     break;
 
   case 0x2eb:
     if (length == 1 && *((uchar_t*) src) == CDROM_BOOT)
-      Ramdisk_Print("cdrom_boot()\n");
+      PrintDebug("cdrom_boot()\n");
     break;
 
   case 0x2ec:
     if (length == 1 && *((uchar_t*) src) == HARD_DRIVE_POST)
-      Ramdisk_Print("ata_hard_drive_post()\n");
+      PrintDebug("ata_hard_drive_post()\n");
     break;
 
   case 0x2ed:
     if (length == 1)
-      Ramdisk_Print("ata_device_no(%d)\n", *((uchar_t*) src));
+      PrintDebug("ata_device_no(%d)\n", *((uchar_t*) src));
     break;
 
   case 0x2ee:
     if (length == 1)
-      Ramdisk_Print("ata_device_type(%d)\n", *((uchar_t*) src));
+      PrintDebug("ata_device_type(%d)\n", *((uchar_t*) src));
     break;
 
   case 0x2ef:
     if (length == 1 && *((uchar_t*) src) == INT13_HARDDISK)
-      Ramdisk_Print("int13_harddrive()\n");
+      PrintDebug("int13_harddrive()\n");
     break;
 
   case 0x2f8:
     if (length == 1 && *((uchar_t*) src) == INT13_CDROM)
-      Ramdisk_Print("int13_cdrom()\n");
+      PrintDebug("int13_cdrom()\n");
     break;
 
   case 0x2f9:
     if (length == 1 && *((uchar_t*) src) == INT13_CDEMU)
-      Ramdisk_Print("int13_cdemu()\n");
+      PrintDebug("int13_cdemu()\n");
     break;
 
   case 0x2fa:
     if (length == 1 && *((uchar_t*) src) == INT13_ELTORITO)
-      Ramdisk_Print("int13_eltorito()\n");
+      PrintDebug("int13_eltorito()\n");
     break;
 
   case 0x2fb:
     if (length == 1 && *((uchar_t*) src) == INT13_DISKETTE_FUNCTION)
-      Ramdisk_Print("int13_diskette_function()\n");
+      PrintDebug("int13_diskette_function()\n");
     break;
 
 
@@ -1836,193 +2578,34 @@ static void trace_info(ushort_t port, void *src, uint_t length)
   }
 }
 
+#endif
 
-uint_t ramdisk_read_port_ignore(ushort_t port,
-                        void *src,
-                        uint_t length,
-                        struct vm_device *dev)
-{
-  //  Ramdisk_Print("[ramdisk_read_port_ignore] port = %x, length = %d\n", port, length);
-  return 1;
-}
-
-uint_t ramdisk_write_port_ignore(ushort_t port,
-                        void *src,
-                        uint_t length,
-                        struct vm_device *dev)
-{
-
-  //  Ramdisk_Print("[ramdisk_write_port_ignore] port = %x, length = %d\n", port, length);
-
-  trace_info(port, src, length);
-  return 1;
-}
-
-//////////////////////////////////////////////////////////////////////////
-
-/*
- * ATAPI subroutines
- */
-
-static 
-void rd_init_send_atapi_command(struct channel_t *channels, Bit8u channel, Bit8u command, int req_length, int alloc_length, bool lazy)
-{
-  // SELECTED_CONTROLLER(channel).byte_count is a union of SELECTED_CONTROLLER(channel).cylinder_no;
-  // lazy is used to force a data read in the buffer at the next read.
-  
-  Ramdisk_Print("[rd_init_send_atapi_cmd]\n");
-  if (SELECTED_CONTROLLER(channel).byte_count == 0xffff)
-    SELECTED_CONTROLLER(channel).byte_count = 0xfffe;
-  
-  if ((SELECTED_CONTROLLER(channel).byte_count & 1)
-      && !(alloc_length <= SELECTED_CONTROLLER(channel).byte_count)) {
-    Ramdisk_Print("\t\tOdd byte count (0x%04x) to ATAPI command 0x%02x, using 0x%x\n", 
-                 SELECTED_CONTROLLER(channel).byte_count, command, SELECTED_CONTROLLER(channel).byte_count - 1);
-    SELECTED_CONTROLLER(channel).byte_count -= 1;
+static int check_bit_fields(struct controller_t * controller) {
+  //Check bit fields
+  controller->sector_count = 0;
+  controller->interrupt_reason.c_d = 1;
+  if (controller->sector_count != 0x01) {
+    return INTR_REASON_BIT_ERR;
   }
   
-  if (SELECTED_CONTROLLER(channel).byte_count == 0)
-    RD_PANIC("\t\tATAPI command with zero byte count\n");
-  
-  if (alloc_length < 0)
-    RD_PANIC("\t\tAllocation length < 0\n");
-  if (alloc_length == 0)
-    alloc_length = SELECTED_CONTROLLER(channel).byte_count;
-  
-  SELECTED_CONTROLLER(channel).interrupt_reason.i_o = 1;
-  SELECTED_CONTROLLER(channel).interrupt_reason.c_d = 0;
-  SELECTED_CONTROLLER(channel).status.busy = 0;
-  SELECTED_CONTROLLER(channel).status.drq = 1;
-  SELECTED_CONTROLLER(channel).status.err = 0;
-  
-  // no bytes transfered yet
-  if (lazy)
-    SELECTED_CONTROLLER(channel).buffer_index = 2048;
-  else
-    SELECTED_CONTROLLER(channel).buffer_index = 0;
-  SELECTED_CONTROLLER(channel).drq_index = 0;
-  
-  if (SELECTED_CONTROLLER(channel).byte_count > req_length)
-    SELECTED_CONTROLLER(channel).byte_count = req_length;
-  
-  if (SELECTED_CONTROLLER(channel).byte_count > alloc_length)
-    SELECTED_CONTROLLER(channel).byte_count = alloc_length;
-  
-  SELECTED_DRIVE(channel).atapi.command = command;
-  SELECTED_DRIVE(channel).atapi.drq_bytes = SELECTED_CONTROLLER(channel).byte_count;
-  SELECTED_DRIVE(channel).atapi.total_bytes_remaining = (req_length < alloc_length) ? req_length : alloc_length;
-  
-  // if (lazy) {
-  // // bias drq_bytes and total_bytes_remaining
-  // SELECTED_DRIVE(channel).atapi.drq_bytes += 2048;
-  // SELECTED_DRIVE(channel).atapi.total_bytes_remaining += 2048;
-  // }
-}
-
-
-static 
-void rd_atapi_cmd_error(struct channel_t *channels, Bit8u channel, sense_t sense_key, asc_t asc)
-{
-  Ramdisk_Print("[rd_atapi_cmd_error]\n");
-  Ramdisk_Print("Error: atapi_cmd_error channel=%02x key=%02x asc=%02x\n", channel, sense_key, asc);
-
-  SELECTED_CONTROLLER(channel).error_register = sense_key << 4;
-  SELECTED_CONTROLLER(channel).interrupt_reason.i_o = 1;
-  SELECTED_CONTROLLER(channel).interrupt_reason.c_d = 1;
-  SELECTED_CONTROLLER(channel).interrupt_reason.rel = 0;
-  SELECTED_CONTROLLER(channel).status.busy = 0;
-  SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-  SELECTED_CONTROLLER(channel).status.write_fault = 0;
-  SELECTED_CONTROLLER(channel).status.drq = 0;
-  SELECTED_CONTROLLER(channel).status.err = 1;
+  controller->sector_count = 0;
+  controller->interrupt_reason.i_o = 1;
+  if (controller->sector_count != 0x02) {
+    return INTR_REASON_BIT_ERR;
+  }
   
-  SELECTED_DRIVE(channel).sense.sense_key = sense_key;
-  SELECTED_DRIVE(channel).sense.asc = asc;
-  SELECTED_DRIVE(channel).sense.ascq = 0;
-}
-
-
-static 
-void rd_atapi_cmd_nop(struct channel_t *channels, Bit8u channel)
-{
-  Ramdisk_Print("[rd_atapi_cmd_nop]\n");
-  SELECTED_CONTROLLER(channel).interrupt_reason.i_o = 1;
-  SELECTED_CONTROLLER(channel).interrupt_reason.c_d = 1;
-  SELECTED_CONTROLLER(channel).interrupt_reason.rel = 0;
-  SELECTED_CONTROLLER(channel).status.busy = 0;
-  SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-  SELECTED_CONTROLLER(channel).status.drq = 0;
-  SELECTED_CONTROLLER(channel).status.err = 0;
-}
-
-
-static 
-void rd_init_mode_sense_single(struct channel_t *channels, 
-                              Bit8u channel, const void* src, int size)
-{
-  Ramdisk_Print("[rd_init_mode_sense_single]\n");
-  // Header
-  SELECTED_CONTROLLER(channel).buffer[0] = (size+6) >> 8;
-  SELECTED_CONTROLLER(channel).buffer[1] = (size+6) & 0xff;
-  SELECTED_CONTROLLER(channel).buffer[2] = 0x70; // no media present
-  SELECTED_CONTROLLER(channel).buffer[3] = 0; // reserved
-  SELECTED_CONTROLLER(channel).buffer[4] = 0; // reserved
-  SELECTED_CONTROLLER(channel).buffer[5] = 0; // reserved
-  SELECTED_CONTROLLER(channel).buffer[6] = 0; // reserved
-  SELECTED_CONTROLLER(channel).buffer[7] = 0; // reserved
+  controller->sector_count = 0;
+  controller->interrupt_reason.rel = 1;
+  if (controller->sector_count != 0x04) {
+    return INTR_REASON_BIT_ERR;
+  }
   
-  // Data
-  memcpy(SELECTED_CONTROLLER(channel).buffer + 8, src, size);
-}
-
-
-static 
-void rd_ready_to_send_atapi(struct channel_t *channels, Bit8u channel)
-{
-  Ramdisk_Print("[rd_ready_to_send_atapi]\n");
-  rd_raise_interrupt(ramdisk_state->channels, channel);
-}
-
-
-static 
-void rd_command_aborted(struct channel_t *channels, 
-                       Bit8u channel, unsigned value)
-{
-  Ramdisk_Print("[rd_command_aborted]\n");
-  Ramdisk_Print("\t\taborting on command 0x%02x {%s}\n", value, SELECTED_TYPE_STRING(channel));
-  SELECTED_CONTROLLER(channel).current_command = 0;
-  SELECTED_CONTROLLER(channel).status.busy = 0;
-  SELECTED_CONTROLLER(channel).status.drive_ready = 1;
-  SELECTED_CONTROLLER(channel).status.err = 1;
-  SELECTED_CONTROLLER(channel).error_register = 0x04; // command ABORTED
-  SELECTED_CONTROLLER(channel).status.drq = 0;
-  SELECTED_CONTROLLER(channel).status.seek_complete = 0;
-  SELECTED_CONTROLLER(channel).status.corrected_data = 0;
-  SELECTED_CONTROLLER(channel).buffer_index = 0;
-  rd_raise_interrupt(ramdisk_state->channels, channel);
-}
-
-
-
-/*
- * Success: return 0; 
- * Failure: return integer greater than 0
- */
-
-struct ramdisk_t * create_ramdisk()
-{
-  struct ramdisk_t *ramdisk;
-  ramdisk = (struct ramdisk_t *)V3_Malloc(sizeof(struct ramdisk_t));  
-  V3_ASSERT(ramdisk != NULL);
+  controller->sector_count = 0;
+  controller->interrupt_reason.tag = 3;
+  if (controller->sector_count != 0x18) {
+    return INTR_REASON_BIT_ERR;
+  }
   
-  ramdisk->cops.init = &rd_init_harddrive;
-  ramdisk->cops.close = &rd_close_harddrive;
-  ramdisk->cops.reset = &rd_reset_harddrive;
-
-  ramdisk->eops.read_port = &ramdisk_read_port;
-  ramdisk->eops.write_port = &ramdisk_write_port;
-  ramdisk->eops.read_port_ignore = &ramdisk_read_port_ignore;
-  ramdisk->eops.write_port_ignore = &ramdisk_write_port_ignore;
-  return ramdisk;
+  return 0;
 }
+#endif
index 7bfb8aa..69acef5 100644 (file)
  */
 struct Page* g_pageList;
 
-#ifdef RAMDISK_BOOT
 ulong_t g_ramdiskImage;
 ulong_t s_ramdiskSize;
-#endif
+
 
 /*
  * Number of pages currently available on the freelist.
@@ -142,13 +141,12 @@ void Init_Mem(struct Boot_Info* bootInfo)
     ulong_t heapEnd;
     ulong_t vmmMemEnd;
 
-    /*Zheng 08/03/2008*/    
-#ifdef RAMDISK_BOOT
+
     g_ramdiskImage = bootInfo->ramdisk_image;
     s_ramdiskSize = bootInfo->ramdisk_size;
     ulong_t initrdAddr;
     ulong_t initrdEnd;
-#endif
+
     
 
     KASSERT(bootInfo->memSizeKB > 0);
@@ -204,7 +202,6 @@ void Init_Mem(struct Boot_Info* bootInfo)
     /* ** */
     vmmMemEnd = Round_Up_To_Page(pageListEnd + VMM_AVAIL_MEM_SIZE);
 
-#ifdef RAMDISK_BOOT
     /*
      * Zheng 08/03/2008
      * copy the ramdisk to this area 
@@ -216,23 +213,23 @@ void Init_Mem(struct Boot_Info* bootInfo)
     memcpy((ulong_t *)initrdAddr, (ulong_t *)g_ramdiskImage, s_ramdiskSize);
     PrintBoth(" done\n");
     PrintBoth("mem.c(%d) Set 0 to unused bytes in the last ramdisk page from %x to %x", __LINE__, initrdAddr+s_ramdiskSize, initrdEnd);
-    memset((ulong_t *)initrdAddr+s_ramdiskSize, 0, initrdEnd-(initrdAddr+s_ramdiskSize));
+    memset((ulong_t *)initrdAddr + s_ramdiskSize, 0, initrdEnd - (initrdAddr + s_ramdiskSize));
     PrintBoth(" done\n");
-    /*
-     * Zheng 08/03/2008
-     */
-    vm_range_start = initrdEnd;
-    vm_range_end = endOfMem;
-#else
+
+
     
     /* 
      *  the disgusting way to get at the memory assigned to a VM
      */
     
-    vm_range_start = vmmMemEnd;
-    vm_range_end = endOfMem;
-    
-#endif
+    //vm_range_start = vmmMemEnd;
+    //vm_range_end = endOfMem;
+    /*
+     * Zheng 08/03/2008
+     */
+    vm_range_start = initrdEnd;
+    vm_range_end = endOfMem;    
+
 
     Add_Page_Range(0, PAGE_SIZE, PAGE_UNUSED);                        // BIOS area
     Add_Page_Range(PAGE_SIZE, PAGE_SIZE * 3, PAGE_ALLOCATED);         // Intial kernel thread obj + stack
index 663a694..e287b6e 100644 (file)
@@ -23,7 +23,9 @@
 #include <geekos/io_defs.h>
 
 /* PAD this currently is in nvram.c */
+/* JRL: This is completely broken
 extern void deliver_timer_interrupt_to_vmm(uint_t period_us);
+*/
 
 /* JRL Add a cpu frequency measurement */
 uint_t cpu_khz_freq;
@@ -217,9 +219,9 @@ static void Timer_Interrupt_Handler(struct Interrupt_State* state)
     
   }
   
-  
+  /* JRL: Broken,  
   deliver_timer_interrupt_to_vmm(1000000/HZ);
-  
+  */
   End_IRQ(state);
 }
 
@@ -439,3 +441,6 @@ void Micro_Delay(int us)
 
     Spin(numSpins);
 }
+
+
+
diff --git a/palacios/src/lwip/FILES b/palacios/src/lwip/FILES
deleted file mode 100644 (file)
index 952aeab..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-api/      - The code for the high-level wrapper API. Not needed if
-            you use the lowel-level call-back/raw API.
-
-core/     - The core of the TPC/IP stack; protocol implementations,
-            memory and buffer management, and the low-level raw API.
-
-include/  - lwIP include files.
-
-netif/    - Generic network interface device drivers are kept here,
-            as well as the ARP module.
-
-For more information on the various subdirectories, check the FILES
-file in each directory.
index 88fec43..0853b0e 100644 (file)
@@ -52,6 +52,8 @@
 #include "lwip/udp.h"
 #include "lwip/tcpip.h"
 
+#include "lwip/arch.h"
+
 #include <string.h>
 
 #define NUM_SOCKETS MEMP_NUM_NETCONN
@@ -853,9 +855,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
   struct lwip_select_cb select_cb;
   struct lwip_select_cb *p_selcb;
 
-  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n",
-                  maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset,
-                  timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L));
+  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout?timeout->tv_sec:-1L, timeout?timeout->tv_usec:-1L));
 
   select_cb.next = 0;
   select_cb.readset = readset;
diff --git a/palacios/src/lwip/arch/sys_arch.c b/palacios/src/lwip/arch/sys_arch.c
new file mode 100644 (file)
index 0000000..289ed70
--- /dev/null
@@ -0,0 +1,710 @@
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ */
+
+/*
+ * Wed Apr 17 16:05:29 EDT 2002 (James Roth)
+ *
+ *  - Fixed an unlikely sys_thread_new() race condition.
+ *
+ *  - Made current_thread() work with threads which where
+ *    not created with sys_thread_new().  This includes
+ *    the main thread and threads made with pthread_create().
+ *
+ *  - Catch overflows where more than SYS_MBOX_SIZE messages
+ *    are waiting to be read.  The sys_mbox_post() routine
+ *    will block until there is more room instead of just
+ *    leaking messages.
+ */
+#include "lwip/debug.h"
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pthread.h>
+
+#include <geekos/synch.h>
+#include <geekos/kthread.h>
+#include <geekos/debug.h>
+#include <geekos/malloc.h>
+
+#include "lwip/sys.h"
+#include "lwip/opt.h"
+#include "lwip/stats.h"
+
+#define UMAX(a, b)      ((a) > (b) ? (a) : (b))
+
+static struct sys_thread *threads = NULL;
+
+//static pthread_mutex_t threads_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct Mutex threads_mutex; // !!!! need to be initiated, void Mutex_Init(struct Mutex* mutex);
+
+struct sys_mbox_msg {
+  struct sys_mbox_msg *next;
+  void *msg;
+};
+
+#define SYS_MBOX_SIZE 128
+
+struct sys_mbox {
+  int first, last;
+  void *msgs[SYS_MBOX_SIZE];
+  struct sys_sem *mail;
+  struct sys_sem *mutex;
+  int wait_send;
+};
+
+struct sys_sem {
+  unsigned int c;
+  
+  //pthread_cond_t cond;
+  struct Condition cond;
+  
+  //pthread_mutex_t mutex;
+  struct Mutex mutex;
+};
+
+struct sys_thread {
+  struct sys_thread *next;
+  struct sys_timeouts timeouts;
+  
+ // pthread_t pthread;
+  struct Kernel_Thread *pthread;
+};
+
+
+static struct timeval starttime;
+
+//static pthread_mutex_t lwprot_mutex = PTHREAD_MUTEX_INITIALIZER;
+static struct Mutex lwprot_mutex; // !!!! need to be initiated, void Mutex_Init(struct Mutex* mutex);
+
+//static pthread_t lwprot_thread = (pthread_t) 0xDEAD;
+static struct Kernel_Thread lwprot_thread = (struct Kernel_Thread) 0xDEAD;  //!!!!! how to set it to a NULL thread?
+
+static int lwprot_count = 0;
+
+static struct sys_sem *sys_sem_new_(u8_t count);
+static void sys_sem_free_(struct sys_sem *sem);
+
+static u32_t cond_wait(struct Condition *cond, struct Mutex *mutex, u32_t timeout);
+
+
+/*-----------------------------------------------------------------------------------*/
+static struct sys_thread * 
+introduce_thread(struct Kernel_Thread *id /*pthread_t id*/)
+{
+  struct sys_thread *thread;
+  
+  thread = (struct sys_thread *)Malloc(sizeof(struct sys_thread)); 
+    
+  if (thread != NULL) {
+    //pthread_mutex_lock(&threads_mutex);
+    Mutex_Lock(&threads_mutex);
+       
+    thread->next = threads;
+    thread->timeouts.next = NULL;
+    thread->pthread = id;
+    threads = thread;
+
+    //pthread_mutex_unlock(&threads_mutex);
+    Mutex_Unlock(&threads_mutex);
+  }
+    
+  return thread;
+}
+
+static int thread_equal(struct Kernel_Thread *kth1, struct Kernel_Thread *kth2){  //added
+
+       return (kth1->pid == kth2->pid);
+
+}
+
+/*-----------------------------------------------------------------------------------*/
+static struct sys_thread *
+current_thread(void)
+{
+  struct sys_thread *st;
+  
+  //pthread_t pt;
+  struct Kernel_Thread *pt;
+  
+  //pt = pthread_self();
+  //!!!!!!!!!!!Do these have the same means? Not sure
+  pt = Get_Current();
+  
+  //pthread_mutex_lock(&threads_mutex);
+  Mutex_Lock(&threads_mutex);
+
+  for(st = threads; st != NULL; st = st->next) {    
+    if (thread_equal(st->pthread, pt)) {
+      //pthread_mutex_unlock(&threads_mutex);
+      Mutex_Unlock(&threads_mutex);
+
+      return st;
+    }
+  }
+
+  //pthread_mutex_unlock(&threads_mutex);
+  Mutex_Unlock(&threads_mutex);
+
+  st = introduce_thread(pt);
+
+  if (!st) {
+    PrintBoth("lwIP error: In current_thread: Can not get current_thread\n");
+    abort();
+  }
+
+  return st;
+}
+
+
+//!!!!!!!!!!!!backto this function later
+/*-----------------------------------------------------------------------------------*/
+sys_thread_t
+sys_thread_new(char *name, void (* function)(void *arg), void *arg, int stacksize, int prio)
+{
+  int code;
+  //pthread_t tmp;
+  struct Kernel_Thread *tmp;
+  struct sys_thread *st = NULL;
+  
+  //tmp = (struct Kernel_Thread *)Malloc(sizeof(struct Kernel_Thread));
+  
+  /* code = pthread_create(&tmp,
+                        NULL, 
+                        (void *(*)(void *)) 
+                        function, 
+                        arg); */
+                       
+  tmp = Start_Kernel_Thread(function, arg, PRIORITY_NORMAL , false);  //did not consider the priority here
+  
+  if (tmp != NULL) {
+    st = introduce_thread(tmp);
+  }
+  
+  if (NULL == st) {
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create: 0x%x, st = 0x%x",
+                       (int)tmp, (int)st));
+    abort();
+  }
+  return st;
+}
+
+
+/*-----------------------------------------------------------------------------------*/
+struct sys_mbox *
+sys_mbox_new(int size)
+{
+  struct sys_mbox *mbox;
+  
+  mbox = (struct sys_mbox *)Malloc(sizeof(struct sys_mbox));
+  if (mbox != NULL) {
+    mbox->first = mbox->last = 0;
+    mbox->mail = sys_sem_new_(0);
+    mbox->mutex = sys_sem_new_(1);
+    mbox->wait_send = 0;
+  
+#if SYS_STATS
+    lwip_stats.sys.mbox.used++;
+    if (lwip_stats.sys.mbox.used > lwip_stats.sys.mbox.max) {
+      lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
+    }
+#endif /* SYS_STATS */
+  }
+  return mbox;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+sys_mbox_free(struct sys_mbox *mbox)
+{
+  if (mbox != SYS_MBOX_NULL) {
+#if SYS_STATS
+    lwip_stats.sys.mbox.used--;
+#endif /* SYS_STATS */
+    sys_sem_wait(mbox->mutex);
+    
+    sys_sem_free_(mbox->mail);
+    sys_sem_free_(mbox->mutex);
+    mbox->mail = mbox->mutex = NULL;
+    /*  LWIP_DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */
+
+    Free(mbox); 
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+err_t
+sys_mbox_trypost(struct sys_mbox *mbox, void *msg)
+{
+  u8_t first;
+  
+  sys_sem_wait(mbox->mutex);
+  
+  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_trypost: mbox %p msg %p\n",
+                          (void *)mbox, (void *)msg));
+  
+  if ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE))
+    return ERR_MEM;
+
+  mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg;
+  
+  if (mbox->last == mbox->first) {
+    first = 1;
+  } else {
+    first = 0;
+  }
+  
+  mbox->last++;
+  
+  if (first) {
+    sys_sem_signal(mbox->mail);
+  }
+
+  sys_sem_signal(mbox->mutex);
+
+  return ERR_OK;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+sys_mbox_post(struct sys_mbox *mbox, void *msg)
+{
+  u8_t first;
+  
+  sys_sem_wait(mbox->mutex);
+  
+  LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg));
+  
+  while ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) {
+    mbox->wait_send++;
+    sys_sem_signal(mbox->mutex);
+    sys_arch_sem_wait(mbox->mail, 0);
+    sys_arch_sem_wait(mbox->mutex, 0);
+    mbox->wait_send--;
+  }
+  
+  mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg;
+  
+  if (mbox->last == mbox->first) {
+    first = 1;
+  } else {
+    first = 0;
+  }
+  
+  mbox->last++;
+  
+  if (first) {
+    sys_sem_signal(mbox->mail);
+  }
+
+  sys_sem_signal(mbox->mutex);
+}
+/*-----------------------------------------------------------------------------------*/
+u32_t
+sys_arch_mbox_tryfetch(struct sys_mbox *mbox, void **msg)
+{
+  sys_arch_sem_wait(mbox->mutex, 0);
+
+  if (mbox->first == mbox->last) {
+    sys_sem_signal(mbox->mutex);
+    return SYS_MBOX_EMPTY;
+  }
+
+  if (msg != NULL) {
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p msg %p\n", (void *)mbox, *msg));
+    *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE];
+  }
+  else{
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_tryfetch: mbox %p, null msg\n", (void *)mbox));
+  }
+
+  mbox->first++;
+  
+  if (mbox->wait_send) {
+    sys_sem_signal(mbox->mail);
+  }
+
+  sys_sem_signal(mbox->mutex);
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+u32_t
+sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, u32_t timeout)
+{
+  u32_t time = 0;
+  
+  /* The mutex lock is quick so we don't bother with the timeout
+     stuff here. */
+  sys_arch_sem_wait(mbox->mutex, 0);
+
+  while (mbox->first == mbox->last) {
+    sys_sem_signal(mbox->mutex);
+    
+    /* We block while waiting for a mail to arrive in the mailbox. We
+       must be prepared to timeout. */
+    if (timeout != 0) {
+      time = sys_arch_sem_wait(mbox->mail, timeout);
+      
+      if (time == SYS_ARCH_TIMEOUT) {
+        return SYS_ARCH_TIMEOUT;
+      }
+    } else {
+      sys_arch_sem_wait(mbox->mail, 0);
+    }
+    
+    sys_arch_sem_wait(mbox->mutex, 0);
+  }
+
+  if (msg != NULL) {
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg));
+    *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE];
+  }
+  else{
+    LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox));
+  }
+
+  mbox->first++;
+  
+  if (mbox->wait_send) {
+    sys_sem_signal(mbox->mail);
+  }
+
+  sys_sem_signal(mbox->mutex);
+
+  return time;
+}
+/*-----------------------------------------------------------------------------------*/
+struct sys_sem *
+sys_sem_new(u8_t count)
+{
+#if SYS_STATS
+  lwip_stats.sys.sem.used++;
+  if (lwip_stats.sys.sem.used > lwip_stats.sys.sem.max) {
+    lwip_stats.sys.sem.max = lwip_stats.sys.sem.used;
+  }
+#endif /* SYS_STATS */
+  return sys_sem_new_(count);
+}
+
+/*-----------------------------------------------------------------------------------*/
+static struct sys_sem *
+sys_sem_new_(u8_t count)
+{
+  struct sys_sem *sem;
+  
+  sem = (struct sys_sem *)Malloc(sizeof(struct sys_sem));
+  if (sem != NULL) {
+    sem->c = count;
+
+    //pthread_cond_init(&(sem->cond), NULL);
+    Cond_Init(&(sem->cond));
+    
+    //pthread_mutex_init(&(sem->mutex), NULL);
+    Mutex_Init(&(sem->mutex));
+  }
+  return sem;
+}
+
+
+/*-----------------------------------------------------------------------------------*/
+static u32_t
+cond_wait(struct Condition *cond, struct Mutex *mutex, u32_t timeout /* timeout is in miliseconds *//* pthread_cond_t *cond, pthread_mutex_t *mutex, u32_t timeout */)
+{
+  ulong_t tdiff, msec;
+
+  /*
+  struct timeval rtime1, rtime2;
+  struct timespec ts;
+  struct timezone tz;
+  */
+  int retval;
+
+  if (timeout > 0) {
+
+    /* Get a timestamp and add the timeout value. */
+    /*gettimeofday(&rtime1, &tz);
+    sec = rtime1.tv_sec;
+    usec = rtime1.tv_usec;
+    usec += timeout % 1000 * 1000;
+    sec += (int)(timeout / 1000) + (int)(usec / 1000000);
+    usec = usec % 1000000;
+    ts.tv_nsec = usec * 1000;
+    ts.tv_sec = sec;
+    */
+    msec = clock_time();
+  
+    if (Cond_Wait_Timeout(cond, mutex, timeout) == 1) //return due to timeout
+               retval = ETIMEDOUT;
+       
+    //retval = pthread_cond_timedwait(cond, mutex, &ts);
+    
+    if (retval == ETIMEDOUT) {
+      return SYS_ARCH_TIMEOUT;
+    } else {
+      /* Calculate for how long we waited for the cond. */
+
+      /*
+      gettimeofday(&rtime2, &tz);
+      tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 +
+        (rtime2.tv_usec - rtime1.tv_usec) / 1000;
+      */
+      tdiff = clock_time();
+
+      tdiff -= msec;
+      
+      if (tdiff <= 0) {
+        return 0;
+      }
+      
+      return tdiff;
+    }
+  } else {
+    //pthread_cond_wait(cond, mutex);
+    Cond_Wait(cond, mutex);
+       
+    return SYS_ARCH_TIMEOUT;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+u32_t
+sys_arch_sem_wait(struct sys_sem *sem, u32_t timeout)
+{
+  u32_t time = 0;
+  
+  //pthread_mutex_lock(&(sem->mutex));
+  Mutex_Lock(&(sem->mutex));
+  
+  while (sem->c <= 0) {
+    if (timeout > 0) {
+      time = cond_wait(&(sem->cond), &(sem->mutex), timeout);
+      
+      if (time == SYS_ARCH_TIMEOUT) {
+        //pthread_mutex_unlock(&(sem->mutex));
+        Mutex_Unlock(&(sem->mutex));
+       
+        return SYS_ARCH_TIMEOUT;
+      }
+      /*      pthread_mutex_unlock(&(sem->mutex));
+              return time; */
+    } else {  // if timeout = 0
+      cond_wait(&(sem->cond), &(sem->mutex), 0);
+    }
+  }
+  sem->c--;
+  //pthread_mutex_unlock(&(sem->mutex));
+  Mutex_Unlock(&(sem->mutex));
+  
+  return time;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+sys_sem_signal(struct sys_sem *sem)
+{
+  //pthread_mutex_lock(&(sem->mutex));
+  Mutex_Lock(&(sem->mutex));
+  
+  sem->c++;
+
+  if (sem->c > 1) {
+    sem->c = 1;
+  }
+
+  //pthread_cond_broadcast(&(sem->cond));
+  Cond_Broadcast(&(sem->cond));
+  
+  //pthread_mutex_unlock(&(sem->mutex));
+  Mutex_Unlock(&(sem->mutex));
+  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+sys_sem_free(struct sys_sem *sem)
+{
+  if (sem != SYS_SEM_NULL) {
+#if SYS_STATS
+    lwip_stats.sys.sem.used--;
+#endif /* SYS_STATS */
+    sys_sem_free_(sem);
+  }
+}
+
+/*-----------------------------------------------------------------------------------*/
+static void
+sys_sem_free_(struct sys_sem *sem)
+{
+  //pthread_cond_destroy(&(sem->cond));
+  Cond_Destroy(&(sem->cond));
+  
+  //pthread_mutex_destroy(&(sem->mutex));
+  Mutex_Destroy(&(sem->mutex));
+  
+  Free(sem);
+}
+
+#if 0
+//return time, we do not need this
+/*-----------------------------------------------------------------------------------*/
+unsigned long
+sys_unix_now()
+{
+  struct timeval tv;
+  struct timezone tz;
+  long sec, usec;
+  unsigned long msec;
+  gettimeofday(&tv, &tz);
+  
+  sec = tv.tv_sec - starttime.tv_sec;
+  usec = tv.tv_usec - starttime.tv_usec;
+  msec = sec * 1000 + usec / 1000;
+    
+  return msec;
+}
+#endif
+
+/*-----------------------------------------------------------------------------------*/
+void
+sys_init()
+{
+  //struct timezone tz;
+  //gettimeofday(&starttime, &tz);
+
+  Mutex_Init(&threads_mutex);
+  Mutex_Init(&lwprot_mutex);
+  
+}
+/*-----------------------------------------------------------------------------------*/
+struct sys_timeouts *
+sys_arch_timeouts(void)
+{
+  struct sys_thread *thread;
+
+  thread = current_thread();
+  return &thread->timeouts;
+}
+/*-----------------------------------------------------------------------------------*/
+/** sys_prot_t sys_arch_protect(void)
+
+This optional function does a "fast" critical region protection and returns
+the previous protection level. This function is only called during very short
+critical regions. An embedded system which supports ISR-based drivers might
+want to implement this function by disabling interrupts. Task-based systems
+might want to implement this by using a mutex or disabling tasking. This
+function should support recursive calls from the same task or interrupt. In
+other words, sys_arch_protect() could be called while already protected. In
+that case the return value indicates that it is already protected.
+
+sys_arch_protect() is only required if your port is supporting an operating
+system.
+*/
+sys_prot_t
+sys_arch_protect(void)
+{
+    /* Note that for the UNIX port, we are using a lightweight mutex, and our
+     * own counter (which is locked by the mutex). The return code is not actually
+     * used. */
+    if (lwprot_thread != current_thread() /*lwprot_thread != pthread_self()*/)
+    {
+        /* We are locking the mutex where it has not been locked before *
+        * or is being locked by another thread */
+        Mutex_Lock(&lwprot_mutex);
+        lwprot_thread = current_thread();
+        lwprot_count = 1;
+    }
+    else
+        /* It is already locked by THIS thread */
+        lwprot_count++;
+    return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+/** void sys_arch_unprotect(sys_prot_t pval)
+
+This optional function does a "fast" set of critical region protection to the
+value specified by pval. See the documentation for sys_arch_protect() for
+more information. This function is only required if your port is supporting
+an operating system.
+*/
+void
+sys_arch_unprotect(sys_prot_t pval)
+{
+    if (lwprot_thread == current_thread())
+    {
+        if (--lwprot_count == 0)
+        {
+            lwprot_thread = (Kernel_Thread) 0xDEAD;
+            Mutex_Unlock(&lwprot_mutex);
+        }
+    }
+}
+
+/*-----------------------------------------------------------------------------------*/
+
+#ifndef MAX_JIFFY_OFFSET
+#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
+#endif
+
+#ifndef HZ
+#define HZ 100
+#endif
+
+unsigned long
+sys_jiffies(void)
+{
+    struct timeval tv;
+    unsigned long sec = tv.tv_sec;
+    long usec = tv.tv_usec;
+
+    gettimeofday(&tv,NULL);
+
+    if (sec >= (MAX_JIFFY_OFFSET / HZ))
+       return MAX_JIFFY_OFFSET;
+    usec += 1000000L / HZ - 1;
+    usec /= 1000000L / HZ;
+    return HZ * sec + usec;
+}
+
+#if PPP_DEBUG
+
+#include <geekos/serial.h>
+
+void ppp_trace(int level, const char *format, ...)
+{
+    va_list args;
+
+    (void)level;
+    va_start(args, format);
+       
+    //vprintf(format, args);
+    SerialPrintList(format, args);
+       
+    va_end(args);
+}
+#endif
diff --git a/palacios/src/lwip/build/Makefile b/palacios/src/lwip/build/Makefile
new file mode 100644 (file)
index 0000000..ce16551
--- /dev/null
@@ -0,0 +1,94 @@
+#
+# Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
+# All rights reserved. 
+# 
+# Redistribution and use in source and binary forms, with or without modification, 
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+#    this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+#    this list of conditions and the following disclaimer in the documentation
+#    and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+#    derived from this software without specific prior written permission. 
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+# SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+# OF SUCH DAMAGE.
+#
+# This file is part of the lwIP TCP/IP stack.
+# 
+# Author: Adam Dunkels <adam@sics.se>
+#
+
+## modified by Lei Xia 
+
+PROJECT_ROOT=../../../
+
+#Set this to where you have the lwip core module
+LWIPDIR=..
+
+CC_PREFIX :=  $(PROJECT_ROOT)../devtools/i386/bin/i386-elf-
+CC=$(CC_PREFIX)gcc
+CFLAGS=-g -Wall -fpic -DIPv4 -DLWIP_DEBUG
+ARCHIVE=ar
+
+CFLAGS:=$(CFLAGS) \
+       -I$(PROJECT_ROOT)include/ -I$(PROJECT_ROOT)include/lwip  -I$(PROJECT_ROOT)include/lwip/ipv4 -I$(PROJECT_ROOT)include/libc 
+
+# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
+COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c $(LWIPDIR)/core/netif.c \
+       $(LWIPDIR)/core/pbuf.c $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \
+        $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \
+        $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c $(LWIPDIR)/core/init.c 
+CORE4FILES=$(LWIPDIR)/core/ipv4/icmp.c $(LWIPDIR)/core/ipv4/ip.c \
+       $(LWIPDIR)/core/ipv4/inet.c $(LWIPDIR)/core/ipv4/ip_addr.c \
+       $(LWIPDIR)/core/ipv4/inet_chksum.c 
+
+
+# APIFILES: The files which implement the sequential and socket APIs.
+APIFILES=$(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c $(LWIPDIR)/api/tcpip.c \
+       $(LWIPDIR)/api/err.c $(LWIPDIR)/api/sockets.c $(LWIPDIR)/api/netbuf.c $(LWIPDIR)/api/netdb.c
+
+# NETIFFILES: Files implementing various generic network interface functions.'
+NETIFFILES=$(LWIPDIR)/netif/loopif.c \
+       $(LWIPDIR)/netif/etharp.c
+
+# ARCHFILES: Architecture specific files.
+ARCHFILES=$(LWIPDIR)/arch/sys_arch.c
+
+# LWIPFILES: All the above.
+LWIPFILES=$(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES)
+LWIPFILESW=$(wildcard $(LWIPFILES))
+LWIPOBJS=$(notdir $(LWIPFILESW:.c=.o))
+
+#LWIPLIB=lwip.o
+
+%.o:
+       $(CC) $(CFLAGS) -c  $(LWIPFILES)
+
+all: $(LWIPOBJS) 
+       cp *.o $(PROJECT_ROOT)build/lwip/
+
+.PHONY: all
+
+clean:
+       rm -f *.o $(LWIPLIB) *.s .depend* *.core
+
+depend dep: .depend
+
+include .depend
+
+##$(LWIPLIB): $(LWIPOBJS)
+##     $(CC) -g -nostartfiles -shared -static $^ -o $@ 
+
+.depend: $(LWIPFILES)
+       $(CC) $(CFLAGS) -MM $^ > .depend || rm -f .depend
diff --git a/palacios/src/lwip/include/ipv4/lwip/autoip.h b/palacios/src/lwip/include/ipv4/lwip/autoip.h
deleted file mode 100644 (file)
index 076a2ed..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * @file
- *
- * AutoIP Automatic LinkLocal IP Configuration
- */
-
-/*
- *
- * Copyright (c) 2007 Dominik Spies <kontakt@dspies.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * Author: Dominik Spies <kontakt@dspies.de>
- *
- * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
- * with RFC 3927.
- *
- *
- * Please coordinate changes and requests with Dominik Spies
- * <kontakt@dspies.de>
- */
-#ifndef __LWIP_AUTOIP_H__
-#define __LWIP_AUTOIP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/netif.h"
-#include "lwip/udp.h"
-#include "netif/etharp.h"
-
-/* AutoIP Timing */
-#define AUTOIP_TMR_INTERVAL      100
-#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
-
-/* RFC 3927 Constants */
-#define PROBE_WAIT               1   /* second   (initial random delay)                 */
-#define PROBE_MIN                1   /* second   (minimum delay till repeated probe)    */
-#define PROBE_MAX                2   /* seconds  (maximum delay till repeated probe)    */
-#define PROBE_NUM                3   /*          (number of probe packets)              */
-#define ANNOUNCE_NUM             2   /*          (number of announcement packets)       */
-#define ANNOUNCE_INTERVAL        2   /* seconds  (time between announcement packets)    */
-#define ANNOUNCE_WAIT            2   /* seconds  (delay before announcing)              */
-#define MAX_CONFLICTS            10  /*          (max conflicts before rate limiting)   */
-#define RATE_LIMIT_INTERVAL      60  /* seconds  (delay between successive attempts)    */
-#define DEFEND_INTERVAL          10  /* seconds  (min. wait between defensive ARPs)     */
-
-/* AutoIP client states */
-#define AUTOIP_STATE_OFF         0
-#define AUTOIP_STATE_PROBING     1
-#define AUTOIP_STATE_ANNOUNCING  2
-#define AUTOIP_STATE_BOUND       3
-
-struct autoip
-{
-  struct ip_addr llipaddr;  /* the currently selected, probed, announced or used LL IP-Address */
-  u8_t state;               /* current AutoIP state machine state */
-  u8_t sent_num;            /* sent number of probes or announces, dependent on state */
-  u16_t ttw;                /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
-  u8_t lastconflict;        /* ticks until a conflict can be solved by defending */
-  u8_t tried_llipaddr;      /* total number of probed/used Link Local IP-Addresses */
-};
-
-
-/** Init srand, has to be called before entering mainloop */
-void autoip_init(void);
-
-/** Start AutoIP client */
-err_t autoip_start(struct netif *netif);
-
-/** Stop AutoIP client */
-err_t autoip_stop(struct netif *netif);
-
-/** Handles every incoming ARP Packet, called by etharp_arp_input */
-void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
-
-/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
-void autoip_tmr(void);
-
-#endif /* LWIP_AUTOIP */
-
-#endif /* __LWIP_AUTOIP_H__ */
diff --git a/palacios/src/lwip/include/ipv4/lwip/icmp.h b/palacios/src/lwip/include/ipv4/lwip/icmp.h
deleted file mode 100644 (file)
index 59a31f9..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_ICMP_H__
-#define __LWIP_ICMP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
-#include "lwip/netif.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ICMP_ER 0      /* echo reply */
-#define ICMP_DUR 3     /* destination unreachable */
-#define ICMP_SQ 4      /* source quench */
-#define ICMP_RD 5      /* redirect */
-#define ICMP_ECHO 8    /* echo */
-#define ICMP_TE 11     /* time exceeded */
-#define ICMP_PP 12     /* parameter problem */
-#define ICMP_TS 13     /* timestamp */
-#define ICMP_TSR 14    /* timestamp reply */
-#define ICMP_IRQ 15    /* information request */
-#define ICMP_IR 16     /* information reply */
-
-enum icmp_dur_type {
-  ICMP_DUR_NET = 0,    /* net unreachable */
-  ICMP_DUR_HOST = 1,   /* host unreachable */
-  ICMP_DUR_PROTO = 2,  /* protocol unreachable */
-  ICMP_DUR_PORT = 3,   /* port unreachable */
-  ICMP_DUR_FRAG = 4,   /* fragmentation needed and DF set */
-  ICMP_DUR_SR = 5      /* source route failed */
-};
-
-enum icmp_te_type {
-  ICMP_TE_TTL = 0,     /* time to live exceeded in transit */
-  ICMP_TE_FRAG = 1     /* fragment reassembly time exceeded */
-};
-
-void icmp_input(struct pbuf *p, struct netif *inp);
-
-void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
-void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct icmp_echo_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u16_t id);
-  PACK_STRUCT_FIELD(u16_t seqno);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-
-PACK_STRUCT_BEGIN
-struct icmp_dur_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u32_t unused);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-
-PACK_STRUCT_BEGIN
-struct icmp_te_hdr {
-  PACK_STRUCT_FIELD(u16_t _type_code);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u32_t unused);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#define ICMPH_TYPE(hdr) (ntohs((hdr)->_type_code) >> 8)
-#define ICMPH_CODE(hdr) (ntohs((hdr)->_type_code) & 0xff)
-
-#define ICMPH_TYPE_SET(hdr, type) ((hdr)->_type_code = htons(ICMPH_CODE(hdr) | ((type) << 8)))
-#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_ICMP */
-
-#endif /* __LWIP_ICMP_H__ */
diff --git a/palacios/src/lwip/include/ipv4/lwip/igmp.h b/palacios/src/lwip/include/ipv4/lwip/igmp.h
deleted file mode 100644 (file)
index 59c933f..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2002 CITEL Technologies Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED.  IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE 
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
- * SUCH DAMAGE. 
- *
- * This file is a contribution to the lwIP TCP/IP stack.
- * The Swedish Institute of Computer Science and Adam Dunkels
- * are specifically granted permission to redistribute this
- * source code.
-*/
-
-#ifndef __LWIP_IGMP_H__
-#define __LWIP_IGMP_H__
-
-#include "lwip/opt.h"
-#include "lwip/ip_addr.h"
-#include "lwip/netif.h"
-#include "lwip/pbuf.h"
-
-#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* 
- * IGMP constants
- */
-#define IP_PROTO_IGMP                  2
-#define IGMP_TTL                       1
-#define IGMP_MINLEN                    8
-#define ROUTER_ALERT                   0x9404
-#define ROUTER_ALERTLEN                4
-
-/*
- * IGMP message types, including version number.
- */
-#define IGMP_MEMB_QUERY                0x11 /* Membership query         */
-#define IGMP_V1_MEMB_REPORT            0x12 /* Ver. 1 membership report */
-#define IGMP_V2_MEMB_REPORT            0x16 /* Ver. 2 membership report */
-#define IGMP_LEAVE_GROUP               0x17 /* Leave-group message      */
-
-/* IGMP timer */
-#define IGMP_TMR_INTERVAL              100 /* Milliseconds */
-#define IGMP_V1_DELAYING_MEMBER_TMR   (1000/IGMP_TMR_INTERVAL)
-#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
-
-/* MAC Filter Actions */
-#define IGMP_DEL_MAC_FILTER            0
-#define IGMP_ADD_MAC_FILTER            1
-
-/* Group  membership states */
-#define IGMP_GROUP_NON_MEMBER          0
-#define IGMP_GROUP_DELAYING_MEMBER     1
-#define IGMP_GROUP_IDLE_MEMBER         2
-
-/*
- * IGMP packet format.
- */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct igmp_msg {
- PACK_STRUCT_FIELD(u8_t           igmp_msgtype);
- PACK_STRUCT_FIELD(u8_t           igmp_maxresp);
- PACK_STRUCT_FIELD(u16_t          igmp_checksum);
- PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/* 
- * now a group structure - there is
- * a list of groups for each interface
- * these should really be linked from the interface, but
- * if we keep them separate we will not affect the lwip original code
- * too much
- * 
- * There will be a group for the all systems group address but this 
- * will not run the state machine as it is used to kick off reports
- * from all the other groups
- */
-
-struct igmp_group {
-  struct igmp_group *next;
-  struct netif      *interface;
-  struct ip_addr     group_address;
-  u8_t               last_reporter_flag; /* signifies we were the last person to report */
-  u8_t               group_state;
-  u16_t              timer;
-  u8_t               use; /* counter of simultaneous uses */
-};
-
-
-/*  Prototypes */
-void   igmp_init(void);
-
-err_t  igmp_start( struct netif *netif);
-
-err_t  igmp_stop( struct netif *netif);
-
-void   igmp_report_groups( struct netif *netif);
-
-struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);
-
-struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);
-
-err_t  igmp_remove_group( struct igmp_group *group);
-
-void   igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
-
-err_t  igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
-
-err_t  igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
-
-void   igmp_tmr(void);
-
-void   igmp_timeout( struct igmp_group *group);
-
-void   igmp_start_timer( struct igmp_group *group, u8_t max_time);
-
-void   igmp_stop_timer( struct igmp_group *group);
-
-void   igmp_delaying_member( struct igmp_group *group, u8_t maxresp);
-
-err_t  igmp_ip_output_if( struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif);
-
-void   igmp_send( struct igmp_group *group, u8_t type);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_IGMP */
-
-#endif /* __LWIP_IGMP_H__ */
diff --git a/palacios/src/lwip/include/ipv4/lwip/inet.h b/palacios/src/lwip/include/ipv4/lwip/inet.h
deleted file mode 100644 (file)
index 1ffcf70..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_INET_H__
-#define __LWIP_INET_H__
-
-#include "lwip/opt.h"
-
-#include "lwip/ip_addr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-u32_t inet_addr(const char *cp);
-int inet_aton(const char *cp, struct in_addr *addr);
-char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
-
-#ifdef htons
-#undef htons
-#endif /* htons */
-#ifdef htonl
-#undef htonl
-#endif /* htonl */
-#ifdef ntohs
-#undef ntohs
-#endif /* ntohs */
-#ifdef ntohl
-#undef ntohl
-#endif /* ntohl */
-
-#ifndef LWIP_PLATFORM_BYTESWAP
-#define LWIP_PLATFORM_BYTESWAP 0
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-#define htons(x) (x)
-#define ntohs(x) (x)
-#define htonl(x) (x)
-#define ntohl(x) (x)
-#else /* BYTE_ORDER != BIG_ENDIAN */
-#ifdef LWIP_PREFIX_BYTEORDER_FUNCS
-/* workaround for naming collisions on some platforms */
-#define htons lwip_htons
-#define ntohs lwip_ntohs
-#define htonl lwip_htonl
-#define ntohl lwip_ntohl
-#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
-#if LWIP_PLATFORM_BYTESWAP
-#define htons(x) LWIP_PLATFORM_HTONS(x)
-#define ntohs(x) LWIP_PLATFORM_HTONS(x)
-#define htonl(x) LWIP_PLATFORM_HTONL(x)
-#define ntohl(x) LWIP_PLATFORM_HTONL(x)
-#else /* LWIP_PLATFORM_BYTESWAP */
-u16_t htons(u16_t x);
-u16_t ntohs(u16_t x);
-u32_t htonl(u32_t x);
-u32_t ntohl(u32_t x);
-#endif /* LWIP_PLATFORM_BYTESWAP */
-
-#endif /* BYTE_ORDER == BIG_ENDIAN */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_INET_H__ */
diff --git a/palacios/src/lwip/include/ipv4/lwip/ip_addr.h b/palacios/src/lwip/include/ipv4/lwip/ip_addr.h
deleted file mode 100644 (file)
index 7f24336..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_IP_ADDR_H__
-#define __LWIP_IP_ADDR_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct ip_addr {
-  PACK_STRUCT_FIELD(u32_t addr);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/*
- * struct ipaddr2 is used in the definition of the ARP packet format in
- * order to support compilers that don't have structure packing.
- */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct ip_addr2 {
-  PACK_STRUCT_FIELD(u16_t addrw[2]);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/* For compatibility with BSD code */
-struct in_addr {
-  u32_t s_addr;
-};
-
-struct netif;
-
-extern const struct ip_addr ip_addr_any;
-extern const struct ip_addr ip_addr_broadcast;
-
-/** IP_ADDR_ can be used as a fixed IP address
- *  for the wildcard and the broadcast address
- */
-#define IP_ADDR_ANY         ((struct ip_addr *)&ip_addr_any)
-#define IP_ADDR_BROADCAST   ((struct ip_addr *)&ip_addr_broadcast)
-
-#define INADDR_NONE         ((u32_t)0xffffffffUL)  /* 255.255.255.255 */
-#define INADDR_LOOPBACK     ((u32_t)0x7f000001UL)  /* 127.0.0.1 */
-
-/* Definitions of the bits in an Internet address integer.
-
-   On subnets, host and network parts are found according to
-   the subnet mask, not these masks.  */
-
-#define IN_CLASSA(a)        ((((u32_t)(a)) & 0x80000000UL) == 0)
-#define IN_CLASSA_NET       0xff000000
-#define IN_CLASSA_NSHIFT    24
-#define IN_CLASSA_HOST      (0xffffffff & ~IN_CLASSA_NET)
-#define IN_CLASSA_MAX       128
-
-#define IN_CLASSB(a)        ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL)
-#define IN_CLASSB_NET       0xffff0000
-#define IN_CLASSB_NSHIFT    16
-#define IN_CLASSB_HOST      (0xffffffff & ~IN_CLASSB_NET)
-#define IN_CLASSB_MAX       65536
-
-#define IN_CLASSC(a)        ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL)
-#define IN_CLASSC_NET       0xffffff00
-#define IN_CLASSC_NSHIFT    8
-#define IN_CLASSC_HOST      (0xffffffff & ~IN_CLASSC_NET)
-
-#define IN_CLASSD(a)        (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL)
-#define IN_CLASSD_NET       0xf0000000          /* These ones aren't really */
-#define IN_CLASSD_NSHIFT    28                  /*   net and host fields, but */
-#define IN_CLASSD_HOST      0x0fffffff          /*   routing needn't know. */
-#define IN_MULTICAST(a)     IN_CLASSD(a)
-
-#define IN_EXPERIMENTAL(a)  (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
-#define IN_BADCLASS(a)      (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL)
-
-#define IN_LOOPBACKNET      127                 /* official! */
-
-#define IP4_ADDR(ipaddr, a,b,c,d) \
-        (ipaddr)->addr = htonl(((u32_t)((a) & 0xff) << 24) | \
-                               ((u32_t)((b) & 0xff) << 16) | \
-                               ((u32_t)((c) & 0xff) << 8) | \
-                                (u32_t)((d) & 0xff))
-
-#define ip_addr_set(dest, src) (dest)->addr = \
-                               ((src) == NULL? 0:\
-                               (src)->addr)
-/**
- * Determine if two address are on the same network.
- *
- * @arg addr1 IP address 1
- * @arg addr2 IP address 2
- * @arg mask network identifier mask
- * @return !0 if the network identifiers of both address match
- */
-#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \
-                                              (mask)->addr) == \
-                                             ((addr2)->addr & \
-                                              (mask)->addr))
-#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
-
-#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
-
-u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *);
-
-#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000UL)) == ntohl(0xe0000000UL))
-
-#define ip_addr_islinklocal(addr1) (((addr1)->addr & ntohl(0xffff0000UL)) == ntohl(0xa9fe0000UL))
-
-#define ip_addr_debug_print(debug, ipaddr) \
-        LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
-                ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff : 0, \
-                ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff : 0, \
-                ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff : 0, \
-                ipaddr ? (u16_t)ntohl((ipaddr)->addr) & 0xff : 0))
-
-/* These are cast to u16_t, with the intent that they are often arguments
- * to printf using the U16_F format from cc.h. */
-#define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
-#define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
-#define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
-#define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_IP_ADDR_H__ */
diff --git a/palacios/src/lwip/include/ipv4/lwip/ip_frag.h b/palacios/src/lwip/include/ipv4/lwip/ip_frag.h
deleted file mode 100644 (file)
index 380e604..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Jani Monoses <jani@iv.ro>
- *
- */
-
-#ifndef __LWIP_IP_FRAG_H__
-#define __LWIP_IP_FRAG_H__
-
-#include "lwip/opt.h"
-#include "lwip/err.h"
-#include "lwip/pbuf.h"
-#include "lwip/netif.h"
-#include "lwip/ip_addr.h"
-#include "lwip/ip.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if IP_REASSEMBLY
-/* The IP reassembly timer interval in milliseconds. */
-#define IP_TMR_INTERVAL 1000
-
-/* IP reassembly helper struct.
- * This is exported because memp needs to know the size.
- */
-struct ip_reassdata {
-  struct ip_reassdata *next;
-  struct pbuf *p;
-  struct ip_hdr iphdr;
-  u16_t datagram_len;
-  u8_t flags;
-  u8_t timer;
-};
-
-void ip_reass_init(void);
-void ip_reass_tmr(void);
-struct pbuf * ip_reass(struct pbuf *p);
-#endif /* IP_REASSEMBLY */
-
-#if IP_FRAG
-err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest);
-#endif /* IP_FRAG */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_IP_FRAG_H__ */
diff --git a/palacios/src/lwip/include/ipv6/lwip/icmp.h b/palacios/src/lwip/include/ipv6/lwip/icmp.h
deleted file mode 100644 (file)
index 87e9ffd..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_ICMP_H__
-#define __LWIP_ICMP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/pbuf.h"
-#include "lwip/netif.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ICMP6_DUR  1
-#define ICMP6_TE   3
-#define ICMP6_ECHO 128    /* echo */
-#define ICMP6_ER   129      /* echo reply */
-
-
-enum icmp_dur_type {
-  ICMP_DUR_NET = 0,    /* net unreachable */
-  ICMP_DUR_HOST = 1,   /* host unreachable */
-  ICMP_DUR_PROTO = 2,  /* protocol unreachable */
-  ICMP_DUR_PORT = 3,   /* port unreachable */
-  ICMP_DUR_FRAG = 4,   /* fragmentation needed and DF set */
-  ICMP_DUR_SR = 5      /* source route failed */
-};
-
-enum icmp_te_type {
-  ICMP_TE_TTL = 0,     /* time to live exceeded in transit */
-  ICMP_TE_FRAG = 1     /* fragment reassembly time exceeded */
-};
-
-void icmp_input(struct pbuf *p, struct netif *inp);
-
-void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
-void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
-
-struct icmp_echo_hdr {
-  u8_t type;
-  u8_t icode;
-  u16_t chksum;
-  u16_t id;
-  u16_t seqno;
-};
-
-struct icmp_dur_hdr {
-  u8_t type;
-  u8_t icode;
-  u16_t chksum;
-  u32_t unused;
-};
-
-struct icmp_te_hdr {
-  u8_t type;
-  u8_t icode;
-  u16_t chksum;
-  u32_t unused;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_ICMP */
-
-#endif /* __LWIP_ICMP_H__ */
-
diff --git a/palacios/src/lwip/include/ipv6/lwip/inet.h b/palacios/src/lwip/include/ipv6/lwip/inet.h
deleted file mode 100644 (file)
index de1a0b6..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_INET_H__
-#define __LWIP_INET_H__
-
-#include "lwip/opt.h"
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-u16_t inet_chksum(void *data, u16_t len);
-u16_t inet_chksum_pbuf(struct pbuf *p);
-u16_t inet_chksum_pseudo(struct pbuf *p,
-       struct ip_addr *src, struct ip_addr *dest,
-       u8_t proto, u32_t proto_len);
-
-u32_t inet_addr(const char *cp);
-s8_t inet_aton(const char *cp, struct in_addr *addr);
-
-#ifndef _MACHINE_ENDIAN_H_
-#ifndef _NETINET_IN_H
-#ifndef _LINUX_BYTEORDER_GENERIC_H
-u16_t htons(u16_t n);
-u16_t ntohs(u16_t n);
-u32_t htonl(u32_t n);
-u32_t ntohl(u32_t n);
-#endif /* _LINUX_BYTEORDER_GENERIC_H */
-#endif /* _NETINET_IN_H */
-#endif /* _MACHINE_ENDIAN_H_ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_INET_H__ */
-
diff --git a/palacios/src/lwip/include/ipv6/lwip/ip.h b/palacios/src/lwip/include/ipv6/lwip/ip.h
deleted file mode 100644 (file)
index f6e59cc..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_IP_H__
-#define __LWIP_IP_H__
-
-#include "lwip/opt.h"
-#include "lwip/def.h"
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
-
-#include "lwip/err.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define IP_HLEN 40
-
-#define IP_PROTO_ICMP    58
-#define IP_PROTO_UDP     17
-#define IP_PROTO_UDPLITE 136
-#define IP_PROTO_TCP     6
-
-/* This is passed as the destination address to ip_output_if (not
-   to ip_output), meaning that an IP header already is constructed
-   in the pbuf. This is used when TCP retransmits. */
-#ifdef IP_HDRINCL
-#undef IP_HDRINCL
-#endif /* IP_HDRINCL */
-#define IP_HDRINCL  NULL
-
-#if LWIP_NETIF_HWADDRHINT
-#define IP_PCB_ADDRHINT ;u8_t addr_hint
-#else
-#define IP_PCB_ADDRHINT
-#endif /* LWIP_NETIF_HWADDRHINT */
-
-/* This is the common part of all PCB types. It needs to be at the
-   beginning of a PCB type definition. It is located here so that
-   changes to this common part are made in one location instead of
-   having to change all PCB structs. */
-#define IP_PCB struct ip_addr local_ip; \
-  struct ip_addr remote_ip; \
-   /* Socket options */  \
-  u16_t so_options;      \
-   /* Type Of Service */ \
-  u8_t tos;              \
-  /* Time To Live */     \
-  u8_t ttl;              \
-  /* link layer address resolution hint */ \
-  IP_PCB_ADDRHINT
-
-
-/* The IPv6 header. */
-struct ip_hdr {
-#if BYTE_ORDER == LITTLE_ENDIAN
-  u8_t tclass1:4, v:4;
-  u8_t flow1:4, tclass2:4;  
-#else
-  u8_t v:4, tclass1:4;
-  u8_t tclass2:8, flow1:4;
-#endif
-  u16_t flow2;
-  u16_t len;                /* payload length */
-  u8_t nexthdr;             /* next header */
-  u8_t hoplim;              /* hop limit (TTL) */
-  struct ip_addr src, dest;          /* source and destination IP addresses */
-};
-
-#define IPH_PROTO(hdr) (iphdr->nexthdr)
-
-void ip_init(void);
-
-#include "lwip/netif.h"
-
-struct netif *ip_route(struct ip_addr *dest);
-
-void ip_input(struct pbuf *p, struct netif *inp);
-
-/* source and destination addresses in network byte order, please */
-err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
-         u8_t ttl, u8_t proto);
-
-err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
-      u8_t ttl, u8_t proto,
-      struct netif *netif);
-
-#if IP_DEBUG
-void ip_debug_print(struct pbuf *p);
-#endif /* IP_DEBUG */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_IP_H__ */
-
-
diff --git a/palacios/src/lwip/include/ipv6/lwip/ip_addr.h b/palacios/src/lwip/include/ipv6/lwip/ip_addr.h
deleted file mode 100644 (file)
index b2d8ae5..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_IP_ADDR_H__
-#define __LWIP_IP_ADDR_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define IP_ADDR_ANY 0
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
- struct ip_addr {
-  PACK_STRUCT_FIELD(u32_t addr[4]);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/*
- * struct ipaddr2 is used in the definition of the ARP packet format in
- * order to support compilers that don't have structure packing.
- */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct ip_addr2 {
-  PACK_STRUCT_FIELD(u16_t addrw[2]);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \
-                                               (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \
-                                               (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \
-                                               (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0)
-
-u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2,
-        struct ip_addr *mask);
-u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2);
-void ip_addr_set(struct ip_addr *dest, struct ip_addr *src);
-u8_t ip_addr_isany(struct ip_addr *addr);
-
-#define ip_addr_debug_print(debug, ipaddr) \
-        LWIP_DEBUGF(debug, ("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F"\n", \
-         (ntohl(ipaddr->addr[0]) >> 16) & 0xffff, \
-         ntohl(ipaddr->addr[0]) & 0xffff, \
-         (ntohl(ipaddr->addr[1]) >> 16) & 0xffff, \
-         ntohl(ipaddr->addr[1]) & 0xffff, \
-         (ntohl(ipaddr->addr[2]) >> 16) & 0xffff, \
-         ntohl(ipaddr->addr[2]) & 0xffff, \
-         (ntohl(ipaddr->addr[3]) >> 16) & 0xffff, \
-         ntohl(ipaddr->addr[3]) & 0xffff));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_IP_ADDR_H__ */
diff --git a/palacios/src/lwip/include/lwip/api.h b/palacios/src/lwip/include/lwip/api.h
deleted file mode 100644 (file)
index 31d767f..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_API_H__
-#define __LWIP_API_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/netbuf.h"
-#include "lwip/sys.h"
-#include "lwip/ip_addr.h"
-#include "lwip/err.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Throughout this file, IP addresses and port numbers are expected to be in
- * the same byte order as in the corresponding pcb.
- */
-
-/* Flags for netconn_write */
-#define NETCONN_NOFLAG 0x00
-#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
-#define NETCONN_COPY   0x01
-#define NETCONN_MORE   0x02
-
-/* Helpers to process several netconn_types by the same code */
-#define NETCONNTYPE_GROUP(t)    (t&0xF0)
-#define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
-
-enum netconn_type {
-  NETCONN_INVALID    = 0,
-  /* NETCONN_TCP Group */
-  NETCONN_TCP        = 0x10,
-  /* NETCONN_UDP Group */
-  NETCONN_UDP        = 0x20,
-  NETCONN_UDPLITE    = 0x21,
-  NETCONN_UDPNOCHKSUM= 0x22,
-  /* NETCONN_RAW Group */
-  NETCONN_RAW        = 0x40
-};
-
-enum netconn_state {
-  NETCONN_NONE,
-  NETCONN_WRITE,
-  NETCONN_LISTEN,
-  NETCONN_CONNECT,
-  NETCONN_CLOSE
-};
-
-enum netconn_evt {
-  NETCONN_EVT_RCVPLUS,
-  NETCONN_EVT_RCVMINUS,
-  NETCONN_EVT_SENDPLUS,
-  NETCONN_EVT_SENDMINUS
-};
-
-#if LWIP_IGMP
-enum netconn_igmp {
-  NETCONN_JOIN,
-  NETCONN_LEAVE
-};
-#endif /* LWIP_IGMP */
-
-/* forward-declare some structs to avoid to include their headers */
-struct ip_pcb;
-struct tcp_pcb;
-struct udp_pcb;
-struct raw_pcb;
-struct netconn;
-
-/** A callback prototype to inform about events for a netconn */
-typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
-
-/** A netconn descriptor */
-struct netconn {
-  /** type of the netconn (TCP, UDP or RAW) */
-  enum netconn_type type;
-  /** current state of the netconn */
-  enum netconn_state state;
-  /** the lwIP internal protocol control block */
-  union {
-    struct ip_pcb  *ip;
-    struct tcp_pcb *tcp;
-    struct udp_pcb *udp;
-    struct raw_pcb *raw;
-  } pcb;
-  /** the last error this netconn had */
-  err_t err;
-  /** sem that is used to synchroneously execute functions in the core context */
-  sys_sem_t op_completed;
-  /** mbox where received packets are stored until they are fetched
-      by the netconn application thread (can grow quite big) */
-  sys_mbox_t recvmbox;
-  /** mbox where new connections are stored until processed
-      by the application thread */
-  sys_mbox_t acceptmbox;
-  /** only used for socket layer */
-  int socket;
-#if LWIP_SO_RCVTIMEO
-  /** timeout to wait for new data to be received
-      (or connections to arrive for listening netconns) */
-  int recv_timeout;
-#endif /* LWIP_SO_RCVTIMEO */
-#if LWIP_SO_RCVBUF
-  /** maximum amount of bytes queued in recvmbox */
-  int recv_bufsize;
-#endif /* LWIP_SO_RCVBUF */
-  u16_t recv_avail;
-  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
-      this temporarily stores the message. */
-  struct api_msg_msg *write_msg;
-  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
-      this temporarily stores how much is already sent. */
-  int write_offset;
-#if LWIP_TCPIP_CORE_LOCKING
-  /** TCP: when data passed to netconn_write doesn't fit into the send buffer,
-      this temporarily stores whether to wake up the original application task
-      if data couldn't be sent in the first try. */
-  u8_t write_delayed;
-#endif /* LWIP_TCPIP_CORE_LOCKING */
-  /** A callback function that is informed about events for this netconn */
-  netconn_callback callback;
-};
-
-/* Register an Network connection event */
-#define API_EVENT(c,e,l) if (c->callback) {         \
-                           (*c->callback)(c, e, l); \
-                         }
-
-/* Network connection functions: */
-#define netconn_new(t)                  netconn_new_with_proto_and_callback(t, 0, NULL)
-#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
-struct
-netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
-                                   netconn_callback callback);
-err_t             netconn_delete  (struct netconn *conn);
-enum netconn_type netconn_type    (struct netconn *conn);
-
-err_t             netconn_getaddr (struct netconn *conn,
-                                   struct ip_addr *addr,
-                                   u16_t *port,
-                                   u8_t local);
-#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
-#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
-
-err_t             netconn_bind    (struct netconn *conn,
-                                   struct ip_addr *addr,
-                                   u16_t port);
-err_t             netconn_connect (struct netconn *conn,
-                                   struct ip_addr *addr,
-                                   u16_t port);
-err_t             netconn_disconnect (struct netconn *conn);
-err_t             netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
-#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
-struct netconn *  netconn_accept  (struct netconn *conn);
-struct netbuf *   netconn_recv    (struct netconn *conn);
-err_t             netconn_sendto  (struct netconn *conn,
-                                   struct netbuf *buf, struct ip_addr *addr, u16_t port);
-err_t             netconn_send    (struct netconn *conn,
-                                   struct netbuf *buf);
-err_t             netconn_write   (struct netconn *conn,
-                                   const void *dataptr, int size,
-                                   u8_t apiflags);
-err_t             netconn_close   (struct netconn *conn);
-
-#if LWIP_IGMP
-err_t             netconn_join_leave_group (struct netconn *conn,
-                                            struct ip_addr *multiaddr,
-                                            struct ip_addr *interface,
-                                            enum netconn_igmp join_or_leave);
-#endif /* LWIP_IGMP */
-#if LWIP_DNS
-err_t             netconn_gethostbyname(const char *name, struct ip_addr *addr);
-#endif /* LWIP_DNS */
-
-#define netconn_err(conn)          ((conn)->err)
-#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_NETCONN */
-
-#endif /* __LWIP_API_H__ */
diff --git a/palacios/src/lwip/include/lwip/api_msg.h b/palacios/src/lwip/include/lwip/api_msg.h
deleted file mode 100644 (file)
index 4c9b48e..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_API_MSG_H__
-#define __LWIP_API_MSG_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/ip_addr.h"
-#include "lwip/err.h"
-#include "lwip/sys.h"
-#include "lwip/igmp.h"
-#include "lwip/api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* IP addresses and port numbers are expected to be in
- * the same byte order as in the corresponding pcb.
- */
-/** This struct includes everything that is necessary to execute a function
-    for a netconn in another thread context (mainly used to process netconns
-    in the tcpip_thread context to be thread safe). */
-struct api_msg_msg {
-  /** The netconn which to process - always needed: it includes the semaphore
-      which is used to block the application thread until the function finished. */
-  struct netconn *conn;
-  /** Depending on the executed function, one of these union members is used */
-  union {
-    /** used for do_send */
-    struct netbuf *b;
-    /** used for do_newconn */
-    struct {
-      u8_t proto;
-    } n;
-    /** used for do_bind and do_connect */
-    struct {
-      struct ip_addr *ipaddr;
-      u16_t port;
-    } bc;
-    /** used for do_getaddr */
-    struct {
-      struct ip_addr *ipaddr;
-      u16_t *port;
-      u8_t local;
-    } ad;
-    /** used for do_write */
-    struct {
-      const void *dataptr;
-      int len;
-      u8_t apiflags;
-    } w;
-    /** used ofr do_recv */
-    struct {
-      u16_t len;
-    } r;
-#if LWIP_IGMP
-    /** used for do_join_leave_group */
-    struct {
-      struct ip_addr *multiaddr;
-      struct ip_addr *interface;
-      enum netconn_igmp join_or_leave;
-    } jl;
-#endif /* LWIP_IGMP */
-#if TCP_LISTEN_BACKLOG
-    struct {
-      u8_t backlog;
-    } lb;
-#endif /* TCP_LISTEN_BACKLOG */
-  } msg;
-};
-
-/** This struct contains a function to execute in another thread context and
-    a struct api_msg_msg that serves as an argument for this function.
-    This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
-struct api_msg {
-  /** function to execute in tcpip_thread context */
-  void (* function)(struct api_msg_msg *msg);
-  /** arguments for this function */
-  struct api_msg_msg msg;
-};
-
-#if LWIP_DNS
-/** As do_gethostbyname requires more arguments but doesn't require a netconn,
-    it has its own struct (to avoid struct api_msg getting bigger than necessary).
-    do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
-    (see netconn_gethostbyname). */
-struct dns_api_msg {
-  /** Hostname to query or dotted IP address string */
-  const char *name;
-  /** Rhe resolved address is stored here */
-  struct ip_addr *addr;
-  /** This semaphore is posted when the name is resolved, the application thread
-      should wait on it. */
-  sys_sem_t sem;
-  /** Errors are given back here */
-  err_t *err;
-};
-#endif /* LWIP_DNS */
-
-void do_newconn         ( struct api_msg_msg *msg);
-void do_delconn         ( struct api_msg_msg *msg);
-void do_bind            ( struct api_msg_msg *msg);
-void do_connect         ( struct api_msg_msg *msg);
-void do_disconnect      ( struct api_msg_msg *msg);
-void do_listen          ( struct api_msg_msg *msg);
-void do_send            ( struct api_msg_msg *msg);
-void do_recv            ( struct api_msg_msg *msg);
-void do_write           ( struct api_msg_msg *msg);
-void do_getaddr         ( struct api_msg_msg *msg);
-void do_close           ( struct api_msg_msg *msg);
-#if LWIP_IGMP
-void do_join_leave_group( struct api_msg_msg *msg);
-#endif /* LWIP_IGMP */
-
-#if LWIP_DNS
-void do_gethostbyname(void *arg);
-#endif /* LWIP_DNS */
-
-struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
-void netconn_free(struct netconn *conn);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_NETCONN */
-
-#endif /* __LWIP_API_MSG_H__ */
diff --git a/palacios/src/lwip/include/lwip/debug.h b/palacios/src/lwip/include/lwip/debug.h
deleted file mode 100644 (file)
index 8070027..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_DEBUG_H__
-#define __LWIP_DEBUG_H__
-
-#include "lwip/arch.h"
-
-/** lower two bits indicate debug level
- * - 0 off
- * - 1 warning
- * - 2 serious
- * - 3 severe
- */
-#define LWIP_DBG_LEVEL_OFF     0x00
-#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
-#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
-#define LWIP_DBG_LEVEL_SEVERE  0x03
-#define LWIP_DBG_MASK_LEVEL    0x03
-
-/** flag for LWIP_DEBUGF to enable that debug message */
-#define LWIP_DBG_ON            0x80U
-/** flag for LWIP_DEBUGF to disable that debug message */
-#define LWIP_DBG_OFF           0x00U
-
-/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
-#define LWIP_DBG_TRACE         0x40U
-/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
-#define LWIP_DBG_STATE         0x20U
-/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
-#define LWIP_DBG_FRESH         0x10U
-/** flag for LWIP_DEBUGF to halt after printing this debug message */
-#define LWIP_DBG_HALT          0x08U
-
-#ifndef LWIP_NOASSERT
-#define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
-#else  /* LWIP_NOASSERT */
-#define LWIP_ASSERT(x,y) 
-#endif /* LWIP_NOASSERT */
-
-/** print "m" message only if "e" is true, and execute "h" expression */
-#ifndef LWIP_ERROR
-#define LWIP_ERROR(m,e,h) do { if (!(e)) { LWIP_PLATFORM_ASSERT(m); h;}} while(0)
-#endif /* LWIP_ERROR */
-
-#ifdef LWIP_DEBUG
-/** print debug message only if debug message type is enabled...
- *  AND is of correct type AND is at least LWIP_DBG_LEVEL
- */
-#define LWIP_DEBUGF(debug,x) do { \
-                               if ( \
-                                   ((debug) & LWIP_DBG_ON) && \
-                                   ((debug) & LWIP_DBG_TYPES_ON) && \
-                                   ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
-                                 LWIP_PLATFORM_DIAG(x); \
-                                 if ((debug) & LWIP_DBG_HALT) { \
-                                   while(1); \
-                                 } \
-                               } \
-                             } while(0)
-
-#else  /* LWIP_DEBUG */
-#define LWIP_DEBUGF(debug,x) 
-#endif /* LWIP_DEBUG */
-
-#endif /* __LWIP_DEBUG_H__ */
-
diff --git a/palacios/src/lwip/include/lwip/dhcp.h b/palacios/src/lwip/include/lwip/dhcp.h
deleted file mode 100644 (file)
index 400f81f..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/** @file
- */
-
-#ifndef __LWIP_DHCP_H__
-#define __LWIP_DHCP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/netif.h"
-#include "lwip/udp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** period (in seconds) of the application calling dhcp_coarse_tmr() */
-#define DHCP_COARSE_TIMER_SECS 60 
-/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */
-#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS*1000)
-/** period (in milliseconds) of the application calling dhcp_fine_tmr() */
-#define DHCP_FINE_TIMER_MSECS 500 
-
-struct dhcp
-{
-  /** current DHCP state machine state */
-  u8_t state;
-  /** retries of current request */
-  u8_t tries;
-  /** transaction identifier of last sent request */ 
-  u32_t xid;
-  /** our connection to the DHCP server */ 
-  struct udp_pcb *pcb;
-  /** (first) pbuf of incoming msg */
-  struct pbuf *p;
-  /** incoming msg */
-  struct dhcp_msg *msg_in;
-  /** incoming msg options */
-  struct dhcp_msg *options_in; 
-  /** ingoing msg options length */
-  u16_t options_in_len;
-
-  struct pbuf *p_out; /* pbuf of outcoming msg */
-  struct dhcp_msg *msg_out; /* outgoing msg */
-  u16_t options_out_len; /* outgoing msg options length */
-  u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
-  u16_t t1_timeout;  /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
-  u16_t t2_timeout;  /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
-  struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */
-  struct ip_addr offered_ip_addr;
-  struct ip_addr offered_sn_mask;
-  struct ip_addr offered_gw_addr;
-  struct ip_addr offered_bc_addr;
-#define DHCP_MAX_DNS 2
-  u32_t dns_count; /* actual number of DNS servers obtained */
-  struct ip_addr offered_dns_addr[DHCP_MAX_DNS]; /* DNS server addresses */
-  u32_t offered_t0_lease; /* lease period (in seconds) */
-  u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
-  u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period)  */
-#if LWIP_DHCP_AUTOIP_COOP
-  u8_t autoip_coop_state;
-#endif
-/** Patch #1308
- *  TODO: See dhcp.c "TODO"s
- */
-#if 0
-  struct ip_addr offered_si_addr;
-  u8_t *boot_file_name;
-#endif
-};
-
-/* MUST be compiled with "pack structs" or equivalent! */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-/** minimum set of fields of any DHCP message */
-struct dhcp_msg
-{
-  PACK_STRUCT_FIELD(u8_t op);
-  PACK_STRUCT_FIELD(u8_t htype);
-  PACK_STRUCT_FIELD(u8_t hlen);
-  PACK_STRUCT_FIELD(u8_t hops);
-  PACK_STRUCT_FIELD(u32_t xid);
-  PACK_STRUCT_FIELD(u16_t secs);
-  PACK_STRUCT_FIELD(u16_t flags);
-  PACK_STRUCT_FIELD(struct ip_addr ciaddr);
-  PACK_STRUCT_FIELD(struct ip_addr yiaddr);
-  PACK_STRUCT_FIELD(struct ip_addr siaddr);
-  PACK_STRUCT_FIELD(struct ip_addr giaddr);
-#define DHCP_CHADDR_LEN 16U
-  PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]);
-#define DHCP_SNAME_LEN 64U
-  PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]);
-#define DHCP_FILE_LEN 128U
-  PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]);
-  PACK_STRUCT_FIELD(u32_t cookie);
-#define DHCP_MIN_OPTIONS_LEN 68U
-/** make sure user does not configure this too small */
-#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
-#  undef DHCP_OPTIONS_LEN
-#endif
-/** allow this to be configured in lwipopts.h, but not too small */
-#if (!defined(DHCP_OPTIONS_LEN))
-/** set this to be sufficient for your options in outgoing DHCP msgs */
-#  define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
-#endif
-  PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/** start DHCP configuration */
-err_t dhcp_start(struct netif *netif);
-/** enforce early lease renewal (not needed normally)*/
-err_t dhcp_renew(struct netif *netif);
-/** release the DHCP lease, usually called before dhcp_stop()*/
-err_t dhcp_release(struct netif *netif);
-/** stop DHCP configuration */
-void dhcp_stop(struct netif *netif);
-/** inform server of our manual IP address */
-void dhcp_inform(struct netif *netif);
-
-/** if enabled, check whether the offered IP address is not in use, using ARP */
-#if DHCP_DOES_ARP_CHECK
-void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr);
-#endif
-
-/** to be called every minute */
-void dhcp_coarse_tmr(void);
-/** to be called every half second */
-void dhcp_fine_tmr(void);
-/** DHCP message item offsets and length */
-#define DHCP_MSG_OFS (UDP_DATA_OFS)  
-  #define DHCP_OP_OFS (DHCP_MSG_OFS + 0)
-  #define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1)
-  #define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2)
-  #define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3)
-  #define DHCP_XID_OFS (DHCP_MSG_OFS + 4)
-  #define DHCP_SECS_OFS (DHCP_MSG_OFS + 8)
-  #define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10)
-  #define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12)
-  #define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16)
-  #define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20)
-  #define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24)
-  #define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28)
-  #define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44)
-  #define DHCP_FILE_OFS (DHCP_MSG_OFS + 108)
-#define DHCP_MSG_LEN 236
-
-#define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
-#define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
-
-#define DHCP_CLIENT_PORT 68  
-#define DHCP_SERVER_PORT 67
-
-/** DHCP client states */
-#define DHCP_REQUESTING 1
-#define DHCP_INIT 2
-#define DHCP_REBOOTING 3
-#define DHCP_REBINDING 4
-#define DHCP_RENEWING 5
-#define DHCP_SELECTING 6
-#define DHCP_INFORMING 7
-#define DHCP_CHECKING 8
-#define DHCP_PERMANENT 9
-#define DHCP_BOUND 10
-/** not yet implemented #define DHCP_RELEASING 11 */
-#define DHCP_BACKING_OFF 12
-#define DHCP_OFF 13
-
-/** AUTOIP cooperatation flags */
-#define DHCP_AUTOIP_COOP_STATE_OFF 0
-#define DHCP_AUTOIP_COOP_STATE_ON 1
-#define DHCP_BOOTREQUEST 1
-#define DHCP_BOOTREPLY 2
-
-#define DHCP_DISCOVER 1
-#define DHCP_OFFER 2
-#define DHCP_REQUEST 3
-#define DHCP_DECLINE 4
-#define DHCP_ACK 5
-#define DHCP_NAK 6
-#define DHCP_RELEASE 7
-#define DHCP_INFORM 8
-
-#define DHCP_HTYPE_ETH 1
-
-#define DHCP_HLEN_ETH 6
-
-#define DHCP_BROADCAST_FLAG 15
-#define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST)
-
-/** BootP options */
-#define DHCP_OPTION_PAD 0
-#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */
-#define DHCP_OPTION_ROUTER 3
-#define DHCP_OPTION_DNS_SERVER 6 
-#define DHCP_OPTION_HOSTNAME 12
-#define DHCP_OPTION_IP_TTL 23
-#define DHCP_OPTION_MTU 26
-#define DHCP_OPTION_BROADCAST 28
-#define DHCP_OPTION_TCP_TTL 37
-#define DHCP_OPTION_END 255
-
-/** DHCP options */
-#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */
-#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */
-#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */
-
-#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */
-#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
-
-
-#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */
-#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */
-
-#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */
-#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
-
-#define DHCP_OPTION_T1 58 /* T1 renewal time */
-#define DHCP_OPTION_T2 59 /* T2 rebinding time */
-#define DHCP_OPTION_US 60
-#define DHCP_OPTION_CLIENT_ID 61
-#define DHCP_OPTION_TFTP_SERVERNAME 66
-#define DHCP_OPTION_BOOTFILE 67
-
-/** possible combinations of overloading the file and sname fields with options */
-#define DHCP_OVERLOAD_NONE 0
-#define DHCP_OVERLOAD_FILE 1
-#define DHCP_OVERLOAD_SNAME  2
-#define DHCP_OVERLOAD_SNAME_FILE 3
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_DHCP */
-
-#endif /*__LWIP_DHCP_H__*/
diff --git a/palacios/src/lwip/include/lwip/dns.h b/palacios/src/lwip/include/lwip/dns.h
deleted file mode 100644 (file)
index 6196742..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * lwip DNS resolver header file.
-
- * Author: Jim Pettinato 
- *   April 2007
-
- * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __LWIP_DNS_H__
-#define __LWIP_DNS_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
-
-/** DNS timer period */
-#define DNS_TMR_INTERVAL          1000
-
-/** DNS field TYPE used for "Resource Records" */
-#define DNS_RRTYPE_A              1     /* a host address */
-#define DNS_RRTYPE_NS             2     /* an authoritative name server */
-#define DNS_RRTYPE_MD             3     /* a mail destination (Obsolete - use MX) */
-#define DNS_RRTYPE_MF             4     /* a mail forwarder (Obsolete - use MX) */
-#define DNS_RRTYPE_CNAME          5     /* the canonical name for an alias */
-#define DNS_RRTYPE_SOA            6     /* marks the start of a zone of authority */
-#define DNS_RRTYPE_MB             7     /* a mailbox domain name (EXPERIMENTAL) */
-#define DNS_RRTYPE_MG             8     /* a mail group member (EXPERIMENTAL) */
-#define DNS_RRTYPE_MR             9     /* a mail rename domain name (EXPERIMENTAL) */
-#define DNS_RRTYPE_NULL           10    /* a null RR (EXPERIMENTAL) */
-#define DNS_RRTYPE_WKS            11    /* a well known service description */
-#define DNS_RRTYPE_PTR            12    /* a domain name pointer */
-#define DNS_RRTYPE_HINFO          13    /* host information */
-#define DNS_RRTYPE_MINFO          14    /* mailbox or mail list information */
-#define DNS_RRTYPE_MX             15    /* mail exchange */
-#define DNS_RRTYPE_TXT            16    /* text strings */
-
-/** DNS field CLASS used for "Resource Records" */
-#define DNS_RRCLASS_IN            1     /* the Internet */
-#define DNS_RRCLASS_CS            2     /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
-#define DNS_RRCLASS_CH            3     /* the CHAOS class */
-#define DNS_RRCLASS_HS            4     /* Hesiod [Dyer 87] */
-#define DNS_RRCLASS_FLUSH         0x800 /* Flush bit */
-
-/** Callback which is invoked when a hostname is found.
- * A function of this type must be implemented by the application using the DNS resolver.
- * @param name pointer to the name that was looked up.
- * @param ipaddr pointer to a struct ip_addr containing the IP address of the hostname,
- *        or NULL if the name could not be found (or on any other error).
- * @param callback_arg a user-specified callback argument passed to dns_gethostbyname
-*/
-typedef void (*dns_found_callback)(const char *name, struct ip_addr *ipaddr, void *callback_arg);
-
-
-void           dns_init(void);
-
-void           dns_tmr(void);
-
-void           dns_setserver(u8_t numdns, struct ip_addr *dnsserver);
-
-struct ip_addr dns_getserver(u8_t numdns);
-
-err_t          dns_gethostbyname(const char *hostname, struct ip_addr *addr,
-                                 dns_found_callback found, void *callback_arg);
-
-#endif /* LWIP_DNS */
-
-#endif /* __LWIP_DNS_H__ */
diff --git a/palacios/src/lwip/include/lwip/init.h b/palacios/src/lwip/include/lwip/init.h
deleted file mode 100644 (file)
index c0869cf..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_INIT_H__
-#define __LWIP_INIT_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Modules initialization */
-void lwip_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_INIT_H__ */
diff --git a/palacios/src/lwip/include/lwip/mem.h b/palacios/src/lwip/include/lwip/mem.h
deleted file mode 100644 (file)
index cf91733..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_MEM_H__
-#define __LWIP_MEM_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if MEM_LIBC_MALLOC
-
-#include <stddef.h> /* for size_t */
-
-typedef size_t mem_size_t;
-
-/* aliases for C library malloc() */
-#define mem_init()
-/* in case C library malloc() needs extra protection,
- * allow these defines to be overridden.
- */
-#ifndef mem_free
-#define mem_free(x) free(x)
-#endif
-#ifndef mem_malloc
-#define mem_malloc(x) malloc(x)
-#endif
-#ifndef mem_calloc
-#define mem_calloc(x, y) calloc(x, y)
-#endif
-#ifndef mem_realloc
-#define mem_realloc(x, size) (x)
-#endif
-#else /* MEM_LIBC_MALLOC */
-
-/* MEM_SIZE would have to be aligned, but using 64000 here instead of
- * 65535 leaves some room for alignment...
- */
-#if MEM_SIZE > 64000l
-typedef u32_t mem_size_t;
-#else
-typedef u16_t mem_size_t;
-#endif /* MEM_SIZE > 64000 */
-
-#if MEM_USE_POOLS
-/** mem_init is not used when using pools instead of a heap */
-#define mem_init()
-/** mem_realloc is not used when using pools instead of a heap:
-    we can't free part of a pool element and don't want to copy the rest */
-#define mem_realloc(mem, size) (mem)
-#else /* MEM_USE_POOLS */
-/* lwIP alternative malloc */
-void  mem_init(void);
-void *mem_realloc(void *mem, mem_size_t size);
-#endif /* MEM_USE_POOLS */
-void *mem_malloc(mem_size_t size);
-void *mem_calloc(mem_size_t count, mem_size_t size);
-void  mem_free(void *mem);
-#endif /* MEM_LIBC_MALLOC */
-
-#ifndef LWIP_MEM_ALIGN_SIZE
-#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
-#endif
-
-#ifndef LWIP_MEM_ALIGN
-#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_MEM_H__ */
diff --git a/palacios/src/lwip/include/lwip/memp.h b/palacios/src/lwip/include/lwip/memp.h
deleted file mode 100644 (file)
index a043863..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-
-#ifndef __LWIP_MEMP_H__
-#define __LWIP_MEMP_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
-typedef enum {
-#define LWIP_MEMPOOL(name,num,size,desc)  MEMP_##name,
-#include "lwip/memp_std.h"
-  MEMP_MAX
-} memp_t;
-
-#if MEM_USE_POOLS
-/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
-typedef enum {
-    /* Get the first (via:
-       MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
-    MEMP_POOL_HELPER_FIRST = ((u8_t)
-#define LWIP_MEMPOOL(name,num,size,desc)
-#define LWIP_MALLOC_MEMPOOL_START 1
-#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
-#define LWIP_MALLOC_MEMPOOL_END
-#include "lwip/memp_std.h"
-    ) ,
-    /* Get the last (via:
-       MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
-    MEMP_POOL_HELPER_LAST = ((u8_t)
-#define LWIP_MEMPOOL(name,num,size,desc)
-#define LWIP_MALLOC_MEMPOOL_START
-#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
-#define LWIP_MALLOC_MEMPOOL_END 1
-#include "lwip/memp_std.h"
-    )
-} memp_pool_helper_t;
-
-/* The actual start and stop values are here (cast them over)
-   We use this helper type and these defines so we can avoid using const memp_t values */
-#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
-#define MEMP_POOL_LAST   ((memp_t) MEMP_POOL_HELPER_LAST)
-
-extern const u16_t memp_sizes[MEMP_MAX];
-#endif /* MEM_USE_POOLS */
-
-void  memp_init(void);
-
-#if MEMP_OVERFLOW_CHECK
-void *memp_malloc_fn(memp_t type, const char* file, const int line);
-#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
-#else
-void *memp_malloc(memp_t type);
-#endif
-void  memp_free(memp_t type, void *mem);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_MEMP_H__ */
diff --git a/palacios/src/lwip/include/lwip/memp_std.h b/palacios/src/lwip/include/lwip/memp_std.h
deleted file mode 100644 (file)
index c314bf8..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SETUP: Make sure we define everything we will need.
- *
- * We have create three types of pools:
- *   1) MEMPOOL - standard pools
- *   2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
- *   3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
- *
- * If the include'r doesn't require any special treatment of each of the types
- * above, then will declare #2 & #3 to be just standard mempools.
- */
-#ifndef LWIP_MALLOC_MEMPOOL
-/* This treats "malloc pools" just like any other pool */
-#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, size, "MALLOC_"#size)
-#define LWIP_MALLOC_MEMPOOL_START
-#define LWIP_MALLOC_MEMPOOL_END
-#endif /* LWIP_MALLOC_MEMPOOL */ 
-
-#ifndef LWIP_PBUF_MEMPOOL
-/* This treats "pbuf pools" just like any other pool.
- * Allocates buffers for a pbuf struct AND a payload size */
-#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
-#endif /* LWIP_PBUF_MEMPOOL */
-
-
-/*
- * A list of internal pools used by LWIP.
- *
- * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
- *     creates a pool name MEMP_pool_name. description is used in stats.c
- */
-#if LWIP_RAW
-LWIP_MEMPOOL(RAW_PCB,        MEMP_NUM_RAW_PCB,         sizeof(struct raw_pcb),        "RAW_PCB")
-#endif /* LWIP_RAW */
-
-#if LWIP_UDP
-LWIP_MEMPOOL(UDP_PCB,        MEMP_NUM_UDP_PCB,         sizeof(struct udp_pcb),        "UDP_PCB")
-#endif /* LWIP_UDP */
-
-#if LWIP_TCP
-LWIP_MEMPOOL(TCP_PCB,        MEMP_NUM_TCP_PCB,         sizeof(struct tcp_pcb),        "TCP_PCB")
-LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN,  sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
-LWIP_MEMPOOL(TCP_SEG,        MEMP_NUM_TCP_SEG,         sizeof(struct tcp_seg),        "TCP_SEG")
-#endif /* LWIP_TCP */
-
-#if IP_REASSEMBLY
-LWIP_MEMPOOL(REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip_reassdata),   "REASSDATA")
-#endif /* IP_REASSEMBLY */
-
-#if LWIP_NETCONN
-LWIP_MEMPOOL(NETBUF,         MEMP_NUM_NETBUF,          sizeof(struct netbuf),         "NETBUF")
-LWIP_MEMPOOL(NETCONN,        MEMP_NUM_NETCONN,         sizeof(struct netconn),        "NETCONN")
-#endif /* LWIP_NETCONN */
-
-#if NO_SYS==0
-LWIP_MEMPOOL(TCPIP_MSG_API,  MEMP_NUM_TCPIP_MSG_API,   sizeof(struct tcpip_msg),      "TCPIP_MSG_API")
-LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),      "TCPIP_MSG_INPKT")
-#endif /* NO_SYS==0 */
-
-#if ARP_QUEUEING
-LWIP_MEMPOOL(ARP_QUEUE,      MEMP_NUM_ARP_QUEUE,       sizeof(struct etharp_q_entry), "ARP_QUEUE")
-#endif /* ARP_QUEUEING */
-
-#if LWIP_IGMP
-LWIP_MEMPOOL(IGMP_GROUP,     MEMP_NUM_IGMP_GROUP,      sizeof(struct igmp_group),     "IGMP_GROUP")
-#endif /* LWIP_IGMP */
-
-#if NO_SYS==0
-LWIP_MEMPOOL(SYS_TIMEOUT,    MEMP_NUM_SYS_TIMEOUT,     sizeof(struct sys_timeo),      "SYS_TIMEOUT")
-#endif /* NO_SYS==0 */
-
-
-/*
- * A list of pools of pbuf's used by LWIP.
- *
- * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
- *     creates a pool name MEMP_pool_name. description is used in stats.c
- *     This allocates enough space for the pbuf struct and a payload.
- *     (Example: pbuf_payload_size=0 allocates only size for the struct)
- */
-LWIP_PBUF_MEMPOOL(PBUF,      MEMP_NUM_PBUF,            0,                             "PBUF_REF/ROM")
-LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE,           PBUF_POOL_BUFSIZE,             "PBUF_POOL")
-
-
-/*
- * Allow for user-defined pools; this must be explicitly set in lwipopts.h
- * since the default is to NOT look for lwippools.h
- */
-#if MEMP_USE_CUSTOM_POOLS
-#include "lwippools.h"
-#endif /* MEMP_USE_CUSTOM_POOLS */
-
-/*
- * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
- * (#undef is ignored for something that is not defined)
- */
-#undef LWIP_MEMPOOL
-#undef LWIP_MALLOC_MEMPOOL
-#undef LWIP_MALLOC_MEMPOOL_START
-#undef LWIP_MALLOC_MEMPOOL_END
-#undef LWIP_PBUF_MEMPOOL
diff --git a/palacios/src/lwip/include/lwip/netbuf.h b/palacios/src/lwip/include/lwip/netbuf.h
deleted file mode 100644 (file)
index f6de3a4..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_NETBUF_H__
-#define __LWIP_NETBUF_H__
-
-#include "lwip/opt.h"
-#include "lwip/pbuf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct netbuf {
-  struct pbuf *p, *ptr;
-  struct ip_addr *addr;
-  u16_t port;
-};
-
-/* Network buffer functions: */
-struct netbuf *   netbuf_new      (void);
-void              netbuf_delete   (struct netbuf *buf);
-void *            netbuf_alloc    (struct netbuf *buf, u16_t size);
-void              netbuf_free     (struct netbuf *buf);
-err_t             netbuf_ref      (struct netbuf *buf,
-           const void *dataptr, u16_t size);
-void              netbuf_chain    (struct netbuf *head,
-           struct netbuf *tail);
-
-u16_t             netbuf_len      (struct netbuf *buf);
-err_t             netbuf_data     (struct netbuf *buf,
-           void **dataptr, u16_t *len);
-s8_t              netbuf_next     (struct netbuf *buf);
-void              netbuf_first    (struct netbuf *buf);
-
-
-#define netbuf_copy_partial(buf, dataptr, len, offset) \
-  pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
-#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
-#define netbuf_len(buf)              ((buf)->p->tot_len)
-#define netbuf_fromaddr(buf)         ((buf)->addr)
-#define netbuf_fromport(buf)         ((buf)->port)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_NETBUF_H__ */
diff --git a/palacios/src/lwip/include/lwip/netdb.h b/palacios/src/lwip/include/lwip/netdb.h
deleted file mode 100644 (file)
index ce175ce..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Simon Goldschmidt
- *
- */
-
-#include "lwip/opt.h"
-
-#if LWIP_DNS && LWIP_SOCKET
-
-#include "lwip/sockets.h"
-
-/* some rarely used options */
-#ifndef LWIP_DNS_API_DECLARE_H_ERRNO
-#define LWIP_DNS_API_DECLARE_H_ERRNO 1
-#endif
-
-#ifndef LWIP_DNS_API_DEFINE_ERRORS
-#define LWIP_DNS_API_DEFINE_ERRORS 1
-#endif
-
-#ifndef LWIP_DNS_API_DECLARE_STRUCTS
-#define LWIP_DNS_API_DECLARE_STRUCTS 1
-#endif
-
-#if LWIP_DNS_API_DEFINE_ERRORS
-/** Errors used by the DNS API functions, h_errno can be one of them */
-#define EAI_NONAME      200
-#define EAI_SERVICE     201
-#define EAI_FAIL        202
-#define EAI_MEMORY      203
-
-#define HOST_NOT_FOUND  210
-#define NO_DATA         211
-#define NO_RECOVERY     212
-#define TRY_AGAIN       213
-#endif /* LWIP_DNS_API_DEFINE_ERRORS */
-
-#if LWIP_DNS_API_DECLARE_STRUCTS
-struct hostent {
-    char  *h_name;      /* Official name of the host. */
-    char **h_aliases;   /* A pointer to an array of pointers to alternative host names,
-                           terminated by a null pointer. */
-    int    h_addrtype;  /* Address type. */
-    int    h_length;    /* The length, in bytes, of the address. */
-    char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
-                           network byte order) for the host, terminated by a null pointer. */
-#define h_addr h_addr_list[0] /* for backward compatibility */
-};
-
-struct addrinfo {
-    int               ai_flags;      /* Input flags. */
-    int               ai_family;     /* Address family of socket. */
-    int               ai_socktype;   /* Socket type. */
-    int               ai_protocol;   /* Protocol of socket. */
-    socklen_t         ai_addrlen;    /* Length of socket address. */
-    struct sockaddr  *ai_addr;       /* Socket address of socket. */
-    char             *ai_canonname;  /* Canonical name of service location. */
-    struct addrinfo  *ai_next;       /* Pointer to next in list. */
-};
-#endif /* LWIP_DNS_API_DECLARE_STRUCTS */
-
-#if LWIP_DNS_API_DECLARE_H_ERRNO
-/* application accessable error code set by the DNS API functions */
-extern int h_errno;
-#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
-
-struct hostent *lwip_gethostbyname(const char *name);
-int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
-                size_t buflen, struct hostent **result, int *h_errnop);
-void lwip_freeaddrinfo(struct addrinfo *ai);
-int lwip_getaddrinfo(const char *nodename,
-       const char *servname,
-       const struct addrinfo *hints,
-       struct addrinfo **res);
-
-#if LWIP_COMPAT_SOCKETS
-#define gethostbyname(name) lwip_gethostbyname(name)
-#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
-       lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
-#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(a)
-#define getaddrinfo(nodname, servname, hints, res) \
-       lwip_getaddrinfo(nodname, servname, hints, res)
-#endif /* LWIP_COMPAT_SOCKETS */
-
-#endif /* LWIP_DNS && LWIP_SOCKET */
diff --git a/palacios/src/lwip/include/lwip/netif.h b/palacios/src/lwip/include/lwip/netif.h
deleted file mode 100644 (file)
index 19c3808..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_NETIF_H__
-#define __LWIP_NETIF_H__
-
-#include "lwip/opt.h"
-
-#include "lwip/err.h"
-
-#include "lwip/ip_addr.h"
-
-#include "lwip/inet.h"
-#include "lwip/pbuf.h"
-#if LWIP_DHCP
-struct dhcp;
-#endif
-#if LWIP_AUTOIP
-struct autoip;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Throughout this file, IP addresses are expected to be in
- * the same byte order as in IP_PCB. */
-
-/** must be the maximum of all used hardware address lengths
-    across all types of interfaces in use */
-#define NETIF_MAX_HWADDR_LEN 6U
-
-/** TODO: define the use (where, when, whom) of netif flags */
-
-/** whether the network interface is 'up'. this is
- * a software flag used to control whether this network
- * interface is enabled and processes traffic.
- */
-#define NETIF_FLAG_UP           0x01U
-/** if set, the netif has broadcast capability */
-#define NETIF_FLAG_BROADCAST    0x02U
-/** if set, the netif is one end of a point-to-point connection */
-#define NETIF_FLAG_POINTTOPOINT 0x04U
-/** if set, the interface is configured using DHCP */
-#define NETIF_FLAG_DHCP         0x08U
-/** if set, the interface has an active link
- *  (set by the network interface driver) */
-#define NETIF_FLAG_LINK_UP      0x10U
-/** if set, the netif is an device using ARP */
-#define NETIF_FLAG_ETHARP       0x20U
-/** if set, the netif has IGMP capability */
-#define NETIF_FLAG_IGMP         0x40U
-
-/** Generic data structure used for all lwIP network interfaces.
- *  The following fields should be filled in by the initialization
- *  function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
-
-struct netif {
-  /** pointer to next in linked list */
-  struct netif *next;
-
-  /** IP address configuration in network byte order */
-  struct ip_addr ip_addr;
-  struct ip_addr netmask;
-  struct ip_addr gw;
-
-  /** This function is called by the network device driver
-   *  to pass a packet up the TCP/IP stack. */
-  err_t (* input)(struct pbuf *p, struct netif *inp);
-  /** This function is called by the IP module when it wants
-   *  to send a packet on the interface. This function typically
-   *  first resolves the hardware address, then sends the packet. */
-  err_t (* output)(struct netif *netif, struct pbuf *p,
-       struct ip_addr *ipaddr);
-  /** This function is called by the ARP module when it wants
-   *  to send a packet on the interface. This function outputs
-   *  the pbuf as-is on the link medium. */
-  err_t (* linkoutput)(struct netif *netif, struct pbuf *p);
-#if LWIP_NETIF_STATUS_CALLBACK
-  /** This function is called when the netif state is set to up or down
-   */
-  void (* status_callback)(struct netif *netif);
-#endif /* LWIP_NETIF_STATUS_CALLBACK */
-#if LWIP_NETIF_LINK_CALLBACK
-  /** This function is called when the netif link is set to up or down
-   */
-  void (* link_callback)(struct netif *netif);
-#endif /* LWIP_NETIF_LINK_CALLBACK */
-  /** This field can be set by the device driver and could point
-   *  to state information for the device. */
-  void *state;
-#if LWIP_DHCP
-  /** the DHCP client state information for this netif */
-  struct dhcp *dhcp;
-#endif /* LWIP_DHCP */
-#if LWIP_AUTOIP
-  /** the AutoIP client state information for this netif */
-  struct autoip *autoip;
-#endif
-#if LWIP_NETIF_HOSTNAME
-  /* the hostname for this netif, NULL is a valid value */
-  char*  hostname;
-#endif /* LWIP_NETIF_HOSTNAME */
-  /** number of bytes used in hwaddr */
-  u8_t hwaddr_len;
-  /** link level hardware address of this interface */
-  u8_t hwaddr[NETIF_MAX_HWADDR_LEN];
-  /** maximum transfer unit (in bytes) */
-  u16_t mtu;
-  /** flags (see NETIF_FLAG_ above) */
-  u8_t flags;
-  /** descriptive abbreviation */
-  char name[2];
-  /** number of this interface */
-  u8_t num;
-#if LWIP_SNMP
-  /** link type (from "snmp_ifType" enum from snmp.h) */
-  u8_t link_type;
-  /** (estimate) link speed */
-  u32_t link_speed;
-  /** timestamp at last change made (up/down) */
-  u32_t ts;
-  /** counters */
-  u32_t ifinoctets;
-  u32_t ifinucastpkts;
-  u32_t ifinnucastpkts;
-  u32_t ifindiscards;
-  u32_t ifoutoctets;
-  u32_t ifoutucastpkts;
-  u32_t ifoutnucastpkts;
-  u32_t ifoutdiscards;
-#endif /* LWIP_SNMP */
-#if LWIP_IGMP
-  /* This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/
-  err_t (*igmp_mac_filter)( struct netif *netif, struct ip_addr *group, u8_t action);
-#endif /* LWIP_IGMP */
-#if LWIP_NETIF_HWADDRHINT
-  u8_t *addr_hint;
-#endif /* LWIP_NETIF_HWADDRHINT */
-};
-
-#if LWIP_SNMP
-#define NETIF_INIT_SNMP(netif, type, speed) \
-  /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \
-  netif->link_type = type;    \
-  /* your link speed here (units: bits per second) */  \
-  netif->link_speed = speed;  \
-  netif->ts = 0;              \
-  netif->ifinoctets = 0;      \
-  netif->ifinucastpkts = 0;   \
-  netif->ifinnucastpkts = 0;  \
-  netif->ifindiscards = 0;    \
-  netif->ifoutoctets = 0;     \
-  netif->ifoutucastpkts = 0;  \
-  netif->ifoutnucastpkts = 0; \
-  netif->ifoutdiscards = 0
-#else /* LWIP_SNMP */
-#define NETIF_INIT_SNMP(netif, type, speed)
-#endif /* LWIP_SNMP */
-
-
-/** The list of network interfaces. */
-extern struct netif *netif_list;
-/** The default network interface. */
-extern struct netif *netif_default;
-
-#define netif_init() /* Compatibility define, not init needed. */
-
-struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
-      struct ip_addr *gw,
-      void *state,
-      err_t (* init)(struct netif *netif),
-      err_t (* input)(struct pbuf *p, struct netif *netif));
-
-void
-netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
-    struct ip_addr *gw);
-void netif_remove(struct netif * netif);
-
-/* Returns a network interface given its name. The name is of the form
-   "et0", where the first two letters are the "name" field in the
-   netif structure, and the digit is in the num field in the same
-   structure. */
-struct netif *netif_find(char *name);
-
-void netif_set_default(struct netif *netif);
-
-void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr);
-void netif_set_netmask(struct netif *netif, struct ip_addr *netmask);
-void netif_set_gw(struct netif *netif, struct ip_addr *gw);
-
-void netif_set_up(struct netif *netif);
-void netif_set_down(struct netif *netif);
-u8_t netif_is_up(struct netif *netif);
-
-#if LWIP_NETIF_STATUS_CALLBACK
-/*
- * Set callback to be called when interface is brought up/down
- */
-void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif));
-#endif /* LWIP_NETIF_STATUS_CALLBACK */
-
-#if LWIP_NETIF_LINK_CALLBACK
-void netif_set_link_up(struct netif *netif);
-void netif_set_link_down(struct netif *netif);
-u8_t netif_is_link_up(struct netif *netif);
-/*
- * Set callback to be called when link is brought up/down
- */
-void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif));
-#endif /* LWIP_NETIF_LINK_CALLBACK */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_NETIF_H__ */
diff --git a/palacios/src/lwip/include/lwip/netifapi.h b/palacios/src/lwip/include/lwip/netifapi.h
deleted file mode 100644 (file)
index 36c6bd0..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- */
-#ifndef __LWIP_NETIFAPI_H__
-#define __LWIP_NETIFAPI_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/sys.h"
-#include "lwip/netif.h"
-#include "lwip/dhcp.h"
-#include "lwip/autoip.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct netifapi_msg_msg {
-#if !LWIP_TCPIP_CORE_LOCKING
-  sys_sem_t sem;
-#endif /* !LWIP_TCPIP_CORE_LOCKING */
-  err_t err;
-  struct netif *netif;
-  union {
-    struct {
-      struct ip_addr *ipaddr;
-      struct ip_addr *netmask;
-      struct ip_addr *gw;
-      void *state;
-      err_t (* init) (struct netif *netif);
-      err_t (* input)(struct pbuf *p, struct netif *netif);
-    } add;
-    struct {
-      void  (* voidfunc)(struct netif *netif);
-      err_t (* errtfunc)(struct netif *netif);
-    } common;
-  } msg;
-};
-
-struct netifapi_msg {
-  void (* function)(struct netifapi_msg_msg *msg);
-  struct netifapi_msg_msg msg;
-};
-
-
-/* API for application */
-err_t netifapi_netif_add       ( struct netif *netif,
-                                 struct ip_addr *ipaddr,
-                                 struct ip_addr *netmask,
-                                 struct ip_addr *gw,
-                                 void *state,
-                                 err_t (* init)(struct netif *netif),
-                                 err_t (* input)(struct pbuf *p, struct netif *netif) );
-
-err_t netifapi_netif_common    ( struct netif *netif,
-                                 void  (* voidfunc)(struct netif *netif),
-                                 err_t (* errtfunc)(struct netif *netif) );
-
-#define netifapi_netif_remove(n)      netifapi_netif_common(n, netif_remove, NULL)
-#define netifapi_netif_set_up(n)      netifapi_netif_common(n, netif_set_up, NULL)
-#define netifapi_netif_set_down(n)    netifapi_netif_common(n, netif_set_down, NULL)
-#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
-#define netifapi_dhcp_start(n)        netifapi_netif_common(n, NULL, dhcp_start)
-#define netifapi_dhcp_stop(n)         netifapi_netif_common(n, dhcp_stop, NULL)
-#define netifapi_autoip_start(n)      netifapi_netif_common(n, NULL, autoip_start)
-#define netifapi_autoip_stop(n)       netifapi_netif_common(n, NULL, autoip_stop)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_NETIF_API */
-
-#endif /* __LWIP_NETIFAPI_H__ */
diff --git a/palacios/src/lwip/include/lwip/opt.h b/palacios/src/lwip/include/lwip/opt.h
deleted file mode 100644 (file)
index c980e44..0000000
+++ /dev/null
@@ -1,1654 +0,0 @@
-/**
- * @file
- *
- * lwIP Options Configuration
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_OPT_H__
-#define __LWIP_OPT_H__
-
-/*
- * Include user defined options first. Anything not defined in these files
- * will be set to standard values. Override anything you dont like!
- */
-#include "lwipopts.h"
-#include "lwip/debug.h"
-
-/*
-   -----------------------------------------------
-   ---------- Platform specific locking ----------
-   -----------------------------------------------
-*/
-
-/**
- * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
- * critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#ifndef SYS_LIGHTWEIGHT_PROT
-#define SYS_LIGHTWEIGHT_PROT            0
-#endif
-
-/** 
- * NO_SYS==1: Provides VERY minimal functionality. Otherwise,
- * use lwIP facilities.
- */
-#ifndef NO_SYS
-#define NO_SYS                          0
-#endif
-
-/**
- * MEMCPY: override this if you have a faster implementation at hand than the
- * one included in your C library
- */
-#ifndef MEMCPY
-#define MEMCPY(dst,src,len)             memcpy(dst,src,len)
-#endif
-
-/**
- * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a
- * call to memcpy() if the length is known at compile time and is small.
- */
-#ifndef SMEMCPY
-#define SMEMCPY(dst,src,len)            memcpy(dst,src,len)
-#endif
-
-/*
-   ------------------------------------
-   ---------- Memory options ----------
-   ------------------------------------
-*/
-/**
- * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library
- * instead of the lwip internal allocator. Can save code size if you
- * already use it.
- */
-#ifndef MEM_LIBC_MALLOC
-#define MEM_LIBC_MALLOC                 0
-#endif
-
-/**
- * MEM_ALIGNMENT: should be set to the alignment of the CPU
- *    4 byte alignment -> #define MEM_ALIGNMENT 4
- *    2 byte alignment -> #define MEM_ALIGNMENT 2
- */
-#ifndef MEM_ALIGNMENT
-#define MEM_ALIGNMENT                   1
-#endif
-
-/**
- * MEM_SIZE: the size of the heap memory. If the application will send
- * a lot of data that needs to be copied, this should be set high.
- */
-#ifndef MEM_SIZE
-#define MEM_SIZE                        1600
-#endif
-
-/**
- * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable
- * amount of bytes before and after each memp element in every pool and fills
- * it with a prominent default value.
- *    MEMP_OVERFLOW_CHECK == 0 no checking
- *    MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed
- *    MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time
- *      memp_malloc() or memp_free() is called (useful but slow!)
- */
-#ifndef MEMP_OVERFLOW_CHECK
-#define MEMP_OVERFLOW_CHECK             0
-#endif
-
-/**
- * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make
- * sure that there are no cycles in the linked lists.
- */
-#ifndef MEMP_SANITY_CHECK
-#define MEMP_SANITY_CHECK               0
-#endif
-
-/**
- * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set
- * of memory pools of various sizes. When mem_malloc is called, an element of
- * the smallest pool that can provide the lenght needed is returned.
- */
-#ifndef MEM_USE_POOLS
-#define MEM_USE_POOLS                   0
-#endif
-
-/**
- * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h
- * that defines additional pools beyond the "standard" ones required
- * by lwIP. If you set this to 1, you must have lwippools.h in your 
- * inlude path somewhere. 
- */
-#ifndef MEMP_USE_CUSTOM_POOLS
-#define MEMP_USE_CUSTOM_POOLS           0
-#endif
-
-
-/*
-   ------------------------------------------------
-   ---------- Internal Memory Pool Sizes ----------
-   ------------------------------------------------
-*/
-/**
- * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
- * If the application sends a lot of data out of ROM (or other static memory),
- * this should be set high.
- */
-#ifndef MEMP_NUM_PBUF
-#define MEMP_NUM_PBUF                   16
-#endif
-
-/**
- * MEMP_NUM_RAW_PCB: Number of raw connection PCBs
- * (requires the LWIP_RAW option)
- */
-#ifndef MEMP_NUM_RAW_PCB
-#define MEMP_NUM_RAW_PCB                4
-#endif
-
-/**
- * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
- * per active UDP "connection".
- * (requires the LWIP_UDP option)
- */
-#ifndef MEMP_NUM_UDP_PCB
-#define MEMP_NUM_UDP_PCB                4
-#endif
-
-/**
- * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
- * (requires the LWIP_TCP option)
- */
-#ifndef MEMP_NUM_TCP_PCB
-#define MEMP_NUM_TCP_PCB                5
-#endif
-
-/**
- * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
- * (requires the LWIP_TCP option)
- */
-#ifndef MEMP_NUM_TCP_PCB_LISTEN
-#define MEMP_NUM_TCP_PCB_LISTEN         8
-#endif
-
-/**
- * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
- * (requires the LWIP_TCP option)
- */
-#ifndef MEMP_NUM_TCP_SEG
-#define MEMP_NUM_TCP_SEG                16
-#endif
-
-/**
- * MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
- * reassembly (whole packets, not fragments!)
- */
-#ifndef MEMP_NUM_REASSDATA
-#define MEMP_NUM_REASSDATA              5
-#endif
-
-/**
- * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing
- * packets (pbufs) that are waiting for an ARP request (to resolve
- * their destination address) to finish.
- * (requires the ARP_QUEUEING option)
- */
-#ifndef MEMP_NUM_ARP_QUEUE
-#define MEMP_NUM_ARP_QUEUE              30
-#endif
-
-/**
- * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces
- * can be members et the same time (one per netif - allsystems group -, plus one
- * per netif membership).
- * (requires the LWIP_IGMP option)
- */
-#ifndef MEMP_NUM_IGMP_GROUP
-#define MEMP_NUM_IGMP_GROUP             8
-#endif
-
-/**
- * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
- * (requires NO_SYS==0)
- */
-#ifndef MEMP_NUM_SYS_TIMEOUT
-#define MEMP_NUM_SYS_TIMEOUT            3
-#endif
-
-/**
- * MEMP_NUM_NETBUF: the number of struct netbufs.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#ifndef MEMP_NUM_NETBUF
-#define MEMP_NUM_NETBUF                 2
-#endif
-
-/**
- * MEMP_NUM_NETCONN: the number of struct netconns.
- * (only needed if you use the sequential API, like api_lib.c)
- */
-#ifndef MEMP_NUM_NETCONN
-#define MEMP_NUM_NETCONN                4
-#endif
-
-/**
- * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
- * for callback/timeout API communication. 
- * (only needed if you use tcpip.c)
- */
-#ifndef MEMP_NUM_TCPIP_MSG_API
-#define MEMP_NUM_TCPIP_MSG_API          8
-#endif
-
-/**
- * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
- * for incoming packets. 
- * (only needed if you use tcpip.c)
- */
-#ifndef MEMP_NUM_TCPIP_MSG_INPKT
-#define MEMP_NUM_TCPIP_MSG_INPKT        8
-#endif
-
-/**
- * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. 
- */
-#ifndef PBUF_POOL_SIZE
-#define PBUF_POOL_SIZE                  16
-#endif
-
-/*
-   ---------------------------------
-   ---------- ARP options ----------
-   ---------------------------------
-*/
-/**
- * LWIP_ARP==1: Enable ARP functionality.
- */
-#ifndef LWIP_ARP
-#define LWIP_ARP                        1
-#endif
-
-/**
- * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached.
- */
-#ifndef ARP_TABLE_SIZE
-#define ARP_TABLE_SIZE                  10
-#endif
-
-/**
- * ARP_QUEUEING==1: Outgoing packets are queued during hardware address
- * resolution.
- */
-#ifndef ARP_QUEUEING
-#define ARP_QUEUEING                    1
-#endif
-
-/**
- * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be
- * updated with the source MAC and IP addresses supplied in the packet.
- * You may want to disable this if you do not trust LAN peers to have the
- * correct addresses, or as a limited approach to attempt to handle
- * spoofing. If disabled, lwIP will need to make a new ARP request if
- * the peer is not already in the ARP table, adding a little latency.
- */
-#ifndef ETHARP_TRUST_IP_MAC
-#define ETHARP_TRUST_IP_MAC             1
-#endif
-
-/*
-   --------------------------------
-   ---------- IP options ----------
-   --------------------------------
-*/
-/**
- * IP_FORWARD==1: Enables the ability to forward IP packets across network
- * interfaces. If you are going to run lwIP on a device with only one network
- * interface, define this to 0.
- */
-#ifndef IP_FORWARD
-#define IP_FORWARD                      0
-#endif
-
-/**
- * IP_OPTIONS_ALLOWED: Defines the behavior for IP options.
- *      IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped.
- *      IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed).
- */
-#ifndef IP_OPTIONS_ALLOWED
-#define IP_OPTIONS_ALLOWED              1
-#endif
-
-/**
- * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that
- * this option does not affect outgoing packet sizes, which can be controlled
- * via IP_FRAG.
- */
-#ifndef IP_REASSEMBLY
-#define IP_REASSEMBLY                   1
-#endif
-
-/**
- * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note
- * that this option does not affect incoming packet sizes, which can be
- * controlled via IP_REASSEMBLY.
- */
-#ifndef IP_FRAG
-#define IP_FRAG                         1
-#endif
-
-/**
- * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally)
- * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived
- * in this time, the whole packet is discarded.
- */
-#ifndef IP_REASS_MAXAGE
-#define IP_REASS_MAXAGE                 3
-#endif
-
-/**
- * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled.
- * Since the received pbufs are enqueued, be sure to configure
- * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive
- * packets even if the maximum amount of fragments is enqueued for reassembly!
- */
-#ifndef IP_REASS_MAX_PBUFS
-#define IP_REASS_MAX_PBUFS              10
-#endif
-
-/**
- * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP
- * fragmentation. Otherwise pbufs are allocated and reference the original
- * packet data to be fragmented.
- */
-#ifndef IP_FRAG_USES_STATIC_BUF
-#define IP_FRAG_USES_STATIC_BUF         1
-#endif
-
-/**
- * IP_FRAG_MAX_MTU: Assumed max MTU on any interface for IP frag buffer
- * (requires IP_FRAG_USES_STATIC_BUF==1)
- */
-#if IP_FRAG_USES_STATIC_BUF && !defined(IP_FRAG_MAX_MTU)
-#define IP_FRAG_MAX_MTU                 1500
-#endif
-
-/**
- * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers.
- */
-#ifndef IP_DEFAULT_TTL
-#define IP_DEFAULT_TTL                  255
-#endif
-
-/*
-   ----------------------------------
-   ---------- ICMP options ----------
-   ----------------------------------
-*/
-/**
- * LWIP_ICMP==1: Enable ICMP module inside the IP stack.
- * Be careful, disable that make your product non-compliant to RFC1122
- */
-#ifndef LWIP_ICMP
-#define LWIP_ICMP                       1
-#endif
-
-/**
- * ICMP_TTL: Default value for Time-To-Live used by ICMP packets.
- */
-#ifndef ICMP_TTL
-#define ICMP_TTL                       (IP_DEFAULT_TTL)
-#endif
-
-/*
-   ---------------------------------
-   ---------- RAW options ----------
-   ---------------------------------
-*/
-/**
- * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
- */
-#ifndef LWIP_RAW
-#define LWIP_RAW                        1
-#endif
-
-/**
- * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
- */
-#ifndef RAW_TTL
-#define RAW_TTL                        (IP_DEFAULT_TTL)
-#endif
-
-/*
-   ----------------------------------
-   ---------- DHCP options ----------
-   ----------------------------------
-*/
-/**
- * LWIP_DHCP==1: Enable DHCP module.
- */
-#ifndef LWIP_DHCP
-#define LWIP_DHCP                       0
-#endif
-
-/**
- * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address.
- */
-#ifndef DHCP_DOES_ARP_CHECK
-#define DHCP_DOES_ARP_CHECK             ((LWIP_DHCP) && (LWIP_ARP))
-#endif
-
-/*
-   ------------------------------------
-   ---------- AUTOIP options ----------
-   ------------------------------------
-*/
-/**
- * LWIP_AUTOIP==1: Enable AUTOIP module.
- */
-#ifndef LWIP_AUTOIP
-#define LWIP_AUTOIP                     0
-#endif
-
-/**
- * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on
- * the same interface at the same time.
- */
-#ifndef LWIP_DHCP_AUTOIP_COOP
-#define LWIP_DHCP_AUTOIP_COOP           0
-#endif
-
-/*
-   ----------------------------------
-   ---------- SNMP options ----------
-   ----------------------------------
-*/
-/**
- * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP
- * transport.
- */
-#ifndef LWIP_SNMP
-#define LWIP_SNMP                       0
-#endif
-
-/**
- * SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will
- * allow. At least one request buffer is required. 
- */
-#ifndef SNMP_CONCURRENT_REQUESTS
-#define SNMP_CONCURRENT_REQUESTS        1
-#endif
-
-/**
- * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
- * destination is required
- */
-#ifndef SNMP_TRAP_DESTINATIONS
-#define SNMP_TRAP_DESTINATIONS          1
-#endif
-
-/**
- * SNMP_PRIVATE_MIB: 
- */
-#ifndef SNMP_PRIVATE_MIB
-#define SNMP_PRIVATE_MIB                0
-#endif
-
-/**
- * Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not
- * a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
- * Unsafe requests are disabled by default!
- */
-#ifndef SNMP_SAFE_REQUESTS
-#define SNMP_SAFE_REQUESTS              1
-#endif
-
-/*
-   ----------------------------------
-   ---------- IGMP options ----------
-   ----------------------------------
-*/
-/**
- * LWIP_IGMP==1: Turn on IGMP module. 
- */
-#ifndef LWIP_IGMP
-#define LWIP_IGMP                       0
-#endif
-
-/*
-   ----------------------------------
-   ---------- DNS options -----------
-   ----------------------------------
-*/
-/**
- * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS
- * transport.
- */
-#ifndef LWIP_DNS
-#define LWIP_DNS                        0
-#endif
-
-/** DNS maximum number of entries to maintain locally. */
-#ifndef DNS_TABLE_SIZE
-#define DNS_TABLE_SIZE                  4
-#endif
-
-/** DNS maximum host name length supported in the name table. */
-#ifndef DNS_MAX_NAME_LENGTH
-#define DNS_MAX_NAME_LENGTH             256
-#endif
-
-/** The maximum of DNS servers */
-#ifndef DNS_MAX_SERVERS
-#define DNS_MAX_SERVERS                 2
-#endif
-
-/** DNS do a name checking between the query and the response. */
-#ifndef DNS_DOES_NAME_CHECK
-#define DNS_DOES_NAME_CHECK             1
-#endif
-
-/** DNS use a local buffer if DNS_USES_STATIC_BUF=0, a static one if
-    DNS_USES_STATIC_BUF=1, or a dynamic one if DNS_USES_STATIC_BUF=2.
-    The buffer will be of size DNS_MSG_SIZE */
-#ifndef DNS_USES_STATIC_BUF
-#define DNS_USES_STATIC_BUF             1
-#endif
-
-/** DNS message max. size. Default value is RFC compliant. */
-#ifndef DNS_MSG_SIZE
-#define DNS_MSG_SIZE                    512
-#endif
-
-/*
-   ---------------------------------
-   ---------- UDP options ----------
-   ---------------------------------
-*/
-/**
- * LWIP_UDP==1: Turn on UDP.
- */
-#ifndef LWIP_UDP
-#define LWIP_UDP                        1
-#endif
-
-/**
- * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP)
- */
-#ifndef LWIP_UDPLITE
-#define LWIP_UDPLITE                    0
-#endif
-
-/**
- * UDP_TTL: Default Time-To-Live value.
- */
-#ifndef UDP_TTL
-#define UDP_TTL                         (IP_DEFAULT_TTL)
-#endif
-
-/*
-   ---------------------------------
-   ---------- TCP options ----------
-   ---------------------------------
-*/
-/**
- * LWIP_TCP==1: Turn on TCP.
- */
-#ifndef LWIP_TCP
-#define LWIP_TCP                        1
-#endif
-
-/**
- * TCP_TTL: Default Time-To-Live value.
- */
-#ifndef TCP_TTL
-#define TCP_TTL                         (IP_DEFAULT_TTL)
-#endif
-
-/**
- * TCP_WND: The size of a TCP window.
- */
-#ifndef TCP_WND
-#define TCP_WND                         2048
-#endif 
-
-/**
- * TCP_MAXRTX: Maximum number of retransmissions of data segments.
- */
-#ifndef TCP_MAXRTX
-#define TCP_MAXRTX                      12
-#endif
-
-/**
- * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments.
- */
-#ifndef TCP_SYNMAXRTX
-#define TCP_SYNMAXRTX                   6
-#endif
-
-/**
- * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
- * Define to 0 if your device is low on memory.
- */
-#ifndef TCP_QUEUE_OOSEQ
-#define TCP_QUEUE_OOSEQ                 1
-#endif
-
-/**
- * TCP_MSS: TCP Maximum segment size. (default is 128, a *very*
- * conservative default.)
- * For the receive side, this MSS is advertised to the remote side
- * when opening a connection. For the transmit size, this MSS sets
- * an upper limit on the MSS advertised by the remote host.
- */
-#ifndef TCP_MSS
-#define TCP_MSS                         128
-#endif
-
-/**
- * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really
- * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which
- * reflects the available reassembly buffer size at the remote host) and the
- * largest size permitted by the IP layer" (RFC 1122)
- * Setting this to 1 enables code that checks TCP_MSS against the MTU of the
- * netif used for a connection and limits the MSS if it would be too big otherwise.
- */
-#ifndef TCP_CALCULATE_EFF_SEND_MSS
-#define TCP_CALCULATE_EFF_SEND_MSS      1
-#endif
-
-
-/**
- * TCP_SND_BUF: TCP sender buffer space (bytes). 
- */
-#ifndef TCP_SND_BUF
-#define TCP_SND_BUF                     256
-#endif
-
-/**
- * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
- * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
- */
-#ifndef TCP_SND_QUEUELEN
-#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF/TCP_MSS))
-#endif
-
-/**
- * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than or equal
- * to TCP_SND_BUF. It is the amount of space which must be available in the
- * TCP snd_buf for select to return writable.
- */
-#ifndef TCP_SNDLOWAT
-#define TCP_SNDLOWAT                    (TCP_SND_BUF/2)
-#endif
-
-/**
- * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
- */
-#ifndef TCP_LISTEN_BACKLOG
-#define TCP_LISTEN_BACKLOG              0
-#endif
-
-/**
- * The maximum allowed backlog for TCP listen netconns.
- * This backlog is used unless another is explicitly specified.
- * 0xff is the maximum (u8_t).
- */
-#ifndef TCP_DEFAULT_LISTEN_BACKLOG
-#define TCP_DEFAULT_LISTEN_BACKLOG      0xff
-#endif
-
-/**
- * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1.
- *     LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
- *         events (accept, sent, etc) that happen in the system.
- *     LWIP_CALLBACK_API==1: The PCB callback function is called directly
- *         for the event.
- */
-#ifndef LWIP_EVENT_API
-#define LWIP_EVENT_API                  0
-#define LWIP_CALLBACK_API               1
-#else 
-#define LWIP_EVENT_API                  1
-#define LWIP_CALLBACK_API               0
-#endif
-
-
-/*
-   ----------------------------------
-   ---------- Pbuf options ----------
-   ----------------------------------
-*/
-/**
- * PBUF_LINK_HLEN: the number of bytes that should be allocated for a
- * link level header. The default is 14, the standard value for
- * Ethernet.
- */
-#ifndef PBUF_LINK_HLEN
-#define PBUF_LINK_HLEN                  14
-#endif
-
-/**
- * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
- * designed to accomodate single full size TCP frame in one pbuf, including
- * TCP_MSS, IP header, and link header.
- */
-#ifndef PBUF_POOL_BUFSIZE
-#define PBUF_POOL_BUFSIZE               LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN)
-#endif
-
-/*
-   ------------------------------------------------
-   ---------- Network Interfaces options ----------
-   ------------------------------------------------
-*/
-/**
- * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
- * field.
- */
-#ifndef LWIP_NETIF_HOSTNAME
-#define LWIP_NETIF_HOSTNAME             0
-#endif
-
-/**
- * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
- */
-#ifndef LWIP_NETIF_API
-#define LWIP_NETIF_API                  0
-#endif
-
-/**
- * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface
- * changes its up/down status (i.e., due to DHCP IP acquistion)
- */
-#ifndef LWIP_NETIF_STATUS_CALLBACK
-#define LWIP_NETIF_STATUS_CALLBACK      0
-#endif
-
-/**
- * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
- * whenever the link changes (i.e., link down)
- */
-#ifndef LWIP_NETIF_LINK_CALLBACK
-#define LWIP_NETIF_LINK_CALLBACK        0
-#endif
-
-/**
- * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table
- * indices) in struct netif. TCP and UDP can make use of this to prevent
- * scanning the ARP table for every sent packet. While this is faster for big
- * ARP tables or many concurrent connections, it might be counterproductive
- * if you have a tiny ARP table or if there never are concurrent connections.
- */
-#ifndef LWIP_NETIF_HWADDRHINT
-#define LWIP_NETIF_HWADDRHINT           0
-#endif
-
-/*
-   ------------------------------------
-   ---------- LOOPIF options ----------
-   ------------------------------------
-*/
-/**
- * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c
- */
-#ifndef LWIP_HAVE_LOOPIF
-#define LWIP_HAVE_LOOPIF                0
-#endif
-
-/**
- * LWIP_LOOPIF_MULTITHREADING: Indicates whether threading is enabled in
- * the system, as LOOPIF must change how it behaves depending on this setting.
- * Setting this is needed to avoid reentering non-reentrant functions like
- * tcp_input().
- *    LWIP_LOOPIF_MULTITHREADING==1: Indicates that the user is using a
- *       multithreaded environment like tcpip.c. In this case, netif->input()
- *       is called directly.
- *    LWIP_LOOPIF_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup.
- *       The packets are put on a list and loopif_poll() must be called in
- *       the main application loop.
- */
-#ifndef LWIP_LOOPIF_MULTITHREADING
-#define LWIP_LOOPIF_MULTITHREADING      1
-#endif
-
-/*
-   ------------------------------------
-   ---------- Thread options ----------
-   ------------------------------------
-*/
-/**
- * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
- */
-#ifndef TCPIP_THREAD_NAME
-#define TCPIP_THREAD_NAME              "tcpip_thread"
-#endif
-
-/**
- * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef TCPIP_THREAD_STACKSIZE
-#define TCPIP_THREAD_STACKSIZE          0
-#endif
-
-/**
- * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef TCPIP_THREAD_PRIO
-#define TCPIP_THREAD_PRIO               1
-#endif
-
-/**
- * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
- * The queue size value itself is platform-dependent, but is passed to
- * sys_mbox_new() when tcpip_init is called.
- */
-#ifndef TCPIP_MBOX_SIZE
-#define TCPIP_MBOX_SIZE                 0
-#endif
-
-/**
- * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread.
- */
-#ifndef SLIPIF_THREAD_NAME
-#define SLIPIF_THREAD_NAME             "slipif_loop"
-#endif
-
-/**
- * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef SLIPIF_THREAD_STACKSIZE
-#define SLIPIF_THREAD_STACKSIZE         0
-#endif
-
-/**
- * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef SLIPIF_THREAD_PRIO
-#define SLIPIF_THREAD_PRIO              1
-#endif
-
-/**
- * PPP_THREAD_NAME: The name assigned to the pppMain thread.
- */
-#ifndef PPP_THREAD_NAME
-#define PPP_THREAD_NAME                "pppMain"
-#endif
-
-/**
- * PPP_THREAD_STACKSIZE: The stack size used by the pppMain thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef PPP_THREAD_STACKSIZE
-#define PPP_THREAD_STACKSIZE            0
-#endif
-
-/**
- * PPP_THREAD_PRIO: The priority assigned to the pppMain thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef PPP_THREAD_PRIO
-#define PPP_THREAD_PRIO                 1
-#endif
-
-/**
- * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread.
- */
-#ifndef DEFAULT_THREAD_NAME
-#define DEFAULT_THREAD_NAME            "lwIP"
-#endif
-
-/**
- * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread.
- * The stack size value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef DEFAULT_THREAD_STACKSIZE
-#define DEFAULT_THREAD_STACKSIZE        0
-#endif
-
-/**
- * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread.
- * The priority value itself is platform-dependent, but is passed to
- * sys_thread_new() when the thread is created.
- */
-#ifndef DEFAULT_THREAD_PRIO
-#define DEFAULT_THREAD_PRIO             1
-#endif
-
-/**
- * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#ifndef DEFAULT_RAW_RECVMBOX_SIZE
-#define DEFAULT_RAW_RECVMBOX_SIZE       0
-#endif
-
-/**
- * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#ifndef DEFAULT_UDP_RECVMBOX_SIZE
-#define DEFAULT_UDP_RECVMBOX_SIZE       0
-#endif
-
-/**
- * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a
- * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
- * to sys_mbox_new() when the recvmbox is created.
- */
-#ifndef DEFAULT_TCP_RECVMBOX_SIZE
-#define DEFAULT_TCP_RECVMBOX_SIZE       0
-#endif
-
-/**
- * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
- * The queue size value itself is platform-dependent, but is passed to
- * sys_mbox_new() when the acceptmbox is created.
- */
-#ifndef DEFAULT_ACCEPTMBOX_SIZE
-#define DEFAULT_ACCEPTMBOX_SIZE         0
-#endif
-
-/*
-   ----------------------------------------------
-   ---------- Sequential layer options ----------
-   ----------------------------------------------
-*/
-/**
- * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
- * Don't use it if you're not an active lwIP project member
- */
-#ifndef LWIP_TCPIP_CORE_LOCKING
-#define LWIP_TCPIP_CORE_LOCKING         0
-#endif
-
-/**
- * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
- */
-#ifndef LWIP_NETCONN
-#define LWIP_NETCONN                    1
-#endif
-
-/*
-   ------------------------------------
-   ---------- Socket options ----------
-   ------------------------------------
-*/
-/**
- * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
- */
-#ifndef LWIP_SOCKET
-#define LWIP_SOCKET                     1
-#endif
-
-/**
- * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
- * (only used if you use sockets.c)
- */
-#ifndef LWIP_COMPAT_SOCKETS
-#define LWIP_COMPAT_SOCKETS             1
-#endif
-
-/**
- * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
- * Disable this option if you use a POSIX operating system that uses the same
- * names (read, write & close). (only used if you use sockets.c)
- */
-#ifndef LWIP_POSIX_SOCKETS_IO_NAMES
-#define LWIP_POSIX_SOCKETS_IO_NAMES     1
-#endif
-
-/**
- * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
- * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
- * in seconds. (does not require sockets.c, and will affect tcp.c)
- */
-#ifndef LWIP_TCP_KEEPALIVE
-#define LWIP_TCP_KEEPALIVE              0
-#endif
-
-/**
- * LWIP_SO_RCVTIMEO==1: Enable SO_RCVTIMEO processing.
- */
-#ifndef LWIP_SO_RCVTIMEO
-#define LWIP_SO_RCVTIMEO                0
-#endif
-
-/**
- * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
- */
-#ifndef LWIP_SO_RCVBUF
-#define LWIP_SO_RCVBUF                  0
-#endif
-
-/**
- * SO_REUSE==1: Enable SO_REUSEADDR and SO_REUSEPORT options. DO NOT USE!
- */
-#ifndef SO_REUSE
-#define SO_REUSE                        0
-#endif
-
-/*
-   ----------------------------------------
-   ---------- Statistics options ----------
-   ----------------------------------------
-*/
-/**
- * LWIP_STATS==1: Enable statistics collection in lwip_stats.
- */
-#ifndef LWIP_STATS
-#define LWIP_STATS                      1
-#endif
-
-#if LWIP_STATS
-
-/**
- * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
- */
-#ifndef LWIP_STATS_DISPLAY
-#define LWIP_STATS_DISPLAY              0
-#endif
-
-/**
- * LINK_STATS==1: Enable link stats.
- */
-#ifndef LINK_STATS
-#define LINK_STATS                      1
-#endif
-
-/**
- * ETHARP_STATS==1: Enable etharp stats.
- */
-#ifndef ETHARP_STATS
-#define ETHARP_STATS                    (LWIP_ARP)
-#endif
-
-/**
- * IP_STATS==1: Enable IP stats.
- */
-#ifndef IP_STATS
-#define IP_STATS                        1
-#endif
-
-/**
- * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is
- * on if using either frag or reass.
- */
-#ifndef IPFRAG_STATS
-#define IPFRAG_STATS                    (IP_REASSEMBLY || IP_FRAG)
-#endif
-
-/**
- * ICMP_STATS==1: Enable ICMP stats.
- */
-#ifndef ICMP_STATS
-#define ICMP_STATS                      1
-#endif
-
-/**
- * IGMP_STATS==1: Enable IGMP stats.
- */
-#ifndef IGMP_STATS
-#define IGMP_STATS                      (LWIP_IGMP)
-#endif
-
-/**
- * UDP_STATS==1: Enable UDP stats. Default is on if
- * UDP enabled, otherwise off.
- */
-#ifndef UDP_STATS
-#define UDP_STATS                       (LWIP_UDP)
-#endif
-
-/**
- * TCP_STATS==1: Enable TCP stats. Default is on if TCP
- * enabled, otherwise off.
- */
-#ifndef TCP_STATS
-#define TCP_STATS                       (LWIP_TCP)
-#endif
-
-/**
- * MEM_STATS==1: Enable mem.c stats.
- */
-#ifndef MEM_STATS
-#define MEM_STATS                       1
-#endif
-
-/**
- * MEMP_STATS==1: Enable memp.c pool stats.
- */
-#ifndef MEMP_STATS
-#define MEMP_STATS                      1
-#endif
-
-/**
- * SYS_STATS==1: Enable system stats (sem and mbox counts, etc).
- */
-#ifndef SYS_STATS
-#define SYS_STATS                       1
-#endif
-
-#else
-
-#define LINK_STATS                      0
-#define IP_STATS                        0
-#define IPFRAG_STATS                    0
-#define ICMP_STATS                      0
-#define IGMP_STATS                      0
-#define UDP_STATS                       0
-#define TCP_STATS                       0
-#define MEM_STATS                       0
-#define MEMP_STATS                      0
-#define SYS_STATS                       0
-#define LWIP_STATS_DISPLAY              0
-
-#endif /* LWIP_STATS */
-
-/*
-   ---------------------------------
-   ---------- PPP options ----------
-   ---------------------------------
-*/
-/**
- * PPP_SUPPORT==1: Enable PPP.
- */
-#ifndef PPP_SUPPORT
-#define PPP_SUPPORT                     0
-#endif
-
-/**
- * PPPOE_SUPPORT==1: Enable PPP Over Ethernet
- */
-#ifndef PPPOE_SUPPORT
-#define PPPOE_SUPPORT                   0
-#endif
-
-/**
- * PPPOS_SUPPORT==1: Enable PPP Over Serial
- */
-#ifndef PPPOS_SUPPORT
-#define PPPOS_SUPPORT                   PPP_SUPPORT
-#endif
-
-#if PPP_SUPPORT
-
-/**
- * NUM_PPP: Max PPP sessions.
- */
-#ifndef NUM_PPP
-#define NUM_PPP                         1
-#endif
-
-/**
- * PAP_SUPPORT==1: Support PAP.
- */
-#ifndef PAP_SUPPORT
-#define PAP_SUPPORT                     0
-#endif
-
-/**
- * CHAP_SUPPORT==1: Support CHAP.
- */
-#ifndef CHAP_SUPPORT
-#define CHAP_SUPPORT                    0
-#endif
-
-/**
- * MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET!
- */
-#ifndef MSCHAP_SUPPORT
-#define MSCHAP_SUPPORT                  0
-#endif
-
-/**
- * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
- */
-#ifndef CBCP_SUPPORT
-#define CBCP_SUPPORT                    0
-#endif
-
-/**
- * CCP_SUPPORT==1: Support CCP. CURRENTLY NOT SUPPORTED! DO NOT SET!
- */
-#ifndef CCP_SUPPORT
-#define CCP_SUPPORT                     0
-#endif
-
-/**
- * VJ_SUPPORT==1: Support VJ header compression.
- */
-#ifndef VJ_SUPPORT
-#define VJ_SUPPORT                      0
-#endif
-
-/**
- * MD5_SUPPORT==1: Support MD5 (see also CHAP).
- */
-#ifndef MD5_SUPPORT
-#define MD5_SUPPORT                     0
-#endif
-
-/*
- * Timeouts
- */
-#ifndef FSM_DEFTIMEOUT
-#define FSM_DEFTIMEOUT                  6       /* Timeout time in seconds */
-#endif
-
-#ifndef FSM_DEFMAXTERMREQS
-#define FSM_DEFMAXTERMREQS              2       /* Maximum Terminate-Request transmissions */
-#endif
-
-#ifndef FSM_DEFMAXCONFREQS
-#define FSM_DEFMAXCONFREQS              10      /* Maximum Configure-Request transmissions */
-#endif
-
-#ifndef FSM_DEFMAXNAKLOOPS
-#define FSM_DEFMAXNAKLOOPS              5       /* Maximum number of nak loops */
-#endif
-
-#ifndef UPAP_DEFTIMEOUT
-#define UPAP_DEFTIMEOUT                 6       /* Timeout (seconds) for retransmitting req */
-#endif
-
-#ifndef UPAP_DEFREQTIME
-#define UPAP_DEFREQTIME                 30      /* Time to wait for auth-req from peer */
-#endif
-
-#ifndef CHAP_DEFTIMEOUT
-#define CHAP_DEFTIMEOUT                 6       /* Timeout time in seconds */
-#endif
-
-#ifndef CHAP_DEFTRANSMITS
-#define CHAP_DEFTRANSMITS               10      /* max # times to send challenge */
-#endif
-
-/* Interval in seconds between keepalive echo requests, 0 to disable. */
-#ifndef LCP_ECHOINTERVAL
-#define LCP_ECHOINTERVAL                0
-#endif
-
-/* Number of unanswered echo requests before failure. */
-#ifndef LCP_MAXECHOFAILS
-#define LCP_MAXECHOFAILS                3
-#endif
-
-/* Max Xmit idle time (in jiffies) before resend flag char. */
-#ifndef PPP_MAXIDLEFLAG
-#define PPP_MAXIDLEFLAG                 100
-#endif
-
-/*
- * Packet sizes
- *
- * Note - lcp shouldn't be allowed to negotiate stuff outside these
- *    limits.  See lcp.h in the pppd directory.
- * (XXX - these constants should simply be shared by lcp.c instead
- *    of living in lcp.h)
- */
-#define PPP_MTU                         1500     /* Default MTU (size of Info field) */
-#ifndef PPP_MAXMTU
-/* #define PPP_MAXMTU  65535 - (PPP_HDRLEN + PPP_FCSLEN) */
-#define PPP_MAXMTU                      1500 /* Largest MTU we allow */
-#endif
-#define PPP_MINMTU                      64
-#define PPP_MRU                         1500     /* default MRU = max length of info field */
-#define PPP_MAXMRU                      1500     /* Largest MRU we allow */
-#ifndef PPP_DEFMRU
-#define PPP_DEFMRU                      296             /* Try for this */
-#endif
-#define PPP_MINMRU                      128             /* No MRUs below this */
-
-
-#define MAXNAMELEN                      256     /* max length of hostname or name for auth */
-#define MAXSECRETLEN                    256     /* max length of password or secret */
-
-#endif /* PPP_SUPPORT */
-
-/*
-   --------------------------------------
-   ---------- Checksum options ----------
-   --------------------------------------
-*/
-/**
- * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.
- */
-#ifndef CHECKSUM_GEN_IP
-#define CHECKSUM_GEN_IP                 1
-#endif
-/**
- * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.
- */
-#ifndef CHECKSUM_GEN_UDP
-#define CHECKSUM_GEN_UDP                1
-#endif
-/**
- * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.
- */
-#ifndef CHECKSUM_GEN_TCP
-#define CHECKSUM_GEN_TCP                1
-#endif
-/**
- * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.
- */
-#ifndef CHECKSUM_CHECK_IP
-#define CHECKSUM_CHECK_IP               1
-#endif
-/**
- * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.
- */
-#ifndef CHECKSUM_CHECK_UDP
-#define CHECKSUM_CHECK_UDP              1
-#endif
-
-/**
- * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.
- */
-#ifndef CHECKSUM_CHECK_TCP
-#define CHECKSUM_CHECK_TCP              1
-#endif
-
-/*
-   ---------------------------------------
-   ---------- Debugging options ----------
-   ---------------------------------------
-*/
-/**
- * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is
- * compared against this value. If it is smaller, then debugging
- * messages are written.
- */
-#ifndef LWIP_DBG_MIN_LEVEL
-#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_OFF
-#endif
-
-/**
- * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable
- * debug messages of certain types.
- */
-#ifndef LWIP_DBG_TYPES_ON
-#define LWIP_DBG_TYPES_ON               LWIP_DBG_ON
-#endif
-
-/**
- * ETHARP_DEBUG: Enable debugging in etharp.c.
- */
-#ifndef ETHARP_DEBUG
-#define ETHARP_DEBUG                    LWIP_DBG_OFF
-#endif
-
-/**
- * NETIF_DEBUG: Enable debugging in netif.c.
- */
-#ifndef NETIF_DEBUG
-#define NETIF_DEBUG                     LWIP_DBG_OFF
-#endif
-
-/**
- * PBUF_DEBUG: Enable debugging in pbuf.c.
- */
-#ifndef PBUF_DEBUG
-#define PBUF_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * API_LIB_DEBUG: Enable debugging in api_lib.c.
- */
-#ifndef API_LIB_DEBUG
-#define API_LIB_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * API_MSG_DEBUG: Enable debugging in api_msg.c.
- */
-#ifndef API_MSG_DEBUG
-#define API_MSG_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * SOCKETS_DEBUG: Enable debugging in sockets.c.
- */
-#ifndef SOCKETS_DEBUG
-#define SOCKETS_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * ICMP_DEBUG: Enable debugging in icmp.c.
- */
-#ifndef ICMP_DEBUG
-#define ICMP_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * IGMP_DEBUG: Enable debugging in igmp.c.
- */
-#ifndef IGMP_DEBUG
-#define IGMP_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * INET_DEBUG: Enable debugging in inet.c.
- */
-#ifndef INET_DEBUG
-#define INET_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * IP_DEBUG: Enable debugging for IP.
- */
-#ifndef IP_DEBUG
-#define IP_DEBUG                        LWIP_DBG_OFF
-#endif
-
-/**
- * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass.
- */
-#ifndef IP_REASS_DEBUG
-#define IP_REASS_DEBUG                  LWIP_DBG_OFF
-#endif
-
-/**
- * RAW_DEBUG: Enable debugging in raw.c.
- */
-#ifndef RAW_DEBUG
-#define RAW_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * MEM_DEBUG: Enable debugging in mem.c.
- */
-#ifndef MEM_DEBUG
-#define MEM_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * MEMP_DEBUG: Enable debugging in memp.c.
- */
-#ifndef MEMP_DEBUG
-#define MEMP_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * SYS_DEBUG: Enable debugging in sys.c.
- */
-#ifndef SYS_DEBUG
-#define SYS_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_DEBUG: Enable debugging for TCP.
- */
-#ifndef TCP_DEBUG
-#define TCP_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug.
- */
-#ifndef TCP_INPUT_DEBUG
-#define TCP_INPUT_DEBUG                 LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit.
- */
-#ifndef TCP_FR_DEBUG
-#define TCP_FR_DEBUG                    LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit
- * timeout.
- */
-#ifndef TCP_RTO_DEBUG
-#define TCP_RTO_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_CWND_DEBUG: Enable debugging for TCP congestion window.
- */
-#ifndef TCP_CWND_DEBUG
-#define TCP_CWND_DEBUG                  LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating.
- */
-#ifndef TCP_WND_DEBUG
-#define TCP_WND_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions.
- */
-#ifndef TCP_OUTPUT_DEBUG
-#define TCP_OUTPUT_DEBUG                LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_RST_DEBUG: Enable debugging for TCP with the RST message.
- */
-#ifndef TCP_RST_DEBUG
-#define TCP_RST_DEBUG                   LWIP_DBG_OFF
-#endif
-
-/**
- * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths.
- */
-#ifndef TCP_QLEN_DEBUG
-#define TCP_QLEN_DEBUG                  LWIP_DBG_OFF
-#endif
-
-/**
- * UDP_DEBUG: Enable debugging in UDP.
- */
-#ifndef UDP_DEBUG
-#define UDP_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * TCPIP_DEBUG: Enable debugging in tcpip.c.
- */
-#ifndef TCPIP_DEBUG
-#define TCPIP_DEBUG                     LWIP_DBG_OFF
-#endif
-
-/**
- * PPP_DEBUG: Enable debugging for PPP.
- */
-#ifndef PPP_DEBUG
-#define PPP_DEBUG                       LWIP_DBG_OFF
-#endif
-
-/**
- * SLIP_DEBUG: Enable debugging in slipif.c.
- */
-#ifndef SLIP_DEBUG
-#define SLIP_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * DHCP_DEBUG: Enable debugging in dhcp.c.
- */
-#ifndef DHCP_DEBUG
-#define DHCP_DEBUG                      LWIP_DBG_OFF
-#endif
-
-/**
- * AUTOIP_DEBUG: Enable debugging in autoip.c.
- */
-#ifndef AUTOIP_DEBUG
-#define AUTOIP_DEBUG                    LWIP_DBG_OFF
-#endif
-
-/**
- * SNMP_MSG_DEBUG: Enable debugging for SNMP messages.
- */
-#ifndef SNMP_MSG_DEBUG
-#define SNMP_MSG_DEBUG                  LWIP_DBG_OFF
-#endif
-
-/**
- * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.
- */
-#ifndef SNMP_MIB_DEBUG
-#define SNMP_MIB_DEBUG                  LWIP_DBG_OFF
-#endif
-
-/**
- * DNS_DEBUG: Enable debugging for DNS.
- */
-#ifndef DNS_DEBUG
-#define DNS_DEBUG                       LWIP_DBG_OFF
-#endif
-
-#endif /* __LWIP_OPT_H__ */
diff --git a/palacios/src/lwip/include/lwip/pbuf.h b/palacios/src/lwip/include/lwip/pbuf.h
deleted file mode 100644 (file)
index 57a1e99..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-
-#ifndef __LWIP_PBUF_H__
-#define __LWIP_PBUF_H__
-
-#include "lwip/opt.h"
-#include "lwip/err.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PBUF_TRANSPORT_HLEN 20
-#define PBUF_IP_HLEN        20
-
-typedef enum {
-  PBUF_TRANSPORT,
-  PBUF_IP,
-  PBUF_LINK,
-  PBUF_RAW
-} pbuf_layer;
-
-typedef enum {
-  PBUF_RAM, /* pbuf data is stored in RAM */
-  PBUF_ROM, /* pbuf data is stored in ROM */
-  PBUF_REF, /* pbuf comes from the pbuf pool */
-  PBUF_POOL /* pbuf payload refers to RAM */
-} pbuf_type;
-
-
-/** indicates this packet's data should be immediately passed to the application */
-#define PBUF_FLAG_PUSH 0x01U
-
-struct pbuf {
-  /** next pbuf in singly linked pbuf chain */
-  struct pbuf *next;
-
-  /** pointer to the actual data in the buffer */
-  void *payload;
-  
-  /**
-   * total length of this buffer and all next buffers in chain
-   * belonging to the same packet.
-   *
-   * For non-queue packet chains this is the invariant:
-   * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
-   */
-  u16_t tot_len;
-  
-  /** length of this buffer */
-  u16_t len;  
-
-  /** pbuf_type as u8_t instead of enum to save space */
-  u8_t /*pbuf_type*/ type;
-
-  /** misc flags */
-  u8_t flags;
-
-  /**
-   * the reference count always equals the number of pointers
-   * that refer to this pbuf. This can be pointers from an application,
-   * the stack itself, or pbuf->next pointers from a chain.
-   */
-  u16_t ref;
-  
-};
-
-/* Initializes the pbuf module. This call is empty for now, but may not be in future. */
-#define pbuf_init()
-
-struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
-void pbuf_realloc(struct pbuf *p, u16_t size); 
-u8_t pbuf_header(struct pbuf *p, s16_t header_size);
-void pbuf_ref(struct pbuf *p);
-void pbuf_ref_chain(struct pbuf *p);
-u8_t pbuf_free(struct pbuf *p);
-u8_t pbuf_clen(struct pbuf *p);  
-void pbuf_cat(struct pbuf *head, struct pbuf *tail);
-void pbuf_chain(struct pbuf *head, struct pbuf *tail);
-struct pbuf *pbuf_dechain(struct pbuf *p);
-err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
-u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_PBUF_H__ */
diff --git a/palacios/src/lwip/include/lwip/raw.h b/palacios/src/lwip/include/lwip/raw.h
deleted file mode 100644 (file)
index 20b0a11..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_RAW_H__
-#define __LWIP_RAW_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/pbuf.h"
-#include "lwip/inet.h"
-#include "lwip/ip.h"
-#include "lwip/ip_addr.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct raw_pcb {
-/* Common members of all PCB types */
-  IP_PCB;
-
-  struct raw_pcb *next;
-
-  u8_t protocol;
-
-  /* receive callback function
-   * @param arg user supplied argument (raw_pcb.recv_arg)
-   * @param pcb the raw_pcb which received data
-   * @param p the packet buffer that was received
-   * @param addr the remote IP address from which the packet was received
-   * @return 1 if the packet was 'eaten' (aka. deleted),
-   *         0 if the packet lives on
-   * If returning 1, the callback is responsible for freeing the pbuf
-   * if it's not used any more.
-   */
-  u8_t (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
-    struct ip_addr *addr);
-  /* user-supplied argument for the recv callback */
-  void *recv_arg;
-};
-
-/* The following functions is the application layer interface to the
-   RAW code. */
-struct raw_pcb * raw_new        (u8_t proto);
-void             raw_remove     (struct raw_pcb *pcb);
-err_t            raw_bind       (struct raw_pcb *pcb, struct ip_addr *ipaddr);
-err_t            raw_connect    (struct raw_pcb *pcb, struct ip_addr *ipaddr);
-
-void             raw_recv       (struct raw_pcb *pcb,
-                                 u8_t (* recv)(void *arg, struct raw_pcb *pcb,
-                                              struct pbuf *p,
-                                              struct ip_addr *addr),
-                                 void *recv_arg);
-err_t            raw_sendto     (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr);
-err_t            raw_send       (struct raw_pcb *pcb, struct pbuf *p);
-
-/* The following functions are the lower layer interface to RAW. */
-u8_t             raw_input      (struct pbuf *p, struct netif *inp);
-#define raw_init() /* Compatibility define, not init needed. */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_RAW */
-
-#endif /* __LWIP_RAW_H__ */
diff --git a/palacios/src/lwip/include/lwip/sio.h b/palacios/src/lwip/include/lwip/sio.h
deleted file mode 100644 (file)
index 7437522..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- */
-
-/*
- * This is the interface to the platform specific serial IO module
- * It needs to be implemented by those platforms which need SLIP or PPP
- */
-
-#include "lwip/arch.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __sio_fd_t_defined
-typedef void * sio_fd_t;
-#endif
-
-#ifndef sio_open
-sio_fd_t sio_open(u8_t);
-#endif
-
-#ifndef sio_send
-void sio_send(u8_t, sio_fd_t);
-#endif
-
-#ifndef sio_recv
-u8_t sio_recv(sio_fd_t);
-#endif
-
-#ifndef sio_read
-u32_t sio_read(sio_fd_t, u8_t *, u32_t);
-#endif
-
-#ifndef sio_write
-u32_t sio_write(sio_fd_t, u8_t *, u32_t);
-#endif
-
-#ifndef sio_read_abort
-void sio_read_abort(sio_fd_t);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/palacios/src/lwip/include/lwip/snmp.h b/palacios/src/lwip/include/lwip/snmp.h
deleted file mode 100644 (file)
index dd03d5d..0000000
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (c) 2001, 2002 Leon Woestenberg <leon.woestenberg@axon.tv>
- * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands.
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Leon Woestenberg <leon.woestenberg@axon.tv>
- *
- */
-#ifndef __LWIP_SNMP_H__
-#define __LWIP_SNMP_H__
-
-#include "lwip/opt.h"
-#include "lwip/netif.h"
-#include "lwip/udp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @see RFC1213, "MIB-II, 6. Definitions"
- */
-enum snmp_ifType {
-  snmp_ifType_other=1,                /* none of the following */
-  snmp_ifType_regular1822,
-  snmp_ifType_hdh1822,
-  snmp_ifType_ddn_x25,
-  snmp_ifType_rfc877_x25,
-  snmp_ifType_ethernet_csmacd,
-  snmp_ifType_iso88023_csmacd,
-  snmp_ifType_iso88024_tokenBus,
-  snmp_ifType_iso88025_tokenRing,
-  snmp_ifType_iso88026_man,
-  snmp_ifType_starLan,
-  snmp_ifType_proteon_10Mbit,
-  snmp_ifType_proteon_80Mbit,
-  snmp_ifType_hyperchannel,
-  snmp_ifType_fddi,
-  snmp_ifType_lapb,
-  snmp_ifType_sdlc,
-  snmp_ifType_ds1,                    /* T-1 */
-  snmp_ifType_e1,                     /* european equiv. of T-1 */
-  snmp_ifType_basicISDN,
-  snmp_ifType_primaryISDN,            /* proprietary serial */
-  snmp_ifType_propPointToPointSerial,
-  snmp_ifType_ppp,
-  snmp_ifType_softwareLoopback,
-  snmp_ifType_eon,                    /* CLNP over IP [11] */
-  snmp_ifType_ethernet_3Mbit,
-  snmp_ifType_nsip,                   /* XNS over IP */
-  snmp_ifType_slip,                   /* generic SLIP */
-  snmp_ifType_ultra,                  /* ULTRA technologies */
-  snmp_ifType_ds3,                    /* T-3 */
-  snmp_ifType_sip,                    /* SMDS */
-  snmp_ifType_frame_relay
-};
-
-#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
-
-/** SNMP "sysuptime" Interval */
-#define SNMP_SYSUPTIME_INTERVAL 10
-
-/** fixed maximum length for object identifier type */
-#define LWIP_SNMP_OBJ_ID_LEN 32
-
-/** internal object identifier representation */
-struct snmp_obj_id
-{
-  u8_t len;
-  s32_t id[LWIP_SNMP_OBJ_ID_LEN];
-};
-
-/* system */
-void snmp_set_sysdesr(u8_t* str, u8_t* len);
-void snmp_set_sysobjid(struct snmp_obj_id *oid);
-void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid);
-void snmp_inc_sysuptime(void);
-void snmp_add_sysuptime(u32_t value);
-void snmp_get_sysuptime(u32_t *value);
-void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen);
-void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen);
-void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen);
-
-/* network interface */
-void snmp_add_ifinoctets(struct netif *ni, u32_t value); 
-void snmp_inc_ifinucastpkts(struct netif *ni);
-void snmp_inc_ifinnucastpkts(struct netif *ni);
-void snmp_inc_ifindiscards(struct netif *ni);
-void snmp_add_ifoutoctets(struct netif *ni, u32_t value);
-void snmp_inc_ifoutucastpkts(struct netif *ni);
-void snmp_inc_ifoutnucastpkts(struct netif *ni);
-void snmp_inc_ifoutdiscards(struct netif *ni);
-void snmp_inc_iflist(void);
-void snmp_dec_iflist(void);
-
-/* ARP (for atTable and ipNetToMediaTable) */
-void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip);
-void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip);
-
-/* IP */
-void snmp_inc_ipinreceives(void);
-void snmp_inc_ipinhdrerrors(void);
-void snmp_inc_ipinaddrerrors(void);
-void snmp_inc_ipforwdatagrams(void);
-void snmp_inc_ipinunknownprotos(void);
-void snmp_inc_ipindiscards(void);
-void snmp_inc_ipindelivers(void);
-void snmp_inc_ipoutrequests(void);
-void snmp_inc_ipoutdiscards(void);
-void snmp_inc_ipoutnoroutes(void);
-void snmp_inc_ipreasmreqds(void);
-void snmp_inc_ipreasmoks(void);
-void snmp_inc_ipreasmfails(void);
-void snmp_inc_ipfragoks(void);
-void snmp_inc_ipfragfails(void);
-void snmp_inc_ipfragcreates(void);
-void snmp_inc_iproutingdiscards(void);
-void snmp_insert_ipaddridx_tree(struct netif *ni);
-void snmp_delete_ipaddridx_tree(struct netif *ni);
-void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni);
-void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni);
-
-/* ICMP */
-void snmp_inc_icmpinmsgs(void);
-void snmp_inc_icmpinerrors(void);
-void snmp_inc_icmpindestunreachs(void);
-void snmp_inc_icmpintimeexcds(void);
-void snmp_inc_icmpinparmprobs(void);
-void snmp_inc_icmpinsrcquenchs(void);
-void snmp_inc_icmpinredirects(void);
-void snmp_inc_icmpinechos(void);
-void snmp_inc_icmpinechoreps(void);
-void snmp_inc_icmpintimestamps(void);
-void snmp_inc_icmpintimestampreps(void);
-void snmp_inc_icmpinaddrmasks(void);
-void snmp_inc_icmpinaddrmaskreps(void);
-void snmp_inc_icmpoutmsgs(void);
-void snmp_inc_icmpouterrors(void);
-void snmp_inc_icmpoutdestunreachs(void);
-void snmp_inc_icmpouttimeexcds(void);
-void snmp_inc_icmpoutparmprobs(void);
-void snmp_inc_icmpoutsrcquenchs(void);
-void snmp_inc_icmpoutredirects(void); 
-void snmp_inc_icmpoutechos(void);
-void snmp_inc_icmpoutechoreps(void);
-void snmp_inc_icmpouttimestamps(void);
-void snmp_inc_icmpouttimestampreps(void);
-void snmp_inc_icmpoutaddrmasks(void);
-void snmp_inc_icmpoutaddrmaskreps(void);
-
-/* TCP */
-void snmp_inc_tcpactiveopens(void);
-void snmp_inc_tcppassiveopens(void);
-void snmp_inc_tcpattemptfails(void);
-void snmp_inc_tcpestabresets(void);
-void snmp_inc_tcpinsegs(void);
-void snmp_inc_tcpoutsegs(void);
-void snmp_inc_tcpretranssegs(void);
-void snmp_inc_tcpinerrs(void);
-void snmp_inc_tcpoutrsts(void);
-
-/* UDP */
-void snmp_inc_udpindatagrams(void);
-void snmp_inc_udpnoports(void);
-void snmp_inc_udpinerrors(void);
-void snmp_inc_udpoutdatagrams(void);
-void snmp_insert_udpidx_tree(struct udp_pcb *pcb);
-void snmp_delete_udpidx_tree(struct udp_pcb *pcb);
-
-/* SNMP */
-void snmp_inc_snmpinpkts(void);
-void snmp_inc_snmpoutpkts(void);
-void snmp_inc_snmpinbadversions(void);
-void snmp_inc_snmpinbadcommunitynames(void);
-void snmp_inc_snmpinbadcommunityuses(void);
-void snmp_inc_snmpinasnparseerrs(void);
-void snmp_inc_snmpintoobigs(void);
-void snmp_inc_snmpinnosuchnames(void);
-void snmp_inc_snmpinbadvalues(void);
-void snmp_inc_snmpinreadonlys(void);
-void snmp_inc_snmpingenerrs(void);
-void snmp_add_snmpintotalreqvars(u8_t value);
-void snmp_add_snmpintotalsetvars(u8_t value);
-void snmp_inc_snmpingetrequests(void);
-void snmp_inc_snmpingetnexts(void);
-void snmp_inc_snmpinsetrequests(void);
-void snmp_inc_snmpingetresponses(void);
-void snmp_inc_snmpintraps(void);
-void snmp_inc_snmpouttoobigs(void);
-void snmp_inc_snmpoutnosuchnames(void);
-void snmp_inc_snmpoutbadvalues(void);
-void snmp_inc_snmpoutgenerrs(void);
-void snmp_inc_snmpoutgetrequests(void);
-void snmp_inc_snmpoutgetnexts(void);
-void snmp_inc_snmpoutsetrequests(void);
-void snmp_inc_snmpoutgetresponses(void);
-void snmp_inc_snmpouttraps(void);
-void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid);
-void snmp_set_snmpenableauthentraps(u8_t *value);
-void snmp_get_snmpenableauthentraps(u8_t *value);
-
-/* LWIP_SNMP support not available */
-/* define everything to be empty */
-#else
-
-/* system */
-#define snmp_set_sysdesr(str, len)
-#define snmp_set_sysobjid(oid);
-#define snmp_get_sysobjid_ptr(oid)
-#define snmp_inc_sysuptime()
-#define snmp_add_sysuptime(value)
-#define snmp_get_sysuptime(value)
-#define snmp_set_syscontact(ocstr, ocstrlen);
-#define snmp_set_sysname(ocstr, ocstrlen);
-#define snmp_set_syslocation(ocstr, ocstrlen);
-
-/* network interface */
-#define snmp_add_ifinoctets(ni,value) 
-#define snmp_inc_ifinucastpkts(ni)
-#define snmp_inc_ifinnucastpkts(ni)
-#define snmp_inc_ifindiscards(ni)
-#define snmp_add_ifoutoctets(ni,value)
-#define snmp_inc_ifoutucastpkts(ni)
-#define snmp_inc_ifoutnucastpkts(ni)
-#define snmp_inc_ifoutdiscards(ni)
-#define snmp_inc_iflist()
-#define snmp_dec_iflist()
-
-/* ARP */
-#define snmp_insert_arpidx_tree(ni,ip)
-#define snmp_delete_arpidx_tree(ni,ip)
-
-/* IP */
-#define snmp_inc_ipinreceives()
-#define snmp_inc_ipinhdrerrors()
-#define snmp_inc_ipinaddrerrors()
-#define snmp_inc_ipforwdatagrams()
-#define snmp_inc_ipinunknownprotos()
-#define snmp_inc_ipindiscards()
-#define snmp_inc_ipindelivers()
-#define snmp_inc_ipoutrequests()
-#define snmp_inc_ipoutdiscards()
-#define snmp_inc_ipoutnoroutes()
-#define snmp_inc_ipreasmreqds()
-#define snmp_inc_ipreasmoks()
-#define snmp_inc_ipreasmfails()
-#define snmp_inc_ipfragoks()
-#define snmp_inc_ipfragfails()
-#define snmp_inc_ipfragcreates()
-#define snmp_inc_iproutingdiscards()
-#define snmp_insert_ipaddridx_tree(ni)
-#define snmp_delete_ipaddridx_tree(ni)
-#define snmp_insert_iprteidx_tree(dflt, ni)
-#define snmp_delete_iprteidx_tree(dflt, ni)
-
-/* ICMP */
-#define snmp_inc_icmpinmsgs()
-#define snmp_inc_icmpinerrors() 
-#define snmp_inc_icmpindestunreachs() 
-#define snmp_inc_icmpintimeexcds()
-#define snmp_inc_icmpinparmprobs() 
-#define snmp_inc_icmpinsrcquenchs() 
-#define snmp_inc_icmpinredirects() 
-#define snmp_inc_icmpinechos() 
-#define snmp_inc_icmpinechoreps()
-#define snmp_inc_icmpintimestamps() 
-#define snmp_inc_icmpintimestampreps()
-#define snmp_inc_icmpinaddrmasks()
-#define snmp_inc_icmpinaddrmaskreps()
-#define snmp_inc_icmpoutmsgs()
-#define snmp_inc_icmpouterrors()
-#define snmp_inc_icmpoutdestunreachs() 
-#define snmp_inc_icmpouttimeexcds() 
-#define snmp_inc_icmpoutparmprobs()
-#define snmp_inc_icmpoutsrcquenchs()
-#define snmp_inc_icmpoutredirects() 
-#define snmp_inc_icmpoutechos() 
-#define snmp_inc_icmpoutechoreps()
-#define snmp_inc_icmpouttimestamps()
-#define snmp_inc_icmpouttimestampreps()
-#define snmp_inc_icmpoutaddrmasks()
-#define snmp_inc_icmpoutaddrmaskreps()
-/* TCP */
-#define snmp_inc_tcpactiveopens()
-#define snmp_inc_tcppassiveopens()
-#define snmp_inc_tcpattemptfails()
-#define snmp_inc_tcpestabresets()
-#define snmp_inc_tcpinsegs()
-#define snmp_inc_tcpoutsegs()
-#define snmp_inc_tcpretranssegs()
-#define snmp_inc_tcpinerrs()
-#define snmp_inc_tcpoutrsts()
-
-/* UDP */
-#define snmp_inc_udpindatagrams()
-#define snmp_inc_udpnoports()
-#define snmp_inc_udpinerrors()
-#define snmp_inc_udpoutdatagrams()
-#define snmp_insert_udpidx_tree(pcb)
-#define snmp_delete_udpidx_tree(pcb)
-
-/* SNMP */
-#define snmp_inc_snmpinpkts()
-#define snmp_inc_snmpoutpkts()
-#define snmp_inc_snmpinbadversions()
-#define snmp_inc_snmpinbadcommunitynames()
-#define snmp_inc_snmpinbadcommunityuses()
-#define snmp_inc_snmpinasnparseerrs()
-#define snmp_inc_snmpintoobigs()
-#define snmp_inc_snmpinnosuchnames()
-#define snmp_inc_snmpinbadvalues()
-#define snmp_inc_snmpinreadonlys()
-#define snmp_inc_snmpingenerrs()
-#define snmp_add_snmpintotalreqvars(value)
-#define snmp_add_snmpintotalsetvars(value)
-#define snmp_inc_snmpingetrequests()
-#define snmp_inc_snmpingetnexts()
-#define snmp_inc_snmpinsetrequests()
-#define snmp_inc_snmpingetresponses()
-#define snmp_inc_snmpintraps()
-#define snmp_inc_snmpouttoobigs()
-#define snmp_inc_snmpoutnosuchnames()
-#define snmp_inc_snmpoutbadvalues()
-#define snmp_inc_snmpoutgenerrs()
-#define snmp_inc_snmpoutgetrequests()
-#define snmp_inc_snmpoutgetnexts()
-#define snmp_inc_snmpoutsetrequests()
-#define snmp_inc_snmpoutgetresponses()
-#define snmp_inc_snmpouttraps()
-#define snmp_get_snmpgrpid_ptr(oid)
-#define snmp_set_snmpenableauthentraps(value)
-#define snmp_get_snmpenableauthentraps(value)
-
-#endif /* LWIP_SNMP */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_SNMP_H__ */
diff --git a/palacios/src/lwip/include/lwip/snmp_asn1.h b/palacios/src/lwip/include/lwip/snmp_asn1.h
deleted file mode 100644 (file)
index 3d70d33..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * @file
- * Abstract Syntax Notation One (ISO 8824, 8825) codec.
- */
-/*
- * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * Author: Christiaan Simons <christiaan.simons@axon.tv>
- */
-
-#ifndef __LWIP_SNMP_ASN1_H__
-#define __LWIP_SNMP_ASN1_H__
-
-#include "lwip/opt.h"
-#include "lwip/err.h"
-#include "lwip/pbuf.h"
-#include "lwip/snmp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SNMP_ASN1_UNIV   (!0x80 | !0x40)
-#define SNMP_ASN1_APPLIC (!0x80 |  0x40)
-#define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
-
-#define SNMP_ASN1_CONSTR (0x20)
-#define SNMP_ASN1_PRIMIT (!0x20)
-
-/* universal tags */
-#define SNMP_ASN1_INTEG  2
-#define SNMP_ASN1_OC_STR 4
-#define SNMP_ASN1_NUL    5
-#define SNMP_ASN1_OBJ_ID 6
-#define SNMP_ASN1_SEQ    16
-
-/* application specific (SNMP) tags */
-#define SNMP_ASN1_IPADDR 0    /* octet string size(4) */
-#define SNMP_ASN1_COUNTER 1   /* u32_t */
-#define SNMP_ASN1_GAUGE 2     /* u32_t */
-#define SNMP_ASN1_TIMETICKS 3 /* u32_t */
-#define SNMP_ASN1_OPAQUE 4    /* octet string */
-
-/* context specific (SNMP) tags */
-#define SNMP_ASN1_PDU_GET_REQ 0
-#define SNMP_ASN1_PDU_GET_NEXT_REQ 1
-#define SNMP_ASN1_PDU_GET_RESP 2
-#define SNMP_ASN1_PDU_SET_REQ 3
-#define SNMP_ASN1_PDU_TRAP 4
-
-err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);
-err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);
-err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);
-err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);
-err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);
-err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);
-
-void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
-void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
-void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
-void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
-err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
-err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
-err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value);
-err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value);
-err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
-err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_SNMP_ASN1_H__ */
diff --git a/palacios/src/lwip/include/lwip/snmp_msg.h b/palacios/src/lwip/include/lwip/snmp_msg.h
deleted file mode 100644 (file)
index d202825..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/**
- * @file
- * SNMP Agent message handling structures.
- */
-
-/*
- * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * Author: Christiaan Simons <christiaan.simons@axon.tv>
- */
-
-#ifndef __LWIP_SNMP_MSG_H__
-#define __LWIP_SNMP_MSG_H__
-
-#include "lwip/opt.h"
-#include "lwip/snmp.h"
-#include "lwip/snmp_structs.h"
-
-#if SNMP_PRIVATE_MIB
-#include "private_mib.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The listen port of the SNMP agent. Clients have to make their requests to
-   this port. Most standard clients won't work if you change this! */
-#ifndef SNMP_IN_PORT
-#define SNMP_IN_PORT 161
-#endif
-/* The remote port the SNMP agent sends traps to. Most standard trap sinks won't
-   work if you change this! */
-#ifndef SNMP_TRAP_PORT
-#define SNMP_TRAP_PORT 162
-#endif
-
-#define SNMP_ES_NOERROR 0
-#define SNMP_ES_TOOBIG 1
-#define SNMP_ES_NOSUCHNAME 2
-#define SNMP_ES_BADVALUE 3
-#define SNMP_ES_READONLY 4
-#define SNMP_ES_GENERROR 5
-
-#define SNMP_GENTRAP_COLDSTART 0
-#define SNMP_GENTRAP_WARMSTART 1
-#define SNMP_GENTRAP_AUTHFAIL 4
-#define SNMP_GENTRAP_ENTERPRISESPC 6
-
-struct snmp_varbind
-{
-  /* next pointer, NULL for last in list */
-  struct snmp_varbind *next;
-  /* previous pointer, NULL for first in list */
-  struct snmp_varbind *prev;
-
-  /* object identifier length (in s32_t) */
-  u8_t ident_len;
-  /* object identifier array */
-  s32_t *ident;
-
-  /* object value ASN1 type */
-  u8_t value_type;
-  /* object value length (in u8_t) */
-  u8_t value_len;
-  /* object value */
-  void *value;
-
-  /* encoding varbind seq length length */
-  u8_t seqlenlen;
-  /* encoding object identifier length length */
-  u8_t olenlen;
-  /* encoding object value length length */
-  u8_t vlenlen;
-  /* encoding varbind seq length */
-  u16_t seqlen;
-  /* encoding object identifier length */
-  u16_t olen;
-  /* encoding object value length */
-  u16_t vlen;
-};
-
-struct snmp_varbind_root
-{
-  struct snmp_varbind *head;
-  struct snmp_varbind *tail;
-  /* number of variable bindings in list */
-  u8_t count;
-  /* encoding varbind-list seq length length */
-  u8_t seqlenlen;
-  /* encoding varbind-list seq length */
-  u16_t seqlen;
-};
-
-/** output response message header length fields */
-struct snmp_resp_header_lengths
-{
-  /* encoding error-index length length */
-  u8_t erridxlenlen;
-  /* encoding error-status length length */
-  u8_t errstatlenlen;
-  /* encoding request id length length */
-  u8_t ridlenlen;
-  /* encoding pdu length length */
-  u8_t pdulenlen;
-  /* encoding community length length */
-  u8_t comlenlen;
-  /* encoding version length length */
-  u8_t verlenlen;
-  /* encoding sequence length length */
-  u8_t seqlenlen;
-
-  /* encoding error-index length */
-  u16_t erridxlen;
-  /* encoding error-status length */
-  u16_t errstatlen;
-  /* encoding request id length */
-  u16_t ridlen;
-  /* encoding pdu length */
-  u16_t pdulen;
-  /* encoding community length */
-  u16_t comlen;
-  /* encoding version length */
-  u16_t verlen;
-  /* encoding sequence length */
-  u16_t seqlen;
-};
-
-/** output response message header length fields */
-struct snmp_trap_header_lengths
-{
-  /* encoding timestamp length length */
-  u8_t tslenlen;
-  /* encoding specific-trap length length */
-  u8_t strplenlen;
-  /* encoding generic-trap length length */
-  u8_t gtrplenlen;
-  /* encoding agent-addr length length */
-  u8_t aaddrlenlen;
-  /* encoding enterprise-id length length */
-  u8_t eidlenlen;
-  /* encoding pdu length length */
-  u8_t pdulenlen;
-  /* encoding community length length */
-  u8_t comlenlen;
-  /* encoding version length length */
-  u8_t verlenlen;
-  /* encoding sequence length length */
-  u8_t seqlenlen;
-
-  /* encoding timestamp length */
-  u16_t tslen;
-  /* encoding specific-trap length */
-  u16_t strplen;
-  /* encoding generic-trap length */
-  u16_t gtrplen;
-  /* encoding agent-addr length */
-  u16_t aaddrlen;
-  /* encoding enterprise-id length */
-  u16_t eidlen;
-  /* encoding pdu length */
-  u16_t pdulen;
-  /* encoding community length */
-  u16_t comlen;
-  /* encoding version length */
-  u16_t verlen;
-  /* encoding sequence length */
-  u16_t seqlen;
-};
-
-/* Accepting new SNMP messages. */
-#define SNMP_MSG_EMPTY                 0
-/* Search for matching object for variable binding. */
-#define SNMP_MSG_SEARCH_OBJ            1
-/* Perform SNMP operation on in-memory object.
-   Pass-through states, for symmetry only. */
-#define SNMP_MSG_INTERNAL_GET_OBJDEF   2
-#define SNMP_MSG_INTERNAL_GET_VALUE    3
-#define SNMP_MSG_INTERNAL_SET_TEST     4
-#define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5
-#define SNMP_MSG_INTERNAL_SET_VALUE    6
-/* Perform SNMP operation on object located externally.
-   In theory this could be used for building a proxy agent.
-   Practical use is for an enterprise spc. app. gateway. */
-#define SNMP_MSG_EXTERNAL_GET_OBJDEF   7
-#define SNMP_MSG_EXTERNAL_GET_VALUE    8
-#define SNMP_MSG_EXTERNAL_SET_TEST     9
-#define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10
-#define SNMP_MSG_EXTERNAL_SET_VALUE    11
-
-#define SNMP_COMMUNITY_STR_LEN 64
-struct snmp_msg_pstat
-{
-  /* lwIP local port (161) binding */
-  struct udp_pcb *pcb;
-  /* source IP address */
-  struct ip_addr sip;
-  /* source UDP port */
-  u16_t sp;
-  /* request type */
-  u8_t rt;
-  /* request ID */
-  s32_t rid;
-  /* error status */
-  s32_t error_status;
-  /* error index */
-  s32_t error_index;
-  /* community name (zero terminated) */
-  u8_t community[SNMP_COMMUNITY_STR_LEN + 1];
-  /* community string length (exclusive zero term) */
-  u8_t com_strlen;
-  /* one out of MSG_EMPTY, MSG_DEMUX, MSG_INTERNAL, MSG_EXTERNAL_x */
-  u8_t state;
-  /* saved arguments for MSG_EXTERNAL_x */
-  struct mib_external_node *ext_mib_node;
-  struct snmp_name_ptr ext_name_ptr;
-  struct obj_def ext_object_def;
-  struct snmp_obj_id ext_oid;
-  /* index into input variable binding list */
-  u8_t vb_idx;
-  /* ptr into input variable binding list */
-  struct snmp_varbind *vb_ptr;
-  /* list of variable bindings from input */
-  struct snmp_varbind_root invb;
-  /* list of variable bindings to output */
-  struct snmp_varbind_root outvb;
-  /* output response lengths used in ASN encoding */
-  struct snmp_resp_header_lengths rhl;
-};
-
-struct snmp_msg_trap
-{
-  /* lwIP local port (161) binding */
-  struct udp_pcb *pcb;
-  /* destination IP address in network order */
-  struct ip_addr dip;
-
-  /* source enterprise ID (sysObjectID) */
-  struct snmp_obj_id *enterprise;
-  /* source IP address, raw network order format */
-  u8_t sip_raw[4];
-  /* generic trap code */
-  u32_t gen_trap;
-  /* specific trap code */
-  u32_t spc_trap;
-  /* timestamp */
-  u32_t ts;
-  /* list of variable bindings to output */
-  struct snmp_varbind_root outvb;
-  /* output trap lengths used in ASN encoding */
-  struct snmp_trap_header_lengths thl;
-};
-
-/** Agent Version constant, 0 = v1 oddity */
-extern const s32_t snmp_version;
-/** Agent default "public" community string */
-extern const char snmp_publiccommunity[7];
-
-extern struct snmp_msg_trap trap_msg;
-
-/** Agent setup, start listening to port 161. */
-void snmp_init(void);
-void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable);
-void snmp_trap_dst_ip_set(u8_t dst_idx, struct ip_addr *dst);
-
-/** Varbind-list functions. */
-struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len);
-void snmp_varbind_free(struct snmp_varbind *vb);
-void snmp_varbind_list_free(struct snmp_varbind_root *root);
-void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb);
-struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root);
-
-/** Handle an internal (recv) or external (private response) event. */
-void snmp_msg_event(u8_t request_id);
-err_t snmp_send_response(struct snmp_msg_pstat *m_stat);
-err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap);
-void snmp_coldstart_trap(void);
-void snmp_authfail_trap(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_SNMP_MSG_H__ */
diff --git a/palacios/src/lwip/include/lwip/snmp_structs.h b/palacios/src/lwip/include/lwip/snmp_structs.h
deleted file mode 100644 (file)
index 9f3f8a9..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * @file
- * Generic MIB tree structures.
- *
- * @todo namespace prefixes
- */
-
-/*
- * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * Author: Christiaan Simons <christiaan.simons@axon.tv>
- */
-
-#ifndef __LWIP_SNMP_STRUCTS_H__
-#define __LWIP_SNMP_STRUCTS_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/snmp.h"
-
-#if SNMP_PRIVATE_MIB
-#include "private_mib.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* MIB object instance */
-#define MIB_OBJECT_NONE 0 
-#define MIB_OBJECT_SCALAR 1
-#define MIB_OBJECT_TAB 2
-
-/* MIB object access */
-#define MIB_OBJECT_READ_ONLY 0
-#define MIB_OBJECT_READ_WRITE 1
-#define MIB_OBJECT_WRITE_ONLY 2
-#define MIB_OBJECT_NOT_ACCESSIBLE 3
-
-/** object definition returned by (get_object_def)() */
-struct obj_def
-{
-  /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */
-  u8_t instance;
-  /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */
-  u8_t access;
-  /* ASN type for this object */
-  u8_t asn_type;
-  /* value length (host length) */
-  u16_t v_len;
-  /* length of instance part of supplied object identifier */
-  u8_t  id_inst_len;
-  /* instance part of supplied object identifier */
-  s32_t *id_inst_ptr;
-};
-
-struct snmp_name_ptr
-{
-  u8_t ident_len;
-  s32_t *ident;
-};
-
-/** MIB const scalar (.0) node */
-#define MIB_NODE_SC 0x01
-/** MIB const array node */
-#define MIB_NODE_AR 0x02
-/** MIB array node (mem_malloced from RAM) */
-#define MIB_NODE_RA 0x03
-/** MIB list root node (mem_malloced from RAM) */
-#define MIB_NODE_LR 0x04
-/** MIB node for external objects */
-#define MIB_NODE_EX 0x05
-
-/** node "base class" layout, the mandatory fields for a node  */
-struct mib_node
-{
-  /** returns struct obj_def for the given object identifier */
-  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
-  /** returns object value for the given object identifier,
-     @note the caller must allocate at least len bytes for the value */
-  void (*get_value)(struct obj_def *od, u16_t len, void *value);
-  /** tests length and/or range BEFORE setting */
-  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
-  /** sets object value, only to be called when set_test()  */
-  void (*set_value)(struct obj_def *od, u16_t len, void *value);  
-  /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
-  const u8_t node_type;
-  /* array or max list length */
-  const u16_t maxlength;
-};
-
-/** derived node for scalars .0 index */
-typedef struct mib_node mib_scalar_node;
-
-/** derived node, points to a fixed size const array
-    of sub-identifiers plus a 'child' pointer */
-struct mib_array_node
-{
-  /* inherited "base class" members */
-  void (* const get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
-  void (* const get_value)(struct obj_def *od, u16_t len, void *value);
-  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
-  void (*set_value)(struct obj_def *od, u16_t len, void *value);
-
-  const u8_t node_type;
-  const u16_t maxlength;
-
-  /* aditional struct members */
-  const s32_t *objid;
-  struct mib_node* const *nptr;
-};
-
-/** derived node, points to a fixed size mem_malloced array
-    of sub-identifiers plus a 'child' pointer */
-struct mib_ram_array_node
-{
-  /* inherited "base class" members */
-  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
-  void (*get_value)(struct obj_def *od, u16_t len, void *value);
-  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
-  void (*set_value)(struct obj_def *od, u16_t len, void *value);
-
-  u8_t node_type;
-  u16_t maxlength;
-
-  /* aditional struct members */
-  s32_t *objid;
-  struct mib_node **nptr;
-};
-
-struct mib_list_node
-{
-  struct mib_list_node *prev;  
-  struct mib_list_node *next;
-  s32_t objid;
-  struct mib_node *nptr;
-};
-
-/** derived node, points to a doubly linked list
-    of sub-identifiers plus a 'child' pointer */
-struct mib_list_rootnode
-{
-  /* inherited "base class" members */
-  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
-  void (*get_value)(struct obj_def *od, u16_t len, void *value);
-  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
-  void (*set_value)(struct obj_def *od, u16_t len, void *value);
-
-  u8_t node_type;
-  u16_t maxlength;
-
-  /* aditional struct members */
-  struct mib_list_node *head;
-  struct mib_list_node *tail;
-  /* counts list nodes in list  */
-  u16_t count;
-};
-
-/** derived node, has access functions for mib object in external memory or device
-    using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */
-struct mib_external_node
-{
-  /* inherited "base class" members */
-  void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
-  void (*get_value)(struct obj_def *od, u16_t len, void *value);
-  u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
-  void (*set_value)(struct obj_def *od, u16_t len, void *value);
-
-  u8_t node_type;
-  u16_t maxlength;
-
-  /* aditional struct members */
-  /** points to an extenal (in memory) record of some sort of addressing
-      information, passed to and interpreted by the funtions below */
-  void* addr_inf;
-  /** tree levels under this node */
-  u8_t tree_levels;
-  /** number of objects at this level */
-  u16_t (*level_length)(void* addr_inf, u8_t level);
-  /** compares object sub identifier with external id
-      return zero when equal, nonzero when unequal */
-  s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id);
-  void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id);
-
-  /** async Questions */
-  void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident);
-  void (*get_value_q)(u8_t rid, struct obj_def *od);
-  void (*set_test_q)(u8_t rid, struct obj_def *od);
-  void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value);
-  /** async Answers */
-  void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od);
-  void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
-  u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
-  void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
-  /** async Panic Close (agent returns error reply, 
-      e.g. used for external transaction cleanup) */
-  void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident);
-  void (*get_value_pc)(u8_t rid, struct obj_def *od);
-  void (*set_test_pc)(u8_t rid, struct obj_def *od);
-  void (*set_value_pc)(u8_t rid, struct obj_def *od);
-};
-
-/** export MIB tree from mib2.c */
-extern const struct mib_array_node internet;
-
-/** dummy function pointers for non-leaf MIB nodes from mib2.c */
-void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
-void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
-u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value);
-void noleafs_set_value(struct obj_def *od, u16_t len, void *value);
-
-void snmp_oidtoip(s32_t *ident, struct ip_addr *ip);
-void snmp_iptooid(struct ip_addr *ip, s32_t *ident);
-void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
-void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);
-
-struct mib_list_node* snmp_mib_ln_alloc(s32_t id);
-void snmp_mib_ln_free(struct mib_list_node *ln);
-struct mib_list_rootnode* snmp_mib_lrn_alloc(void);
-void snmp_mib_lrn_free(struct mib_list_rootnode *lrn);
-
-s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn);
-s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
-struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
-
-struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
-struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
-u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
-u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_SNMP */
-
-#endif /* __LWIP_SNMP_STRUCTS_H__ */
diff --git a/palacios/src/lwip/include/lwip/stats.h b/palacios/src/lwip/include/lwip/stats.h
deleted file mode 100644 (file)
index 755092e..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_STATS_H__
-#define __LWIP_STATS_H__
-
-#include "lwip/opt.h"
-
-#include "lwip/mem.h"
-#include "lwip/memp.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if LWIP_STATS
-
-#ifndef LWIP_STATS_LARGE
-#define LWIP_STATS_LARGE 0
-#endif
-
-#if LWIP_STATS_LARGE
-#define STAT_COUNTER     u32_t
-#define STAT_COUNTER_F   U32_F
-#else
-#define STAT_COUNTER     u16_t
-#define STAT_COUNTER_F   U16_F
-#endif 
-
-struct stats_proto {
-  STAT_COUNTER xmit;             /* Transmitted packets. */
-  STAT_COUNTER rexmit;           /* Retransmitted packets. */
-  STAT_COUNTER recv;             /* Received packets. */
-  STAT_COUNTER fw;               /* Forwarded packets. */
-  STAT_COUNTER drop;             /* Dropped packets. */
-  STAT_COUNTER chkerr;           /* Checksum error. */
-  STAT_COUNTER lenerr;           /* Invalid length error. */
-  STAT_COUNTER memerr;           /* Out of memory error. */
-  STAT_COUNTER rterr;            /* Routing error. */
-  STAT_COUNTER proterr;          /* Protocol error. */
-  STAT_COUNTER opterr;           /* Error in options. */
-  STAT_COUNTER err;              /* Misc error. */
-  STAT_COUNTER cachehit;
-};
-
-struct stats_igmp {
-  STAT_COUNTER lenerr;           /* Invalid length error. */
-  STAT_COUNTER chkerr;           /* Checksum error. */
-  STAT_COUNTER v1_rxed;          /* */
-  STAT_COUNTER join_sent;        /* */
-  STAT_COUNTER leave_sent;       /* */
-  STAT_COUNTER unicast_query;    /* */
-  STAT_COUNTER report_sent;      /* */
-  STAT_COUNTER report_rxed;      /* */
-  STAT_COUNTER group_query_rxed; /* */
-};
-
-struct stats_mem {
-  mem_size_t avail;
-  mem_size_t used;
-  mem_size_t max;
-  mem_size_t err;
-};
-
-struct stats_syselem {
-  STAT_COUNTER used;
-  STAT_COUNTER max;
-  STAT_COUNTER err;
-};
-
-struct stats_sys {
-  struct stats_syselem sem;
-  struct stats_syselem mbox;
-};
-
-struct stats_ {
-#if LINK_STATS
-  struct stats_proto link;
-#endif
-#if ETHARP_STATS
-  struct stats_proto etharp;
-#endif
-#if IPFRAG_STATS
-  struct stats_proto ip_frag;
-#endif
-#if IP_STATS
-  struct stats_proto ip;
-#endif
-#if ICMP_STATS
-  struct stats_proto icmp;
-#endif
-#if IGMP_STATS
-  struct stats_igmp igmp;
-#endif
-#if UDP_STATS
-  struct stats_proto udp;
-#endif
-#if TCP_STATS
-  struct stats_proto tcp;
-#endif
-#if MEM_STATS
-  struct stats_mem mem;
-#endif
-#if MEMP_STATS
-  struct stats_mem memp[MEMP_MAX];
-#endif
-#if SYS_STATS
-  struct stats_sys sys;
-#endif
-};
-
-extern struct stats_ lwip_stats;
-
-#define stats_init() /* Compatibility define, not init needed. */
-
-#define STATS_INC(x) ++lwip_stats.x
-#else
-#define stats_init()
-#define STATS_INC(x)
-#endif /* LWIP_STATS */
-
-#if TCP_STATS
-#define TCP_STATS_INC(x) STATS_INC(x)
-#else
-#define TCP_STATS_INC(x)
-#endif
-
-#if UDP_STATS
-#define UDP_STATS_INC(x) STATS_INC(x)
-#else
-#define UDP_STATS_INC(x)
-#endif
-
-#if ICMP_STATS
-#define ICMP_STATS_INC(x) STATS_INC(x)
-#else
-#define ICMP_STATS_INC(x)
-#endif
-
-#if IGMP_STATS
-#define IGMP_STATS_INC(x) STATS_INC(x)
-#else
-#define IGMP_STATS_INC(x)
-#endif
-
-#if IP_STATS
-#define IP_STATS_INC(x) STATS_INC(x)
-#else
-#define IP_STATS_INC(x)
-#endif
-
-#if IPFRAG_STATS
-#define IPFRAG_STATS_INC(x) STATS_INC(x)
-#else
-#define IPFRAG_STATS_INC(x)
-#endif
-
-#if ETHARP_STATS
-#define ETHARP_STATS_INC(x) STATS_INC(x)
-#else
-#define ETHARP_STATS_INC(x)
-#endif
-
-#if LINK_STATS
-#define LINK_STATS_INC(x) STATS_INC(x)
-#else
-#define LINK_STATS_INC(x)
-#endif
-
-/* Display of statistics */
-#if LWIP_STATS_DISPLAY
-void stats_display(void);
-#else
-#define stats_display()
-#endif /* LWIP_STATS_DISPLAY */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_STATS_H__ */
diff --git a/palacios/src/lwip/include/lwip/sys.h b/palacios/src/lwip/include/lwip/sys.h
deleted file mode 100644 (file)
index ce73bea..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_SYS_H__
-#define __LWIP_SYS_H__
-
-#include "lwip/opt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if NO_SYS
-
-/* For a totally minimal and standalone system, we provide null
-   definitions of the sys_ functions. */
-typedef u8_t sys_sem_t;
-typedef u8_t sys_mbox_t;
-typedef u8_t sys_prot_t;
-struct sys_timeo {u8_t dummy;};
-
-#define sys_init()
-#define sys_timeout(m,h,a)
-#define sys_untimeout(m,a)
-#define sys_sem_new(c) c
-#define sys_sem_signal(s)
-#define sys_sem_wait(s)
-#define sys_sem_wait_timeout(s,t)
-#define sys_arch_sem_wait(s,t)
-#define sys_sem_free(s)
-#define sys_mbox_new(s) 0
-#define sys_mbox_fetch(m,d)
-#define sys_mbox_tryfetch(m,d)
-#define sys_mbox_post(m,d)
-#define sys_mbox_trypost(m,d)
-#define sys_mbox_free(m)
-
-#define sys_thread_new(n,t,a,s,p)
-
-#else /* NO_SYS */
-
-/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
-#define SYS_ARCH_TIMEOUT 0xffffffffUL
-
-/* sys_mbox_tryfetch returns SYS_MBOX_EMPTY if appropriate.
- * For now we use the same magic value, but we allow this to change in future.
- */
-#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT 
-
-#include "lwip/err.h"
-#include "arch/sys_arch.h"
-
-typedef void (* sys_timeout_handler)(void *arg);
-
-struct sys_timeo {
-  struct sys_timeo *next;
-  u32_t time;
-  sys_timeout_handler h;
-  void *arg;
-};
-
-struct sys_timeouts {
-  struct sys_timeo *next;
-};
-
-/* sys_init() must be called before anthing else. */
-void sys_init(void);
-
-/*
- * sys_timeout():
- *
- * Schedule a timeout a specified amount of milliseconds in the
- * future. When the timeout occurs, the specified timeout handler will
- * be called. The handler will be passed the "arg" argument when
- * called.
- *
- */
-void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
-void sys_untimeout(sys_timeout_handler h, void *arg);
-struct sys_timeouts *sys_arch_timeouts(void);
-
-/* Semaphore functions. */
-sys_sem_t sys_sem_new(u8_t count);
-void sys_sem_signal(sys_sem_t sem);
-u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout);
-void sys_sem_free(sys_sem_t sem);
-void sys_sem_wait(sys_sem_t sem);
-int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout);
-
-/* Time functions. */
-#ifndef sys_msleep
-void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */
-#endif
-#ifndef sys_jiffies
-u32_t sys_jiffies(void); /* since power up. */
-#endif
-
-/* Mailbox functions. */
-sys_mbox_t sys_mbox_new(int size);
-void sys_mbox_post(sys_mbox_t mbox, void *msg);
-err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg);
-u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
-#ifndef sys_arch_mbox_tryfetch /* Allow port to override with a macro */
-u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg);
-#endif
-/* For now, we map straight to sys_arch implementation. */
-#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
-void sys_mbox_free(sys_mbox_t mbox);
-void sys_mbox_fetch(sys_mbox_t mbox, void **msg);
-
-/* Thread functions. */
-sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio);
-
-/* The following functions are used only in Unix code, and
-   can be omitted when porting the stack. */
-/* Returns the current time in microseconds. */
-unsigned long sys_now(void);
-
-#endif /* NO_SYS */
-
-/* Critical Region Protection */
-/* These functions must be implemented in the sys_arch.c file.
-   In some implementations they can provide a more light-weight protection
-   mechanism than using semaphores. Otherwise semaphores can be used for
-   implementation */
-#ifndef SYS_ARCH_PROTECT
-/** SYS_LIGHTWEIGHT_PROT
- * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
- * for certain critical regions during buffer allocation, deallocation and memory
- * allocation and deallocation.
- */
-#if SYS_LIGHTWEIGHT_PROT
-
-/** SYS_ARCH_DECL_PROTECT
- * declare a protection variable. This macro will default to defining a variable of
- * type sys_prot_t. If a particular port needs a different implementation, then
- * this macro may be defined in sys_arch.h.
- */
-#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
-/** SYS_ARCH_PROTECT
- * Perform a "fast" protect. This could be implemented by
- * disabling interrupts for an embedded system or by using a semaphore or
- * mutex. The implementation should allow calling SYS_ARCH_PROTECT when
- * already protected. The old protection level is returned in the variable
- * "lev". This macro will default to calling the sys_arch_protect() function
- * which should be implemented in sys_arch.c. If a particular port needs a
- * different implementation, then this macro may be defined in sys_arch.h
- */
-#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
-/** SYS_ARCH_UNPROTECT
- * Perform a "fast" set of the protection level to "lev". This could be
- * implemented by setting the interrupt level to "lev" within the MACRO or by
- * using a semaphore or mutex.  This macro will default to calling the
- * sys_arch_unprotect() function which should be implemented in
- * sys_arch.c. If a particular port needs a different implementation, then
- * this macro may be defined in sys_arch.h
- */
-#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
-sys_prot_t sys_arch_protect(void);
-void sys_arch_unprotect(sys_prot_t pval);
-
-#else
-
-#define SYS_ARCH_DECL_PROTECT(lev)
-#define SYS_ARCH_PROTECT(lev)
-#define SYS_ARCH_UNPROTECT(lev)
-
-#endif /* SYS_LIGHTWEIGHT_PROT */
-
-#endif /* SYS_ARCH_PROTECT */
-
-/*
- * Macros to set/get and increase/decrease variables in a thread-safe way.
- * Use these for accessing variable that are used from more than one thread.
- */
-
-#ifndef SYS_ARCH_INC
-#define SYS_ARCH_INC(var, val) do { \
-                                SYS_ARCH_DECL_PROTECT(old_level); \
-                                SYS_ARCH_PROTECT(old_level); \
-                                var += val; \
-                                SYS_ARCH_UNPROTECT(old_level); \
-                              } while(0)
-#endif /* SYS_ARCH_INC */
-
-#ifndef SYS_ARCH_DEC
-#define SYS_ARCH_DEC(var, val) do { \
-                                SYS_ARCH_DECL_PROTECT(old_level); \
-                                SYS_ARCH_PROTECT(old_level); \
-                                var -= val; \
-                                SYS_ARCH_UNPROTECT(old_level); \
-                              } while(0)
-#endif /* SYS_ARCH_DEC */
-
-#ifndef SYS_ARCH_GET
-#define SYS_ARCH_GET(var, ret) do { \
-                                SYS_ARCH_DECL_PROTECT(old_level); \
-                                SYS_ARCH_PROTECT(old_level); \
-                                ret = var; \
-                                SYS_ARCH_UNPROTECT(old_level); \
-                              } while(0)
-#endif /* SYS_ARCH_GET */
-
-#ifndef SYS_ARCH_SET
-#define SYS_ARCH_SET(var, val) do { \
-                                SYS_ARCH_DECL_PROTECT(old_level); \
-                                SYS_ARCH_PROTECT(old_level); \
-                                var = val; \
-                                SYS_ARCH_UNPROTECT(old_level); \
-                              } while(0)
-#endif /* SYS_ARCH_SET */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __LWIP_SYS_H__ */
diff --git a/palacios/src/lwip/include/lwip/tcp.h b/palacios/src/lwip/include/lwip/tcp.h
deleted file mode 100644 (file)
index 883b0b8..0000000
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_TCP_H__
-#define __LWIP_TCP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/sys.h"
-#include "lwip/mem.h"
-#include "lwip/pbuf.h"
-#include "lwip/ip.h"
-#include "lwip/icmp.h"
-#include "lwip/err.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct tcp_pcb;
-
-/* Functions for interfacing with TCP: */
-
-/* Lower layer interface to TCP: */
-#define tcp_init() /* Compatibility define, not init needed. */
-void             tcp_tmr     (void);  /* Must be called every
-                                         TCP_TMR_INTERVAL
-                                         ms. (Typically 250 ms). */
-/* Application program's interface: */
-struct tcp_pcb * tcp_new     (void);
-struct tcp_pcb * tcp_alloc   (u8_t prio);
-
-void             tcp_arg     (struct tcp_pcb *pcb, void *arg);
-void             tcp_accept  (struct tcp_pcb *pcb,
-                              err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
-                 err_t err));
-void             tcp_recv    (struct tcp_pcb *pcb,
-                              err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
-                              struct pbuf *p, err_t err));
-void             tcp_sent    (struct tcp_pcb *pcb,
-                              err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
-                              u16_t len));
-void             tcp_poll    (struct tcp_pcb *pcb,
-                              err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
-                              u8_t interval);
-void             tcp_err     (struct tcp_pcb *pcb,
-                              void (* err)(void *arg, err_t err));
-
-#define          tcp_mss(pcb)      ((pcb)->mss)
-#define          tcp_sndbuf(pcb)   ((pcb)->snd_buf)
-
-#if TCP_LISTEN_BACKLOG
-#define          tcp_accepted(pcb) (((struct tcp_pcb_listen *)(pcb))->accepts_pending--)
-#else  /* TCP_LISTEN_BACKLOG */
-#define          tcp_accepted(pcb)
-#endif /* TCP_LISTEN_BACKLOG */
-
-void             tcp_recved  (struct tcp_pcb *pcb, u16_t len);
-err_t            tcp_bind    (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
-                              u16_t port);
-err_t            tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
-                              u16_t port, err_t (* connected)(void *arg,
-                              struct tcp_pcb *tpcb,
-                              err_t err));
-
-struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog);
-#define          tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG)
-
-void             tcp_abort   (struct tcp_pcb *pcb);
-err_t            tcp_close   (struct tcp_pcb *pcb);
-
-/* Flags for "apiflags" parameter in tcp_write and tcp_enqueue */
-#define TCP_WRITE_FLAG_COPY 0x01
-#define TCP_WRITE_FLAG_MORE 0x02
-
-err_t            tcp_write   (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
-                              u8_t apiflags);
-
-void             tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
-
-#define TCP_PRIO_MIN    1
-#define TCP_PRIO_NORMAL 64
-#define TCP_PRIO_MAX    127
-
-/* It is also possible to call these two functions at the right
-   intervals (instead of calling tcp_tmr()). */
-void             tcp_slowtmr (void);
-void             tcp_fasttmr (void);
-
-
-/* Only used by IP to pass a TCP segment to TCP: */
-void             tcp_input   (struct pbuf *p, struct netif *inp);
-/* Used within the TCP code only: */
-err_t            tcp_output  (struct tcp_pcb *pcb);
-void             tcp_rexmit  (struct tcp_pcb *pcb);
-void             tcp_rexmit_rto  (struct tcp_pcb *pcb);
-
-/**
- * This is the Nagle algorithm: inhibit the sending of new TCP
- * segments when new outgoing data arrives from the user if any
- * previously transmitted data on the connection remains
- * unacknowledged.
- */
-#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
-                            ((tpcb)->flags & TF_NODELAY) || \
-                            (((tpcb)->unsent != NULL) && ((tpcb)->unsent->next != NULL))) ? \
-                                1 : 0)
-#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
-
-
-/** This returns a TCP header option for MSS in an u32_t */
-#define TCP_BUILD_MSS_OPTION()  htonl(((u32_t)2 << 24) | \
-                                ((u32_t)4 << 16) | \
-                                (((u32_t)TCP_MSS / 256) << 8) | \
-                                (TCP_MSS & 255))
-
-#define TCP_SEQ_LT(a,b)     ((s32_t)((a)-(b)) < 0)
-#define TCP_SEQ_LEQ(a,b)    ((s32_t)((a)-(b)) <= 0)
-#define TCP_SEQ_GT(a,b)     ((s32_t)((a)-(b)) > 0)
-#define TCP_SEQ_GEQ(a,b)    ((s32_t)((a)-(b)) >= 0)
-/* is b<=a<=c? */
-#if 0 /* see bug #10548 */
-#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
-#endif
-#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
-#define TCP_FIN 0x01U
-#define TCP_SYN 0x02U
-#define TCP_RST 0x04U
-#define TCP_PSH 0x08U
-#define TCP_ACK 0x10U
-#define TCP_URG 0x20U
-#define TCP_ECE 0x40U
-#define TCP_CWR 0x80U
-
-#define TCP_FLAGS 0x3fU
-
-/* Length of the TCP header, excluding options. */
-#define TCP_HLEN 20
-
-#ifndef TCP_TMR_INTERVAL
-#define TCP_TMR_INTERVAL       250  /* The TCP timer interval in milliseconds. */
-#endif /* TCP_TMR_INTERVAL */
-
-#ifndef TCP_FAST_INTERVAL
-#define TCP_FAST_INTERVAL      TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */
-#endif /* TCP_FAST_INTERVAL */
-
-#ifndef TCP_SLOW_INTERVAL
-#define TCP_SLOW_INTERVAL      (2*TCP_TMR_INTERVAL)  /* the coarse grained timeout in milliseconds */
-#endif /* TCP_SLOW_INTERVAL */
-
-#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
-#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
-
-#define TCP_OOSEQ_TIMEOUT        6U /* x RTO */
-
-#ifndef TCP_MSL
-#define TCP_MSL 60000U /* The maximum segment lifetime in milliseconds */
-#endif
-
-/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */
-#ifndef  TCP_KEEPIDLE_DEFAULT
-#define  TCP_KEEPIDLE_DEFAULT     7200000UL /* Default KEEPALIVE timer in milliseconds */
-#endif
-
-#ifndef  TCP_KEEPINTVL_DEFAULT
-#define  TCP_KEEPINTVL_DEFAULT    75000UL   /* Default Time between KEEPALIVE probes in milliseconds */
-#endif
-
-#ifndef  TCP_KEEPCNT_DEFAULT
-#define  TCP_KEEPCNT_DEFAULT      9U        /* Default Counter for KEEPALIVE probes */
-#endif
-
-#define  TCP_MAXIDLE              TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT  /* Maximum KEEPALIVE probe time */
-
-/* Fields are (of course) in network byte order.
- * Some fields are converted to host byte order in tcp_input().
- */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct tcp_hdr {
-  PACK_STRUCT_FIELD(u16_t src);
-  PACK_STRUCT_FIELD(u16_t dest);
-  PACK_STRUCT_FIELD(u32_t seqno);
-  PACK_STRUCT_FIELD(u32_t ackno);
-  PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
-  PACK_STRUCT_FIELD(u16_t wnd);
-  PACK_STRUCT_FIELD(u16_t chksum);
-  PACK_STRUCT_FIELD(u16_t urgp);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#define TCPH_OFFSET(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 8)
-#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)
-#define TCPH_FLAGS(phdr)  (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)
-
-#define TCPH_OFFSET_SET(phdr, offset) (phdr)->_hdrlen_rsvd_flags = htons(((offset) << 8) | TCPH_FLAGS(phdr))
-#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
-#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons((ntohs((phdr)->_hdrlen_rsvd_flags) & ~TCP_FLAGS) | (flags))
-#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (flags))
-#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) )
-
-#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || \
-          TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0))
-
-enum tcp_state {
-  CLOSED      = 0,
-  LISTEN      = 1,
-  SYN_SENT    = 2,
-  SYN_RCVD    = 3,
-  ESTABLISHED = 4,
-  FIN_WAIT_1  = 5,
-  FIN_WAIT_2  = 6,
-  CLOSE_WAIT  = 7,
-  CLOSING     = 8,
-  LAST_ACK    = 9,
-  TIME_WAIT   = 10
-};
-
-/** Flags used on input processing, not on pcb->flags
-*/
-#define TF_RESET     (u8_t)0x08U   /* Connection was reset. */
-#define TF_CLOSED    (u8_t)0x10U   /* Connection was sucessfully closed. */
-#define TF_GOT_FIN   (u8_t)0x20U   /* Connection was closed by the remote end. */
-
-/**
- * members common to struct tcp_pcb and struct tcp_listen_pcb
- */
-#define TCP_PCB_COMMON(type) \
-  type *next; /* for the linked list */ \
-  enum tcp_state state; /* TCP state */ \
-  u8_t prio; \
-  void *callback_arg; \
-  /* ports are in host byte order */ \
-  u16_t local_port
-
-/* the TCP protocol control block */
-struct tcp_pcb {
-/** common PCB members */
-  IP_PCB;
-/** protocol specific PCB members */
-  TCP_PCB_COMMON(struct tcp_pcb);
-
-  /* ports are in host byte order */
-  u16_t remote_port;
-  
-  u8_t flags;
-#define TF_ACK_DELAY   (u8_t)0x01U   /* Delayed ACK. */
-#define TF_ACK_NOW     (u8_t)0x02U   /* Immediate ACK. */
-#define TF_INFR        (u8_t)0x04U   /* In fast recovery. */
-#define TF_FIN         (u8_t)0x20U   /* Connection was closed locally (FIN segment enqueued). */
-#define TF_NODELAY     (u8_t)0x40U   /* Disable Nagle algorithm */
-#define TF_NAGLEMEMERR (u8_t)0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */
-
-  /* the rest of the fields are in host byte order
-     as we have to do some math with them */
-  /* receiver variables */
-  u32_t rcv_nxt;   /* next seqno expected */
-  u16_t rcv_wnd;   /* receiver window */
-  u16_t rcv_ann_wnd; /* announced receive window */
-
-  /* Timers */
-  u32_t tmr;
-  u8_t polltmr, pollinterval;
-  
-  /* Retransmission timer. */
-  s16_t rtime;
-  
-  u16_t mss;   /* maximum segment size */
-  
-  /* RTT (round trip time) estimation variables */
-  u32_t rttest; /* RTT estimate in 500ms ticks */
-  u32_t rtseq;  /* sequence number being timed */
-  s16_t sa, sv; /* @todo document this */
-
-  s16_t rto;    /* retransmission time-out */
-  u8_t nrtx;    /* number of retransmissions */
-
-  /* fast retransmit/recovery */
-  u32_t lastack; /* Highest acknowledged seqno. */
-  u8_t dupacks;
-  
-  /* congestion avoidance/control variables */
-  u16_t cwnd;  
-  u16_t ssthresh;
-
-  /* sender variables */
-  u32_t snd_nxt,   /* next seqno to be sent */
-    snd_max;       /* Highest seqno sent. */
-  u16_t snd_wnd;   /* sender window */
-  u32_t snd_wl1, snd_wl2, /* Sequence and acknowledgement numbers of last
-                             window update. */
-    snd_lbb;       /* Sequence number of next byte to be buffered. */
-
-  u16_t acked;
-  
-  u16_t snd_buf;   /* Available buffer space for sending (in bytes). */
-#define TCP_SNDQUEUELEN_OVERFLOW (0xffff-3)
-  u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */
-  
-  
-  /* These are ordered by sequence number: */
-  struct tcp_seg *unsent;   /* Unsent (queued) segments. */
-  struct tcp_seg *unacked;  /* Sent but unacknowledged segments. */
-#if TCP_QUEUE_OOSEQ  
-  struct tcp_seg *ooseq;    /* Received out of sequence segments. */
-#endif /* TCP_QUEUE_OOSEQ */
-
-  struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */
-
-#if LWIP_CALLBACK_API
-  /* Function to be called when more send buffer space is available.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb the tcp_pcb which has send buffer space available
-   * @param space the amount of bytes available
-   * @return ERR_OK: try to send some data by calling tcp_output
-   */
-  err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space);
-  
-  /* Function to be called when (in-sequence) data has arrived.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb the tcp_pcb for which data has arrived
-   * @param p the packet buffer which arrived
-   * @param err an error argument (TODO: that is current always ERR_OK?)
-   * @return ERR_OK: try to send some data by calling tcp_output
-   */
-  err_t (* recv)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
-
-  /* Function to be called when a connection has been set up.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb the tcp_pcb that now is connected
-   * @param err an error argument (TODO: that is current always ERR_OK?)
-   * @return value is currently ignored
-   */
-  err_t (* connected)(void *arg, struct tcp_pcb *pcb, err_t err);
-
-  /* Function to call when a listener has been connected.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb a new tcp_pcb that now is connected
-   * @param err an error argument (TODO: that is current always ERR_OK?)
-   * @return ERR_OK: accept the new connection,
-   *                 any other err_t abortsthe new connection
-   */
-  err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);
-
-  /* Function which is called periodically.
-   * The period can be adjusted in multiples of the TCP slow timer interval
-   * by changing tcp_pcb.polltmr.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb the tcp_pcb to poll for
-   * @return ERR_OK: try to send some data by calling tcp_output
-   */
-  err_t (* poll)(void *arg, struct tcp_pcb *pcb);
-
-  /* Function to be called whenever a fatal error occurs.
-   * There is no pcb parameter since most of the times, the pcb is
-   * already deallocated (or there is no pcb) when this function is called.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param err an indication why the error callback is called:
-   *            ERR_ABRT: aborted through tcp_abort or by a TCP timer
-   *            ERR_RST: the connection was reset by the remote host
-   */
-  void (* errf)(void *arg, err_t err);
-#endif /* LWIP_CALLBACK_API */
-
-  /* idle time before KEEPALIVE is sent */
-  u32_t keep_idle;
-#if LWIP_TCP_KEEPALIVE
-  u32_t keep_intvl;
-  u32_t keep_cnt;
-#endif /* LWIP_TCP_KEEPALIVE */
-  
-  /* Persist timer counter */
-  u32_t persist_cnt;
-  /* Persist timer back-off */
-  u8_t persist_backoff;
-
-  /* KEEPALIVE counter */
-  u8_t keep_cnt_sent;
-};
-
-struct tcp_pcb_listen {  
-/* Common members of all PCB types */
-  IP_PCB;
-/* Protocol specific PCB members */
-  TCP_PCB_COMMON(struct tcp_pcb_listen);
-
-#if LWIP_CALLBACK_API
-  /* Function to call when a listener has been connected.
-   * @param arg user-supplied argument (tcp_pcb.callback_arg)
-   * @param pcb a new tcp_pcb that now is connected
-   * @param err an error argument (TODO: that is current always ERR_OK?)
-   * @return ERR_OK: accept the new connection,
-   *                 any other err_t abortsthe new connection
-   */
-  err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);
-#endif /* LWIP_CALLBACK_API */
-#if TCP_LISTEN_BACKLOG
-  u8_t backlog;
-  u8_t accepts_pending;
-#endif /* TCP_LISTEN_BACKLOG */
-};
-
-#if LWIP_EVENT_API
-
-enum lwip_event {
-  LWIP_EVENT_ACCEPT,
-  LWIP_EVENT_SENT,
-  LWIP_EVENT_RECV,
-  LWIP_EVENT_CONNECTED,
-  LWIP_EVENT_POLL,
-  LWIP_EVENT_ERR
-};
-
-err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
-         enum lwip_event,
-         struct pbuf *p,
-         u16_t size,
-         err_t err);
-
-#define TCP_EVENT_ACCEPT(pcb,err,ret)    ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
-                LWIP_EVENT_ACCEPT, NULL, 0, err)
-#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
-                   LWIP_EVENT_SENT, NULL, space, ERR_OK)
-#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
-                LWIP_EVENT_RECV, (p), 0, (err))
-#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
-                LWIP_EVENT_CONNECTED, NULL, 0, (err))
-#define TCP_EVENT_POLL(pcb,ret)       ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
-                LWIP_EVENT_POLL, NULL, 0, ERR_OK)
-#define TCP_EVENT_ERR(errf,arg,err)  lwip_tcp_event((arg), NULL, \
-                LWIP_EVENT_ERR, NULL, 0, (err))
-#else /* LWIP_EVENT_API */
-#define TCP_EVENT_ACCEPT(pcb,err,ret)     \
-                        if((pcb)->accept != NULL) \
-                        (ret = (pcb)->accept((pcb)->callback_arg,(pcb),(err)))
-#define TCP_EVENT_SENT(pcb,space,ret) \
-                        if((pcb)->sent != NULL) \
-                        (ret = (pcb)->sent((pcb)->callback_arg,(pcb),(space)))
-#define TCP_EVENT_RECV(pcb,p,err,ret) \
-                        if((pcb)->recv != NULL) \
-                        { ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
-                          ret = ERR_OK; \
-                          if (p) pbuf_free(p); }
-#define TCP_EVENT_CONNECTED(pcb,err,ret) \
-                        if((pcb)->connected != NULL) \
-                        (ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err)))
-#define TCP_EVENT_POLL(pcb,ret) \
-                        if((pcb)->poll != NULL) \
-                        (ret = (pcb)->poll((pcb)->callback_arg,(pcb)))
-#define TCP_EVENT_ERR(errf,arg,err) \
-                        if((errf) != NULL) \
-                        (errf)((arg),(err))
-#endif /* LWIP_EVENT_API */
-
-/* This structure represents a TCP segment on the unsent and unacked queues */
-struct tcp_seg {
-  struct tcp_seg *next;    /* used when putting segements on a queue */
-  struct pbuf *p;          /* buffer containing data + TCP header */
-  void *dataptr;           /* pointer to the TCP data in the pbuf */
-  u16_t len;               /* the TCP length of this segment */
-  struct tcp_hdr *tcphdr;  /* the TCP header */
-};
-
-/* Internal functions and global variables: */
-struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
-void tcp_pcb_purge(struct tcp_pcb *pcb);
-void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
-
-u8_t tcp_segs_free(struct tcp_seg *seg);
-u8_t tcp_seg_free(struct tcp_seg *seg);
-struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
-
-#define tcp_ack(pcb)     if((pcb)->flags & TF_ACK_DELAY) { \
-                            (pcb)->flags &= ~TF_ACK_DELAY; \
-                            (pcb)->flags |= TF_ACK_NOW; \
-                            tcp_output(pcb); \
-                         } else { \
-                            (pcb)->flags |= TF_ACK_DELAY; \
-                         }
-
-#define tcp_ack_now(pcb) (pcb)->flags |= TF_ACK_NOW; \
-                         tcp_output(pcb)
-
-err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags);
-err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len,
-    u8_t flags, u8_t apiflags,
-                u8_t *optdata, u8_t optlen);
-
-void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
-
-void tcp_rst(u32_t seqno, u32_t ackno,
-       struct ip_addr *local_ip, struct ip_addr *remote_ip,
-       u16_t local_port, u16_t remote_port);
-
-u32_t tcp_next_iss(void);
-
-void tcp_keepalive(struct tcp_pcb *pcb);
-void tcp_zero_window_probe(struct tcp_pcb *pcb);
-
-#if TCP_CALCULATE_EFF_SEND_MSS
-u16_t tcp_eff_send_mss(u16_t sendmss, struct ip_addr *addr);
-#endif /* TCP_CALCULATE_EFF_SEND_MSS */
-
-extern struct tcp_pcb *tcp_input_pcb;
-extern u32_t tcp_ticks;
-
-#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
-void tcp_debug_print(struct tcp_hdr *tcphdr);
-void tcp_debug_print_flags(u8_t flags);
-void tcp_debug_print_state(enum tcp_state s);
-void tcp_debug_print_pcbs(void);
-s16_t tcp_pcbs_sane(void);
-#else
-#  define tcp_debug_print(tcphdr)
-#  define tcp_debug_print_flags(flags)
-#  define tcp_debug_print_state(s)
-#  define tcp_debug_print_pcbs()
-#  define tcp_pcbs_sane() 1
-#endif /* TCP_DEBUG */
-
-#if NO_SYS
-#define tcp_timer_needed()
-#else
-void tcp_timer_needed(void);
-#endif
-
-/* The TCP PCB lists. */
-union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
-  struct tcp_pcb_listen *listen_pcbs; 
-  struct tcp_pcb *pcbs;
-};
-extern union tcp_listen_pcbs_t tcp_listen_pcbs;
-extern struct tcp_pcb *tcp_active_pcbs;  /* List of all TCP PCBs that are in a
-              state in which they accept or send
-              data. */
-extern struct tcp_pcb *tcp_tw_pcbs;      /* List of all TCP PCBs in TIME-WAIT. */
-
-extern struct tcp_pcb *tcp_tmp_pcb;      /* Only used for temporary storage. */
-
-/* Axioms about the above lists:   
-   1) Every TCP PCB that is not CLOSED is in one of the lists.
-   2) A PCB is only in one of the lists.
-   3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
-   4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.
-*/
-
-/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
-   with a PCB list or removes a PCB from a list, respectively. */
-#if 0
-#define TCP_REG(pcbs, npcb) do {\
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
-                            for(tcp_tmp_pcb = *pcbs; \
-          tcp_tmp_pcb != NULL; \
-        tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                                LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
-                            } \
-                            LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
-                            npcb->next = *pcbs; \
-                            LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
-                            *(pcbs) = npcb; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-              tcp_timer_needed(); \
-                            } while(0)
-#define TCP_RMV(pcbs, npcb) do { \
-                            LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
-                            if(*pcbs == npcb) { \
-                               *pcbs = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
-                                  break; \
-                               } \
-                            } \
-                            npcb->next = NULL; \
-                            LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
-                            LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
-                            } while(0)
-
-#else /* LWIP_DEBUG */
-#define TCP_REG(pcbs, npcb) do { \
-                            npcb->next = *pcbs; \
-                            *(pcbs) = npcb; \
-              tcp_timer_needed(); \
-                            } while(0)
-#define TCP_RMV(pcbs, npcb) do { \
-                            if(*(pcbs) == npcb) { \
-                               (*(pcbs)) = (*pcbs)->next; \
-                            } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
-                               if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
-                                  tcp_tmp_pcb->next = npcb->next; \
-                                  break; \
-                               } \
-                            } \
-                            npcb->next = NULL; \
-                            } while(0)
-#endif /* LWIP_DEBUG */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_TCP */
-
-#endif /* __LWIP_TCP_H__ */
diff --git a/palacios/src/lwip/include/lwip/tcpip.h b/palacios/src/lwip/include/lwip/tcpip.h
deleted file mode 100644 (file)
index 541d28a..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_TCPIP_H__
-#define __LWIP_TCPIP_H__
-
-#include "lwip/opt.h"
-
-#if !NO_SYS /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/api_msg.h"
-#include "lwip/netifapi.h"
-#include "lwip/pbuf.h"
-#include "lwip/api.h"
-#include "lwip/sys.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if LWIP_TCPIP_CORE_LOCKING
-/** The global semaphore to lock the stack. */
-extern sys_sem_t lock_tcpip_core;
-#define LOCK_TCPIP_CORE()     sys_sem_wait(lock_tcpip_core)
-#define UNLOCK_TCPIP_CORE()   sys_sem_signal(lock_tcpip_core)
-#define TCPIP_APIMSG(m)       tcpip_apimsg_lock(m)
-#define TCPIP_APIMSG_ACK(m)
-#define TCPIP_NETIFAPI(m)     tcpip_netifapi_lock(m)
-#define TCPIP_NETIFAPI_ACK(m)
-#else
-#define LOCK_TCPIP_CORE()
-#define UNLOCK_TCPIP_CORE()
-#define TCPIP_APIMSG(m)       tcpip_apimsg(m)
-#define TCPIP_APIMSG_ACK(m)   sys_sem_signal(m->conn->op_completed)
-#define TCPIP_NETIFAPI(m)     tcpip_netifapi(m)
-#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
-#endif /* LWIP_TCPIP_CORE_LOCKING */
-
-void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
-
-#if LWIP_NETCONN
-err_t tcpip_apimsg(struct api_msg *apimsg);
-#if LWIP_TCPIP_CORE_LOCKING
-err_t tcpip_apimsg_lock(struct api_msg *apimsg);
-#endif /* LWIP_TCPIP_CORE_LOCKING */
-#endif /* LWIP_NETCONN */
-
-err_t tcpip_input(struct pbuf *p, struct netif *inp);
-
-#if LWIP_NETIF_API
-err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
-#if LWIP_TCPIP_CORE_LOCKING
-err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
-#endif /* LWIP_TCPIP_CORE_LOCKING */
-#endif /* LWIP_NETIF_API */
-
-err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
-#define tcpip_callback(f,ctx) tcpip_callback_with_block(f,ctx,1)
-
-err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
-#define tcpip_untimeout(h, arg) tcpip_timeout(0xffffffff, h, arg)
-
-enum tcpip_msg_type {
-#if LWIP_NETCONN
-  TCPIP_MSG_API,
-#endif /* LWIP_NETCONN */
-  TCPIP_MSG_INPKT,
-#if LWIP_NETIF_API
-  TCPIP_MSG_NETIFAPI,
-#endif /* LWIP_NETIF_API */
-  TCPIP_MSG_CALLBACK,
-  TCPIP_MSG_TIMEOUT
-};
-
-struct tcpip_msg {
-  enum tcpip_msg_type type;
-  sys_sem_t *sem;
-  union {
-#if LWIP_NETCONN
-    struct api_msg *apimsg;
-#endif /* LWIP_NETCONN */
-#if LWIP_NETIF_API
-    struct netifapi_msg *netifapimsg;
-#endif /* LWIP_NETIF_API */
-    struct {
-      struct pbuf *p;
-      struct netif *netif;
-    } inp;
-    struct {
-      void (*f)(void *ctx);
-      void *ctx;
-    } cb;
-    struct {
-      u32_t msecs;
-      sys_timeout_handler h;
-      void *arg;
-    } tmo;
-  } msg;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !NO_SYS */
-
-#endif /* __LWIP_TCPIP_H__ */
diff --git a/palacios/src/lwip/include/lwip/udp.h b/palacios/src/lwip/include/lwip/udp.h
deleted file mode 100644 (file)
index d7b2a38..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __LWIP_UDP_H__
-#define __LWIP_UDP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/pbuf.h"
-#include "lwip/netif.h"
-#include "lwip/ip_addr.h"
-#include "lwip/ip.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define UDP_HLEN 8
-
-/* Fields are (of course) in network byte order. */
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct udp_hdr {
-  PACK_STRUCT_FIELD(u16_t src);
-  PACK_STRUCT_FIELD(u16_t dest);  /* src/dest UDP ports */
-  PACK_STRUCT_FIELD(u16_t len);
-  PACK_STRUCT_FIELD(u16_t chksum);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#define UDP_FLAGS_NOCHKSUM 0x01U
-#define UDP_FLAGS_UDPLITE  0x02U
-#define UDP_FLAGS_CONNECTED  0x04U
-
-struct udp_pcb {
-/* Common members of all PCB types */
-  IP_PCB;
-
-/* Protocol specific PCB members */
-
-  struct udp_pcb *next;
-
-  u8_t flags;
-  /* ports are in host byte order */
-  u16_t local_port, remote_port;
-
-#if LWIP_IGMP
-  /* outgoing network interface for multicast packets */
-  struct ip_addr multicast_ip;
-#endif /* LWIP_IGMP */
-
-#if LWIP_UDPLITE
-  /* used for UDP_LITE only */
-  u16_t chksum_len_rx, chksum_len_tx;
-#endif /* LWIP_UDPLITE */
-
-  /* receive callback function
-   * addr and port are in same byte order as in the pcb
-   * The callback is responsible for freeing the pbuf
-   * if it's not used any more.
-   *
-   * @param arg user supplied argument (udp_pcb.recv_arg)
-   * @param pcb the udp_pcb which received data
-   * @param p the packet buffer that was received
-   * @param addr the remote IP address from which the packet was received
-   * @param port the remote port from which the packet was received
-   */
-  void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
-    struct ip_addr *addr, u16_t port);
-  /* user-supplied argument for the recv callback */
-  void *recv_arg;  
-};
-/* udp_pcbs export for exernal reference (e.g. SNMP agent) */
-extern struct udp_pcb *udp_pcbs;
-
-/* The following functions is the application layer interface to the
-   UDP code. */
-struct udp_pcb * udp_new        (void);
-void             udp_remove     (struct udp_pcb *pcb);
-err_t            udp_bind       (struct udp_pcb *pcb, struct ip_addr *ipaddr,
-                 u16_t port);
-err_t            udp_connect    (struct udp_pcb *pcb, struct ip_addr *ipaddr,
-                 u16_t port);
-void             udp_disconnect    (struct udp_pcb *pcb);
-void             udp_recv       (struct udp_pcb *pcb,
-         void (* recv)(void *arg, struct udp_pcb *upcb,
-                 struct pbuf *p,
-                 struct ip_addr *addr,
-                 u16_t port),
-         void *recv_arg);
-err_t            udp_sendto_if  (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif);
-err_t            udp_sendto     (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port);
-err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
-
-#define          udp_flags(pcb)  ((pcb)->flags)
-#define          udp_setflags(pcb, f)  ((pcb)->flags = (f))
-
-/* The following functions are the lower layer interface to UDP. */
-void             udp_input      (struct pbuf *p, struct netif *inp);
-
-#define udp_init() /* Compatibility define, not init needed. */
-
-#if UDP_DEBUG
-void udp_debug_print(struct udp_hdr *udphdr);
-#else
-#define udp_debug_print(udphdr)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_UDP */
-
-#endif /* __LWIP_UDP_H__ */
diff --git a/palacios/src/lwip/include/netif/etharp.h b/palacios/src/lwip/include/netif/etharp.h
deleted file mode 100644 (file)
index 2b76823..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv>
- * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-
-#ifndef __NETIF_ETHARP_H__
-#define __NETIF_ETHARP_H__
-
-#include "lwip/opt.h"
-
-#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */
-
-#include "lwip/pbuf.h"
-#include "lwip/ip_addr.h"
-#include "lwip/netif.h"
-#include "lwip/ip.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef ETH_PAD_SIZE
-#define ETH_PAD_SIZE          0
-#endif
-
-#ifndef ETHARP_HWADDR_LEN
-#define ETHARP_HWADDR_LEN     6
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct eth_addr {
-  PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct eth_hdr {
-#if ETH_PAD_SIZE
-  PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
-#endif
-  PACK_STRUCT_FIELD(struct eth_addr dest);
-  PACK_STRUCT_FIELD(struct eth_addr src);
-  PACK_STRUCT_FIELD(u16_t type);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-/** the ARP message */
-struct etharp_hdr {
-  PACK_STRUCT_FIELD(struct eth_hdr ethhdr);
-  PACK_STRUCT_FIELD(u16_t hwtype);
-  PACK_STRUCT_FIELD(u16_t proto);
-  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
-  PACK_STRUCT_FIELD(u16_t opcode);
-  PACK_STRUCT_FIELD(struct eth_addr shwaddr);
-  PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
-  PACK_STRUCT_FIELD(struct eth_addr dhwaddr);
-  PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct ethip_hdr {
-  PACK_STRUCT_FIELD(struct eth_hdr eth);
-  PACK_STRUCT_FIELD(struct ip_hdr ip);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-/** 5 seconds period */
-#define ARP_TMR_INTERVAL 5000
-
-#define ETHTYPE_ARP       0x0806
-#define ETHTYPE_IP        0x0800
-#define ETHTYPE_PPPOEDISC 0x8863  /* PPP Over Ethernet Discovery Stage */
-#define ETHTYPE_PPPOE     0x8864  /* PPP Over Ethernet Session Stage */
-
-/** ARP message types (opcodes) */
-#define ARP_REQUEST 1
-#define ARP_REPLY   2
-
-#if ARP_QUEUEING
-/** struct for queueing outgoing packets for unknown address
-  * defined here to be accessed by memp.h
-  */
-struct etharp_q_entry {
-  struct etharp_q_entry *next;
-  struct pbuf *p;
-};
-#endif /* ARP_QUEUEING */
-
-#define etharp_init() /* Compatibility define, not init needed. */
-void etharp_tmr(void);
-s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
-         struct eth_addr **eth_ret, struct ip_addr **ip_ret);
-void etharp_ip_input(struct netif *netif, struct pbuf *p);
-void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
-         struct pbuf *p);
-err_t etharp_output(struct netif *netif, struct pbuf *q, struct ip_addr *ipaddr);
-err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
-err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);
-
-err_t ethernet_input(struct pbuf *p, struct netif *netif);
-
-#if LWIP_AUTOIP
-err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
-                 const struct eth_addr *ethdst_addr,
-                 const struct eth_addr *hwsrc_addr, const struct ip_addr *ipsrc_addr,
-                 const struct eth_addr *hwdst_addr, const struct ip_addr *ipdst_addr,
-                 const u16_t opcode);
-#endif /* LWIP_AUTOIP */
-
-#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
-
-extern const struct eth_addr ethbroadcast, ethzero;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LWIP_ARP */
-
-#endif /* __NETIF_ARP_H__ */
diff --git a/palacios/src/lwip/include/netif/loopif.h b/palacios/src/lwip/include/netif/loopif.h
deleted file mode 100644 (file)
index 68fc7b3..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __NETIF_LOOPIF_H__
-#define __NETIF_LOOPIF_H__
-
-#include "lwip/netif.h"
-#include "lwip/err.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !LWIP_LOOPIF_MULTITHREADING
-void loopif_poll(struct netif *netif);
-#endif
-
-err_t loopif_init(struct netif *netif);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __NETIF_LOOPIF_H__ */
diff --git a/palacios/src/lwip/include/netif/ppp_oe.h b/palacios/src/lwip/include/netif/ppp_oe.h
deleted file mode 100644 (file)
index 3aa55ae..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*****************************************************************************
-* ppp_oe.h - PPP Over Ethernet implementation for lwIP.
-*
-* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc.
-*
-* The authors hereby grant permission to use, copy, modify, distribute,
-* and license this software and its documentation for any purpose, provided
-* that existing copyright notices are retained in all copies and that this
-* notice and the following disclaimer are included verbatim in any 
-* distributions. No written agreement, license, or royalty fee is required
-* for any of the authorized uses.
-*
-* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-******************************************************************************
-* REVISION HISTORY
-*
-* 06-01-01 Marc Boucher <marc@mbsi.ca>
-*   Ported to lwIP.
-*****************************************************************************/
-
-
-
-/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */
-
-/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Martin Husemann <martin@NetBSD.org>.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *        This product includes software developed by the NetBSD
- *        Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef PPP_OE_H
-#define PPP_OE_H
-
-#include "lwip/opt.h"
-
-#if PPPOE_SUPPORT > 0
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct pppoehdr {
-       PACK_STRUCT_FIELD(u8_t vertype);
-       PACK_STRUCT_FIELD(u8_t code);
-       PACK_STRUCT_FIELD(u16_t session);
-       PACK_STRUCT_FIELD(u16_t plen);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/bpstruct.h"
-#endif
-PACK_STRUCT_BEGIN
-struct pppoetag {
-       PACK_STRUCT_FIELD(u16_t tag);
-       PACK_STRUCT_FIELD(u16_t len);
-} PACK_STRUCT_STRUCT;
-PACK_STRUCT_END
-#ifdef PACK_STRUCT_USE_INCLUDES
-#  include "arch/epstruct.h"
-#endif
-
-
-#define PPPOE_STATE_INITIAL    0
-#define PPPOE_STATE_PADI_SENT  1
-#define        PPPOE_STATE_PADR_SENT   2
-#define        PPPOE_STATE_SESSION     3
-#define        PPPOE_STATE_CLOSING     4
-/* passive */
-#define        PPPOE_STATE_PADO_SENT   1
-
-#define PPPOE_HEADERLEN        sizeof(struct pppoehdr)
-#define        PPPOE_VERTYPE   0x11    /* VER=1, TYPE = 1 */
-
-#define        PPPOE_TAG_EOL           0x0000          /* end of list */
-#define        PPPOE_TAG_SNAME         0x0101          /* service name */
-#define        PPPOE_TAG_ACNAME        0x0102          /* access concentrator name */
-#define        PPPOE_TAG_HUNIQUE       0x0103          /* host unique */
-#define        PPPOE_TAG_ACCOOKIE      0x0104          /* AC cookie */
-#define        PPPOE_TAG_VENDOR        0x0105          /* vendor specific */
-#define        PPPOE_TAG_RELAYSID      0x0110          /* relay session id */
-#define        PPPOE_TAG_SNAME_ERR     0x0201          /* service name error */
-#define        PPPOE_TAG_ACSYS_ERR     0x0202          /* AC system error */
-#define        PPPOE_TAG_GENERIC_ERR   0x0203          /* gerneric error */
-
-#define PPPOE_CODE_PADI                0x09            /* Active Discovery Initiation */
-#define        PPPOE_CODE_PADO         0x07            /* Active Discovery Offer */
-#define        PPPOE_CODE_PADR         0x19            /* Active Discovery Request */
-#define        PPPOE_CODE_PADS         0x65            /* Active Discovery Session confirmation */
-#define        PPPOE_CODE_PADT         0xA7            /* Active Discovery Terminate */
-
-#ifndef ETHERMTU
-#define ETHERMTU 1500
-#endif
-
-/* two byte PPP protocol discriminator, then IP data */
-#define        PPPOE_MAXMTU    (ETHERMTU-PPPOE_HEADERLEN-2)
-
-struct pppoe_softc;
-
-
-void pppoe_init(void);
-
-err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr);
-err_t pppoe_destroy(struct netif *ifp);
-
-int pppoe_connect(struct pppoe_softc *sc);
-void pppoe_disconnect(struct pppoe_softc *sc);
-
-void pppoe_disc_input(struct netif *netif, struct pbuf *p);
-void pppoe_data_input(struct netif *netif, struct pbuf *p);
-
-err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb);
-
-extern int pppoe_hdrlen;
-
-#endif /* PPPOE_SUPPORT */
-
-#endif /* PPP_OE_H */
diff --git a/palacios/src/lwip/include/netif/slipif.h b/palacios/src/lwip/include/netif/slipif.h
deleted file mode 100644 (file)
index aa08ada..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2001, Swedish Institute of Computer Science.
- * All rights reserved. 
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met: 
- * 1. Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- * 2. Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in the 
- *    documentation and/or other materials provided with the distribution. 
- * 3. Neither the name of the Institute nor the names of its contributors 
- *    may be used to endorse or promote products derived from this software 
- *    without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
- * SUCH DAMAGE. 
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <adam@sics.se>
- *
- */
-#ifndef __NETIF_SLIPIF_H__
-#define __NETIF_SLIPIF_H__
-
-#include "lwip/netif.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-err_t slipif_init(struct netif * netif);
-
-#ifdef __cplusplus
-}
-#endif
-#endif 
-
index 6d48cd2..83dafd7 100644 (file)
@@ -62,7 +62,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: chap.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: chap.h,v 1.4 2007/12/19 20:47:22 fbernon Exp $
  */
 
 #ifndef CHAP_H
index 71449be..df070fb 100644 (file)
@@ -51,7 +51,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: chpms.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $
  */
 
 #ifndef CHPMS_H
index 10c5443..14034ec 100644 (file)
@@ -48,7 +48,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: fsm.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: fsm.h,v 1.4 2007/12/19 20:47:23 fbernon Exp $
  */
 
 #ifndef FSM_H
index 508c7ca..dfcf4fb 100644 (file)
@@ -48,7 +48,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: ipcp.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: ipcp.h,v 1.3 2007/12/19 20:47:23 fbernon Exp $
  */
 
 #ifndef IPCP_H
index daf351d..1a5e5a4 100644 (file)
@@ -48,7 +48,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: lcp.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: lcp.h,v 1.3 2007/12/19 20:47:23 fbernon Exp $
  */
 
 #ifndef LCP_H
index e214272..bc51749 100644 (file)
@@ -48,7 +48,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * $Id: magic.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: magic.h,v 1.2 2007/12/02 22:35:55 fbernon Exp $
  */
 
 #ifndef MAGIC_H
index 9300ce1..b9617da 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Definitions for tcp compression routines.
  *
- * $Id: vj.h,v 1.1 2008/09/12 20:16:42 jarusl Exp $
+ * $Id: vj.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $
  *
  * Copyright (c) 1989 Regents of the University of California.
  * All rights reserved.
index e4b973f..027b036 100644 (file)
@@ -1,6 +1,7 @@
 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
 
+
 #include <palacios/vmm_config.h>
 #include <palacios/vmm.h>
 #include <palacios/vmm_debug.h>
 #include <devices/8254.h>
 #include <devices/nvram.h>
 #include <devices/generic.h>
+#include <devices/ramdisk.h>
+
+
+#define USE_GENERIC 1
+#define USE_RAMDISK 1
 
 
 
@@ -62,7 +68,10 @@ int config_guest(struct guest_info * info, void * config_ptr) {
   void * region_start;
   int i;
 
-  
+  int use_ramdisk = USE_RAMDISK;
+  int use_generic = USE_GENERIC;
+
+
   v3_init_time(info);
   init_shadow_map(info);
   
@@ -158,75 +167,88 @@ int config_guest(struct guest_info * info, void * config_ptr) {
 
   
   {
-    
+    struct vm_device * ramdisk = NULL;
     struct vm_device * nvram = create_nvram();
     //struct vm_device * timer = create_timer();
     struct vm_device * pic = create_pic();
     struct vm_device * keyboard = create_keyboard();
     struct vm_device * pit = create_pit(); 
     //struct vm_device * serial = create_serial();
+    struct vm_device * generic = NULL;
+    //Zheng 09/29/2008
+
+
+    if (use_ramdisk) {
+      PrintDebug("Creating Ramdisk\n");
+      ramdisk = create_ramdisk();
+    }
     
     
-#define GENERIC 1
-    
-#if GENERIC
-    generic_port_range_type range[] = {
-#if 1
+    if (use_generic) {
+      PrintDebug("Creating Generic Device\n");
+      generic = create_generic();
+      
       // Make the DMA controller invisible
-
-      {0x00, 0x07, GENERIC_PRINT_AND_IGNORE},   // DMA 1 channels 0,1,2,3 (address, counter)
-      {0xc0, 0xc7, GENERIC_PRINT_AND_IGNORE},   // DMA 2 channels 4,5,6,7 (address, counter)
-      {0x87, 0x87, GENERIC_PRINT_AND_IGNORE},   // DMA 1 channel 0 page register
-      {0x83, 0x83, GENERIC_PRINT_AND_IGNORE},   // DMA 1 channel 1 page register
-      {0x81, 0x81, GENERIC_PRINT_AND_IGNORE},   // DMA 1 channel 2 page register
-      {0x82, 0x82, GENERIC_PRINT_AND_IGNORE},   // DMA 1 channel 3 page register
-      {0x8f, 0x8f, GENERIC_PRINT_AND_IGNORE},   // DMA 2 channel 4 page register
-      {0x8b, 0x8b, GENERIC_PRINT_AND_IGNORE},   // DMA 2 channel 5 page register
-      {0x89, 0x89, GENERIC_PRINT_AND_IGNORE},   // DMA 2 channel 6 page register
-      {0x8a, 0x8a, GENERIC_PRINT_AND_IGNORE},   // DMA 2 channel 7 page register
-      {0x08, 0x0f, GENERIC_PRINT_AND_IGNORE},   // DMA 1 misc registers (csr, req, smask,mode,clearff,reset,enable,mmask)
-      {0xd0, 0xde, GENERIC_PRINT_AND_IGNORE},   // DMA 2 misc registers
-#endif
+      v3_generic_add_port_range(generic, 0x00, 0x07, GENERIC_PRINT_AND_IGNORE);   // DMA 1 channels 0,1,2,3 (address, counter)
+      v3_generic_add_port_range(generic, 0xc0, 0xc7, GENERIC_PRINT_AND_IGNORE);   // DMA 2 channels 4,5,6,7 (address, counter)
+      v3_generic_add_port_range(generic, 0x87, 0x87, GENERIC_PRINT_AND_IGNORE);   // DMA 1 channel 0 page register
+      v3_generic_add_port_range(generic, 0x83, 0x83, GENERIC_PRINT_AND_IGNORE);   // DMA 1 channel 1 page register
+      v3_generic_add_port_range(generic, 0x81, 0x81, GENERIC_PRINT_AND_IGNORE);   // DMA 1 channel 2 page register
+      v3_generic_add_port_range(generic, 0x82, 0x82, GENERIC_PRINT_AND_IGNORE);   // DMA 1 channel 3 page register
+      v3_generic_add_port_range(generic, 0x8f, 0x8f, GENERIC_PRINT_AND_IGNORE);   // DMA 2 channel 4 page register
+      v3_generic_add_port_range(generic, 0x8b, 0x8b, GENERIC_PRINT_AND_IGNORE);   // DMA 2 channel 5 page register
+      v3_generic_add_port_range(generic, 0x89, 0x89, GENERIC_PRINT_AND_IGNORE);   // DMA 2 channel 6 page register
+      v3_generic_add_port_range(generic, 0x8a, 0x8a, GENERIC_PRINT_AND_IGNORE);   // DMA 2 channel 7 page register
+      v3_generic_add_port_range(generic, 0x08, 0x0f, GENERIC_PRINT_AND_IGNORE);   // DMA 1 misc registers (csr, req, smask,mode,clearff,reset,enable,mmask)
+      v3_generic_add_port_range(generic, 0xd0, 0xde, GENERIC_PRINT_AND_IGNORE);   // DMA 2 misc registers
+      
+      
+      
       
-
-#if 1      
       // Make the Serial ports invisible 
+      
+      v3_generic_add_port_range(generic, 0x3f8, 0x3f8+7, GENERIC_PRINT_AND_IGNORE);      // COM 1
+      v3_generic_add_port_range(generic, 0x2f8, 0x2f8+7, GENERIC_PRINT_AND_IGNORE);      // COM 2
+      
 
-      {0x3f8, 0x3f8+7, GENERIC_PRINT_AND_IGNORE},      // COM 1
-      {0x2f8, 0x2f8+7, GENERIC_PRINT_AND_IGNORE},      // COM 2
-      {0x3e8, 0x3e8+7, GENERIC_PRINT_AND_IGNORE},      // COM 3
-      {0x2e8, 0x2e8+7, GENERIC_PRINT_AND_IGNORE},      // COM 4
-#endif
+      
 
+      v3_generic_add_port_range(generic, 0x3e8, 0x3e8+7, GENERIC_PRINT_AND_IGNORE);      // COM 3
+      v3_generic_add_port_range(generic, 0x2e8, 0x2e8+7, GENERIC_PRINT_AND_IGNORE);      // COM 4
 
-#if 1
-      // Make the PCI bus invisible (at least it's configuration)
+      
+      
 
-      {0xcf8, 0xcf8, GENERIC_PRINT_AND_IGNORE}, // PCI Config Address
-      {0xcfc, 0xcfc, GENERIC_PRINT_AND_IGNORE}, // PCI Config Data
-#endif
-#if 1
+      // Make the PCI bus invisible (at least it's configuration)
+      
+      v3_generic_add_port_range(generic, 0xcf8, 0xcf8, GENERIC_PRINT_AND_IGNORE); // PCI Config Address
+      v3_generic_add_port_range(generic, 0xcfc, 0xcfc, GENERIC_PRINT_AND_IGNORE); // PCI Config Data
 
-      // Monitor the IDE controllers (very slow)
+      
+      
+#if 0
+      if (!use_ramdisk) {
+       // Monitor the IDE controllers (very slow)
+       v3_generic_add_port_range(generic, 0x170, 0x178, GENERIC_PRINT_AND_PASSTHROUGH); // IDE 1
+       v3_generic_add_port_range(generic, 0x376, 0x377, GENERIC_PRINT_AND_PASSTHROUGH); // IDE 1
+      }
+      
 
-      {0x170, 0x178, GENERIC_PRINT_AND_PASSTHROUGH}, // IDE 1
-      {0x376, 0x377, GENERIC_PRINT_AND_PASSTHROUGH}, // IDE 1
-      {0x1f0, 0x1f8, GENERIC_PRINT_AND_PASSTHROUGH}, // IDE 0
-      {0x3f6, 0x3f7, GENERIC_PRINT_AND_PASSTHROUGH}, // IDE 0
+      v3_generic_add_port_range(generic, 0x1f0, 0x1f8, GENERIC_PRINT_AND_PASSTHROUGH); // IDE 0
+      v3_generic_add_port_range(generic, 0x3f6, 0x3f7, GENERIC_PRINT_AND_PASSTHROUGH); // IDE 0
 #endif
       
-
+      
 #if 0
-
+      
       // Make the floppy controllers invisible
-
-      {0x3f0, 0x3f2, GENERIC_PRINT_AND_IGNORE}, // Primary floppy controller (base,statusa/statusb,DOR)
-      {0x3f4, 0x3f5, GENERIC_PRINT_AND_IGNORE}, // Primary floppy controller (mainstat/datarate,data)
-      {0x3f7, 0x3f7, GENERIC_PRINT_AND_IGNORE}, // Primary floppy controller (DIR)
-      {0x370, 0x372, GENERIC_PRINT_AND_IGNORE}, // Secondary floppy controller (base,statusa/statusb,DOR)
-      {0x374, 0x375, GENERIC_PRINT_AND_IGNORE}, // Secondary floppy controller (mainstat/datarate,data)
-      {0x377, 0x377, GENERIC_PRINT_AND_IGNORE}, // Secondary floppy controller (DIR)
+      
+      v3_generic_add_port_range(generic, 0x3f0, 0x3f2, GENERIC_PRINT_AND_IGNORE); // Primary floppy controller (base,statusa/statusb,DOR)
+      v3_generic_add_port_range(generic, 0x3f4, 0x3f5, GENERIC_PRINT_AND_IGNORE); // Primary floppy controller (mainstat/datarate,data)
+      v3_generic_add_port_range(generic, 0x3f7, 0x3f7, GENERIC_PRINT_AND_IGNORE); // Primary floppy controller (DIR)
+      v3_generic_add_port_range(generic, 0x370, 0x372, GENERIC_PRINT_AND_IGNORE); // Secondary floppy controller (base,statusa/statusb,DOR)
+      v3_generic_add_port_range(generic, 0x374, 0x375, GENERIC_PRINT_AND_IGNORE); // Secondary floppy controller (mainstat/datarate,data)
+      v3_generic_add_port_range(generic, 0x377, 0x377, GENERIC_PRINT_AND_IGNORE); // Secondary floppy controller (DIR)
       
 #endif
 
@@ -234,7 +256,7 @@ int config_guest(struct guest_info * info, void * config_ptr) {
 
       // Make the parallel port invisible
       
-      {0x378, 0x37f, GENERIC_PRINT_AND_IGNORE},
+      v3_generic_add_port_range(generic, 0x378, 0x37f, GENERIC_PRINT_AND_IGNORE);
 
 #endif
 
@@ -242,8 +264,8 @@ int config_guest(struct guest_info * info, void * config_ptr) {
 
       // Monitor graphics card operations
 
-      {0x3b0, 0x3bb, GENERIC_PRINT_AND_PASSTHROUGH},
-      {0x3c0, 0x3df, GENERIC_PRINT_AND_PASSTHROUGH},
+      v3_generic_add_port_range(generic, 0x3b0, 0x3bb, GENERIC_PRINT_AND_PASSTHROUGH);
+      v3_generic_add_port_range(generic, 0x3c0, 0x3df, GENERIC_PRINT_AND_PASSTHROUGH);
       
 #endif
 
@@ -251,36 +273,31 @@ int config_guest(struct guest_info * info, void * config_ptr) {
 #if 1
       // Make the ISA PNP features invisible
 
-      {0x274, 0x277, GENERIC_PRINT_AND_IGNORE},
-      {0x279, 0x279, GENERIC_PRINT_AND_IGNORE},
-      {0xa79, 0xa79, GENERIC_PRINT_AND_IGNORE},
+      v3_generic_add_port_range(generic, 0x274, 0x277, GENERIC_PRINT_AND_IGNORE);
+      v3_generic_add_port_range(generic, 0x279, 0x279, GENERIC_PRINT_AND_IGNORE);
+      v3_generic_add_port_range(generic, 0xa79, 0xa79, GENERIC_PRINT_AND_IGNORE);
 #endif
 
 
 #if 1
       // Monitor any network card (realtek ne2000) operations 
-      {0xc100, 0xc1ff, GENERIC_PRINT_AND_PASSTHROUGH},
+      v3_generic_add_port_range(generic, 0xc100, 0xc1ff, GENERIC_PRINT_AND_PASSTHROUGH);
 #endif
 
 
 #if 1
       // Make any Bus master ide controller invisible
       
-      {0xc000, 0xc00f, GENERIC_PRINT_AND_IGNORE},
+      v3_generic_add_port_range(generic, 0xc000, 0xc00f, GENERIC_PRINT_AND_IGNORE);
 #endif
-
-
-      //         {0x378, 0x400, GENERIC_PRINT_AND_IGNORE}
       
-      {0,0,0},  // sentinal - must be last
+    }
+      //  v3_generic_add_port_range(generic, 0x378, 0x400, GENERIC_PRINT_AND_IGNORE);
       
-    };
-    
 
-    struct vm_device * generic = create_generic(range, NULL, NULL);
-    
-#endif
+
     
+
     v3_attach_device(info, nvram);
     //v3_attach_device(info, timer);
     v3_attach_device(info, pic);
@@ -288,12 +305,14 @@ int config_guest(struct guest_info * info, void * config_ptr) {
     v3_attach_device(info, keyboard);
     // v3_attach_device(info, serial);
 
+    if (use_ramdisk) {
+      v3_attach_device(info, ramdisk);
+    }
 
-#if GENERIC
-    // Important that this be attached last!
-    v3_attach_device(info, generic);
-    
-#endif
+    if (use_generic) {
+      // Important that this be attached last!
+      v3_attach_device(info, generic);
+    }
     
     PrintDebugDevMgr(info);
   }
@@ -302,19 +321,19 @@ int config_guest(struct guest_info * info, void * config_ptr) {
   // no longer needed since we have a keyboard device
   //hook_irq(&vm_info, 1);
   
-#if 1
+#if 0
   // give floppy controller to vm
   v3_hook_irq_for_guest_injection(info, 6);
 #endif
   
-#if 1
-  //primary ide
-  v3_hook_irq_for_guest_injection(info, 14);
-  
-  // secondary ide
-  v3_hook_irq_for_guest_injection(info, 15);
-#endif
+
+  if (!use_ramdisk) {
+    //primary ide
+    v3_hook_irq_for_guest_injection(info, 14);
   
+    // secondary ide
+    v3_hook_irq_for_guest_injection(info, 15);    
+  }  
 
   //v3_hook_io_port(info, 1234, &IO_Read, NULL, info);
 
index 242d63b..431b58c 100644 (file)
@@ -149,13 +149,14 @@ int v3_lower_irq(struct guest_info * info, int irq) {
 
   PrintDebug("[v3_lower_irq]\n");
 
-  //  if ((info->intr_state.controller) && 
-  //  (info->intr_state.controller->raise_intr)) {
+  if ((info->intr_state.controller) && 
+      (info->intr_state.controller->raise_intr)) {
     info->intr_state.controller->lower_intr(info->intr_state.controller_state, irq);
-    //} else {
-    // PrintDebug("There is no registered Interrupt Controller... (NULL POINTER)\n");
-    // return -1;
-    //}
+  } else {
+    PrintDebug("There is no registered Interrupt Controller... (NULL POINTER)\n");
+    return -1;
+  }
+
   return 0;
 }
 
@@ -167,13 +168,14 @@ int v3_raise_irq(struct guest_info * info, int irq) {
 
   PrintDebug("[v3_raise_irq]\n");
 
-  //  if ((info->intr_state.controller) && 
-  //  (info->intr_state.controller->raise_intr)) {
+  if ((info->intr_state.controller) && 
+      (info->intr_state.controller->raise_intr)) {
     info->intr_state.controller->raise_intr(info->intr_state.controller_state, irq);
-    //} else {
-    // PrintDebug("There is no registered Interrupt Controller... (NULL POINTER)\n");
-    // return -1;
-    //}
+  } else {
+    PrintDebug("There is no registered Interrupt Controller... (NULL POINTER)\n");
+    return -1;
+  }
+
   return 0;
 }