Add Etherner drive source code and CodeWarrior project file, from:

https://web.archive.org/web/20131124123749/http://gwenole.beauchesne.free.fr/sheepshaver/files/SheepShaver-Ethernet.tar.bz2

The project can be used in CodeWarrior to build a binary blob that
can then be converted into EthernetDriverFull.i by hexconv.cpp.
This commit is contained in:
Alexei Svitkine 2015-06-06 12:15:29 -04:00
parent 48b838e1cc
commit 1cef34125c
45 changed files with 2776 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View File

@ -0,0 +1,308 @@
/*
* Ethernet.cpp - SheepShaver ethernet PCI driver stub
*
* SheepShaver (C) 1997-2005 Christian Bauer and Marc Hellwig
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdeps.h"
#include <stddef.h>
#include "xlowmem.h"
#include "ether_defs.h"
// Macro for tail-calling native code from assembly functions
#define ASM_TAIL_CALL_NATIVE(NAME) \
lwz r0,XLM_##NAME(r0) ;\
lwz r2,XLM_TOC(r0) ;\
mtctr r0 ;\
bctr
// Macro for calling native code from assembly functions
#define ASM_CALL_NATIVE(NAME) \
mflr r0 ;\
stw r2,12(r1) ;\
stw r0,8(r1) ;\
stwu r1,-64(r1) ;\
lwz r0,XLM_##NAME(r0) ;\
lwz r2,XLM_TOC(r0) ;\
mtlr r0 ;\
blrl ;\
lwz r0,64+8(r1) ;\
lwz r2,64+12(r1) ;\
mtlr r0 ;\
addi r1,r1,64 ;\
blr
/*
* Driver Description structure
*/
struct DriverDescription {
uint32 driverDescSignature;
uint32 driverDescVersion;
char nameInfoStr[32];
uint32 version;
uint32 driverRuntime;
char driverName[32];
uint32 driverDescReserved[8];
uint32 nServices;
uint32 serviceCategory;
uint32 serviceType;
uint32 serviceVersion;
};
#pragma export on
DriverDescription TheDriverDescription = {
'mtej',
0,
"\pSheepShaver Ethernet",
0x01008000, // V1.0.0final
4, // kDriverIsUnderExpertControl
"\penet",
0, 0, 0, 0, 0, 0, 0, 0,
1,
'otan',
0x000a0b01, // Ethernet, Framing: Ethernet/EthernetIPX/802.2, IsDLPI
0x01000000, // V1.0.0
};
#pragma export off
/*
* install_info and related structures
*/
#ifdef BUILD_ETHER_FULL_DRIVER
#define ETHERDECL extern
#else
#define ETHERDECL static
#endif
ETHERDECL int ether_open(queue_t *rdq, void *dev, int flag, int sflag, void *creds);
ETHERDECL int ether_close(queue_t *rdq, int flag, void *creds);
ETHERDECL int ether_wput(queue_t *q, msgb *mp);
ETHERDECL int ether_wsrv(queue_t *q);
ETHERDECL int ether_rput(queue_t *q, msgb *mp);
ETHERDECL int ether_rsrv(queue_t *q);
struct ot_module_info {
uint16 mi_idnum;
char *mi_idname;
int32 mi_minpsz; // Minimum packet size
int32 mi_maxpsz; // Maximum packet size
uint32 mi_hiwat; // Queue hi-water mark
uint32 mi_lowat; // Queue lo-water mark
};
static ot_module_info module_information = {
kEnetModuleID,
"SheepShaver Ethernet",
0,
kEnetTSDU,
6000,
5000
};
typedef int (*putp_t)(queue_t *, msgb *);
typedef int (*srvp_t)(queue_t *);
typedef int (*openp_t)(queue_t *, void *, int, int, void *);
typedef int (*closep_t)(queue_t *, int, void *);
struct qinit {
putp_t qi_putp;
srvp_t qi_srvp;
openp_t qi_qopen;
closep_t qi_qclose;
void *qi_qadmin;
struct ot_module_info *qi_minfo;
void *qi_mstat;
};
static qinit read_side = {
NULL,
ether_rsrv,
ether_open,
ether_close,
NULL,
&module_information,
NULL
};
static qinit write_side = {
ether_wput,
NULL,
ether_open,
ether_close,
NULL,
&module_information,
NULL
};
struct streamtab {
struct qinit *st_rdinit;
struct qinit *st_wrinit;
struct qinit *st_muxrinit;
struct qinit *st_muxwinit;
};
static streamtab the_streamtab = {
&read_side,
&write_side,
NULL,
NULL
};
struct install_info {
struct streamtab *install_str;
uint32 install_flags;
uint32 install_sqlvl;
char *install_buddy;
void *ref_load;
uint32 ref_count;
};
enum {
kOTModIsDriver = 0x00000001,
kOTModUpperIsDLPI = 0x00002000,
SQLVL_MODULE = 3,
};
static install_info the_install_info = {
&the_streamtab,
kOTModIsDriver /*| kOTModUpperIsDLPI */,
SQLVL_MODULE,
NULL,
NULL,
0
};
// Prototypes for exported functions
extern "C" {
#pragma export on
extern uint32 ValidateHardware(void *theID);
extern install_info* GetOTInstallInfo();
extern uint8 InitStreamModule(void *theID);
extern void TerminateStreamModule(void);
#pragma export off
}
/*
* Validate that our hardware is available (always available)
*/
uint32 ValidateHardware(void *theID)
{
return 0;
}
/*
* Return pointer to install_info structure
*/
install_info *GetOTInstallInfo(void)
{
return &the_install_info;
}
/*
* Init module
*/
#ifdef BUILD_ETHER_FULL_DRIVER
asm bool NativeInitStreamModule(register void *theID)
{
ASM_CALL_NATIVE(ETHER_INIT)
}
#else
asm uint8 InitStreamModule(register void *theID)
{
ASM_TAIL_CALL_NATIVE(ETHER_INIT)
}
#endif
/*
* Terminate module
*/
#ifdef BUILD_ETHER_FULL_DRIVER
asm void NativeTerminateStreamModule(void)
{
ASM_CALL_NATIVE(ETHER_TERM)
}
#else
asm void TerminateStreamModule(void)
{
ASM_TAIL_CALL_NATIVE(ETHER_TERM)
}
#endif
/*
* DLPI functions
*/
#ifndef BUILD_ETHER_FULL_DRIVER
static asm int ether_open(register queue_t *rdq, register void *dev, register int flag, register int sflag, register void *creds)
{
ASM_TAIL_CALL_NATIVE(ETHER_OPEN)
}
static asm int ether_close(register queue_t *rdq, register int flag, register void *creds)
{
ASM_TAIL_CALL_NATIVE(ETHER_CLOSE)
}
static asm int ether_wput(register queue_t *q, register msgb *mp)
{
ASM_TAIL_CALL_NATIVE(ETHER_WPUT)
}
static asm int ether_rsrv(register queue_t *q)
{
ASM_TAIL_CALL_NATIVE(ETHER_RSRV)
}
#endif
/*
* Hooks to add-on low-level functions
*/
asm void AO_get_ethernet_address(register uint32)
{
ASM_CALL_NATIVE(ETHER_AO_GET_HWADDR)
}
asm void AO_enable_multicast(register uint32 addr)
{
ASM_CALL_NATIVE(ETHER_AO_ADD_MULTI)
}
asm void AO_disable_multicast(register uint32 addr)
{
ASM_CALL_NATIVE(ETHER_AO_DEL_MULTI)
}
asm void AO_transmit_packet(register uint32 mp)
{
ASM_CALL_NATIVE(ETHER_AO_SEND_PACKET)
}

