Add 32-bit support for Gxemul's oldtestmips machine emulation

Original work by: kan@
This commit is contained in:
Oleksandr Tymoshenko 2013-09-04 20:34:36 +00:00
parent a9e5c5a364
commit 3b15395e04
6 changed files with 107 additions and 7 deletions

View File

@ -99,18 +99,16 @@ static void gxemul_cons_timeout(void *);
* XXXRW: Should be using FreeBSD's bus routines here, but they are not
* available until later in the boot.
*/
typedef uint64_t paddr_t;
typedef uint64_t vaddr_t;
static inline vaddr_t
mips_phys_to_uncached(paddr_t phys)
static inline vm_offset_t
mips_phys_to_uncached(vm_paddr_t phys)
{
return (MIPS_PHYS_TO_DIRECT_UNCACHED(phys));
}
static inline uint8_t
mips_ioread_uint8(vaddr_t vaddr)
mips_ioread_uint8(vm_offset_t vaddr)
{
uint8_t v;
@ -119,7 +117,7 @@ mips_ioread_uint8(vaddr_t vaddr)
}
static inline void
mips_iowrite_uint8(vaddr_t vaddr, uint8_t v)
mips_iowrite_uint8(vm_offset_t vaddr, uint8_t v)
{
__asm__ __volatile__ ("sb %0, 0(%1)" : : "r" (v), "r" (vaddr));

View File

@ -214,7 +214,14 @@ gxemul_disk_read(unsigned diskid, void *buf, off_t off)
if (off < 0 || off % GXEMUL_DISK_DEV_BLOCKSIZE != 0)
return (EINVAL);
#ifdef _LP64
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET, (uint64_t)off);
#else
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_LO,
(uint32_t)(off & 0xffffffff));
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_HI,
(uint32_t)((off >> 32) & 0xffffffff));
#endif
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_DISKID, diskid);
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_START, GXEMUL_DISK_DEV_START_READ);
switch (GXEMUL_DISK_DEV_READ(GXEMUL_DISK_DEV_STATUS)) {
@ -280,7 +287,15 @@ gxemul_disk_write(unsigned diskid, const void *buf, off_t off)
if (off < 0 || off % GXEMUL_DISK_DEV_BLOCKSIZE != 0)
return (EINVAL);
#ifdef _LP64
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET, (uint64_t)off);
#else
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_LO,
(uint32_t)(off & 0xffffffff));
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_OFFSET_HI,
(uint32_t)((off >> 32) & 0xffffffff));
#endif
GXEMUL_DISK_DEV_WRITE(GXEMUL_DISK_DEV_DISKID, diskid);
dst = GXEMUL_DISK_DEV_FUNCTION(GXEMUL_DISK_DEV_BLOCK);

View File

@ -36,16 +36,28 @@
#define GXEMUL_DISK_DEV_ID_START (0x0000)
#define GXEMUL_DISK_DEV_ID_END (0x0100)
#ifdef _LP64
#define GXEMUL_DISK_DEV_OFFSET (0x0000)
#else
#define GXEMUL_DISK_DEV_OFFSET_LO (0x0000)
#define GXEMUL_DISK_DEV_OFFSET_HI (0x0008)
#endif
#define GXEMUL_DISK_DEV_DISKID (0x0010)
#define GXEMUL_DISK_DEV_START (0x0020)
#define GXEMUL_DISK_DEV_STATUS (0x0030)
#define GXEMUL_DISK_DEV_BLOCK (0x4000)
#ifdef _LP64
#define GXEMUL_DISK_DEV_FUNCTION(f) \
(volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_DISK_DEV_BASE + (f))
#define GXEMUL_DISK_DEV_READ(f) \
(volatile uint64_t)*GXEMUL_DISK_DEV_FUNCTION(f)
#else
#define GXEMUL_DISK_DEV_FUNCTION(f) \
(volatile uint32_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_DISK_DEV_BASE + (f))
#define GXEMUL_DISK_DEV_READ(f) \
(volatile uint32_t)*GXEMUL_DISK_DEV_FUNCTION(f)
#endif
#define GXEMUL_DISK_DEV_WRITE(f, v) \
*GXEMUL_DISK_DEV_FUNCTION(f) = (v)

View File

@ -40,10 +40,17 @@
#define GXEMUL_ETHER_DEV_COMMAND (0x4020)
#define GXEMUL_ETHER_DEV_MAC (0x4040)
#ifdef _LP64
#define GXEMUL_ETHER_DEV_FUNCTION(f) \
(volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_ETHER_DEV_BASE + (f))
#define GXEMUL_ETHER_DEV_READ(f) \
(volatile uint64_t)*GXEMUL_ETHER_DEV_FUNCTION(f)
#else
#define GXEMUL_ETHER_DEV_FUNCTION(f) \
(volatile uint32_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_ETHER_DEV_BASE + (f))
#define GXEMUL_ETHER_DEV_READ(f) \
(volatile uint32_t)*GXEMUL_ETHER_DEV_FUNCTION(f)
#endif
#define GXEMUL_ETHER_DEV_WRITE(f, v) \
*GXEMUL_ETHER_DEV_FUNCTION(f) = (v)

61
sys/mips/conf/GXEMUL32 Normal file
View File

@ -0,0 +1,61 @@
#
# GXEMUL "oldtestmips" sample kernel configuration.
#
# $FreeBSD$
#
ident GXEMUL
machine mips mips
cpu CPU_MIPS4KC
options HZ=100
makeoptions KERNLOADADDR=0x80100000
include "../gxemul/std.gxemul"
hints "GXEMUL.hints" #Default places to look for devices.
makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
makeoptions MODULES_OVERRIDE=""
options DDB
options KDB
# Make an SMP-capable kernel by default
options SMP # Symmetric MultiProcessor Kernel
options SCHED_ULE
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options FFS #Berkeley Fast Filesystem
# Debugging for use in -current
#options DEADLKRES #Enable the deadlock resolver
options INVARIANTS #Enable calls of extra sanity checking
options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS #Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed
options ROOTDEVNAME=\"ufs:gxemul_disk0\"
device gxemul_cons
device gxemul_disk
device gxemul_ether
# Pseudo devices.
device loop # Network loopback
device random # Entropy device
device ether # Ethernet support
device tun # Packet tunnel.
device md # Memory "disks"
device gif # IPv6 and IPv4 tunneling
device faith # IPv6-to-IPv4 relaying (translation)
# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
device bpf # Berkeley packet filter

View File

@ -43,10 +43,17 @@
#define GXEMUL_MP_DEV_IPI_READ 0x00c0
#define GXEMUL_MP_DEV_CYCLES 0x00d0
#ifdef _LP64
#define GXEMUL_MP_DEV_FUNCTION(f) \
(volatile uint64_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_MP_DEV_BASE + (f))
#define GXEMUL_MP_DEV_READ(f) \
(volatile uint64_t)*GXEMUL_MP_DEV_FUNCTION(f)
#else
#define GXEMUL_MP_DEV_FUNCTION(f) \
(volatile uint32_t *)MIPS_PHYS_TO_DIRECT_UNCACHED(GXEMUL_MP_DEV_BASE + (f))
#define GXEMUL_MP_DEV_READ(f) \
(volatile uint32_t)*GXEMUL_MP_DEV_FUNCTION(f)
#endif
#define GXEMUL_MP_DEV_WRITE(f, v) \
*GXEMUL_MP_DEV_FUNCTION(f) = (v)