Merge zizzer.eecs.umich.edu:/z/m5/Bitkeeper/m5
into zizzer.eecs.umich.edu:/z/stever/bk/m5 --HG-- extra : convert_revision : aac76a4b82b3455620618bba6238507248cc68cc
This commit is contained in:
69
SConscript
69
SConscript
@@ -43,12 +43,12 @@ Import('env')
|
||||
|
||||
# Base sources used by all configurations.
|
||||
base_sources = Split('''
|
||||
targetarch/decoder.cc
|
||||
targetarch/fast_cpu_exec.cc
|
||||
targetarch/simple_cpu_exec.cc
|
||||
targetarch/full_cpu_exec.cc
|
||||
targetarch/faults.cc
|
||||
targetarch/isa_traits.cc
|
||||
arch/alpha/decoder.cc
|
||||
arch/alpha/fast_cpu_exec.cc
|
||||
arch/alpha/simple_cpu_exec.cc
|
||||
arch/alpha/full_cpu_exec.cc
|
||||
arch/alpha/faults.cc
|
||||
arch/alpha/isa_traits.cc
|
||||
|
||||
base/circlebuf.cc
|
||||
base/copyright.cc
|
||||
@@ -237,12 +237,12 @@ mysql_sources = Split('''
|
||||
|
||||
# Full-system sources
|
||||
full_system_sources = Split('''
|
||||
targetarch/alpha_memory.cc
|
||||
targetarch/arguments.cc
|
||||
targetarch/ev5.cc
|
||||
targetarch/osfpal.cc
|
||||
targetarch/pseudo_inst.cc
|
||||
targetarch/vtophys.cc
|
||||
arch/alpha/alpha_memory.cc
|
||||
arch/alpha/arguments.cc
|
||||
arch/alpha/ev5.cc
|
||||
arch/alpha/osfpal.cc
|
||||
arch/alpha/pseudo_inst.cc
|
||||
arch/alpha/vtophys.cc
|
||||
|
||||
base/crc.cc
|
||||
base/inet.cc
|
||||
@@ -310,9 +310,9 @@ full_system_sources = Split('''
|
||||
''')
|
||||
|
||||
full_system_obj_desc_files = Split('''
|
||||
targetarch/AlphaDTB.od
|
||||
targetarch/AlphaITB.od
|
||||
targetarch/AlphaTLB.od
|
||||
arch/alpha/AlphaDTB.od
|
||||
arch/alpha/AlphaITB.od
|
||||
arch/alpha/AlphaTLB.od
|
||||
dev/AlphaConsole.od
|
||||
dev/ConsoleListener.od
|
||||
dev/CowDiskImage.od
|
||||
@@ -349,9 +349,9 @@ full_system_obj_desc_files = Split('''
|
||||
|
||||
# Syscall emulation (non-full-system) sources
|
||||
syscall_emulation_sources = Split('''
|
||||
targetarch/alpha_common_syscall_emul.cc
|
||||
targetarch/alpha_linux_process.cc
|
||||
targetarch/alpha_tru64_process.cc
|
||||
arch/alpha/alpha_common_syscall_emul.cc
|
||||
arch/alpha/alpha_linux_process.cc
|
||||
arch/alpha/alpha_tru64_process.cc
|
||||
cpu/memtest/memtest.cc
|
||||
cpu/trace/opt_cpu.cc
|
||||
cpu/trace/trace_cpu.cc
|
||||
@@ -370,46 +370,31 @@ syscall_emulation_obj_desc_files = Split('''
|
||||
''')
|
||||
|
||||
targetarch_files = Split('''
|
||||
alpha_common_syscall_emul.cc
|
||||
alpha_common_syscall_emul.hh
|
||||
AlphaDTB.od
|
||||
AlphaITB.od
|
||||
alpha_linux_process.cc
|
||||
alpha_linux_process.hh
|
||||
alpha_memory.cc
|
||||
alpha_memory.hh
|
||||
AlphaTLB.od
|
||||
alpha_tru64_process.cc
|
||||
alpha_tru64_process.hh
|
||||
aout_machdep.h
|
||||
arguments.cc
|
||||
arguments.hh
|
||||
byte_swap.hh
|
||||
ecoff_machdep.h
|
||||
elf_machdep.h
|
||||
ev5.cc
|
||||
ev5.hh
|
||||
faults.cc
|
||||
faults.hh
|
||||
isa_desc
|
||||
isa_fullsys_traits.hh
|
||||
isa_traits.cc
|
||||
isa_traits.hh
|
||||
machine_exo.h
|
||||
osfpal.cc
|
||||
osfpal.hh
|
||||
pmap.h
|
||||
pseudo_inst.cc
|
||||
pseudo_inst.hh
|
||||
PseudoInsts.pd
|
||||
syscalls.hh
|
||||
vptr.hh
|
||||
vtophys.cc
|
||||
vtophys.hh
|
||||
''')
|
||||
|
||||
for f in targetarch_files:
|
||||
env.Command('targetarch/' + f, 'arch/alpha/' + f, 'cp $SOURCE $TARGET')
|
||||
env.Command('targetarch/' + f, 'arch/alpha/' + f,
|
||||
'''echo '#include "arch/alpha/%s"' > $TARGET''' % f)
|
||||
|
||||
|
||||
# Set up complete list of sources based on configuration.
|
||||
@@ -450,14 +435,14 @@ env.Command(Split('base/traceflags.hh base/traceflags.cc'),
|
||||
'python $SOURCE $TARGET.base')
|
||||
|
||||
# several files are generated from arch/$TARGET_ISA/isa_desc.
|
||||
env.Command(Split('''targetarch/decoder.cc
|
||||
targetarch/decoder.hh
|
||||
targetarch/fast_cpu_exec.cc
|
||||
targetarch/simple_cpu_exec.cc
|
||||
targetarch/full_cpu_exec.cc'''),
|
||||
Split('''targetarch/isa_desc
|
||||
env.Command(Split('''arch/alpha/decoder.cc
|
||||
arch/alpha/decoder.hh
|
||||
arch/alpha/fast_cpu_exec.cc
|
||||
arch/alpha/simple_cpu_exec.cc
|
||||
arch/alpha/full_cpu_exec.cc'''),
|
||||
Split('''arch/alpha/isa_desc
|
||||
arch/isa_parser.py'''),
|
||||
'$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir targetarch')
|
||||
'$SRCDIR/arch/isa_parser.py $SOURCE $TARGET.dir arch/alpha')
|
||||
|
||||
|
||||
# libelf build is described in its own SConscript file.
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "arch/alpha/alpha_memory.hh"
|
||||
#include "arch/alpha/ev5.hh"
|
||||
#include "base/inifile.hh"
|
||||
#include "base/str.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/exec_context.hh"
|
||||
#include "sim/builder.hh"
|
||||
#include "targetarch/alpha_memory.hh"
|
||||
#include "targetarch/ev5.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "arch/alpha/arguments.hh"
|
||||
#include "arch/alpha/vtophys.hh"
|
||||
#include "cpu/exec_context.hh"
|
||||
#include "mem/functional_mem/physical_memory.hh"
|
||||
#include "targetarch/arguments.hh"
|
||||
#include "targetarch/vtophys.hh"
|
||||
|
||||
AlphaArguments::Data::~Data()
|
||||
{
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "arch/alpha/vtophys.hh"
|
||||
#include "base/refcnt.hh"
|
||||
#include "sim/host.hh"
|
||||
#include "targetarch/vtophys.hh"
|
||||
|
||||
class ExecContext;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "targetarch/faults.hh"
|
||||
#include "arch/alpha/faults.hh"
|
||||
|
||||
namespace {
|
||||
const char *
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#ifndef __ISA_TRAITS_HH__
|
||||
#define __ISA_TRAITS_HH__
|
||||
|
||||
#include "sim/host.hh"
|
||||
#include "targetarch/faults.hh"
|
||||
#include "arch/alpha/faults.hh"
|
||||
#include "base/misc.hh"
|
||||
#include "sim/host.hh"
|
||||
|
||||
class FastCPU;
|
||||
class FullCPU;
|
||||
@@ -125,7 +125,7 @@ class AlphaISA
|
||||
|
||||
typedef uint64_t InternalProcReg;
|
||||
|
||||
#include "targetarch/isa_fullsys_traits.hh"
|
||||
#include "arch/alpha/isa_fullsys_traits.hh"
|
||||
|
||||
#else
|
||||
enum {
|
||||
@@ -278,7 +278,7 @@ const int NumInterruptLevels = TheISA::NumInterruptLevels;
|
||||
|
||||
// more stuff that should be imported here, but I'm too tired to do it
|
||||
// right now...
|
||||
#include "targetarch/ev5.hh"
|
||||
#include "arch/alpha/ev5.hh"
|
||||
#endif
|
||||
|
||||
#endif // __ALPHA_ISA_H__
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "targetarch/osfpal.hh"
|
||||
#include "arch/alpha/osfpal.hh"
|
||||
|
||||
namespace {
|
||||
const char *strings[PAL::NumCodes] = {
|
||||
|
||||
@@ -28,61 +28,47 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "targetarch/pmap.h"
|
||||
|
||||
#include "arch/alpha/vtophys.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "cpu/exec_context.hh"
|
||||
#include "mem/functional_mem/physical_memory.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "targetarch/vtophys.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
inline Addr
|
||||
level3_index(Addr vaddr)
|
||||
{ return (vaddr >> ALPHA_PGSHIFT) & PTEMASK; }
|
||||
|
||||
inline Addr
|
||||
level2_index(Addr vaddr)
|
||||
{ return (vaddr >> (ALPHA_PGSHIFT + NPTEPG_SHIFT)) & PTEMASK; }
|
||||
|
||||
inline Addr
|
||||
level1_index(Addr vaddr)
|
||||
{ return (vaddr >> (ALPHA_PGSHIFT + 2 * NPTEPG_SHIFT)) & PTEMASK; }
|
||||
|
||||
Addr
|
||||
kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, Addr vaddr)
|
||||
AlphaISA::PageTableEntry
|
||||
kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, AlphaISA::VAddr vaddr)
|
||||
{
|
||||
uint64_t level1_map = ptbr;
|
||||
Addr level1_pte = level1_map + (level1_index(vaddr) << PTESHIFT);
|
||||
|
||||
uint64_t level1 = pmem->phys_read_qword(level1_pte);
|
||||
if (!entry_valid(level1)) {
|
||||
Addr level1_pte = ptbr + vaddr.level1();
|
||||
AlphaISA::PageTableEntry level1 = pmem->phys_read_qword(level1_pte);
|
||||
if (!level1.valid()) {
|
||||
DPRINTF(VtoPhys, "level 1 PTE not valid, va = %#\n", vaddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t level2_map = PMAP_PTE_PA(level1);
|
||||
Addr level2_pte = level2_map + (level2_index(vaddr) << PTESHIFT);
|
||||
uint64_t level2 = pmem->phys_read_qword(level2_pte);
|
||||
if (!entry_valid(level2)) {
|
||||
Addr level2_pte = level1.paddr() + vaddr.level2();
|
||||
AlphaISA::PageTableEntry level2 = pmem->phys_read_qword(level2_pte);
|
||||
if (!level2.valid()) {
|
||||
DPRINTF(VtoPhys, "level 2 PTE not valid, va = %#x\n", vaddr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t level3_map = PMAP_PTE_PA(level2);
|
||||
Addr level3_pte = level3_map + (level3_index(vaddr) << PTESHIFT);
|
||||
|
||||
return level3_pte;
|
||||
Addr level3_pte = level2.paddr() + vaddr.level3();
|
||||
AlphaISA::PageTableEntry level3 = pmem->phys_read_qword(level3_pte);
|
||||
if (!level3.valid()) {
|
||||
DPRINTF(VtoPhys, "level 3 PTE not valid, va = %#x\n", vaddr);
|
||||
return 0;
|
||||
}
|
||||
return level3;
|
||||
}
|
||||
|
||||
Addr
|
||||
vtophys(PhysicalMemory *xc, Addr vaddr)
|
||||
{
|
||||
Addr paddr = 0;
|
||||
if (vaddr < ALPHA_K0SEG_BASE)
|
||||
if (AlphaISA::IsUSeg(vaddr))
|
||||
DPRINTF(VtoPhys, "vtophys: invalid vaddr %#x", vaddr);
|
||||
else if (vaddr < ALPHA_K1SEG_BASE)
|
||||
paddr = ALPHA_K0SEG_TO_PHYS(vaddr);
|
||||
else if (AlphaISA::IsK0Seg(vaddr))
|
||||
paddr = AlphaISA::K0Seg2Phys(vaddr);
|
||||
else
|
||||
panic("vtophys: ptbr is not set on virtual lookup");
|
||||
|
||||
@@ -92,8 +78,9 @@ vtophys(PhysicalMemory *xc, Addr vaddr)
|
||||
}
|
||||
|
||||
Addr
|
||||
vtophys(ExecContext *xc, Addr vaddr)
|
||||
vtophys(ExecContext *xc, Addr addr)
|
||||
{
|
||||
AlphaISA::VAddr vaddr = addr;
|
||||
Addr ptbr = xc->regs.ipr[AlphaISA::IPR_PALtemp20];
|
||||
Addr paddr = 0;
|
||||
//@todo Andrew couldn't remember why he commented some of this code
|
||||
@@ -101,15 +88,15 @@ vtophys(ExecContext *xc, Addr vaddr)
|
||||
if (PC_PAL(vaddr) && (vaddr < PAL_MAX)) {
|
||||
paddr = vaddr & ~ULL(1);
|
||||
} else {
|
||||
if (vaddr >= ALPHA_K0SEG_BASE && vaddr <= ALPHA_K0SEG_END) {
|
||||
paddr = ALPHA_K0SEG_TO_PHYS(vaddr);
|
||||
if (AlphaISA::IsK0Seg(vaddr)) {
|
||||
paddr = AlphaISA::K0Seg2Phys(vaddr);
|
||||
} else if (!ptbr) {
|
||||
paddr = vaddr;
|
||||
} else {
|
||||
Addr pte = kernel_pte_lookup(xc->physmem, ptbr, vaddr);
|
||||
uint64_t entry = xc->physmem->phys_read_qword(pte);
|
||||
if (pte && entry_valid(entry))
|
||||
paddr = PMAP_PTE_PA(entry) | (vaddr & ALPHA_PGOFSET);
|
||||
AlphaISA::PageTableEntry pte =
|
||||
kernel_pte_lookup(xc->physmem, ptbr, vaddr);
|
||||
if (pte.valid())
|
||||
paddr = pte.paddr() | vaddr.offset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +128,8 @@ CopyOut(ExecContext *xc, void *dest, Addr src, size_t cplen)
|
||||
int len;
|
||||
|
||||
paddr = vtophys(xc, src);
|
||||
len = min((int)(ALPHA_PGBYTES - (paddr & ALPHA_PGOFSET)), (int)cplen);
|
||||
len = min((int)(AlphaISA::PageBytes - (paddr & AlphaISA::PageOffset)),
|
||||
(int)cplen);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
|
||||
assert(dmaaddr);
|
||||
|
||||
@@ -153,15 +141,15 @@ CopyOut(ExecContext *xc, void *dest, Addr src, size_t cplen)
|
||||
dst += len;
|
||||
src += len;
|
||||
|
||||
while (cplen > ALPHA_PGBYTES) {
|
||||
while (cplen > AlphaISA::PageBytes) {
|
||||
paddr = vtophys(xc, src);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, AlphaISA::PageBytes);
|
||||
assert(dmaaddr);
|
||||
|
||||
memcpy(dst, dmaaddr, ALPHA_PGBYTES);
|
||||
cplen -= ALPHA_PGBYTES;
|
||||
dst += ALPHA_PGBYTES;
|
||||
src += ALPHA_PGBYTES;
|
||||
memcpy(dst, dmaaddr, AlphaISA::PageBytes);
|
||||
cplen -= AlphaISA::PageBytes;
|
||||
dst += AlphaISA::PageBytes;
|
||||
src += AlphaISA::PageBytes;
|
||||
}
|
||||
|
||||
if (cplen > 0) {
|
||||
@@ -182,7 +170,8 @@ CopyIn(ExecContext *xc, Addr dest, void *source, size_t cplen)
|
||||
int len;
|
||||
|
||||
paddr = vtophys(xc, dest);
|
||||
len = min((int)(ALPHA_PGBYTES - (paddr & ALPHA_PGOFSET)), (int)cplen);
|
||||
len = min((int)(AlphaISA::PageBytes - (paddr & AlphaISA::PageOffset)),
|
||||
(int)cplen);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
|
||||
assert(dmaaddr);
|
||||
|
||||
@@ -194,15 +183,15 @@ CopyIn(ExecContext *xc, Addr dest, void *source, size_t cplen)
|
||||
src += len;
|
||||
dest += len;
|
||||
|
||||
while (cplen > ALPHA_PGBYTES) {
|
||||
while (cplen > AlphaISA::PageBytes) {
|
||||
paddr = vtophys(xc, dest);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, AlphaISA::PageBytes);
|
||||
assert(dmaaddr);
|
||||
|
||||
memcpy(dmaaddr, src, ALPHA_PGBYTES);
|
||||
cplen -= ALPHA_PGBYTES;
|
||||
src += ALPHA_PGBYTES;
|
||||
dest += ALPHA_PGBYTES;
|
||||
memcpy(dmaaddr, src, AlphaISA::PageBytes);
|
||||
cplen -= AlphaISA::PageBytes;
|
||||
src += AlphaISA::PageBytes;
|
||||
dest += AlphaISA::PageBytes;
|
||||
}
|
||||
|
||||
if (cplen > 0) {
|
||||
@@ -222,7 +211,8 @@ CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen)
|
||||
int len;
|
||||
|
||||
paddr = vtophys(xc, vaddr);
|
||||
len = min((int)(ALPHA_PGBYTES - (paddr & ALPHA_PGOFSET)), (int)maxlen);
|
||||
len = min((int)(AlphaISA::PageBytes - (paddr & AlphaISA::PageOffset)),
|
||||
(int)maxlen);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, len);
|
||||
assert(dmaaddr);
|
||||
|
||||
@@ -239,21 +229,21 @@ CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen)
|
||||
dst += len;
|
||||
vaddr += len;
|
||||
|
||||
while (maxlen > ALPHA_PGBYTES) {
|
||||
while (maxlen > AlphaISA::PageBytes) {
|
||||
paddr = vtophys(xc, vaddr);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, ALPHA_PGBYTES);
|
||||
dmaaddr = (char *)xc->physmem->dma_addr(paddr, AlphaISA::PageBytes);
|
||||
assert(dmaaddr);
|
||||
|
||||
char *term = (char *)memchr(dmaaddr, 0, ALPHA_PGBYTES);
|
||||
len = term ? (term - dmaaddr + 1) : ALPHA_PGBYTES;
|
||||
char *term = (char *)memchr(dmaaddr, 0, AlphaISA::PageBytes);
|
||||
len = term ? (term - dmaaddr + 1) : AlphaISA::PageBytes;
|
||||
|
||||
memcpy(dst, dmaaddr, len);
|
||||
if (term)
|
||||
return;
|
||||
|
||||
maxlen -= ALPHA_PGBYTES;
|
||||
dst += ALPHA_PGBYTES;
|
||||
vaddr += ALPHA_PGBYTES;
|
||||
maxlen -= AlphaISA::PageBytes;
|
||||
dst += AlphaISA::PageBytes;
|
||||
vaddr += AlphaISA::PageBytes;
|
||||
}
|
||||
|
||||
if (maxlen > 0) {
|
||||
|
||||
@@ -26,19 +26,17 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __VTOPHYS_H__
|
||||
#define __VTOPHYS_H__
|
||||
#ifndef __ARCH_ALPHA_VTOPHYS_H__
|
||||
#define __ARCH_ALPHA_VTOPHYS_H__
|
||||
|
||||
#include "targetarch/isa_traits.hh"
|
||||
#include "targetarch/pmap.h"
|
||||
|
||||
inline bool entry_valid(uint64_t entry)
|
||||
{ return (entry & ALPHA_PTE_VALID) != 0; }
|
||||
#include "arch/alpha/isa_traits.hh"
|
||||
|
||||
class ExecContext;
|
||||
class PhysicalMemory;
|
||||
|
||||
Addr kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, Addr vaddr);
|
||||
AlphaISA::PageTableEntry
|
||||
kernel_pte_lookup(PhysicalMemory *pmem, Addr ptbr, AlphaISA::VAddr vaddr);
|
||||
|
||||
Addr vtophys(PhysicalMemory *xc, Addr vaddr);
|
||||
Addr vtophys(ExecContext *xc, Addr vaddr);
|
||||
uint8_t *vtomem(ExecContext *xc, Addr vaddr, size_t len);
|
||||
@@ -48,5 +46,5 @@ void CopyOut(ExecContext *xc, void *dst, Addr src, size_t len);
|
||||
void CopyIn(ExecContext *xc, Addr dst, void *src, size_t len);
|
||||
void CopyString(ExecContext *xc, char *dst, Addr vaddr, size_t maxlen);
|
||||
|
||||
#endif // __VTOPHYS_H__
|
||||
#endif // __ARCH_ALPHA_VTOPHYS_H__
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __BITFIELD_HH
|
||||
#define __BITFIELD_HH
|
||||
#ifndef __BASE_BITFIELD_HH__
|
||||
#define __BASE_BITFIELD_HH__
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "sim/host.hh"
|
||||
|
||||
/**
|
||||
* Generate a 64-bit mask of 'nbits' 1s, right justified.
|
||||
@@ -66,4 +66,4 @@ sext(uint64_t val)
|
||||
return sign_bit ? (val | ~mask(N)) : val;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // __BASE_BITFIELD_HH__
|
||||
|
||||
@@ -26,16 +26,16 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __NULL_COMPRESSION_HH__
|
||||
#define __NULL_COMPRESSION_HH__
|
||||
#ifndef __BASE_COMPRESSION_NULL_COMPRESSION_HH__
|
||||
#define __BASE_COMPRESSION_NULL_COMPRESSION_HH__
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file defines a doNothing compression algorithm.
|
||||
*/
|
||||
|
||||
#include <inttypes.h> // for uint8_t
|
||||
#include "base/misc.hh" // for fatal()
|
||||
#include "sim/host.hh"
|
||||
|
||||
|
||||
/**
|
||||
@@ -73,4 +73,4 @@ class NullCompression
|
||||
}
|
||||
};
|
||||
|
||||
#endif //__NULL_COMPRESSION_HH__
|
||||
#endif //__BASE_COMPRESSION_NULL_COMPRESSION_HH__
|
||||
|
||||
174
base/inet.cc
174
base/inet.cc
@@ -26,6 +26,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -34,29 +35,174 @@
|
||||
#include "base/inet.hh"
|
||||
|
||||
using namespace std;
|
||||
namespace Net {
|
||||
|
||||
EthAddr::EthAddr()
|
||||
{
|
||||
memset(data, 0, ETH_ADDR_LEN);
|
||||
}
|
||||
|
||||
EthAddr::EthAddr(const uint8_t ea[ETH_ADDR_LEN])
|
||||
{
|
||||
*data = *ea;
|
||||
}
|
||||
|
||||
EthAddr::EthAddr(const eth_addr &ea)
|
||||
{
|
||||
*data = *ea.data;
|
||||
}
|
||||
|
||||
EthAddr::EthAddr(const std::string &addr)
|
||||
{
|
||||
parse(addr);
|
||||
}
|
||||
|
||||
const EthAddr &
|
||||
EthAddr::operator=(const eth_addr &ea)
|
||||
{
|
||||
*data = *ea.data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const EthAddr &
|
||||
EthAddr::operator=(const std::string &addr)
|
||||
{
|
||||
parse(addr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
EthAddr::parse(const std::string &addr)
|
||||
{
|
||||
// the hack below is to make sure that ETH_ADDR_LEN is 6 otherwise
|
||||
// the sscanf function won't work.
|
||||
int bytes[ETH_ADDR_LEN == 6 ? ETH_ADDR_LEN : -1];
|
||||
if (sscanf(addr.c_str(), "%x:%x:%x:%x:%x:%x", &bytes[0], &bytes[1],
|
||||
&bytes[2], &bytes[3], &bytes[4], &bytes[5]) != ETH_ADDR_LEN) {
|
||||
memset(data, 0xff, ETH_ADDR_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ETH_ADDR_LEN; ++i) {
|
||||
if (bytes[i] & ~0xff) {
|
||||
memset(data, 0xff, ETH_ADDR_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
data[i] = bytes[i];
|
||||
}
|
||||
}
|
||||
|
||||
string
|
||||
eaddr_string(const uint8_t a[6])
|
||||
EthAddr::string() const
|
||||
{
|
||||
stringstream stream;
|
||||
ccprintf(stream, "%x:%x:%x:%x:%x:%x", a[0], a[1], a[2], a[3], a[4], a[5]);
|
||||
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
uint16_t
|
||||
IpHdr::ip_cksum() const
|
||||
bool
|
||||
operator==(const EthAddr &left, const EthAddr &right)
|
||||
{
|
||||
int sum = ip_cksum_add(this, hlen(), 0);
|
||||
sum = ip_cksum_carry(sum);
|
||||
return sum;
|
||||
return memcmp(left.bytes(), right.bytes(), ETH_ADDR_LEN);
|
||||
}
|
||||
|
||||
ostream &
|
||||
operator<<(ostream &stream, const EthAddr &ea)
|
||||
{
|
||||
const uint8_t *a = ea.addr();
|
||||
ccprintf(stream, "%x:%x:%x:%x:%x:%x", a[0], a[1], a[2], a[3], a[4], a[5]);
|
||||
return stream;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
IpHdr::tu_cksum() const
|
||||
cksum(const IpPtr &ptr)
|
||||
{
|
||||
int sum = ip_cksum_add(payload(), len() - hlen(), 0);
|
||||
sum = ip_cksum_add(&ip_src, 8, sum); // source and destination
|
||||
sum += htons(ip_p + len() - hlen());
|
||||
sum = ip_cksum_carry(sum);
|
||||
return sum;
|
||||
int sum = ip_cksum_add(ptr->bytes(), ptr->hlen(), 0);
|
||||
return ip_cksum_carry(sum);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
__tu_cksum(const IpPtr &ip)
|
||||
{
|
||||
int tcplen = ip->len() - ip->hlen();
|
||||
int sum = ip_cksum_add(ip->payload(), tcplen, 0);
|
||||
sum = ip_cksum_add(&ip->ip_src, 8, sum); // source and destination
|
||||
sum += htons(ip->ip_p + tcplen);
|
||||
return ip_cksum_carry(sum);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
cksum(const TcpPtr &tcp)
|
||||
{ return __tu_cksum(IpPtr(tcp.packet())); }
|
||||
|
||||
uint16_t
|
||||
cksum(const UdpPtr &udp)
|
||||
{ return __tu_cksum(IpPtr(udp.packet())); }
|
||||
|
||||
bool
|
||||
IpHdr::options(vector<const IpOpt *> &vec) const
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
const uint8_t *data = bytes() + sizeof(struct ip_hdr);
|
||||
int all = hlen() - sizeof(struct ip_hdr);
|
||||
while (all > 0) {
|
||||
const IpOpt *opt = (const IpOpt *)data;
|
||||
int len = opt->len();
|
||||
if (all < len)
|
||||
return false;
|
||||
|
||||
vec.push_back(opt);
|
||||
all -= len;
|
||||
data += len;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TcpHdr::options(vector<const TcpOpt *> &vec) const
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
const uint8_t *data = bytes() + sizeof(struct tcp_hdr);
|
||||
int all = off() - sizeof(struct tcp_hdr);
|
||||
while (all > 0) {
|
||||
const TcpOpt *opt = (const TcpOpt *)data;
|
||||
int len = opt->len();
|
||||
if (all < len)
|
||||
return false;
|
||||
|
||||
vec.push_back(opt);
|
||||
all -= len;
|
||||
data += len;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TcpOpt::sack(vector<SackRange> &vec) const
|
||||
{
|
||||
vec.clear();
|
||||
|
||||
const uint8_t *data = bytes() + sizeof(struct tcp_hdr);
|
||||
int all = len() - offsetof(tcp_opt, opt_data.sack);
|
||||
while (all > 0) {
|
||||
const uint16_t *sack = (const uint16_t *)data;
|
||||
int len = sizeof(uint16_t) * 2;
|
||||
if (all < len) {
|
||||
vec.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
vec.push_back(RangeIn(ntohs(sack[0]), ntohs(sack[1])));
|
||||
all -= len;
|
||||
data += len;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* namespace Net */ }
|
||||
|
||||
311
base/inet.hh
311
base/inet.hh
@@ -29,10 +29,16 @@
|
||||
#ifndef __BASE_INET_HH__
|
||||
#define __BASE_INET_HH__
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/range.hh"
|
||||
#include "dev/etherpkt.hh"
|
||||
#include "sim/host.hh"
|
||||
|
||||
#include "dnet/os.h"
|
||||
|
||||
#include "dnet/eth.h"
|
||||
#include "dnet/ip.h"
|
||||
#include "dnet/ip6.h"
|
||||
@@ -41,45 +47,90 @@
|
||||
#include "dnet/icmp.h"
|
||||
#include "dnet/tcp.h"
|
||||
#include "dnet/udp.h"
|
||||
|
||||
#include "dnet/intf.h"
|
||||
#include "dnet/route.h"
|
||||
#include "dnet/fw.h"
|
||||
|
||||
#include "dnet/blob.h"
|
||||
#include "dnet/rand.h"
|
||||
|
||||
#include "sim/host.hh"
|
||||
namespace Net {
|
||||
|
||||
std::string eaddr_string(const uint8_t a[6]);
|
||||
/*
|
||||
* Ethernet Stuff
|
||||
*/
|
||||
struct EthAddr : protected eth_addr
|
||||
{
|
||||
protected:
|
||||
void parse(const std::string &addr);
|
||||
|
||||
struct EthHdr;
|
||||
struct IpHdr;
|
||||
struct TcpHdr;
|
||||
struct UdpHdr;
|
||||
public:
|
||||
EthAddr();
|
||||
EthAddr(const uint8_t ea[ETH_ADDR_LEN]);
|
||||
EthAddr(const eth_addr &ea);
|
||||
EthAddr(const std::string &addr);
|
||||
const EthAddr &operator=(const eth_addr &ea);
|
||||
const EthAddr &operator=(const std::string &addr);
|
||||
|
||||
struct EthHdr : protected eth_hdr
|
||||
int size() const { return sizeof(eth_addr); }
|
||||
|
||||
const uint8_t *bytes() const { return &data[0]; }
|
||||
uint8_t *bytes() { return &data[0]; }
|
||||
|
||||
const uint8_t *addr() const { return &data[0]; }
|
||||
bool unicast() const { return data[0] == 0x00; }
|
||||
bool multicast() const { return data[0] == 0x01; }
|
||||
bool broadcast() const { return data[0] == 0xff; }
|
||||
std::string string() const;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &stream, const EthAddr &ea);
|
||||
bool operator==(const EthAddr &left, const EthAddr &right);
|
||||
|
||||
struct EthHdr : public eth_hdr
|
||||
{
|
||||
uint16_t type() const { return ntohs(eth_type); }
|
||||
const EthAddr &src() const { return *(EthAddr *)ð_src; }
|
||||
const EthAddr &dst() const { return *(EthAddr *)ð_dst; }
|
||||
|
||||
const IpHdr *ip() const
|
||||
{ return type() == ETH_TYPE_IP ? (const IpHdr *)payload() : 0; }
|
||||
int size() const { return sizeof(eth_hdr); }
|
||||
|
||||
IpHdr *ip()
|
||||
{ return type() == ETH_TYPE_IP ? (IpHdr *)payload() : 0; }
|
||||
|
||||
bool unicast() { return eth_dst.data[0] == 0x00; }
|
||||
bool multicast() { return eth_dst.data[0] == 0x01; }
|
||||
bool broadcast() { return eth_dst.data[0] == 0xff; }
|
||||
|
||||
int size() const { return sizeof(EthHdr); }
|
||||
const uint8_t *bytes() const { return (const uint8_t *)this; }
|
||||
const uint8_t *payload() const { return bytes() + size(); }
|
||||
uint8_t *bytes() { return (uint8_t *)this; }
|
||||
uint8_t *payload() { return bytes() + size(); }
|
||||
};
|
||||
|
||||
struct IpHdr : protected ip_hdr
|
||||
class EthPtr
|
||||
{
|
||||
protected:
|
||||
friend class IpPtr;
|
||||
PacketPtr p;
|
||||
|
||||
public:
|
||||
EthPtr() {}
|
||||
EthPtr(const PacketPtr &ptr) : p(ptr) { }
|
||||
|
||||
EthHdr *operator->() { return (EthHdr *)p->data; }
|
||||
EthHdr &operator*() { return *(EthHdr *)p->data; }
|
||||
operator EthHdr *() { return (EthHdr *)p->data; }
|
||||
|
||||
const EthHdr *operator->() const { return (const EthHdr *)p->data; }
|
||||
const EthHdr &operator*() const { return *(const EthHdr *)p->data; }
|
||||
operator const EthHdr *() const { return (const EthHdr *)p->data; }
|
||||
|
||||
const EthPtr &operator=(const PacketPtr &ptr) { p = ptr; return *this; }
|
||||
|
||||
const PacketPtr packet() const { return p; }
|
||||
PacketPtr packet() { return p; }
|
||||
bool operator!() const { return !p; }
|
||||
operator bool() const { return p; }
|
||||
};
|
||||
|
||||
/*
|
||||
* IP Stuff
|
||||
*/
|
||||
struct IpOpt;
|
||||
struct IpHdr : public ip_hdr
|
||||
{
|
||||
uint8_t version() const { return ip_v; }
|
||||
uint8_t hlen() const { return ip_hl * 4; }
|
||||
@@ -96,19 +147,7 @@ struct IpHdr : protected ip_hdr
|
||||
|
||||
void sum(uint16_t sum) { ip_sum = sum; }
|
||||
|
||||
uint16_t ip_cksum() const;
|
||||
uint16_t tu_cksum() const;
|
||||
|
||||
const TcpHdr *tcp() const
|
||||
{ return proto() == IP_PROTO_TCP ? (const TcpHdr *)payload() : 0; }
|
||||
const UdpHdr *udp() const
|
||||
{ return proto() == IP_PROTO_UDP ? (const UdpHdr *)payload() : 0; }
|
||||
|
||||
TcpHdr *tcp()
|
||||
{ return proto() == IP_PROTO_TCP ? (TcpHdr *)payload() : 0; }
|
||||
UdpHdr *udp()
|
||||
{ return proto() == IP_PROTO_UDP ? (UdpHdr *)payload() : 0; }
|
||||
|
||||
bool options(std::vector<const IpOpt *> &vec) const;
|
||||
|
||||
int size() const { return hlen(); }
|
||||
const uint8_t *bytes() const { return (const uint8_t *)this; }
|
||||
@@ -117,7 +156,84 @@ struct IpHdr : protected ip_hdr
|
||||
uint8_t *payload() { return bytes() + size(); }
|
||||
};
|
||||
|
||||
struct TcpHdr : protected tcp_hdr
|
||||
class IpPtr
|
||||
{
|
||||
protected:
|
||||
friend class TcpPtr;
|
||||
friend class UdpPtr;
|
||||
PacketPtr p;
|
||||
|
||||
const IpHdr *h() const
|
||||
{ return (const IpHdr *)(p->data + sizeof(eth_hdr)); }
|
||||
IpHdr *h() { return (IpHdr *)(p->data + sizeof(eth_hdr)); }
|
||||
|
||||
void set(const PacketPtr &ptr)
|
||||
{
|
||||
EthHdr *eth = (EthHdr *)ptr->data;
|
||||
if (eth->type() == ETH_TYPE_IP)
|
||||
p = ptr;
|
||||
else
|
||||
p = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
IpPtr() {}
|
||||
IpPtr(const PacketPtr &ptr) { set(ptr); }
|
||||
IpPtr(const EthPtr &ptr) { set(ptr.p); }
|
||||
IpPtr(const IpPtr &ptr) : p(ptr.p) { }
|
||||
|
||||
IpHdr *operator->() { return h(); }
|
||||
IpHdr &operator*() { return *h(); }
|
||||
operator IpHdr *() { return h(); }
|
||||
|
||||
const IpHdr *operator->() const { return h(); }
|
||||
const IpHdr &operator*() const { return *h(); }
|
||||
operator const IpHdr *() const { return h(); }
|
||||
|
||||
const IpPtr &operator=(const PacketPtr &ptr) { set(ptr); return *this; }
|
||||
const IpPtr &operator=(const EthPtr &ptr) { set(ptr.p); return *this; }
|
||||
const IpPtr &operator=(const IpPtr &ptr) { p = ptr.p; return *this; }
|
||||
|
||||
const PacketPtr packet() const { return p; }
|
||||
PacketPtr packet() { return p; }
|
||||
bool operator!() const { return !p; }
|
||||
operator bool() const { return p; }
|
||||
operator bool() { return p; }
|
||||
};
|
||||
|
||||
uint16_t cksum(const IpPtr &ptr);
|
||||
|
||||
struct IpOpt : public ip_opt
|
||||
{
|
||||
uint8_t type() const { return opt_type; }
|
||||
uint8_t typeNumber() const { return IP_OPT_NUMBER(opt_type); }
|
||||
uint8_t typeClass() const { return IP_OPT_CLASS(opt_type); }
|
||||
uint8_t typeCopied() const { return IP_OPT_COPIED(opt_type); }
|
||||
uint8_t len() const { return IP_OPT_TYPEONLY(type()) ? 1 : opt_len; }
|
||||
|
||||
bool isNumber(int num) const { return typeNumber() == IP_OPT_NUMBER(num); }
|
||||
bool isClass(int cls) const { return typeClass() == IP_OPT_CLASS(cls); }
|
||||
bool isCopied(int cpy) const { return typeCopied() == IP_OPT_COPIED(cpy); }
|
||||
|
||||
const uint8_t *data() const { return opt_data.data8; }
|
||||
void sec(ip_opt_data_sec &sec) const;
|
||||
void lsrr(ip_opt_data_rr &rr) const;
|
||||
void ssrr(ip_opt_data_rr &rr) const;
|
||||
void ts(ip_opt_data_ts &ts) const;
|
||||
uint16_t satid() const { return ntohs(opt_data.satid); }
|
||||
uint16_t mtup() const { return ntohs(opt_data.mtu); }
|
||||
uint16_t mtur() const { return ntohs(opt_data.mtu); }
|
||||
void tr(ip_opt_data_tr &tr) const;
|
||||
const uint32_t *addext() const { return &opt_data.addext[0]; }
|
||||
uint16_t rtralt() const { return ntohs(opt_data.rtralt); }
|
||||
void sdb(std::vector<uint32_t> &vec) const;
|
||||
};
|
||||
|
||||
/*
|
||||
* TCP Stuff
|
||||
*/
|
||||
struct TcpOpt;
|
||||
struct TcpHdr : public tcp_hdr
|
||||
{
|
||||
uint16_t sport() const { return ntohs(th_sport); }
|
||||
uint16_t dport() const { return ntohs(th_dport); }
|
||||
@@ -131,6 +247,8 @@ struct TcpHdr : protected tcp_hdr
|
||||
|
||||
void sum(uint16_t sum) { th_sum = sum; }
|
||||
|
||||
bool options(std::vector<const TcpOpt *> &vec) const;
|
||||
|
||||
int size() const { return off(); }
|
||||
const uint8_t *bytes() const { return (const uint8_t *)this; }
|
||||
const uint8_t *payload() const { return bytes() + size(); }
|
||||
@@ -138,7 +256,81 @@ struct TcpHdr : protected tcp_hdr
|
||||
uint8_t *payload() { return bytes() + size(); }
|
||||
};
|
||||
|
||||
struct UdpHdr : protected udp_hdr
|
||||
class TcpPtr
|
||||
{
|
||||
protected:
|
||||
PacketPtr p;
|
||||
int off;
|
||||
|
||||
const TcpHdr *h() const { return (const TcpHdr *)(p->data + off); }
|
||||
TcpHdr *h() { return (TcpHdr *)(p->data + off); }
|
||||
|
||||
void set(const PacketPtr &ptr, int offset) { p = ptr; off = offset; }
|
||||
void set(const IpPtr &ptr)
|
||||
{
|
||||
if (ptr->proto() == IP_PROTO_TCP)
|
||||
set(ptr.p, sizeof(eth_hdr) + ptr->hlen());
|
||||
else
|
||||
set(0, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
TcpPtr() {}
|
||||
TcpPtr(const IpPtr &ptr) { set(ptr); }
|
||||
TcpPtr(const TcpPtr &ptr) : p(ptr.p), off(ptr.off) {}
|
||||
|
||||
TcpHdr *operator->() { return h(); }
|
||||
TcpHdr &operator*() { return *h(); }
|
||||
operator TcpHdr *() { return h(); }
|
||||
|
||||
const TcpHdr *operator->() const { return h(); }
|
||||
const TcpHdr &operator*() const { return *h(); }
|
||||
operator const TcpHdr *() const { return h(); }
|
||||
|
||||
const TcpPtr &operator=(const IpPtr &i) { set(i); return *this; }
|
||||
const TcpPtr &operator=(const TcpPtr &t) { set(t.p, t.off); return *this; }
|
||||
|
||||
const PacketPtr packet() const { return p; }
|
||||
PacketPtr packet() { return p; }
|
||||
bool operator!() const { return !p; }
|
||||
operator bool() const { return p; }
|
||||
operator bool() { return p; }
|
||||
};
|
||||
|
||||
uint16_t cksum(const TcpPtr &ptr);
|
||||
|
||||
typedef Range<uint16_t> SackRange;
|
||||
|
||||
struct TcpOpt : public tcp_opt
|
||||
{
|
||||
uint8_t type() const { return opt_type; }
|
||||
uint8_t len() const { return TCP_OPT_TYPEONLY(type()) ? 1 : opt_len; }
|
||||
|
||||
bool isopt(int opt) const { return type() == opt; }
|
||||
|
||||
const uint8_t *data() const { return opt_data.data8; }
|
||||
|
||||
uint16_t mss() const { return ntohs(opt_data.mss); }
|
||||
uint8_t wscale() const { return opt_data.wscale; }
|
||||
bool sack(std::vector<SackRange> &vec) const;
|
||||
uint32_t echo() const { return ntohl(opt_data.echo); }
|
||||
uint32_t tsval() const { return ntohl(opt_data.timestamp[0]); }
|
||||
uint32_t tsecr() const { return ntohl(opt_data.timestamp[1]); }
|
||||
uint32_t cc() const { return ntohl(opt_data.cc); }
|
||||
uint8_t cksum() const{ return opt_data.cksum; }
|
||||
const uint8_t *md5() const { return opt_data.md5; }
|
||||
|
||||
int size() const { return len(); }
|
||||
const uint8_t *bytes() const { return (const uint8_t *)this; }
|
||||
const uint8_t *payload() const { return bytes() + size(); }
|
||||
uint8_t *bytes() { return (uint8_t *)this; }
|
||||
uint8_t *payload() { return bytes() + size(); }
|
||||
};
|
||||
|
||||
/*
|
||||
* UDP Stuff
|
||||
*/
|
||||
struct UdpHdr : public udp_hdr
|
||||
{
|
||||
uint16_t sport() const { return ntohs(uh_sport); }
|
||||
uint16_t dport() const { return ntohs(uh_dport); }
|
||||
@@ -147,11 +339,56 @@ struct UdpHdr : protected udp_hdr
|
||||
|
||||
void sum(uint16_t sum) { uh_sum = htons(sum); }
|
||||
|
||||
int size() const { return sizeof(UdpHdr); }
|
||||
int size() const { return sizeof(udp_hdr); }
|
||||
const uint8_t *bytes() const { return (const uint8_t *)this; }
|
||||
const uint8_t *payload() const { return bytes() + size(); }
|
||||
uint8_t *bytes() { return (uint8_t *)this; }
|
||||
uint8_t *payload() { return bytes() + size(); }
|
||||
};
|
||||
|
||||
class UdpPtr
|
||||
{
|
||||
protected:
|
||||
PacketPtr p;
|
||||
int off;
|
||||
|
||||
const UdpHdr *h() const { return (const UdpHdr *)(p->data + off); }
|
||||
UdpHdr *h() { return (UdpHdr *)(p->data + off); }
|
||||
|
||||
void set(const PacketPtr &ptr, int offset) { p = ptr; off = offset; }
|
||||
void set(const IpPtr &ptr)
|
||||
{
|
||||
if (ptr->proto() == IP_PROTO_UDP)
|
||||
set(ptr.p, sizeof(eth_hdr) + ptr->hlen());
|
||||
else
|
||||
set(0, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
UdpPtr() {}
|
||||
UdpPtr(const IpPtr &ptr) { set(ptr); }
|
||||
UdpPtr(const UdpPtr &ptr) : p(ptr.p), off(ptr.off) {}
|
||||
|
||||
UdpHdr *operator->() { return h(); }
|
||||
UdpHdr &operator*() { return *h(); }
|
||||
operator UdpHdr *() { return h(); }
|
||||
|
||||
const UdpHdr *operator->() const { return h(); }
|
||||
const UdpHdr &operator*() const { return *h(); }
|
||||
operator const UdpHdr *() const { return h(); }
|
||||
|
||||
const UdpPtr &operator=(const IpPtr &i) { set(i); return *this; }
|
||||
const UdpPtr &operator=(const UdpPtr &t) { set(t.p, t.off); return *this; }
|
||||
|
||||
const PacketPtr packet() const { return p; }
|
||||
PacketPtr packet() { return p; }
|
||||
bool operator!() const { return !p; }
|
||||
operator bool() const { return p; }
|
||||
operator bool() { return p; }
|
||||
};
|
||||
|
||||
uint16_t cksum(const UdpPtr &ptr);
|
||||
|
||||
/* namespace Net */ }
|
||||
|
||||
#endif // __BASE_INET_HH__
|
||||
|
||||
@@ -51,15 +51,26 @@ class RefCountingPtr
|
||||
protected:
|
||||
T *data;
|
||||
|
||||
void copy(T *d) {
|
||||
void copy(T *d)
|
||||
{
|
||||
data = d;
|
||||
if (data)
|
||||
data->incref();
|
||||
}
|
||||
void del() {
|
||||
void del()
|
||||
{
|
||||
if (data)
|
||||
data->decref();
|
||||
}
|
||||
void set(T *d)
|
||||
{
|
||||
if (data == d)
|
||||
return;
|
||||
|
||||
del();
|
||||
copy(d);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
RefCountingPtr() : data(NULL) {}
|
||||
@@ -75,21 +86,9 @@ class RefCountingPtr
|
||||
const T &operator*() const { return *data; }
|
||||
const T *get() const { return data; }
|
||||
|
||||
RefCountingPtr &operator=(T *p) {
|
||||
if (data != p) {
|
||||
del();
|
||||
copy(p);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RefCountingPtr &operator=(const RefCountingPtr &r) {
|
||||
if (data != r.data) {
|
||||
del();
|
||||
copy(r.data);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
RefCountingPtr &operator=(T *p) { set(p); return *this; }
|
||||
RefCountingPtr &operator=(const RefCountingPtr &r)
|
||||
{ return operator=(r.data); }
|
||||
|
||||
bool operator!() const { return data == 0; }
|
||||
operator bool() const { return data != 0; }
|
||||
|
||||
@@ -326,14 +326,13 @@ bool
|
||||
RemoteGDB::acc(Addr va, size_t len)
|
||||
{
|
||||
Addr last_va;
|
||||
Addr pte;
|
||||
|
||||
va = alpha_trunc_page(va);
|
||||
last_va = alpha_round_page(va + len);
|
||||
va = TheISA::TruncPage(va);
|
||||
last_va = TheISA::RoundPage(va + len);
|
||||
|
||||
do {
|
||||
if (va >= ALPHA_K0SEG_BASE && va < ALPHA_K1SEG_BASE) {
|
||||
if (va < (ALPHA_K0SEG_BASE + pmem->size())) {
|
||||
if (TheISA::IsK0Seg(va)) {
|
||||
if (va < (TheISA::K0SegBase + pmem->size())) {
|
||||
DPRINTF(GDBAcc, "acc: Mapping is valid K0SEG <= "
|
||||
"%#x < K0SEG + size\n", va);
|
||||
return true;
|
||||
@@ -355,12 +354,12 @@ RemoteGDB::acc(Addr va, size_t len)
|
||||
return true;
|
||||
|
||||
Addr ptbr = context->regs.ipr[AlphaISA::IPR_PALtemp20];
|
||||
pte = kernel_pte_lookup(pmem, ptbr, va);
|
||||
if (!pte || !entry_valid(pmem->phys_read_qword(pte))) {
|
||||
TheISA::PageTableEntry pte = kernel_pte_lookup(pmem, ptbr, va);
|
||||
if (!pte.valid()) {
|
||||
DPRINTF(GDBAcc, "acc: %#x pte is invalid\n", va);
|
||||
return false;
|
||||
}
|
||||
va += ALPHA_PGBYTES;
|
||||
va += TheISA::PageBytes;
|
||||
} while (va < last_va);
|
||||
|
||||
DPRINTF(GDBAcc, "acc: %#x mapping is valid\n", va);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define __BASE_STATS_TYPES_HH__
|
||||
|
||||
#include <vector>
|
||||
#include <inttypes.h>
|
||||
#include "sim/host.hh"
|
||||
|
||||
namespace Stats {
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "base/refcnt.hh"
|
||||
#include "base/inet.hh"
|
||||
#include "sim/host.hh"
|
||||
|
||||
/*
|
||||
@@ -57,17 +56,6 @@ class PacketData : public RefCounted
|
||||
: data(d.release()), length(l) { }
|
||||
~PacketData() { if (data) delete [] data; }
|
||||
|
||||
public:
|
||||
const EthHdr *eth() const { return (const EthHdr *)data; }
|
||||
const IpHdr *ip() const {const EthHdr *h = eth(); return h ? h->ip() : 0;}
|
||||
const TcpHdr *tcp() const {const IpHdr *h = ip(); return h ? h->tcp() : 0;}
|
||||
const UdpHdr *udp() const {const IpHdr *h = ip(); return h ? h->udp() : 0;}
|
||||
|
||||
EthHdr *eth() { return (EthHdr *)data; }
|
||||
IpHdr *ip() { EthHdr *h = eth(); return h ? h->ip() : 0; }
|
||||
TcpHdr *tcp() { IpHdr *h = ip(); return h ? h->tcp() : 0; }
|
||||
UdpHdr *udp() { IpHdr *h = ip(); return h ? h->udp() : 0; }
|
||||
|
||||
public:
|
||||
void serialize(std::ostream &os);
|
||||
void unserialize(Checkpoint *cp, const std::string §ion);
|
||||
|
||||
@@ -63,9 +63,6 @@ IdeController::IdeController(const string &name, IntrControl *ic,
|
||||
Bus *host_bus, Tick pio_latency, HierParams *hier)
|
||||
: PciDev(name, mmu, cf, cd, bus_num, dev_num, func_num), tsunami(t)
|
||||
{
|
||||
// put back pointer into Tsunami
|
||||
tsunami->disk_controller = this;
|
||||
|
||||
// initialize the PIO interface addresses
|
||||
pri_cmd_addr = 0;
|
||||
pri_cmd_size = BARSize[0];
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include "arch/alpha/pmap.h"
|
||||
#include "base/cprintf.hh" // csprintf
|
||||
#include "base/trace.hh"
|
||||
#include "dev/disk_image.hh"
|
||||
@@ -51,6 +50,7 @@
|
||||
#include "sim/builder.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
#include "sim/universe.hh"
|
||||
#include "targetarch/isa_traits.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -188,14 +188,14 @@ IdeDisk::bytesInDmaPage(Addr curAddr, uint32_t bytesLeft)
|
||||
uint32_t bytesInPage = 0;
|
||||
|
||||
// First calculate how many bytes could be in the page
|
||||
if (bytesLeft > ALPHA_PGBYTES)
|
||||
bytesInPage = ALPHA_PGBYTES;
|
||||
if (bytesLeft > TheISA::PageBytes)
|
||||
bytesInPage = TheISA::PageBytes;
|
||||
else
|
||||
bytesInPage = bytesLeft;
|
||||
|
||||
// Next, see if we have crossed a page boundary, and adjust
|
||||
Addr upperBound = curAddr + bytesInPage;
|
||||
Addr pageBound = alpha_trunc_page(curAddr) + ALPHA_PGBYTES;
|
||||
Addr pageBound = TheISA::TruncPage(curAddr) + TheISA::PageBytes;
|
||||
|
||||
assert(upperBound >= curAddr && "DMA read wraps around address space!\n");
|
||||
|
||||
@@ -510,7 +510,7 @@ IdeDisk::dmaWriteDone()
|
||||
|
||||
// setup the initial page and DMA address
|
||||
curAddr = curPrd.getBaseAddr();
|
||||
pageAddr = alpha_trunc_page(curAddr);
|
||||
pageAddr = TheISA::TruncPage(curAddr);
|
||||
dmaAddr = pciToDma(curAddr);
|
||||
|
||||
// clear out the data buffer
|
||||
@@ -518,14 +518,14 @@ IdeDisk::dmaWriteDone()
|
||||
|
||||
while (bytesRead < curPrd.getByteCount()) {
|
||||
// see if we have crossed into a new page
|
||||
if (pageAddr != alpha_trunc_page(curAddr)) {
|
||||
if (pageAddr != TheISA::TruncPage(curAddr)) {
|
||||
// write the data to memory
|
||||
memcpy(physmem->dma_addr(dmaAddr, bytesInPage),
|
||||
(void *)(dataBuffer + (bytesRead - bytesInPage)),
|
||||
bytesInPage);
|
||||
|
||||
// update the DMA address and page address
|
||||
pageAddr = alpha_trunc_page(curAddr);
|
||||
pageAddr = TheISA::TruncPage(curAddr);
|
||||
dmaAddr = pciToDma(curAddr);
|
||||
|
||||
bytesInPage = 0;
|
||||
|
||||
@@ -86,7 +86,7 @@ const char *NsDmaState[] =
|
||||
};
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace Net;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -99,7 +99,7 @@ NSGigE::NSGigE(const std::string &name, IntrControl *i, Tick intr_delay,
|
||||
bool dma_data_free, Tick dma_read_delay, Tick dma_write_delay,
|
||||
Tick dma_read_factor, Tick dma_write_factor, PciConfigAll *cf,
|
||||
PciConfigData *cd, Tsunami *t, uint32_t bus, uint32_t dev,
|
||||
uint32_t func, bool rx_filter, const int eaddr[6],
|
||||
uint32_t func, bool rx_filter, EthAddr eaddr,
|
||||
uint32_t tx_fifo_size, uint32_t rx_fifo_size)
|
||||
: PciDev(name, mmu, cf, cd, bus, dev, func), tsunami(t), ioEnable(false),
|
||||
maxTxFifoSize(tx_fifo_size), maxRxFifoSize(rx_fifo_size),
|
||||
@@ -119,8 +119,6 @@ NSGigE::NSGigE(const std::string &name, IntrControl *i, Tick intr_delay,
|
||||
physmem(pmem), intctrl(i), intrTick(0), cpuPendingIntr(false),
|
||||
intrEvent(0), interface(0)
|
||||
{
|
||||
tsunami->ethernet = this;
|
||||
|
||||
if (header_bus) {
|
||||
pioInterface = newPioInterface(name, hier, header_bus, this,
|
||||
&NSGigE::cacheAccess);
|
||||
@@ -151,12 +149,7 @@ NSGigE::NSGigE(const std::string &name, IntrControl *i, Tick intr_delay,
|
||||
dmaWriteFactor = dma_write_factor;
|
||||
|
||||
regsReset();
|
||||
rom.perfectMatch[0] = eaddr[0];
|
||||
rom.perfectMatch[1] = eaddr[1];
|
||||
rom.perfectMatch[2] = eaddr[2];
|
||||
rom.perfectMatch[3] = eaddr[3];
|
||||
rom.perfectMatch[4] = eaddr[4];
|
||||
rom.perfectMatch[5] = eaddr[5];
|
||||
memcpy(&rom.perfectMatch, eaddr.bytes(), ETH_ADDR_LEN);
|
||||
}
|
||||
|
||||
NSGigE::~NSGigE()
|
||||
@@ -1339,10 +1332,10 @@ NSGigE::rxKick()
|
||||
|
||||
#if TRACING_ON
|
||||
if (DTRACE(Ethernet)) {
|
||||
const IpHdr *ip = rxPacket->ip();
|
||||
IpPtr ip(rxPacket);
|
||||
if (ip) {
|
||||
DPRINTF(Ethernet, "ID is %d\n", ip->id());
|
||||
const TcpHdr *tcp = rxPacket->tcp();
|
||||
TcpPtr tcp(ip);
|
||||
if (tcp) {
|
||||
DPRINTF(Ethernet, "Src Port=%d, Dest Port=%d\n",
|
||||
tcp->sport(), tcp->dport());
|
||||
@@ -1401,36 +1394,38 @@ NSGigE::rxKick()
|
||||
*/
|
||||
if (rxFilterEnable) {
|
||||
rxDescCache.cmdsts &= ~CMDSTS_DEST_MASK;
|
||||
EthHdr *eth = rxFifoFront()->eth();
|
||||
if (eth->unicast())
|
||||
const EthAddr &dst = rxFifoFront()->dst();
|
||||
if (dst->unicast())
|
||||
rxDescCache.cmdsts |= CMDSTS_DEST_SELF;
|
||||
if (eth->multicast())
|
||||
if (dst->multicast())
|
||||
rxDescCache.cmdsts |= CMDSTS_DEST_MULTI;
|
||||
if (eth->broadcast())
|
||||
if (dst->broadcast())
|
||||
rxDescCache.cmdsts |= CMDSTS_DEST_MASK;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (extstsEnable && rxPacket->ip()) {
|
||||
IpPtr ip(rxPacket);
|
||||
if (extstsEnable && ip) {
|
||||
rxDescCache.extsts |= EXTSTS_IPPKT;
|
||||
rxIpChecksums++;
|
||||
IpHdr *ip = rxPacket->ip();
|
||||
if (ip->ip_cksum() != 0) {
|
||||
if (cksum(ip) != 0) {
|
||||
DPRINTF(EthernetCksum, "Rx IP Checksum Error\n");
|
||||
rxDescCache.extsts |= EXTSTS_IPERR;
|
||||
}
|
||||
if (rxPacket->tcp()) {
|
||||
TcpPtr tcp(ip);
|
||||
UdpPtr udp(ip);
|
||||
if (tcp) {
|
||||
rxDescCache.extsts |= EXTSTS_TCPPKT;
|
||||
rxTcpChecksums++;
|
||||
if (ip->tu_cksum() != 0) {
|
||||
if (cksum(tcp) != 0) {
|
||||
DPRINTF(EthernetCksum, "Rx TCP Checksum Error\n");
|
||||
rxDescCache.extsts |= EXTSTS_TCPERR;
|
||||
|
||||
}
|
||||
} else if (rxPacket->udp()) {
|
||||
} else if (udp) {
|
||||
rxDescCache.extsts |= EXTSTS_UDPPKT;
|
||||
rxUdpChecksums++;
|
||||
if (ip->tu_cksum() != 0) {
|
||||
if (cksum(udp) != 0) {
|
||||
DPRINTF(EthernetCksum, "Rx UDP Checksum Error\n");
|
||||
rxDescCache.extsts |= EXTSTS_UDPERR;
|
||||
}
|
||||
@@ -1548,10 +1543,10 @@ NSGigE::transmit()
|
||||
if (interface->sendPacket(txFifo.front())) {
|
||||
#if TRACING_ON
|
||||
if (DTRACE(Ethernet)) {
|
||||
const IpHdr *ip = txFifo.front()->ip();
|
||||
IpPtr ip(txFifo.front());
|
||||
if (ip) {
|
||||
DPRINTF(Ethernet, "ID is %d\n", ip->id());
|
||||
const TcpHdr *tcp = txFifo.front()->tcp();
|
||||
TcpPtr tcp(ip);
|
||||
if (tcp) {
|
||||
DPRINTF(Ethernet, "Src Port=%d, Dest Port=%d\n",
|
||||
tcp->sport(), tcp->dport());
|
||||
@@ -1814,21 +1809,21 @@ NSGigE::txKick()
|
||||
DPRINTF(EthernetSM, "This packet is done, let's wrap it up\n");
|
||||
/* deal with the the packet that just finished */
|
||||
if ((regs.vtcr & VTCR_PPCHK) && extstsEnable) {
|
||||
IpHdr *ip = txPacket->ip();
|
||||
IpPtr ip(txPacket);
|
||||
if (txDescCache.extsts & EXTSTS_UDPPKT) {
|
||||
UdpHdr *udp = txPacket->udp();
|
||||
UdpPtr udp(ip);
|
||||
udp->sum(0);
|
||||
udp->sum(ip->tu_cksum());
|
||||
udp->sum(cksum(udp));
|
||||
txUdpChecksums++;
|
||||
} else if (txDescCache.extsts & EXTSTS_TCPPKT) {
|
||||
TcpHdr *tcp = txPacket->tcp();
|
||||
TcpPtr tcp(ip);
|
||||
tcp->sum(0);
|
||||
tcp->sum(ip->tu_cksum());
|
||||
tcp->sum(cksum(tcp));
|
||||
txTcpChecksums++;
|
||||
}
|
||||
if (txDescCache.extsts & EXTSTS_IPPKT) {
|
||||
ip->sum(0);
|
||||
ip->sum(ip->ip_cksum());
|
||||
ip->sum(cksum(ip));
|
||||
txIpChecksums++;
|
||||
}
|
||||
}
|
||||
@@ -1987,31 +1982,31 @@ NSGigE::transferDone()
|
||||
}
|
||||
|
||||
bool
|
||||
NSGigE::rxFilter(PacketPtr packet)
|
||||
NSGigE::rxFilter(PacketPtr &packet)
|
||||
{
|
||||
EthPtr eth = packet;
|
||||
bool drop = true;
|
||||
string type;
|
||||
|
||||
EthHdr *eth = packet->eth();
|
||||
if (eth->unicast()) {
|
||||
const EthAddr &dst = eth->dst();
|
||||
if (dst.unicast()) {
|
||||
// If we're accepting all unicast addresses
|
||||
if (acceptUnicast)
|
||||
drop = false;
|
||||
|
||||
// If we make a perfect match
|
||||
if (acceptPerfect &&
|
||||
memcmp(rom.perfectMatch, packet->data, EADDR_LEN) == 0)
|
||||
if (acceptPerfect && dst == rom.perfectMatch)
|
||||
drop = false;
|
||||
|
||||
if (acceptArp && eth->type() == ETH_TYPE_ARP)
|
||||
drop = false;
|
||||
|
||||
} else if (eth->broadcast()) {
|
||||
} else if (dst.broadcast()) {
|
||||
// if we're accepting broadcasts
|
||||
if (acceptBroadcast)
|
||||
drop = false;
|
||||
|
||||
} else if (eth->multicast()) {
|
||||
} else if (dst.multicast()) {
|
||||
// if we're accepting all multicasts
|
||||
if (acceptMulticast)
|
||||
drop = false;
|
||||
@@ -2027,7 +2022,7 @@ NSGigE::rxFilter(PacketPtr packet)
|
||||
}
|
||||
|
||||
bool
|
||||
NSGigE::recvPacket(PacketPtr packet)
|
||||
NSGigE::recvPacket(PacketPtr &packet)
|
||||
{
|
||||
rxBytes += packet->length;
|
||||
rxPackets++;
|
||||
@@ -2120,7 +2115,7 @@ NSGigE::serialize(ostream &os)
|
||||
SERIALIZE_SCALAR(regs.taner);
|
||||
SERIALIZE_SCALAR(regs.tesr);
|
||||
|
||||
SERIALIZE_ARRAY(rom.perfectMatch, EADDR_LEN);
|
||||
SERIALIZE_ARRAY(rom.perfectMatch, ETH_ADDR_LEN);
|
||||
|
||||
SERIALIZE_SCALAR(ioEnable);
|
||||
|
||||
@@ -2277,7 +2272,7 @@ NSGigE::unserialize(Checkpoint *cp, const std::string §ion)
|
||||
UNSERIALIZE_SCALAR(regs.taner);
|
||||
UNSERIALIZE_SCALAR(regs.tesr);
|
||||
|
||||
UNSERIALIZE_ARRAY(rom.perfectMatch, EADDR_LEN);
|
||||
UNSERIALIZE_ARRAY(rom.perfectMatch, ETH_ADDR_LEN);
|
||||
|
||||
UNSERIALIZE_SCALAR(ioEnable);
|
||||
|
||||
@@ -2517,16 +2512,13 @@ END_INIT_SIM_OBJECT_PARAMS(NSGigE)
|
||||
|
||||
CREATE_SIM_OBJECT(NSGigE)
|
||||
{
|
||||
int eaddr[6];
|
||||
sscanf(((string)hardware_address).c_str(), "%x:%x:%x:%x:%x:%x",
|
||||
&eaddr[0], &eaddr[1], &eaddr[2], &eaddr[3], &eaddr[4], &eaddr[5]);
|
||||
|
||||
return new NSGigE(getInstanceName(), intr_ctrl, intr_delay,
|
||||
physmem, tx_delay, rx_delay, mmu, hier, header_bus,
|
||||
payload_bus, pio_latency, dma_desc_free, dma_data_free,
|
||||
dma_read_delay, dma_write_delay, dma_read_factor,
|
||||
dma_write_factor, configspace, configdata,
|
||||
tsunami, pci_bus, pci_dev, pci_func, rx_filter, eaddr,
|
||||
tsunami, pci_bus, pci_dev, pci_func, rx_filter,
|
||||
EthAddr((string)hardware_address),
|
||||
tx_fifo_size, rx_fifo_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,10 @@
|
||||
* DP83820 ethernet controller
|
||||
*/
|
||||
|
||||
#ifndef __NS_GIGE_HH__
|
||||
#define __NS_GIGE_HH__
|
||||
#ifndef __DEV_NS_GIGE_HH__
|
||||
#define __DEV_NS_GIGE_HH__
|
||||
|
||||
#include "base/inet.hh"
|
||||
#include "base/statistics.hh"
|
||||
#include "dev/etherint.hh"
|
||||
#include "dev/etherpkt.hh"
|
||||
@@ -44,9 +45,6 @@
|
||||
#include "mem/bus/bus.hh"
|
||||
#include "sim/eventq.hh"
|
||||
|
||||
/** length of ethernet address in bytes */
|
||||
#define EADDR_LEN 6
|
||||
|
||||
/**
|
||||
* Ethernet device registers
|
||||
*/
|
||||
@@ -90,7 +88,7 @@ struct dp_rom {
|
||||
* for perfect match memory.
|
||||
* the linux driver doesn't use any other ROM
|
||||
*/
|
||||
uint8_t perfectMatch[EADDR_LEN];
|
||||
uint8_t perfectMatch[ETH_ADDR_LEN];
|
||||
};
|
||||
|
||||
class IntrControl;
|
||||
@@ -302,7 +300,7 @@ class NSGigE : public PciDev
|
||||
* receive address filter
|
||||
*/
|
||||
bool rxFilterEnable;
|
||||
bool rxFilter(PacketPtr packet);
|
||||
bool rxFilter(PacketPtr &packet);
|
||||
bool acceptBroadcast;
|
||||
bool acceptMulticast;
|
||||
bool acceptUnicast;
|
||||
@@ -339,7 +337,7 @@ class NSGigE : public PciDev
|
||||
bool dma_data_free, Tick dma_read_delay, Tick dma_write_delay,
|
||||
Tick dma_read_factor, Tick dma_write_factor, PciConfigAll *cf,
|
||||
PciConfigData *cd, Tsunami *t, uint32_t bus, uint32_t dev,
|
||||
uint32_t func, bool rx_filter, const int eaddr[6],
|
||||
uint32_t func, bool rx_filter, Net::EthAddr eaddr,
|
||||
uint32_t tx_fifo_size, uint32_t rx_fifo_size);
|
||||
~NSGigE();
|
||||
|
||||
@@ -352,7 +350,7 @@ class NSGigE : public PciDev
|
||||
bool cpuIntrPending() const;
|
||||
void cpuIntrAck() { cpuIntrClear(); }
|
||||
|
||||
bool recvPacket(PacketPtr packet);
|
||||
bool recvPacket(PacketPtr &packet);
|
||||
void transferDone();
|
||||
|
||||
void setInterface(NSGigEInt *i) { assert(!interface); interface = i; }
|
||||
@@ -403,4 +401,4 @@ class NSGigEInt : public EtherInt
|
||||
virtual void sendDone() { dev->transferDone(); }
|
||||
};
|
||||
|
||||
#endif // __NS_GIGE_HH__
|
||||
#endif // __DEV_NS_GIGE_HH__
|
||||
|
||||
@@ -62,12 +62,9 @@ class Tsunami : public Platform
|
||||
|
||||
/** Pointer to the system */
|
||||
System *system;
|
||||
|
||||
/** Pointer to the TsunamiIO device which has the RTC */
|
||||
TsunamiIO *io;
|
||||
/** Pointer to the disk controller device */
|
||||
IdeController *disk_controller;
|
||||
/** Pointer to the ethernet controller device */
|
||||
NSGigE *ethernet;
|
||||
|
||||
/** Pointer to the Tsunami CChip.
|
||||
* The chip contains some configuration information and
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __ALIGNED_HH__
|
||||
#define __ALIGNED_HH__
|
||||
#ifndef __KERN_LINUX_ALIGNED_HH__
|
||||
#define __KERN_LINUX_ALIGNED_HH__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sim/host.hh"
|
||||
#include "targetarch/isa_traits.hh"
|
||||
|
||||
/* GCC 3.3.X has a bug in which attributes+typedefs don't work. 3.2.X is fine
|
||||
@@ -18,4 +18,4 @@ typedef Addr Addr_a __attribute__ ((aligned (8))) ;
|
||||
#define Addr_a Addr __attribute__ ((aligned (8)))
|
||||
#endif /* __GNUC__ __GNUC_MINOR__ */
|
||||
|
||||
#endif /* __ALIGNED_H__ */
|
||||
#endif /* __KERN_LINUX_ALIGNED_HH__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __ALPHA_HWRPB_H__
|
||||
#define __ALPHA_HWRPB_H__
|
||||
#ifndef __KERN_LINUX_HWRPB_HH__
|
||||
#define __KERN_LINUX_HWRPB_HH__
|
||||
|
||||
#include "kern/linux/aligned.hh"
|
||||
|
||||
@@ -15,4 +15,4 @@ namespace Linux {
|
||||
uint64_ta res1, res2;
|
||||
};
|
||||
}
|
||||
#endif /* __ALPHA_HWRPB_H */
|
||||
#endif // __KERN_LINUX_HWRPB_HH__
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
#include "kern/tru64/tru64_events.hh"
|
||||
#include "kern/tru64/dump_mbuf.hh"
|
||||
#include "kern/tru64/printf.hh"
|
||||
#include "targetarch/arguments.hh"
|
||||
#include "mem/functional_mem/memory_control.hh"
|
||||
#include "targetarch/arguments.hh"
|
||||
#include "targetarch/isa_traits.hh"
|
||||
|
||||
//void SkipFuncEvent::process(ExecContext *xc);
|
||||
|
||||
@@ -46,8 +47,8 @@ BadAddrEvent::process(ExecContext *xc)
|
||||
|
||||
uint64_t a0 = xc->regs.intRegFile[ArgumentReg0];
|
||||
|
||||
if (a0 < ALPHA_K0SEG_BASE || a0 >= ALPHA_K1SEG_BASE ||
|
||||
xc->memctrl->badaddr(ALPHA_K0SEG_TO_PHYS(a0) & PA_IMPL_MASK)) {
|
||||
if (!TheISA::IsK0Seg(a0) ||
|
||||
xc->memctrl->badaddr(TheISA::K0Seg2Phys(a0) & PA_IMPL_MASK)) {
|
||||
|
||||
DPRINTF(BADADDR, "badaddr arg=%#x bad\n", a0);
|
||||
xc->regs.intRegFile[ReturnValueReg] = 0x1;
|
||||
|
||||
Reference in New Issue
Block a user