Binary file not shown.

View File

@ -0,0 +1 @@
#ifndef CPU_EMULATION_H #define CPU_EMULATION_H static inline uint32 ReadMacInt32(uint32 addr) {return *(uint32 *)addr;} static inline uint32 Host2MacAddr(uint8 *addr) {return (uint32)addr;} static inline uint8 *Mac2HostAddr(uint32 addr) {return (uint8 *)addr;} static inline void *Mac_memset(uint32 addr, int c, size_t n) {return memset(Mac2HostAddr(addr), c, n);} static inline void *Mac2Host_memcpy(uint8 *dst, uint32 src, size_t n) {return memcpy(dst,Mac2HostAddr(src),n);} #endif /* CPU_EMULATION */

View File

@ -0,0 +1 @@
#ifndef DEBUG_H #define DEBUG_H #define D(x) #include <stdio.h> #define bug printf #endif /* DEBUG_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,113 @@
/*
* ether.h - SheepShaver Ethernet Device Driver
*
* SheepShaver (C) 1997-2005 Marc Hellwig and Christian Bauer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ETHER_H
#define ETHER_H
struct queue;
struct msgb;
typedef struct queue queue_t;
typedef struct msgb mblk_t;
// Prototypes for exported functions
extern "C" {
#pragma export on
extern uint32 ValidateHardware(void *theID);
struct install_info;
extern install_info* GetOTInstallInfo();
extern uint8 InitStreamModule(void *theID);
extern void TerminateStreamModule(void);
#pragma export off
}
extern bool NativeInitStreamModule(void *);
extern void NativeTerminateStreamModule(void);
extern int ether_open(queue_t *rdq, void *dev, int flag, int sflag, void *creds);
extern int ether_close(queue_t *rdq, int flag, void *creds);
extern int ether_wput(queue_t *q, mblk_t *mp);
extern int ether_rsrv(queue_t *q);
// System specific and internal functions/data
extern void EtherInit(void);
extern void EtherExit(void);
extern void EtherIRQ(void);
extern void AO_get_ethernet_address(uint32 addr);
extern void AO_enable_multicast(uint32 addr);
extern void AO_disable_multicast(uint32 addr);
extern void AO_transmit_packet(uint32 mp);
extern mblk_t *allocb(size_t size, int pri);
extern void OTEnterInterrupt(void);
extern void OTLeaveInterrupt(void);
extern void ether_dispatch_packet(uint32 p, uint32 length);
extern void ether_packet_received(mblk_t *mp);
extern bool ether_driver_opened;
// Ethernet packet allocator (optimized for 32-bit platforms in real addressing mode)
class EthernetPacket {
#if SIZEOF_VOID_P == 4 && REAL_ADDRESSING
uint8 packet[1516];
public:
uint32 addr(void) const { return (uint32)packet; }
#else
uint32 packet;
public:
EthernetPacket();
~EthernetPacket();
uint32 addr(void) const { return packet; }
#endif
};
// Copy packet data from message block to linear buffer (must hold at
// least 1514 bytes), returns packet length
static inline int ether_msgb_to_buffer(uint32 mp, uint8 *p)
{
int len = 0;
while (mp) {
uint32 size = ReadMacInt32(mp + 16) - ReadMacInt32(mp + 12);
Mac2Host_memcpy(p, ReadMacInt32(mp + 12), size);
len += size;
p += size;
mp = ReadMacInt32(mp + 8);
}
return len;
}
extern int32 num_wput;
extern int32 num_error_acks;
extern int32 num_tx_packets;
extern int32 num_tx_raw_packets;
extern int32 num_tx_normal_packets;
extern int32 num_tx_buffer_full;
extern int32 num_rx_packets;
extern int32 num_ether_irq;
extern int32 num_unitdata_ind;
extern int32 num_rx_fastpath;
extern int32 num_rx_no_mem;
extern int32 num_rx_dropped;
extern int32 num_rx_stream_not_ready;
extern int32 num_rx_no_unitdata_mem;
#endif

View File

@ -0,0 +1,552 @@
/*
* ether_defs.h - Definitions for DLPI Ethernet Driver
*
* SheepShaver (C) 1997-2005 Marc Hellwig and Christian Bauer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ETHER_DEFS_H
#define ETHER_DEFS_H
#if __MWERKS__ && __POWERPC__
#ifndef PRAGMA_ALIGN_SUPPORTED
#define PRAGMA_ALIGN_SUPPORTED 1
#endif
#define PACKED__
#else
#define PACKED__ __attribute__ ((packed))
#endif
/*
* Macros
*/
// Get pointer to the read queue, assumes 'q' is a write queue ptr
#define RD(q) (&q[-1])
// Get pointer to the write queue, assumes 'q' is a read queue ptr
#define WR(q) (&q[1])
#define OTCompare48BitAddresses(p1, p2) \
(*(const uint32*)((const uint8*)(p1)) == *(const uint32*)((const uint8*)(p2)) && \
*(const uint16*)(((const uint8*)(p1))+4) == *(const uint16*)(((const uint8*)(p2))+4) )
#define OTCopy48BitAddress(p1, p2) \
(*(uint32*)((uint8*)(p2)) = *(const uint32*)((const uint8*)(p1)), \
*(uint16*)(((uint8*)(p2))+4) = *(const uint16*)(((const uint8*)(p1))+4) )
#define OTClear48BitAddress(p1) \
(*(uint32*)((uint8*)(p1)) = 0, \
*(uint16*)(((uint8*)(p1))+4) = 0 )
#define OTCompare8022SNAP(p1, p2) \
(*(const uint32*)((const uint8*)(p1)) == *(const uint32*)((const uint8*)(p2)) && \
*(((const uint8*)(p1))+4) == *(((const uint8*)(p2))+4) )
#define OTCopy8022SNAP(p1, p2) \
(*(uint32*)((uint8*)(p2)) = *(const uint32*)((const uint8*)(p1)), \
*(((uint8*)(p2))+4) = *(((const uint8*)(p1))+4) )
#define OTIs48BitBroadcastAddress(p1) \
(*(uint32*)((uint8*)(p1)) == 0xffffffff && \
*(uint16*)(((uint8*)(p1))+4) == 0xffff )
#define OTSet48BitBroadcastAddress(p1) \
(*(uint32*)((uint8*)(p1)) = 0xffffffff, \
*(uint16*)(((uint8*)(p1))+4) = 0xffff )
#define OTIs48BitZeroAddress(p1) \
(*(uint32*)((uint8*)(p1)) == 0 && \
*(uint16*)(((uint8*)(p1))+4) == 0 )
/*
* Constants
*/
enum {
// Address and packet lengths
kEnetPhysicalAddressLength = 6,
k8022SAPLength = 1,
k8022DLSAPLength = 2,
k8022SNAPLength = 5,
kMaxBoundAddrLength = 6 + 2 + 5, // addr/SAP/SNAP
kEnetAndSAPAddressLength = kEnetPhysicalAddressLength + k8022DLSAPLength,
kEnetPacketHeaderLength = (2 * kEnetPhysicalAddressLength) + k8022DLSAPLength,
k8022BasicHeaderLength = 3, // SSAP/DSAP/Control
k8022SNAPHeaderLength = k8022SNAPLength + k8022BasicHeaderLength,
kMinDIXSAP = 1501,
kEnetTSDU = 1514,
// Special addresses
kSNAPSAP = 0xaa,
kMax8022SAP = 0xfe,
k8022GlobalSAP = 0xff,
kIPXSAP = 0xff,
// DLPI interface states
DL_UNBOUND = 0,
// Message types
M_DATA = 0,
M_PROTO = 1,
M_IOCTL = 14,
M_IOCACK = 129,
M_IOCNAK = 130,
M_PCPROTO = 131, // priority message
M_FLUSH = 134,
FLUSHDATA = 0,
FLUSHALL = 1,
FLUSHR = 1,
FLUSHW = 2,
FLUSHRW = 3,
// DLPI primitives
DL_INFO_REQ = 0,
DL_BIND_REQ = 1,
DL_PEER_BIND = 1,
DL_HIERARCHICAL_BIND = 2,
DL_UNBIND_REQ = 2,
DL_INFO_ACK = 3,
DL_BIND_ACK = 4,
DL_ERROR_ACK = 5,
DL_OK_ACK = 6,
DL_UNITDATA_REQ = 7,
DL_UNITDATA_IND = 8,
DL_UDERROR_IND = 9,
DL_SUBS_UNBIND_REQ = 21,
DL_SUBS_BIND_REQ = 27,
DL_SUBS_BIND_ACK = 28,
DL_ENABMULTI_REQ = 29,
DL_DISABMULTI_REQ = 30,
DL_PHYS_ADDR_REQ = 49,
DL_PHYS_ADDR_ACK = 50,
DL_FACT_PHYS_ADDR = 1,
DL_CURR_PHYS_ADDR = 2,
// DLPI states
DL_IDLE = 3,
// DLPI error codes
DL_BADADDR = 1, // improper address format
DL_OUTSTATE = 3, // improper state
DL_SYSERR = 4, // UNIX system error
DL_UNSUPPORTED = 7, // service unsupported
DL_BADPRIM = 9, // primitive unknown
DL_NOTSUPPORTED = 18, // primitive not implemented
DL_TOOMANY = 19, // limit exceeded
// errnos
MAC_ENXIO = 6,
MAC_ENOMEM = 12,
MAC_EINVAL = 22,
// Various DLPI constants
DL_CLDLS = 2, // connectionless data link service
DL_STYLE1 = 0x500,
DL_VERSION_2 = 2,
DL_CSMACD = 0,
DL_ETHER = 4,
DL_UNKNOWN = -1,
// ioctl() codes
I_OTSetFramingType = (('O' << 8) | 2),
kOTGetFramingValue = -1,
kOTFramingEthernet = 1,
kOTFramingEthernetIPX = 2,
kOTFramingEthernet8023 = 4,
kOTFraming8022 = 8,
I_OTSetRawMode = (('O' << 8) | 3),
DL_IOC_HDR_INFO = (('l' << 8) | 10),
// Buffer allocation priority
BPRI_LO = 1,
BPRI_HI = 3,
// Misc constants
kEnetModuleID = 7101
};
enum EAddrType {
keaStandardAddress = 0,
keaMulticast,
keaBroadcast,
keaBadAddress
};
/*
* Data member wrappers
*/
// Forward declarations
struct datab;
struct msgb;
struct queue;
struct multicast_node;
struct DLPIStream;
// Optimize for 32-bit big endian targets
#if defined(WORDS_BIGENDIAN) && (SIZEOF_VOID_P == 4)
// Predefined member types
typedef int8 nw_int8;
typedef int16 nw_int16;
typedef int32 nw_int32;
typedef uint8 nw_uint8;
typedef uint16 nw_uint16;
typedef uint32 nw_uint32;
typedef int nw_bool;
typedef uint8 * nw_uint8_p;
typedef void * nw_void_p;
typedef datab * nw_datab_p;
typedef msgb * nw_msgb_p;
typedef queue * nw_queue_p;
typedef multicast_node *nw_multicast_node_p;
typedef DLPIStream * nw_DLPIStream_p;
#else
// Big-endian memory accessor
template< int nbytes >
struct nw_memory_helper;
template<>
struct nw_memory_helper<1> {
static inline uint8 load(void *ptr) { return *((uint8 *)ptr); }
static inline void store(void *ptr, uint8 val) { *((uint8 *)ptr) = val; }
};
template<>
struct nw_memory_helper<2> {
static inline uint16 load(void *ptr) { return ntohs(*((uint16 *)ptr)); }
static inline void store(void *ptr, uint16 val) { *((uint16 *)ptr) = htons(val); }
};
template<>
struct nw_memory_helper<4> {
static inline uint32 load(void *ptr) { return ntohl(*((uint32 *)ptr)); }
static inline void store(void *ptr, uint32 val) { *((uint32 *)ptr) = htonl(val); }
};
// Scalar data member wrapper (specialise for pointer member types?)
template< class type, class public_type >
class nw_scalar_member_helper {
uint8 _pad[sizeof(type)];
public:
operator public_type () const {
return (public_type)(uintptr)nw_memory_helper<sizeof(type)>::load((void *)this);
}
public_type operator -> () const {
return this->operator public_type ();
}
nw_scalar_member_helper<type, public_type> & operator = (public_type val) {
nw_memory_helper<sizeof(type)>::store((void *)this, (type)(uintptr)val);
return *this;
}
nw_scalar_member_helper<type, public_type> & operator += (int val) {
*this = *this + val;
return *this;
}
nw_scalar_member_helper<type, public_type> & operator -= (int val) {
*this = *this - val;
return *this;
}
nw_scalar_member_helper<type, public_type> & operator &= (int val) {
*this = *this & val;
return *this;
}
nw_scalar_member_helper<type, public_type> & operator |= (int val) {
*this = *this | val;
return *this;
}
};
// Predefined member types
typedef nw_scalar_member_helper<uint8, int8> nw_int8;
typedef nw_scalar_member_helper<uint16, int16> nw_int16;
typedef nw_scalar_member_helper<uint32, int32> nw_int32;
typedef nw_scalar_member_helper<uint8, uint8> nw_uint8;
typedef nw_scalar_member_helper<uint16, uint16> nw_uint16;
typedef nw_scalar_member_helper<uint32, uint32> nw_uint32;
typedef nw_scalar_member_helper<int, bool> nw_bool;
typedef nw_scalar_member_helper<uint32, uint8 *> nw_uint8_p;
typedef nw_scalar_member_helper<uint32, void *> nw_void_p;
typedef nw_scalar_member_helper<uint32, datab *> nw_datab_p;
typedef nw_scalar_member_helper<uint32, msgb *> nw_msgb_p;
typedef nw_scalar_member_helper<uint32, queue *> nw_queue_p;
typedef nw_scalar_member_helper<uint32, multicast_node *> nw_multicast_node_p;
typedef nw_scalar_member_helper<uint32, DLPIStream *> nw_DLPIStream_p;
#endif
/*
* Structures
*/
// Data block
struct datab {
nw_datab_p db_freep;
nw_uint8_p db_base;
nw_uint8_p db_lim;
nw_uint8 db_ref;
nw_uint8 db_type;
// ...
};
// Message block
struct msgb {
nw_msgb_p b_next;
nw_msgb_p b_prev;
nw_msgb_p b_cont;
nw_uint8_p b_rptr;
nw_uint8_p b_wptr;
nw_datab_p b_datap;
// ...
};
// Queue (full structure required because of size)
struct queue {
nw_void_p q_qinfo;
nw_msgb_p q_first;
nw_msgb_p q_last;
nw_queue_p q_next;
nw_queue_p q_link;
nw_DLPIStream_p q_ptr;
nw_uint32 q_count;
nw_int32 q_minpsz;
nw_int32 q_maxpsz;
nw_uint32 q_hiwat;
nw_uint32 q_lowat;
nw_void_p q_bandp;
nw_uint16 q_flag;
nw_uint8 q_nband;
uint8 _q_pad1[1];
nw_void_p q_osx;
nw_queue_p q_ffcp;
nw_queue_p q_bfcp;
};
typedef struct queue queue_t;
// M_IOCTL parameters
struct iocblk {
nw_int32 ioc_cmd;
nw_void_p ioc_cr;
nw_uint32 ioc_id;
nw_uint32 ioc_count;
nw_int32 ioc_error;
nw_int32 ioc_rval;
int32 _ioc_filler[4];
};
// Priority specification
struct dl_priority_t {
nw_int32 dl_min, dl_max;
};
// DPLI primitives
struct dl_info_req_t {
nw_uint32 dl_primitive; // DL_INFO_REQ
};
struct dl_info_ack_t {
nw_uint32 dl_primitive; // DL_INFO_ACK
nw_uint32 dl_max_sdu;
nw_uint32 dl_min_sdu;
nw_uint32 dl_addr_length;
nw_uint32 dl_mac_type;
nw_uint32 dl_reserved;
nw_uint32 dl_current_state;
nw_int32 dl_sap_length;
nw_uint32 dl_service_mode;
nw_uint32 dl_qos_length;
nw_uint32 dl_qos_offset;
nw_uint32 dl_qos_range_length;
nw_uint32 dl_qos_range_offset;
nw_uint32 dl_provider_style;
nw_uint32 dl_addr_offset;
nw_uint32 dl_version;
nw_uint32 dl_brdcst_addr_length;
nw_uint32 dl_brdcst_addr_offset;
nw_uint32 dl_growth;
};
struct dl_bind_req_t {
nw_uint32 dl_primitive; // DL_BIND_REQ
nw_uint32 dl_sap;
nw_uint32 dl_max_conind;
nw_uint16 dl_service_mode;
nw_uint16 dl_conn_mgmt;
nw_uint32 dl_xidtest_flg;
};
struct dl_bind_ack_t {
nw_uint32 dl_primitive; // DL_BIND_ACK
nw_uint32 dl_sap;
nw_uint32 dl_addr_length;
nw_uint32 dl_addr_offset;
nw_uint32 dl_max_conind;
nw_uint32 dl_xidtest_flg;
};
struct dl_error_ack_t {
nw_uint32 dl_primitive; // DL_ERROR_ACK
nw_uint32 dl_error_primitive;
nw_uint32 dl_errno;
nw_uint32 dl_unix_errno;
};
struct dl_ok_ack_t {
nw_uint32 dl_primitive; // DL_ERROR_ACK
nw_uint32 dl_correct_primitive;
};
struct dl_unitdata_req_t {
nw_uint32 dl_primitive; // DL_UNITDATA_REQ
nw_uint32 dl_dest_addr_length;
nw_uint32 dl_dest_addr_offset;
dl_priority_t dl_priority;
};
struct dl_unitdata_ind_t {
nw_uint32 dl_primitive; // DL_UNITDATA_IND
nw_uint32 dl_dest_addr_length;
nw_uint32 dl_dest_addr_offset;
nw_uint32 dl_src_addr_length;
nw_uint32 dl_src_addr_offset;
nw_uint32 dl_group_address;
};
struct dl_uderror_ind_t {
nw_uint32 dl_primitive; // DL_UDERROR_IND
nw_uint32 dl_dest_addr_length;
nw_uint32 dl_dest_addr_offset;
nw_uint32 dl_unix_errno;
nw_uint32 dl_errno;
};
struct dl_subs_bind_req_t {
nw_uint32 dl_primitive; // DL_SUBS_BIND_REQ
nw_uint32 dl_subs_sap_offset;
nw_uint32 dl_subs_sap_length;
nw_uint32 dl_subs_bind_class;
};
struct dl_subs_bind_ack_t {
nw_uint32 dl_primitive; // DL_SUBS_BIND_ACK
nw_uint32 dl_subs_sap_offset;
nw_uint32 dl_subs_sap_length;
};
struct dl_subs_unbind_req_t {
nw_uint32 dl_primitive; // DL_SUBS_UNBIND_REQ
nw_uint32 dl_subs_sap_offset;
nw_uint32 dl_subs_sap_length;
};
struct dl_enabmulti_req_t {
nw_uint32 dl_primitive; // DL_ENABMULTI_REQ
nw_uint32 dl_addr_length;
nw_uint32 dl_addr_offset;
};
struct dl_disabmulti_req_t {
nw_uint32 dl_primitive; // DL_DISABMULTI_REQ
nw_uint32 dl_addr_length;
nw_uint32 dl_addr_offset;
};
struct dl_phys_addr_req_t {
nw_uint32 dl_primitive; // DL_PHYS_ADDR_REQ
nw_uint32 dl_addr_type;
};
struct dl_phys_addr_ack_t {
nw_uint32 dl_primitive; // DL_PHYS_ADDR_ACK
nw_uint32 dl_addr_length;
nw_uint32 dl_addr_offset;
};
// Parameters for I_OTSetRawMode/kOTSetRecvMode ioctl()
struct dl_recv_control_t {
nw_uint32 dl_primitive;
nw_uint32 dl_flags;
nw_uint32 dl_truncation_length;
};
union DL_primitives {
nw_uint32 dl_primitive;
dl_info_req_t info_req;
dl_info_ack_t info_ack;
dl_bind_req_t bind_req;
dl_bind_ack_t bind_ack;
dl_error_ack_t error_ack;
dl_ok_ack_t ok_ack;
dl_unitdata_req_t unitdata_req;
dl_unitdata_ind_t unitdata_ind;
dl_uderror_ind_t uderror_ind;
dl_subs_bind_req_t subs_bind_req;
dl_subs_bind_ack_t subs_bind_ack;
dl_subs_unbind_req_t subs_unbind_req;
dl_enabmulti_req_t enabmulti_req;
dl_disabmulti_req_t disabmulti_req;
dl_phys_addr_req_t phys_addr_req;
dl_phys_addr_ack_t phys_addr_ack;
};
#ifdef PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
// Packet headers
struct EnetPacketHeader {
uint8 fDestAddr[6];
uint8 fSourceAddr[6];
nw_uint16 fProto;
} PACKED__;
struct T8022Header {
uint8 fDSAP;
uint8 fSSAP;
uint8 fCtrl;
} PACKED__;
struct T8022SNAPHeader {
uint8 fDSAP;
uint8 fSSAP;
uint8 fCtrl;
uint8 fSNAP[k8022SNAPLength];
} PACKED__;
struct T8022FullPacketHeader {
EnetPacketHeader fEnetPart;
T8022SNAPHeader f8022Part;
} PACKED__;
struct T8022AddressStruct {
uint8 fHWAddr[6];
nw_uint16 fSAP;
uint8 fSNAP[k8022SNAPLength];
} PACKED__;
#ifdef PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#endif

