OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [WizNET_DEMO_TERN_186/] [include/] [SOCKET.H] - Blame information for rev 606

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 585 jeremybenn
/*
2
********************************************************************************
3
* TERN, Inc.
4
* (c) Copyright 2005, http://www.tern.com
5
*
6
* - Derived based on development version provided by Wiznet.
7
*
8
* Filename : socket.h
9
* Programmer(s):
10
* Created : 2002/06/20
11
* Modified :
12
*  2002/09/27 : - Renaming
13
*                              INT_STATUS --> INT_REG
14
*                              STATUS(i) --> INT_STATUS(i)
15
*                              C_STATUS(i) --> SOCK_STATUS(i)
16
*  2003/11/06 : Ported for use with TERN controller.  Note all byte access is at even addresses
17
*  2005/10/8  : Modified constants for easier initialization.
18
*
19
* Description : Header file of W3100A for TERN embedded controller
20
********************************************************************************
21
*/
22
#ifndef __SOCKET_H__
23
#define __SOCKET_H__
24
 
25
#include "types.h"
26
#include "i2chip_hw.h"
27
#include 
28
 
29
/*******************************************************************/
30
#define MAX_SOCK_NUM    4                                       // Concurrent maxmium number of socket
31
 
32
#define I2CHIP_C0_CR       0x00
33
#define I2CHIP_C1_CR       0x01
34
#define I2CHIP_C2_CR       0x02
35
#define I2CHIP_C3_CR       0x03
36
#define I2CHIP_C0_ISR      0x04
37
#define I2CHIP_C1_ISR      0x05
38
#define I2CHIP_C2_ISR      0x06
39
#define I2CHIP_C3_ISR      0x07
40
#define I2CHIP_IR          0x08
41
#define I2CHIP_IMR         0x09
42
 
43
#define I2CHIP_IDM_OR           0x0C
44
#define I2CHIP_IDM_AR0     0x0D
45
#define I2CHIP_IDM_AR1     0x0E
46
#define I2CHIP_IDM_DR      0x0F
47
#define I2CHIP_C0_RW_PR    0x10
48
#define I2CHIP_C0_RR_PR    0x14
49
#define I2CHIP_C0_TA_PR    0x18
50
#define I2CHIP_C1_RW_PR    0x1C
51
#define I2CHIP_C1_RR_PR    0x20
52
#define I2CHIP_C1_TA_PR    0x24
53
#define I2CHIP_C2_RW_PR    0x28
54
#define I2CHIP_C2_RR_PR    0x2C
55
#define I2CHIP_C2_TA_PR    0x30
56
#define I2CHIP_C3_RW_PR    0x34
57
#define I2CHIP_C3_RR_PR    0x38
58
#define I2CHIP_C3_TA_PR    0x3C
59
#define I2CHIP_C0_TW_PR    0x40
60
#define I2CHIP_C0_TR_PR    0x44
61
#define I2CHIP_C1_TW_PR    0x4C
62
#define I2CHIP_C1_TR_PR    0x50
63
#define I2CHIP_C2_TW_PR    0x58
64
#define I2CHIP_C2_TR_PR    0x5C
65
#define I2CHIP_C3_TW_PR    0x64
66
#define I2CHIP_C3_TR_PR    0x68
67
#define I2CHIP_GAR         0x80
68
#define I2CHIP_SMR         0x84
69
#define I2CHIP_SHAR             0x88
70
#define I2CHIP_SIPR        0x8E
71
#define I2CHIP_IRTR        0x92
72
#define I2CHIP_RCR         0x94
73
#define I2CHIP_RMSR        0x95
74
#define I2CHIP_TMSR        0x96
75
#define I2CHIP_C0_SSR      0xA0
76
#define I2CHIP_C0_SOPR     0xA1
77
#define I2CHIP_C0_DIR      0xA8
78
#define I2CHIP_CO_DPR      0xAC
79
#define I2CHIP_C0_SPR      0xAE
80
#define I2CHIP_C0_IPR      0xB0
81
#define I2CHIP_C0_TOSR     0xB1
82
#define I2CHIP_C0_MSSR     0xB2
83
 
84
#define I2CHIP_C1_SSR      0xB8
85
#define I2CHIP_C1_SOPR     0xB9
86
#define I2CHIP_C1_DIR      0xC0
87
#define I2CHIP_C1_DPR      0xC4
88
#define I2CHIP_C1_SPR      0xC6
89
#define I2CHIP_C1_IPR      0xC8
90
#define I2CHIP_C1_TOSR     0xC9
91
#define I2CHIP_C1_MSSR     0xCA
92
 
