ethernet.h
3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*
* sim_ether.h - Interface to the ethernet.
*
* Created by: Ed Bugnion, 06/95
* Revised: Dan Teodosiu, 07/95
*/
/* ************************************************************************
* In the new version, we model an ethernet controller capable of
* handling multiple outstanding sends and receives. The controller
* is controlled through uncached reads/writes in the I/O space. It
* can handle ETHER_MAX_RCV_ENTRIES incoming packets before dropping
* them on the floor. On the way out, it can buffer up to
* ETHER_MAX_SND_ENTRIES requests and support a scatter-gather of the
* chunks of the packets. The maximum number of packet chunks is set
* to ETHER_MAX_SND_CHUNKS.
*
* The controller maintains 3 circular buffers, received packets, send
* packets and the send packet chunks. It will issue an interrupt if
* at least one of the
* **************************************************************************/
#ifndef _SIM_ETHER_H
#define _SIM_ETHER_H
#define ETHER_MAX_CONTROLLERS 32
#define ETHER_MAX_RCV_ENTRIES 64
#define ETHER_MAX_SND_ENTRIES 64
#define ETHER_MAX_SND_CHUNKS 128
#include "../../cpus/simos/machine_defs.h"
typedef DevRegister EthRegister;
/*
* Ethernet controller registers.
*/
typedef struct SimetherRegisters {
EthRegister etheraddr[6]; /* Controller tells OS its internal ethernet address. */
EthRegister numRcvEntries;/* Read by OS, set by controller. Indicates how many
* receive ring buffer entries will be used. OS must
* allocate a rcv buffer for each of these entries. */
EthRegister numSndEntries;/* Read by OS, set by contr. Informs the OS how many
* send ring buff entries will be used so it knows when
* to wrap its index pointer. */
EthRegister numSndChunks; /* Same as numSndEntries. */
struct {
EthRegister pAddr;
EthRegister maxLen;
EthRegister len;
EthRegister flag;
} rcvEntries[ ETHER_MAX_RCV_ENTRIES ];
struct {
EthRegister firstChunk;
EthRegister lastChunk;
EthRegister flag;
} sndEntries[ ETHER_MAX_SND_ENTRIES ];
struct {
EthRegister pAddr;
EthRegister len;
} sndChunks[ETHER_MAX_SND_CHUNKS ];
EthRegister intrCPU; /* OS tells controller which CPU to interrupt */
} SimetherRegisters;
/* values for flag field: */
#define OS_OWNED 1
#define CONTROLLER_OWNED 2
#define SIMETHER_MAX_TRANSFER_SIZE 1800
/*** SimOS interface ***/
typedef void (*EtherIntFunc)(int iface_num, int on);
extern int SimetherInit(int restore, EtherIntFunc int_f);
extern void SimetherInitCluster(void);
extern char* SimetherAddr(int iface_num);
extern void SimetherPoll(void); /* poll function, called periodically */
/* called from cluster.c */
extern int SimetherReceivePacket(int iface_num,char *packet,int packetSize);
/* parameters */
extern char *EthersimHostname;
extern char *EtherAddress;
extern int EtherSendPort;
extern int RestoreEthernet;
/*** OS interface ***/
/* Note: for the following function, offs is the offset in BYTES
* from the beginning of a SimetherRegisters structures. Legal offsets
* are all uint (word) aligned.
*
* The function is used for reading/writing ether registers. Certain
* registers (such as flags) trigger actions (sending a packet).
*
* Only dword-sized accesses are supported.
*/
extern EthRegister SimetherIO(int iface_num, int offset, int is_write, EthRegister data);
#endif /* _SIM_ETHER_H */