Binary file not shown.

View File

@ -0,0 +1 @@
#include "sysdeps.h" #include "macos_util.h" #include "xlowmem.h" #include <string.h> #include <MacTypes.h> #include <CodeFragments.h> #define DEBUG 0 #include "debug.h" /* * Find symbol in shared library (using CFM) * lib and sym must be Pascal strings! */ typedef OpaqueCFragConnectionID * ConnectionID; typedef unsigned char SymClass; static uint32 FindLibSymbol(Str63 lib, Str255 sym) { ConnectionID conn_id = 0; Ptr main_addr = NULL; Str255 err = ""; Ptr sym_addr = NULL; SymClass sym_class = 0; int16 res; res = GetSharedLibrary(lib, FOURCC('p','w','p','c'), 1, &conn_id, &main_addr, err); D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id, main_addr)); if (res) return NULL; res = FindSymbol(conn_id, sym, &sym_addr, &sym_class); D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr, sym_class));//!!?? CloseConnection(&conn_id); if (res) return NULL; else return (uint32)sym_addr; } uint32 FindLibSymbol(char *lib_name, char *sym_name) { Str63 lib; memcpy(&lib[0], lib_name, lib_name[0]+1); Str255 sym; memcpy(&sym[0], sym_name, sym_name[0]+1); return FindLibSymbol(lib, sym); } /* * Memory allocators in MacOS system heap zone */ uint32 Mac_sysalloc(uint32 size) { return (uint32)NewPtrSys(size); } void Mac_sysfree(uint32 addr) { DisposePtr((char *)addr); } /* * Glue for calling MacOS routines */ #define prolog ;\ mflr r0 ;\ stw r0,8(r1) ;\ stw r2,12(r1) ;\ stwu r1,-64(r1) ;\ lwz r0,0(r3) ;\ lwz r2,4(r3) ;\ mtctr r0 #define epilog ;\ bctrl ;\ lwz r0,64+8(r1) ;\ lwz r2,64+12(r1);\ mtlr r0 ;\ addi r1,r1,64 ;\ blr asm uint32 call_macos(register uint32 tvect) { prolog epilog } asm uint32 call_macos1(register uint32 tvect, register uint32 arg1) { prolog mr r3,r4 epilog } asm uint32 call_macos2(register uint32 tvect, register uint32 arg1, register uint32 arg2) { prolog mr r3,r4 mr r4,r5 epilog } asm uint32 call_macos3(register uint32 tvect, register uint32 arg1, register uint32 arg2, register uint32 arg3) { prolog mr r3,r4 mr r4,r5 mr r5,r6 epilog } asm uint32 call_macos4(register uint32 tvect, register uint32 arg1, register uint32 arg2, register uint32 arg3, register uint32 arg4) { prolog mr r3,r4 mr r4,r5 mr r5,r6 mr r6,r7 epilog } asm uint32 call_macos5(register uint32 tvect, register uint32 arg1, register uint32 arg2, register uint32 arg3, register uint32 arg4, register uint32 arg5) { prolog mr r3,r4 mr r4,r5 mr r5,r6 mr r6,r7 mr r7,r8 epilog } asm uint32 call_macos6(register uint32 tvect, register uint32 arg1, register uint32 arg2, register uint32 arg3, register uint32 arg4, register uint32 arg5, register uint32 arg6) { prolog mr r3,r4 mr r4,r5 mr r5,r6 mr r6,r7 mr r7,r8 mr r8,r9 epilog } asm uint32 call_macos7(register uint32 tvect, register uint32 arg1, register uint32 arg2, register uint32 arg3, register uint32 arg4, register uint32 arg5, register uint32 arg6, register uint32 arg7) { prolog mr r3,r4 mr r4,r5 mr r5,r6 mr r6,r7 mr r7,r8 mr r8,r9 mr r9,r10 epilog } /* * Some standard C library implementations */ extern "C" void *memcpy(void *dest, const void *src, size_t n); void *memcpy(void *dest, const void *src, size_t n) { BlockMoveData(src, dest, n); return dest; } extern "C" void *memset(void *s, int c, size_t n); void *memset(void *s, int c, size_t n) { if (c == 0) BlockZero(s, n); else { char *p = (char *)s; n++; while (--n) *p++ = c; } return s; } extern "C" int memcmp(const void *s1, const void *s2, size_t n); int memcmp(const void *s1, const void *s2, size_t n) { const unsigned char *d = (const unsigned char *)s1; const unsigned char *s = (const unsigned char *)s2; n++; while (--n) { int r; if (r = (*d - *s)) return r; ++d; ++s; } return 0; } extern "C" int printf(const char *format, ...); int printf(const char *format, ...) { return 0; }