93
#define I2CHIP_C2_SSR      0xD0
94
#define I2CHIP_C2_SOPR     0xD1
95
#define I2CHIP_C2_DIR      0xD8
96
#define I2CHIP_C2_DPR      0xDC
97
#define I2CHIP_C2_SPR      0xDE
98
#define I2CHIP_C2_IPR      0xE0
99
#define I2CHIP_C2_TOSR     0xE1
100
#define I2CHIP_C2_MSSR     0xE2
101
 
102
#define I2CHIP_C3_SSR      0xE8
103
#define I2CHIP_C3_SOPR     0xE9
104
#define I2CHIP_C3_DIR      0xF0
105
#define I2CHIP_C3_DPR      0xF4
106
#define I2CHIP_C3_SPR      0xF6
107
#define I2CHIP_C3_IPR      0xF8
108
#define I2CHIP_C3_TOSR     0xF9
109
#define I2CHIP_C3_MSSR     0xFA
110
 
111
#define MAX_SEGMENT_SIZE        1460                    // Maximum TCP transmission packet size
112
#define MAX_BUF_SIZE1           0
113
 
114
 
115
/* SOCKET OPTION(Settting OPT_PROTOCOL REG.) */
116
#define SOCKOPT_BROADCAST       0x80            // Transmission, Reception of broadcasting data
117
#define SOCKOPT_NDTIMEOUT       0x40            // Setting timeout
118
#define SOCKOPT_NDACK           0x20            // Setting No Delayed Ack(TCP)
119
#define SOCKOPT_SWS                     0x10            // Setting Silly Window Syndrome(TCP)
120
 
121
/* OPTION(Setting OPT_PROTOCOL REG.) for MAC LAYER RAW MODE */
122
#define MACLOPT_RXERR           0x80            // Setting reception of error packet
123
#define MACLOPT_BROADCAST       0x40            // Setting reception of broadcast packet
124
#define MACLOPT_PROMISC         0x20            // Setting reception of promiscuous packet
125
 
126
/* Distinguish TCP / UDP / IP RAW / MAC RAW (Setting OPT_PROTOCOL REG.) */
127
#define SOCK_CLOSEDM    0x00                    // unused socket
128
#define SOCK_STREAM             0x01                    // TCP
129
#define SOCK_DGRAM              0x02                    // UDP
130
#define SOCK_IPL_RAW    0x03                    // IP LAYER RAW SOCK
131
#define SOCK_MACL_RAW   0x04                    // MAC LAYER RAW SOCK
132
 
133
/* Setting IP PROTOCOL */
134
#define IPPROTO_IP              0               // dummy for IP
135
#define IPPROTO_ICMP            1               // control message protocol
136
#define IPPROTO_IGMP            2               // internet group management protocol
137
#define IPPROTO_GGP             3               // gateway^2 (deprecated)
138
#define IPPROTO_TCP             6               // tcp
139
#define IPPROTO_PUP             12              // pup
140
#define IPPROTO_UDP             17              // user datagram protocol
141
#define IPPROTO_IDP             22              // xns idp
142
#define IPPROTO_ND              77              // UNOFFICIAL net disk proto
143
#define IPPROTO_RAW             255             // raw IP packet
144
 
145
/* Select parameter to use */
146
#define SEL_CONTROL     0                        //Confirm socket status
147
#define SEL_SEND                1                       // Confirm Tx free buffer size
148
#define SEL_RECV                2                       // Confirm Rx data size
149
 
150
/* Command variables */
151
#define CSYS_INIT               0x01       // To set up network information(mac address, gateway address,
152
                              // subnet mask, source ip)
153
#define CSOCK_INIT      0x02            // To initialize socket
154
#define CCONNECT                0x04            // To establish connection as tcp client mode
155
#define CLISTEN         0x08            // To wait for connection request as tcp server mode
156
#define CCLOSE                  0x10            // To terminate connection
157
#define CSEND                   0x20            // To send data
158
#define CRECV                   0x40            // To receive data
159
#define CSW_RESET               0x80            // To do software reset
160
 
161
#define CSET_MEMORY_TEST   0x80     // To set the memory test bit
162
#define CRESET_MEMORY_TEST 0x00     // To clear the memory test bit
163
 
