direct-io.hg

changeset 4377:6234d6fd8618

bitkeeper revision 1.1236.1.157 (424a5bd9vDVxqBGBnc7AKIyONvJCyQ)

[PATCH] ioemu-x86-64-fixes.patch

Make ioemu compile on x86-64.

Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author arun.sharma@intel.com[kaf24]
date Wed Mar 30 07:57:13 2005 +0000 (2005-03-30)
parents c3e543f81772
children 89abc2bc14bb
files tools/ioemu/iodev/Makefile tools/ioemu/iodev/cpu.cc tools/ioemu/iodev/eth_linux.cc tools/ioemu/memory/memory.cc tools/ioemu/memory/memory.h
line diff
     1.1 --- a/tools/ioemu/iodev/Makefile	Wed Mar 30 07:57:09 2005 +0000
     1.2 +++ b/tools/ioemu/iodev/Makefile	Wed Mar 30 07:57:13 2005 +0000
     1.3 @@ -1,8 +1,11 @@
     1.4 +XEN_ROOT= ../../../
     1.5 +include $(XEN_ROOT)/tools/Rules.mk
     1.6 + 
     1.7  TOPDIR= ..
     1.8  CXXFLAGS=-I. -I../include -I..
     1.9  OBJS=$(patsubst %.cc,%.o,$(wildcard *.cc))
    1.10  BXLIBS = ../gui/libgui.a ../memory/libmemory.a  
    1.11 -LDLIBS= $(BXLIBS) -L/usr/X11R6/lib -lX11 -lXpm -lstdc++ -L ../../../tools/libxc -L ../../../tools/libxutil -lxc -lxutil -lpthread -lncurses
    1.12 +LDLIBS= $(BXLIBS) $(X11_LDPATH) -lX11 -lXpm -lstdc++ -L../../../tools/libxc -L../../../tools/libxutil -lxc -lxutil -lpthread -lncurses 
    1.13  
    1.14  all: device-model
    1.15  
     2.1 --- a/tools/ioemu/iodev/cpu.cc	Wed Mar 30 07:57:09 2005 +0000
     2.2 +++ b/tools/ioemu/iodev/cpu.cc	Wed Mar 30 07:57:13 2005 +0000
     2.3 @@ -102,20 +102,20 @@ void bx_cpu_c::dispatch_ioreq(ioreq_t *r
     2.4  
     2.5  				for (i = 0; i < req->count; i++) {
     2.6  					tmp = BX_INP(req->addr, req->size);
     2.7 -					BX_MEM_WRITE_PHYSICAL((Bit32u) req->u.pdata + (sign * i * req->size), 
     2.8 +					BX_MEM_WRITE_PHYSICAL((dma_addr_t) req->u.pdata + (sign * i * req->size), 
     2.9  							       req->size, &tmp);
    2.10  				}
    2.11  			}
    2.12  		} else if(req->dir == IOREQ_WRITE) {
    2.13  			if (!req->pdata_valid) {
    2.14 -				BX_OUTP(req->addr, (Bit32u) req->u.data, req->size);
    2.15 +				BX_OUTP(req->addr, (dma_addr_t) req->u.data, req->size);
    2.16  			} else {
    2.17  				for (i = 0; i < req->count; i++) {
    2.18  					unsigned long tmp;
    2.19  
    2.20 -					BX_MEM_READ_PHYSICAL((Bit32u) req->u.pdata + (sign * i * req->size), req->size, 
    2.21 +					BX_MEM_READ_PHYSICAL((dma_addr_t) req->u.pdata + (sign * i * req->size), req->size, 
    2.22  							 &tmp);
    2.23 -					BX_OUTP(req->addr, (Bit32u) tmp, req->size);
    2.24 +					BX_OUTP(req->addr, (dma_addr_t) tmp, req->size);
    2.25  				}
    2.26  			}
    2.27  			
    2.28 @@ -133,12 +133,12 @@ void bx_cpu_c::dispatch_ioreq(ioreq_t *r
    2.29  				//BX_INFO(("<READ>addr:%llx, pdata:%llx, size: %x, count: %x\n", req->addr, req->u.pdata, req->size, req->count));
    2.30  				for (i = 0; i < req->count; i++) {
    2.31  					BX_MEM_READ_PHYSICAL(req->addr + (sign * i * req->size), req->size, &tmp);
    2.32 -					BX_MEM_WRITE_PHYSICAL((Bit32u) req->u.pdata + (sign * i * req->size), req->size, &tmp);
    2.33 +					BX_MEM_WRITE_PHYSICAL((dma_addr_t) req->u.pdata + (sign * i * req->size), req->size, &tmp);
    2.34  				}
    2.35  			} else if (req->dir == IOREQ_WRITE) {
    2.36  				//BX_INFO(("<WRITE>addr:%llx, pdata:%llx, size: %x, count: %x\n", req->addr, req->u.pdata, req->size, req->count));
    2.37  				for (i = 0; i < req->count; i++) {
    2.38 -					BX_MEM_READ_PHYSICAL((Bit32u)req->u.pdata + (sign * i * req->size), req->size, &tmp);
    2.39 +					BX_MEM_READ_PHYSICAL((dma_addr_t)req->u.pdata + (sign * i * req->size), req->size, &tmp);
    2.40  					BX_MEM_WRITE_PHYSICAL(req->addr + (sign * i * req->size), req->size, &tmp);
    2.41  				}
    2.42  			}
    2.43 @@ -245,6 +245,7 @@ bx_cpu_c::cpu_loop(int max_instr_count)
    2.44  	}
    2.45  }
    2.46  
    2.47 +#ifdef __i386__
    2.48  static __inline__ void set_bit(long nr, volatile void *addr)
    2.49  {
    2.50  	__asm__ __volatile__( "lock ; "
    2.51 @@ -254,6 +255,18 @@ static __inline__ void set_bit(long nr, 
    2.52  
    2.53  	return;
    2.54  }
    2.55 +#else 
    2.56 +/* XXX: clean for IPF */
    2.57 +static __inline__ void set_bit(long nr, volatile void *addr)
    2.58 +{
    2.59 +	__asm__ __volatile__( "lock ; "
    2.60 +		"btsq %1,%0"
    2.61 +		:"=m" ((*(volatile long *)addr))
    2.62 +		:"Ir" (nr));
    2.63 +
    2.64 +	return;
    2.65 +}
    2.66 +#endif
    2.67  
    2.68  void
    2.69  bx_cpu_c::interrupt(Bit8u vector)
     3.1 --- a/tools/ioemu/iodev/eth_linux.cc	Wed Mar 30 07:57:09 2005 +0000
     3.2 +++ b/tools/ioemu/iodev/eth_linux.cc	Wed Mar 30 07:57:13 2005 +0000
     3.3 @@ -212,7 +212,7 @@ bx_linux_pktmover_c::bx_linux_pktmover_c
     3.4    this->filter[3].k = (macaddr[0] & 0xff) << 8 | (macaddr[1] & 0xff);
     3.5    fp.len = BX_LSF_ICNT;
     3.6    fp.filter = this->filter;
     3.7 -  BX_INFO(("eth_linux: fp.len=%d fp.filter=%x", fp.len, (unsigned) fp.filter));
     3.8 +  BX_INFO(("eth_linux: fp.len=%d fp.filter=%x", fp.len, (unsigned long) fp.filter));
     3.9    if (setsockopt(this->fd, SOL_SOCKET, SO_ATTACH_FILTER, &fp, sizeof(fp)) < 0) {
    3.10      BX_PANIC(("eth_linux: could not set socket filter: %s", strerror(errno)));
    3.11      close(this->fd);
     4.1 --- a/tools/ioemu/memory/memory.cc	Wed Mar 30 07:57:09 2005 +0000
     4.2 +++ b/tools/ioemu/memory/memory.cc	Wed Mar 30 07:57:13 2005 +0000
     4.3 @@ -36,7 +36,7 @@
     4.4  #if BX_PROVIDE_CPU_MEMORY
     4.5  
     4.6    void BX_CPP_AttrRegparmN(3)
     4.7 -BX_MEM_C::writePhysicalPage(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
     4.8 +BX_MEM_C::writePhysicalPage(BX_CPU_C *cpu, dma_addr_t addr, unsigned len, void *data)
     4.9  {
    4.10    Bit8u *data_ptr;
    4.11    Bit32u a20addr;
    4.12 @@ -235,7 +235,7 @@ inc_one:
    4.13  
    4.14  
    4.15    void BX_CPP_AttrRegparmN(3)
    4.16 -BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
    4.17 +BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, dma_addr_t addr, unsigned len, void *data)
    4.18  {
    4.19    Bit8u *data_ptr;
    4.20    Bit32u a20addr;
     5.1 --- a/tools/ioemu/memory/memory.h	Wed Mar 30 07:57:09 2005 +0000
     5.2 +++ b/tools/ioemu/memory/memory.h	Wed Mar 30 07:57:13 2005 +0000
     5.3 @@ -37,6 +37,12 @@
     5.4  #  define BX_MEM_THIS this->
     5.5  #endif
     5.6  
     5.7 +#if defined(__i386__)
     5.8 +typedef Bit32u dma_addr_t;
     5.9 +#elif defined(__x86_64__)
    5.10 +typedef Bit64u dma_addr_t;
    5.11 +#endif
    5.12 +
    5.13  // alignment of memory vector, must be a power of 2
    5.14  #define BX_MEM_VECTOR_ALIGN 4096
    5.15  
    5.16 @@ -64,9 +70,9 @@ public:
    5.17    ~BX_MEM_C(void);
    5.18    BX_MEM_SMF void    alloc_vector_aligned (size_t bytes, size_t alignment) BX_CPP_AttrRegparmN(2);
    5.19    BX_MEM_SMF void    init_memory(int memsize);
    5.20 -  BX_MEM_SMF void    readPhysicalPage(BX_CPU_C *cpu, Bit32u addr,
    5.21 +  BX_MEM_SMF void    readPhysicalPage(BX_CPU_C *cpu, dma_addr_t addr,
    5.22                                        unsigned len, void *data) BX_CPP_AttrRegparmN(3);
    5.23 -  BX_MEM_SMF void    writePhysicalPage(BX_CPU_C *cpu, Bit32u addr,
    5.24 +  BX_MEM_SMF void    writePhysicalPage(BX_CPU_C *cpu, dma_addr_t addr,
    5.25                                         unsigned len, void *data) BX_CPP_AttrRegparmN(3);
    5.26    BX_MEM_SMF void    load_ROM(const char *path, Bit32u romaddress, Bit8u type);
    5.27    BX_MEM_SMF Bit32u  get_memory_in_k(void);