View File

@ -0,0 +1 @@
#ifndef MACOS_UTIL_H #define MACOS_UTIL_H // Macro for calling MacOS routines #define CallMacOS(type, tvect) call_macos((uintptr)tvect) #define CallMacOS1(type, tvect, arg1) call_macos1((uintptr)tvect, (uintptr)arg1) #define CallMacOS2(type, tvect, arg1, arg2) call_macos2((uintptr)tvect, (uintptr)arg1, (uintptr)arg2) #define CallMacOS3(type, tvect, arg1, arg2, arg3) call_macos3((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3) #define CallMacOS4(type, tvect, arg1, arg2, arg3, arg4) call_macos4((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4) #define CallMacOS5(type, tvect, arg1, arg2, arg3, arg4, arg5) call_macos5((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5) #define CallMacOS6(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6) call_macos6((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5, (uintptr)arg6) #define CallMacOS7(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6, arg7) call_macos7((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5, (uintptr)arg6, (uintptr)arg7) #ifdef __cplusplus extern "C" { #endif extern uint32 call_macos(uint32 tvect); extern uint32 call_macos1(uint32 tvect, uint32 arg1); extern uint32 call_macos2(uint32 tvect, uint32 arg1, uint32 arg2); extern uint32 call_macos3(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3); extern uint32 call_macos4(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4); extern uint32 call_macos5(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5); extern uint32 call_macos6(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5, uint32 arg6); extern uint32 call_macos7(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5, uint32 arg6, uint32 arg7); #ifdef __cplusplus } #endif // Construct four-character-code from string #define FOURCC(a,b,c,d) (((uint32)(a) << 24) | ((uint32)(b) << 16) | ((uint32)(c) << 8) | (uint32)(d)) extern uint32 FindLibSymbol(char *lib, char *sym); // Find symbol in shared library extern uint32 Mac_sysalloc(uint32 size); // Allocate block in MacOS system heap zone extern void Mac_sysfree(uint32 addr); // Release block occupied by the nonrelocatable block p #endif /* MACOS_UTIL_H */

