aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/sql/CallableStatement.java
blob: 9a1547e94da22db8d56001125c8ea97d4e3e4380 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* CallableStatement.java -- A statement for calling stored procedures.
   Copyright (C) 1999, 2000 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath 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, or (at your option)
any later version.
 
GNU Classpath 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 GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */


package java.sql;

import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Map;

/**
  * This interface provides a mechanism for calling stored procedures.
  *
  * @author Aaron M. Renn (arenn@urbanophile.com)
  */
public interface CallableStatement extends PreparedStatement
{

/*************************************************************************/

/**
  * This method tests whether the value of the last parameter that was fetched
  * was actually a SQL NULL value.
  *
  * @return <code>true</code> if the last parameter fetched was a NULL,
  * <code>false</code> otherwise.
  * 
  * @exception SQLException If an error occurs.
  */
public abstract boolean
wasNull() throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>String</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>String</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract String
getString(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Object</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as an <code>Object</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Object
getObject(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Object</code>.
  *
  * @param index The index of the parameter to return.
  * @param map The mapping to use for conversion from SQL to Java types.
  *
  * @return The parameter value as an <code>Object</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Object
getObject(int index, Map map) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>boolean</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>boolean</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract boolean
getBoolean(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>byte</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>byte</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract byte
getByte(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>short</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>short</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract short
getShort(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>int</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>int</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract int
getInt(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>long</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>long</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract long
getLong(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>float</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>float</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract float
getFloat(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>double</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>double</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract double
getDouble(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>BigDecimal</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>BigDecimal</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract BigDecimal
getBigDecimal(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>BigDecimal</code>.
  *
  * @param index The index of the parameter to return.
  * @param scale The number of digits to the right of the decimal to return.
  *
  * @return The parameter value as a <code>BigDecimal</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract BigDecimal
getBigDecimal(int index, int scale) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * byte array.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a byte array
  *
  * @exception SQLException If an error occurs.
  */
public abstract byte[]
getBytes(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Date</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>java.sql.Date</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Date
getDate(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Date</code>.
  *
  * @param index The index of the parameter to return.
  * @param calendar The <code>Calendar</code> to use for timezone and locale.
  *
  * @return The parameter value as a <code>java.sql.Date</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Date
getDate(int index, Calendar calendar) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Time</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>java.sql.Time</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Time
getTime(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Time</code>.
  *
  * @param index The index of the parameter to return.
  * @param calendar The <code>Calendar</code> to use for timezone and locale.
  *
  * @return The parameter value as a <code>java.sql.Time</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Time
getTime(int index, Calendar calendar) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Timestamp</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>java.sql.Timestamp</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Timestamp
getTimestamp(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>java.sql.Timestamp</code>.
  *
  * @param index The index of the parameter to return.
  * @param calendar The <code>Calendar</code> to use for timezone and locale.
  *
  * @return The parameter value as a <code>java.sql.Timestamp</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract java.sql.Timestamp
getTimestamp(int index, Calendar calendar) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Ref</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>Ref</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Ref
getRef(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Blob</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>Blob</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Blob
getBlob(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Clob</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>Clob</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Clob
getClob(int index) throws SQLException;

/*************************************************************************/

/**
  * This method returns the value of the specified parameter as a Java
  * <code>Array</code>.
  *
  * @param index The index of the parameter to return.
  *
  * @return The parameter value as a <code>Array</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract Array
getArray(int index) throws SQLException;

/*************************************************************************/

/**
  * This method registers the specified parameter as an output parameter
  * of the specified SQL type.
  *
  * @param index The index of the parameter to register as output.
  * @param type The SQL type value from <code>Types</code>.
  *
  * @exception SQLException If an error occurs.
  */
public abstract void
registerOutParameter(int index, int type) throws SQLException;

/*************************************************************************/

/**
  * This method registers the specified parameter as an output parameter
  * of the specified SQL type.
  *
  * @param index The index of the parameter to register as output.
  * @param type The SQL type value from <code>Types</code>.
  * @param name The user defined data type name.
  *
  * @exception SQLException If an error occurs.
  */
public abstract void
registerOutParameter(int index, int type, String name) throws SQLException;

/*************************************************************************/

/**
  * This method registers the specified parameter as an output parameter
  * of the specified SQL type and scale.
  *
  * @param index The index of the parameter to register as output.
  * @param type The SQL type value from <code>Types</code>.
  * @param scale The scale of the value that will be returned.
  *
  * @exception SQLException If an error occurs.
  */
public abstract void
registerOutParameter(int index, int type, int scale) throws SQLException;

} // interface CallableStatement


s by <tymm@computer.org> 0.451 5-Nov-98 Fixed mca stuff cuz I'm a dummy. <tymm@computer.org> 0.5 14-Nov-98 Re-spin for 2.1.x kernels. 0.51 27-Jun-99 Correct received packet length for CRC from report by <worm@dkik.dk> ========================================================================= */ #include "etherboot.h" #include "nic.h" #include <gpxe/isa.h> #include "console.h" #include <gpxe/ethernet.h> /* ** I/O addresses. Note that the 2k buffer option is not supported in ** this driver. */ #define DEPCA_NICSR 0x00 /* Network interface CSR */ #define DEPCA_RBI 0x02 /* RAM buffer index (2k buffer mode) */ #define DEPCA_DATA 0x04 /* LANCE registers' data port */ #define DEPCA_ADDR 0x06 /* LANCE registers' address port */ #define DEPCA_HBASE 0x08 /* EISA high memory base address reg. */ #define DEPCA_PROM 0x0c /* Ethernet address ROM data port */ #define DEPCA_CNFG 0x0c /* EISA Configuration port */ #define DEPCA_RBSA 0x0e /* RAM buffer starting address (2k buff.) */ /* ** These are LANCE registers addressable through nic->ioaddr + DEPCA_ADDR */ #define CSR0 0 #define CSR1 1 #define CSR2 2 #define CSR3 3 /* ** NETWORK INTERFACE CSR (NI_CSR) bit definitions */ #define TO 0x0100 /* Time Out for remote boot */ #define SHE 0x0080 /* SHadow memory Enable */ #define BS 0x0040 /* Bank Select */ #define BUF 0x0020 /* BUFfer size (1->32k, 0->64k) */ #define RBE 0x0010 /* Remote Boot Enable (1->net boot) */ #define AAC 0x0008 /* Address ROM Address Counter (1->enable) */ #define _128KB 0x0008 /* 128kB Network RAM (1->enable) */ #define IM 0x0004 /* Interrupt Mask (1->mask) */ #define IEN 0x0002 /* Interrupt tristate ENable (1->enable) */ #define LED 0x0001 /* LED control */ /* ** Control and Status Register 0 (CSR0) bit definitions */ #define ERR 0x8000 /* Error summary */ #define BABL 0x4000 /* Babble transmitter timeout error */ #define CERR 0x2000 /* Collision Error */ #define MISS 0x1000 /* Missed packet */ #define MERR 0x0800 /* Memory Error */ #define RINT 0x0400 /* Receiver Interrupt */ #define TINT 0x0200 /* Transmit Interrupt */ #define IDON 0x0100 /* Initialization Done */ #define INTR 0x0080 /* Interrupt Flag */ #define INEA 0x0040 /* Interrupt Enable */ #define RXON 0x0020 /* Receiver on */ #define TXON 0x0010 /* Transmitter on */ #define TDMD 0x0008 /* Transmit Demand */ #define STOP 0x0004 /* Stop */ #define STRT 0x0002 /* Start */ #define INIT 0x0001 /* Initialize */ #define INTM 0xff00 /* Interrupt Mask */ #define INTE 0xfff0 /* Interrupt Enable */ /* ** CONTROL AND STATUS REGISTER 3 (CSR3) */ #define BSWP 0x0004 /* Byte SWaP */ #define ACON 0x0002 /* ALE control */ #define BCON 0x0001 /* Byte CONtrol */ /* ** Initialization Block Mode Register */ #define PROM 0x8000 /* Promiscuous Mode */ #define EMBA 0x0080 /* Enable Modified Back-off Algorithm */ #define INTL 0x0040 /* Internal Loopback */ #define DRTY 0x0020 /* Disable Retry */ #define COLL 0x0010 /* Force Collision */ #define DTCR 0x0008 /* Disable Transmit CRC */ #define LOOP 0x0004 /* Loopback */ #define DTX 0x0002 /* Disable the Transmitter */ #define DRX 0x0001 /* Disable the Receiver */ /* ** Receive Message Descriptor 1 (RMD1) bit definitions. */ #define R_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */ #define R_ERR 0x4000 /* Error Summary */ #define R_FRAM 0x2000 /* Framing Error */ #define R_OFLO 0x1000 /* Overflow Error */ #define R_CRC 0x0800 /* CRC Error */ #define R_BUFF 0x0400 /* Buffer Error */ #define R_STP 0x0200 /* Start of Packet */ #define R_ENP 0x0100 /* End of Packet */ /* ** Transmit Message Descriptor 1 (TMD1) bit definitions. */ #define T_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */ #define T_ERR 0x4000 /* Error Summary */ #define T_ADD_FCS 0x2000 /* More the 1 retry needed to Xmit */ #define T_MORE 0x1000 /* >1 retry to transmit packet */ #define T_ONE 0x0800 /* 1 try needed to transmit the packet */ #define T_DEF 0x0400 /* Deferred */ #define T_STP 0x02000000 /* Start of Packet */ #define T_ENP 0x01000000 /* End of Packet */ #define T_FLAGS 0xff000000 /* TX Flags Field */ /* ** Transmit Message Descriptor 3 (TMD3) bit definitions. */ #define TMD3_BUFF 0x8000 /* BUFFer error */ #define TMD3_UFLO 0x4000 /* UnderFLOw error */ #define TMD3_RES 0x2000 /* REServed */ #define TMD3_LCOL 0x1000 /* Late COLlision */ #define TMD3_LCAR 0x0800 /* Loss of CARrier */ #define TMD3_RTRY 0x0400 /* ReTRY error */ /* ** Ethernet PROM defines */ #define PROBE_LENGTH 32 /* ** Set the number of Tx and Rx buffers. Ensure that the memory requested ** here is <= to the amount of shared memory set up by the board switches. ** The number of descriptors MUST BE A POWER OF 2. ** ** total_memory = NUM_RX_DESC*(8+RX_BUFF_SZ) + NUM_TX_DESC*(8+TX_BUFF_SZ) */ #define NUM_RX_DESC 2 /* Number of RX descriptors */ #define NUM_TX_DESC 2 /* Number of TX descriptors */ #define RX_BUFF_SZ 1536 /* Buffer size for each Rx buffer */ #define TX_BUFF_SZ 1536 /* Buffer size for each Tx buffer */ /* ** ISA Bus defines */ #ifndef DEPCA_MODEL #define DEPCA_MODEL DEPCA #endif static enum { DEPCA, DE100, DE101, DE200, DE201, DE202, DE210, DE212, DE422, unknown } adapter = DEPCA_MODEL; /* ** Name <-> Adapter mapping */ static char *adapter_name[] = { "DEPCA", "DE100","DE101", "DE200","DE201","DE202", "DE210","DE212", "DE422", "" }; #ifndef DEPCA_RAM_BASE #define DEPCA_RAM_BASE 0xd0000 #endif /* ** Memory Alignment. Each descriptor is 4 longwords long. To force a ** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and ** DESC_ALIGN. ALIGN aligns the start address of the private memory area ** and hence the RX descriptor ring's first entry. */ #define ALIGN4 ((u32)4 - 1) /* 1 longword align */ #define ALIGN8 ((u32)8 - 1) /* 2 longword (quadword) align */ #define ALIGN ALIGN8 /* Keep the LANCE happy... */ /* ** The DEPCA Rx and Tx ring descriptors. */ struct depca_rx_desc { volatile s32 base; s16 buf_length; /* This length is negative 2's complement! */ s16 msg_length; /* This length is "normal". */ }; struct depca_tx_desc { volatile s32 base; s16 length; /* This length is negative 2's complement! */ s16 misc; /* Errors and TDR info */ }; #define LA_MASK 0x0000ffff /* LANCE address mask for mapping network RAM to LANCE memory address space */ /* ** The Lance initialization block, described in databook, in common memory. */ struct depca_init { u16 mode; /* Mode register */ u8 phys_addr[ETH_ALEN]; /* Physical ethernet address */ u8 mcast_table[8]; /* Multicast Hash Table. */ u32 rx_ring; /* Rx ring base pointer & ring length */ u32 tx_ring; /* Tx ring base pointer & ring length */ }; struct depca_private { struct depca_rx_desc *rx_ring; struct depca_tx_desc *tx_ring; struct depca_init init_block; /* Shadow init block */ char *rx_memcpy[NUM_RX_DESC]; char *tx_memcpy[NUM_TX_DESC]; u32 bus_offset; /* ISA bus address offset */ u32 sh_mem; /* address of shared mem */ u32 dma_buffs; /* Rx & Tx buffer start */ int rx_cur, tx_cur; /* Next free ring entry */ int txRingMask, rxRingMask; s32 rx_rlen, tx_rlen; /* log2([rt]xRingMask+1) for the descriptors */ }; static Address mem_start = DEPCA_RAM_BASE; static Address mem_len, offset; static struct depca_private lp; /* ** Miscellaneous defines... */ #define STOP_DEPCA(ioaddr) \ outw(CSR0, ioaddr + DEPCA_ADDR);\ outw(STOP, ioaddr + DEPCA_DATA) /* Initialize the lance Rx and Tx descriptor rings. */ static void depca_init_ring(struct nic *nic) { int i; u32 p; lp.rx_cur = lp.tx_cur = 0; /* Initialize the base addresses and length of each buffer in the ring */ for (i = 0; i <= lp.rxRingMask; i++) { writel((p = lp.dma_buffs + i * RX_BUFF_SZ) | R_OWN, &lp.rx_ring[i].base); writew(-RX_BUFF_SZ, &lp.rx_ring[i].buf_length); lp.rx_memcpy[i] = (char *) (p + lp.bus_offset); } for (i = 0; i <= lp.txRingMask; i++) { writel((p = lp.dma_buffs + (i + lp.txRingMask + 1) * TX_BUFF_SZ) & 0x00ffffff, &lp.tx_ring[i].base); lp.tx_memcpy[i] = (char *) (p + lp.bus_offset); } /* Set up the initialization block */ lp.init_block.rx_ring = ((u32) ((u32) lp.rx_ring) & LA_MASK) | lp.rx_rlen; lp.init_block.tx_ring = ((u32) ((u32) lp.tx_ring) & LA_MASK) | lp.tx_rlen; for (i = 0; i < ETH_ALEN; i++) lp.init_block.phys_addr[i] = nic->node_addr[i]; lp.init_block.mode = 0x0000; /* Enable the Tx and Rx */ memset(lp.init_block.mcast_table, 0, sizeof(lp.init_block.mcast_table)); } static inline void LoadCSRs(struct nic *nic) { outw(CSR1, nic->ioaddr + DEPCA_ADDR); /* initialisation block address LSW */ outw((u16) (lp.sh_mem & LA_MASK), nic->ioaddr + DEPCA_DATA); outw(CSR2, nic->ioaddr + DEPCA_ADDR); /* initialisation block address MSW */ outw((u16) ((lp.sh_mem & LA_MASK) >> 16), nic->ioaddr + DEPCA_DATA); outw(CSR3, nic->ioaddr + DEPCA_ADDR); /* ALE control */ outw(ACON, nic->ioaddr + DEPCA_DATA); outw(CSR0, nic->ioaddr + DEPCA_ADDR); /* Point back to CSR0 */ } static inline int InitRestartDepca(struct nic *nic) { int i; /* Copy the shadow init_block to shared memory */ memcpy_toio((char *)lp.sh_mem, &lp.init_block, sizeof(struct depca_init)); outw(CSR0, nic->ioaddr + DEPCA_ADDR); /* point back to CSR0 */ outw(INIT, nic->ioaddr + DEPCA_DATA); /* initialise DEPCA */ for (i = 0; i < 100 && !(inw(nic->ioaddr + DEPCA_DATA) & IDON); i++) ; if (i < 100) { /* clear IDON by writing a 1, and start LANCE */ outw(IDON | STRT, nic->ioaddr + DEPCA_DATA); } else { printf("DEPCA not initialised\n"); return (1); } return (0); } /************************************************************************** RESET - Reset adapter ***************************************************************************/ static void depca_reset(struct nic *nic) { s16 nicsr; int i, j; STOP_DEPCA(nic->ioaddr); nicsr = inb(nic->ioaddr + DEPCA_NICSR); nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM); outb(nicsr, nic->ioaddr + DEPCA_NICSR); if (inw(nic->ioaddr + DEPCA_DATA) != STOP) { printf("depca: Cannot stop NIC\n"); return; } /* Initialisation block */ lp.sh_mem = mem_start; mem_start += sizeof(struct depca_init); /* Tx & Rx descriptors (aligned to a quadword boundary) */ mem_start = (mem_start + ALIGN) & ~ALIGN; lp.rx_ring = (struct depca_rx_desc *) mem_start; mem_start += (sizeof(struct depca_rx_desc) * NUM_RX_DESC); lp.tx_ring = (struct depca_tx_desc *) mem_start; mem_start += (sizeof(struct depca_tx_desc) * NUM_TX_DESC); lp.bus_offset = mem_start & 0x00ff0000; /* LANCE re-mapped start address */ lp.dma_buffs = mem_start & LA_MASK; /* Finish initialising the ring information. */ lp.rxRingMask = NUM_RX_DESC - 1; lp.txRingMask = NUM_TX_DESC - 1; /* Calculate Tx/Rx RLEN size for the descriptors. */ for (i = 0, j = lp.rxRingMask; j > 0; i++) { j >>= 1; } lp.rx_rlen = (s32) (i << 29); for (i = 0, j = lp.txRingMask; j > 0; i++) { j >>= 1; } lp.tx_rlen = (s32) (i << 29); /* Load the initialisation block */ depca_init_ring(nic); LoadCSRs(nic); InitRestartDepca(nic); } /************************************************************************** POLL - Wait for a frame ***************************************************************************/ static int depca_poll(struct nic *nic, int retrieve) { int entry; u32 status; entry = lp.rx_cur; if ((status = readl(&lp.rx_ring[entry].base) & R_OWN)) return (0); if ( ! retrieve ) return 1; memcpy(nic->packet, lp.rx_memcpy[entry], nic->packetlen = lp.rx_ring[entry].msg_length); lp.rx_ring[entry].base |= R_OWN; lp.rx_cur = (++lp.rx_cur) & lp.rxRingMask; return (1); } /************************************************************************** TRANSMIT - Transmit a frame ***************************************************************************/ static void depca_transmit( struct nic *nic, const char *d, /* Destination */ unsigned int t, /* Type */ unsigned int s, /* size */ const char *p) /* Packet */ { int entry, len; char *mem; /* send the packet to destination */ /* ** Caution: the right order is important here... dont ** setup the ownership rights until all the other ** information is in place */ mem = lp.tx_memcpy[entry = lp.tx_cur]; memcpy_toio(mem, d, ETH_ALEN); memcpy_toio(mem + ETH_ALEN, nic->node_addr, ETH_ALEN); mem[ETH_ALEN * 2] = t >> 8; mem[ETH_ALEN * 2 + 1] = t; memcpy_toio(mem + ETH_HLEN, p, s);