164
/* Status Variables */
165
#define SSYS_INIT_OK            0x01    // Completion of CSYS_INIT command
166
#define SSOCK_INIT_OK   0x02    // Completion of CSOCK_INIT command
167
#define SESTABLISHED            0x04    // Completion of connection setup
168
#define SCLOSED                 0x08    // Completion of CCLOSED command
169
#define SSEND_OK                   0x20 // Completion of sending data
170
#define SRECV_OK                   0x40 // Completion of receiving data
171
 
172
/* Socket Status Vabiables */
173
#define SOCK_CLOSED                0x00    // Status of connection closed
174
#define SOCK_ARP                      0x01              // Status of ARP
175
#define SOCK_LISTEN                0x02         // Status of waiting for TCP connection setup
176
#define SOCK_SYNSENT               0x03         // Status of setting up TCP connection
177
#define SOCK_SYNSENT_ACK        0x04            // Status of setting up TCP connection
178
#define SOCK_SYNRECV               0x05         // Status of setting up TCP connection
179
#define SOCK_ESTABLISHED        0x06            // Status of TCP connection established
180
#define SOCK_CLOSE_WAIT         0x07            // Status of closing TCP connection
181
#define SOCK_LAST_ACK           0x08            // Status of closing TCP connection
182
#define SOCK_FIN_WAIT1          0x09            // Status of closing TCP connection
183
#define SOCK_FIN_WAIT2          0x0A            // Status of closing TCP connection
184
#define SOCK_CLOSING               0x0B         // Status of closing TCP connection
185
#define SOCK_TIME_WAIT          0x0C            // Status of closing TCP connection
186
#define SOCK_RESET                 0x0D         // Status of closing TCP connection
187
#define SOCK_INIT                     0x0E              // Status of socket initialization
188
#define SOCK_UDP                      0x0F              // Status of UDP
189
#define SOCK_RAW                      0x10              // Status of IP RAW
190
 
191
/* TERN Behavior Parameters */
192
#define TERN_TDMA_THRES    10000      // Use DMA for transmits if data > thres bytes.
193
#define TERN_RDMA_THRES    10000      // Use DMA for receives if data > thres bytes.
194
                                      // High thres value effectively disables DMA
195
 
196
void far interrupt in4_isr_i2chip(void);
197
 
198
//void ISR_ESTABLISHED(SOCKET s);
199
//void ISR_CLOSED(SOCKET s);
200
//void ISR_RX(SOCKET s);
201
 
202
void initW3100A(void);
203
void sysinit(u_char sbufsize, u_char rbufsize);
204
void setsubmask(u_char * addr);
205
void setgateway(u_char * addr);
206
void setMACAddr(u_char * addr);
207
void setIP(u_char * addr);
208
 
209
char socket(SOCKET s, u_char protocol, u_int port, u_char flag);
210
 
211
void setIPprotocol(SOCKET s, u_char ipprotocol);
212
 
213
void setINTMask(u_char mask);
214
void settimeout(u_char * val);
215
void setTOS(SOCKET s, u_char tos);
216
 
217
void GetDestAddr(SOCKET s, u_char* addr);
218
 
219
//void setbroadcast(SOCKET s);
220
 
221
char connect(SOCKET s, u_char far * addr, u_int port);
222
char NBconnect(SOCKET s, u_char far * addr, u_int port);
223
 
224
//char listen(SOCKET s, u_char far * addr, u_int far * port);
225
char NBlisten(SOCKET s);
226
 
227
void initseqnum(SOCKET s);
228
 
229
int send(SOCKET s, u_char far * buf, u_int len);
230
int send_in(SOCKET s, u_char far * buf, u_int len);
231
int recv(SOCKET s, u_char far * buf, u_int len);
232
 
233
u_int sendto(SOCKET , u_char far * buf, u_int, u_char * addr, u_int);
234
u_int sendto_in(SOCKET , u_char far *, u_int);
235
u_int recvfrom(SOCKET , u_char far * buf, u_int, u_char * addr, u_int *);
236
 
237
u_int read_data(SOCKET s, u_int src_offset, u_char far * dst, u_int len);
238
u_int write_data(SOCKET s, u_char far * src, u_int dst_offset, u_int len);
239
 
240
void close(SOCKET s);
241
char reset_sock(SOCKET s);
242
 
243
u_int select(SOCKET s, u_char func);
244
void recv_clear(SOCKET s);
245
u_char tx_empty(SOCKET s);
246
 
247
#endif  // __SOCKET_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.