View File

@ -0,0 +1 @@
#ifndef SYSDEPS_H #define SYSDEPS_H #include <Memory.h> #define SIZEOF_VOID_P 4 #define WORDS_BIGENDIAN 1 #define REAL_ADDRESSING 1 /* Define to build the Ethernet driver completly in MacOS space */ #define BUILD_ETHER_FULL_DRIVER 1 #define ntohl(x) ((uint32)(x)) #define ntohs(x) ((uint16)(x)) #define assert(expr) typedef int bool; typedef signed char int8; typedef signed short int16; typedef signed int int32; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedef uint32 uintptr; #endif /* SYSDEPS_H */

View File

@ -0,0 +1,64 @@
/*
* xlowmem.h - Definitions for extra Low Memory globals (0x2800..)
*
* SheepShaver (C) 1997-2005 Christian Bauer and Marc Hellwig
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef XLOWMEM_H
#define XLOWMEM_H
// Modes for XLM_RUN_MODE
#define MODE_68K 0 // 68k emulator active
#define MODE_NATIVE 1 // Switched to native mode
#define MODE_EMUL_OP 2 // 68k emulator active, within EMUL_OP routine
#define XLM_SIGNATURE 0x2800 // SheepShaver signature
#define XLM_KERNEL_DATA 0x2804 // Pointer to Kernel Data
#define XLM_TOC 0x2808 // TOC pointer of emulator
#define XLM_SHEEP_OBJ 0x280c // Pointer to SheepShaver object
#define XLM_RUN_MODE 0x2810 // Current run mode, see enum above
#define XLM_68K_R25 0x2814 // Contents of the 68k emulator's r25 (which contains the interrupt level), saved upon entering EMUL_OP mode, used by Execute68k() and the USR1 signal handler
#define XLM_IRQ_NEST 0x2818 // Interrupt disable nesting counter (>0: disabled)
#define XLM_PVR 0x281c // Theoretical PVR
#define XLM_BUS_CLOCK 0x2820 // Bus clock speed in Hz (for DriverServicesLib patch)
#define XLM_EMUL_RETURN_PROC 0x2824 // Pointer to EMUL_RETURN routine
#define XLM_EXEC_RETURN_PROC 0x2828 // Pointer to EXEC_RETURN routine
#define XLM_EMUL_OP_PROC 0x282c // Pointer to EMUL_OP routine
#define XLM_EMUL_RETURN_STACK 0x2830 // Stack pointer for EMUL_RETURN
#define XLM_RES_LIB_TOC 0x2834 // TOC pointer of Resources library
#define XLM_GET_RESOURCE 0x2838 // Pointer to native GetResource() routine
#define XLM_GET_1_RESOURCE 0x283c // Pointer to native Get1Resource() routine
#define XLM_GET_IND_RESOURCE 0x2840 // Pointer to native GetIndResource() routine
#define XLM_GET_1_IND_RESOURCE 0x2844 // Pointer to native Get1IndResource() routine
#define XLM_R_GET_RESOURCE 0x2848 // Pointer to native RGetResource() routine
#define XLM_EXEC_RETURN_OPCODE 0x284c // EXEC_RETURN opcode for Execute68k()
#define XLM_ZERO_PAGE 0x2850 // Pointer to read-only page with all bits set to 0
#define XLM_R13 0x2854 // Pointer to .sdata section (Linux)
#define XLM_ETHER_AO_GET_HWADDR 0x28b0 // Pointer to ethernet A0_get_ethernet_address() function
#define XLM_ETHER_AO_ADD_MULTI 0x28b4 // Pointer to ethernet A0_enable_multicast() function
#define XLM_ETHER_AO_DEL_MULTI 0x28b8 // Pointer to ethernet A0_disable_multicast() function
#define XLM_ETHER_AO_SEND_PACKET 0x28bc // Pointer to ethernet A0_transmit_packet() function
#define XLM_ETHER_INIT 0x28c0 // Pointer to ethernet InitStreamModule() function
#define XLM_ETHER_TERM 0x28c4 // Pointer to ethernet TerminateStreamModule() function
#define XLM_ETHER_OPEN 0x28c8 // Pointer to ethernet ether_open() function
#define XLM_ETHER_CLOSE 0x28cc // Pointer to ethernet ether_close() function
#define XLM_ETHER_WPUT 0x28d0 // Pointer to ethernet ether_wput() function
#define XLM_ETHER_RSRV 0x28d4 // Pointer to ethernet ether_rsrv() function
#define XLM_VIDEO_DOIO 0x28d8 // Pointer to video DoDriverIO() function
#endif