finally move buildroot-ng to trunk
[openwrt.git] / target / linux / ar7-2.4 / patches / 004-atm_driver.patch
1 diff -urN linux.old/drivers/atm/Config.in linux.dev/drivers/atm/Config.in
2 --- linux.old/drivers/atm/Config.in 2005-08-22 23:18:37.773532032 +0200
3 +++ linux.dev/drivers/atm/Config.in 2005-08-23 04:46:50.076846888 +0200
4 @@ -99,4 +99,10 @@
5 bool 'Use S/UNI PHY driver' CONFIG_ATM_HE_USE_SUNI
6 fi
7 fi
8 +#
9 +# Texas Instruments SANGAM ADSL/ATM support
10 +#
11 +if [ "$CONFIG_AR7" = "y" ]; then
12 + tristate 'Texas Instruments SANGAM ATM/ADSL support' CONFIG_MIPS_SANGAM_ATM
13 +fi
14 endmenu
15 diff -urN linux.old/drivers/atm/Makefile linux.dev/drivers/atm/Makefile
16 --- linux.old/drivers/atm/Makefile 2005-08-22 23:18:37.773532032 +0200
17 +++ linux.dev/drivers/atm/Makefile 2005-08-23 04:46:50.077846736 +0200
18 @@ -14,6 +14,32 @@
19 obj-$(CONFIG_ATM_NICSTAR) += nicstar.o
20 obj-$(CONFIG_ATM_IDT77252) += idt77252.o
21
22 +ifeq ($(CONFIG_AR7),y)
23 +
24 +subdir-$(CONFIG_MIPS_SANGAM_ATM) += sangam_atm
25 +
26 +EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
27 +#EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP
28 +
29 +ifeq ($(ANNEX),B)
30 +EXTRA_CFLAGS += -DANNEX_B -DB
31 +else
32 +ifeq ($(ANNEX),C)
33 +EXTRA_CFLAGS += -DANNEX_C -DC
34 +else
35 +EXTRA_CFLAGS += -DANNEX_A -DP
36 +endif
37 +endif
38 +
39 +list-multi := tiatm.o
40 +tiatm-objs := sangam_atm/tn7atm.o sangam_atm/tn7dsl.o sangam_atm/tn7sar.o \
41 + sangam_atm/dsl_hal_api.o sangam_atm/dsl_hal_support.o sangam_atm/cpsar.o \
42 + sangam_atm/aal5sar.o
43 +
44 +obj-$(CONFIG_MIPS_SANGAM_ATM) += sangam_atm/tiatm.o
45 +
46 +endif
47 +
48 ifeq ($(CONFIG_ATM_NICSTAR_USE_SUNI),y)
49 obj-$(CONFIG_ATM_NICSTAR) += suni.o
50 endif
51 diff -urN linux.old/drivers/atm/sangam_atm/aal5sar.c linux.dev/drivers/atm/sangam_atm/aal5sar.c
52 --- linux.old/drivers/atm/sangam_atm/aal5sar.c 1970-01-01 01:00:00.000000000 +0100
53 +++ linux.dev/drivers/atm/sangam_atm/aal5sar.c 2005-08-23 04:46:50.080846280 +0200
54 @@ -0,0 +1,2962 @@
55 +
56 +/**
57 + *
58 + * aal5sar.c
59 + *
60 + * TNETDxxxx Software Support\n
61 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
62 + *
63 + * version
64 + * 28Feb02 Greg 1.00 Original Version created.\n
65 + * 06Mar02 Greg 1.01 Documentation (Doxygen-style) enhanced
66 + * 06May02 Greg 1.02 AAL2 added
67 + * 06Jun02 Greg 1.03 Multiple API and bug fixes from emulation
68 + * 12Jul02 Greg 1.04 API Update
69 + */
70 +
71 +/**
72 +@defgroup CPHAL_Functions CPHAL Functions
73 +
74 +These are the CPHAL Functions.
75 +*/
76 +
77 +/**
78 +@page CPHAL_Implementation_Details
79 +
80 +@section cphal_intro Introduction
81 +
82 +The CPHAL API described above is generally applicable to all modules. Any
83 +implementation differences will be described in the following module-specific
84 +appendix sections.
85 +
86 +Included for your reference is a diagram showing the internal architecture
87 +of the CPHAL:
88 +
89 +@image html SangamSoftware.jpg "HAL Architecture"
90 +@image latex SangamSoftware.jpg "HAL Architecture" height=2.8in
91 +
92 +*/
93 +
94 +/**
95 +@defgroup AAL5_Functions Additional Functions for AAL5 Implementation
96 +
97 +These functions are used only by the AAL5 module.
98 +*/
99 +
100 +/*
101 +@defgroup CPMAC_Functions Additional Functions for CPMAC Implementation
102 +
103 +No additional functions currently defined.
104 +*/
105 +
106 +/**
107 +@page VDMA_Implementation_Details
108 +
109 +@section vdma_intro Introduction
110 +
111 +The VDMA-VT module facilitates efficient transfer of data (especially voice)
112 +between two devices, as shown in the figure below.
113 +
114 +@image html vdma.jpg "VDMA System Block Diagram"
115 +@image latex vdma.jpg "VDMA System Block Diagram" height=1in
116 +
117 +The VDMA-VT module supports two modes of operation: mirror mode and credit mode.
118 +Mirror mode is intended for systems in which the remote device does not have a
119 +VDMA-based module. Credit mode is intended for highest performance when VDMA-based
120 +modules exist on both ends of an interface.
121 +
122 +For more detailed information on the operation of the VDMA module, please
123 +reference the VDMA Module Guide.
124 +
125 +@section vdma_channels VDMA Channels
126 +
127 +The VDMA-VT module is a single channel, single transmit queue device. Therefore,
128 +when using the CHANNEL_INFO structure, the correct value for @c Ch is always 0.
129 +Correspondingly, the correct value for the @c Ch parameter in @c ChannelTeardown() is
130 +always 0. Further, when calling @c Send(), the driver should always supply the value
131 +of 0 for both the @c Ch and @c Queue parameters.
132 +
133 +For the VDMA-VT, configuring the channel requires the configuration of either 2 FIFO
134 +elements (in credit mode) or 4 FIFO elements (in mirror mode). For credit mode, the
135 +driver must configure just the local Tx and Rx FIFOs. For mirror mode, the driver must
136 +configure the Tx and Rx FIFOs for both the remote and local ends of the interface.
137 +
138 +This channel configuration is accomplished through multiple calls to @c ChannelSetup().
139 +Each call configures a single FIFO, according to the parameters in the CHANNEL_INFO
140 +structure. The members of VDMA-VT's CHANNEL_INFO structure are defined below.
141 +
142 +
143 +- int RemFifoAddr; Address of remote FIFO (mirror mode only). Set to 0 for credit mode.
144 +- int FifoAddr; Address of the local FIFO. If 0, the CPHAL will allocate the FIFO.
145 +- int FifoSize; Size of the FIFO.
146 +- int PollInt; Polling interval for the FIFO.
147 +- int Endianness; Endianness of the FIFO. If 1, big endian. If 0, little endian.
148 +- int RemAddr; Used only in credit mode. This is the base address of the remote
149 + remote VDMA-based device (VDMA-VT or AAL2)
150 +- int RemDevID; Used only in credit mode. Identifies the type of remote VDMA-based device.
151 + 0=VDMAVT, 1=AAL2 Ch0, 2=AAL2 Ch1, 3=AAL2 Ch2, 4= AAL2 Ch3.
152 +
153 +For the VDMA-VT module, the driver must make all calls to @c ChannelSetup() prior to calling
154 +@c Open(). This is because several of the channel specific parameters may not be changed
155 +while the VDMA-VT module is operational.
156 +
157 +@section vdma_params VDMA Parameters
158 +
159 +Defined here are the set of parameters for the VDMA-VT module. Default settings for
160 +each parameter should be represented in the device configuration file (options.conf).
161 +During @c Init(), the CPHAL will reference the device configuration file and load all
162 +default settings. The @c Control() interface gives the driver an opportunity to
163 +modify any default settings before the module becomes operational during the @c Open()
164 +call.
165 +
166 +@param NoTxIndication If 1, the CPHAL will not call @c SendComplete(). 0 is default.
167 +@param NoRxIndication If 1, the CPHAL will not call @c Receive(). 0 is default.
168 +@param RemoteCPU If 1, the CPHAL will not directly manipulate data in FIFO's, leaving
169 + that task for a remote CPU. 0 is default.
170 +@param RxIntEn If 1, enables Rx interrupts. 0 is default.
171 +@param TxIntEn If 1, enables Tx interrupts. 0 is default.
172 +@param Mirror If 1, enables mirror mode. 0 selects credit mode (default).
173 +@param RxIntCtl Valid only in mirror mode. If 1, interrupts will occur when the Rx FIFO
174 + RdIndex is updated. If 0, interrupts occur when the Rx FIFO WrIndex
175 + is updated.
176 +@param TxIntCtl Valid only in mirror mode. If 1, interrupts will occur when the Rx FIFO
177 + RdIndex is updated. If 0, interrupts occur when the Rx FIFO WrIndex
178 + is updated.
179 +@param RBigEn Remote big endian mode. If 1, remote is big endian.
180 +@param LBigEn Local big endian mode. If 1, local is big endian.
181 +
182 +@section vdma_polling Using VDMA-VT without interrupts
183 +
184 +If your system configuration does not utilize VDMA interrupts, the ability to process the
185 +Tx and Rx FIFOs is supported. To process the Tx FIFO, call @c CheckTx(). If the CPHAL is
186 +able to process any complete data transmissions, it will call @c SendComplete() as usual.
187 +To process the Rx FIFO, call @c CheckRx(). If the CPHAL has received any data, it will
188 +call @c Receive() to pass the driver the data. Please reference @ref VDMA_Functions for more
189 +information on these interfaces.
190 +
191 +@section vdma_details VDMA Implementation Details
192 +
193 +The following functions are not defined for use with VDMA: @c Status(), @c Tick(), @c StatsGet(),
194 +and @c StatsClear().
195 +
196 +*/
197 +
198 +/**
199 +@page AAL5_Implementation_Details
200 +
201 +@section aal5_ver Version
202 +
203 +@copydoc AAL5_Version
204 +
205 +@section aal5_intro Introduction
206 +
207 +The AAL5 implementation will support 16 channels for transmit and 16 channels for
208 +receive. Each of the transmit channels may have up to two transmit queues
209 +associated with it. If two queues are used, Queue 0 is the high priority queue,
210 +and Queue 1 is the low priority queue.
211 +
212 +@section aal5_params AAL5 Configuration Parameters
213 +
214 +AAL5 requires two device entries to be available in the configuration repository, named
215 +@p "aal5" and @p "sar". The @p aal5 device entry must contain @p base (base address)
216 +and @p int_line (interrupt number). The @p sar device entry must have both @p base
217 +(base address) and @p reset_bit (reset bit).
218 +
219 +@par Device Level Configuration Parameters
220 +
221 +The following parameters are device-level parameters, which apply across all
222 +channels. The value for these parameters may be modified by changing the value in the
223 +configuration repository.
224 +
225 +- "UniNni":
226 +AAL5 network setting. 0 = UNI (default), 1 = NNI.
227 +
228 +@par Channel Configuration Parameters
229 +
230 +All AAL5 channel parameters may also be configured through the @c ChannelSetup() interface.
231 +Following is the list of @p CHANNEL_INFO members that may be modified by the driver when
232 +calling @c ChannelSetup(). The driver may provide a value of 0xFFFFFFFF for any channel
233 +parameter to select a default value for the parameter. The driver should at a minimum
234 +configure @p Vci and @p Vpi. The usage of all parameters beginning with TxVc_,
235 +TxVp_, RxVc_, RxVp_ is described in greater detail in the SAR Firmware Spec.
236 +These parameters are mainly associated with QoS and OAM functionality.
237 +
238 +- "RxNumBuffers":
239 +The number of Rx buffer descriptors to allocate for Ch.
240 +- "RxBufSize":
241 +Size (in bytes) for each Rx buffer.
242 +- "RxBufferOffset":
243 +Number of bytes to offset rx data from start of buffer (must be less than buffer size).
244 +- "RxServiceMax":
245 +Maximum number of packets to service at one time.
246 +- "TxNumBuffers":
247 +The number of Tx buffer descriptors to allocate for Ch.
248 +- "TxNumQueues":
249 +Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue.
250 +- "TxServiceMax":
251 +Maximum number of packets to service at one time.
252 +- "CpcsUU":
253 +The 2-byte CPCS UU and CPI information.
254 +- "Gfc":
255 +Generic Flow Control. Used in ATM header of Tx packets.
256 +- "Clp":
257 +Cell Loss Priority. Used in ATM header of Tx packets.
258 +- "Pti":
259 +Payload Type Indication. Used in ATM header of Tx packets.
260 +- "DaMask":
261 +Specifies whether credit issuance is paused when Tx data not available.
262 +- "Priority":
263 +Priority bin this channel will be scheduled within.
264 +- "PktType":
265 +0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2.
266 +- "Vci":
267 +Virtual Channel Identifier.
268 +- "Vpi":
269 +Virtual Path Identifier.
270 +- "TxVc_AtmHeader":
271 +In firmware OAM mode, this
272 +is the ATM header to be appended to front of firmware generated VC OAM cells for
273 +this channel. Note: To generate host OAM cells, call @c Send() with
274 +the appropriate mode.
275 +- "TxVc_CellRate":
276 +Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR).
277 +- "TxVc_QosType":
278 +0=CBR,1=VBR,2=UBR,3=UBRmcr.
279 +- "TxVc_Mbs":
280 +Min Burst Size in cells.
281 +- "TxVc_Pcr":
282 +Peak Cell Rate for VBR in clock ticks between transmissions.
283 +- "TxVc_OamTc":
284 +TC Path to transmit OAM cells for TX connections (0,1).
285 +- "TxVc_VpOffset":
286 +Offset to the OAM VP state table for TX connections. Channels with the same
287 +VPI must have the same VpOffset value. Channels with different VPIs
288 +must have unique VpOffset values.
289 +- "RxVc_OamCh":
290 +Channel to which to terminate received OAM cells to be forwarded to the Host
291 +for either Host OAM mode, or when RxVc_OamToHost is enabled during Firmware
292 +OAM mode.
293 +- "RxVc_OamToHost":
294 +Indicates whether to pass received unmatched OAM loopback cells to the host;
295 +0=do not pass, 1=pass.
296 +- "RxVc_AtmHeader":
297 +ATM Header placed on firmware gen'd OAM cells for this channel on a Rx
298 +connection (must be big endian with 0 PTI).
299 +- "RxVc_OamTc":
300 +TC Path to transmit OAM cells for RX connections (0,1).
301 +- "RxVc_VpOffset":
302 +Offset to the OAM VP state table for RX connections. Channels with the same
303 +VPI must have the same VpOffset value. Channels with different VPIs
304 +must have unique VpOffset values.
305 +- "TxVp_OamTc":
306 +TC Path to transmit OAM cells for TX VP connections (0,1).
307 +- "TxVp_AtmHeader":
308 +ATM Header placed on firmware gen'd VP OAM cells for this channel on a Tx VP
309 +connection (must be big endian with 0 VCI).
310 +- "RxVp_OamCh":
311 +Channel to which to terminate received OAM cells to be forwarded to the Host
312 +for either Host OAM mode, or when RxVc_OamToHost is enabled during Firmware
313 +OAM mode.
314 +- "RxVp_OamToHost":
315 +Indicates whether to pass received unmatched OAM loopback cells to the host;
316 +0=do not pass, 1=pass.
317 +- "RxVp_AtmHeader":
318 +In firmware OAM mode, this
319 +is the ATM header to be appended to front of firmware generated VP OAM cells for
320 +this channel. Note: To generate host OAM cells, call @c Send() with
321 +the appropriate mode.
322 +- "RxVp_OamTc":
323 +TC Path to transmit OAM cells for RX VP connections (0,1).
324 +- "RxVp_OamVcList":
325 +This 32-bit field is one-hot encoded to indicate all the VC channels that are
326 +associated with this VP channel. A value of 21 will indicate that VC
327 +channels 0, 2, and 4 are associated with this VP channel.
328 +- "FwdUnkVc":
329 +Indicates whether or not to forward unknown VCI/VPI cells to the host. This
330 +parameter only takes effect if the channel's PktType is Transparent(3).
331 +1=forwarding enabled, 0=forwarding disabled.
332 +
333 +@section aal5_details API Implementation Details
334 +
335 +ATTENTION: Documentation given here supplements the documentation given in the general
336 +CPHAL API section. The following details are crucial to correct usage of the
337 +AAL5 CPHAL.
338 +
339 +@par Receive()
340 +The least significant byte of @p Mode contains the channel number. Bit 31
341 +indicates whether or not the ATM header is present in the first fragment of
342 +the packet. If bit 31 is set, the 4 byte ATM header (minus HEC) will be provided
343 +in the first fragment, with the payload beginning in the second fragment. Currently,
344 +this is the default behavior for host OAM and transparent mode packets.
345 +Bits 17-16 indicate the packet type that is being received.
346 +Mode Parameter Breakdown: <BR>
347 +- 31 ATM Header In First Fragment (1=true, 0=false) <BR>
348 +- 30-18 Unused. <BR>
349 +- 17-16 Pkt Type. <BR>
350 + - 0=AAL5 <BR>
351 + - 1=PTI Based Null AAL <BR>
352 + - 2=OAM <BR>
353 + - 3=Transparent <BR>
354 +- 15-08 Unused. <BR>
355 +- 07-00 Channel Number.
356 +
357 +@par Send()
358 +The most significant 16 bits of the first fragment 'len' is used as the Offset
359 +to be added to the packet. @c Send() will reserve this many bytes at the
360 +beginning of the transmit buffer prior to the first byte of valid data.
361 +For the @p Mode parameter, Bit 31 must be set if the user has sent a packet with
362 +the ATM Header (minus HEC) embedded in the first 4 bytes of the first fragment data buffer.
363 +The OS has the option of using a 4 byte first fragment containing only ATM header,
364 +or concatenating the ATM Header in front of the data payload.
365 +If Bit 31 is set, the ATM Header in the buffer is preserved and sent with
366 +each cell of the packet. Otherwise, Send() will build the ATM header based on the
367 +values of the Pti, Gfc, Clp, Vpi, and Vci parameters for the given channel.
368 +Bits 17-16 are defined as the packet type. Bits 15-08 may be used to specify the
369 +transmit queue to send the packet on. Only values 0 (high priority) and 1 (low
370 +priority) are accepted. Bits 07-00 should be used to indicate the channel number
371 +for the @c Send() operation. Valid channel numbers are 0-15.
372 +Mode Parameter Breakdown: <BR>
373 +- 31 ATM Header In Packet (1=true, 0=false) <BR>
374 +- 30-18 Unused. <BR>
375 +- 17-16 Pkt Type. <BR>
376 + - 0=AAL5 <BR>
377 + - 1=PTI Based Null AAL <BR>
378 + - 2=OAM <BR>
379 + - 3=Transparent <BR>
380 +- 15-08 Transmit Queue. <BR>
381 +- 07-00 Channel Number.
382 +
383 +@par ChannelSetup()
384 +The AAL5 @c ChannelSetup() always configures both the Tx and Rx side of the channel
385 +connection in the same call.
386 +
387 +@par ChannelTeardown()
388 +Regardless of the channel teardown direction selected, the AAL5 CPHAL will always
389 +teardown both the Tx and Rx side of the channel connection.
390 +
391 +@par TeardownComplete()
392 +The value for the @p Direction parameter should be ignored for the AAL5 implementation,
393 +since both directions (Tx and Rx) are always torndown in response to a @c ChannelTeardown()
394 +command.
395 +
396 +@par Control() (HAL version)
397 +Defined keys and actions. Unless otherwise stated, the data type
398 +for Value is pointer to unsigned integer. The list is broken into
399 +three groups, one group which can be used anytime, one group that should
400 +be used before halOpen(), and one group which can only be used after
401 +halOpen() (but before halClose()). For channelized parameters, replace
402 +'Ch' with the integer number of a channel (ex. "Gfc.4" can be used to set
403 +Gfc for channel 4).
404 +
405 +MAY USE ANYTIME AFTER INIT (after halInit() is called):
406 +
407 +- "Gfc.Ch". The OS may "Set" this value. Changing this value causes
408 +the Gfc in each Tx ATM header for this channel to take on the new Gfc value.
409 +
410 +- "Clp.Ch". The OS may "Set" this value. Changing this value causes
411 +the Clp in each Tx ATM header for this channel to take on the new Clp value.
412 +
413 +- "Pti.Ch". The OS may "Set" this value. Changing this value causes
414 +the Pti in each Tx ATM header for this channel to take on the new Pti value.
415 +
416 +- "CpcsUU.Ch". The OS may "Set" this value. Changing this value causes
417 +the CpcsUU in each Tx ATM header for this channel to take on the new CpcsUU value.
418 +
419 +- "OamMode". Specifies if host or firmware is performing OAM functions; 0 = Host OAM,
420 +1 = Firmware OAM. When set, all SAR channels will be configured for
421 +the selection, including AAL2 channels.
422 +
423 +- "OamLbTimeout". Specifies the firmware OAM loopback timeout, in milliseconds.
424 +
425 +- "DeviceCPID". The OS may "Set" this value. This is the OAM connection
426 +point identifier. The OS should provide a pointer to an array of 4 32-bit
427 +integers. Each word must be configured in big endian format.
428 +
429 +- "FwdUnkVc.Ch". Indicates whether or not to forward unknown VCI/VPI cells to the host.
430 +This parameter only takes effect if the channel's PktType is Transparent(3).
431 +1=forwarding enabled, 0=forwarding disabled.
432 +
433 +MAY USE ONLY BEFORE HAL IS OPEN (before halOpen() call):
434 +- "StrictPriority". The OS may "Set" this value. Setting to 1 causes
435 +a different interrupt processing routine to be used, which gives strict
436 +priority to channels with lower numbers (channel 0 has highest priority).
437 +The default handler gives equal priority to all channels.
438 +
439 +- "MaxFrags". The OS may "Set" or "Get" this value. This defines the maximum
440 +number of fragments that can be received by the AAL5 Rx port. The default
441 +value for AAL5 is 46. This provides enough space to receive a maximum
442 +length AAL5 packet (65,568 bytes) with the default buffer size of 1518 bytes, and
443 +any amount of RxBufferOffset. If the buffer size is configured to be smaller,
444 +the OS *MUST* modify this parameter according to the following formula:
445 +((System Max AAL5 packet length)/(RxBufSize)) + 2. (The extra two fragments in
446 +the formula allow for RxBufferOffset and one fragment for the ATM Header, used
447 +when receiving host OAM or transparent mode packets)
448 +
449 +MAY USE ONLY AFTER HAL IS 'OPEN' (after halOpen() call):
450 +- "Stats;Level;Ch;Queue". The OS may "Get" Stats groups with this key, where
451 +'Level' is an integer from 0-4, Ch is an integer from 0-15, and Queue is
452 +an integer from 0-1. Note that Ch is not required for Level 4 stats, and Queue
453 +is not required for Level 0, 3, and 4. The statistics functionality and return
454 +value is described in the appendix entitled "Configuration and Control".
455 +
456 +- "TxVc_CellRate.Ch". The OS may "Set" this value. Can be used to modify
457 +CellRate for a channel on the fly.
458 +
459 +- "TxVc_Mbs.Ch". The OS may "Set" this value. Can be used to modify
460 +Mbs for a channel on the fly.
461 +
462 +- "TxVc_Pcr.Ch". The OS may "Set" this value. Can be used to modify
463 +Pcr for a channel on the fly.
464 +
465 +- "PdspEnable". The OS may "Set" this value. Value 0 disables the PDSP.
466 +Value 1 enables to PDSP.
467 +
468 +- "DeviceCPID". The OS may "Set" this value. The Value should be an array
469 +of 4 32-bit integers that comprise the CPID.
470 +
471 +- "RxVc_RDICount.Ch". The OS may "Get" or "Set" this value. Get returns
472 +the current RDI count for the VC channel. Set clears the counter, and the Value
473 +is ignored.
474 +
475 +- "RxVp_RDICount.Ch". The OS may "Get" or "Set" this value. Get returns
476 +the current RDI count for the VP channel. Set clears the counter, and the Value
477 +is ignored.
478 +
479 +- "RxVc_AISseg.Ch". The OS may "Get" this value. This is an indication of
480 +AIS segment error for the VC channel.
481 +
482 +- "RxVp_AISseg.Ch". The OS may "Get" this value. This is an indication of
483 +AIS segment error for the VP channel.
484 +
485 +- "RxVc_AISetoe.Ch". The OS may "Get" this value. This is an indication of
486 +AIS end-to-end error for the VC channel.
487 +
488 +- "RxVp_AISetoe.Ch". The OS may "Get" this value. This is an indication of
489 +AIS end-to-end error for the VP channel.
490 +
491 +- "RxVc_OamCh.Ch". The OS may "Set" this value. Channel to which to terminate
492 +received OAM cells to be forwarded to the Host for either Host OAM mode, or when
493 +RxVc_OamToHost is enabled during Firmware OAM mode.
494 +
495 +- "RxVp_OamCh.Ch". The OS may "Set" this value. Channel to which to terminate
496 +received OAM cells to be forwarded to the Host for either Host OAM mode, or when
497 +RxVp_OamToHost is enabled during Firmware OAM mode.
498 +
499 +- "F4_LB_Counter". The OS may "Get" this value. This is a count of the number
500 + of near-end F4 loopbacks performed by the PDSP in firmware OAM mode.
501 +
502 +- "F5_LB_Counter". The OS may "Get" this value. This is a count of the number
503 + of near-end F5 loopbacks performed by the PDSP in firmware OAM mode.
504 +
505 +- "TxVc_AtmHeader.Ch". The OS may "Set" this value. In firmware OAM mode, this
506 +is the ATM header to be appended to front of firmware generated VC OAM cells for
507 +this channel. In host OAM mode, this is used as the ATM header to be appended
508 +to front of host generated VC OAM cells for this channel. It must be configured
509 +as big endian with PTI=0. Note: To generate host OAM cells, call @c Send() with
510 +the appropriate mode.
511 +
512 +- "TxVp_AtmHeader.Ch". The OS may "Set" this value. In firmware OAM mode, this
513 +is the ATM header to be appended to front of firmware generated VP OAM cells for
514 +this channel. In host OAM mode, this is used as the ATM header to be appended
515 +to front of host generated VP OAM cells for this channel. It must be configured
516 +as big endian with VCI=0. Note: To generate host OAM cells, call @c Send() with
517 +the appropriate mode.
518 +
519 +- "PdspEnable". The OS may "Set" this value. Controls whether or not the PDSP is
520 +allowed to fetch new instructions. The PDSP is enabled by the CPHAL during Open(),
521 +and disabled during Close(). 0 = disabled, 1 = enabled.
522 +
523 +@par Control() (OS version)
524 +Defined keys and actions:
525 +
526 +- "Firmware". The CPHAL will perform a "Get" action for the key "Firmware". A pointer
527 +to a pointer is passed in @p Value. The OS must modify the referenced pointer to point
528 +to the firmware.
529 +
530 +- "FirmwareSize". The CPHAL will perform a "Get" action for the key "FirmwareSize".
531 +The OS must place the firmware size in the memory pointed at by @p Value.
532 +
533 +- "OamLbResult". When a channel that is in firmware OAM mode is commanded to perform
534 +a loopback function, the result of the loopback generates an interrupt that is handled
535 +by the OS like any other interrupt. The CPHAL, upon servicing the interrupt, will call
536 +osControl with this key, and an action of "Set". The @p Value parameter will be a
537 +pointer to the integer result. 1 = pass, 0 = fail.
538 +
539 +- "SarFreq". The CPHAL will perform a "Get" action for this key. The OS should place
540 +the SAR frequency (in Hz) in the memory pointed at by @p Value.
541 +
542 +@section aal5_stats AAL5 Specific Statistics
543 +
544 +Statistics level '0' contains all AAL5 specific statistics. The following values will
545 +be obtained when requesting stats level 0:
546 +
547 +- "Crc Errors". Number of CRC errors reported by SAR hardware. Incremented for received
548 +packets that contain CRC errors.
549 +
550 +- "Len Errors". Number of length errors reported by SAR hardware. Incremented for received
551 +packets that are in excess of 1366 cells.
552 +
553 +- "Abort Errors". Number of abort errors reported by SAR hardware.
554 +
555 +- "Starv Errors". Number of buffer starvation errors reported by SAR hardware. Incremented
556 +when a part or all of a buffer cannot be received due to lack of RX buffer resources. The SAR
557 +drops all cells associated with the packet for each buffer starvation error that occurs.
558 +
559 +*/
560 +
561 +/* register files */
562 +#include "cp_sar_reg.h"
563 +
564 +#define _CPHAL_AAL5
565 +#define _CPHAL
566 +#define _CPPI_TEST /** @todo remove for release */
567 +#define __CPHAL_CPPI_OFFSET /* support use of offset */
568 +
569 +/* OS Data Structure definitions */
570 +
571 +typedef void OS_PRIVATE;
572 +typedef void OS_DEVICE;
573 +typedef void OS_SENDINFO;
574 +typedef void OS_RECEIVEINFO;
575 +typedef void OS_SETUP;
576 +
577 +/* CPHAL Data Structure definitions */
578 +
579 +typedef struct hal_device HAL_DEVICE;
580 +typedef struct hal_private HAL_PRIVATE;
581 +typedef struct hal_private HAL_RECEIVEINFO;
582 +
583 +/* include CPHAL header files here */
584 +#include "cpcommon_cpaal5.h"
585 +#include "cpswhal_cpaal5.h"
586 +#include "aal5sar.h"
587 +#include "cpcommon_cpaal5.c"
588 +
589 +#define CR_SERVICE (170-1)
590 +#define UTOPIA_PAUSE_REG (*(volatile bit32u *)0xa4000000)
591 +
592 +/*
593 +these masks are for the mode parameter used in halSend/OsReceive
594 +(may move these elsewhere)
595 +*/
596 +#define CH_MASK 0xff
597 +#define PRI_MASK 0x10000
598 +
599 +/* Rcb/Tcb Constants */
600 +#define CB_SOF_BIT (1<<31)
601 +#define CB_EOF_BIT (1<<30)
602 +#define CB_SOF_AND_EOF_BIT (CB_SOF_BIT|CB_EOF_BIT)
603 +#define CB_OWNERSHIP_BIT (1<<29)
604 +#define CB_EOQ_BIT (1<<28)
605 +#define CB_SIZE_MASK 0x0000ffff
606 +#define CB_OFFSET_MASK 0xffff0000
607 +#define RCB_ERRORS_MASK 0x03fe0000
608 +#define RX_ERROR_MASK 0x000f0000
609 +#define CRC_ERROR_MASK 0x00010000
610 +#define LENGTH_ERROR_MASK 0x00020000
611 +#define ABORT_ERROR_MASK 0x00040000
612 +#define STARV_ERROR_MASK 0x00080000
613 +#define TEARDOWN_VAL 0xfffffffc
614 +
615 +/* interrupt vector masks */
616 +#define TXH_PEND 0x01000000
617 +#define TXL_PEND 0x02000000
618 +#define RX_PEND 0x04000000
619 +#define STS_PEND 0x08000000
620 +#define AAL2_PEND 0x10000000
621 +#define INT_PENDING (TXH_PEND | TXL_PEND | RX_PEND | STS_PEND | AAL2_PEND)
622 +#define STS_PEND_INVEC 0x0001F000
623 +#define RX_PEND_INVEC 0x00000F00
624 +#define TXL_PEND_INVEC 0x000000F0
625 +#define TXH_PEND_INVEC 0x0000000F
626 +#define AIS_SEG_MASK 0x1 /* +01.02.00 */
627 +#define AIS_SEG_SHIFT 0 /* +01.02.00 */
628 +#define AIS_ETOE_MASK 0x20000 /* +01.02.00 */
629 +#define AIS_ETOE_SHIFT 17 /* +01.02.00 */
630 +#define RDI_CNT_MASK 0xffff0000 /* +01.02.00 */
631 +#define RDI_CNT_SHIFT 16 /* +01.02.00 */
632 +
633 +/*
634 + * This function takes a vpi/vci pair and computes the 4 byte atm header
635 + * (minus the HEC).
636 + *
637 + * @param vpi Virtual Path Identifier.
638 + * @param vci Virtual Channel Identifier.
639 + *
640 + * @return A properly formatted ATM header, without the HEC.
641 + */
642 +static int atmheader(int gfc, int vpi, int vci, int pti, int clp)
643 + {
644 + int itmp;
645 +
646 + itmp=0;
647 +
648 + /* UNI Mode uses the GFC field */
649 + itmp |= ((gfc & 0xF) << 28);
650 + itmp |= ((vpi & 0xFF) << 20);
651 +
652 + /* if NNI Mode, no gfc and larger VPI */
653 + /*itmp |= ((vpi & 0xFFF) << 20);*/
654 +
655 + itmp|=((vci & 0xFFFF) << 4);
656 + itmp|=((pti & 0x7) << 1);
657 + itmp|=(clp & 0x1);
658 + return(itmp);
659 + }
660 +
661 +#include "cppi_cpaal5.c"
662 +
663 +/*
664 + * Re-entrancy Issues
665 + * In order to ensure successful re-entrancy certain sections of the
666 + * CPHAL code will be bracketed as Critical.
667 + * The OS will provide the function Os.CriticalSection(BOOL), which
668 + * will be passed a TRUE to enter the Critical Section and FALSE to exit.
669 + */
670 +
671 +/*
672 + * @ingroup CPHAL_Functions
673 + * Clears the statistics information.
674 + *
675 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
676 + *
677 + * @return 0 OK, Non-zero not OK
678 + */
679 +static int StatsClear(HAL_DEVICE *HalDev)
680 + {
681 + int i;
682 +
683 +#ifdef __CPHAL_DEBUG
684 + if (DBG(0))
685 + {
686 + dbgPrintf("[aal5]StatsClear(HalDev:%08x)\n", (bit32u)HalDev);
687 + osfuncSioFlush();
688 + }
689 +#endif
690 +
691 + /* clear stats */
692 + for (i=0; i<NUM_AAL5_CHAN; i++)
693 + {
694 + HalDev->Stats.CrcErrors[i]=0;
695 + HalDev->Stats.LenErrors[i]=0;
696 + HalDev->Stats.DmaLenErrors[i]=0;
697 + HalDev->Stats.AbortErrors[i]=0;
698 + HalDev->Stats.StarvErrors[i]=0;
699 + HalDev->Stats.TxMisQCnt[i][0]=0;
700 + HalDev->Stats.TxMisQCnt[i][1]=0;
701 + HalDev->Stats.RxMisQCnt[i]=0;
702 + HalDev->Stats.RxEOQCnt[i]=0;
703 + HalDev->Stats.TxEOQCnt[i][0]=0;
704 + HalDev->Stats.TxEOQCnt[i][1]=0;
705 + HalDev->Stats.RxPacketsServiced[i]=0;
706 + HalDev->Stats.TxPacketsServiced[i][0]=0;
707 + HalDev->Stats.TxPacketsServiced[i][1]=0;
708 + HalDev->Stats.TxMaxServiced[i][0]=0;
709 + HalDev->Stats.TxMaxServiced[i][1]=0;
710 + }
711 + HalDev->Stats.RxTotal=0;
712 + HalDev->Stats.TxTotal=0;
713 + HalDev->Stats.RxMaxServiced=0;
714 + return (EC_NO_ERRORS);
715 + }
716 +
717 +/*
718 + * Returns statistics information.
719 + *
720 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
721 + *
722 + * @return 0
723 + */
724 +/*
725 +static STAT_INFO* StatsGet(HAL_DEVICE *HalDev)
726 + {
727 + STAT_INFO* MyStats = &HalDev->Stats;
728 +#ifdef __CPHAL_DEBUG
729 + if (DBG(0))
730 + {
731 + dbgPrintf("[aal5]StatsGet(HalDev:%08x)\n", (bit32u)HalDev);
732 + osfuncSioFlush();
733 + }
734 +#endif
735 +
736 + dbgPrintf("HAL Stats:\n");
737 + DispStat(HalDev, "Rx Total",MyStats->RxTotal);
738 + DispStat(HalDev, "Tx Total",MyStats->TxTotal);
739 + DispStat(HalDev, "Rx Peak",MyStats->RxMaxServiced);
740 + DispStat(HalDev, "TxH Peak",MyStats->TxMaxServiced[0][0]);
741 + DispStat(HalDev, "TxL Peak",MyStats->TxMaxServiced[0][1]);
742 + DispChStat(HalDev, "CrcErr",&MyStats->CrcErrors[0],1);
743 + DispChStat(HalDev, "LenErr",&MyStats->LenErrors[0],1);
744 + DispChStat(HalDev, "DmaLenErr",&MyStats->DmaLenErrors[0],1);
745 + DispChStat(HalDev, "AbortErr",&MyStats->AbortErrors[0],1);
746 + DispChStat(HalDev, "StarvErr",&MyStats->StarvErrors[0],1);
747 + DispChStat(HalDev, "TxH MisQ Cnt",&MyStats->TxMisQCnt[0][0],2);
748 + DispChStat(HalDev, "TxL MisQ Cnt",&MyStats->TxMisQCnt[0][1],2);
749 + DispChStat(HalDev, "Rx MisQ Cnt",&MyStats->RxMisQCnt[0],1);
750 + DispChStat(HalDev, "Rx EOQ Cnt",&MyStats->RxEOQCnt[0],1);
751 + DispChStat(HalDev, "TxH EOQ Cnt",&MyStats->TxEOQCnt[0][0],2);
752 + DispChStat(HalDev, "TxL EOQ Cnt",&MyStats->TxEOQCnt[0][1],2);
753 + DispChStat(HalDev, "Rx Pkts",&MyStats->RxPacketsServiced[0],1);
754 + DispChStat(HalDev, "TxH Pkts",&MyStats->TxPacketsServiced[0][0],2);
755 + DispChStat(HalDev, "TxL Pkts",&MyStats->TxPacketsServiced[0][1],2);
756 +
757 + return (&HalDev->Stats);
758 + }
759 +*/
760 +
761 +#ifdef __CPHAL_DEBUG
762 +void dbgChannelConfigDump(HAL_DEVICE *HalDev, int Ch)
763 + {
764 + CHANNEL_INFO *HalCh = &HalDev->ChData[Ch];
765 + dbgPrintf(" [aal5 Inst %d, Ch %d] Config Dump:\n", HalDev->Inst, Ch);
766 + dbgPrintf(" TxNumBuffers :%08d, TxNumQueues :%08d\n",
767 + HalCh->TxNumBuffers, HalCh->TxNumQueues);
768 + dbgPrintf(" RxNumBuffers :%08d, RxBufSize :%08d\n",
769 + HalCh->RxNumBuffers, HalCh->RxBufSize);
770 + dbgPrintf(" TxServiceMax :%08d, RxServiceMax:%08d\n",
771 + HalCh->TxServiceMax, HalCh->RxServiceMax);
772 + dbgPrintf(" RxBufferOffset:%08d, DaMask :%08d\n",
773 + HalCh->RxBufferOffset, HalCh->DaMask);
774 + dbgPrintf(" CpcsUU :%08d, Gfc :%08d\n",
775 + HalCh->CpcsUU, HalCh->Gfc);
776 + dbgPrintf(" Clp :%08d, Pti :%08d\n",
777 + HalCh->Clp, HalCh->Pti);
778 + dbgPrintf(" Priority :%08d, PktType :%08d\n",
779 + HalCh->Priority, HalCh->PktType);
780 + dbgPrintf(" Vci :%08d, Vpi :%08d\n",
781 + HalCh->Vci, HalCh->Vpi);
782 + dbgPrintf(" TxVc_CellRate :%08d, TxVc_QosType:%08d\n",
783 + HalCh->TxVc_CellRate, HalCh->TxVc_QosType);
784 + dbgPrintf(" TxVc_Mbs :%08d, TxVc_Pcr :%08d\n",
785 + HalCh->TxVc_Mbs, HalCh->TxVc_Pcr);
786 + dbgPrintf(" TxVc_AtmHeader:%08d\n",
787 + HalCh->TxVc_AtmHeader);
788 + osfuncSioFlush();
789 + }
790 +#endif
791 +
792 +/*
793 + * Retrieves channel parameters from configuration file. Any parameters
794 + * which are not found are ignored, and the HAL default value will apply,
795 + * unless a new value is given through the channel structure in the call
796 + * to ChannelSetup.
797 + */
798 +static int ChannelConfigGet(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
799 + {
800 + unsigned int Ret, Value, Ch = HalChn->Channel;
801 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
802 + void *ChInfo;
803 +
804 +#ifdef __CPHAL_DEBUG
805 + if (DBG(0))
806 + {
807 + dbgPrintf("[aal5]ChannelConfigGet(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
808 + (bit32u)HalChn);
809 + osfuncSioFlush();
810 + }
811 +#endif
812 +
813 + Ret=OsFunc->DeviceFindParmValue(HalDev->DeviceInfo, channel_names[Ch], &ChInfo);
814 + if (Ret) return (EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_INFO_NOT_FOUND);
815 +
816 + /* i don't care if a value is not found because they are optional */
817 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxNumBuffers", &Value);
818 + if (!Ret) HalDev->ChData[Ch].TxNumBuffers = Value;
819 +
820 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxNumQueues", &Value);
821 + if (!Ret) HalDev->ChData[Ch].TxNumQueues = Value;
822 +
823 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxServiceMax", &Value);
824 + if (!Ret) HalDev->ChData[Ch].TxServiceMax = Value;
825 +
826 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxNumBuffers", &Value);
827 + if (!Ret) HalDev->ChData[Ch].RxNumBuffers = Value;
828 +
829 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxBufferOffset", &Value);
830 + if (!Ret) HalDev->ChData[Ch].RxBufferOffset = Value;
831 +
832 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxBufSize", &Value);
833 + if (!Ret) HalDev->ChData[Ch].RxBufSize = Value;
834 +
835 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "RxServiceMax", &Value);
836 + if (!Ret) HalDev->ChData[Ch].RxServiceMax = Value;
837 +
838 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "CpcsUU", &Value);
839 + if (!Ret) HalDev->ChData[Ch].CpcsUU = Value;
840 +
841 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Gfc", &Value);
842 + if (!Ret) HalDev->ChData[Ch].Gfc = Value;
843 +
844 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Clp", &Value);
845 + if (!Ret) HalDev->ChData[Ch].Clp = Value;
846 +
847 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Pti", &Value);
848 + if (!Ret) HalDev->ChData[Ch].Pti = Value;
849 +
850 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "DaMask", &Value);
851 + if (!Ret) HalDev->ChData[Ch].DaMask = Value;
852 +
853 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Priority", &Value);
854 + if (!Ret) HalDev->ChData[Ch].Priority = Value;
855 +
856 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "PktType", &Value);
857 + if (!Ret) HalDev->ChData[Ch].PktType = Value;
858 +
859 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Vci", &Value);
860 + if (!Ret) HalDev->ChData[Ch].Vci = Value;
861 +
862 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "Vpi", &Value);
863 + if (!Ret) HalDev->ChData[Ch].Vpi = Value;
864 +
865 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_CellRate", &Value);
866 + if (!Ret) HalDev->ChData[Ch].TxVc_CellRate = Value;
867 +
868 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_QosType", &Value);
869 + if (!Ret) HalDev->ChData[Ch].TxVc_QosType = Value;
870 +
871 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_Mbs", &Value);
872 + if (!Ret) HalDev->ChData[Ch].TxVc_Mbs = Value;
873 +
874 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_Pcr", &Value);
875 + if (!Ret) HalDev->ChData[Ch].TxVc_Pcr = Value;
876 +
877 + Ret=OsFunc->DeviceFindParmUint(ChInfo, "TxVc_AtmHeader", &Value);
878 + if (!Ret) HalDev->ChData[Ch].TxVc_AtmHeader = Value;
879 +
880 + return (EC_NO_ERRORS);
881 + }
882 +
883 +/*
884 + * Sets up channel parameters in the hardware, and initializes the CPPI
885 + * TX and RX buffer descriptors and buffers.
886 + */
887 +static int ChannelConfigApply(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
888 + {
889 + int j, Ch = HalChn->Channel;
890 + volatile bit32u *pTmp;
891 + int Ret; /* +GSG 030410 */
892 +
893 +#ifdef __CPHAL_DEBUG
894 + if (DBG(0))
895 + {
896 + dbgPrintf("[aal5]ChannelConfigApply(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
897 + (bit32u)HalChn);
898 + osfuncSioFlush();
899 + }
900 +#endif
901 +
902 + if ((HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE) || (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE))
903 + {
904 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
905 + }
906 +
907 + HalDev->InRxInt[Ch]=FALSE;
908 +
909 + /* Initialize Queue Data */
910 + HalDev->RxActQueueHead[Ch]=0;
911 + HalDev->RxActQueueCount[Ch]=0;
912 + HalDev->TxActQueueHead[Ch][0]=0;
913 + HalDev->TxActQueueHead[Ch][1]=0;
914 + HalDev->TxActQueueCount[Ch][0]=0;
915 + HalDev->TxActQueueCount[Ch][1]=0;
916 + HalDev->RxActive[Ch] = FALSE;
917 + HalDev->TxActive[Ch][0] = FALSE;
918 + HalDev->TxActive[Ch][1] = FALSE;
919 +
920 + /* Clear Rx State RAM */
921 + pTmp = pRX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64);
922 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
923 + *pTmp++ = 0;
924 +
925 + /* Check that Rx DMA State RAM was cleared */
926 + pTmp -= NUM_RX_STATE_WORDS;
927 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
928 + {
929 + if (*pTmp++ != 0)
930 + {
931 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_RX_STATE_RAM_NOT_CLEARED);
932 + }
933 + }
934 +
935 + /* Clear Tx State RAM */
936 + pTmp = pTX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64);
937 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
938 + *pTmp++ = 0;
939 +
940 + /* Check that Tx DMA State RAM was cleared */
941 + pTmp -= NUM_TX_STATE_WORDS;
942 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
943 + {
944 + if (*pTmp++ != 0)
945 + {
946 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_TX_STATE_RAM_NOT_CLEARED);
947 + }
948 + }
949 +
950 + /* Initialize Tx State RAM (Nothing to do) */
951 +
952 + /* Initialize Rx State RAM */
953 + /* Configure the Rx buffer offset */
954 + pTmp=(pRX_DMA_STATE_WORD_0(HalDev->dev_base) + (Ch*64));
955 + *pTmp |= (HalDev->ChData[Ch].RxBufferOffset & 0xFF);
956 +
957 + /* Initialize buffer memory for the channel */
958 + Ret = InitTcb(HalDev, Ch);
959 + if (Ret) return (Ret);
960 +
961 + Ret = InitRcb(HalDev, Ch);
962 + if (Ret) return (Ret);
963 +
964 + /* setup interrupt mask/enable for the channel */
965 + SAR_TX_MASK_SET(HalDev->dev_base) = (1<<Ch);
966 +
967 + /* if using the low priority queue, set up mask for it */
968 + if (HalDev->ChData[Ch].TxNumQueues == 2) /* +GSG 030421 */
969 + SAR_TX_MASK_SET(HalDev->dev_base) = (1<<Ch)<<16; /* +GSG 030421 */
970 +
971 + SAR_RX_MASK_SET(HalDev->dev_base) = (1<<Ch);
972 +
973 + /* call SAR layer to complete the channel setup - hardware configuration of ch */
974 + Ret = HalDev->SarFunc->ChannelSetup(HalDev->SarDev, &HalDev->ChData[Ch]); /* ~GSG 030410 */
975 + if (Ret) /* +GSG 030410 */
976 + return (Ret); /* +GSG 030410 */
977 +
978 + /* channel officially open for business */
979 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = TRUE;
980 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = TRUE;
981 +
982 + return (EC_NO_ERRORS);
983 + }
984 +
985 +/*
986 + * Sets up HAL default channel configuration parameter values.
987 + */
988 +static void ChannelConfigInit(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
989 + {
990 + int Ch = HalChn->Channel;
991 +
992 +#ifdef __CPHAL_DEBUG
993 + if (DBG(0))
994 + {
995 + dbgPrintf("[aal5]ChannelConfigInit(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
996 + (bit32u)HalChn);
997 + osfuncSioFlush();
998 + }
999 +#endif
1000 +
1001 + HalDev->ChData[Ch].Channel = Ch;
1002 + HalDev->ChData[Ch].TxNumBuffers = cfg_tx_num_bufs[Ch];
1003 + HalDev->ChData[Ch].RxNumBuffers = cfg_rx_num_bufs[Ch];
1004 + HalDev->ChData[Ch].RxBufSize = cfg_rx_buf_size[Ch];
1005 + HalDev->ChData[Ch].RxBufferOffset = cfg_rx_buf_offset[Ch];
1006 + HalDev->ChData[Ch].TxNumQueues = cfg_tx_num_queues[Ch];
1007 + HalDev->ChData[Ch].CpcsUU = cfg_cpcs_uu[Ch];
1008 + HalDev->ChData[Ch].DaMask = cfg_da_mask[Ch];
1009 + HalDev->ChData[Ch].Priority = cfg_priority[Ch];
1010 + HalDev->ChData[Ch].PktType = cfg_pkt_type[Ch];
1011 + HalDev->ChData[Ch].Vci = cfg_vci[Ch];
1012 + HalDev->ChData[Ch].Vpi = cfg_vpi[Ch];
1013 + HalDev->ChData[Ch].TxVc_CellRate = cfg_cell_rate[Ch];
1014 + HalDev->ChData[Ch].TxVc_QosType = cfg_qos_type[Ch];
1015 + HalDev->ChData[Ch].TxVc_Mbs = cfg_mbs[Ch];
1016 + HalDev->ChData[Ch].TxVc_Pcr = cfg_pcr[Ch];
1017 + HalDev->ChData[Ch].Gfc = cfg_gfc[Ch];
1018 + HalDev->ChData[Ch].Clp = cfg_clp[Ch];
1019 + HalDev->ChData[Ch].Pti = cfg_pti[Ch];
1020 + HalDev->ChData[Ch].RxServiceMax = cfg_rx_max_service[Ch];
1021 + HalDev->ChData[Ch].TxServiceMax = cfg_tx_max_service[Ch];
1022 + }
1023 +
1024 +/*
1025 + * Update per channel data in the HalDev based channel structure.
1026 + * If a certain channel parameter has been passed with the HAL_DEFAULT
1027 + * value (0xFFFFFFFF), then do not copy it.
1028 + */
1029 +static void ChannelConfigUpdate(HAL_DEVICE *HalDev, CHANNEL_INFO *HalChn)
1030 + {
1031 + int Ch = HalChn->Channel;
1032 +
1033 +#ifdef __CPHAL_DEBUG
1034 + if (DBG(0))
1035 + {
1036 + dbgPrintf("[aal5]ChannelConfigUpdate(HalDev:%08x, HalChn:%08x)\n", (bit32u)HalDev,
1037 + (bit32u)HalChn);
1038 + osfuncSioFlush();
1039 + }
1040 +#endif
1041 +
1042 + HalDev->ChData[Ch].Channel = Ch;
1043 +
1044 + /* ChannelUpdate is a macro defined in cpcommon.h. It requires
1045 + the presence of the variables named 'Ch' and 'HalChn'.*/
1046 + ChannelUpdate(DaMask);
1047 + ChannelUpdate(Priority);
1048 + ChannelUpdate(PktType);
1049 + ChannelUpdate(Vci);
1050 + ChannelUpdate(Vpi);
1051 + ChannelUpdate(CpcsUU);
1052 + ChannelUpdate(Gfc);
1053 + ChannelUpdate(Clp);
1054 + ChannelUpdate(Pti);
1055 + /* AAL5 Stuff */
1056 + ChannelUpdate(TxNumBuffers);
1057 + ChannelUpdate(RxNumBuffers);
1058 + ChannelUpdate(RxBufSize);
1059 + ChannelUpdate(RxBufferOffset);
1060 + ChannelUpdate(TxNumQueues);
1061 + ChannelUpdate(TxServiceMax);
1062 + ChannelUpdate(RxServiceMax);
1063 + /* PDSP STATE RAM */
1064 + ChannelUpdate(TxVc_CellRate);
1065 + ChannelUpdate(TxVc_QosType);
1066 + ChannelUpdate(TxVc_Mbs);
1067 + ChannelUpdate(TxVc_Pcr);
1068 + /* OAM */
1069 + ChannelUpdate(TxVc_AtmHeader);
1070 + ChannelUpdate(TxVc_OamTc);
1071 + ChannelUpdate(TxVc_VpOffset);
1072 + ChannelUpdate(RxVc_OamCh);
1073 + ChannelUpdate(RxVc_OamToHost);
1074 + ChannelUpdate(RxVc_AtmHeader);
1075 + ChannelUpdate(RxVc_VpOffset);
1076 + ChannelUpdate(RxVc_OamTc);
1077 + ChannelUpdate(TxVp_AtmHeader);
1078 + ChannelUpdate(TxVp_OamTc);
1079 + ChannelUpdate(RxVp_AtmHeader);
1080 + ChannelUpdate(RxVp_OamCh);
1081 + ChannelUpdate(RxVp_OamTc);
1082 + ChannelUpdate(RxVp_OamToHost);
1083 + ChannelUpdate(RxVp_OamVcList);
1084 + ChannelUpdate(FwdUnkVc);
1085 + }
1086 +
1087 +/**
1088 + * @ingroup CPHAL_Functions
1089 + * This function opens the specified channel. The caller must populate
1090 + * the @p HalCh structure. CPHAL default values may be requested for any or all
1091 + * members of the @p HalCh structure by supplying a value of 0xFFFFFFFF for the
1092 + * given member. The @p OsSetup parameter is a pointer to an OS defined
1093 + * data structure. If the CPHAL later calls @c MallocRxBuffer(), this pointer
1094 + * is returned in that call.
1095 + *
1096 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1097 + * @param HalCh Per channel information structure. Implementation specific.
1098 + * @param OsSetup Pointer to an OS-defined data structure.
1099 + *
1100 + * @return EC_NO_ERRORS (ok). <BR>
1101 + * Possible Error Codes:<BR>
1102 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
1103 + * @ref EC_VAL_NULL_CH_STRUCT "EC_VAL_NULL_CH_STRUCT"<BR>
1104 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
1105 + * @ref EC_VAL_CH_ALREADY_OPEN "EC_VAL_CH_ALREADY_OPEN"<BR>
1106 + * @ref EC_VAL_RX_STATE_RAM_NOT_CLEARED "EC_VAL_RX_STATE_RAM_NOT_CLEARED"<BR>
1107 + * @ref EC_VAL_TX_STATE_RAM_NOT_CLEARED "EC_VAL_TX_STATE_RAM_NOT_CLEARED"<BR>
1108 + * @ref EC_VAL_TCB_MALLOC_FAILED "EC_VAL_TCB_MALLOC_FAILED"<BR>
1109 + * @ref EC_VAL_RCB_MALLOC_FAILED "EC_VAL_RCB_MALLOC_FAILED"<BR>
1110 + * @ref EC_VAL_RX_BUFFER_MALLOC_FAILED "EC_VAL_RX_BUFFER_MALLOC_FAILED"<BR>
1111 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
1112 + */
1113 +static int halChannelSetup(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup)
1114 + {
1115 + int Ch, Ret;
1116 +
1117 +#ifdef __CPHAL_DEBUG
1118 + if (DBG(0))
1119 + {
1120 + dbgPrintf("[aal5]halChannelSetup(HalDev:%08x, HalCh:%08x, OsSetup:%08x)\n", (bit32u)HalDev,
1121 + (bit32u)HalCh, (bit32u)OsSetup);
1122 + osfuncSioFlush();
1123 + }
1124 +#endif
1125 +
1126 + /* Verify proper device state */
1127 + if (HalDev->State < enInitialized)
1128 + return (EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_INVALID_STATE);
1129 +
1130 + /* We require the channel structure to be passed, even if it only contains
1131 + the channel number */
1132 + if (HalCh == NULL)
1133 + {
1134 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_NULL_CH_STRUCT);
1135 + }
1136 +
1137 + Ch = HalCh->Channel;
1138 +
1139 + if ((Ch < 0) || (Ch > MAX_AAL5_CHAN))
1140 + {
1141 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_INVALID_CH);
1142 + }
1143 +
1144 + /* if channel is already open, this call is invalid */
1145 + if ((HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE) || (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE))
1146 + {
1147 + return(EC_AAL5|EC_FUNC_CHSETUP|EC_VAL_CH_ALREADY_OPEN);
1148 + }
1149 +
1150 + /* channel is closed, but might be setup. If so, reopen the hardware channel. */
1151 + if ((HalDev->ChIsSetup[Ch][DIRECTION_TX] == FALSE) && (HalDev->ChIsSetup[Ch][DIRECTION_RX] == FALSE))
1152 + {
1153 + /* Setup channel configuration */
1154 + /* Store OS_SETUP */
1155 + HalDev->ChData[Ch].OsSetup = OsSetup; /* ~GSG 030508 */
1156 +
1157 + /* setup HAL default values for this channel first */
1158 + ChannelConfigInit(HalDev, HalCh);
1159 +
1160 + /* retrieve options.conf channel parameters */
1161 + /* currently ignoring return value, making the choice that it's okay if
1162 + the user does not supply channel configuration in the data store */
1163 + ChannelConfigGet(HalDev, HalCh);
1164 +
1165 + /* update HalDev with data given in HalCh */
1166 + ChannelConfigUpdate(HalDev, HalCh);
1167 +
1168 +#ifdef __CPHAL_DEBUG
1169 + if (DBG(8))
1170 + {
1171 + dbgChannelConfigDump(HalDev, Ch);
1172 + }
1173 +#endif
1174 +
1175 + /* HalDev->ChIsSetup[Ch][0] = TRUE; */
1176 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = TRUE;
1177 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = TRUE;
1178 +
1179 + /* I don't initialize RcbStart or TcbStart here because their values may be
1180 + reused across several Setup/Teardown calls */
1181 + }
1182 +
1183 + /* If the hardware has been opened (is out of reset), then configure the channel
1184 + in the hardware. NOTE: ChannelConfigApply calls the CPSAR ChannelSetup()! */
1185 + if (HalDev->State == enOpened)
1186 + {
1187 + Ret = ChannelConfigApply(HalDev, HalCh);
1188 + if (Ret) return (Ret);
1189 + }
1190 +
1191 + return (EC_NO_ERRORS);
1192 + }
1193 +
1194 +/*
1195 + * This function configures the rate at which the OAM timer scheduler
1196 + * channels will be scheduled. The value of OamRate is the number of
1197 + * clock ticks between cell transmissions (if OAM function is sourcing
1198 + * cells), or the number of clock ticks between events or absence of events
1199 + * (if OAM function is sinking cells). The value of i indicates
1200 + * which OAM function to apply the rate to. A list is given below.
1201 + *
1202 + * @par Oam Function Values
1203 + * - 0 : Loopback source
1204 + * - 1 : F4 CC source
1205 + * - 2 : F5 CC source
1206 + * - 3 : F4 CC sink
1207 + * - 4 : F5 CC sink
1208 + * - 5 : F4 TX AIS source
1209 + * - 6 : F5 TX AIS source
1210 + * - 7 : F4 RX RDI source
1211 + * - 8 : F5 RX RDI source
1212 + * - 9 : F4 AIS monitor
1213 + * - 10 : F5 AIS monitor
1214 + *
1215 + * The following is information on how to calculate the OAM rate. There
1216 + * is only one OAM timer that is shared among all channels. Therefore, if
1217 + * you wanted an OAM source function (ex. F4 CC source) to generate 1 cell/sec
1218 + * across 8 channels, you would need to configure the OAM timer to schedule 8
1219 + * cells/sec. In addition, the credits are shared between segment and end-to-end
1220 + * type OAM cells, so if you were sending both types of cells, you would
1221 + * need to configure the OAM timer for 16 cells/sec. However, the clock
1222 + * rate must be specified in clock ticks between events. Using an example
1223 + * clock rate of 125 MHz, the rate in clock ticks can be calculated by
1224 + * dividing 125 Mhz by 16 cells/sec. The results is 7812500 ticks. Thus,
1225 + * every 7812500 clock cycles, an OAM cell will be generated for the F4 CC
1226 + * Source function.
1227 + */
1228 +static void OamRateConfig(HAL_DEVICE *HalDev)
1229 + {
1230 + int i;
1231 + bit32u OamRate, Freq = HalDev->SarFrequency;
1232 +
1233 + /* Configure OAM Timer State Block */
1234 + for (i=0; i<NUM_OAM_RATES; i++)
1235 + {
1236 + switch(i)
1237 + {
1238 + case 0: OamRate = ((Freq/1000)*HalDev->OamLbTimeout);
1239 + break;
1240 + case 1:
1241 + case 2:
1242 + case 5:
1243 + case 6:
1244 + case 7:
1245 + case 8: OamRate = (Freq/38);
1246 + break;
1247 + case 3:
1248 + case 4: OamRate = ((Freq*3) + (Freq/2))/38;
1249 + break;
1250 + case 9:
1251 + case 10: OamRate = ((Freq*2) + (Freq/2))/38;
1252 + break;
1253 + default: OamRate = (Freq*5);
1254 + break;
1255 + }
1256 +
1257 + *(pOAM_TIMER_STATE_WORD_0(HalDev->dev_base) + (i*64) + 1) = OamRate;
1258 + }
1259 + }
1260 +
1261 +/**
1262 + * @ingroup AAL5_Functions
1263 + * This function is used to enable OAM functions (other than loopback) for a
1264 + * particular channel. The channel (embedded within OamConfig - see below) must
1265 + * have been configured for firmware OAM (not host OAM) for these configurations
1266 + * to take effect. More than one function may be enabled at one time.
1267 + * If more than one function is enabled, they must all be of the same level, all
1268 + * F4(VP) or all F5(VC).
1269 + *
1270 + * The usage of the OamConfig parameter is described through the table below. To
1271 + * initiate firmware OAM, set one or more bits in OamConfig corresponding to the
1272 + * various OAM functions. To disable firmware OAM functions, set bit 30 along
1273 + * with any other combination of bits to shutdown various OAM functions at once.
1274 + *
1275 + * Acronyms:
1276 + * e2e - end to end, seg - segment, CC - continuity check,
1277 + * AIS - Alarm Indication Signal
1278 + *
1279 + * @par Bit: Function: Description
1280 + * - 31: Reserved:
1281 + * - 30: Setup/Teardown: 0 - enable, 1 - disable (Note 1)
1282 + * - 29: F4 CC Source seg: 0 - no action, 1 - configure
1283 + * - 28: F4 CC Source e2e: 0 - no action, 1 - configure
1284 + * - 27: F4 AIS Source seg: 0 - no action, 1 - configure
1285 + * - 26: F4 AIS Source e2e: 0 - no action, 1 - configure
1286 + * - 25: F5 CC Source seg: 0 - no action, 1 - configure
1287 + * - 24: F5 CC Source e2e: 0 - no action, 1 - configure
1288 + * - 23: F5 AIS Source seg: 0 - no action, 1 - configure
1289 + * - 22: F5 AIS Source e2e: 0 - no action, 1 - configure
1290 + * - 21: F4 CC Sink seg: 0 - no action, 1 - configure
1291 + * - 20: F4 CC Sink e2e: 0 - no action, 1 - configure
1292 + * - 19: F5 CC Sink seg: 0 - no action, 1 - configure
1293 + * - 18: F5 CC Sink e2e: 0 - no action, 1 - configure
1294 + * - 17:8: Reserved:
1295 + * - 7:0: Channel: AAL5/AAL2 VC/VP channel (Note 2)
1296 + *
1297 + *
1298 + * Note 1: This bit must be clear to enable the specified OAM function.
1299 + * Note 2: This must specify the VC channel for F5 functions, and the VP
1300 + * channel for F4 functions.
1301 + *
1302 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1303 + * @param OamConfig A 32-bit integer field defined as follows:
1304 + */
1305 +static void halOamFuncConfig(HAL_DEVICE *HalDev, unsigned int OamConfig)
1306 + {
1307 + /* GPR 0 */
1308 + SAR_PDSP_HOST_OAM_CONFIG_REG(HalDev->dev_base) = OamConfig;
1309 + }
1310 +
1311 +/**
1312 + * @ingroup AAL5_Functions
1313 + * This function is used to enable OAM loopback functions for a particular
1314 + * channel. The channel (embedded within OamConfig - see below) must have been
1315 + * configured for firmware OAM (not host OAM) for these configurations to take
1316 + * effect. Only one loopback function can be enabled at a time.
1317 + *
1318 + * The LLID is inserted into to the OAM cell's LLID field, and it specifies the
1319 + * LLID of the connection point in the network where the generated loopback cell
1320 + * should be turned around. The LLID is composed of 4 32-bit words, and this
1321 + * function expects the caller to pass an array of 4 words in the LLID field.
1322 + * The CorrelationTag is a 32-bit word that the PDSP uses to correlate loopback
1323 + * commands with loopback responses. It should simply be changed for each
1324 + * call, and there is no restriction on the value used for CorrelationTag.
1325 + *
1326 + * The usage of the OamConfig parameter is described through the table below. To
1327 + * initiate firmware OAM, set one of the bits corresponding to the
1328 + * various loopback OAM functions. Note that only one loopback source may be
1329 + * commanded at a time.
1330 + *
1331 + * Acronyms:
1332 + * e2e - end to end, seg - segment, LB - loopback
1333 + *
1334 + * @par Bit: Function: Description
1335 + * - 31:16: Reserved:
1336 + * - 15: F4 LB Source seg: 0 - no action, 1 - configure (Note 1)
1337 + * - 14: F4 LB Source seg: 0 - no action, 1 - configure (Note 1)
1338 + * - 13: F4 LB Source e2e: 0 - no action, 1 - configure (Note 1)
1339 + * - 12: F4 LB Source e2e: 0 - no action, 1 - configure (Note 1)
1340 + * - 11:8: Reserved:
1341 + * - 7:0: Channel: AAL5/AAL2 VC/VP channel (Note 2)
1342 + *
1343 + *
1344 + * Note 1: Only one LB function may be enabled at one time. Once enabled,
1345 + * the PDSP will time out after 5 seconds. The host must wait until it
1346 + * has received the result of the current LB request before initiating
1347 + * a new request. <BR>
1348 + * Note 2: This must specify the VC channel for F5 functions, and the VP
1349 + * channel for F4 functions.
1350 + *
1351 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1352 + * @param OamConfig A 32-bit integer field defined as follows:
1353 + * @param LLID Loopback Location Identifier (passed as 4 word array).
1354 + * Must be configured in big endian format.
1355 + * @param CorrelationTag 32-bit tag correlates loopback commands with loopback
1356 + * responses. Must be configured in big endian format.
1357 + *
1358 + */
1359 +static void halOamLoopbackConfig(HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag)
1360 + {
1361 + volatile bit32u *tmp;
1362 +
1363 + /* test to see if this is a loopback command */
1364 + if (OamConfig & 0xf000)
1365 + {
1366 + /* write the OAM correlation tag (GPR 1) */
1367 + SAR_PDSP_OAM_CORR_REG(HalDev->dev_base) = CorrelationTag;
1368 +
1369 + /* write the LLID */
1370 + tmp = pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base);
1371 +
1372 + /* advance past the CPID */
1373 + tmp += 4;
1374 +
1375 + *tmp++ = LLID[0];
1376 + *tmp++ = LLID[1];
1377 + *tmp++ = LLID[2];
1378 + *tmp = LLID[3];
1379 +
1380 + /* GPR 0 */
1381 + SAR_PDSP_HOST_OAM_CONFIG_REG(HalDev->dev_base) = OamConfig;
1382 + }
1383 + }
1384 +
1385 +/*
1386 + * This function allows the host software to access any register directly.
1387 + * Primarily used for debug.
1388 + *
1389 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1390 + * @param RegOffset Hexadecimal offset to desired register (from device base addr)
1391 + *
1392 + * @return Volatile pointer to desired register.
1393 + */
1394 +static volatile bit32u* halRegAccess(HAL_DEVICE *HalDev, bit32u RegOffset)
1395 + {
1396 + /* compute the register address */
1397 + return ((volatile bit32u *)(HalDev->dev_base + RegOffset));
1398 + }
1399 +
1400 +#ifdef __CPHAL_DEBUG
1401 +static void dbgConfigDump(HAL_DEVICE *HalDev)
1402 + {
1403 + dbgPrintf(" AAL5 Inst %d Config Dump:\n", HalDev->Inst);
1404 + dbgPrintf(" Base :%08x, offset:%08d\n",
1405 + HalDev->dev_base, HalDev->offset);
1406 + dbgPrintf(" Interrupt:%08d, debug :%08d\n",
1407 + HalDev->interrupt, HalDev->debug);
1408 + osfuncSioFlush();
1409 + }
1410 +#endif
1411 +
1412 +/**
1413 + * @ingroup CPHAL_Functions
1414 + * Performs a variety of control functions on the CPHAL module. It is used to
1415 + * modify/read configuration parameters and to initiate internal functions.
1416 + * The @p Key indicates the function to perform or the parameter to access (note
1417 + * that these Keys are identical to those used in accessing the configuration data
1418 + * store). @p Action is applicable to parameters only, and indicates what the
1419 + * CPHAL should do with the parameter (i.e. "Set", "Get", etc..). The actions
1420 + * for each parameter are defined in the module specific documentation.
1421 + *
1422 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
1423 + * @param Key Key specifying the parameter to change or internal function to initiate. See module specific documentation for available keys.
1424 + * @param Action Specifies the action to take. See module specific documentation for available actions.
1425 + * @param Value Pointer to new value for given @p Key parameter ("Set"), or returned value of Key ("Get").
1426 + *
1427 + * @return EC_NO_ERRORS (ok).<BR>
1428 + * Possible Error Codes:<BR>
1429 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
1430 + * @ref EC_VAL_KEY_NOT_FOUND "EC_VAL_KEY_NOT_FOUND"<BR>
1431 + * @ref EC_VAL_ACTION_NOT_FOUND "EC_VAL_ACTION_NOT_FOUND"<BR>
1432 + */
1433 +static int halControl(HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value)
1434 + {
1435 + int Level, Ch, KeyFound=0, ActionFound=0, rc=EC_NO_ERRORS, Queue;
1436 + char *TmpKey = (char *)Key;
1437 +
1438 +#ifdef __CPHAL_DEBUG
1439 + if (DBG(0))
1440 + {
1441 + dbgPrintf("[aal5]halControl(HalDev:%08x, Key:%s, Action:%s, Value:%08x)\n", (bit32u)HalDev,
1442 + Key, Action, (bit32u)Value);
1443 + osfuncSioFlush();
1444 + }
1445 +#endif
1446 +
1447 + /* Verify proper device state */
1448 + if (HalDev->State < enInitialized)
1449 + return (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_STATE);
1450 +
1451 + if (HalDev->OsFunc->Strcmpi(Key, "Debug") == 0)
1452 + {
1453 + KeyFound=1;
1454 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1455 + {
1456 + ActionFound=1;
1457 + HalDev->debug = *(int *)Value;
1458 + /* also setup debug variable in CPSAR module */
1459 + rc = HalDev->SarFunc->Control(HalDev->SarDev, "Debug", "Set", Value);
1460 + }
1461 + }
1462 +
1463 + if (HalDev->OsFunc->Strstr(Key, "FwdUnkVc.") != 0)
1464 + {
1465 + KeyFound=1;
1466 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1467 + {
1468 + ActionFound=1;
1469 +
1470 + /* extract channel number */
1471 + TmpKey += HalDev->OsFunc->Strlen("FwdUnkVc.");
1472 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1473 +
1474 + HalDev->ChData[Ch].FwdUnkVc = *(int *)Value;
1475 +
1476 + if ((HalDev->State == enOpened) && (HalDev->ChData[Ch].PktType == 3))
1477 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1478 + }
1479 + }
1480 +
1481 + /* +GSG 030407 */
1482 + if (HalDev->OsFunc->Strcmpi(Key, "OamMode") == 0)
1483 + {
1484 + KeyFound=1;
1485 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1486 + {
1487 + ActionFound=1;
1488 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1489 + }
1490 +
1491 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1492 + {
1493 + ActionFound=1;
1494 + rc = HalDev->SarFunc->Control(HalDev->SarDev, Key, Action, Value);
1495 + }
1496 + }
1497 +
1498 + /* +GSG 030307 */
1499 + if (HalDev->OsFunc->Strcmpi(Key, "Version") == 0)
1500 + {
1501 + KeyFound=1;
1502 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1503 + {
1504 + ActionFound=1;
1505 + *(const char **)Value = pszVersion_CPAAL5;
1506 + }
1507 + }
1508 +
1509 + /* +GSG 030529 */
1510 + if (HalDev->OsFunc->Strcmpi(Key, "TurboDslErrors") == 0)
1511 + {
1512 + KeyFound=1;
1513 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1514 + {
1515 + ActionFound=1;
1516 + *(int *)Value = HalDev->TurboDslErrors;
1517 + }
1518 + }
1519 +
1520 + /* +GSG 030416 */
1521 + if (HalDev->OsFunc->Strcmpi(Key, "F4_LB_Counter") == 0)
1522 + {
1523 + KeyFound=1;
1524 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1525 + {
1526 + ActionFound=1;
1527 + *(int *)Value = SAR_PDSP_OAM_F4_LB_COUNT_REG(HalDev->dev_base);
1528 + }
1529 + }
1530 +
1531 + /* +GSG 030416 */
1532 + if (HalDev->OsFunc->Strcmpi(Key, "F5_LB_Counter") == 0)
1533 + {
1534 + KeyFound=1;
1535 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1536 + {
1537 + ActionFound=1;
1538 + *(int *)Value = SAR_PDSP_OAM_F5_LB_COUNT_REG(HalDev->dev_base);
1539 + }
1540 + }
1541 +
1542 + if (HalDev->OsFunc->Strstr(Key, "Stats;") != 0)
1543 + {
1544 + KeyFound=1;
1545 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1546 + {
1547 + ActionFound=1;
1548 + TmpKey += HalDev->OsFunc->Strlen("Stats;");
1549 + Level = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1550 + TmpKey++;
1551 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1552 + TmpKey++;
1553 + Queue = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1554 + TmpKey++;
1555 + StatsGet(HalDev, (void **)Value, Level, Ch, Queue);
1556 + }
1557 + }
1558 +
1559 + /* +GSG 030306 */
1560 + /* Fixes PITS #100 */
1561 + if (HalDev->OsFunc->Strstr(Key, "Gfc.") != 0)
1562 + {
1563 + KeyFound=1;
1564 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1565 + {
1566 + ActionFound=1;
1567 + /* extract channel number */
1568 + TmpKey += HalDev->OsFunc->Strlen("Gfc.");
1569 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1570 +
1571 + /* first, store new value in our channel structure */
1572 + HalDev->ChData[Ch].Gfc = *(int *)Value;
1573 + }
1574 + }
1575 +
1576 + /* +GSG 030306 */
1577 + /* Fixes PITS #100 */
1578 + if (HalDev->OsFunc->Strstr(Key, "Clp.") != 0)
1579 + {
1580 + KeyFound=1;
1581 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1582 + {
1583 + ActionFound=1;
1584 + /* extract channel number */
1585 + TmpKey += HalDev->OsFunc->Strlen("Clp.");
1586 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1587 +
1588 + /* first, store new value in our channel structure */
1589 + HalDev->ChData[Ch].Clp = *(int *)Value;
1590 + }
1591 + }
1592 +
1593 + /* +GSG 030306 */
1594 + /* Fixes PITS #100 */
1595 + if (HalDev->OsFunc->Strstr(Key, "Pti.") != 0)
1596 + {
1597 + KeyFound=1;
1598 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1599 + {
1600 + ActionFound=1;
1601 + /* extract channel number */
1602 + TmpKey += HalDev->OsFunc->Strlen("Pti.");
1603 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1604 +
1605 + /* first, store new value in our channel structure */
1606 + HalDev->ChData[Ch].Pti = *(int *)Value;
1607 + }
1608 + }
1609 +
1610 + /* +GSG 030306 */
1611 + /* Fixes PITS #100 */
1612 + if (HalDev->OsFunc->Strstr(Key, "CpcsUU.") != 0)
1613 + {
1614 + KeyFound=1;
1615 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1616 + {
1617 + ActionFound=1;
1618 + /* extract channel number */
1619 + TmpKey += HalDev->OsFunc->Strlen("CpcsUU.");
1620 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1621 +
1622 + /* first, store new value in our channel structure */
1623 + HalDev->ChData[Ch].CpcsUU = *(int *)Value;
1624 + }
1625 + }
1626 +
1627 + /* +GSG 030306 */
1628 + /* Fixes PITS #100 */
1629 + if (HalDev->OsFunc->Strstr(Key, "TxVc_CellRate.") != 0)
1630 + {
1631 + KeyFound=1;
1632 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1633 + {
1634 + ActionFound=1;
1635 + /* extract channel number */
1636 + TmpKey += HalDev->OsFunc->Strlen("TxVc_CellRate.");
1637 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1638 +
1639 + /* first, store new value in our channel structure */
1640 + HalDev->ChData[Ch].TxVc_CellRate = *(int *)Value;
1641 +
1642 + /* now, apply to PDSP state RAM */
1643 + if (HalDev->State == enOpened)
1644 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))= HalDev->ChData[Ch].TxVc_CellRate;
1645 + }
1646 + }
1647 +
1648 + /* +GSG 030306 */
1649 + /* Fixes PITS #100 */
1650 + if (HalDev->OsFunc->Strstr(Key, "TxVc_Mbs.") != 0)
1651 + {
1652 + KeyFound=1;
1653 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1654 + {
1655 + ActionFound=1;
1656 + /* extract channel number */
1657 + TmpKey += HalDev->OsFunc->Strlen("TxVc_Mbs.");
1658 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1659 +
1660 + /* first, store new value in our channel structure */
1661 + HalDev->ChData[Ch].TxVc_Mbs = *(int *)Value;
1662 +
1663 + /* now, apply to PDSP state RAM */
1664 + if (HalDev->State == enOpened)
1665 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)= HalDev->ChData[Ch].TxVc_Mbs;
1666 + }
1667 + }
1668 +
1669 + if (HalDev->OsFunc->Strstr(Key, "TxVc_AtmHeader.") != 0)
1670 + {
1671 + KeyFound=1;
1672 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1673 + {
1674 + ActionFound=1;
1675 + /* extract channel number */
1676 + TmpKey += HalDev->OsFunc->Strlen("TxVc_AtmHeader.");
1677 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1678 +
1679 + /* first, store new value in our channel structure */
1680 + HalDev->ChData[Ch].TxVc_AtmHeader = *(int *)Value;
1681 +
1682 + /* now, apply to PDSP state RAM */
1683 + if (HalDev->State == enOpened)
1684 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+6)= HalDev->ChData[Ch].TxVc_AtmHeader;
1685 + }
1686 + }
1687 +
1688 + if (HalDev->OsFunc->Strstr(Key, "TxVp_AtmHeader.") != 0)
1689 + {
1690 + KeyFound=1;
1691 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1692 + {
1693 + ActionFound=1;
1694 + /* extract channel number */
1695 + TmpKey += HalDev->OsFunc->Strlen("TxVp_AtmHeader.");
1696 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1697 +
1698 + /* first, store new value in our channel structure */
1699 + HalDev->ChData[Ch].TxVp_AtmHeader = *(int *)Value;
1700 +
1701 + /* now, apply to PDSP state RAM */
1702 + if (HalDev->State == enOpened)
1703 + *(pPDSP_AAL5_TX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64))= HalDev->ChData[Ch].TxVp_AtmHeader;
1704 + }
1705 + }
1706 +
1707 + /* +GSG 030306 */
1708 + /* Fixes PITS #100 */
1709 + if (HalDev->OsFunc->Strstr(Key, "TxVc_Pcr.") != 0)
1710 + {
1711 + KeyFound=1;
1712 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1713 + {
1714 + ActionFound=1;
1715 + /* extract channel number */
1716 + TmpKey += HalDev->OsFunc->Strlen("TxVc_Pcr.");
1717 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1718 +
1719 + /* first, store new value in our channel structure */
1720 + HalDev->ChData[Ch].TxVc_Pcr = *(int *)Value;
1721 +
1722 + /* now, apply to PDSP state RAM */
1723 + if (HalDev->State == enOpened)
1724 + *(pPDSP_AAL5_TX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+4)= HalDev->ChData[Ch].TxVc_Pcr;
1725 + }
1726 + }
1727 +
1728 + /* +GSG 030428 */
1729 + if (HalDev->OsFunc->Strstr(Key, "RxVc_OamCh.") != 0)
1730 + {
1731 + KeyFound=1;
1732 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1733 + {
1734 + ActionFound=1;
1735 + /* extract channel number */
1736 + TmpKey += HalDev->OsFunc->Strlen("RxVc_OamCh.");
1737 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1738 +
1739 + /* first, store new value in our channel structure */
1740 + HalDev->ChData[Ch].RxVc_OamCh = (*(int *)Value) & 0xff;
1741 +
1742 + /* now, apply to PDSP state RAM */
1743 + if (HalDev->State == enOpened)
1744 + *(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)) |= HalDev->ChData[Ch].RxVc_OamCh;
1745 + }
1746 + }
1747 +
1748 + /* +GSG 030428 */
1749 + if (HalDev->OsFunc->Strstr(Key, "RxVp_OamCh.") != 0)
1750 + {
1751 + KeyFound=1;
1752 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1753 + {
1754 + ActionFound=1;
1755 + /* extract channel number */
1756 + TmpKey += HalDev->OsFunc->Strlen("RxVp_OamCh.");
1757 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1758 +
1759 + /* first, store new value in our channel structure */
1760 + HalDev->ChData[Ch].RxVp_OamCh = (*(int *)Value) & 0xff;
1761 +
1762 + /* now, apply to PDSP state RAM */
1763 + if (HalDev->State == enOpened)
1764 + *(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1) |= HalDev->ChData[Ch].RxVp_OamCh;
1765 + }
1766 + }
1767 +
1768 + /* +GSG 030304 */
1769 + /* Fixes PITS #98 */
1770 + if (HalDev->OsFunc->Strstr(Key, "PdspEnable") != 0)
1771 + {
1772 + KeyFound=1;
1773 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1774 + {
1775 + ActionFound=1;
1776 +
1777 + /* this variable is controlled by the CPSAR module */
1778 + if (HalDev->State == enOpened)
1779 + {
1780 + rc=HalDev->SarFunc->Control(HalDev->SarDev, "PdspEnable", "Set", Value);
1781 + }
1782 + }
1783 + }
1784 +
1785 + if (HalDev->OsFunc->Strstr(Key, "OamLbTimeout") != 0)
1786 + {
1787 + KeyFound=1;
1788 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1789 + {
1790 + ActionFound=1;
1791 +
1792 + HalDev->OamLbTimeout = *(int *)Value;
1793 + /* this variable is controlled by the CPSAR module */
1794 + if (HalDev->State == enOpened)
1795 + {
1796 + *(pOAM_TIMER_STATE_WORD_0(HalDev->dev_base) + 1) =
1797 + ((HalDev->SarFrequency/1000) * HalDev->OamLbTimeout);
1798 + }
1799 + }
1800 + }
1801 +
1802 + /* +GSG 030306 (PITS #114) */
1803 + if (HalDev->OsFunc->Strstr(Key, "DeviceCPID") != 0)
1804 + {
1805 + KeyFound=1;
1806 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1807 + {
1808 + unsigned int* local = (unsigned int *)Value;
1809 + ActionFound=1;
1810 + /* first, store new value in our hal structure */
1811 + HalDev->DeviceCPID[0] = local[0];
1812 + HalDev->DeviceCPID[1] = local[1];
1813 + HalDev->DeviceCPID[2] = local[2];
1814 + HalDev->DeviceCPID[3] = local[3];
1815 +
1816 + /* now, apply to PDSP state RAM */
1817 + if (HalDev->State == enOpened)
1818 + {
1819 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 0) = HalDev->DeviceCPID[0];
1820 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 1) = HalDev->DeviceCPID[1];
1821 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 2) = HalDev->DeviceCPID[2];
1822 + *(bit32u *)(pOAM_CONFIG_BLOCK_WORD_0(HalDev->dev_base) + 3) = HalDev->DeviceCPID[3];
1823 + }
1824 + }
1825 + }
1826 +
1827 + /* +GSG 030304 */
1828 + /* Fixes PITS #99 */
1829 + if (HalDev->OsFunc->Strstr(Key, "StrictPriority") != 0)
1830 + {
1831 + KeyFound=1;
1832 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1833 + {
1834 + ActionFound=1;
1835 +
1836 + /* used in halOpen to decide which interrupt handler to use */
1837 + HalDev->StrictPriority = *(int *)Value;
1838 + }
1839 + }
1840 +
1841 + if (HalDev->OsFunc->Strstr(Key, hcMaxFrags) != 0)
1842 + {
1843 + KeyFound=1;
1844 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1845 + {
1846 + ActionFound=1;
1847 +
1848 + if ((*(int *)Value) > 0)
1849 + HalDev->MaxFrags = *(int *)Value;
1850 + else
1851 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_INVALID_VALUE);
1852 + }
1853 +
1854 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1855 + {
1856 + ActionFound=1;
1857 +
1858 + *(int *)Value = HalDev->MaxFrags;
1859 + }
1860 + }
1861 +
1862 + /* +GSG 030306 */
1863 + /* Fixes PITS #103 */
1864 + if (HalDev->OsFunc->Strstr(Key, "RxVc_RDICount.") != 0)
1865 + {
1866 + KeyFound=1;
1867 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1868 + {
1869 + ActionFound=1;
1870 +
1871 + /* extract channel number */
1872 + TmpKey += HalDev->OsFunc->Strlen("RxVc_RDICount.");
1873 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1874 +
1875 + /* PDSP's Rx VC State word 3 contains the value */
1876 + if (HalDev->State == enOpened)
1877 + {
1878 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))) & RDI_CNT_MASK)>>RDI_CNT_SHIFT);
1879 + }
1880 + }
1881 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1882 + {
1883 + ActionFound=1;
1884 +
1885 + /* extract channel number */
1886 + TmpKey += HalDev->OsFunc->Strlen("RxVc_RDICount.");
1887 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1888 +
1889 + /* All sets write 0, this action is a clear only */
1890 + if (HalDev->State == enOpened)
1891 + {
1892 + (*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64))) &=~ RDI_CNT_MASK;
1893 + }
1894 + }
1895 + }
1896 +
1897 + /* +GSG 030306 */
1898 + /* Fixes PITS #103 */
1899 + if (HalDev->OsFunc->Strstr(Key, "RxVc_AISseg.") != 0)
1900 + {
1901 + KeyFound=1;
1902 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1903 + {
1904 + ActionFound=1;
1905 +
1906 + /* extract channel number */
1907 + TmpKey += HalDev->OsFunc->Strlen("RxVc_AISseg.");
1908 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1909 +
1910 + /* PDSP's Rx VC State word 3 contains the value */
1911 + if (HalDev->State == enOpened)
1912 + {
1913 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+3)) & AIS_SEG_MASK)>>AIS_SEG_SHIFT);
1914 + }
1915 + }
1916 + }
1917 +
1918 + /* +GSG 030306 */
1919 + /* Fixes PITS #103 */
1920 + if (HalDev->OsFunc->Strstr(Key, "RxVc_AISetoe.") != 0)
1921 + {
1922 + KeyFound=1;
1923 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1924 + {
1925 + ActionFound=1;
1926 +
1927 + /* extract channel number */
1928 + TmpKey += HalDev->OsFunc->Strlen("RxVc_AISetoe.");
1929 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1930 +
1931 + /* PDSP's Rx VC State word 3 contains the value */
1932 + if (HalDev->State == enOpened)
1933 + {
1934 + *(int *)Value = (((*(pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+3)) & AIS_ETOE_MASK)>>AIS_ETOE_SHIFT);
1935 + }
1936 + }
1937 + }
1938 +
1939 + /* +GSG 030306 */
1940 + /* Fixes PITS #103 */
1941 + if (HalDev->OsFunc->Strstr(Key, "RxVp_RDICount.") != 0)
1942 + {
1943 + KeyFound=1;
1944 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1945 + {
1946 + ActionFound=1;
1947 +
1948 + /* extract channel number */
1949 + TmpKey += HalDev->OsFunc->Strlen("RxVp_RDICount.");
1950 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1951 +
1952 + /* PDSP's Rx VC State word 3 contains the value */
1953 + if (HalDev->State == enOpened)
1954 + {
1955 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1)) & RDI_CNT_MASK)>>RDI_CNT_SHIFT);
1956 + }
1957 + }
1958 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
1959 + {
1960 + ActionFound=1;
1961 +
1962 + /* extract channel number */
1963 + TmpKey += HalDev->OsFunc->Strlen("RxVp_RDICount.");
1964 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1965 +
1966 + /* All sets write 0, this action is a clear only */
1967 + if (HalDev->State == enOpened)
1968 + {
1969 + (*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+1)) &=~ RDI_CNT_MASK;
1970 + }
1971 + }
1972 + }
1973 +
1974 + /* +GSG 030306 */
1975 + /* Fixes PITS #103 */
1976 + if (HalDev->OsFunc->Strstr(Key, "RxVp_AISseg.") != 0)
1977 + {
1978 + KeyFound=1;
1979 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
1980 + {
1981 + ActionFound=1;
1982 +
1983 + /* extract channel number */
1984 + TmpKey += HalDev->OsFunc->Strlen("RxVp_AISseg.");
1985 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
1986 +
1987 + /* PDSP's Rx VC State word 3 contains the value */
1988 + if (HalDev->State == enOpened)
1989 + {
1990 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)) & AIS_SEG_MASK)>>AIS_SEG_SHIFT);
1991 + }
1992 + }
1993 + }
1994 +
1995 + /* +GSG 030306 */
1996 + /* Fixes PITS #103 */
1997 + if (HalDev->OsFunc->Strstr(Key, "RxVp_AISetoe.") != 0)
1998 + {
1999 + KeyFound=1;
2000 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
2001 + {
2002 + ActionFound=1;
2003 +
2004 + /* extract channel number */
2005 + TmpKey += HalDev->OsFunc->Strlen("RxVp_AISetoe.");
2006 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
2007 +
2008 + /* PDSP's Rx VC State word 3 contains the value */
2009 + if (HalDev->State == enOpened)
2010 + {
2011 + *(int *)Value = (((*(pPDSP_AAL5_RX_VP_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+2)) & AIS_ETOE_MASK)>>AIS_ETOE_SHIFT);
2012 + }
2013 + }
2014 + }
2015 +
2016 + if (KeyFound == 0)
2017 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND);
2018 +
2019 + if (ActionFound == 0)
2020 + rc = (EC_AAL5|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND);
2021 +
2022 + return(rc);
2023 + }
2024 +
2025 +/*
2026 + * Sets up HAL default configuration parameter values.
2027 + */
2028 +static void ConfigInit(HAL_DEVICE *HalDev)
2029 + {
2030 +#ifdef __CPHAL_DEBUG
2031 + if (DBG(0))
2032 + {
2033 + dbgPrintf("[aal5]ConfigInit(HalDev:%08x)\n", (bit32u)HalDev);
2034 + osfuncSioFlush();
2035 + }
2036 +#endif
2037 +
2038 + /* configure some defaults with tnetx7300 values */
2039 + HalDev->dev_base = 0xa3000000;
2040 + HalDev->offset = 0;
2041 + HalDev->interrupt = 15;
2042 + HalDev->debug = 0;
2043 + HalDev->MaxFrags = 46;
2044 + HalDev->OamLbTimeout = 5000;
2045 + }
2046 +
2047 +/*
2048 + * Retrieve HAL configuration parameter values.
2049 + */
2050 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
2051 + {
2052 + bit32u Ret;
2053 +
2054 +#ifdef __CPHAL_DEBUG
2055 + if (DBG(0))
2056 + {
2057 + dbgPrintf("[aal5]ConfigGet(HalDev:%08x)\n", (bit32u)HalDev);
2058 + osfuncSioFlush();
2059 + }
2060 +#endif
2061 +
2062 + /* get the configuration parameters common to all modules */
2063 + Ret = ConfigGetCommon(HalDev);
2064 + if (Ret) return (EC_AAL5|Ret);
2065 +
2066 + /* get AAL5 specific configuration parameters here */
2067 + Ret = HalDev->OsFunc->Control(HalDev->OsDev, hcSarFrequency, pszGET, &HalDev->SarFrequency); /* GSG +030416*/
2068 + if (Ret) /* GSG +030416*/
2069 + HalDev->SarFrequency = 200000000; /* 200 Mhz default */ /* GSG +030416*/
2070 +
2071 + return (EC_NO_ERRORS);
2072 + }
2073 +
2074 +/**
2075 + * @ingroup CPHAL_Functions
2076 + * This function initializes the CPHAL module. It gathers all
2077 + * necessary global configuration info from the configuration file, and
2078 + * performs initialization and configuration of the device. Note that
2079 + * the device operation is not started until the OS calls @c Open().
2080 + *
2081 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2082 + *
2083 + * @return EC_NO_ERRORS (ok). <BR>
2084 + * Possible Error Codes:<BR>
2085 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2086 + * @ref EC_VAL_BASE_ADDR_NOT_FOUND "EC_VAL_BASE_ADDR_NOT_FOUND"<BR>
2087 + * @ref EC_VAL_RESET_BIT_NOT_FOUND "EC_VAL_RESET_BIT_NOT_FOUND"<BR>
2088 + * @ref EC_VAL_INTERRUPT_NOT_FOUND "EC_VAL_INTERRUPT_NOT_FOUND"<BR>
2089 + * @ref EC_VAL_OFFSET_NOT_FOUND "EC_VAL_OFFSET_NOT_FOUND"<BR>
2090 + */
2091 +static int halInit(HAL_DEVICE *HalDev)
2092 + {
2093 + int i;
2094 + bit32u error_code;
2095 +
2096 +#ifdef __CPHAL_DEBUG
2097 + if (DBG(0))
2098 + {
2099 + dbgPrintf("[aal5]halInit(HalDev:%08x)\n", (bit32u)HalDev);
2100 + osfuncSioFlush();
2101 + }
2102 +#endif
2103 +
2104 + /* Verify proper device state */
2105 + if (HalDev->State != enDevFound)
2106 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_INVALID_STATE);
2107 +
2108 + /* Configure HAL defaults */
2109 + ConfigInit(HalDev);
2110 +
2111 + /* Retrieve HAL configuration parameters from data store */
2112 + error_code = ConfigGet(HalDev);
2113 + if (error_code) return (error_code);
2114 +
2115 + /* Other items (OAM related) that need to be passed in somehow */
2116 + HalDev->DeviceCPID[0] = 0xffffffff;
2117 + HalDev->DeviceCPID[1] = 0xffffffff;
2118 + HalDev->DeviceCPID[2] = 0xffffffff;
2119 + HalDev->DeviceCPID[3] = 0xffffffff;
2120 + HalDev->LBSourceLLID[0] = 0xffffffff;
2121 + HalDev->LBSourceLLID[1] = 0xffffffff;
2122 + HalDev->LBSourceLLID[2] = 0xffffffff;
2123 + HalDev->LBSourceLLID[3] = 0xffffffff;
2124 +
2125 + /* Initialize SAR layer*/
2126 + error_code = HalDev->SarFunc->Init(HalDev->SarDev);
2127 + if (error_code) return (error_code);
2128 +
2129 + /* Initialize various HalDev members. This is probably overkill, since these
2130 + are initialized in ChannelSetup() and HalDev is cleared in InitModule(). */
2131 + for (i=0; i<NUM_AAL5_CHAN; i++)
2132 + {
2133 + HalDev->InRxInt[i]=FALSE;
2134 + HalDev->ChIsOpen[i][DIRECTION_TX] = FALSE;
2135 + HalDev->ChIsOpen[i][DIRECTION_RX] = FALSE;
2136 + HalDev->TcbStart[i][0] = 0;
2137 + HalDev->TcbStart[i][1] = 0;
2138 + HalDev->RcbStart[i] = 0;
2139 + }
2140 +
2141 + /* initialize SAR stats */
2142 + StatsClear(HalDev);
2143 +
2144 + /* init Stat pointers */
2145 +
2146 + /* even though these statistics may be for multiple channels/queues, i need
2147 + only configure the pointer to the beginning of the array, and I can index
2148 + from there if necessary */
2149 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
2150 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
2151 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
2152 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
2153 +
2154 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
2155 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
2156 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
2157 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
2158 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
2159 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
2160 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
2161 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
2162 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
2163 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
2164 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
2165 +
2166 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
2167 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
2168 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
2169 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
2170 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
2171 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
2172 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
2173 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
2174 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
2175 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
2176 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
2177 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
2178 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
2179 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
2180 +
2181 + StatsTable4[0].StatPtr = &HalDev->dev_base;
2182 + StatsTable4[1].StatPtr = &HalDev->offset;
2183 + StatsTable4[2].StatPtr = &HalDev->interrupt;
2184 + StatsTable4[3].StatPtr = &HalDev->debug;
2185 + StatsTable4[4].StatPtr = &HalDev->Inst;
2186 +
2187 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
2188 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
2189 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
2190 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
2191 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
2192 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
2193 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
2194 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
2195 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
2196 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
2197 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
2198 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
2199 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
2200 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
2201 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
2202 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
2203 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
2204 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
2205 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
2206 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
2207 +
2208 + /* update device state */
2209 + HalDev->State = enInitialized;
2210 +
2211 +#ifdef __CPHAL_DEBUG
2212 + if (DBG(9))
2213 + dbgConfigDump(HalDev);
2214 +#endif
2215 +
2216 + return(EC_NO_ERRORS);
2217 + }
2218 +
2219 +/*
2220 + * Use this function to actually send after queuing multiple packets using
2221 + * Send(). This is a debug only function that should be removed - it was
2222 + * necessary to properly implement my loopback tests.
2223 + *
2224 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2225 + * @param Queue Queue number to kick.
2226 + *
2227 + * @return 0 OK, Non-Zero Not OK
2228 + */
2229 +static int halKick(HAL_DEVICE *HalDev, int Queue)
2230 + {
2231 + int Ch;
2232 +
2233 +#ifdef __CPHAL_DEBUG
2234 + if (DBG(0))
2235 + {
2236 + dbgPrintf("[aal5]halKick(HalDev:%08x. Queue:%d)\n", (bit32u)HalDev, Queue);
2237 + osfuncSioFlush();
2238 + }
2239 +#endif
2240 +
2241 + for (Ch = 0; Ch < 16; Ch ++)
2242 + {
2243 + if ((!HalDev->TxActive[Ch][Queue]) && (HalDev->TxActQueueHead[Ch][Queue] != 0))
2244 + {
2245 + *(pTX_DMA_STATE_WORD_0(HalDev->dev_base)+(Ch*64)+Queue)=
2246 + VirtToPhys(HalDev->TxActQueueHead[Ch][Queue]);
2247 + HalDev->TxActive[Ch][Queue]=TRUE;
2248 + }
2249 + }
2250 +
2251 + return (EC_NO_ERRORS);
2252 + }
2253 +
2254 +/* +GSG 030305 For PITS #99
2255 + * Alternate interrupt handler that uses the INT_VECTOR in order to
2256 + * provide strict priority handling among channels, beginning with Ch 0.
2257 + *
2258 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2259 + * @param MoreWork (Output) When set to 1, indicates that there is more work to do.
2260 + * Caller should ensure that the value pointed at is set to 0
2261 + * prior to the call.
2262 + * @return 0 OK, non-zero error.
2263 + */
2264 +static int DeviceIntAlt(HAL_DEVICE *HalDev, int *MoreWork)
2265 + {
2266 + int tmp, Ch, WorkFlag;
2267 + bit32u rc;
2268 +
2269 +#ifdef __CPHAL_DEBUG
2270 + if (DBG(0))
2271 + {
2272 + dbgPrintf("[aal5]DeviceIntAlt(HalDev:%08x, MoreWork:%08x)\n", (bit32u)HalDev, (bit32u)MoreWork);
2273 + osfuncSioFlush();
2274 + }
2275 +#endif
2276 +
2277 + /* Verify proper device state - important because a call prior to Open would
2278 + result in a lockup */
2279 + if (HalDev->State != enOpened)
2280 + return(EC_AAL5|EC_FUNC_DEVICE_INT_ALT|EC_VAL_INVALID_STATE);
2281 +
2282 + if ((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING)
2283 + {
2284 + /*printf("\015 %d RxQ",HalDev->RxActQueueCount[0]);
2285 + HalDev->OsFunc->Control(HalDev->OsDev, enSIO_FLUSH, enNULL, 0); */
2286 +
2287 + if (tmp&TXH_PEND)
2288 + {
2289 + /* decide which channel to service */
2290 + Ch = (SAR_INTR_VECTOR(HalDev->dev_base) & TXH_PEND_INVEC);
2291 +
2292 + rc = TxInt(HalDev,Ch,0,&WorkFlag);
2293 + if (rc) return (rc);
2294 +
2295 + if (WorkFlag == 1)
2296 + *MoreWork = 1;
2297 + }
2298 +
2299 + if (tmp&TXL_PEND)
2300 + {
2301 + /* decide which channel to service */
2302 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & TXL_PEND_INVEC) >> 4);
2303 +
2304 + rc = TxInt(HalDev,Ch,1,&WorkFlag);
2305 + if (rc) return (rc);
2306 +
2307 + if (WorkFlag == 1)
2308 + *MoreWork = 1;
2309 + }
2310 +
2311 + if (tmp&RX_PEND)
2312 + {
2313 + /* decide which channel to service */
2314 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & RX_PEND_INVEC) >> 8);
2315 +
2316 + rc = RxInt(HalDev,Ch,&WorkFlag);
2317 + if (rc) return (rc);
2318 +
2319 + if (WorkFlag == 1)
2320 + *MoreWork = 1;
2321 + }
2322 +
2323 + if (tmp&STS_PEND)
2324 + {
2325 + /* GPR 2 code added for PITS 103 */
2326 + /* determine interrupt source */
2327 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & STS_PEND_INVEC) >> 12);
2328 +
2329 + /* only if this is GPR 2 interrupt do we take action */
2330 + if (Ch == 26)
2331 + {
2332 + /* pass loopback result back to OS */
2333 + HalDev->OsFunc->Control(HalDev->OsDev, "OamLbResult", "Set",
2334 + (bit32u *)pSAR_PDSP_OAM_LB_RESULT_REG(HalDev->dev_base));
2335 + }
2336 +
2337 + /* clear the interrupt */
2338 + SAR_STATUS_CLR_REG(HalDev->dev_base) |= 0x04000000;
2339 + }
2340 +
2341 + if (tmp&AAL2_PEND)
2342 + {
2343 + /* no action defined */
2344 + }
2345 +
2346 + SAR_INTR_VECTOR(HalDev->dev_base) = 0;
2347 + }
2348 +
2349 + return (EC_NO_ERRORS);
2350 + }
2351 +
2352 +/*
2353 + * Called to service a module interrupt. This function determines
2354 + * what type of interrupt occurred and dispatches the correct handler.
2355 + *
2356 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2357 + * @param MoreWork (Output) When set to 1, indicates that there is more work to do.
2358 + * Caller should ensure that the value pointed at is set to 0
2359 + * prior to the call.
2360 + * @return 0 OK, non-zero error.
2361 + */
2362 +static int DeviceInt(HAL_DEVICE *HalDev, int *MoreWork)
2363 + {
2364 + /*static int NextRxCh=0;
2365 + static int NextTxCh[2]={0,0};*/
2366 +
2367 + int tmp, Ch, FirstCh, WorkFlag;
2368 + int NextTxLCh, NextTxHCh, NextRxCh;
2369 + bit32u rc;
2370 +
2371 +#ifdef __CPHAL_DEBUG
2372 + if (DBG(0))
2373 + {
2374 + dbgPrintf("[aal5]DeviceInt(HalDev:%08x, MoreWork:%08x)\n", (bit32u)HalDev, (bit32u)MoreWork);
2375 + osfuncSioFlush();
2376 + }
2377 +#endif
2378 +
2379 + /* Verify proper device state - important because a call prior to Open would
2380 + result in a lockup */
2381 + if (HalDev->State != enOpened)
2382 + return(EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_INVALID_STATE);
2383 +
2384 + NextTxHCh = HalDev->NextTxCh[0];
2385 + NextTxLCh = HalDev->NextTxCh[1];
2386 + NextRxCh = HalDev->NextRxCh;
2387 +
2388 + /* service interrupts while there is more work to do */
2389 + /*while (((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING) && (TotalPkts < 500))*/
2390 + if ((tmp=SAR_INTR_VECTOR(HalDev->dev_base))&INT_PENDING)
2391 + {
2392 + /*printf("\015 %d RxQ",HalDev->RxActQueueCount[0]);
2393 + HalDev->OsFunc->Control(HalDev->OsDev, enSIO_FLUSH, enNULL, 0); */
2394 +
2395 + if (tmp&TXH_PEND)
2396 + {
2397 + /* decide which channel to service */
2398 + FirstCh = NextTxHCh;
2399 + while (1)
2400 + {
2401 + Ch = NextTxHCh++;
2402 + if (NextTxHCh == 16)
2403 + NextTxHCh = 0;
2404 + if (SAR_TX_MASKED_STATUS(HalDev->dev_base) & (1<<Ch))
2405 + break;
2406 + if (FirstCh == NextTxHCh)
2407 + {
2408 + /* we checked every channel and still haven't found anything to do */
2409 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_TXH_WORK_TO_DO);
2410 + }
2411 + }
2412 +
2413 + rc = TxInt(HalDev,Ch,0,&WorkFlag);
2414 + if (rc) return (rc);
2415 +
2416 + if (WorkFlag == 1)
2417 + *MoreWork = 1;
2418 + }
2419 +
2420 + if (tmp&TXL_PEND)
2421 + {
2422 + /* decide which channel to service */
2423 + FirstCh = NextTxLCh;
2424 + while (1)
2425 + {
2426 + Ch = NextTxLCh++;
2427 + if (NextTxLCh == 16)
2428 + NextTxLCh = 0;
2429 + if (SAR_TX_MASKED_STATUS(HalDev->dev_base) & (1<<(Ch+16)))
2430 + break;
2431 + if (FirstCh == NextTxLCh)
2432 + {
2433 + /* we checked every channel and still haven't found anything to do */
2434 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_TXL_WORK_TO_DO);
2435 + }
2436 + }
2437 +
2438 + rc = TxInt(HalDev,Ch,1,&WorkFlag);
2439 + if (rc) return (rc);
2440 +
2441 + if (WorkFlag == 1)
2442 + *MoreWork = 1;
2443 + }
2444 +
2445 + if (tmp&RX_PEND)
2446 + {
2447 + FirstCh = NextRxCh;
2448 + while (1)
2449 + {
2450 + Ch = NextRxCh++;
2451 + if (NextRxCh == 16)
2452 + NextRxCh = 0;
2453 + if (SAR_RX_MASKED_STATUS(HalDev->dev_base) & (1 << Ch))
2454 + break; /* found a channel to service */
2455 + if (FirstCh == NextRxCh)
2456 + {
2457 + /* we checked every channel and still haven't found anything to do */
2458 + return (EC_AAL5|EC_FUNC_DEVICE_INT|EC_VAL_NO_RX_WORK_TO_DO);
2459 + }
2460 + }
2461 +
2462 + rc = RxInt(HalDev,Ch, &WorkFlag);
2463 + if (rc) return (rc);
2464 +
2465 + if (WorkFlag == 1)
2466 + *MoreWork = 1;
2467 + }
2468 +
2469 + if (tmp&STS_PEND)
2470 + {
2471 + /* +GSG 030305 */
2472 + /* GPR 2 code added for PITS 103 */
2473 + /* determine interrupt source */
2474 + Ch = ((SAR_INTR_VECTOR(HalDev->dev_base) & STS_PEND_INVEC) >> 12);
2475 +
2476 + /* only if this is GPR 2 interrupt do we take action */
2477 + if (Ch == 26)
2478 + {
2479 + /* pass loopback result back to OS */
2480 + HalDev->OsFunc->Control(HalDev->OsDev, "OamLbResult", "Set",
2481 + (bit32u *)pSAR_PDSP_OAM_LB_RESULT_REG(HalDev->dev_base));
2482 + }
2483 +
2484 + /* clear the interrupt */
2485 + SAR_STATUS_CLR_REG(HalDev->dev_base) |= 0x04000000;
2486 + }
2487 +
2488 + if (tmp&AAL2_PEND)
2489 + {
2490 + /* no action defined */
2491 + }
2492 +
2493 + SAR_INTR_VECTOR(HalDev->dev_base) = 0;
2494 + }
2495 +
2496 + HalDev->NextTxCh[0] = NextTxHCh;
2497 + HalDev->NextTxCh[1] = NextTxLCh;
2498 + HalDev->NextRxCh = NextRxCh;
2499 +
2500 + /* This must be done by the upper layer */
2501 + /* SAR_EOI(HalDev->dev_base) = 0; */
2502 +
2503 + return (EC_NO_ERRORS);
2504 + }
2505 +
2506 +/**
2507 + * @ingroup CPHAL_Functions
2508 + * This function starts the operation of the CPHAL device. It takes the device
2509 + * out of reset, and calls @c IsrRegister(). This function should be called after
2510 + * calling the @c Init() function.
2511 + *
2512 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2513 + *
2514 + * @return EC_NO_ERRORS (ok).<BR>
2515 + * Possible Error Codes:<BR>
2516 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2517 + * @ref EC_VAL_KEY_NOT_FOUND "EC_VAL_KEY_NOT_FOUND"<BR>
2518 + * @ref EC_VAL_FIRMWARE_TOO_LARGE "EC_VAL_FIRMWARE_TOO_LARGE"<BR>
2519 + * @ref EC_VAL_PDSP_LOAD_FAIL "EC_VAL_PDSP_LOAD_FAIL"<BR>
2520 + * @ref EC_VAL_RX_STATE_RAM_NOT_CLEARED "EC_VAL_RX_STATE_RAM_NOT_CLEARED"<BR>
2521 + * @ref EC_VAL_TX_STATE_RAM_NOT_CLEARED "EC_VAL_TX_STATE_RAM_NOT_CLEARED"<BR>
2522 + * @ref EC_VAL_TCB_MALLOC_FAILED "EC_VAL_TCB_MALLOC_FAILED"<BR>
2523 + * @ref EC_VAL_RCB_MALLOC_FAILED "EC_VAL_RCB_MALLOC_FAILED"<BR>
2524 + * @ref EC_VAL_RX_BUFFER_MALLOC_FAILED "EC_VAL_RX_BUFFER_MALLOC_FAILED"<BR>
2525 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
2526 + */
2527 +static int halOpen(HAL_DEVICE *HalDev)
2528 + {
2529 + int i,Ret;
2530 + bit32 SarBase = HalDev->dev_base;
2531 +
2532 +#ifdef __CPHAL_DEBUG
2533 + if (DBG(0))
2534 + {
2535 + dbgPrintf("[aal5]halOpen(HalDev:%08x)\n", (bit32u)HalDev);
2536 + osfuncSioFlush();
2537 + }
2538 +#endif
2539 +
2540 + /* Verify proper device state */
2541 + if (HalDev->State < enInitialized)
2542 + return (EC_AAL5|EC_FUNC_OPEN|EC_VAL_INVALID_STATE);
2543 +
2544 + /* Open the SAR (this brings the whole device out of reset */
2545 + Ret = HalDev->SarFunc->Open(HalDev->SarDev); /* ~GSG 030410 */
2546 + if (Ret) /* +GSG 030410 */
2547 + return (Ret); /* +GSG 030410 */
2548 +
2549 + /* Change device state */
2550 + HalDev->State = enOpened;
2551 +
2552 +
2553 +#ifdef __CPHAL_DEBUG
2554 + /* print out the version information */
2555 + if (DBG(7))
2556 + {
2557 + dbgPrintf("[aal5 halOpen()]Module ID(AAL5-CPSAR):%d, Version:%2d.%02d\n",
2558 + (SAR_ID_REG(SarBase)&0xffff0000)>>16,
2559 + (SAR_ID_REG(SarBase)&0xff00)>>8,
2560 + SAR_ID_REG(SarBase)&0xff);
2561 + osfuncSioFlush();
2562 + }
2563 +#endif
2564 +
2565 + /* GREG 11/1/02: The State RAM clearing code was previously in cpsar.c,
2566 + directly after device reset. I moved it here because I believe it is
2567 + AAL5 specific code. Also the MAX_CHAN was set to 19 in cpsar.c, which
2568 + would have caused this code to clear too much memory! */
2569 +
2570 + /* NOTE: State RAM must be cleared prior to initializing the PDSP!! */
2571 +
2572 + /* GSG 030416: Removed all of this. All PDSP State RAM is cleared
2573 + in CPSAR Open(). On Close(), all channels are torndown, thus all
2574 + AAL5 channel state RAM is cleared. */
2575 +
2576 + /* Clear Rx State RAM */
2577 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2578 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
2579 + *(pRX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) = 0; */
2580 +
2581 + /* Check that Rx DMA State RAM was cleared */
2582 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2583 + for (j=0; j<NUM_RX_STATE_WORDS; j++)
2584 + {
2585 + if (*(pRX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) != 0)
2586 + {
2587 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_RX_STATE_RAM_NOT_CLEARED);
2588 + }
2589 + }*/
2590 +
2591 + /* Clear Tx State RAM */
2592 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2593 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
2594 + {
2595 + *(pTX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) = 0;
2596 + }*/
2597 +
2598 + /* Check that Tx DMA State RAM was cleared */
2599 + /*for (i=0; i<NUM_AAL5_CHAN; i++)
2600 + for (j=0; j<NUM_TX_STATE_WORDS; j++)
2601 + {
2602 + if (*(pTX_DMA_STATE_WORD_0(SarBase) + (i*64) + j) != 0)
2603 + {
2604 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_TX_STATE_RAM_NOT_CLEARED);
2605 + }
2606 + }*/
2607 +
2608 + /* GSG +030523 Malloc space for the Rx fraglist */
2609 + HalDev->fraglist = HalDev->OsFunc->Malloc(HalDev->MaxFrags * sizeof(FRAGLIST));
2610 +
2611 + /* For any channels that have been pre-initialized, set them up now */
2612 + for (i=0; i<NUM_AAL5_CHAN; i++)
2613 + {
2614 + if ((HalDev->ChIsSetup[i][0]==TRUE) && (HalDev->ChIsOpen[i][0]==FALSE))
2615 + {
2616 + CHANNEL_INFO HalChn;
2617 + HalChn.Channel = i;
2618 + Ret = ChannelConfigApply(HalDev, &HalChn);
2619 + if (Ret) return (Ret);
2620 + }
2621 + }
2622 +
2623 + /* OAM code would be a candidate to go into ConfigApply */
2624 +
2625 + /* Configure OAM Timer State Block */
2626 + OamRateConfig(HalDev); /* +GSG 030416 */
2627 +
2628 + /* Setup OAM Configuration Block */
2629 + for (i=0; i<8; i++) /* ~GSG 030603 4->8 */
2630 + {
2631 + if (i < 4)
2632 + *(pOAM_CONFIG_BLOCK_WORD_0(SarBase) + i) = HalDev->DeviceCPID[i];
2633 + else
2634 + *(pOAM_CONFIG_BLOCK_WORD_0(SarBase) + i) = HalDev->LBSourceLLID[i-4];
2635 + }
2636 +
2637 + /* Setup OAM Padding Block */
2638 + for (i=0; i<12; i++)
2639 + {
2640 + *(pOAM_PADDING_BLOCK_WORD_0(SarBase) + i) = ((i==11)?0x6a6a0000:0x6a6a6a6a);
2641 + }
2642 +
2643 + /* Enable Tx CPPI DMA */
2644 + TX_CPPI_CTL_REG(HalDev->dev_base) = 1;
2645 +
2646 + /* Enable Rx CPPI DMA */
2647 + RX_CPPI_CTL_REG(HalDev->dev_base) = 1;
2648 +
2649 + /* +GSG 030306 */
2650 + /* Fix for PITS 103 */
2651 + /* Enable Host Interrupt for GPR 2 (OAM LB result register) */
2652 + SAR_HOST_INT_EN_SET_REG(HalDev->dev_base) |= 0x04000000;
2653 +
2654 + /* +GSG 030304 to fix PITS 99 (if block is new)*/
2655 + if (HalDev->StrictPriority == 1)
2656 + {
2657 +#ifdef __CPHAL_DEBUG
2658 + if (DBG(1))
2659 + {
2660 + dbgPrintf("[aal5->os]IsrRegister(OsDev:%08x, halIsr:%08x, Interrupt:%d)\n",
2661 + (bit32u)HalDev->OsDev, (bit32u)DeviceIntAlt, HalDev->interrupt);
2662 + osfuncSioFlush();
2663 + }
2664 +#endif
2665 +
2666 + /* "register" the interrupt handler */
2667 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, DeviceIntAlt, HalDev->interrupt);
2668 + }
2669 + else /* +GSG 030306 */
2670 + { /* +GSG 030306 */
2671 +#ifdef __CPHAL_DEBUG
2672 + if (DBG(1))
2673 + {
2674 + dbgPrintf("[aal5->os]IsrRegister(OsDev:%08x, halIsr:%08x, Interrupt:%d)\n",
2675 + (bit32u)HalDev->OsDev, (bit32u)DeviceInt, HalDev->interrupt);
2676 + osfuncSioFlush();
2677 + }
2678 +#endif
2679 +
2680 + /* "register" the interrupt handler */
2681 + HalDev->OsFunc->IsrRegister(HalDev->OsDev, DeviceInt, HalDev->interrupt);
2682 + } /* +GSG 030306 */
2683 +
2684 + return(EC_NO_ERRORS);
2685 + }
2686 +
2687 +/**
2688 + * @ingroup CPHAL_Functions
2689 + * Called to retrigger the interrupt mechanism after packets have been
2690 + * processed. Call this function when the HalISR function indicates that
2691 + * there is no more work to do. Proper use of this function will guarantee
2692 + * that interrupts are never missed.
2693 + *
2694 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2695 + *
2696 + * @return EC_NO_ERRORS (ok). <BR>
2697 + */
2698 +static int halPacketProcessEnd(HAL_DEVICE *HalDev)
2699 + {
2700 +#ifdef __CPHAL_DEBUG
2701 + if (DBG(0))
2702 + {
2703 + dbgPrintf("[aal5]halPacketProcessEnd(HalDev:%08x)\n", (bit32u)HalDev);
2704 + osfuncSioFlush();
2705 + }
2706 +#endif
2707 +
2708 + SAR_EOI(HalDev->dev_base) = 0;
2709 + return (EC_NO_ERRORS);
2710 + }
2711 +
2712 +/**
2713 + * @ingroup CPHAL_Functions
2714 + * This function probes for the instance of the CPHAL module. It will call
2715 + * the OS function @c DeviceFindInfo() to get the information required.
2716 + *
2717 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2718 + *
2719 + * @return EC_NO_ERRORS (ok). <BR>
2720 + * Possible Error Codes:<BR>
2721 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2722 + * @ref EC_VAL_DEVICE_NOT_FOUND "EC_VAL_DEVICE_NOT_FOUND"<BR>
2723 + */
2724 +static int halProbe(HAL_DEVICE *HalDev)
2725 + {
2726 + int Ret;
2727 +
2728 +#ifdef __CPHAL_DEBUG
2729 + if (DBG(0))
2730 + {
2731 + dbgPrintf("[aal5]halProbe(HalDev:%08x)\n", (bit32u)HalDev);
2732 + osfuncSioFlush();
2733 + }
2734 +#endif
2735 +
2736 + /* Verify hardware state is "enConnected */
2737 + if (HalDev->State != enConnected)
2738 + return (EC_AAL5|EC_FUNC_PROBE|EC_VAL_INVALID_STATE);
2739 +
2740 +#ifdef __CPHAL_DEBUG
2741 + if (DBG(1))
2742 + {
2743 + dbgPrintf("[aal5->os]DeviceFindInfo(Inst:%d, DeviceName:%s, DeviceInfo:%08x)\n",
2744 + HalDev->Inst, "aal5", (bit32u)&HalDev->DeviceInfo);
2745 + osfuncSioFlush();
2746 + }
2747 +#endif
2748 +
2749 + /* Attempt to find the device information */
2750 + Ret = HalDev->OsFunc->DeviceFindInfo(HalDev->Inst, "aal5", &HalDev->DeviceInfo);
2751 + if (Ret)
2752 + return(EC_AAL5|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND);
2753 +
2754 + /* Call Probe for supporting CPSAR layer */
2755 + Ret = HalDev->SarFunc->Probe(HalDev->SarDev);
2756 + if (Ret)
2757 + return(Ret);
2758 +
2759 + /* Set device state to DevFound */
2760 + HalDev->State = enDevFound;
2761 +
2762 + return(EC_NO_ERRORS);
2763 + }
2764 +
2765 +/**
2766 + * @ingroup CPHAL_Functions
2767 + * This function shuts down the CPHAL module completely. The caller must call
2768 + * Close() to put the device in reset prior shutting down. This call will free
2769 + * the HalDev and the HAL function pointer structure, effectively ending
2770 + * communications between the driver and the CPHAL. Further use of the module
2771 + * must be initiated by a call to xxxInitModule(), which starts the entire process
2772 + * over again.
2773 + *
2774 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2775 + *
2776 + * @return EC_NO_ERRORS (ok). <BR>
2777 + * Possible Error Codes:<BR>
2778 + * Any error code from halClose().<BR>
2779 + */
2780 +static int halShutdown(HAL_DEVICE *HalDev)
2781 + {
2782 + int Ch, Queue; /*GSG+030514*/
2783 +
2784 +#ifdef __CPHAL_DEBUG
2785 + if (DBG(0))
2786 + {
2787 + dbgPrintf("[aal5]halShutdown(HalDev:%08x)\n", (bit32u)HalDev);
2788 + osfuncSioFlush();
2789 + }
2790 +#endif
2791 +
2792 + /* Verify proper device state */
2793 + if (HalDev->State == enOpened)
2794 + halClose(HalDev, 3); /*GSG+030429*/
2795 +
2796 + /* Buffer/descriptor resources may still need to be freed if a Close
2797 + Mode 1 was performed prior to Shutdown - clean up here */ /*GSG+030514*/
2798 + for (Ch=0; Ch<NUM_AAL5_CHAN; Ch++)
2799 + {
2800 + if (HalDev->RcbStart[Ch] != 0)
2801 + FreeRx(HalDev,Ch);
2802 +
2803 + for(Queue=0; Queue<MAX_QUEUE; Queue++)
2804 + {
2805 + if (HalDev->TcbStart[Ch][Queue] != 0)
2806 + FreeTx(HalDev,Ch,Queue);
2807 + }
2808 + }
2809 +
2810 + /* shutdown the CPSAR layer */
2811 + HalDev->SarFunc->Shutdown(HalDev->SarDev);
2812 +
2813 +#ifdef __CPHAL_DEBUG
2814 + if (DBG(6))
2815 + {
2816 + dbgPrintf(" [aal5 halShutdown()]Free AAL5 function pointers\n");
2817 + osfuncSioFlush();
2818 + }
2819 + if (DBG(1)||DBG(3))
2820 + {
2821 + dbgPrintf("[aal5->os]Free(MemPtr:%08x)\n", (bit32u)HalDev->HalFuncPtr);
2822 + osfuncSioFlush();
2823 + }
2824 +#endif
2825 + /* free the HalFunc */
2826 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
2827 +
2828 +#ifdef __CPHAL_DEBUG
2829 + if (DBG(6))
2830 + {
2831 + dbgPrintf(" [aal5 halShutdown]Free HalDev\n");
2832 + osfuncSioFlush();
2833 + }
2834 + if (DBG(1)||DBG(3))
2835 + {
2836 + dbgPrintf("[aal5->os]Free(MemPtr:%08x)\n", (bit32u)HalDev);
2837 + osfuncSioFlush();
2838 + }
2839 +#endif
2840 + /* free the HAL device */
2841 + HalDev->OsFunc->FreeDev(HalDev);
2842 +
2843 + return(EC_NO_ERRORS);
2844 + }
2845 +
2846 +/**
2847 + * @ingroup CPHAL_Functions
2848 + * Used to perform regular checks on the device. This function should be
2849 + * called at a regular interval specified by the @c Tick parameter.
2850 + *
2851 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
2852 + *
2853 + * @return EC_NO_ERRORS (ok).<BR>
2854 + * Possible Error Codes:<BR>
2855 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
2856 + */
2857 +static int halTick(HAL_DEVICE *HalDev)
2858 + {
2859 +#ifdef __CPHAL_DEBUG
2860 + if (DBG(0))
2861 + {
2862 + dbgPrintf("[aal5]halTick(HalDev:%08x)\n", (bit32u)HalDev);
2863 + osfuncSioFlush();
2864 + }
2865 +#endif
2866 +
2867 + if (HalDev->State != enOpened)
2868 + return(EC_AAL5|EC_FUNC_TICK|EC_VAL_INVALID_STATE);
2869 +
2870 + return(EC_NO_ERRORS);
2871 + }
2872 +
2873 +/**
2874 + * @ingroup CPHAL_Functions
2875 + *
2876 + * This function will:
2877 + * -# allocate a HalDev that will be used by the OS for future communications with the device
2878 + * -# save OsDev for use when calling OS functions
2879 + * -# allocate and populate HalFunc with the addresses of CPHAL functions.
2880 + * -# check OsFuncSize to see if it meets the minimum requirement.
2881 + * -# return the size of the HAL_FUNCTIONS structure through the HalFuncSize pointer. The OS
2882 + * should check this value to ensure that the HAL meets its minimum requirement.
2883 + *
2884 + * Version checking between the OS and the CPHAL is done using the OsFuncSize and
2885 + * HalFuncSize. Future versions of the CPHAL may add new functions to either
2886 + * HAL_FUNCTIONS or OS_FUNCTIONS, but will never remove functionality. This enables
2887 + * both the HAL and OS to check the size of the function structure to ensure that
2888 + * the current OS and CPHAL are compatible.
2889 + *
2890 + * Note: This is the only function exported by a CPHAL module.
2891 + *
2892 + * Please refer to the section "@ref hal_init" for example code.
2893 + *
2894 + * @param HalDev Pointer to pointer to CPHAL module information. This will
2895 + * be used by the OS when communicating to this module via
2896 + * CPHAL. Allocated during the call.
2897 + * @param OsDev Pointer to OS device information. This will be saved by
2898 + * the CPHAL and returned to the OS when required.
2899 + * @param HalFunc Pointer to pointer to structure containing function pointers for all CPHAL
2900 + * interfaces. Allocated during the call.
2901 + * @param OsFunc Pointer to structure containing function pointers for all OS
2902 + * provided interfaces. Must be allocated by OS prior to call.
2903 + * @param OsFuncSize Size of OS_FUNCTIONS structure.
2904 + * @param HalFuncSize Pointer to the size of the HAL_FUNCTIONS structure.
2905 + * @param Inst The instance number of the module to initialize. (start at
2906 + * 0).
2907 + *
2908 + * @return EC_NO_ERRORS (ok). <BR>
2909 + * Possible Error Codes:<BR>
2910 + * @ref EC_VAL_OS_VERSION_NOT_SUPPORTED "EC_VAL_OS_VERSION_NOT_SUPPORTED"<BR>
2911 + * @ref EC_VAL_MALLOC_DEV_FAILED "EC_VAL_MALLOC_DEV_FAILED"<BR>
2912 + * @ref EC_VAL_MALLOC_FAILED "EC_VAL_MALLOC_FAILED"<BR>
2913 + */
2914 +int xxxInitModule(HAL_DEVICE **HalDev,
2915 + OS_DEVICE *OsDev,
2916 + HAL_FUNCTIONS **HalFunc,
2917 + OS_FUNCTIONS *OsFunc,
2918 + int OsFuncSize,
2919 + int *HalFuncSize,
2920 + int Inst);
2921 +
2922 +int cpaal5InitModule(HAL_DEVICE **HalDev,
2923 + OS_DEVICE *OsDev,
2924 + HAL_FUNCTIONS **HalFunc,
2925 + OS_FUNCTIONS *OsFunc,
2926 + int OsFuncSize,
2927 + int *HalFuncSize,
2928 + int Inst)
2929 + {
2930 + int rc, SarFuncSize;
2931 + HAL_DEVICE *HalPtr;
2932 + HAL_FUNCTIONS *HalFuncPtr;
2933 +
2934 + /* NEW CODE */
2935 + if (OsFuncSize < sizeof(OS_FUNCTIONS))
2936 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_OS_VERSION_NOT_SUPPORTED);
2937 +
2938 + HalPtr = (HAL_DEVICE *) OsFunc->MallocDev(sizeof(HAL_DEVICE));
2939 + if (!HalPtr)
2940 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
2941 +
2942 + HalFuncPtr = (HAL_FUNCTIONS *) OsFunc->Malloc(sizeof(HAL_FUNCTIONS));
2943 + if (!HalFuncPtr)
2944 + return (EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
2945 +
2946 + /* Initialize the size of hal functions */
2947 + *HalFuncSize = sizeof (HAL_FUNCTIONS);
2948 +
2949 + /* clear the device structure */
2950 + OsFunc->Memset(HalPtr, 0, sizeof(HAL_DEVICE));
2951 +
2952 + /* clear the function pointers */
2953 + OsFunc->Memset(HalFuncPtr, 0, sizeof(HAL_FUNCTIONS));
2954 +
2955 + /* initialize the HAL_DEVICE structure */
2956 + HalPtr->OsDev = OsDev;
2957 + /*HalPtr->OsOpen = OsDev;*/
2958 + HalPtr->Inst = Inst;
2959 + HalPtr->OsFunc = OsFunc;
2960 +
2961 + /* Supply pointers for the CPHAL API functions */
2962 + HalFuncPtr->RxReturn = halRxReturn;
2963 + HalFuncPtr->Init = halInit;
2964 + HalFuncPtr->Close = halClose;
2965 + HalFuncPtr->Send = halSend;
2966 + HalFuncPtr->ChannelSetup = halChannelSetup;
2967 + HalFuncPtr->ChannelTeardown = halChannelTeardown;
2968 + HalFuncPtr->Open = halOpen;
2969 + HalFuncPtr->Kick = halKick;
2970 + HalFuncPtr->RegAccess = halRegAccess;
2971 + HalFuncPtr->Probe = halProbe;
2972 + HalFuncPtr->Control = halControl;
2973 + HalFuncPtr->Tick = halTick;
2974 + HalFuncPtr->Shutdown = halShutdown;
2975 + HalFuncPtr->OamFuncConfig = halOamFuncConfig; /* +GSG 030306 */
2976 + HalFuncPtr->OamLoopbackConfig = halOamLoopbackConfig; /* ~GSG 030416 */
2977 +
2978 + /* Temporary */
2979 + /*HalFuncPtr->StatsGetOld = StatsGet;*/
2980 + HalFuncPtr->PacketProcessEnd = halPacketProcessEnd;
2981 +
2982 + /* Now, AAL5 must connect to the CPSAR layer */
2983 +
2984 + /* Attach to SAR HAL Functions */
2985 + /*
2986 + cpsarInitModule(NULL, NULL, 0, NULL, &SarFuncSize, Inst);
2987 +
2988 + if (SarFuncSize!=sizeof(CPSAR_FUNCTIONS))
2989 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_CPSAR_VERSION_NOT_SUPPORTED);
2990 +
2991 + HalPtr->SarFunc = (CPSAR_FUNCTIONS *) OsFunc->Malloc(SarFuncSize);
2992 + */
2993 +
2994 + rc = cpsarInitModule(&HalPtr->SarDev, OsDev, &HalPtr->SarFunc, OsFunc, sizeof(OS_FUNCTIONS), &SarFuncSize, Inst);
2995 +
2996 + /* pass back the error value from the CPSAR layer if necessary */
2997 + if (rc)
2998 + return(rc);
2999 +
3000 + /*
3001 + if (!HalPtr->SarDev)
3002 + return(EC_AAL5|EC_FUNC_HAL_INIT|EC_VAL_NULL_CPSAR_DEV);
3003 + */
3004 +
3005 + /* Initialize the hardware state */
3006 + HalPtr->State = enConnected;
3007 +
3008 + /* keep a reference to HalFuncPtr so I can free it later */
3009 + HalPtr->HalFuncPtr = HalFuncPtr;
3010 +
3011 + /* pass the HalPtr back to the caller */
3012 + *HalDev = HalPtr;
3013 + *HalFunc = HalFuncPtr;
3014 +
3015 + return(EC_NO_ERRORS);
3016 + }
3017 diff -urN linux.old/drivers/atm/sangam_atm/aal5sar.h linux.dev/drivers/atm/sangam_atm/aal5sar.h
3018 --- linux.old/drivers/atm/sangam_atm/aal5sar.h 1970-01-01 01:00:00.000000000 +0100
3019 +++ linux.dev/drivers/atm/sangam_atm/aal5sar.h 2005-08-23 04:46:50.080846280 +0200
3020 @@ -0,0 +1,198 @@
3021 +/**@file************************************************************************
3022 + * TNETDxxxx Software Support
3023 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
3024 + *
3025 + * FILE: aal5sar.h
3026 + *
3027 + * DESCRIPTION:
3028 + * This file contains data structure definitions for the AAL5 HAL SAR.
3029 + *
3030 + * HISTORY:
3031 + * 28Feb02 Greg 1.00 Original Version created.
3032 + * 06Mar02 Greg 1.01 Documented structures.
3033 + * 18Jul02 Greg 1.02 Major reorganization
3034 + *
3035 + *****************************************************************************/
3036 +#ifndef _INC_AAL5SAR
3037 +#define _INC_AAL5SAR
3038 +
3039 +/** \namespace AAL5_Version
3040 +This documents version 01.06.06 of the AAL5 CPHAL.
3041 +*/
3042 +const char *pszVersion_CPAAL5="CPAAL5 01.06.06 "__DATE__" "__TIME__;
3043 +
3044 +#include "cpsar_cpaal5.h"
3045 +
3046 +#define NUM_AAL5_CHAN 16
3047 +#define MAX_AAL5_CHAN 15
3048 +#define MAX_QUEUE 2
3049 +#define MAX_DIRECTION 2
3050 +
3051 +#define PKT_TYPE_AAL5 0 /* +GSG 030508 */
3052 +#define PKT_TYPE_NULL 1 /* +GSG 030508 */
3053 +#define PKT_TYPE_OAM 2 /* +GSG 030508 */
3054 +#define PKT_TYPE_TRANS 3 /* +GSG 030508 */
3055 +#define ATM_HEADER_SIZE 4 /* +GSG 030508 */
3056 +
3057 +/*
3058 + * HAL Default Parameter Values
3059 + */
3060 +#define CFG_TX_NUM_BUFS {256,256,256,256,256,256,256,256, 256,256,256,256,256,256,256,256}
3061 +#define CFG_RX_NUM_BUFS {256,256,256,256,256,256,256,256, 256,256,256,256,256,256,256,256}
3062 +#define CFG_RX_BUF_SIZE {1518,1518,1518,1518,1518,1518,1518,1518, 1518,1518,1518,1518,1518,1518,1518,1518}
3063 +#define CFG_RX_BUF_OFFSET {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3064 +#define CFG_TX_NUM_QUEUES {1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1}
3065 +#define CFG_CPCS_UU {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3066 +#define CFG_DA_MASK {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3067 +#define CFG_PRIORITY {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3068 +#define CFG_PKT_TYPE {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3069 +#define CFG_VCI {100,101,102,103,104,105,106,107, 108,109,110,111,112,113,114,115}
3070 +#define CFG_VPI {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3071 +#define CFG_CELL_RATE {0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4, 0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4,0x30d4}
3072 +#define CFG_QOS_TYPE {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3073 +#define CFG_MBS {8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8}
3074 +#define CFG_PCR {1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1}
3075 +#define CFG_GFC {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3076 +#define CFG_CLP {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3077 +#define CFG_PTI {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0}
3078 +#define CFG_RX_MAX_SERVICE {170,170,170,170,170,170,170,170, 170,170,170,170,170,170,170,170}
3079 +#define CFG_TX_MAX_SERVICE {170,170,170,170,170,170,170,170, 170,170,170,170,170,170,170,170}
3080 +
3081 +static int cfg_tx_num_bufs[NUM_AAL5_CHAN] = CFG_TX_NUM_BUFS;
3082 +static int cfg_rx_num_bufs[NUM_AAL5_CHAN] = CFG_RX_NUM_BUFS;
3083 +static int cfg_rx_buf_size[NUM_AAL5_CHAN] = CFG_RX_BUF_SIZE;
3084 +static int cfg_rx_buf_offset[NUM_AAL5_CHAN] = CFG_RX_BUF_OFFSET;
3085 +static int cfg_tx_num_queues[NUM_AAL5_CHAN] = CFG_TX_NUM_QUEUES;
3086 +static bit32u cfg_cpcs_uu[NUM_AAL5_CHAN] = CFG_CPCS_UU;
3087 +static int cfg_da_mask[NUM_AAL5_CHAN] = CFG_DA_MASK;
3088 +static int cfg_priority[NUM_AAL5_CHAN] = CFG_PRIORITY;
3089 +static int cfg_pkt_type[NUM_AAL5_CHAN] = CFG_PKT_TYPE;
3090 +static int cfg_vci[NUM_AAL5_CHAN] = CFG_VCI;
3091 +static int cfg_vpi[NUM_AAL5_CHAN] = CFG_VPI;
3092 +static bit32u cfg_cell_rate[NUM_AAL5_CHAN] = CFG_CELL_RATE;
3093 +static int cfg_qos_type[NUM_AAL5_CHAN] = CFG_QOS_TYPE;
3094 +static int cfg_mbs[NUM_AAL5_CHAN] = CFG_MBS;
3095 +static int cfg_pcr[NUM_AAL5_CHAN] = CFG_PCR;
3096 +static int cfg_gfc[NUM_AAL5_CHAN] = CFG_GFC;
3097 +static int cfg_clp[NUM_AAL5_CHAN] = CFG_CLP;
3098 +static int cfg_pti[NUM_AAL5_CHAN] = CFG_PTI;
3099 +static int cfg_rx_max_service[NUM_AAL5_CHAN]= CFG_RX_MAX_SERVICE;
3100 +static int cfg_tx_max_service[NUM_AAL5_CHAN]= CFG_TX_MAX_SERVICE;
3101 +static char *channel_names[] = CHANNEL_NAMES;
3102 +
3103 +/*
3104 + * The HAL_FUNCTIONS struct defines the function pointers for all HAL functions
3105 + * accessible to upper layer software. It is populated by calling
3106 + * halInitModules().
3107 + *
3108 + * Note that this list is still under definition.
3109 + */
3110 +
3111 +/*
3112 + * This is the data structure for a transmit buffer descriptor. The first
3113 + * four 32-bit words of the BD represent the CPPI 3.0 defined buffer descriptor
3114 + * words. The other words are SAR/HAL implementation specific.
3115 + */
3116 +typedef struct
3117 + {
3118 + bit32 HNext; /**< Hardware's pointer to next buffer descriptor */
3119 + bit32 BufPtr; /**< Pointer to the data buffer */
3120 + bit32 Off_BLen; /**< Contains buffer offset and buffer length */
3121 + bit32 mode; /**< SOP, EOP, Ownership, EOQ, Teardown Complete bits */
3122 + bit32 AtmHeader; /**< Atm Header to be used for each fragment */
3123 + bit32 Word5; /**< General control information for the packet */
3124 + bit32 Res6;
3125 + bit32 Res7;
3126 + void *Next;
3127 + void *OsInfo;
3128 +#ifdef __CPHAL_DEBUG
3129 + bit32 DbgSop;
3130 + bit32 DbgData;
3131 + bit32 DbgFraglist;
3132 +#endif
3133 + void *Eop;
3134 + }HAL_TCB;
3135 +
3136 +/*
3137 + * This is the data structure for a receive buffer descriptor. The first
3138 + * six 32-bit words of the BD represent the CPPI 3.0 defined buffer descriptor
3139 + * words. The other words are HAL implementation specific.
3140 + */
3141 +typedef volatile struct hal_private
3142 + {
3143 + bit32 HNext; /**< Hardware's pointer to next buffer descriptor */
3144 + bit32 BufPtr; /**< Pointer to the data buffer */
3145 + bit32 Off_BLen; /**< Contains buffer offset and buffer length */
3146 + bit32 mode; /**< SOP, EOP, Ownership, EOQ, Teardown, Q Starv, Length */
3147 + bit32 AtmHeader;
3148 + bit32 UuCpi;
3149 + bit32 Res6;
3150 + bit32 Res7;
3151 + void *DatPtr;
3152 + void *Next;
3153 + void *OsInfo;
3154 + void *Eop;
3155 + bit32 FragCount;
3156 + bit32 Ch;
3157 + HAL_DEVICE *HalDev;
3158 + }HAL_RCB;
3159 +
3160 +
3161 +#define MAX_NEEDS 512 /*MJH+030409*/
3162 +/*
3163 + * This is the data structure for a generic HAL device. It contains all device
3164 + * specific data for a single instance of that device. This includes Rx/Tx
3165 + * buffer queues, device base address, reset bit, and other information.
3166 + */
3167 +typedef struct hal_device
3168 + {
3169 + HAL_RCB *RcbPool[NUM_AAL5_CHAN];
3170 + bit32u rxbufseq;
3171 + bit32 RxActQueueCount[NUM_AAL5_CHAN];
3172 + HAL_RCB *RxActQueueHead[NUM_AAL5_CHAN];
3173 + HAL_RCB *RxActQueueTail[NUM_AAL5_CHAN];
3174 + bit32 RxActive[NUM_AAL5_CHAN];
3175 + bit32 dev_base;
3176 + HAL_TCB *TcbPool[NUM_AAL5_CHAN][MAX_QUEUE];
3177 + bit32 offset;
3178 + bit32 TxActQueueCount[NUM_AAL5_CHAN][MAX_QUEUE];
3179 + HAL_TCB *TxActQueueHead[NUM_AAL5_CHAN][MAX_QUEUE];
3180 + HAL_TCB *TxActQueueTail[NUM_AAL5_CHAN][MAX_QUEUE];
3181 + bit32 TxActive[NUM_AAL5_CHAN][MAX_QUEUE];
3182 + bit32 TxTeardownPending[NUM_AAL5_CHAN];
3183 + bit32 RxTeardownPending[NUM_AAL5_CHAN];
3184 + bit32 ChIsOpen[NUM_AAL5_CHAN][MAX_DIRECTION];
3185 + bit32 ChIsSetup[NUM_AAL5_CHAN][MAX_DIRECTION];
3186 + bit32 interrupt;
3187 + bit32 debug;
3188 + OS_DEVICE *OsDev;
3189 + OS_FUNCTIONS *OsFunc;
3190 + CPSAR_FUNCTIONS *SarFunc;
3191 + CPSAR_DEVICE *SarDev;
3192 + /*void *OsOpen;*/
3193 + /*FRAGLIST fraglist[MAX_FRAG];*/
3194 + FRAGLIST *fraglist;
3195 + char *TcbStart[NUM_AAL5_CHAN][MAX_QUEUE];
3196 + char *RcbStart[NUM_AAL5_CHAN];
3197 + /*bit32 RcbSize[NUM_AAL5_CHAN];*/
3198 + bit32 InRxInt[NUM_AAL5_CHAN];
3199 + STAT_INFO Stats;
3200 + bit32 Inst;
3201 + bit32u DeviceCPID[4];
3202 + bit32u LBSourceLLID[4];
3203 + CHANNEL_INFO ChData[NUM_AAL5_CHAN];
3204 + DEVICE_STATE State;
3205 + char *DeviceInfo;
3206 + HAL_FUNCTIONS *HalFuncPtr;
3207 + int NextRxCh;
3208 + int NextTxCh[2];
3209 + int StrictPriority; /* +GSG 030304 */
3210 + bit32u NeedsCount; /*MJH+030409*/
3211 + HAL_RECEIVEINFO *Needs[MAX_NEEDS]; /*MJH+030409*/
3212 + bit32u SarFrequency; /* +GSG 030416 */
3213 + int MaxFrags;
3214 + bit32u TurboDslErrors;
3215 + bit32u OamLbTimeout;
3216 + }HALDEVICE;
3217 +
3218 +#endif
3219 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.c linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.c
3220 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
3221 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.c 2005-08-23 04:46:50.081846128 +0200
3222 @@ -0,0 +1,728 @@
3223 +#ifndef _INC_CPCOMMON_C
3224 +#define _INC_CPCOMMON_C
3225 +
3226 +#ifdef _CPHAL_CPMAC
3227 +#include "cpremap_cpmac.c"
3228 +#endif
3229 +
3230 +#ifdef _CPHAL_AAL5
3231 +#include "cpremap_cpaal5.c"
3232 +#endif
3233 +
3234 +#ifdef _CPHAL_CPSAR
3235 +#include "cpremap_cpsar.c"
3236 +#endif
3237 +
3238 +#ifdef _CPHAL_AAL2
3239 +#include "cpremap_cpaal2.c"
3240 +#endif
3241 +
3242 +/**
3243 +@defgroup Common_Config_Params Common Configuration Parameters
3244 +
3245 +This section documents the configuration parameters that are valid across
3246 +all CPHAL devices.
3247 +@{
3248 +*/
3249 +/** This is the debug level. The field is bit defined, such that the user
3250 +should set to 1 all the bits corresponding to desired debug outputs. The following
3251 +are the meanings for each debug bit:
3252 +- bit0 (LSB): CPHAL Function Trace
3253 +- b1 : OS Function call trace
3254 +- b2 : Critical section entry/exit
3255 +- b3 : Memory allocation/destruction
3256 +- b4 : Detailed information in Rx path
3257 +- b5 : Detailed information in Tx path
3258 +- b6 : Extended error information
3259 +- b7 : General info
3260 +*/
3261 +static const char pszDebug[] = "debug";
3262 +/** CPU Frequency. */
3263 +/*static const char pszCpuFreq[] = "CpuFreq";*/ /*MJH-030403*/
3264 +/** Base address for the module. */
3265 +static const char pszBase[] = "base";
3266 +/** Reset bit for the module. */
3267 +static const char pszResetBit[] = "reset_bit";
3268 +/** Reset base address for the module. */
3269 +static const char pszResetBase[] = "ResetBase";
3270 +/** Interrupt line for the module. */
3271 +static const char pszIntLine[] = "int_line";
3272 +/** VLYNQ offset for the module. Disregard if not using VLYNQ. */
3273 +static const char pszOffset[] = "offset";
3274 +/** The OS may "Get" this parameter, which is a pointer
3275 + to a character string that indicates the version of CPHAL. */
3276 +static const char pszVer[] = "Version";
3277 +/*@}*/
3278 +
3279 +/**
3280 +@defgroup Common_Control_Params Common Keys for [os]Control()
3281 +
3282 +This section documents the keys used with the OS @c Control() interface that
3283 +are required by CPHAL devices.
3284 +
3285 +@{
3286 +*/
3287 +/** Used to wait for an integer number of clock ticks, given as an integer
3288 + pointer in the @p Value parameter. No actions are defined. */
3289 +static const char pszSleep[] = "Sleep";
3290 +/** Requests the OS to flush it's IO buffers. No actions are defined. */
3291 +static const char pszSioFlush[] = "SioFlush";
3292 +/*@}*/
3293 +
3294 +static const char pszStateChange[] = "StateChange";
3295 +static const char pszStatus[] = "Status";
3296 +
3297 +static const char pszGET[] = "Get";
3298 +static const char pszSET[] = "Set";
3299 +static const char pszCLEAR[] = "Clear";
3300 +static const char pszNULL[] = "";
3301 +static const char pszLocator[] = "Locator";
3302 +static const char pszOff[] = "Off";
3303 +static const char pszOn[] = "On";
3304 +static const char hcMaxFrags[] = "MaxFrags";
3305 +
3306 +#ifdef _CPHAL_CPMAC
3307 +
3308 +/* New method for string constants */
3309 +const char hcClear[] = "Clear";
3310 +const char hcGet[] = "Get";
3311 +const char hcSet[] = "Set";
3312 +
3313 +const char hcTick[] = "Tick";
3314 +
3315 +static const CONTROL_KEY KeyCommon[] =
3316 + {
3317 + {"" , enCommonStart},
3318 + {pszStatus , enStatus},
3319 + {pszOff , enOff},
3320 + {pszOn , enOn},
3321 + {pszDebug , enDebug},
3322 + {hcCpuFrequency , enCpuFreq}, /*MJH~030403*/
3323 + {"" , enCommonEnd}
3324 + };
3325 +#endif
3326 +
3327 +/**
3328 +@defgroup Common_Statistics Statistics
3329 +
3330 +A broad array of module statistics is available. Statistics values are accessed
3331 +through the @c Control() interface of the CPHAL. There are 5 different levels
3332 +of statistics, each of which correspond to a unique set of data. Furthermore,
3333 +certain statistics data is indexed by using a channel number and Tx queue number.
3334 +The following is a brief description of each statistics level, along with the
3335 +indexes used for the level:
3336 +
3337 +- Level 0: Hardware Statistics (index with channel)
3338 +- Level 1: CPHAL Software Statistics (channel, queue)
3339 +- Level 2: CPHAL Flags (channel, queue)
3340 +- Level 3: CPHAL Channel Configuration (channel)
3341 +- Level 4: CPHAL General Configuration (no index)
3342 +
3343 +The caller requests statistics information by providing a Key string to the
3344 +@c Control() API in the following format: "Stats;[Level #];[Ch #];[Queue #]".
3345 +The only valid Action parameter for statistics usage is "Get".
3346 +
3347 +Code Examples:
3348 +@code
3349 +unsigned int *StatsData;
3350 +
3351 +# Get Level 0 stats for Channel 1
3352 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
3353 +
3354 +# Get Level 2 stats for Channel 0, Queue 0
3355 +HalFunc->Control(OsDev->HalDev, "Stats;2;0;0", "Get", &StatsData);
3356 +
3357 +# Get Level 4 stats
3358 +HalFunc->Control(OsDev->HalDev, "Stats;4", "Get", &StatsData);
3359 +@endcode
3360 +
3361 +The information returned in the Value parameter of @c Control() is an
3362 +array of pointers to strings. The pointers are arranged in pairs.
3363 +The first pointer is a pointer to a name string for a particular statistic.
3364 +The next pointer is a pointer to a string containing the representation of
3365 +the integer statistic value corresponding to the first pointer. This is followed
3366 +by another pair of pointers, and so on, until a NULL pointer is encountered. The
3367 +following is example code for processing the statistics data. Note that the OS
3368 +is responsible for freeing the memory passed back through the Value parameter of
3369 +@c Control().
3370 +
3371 +@code
3372 +unsigned int *StatsData;
3373 +
3374 +# Get Level 0 stats for Channel 1
3375 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
3376 +
3377 +# output Statistics data
3378 +PrintStats(StatsData);
3379 +
3380 +# the upper layer is responsible for freeing stats info
3381 +free(&StatsPtr);
3382 +
3383 +...
3384 +
3385 +void PrintStats(unsigned int *StatsPtr)
3386 + {
3387 + while(*StatsPtr)
3388 + {
3389 + printf("%20s:", (char *)*StatsPtr);
3390 + StatsPtr++;
3391 + printf("%11s\n", (char *)*StatsPtr);
3392 + StatsPtr++;
3393 + }
3394 + MySioFlush();
3395 + }
3396 +@endcode
3397 +
3398 +Within each statistics level, there are several statistics defined. The statistics that
3399 +are common to every CPPI module are listed below. In addition, each module may define
3400 +extra statistics in each level, which will be documented within the module-specific
3401 +documentation appendices.
3402 +
3403 +- Level 0 Statistics
3404 + - All level 0 statistics are module-specific.
3405 +- Level 1 Statistics (CPHAL Software Statistics)
3406 + - DmaLenErrors: Incremented when the port DMA's more data than expected (per channel). (AAL5 Only)
3407 + - TxMisQCnt: Incremented when host queues a packet for transmission as the port finishes
3408 +transmitting the previous last packet in the queue (per channel and queue).
3409 + - RxMisQCnt: Incremented when host queues adds buffers to a queue as the port finished the
3410 +reception of the previous last packet in the queue (per channel).
3411 + - TxEOQCnt: Number of times the port has reached the end of the transmit queue (per channel and queue).
3412 + - RxEOQCnt: Number of times the port has reached the end of the receive queue (per channel).
3413 + - RxPacketsServiced: Number of received packets (per channel).
3414 + - TxPacketsServiced: Number of transmitted packets (per channel and queue).
3415 + - RxMaxServiced: Maximum number of packets that the CPHAL receive interrupt has serviced at a time (per channel).
3416 + - TxMaxServiced: Maximum number of packets that the CPHAL transmit interrupt has serviced at a time (per channel and queue).
3417 + - RxTotal: Total number of received packets, all channels.
3418 + - TxTotal: Total number of transmitted packets, all channels and queues.
3419 +- Level 2 Statistics (CPHAL Flags)
3420 + - RcbPool: Pointer to receive descriptor pool (per channel).
3421 + - RxActQueueCount: Number of buffers currently available for receive (per channel).
3422 + - RxActQueueHead: Pointer to first buffer in receive queue (per channel).
3423 + - RxActQueueTail: Pointer to last buffer in receive queue (per channel).
3424 + - RxActive: 0 if inactive (no buffers available), or 1 if active (buffers available).
3425 + - RcbStart: Pointer to block of receive descriptors.
3426 + - RxTeardownPending: 1 if Rx teardown is pending but incomplete, 0 otherwise.
3427 + - TcbPool: Pointer to transmit descriptor pool (per channel and queue).
3428 + - TxActQueueCount: Number of buffers currently queued to be transmitted (per channel and queue).
3429 + - TxActQueueHead: Pointer to first buffer in transmit queue (per channel and queue).
3430 + - TxActQueueTail: Pointer to last buffer in transmit queue (per channel and queue).
3431 + - TxActive: 0 if inactive (no buffers to send), or 1 if active (buffers queued to send).
3432 + - TcbStart: Pointer to block of transmit descriptors.
3433 + - TxTeardownPending: 1 if Tx teardown is pending but incomplete, 0 otherwise.
3434 +- Level 3 Statistics (CPHAL Channel Configuration)
3435 + - RxBufSize: Rx buffer size.
3436 + - RxBufferOffset: Rx buffer offset.
3437 + - RxNumBuffers: Number of Rx buffers.
3438 + - RxServiceMax: Maximum number of receive packets to service at a time.
3439 + - TxNumBuffers: Number of Tx buffer descriptors.
3440 + - TxNumQueues: Number of Tx queues to use.
3441 + - TxServiceMax: Maximum number of transmit packets to service at a time.
3442 +- Level 4 Statistics (CPHAL General Configuration)
3443 + - Base Address: Base address of the module.
3444 + - Offset (VLYNQ): VLYNQ relative module offset.
3445 + - Interrupt Line: Interrupt number.
3446 + - Debug: Debug flag, 1 to enable debug.
3447 + - Inst: Instance number.
3448 +*/
3449 +
3450 +/*
3451 + Data Type 0 = int display
3452 + Data Type 1 = hex display
3453 + Data Type 2 = channel structure, int display
3454 + Data Type 3 = queue index and int display
3455 + Data Type 4 = queue index and hex display
3456 +*/
3457 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC)) /* +GSG 030307 */
3458 +static STATS_TABLE StatsTable0[] =
3459 + {
3460 +#ifdef _CPHAL_AAL5
3461 + /* Name , Data Ptr, Data Type */
3462 + {"Crc Errors", 0, 0},
3463 + {"Len Errors", 0, 0},
3464 + {"Abort Errors", 0, 0},
3465 + {"Starv Errors", 0, 0}
3466 +#endif
3467 +#ifdef _CPHAL_CPMAC
3468 + {"Rx Good Frames", 0, 0}
3469 +#endif
3470 + };
3471 +
3472 +static STATS_TABLE StatsTable1[] =
3473 + {
3474 + /* Name , Data Ptr, Data Type */
3475 + {"DmaLenErrors", 0, 0},
3476 + {"TxMisQCnt", 0, 3},
3477 + {"RxMisQCnt", 0, 0},
3478 + {"TxEOQCnt", 0, 3},
3479 + {"RxEOQCnt", 0, 0},
3480 + {"RxPacketsServiced", 0, 0},
3481 + {"TxPacketsServiced", 0, 3},
3482 + {"RxMaxServiced", 0, 0},
3483 + {"TxMaxServiced", 0, 3},
3484 + {"RxTotal", 0, 0},
3485 + {"TxTotal", 0, 0},
3486 + };
3487 +
3488 +static STATS_TABLE StatsTable2[] =
3489 + {
3490 + /* Name , Data Ptr, Data Type */
3491 + {"RcbPool", 0, 1},
3492 + {"RxActQueueCount", 0, 0},
3493 + {"RxActQueueHead", 0, 1},
3494 + {"RxActQueueTail", 0, 1},
3495 + {"RxActive", 0, 0},
3496 + {"RcbStart", 0, 1},
3497 + {"RxTeardownPending", 0, 0},
3498 + {"TcbPool", 0, 4},
3499 + {"TxActQueueCount", 0, 3},
3500 + {"TxActQueueHead", 0, 4},
3501 + {"TxActQueueTail", 0, 4},
3502 + {"TxActive", 0, 3},
3503 + {"TcbStart", 0, 4},
3504 + {"TxTeardownPending", 0, 0}
3505 + };
3506 +
3507 +static STATS_TABLE StatsTable3[] =
3508 + {
3509 + /* Name , Data Ptr, Data Type */
3510 + {"RxBufSize", 0, 2},
3511 + {"RxBufferOffset", 0, 2},
3512 + {"RxNumBuffers", 0, 2},
3513 + {"RxServiceMax", 0, 2},
3514 + {"TxNumBuffers", 0, 2},
3515 + {"TxNumQueues", 0, 2},
3516 + {"TxServiceMax", 0, 2},
3517 +#ifdef _CPHAL_AAL5
3518 + {"CpcsUU", 0, 2},
3519 + {"Gfc", 0, 2},
3520 + {"Clp", 0, 2},
3521 + {"Pti", 0, 2},
3522 + {"DaMask", 0, 2},
3523 + {"Priority", 0, 2},
3524 + {"PktType", 0, 2},
3525 + {"Vci", 0, 2},
3526 + {"Vpi", 0, 2},
3527 + {"CellRate", 0, 2},
3528 + {"QosType", 0, 2},
3529 + {"Mbs", 0, 2},
3530 + {"Pcr", 0, 2}
3531 +#endif
3532 + };
3533 +
3534 +static STATS_TABLE StatsTable4[] =
3535 + {
3536 + {"Base Address", 0, 1},
3537 + {"Offset (VLYNQ)", 0, 0},
3538 + {"Interrupt Line", 0, 0},
3539 + {"Debug", 0, 0},
3540 + {"Instance", 0, 0},
3541 +#ifdef _CPHAL_AAL5
3542 + {"UniNni", 0, 0}
3543 +#endif
3544 + };
3545 +
3546 +static STATS_DB StatsDb[] =
3547 + {
3548 + {(sizeof(StatsTable0)/sizeof(STATS_TABLE)), StatsTable0},
3549 + {(sizeof(StatsTable1)/sizeof(STATS_TABLE)), StatsTable1},
3550 + {(sizeof(StatsTable2)/sizeof(STATS_TABLE)), StatsTable2},
3551 + {(sizeof(StatsTable3)/sizeof(STATS_TABLE)), StatsTable3},
3552 + {(sizeof(StatsTable4)/sizeof(STATS_TABLE)), StatsTable4}
3553 + };
3554 +#endif /* +GSG 030307 */
3555 +
3556 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
3557 +static void resetWait(HAL_DEVICE *HalDev)
3558 + { /*+RC3.02*/
3559 + const int TickReset=64;
3560 + osfuncSleep((int*)&TickReset);
3561 + } /*+RC3.02*/
3562 +#endif /* +RC 3.02 */
3563 +
3564 +/* I only define the reset base function for the modules
3565 + that can perform a reset. The AAL5 and AAL2 modules
3566 + do not perform a reset, that is done by the shared module
3567 + CPSAR */
3568 +#if defined(_CPHAL_CPSAR) || defined(_CPHAL_CPMAC) || defined(_CPHAL_VDMAVT)
3569 +/*
3570 + * Determines the reset register address to be used for a particular device.
3571 + * It will search the current device entry for Locator information. If the
3572 + * device is a root device, there will be no Locator information, and the
3573 + * function will find and return the root reset register. If a Locator value
3574 + * is found, the function will search each VLYNQ device entry in the system
3575 + * looking for a matching Locator. Once it finds a VLYNQ device entry with
3576 + * a matching Locator, it will extract the "ResetBase" parameter from that
3577 + * VLYNQ device entry (thus every VLYNQ entry must have the ResetBase parameter).
3578 + *
3579 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
3580 + * @param ResetBase Pointer to integer address of reset register.
3581 + *
3582 + * @return 0 OK, Non-zero not OK
3583 + */
3584 +static int ResetBaseGet(HAL_DEVICE *HalDev, bit32u *ResetBase)
3585 + {
3586 + char *DeviceInfo = HalDev->DeviceInfo;
3587 + char *MyLocator, *NextLocator;
3588 + int Inst=1;
3589 + bit32u error_code;
3590 +
3591 +#ifdef __CPHAL_DEBUG
3592 + if (DBG(0))
3593 + {
3594 + dbgPrintf("[cpcommon]ResetBaseGet(HalDev:%08x, ResetBase:%08x)\n", (bit32u)HalDev, ResetBase);
3595 + osfuncSioFlush();
3596 + }
3597 +#endif
3598 +
3599 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &MyLocator);
3600 + if (error_code)
3601 + {
3602 + /* if no Locator value, device is on the root, so get the "reset" device */
3603 + error_code = HalDev->OsFunc->DeviceFindInfo(0, "reset", &DeviceInfo);
3604 + if (error_code)
3605 + {
3606 + return(EC_VAL_DEVICE_NOT_FOUND);
3607 + }
3608 +
3609 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "base", ResetBase);
3610 + if (error_code)
3611 + {
3612 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
3613 + }
3614 +
3615 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
3616 +
3617 + /* found base address for root device, so we're done */
3618 + return (EC_NO_ERRORS);
3619 + }
3620 + else
3621 + {
3622 + /* we have a Locator value, so the device is remote */
3623 +
3624 + /* Find a vlynq device with a matching locator value */
3625 + while ((HalDev->OsFunc->DeviceFindInfo(Inst, "vlynq", &DeviceInfo)) == EC_NO_ERRORS)
3626 + {
3627 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &NextLocator);
3628 + if (error_code)
3629 + {
3630 + /* no Locator value for this VLYNQ, so move on */
3631 + continue;
3632 + }
3633 + if (HalDev->OsFunc->Strcmpi(MyLocator, NextLocator)==0)
3634 + {
3635 + /* we have found a VLYNQ with a matching Locator, so extract the ResetBase */
3636 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "ResetBase", ResetBase);
3637 + if (error_code)
3638 + {
3639 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
3640 + }
3641 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
3642 +
3643 + /* found base address for root device, so we're done */
3644 + return (EC_NO_ERRORS);
3645 + }
3646 + Inst++;
3647 + } /* while */
3648 + } /* else */
3649 +
3650 + return (EC_NO_ERRORS);
3651 + }
3652 +#endif
3653 +
3654 +#ifndef _CPHAL_AAL2 /* + RC 3.02 */
3655 +static bit32u ConfigGetCommon(HAL_DEVICE *HalDev)
3656 + {
3657 + bit32u ParmValue;
3658 + bit32 error_code;
3659 + char *DeviceInfo = HalDev->DeviceInfo;
3660 +
3661 +#ifdef __CPHAL_DEBUG
3662 + if (DBG(0))
3663 + {
3664 + dbgPrintf("[cpcommon]ConfigGetCommon(HalDev:%08x)\n", (bit32u)HalDev);
3665 + osfuncSioFlush();
3666 + }
3667 +#endif
3668 +
3669 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszBase, &ParmValue);
3670 + if (error_code)
3671 + {
3672 + return(EC_FUNC_HAL_INIT|EC_VAL_BASE_ADDR_NOT_FOUND);
3673 + }
3674 + HalDev->dev_base = ((bit32u)PhysToVirtNoCache(ParmValue));
3675 +
3676 +#ifndef _CPHAL_AAL5
3677 +#ifndef _CPHAL_AAL2
3678 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszResetBit, &ParmValue);
3679 + if(error_code)
3680 + {
3681 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BIT_NOT_FOUND);
3682 + }
3683 + HalDev->ResetBit = ParmValue;
3684 +
3685 + /* Get reset base address */
3686 + error_code = ResetBaseGet(HalDev, &ParmValue);
3687 + if (error_code)
3688 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BASE_NOT_FOUND);
3689 + HalDev->ResetBase = ParmValue;
3690 +#endif
3691 +#endif
3692 +
3693 +#ifndef _CPHAL_CPSAR
3694 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszIntLine,&ParmValue);
3695 + if (error_code)
3696 + {
3697 + return(EC_FUNC_HAL_INIT|EC_VAL_INTERRUPT_NOT_FOUND);
3698 + }
3699 + HalDev->interrupt = ParmValue;
3700 +#endif
3701 +
3702 + /* only look for the offset if there is a Locator field, which indicates that
3703 + the module is a VLYNQ module */
3704 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszLocator,&ParmValue);
3705 + if (!error_code)
3706 + {
3707 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszOffset,&ParmValue);
3708 + if (error_code)
3709 + {
3710 + return(EC_FUNC_HAL_INIT|EC_VAL_OFFSET_NOT_FOUND);
3711 + }
3712 + HalDev->offset = ParmValue;
3713 + }
3714 + else
3715 + HalDev->offset = 0;
3716 +
3717 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszDebug, &ParmValue);
3718 + if (!error_code) HalDev->debug = ParmValue;
3719 +
3720 + return (EC_NO_ERRORS);
3721 + }
3722 +#endif /* +RC 3.02 */
3723 +
3724 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
3725 +static void StatsInit(HAL_DEVICE *HalDev) /* +() RC3.02 */
3726 + {
3727 + /* even though these statistics may be for multiple channels and
3728 + queues, i need only configure the pointer to the beginning
3729 + of the array, and I can index from there if necessary */
3730 +
3731 +#ifdef _CPHAL_AAL5
3732 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
3733 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
3734 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
3735 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
3736 +
3737 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
3738 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
3739 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
3740 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
3741 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
3742 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
3743 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
3744 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
3745 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
3746 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
3747 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
3748 +#endif
3749 +
3750 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC))
3751 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
3752 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
3753 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
3754 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
3755 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
3756 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
3757 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
3758 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
3759 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
3760 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
3761 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
3762 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
3763 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
3764 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
3765 +
3766 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
3767 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
3768 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
3769 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
3770 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
3771 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
3772 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
3773 +#ifdef _CPHAL_AAL5
3774 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
3775 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
3776 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
3777 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
3778 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
3779 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
3780 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
3781 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
3782 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
3783 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
3784 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
3785 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
3786 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
3787 +#endif
3788 +#endif
3789 +
3790 + StatsTable4[0].StatPtr = &HalDev->dev_base;
3791 + StatsTable4[1].StatPtr = &HalDev->offset;
3792 + StatsTable4[2].StatPtr = &HalDev->interrupt;
3793 + StatsTable4[3].StatPtr = &HalDev->debug;
3794 + StatsTable4[4].StatPtr = &HalDev->Inst;
3795 + }
3796 +#endif /* +RC 3.02 */
3797 +
3798 +#ifndef _CPHAL_CPSAR /* +RC 3.02 */
3799 +#ifndef _CPHAL_AAL2 /* +RC 3.02 */
3800 +/*
3801 + * Returns statistics information.
3802 + *
3803 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
3804 + *
3805 + * @return 0
3806 + */
3807 +static int StatsGet(HAL_DEVICE *HalDev, void **StatPtr, int Index, int Ch, int Queue)
3808 + {
3809 + int Size;
3810 + bit32u *AddrPtr;
3811 + char *DataPtr;
3812 + STATS_TABLE *StatsTable;
3813 + int i, NumberOfStats;
3814 +
3815 +#ifdef __CPHAL_DEBUG
3816 + if (DBG(0))
3817 + {
3818 + dbgPrintf("[cpcommon]StatsGet(HalDev:%08x, StatPtr:%08x)\n",
3819 + (bit32u)HalDev, (bit32u)StatPtr);
3820 + osfuncSioFlush();
3821 + }
3822 +#endif
3823 +
3824 + StatsTable = StatsDb[Index].StatTable;
3825 + NumberOfStats = StatsDb[Index].NumberOfStats;
3826 +
3827 + Size = sizeof(bit32u)*((NumberOfStats*2)+1);
3828 + Size += (NumberOfStats*11);
3829 + *StatPtr = (bit32u *)HalDev->OsFunc->Malloc(Size);
3830 +
3831 + AddrPtr = (bit32u *) *StatPtr;
3832 + DataPtr = (char *)AddrPtr;
3833 + DataPtr += sizeof(bit32u)*((NumberOfStats*2)+1);
3834 +
3835 + for (i=0; i<NumberOfStats; i++)
3836 + {
3837 + *AddrPtr++ = (bit32u)StatsTable[i].StatName;
3838 + *AddrPtr++ = (bit32u)DataPtr;
3839 + if (&StatsTable[i].StatPtr[Ch] != 0)
3840 + {
3841 + switch(StatsTable[i].DataType)
3842 + {
3843 + case 0:
3844 + HalDev->OsFunc->Sprintf(DataPtr, "%d", (bit32u *)StatsTable[i].StatPtr[Ch]);
3845 + break;
3846 + case 1:
3847 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", (bit32u *)StatsTable[i].StatPtr[Ch]);
3848 + break;
3849 + case 2:
3850 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch * (sizeof(CHANNEL_INFO)/4))));
3851 + break;
3852 + case 3:
3853 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
3854 + break;
3855 + case 4:
3856 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
3857 + break;
3858 + default:
3859 + /* invalid data type, due to CPHAL programming error */
3860 + break;
3861 + }
3862 + }
3863 + else
3864 + {
3865 + /* invalid statistics pointer, probably was not initialized */
3866 + }
3867 + DataPtr += HalDev->OsFunc->Strlen(DataPtr) + 1;
3868 + }
3869 +
3870 + *AddrPtr = (bit32u) 0;
3871 +
3872 + return (EC_NO_ERRORS);
3873 + }
3874 +#endif /* +RC 3.02 */
3875 +#endif /* +RC 3.02 */
3876 +
3877 +#ifdef _CPHAL_CPMAC
3878 +static void gpioFunctional(int base, int bit)
3879 + { /*+RC3.02*/
3880 + bit32u GpioEnr = base + 0xC;
3881 + /* To make functional, set to zero */
3882 + *(volatile bit32u *)(GpioEnr) &= ~(1 << bit); /*+RC3.02*/
3883 + } /*+RC3.02*/
3884 +
3885 +
3886 +/*+RC3.02*/
3887 +/* Common function, Checks to see if GPIO should be in functional mode */
3888 +static void gpioCheck(HAL_DEVICE *HalDev, void *moduleDeviceInfo)
3889 + { /*+RC3.02*/
3890 + int rc;
3891 + void *DeviceInfo;
3892 + char *pszMuxBits;
3893 + char pszMuxBit[20];
3894 + char *pszTmp;
3895 + char szMuxBit[20];
3896 + char *ptr;
3897 + int base;
3898 + int reset_bit;
3899 + int bit;
3900 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
3901 +
3902 + rc = OsFunc->DeviceFindParmValue(moduleDeviceInfo, "gpio_mux",&pszTmp);
3903 + if(rc) return;
3904 + /* gpio entry found, get GPIO register info and make functional */
3905 +
3906 + /* temp copy until FinParmValue fixed */
3907 + ptr = &szMuxBit[0];
3908 + while ((*ptr++ = *pszTmp++));
3909 +
3910 + pszMuxBits = &szMuxBit[0];
3911 +
3912 + rc = OsFunc->DeviceFindInfo(0,"gpio",&DeviceInfo);
3913 + if(rc) return;
3914 +
3915 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",&base);
3916 + if(rc) return;
3917 +
3918 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
3919 + if(rc) return;
3920 +
3921 + /* If GPIO still in reset, then exit */
3922 + if((VOLATILE32(HalDev->ResetBase) & (1 << reset_bit)) == 0)
3923 + return;
3924 + /* format for gpio_mux is gpio_mux = <int>;<int>;<int>...*/
3925 + while (*pszMuxBits)
3926 + {
3927 + pszTmp = &pszMuxBit[0];
3928 + if(*pszMuxBits == ';') pszMuxBits++;
3929 + while ((*pszMuxBits != ';') && (*pszMuxBits != '\0'))
3930 + {
3931 + osfuncSioFlush();
3932 + /*If value not a number, skip */
3933 + if((*pszMuxBits < '0') || (*pszMuxBits > '9'))
3934 + pszMuxBits++;
3935 + else
3936 + *pszTmp++ = *pszMuxBits++;
3937 + }
3938 + *pszTmp = '\0';
3939 + bit = OsFunc->Strtoul(pszMuxBit, &pszTmp, 10);
3940 + gpioFunctional(base, bit);
3941 + resetWait(HalDev); /* not sure if this is needed */
3942 + }
3943 + } /*+RC3.02*/
3944 +#endif /* CPMAC */
3945 +
3946 +#ifdef _CPHAL_AAL5
3947 +const char hcSarFrequency[] = "SarFreq";
3948 +#endif
3949 +
3950 +#endif /* _INC */
3951 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.h
3952 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
3953 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpaal5.h 2005-08-23 04:46:50.082845976 +0200
3954 @@ -0,0 +1,79 @@
3955 +#ifndef _INC_CPCOMMON_H
3956 +#define _INC_CPCOMMON_H
3957 +
3958 +#define VOLATILE32(addr) (*(volatile bit32u *)(addr))
3959 +#ifndef dbgPrintf
3960 +#define dbgPrintf HalDev->OsFunc->Printf
3961 +#endif
3962 +
3963 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
3964 +
3965 +#define DBG(level) (HalDev->debug & (1<<(level)))
3966 +/*
3967 +#define DBG0() DBG(0)
3968 +#define DBG1() DBG(1)
3969 +#define DBG2() DBG(2)
3970 +#define DBG3() DBG(3)
3971 +#define DBG4() DBG(4)
3972 +#define DBG5() DBG(5)
3973 +#define DBG6() DBG(6)
3974 +#define DBG7() DBG(7)
3975 +*/
3976 +
3977 +/*
3978 + * List of defined actions for use with Control().
3979 + */
3980 +typedef enum
3981 + {
3982 + enGET=0, /**< Get the value associated with a key */
3983 + enSET, /**< Set the value associates with a key */
3984 + enCLEAR, /**<Clear the value */
3985 + enNULL /**< No data action, used to initiate a service or send a message */
3986 + }ACTION;
3987 +
3988 +/*
3989 + * Enumerated hardware states.
3990 + */
3991 +typedef enum
3992 + {
3993 + enConnected=1, enDevFound, enInitialized, enOpened
3994 + }DEVICE_STATE;
3995 +
3996 +typedef enum
3997 + {
3998 + enCommonStart=0,
3999 + /* General */
4000 + enOff, enOn, enDebug,
4001 + /* Module General */
4002 + enCpuFreq,
4003 + enStatus,
4004 + enCommonEnd
4005 + }COMMON_KEY;
4006 +
4007 +typedef struct
4008 + {
4009 + const char *strKey;
4010 + int enKey;
4011 + }CONTROL_KEY;
4012 +
4013 +typedef struct
4014 + {
4015 + char *StatName;
4016 + unsigned int *StatPtr;
4017 + int DataType; /* 0: int, 1: hex int, 2:channel data */
4018 + }STATS_TABLE;
4019 +
4020 +typedef struct
4021 + {
4022 + int NumberOfStats;
4023 + STATS_TABLE *StatTable;
4024 + }STATS_DB;
4025 +
4026 +#define osfuncSioFlush() HalDev->OsFunc->Control(HalDev->OsDev,"SioFlush",pszNULL,0)
4027 +#define osfuncSleep(Ticks) HalDev->OsFunc->Control(HalDev->OsDev,pszSleep,pszNULL,Ticks)
4028 +#define osfuncStateChange() HalDev->OsFunc->Control(HalDev->OsDev,pszStateChange,pszNULL,0)
4029 +
4030 +#define CHANNEL_NAMES {"Ch0","Ch1","Ch2","Ch3","Ch4","Ch5","Ch6","Ch7","Ch8","Ch9","Ch10","Ch11","Ch12","Ch13","Ch14","Ch15"}
4031 +
4032 +#endif
4033 +
4034 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.c linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.c
4035 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.c 1970-01-01 01:00:00.000000000 +0100
4036 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.c 2005-08-23 04:46:50.082845976 +0200
4037 @@ -0,0 +1,728 @@
4038 +#ifndef _INC_CPCOMMON_C
4039 +#define _INC_CPCOMMON_C
4040 +
4041 +#ifdef _CPHAL_CPMAC
4042 +#include "cpremap_cpmac.c"
4043 +#endif
4044 +
4045 +#ifdef _CPHAL_AAL5
4046 +#include "cpremap_cpaal5.c"
4047 +#endif
4048 +
4049 +#ifdef _CPHAL_CPSAR
4050 +#include "cpremap_cpsar.c"
4051 +#endif
4052 +
4053 +#ifdef _CPHAL_AAL2
4054 +#include "cpremap_cpaal2.c"
4055 +#endif
4056 +
4057 +/**
4058 +@defgroup Common_Config_Params Common Configuration Parameters
4059 +
4060 +This section documents the configuration parameters that are valid across
4061 +all CPHAL devices.
4062 +@{
4063 +*/
4064 +/** This is the debug level. The field is bit defined, such that the user
4065 +should set to 1 all the bits corresponding to desired debug outputs. The following
4066 +are the meanings for each debug bit:
4067 +- bit0 (LSB): CPHAL Function Trace
4068 +- b1 : OS Function call trace
4069 +- b2 : Critical section entry/exit
4070 +- b3 : Memory allocation/destruction
4071 +- b4 : Detailed information in Rx path
4072 +- b5 : Detailed information in Tx path
4073 +- b6 : Extended error information
4074 +- b7 : General info
4075 +*/
4076 +static const char pszDebug[] = "debug";
4077 +/** CPU Frequency. */
4078 +/*static const char pszCpuFreq[] = "CpuFreq";*/ /*MJH-030403*/
4079 +/** Base address for the module. */
4080 +static const char pszBase[] = "base";
4081 +/** Reset bit for the module. */
4082 +static const char pszResetBit[] = "reset_bit";
4083 +/** Reset base address for the module. */
4084 +static const char pszResetBase[] = "ResetBase";
4085 +/** Interrupt line for the module. */
4086 +static const char pszIntLine[] = "int_line";
4087 +/** VLYNQ offset for the module. Disregard if not using VLYNQ. */
4088 +static const char pszOffset[] = "offset";
4089 +/** The OS may "Get" this parameter, which is a pointer
4090 + to a character string that indicates the version of CPHAL. */
4091 +static const char pszVer[] = "Version";
4092 +/*@}*/
4093 +
4094 +/**
4095 +@defgroup Common_Control_Params Common Keys for [os]Control()
4096 +
4097 +This section documents the keys used with the OS @c Control() interface that
4098 +are required by CPHAL devices.
4099 +
4100 +@{
4101 +*/
4102 +/** Used to wait for an integer number of clock ticks, given as an integer
4103 + pointer in the @p Value parameter. No actions are defined. */
4104 +static const char pszSleep[] = "Sleep";
4105 +/** Requests the OS to flush it's IO buffers. No actions are defined. */
4106 +static const char pszSioFlush[] = "SioFlush";
4107 +/*@}*/
4108 +
4109 +static const char pszStateChange[] = "StateChange";
4110 +static const char pszStatus[] = "Status";
4111 +
4112 +static const char pszGET[] = "Get";
4113 +static const char pszSET[] = "Set";
4114 +static const char pszCLEAR[] = "Clear";
4115 +static const char pszNULL[] = "";
4116 +static const char pszLocator[] = "Locator";
4117 +static const char pszOff[] = "Off";
4118 +static const char pszOn[] = "On";
4119 +static const char hcMaxFrags[] = "MaxFrags";
4120 +
4121 +#ifdef _CPHAL_CPMAC
4122 +
4123 +/* New method for string constants */
4124 +const char hcClear[] = "Clear";
4125 +const char hcGet[] = "Get";
4126 +const char hcSet[] = "Set";
4127 +
4128 +const char hcTick[] = "Tick";
4129 +
4130 +static const CONTROL_KEY KeyCommon[] =
4131 + {
4132 + {"" , enCommonStart},
4133 + {pszStatus , enStatus},
4134 + {pszOff , enOff},
4135 + {pszOn , enOn},
4136 + {pszDebug , enDebug},
4137 + {hcCpuFrequency , enCpuFreq}, /*MJH~030403*/
4138 + {"" , enCommonEnd}
4139 + };
4140 +#endif
4141 +
4142 +/**
4143 +@defgroup Common_Statistics Statistics
4144 +
4145 +A broad array of module statistics is available. Statistics values are accessed
4146 +through the @c Control() interface of the CPHAL. There are 5 different levels
4147 +of statistics, each of which correspond to a unique set of data. Furthermore,
4148 +certain statistics data is indexed by using a channel number and Tx queue number.
4149 +The following is a brief description of each statistics level, along with the
4150 +indexes used for the level:
4151 +
4152 +- Level 0: Hardware Statistics (index with channel)
4153 +- Level 1: CPHAL Software Statistics (channel, queue)
4154 +- Level 2: CPHAL Flags (channel, queue)
4155 +- Level 3: CPHAL Channel Configuration (channel)
4156 +- Level 4: CPHAL General Configuration (no index)
4157 +
4158 +The caller requests statistics information by providing a Key string to the
4159 +@c Control() API in the following format: "Stats;[Level #];[Ch #];[Queue #]".
4160 +The only valid Action parameter for statistics usage is "Get".
4161 +
4162 +Code Examples:
4163 +@code
4164 +unsigned int *StatsData;
4165 +
4166 +# Get Level 0 stats for Channel 1
4167 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
4168 +
4169 +# Get Level 2 stats for Channel 0, Queue 0
4170 +HalFunc->Control(OsDev->HalDev, "Stats;2;0;0", "Get", &StatsData);
4171 +
4172 +# Get Level 4 stats
4173 +HalFunc->Control(OsDev->HalDev, "Stats;4", "Get", &StatsData);
4174 +@endcode
4175 +
4176 +The information returned in the Value parameter of @c Control() is an
4177 +array of pointers to strings. The pointers are arranged in pairs.
4178 +The first pointer is a pointer to a name string for a particular statistic.
4179 +The next pointer is a pointer to a string containing the representation of
4180 +the integer statistic value corresponding to the first pointer. This is followed
4181 +by another pair of pointers, and so on, until a NULL pointer is encountered. The
4182 +following is example code for processing the statistics data. Note that the OS
4183 +is responsible for freeing the memory passed back through the Value parameter of
4184 +@c Control().
4185 +
4186 +@code
4187 +unsigned int *StatsData;
4188 +
4189 +# Get Level 0 stats for Channel 1
4190 +HalFunc->Control(OsDev->HalDev, "Stats;0;1", "Get", &StatsData);
4191 +
4192 +# output Statistics data
4193 +PrintStats(StatsData);
4194 +
4195 +# the upper layer is responsible for freeing stats info
4196 +free(&StatsPtr);
4197 +
4198 +...
4199 +
4200 +void PrintStats(unsigned int *StatsPtr)
4201 + {
4202 + while(*StatsPtr)
4203 + {
4204 + printf("%20s:", (char *)*StatsPtr);
4205 + StatsPtr++;
4206 + printf("%11s\n", (char *)*StatsPtr);
4207 + StatsPtr++;
4208 + }
4209 + MySioFlush();
4210 + }
4211 +@endcode
4212 +
4213 +Within each statistics level, there are several statistics defined. The statistics that
4214 +are common to every CPPI module are listed below. In addition, each module may define
4215 +extra statistics in each level, which will be documented within the module-specific
4216 +documentation appendices.
4217 +
4218 +- Level 0 Statistics
4219 + - All level 0 statistics are module-specific.
4220 +- Level 1 Statistics (CPHAL Software Statistics)
4221 + - DmaLenErrors: Incremented when the port DMA's more data than expected (per channel). (AAL5 Only)
4222 + - TxMisQCnt: Incremented when host queues a packet for transmission as the port finishes
4223 +transmitting the previous last packet in the queue (per channel and queue).
4224 + - RxMisQCnt: Incremented when host queues adds buffers to a queue as the port finished the
4225 +reception of the previous last packet in the queue (per channel).
4226 + - TxEOQCnt: Number of times the port has reached the end of the transmit queue (per channel and queue).
4227 + - RxEOQCnt: Number of times the port has reached the end of the receive queue (per channel).
4228 + - RxPacketsServiced: Number of received packets (per channel).
4229 + - TxPacketsServiced: Number of transmitted packets (per channel and queue).
4230 + - RxMaxServiced: Maximum number of packets that the CPHAL receive interrupt has serviced at a time (per channel).
4231 + - TxMaxServiced: Maximum number of packets that the CPHAL transmit interrupt has serviced at a time (per channel and queue).
4232 + - RxTotal: Total number of received packets, all channels.
4233 + - TxTotal: Total number of transmitted packets, all channels and queues.
4234 +- Level 2 Statistics (CPHAL Flags)
4235 + - RcbPool: Pointer to receive descriptor pool (per channel).
4236 + - RxActQueueCount: Number of buffers currently available for receive (per channel).
4237 + - RxActQueueHead: Pointer to first buffer in receive queue (per channel).
4238 + - RxActQueueTail: Pointer to last buffer in receive queue (per channel).
4239 + - RxActive: 0 if inactive (no buffers available), or 1 if active (buffers available).
4240 + - RcbStart: Pointer to block of receive descriptors.
4241 + - RxTeardownPending: 1 if Rx teardown is pending but incomplete, 0 otherwise.
4242 + - TcbPool: Pointer to transmit descriptor pool (per channel and queue).
4243 + - TxActQueueCount: Number of buffers currently queued to be transmitted (per channel and queue).
4244 + - TxActQueueHead: Pointer to first buffer in transmit queue (per channel and queue).
4245 + - TxActQueueTail: Pointer to last buffer in transmit queue (per channel and queue).
4246 + - TxActive: 0 if inactive (no buffers to send), or 1 if active (buffers queued to send).
4247 + - TcbStart: Pointer to block of transmit descriptors.
4248 + - TxTeardownPending: 1 if Tx teardown is pending but incomplete, 0 otherwise.
4249 +- Level 3 Statistics (CPHAL Channel Configuration)
4250 + - RxBufSize: Rx buffer size.
4251 + - RxBufferOffset: Rx buffer offset.
4252 + - RxNumBuffers: Number of Rx buffers.
4253 + - RxServiceMax: Maximum number of receive packets to service at a time.
4254 + - TxNumBuffers: Number of Tx buffer descriptors.
4255 + - TxNumQueues: Number of Tx queues to use.
4256 + - TxServiceMax: Maximum number of transmit packets to service at a time.
4257 +- Level 4 Statistics (CPHAL General Configuration)
4258 + - Base Address: Base address of the module.
4259 + - Offset (VLYNQ): VLYNQ relative module offset.
4260 + - Interrupt Line: Interrupt number.
4261 + - Debug: Debug flag, 1 to enable debug.
4262 + - Inst: Instance number.
4263 +*/
4264 +
4265 +/*
4266 + Data Type 0 = int display
4267 + Data Type 1 = hex display
4268 + Data Type 2 = channel structure, int display
4269 + Data Type 3 = queue index and int display
4270 + Data Type 4 = queue index and hex display
4271 +*/
4272 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC)) /* +GSG 030307 */
4273 +static STATS_TABLE StatsTable0[] =
4274 + {
4275 +#ifdef _CPHAL_AAL5
4276 + /* Name , Data Ptr, Data Type */
4277 + {"Crc Errors", 0, 0},
4278 + {"Len Errors", 0, 0},
4279 + {"Abort Errors", 0, 0},
4280 + {"Starv Errors", 0, 0}
4281 +#endif
4282 +#ifdef _CPHAL_CPMAC
4283 + {"Rx Good Frames", 0, 0}
4284 +#endif
4285 + };
4286 +
4287 +static STATS_TABLE StatsTable1[] =
4288 + {
4289 + /* Name , Data Ptr, Data Type */
4290 + {"DmaLenErrors", 0, 0},
4291 + {"TxMisQCnt", 0, 3},
4292 + {"RxMisQCnt", 0, 0},
4293 + {"TxEOQCnt", 0, 3},
4294 + {"RxEOQCnt", 0, 0},
4295 + {"RxPacketsServiced", 0, 0},
4296 + {"TxPacketsServiced", 0, 3},
4297 + {"RxMaxServiced", 0, 0},
4298 + {"TxMaxServiced", 0, 3},
4299 + {"RxTotal", 0, 0},
4300 + {"TxTotal", 0, 0},
4301 + };
4302 +
4303 +static STATS_TABLE StatsTable2[] =
4304 + {
4305 + /* Name , Data Ptr, Data Type */
4306 + {"RcbPool", 0, 1},
4307 + {"RxActQueueCount", 0, 0},
4308 + {"RxActQueueHead", 0, 1},
4309 + {"RxActQueueTail", 0, 1},
4310 + {"RxActive", 0, 0},
4311 + {"RcbStart", 0, 1},
4312 + {"RxTeardownPending", 0, 0},
4313 + {"TcbPool", 0, 4},
4314 + {"TxActQueueCount", 0, 3},
4315 + {"TxActQueueHead", 0, 4},
4316 + {"TxActQueueTail", 0, 4},
4317 + {"TxActive", 0, 3},
4318 + {"TcbStart", 0, 4},
4319 + {"TxTeardownPending", 0, 0}
4320 + };
4321 +
4322 +static STATS_TABLE StatsTable3[] =
4323 + {
4324 + /* Name , Data Ptr, Data Type */
4325 + {"RxBufSize", 0, 2},
4326 + {"RxBufferOffset", 0, 2},
4327 + {"RxNumBuffers", 0, 2},
4328 + {"RxServiceMax", 0, 2},
4329 + {"TxNumBuffers", 0, 2},
4330 + {"TxNumQueues", 0, 2},
4331 + {"TxServiceMax", 0, 2},
4332 +#ifdef _CPHAL_AAL5
4333 + {"CpcsUU", 0, 2},
4334 + {"Gfc", 0, 2},
4335 + {"Clp", 0, 2},
4336 + {"Pti", 0, 2},
4337 + {"DaMask", 0, 2},
4338 + {"Priority", 0, 2},
4339 + {"PktType", 0, 2},
4340 + {"Vci", 0, 2},
4341 + {"Vpi", 0, 2},
4342 + {"CellRate", 0, 2},
4343 + {"QosType", 0, 2},
4344 + {"Mbs", 0, 2},
4345 + {"Pcr", 0, 2}
4346 +#endif
4347 + };
4348 +
4349 +static STATS_TABLE StatsTable4[] =
4350 + {
4351 + {"Base Address", 0, 1},
4352 + {"Offset (VLYNQ)", 0, 0},
4353 + {"Interrupt Line", 0, 0},
4354 + {"Debug", 0, 0},
4355 + {"Instance", 0, 0},
4356 +#ifdef _CPHAL_AAL5
4357 + {"UniNni", 0, 0}
4358 +#endif
4359 + };
4360 +
4361 +static STATS_DB StatsDb[] =
4362 + {
4363 + {(sizeof(StatsTable0)/sizeof(STATS_TABLE)), StatsTable0},
4364 + {(sizeof(StatsTable1)/sizeof(STATS_TABLE)), StatsTable1},
4365 + {(sizeof(StatsTable2)/sizeof(STATS_TABLE)), StatsTable2},
4366 + {(sizeof(StatsTable3)/sizeof(STATS_TABLE)), StatsTable3},
4367 + {(sizeof(StatsTable4)/sizeof(STATS_TABLE)), StatsTable4}
4368 + };
4369 +#endif /* +GSG 030307 */
4370 +
4371 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
4372 +static void resetWait(HAL_DEVICE *HalDev)
4373 + { /*+RC3.02*/
4374 + const int TickReset=64;
4375 + osfuncSleep((int*)&TickReset);
4376 + } /*+RC3.02*/
4377 +#endif /* +RC 3.02 */
4378 +
4379 +/* I only define the reset base function for the modules
4380 + that can perform a reset. The AAL5 and AAL2 modules
4381 + do not perform a reset, that is done by the shared module
4382 + CPSAR */
4383 +#if defined(_CPHAL_CPSAR) || defined(_CPHAL_CPMAC) || defined(_CPHAL_VDMAVT)
4384 +/*
4385 + * Determines the reset register address to be used for a particular device.
4386 + * It will search the current device entry for Locator information. If the
4387 + * device is a root device, there will be no Locator information, and the
4388 + * function will find and return the root reset register. If a Locator value
4389 + * is found, the function will search each VLYNQ device entry in the system
4390 + * looking for a matching Locator. Once it finds a VLYNQ device entry with
4391 + * a matching Locator, it will extract the "ResetBase" parameter from that
4392 + * VLYNQ device entry (thus every VLYNQ entry must have the ResetBase parameter).
4393 + *
4394 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
4395 + * @param ResetBase Pointer to integer address of reset register.
4396 + *
4397 + * @return 0 OK, Non-zero not OK
4398 + */
4399 +static int ResetBaseGet(HAL_DEVICE *HalDev, bit32u *ResetBase)
4400 + {
4401 + char *DeviceInfo = HalDev->DeviceInfo;
4402 + char *MyLocator, *NextLocator;
4403 + int Inst=1;
4404 + bit32u error_code;
4405 +
4406 +#ifdef __CPHAL_DEBUG
4407 + if (DBG(0))
4408 + {
4409 + dbgPrintf("[cpcommon]ResetBaseGet(HalDev:%08x, ResetBase:%08x)\n", (bit32u)HalDev, ResetBase);
4410 + osfuncSioFlush();
4411 + }
4412 +#endif
4413 +
4414 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &MyLocator);
4415 + if (error_code)
4416 + {
4417 + /* if no Locator value, device is on the root, so get the "reset" device */
4418 + error_code = HalDev->OsFunc->DeviceFindInfo(0, "reset", &DeviceInfo);
4419 + if (error_code)
4420 + {
4421 + return(EC_VAL_DEVICE_NOT_FOUND);
4422 + }
4423 +
4424 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "base", ResetBase);
4425 + if (error_code)
4426 + {
4427 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
4428 + }
4429 +
4430 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
4431 +
4432 + /* found base address for root device, so we're done */
4433 + return (EC_NO_ERRORS);
4434 + }
4435 + else
4436 + {
4437 + /* we have a Locator value, so the device is remote */
4438 +
4439 + /* Find a vlynq device with a matching locator value */
4440 + while ((HalDev->OsFunc->DeviceFindInfo(Inst, "vlynq", &DeviceInfo)) == EC_NO_ERRORS)
4441 + {
4442 + error_code = HalDev->OsFunc->DeviceFindParmValue(DeviceInfo, "Locator", &NextLocator);
4443 + if (error_code)
4444 + {
4445 + /* no Locator value for this VLYNQ, so move on */
4446 + continue;
4447 + }
4448 + if (HalDev->OsFunc->Strcmpi(MyLocator, NextLocator)==0)
4449 + {
4450 + /* we have found a VLYNQ with a matching Locator, so extract the ResetBase */
4451 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, "ResetBase", ResetBase);
4452 + if (error_code)
4453 + {
4454 + return(EC_VAL_BASE_ADDR_NOT_FOUND);
4455 + }
4456 + *ResetBase = ((bit32u)PhysToVirtNoCache(*ResetBase));
4457 +
4458 + /* found base address for root device, so we're done */
4459 + return (EC_NO_ERRORS);
4460 + }
4461 + Inst++;
4462 + } /* while */
4463 + } /* else */
4464 +
4465 + return (EC_NO_ERRORS);
4466 + }
4467 +#endif
4468 +
4469 +#ifndef _CPHAL_AAL2 /* + RC 3.02 */
4470 +static bit32u ConfigGetCommon(HAL_DEVICE *HalDev)
4471 + {
4472 + bit32u ParmValue;
4473 + bit32 error_code;
4474 + char *DeviceInfo = HalDev->DeviceInfo;
4475 +
4476 +#ifdef __CPHAL_DEBUG
4477 + if (DBG(0))
4478 + {
4479 + dbgPrintf("[cpcommon]ConfigGetCommon(HalDev:%08x)\n", (bit32u)HalDev);
4480 + osfuncSioFlush();
4481 + }
4482 +#endif
4483 +
4484 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszBase, &ParmValue);
4485 + if (error_code)
4486 + {
4487 + return(EC_FUNC_HAL_INIT|EC_VAL_BASE_ADDR_NOT_FOUND);
4488 + }
4489 + HalDev->dev_base = ((bit32u)PhysToVirtNoCache(ParmValue));
4490 +
4491 +#ifndef _CPHAL_AAL5
4492 +#ifndef _CPHAL_AAL2
4493 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszResetBit, &ParmValue);
4494 + if(error_code)
4495 + {
4496 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BIT_NOT_FOUND);
4497 + }
4498 + HalDev->ResetBit = ParmValue;
4499 +
4500 + /* Get reset base address */
4501 + error_code = ResetBaseGet(HalDev, &ParmValue);
4502 + if (error_code)
4503 + return(EC_FUNC_HAL_INIT|EC_VAL_RESET_BASE_NOT_FOUND);
4504 + HalDev->ResetBase = ParmValue;
4505 +#endif
4506 +#endif
4507 +
4508 +#ifndef _CPHAL_CPSAR
4509 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszIntLine,&ParmValue);
4510 + if (error_code)
4511 + {
4512 + return(EC_FUNC_HAL_INIT|EC_VAL_INTERRUPT_NOT_FOUND);
4513 + }
4514 + HalDev->interrupt = ParmValue;
4515 +#endif
4516 +
4517 + /* only look for the offset if there is a Locator field, which indicates that
4518 + the module is a VLYNQ module */
4519 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszLocator,&ParmValue);
4520 + if (!error_code)
4521 + {
4522 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszOffset,&ParmValue);
4523 + if (error_code)
4524 + {
4525 + return(EC_FUNC_HAL_INIT|EC_VAL_OFFSET_NOT_FOUND);
4526 + }
4527 + HalDev->offset = ParmValue;
4528 + }
4529 + else
4530 + HalDev->offset = 0;
4531 +
4532 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo, pszDebug, &ParmValue);
4533 + if (!error_code) HalDev->debug = ParmValue;
4534 +
4535 + return (EC_NO_ERRORS);
4536 + }
4537 +#endif /* +RC 3.02 */
4538 +
4539 +#ifdef _CPHAL_CPMAC /* +RC 3.02 */
4540 +static void StatsInit(HAL_DEVICE *HalDev) /* +() RC3.02 */
4541 + {
4542 + /* even though these statistics may be for multiple channels and
4543 + queues, i need only configure the pointer to the beginning
4544 + of the array, and I can index from there if necessary */
4545 +
4546 +#ifdef _CPHAL_AAL5
4547 + StatsTable0[0].StatPtr = &HalDev->Stats.CrcErrors[0];
4548 + StatsTable0[1].StatPtr = &HalDev->Stats.LenErrors[0];
4549 + StatsTable0[2].StatPtr = &HalDev->Stats.AbortErrors[0];
4550 + StatsTable0[3].StatPtr = &HalDev->Stats.StarvErrors[0];
4551 +
4552 + StatsTable1[0].StatPtr = &HalDev->Stats.DmaLenErrors[0];
4553 + StatsTable1[1].StatPtr = &HalDev->Stats.TxMisQCnt[0][0];
4554 + StatsTable1[2].StatPtr = &HalDev->Stats.RxMisQCnt[0];
4555 + StatsTable1[3].StatPtr = &HalDev->Stats.TxEOQCnt[0][0];
4556 + StatsTable1[4].StatPtr = &HalDev->Stats.RxEOQCnt[0];
4557 + StatsTable1[5].StatPtr = &HalDev->Stats.RxPacketsServiced[0];
4558 + StatsTable1[6].StatPtr = &HalDev->Stats.TxPacketsServiced[0][0];
4559 + StatsTable1[7].StatPtr = &HalDev->Stats.RxMaxServiced;
4560 + StatsTable1[8].StatPtr = &HalDev->Stats.TxMaxServiced[0][0];
4561 + StatsTable1[9].StatPtr = &HalDev->Stats.RxTotal;
4562 + StatsTable1[10].StatPtr = &HalDev->Stats.TxTotal;
4563 +#endif
4564 +
4565 +#if (defined(_CPHAL_AAL5) || defined(_CPHAL_CPMAC))
4566 + StatsTable2[0].StatPtr = (bit32u *)&HalDev->RcbPool[0];
4567 + StatsTable2[1].StatPtr = &HalDev->RxActQueueCount[0];
4568 + StatsTable2[2].StatPtr = (bit32u *)&HalDev->RxActQueueHead[0];
4569 + StatsTable2[3].StatPtr = (bit32u *)&HalDev->RxActQueueTail[0];
4570 + StatsTable2[4].StatPtr = &HalDev->RxActive[0];
4571 + StatsTable2[5].StatPtr = (bit32u *)&HalDev->RcbStart[0];
4572 + StatsTable2[6].StatPtr = &HalDev->RxTeardownPending[0];
4573 + StatsTable2[7].StatPtr = (bit32u *)&HalDev->TcbPool[0][0];
4574 + StatsTable2[8].StatPtr = &HalDev->TxActQueueCount[0][0];
4575 + StatsTable2[9].StatPtr = (bit32u *)&HalDev->TxActQueueHead[0][0];
4576 + StatsTable2[10].StatPtr = (bit32u *)&HalDev->TxActQueueTail[0][0];
4577 + StatsTable2[11].StatPtr = &HalDev->TxActive[0][0];
4578 + StatsTable2[12].StatPtr = (bit32u *)&HalDev->TcbStart[0][0];
4579 + StatsTable2[13].StatPtr = &HalDev->TxTeardownPending[0];
4580 +
4581 + StatsTable3[0].StatPtr = &HalDev->ChData[0].RxBufSize;
4582 + StatsTable3[1].StatPtr = &HalDev->ChData[0].RxBufferOffset;
4583 + StatsTable3[2].StatPtr = &HalDev->ChData[0].RxNumBuffers;
4584 + StatsTable3[3].StatPtr = &HalDev->ChData[0].RxServiceMax;
4585 + StatsTable3[4].StatPtr = &HalDev->ChData[0].TxNumBuffers;
4586 + StatsTable3[5].StatPtr = &HalDev->ChData[0].TxNumQueues;
4587 + StatsTable3[6].StatPtr = &HalDev->ChData[0].TxServiceMax;
4588 +#ifdef _CPHAL_AAL5
4589 + StatsTable3[7].StatPtr = &HalDev->ChData[0].CpcsUU;
4590 + StatsTable3[8].StatPtr = &HalDev->ChData[0].Gfc;
4591 + StatsTable3[9].StatPtr = &HalDev->ChData[0].Clp;
4592 + StatsTable3[10].StatPtr = &HalDev->ChData[0].Pti;
4593 + StatsTable3[11].StatPtr = &HalDev->ChData[0].DaMask;
4594 + StatsTable3[12].StatPtr = &HalDev->ChData[0].Priority;
4595 + StatsTable3[13].StatPtr = &HalDev->ChData[0].PktType;
4596 + StatsTable3[14].StatPtr = &HalDev->ChData[0].Vci;
4597 + StatsTable3[15].StatPtr = &HalDev->ChData[0].Vpi;
4598 + StatsTable3[16].StatPtr = &HalDev->ChData[0].TxVc_CellRate;
4599 + StatsTable3[17].StatPtr = &HalDev->ChData[0].TxVc_QosType;
4600 + StatsTable3[18].StatPtr = &HalDev->ChData[0].TxVc_Mbs;
4601 + StatsTable3[19].StatPtr = &HalDev->ChData[0].TxVc_Pcr;
4602 +#endif
4603 +#endif
4604 +
4605 + StatsTable4[0].StatPtr = &HalDev->dev_base;
4606 + StatsTable4[1].StatPtr = &HalDev->offset;
4607 + StatsTable4[2].StatPtr = &HalDev->interrupt;
4608 + StatsTable4[3].StatPtr = &HalDev->debug;
4609 + StatsTable4[4].StatPtr = &HalDev->Inst;
4610 + }
4611 +#endif /* +RC 3.02 */
4612 +
4613 +#ifndef _CPHAL_CPSAR /* +RC 3.02 */
4614 +#ifndef _CPHAL_AAL2 /* +RC 3.02 */
4615 +/*
4616 + * Returns statistics information.
4617 + *
4618 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
4619 + *
4620 + * @return 0
4621 + */
4622 +static int StatsGet(HAL_DEVICE *HalDev, void **StatPtr, int Index, int Ch, int Queue)
4623 + {
4624 + int Size;
4625 + bit32u *AddrPtr;
4626 + char *DataPtr;
4627 + STATS_TABLE *StatsTable;
4628 + int i, NumberOfStats;
4629 +
4630 +#ifdef __CPHAL_DEBUG
4631 + if (DBG(0))
4632 + {
4633 + dbgPrintf("[cpcommon]StatsGet(HalDev:%08x, StatPtr:%08x)\n",
4634 + (bit32u)HalDev, (bit32u)StatPtr);
4635 + osfuncSioFlush();
4636 + }
4637 +#endif
4638 +
4639 + StatsTable = StatsDb[Index].StatTable;
4640 + NumberOfStats = StatsDb[Index].NumberOfStats;
4641 +
4642 + Size = sizeof(bit32u)*((NumberOfStats*2)+1);
4643 + Size += (NumberOfStats*11);
4644 + *StatPtr = (bit32u *)HalDev->OsFunc->Malloc(Size);
4645 +
4646 + AddrPtr = (bit32u *) *StatPtr;
4647 + DataPtr = (char *)AddrPtr;
4648 + DataPtr += sizeof(bit32u)*((NumberOfStats*2)+1);
4649 +
4650 + for (i=0; i<NumberOfStats; i++)
4651 + {
4652 + *AddrPtr++ = (bit32u)StatsTable[i].StatName;
4653 + *AddrPtr++ = (bit32u)DataPtr;
4654 + if (&StatsTable[i].StatPtr[Ch] != 0)
4655 + {
4656 + switch(StatsTable[i].DataType)
4657 + {
4658 + case 0:
4659 + HalDev->OsFunc->Sprintf(DataPtr, "%d", (bit32u *)StatsTable[i].StatPtr[Ch]);
4660 + break;
4661 + case 1:
4662 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", (bit32u *)StatsTable[i].StatPtr[Ch]);
4663 + break;
4664 + case 2:
4665 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch * (sizeof(CHANNEL_INFO)/4))));
4666 + break;
4667 + case 3:
4668 + HalDev->OsFunc->Sprintf(DataPtr, "%d", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
4669 + break;
4670 + case 4:
4671 + HalDev->OsFunc->Sprintf(DataPtr, "0x%x", *((bit32u *)StatsTable[i].StatPtr + (Ch*MAX_QUEUE)+Queue));
4672 + break;
4673 + default:
4674 + /* invalid data type, due to CPHAL programming error */
4675 + break;
4676 + }
4677 + }
4678 + else
4679 + {
4680 + /* invalid statistics pointer, probably was not initialized */
4681 + }
4682 + DataPtr += HalDev->OsFunc->Strlen(DataPtr) + 1;
4683 + }
4684 +
4685 + *AddrPtr = (bit32u) 0;
4686 +
4687 + return (EC_NO_ERRORS);
4688 + }
4689 +#endif /* +RC 3.02 */
4690 +#endif /* +RC 3.02 */
4691 +
4692 +#ifdef _CPHAL_CPMAC
4693 +static void gpioFunctional(int base, int bit)
4694 + { /*+RC3.02*/
4695 + bit32u GpioEnr = base + 0xC;
4696 + /* To make functional, set to zero */
4697 + *(volatile bit32u *)(GpioEnr) &= ~(1 << bit); /*+RC3.02*/
4698 + } /*+RC3.02*/
4699 +
4700 +
4701 +/*+RC3.02*/
4702 +/* Common function, Checks to see if GPIO should be in functional mode */
4703 +static void gpioCheck(HAL_DEVICE *HalDev, void *moduleDeviceInfo)
4704 + { /*+RC3.02*/
4705 + int rc;
4706 + void *DeviceInfo;
4707 + char *pszMuxBits;
4708 + char pszMuxBit[20];
4709 + char *pszTmp;
4710 + char szMuxBit[20];
4711 + char *ptr;
4712 + int base;
4713 + int reset_bit;
4714 + int bit;
4715 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
4716 +
4717 + rc = OsFunc->DeviceFindParmValue(moduleDeviceInfo, "gpio_mux",&pszTmp);
4718 + if(rc) return;
4719 + /* gpio entry found, get GPIO register info and make functional */
4720 +
4721 + /* temp copy until FinParmValue fixed */
4722 + ptr = &szMuxBit[0];
4723 + while ((*ptr++ = *pszTmp++));
4724 +
4725 + pszMuxBits = &szMuxBit[0];
4726 +
4727 + rc = OsFunc->DeviceFindInfo(0,"gpio",&DeviceInfo);
4728 + if(rc) return;
4729 +
4730 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "base",&base);
4731 + if(rc) return;
4732 +
4733 + rc = OsFunc->DeviceFindParmUint(DeviceInfo, "reset_bit",&reset_bit);
4734 + if(rc) return;
4735 +
4736 + /* If GPIO still in reset, then exit */
4737 + if((VOLATILE32(HalDev->ResetBase) & (1 << reset_bit)) == 0)
4738 + return;
4739 + /* format for gpio_mux is gpio_mux = <int>;<int>;<int>...*/
4740 + while (*pszMuxBits)
4741 + {
4742 + pszTmp = &pszMuxBit[0];
4743 + if(*pszMuxBits == ';') pszMuxBits++;
4744 + while ((*pszMuxBits != ';') && (*pszMuxBits != '\0'))
4745 + {
4746 + osfuncSioFlush();
4747 + /*If value not a number, skip */
4748 + if((*pszMuxBits < '0') || (*pszMuxBits > '9'))
4749 + pszMuxBits++;
4750 + else
4751 + *pszTmp++ = *pszMuxBits++;
4752 + }
4753 + *pszTmp = '\0';
4754 + bit = OsFunc->Strtoul(pszMuxBit, &pszTmp, 10);
4755 + gpioFunctional(base, bit);
4756 + resetWait(HalDev); /* not sure if this is needed */
4757 + }
4758 + } /*+RC3.02*/
4759 +#endif /* CPMAC */
4760 +
4761 +#ifdef _CPHAL_AAL5
4762 +const char hcSarFrequency[] = "SarFreq";
4763 +#endif
4764 +
4765 +#endif /* _INC */
4766 diff -urN linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.h linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.h
4767 --- linux.old/drivers/atm/sangam_atm/cpcommon_cpsar.h 1970-01-01 01:00:00.000000000 +0100
4768 +++ linux.dev/drivers/atm/sangam_atm/cpcommon_cpsar.h 2005-08-23 04:46:50.083845824 +0200
4769 @@ -0,0 +1,79 @@
4770 +#ifndef _INC_CPCOMMON_H
4771 +#define _INC_CPCOMMON_H
4772 +
4773 +#define VOLATILE32(addr) (*(volatile bit32u *)(addr))
4774 +#ifndef dbgPrintf
4775 +#define dbgPrintf HalDev->OsFunc->Printf
4776 +#endif
4777 +
4778 +#define ChannelUpdate(Field) if(HalChn->Field != 0xFFFFFFFF) HalDev->ChData[Ch].Field = HalChn->Field
4779 +
4780 +#define DBG(level) (HalDev->debug & (1<<(level)))
4781 +/*
4782 +#define DBG0() DBG(0)
4783 +#define DBG1() DBG(1)
4784 +#define DBG2() DBG(2)
4785 +#define DBG3() DBG(3)
4786 +#define DBG4() DBG(4)
4787 +#define DBG5() DBG(5)
4788 +#define DBG6() DBG(6)
4789 +#define DBG7() DBG(7)
4790 +*/
4791 +
4792 +/*
4793 + * List of defined actions for use with Control().
4794 + */
4795 +typedef enum
4796 + {
4797 + enGET=0, /**< Get the value associated with a key */
4798 + enSET, /**< Set the value associates with a key */
4799 + enCLEAR, /**<Clear the value */
4800 + enNULL /**< No data action, used to initiate a service or send a message */
4801 + }ACTION;
4802 +
4803 +/*
4804 + * Enumerated hardware states.
4805 + */
4806 +typedef enum
4807 + {
4808 + enConnected=1, enDevFound, enInitialized, enOpened
4809 + }DEVICE_STATE;
4810 +
4811 +typedef enum
4812 + {
4813 + enCommonStart=0,
4814 + /* General */
4815 + enOff, enOn, enDebug,
4816 + /* Module General */
4817 + enCpuFreq,
4818 + enStatus,
4819 + enCommonEnd
4820 + }COMMON_KEY;
4821 +
4822 +typedef struct
4823 + {
4824 + const char *strKey;
4825 + int enKey;
4826 + }CONTROL_KEY;
4827 +
4828 +typedef struct
4829 + {
4830 + char *StatName;
4831 + unsigned int *StatPtr;
4832 + int DataType; /* 0: int, 1: hex int, 2:channel data */
4833 + }STATS_TABLE;
4834 +
4835 +typedef struct
4836 + {
4837 + int NumberOfStats;
4838 + STATS_TABLE *StatTable;
4839 + }STATS_DB;
4840 +
4841 +#define osfuncSioFlush() HalDev->OsFunc->Control(HalDev->OsDev,"SioFlush",pszNULL,0)
4842 +#define osfuncSleep(Ticks) HalDev->OsFunc->Control(HalDev->OsDev,pszSleep,pszNULL,Ticks)
4843 +#define osfuncStateChange() HalDev->OsFunc->Control(HalDev->OsDev,pszStateChange,pszNULL,0)
4844 +
4845 +#define CHANNEL_NAMES {"Ch0","Ch1","Ch2","Ch3","Ch4","Ch5","Ch6","Ch7","Ch8","Ch9","Ch10","Ch11","Ch12","Ch13","Ch14","Ch15"}
4846 +
4847 +#endif
4848 +
4849 diff -urN linux.old/drivers/atm/sangam_atm/cppi_cpaal5.c linux.dev/drivers/atm/sangam_atm/cppi_cpaal5.c
4850 --- linux.old/drivers/atm/sangam_atm/cppi_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
4851 +++ linux.dev/drivers/atm/sangam_atm/cppi_cpaal5.c 2005-08-23 04:46:50.084845672 +0200
4852 @@ -0,0 +1,1483 @@
4853 +/*************************************************************************
4854 + * TNETDxxxx Software Support
4855 + * Copyright (c) 2002,2003 Texas Instruments Incorporated. All Rights Reserved.
4856 + *
4857 + * FILE: cppi.c
4858 + *
4859 + * DESCRIPTION:
4860 + * This file contains shared code for all CPPI modules.
4861 + *
4862 + * HISTORY:
4863 + * 7Aug02 Greg RC1.00 Original Version created.
4864 + * 27Sep02 Mick RC1.01 Merged for use by CPMAC/CPSAR
4865 + * 16Oct02 Mick RC1.02 Performance Tweaks (see cppihist.txt)
4866 + * 12Nov02 Mick RC1.02 Updated to use cpmac_reg.h
4867 + * 09Jan03 Mick RC3.01 Removed modification to RxBuffer ptr
4868 + * 28Mar03 Mick 1.03 RxReturn now returns error if Malloc Fails
4869 + * 10Apr03 Mick 1.03.02 Added Needs Buffer Support
4870 + * 11Jun03 Mick 1.06.02 halSend() errors corrected
4871 + *
4872 + * @author Greg Guyotte
4873 + * @version 1.00
4874 + * @date 7-Aug-2002
4875 + *****************************************************************************/
4876 +/* each CPPI module must modify this file, the rest of the
4877 + code in cppi.c should be totally shared *//* Each CPPI module MUST properly define all constants shown below */
4878 +
4879 +/* CPPI registers */
4880 +
4881 +/* the following defines are not CPPI specific, but still used by cppi.c */
4882 +
4883 +static void FreeRx(HAL_DEVICE *HalDev, int Ch)
4884 + {
4885 + HAL_RCB *rcb_ptr; /*+GSG 030303*/
4886 + int rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf; /*+GSG 030303*/
4887 + int Num = HalDev->ChData[Ch].RxNumBuffers, i; /*+GSG 030303*/
4888 +
4889 + /* Free Rx data buffers attached to descriptors, if necessary */
4890 + if (HalDev->RcbStart[Ch] != 0) /*+GSG 030303*/
4891 + { /*+GSG 030303*/
4892 + for(i=0;i<Num;i++) /*+GSG 030303*/
4893 + { /*+GSG 030303*/
4894 + rcb_ptr = (HAL_RCB *)(HalDev->RcbStart[Ch] + (i*rcbSize)); /*+GSG 030303*/
4895 +
4896 + /* free the data buffer */
4897 + if (rcb_ptr->DatPtr != 0)
4898 + {
4899 +
4900 + HalDev->OsFunc->FreeRxBuffer((void *)rcb_ptr->OsInfo, (void *)rcb_ptr->DatPtr);
4901 + rcb_ptr->OsInfo=0; /*MJH+030522*/
4902 + rcb_ptr->DatPtr=0; /*MJH+030522*/
4903 + }
4904 + } /*+GSG 030303*/
4905 + } /*+GSG 030303*/
4906 +
4907 + /* free up all desciptors at once */
4908 + HalDev->OsFunc->FreeDmaXfer(HalDev->RcbStart[Ch]);
4909 +
4910 + /* mark buffers as freed */
4911 + HalDev->RcbStart[Ch] = 0;
4912 + }
4913 +
4914 +static void FreeTx(HAL_DEVICE *HalDev, int Ch, int Queue)
4915 + {
4916 +
4917 +/*+GSG 030303*/
4918 +
4919 + /* free all descriptors at once */
4920 + HalDev->OsFunc->FreeDmaXfer(HalDev->TcbStart[Ch][Queue]);
4921 +
4922 + HalDev->TcbStart[Ch][Queue] = 0;
4923 + }
4924 +
4925 +/* return of 0 means that this code executed, -1 means the interrupt was not
4926 + a teardown interrupt */
4927 +static int RxTeardownInt(HAL_DEVICE *HalDev, int Ch)
4928 + {
4929 + bit32u base = HalDev->dev_base;
4930 +
4931 + int i;
4932 + volatile bit32u *pTmp;
4933 +
4934 + /* check to see if the interrupt is a teardown interrupt */
4935 + if (((*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) & TEARDOWN_VAL) == TEARDOWN_VAL)
4936 + {
4937 + /* finish channel teardown */
4938 +
4939 + /* Free channel resources on a FULL teardown */
4940 + if (HalDev->RxTeardownPending[Ch] & FULL_TEARDOWN)
4941 + {
4942 + FreeRx(HalDev, Ch);
4943 + }
4944 +
4945 + /* bug fix - clear Rx channel pointers on teardown */
4946 + HalDev->RcbPool[Ch] = 0;
4947 + HalDev->RxActQueueHead[Ch] = 0;
4948 + HalDev->RxActQueueCount[Ch] = 0;
4949 + HalDev->RxActive[Ch] = FALSE;
4950 +
4951 + /* write completion pointer */
4952 + (*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) = TEARDOWN_VAL;
4953 +
4954 + /* use direction bit as a teardown pending bit! May be able to
4955 + use only one teardown pending integer in HalDev */
4956 +
4957 + HalDev->RxTeardownPending[Ch] &= ~RX_TEARDOWN;
4958 +
4959 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
4960 +
4961 + /* call OS Teardown Complete (if TX is also done) */
4962 + if ((HalDev->TxTeardownPending[Ch] & TX_TEARDOWN) == 0)
4963 + {
4964 + /* mark channel as closed */
4965 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
4966 +
4967 + /* disable channel interrupt */
4968 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
4969 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<(Ch+16)); /* +GSG 030307 */
4970 + SAR_RX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
4971 +
4972 + /* Clear PDSP Channel State RAM */
4973 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+(Ch*64));
4974 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
4975 + *pTmp++ = 0;
4976 +
4977 + if ((HalDev->RxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
4978 + {
4979 +
4980 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX|DIRECTION_RX);
4981 + }
4982 + /* clear all teardown pending information for this channel */
4983 + HalDev->RxTeardownPending[Ch] = 0;
4984 + HalDev->TxTeardownPending[Ch] = 0;
4985 + }
4986 +
4987 + return (EC_NO_ERRORS);
4988 + }
4989 + return (-1);
4990 + }
4991 +
4992 +/* return of 0 means that this code executed, -1 means the interrupt was not
4993 + a teardown interrupt */
4994 +static int TxTeardownInt(HAL_DEVICE *HalDev, int Ch, int Queue)
4995 + {
4996 + bit32u base = HalDev->dev_base;
4997 + HAL_TCB *Last, *Curr, *First; /*+GSG 030303*/
4998 +
4999 + int i;
5000 + volatile bit32u *pTmp;
5001 +
5002 + if (((*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) & TEARDOWN_VAL) == TEARDOWN_VAL)
5003 + {
5004 + /* return outstanding buffers to OS +RC3.02*/
5005 + Curr = HalDev->TxActQueueHead[Ch][Queue]; /*+GSG 030303*/
5006 + First = Curr; /*+GSG 030303*/
5007 + while (Curr) /*+GSG 030303*/
5008 + { /*+GSG 030303*/
5009 + /* Pop TCB(s) for packet from the stack */ /*+GSG 030303*/
5010 + Last = Curr->Eop; /*+GSG 030303*/
5011 + HalDev->TxActQueueHead[Ch][Queue] = Last->Next; /*+GSG 030303*/
5012 + /*+GSG 030303*/
5013 + /* return to OS */ /*+GSG 030303*/
5014 + HalDev->OsFunc->SendComplete(Curr->OsInfo); /*+GSG 030303*/
5015 + /*+GSG 030303*/
5016 + /* Push Tcb(s) back onto the stack */ /*+GSG 030303*/
5017 + Curr = Last->Next; /*+GSG 030303*/
5018 + Last->Next = HalDev->TcbPool[Ch][Queue]; /*+GSG 030303*/
5019 + HalDev->TcbPool[Ch][Queue] = First; /*+GSG 030303*/
5020 + /*+GSG 030303*/
5021 + /* set the first(SOP) pointer for the next packet */ /*+GSG 030303*/
5022 + First = Curr; /*+GSG 030303*/
5023 + } /*+GSG 030303*/
5024 +
5025 + /* finish channel teardown */
5026 +
5027 + /* save the OsInfo to pass to upper layer
5028 + THIS WAS CRASHING - because it's possible that I get the teardown
5029 + notification and the TcbHPool is null. In this case, the buffers
5030 + to free can be found in the TxHActiveQueue. If I need to get OsInfo
5031 + in the future, I can get it from one of those buffers.
5032 + OsInfo = HalDev->TcbHPool[Ch]->OsInfo; */
5033 +
5034 + if (HalDev->TxTeardownPending[Ch] & FULL_TEARDOWN)
5035 + {
5036 + FreeTx(HalDev, Ch, Queue);
5037 + } /* if FULL teardown */
5038 +
5039 + /* bug fix - clear Tx channel pointers on teardown */
5040 + HalDev->TcbPool[Ch][Queue] = 0;
5041 + HalDev->TxActQueueHead[Ch][Queue] = 0;
5042 + HalDev->TxActQueueCount[Ch][Queue] = 0;
5043 + HalDev->TxActive[Ch][Queue] = FALSE;
5044 +
5045 + /* write completion pointer */
5046 + (*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) = TEARDOWN_VAL;
5047 +
5048 + /* no longer pending teardown */
5049 + HalDev->TxTeardownPending[Ch] &= ~TX_TEARDOWN;
5050 +
5051 + HalDev->ChIsOpen[Ch][DIRECTION_TX] = 0;
5052 +
5053 + /* call OS Teardown Complete (if Rx is also done) */
5054 + if ((HalDev->RxTeardownPending[Ch] & RX_TEARDOWN) == 0)
5055 + {
5056 + /* mark channel as closed */
5057 + HalDev->ChIsOpen[Ch][DIRECTION_RX] = 0;
5058 +
5059 + /* disable channel interrupt */
5060 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
5061 + SAR_TX_MASK_CLR(HalDev->dev_base) = (1<<(Ch+16)); /* +GSG 030307 */
5062 + SAR_RX_MASK_CLR(HalDev->dev_base) = (1<<Ch);
5063 +
5064 + /* Clear PDSP Channel State RAM */
5065 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+(Ch*64));
5066 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
5067 + *pTmp++ = 0;
5068 +
5069 + if ((HalDev->TxTeardownPending[Ch] & BLOCKING_TEARDOWN) == 0)
5070 + {
5071 +
5072 + HalDev->OsFunc->TeardownComplete(HalDev->OsDev, Ch, DIRECTION_TX|DIRECTION_RX);
5073 + }
5074 +
5075 + /* clear all teardown pending information for this channel */
5076 + HalDev->RxTeardownPending[Ch] = 0;
5077 + HalDev->TxTeardownPending[Ch] = 0;
5078 + }
5079 +
5080 + return (EC_NO_ERRORS);
5081 + }
5082 + return (-1);
5083 + }
5084 +
5085 +/* +GSG 030421 */
5086 +static void AddToRxQueue(HAL_DEVICE *HalDev, HAL_RCB *FirstRcb, HAL_RCB *LastRcb, int FragCount, int Ch)
5087 + {
5088 + HAL_RCB *OldTailRcb;
5089 +
5090 + if (HalDev->RxActQueueCount[Ch]==0)
5091 + {
5092 +
5093 + HalDev->RxActQueueHead[Ch]=FirstRcb;
5094 + HalDev->RxActQueueTail[Ch]=LastRcb;
5095 + HalDev->RxActQueueCount[Ch]=FragCount;
5096 + if ((!HalDev->InRxInt[Ch])&&(!HalDev->RxActive[Ch]))
5097 + {
5098 + /* write Rx Queue Head Descriptor Pointer */
5099 + (*(pRX_DMA_STATE_WORD_1( HalDev->dev_base )+( Ch *64))) = VirtToPhys(FirstRcb) - HalDev->offset;
5100 + HalDev->RxActive[Ch]=TRUE;
5101 + }
5102 + }
5103 + else
5104 + {
5105 +
5106 + OldTailRcb=HalDev->RxActQueueTail[Ch];
5107 + OldTailRcb->Next=(void *)FirstRcb;
5108 +
5109 + /* Emerald fix 10/29 (Denis) */
5110 + *((bit32u *) VirtToVirtNoCache(&OldTailRcb->HNext))=VirtToPhys(FirstRcb) - HalDev->offset;
5111 +
5112 + HalDev->RxActQueueTail[Ch]=LastRcb;
5113 + HalDev->RxActQueueCount[Ch]+=FragCount;
5114 + }
5115 + }
5116 +
5117 +/**
5118 + * @ingroup CPHAL_Functions
5119 + * This function is called to indicate to the CPHAL that the upper layer
5120 + * software has finished processing the receive data (given to it by
5121 + * osReceive()). The CPHAL will then return the appropriate receive buffers
5122 + * and buffer descriptors to the available pool.
5123 + *
5124 + * @param HalReceiveInfo Start of receive buffer descriptor chain returned to
5125 + * CPHAL.
5126 + * @param StripFlag Flag indicating whether the upper layer software has
5127 + * retained ownership of the receive data buffers.
5128 + *<BR>
5129 + * 'FALSE' means that the CPHAL can reuse the receive data buffers.
5130 + *<BR>
5131 + * 'TRUE' : indicates the data buffers were retained by the OS
5132 + *<BR>
5133 + * NOTE: If StripFlag is TRUE, it is the responsibility of the upper layer software to free the buffers when they are no longer needed.
5134 + *
5135 + * @return EC_NO_ERRORS (ok). <BR>
5136 + * Possible Error Codes:<BR>
5137 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5138 + * @ref EC_VAL_RCB_NEEDS_BUFFER "EC_VAL_RCB_NEEDS_BUFFER"<BR>
5139 + * @ref EC_VAL_RCB_DROPPED "EC_VAL_RCB_DROPPED"<BR>
5140 + */
5141 +static int halRxReturn(HAL_RECEIVEINFO *HalReceiveInfo,
5142 + int StripFlag)
5143 + {
5144 + int Ch = HalReceiveInfo->Ch, i;
5145 + HAL_RCB *LastRcb, *TempRcb;
5146 + char *pBuf;
5147 + HAL_RCB *CurrHeadRcb = HalReceiveInfo, *LastGoodRcb=0; /* +GSG 030421 */
5148 + HAL_DEVICE *HalDev = HalReceiveInfo->HalDev;
5149 + int RcbSize = HalDev->ChData[Ch].RxBufSize;
5150 + int FragCount = HalReceiveInfo->FragCount;
5151 + int rc=0; /*MJH+030417*/
5152 + int GoodCount=0; /*GSG+030421*/
5153 +
5154 + if (HalDev->State != enOpened)
5155 + return(EC_AAL5 |EC_FUNC_RXRETURN|EC_VAL_INVALID_STATE);
5156 +
5157 + LastRcb=(HAL_RCB *)HalReceiveInfo->Eop;
5158 + LastRcb->HNext=0;
5159 + LastRcb->Next=0;
5160 +
5161 + if (FragCount>1)
5162 + {
5163 + LastRcb->Off_BLen=RcbSize;
5164 + LastRcb->mode=CB_OWNERSHIP_BIT;
5165 + }
5166 +
5167 + HalReceiveInfo->Off_BLen=RcbSize;
5168 + HalReceiveInfo->mode=CB_OWNERSHIP_BIT;
5169 +
5170 + /* If OS has kept the buffers for this packet, attempt to alloc new buffers */
5171 + if (StripFlag)
5172 + {
5173 + TempRcb = HalReceiveInfo;
5174 + for (i=0; i<FragCount; i++)
5175 + {
5176 + if (TempRcb == 0)
5177 + {
5178 + dbgPrintf("Rx Return error while allocating new buffers\n");
5179 + dbgPrintf("Rcb = %08x, Rcb->Eop = %08x, FragCount = %d:%d\n",
5180 + (bit32u)HalReceiveInfo, (bit32u)HalReceiveInfo->Eop, FragCount,i);
5181 + osfuncSioFlush();
5182 +
5183 + return(EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_CORRUPT_RCB_CHAIN);
5184 + }
5185 +
5186 + /* size = ((RcbSize+15) & ~15) + 15;*/ /*-3.01b*/
5187 + /*size = RcbSize + 15;*/ /* -GSG 030421 */
5188 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(RcbSize,0,
5189 + 0xF,HalDev->ChData[Ch].OsSetup,
5190 + (void *)TempRcb,
5191 + (void *)&TempRcb->OsInfo,
5192 + (void *) HalDev->OsDev);
5193 + if (!pBuf)
5194 + {
5195 + /* malloc failed, add this RCB to Needs Buffer List */
5196 + TempRcb->FragCount = 1; /*MJH+030417*/
5197 + (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
5198 +
5199 + if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
5200 + { /* +MJH 030410 */
5201 + HalDev->Needs[HalDev->NeedsCount] = (HAL_RECEIVEINFO *) TempRcb; /* +MJH 030410 */
5202 + HalDev->NeedsCount++; /* +MJH 030410 */
5203 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_NEEDS_BUFFER); /* ~MJH 030417 */
5204 + } /* +MJH 030410 */
5205 + else /* +MJH 030410 */
5206 + rc = (EC_CPPI|EC_FUNC_RXRETURN|EC_VAL_RCB_DROPPED); /* ~MJH 030417 */
5207 +
5208 + /* requeue any previous RCB's that were ready to go before this one */
5209 + if (GoodCount > 0) /* +GSG 030421 */
5210 + { /* +GSG 030421 */
5211 + LastGoodRcb->HNext=0; /* +GSG 030430 */
5212 + LastGoodRcb->Next=0; /* +GSG 030430 */
5213 + osfuncDataCacheHitWriteback((void *)LastGoodRcb, 16); /* +GSG 030430 */
5214 +
5215 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
5216 + GoodCount = 0; /* +GSG 030421 */
5217 + } /* +GSG 030421 */
5218 +
5219 + CurrHeadRcb = TempRcb->Next; /* +GSG 030421 */
5220 + }
5221 + else /* +GSG 030421 */
5222 + { /* +GSG 030421 */
5223 + /* malloc succeeded, requeue the RCB to the hardware */
5224 + TempRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
5225 + TempRcb->DatPtr=pBuf;
5226 + /* Emerald fix 10/29 */
5227 + osfuncDataCacheHitWriteback((void *)TempRcb, 16);
5228 +
5229 + /* i store the last good RCB in case the malloc fails for the
5230 + next fragment. This ensures that I can go ahead and return
5231 + a partial chain of RCB's to the hardware */
5232 + LastGoodRcb = TempRcb; /* +GSG 030421 */
5233 + GoodCount++; /* +GSG 030421 */
5234 + } /* +GSG 030421 */
5235 + TempRcb = TempRcb->Next;
5236 + } /* end of Frag loop */
5237 + /* if there any good RCB's to requeue, do so here */
5238 + if (GoodCount > 0) /* +GSG 030421 */
5239 + {
5240 + AddToRxQueue(HalDev, CurrHeadRcb, LastGoodRcb, GoodCount, Ch); /* +GSG 030421 */
5241 + }
5242 + return(rc); /* ~GSG 030421 */
5243 + }
5244 + else
5245 + {
5246 + /* Not Stripping */
5247 + /* Emerald */
5248 + /* Write Back SOP and last RCB */
5249 + osfuncDataCacheHitWriteback((void *)HalReceiveInfo, 16);
5250 +
5251 + if (FragCount > 1)
5252 + {
5253 + osfuncDataCacheHitWriteback((void *)LastRcb, 16);
5254 + }
5255 + /* if not stripping buffers, always add to queue */
5256 + AddToRxQueue(HalDev, HalReceiveInfo, LastRcb, FragCount, Ch); /*MJH~030520*/
5257 + }
5258 +
5259 + return(EC_NO_ERRORS);
5260 + }
5261 +
5262 +/* +MJH 030410
5263 + Trys to liberate an RCB until liberation fails.
5264 + Note: If liberation fails then RxReturn will re-add the RCB to the
5265 + Needs list.
5266 +*/
5267 +static void NeedsCheck(HAL_DEVICE *HalDev)
5268 +{
5269 + HAL_RECEIVEINFO* HalRcb;
5270 + int rc;
5271 + HalDev->OsFunc->CriticalOn();
5272 + while(HalDev->NeedsCount)
5273 + {
5274 + HalDev->NeedsCount--;
5275 + HalRcb = HalDev->Needs[HalDev->NeedsCount];
5276 + rc = halRxReturn(HalRcb, 1);
5277 + /* short circuit if RxReturn starts to fail */
5278 + if (rc != 0)
5279 + break;
5280 + }
5281 + HalDev->OsFunc->CriticalOff();
5282 +}
5283 +
5284 +/*
5285 + * This function allocates transmit buffer descriptors (internal CPHAL function).
5286 + * It creates a high priority transmit queue by default for a single Tx
5287 + * channel. If QoS is enabled for the given CPHAL device, this function
5288 + * will also allocate a low priority transmit queue.
5289 + *
5290 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5291 + * @param Ch Channel number.
5292 + *
5293 + * @return 0 OK, Non-Zero Not OK
5294 + */
5295 +static int InitTcb(HAL_DEVICE *HalDev, int Ch)
5296 + {
5297 + int i, Num = HalDev->ChData[Ch].TxNumBuffers;
5298 + HAL_TCB *pTcb=0;
5299 + char *AllTcb;
5300 + int tcbSize, Queue;
5301 + int SizeMalloc;
5302 +
5303 + tcbSize = (sizeof(HAL_TCB)+0xf)&~0xf;
5304 + SizeMalloc = (tcbSize*Num)+0xf;
5305 +
5306 + for (Queue=0; Queue < HalDev->ChData[Ch].TxNumQueues; Queue++)
5307 + {
5308 + if (HalDev->TcbStart[Ch][Queue] == 0)
5309 + {
5310 +
5311 + /* malloc all TCBs at once */
5312 + AllTcb = (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
5313 + if (!AllTcb)
5314 + {
5315 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_TCB_MALLOC_FAILED);
5316 + }
5317 +
5318 + HalDev->OsFunc->Memset(AllTcb, 0, SizeMalloc);
5319 +
5320 + /* keep this address for freeing later */
5321 + HalDev->TcbStart[Ch][Queue] = AllTcb;
5322 + }
5323 + else
5324 + {
5325 + /* if the memory has already been allocated, simply reuse it! */
5326 + AllTcb = HalDev->TcbStart[Ch][Queue];
5327 + }
5328 +
5329 + /* align to cache line */
5330 + AllTcb = (char *)(((bit32u)AllTcb + 0xf) &~ 0xf); /*PITS #143 MJH~030522*/
5331 +
5332 + /* default High priority transmit queue */
5333 + HalDev->TcbPool[Ch][Queue]=0;
5334 + for(i=0;i<Num;i++)
5335 + {
5336 + /*pTcb=(HAL_TCB *) OsFunc->MallocDmaXfer(sizeof(HAL_TCB),0,0xffffffff); */
5337 + pTcb= (HAL_TCB *)(AllTcb + (i*tcbSize));
5338 + pTcb->mode=0;
5339 + pTcb->BufPtr=0;
5340 + pTcb->Next=HalDev->TcbPool[Ch][Queue];
5341 + pTcb->Off_BLen=0;
5342 + HalDev->TcbPool[Ch][Queue]=pTcb;
5343 + }
5344 + /*HalDev->TcbEnd = pTcb;*/
5345 + }
5346 +
5347 + return(EC_NO_ERRORS);
5348 + }
5349 +
5350 +/*
5351 + * This function allocates receive buffer descriptors (internal CPHAL function).
5352 + * After allocation, the function 'queues' (gives to the hardware) the newly
5353 + * created receive buffers to enable packet reception.
5354 + *
5355 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5356 + * @param Ch Channel number.
5357 + *
5358 + * @return 0 OK, Non-Zero Not OK
5359 + */
5360 +static int InitRcb(HAL_DEVICE *HalDev, int Ch)
5361 + {
5362 + int i, Num = HalDev->ChData[Ch].RxNumBuffers;
5363 + int Size = HalDev->ChData[Ch].RxBufSize;
5364 + HAL_RCB *pRcb;
5365 + char *pBuf;
5366 + char *AllRcb;
5367 + int rcbSize;
5368 + int DoMalloc = 0;
5369 + int SizeMalloc;
5370 + int MallocSize;
5371 +
5372 + rcbSize = (sizeof(HAL_RCB)+0xf)&~0xf;
5373 + SizeMalloc = (rcbSize*Num)+0xf;
5374 +
5375 + if (HalDev->RcbStart[Ch] == 0)
5376 + {
5377 + DoMalloc = 1;
5378 +
5379 + /* malloc all RCBs at once */
5380 + AllRcb= (char *)HalDev->OsFunc->MallocDmaXfer(SizeMalloc,0,0xffffffff);
5381 + if (!AllRcb)
5382 + {
5383 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RCB_MALLOC_FAILED);
5384 + }
5385 +
5386 + HalDev->OsFunc->Memset(AllRcb, 0, SizeMalloc);
5387 +
5388 + /* keep this address for freeing later */
5389 + HalDev->RcbStart[Ch] = AllRcb;
5390 + }
5391 + else
5392 + {
5393 + /* if the memory has already been allocated, simply reuse it! */
5394 + AllRcb = HalDev->RcbStart[Ch];
5395 + }
5396 +
5397 + /* align to cache line */
5398 + AllRcb = (char *)(((bit32u)AllRcb + 0xf)&~0xf); /*PITS #143 MJH~030522*/
5399 +
5400 + HalDev->RcbPool[Ch]=0;
5401 + for(i=0;i<Num;i++)
5402 + {
5403 + pRcb = (HAL_RCB *)(AllRcb + (i*rcbSize));
5404 +
5405 + if (DoMalloc == 1)
5406 + {
5407 +
5408 + MallocSize = Size; /*~3.01 */
5409 + pBuf= (char *) HalDev->OsFunc->MallocRxBuffer(MallocSize,0,0xF,HalDev->ChData[Ch].OsSetup, (void *)pRcb, (void *)&pRcb->OsInfo, (void *) HalDev->OsDev);
5410 + if(!pBuf)
5411 + {
5412 + return(EC_CPPI|EC_FUNC_HAL_INIT|EC_VAL_RX_BUFFER_MALLOC_FAILED);
5413 + }
5414 + /* -RC3.01 pBuf = (char *)(((bit32u)pBuf+0xF) & ~0xF); */
5415 + pRcb->BufPtr=VirtToPhys(pBuf) - HalDev->offset;
5416 + pRcb->DatPtr=pBuf;
5417 + /*pRcb->BufSize=Size;*/
5418 + }
5419 + pRcb->mode=0;
5420 + pRcb->Ch=Ch;
5421 + pRcb->Next=(void *)HalDev->RcbPool[Ch];
5422 + pRcb->Off_BLen=0;
5423 + pRcb->HalDev = HalDev;
5424 + HalDev->RcbPool[Ch]=pRcb;
5425 + }
5426 +
5427 + /* Give all of the Rx buffers to hardware */
5428 +
5429 + while(HalDev->RcbPool[Ch])
5430 + {
5431 + pRcb=HalDev->RcbPool[Ch];
5432 + HalDev->RcbPool[Ch]=pRcb->Next;
5433 + pRcb->Eop=(void*)pRcb;
5434 + pRcb->FragCount=1;
5435 + halRxReturn((HAL_RECEIVEINFO *)pRcb, 0);
5436 + }
5437 +
5438 + return(EC_NO_ERRORS);
5439 + }
5440 +
5441 +/**
5442 + * @ingroup CPHAL_Functions
5443 + * This function transmits the data in FragList using available transmit
5444 + * buffer descriptors. More information on the use of the Mode parameter
5445 + * is available in the module-specific appendices. Note: The OS should
5446 + * not call Send() for a channel that has been requested to be torndown.
5447 + *
5448 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5449 + * @param FragList Fragment List structure.
5450 + * @param FragCount Number of fragments in FragList.
5451 + * @param PacketSize Number of bytes to transmit.
5452 + * @param OsSendInfo OS Send Information structure. <BR>
5453 + * @param Mode 32-bit value with the following bit fields: <BR>
5454 + * 31-16: Mode (used for module specific data). <BR>
5455 + * 15-08: Queue (transmit queue to send on). <BR>
5456 + * 07-00: Channel (channel number to send on).
5457 + *
5458 + * @return EC_NO_ERRORS (ok). <BR>
5459 + * Possible Error Codes:<BR>
5460 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
5461 + * @ref EC_VAL_NOT_LINKED "EC_VAL_NOT_LINKED"<BR>
5462 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
5463 + * @ref EC_VAL_OUT_OF_TCBS "EC_VAL_OUT_OF_TCBS"<BR>
5464 + * @ref EC_VAL_NO_TCBS "EC_VAL_NO_TCBS"<BR>
5465 + */
5466 +static int halSend(HAL_DEVICE *HalDev,FRAGLIST *FragList,
5467 + int FragCount,int PacketSize, OS_SENDINFO *OsSendInfo,
5468 + bit32u Mode)
5469 + {
5470 + HAL_TCB *tcb_ptr, *head;
5471 + int i;
5472 + bit32u base = HalDev->dev_base;
5473 + int rc = EC_NO_ERRORS;
5474 + int Ch = Mode & 0xFF;
5475 + int Queue = (Mode>>8)&0xFF;
5476 +
5477 + int WaitFlag = (Mode>>30)&1; /* This is for AAL5 testing only */ /* ~GSG 030508 */
5478 + int Offset = (FragList[0].len >> 16);
5479 + int PktType = (Mode>>16)&3; /* 0=AAL5, 1=Null AAL, 2=OAM, 3=Transparent */ /* +GSG 030508 */
5480 + int AtmHeaderInData = (Mode>>31)&1; /* +GSG 030508 */
5481 + int FragIndex = 0;
5482 +
5483 + if (HalDev->State != enOpened)
5484 + return(EC_CPPI|EC_FUNC_SEND|EC_VAL_INVALID_STATE);
5485 +
5486 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0) /*MJH~030611*/ /*PITS 148*/
5487 + return(EC_AAL5 |EC_FUNC_SEND|EC_VAL_INVALID_CH); /*+GSG 030303*/
5488 +
5489 + HalDev->OsFunc->CriticalOn();
5490 +
5491 + tcb_ptr = head = HalDev->TcbPool[Ch][Queue];
5492 +
5493 + if (tcb_ptr)
5494 + {
5495 +
5496 + /* these two TCB words are only valid on SOP */
5497 + if (AtmHeaderInData == 1)
5498 + {
5499 + tcb_ptr->AtmHeader = 0; /* bug fix for transparent mode PTI problem */
5500 + /* Expect AtmHeader in the data */
5501 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 24;
5502 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 16;
5503 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++) << 8;
5504 + tcb_ptr->AtmHeader |= *((bit8u *)FragList[FragIndex].data++);
5505 +
5506 + /* decrement data buffer length accordingly */
5507 + FragList[FragIndex].len -= ATM_HEADER_SIZE;
5508 +
5509 + /* if the first fragment was ATM Header only, go to next fragment for loop */
5510 + if (FragList[FragIndex].len == 0)
5511 + FragIndex++;
5512 +
5513 + /* No CPCS_UU/CPI if not AAL5 */
5514 + tcb_ptr->Word5 = ((PktType & 0x3)<<16);
5515 + }
5516 + else
5517 + {
5518 + /* calculate AtmHeader from fields */
5519 + tcb_ptr->AtmHeader = atmheader(HalDev->ChData[Ch].Gfc, /* ~GSG 030306 */
5520 + HalDev->ChData[Ch].Vpi, HalDev->ChData[Ch].Vci,
5521 + HalDev->ChData[Ch].Pti, HalDev->ChData[Ch].Clp);
5522 +
5523 + tcb_ptr->Word5 = HalDev->ChData[Ch].CpcsUU | ((HalDev->ChData[Ch].PktType &0x3)<<16);
5524 + }
5525 +
5526 + for (i=FragIndex; i<FragCount; i++)
5527 +
5528 + {
5529 + /* Setup Tx mode and size */
5530 + tcb_ptr->HNext = VirtToPhys((bit32 *)tcb_ptr->Next) - HalDev->offset;
5531 + tcb_ptr->Off_BLen = FragList[i].len;
5532 +
5533 + if (i==0)
5534 + tcb_ptr->Off_BLen |= (Offset << 16);
5535 +
5536 + tcb_ptr->mode = 0; /* MUST clear this for each frag !!! */
5537 + tcb_ptr->BufPtr = VirtToPhys((bit32 *)FragList[i].data) -
5538 + HalDev->offset;
5539 +
5540 + /* first fragment */
5541 + if (i == 0)
5542 + {
5543 + tcb_ptr->mode |= CB_SOF_BIT;
5544 +
5545 + }
5546 +
5547 + tcb_ptr->mode |= (PacketSize | CB_OWNERSHIP_BIT);
5548 + tcb_ptr->OsInfo = OsSendInfo;
5549 +
5550 + if (i == (FragCount - 1))
5551 + {
5552 + /* last fragment */
5553 + tcb_ptr->mode |= CB_EOF_BIT;
5554 +
5555 + /* since this is the last fragment, set the TcbPool pointer before
5556 + nulling out the Next pointers */
5557 +
5558 + HalDev->TcbPool[Ch][Queue] = tcb_ptr->Next;
5559 +
5560 + tcb_ptr->Next = 0;
5561 + tcb_ptr->HNext = 0;
5562 +
5563 + /* In the Tx Interrupt handler, we will need to know which TCB is EOP,
5564 + so we can save that information in the SOP */
5565 + head->Eop = tcb_ptr;
5566 +
5567 + /* Emerald fix 10/29 */
5568 + osfuncDataCacheHitWriteback((void *)tcb_ptr, 16);
5569 +
5570 + osfuncDataCacheHitWriteback((void *)((bit32u)tcb_ptr + 16), 16);
5571 +
5572 + }
5573 + else
5574 + {
5575 + /* Emerald fix 10/29 */
5576 + osfuncDataCacheHitWriteback((void *)tcb_ptr, 16);
5577 +
5578 + osfuncDataCacheHitWriteback((void *)((bit32u)tcb_ptr + 16), 16);
5579 +
5580 + tcb_ptr = tcb_ptr->Next; /* what about the end of TCB list?? */
5581 +
5582 + if (tcb_ptr == 0)
5583 + {
5584 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_OUT_OF_TCBS;
5585 + goto ExitSend;
5586 + }
5587 + }
5588 + } /* for */
5589 +
5590 + /* put it on the high priority queue */
5591 + if (HalDev->TxActQueueHead[Ch][Queue] == 0)
5592 + {
5593 + HalDev->TxActQueueHead[Ch][Queue]=head;
5594 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
5595 +/*+GSG 030303*//*+GSG 030303*/
5596 + if (!HalDev->TxActive[Ch][Queue])
5597 + {
5598 +
5599 + if (!WaitFlag)
5600 + {
5601 +
5602 + /* write CPPI TX HDP */
5603 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( Queue ))) = VirtToPhys(head) - HalDev->offset;
5604 + HalDev->TxActive[Ch][Queue]=TRUE;
5605 +
5606 + }
5607 +
5608 + }
5609 + }
5610 + else
5611 + {
5612 + HalDev->TxActQueueTail[Ch][Queue]->Next=head;
5613 + /* Emerald fix 10/29 */
5614 + *((bit32u *) VirtToVirtNoCache(&HalDev->TxActQueueTail[Ch][Queue]->HNext))=VirtToPhys(head) - HalDev->offset;
5615 + HalDev->TxActQueueTail[Ch][Queue]=tcb_ptr;
5616 +/*+GSG 030303*//*+GSG 030303*/
5617 + }
5618 + rc = EC_NO_ERRORS;
5619 + goto ExitSend;
5620 + } /* if (tcb_ptr) */
5621 + else
5622 + {
5623 + rc = EC_CPPI|EC_FUNC_SEND|EC_VAL_NO_TCBS;
5624 + goto ExitSend;
5625 + }
5626 +ExitSend:
5627 +
5628 + HalDev->OsFunc->CriticalOff();
5629 + return(rc);
5630 + }
5631 +
5632 +/*
5633 + * This function processes receive interrupts. It traverses the receive
5634 + * buffer queue, extracting the data and passing it to the upper layer software via
5635 + * osReceive(). It handles all error conditions and fragments without valid data by
5636 + * immediately returning the RCB's to the RCB pool.
5637 + *
5638 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5639 + * @param Ch Channel Number.
5640 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
5641 + *
5642 + * @return 0 if OK, non-zero otherwise.
5643 + */
5644 +static int RxInt(HAL_DEVICE *HalDev, int Ch, int *MoreWork)
5645 + {
5646 + HAL_RCB *CurrentRcb, *LastRcb=0, *SopRcb, *EofRcb, *EopRcb;
5647 + bit32u RxBufStatus,PacketsServiced, RxPktLen = 0, RxSopStatus,
5648 + FrmFrags, TotalFrags, CurrDmaLen, DmaLen, FrmLen;
5649 + int base = HalDev->dev_base, Ret;
5650 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
5651 + int RxServiceMax = HalDev->ChData[Ch].RxServiceMax;
5652 + int FragIndex; /* +GSG 030508 */
5653 + int EarlyReturn = 0; /* +GSG 030521 */
5654 +
5655 + bit32u PktType, ExpDmaSize, Cells;
5656 + int PassHeader=0;
5657 +
5658 + int mode;
5659 +
5660 + bit32u SopOffset;
5661 +
5662 + if(HalDev->NeedsCount) /* +MJH 030410 */
5663 + NeedsCheck(HalDev); /* +MJH 030410 */
5664 +
5665 + /* Handle case of teardown interrupt */
5666 + if (HalDev->RxTeardownPending[Ch] != 0)
5667 + {
5668 + Ret = RxTeardownInt(HalDev, Ch);
5669 + if (Ret == 0)
5670 + { /*+GSG 030303*/
5671 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
5672 + return (EC_NO_ERRORS);
5673 + } /*+GSG 030303*/
5674 + }
5675 +
5676 + CurrentRcb=HalDev->RxActQueueHead[Ch];
5677 +
5678 + osfuncDataCacheHitInvalidate((void*)CurrentRcb, 16);
5679 +
5680 + RxBufStatus=CurrentRcb->mode;
5681 +
5682 + /* I think I need to do this to ensure that i read UuCpi properly,
5683 + which is on the second cache line of the Rcb */
5684 + osfuncDataCacheHitInvalidate((void*)((bit32u)CurrentRcb+16), 16);
5685 +
5686 + PacketsServiced=0;
5687 + HalDev->InRxInt[Ch]=TRUE;
5688 +
5689 + while((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)&&
5690 + (PacketsServiced<RxServiceMax)) /* ~GSG 030307 */
5691 + {
5692 +
5693 + PacketsServiced++; /* ~GSG 030307 */
5694 + SopRcb=CurrentRcb;
5695 + RxSopStatus=RxBufStatus;
5696 +
5697 + RxPktLen = RxSopStatus&CB_SIZE_MASK;
5698 + /* Not sure what MAC needs to do for next block */
5699 +
5700 + PktType=((SopRcb->UuCpi & 0x00030000) >> 16); /* GSG ~030508 */
5701 + /* Calculate the expected DMA length */
5702 + if (RxPktLen != 0)
5703 + {
5704 + Cells=RxPktLen/48;
5705 + if ((RxPktLen%48) > 40)
5706 + Cells++;
5707 + if (PktType == PKT_TYPE_AAL5) /* ~GSG 030508 */
5708 + Cells++;
5709 + ExpDmaSize=Cells*48;
5710 + }
5711 + else
5712 + {
5713 + ExpDmaSize=0;
5714 + }
5715 +
5716 + SopOffset=(SopRcb->Off_BLen&CB_OFFSET_MASK)>>16;
5717 +
5718 + CurrDmaLen=0;
5719 + FrmFrags=0;
5720 + TotalFrags=0;
5721 + FragIndex=0;
5722 + FrmLen=0;
5723 + EofRcb=0;
5724 +
5725 +/* +GSG 030508 */
5726 + if ((PktType == PKT_TYPE_OAM) || (PktType == PKT_TYPE_TRANS)) /* +GSG 030508 */
5727 + { /* +GSG 030508 */
5728 + /* first frag is ATM Header */ /* +GSG 030508 */
5729 + PassHeader = 1; /* +GSG 030508 */
5730 + HalDev->fraglist[FragIndex].data = (void *)&SopRcb->AtmHeader; /* +GSG 030508 */
5731 + HalDev->fraglist[FragIndex].len = 4; /* +GSG 030508 */
5732 + HalDev->fraglist[FragIndex].OsInfo = SopRcb->OsInfo; /* +GSG 030701 */
5733 + FragIndex++; /* +GSG 030508 */
5734 + } /* +GSG 030508 */
5735 +/* +GSG 030508 */
5736 +
5737 + do
5738 + {
5739 +
5740 + DmaLen=CurrentRcb->Off_BLen&CB_SIZE_MASK;
5741 +
5742 + CurrDmaLen+=DmaLen;
5743 + FrmLen+=DmaLen;
5744 + TotalFrags++;
5745 + if (!EofRcb)
5746 + {
5747 + HalDev->fraglist[FragIndex].data=((char *)CurrentRcb->DatPtr); /* ~GSG 030508 */
5748 +
5749 + HalDev->fraglist[FragIndex].data+=((FrmFrags==0)?SopOffset:0); /* ~GSG 030508 */
5750 +
5751 + HalDev->fraglist[FragIndex].len=DmaLen; /* ~GSG 030508 */
5752 +
5753 + /* GSG 12/9 */
5754 + HalDev->fraglist[FragIndex].OsInfo = CurrentRcb->OsInfo; /* ~GSG 030508 */
5755 +
5756 + /* Upper layer must do the data invalidate */
5757 +
5758 + FrmFrags++;
5759 + FragIndex++; /* ~GSG 030508 */
5760 + if (FrmLen>=RxPktLen)
5761 + EofRcb=CurrentRcb;
5762 + }
5763 + LastRcb=CurrentRcb;
5764 + CurrentRcb=LastRcb->Next;
5765 + if (CurrentRcb)
5766 + {
5767 + osfuncDataCacheHitInvalidate((void*)CurrentRcb,16);
5768 + /* RxBufStatus=CurrentRcb->mode; */ /*DRB~030522*/
5769 + }
5770 + }while(((LastRcb->mode&CB_EOF_BIT)==0)&&(CurrentRcb));
5771 +
5772 + /* New location for interrupt acknowledge */
5773 + /* Write the completion pointer */
5774 + (*(pRX_CPPI_COMP_PTR( base )+( Ch *64))) = VirtToPhys(LastRcb) - HalDev->offset;
5775 +
5776 + EopRcb=LastRcb;
5777 + HalDev->RxActQueueHead[Ch]=CurrentRcb;
5778 + HalDev->RxActQueueCount[Ch]-=TotalFrags;
5779 +
5780 + if (LastRcb->mode&CB_EOQ_BIT)
5781 + {
5782 + if (CurrentRcb)
5783 + {
5784 +
5785 + HalDev->Stats.RxMisQCnt[Ch]++;
5786 +
5787 + (*(pRX_DMA_STATE_WORD_1( base )+( Ch *64))) = LastRcb->HNext;
5788 + }
5789 + else
5790 + {
5791 +
5792 + /* Rx EOQ */
5793 + HalDev->Stats.RxMisQCnt[Ch]++;
5794 +
5795 + HalDev->RxActive[Ch]=FALSE;
5796 + }
5797 + }
5798 +
5799 + EopRcb->Next=0;
5800 +
5801 + /* setup SopRcb for the packet */
5802 + SopRcb->Eop=(void*)EopRcb;
5803 + SopRcb->FragCount=TotalFrags;
5804 +
5805 + if ((ExpDmaSize!=CurrDmaLen)||(RxSopStatus&RX_ERROR_MASK))
5806 + {
5807 + /* check for Rx errors (only valid on SOP) */
5808 + if (RxSopStatus & RX_ERROR_MASK)
5809 + {
5810 + if (RxSopStatus & CRC_ERROR_MASK)
5811 + HalDev->Stats.CrcErrors[Ch]++;
5812 +
5813 + if (RxSopStatus & LENGTH_ERROR_MASK)
5814 + HalDev->Stats.LenErrors[Ch]++;
5815 +
5816 + if (RxSopStatus & ABORT_ERROR_MASK)
5817 + HalDev->Stats.AbortErrors[Ch]++;
5818 +
5819 + if (RxSopStatus & STARV_ERROR_MASK)
5820 + HalDev->Stats.StarvErrors[Ch]++;
5821 + }
5822 + else
5823 + {
5824 + HalDev->Stats.DmaLenErrors[Ch]++; /* different type of length error */
5825 + }
5826 +
5827 + EarlyReturn = 1;
5828 + }
5829 +
5830 + /* do not pass up the packet if we're out of RCB's (or have an errored packet)*/
5831 + if ((CurrentRcb == 0) || (EarlyReturn == 1))
5832 + {
5833 + halRxReturn((HAL_RECEIVEINFO *)SopRcb,0);
5834 + }
5835 + else
5836 + {
5837 +
5838 + if (EopRcb!=EofRcb)
5839 + {
5840 + HAL_RCB *FirstEmptyRcb;
5841 +
5842 + FirstEmptyRcb = EofRcb->Next;
5843 + FirstEmptyRcb->Eop = (void*)EopRcb;
5844 + FirstEmptyRcb->FragCount = TotalFrags-FrmFrags;
5845 +
5846 + halRxReturn((HAL_RECEIVEINFO *)FirstEmptyRcb,0);
5847 + SopRcb->Eop=(void*)EofRcb;
5848 + SopRcb->FragCount=FrmFrags;
5849 + EofRcb->Next=0; /* Optional */
5850 + }
5851 +
5852 + mode = Ch | (PktType << 16) | (PassHeader << 31); /* ~GSG 030508 */
5853 +
5854 + OsFunc->Receive(HalDev->OsDev,HalDev->fraglist,FragIndex,RxPktLen, /* ~GSG 030508 */
5855 + (HAL_RECEIVEINFO *)SopRcb,mode);
5856 + } /* else */
5857 +
5858 + if (CurrentRcb) /*MJH+030522*/
5859 + {
5860 + RxBufStatus=CurrentRcb->mode;
5861 + }
5862 + } /* while */
5863 +
5864 + if ((CurrentRcb)&&((RxBufStatus&CB_OWNERSHIP_BIT)==0)) /*~GSG 030307*/
5865 + {
5866 + *MoreWork = 1;
5867 + }
5868 + else
5869 + {
5870 + *MoreWork = 0;
5871 + }
5872 +
5873 + if (PacketsServiced != 0)
5874 + {
5875 + /* REMOVED when removing InRxInt */
5876 + if ((!HalDev->RxActive[Ch]) && (HalDev->RxActQueueCount[Ch]))
5877 + {
5878 + (*(pRX_DMA_STATE_WORD_1( base )+( Ch *64))) = VirtToPhys(HalDev->RxActQueueHead[Ch]);
5879 + HalDev->RxActive[Ch]=TRUE;
5880 + }
5881 + }
5882 +
5883 + HalDev->InRxInt[Ch]=FALSE;
5884 +
5885 + /* update stats */
5886 + HalDev->Stats.RxPacketsServiced[Ch] += PacketsServiced;
5887 + HalDev->Stats.RxTotal += PacketsServiced;
5888 + if (HalDev->Stats.RxMaxServiced < PacketsServiced)
5889 + HalDev->Stats.RxMaxServiced = PacketsServiced;
5890 +
5891 + return (EC_NO_ERRORS);
5892 + }
5893 +
5894 +/*
5895 + * This function processes transmit interrupts. It traverses the
5896 + * transmit buffer queue, detecting sent data buffers and notifying the upper
5897 + * layer software via osSendComplete(). (for SAR, i originally had this split
5898 + * into two functions, one for each queue, but joined them on 8/8/02)
5899 + *
5900 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
5901 + * @param Queue Queue number to service (always 0 for MAC, Choose 1 for SAR to service low priority queue)
5902 + * @param MoreWork Flag that indicates that there is more work to do when set to 1.
5903 + *
5904 + * @return 0 if OK, non-zero otherwise.
5905 + */
5906 +static int TxInt(HAL_DEVICE *HalDev, int Ch, int Queue, int *MoreWork)
5907 + {
5908 + HAL_TCB *CurrentTcb,*LastTcbProcessed,*FirstTcbProcessed;
5909 + int PacketsServiced;
5910 + bit32u TxFrameStatus;
5911 + int base = HalDev->dev_base, Ret;
5912 + int TxServiceMax = HalDev->ChData[Ch].TxServiceMax;
5913 + OS_FUNCTIONS *OsFunc = HalDev->OsFunc;
5914 +
5915 + int OtherQueue = Queue^1;
5916 +
5917 +/*+GSG 030303*//*+GSG 030303*/
5918 +
5919 + /* Handle case of teardown interrupt. This must be checked at
5920 + the top of the function rather than the bottom, because
5921 + the normal data processing can wipe out the completion
5922 + pointer which is used to determine teardown complete. */
5923 + if (HalDev->TxTeardownPending[Ch] != 0)
5924 + {
5925 + Ret = TxTeardownInt(HalDev, Ch, Queue);
5926 + if (Ret == 0)
5927 + { /*+GSG 030303*/
5928 + *MoreWork = 0; /* bug fix 1/6 */ /*+GSG 030303*/
5929 + return (EC_NO_ERRORS);
5930 + } /*+GSG 030303*/
5931 + }
5932 +
5933 + CurrentTcb = HalDev->TxActQueueHead[Ch][Queue];
5934 + FirstTcbProcessed=CurrentTcb;
5935 +
5936 + if (CurrentTcb==0)
5937 + {
5938 + /* I saw this error a couple of times when multi-channels were added */
5939 + dbgPrintf("[cppi TxInt()]TxH int with no TCB in queue!\n");
5940 + dbgPrintf(" Ch=%d, CurrentTcb = 0x%08x\n", Ch, (bit32u)CurrentTcb);
5941 + dbgPrintf(" HalDev = 0x%08x\n", (bit32u)HalDev);
5942 + osfuncSioFlush();
5943 + return(EC_CPPI|EC_FUNC_TXINT|EC_VAL_NULL_TCB);
5944 + }
5945 +
5946 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
5947 + TxFrameStatus=CurrentTcb->mode;
5948 + PacketsServiced=0;
5949 +
5950 + /* should the ownership bit check be inside of the loop?? could make it a
5951 + while-do loop and take this check away */
5952 + if ((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
5953 + {
5954 + OsFunc->CriticalOn(); /* +GSG 030307 */
5955 + do
5956 + {
5957 + /* Pop TCB(s) for packet from the stack */
5958 + LastTcbProcessed=CurrentTcb->Eop;
5959 +
5960 + /* new location for acknowledge */
5961 + /* Write the completion pointer */
5962 + (*(pTXH_CPPI_COMP_PTR( base )+( Ch *64)+( Queue ))) = VirtToPhys(LastTcbProcessed);
5963 +
5964 + HalDev->TxActQueueHead[Ch][Queue] = LastTcbProcessed->Next;
5965 +
5966 +/*+GSG 030303*//*+GSG 030303*/
5967 +
5968 + osfuncDataCacheHitInvalidate((void *)LastTcbProcessed, 16);
5969 +
5970 + if (LastTcbProcessed->mode&CB_EOQ_BIT)
5971 + {
5972 + if (LastTcbProcessed->Next)
5973 + {
5974 + /* Misqueued packet */
5975 +
5976 + HalDev->Stats.TxMisQCnt[Ch][Queue]++;
5977 +
5978 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( Queue ))) = LastTcbProcessed->HNext;
5979 + }
5980 + else
5981 + {
5982 + /* Tx End of Queue */
5983 +
5984 + HalDev->Stats.TxEOQCnt[Ch][Queue]++;
5985 +
5986 + HalDev->TxActive[Ch][Queue]=FALSE;
5987 + }
5988 + }
5989 +
5990 + OsFunc->SendComplete(CurrentTcb->OsInfo);
5991 +
5992 + /* Push Tcb(s) back onto the stack */
5993 + CurrentTcb = LastTcbProcessed->Next;
5994 +
5995 + LastTcbProcessed->Next=HalDev->TcbPool[Ch][Queue];
5996 +
5997 + HalDev->TcbPool[Ch][Queue]=FirstTcbProcessed;
5998 +
5999 + PacketsServiced++;
6000 +
6001 + TxFrameStatus=CB_OWNERSHIP_BIT;
6002 + /* set the first(SOP) pointer for the next packet */
6003 + FirstTcbProcessed = CurrentTcb;
6004 + if (CurrentTcb)
6005 + {
6006 + osfuncDataCacheHitInvalidate((void *)CurrentTcb, 16);
6007 + TxFrameStatus=CurrentTcb->mode;
6008 + }
6009 +
6010 + }while(((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6011 + &&(PacketsServiced<TxServiceMax));
6012 +
6013 + /* this fixes the SAR TurboDSL hardware bug (multiple queue failure) */
6014 + if (HalDev->TxActive[Ch][OtherQueue])
6015 + if (HalDev->TxActQueueHead[Ch][OtherQueue])
6016 + if ((*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( OtherQueue ))) == 0)
6017 + {
6018 + osfuncDataCacheHitInvalidate(HalDev->TxActQueueHead[Ch][OtherQueue],16);
6019 + if ((HalDev->TxActQueueHead[Ch][OtherQueue]->mode) & CB_OWNERSHIP_BIT)
6020 + {
6021 + HalDev->TurboDslErrors++;
6022 + (*(pTX_DMA_STATE_WORD_0( base )+( Ch *64)+( OtherQueue ))) =
6023 + VirtToPhys(HalDev->TxActQueueHead[Ch][OtherQueue]);
6024 + }
6025 + }
6026 +
6027 + OsFunc->CriticalOff(); /* +GSG 030307 */
6028 + if (((TxFrameStatus&CB_OWNERSHIP_BIT)==0)
6029 + &&(PacketsServiced==TxServiceMax))
6030 + {
6031 + *MoreWork = 1;
6032 + }
6033 + else
6034 + {
6035 + *MoreWork = 0;
6036 + }
6037 + }
6038 +
6039 + /* update stats */
6040 + HalDev->Stats.TxPacketsServiced[Ch][Queue] += PacketsServiced;
6041 + HalDev->Stats.TxTotal += PacketsServiced;
6042 + if (HalDev->Stats.TxMaxServiced[Ch][Queue] < PacketsServiced)
6043 + HalDev->Stats.TxMaxServiced[Ch][Queue] = PacketsServiced;
6044 +
6045 + return(EC_NO_ERRORS);
6046 + }
6047 +
6048 +/**
6049 + * @ingroup CPHAL_Functions
6050 + * This function performs a teardown for the given channel. The value of the
6051 + * Mode parameter controls the operation of the function, as documented below.
6052 + *
6053 + * Note: If bit 3 of Mode is set, this call is blocking, and will not return
6054 + * until the teardown interrupt has occurred and been processed. While waiting
6055 + * for a blocking teardown to complete, ChannelTeardown() will signal the OS
6056 + * (via Control(.."Sleep"..)) to allow the OS to perform other tasks if
6057 + * necessary. If and only if bit 3 of Mode is clear, the CPHAL will call the
6058 + * OS TeardownComplete() function to indicate that the teardown has completed.
6059 + *
6060 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6061 + * @param Ch Channel number.
6062 + * @param Mode Bit 0 (LSB): Perform Tx teardown (if set).<BR>
6063 + * Bit 1: Perform Rx teardown (if set). <BR>
6064 + * Bit 2: If set, perform full teardown (free buffers/descriptors).
6065 + * If clear, perform partial teardown (keep buffers). <BR>
6066 + * Bit 3 (MSB): If set, call is blocking.
6067 + * If clear, call is non-blocking.
6068 + *
6069 + * @return EC_NO_ERRORS (ok). <BR>
6070 + * Possible Error Codes:<BR>
6071 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6072 + * @ref EC_VAL_INVALID_CH "EC_VAL_INVALID_CH"<BR>
6073 + * @ref EC_VAL_TX_TEARDOWN_ALREADY_PEND "EC_VAL_TX_TEARDOWN_ALREADY_PEND"<BR>
6074 + * @ref EC_VAL_RX_TEARDOWN_ALREADY_PEND "EC_VAL_RX_TEARDOWN_ALREADY_PEND"<BR>
6075 + * @ref EC_VAL_TX_CH_ALREADY_TORNDOWN "EC_VAL_TX_CH_ALREADY_TORNDOWN"<BR>
6076 + * @ref EC_VAL_RX_CH_ALREADY_TORNDOWN "EC_VAL_RX_CH_ALREADY_TORNDOWN"<BR>
6077 + * @ref EC_VAL_TX_TEARDOWN_TIMEOUT "EC_VAL_TX_TEARDOWN_TIMEOUT"<BR>
6078 + * @ref EC_VAL_RX_TEARDOWN_TIMEOUT "EC_VAL_RX_TEARDOWN_TIMEOUT"<BR>
6079 + * @ref EC_VAL_LUT_NOT_READY "EC_VAL_LUT_NOT_READY"<BR>
6080 + */
6081 +static int halChannelTeardown(HAL_DEVICE *HalDev, int Ch, bit32 Mode)
6082 + {
6083 + int DoTx, DoRx, Sleep=2048, timeout=0; /*MJH~030306*/
6084 + bit32u base = HalDev->dev_base;
6085 +
6086 +/* Set the module, used for error returns */
6087 +
6088 + int Ret;
6089 +
6090 + /* AAL5 only supports tearing down both sides at once (currently)*/
6091 + Mode = (Mode | TX_TEARDOWN | RX_TEARDOWN);
6092 +
6093 + DoTx = (Mode & TX_TEARDOWN);
6094 + DoRx = (Mode & RX_TEARDOWN);
6095 +
6096 + if (HalDev->State < enInitialized)
6097 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_STATE);
6098 +
6099 + if ((Ch < 0) || (Ch > MAX_AAL5_CHAN ))
6100 + {
6101 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6102 + }
6103 +
6104 + /* set teardown pending bits before performing the teardown, because they
6105 + will be used in the int handler (this is done for AAL5) */
6106 + if (DoTx)
6107 + {
6108 + if (HalDev->TxTeardownPending[Ch] != 0)
6109 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_ALREADY_PEND);
6110 +
6111 + /* If a full teardown, this also means that the user must
6112 + setup all channels again to use them */
6113 + if (Mode & FULL_TEARDOWN)
6114 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6115 +
6116 + if (HalDev->State < enOpened)
6117 + {
6118 + /* if the hardware has never been opened, the channel has never actually
6119 + been setup in the hardware, so I just need to reset the software flag
6120 + and leave */
6121 + HalDev->ChIsSetup[Ch][DIRECTION_TX] = 0;
6122 + return (EC_NO_ERRORS);
6123 + }
6124 + else
6125 + {
6126 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == 0)
6127 + {
6128 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_CH_ALREADY_TORNDOWN);
6129 + }
6130 +
6131 + /* set teardown flag */
6132 + HalDev->TxTeardownPending[Ch] = Mode;
6133 + }
6134 + }
6135 +
6136 + if (DoRx)
6137 + {
6138 + if (HalDev->RxTeardownPending[Ch] != 0)
6139 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_ALREADY_PEND);
6140 +
6141 + if (Mode & FULL_TEARDOWN)
6142 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6143 +
6144 + if (HalDev->State < enOpened)
6145 + {
6146 + HalDev->ChIsSetup[Ch][DIRECTION_RX] = 0;
6147 + return (EC_NO_ERRORS);
6148 + }
6149 + else
6150 + {
6151 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == 0)
6152 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_CH_ALREADY_TORNDOWN);
6153 +
6154 + HalDev->RxTeardownPending[Ch] = Mode;
6155 + }
6156 + }
6157 +
6158 + /* Perform Tx Teardown Duties */
6159 + if ((DoTx) && (HalDev->State == enOpened))
6160 + {
6161 + /* Request TX channel teardown */
6162 + (TX_CPPI_TEARDOWN_REG( base )) = Ch;
6163 +
6164 + /* wait until teardown has completed */
6165 + if (Mode & BLOCKING_TEARDOWN)
6166 + {
6167 + timeout = 0;
6168 + while (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6169 + {
6170 + osfuncSleep(&Sleep);
6171 +
6172 + timeout++;
6173 + if (timeout > 100000)
6174 + {
6175 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_TX_TEARDOWN_TIMEOUT);
6176 + }
6177 + }
6178 + }
6179 + } /* if DoTx */
6180 +
6181 + /* Perform Rx Teardown Duties */
6182 + if ((DoRx) && (HalDev->State == enOpened))
6183 + {
6184 +
6185 + /* call main teardown routine for Rx */
6186 + Ret = HalDev->SarFunc->ChannelTeardown(HalDev->SarDev, Ch, Mode);
6187 + if (Ret) return (Ret);
6188 +
6189 + if (Mode & BLOCKING_TEARDOWN)
6190 + {
6191 + timeout = 0;
6192 + while (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6193 + {
6194 + osfuncSleep(&Sleep);
6195 +
6196 + timeout++;
6197 + if (timeout > 100000)
6198 + {
6199 + return(EC_AAL5 |EC_FUNC_CHTEARDOWN|EC_VAL_RX_TEARDOWN_TIMEOUT);
6200 + }
6201 + }
6202 + }
6203 + } /* if DoRx */
6204 +
6205 + return (EC_NO_ERRORS);
6206 + }
6207 +
6208 +/**
6209 + * @ingroup CPHAL_Functions
6210 + * This function closes the CPHAL module. The module will be reset.
6211 + * The Mode parameter should be used to determine the actions taken by
6212 + * Close().
6213 + *
6214 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6215 + * @param Mode Indicates actions to take on close. The following integer
6216 + * values are valid: <BR>
6217 + * 1: Does not free buffer resources, init parameters remain
6218 + * intact. User can then call Open() without calling Init()
6219 + * to attempt to reset the device and bring it back to the
6220 + * last known state.<BR>
6221 + * 2: Frees the buffer resources, but keeps init parameters. This
6222 + * option is a more aggressive means of attempting a device reset.
6223 + * 3: Frees the buffer resources, and clears all init parameters. <BR>
6224 + * At this point, the caller would have to call to completely
6225 + * reinitialize the device (Init()) before being able to call
6226 + * Open(). Use this mode if you are shutting down the module
6227 + * and do not plan to restart.
6228 + *
6229 + * @return EC_NO_ERRORS (ok).<BR>
6230 + * Possible Error Codes:<BR>
6231 + * @ref EC_VAL_INVALID_STATE "EC_VAL_INVALID_STATE"<BR>
6232 + * Any error code from halChannelTeardown().<BR>
6233 + */
6234 +static int halClose(HAL_DEVICE *HalDev, bit32 Mode)
6235 + {
6236 + int Ch, Inst, Ret;
6237 + OS_DEVICE *TmpOsDev;
6238 + OS_FUNCTIONS *TmpOsFunc;
6239 + HAL_FUNCTIONS *TmpHalFunc;
6240 + char *TmpDeviceInfo;
6241 +
6242 + CPSAR_FUNCTIONS *TmpSarFunc;
6243 + CPSAR_DEVICE *TmpSarDev;
6244 +
6245 + /* Verify proper device state */
6246 + if (HalDev->State != enOpened)
6247 + return (EC_AAL5 | EC_FUNC_CLOSE|EC_VAL_INVALID_STATE);
6248 +
6249 + /* Teardown all open channels */
6250 + for (Ch = 0; Ch <= MAX_AAL5_CHAN ; Ch++)
6251 + {
6252 + if (HalDev->ChIsOpen[Ch][DIRECTION_TX] == TRUE)
6253 + {
6254 + if (Mode == 1)
6255 + {
6256 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6257 + if (Ret) return (Ret);
6258 + }
6259 + else
6260 + {
6261 + Ret = halChannelTeardown(HalDev, Ch, TX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6262 + if (Ret) return (Ret);
6263 + }
6264 + }
6265 +
6266 + if (HalDev->ChIsOpen[Ch][DIRECTION_RX] == TRUE)
6267 + {
6268 + if (Mode == 1)
6269 + {
6270 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | PARTIAL_TEARDOWN | BLOCKING_TEARDOWN);
6271 + if (Ret) return (Ret);
6272 + }
6273 + else
6274 + {
6275 + Ret = halChannelTeardown(HalDev, Ch, RX_TEARDOWN | FULL_TEARDOWN | BLOCKING_TEARDOWN);
6276 + if (Ret) return (Ret);
6277 + }
6278 + }
6279 + }
6280 +
6281 + /* free fraglist in HalDev */
6282 + HalDev->OsFunc->Free(HalDev->fraglist);
6283 + HalDev->fraglist = 0;
6284 +
6285 + /* unregister the interrupt */
6286 + HalDev->OsFunc->IsrUnRegister(HalDev->OsDev, HalDev->interrupt);
6287 +
6288 + /* Disable the Tx CPPI DMA */
6289 + TX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6290 +
6291 + /* Disable the Rx CPPI DMA */
6292 + RX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6293 +
6294 + /* Close the SAR hardware - puts the device in reset if this module is the
6295 + "last one out" */
6296 + HalDev->SarFunc->Close(HalDev->SarDev, Mode);
6297 +
6298 + /* If mode is 3, than clear the HalDev and set next state to DevFound*/
6299 + if (Mode == 3)
6300 + {
6301 + /* I need to keep the HalDev parameters that were setup in InitModule */
6302 + TmpOsDev = HalDev->OsDev;
6303 + TmpOsFunc = HalDev->OsFunc;
6304 + TmpDeviceInfo = HalDev->DeviceInfo;
6305 +
6306 + TmpSarFunc = HalDev->SarFunc;
6307 + TmpSarDev = HalDev->SarDev;
6308 +
6309 + TmpHalFunc = HalDev->HalFuncPtr;
6310 + Inst = HalDev->Inst;
6311 +
6312 + /* Clear HalDev */
6313 +
6314 + HalDev->OsFunc->Memset(HalDev, 0, sizeof(HAL_DEVICE));
6315 +
6316 + /* Restore key parameters */
6317 + HalDev->OsDev = TmpOsDev;
6318 + HalDev->OsFunc = TmpOsFunc;
6319 + HalDev->DeviceInfo = TmpDeviceInfo;
6320 +
6321 + HalDev->SarFunc = TmpSarFunc;
6322 + HalDev->SarDev = TmpSarDev;
6323 +
6324 + HalDev->HalFuncPtr = TmpHalFunc;
6325 + HalDev->Inst = Inst;
6326 +
6327 + HalDev->State = enDevFound;
6328 + }
6329 + else
6330 + {
6331 + HalDev->State = enInitialized;
6332 + }
6333 +
6334 + return(EC_NO_ERRORS);
6335 + }
6336 diff -urN linux.old/drivers/atm/sangam_atm/cpremap_cpaal5.c linux.dev/drivers/atm/sangam_atm/cpremap_cpaal5.c
6337 --- linux.old/drivers/atm/sangam_atm/cpremap_cpaal5.c 1970-01-01 01:00:00.000000000 +0100
6338 +++ linux.dev/drivers/atm/sangam_atm/cpremap_cpaal5.c 2005-08-23 04:46:50.084845672 +0200
6339 @@ -0,0 +1,27 @@
6340 +#ifndef _INC_CPREMAP_C
6341 +#define _INC_CPREMAP_C
6342 +
6343 +#ifdef __ADAM2
6344 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
6345 + {
6346 + asm(" cache 17, (%0)" : : "r" (ptr));
6347 + }
6348 +
6349 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
6350 + {
6351 + asm(" cache 25, (%0)" : : "r" (ptr));
6352 + }
6353 +
6354 +#else
6355 + #define osfuncDataCacheHitInvalidate(MemPtr, Size) HalDev->OsFunc->DataCacheHitInvalidate(MemPtr, Size)
6356 + #define osfuncDataCacheHitWriteback(MemPtr, Size) HalDev->OsFunc->DataCacheHitWriteback(MemPtr, Size)
6357 +#endif
6358 +
6359 +/*
6360 +#define osfuncDataCacheHitInvalidate(ptr, Size) asm(" cache 17, (%0)" : : "r" (ptr))
6361 +#define osfuncDataCacheHitWriteback(ptr, Size) asm(" cache 25, (%0)" : : "r" (ptr))
6362 +*/
6363 +
6364 +
6365 +
6366 +#endif
6367 diff -urN linux.old/drivers/atm/sangam_atm/cpremap_cpsar.c linux.dev/drivers/atm/sangam_atm/cpremap_cpsar.c
6368 --- linux.old/drivers/atm/sangam_atm/cpremap_cpsar.c 1970-01-01 01:00:00.000000000 +0100
6369 +++ linux.dev/drivers/atm/sangam_atm/cpremap_cpsar.c 2005-08-23 04:46:50.084845672 +0200
6370 @@ -0,0 +1,27 @@
6371 +#ifndef _INC_CPREMAP_C
6372 +#define _INC_CPREMAP_C
6373 +
6374 +#ifdef __ADAM2
6375 +static inline void osfuncDataCacheHitInvalidate(void *ptr, int Size)
6376 + {
6377 + asm(" cache 17, (%0)" : : "r" (ptr));
6378 + }
6379 +
6380 +static inline void osfuncDataCacheHitWriteback(void *ptr, int Size)
6381 + {
6382 + asm(" cache 25, (%0)" : : "r" (ptr));
6383 + }
6384 +
6385 +#else
6386 + #define osfuncDataCacheHitInvalidate(MemPtr, Size) HalDev->OsFunc->DataCacheHitInvalidate(MemPtr, Size)
6387 + #define osfuncDataCacheHitWriteback(MemPtr, Size) HalDev->OsFunc->DataCacheHitWriteback(MemPtr, Size)
6388 +#endif
6389 +
6390 +/*
6391 +#define osfuncDataCacheHitInvalidate(ptr, Size) asm(" cache 17, (%0)" : : "r" (ptr))
6392 +#define osfuncDataCacheHitWriteback(ptr, Size) asm(" cache 25, (%0)" : : "r" (ptr))
6393 +*/
6394 +
6395 +
6396 +
6397 +#endif
6398 diff -urN linux.old/drivers/atm/sangam_atm/cpsar.c linux.dev/drivers/atm/sangam_atm/cpsar.c
6399 --- linux.old/drivers/atm/sangam_atm/cpsar.c 1970-01-01 01:00:00.000000000 +0100
6400 +++ linux.dev/drivers/atm/sangam_atm/cpsar.c 2005-08-23 04:46:50.086845368 +0200
6401 @@ -0,0 +1,881 @@
6402 +/**
6403 + * cpsar.c
6404 + *
6405 + * TNETDxxxx Software Support\n
6406 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
6407 + *
6408 + * This file contains the HAL for the CPSAR module. In the software
6409 + * architecture, the CPSAR module is used exclusively by the AAL5 and AAL2
6410 + * CPHAL modules. AAL5 and AAL2 may utilize the same CPSAR instance
6411 + * simulataneously.
6412 + *
6413 + * version
6414 + * 5Sep02 Greg 1.00 Original Version created.
6415 + */
6416 +
6417 +/* register files */
6418 +#include "cp_sar_reg.h"
6419 +
6420 +#define _CPHAL_CPSAR
6421 +#define _CPHAL
6422 +
6423 +#define WAIT_THRESH 200000
6424 +#define IRAM_SIZE 1536
6425 +#define MAX_INST 2
6426 +
6427 +/* OS Data Structure definition */
6428 +
6429 +typedef void OS_PRIVATE;
6430 +typedef void OS_DEVICE;
6431 +typedef void OS_SENDINFO;
6432 +typedef void OS_RECEIVEINFO;
6433 +typedef void OS_SETUP;
6434 +
6435 +/* CPHAL Data Structure definitions */
6436 +
6437 +typedef struct cpsar_device CPSAR_DEVICE;
6438 +typedef struct cpsar_device HAL_DEVICE;
6439 +typedef void HAL_RECEIVEINFO;
6440 +
6441 +#define MAX_QUEUE 2
6442 +#define MAX_CHAN 19
6443 +
6444 +#include "cpcommon_cpsar.h"
6445 +#include "cpswhal_cpsar.h"
6446 +#include "cpsar.h"
6447 +#include "cpcommon_cpsar.c"
6448 +
6449 +static CPSAR_DEVICE *CpsarDev[MAX_INST]= {0,0};
6450 +
6451 +/*
6452 + * Returns statistics information.
6453 + *
6454 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6455 + *
6456 + * @return 0
6457 + */
6458 +static int StatsGet3(CPSAR_DEVICE *HalDev)
6459 + {
6460 +
6461 +#ifdef __CPHAL_DEBUG
6462 + if (DBG(0))
6463 + {
6464 + dbgPrintf("[cpsar]StatsGet3(HalDev:%08x)\n", (bit32u)HalDev);
6465 + osfuncSioFlush();
6466 + }
6467 +#endif
6468 + /*
6469 + dbgPrintf("CPSAR General Stats:\n");
6470 + DispHexStat(HalDev, "Base Address",HalDev->dev_base);
6471 + DispStat(HalDev, "Offset (VLYNQ)",HalDev->offset);
6472 + DispStat(HalDev, "Debug Level",HalDev->debug);
6473 + DispStat(HalDev, "Instance",HalDev->Inst);
6474 + DispHexStat(HalDev, "Reset Address",HalDev->ResetBase);
6475 + DispStat(HalDev, "Reset Bit",HalDev->ResetBit);
6476 + */
6477 + return (EC_NO_ERRORS);
6478 + }
6479 +
6480 +/* +GSG 030407 */
6481 +static void SetOamMode(HAL_DEVICE *HalDev)
6482 + {
6483 + int Ch;
6484 + volatile bit32u *pTmp;
6485 + int OamMode = (1<<8);
6486 +
6487 + /* any configuration of OamMode affects all VC's, including AAL2 */
6488 + for (Ch = 0; Ch < MAX_CHAN; Ch++)
6489 + {
6490 + if (Ch < 16)
6491 + pTmp = (pPDSP_AAL5_RX_STATE_WORD_0(HalDev->dev_base) + (Ch*64));
6492 + else
6493 + pTmp = (pPDSP_AAL2_RX_STATE_WORD_0(HalDev->dev_base) + ((Ch-16)*64));
6494 +
6495 + if (HalDev->OamMode == 0)
6496 + {
6497 + *pTmp &=~ OamMode;
6498 + }
6499 + else
6500 + {
6501 + *pTmp |= OamMode;
6502 + }
6503 + }
6504 + }
6505 +
6506 +static int halControl(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value)
6507 + {
6508 + int KeyFound=0, ActionFound=0, rc=EC_NO_ERRORS, Ch; /* +RC3.02*/
6509 + char *TmpKey = (char *)Key;
6510 +
6511 +#ifdef __CPHAL_DEBUG
6512 + if (DBG(0))
6513 + {
6514 + dbgPrintf("[cpsar]halControl(HalDev:%08x, Key:%s, Action:%s, Value:%08x)\n", (bit32u)HalDev,
6515 + Key, Action, (bit32u)Value);
6516 + osfuncSioFlush();
6517 + }
6518 +#endif
6519 +
6520 + if (HalDev->OsFunc->Strcmpi(Key, "Debug") == 0)
6521 + {
6522 + KeyFound=1; /* +RC3.02*/
6523 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6524 + {
6525 + ActionFound=1; /* +RC3.02*/
6526 + HalDev->debug = *(int *)Value;
6527 + }
6528 + }
6529 +
6530 + /* +GSG 030407 */
6531 + if (HalDev->OsFunc->Strcmpi(Key, "OamMode") == 0)
6532 + {
6533 + KeyFound=1;
6534 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6535 + {
6536 + ActionFound=1;
6537 + HalDev->OamMode = *(int *)Value;
6538 +
6539 + /* only do this if we're open */
6540 + if (HalDev->OpenCount > 0)
6541 + SetOamMode(HalDev);
6542 + }
6543 +
6544 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
6545 + {
6546 + ActionFound=1;
6547 + *(int *)Value = HalDev->OamMode;
6548 + }
6549 + }
6550 +
6551 + if (HalDev->OsFunc->Strcmpi(Key, "Stats3") == 0)
6552 + {
6553 + if (HalDev->OsFunc->Strcmpi(Action, "Get") == 0)
6554 + StatsGet3(HalDev);
6555 + }
6556 +
6557 + /* +RC3.02 (if statement) */
6558 + /* Fixes PITS #98 */
6559 + if (HalDev->OsFunc->Strstr(Key, "PdspEnable") != 0)
6560 + {
6561 + KeyFound=1;
6562 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6563 + {
6564 + ActionFound=1;
6565 +
6566 + /* Configure PDSP enable bit based on Value*/
6567 + if (*(int *)Value & 1)
6568 + {
6569 + /* enable PDSP */
6570 + PDSP_CTRL_REG(HalDev->dev_base) |= 0x2;
6571 + }
6572 + else
6573 + {
6574 + /* disable PDSP */
6575 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x2;
6576 + }
6577 + }
6578 + }
6579 +
6580 + if (HalDev->OsFunc->Strstr(Key, "FwdUnkVc.") != 0)
6581 + {
6582 + KeyFound=1;
6583 + if (HalDev->OsFunc->Strcmpi(Action, "Set") == 0)
6584 + {
6585 + ActionFound=1;
6586 +
6587 + /* extract channel number */
6588 + TmpKey += HalDev->OsFunc->Strlen("FwdUnkVc.");
6589 + Ch = HalDev->OsFunc->Strtoul(TmpKey, &TmpKey, 10);
6590 +
6591 + /* Configure forwarding of unknown VCI/VPI cells */
6592 + SAR_PDSP_FWD_UNK_VC_REG(HalDev->dev_base) = (((*(int*)Value)<<31) | Ch);
6593 + }
6594 + }
6595 +
6596 + if (KeyFound == 0) /* +RC3.02 */
6597 + rc = (EC_CPSAR|EC_FUNC_CONTROL|EC_VAL_KEY_NOT_FOUND); /* +RC3.02 */
6598 +
6599 + if (ActionFound == 0) /* +RC3.02 */
6600 + rc = (EC_CPSAR|EC_FUNC_CONTROL|EC_VAL_ACTION_NOT_FOUND); /* +RC3.02 */
6601 +
6602 + return(rc); /* ~RC3.02 */
6603 + }
6604 +
6605 +/*
6606 + * This function opens the specified channel.
6607 + *
6608 + * @param HalDev CPHAL module instance. (set by cphalInitModule())
6609 + * @param Ch Channel number.
6610 + *
6611 + * @return 0 OK, Non-zero Not OK
6612 + */
6613 +static int halChannelSetup(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh)
6614 + {
6615 + int i;
6616 + int Ch = HalCh->Channel;
6617 + int PdspChBlock = Ch;
6618 + int PdspBlockOffset = 0;
6619 + volatile bit32u *pTmp;
6620 +
6621 +#ifdef __CPHAL_DEBUG
6622 + if (DBG(0))
6623 + {
6624 + dbgPrintf("[cpsar]halChannelSetup(HalDev:%08x, HalCh:%08x)\n", (bit32u)HalDev,
6625 + (bit32u)HalCh);
6626 + osfuncSioFlush();
6627 + }
6628 +#endif
6629 +
6630 + /* Figure out the correct offset from the start of the PDSP
6631 + Scratchpad RAM (starting at 0x8050 in the SAR) */
6632 + if (Ch > 15)
6633 + {
6634 + /* this is an AAL2 channel, which are channels 16-18 */
6635 + PdspChBlock = Ch - 16;
6636 + /* Get the offset to the AAL2 portion of the block (in words) */
6637 + PdspBlockOffset = NUM_PDSP_AAL5_STATE_WORDS + (PdspChBlock*64);
6638 + /* Clear PDSP State RAM */
6639 + /*pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6640 + for (i=0; i<NUM_PDSP_AAL2_STATE_WORDS; i++)
6641 + *pTmp++ = 0;*/
6642 + }
6643 + else
6644 + {
6645 + /* Get the offset to the AAL5 portion of the block (in words) */
6646 + PdspBlockOffset = (PdspChBlock*64);
6647 + /* Clear PDSP State RAM */
6648 + /*pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6649 + for (i=0; i<NUM_PDSP_AAL5_STATE_WORDS; i++)
6650 + *pTmp++ = 0;*/
6651 + }
6652 +
6653 + /* Configure PDSP State RAM */
6654 +
6655 + /* Setup TX PDSP State RAM */
6656 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6657 + *pTmp++ = HalCh->TxVc_CellRate; /* Set the cell rate in cells/sec */
6658 + *pTmp++ = HalCh->TxVc_QosType; /* Configure the QoS Type */
6659 + *pTmp++ = HalCh->TxVc_Mbs; /* Set minimum burst size */
6660 + *pTmp++ = 0; /* (skip a register) */
6661 + *pTmp++ = HalCh->TxVc_Pcr; /* set the peak cell rate */
6662 + *pTmp++ = 0; /* new addition 4.9.02 */
6663 + *pTmp++ = HalCh->TxVc_AtmHeader; /* give the ATM header */
6664 + *pTmp++ = (HalCh->TxVc_OamTc << 8)
6665 + |(HalCh->TxVc_VpOffset); /* Set the OAM TC Path and VP Offset */
6666 +
6667 + /* Setup RX PDSP State RAM */
6668 + *pTmp++ = (HalCh->RxVc_OamCh)|
6669 + (HalDev->OamMode << 8) |
6670 + (HalCh->RxVc_OamToHost<<9); /* Set OAM Channel, Mode, and ToHost options */
6671 + *pTmp++ = HalCh->RxVc_AtmHeader; /* ATM hdr put on firmware generated OAM */
6672 + *pTmp++ = (HalCh->RxVc_VpOffset)| /* Set Rx OAM TC Path and VP Offset */
6673 + (HalCh->RxVc_OamTc<<8);
6674 +
6675 + /* Setup TX VP PDSP State RAM */
6676 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset+16); /*GSG~030703 12->16 */
6677 + *pTmp++ = HalCh->TxVp_AtmHeader;
6678 + *pTmp++ = (HalCh->TxVp_OamTc << 8);
6679 +
6680 + /* Setup RX VP PDSP State RAM */
6681 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset+20); /*GSG~030703 16->20 */
6682 + *pTmp++ = HalCh->RxVp_AtmHeader;
6683 + *pTmp++ = (HalCh->RxVp_OamCh)|
6684 + (HalCh->RxVp_OamTc<<8)|
6685 + (HalCh->RxVp_OamToHost<<9); /* Set OAM Channel, Mode, and ToHost options */
6686 + *pTmp++ = 0;
6687 + *pTmp++ = HalCh->RxVp_OamVcList;
6688 +
6689 + /* Configure forwarding of unknown VCI/VPI cells */
6690 + if (HalCh->PktType == 3)
6691 + SAR_PDSP_FWD_UNK_VC_REG(HalDev->dev_base) = ((HalCh->FwdUnkVc<<31)|Ch);
6692 +
6693 + /* Configure Tx Channel Mapping Register (turn channel "ON") */
6694 + TX_CH_MAPPING_REG(HalDev->dev_base) = 0x80000000 |
6695 + (HalCh->DaMask << 30)
6696 + | (HalCh->Priority << 24) | Ch;
6697 +
6698 + /* Setup Rx Channel in the LUT */
6699 + i=0;
6700 + while (!(RX_LUT_CH_SETUP_REQ_REG(HalDev->dev_base) & 0x80000000))
6701 + {
6702 + if (i > WAIT_THRESH)
6703 + {
6704 + return(EC_CPSAR|EC_FUNC_CHSETUP|EC_VAL_LUT_NOT_READY);
6705 + }
6706 + else
6707 + i++;
6708 + }
6709 +
6710 + /* RX LUT is ready */
6711 + RX_LUT_CH_SETUP_REQ_REG(HalDev->dev_base) = (HalCh->PktType << 24) | Ch;
6712 + RX_LUT_CH_SETUP_REQ_VC_REG(HalDev->dev_base) = ((HalCh->Vpi << 20) |
6713 + (HalCh->Vci << 4));
6714 +
6715 + return (EC_NO_ERRORS);
6716 + }
6717 +
6718 +static int halChannelTeardown(CPSAR_DEVICE *HalDev, int Ch, bit32 Mode)
6719 + {
6720 + int waitcnt = 0;
6721 + int PdspBlockOffset = 0, i;
6722 + volatile bit32u *pTmp;
6723 +
6724 +#ifdef __CPHAL_DEBUG
6725 + if (DBG(0))
6726 + {
6727 + dbgPrintf("[cpsar]halChannelTeardown(HalDev:%08x, Ch:%d, Mode:%d\n",
6728 + (bit32u)HalDev, Ch, Mode);
6729 + osfuncSioFlush();
6730 + }
6731 +#endif
6732 +
6733 + if ((Ch < 0) || (Ch > MAX_CHAN))
6734 + return(EC_CPSAR|EC_FUNC_CHTEARDOWN|EC_VAL_INVALID_CH);
6735 +
6736 + /* Request RX channel teardown through LUT */
6737 + while ((RX_LUT_CH_TEARDOWN_REQ_REG(HalDev->dev_base) & 0x80000000) == 0)
6738 + {
6739 + waitcnt++;
6740 + if (waitcnt == WAIT_THRESH)
6741 + {
6742 + return(EC_CPSAR|EC_FUNC_CHTEARDOWN|EC_VAL_LUT_NOT_READY);
6743 + }
6744 + }
6745 +
6746 + RX_LUT_CH_TEARDOWN_REQ_REG(HalDev->dev_base) = (Ch & 0xffff);
6747 +
6748 + /* for AAL2, clear channel PDSP RAM here. AAL5 does it when the teardown
6749 + has completed (which is asynchronous)*/
6750 + if (Ch > 15)
6751 + {
6752 + /* Get the offset to the AAL2 portion of the block (in words) */
6753 + PdspBlockOffset = NUM_PDSP_AAL5_STATE_WORDS + ((Ch-16)*64);
6754 + /* Clear PDSP State RAM */
6755 + pTmp = (pPDSP_BLOCK_0(HalDev->dev_base)+PdspBlockOffset);
6756 + for (i=0; i<NUM_PDSP_AAL2_STATE_WORDS; i++)
6757 + *pTmp++ = 0;
6758 + }
6759 +
6760 + return (EC_NO_ERRORS);
6761 + }
6762 +
6763 +int InitPdsp(CPSAR_DEVICE *HalDev)
6764 + {
6765 + bit32u NumOfEntries,i,IRamAddress,iTmp;
6766 + int *SarPdspFirmware; /* ~GSG 030403 */
6767 + int FirmwareSize, rc; /* ~GSG 030403 */
6768 +
6769 +#ifdef __CPHAL_DEBUG
6770 + if (DBG(0))
6771 + {
6772 + dbgPrintf("[cpsar]InitPdsp(HalDev:%08x)\n", (bit32u)HalDev);
6773 + osfuncSioFlush();
6774 + }
6775 +#endif
6776 +
6777 + /* Get firmware */
6778 + rc = HalDev->OsFunc->Control(HalDev->OsDev, "Firmware", "Get", &SarPdspFirmware); /* ~GSG 030403 */
6779 + if (rc) /* +GSG 030403 */
6780 + return (EC_CPSAR|EC_FUNC_OPEN|EC_VAL_KEY_NOT_FOUND); /* +GSG 030403 */
6781 +
6782 + /* Get firmware size */
6783 + rc = HalDev->OsFunc->Control(HalDev->OsDev, "FirmwareSize", "Get", &FirmwareSize); /* ~GSG 030403 */
6784 + if (rc) /* +GSG 030403 */
6785 + return (EC_CPSAR|EC_FUNC_OPEN|EC_VAL_KEY_NOT_FOUND); /* +GSG 030403 */
6786 +
6787 + IRamAddress = (bit32u) pPDSP_CTRL_REG(HalDev->dev_base);
6788 +
6789 + NumOfEntries = (FirmwareSize)/4; /* ~GSG 030403 */
6790 + if (NumOfEntries > IRAM_SIZE)
6791 + {
6792 + /* Note: On Avalanche, they truncated the PDSP firmware and warned */
6793 + /* NumOfEntries = IRAM_SIZE; */
6794 + return(EC_CPSAR|EC_FUNC_INIT|EC_VAL_FIRMWARE_TOO_LARGE);
6795 + }
6796 + for(i=8;i<NumOfEntries;i++)
6797 + (*((bit32 *) (IRamAddress+(i*4))))=SarPdspFirmware[i]; /* ~GSG 030403 */
6798 +
6799 + /* Check code */
6800 + for(i=8;i<NumOfEntries;i++)
6801 + {
6802 + iTmp=(*((bit32 *) (IRamAddress+(i*4))));
6803 + if (iTmp != SarPdspFirmware[i]) /* ~GSG 030403 */
6804 + {
6805 + return(EC_CPSAR|EC_FUNC_OPEN|EC_VAL_PDSP_LOAD_FAIL);
6806 + }
6807 + }
6808 +
6809 + return(EC_NO_ERRORS);
6810 + }
6811 +
6812 +/*
6813 + * This function probes for the instance of the CPHAL module. It will call
6814 + * the OS function @c DeviceFindInfo() to get the information required.
6815 + *
6816 + * @param HalDev CPHAL module instance. (set by xxxInitModule())
6817 + *
6818 + * @return 0 OK, Otherwise error.
6819 + */
6820 +static int halProbe(CPSAR_DEVICE *HalDev)
6821 + {
6822 + int Ret;
6823 +
6824 +#ifdef __CPHAL_DEBUG
6825 + if (DBG(0))
6826 + {
6827 + dbgPrintf("[cpsar]halProbe(HalDev:%08x)\n", (bit32u)HalDev);
6828 + osfuncSioFlush();
6829 + }
6830 +#endif
6831 +
6832 +#ifdef __CPHAL_DEBUG
6833 + if (DBG(1))
6834 + {
6835 + dbgPrintf("[os]DeviceFindInfo(Inst:%d, DeviceName:%s, DeviceInfo:%08x)\n",
6836 + HalDev->Inst, "sar", (bit32u)&HalDev->DeviceInfo);
6837 + osfuncSioFlush();
6838 + }
6839 +#endif
6840 +
6841 + /* Attempt to find the device information */
6842 + Ret = HalDev->OsFunc->DeviceFindInfo(HalDev->Inst, "sar", &HalDev->DeviceInfo);
6843 + if (Ret)
6844 + return(EC_CPSAR|EC_FUNC_PROBE|EC_VAL_DEVICE_NOT_FOUND);
6845 +
6846 + return(EC_NO_ERRORS);
6847 + }
6848 +
6849 +#ifdef __CPHAL_DEBUG
6850 +static void dbgConfigDump(HAL_DEVICE *HalDev)
6851 + {
6852 + dbgPrintf(" [cpsar Inst %d] Config Dump:\n", HalDev->Inst);
6853 + dbgPrintf(" Base :%08x, offset :%08d\n",
6854 + HalDev->dev_base, HalDev->offset);
6855 + dbgPrintf(" ResetBit:%08d, ResetBase:%08x\n",
6856 + HalDev->ResetBit, HalDev->ResetBase);
6857 + dbgPrintf(" UniNni :%08d, debug :%08d\n",
6858 + HalDev->ResetBit, HalDev->debug);
6859 + osfuncSioFlush();
6860 + }
6861 +#endif
6862 +
6863 +/*
6864 + * Sets up HAL default configuration parameter values.
6865 + */
6866 +static void ConfigInit(CPSAR_DEVICE *HalDev)
6867 + {
6868 +#ifdef __CPHAL_DEBUG
6869 + if (DBG(0))
6870 + {
6871 + dbgPrintf("[cpsar]ConfigInit(HalDev:%08x)\n", (bit32u)HalDev);
6872 + osfuncSioFlush();
6873 + }
6874 +#endif
6875 + /* configure some defaults with tnetd7300 values */
6876 + HalDev->dev_base = 0xa3000000;
6877 + HalDev->offset = 0;
6878 + HalDev->UniNni = CFG_UNI_NNI;
6879 + HalDev->ResetBit = 9;
6880 + HalDev->debug = 0;
6881 + HalDev->ResetBase = 0xa8611600;
6882 + }
6883 +
6884 +/*
6885 + * Retrieve HAL configuration parameter values.
6886 + */
6887 +static bit32u ConfigGet(HAL_DEVICE *HalDev)
6888 + {
6889 + bit32u ParmValue, error_code;
6890 + char *DeviceInfo = HalDev->DeviceInfo;
6891 +
6892 +#ifdef __CPHAL_DEBUG
6893 + if (DBG(0))
6894 + {
6895 + dbgPrintf("[cpsar]ConfigGet(HalDev:%08x)\n", (bit32u)HalDev);
6896 + osfuncSioFlush();
6897 + }
6898 +#endif
6899 +
6900 + /* get the configuration parameters common to all modules */
6901 + error_code = ConfigGetCommon(HalDev);
6902 + if (error_code) return (EC_CPSAR|error_code);
6903 +
6904 + /* get SAR specific configuration parameters */
6905 + error_code = HalDev->OsFunc->DeviceFindParmUint(DeviceInfo,"UniNni",&ParmValue);
6906 + if (!error_code) HalDev->UniNni = ParmValue;
6907 +
6908 + return (EC_NO_ERRORS);
6909 + }
6910 +
6911 +static int halInit(CPSAR_DEVICE *HalDev)
6912 + {
6913 + bit32u Ret;
6914 +
6915 +#ifdef __CPHAL_DEBUG
6916 + if (DBG(0))
6917 + {
6918 + dbgPrintf("[cpsar]halInit(HalDev:%08x)\n", (bit32u)HalDev);
6919 + osfuncSioFlush();
6920 + }
6921 +#endif
6922 +
6923 +#ifdef __CPHAL_DEBUG
6924 + if (DBG(7))
6925 + {
6926 + dbgPrintf("[cpsar halInit()]InitCount = %d\n", HalDev->InitCount);
6927 + osfuncSioFlush();
6928 + }
6929 +#endif
6930 +
6931 + /* Only run the init code for the first calling module per instance */
6932 + if (HalDev->InitCount > 1)
6933 + {
6934 + return (EC_NO_ERRORS);
6935 + }
6936 +
6937 + /* Configure HAL defaults */
6938 + ConfigInit(HalDev);
6939 +
6940 + /* Retrieve HAL configuration parameters from data store */
6941 + Ret = ConfigGet(HalDev);
6942 + if (Ret) return (Ret);
6943 +
6944 +#ifdef __CPHAL_DEBUG
6945 + if (DBG(9))
6946 + dbgConfigDump(HalDev);
6947 +#endif
6948 +
6949 + return(EC_NO_ERRORS);
6950 + }
6951 +
6952 +static int halOpen(CPSAR_DEVICE *HalDev)
6953 + {
6954 + int Ret, Ticks=64;
6955 + int i; /*+GSG 030407*/
6956 + volatile int *pTmp; /*+GSG 030407*/
6957 +
6958 +#ifdef __CPHAL_DEBUG
6959 + if (DBG(0))
6960 + {
6961 + dbgPrintf("[cpsar]halOpen(HalDev:%08x)\n", (bit32u)HalDev);
6962 + osfuncSioFlush();
6963 + }
6964 +#endif
6965 +
6966 +#ifdef __CPHAL_DEBUG
6967 + if (DBG(7))
6968 + {
6969 + dbgPrintf("[cpsar halOpen()]OpenCount = %d\n", HalDev->OpenCount);
6970 + osfuncSioFlush();
6971 + }
6972 +#endif
6973 +
6974 + /* Only run the open code for the first calling module per instance */
6975 + if (HalDev->OpenCount++ > 0)
6976 + {
6977 + return (EC_NO_ERRORS);
6978 + }
6979 +
6980 + /* Take SAR out of reset */
6981 + if (((*(volatile bit32u *)(HalDev->ResetBase)) & (1<<HalDev->ResetBit)) != 0)
6982 + {
6983 + /** @todo Should I somehow call AAL5/AAL2 Close() here? All I've done
6984 + here is copy the Close code from each and paste it here. */
6985 +
6986 +#ifdef __CPHAL_DEBUG
6987 + if (DBG(7))
6988 + {
6989 + dbgPrintf("[cpsar halOpen()]Module was already out of reset.\n");
6990 + dbgPrintf(" Closing module and resetting.\n");
6991 + osfuncSioFlush();
6992 + }
6993 +#endif
6994 +
6995 + /* Disable the Tx CPPI DMA */
6996 + TX_CPPI_CTL_REG(HalDev->dev_base) = 0;
6997 +
6998 + /* Disable the Rx CPPI DMA */
6999 + RX_CPPI_CTL_REG(HalDev->dev_base) = 0;
7000 +
7001 + /* Disable the PDSP */
7002 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x00000002;
7003 +
7004 + /* disable interrupt masks */
7005 + SAR_TX_MASK_CLR(HalDev->dev_base) = 0xffffffff;
7006 + SAR_RX_MASK_CLR(HalDev->dev_base) = 0xffffffff;
7007 +
7008 +#ifndef NO_RESET /* GSG+ 030428 */
7009 + /* clear reset bit */
7010 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit); /* ~GSG 030307 */
7011 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7012 +
7013 + /* set reset bit */
7014 + (*(volatile bit32u *)(HalDev->ResetBase)) |= (1<<HalDev->ResetBit); /* ~GSG 030307 */
7015 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7016 +#endif /* GSG+ 030428 */
7017 + }
7018 + else
7019 + {
7020 + (*(volatile bit32u *)(HalDev->ResetBase)) |= (1<<HalDev->ResetBit); /* ~GSG 030307 */
7021 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7022 + }
7023 +
7024 + /* Configure UNI/NNI */
7025 + RX_LUT_GLOBAL_CFG_REG(HalDev->dev_base) |= (HalDev->UniNni & 0x1);
7026 +
7027 + /* Clear entire PDSP state RAM */ /*+GSG 030407*/
7028 + pTmp = (pTX_DMA_STATE_WORD_0(HalDev->dev_base)); /*+GSG 030407*/
7029 + for (i=0; i<PDSP_STATE_RAM_SIZE; i++) /*+GSG 030407*/
7030 + *pTmp++ = 0; /*+GSG 030407*/
7031 +
7032 + /* Configure Oam Mode */ /*+GSG 030407*/
7033 + SetOamMode(HalDev); /*+GSG 030407*/
7034 +
7035 + /* Initialize PDSP */
7036 + Ret=InitPdsp(HalDev);
7037 + if(Ret)
7038 + return(Ret);
7039 +
7040 + /* Reset and Enable the PDSP */
7041 + PDSP_CTRL_REG(HalDev->dev_base) = 0x00080003;
7042 +
7043 + return(EC_NO_ERRORS);
7044 + }
7045 +
7046 +static int halClose(CPSAR_DEVICE *HalDev, int Mode)
7047 + {
7048 + int Ticks = 64;
7049 +
7050 +#ifdef __CPHAL_DEBUG
7051 + if (DBG(0))
7052 + {
7053 + dbgPrintf("[cpsar]halClose(HalDev:%08x, Mode:%d)\n", (bit32u)HalDev, Mode);
7054 + osfuncSioFlush();
7055 + }
7056 +#endif
7057 +
7058 + /* handle the error case if there is nothing open */
7059 + if (HalDev->OpenCount == 0)
7060 + {
7061 + return(EC_CPSAR|EC_FUNC_CLOSE|EC_VAL_MODULE_ALREADY_CLOSED);
7062 + }
7063 +
7064 +#ifdef __CPHAL_DEBUG
7065 + if (DBG(7))
7066 + {
7067 + dbgPrintf("[cpsar halClose()]OpenCount = %d\n", HalDev->OpenCount);
7068 + osfuncSioFlush();
7069 + }
7070 +#endif
7071 +
7072 + /* Only run the close code for the last calling module per instance */
7073 + if (HalDev->OpenCount-- > 1)
7074 + {
7075 + return (EC_NO_ERRORS);
7076 + }
7077 +
7078 + /* Disable the PDSP */
7079 + PDSP_CTRL_REG(HalDev->dev_base) &=~ 0x00000002;
7080 +
7081 +#ifndef NO_RESET /* GSG +030428 */
7082 + /* put device back into reset */
7083 + (*(volatile bit32u *)(HalDev->ResetBase)) &=~ (1<<HalDev->ResetBit); /* ~GSG 030307 */
7084 + HalDev->OsFunc->Control(HalDev->OsDev, "Sleep", "", &Ticks);
7085 +#endif /* GSG +030428 */
7086 +
7087 + return(EC_NO_ERRORS);
7088 + }
7089 +
7090 +static int halShutdown(CPSAR_DEVICE *HalDev)
7091 + {
7092 +#ifdef __CPHAL_DEBUG
7093 + if (DBG(0))
7094 + {
7095 + dbgPrintf("[cpsar]halShutdown(HalDev:%08x)\n", (bit32u)HalDev);
7096 + osfuncSioFlush();
7097 + }
7098 +#endif
7099 +
7100 + /* handle the error case */
7101 + if (HalDev->InitCount == 0)
7102 + {
7103 + return(EC_CPSAR|EC_FUNC_CLOSE|EC_VAL_MODULE_ALREADY_SHUTDOWN);
7104 + }
7105 +
7106 +#ifdef __CPHAL_DEBUG
7107 + if (DBG(7))
7108 + {
7109 + dbgPrintf("[cpsar halShutdown()]InitCount = %d\n", HalDev->InitCount);
7110 + osfuncSioFlush();
7111 + }
7112 +#endif
7113 +
7114 + /* Only run the shutdown code for the last calling module per instance */
7115 + if (HalDev->InitCount-- > 1)
7116 + {
7117 + return (EC_NO_ERRORS);
7118 + }
7119 +
7120 + /* free the SAR functions */
7121 +#ifdef __CPHAL_DEBUG
7122 + if (DBG(6))
7123 + {
7124 + dbgPrintf(" [cpsar halShutdown()]: Free CPSAR function pointers\n");
7125 + osfuncSioFlush();
7126 + }
7127 + if (DBG(1)||DBG(3))
7128 + {
7129 + dbgPrintf("[os]Free(MemPtr:%08x)\n", (bit32u)HalDev->HalFuncPtr);
7130 + osfuncSioFlush();
7131 + }
7132 +#endif
7133 + /* free the HalFunc */
7134 + HalDev->OsFunc->Free(HalDev->HalFuncPtr);
7135 +
7136 + /* we have a static global, so I should clear it's value as well */
7137 + CpsarDev[HalDev->Inst] = 0;
7138 +
7139 +#ifdef __CPHAL_DEBUG
7140 + if (DBG(6))
7141 + {
7142 + dbgPrintf(" [cpsar halShutdown()]Free HalDev\n");
7143 + osfuncSioFlush();
7144 + }
7145 + if (DBG(1)||DBG(3))
7146 + {
7147 + dbgPrintf("[os]Free(MemPtr:%08x)\n", (bit32u)HalDev);
7148 + osfuncSioFlush();
7149 + }
7150 +#endif
7151 + /* free the CPSAR device */
7152 + HalDev->OsFunc->Free(HalDev);
7153 +
7154 + return(EC_NO_ERRORS);
7155 + }
7156 +
7157 +static int halTick(CPSAR_DEVICE *HalDev)
7158 + {
7159 +#ifdef __CPHAL_DEBUG
7160 + if (DBG(0))
7161 + {
7162 + dbgPrintf("[cpsar]halTick(HalDev:%08x)\n", (bit32u)HalDev);
7163 + osfuncSioFlush();
7164 + }
7165 +#endif
7166 +
7167 + return(EC_NO_ERRORS);
7168 + }
7169 +
7170 +/*
7171 + * The CPSAR version of InitModule() should be passed the OS_FUNCTIONS pointer,
7172 + * and will return the HalDev pointer.
7173 + *
7174 + * @param HalDev Pointer to CPSAR module information. This will
7175 + * be used by the OS when communicating to this module via
7176 + * CPSAR.
7177 + * @param OsDev Pointer to OS device information. This will be saved by
7178 + * the CPSAR and returned to the OS when required.
7179 + * @param HalFunc HAL_FUNCTIONS pointer.
7180 + * @param Size Pointer to the size of the HAL_FUNCTIONS structure. (If
7181 + * HalFunc is 0, the value will be set by CPSAR, otherwise
7182 + * ignored)
7183 + * @param Inst The instance number of the module to initialize. (start at
7184 + * 0).
7185 + *
7186 + * @return 0 OK, Nonzero - error.
7187 + */
7188 +/*
7189 +int cpsarInitModule(CPSAR_DEVICE **HalDev,
7190 + OS_DEVICE *OsDev,
7191 + CPSAR_FUNCTIONS *HalFunc,
7192 + OS_FUNCTIONS *OsFunc,
7193 + int *Size,
7194 + int Inst)
7195 +*/
7196 +int cpsarInitModule(CPSAR_DEVICE **HalDev,
7197 + OS_DEVICE *OsDev,
7198 + CPSAR_FUNCTIONS **HalFunc,
7199 + OS_FUNCTIONS *OsFunc,
7200 + int OsFuncSize,
7201 + int *HalFuncSize,
7202 + int Inst)
7203 + {
7204 + CPSAR_DEVICE *HalPtr;
7205 + CPSAR_FUNCTIONS *HalFuncPtr;
7206 +
7207 + /*
7208 + if ( HalFunc == 0 )
7209 + {
7210 + *Size = sizeof(CPSAR_FUNCTIONS);
7211 + return(EC_NO_ERRORS);
7212 + }
7213 + */
7214 +
7215 + if (CpsarDev[Inst] != 0)
7216 + {
7217 + /* this SAR module has been connected to before, so do not
7218 + allocate another CPSAR_DEVICE */
7219 + HalPtr = CpsarDev[Inst];
7220 +
7221 + /* increase count of attached modules */
7222 + HalPtr->InitCount++;
7223 + }
7224 + else
7225 + {
7226 + /* allocate the CPSAR_DEVICE structure */
7227 + HalPtr = (CPSAR_DEVICE *) OsFunc->MallocDev(sizeof(CPSAR_DEVICE));
7228 + if(!HalPtr)
7229 + return(EC_CPSAR|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_DEV_FAILED);
7230 +
7231 + HalFuncPtr = (CPSAR_FUNCTIONS *) OsFunc->Malloc(sizeof(CPSAR_FUNCTIONS));
7232 + if (!HalFuncPtr)
7233 + return (EC_CPSAR|EC_FUNC_HAL_INIT|EC_VAL_MALLOC_FAILED);
7234 +
7235 + /* Initialize the size of hal functions */
7236 + *HalFuncSize = sizeof (CPSAR_FUNCTIONS);
7237 +
7238 + /* ensure the device structure is cleared */
7239 + OsFunc->Memset(HalPtr, 0, sizeof(CPSAR_DEVICE));
7240 +
7241 + /* clear the function pointers */
7242 + OsFunc->Memset(HalFuncPtr, 0, sizeof(CPSAR_FUNCTIONS));
7243 +
7244 + /* Supply pointers for the CPSAR API functions */
7245 + HalFuncPtr->ChannelSetup = halChannelSetup;
7246 + HalFuncPtr->ChannelTeardown = halChannelTeardown;
7247 + HalFuncPtr->Close = halClose;
7248 + HalFuncPtr->Control = halControl;
7249 + HalFuncPtr->Init = halInit;
7250 + HalFuncPtr->Open = halOpen;
7251 + HalFuncPtr->Probe = halProbe;
7252 + HalFuncPtr->Shutdown = halShutdown;
7253 + HalFuncPtr->Tick = halTick;
7254 +
7255 + /* keep a reference to HalFuncPtr so I can free it later */
7256 + HalPtr->HalFuncPtr = HalFuncPtr;
7257 +
7258 + /* store the CPSAR_DEVICE, so the CPSAR module will know whether
7259 + it is in use for the given instance */
7260 + CpsarDev[Inst] = HalPtr;
7261 +
7262 + /* increase count of attached modules */
7263 + HalPtr->InitCount++;
7264 + }
7265 +
7266 + /* @todo Does this need modification to deal with multiple callers/
7267 + drivers? If different callers will use different OsDev/OsFunc,
7268 + then the current code will not work.
7269 + */
7270 +
7271 + /* initialize the CPSAR_DEVICE structure */
7272 + HalPtr->OsDev = OsDev;
7273 + /*HalPtr->OsOpen = OsDev;*/
7274 + HalPtr->Inst = Inst;
7275 + HalPtr->OsFunc = OsFunc;
7276 +
7277 + /* pass the HalPtr back to the caller */
7278 + *HalDev = HalPtr;
7279 + *HalFunc = HalPtr->HalFuncPtr;
7280 +
7281 + return (EC_NO_ERRORS);
7282 + }
7283 diff -urN linux.old/drivers/atm/sangam_atm/cpsar_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpsar_cpaal5.h
7284 --- linux.old/drivers/atm/sangam_atm/cpsar_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
7285 +++ linux.dev/drivers/atm/sangam_atm/cpsar_cpaal5.h 2005-08-23 04:46:50.087845216 +0200
7286 @@ -0,0 +1,103 @@
7287 +/*******************************************************************************
7288 + * TNETDxxxx Software Support
7289 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7290 + *
7291 + * FILE: cpsar.h
7292 + *
7293 + * DESCRIPTION:
7294 + * This file contains data structure definitions for the CPSAR HAL.
7295 + *
7296 + * HISTORY:
7297 + * 6Sep02 Greg 1.00 Original Version created.
7298 + *
7299 + *****************************************************************************/
7300 +#ifndef _INC_CPSAR
7301 +#define _INC_CPSAR
7302 +
7303 +#define NUM_RX_STATE_WORDS 7
7304 +#define NUM_TX_STATE_WORDS 9
7305 +#define MAX_CHAN 19
7306 +
7307 +
7308 +#ifndef _CPHAL_CPSAR
7309 +typedef void CPSAR_DEVICE;
7310 +#endif
7311 +
7312 +/*
7313 + * HAL Default Parameter Values
7314 + */
7315 +#define CFG_UNI_NNI 0
7316 +
7317 +/**
7318 + * @ingroup shared_data
7319 + *
7320 + * List of defined keys for use with Control().
7321 + */
7322 +typedef enum
7323 + {
7324 + /* SAR */
7325 + enGET_FIRMWARE, /**< Used by the SAR to request a pointer to firmware */
7326 + enGET_FIRMWARE_SIZE, /**< Used by the SAR to request the size of the firmware */
7327 + enEND=9999 /* Last entry */
7328 + }INFO_KEY;
7329 +
7330 +/*
7331 + * The CPHAL_FUNCTIONS struct defines the CPHAL function pointers used by upper layer
7332 + * software. The upper layer software receives these pointers through the
7333 + * call to cphalInitModule().
7334 + */
7335 +typedef struct
7336 + {
7337 + int (*ChannelSetup)(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh);
7338 + int (*ChannelTeardown)(CPSAR_DEVICE *HalDev, int Ch, int Mode);
7339 + int (*Close)(CPSAR_DEVICE *HalDev, int Mode);
7340 + int (*Control)(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7341 + int (*Init)(CPSAR_DEVICE *HalDev);
7342 + int (*ModeChange)(CPSAR_DEVICE *HalDev, char *DeviceParms);
7343 + int (*Open)(CPSAR_DEVICE *HalDev);
7344 + int (*Probe)(CPSAR_DEVICE *HalDev);
7345 + int (*Shutdown)(CPSAR_DEVICE *HalDev);
7346 + int (*Tick)(CPSAR_DEVICE *HalDev);
7347 + } CPSAR_FUNCTIONS;
7348 +
7349 +/*
7350 + * This is the data structure for a generic HAL device. It contains all device
7351 + * specific data for a single instance of that device. This includes Rx/Tx
7352 + * buffer queues, device base address, reset bit, and other information.
7353 + */
7354 +typedef struct cpsar_device
7355 + {
7356 + bit32 dev_base;
7357 + bit32 offset;
7358 + bit32 TxTeardownPending[MAX_CHAN];
7359 + bit32 RxTeardownPending[MAX_CHAN];
7360 + bit32 ChIsOpen[MAX_CHAN];
7361 + bit32 ResetBit;
7362 + bit32 debug;
7363 + OS_DEVICE *OsDev;
7364 + OS_FUNCTIONS *OsFunc;
7365 + /*void *OsOpen;*/
7366 + bit32 UniNni;
7367 + bit32 Inst;
7368 + bit32u DeviceCPID[4];
7369 + bit32u LBSourceLLID[4];
7370 + bit32u OamRate[11];
7371 + CHANNEL_INFO ChData[MAX_CHAN];
7372 + int InitCount;
7373 + int OpenCount;
7374 + char *DeviceInfo;
7375 + bit32u ResetBase;
7376 + DEVICE_STATE State;
7377 + CPSAR_FUNCTIONS *HalFuncPtr;
7378 + int OamMode; /* +GSG 030407 */
7379 + }CPSARDEVICE;
7380 +
7381 +extern int cpsarInitModule(CPSAR_DEVICE **HalDev,
7382 + OS_DEVICE *OsDev,
7383 + CPSAR_FUNCTIONS **HalFunc,
7384 + OS_FUNCTIONS *OsFunc,
7385 + int OsFuncSize,
7386 + int *HalFuncSize,
7387 + int Inst);
7388 +
7389 +#endif
7390 diff -urN linux.old/drivers/atm/sangam_atm/cpsar.h linux.dev/drivers/atm/sangam_atm/cpsar.h
7391 --- linux.old/drivers/atm/sangam_atm/cpsar.h 1970-01-01 01:00:00.000000000 +0100
7392 +++ linux.dev/drivers/atm/sangam_atm/cpsar.h 2005-08-23 04:46:50.087845216 +0200
7393 @@ -0,0 +1,103 @@
7394 +/*******************************************************************************
7395 + * TNETDxxxx Software Support
7396 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7397 + *
7398 + * FILE: cpsar.h
7399 + *
7400 + * DESCRIPTION:
7401 + * This file contains data structure definitions for the CPSAR HAL.
7402 + *
7403 + * HISTORY:
7404 + * 6Sep02 Greg 1.00 Original Version created.
7405 + *
7406 + *****************************************************************************/
7407 +#ifndef _INC_CPSAR
7408 +#define _INC_CPSAR
7409 +
7410 +#define NUM_RX_STATE_WORDS 7
7411 +#define NUM_TX_STATE_WORDS 9
7412 +#define MAX_CHAN 19
7413 +
7414 +
7415 +#ifndef _CPHAL_CPSAR
7416 +typedef void CPSAR_DEVICE;
7417 +#endif
7418 +
7419 +/*
7420 + * HAL Default Parameter Values
7421 + */
7422 +#define CFG_UNI_NNI 0
7423 +
7424 +/**
7425 + * @ingroup shared_data
7426 + *
7427 + * List of defined keys for use with Control().
7428 + */
7429 +typedef enum
7430 + {
7431 + /* SAR */
7432 + enGET_FIRMWARE, /**< Used by the SAR to request a pointer to firmware */
7433 + enGET_FIRMWARE_SIZE, /**< Used by the SAR to request the size of the firmware */
7434 + enEND=9999 /* Last entry */
7435 + }INFO_KEY;
7436 +
7437 +/*
7438 + * The CPHAL_FUNCTIONS struct defines the CPHAL function pointers used by upper layer
7439 + * software. The upper layer software receives these pointers through the
7440 + * call to cphalInitModule().
7441 + */
7442 +typedef struct
7443 + {
7444 + int (*ChannelSetup)(CPSAR_DEVICE *HalDev, CHANNEL_INFO *HalCh);
7445 + int (*ChannelTeardown)(CPSAR_DEVICE *HalDev, int Ch, int Mode);
7446 + int (*Close)(CPSAR_DEVICE *HalDev, int Mode);
7447 + int (*Control)(CPSAR_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
7448 + int (*Init)(CPSAR_DEVICE *HalDev);
7449 + int (*ModeChange)(CPSAR_DEVICE *HalDev, char *DeviceParms);
7450 + int (*Open)(CPSAR_DEVICE *HalDev);
7451 + int (*Probe)(CPSAR_DEVICE *HalDev);
7452 + int (*Shutdown)(CPSAR_DEVICE *HalDev);
7453 + int (*Tick)(CPSAR_DEVICE *HalDev);
7454 + } CPSAR_FUNCTIONS;
7455 +
7456 +/*
7457 + * This is the data structure for a generic HAL device. It contains all device
7458 + * specific data for a single instance of that device. This includes Rx/Tx
7459 + * buffer queues, device base address, reset bit, and other information.
7460 + */
7461 +typedef struct cpsar_device
7462 + {
7463 + bit32 dev_base;
7464 + bit32 offset;
7465 + bit32 TxTeardownPending[MAX_CHAN];
7466 + bit32 RxTeardownPending[MAX_CHAN];
7467 + bit32 ChIsOpen[MAX_CHAN];
7468 + bit32 ResetBit;
7469 + bit32 debug;
7470 + OS_DEVICE *OsDev;
7471 + OS_FUNCTIONS *OsFunc;
7472 + /*void *OsOpen;*/
7473 + bit32 UniNni;
7474 + bit32 Inst;
7475 + bit32u DeviceCPID[4];
7476 + bit32u LBSourceLLID[4];
7477 + bit32u OamRate[11];
7478 + CHANNEL_INFO ChData[MAX_CHAN];
7479 + int InitCount;
7480 + int OpenCount;
7481 + char *DeviceInfo;
7482 + bit32u ResetBase;
7483 + DEVICE_STATE State;
7484 + CPSAR_FUNCTIONS *HalFuncPtr;
7485 + int OamMode; /* +GSG 030407 */
7486 + }CPSARDEVICE;
7487 +
7488 +extern int cpsarInitModule(CPSAR_DEVICE **HalDev,
7489 + OS_DEVICE *OsDev,
7490 + CPSAR_FUNCTIONS **HalFunc,
7491 + OS_FUNCTIONS *OsFunc,
7492 + int OsFuncSize,
7493 + int *HalFuncSize,
7494 + int Inst);
7495 +
7496 +#endif
7497 diff -urN linux.old/drivers/atm/sangam_atm/cp_sar_reg.h linux.dev/drivers/atm/sangam_atm/cp_sar_reg.h
7498 --- linux.old/drivers/atm/sangam_atm/cp_sar_reg.h 1970-01-01 01:00:00.000000000 +0100
7499 +++ linux.dev/drivers/atm/sangam_atm/cp_sar_reg.h 2005-08-23 04:46:50.087845216 +0200
7500 @@ -0,0 +1,217 @@
7501 +/***************************************************************************
7502 + TNETD73xx Software Support
7503 + Copyright(c) 2000, Texas Instruments Incorporated. All Rights Reserved.
7504 +
7505 + FILE: cp_sar_reg.h Register definitions for the SAR module
7506 +
7507 + DESCRIPTION:
7508 + This include file contains register definitions for the
7509 + SAR module.
7510 +
7511 + HISTORY:
7512 + 15 Jan 02 G. Guyotte Original version written
7513 + 03 Oct 02 G. Guyotte C++ style comments removed
7514 +****************************************************************************/
7515 +#ifndef _INC_SAR_REG
7516 +#define _INC_SAR_REG
7517 +
7518 +/* Global Registers */
7519 +#define pSAR_ID_REG(base) ((volatile bit32u *)(base+0x0000))
7520 +#define SAR_ID_REG(base) (*pSAR_ID_REG(base))
7521 +#define pSAR_STATUS_SET_REG(base) ((volatile bit32u *)(base+0x0008))
7522 +#define SAR_STATUS_SET_REG(base) (*pSAR_STATUS_SET_REG(base))
7523 +#define pSAR_STATUS_CLR_REG(base) ((volatile bit32u *)(base+0x000C))
7524 +#define SAR_STATUS_CLR_REG(base) (*pSAR_STATUS_CLR_REG(base))
7525 +#define pSAR_HOST_INT_EN_SET_REG(base) ((volatile bit32u *)(base+0x0010))
7526 +#define SAR_HOST_INT_EN_SET_REG(base) (*pSAR_HOST_INT_EN_SET_REG(base))
7527 +#define pSAR_HOST_INT_EN_CLR_REG(base) ((volatile bit32u *)(base+0x0014))
7528 +#define SAR_HOST_INT_EN_CLR_REG(base) (*pSAR_HOST_INT_EN_CLR_REG(base))
7529 +#define pSAR_PDSP_INT_EN_SET_REG(base) ((volatile bit32u *)(base+0x0018))
7530 +#define SAR_PDSP_INT_EN_SET_REG(base) (*pSAR_PDSP_INT_EN_SET_REG(base))
7531 +#define pSAR_PDSP_INT_EN_CLR_REG(base) ((volatile bit32u *)(base+0x001C))
7532 +#define SAR_PDSP_INT_EN_CLR_REG(base) (*pSAR_PDSP_INT_EN_CLR_REG(base))
7533 +
7534 +/* PDSP OAM General Purpose Registers */
7535 +#define pSAR_PDSP_HOST_OAM_CONFIG_REG(base) ((volatile bit32u *)(base+0x0020))
7536 +#define SAR_PDSP_HOST_OAM_CONFIG_REG(base) (*pSAR_PDSP_HOST_OAM_CONFIG_REG(base))
7537 +#define pSAR_PDSP_OAM_CORR_REG(base) ((volatile bit32u *)(base+0x0024))
7538 +#define SAR_PDSP_OAM_CORR_REG(base) (*pSAR_PDSP_OAM_CORR_REG(base))
7539 +#define pSAR_PDSP_OAM_LB_RESULT_REG(base) ((volatile bit32u *)(base+0x0028))
7540 +#define SAR_PDSP_OAM_LB_RESULT_REG(base) (*pSAR_PDSP_OAM_LB_RESULT_REG(base))
7541 +#define pSAR_PDSP_OAM_F5_LB_COUNT_REG(base) ((volatile bit32u *)(base+0x002c)) /* +GSG 030416 */
7542 +#define SAR_PDSP_OAM_F5_LB_COUNT_REG(base) (*pSAR_PDSP_OAM_F5_LB_COUNT_REG(base)) /* +GSG 030416 */
7543 +#define pSAR_PDSP_OAM_F4_LB_COUNT_REG(base) ((volatile bit32u *)(base+0x0030)) /* +GSG 030416 */
7544 +#define SAR_PDSP_OAM_F4_LB_COUNT_REG(base) (*pSAR_PDSP_OAM_F4_LB_COUNT_REG(base)) /* +GSG 030416 */
7545 +#define pSAR_PDSP_FWD_UNK_VC_REG(base) ((volatile bit32u *)(base+0x0034)) /* +GSG 030701 */
7546 +#define SAR_PDSP_FWD_UNK_VC_REG(base) (*pSAR_PDSP_FWD_UNK_VC_REG(base)) /* +GSG 030701 */
7547 +
7548 +
7549 +/* Rx Lookup Table Registers */
7550 +#define pRX_LUT_GLOBAL_CFG_REG(base) ((volatile bit32u *)(base+0x0080))
7551 +#define RX_LUT_GLOBAL_CFG_REG(base) (*pRX_LUT_GLOBAL_CFG_REG(base))
7552 +#define pRX_LUT_CH_SETUP_REQ_REG(base) ((volatile bit32u *)(base+0x0090))
7553 +#define RX_LUT_CH_SETUP_REQ_REG(base) (*pRX_LUT_CH_SETUP_REQ_REG(base))
7554 +#define pRX_LUT_CH_SETUP_REQ_VC_REG(base) ((volatile bit32u *)(base+0x0094))
7555 +#define RX_LUT_CH_SETUP_REQ_VC_REG(base) (*pRX_LUT_CH_SETUP_REQ_VC_REG(base))
7556 +#define pRX_LUT_CH_TEARDOWN_REQ_REG(base) ((volatile bit32u *)(base+0x009C))
7557 +#define RX_LUT_CH_TEARDOWN_REQ_REG(base) (*pRX_LUT_CH_TEARDOWN_REQ_REG(base))
7558 +
7559 +/* Tx Scheduler Registers */
7560 +#define pTX_CH_MAPPING_REG(base) ((volatile bit32u *)(base+0x0170))
7561 +#define TX_CH_MAPPING_REG(base) (*pTX_CH_MAPPING_REG(base))
7562 +
7563 +/* Tx CPPI DMA Controller Registers */
7564 +#define pTX_CPPI_CTL_REG(base) ((volatile bit32u *)(base+0x0700))
7565 +#define TX_CPPI_CTL_REG(base) (*pTX_CPPI_CTL_REG(base))
7566 +#define pTX_CPPI_TEARDOWN_REG(base) ((volatile bit32u *)(base+0x0704))
7567 +#define TX_CPPI_TEARDOWN_REG(base) (*pTX_CPPI_TEARDOWN_REG(base))
7568 +
7569 +/* EOI Interrupt Additions */
7570 +#define pSAR_EOI(base) ((volatile bit32u *)(base+0x0708))
7571 +#define SAR_EOI(base) (*pSAR_EOI(base))
7572 +#define pSAR_INTR_VECTOR(base) ((volatile bit32u *)(base+0x070c))
7573 +#define SAR_INTR_VECTOR(base) (*pSAR_INTR_VECTOR(base))
7574 +#define pSAR_TX_MASKED_STATUS(base) ((volatile bit32u *)(base+0x0710))
7575 +#define SAR_TX_MASKED_STATUS(base) (*pSAR_TX_MASKED_STATUS(base))
7576 +#define pSAR_TX_RAW_STATUS(base) ((volatile bit32u *)(base+0x0714))
7577 +#define SAR_TX_RAW_STATUS(base) (*pSAR_TX_RAW_STATUS(base))
7578 +#define pSAR_TX_MASK_SET(base) ((volatile bit32u *)(base+0x0718))
7579 +#define SAR_TX_MASK_SET(base) (*pSAR_TX_MASK_SET(base))
7580 +#define pSAR_TX_MASK_CLR(base) ((volatile bit32u *)(base+0x071c))
7581 +#define SAR_TX_MASK_CLR(base) (*pSAR_TX_MASK_CLR(base))
7582 +
7583 +/* Rx CPPI DMA Controller Registers */
7584 +#define pRX_CPPI_CTL_REG(base) ((volatile bit32u *)(base+0x0780))
7585 +#define RX_CPPI_CTL_REG(base) (*pRX_CPPI_CTL_REG(base))
7586 +#define pSAR_RX_MASKED_STATUS(base) ((volatile bit32u *)(base+0x0790))
7587 +#define SAR_RX_MASKED_STATUS(base) (*pSAR_RX_MASKED_STATUS(base))
7588 +#define pSAR_RX_RAW_STATUS(base) ((volatile bit32u *)(base+0x0794))
7589 +#define SAR_RX_RAW_STATUS(base) (*pSAR_RX_RAW_STATUS(base))
7590 +#define pSAR_RX_MASK_SET(base) ((volatile bit32u *)(base+0x0798))
7591 +#define SAR_RX_MASK_SET(base) (*pSAR_RX_MASK_SET(base))
7592 +#define pSAR_RX_MASK_CLR(base) ((volatile bit32u *)(base+0x079c))
7593 +#define SAR_RX_MASK_CLR(base) (*pSAR_RX_MASK_CLR(base))
7594 +
7595 +/* PDSP Control/Status Registers */
7596 +#define pPDSP_CTRL_REG(base) ((volatile bit32u *)(base+0x4000))
7597 +#define PDSP_CTRL_REG(base) (*pPDSP_CTRL_REG(base))
7598 +
7599 +/* PDSP Instruction RAM */
7600 +#define pPDSP_IRAM(base) ((volatile bit32u *)(base+0x4020))
7601 +#define PDSP_IRAM(base) (*pPDSP_IRAM(base))
7602 +
7603 +/*
7604 + * Channel 0 State/Scratchpad RAM Block
7605 + *
7606 + * The following registers (Tx DMA State, Rx DMA State, CPPI Completion PTR,
7607 + * and PDSP Data) have been given the correct address for channel 0. To
7608 + * reach the registers for channel X, add (X * 0x100) to the pointer address.
7609 + *
7610 + */
7611 +
7612 +#define PDSP_STATE_RAM_SIZE 1024
7613 +
7614 +/* Tx DMA State RAM */
7615 +#define pTX_DMA_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8000))
7616 +#define TX_DMA_STATE_WORD_0(base) (*pTX_DMA_STATE_WORD_0(base))
7617 +#define pTX_DMA_STATE_WORD_1(base) ((volatile bit32u *)(base+0x8004))
7618 +#define TX_DMA_STATE_WORD_1(base) (*pTX_DMA_STATE_WORD_1(base))
7619 +#define pTX_DMA_STATE_WORD_2(base) ((volatile bit32u *)(base+0x8008))
7620 +#define TX_DMA_STATE_WORD_2(base) (*pTX_DMA_STATE_WORD_2(base))
7621 +#define pTX_DMA_STATE_WORD_3(base) ((volatile bit32u *)(base+0x800C))
7622 +#define TX_DMA_STATE_WORD_3(base) (*pTX_DMA_STATE_WORD_3(base))
7623 +#define pTX_DMA_STATE_WORD_4(base) ((volatile bit32u *)(base+0x8010))
7624 +#define TX_DMA_STATE_WORD_4(base) (*pTX_DMA_STATE_WORD_4(base))
7625 +#define pTX_DMA_STATE_WORD_5(base) ((volatile bit32u *)(base+0x8014))
7626 +#define TX_DMA_STATE_WORD_5(base) (*pTX_DMA_STATE_WORD_5(base))
7627 +#define pTX_DMA_STATE_WORD_6(base) ((volatile bit32u *)(base+0x8018))
7628 +#define TX_DMA_STATE_WORD_6(base) (*pTX_DMA_STATE_WORD_6(base))
7629 +#define pTX_DMA_STATE_WORD_7(base) ((volatile bit32u *)(base+0x801C))
7630 +#define TX_DMA_STATE_WORD_7(base) (*pTX_DMA_STATE_WORD_7(base))
7631 +#define pTX_DMA_STATE_WORD_8(base) ((volatile bit32u *)(base+0x8020))
7632 +#define TX_DMA_STATE_WORD_8(base) (*pTX_DMA_STATE_WORD_8(base))
7633 +
7634 +/* Rx DMA State RAM */
7635 +#define pRX_DMA_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8024))
7636 +#define RX_DMA_STATE_WORD_0(base) (*pRX_DMA_STATE_WORD_0(base))
7637 +#define pRX_DMA_STATE_WORD_1(base) ((volatile bit32u *)(base+0x8028))
7638 +#define RX_DMA_STATE_WORD_1(base) (*pRX_DMA_STATE_WORD_1(base))
7639 +#define pRX_DMA_STATE_WORD_2(base) ((volatile bit32u *)(base+0x802C))
7640 +#define RX_DMA_STATE_WORD_2(base) (*pRX_DMA_STATE_WORD_2(base))
7641 +#define pRX_DMA_STATE_WORD_3(base) ((volatile bit32u *)(base+0x8030))
7642 +#define RX_DMA_STATE_WORD_3(base) (*pRX_DMA_STATE_WORD_3(base))
7643 +#define pRX_DMA_STATE_WORD_4(base) ((volatile bit32u *)(base+0x8034))
7644 +#define RX_DMA_STATE_WORD_4(base) (*pRX_DMA_STATE_WORD_4(base))
7645 +#define pRX_DMA_STATE_WORD_5(base) ((volatile bit32u *)(base+0x8038))
7646 +#define RX_DMA_STATE_WORD_5(base) (*pRX_DMA_STATE_WORD_5(base))
7647 +#define pRX_DMA_STATE_WORD_6(base) ((volatile bit32u *)(base+0x803C))
7648 +#define RX_DMA_STATE_WORD_6(base) (*pRX_DMA_STATE_WORD_6(base))
7649 +
7650 +/* Tx CPPI Completion Pointers */
7651 +#define pTXH_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8040))
7652 +#define TXH_CPPI_COMP_PTR(base) (*pTXH_CPPI_COMP_PTR(base))
7653 +#define pTXL_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8044))
7654 +#define TXL_CPPI_COMP_PTR(base) (*pTXL_CPPI_COMP_PTR(base))
7655 +
7656 +/* Rx CPPI Completion Pointer */
7657 +#define pRX_CPPI_COMP_PTR(base) ((volatile bit32u *)(base+0x8048))
7658 +#define RX_CPPI_COMP_PTR(base) (*pRX_CPPI_COMP_PTR(base))
7659 +
7660 +/* Tx PDSP Defines */
7661 +#define NUM_PDSP_AAL5_STATE_WORDS 24
7662 +#define NUM_PDSP_AAL2_STATE_WORDS 20
7663 +
7664 +/* PDSP State RAM Block 0 */
7665 +#define pPDSP_BLOCK_0(base) ((volatile bit32u *)(base+0x8050))
7666 +#define PDSP_BLOCK_0(base) (*pPDSP_BLOCK_0(base))
7667 +
7668 +/* AAL5 Tx PDSP State RAM */
7669 +#define pPDSP_AAL5_TX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8050))
7670 +#define PDSP_AAL5_TX_STATE_WORD_0(base) (*pPDSP_AAL5_TX_STATE_WORD_0(base))
7671 +
7672 +/* AAL5 Rx PDSP State RAM */
7673 +#define pPDSP_AAL5_RX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8070))
7674 +#define PDSP_AAL5_RX_STATE_WORD_0(base) (*pPDSP_AAL5_RX_STATE_WORD_0(base))
7675 +
7676 +/* AAL5 Tx VP PDSP State RAM */
7677 +#define pPDSP_AAL5_TX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x8090))
7678 +#define PDSP_AAL5_TX_VP_STATE_WORD_0(base) (*pPDSP_AAL5_TX_VP_STATE_WORD_0(base))
7679 +
7680 +/* AAL5 Rx VP PDSP State RAM */
7681 +#define pPDSP_AAL5_RX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80A0))
7682 +#define PDSP_AAL5_RX_VP_STATE_WORD_0(base) (*pPDSP_AAL5_RX_VP_STATE_WORD_0(base))
7683 +
7684 +/* AAL2 Tx PDSP State RAM */
7685 +#define pPDSP_AAL2_TX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80B0))
7686 +#define PDSP_AAL2_TX_STATE_WORD_0(base) (*pPDSP_AAL2_TX_STATE_WORD_0(base))
7687 +
7688 +/* AAL2 Rx PDSP State RAM */
7689 +#define pPDSP_AAL2_RX_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80D0))
7690 +#define PDSP_AAL2_RX_STATE_WORD_0(base) (*pPDSP_AAL2_RX_STATE_WORD_0(base))
7691 +
7692 +/* AAL2 Tx VP PDSP State RAM */
7693 +#define pPDSP_AAL2_TX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80E0))
7694 +#define PDSP_AAL2_TX_VP_STATE_WORD_0(base) (*pPDSP_AAL2_TX_VP_STATE_WORD_0(base))
7695 +
7696 +/* AAL2 Rx VP PDSP State RAM */
7697 +#define pPDSP_AAL2_RX_VP_STATE_WORD_0(base) ((volatile bit32u *)(base+0x80F0))
7698 +#define PDSP_AAL2_RX_VP_STATE_WORD_0(base) (*pPDSP_AAL2_RX_VP_STATE_WORD_0(base))
7699 +
7700 +/* PDSP OAM Configuration Block */
7701 +#define pOAM_CONFIG_BLOCK_WORD_0(base) ((volatile bit32u *)(base+0x83C0))
7702 +#define OAM_CONFIG_BLOCK_WORD_0(base) (*pOAM_CONFIG_BLOCK_WORD_0(base))
7703 +
7704 +/* PDSP OAM Padding Block */
7705 +#define pOAM_PADDING_BLOCK_WORD_0(base) ((volatile bit32u *)(base+0x84C0))
7706 +#define OAM_PADDING_BLOCK_WORD_0(base) (*pOAM_PADDING_BLOCK_WORD_0(base))
7707 +
7708 +#define NUM_OAM_RATES 11
7709 +
7710 +/* PDSP OAM Timer State RAM */
7711 +#define pOAM_TIMER_STATE_WORD_0(base) ((volatile bit32u *)(base+0x85B0))
7712 +#define OAM_TIMER_STATE_WORD_0(base) (*pOAM_TIMER_STATE_WORD_0(base))
7713 +
7714 +
7715 +/* END OF FILE */
7716 +
7717 +#endif _INC_SAR_REG
7718 diff -urN linux.old/drivers/atm/sangam_atm/cpswhal_cpaal5.h linux.dev/drivers/atm/sangam_atm/cpswhal_cpaal5.h
7719 --- linux.old/drivers/atm/sangam_atm/cpswhal_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
7720 +++ linux.dev/drivers/atm/sangam_atm/cpswhal_cpaal5.h 2005-08-23 04:46:50.088845064 +0200
7721 @@ -0,0 +1,629 @@
7722 +/************************************************************************
7723 + * TNETDxxxx Software Support
7724 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
7725 + *
7726 + * FILE: cphal.h
7727 + *
7728 + * DESCRIPTION:
7729 + * User include file, contains data definitions shared between the CPHAL
7730 + * and the upper-layer software.
7731 + *
7732 + * HISTORY:
7733 + * Date Modifier Ver Notes
7734 + * 28Feb02 Greg 1.00 Original
7735 + * 06Mar02 Greg 1.01 Documentation enhanced
7736 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
7737 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
7738 + *
7739 + * author Greg Guyotte
7740 + * version 1.02
7741 + * date 18-Jul-2002
7742 + *****************************************************************************/
7743 +#ifndef _INC_CPHAL_H
7744 +#define _INC_CPHAL_H
7745 +
7746 +#ifdef _CPHAL_CPMAC
7747 +#include "ec_errors_cpmac.h"
7748 +#endif
7749 +
7750 +#ifdef _CPHAL_AAL5
7751 +#include "ec_errors_cpaal5.h"
7752 +#endif
7753 +
7754 +#ifdef _CPHAL_CPSAR
7755 +#include "ec_errors_cpsar.h"
7756 +#endif
7757 +
7758 +#ifdef _CPHAL_AAL2
7759 +#include "ec_errors_cpaal2.h"
7760 +#endif
7761 +
7762 +#ifndef __ADAM2
7763 +typedef char bit8;
7764 +typedef short bit16;
7765 +typedef int bit32;
7766 +
7767 +typedef unsigned char bit8u;
7768 +typedef unsigned short bit16u;
7769 +typedef unsigned int bit32u;
7770 +
7771 +/*
7772 +typedef char INT8;
7773 +typedef short INT16;
7774 +typedef int INT32;
7775 +typedef unsigned char UINT8;
7776 +typedef unsigned short UINT16;
7777 +typedef unsigned int UINT32;
7778 +*/
7779 +/*typedef unsigned int size_t;*/
7780 +#endif
7781 +
7782 +#ifdef _CPHAL
7783 +
7784 +#ifndef TRUE
7785 +#define TRUE (1==1)
7786 +#endif
7787 +
7788 +#ifndef FALSE
7789 +#define FALSE (1==2)
7790 +#endif
7791 +
7792 +#ifndef NULL
7793 +#define NULL 0
7794 +#endif
7795 +
7796 +#endif
7797 +
7798 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
7799 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
7800 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
7801 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
7802 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
7803 +/*
7804 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
7805 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
7806 +*/
7807 +
7808 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
7809 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
7810 +
7811 +/* Channel Teardown Defines */
7812 +#define RX_TEARDOWN 2
7813 +#define TX_TEARDOWN 1
7814 +#define BLOCKING_TEARDOWN 8
7815 +#define FULL_TEARDOWN 4
7816 +#define PARTIAL_TEARDOWN 0
7817 +
7818 +#define MAX_DIR 2
7819 +#define DIRECTION_TX 0
7820 +#define DIRECTION_RX 1
7821 +#define TX_CH 0
7822 +#define RX_CH 1
7823 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
7824 +#define HAL_ERROR_FAILED_MALLOC 2
7825 +#define HAL_ERROR_OSFUNC_SIZE 3
7826 +#define HAL_DEFAULT 0xFFFFFFFF
7827 +#define VALID(val) (val!=HAL_DEFAULT)
7828 +
7829 +/*
7830 +ERROR REPORTING
7831 +
7832 +HAL Module Codes. Each HAL module reporting an error code
7833 +should OR the error code with the respective Module error code
7834 +from the list below.
7835 +*/
7836 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
7837 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
7838 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
7839 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
7840 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
7841 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
7842 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
7843 +
7844 +/*
7845 +HAL Function Codes. Each HAL module reporting an error code
7846 +should OR the error code with one of the function codes from
7847 +the list below.
7848 +*/
7849 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
7850 +#define EC_FUNC_CHSETUP EC_FUNC(2)
7851 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
7852 +#define EC_FUNC_RXRETURN EC_FUNC(4)
7853 +#define EC_FUNC_SEND EC_FUNC(5)
7854 +#define EC_FUNC_RXINT EC_FUNC(6)
7855 +#define EC_FUNC_TXINT EC_FUNC(7)
7856 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
7857 +#define EC_FUNC_OPTIONS EC_FUNC(9)
7858 +#define EC_FUNC_PROBE EC_FUNC(10)
7859 +#define EC_FUNC_OPEN EC_FUNC(11)
7860 +#define EC_FUNC_CONTROL EC_FUNC(12)
7861 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
7862 +#define EC_FUNC_STATUS EC_FUNC(14)
7863 +#define EC_FUNC_TICK EC_FUNC(15)
7864 +#define EC_FUNC_CLOSE EC_FUNC(16)
7865 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
7866 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
7867 +
7868 +/*
7869 +HAL Error Codes. The list below defines every type of error
7870 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
7871 +values in integer order to the bottom of the list.
7872 +*/
7873 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
7874 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
7875 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
7876 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
7877 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
7878 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
7879 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
7880 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
7881 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
7882 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
7883 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
7884 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
7885 +
7886 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
7887 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
7888 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
7889 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
7890 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
7891 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
7892 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
7893 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
7894 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
7895 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
7896 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
7897 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
7898 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
7899 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
7900 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
7901 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
7902 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
7903 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
7904 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
7905 +
7906 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
7907 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
7908 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
7909 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
7910 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
7911 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
7912 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
7913 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
7914 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
7915 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
7916 +
7917 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
7918 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
7919 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
7920 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
7921 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
7922 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
7923 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
7924 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
7925 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
7926 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
7927 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
7928 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
7929 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
7930 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
7931 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
7932 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
7933 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
7934 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
7935 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
7936 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
7937 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
7938 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
7939 +
7940 +/**
7941 +@defgroup shared_data Shared Data Structures
7942 +
7943 +The data structures documented here are shared by all modules.
7944 +*/
7945 +
7946 +/**
7947 + * @ingroup shared_data
7948 + * This is the fragment list structure. Each fragment list entry contains a
7949 + * length and a data buffer.
7950 + */
7951 +typedef struct
7952 + {
7953 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
7954 + void *data; /**< Pointer to fragment data. */
7955 + void *OsInfo; /**< Pointer to OS defined data. */
7956 + }FRAGLIST;
7957 +
7958 +#if defined (_CPHAL_CPMAC)
7959 +#define CB_PASSCRC_BIT (1<<26)
7960 +
7961 +/* CPMAC CPHAL STATUS */
7962 +#define CPMAC_STATUS_LINK (1 << 0)
7963 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
7964 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
7965 +
7966 +/* ADAPTER CHECK Codes */
7967 +
7968 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
7969 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
7970 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
7971 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
7972 +
7973 +#define _CPMDIO_DISABLE (1 << 0)
7974 +#define _CPMDIO_HD (1 << 1)
7975 +#define _CPMDIO_FD (1 << 2)
7976 +#define _CPMDIO_10 (1 << 3)
7977 +#define _CPMDIO_100 (1 << 4)
7978 +#define _CPMDIO_NEG_OFF (1 << 5)
7979 +#define _CPMDIO_LOOPBK (1 << 16)
7980 +#define _CPMDIO_NOPHY (1 << 20)
7981 +#endif
7982 +
7983 +/**
7984 + * @ingroup shared_data
7985 + * Channel specific configuration information. This structure should be
7986 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
7987 + * configuration item that can be changed on a per channel basis should
7988 + * be represented here. Each module may define this structure with additional
7989 + * module-specific members.
7990 + */
7991 +typedef struct
7992 + {
7993 + int Channel; /**< Channel number. */
7994 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
7995 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
7996 +
7997 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
7998 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
7999 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
8000 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
8001 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
8002 +
8003 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
8004 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
8005 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
8006 +#endif
8007 +
8008 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8009 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
8010 + int Gfc; /**< Generic Flow Control. */
8011 + int Clp; /**< Cell Loss Priority. */
8012 + int Pti; /**< Payload Type Indication. */
8013 +#endif
8014 +
8015 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8016 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
8017 + int Priority; /**< Priority bin this channel will be scheduled within. */
8018 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
8019 + int Vci; /**< Virtual Channel Identifier. */
8020 + int Vpi; /**< Virtual Path Identifier. */
8021 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
8022 +
8023 + /* Tx VC State */
8024 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
8025 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
8026 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
8027 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
8028 +
8029 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
8030 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
8031 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
8032 + /* Rx VC State */
8033 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8034 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
8035 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
8036 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
8037 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
8038 + /* Tx VP State */
8039 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
8040 + bit32 TxVp_AtmHeader; /**< ATM Header placed on firmware gen'd VP OAM cells for this Tx VP conn (must be big endian with 0 VCI). */
8041 + /* Rx VP State */
8042 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8043 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
8044 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
8045 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
8046 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
8047 +#endif
8048 +
8049 +
8050 +#ifdef _CPHAL_VDMAVT
8051 + bit32u RemFifoAddr; /* Mirror mode only. */
8052 + bit32u FifoAddr;
8053 + bit32 PollInt;
8054 + bit32 FifoSize;
8055 + int Ready;
8056 +#endif
8057 +
8058 + }CHANNEL_INFO;
8059 +
8060 +/*
8061 + * This structure contains each statistic value gathered by the CPHAL.
8062 + * Applications may access statistics data by using the @c StatsGet() routine.
8063 + */
8064 +/* STATS */
8065 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8066 +typedef struct
8067 + {
8068 + bit32u CrcErrors[16];
8069 + bit32u LenErrors[16];
8070 + bit32u DmaLenErrors[16];
8071 + bit32u AbortErrors[16];
8072 + bit32u StarvErrors[16];
8073 + bit32u TxMisQCnt[16][2];
8074 + bit32u RxMisQCnt[16];
8075 + bit32u RxEOQCnt[16];
8076 + bit32u TxEOQCnt[16][2];
8077 + bit32u RxPacketsServiced[16];
8078 + bit32u TxPacketsServiced[16][2];
8079 + bit32u RxMaxServiced;
8080 + bit32u TxMaxServiced[16][2];
8081 + bit32u RxTotal;
8082 + bit32u TxTotal;
8083 + } STAT_INFO;
8084 +#endif
8085 +
8086 +/*
8087 + * VDMA Channel specific configuration information
8088 + */
8089 +#ifdef _CPHAL_AAL2
8090 +typedef struct
8091 + {
8092 + int Ch; /**< Channel Number */
8093 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
8094 + int CpsSwap; /**< When 0, octet 0 in CPS pkt located in LS byte of 16-bit word sent to rem VDMA device. When 1, in MS byte. */
8095 + }VdmaChInfo;
8096 +#endif
8097 +
8098 +#ifndef _CPHAL
8099 + typedef void HAL_DEVICE;
8100 + typedef void HAL_PRIVATE;
8101 + typedef void HAL_RCB;
8102 + typedef void HAL_RECEIVEINFO;
8103 +#endif
8104 +
8105 +/**
8106 + * @ingroup shared_data
8107 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
8108 + * software. The upper layer software receives these pointers through the
8109 + * call to xxxInitModule().
8110 + */
8111 +typedef struct
8112 + {
8113 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
8114 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
8115 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
8116 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8117 + int (*Init) (HAL_DEVICE *HalDev);
8118 + int (*Open) (HAL_DEVICE *HalDev);
8119 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
8120 + int (*Probe) (HAL_DEVICE *HalDev);
8121 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8122 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
8123 + int (*Shutdown) (HAL_DEVICE *HalDev);
8124 + int (*Tick) (HAL_DEVICE *HalDev);
8125 +
8126 +#ifdef _CPHAL_AAL5
8127 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
8128 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
8129 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
8130 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8131 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
8132 +#endif
8133 + } HAL_FUNCTIONS;
8134 +
8135 +/**
8136 + * @ingroup shared_data
8137 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
8138 + * functions accessible to the CPHAL. The upper layer software is responsible
8139 + * for providing the correct OS-specific implementations for the following
8140 + * functions. It is populated by calling InitModule() (done by the CPHAL in
8141 + * xxxInitModule().
8142 + */
8143 +typedef struct
8144 + {
8145 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
8146 + void (*CriticalOn)(void);
8147 + void (*CriticalOff)(void);
8148 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
8149 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
8150 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
8151 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
8152 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
8153 + void (*Free)(void *MemPtr);
8154 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
8155 + void (*FreeDev)(void *MemPtr);
8156 + void (*FreeDmaXfer)(void *MemPtr);
8157 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
8158 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
8159 + void* (*Malloc)(bit32u size);
8160 + void* (*MallocDev)(bit32u Size);
8161 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
8162 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
8163 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8164 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
8165 + void* (*Memset)(void *Dest, int C, bit32u N);
8166 + int (*Printf)(const char *Format, ...);
8167 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
8168 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
8169 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
8170 + int (*Sprintf)(char *S, const char *Format, ...);
8171 + int (*Strcmpi)(const char *Str1, const char *Str2);
8172 + unsigned int (*Strlen)(const char *S);
8173 + char* (*Strstr)(const char *S1, const char *S2);
8174 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
8175 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
8176 + } OS_FUNCTIONS;
8177 +
8178 +/************** MODULE SPECIFIC STUFF BELOW **************/
8179 +
8180 +#ifdef _CPHAL_CPMAC
8181 +
8182 +/*
8183 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
8184 +*/
8185 +
8186 +int halCpmacInitModule(HAL_DEVICE **HalDev,
8187 + OS_DEVICE *OsDev,
8188 + HAL_FUNCTIONS **HalFunc,
8189 + OS_FUNCTIONS *OsFunc,
8190 + int OsFuncSize,
8191 + int *HalFuncSize,
8192 + int Inst);
8193 +#endif
8194 +
8195 +#ifdef _CPHAL_AAL5
8196 +/*
8197 + * @ingroup shared_data
8198 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
8199 + * software. The upper layer software receives these pointers through the
8200 + * call to cphalInitModule().
8201 + */
8202 +/*
8203 +typedef struct
8204 + {
8205 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8206 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8207 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8208 + int (*Init)(HAL_DEVICE *HalDev);
8209 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8210 + int (*Open)(HAL_DEVICE *HalDev);
8211 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
8212 + int (*Probe)(HAL_DEVICE *HalDev);
8213 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8214 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
8215 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
8216 + bit32u Mode);
8217 + int (*StatsClear)(HAL_DEVICE *HalDev);
8218 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8219 + int (*Status)(HAL_DEVICE *HalDev);
8220 + void (*Tick)(HAL_DEVICE *HalDev);
8221 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
8222 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8223 + } AAL5_FUNCTIONS;
8224 +*/
8225 +
8226 +int cpaal5InitModule(HAL_DEVICE **HalDev,
8227 + OS_DEVICE *OsDev,
8228 + HAL_FUNCTIONS **HalFunc,
8229 + OS_FUNCTIONS *OsFunc,
8230 + int OsFuncSize,
8231 + int *HalFuncSize,
8232 + int Inst);
8233 +#endif
8234 +
8235 +#ifdef _CPHAL_AAL2
8236 +/**
8237 + * @ingroup shared_data
8238 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
8239 + * software. The upper layer software receives these pointers through the
8240 + * call to cphalInitModule().
8241 + */
8242 +typedef struct
8243 + {
8244 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8245 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8246 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8247 + int (*Init)(HAL_DEVICE *HalDev);
8248 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8249 + int (*Open)(HAL_DEVICE *HalDev);
8250 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
8251 + int (*Probe)(HAL_DEVICE *HalDev);
8252 +
8253 + int (*StatsClear)(HAL_DEVICE *HalDev);
8254 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8255 + int (*Status)(HAL_DEVICE *HalDev);
8256 + void (*Tick)(HAL_DEVICE *HalDev);
8257 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
8258 + int VdmaCh, int UUIDiscard);
8259 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
8260 + int LC);
8261 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
8262 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
8263 + VdmaChInfo *VdmaCh);
8264 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8265 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
8266 + int RxMultiMode, int TxMultiMode, int SchedMode,
8267 + int TcCh);
8268 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
8269 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
8270 + } AAL2_FUNCTIONS;
8271 +
8272 +int cpaal2InitModule(HAL_DEVICE **HalDev,
8273 + OS_DEVICE *OsDev,
8274 + AAL2_FUNCTIONS **HalFunc,
8275 + OS_FUNCTIONS *OsFunc,
8276 + int OsFuncSize,
8277 + int *HalFuncSize,
8278 + int Inst);
8279 +#endif
8280 +
8281 +#ifdef _CPHAL_VDMAVT
8282 +/**
8283 + * @ingroup shared_data
8284 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
8285 + * software. The upper layer software receives these pointers through the
8286 + * call to InitModule().
8287 + *
8288 + * Note that this list is still under definition.
8289 + */
8290 +typedef struct
8291 + {
8292 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
8293 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8294 + bit32u Addr, bit32u Size, bit32u PollInt);
8295 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8296 + bit32u Addr, bit32u Size, bit32u PollInt); */
8297 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
8298 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
8299 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
8300 + bit32u RemDevID);
8301 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
8302 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
8303 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
8304 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
8305 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8306 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8307 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
8308 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
8309 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
8310 + } VDMA_FUNCTIONS;
8311 +
8312 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
8313 + OS_DEVICE *OsDev,
8314 + VDMA_FUNCTIONS **VdmaVtFunc,
8315 + OS_FUNCTIONS *OsFunc,
8316 + int OsFuncSize,
8317 + int *HalFuncSize,
8318 + int Inst);
8319 +#endif
8320 +
8321 +/*
8322 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
8323 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
8324 + int *Size, int Inst);
8325 +*/
8326 +
8327 +
8328 +#ifdef _CPHAL_AAL5
8329 +extern const char hcSarFrequency[];
8330 +#endif
8331 +
8332 +#ifdef _CPHAL_CPMAC
8333 +/* following will be common, once 'utl' added */
8334 +extern const char hcClear[];
8335 +extern const char hcGet[];
8336 +extern const char hcSet[];
8337 +extern const char hcTick[];
8338 +
8339 +extern const char hcCpuFrequency[];
8340 +extern const char hcCpmacFrequency[];
8341 +extern const char hcMdioBusFrequency[];
8342 +extern const char hcMdioClockFrequency[];
8343 +extern const char hcCpmacBase[];
8344 +extern const char hcPhyNum[];
8345 +extern const char hcSize[];
8346 +extern const char hcCpmacSize[];
8347 +extern const char hcPhyAccess[];
8348 +#endif
8349 +
8350 +#endif /* end of _INC_ */
8351 diff -urN linux.old/drivers/atm/sangam_atm/cpswhal_cpsar.h linux.dev/drivers/atm/sangam_atm/cpswhal_cpsar.h
8352 --- linux.old/drivers/atm/sangam_atm/cpswhal_cpsar.h 1970-01-01 01:00:00.000000000 +0100
8353 +++ linux.dev/drivers/atm/sangam_atm/cpswhal_cpsar.h 2005-08-23 04:46:50.089844912 +0200
8354 @@ -0,0 +1,629 @@
8355 +/************************************************************************
8356 + * TNETDxxxx Software Support
8357 + * Copyright (c) 2002 Texas Instruments Incorporated. All Rights Reserved.
8358 + *
8359 + * FILE: cphal.h
8360 + *
8361 + * DESCRIPTION:
8362 + * User include file, contains data definitions shared between the CPHAL
8363 + * and the upper-layer software.
8364 + *
8365 + * HISTORY:
8366 + * Date Modifier Ver Notes
8367 + * 28Feb02 Greg 1.00 Original
8368 + * 06Mar02 Greg 1.01 Documentation enhanced
8369 + * 18Jul02 Greg 1.02 Many updates (OAM additions, general reorg)
8370 + * 22Nov02 Mick RC2 Additions from Denis' input on Control
8371 + *
8372 + * author Greg Guyotte
8373 + * version 1.02
8374 + * date 18-Jul-2002
8375 + *****************************************************************************/
8376 +#ifndef _INC_CPHAL_H
8377 +#define _INC_CPHAL_H
8378 +
8379 +#ifdef _CPHAL_CPMAC
8380 +#include "ec_errors_cpmac.h"
8381 +#endif
8382 +
8383 +#ifdef _CPHAL_AAL5
8384 +#include "ec_errors_cpaal5.h"
8385 +#endif
8386 +
8387 +#ifdef _CPHAL_CPSAR
8388 +#include "ec_errors_cpsar.h"
8389 +#endif
8390 +
8391 +#ifdef _CPHAL_AAL2
8392 +#include "ec_errors_cpaal2.h"
8393 +#endif
8394 +
8395 +#ifndef __ADAM2
8396 +typedef char bit8;
8397 +typedef short bit16;
8398 +typedef int bit32;
8399 +
8400 +typedef unsigned char bit8u;
8401 +typedef unsigned short bit16u;
8402 +typedef unsigned int bit32u;
8403 +
8404 +/*
8405 +typedef char INT8;
8406 +typedef short INT16;
8407 +typedef int INT32;
8408 +typedef unsigned char UINT8;
8409 +typedef unsigned short UINT16;
8410 +typedef unsigned int UINT32;
8411 +*/
8412 +/*typedef unsigned int size_t;*/
8413 +#endif
8414 +
8415 +#ifdef _CPHAL
8416 +
8417 +#ifndef TRUE
8418 +#define TRUE (1==1)
8419 +#endif
8420 +
8421 +#ifndef FALSE
8422 +#define FALSE (1==2)
8423 +#endif
8424 +
8425 +#ifndef NULL
8426 +#define NULL 0
8427 +#endif
8428 +
8429 +#endif
8430 +
8431 +#define VirtToPhys(a) (((int)a)&~0xe0000000)
8432 +#define VirtToVirtNoCache(a) ((void*)((VirtToPhys(a))|0xa0000000))
8433 +#define VirtToVirtCache(a) ((void*)((VirtToPhys(a))|0x80000000))
8434 +#define PhysToVirtNoCache(a) ((void*)(((int)a)|0xa0000000))
8435 +#define PhysToVirtCache(a) ((void*)(((int)a)|0x80000000))
8436 +/*
8437 +#define DataCacheHitInvalidate(a) {__asm__(" cache 17, (%0)" : : "r" (a));}
8438 +#define DataCacheHitWriteback(a) {__asm__(" cache 25, (%0)" : : "r" (a));}
8439 +*/
8440 +
8441 +#define PARTIAL 1 /**< Used in @c Close() and @c ChannelTeardown() */
8442 +#define FULL 2 /**< Used in @c Close() and @c ChannelTeardown() */
8443 +
8444 +/* Channel Teardown Defines */
8445 +#define RX_TEARDOWN 2
8446 +#define TX_TEARDOWN 1
8447 +#define BLOCKING_TEARDOWN 8
8448 +#define FULL_TEARDOWN 4
8449 +#define PARTIAL_TEARDOWN 0
8450 +
8451 +#define MAX_DIR 2
8452 +#define DIRECTION_TX 0
8453 +#define DIRECTION_RX 1
8454 +#define TX_CH 0
8455 +#define RX_CH 1
8456 +#define HAL_ERROR_DEVICE_NOT_FOUND 1
8457 +#define HAL_ERROR_FAILED_MALLOC 2
8458 +#define HAL_ERROR_OSFUNC_SIZE 3
8459 +#define HAL_DEFAULT 0xFFFFFFFF
8460 +#define VALID(val) (val!=HAL_DEFAULT)
8461 +
8462 +/*
8463 +ERROR REPORTING
8464 +
8465 +HAL Module Codes. Each HAL module reporting an error code
8466 +should OR the error code with the respective Module error code
8467 +from the list below.
8468 +*/
8469 +#define EC_AAL5 EC_HAL|EC_DEV_AAL5
8470 +#define EC_AAL2 EC_HAL|EC_DEV_AAL2
8471 +#define EC_CPSAR EC_HAL|EC_DEV_CPSAR
8472 +#define EC_CPMAC EC_HAL|EC_DEV_CPMAC
8473 +#define EC_VDMA EC_HAL|EC_DEV_VDMA
8474 +#define EC_VLYNQ EC_HAL|EC_DEV_VLYNQ
8475 +#define EC_CPPI EC_HAL|EC_DEV_CPPI
8476 +
8477 +/*
8478 +HAL Function Codes. Each HAL module reporting an error code
8479 +should OR the error code with one of the function codes from
8480 +the list below.
8481 +*/
8482 +#define EC_FUNC_HAL_INIT EC_FUNC(1)
8483 +#define EC_FUNC_CHSETUP EC_FUNC(2)
8484 +#define EC_FUNC_CHTEARDOWN EC_FUNC(3)
8485 +#define EC_FUNC_RXRETURN EC_FUNC(4)
8486 +#define EC_FUNC_SEND EC_FUNC(5)
8487 +#define EC_FUNC_RXINT EC_FUNC(6)
8488 +#define EC_FUNC_TXINT EC_FUNC(7)
8489 +#define EC_FUNC_AAL2_VDMA EC_FUNC(8)
8490 +#define EC_FUNC_OPTIONS EC_FUNC(9)
8491 +#define EC_FUNC_PROBE EC_FUNC(10)
8492 +#define EC_FUNC_OPEN EC_FUNC(11)
8493 +#define EC_FUNC_CONTROL EC_FUNC(12)
8494 +#define EC_FUNC_DEVICE_INT EC_FUNC(13)
8495 +#define EC_FUNC_STATUS EC_FUNC(14)
8496 +#define EC_FUNC_TICK EC_FUNC(15)
8497 +#define EC_FUNC_CLOSE EC_FUNC(16)
8498 +#define EC_FUNC_SHUTDOWN EC_FUNC(17)
8499 +#define EC_FUNC_DEVICE_INT_ALT EC_FUNC(18) /* +GSG 030306 */
8500 +
8501 +/*
8502 +HAL Error Codes. The list below defines every type of error
8503 +used in all HAL modules. DO NOT CHANGE THESE VALUES! Add new
8504 +values in integer order to the bottom of the list.
8505 +*/
8506 +#define EC_VAL_PDSP_LOAD_FAIL EC_ERR(0x01)|EC_CRITICAL
8507 +#define EC_VAL_FIRMWARE_TOO_LARGE EC_ERR(0x02)|EC_CRITICAL
8508 +#define EC_VAL_DEVICE_NOT_FOUND EC_ERR(0x03)|EC_CRITICAL
8509 +#define EC_VAL_BASE_ADDR_NOT_FOUND EC_ERR(0x04)|EC_CRITICAL
8510 +#define EC_VAL_RESET_BIT_NOT_FOUND EC_ERR(0x05)|EC_CRITICAL
8511 +#define EC_VAL_CH_INFO_NOT_FOUND EC_ERR(0x06)
8512 +#define EC_VAL_RX_STATE_RAM_NOT_CLEARED EC_ERR(0x07)|EC_CRITICAL
8513 +#define EC_VAL_TX_STATE_RAM_NOT_CLEARED EC_ERR(0x08)|EC_CRITICAL
8514 +#define EC_VAL_MALLOC_DEV_FAILED EC_ERR(0x09)
8515 +#define EC_VAL_OS_VERSION_NOT_SUPPORTED EC_ERR(0x0A)|EC_CRITICAL
8516 +#define EC_VAL_CPSAR_VERSION_NOT_SUPPORTED EC_ERR(0x0B)|EC_CRITICAL
8517 +#define EC_VAL_NULL_CPSAR_DEV EC_ERR(0x0C)|EC_CRITICAL
8518 +
8519 +#define EC_VAL_LUT_NOT_READY EC_ERR(0x0D)
8520 +#define EC_VAL_INVALID_CH EC_ERR(0x0E)
8521 +#define EC_VAL_NULL_CH_STRUCT EC_ERR(0x0F)
8522 +#define EC_VAL_RX_TEARDOWN_ALREADY_PEND EC_ERR(0x10)
8523 +#define EC_VAL_TX_TEARDOWN_ALREADY_PEND EC_ERR(0x11)
8524 +#define EC_VAL_RX_CH_ALREADY_TORNDOWN EC_ERR(0x12)
8525 +#define EC_VAL_TX_CH_ALREADY_TORNDOWN EC_ERR(0x13)
8526 +#define EC_VAL_TX_TEARDOWN_TIMEOUT EC_ERR(0x14)
8527 +#define EC_VAL_RX_TEARDOWN_TIMEOUT EC_ERR(0x15)
8528 +#define EC_VAL_CH_ALREADY_TORNDOWN EC_ERR(0x16)
8529 +#define EC_VAL_VC_SETUP_NOT_READY EC_ERR(0x17)
8530 +#define EC_VAL_VC_TEARDOWN_NOT_READY EC_ERR(0x18)
8531 +#define EC_VAL_INVALID_VC EC_ERR(0x19)
8532 +#define EC_VAL_INVALID_LC EC_ERR(0x20)
8533 +#define EC_VAL_INVALID_VDMA_CH EC_ERR(0x21)
8534 +#define EC_VAL_INVALID_CID EC_ERR(0x22)
8535 +#define EC_VAL_INVALID_UUI EC_ERR(0x23)
8536 +#define EC_VAL_INVALID_UUI_DISCARD EC_ERR(0x24)
8537 +#define EC_VAL_CH_ALREADY_OPEN EC_ERR(0x25)
8538 +
8539 +#define EC_VAL_RCB_MALLOC_FAILED EC_ERR(0x26)
8540 +#define EC_VAL_RX_BUFFER_MALLOC_FAILED EC_ERR(0x27)
8541 +#define EC_VAL_OUT_OF_TCBS EC_ERR(0x28)
8542 +#define EC_VAL_NO_TCBS EC_ERR(0x29)
8543 +#define EC_VAL_NULL_RCB EC_ERR(0x30)|EC_CRITICAL
8544 +#define EC_VAL_SOP_ERROR EC_ERR(0x31)|EC_CRITICAL
8545 +#define EC_VAL_EOP_ERROR EC_ERR(0x32)|EC_CRITICAL
8546 +#define EC_VAL_NULL_TCB EC_ERR(0x33)|EC_CRITICAL
8547 +#define EC_VAL_CORRUPT_RCB_CHAIN EC_ERR(0x34)|EC_CRITICAL
8548 +#define EC_VAL_TCB_MALLOC_FAILED EC_ERR(0x35)
8549 +
8550 +#define EC_VAL_DISABLE_POLLING_FAILED EC_ERR(0x36)
8551 +#define EC_VAL_KEY_NOT_FOUND EC_ERR(0x37)
8552 +#define EC_VAL_MALLOC_FAILED EC_ERR(0x38)
8553 +#define EC_VAL_RESET_BASE_NOT_FOUND EC_ERR(0x39)|EC_CRITICAL
8554 +#define EC_VAL_INVALID_STATE EC_ERR(0x40)
8555 +#define EC_VAL_NO_TXH_WORK_TO_DO EC_ERR(0x41)
8556 +#define EC_VAL_NO_TXL_WORK_TO_DO EC_ERR(0x42)
8557 +#define EC_VAL_NO_RX_WORK_TO_DO EC_ERR(0x43)
8558 +#define EC_VAL_NOT_LINKED EC_ERR(0x44)
8559 +#define EC_VAL_INTERRUPT_NOT_FOUND EC_ERR(0x45)
8560 +#define EC_VAL_OFFSET_NOT_FOUND EC_ERR(0x46)
8561 +#define EC_VAL_MODULE_ALREADY_CLOSED EC_ERR(0x47)
8562 +#define EC_VAL_MODULE_ALREADY_SHUTDOWN EC_ERR(0x48)
8563 +#define EC_VAL_ACTION_NOT_FOUND EC_ERR(0x49)
8564 +#define EC_VAL_RX_CH_ALREADY_SETUP EC_ERR(0x50)
8565 +#define EC_VAL_TX_CH_ALREADY_SETUP EC_ERR(0x51)
8566 +#define EC_VAL_RX_CH_ALREADY_OPEN EC_ERR(0x52)
8567 +#define EC_VAL_TX_CH_ALREADY_OPEN EC_ERR(0x53)
8568 +#define EC_VAL_CH_ALREADY_SETUP EC_ERR(0x54)
8569 +#define EC_VAL_RCB_NEEDS_BUFFER EC_ERR(0x55) /* +GSG 030410 */
8570 +#define EC_VAL_RCB_DROPPED EC_ERR(0x56) /* +GSG 030410 */
8571 +#define EC_VAL_INVALID_VALUE EC_ERR(0x57)
8572 +
8573 +/**
8574 +@defgroup shared_data Shared Data Structures
8575 +
8576 +The data structures documented here are shared by all modules.
8577 +*/
8578 +
8579 +/**
8580 + * @ingroup shared_data
8581 + * This is the fragment list structure. Each fragment list entry contains a
8582 + * length and a data buffer.
8583 + */
8584 +typedef struct
8585 + {
8586 + bit32u len; /**< Length of the fragment in bytes (lower 16 bits are valid). For SOP, upper 16 bits is the buffer offset. */
8587 + void *data; /**< Pointer to fragment data. */
8588 + void *OsInfo; /**< Pointer to OS defined data. */
8589 + }FRAGLIST;
8590 +
8591 +#if defined (_CPHAL_CPMAC)
8592 +#define CB_PASSCRC_BIT (1<<26)
8593 +
8594 +/* CPMAC CPHAL STATUS */
8595 +#define CPMAC_STATUS_LINK (1 << 0)
8596 +#define CPMAC_STATUS_LINK_DUPLEX (1 << 1) /* 0 - HD, 1 - FD */
8597 +#define CPMAC_STATUS_LINK_SPEED (1 << 2) /* 0 - 10, 1 - 100 */
8598 +
8599 +/* ADAPTER CHECK Codes */
8600 +
8601 +#define CPMAC_STATUS_ADAPTER_CHECK (1 << 7)
8602 +#define CPMAC_STATUS_HOST_ERR_DIRECTION (1 << 8)
8603 +#define CPMAC_STATUS_HOST_ERR_CODE (0xF << 9)
8604 +#define CPMAC_STATUS_HOST_ERR_CH (0x7 << 13)
8605 +
8606 +#define _CPMDIO_DISABLE (1 << 0)
8607 +#define _CPMDIO_HD (1 << 1)
8608 +#define _CPMDIO_FD (1 << 2)
8609 +#define _CPMDIO_10 (1 << 3)
8610 +#define _CPMDIO_100 (1 << 4)
8611 +#define _CPMDIO_NEG_OFF (1 << 5)
8612 +#define _CPMDIO_LOOPBK (1 << 16)
8613 +#define _CPMDIO_NOPHY (1 << 20)
8614 +#endif
8615 +
8616 +/**
8617 + * @ingroup shared_data
8618 + * Channel specific configuration information. This structure should be
8619 + * populated by upper-layer software prior to calling @c ChannelSetup(). Any
8620 + * configuration item that can be changed on a per channel basis should
8621 + * be represented here. Each module may define this structure with additional
8622 + * module-specific members.
8623 + */
8624 +typedef struct
8625 + {
8626 + int Channel; /**< Channel number. */
8627 + int Direction; /**< DIRECTION_RX(1) or DIRECTION_TX(0). */
8628 + OS_SETUP *OsSetup; /**< OS defined information associated with this channel. */
8629 +
8630 +#if defined(_CPHAL_AAL5) || defined (_CPHAL_CPSAR) || defined (_CPHAL_CPMAC)
8631 + int RxBufSize; /**< Size (in bytes) for each Rx buffer.*/
8632 + int RxBufferOffset; /**< Number of bytes to offset rx data from start of buffer (must be less than buffer size). */
8633 + int RxNumBuffers; /**< The number of Rx buffer descriptors to allocate for Ch. */
8634 + int RxServiceMax; /**< Maximum number of packets to service at one time. */
8635 +
8636 + int TxNumBuffers; /**< The number of Tx buffer descriptors to allocate for Ch. */
8637 + int TxNumQueues; /**< Number of Tx queues for this channel (1-2). Choosing 2 enables a low priority SAR queue. */
8638 + int TxServiceMax; /**< Maximum number of packets to service at one time. */
8639 +#endif
8640 +
8641 +#if defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8642 + int CpcsUU; /**< The 2-byte CPCS UU and CPI information. */
8643 + int Gfc; /**< Generic Flow Control. */
8644 + int Clp; /**< Cell Loss Priority. */
8645 + int Pti; /**< Payload Type Indication. */
8646 +#endif
8647 +
8648 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8649 + int DaMask; /**< Specifies whether credit issuance is paused when Tx data not available. */
8650 + int Priority; /**< Priority bin this channel will be scheduled within. */
8651 + int PktType; /**< 0=AAL5,1=Null AAL,2=OAM,3=Transparent,4=AAL2. */
8652 + int Vci; /**< Virtual Channel Identifier. */
8653 + int Vpi; /**< Virtual Path Identifier. */
8654 + int FwdUnkVc; /**< Enables forwarding of unknown VCI/VPI cells to host. 1=enable, 0=disable. */
8655 +
8656 + /* Tx VC State */
8657 + int TxVc_CellRate; /**< Tx rate, set as clock ticks between transmissions (SCR for VBR, CBR for CBR). */
8658 + int TxVc_QosType; /**< 0=CBR,1=VBR,2=UBR,3=UBRmcr. */
8659 + int TxVc_Mbs; /**< Min Burst Size in cells.*/
8660 + int TxVc_Pcr; /**< Peak Cell Rate for VBR in clock ticks between transmissions. */
8661 +
8662 + bit32 TxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Tx Ch (must be big endian with 0 PTI). */
8663 + int TxVc_OamTc; /**< TC Path to transmit OAM cells for TX connection (0,1). */
8664 + int TxVc_VpOffset; /**< Offset to the OAM VP state table. */
8665 + /* Rx VC State */
8666 + int RxVc_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8667 + int RxVc_OamToHost; /**< 0=do not pass, 1=pass. */
8668 + bit32 RxVc_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx conn (must be big endian with 0 PTI). */
8669 + int RxVc_OamTc; /**< TC Path to transmit OAM cells for RX connection (0,1). */
8670 + int RxVc_VpOffset; /**< Offset to the OAM VP state table. */
8671 + /* Tx VP State */
8672 + int TxVp_OamTc; /**< TC Path to transmit OAM cells for TX VP connection (0,1). */
8673 + bit32 TxVp_AtmHeader; /**< ATM Header placed on firmware gen'd VP OAM cells for this Tx VP conn (must be big endian with 0 VCI). */
8674 + /* Rx VP State */
8675 + int RxVp_OamCh; /**< Ch to terminate rx'd OAM cells to be forwarded to the host. */
8676 + int RxVp_OamToHost; /**< 0=do not pass, 1=pass. */
8677 + bit32 RxVp_AtmHeader; /**< ATM Header placed on firmware gen'd OAM cells for this Rx VP conn (must be big endian with 0 VCI). */
8678 + int RxVp_OamTc; /**< TC Path to transmit OAM cells for RX VP connection (0,1). */
8679 + int RxVp_OamVcList; /**< Indicates all VC channels associated with this VP channel (one-hot encoded). */
8680 +#endif
8681 +
8682 +
8683 +#ifdef _CPHAL_VDMAVT
8684 + bit32u RemFifoAddr; /* Mirror mode only. */
8685 + bit32u FifoAddr;
8686 + bit32 PollInt;
8687 + bit32 FifoSize;
8688 + int Ready;
8689 +#endif
8690 +
8691 + }CHANNEL_INFO;
8692 +
8693 +/*
8694 + * This structure contains each statistic value gathered by the CPHAL.
8695 + * Applications may access statistics data by using the @c StatsGet() routine.
8696 + */
8697 +/* STATS */
8698 +#if defined(_CPHAL_AAL2) || defined(_CPHAL_AAL5) || defined(_CPHAL_CPSAR)
8699 +typedef struct
8700 + {
8701 + bit32u CrcErrors[16];
8702 + bit32u LenErrors[16];
8703 + bit32u DmaLenErrors[16];
8704 + bit32u AbortErrors[16];
8705 + bit32u StarvErrors[16];
8706 + bit32u TxMisQCnt[16][2];
8707 + bit32u RxMisQCnt[16];
8708 + bit32u RxEOQCnt[16];
8709 + bit32u TxEOQCnt[16][2];
8710 + bit32u RxPacketsServiced[16];
8711 + bit32u TxPacketsServiced[16][2];
8712 + bit32u RxMaxServiced;
8713 + bit32u TxMaxServiced[16][2];
8714 + bit32u RxTotal;
8715 + bit32u TxTotal;
8716 + } STAT_INFO;
8717 +#endif
8718 +
8719 +/*
8720 + * VDMA Channel specific configuration information
8721 + */
8722 +#ifdef _CPHAL_AAL2
8723 +typedef struct
8724 + {
8725 + int Ch; /**< Channel Number */
8726 + int RemoteEndian; /**< Endianness of remote VDMA-VT device */
8727 + int CpsSwap; /**< When 0, octet 0 in CPS pkt located in LS byte of 16-bit word sent to rem VDMA device. When 1, in MS byte. */
8728 + }VdmaChInfo;
8729 +#endif
8730 +
8731 +#ifndef _CPHAL
8732 + typedef void HAL_DEVICE;
8733 + typedef void HAL_PRIVATE;
8734 + typedef void HAL_RCB;
8735 + typedef void HAL_RECEIVEINFO;
8736 +#endif
8737 +
8738 +/**
8739 + * @ingroup shared_data
8740 + * The HAL_FUNCTIONS struct defines the function pointers used by upper layer
8741 + * software. The upper layer software receives these pointers through the
8742 + * call to xxxInitModule().
8743 + */
8744 +typedef struct
8745 + {
8746 + int (*ChannelSetup) (HAL_DEVICE *HalDev, CHANNEL_INFO *Channel, OS_SETUP *OsSetup);
8747 + int (*ChannelTeardown) (HAL_DEVICE *HalDev, int Channel, int Mode);
8748 + int (*Close) (HAL_DEVICE *HalDev, int Mode);
8749 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8750 + int (*Init) (HAL_DEVICE *HalDev);
8751 + int (*Open) (HAL_DEVICE *HalDev);
8752 + int (*PacketProcessEnd) (HAL_DEVICE *HalDev);
8753 + int (*Probe) (HAL_DEVICE *HalDev);
8754 + int (*RxReturn) (HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8755 + int (*Send) (HAL_DEVICE *HalDev, FRAGLIST *FragList, int FragCount, int PacketSize, OS_SENDINFO *OsSendInfo, bit32u Mode);
8756 + int (*Shutdown) (HAL_DEVICE *HalDev);
8757 + int (*Tick) (HAL_DEVICE *HalDev);
8758 +
8759 +#ifdef _CPHAL_AAL5
8760 + int (*Kick) (HAL_DEVICE *HalDev, int Queue);
8761 + void (*OamFuncConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig);
8762 + void (*OamLoopbackConfig) (HAL_DEVICE *HalDev, unsigned int OamConfig, unsigned int *LLID, unsigned int CorrelationTag);
8763 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8764 + STAT_INFO* (*StatsGetOld)(HAL_DEVICE *HalDev);
8765 +#endif
8766 + } HAL_FUNCTIONS;
8767 +
8768 +/**
8769 + * @ingroup shared_data
8770 + * The OS_FUNCTIONS struct defines the function pointers for all upper layer
8771 + * functions accessible to the CPHAL. The upper layer software is responsible
8772 + * for providing the correct OS-specific implementations for the following
8773 + * functions. It is populated by calling InitModule() (done by the CPHAL in
8774 + * xxxInitModule().
8775 + */
8776 +typedef struct
8777 + {
8778 + int (*Control)(OS_DEVICE *OsDev, const char *Key, const char *Action, void *Value);
8779 + void (*CriticalOn)(void);
8780 + void (*CriticalOff)(void);
8781 + void (*DataCacheHitInvalidate)(void *MemPtr, int Size);
8782 + void (*DataCacheHitWriteback)(void *MemPtr, int Size);
8783 + int (*DeviceFindInfo)(int Inst, const char *DeviceName, void *DeviceInfo);
8784 + int (*DeviceFindParmUint)(void *DeviceInfo, const char *Parm, bit32u *Value);
8785 + int (*DeviceFindParmValue)(void *DeviceInfo, const char *Parm, void *Value);
8786 + void (*Free)(void *MemPtr);
8787 + void (*FreeRxBuffer)(OS_RECEIVEINFO *OsReceiveInfo, void *MemPtr);
8788 + void (*FreeDev)(void *MemPtr);
8789 + void (*FreeDmaXfer)(void *MemPtr);
8790 + void (*IsrRegister)(OS_DEVICE *OsDev, int (*halISR)(HAL_DEVICE*, int*), int InterruptBit);
8791 + void (*IsrUnRegister)(OS_DEVICE *OsDev, int InterruptBit);
8792 + void* (*Malloc)(bit32u size);
8793 + void* (*MallocDev)(bit32u Size);
8794 + void* (*MallocDmaXfer)(bit32u size, void *MemBase, bit32u MemRange);
8795 + void* (*MallocRxBuffer)(bit32u size, void *MemBase, bit32u MemRange,
8796 + OS_SETUP *OsSetup, HAL_RECEIVEINFO *HalReceiveInfo,
8797 + OS_RECEIVEINFO **OsReceiveInfo, OS_DEVICE *OsDev);
8798 + void* (*Memset)(void *Dest, int C, bit32u N);
8799 + int (*Printf)(const char *Format, ...);
8800 + int (*Receive)(OS_DEVICE *OsDev,FRAGLIST *FragList,bit32u FragCount,
8801 + bit32u PacketSize,HAL_RECEIVEINFO *HalReceiveInfo, bit32u Mode);
8802 + int (*SendComplete)(OS_SENDINFO *OsSendInfo);
8803 + int (*Sprintf)(char *S, const char *Format, ...);
8804 + int (*Strcmpi)(const char *Str1, const char *Str2);
8805 + unsigned int (*Strlen)(const char *S);
8806 + char* (*Strstr)(const char *S1, const char *S2);
8807 + unsigned long (*Strtoul)(const char *Str, char **Endptr, int Base);
8808 + void (*TeardownComplete)(OS_DEVICE *OsDev, int Ch, int Direction);
8809 + } OS_FUNCTIONS;
8810 +
8811 +/************** MODULE SPECIFIC STUFF BELOW **************/
8812 +
8813 +#ifdef _CPHAL_CPMAC
8814 +
8815 +/*
8816 +int halCpmacInitModule(HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc, int (*osBridgeInitModule)(OS_FUNCTIONS *), void* (*osMallocDev) (bit32u), int *Size, int inst);
8817 +*/
8818 +
8819 +int halCpmacInitModule(HAL_DEVICE **HalDev,
8820 + OS_DEVICE *OsDev,
8821 + HAL_FUNCTIONS **HalFunc,
8822 + OS_FUNCTIONS *OsFunc,
8823 + int OsFuncSize,
8824 + int *HalFuncSize,
8825 + int Inst);
8826 +#endif
8827 +
8828 +#ifdef _CPHAL_AAL5
8829 +/*
8830 + * @ingroup shared_data
8831 + * The AAL5_FUNCTIONS struct defines the AAL5 function pointers used by upper layer
8832 + * software. The upper layer software receives these pointers through the
8833 + * call to cphalInitModule().
8834 + */
8835 +/*
8836 +typedef struct
8837 + {
8838 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8839 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8840 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8841 + int (*Init)(HAL_DEVICE *HalDev);
8842 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8843 + int (*Open)(HAL_DEVICE *HalDev);
8844 + int (*InfoGet)(HAL_DEVICE *HalDev, int Key, void *Value);
8845 + int (*Probe)(HAL_DEVICE *HalDev);
8846 + int (*RxReturn)(HAL_RECEIVEINFO *HalReceiveInfo, int StripFlag);
8847 + int (*Send)(HAL_DEVICE *HalDev,FRAGLIST *FragList,int FragCount,
8848 + int PacketSize,OS_SENDINFO *OsSendInfo,int Ch, int Queue,
8849 + bit32u Mode);
8850 + int (*StatsClear)(HAL_DEVICE *HalDev);
8851 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8852 + int (*Status)(HAL_DEVICE *HalDev);
8853 + void (*Tick)(HAL_DEVICE *HalDev);
8854 + int (*Kick)(HAL_DEVICE *HalDev, int Queue);
8855 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8856 + } AAL5_FUNCTIONS;
8857 +*/
8858 +
8859 +int cpaal5InitModule(HAL_DEVICE **HalDev,
8860 + OS_DEVICE *OsDev,
8861 + HAL_FUNCTIONS **HalFunc,
8862 + OS_FUNCTIONS *OsFunc,
8863 + int OsFuncSize,
8864 + int *HalFuncSize,
8865 + int Inst);
8866 +#endif
8867 +
8868 +#ifdef _CPHAL_AAL2
8869 +/**
8870 + * @ingroup shared_data
8871 + * The AAL2_FUNCTIONS struct defines the AAL2 function pointers used by upper layer
8872 + * software. The upper layer software receives these pointers through the
8873 + * call to cphalInitModule().
8874 + */
8875 +typedef struct
8876 + {
8877 + int (*ChannelSetup)(HAL_DEVICE *HalDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8878 + int (*ChannelTeardown)(HAL_DEVICE *HalDev, int Ch, int Mode);
8879 + int (*Close)(HAL_DEVICE *HalDev, int Mode);
8880 + int (*Init)(HAL_DEVICE *HalDev);
8881 + int (*ModeChange)(HAL_DEVICE *HalDev, char *DeviceParms);
8882 + int (*Open)(HAL_DEVICE *HalDev);
8883 + int (*OptionsGet)(HAL_DEVICE *HalDev, char *Key, bit32u *Value);
8884 + int (*Probe)(HAL_DEVICE *HalDev);
8885 +
8886 + int (*StatsClear)(HAL_DEVICE *HalDev);
8887 + STAT_INFO* (*StatsGet)(HAL_DEVICE *HalDev);
8888 + int (*Status)(HAL_DEVICE *HalDev);
8889 + void (*Tick)(HAL_DEVICE *HalDev);
8890 + int (*Aal2UuiMappingSetup)(HAL_DEVICE *HalDev, int VC, int UUI,
8891 + int VdmaCh, int UUIDiscard);
8892 + int (*Aal2RxMappingSetup)(HAL_DEVICE *HalDev, int VC, int CID,
8893 + int LC);
8894 + int (*Aal2TxMappingSetup)(HAL_DEVICE *HalDev, int VC, int LC, int VdmaCh);
8895 + int (*Aal2VdmaChSetup)(HAL_DEVICE *HalDev, bit32u RemVdmaVtAddr,
8896 + VdmaChInfo *VdmaCh);
8897 + volatile bit32u* (*RegAccess)(HAL_DEVICE *HalDev, bit32u RegOffset);
8898 + int (*Aal2ModeChange)(HAL_DEVICE *HalDev, int Vc, int RxCrossMode,
8899 + int RxMultiMode, int TxMultiMode, int SchedMode,
8900 + int TcCh);
8901 + void (*Aal2VdmaEnable)(HAL_DEVICE *HalDev, int Ch);
8902 + int (*Aal2VdmaDisable)(HAL_DEVICE *HalDev, int Ch);
8903 + } AAL2_FUNCTIONS;
8904 +
8905 +int cpaal2InitModule(HAL_DEVICE **HalDev,
8906 + OS_DEVICE *OsDev,
8907 + AAL2_FUNCTIONS **HalFunc,
8908 + OS_FUNCTIONS *OsFunc,
8909 + int OsFuncSize,
8910 + int *HalFuncSize,
8911 + int Inst);
8912 +#endif
8913 +
8914 +#ifdef _CPHAL_VDMAVT
8915 +/**
8916 + * @ingroup shared_data
8917 + * The VDMA_FUNCTIONS struct defines the HAL function pointers used by upper layer
8918 + * software. The upper layer software receives these pointers through the
8919 + * call to InitModule().
8920 + *
8921 + * Note that this list is still under definition.
8922 + */
8923 +typedef struct
8924 + {
8925 + bit32 (*Init)( HAL_DEVICE *VdmaVtDev);
8926 + /* bit32 (*SetupTxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8927 + bit32u Addr, bit32u Size, bit32u PollInt);
8928 + bit32 (*SetupRxFifo)(HAL_DEVICE *VdmaVtDev, bit32u LclRem,
8929 + bit32u Addr, bit32u Size, bit32u PollInt); */
8930 + bit32 (*Tx)(HAL_DEVICE *VdmaVtDev);
8931 + bit32 (*Rx)(HAL_DEVICE *VdmaVtDev);
8932 + bit32 (*SetRemoteChannel)(HAL_DEVICE *VdmaVtDev, bit32u RemAddr,
8933 + bit32u RemDevID);
8934 + bit32 (*ClearRxInt)(HAL_DEVICE *VdmaVtDev);
8935 + bit32 (*ClearTxInt)(HAL_DEVICE *VdmaVtDev);
8936 + bit32 (*Open)(HAL_DEVICE *VdmaVtDev);
8937 + bit32 (*Close)(HAL_DEVICE *VdmaVtDev);
8938 + int (*Control) (HAL_DEVICE *HalDev, const char *Key, const char *Action, void *Value);
8939 + int (*ChannelSetup)(HAL_DEVICE *VdmaVtDev, CHANNEL_INFO *HalCh, OS_SETUP *OsSetup);
8940 + int (*ChannelTeardown)(HAL_DEVICE *VdmaVtDev, int Ch, int Mode);
8941 + int (*Send)(HAL_DEVICE *VdmaVtDev,FRAGLIST *FragList,int FragCount,
8942 + int PacketSize,OS_SENDINFO *OsSendInfo,bit32u Mode);
8943 + } VDMA_FUNCTIONS;
8944 +
8945 +int VdmaInitModule(HAL_DEVICE **VdmaVt,
8946 + OS_DEVICE *OsDev,
8947 + VDMA_FUNCTIONS **VdmaVtFunc,
8948 + OS_FUNCTIONS *OsFunc,
8949 + int OsFuncSize,
8950 + int *HalFuncSize,
8951 + int Inst);
8952 +#endif
8953 +
8954 +/*
8955 +extern int cphalInitModule(MODULE_TYPE ModuleType, HAL_DEVICE **HalDev, OS_DEVICE *OsDev, HAL_FUNCTIONS *HalFunc,
8956 + int (*osInitModule)(OS_FUNCTIONS *), void* (*osMallocDev)(bit32u),
8957 + int *Size, int Inst);
8958 +*/
8959 +
8960 +
8961 +#ifdef _CPHAL_AAL5
8962 +extern const char hcSarFrequency[];
8963 +#endif
8964 +
8965 +#ifdef _CPHAL_CPMAC
8966 +/* following will be common, once 'utl' added */
8967 +extern const char hcClear[];
8968 +extern const char hcGet[];
8969 +extern const char hcSet[];
8970 +extern const char hcTick[];
8971 +
8972 +extern const char hcCpuFrequency[];
8973 +extern const char hcCpmacFrequency[];
8974 +extern const char hcMdioBusFrequency[];
8975 +extern const char hcMdioClockFrequency[];
8976 +extern const char hcCpmacBase[];
8977 +extern const char hcPhyNum[];
8978 +extern const char hcSize[];
8979 +extern const char hcCpmacSize[];
8980 +extern const char hcPhyAccess[];
8981 +#endif
8982 +
8983 +#endif /* end of _INC_ */
8984 diff -urN linux.old/drivers/atm/sangam_atm/dev_host_interface.h linux.dev/drivers/atm/sangam_atm/dev_host_interface.h
8985 --- linux.old/drivers/atm/sangam_atm/dev_host_interface.h 1970-01-01 01:00:00.000000000 +0100
8986 +++ linux.dev/drivers/atm/sangam_atm/dev_host_interface.h 2005-08-23 04:46:50.091844608 +0200
8987 @@ -0,0 +1,1162 @@
8988 +#ifndef __DEV_HOST_INTERFACE_H__
8989 +#define __DEV_HOST_INTERFACE_H__ 1
8990 +
8991 +/*******************************************************************************
8992 +* FILE PURPOSE: Public header file for the Host-to-DSP interface
8993 +********************************************************************************
8994 +*
8995 +* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
8996 +*
8997 +* (C) Copyright Texas Instruments Inc. 2002. All rights reserved.
8998 +*
8999 +* Property of Texas Instruments Incorporated
9000 +*
9001 +* Restricted Rights - Use, duplication, or disclosure is subject to
9002 +* restrictions set forth in TI's program license agreement and
9003 +* associated documentation
9004 +*
9005 +*
9006 +* FILE NAME: dev_host_interface.h
9007 +*
9008 +* DESCRIPTION:
9009 +* This header file defines the variables and parameters used between the
9010 +* host processor and the DSP. This file is included in both the DSP
9011 +* software and the host software.
9012 +*
9013 +* RULES FOR MODIFICATION AND USE OF THIS FILE:
9014 +*
9015 +* --The main pointer to the struct of pointers will always be at the same fixed
9016 +* location (0x80000000).
9017 +*
9018 +* --Each pointer element in the struct of pointers (indicated by the main pointer)
9019 +* will always point to a struct only.
9020 +*
9021 +* --Any new structures added to the host interface in subsequent versions must
9022 +* each have a corresponding new pointer element added to the END of the struct
9023 +* of pointers. Other than this, there will never be any moving or rearranging
9024 +* of the pointer elements in the struct of pointers.
9025 +*
9026 +* --Any new elements added to existing structures will be added at the END of the
9027 +* structure. Other than this, there will never be any moving or rearranging
9028 +* of structure elements.
9029 +*
9030 +* --A new structure will never be added as a new element in an old structure.
9031 +* New structures must be added separately with a new entry in the struct of
9032 +* pointers, as noted above.
9033 +*
9034 +* --Also, the sizes of existing arrays within old structures will never be changed.
9035 +*
9036 +* --The modem code in the DSP will never reference the struct of pointers in order
9037 +* to avoid aliasing issues in the DSP code. The modem code will only use the
9038 +* specific structures directly.
9039 +*
9040 +* --The host processor never accesses the DSP side of the ATM-TC hardware directly.
9041 +* The DSP interfaces directly to the ATM-TC hardware and relays information to
9042 +* the host processor through the host interface.
9043 +*
9044 +* --The host processor can track the modem's transition through important states
9045 +* by accessing the Modem State Bit Field in the host interface. Each bit in
9046 +* the bit field represents an important state to track in the modem. As the
9047 +* modem transitions through each important state, the corresponding bit will
9048 +* change from a zero to a one. Each bit in the bit field will only be reset to
9049 +* zero if the modem retrains. If new states need to be tracked and are added
9050 +* in subsequent versions of the host interface, a corresponding bit will be
9051 +* added at the END of the bit field to ensure backwards compatibility. The
9052 +* Modem State Bit Field is reset if the modem retrains or falls out of Showtime.
9053 +*
9054 +* --An interrupt will be sent to the host processor when a change occurs in the
9055 +* Modem State Bit Field. There is an interrupt masking register which can mask
9056 +* specific interrupts corresponding to the bits of the Modem State Bit Field.
9057 +* This allows the host to keep an interrupt from being generated for those
9058 +* states that are masked.
9059 +*
9060 +* HISTORY:
9061 +*
9062 +* 11/20/02 J. Bergsagel Written from the previous host interface file
9063 +* 11/27/02 J. Bergsagel Added comments for mailbox control struct and
9064 +* fixed a couple items for overlay page stuff.
9065 +* Also, added temporary elements for SWTC code.
9066 +* 12/04/02 J. Bergsagel Added extra dummy byte to DEV_HOST_eocVarDef_t
9067 +* for proper word alignment.
9068 +* 12/12/02 J. Bergsagel Changed initial states in the modem state bit field
9069 +* and added more instructions for adding more states.
9070 +* 12/16/02 J. Bergsagel Changed name "hostVersion_p" to "hostIntfcVersion_p".
9071 +* Removed dspAturState from DEV_HOST_modemStateBitField_t.
9072 +* Reorganized several struct elements to clean up the
9073 +* host interface.
9074 +* 12/27/02 Sameer V Added missing channel 0 statistics for TC. Added
9075 +* ocd error information.
9076 +* 12/27/02 Sameer V Added overlayState to OlayDP_Parms to indicate whether
9077 +* overlays are being executed in current state.
9078 +* 01/06/03 J. Bergsagel Added maxAllowedMargin and minRequiredMargin to
9079 +* DEV_HOST_msg_t.
9080 +* Renamed TC chan 1 items to be chan 0 items to start out.
9081 +* 01/17/03 Sameer V Moved delineationState to atmStats structure.
9082 +* 01/21/03 Barnett Implemented Ax7 UNIT-MODULE modular software framework.
9083 +* 01/22/03 J. Bergsagel Added warning comments for certain struct typedefs.
9084 +* 01/23/03 C. Perez-N. Removed old AX5-only diags. command/response entries in the
9085 +* HOST and DSP ennumerations, and added the AX7 new ones
9086 +* Added pointer entries in the DEV_HOST_dspOamSharedInterface_t
9087 +* structure pointing to the analog diags. input/output/options
9088 +* structures.
9089 +* 01/29/03 Sameer V Removed TC_IDLE in enum for delineation state. Hardware
9090 +* only reports TC_HUNT, TC_PRESYNC and TC_SYNC.
9091 +* 03/07/03 Sameer/Jonathan Put SWTC token around structs and elements only used by SWTC
9092 +* 03/12/03 Mannering Add CO profile data structures
9093 +* 03/18/03 J. Bergsagel Removed the obsolete DSP_CHECK_TC response message.
9094 +* 03/24/03 J. Bergsagel Added DEV_HOST_hostInterruptMask_t for masking DSP interrupt sources
9095 +* 03/28/03 C. Perez-N Changed the C-style comments and made them C++ sytle instead.
9096 +* Replaced the occurrences of "SINT32 *" pointer declarations with
9097 +* "PSINT32"
9098 +* 03/28/03 Mannering Update CO profile data structures
9099 +* 04/04/03 S. Yim Add host I/F hooks for switchable hybrid and RJ11
9100 +* inner/outer pair selection
9101 +* 04/11/03 J. Bergsagel Changed modem state bit field struct types to enums instead and used
9102 +* a single integer variable for each "bitfield".
9103 +* Changed bit field for host interrupt masks to an integer value also.
9104 +* 04/14/03 J. Bergsagel Changed name of table pointer "meanSquareTblDstrm_p" to "marginTblDstrm_p".
9105 +* 04/03/03 Umesh Iyer CMsg1 and RMsg1 use the same storage as CMSGPCB and RMSGPCB.
9106 +* The string lengths for these have been adjusted to hold the longest
9107 +* message in each case. The PCB messages from ADSL2 are longer.
9108 +* 04/21/03 Sameeer V Added new host mailbox message for shutting down the DSLSS peripherals.
9109 +* 04/23/03 J. Bergsagel Fixed comments for overlay mailbox messages and for losErrors.
9110 +* 04/28/03 Mannering Added skip phase op flag to CO profile data structure
9111 +* 05/05/03 Mannering Review Comments - Removed "#if CO_PROFILE" from around structure
9112 +* definitions and define the number of profiles (DEV_HOST_LIST_ENTRIES)
9113 +* 05/13/03 J. Bergsagel Added new elements to DEV_HOST_phyPerf_t for host control of hybrid.
9114 +* 05/15/03 J. Bergsagel Added "farEndLosErrors" and "farEndRdiErrors" to DEV_HOST_modemStatsDef_t.
9115 +* 05/16/03 Mannering Updated CO profile structure to support updated bit allocation and
9116 +* interopability.
9117 +* 05/20/03 Sameer V Added DSP message to inicate DYING GASP.
9118 +* 05/22/03 J. Bergsagel Added a new struct typedef "DEV_HOST_hostInterruptSource_t".
9119 +* Added "atucGhsRevisionNum" to "DEV_HOST_dspWrNegoParaDef_t".
9120 +* Moved the following struct typedef's here to the public host interface:
9121 +* DEV_HOST_dspBitSwapDef_t
9122 +* DEV_HOST_atmDsBert_t
9123 +* 05/28/03 A. Redfern Changed pointer type and location for margin reporting.
9124 +* 05/28/03 Mannering Moved CO profile defines to dev_host_interface_pvt.h
9125 +* 05/28/03 J. Bergsagel Moved subStateIndex and STM BERT controls into new struct "DEV_HOST_modemEnvPublic_t"
9126 +* 05/29/03 J. Bergsagel Added elements to "DEV_HOST_modemEnvPublic_t" for host control of DSLSS LED's.
9127 +* 06/10/03 Umesh Iyer Modified trainMode check to be compliant with the new host i/f mods.
9128 +* 06/05/03 J. Bergsagel Added enum that will eventually replace the bitfield: DEV_HOST_diagAnlgOptionsVar_t.
9129 +* Added new element "currentHybridNumUsed" in the DEV_HOST_phyPerf_t typedef
9130 +* Added new host control flags for LPR signal detection on GPIO[0].
9131 +* 06/06/03 A. Redfern Removed fine gain scale from the CO profile and added max downstream power cutback.
9132 +* Changed "test1" in CO profile struct to "phyEcDelayAdjustment".
9133 +* 06/26/03 J. Bergsagel Added genericStructure typedef and two pointer elements of this type in the big table.
9134 +* 07/03/03 Jack Huang Renamed test2 to bSwapThresholdUpdate
9135 +* 07/07/03 Mallesh Changed phySigTxPowerCutback_f flag to a variable phySigTxGainReductionAt0kft which indicates the
9136 +* amount of gain reduction in linear scale.
9137 +* 07/15/03 Sameer V Changed DEV_HOST_diagAnlgOptionsVar_t to be an enum instead of a bit field. Host code
9138 +* does not support setting bit fields.
9139 +* 07/22/03 Jack Huang Added bitswap control flag in host i/f for API calls
9140 +* 08/06/03 Sameer V Added missingToneDs_p to the DEV_HOST_oamWrNegoParaDef_t to enable host to switch off
9141 +* DS tones on specified bins
9142 +* 08/21/03 Jack Huang Added pcbEnabled flag in the DEV_HOST_modemEnvPublic_t structure
9143 +* Added g.hs buffer definitions to DEV_HOST_dspOamSharedInterface_t
9144 +* Added DEV_HOST_consBufDef_t to the DEV_HOST_dspOamSharedInterface_t structure
9145 +* 08/26/03 J. Bergsagel Fixed name of "missingToneDs_p" to be "missingToneDsAddr" instead (since it is
9146 +* not really used as a pointer).
9147 +* 09/11/03 Mallesh Added a flag "usPilotInT1413ModeInMedley" to determine the need to send Upstream Pilot
9148 +* in medley in T1.413 mode.
9149 +* 09/12/03 J. Bergsagel Changed "test3" to "phyBitaFastPathExcessFineGainBump" in CO profile struct.
9150 +* Changed "test4" to "phyBitaSkipGapAdjustment" in CO profile struct.
9151 +* 09/23/03 J. Bergsagel Changed "T1413vendorRevisionNumber" to "vendorRevisionNumber" in DEV_HOST_msg_t.
9152 +* Added ADSL2 and ADSL2 diag. states to the modem state bit field.
9153 +* 10/01/03 J. Bergsagel Changed define of "MULTI_MODE" to be 255 to indicate that all possible bits
9154 +* in the 8-bit bit field are turned on for any current and future training modes.
9155 +* 10/09/03 M. Turkboylari Added DSP_TRAINING_MSGS and adsl2DeltMsgs_p, which is a pointer to a pointer,
9156 +* in order to pass the ADSL2 training and DELT messages to the host side. This is for ACT.
9157 +* 10/20/03 Mallesh Added a GHS state enumerator for cleardown
9158 +* 10/20/03 Xiaohui Li Add definition for READSL2_MODE and READSL2_DELT
9159 +* 11/07/03 J. Bergsagel Removed all code for when SWTC==1, which therefore allows removal of include of
9160 +* "env_def_defines.h". We shouldn't have any compile tokens used in this file.
9161 +* (the SWTC token is always off in any Ax7 code).
9162 +* 11/14/03 J. Bergsagel Also removed READSL2_ENABLE token (no more compile tokens to be used in this .h file).
9163 +* 12/12/03 Sameer/Ram Added DEV_HOST_EOCAOC_INTERRUPT_MASK to enable host to disable response code for AOC/EOC
9164 +* mailbox messages
9165 +* 12/09/03 Jack Huang Changed G.hs txbuf size from 60 to 64 to fit the max segment size
9166 +* 12/15/03 Mallesh Changed vendor ID type defenition from SINT16 to UINT16
9167 +* 12/23/03 Sameer V Added ability to turn off constellation display reporting to host using oamFeature bit field.
9168 +* 12/24/03 Sameer V Changed comment for Constellation Display Current Address to Host Write instead of DSP Write.
9169 +* 12/26/03 Sameer/Ram Added DEV_HOST_GHSMSG_INTERRUPT_MASK to enable host to disable response code for GHS Messages
9170 +* (C) Copyright Texas Instruments Inc. 2002. All rights reserved.
9171 +*******************************************************************************/
9172 +
9173 +#include "dev_host_verdef.h"
9174 +
9175 +// ---------------------------------------------------------------------------------
9176 +// Address of the pointer to the DEV_HOST_dspOamSharedInterface_s struct of pointers
9177 +// This is where it all starts.
9178 +// ---------------------------------------------------------------------------------
9179 +#define DEV_HOST_DSP_OAM_POINTER_LOCATION 0x80000000
9180 +
9181 +// The define "MAX_NUM_UPBINS" is used in "DEV_HOST_diagAnlgInputVar_t" below.
9182 +// This value can never be changed (for host intf. backwards compatibility)
9183 +#define MAX_NUM_UPBINS 64
9184 +
9185 +// -----------------------------------------------
9186 +// Begin common enumerations between DSP and host.
9187 +// -----------------------------------------------
9188 +
9189 +// These Host-to-DSP commands are organized into two groups:
9190 +// immediate state change commands and status affecting commands.
9191 +// Do not add or remove commands except at the bottom since the DSP assumes this sequence.
9192 +
9193 +enum
9194 +{
9195 + HOST_ACTREQ, // Send R-ACKREQ and monitor for C-ACKx
9196 + HOST_QUIET, // Sit quietly doing nothing for about 60 seconds, DEFAULT STATE; R_IDLE
9197 + HOST_XMITBITSWAP, // Perform upstream bitswap - FOR INTERNAL USE ONLY
9198 + HOST_RCVBITSWAP, // Perform downstream bitswap - FOR INTERNAL USE ONLY
9199 + HOST_RTDLPKT, // Send a remote download packet - FOR INTERNAL USE ONLY
9200 + HOST_CHANGELED, // Read the LED settings and change accordingly
9201 + HOST_IDLE, // Sit quiet
9202 + HOST_REVERBTEST, // Generate REVERB for manufacturing test
9203 + HOST_CAGCTEST, // Set coarse receive gain for manufacturing test
9204 + HOST_DGASP, // send Dying Gasp messages through EOC channel
9205 + HOST_GHSREQ, // G.hs - FOR INTERNAL USE ONLY
9206 + HOST_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
9207 + HOST_GHS_SENDGALF, // G.hs - FOR INTERNAL USE ONLY
9208 + HOST_GHSEXIT, // G.hs - FOR INTERNAL USE ONLY
9209 + HOST_GHSMSG1, // G.hs - FOR INTERNAL USE ONLY
9210 + HOST_HYBRID, // Enable/Disable automatic hybrid switch
9211 + HOST_RJ11SELECT, // RJ11 inner/outer pair select
9212 + HOST_DIGITAL_MEM, // Digital Diags: run external memory tests
9213 + HOST_TXREVERB, // AFE Diags: TX path Reverb
9214 + HOST_TXMEDLEY, // AFE Diags: TX path Medley
9215 + HOST_RXNOISEPOWER, // AFE Diags: RX noise power
9216 + HOST_ECPOWER, // AFE Diags: RX eco power
9217 + HOST_ALL_ADIAG, // AFE Diags: all major analog diagnostic modes. Host is responsible to initiate each diagnostic sessions
9218 + HOST_USER_ADIAG, // AFE Diags: Host fills in analog diagnostic input data structure as specified and requests DSP to perform measurements as specified
9219 + HOST_QUIT_ADIAG, // AFE Diags: Host requests DSP to quit current diagnostic session. This is used for stopping the transmit REVERB/MEDLEY
9220 + HOST_NO_CMD, // All others - G.hs - FOR INTERNAL USE ONLY
9221 + HOST_DSLSS_SHUTDOWN, // Host initiated DSLSS shutdown message
9222 + HOST_SET_GENERIC, // Set generic CO profile
9223 + HOST_UNDO_GENERIC, // Set profile previous to Generic
9224 + HOST_GHS_CLEARDOWN // G.hs - FOR INTERNAL USE ONLY to start cleardown
9225 +};
9226 +
9227 +// These DSP-to-Host responses are organized into two groups:
9228 +// responses to commands and requests for OAM services.
9229 +
9230 +enum
9231 +{
9232 + DSP_IDLE, // R_IDLE state entered
9233 + DSP_ACTMON, // R_ACTMON state entered
9234 + DSP_TRAIN, // R_TRAIN state entered
9235 + DSP_ACTIVE, // R_ACTIVE state entered
9236 + DSP_XMITBITSWAP, // Upstream bitswap complete - FOR INTERNAL USE ONLY
9237 + DSP_RCVBITSWAP, // Downstream bitswap complete - FOR INTERNAL USE ONLY
9238 + DSP_RTDL, // R_RTDL state entered - FOR INTERNAL USE ONLY
9239 + DSP_RRTDLPKT, // RTDL packet received - FOR INTERNAL USE ONLY
9240 + DSP_XRTDLPKT, // RTDL packet transmitted - FOR INTERNAL USE ONLY
9241 + DSP_ERROR, // Command rejected, wrong state for this command
9242 + DSP_REVERBTEST, // Manufacturing REVERB test mode entered
9243 + DSP_CAGCTEST, // Manufacturing receive gain test done
9244 + DSP_OVERLAY_START, // Notify host that page overlay has started - overlay number indicated by "tag"
9245 + DSP_OVERLAY_END, // Notify host that page overlay has ended - overlay number indicated by "tag"
9246 + DSP_CRATES1, // CRATES1 message is valid and should be copied to host memory now
9247 + DSP_SNR, // SNR calculations are ready and should be copied to host memory now
9248 + DSP_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
9249 + DSP_RCVBITSWAP_TIMEOUT, // Acknowledge Message was not received within ~500 msec (26 Superframes).
9250 + DSP_ATM_TC_SYNC, // Indicates true TC sync on both the upstream and downstream. Phy layer ready for data xfer.
9251 + DSP_ATM_NO_TC_SYNC, // Indicates loss of sync on phy layer on either US or DS.
9252 + DSP_HYBRID, // DSP completed hybrid switch
9253 + DSP_RJ11SELECT, // DSP completed RJ11 inner/outer pair select
9254 + DSP_INVALID_CMD, // Manufacturing (Digital and AFE) diags: CMD received not recognized
9255 + DSP_TEST_PASSED, // Manufacturing diags: test passed
9256 + DSP_TEST_FAILED, // Manufacturing diags: test failed
9257 + DSP_TXREVERB, // Manufacturing AFE diags: Response to HOST_TXREVERB
9258 + DSP_TXMEDLEY, // Manufacturing AFE diags: Response to HOST_TXMEDLEY
9259 + DSP_RXNOISEPOWER, // Manufacturing AFE diags: Response to HOST_RXNOISEPOWER
9260 + DSP_ECPOWER, // Manufacturing AFE diags: Response to HOST_ECPOWER
9261 + DSP_ALL_ADIAG, // Manufacturing AFE diags: Response to HOST_ALL_ADIAG
9262 + DSP_USER_ADIAG, // Manufacturing AFE diags: Response to HOST_USER_ADIAG
9263 + DSP_QUIT_ADIAG, // Manufacturing AFE diags: Response to HOST_QUIT_ADIAG
9264 + DSP_DGASP, // DSP Message to indicate dying gasp
9265 + DSP_EOC, // DSP Message to indicate that DSP sent an EOC message to CO
9266 + DSP_TRAINING_MSGS // DSP Message to indicate that host has to copy the training message specified in the tag field.
9267 +};
9268 +
9269 +// Define different ADSL training modes.
9270 +//Defintions as per new host interface.
9271 +#define NO_MODE 0
9272 +#define GDMT_MODE 2
9273 +#define GLITE_MODE 4
9274 +#define ADSL2_MODE 8
9275 +#define ADSL2_DELT (ADSL2_MODE+1)
9276 +#define ADSL2PLUS_MODE 16
9277 +#define ADSL2PLUS_DELT (ADSL2PLUS_MODE+1)
9278 +#define READSL2_MODE 32
9279 +#define READSL2_DELT (READSL2_MODE+1)
9280 +#define T1413_MODE 128
9281 +#define MULTI_MODE 255 // all possible bits are set in the bit field
9282 +
9283 +// Define the reason for dropping the connection
9284 +
9285 +enum
9286 +{
9287 + REASON_LOS = 0x01,
9288 + REASON_DYING_GASP = 0x02,
9289 + REASON_USCRCERR = 0x04,
9290 + REASON_MARGIN_DROP = 0x08
9291 +};
9292 +
9293 +
9294 +// ----------------------------------------------------
9295 +// Begin modem state bit field definitions - DSP write.
9296 +// ----------------------------------------------------
9297 +
9298 +// BitField1 for initial states and G.hs states.
9299 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9300 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9301 +// that causes the proper values to be entered into the modem state bit fields.
9302 +typedef enum
9303 +{
9304 + ZERO_STATE1 = 0,
9305 + RTEST = 0x1,
9306 + RIDLE = 0x2,
9307 + RINIT = 0x4,
9308 + RRESET = 0x8,
9309 + GNSFLR = 0x10,
9310 + GTONE = 0x20,
9311 + GSILENT = 0x40,
9312 + GNEGO = 0x80,
9313 + GFAIL = 0x100,
9314 + GACKX = 0x200,
9315 + GQUIET2 = 0x400
9316 +} DEV_HOST_stateBitField1_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9317 +
9318 +// BitField2 for T1.413 states and for the rest of the modem states (so far)
9319 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9320 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9321 +// that causes the proper values to be entered into the modem state bit fields.
9322 +typedef enum
9323 +{
9324 + ZERO_STATE2 = 0,
9325 + TNSFLR = 0x1,
9326 + TACTREQ = 0x2,
9327 + TACTMON = 0x4,
9328 + TFAIL = 0x8,
9329 + TACKX = 0x10,
9330 + TQUIET2 = 0x20,
9331 + RQUIET2 = 0x40,
9332 + RREVERB1 = 0x80,
9333 + RQUIET3 = 0x100,
9334 + RECT = 0x200,
9335 + RREVERB2 = 0x400,
9336 + RSEGUE1 = 0x800,
9337 + RREVERB3 = 0x1000,
9338 + RSEGUE2 = 0x2000,
9339 + RRATES1 = 0x4000,
9340 + RMSGS1 = 0x8000,
9341 + RMEDLEY = 0x10000,
9342 + RREVERB4 = 0x20000,
9343 + RSEGUE3 = 0x40000,
9344 + RMSGSRA = 0x80000,
9345 + RRATESRA = 0x100000,
9346 + RREVERBRA = 0x200000,
9347 + RSEGUERA = 0x400000,
9348 + RMSGS2 = 0x800000,
9349 + RRATES2 = 0x1000000,
9350 + RREVERB5 = 0x2000000,
9351 + RSEGUE4 = 0x4000000,
9352 + RBNG = 0x8000000,
9353 + RREVERB6 = 0x10000000,
9354 + RSHOWTIME = 0x20000000
9355 +} DEV_HOST_stateBitField2_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9356 +
9357 +// BitField3 for ADSL2 states
9358 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9359 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9360 +// that causes the proper values to be entered into the modem state bit fields.
9361 +typedef enum
9362 +{
9363 + ZERO_STATE3 = 0,
9364 + G2QUIET1 = 0x1,
9365 + G2COMB1 = 0x2,
9366 + G2QUIET2 = 0x4,
9367 + G2COMB2 = 0x8,
9368 + G2ICOMB1 = 0x10,
9369 + G2LINEPROBE = 0x20,
9370 + G2QUIET3 = 0x40,
9371 + G2COMB3 = 0x80,
9372 + G2ICOMB2 = 0x100,
9373 + G2RMSGFMT = 0x200,
9374 + G2RMSGPCB = 0x400,
9375 + G2REVERB1 = 0x800,
9376 + G2QUIET4 = 0x1000,
9377 + G2REVERB2 = 0x2000,
9378 + G2QUIET5 = 0x4000,
9379 + G2REVERB3 = 0x8000,
9380 + G2ECT = 0x10000,
9381 + G2REVERB4 = 0x20000,
9382 + G2SEGUE1 = 0x40000,
9383 + G2REVERB5 = 0x80000,
9384 + G2SEGUE2 = 0x100000,
9385 + G2RMSG1 = 0x200000,
9386 + G2MEDLEY = 0x400000,
9387 + G2EXCHANGE = 0x800000,
9388 + G2RMSG2 = 0x1000000,
9389 + G2REVERB6 = 0x2000000,
9390 + G2SEGUE3 = 0x4000000,
9391 + G2RPARAMS = 0x8000000,
9392 + G2REVERB7 = 0x10000000,
9393 + G2SEGUE4 = 0x20000000
9394 +} DEV_HOST_stateBitField3_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9395 +
9396 +// BitField4 for ADSL2 diag. states
9397 +// If more values need to be added, they will be added at the end (up to 32 total entries). However, if this causes
9398 +// the state transitions to tick off out of normal bit order, then the C code will have to be re-written
9399 +// that causes the proper values to be entered into the modem state bit fields.
9400 +typedef enum
9401 +{
9402 + ZERO_STATE4 = 0,
9403 + GDSEGUE1 = 0x1,
9404 + GDREVERB5 = 0x2,
9405 + GDSEGUE2 = 0x4,
9406 + GDEXCHANGE = 0x8,
9407 + GDSEGUELD = 0x10,
9408 + GDRMSGLD = 0x20,
9409 + GDQUIET1LD = 0x40,
9410 + GDQUIET2LD = 0x80,
9411 + GDRACK1 = 0x100,
9412 + GDRNACK1 = 0x200,
9413 + GDQUIETLAST = 0x400
9414 +} DEV_HOST_stateBitField4_t; // this enum should only have 32 bit entries in it. Add another enum if you need more.
9415 +
9416 +// This struct collects all of the bitfield types listed above for the modem state bit field(s)
9417 +typedef struct
9418 +{
9419 + DEV_HOST_stateBitField1_t bitField1; // this is the first modem state bit field (mostly init. and G.hs)
9420 + DEV_HOST_stateBitField2_t bitField2; // this is the second modem state bit field (T1.413 and G.dmt)
9421 + DEV_HOST_stateBitField3_t bitField3; // this is the third modem state bit field (ADSL2)
9422 + DEV_HOST_stateBitField4_t bitField4; // this is the fourth modem state bit field (ADSL2 diag.)
9423 +} DEV_HOST_modemStateBitField_t;
9424 +
9425 +
9426 +// -----------------------------------------------
9427 +// Begin NegoPara message definitions - DSP write.
9428 +// -----------------------------------------------
9429 +
9430 +typedef struct
9431 +{
9432 + UINT8 trainMode; // Train mode selected. See training modes defined above.
9433 + UINT8 bDummy1; // dummy byte for explicit 32-bit alignment
9434 + UINT16 lineLength; // Contains loop length estimate. Accuracy w/i 500 ft. LSbit = 1 for straight loop, = 0 for bridge tap
9435 + UINT32 atucVendorId; // Pass the vendor id of the CO to the host
9436 + UINT8 cMsgs1[8]; // CMsgs1 and CMSGPCB
9437 + UINT16 adsl2DSRate; //
9438 + UINT8 cRates2; //
9439 + UINT8 rRates2; //
9440 + UINT8 rRates1[4][11]; //
9441 + UINT8 cMsgs2[4]; //
9442 + UINT8 cRates1[4][30]; //
9443 + UINT8 rMsgs2[4]; //
9444 + UINT16 adsl2USRate; //
9445 + UINT8 atucGhsRevisionNum; // Pass the G.hs Revision number of the CO to the host
9446 + UINT8 reserved1; //
9447 + PUINT8 *adsl2DeltMsgs_p; // This pointer to a pointer passes the address of the globalvar.pString, which is also
9448 + // a pointer list of pointers. It will be used to pass all the new ADSL2 DELT messages to
9449 + // host side. This is for ACT.
9450 +} DEV_HOST_dspWrNegoParaDef_t;
9451 +
9452 +
9453 +// ----------------------------------------------------
9454 +// Begin OAM NegoPara message definitions - Host write.
9455 +// ----------------------------------------------------
9456 +
9457 +// OAM Feature bit fields.
9458 +//
9459 +// Bit 0 - Enable auto retrain of modem
9460 +// Bit 1 - Detect and report TC sync to host
9461 +// Bit 2-31 - Reserved
9462 +
9463 +#define DEV_HOST_AUTORETRAIN_ON 0x00000001
9464 +#define DEV_HOST_TC_SYNC_DETECT_ON 0x00000002
9465 +
9466 +#define DEV_HOST_AUTORETRAIN_MASK 0x00000001
9467 +#define DEV_HOST_TC_SYNC_DETECT_MASK 0x00000002
9468 +#define DEV_HOST_EOCAOC_INTERRUPT_MASK 0x00000004
9469 +#define DEV_HOST_CONS_DISP_DISABLE_MASK 0x00000008
9470 +#define DEV_HOST_GHSMSG_INTERRUPT_MASK 0x00000010
9471 +
9472 +typedef struct
9473 +{
9474 + UINT8 stdMode; // Desired train mode. See training modes defined above.
9475 + UINT8 ghsSequence; // Selected G.hs session as shown in Appendix 1
9476 + UINT8 usPilotFlag; // Value of 1 indicates transmit an upstream pilot on bin 16
9477 + UINT8 bDummy1; // dummy byte for 32-bit alignment
9478 + UINT8 rMsgs1[38]; // RMSG-1(6) and RMSG_PCB (38)
9479 + UINT8 bDummy2[2]; // dummy bytes for 32-bit alignment
9480 + UINT32 oamFeature; // 32 bit wide bit field to set OAM-specific features.
9481 + SINT8 marginThreshold; // Threshold for margin reporting
9482 + UINT8 hostFixAgc; // flag to force datapump to bypass AGC training and use the following values
9483 + UINT8 hostFixEqualizer; // forced analog equalizer value used during AGC training when hostfix_agc is on
9484 + UINT8 hostFixPga1; // forced pga1 value used during AGC training when hostFixAgc is on
9485 + UINT8 hostFixPga2; // forced pga2 value used during AGC training when hostFixAgc is on
9486 + UINT8 hostFixPga3; // forced pga3 value used during AGC training when hostFixAgc is on
9487 + UINT8 marginMonitorShwtme; // margin monitoring flag (during showtime)
9488 + UINT8 marginMonitorTrning; // margin monitoring flag (during training)
9489 + UINT8 disableLosAlarm; // flag to disable training based on los
9490 + UINT8 usCrcRetrain; // flag to disable retrain due to excessive USCRC
9491 + UINT8 t1413VendorId[2]; // Vendor ID used for T1.413 trainings
9492 + UINT8 gdmtVendorId[8]; // Vendor ID used for G.dmt trainings (ITU VendorID)
9493 + UINT8 missingTones[64]; // 64 element array to define missing tones for TX_MEDLEY and TX REVERB tests
9494 + UINT32 missingToneDsAddr; // Address given to DSP for tones to be switched off in DS direction
9495 + UINT8 dsToneTurnoff_f; // This flag controls the DS tone turn off logic
9496 + UINT8 reserved1; // Dummy bytes
9497 + UINT8 reserved2; // Dummy bytes
9498 + UINT8 reserved3; // Dummy bytes
9499 +} DEV_HOST_oamWrNegoParaDef_t;
9500 +
9501 +
9502 +// ----------------------------------------
9503 +// Begin Rate-adaptive message definitions.
9504 +// ----------------------------------------
9505 +
9506 +// The four values below can never be changed (for host intf. backwards compatibility)
9507 +#define DEV_HOST_RMSGSRA_LENGTH 10
9508 +#define DEV_HOST_RRATESRA_LENGTH 1
9509 +#define DEV_HOST_CRATESRA_LENGTH 120
9510 +#define DEV_HOST_CMSGSRA_LENGTH 6
9511 +
9512 +typedef struct
9513 +{
9514 + UINT8 rRatesRaString[DEV_HOST_RRATESRA_LENGTH+3];
9515 + UINT8 rMsgsRaString[DEV_HOST_RMSGSRA_LENGTH+2];
9516 + UINT8 cMsgsRaString[DEV_HOST_CMSGSRA_LENGTH+2];
9517 +} DEV_HOST_raMsgsDef_t;
9518 +
9519 +
9520 +// ----------------------------------------------
9521 +// Begin superframe cnts definitions - DSP write.
9522 +// ----------------------------------------------
9523 +
9524 +#define DEV_HOST_FRAMES_PER_SUPER 68
9525 +#define DEV_HOST_SUPERFRAMECNTDSTRM 0
9526 +#define DEV_HOST_SUPERFRAMECNTUSTRM 4
9527 +
9528 +// Although only the least significant 8 bits should be used as an
9529 +// unsigned char for computing the bitswap superframe number, a
9530 +// full 32 bit counter is provided here in order to have an
9531 +// accurate indicator of the length of time that the modem has
9532 +// been connected. This counter will overflow after 2.35 years
9533 +// of connect time.
9534 +
9535 +typedef struct
9536 +{
9537 + UINT32 wSuperFrameCntDstrm;
9538 + UINT32 wSuperFrameCntUstrm;
9539 +} DEV_HOST_dspWrSuperFrameCntDef_t;
9540 +
9541 +
9542 +// --------------------------------
9543 +// Begin ATUR/ATUC msg definitions.
9544 +// --------------------------------
9545 +
9546 +// Grouping used by the DSP to simplify parameter passing.
9547 +// All of these are written by the DSP.
9548 +
9549 +typedef struct
9550 +{
9551 + UINT16 vendorId; // TI's vendor ID = 0x0004; Amati's vendor ID = 0x0006
9552 + UINT8 versionNum; // T1.413 issue number
9553 + UINT8 rateAdapt; // 0 = fix rate (Default); 1= adaptive rate
9554 + UINT8 trellis; // 0 = disable trellis(default); 1 = enable trellis
9555 + UINT8 echoCancelling; // 0 = disable echo cancelling; 1 = enable echo cancelling(default)
9556 + UINT8 maxBits; // value range: 0-15; default = 15
9557 + UINT8 maxPsd; //
9558 + UINT8 actualPsd; //
9559 + UINT8 maxIntlvDepth; // 0, 1, 2, or 3 for 64, 128, 256, or 512 max depth
9560 + UINT8 framingMode; // 0 for asynchronous, 1 for synchronous full overhead
9561 + // 2 for reduced overhead, 3 for merged reduced overhead DSP write.
9562 + UINT8 maxFrameMode; // maximum framing mode desired. Nor 0 or 3.
9563 + SINT16 targetMargin; //
9564 + SINT16 maxAllowedMargin; //
9565 + SINT16 minRequiredMargin; //
9566 + SINT16 maxTotBits; //
9567 + UINT8 grossGain; //
9568 + UINT8 ntr; // Enable/disable NTR support
9569 + SINT16 loopAttn; // Loop Attenuation
9570 + UINT8 vendorRevisionNumber; // Reported Vendor Revision Number
9571 + UINT8 reserved1; // for 32-bit alignment
9572 + UINT8 reserved2; // for 32-bit alignment
9573 + UINT8 reserved3; // for 32-bit alignment
9574 +} DEV_HOST_msg_t;
9575 +
9576 +
9577 +// --------------------------------------
9578 +// Begin bits and gains table definitions
9579 +// --------------------------------------
9580 +
9581 +typedef struct
9582 +{
9583 + PUINT8 aturBng_p; // pointer to ATU-R bits and gains table
9584 + PUINT8 atucBng_p; // pointer to ATU-C bits and gains table
9585 + PUINT8 bitAllocTblDstrm_p; // pointer to Downstream Bit Allocation table
9586 + PUINT8 bitAllocTblUstrm_p; // pointer to Upstream Bit Allocation table
9587 + PSINT8 marginTblDstrm_p; // pointer to Downstream Margin table
9588 +} DEV_HOST_dspWrSharedTables_t;
9589 +
9590 +
9591 +// ----------------------------------------
9592 +// Begin datapump code overlay definitions.
9593 +// ----------------------------------------
9594 +
9595 +#define DEV_HOST_PAGE_NUM 4 // number of overlay pages
9596 +
9597 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_olayDpDef_t struct
9598 +typedef struct
9599 +{
9600 + UINT32 overlayHostAddr; // source address in host memory
9601 + UINT32 overlayXferCount; // number of 32bit words to be transfered
9602 + UINT32 overlayDspAddr; // destination address in DSP's PMEM
9603 +} DEV_HOST_olayDpPageDef_t;
9604 +
9605 +
9606 +typedef struct
9607 +{
9608 + UINT32 overlayStatus; // Status of current overlay to DSP PMEM
9609 + UINT32 overlayNumber; // DSP PMEM overlay page number
9610 + UINT32 overlayState; // Indicates whether current state is an overlay state
9611 + DEV_HOST_olayDpPageDef_t *olayDpPage_p[DEV_HOST_PAGE_NUM]; // Def's for the Pages
9612 +} DEV_HOST_olayDpDef_t;
9613 +
9614 +
9615 +// -------------------------
9616 +// Begin ATM-TC definitions.
9617 +// -------------------------
9618 +
9619 +// TC cell states.
9620 +typedef enum
9621 +{
9622 + TC_HUNT,
9623 + TC_PRESYNC,
9624 + TC_SYNC
9625 +} DEV_HOST_cellDelinState_t;
9626 +
9627 +
9628 +// --------------------------------------------
9629 +// Begin datapump error/statistics definitions.
9630 +// --------------------------------------------
9631 +
9632 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_modemStatsDef_t struct.
9633 +typedef struct
9634 +{
9635 + UINT32 crcErrors; // Num of CRC errored ADSL frames
9636 + UINT32 fecErrors; // Num of FEC errored (corrected) ADSL frames
9637 + UINT32 ocdErrors; // Out of Cell Delineation
9638 + UINT32 ncdError; // No Cell Delineation
9639 + UINT32 lcdErrors; // Loss of Cell Delineation (within the same connection)
9640 + UINT32 hecErrors; // Num of HEC errored ADSL frames
9641 +} DEV_HOST_errorStats_t;
9642 +
9643 +
9644 +typedef struct
9645 +{
9646 + DEV_HOST_errorStats_t *usErrorStatsIntlv_p; // us error stats - interleave path
9647 + DEV_HOST_errorStats_t *dsErrorStatsIntlv_p; // ds error stats - interleave path
9648 + DEV_HOST_errorStats_t *usErrorStatsFast_p; // us error stats - fast path
9649 + DEV_HOST_errorStats_t *dsErrorStatsFast_p; // ds error stats - fast path
9650 + UINT32 losErrors; // Num of ADSL frames where loss-of-signal
9651 + UINT32 sefErrors; // Num of severly errored ADSL frames - LOS > MAXBADSYNC ADSL frames
9652 + UINT32 farEndLosErrors; // Number of reported LOS defects by the CO.
9653 + UINT32 farEndRdiErrors; // Number of reported RDI defects by the CO.
9654 +} DEV_HOST_modemStatsDef_t;
9655 +
9656 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_atmStats_t struct.
9657 +typedef struct
9658 +{
9659 + UINT32 goodCount; // Upstream Good Cell Count
9660 + UINT32 idleCount; // Upstream Idle Cell Count
9661 +} DEV_HOST_usAtmStats_t;
9662 +
9663 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_atmStats_t struct.
9664 +typedef struct
9665 +{
9666 + UINT32 goodCount; // Downstream Good Cell Count
9667 + UINT32 idleCount; // Downstream Idle Cell Count
9668 + UINT32 badHecCount; // Downstream Bad Hec Cell Count
9669 + UINT32 ovflwDropCount; // Downstream Overflow Dropped Cell Count
9670 + DEV_HOST_cellDelinState_t delineationState; // Indicates current delineation state
9671 +} DEV_HOST_dsAtmStats_t;
9672 +
9673 +
9674 +typedef struct
9675 +{
9676 + DEV_HOST_usAtmStats_t *us0_p; // US ATM stats for TC channel 0
9677 + DEV_HOST_dsAtmStats_t *ds0_p; // DS ATM stats for TC channel 0
9678 + DEV_HOST_usAtmStats_t *us1_p; // US ATM stats for TC channel 1
9679 + DEV_HOST_dsAtmStats_t *ds1_p; // DS ATM stats for TC channel 1
9680 +} DEV_HOST_atmStats_t;
9681 +
9682 +
9683 +// ----------------------
9684 +// Begin EOC definitions.
9685 +// ----------------------
9686 +
9687 +// The two values below can never change (for backwards compatibility of host intf.)
9688 +#define DEV_HOST_EOCREG4LENGTH 32
9689 +#define DEV_HOST_EOCREG5LENGTH 32
9690 +
9691 +typedef struct
9692 +{
9693 + UINT8 eocReg4[DEV_HOST_EOCREG4LENGTH]; // Host/Dsp Write, vendor specific EOC Register 4
9694 + UINT8 eocReg5[DEV_HOST_EOCREG5LENGTH]; // Host/Dsp Write, vendor specific EOC Register 5
9695 + UINT8 vendorId[8]; // Host write
9696 + UINT8 revNumber[4]; // Host, ATU-R Revision Number
9697 + UINT8 serialNumber[32]; // Host write
9698 + UINT8 eocReg4Length; // Host Write, valid length for EOC register 4
9699 + UINT8 eocReg5Length; // Host Write, valid length for EOC register 5
9700 + UINT8 dummy[2]; // dummy bytes for 32-bit alignment
9701 + UINT32 eocModemStatusReg; // Dsp Write, status bits to host
9702 + UINT8 lineAtten; // Dsp Write, line attenuation in 0.5 db step
9703 + SINT8 dsMargin; // DSP Write, measured DS margin
9704 + UINT8 aturConfig[30]; // Dsp Write, also used by EOC for ATUR Configuration
9705 +} DEV_HOST_eocVarDef_t;
9706 +
9707 +typedef struct
9708 +{
9709 + UINT16 endEocThresh; // Host Write, end of Clear EOC stream threshold
9710 + UINT16 dummy; // dummy value to fill gap
9711 + UINT32 dropEocCount; // Dsp Write, counter of dropped Clear EOC bytes
9712 + UINT16 eocRxLength; // Host/DSP write, number of valid Rx Clear EOC bytes
9713 + UINT16 eocTxLength; // Host/DSP write, number of valid Tx Clear EOC bytes
9714 + UINT8 eocRxBuf[64]; // Dsp Write, Buffer for receiving Rx Clear EOC bytes
9715 + UINT8 eocTxBuf[64]; // Host Write, Buffer for writing Tx Clear EOC bytes
9716 +} DEV_HOST_clearEocVarDef_t;
9717 +
9718 +
9719 +// -----------------------------------
9720 +// Begin CO profile Definitions.
9721 +// -----------------------------------
9722 +
9723 +/* struct size must be a word size */
9724 +typedef struct
9725 +{
9726 +
9727 + SINT16 devCodecRxdf4Coeff[12] ; // (BOTH) IIR Coefficients
9728 + SINT16 devCodecTxdf2aCoeff[64] ; // (BOTH) FIR filter coefficients
9729 + SINT16 devCodecTxdf2bCoeff[64] ; // (BOTH) FIR filter coefficients
9730 + SINT16 devCodecTxdf1Coeff[12] ; // (BOTH) IIR filter coefficients
9731 + UINT16 devCodecTxDf2aDen; // (BOTH) denominator for IIR filter
9732 + UINT16 devCodecTxDf2bDen; // (BOTH) denominator for IIR filter
9733 + SINT16 ctrlMsmSpecGain[32]; // (BOTH)
9734 +
9735 + SINT16 phyBitaRateNegIntNoTrellis ; // (BOTH) value to set
9736 + SINT16 phyBitaRateNegIntTrellis ; // (BOTH) value to set
9737 + SINT16 phyBitaRateNegFastNoTrellis ; // (BOTH) value to set
9738 + SINT16 phyBitaRateNegFastTrellis ; // (BOTH) value to set
9739 + SINT16 phyBitaRsFlag ; // (BOTH)
9740 + SINT16 phyBitaFirstSubChannel ; // (BOTH)
9741 + SINT16 phyBitaMaxFineGainBump; // max fine gain bump
9742 + SINT16 phyBitaFineGainReduction; // fine gain reduction
9743 + SINT16 phyBitaMaxDownstreamPowerCutback; // max downstream power cutback
9744 +
9745 + SINT16 phySigTxGainReductionAt0kft; // upstream power reduction at 0 kft.
9746 +
9747 + SINT16 phyAgcPgaTarget ; // (BOTH) compare value
9748 +
9749 + UINT16 imsg413TxRate ; // (BOTH) Tx rate
9750 + SINT16 imsg413RsBytesAdjust ; // (BOTH) subtract value
9751 + UINT16 imsg413PstringMask ; // (POTS) Or'ed into pString[RMSGS1_INDEX][1]
9752 + SINT16 imsg413UsPilot ; // (BOTH)??
9753 + UINT16 imsg413SkipPhaseOp ; // (POTS)
9754 +
9755 + UINT16 ctrlMsmSensitivity1 ; // (BOTH) value to set
9756 + UINT16 ctrlMsmTxPsdShape_f; // (BOTH) upstream spectral shaping flag
9757 +
9758 + UINT16 ovhdAocUsBswapReq_f ; // (BOTH)value to set
9759 + UINT16 ovhdAocScanMse_f ; // (BOTH)value to set
9760 +
9761 + SINT16 phyRevFullFirstBin ; //
9762 + SINT16 phyRevFullLastBin ; //
9763 + SINT16 phyRevFirstBin ; //
9764 + SINT16 phyRevLastBin ; //
9765 + SINT16 phyMedFirstBin ; //
9766 + SINT16 phyMedLastBin ; //
9767 + SINT16 phyMedOptionalLastBin; // Medley last bin - optional
9768 +
9769 + SINT16 phyEcDelayAdjustment; // Echo delay adjustment
9770 + SINT16 bSwapThresholdUpdate; // bSwapThresholdUpdate
9771 + SINT16 phyBitaFastPathExcessFineGainBump; // Used in phy_bita.c
9772 + SINT16 phyBitaSkipGapAdjustment; // Used in phy_bita.c
9773 + SINT16 usPilotInT1413ModeInMedley; // To send Upstream Pilot in medley in T1.413 mode.
9774 +
9775 + UINT32 profileVendorId ; // vendor id
9776 +
9777 +} DEV_HOST_coData_t ;
9778 +
9779 +typedef struct
9780 +{
9781 + DEV_HOST_coData_t * hostProfileBase_p; // base address of profile list
9782 +} DEV_HOST_profileBase_t ;
9783 +
9784 +
9785 +
9786 +// -----------------------------------
9787 +// Begin DSP/Host Mailbox Definitions.
9788 +// -----------------------------------
9789 +
9790 +// The 3 values below can never be decreased, only increased.
9791 +// If you increase one of the values, you must add more to the
9792 +// initializers in "dev_host_interface.c".
9793 +#define DEV_HOST_HOSTQUEUE_LENGTH 8
9794 +#define DEV_HOST_DSPQUEUE_LENGTH 8
9795 +#define DEV_HOST_TEXTQUEUE_LENGTH 8
9796 +
9797 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_mailboxControl_t struct.
9798 +typedef struct
9799 +{
9800 + UINT8 cmd;
9801 + UINT8 tag;
9802 + UINT8 param1;
9803 + UINT8 param2;
9804 +} DEV_HOST_dspHostMsg_t;
9805 +
9806 +// Never access a struct of this typedef directly. Always go through the DEV_HOST_mailboxControl_t struct.
9807 +typedef struct
9808 +{
9809 + UINT32 msgPart1;
9810 + UINT32 msgPart2;
9811 +} DEV_HOST_textMsg_t;
9812 +
9813 +// The structure below has been ordered so that the Host need only write to
9814 +// even byte locations to update the indices.
9815 +
9816 +// The Buffer pointers in the struct below each point to a different
9817 +// struct array that has an array size of one of the matching Queue Length
9818 +// values defined above (DEV_HOST_HOSTQUEUE_LENGTH, DEV_HOST_DSPQUEUE_LENGTH,
9819 +// and DEV_HOST_TEXTQUEUE_LENGTH).
9820 +
9821 +typedef struct
9822 +{
9823 + UINT8 hostInInx; // Host write, DSP must never write except for init
9824 + UINT8 bDummy0[3]; // dummy bytes for explicit 32-bit alignment
9825 + UINT8 hostOutInx; // DSP write, Host must never write
9826 + UINT8 bDummy1[3]; // dummy bytes for explicit 32-bit alignment
9827 + UINT8 dspOutInx; // Host write, DSP must never write except for init
9828 + UINT8 bDummy2[3]; // dummy bytes for explicit 32-bit alignment
9829 + UINT8 dspInInx; // DSP write, Host must never write
9830 + UINT8 bDummy3[3]; // dummy bytes for explicit 32-bit alignment
9831 + UINT8 textInInx; // DSP write, Host must never write
9832 + UINT8 bDummy4[3]; // dummy bytes for explicit 32-bit alignment
9833 + UINT8 textOutInx; // Host write, DSP must never write except for init
9834 + UINT8 bDummy5[3]; // dummy bytes for explicit 32-bit alignment
9835 + DEV_HOST_dspHostMsg_t *hostMsgBuf_p; // pointer to Host Mailbox Buffer (Host writes the buffer)
9836 + DEV_HOST_dspHostMsg_t *dspMsgBuf_p; // pointer to DSP Mailbox Buffer (DSP writes the buffer)
9837 + DEV_HOST_textMsg_t *textMsgBuf_p; // pointer to Text Mailbox Buffer (DSP writes the buffer)
9838 +} DEV_HOST_mailboxControl_t;
9839 +
9840 +
9841 +//-----------------------------------------
9842 +// Physical layer performance parameter
9843 +//-----------------------------------------
9844 +typedef struct
9845 +{
9846 + SINT32 hybridCost[5]; // Cost functions for hybrids (0: none, 1-4 hybrid options)
9847 + SINT32 usAvgGain; // upstream average gain in 20log10 (Q8)
9848 + SINT32 dsAvgGain; // downstream average gain in 20log10 (Q8)
9849 + UINT8 disableDspHybridSelect_f; // Allows host to disable the automatic hybrid selection by the DSP
9850 + UINT8 hostSelectHybridNum; // DSP will use this hybrid number only if DSP Select is disabled (values: 1-4)
9851 + UINT8 currentHybridNumUsed; // DSP indicates to the host the current hybrid number in use
9852 + UINT8 reserved1; // reserved for future use
9853 +} DEV_HOST_phyPerf_t;
9854 +
9855 +
9856 +/***********************************************************
9857 + * The 3 structures below are used only for analog
9858 + * diagnostic functions originally defined in diag.h
9859 + * Moved here by Carlos A. Perez under J. Bergsagel request
9860 + ***********************************************************/
9861 +
9862 +/****************************************************************************/
9863 +/* Options for the Analog Diagnostic user input data structure */
9864 +/* (MUST be word aligned) */
9865 +/****************************************************************************/
9866 +typedef enum
9867 +{
9868 + ZERO_DIAG_OPT = 0, // dummy value for zero place-holder
9869 + NOISE_ONLY = 0x1, // diagnostic in noise only mode (on=1, off=0), disregard diagMode 0-4
9870 + EXTERNAL_CO = 0x2, // operates against external CO (external=1, internal=0)
9871 + DIAG_AGC = 0x4, // agc selects gains control (agc=1, manual=0)
9872 + CROSSTALK_TEQ = 0x8, // crosstalk selects teq (crosstalk=1, manual=0)
9873 + LEAKY_TEQ = 0x10, // use leaky teq (on=1, off=0)
9874 + AUX_AMPS = 0x20, // auxamps (on=1, off=0)
9875 + BW_SELECT = 0x40, // change rxhpf/txlpf fc (modify=1, default=0)
9876 + DIAG_HYB_SELECT = 0x80, // change hybrid (modify=1, default=0)
9877 + POWER_DOWN_CDC = 0x100, // power down codec (power down=1, no power down=0)
9878 + ISDN_OP_MODE = 0x200, // operation mode (pots=0, isdn=1)
9879 + BYPASS_RXAF2 = 0x400, // Bypass except RXAF2 (on=1, off = 0)
9880 + TX_TEST_CONT = 0x800, // Continuous tx test (on=1, off=0)
9881 + TX_SCALE_MTT = 0x1000 // Scale tx signal for Mtt test (on=1, off=0)
9882 +} DEV_HOST_diagAnlgOptionsVar_t;
9883 +
9884 +/****************************************************************************/
9885 +/* Analog Diagnostic user input data structure (MUST be word align) */
9886 +/****************************************************************************/
9887 +
9888 +typedef struct
9889 +{
9890 + DEV_HOST_diagAnlgOptionsVar_t diagOption; // Other diagnostic optional settings
9891 +
9892 + UINT8 diagMode; // Performance diagnostic mode
9893 + UINT8 txMode; // transmit mode
9894 + UINT8 rxMode; // receive mode
9895 + UINT8 teqSp; // Select teq starting pt
9896 + UINT8 txDf1; // see dev_codec_filters.c and
9897 + UINT8 txDf2a; // dev_codec.h for filter coefficients
9898 + UINT8 txDf2b;
9899 + UINT8 rxDf4;
9900 +
9901 + UINT16 codingGain256Log2; // 256*Log2(coding gain)
9902 + UINT16 noiseMargin256Log2; // 256*Log2(noise margin)
9903 +
9904 + UINT16 rxPga1; // PGA1
9905 + UINT16 rxPga2; // PGA2
9906 + UINT16 rxPga3; // PGA3
9907 + UINT16 anlgEq; // AEQ settings (dB/MHz)
9908 +
9909 + SINT8 pilotBin; // Select pilot subchannel
9910 + SINT8 txSwGain; // manual set for bridge tap loop
9911 + SINT8 tdw1Len; // TDW1 length - 0,2,4,8,16
9912 + SINT8 tdw2Len; // TDW2 length - 0,2,4,8,16
9913 +
9914 + UINT8 teqEcMode; // TEQ/EC mode
9915 + UINT8 hybrid;
9916 + UINT8 txAttn; // Codec Tx attenuation
9917 + UINT8 txGain; // Codec Tx gain (Sangam only)
9918 +
9919 + SINT16 txPda; //Codec Tx Digital gain/attn
9920 + UINT8 txTone[MAX_NUM_UPBINS]; // Turning tones on/off
9921 + // Still govern by lastbin
9922 + UINT16 rsvd; //for 32 bits alignment
9923 +}DEV_HOST_diagAnlgInputVar_t;
9924 +
9925 +/****************************************************************************/
9926 +/* Analog diagnostic output data structure */
9927 +/****************************************************************************/
9928 +typedef struct
9929 +{
9930 + PSINT32 rxSnr_p[2]; // Pointer to estimated snr
9931 + PSINT32 rxSubChannelCapacity_p[2]; // Pointer to estimated subchan capacity
9932 + PSINT32 rxSignalPower_p[2]; // Pointer to estimated signal power
9933 + PSINT32 rxNoisePower_p[2]; // Pointer to estimated noise power
9934 + PSINT32 rxAvg_p; // Pointer to average of rcvd signal
9935 + SINT32 chanCapacity[2] ; // Channel total capacity
9936 + SINT32 dataRate[2]; // Modem data rate (SNR)
9937 + SINT32 avgNoiseFloor; // Average noise floor
9938 + SINT16 snrGap256Log2; // 256*Log2(snr gap)
9939 + SINT16 rxPga1; // PGA1
9940 + SINT16 rxPga2; // PGA2
9941 + SINT16 rxPga3; // PGA3
9942 + SINT16 anlgEq; // AEQ settings (dB/MHz)
9943 + SINT16 rsvd;
9944 +}DEV_HOST_diagAnlgOutputVar_t;
9945 +
9946 +
9947 +// Bit field structure that allows the host to mask off interrupt sources for possible DSP-to-Host interrupts.
9948 +// Each bit represents a possible source of interrupts in the DSP code that might cause a DSP-to-Host
9949 +// interrupt to occur.
9950 +// This mask structure is not intended to show how interrupt sources in the DSP code correspond to the actual
9951 +// DSP-to-Host interrupts. There could be multiple ways to cause an interrupt in the DSP code, but they all
9952 +// eventually tie into one of the three possible DSP-to-Host interrupts.
9953 +// The host should write a "1" to an individual bit when it wants to mask possible interrupts from that source.
9954 +
9955 +// enum that represents individual bits in maskBitField1
9956 +typedef enum
9957 +{
9958 + ZERO_MASK1 = 0, // dummy value for zero place-holder
9959 + DSP_MSG_BUF = 0x1, // mask interrupts due to DSP-to-Host message mailbox updates
9960 + STATE_BIT_FIELD = 0x2, // mask interrupts due to changes in the modem state bit fields
9961 + DSP_HEARTBEAT = 0x4 // mask interrupts for the DSP hearbeat
9962 +} DEV_HOST_intMask1_t; // this enum should only have 32 values in it (maximum).
9963 +
9964 +// Add more "mask bit fields" at the end of this struct if you need more mask values
9965 +typedef struct
9966 +{
9967 + DEV_HOST_intMask1_t maskBitField1;
9968 +} DEV_HOST_hostInterruptMask_t; // this struct should only have 32 bits in it.
9969 +
9970 +// Bit field structure that allows the host to determine the source(s) of DSP-to-Host interrupts in case
9971 +// several of the interrupt sources get combined onto a single DSP-to-Host interrupt.
9972 +// DSP will set each bit to a "1"as an interrupt occurs.
9973 +// Host has the reponsibility to clear each bit to a "0" after it has determined the source(s) of interrupts.
9974 +// Each source bit field in this struct will use the same enum typedef that matches the corresponding mask
9975 +// bit field in "DEV_HOST_hostInterruptMask_t"
9976 +typedef struct
9977 +{
9978 + DEV_HOST_intMask1_t sourceBitField1;
9979 +} DEV_HOST_hostInterruptSource_t;
9980 +
9981 +
9982 +// --------------------------
9983 +// Begin bitswap definitions.
9984 +// --------------------------
9985 +
9986 +// bitSwapSCnt contains the superframe to perform bit swap
9987 +// The entries must be ordered so that the first group only contains bit change commands
9988 +// The other entries may contain power adjustment instructions and must be
9989 +// written with something. NOP (0) is an available instruction.
9990 +typedef struct
9991 +{
9992 + PUINT8 fineGains_p; // pointer to bng string, needed to check fine gains for powerswap
9993 + UINT8 bitSwapNewIndices[6]; // Bin before bitSwapBin to process
9994 + UINT8 bitSwapCmd[6]; // Bitswap command for bitSwapBin
9995 + UINT8 bitSwapBin[6]; // bin to modify
9996 + UINT8 bitSwapSCnt; // Superframe count on which to perform bitswap
9997 + UINT8 bitSwapEnabled; // bitSwapEnabled
9998 +} DEV_HOST_dspBitSwapDef_t;
9999 +
10000 +
10001 +// ---------------------------
10002 +// Begin ATM BERT definitions.
10003 +// ---------------------------
10004 +
10005 +// Structure used for ATM Idle Cells based bit error rate computation.
10006 +typedef struct
10007 +{
10008 + UINT8 atmBertFlag; // Feature enable/disable flag (Host write)
10009 + UINT8 dummy1;
10010 + UINT8 dummy[2]; // Dummy bytes for 32-bit alignment
10011 + UINT32 bitCountLow; // Low part of 64-bit BERT bit count (DSP write)
10012 + UINT32 bitCountHigh; // High part of 64-bit BERT bit count (DSP write)
10013 + UINT32 bitErrorCountLow; // Low part of 64-bit BERT bit count (DSP write)
10014 + UINT32 bitErrorCountHigh;// High part of 64-bit BERT bit count (DSP write)
10015 +} DEV_HOST_atmDsBert_t;
10016 +
10017 +
10018 +// ------------------------------------
10019 +// Misc. modem environment definitions.
10020 +// ------------------------------------
10021 +
10022 +
10023 +typedef struct
10024 +{
10025 + SINT16 subStateIndex; // Index that signifies datapump substate. (DSP write)
10026 + UINT8 externalBert; // Turn on/off external BERT interface. 0 = OFF; 1 = ON. (Host write)
10027 + UINT8 usBertPattern; // BERT pattern for US TX data. 0 = 2^15-1; 1 = 2^23-1. (Host write)
10028 + UINT8 overrideDslLinkLed_f; // Overrides DSP operation of the DSL_LINK LED. (Host write)
10029 + // 0 = DSP is in control; 1 = Host is in control.
10030 + UINT8 dslLinkLedState_f; // DSL_LINK LED state when override flag has been set. (Host write)
10031 + // DSL_LINK LED will be updated with this value once per frame.
10032 + // LED is active-low: 0 = ON, 1 = OFF.
10033 + UINT8 overrideDslActLed_f; // Overrides DSP operation of the DSL_ACT LED. (Host write)
10034 + // 0 = DSP is in control; 1 = Host is in control.
10035 + UINT8 dslActLedState_f; // DSL_ACT LED state when override flag has been set. (Host write)
10036 + // DSL_ACT LED will be updated with this value once per frame.
10037 + // LED is active-low: 0 = ON, 1 = OFF.
10038 + UINT8 dGaspLprIndicator_f; // How LPR signal (GPIO[0]) is to be interpreted. (Host write)
10039 + // 0 = LPR is active-low; 1 = LPR is active-high.
10040 + UINT8 overrideDspLprGasp_f; // Overrides DSP detection of LPR signal to send out DGASP. (Host write)
10041 + // 0 = DSP detects LPR; 1 = Host detects LPR and sends "HOST_DGASP" to DSP.
10042 + UINT8 pcbEnabled; // DS power cut back
10043 + UINT8 maxAvgFineGainCtrl_f; // If maxAvgFineGainCtrl_f == 0, then the datapump controls the maximum average fine gain value.
10044 + // If maxAvgFineGainCtrl_f == 1, then the host controls the maximum average fine gain value.
10045 + UINT32 reasonForDrop; // This field will tell the host what might be the reason for a dropped connection.
10046 + SINT16 maxAverageFineGain; // When maxAvgFineGainCtrl_f == 1, the value in maxAverageFineGain is the maximum average fine gain level in 256log2 units.
10047 + UINT8 reserved1; // These are for 32-bit alignment.
10048 + UINT8 reserved2; // These are for 32-bit alignment.
10049 +} DEV_HOST_modemEnvPublic_t;
10050 +
10051 +
10052 +// -----------------------------
10053 +// Generic structure definition.
10054 +// -----------------------------
10055 +
10056 +typedef struct
10057 +{
10058 + PSINT8 parameter1_p;
10059 + PSINT16 parameter2_p;
10060 + PSINT32 parameter3_p;
10061 + PUINT8 parameter4_p;
10062 + PUINT16 parameter5_p;
10063 + PUINT32 parameter6_p;
10064 +} DEV_HOST_genericStructure_t;
10065 +
10066 +
10067 +// ------------------------------
10068 +// Begin G.hs buffer definitions.
10069 +// ------------------------------
10070 +
10071 +typedef struct
10072 +{
10073 + UINT8 txBuf[64]; // G.hs xmt buffer
10074 +} DEV_HOST_ghsDspTxBufDef_t;
10075 +
10076 +
10077 +typedef struct
10078 +{
10079 + UINT8 rxBuf[80]; // G.hs rcv buffer
10080 +} DEV_HOST_ghsDspRxBufDef_t;
10081 +
10082 +// -----------------------------------------
10083 +// Begin Constellation Display definitions.
10084 +// -----------------------------------------
10085 +
10086 +typedef struct
10087 +{
10088 + UINT32 consDispStartAddr; // Host write
10089 + UINT32 consDispCurrentAddr; // Host write
10090 + UINT32 consDispBufLen; // Constellation Buffer Length
10091 + UINT32 consDispBin; // Host write, DS band only
10092 +} DEV_HOST_consBufDef_t;
10093 +
10094 +typedef struct
10095 +{
10096 + PSINT16 buffer1_p; //DSP write
10097 + PSINT16 buffer2_p; //DSP write
10098 +} DEV_HOST_snrBuffer_t;
10099 +
10100 +// --------------------------------------------------------------------------------------
10101 +// Typedef to be used for the DEV_HOST_dspOamSharedInterface_s struct of pointers
10102 +// (this is used in dev_host_interface.c).
10103 +// NOTE: This struct of pointers is NEVER to be referenced anywhere else in the DSP code.
10104 +// IMPORTANT: Only pointers to other structs go into this struct !!
10105 +// --------------------------------------------------------------------------------------
10106 +typedef struct
10107 +{
10108 + DEV_HOST_hostIntfcVersionDef_t *hostIntfcVersion_p;
10109 + DEV_HOST_dspVersionDef_t *datapumpVersion_p;
10110 + DEV_HOST_modemStateBitField_t *modemStateBitField_p;
10111 + DEV_HOST_dspWrNegoParaDef_t *dspWriteNegoParams_p;
10112 + DEV_HOST_oamWrNegoParaDef_t *oamWriteNegoParams_p;
10113 + DEV_HOST_raMsgsDef_t *raMsgs_p;
10114 + DEV_HOST_dspWrSuperFrameCntDef_t *dspWriteSuperFrameCnt_p;
10115 + DEV_HOST_msg_t *atucMsg_p;
10116 + DEV_HOST_msg_t *aturMsg_p;
10117 + DEV_HOST_dspWrSharedTables_t *dspWrSharedTables_p;
10118 + DEV_HOST_olayDpDef_t *olayDpParms_p;
10119 + DEV_HOST_eocVarDef_t *eocVar_p;
10120 + DEV_HOST_clearEocVarDef_t *clearEocVar_p;
10121 + DEV_HOST_modemStatsDef_t *modemStats_p;
10122 + DEV_HOST_atmStats_t *atmStats_p;
10123 + DEV_HOST_mailboxControl_t *dspHostMailboxControl_p;
10124 + DEV_HOST_phyPerf_t *phyPerf_p;
10125 + DEV_HOST_diagAnlgInputVar_t *analogInputVar_p;
10126 + DEV_HOST_diagAnlgOutputVar_t *analogOutputVar_p;
10127 + DEV_HOST_hostInterruptMask_t *hostInterruptMask_p;
10128 + DEV_HOST_profileBase_t *profileList_p;
10129 + DEV_HOST_hostInterruptSource_t *hostInterruptSource_p;
10130 + DEV_HOST_dspBitSwapDef_t *dspBitSwapDstrm_p;
10131 + DEV_HOST_dspBitSwapDef_t *dspBitSwapUstrm_p;
10132 + DEV_HOST_atmDsBert_t *atmDsBert_p;
10133 + DEV_HOST_modemEnvPublic_t *modemEnvPublic_p;
10134 + DEV_HOST_genericStructure_t *genericStructure1_p;
10135 + DEV_HOST_genericStructure_t *genericStructure2_p;
10136 + DEV_HOST_ghsDspTxBufDef_t *ghsDspTxBuf_p;
10137 + DEV_HOST_ghsDspRxBufDef_t *ghsDspRxBuf_p;
10138 + DEV_HOST_consBufDef_t *consDispVar_p;
10139 + DEV_HOST_snrBuffer_t *snrBuffer_p;
10140 +} DEV_HOST_dspOamSharedInterface_t;
10141 +
10142 +
10143 +// ---------------------------------------------------------------------------------
10144 +// Typedef to be used for the pointer to the DEV_HOST_dspOamSharedInterface_s struct
10145 +// of pointers (this is used in dev_host_interface.c).
10146 +// ---------------------------------------------------------------------------------
10147 +typedef DEV_HOST_dspOamSharedInterface_t *DEV_HOST_dspOamSharedInterfacePtr_t;
10148 +
10149 +#endif
10150 diff -urN linux.old/drivers/atm/sangam_atm/dev_host_verdef.h linux.dev/drivers/atm/sangam_atm/dev_host_verdef.h
10151 --- linux.old/drivers/atm/sangam_atm/dev_host_verdef.h 1970-01-01 01:00:00.000000000 +0100
10152 +++ linux.dev/drivers/atm/sangam_atm/dev_host_verdef.h 2005-08-23 04:46:50.091844608 +0200
10153 @@ -0,0 +1,102 @@
10154 +#ifndef __DEV_HOST_VERDEF_H__
10155 +#define __DEV_HOST_VERDEF_H__ 1
10156 +
10157 +//********************************************************************
10158 +//*
10159 +//* DMT-BASE ADSL MODEM PROGRAM
10160 +//* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
10161 +//* AMATI CONFIDENTIAL PROPRIETARY
10162 +//*
10163 +//* (c) Copyright April 1999, Texas Instruments Incorporated.
10164 +//* All Rights Reserved.
10165 +//*
10166 +//* Property of Texas Instruments Incorporated and Amati Communications Corp.
10167 +//*
10168 +//* Restricted Rights - Use, duplication, or disclosure is subject to
10169 +//* restrictions set forth in TI's and Amati program license agreement and
10170 +//* associated documentation
10171 +//*
10172 +//*********************************************************************
10173 +//*
10174 +//* FILENAME: dev_host_verdef.h
10175 +//*
10176 +//* ABSTRACT: This file defines the version structure
10177 +//*
10178 +//* TARGET: Non specific.
10179 +//*
10180 +//* TOOLSET: Non specific.
10181 +//*
10182 +//* ACTIVATION:
10183 +//*
10184 +//* HISTORY: DATE AUTHOR DESCRIPTION
10185 +//* 04/29/99 FLW Created
10186 +//* 01/17/00 Barnett Mod's in support of merging NIC
10187 +//* hardware rev 6/7 T1.413 codebases.
10188 +//* 01/21/00 Wagner derfmake mods
10189 +//* 05/11/00 Barnett hardware_rev is a 2 char string.
10190 +//* 07/24/00 Barnett Rework as part of host interface redesign.
10191 +//* 11/29/00 Hunt added chipset_id2
10192 +//* 03/30/01 Barnett Prefixed all public elements with DSPDP_.
10193 +//* This insures uniqueness of names that might
10194 +//* match host names by coincidence.
10195 +//* 03/30/01 Barnett Added DSPDP_Host_VersionDef to facilitate
10196 +//* representing a version id for the host i/f
10197 +//* separate from the firmware version id as
10198 +//* a courtesy to the host.
10199 +//* 07/23/01 JEB Changed name from verdef_u.h to dpsys_verdef.h
10200 +//* 04/12/02 Barnett Make timestamp unsigned 32-bit field.
10201 +//* Generalizes for all kinds of hosts.
10202 +//* 11/15/02 JEB Changed name from dpsys_verdef.h to dev_host_verdef.h
10203 +//* Updated structs according to coding guidelines
10204 +//* 12/16/02 JEB Renamed some struct elements for new usage in Ax7
10205 +//* 01/21/03 MCB Implemented Ax7 UNIT-MODULE modular software framework.
10206 +//* 03/19/03 JEB Added back in "bugFix" elements into each struct type.
10207 +//* Rearranged elements.
10208 +//*
10209 +//********************************************************************
10210 +
10211 +#include "env_def_typedefs.h"
10212 +
10213 +#define DSPDP_FLAVOR_NEWCODES 0xFF // Other values are valid old-style flavors
10214 +
10215 +// ------------------------------
10216 +// ------------------------------
10217 +// Begin DSP version definitions.
10218 +// ------------------------------
10219 +// ------------------------------
10220 +
10221 +typedef struct
10222 +{
10223 + UINT32 timestamp; // Number of seconds since 01/01/1970
10224 + UINT8 major; // Major "00".00.00.00 revision nomenclature
10225 + UINT8 minor; // Minor 00."00".00.00 revision nomenclature
10226 + UINT8 bugFix; // Bug Fix 00.00."00".00 revision nomenclature
10227 + UINT8 buildNum; // Build Number 00.00.00."00" revision nomenclature
10228 + UINT8 netService; // Network service identifier
10229 + UINT8 chipsetGen; // chipset generation
10230 + UINT8 chipsetId; // chipset identifier
10231 + UINT8 chipsetId2; // second byte for "RV" chipset et al.
10232 + UINT8 hardwareRev1; // hardware revision, 1st char
10233 + UINT8 hardwareRev2; // hardware revision, 2nd char
10234 + UINT8 featureCode; // feature code
10235 + UINT8 dummy1; // dummy byte for explicit 32-bit alignment
10236 +} DEV_HOST_dspVersionDef_t;
10237 +
10238 +// -------------------------------
10239 +// -------------------------------
10240 +// Begin host version definitions.
10241 +// -------------------------------
10242 +// -------------------------------
10243 +
10244 +typedef struct
10245 +{
10246 + UINT8 major; // Major "00".00.00.00 revision nomenclature
10247 + UINT8 minor; // Minor 00."00".00.00 revision nomenclature
10248 + UINT8 bugFix; // Bug Fix 00.00."00".00 revision nomenclature
10249 + UINT8 buildNum; // Build Number 00.00.00."00" revision nomenclature
10250 + UINT8 netService; // Network service identifier
10251 + UINT8 dummy[3]; // dummy bytes for explicit 32-bit alignment
10252 +} DEV_HOST_hostIntfcVersionDef_t;
10253 +
10254 +
10255 +#endif // __DEV_HOST_VERDEF_H__
10256 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_api.c linux.dev/drivers/atm/sangam_atm/dsl_hal_api.c
10257 --- linux.old/drivers/atm/sangam_atm/dsl_hal_api.c 1970-01-01 01:00:00.000000000 +0100
10258 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_api.c 2005-08-23 04:46:50.095844000 +0200
10259 @@ -0,0 +1,3339 @@
10260 +/*******************************************************************************
10261 +* FILE PURPOSE: DSL Driver API functions for Sangam
10262 +*
10263 +********************************************************************************
10264 +* FILE NAME: dsl_hal_basicapi.c
10265 +*
10266 +* DESCRIPTION:
10267 +* Contains basic DSL HAL APIs for Sangam
10268 +*
10269 +*
10270 +* (C) Copyright 2001-02, Texas Instruments, Inc.
10271 +* History
10272 +* Date Version Notes
10273 +* 06Feb03 0.00.00 RamP Original Version Created
10274 +* 10Mar03 0.00.01 RamP Initial Revision for Modular Code Branch
10275 +* 19Mar03 0.00.02 RamP Fixed DSL and DSP Version API Structures
10276 +* 20Mar03 0.00.03 RamP Changed byteswap function names
10277 +* 21Mar03 0.00.03 RamP/ZT Malloc for DSP f/w done in dslStartup
10278 +* 25Mar03 0.00.04 RamP Removed statistics used only by SWTC
10279 +* Created Checkpoint 3
10280 +* 26Mar03 0.00.05 RamP Added Memory allocation for fwimage in
10281 +* dslStartup function.
10282 +* 07Apr03 0.00.06 RamP Implemented new error reporting scheme
10283 +* Changed Commenting to C style only
10284 +* 09Apr03 0.00.07 RamP Reorganized code to delete POST_SILICON
10285 +* 10Apr03 0.00.08 RamP Removed ptidsl from loadFWImage function
10286 +* moved size and fwimage initialization to
10287 +* dslStartup function
10288 +* 14Apr03 0.00.09 RamP Moved modemStateBitField processing to a
10289 +* support function; deleted stateHistory
10290 +* renamed the REG32 macro
10291 +* 15Apr03 0.00.10 RamP Changed firmware allocate to shim_
10292 +* osAllocateVMemory function
10293 +* 15Apr03 0.00.11 RamP Changed host version number to 07.00.00.01
10294 +* 16Apr03 0.00.12 RamP Modified return condition on dslShutdown
10295 +* 16Apr03 0.00.13 RamP Changed host version number to 07.00.00.02
10296 +* 21Apr03 0.01.00 RamP Cleaned up dslShutdown function
10297 +* Added new function calls to allocate
10298 +* (Alpha) /free overlay pages for different OS
10299 +* Fixed typecasting for allocate/free fxns
10300 +* Added Interrupt Acknowledge logic
10301 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt into api
10302 +* Added static global for intr source
10303 +* 24Apr03 0.01.02 RamP Added processing for OVERLAY_END in
10304 +* DSP message handlers, verified crc32
10305 +* recovery for overlays
10306 +* 28Apr03 0.01.03 RamP Removed global variable intrSource
10307 +* Added parameter to handleInterrupt fxn
10308 +* (Alpha Plus) to indicate interrupt source
10309 +* Changed version number to 01.00.01.00
10310 +* Fixed setTrainingMode function problem
10311 +* 07May03 0.01.04 RamP Removed delineation state check in
10312 +* message handling functions, added more
10313 +* safety for setting lConnected in TC_SYNC
10314 +* Changed version number to 01.00.01.01
10315 +* 14May03 0.01.05 RamP Added 3 Switchable Hybrid APIs
10316 +* Added additional statistics us/ds TxPower,
10317 +* us margin,attenuation, us/ds bitallocation
10318 +* moved versioning to dsl_hal_version.h
10319 +* 14May03 0.01.06 RamP Fixed problem with CMsgs2 parsing
10320 +* 20May03 0.01.07 RamP Added Inner/Outer pair API support. Added
10321 +* dying gasp message.
10322 +* 29May03 0.01.08 ZT/RamP Added memory optimizations for overlay pages
10323 +* and coProfiles; added functions to free,
10324 +* reload overlays and profiles
10325 +* 04Jun03 0.01.09 RamP Added tick counters, fail states reporting
10326 +* Made statistics fixes for higher data rates
10327 +* Added Margin per tone to statistics
10328 +* Added configuration checks for trellis/FEC
10329 +* 06Jun03 0.01.10 RamP Added LED, STM Bert, dGasp LPR Config APIs
10330 +* Modified interrupt acknowledge logic
10331 +* Added current hybrid flag as statistic
10332 +* 09Jun03 0.01.11 RamP Added function to send dying Gasp to Modem
10333 +* fixed problem with reading OamNegoPara var
10334 +* (Beta) fixed problem with reading current config
10335 +* Added function to configure ATM Bert
10336 +* fixed memory leak due to coProfiles
10337 +* Added us/ds R/S FEC statistics
10338 +* Added additional config capability for LED
10339 +* fixed problem in free memory for CO profiles
10340 +* 18Jul03 0.01.12 RamP Fixed problem with reading modemEnv structure
10341 +* affects LED, DGaspLpr APIs
10342 +* Sending Dying Gasp from shutdown function
10343 +* 01Aug03 0.01.13 RamP Added preferred training mode to statistics
10344 +* 13Aug03 0.01.14 MCB Set rev id for D3/R1.1 (ADSL2).
10345 +* 21Aug03 0.01.15 RamP Added g.hs and aoc bitswap message gathering
10346 +* Added new references to bits n gains table
10347 +* Decoupled modem idle/retrain from pair select
10348 +* Added line length and gross gain to statistics
10349 +* 29Sep03 0.01.16 RamP Replaced advcfg function calls with support
10350 +* module function switches
10351 +* 01Oct03 0.01.17 RamP Added enum translation to set training mode
10352 +* & to read statistics
10353 +* 08Oct03 0.01.18 RamP Fixed problems with usTxPower statistic in
10354 +* Annex B target, fixed problem with Trellis
10355 +* 12Oct03 0.01.19 RamP Added API calls to gather ADSL2 Messages
10356 +* 29Oct03 0.01.20 RamP Restored TC_SYNC detect logic
10357 +* 30Oct03 0.01.21 RamP Removed Scaling factor for adsl2DSConRate
10358 +* Setting Showtime state upon DSP_ACTIVE
10359 +* 14Nov03 0.01.22 RamP Fixed scaling for usTxPower & dsTxPower
10360 +* 14Nov03 0.01.23 RamP Added logic to gather CRates1/RRates1
10361 +* by parsing DSP_CRATES1
10362 +* 20Nov03 0.01.24 RamP Added generic & interface Read
10363 +* and Write functions to read from
10364 +* DSP - Host Interface
10365 +* 24Nov03 0.01.25 RamP Modified interface Read/Write functions
10366 +* to seperate element offsets from pointers
10367 +* 19Dec03 0.01.26 RamP Modified pointer accessing problems with
10368 +* block read functions
10369 +* 26Dec03 0.01.27 RamP Made ghsIndex a local variable & added
10370 +* check to avoid buffer overflow
10371 +* 30Dec03 0.01.28 RamP Added generic mailbox command function
10372 +*******************************************************************************/
10373 +#include "dsl_hal_register.h"
10374 +#include "dsl_hal_support.h"
10375 +#include "dsl_hal_logtable.h"
10376 +#include "dsl_hal_version.h"
10377 +
10378 +static unsigned int hybrid_selected;
10379 +static unsigned int showtimeFlag = FALSE;
10380 +
10381 +#ifdef PRE_SILICON
10382 +/*********************************************/
10383 +/* Base Addresses */
10384 +/*********************************************/
10385 +#define DEV_MDMA_BASE 0x02000500
10386 +
10387 +/*********************************************/
10388 +/* MC DMA Control Registers in DSL */
10389 +/*********************************************/
10390 +
10391 +#define DEV_MDMA0_SRC_ADDR (DEV_MDMA_BASE + 0x00000000)
10392 +#define DEV_MDMA0_DST_ADDR (DEV_MDMA_BASE + 0x00000004)
10393 +#define DEV_MDMA0_CTL_ADDR (DEV_MDMA_BASE + 0x00000008)
10394 +#define DEV_MDMA1_SRC_ADDR (DEV_MDMA_BASE + 0x00000040)
10395 +#define DEV_MDMA1_DST_ADDR (DEV_MDMA_BASE + 0x00000044)
10396 +#define DEV_MDMA1_CTL_ADDR (DEV_MDMA_BASE + 0x00000048)
10397 +#define DEV_MDMA2_SRC_ADDR (DEV_MDMA_BASE + 0x00000080)
10398 +#define DEV_MDMA2_DST_ADDR (DEV_MDMA_BASE + 0x00000084)
10399 +#define DEV_MDMA2_CTL_ADDR (DEV_MDMA_BASE + 0x00000088)
10400 +#define DEV_MDMA3_SRC_ADDR (DEV_MDMA_BASE + 0x000000C0)
10401 +#define DEV_MDMA3_DST_ADDR (DEV_MDMA_BASE + 0x000000C4)
10402 +#define DEV_MDMA3_CTL_ADDR (DEV_MDMA_BASE + 0x000000C8)
10403 +
10404 +#define DEV_MDMA0_SRC (*((volatile UINT32 *) DEV_MDMA0_SRC_ADDR))
10405 +#define DEV_MDMA0_DST (*((volatile UINT32 *) DEV_MDMA0_DST_ADDR))
10406 +#define DEV_MDMA0_CTL (*((volatile UINT32 *) DEV_MDMA0_CTL_ADDR))
10407 +#define DEV_MDMA1_SRC (*((volatile UINT32 *) DEV_MDMA1_SRC_ADDR))
10408 +#define DEV_MDMA1_DST (*((volatile UINT32 *) DEV_MDMA1_DST_ADDR))
10409 +#define DEV_MDMA1_CTL (*((volatile UINT32 *) DEV_MDMA1_CTL_ADDR))
10410 +#define DEV_MDMA2_SRC (*((volatile UINT32 *) DEV_MDMA2_SRC_ADDR))
10411 +#define DEV_MDMA2_DST (*((volatile UINT32 *) DEV_MDMA2_DST_ADDR))
10412 +#define DEV_MDMA2_CTL (*((volatile UINT32 *) DEV_MDMA2_CTL_ADDR))
10413 +#define DEV_MDMA3_SRC (*((volatile UINT32 *) DEV_MDMA3_SRC_ADDR))
10414 +#define DEV_MDMA3_DST (*((volatile UINT32 *) DEV_MDMA3_DST_ADDR))
10415 +#define DEV_MDMA3_CTL (*((volatile UINT32 *) DEV_MDMA3_CTL_ADDR))
10416 +
10417 +/* MDMA control bits */
10418 +
10419 +#define DEV_MDMA_START 0x80000000
10420 +#define DEV_MDMA_STOP 0x00000000
10421 +#define DEV_MDMA_STATUS 0x40000000
10422 +#define DEV_MDMA_DST_INC 0x00000000
10423 +#define DEV_MDMA_DST_FIX 0x02000000
10424 +#define DEV_MDMA_SRC_INC 0x00000000
10425 +#define DEV_MDMA_SRC_FIX 0x00800000
10426 +#define DEV_MDMA_BURST1 0x00000000
10427 +#define DEV_MDMA_BURST2 0x00100000
10428 +#define DEV_MDMA_BURST4 0x00200000
10429 +
10430 +#define DEV_MDMA_LEN_SHF 2
10431 +#define DEV_MDMA_LEN_MASK 0x0000FFFF
10432 +
10433 +#define DMA0 0
10434 +#define DMA1 1
10435 +#define DMA2 2
10436 +#define DMA3 3
10437 +#endif
10438 +#ifdef DMA
10439 +SINT32 getDmaStatus(UINT32 mask)
10440 +{
10441 + if(!(IFR & mask))
10442 + {
10443 + return DSLHAL_ERROR_NO_ERRORS;
10444 + }
10445 + else
10446 + {
10447 + ICR = mask ;
10448 + return 1 ;
10449 + }
10450 +}
10451 +
10452 +void programMdma(UINT32 dma, UINT32 source, UINT32 destination, UINT32 length, UINT32 wait)
10453 +{
10454 + volatile UINT32 statusMask ;
10455 +
10456 + switch(dma)
10457 + {
10458 + case DMA0:
10459 + {
10460 + DEV_MDMA0_SRC = source ;
10461 + DEV_MDMA0_DST = destination ;
10462 + DEV_MDMA0_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10463 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10464 + statusMask = 0x00000010 ;
10465 + }
10466 + break ;
10467 + case DMA1:
10468 + {
10469 + DEV_MDMA1_SRC = source ;
10470 + DEV_MDMA1_DST = destination ;
10471 + DEV_MDMA1_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10472 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10473 + statusMask = 0x00000020 ;
10474 + }
10475 + break ;
10476 + case DMA2:
10477 + {
10478 + DEV_MDMA2_SRC = source ;
10479 + DEV_MDMA2_DST = destination ;
10480 + DEV_MDMA2_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10481 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10482 + statusMask = 0x00000040 ;
10483 + }
10484 + break ;
10485 + case DMA3:
10486 + {
10487 + DEV_MDMA3_SRC = source ;
10488 + DEV_MDMA3_DST = destination ;
10489 + DEV_MDMA3_CTL = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
10490 + DEV_MDMA_BURST1 | (length << DEV_MDMA_LEN_SHF)) ;
10491 + statusMask = 0x00000080 ;
10492 + }
10493 + break ;
10494 +
10495 + }
10496 +
10497 + if(wait)
10498 + {
10499 + while(!(getDmaStatus(statusMask))) ;
10500 + }
10501 +
10502 +}
10503 +#endif
10504 +
10505 +
10506 +
10507 +/******************************************************************************************
10508 +* FUNCTION NAME: dslhal_api_dslStartup
10509 +*
10510 +*******************************************************************************************
10511 +* DESCRIPTION: Entry point to initialize and load ax5 daughter board
10512 +*
10513 +* INPUT: PITIDSLHW_T *ppIHw
10514 +*
10515 +* RETURN: 0 --succeeded
10516 +* 1 --Failed
10517 +*
10518 +*****************************************************************************************/
10519 +
10520 +int dslhal_api_dslStartup(PITIDSLHW_T *ppIHw)
10521 +{
10522 +
10523 + ITIDSLHW_T *ptidsl;
10524 + int i;
10525 + int rc;
10526 + dprintf(4,"dslhal_api_dslStartup() NEW 1\n");
10527 +
10528 + ptidsl=(ITIDSLHW_T *)shim_osAllocateMemory(sizeof(ITIDSLHW_T));
10529 + if(ptidsl==NULL)
10530 + {
10531 + dprintf(1, "unable to allocate memory for ptidsl\n");
10532 + return 1;
10533 + }
10534 + *ppIHw=ptidsl;
10535 + shim_osZeroMemory((char *) ptidsl, sizeof(ITIDSLHW_T));
10536 +
10537 + /* Unreset the ADSL Subsystem */
10538 + rc=dslhal_support_unresetDslSubsystem();
10539 + if(rc)
10540 + {
10541 + dprintf(1, "unable to reset ADSL Subsystem \n");
10542 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10543 + return DSLHAL_ERROR_UNRESET_ADSLSS;
10544 + }
10545 + ptidsl->fwimage = shim_osAllocateVMemory(DSP_FIRMWARE_MALLOC_SIZE);
10546 + if(!ptidsl->fwimage)
10547 + {
10548 + dprintf(1,"Failed to Allocate Memory for DSP firmware binary \n");
10549 + return DSLHAL_ERROR_FIRMWARE_MALLOC;
10550 + }
10551 + /* read firmware file from flash */
10552 + rc=shim_osLoadFWImage(ptidsl->fwimage);
10553 + if(rc<0)
10554 + {
10555 + dprintf(1, "unable to get fw image\n");
10556 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10557 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10558 + return DSLHAL_ERROR_NO_FIRMWARE_IMAGE;
10559 + }
10560 + else
10561 + {
10562 + ptidsl->imagesize = rc;
10563 + }
10564 + /* Compute the CRC checksum on the image and validate the image */
10565 +
10566 + /* Validate the image in the RAM */
10567 +
10568 + /* load fw to DSP */
10569 +
10570 + if(dslhal_support_hostDspCodeDownload(ptidsl))
10571 + {
10572 + dprintf(0,"dsp load error\n");
10573 + for(i=0; i<NUM_PAGES; i++)
10574 + {
10575 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10576 + {
10577 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10578 + ptidsl->olayDpPage[i].OverlayXferCount);
10579 + }
10580 + }
10581 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10582 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10583 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10584 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10585 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10586 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10587 + return DSLHAL_ERROR_CODE_DOWNLOAD;
10588 + }
10589 +
10590 + /* set flag to indicated overlay pages are loaded */
10591 + ptidsl->bOverlayPageLoaded = 1;
10592 + /* set auto retrain to 1 to disble the overlay page reload */
10593 + ptidsl->bAutoRetrain = 1;
10594 +
10595 + /* unreset Raptor */
10596 + /* change this to new function */
10597 + /* This function should basically bring DSP out of reset bit 23 of PRCR */
10598 + /* Function is ready but bypassed for Pre-Silicon */
10599 +
10600 + rc=dslhal_support_unresetDsp();
10601 + if (rc)
10602 + {
10603 + dprintf(0,"unable to bring DSP out of Reset\n");
10604 + for(i=0; i<NUM_PAGES; i++)
10605 + {
10606 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10607 + {
10608 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10609 + ptidsl->olayDpPage[i].OverlayXferCount);
10610 + }
10611 + }
10612 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10613 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10614 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10615 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10616 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10617 + shim_osFreeMemory((void *) ptidsl, sizeof(ITIDSLHW_T));
10618 + return DSLHAL_ERROR_UNRESET_DSP;
10619 + }
10620 + shim_osFreeVMemory((void *)ptidsl->fwimage,DSP_FIRMWARE_MALLOC_SIZE);
10621 + dprintf(4,"dslhal_api_dslStartup() done\n");
10622 +
10623 + /* Add the code to initialize the host interface variables */
10624 + /* Add code to tickle the host interface */
10625 + return DSLHAL_ERROR_NO_ERRORS;
10626 +}
10627 +
10628 +
10629 +/******************************************************************************************
10630 + * FUNCTION NAME: dslhal_api_dslShutdown
10631 + *
10632 + *******************************************************************************************
10633 + * DESCRIPTION: routine to shutdown ax5 modem and free the resource
10634 + *
10635 + * INPUT: tidsl_t *ptidsl
10636 + *
10637 + * RETURN: NULL
10638 + *
10639 + *
10640 + *****************************************************************************************/
10641 +
10642 +int dslhal_api_dslShutdown(tidsl_t *ptidsl)
10643 +{
10644 + int rc= DSLHAL_ERROR_NO_ERRORS;
10645 + int i;
10646 +
10647 + dprintf(5, "dslhal_api_dslShutdown\n");
10648 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DSLSS_SHUTDOWN, 0, 0, 0);
10649 + if(rc)
10650 + {
10651 + dprintf(1, " unable to reset DSP \n");
10652 + rc = DSLHAL_ERROR_RESET_DSP;
10653 + }
10654 + /* DSP need 50 ms to send out the message*/
10655 +
10656 + shim_osClockWait(60 * 1000);
10657 +
10658 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DGASP, 0, 0, 0);
10659 +
10660 + /* free memory allocated*/
10661 +
10662 + for(i=0; i<NUM_PAGES; i++)
10663 + {
10664 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
10665 + {
10666 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
10667 + ptidsl->olayDpPage[i].OverlayXferCount);
10668 + }
10669 + }
10670 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
10671 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
10672 + if(ptidsl->constDisplay.PmemStartWtAddr != NULL)
10673 + shim_osFreeDmaMemory((void *)ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.OverlayXferCount);
10674 + shim_osFreeMemory((void *)ptidsl, sizeof(tidsl_t));
10675 + rc = dslhal_support_resetDsp();
10676 + if(rc)
10677 + {
10678 + dprintf(1, " unable to reset ADSL subsystem \n");
10679 + rc = DSLHAL_ERROR_RESET_DSP;
10680 + }
10681 + rc = dslhal_support_resetDslSubsystem();
10682 + if(rc)
10683 + {
10684 + dprintf(1, " unable to reset ADSL subsystem \n");
10685 + rc = DSLHAL_ERROR_RESET_ADSLSS;
10686 + }
10687 +return rc;
10688 +}
10689 +
10690 +
10691 +/******************************************************************************************
10692 +* FUNCTION NAME: dslhal_api_getDslHalVersion
10693 +*
10694 +*******************************************************************************************
10695 +* DESCRIPTION: This routine supply DSL Driver version.
10696 +*
10697 +* INPUT: tidsl_t * ptidsl
10698 +* void *pVer, DSP Driver Version Pointer
10699 +*
10700 +* RETURN: 0 --succeeded
10701 +* 1 --Failed
10702 +* Note: See verdef_u.h for version structure definition.
10703 +*****************************************************************************************/
10704 +
10705 +void dslhal_api_getDslHalVersion(void *pVer)
10706 +{
10707 + dslVer *pVersion;
10708 + pVersion = (dslVer *)pVer;
10709 + pVersion->major = (unsigned char) DSLHAL_VERSION_MAJOR;
10710 + pVersion->minor = (unsigned char) DSLHAL_VERSION_MINOR;
10711 + pVersion->bugfix = (unsigned char) DSLHAL_VERSION_BUGFIX;
10712 + pVersion->buildNum = (unsigned char) DSLHAL_VERSION_BUILDNUM;
10713 + pVersion->timeStamp = (unsigned char) DSLHAL_VERSION_TIMESTAMP;
10714 +}
10715 +
10716 +/********************************************************************************************
10717 + * FUNCTION NAME: dslhal_api_pollTrainingStatus()
10718 + *
10719 + *********************************************************************************************
10720 + * DESCRIPTION: code to decode modem status and to start modem training
10721 + * Input: tidsl_t *ptidsl
10722 + *
10723 + * Return: modem status
10724 + * -1 failed
10725 + *
10726 + ********************************************************************************************/
10727 +
10728 +int dslhal_api_pollTrainingStatus(tidsl_t *ptidsl)
10729 +{
10730 + int cmd;
10731 + int tag;
10732 + int parm1,parm2;
10733 + int rc;
10734 + unsigned int failState;
10735 + static unsigned int pollGhsIndex=0;
10736 +
10737 + /*char *tmp;*/
10738 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
10739 +#if SWTC
10740 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
10741 +#endif
10742 +
10743 + dprintf(5,"dslhal_api_pollTrainingStatus\n");
10744 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
10745 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
10746 + sizeof(DEV_HOST_dspOamSharedInterface_t));
10747 + if (rc)
10748 + {
10749 + dprintf(1,"dslhal_support_blockRead failed\n");
10750 + return DSLHAL_ERROR_BLOCK_READ;
10751 + }
10752 +#if SWTC
10753 + dspOamSharedInterface.tcHostComm_p =(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
10754 +
10755 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
10756 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
10757 + if (rc)
10758 + {
10759 + dprintf(1,"dslhal_support_blockRead failed\n");
10760 + return DSLHAL_ERROR_BLOCK_READ;
10761 + }
10762 +#endif
10763 +
10764 + rc = dslhal_support_processTrainingState(ptidsl);
10765 + if(rc)
10766 + {
10767 + dprintf(0,"Error Reading Modem Training State \n");
10768 + return DSLHAL_ERROR_MODEMSTATE;
10769 + }
10770 + rc = dslhal_support_processModemStateBitField(ptidsl);
10771 + if(rc)
10772 + {
10773 + dprintf(0,"Error Reading Modem Training State \n");
10774 + return DSLHAL_ERROR_MODEMSTATE;
10775 + }
10776 + /*
10777 + rc = dslhal_support_readDelineationState(ptidsl);
10778 + if(rc)
10779 + {
10780 + dprintf(0,"Error Reading Delineation State \n");
10781 + return DSLHAL_ERROR_MODEMSTATE;
10782 + }
10783 + */
10784 + while (dslhal_support_readDspMailbox(ptidsl,&cmd, &tag, &parm1, &parm2) == DSLHAL_ERROR_NO_ERRORS )
10785 + {
10786 + dprintf(4,"mailbox message: 0x%x\n", cmd);
10787 + /*
10788 + for(rc=0;rc<8;rc++)
10789 + {
10790 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
10791 + }
10792 + */
10793 +
10794 + if (cmd == DSP_IDLE)
10795 + {
10796 + dprintf(4,"DSP_IDLE\n");
10797 + ptidsl->lConnected=0;
10798 + hybrid_selected=888;
10799 + /* add code for reload overlay pages */
10800 + if(ptidsl->bAutoRetrain == 0)
10801 + {
10802 + while(ptidsl->bOverlayPageLoaded == 0)
10803 + {
10804 + shim_osClockWait(6400);
10805 + }
10806 + //dslhal_support_restoreTrainingInfo(ptidsl);
10807 + //ptidsl->bOverlayPageLoaded = 1;
10808 + }
10809 + /* command DSP to ACTREQ */
10810 + if(showtimeFlag == TRUE)
10811 + {
10812 + dslhal_api_resetTrainFailureLog(ptidsl);
10813 + dslhal_support_advancedIdleProcessing(ptidsl);
10814 + showtimeFlag = FALSE;
10815 + }
10816 + failState = (unsigned int)parm1;
10817 + if(failState!=0)
10818 + {
10819 + ptidsl->AppData.trainFailStates[ptidsl->AppData.trainFails]=failState;
10820 + ptidsl->AppData.trainFails++;
10821 + if(ptidsl->AppData.trainFails > 30)
10822 + ptidsl->AppData.trainFails=0;
10823 + }
10824 + for(pollGhsIndex=0;pollGhsIndex<10;pollGhsIndex++)
10825 + {
10826 + for(rc=0;rc<62;rc++)
10827 + ptidsl->AppData.dsl_ghsRxBuf[pollGhsIndex][rc]=0;
10828 + }
10829 + pollGhsIndex=0;
10830 + rc = dslhal_support_writeHostMailbox(ptidsl,HOST_ACTREQ, 0, 0, 0);
10831 + if (rc)
10832 + return DSLHAL_ERROR_MAILBOX_WRITE;
10833 + }
10834 +
10835 + if(cmd == DSP_ATM_TC_SYNC)
10836 + {
10837 + dprintf(4,"\nTC_SYNC\n");
10838 + showtimeFlag = TRUE;
10839 + ptidsl->lConnected=1;
10840 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 1)
10841 + {
10842 + dslhal_support_clearTrainingInfo(ptidsl);
10843 + ptidsl->bOverlayPageLoaded = 0;
10844 + }
10845 + }
10846 + if(cmd == DSP_ACTIVE)
10847 + {
10848 + dprintf(4,"DSP_ACTIVE");
10849 + ptidsl->lConnected=0;
10850 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
10851 + dprintf(4,"US Connect Rate: %u \n",ptidsl->AppData.USConRate);
10852 + dprintf(4,"DS Connect Rate: %u \n",ptidsl->AppData.DSConRate);
10853 + }
10854 + if(cmd == DSP_ATM_NO_TC_SYNC)
10855 + {
10856 + dprintf(4,"\nTC_NOSYNC\n");
10857 + ptidsl->lConnected=0;
10858 + }
10859 + if(cmd == DSP_DGASP)
10860 + {
10861 + dprintf(0,"\n GASP!!! \n");
10862 + }
10863 + if(cmd == DSP_OVERLAY_END)
10864 + {
10865 + dprintf(4,"Overlay Page Done %d \n",tag);
10866 + rc = dslhal_support_checkOverlayPage(ptidsl,tag);
10867 + if(rc == DSLHAL_ERROR_OVERLAY_CORRUPTED)
10868 + {
10869 + dprintf(0,"Overlay Page: %d CORRUPTED \n",tag);
10870 + return (0-DSLHAL_ERROR_OVERLAY_CORRUPTED);
10871 + }
10872 + }
10873 + if(cmd == DSP_HYBRID)
10874 + {
10875 + dprintf(2,"Hybrid Metrics Available: %d\n",tag);
10876 + hybrid_selected = tag;
10877 + }
10878 + if(cmd == DSP_DGASP)
10879 + {
10880 + dprintf(0,"\n GASP!!! \n");
10881 + }
10882 + if(cmd == DSP_XMITBITSWAP)
10883 + {
10884 + dslhal_support_aocBitSwapProcessing(ptidsl,0);
10885 + }
10886 + if(cmd == DSP_RCVBITSWAP)
10887 + {
10888 + dslhal_support_aocBitSwapProcessing(ptidsl,1);
10889 + }
10890 + if(cmd == DSP_GHSMSG)
10891 + {
10892 + dprintf(3,"Ghs Message Received, bytes: %d \n",tag);
10893 + dprintf(3,"Addr: 0x%x\n",dspOamSharedInterface.ghsDspRxBuf_p);
10894 + if(pollGhsIndex > 9)
10895 + pollGhsIndex=0;
10896 + rc = dslhal_support_blockRead((void *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.ghsDspRxBuf_p), &ptidsl->AppData.dsl_ghsRxBuf[pollGhsIndex++][0], tag);
10897 + }
10898 + if(cmd == DSP_CRATES1)
10899 + {
10900 + dprintf(3,"DSP C-Rates1 Data Ready \n");
10901 + rc = dslhal_support_gatherRateMessages(ptidsl);
10902 + }
10903 + if(cmd == DSP_SNR)
10904 + {
10905 + dprintf(3,"DSP SNR Data Ready \n");
10906 + rc = dslhal_support_gatherSnrPerBin(ptidsl,tag);
10907 + }
10908 + if(cmd == DSP_EOC)
10909 + {
10910 + dprintf(3,"DSP_EOC message \n");
10911 + rc = dslhal_support_gatherEocMessages(ptidsl,tag,parm1,parm2);
10912 + }
10913 +
10914 + if(cmd == DSP_TRAINING_MSGS)
10915 + {
10916 + dprintf(3,"DSP_TRAINING_MSGS \n");
10917 + rc = dslhal_support_gatherAdsl2Messages(ptidsl,tag,parm1,parm2);
10918 + }
10919 + }
10920 + dprintf(6,"dslhal_api_pollTrainingStatus done\n");
10921 + return(ptidsl->AppData.bState);
10922 +
10923 +} /* end of dslhal_api_pollTrainingStatus() */
10924 +
10925 +/********************************************************************************************
10926 +* FUNCTION NAME: dslhal_api_handleTrainingInterrupt()
10927 +*
10928 +*********************************************************************************************
10929 +* DESCRIPTION: Code to handle ax5 hardware interrupts
10930 +*
10931 +* Input: tidsl_t *ptidsl
10932 +* int *pMsg, pointer to returned hardware messages. Each byte represent a messge
10933 +* int *pTag, pointer to returned hardware message tags. Each byte represent a tag.
10934 +* Return: 0 success
10935 +* 1 failed
10936 +*
10937 +********************************************************************************************/
10938 +int dslhal_api_handleTrainingInterrupt(tidsl_t *ptidsl, int intrSource)
10939 +{
10940 + int cmd;
10941 + int tag;
10942 + int parm1,parm2;
10943 + unsigned int msg1;
10944 + unsigned int msg2;
10945 + int rc;
10946 + unsigned int failState;
10947 + static unsigned int interruptGhsIndex=0;
10948 + /*char *tmp;*/
10949 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
10950 +#if SWTC
10951 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
10952 +#endif
10953 + dprintf(6,"dslhal_api_handleTrainingInterrupt\n");
10954 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
10955 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
10956 + sizeof(DEV_HOST_dspOamSharedInterface_t));
10957 + if (rc)
10958 + {
10959 + dprintf(1,"dslhal_support_blockRead failed\n");
10960 + return DSLHAL_ERROR_BLOCK_READ;
10961 + }
10962 +#if SWTC
10963 + dspOamSharedInterface.tcHostComm_p =(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
10964 +
10965 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
10966 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
10967 + if (rc)
10968 + {
10969 + dprintf(1,"dslhal_support_blockRead failed\n");
10970 + return DSLHAL_ERROR_BLOCK_READ;
10971 + }
10972 +#endif
10973 +
10974 + if(intrSource & MASK_BITFIELD_INTERRUPTS)
10975 + {
10976 + dspOamSharedInterface.modemStateBitField_p =(DEV_HOST_modemStateBitField_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStateBitField_p);
10977 + rc = dslhal_support_processTrainingState(ptidsl);
10978 + if(rc)
10979 + {
10980 + dprintf(0,"Error Reading Modem Training State \n");
10981 + return DSLHAL_ERROR_MODEMSTATE;
10982 + }
10983 + rc = dslhal_support_processModemStateBitField(ptidsl);
10984 + if(rc)
10985 + {
10986 + dprintf(0,"Error Reading Modem Training State \n");
10987 + return DSLHAL_ERROR_MODEMSTATE;
10988 + }
10989 + }
10990 + if(intrSource & MASK_MAILBOX_INTERRUPTS)
10991 + {
10992 + /*
10993 + rc = dslhal_support_readDelineationState(ptidsl);
10994 + if(rc)
10995 + {
10996 + dprintf(0,"Error Reading Delineation State \n");
10997 + return DSLHAL_ERROR_MODEMSTATE;
10998 + }
10999 + */
11000 + while (dslhal_support_readDspMailbox(ptidsl,&cmd, &tag, &parm1, &parm2) == DSLHAL_ERROR_NO_ERRORS )
11001 + {
11002 + dprintf(4,"mailbox message: 0x%x\n", cmd);
11003 + /*
11004 + for(rc=0;rc<8;rc++)
11005 + {
11006 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
11007 + }
11008 + */
11009 + if (cmd == DSP_IDLE)
11010 + {
11011 + dprintf(4,"DSP_IDLE\n");
11012 + ptidsl->lConnected=0;
11013 + hybrid_selected=888;
11014 + if(showtimeFlag == TRUE)
11015 + {
11016 + dslhal_api_resetTrainFailureLog(ptidsl);
11017 + dslhal_support_advancedIdleProcessing(ptidsl);
11018 + showtimeFlag = FALSE;
11019 + }
11020 + failState = (unsigned int)parm1;
11021 + if(failState!=0)
11022 + {
11023 + ptidsl->AppData.trainFailStates[ptidsl->AppData.trainFails]=failState;
11024 + ptidsl->AppData.trainFails++;
11025 + if(ptidsl->AppData.trainFails > 30)
11026 + ptidsl->AppData.trainFails=0;
11027 + }
11028 + for(interruptGhsIndex=0;interruptGhsIndex<10;interruptGhsIndex++)
11029 + {
11030 + for(rc=0;rc<62;rc++)
11031 + ptidsl->AppData.dsl_ghsRxBuf[interruptGhsIndex][rc]=0;
11032 + }
11033 + interruptGhsIndex=0;
11034 +
11035 + /* add code for reload overlay pages */
11036 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 0)
11037 + {
11038 + dslhal_support_restoreTrainingInfo(ptidsl);
11039 + ptidsl->bOverlayPageLoaded = 1;
11040 + }
11041 + /* command DSP to ACTREQ */
11042 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_ACTREQ, 0, 0, 0);
11043 + if (rc)
11044 + return DSLHAL_ERROR_MAILBOX_WRITE;
11045 + }
11046 + if(cmd == DSP_ATM_TC_SYNC)
11047 + {
11048 + dprintf(4,"\nTC_SYNC\n");
11049 + showtimeFlag = TRUE;
11050 + ptidsl->lConnected=1;
11051 + if(ptidsl->bAutoRetrain == 0 && ptidsl->bOverlayPageLoaded == 1)
11052 + {
11053 + dslhal_support_clearTrainingInfo(ptidsl);
11054 + ptidsl->bOverlayPageLoaded = 0;
11055 + }
11056 + }
11057 + if(cmd == DSP_ACTIVE)
11058 + {
11059 + ptidsl->lConnected=0;
11060 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
11061 + dprintf(4,"DSP_ACTIVE");
11062 + dprintf(4,"US Connect Rate: %u \n",ptidsl->AppData.USConRate);
11063 + dprintf(4,"DS Connect Rate: %u \n",ptidsl->AppData.DSConRate);
11064 + }
11065 + if(cmd == DSP_ATM_NO_TC_SYNC)
11066 + {
11067 + dprintf(4,"\nTC_NOSYNC\n");
11068 + ptidsl->lConnected=0;
11069 + /* add code for reload overlay pages */
11070 + }
11071 + if(cmd == DSP_OVERLAY_END)
11072 + {
11073 + dprintf(4,"Overlay Page Done %d \n",tag);
11074 + rc = dslhal_support_checkOverlayPage(ptidsl,tag);
11075 + if(rc == DSLHAL_ERROR_OVERLAY_CORRUPTED)
11076 + {
11077 + dprintf(4,"Overlay Page: %d CORRUPTED \n",tag);
11078 + return(0-DSLHAL_ERROR_OVERLAY_CORRUPTED);
11079 + }
11080 + }
11081 + if(cmd == DSP_HYBRID)
11082 + {
11083 + dprintf(2,"Hybrid Metrics Available\n");
11084 + hybrid_selected = tag;
11085 + }
11086 + if(cmd == DSP_XMITBITSWAP)
11087 + {
11088 + rc = dslhal_support_aocBitSwapProcessing(ptidsl,0);
11089 + }
11090 + if(cmd == DSP_RCVBITSWAP)
11091 + {
11092 + rc = dslhal_support_aocBitSwapProcessing(ptidsl,1);
11093 + }
11094 + if(cmd == DSP_GHSMSG)
11095 + {
11096 + dprintf(3,"Ghs Message Received, bytes: %d \n",tag);
11097 + dprintf(3,"Addr: 0x%x\n",dspOamSharedInterface.ghsDspRxBuf_p);
11098 + if(interruptGhsIndex > 9)
11099 + interruptGhsIndex=0;
11100 + rc = dslhal_support_blockRead((void *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.ghsDspRxBuf_p), &ptidsl->AppData.dsl_ghsRxBuf[interruptGhsIndex++][0], tag);
11101 + }
11102 + if(cmd == DSP_CRATES1)
11103 + {
11104 + dprintf(3,"DSP C-Rates1 Data Ready \n");
11105 + rc = dslhal_support_gatherRateMessages(ptidsl);
11106 + }
11107 + if(cmd == DSP_SNR)
11108 + {
11109 + dprintf(3,"DSP SNR Data Ready \n");
11110 + rc = dslhal_support_gatherSnrPerBin(ptidsl,tag);
11111 + }
11112 + if(cmd == DSP_EOC)
11113 + {
11114 + dprintf(3,"DSP_EOC message \n");
11115 + rc = dslhal_support_gatherEocMessages(ptidsl,tag,parm1,parm2);
11116 + }
11117 + if(cmd == DSP_TRAINING_MSGS)
11118 + {
11119 + dprintf(3,"DSP_TRAINING_MSGS \n");
11120 + rc = dslhal_support_gatherAdsl2Messages(ptidsl,tag,parm1,parm2);
11121 + }
11122 + }
11123 +
11124 + dslhal_support_readTextMailbox(ptidsl,&msg1, &msg2);
11125 + dprintf(5,"Text Message Part1: 0x%x \t Text Message Part2: 0x%x \n",msg1,msg2);
11126 + }
11127 + dprintf(6,"dslhal_api_handleTrainingInterrupt done\n");
11128 + return(ptidsl->AppData.bState);
11129 +} /* end of dslhal_api_handleTrainingInterrupt() */
11130 +
11131 +
11132 +
11133 +
11134 +/******************************************************************************************
11135 + * FUNCTION NAME: dslhal_api_dslRetrain(tidsl_t *ptidsl)
11136 + *
11137 + *******************************************************************************************
11138 + * DESCRIPTION: This fuction sends CMD_ACTREQ to the DSP to issue a retrain
11139 + *
11140 + * INPUT: PITIDSLHW_T *ptidsl
11141 + *
11142 + * RETURN: 0 SUCCESS
11143 + * 1 FAILED
11144 + *
11145 + *****************************************************************************************/
11146 +unsigned int dslhal_api_dslRetrain(tidsl_t *ptidsl)
11147 +{
11148 + int rc;
11149 +
11150 + dprintf(5, "dslhal_cfg_dslRetrain \n");
11151 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_QUIET, 0, 0, 0);
11152 + if(rc)
11153 + {
11154 + dprintf(1,"dslhal_cfg_dslRetrain failed\n");
11155 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11156 + }
11157 + return DSLHAL_ERROR_NO_ERRORS;
11158 +}
11159 +
11160 +/******************************************************************************************
11161 + * FUNCTION NAME: dslhal_api_sendQuiet(tidsl_t *ptidsl)
11162 + *
11163 + *******************************************************************************************
11164 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
11165 + *
11166 + * INPUT: PITIDSLHW_T *ptidsl
11167 + *
11168 + * RETURN: 0 SUCCESS
11169 + * 1 FAILED
11170 + *
11171 + *****************************************************************************************/
11172 +unsigned int dslhal_api_sendQuiet(tidsl_t *ptidsl)
11173 +{
11174 + int rc;
11175 +
11176 + dprintf(5, "dslhal_api_sendQuiet\n");
11177 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_QUIET, 0, 0, 0);
11178 + if(rc)
11179 + {
11180 + dprintf(1,"dslhal_api_sendQuiet failed\n");
11181 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11182 + }
11183 + return DSLHAL_ERROR_NO_ERRORS;
11184 +}
11185 +
11186 +/******************************************************************************************
11187 + * FUNCTION NAME: dslhal_api_sendIdle(tidsl_t *ptidsl)
11188 + *
11189 + *******************************************************************************************
11190 + * DESCRIPTION: This fuction sends the CMD_IDLE message to the DSP
11191 + *
11192 + * INPUT: PITIDSLHW_T *ptidsl
11193 + *
11194 + * RETURN: 0 SUCCESS
11195 + * 1 FAILED
11196 + *
11197 + *****************************************************************************************/
11198 +unsigned int dslhal_api_sendIdle(tidsl_t *ptidsl)
11199 +{
11200 + int rc;
11201 +
11202 + dprintf(5, "dslhal_api_sendIdle\n");
11203 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_IDLE, 0, 0, 0);
11204 + if(rc)
11205 + {
11206 + dprintf(1,"dslhal_api_sendIdle failed\n");
11207 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11208 + }
11209 + return DSLHAL_ERROR_NO_ERRORS;
11210 +}
11211 +
11212 +/******************************************************************************************
11213 + * FUNCTION NAME: dslhal_api_sendDgasp(tidsl_t *ptidsl)
11214 + *
11215 + *******************************************************************************************
11216 + * DESCRIPTION: This fuction sends the HOST_DGASP message to the DSP
11217 + *
11218 + * INPUT: PITIDSLHW_T *ptidsl
11219 + *
11220 + * RETURN: 0 SUCCESS
11221 + * 1 FAILED
11222 + *
11223 + *****************************************************************************************/
11224 +unsigned int dslhal_api_sendDgasp(tidsl_t *ptidsl)
11225 +{
11226 + int rc;
11227 +
11228 + dprintf(5, "dslhal_api_sendDgasp\n");
11229 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_DGASP, 0, 0, 0);
11230 + if(rc)
11231 + {
11232 + dprintf(1,"dslhal_api_sendDgasp failed\n");
11233 + return DSLHAL_ERROR_CTRL_API_FAILURE;
11234 + }
11235 + return DSLHAL_ERROR_NO_ERRORS;
11236 +}
11237 +
11238 +/******************************************************************************************
11239 +* FUNCTION NAME: dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
11240 +*
11241 +*******************************************************************************************
11242 +* DESCRIPTION: This fuction Sets the Desired Training Mode {None/Multimode/G.dmt/lite
11243 +*
11244 +* INPUT: PITIDSLHW_T *ptidsl
11245 +* unsigned int trainmode :Should be between 0 and 4; 0:No Mode 1:Multimode
11246 +* 2: T1.413, 3:G.dmt, 4: G.lite
11247 +* RETURN: 0 SUCCESS
11248 +* 1 FAILED
11249 +*
11250 +*****************************************************************************************/
11251 +unsigned int dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
11252 +{
11253 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
11254 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11255 + int rc;
11256 + dprintf(5," dslhal_api_setTrainingMode()\n");
11257 + if(trainmode>255)
11258 + {
11259 + dprintf(3,"Invalid Value for Desired Training Mode (must be <255)\n");
11260 + return DSLHAL_ERROR_INVALID_PARAM;
11261 + }
11262 +
11263 + if(!ptidsl)
11264 + {
11265 + dprintf(3, "Error: PTIDSL pointer invalid\n");
11266 + return DSLHAL_ERROR_INVALID_PARAM;
11267 + }
11268 +
11269 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11270 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
11271 + sizeof(DEV_HOST_dspOamSharedInterface_t));
11272 + if (rc)
11273 + {
11274 + dprintf(1,"dslhal_support_blockRead failed\n");
11275 + return DSLHAL_ERROR_BLOCK_READ;
11276 + }
11277 +
11278 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
11279 +
11280 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11281 + if (rc)
11282 + {
11283 + dprintf(1,"dslhal_support_blockRead failed\n");
11284 + return DSLHAL_ERROR_BLOCK_READ;
11285 + }
11286 + /* Enum Translation to maintain backwards compatibility for train modes */
11287 + if(trainmode == DSLTRAIN_MULTI_MODE)
11288 + trainmode = MULTI_MODE;
11289 + if(trainmode == DSLTRAIN_T1413_MODE)
11290 + trainmode = T1413_MODE;
11291 + if(trainmode == DSLTRAIN_GDMT_MODE)
11292 + trainmode = GDMT_MODE;
11293 +
11294 + NegoPara.stdMode = trainmode;
11295 + dprintf(5,"Train Mode: 0x%x\n",trainmode);
11296 + rc = dslhal_support_blockWrite(&NegoPara,(PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11297 + if(rc)
11298 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
11299 +
11300 + dprintf(5," dslhal_api_setTrainingMode() Done\n");
11301 + return DSLHAL_ERROR_NO_ERRORS;
11302 +}
11303 +
11304 +/******************************************************************************************
11305 +* FUNCTION NAME: dslhal_api_getDspVersion
11306 +*
11307 +*******************************************************************************************
11308 +* DESCRIPTION: This routine supply AX5 daugther card DSP version.
11309 +*
11310 +* INPUT: tidsl_t * ptidsl
11311 +* void *pVer, DSP version struct is returned starting at this pointer
11312 +*
11313 +* RETURN: 0 --succeeded
11314 +* 1 --Failed
11315 +* Note: See verdef_u.h for version structure definition.
11316 +*****************************************************************************************/
11317 +int dslhal_api_getDspVersion(tidsl_t *ptidsl, void *pVer)
11318 +{
11319 + /* DEV_HOST_dspVersionDef_t dspVersion; */
11320 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11321 + int rc;
11322 + dprintf(5, "dslhal_api_getDspVersion\n");
11323 + if(!ptidsl)
11324 + {
11325 + dprintf(3, "Error: PTIDSL pointer invalid\n");
11326 + return DSLHAL_ERROR_INVALID_PARAM;
11327 + }
11328 + if(!pVer)
11329 + return DSLHAL_ERROR_INVALID_PARAM;
11330 +
11331 + *(unsigned int *) pVer = 0;
11332 +
11333 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11334 +
11335 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
11336 + if (rc)
11337 + {
11338 + dprintf(1,"dslhal_support_blockRead failed\n");
11339 + return DSLHAL_ERROR_BLOCK_READ;
11340 + }
11341 +
11342 + dspOamSharedInterface.datapumpVersion_p = (DEV_HOST_dspVersionDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.datapumpVersion_p);
11343 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.datapumpVersion_p,
11344 + pVer, sizeof(dspVer));
11345 + if (rc)
11346 + {
11347 + dprintf(1,"dslhal_support_blockRead failed\n");
11348 + return DSLHAL_ERROR_BLOCK_READ;
11349 + }
11350 + pVer = (DEV_HOST_dspVersionDef_t *)(dslhal_support_byteSwap32((unsigned int)pVer));
11351 + return DSLHAL_ERROR_NO_ERRORS;
11352 +}
11353 +
11354 +/********************************************************************************************
11355 +* FUNCTION NAME: dslhal_api_gatherStatistics()
11356 +*
11357 +*********************************************************************************************
11358 +* DESCRIPTION: Read statistical infromation from ax5 modem daugter card.
11359 +* Input: tidsl_t *ptidsl
11360 +*
11361 +* Return: 0 success
11362 +* 1 failed
11363 +*
11364 +********************************************************************************************/
11365 +void dslhal_api_gatherStatistics(tidsl_t * ptidsl)
11366 +{
11367 + int rc,optIdxU,optIdxD,i;
11368 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11369 + DEV_HOST_dspWrNegoParaDef_t rateparms;
11370 + DEV_HOST_oamWrNegoParaDef_t configParms;
11371 + DEV_HOST_modemStatsDef_t StatisticsDef;
11372 + DEV_HOST_errorStats_t usIntlvError, usFastError, dsIntlvError, dsFastError;
11373 + DEV_HOST_atmStats_t atmStats;
11374 + DEV_HOST_usAtmStats_t usAtmStats0, usAtmStats1;
11375 + DEV_HOST_dsAtmStats_t dsAtmStats0,dsAtmStats1;
11376 + DEV_HOST_dspWrSuperFrameCntDef_t SuperFrameCnt;
11377 + DEV_HOST_msg_t atuc_msg, aturMsg;
11378 + DEV_HOST_eocVarDef_t eocVar;
11379 + DEV_HOST_dspWrSharedTables_t sharedTables;
11380 + DEV_HOST_phyPerf_t phyPerf;
11381 + unsigned char usBits[64],dsBits[256];
11382 + unsigned char dsPowerCutBack;
11383 + int usNumLoadedTones=0, dsNumLoadedTones=0;
11384 +
11385 + dprintf(5, "dslhal_api_gatherStatistics\n");
11386 +
11387 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
11388 +
11389 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
11390 + sizeof(DEV_HOST_dspOamSharedInterface_t));
11391 + if (rc)
11392 + {
11393 + dprintf(1,"dslhal_support_blockRead failed\n");
11394 + return;
11395 + }
11396 + if(!ptidsl->bStatisticsInitialized && ptidsl->lConnected == LINE_CONNECTED)
11397 + {
11398 + dslhal_api_initStatistics(ptidsl);
11399 + ptidsl->bStatisticsInitialized = TRUE;
11400 + }
11401 +
11402 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
11403 +
11404 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p,
11405 + &rateparms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
11406 +
11407 + if (rc)
11408 + {
11409 + dprintf(1,"dslhal_support_blockRead failed\n");
11410 + return;
11411 + }
11412 + if(!rc)
11413 + {
11414 + /* trained mode */
11415 + ptidsl->AppData.dsl_modulation = (unsigned int)rateparms.trainMode;
11416 + if(rateparms.trainMode == T1413_MODE)
11417 + ptidsl->AppData.dsl_modulation = DSLTRAIN_T1413_MODE;
11418 + if(rateparms.trainMode == GDMT_MODE)
11419 + ptidsl->AppData.dsl_modulation = DSLTRAIN_GDMT_MODE;
11420 + /* rate */
11421 + /* shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)rateparms.cRates1, 120); */
11422 + ptidsl->AppData.bCRates2 = rateparms.cRates2;
11423 + /* shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)rateparms.rRates1, 44); */
11424 + ptidsl->AppData.bRRates2 = rateparms.rRates2;
11425 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs1, (void *)rateparms.cMsgs1, 6);
11426 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs2, (void *)rateparms.cMsgs2, 4);
11427 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs2, (void *)rateparms.rMsgs2, 4);
11428 + ptidsl->AppData.atucVendorId = (unsigned int)rateparms.atucVendorId;
11429 + ptidsl->AppData.lineLength = (unsigned int)dslhal_support_byteSwap16((unsigned short)rateparms.lineLength);
11430 + ptidsl->AppData.atucRevisionNum = (unsigned int)rateparms.atucGhsRevisionNum;
11431 + ptidsl->AppData.usLineAttn = (ptidsl->AppData.bCMsgs2[3] >>2)&0x003f;
11432 + ptidsl->AppData.usMargin = (ptidsl->AppData.bCMsgs2[2])&0x001f;
11433 +
11434 + if((rateparms.cRates2 & 0x0f) == 0x01)
11435 + optIdxU = 0;
11436 + else if((rateparms.cRates2 & 0x0f) == 0x02)
11437 + optIdxU = 1;
11438 + else if((rateparms.cRates2 & 0x0f) == 0x04)
11439 + optIdxU = 2;
11440 + else if((rateparms.cRates2 & 0x0f) == 0x08)
11441 + optIdxU = 3;
11442 + else
11443 + optIdxU = -1;
11444 +
11445 + dprintf(5, "optIdxU=%d\n", optIdxU);
11446 +
11447 + /* Obtain the US Rates using Opt# and CRates1 Table */
11448 + /* Rate(US) = [Bf(LS0) + Bi(LS0)]*32 */
11449 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11450 + ptidsl->AppData.USConRate = ((rateparms.cRates1[optIdxU][CRATES1_BF_LS0] + rateparms.cRates1[optIdxU][CRATES1_BI_LS0]) * 32);
11451 + else
11452 + ptidsl->AppData.USConRate = 32 * dslhal_support_byteSwap16((unsigned short)rateparms.adsl2USRate);
11453 +
11454 + ptidsl->AppData.USPeakCellRate = ptidsl->AppData.USConRate;
11455 +
11456 + if(((rateparms.cRates2 >> 4) & 0x0f) == 0x01)
11457 + optIdxD = 0;
11458 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x02)
11459 + optIdxD = 1;
11460 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x04)
11461 + optIdxD = 2;
11462 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x08)
11463 + optIdxD = 3;
11464 + else
11465 + optIdxD = -1;
11466 + /* Obtain the DS Rates using Opt# and CRates1 Table */
11467 + /* Rate(DS) = [Bf(AS0) + Bi(AS0)]*32 */
11468 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11469 + ptidsl->AppData.DSConRate = (((rateparms.cRates1[optIdxD][CRATES1_BF_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BF_DSRS]&0x80)<<1))+ (rateparms.cRates1[optIdxD][CRATES1_BI_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BI_DSRS]&0x80)<<1)))* 32);
11470 + else
11471 + ptidsl->AppData.DSConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2DSRate);
11472 +
11473 + dprintf(5, "ptidsl->AppData.wDSConRate=%d\n", ptidsl->AppData.DSConRate);
11474 + /* Determine which Path has Modem Trained with */
11475 + if((rateparms.cRates1[optIdxU][CRATES1_BF_LS0]) && (rateparms.cRates1[optIdxD][CRATES1_BF_AS0]))
11476 + ptidsl->AppData.TrainedPath = FAST_PATH;
11477 + else
11478 + ptidsl->AppData.TrainedPath = INTERLEAVED_PATH;
11479 +
11480 + /* Set the mode in which the modem is trained */
11481 + ptidsl->AppData.TrainedMode = (unsigned int)rateparms.trainMode;
11482 + if(rateparms.trainMode == T1413_MODE)
11483 + ptidsl->AppData.TrainedMode = DSLTRAIN_T1413_MODE;
11484 + if(rateparms.trainMode == GDMT_MODE)
11485 + ptidsl->AppData.TrainedMode = DSLTRAIN_GDMT_MODE;
11486 +
11487 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
11488 + ptidsl->AppData.dsFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_DSRS]&0x1f);
11489 + else
11490 + ptidsl->AppData.dsIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_DSRS]&0x1f);
11491 + ptidsl->AppData.dsSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0x1f);
11492 + ptidsl->AppData.dsInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_DSI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0xc0)<<2));
11493 +
11494 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
11495 + ptidsl->AppData.usFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_USRS]&0x1f);
11496 + else
11497 + ptidsl->AppData.usIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_USRS]&0x1f);
11498 + ptidsl->AppData.usSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0x1f);
11499 + ptidsl->AppData.usInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_USI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0xc0)<<2));
11500 + }
11501 +
11502 + dspOamSharedInterface.modemStats_p = (DEV_HOST_modemStatsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStats_p);
11503 +
11504 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemStats_p,&StatisticsDef, sizeof(DEV_HOST_modemStatsDef_t));
11505 +
11506 + if (rc)
11507 + {
11508 + dprintf(1,"dslhal_support_blockRead failed\n");
11509 + return;
11510 + }
11511 + /* Populate the Error Structure Variables */
11512 +
11513 + /* US Interleave Path Error Statistics */
11514 +
11515 + /* Change the endianness of the Pointer */
11516 + StatisticsDef.usErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsIntlv_p);
11517 +
11518 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsIntlv_p,&usIntlvError, (sizeof(DEV_HOST_errorStats_t)));
11519 +
11520 + if (rc)
11521 + return;
11522 +
11523 + /* DS Interleave Path Error Statistics */
11524 +
11525 + /* Change the endianness of the Pointer */
11526 + StatisticsDef.dsErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsIntlv_p);
11527 +
11528 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsIntlv_p,&dsIntlvError, (sizeof(DEV_HOST_errorStats_t)));
11529 +
11530 + if (rc)
11531 + return;
11532 +
11533 + /* US Fast Path Error Statistics */
11534 +
11535 + /* Change the endianness of the Pointer */
11536 + StatisticsDef.usErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsFast_p);
11537 +
11538 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsFast_p,&usFastError, (sizeof(DEV_HOST_errorStats_t)));
11539 +
11540 + if (rc)
11541 + return;
11542 +
11543 + /* DS Fast Path Error Statistics */
11544 +
11545 + /* Change the endianness of the Pointer */
11546 + StatisticsDef.dsErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsFast_p);
11547 +
11548 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsFast_p,&dsFastError, (sizeof(DEV_HOST_errorStats_t)));
11549 +
11550 + if (rc)
11551 + return;
11552 + if(!rc)
11553 + {
11554 + if(ptidsl->AppData.bState > 2)
11555 + {
11556 + /* Get CRC Errors Stats for both US and DS */
11557 + ptidsl->AppData.dsICRC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.crcErrors);
11558 + ptidsl->AppData.dsFCRC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.crcErrors);
11559 + ptidsl->AppData.usICRC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.crcErrors);
11560 + ptidsl->AppData.usFCRC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.crcErrors);
11561 + /* Get FEC Errors Stats for both US and DS */
11562 + ptidsl->AppData.dsIFEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.fecErrors);
11563 + ptidsl->AppData.dsFFEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.fecErrors);
11564 + ptidsl->AppData.usIFEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.fecErrors);
11565 + ptidsl->AppData.usFFEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.fecErrors);
11566 + /* Get NCD Errors Stats for both US and DS */
11567 + ptidsl->AppData.dsINCD_error = dslhal_support_byteSwap32((unsigned int)dsIntlvError.ncdError);
11568 + ptidsl->AppData.dsFNCD_error = dslhal_support_byteSwap32((unsigned int)dsFastError.ncdError);
11569 + ptidsl->AppData.usINCD_error = dslhal_support_byteSwap32((unsigned int)usIntlvError.ncdError);
11570 + ptidsl->AppData.usFNCD_error = dslhal_support_byteSwap32((unsigned int)usFastError.ncdError);
11571 + /* Get LCD Errors Stats for both US and DS */
11572 + ptidsl->AppData.dsILCD_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.lcdErrors);
11573 + ptidsl->AppData.dsFLCD_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.lcdErrors);
11574 + ptidsl->AppData.usILCD_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.lcdErrors);
11575 + ptidsl->AppData.usFLCD_errors = dslhal_support_byteSwap32((unsigned int)usFastError.lcdErrors);
11576 + /*Get HEC Errors Stats for both US and DS */
11577 + ptidsl->AppData.dsIHEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.hecErrors);
11578 + ptidsl->AppData.dsFHEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.hecErrors);
11579 + ptidsl->AppData.usIHEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.hecErrors);
11580 + ptidsl->AppData.usFHEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.hecErrors);
11581 +
11582 + /* Get LOS and SEF error Stats */
11583 + ptidsl->AppData.LOS_errors = dslhal_support_byteSwap32(StatisticsDef.losErrors);
11584 + ptidsl->AppData.SEF_errors = dslhal_support_byteSwap32(StatisticsDef.sefErrors);
11585 + ptidsl->AppData.coLosErrors = dslhal_support_byteSwap32(StatisticsDef.farEndLosErrors);
11586 + ptidsl->AppData.coRdiErrors = dslhal_support_byteSwap32(StatisticsDef.farEndRdiErrors);
11587 +
11588 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
11589 +
11590 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
11591 +
11592 + if (rc)
11593 + {
11594 + dprintf(1,"dslhal_support_blockRead failed\n");
11595 + return;
11596 + }
11597 +
11598 + /* Populate the US/DS ATM Stats Variables */
11599 +
11600 + /* US ATM Statistics */
11601 +
11602 + /* Change the endianness of the Pointer */
11603 + atmStats.us0_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us0_p);
11604 +
11605 + rc = dslhal_support_blockRead((PVOID)atmStats.us0_p,&usAtmStats0, (sizeof(DEV_HOST_usAtmStats_t)));
11606 +
11607 + if (rc)
11608 + return;
11609 +
11610 + atmStats.us1_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us1_p);
11611 +
11612 + rc = dslhal_support_blockRead((PVOID)atmStats.us1_p,&usAtmStats1, (sizeof(DEV_HOST_usAtmStats_t)));
11613 +
11614 + if (rc)
11615 + return;
11616 +
11617 + /* DS ATM Statistics */
11618 +
11619 + /* Change the endianness of the Pointer */
11620 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
11621 +
11622 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
11623 +
11624 + if (rc)
11625 + return;
11626 + atmStats.ds1_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds1_p);
11627 +
11628 + rc = dslhal_support_blockRead((PVOID)atmStats.ds1_p,&dsAtmStats1, (sizeof(DEV_HOST_dsAtmStats_t)));
11629 +
11630 + if (rc)
11631 + return;
11632 +
11633 + /* Get ATM Stats for both US and DS for Channel 0*/
11634 + ptidsl->AppData.usAtm_count[0] = dslhal_support_byteSwap32(usAtmStats0.goodCount);
11635 + ptidsl->AppData.usIdle_count[0] = dslhal_support_byteSwap32(usAtmStats0.idleCount);
11636 +#if SWTC
11637 + ptidsl->AppData.usPdu_count[0] = dslhal_support_byteSwap32(usAtmStats0.pduCount);
11638 +#endif
11639 + ptidsl->AppData.dsGood_count[0] = dslhal_support_byteSwap32(dsAtmStats0.goodCount);
11640 + ptidsl->AppData.dsIdle_count[0] = dslhal_support_byteSwap32(dsAtmStats0.idleCount);
11641 +#if SWTC
11642 + ptidsl->AppData.dsPdu_count[0] = dslhal_support_byteSwap32(dsAtmStats0.pduCount);
11643 +#endif
11644 + ptidsl->AppData.dsBadHec_count[0] = dslhal_support_byteSwap32((dsAtmStats0.badHecCount));
11645 + ptidsl->AppData.dsOVFDrop_count[0] = dslhal_support_byteSwap32((dsAtmStats0.ovflwDropCount));
11646 + /* Get ATM Stats for both US and DS for Channel 1*/
11647 + ptidsl->AppData.usAtm_count[1] = dslhal_support_byteSwap32(usAtmStats1.goodCount);
11648 + ptidsl->AppData.usIdle_count[1] = dslhal_support_byteSwap32(usAtmStats1.idleCount);
11649 +#if SWTC
11650 + ptidsl->AppData.usPdu_count[1] = dslhal_support_byteSwap32(usAtmStats1.pduCount);
11651 +#endif
11652 + ptidsl->AppData.dsGood_count[1] = dslhal_support_byteSwap32(dsAtmStats1.goodCount);
11653 + ptidsl->AppData.dsIdle_count[1] = dslhal_support_byteSwap32(dsAtmStats1.idleCount);
11654 +#if SWTC
11655 + ptidsl->AppData.dsPdu_count[1] = dslhal_support_byteSwap32(dsAtmStats1.pduCount);
11656 +#endif
11657 + ptidsl->AppData.dsBadHec_count[1] = dslhal_support_byteSwap32((dsAtmStats1.badHecCount));
11658 + ptidsl->AppData.dsOVFDrop_count[1] = dslhal_support_byteSwap32((dsAtmStats1.ovflwDropCount));
11659 +
11660 + /* Determine the US and DS Superframe Count */
11661 +
11662 + dspOamSharedInterface.dspWriteSuperFrameCnt_p = (DEV_HOST_dspWrSuperFrameCntDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteSuperFrameCnt_p);
11663 +
11664 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteSuperFrameCnt_p,&SuperFrameCnt, sizeof(DEV_HOST_dspWrSuperFrameCntDef_t));
11665 +
11666 + if (rc)
11667 + {
11668 + dprintf(1,"dslhal_support_blockRead failed\n");
11669 + return;
11670 + }
11671 + ptidsl->AppData.usSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntUstrm);
11672 + ptidsl->AppData.dsSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntDstrm);
11673 +
11674 + /* Determine Frame Mode and Max Frame Mode */
11675 +
11676 + dspOamSharedInterface.atucMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atucMsg_p);
11677 +
11678 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atucMsg_p,&atuc_msg, sizeof(DEV_HOST_msg_t));
11679 +
11680 + if (rc)
11681 + {
11682 + dprintf(1,"dslhal_support_blockRead failed\n");
11683 + return;
11684 + }
11685 +
11686 + ptidsl->AppData.FrmMode = (unsigned int)atuc_msg.framingMode;
11687 + ptidsl->AppData.MaxFrmMode = (unsigned int)atuc_msg.maxFrameMode;
11688 +
11689 + /* Determine Gross Gain */
11690 +
11691 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
11692 +
11693 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
11694 +
11695 + if (rc)
11696 + {
11697 + dprintf(1,"dslhal_support_blockRead failed\n");
11698 + return;
11699 + }
11700 + ptidsl->AppData.grossGain = (unsigned int)aturMsg.grossGain;
11701 +
11702 + /* Determine DS Line Attenuation & Margin */
11703 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
11704 +
11705 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,&eocVar, sizeof(DEV_HOST_eocVarDef_t));
11706 +
11707 + if (rc)
11708 + {
11709 + dprintf(1,"dslhal_support_blockRead failed\n");
11710 + return;
11711 + }
11712 + ptidsl->AppData.dsLineAttn = (unsigned int)eocVar.lineAtten;
11713 + ptidsl->AppData.dsMargin = (unsigned int)eocVar.dsMargin;
11714 + }
11715 + }
11716 +
11717 + /* Read in the Shared Tables structure */
11718 + dspOamSharedInterface.dspWrSharedTables_p = (DEV_HOST_dspWrSharedTables_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWrSharedTables_p);
11719 +
11720 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWrSharedTables_p,&sharedTables, sizeof(DEV_HOST_dspWrSharedTables_t));
11721 +
11722 + if (rc)
11723 + {
11724 + dprintf(1,"dslhal_support_blockRead failed\n");
11725 + return;
11726 + }
11727 +
11728 + /* Read the ATU-R Bits and Gains Table */
11729 + sharedTables.aturBng_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.aturBng_p);
11730 + rc = dslhal_support_blockRead((PVOID)sharedTables.aturBng_p,ptidsl->AppData.rBng,255*2*sizeof(unsigned char));
11731 + if (rc)
11732 + {
11733 + dprintf(1,"dslhal_support_blockRead failed\n");
11734 + return;
11735 + }
11736 + /* Read the ATU-C Bits and Gains Table */
11737 + sharedTables.atucBng_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.atucBng_p);
11738 + if(ptidsl->netService == 2) /* for Annex_B */
11739 + {
11740 + rc = dslhal_support_blockRead((PVOID)sharedTables.atucBng_p,ptidsl->AppData.cBng,126*sizeof(unsigned char));
11741 + if (rc)
11742 + {
11743 + dprintf(1,"dslhal_support_blockRead failed\n");
11744 + return;
11745 + }
11746 + for(i=0;i<US_BNG_LENGTH*2;i++)
11747 + usBits[i]=0;
11748 + for(i=1;i<US_BNG_LENGTH*2;i++)
11749 + {
11750 + usBits[i]=((ptidsl->AppData.cBng[(i-1)*2])&0xf);
11751 + dprintf(5,"Bit #%d : 0x%x\n",i,usBits[i]);
11752 + }
11753 + for(i=1;i<US_BNG_LENGTH*2;i++)
11754 + {
11755 + if(usBits[i])
11756 + usNumLoadedTones++;
11757 + }
11758 + }
11759 + else
11760 + {
11761 + rc = dslhal_support_blockRead((PVOID)sharedTables.atucBng_p,ptidsl->AppData.cBng,62*sizeof(unsigned char));
11762 + if (rc)
11763 + {
11764 + dprintf(1,"dslhal_support_blockRead failed\n");
11765 + return;
11766 + }
11767 + for(i=0;i<US_BNG_LENGTH;i++)
11768 + usBits[i]=0;
11769 + for(i=1;i<US_BNG_LENGTH;i++)
11770 + {
11771 + usBits[i]=((ptidsl->AppData.cBng[(i-1)*2])&0xf);
11772 + dprintf(5,"Bit #%d : 0x%x\n",i,usBits[i]);
11773 + }
11774 + for(i=1;i<US_BNG_LENGTH;i++)
11775 + {
11776 + if(usBits[i])
11777 + usNumLoadedTones++;
11778 + }
11779 + }
11780 +
11781 + /* Determine Number U/S of Loaded Tones */
11782 +
11783 + /* U/S Power Computation */
11784 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
11785 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
11786 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
11787 + if (rc)
11788 + {
11789 + dprintf(1,"dslhal_support_blockRead failed\n");
11790 + return;
11791 + }
11792 + ptidsl->AppData.currentHybridNum = phyPerf.currentHybridNumUsed;
11793 + phyPerf.usAvgGain = dslhal_support_byteSwap32(phyPerf.usAvgGain);
11794 + ptidsl->AppData.usTxPower = LOG43125 + phyPerf.usAvgGain + (256*US_NOMINAL_POWER)+log10[usNumLoadedTones-1];
11795 + dprintf(7,"Avg Gain: 0x%x usNumLoadedTones: 0x%x log: 0x%x\n",phyPerf.usAvgGain, usNumLoadedTones, log10[usNumLoadedTones-1]);
11796 +
11797 + /* Determine Number D/S of Loaded Tones */
11798 + dsBits[0]=0;
11799 + for(i=0;i<DS_BNG_LENGTH;i++)
11800 + {
11801 + dsBits[i]=0;
11802 + /* ptidsl->AppData.rBng[i-1]=dslhal_support_byteSwap32((unsigned int)ptidsl->AppData.rBng[i-1]);*/
11803 + }
11804 + for(i=1;i<DS_BNG_LENGTH;i++)
11805 + {
11806 + dsBits[i]=((ptidsl->AppData.rBng[(i-1)*2])&0xf);
11807 + dprintf(5,"Bit #%d : 0x%x\n",i,dsBits[i]);
11808 + }
11809 + for(i=1;i<DS_BNG_LENGTH;i++)
11810 + {
11811 + if(dsBits[i])
11812 + dsNumLoadedTones++;
11813 + }
11814 + /* D/S Power Computation */
11815 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
11816 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
11817 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
11818 + if (rc)
11819 + {
11820 + dprintf(1,"dslhal_support_blockRead failed\n");
11821 + return;
11822 + }
11823 + /* D/S Power Cutback */
11824 + dsPowerCutBack = (unsigned char)((((ptidsl->AppData.bCMsgs1[0]) >>6) &0x3)+(((ptidsl->AppData.bCMsgs1[1]) &0x1) <<2));
11825 + phyPerf.dsAvgGain = dslhal_support_byteSwap32(phyPerf.dsAvgGain);
11826 + ptidsl->AppData.dsTxPower = LOG43125 + phyPerf.dsAvgGain + (256*((2*(dsPowerCutBack-1))-52)) + log10[dsNumLoadedTones-1];
11827 + dprintf(7,"Avg Gain: %d dsNumLoadedTones: %d log: %d pcb: %d \n",phyPerf.dsAvgGain, dsNumLoadedTones, log10[dsNumLoadedTones-1], dsPowerCutBack);
11828 + /* ds bit allocation */
11829 + sharedTables.bitAllocTblDstrm_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.bitAllocTblDstrm_p);
11830 + rc = dslhal_support_blockRead((PVOID)sharedTables.bitAllocTblDstrm_p,ptidsl->AppData.BitAllocTblDstrm, 256*sizeof(unsigned char));
11831 + if(rc)
11832 + {
11833 + dprintf(1,"dslhal_support_blockRead failed \n");
11834 + return;
11835 + }
11836 +
11837 + /* us bit allocation */
11838 + sharedTables.bitAllocTblUstrm_p = (unsigned char *)dslhal_support_byteSwap32((unsigned int)sharedTables.bitAllocTblUstrm_p);
11839 + rc = dslhal_support_blockRead((PVOID)sharedTables.bitAllocTblUstrm_p,ptidsl->AppData.BitAllocTblUstrm, 32*sizeof(unsigned char));
11840 + if(rc)
11841 + {
11842 + dprintf(1,"dslhal_support_blockRead failed \n");
11843 + return;
11844 + }
11845 + /* margin per tone */
11846 + sharedTables.marginTblDstrm_p = (signed char *)dslhal_support_byteSwap32((unsigned int)sharedTables.marginTblDstrm_p);
11847 + rc = dslhal_support_blockRead((PVOID)sharedTables.marginTblDstrm_p,ptidsl->AppData.marginTblDstrm, 256*sizeof(signed char));
11848 + if(rc)
11849 + {
11850 + dprintf(1,"dslhal_support_blockRead failed \n");
11851 + return;
11852 + }
11853 + /* Read Configured Options */
11854 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
11855 +
11856 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.oamWriteNegoParams_p,
11857 + &configParms, sizeof(DEV_HOST_oamWrNegoParaDef_t));
11858 +
11859 + if (rc)
11860 + {
11861 + dprintf(1,"dslhal_support_blockRead failed\n");
11862 + return;
11863 + }
11864 + else
11865 + {
11866 + /* r-Msg1 */
11867 + ptidsl->AppData.StdMode = (unsigned int)configParms.stdMode;
11868 + if(configParms.stdMode == T1413_MODE)
11869 + ptidsl->AppData.StdMode = DSLTRAIN_T1413_MODE;
11870 + if(configParms.stdMode == GDMT_MODE)
11871 + ptidsl->AppData.StdMode = DSLTRAIN_GDMT_MODE;
11872 + if(configParms.stdMode == MULTI_MODE)
11873 + ptidsl->AppData.StdMode = DSLTRAIN_MULTI_MODE;
11874 +
11875 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs1, (void *)configParms.rMsgs1, 6*sizeof(char));
11876 + if((ptidsl->AppData.bRMsgs1[2] & 0x02) == 0x02)
11877 + {
11878 + dprintf(7,"Trellis!\n");
11879 + ptidsl->configFlag |= CONFIG_FLAG_TRELLIS;
11880 + }
11881 + else
11882 + ptidsl->configFlag &= ~CONFIG_FLAG_TRELLIS;
11883 + if(ptidsl->AppData.bRMsgs1[2]&0x01)
11884 + ptidsl->configFlag |= CONFIG_FLAG_EC;
11885 + else
11886 + ptidsl->configFlag &= ~CONFIG_FLAG_EC;
11887 + }
11888 + return;
11889 +}
11890 +
11891 +
11892 +/********************************************************************************************
11893 +* FUNCTION NAME: dslhal_api_initStatistics()
11894 +*
11895 +*********************************************************************************************
11896 +* DESCRIPTION: init statistical information of ax5 modem daugter card.
11897 +*
11898 +* Input: tidsl_t *ptidsl
11899 +*
11900 +* Return: NULL
11901 +*
11902 +********************************************************************************************/
11903 +void dslhal_api_initStatistics(tidsl_t * ptidsl)
11904 +{
11905 + int rc;
11906 + /*TCHostCommDef TCHostCommParms; */
11907 + int optIdxU, optIdxD;
11908 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
11909 + DEV_HOST_dspWrNegoParaDef_t rateparms;
11910 + DEV_HOST_modemStatsDef_t StatisticsDef;
11911 + DEV_HOST_errorStats_t usIntlvError, usFastError, dsIntlvError, dsFastError;
11912 + DEV_HOST_atmStats_t atmStats;
11913 + DEV_HOST_usAtmStats_t usAtmStats0, usAtmStats1;
11914 + DEV_HOST_dsAtmStats_t dsAtmStats0,dsAtmStats1;
11915 + DEV_HOST_dspWrSuperFrameCntDef_t SuperFrameCnt;
11916 + DEV_HOST_msg_t atuc_msg, aturMsg;
11917 + DEV_HOST_eocVarDef_t eocVar;
11918 +
11919 + dprintf(5, "dslhal_api_initStatistics\n");
11920 +
11921 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
11922 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
11923 + if (rc)
11924 + {
11925 + dprintf(1,"dslhal_support_blockRead failed\n");
11926 + return;
11927 + }
11928 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
11929 +
11930 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p,&rateparms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
11931 +
11932 + if (rc)
11933 + {
11934 + dprintf(1,"dslhal_support_blockRead failed\n");
11935 + return;
11936 + }
11937 + if(!rc)
11938 + {
11939 + /* shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)rateparms.cRates1, SIZE_OF_CRATES1_TABLE); */
11940 + ptidsl->AppData.bCRates2 = rateparms.cRates2;
11941 + /* shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)rateparms.rRates1, 44); */
11942 + ptidsl->AppData.bRRates2 = rateparms.rRates2;
11943 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs1, (void *)rateparms.cMsgs1, 6);
11944 + shim_osMoveMemory((void *)ptidsl->AppData.bCMsgs2, (void *)rateparms.cMsgs2, 4);
11945 + shim_osMoveMemory((void *)ptidsl->AppData.bRMsgs2, (void *)rateparms.rMsgs2, 4);
11946 +
11947 + ptidsl->AppData.atucVendorId = dslhal_support_byteSwap32((unsigned int)rateparms.atucVendorId);
11948 + ptidsl->AppData.lineLength = (unsigned int)dslhal_support_byteSwap16((unsigned short)rateparms.lineLength);
11949 + ptidsl->AppData.atucRevisionNum = rateparms.atucGhsRevisionNum;
11950 + ptidsl->AppData.usLineAttn = (ptidsl->AppData.bCMsgs2[3] >>2)&0x003f;
11951 + ptidsl->AppData.usMargin = (ptidsl->AppData.bCMsgs2[2])&0x001f;
11952 +
11953 + /* Get the UpStream Connection Rate */
11954 + /* Based on the Bit Pattern Get the Opt# */
11955 + if((rateparms.cRates2 & 0x0f) == 0x01)
11956 + optIdxU = 0;
11957 + else if((rateparms.cRates2 & 0x0f) == 0x02)
11958 + optIdxU = 1;
11959 + else if((rateparms.cRates2 & 0x0f) == 0x04)
11960 + optIdxU = 2;
11961 + else if((rateparms.cRates2 & 0x0f) == 0x08)
11962 + optIdxU = 3;
11963 + else
11964 + optIdxU = -1;
11965 + dprintf(5, "optIdxU=%d\n", optIdxU);
11966 + /* Obtain the US Rates using Opt# and CRates1 Table */
11967 + /* Rate(US) = [Bf(LS0) + Bi(LS0)]*32 */
11968 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11969 + ptidsl->AppData.USConRate = ((rateparms.cRates1[optIdxU][CRATES1_BF_LS0] + rateparms.cRates1[optIdxU][CRATES1_BI_LS0]) * 32);
11970 + else
11971 + ptidsl->AppData.USConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2USRate);
11972 + ptidsl->AppData.USPeakCellRate = ptidsl->AppData.USConRate;
11973 +
11974 + /* Get the DownStream Connection Rate */
11975 + /* Based on the Bit Pattern Get the Opt# */
11976 + if(((rateparms.cRates2 >> 4) & 0x0f) == 0x01)
11977 + optIdxD = 0;
11978 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x02)
11979 + optIdxD = 1;
11980 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x04)
11981 + optIdxD = 2;
11982 + else if(((rateparms.cRates2 >> 4) & 0x0f) == 0x08)
11983 + optIdxD = 3;
11984 + else
11985 + optIdxD = -1;
11986 + /* Obtain the DS Rates using Opt# and CRates1 Table */
11987 + /* Rate(DS) = [Bf(AS0) + Bi(AS0)]*32 */
11988 + if(ptidsl->AppData.dsl_modulation <= DSLTRAIN_GLITE_MODE)
11989 + ptidsl->AppData.DSConRate = (((rateparms.cRates1[optIdxD][CRATES1_BF_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BF_DSRS]&0x80)<<1))+ (rateparms.cRates1[optIdxD][CRATES1_BI_AS0]|((rateparms.cRates1[optIdxD][CRATES1_BI_DSRS]&0x80)<<1)))* 32);
11990 + else
11991 + ptidsl->AppData.DSConRate = dslhal_support_byteSwap16((unsigned short)rateparms.adsl2DSRate);
11992 + dprintf(5, "ptidsl->AppData.wDSConRate=%d\n", ptidsl->AppData.DSConRate);
11993 + /* Determine which Path has Modem Trained with */
11994 + if((rateparms.cRates1[optIdxU][CRATES1_BF_LS0]) && (rateparms.cRates1[optIdxD][CRATES1_BF_AS0]))
11995 + ptidsl->AppData.TrainedPath = FAST_PATH;
11996 + else
11997 + ptidsl->AppData.TrainedPath = INTERLEAVED_PATH;
11998 +
11999 + /* Set the mode in which the modem is trained */
12000 + ptidsl->AppData.TrainedMode = (unsigned int)rateparms.trainMode;
12001 + if(rateparms.trainMode == T1413_MODE)
12002 + ptidsl->AppData.TrainedMode = DSLTRAIN_T1413_MODE;
12003 + if(rateparms.trainMode == GDMT_MODE)
12004 + ptidsl->AppData.TrainedMode = DSLTRAIN_GDMT_MODE;
12005 +
12006 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
12007 + ptidsl->AppData.dsFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_DSRS]&0x1f);
12008 + else
12009 + ptidsl->AppData.dsIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_DSRS]&0x1f);
12010 + ptidsl->AppData.dsSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0x1f);
12011 + ptidsl->AppData.dsInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_DSI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_DSS]&0xc0)<<2));
12012 +
12013 + if(ptidsl->AppData.TrainedPath == FAST_PATH)
12014 + ptidsl->AppData.usFastParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BF_USRS]&0x1f);
12015 + else
12016 + ptidsl->AppData.usIntlvParityBytesPerSymbol = (rateparms.cRates1[optIdxU][CRATES1_BI_USRS]&0x1f);
12017 + ptidsl->AppData.usSymbolsPerCodeWord = (rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0x1f);
12018 + ptidsl->AppData.usInterleaverDepth = ((rateparms.cRates1[optIdxU][CRATES1_BFI_USI])|((rateparms.cRates1[optIdxU][CRATES1_BFI_USS]&0xc0)<<2));
12019 + }
12020 +
12021 + /* get the Statistics itself */
12022 +
12023 + dspOamSharedInterface.modemStats_p = (DEV_HOST_modemStatsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemStats_p);
12024 +
12025 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemStats_p,&StatisticsDef, sizeof(DEV_HOST_modemStatsDef_t));
12026 +
12027 + if (rc)
12028 + {
12029 + dprintf(1,"dslhal_support_blockRead failed\n");
12030 + return;
12031 + }
12032 +
12033 + /* Populate the Error Structure Variables */
12034 +
12035 + /* US Interleave Path Error Statistics */
12036 +
12037 + /* Change the endianness of the Pointer */
12038 + StatisticsDef.usErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsIntlv_p);
12039 +
12040 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsIntlv_p,&usIntlvError, (sizeof(DEV_HOST_errorStats_t)));
12041 +
12042 + if (rc)
12043 + return;
12044 +
12045 + /* DS Interleave Path Error Statistics */
12046 +
12047 + /* Change the endianness of the Pointer */
12048 + StatisticsDef.dsErrorStatsIntlv_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsIntlv_p);
12049 +
12050 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsIntlv_p,&dsIntlvError, (sizeof(DEV_HOST_errorStats_t)));
12051 +
12052 + if (rc)
12053 + return;
12054 +
12055 + /* US Fast Path Error Statistics */
12056 +
12057 + /* Change the endianness of the Pointer */
12058 + StatisticsDef.usErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.usErrorStatsFast_p);
12059 +
12060 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.usErrorStatsFast_p,&usFastError, (sizeof(DEV_HOST_errorStats_t)));
12061 +
12062 + if (rc)
12063 + return;
12064 +
12065 +
12066 + /* DS Fast Path Error Statistics */
12067 +
12068 + /* Change the endianness of the Pointer */
12069 + StatisticsDef.dsErrorStatsFast_p = (DEV_HOST_errorStats_t *) dslhal_support_byteSwap32((unsigned int)StatisticsDef.dsErrorStatsFast_p);
12070 +
12071 + rc = dslhal_support_blockRead((PVOID)StatisticsDef.dsErrorStatsFast_p,&dsFastError, (sizeof(DEV_HOST_errorStats_t)));
12072 +
12073 + if (rc)
12074 + return;
12075 +
12076 + if(ptidsl->AppData.bState > 2)
12077 + {
12078 + /* Get CRC Errors Stats for both US and DS */
12079 + ptidsl->AppData.dsICRC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.crcErrors);
12080 + ptidsl->AppData.dsFCRC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.crcErrors);
12081 + ptidsl->AppData.usICRC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.crcErrors);
12082 + ptidsl->AppData.usFCRC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.crcErrors);
12083 + /* Get FEC Errors Stats for both US and DS */
12084 + ptidsl->AppData.dsIFEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.fecErrors);
12085 + ptidsl->AppData.dsFFEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.fecErrors);
12086 + ptidsl->AppData.usIFEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.fecErrors);
12087 + ptidsl->AppData.usFFEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.fecErrors);
12088 + /* Get NCD Errors Stats for both US and DS */
12089 + ptidsl->AppData.dsINCD_error = dslhal_support_byteSwap32((unsigned int)dsIntlvError.ncdError);
12090 + ptidsl->AppData.dsFNCD_error = dslhal_support_byteSwap32((unsigned int)dsFastError.ncdError);
12091 + ptidsl->AppData.usINCD_error = dslhal_support_byteSwap32((unsigned int)usIntlvError.ncdError);
12092 + ptidsl->AppData.usFNCD_error = dslhal_support_byteSwap32((unsigned int)usFastError.ncdError);
12093 + /* Get LCD Errors Stats for both US and DS */
12094 + ptidsl->AppData.dsILCD_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.lcdErrors);
12095 + ptidsl->AppData.dsFLCD_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.lcdErrors);
12096 + ptidsl->AppData.usILCD_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.lcdErrors);
12097 + ptidsl->AppData.usFLCD_errors = dslhal_support_byteSwap32((unsigned int)usFastError.lcdErrors);
12098 + /*Get HEC Errors Stats for both US and DS */
12099 + ptidsl->AppData.dsIHEC_errors = dslhal_support_byteSwap32((unsigned int)dsIntlvError.hecErrors);
12100 + ptidsl->AppData.dsFHEC_errors = dslhal_support_byteSwap32((unsigned int)dsFastError.hecErrors);
12101 + ptidsl->AppData.usIHEC_errors = dslhal_support_byteSwap32((unsigned int)usIntlvError.hecErrors);
12102 + ptidsl->AppData.usFHEC_errors = dslhal_support_byteSwap32((unsigned int)usFastError.hecErrors);
12103 +
12104 + /* Get LOS and SEF error Stats */
12105 + ptidsl->AppData.LOS_errors = dslhal_support_byteSwap32(StatisticsDef.losErrors);
12106 + ptidsl->AppData.SEF_errors = dslhal_support_byteSwap32(StatisticsDef.sefErrors);
12107 + ptidsl->AppData.coLosErrors = dslhal_support_byteSwap32(StatisticsDef.farEndLosErrors);
12108 + ptidsl->AppData.coRdiErrors = dslhal_support_byteSwap32(StatisticsDef.farEndRdiErrors);
12109 +
12110 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
12111 +
12112 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
12113 +
12114 + if (rc)
12115 + {
12116 + dprintf(1,"dslhal_support_blockRead failed\n");
12117 + return;
12118 + }
12119 +
12120 + /* Populate the US/DS ATM Stats Variables */
12121 +
12122 + /* US ATM Statistics */
12123 +
12124 + /* Change the endianness of the Pointer */
12125 + atmStats.us0_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us0_p);
12126 +
12127 + rc = dslhal_support_blockRead((PVOID)atmStats.us0_p,&usAtmStats0, (sizeof(DEV_HOST_usAtmStats_t)));
12128 +
12129 + if (rc)
12130 + return;
12131 +
12132 + /* Change the endianness of the Pointer */
12133 + atmStats.us1_p = (DEV_HOST_usAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.us1_p);
12134 +
12135 + rc = dslhal_support_blockRead((PVOID)atmStats.us1_p,&usAtmStats1, (sizeof(DEV_HOST_usAtmStats_t)));
12136 +
12137 + if (rc)
12138 + return;
12139 +
12140 +
12141 + /* DS ATM Statistics */
12142 +
12143 + /* Change the endianness of the Pointer */
12144 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
12145 +
12146 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
12147 +
12148 + if (rc)
12149 + return;
12150 +
12151 + /* Change the endianness of the Pointer */
12152 + atmStats.ds1_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds1_p);
12153 +
12154 + rc = dslhal_support_blockRead((PVOID)atmStats.ds1_p,&dsAtmStats1, (sizeof(DEV_HOST_dsAtmStats_t)));
12155 +
12156 + if (rc)
12157 + return;
12158 + /* Get ATM Stats for both US and DS Channel 0*/
12159 + ptidsl->AppData.usAtm_count[0] = dslhal_support_byteSwap32(usAtmStats0.goodCount);
12160 + ptidsl->AppData.usIdle_count[0] = dslhal_support_byteSwap32(usAtmStats0.idleCount);
12161 +#if SWTC
12162 + ptidsl->AppData.usPdu_count[0] = dslhal_support_byteSwap32(usAtmStats0.pduCount);
12163 +#endif
12164 + ptidsl->AppData.dsGood_count[0] = dslhal_support_byteSwap32(dsAtmStats0.goodCount);
12165 + ptidsl->AppData.dsIdle_count[0] = dslhal_support_byteSwap32(dsAtmStats0.idleCount);
12166 +#if SWTC
12167 + ptidsl->AppData.dsPdu_count[0] = dslhal_support_byteSwap32(dsAtmStats0.pduCount);
12168 +#endif
12169 + ptidsl->AppData.dsBadHec_count[0] = dslhal_support_byteSwap32((dsAtmStats0.badHecCount));
12170 + ptidsl->AppData.dsOVFDrop_count[0] = dslhal_support_byteSwap32((dsAtmStats0.ovflwDropCount));
12171 +
12172 + /* Get ATM Stats for both US and DS Channel 1*/
12173 + ptidsl->AppData.usAtm_count[1] = dslhal_support_byteSwap32(usAtmStats1.goodCount);
12174 + ptidsl->AppData.usIdle_count[1] = dslhal_support_byteSwap32(usAtmStats1.idleCount);
12175 +#if SWTC
12176 + ptidsl->AppData.usPdu_count[1] = dslhal_support_byteSwap32(usAtmStats1.pduCount);
12177 +#endif
12178 + ptidsl->AppData.dsGood_count[1] = dslhal_support_byteSwap32(dsAtmStats1.goodCount);
12179 + ptidsl->AppData.dsIdle_count[1] = dslhal_support_byteSwap32(dsAtmStats1.idleCount);
12180 +#if SWTC
12181 + ptidsl->AppData.dsPdu_count[1] = dslhal_support_byteSwap32(dsAtmStats1.pduCount);
12182 +#endif
12183 + ptidsl->AppData.dsBadHec_count[1] = dslhal_support_byteSwap32((dsAtmStats1.badHecCount));
12184 + ptidsl->AppData.dsOVFDrop_count[1] = dslhal_support_byteSwap32((dsAtmStats1.ovflwDropCount));
12185 +
12186 +
12187 + /* Determine the US and DS Superframe Count */
12188 +
12189 + dspOamSharedInterface.dspWriteSuperFrameCnt_p = (DEV_HOST_dspWrSuperFrameCntDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteSuperFrameCnt_p);
12190 +
12191 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteSuperFrameCnt_p,&SuperFrameCnt, sizeof(DEV_HOST_dspWrSuperFrameCntDef_t));
12192 +
12193 + if (rc)
12194 + {
12195 + dprintf(1,"dslhal_support_blockRead failed\n");
12196 + return;
12197 + }
12198 +
12199 + ptidsl->AppData.usSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntUstrm);
12200 + ptidsl->AppData.dsSuperFrmCnt = dslhal_support_byteSwap32(SuperFrameCnt.wSuperFrameCntDstrm);
12201 +
12202 + /* Determine Frame Mode and Max Frame Mode */
12203 +
12204 + dspOamSharedInterface.atucMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atucMsg_p);
12205 +
12206 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atucMsg_p,&atuc_msg, sizeof(DEV_HOST_msg_t));
12207 +
12208 + if (rc)
12209 + {
12210 + dprintf(1,"dslhal_support_blockRead failed\n");
12211 + return;
12212 + }
12213 +
12214 + ptidsl->AppData.FrmMode = (unsigned int)atuc_msg.framingMode;
12215 + ptidsl->AppData.MaxFrmMode = (unsigned int)atuc_msg.maxFrameMode;
12216 +
12217 + /* Determine Gross Gain */
12218 +
12219 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12220 +
12221 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
12222 +
12223 + if (rc)
12224 + {
12225 + dprintf(1,"dslhal_support_blockRead failed\n");
12226 + return;
12227 + }
12228 + ptidsl->AppData.grossGain = (unsigned int)aturMsg.grossGain;
12229 + /* Determine DS Line Attenuation & Margin */
12230 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12231 +
12232 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,&eocVar, sizeof(DEV_HOST_eocVarDef_t));
12233 +
12234 + if (rc)
12235 + {
12236 + dprintf(1,"dslhal_support_blockRead failed\n");
12237 + return;
12238 + }
12239 +
12240 + ptidsl->AppData.dsLineAttn = (unsigned int)eocVar.lineAtten;
12241 + ptidsl->AppData.dsMargin = (unsigned int)eocVar.dsMargin;
12242 + }
12243 +
12244 +#if __HOST_FORINTERNALUSEONLY_R_H__
12245 + ptidsl->AppData.BER = dslhal_INTERNAL_computeAtmBitErrorRate(ptidsl);
12246 +#endif
12247 + dprintf(5, "initstatistics done\n");
12248 + return;
12249 + }
12250 +
12251 +/******************************************************************************************
12252 + * FUNCTION NAME: dslhal_api_disableLosAlarm(tidsl_t *ptidsl,unsigned int set)
12253 + *
12254 + *******************************************************************************************
12255 + * DESCRIPTION: This fuction enables/disables all the LOS alarms
12256 + *
12257 + * INPUT: PITIDSLHW_T *ptidsl
12258 + * unsigned int set; //if set is TRUE: LOS Alarms are disabled else enabled
12259 + * RETURN: 0 SUCCESS
12260 + * 1 FAILED
12261 + * NOTES: Currently not supported in any version other than MR4 Patch release..
12262 + *****************************************************************************************/
12263 +unsigned int dslhal_api_disableLosAlarm(tidsl_t *ptidsl,unsigned int set)
12264 +{
12265 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12266 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12267 + int rc;
12268 + dprintf(5," dslhal_api_setTrainingMode()\n");
12269 + if(!ptidsl)
12270 + {
12271 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12272 + return DSLHAL_ERROR_INVALID_PARAM;
12273 + }
12274 +
12275 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12276 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
12277 + sizeof(DEV_HOST_dspOamSharedInterface_t));
12278 + if (rc)
12279 + {
12280 + dprintf(1,"dslhal_support_blockRead failed\n");
12281 + return DSLHAL_ERROR_BLOCK_READ;
12282 + }
12283 +
12284 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12285 +
12286 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12287 + if (rc)
12288 + {
12289 + dprintf(1,"dslhal_support_blockRead failed\n");
12290 + return DSLHAL_ERROR_BLOCK_READ;
12291 + }
12292 + if(set)
12293 + {
12294 + NegoPara.disableLosAlarm = TRUE;
12295 + /* NegoPara.marginMonitorTrning = TRUE;
12296 + NegoPara.marginMonitorShwtme = TRUE;*/
12297 + }
12298 + else
12299 + {
12300 + NegoPara.disableLosAlarm = FALSE;
12301 + /* NegoPara.marginMonitorTrning = FALSE;
12302 + NegoPara.marginMonitorShwtme = FALSE;*/
12303 + }
12304 +
12305 + rc = dslhal_support_blockWrite(&NegoPara,(PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12306 + if(rc)
12307 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12308 + dprintf(5," dslhal_api_disableLosAlarm() Done\n");
12309 + return DSLHAL_ERROR_NO_ERRORS;
12310 +}
12311 +
12312 +/******************************************************************************************
12313 + * FUNCTION NAME: dslhal_api_setMarginThreshold(tidsl_t *ptidsl,int threshold)
12314 + *
12315 + *******************************************************************************************
12316 + * DESCRIPTION: This fuction does sets the Margin threshold
12317 + *
12318 + * INPUT: PITIDSLHW_T *ptidsl
12319 + * int threshold
12320 + *
12321 + *
12322 + * RETURN: 0 SUCCESS
12323 + * 1 FAILED
12324 + *
12325 + *****************************************************************************************/
12326 +unsigned int dslhal_api_setMarginThreshold(tidsl_t *ptidsl, int threshold)
12327 +{
12328 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12329 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12330 + int rc;
12331 +
12332 + dprintf(5," dslhal_ctrl_setThreshold()\n");
12333 +
12334 + if(!ptidsl)
12335 + {
12336 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12337 + return DSLHAL_ERROR_INVALID_PARAM;
12338 + }
12339 +
12340 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12341 +
12342 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12343 + if (rc)
12344 + {
12345 + dprintf(1,"dslhal_support_blockRead failed\n");
12346 + return DSLHAL_ERROR_BLOCK_READ;
12347 + }
12348 +
12349 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12350 +
12351 +
12352 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12353 + if (rc)
12354 + {
12355 + dprintf(1,"dslhal_support_blockRead failed\n");
12356 + return DSLHAL_ERROR_BLOCK_READ;
12357 + }
12358 +
12359 + NegoPara.marginThreshold = threshold;
12360 +
12361 + rc = dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12362 +
12363 + if(rc)
12364 + return DSLHAL_ERROR_MARGIN_API_FAILURE;
12365 +
12366 + dprintf(5," dslhal_api_setThreshold() Done\n");
12367 + return DSLHAL_ERROR_NO_ERRORS;
12368 +}
12369 +
12370 +
12371 +/******************************************************************************************
12372 + * FUNCTION NAME: dslhal_api_setMonitorFlags(tidsl_t *ptidsl, unsigned int trainflag,unsigned int shwtflag)
12373 + *
12374 + *******************************************************************************************
12375 + * DESCRIPTION: This fuction does sets the Margin monitoring flag
12376 + *
12377 + * INPUT: PITIDSLHW_T *ptidsl
12378 + * unsigned int trainflag
12379 + * unsigned int shwtflag
12380 + *
12381 + * RETURN: 0 SUCCESS
12382 + * 1 FAILED
12383 + *
12384 + *****************************************************************************************/
12385 +unsigned int dslhal_api_setMarginMonitorFlags(tidsl_t *ptidsl,unsigned int trainflag,unsigned int shwtflag)
12386 +{
12387 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12388 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12389 + int rc;
12390 +
12391 + dprintf(5," dslhal_ctrl_setMonitorFlags()\n");
12392 +
12393 + if(!ptidsl)
12394 + {
12395 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12396 + return DSLHAL_ERROR_INVALID_PARAM;
12397 + }
12398 +
12399 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12400 +
12401 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12402 + if (rc)
12403 + {
12404 + dprintf(1,"dslhal_support_blockRead failed\n");
12405 + return DSLHAL_ERROR_BLOCK_READ;
12406 + }
12407 +
12408 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12409 +
12410 +
12411 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12412 + if (rc)
12413 + {
12414 + dprintf(1,"dslhal_support_blockRead failed\n");
12415 + return DSLHAL_ERROR_BLOCK_READ;
12416 + }
12417 +
12418 + if (trainflag)
12419 + {
12420 + NegoPara.marginMonitorTrning = TRUE;
12421 + }
12422 + else
12423 + {
12424 + NegoPara.marginMonitorTrning = FALSE;
12425 + }
12426 + if (shwtflag)
12427 + {
12428 + NegoPara.marginMonitorShwtme = TRUE;
12429 + }
12430 + else
12431 + {
12432 + NegoPara.marginMonitorShwtme = FALSE;
12433 + }
12434 +
12435 + rc = dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12436 + if(rc)
12437 + return DSLHAL_ERROR_MARGIN_API_FAILURE;
12438 + dprintf(5," dslhal_api_setMonitorFlags() Done\n");
12439 + return DSLHAL_ERROR_NO_ERRORS;
12440 +}
12441 +
12442 +/******************************************************************************************
12443 + * FUNCTION NAME: dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNum)
12444 + *
12445 + *******************************************************************************************
12446 + * DESCRIPTION: This fuction Sets the eoc Serial Number
12447 + *
12448 + * INPUT: PITIDSLHW_T *ptidsl
12449 + * char *SerialNum : Input eoc Serial Number
12450 + *
12451 + * RETURN: 0 SUCCESS
12452 + * 1 FAILED
12453 + *
12454 + *****************************************************************************************/
12455 +unsigned int dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNumber)
12456 +{
12457 + DEV_HOST_eocVarDef_t eocVar;
12458 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12459 + int rc;
12460 + dprintf(5," dslhal_api_setEocSerialNumber()\n");
12461 +
12462 + if(!ptidsl)
12463 + {
12464 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12465 + return DSLHAL_ERROR_INVALID_PARAM;
12466 + }
12467 +
12468 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12469 +
12470 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12471 + if (rc)
12472 + {
12473 + dprintf(1,"dslhal_support_blockRead failed\n");
12474 + return DSLHAL_ERROR_BLOCK_READ;
12475 + }
12476 +
12477 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12478 +
12479 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12480 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12481 +
12482 + if (rc)
12483 + {
12484 + dprintf(1,"dslhal_support_blockRead failed\n");
12485 + return DSLHAL_ERROR_BLOCK_READ;
12486 + }
12487 +
12488 + shim_osMoveMemory(eocVar.serialNumber,SerialNumber,32);
12489 +
12490 + rc= dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12491 + if(rc)
12492 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12493 + dprintf(5," dslhal_api_setEocSerialNumber() Done\n");
12494 +
12495 + return DSLHAL_ERROR_NO_ERRORS;
12496 +
12497 +}
12498 +
12499 +
12500 +/******************************************************************************************
12501 + * FUNCTION NAME: dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
12502 + *
12503 + *******************************************************************************************
12504 + * DESCRIPTION: This fuction Sets the eoc Vendor ID
12505 + *
12506 + * INPUT: PITIDSLHW_T *ptidsl
12507 + * char *VendorID : Input eoc Vendor ID
12508 + *
12509 + * RETURN: 0 SUCCESS
12510 + * 1 FAILED
12511 + *
12512 + *****************************************************************************************/
12513 +unsigned int dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
12514 +{
12515 + DEV_HOST_oamWrNegoParaDef_t NegoPara;
12516 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12517 + int rc;
12518 + dprintf(5," dslhal_api_setEocVendorId()\n");
12519 +
12520 + if(!ptidsl)
12521 + {
12522 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12523 + return DSLHAL_ERROR_INVALID_PARAM;
12524 + }
12525 +
12526 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12527 +
12528 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12529 + if (rc)
12530 + {
12531 + dprintf(1,"dslhal_support_blockRead failed\n");
12532 + return DSLHAL_ERROR_BLOCK_READ;
12533 + }
12534 +
12535 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12536 +
12537 +
12538 + rc = dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&NegoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12539 + if (rc)
12540 + {
12541 + dprintf(1,"dslhal_support_blockRead failed\n");
12542 + return DSLHAL_ERROR_BLOCK_READ;
12543 + }
12544 +
12545 + shim_osMoveMemory(NegoPara.gdmtVendorId,VendorID,8);
12546 + rc= dslhal_support_blockWrite(&NegoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12547 + if(rc)
12548 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12549 +
12550 + dprintf(5," dslhal_api_setEocVendorId() Done\n");
12551 + return DSLHAL_ERROR_NO_ERRORS;
12552 +}
12553 +
12554 +/******************************************************************************************
12555 + * FUNCTION NAME: dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNum)
12556 + *
12557 + *******************************************************************************************
12558 + * DESCRIPTION: This fuction Sets the eoc Revision Number
12559 + *
12560 + * INPUT: PITIDSLHW_T *ptidsl
12561 + * char *RevNum : Input eoc Revision Number
12562 + *
12563 + * RETURN: 0 SUCCESS
12564 + * 1 FAILED
12565 + *
12566 + *****************************************************************************************/
12567 +unsigned int dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNumber)
12568 +{
12569 +
12570 + DEV_HOST_eocVarDef_t eocVar;
12571 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12572 + int rc;
12573 + /*add for UR2 test */
12574 + UINT8 selfTestResults[2];
12575 + memset(selfTestResults,0x00,sizeof(selfTestResults));
12576 + /* add for UR2 test */
12577 + dprintf(5," dslhal_api_setEocRevisionNumber()\n");
12578 +
12579 + if(!ptidsl)
12580 + {
12581 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12582 + return DSLHAL_ERROR_INVALID_PARAM;
12583 + }
12584 +
12585 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12586 +
12587 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12588 + if (rc)
12589 + {
12590 + dprintf(1,"dslhal_support_blockRead failed\n");
12591 + return DSLHAL_ERROR_BLOCK_READ;
12592 + }
12593 +
12594 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12595 +
12596 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12597 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12598 +
12599 + if (rc)
12600 + {
12601 + dprintf(1,"dslhal_support_blockRead failed\n");
12602 + return DSLHAL_ERROR_BLOCK_READ;
12603 + }
12604 + shim_osMoveMemory(eocVar.revNumber,RevNumber,4);
12605 + /* add for UR2 test */
12606 + shim_osMoveMemory(eocVar.dummy,selfTestResults,2);
12607 + /* add for UR2 test */
12608 + rc=dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12609 + if(rc)
12610 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12611 + dprintf(5," dslhal_api_setEocRevisionNumber Done\n");
12612 + return DSLHAL_ERROR_NO_ERRORS;
12613 +}
12614 +
12615 +/******************************************************************************************
12616 + * FUNCTION NAME: dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
12617 + *
12618 + *******************************************************************************************
12619 + * DESCRIPTION: This fuction Sets the eoc ATUR Config Register
12620 + *
12621 + * INPUT: PITIDSLHW_T *ptidsl
12622 + * char *ATURConfig : Input eoc ATUR Config Register
12623 + *
12624 + * RETURN: 0 SUCCESS
12625 + * 1 FAILED
12626 + *
12627 + *****************************************************************************************/
12628 +unsigned int dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
12629 +{
12630 +
12631 + DEV_HOST_eocVarDef_t eocVar;
12632 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12633 + int rc;
12634 + dprintf(5," dslhal_api_setAturConfig()\n");
12635 +
12636 + if(!ptidsl)
12637 + {
12638 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12639 + return DSLHAL_ERROR_INVALID_PARAM;
12640 + }
12641 +
12642 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12643 +
12644 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12645 + if (rc)
12646 + {
12647 + dprintf(1,"dslhal_support_blockRead failed\n");
12648 + return DSLHAL_ERROR_BLOCK_READ;
12649 + }
12650 +
12651 + dspOamSharedInterface.eocVar_p = (DEV_HOST_eocVarDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.eocVar_p);
12652 +
12653 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.eocVar_p,
12654 + &eocVar, sizeof(DEV_HOST_eocVarDef_t));
12655 +
12656 + if (rc)
12657 + {
12658 + dprintf(1,"dslhal_support_blockRead failed\n");
12659 + return DSLHAL_ERROR_BLOCK_READ;
12660 + }
12661 + shim_osMoveMemory(eocVar.aturConfig,ATURConfig,30);
12662 + rc= dslhal_support_blockWrite(&eocVar,dspOamSharedInterface.eocVar_p,sizeof(DEV_HOST_eocVarDef_t));
12663 + if(rc)
12664 + return DSLHAL_ERROR_EOCREG_API_FAILURE;
12665 + dprintf(5," dslhal_api_setAturConfig() Done\n");
12666 + return DSLHAL_ERROR_NO_ERRORS;
12667 +}
12668 +
12669 +
12670 +/******************************************************************************************
12671 +* FUNCTION NAME: dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl,unsigned int flag)
12672 +*
12673 +*******************************************************************************************
12674 +* DESCRIPTION: This fuction Sets the Rate Adapt Enable Flag
12675 +*
12676 +* INPUT: PITIDSLHW_T *ptidsl
12677 +* unsigned int flag; //if flag = TRUE set rateadapt flag else reset it
12678 +* RETURN: 0 SUCCESS
12679 +* 1 FAILED
12680 +*
12681 +*****************************************************************************************/
12682 +unsigned int dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl,unsigned int flag)
12683 +{
12684 + DEV_HOST_msg_t aturMsg;
12685 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12686 + int rc;
12687 + dprintf(5," dslhal_api_setRateAdaptFlag()\n");
12688 +
12689 + if(!ptidsl)
12690 + {
12691 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12692 + return DSLHAL_ERROR_INVALID_PARAM;
12693 + }
12694 +
12695 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12696 +
12697 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12698 + if (rc)
12699 + {
12700 + dprintf(1,"dslhal_support_blockRead failed\n");
12701 + return DSLHAL_ERROR_BLOCK_READ;
12702 + }
12703 +
12704 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12705 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12706 + &aturMsg, sizeof(DEV_HOST_msg_t));
12707 + if (rc)
12708 + {
12709 + dprintf(1,"dslhal_support_blockRead failed\n");
12710 + return DSLHAL_ERROR_BLOCK_READ;
12711 + }
12712 +
12713 + if(flag)
12714 + aturMsg.rateAdapt = TRUE;
12715 + else
12716 + aturMsg.rateAdapt = FALSE;
12717 +
12718 + rc= dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12719 + if(rc)
12720 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12721 + dprintf(5," dslhal_api_setRateAdaptFlag() Done\n");
12722 + return DSLHAL_ERROR_NO_ERRORS;
12723 +}
12724 +
12725 +/******************************************************************************************
12726 +* FUNCTION NAME: dslhal_api_setTrellisFlag(tidsl_t *ptidsl,unsigned int flag)
12727 +*
12728 +*******************************************************************************************
12729 +* DESCRIPTION: This fuction Sets the Trellis Coding Enable Flag
12730 +*
12731 +* INPUT: PITIDSLHW_T *ptidsl
12732 +* unsigned int flag; // if flag = TRUE, set trellis flag else reset
12733 +* RETURN: 0 SUCCESS
12734 +* 1 FAILED
12735 +*
12736 +*****************************************************************************************/
12737 +unsigned int dslhal_api_setTrellisFlag(tidsl_t *ptidsl,unsigned int flag)
12738 +{
12739 +
12740 + DEV_HOST_msg_t aturMsg;
12741 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12742 + DEV_HOST_oamWrNegoParaDef_t negoPara;
12743 + int rc;
12744 + dprintf(5," dslhal_api_setTrellisFlag()\n");
12745 + if(!ptidsl)
12746 + {
12747 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12748 + return DSLHAL_ERROR_INVALID_PARAM;
12749 + }
12750 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12751 +
12752 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12753 + if (rc)
12754 + {
12755 + dprintf(1,"dslhal_support_blockRead failed\n");
12756 + return DSLHAL_ERROR_BLOCK_READ;
12757 + }
12758 +
12759 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12760 + rc += dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,&aturMsg, sizeof(DEV_HOST_msg_t));
12761 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
12762 + rc += dslhal_support_blockRead((PVOID) dspOamSharedInterface.oamWriteNegoParams_p,&negoPara, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12763 + if (rc)
12764 + {
12765 + dprintf(1,"dslhal_support_blockRead failed\n");
12766 + return DSLHAL_ERROR_BLOCK_READ;
12767 + }
12768 +
12769 + if(flag)
12770 + {
12771 + aturMsg.trellis = TRUE;
12772 + negoPara.rMsgs1[2] |= 0x02;
12773 + }
12774 + else
12775 + {
12776 + aturMsg.trellis = FALSE;
12777 + negoPara.rMsgs1[2] &= 0xFD;
12778 + }
12779 + rc=0;
12780 + rc+=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12781 + rc+= dslhal_support_blockWrite(&negoPara,dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
12782 + if(rc)
12783 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12784 +
12785 + dprintf(5," dslhal_api_setTrellisFlag() Done\n");
12786 + return DSLHAL_ERROR_NO_ERRORS;
12787 +}
12788 +
12789 +/******************************************************************************************
12790 +* FUNCTION NAME: dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
12791 +*
12792 +*******************************************************************************************
12793 +* DESCRIPTION: This fuction Sets the Maximum bits per carrier value
12794 +*
12795 +* INPUT: PITIDSLHW_T *ptidsl
12796 +* unsigned int maxbits : should be a value between 0-15
12797 +*
12798 +* RETURN: 0 SUCCESS
12799 +* 1 FAILED
12800 +*
12801 +*****************************************************************************************/
12802 +unsigned int dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
12803 +{
12804 +
12805 + DEV_HOST_msg_t aturMsg;
12806 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12807 + int rc;
12808 +
12809 + dprintf(5," dslhal_api_setMaxBitsPerCarrier()\n");
12810 + if(maxbits>15)
12811 + {
12812 + dprintf(3,"Maximum Number of Bits per carrier cannot exceed 15!\n");
12813 + return DSLHAL_ERROR_INVALID_PARAM;
12814 + }
12815 +
12816 + if(!ptidsl)
12817 + {
12818 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12819 + return DSLHAL_ERROR_INVALID_PARAM;
12820 + }
12821 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12822 +
12823 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12824 + if (rc)
12825 + {
12826 + dprintf(1,"dslhal_support_blockRead failed\n");
12827 + return DSLHAL_ERROR_BLOCK_READ;
12828 + }
12829 +
12830 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12831 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12832 + &aturMsg, sizeof(DEV_HOST_msg_t));
12833 + if (rc)
12834 + {
12835 + dprintf(1,"dslhal_support_blockRead failed\n");
12836 + return DSLHAL_ERROR_BLOCK_READ;
12837 + }
12838 +
12839 + aturMsg.maxBits = maxbits;
12840 +
12841 + rc=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12842 + if(rc)
12843 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12844 + dprintf(5," dslhal_api_setMaxBitsPerCarrier() Done\n");
12845 + return DSLHAL_ERROR_NO_ERRORS;
12846 +}
12847 +
12848 +
12849 +/******************************************************************************************
12850 +* FUNCTION NAME: dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
12851 +*
12852 +*******************************************************************************************
12853 +* DESCRIPTION: This fuction Sets the Maximum Interleave Depth Supported
12854 +*
12855 +* INPUT: PITIDSLHW_T *ptidsl
12856 +* unsigned int maxdepth : Should be between 0 and 3 depending on intlv buffer
12857 +* size 64-512
12858 +* RETURN: 0 SUCCESS
12859 +* 1 FAILED
12860 +*
12861 +*****************************************************************************************/
12862 +unsigned int dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
12863 +{
12864 + DEV_HOST_msg_t aturMsg;
12865 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12866 + int rc;
12867 + dprintf(5," dslhal_api_setMaxInterleaverDepth()\n");
12868 + if(maxdepth>3)
12869 + {
12870 + dprintf(3,"Invalid Value for maximum interleave depth (must be <3)\n");
12871 + return DSLHAL_ERROR_INVALID_PARAM;
12872 + }
12873 +
12874 + if(!ptidsl)
12875 + {
12876 + dprintf(3, "Error: PTIDSL pointer invalid\n");
12877 + return DSLHAL_ERROR_INVALID_PARAM;
12878 + }
12879 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12880 +
12881 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12882 + if (rc)
12883 + {
12884 + dprintf(1,"dslhal_support_blockRead failed\n");
12885 + return DSLHAL_ERROR_BLOCK_READ;
12886 + }
12887 +
12888 + dspOamSharedInterface.aturMsg_p = (DEV_HOST_msg_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.aturMsg_p);
12889 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.aturMsg_p,
12890 + &aturMsg, sizeof(DEV_HOST_msg_t));
12891 + if (rc)
12892 + {
12893 + dprintf(1,"dslhal_support_blockRead failed\n");
12894 + return DSLHAL_ERROR_BLOCK_READ;
12895 + }
12896 +
12897 + aturMsg.maxIntlvDepth = maxdepth;
12898 +
12899 + rc=dslhal_support_blockWrite(&aturMsg,dspOamSharedInterface.aturMsg_p,sizeof(DEV_HOST_msg_t));
12900 + if(rc)
12901 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
12902 + dprintf(5," dslhal_api_setMaxInterleaverDepth() Done\n");
12903 + return DSLHAL_ERROR_NO_ERRORS;
12904 +}
12905 +
12906 +/********************************************************************************************
12907 +* FUNCTION NAME: dslhal_api_acknowledgeInterrupt()
12908 +*
12909 +*********************************************************************************************
12910 +* DESCRIPTION:
12911 +* Sets the host interrupt bit masks
12912 +*
12913 +* Return: 0 success
12914 +* 1 failed
12915 +*
12916 +* NOTE:
12917 +* DSP image is based on LITTLE endian
12918 +*
12919 +********************************************************************************************/
12920 +unsigned int dslhal_api_acknowledgeInterrupt(tidsl_t * ptidsl)
12921 +{
12922 + unsigned int interruptSources=0;
12923 + /* Clear out the DSLSS Interrupt Registers to acknowledge Interrupt */
12924 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_MAILBOX_INTERRUPTS)
12925 + {
12926 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_MAILBOX_INTERRUPTS;
12927 + dprintf(5,"Mailbox Interrupt \n");
12928 + }
12929 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_BITFIELD_INTERRUPTS)
12930 + {
12931 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_BITFIELD_INTERRUPTS;
12932 + dprintf(5,"Bitfield Interrupt \n");
12933 + }
12934 + if(DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_SOURCE_REGISTER))&MASK_HEARTBEAT_INTERRUPTS)
12935 + {
12936 + DSLHAL_REG32(dslhal_support_hostDspAddressTranslate(DSP_INTERRUPT_CLEAR_REGISTER))|=MASK_HEARTBEAT_INTERRUPTS;
12937 + dprintf(5,"HeartBeat Interrupt \n");
12938 + }
12939 + interruptSources = dslhal_support_parseInterruptSource(ptidsl);
12940 + if(interruptSources < 0)
12941 + return DSLHAL_ERROR_INTERRUPT_FAILURE;
12942 + else
12943 + return interruptSources;
12944 +}
12945 +
12946 +/********************************************************************************************
12947 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
12948 +*
12949 +*********************************************************************************************
12950 +* DESCRIPTION:
12951 +* Sets the host interrupt bit masks
12952 +*
12953 +* Return: 0 success
12954 +* 1 failed
12955 +*
12956 +* NOTE:
12957 +* DSP image is based on LITTLE endian
12958 +*
12959 +********************************************************************************************/
12960 +unsigned int dslhal_api_disableDspHybridSelect(tidsl_t * ptidsl,unsigned int disable)
12961 +{
12962 + int rc;
12963 + DEV_HOST_phyPerf_t phyPerf;
12964 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
12965 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
12966 +
12967 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
12968 + if (rc)
12969 + {
12970 + dprintf(1,"dslhal_support_blockRead failed\n");
12971 + return DSLHAL_ERROR_BLOCK_READ;
12972 + }
12973 +
12974 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
12975 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
12976 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
12977 + if (rc)
12978 + {
12979 + dprintf(1,"dslhal_support_blockRead failed\n");
12980 + return DSLHAL_ERROR_BLOCK_READ;
12981 + }
12982 + if(disable==1)
12983 + {
12984 + phyPerf.disableDspHybridSelect_f = TRUE;
12985 + // hybrid_selected = 888;
12986 + }
12987 + else
12988 + {
12989 + phyPerf.disableDspHybridSelect_f = FALSE;
12990 + // hybrid_selected = 888;
12991 + }
12992 + rc=dslhal_support_blockWrite(&phyPerf,dspOamSharedInterface.phyPerf_p,sizeof(DEV_HOST_phyPerf_t));
12993 + if(rc)
12994 + return DSLHAL_ERROR_HYBRID_API_FAILURE;
12995 + else
12996 + return DSLHAL_ERROR_NO_ERRORS;
12997 +}
12998 +
12999 +/********************************************************************************************
13000 +* FUNCTION NAME: dslhal_api_selectHybrid()
13001 +*
13002 +*********************************************************************************************
13003 +* DESCRIPTION:
13004 +* Sets the host interrupt bit masks
13005 +*
13006 +* Return: 0 success
13007 +* 1 failed
13008 +*
13009 +* NOTE:
13010 +* DSP image is based on LITTLE endian
13011 +*
13012 +********************************************************************************************/
13013 +unsigned int dslhal_api_selectHybrid(tidsl_t * ptidsl,unsigned int hybridNum)
13014 +{
13015 + int rc;
13016 + DEV_HOST_phyPerf_t phyPerf;
13017 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13018 + if(hybridNum<1||hybridNum>4)
13019 + {
13020 + dprintf(3,"Invalid Value for Hybrid Number \n");
13021 + return DSLHAL_ERROR_INVALID_PARAM;
13022 + }
13023 +
13024 + if(!ptidsl)
13025 + {
13026 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13027 + return DSLHAL_ERROR_INVALID_PARAM;
13028 + }
13029 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13030 +
13031 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13032 + if (rc)
13033 + {
13034 + dprintf(1,"dslhal_support_blockRead failed\n");
13035 + return DSLHAL_ERROR_BLOCK_READ;
13036 + }
13037 +
13038 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
13039 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
13040 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
13041 + if (rc)
13042 + {
13043 + dprintf(1,"dslhal_support_blockRead failed\n");
13044 + return DSLHAL_ERROR_BLOCK_READ;
13045 + }
13046 + phyPerf.hostSelectHybridNum = hybridNum;
13047 + rc=dslhal_support_blockWrite(&phyPerf,dspOamSharedInterface.phyPerf_p,sizeof(DEV_HOST_phyPerf_t));
13048 + if(rc)
13049 + return DSLHAL_ERROR_HYBRID_API_FAILURE;
13050 + else
13051 + return DSLHAL_ERROR_NO_ERRORS;
13052 +}
13053 +
13054 +/********************************************************************************************
13055 +* FUNCTION NAME: dslhal_api_reportHybridMetrics()
13056 +*
13057 +*********************************************************************************************
13058 +* DESCRIPTION:
13059 +* Sets the host interrupt bit masks
13060 +*
13061 +* Return: 0 success
13062 +* 1 failed
13063 +*
13064 +* NOTE:
13065 +* DSP image is based on LITTLE endian
13066 +*
13067 +********************************************************************************************/
13068 +unsigned int dslhal_api_reportHybridMetrics(tidsl_t * ptidsl,int *metric)
13069 +{
13070 + int rc,i;
13071 + DEV_HOST_phyPerf_t phyPerf;
13072 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13073 + if(hybrid_selected>5)
13074 + {
13075 + dprintf(4,"Hybrid Metrics Not Yet Available \n");
13076 + }
13077 + if(!ptidsl)
13078 + {
13079 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13080 + return (0-DSLHAL_ERROR_INVALID_PARAM);
13081 + }
13082 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13083 +
13084 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13085 + if (rc)
13086 + {
13087 + dprintf(1,"dslhal_support_blockRead failed\n");
13088 + return (0-DSLHAL_ERROR_BLOCK_READ);
13089 + }
13090 +
13091 + dspOamSharedInterface.phyPerf_p = (DEV_HOST_phyPerf_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.phyPerf_p);
13092 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.phyPerf_p,
13093 + &phyPerf, sizeof(DEV_HOST_phyPerf_t));
13094 + if (rc)
13095 + {
13096 + dprintf(1,"dslhal_support_blockRead failed\n");
13097 + return (0-DSLHAL_ERROR_BLOCK_READ);
13098 + }
13099 + rc = sizeof(phyPerf.hybridCost);
13100 + for(i=0;i<(rc/4);i++)
13101 + {
13102 + metric[i] = dslhal_support_byteSwap32(phyPerf.hybridCost[i]);
13103 + }
13104 + return hybrid_selected;
13105 +}
13106 +
13107 +/******************************************************************************************
13108 + * FUNCTION NAME: dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl,unsigned int pairSelect)
13109 + *
13110 + *******************************************************************************************
13111 + * DESCRIPTION: This fuction selects inner/outer pair on RJ11.
13112 + *
13113 + * INPUT: PITIDSLHW_T *ptidsl , unsigned int pairSelect
13114 + *
13115 + * RETURN: 0 SUCCESS
13116 + * 1 FAILED
13117 + *
13118 + *****************************************************************************************/
13119 +unsigned int dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl,unsigned int pairSelect)
13120 +{
13121 + int rc;
13122 +
13123 + dprintf(5, "dslhal_api_sendQuiet\n");
13124 + rc = dslhal_support_writeHostMailbox(ptidsl, HOST_RJ11SELECT, (unsigned int)pairSelect, 0, 0);
13125 + if(rc)
13126 + {
13127 + dprintf(1,"dslhal_api_sendQuiet failed\n");
13128 + return DSLHAL_ERROR_CTRL_API_FAILURE;
13129 + }
13130 + return DSLHAL_ERROR_NO_ERRORS;
13131 +}
13132 +
13133 +/******************************************************************************************
13134 + * FUNCTION NAME: dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl)
13135 + *
13136 + *******************************************************************************************
13137 + * DESCRIPTION: This fuction resets the failed state log stored
13138 + *
13139 + * INPUT: PITIDSLHW_T *ptidsl
13140 + *
13141 + * RETURN: 0 SUCCESS
13142 + * 1 FAILED
13143 + *
13144 + *****************************************************************************************/
13145 +unsigned int dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl)
13146 +{
13147 +
13148 + int rc;
13149 + dprintf(5, "dslhal_api_resetTrainFailureLog \n");
13150 + for(rc=0;rc<ptidsl->AppData.trainFails;rc++)
13151 + {
13152 + ptidsl->AppData.trainFailStates[rc]=0;
13153 + }
13154 + ptidsl->AppData.trainFails = 0;
13155 + return DSLHAL_ERROR_NO_ERRORS;
13156 +}
13157 +
13158 +/********************************************************************************************
13159 +* FUNCTION NAME: dslhal_api_configureLed()
13160 +*
13161 +*********************************************************************************************
13162 +* DESCRIPTION:
13163 +* Sets the host interrupt bit masks
13164 +*
13165 +* Return: 0 success
13166 +* 1 failed
13167 +*
13168 +* NOTE:
13169 +* DSP image is based on LITTLE endian
13170 +*
13171 +********************************************************************************************/
13172 +unsigned int dslhal_api_configureLed(tidsl_t * ptidsl,unsigned int idLed, unsigned int onOff)
13173 +{
13174 + int rc;
13175 + DEV_HOST_modemEnvPublic_t modemEnv;
13176 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13177 + if(idLed>2 || onOff>2)
13178 + {
13179 + dprintf(3,"Invalid input parameter \n");
13180 + return DSLHAL_ERROR_INVALID_PARAM;
13181 + }
13182 +
13183 + if(!ptidsl)
13184 + {
13185 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13186 + return DSLHAL_ERROR_INVALID_PARAM;
13187 + }
13188 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13189 +
13190 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13191 + if (rc)
13192 + {
13193 + dprintf(1,"dslhal_support_blockRead failed\n");
13194 + return DSLHAL_ERROR_BLOCK_READ;
13195 + }
13196 +
13197 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13198 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13199 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13200 + if (rc)
13201 + {
13202 + dprintf(1,"dslhal_support_blockRead failed\n");
13203 + return DSLHAL_ERROR_BLOCK_READ;
13204 + }
13205 + if(idLed==ID_DSL_LINK_LED)
13206 + {
13207 + modemEnv.overrideDslLinkLed_f = TRUE;
13208 + if(onOff!=2)
13209 + modemEnv.dslLinkLedState_f = onOff;
13210 + }
13211 + if(idLed==ID_DSL_ACT_LED)
13212 + {
13213 + modemEnv.overrideDslLinkLed_f = TRUE;
13214 + if(onOff!=2)
13215 + modemEnv.dslLinkLedState_f = onOff;
13216 + }
13217 + if(idLed==ID_RESTORE_DEFAULT_LED)
13218 + {
13219 + modemEnv.overrideDslLinkLed_f = FALSE;
13220 + modemEnv.overrideDslActLed_f = FALSE;
13221 + }
13222 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13223 + if(rc)
13224 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13225 + else
13226 + return DSLHAL_ERROR_NO_ERRORS;
13227 +}
13228 +
13229 +/********************************************************************************************
13230 +* FUNCTION NAME: dslhal_api_configureExternBert()
13231 +*
13232 +*********************************************************************************************
13233 +* DESCRIPTION:
13234 +* Sets the host interrupt bit masks
13235 +*
13236 +* Return: 0 success
13237 +* 1 failed
13238 +*
13239 +* NOTE:
13240 +* DSP image is based on LITTLE endian
13241 +*
13242 +********************************************************************************************/
13243 +unsigned int dslhal_api_configureExternBert(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13244 +{
13245 + int rc;
13246 + DEV_HOST_modemEnvPublic_t modemEnv;
13247 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13248 + if(configParm>1 || parmVal>1)
13249 + {
13250 + dprintf(3,"Invalid input parameter \n");
13251 + return DSLHAL_ERROR_INVALID_PARAM;
13252 + }
13253 +
13254 + if(!ptidsl)
13255 + {
13256 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13257 + return DSLHAL_ERROR_INVALID_PARAM;
13258 + }
13259 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13260 +
13261 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13262 + if (rc)
13263 + {
13264 + dprintf(1,"dslhal_support_blockRead failed\n");
13265 + return DSLHAL_ERROR_BLOCK_READ;
13266 + }
13267 +
13268 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13269 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13270 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13271 + if (rc)
13272 + {
13273 + dprintf(1,"dslhal_support_blockRead failed\n");
13274 + return DSLHAL_ERROR_BLOCK_READ;
13275 + }
13276 + if(configParm==0)
13277 + {
13278 + modemEnv.externalBert = parmVal;
13279 + }
13280 + if(configParm==1)
13281 + {
13282 + modemEnv.usBertPattern = parmVal;
13283 + }
13284 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13285 + if(rc)
13286 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13287 + else
13288 + return DSLHAL_ERROR_NO_ERRORS;
13289 +}
13290 +
13291 +/********************************************************************************************
13292 +* FUNCTION NAME: dslhal_api_configureAtmBert()
13293 +*
13294 +*********************************************************************************************
13295 +* DESCRIPTION:
13296 +* Sets the host interrupt bit masks
13297 +*
13298 +* Return: 0 success
13299 +* 1 failed
13300 +*
13301 +* NOTE:
13302 +* DSP image is based on LITTLE endian
13303 +*
13304 +********************************************************************************************/
13305 +unsigned int dslhal_api_configureAtmBert(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13306 +{
13307 + int rc;
13308 + DEV_HOST_atmDsBert_t atmDsBert;
13309 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13310 + if(configParm>1 || parmVal>1)
13311 + {
13312 + dprintf(3,"Invalid input parameter \n");
13313 + return DSLHAL_ERROR_INVALID_PARAM;
13314 + }
13315 +
13316 + if(!ptidsl)
13317 + {
13318 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13319 + return DSLHAL_ERROR_INVALID_PARAM;
13320 + }
13321 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13322 +
13323 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13324 + if (rc)
13325 + {
13326 + dprintf(1,"dslhal_support_blockRead failed\n");
13327 + return DSLHAL_ERROR_BLOCK_READ;
13328 + }
13329 +
13330 + dspOamSharedInterface.atmDsBert_p = (DEV_HOST_atmDsBert_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmDsBert_p);
13331 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmDsBert_p,
13332 + &atmDsBert, sizeof(DEV_HOST_atmDsBert_t));
13333 + if (rc)
13334 + {
13335 + dprintf(1,"dslhal_support_blockRead failed\n");
13336 + return DSLHAL_ERROR_BLOCK_READ;
13337 + }
13338 + if(configParm==0)
13339 + {
13340 + atmDsBert.atmBertFlag = parmVal;
13341 + rc=dslhal_support_blockWrite(&atmDsBert,dspOamSharedInterface.atmDsBert_p,sizeof(DEV_HOST_atmDsBert_t));
13342 + if(rc)
13343 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
13344 + }
13345 + if(configParm==1)
13346 + {
13347 + ptidsl->AppData.atmBertBitCountLow = atmDsBert.bitCountLow;
13348 + ptidsl->AppData.atmBertBitCountHigh = atmDsBert.bitCountHigh;
13349 + ptidsl->AppData.atmBertBitErrorCountLow = atmDsBert.bitErrorCountLow;
13350 + ptidsl->AppData.atmBertBitErrorCountHigh = atmDsBert.bitErrorCountHigh;
13351 + }
13352 + return DSLHAL_ERROR_NO_ERRORS;
13353 +}
13354 +
13355 +/********************************************************************************************
13356 +* FUNCTION NAME: dslhal_api_configureDgaspLpr()
13357 +*
13358 +*********************************************************************************************
13359 +* DESCRIPTION:
13360 +* Configures dying gasp LPR signal
13361 +*
13362 +* Return: 0 success
13363 +* 1 failed
13364 +*
13365 +* NOTE:
13366 +* DSP image is based on LITTLE endian
13367 +*
13368 +********************************************************************************************/
13369 +unsigned int dslhal_api_configureDgaspLpr(tidsl_t * ptidsl,unsigned int configParm, unsigned int parmVal)
13370 +{
13371 + int rc;
13372 + DEV_HOST_modemEnvPublic_t modemEnv;
13373 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
13374 + if(configParm>1 || parmVal>1)
13375 + {
13376 + dprintf(3,"Invalid input parameter \n");
13377 + return DSLHAL_ERROR_INVALID_PARAM;
13378 + }
13379 +
13380 + if(!ptidsl)
13381 + {
13382 + dprintf(3, "Error: PTIDSL pointer invalid\n");
13383 + return DSLHAL_ERROR_INVALID_PARAM;
13384 + }
13385 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
13386 +
13387 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
13388 + if (rc)
13389 + {
13390 + dprintf(1,"dslhal_support_blockRead failed\n");
13391 + return DSLHAL_ERROR_BLOCK_READ;
13392 + }
13393 +
13394 + dspOamSharedInterface.modemEnvPublic_p = (DEV_HOST_modemEnvPublic_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.modemEnvPublic_p);
13395 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.modemEnvPublic_p,
13396 + &modemEnv, sizeof(DEV_HOST_modemEnvPublic_t));
13397 + if (rc)
13398 + {
13399 + dprintf(1,"dslhal_support_blockRead failed\n");
13400 + return DSLHAL_ERROR_BLOCK_READ;
13401 + }
13402 + if(configParm==0)
13403 + {
13404 + modemEnv.dGaspLprIndicator_f = parmVal;
13405 + }
13406 + if(configParm==1)
13407 + {
13408 + modemEnv.overrideDspLprGasp_f = parmVal;
13409 + }
13410 + rc=dslhal_support_blockWrite(&modemEnv,dspOamSharedInterface.modemEnvPublic_p,sizeof(DEV_HOST_modemEnvPublic_t));
13411 + if(rc)
13412 + return DSLHAL_ERROR_MODEMENV_API_FAILURE;
13413 + else
13414 + return DSLHAL_ERROR_NO_ERRORS;
13415 +}
13416 +
13417 +/********************************************************************************************
13418 +* FUNCTION NAME: dslhal_api_genericDspRead()
13419 +*
13420 +*********************************************************************************************
13421 +* DESCRIPTION:
13422 +* Reads from a Generic Location in the DSP Host Interface
13423 +*
13424 +* Return: 0 success
13425 +* 1 failed
13426 +*
13427 +* NOTE:
13428 +* DSP image is based on LITTLE endian
13429 +*
13430 +********************************************************************************************/
13431 +unsigned int dslhal_api_genericDspRead(tidsl_t * ptidsl,unsigned int offset1, unsigned int offset2,
13432 + unsigned int offset3, unsigned char *localBuffer, unsigned int numBytes)
13433 +{
13434 + int rc=0;
13435 + unsigned int hostIfLoc,structLoc,elementLoc;
13436 + hostIfLoc = (unsigned int)ptidsl->pmainAddr;
13437 + if(numBytes<=0 || !localBuffer || !ptidsl)
13438 + {
13439 + dprintf(3,"Invalid input parameter \n");
13440 + return DSLHAL_ERROR_INVALID_PARAM;
13441 + }
13442 + rc += dslhal_support_blockRead((PVOID)(hostIfLoc+sizeof(int)*offset1), &structLoc,sizeof(int));
13443 + structLoc = dslhal_support_byteSwap32(structLoc);
13444 + rc += dslhal_support_blockRead((PVOID)(structLoc+sizeof(int)*offset2), &elementLoc,sizeof(int));
13445 + elementLoc = dslhal_support_byteSwap32(elementLoc);
13446 + dprintf(3,"Host IF Location: 0x%x Struct1 Location: 0x%x Element Location: 0x%x \n",hostIfLoc, structLoc, elementLoc);
13447 + rc += dslhal_support_blockRead((PVOID)(elementLoc+(offset3*4)), localBuffer,numBytes);
13448 + if (rc)
13449 + return DSLHAL_ERROR_BLOCK_READ;
13450 + return DSLHAL_ERROR_NO_ERRORS;
13451 +}
13452 +
13453 +/********************************************************************************************
13454 +* FUNCTION NAME: dslhal_api_genericDspWrite()
13455 +*
13456 +*********************************************************************************************
13457 +* DESCRIPTION:
13458 +* Writes to a Generic Location in the DSP Host Interface
13459 +*
13460 +* Return: 0 success
13461 +* 1 failed
13462 +*
13463 +* NOTE:
13464 +* DSP image is based on LITTLE endian
13465 +*
13466 +********************************************************************************************/
13467 +unsigned int dslhal_api_genericDspWrite(tidsl_t * ptidsl,unsigned int offset1, unsigned int offset2,
13468 + unsigned int offset3, unsigned char *localBuffer, unsigned int numBytes)
13469 +{
13470 +
13471 + int rc=0;
13472 + unsigned int hostIfLoc,structLoc,elementLoc;
13473 + hostIfLoc = (unsigned int)ptidsl->pmainAddr;
13474 + if(numBytes<=0 || !localBuffer || !ptidsl)
13475 + {
13476 + dprintf(3,"Invalid input parameter \n");
13477 + return DSLHAL_ERROR_INVALID_PARAM;
13478 + }
13479 + rc += dslhal_support_blockRead((PVOID)(hostIfLoc+(offset1*4)), &structLoc,4);
13480 + structLoc = dslhal_support_byteSwap32(structLoc);
13481 + rc += dslhal_support_blockRead((PVOID)(structLoc+(offset2*4)), &elementLoc,4);
13482 + elementLoc = dslhal_support_byteSwap32(elementLoc);
13483 + dprintf(3,"Host IF Location: 0x%x Struct1 Location: 0x%x Element Location: 0x%x \n",hostIfLoc, structLoc, elementLoc);
13484 + rc += dslhal_support_blockWrite(localBuffer,(PVOID)(elementLoc+(offset3*4)),numBytes);
13485 + if (rc)
13486 + return DSLHAL_ERROR_BLOCK_READ;
13487 + return DSLHAL_ERROR_NO_ERRORS;
13488 +}
13489 +
13490 +/********************************************************************************************
13491 +* FUNCTION NAME: dslhal_api_dspInterfaceRead()
13492 +*
13493 +*********************************************************************************************
13494 +* DESCRIPTION:
13495 +* Reads from a Generic Location in the DSP Host Interface
13496 +*
13497 +* Return: 0 success
13498 +* 1 failed
13499 +*
13500 +* NOTE:
13501 +* DSP image is based on LITTLE endian
13502 +*
13503 +********************************************************************************************/
13504 +unsigned int dslhal_api_dspInterfaceRead(tidsl_t * ptidsl,unsigned int baseAddr, unsigned int numOffsets,
13505 + unsigned int *offsets, unsigned char *localBuffer, unsigned int numBytes)
13506 +{
13507 + int rc=0, off=0;
13508 + unsigned int prevAddr,currAddr;
13509 + prevAddr = baseAddr;
13510 + if(numBytes<=0 || !localBuffer || !ptidsl || !offsets)
13511 + {
13512 + dprintf(3,"Invalid input parameter \n");
13513 + return DSLHAL_ERROR_INVALID_PARAM;
13514 + }
13515 + for(off=0;off<numOffsets-1;off++)
13516 + {
13517 + rc += dslhal_support_blockRead((PVOID)(prevAddr+(4*offsets[off])), &currAddr,4);
13518 + currAddr = dslhal_support_byteSwap32(currAddr);
13519 + prevAddr = currAddr;
13520 + dprintf(5,"Curr Addr = 0x%x Current Level: %d \n",currAddr,off);
13521 + }
13522 + currAddr = currAddr + offsets[numOffsets-1]*4;
13523 + rc += dslhal_support_blockRead((PVOID)(currAddr),localBuffer,numBytes);
13524 + if (rc)
13525 + return DSLHAL_ERROR_BLOCK_READ;
13526 + return DSLHAL_ERROR_NO_ERRORS;
13527 +}
13528 +
13529 +/********************************************************************************************
13530 +* FUNCTION NAME: dslhal_api_dspInterfaceWrite()
13531 +*
13532 +*********************************************************************************************
13533 +* DESCRIPTION:
13534 +* Writes to a Generic Location in the DSP Host Interface
13535 +*
13536 +* Return: 0 success
13537 +* 1 failed
13538 +*
13539 +* NOTE:
13540 +* DSP image is based on LITTLE endian
13541 +*
13542 +********************************************************************************************/
13543 +unsigned int dslhal_api_dspInterfaceWrite(tidsl_t * ptidsl,unsigned int baseAddr, unsigned int numOffsets,
13544 + unsigned int *offsets,unsigned char *localBuffer, unsigned int numBytes)
13545 +{
13546 +
13547 + int rc=0, off=0;
13548 + unsigned int prevAddr,currAddr;
13549 + prevAddr = baseAddr;
13550 + if(numBytes<=0 || !localBuffer || !ptidsl || !offsets)
13551 + {
13552 + dprintf(3,"Invalid input parameter \n");
13553 + return DSLHAL_ERROR_INVALID_PARAM;
13554 + }
13555 + for(off=0;off<numOffsets-1;off++)
13556 + {
13557 + rc += dslhal_support_blockRead((PVOID)(prevAddr+(4*offsets[off])), &currAddr,4);
13558 + currAddr = dslhal_support_byteSwap32(currAddr);
13559 + prevAddr = currAddr;
13560 + dprintf(5,"Curr Addr = 0x%x Current Level: %d \n",currAddr,off);
13561 + }
13562 + currAddr = currAddr + offsets[numOffsets-1]*4;
13563 + rc += dslhal_support_blockWrite(localBuffer,(PVOID)(currAddr),numBytes);
13564 + if (rc)
13565 + return DSLHAL_ERROR_BLOCK_READ;
13566 + return DSLHAL_ERROR_NO_ERRORS;
13567 +}
13568 +
13569 +
13570 +/******************************************************************************************
13571 + * FUNCTION NAME: dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
13572 + *
13573 + *******************************************************************************************
13574 + * DESCRIPTION: This fuction sends the passed mailbox command to the DSP
13575 + *
13576 + * INPUT: PITIDSLHW_T *ptidsl
13577 + * unsigned int cmd
13578 + *
13579 + * RETURN: 0 SUCCESS
13580 + * 1 FAILED
13581 + *
13582 + *****************************************************************************************/
13583 +/* Function is commented out for now since, its not tested */
13584 + /*unsigned int dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
13585 +{
13586 + int rc;
13587 +
13588 + dprintf(5, "dslhal_api_sendMailboxCommand\n");
13589 + rc = dslhal_support_writeHostMailbox(ptidsl, cmd, 0, 0, 0);
13590 + if(rc)
13591 + {
13592 + dprintf(1,"dslhal_api_sendMailboxCommand failed\n");
13593 + return DSLHAL_ERROR_CTRL_API_FAILURE;
13594 + }
13595 + return DSLHAL_ERROR_NO_ERRORS;
13596 +} */
13597 +
13598 +
13599 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_api.h linux.dev/drivers/atm/sangam_atm/dsl_hal_api.h
13600 --- linux.old/drivers/atm/sangam_atm/dsl_hal_api.h 1970-01-01 01:00:00.000000000 +0100
13601 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_api.h 2005-08-23 04:46:50.097843696 +0200
13602 @@ -0,0 +1,1721 @@
13603 +#ifndef __DSL_HAL_API_H__
13604 +#define __DSL_HAL_API_H__ 1
13605 +/*******************************************************************************
13606 +* FILE PURPOSE: DSL HAL to Application Interface for Sangam
13607 +*
13608 +********************************************************************************
13609 +* FILE NAME: dsl_application_interface.h
13610 +*
13611 +* DESCRIPTION:
13612 +* DSL-Application Interface Structures
13613 +*
13614 +*
13615 +* By: Ramakrishnan Parasuraman
13616 +*
13617 +* (C) Copyright 2003, Texas Instruments, Inc.
13618 +* History
13619 +* Data Version By Notes
13620 +* 06Feb03 0.00 RamP Initial Version Written
13621 +* 07Apr03 0.01 RamP Commented out typedefs
13622 +* 09Apr03 0.02 RamP Added deviceContext and extended
13623 +* dspVer to include bugfixes
13624 +* 14Apr03 0.03 RamP Added stateTransition to structure
13625 +* 16Apr03 0.04 RamP Removed typedefs; changed dspVer
13626 +* 22Apr03 0.05 RamP Moved acknowledgeInterrupt from
13627 +* (alpha) support module into this
13628 +* 24Apr03 0.06 RamP Moved the RSTATE enum from register
13629 +*
13630 +* 28Apr03 0.07 RamP Added additional parameter to the
13631 +* (alpha +) handleInterrupt function for intrSrc
13632 +* 14May03 0.08 RamP Added hybrid switching APIs
13633 +* (alpha ++) Added statistics fields in AppData
13634 +* Added netService identifier
13635 +* 20May03 0.09 RamP Added Inner/Outer pair API support.
13636 +* Added dying gasp message.
13637 +* 29May03 0.10 RamP Added coProfile structure
13638 +* 04Jun03 0.11 RamP Added margin per tone statistics,
13639 +* Added timing counters, added train
13640 +* failure functions,added config flags
13641 +* 06Jun03 0.12 RamP Added LED, STM Bert, dGasp LPR
13642 +* config API functions
13643 +* 09Jun03 0.13 RamP Added ATM Bert function, CO stats
13644 +* Moved stateTransition to ITIDSLHW
13645 +* (Beta) Moved configFlag to ITIDSLHW,
13646 +* Cleaned up fifoInfo structure
13647 +* Added US/DS R/S FEC parameters
13648 +* 21Aug03 0.14 RamP Added g.hs message buffer, us/ds
13649 +* bits n gains table, negoMsgs struct
13650 +* (act) bitswap stucts/indices, trainstate,
13651 +* Added functions for advanced config
13652 +* Added gross gain and line length
13653 +* 29Sep03 0.15 RamP Added tokens for advanced config
13654 +* module api functions
13655 +* 12Oct03 0.16 RamP Added adsl2Msgs structure with worst
13656 +* case size for variable length msgs
13657 +* Added API function prototypes
13658 +* 21Oct03 0.17 RamP Added typedef for current modem
13659 +* user settings
13660 +* 28Oct03 0.18 RamP Added function to config blackout
13661 +* bitmap in the RMSGPCB message
13662 +* 20Nov03 0.19 RamP Added functions for generic and
13663 +* host interface read - write
13664 +* 24Nov03 0.20 RamP Added enum for detailed state track
13665 +* Added element for state bit fields
13666 +* Addded rState for encoded main state
13667 +* Added blackout valid flag
13668 +* 26Dec03 0.21 RamP Added defines for oamFeature masks
13669 +* 30Dec03 0.22 RamP Increased sizes for cMsgPcb,RMsgPcb
13670 +* to incorporate DELT mode messages
13671 +* 30Dec03 0.23 RamP Added generic mailbox command fxn
13672 +*******************************************************************************/
13673 +
13674 +#ifdef INTERNAL_BUILD
13675 +#include <dsl_hal_api_pvt.h>
13676 +#endif
13677 +
13678 +#define NUM_PAGES 4
13679 +#define OAMFEATURE_AUTORETRAIN_MASK 0x00000001
13680 +#define OAMFEATURE_TC_SYNC_DETECT_MASK 0x00000002
13681 +#define OAMFEATURE_EOCAOC_INTERRUPT_MASK 0x00000004
13682 +#define OAMFEATURE_CONS_DISP_DISABLE_MASK 0x00000008
13683 +#define OAMFEATURE_GHSMSG_INTERRUPT_MASK 0x00000010
13684 +
13685 +typedef struct tagTIOIDINFO
13686 +{
13687 + unsigned int bState; /* addr->bDSPATURState */
13688 + unsigned int USConRate; /* US Conection Rates */
13689 + unsigned int DSConRate; /* DS Connection Rates */
13690 + unsigned int USPayload; /* ennic_tx_pullup*/
13691 + unsigned int DSPayload; /* ennic_indicate_receive_packet*/
13692 + unsigned int FrmMode; /* addr->atur_msg.framing_mode*/
13693 + unsigned int MaxFrmMode;
13694 + unsigned int TrainedPath; /* Status of the Modem in which trained (Fast or Interleaved Path) */
13695 + unsigned int TrainedMode; /* Status of the mode in which the modem is trained (G.dmt, T1.413, etc) */
13696 +
13697 + /* Superframe Count */
13698 + unsigned int usSuperFrmCnt; /* Num of US Superframes */
13699 + unsigned int dsSuperFrmCnt; /* Num of DS Superframes */
13700 +
13701 + /* LOS & SEF Stats */
13702 + unsigned int LOS_errors; /* Num of ADSL frames where loss-of-sync */
13703 + unsigned int SEF_errors; /* Num of severly errored ADSL frames - LOS > MAXBADSYNC ADSL frames */
13704 + unsigned int coLosErrors; /* CO LOS Defects */
13705 + unsigned int coRdiErrors; /* CO RDI defects */
13706 + /* CRC Stats */
13707 + unsigned int usICRC_errors; /* Num of Upstream CRC errored ADSL frames on Interleaved Path */
13708 + unsigned int usFCRC_errors; /* Num of Upstream CRC errored ADSL frames on Fast Path */
13709 + unsigned int dsICRC_errors; /* Num of Downstream CRC errored ADSL frames on Interleaved Path */
13710 + unsigned int dsFCRC_errors; /* Num of Downstream CRC errored ADSL frames on Fast Path */
13711 +
13712 + /* FEC Stats */
13713 + unsigned int usIFEC_errors; /* Num of Upstream FEC errored (corrected) ADSL frames on Interleaved Path */
13714 + unsigned int usFFEC_errors; /* Num of Upstream FEC errored (corrected) ADSL frames on Fast Path */
13715 + unsigned int dsIFEC_errors; /* Num of Downstream FEC errored (corrected) ADSL frames on Interleaved Path */
13716 + unsigned int dsFFEC_errors; /* Num of Downstream FEC errored (corrected) ADSL frames on Fast Path */
13717 +
13718 + /* NCD Stats */
13719 + unsigned int usINCD_error; /* UpStream No Cell Delineation on Interleaved Path */
13720 + unsigned int usFNCD_error; /* UpStream No Cell Delineation on Fast Path */
13721 + unsigned int dsINCD_error; /* Downstream No Cell Delineation on Interleaved Path */
13722 + unsigned int dsFNCD_error; /* Downstream No Cell Delineation on Fast Path */
13723 +
13724 + /* LCD Stats */
13725 + unsigned int usILCD_errors; /* UpStream Loss of Cell Delineation (within the same connection) on Interleaved Path */
13726 + unsigned int usFLCD_errors; /* UpStream Loss of Cell Delineation (within the same connection) on Fast Path */
13727 + unsigned int dsILCD_errors; /* Downstream Loss of Cell Delineation (within the same connection) on Interleaved Path */
13728 + unsigned int dsFLCD_errors; /* Downstream Loss of Cell Delineation (within the same connection) on Fast Path */
13729 +
13730 + /* HEC Stats */
13731 + unsigned int usIHEC_errors; /* Num of Upstream HEC errored ADSL frames on Interleaved Path */
13732 + unsigned int usFHEC_errors; /* Num of Upstream HEC errored ADSL frames on Fast Path */
13733 + unsigned int dsIHEC_errors; /* Num of Downstream HEC errored ADSL frames on Interleaved Path */
13734 + unsigned int dsFHEC_errors; /* Num of Downstream HEC errored ADSL frames on Fast Path */
13735 +
13736 + /* Upstream ATM Stats */
13737 + unsigned int usAtm_count[2]; /* Upstream Good Cell Count */
13738 + unsigned int usIdle_count[2]; /* Upstream Idle Cell Count */
13739 + unsigned int usPdu_count[2]; /* UpStream PDU Count */
13740 +
13741 + /* Downstream ATM Stats */
13742 + unsigned int dsGood_count[2]; /* Downstream Good Cell Count */
13743 + unsigned int dsIdle_count[2]; /* Downstream Idle Cell Count */
13744 + unsigned int dsBadHec_count[2]; /* Downstream Bad Hec Cell Count */
13745 + unsigned int dsOVFDrop_count[2]; /* Downstream Overflow Dropped Cell Count */
13746 + unsigned int dsPdu_count[2]; /* Downstream PDU Count */
13747 + /* (only looks for end of pdu on good atm cells received, */
13748 + /* not on Bad_Hec or Overflow cell) */
13749 +
13750 + unsigned int dsLineAttn; /* DS Line Attenuation */
13751 + unsigned int dsMargin; /* Measured DS MArgin */
13752 +
13753 + unsigned int usLineAttn;
13754 + unsigned int usMargin;
13755 +
13756 + unsigned char bCMsgs1[6];
13757 + unsigned char bRMsgs1[6];
13758 + unsigned char bCRates2;
13759 + unsigned char bRRates2;
13760 + unsigned char bRRates1[4][11];
13761 + unsigned char bCMsgs2[4];
13762 + unsigned char bCRates1[4][30];
13763 + unsigned char bRMsgs2[4];
13764 +
13765 + unsigned int USPeakCellRate;
13766 +
13767 + unsigned int dsl_status;
13768 + unsigned int dsl_modulation;
13769 + unsigned char dsl_ghsRxBuf[10][64];
13770 + unsigned char dsl_GHS_msg_type[2];
13771 +
13772 + int TxVCs[12];
13773 + int RxVCs[12];
13774 +
13775 + unsigned int vci_vpi_val;
13776 +
13777 + unsigned char BitAllocTblDstrm[256];
13778 + unsigned char BitAllocTblUstrm[32];
13779 + signed char marginTblDstrm[256];
13780 + unsigned char rBng[512];
13781 + unsigned char cBng[126];
13782 + int usTxPower;
13783 + int dsTxPower;
13784 + short rxSnrPerBin0[256];
13785 + short rxSnrPerBin1[256];
13786 + short rxSnrPerBin2[256];
13787 +
13788 + unsigned int StdMode;
13789 + unsigned int atucVendorId;
13790 + unsigned char currentHybridNum;
13791 + unsigned char atucRevisionNum;
13792 + unsigned int trainFails;
13793 + unsigned int trainFailStates[30];
13794 + unsigned int idleTick;
13795 + unsigned int initTick;
13796 + unsigned int showtimeTick;
13797 + unsigned char dsFastParityBytesPerSymbol;
13798 + unsigned char dsIntlvParityBytesPerSymbol;
13799 + unsigned char dsSymbolsPerCodeWord;
13800 + unsigned int dsInterleaverDepth;
13801 + unsigned char usFastParityBytesPerSymbol;
13802 + unsigned char usIntlvParityBytesPerSymbol;
13803 + unsigned char usSymbolsPerCodeWord;
13804 + unsigned int usInterleaverDepth;
13805 + unsigned int atmBertBitCountLow;
13806 + unsigned int atmBertBitCountHigh;
13807 + unsigned int atmBertBitErrorCountLow;
13808 + unsigned int atmBertBitErrorCountHigh;
13809 + unsigned int lineLength;
13810 + unsigned int grossGain;
13811 + int rxNoisePower0[256];
13812 + int rxNoisePower1[256];
13813 +}TIOIDINFO,*PTIOIDINFO;
13814 +
13815 +typedef struct{
13816 + unsigned char bCMsgs1[6];
13817 + unsigned char bCRates2;
13818 + unsigned char bRRates2;
13819 + unsigned char bRRates1[4][11];
13820 + unsigned char bCMsgs2[4];
13821 + unsigned char bCRates1[4][30];
13822 + unsigned char bCRatesRA[4][30];
13823 + unsigned char bRMsgs2[4];
13824 + unsigned char bRRatesRA[4];
13825 + unsigned char bRMsgsRA[12];
13826 + unsigned char bCMsgsRA[6];
13827 +}negoMsgs;
13828 +
13829 +typedef struct{
13830 + unsigned char cMsgFmt[2];
13831 + unsigned char rMsgFmt[2];
13832 + unsigned char cMsgPcb[12];
13833 + unsigned char rMsgPcb[70];
13834 + unsigned char dummy1[2];
13835 + unsigned char cMsg1[40];
13836 + unsigned char rMsg1[4];
13837 + unsigned char cMsg2[8];
13838 + unsigned char rMsg2[64];
13839 + unsigned char cParams[264];
13840 + unsigned char rParams[2088];
13841 + unsigned short cMsgPcbLen;
13842 + unsigned short rMsgPcbLen;
13843 + unsigned short cMsg1Len;
13844 + unsigned short rMsg1Len;
13845 + unsigned short cMsg2Len;
13846 + unsigned short rMsg2Len;
13847 + unsigned short cParamsLen;
13848 + unsigned short rParamsLen;
13849 +}adsl2Msgs;
13850 +
13851 +typedef struct{
13852 + unsigned char rMsg1Ld[16];
13853 + unsigned char rMsg2Ld[260];
13854 + unsigned char rMsg3Ld[260];
13855 + unsigned char rMsg4Ld[260];
13856 + unsigned char rMsg5Ld[260];
13857 + unsigned char rMsg6Ld[260];
13858 + unsigned char rMsg7Ld[260];
13859 + unsigned char rMsg8Ld[260];
13860 + unsigned char rMsg9Ld[260];
13861 + unsigned char cMsg1Ld[16];
13862 + unsigned char cMsg2Ld[260];
13863 + unsigned char cMsg3Ld[132];
13864 + unsigned char cMsg4Ld[68];
13865 + unsigned char cMsg5Ld[68];
13866 + unsigned short rMsg1LdLen;
13867 + unsigned short rMsgxLdLen;
13868 + unsigned short cMsg1LdLen;
13869 + unsigned short cMsg2LdLen;
13870 + unsigned short cMsg3LdLen;
13871 + unsigned short cMsg4LdLen;
13872 + unsigned short cMsg5LdLen;
13873 + unsigned short dummy8;
13874 +}adsl2DeltMsgs;
13875 +
13876 +typedef struct{
13877 + unsigned char trellisFlag;
13878 + unsigned char rateAdaptFlag;
13879 + unsigned char marginMonitorTraining;
13880 + unsigned char marginMonitorShowtime;
13881 + signed char marginThreshold;
13882 + unsigned char disableLosFlag;
13883 + unsigned char aturConfig[30];
13884 + unsigned char eocVendorId[8];
13885 + unsigned char eocSerialNumber[32];
13886 + unsigned char eocRevisionNumber[4];
13887 +}currentPhySettings;
13888 +
13889 +
13890 +typedef struct
13891 +{
13892 + unsigned int PmemStartWtAddr; /* source address in host memory */
13893 + unsigned int OverlayXferCount; /* number of 32bit words to be transfered */
13894 + unsigned int BinAddr; /* destination address in dsp's pmem */
13895 + unsigned int overlayHostAddr;
13896 + unsigned int olayPageCrc32;
13897 + unsigned int SecOffset;
13898 +} OlayDP_Def;
13899 +
13900 +typedef struct
13901 +{
13902 + unsigned int timeStamp; /* TimeStp revision */
13903 + unsigned char major; /* Major revision */
13904 + unsigned char minor; /* Minor revision */
13905 + unsigned char bugFix; /* BugFix revision */
13906 + unsigned char buildNum; /* BuildNum revision */
13907 + unsigned char reserved; /* for future use */
13908 +}dspVer;
13909 +
13910 +typedef struct{
13911 + unsigned char major;
13912 + unsigned char minor;
13913 + unsigned char bugfix;
13914 + unsigned char buildNum;
13915 + unsigned int timeStamp;
13916 +}dslVer;
13917 +
13918 +typedef struct{
13919 + unsigned char bitSwapCommand[6];
13920 + unsigned char bitSwapBinNum[6];
13921 + unsigned char bitSwapSFrmCnt;
13922 +}dslBitSwapDef;
13923 +
13924 +typedef struct{
13925 + unsigned int aturState;
13926 + unsigned int subStateIndex;
13927 + unsigned int timeStamp;
13928 +}trainStateInfo;
13929 +
13930 +typedef struct{
13931 + unsigned char ctrlBits;
13932 + unsigned char infoBits;
13933 +}eocMessageDef;
13934 +
13935 +enum
13936 +{
13937 + RSTATE_TEST,
13938 + RSTATE_IDLE,
13939 + RSTATE_INIT,
13940 + RSTATE_HS,
13941 + RSTATE_RTDL,
13942 + RSTATE_SHOWTIME,
13943 +};
13944 +
13945 +typedef enum
13946 +{
13947 + ATU_RZERO1 = 100,
13948 + ATU_RTEST = 101,
13949 + ATU_RIDLE = 102,
13950 + ATU_RINIT = 103,
13951 + ATU_RRESET = 104,
13952 + GDMT_NSFLR = 105,
13953 + GDMT_TONE = 106,
13954 + GDMT_SILENT = 107,
13955 + GDMT_NEGO = 108,
13956 + GDMT_FAIL = 109,
13957 + GDMT_ACKX = 110,
13958 + GDMT_QUIET2 = 111,
13959 + ATU_RZERO2 = 200,
13960 + T1413_NSFLR = 201,
13961 + T1413_ACTREQ = 202,
13962 + T1413_ACTMON = 203,
13963 + T1413_FAIL = 204,
13964 + T1413_ACKX = 205,
13965 + T1413_QUIET2 = 206,
13966 + ATU_RQUIET2 = 207,
13967 + ATU_RREVERB1 = 208,
13968 + ATU_RQUIET3 = 209,
13969 + ATU_RECT = 210,
13970 + ATU_RREVERB2 = 211,
13971 + ATU_RSEGUE1 = 212,
13972 + ATU_RREVERB3 = 213,
13973 + ATU_RSEGUE2 = 214,
13974 + ATU_RRATES1 = 215,
13975 + ATU_RMSGS1 = 216,
13976 + ATU_RMEDLEY = 217,
13977 + ATU_RREVERB4 = 218,
13978 + ATU_RSEGUE3 = 219,
13979 + ATU_RMSGSRA = 220,
13980 + ATU_RRATESRA = 221,
13981 + ATU_RREVERBRA = 222,
13982 + ATU_RSEGUERA = 223,
13983 + ATU_RMSGS2 = 224,
13984 + ATU_RRATES2 = 225,
13985 + ATU_RREVERB5 = 226,
13986 + ATU_RSEGUE4 = 227,
13987 + ATU_RBNG = 228,
13988 + ATU_RREVERB6 = 229,
13989 + ATU_RSHOWTIME = 230,
13990 + ATU_RZERO3 = 300,
13991 + ADSL2_QUIET1 = 301,
13992 + ADSL2_COMB1 = 302,
13993 + ADSL2_QUIET2 = 303,
13994 + ADSL2_COMB2 = 304,
13995 + ADSL2_ICOMB1 = 305,
13996 + ADSL2_LINEPROBE = 306,
13997 + ADSL2_QUIET3 = 307,
13998 + ADSL2_COMB3 = 308,
13999 + ADSL2_ICOMB2 = 309,
14000 + ADSL2_RMSGFMT = 310,
14001 + ADSL2_RMSGPCB = 311,
14002 + ADSL2_REVERB1 = 312,
14003 + ADSL2_QUIET4 = 313,
14004 + ADSL2_REVERB2 = 314,
14005 + ADSL2_QUIET5 = 315,
14006 + ADSL2_REVERB3 = 316,
14007 + ADSL2_ECT = 317,
14008 + ADSL2_REVERB4 = 318,
14009 + ADSL2_SEGUE1 = 319,
14010 + ADSL2_REVERB5 = 320,
14011 + ADSL2_SEGUE2 = 321,
14012 + ADSL2_RMSG1 = 322,
14013 + ADSL2_MEDLEY = 323,
14014 + ADSL2_EXCHANGE = 324,
14015 + ADSL2_RMSG2 = 325,
14016 + ADSL2_REVERB6 = 326,
14017 + ADSL2_SEGUE3 = 327,
14018 + ADSL2_RPARAMS = 328,
14019 + ADSL2_REVERB7 = 329,
14020 + ADSL2_SEGUE4 = 330,
14021 + ATU_RZERO4 = 400,
14022 + DELT_SEGUE1 = 401,
14023 + DELT_REVERB5 = 402,
14024 + DELT_SEGUE2 = 403,
14025 + DELT_EXCHANGE = 404,
14026 + DELT_SEGUELD = 405,
14027 + DELT_RMSGLD = 406,
14028 + DELT_QUIET1LD = 407,
14029 + DELT_QUIET2LD = 408,
14030 + DELT_RACK1 = 409,
14031 + DELT_RNACK1 = 410,
14032 + DELT_QUIETLAST = 411
14033 +} modemStates_t;
14034 +
14035 +enum
14036 +{
14037 + DSLTRAIN_NO_MODE,
14038 + DSLTRAIN_MULTI_MODE,
14039 + DSLTRAIN_T1413_MODE,
14040 + DSLTRAIN_GDMT_MODE,
14041 + DSLTRAIN_GLITE_MODE
14042 +};
14043 +
14044 +enum
14045 +{
14046 + ID_RESTORE_DEFAULT_LED,
14047 + ID_DSL_LINK_LED,
14048 + ID_DSL_ACT_LED
14049 +};
14050 +
14051 +typedef struct _ITIDSLHW
14052 +{
14053 + /* struct _TIDSL_IHwVtbl * pVtbl; */
14054 + unsigned char* fwimage;
14055 + void* pmainAddr;
14056 + void* pOsContext;
14057 + unsigned int ReferenceCount;
14058 + unsigned int netService;
14059 +
14060 + int InitFlag;
14061 +
14062 + int imagesize;
14063 +
14064 + unsigned int lConnected;
14065 + unsigned int bStatisticsInitialized;
14066 + unsigned int rState;
14067 + unsigned int bShutdown;
14068 + unsigned int blackOutValid_f;
14069 + unsigned char blackOutBits[64];
14070 + unsigned int bAutoRetrain;
14071 + volatile unsigned int bOverlayPageLoaded;
14072 + unsigned int stateTransition;
14073 + unsigned int configFlag;
14074 + unsigned int dsBitSwapInx;
14075 + unsigned int usBitSwapInx;
14076 + unsigned int trainStateInx;
14077 + unsigned int usEocMsgInx;
14078 + unsigned int dsEocMsgInx;
14079 + unsigned int reasonForDrop;
14080 + TIOIDINFO AppData;
14081 + dspVer dspVer;
14082 +
14083 + OlayDP_Def olayDpPage[NUM_PAGES];
14084 + OlayDP_Def coProfiles;
14085 + OlayDP_Def constDisplay;
14086 + dslBitSwapDef dsBitSwap[30];
14087 + dslBitSwapDef usBitSwap[30];
14088 + trainStateInfo trainHistory[120];
14089 + eocMessageDef usEocMsgBuf[30];
14090 + eocMessageDef dsEocMsgBuf[30];
14091 + adsl2Msgs adsl2TrainingMessages;
14092 + adsl2DeltMsgs adsl2DiagnosticMessages;
14093 + unsigned int modemStateBitField[4];
14094 +#ifdef INTERNAL_BUILD
14095 + internalParameters internalVars;
14096 +#endif
14097 +} ITIDSLHW_T, *PITIDSLHW_T, tidsl_t;
14098 +
14099 +
14100 +/**********************************************************************************
14101 +* API proto type defines
14102 +**********************************************************************************/
14103 +
14104 +/******************************************************************************************
14105 +* FUNCTION NAME: dslhal_api_dslStartup
14106 +*
14107 +*******************************************************************************************
14108 +* DESCRIPTION: Entry point to initialize and load ax5 daughter board
14109 +*
14110 +* INPUT: PITIDSLHW_T *ppIHw
14111 +*
14112 +* RETURN: 0 --succeeded
14113 +* 1 --Failed
14114 +*
14115 +* Notes: external function osAllocateMemory(), osZeroMemory(), osLoadFWImage() are required
14116 +*****************************************************************************************/
14117 +int dslhal_api_dslStartup
14118 +(
14119 + PITIDSLHW_T *ppIHw
14120 +);
14121 +
14122 +
14123 +/********************************************************************************************
14124 +* FUNCTION NAME: dslhal_api_gatherStatistics
14125 +*
14126 +*********************************************************************************************
14127 +* DESCRIPTION: Read statistical infromation from ax5 modem daugter card.
14128 +* Input: tidsl_t *ptidsl
14129 +*
14130 +* Return: 0 success
14131 +* 1 failed
14132 +*
14133 +********************************************************************************************/
14134 +
14135 +void dslhal_api_gatherStatistics
14136 +(
14137 + tidsl_t * ptidsl
14138 +);
14139 +
14140 +
14141 +/********************************************************************************************
14142 +* FUNCTION NAME: dslhal_api_initStatistics
14143 +*
14144 +*********************************************************************************************
14145 +* DESCRIPTION: init statistical infromation of ax5 modem daugter card.
14146 +*
14147 +* Input: tidsl_t *ptidsl
14148 +*
14149 +* Return: NULL
14150 +*
14151 +********************************************************************************************/
14152 +
14153 +void dslhal_api_initStatistics
14154 +(
14155 + tidsl_t * ptidsl
14156 +);
14157 +
14158 +
14159 +
14160 +/******************************************************************************************
14161 +* FUNCTION NAME: dslhal_api_getDslDriverVersion
14162 +*
14163 +*******************************************************************************************
14164 +* DESCRIPTION: This routine supply DSL Driver version.
14165 +*
14166 +* INPUT: tidsl_t * ptidsl
14167 +* void *pVer, DSP Driver Version Pointer
14168 +*
14169 +* RETURN: 0 --succeeded
14170 +* 1 --Failed
14171 +* Note: See verdef_u.h for version structure definition.
14172 +*****************************************************************************************/
14173 +
14174 +void dslhal_api_getDslHalVersion
14175 +(
14176 + void *pVer
14177 +);
14178 +
14179 +/******************************************************************************************
14180 +* FUNCTION NAME: dslhal_api_dslShutdown
14181 +*
14182 +*******************************************************************************************
14183 +* DESCRIPTION: routine to shutdown ax5 modem and free the resource
14184 +*
14185 +* INPUT: tidsl_t *ptidsl
14186 +*
14187 +* RETURN: NULL
14188 +*
14189 +* Notes: external function osFreeMemory() is required.
14190 +*****************************************************************************************/
14191 +
14192 +int dslhal_api_dslShutdown
14193 +(
14194 + tidsl_t *ptidsl
14195 +);
14196 +
14197 +
14198 +/******************************************************************************************
14199 +* FUNCTION NAME: dslhal_api_getDspVersion
14200 +*
14201 +*******************************************************************************************
14202 +* DESCRIPTION: This routine supply AX5 daugther card DSP version.
14203 +*
14204 +* INPUT: tidsl_t * ptidsl
14205 +* void *pVer, DSP version struct is returned starting at this pointer
14206 +*
14207 +* RETURN: 0 --succeeded
14208 +* 1 --Failed
14209 +*
14210 +*****************************************************************************************/
14211 +
14212 +int dslhal_api_getDspVersion
14213 +(
14214 + tidsl_t *ptidsl,
14215 + void *pVer
14216 +);
14217 +
14218 +
14219 +/********************************************************************************************
14220 +* FUNCTION NAME: dslhal_diags_digi_memTestA()
14221 +*
14222 +*********************************************************************************************
14223 +* DESCRIPTION: This function does the digital tests on the DSP. It does the DSP ID test,
14224 +* memory tests on the external and internal memories of DSP, Codec Interconnect
14225 +* test and Interrupt Test.
14226 +*
14227 +* Input: Test selects the test to be performed based on the elements set of 9 element
14228 +* array passed the the parameter.
14229 +*
14230 +* Return: Status of the Tests Failed
14231 +*
14232 +********************************************************************************************/
14233 +
14234 +unsigned int dslhal_diags_digi_memTestA
14235 +(
14236 +unsigned int* Test
14237 +);
14238 +
14239 +
14240 +/********************************************************************************************
14241 +* FUNCTION NAME: dslhal_diags_digi_memTestB()
14242 +*
14243 +*********************************************************************************************
14244 +* DESCRIPTION: This function does the digital tests on the DSP. It does the DSP ID test,
14245 +* memory tests on the external and internal memories of DSP, Codec Interconnect
14246 +* test and Interrupt Test.
14247 +*
14248 +* Input: Test selects the digital test to be performed.
14249 +*
14250 +* Return: Status of the Tests Failed
14251 +*
14252 +********************************************************************************************/
14253 +
14254 +unsigned int dslhal_diags_digi_memTestB
14255 +(
14256 +unsigned int Test,
14257 +unsigned int *Status
14258 +);
14259 +
14260 +
14261 +/********************************************************************************************
14262 +* FUNCTION NAME: dslhal_diags_anlg_tonesTestA()
14263 +*
14264 +*********************************************************************************************
14265 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14266 +* tones and Medley's with missing tones. These signals are defined in ITU
14267 +* G.992.1 ADSL Standards.
14268 +*
14269 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14270 +* Array is a 64 element unsigned integer type array. The element of this array
14271 +* describe which tones are to be generated by selecting the element of
14272 +* the array to be non zero.
14273 +* Return: NULL
14274 +*
14275 +********************************************************************************************/
14276 +
14277 +void dslhal_diags_anlg_tonesTestA
14278 +(
14279 +unsigned int Test,
14280 +unsigned int* Array
14281 +);
14282 +
14283 +
14284 +/********************************************************************************************
14285 +* FUNCTION NAME: dslhal_diags_anlg_tonesTestB()
14286 +*
14287 +*********************************************************************************************
14288 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14289 +* tones and Medley's with missing tones. These signals are defined in ITU
14290 +* G.992.1 ADSL Standards.
14291 +*
14292 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14293 +* Array is a 64 element unsigned integer type array. The element of this array
14294 +* describe which tones are to be generated by selecting the element of
14295 +* the array to be non zero.
14296 +* Return: NULL
14297 +*
14298 +********************************************************************************************/
14299 +
14300 +void dslhal_diags_anlg_tonesTestB
14301 +(
14302 +unsigned int Test,
14303 +unsigned int Tones
14304 +);
14305 +
14306 +/********************************************************************************************
14307 +* FUNCTION NAME: dslhal_diags_anlg_rxNoiseTest()
14308 +*
14309 +*********************************************************************************************
14310 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14311 +* tones and Medley's with missing tones. These signals are defined in ITU
14312 +* G.992.1 ADSL Standards.
14313 +*
14314 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14315 +* Tones selects the .
14316 +* Return: NULL
14317 +*
14318 +********************************************************************************************/
14319 +
14320 +void dslhal_diags_anlg_rxNoiseTest
14321 +(int agcFlag,
14322 +short pga1,
14323 +short pga2,
14324 +short pga3,
14325 +short aeq
14326 +);
14327 +
14328 +/********************************************************************************************
14329 +* FUNCTION NAME: dslhal_diags_anlg_ecNoiseTest()
14330 +*
14331 +*********************************************************************************************
14332 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
14333 +* tones and Medley's with missing tones. These signals are defined in ITU
14334 +* G.992.1 ADSL Standards.
14335 +*
14336 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
14337 +* Tones selects the .
14338 +* Return: NULL
14339 +*
14340 +********************************************************************************************/
14341 +
14342 +void dslhal_diags_anlg_ecNoiseTest
14343 +(int agcFlag,
14344 +short pga1,
14345 +short pga2,
14346 +short pga3,
14347 +short aeq
14348 +);
14349 +
14350 +
14351 +/********************************************************************************************
14352 +* FUNCTION NAME: dslhal_api_pollTrainingStatus()
14353 +*
14354 +*********************************************************************************************
14355 +* DESCRIPTION: code to decode modem status and to start modem training
14356 +*
14357 +* Input: tidsl_t *ptidsl
14358 +*
14359 +* Return: 0-? status mode training
14360 +* -1 failed
14361 +*
14362 +********************************************************************************************/
14363 +int dslhal_api_pollTrainingStatus
14364 +(
14365 + tidsl_t *ptidsl
14366 +);
14367 +
14368 +
14369 +
14370 +/********************************************************************************************
14371 +* FUNCTION NAME: dslhal_api_handleTrainingInterrupt()
14372 +*
14373 +*********************************************************************************************
14374 +* DESCRIPTION: Code to handle ax5 hardware interrupts
14375 +*
14376 +* Input: tidsl_t *ptidsl
14377 +* int *pMsg, pointer to returned hardware messages. Each byte represent a messge
14378 +* int *pTag, pointer to returned hardware message tags. Each byte represent a tag.
14379 +* Return: 0 success
14380 +* 1 failed
14381 +*
14382 +********************************************************************************************/
14383 +int dslhal_api_handleTrainingInterrupt
14384 +(
14385 + tidsl_t *ptidsl,
14386 + int intrSource
14387 +);
14388 +
14389 +/******************************************************************************************
14390 + * FUNCTION NAME: dslhal_api_setEocSerialNumber(tidsl_t *ptidsl,char *SerialNumber)
14391 + *
14392 + *******************************************************************************************
14393 + * DESCRIPTION: This fuction Sets the EOC Serial Number
14394 + *
14395 + * INPUT: PITIDSLHW_T *ptidsl
14396 + * char *SerialNumber : Input EOC Serial Number
14397 + *
14398 + * RETURN: 0 SUCCESS
14399 + * 1 FAILED
14400 + *
14401 + *****************************************************************************************/
14402 +unsigned int dslhal_api_setEocSerialNumber
14403 +(
14404 +tidsl_t *ptidsl,
14405 +char *SerialNumber
14406 +);
14407 +
14408 +/******************************************************************************************
14409 + * FUNCTION NAME: dslhal_api_setEocVendorId(tidsl_t *ptidsl,char *VendorID)
14410 + *
14411 + *******************************************************************************************
14412 + * DESCRIPTION: This fuction Sets the EOC Serial Number
14413 + *
14414 + * INPUT: PITIDSLHW_T *ptidsl
14415 + * char *VendorID : EOC Vendor ID
14416 + *
14417 + * RETURN: 0 SUCCESS
14418 + * 1 FAILED
14419 + *
14420 + *****************************************************************************************/
14421 +unsigned int dslhal_api_setEocVendorId
14422 +(
14423 +tidsl_t *ptidsl,
14424 +char *VendorID
14425 +);
14426 +
14427 +/******************************************************************************************
14428 + * FUNCTION NAME: dslhal_api_setEocRevisionNumber(tidsl_t *ptidsl,char *RevNum)
14429 + *
14430 + *******************************************************************************************
14431 + * DESCRIPTION: This fuction Sets the EOC Revision Number
14432 + *
14433 + * INPUT: PITIDSLHW_T *ptidsl
14434 + * char *RevNum : Input EOC Revision Number
14435 + *
14436 + * RETURN: 0 SUCCESS
14437 + * 1 FAILED
14438 + *
14439 + *****************************************************************************************/
14440 +unsigned int dslhal_api_setEocRevisionNumber
14441 +(
14442 +tidsl_t *ptidsl,
14443 +char *RevNumber
14444 +);
14445 +
14446 +/******************************************************************************************
14447 + * FUNCTION NAME: dslhal_api_setAturConfig(tidsl_t *ptidsl,char *ATURConfig)
14448 + *
14449 + *******************************************************************************************
14450 + * DESCRIPTION: This fuction Sets the EOC ATUR Config Register
14451 + *
14452 + * INPUT: PITIDSLHW_T *ptidsl
14453 + * char *RevNum : Input EOC ATUR Config Register
14454 + *
14455 + * RETURN: 0 SUCCESS
14456 + * 1 FAILED
14457 + *
14458 + *****************************************************************************************/
14459 +unsigned int dslhal_api_setAturConfig
14460 +(
14461 +tidsl_t *ptidsl,
14462 +char *ATURConfig
14463 +);
14464 +
14465 +/******************************************************************************************
14466 + * FUNCTION NAME: dslhal_api_disableLosAlarm(tidsl_t *ptidsl, unsigned int set)
14467 + *
14468 + *******************************************************************************************
14469 + * DESCRIPTION: This fuction disables all the LOS alarms
14470 + *
14471 + * INPUT: PITIDSLHW_T *ptidsl
14472 + * unsigned int set // if set == TRUE : Disable LOS alarms, else enable
14473 + *
14474 + * RETURN: 0 SUCCESS
14475 + * 1 FAILED
14476 + * NOTES: Currently not supported in any version other than MR4 Patch release..
14477 + *****************************************************************************************/
14478 +unsigned int dslhal_api_disableLosAlarm
14479 +(
14480 +tidsl_t *ptidsl,
14481 +unsigned int
14482 +);
14483 +
14484 +/******************************************************************************************
14485 + * FUNCTION NAME: dslhal_api_sendIdle(tidsl_t *ptidsl)
14486 + *
14487 + *******************************************************************************************
14488 + * DESCRIPTION: This fuction sends the CMD_IDLE message to the DSP
14489 + *
14490 + * INPUT: PITIDSLHW_T *ptidsl
14491 + *
14492 + * RETURN: 0 SUCCESS
14493 + * 1 FAILED
14494 + *
14495 + *****************************************************************************************/
14496 +unsigned int dslhal_api_sendIdle
14497 +(
14498 +tidsl_t *ptidsl
14499 +);
14500 +
14501 +/******************************************************************************************
14502 + * FUNCTION NAME: dslhal_api_sendQuiet(tidsl_t *ptidsl)
14503 + *
14504 + *******************************************************************************************
14505 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14506 + *
14507 + * INPUT: PITIDSLHW_T *ptidsl
14508 + *
14509 + * RETURN: 0 SUCCESS
14510 + * 1 FAILED
14511 + *
14512 + *****************************************************************************************/
14513 +unsigned int dslhal_api_sendQuiet
14514 +(
14515 +tidsl_t *ptidsl
14516 +);
14517 +
14518 +/******************************************************************************************
14519 + * FUNCTION NAME: dslhal_api_sendDgasp(tidsl_t *ptidsl)
14520 + *
14521 + *******************************************************************************************
14522 + * DESCRIPTION: This fuction sends the HOST_DGASP message to the DSP
14523 + *
14524 + * INPUT: PITIDSLHW_T *ptidsl
14525 + *
14526 + * RETURN: 0 SUCCESS
14527 + * 1 FAILED
14528 + *
14529 + *****************************************************************************************/
14530 +unsigned int dslhal_api_sendDgasp
14531 +(
14532 +tidsl_t *ptidsl
14533 +);
14534 +
14535 +/******************************************************************************************
14536 + * FUNCTION NAME: dslhal_api_setMarginThreshold(tidsl_t *ptidsl, int threshold)
14537 + *
14538 + *******************************************************************************************
14539 + * DESCRIPTION: This fuction does sets the Margin threshold
14540 + *
14541 + * INPUT: PITIDSLHW_T *ptidsl
14542 + * int threshold
14543 + *
14544 + *
14545 + * RETURN: 0 SUCCESS
14546 + * 1 FAILED
14547 + *
14548 + *****************************************************************************************/
14549 +unsigned int dslhal_api_setMarginThreshold
14550 +(
14551 +tidsl_t *ptidsl,
14552 +int threshold
14553 +);
14554 +
14555 +
14556 +/******************************************************************************************
14557 + * FUNCTION NAME: dslhal_api_setMarginMonitorFlags(tidsl_t *ptidsl, unsigned int trainflag,unsigned int shwtflag)
14558 + *
14559 + *******************************************************************************************
14560 + * DESCRIPTION: This fuction does sets the Margin monitoring flag
14561 + *
14562 + * INPUT: PITIDSLHW_T *ptidsl
14563 + * unsigned int trainflag
14564 + * unsigned int shwtflag
14565 + *
14566 + * RETURN: 0 SUCCESS
14567 + * 1 FAILED
14568 + *
14569 + *****************************************************************************************/
14570 +unsigned int dslhal_api_setMarginMonitorFlags
14571 +(
14572 +tidsl_t *ptidsl,
14573 +unsigned int trainflag,
14574 +unsigned int shwtflag
14575 +);
14576 +
14577 +/******************************************************************************************
14578 +* FUNCTION NAME: dslhal_api_setRateAdaptFlag(tidsl_t *ptidsl)
14579 +*
14580 +*******************************************************************************************
14581 +* DESCRIPTION: This fuction Sets the Rate Adapt Enable Flag
14582 +*
14583 +* INPUT: PITIDSLHW_T *ptidsl
14584 +* unsigned int flag //if flag = TRUE set flag else reset
14585 +* RETURN: 0 SUCCESS
14586 +* 1 FAILED
14587 +*
14588 +*****************************************************************************************/
14589 +unsigned int dslhal_api_setRateAdaptFlag
14590 +(
14591 +tidsl_t *ptidsl,
14592 +unsigned int flag
14593 +);
14594 +
14595 +/******************************************************************************************
14596 +* FUNCTION NAME: dslhal_api_setTrellisFlag(tidsl_t *ptidsl, unsigned int flag)
14597 +*
14598 +*******************************************************************************************
14599 +* DESCRIPTION: This fuction Sets the Trellis Coding Enable Flag
14600 +*
14601 +* INPUT: PITIDSLHW_T *ptidsl
14602 +* unsigned int flag //if flag = TRUE set flag else reset
14603 +* RETURN: 0 SUCCESS
14604 +* 1 FAILED
14605 +*
14606 +*****************************************************************************************/
14607 +unsigned int dslhal_api_setTrellisFlag
14608 +(
14609 +tidsl_t *ptidsl,
14610 +unsigned int flag
14611 +);
14612 +
14613 +/******************************************************************************************
14614 +* FUNCTION NAME: dslhal_api_setMaxBitsPerCarrier(tidsl_t *ptidsl,unsigned int maxbits)
14615 +*
14616 +*******************************************************************************************
14617 +* DESCRIPTION: This fuction Sets the Maximum bits per carrier value
14618 +*
14619 +* INPUT: PITIDSLHW_T *ptidsl
14620 +* unsigned int maxbits : should be a value between 0-15
14621 +*
14622 +* RETURN: 0 SUCCESS
14623 +* 1 FAILED
14624 +*
14625 +*****************************************************************************************/
14626 +unsigned int dslhal_api_setMaxBitsPerCarrier
14627 +(
14628 +tidsl_t *ptidsl,
14629 +unsigned int maxbits
14630 +);
14631 +
14632 +/******************************************************************************************
14633 +* FUNCTION NAME: dslhal_api_setMaxInterleaverDepth(tidsl_t *ptidsl,unsigned int maxdepth)
14634 +*
14635 +*******************************************************************************************
14636 +* DESCRIPTION: This fuction Sets the Maximum Interleave Depth Supported
14637 +*
14638 +* INPUT: PITIDSLHW_T *ptidsl
14639 +* unsigned int maxdepth : Should be between 0 and 3 depending on intlv buffer
14640 +* size 64-512
14641 +* RETURN: 0 SUCCESS
14642 +* 1 FAILED
14643 +*
14644 +*****************************************************************************************/
14645 +unsigned int dslhal_api_setMaxInterleaverDepth
14646 +(
14647 +tidsl_t *ptidsl,
14648 +unsigned int maxdepth
14649 +);
14650 +
14651 +/******************************************************************************************
14652 +* FUNCTION NAME: dslhal_api_setTrainingMode(tidsl_t *ptidsl,unsigned int trainmode)
14653 +*
14654 +*******************************************************************************************
14655 +* DESCRIPTION: This fuction Sets the desired training mode(none/T1.413/G.dmt/G.lite)
14656 +*
14657 +* INPUT: PITIDSLHW_T *ptidsl
14658 +* unsigned int trainmode :Should be between 0 and 4; 0:No Mode 1:Multimode
14659 +* 2: T1.413, 3:G.dmt, 4: G.lite
14660 +* RETURN: 0 SUCCESS
14661 +* 1 FAILED
14662 +*
14663 +*****************************************************************************************/
14664 +
14665 +unsigned int dslhal_api_setTrainingMode
14666 +(
14667 +tidsl_t *ptidsl,
14668 +unsigned int trainmode
14669 +);
14670 +
14671 +/******************************************************************************************
14672 + * FUNCTION NAME: dslhal_api_dslRetrain(tidsl_t *ptidsl)
14673 + *
14674 + *******************************************************************************************
14675 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14676 + *
14677 + * INPUT: PITIDSLHW_T *ptidsl
14678 + *
14679 + * RETURN: 0 SUCCESS
14680 + * 1 FAILED
14681 + *
14682 + *****************************************************************************************/
14683 +unsigned int dslhal_api_dslRetrain
14684 +(
14685 +tidsl_t *ptidsl
14686 +);
14687 +
14688 +/********************************************************************************************
14689 +* FUNCTION NAME: dslhal_api_acknowledgeInterrupt()
14690 +*
14691 +*********************************************************************************************
14692 +* DESCRIPTION:
14693 +* Sets the host interrupt bit masks
14694 +*
14695 +* Return: 0 success
14696 +* 1 failed
14697 +*
14698 +* NOTE:
14699 +* DSP image is based on LITTLE endian
14700 +*
14701 +********************************************************************************************/
14702 +unsigned int dslhal_api_acknowledgeInterrupt
14703 +(tidsl_t * ptidsl
14704 +);
14705 +
14706 +/********************************************************************************************
14707 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
14708 +*
14709 +*********************************************************************************************
14710 +* DESCRIPTION:
14711 +* Sets the host interrupt bit masks
14712 +*
14713 +* Return: 0 success
14714 +* 1 failed
14715 +*
14716 +* NOTE:
14717 +* DSP image is based on LITTLE endian
14718 +*
14719 +********************************************************************************************/
14720 +unsigned int dslhal_api_disableDspHybridSelect
14721 +(tidsl_t * ptidsl,
14722 + unsigned int disable
14723 +);
14724 +
14725 +/********************************************************************************************
14726 +* FUNCTION NAME: dslhal_api_disableDspHybridSelect()
14727 +*
14728 +*********************************************************************************************
14729 +* DESCRIPTION:
14730 +* Sets the host interrupt bit masks
14731 +*
14732 +* Return: 0 success
14733 +* 1 failed
14734 +*
14735 +* NOTE:
14736 +* DSP image is based on LITTLE endian
14737 +*
14738 +********************************************************************************************/
14739 +unsigned int dslhal_api_selectHybrid
14740 +(tidsl_t * ptidsl,
14741 + unsigned int hybridNum
14742 +);
14743 +
14744 +/********************************************************************************************
14745 +* FUNCTION NAME: dslhal_api_reportHybridMetrics()
14746 +*
14747 +*********************************************************************************************
14748 +* DESCRIPTION:
14749 +* Sets the host interrupt bit masks
14750 +*
14751 +* Return: 0 success
14752 +* 1 failed
14753 +*
14754 +* NOTE:
14755 +* DSP image is based on LITTLE endian
14756 +*
14757 +********************************************************************************************/
14758 +unsigned int dslhal_api_reportHybridMetrics
14759 +(tidsl_t * ptidsl,
14760 + int *metric
14761 +);
14762 +
14763 +/******************************************************************************************
14764 + * FUNCTION NAME: dslhal_api_selectInnerOuterPair(tidsl_t *ptidsl, unsigned int pairSelect)
14765 + *
14766 + *******************************************************************************************
14767 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14768 + *
14769 + * INPUT: PITIDSLHW_T *ptidsl
14770 + *
14771 + * RETURN: 0 SUCCESS
14772 + * 1 FAILED
14773 + *
14774 + *****************************************************************************************/
14775 +
14776 +unsigned int dslhal_api_selectInnerOuterPair
14777 +(tidsl_t *ptidsl,
14778 +unsigned int pairSelect
14779 +);
14780 +
14781 +/******************************************************************************************
14782 + * FUNCTION NAME: dslhal_api_resetTrainFailureLog(tidsl_t *ptidsl, unsigned int pairSelect)
14783 + *
14784 + *******************************************************************************************
14785 + * DESCRIPTION: This fuction sends the CMD_QUIET message to the DSP
14786 + *
14787 + * INPUT: PITIDSLHW_T *ptidsl
14788 + *
14789 + * RETURN: 0 SUCCESS
14790 + * 1 FAILED
14791 + *
14792 + *****************************************************************************************/
14793 +
14794 +unsigned int dslhal_api_resetTrainFailureLog
14795 +(tidsl_t *ptidsl
14796 +);
14797 +
14798 +/********************************************************************************************
14799 +* FUNCTION NAME: dslhal_api_controlLed()
14800 +*
14801 +*********************************************************************************************
14802 +* DESCRIPTION:
14803 +* Sets the host interrupt bit masks
14804 +*
14805 +* Return: 0 success
14806 +* 1 failed
14807 +*
14808 +* NOTE:
14809 +* DSP image is based on LITTLE endian
14810 +*
14811 +********************************************************************************************/
14812 +unsigned int dslhal_api_configureLed
14813 +(tidsl_t * ptidsl,
14814 +unsigned int idLed,
14815 +unsigned int onOff
14816 +);
14817 +
14818 +/********************************************************************************************
14819 +* FUNCTION NAME: dslhal_api_configureExternBert()
14820 +*
14821 +*********************************************************************************************
14822 +* DESCRIPTION:
14823 +* Sets the host interrupt bit masks
14824 +*
14825 +* Return: 0 success
14826 +* 1 failed
14827 +*
14828 +* NOTE:
14829 +* DSP image is based on LITTLE endian
14830 +*
14831 +********************************************************************************************/
14832 +unsigned int dslhal_api_configureExternBert
14833 +(tidsl_t * ptidsl,
14834 +unsigned int configParm,
14835 +unsigned int parmVal
14836 +);
14837 +
14838 +/********************************************************************************************
14839 +* FUNCTION NAME: dslhal_api_configureAtmBert()
14840 +*
14841 +*********************************************************************************************
14842 +* DESCRIPTION:
14843 +* Sets the host interrupt bit masks
14844 +*
14845 +* Return: 0 success
14846 +* 1 failed
14847 +*
14848 +* NOTE:
14849 +* DSP image is based on LITTLE endian
14850 +*
14851 +********************************************************************************************/
14852 +unsigned int dslhal_api_configureAtmBert
14853 +(tidsl_t * ptidsl,
14854 +unsigned int configParm,
14855 +unsigned int parmVal
14856 +);
14857 +
14858 +/********************************************************************************************
14859 +* FUNCTION NAME: dslhal_api_configureDgaspLpr()
14860 +*
14861 +*********************************************************************************************
14862 +* DESCRIPTION:
14863 +* Sets the host interrupt bit masks
14864 +*
14865 +* Return: 0 success
14866 +* 1 failed
14867 +*
14868 +* NOTE:
14869 +* DSP image is based on LITTLE endian
14870 +*
14871 +********************************************************************************************/
14872 +unsigned int dslhal_api_configureDgaspLpr
14873 +(tidsl_t * ptidsl,
14874 +unsigned int configParm,
14875 +unsigned int parmVal
14876 +);
14877 +
14878 +/********************************************************************************************
14879 +* FUNCTION NAME: dslhal_advcfg_onOffPcb()
14880 +*
14881 +*********************************************************************************************
14882 +* DESCRIPTION:
14883 +* Sets the host interrupt bit masks
14884 +*
14885 +* Return: 0 success
14886 +* 1 failed
14887 +*
14888 +* NOTE:
14889 +* DSP image is based on LITTLE endian
14890 +*
14891 +********************************************************************************************/
14892 +unsigned int dslhal_advcfg_onOffPcb
14893 +(tidsl_t * ptidsl,
14894 +unsigned int onOff
14895 +);
14896 +
14897 +/********************************************************************************************
14898 +* FUNCTION NAME: dslhal_advcfg_onOffBitSwap()
14899 +*
14900 +*********************************************************************************************
14901 +* DESCRIPTION:
14902 +* Turns on / off the power cutback feature;
14903 +* Input
14904 +* usDs; 0 = us and 1 = ds;
14905 +* onOff; 0 = OFF and 1 = ON
14906 +*
14907 +* Return: 0 success
14908 +* 1 failed
14909 +*
14910 +* NOTE:
14911 +* DSP image is based on LITTLE endian
14912 +*
14913 +********************************************************************************************/
14914 +unsigned int dslhal_advcfg_onOffBitSwap
14915 +(tidsl_t * ptidsl,
14916 + unsigned int usDs,
14917 + unsigned int onOff
14918 +);
14919 +
14920 +/********************************************************************************************
14921 +* FUNCTION NAME: dslhal_advcfg_configDsTones()
14922 +*
14923 +*********************************************************************************************
14924 +* DESCRIPTION:
14925 +* Turns on / off specific tones in the downstream direction;
14926 +* Input
14927 +* pointer to the array specifying the tones to be turned on/off
14928 +*
14929 +*
14930 +* Return: 0 success
14931 +* 1 failed
14932 +*
14933 +* NOTE:
14934 +* DSP image is based on LITTLE endian
14935 +*
14936 +********************************************************************************************/
14937 +unsigned int dslhal_advcfg_configDsTones
14938 +(tidsl_t * ptidsl,
14939 + unsigned int *dsTones
14940 +);
14941 +
14942 +/********************************************************************************************
14943 +* FUNCTION NAME: dslhal_advcfg_getAocBitSwapBuffer()
14944 +*
14945 +*********************************************************************************************
14946 +* DESCRIPTION:
14947 +* Fetches the Tx/Rx AOC bitswap Buffer;
14948 +* Input
14949 +* Transmit / Receive buffer to be fetched
14950 +*
14951 +*
14952 +* Return: 0 success
14953 +* 1 failed
14954 +*
14955 +* NOTE:
14956 +* DSP image is based on LITTLE endian
14957 +*
14958 +********************************************************************************************/
14959 +unsigned int dslhal_advcfg_getAocBitswapBuffer
14960 +(tidsl_t * ptidsl,
14961 +unsigned int usDs
14962 +);
14963 +
14964 +/********************************************************************************************
14965 +* FUNCTION NAME: dslhal_advcfg_readTrainingMessages()
14966 +*
14967 +*********************************************************************************************
14968 +* DESCRIPTION:
14969 +* Reads all the training messages on demand;
14970 +* Input
14971 +* tidsl_t *ptidsl : Pointer to application structure
14972 +* void *msgStruct : Pointer to Message Structure
14973 +*
14974 +*
14975 +* Return: 0 success
14976 +* 1 failed
14977 +*
14978 +* NOTE:
14979 +* DSP image is based on LITTLE endian
14980 +*
14981 +********************************************************************************************/
14982 +unsigned int dslhal_advcfg_readTrainingMessages
14983 +(tidsl_t * ptidsl,
14984 +void *msgPtr
14985 +);
14986 +
14987 +/********************************************************************************************
14988 +* FUNCTION NAME: dslhal_advcfg_getTrainingState()
14989 +*
14990 +*********************************************************************************************
14991 +* DESCRIPTION:
14992 +* Reads all the training messages on demand;
14993 +* Input
14994 +* tidsl_t *ptidsl : Pointer to application structure
14995 +* void *msgStruct : Pointer to training state structure
14996 +*
14997 +*
14998 +* Return: 0 success
14999 +* 1 failed
15000 +*
15001 +* NOTE:
15002 +* DSP image is based on LITTLE endian
15003 +*
15004 +********************************************************************************************/
15005 +unsigned int dslhal_advcfg_getTrainingState
15006 +(tidsl_t * ptidsl,
15007 +void *statePtr
15008 +);
15009 +
15010 +/********************************************************************************************
15011 +* FUNCTION NAME: dslhal_advcfg_resetBitSwapMessageLog()
15012 +*
15013 +*********************************************************************************************
15014 +* DESCRIPTION:
15015 +* Clears the Aoc Bitswap Message Log
15016 +* Input
15017 +* tidsl_t *ptidsl : Pointer to application structure
15018 +* unsigned int usDs ; Upstream=0, Downstream=1
15019 +*
15020 +* Return: 0 success
15021 +* 1 failed
15022 +*
15023 +********************************************************************************************/
15024 +unsigned int dslhal_advcfg_resetBitSwapMessageLog
15025 +(tidsl_t * ptidsl,
15026 + unsigned int usDs
15027 +);
15028 +
15029 +/********************************************************************************************
15030 +* FUNCTION NAME: dslhal_advcfg_setConstellationBinNumber()
15031 +*
15032 +*********************************************************************************************
15033 +* DESCRIPTION:
15034 +* Specifies the bin number for which constellation data should be fetched
15035 +* Input
15036 +* tidsl_t *ptidsl : Pointer to application structure
15037 +* unsigned int binNum : constellation bin number whose data is required
15038 +*
15039 +* Return: 0 success
15040 +* 1 failed
15041 +*
15042 +********************************************************************************************/
15043 +unsigned int dslhal_advcfg_setConstellationBinNumber
15044 +(tidsl_t * ptidsl,
15045 + unsigned int binNum
15046 +);
15047 +
15048 +/********************************************************************************************
15049 +* FUNCTION NAME: dslhal_advcfg_resetTrainStateHistory()
15050 +*
15051 +*********************************************************************************************
15052 +* DESCRIPTION:
15053 +* Clears the Training State History Log
15054 +* Input
15055 +* tidsl_t *ptidsl : Pointer to application structure
15056 +*
15057 +*
15058 +* Return: 0 success
15059 +* 1 failed
15060 +*
15061 +********************************************************************************************/
15062 +unsigned int dslhal_advcfg_resetTrainStateHistory
15063 +(tidsl_t * ptidsl
15064 +);
15065 +
15066 +/********************************************************************************************
15067 +* FUNCTION NAME: dslhal_advcfg_getSnrPerBin()
15068 +*
15069 +*********************************************************************************************
15070 +* DESCRIPTION:
15071 +* Get SNR data per bin
15072 +* Input
15073 +* tidsl_t *ptidsl : Pointer to application structure
15074 +*
15075 +*
15076 +* Return: 0 success
15077 +* 1 failed
15078 +*
15079 +********************************************************************************************/
15080 +unsigned int dslhal_advcfg_getSnrPerBin
15081 +(tidsl_t * ptidsl,
15082 + unsigned int snrBufferOpt
15083 +);
15084 +
15085 +/********************************************************************************************
15086 +* FUNCTION NAME: dslhal_advcfg_logEocMessages()
15087 +*
15088 +*********************************************************************************************
15089 +* DESCRIPTION:
15090 +* Logs EOC messages sent by the Modem to the CO
15091 +* Input
15092 +* tidsl_t *ptidsl : Pointer to application structure
15093 +* unsigned int eocLowerBytes : Lower [1-5] bits of EOC Message
15094 +* unsigned int eocUpperBytes : Upper [6-13] bits of EOC Message
15095 +*
15096 +* Return: 0 success
15097 +* 1 failed
15098 +*
15099 +********************************************************************************************/
15100 +unsigned int dslhal_advcfg_logEocMessages
15101 +(tidsl_t * ptidsl,
15102 + unsigned int usDs,
15103 + unsigned int eocLowerBytes,
15104 + unsigned int eocUpperBytes
15105 +);
15106 +
15107 +/********************************************************************************************
15108 +* FUNCTION NAME: dslhal_advcfg_getReasonForDrop()
15109 +*
15110 +*********************************************************************************************
15111 +* DESCRIPTION:
15112 +* Reads the reason for dropping DSL connection;
15113 +* Input
15114 +* tidsl_t *ptidsl : Pointer to application structure
15115 +
15116 +*
15117 +*
15118 +* Return: 0 success
15119 +* 1 failed
15120 +*
15121 +* NOTE:
15122 +* DSP image is based on LITTLE endian
15123 +*
15124 +********************************************************************************************/
15125 +unsigned int dslhal_advcfg_getReasonForDrop
15126 +(tidsl_t * ptidsl
15127 +);
15128 +
15129 +/********************************************************************************************
15130 +* FUNCTION NAME: dslhal_advcfg_ctrlMaxAvgFineGains()
15131 +*
15132 +*********************************************************************************************
15133 +* DESCRIPTION:
15134 +* Turns on / off the host control for Max Avg Fine Gains; 0 = OFF and 1 = ON
15135 +*
15136 +* Return: 0 success
15137 +* 1 failed
15138 +*
15139 +* NOTE:
15140 +* DSP image is based on LITTLE endian
15141 +*
15142 +********************************************************************************************/
15143 +unsigned int dslhal_advcfg_ctrlMaxAvgFineGains
15144 +(tidsl_t * ptidsl,
15145 +unsigned int onOff
15146 +);
15147 +
15148 +
15149 +/********************************************************************************************
15150 +* FUNCTION NAME: dslhal_advcfg_setMaxAvgFineGain()
15151 +*
15152 +*********************************************************************************************
15153 +* DESCRIPTION:
15154 +* Set the Maximum Average Fine Gain Value
15155 +*
15156 +* Return: 0 success
15157 +* 1 failed
15158 +*
15159 +* NOTE:
15160 +* DSP image is based on LITTLE endian
15161 +*
15162 +********************************************************************************************/
15163 +unsigned int dslhal_advcfg_setMaxAvgFineGain
15164 +(tidsl_t * ptidsl,
15165 + short fineGain
15166 +);
15167 +/********************************************************************************************
15168 +* FUNCTION NAME: dslhal_advcfg_readPhySettings()
15169 +*
15170 +*********************************************************************************************
15171 +* DESCRIPTION:
15172 +* Reads the advanced Phy layer settings on demand;
15173 +* Input
15174 +* tidsl_t *ptidsl : Pointer to application structure
15175 +* void *cfgStruct : Pointer to Phy Config Structure
15176 +*
15177 +*
15178 +* Return: 0 success
15179 +* 1 failed
15180 +*
15181 +* NOTE:
15182 +* DSP image is based on LITTLE endian
15183 +*
15184 +********************************************************************************************/
15185 +unsigned int dslhal_advcfg_readPhySettings
15186 +(tidsl_t * ptidsl,
15187 +void *cfgPtr
15188 +);
15189 +
15190 +/********************************************************************************************
15191 +* FUNCTION NAME: dslhal_advcfg_setBlackOutBits()
15192 +*
15193 +*********************************************************************************************
15194 +* DESCRIPTION:
15195 +* Sets the Blackout Bits in the RMSGPCB message
15196 +*
15197 +* Return: 0 success
15198 +* 1 failed
15199 +*
15200 +* NOTE:
15201 +* DSP image is based on LITTLE endian
15202 +*
15203 +********************************************************************************************/
15204 +unsigned int dslhal_advcfg_setBlackOutBits
15205 +(tidsl_t * ptidsl
15206 +);
15207 +
15208 +/********************************************************************************************
15209 +* FUNCTION NAME: dslhal_api_genericDspRead()
15210 +*
15211 +*********************************************************************************************
15212 +* DESCRIPTION:
15213 +* Reads from a generic location in the host interface
15214 +*
15215 +* Return: 0 success
15216 +* 1 failed
15217 +*
15218 +* NOTE:
15219 +* DSP image is based on LITTLE endian
15220 +*
15221 +********************************************************************************************/
15222 +unsigned int dslhal_api_genericDspRead
15223 +(tidsl_t * ptidsl,
15224 + unsigned int offset1,
15225 + unsigned int offset2,
15226 + unsigned int offset3,
15227 + unsigned char* localBuffer,
15228 + unsigned int numBytes
15229 +);
15230 +
15231 +/********************************************************************************************
15232 +* FUNCTION NAME: dslhal_api_genericDspWrite()
15233 +*
15234 +*********************************************************************************************
15235 +* DESCRIPTION:
15236 +* Writes to a generic location in the host interface
15237 +*
15238 +* Return: 0 success
15239 +* 1 failed
15240 +*
15241 +* NOTE:
15242 +* DSP image is based on LITTLE endian
15243 +*
15244 +********************************************************************************************/
15245 +unsigned int dslhal_api_genericDspWrite
15246 +(tidsl_t * ptidsl,
15247 + unsigned int offset1,
15248 + unsigned int offset2,
15249 + unsigned int offset3,
15250 + unsigned char* localBuffer,
15251 + unsigned int numBytes
15252 +);
15253 +
15254 +/********************************************************************************************
15255 +* FUNCTION NAME: dslhal_api_dspInterfaceRead()
15256 +*
15257 +*********************************************************************************************
15258 +* DESCRIPTION:
15259 +* Reads from a generic location in the host interface
15260 +*
15261 +* Return: 0 success
15262 +* 1 failed
15263 +*
15264 +* NOTE:
15265 +* DSP image is based on LITTLE endian
15266 +*
15267 +********************************************************************************************/
15268 +unsigned int dslhal_api_dspInterfaceRead
15269 +(tidsl_t * ptidsl,
15270 + unsigned int baseAddr,
15271 + unsigned int numOffsets,
15272 + unsigned int *offsets,
15273 + unsigned char* localBuffer,
15274 + unsigned int numBytes
15275 +);
15276 +
15277 +/********************************************************************************************
15278 +* FUNCTION NAME: dslhal_api_dspInterfaceWrite()
15279 +*
15280 +*********************************************************************************************
15281 +* DESCRIPTION:
15282 +* Writes to a generic location in the host interface
15283 +*
15284 +* Return: 0 success
15285 +* 1 failed
15286 +*
15287 +* NOTE:
15288 +* DSP image is based on LITTLE endian
15289 +*
15290 +********************************************************************************************/
15291 +unsigned int dslhal_api_dspInterfaceWrite
15292 +(tidsl_t * ptidsl,
15293 + unsigned int baseAddr,
15294 + unsigned int numOffsets,
15295 + unsigned int *offsets,
15296 + unsigned char* localBuffer,
15297 + unsigned int numBytes
15298 +);
15299 +
15300 +/******************************************************************************************
15301 + * FUNCTION NAME: dslhal_api_sendMailboxCommand(tidsl_t *ptidsl, unsigned int cmd)
15302 + *
15303 + *******************************************************************************************
15304 + * DESCRIPTION: This fuction sends the passed mailbox command to the DSP
15305 + *
15306 + * INPUT: PITIDSLHW_T *ptidsl
15307 + * unsigned int cmd
15308 + *
15309 + * RETURN: 0 SUCCESS
15310 + * 1 FAILED
15311 + *
15312 + *****************************************************************************************/
15313 +unsigned int dslhal_api_sendMailboxCommand
15314 +(tidsl_t *ptidsl,
15315 +unsigned int cmd
15316 +);
15317 +
15318 +#ifdef INTERNAL_BUILD
15319 +#include <dsl_hal_internal_api.h>
15320 +#endif
15321 +
15322 +
15323 +#endif /* pairs #ifndef __DSL_APPLICATION_INTERFACE_H__ */
15324 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_logtable.h linux.dev/drivers/atm/sangam_atm/dsl_hal_logtable.h
15325 --- linux.old/drivers/atm/sangam_atm/dsl_hal_logtable.h 1970-01-01 01:00:00.000000000 +0100
15326 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_logtable.h 2005-08-23 04:46:50.097843696 +0200
15327 @@ -0,0 +1,259 @@
15328 +unsigned int log10[]=
15329 +{
15330 + 0,
15331 + 771,
15332 + 1221,
15333 + 1541,
15334 + 1789,
15335 + 1992,
15336 + 2163,
15337 + 2312,
15338 + 2443,
15339 + 2560,
15340 + 2666,
15341 + 2763,
15342 + 2852,
15343 + 2934,
15344 + 3011,
15345 + 3083,
15346 + 3150,
15347 + 3213,
15348 + 3274,
15349 + 3331,
15350 + 3385,
15351 + 3437,
15352 + 3486,
15353 + 3533,
15354 + 3579,
15355 + 3622,
15356 + 3664,
15357 + 3705,
15358 + 3744,
15359 + 3781,
15360 + 3818,
15361 + 3853,
15362 + 3887,
15363 + 3921,
15364 + 3953,
15365 + 3984,
15366 + 4015,
15367 + 4044,
15368 + 4073,
15369 + 4101,
15370 + 4129,
15371 + 4156,
15372 + 4182,
15373 + 4207,
15374 + 4232,
15375 + 4257,
15376 + 4281,
15377 + 4304,
15378 + 4327,
15379 + 4349,
15380 + 4371,
15381 + 4393,
15382 + 4414,
15383 + 4435,
15384 + 4455,
15385 + 4475,
15386 + 4495,
15387 + 4514,
15388 + 4533,
15389 + 4552,
15390 + 4570,
15391 + 4589,
15392 + 4606,
15393 + 4624,
15394 + 4641,
15395 + 4658,
15396 + 4675,
15397 + 4691,
15398 + 4707,
15399 + 4723,
15400 + 4739,
15401 + 4755,
15402 + 4770,
15403 + 4785,
15404 + 4800,
15405 + 4815,
15406 + 4829,
15407 + 4844,
15408 + 4858,
15409 + 4872,
15410 + 4886,
15411 + 4899,
15412 + 4913,
15413 + 4926,
15414 + 4939,
15415 + 4952,
15416 + 4965,
15417 + 4978,
15418 + 4990,
15419 + 5003,
15420 + 5015,
15421 + 5027,
15422 + 5039,
15423 + 5051,
15424 + 5063,
15425 + 5075,
15426 + 5086,
15427 + 5098,
15428 + 5109,
15429 + 5120,
15430 + 5131,
15431 + 5142,
15432 + 5153,
15433 + 5164,
15434 + 5174,
15435 + 5185,
15436 + 5195,
15437 + 5206,
15438 + 5216,
15439 + 5226,
15440 + 5236,
15441 + 5246,
15442 + 5256,
15443 + 5266,
15444 + 5275,
15445 + 5285,
15446 + 5295,
15447 + 5304,
15448 + 5313,
15449 + 5323,
15450 + 5332,
15451 + 5341,
15452 + 5350,
15453 + 5359,
15454 + 5368,
15455 + 5377,
15456 + 5386,
15457 + 5394,
15458 + 5403,
15459 + 5412,
15460 + 5420,
15461 + 5429,
15462 + 5437,
15463 + 5445,
15464 + 5454,
15465 + 5462,
15466 + 5470,
15467 + 5478,
15468 + 5486,
15469 + 5494,
15470 + 5502,
15471 + 5510,
15472 + 5518,
15473 + 5525,
15474 + 5533,
15475 + 5541,
15476 + 5548,
15477 + 5556,
15478 + 5563,
15479 + 5571,
15480 + 5578,
15481 + 5586,
15482 + 5593,
15483 + 5600,
15484 + 5607,
15485 + 5614,
15486 + 5622,
15487 + 5629,
15488 + 5636,
15489 + 5643,
15490 + 5649,
15491 + 5656,
15492 + 5663,
15493 + 5670,
15494 + 5677,
15495 + 5683,
15496 + 5690,
15497 + 5697,
15498 + 5703,
15499 + 5710,
15500 + 5716,
15501 + 5723,
15502 + 5729,
15503 + 5736,
15504 + 5742,
15505 + 5749,
15506 + 5755,
15507 + 5761,
15508 + 5767,
15509 + 5773,
15510 + 5780,
15511 + 5786,
15512 + 5792,
15513 + 5798,
15514 + 5804,
15515 + 5810,
15516 + 5816,
15517 + 5822,
15518 + 5828,
15519 + 5834,
15520 + 5839,
15521 + 5845,
15522 + 5851,
15523 + 5857,
15524 + 5862,
15525 + 5868,
15526 + 5874,
15527 + 5879,
15528 + 5885,
15529 + 5891,
15530 + 5896,
15531 + 5902,
15532 + 5907,
15533 + 5913,
15534 + 5918,
15535 + 5924,
15536 + 5929,
15537 + 5934,
15538 + 5940,
15539 + 5945,
15540 + 5950,
15541 + 5955,
15542 + 5961,
15543 + 5966,
15544 + 5971,
15545 + 5976,
15546 + 5981,
15547 + 5986,
15548 + 5992,
15549 + 5997,
15550 + 6002,
15551 + 6007,
15552 + 6012,
15553 + 6017,
15554 + 6022,
15555 + 6027,
15556 + 6031,
15557 + 6036,
15558 + 6041,
15559 + 6046,
15560 + 6051,
15561 + 6056,
15562 + 6060,
15563 + 6065,
15564 + 6070,
15565 + 6075,
15566 + 6079,
15567 + 6084,
15568 + 6089,
15569 + 6093,
15570 + 6098,
15571 + 6103,
15572 + 6107,
15573 + 6112,
15574 + 6116,
15575 + 6121,
15576 + 6125,
15577 + 6130,
15578 + 6134,
15579 + 6139,
15580 + 6143,
15581 + 6148,
15582 + 6152,
15583 + 6156,
15584 + 6161,
15585 + 6165
15586 + };
15587 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_register.h linux.dev/drivers/atm/sangam_atm/dsl_hal_register.h
15588 --- linux.old/drivers/atm/sangam_atm/dsl_hal_register.h 1970-01-01 01:00:00.000000000 +0100
15589 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_register.h 2005-08-23 04:46:50.097843696 +0200
15590 @@ -0,0 +1,337 @@
15591 +#ifndef ___DSL_REGISTER_DEFINES_H___
15592 +#define ___DSL_REGISTER_DEFINES_H___ 1
15593 +
15594 +/*******************************************************************************
15595 +* FILE PURPOSE: DSL HAL H/W Registers and Constant Declarations for Sangam
15596 +*
15597 +********************************************************************************
15598 +* FILE NAME: dsl_hal_register.h
15599 +*
15600 +* DESCRIPTION:
15601 +* Contains DSL HAL APIs for Adam2 OS functions
15602 +*
15603 +*
15604 +* (C) Copyright 2001-02, Texas Instruments, Inc.
15605 +* History
15606 +* Date Version Notes
15607 +* 06Feb03 0.00.00 RamP Created
15608 +* 21Mar03 0.00.01 RamP Changed header files for Modular
15609 +* build framework
15610 +* 21Mar03 0.00.02 RamP Introduced malloc size for DSP f/w
15611 +* 07Apr03 0.00.03 RamP Implemented new error reporting scheme
15612 +* Changed Commenting to C style only
15613 +* 12Apr03 0.00.04 RamP Added Interrupt Mask defines
15614 +* 14Apr03 0.00.05 RamP Renamed macros for REG8, REG16 & REG32
15615 +* 21Apr03 0.01.00 RamP Added Interrupt source/clear registers
15616 +* Changed enum RSTATE_SHOWTIME to 5
15617 +* 24Apr03 0.01.01 RamP Moved the RSTATE enum to api.h
15618 +* Added olay recovery error condition
15619 +* 14May03 0.01.02 RamP Added defines for power computation
15620 +* Added error condition for hybrids
15621 +* 04Jun03 0.01.03 RamP Added enum for config flags,
15622 +* Cleaned up AR5 register defines
15623 +* Added defines for higher data rate
15624 +* 06Jun03 0.01.04 RamP Added error & interrupt defines
15625 +* 09Jun03 0.01.05 RamP Modified enum for current config
15626 +* Added additional C-Rates defines
15627 +* 18Jul03 0.01.06 RamP Modified internal build flow
15628 +* 21Aug03 0.01.07 RamP Added constellation buffer size
15629 +* 08Oct03 0.01.08 RamP Added us/ds Bits n gains size
15630 +* 12Oct03 0.01.08 RamP Added ADSL2 Message sizes, lengths
15631 +* and offsets for various formats
15632 +* 29Oct03 0.01.09 RamP Added ADSL2 Delt offsets & sizes
15633 +* 24Nov03 0.01.10 RamP Added bit field number, scan vector
15634 +* 26Dec03 0.01.11 RamP Removed the oamFeature masks to api.h
15635 +*******************************************************************************/
15636 +
15637 +#include "env_def_typedefs.h"
15638 +#ifdef INTERNAL_BUILD
15639 +#include "dev_host_internalinterface.h"
15640 +#endif
15641 +#include "dev_host_interface.h"
15642 +#include "dsl_hal_api.h"
15643 +
15644 +#define ADSLSS_BASE 0x01000000
15645 +#define BBIF_BASE 0x02000000
15646 +
15647 +#define ADSLSSADR (BBIF_BASE+0x0000)
15648 +#define ADSLSSADRMASK 0xff000000
15649 +#define WAKEUP_DSP 0x00000001
15650 +
15651 +/* Ax7 Reset Control */
15652 +
15653 +#define RST_CNTRL_BASE 0x8611600
15654 +#define RST_CNTRL_PRCR (RST_CNTRL_BASE + 0x00 )
15655 +
15656 +#define RST_CNTRL_PRCR_GPIO 0x00000040
15657 +#define RST_CNTRL_PRCR_ADSLSS 0x00000080
15658 +#define RST_CNTRL_PRCR_USB 0x00000100
15659 +#define RST_CNTRL_PRCR_SAR 0x00000200
15660 +#define RST_CNTRL_PRCR_DSP 0x00800000
15661 +#define RST_CNTRL_PRCR_EMAC1 0x00200000 /* EMAC1 reset */
15662 +
15663 +#define RST_CNTRL_SWRCR (RST_CNTRL_BASE + 0x04 )
15664 +#define RST_SWRCR_SWR0 0x00000001
15665 +#define RST_SWRCR_SWR1 0x00000002
15666 +
15667 +#define RST_CNTRL_RSR (TNETD53XX_RST_CNTRL_BASE + 0x08 )
15668 +#define RST_RSR_RSCAUSE 0x00000003 /* Software Reset Caused by writing to SWR1 bit */
15669 +
15670 +
15671 +/* ******************************************************
15672 +Interrupt sources on Ax7 interrupt controller.
15673 +The reserved sources are noted.
15674 +********************************************************* */
15675 +
15676 +#define INTR_CNTRL_SRC_SECOND 0
15677 +#define INTR_CNTRL_SRC_EXTERNAL0 1
15678 +#define INTR_CNTRL_SRC_EXTERNAL1 2
15679 +/* reserved sources ... */
15680 +#define INTR_CNTRL_SRC_TIMER0 5
15681 +#define INTR_CNTRL_SRC_TIMER1 6
15682 +#define INTR_CNTRL_SRC_UART0 7
15683 +#define INTR_CNTRL_SRC_UART1 8
15684 +#define INTR_CNTRL_SRC_DMA0 9
15685 +#define INTR_CNTRL_SRC_DMA1 10
15686 +/* reserved sources ... */
15687 +#define INTR_CNTRL_SRC_SAR 15
15688 +/* reserved sources ... */
15689 +#define INTR_CNTRL_SRC_EMAC0 19
15690 +/* reserved sources ... */
15691 +#define INTR_CNTRL_SRC_VLYNQ0 21
15692 +#define INTR_CNTRL_SRC_CODEC_WAKE 22
15693 +/* reserved sources ... */
15694 +#define INTR_CNTRL_SRC_USB 24
15695 +#define INTR_CNTRL_SRC_VLYNQ1 25
15696 +/* reserved sources ... */
15697 +#define INTR_CNTRL_SRC_EMAC1 28
15698 +#define INTR_CNTRL_SRC_I2C 29
15699 +#define INTR_CNTRL_SRC_DMA2 30
15700 +#define INTR_CNTRL_SRC_DMA3 31
15701 +/* reserved sources ... */
15702 +#define INTR_CNTRL_SRC_VDMA_RX 37
15703 +#define INTR_CNTRL_SRC_VDMA_TX 38
15704 +#define INTR_CNTRL_SRC_ADSLSS 39
15705 +
15706 +#ifndef K0BASE
15707 +#define K0BASE 0x80000000
15708 +#endif
15709 +
15710 +#ifndef K1BASE
15711 +#define K1BASE 0xA0000000
15712 +#endif
15713 +
15714 +#ifndef PHYS_ADDR
15715 +#define PHYS_ADDR(X) ((X) & 0X1FFFFFFF)
15716 +#endif
15717 +
15718 +#ifndef PHYS_TO_K0
15719 +#define PHYS_TO_K0(X) (PHYS_ADDR(X)|K0BASE)
15720 +#endif
15721 +
15722 +#ifndef PHYS_TO_K1
15723 +#define PHYS_TO_K1(X) (PHYS_ADDR(X)|K1BASE)
15724 +#endif
15725 +
15726 +#ifndef DSLHAL_REG8
15727 +#define DSLHAL_REG8( addr ) (*(volatile unsigned short *) PHYS_TO_K1(addr))
15728 +#endif
15729 +
15730 +#ifndef DSLHAL_REG16
15731 +#define DSLHAL_REG16( addr ) (*(volatile unsigned short *)PHYS_TO_K1(addr))
15732 +#endif
15733 +
15734 +#ifndef DSLHAL_REG32
15735 +#define DSLHAL_REG32( addr ) (*(volatile unsigned int *)PHYS_TO_K1(addr))
15736 +#endif
15737 +
15738 +#ifndef NULL
15739 +#define NULL 0
15740 +#endif
15741 +
15742 +#ifndef TRUE
15743 +#define TRUE (1==1)
15744 +#endif
15745 +
15746 +#ifndef FALSE
15747 +#define FALSE (1==2)
15748 +#endif
15749 +
15750 +/*******************************************************************************
15751 +* Type Defines for Library
15752 +********************************************************************************/
15753 +typedef unsigned int size_t;
15754 +
15755 +#define TIDSL_HW_CREATED 0x00000001
15756 +#define TIDSL_HW_OPENED 0x00000002
15757 +#define TIDSL_HW_STARTED 0x00000004
15758 +#define TIDSL_OS_INITIALIZED 0x00000008
15759 +
15760 +/* Data Pump CRATES Table Defines */
15761 +#define SIZE_OF_CRATES1_TABLE 120
15762 +#define CRATES1_BF_LS0 7
15763 +#define CRATES1_BI_LS0 17
15764 +#define CRATES1_BF_AS0 0
15765 +#define CRATES1_BI_AS0 10
15766 +#define CRATES1_BF_DSRS 20
15767 +#define CRATES1_BI_DSRS 21
15768 +#define CRATES1_BFI_DSS 22
15769 +#define CRATES1_BFI_DSI 23
15770 +#define CRATES1_BF_USRS 25
15771 +#define CRATES1_BI_USRS 26
15772 +#define CRATES1_BFI_USS 27
15773 +#define CRATES1_BFI_USI 28
15774 +
15775 +#define FAST_PATH 0
15776 +#define INTERLEAVED_PATH 1
15777 +
15778 +#define LINE_NOT_CONNECTED 0
15779 +#define LINE_CONNECTED 1
15780 +#define LINE_DISCONNECTED 2
15781 +#define LINE_NOT_TO_CONNECT 3
15782 +
15783 +#define MAXSECTIONS 125
15784 +
15785 +/*****************************************************************************************
15786 + * Localstructure declarations
15787 + *
15788 + ****************************************************************************************/
15789 +enum
15790 +{
15791 + DSLHAL_ERROR_NO_ERRORS, /* 00 */
15792 + DSLHAL_ERROR_UNRESET_ADSLSS, /* 01 */
15793 + DSLHAL_ERROR_RESET_ADSLSS, /* 02 */
15794 + DSLHAL_ERROR_UNRESET_DSP, /* 03 */
15795 + DSLHAL_ERROR_RESET_DSP, /* 04 */
15796 + DSLHAL_ERROR_NO_FIRMWARE_IMAGE, /* 05 */
15797 + DSLHAL_ERROR_MALLOC, /* 06 */
15798 + DSLHAL_ERROR_FIRMWARE_MALLOC, /* 07 */
15799 + DSLHAL_ERROR_DIAG_MALLOC, /* 08 */
15800 + DSLHAL_ERROR_OVERLAY_MALLOC, /* 09 */
15801 + DSLHAL_ERROR_CODE_DOWNLOAD, /* 10 */
15802 + DSLHAL_ERROR_DIAGCODE_DOWNLOAD, /* 11 */
15803 + DSLHAL_ERROR_BLOCK_READ, /* 12 */
15804 + DSLHAL_ERROR_BLOCK_WRITE, /* 13 */
15805 + DSLHAL_ERROR_MAILBOX_READ, /* 14 */
15806 + DSLHAL_ERROR_MAILBOX_WRITE, /* 15 */
15807 + DSLHAL_ERROR_MAILBOX_NOMAIL, /* 16 */
15808 + DSLHAL_ERROR_MAILBOX_OVERFLOW, /* 17 */
15809 + DSLHAL_ERROR_INVALID_PARAM, /* 18 */
15810 + DSLHAL_ERROR_ADDRESS_TRANSLATE, /* 19 */
15811 + DSLHAL_ERROR_FIRMWARE_CRC, /* 20 */
15812 + DSLHAL_ERROR_FIRMWARE_OFFSET, /* 21 */
15813 + DSLHAL_ERROR_CONFIG_API_FAILURE, /* 22 */
15814 + DSLHAL_ERROR_EOCREG_API_FAILURE, /* 23 */
15815 + DSLHAL_ERROR_VERSION_API_FAILURE, /* 24 */
15816 + DSLHAL_ERROR_STATS_API_FAILURE, /* 25 */
15817 + DSLHAL_ERROR_MARGIN_API_FAILURE, /* 26 */
15818 + DSLHAL_ERROR_CTRL_API_FAILURE, /* 27 */
15819 + DSLHAL_ERROR_HYBRID_API_FAILURE, /* 28 */
15820 + DSLHAL_ERROR_MODEMENV_API_FAILURE, /* 29 */
15821 + DSLHAL_ERROR_INTERRUPT_FAILURE, /* 30 */
15822 + DSLHAL_ERROR_INTERNAL_API_FAILURE, /* 31 */
15823 + DSLHAL_ERROR_DIGIDIAG_FAILURE, /* 32 */
15824 + DSLHAL_ERROR_TONETEST_FAILURE, /* 33 */
15825 + DSLHAL_ERROR_NOISETEST_FAILURE, /* 34 */
15826 + DSLHAL_ERROR_MODEMSTATE, /* 35 */
15827 + DSLHAL_ERROR_OVERLAY_CORRUPTED /* 36 */
15828 +};
15829 +
15830 +enum
15831 +{
15832 + CONFIG_FLAG_NOFLAG, /* 00 */
15833 + CONFIG_FLAG_TRELLIS, /* 01 */
15834 + CONFIG_FLAG_EC, /* 02 */
15835 + CONFIG_FLAG_RS /* 03 */
15836 +};
15837 +
15838 +#define USE_EMIF_REV 0
15839 +#define USE_CVR_REV 1
15840 +#define TNETD53XX_MAXLOOP 10000
15841 +#define REVERB 0
15842 +#define MEDLEY 1
15843 +#define NONINTENSE 0
15844 +#define slavespace0 0xa1000000
15845 +
15846 +#define MASK_MAILBOX_INTERRUPTS 0x00000001
15847 +#define MASK_BITFIELD_INTERRUPTS 0x00000002
15848 +#define MASK_HEARTBEAT_INTERRUPTS 0x00000004
15849 +#define DSP_INTERRUPT_SOURCE_REGISTER 0x020007A0
15850 +#define DSP_INTERRUPT_CLEAR_REGISTER 0x020007A4
15851 +
15852 +#define DIGITAL_DIAG_MEMSIZE 1048576
15853 +#define CRC32_QUOTIENT 0x04c11db7
15854 +#define DSP_FIRMWARE_MALLOC_SIZE 0x7ffff
15855 +#define DSP_CONSTELLATION_BUFFER_SIZE 1024*4
15856 +#define LOG43125 9303
15857 +#define US_NOMINAL_POWER (-38)
15858 +#define US_BNG_LENGTH 32
15859 +#define DS_BNG_LENGTH 256
15860 +#define NUMBER_OF_BITFIELDS 4
15861 +#define BITFIELD_SCAN 0x80000000
15862 +
15863 +/* ADSL Message offsets from Host Interface Pointer */
15864 +
15865 +/* ADSL2 Messages Index and Length defines */
15866 +
15867 +#define CMSGFMT_INDEX 0
15868 +#define CMSGPCB_INDEX 1
15869 +#define RMSGFMT_INDEX 2
15870 +#define RMSGPCB_INDEX 3
15871 +#define RMSG1LD_INDEX 13
15872 +#define RMSG2LD_INDEX 14
15873 +#define RMSG3LD_INDEX 15
15874 +#define RMSG4LD_INDEX 16
15875 +#define RMSG5LD_INDEX 17
15876 +#define RMSG6LD_INDEX 18
15877 +#define RMSG7LD_INDEX 19
15878 +#define RMSG8LD_INDEX 20
15879 +#define RMSG9LD_INDEX 21
15880 +#define CMSG1LD_INDEX 22
15881 +#define CMSG2LD_INDEX 23
15882 +#define CMSG3LD_INDEX 24
15883 +#define CMSG4LD_INDEX 25
15884 +#define CMSG5LD_INDEX 26
15885 +#define CMSGPCB2_INDEX 28
15886 +#define CMSGPCB2L_INDEX 29
15887 +#define RMSGFMT2_INDEX 30
15888 +#define RMSGPCB2L_INDEX 31
15889 +#define CMSG1ADSL2_INDEX 32
15890 +#define RMSG1ADSL2_INDEX 33
15891 +#define CMSG2ADSL2_INDEX 34
15892 +#define RMSG2ADSL2_INDEX 35
15893 +#define CPARAMS_INDEX 36
15894 +#define RPARAMS_INDEX 37
15895 +
15896 +/* ADSL2 Message Sizes */
15897 +
15898 +#define CMSGFMT_SIZE 2
15899 +#define RMSGFMT_SIZE 2
15900 +#define CMSGPCB_SIZE 2
15901 +#define CMSGPCB2_SIZE 6 /* Annex A with Blackout */
15902 +#define CMSGPCB2L_SIZE 10 /* Annex B with Blackout */
15903 +#define RMSGPCB_SIZE 36
15904 +#define RMSG1LD_SIZE 16
15905 +#define RMSGxLD_SIZE 258
15906 +#define CMSG1LD_SIZE 16
15907 +#define CMSG2LD_SIZE 130
15908 +#define CMSG3LD_SIZE 66
15909 +#define CMSG4LD_SIZE 34
15910 +#define CMSG5LD_SIZE 34
15911 +#define CMSG1ADSL2_SIZE 24
15912 +#define RMSG1ADSL2_SIZE 4
15913 +#define CMSG2ADSL2_SIZE 4
15914 +#define RMSG2ADSL2_SIZE 32
15915 +#define CPARAMS_SIZE 136
15916 +#define RPARAMS_SIZE 808
15917 +
15918 +/* ADSL2 Plus Message Sizes (if Different from ADSL2) */
15919 +
15920 +#define RMSGPCB_P_SIZE 68
15921 +#define CMSG1ADSL2P_SIZE 40 /* With Blackout */
15922 +#define CPARAMS_PA_SIZE 168
15923 +#define RPARAMS_PA_SIZE 2088
15924 +#define CPARAMS_PB_SIZE 296
15925 +#define RPARAMS_PB_SIZE 2088
15926 +
15927 +#endif /* pairs #ifndef ___DSL_REGISTER_DEFINES_H___ */
15928 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_support.c linux.dev/drivers/atm/sangam_atm/dsl_hal_support.c
15929 --- linux.old/drivers/atm/sangam_atm/dsl_hal_support.c 1970-01-01 01:00:00.000000000 +0100
15930 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_support.c 2005-08-23 04:46:50.100843240 +0200
15931 @@ -0,0 +1,2788 @@
15932 +/*******************************************************************************
15933 +* FILE PURPOSE: DSL Driver API functions for Sangam
15934 +*********************************************************************************
15935 +* FILE NAME: dsl_hal_support.c
15936 +*
15937 +* DESCRIPTION:
15938 +* Contains DSL HAL APIs for Modem Control
15939 +*
15940 +*
15941 +* (C) Copyright 2001-02, Texas Instruments, Inc.
15942 +* History
15943 +* Date Version Notes
15944 +* 06Feb03 0.00.00 RamP Created
15945 +* 21Mar03 0.00.01 RamP Inserted byteswap functions
15946 +* 07Apr03 0.00.02 RamP Implemented new error reporting scheme
15947 +* Changed Commenting to C style only
15948 +* 12Apr03 0.00.03 RamP Added function to set Interrupt Bit
15949 +* Masks for bitfield & Mailboxes
15950 +* 14Apr03 0.00.04 RamP Added function to process modem state
15951 +* bit fields; renamed REG32 macros
15952 +* Changed interrupt bit field settings
15953 +* 15Apr03 0.00.05 RamP Fixed exit condition on dslShutdown
15954 +* 21Apr03 0.01.00 RamP Fixed dslShutdown function & changed
15955 +* loop counter for overlay byteswaps
15956 +* (Alpha) Added cache writeback for overlays
15957 +* Added function acknowledgeInterrupt
15958 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt into api
15959 +* 24Apr03 0.01.02 RamP Added function to compare crc32 with
15960 +* pre-computed value as a recovery
15961 +* scheme for corrupt overlay pages
15962 +* 28Apr03 0.01.03 RamP Fixed a parameter in crc32 fxn call
15963 +* 05May03 0.01.04 RamP Fixed Message structure access in
15964 +* writeHostMailbox function
15965 +* 14May03 0.01.05 RamP Lookup to netService of dsp version
15966 +* (alpha ++) to determine pots/isdn service
15967 +* 21May03 0.01.06 RamP Added support for CO profiles
15968 +* 29May03 0.01.07 RamP Added critical section tabs for block
15969 +* read/write operations
15970 +* Added functions to reload overlay pages
15971 +* and CO Profiles
15972 +* 04Jun03 0.01.08 RamP Added state transition timing counters
15973 +* 06Jun03 0.01.09 RamP Added Interrupt source parsing function
15974 +* Interrupt masking for heartbeat added
15975 +* 09Jun03 0.01.10 RamP Modified modem state bit field processing
15976 +* for structure changes in ITIDSLHW
15977 +* fixed problem in free memory for CO prof
15978 +* 18Jul03 0.01.11 RamP Optimized free memory for CO profiles &
15979 +* overlay pages in the supporting APIs
15980 +* 28Jul03 0.02.00 RamP Modified the process bitfield functn
15981 +* for LED & Application State report
15982 +* 21Aug03 0.03.00 RamP Added logic to allocate & communicate
15983 +* memory for constellation buffer display
15984 +* 29Sep03 0.03.01 RamP Added API switch calls to advcfg module
15985 +* to abstract them from the API module
15986 +* 12Oct03 0.03.02 RamP Added API to gather ADSL2 Messages
15987 +* 14Oct03 0.03.03 RamP Added function to read CMsgsRA
15988 +* 23Oct03 0.03.04 RamP Changed train history index to circular
15989 +* buffer upon rollover
15990 +* 29Oct03 0.03.05 RamP Added Adsl2 Delt Message Parsing
15991 +* 12Nov03 0.03.06 RamP Fixed endianness issues with
15992 +* Constellation Display
15993 +* 14Nov03 0.03.07 RamP Added function to gather CRates1/RRates1
15994 +* before they get overwritten by CRatesRA
15995 +* 19Nov03 0.03.08 JohnP Revised dslhal_support_aocBitSwapProcessing to
15996 +* prevent duplicate ATU-R bitswaps going to ACT
15997 +* 24Nov03 0.03.09 RamP Implemented detailed State Tracking through
15998 +* Modem State bit fields for ADSL/2
15999 +* 12Dec03 0.03.10 RamP Tokenized advanced configuration code
16000 +* 12Dec03 0.03.11 RamP Added state reset upon IDLE
16001 +* 19Dec03 0.03.12 RamP Added static adsl2 byteswap function for
16002 +* handling pointer to pointer cases
16003 +* Changed adsl2 messages to correct pointer to
16004 +* pointer dereferencing problems in some OS
16005 +* 26Dec03 0.03.13 RamP Setting Current Address for Constellation
16006 +* buffer in addition to start address
16007 +* Added additional check to overlay page malloc
16008 +*******************************************************************************/
16009 +#include "dsl_hal_register.h"
16010 +#include "dsl_hal_support.h"
16011 +
16012 +static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
16013 +
16014 +/******************************************************************************************
16015 +* FUNCTION NAME: dslhal_support_unresetDslSubsystem
16016 +*
16017 +*******************************************************************************************
16018 +* DESCRIPTION: This function unreset Dsl Subsystem
16019 +*
16020 +* INPUT: None
16021 +*
16022 +* RETURN: 0 if Pass; 1 if Fail
16023 +*
16024 +*****************************************************************************************/
16025 +int dslhal_support_unresetDslSubsystem(void)
16026 +{
16027 + dprintf(4," dslhal_support_unresetDslSubsystem()\n");
16028 + /* Put ADSLSS in to reset */
16029 + DSLHAL_REG32(0xa8611a10) = 0x1;
16030 + shim_osClockWait(64);
16031 + dprintf(5,"Selected APLL Reg \n");
16032 +
16033 + DSLHAL_REG32(0xa8610a90) = 0x4;
16034 + shim_osClockWait(64);
16035 + dprintf(5,"Enable Analog PLL \n");
16036 +
16037 + DSLHAL_REG32(0xa8610a90) = 0x77fe;
16038 + shim_osClockWait(64);
16039 + dprintf(5,"Set PLL for DSP\n");
16040 +
16041 + /* DSLHAL_REG32(0xa8611600) = 0x007f1bdf;*/
16042 + DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_ADSLSS;
16043 + shim_osClockWait(64);
16044 + dprintf(5,"Brought ADSLSS out of Reset \n");
16045 +
16046 + DSLHAL_REG32(0xa861090c) &= ~((1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24)|(1<<25));
16047 + shim_osClockWait(64);
16048 + dprintf(5,"Configured GPIO 20-25 for McBSP \n");
16049 +
16050 + /*DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_ADSLSS;*/
16051 +
16052 +
16053 + /* DSLHAL_REG32(0xa8611a04) = 0x00000001;
16054 + shim_osClockWait(64); */
16055 +
16056 + dprintf(4," dslhal_support_unresetDslSubsystem done\n");
16057 + return DSLHAL_ERROR_NO_ERRORS;
16058 +}
16059 +
16060 +
16061 +/******************************************************************************************
16062 +* FUNCTION NAME: dslhal_support_resetDslSubsystem
16063 +*
16064 +*******************************************************************************************
16065 +* DESCRIPTION: This function unreset Dsl Subsystem
16066 +*
16067 +* INPUT: None
16068 +*
16069 +* RETURN: 0 if Pass; 1 if Fail
16070 +*
16071 +*****************************************************************************************/
16072 +int dslhal_support_resetDslSubsystem(void)
16073 +{
16074 + dprintf(4, "dslhal_support_resetDslSubsystem \n");
16075 + /* Put ADSLSS into reset */
16076 + DSLHAL_REG32(0xa8611600) &= ~RST_CNTRL_PRCR_ADSLSS;
16077 + shim_osClockWait(64);
16078 + /* DSLHAL_REG32(0xa8611a04) = 0x00000000;
16079 + shim_osClockWait(64); */
16080 + dprintf(4, "dslhal_support_resetDslSubsystem Done \n");
16081 + return DSLHAL_ERROR_NO_ERRORS;
16082 +}
16083 +
16084 +/******************************************************************************************
16085 +* FUNCTION NAME: dslhal_support_unresetDsp()
16086 +*
16087 +*******************************************************************************************
16088 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
16089 +*
16090 +* INPUT: None
16091 +*
16092 +* RETURN: 0 --successful.
16093 +* 1 --failed
16094 +*
16095 +*****************************************************************************************/
16096 +int dslhal_support_unresetDsp(void)
16097 +{
16098 +#ifdef PRE_SILICON
16099 + /* unsigned char value; */
16100 + int rc;
16101 +
16102 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_SRC_ADDR);
16103 + if(rc==DSLHAL_ERROR_ADDRESS_TRANSLATE)
16104 + {
16105 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16106 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16107 + }
16108 + dprintf(5,"MDMA SRC: %08x\n", rc);
16109 + DSLHAL_REG32(rc) = 0x80000001;
16110 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_DST_ADDR);
16111 + if(rc==DSLHAL_ERROR_ADDRESS_TRANSLATE)
16112 + {
16113 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16114 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16115 + }
16116 + dprintf(5,"MDMA DST: %08x\n", rc);
16117 + DSLHAL_REG32(rc) = 0x02090001;
16118 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)DEV_MDMA0_CTL_ADDR);
16119 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16120 + {
16121 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16122 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16123 + }
16124 + dprintf(5,"MDMA CTL: %08x\n", rc);
16125 + DSLHAL_REG32(rc) = (DEV_MDMA_START | DEV_MDMA_DST_INC | DEV_MDMA_SRC_INC |
16126 + DEV_MDMA_BURST1 | (1 << DEV_MDMA_LEN_SHF));
16127 + /* statusMask = 0x00000010;*/
16128 +#else
16129 + dprintf(4, "dslhal_support_unresetDsp()\n");
16130 +
16131 + /* Bring the DSP core out of reset */
16132 + /* DSLHAL_REG32(0xa8611600) = 0x00ff1bdf; */
16133 + DSLHAL_REG32(0xa8611600) |= RST_CNTRL_PRCR_DSP;
16134 + shim_osClockWait(64);
16135 + dprintf(5,"Brought DSP out of Reset \n");
16136 + dprintf(6,"Current Contents of PRCR: 0x%x\n",(unsigned int)DSLHAL_REG32(0xa8611600));
16137 + /* DSLHAL_REG32(0xa8611a0c) = 0x00000007;
16138 + shim_osClockWait(64); */
16139 +#endif
16140 +
16141 + dprintf(4, "dslhal_support_unresetDsp() done\n");
16142 + return DSLHAL_ERROR_NO_ERRORS;
16143 +}
16144 +
16145 +/******************************************************************************************
16146 +* FUNCTION NAME: dslhal_support_resetDsp()
16147 +*
16148 +*******************************************************************************************
16149 +* DESCRIPTION: This fuction takes ax5 daugter board into reset.
16150 +*
16151 +* INPUT: None
16152 +*
16153 +* RETURN: 0 --successful.
16154 +* 1 --failed
16155 +*
16156 +*****************************************************************************************/
16157 +int dslhal_support_resetDsp(void)
16158 +{
16159 + dprintf(4, "dslhal_support_resetDsp \n");
16160 + /* Put ADSLSS into reset */
16161 + DSLHAL_REG32(0xa8611600) &= ~RST_CNTRL_PRCR_DSP;
16162 + shim_osClockWait(64);
16163 + dprintf(4, "dslhal_support_resetDsp Done \n");
16164 + return DSLHAL_ERROR_NO_ERRORS;
16165 +}
16166 +
16167 +/********************************************************************************************
16168 +* FUNCTION NAME: dslhal_support_hostDspAddressTranslate()
16169 +*
16170 +*********************************************************************************************
16171 +* DESCRIPTION:
16172 +* Maps ax5 daugter card dsp memory address to avalanche memory space
16173 +*
16174 +* Input: unsigned int addr, dsp memory address.
16175 +*
16176 +* Return: >=0, unsigned int, mapped Avalanche address(VBUS address).
16177 +* -1, mapping failed
16178 +*
16179 +*
16180 +********************************************************************************************/
16181 +/* static unsigned int bbifmap0,bbifmap1; */
16182 +
16183 +unsigned int dslhal_support_hostDspAddressTranslate( unsigned int addr )
16184 +{
16185 + unsigned int addrMap;
16186 + /* This function should just be used to move the memory window of the ADSLSS */
16187 + dprintf(5, "dslhal_support_hostDspAddressTranslate()\n");
16188 +
16189 + /* select vbus to xbus memory */
16190 + /* addrMap = addr & 0xff000000; */
16191 + addrMap = addr & ADSLSSADRMASK;
16192 +
16193 + DSLHAL_REG32(ADSLSSADR) = addrMap;
16194 +
16195 + dprintf(6, "dslhal_support_hostDspAddressTranslate() done\n");
16196 +#ifdef PRE_SILICON
16197 + return ((ADSLSS_BASE | (~ADSLSSADRMASK & addr))+ 0x00000100);
16198 + /* Added 0x100 for Pre-Silicon VLNQ offset.. to be removed for Silicon */
16199 +#else
16200 + return ((ADSLSS_BASE | (~ADSLSSADRMASK & addr)));
16201 + /* Added 0x100 for Pre-Silicon VLNQ offset.. to be removed for Silicon */
16202 +#endif
16203 +
16204 +}
16205 +
16206 +
16207 +/******************************************************************************************
16208 +* FUNCTION NAME: dslhal_support_blockWrite
16209 +*
16210 +*******************************************************************************************
16211 +* DESCRIPTION: This rouin simulates DSP memory write as done in ax5 pci nic card
16212 +*
16213 +* INPUT: void *buffer, data need to written
16214 +* void *adde, memory address to be written
16215 +* size_t count, number of bytes to be written
16216 +*
16217 +* RETURN: 0 --succeeded
16218 +* 1 --Failed
16219 +*
16220 +*****************************************************************************************/
16221 +
16222 +int dslhal_support_blockWrite(void *buffer, void *addr, size_t count)
16223 +{
16224 + int rc, byteCnt=0;
16225 + unsigned char* ptr;
16226 + union
16227 + {
16228 + unsigned char *cptr;
16229 + short *sptr;
16230 + int *iptr;
16231 + } src;
16232 + union
16233 + {
16234 + int anint; /* DSP location */
16235 + unsigned char *cptr; /* to avoid casts */
16236 + } dst;
16237 + union
16238 + {
16239 + unsigned int anint;
16240 + unsigned char byte[4];
16241 + }data,dword,sword;
16242 +
16243 + /* Enter Critical Section */
16244 + shim_osCriticalEnter();
16245 +
16246 + dprintf(6, "dslhal_support_blockWrite\n");
16247 +
16248 + dprintf(6,"addr=0x%X, length=0x%X, buffer=0x%X\n", (unsigned int) addr, (unsigned int) count, (unsigned int)buffer);
16249 +
16250 + src.cptr = (unsigned char*) buffer; /* local buffer */
16251 + dst.cptr = addr; /* DSP memory location */
16252 +
16253 + /*Maps address first*/
16254 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)addr);
16255 + dprintf(5, "NewAddr: %08x\n", rc);
16256 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16257 + {
16258 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16259 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16260 + }
16261 +
16262 + dst.cptr=(unsigned char *)rc;
16263 +
16264 + /* check wether address is at 32bits boundary */
16265 +
16266 + if ((dst.anint & 0x3) && count)
16267 + {
16268 + sword.anint = *(unsigned int*)((unsigned int)src.cptr & 0xfffffffc);
16269 + dword.anint = DSLHAL_REG32((unsigned int)dst.cptr & 0xfffffffc);
16270 + sword.anint = (unsigned int) dslhal_support_byteSwap32(sword.anint);
16271 + dword.anint = (unsigned int) dslhal_support_byteSwap32(dword.anint);
16272 + ptr = (unsigned char *)((unsigned int)dst.cptr & 0xfffffffc);
16273 +
16274 + if((dst.anint & 3) ==3) /* last byte of a dword */
16275 + {
16276 + dword.byte[3] = sword.byte[3];
16277 + dst.anint++; /* bump the address by one */
16278 + byteCnt++;
16279 + count--;
16280 + }
16281 +
16282 + if((dst.anint & 3) ==1) /* second byte */
16283 + {
16284 + if(count>3)
16285 + {
16286 + dword.byte[3] = sword.byte[3];
16287 + dst.anint++;
16288 + count--;
16289 + byteCnt++;
16290 + }
16291 + if(count>2)
16292 + {
16293 + dword.byte[2] = sword.byte[2];
16294 + dst.anint++;
16295 + count--;
16296 + byteCnt++;
16297 + }
16298 + if(count)
16299 + {
16300 + dword.byte[1] = sword.byte[1];
16301 + dst.anint++;
16302 + count--;
16303 + byteCnt++;
16304 + }
16305 + }
16306 +
16307 + if((dst.anint & 3) && (count >1))
16308 + {
16309 + dword.byte[2] = sword.byte[2];
16310 + dword.byte[3] = sword.byte[3];
16311 + byteCnt+=2;
16312 + dst.anint += 2; /* bump the address by two */
16313 + count -= 2; /* decrement the byte count by two */
16314 + }
16315 +
16316 + if((dst.anint & 3) && (count==1))
16317 + {
16318 + dword.byte[2] = sword.byte[2];
16319 + dst.anint++;
16320 + byteCnt++;
16321 + count--;
16322 + }
16323 + src.cptr = (char *)((unsigned int)src.cptr & 0xfffffffc); /* fix 032802 */
16324 + dword.anint = dslhal_support_byteSwap32(dword.anint);
16325 + DSLHAL_REG32((unsigned int)ptr) = dword.anint;
16326 + ptr = src.cptr;
16327 + for(rc=0;rc<count;rc++)
16328 + {
16329 + *ptr = *(ptr+byteCnt);
16330 + ptr++;
16331 + }
16332 + }
16333 +
16334 + /* the dst pointer should now be on a 32-bit boundary */
16335 +
16336 + while (count > 3)
16337 + {
16338 + DSLHAL_REG32((unsigned int)dst.cptr) = dslhal_support_byteSwap32(*src.iptr);
16339 + src.iptr++; /* bump the data pointer by four */
16340 + dst.anint += 4; /* bump the address by four */
16341 + count -= 4; /* decrement the byte count by four */
16342 + }
16343 +
16344 + /* write remaining bytes */
16345 + if(count)
16346 + {
16347 + int i;
16348 +
16349 + data.anint= DSLHAL_REG32((unsigned int)dst.cptr);
16350 + data.anint=dslhal_support_byteSwap32(data.anint);
16351 + for (i=0; i< count; i++)
16352 + {
16353 + data.byte[i]=*(src.cptr+i);
16354 + }
16355 + data.anint=dslhal_support_byteSwap32(data.anint);
16356 + DSLHAL_REG32((unsigned int)dst.cptr) = data.anint;
16357 + src.cptr +=count;
16358 + dst.anint +=count;
16359 + count=0;
16360 + }
16361 + dprintf(6, "dslhal_support_blockWrite done\n");
16362 + /* Exit Critical Section */
16363 + shim_osCriticalExit();
16364 + return DSLHAL_ERROR_NO_ERRORS;
16365 +} /* end of dslhal_support_blockWrite() */
16366 +
16367 +
16368 +/******************************************************************************************
16369 +* FUNCTION NAME: dslhal_support_blockRead
16370 +*
16371 +*********************************************************************************************
16372 +* DESCRIPTION: This rouin simulates DSP memory read as done in ax5 pci nic card
16373 +*
16374 +* INPUT: void *addr, memory address to be read
16375 +* void *buffer, dat buffer to be filled with from memmory
16376 +* size_t count, number of bytes to be written
16377 +*
16378 +* RETURN: 0 --succeeded
16379 +* 1 --Failed
16380 +*
16381 +*****************************************************************************************/
16382 +
16383 +int dslhal_support_blockRead(void *addr, void *buffer, size_t count)
16384 +{
16385 + int rc;
16386 + union
16387 + {
16388 + int anint; /* DSP location */
16389 + char *cptr; /* to avoid casts */
16390 + } src;
16391 + union
16392 + {
16393 + char byte[4];
16394 + int anint; /* DSP data */
16395 + } data;
16396 + union
16397 + {
16398 + char *cptr;
16399 + int *iptr;
16400 + } dst;
16401 +
16402 + /* Enter Critical Section */
16403 + shim_osCriticalEnter();
16404 +
16405 + dprintf(6,"dslhal_support_blockRead\n");
16406 +
16407 +
16408 + src.cptr = addr; /* DSP memory location */
16409 + dst.cptr = buffer; /* local buffer */
16410 +
16411 + dprintf(6, "Read addr=0x%X, size=0x%X\n", (unsigned int)addr, count);
16412 +
16413 +
16414 + /*Maps address first*/
16415 + rc=dslhal_support_hostDspAddressTranslate((unsigned int)addr);
16416 + if(rc== DSLHAL_ERROR_ADDRESS_TRANSLATE)
16417 + {
16418 + dprintf(1, "dslhal_support_hostDspAddressTranslate failed\n");
16419 + return DSLHAL_ERROR_ADDRESS_TRANSLATE;
16420 + }
16421 +
16422 + src.cptr=(unsigned char *)rc;
16423 +
16424 + /**********************************************
16425 + * if the source is NOT on a 32-bit boundary *
16426 + * then we read the full word *
16427 + * and ignore the first part of it *
16428 + **********************************************/
16429 +
16430 + if ((src.anint & 3) && count)
16431 + {
16432 + unsigned int anword;
16433 +
16434 + anword = DSLHAL_REG32((unsigned int)src.cptr & 0xfffffffc);
16435 + data.anint = dslhal_support_byteSwap32(anword);
16436 +
16437 + /************************************
16438 + * there is no need for case 0 *
16439 + * notice that there are no breaks *
16440 + * each falls through to the next *
16441 + ************************************/
16442 +
16443 + switch (src.anint & 3)
16444 + {
16445 + case 1:
16446 + /* use only byte[1-3] */
16447 + *(dst.cptr++) = data.byte[1];
16448 + src.anint++;
16449 + count--;
16450 + case 2:
16451 + /* use byte[2-3] */
16452 + if (count)
16453 + {
16454 + *(dst.cptr++) = data.byte[2];
16455 + src.anint++;
16456 + count--;
16457 + }
16458 + case 3:
16459 + /* use byte[3] */
16460 + if (count)
16461 + {
16462 + *(dst.cptr++) = data.byte[3];
16463 + src.anint++;
16464 + count--;
16465 + }
16466 + }
16467 + }
16468 +
16469 + /* the src pointer should now be on a 32-bit boundary */
16470 + while (count > 3)
16471 + {
16472 + unsigned int anword;
16473 +
16474 + anword=DSLHAL_REG32((unsigned int)src.cptr);
16475 +
16476 + *dst.iptr = dslhal_support_byteSwap32(anword);
16477 + src.anint += 4; /* bump the address by four */
16478 + dst.iptr++; /* bump the data pointer by four */
16479 + count -= 4; /* decrement the byte count by four */
16480 + }
16481 +
16482 + /*******************************
16483 + * if there's any count left *
16484 + * then we read the next word *
16485 + * and ignore the end of it *
16486 + *******************************/
16487 + if (count)
16488 + {
16489 + unsigned int anword;
16490 +
16491 + anword= DSLHAL_REG32((unsigned int)src.cptr);
16492 + data.anint = dslhal_support_byteSwap32(anword);
16493 +
16494 + /************************************
16495 + * there is no need for case 0 *
16496 + * notice that there are no breaks *
16497 + * each falls through to the next *
16498 + ************************************/
16499 + switch (count)
16500 + {
16501 + case 1:
16502 + /* use byte[0] */
16503 + *(dst.cptr++) = data.byte[0];
16504 + src.anint++;
16505 + count--;
16506 + break;
16507 + case 2:
16508 + /* use byte[0-1] */
16509 + *(dst.cptr++) = data.byte[0];
16510 + *(dst.cptr++) = data.byte[1];
16511 + src.anint +=2;
16512 + count -= 2;
16513 + break;
16514 + case 3:
16515 + /* use only byte[0-2] */
16516 + *(dst.cptr++) = data.byte[0];
16517 + *(dst.cptr++) = data.byte[1];
16518 + *(dst.cptr++) = data.byte[2];
16519 + src.anint +=3;
16520 + count -= 3;
16521 + break;
16522 + }
16523 + }
16524 + /* Exit Critical Section */
16525 + shim_osCriticalExit();
16526 +
16527 + return DSLHAL_ERROR_NO_ERRORS;
16528 +
16529 +} /* end of dslhal_support_blockRead() */
16530 +
16531 +
16532 +/********************************************************************************************
16533 +* FUNCTION NAME: dslhal_support_readDspMailbox
16534 +*
16535 +*********************************************************************************************
16536 +* DESCRIPTION: Reads a message from the mailbox
16537 +*
16538 +* ARGUMENTS: int *pcmd Pointer to command read
16539 +*
16540 +* RETURNS: 0 if successful
16541 +* 1 if no mail
16542 +* NZ otherwise
16543 +*
16544 +*****************************************************************************************/
16545 +
16546 +int dslhal_support_readDspMailbox(tidsl_t *ptidsl, int *pcmd, int *ptag, int *pprm1, int *pprm2)
16547 +{
16548 + int rc;
16549 + int cmd;
16550 + int tag;
16551 + int prm1;
16552 + int prm2;
16553 + unsigned char dspOutInx;
16554 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16555 + DEV_HOST_mailboxControl_t mailboxControl;
16556 + DEV_HOST_dspHostMsg_t dspMailboxMsg[DEV_HOST_DSPQUEUE_LENGTH];
16557 +
16558 + dprintf(6,"dslhal_support_readDspMailbox\n");
16559 +
16560 + /* get the DSP main pointer */
16561 +
16562 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16563 +
16564 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16565 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16566 + if (rc)
16567 + {
16568 + dprintf(1,"dslhal_support_blockRead failed\n");
16569 + return DSLHAL_ERROR_BLOCK_READ;
16570 + }
16571 +
16572 + /* Read in the command/response buffer */
16573 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16574 +
16575 +
16576 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16577 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16578 +
16579 + if (rc)
16580 + {
16581 + dprintf(1,"dslhal_support_blockRead failed\n");
16582 + return DSLHAL_ERROR_BLOCK_READ;
16583 + }
16584 +
16585 + /* Change the endianness of the Mailbox Pointer */
16586 + mailboxControl.dspMsgBuf_p = (DEV_HOST_dspHostMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.dspMsgBuf_p);
16587 +
16588 + rc = dslhal_support_blockRead((PVOID)mailboxControl.dspMsgBuf_p,
16589 + &dspMailboxMsg, (sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_DSPQUEUE_LENGTH));
16590 +
16591 + if (rc)
16592 + return DSLHAL_ERROR_BLOCK_READ;
16593 + /* Extract the command/response message index */
16594 + mailboxControl.hostInInx &= 7;
16595 + mailboxControl.hostOutInx &= 7;
16596 + mailboxControl.dspOutInx &= 7;
16597 + mailboxControl.dspInInx &= 7;
16598 +
16599 +
16600 + /* check for messages in the mailbox */
16601 +
16602 + if (mailboxControl.dspOutInx == mailboxControl.dspInInx)
16603 + {
16604 + return DSLHAL_ERROR_MAILBOX_NOMAIL;
16605 + /* no messages to read */
16606 + }
16607 +
16608 + /* use bDRESPOutInx as index to DRESPMsgBuf */
16609 +
16610 + cmd = dspMailboxMsg[mailboxControl.dspOutInx].cmd;
16611 + tag = dspMailboxMsg[mailboxControl.dspOutInx].tag;
16612 + prm1= dspMailboxMsg[mailboxControl.dspOutInx].param1;
16613 + prm2= dspMailboxMsg[mailboxControl.dspOutInx].param2;
16614 +
16615 + mailboxControl.dspOutInx++; /* increment count */
16616 + mailboxControl.dspOutInx &= 7; /* only two bits */
16617 +
16618 + dspOutInx = mailboxControl.dspOutInx;
16619 +
16620 + /* Read in the command response buffer again to take care of changes */
16621 + mailboxControl.dspOutInx = dspOutInx;
16622 + rc = dslhal_support_blockWrite(&mailboxControl.dspOutInx,
16623 + &dspOamSharedInterface.dspHostMailboxControl_p->dspOutInx, sizeof(BYTE));
16624 +
16625 + if (rc)
16626 + return DSLHAL_ERROR_BLOCK_WRITE;
16627 +
16628 + /* Is the input parameter address non-zero*/
16629 +
16630 + if (pcmd)
16631 + {
16632 + *pcmd = cmd;
16633 + }
16634 + if (ptag)
16635 + {
16636 + *ptag = tag;
16637 + }
16638 + if (pprm1)
16639 + {
16640 + *pprm1 = prm1;
16641 + }
16642 + if (pprm2)
16643 + {
16644 + *pprm2 = prm2;
16645 + }
16646 +
16647 + dprintf(6,"dslhal_support_readDspMailbox done\n");
16648 + dprintf(6,"cmd=%d, tag=%d\n", cmd, tag);
16649 + dprintf(6,"dslhal_support_readDspMailbox:cmd: 0x%x, tag=%d\n", cmd, tag);
16650 + return DSLHAL_ERROR_NO_ERRORS;
16651 +
16652 +} /* end of dslhal_support_readDspMailbox() */
16653 +
16654 +/*******************************************************************************************
16655 +* FUNCTION NAME: dslhal_support_writeHostMailbox
16656 +*
16657 +********************************************************************************************
16658 +* DESCRIPTION: Send a message to a mailbox
16659 +*
16660 +* ARGUMENTS: int cmd command to write
16661 +* int tag tag (currently unused)
16662 +* int p1 parameter 1 (currently unused)
16663 +* int p2 parameter 2 (currently unused)
16664 +*
16665 +* RETURNS: 0 if successful
16666 +* NZ otherwise
16667 +*
16668 +*******************************************************************************************/
16669 +
16670 +int dslhal_support_writeHostMailbox(tidsl_t *ptidsl, int cmd, int tag, int p1, int p2)
16671 +{
16672 + int rc;
16673 + int index;
16674 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16675 + DEV_HOST_mailboxControl_t mailboxControl;
16676 + DEV_HOST_dspHostMsg_t hostMailboxMsg[DEV_HOST_HOSTQUEUE_LENGTH];
16677 + unsigned char hostInInx;
16678 +
16679 + dprintf(6,"dslhal_support_writeHostMailbox:cmd: 0x%x, tag=%d\n", cmd, tag);
16680 +
16681 + dprintf(6,"cmd=%d, tag=%d\n", cmd, tag);
16682 +
16683 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16684 +
16685 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16686 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16687 + if (rc)
16688 + {
16689 + dprintf(1,"dslhal_support_blockRead failed\n");
16690 + return DSLHAL_ERROR_BLOCK_READ;
16691 + }
16692 + /* Read in the command/response buffer */
16693 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16694 +
16695 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16696 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16697 +
16698 + if (rc)
16699 + {
16700 + dprintf(1,"dslhal_support_blockRead failed\n");
16701 + return DSLHAL_ERROR_BLOCK_READ;
16702 + }
16703 + /* Change the endianness of the Mailbox Control Pointer */
16704 + mailboxControl.hostMsgBuf_p = (DEV_HOST_dspHostMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.hostMsgBuf_p);
16705 + rc = dslhal_support_blockRead((PVOID)mailboxControl.hostMsgBuf_p,
16706 + &hostMailboxMsg, (sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_HOSTQUEUE_LENGTH));
16707 +
16708 + if (rc)
16709 + return DSLHAL_ERROR_BLOCK_READ;
16710 + /* Extract the command/response message index */
16711 + mailboxControl.hostInInx &= 7;
16712 + mailboxControl.hostOutInx &= 7;
16713 + mailboxControl.dspOutInx &= 7;
16714 + mailboxControl.dspInInx &= 7;
16715 +
16716 + /* make sure there's room in the mailbox */
16717 +
16718 + index = mailboxControl.hostInInx;
16719 + mailboxControl.hostInInx++;
16720 + mailboxControl.hostInInx &= 7;
16721 + hostInInx = mailboxControl.hostInInx;
16722 + if (mailboxControl.hostInInx == mailboxControl.hostOutInx)
16723 + {
16724 + /* mailbox is full */
16725 + return DSLHAL_ERROR_MAILBOX_OVERFLOW;
16726 + }
16727 +
16728 + /* use bOCMDInInx as index to OCMDMsgBuf */
16729 + hostMailboxMsg[index].cmd = (BYTE) cmd;
16730 + hostMailboxMsg[index].tag = (BYTE) tag;
16731 + hostMailboxMsg[index].param1 = (BYTE) p1;
16732 + hostMailboxMsg[index].param2 = (BYTE) p2;
16733 + rc = dslhal_support_blockWrite(&hostMailboxMsg,
16734 + (PVOID)mailboxControl.hostMsgBuf_p,
16735 + sizeof(DEV_HOST_dspHostMsg_t)*DEV_HOST_HOSTQUEUE_LENGTH);
16736 + if (rc)
16737 + {
16738 + dprintf(1,"dslhal_support_blockWrite failed\n");
16739 + return DSLHAL_ERROR_BLOCK_READ;
16740 + }
16741 + rc = dslhal_support_blockWrite(&mailboxControl,
16742 + &dspOamSharedInterface.dspHostMailboxControl_p,
16743 + sizeof(DEV_HOST_mailboxControl_t));
16744 + if (rc)
16745 + return DSLHAL_ERROR_BLOCK_WRITE;
16746 + /* update the index */
16747 + mailboxControl.hostInInx = hostInInx;
16748 + rc = dslhal_support_blockWrite(&mailboxControl.hostInInx,
16749 + &dspOamSharedInterface.dspHostMailboxControl_p->hostInInx,
16750 + sizeof(BYTE));
16751 + if (rc)
16752 + return DSLHAL_ERROR_BLOCK_WRITE;
16753 +
16754 + dprintf(6,"dslhal_support_writeHostMailbox done\n");
16755 + return DSLHAL_ERROR_NO_ERRORS;
16756 +
16757 +}
16758 +/* end of dslhal_support_writeHostMailbox() */
16759 +
16760 +
16761 +/********************************************************************************************
16762 +* FUNCTION NAME: dslhal_support_readTextMailbox
16763 +*
16764 +*********************************************************************************************
16765 +* DESCRIPTION: Reads a message from the mailbox
16766 +*
16767 +* ARGUMENTS: int *pcmd Pointer to command read
16768 +*
16769 +* RETURNS: 0 if successful
16770 +* 1 if no mail
16771 +* NZ otherwise
16772 +*
16773 +*****************************************************************************************/
16774 +
16775 +int dslhal_support_readTextMailbox(tidsl_t *ptidsl, int *pmsg1, int *pmsg2)
16776 +{
16777 + int rc;
16778 + unsigned int msg1;
16779 + unsigned int msg2;
16780 + unsigned char textOutInx;
16781 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
16782 + DEV_HOST_mailboxControl_t mailboxControl;
16783 + DEV_HOST_textMsg_t textMailboxMsg[DEV_HOST_TEXTQUEUE_LENGTH];
16784 +
16785 + dprintf(6,"dslhal_support_readTextMailbox\n");
16786 +
16787 + /* get the DSP main pointer */
16788 +
16789 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterfacePtr_t) ptidsl->pmainAddr;
16790 +
16791 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
16792 + sizeof(DEV_HOST_dspOamSharedInterface_t));
16793 + if (rc)
16794 + {
16795 + dprintf(1,"dslhal_support_blockRead failed\n");
16796 + return DSLHAL_ERROR_BLOCK_READ;
16797 + }
16798 +
16799 + /* Read in the command/response buffer */
16800 + dspOamSharedInterface.dspHostMailboxControl_p = (DEV_HOST_mailboxControl_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspHostMailboxControl_p);
16801 +
16802 +
16803 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspHostMailboxControl_p,
16804 + &mailboxControl, sizeof(DEV_HOST_mailboxControl_t));
16805 +
16806 + if (rc)
16807 + {
16808 + dprintf(1,"dslhal_support_blockRead failed\n");
16809 + return DSLHAL_ERROR_BLOCK_READ;
16810 + }
16811 +
16812 + /* Change the endianness of the Mailbox Pointer */
16813 + mailboxControl.textMsgBuf_p = (DEV_HOST_textMsg_t *) dslhal_support_byteSwap32((unsigned int)mailboxControl.textMsgBuf_p);
16814 +
16815 + rc = dslhal_support_blockRead((PVOID)mailboxControl.textMsgBuf_p,
16816 + &textMailboxMsg, (sizeof(DEV_HOST_textMsg_t)*DEV_HOST_DSPQUEUE_LENGTH));
16817 +
16818 + if (rc)
16819 + return DSLHAL_ERROR_BLOCK_READ;
16820 + /* Extract the command/response message index */
16821 +
16822 + mailboxControl.textInInx &= 7;
16823 + mailboxControl.textOutInx &= 7;
16824 +
16825 + /* check for messages in the mailbox */
16826 +
16827 + if (mailboxControl.textOutInx == mailboxControl.textInInx)
16828 + {
16829 + return DSLHAL_ERROR_MAILBOX_NOMAIL;
16830 + /* no messages to read */
16831 + }
16832 +
16833 + /* use bDRESPOutInx as index to DRESPMsgBuf */
16834 +
16835 + msg1 = textMailboxMsg[mailboxControl.textOutInx].msgPart1;
16836 + msg2 = textMailboxMsg[mailboxControl.textOutInx].msgPart2;
16837 + msg1 = (unsigned int) dslhal_support_byteSwap32((unsigned int)msg1);
16838 + msg2 = (unsigned int) dslhal_support_byteSwap32((unsigned int)msg2);
16839 +
16840 + mailboxControl.textOutInx++; /* increment count */
16841 + mailboxControl.textOutInx &= 7; /* only two bits */
16842 +
16843 + textOutInx = mailboxControl.textOutInx;
16844 +
16845 + /* Read in the command response buffer again to take care of changes */
16846 +
16847 + mailboxControl.textOutInx = textOutInx;
16848 +
16849 + rc = dslhal_support_blockWrite(&mailboxControl.textOutInx,
16850 + &dspOamSharedInterface.dspHostMailboxControl_p->textOutInx, sizeof(BYTE));
16851 +
16852 + if (rc)
16853 + return DSLHAL_ERROR_BLOCK_WRITE;
16854 +
16855 + /* Is the input parameter address non-zero*/
16856 +
16857 + if (pmsg1)
16858 + {
16859 + *pmsg1 = msg1;
16860 + }
16861 + if (pmsg2)
16862 + {
16863 + *pmsg2 = msg2;
16864 + }
16865 +
16866 + dprintf(6,"dslhal_support_readTextMailbox done\n");
16867 + dprintf(6,"msgPart1=%d, msgPart2=%d\n", msg1, msg2);
16868 + dprintf(6,"dslhal_support_readTextMailbox:Message Part1: 0x%x, tag=0x%x\n", msg1, msg2);
16869 + return DSLHAL_ERROR_NO_ERRORS;
16870 +
16871 +} /* end of dslhal_support_readTextMailbox() */
16872 +
16873 +
16874 +
16875 +/********************************************************************************************
16876 +* FUNCTION NAME: dslhal_support_hostDspCodeDownload()
16877 +*
16878 +*********************************************************************************************
16879 +* DESCRIPTION:
16880 +* download DSP image from host memory to dsp memory
16881 +*
16882 +* Return: 0 success
16883 +* 1 failed
16884 +*
16885 +* NOTE:
16886 +* DSP image is based on LITTLE endian
16887 +*
16888 +********************************************************************************************/
16889 +
16890 +int dslhal_support_hostDspCodeDownload(tidsl_t * ptidsl)
16891 +{
16892 +
16893 + unsigned int index;
16894 + int rc = 0, i;
16895 + unsigned char *iptr; /* image pointer */
16896 + unsigned int numbytes,olayXfer,olayStore;
16897 + /* unsigned int holdSecPhyAddr=0,holdSecVirtAddr; */
16898 + unsigned int *olayStart;
16899 + size_t len; /* size of the file */
16900 + size_t expoffset; /* expected offset for next section header */
16901 + unsigned short checksum;
16902 + unsigned int crc32;
16903 + unsigned char * image;
16904 + char *tmp = (char *)DEV_HOST_DSP_OAM_POINTER_LOCATION;
16905 + DEV_HOST_dspVersionDef_t dspVersion;
16906 +#if SWTC
16907 + DEV_HOST_tcHostCommDef_t TCHostCommDef;
16908 +#endif
16909 + DEV_HOST_oamWrNegoParaDef_t OamWrNegoParaDef;
16910 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface, *pdspOamSharedInterface;
16911 + DEV_HOST_olayDpDef_t olayDpParms;
16912 + DEV_HOST_profileBase_t profileList;
16913 +#ifndef NO_ACT
16914 + DEV_HOST_consBufDef_t constDisp;
16915 +#endif
16916 +#if CO_PROFILES
16917 + DEV_HOST_coData_t coData;
16918 +#endif
16919 + DEV_HOST_olayDpPageDef_t olayDpPageDef[NUM_PAGES];
16920 + union
16921 + {
16922 + char byte[4];
16923 + unsigned short hword[2];
16924 + unsigned int aword;
16925 + } data;
16926 +
16927 + struct _header
16928 + {
16929 + char signature[6];
16930 + unsigned short sectcount;
16931 + unsigned int length;
16932 + } header;
16933 +
16934 + struct _section
16935 + {
16936 + unsigned int addr;
16937 + unsigned int length;
16938 + unsigned int offset;
16939 + unsigned int page;
16940 + };/* section[MAXSECTIONS]; */
16941 +
16942 + struct _section *sptr;
16943 + unsigned int secAddr, secLength, secOffset, secPage;
16944 +
16945 +
16946 + dprintf(5,"dslhal_support_hostDspCodeDownload\n");
16947 + image = ptidsl->fwimage;
16948 +
16949 + if (!image)
16950 + {
16951 + dprintf(1,"no image file\n");
16952 + return DSLHAL_ERROR_NO_FIRMWARE_IMAGE;
16953 + }
16954 +
16955 + iptr=image;
16956 +
16957 + numbytes = sizeof(header);
16958 +
16959 + shim_osMoveMemory((char *) &header, (char *)iptr, numbytes);
16960 + header.length = dslhal_support_byteSwap32(header.length);
16961 + header.sectcount = dslhal_support_byteSwap16(header.sectcount);
16962 +#if 0
16963 + crc32 = dslhal_support_computeCrc32((unsigned char*)&crcTest[0],20);
16964 + dprintf(6,"CRC-32 for the crcTest: 0x%x",crc32);
16965 + dprintf(4,"header.length=%d, header.sectcount=0x%X\n", header.length, header.sectcount);
16966 +#endif
16967 + /* point to the checksum */
16968 + /* compute the checksum on CRC32 here */
16969 + iptr = image + header.length-4;
16970 + numbytes = sizeof(data.aword);
16971 +
16972 + dprintf(5,"tiload: check checksum\n");
16973 + shim_osMoveMemory((char *)&(data.byte), (char *)iptr, numbytes);
16974 +
16975 + crc32 = dslhal_support_computeCrc32(image,ptidsl->imagesize);
16976 + dprintf(5,"CRC-32 for the Binary: 0x%x",crc32);
16977 + /* CRC currently not added to the DSP binary, so this code is commented out */
16978 + /*
16979 + data.aword = dslhal_support_byteSwap32(data.aword);
16980 + if (data.aword != crc32)
16981 + {
16982 + dprintf(1,"Checksum error\n");
16983 + }
16984 + */
16985 + /* Verify signature - Changed from "320C6x" to "TIDSL" for load 80 */
16986 +
16987 + header.signature[5]='\0';
16988 + dprintf(5, "signature=%s\n", header.signature);
16989 +
16990 + if (shim_osStringCmp(header.signature, "TIDSL"))
16991 + {
16992 + dprintf(1,"Signature not match\n");
16993 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
16994 + }
16995 +
16996 + dprintf(5,"tiload: check sect count\n");
16997 + /* check section count */
16998 +
16999 + if (header.sectcount > MAXSECTIONS)
17000 + {
17001 + dprintf(1,"Section # %d exceeds max %d\n", header.sectcount, MAXSECTIONS);
17002 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17003 + }
17004 + else
17005 + {
17006 + dprintf(5,"found %d sections\n", header.sectcount);
17007 + }
17008 +
17009 + /* Validation of Section offsets */
17010 +
17011 + /* point to the first section */
17012 + len = header.length; /* file size in bytes */
17013 + expoffset = sizeof(struct _header) + header.sectcount * sizeof(struct _section);
17014 +
17015 + dprintf(5,"tiload: check offset\n");
17016 + for (index=0; index<header.sectcount; index++) /* parse the sections one by one */
17017 + {
17018 + numbytes = sizeof(struct _header) + index * sizeof(struct _section); /* Compute Section Offset */
17019 + sptr = (struct _section *)(image + numbytes); /* Section Pointer to beginning of the section */
17020 +
17021 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17022 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17023 + secLength = dslhal_support_byteSwap32(sptr->length);
17024 + secPage = dslhal_support_byteSwap32(sptr->page);
17025 +
17026 + /* validate offset */
17027 + if ( secOffset== 0xffffffff)
17028 + {
17029 + /* special case: zero fill */
17030 + /* offset is valid, don't change expoffset */
17031 + }
17032 + else
17033 + {
17034 + if (secOffset > len-4)
17035 + {
17036 + dprintf(5,"Offset error\n");
17037 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17038 + }
17039 +
17040 + /* determine expected offset of NEXT section */
17041 + expoffset = secLength + secOffset;
17042 +
17043 + /* all addresses must be on word boundaries */
17044 + if (secAddr & 3)
17045 + {
17046 +
17047 + }
17048 + }
17049 + }
17050 +
17051 + /* check final offset - should just be a checksum left */
17052 +/* IMPORTANT 11/24/02 --> Got this error... but bypassed for Pf of Concept*/
17053 + /*
17054 + if (expoffset != len-4)
17055 + {
17056 + dprintf(5,"Final offset error\n");
17057 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17058 + }
17059 + */
17060 +
17061 + /* Actual Code loading to DSP Memory */
17062 +
17063 + /* Initialize DSP Data Memory before code load*/
17064 + dprintf(5,"Zero Prefill DSP DMEM\n");
17065 + DSLHAL_REG32(ADSLSSADR)=0x80000000;
17066 + shim_osZeroMemory((char *)0xa1000000, 0x10000);
17067 + /* Load sections from the image */
17068 + for (index=0; index<header.sectcount; index++) /* Parse each section */
17069 + {
17070 + numbytes = sizeof(header) + index * sizeof(struct _section); /* Compute offset to next section */
17071 + sptr = (struct _section *)(image + numbytes); /* Point to next section */
17072 +
17073 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17074 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17075 + secLength = dslhal_support_byteSwap32(sptr->length);
17076 + secPage = dslhal_support_byteSwap32(sptr->page);
17077 +
17078 + data.aword = secAddr;
17079 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17080 +
17081 + data.aword = secLength;
17082 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17083 +
17084 + data.aword = secOffset;
17085 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17086 +
17087 + data.aword = secPage;
17088 + checksum += data.byte[0] + data.byte[1] + data.byte[2] + data.byte[3];
17089 +
17090 +
17091 + /* validate offset */
17092 + if (secOffset == 0xffffffff)
17093 + {
17094 + /* special case: zero fill */
17095 + /* offset is valid, don't change expoffset */
17096 + }
17097 + else
17098 + {
17099 + /* real offset */
17100 + if(secOffset > len-4)
17101 + {
17102 + dprintf(5,"section[%u] offset too big (%X/%X)\n", index,
17103 + secOffset, len-4);
17104 +
17105 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17106 + }
17107 +
17108 + /* determine expected offset of NEXT section */
17109 + expoffset = secLength + secOffset;
17110 +
17111 + }
17112 +
17113 + }
17114 +
17115 + /* check final offset - should just be a checksum left */
17116 + /*
17117 + if(expoffset != len-4)
17118 + {
17119 + dprintf(1,"sections don't span full file (%X/%X)\n",expoffset,len-2);
17120 + return DSLHAL_ERROR_FIRMWARE_OFFSET;
17121 + }
17122 + */
17123 + dprintf(5,"tiload: load binary\n");
17124 +
17125 + for (index=0; index<header.sectcount; index++)
17126 + {
17127 + numbytes = sizeof(header) + index * sizeof(struct _section);
17128 + sptr = (struct _section *)(image + numbytes);
17129 +
17130 + secAddr = dslhal_support_byteSwap32(sptr->addr);
17131 + secOffset = dslhal_support_byteSwap32(sptr->offset);
17132 + secLength = dslhal_support_byteSwap32(sptr->length);
17133 + secPage = dslhal_support_byteSwap32(sptr->page);
17134 + dprintf(5,"loading section %u\n", index);
17135 + dprintf(5,"section %u: addr: %X\n", index, secAddr);
17136 + dprintf(5,"section %u: length: %X\n", index, secLength);
17137 + dprintf(5,"section %u: offset: %X\n", index, secOffset);
17138 + dprintf(5,"section %u: page: %X\n", index, secPage);
17139 +
17140 + /* point to the section's data */
17141 + if(secOffset != 0xffffffff)
17142 + {
17143 + /* Load this section of data */
17144 + iptr = image + secOffset;
17145 + dprintf(6, "iptr %8x\n", (unsigned int)iptr);
17146 + }
17147 +
17148 + if(secPage)
17149 + {
17150 + dprintf(6,"OVERLAY PAGE #%d\n",secPage);
17151 + /* overlay page, don't write to dsp yet, save into host memory*/
17152 +
17153 + dprintf(6,"Section Length: %d \n",secLength);
17154 + ptidsl->olayDpPage[secPage].PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17155 + if(ptidsl->olayDpPage[secPage].PmemStartWtAddr == NULL)
17156 + {
17157 + dprintf(1, "overlay page allocate error\n");
17158 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17159 + }
17160 +#ifdef PRE_SILICON
17161 + ptidsl->olayDpPage[secPage].overlayHostAddr = ((((ptidsl->olayDpPage[secPage].PmemStartWtAddr)-0x84000000)-0x10000000)+0x030b0000);
17162 +#else
17163 + /* ptidsl->olayDpPage[secPage].overlayHostAddr = ((unsigned int)(ptidsl->olayDpPage[secPage].PmemStartWtAddr)&~0xe0000000); */
17164 + ptidsl->olayDpPage[secPage].overlayHostAddr = virtual2Physical((unsigned int)ptidsl->olayDpPage[secPage].PmemStartWtAddr);
17165 +#endif
17166 + dprintf(6,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->olayDpPage[secPage].PmemStartWtAddr,ptidsl->olayDpPage[secPage].overlayHostAddr);
17167 +
17168 + ptidsl->olayDpPage[secPage].overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->olayDpPage[secPage].overlayHostAddr);
17169 + ptidsl->olayDpPage[secPage].OverlayXferCount = secLength;
17170 + ptidsl->olayDpPage[secPage].BinAddr = secAddr;
17171 + ptidsl->olayDpPage[secPage].SecOffset = secOffset;
17172 + shim_osMoveMemory((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, (char *)iptr, secLength);
17173 + /* RamP Image ByteSwap test */
17174 + olayStart = (unsigned int *)ptidsl->olayDpPage[secPage].PmemStartWtAddr;
17175 +
17176 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17177 + {
17178 + olayStore = *(unsigned int *)olayStart;
17179 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17180 + *(unsigned int*)olayStart = olayStore;
17181 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17182 + olayStart++;
17183 + olayStore=0;
17184 + }
17185 + /* RamP Image ByteSwap test */
17186 + /* compute the CRC of each overlay page and Store the Checksum in a local global variable */
17187 + /* This Value of CRC is to be compared with the header where all the CRC bytes are lumped together */
17188 + ptidsl->olayDpPage[secPage].olayPageCrc32 = dslhal_support_computeCrc32((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, ptidsl->olayDpPage[secPage].OverlayXferCount);
17189 +
17190 + shim_osWriteBackCache((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, secLength);
17191 + }
17192 + else
17193 + {
17194 + rc = secAddr&0xff000000;
17195 + if(rc && rc!=0x80000000)
17196 + {
17197 + dprintf(4,"Not DSP PMEM/DMEM\n");
17198 + /* don't write to dsp, save into host memory*/
17199 + dprintf(4,"Section Addr: %x Section Length: %d \n",secAddr,secLength);
17200 + ptidsl->coProfiles.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17201 + if(ptidsl->coProfiles.PmemStartWtAddr == NULL)
17202 + {
17203 + dprintf(1, "memory allocate error\n");
17204 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17205 + }
17206 + ptidsl->coProfiles.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->coProfiles.PmemStartWtAddr);
17207 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.overlayHostAddr);
17208 + ptidsl->coProfiles.overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->coProfiles.overlayHostAddr);
17209 + ptidsl->coProfiles.OverlayXferCount = secLength;
17210 + ptidsl->coProfiles.BinAddr = secAddr;
17211 + ptidsl->coProfiles.SecOffset = secOffset;
17212 +
17213 + shim_osMoveMemory((char *)ptidsl->coProfiles.PmemStartWtAddr, (char *)iptr, secLength);
17214 + /* RamP Image ByteSwap test */
17215 + olayStart = (unsigned int *)ptidsl->coProfiles.PmemStartWtAddr;
17216 +
17217 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17218 + {
17219 + olayStore = *(unsigned int *)olayStart;
17220 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17221 + *(unsigned int*)olayStart = olayStore;
17222 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17223 + olayStart++;
17224 + olayStore=0;
17225 + }
17226 + shim_osWriteBackCache((void *)ptidsl->coProfiles.PmemStartWtAddr, secLength);
17227 + }
17228 + else
17229 + {
17230 + /* IMPORTANT: write image to DSP memory */
17231 + rc=dslhal_support_blockWrite((void *)iptr, (void *)secAddr, secLength);
17232 + if(rc)
17233 + {
17234 + dprintf(1,"dslhal_support_blockRead failed\n");
17235 + return DSLHAL_ERROR_BLOCK_READ;
17236 + }
17237 + shim_osClockWait(0x50000);
17238 + /*
17239 + rc=dslhal_support_blockRead((void*)secAddr, (void*)tmpBuffer, secLength);
17240 + if(rc)
17241 + {
17242 + dprintf(1,"dslhal_support_blockRead failed\n");
17243 + return DSLHAL_ERROR_BLOCK_READ;
17244 + }
17245 + for(i=0;i<secLength;i++)
17246 + {
17247 + if(*iptr
17248 + }*/
17249 + }
17250 + }
17251 + } /* end of write dsp image */
17252 +
17253 + /***********************************************************************************
17254 + * Start to fillup various values to our hardware structure for late use
17255 + ************************************************************************************/
17256 +
17257 + /* get main pointer for data */
17258 +
17259 + rc = dslhal_support_blockRead(tmp, &pdspOamSharedInterface, sizeof(unsigned int));
17260 + dprintf(5, "tmp=0x%X, addr=0x%X\n", (unsigned int)tmp, (unsigned int)pdspOamSharedInterface);
17261 + pdspOamSharedInterface= (DEV_HOST_dspOamSharedInterface_t *)dslhal_support_byteSwap32((unsigned int)pdspOamSharedInterface);
17262 + dprintf(5, "tmp=0x%X, addr=0x%X\n", (unsigned int)tmp, (unsigned int)pdspOamSharedInterface);
17263 + if (rc)
17264 + {
17265 + dprintf(1,"dslhal_support_blockRead failed\n");
17266 + return DSLHAL_ERROR_BLOCK_READ;
17267 + }
17268 +
17269 + if(!pdspOamSharedInterface)
17270 + {
17271 + dprintf(1,"Couldn't read main pointer\n");
17272 + return DSLHAL_ERROR_INVALID_PARAM;
17273 + }
17274 +
17275 + ptidsl->pmainAddr=pdspOamSharedInterface;
17276 +
17277 + /* read the OamSharedInterfaceStructure */
17278 +
17279 + dprintf(5,"ptidsl->hostIf.mainAddr=0x%X\n", (unsigned int)ptidsl->pmainAddr);
17280 +
17281 + /* get the pointer to DSP-OAM Shared Interface */
17282 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,
17283 + sizeof(DEV_HOST_dspOamSharedInterface_t));
17284 + if (rc)
17285 + {
17286 + dprintf(1,"dslhal_support_blockRead failed\n");
17287 + return DSLHAL_ERROR_BLOCK_READ;
17288 + }
17289 + /* Communicate the Allocated Memory Address to DSP to choose CO Profiles */
17290 +
17291 + /* Change the Endianness of the profileList pointer */
17292 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
17293 + /* Access the profileList Structure */
17294 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
17295 +
17296 + if (rc)
17297 + {
17298 + dprintf(1,"dslhal_support_blockRead failed\n");
17299 + return DSLHAL_ERROR_BLOCK_READ;
17300 + }
17301 + dprintf(2,"Old Addr:%x New: %x \n",profileList.hostProfileBase_p,ptidsl->coProfiles.overlayHostAddr);
17302 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)ptidsl->coProfiles.overlayHostAddr;
17303 + rc = dslhal_support_blockWrite(&profileList,(PVOID)dspOamSharedInterface.profileList_p,sizeof(DEV_HOST_profileBase_t));
17304 + if (rc)
17305 + return DSLHAL_ERROR_BLOCK_WRITE;
17306 +
17307 + /* Communicate the Allocated Memory Address to DSP to do overlays */
17308 +
17309 + /* Change the Endianness of the olayDpDef pointer */
17310 + dspOamSharedInterface.olayDpParms_p = (DEV_HOST_olayDpDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.olayDpParms_p);
17311 + /* Access the olayDpDef Structure */
17312 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.olayDpParms_p,&olayDpParms, sizeof(DEV_HOST_olayDpDef_t));
17313 +
17314 + if (rc)
17315 + {
17316 + dprintf(1,"dslhal_support_blockRead failed\n");
17317 + return DSLHAL_ERROR_BLOCK_READ;
17318 + }
17319 +
17320 +
17321 + for(i=1;i<NUM_PAGES;i++)
17322 + {
17323 + /* Change the endianness of the olayDpPageDef Pointer */
17324 + olayDpParms.olayDpPage_p[i] = (DEV_HOST_olayDpPageDef_t *) dslhal_support_byteSwap32((unsigned int)olayDpParms.olayDpPage_p[i]);
17325 + /* Access the olayDpPageDef Structure */
17326 + rc = dslhal_support_blockRead((PVOID)olayDpParms.olayDpPage_p[i],&olayDpPageDef[i],sizeof(DEV_HOST_olayDpPageDef_t));
17327 + if (rc)
17328 + return DSLHAL_ERROR_BLOCK_READ;
17329 + olayDpPageDef[i].overlayHostAddr = ptidsl->olayDpPage[i].overlayHostAddr;
17330 + rc = dslhal_support_blockWrite(&olayDpPageDef[i],(PVOID)olayDpParms.olayDpPage_p[i],sizeof(DEV_HOST_olayDpPageDef_t));
17331 + if (rc)
17332 + return DSLHAL_ERROR_BLOCK_WRITE;
17333 + }
17334 +
17335 + /* Change the endianness of the Datapump Version Pointer */
17336 + dspOamSharedInterface.datapumpVersion_p = (DEV_HOST_dspVersionDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.datapumpVersion_p);
17337 +
17338 + /* get DSPVersion itself */
17339 +
17340 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.datapumpVersion_p,&dspVersion, sizeof(DEV_HOST_dspVersionDef_t));
17341 +
17342 + if (rc)
17343 + {
17344 + dprintf(1,"dslhal_support_blockRead failed\n");
17345 + return DSLHAL_ERROR_BLOCK_READ;
17346 + }
17347 +
17348 + /* table_dsp info */
17349 +#if SWTC
17350 + dspOamSharedInterface.tcHostComm_p = (DEV_HOST_tcHostCommDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.tcHostComm_p);
17351 + rc = dslhal_support_blockRead(&pdspOamSharedInterface->tcHostComm_p,
17352 + &pTCHostCommDef, 4);
17353 + if (rc)
17354 + {
17355 + dprintf(1,"dslhal_support_blockRead failed\n");
17356 + return DSLHAL_ERROR_BLOCK_READ;
17357 + }
17358 +
17359 + pTCHostCommDef=(DEV_HOST_tcHostCommDef_t *) dslhal_support_byteSwap32((unsigned int)pTCHostCommDef);
17360 +
17361 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.tcHostComm_p,
17362 + &TCHostCommDef, sizeof(DEV_HOST_tcHostCommDef_t));
17363 + if (rc)
17364 + {
17365 + dprintf(1,"dslhal_support_blockRead failed\n");
17366 + return DSLHAL_ERROR_BLOCK_READ;
17367 + }
17368 +#endif
17369 + /* Select the Multimode Training */
17370 + dspOamSharedInterface.oamWriteNegoParams_p = (DEV_HOST_oamWrNegoParaDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.oamWriteNegoParams_p);
17371 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.oamWriteNegoParams_p, &OamWrNegoParaDef, sizeof(DEV_HOST_oamWrNegoParaDef_t));
17372 + if (rc)
17373 + {
17374 + dprintf(1,"dslhal_support_blockRead failed\n");
17375 + return DSLHAL_ERROR_BLOCK_READ;
17376 + }
17377 +switch(dspVersion.netService)
17378 + {
17379 + case 1: OamWrNegoParaDef.stdMode = MULTI_MODE;
17380 + dprintf(5,"POTS Service \n");
17381 + ptidsl->netService = 1;
17382 + break;
17383 + case 2: OamWrNegoParaDef.stdMode = GDMT_MODE;
17384 + dprintf(5,"ISDN Service \n");
17385 + ptidsl->netService = 2;
17386 + break;
17387 + default: OamWrNegoParaDef.stdMode = T1413_MODE;
17388 + dprintf(5,"Default Service \n");
17389 + break;
17390 + }
17391 +
17392 + ptidsl->AppData.StdMode = (unsigned int)OamWrNegoParaDef.stdMode;
17393 +
17394 + OamWrNegoParaDef.oamFeature = dslhal_support_byteSwap32((OAMFEATURE_TC_SYNC_DETECT_MASK));
17395 + /* Set the flag to start retraining if the margin of the modem drops below
17396 + default margin during showtime */
17397 +
17398 + OamWrNegoParaDef.marginMonitorShwtme = FALSE;
17399 + /* Set the flag to start retraining if the margin of the modem drops below default margin during training */
17400 +
17401 + OamWrNegoParaDef.marginMonitorTrning = FALSE;
17402 + OamWrNegoParaDef.dsToneTurnoff_f = 0;
17403 + dslhal_support_blockWrite(&OamWrNegoParaDef,
17404 + (PVOID)dspOamSharedInterface.oamWriteNegoParams_p, sizeof(DEV_HOST_oamWrNegoParaDef_t));
17405 + rc=dslhal_support_setInterruptMask(ptidsl,0);
17406 + if(rc!=DSLHAL_ERROR_NO_ERRORS)
17407 + return rc;
17408 + /* Co Profile Test */
17409 +#if CO_PROFILES
17410 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
17411 + /* Access the profileList Structure */
17412 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
17413 + if (rc)
17414 + {
17415 + dprintf(1,"dslhal_support_blockRead failed\n");
17416 + return DSLHAL_ERROR_BLOCK_READ;
17417 + }
17418 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)dslhal_support_byteSwap32((unsigned int)profileList.hostProfileBase_p);
17419 + rc = dslhal_support_blockRead((PVOID)profileList.hostProfileBase_p,&coData, sizeof(DEV_HOST_coData_t));
17420 + if (rc)
17421 + {
17422 + dprintf(1,"dslhal_support_blockRead failed\n");
17423 + return DSLHAL_ERROR_BLOCK_READ;
17424 + }
17425 + dprintf(2,"Current Profile Vendor Id: %x \n",coData.phyAgcPgaTarget);
17426 + coData.phyAgcPgaTarget = 0xcaba;
17427 + rc = dslhal_support_blockWrite(&coData,(PVOID)profileList.hostProfileBase_p,sizeof(DEV_HOST_coData_t));
17428 + if(rc)
17429 + return DSLHAL_ERROR_BLOCK_WRITE;
17430 +#endif
17431 + /* End of CO Profile Test */
17432 +
17433 +#ifndef NO_ACT
17434 + /* Constellation Display Buffer Allocate */
17435 + ptidsl->constDisplay.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(DSP_CONSTELLATION_BUFFER_SIZE);
17436 + if(ptidsl->constDisplay.PmemStartWtAddr == NULL)
17437 + {
17438 + dprintf(1, "memory allocate error\n");
17439 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17440 + }
17441 + shim_osZeroMemory((void*)ptidsl->constDisplay.PmemStartWtAddr,DSP_CONSTELLATION_BUFFER_SIZE);
17442 + ptidsl->constDisplay.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->constDisplay.PmemStartWtAddr);
17443 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->constDisplay.PmemStartWtAddr, ptidsl->constDisplay.overlayHostAddr);
17444 + ptidsl->constDisplay.OverlayXferCount = DSP_CONSTELLATION_BUFFER_SIZE;
17445 +
17446 + /* Communicate the Allocated Buffer for DSP load Constellation Data */
17447 +
17448 + /* Change the Endianness of the profileList pointer */
17449 + dspOamSharedInterface.consDispVar_p = (DEV_HOST_consBufDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.consDispVar_p);
17450 + /* Access the profileList Structure */
17451 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.consDispVar_p,&constDisp, sizeof(DEV_HOST_consBufDef_t));
17452 +
17453 + if (rc)
17454 + {
17455 + dprintf(1,"dslhal_support_blockRead failed\n");
17456 + return DSLHAL_ERROR_BLOCK_READ;
17457 + }
17458 + dprintf(2,"Constellation Old Addr:%x New: %x \n",constDisp.consDispStartAddr,ptidsl->constDisplay.overlayHostAddr);
17459 + constDisp.consDispStartAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->constDisplay.overlayHostAddr);
17460 + constDisp.consDispCurrentAddr = constDisp.consDispStartAddr;
17461 + constDisp.consDispBufLen = (unsigned int)dslhal_support_byteSwap32(DSP_CONSTELLATION_BUFFER_SIZE);
17462 + rc = dslhal_support_blockWrite(&constDisp,(PVOID)dspOamSharedInterface.consDispVar_p,sizeof(DEV_HOST_consBufDef_t));
17463 + if (rc)
17464 + return DSLHAL_ERROR_BLOCK_WRITE;
17465 +#endif
17466 + dprintf(5,"dslhal_support_hostDspCodeDownload() completed.\n");
17467 + return DSLHAL_ERROR_NO_ERRORS;
17468 +
17469 +} /* end of dslhal_support_hostDspCodeDownload() */
17470 +
17471 +/********************************************************************************************
17472 +* FUNCTION NAME: dslhal_support_readDelineationState()
17473 +*
17474 +*********************************************************************************************
17475 +* DESCRIPTION:
17476 +* download DSP image from host memory to dsp memory
17477 +*
17478 +* Return: 0 success
17479 +* 1 failed
17480 +*
17481 +* NOTE:
17482 +* DSP image is based on LITTLE endian
17483 +*
17484 +********************************************************************************************/
17485 +
17486 +unsigned int dslhal_support_readDelineationState(tidsl_t * ptidsl)
17487 +{
17488 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17489 + DEV_HOST_atmStats_t atmStats;
17490 + DEV_HOST_dsAtmStats_t dsAtmStats0;
17491 + unsigned int rc=0, delinState=0;
17492 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17493 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17494 + if (rc)
17495 + {
17496 + dprintf(1,"dslhal_support_blockRead failed\n");
17497 + return DSLHAL_ERROR_BLOCK_READ;
17498 + }
17499 +
17500 + dspOamSharedInterface.atmStats_p = (DEV_HOST_atmStats_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.atmStats_p);
17501 +
17502 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.atmStats_p,&atmStats, sizeof(DEV_HOST_atmStats_t));
17503 +
17504 + if (rc)
17505 + {
17506 + dprintf(1,"dslhal_support_blockRead failed\n");
17507 + return DSLHAL_ERROR_BLOCK_READ;
17508 + }
17509 +
17510 + atmStats.ds0_p = (DEV_HOST_dsAtmStats_t *) dslhal_support_byteSwap32((unsigned int)atmStats.ds0_p);
17511 +
17512 + rc = dslhal_support_blockRead((PVOID)atmStats.ds0_p,&dsAtmStats0, (sizeof(DEV_HOST_dsAtmStats_t)));
17513 +
17514 + if (rc)
17515 + return rc;
17516 + delinState = dslhal_support_byteSwap32(dsAtmStats0.delineationState);
17517 + if(delinState == TC_SYNC)
17518 + ptidsl->lConnected = 1;
17519 + else
17520 + ptidsl->lConnected = 0;
17521 + return DSLHAL_ERROR_NO_ERRORS;
17522 +}
17523 +
17524 +/********************************************************************************************
17525 +* FUNCTION NAME: dslhal_support_processModemStateBitField()
17526 +*
17527 +*********************************************************************************************
17528 +* DESCRIPTION:
17529 +* download DSP image from host memory to dsp memory
17530 +*
17531 +* Return: 0 success
17532 +* 1 failed
17533 +*
17534 +* NOTE:
17535 +* DSP image is based on LITTLE endian
17536 +*
17537 +********************************************************************************************/
17538 +
17539 +unsigned int dslhal_support_processModemStateBitField(tidsl_t * ptidsl)
17540 +{
17541 + int rc, offset[2]={2,0};
17542 + int modemStateBitFields[NUMBER_OF_BITFIELDS],changedField=0;
17543 + rc = dslhal_api_dspInterfaceRead(ptidsl,(unsigned int)ptidsl->pmainAddr,2,(unsigned int *)&offset,
17544 + (unsigned char *)&modemStateBitFields,NUMBER_OF_BITFIELDS*sizeof(int));
17545 + if (rc)
17546 + return DSLHAL_ERROR_BLOCK_READ;
17547 + for(rc=0;rc<NUMBER_OF_BITFIELDS;rc++)
17548 + dprintf(4,"Bit Field %d: 0x%x \n",rc+1,dslhal_support_byteSwap32((unsigned int)modemStateBitFields[rc]));
17549 +
17550 + for(rc=NUMBER_OF_BITFIELDS;rc>0;rc--)
17551 + {
17552 + if(ptidsl->modemStateBitField[rc-1]!=modemStateBitFields[rc-1])
17553 + {
17554 + changedField = rc;
17555 + break;
17556 + }
17557 + }
17558 + if(changedField)
17559 + {
17560 + for(rc=0;rc<32;rc++)
17561 + {
17562 + if(modemStateBitFields[changedField-1] & dslhal_support_byteSwap32((BITFIELD_SCAN >> rc)))
17563 + break;
17564 + }
17565 + dprintf(5,"Changed Field : %d Changed Bit : %d \n",changedField,(31-rc));
17566 + ptidsl->rState = ((changedField*100) + (31-rc));
17567 + dprintf(5,"Modem State : %d \n",ptidsl->rState);
17568 + shim_osMoveMemory((void *)ptidsl->modemStateBitField,(void *)modemStateBitFields, 4*NUMBER_OF_BITFIELDS);
17569 + }
17570 +
17571 + switch(changedField)
17572 + {
17573 + case 1: if((ptidsl->rState >= ATU_RIDLE) && (ptidsl->AppData.bState < RSTATE_IDLE))
17574 + ptidsl->AppData.bState = RSTATE_IDLE;
17575 + if((ptidsl->rState >= GDMT_NSFLR) && (ptidsl->AppData.bState < RSTATE_INIT))
17576 + ptidsl->AppData.bState = RSTATE_INIT;
17577 + if((ptidsl->rState >= GDMT_ACKX) && (ptidsl->AppData.bState < RSTATE_HS))
17578 + ptidsl->AppData.bState = RSTATE_HS;
17579 + break;
17580 +
17581 + case 2: if((ptidsl->rState >= T1413_NSFLR) && (ptidsl->AppData.bState < RSTATE_INIT))
17582 + ptidsl->AppData.bState = RSTATE_INIT;
17583 + if((ptidsl->rState >= T1413_ACKX) && (ptidsl->AppData.bState < RSTATE_HS))
17584 + ptidsl->AppData.bState = RSTATE_HS;
17585 + if((ptidsl->rState == ATU_RSHOWTIME) && (ptidsl->AppData.bState < RSTATE_SHOWTIME))
17586 + ptidsl->AppData.bState = RSTATE_SHOWTIME;
17587 + break;
17588 +
17589 + case 3: if((ptidsl->rState >= ADSL2_COMB3) && (ptidsl->AppData.bState < RSTATE_INIT))
17590 + ptidsl->AppData.bState = RSTATE_INIT;
17591 + if((ptidsl->rState >= ADSL2_RPARAMS) && (ptidsl->AppData.bState < RSTATE_HS))
17592 + ptidsl->AppData.bState = RSTATE_HS;
17593 + break;
17594 +
17595 + case 4: break;
17596 + default: break;
17597 + }
17598 +
17599 + ptidsl->stateTransition = modemStateBitFields[1];
17600 + switch(ptidsl->AppData.bState)
17601 + {
17602 + case RSTATE_IDLE: ptidsl->AppData.idleTick=shim_osClockTick();
17603 + ptidsl->AppData.initTick=0;
17604 + ptidsl->AppData.showtimeTick=0;
17605 + break;
17606 + case RSTATE_HS: if(!ptidsl->AppData.initTick)
17607 + {
17608 + ptidsl->AppData.initTick=shim_osClockTick();
17609 + }
17610 + ptidsl->AppData.showtimeTick=0;
17611 + break;
17612 + case RSTATE_SHOWTIME: if(!ptidsl->AppData.showtimeTick)
17613 + ptidsl->AppData.showtimeTick=shim_osClockTick();
17614 + break;
17615 + default: break;
17616 + }
17617 + return DSLHAL_ERROR_NO_ERRORS;
17618 +}
17619 +
17620 +/********************************************************************************************
17621 +* FUNCTION NAME: dslhal_support_setInterruptMask()
17622 +*
17623 +*********************************************************************************************
17624 +* DESCRIPTION:
17625 +* Sets the host interrupt bit masks
17626 +*
17627 +* Return: 0 success
17628 +* 1 failed
17629 +*
17630 +* NOTE:
17631 +* DSP image is based on LITTLE endian
17632 +*
17633 +********************************************************************************************/
17634 +
17635 +unsigned int dslhal_support_setInterruptMask(tidsl_t * ptidsl,unsigned int inputMask)
17636 +{
17637 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17638 + DEV_HOST_hostInterruptMask_t interruptMask;
17639 + unsigned int rc=0;
17640 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17641 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17642 + if (rc)
17643 + {
17644 + dprintf(1,"dslhal_support_blockRead failed\n");
17645 + return DSLHAL_ERROR_BLOCK_READ;
17646 + }
17647 + dspOamSharedInterface.hostInterruptMask_p =(DEV_HOST_hostInterruptMask_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.hostInterruptMask_p);
17648 +
17649 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.hostInterruptMask_p,
17650 + &interruptMask, sizeof(DEV_HOST_hostInterruptMask_t));
17651 + if (rc)
17652 + {
17653 + dprintf(1,"dslhal_support_blockRead failed\n");
17654 + return DSLHAL_ERROR_BLOCK_READ;
17655 + }
17656 + if(inputMask & MASK_MAILBOX_INTERRUPTS)
17657 + {
17658 + dprintf(7,"Mailbox Interrupts Masked \n");
17659 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17660 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_MAILBOX_INTERRUPTS);
17661 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17662 + }
17663 + if(inputMask & MASK_BITFIELD_INTERRUPTS)
17664 + {
17665 + dprintf(7,"Bit field Interrupts Masked \n");
17666 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17667 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_BITFIELD_INTERRUPTS);
17668 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17669 + }
17670 + if(inputMask & MASK_HEARTBEAT_INTERRUPTS)
17671 + {
17672 + dprintf(7,"Bit field Interrupts Masked \n");
17673 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17674 + interruptMask.maskBitField1 |= dslhal_support_byteSwap32(MASK_HEARTBEAT_INTERRUPTS);
17675 + dprintf(7,"interruptMask.maskBitField1 = %d \n",dslhal_support_byteSwap32(interruptMask.maskBitField1));
17676 + }
17677 + dslhal_support_blockWrite(&interruptMask,
17678 + dspOamSharedInterface.hostInterruptMask_p, sizeof(DEV_HOST_hostInterruptMask_t));
17679 + dprintf(5,"dslhal_support_setInterruptMask() completed.\n");
17680 + return DSLHAL_ERROR_NO_ERRORS;
17681 +}
17682 +
17683 +/********************************************************************************************
17684 +* FUNCTION NAME: dslhal_support_parseInterruptSource()
17685 +*
17686 +*********************************************************************************************
17687 +* DESCRIPTION:
17688 +* Parses the Interrupt Source Bit Field
17689 +*
17690 +* Return: interrupt Code if successful
17691 +* negative error code if failed
17692 +*
17693 +* NOTE:
17694 +* DSP image is based on LITTLE endian
17695 +*
17696 +********************************************************************************************/
17697 +
17698 +unsigned int dslhal_support_parseInterruptSource(tidsl_t * ptidsl)
17699 +{
17700 + DEV_HOST_dspOamSharedInterface_t *pdspOamSharedInterface, dspOamSharedInterface;
17701 + DEV_HOST_hostInterruptSource_t interruptSource;
17702 + unsigned int rc=0,intrCode=0;
17703 + pdspOamSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
17704 + rc = dslhal_support_blockRead(pdspOamSharedInterface, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
17705 + if (rc)
17706 + {
17707 + dprintf(1,"dslhal_support_blockRead failed\n");
17708 + return (0-DSLHAL_ERROR_BLOCK_READ);
17709 + }
17710 + dspOamSharedInterface.hostInterruptSource_p =(DEV_HOST_hostInterruptSource_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.hostInterruptSource_p);
17711 +
17712 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.hostInterruptSource_p,
17713 + &interruptSource, sizeof(DEV_HOST_hostInterruptSource_t));
17714 + if (rc)
17715 + {
17716 + dprintf(1,"dslhal_support_blockRead failed\n");
17717 + return (0-DSLHAL_ERROR_BLOCK_READ);
17718 + }
17719 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_MAILBOX_INTERRUPTS))
17720 + {
17721 + dprintf(7,"Mailbox Interrupts Acknowledge \n");
17722 + intrCode |= 0x00000011;
17723 + }
17724 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_BITFIELD_INTERRUPTS))
17725 + {
17726 + dprintf(7,"Bit field Interrupt Acknowledge \n");
17727 + intrCode |= 0x00001002;
17728 + }
17729 + if(interruptSource.sourceBitField1 & dslhal_support_byteSwap32(MASK_HEARTBEAT_INTERRUPTS))
17730 + {
17731 + dprintf(7,"HeartBeat Interrupt Acknowledge \n");
17732 + intrCode |= 0x00100004;
17733 + }
17734 +
17735 + interruptSource.sourceBitField1 &=0x0;
17736 + rc=dslhal_support_blockWrite(&interruptSource,
17737 + dspOamSharedInterface.hostInterruptSource_p, sizeof(DEV_HOST_hostInterruptSource_t));
17738 + if(rc)
17739 + return (0-DSLHAL_ERROR_BLOCK_WRITE);
17740 + dprintf(5,"dslhal_support_parseInterruptSource() completed.\n");
17741 + return intrCode;
17742 +}
17743 +
17744 +/********************************************************************************************
17745 +* FUNCTION NAME: dslhal_support_byteSwap16()
17746 +*
17747 +*********************************************************************************************
17748 +* DESCRIPTION:
17749 +* input 16 bit short, byte swap from little endian to big endian or vise versa
17750 +*
17751 +********************************************************************************************/
17752 +
17753 +unsigned short dslhal_support_byteSwap16(unsigned short in16Bits)
17754 +{
17755 + unsigned short out16Bits;
17756 +
17757 +#ifdef EB
17758 + unsigned char *pchar;
17759 + unsigned char tmp;
17760 +#endif
17761 +
17762 + out16Bits = in16Bits;
17763 +
17764 +#ifdef EB
17765 + pchar = (unsigned char *)(&out16Bits);
17766 +
17767 + tmp = *pchar;
17768 + *pchar = *(pchar + 1);
17769 + *(pchar + 1) = tmp;
17770 +#endif
17771 +
17772 + return out16Bits;
17773 +
17774 +} /* end of dslhal_support_byteSwap16() */
17775 +
17776 +/********************************************************************************************
17777 +* FUNCTION NAME: dslhal_support_byteSwap32()
17778 +*
17779 +*********************************************************************************************
17780 +* DESCRIPTION:
17781 +* input 32 bit int, byte swap from little endian to big endian or vise versa
17782 +*
17783 +********************************************************************************************/
17784 +
17785 +unsigned int dslhal_support_byteSwap32(unsigned int in32Bits)
17786 +{
17787 + int out32Bits;
17788 +
17789 +#ifdef EB
17790 + unsigned char tmp;
17791 + unsigned char *pchar;
17792 +#endif
17793 +
17794 + out32Bits = in32Bits;
17795 +
17796 +#ifdef EB
17797 + pchar = (unsigned char *)(&out32Bits);
17798 +
17799 + tmp = *pchar;
17800 + *pchar = *(pchar + 3);
17801 + *(pchar + 3) = tmp;
17802 +
17803 + tmp = *(pchar + 1);
17804 + *(pchar + 1) = *(pchar + 2);
17805 + *(pchar + 2) = tmp;
17806 +#endif
17807 +
17808 + return out32Bits;
17809 +
17810 +} /* end of dslhal_support_byteSwap32() */
17811 +
17812 +
17813 +/********************************************************************************************
17814 +* FUNCTION NAME: dslhal_support_computeCrc32()
17815 +*
17816 +*********************************************************************************************
17817 +* DESCRIPTION:
17818 +* Computes the CRC-32 for the input data
17819 +*
17820 +* Return: 32 bit CRC of the input data
17821 +*
17822 +*
17823 +* NOTE:
17824 +* DSP image is based on LITTLE endian
17825 +*
17826 +********************************************************************************************/
17827 +unsigned int dslhal_support_computeCrc32(unsigned char *data, int len)
17828 +{
17829 + unsigned int result;
17830 + int i,j;
17831 + unsigned char octet;
17832 +
17833 + if ((len < 4) || (data==NULL))
17834 + return(0xdeaddead);
17835 + result = *data++ << 24;
17836 + result |= *data++ << 16;
17837 + result |= *data++ << 8;
17838 + result |= *data++;
17839 + result = ~ result;
17840 +
17841 + len -=4;
17842 +
17843 + for (i=0; i<len; i++)
17844 + {
17845 + octet = *(data++);
17846 + for (j=0; j<8; j++)
17847 + {
17848 + if (result & 0x80000000)
17849 + {
17850 + result = (result << 1) ^ CRC32_QUOTIENT ^ (octet >> 7);
17851 + }
17852 + else
17853 + {
17854 + result = (result << 1) ^ (octet >> 7);
17855 + }
17856 + octet <<= 1;
17857 + }
17858 + }
17859 + return ~result; /* The complement of the remainder */
17860 +}
17861 +
17862 +/********************************************************************************************
17863 +* FUNCTION NAME: dslhal_support_checkOverlayPage()
17864 +*
17865 +*********************************************************************************************
17866 +* DESCRIPTION:
17867 +* Computes the CRC-32 for the input data and compares it with reference
17868 +*
17869 +* Return: Error Condition (if any)
17870 +*
17871 +*
17872 +* NOTE:
17873 +* DSP image is based on LITTLE endian
17874 +*
17875 +********************************************************************************************/
17876 +unsigned int dslhal_support_checkOverlayPage(tidsl_t *ptidsl, unsigned int tag)
17877 +{
17878 + unsigned int computedCrc;
17879 + if((unsigned char *)ptidsl->olayDpPage[tag].PmemStartWtAddr == NULL)
17880 + {
17881 + dprintf(5,"Null Address for Page: %d\n",tag);
17882 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17883 + }
17884 + computedCrc = dslhal_support_computeCrc32((unsigned char *)ptidsl->olayDpPage[tag].PmemStartWtAddr, ptidsl->olayDpPage[tag].OverlayXferCount);
17885 + dprintf(6,"\n Pre-Computed CRC32 = 0x%x \t Current CRC32 = 0x%x \n",ptidsl->olayDpPage[tag].olayPageCrc32,computedCrc);
17886 + if(computedCrc != ptidsl->olayDpPage[tag].olayPageCrc32)
17887 + return DSLHAL_ERROR_OVERLAY_CORRUPTED;
17888 + else
17889 + return DSLHAL_ERROR_NO_ERRORS;
17890 +}
17891 +
17892 +/********************************************************************************************
17893 +* FUNCTION NAME: dslhal_support_clearTrainingInfo()
17894 +*
17895 +*********************************************************************************************
17896 +* DESCRIPTION:
17897 +* Computes the CRC-32 for the input data and compares it with reference
17898 +*
17899 +* Return: Error Condition (if any)
17900 +*
17901 +*
17902 +* NOTE:
17903 +* DSP image is based on LITTLE endian
17904 +*
17905 +********************************************************************************************/
17906 +
17907 +int dslhal_support_clearTrainingInfo(tidsl_t *ptidsl)
17908 +{
17909 + int i;
17910 +
17911 + for(i=0; i<NUM_PAGES; i++)
17912 + {
17913 + if(ptidsl->olayDpPage[i].PmemStartWtAddr !=NULL)
17914 + {
17915 + shim_osFreeDmaMemory((void *) ptidsl->olayDpPage[i].PmemStartWtAddr,
17916 + ptidsl->olayDpPage[i].OverlayXferCount);
17917 + ptidsl->olayDpPage[i].PmemStartWtAddr =NULL;
17918 + }
17919 + }
17920 + if(ptidsl->coProfiles.PmemStartWtAddr != NULL)
17921 + {
17922 + shim_osFreeDmaMemory((void *)ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.OverlayXferCount);
17923 + ptidsl->coProfiles.PmemStartWtAddr = NULL;
17924 + }
17925 + return 0;
17926 +}
17927 +
17928 +
17929 +/********************************************************************************************
17930 +* FUNCTION NAME: dslhal_support_reloadTrainingInfo()
17931 +*
17932 +*********************************************************************************************
17933 +* DESCRIPTION:
17934 +* Reload overlay pages from flash or memory
17935 +*
17936 +* Return: 0 success
17937 +* 1 failed
17938 +*
17939 +* NOTE:
17940 +* DSP image is based on LITTLE endian
17941 +*
17942 +********************************************************************************************/
17943 +
17944 +int dslhal_support_reloadTrainingInfo(tidsl_t * ptidsl)
17945 +{
17946 +
17947 + int rc = 0, i;
17948 + unsigned int olayXfer,olayStore;
17949 + unsigned int *olayStart;
17950 +
17951 + unsigned int crc32;
17952 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
17953 + DEV_HOST_olayDpDef_t olayDpParms;
17954 + DEV_HOST_olayDpPageDef_t olayDpPageDef[NUM_PAGES];
17955 + DEV_HOST_profileBase_t profileList;
17956 +
17957 + unsigned int secLength, secOffset, secPage;
17958 +
17959 + /* co profile */
17960 + secLength = ptidsl->coProfiles.OverlayXferCount;
17961 + secOffset = ptidsl->coProfiles.SecOffset;
17962 + ptidsl->coProfiles.PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
17963 + if(ptidsl->coProfiles.PmemStartWtAddr == NULL)
17964 + {
17965 + dprintf(1, "memory allocate error\n");
17966 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17967 + }
17968 + /* holdSecPhyAddr = virtual2Physical((unsigned int)holdSecVirtAddr); */
17969 + ptidsl->coProfiles.overlayHostAddr = virtual2Physical((unsigned int)ptidsl->coProfiles.PmemStartWtAddr);
17970 + dprintf(4,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->coProfiles.PmemStartWtAddr, ptidsl->coProfiles.overlayHostAddr);
17971 + ptidsl->coProfiles.overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->coProfiles.overlayHostAddr);
17972 +
17973 + rc = shim_read_overlay_page((void *)ptidsl->coProfiles.PmemStartWtAddr, secOffset, secLength);
17974 + if(rc != secLength)
17975 + {
17976 + dprintf(1, "shim_read_overlay_page failed\n");
17977 + return DSLHAL_ERROR_OVERLAY_MALLOC;
17978 + }
17979 +
17980 + /*shim_osMoveMemory((char *)ptidsl->coProfiles.PmemStartWtAddr, (char *)iptr, secLength);*/
17981 + /* RamP Image ByteSwap test */
17982 + olayStart = (unsigned int *)ptidsl->coProfiles.PmemStartWtAddr;
17983 +
17984 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
17985 + {
17986 + olayStore = *(unsigned int *)olayStart;
17987 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
17988 + *(unsigned int*)olayStart = olayStore;
17989 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
17990 + olayStart++;
17991 + olayStore=0;
17992 + }
17993 + shim_osWriteBackCache((void *)ptidsl->coProfiles.PmemStartWtAddr, secLength);
17994 +
17995 +
17996 + for (secPage=1;secPage<NUM_PAGES; secPage++)
17997 + {
17998 +
17999 + dprintf(6,"OVERLAY PAGE #%d\n",secPage);
18000 +
18001 + secLength = ptidsl->olayDpPage[secPage].OverlayXferCount;
18002 +
18003 + dprintf(4,"Section[%d] Length: %d \n",secPage, secLength);
18004 +
18005 + secOffset = ptidsl->olayDpPage[secPage].SecOffset;
18006 + ptidsl->olayDpPage[secPage].PmemStartWtAddr = (unsigned int) shim_osAllocateDmaMemory(secLength);
18007 + if(ptidsl->olayDpPage[secPage].PmemStartWtAddr == NULL)
18008 + {
18009 + dprintf(1, "overlay page allocate error\n");
18010 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18011 + }
18012 +
18013 + rc = shim_read_overlay_page((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr,secOffset, secLength);
18014 + if(rc != secLength)
18015 + {
18016 + dprintf(1, "overlay page read error\n");
18017 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18018 + }
18019 +
18020 + /* ptidsl->olayDpPage[secPage].overlayHostAddr = ((unsigned int)(ptidsl->olayDpPage[secPage].PmemStartWtAddr)&~0xe0000000); */
18021 + ptidsl->olayDpPage[secPage].overlayHostAddr = virtual2Physical((unsigned int)ptidsl->olayDpPage[secPage].PmemStartWtAddr);
18022 + dprintf(6,"Allocated Addr: 0x%x \t Xlated Addr: 0x%x \n",ptidsl->olayDpPage[secPage].PmemStartWtAddr,ptidsl->olayDpPage[secPage].overlayHostAddr);
18023 +
18024 + ptidsl->olayDpPage[secPage].overlayHostAddr = (unsigned int)dslhal_support_byteSwap32(ptidsl->olayDpPage[secPage].overlayHostAddr);
18025 + /*ptidsl->olayDpPage[secPage].OverlayXferCount = secLength;
18026 + ptidsl->olayDpPage[secPage].BinAddr = secAddr;
18027 + shim_osMoveMemory((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, (char *)iptr, secLength);
18028 + */
18029 + olayStart = (unsigned int *)ptidsl->olayDpPage[secPage].PmemStartWtAddr;
18030 +
18031 + for(olayXfer=0;olayXfer< secLength/4;olayXfer++)
18032 + {
18033 + olayStore = *(unsigned int *)olayStart;
18034 + olayStore = (unsigned int)dslhal_support_byteSwap32(olayStore);
18035 + *(unsigned int*)olayStart = olayStore;
18036 + dprintf(5, "Addr:0x%x \t Content: 0x%x \n",olayStart,olayStore);
18037 + olayStart++;
18038 + olayStore=0;
18039 + }
18040 + /* RamP Image ByteSwap test */
18041 + /* compute the CRC of each overlay page and Store the Checksum in a local global variable */
18042 + /* This Value of CRC is to be compared with the header where all the CRC bytes are lumped together */
18043 + crc32 = dslhal_support_computeCrc32((char *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, ptidsl->olayDpPage[secPage].OverlayXferCount);
18044 + if(crc32 != ptidsl->olayDpPage[secPage].olayPageCrc32)
18045 + return DSLHAL_ERROR_OVERLAY_MALLOC;
18046 +
18047 + shim_osWriteBackCache((void *)ptidsl->olayDpPage[secPage].PmemStartWtAddr, secLength);
18048 + }
18049 +
18050 +
18051 + dprintf(5,"ptidsl->hostIf.mainAddr=0x%X\n", (unsigned int)ptidsl->pmainAddr);
18052 +
18053 + /* get the pointer to DSP-OAM Shared Interface */
18054 + rc = dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,
18055 + sizeof(DEV_HOST_dspOamSharedInterface_t));
18056 + if (rc)
18057 + {
18058 + dprintf(1,"dslhal_support_blockRead failed\n");
18059 + return DSLHAL_ERROR_BLOCK_READ;
18060 + }
18061 +
18062 + /* Communicate the Allocated Memory Address to DSP to choose CO Profiles */
18063 +
18064 + /* Change the Endianness of the profileList pointer */
18065 + dspOamSharedInterface.profileList_p = (DEV_HOST_profileBase_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.profileList_p);
18066 + /* Access the profileList Structure */
18067 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.profileList_p,&profileList, sizeof(DEV_HOST_profileBase_t));
18068 +
18069 + if (rc)
18070 + {
18071 + dprintf(1,"dslhal_support_blockRead failed\n");
18072 + return DSLHAL_ERROR_BLOCK_READ;
18073 + }
18074 + dprintf(2,"Old Addr:%x New: %x \n",profileList.hostProfileBase_p,ptidsl->coProfiles.overlayHostAddr);
18075 + profileList.hostProfileBase_p = (DEV_HOST_coData_t *)ptidsl->coProfiles.overlayHostAddr;
18076 + rc = dslhal_support_blockWrite(&profileList,(PVOID)dspOamSharedInterface.profileList_p,sizeof(DEV_HOST_profileBase_t));
18077 + if (rc)
18078 + return DSLHAL_ERROR_BLOCK_WRITE;
18079 +
18080 + /* Communicate the Allocated Memory Address to DSP to do overlays */
18081 +
18082 + /* Change the Endianness of the olayDpDef pointer */
18083 + dspOamSharedInterface.olayDpParms_p = (DEV_HOST_olayDpDef_t *)dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.olayDpParms_p);
18084 + /* Access the olayDpDef Structure */
18085 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.olayDpParms_p,&olayDpParms, sizeof(DEV_HOST_olayDpDef_t));
18086 +
18087 + if (rc)
18088 + {
18089 + dprintf(1,"dslhal_support_blockRead failed\n");
18090 + return DSLHAL_ERROR_BLOCK_READ;
18091 + }
18092 +
18093 +
18094 + for(i=1;i<NUM_PAGES;i++)
18095 + {
18096 + /* Change the endianness of the olayDpPageDef Pointer */
18097 + olayDpParms.olayDpPage_p[i] = (DEV_HOST_olayDpPageDef_t *) dslhal_support_byteSwap32((unsigned int)olayDpParms.olayDpPage_p[i]);
18098 + /* Access the olayDpPageDef Structure */
18099 + rc = dslhal_support_blockRead((PVOID)olayDpParms.olayDpPage_p[i],&olayDpPageDef[i],sizeof(DEV_HOST_olayDpPageDef_t));
18100 + if (rc)
18101 + return DSLHAL_ERROR_BLOCK_READ;
18102 + olayDpPageDef[i].overlayHostAddr = ptidsl->olayDpPage[i].overlayHostAddr;
18103 + rc = dslhal_support_blockWrite(&olayDpPageDef[i],(PVOID)olayDpParms.olayDpPage_p[i],sizeof(DEV_HOST_olayDpPageDef_t));
18104 + if (rc)
18105 + return DSLHAL_ERROR_BLOCK_WRITE;
18106 + }
18107 +
18108 + ptidsl->bOverlayPageLoaded = 1;
18109 + return DSLHAL_ERROR_NO_ERRORS;
18110 +}
18111 + /* end of dslhal_support_reloadTrainingInfo() */
18112 +
18113 +
18114 +/********************************************************************************************
18115 +* FUNCTION NAME: dslhal_support_restoreTrainingInfo()
18116 +*
18117 +*********************************************************************************************
18118 +* DESCRIPTION:
18119 +* Computes the CRC-32 for the input data and compares it with reference
18120 +*
18121 +* Return: Error Condition (if any)
18122 +*
18123 +*
18124 +* NOTE:
18125 +* DSP image is based on LITTLE endian
18126 +*
18127 +********************************************************************************************/
18128 +
18129 +
18130 +int dslhal_support_restoreTrainingInfo(tidsl_t *ptidsl)
18131 +{
18132 + int rc;
18133 +
18134 + rc=1;
18135 + while(rc != 0)
18136 + {
18137 + dslhal_support_clearTrainingInfo(ptidsl);
18138 + //shim_osCriticalEnter();
18139 + rc = dslhal_support_reloadTrainingInfo(ptidsl);
18140 + //shim_osCriticalExit();
18141 + shim_osClockWait(6400);
18142 + }
18143 + return 0;
18144 +}
18145 +
18146 +/********************************************************************************************
18147 +* FUNCTION NAME: dslhal_support_advancedIdleProcessing()
18148 +*
18149 +*********************************************************************************************
18150 +* DESCRIPTION:
18151 +* Calls Advanced Idle State Processing Functions
18152 +*
18153 +* Return: Error Condition (if any)
18154 +*
18155 +*
18156 +* NOTE:
18157 +* DSP image is based on LITTLE endian
18158 +*
18159 +********************************************************************************************/
18160 +unsigned int dslhal_support_advancedIdleProcessing(tidsl_t *ptidsl)
18161 +{
18162 + int rc=0;
18163 + ptidsl->AppData.bState = RSTATE_IDLE;
18164 +#ifndef NO_ACT
18165 + rc += dslhal_advcfg_resetBitSwapMessageLog(ptidsl,0);
18166 + rc += dslhal_advcfg_resetBitSwapMessageLog(ptidsl,1);
18167 + rc += dslhal_advcfg_resetTrainStateHistory(ptidsl);
18168 + rc += dslhal_advcfg_getReasonForDrop(ptidsl);
18169 +#endif
18170 + if(rc)
18171 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18172 + else
18173 + return DSLHAL_ERROR_NO_ERRORS;
18174 +}
18175 +
18176 +/********************************************************************************************
18177 +* FUNCTION NAME: dslhal_support_aocBitSwapProcessing()
18178 +*
18179 +*********************************************************************************************
18180 +* DESCRIPTION:
18181 +* Calls Advanced Idle State Processing Functions
18182 +*
18183 +* Return: Error Condition (if any)
18184 +*
18185 +*
18186 +* NOTE:
18187 +* DSP image is based on LITTLE endian
18188 +*
18189 +********************************************************************************************/
18190 +unsigned int dslhal_support_aocBitSwapProcessing(tidsl_t *ptidsl,unsigned int usDs)
18191 +{
18192 + int rc=0;
18193 +#ifndef NO_ACT
18194 + int i;
18195 + int differentCmd_f;
18196 + unsigned int dsSwapInx;
18197 +
18198 + static UINT8 lastAturBitSwapCommands[6] = {0, 0, 0, 0, 0, 0};
18199 + static UINT8 lastAturBitSwapBinNum[6] = {0, 0, 0, 0, 0, 0};
18200 +
18201 + if (usDs == 0)
18202 + {
18203 + dprintf(4," DSP_XMITBITSWAP\n");
18204 + rc += dslhal_advcfg_getAocBitswapBuffer(ptidsl,0);
18205 + ptidsl->usBitSwapInx++;
18206 + if (ptidsl->usBitSwapInx > 29)
18207 + ptidsl->usBitSwapInx=0;
18208 + }
18209 +
18210 + if (usDs == 1)
18211 + {
18212 + dprintf(4," DSP_RCVBITSWAP\n");
18213 + rc += dslhal_advcfg_getAocBitswapBuffer(ptidsl,1);
18214 + differentCmd_f = FALSE;
18215 + dsSwapInx = ptidsl->dsBitSwapInx;
18216 + if (! rc)
18217 + {
18218 + for (i = 0; i < 6; i++)
18219 + {
18220 + if (lastAturBitSwapCommands[i] != ptidsl->dsBitSwap[dsSwapInx].bitSwapCommand[i])
18221 + {
18222 + differentCmd_f = TRUE;
18223 + break;
18224 + }
18225 + }
18226 + if (! differentCmd_f)
18227 + {
18228 + for (i = 0; i < 6; i++)
18229 + {
18230 + if (lastAturBitSwapBinNum[i] != ptidsl->dsBitSwap[dsSwapInx].bitSwapBinNum[i])
18231 + {
18232 + differentCmd_f = TRUE;
18233 + break;
18234 + }
18235 + }
18236 + }
18237 + //CPE data pump seems to occasionally send us the same bit swap twice in a row with different sframe counter.
18238 + //Since these are never counted twice by the debug output of AC5, we should not count them twice either.
18239 + //So, we ignore the sframe_counter in determining whether the most recent bitswap is a duplicate.
18240 + if (differentCmd_f)
18241 + {
18242 + shim_osMoveMemory((void *)lastAturBitSwapCommands, (void *)ptidsl->dsBitSwap[dsSwapInx].bitSwapCommand, 6);
18243 + shim_osMoveMemory((void *)lastAturBitSwapBinNum, (void *)ptidsl->dsBitSwap[dsSwapInx].bitSwapBinNum, 6);
18244 + ptidsl->dsBitSwapInx++;
18245 + if (ptidsl->dsBitSwapInx > 29)
18246 + ptidsl->dsBitSwapInx = 0;
18247 + }
18248 + }
18249 + }
18250 +#endif
18251 + if(rc)
18252 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18253 + else
18254 + return DSLHAL_ERROR_NO_ERRORS;
18255 +}
18256 +
18257 +/********************************************************************************************
18258 +* FUNCTION NAME: dslhal_support_gatherEocMessages()
18259 +*
18260 +*********************************************************************************************
18261 +* DESCRIPTION:
18262 +* Calls Advanced EOC Buffering functions
18263 +*
18264 +* Return: Error Condition (if any)
18265 +*
18266 +*
18267 +* NOTE:
18268 +* DSP image is based on LITTLE endian
18269 +*
18270 +********************************************************************************************/
18271 +unsigned int dslhal_support_gatherEocMessages(tidsl_t *ptidsl,int usDs, int msgPart1, int msgPart2)
18272 +{
18273 + int rc=0;
18274 +#ifndef NO_ACT
18275 + rc = dslhal_advcfg_logEocMessages(ptidsl,usDs, msgPart1, msgPart2);
18276 +#endif
18277 + if(rc)
18278 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18279 + else
18280 + return DSLHAL_ERROR_NO_ERRORS;
18281 +}
18282 +/********************************************************************************************
18283 +* FUNCTION NAME: dslhal_support_gatherSnrPerBin()
18284 +*
18285 +*********************************************************************************************
18286 +* DESCRIPTION:
18287 +* Calls Advanced Snr per bin buffering Functions
18288 +*
18289 +* Return: Error Condition (if any)
18290 +*
18291 +*
18292 +* NOTE:
18293 +* DSP image is based on LITTLE endian
18294 +*
18295 +********************************************************************************************/
18296 +unsigned int dslhal_support_gatherSnrPerBin(tidsl_t *ptidsl,unsigned int snrParam)
18297 +{
18298 + int rc=0;
18299 +#ifndef NO_ACT
18300 + rc = dslhal_advcfg_getSnrPerBin(ptidsl,snrParam);
18301 +#endif
18302 + if(rc)
18303 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18304 + else
18305 + return DSLHAL_ERROR_NO_ERRORS;
18306 +}
18307 +
18308 +/********************************************************************************************
18309 +* FUNCTION NAME: dslhal_support_processTrainingState()
18310 +*
18311 +*********************************************************************************************
18312 +* DESCRIPTION:
18313 +* Calls Advanced Training State Processing Functions
18314 +*
18315 +* Return: Error Condition (if any)
18316 +*
18317 +*
18318 +* NOTE:
18319 +* DSP image is based on LITTLE endian
18320 +*
18321 +********************************************************************************************/
18322 +unsigned int dslhal_support_processTrainingState(tidsl_t *ptidsl)
18323 +{
18324 + int rc=0;
18325 +#ifndef NO_ACT
18326 +
18327 + if(ptidsl->trainStateInx<120)
18328 + {
18329 + rc = dslhal_advcfg_getTrainingState(ptidsl,(void *)&ptidsl->trainHistory[ptidsl->trainStateInx++]);
18330 + if(ptidsl->trainHistory[(ptidsl->trainStateInx-1)].subStateIndex ==
18331 + ptidsl->trainHistory[(ptidsl->trainStateInx-2)].subStateIndex)
18332 + ptidsl->trainStateInx--;
18333 + }
18334 + else
18335 + ptidsl->trainStateInx = 0;
18336 +#endif
18337 + if(rc)
18338 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18339 + else
18340 + return DSLHAL_ERROR_NO_ERRORS;
18341 +}
18342 +
18343 +/********************************************************************************************
18344 +* FUNCTION NAME: dslhal_support_gatherAdsl2Messages()
18345 +*
18346 +*********************************************************************************************
18347 +* DESCRIPTION:
18348 +* Gathers ADSL2 Training Messages
18349 +*
18350 +* Return: Error Condition (if any)
18351 +*
18352 +*
18353 +* NOTE:
18354 +* DSP image is based on LITTLE endian
18355 +*
18356 +********************************************************************************************/
18357 +unsigned int dslhal_support_gatherAdsl2Messages(tidsl_t *ptidsl,int tag, int param1, int param2)
18358 +{
18359 + int rc=0;
18360 + unsigned int adsl2MsgLoc;
18361 + switch(tag)
18362 + {
18363 + case CMSGFMT_INDEX:
18364 + dprintf(5,"C-Msg-FMT rec'd\n");
18365 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18366 + (ptidsl, CMSGFMT_INDEX);
18367 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18368 + ptidsl->adsl2TrainingMessages.cMsgFmt,CMSGFMT_SIZE);
18369 + break;
18370 + case RMSGFMT_INDEX:
18371 + case RMSGFMT2_INDEX:
18372 + dprintf(5,"R-Msg-FMT rec'd\n");
18373 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18374 + (ptidsl, RMSGFMT_INDEX);
18375 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18376 + ptidsl->adsl2TrainingMessages.rMsgFmt,RMSGFMT_SIZE);
18377 + break;
18378 + case CMSGPCB_INDEX:
18379 + dprintf(5,"C-Msg-PCB rec'd\n");
18380 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18381 + (ptidsl, CMSGPCB_INDEX);
18382 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18383 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB_SIZE);
18384 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB_SIZE;
18385 + break;
18386 + case CMSGPCB2_INDEX:
18387 + dprintf(5,"C-Msg-PCB2 rec'd\n");
18388 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18389 + (ptidsl, CMSGPCB2_INDEX);
18390 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18391 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB2_SIZE);
18392 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB2_SIZE;
18393 +#ifndef NO_ACT
18394 + rc += dslhal_advcfg_setBlackOutBits(ptidsl);
18395 +#endif
18396 + break;
18397 + case CMSGPCB2L_INDEX:
18398 + dprintf(5,"C-Msg-PCB2L rec'd\n");
18399 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18400 + (ptidsl, CMSGPCB2L_INDEX);
18401 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18402 + ptidsl->adsl2TrainingMessages.cMsgPcb,CMSGPCB2L_SIZE);
18403 + ptidsl->adsl2TrainingMessages.cMsgPcbLen = CMSGPCB2L_SIZE;
18404 + break;
18405 + case RMSGPCB_INDEX:
18406 + case RMSGPCB2L_INDEX:
18407 + dprintf(5,"R-Msg-PCB rec'd\n");
18408 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18409 + (ptidsl, RMSGPCB_INDEX);
18410 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18411 + ptidsl->adsl2TrainingMessages.rMsgPcb,RMSGPCB_SIZE);
18412 + ptidsl->adsl2TrainingMessages.rMsgPcbLen = RMSGPCB_SIZE;
18413 + break;
18414 +
18415 + case CMSG1ADSL2_INDEX:
18416 + dprintf(5,"C-Msg1 rec'd\n");
18417 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18418 + (ptidsl, CMSG1ADSL2_INDEX);
18419 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18420 + ptidsl->adsl2TrainingMessages.cMsg1,CMSG1ADSL2_SIZE);
18421 + ptidsl->adsl2TrainingMessages.cMsg1Len = CMSG1ADSL2_SIZE;
18422 + break;
18423 + case CMSG2ADSL2_INDEX:
18424 + dprintf(5,"C-Msg2 rec'd\n");
18425 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18426 + (ptidsl, CMSG2ADSL2_INDEX);
18427 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18428 + ptidsl->adsl2TrainingMessages.cMsg2,CMSG2ADSL2_SIZE);
18429 + ptidsl->adsl2TrainingMessages.cMsg2Len = CMSG2ADSL2_SIZE;
18430 + break;
18431 + case RMSG1ADSL2_INDEX:
18432 + dprintf(5,"R-Msg1 rec'd\n");
18433 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18434 + (ptidsl, RMSG1ADSL2_INDEX);
18435 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18436 + ptidsl->adsl2TrainingMessages.rMsg1,RMSG1ADSL2_SIZE);
18437 + ptidsl->adsl2TrainingMessages.rMsg1Len = RMSG1ADSL2_SIZE;
18438 + break;
18439 + case RMSG2ADSL2_INDEX:
18440 + dprintf(5,"R-Msg2 rec'd\n");
18441 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18442 + (ptidsl, RMSG2ADSL2_INDEX);
18443 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18444 + ptidsl->adsl2TrainingMessages.rMsg2,RMSG2ADSL2_SIZE);
18445 + ptidsl->adsl2TrainingMessages.rMsg2Len = RMSG2ADSL2_SIZE;
18446 + break;
18447 + case CPARAMS_INDEX:
18448 + dprintf(5,"C-Params rec'd\n");
18449 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18450 + (ptidsl, CPARAMS_INDEX);
18451 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18452 + ptidsl->adsl2TrainingMessages.cParams,CPARAMS_SIZE);
18453 + ptidsl->adsl2TrainingMessages.cParamsLen = CPARAMS_SIZE;
18454 + break;
18455 + case RPARAMS_INDEX:
18456 + dprintf(5,"R-Params rec'd\n");
18457 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18458 + (ptidsl, RPARAMS_INDEX);
18459 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18460 + ptidsl->adsl2TrainingMessages.rParams,RPARAMS_SIZE);
18461 + ptidsl->adsl2TrainingMessages.rParamsLen = RPARAMS_SIZE;
18462 + break;
18463 + case RMSG1LD_INDEX:
18464 + dprintf(5,"R-Msg1 LD rec'd\n");
18465 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18466 + (ptidsl, RMSG1LD_INDEX);
18467 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18468 + ptidsl->adsl2DiagnosticMessages.rMsg1Ld,RMSG1LD_SIZE);
18469 + ptidsl->adsl2DiagnosticMessages.rMsg1LdLen = RMSG1LD_SIZE;
18470 + break;
18471 + case RMSG2LD_INDEX:
18472 + dprintf(5,"R-Msg2 LD rec'd\n");
18473 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18474 + (ptidsl, RMSG2LD_INDEX);
18475 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18476 + ptidsl->adsl2DiagnosticMessages.rMsg2Ld,RMSGxLD_SIZE);
18477 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18478 + break;
18479 + case RMSG3LD_INDEX:
18480 + dprintf(5,"R-Msg3 LD rec'd\n");
18481 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18482 + (ptidsl, RMSG3LD_INDEX);
18483 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18484 + ptidsl->adsl2DiagnosticMessages.rMsg3Ld,RMSGxLD_SIZE);
18485 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18486 + break;
18487 + case RMSG4LD_INDEX:
18488 + dprintf(5,"R-Msg4 LD rec'd\n");
18489 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18490 + (ptidsl, RMSG4LD_INDEX);
18491 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18492 + ptidsl->adsl2DiagnosticMessages.rMsg4Ld,RMSGxLD_SIZE);
18493 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18494 + break;
18495 + case RMSG5LD_INDEX:
18496 + dprintf(5,"R-Msg5 LD rec'd\n");
18497 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18498 + (ptidsl, RMSG5LD_INDEX);
18499 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18500 + ptidsl->adsl2DiagnosticMessages.rMsg5Ld,RMSGxLD_SIZE);
18501 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18502 + break;
18503 + case RMSG6LD_INDEX:
18504 + dprintf(5,"R-Msg6 LD rec'd\n");
18505 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18506 + (ptidsl, RMSG6LD_INDEX);
18507 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18508 + ptidsl->adsl2DiagnosticMessages.rMsg6Ld,RMSGxLD_SIZE);
18509 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18510 + break;
18511 + case RMSG7LD_INDEX:
18512 + dprintf(5,"R-Msg7 LD rec'd\n");
18513 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18514 + (ptidsl, RMSG7LD_INDEX);
18515 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18516 + ptidsl->adsl2DiagnosticMessages.rMsg7Ld,RMSGxLD_SIZE);
18517 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18518 + break;
18519 + case RMSG8LD_INDEX:
18520 + dprintf(5,"R-Msg8 LD rec'd\n");
18521 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18522 + (ptidsl, RMSG8LD_INDEX);
18523 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18524 + ptidsl->adsl2DiagnosticMessages.rMsg8Ld,RMSGxLD_SIZE);
18525 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18526 + break;
18527 + case RMSG9LD_INDEX:
18528 + dprintf(5,"R-Msg9 LD rec'd\n");
18529 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18530 + (ptidsl, RMSG9LD_INDEX);
18531 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18532 + ptidsl->adsl2DiagnosticMessages.rMsg9Ld,RMSGxLD_SIZE);
18533 + ptidsl->adsl2DiagnosticMessages.rMsgxLdLen = RMSGxLD_SIZE;
18534 + break;
18535 + case CMSG1LD_INDEX:
18536 + dprintf(5,"C-Msg1 LD rec'd\n");
18537 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18538 + (ptidsl, CMSG1LD_INDEX);
18539 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18540 + ptidsl->adsl2DiagnosticMessages.cMsg1Ld,CMSG1LD_SIZE);
18541 + ptidsl->adsl2DiagnosticMessages.cMsg1LdLen = CMSG1LD_SIZE;
18542 + break;
18543 + case CMSG2LD_INDEX:
18544 + dprintf(5,"C-Msg2 LD rec'd\n");
18545 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18546 + (ptidsl, CMSG2LD_INDEX);
18547 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18548 + ptidsl->adsl2DiagnosticMessages.cMsg2Ld,CMSG2LD_SIZE);
18549 + ptidsl->adsl2DiagnosticMessages.cMsg2LdLen = CMSG2LD_SIZE;
18550 + break;
18551 + case CMSG3LD_INDEX:
18552 + dprintf(5,"C-Msg3 LD rec'd\n");
18553 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18554 + (ptidsl, CMSG3LD_INDEX);
18555 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18556 + ptidsl->adsl2DiagnosticMessages.cMsg3Ld,CMSG3LD_SIZE);
18557 + ptidsl->adsl2DiagnosticMessages.cMsg3LdLen = CMSG3LD_SIZE;
18558 + break;
18559 + case CMSG4LD_INDEX:
18560 + dprintf(5,"C-Msg4 LD rec'd\n");
18561 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18562 + (ptidsl, CMSG4LD_INDEX);
18563 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18564 + ptidsl->adsl2DiagnosticMessages.cMsg4Ld,CMSG4LD_SIZE);
18565 + ptidsl->adsl2DiagnosticMessages.cMsg4LdLen = CMSG4LD_SIZE;
18566 + break;
18567 + case CMSG5LD_INDEX:
18568 + dprintf(5,"C-Msg5 LD rec'd\n");
18569 + adsl2MsgLoc = dslhal_support_getAdsl2MessageLocation
18570 + (ptidsl, CMSG5LD_INDEX);
18571 + rc += dslhal_support_blockRead((PVOID)adsl2MsgLoc,
18572 + ptidsl->adsl2DiagnosticMessages.cMsg5Ld,CMSG5LD_SIZE);
18573 + ptidsl->adsl2DiagnosticMessages.cMsg5LdLen = CMSG5LD_SIZE;
18574 + break;
18575 + default:
18576 + dprintf(5,"Unknown ADSL2 Message rec'd\n");
18577 + break;
18578 + }
18579 + if(rc)
18580 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18581 + else
18582 + return DSLHAL_ERROR_NO_ERRORS;
18583 +}
18584 +
18585 +/********************************************************************************************
18586 +* FUNCTION NAME: dslhal_support_getAdsl2MessageLocation()
18587 +*
18588 +*********************************************************************************************
18589 +* DESCRIPTION:
18590 +* Gets the address to the ADSL2 Message being looked up
18591 +*
18592 +* Return: Error Condition (if any)
18593 +*
18594 +*
18595 +* NOTE:
18596 +* DSP image is based on LITTLE endian
18597 +*
18598 +********************************************************************************************/
18599 +unsigned int dslhal_support_getAdsl2MessageLocation(tidsl_t *ptidsl,int msgOffset)
18600 +{
18601 + int rc=0;
18602 +
18603 + DEV_HOST_dspOamSharedInterface_t *pSharedInterface, sharedInterface;
18604 + DEV_HOST_dspWrNegoParaDef_t dspNegoPara;
18605 + int adsl2MsgString, adsl2MsgAddr;
18606 +
18607 + pSharedInterface = (DEV_HOST_dspOamSharedInterface_t *) ptidsl->pmainAddr;
18608 + rc += dslhal_support_blockRead(pSharedInterface, &sharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18609 + sharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_adsl2ByteSwap32((unsigned int)sharedInterface.dspWriteNegoParams_p);
18610 + rc += dslhal_support_blockRead((PVOID)sharedInterface.dspWriteNegoParams_p,&dspNegoPara, sizeof(DEV_HOST_dspWrNegoParaDef_t));
18611 +
18612 + if (rc)
18613 + {
18614 + dprintf(1,"dslhal_support_blockRead failed\n");
18615 + return DSLHAL_ERROR_BLOCK_READ;
18616 + }
18617 +
18618 + adsl2MsgString = dslhal_support_adsl2ByteSwap32((unsigned int)dspNegoPara.adsl2DeltMsgs_p);
18619 + dprintf(5,"ADSL2 Message String Address: 0x%x\n",adsl2MsgString);
18620 + rc += dslhal_support_blockRead((PVOID)(adsl2MsgString +
18621 + ((sizeof(unsigned char *)*msgOffset))),
18622 + &adsl2MsgAddr, sizeof(int));
18623 + adsl2MsgAddr = dslhal_support_adsl2ByteSwap32((unsigned int)adsl2MsgAddr);
18624 + dprintf(5," Message Address: 0x%x\n",adsl2MsgAddr);
18625 +
18626 + if(rc)
18627 + return DSLHAL_ERROR_BLOCK_READ;
18628 + else
18629 + return adsl2MsgAddr;
18630 +}
18631 +
18632 +/********************************************************************************************
18633 +* FUNCTION NAME: dslhal_support_getCMsgsRa()
18634 +*
18635 +*********************************************************************************************
18636 +* DESCRIPTION:
18637 +* Calls Advanced Training Message functions
18638 +*
18639 +* Return: Error Condition (if any)
18640 +*
18641 +*
18642 +* NOTE:
18643 +* DSP image is based on LITTLE endian
18644 +*
18645 +********************************************************************************************/
18646 +unsigned int dslhal_support_getCMsgsRa(tidsl_t *ptidsl,void *cMsg)
18647 +{
18648 + int rc=0;
18649 + DEV_HOST_raMsgsDef_t raMsgParms;
18650 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
18651 + rc += dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18652 +
18653 + dspOamSharedInterface.raMsgs_p = (DEV_HOST_raMsgsDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.raMsgs_p);
18654 +
18655 + rc += dslhal_support_blockRead((PVOID)dspOamSharedInterface.raMsgs_p,
18656 + &raMsgParms, sizeof(DEV_HOST_raMsgsDef_t));
18657 + shim_osMoveMemory((void *)cMsg,(void *)raMsgParms.cMsgsRaString,6);
18658 +
18659 + if(rc)
18660 + return DSLHAL_ERROR_CONFIG_API_FAILURE;
18661 + else
18662 + return DSLHAL_ERROR_NO_ERRORS;
18663 +}
18664 +
18665 +/********************************************************************************************
18666 +* FUNCTION NAME: dslhal_support_gatherRateMessages()
18667 +*
18668 +*********************************************************************************************
18669 +* DESCRIPTION:
18670 +* Gathers Rate Training Messages
18671 +* Input
18672 +* tidsl_t *ptidsl : Pointer to application structure
18673 +*
18674 +*
18675 +* Return: 0 success
18676 +* 1 failed
18677 +*
18678 +* NOTE:
18679 +* DSP image is based on LITTLE endian
18680 +*
18681 +********************************************************************************************/
18682 +unsigned int dslhal_support_gatherRateMessages(tidsl_t * ptidsl)
18683 +{
18684 + int rc;
18685 + DEV_HOST_dspWrNegoParaDef_t negoParms;
18686 + DEV_HOST_dspOamSharedInterface_t dspOamSharedInterface;
18687 +
18688 + dprintf(1, "dslhal_support_gatherRateMessages\n");
18689 +
18690 + rc += dslhal_support_blockRead(ptidsl->pmainAddr, &dspOamSharedInterface,sizeof(DEV_HOST_dspOamSharedInterface_t));
18691 + dspOamSharedInterface.dspWriteNegoParams_p = (DEV_HOST_dspWrNegoParaDef_t *) dslhal_support_byteSwap32((unsigned int)dspOamSharedInterface.dspWriteNegoParams_p);
18692 +
18693 + rc = dslhal_support_blockRead((PVOID)dspOamSharedInterface.dspWriteNegoParams_p, &negoParms, sizeof(DEV_HOST_dspWrNegoParaDef_t));
18694 + if (rc)
18695 + return DSLHAL_ERROR_BLOCK_READ;
18696 + else
18697 + {
18698 + shim_osMoveMemory((void *)ptidsl->AppData.bCRates1, (void *)negoParms.cRates1, 120);
18699 + shim_osMoveMemory((void *)ptidsl->AppData.bRRates1, (void *)negoParms.rRates1, 44);
18700 + }
18701 +return DSLHAL_ERROR_NO_ERRORS;
18702 +}
18703 +
18704 +static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits)
18705 +{
18706 + int out32Bits=0;
18707 +
18708 +#ifdef EB
18709 + out32Bits = (in32Bits << 24);
18710 + out32Bits |=((in32Bits & 0x0000ff00) << 8);
18711 + out32Bits |=((in32Bits & 0xff000000) >> 24);
18712 + out32Bits |=((in32Bits & 0x00ff0000) >> 8);
18713 +#else
18714 + out32Bits = in32Bits;
18715 +#endif
18716 +
18717 + return out32Bits;
18718 +
18719 +} /* end of dslhal_support_byteSwap32() */
18720 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_support.h linux.dev/drivers/atm/sangam_atm/dsl_hal_support.h
18721 --- linux.old/drivers/atm/sangam_atm/dsl_hal_support.h 1970-01-01 01:00:00.000000000 +0100
18722 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_support.h 2005-08-23 04:46:50.101843088 +0200
18723 @@ -0,0 +1,718 @@
18724 +#ifndef DSL_HAL_SUPPORT_H__
18725 +#define DSL_HAL_SUPPORT_H__ 1
18726 +
18727 +/*******************************************************************************
18728 +* FILE PURPOSE: DSL Driver API functions for Sangam
18729 +*
18730 +********************************************************************************
18731 +* FILE NAME: dsl_hal_functiondefines.c
18732 +*
18733 +* DESCRIPTION:
18734 +* Contains basic DSL HAL API declarations for Sangam
18735 +*
18736 +*
18737 +* (C) Copyright 2001-02, Texas Instruments, Inc.
18738 +* History
18739 +* Date Version Notes
18740 +* 06Feb03 0.00.00 RamP Created
18741 +* 21Mar03 0.00.01 RamP Removed byteswap functions
18742 +* 21Mar03 0.00.02 RamP Added extern osFreeVMemory declaration
18743 +* 10Apr03 0.00.03 RamP Changed declaration for loadFWImage &
18744 +* loadDebugFWImage to remove ptidsl param
18745 +* 12Apr03 0.00.04 RamP Added function to set Interrupt Bit
18746 +* Masks for bitfield & Mailboxes
18747 +* 14Apr03 0.00.05 RamP Added modem state bit field processing
18748 +* 15Apr03 0.00.06 RamP Added function osAllocateVMemory
18749 +* 21Apr03 0.01.00 RamP Added function osAllocateDmaMemory
18750 +* Added function osFreeDmaMemory
18751 +* (Alpha) Added macro virtual2Physical,
18752 +* 22Apr03 0.01.01 RamP Moved acknowledgeInterrupt to api.h
18753 +* 24Apr03 0.01.02 RamP Added checkOvelayPage function
18754 +* 29May03 0.01.03 RamP Added critical enter/exit function decl
18755 +* 06Jun03 0.01.04 RamP Added Interrupt source parsing function
18756 +* 06Oct03 0.01.05 RamP Added function abstraction switches
18757 +* 12Oct03 0.01.06 RamP Added ADSL2 Message function prototypes
18758 +* 14Nov03 0.03.07 RamP Added function to gather Rate Messages
18759 +*******************************************************************************/
18760 +
18761 +#include "dsl_hal_api.h"
18762 +
18763 +#define virtual2Physical(a) (((int)a)&~0xe0000000)
18764 +/* External Function Prototype Declarations */
18765 +
18766 +extern unsigned int shim_osGetCpuFrequency(void);
18767 +extern void shim_osClockWait(int val);
18768 +extern unsigned int shim_osClockTick(void);
18769 +
18770 +extern int shim_osStringCmp(const char *s1, const char *s2);
18771 +
18772 +extern void dprintf( int uDbgLevel, char * szFmt, ...);
18773 +
18774 +extern int shim_osLoadFWImage(unsigned char *firmwareImage);
18775 +extern int shim_osLoadDebugFWImage(unsigned char *debugFirmwareImage);
18776 +extern unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength);
18777 +extern void shim_osMoveMemory(char *dst, char *src, unsigned int numBytes);
18778 +extern void shim_osZeroMemory(char *dst, unsigned int numBytes);
18779 +
18780 +extern void *shim_osAllocateMemory(unsigned int size);
18781 +extern void *shim_osAllocateVMemory(unsigned int size);
18782 +extern void *shim_osAllocateDmaMemory(unsigned int size);
18783 +
18784 +extern void shim_osFreeMemory(void *ptr, unsigned int size);
18785 +extern void shim_osFreeVMemory(void *ptr, unsigned int size);
18786 +extern void shim_osFreeDmaMemory(void *ptr, unsigned int size);
18787 +
18788 +extern void shim_osWriteBackCache(void *pMem, unsigned int size);
18789 +extern void shim_osCriticalEnter(void);
18790 +extern void shim_osCriticalExit(void);
18791 +
18792 +
18793 +/*******************************************************************************************
18794 +* FUNCTION NAME: dslhal_support_writeHostMailbox
18795 +*
18796 +********************************************************************************************
18797 +* DESCRIPTION: Send a message to a mailbox
18798 +*
18799 +* ARGUMENTS: int cmd command to write
18800 +* int tag tag (currently unused)
18801 +* int p1 parameter 1 (currently unused)
18802 +* int p2 parameter 2 (currently unused)
18803 +*
18804 +* RETURNS: 0 if successful
18805 +* NZ otherwise
18806 +*
18807 +*******************************************************************************************/
18808 +
18809 +int dslhal_support_writeHostMailbox
18810 +(tidsl_t *ptidsl,
18811 + int cmd,
18812 + int tag,
18813 + int p1,
18814 + int p2);
18815 +
18816 +/********************************************************************************************
18817 +* FUNCTION NAME: dslhal_support_readDspMailbox
18818 +*
18819 +*********************************************************************************************
18820 +* DESCRIPTION: Reads a message from the mailbox
18821 +*
18822 +* ARGUMENTS: int *pcmd Pointer to command read
18823 +*
18824 +* RETURNS: 0 if successful
18825 +* 1 if no mail
18826 +* NZ otherwise
18827 +*
18828 +*****************************************************************************************/
18829 +
18830 +int dslhal_support_readDspMailbox
18831 +(tidsl_t *ptidsl,
18832 + int *pcmd,
18833 + int *ptag,
18834 + int *pprm1,
18835 + int *pprm2);
18836 +
18837 +/********************************************************************************************
18838 +* FUNCTION NAME: dslhal_support_readTextMailbox
18839 +*
18840 +*********************************************************************************************
18841 +* DESCRIPTION: Reads a message from the mailbox
18842 +*
18843 +* ARGUMENTS: int *pcmd Pointer to command read
18844 +*
18845 +* RETURNS: 0 if successful
18846 +* 1 if no mail
18847 +* NZ otherwise
18848 +*
18849 +*****************************************************************************************/
18850 +
18851 +int dslhal_support_readTextMailbox
18852 +(tidsl_t *ptidsl,
18853 + int *pmsg1,
18854 + int *pmsg2);
18855 +
18856 +/******************************************************************************************
18857 +* FUNCTION NAME: dslhal_support_blockRead
18858 +*
18859 +*********************************************************************************************
18860 +* DESCRIPTION: This rouin simulates DSP memory read as done in ax5 pci nic card
18861 +*
18862 +* INPUT: void *addr, memory address to be read
18863 +* void *buffer, dat buffer to be filled with from memmory
18864 +* size_t count, number of bytes to be written
18865 +*
18866 +* RETURN: 0 --succeeded
18867 +* 1 --Failed
18868 +*
18869 +*****************************************************************************************/
18870 +
18871 +int dslhal_support_blockRead
18872 +(void *addr,
18873 + void *buffer,
18874 + size_t count);
18875 +
18876 +/******************************************************************************************
18877 +* FUNCTION NAME: dslhal_support_blockWrite
18878 +*
18879 +*******************************************************************************************
18880 +* DESCRIPTION: This rouin simulates DSP memory write as done in ax5 pci nic card
18881 +*
18882 +* INPUT: void *buffer, data need to written
18883 +* void *adde, memory address to be written
18884 +* size_t count, number of bytes to be written
18885 +*
18886 +* RETURN: 0 --succeeded
18887 +* 1 --Failed
18888 +*
18889 +*****************************************************************************************/
18890 +
18891 +int dslhal_support_blockWrite
18892 +(void *buffer,
18893 + void *addr,
18894 + size_t count);
18895 +
18896 +/******************************************************************************************
18897 +* FUNCTION NAME: dslhal_support_hostDspAddressTranslate
18898 +*
18899 +*******************************************************************************************
18900 +* DESCRIPTION: This function moves the address window to translate physical address
18901 +*
18902 +* INPUT: unsigned int addr : address that requires translation
18903 +*
18904 +* RETURN: Translated address or error condition
18905 +*
18906 +*
18907 +*****************************************************************************************/
18908 +
18909 +unsigned int dslhal_support_hostDspAddressTranslate
18910 +( unsigned int addr
18911 +);
18912 +
18913 +/******************************************************************************************
18914 +* FUNCTION NAME: dslhal_support_unresetDslSubsystem
18915 +*
18916 +*******************************************************************************************
18917 +* DESCRIPTION: This function unreset Dsl Subsystem
18918 +*
18919 +* INPUT: None
18920 +*
18921 +* RETURN: 0 if Pass; 1 if Fail
18922 +*
18923 +*****************************************************************************************/
18924 +int dslhal_support_unresetDslSubsystem
18925 +(void
18926 +);
18927 +
18928 +/******************************************************************************************
18929 +* FUNCTION NAME: dslhal_support_unresetDsp()
18930 +*
18931 +*******************************************************************************************
18932 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
18933 +*
18934 +* INPUT: None
18935 +*
18936 +* RETURN: 0 --successful.
18937 +* 1 --failed
18938 +*
18939 +*****************************************************************************************/
18940 +int dslhal_support_unresetDsp
18941 +(void
18942 +);
18943 +
18944 +
18945 +/******************************************************************************************
18946 +* FUNCTION NAME: dslhal_support_resetDslSubsystem
18947 +*
18948 +*******************************************************************************************
18949 +* DESCRIPTION: This function unreset Dsl Subsystem
18950 +*
18951 +* INPUT: None
18952 +*
18953 +* RETURN: 0 if Pass; 1 if Fail
18954 +*
18955 +*****************************************************************************************/
18956 +int dslhal_support_resetDslSubsystem
18957 +(void
18958 +);
18959 +
18960 +/******************************************************************************************
18961 +* FUNCTION NAME: dslhal_support_resetDsp()
18962 +*
18963 +*******************************************************************************************
18964 +* DESCRIPTION: This fuction takes ax5 daugter board out of reset.
18965 +*
18966 +* INPUT: None
18967 +*
18968 +* RETURN: 0 --successful.
18969 +* 1 --failed
18970 +*
18971 +*****************************************************************************************/
18972 +int dslhal_support_resetDsp
18973 +(void
18974 +);
18975 +
18976 +
18977 +/********************************************************************************************
18978 +* FUNCTION NAME: dslhal_support_hostDspCodeDownload()
18979 +*
18980 +*********************************************************************************************
18981 +* DESCRIPTION:
18982 +* download DSP image from host memory to dsp memory
18983 +*
18984 +* Return: 0 success
18985 +* 1 failed
18986 +*
18987 +* NOTE:
18988 +* DSP image is based on LITTLE endian
18989 +*
18990 +********************************************************************************************/
18991 +
18992 +int dslhal_support_hostDspCodeDownload
18993 +(tidsl_t * ptidsl
18994 +);
18995 +
18996 +/********************************************************************************************
18997 +* FUNCTION NAME: dslhal_diags_digi_assignMemTestSpace()
18998 +*
18999 +*********************************************************************************************
19000 +* DESCRIPTION: Assigns Memory Space in SDRAM for External Memory Test
19001 +* Input: tidsl_t *ptidsl
19002 +*
19003 +* Return: 0 success
19004 +* 1 failed
19005 +*
19006 +********************************************************************************************/
19007 +
19008 +unsigned int dslhal_diags_digi_assignMemTestSpace
19009 +(tidsl_t *ptidsl
19010 +);
19011 +
19012 +/********************************************************************************************
19013 +* FUNCTION NAME: dslhal_diags_digi_readMemTestResult()
19014 +*
19015 +*********************************************************************************************
19016 +* DESCRIPTION: Reads Results of External Memory Test
19017 +* Input: tidsl_t *ptidsl
19018 +*
19019 +* Return: 0 success
19020 +* 1 failed
19021 +*
19022 +********************************************************************************************/
19023 +
19024 +unsigned int dslhal_diags_digi_readMemTestResult
19025 +(tidsl_t *ptidsl,
19026 +unsigned int testResult
19027 +);
19028 +
19029 +
19030 +/********************************************************************************************
19031 +* FUNCTION NAME: dslhal_diags_codeDownload()
19032 +*
19033 +*********************************************************************************************
19034 +* DESCRIPTION: Brings DSLSS out of Reset, Downloads Diag Firmware,
19035 +* brings DSP out of Reset
19036 +* Input: tidsl_t *ptidsl
19037 +*
19038 +* Return: 0 success
19039 +* 1 failed
19040 +*
19041 +********************************************************************************************/
19042 +
19043 +unsigned int dslhal_diags_codeDownload
19044 +(tidsl_t *ptidsl,
19045 +unsigned char* missingTones
19046 +);
19047 +
19048 +/********************************************************************************************
19049 +* FUNCTION NAME: dslhal_diags_anlg_setPgaParams()
19050 +*
19051 +*********************************************************************************************
19052 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19053 +* tones and Medley's with missing tones. These signals are defined in ITU
19054 +* G.992.1 ADSL Standards.
19055 +*
19056 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19057 +* Tones selects the .
19058 +* Return: NULL
19059 +*
19060 +********************************************************************************************/
19061 +
19062 +unsigned int dslhal_diags_anlg_setPgaParams
19063 +(tidsl_t *ptidsl,
19064 +int agcFlag,
19065 +short pga1,
19066 +short pga2,
19067 +short pga3,
19068 +short aeq
19069 +);
19070 +
19071 +/********************************************************************************************
19072 +* FUNCTION NAME: dslhal_diags_anlg_getRxNoisePower()
19073 +*
19074 +*********************************************************************************************
19075 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19076 +* tones and Medley's with missing tones. These signals are defined in ITU
19077 +* G.992.1 ADSL Standards.
19078 +*
19079 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19080 +* Tones selects the .
19081 +* Return: NULL
19082 +*
19083 +********************************************************************************************/
19084 +
19085 +unsigned int dslhal_diags_anlg_getRxNoisePower
19086 +(tidsl_t *ptidsl
19087 +);
19088 +
19089 +/********************************************************************************************
19090 +* FUNCTION NAME: dslhal_diags_anlg_setMissingTones()
19091 +*
19092 +*********************************************************************************************
19093 +* DESCRIPTION: This function instructs the Transciever to transmit the Reverb with missing
19094 +* tones and Medley's with missing tones. These signals are defined in ITU
19095 +* G.992.1 ADSL Standards.
19096 +*
19097 +* Input: Test selects between the Reverb or Medley tests. 0 - Reverb, 1 - Medley
19098 +* Tones selects the .
19099 +* Return: NULL
19100 +*
19101 +********************************************************************************************/
19102 +
19103 +unsigned int dslhal_diags_anlg_setMissingTones
19104 +(tidsl_t *ptidsl,
19105 +unsigned char* missingTones
19106 +);
19107 +
19108 +/********************************************************************************************
19109 +* FUNCTION NAME: dslhal_support_readDelineationState()
19110 +*
19111 +*********************************************************************************************
19112 +* DESCRIPTION:
19113 +* download DSP image from host memory to dsp memory
19114 +*
19115 +* Return: 0 success
19116 +* 1 failed
19117 +*
19118 +* NOTE:
19119 +* DSP image is based on LITTLE endian
19120 +*
19121 +********************************************************************************************/
19122 +unsigned int dslhal_support_readDelineationState
19123 +(tidsl_t *ptidsl
19124 +);
19125 +
19126 +/********************************************************************************************
19127 +* FUNCTION NAME: dslhal_support_processModemStateBitField()
19128 +*
19129 +*********************************************************************************************
19130 +* DESCRIPTION:
19131 +* download DSP image from host memory to dsp memory
19132 +*
19133 +* Return: 0 success
19134 +* 1 failed
19135 +*
19136 +* NOTE:
19137 +* DSP image is based on LITTLE endian
19138 +*
19139 +********************************************************************************************/
19140 +unsigned int dslhal_support_processModemStateBitField
19141 +(tidsl_t *ptidsl
19142 +);
19143 +
19144 +/********************************************************************************************
19145 +* FUNCTION NAME: dslhal_support_setInterruptMask()
19146 +*
19147 +*********************************************************************************************
19148 +* DESCRIPTION:
19149 +* Sets the host interrupt bit masks
19150 +*
19151 +* Return: 0 success
19152 +* 1 failed
19153 +*
19154 +* NOTE:
19155 +* DSP image is based on LITTLE endian
19156 +*
19157 +********************************************************************************************/
19158 +
19159 +unsigned int dslhal_support_setInterruptMask
19160 +(tidsl_t * ptidsl,
19161 +unsigned int inputMask
19162 +);
19163 +
19164 +/********************************************************************************************
19165 +* FUNCTION NAME: dslhal_support_computeCrc32()
19166 +*
19167 +*********************************************************************************************
19168 +* DESCRIPTION:
19169 +* Computes the CRC-32 for the input data
19170 +*
19171 +* Return: 32 bit CRC of the input data
19172 +*
19173 +*
19174 +* NOTE:
19175 +* DSP image is based on LITTLE endian
19176 +*
19177 +********************************************************************************************/
19178 +unsigned int dslhal_support_computeCrc32
19179 +(unsigned char *data,
19180 +int len
19181 +);
19182 +
19183 +/********************************************************************************************
19184 +* FUNCTION NAME: dslhal_support_checkOverlayPage()
19185 +*
19186 +*********************************************************************************************
19187 +* DESCRIPTION:
19188 +* Computes the CRC-32 for the input data and compares it with reference
19189 +*
19190 +* Return: Error Condition (if any)
19191 +*
19192 +*
19193 +* NOTE:
19194 +* DSP image is based on LITTLE endian
19195 +*
19196 +********************************************************************************************/
19197 +unsigned int dslhal_support_checkOverlayPage
19198 +(tidsl_t *ptidsl,
19199 +unsigned int tag
19200 +);
19201 +
19202 +/********************************************************************************************
19203 +* FUNCTION NAME: dslhal_support_restoreTrainingInfo()
19204 +*
19205 +*********************************************************************************************
19206 +* DESCRIPTION:
19207 +* Computes the CRC-32 for the input data and compares it with reference
19208 +*
19209 +* Return: Error Condition (if any)
19210 +*
19211 +*
19212 +* NOTE:
19213 +* DSP image is based on LITTLE endian
19214 +*
19215 +********************************************************************************************/
19216 +
19217 +int dslhal_support_restoreTrainingInfo(tidsl_t * ptidsl);
19218 +
19219 +/********************************************************************************************
19220 +* FUNCTION NAME: dslhal_support_reloadTrainingInfo()
19221 +*
19222 +*********************************************************************************************
19223 +* DESCRIPTION:
19224 +* Computes the CRC-32 for the input data and compares it with reference
19225 +*
19226 +* Return: Error Condition (if any)
19227 +*
19228 +*
19229 +* NOTE:
19230 +* DSP image is based on LITTLE endian
19231 +*
19232 +********************************************************************************************/
19233 +
19234 +int dslhal_support_reloadTrainingInfo(tidsl_t * ptidsl);
19235 +
19236 +/********************************************************************************************
19237 +* FUNCTION NAME: dslhal_support_clearTrainingInfo()
19238 +*
19239 +*********************************************************************************************
19240 +* DESCRIPTION:
19241 +* Computes the CRC-32 for the input data and compares it with reference
19242 +*
19243 +* Return: Error Condition (if any)
19244 +*
19245 +*
19246 +* NOTE:
19247 +* DSP image is based on LITTLE endian
19248 +*
19249 +********************************************************************************************/
19250 +
19251 +int dslhal_support_clearTrainingInfo(tidsl_t * ptidsl);
19252 +
19253 +/********************************************************************************************
19254 +* FUNCTION NAME: dslhal_support_parseInterruptSource()
19255 +*
19256 +*********************************************************************************************
19257 +* DESCRIPTION:
19258 +* Sets the host interrupt bit masks
19259 +*
19260 +* Return: 0 success
19261 +* 1 failed
19262 +*
19263 +* NOTE:
19264 +* DSP image is based on LITTLE endian
19265 +*
19266 +********************************************************************************************/
19267 +
19268 +unsigned int dslhal_support_parseInterruptSource(tidsl_t * ptidsl);
19269 +/********************************************************************************************
19270 +* FUNCTION NAME: dslhal_support_advancedIdleProcessing()
19271 +*
19272 +*********************************************************************************************
19273 +* DESCRIPTION:
19274 +* Calls Advanced Idle State Processing Functions
19275 +*
19276 +* Return: Error Condition (if any)
19277 +*
19278 +*
19279 +* NOTE:
19280 +* DSP image is based on LITTLE endian
19281 +*
19282 +********************************************************************************************/
19283 +unsigned int dslhal_support_advancedIdleProcessing(tidsl_t *ptidsl);
19284 +
19285 +/********************************************************************************************
19286 +* FUNCTION NAME: dslhal_support_aocBitSwapProcessing()
19287 +*
19288 +*********************************************************************************************
19289 +* DESCRIPTION:
19290 +* Calls Advanced Bitswap buffer Processing Functions
19291 +*
19292 +* Return: Error Condition (if any)
19293 +*
19294 +*
19295 +* NOTE:
19296 +* DSP image is based on LITTLE endian
19297 +*
19298 +********************************************************************************************/
19299 +unsigned int dslhal_support_aocBitSwapProcessing(tidsl_t *ptidsl,unsigned int usDs);
19300 +
19301 +/********************************************************************************************
19302 +* FUNCTION NAME: dslhal_support_gatherEocMessages()
19303 +*
19304 +*********************************************************************************************
19305 +* DESCRIPTION:
19306 +* Calls Advanced EOC Buffering functions
19307 +*
19308 +* Return: Error Condition (if any)
19309 +*
19310 +*
19311 +* NOTE:
19312 +* DSP image is based on LITTLE endian
19313 +*
19314 +********************************************************************************************/
19315 +unsigned int dslhal_support_gatherEocMessages(tidsl_t *ptidsl,int usDs, int msgPart1, int msgPart2);
19316 +
19317 +/********************************************************************************************
19318 +* FUNCTION NAME: dslhal_support_gatherSnrPerBin()
19319 +*
19320 +*********************************************************************************************
19321 +* DESCRIPTION:
19322 +* Calls Advanced Snr per bin buffering Functions
19323 +*
19324 +* Return: Error Condition (if any)
19325 +*
19326 +*
19327 +* NOTE:
19328 +* DSP image is based on LITTLE endian
19329 +*
19330 +********************************************************************************************/
19331 +unsigned int dslhal_support_gatherSnrPerBin(tidsl_t *ptidsl,unsigned int snrParm);
19332 +
19333 +/********************************************************************************************
19334 +* FUNCTION NAME: dslhal_support_processTrainingState()
19335 +*
19336 +*********************************************************************************************
19337 +* DESCRIPTION:
19338 +* Calls Advanced Training State Processing Functions
19339 +*
19340 +* Return: Error Condition (if any)
19341 +*
19342 +*
19343 +* NOTE:
19344 +* DSP image is based on LITTLE endian
19345 +*
19346 +********************************************************************************************/
19347 +unsigned int dslhal_support_processTrainingState(tidsl_t *ptidsl);
19348 +
19349 +/********************************************************************************************
19350 +* FUNCTION NAME: dslhal_support_gatherAdsl2Messages()
19351 +*
19352 +*********************************************************************************************
19353 +* DESCRIPTION:
19354 +* Calls Advanced EOC Buffering functions
19355 +*
19356 +* Return: Error Condition (if any)
19357 +*
19358 +*
19359 +* NOTE:
19360 +* DSP image is based on LITTLE endian
19361 +*
19362 +********************************************************************************************/
19363 +unsigned int dslhal_support_gatherAdsl2Messages(tidsl_t *ptidsl,int msgTag, int param1, int param2);
19364 +
19365 +/********************************************************************************************
19366 +* FUNCTION NAME: dslhal_support_getAdsl2MsgLocation()
19367 +*
19368 +*********************************************************************************************
19369 +* DESCRIPTION:
19370 +* Gets the address to the ADSL2 Message being looked up
19371 +*
19372 +* Return: Error Condition (if any)
19373 +*
19374 +*
19375 +* NOTE:
19376 +* DSP image is based on LITTLE endian
19377 +*
19378 +********************************************************************************************/
19379 +unsigned int dslhal_support_getAdsl2MessageLocation(tidsl_t *ptidsl,int msgOffset);
19380 +
19381 +/********************************************************************************************
19382 +* FUNCTION NAME: dslhal_support_getCMsgsRa()
19383 +*
19384 +*********************************************************************************************
19385 +* DESCRIPTION:
19386 +* Calls Advanced Training Message functions
19387 +*
19388 +* Return: Error Condition (if any)
19389 +*
19390 +*
19391 +* NOTE:
19392 +* DSP image is based on LITTLE endian
19393 +*
19394 +********************************************************************************************/
19395 +unsigned int dslhal_support_getCMsgsRa(tidsl_t *ptidsl,void *cMsg);
19396 +
19397 +/********************************************************************************************
19398 +* FUNCTION NAME: dslhal_support_gatherRateMessages()
19399 +*
19400 +*********************************************************************************************
19401 +* DESCRIPTION:
19402 +* Gathers Advanced Training Messages
19403 +*
19404 +* Return: Error Condition (if any)
19405 +*
19406 +*
19407 +* NOTE:
19408 +* DSP image is based on LITTLE endian
19409 +*
19410 +********************************************************************************************/
19411 +unsigned int dslhal_support_gatherRateMessages(tidsl_t *ptidsl);
19412 +
19413 +/********************************************************************************************
19414 +* FUNCTION NAME: dslhal_support_byteSwap16()
19415 +*
19416 +*********************************************************************************************
19417 +* DESCRIPTION:
19418 +* byteswap a short
19419 +*
19420 +* INPUT:
19421 +* Return: NULL
19422 +*
19423 +********************************************************************************************/
19424 +
19425 +unsigned short dslhal_support_byteSwap16(unsigned short in16Bits);
19426 +
19427 +/********************************************************************************************
19428 +* FUNCTION NAME: dslhal_support_byteSwap32()
19429 +*
19430 +*********************************************************************************************
19431 +* DESCRIPTION:
19432 +* byteswap a word
19433 +*
19434 +* INPUT:
19435 +* Return: NULL
19436 +*
19437 +********************************************************************************************/
19438 +
19439 +unsigned int dslhal_support_byteSwap32(unsigned int in32Bits);
19440 +
19441 +#endif /* Pairs #ifndef DSL_HAL_FUNCTIONDEFINES_H__ */
19442 diff -urN linux.old/drivers/atm/sangam_atm/dsl_hal_version.h linux.dev/drivers/atm/sangam_atm/dsl_hal_version.h
19443 --- linux.old/drivers/atm/sangam_atm/dsl_hal_version.h 1970-01-01 01:00:00.000000000 +0100
19444 +++ linux.dev/drivers/atm/sangam_atm/dsl_hal_version.h 2005-08-23 04:46:50.102842936 +0200
19445 @@ -0,0 +1,94 @@
19446 +#ifndef __SYSSW_VERSION_H__
19447 +#define __SYSSW_VERSION_H__ 1
19448 +
19449 +/*******************************************************************************
19450 +* FILE PURPOSE: DSL Driver API functions for Sangam
19451 +*
19452 +********************************************************************************
19453 +* FILE NAME: dsl_hal_basicapi.c
19454 +*
19455 +* DESCRIPTION:
19456 +* Contains basic DSL HAL APIs for Sangam
19457 +*
19458 +* (C) Copyright 2003-04, Texas Instruments, Inc.
19459 +* History
19460 +* Date Version Notes
19461 +* 14May03 0.00.00 RamP Original Version Created
19462 +* 14May03 0.00.01 RamP Initial Rev numbers inserted
19463 +* 14May03 0.00.02 RamP Bumped version numbers for Dsl Hal
19464 +* & dhalapp for alpha plus
19465 +* 19May03 0.00.03 MCB Bumped dslhal version number
19466 +* because of dependant changes
19467 +* wrt. linux-nsp atm drivers.
19468 +* 22May03 0.00.04 RamP Bumped dslhal & dhalapp buildnum
19469 +* for inner/outer pair & DGASP code
19470 +* 06Jun03 0.00.05 RamP Bumped up buildnum for LED, STM,
19471 +* interrupt processing, statistics
19472 +* and other pre-beta features
19473 +* 09Jun03 0.00.06 JEB Fixed error in DHALAPP bugfix/buildnum
19474 +* 09Jun03 0.00.07 RamP Bumped up buildnum for incremental
19475 +* changes to apis, statistics, memory
19476 +* fixes, parameter configurations
19477 +* 11Jun03 0.00.08 RamP Bumped up buildnum for Co profile
19478 +* free memory fix
19479 +* 12Jun03 0.00.09 JEB Bumped version numbers for AR7 1.00 Beta
19480 +* 02Jul03 0.00.10 ZT Bumped HAL version for overlay page
19481 +* 18Jul03 0.00.11 RamP Bumped HAL version for analog diags
19482 +* 22Jul03 0.00.12 JEB Bumped DHALAPP buildnum for analog diags
19483 +* 31Jul03 0.00.13 RamP Bumped HAL version for engr. drop
19484 +* 04Aug03 0.00.14 JEB Bumped HAL version buildnum for CHECKPOINT65 changes
19485 +* Bumped LINUX version buildnum for CHECKPOINT65 changes
19486 +* 06Aug03 0.00.15 MCB Bumped all version numbers in prep for AR7 1.0 R2 release for POTS.
19487 +* 13Aug03 0.00.16 MCB Set rev id's for D3/R1.1 (ADSL2).
19488 +* 21Aug03 0.00.17 JEB Bumped up build numbers for merge of code additions from D1
19489 +* 26Sep03 0.00.18 JEB Set rev id's for another D3/R1 (ADSL2).
19490 +* 14Oct03 0.00.19 JEB Bumped Linux minor number and reset bugfix number for release.
19491 +* Bumped build numbers on DSLHAL and DHALAPP for this checkpoint.
19492 +* 14Oct03 0.00.20 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT15.
19493 +* 21Oct03 0.00.21 JEB Bumped build number on DSLHAL for CHECKPOINT16.
19494 +* 22Oct03 0.00.22 MCB Bumped all version numbers in support of D3R1 release.
19495 +* 27Oct03 0.00.23 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT19.
19496 +* Updated version for DSLAGENT to be 02.01.00.01 for ACT 2.1 R0.
19497 +* 30Oct03 0.00.24 JEB Bumped bugfix number on LINUXATM Version for next release.
19498 +* Bumped build numbers on DSLHAL and DHALAPP
19499 +* 31Oct03 0.00.25 MCB Bumped all version numbers in support of D3R2 release.
19500 +* 14Nov03 0.00.26 JEB Bumped build numbers on DSLHAL and DHALAPP
19501 +* Changed version for DSLAGENT to be 02.00.01.01 for an ACT 2.0 R0
19502 +* 20Nov03 0.00.27 JEB Bumped build number on DSLHAL.
19503 +* Changed version for DSLAGENT to be 02.00.02.00 for the next ACT 2.0 R2
19504 +* 21Nov03 0.00.28 MCB Bumped all version numbers in support of D3R2 release.
19505 +* 21Nov03 0.00.29 JEB Bumped build numbers on DSLHAL and DHALAPP for D3-R0 drop on 11/21.
19506 +* 16Dec03 0.00.30 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT31.
19507 +* 21Dec03 0.00.31 MCB Bumped all version numbers in support of D3R2 release.
19508 +* 05Jan04 0.00.32 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 34.
19509 +* 15Jan04 0.00.33 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 36.
19510 +* 26Jan04 0.00.34 JEB Changed Linux ATM version number to be 04.02.03.00.
19511 +* 27Jan04 0.00.35 MCB Bumped all version numbers in support of D3R2 release.
19512 +*******************************************************************************/
19513 +
19514 +/* Dsl Hal API Version Numbers */
19515 +#define DSLHAL_VERSION_MAJOR 03
19516 +#define DSLHAL_VERSION_MINOR 00
19517 +#define DSLHAL_VERSION_BUGFIX 06
19518 +#define DSLHAL_VERSION_BUILDNUM 00
19519 +#define DSLHAL_VERSION_TIMESTAMP 00
19520 +
19521 +/* dhalapp Adam2 Application Version Numbers */
19522 +#define DHALAPP_VERSION_MAJOR 03
19523 +#define DHALAPP_VERSION_MINOR 00
19524 +#define DHALAPP_VERSION_BUGFIX 05
19525 +#define DHALAPP_VERSION_BUILDNUM 00
19526 +
19527 +/* Linux ATM Driver Version Numbers */
19528 +#define LINUXATM_VERSION_MAJOR 04
19529 +#define LINUXATM_VERSION_MINOR 02
19530 +#define LINUXATM_VERSION_BUGFIX 04
19531 +#define LINUXATM_VERSION_BUILDNUM 00
19532 +
19533 +/* DSL Agent Version Numbers */
19534 +#define DSLAGENT_VERSION_MAJOR 02
19535 +#define DSLAGENT_VERSION_MINOR 00
19536 +#define DSLAGENT_VERSION_BUGFIX 02
19537 +#define DSLAGENT_VERSION_BUILDNUM 00
19538 +
19539 +#endif /* pairs with #ifndef __SYSSW_VERSION_H__ */
19540 diff -urN linux.old/drivers/atm/sangam_atm/ec_errors_cpaal5.h linux.dev/drivers/atm/sangam_atm/ec_errors_cpaal5.h
19541 --- linux.old/drivers/atm/sangam_atm/ec_errors_cpaal5.h 1970-01-01 01:00:00.000000000 +0100
19542 +++ linux.dev/drivers/atm/sangam_atm/ec_errors_cpaal5.h 2005-08-23 04:46:50.102842936 +0200
19543 @@ -0,0 +1,118 @@
19544 +/***************************************************************************
19545 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
19546 +
19547 + FILE: ec_errors.h
19548 +
19549 + DESCRIPTION:
19550 + This file contains definitions and function declarations for
19551 + error code support.
19552 +
19553 + HISTORY:
19554 + 14Dec00 MJH Added masking to EC_CLASS etc macros
19555 + 17Sep02 GSG Added HAL support (new class&devices)
19556 + 03Oct02 GSG Removed C++ style comments
19557 +***************************************************************************/
19558 +#ifndef _INC_EC_ERRORS
19559 +#define _INC_EC_ERRORS
19560 +
19561 +/*
19562 + 31 - CRITICAL
19563 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
19564 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
19565 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
19566 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
19567 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
19568 +*/
19569 +
19570 +/*---------------------------------------------------------------------------
19571 + Useful defines for accessing fields within error code
19572 +---------------------------------------------------------------------------*/
19573 +#define CRITICAL_SHIFT 31
19574 +#define CLASS_SHIFT 28
19575 +#define INST_SHIFT 24
19576 +#define DEVICE_SHIFT 16
19577 +#define FUNCTION_SHIFT 8
19578 +#define ERROR_CODE_SHIFT 0
19579 +
19580 +#define CRITICAL_MASK 1
19581 +#define CLASS_MASK 0x07
19582 +#define DEVICE_MASK 0xFF
19583 +#define INST_MASK 0x0F
19584 +#define FUNCTION_MASK 0xFF
19585 +#define ERROR_CODE_MASK 0xFF
19586 +
19587 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
19588 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
19589 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
19590 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
19591 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
19592 +
19593 +/*---------------------------------------------------------------------------
19594 + Operation classes
19595 +---------------------------------------------------------------------------*/
19596 +#define EC_HAL EC_CLASS(0)
19597 +#define EC_DIAG EC_CLASS(8)
19598 +
19599 +/*---------------------------------------------------------------------------
19600 + Device types
19601 +---------------------------------------------------------------------------*/
19602 +#define EC_DEV_EMAC EC_DEVICE(1)
19603 +#define EC_DEV_IIC EC_DEVICE(2)
19604 +#define EC_DEV_RESET EC_DEVICE(3)
19605 +#define EC_DEV_ATMSAR EC_DEVICE(4)
19606 +#define EC_DEV_MEM EC_DEVICE(5)
19607 +#define EC_DEV_DES EC_DEVICE(6)
19608 +#define EC_DEV_DMA EC_DEVICE(7)
19609 +#define EC_DEV_DSP EC_DEVICE(8)
19610 +#define EC_DEV_TMR EC_DEVICE(9)
19611 +#define EC_DEV_WDT EC_DEVICE(10)
19612 +#define EC_DEV_DCL EC_DEVICE(11)
19613 +#define EC_DEV_BBIF EC_DEVICE(12)
19614 +#define EC_DEV_PCI EC_DEVICE(13)
19615 +#define EC_DEV_XBUS EC_DEVICE(14)
19616 +#define EC_DEV_DSLIF EC_DEVICE(15)
19617 +#define EC_DEV_USB EC_DEVICE(16)
19618 +#define EC_DEV_CLKC EC_DEVICE(17)
19619 +#define EC_DEV_RAPTOR EC_DEVICE(18)
19620 +#define EC_DEV_DSPC EC_DEVICE(19)
19621 +#define EC_DEV_INTC EC_DEVICE(20)
19622 +#define EC_DEV_GPIO EC_DEVICE(21)
19623 +#define EC_DEV_BIST EC_DEVICE(22)
19624 +#define EC_DEV_HDLC EC_DEVICE(23)
19625 +#define EC_DEV_UART EC_DEVICE(24)
19626 +#define EC_DEV_VOIC EC_DEVICE(25)
19627 +/* 9.17.02 (new HAL modules) */
19628 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
19629 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
19630 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
19631 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
19632 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
19633 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
19634 +#define EC_DEV_CPPI EC_DEVICE(0x20)
19635 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
19636 +
19637 +/*---------------------------------------------------------------------------
19638 + Function types
19639 +---------------------------------------------------------------------------*/
19640 +#define EC_FUNC_READ_CONF EC_FUNC(1)
19641 +#define EC_FUNC_INIT EC_FUNC(2)
19642 +
19643 +/*---------------------------------------------------------------------------
19644 + Error codes
19645 +---------------------------------------------------------------------------*/
19646 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
19647 +#define EC_NO_ERRORS 0
19648 +#define EC_VAL_NO_BASE EC_ERR(1)
19649 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
19650 +#define EC_VAL_NO_RESET EC_ERR(3)
19651 +#define EC_VAL_BAD_BASE EC_ERR(4)
19652 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
19653 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
19654 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
19655 +
19656 +/*---------------------------------------------------------------------------
19657 + Function declarations
19658 +---------------------------------------------------------------------------*/
19659 +extern void ec_log_error( unsigned int );
19660 +
19661 +#endif /* _INC_EC_ERRORS */
19662 diff -urN linux.old/drivers/atm/sangam_atm/ec_errors_cpsar.h linux.dev/drivers/atm/sangam_atm/ec_errors_cpsar.h
19663 --- linux.old/drivers/atm/sangam_atm/ec_errors_cpsar.h 1970-01-01 01:00:00.000000000 +0100
19664 +++ linux.dev/drivers/atm/sangam_atm/ec_errors_cpsar.h 2005-08-23 04:46:50.102842936 +0200
19665 @@ -0,0 +1,118 @@
19666 +/***************************************************************************
19667 + Copyright(c) 2001, Texas Instruments Incorporated. All Rights Reserved.
19668 +
19669 + FILE: ec_errors.h
19670 +
19671 + DESCRIPTION:
19672 + This file contains definitions and function declarations for
19673 + error code support.
19674 +
19675 + HISTORY:
19676 + 14Dec00 MJH Added masking to EC_CLASS etc macros
19677 + 17Sep02 GSG Added HAL support (new class&devices)
19678 + 03Oct02 GSG Removed C++ style comments
19679 +***************************************************************************/
19680 +#ifndef _INC_EC_ERRORS
19681 +#define _INC_EC_ERRORS
19682 +
19683 +/*
19684 + 31 - CRITICAL
19685 + 30-28 - CLASS (ie. DIAG, KERNEL, FLASH, etc)
19686 + 27-24 - INSTANCE (ie. 1, 2, 3, etc )
19687 + 23-16 - DEVICE (ie. EMAC, IIC, etc)
19688 + 15-08 - FUNCTION (ie. RX, TX, INIT, etc)
19689 + 07-00 - ERROR CODE (ie. NO_BASE, FILE_NOT_FOUND, etc )
19690 +*/
19691 +
19692 +/*---------------------------------------------------------------------------
19693 + Useful defines for accessing fields within error code
19694 +---------------------------------------------------------------------------*/
19695 +#define CRITICAL_SHIFT 31
19696 +#define CLASS_SHIFT 28
19697 +#define INST_SHIFT 24
19698 +#define DEVICE_SHIFT 16
19699 +#define FUNCTION_SHIFT 8
19700 +#define ERROR_CODE_SHIFT 0
19701 +
19702 +#define CRITICAL_MASK 1
19703 +#define CLASS_MASK 0x07
19704 +#define DEVICE_MASK 0xFF
19705 +#define INST_MASK 0x0F
19706 +#define FUNCTION_MASK 0xFF
19707 +#define ERROR_CODE_MASK 0xFF
19708 +
19709 +#define EC_CLASS(val) ((val&CLASS_MASK) << CLASS_SHIFT)
19710 +#define EC_DEVICE(val) ((val&DEVICE_MASK) << DEVICE_SHIFT)
19711 +#define EC_INST(val) ((val&INST_MASK) << INST_SHIFT)
19712 +#define EC_FUNC(val) ((val&FUNCTION_MASK) << FUNCTION_SHIFT)
19713 +#define EC_ERR(val) ((val&ERROR_CODE_MASK) << ERROR_CODE_SHIFT)
19714 +
19715 +/*---------------------------------------------------------------------------
19716 + Operation classes
19717 +---------------------------------------------------------------------------*/
19718 +#define EC_HAL EC_CLASS(0)
19719 +#define EC_DIAG EC_CLASS(8)
19720 +
19721 +/*---------------------------------------------------------------------------
19722 + Device types
19723 +---------------------------------------------------------------------------*/
19724 +#define EC_DEV_EMAC EC_DEVICE(1)
19725 +#define EC_DEV_IIC EC_DEVICE(2)
19726 +#define EC_DEV_RESET EC_DEVICE(3)
19727 +#define EC_DEV_ATMSAR EC_DEVICE(4)
19728 +#define EC_DEV_MEM EC_DEVICE(5)
19729 +#define EC_DEV_DES EC_DEVICE(6)
19730 +#define EC_DEV_DMA EC_DEVICE(7)
19731 +#define EC_DEV_DSP EC_DEVICE(8)
19732 +#define EC_DEV_TMR EC_DEVICE(9)
19733 +#define EC_DEV_WDT EC_DEVICE(10)
19734 +#define EC_DEV_DCL EC_DEVICE(11)
19735 +#define EC_DEV_BBIF EC_DEVICE(12)
19736 +#define EC_DEV_PCI EC_DEVICE(13)
19737 +#define EC_DEV_XBUS EC_DEVICE(14)
19738 +#define EC_DEV_DSLIF EC_DEVICE(15)
19739 +#define EC_DEV_USB EC_DEVICE(16)
19740 +#define EC_DEV_CLKC EC_DEVICE(17)
19741 +#define EC_DEV_RAPTOR EC_DEVICE(18)
19742 +#define EC_DEV_DSPC EC_DEVICE(19)
19743 +#define EC_DEV_INTC EC_DEVICE(20)
19744 +#define EC_DEV_GPIO EC_DEVICE(21)
19745 +#define EC_DEV_BIST EC_DEVICE(22)
19746 +#define EC_DEV_HDLC EC_DEVICE(23)
19747 +#define EC_DEV_UART EC_DEVICE(24)
19748 +#define EC_DEV_VOIC EC_DEVICE(25)
19749 +/* 9.17.02 (new HAL modules) */
19750 +#define EC_DEV_CPSAR EC_DEVICE(0x1A)
19751 +#define EC_DEV_AAL5 EC_DEVICE(0x1B)
19752 +#define EC_DEV_AAL2 EC_DEVICE(0x1C)
19753 +#define EC_DEV_CPMAC EC_DEVICE(0x1D)
19754 +#define EC_DEV_VDMA EC_DEVICE(0x1E)
19755 +#define EC_DEV_VLYNQ EC_DEVICE(0x1F)
19756 +#define EC_DEV_CPPI EC_DEVICE(0x20)
19757 +#define EC_DEV_CPMDIO EC_DEVICE(0x21)
19758 +
19759 +/*---------------------------------------------------------------------------
19760 + Function types
19761 +---------------------------------------------------------------------------*/
19762 +#define EC_FUNC_READ_CONF EC_FUNC(1)
19763 +#define EC_FUNC_INIT EC_FUNC(2)
19764 +
19765 +/*---------------------------------------------------------------------------
19766 + Error codes
19767 +---------------------------------------------------------------------------*/
19768 +#define EC_CRITICAL (1<<CRITICAL_SHIFT)
19769 +#define EC_NO_ERRORS 0
19770 +#define EC_VAL_NO_BASE EC_ERR(1)
19771 +#define EC_VAL_NO_RESET_BIT EC_ERR(2)
19772 +#define EC_VAL_NO_RESET EC_ERR(3)
19773 +#define EC_VAL_BAD_BASE EC_ERR(4)
19774 +#define EC_VAL_MALLOCFAILED EC_ERR(5)
19775 +#define EC_VAL_NO_RESETBASE EC_ERR(6)
19776 +#define EC_DEVICE_NOT_FOUND EC_ERR(7)
19777 +
19778 +/*---------------------------------------------------------------------------
19779 + Function declarations
19780 +---------------------------------------------------------------------------*/
19781 +extern void ec_log_error( unsigned int );
19782 +
19783 +#endif /* _INC_EC_ERRORS */
19784 diff -urN linux.old/drivers/atm/sangam_atm/env_def_defines.h linux.dev/drivers/atm/sangam_atm/env_def_defines.h
19785 --- linux.old/drivers/atm/sangam_atm/env_def_defines.h 1970-01-01 01:00:00.000000000 +0100
19786 +++ linux.dev/drivers/atm/sangam_atm/env_def_defines.h 2005-08-23 04:46:50.103842784 +0200
19787 @@ -0,0 +1,926 @@
19788 +#ifndef __ENV_DEF_DEFINES_H__
19789 +#define __ENV_DEF_DEFINES_H__ 1
19790 +
19791 +//********************************************************************
19792 +//* DMT-BASE ADSL MODEM PROGRAM
19793 +//* TEXAS INSTRUMENTS PROPRIETARTY INFORMATION
19794 +//* AMATI CONFIDENTIAL PROPRIETARY
19795 +//*
19796 +//* (c) Copyright May 1999, Texas Instruments Incorporated.
19797 +//* All Rights Reserved.
19798 +//*
19799 +//* Property of Texas Instruments Incorporated and Amati Communications Corp.
19800 +//*
19801 +//* Restricted Rights - Use, duplication, or disclosure is subject to
19802 +//* restrictions set forth in TI's and Amati program license agreement and
19803 +//* associated documentation
19804 +//*
19805 +//*********************************************************************
19806 +//*
19807 +//* FILENAME: dpsys_defines.h
19808 +//*
19809 +//* ABSTRACT: This file provides a mechanism for defining standard
19810 +//* preprocessor flag sets for datapump.
19811 +//*
19812 +//* TARGET: Non specific.
19813 +//*
19814 +//* TOOLSET: Non specific.
19815 +//*
19816 +//* ACTIVATION:
19817 +//*
19818 +//* HISTORY: DATE AUTHOR DESCRIPTION
19819 +//* 05/11/99 FLW Created
19820 +//* 01/21/00 FLW derfmake changes
19821 +//* 02/07/00 FLW/M.Seidl added _debug targets
19822 +//* 02/23/00 FLW/M.Barnett merged in from G.lite branch
19823 +//* 03/03/00 FLW/M.Barnett added TRELLIS token
19824 +//* 05/11/00 Barnett Added ap036btp & ap037btp support.
19825 +//* 02/07/00 M.Seidl added HW_TEQ, HW_DEC and DC_BIAS tokens
19826 +//* 02/28/00 Derf/Seidl Mod's in support of suppressing compiler warnings for empty source files
19827 +//* 02/28/00 M. Seidl added SWTC token
19828 +//* 02/28/00 M. Seidl added ap0501tp and its _debug target
19829 +//* 03/03/00 M. Seidl added MODPILOT token, ap0307tp_debug has SWDI and FDD enabled
19830 +//* 03/08/00 Jack Huang Added HWRSDEC token
19831 +//* 03/29/00 Derf/Seidl Mod's in support Soft-TC and derfmake
19832 +//* 04/10/00 Jack Huang Added PCIMASTER token
19833 +//* 04/11/00 Jack Huang Added STBFIX token
19834 +//* 04/24/00 M. Seidl ap0500tp has OLAYDP turned on, ap0500tp_debug has OLAYDP turned off now
19835 +//* 04/28/00 M.Seidl added KAPIL token for ap0501tp targets
19836 +//* 06/02/00 P.Sexton Added OAM_EOC token
19837 +//* 06/06/00 M. Seidl added au0501tp target
19838 +//* 06/12/00 Michael Seidl activated h/w TEQ for KAPIL targets, disabled STBFIX for all targets
19839 +//* 06/14/00 Derf added ap0308tp, alphabetized token lists
19840 +//* 06/16/00 Jack Huang added au0501tp_debug target
19841 +//* 06/22/00 M. Seidl Enabled code overlays through EMIF from external memory. Now there are 3
19842 +//* different code overlay schemes that are differentiated by the following tokens:
19843 +//* OLAYDP_PCI: uses PCI DMA in PCI Master Mode
19844 +//* OLAYDP_HOST: Host downloads overlay code into DMEM upon request from DSP
19845 +//* OLAYDP_EMIF: Host downloads overlay code into ext. mem at boot-time. DSP uses
19846 +//* DMA channel 0 to load code into on-chip PMEM
19847 +//* OLAYDP: turns overlays generally on or off
19848 +//* 07/15/00 B.Srinivasan Cleaned up default tokens and tokens for au0501tp, au0501tp_debug,
19849 +//* ap0501tp and ap0501tp_debug targets as well
19850 +//* 07/19/00 B.Srinivasan Made changes w.r.t cleaning/fixing Rufus Interrupt related code
19851 +//* (changed token TC_INTRPT_RUFUS to INTRPT_RUFUS
19852 +//* 06/14/00 Derf added au0501cp
19853 +//* 08/12/00 Yinong Ding Added DPLL_MODE token.
19854 +//* 08/16/00 F. Mujica Moved DOUBLE_XMT_RATE, RX_HPF, and LEAKY_LMS tokens here.
19855 +//* 09/05/00 M. Seidl Changed ap0501tp back to do overlay through PCI (OLAY_PCI = 1)
19856 +//* 09/11/00 M. Seidl moved USB and OLAYDP_HOST definitions to be CHIPSET specific, not target specific
19857 +//* 09/21/00 U.Dasgupta/ Added a token for separate transmit and receive buffers.
19858 +//* F.Mujica (SEPARATE_TX_RX_BUFFERS).
19859 +//* 10/02/00 U.Dasgupta/ Added DPLL and SEPARATE_TX_RX_BUFFER tokens for au0502 target.
19860 +//* F.Mujica
19861 +//* 10/02/00 M. Castellano Added new tokens for new Host/EMIF DSP code overlay.
19862 +//* OLAYDP_2STEP: Host downloads overlay code into ext. mem upon DSP request. DSP
19863 +//* DMA channel 0 to load code into on-chip PMEM. It is a somewhat hybrid version
19864 +//* of OLAYDP_HOST and OLAYDP_EMIF. The test target is ap0502tp.
19865 +//* 10/25/00 Balaji Added tokens for arv500tp target
19866 +//* 10/31/00 U. Iyer Added TEQ_AVG token and set it one for Ax5
19867 +//* 11/02/00 Barnett Added OAM_EOC=0 in defaults at bottom of file.
19868 +//* 11/21/00 M. Seidl turned OLAYDP and AOC off for ap0307tp to make binary compatible w. whql'ed driver
19869 +//* 11/28/00 Paul Hunt added FASTRETRAIN token for fast retrain specific code
19870 +//* 11/28/00 Paul Hunt added PILOTDATA token to control channel estimation and transmission
19871 +//* of data on the upstream pilot tone for ITU standard code loads
19872 +//* 12/20/00 Jack Huang added EIGHTBITSRAM toekn for the targets that use 8-bit SRAM for
19873 +//* interleaver/deinterleaver
19874 +//* 01/11/01 U.Dasgupta Added mp targets and cleaned up GHS/PILOTDATA variables
19875 +//* 01/23/01 U.Dasgupta Cleaned up code within GLITE tokens
19876 +//* 01/23/00 Barnett Added in full EOC support for AP3/Ax5. Got rid of UTC. No longer needed.
19877 +//* 02/08/01 Barnett Added DDC token.
19878 +//* 03/09/01 Nirmal Warke Added in TOKEN definition for line diagnostics (LINE_DIAG): IMP DEPENDENCIES -
19879 +//* TEQ_AVG must be off when LINE_DIAG is on (since they share a union buffer at the same time)
19880 +//* 03/13/01 M. Seidl Recovered ap0500tp target. Added GHS token as PMEM saving option
19881 +//* 03/14/01 Barnett Added ap0500mb target support. Look-and-feel is similar to ap0500tp.
19882 +//* Added seperate-but-equal def's wrt. ISDN Annex B, Annex C, and PROP.
19883 +//* 03/14/01 J. Bergsagel Added EXTERNBERT token.
19884 +//* 03/15/01 Barnett/Balaji Merged AR5(H) -> 03.00.00 datapump.
19885 +//* 03/16/01 Nirmal Warke Added in TOKEN definition for crosstalk performance mods (CROSSTALK): IMP DEPENDENCIES -
19886 +//* TEQ_AVG must be off and LEAKY_LMS must be on when CROSSTALK is on
19887 +//* 03/21/01 Barnett Added support for ar0500lp, ar0500mp, ar0500dp, arv500lp, arv500mp, and arv500dp.
19888 +//* 03/26/01 M. Seidl enabled 64pt IFFT for ap0500mb (Raptor+AD11, FDM)
19889 +//* 03/28/01 J. Bergsagel Removed EXTERNBERT token (now use host intf. var. instead)
19890 +//* 04/03/01 J. Bergsagel Removed condition of DSPDP_CHIPSET_GEN==5 for default defines
19891 +//* Removed LEAKY_LMS token (assumed always 1)
19892 +//* Removed OLAYDP_HOST token (assumed always 0)
19893 +//* Removed RX_HPF token (assumed always 1)
19894 +//* Removed TRIBRID token (not used any more)
19895 +//* Removed FDD token (assumed always 1)
19896 +//* Removed HW_DEC token (assumed always 1)
19897 +//* Removed HW_TEQ token (assumed always 1)
19898 +//* Removed HWRSDEC token (assumed always 1)
19899 +//* Removed ILEC_AD11_ALCATEL337 token (assumed always 0)
19900 +//* Removed ILEC_AD11_HDSLNOISEFIX token (assumed always 0)
19901 +//* Removed ILEC_AD11_MODULATEPILOT token (assumed always 0)
19902 +//* Removed ILEC_AD11_NEWINTERPOLATE token (assumed always 0)
19903 +//* Removed ILEC_AD11_USTXHPF token (assumed always 0)
19904 +//* Removed SWDI token (assumed always 1)
19905 +//* Removed TD_AGC token (assumed always 1)
19906 +//* Removed DSPDP_LEGACY_TARGET token (assumed always 0)
19907 +//* Removed AD11_20, AD11_20NL and AD11_20_NEWPREC token (always 1)
19908 +//* Removed AI token (assumed always 1)
19909 +//* Removed ATUC token (assumed always 0)
19910 +//* Removed EU token (assumed always 0)
19911 +//* Removed EVM2 token (assumed always 0)
19912 +//* Removed INTRPT_RUFUS token (assumed always 0)
19913 +//* Removed MODPILOT token (assumed always 0)
19914 +//* Removed SL and SL_EVM tokens (assumed always 0)
19915 +//* Removed STBIFX token (assumed always 0)
19916 +//* Removed STD token (assumed always 1)
19917 +//* Removed SWDI_LOOPBACK token (assumed always 0)
19918 +//* Removed TID token (assumed always 0)
19919 +//* Removed TII token (assumed always 1)
19920 +//* Removed TIPCI token (assumed always 1)
19921 +//* Removed UDI token (assumed always 1)
19922 +//* Removed DC_BIAS token (assumed always 1)
19923 +//* 04/05/01 Barnett Added DSPDP_ prefix to tokens that originate
19924 +//* in the public interface.
19925 +//* 05/07/01 Jack Huang Removed DOUBLE_XMT_RATE token.
19926 +//* 05/16/01 Barnett Added back in EXTERNBERT token in support
19927 +//* of saving PMEM.
19928 +//* 06/05/01 Jack Huang Fixed the rules for ar0500mp_debug target
19929 +//* 04/23/01 M. Halleck Merge Astro Wu's DDC enhancements
19930 +//* 06/05/01 M. Capps Changed DSP_DEBUG to ENHANCED_SERIAL_DEBUG
19931 +//* 07/03/01 M. Capps Replaced ESD token with !DDC, added DEV_DEBUG
19932 +//* 06/26/01 J. Bergsagel Removed all the old ap03... stuff
19933 +//* Removed OLAYDP_HOST token (again)
19934 +//* Removed CROSSTALK token (assumed always 1)
19935 +//* Removed TEQ_AVG token (assumed always 0)
19936 +//* Removed DE token (assumed always 1)
19937 +//* Removed PVAT token and au0501cp target
19938 +//* Removed FASTRETRAIN token (assumed always 0)
19939 +//* 07/05/01 J. Bergsagel Changed PCIMASTER token to TC_ATM_PCIMASTER
19940 +//* 07/20/01 Umesh Iyer Added ATMBERT token. ATMBERT is conditional on SWTC definition. if SWTC is 0
19941 +//* ATMBERT should be 0. Else it can be 0/1. Default 0.
19942 +//* 07/23/01 J. Bergsagel Changed name from defines_u.h to dpsys_defines.h
19943 +//* 07/24/01 Barnett Added support for build of $(TARGET)_diag mfgr'ing targets.
19944 +//* 08/02/01 Michael Seidl renamed KAPIL token to !AD1X
19945 +//* 08/02/01 Michael Seidl renamed GHS token to PMEMSAVE_GHS
19946 +//* 08/03/01 S.Yim Added MFGR_DIAG token for afe diagnostic
19947 +//* Added AFEDEV token for afe device driver
19948 +//* Added DSPBIOSII token for dsp bios
19949 +//* 09/21/01 Sameer Enable EXTERNBERT. Disable ATMBERT.
19950 +//* 10/01/01 U.Dasgupta Turned off SMART_MARGIN for ap0500mb because of FECs/CRCs;
19951 +//* 10/09/01 Barnett Added support for ar0500db.
19952 +//* 10/12/01 Barnett Disable EXTERNBERT.
19953 +//* 10/15/01 Barnett Turn off SMART_MARGIN.
19954 +//* 11/07/01 Barnett Def'ed ISDN_DEBUG for all targets to avoid compiler warnings.
19955 +//* Assumed defaul value is zero.
19956 +//* 11/13/01 Barnett Reworked ar0500db_debug to build JTAG-bootable load.
19957 +//* The equivalent production target should only be flash-bootable.
19958 +//* 01/11/02 Yim Added TOKEN JTAG to build JTAG load ar0500db_diag.
19959 +//* 01/23/02 U Iyer Added DEBUG_LOG token. Default value 0
19960 +//* 01/31/02 Barnett Added support for ar0700mp target.
19961 +//* 02/04/02 S.Yim Added TOKEN JTAG to build JTAG load ar0500mp_diag
19962 +//* 02/11/02 U Iyer Added MARGIN_DELTA_RETRAIN token. Default value 1
19963 +//* 05/15/02 Sameer V Enabled EXTERNBERT token for AR5 and AU5 platforms. EXTERNBERT is
19964 +//* not supported on AR5H.
19965 +//* 02/14/02 Barnett Don't ref the SWTC feature token if mfgr'ing diag target.
19966 +//* 02/19/02 Yim Added support to build au0502db_diag target.
19967 +//* 03/08/02 Nirmal Warke Added feature token HYBRID_SWITCH
19968 +//* 03/15/02 U G Jani Turned ON Bitswap support for AU5I (au0502db) targets.
19969 +//* 04/08/02 U G Jani Enabled NLNOISEADJSNR token for AU5I targets.
19970 +//* 06/24/02 Seungmok Oh Added PERTONE_EQ token support for those targets:
19971 +//* (ar0500mp_debug, au0502mp_debug, ar0500mp, au0502mp)
19972 +//* 06/26/02 Mallesh Added DS_PWR_CUTBACK token. Default value 1.
19973 +//* 06/27/02 Mallesh Changed default value of DS_PWR_CUTBACK token to 0.
19974 +//* 06/29/02 U.Dasgupta Token cleanup: Removed ISDN_DEBUG token
19975 +//* 04/29/02 Mannering Remove EIGHTBITSRAM, Combined DOUBLEBUFFER with
19976 +//* BITSWAP, added FPGA token
19977 +//* 05/03/02 Mannering cleanup token changed by the new routine names
19978 +//* 05/06/02 Mannering Add tokens OUTBAND and INBAND for codec commands
19979 +//* If both OUTBAND and INBAND are 0 codec register are
19980 +//* memory mapped.
19981 +//* 05/29/2002 S.Yim Removed AD1X, AFEDEV
19982 +//* 08/31/2002 Paul Hunt Added PERTONE_EQ and HYBRID_SWITCH for ar0700mp
19983 +//* 09/12/2002 Paul Hunt Added support for ar0700db target.
19984 +//* 08/07/2002 U.Dasgupta Turned off MARGIN_DELTA_RETRAIN feature for ISDN platforms
19985 +//* 11/14/2002 Paul Hunt Merged AX5 MR6 PC modifications into AR7 codebase, specifically
19986 +//* turned off MARGIN_DELTA_RETRAIN feature for ar0700db target
19987 +//* 08/26/2002 N. Warke Added DUAL_TEQ token. Active only for Ax7 target
19988 +//* 09/26/2002 Mannering Add token CODEC_EMU for codec emulator board
19989 +//* 10/15/2002 Iyer/Molla Added DMT_BIS token for DELT support
19990 +//* 10/21/2002 A. Redfern Added PHY_EC_ENABLE and PHY_PATH_ENABLE tokens
19991 +//* 10/23/2002 A. Redfern Removed LINE_DIAG token
19992 +//* 10/28/2002 J. Bergsagel Cleaned up old targets and cleaned up the token list
19993 +//* 10/30/2002 A. Redfern Added PHY_TDW_ENABLE
19994 +//* 11/01/2002 A. Redfern Removed SMART_MARGIN token
19995 +//* 11/01/2002 Mustafa Turned on SPECTRAL_SHAPING features for Lucent AnyMedia O.69 Interop.
19996 +//* 11/15/2002 Yim/Mannering Added CODEC_EMU token for analog emulation board specifics
19997 +//* 11/15/2002 Iyer/Molla Added DEBUG_DELT and MEM_STR token to support DELT debug
19998 +//* 12/27/2002 Sameer V Added ATM_TC_HW token for Sangam.
19999 +//* 01/06/2003 J. Bergsagel Added default values for NLNOISEADJSNR, ARTT and DS_PWR_CUTBACK
20000 +//* 01/07/2003 S.Yim Modified ar0700db_diag target to turn on ISDN token
20001 +//* 01/22/2003 J. Bergsagel Added back in defines for the debug targets.
20002 +//* 01/21/2003 MCB Implemented Ax7 UNIT-MODULE modular software framework.
20003 +//* 01/31/2003 J. Bergsagel Made debug targets to be for the FPGA platform; non-debug for Sangam.
20004 +//* Turned off DUAL_TEQ, PHY_EC_ENABLE and PHY_PATH_ENABLE by default
20005 +//* for the Sangam (non-debug) targets.
20006 +//* Turned off OLAYDP token by default.
20007 +//* Turned off SWTC and turned on ATM_TC_HW by default for Sangam targets.
20008 +//* 01/29/2003 Sameer V Added ATMBERT_HW token for Sangam.
20009 +//* 02/04/2003 D. Mannering Added CO_PROFILE token
20010 +//* 02/19/2003 Sameer V Added back EXTERNBERT token for ar0700mp_dp and ar0700db_dp targets.
20011 +//* Disabled EXTERNBERT for debug target since it is not supported on the
20012 +//* FPGA platform.
20013 +//* 02/21/2003 A. Redfern Turned off OAM_EOC, AOC and BITSWAP (until memory issues are resolved).
20014 +//* Turned on DUAL_TEQ, PHY_PATH_ENABLE and PHY_EC_ENABLE.
20015 +//* 02/21/2003 D. Mannering Added DEBUG_DUMP.
20016 +//* 03/06/2003 J. Bergsagel Cleaned up tokens for each target and switched diag targets
20017 +//* over to the Sangam platform (instead of the FPGA platform).
20018 +//* 03/07/2003 J. Bergsagel Cleaned up TC and BERT tokens
20019 +//* 03/11/2003 J. Bergsagel Turned on AOC and BITSWAP for Sangam POTS and ISDN targets.
20020 +//* 03/20/2003 Mallesh Added SHALF token.
20021 +//* 03/24/2003 F. Mujica Enable hybrid selection
20022 +//* 03/26/2003 A. Redfern Removed PMEMSAVE_GHS (always = 1).
20023 +//* 04/08/2003 F. Mujica Renamed HYBRID_SWITCH token to PHY_HYB_ENABLE
20024 +//* 04/08/2003 J. Bergsagel Turned off PHY_HYB_ENABLE for _debug targets (FPGA board builds)
20025 +//* 04/09/2003 J. Bergsagel Turned on OLAYDP only for ar0700mp and ar0700db.
20026 +//* Turned on AOC, BITSWAP, and OAM_EOC for ar0700mp and ar0700db.
20027 +//* 04/09/2003 J. Bergsagel Corrected name "PHY_HYB_SELECT" to "PHY_HYB_ENABLE"
20028 +//* 04/15/2003 A. Redfern Turned on ECI_PULSECOM_INTEROP because phase optimization was enabled.
20029 +//* 05/05/2003 D. Mannering Review Comments - turn on AOC, EXTERNBERT, SHALF, for ar0700mp; amd
20030 +//* turn on AOC for ar0700db
20031 +//* 05/11/2003 Prashant S Added DMT_BIS token for AR7 Soft DI work
20032 +//* 05/13/2003 J. Bergsagel Turned on IMPROVED_STAT_SUPPORT_06_03_00 by default for necessary statistics
20033 +//* 05/15/2003 J. Bergsagel Turned off CO_PROFILE for diag targets.
20034 +//* 05/27/2003 U.Dasgupta Added NLNOISEADJSNR_EC token for ISDN - to take care of non-linear noise
20035 +//* (from ISDN splitter) compensation.
20036 +//* 06/02/2003 Z. Yang Added PHY_NDIAG_ENABLE token.
20037 +//* 06/02/2003 Z. Yang Added COMB_LINEDIAG_ENABLE token.
20038 +//* 06/05/2003 P. Hunt Turned on ATUC_CLEARDOWN_CHANGE token for all targets.
20039 +//* 06/05/2003 Mallesh Turned on CENTILLIUM_VENDORID_AND_TXRATE_CHNG to enable logging the vendor ID
20040 +//* for centillium and litespan
20041 +//* 06/05/2003 U.Dasgupta Turned on SHALF token for ISDN.
20042 +//* 06/06/2003 U.Dasgupta Turned on G.hs nonstandard field token for ar0700db target.
20043 +//* 06/12/2003 J. Bergsagel Changed *_debug targets to be for JTAG=1 instead of FPGA targets
20044 +//* IMPORTANT: For non-JTAG cases, "JTAG" should be undefined.
20045 +//* Therefore, "JTAG" should not have a default case at the bottom (JTAG 0)
20046 +//* 06/18/2003 A. Redfern Turned on spectral shaping token for all targets.
20047 +//* 06/23/2003 J. Bergsagel Turned off GHS_NON_STD_FIELD token for ar0700db until bugs are fixed.
20048 +//* 06/23/2003 U G Jani Undid the above change since the bug is fixed.
20049 +//* 06/27/2003 Mallesh Removed all the interop tokens which are no longer required.
20050 +//* 08/20/2003 J. Bergsagel Added default value for OVHD_PMDTEST_PARA and put default section
20051 +//* tokens in alphabetical order.
20052 +//* 10/09/2003 Hanyu Liu Defined token ADSL2_1BIT_TONE to support Rx one bit constellation.
20053 +//* 10/12/2003 Hanyu Liu Defined token ADSL2_BSWP for bitswap.
20054 +//* 10/20/2003 Xiaohui Li Added READSL2_ENABLE token.
20055 +//* 12/01/2003 Seungmok Oh Added TXDF2B_PROFILING token, which is active only for POTS target.
20056 +//* 12/09/2003 Jack Huang Turned on GHS_NON_STD_FIELD support for AR7 POTS targets
20057 +//* 12/16/2003 Mustafa T. Added the necessary definitions for diag target.
20058 +//*****************************************************************************************************
20059 +//*
20060 +//* The default flag settings are:
20061 +//*
20062 +//* -dATUC=1 -dSTD=0 -dISDN=0 -dTIPCI=0 -dTID=0 -dTII=0 -dAI=0
20063 +//* -dEVM2=0 -dEU=0 -dSL=0 -dSL_EVM=1 -dGLITE=0
20064 +//*
20065 +//* and are set after all the per-suffix options have had a chance to
20066 +//* set them. Each flag is only set if it has not previously been set, so
20067 +//* per-suffix settings can override defaults, and command-line defines can
20068 +//* override per-suffix settings.
20069 +//*
20070 +//*****************************************************************************
20071 +
20072 +
20073 +//* ===========================================================================
20074 +//* Suffix codes
20075 +//* The command-line can include -dOBJSFX_xxx to get a flag set
20076 +//* instead of explicitly setting each flag on each CC/ASM command-line.
20077 +//* and the object suffix will control the settings of "feature" constants.
20078 +//* ===========================================================================
20079 +//
20080 +//* ===========================================================================
20081 +// Flag settings for new suffixes (in alphabetical order of suffix)
20082 +// Each suffix has to specify only those flags which differ from the
20083 +// default settings.
20084 +//* ===========================================================================
20085 +// NOTE: Try to keep feature flags in alphabetical order to ease maintenance.
20086 +//* ===========================================================================
20087 +//*
20088 +
20089 +#define CHIPSET_ID_UNKN '?'
20090 +#define CHIPSET_ID_AH 'H'
20091 +#define CHIPSET_ID_AP 'P'
20092 +#define CHIPSET_ID_AR 'R'
20093 +#define CHIPSET_ID_ARV 'R'
20094 +#define CHIPSET_ID_AT 'T'
20095 +#define CHIPSET_ID_AU 'U'
20096 +
20097 +#define CHIPSET_ID2_GENERIC '0'
20098 +#define CHIPSET_ID2_ARV 'R'
20099 +
20100 + #define DSPDP_IMAGE_ID_STANDARD(code) ( \
20101 + STANDARD_is_MULTIMODE(code) ? "M" : \
20102 + STANDARD_is_GDMT(code) ? "D" : \
20103 + STANDARD_is_GLITE(code) ? "L" : \
20104 + STANDARD_is_T1413(code) ? "T" : "_")
20105 +
20106 + #define DSPDP_IMAGE_ID_SERVICE(code) ( \
20107 + SERVICE_is_POTS(code) ? "P" : \
20108 + SERVICE_is_ISDN_ANNEXB(code) ? "B" : \
20109 + SERVICE_is_ISDN_ANNEXC(code) ? "C" : \
20110 + SERVICE_is_ISDN_PROP(code) ? "I" : "")
20111 +
20112 +// Bit-codes for feature byte in new version.
20113 +//
20114 +// 0000 0000
20115 +// |||| ||||
20116 +// |||| |||+ -- POTS
20117 +// |||| ||+---- ISDN_ANNEXB
20118 +// |||| |+----- ISDN_ANNEXC
20119 +// |||| +------ ISDN_PROP
20120 +// |||+--------
20121 +// ||+--------- GHS
20122 +// |+---------- GLITE
20123 +// +----------- T1413
20124 +//
20125 +//
20126 +#define FEATURE_BIT_T1413 0x80
20127 +#define FEATURE_BIT_GLITE 0x40
20128 +#define FEATURE_BIT_GHS 0x20
20129 +#define FEATURE_BIT_ISDN_PROP 0x08
20130 +#define FEATURE_BIT_ISDN_ANNEXC 0x04
20131 +#define FEATURE_BIT_ISDN_ANNEXB 0x02
20132 +#define FEATURE_BIT_POTS 0x01
20133 +
20134 +#define STANDARD_BITS_MASK (FEATURE_BIT_T1413 | FEATURE_BIT_GLITE | FEATURE_BIT_GHS)
20135 +#define STANDARD_BITS_T1413 FEATURE_BIT_T1413
20136 +#define STANDARD_BITS_GHS FEATURE_BIT_GHS
20137 +#define STANDARD_BITS_GLITE (FEATURE_BIT_GLITE | FEATURE_BIT_GHS)
20138 +#define STANDARD_BITS_GDMT (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)
20139 +#define STANDARD_BITS_MULTIMODE (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)
20140 +
20141 +#define SERVICE_BIT_ISDN_ANNEXB FEATURE_BIT_ISDN_ANNEXB
20142 +#define SERVICE_BIT_ISDN_ANNEXC FEATURE_BIT_ISDN_ANNEXC
20143 +#define SERVICE_BIT_ISDN_PROP FEATURE_BIT_ISDN_PROP
20144 +#define SERVICE_BIT_POTS FEATURE_BIT_POTS
20145 +
20146 +//
20147 +// Debug new-style suffixes
20148 +//
20149 +//
20150 +
20151 +#if defined(OBJSFX_ar0700db_debugobj)
20152 +#ifndef OBJSFX_ar0700dbobj
20153 +#define OBJSFX_ar0700dbobj 1
20154 +#endif
20155 +// Here, in alphabetic order, are the feature tokens that
20156 +// distinguish this suffix from its non-_debug partner:
20157 +// (All other tokens from the non-_debug partner that are non-conflicting will also be picked up)
20158 +
20159 +#ifndef JTAG
20160 +#define JTAG 1
20161 +#endif
20162 +
20163 +#elif defined(OBJSFX_ar0700mp_debugobj)
20164 +#ifndef OBJSFX_ar0700mpobj
20165 +#define OBJSFX_ar0700mpobj 1
20166 +#endif
20167 +// Here, in alphabetic order, are the feature tokens that
20168 +// distinguish this suffix from its non-_debug partner:
20169 +// (All other tokens from the non-_debug partner that are non-conflicting will also be picked up)
20170 +
20171 +#ifndef ADSL2_BSWP
20172 +#define ADSL2_BSWP 1
20173 +#endif
20174 +#ifndef AOC
20175 +#define AOC 1
20176 +#endif
20177 +#ifndef BITSWAP
20178 +#define BITSWAP 1
20179 +#endif
20180 +#ifndef DEBUG_ADSL2
20181 +#define DEBUG_ADSL2 0
20182 +#endif
20183 +#ifndef DEBUG_LOG
20184 +#define DEBUG_LOG 0
20185 +#endif
20186 +#ifndef GHS_NON_STD_FIELD
20187 +#define GHS_NON_STD_FIELD 1
20188 +#endif
20189 +#ifndef JTAG
20190 +#define JTAG 1
20191 +#endif
20192 +#endif // end of the series of "#elif defined" for debug targets
20193 +
20194 +
20195 +//
20196 +// Standard new-style suffixes for operational and mfgr'ing diag.
20197 +//
20198 +
20199 +#if defined(OBJSFX_ar0700dbobj)
20200 +#define CHIPSET_AR07 1
20201 +#define PLATFORM_AR0700 1
20202 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20203 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20204 +#define DSPDP_CHIPSET_GEN 7
20205 +#define DSPDP_HARDWARE_REV1 '0'
20206 +#define DSPDP_HARDWARE_REV2 '0'
20207 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_GDMT|SERVICE_BIT_ISDN_ANNEXB)
20208 +#ifndef AOC
20209 +#define AOC 1
20210 +#endif
20211 +// ATM_TC_HW and SWTC are mutually exclusive
20212 +#ifndef ATM_TC_HW
20213 +#define ATM_TC_HW 1
20214 +#endif
20215 +#ifndef SWTC
20216 +#define SWTC 0
20217 +#endif
20218 +#ifndef BITSWAP
20219 +#define BITSWAP 1
20220 +#endif
20221 +#ifndef EXTERNBERT
20222 +#define EXTERNBERT 0
20223 +#endif
20224 +#ifndef GHS_NON_STD_FIELD
20225 +#define GHS_NON_STD_FIELD 1
20226 +#endif
20227 +#ifndef MARGIN_DELTA_RETRAIN
20228 +#define MARGIN_DELTA_RETRAIN 0
20229 +#endif
20230 +#ifndef NLNOISEADJSNR_EC
20231 +#define NLNOISEADJSNR_EC 1
20232 +#endif
20233 +#ifndef OLAYDP
20234 +#define OLAYDP 1
20235 +#endif
20236 +#ifndef SHALF
20237 +#define SHALF 1
20238 +#endif
20239 +
20240 +
20241 +#elif defined(OBJSFX_ar0700db_diagobj)
20242 +#define CHIPSET_AR07 1
20243 +#define PLATFORM_AR0700 1
20244 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20245 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20246 +#define DSPDP_CHIPSET_GEN 7
20247 +#define DSPDP_HARDWARE_REV1 '0'
20248 +#define DSPDP_HARDWARE_REV2 '0'
20249 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_GDMT|SERVICE_BIT_ISDN_ANNEXB)
20250 +#ifndef AOC
20251 +#define AOC 0
20252 +#endif
20253 +// ATM_TC_HW and SWTC are mutually exclusive (or both must be off)
20254 +#ifndef ATM_TC_HW
20255 +#define ATM_TC_HW 0
20256 +#endif
20257 +#ifndef SWTC
20258 +#define SWTC 0
20259 +#endif
20260 +#ifndef BITSWAP
20261 +#define BITSWAP 0
20262 +#endif
20263 +#ifndef CO_PROFILE
20264 +#define CO_PROFILE 0
20265 +#endif
20266 +#ifndef MARGIN_DELTA_RETRAIN
20267 +#define MARGIN_DELTA_RETRAIN 0
20268 +#endif
20269 +#ifndef MFGR_DIAG
20270 +#define MFGR_DIAG 1
20271 +#endif
20272 +#ifndef OAM_EOC
20273 +#define OAM_EOC 0
20274 +#endif
20275 +#ifndef OLAYDP
20276 +#define OLAYDP 0
20277 +#endif
20278 +#ifndef SNR_UPDATE
20279 +#define SNR_UPDATE 0
20280 +#endif
20281 +
20282 +#elif defined(OBJSFX_ar0700mpobj)
20283 +#define CHIPSET_AR07 1
20284 +#define PLATFORM_AR0700 1
20285 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20286 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20287 +#define DSPDP_CHIPSET_GEN 7
20288 +#define DSPDP_HARDWARE_REV1 '0'
20289 +#define DSPDP_HARDWARE_REV2 '0'
20290 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_MULTIMODE|SERVICE_BIT_POTS)
20291 +#ifndef AOC
20292 +#define AOC 1
20293 +#endif
20294 +// ATM_TC_HW and SWTC are mutually exclusive
20295 +#ifndef ADSL2_1BIT_TONE
20296 +#define ADSL2_1BIT_TONE 0
20297 +#endif
20298 +#ifndef ADSL2_BSWP
20299 +#define ADSL2_BSWP 1
20300 +#endif
20301 +#ifndef ATM_TC_HW
20302 +#define ATM_TC_HW 1
20303 +#endif
20304 +#ifndef SWTC
20305 +#define SWTC 0
20306 +#endif
20307 +#ifndef BITSWAP
20308 +#define BITSWAP 1
20309 +#endif
20310 +#ifndef EXTERNBERT
20311 +#define EXTERNBERT 0
20312 +#endif
20313 +#ifndef OLAYDP
20314 +#define OLAYDP 1
20315 +#endif
20316 +#ifndef DMT_BIS
20317 +#define DMT_BIS 1
20318 +#endif
20319 +#ifndef SHALF
20320 +#define SHALF 1
20321 +#endif
20322 +#ifndef MEM_STR
20323 +#define MEM_STR 0
20324 +#endif
20325 +#ifndef DS_LOOP_BACK
20326 +#define DS_LOOP_BACK 0
20327 +#endif
20328 +#ifndef LOOP_BACK_DEBUG
20329 +#define LOOP_BACK_DEBUG 0
20330 +#endif
20331 +#ifndef US_LOOP_BACK
20332 +#define US_LOOP_BACK 0
20333 +#endif
20334 +#ifndef OVHD_PMDTEST_PARA
20335 +#define OVHD_PMDTEST_PARA 0
20336 +#endif
20337 +#ifndef DS_RX_CODEWORD
20338 +#define DS_RX_CODEWORD 1
20339 +#endif
20340 +#ifndef READSL2_ENABLE
20341 +#define READSL2_ENABLE 1
20342 +#endif
20343 +#ifndef GHS_NON_STD_FIELD
20344 +#define GHS_NON_STD_FIELD 1
20345 +#endif
20346 +
20347 +#elif defined(OBJSFX_ar0700mp_diagobj)
20348 +#define CHIPSET_AR07 1
20349 +#define PLATFORM_AR0700 1
20350 +#define DSPDP_CHIPSET_ID CHIPSET_ID_AR
20351 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20352 +#define DSPDP_CHIPSET_GEN 7
20353 +#define DSPDP_HARDWARE_REV1 '0'
20354 +#define DSPDP_HARDWARE_REV2 '0'
20355 +#define DSPDP_FEATURE_CODE (STANDARD_BITS_MULTIMODE|SERVICE_BIT_POTS)
20356 +#ifndef ADSL2_BSWP
20357 +#define ADSL2_BSWP 0
20358 +#endif
20359 +#ifndef AOC
20360 +#define AOC 0
20361 +#endif
20362 +// ATM_TC_HW and SWTC are mutually exclusive (or both must be off)
20363 +#ifndef ATM_TC_HW
20364 +#define ATM_TC_HW 0
20365 +#endif
20366 +#ifndef SWTC
20367 +#define SWTC 0
20368 +#endif
20369 +#ifndef BITSWAP
20370 +#define BITSWAP 0
20371 +#endif
20372 +#ifndef CO_PROFILE
20373 +#define CO_PROFILE 0
20374 +#endif
20375 +#ifndef DMT_BIS
20376 +#define DMT_BIS 0
20377 +#endif
20378 +#ifndef MARGIN_DELTA_RETRAIN
20379 +#define MARGIN_DELTA_RETRAIN 0
20380 +#endif
20381 +#ifndef MFGR_DIAG
20382 +#define MFGR_DIAG 1
20383 +#endif
20384 +#ifndef OAM_EOC
20385 +#define OAM_EOC 0
20386 +#endif
20387 +#ifndef OLAYDP
20388 +#define OLAYDP 0
20389 +#endif
20390 +#ifndef SNR_UPDATE
20391 +#define SNR_UPDATE 0
20392 +#endif
20393 +#ifndef US_CRC_RETRAIN
20394 +#define US_CRC_RETRAIN 0
20395 +#endif
20396 +#ifndef ADSL2_BSWP
20397 +#define ADSL2_BSWP 0
20398 +#endif
20399 +#ifndef DMT_BIS
20400 +#define DMT_BIS 0
20401 +#endif
20402 +#ifndef DS_RX_CODEWORD
20403 +#define DS_RX_CODEWORD 0
20404 +#endif
20405 +
20406 +#else
20407 +#define DSPDP_CHIPSET_ID CHIPSET_ID_UNKN
20408 +#define DSPDP_CHIPSET_ID2 CHIPSET_ID2_GENERIC
20409 +#define DSPDP_CHIPSET_GEN 0
20410 +#define DSPDP_HARDWARE_REV1 '0'
20411 +#define DSPDP_HARDWARE_REV2 '0'
20412 +#define DSPDP_FEATURE_CODE 0
20413 +#endif
20414 +
20415 +// For use in checking the code in drivers -- indented to avoid .h->.ah
20416 + #define STANDARD_is_T1413(code) (!(((code) & STANDARD_BITS_MASK) ^ STANDARD_BITS_T1413))
20417 + #define STANDARD_is_GLITE(code) (!(((code) & STANDARD_BITS_MASK) ^ STANDARD_BITS_GLITE))
20418 + #define STANDARD_is_GHS(code) (((code) & STANDARD_BITS_MASK) & STANDARD_BITS_GHS)
20419 + #define STANDARD_is_GDMT(code) (!(((code) & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)))
20420 + #define STANDARD_is_MULTIMODE(code) (!(((code) & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)))
20421 + #define SERVICE_is_POTS(code) ((code) & SERVICE_BIT_POTS)
20422 + #define SERVICE_is_ISDN_ANNEXB(code) ((code) & SERVICE_BIT_ISDN_ANNEXB)
20423 + #define SERVICE_is_ISDN_ANNEXC(code) ((code) & SERVICE_BIT_ISDN_ANNEXC)
20424 + #define SERVICE_is_ISDN_PROP(code) ((code) & SERVICE_BIT_ISDN_PROP)
20425 +
20426 +#define STANDARD_T1413 (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ STANDARD_BITS_T1413))
20427 +#define STANDARD_GLITE (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ STANDARD_BITS_GLITE))
20428 +#define STANDARD_GHS ((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) & STANDARD_BITS_GHS)
20429 +#define STANDARD_GDMT (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GHS)))
20430 +#define STANDARD_MULTIMODE (!((DSPDP_FEATURE_CODE & STANDARD_BITS_MASK) ^ (STANDARD_BITS_T1413 | STANDARD_BITS_GLITE | STANDARD_BITS_GDMT)))
20431 +
20432 +#define SERVICE_POTS (DSPDP_FEATURE_CODE & SERVICE_BIT_POTS)
20433 +#define SERVICE_ISDN_ANNEXB (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_ANNEXB)
20434 +#define SERVICE_ISDN_ANNEXC (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_ANNEXC)
20435 +#define SERVICE_ISDN_PROP (DSPDP_FEATURE_CODE & SERVICE_BIT_ISDN_PROP)
20436 +#define SERVICE_ISDN (SERVICE_ISDN_ANNEXB | SERVICE_ISDN_ANNEXC | SERVICE_ISDN_PROP)
20437 +
20438 +
20439 +//
20440 +// Backwards compatibility with old tokens
20441 +//
20442 +
20443 +#if (SERVICE_POTS)
20444 +#ifndef ISDN
20445 +#define ISDN 0
20446 +#endif
20447 +#endif
20448 +
20449 +#if (SERVICE_ISDN_ANNEXB | SERVICE_ISDN_PROP)
20450 +#ifndef ISDN
20451 +#define ISDN 1
20452 +#endif
20453 +#endif
20454 +
20455 +
20456 +//
20457 +//* ===========================================================================
20458 +// More Default settings
20459 +//* ===========================================================================
20460 +//
20461 +
20462 +//
20463 +// BEGIN Could automatically generate showdefs code
20464 +//
20465 +#ifndef AOC
20466 +#define AOC 1
20467 +#endif
20468 +#ifndef ARTT
20469 +#define ARTT 0
20470 +#endif
20471 +#ifndef ATMBERT
20472 +#define ATMBERT 0
20473 +#endif
20474 +// ATM_TC_HW and SWTC are mutually exclusive
20475 +#ifndef ATM_TC_HW
20476 +#define ATM_TC_HW 1
20477 +#endif
20478 +#if ATM_TC_HW
20479 +#ifndef ATMBERT_HW
20480 +#define ATMBERT_HW 1
20481 +#endif
20482 +#ifndef SWTC
20483 +#define SWTC 0
20484 +#endif
20485 +#else // else case for #if ATM_TC_HW
20486 +#ifndef ATMBERT_HW
20487 +#define ATMBERT_HW 0
20488 +#endif
20489 +#ifndef SWTC
20490 +#define SWTC 1
20491 +#endif
20492 +#endif // end of #if ATM_TC_HW
20493 +#ifndef ATM_TC_PATH1_ON
20494 +#define ATM_TC_PATH1_ON 0
20495 +#endif
20496 +#ifndef BITSWAP
20497 +#define BITSWAP 1
20498 +#endif
20499 +#ifndef COMB_LINEDIAG_ENABLE
20500 +#define COMB_LINEDIAG_ENABLE 0
20501 +#endif
20502 +#ifndef CODEC_EMU
20503 +#define CODEC_EMU 0
20504 +#endif
20505 +#ifndef CO_PROFILE
20506 +#define CO_PROFILE 1
20507 +#endif
20508 +#ifndef DDC
20509 +#define DDC 0
20510 +#endif
20511 +#ifndef DEBUG_ADSL2
20512 +#define DEBUG_ADSL2 0
20513 +#endif
20514 +#ifndef DEBUG_DUMP
20515 +#define DEBUG_DUMP 0
20516 +#endif
20517 +#ifndef DEBUG_LOG
20518 +#define DEBUG_LOG 0
20519 +#endif
20520 +#ifndef DEV_DEBUG
20521 +#define DEV_DEBUG 0
20522 +#endif
20523 +#ifndef DS_LOOP_BACK
20524 +#define DS_LOOP_BACK 0
20525 +#endif
20526 +#ifndef DS_RX_CODEWORD
20527 +#define DS_RX_CODEWORD 1
20528 +#endif
20529 +#ifndef LOOP_BACK_DEBUG
20530 +#define LOOP_BACK_DEBUG 0
20531 +#endif
20532 +#ifndef US_LOOP_BACK
20533 +#define US_LOOP_BACK 0
20534 +#endif
20535 +#ifndef DPLL_MODE
20536 +#define DPLL_MODE 0
20537 +#endif
20538 +#ifndef DSPBIOSII
20539 +#define DSPBIOSII 0
20540 +#endif
20541 +#ifndef DMT_BIS
20542 +#define DMT_BIS 1
20543 +#endif
20544 +#ifndef ADSL2_1BIT_TONE
20545 +#define ADSL2_1BIT_TONE 0
20546 +#endif
20547 +#ifndef ADSL2_BSWP
20548 +#define ADSL2_BSWP 1
20549 +#endif
20550 +#ifndef MEM_STR
20551 +#define MEM_STR 0
20552 +#endif
20553 +#ifndef DS_PWR_CUTBACK
20554 +#define DS_PWR_CUTBACK 0
20555 +#endif
20556 +#ifndef DUAL_TEQ
20557 +#define DUAL_TEQ 1
20558 +#endif
20559 +#ifndef EXTERNBERT
20560 +#define EXTERNBERT 0
20561 +#endif
20562 +#ifndef FPGA
20563 +#define FPGA 0
20564 +#endif
20565 +#ifndef INBAND
20566 +#define INBAND 0
20567 +#endif
20568 +#ifndef ISDN
20569 +#define ISDN 0
20570 +#endif
20571 +#ifndef ISDN_DEBUG
20572 +#define ISDN_DEBUG 0
20573 +#endif
20574 +#ifndef LINE_DIAG
20575 +#define LINE_DIAG 1
20576 +#endif
20577 +#ifndef LOOP_BACK_DEBUG
20578 +#define LOOP_BACK_DEBUG 0
20579 +#endif
20580 +#ifndef MANUFACTURING_TESTS
20581 +#define MANUFACTURING_TESTS 0
20582 +#endif
20583 +#ifndef MARGIN_DELTA_RETRAIN
20584 +#define MARGIN_DELTA_RETRAIN 1
20585 +#endif
20586 +#ifndef MEM_STR
20587 +#define MEM_STR 0
20588 +#endif
20589 +#ifndef MFGR_DIAG
20590 +#define MFGR_DIAG 0
20591 +#endif
20592 +#ifndef NLNOISEADJSNR
20593 +#define NLNOISEADJSNR 0
20594 +#endif
20595 +#ifndef NLNOISEADJSNR_EC
20596 +#define NLNOISEADJSNR_EC 0
20597 +#endif
20598 +#ifndef NTR_MODE
20599 +#define NTR_MODE 0
20600 +#endif
20601 +#ifndef OAM_EOC
20602 +#define OAM_EOC 1
20603 +#endif
20604 +#ifndef OLAYDP
20605 +#define OLAYDP 0
20606 +#endif
20607 +#ifndef OLAYDP_EMIF
20608 +#define OLAYDP_EMIF 0
20609 +#endif
20610 +#ifndef OLAYDP_2STEP
20611 +#define OLAYDP_2STEP 0
20612 +#endif
20613 +#ifndef OLAYDP_PCI
20614 +#define OLAYDP_PCI 0
20615 +#endif
20616 +#ifndef OUTBAND
20617 +#define OUTBAND 0
20618 +#endif
20619 +#ifndef OVHD_PMDTEST_PARA
20620 +#define OVHD_PMDTEST_PARA 0
20621 +#endif
20622 +#ifndef PERTONE_EQ
20623 +#define PERTONE_EQ 0
20624 +#endif
20625 +#ifndef PHY_EC_ENABLE
20626 +#define PHY_EC_ENABLE 1
20627 +#endif
20628 +#ifndef PHY_HYB_ENABLE
20629 +#define PHY_HYB_ENABLE 1
20630 +#endif
20631 +#ifndef PHY_NDIAG_ENABLE
20632 +#define PHY_NDIAG_ENABLE 0
20633 +#endif
20634 +#ifndef PHY_PATH_ENABLE
20635 +#define PHY_PATH_ENABLE 1
20636 +#endif
20637 +#ifndef PHY_TDW_ENABLE
20638 +#define PHY_TDW_ENABLE 0
20639 +#endif
20640 +#ifndef TC_ATM_PCIMASTER
20641 +#define TC_ATM_PCIMASTER 0
20642 +#endif
20643 +#ifndef SEPARATE_TX_RX_BUFFERS
20644 +#define SEPARATE_TX_RX_BUFFERS 0
20645 +#endif
20646 +#ifndef SHALF
20647 +#define SHALF 0
20648 +#endif
20649 +#ifndef SPECTRAL_SHAPING
20650 +#define SPECTRAL_SHAPING 1
20651 +#endif
20652 +#ifndef SNR_UPDATE
20653 +#define SNR_UPDATE 1
20654 +#endif
20655 +#ifndef TC_DEBUG
20656 +#define TC_DEBUG 0
20657 +#endif
20658 +#ifndef TC_LOOPBACK
20659 +#define TC_LOOPBACK 0
20660 +#endif
20661 +#ifndef TESTMODE
20662 +#define TESTMODE 0
20663 +#endif
20664 +#ifndef TRELLIS
20665 +#define TRELLIS 1
20666 +#endif
20667 +#ifndef TXDF2B_PROFILING
20668 +#if (SERVICE_POTS & (!MFGR_DIAG) & (CO_PROFILE))
20669 +#define TXDF2B_PROFILING 1
20670 +#else
20671 +#define TXDF2B_PROFILING 0
20672 +#endif
20673 +#endif
20674 +#ifndef US_CRC_RETRAIN
20675 +#define US_CRC_RETRAIN 1
20676 +#endif
20677 +#ifndef US_LOOP_BACK
20678 +#define US_LOOP_BACK 0
20679 +#endif
20680 +#ifndef USB
20681 +#define USB 0
20682 +#endif
20683 +#ifndef READSL2_ENABLE
20684 +#define READSL2_ENABLE 1
20685 +#endif
20686 +
20687 +// Interop tokens
20688 +#ifndef GHS_NON_STD_FIELD
20689 +#define GHS_NON_STD_FIELD 0
20690 +#endif
20691 +#ifndef LUCENT_ANYMEDIA_ENIATT_INTEROP
20692 +#define LUCENT_ANYMEDIA_ENIATT_INTEROP 0
20693 +#endif
20694 +
20695 +
20696 +//
20697 +// END Could automatically generate showdefs code
20698 +//
20699 +#if DSPDP_FEATURE_CODE
20700 +#else
20701 +// Unrecognized_suffix____check_spelling
20702 +#endif
20703 +//
20704 +// LNK_CMD is set when running CPP to generate lnk_cpe.cmd file
20705 +// -- the linker is not happy when it sees C code show up in the
20706 +// result!
20707 +//
20708 +#ifndef LNK_CMD
20709 +extern int compile_happy; // Keep the compiler from complaining about an empty file
20710 +#endif
20711 +
20712 +#endif
20713 +
20714 diff -urN linux.old/drivers/atm/sangam_atm/env_def_typedefs.h linux.dev/drivers/atm/sangam_atm/env_def_typedefs.h
20715 --- linux.old/drivers/atm/sangam_atm/env_def_typedefs.h 1970-01-01 01:00:00.000000000 +0100
20716 +++ linux.dev/drivers/atm/sangam_atm/env_def_typedefs.h 2005-08-23 04:46:50.104842632 +0200
20717 @@ -0,0 +1,228 @@
20718 +#ifndef __ENV_DEF_TYPEDEFS_H__
20719 +#define __ENV_DEF_TYPEDEFS_H__ 1
20720 +
20721 +/*******************************************************************************
20722 +* FILE PURPOSE: Define data types for C and TMS320C6x C compilers
20723 +********************************************************************************
20724 +*
20725 +* FILE NAME: dpsys_typedefs.h
20726 +*
20727 +* DESCRIPTION:
20728 +* This file contains the main typedefs that we need.
20729 +*
20730 +* HISTORY:
20731 +*
20732 +* 03/11/97 Bob Lee Created
20733 +* 03/13/97 Chishtie
20734 +* 03/14/97 Bob Lee Format change to meet "Engineering Model
20735 +* - System Architucture Specification"
20736 +* Rev AP3. Jan. 29, 1997
20737 +* 07/21/00 Barnett Moved many common typedefs from
20738 +* host i/f header file to here.
20739 +* 03/30/01 Barnett Mod's per driver team feedback.
20740 +* Some tokens cannot be def'ed
20741 +* if _WINDEF_ is def'ed.
20742 +* 04/05/01 Barnett Added DSPDP_ prefix to tokens that originate
20743 +* in the public interface.
20744 +* 06/01/01 J. Bergsagel Modified to add standard typedefs
20745 +* 07/25/01 J. Bergsagel Changed name from typedefs.h to dpsys_typedefs.h
20746 +* 07/30/01 J. Bergsagel Moved typedefs that were conflicting with Windows
20747 +* driver software to the "#ifndef _WINDEF_" section.
20748 +* 08/09/01 S. Yim Moved FALSE/TRUE definitions from ctl_interface_u.h
20749 +* (conflict with BIOS/std.h)
20750 +* 09/03/01 S. Yim Do not include typedef char and float if _STD defined
20751 +* (conflict with BIOS/std.h)
20752 +* 01/21/03 MCB Implemented Ax7 UNIT-MODULE modular software framework.
20753 +* 03/20/03 Mallesh Defined size of basic variables
20754 +* 03/27/03 F. Mujica Added SINT40 and UINT40 definitions.
20755 +*
20756 +* (C) Copyright Texas Instruments Inc. 1997-2001. All rights reserved.
20757 +*******************************************************************************/
20758 +
20759 +// Common type definitions
20760 +
20761 +// Basic constants needed everywhere
20762 +#ifndef STD_
20763 +#define FALSE 0
20764 +#define TRUE 1
20765 +#endif
20766 +
20767 +// Read-Write Data Types
20768 +typedef signed char SINT8; // Signed 8-bit integer (7-bit magnitude)
20769 +typedef unsigned char UINT8; // Unsigned 8-bit integer
20770 +typedef signed short SINT16; // Signed 16-bit integer (15-bit magnitude)
20771 +typedef unsigned short UINT16; // Unsigned 16-bit integer
20772 +typedef signed int SINT32; // Signed 32-bit integer (31-bit magnitude)
20773 +typedef unsigned int UINT32; // Unsigned 32-bit integer
20774 +typedef long signed int SINT40; // Long signed 40-bit integer
20775 +typedef long unsigned int UINT40; // Long unsigned 40-bit integer
20776 +
20777 +// All pointers are 32 bits long
20778 +typedef SINT8 *PSINT8; // Pointer to SINT8
20779 +typedef UINT8 *PUINT8; // Pointer to UINT8
20780 +typedef SINT16 *PSINT16; // Pointer to SINT16
20781 +typedef UINT16 *PUINT16; // Pointer to UINT16
20782 +typedef SINT32 *PSINT32; // Pointer to SINT32
20783 +typedef UINT32 *PUINT32; // Pointer to UINT32
20784 +
20785 +#define SIZEOF_SINT8 1
20786 +#define SIZEOF_UINT8 1
20787 +#define SIZEOF_SINT16 2
20788 +#define SIZEOF_UINT16 2
20789 +#define SIZEOF_SINT32 4
20790 +#define SIZEOF_UINT32 4
20791 +#define SIZEOF_SINT40 8
20792 +#define SIZEOF_UINT40 8
20793 +
20794 +// Size of Read-Write Data Types - in bytes
20795 +#define SIZEOF_char 1
20796 +#define SIZEOF_Int8 1
20797 +#define SIZEOF_UChar 1
20798 +#define SIZEOF_UInt8 1
20799 +#define SIZEOF_Float 4
20800 +#define SIZEOF_Double 8
20801 +#define SIZEOF_byte 1
20802 +
20803 +// Read-Only Data Types - should be only used for ROM code
20804 +typedef const char CharRom; // 8 bit signed character
20805 +typedef const signed char Int8Rom; // 8 bit signed integer
20806 +typedef const unsigned char UCharRom; // 8 bit unsigned character
20807 +typedef const unsigned char UInt8Rom; // 8 bit unsigned integer
20808 +typedef const float FloatRom; // IEEE 32-bit
20809 +typedef const double DoubleRom; // IEEE 64-bit
20810 +
20811 +#ifndef _WINDEF_
20812 +
20813 +// Read-Write Data Types
20814 +typedef signed char Int8; // 8 bit signed integer
20815 +typedef unsigned char UChar; // 8 bit unsigned character
20816 +typedef unsigned char UInt8; // 8 bit unsigned integer
20817 +#ifndef STD_
20818 +typedef char Char; // 8 bit signed character
20819 +typedef float Float; // IEEE 32-bit
20820 +#endif
20821 +typedef double Double; // IEEE 64-bit
20822 +typedef signed char byte; // 8 bit signed integer
20823 +
20824 +
20825 +// These typedefs collide with those in Win2k DDK inc\WINDEF.H
20826 +
20827 +// common type definition
20828 +typedef unsigned char BYTE; // 8-bit
20829 +typedef signed short SHORT; // 16-bit signed
20830 +typedef unsigned short WORD; // 16-bit
20831 +typedef unsigned int DWORD; // 32-bit, TI DSP has 40 bit longs
20832 +
20833 +// All pointers are 32 bits long
20834 +typedef BYTE *PBYTE; // pointer to 8 bit data
20835 +typedef unsigned char *PCHAR; // pointer to 8 bit data
20836 +typedef SHORT *PSHORT; // pointer to 16 bit data
20837 +typedef WORD *PWORD; // pointer to 16 bit data
20838 +typedef DWORD *PDWORD; // pointer to 32 bit data
20839 +
20840 +#endif // #ifndef _WINDEF_
20841 +
20842 +
20843 +#define SIZEOF_BYTE 1
20844 +#define SIZEOF_SHORT 2
20845 +#define SIZEOF_WORD 2
20846 +#define SIZEOF_DWORD 4
20847 +#define SIZEOF_PCHAR 4
20848 +#define SIZEOF_PWORD 4
20849 +#define SIZEOF_PDWORD 4
20850 +
20851 +// Size of Read-Only Data Types - in bytes
20852 +#define SIZEOF_CharRom 1
20853 +#define SIZEOF_Int8Rom 1
20854 +#define SIZEOF_UCharRom 1
20855 +#define SIZEOF_UInt8Rom 1
20856 +#define SIZEOF_FloatRom 4
20857 +#define SIZEOF_DoubleRom 8
20858 +
20859 +#define SIZEOF_complex_byte (2*SIZEOF_byte)
20860 +#define SIZEOF_PTR_complex_byte 4
20861 +typedef struct {
20862 + byte re;
20863 + byte im;
20864 +} complex_byte, *PTR_complex_byte;
20865 +
20866 +#define SIZEOF_complex_short 4
20867 +#define SIZEOF_PTR_complex_short 4
20868 +typedef struct {
20869 + short re;
20870 + short im;
20871 +} complex_short, *PTR_complex_short;
20872 +
20873 +#define SIZEOF_complex_int 8
20874 +#define SIZEOF_PTR_complex_int 4
20875 +typedef struct {
20876 + int re;
20877 + int im;
20878 +} complex_int, *PTR_complex_int;
20879 +
20880 +typedef struct {
20881 + int high;
20882 + unsigned int low;
20883 +} int64;
20884 +
20885 +typedef struct {
20886 + int64 real;
20887 + int64 imag;
20888 +} complex_int64;
20889 +
20890 +#define SIZEOF_PVOID 4
20891 +typedef void *PVOID; // pointer to void
20892 +
20893 +//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20894 +
20895 +#if defined(_TMS320C6X) // TMS320C6xx type definitions
20896 +
20897 +// Read-Write Data Types
20898 +typedef short Int16; // 16 bit signed integer
20899 +typedef unsigned short UInt16; // 16 bit unsigned integer
20900 +typedef int Int32; // 32 bit signed integer
20901 +typedef unsigned int UInt32; // 32 bit unsigned signed integer
20902 +typedef long Long40; // 40 bit signed integer
20903 +typedef unsigned long ULong40; // 40 bit unsigned signed integer
20904 +
20905 +// Size of Read-Write Data Types - in bytes
20906 +#define SIZEOF_Int16 2
20907 +#define SIZEOF_UInt16 2
20908 +#define SIZEOF_Int32 4
20909 +#define SIZEOF_UInt32 4
20910 +#define SIZEOF_Long40 5
20911 +#define SIZEOF_ULong40 5
20912 +
20913 +// Read-Only Data Types - should be only used for ROM code
20914 +typedef const short Int16Rom; // 16 bit signed integer
20915 +typedef const unsigned short UInt16Rom; // 16 bit unsigned integer
20916 +typedef const int Int32Rom; // 32 bit signed integer
20917 +typedef const unsigned int UInt32Rom; // 32 bit unsigned signed integer
20918 +typedef const long Long40Rom; // 40 bit signed integer
20919 +typedef const unsigned long ULong40Rom; // 40 bit unsigned signed integer
20920 +
20921 +// Size of Read-Only Data Types - in bytes
20922 +#define SIZEOF_Int16Rom 2
20923 +#define SIZEOF_UInt16Rom 2
20924 +#define SIZEOF_Int32Rom 4
20925 +#define SIZEOF_UInt32Rom 4
20926 +#define SIZEOF_Long40Rom 5
20927 +#define SIZEOF_ULong40Rom 5
20928 +
20929 +#else // 32 bits PC Host type definitions
20930 +
20931 +// Read-Write Data Types
20932 +typedef short Int16; // 16 bit signed integer
20933 +typedef unsigned short UInt16; // 16 bit unsigned integer
20934 +typedef int Int32; // 32 bit signed integer
20935 +typedef unsigned int UInt32; // 32 bit unsigned integer
20936 +
20937 +// Read-Only Data Types - should be only used for ROM code
20938 +typedef const short Int16Rom; // 16 bit signed integer
20939 +typedef const unsigned short UInt16Rom; // 16 bit unsigned integer
20940 +typedef const int Int32Rom; // 32 bit signed integer
20941 +typedef const unsigned int UInt32Rom; // 32 bit unsigned integer
20942 +
20943 +#endif
20944 +
20945 +#endif
20946 diff -urN linux.old/drivers/atm/sangam_atm/Makefile linux.dev/drivers/atm/sangam_atm/Makefile
20947 --- linux.old/drivers/atm/sangam_atm/Makefile 1970-01-01 01:00:00.000000000 +0100
20948 +++ linux.dev/drivers/atm/sangam_atm/Makefile 2005-08-23 04:46:50.104842632 +0200
20949 @@ -0,0 +1,35 @@
20950 +# File: drivers/net/avalanche_cpmac/Makefile
20951 +#
20952 +# Makefile for the Linux network (CPMAC) device drivers.
20953 +#
20954 +
20955 +
20956 +O_TARGET := tiatm.o
20957 +obj-$(CONFIG_MIPS_SANGAM_ATM) += tiatm.o
20958 +list-multi := tiatm.o
20959 +
20960 +tiatm-objs := tn7atm.o tn7dsl.o tn7sar.o dsl_hal_api.o dsl_hal_support.o cpsar.o aal5sar.o
20961 +
20962 +EXTRA_CFLAGS += -DEL -I$(TOPDIR)/drivers/atm/sangam_atm -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
20963 +
20964 +ifeq ($(ANNEX),B)
20965 +EXTRA_CFLAGS += -DANNEX_B -DB
20966 +else
20967 +ifeq ($(ANNEX),C)
20968 +EXTRA_CFLAGS += -DANNEX_C -DC
20969 +else
20970 +EXTRA_CFLAGS += -DANNEX_A -DP
20971 +endif
20972 +endif
20973 +
20974 +
20975 +include $(TOPDIR)/Rules.make
20976 +
20977 +tiatm.o: $(tiatm-objs)
20978 + $(LD) -r -o $@ $(tiatm-objs)
20979 +
20980 +#avalanche_cpmac.o: $(avalanche_cpmac-objs)
20981 +# $(LD) -r -o $@ $(avalanche_cpmac-objs)
20982 +
20983 +clean:
20984 + rm -f core *.o *.a *.s
20985 diff -urN linux.old/drivers/atm/sangam_atm/queue.h linux.dev/drivers/atm/sangam_atm/queue.h
20986 --- linux.old/drivers/atm/sangam_atm/queue.h 1970-01-01 01:00:00.000000000 +0100
20987 +++ linux.dev/drivers/atm/sangam_atm/queue.h 2005-08-23 04:46:50.104842632 +0200
20988 @@ -0,0 +1,167 @@
20989 +
20990 +#if !defined( __QUEUE_H__ )
20991 +#define __QUEUE_H__
20992 +
20993 +typedef spinlock_t OS_SPIN_LOCK;
20994 +#define osFreeSpinLock(pLock) while(0)
20995 +void osAcquireSpinLock(OS_SPIN_LOCK *pLock);
20996 +void osReleaseSpinLock(OS_SPIN_LOCK *pLock);
20997 +void osAllocateSpinLock(OS_SPIN_LOCK *pLock);
20998 +
20999 +//#define osAcquireSpinLock(pLock) spin_lock(pLock)
21000 +//#define osReleaseSpinLock(pLock) spin_unlock(pLock)
21001 +//#define osAllocateSpinLock(pLock) spin_lock_init(pLock)
21002 +
21003 +
21004 +typedef struct _TI_LIST_ENTRY {
21005 + struct _TI_LIST_ENTRY *Flink;
21006 + struct _TI_LIST_ENTRY *Blink;
21007 +} TI_LIST_ENTRY, *PTI_LIST_ENTRY, TQE, *PTQE;
21008 +
21009 +typedef struct _TIATM_LIST_ENTRY
21010 +{
21011 + TI_LIST_ENTRY Link;
21012 +} TIATM_LIST_ENTRY, *PTIATM_LIST_ENTRY;
21013 +
21014 +//-------------------------------------------------------------------------
21015 +// QueueInitList -- Macro which will initialize a queue to NULL.
21016 +//-------------------------------------------------------------------------
21017 +#define QueueInitList(_L) (_L)->Link.Flink = (_L)->Link.Blink = (PTI_LIST_ENTRY)0;
21018 +
21019 +//-------------------------------------------------------------------------
21020 +// QueueEmpty -- Macro which checks to see if a queue is empty.
21021 +//-------------------------------------------------------------------------
21022 +#define QueueEmpty(_L) (QueueGetHead((_L)) == (PTIATM_LIST_ENTRY)0)
21023 +
21024 +//-------------------------------------------------------------------------
21025 +// QueueGetHead -- Macro which returns the head of the queue, but does not
21026 +// remove the head from the queue.
21027 +//-------------------------------------------------------------------------
21028 +#define QueueGetHead(_L) ((PTIATM_LIST_ENTRY)((_L)->Link.Flink))
21029 +
21030 +#define QueueGetNext(Elem) ((PTIATM_LIST_ENTRY)((Elem)->Link.Flink))
21031 +
21032 +//-------------------------------------------------------------------------
21033 +// QueuePushHead -- Macro which puts an element at the head of the queue.
21034 +//-------------------------------------------------------------------------
21035 +#define QueuePushHead(_L,_E) \
21036 + if (!((_E)->Link.Flink = (_L)->Link.Flink)) \
21037 + { \
21038 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21039 + } \
21040 +(_L)->Link.Flink = (PTI_LIST_ENTRY)(_E);
21041 +
21042 +//-------------------------------------------------------------------------
21043 +// QueueRemoveHead -- Macro which removes the head of the head of queue.
21044 +//-------------------------------------------------------------------------
21045 +#define QueueRemoveHead(_L) \
21046 +{ \
21047 + PTIATM_LIST_ENTRY ListElem; \
21048 + if (ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink) \
21049 + { \
21050 + if(!((_L)->Link.Flink = ListElem->Link.Flink)) \
21051 + (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21052 + } \
21053 +}
21054 +
21055 +//-------------------------------------------------------------------------
21056 +// QueuePutTail -- Macro which puts an element at the tail (end) of the queue.
21057 +//-------------------------------------------------------------------------
21058 +#define QueuePutTail(_L,_E) \
21059 +{ \
21060 + if ((_L)->Link.Blink) \
21061 + { \
21062 + ((PTIATM_LIST_ENTRY)(_L)->Link.Blink)->Link.Flink = (PTI_LIST_ENTRY)(_E); \
21063 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21064 + } \
21065 + else \
21066 + { \
21067 + (_L)->Link.Flink = \
21068 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21069 + } \
21070 + (_E)->Link.Flink = (PTI_LIST_ENTRY)0; \
21071 +}
21072 +
21073 +//-------------------------------------------------------------------------
21074 +// QueuePutTailWithLock -- Macro which puts an element at the tail (end) of
21075 +// the queue, using spin lock.
21076 +//-------------------------------------------------------------------------
21077 +#define QueuePutTailWithLock(_L,_E, pLock) \
21078 +{ \
21079 + osAcquireSpinLock(pLock); \
21080 + if ((_L)->Link.Blink) \
21081 + { \
21082 + ((PTIATM_LIST_ENTRY)(_L)->Link.Blink)->Link.Flink = (PTI_LIST_ENTRY)(_E); \
21083 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21084 + } \
21085 + else \
21086 + { \
21087 + (_L)->Link.Flink = \
21088 + (_L)->Link.Blink = (PTI_LIST_ENTRY)(_E); \
21089 + } \
21090 + (_E)->Link.Flink = (PTI_LIST_ENTRY)0; \
21091 + osReleaseSpinLock(pLock); \
21092 +}
21093 +
21094 +//-------------------------------------------------------------------------
21095 +// QueueGetTail -- Macro which returns the tail of the queue, but does not
21096 +// remove the tail from the queue.
21097 +//-------------------------------------------------------------------------
21098 +#define QueueGetTail(_L) ((PTIATM_LIST_ENTRY)((_L)->Link.Blink))
21099 +
21100 +//-------------------------------------------------------------------------
21101 +// QueuePopHead -- Macro which will pop the head off of a queue (list), and
21102 +// return it (this differs only from queueremovehead only in
21103 +// the 1st line)
21104 +//-------------------------------------------------------------------------
21105 +#define QueuePopHead(_L) \
21106 +(PTIATM_LIST_ENTRY) (_L)->Link.Flink; QueueRemoveHead(_L);
21107 +
21108 +#define QueueRemoveTail(_L) \
21109 +{ \
21110 + PTIATM_LIST_ENTRY ListElem; \
21111 + ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink; \
21112 + if(ListElem == (PTIATM_LIST_ENTRY)(_L)->Link.Blink) \
21113 + { \
21114 + (_L)->Link.Flink = (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21115 + } \
21116 + else \
21117 + { \
21118 + while(ListElem->Link.Flink != (PTI_LIST_ENTRY)(_L)->Link.Blink) \
21119 + { \
21120 + ListElem = (PTIATM_LIST_ENTRY)ListElem->Link.Flink; \
21121 + } \
21122 + (_L)->Link.Blink = (PTI_LIST_ENTRY) ListElem; \
21123 + ListElem->Link.Flink = (PTI_LIST_ENTRY)0; \
21124 + } \
21125 +}
21126 +
21127 +#define QueueRemoveItem(_L, Elem) \
21128 +{ \
21129 + PTIATM_LIST_ENTRY ListElem; \
21130 + ListElem = (PTIATM_LIST_ENTRY)(_L)->Link.Flink; \
21131 + if(ListElem == Elem) \
21132 + { \
21133 + QueueRemoveHead(_L); \
21134 + } \
21135 + else \
21136 + { \
21137 + while(ListElem) \
21138 + { \
21139 + if(Elem == (PTIATM_LIST_ENTRY)ListElem->Link.Flink) \
21140 + { \
21141 + ListElem->Link.Flink = ((PTIATM_LIST_ENTRY)Elem)->Link.Flink; \
21142 + if(Elem == (PTIATM_LIST_ENTRY)(_L)->Link.Blink) \
21143 + (_L)->Link.Blink = (PTI_LIST_ENTRY) 0; \
21144 + break; \
21145 + } \
21146 + ListElem = (PTIATM_LIST_ENTRY)ListElem->Link.Flink; \
21147 + }\
21148 + } \
21149 + ((PTIATM_LIST_ENTRY)Elem)->Link.Flink = (PTI_LIST_ENTRY) 0; \
21150 +}
21151 +
21152 +#define QueuePopTail(_L) \
21153 +((PTIATM_LIST_ENTRY)((_L)->Link.Blink)); QueueRemoveTail(_L);
21154 +
21155 +#endif
21156 diff -urN linux.old/drivers/atm/sangam_atm/release.txt linux.dev/drivers/atm/sangam_atm/release.txt
21157 --- linux.old/drivers/atm/sangam_atm/release.txt 1970-01-01 01:00:00.000000000 +0100
21158 +++ linux.dev/drivers/atm/sangam_atm/release.txt 2005-08-23 04:46:50.104842632 +0200
21159 @@ -0,0 +1,118 @@
21160 +This is release notes for AR7 Linux ATM driver.
21161 +
21162 +version 04.02.04.00
21163 +-------------------
21164 +
21165 +1. Corrected the conditional logic from logical AND to logical OR in the case
21166 + of check for DSL line down condition. This is to fix PPPoA crashing
21167 + problem when DSL line is unplugged.
21168 +
21169 +version 04.02.03.00
21170 +-------------------
21171 +1. Changed overlay page to static allocation.
21172 +2. Added flag to stop TX during channel closing.
21173 +3. Changed DMA memory allocation back to "GFP_ATOMIC" flag.
21174 +
21175 +version 04.02.02.00
21176 +-------------------
21177 +1. Changed DMA memory allocation from "GFP_ATOMIC" to "GFP_KERNEL" flag.
21178 +2. Added "DoMask" setting for VBR channel setup.
21179 +
21180 +version 04.02.01.01
21181 +-------------------
21182 +1. Modified priority check scheme per SPTC request.
21183 +
21184 +Version 04.02.01.00
21185 +-------------------
21186 +1. Add check to skb->priority to place packets to either normal or priority queue.
21187 +2. Add spin lock to increment and decrement of queued buffer number.
21188 +
21189 +Version 04.02.00.00
21190 +-------------------
21191 +Features:
21192 +1. Add MBS and CDVT QoS support for ATM driver.
21193 +2. Add "stop/start queue" for ToS application.
21194 +3. Add Showtime margin retrain based on EOC message.
21195 +4. Add EOC vendor ID customalization logic for Annex B.
21196 +5. Supports D3 datapump.
21197 +
21198 +Version 04.01.00.00
21199 +-------------------
21200 +Re-release of 04.00.07.00 for D1.1 datapump.
21201 +
21202 +Version 04.00.07.00
21203 +-------------------
21204 +Features:
21205 +1. Add marging retrain capability by setting following Adam2 Env.
21206 + setenv enable_margin_retrain 1
21207 + setenv margin_threshold xx, xx is in half db, i.e., 10 means 5db.
21208 +
21209 +Bugfixs:
21210 +1. New PDSP firmware that fix the F5 OAM cell loopback probelm in Cisco DSLAM.
21211 +
21212 +Version 04.00.06.00
21213 +-------------------
21214 +1. ATM interrupt pacing is defauted to 2 interrupts/s.
21215 +2. Rx Service MAX changed ftom 16 to 8.
21216 +
21217 +Version 04.00.05.00
21218 +-------------------
21219 +Features:
21220 +1. Add Adam2 env to disable the TurboDSL by entering "setenv TurboDSL 0".
21221 +2. Add ability to set interrupt pacing for ATM driver.
21222 +
21223 +Bugfixs:
21224 +1. Fixed the RFC2684 and CLIP problems for Cisco router.
21225 +2. Fixed LED blinking problem when DSL cable is unplugged.
21226 +3. Fixed problem that "selected mode" is not updated.
21227 +
21228 +Version 04.00.04.00
21229 +-------------------
21230 +Features:
21231 +1. Added feature so OAM F5 ping will not require a corresponding PVC channel to
21232 + be setup.
21233 +2. Added timeout value for F5 OAM ping. The new command are "exxxpyyycdzzzt" for
21234 + end-to-end and "sxxxpyyycdzzzt" for segment. "zzz" is timeout value in milli-second.
21235 +3. Added proc entry "avsar_pvc_table" to record received VPIs and VCIs. The format is
21236 + vpi,vci
21237 + seperated by new line. To search for PVCs, an application can do the following.
21238 + i) Send a (or several) F5 OAM cell on a VPI/VPI pairs with command
21239 + echo exxxpyyycd2t > /proc/sys/dev/dslmod
21240 + ii) Wait >2ms or poll proc entry /proc/avalanche/avsar_oam_ping until the result
21241 + indicates a failure. (It will be failed all the time with 2ms timeout.)
21242 + iii) Repeat above two steps for new VPI/VCI pairs.
21243 + iv) Check proc entry /proc/avalanche/avsar_pvc_table any time for PVCs that responded.
21244 +
21245 +Version 04.00.03.00
21246 +-------------------
21247 +Bug Fixs:
21248 +1. Fixed bug that caused crash when phone cable is unplugged.
21249 +2. Fixed LED operation for "flexible LEDs".
21250 +
21251 +Features:
21252 +1. Added the proc entry "avsar_oam_ping" to signal oam ping result.
21253 + 0 - failed; 1 - success; 2 - in progress.
21254 +2. Added oam ping timeout env variable. The timeout can be specified by
21255 + adding Adam2 env "oam_lb_timeout". The value is in millisecond.
21256 +
21257 +Version 04.00.02.00
21258 +-------------------
21259 +1. The driver uses hardware queue for Turbo DSL.
21260 +2. Added new modem statistics listed below:
21261 + US and DS TX powers, atuc Vendor ID and revision, training mode selected,
21262 + Hybrid Selected, and etc.
21263 +
21264 +Version 04.00.01.00
21265 +-------------------
21266 +
21267 +1. This driver release contains all the features that exists in AR5 Linux ATM
21268 + 3.1 driver.
21269 +
21270 +2. F4 OAM generation is added.
21271 +
21272 +3. Software queuing is used for TURBO DSL.
21273 +
21274 +4. Porting guide "is created. Please look into that document for detailed
21275 + information.
21276 +
21277 +
21278 diff -urN linux.old/drivers/atm/sangam_atm/syssw_version.h linux.dev/drivers/atm/sangam_atm/syssw_version.h
21279 --- linux.old/drivers/atm/sangam_atm/syssw_version.h 1970-01-01 01:00:00.000000000 +0100
21280 +++ linux.dev/drivers/atm/sangam_atm/syssw_version.h 2005-08-23 04:46:50.105842480 +0200
21281 @@ -0,0 +1,94 @@
21282 +#ifndef __SYSSW_VERSION_H__
21283 +#define __SYSSW_VERSION_H__ 1
21284 +
21285 +/*******************************************************************************
21286 +* FILE PURPOSE: DSL Driver API functions for Sangam
21287 +*
21288 +********************************************************************************
21289 +* FILE NAME: dsl_hal_basicapi.c
21290 +*
21291 +* DESCRIPTION:
21292 +* Contains basic DSL HAL APIs for Sangam
21293 +*
21294 +* (C) Copyright 2003-04, Texas Instruments, Inc.
21295 +* History
21296 +* Date Version Notes
21297 +* 14May03 0.00.00 RamP Original Version Created
21298 +* 14May03 0.00.01 RamP Initial Rev numbers inserted
21299 +* 14May03 0.00.02 RamP Bumped version numbers for Dsl Hal
21300 +* & dhalapp for alpha plus
21301 +* 19May03 0.00.03 MCB Bumped dslhal version number
21302 +* because of dependant changes
21303 +* wrt. linux-nsp atm drivers.
21304 +* 22May03 0.00.04 RamP Bumped dslhal & dhalapp buildnum
21305 +* for inner/outer pair & DGASP code
21306 +* 06Jun03 0.00.05 RamP Bumped up buildnum for LED, STM,
21307 +* interrupt processing, statistics
21308 +* and other pre-beta features
21309 +* 09Jun03 0.00.06 JEB Fixed error in DHALAPP bugfix/buildnum
21310 +* 09Jun03 0.00.07 RamP Bumped up buildnum for incremental
21311 +* changes to apis, statistics, memory
21312 +* fixes, parameter configurations
21313 +* 11Jun03 0.00.08 RamP Bumped up buildnum for Co profile
21314 +* free memory fix
21315 +* 12Jun03 0.00.09 JEB Bumped version numbers for AR7 1.00 Beta
21316 +* 02Jul03 0.00.10 ZT Bumped HAL version for overlay page
21317 +* 18Jul03 0.00.11 RamP Bumped HAL version for analog diags
21318 +* 22Jul03 0.00.12 JEB Bumped DHALAPP buildnum for analog diags
21319 +* 31Jul03 0.00.13 RamP Bumped HAL version for engr. drop
21320 +* 04Aug03 0.00.14 JEB Bumped HAL version buildnum for CHECKPOINT65 changes
21321 +* Bumped LINUX version buildnum for CHECKPOINT65 changes
21322 +* 06Aug03 0.00.15 MCB Bumped all version numbers in prep for AR7 1.0 R2 release for POTS.
21323 +* 13Aug03 0.00.16 MCB Set rev id's for D3/R1.1 (ADSL2).
21324 +* 21Aug03 0.00.17 JEB Bumped up build numbers for merge of code additions from D1
21325 +* 26Sep03 0.00.18 JEB Set rev id's for another D3/R1 (ADSL2).
21326 +* 14Oct03 0.00.19 JEB Bumped Linux minor number and reset bugfix number for release.
21327 +* Bumped build numbers on DSLHAL and DHALAPP for this checkpoint.
21328 +* 14Oct03 0.00.20 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT15.
21329 +* 21Oct03 0.00.21 JEB Bumped build number on DSLHAL for CHECKPOINT16.
21330 +* 22Oct03 0.00.22 MCB Bumped all version numbers in support of D3R1 release.
21331 +* 27Oct03 0.00.23 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT19.
21332 +* Updated version for DSLAGENT to be 02.01.00.01 for ACT 2.1 R0.
21333 +* 30Oct03 0.00.24 JEB Bumped bugfix number on LINUXATM Version for next release.
21334 +* Bumped build numbers on DSLHAL and DHALAPP
21335 +* 31Oct03 0.00.25 MCB Bumped all version numbers in support of D3R2 release.
21336 +* 14Nov03 0.00.26 JEB Bumped build numbers on DSLHAL and DHALAPP
21337 +* Changed version for DSLAGENT to be 02.00.01.01 for an ACT 2.0 R0
21338 +* 20Nov03 0.00.27 JEB Bumped build number on DSLHAL.
21339 +* Changed version for DSLAGENT to be 02.00.02.00 for the next ACT 2.0 R2
21340 +* 21Nov03 0.00.28 MCB Bumped all version numbers in support of D3R2 release.
21341 +* 21Nov03 0.00.29 JEB Bumped build numbers on DSLHAL and DHALAPP for D3-R0 drop on 11/21.
21342 +* 16Dec03 0.00.30 JEB Bumped build numbers on DSLHAL and DHALAPP for CHECKPOINT31.
21343 +* 21Dec03 0.00.31 MCB Bumped all version numbers in support of D3R2 release.
21344 +* 05Jan04 0.00.32 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 34.
21345 +* 15Jan04 0.00.33 JEB Bumped build numbers on DSLHAL and Linux ATM for CHECKPOINT 36.
21346 +* 26Jan04 0.00.34 JEB Changed Linux ATM version number to be 04.02.03.00.
21347 +* 27Jan04 0.00.35 MCB Bumped all version numbers in support of D3R2 release.
21348 +*******************************************************************************/
21349 +
21350 +/* Dsl Hal API Version Numbers */
21351 +#define DSLHAL_VERSION_MAJOR 03
21352 +#define DSLHAL_VERSION_MINOR 00
21353 +#define DSLHAL_VERSION_BUGFIX 06
21354 +#define DSLHAL_VERSION_BUILDNUM 00
21355 +#define DSLHAL_VERSION_TIMESTAMP 00
21356 +
21357 +/* dhalapp Adam2 Application Version Numbers */
21358 +#define DHALAPP_VERSION_MAJOR 03
21359 +#define DHALAPP_VERSION_MINOR 00
21360 +#define DHALAPP_VERSION_BUGFIX 05
21361 +#define DHALAPP_VERSION_BUILDNUM 00
21362 +
21363 +/* Linux ATM Driver Version Numbers */
21364 +#define LINUXATM_VERSION_MAJOR 04
21365 +#define LINUXATM_VERSION_MINOR 02
21366 +#define LINUXATM_VERSION_BUGFIX 04
21367 +#define LINUXATM_VERSION_BUILDNUM 00
21368 +
21369 +/* DSL Agent Version Numbers */
21370 +#define DSLAGENT_VERSION_MAJOR 02
21371 +#define DSLAGENT_VERSION_MINOR 00
21372 +#define DSLAGENT_VERSION_BUGFIX 02
21373 +#define DSLAGENT_VERSION_BUILDNUM 00
21374 +
21375 +#endif /* pairs with #ifndef __SYSSW_VERSION_H__ */
21376 diff -urN linux.old/drivers/atm/sangam_atm/tn7api.h linux.dev/drivers/atm/sangam_atm/tn7api.h
21377 --- linux.old/drivers/atm/sangam_atm/tn7api.h 1970-01-01 01:00:00.000000000 +0100
21378 +++ linux.dev/drivers/atm/sangam_atm/tn7api.h 2005-08-23 04:46:50.105842480 +0200
21379 @@ -0,0 +1,54 @@
21380 +/*
21381 + * Tnetd73xx ATM driver.
21382 + * by Zhicheng Tang, ztang@ti.com
21383 + * 2000 (c) Texas Instruments Inc.
21384 + *
21385 + *
21386 +*/
21387 +
21388 +#ifndef __SAPI_H
21389 +#define __SAPI_H
21390 +
21391 +/* tn7atm.c */
21392 +void xdump(unsigned char *buff, int len, int debugLev);
21393 +int tn7atm_receive(void *os_dev, int ch, unsigned int packet_size, void *os_receive_info, void *data);
21394 +void *tn7atm_allocate_rx_skb(void *os_dev, void **os_receive_info, unsigned int size);
21395 +void tn7atm_free_rx_skb(void *skb);
21396 +void tn7atm_sarhal_isr_register(void *os_dev, void *hal_isr, int interrupt_num);
21397 +int tn7atm_send_complete(void *osSendInfo);
21398 +int tn7atm_device_connect_status(void *priv, int state);
21399 +int tn7atm_lut_find(short vpi, int vci);
21400 +
21401 +/* tn7dsl.h */
21402 +void tn7dsl_exit(void);
21403 +int tn7dsl_init(void *priv);
21404 +int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21405 +int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21406 +int tn7dsl_handle_interrupt(void);
21407 +void dprintf( int uDbgLevel, char * szFmt, ...);
21408 +void tn7dsl_dslmod_sysctl_register(void);
21409 +void tn7dsl_dslmod_sysctl_unregister(void);
21410 +int tn7dsl_get_dslhal_version(char *pVer);
21411 +int tn7dsl_get_dsp_version(char *pVer);
21412 +
21413 +int os_atoi(const char *pStr);
21414 +int os_atoh(const char *pStr);
21415 +unsigned long os_atoul(const char *pStr);
21416 +
21417 +/* tn7sar.c */
21418 +int tn7sar_activate_vc(Tn7AtmPrivate *priv, short vpi, int vci, int pcr, int scr, int mbs, int cdvt, int chan, int qos);
21419 +int tn7sar_init(struct atm_dev *dev, Tn7AtmPrivate *priv);
21420 +int tn7sar_register_interrupt_handle(void *os_dev, void *hal_isr, int *interrupt_num);
21421 +void tn7sar_exit(struct atm_dev *dev, Tn7AtmPrivate *priv);
21422 +int tn7sar_deactivate_vc(Tn7AtmPrivate *priv, int chan);
21423 +int tn7sar_handle_interrupt(struct atm_dev *dev, Tn7AtmPrivate *priv);
21424 +int tn7sar_send_packet(Tn7AtmPrivate *priv, int chan, void *new_skb, void *data,unsigned int len, int priority);
21425 +void tn7sar_get_sar_version(Tn7AtmPrivate *priv, char **pVer);
21426 +int tn7sar_get_near_end_loopback_count(unsigned int *pF4count, unsigned int *pF5count);
21427 +int tn7sar_oam_generation(void *privContext, int chan, int type, int vpi, int vci, int timeout);
21428 +int tn7sar_get_stats(void *priv1);
21429 +int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21430 +void tn7sar_get_sar_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls);
21431 +int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21432 +int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21433 +#endif
21434 diff -urN linux.old/drivers/atm/sangam_atm/tn7atm.c linux.dev/drivers/atm/sangam_atm/tn7atm.c
21435 --- linux.old/drivers/atm/sangam_atm/tn7atm.c 2005-08-28 01:52:26.000000000 -0600
21436 +++ linux.dev/drivers/atm/sangam_atm/tn7atm.c 2005-08-28 02:08:07.000000000 -0600
21437 @@ -0,0 +1,1233 @@
21438 +/*
21439 + * tn7.c
21440 + * Linux atm module implementation.
21441 + * Zhicheng Tang 01/08/2003
21442 + * 2003 (c) Texas Instruments Inc.
21443 + *
21444 + *
21445 +*/
21446 +
21447 +#include <linux/config.h>
21448 +#include <linux/kernel.h>
21449 +#include <linux/module.h>
21450 +#include <linux/init.h>
21451 +#include <linux/atmdev.h>
21452 +#include <linux/delay.h>
21453 +#include <linux/spinlock.h>
21454 +#include <linux/smp_lock.h>
21455 +#include <asm/io.h>
21456 +#include <asm/mips-boards/prom.h>
21457 +#include <linux/proc_fs.h>
21458 +#include <linux/string.h>
21459 +#include <linux/ctype.h>
21460 +#include "tn7atm.h"
21461 +#include "tn7api.h"
21462 +#include "syssw_version.h"
21463 +
21464 +#ifdef CONFIG_LED_MODULE
21465 +#include <asm/ar7/ledapp.h>
21466 +#endif
21467 +#include <asm/ar7/avalanche_intc.h>
21468 +
21469 +#ifdef MODULE
21470 +MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
21471 +MODULE_AUTHOR ("Zhicheng Tang");
21472 +#endif
21473 +
21474 +/* Version Information */
21475 +//static char atm_version[] ="1.0.0.1";
21476 +
21477 +#define TRUE 1
21478 +#define FALSE 0
21479 +
21480 +#define STOP_EMPTY_BUFF 2
21481 +#define START_EMPTY_BUFF 3
21482 +/* externs */
21483 +
21484 +/*end of externs */
21485 +
21486 +#define tn7atm_kfree_skb(x) dev_kfree_skb(x)
21487 +
21488 +/* prototypes */
21489 +int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
21490 +
21491 +void tn7atm_close (struct atm_vcc *vcc);
21492 +
21493 +static int tn7atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg);
21494 +
21495 +int tn7atm_send (struct atm_vcc *vcc, struct sk_buff *skb);
21496 +
21497 +static int tn7atm_change_qos (struct atm_vcc *vcc, struct atm_qos *qos,int flags);
21498 +
21499 +static int tn7atm_detect(void);
21500 +static int tn7atm_init(struct atm_dev* dev);
21501 +//static int tn7atm_reset(void);
21502 +static int tn7atm_irq_request(struct atm_dev* dev);
21503 +static int tn7atm_proc_version(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21504 +static void tn7atm_exit(void);
21505 +static int tn7atm_proc_channels(char* buf, char **start, off_t offset, int count,int *eof, void *data);
21506 +static int tn7atm_proc_private(char* buf, char **start, off_t offset, int count,int *eof,void *data);
21507 +//static void tn7atm_free_packet(void *vcc1, void *priv, void *skb1);
21508 +static int tn7atm_queue_packet_to_sar(void *vcc1, void *skb1);
21509 +
21510 +#include "turbodsl.c"
21511 +
21512 +/* ATM device operations */
21513 +
21514 +struct atm_dev *mydev;
21515 +
21516 +static const struct atmdev_ops tn7atm_ops = {
21517 + open: tn7atm_open,
21518 + close: tn7atm_close,
21519 + ioctl: tn7atm_ioctl,
21520 + getsockopt: NULL,
21521 + setsockopt: NULL,
21522 + send: tn7atm_send,
21523 + sg_send: NULL,
21524 + phy_put: NULL,
21525 + phy_get: NULL,
21526 + change_qos: tn7atm_change_qos,
21527 +};
21528 +
21529 +
21530 +int __guDbgLevel = 1;
21531 +
21532 +
21533 +void xdump(unsigned char *buff, int len, int debugLev)
21534 +{
21535 +#ifdef DEBUG_BUILD
21536 + int i, j;
21537 + if( __guDbgLevel < debugLev)
21538 + return;
21539 +
21540 + j=0;
21541 + for(i=0;i<len;i++)
21542 + {
21543 + printk("%02x ", buff[i]);
21544 + j++;
21545 + if(j==8)
21546 + {
21547 + j=0;
21548 + printk("\n");
21549 + }
21550 + }
21551 + printk("\n");
21552 +#endif
21553 +}
21554 +
21555 +
21556 +#if 0 /* by nbd */
21557 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21558 + *
21559 + * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
21560 + *
21561 + * Description: retrieve VPI/VCI for connection
21562 + *
21563 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21564 +static int
21565 +tn7atm_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
21566 +{
21567 + struct atm_vcc* walk;
21568 +
21569 + // printk(tn7 "tn7atm_walk_vccs\n");
21570 + /* find a free VPI */
21571 + if (*vpi == ATM_VPI_ANY) {
21572 +
21573 + for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next) {
21574 +
21575 + if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
21576 + (*vpi)++;
21577 + walk = vcc->dev->vccs;
21578 + }
21579 + }
21580 + }
21581 +
21582 + /* find a free VCI */
21583 + if (*vci == ATM_VCI_ANY) {
21584 +
21585 + for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk; walk = walk->next) {
21586 +
21587 + if ((walk->vpi = *vpi) && (walk->vci == *vci)) {
21588 + *vci = walk->vci + 1;
21589 + walk = vcc->dev->vccs;
21590 + }
21591 + }
21592 + }
21593 +
21594 + return 0;
21595 +}
21596 +#endif
21597 +
21598 +
21599 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21600 + *
21601 + * Function: int tn7atm_sar_irq(void)
21602 + *
21603 + * Description: tnetd73xx SAR interrupt.
21604 + *
21605 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21606 +static void
21607 +tn7atm_sar_irq(int irq , void *voiddev , struct pt_regs *regs)
21608 +{
21609 + struct atm_dev *atmdev;
21610 + Tn7AtmPrivate *priv;
21611 +
21612 + dprintf(6, "tn7atm_sar_irq\n");
21613 + atmdev = (struct atm_dev *) voiddev;
21614 + priv = (Tn7AtmPrivate *)atmdev->dev_data;
21615 +
21616 + tn7sar_handle_interrupt(atmdev, priv);
21617 +
21618 + dprintf(6, "Leaving tn7atm_sar_irq\n");
21619 +}
21620 +
21621 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21622 + *
21623 + * Function: int tn7atm_dsl_irq(void)
21624 + *
21625 + * Description: tnetd73xx DSL interrupt.
21626 + *
21627 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
21628 +static void
21629 +tn7atm_dsl_irq(int irq , void *voiddev , struct pt_regs *regs)
21630 +{
21631 + struct atm_dev *atmdev;
21632 + Tn7AtmPrivate *priv;
21633 +
21634 + dprintf(4, "tn7atm_dsl_irq\n");
21635 + atmdev = (struct atm_dev *) voiddev;
21636 + priv = (Tn7AtmPrivate *)atmdev->dev_data;
21637 +
21638 + tn7dsl_handle_interrupt();
21639 +
21640 + dprintf(4, "Leaving tn7atm_dsl_irq\n");
21641 +}
21642 +
21643 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21644 + *
21645 + * Function: int tn7atm_Inittxcomp(struct tn7* tn7)
21646 + *
21647 + * Description: Initialize Interrupt handler
21648 + *
21649 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21650 +static int __init
21651 +tn7atm_irq_request (struct atm_dev *dev)
21652 +{
21653 + Tn7AtmPrivate *priv;
21654 + char *ptr;
21655 + int ipace=2;
21656 +
21657 + dprintf(4, "tn7atm_irq_request()\n");
21658 + priv = (Tn7AtmPrivate *) dev->dev_data;
21659 +
21660 + /* Register SAR interrupt */
21661 + priv->sar_irq = LNXINTNUM(ATM_SAR_INT); /* Interrupt line # */
21662 + if (request_irq(priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
21663 + printk ("Could not register tn7atm_sar_irq\n");
21664 +
21665 + /* interrupt pacing */
21666 + ptr= prom_getenv("sar_ipacemax");
21667 + if(ptr)
21668 + {
21669 + ipace=os_atoi(ptr);
21670 + }
21671 + avalanche_request_pacing(priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM, ipace);
21672 +
21673 + /* Reigster Receive interrupt A */
21674 + priv->dsl_irq = LNXINTNUM(ATM_DSL_INT); /* Interrupt line # */
21675 + if (request_irq(priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
21676 + printk ("Could not register tn7atm_dsl_irq\n");
21677 +
21678 + return 0;
21679 +}
21680 +
21681 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21682 + *
21683 + * Function: int tn7atm_lut_find(struct atm_vcc *vcc)
21684 + *
21685 + * Description: find an TX DMA channel
21686 + * that matches a vpi/vci pair
21687 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21688 +int
21689 +tn7atm_lut_find(short vpi, int vci)
21690 +{
21691 + int i;
21692 + Tn7AtmPrivate *priv;
21693 +
21694 + priv = (Tn7AtmPrivate *)mydev->dev_data;
21695 +
21696 + if(vci==0) // find first vpi channel
21697 + {
21698 + for(i=0; i< MAX_DMA_CHAN; i++)
21699 + {
21700 + if((priv->lut[i].vpi == vpi))
21701 + return i;
21702 + }
21703 + }
21704 +
21705 + dprintf(4, "vpi=%d, vci=%d\n", vpi, vci);
21706 + for(i=0; i< MAX_DMA_CHAN; i++)
21707 + {
21708 + if((priv->lut[i].vpi == vpi) && (priv->lut[i].vci == vci))
21709 + return i;
21710 + }
21711 +
21712 +
21713 +
21714 + return ATM_NO_DMA_CHAN;
21715 +}
21716 +
21717 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21718 + *
21719 + * Function: int tn7atm_lut_clear(struct atm_vcc *vcc,int chan)
21720 + *
21721 + * Description: find an TX DMA channel
21722 + * that matches a vpi/vci pair
21723 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21724 +static int
21725 +tn7atm_lut_clear(struct atm_vcc *vcc, int chan)
21726 +{
21727 + Tn7AtmPrivate *priv;
21728 +
21729 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21730 +
21731 + memset(&priv->lut[chan], 0, sizeof(priv->lut[chan]));
21732 +
21733 + return 0;
21734 +}
21735 +
21736 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21737 + *
21738 + * Function: int tn7atm_walk_lut(void)
21739 + *
21740 + * Description: find an available TX DMA channel
21741 + * and initialize LUT
21742 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21743 +static int
21744 +tn7atm_walk_lut(Tn7AtmPrivate *priv)
21745 +{
21746 + int i;
21747 +
21748 + for(i=0; i< MAX_DMA_CHAN; i++){
21749 + if(!priv->lut[i].inuse)
21750 + {
21751 + return i; /* return available dma channel number */
21752 + }
21753 + }
21754 + return ATM_NO_DMA_CHAN; /* no tx dma channels available */
21755 +}
21756 +
21757 +static int
21758 +tn7atm_set_lut(Tn7AtmPrivate *priv, struct atm_vcc *vcc, int chan)
21759 +{
21760 +
21761 + if(!priv->lut[chan].inuse)
21762 + {
21763 + priv->lut[chan].vpi = (int)vcc->vpi;
21764 + priv->lut[chan].vci = vcc->vci;
21765 + priv->lut[chan].chanid = chan;
21766 + priv->lut[chan].inuse = 1; /* claim the channel */
21767 + priv->lut[chan].vcc = (void *)vcc;
21768 + priv->lut[chan].bClosing = 0;
21769 + priv->lut[chan].ready = 0;
21770 + priv->lut[chan].tx_total_bufs = TX_BUFFER_NUM;
21771 + priv->lut[chan].tx_used_bufs[0] = 0;
21772 + priv->lut[chan].tx_used_bufs[1] = 0;
21773 + return 0;
21774 + }
21775 + return -1; /* no tx dma channels available */
21776 +}
21777 +
21778 +#if 0
21779 +static void tn7atm_free_packet(void *pVc, void *pDev, void *pPacket)
21780 + {
21781 + Tn7AtmPrivate *priv;
21782 + struct atm_vcc *vcc;
21783 + struct sk_buff *skb;
21784 +
21785 + vcc = (struct atm_vcc *)pVc;
21786 + priv = (Tn7AtmPrivate *)pDev;
21787 + skb = (struct sk_buff *) pPacket;
21788 +
21789 + if(vcc->pop)
21790 + vcc->pop(vcc, skb);
21791 + else
21792 + tn7atm_kfree_skb(skb);
21793 + }
21794 +#endif
21795 +
21796 +static void str2eaddr(char *pMac, char *pStr)
21797 +{
21798 + char tmp[3];
21799 + int i;
21800 +
21801 + for(i=0;i<6;i++)
21802 + {
21803 + tmp[0]=pStr[i*3];
21804 + tmp[1]=pStr[i*3+1];
21805 + tmp[2]=0;
21806 + pMac[i]=os_atoh(tmp);
21807 + }
21808 +}
21809 +
21810 +static int __init
21811 +tn7atm_get_ESI(struct atm_dev *dev)
21812 +{
21813 + int i;
21814 + char esi_addr[ESI_LEN]={0x00,0x00,0x11,0x22,0x33,0x44};
21815 + char *esiaddr_str = NULL;
21816 +
21817 + esiaddr_str = prom_getenv("macc");
21818 +
21819 + if (!esiaddr_str) {
21820 + //printk("macc address not set in adam2 environment space\n");
21821 + //printk("Using default macc address = 00:01:02:03:04:05\n");
21822 + esiaddr_str = "00:00:02:03:04:05";
21823 + }
21824 + str2eaddr(esi_addr, esiaddr_str);
21825 +
21826 + for(i=0; i < ESI_LEN; i++)
21827 + dev->esi[i] = esi_addr[i];
21828 +
21829 + return 0;
21830 +}
21831 +
21832 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21833 + *
21834 + * Function: int tn7atm_open(struct atm_vcc *vcc, short vpi, int vci)
21835 + *
21836 + * Description: Device operation: open
21837 + *
21838 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
21839 +//static int
21840 +int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
21841 +{
21842 + Tn7AtmPrivate *priv;
21843 + int dmachan;
21844 + int rc;
21845 + int traffic_type;
21846 + int pcr = 0x20000;
21847 + int scr = 0x20000;
21848 + int mbs = 0x20000;
21849 + int cdvt = 10000;
21850 + int err;
21851 +
21852 + dprintf(1, "tn7atm_open()\n");
21853 +
21854 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21855 + if(priv==NULL)
21856 + {
21857 + printk("null priv\n");
21858 + return -1;
21859 + }
21860 +
21861 + MOD_INC_USE_COUNT;
21862 +
21863 +#if 0 /* by nbd */
21864 + /* find a free VPI/VCI */
21865 + tn7atm_walk_vccs(vcc, &vpi, &vci);
21866 +#else
21867 + if ((err = atm_find_ci(vcc, &vpi, &vci))) {
21868 + printk("atm_find_ci err = %d\n", err);
21869 + return err;
21870 + }
21871 +
21872 +#endif
21873 +
21874 + vcc->vpi = vpi;
21875 + vcc->vci = vci;
21876 +
21877 + if (vci == ATM_VCI_UNSPEC || vpi == ATM_VCI_UNSPEC)
21878 + {
21879 + MOD_DEC_USE_COUNT;
21880 + return -EBUSY;
21881 + }
21882 +
21883 + /* check to see whether PVC is opened or not */
21884 + if((dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci)) != ATM_NO_DMA_CHAN)
21885 + {
21886 + MOD_DEC_USE_COUNT;
21887 + printk("PVC already opened. dmachan = %d\n", dmachan);
21888 + return -EBUSY;
21889 + }
21890 + /*check for available channel */
21891 + if((dmachan = tn7atm_walk_lut(priv)) == ATM_NO_DMA_CHAN)
21892 + {
21893 + printk("No TX DMA channels available\n");
21894 + return -EBUSY;
21895 + }
21896 +
21897 + set_bit(ATM_VF_ADDR, &vcc->flags); /* claim address */
21898 +
21899 + vcc->itf = vcc->dev->number; /* interface number */
21900 +
21901 + switch(vcc->qos.txtp.traffic_class)
21902 + {
21903 + case ATM_CBR: /* Constant Bit Rate */
21904 + traffic_type = 0;
21905 + pcr = vcc->qos.txtp.pcr;
21906 + scr = vcc->qos.txtp.pcr;
21907 + cdvt = vcc->qos.txtp.max_cdv;
21908 + printk("cdvt=%d\n", cdvt);
21909 + break;
21910 + case ATM_UBR: /* Unspecified Bit Rate */
21911 + traffic_type = 2;
21912 + break;
21913 +
21914 + /* Disable ATM_VBR until pppd ppoatm plugin supports it.
21915 + * NOTE: Support ATM_VBR requires the addition of a scr
21916 + * field to the atm_trafprm structure which will cause
21917 + * a change in the SO_ATMQOS ioctl. Make sure that the
21918 + * revised header file becomes visible to the pppd
21919 + * pppoatm plugin source, or the SO_ATMQOS ioctl will fail.
21920 + */
21921 +#if 0
21922 + case ATM_VBR: /* Variable Bit Rate */
21923 + traffic_type = 1;
21924 + pcr = vcc->qos.txtp.pcr;
21925 + scr = vcc->qos.txtp.scr;
21926 + if(vcc->qos.txtp.max_pcr >= 0)
21927 + mbs = vcc->qos.txtp.max_pcr;
21928 + cdvt = vcc->qos.txtp.max_cdv;
21929 + printk("cdvt=%d\n", cdvt);
21930 + printk("mbs=%d\n", mbs);
21931 + break;
21932 +#endif
21933 + default:
21934 + traffic_type = 2;
21935 + }
21936 +
21937 + dprintf(4, "vpi=%d, vci=%d, pcr=%d, dmachan=%d, qos=%d\n", vpi,vci,pcr,dmachan,traffic_type);
21938 + /* Activate SAR channel */
21939 + rc = tn7sar_activate_vc(priv, vpi, vci, pcr, scr, mbs, cdvt, dmachan, traffic_type);
21940 + if(rc < 0)
21941 + {
21942 +
21943 + MOD_DEC_USE_COUNT;
21944 + return -EBUSY;
21945 + }
21946 +
21947 + /* insure that the the vcc struct points to the correct entry
21948 + in the lookup table */
21949 +
21950 + tn7atm_set_lut(priv,vcc, dmachan);
21951 + vcc->dev_data = (void *)&priv->lut[dmachan];
21952 + set_bit(ATM_VF_READY, &vcc->flags);
21953 +
21954 + mdelay(100);
21955 + priv->lut[dmachan].ready = 1;
21956 + dprintf (1, "Leave tn7atm_open\n");
21957 + return 0;
21958 +}
21959 +
21960 +
21961 +//static void
21962 +void tn7atm_close (struct atm_vcc *vcc)
21963 +{
21964 + Tn7AtmPrivate *priv;
21965 + int dmachan;
21966 +
21967 + priv = (Tn7AtmPrivate *)vcc->dev->dev_data;
21968 + dprintf(4, "closing %d.%d.%d.%d\n", vcc->itf, vcc->vpi, vcc->vci, vcc->qos.aal);
21969 +
21970 + clear_bit(ATM_VF_READY, &vcc->flags); /* ATM_VF_READY: channel is ready to transfer data */
21971 +
21972 + dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci);
21973 + printk("closing channel: %d\n", dmachan);
21974 + if(dmachan == ATM_NO_DMA_CHAN)
21975 + {
21976 + printk("Closing channel not found.\n");
21977 + return;
21978 + }
21979 + priv->lut[dmachan].bClosing = 1;
21980 + priv->lut[dmachan].ready = 0;
21981 + if(tn7sar_deactivate_vc(priv,dmachan)) /* tear down channel */
21982 + {
21983 + printk("failed to close channel %d.\n", dmachan);
21984 + }
21985 +
21986 + clear_bit(ATM_VF_READY, &vcc->flags); /* ATM_VF_READY: channel is ready to transfer data */
21987 + tn7atm_lut_clear(vcc, dmachan);
21988 +
21989 + MOD_DEC_USE_COUNT;
21990 +
21991 + dprintf (1, "Leave tn7atm_close\n");
21992 +}
21993 +
21994 +#define ATM_TXSTOP 0x800c61f4
21995 +static int
21996 +tn7atm_ioctl (struct atm_dev *dev, unsigned int cmd, void *arg)
21997 +{
21998 + Tn7AtmPrivate *priv;
21999 + priv = (Tn7AtmPrivate *) dev->dev_data;
22000 +
22001 + //printk("tn7atm_ioctl\n");
22002 + //printk("arg = %x\n", *(int *)arg);
22003 + //printk("cmd =%x\n", cmd);
22004 + switch(cmd)
22005 + {
22006 +
22007 + case ATM_TXSTOP: /*temp fix for SAR tear down problem */
22008 +// printk("ioctl cmd = 0x%x (%u), arg = 0x%p (%lu)\n", cmd, cmd, arg, (unsigned long)arg);
22009 +// printk("arg = %d\n", *(int*)arg);
22010 + priv->xmitStop = *(int *)arg;
22011 + //printk("Executing ATM_SETLOOP for tn7 \n");
22012 + //printk("Stop variable = :%d: \n",priv->xmitStop);
22013 + return 0;
22014 +
22015 + //case SAR_DSL_RESET_SOFTBOOT:
22016 + // return tn7atm_dsl_clean_reboot();
22017 + case 0:
22018 + return 0;
22019 + }
22020 +
22021 + return -ENOSYS;
22022 +
22023 +}
22024 +
22025 +static int
22026 +tn7atm_change_qos (struct atm_vcc *vcc, struct atm_qos *qos,int flags)
22027 +{
22028 + dprintf (1, "Enter tn7atm_change_qos\n");
22029 + dprintf (1, "Leave tn7atm_change_qos\n");
22030 + return 0;
22031 +}
22032 +
22033 +
22034 +int tn7atm_send (struct atm_vcc *vcc, struct sk_buff *skb)
22035 +{
22036 +
22037 + Tn7AtmPrivate *priv;
22038 + int bret;
22039 + int chan;
22040 +
22041 + dprintf(4, "tn7atm_send()\n");
22042 +
22043 + priv = (Tn7AtmPrivate*)vcc->dev->dev_data;
22044 +
22045 + //if(skb->len < 64)
22046 + //xdump((unsigned char *)skb->data, skb->len, 1);
22047 + //else
22048 + //xdump((unsigned char *)skb->data, 64, 1);
22049 + /* check for dsl line connection */
22050 +
22051 + /* add vcc field in skb for clip inATMARP fix */
22052 + ATM_SKB(skb)->vcc = vcc;
22053 + /* Ron change 2.3 -> 2.4 ??*/
22054 + //if(priv->lConnected != 1 || priv->xmitStop == 1)
22055 + if(priv->lConnected != 1 && priv->xmitStop == 1)
22056 + {
22057 + dprintf(4,"dsl line down\n");
22058 + if(vcc->pop)
22059 + vcc->pop(vcc, skb);
22060 + else
22061 + tn7atm_kfree_skb(skb);
22062 + return 1;
22063 + }
22064 +
22065 + /* check whether PVC is closing */
22066 + chan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22067 + /* set br2684 dev pointer */
22068 + priv->lut[chan].net_device = skb->dev;
22069 + if(chan == ATM_NO_DMA_CHAN || priv->lut[chan].bClosing == 1)
22070 + {
22071 + dprintf(4, "can find sar channel\n");
22072 + if(vcc->pop)
22073 + vcc->pop(vcc, skb);
22074 + else
22075 + tn7atm_kfree_skb(skb);
22076 + return 1;
22077 + }
22078 +
22079 + bret=tn7atm_queue_packet_to_sar(vcc, skb);
22080 +
22081 + return bret;
22082 +}
22083 +
22084 +
22085 +static int tn7atm_queue_packet_to_sar(void *vcc1, void *skb1)
22086 +{
22087 + struct atm_vcc *vcc;
22088 + struct sk_buff *skb;
22089 + int priority = 1;
22090 + Tn7AtmPrivate *priv;
22091 + int dmachan;
22092 +
22093 + vcc = (struct atm_vcc *)vcc1;
22094 + skb = (struct sk_buff *)skb1;
22095 +
22096 + priv = (Tn7AtmPrivate*)vcc->dev->dev_data;
22097 +
22098 + dprintf(4, "vcc->vci=%d\n", vcc->vci);
22099 + dmachan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22100 + if(dmachan == ATM_NO_DMA_CHAN)
22101 + {
22102 + dprintf(4, "can find sar channel\n");
22103 + if(vcc->pop)
22104 + vcc->pop(vcc, skb);
22105 + else
22106 + tn7atm_kfree_skb(skb);
22107 + return 1;
22108 + }
22109 +
22110 + // turbo dsl TCP ack check
22111 + if(priv->bTurboDsl)
22112 + priority = turbodsl_check_priority_type(skb->data);
22113 +
22114 + //skb priority check
22115 + if(priority != 0)
22116 + {
22117 + if((skb->cb[47])>>1)
22118 + priority=1;
22119 + else
22120 + priority = 0;
22121 + }
22122 +
22123 + /* add queue info here */
22124 + skb->cb[47] = (char)priority;
22125 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22126 + priv->lut[dmachan].tx_used_bufs[priority]++;
22127 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22128 +
22129 + if(tn7sar_send_packet(priv,dmachan, skb, skb->data, skb->len, priority) != 0)
22130 + {
22131 + dprintf(1, "failed to send packet\n");
22132 + if(vcc->pop)
22133 + vcc->pop(vcc, skb);
22134 + else
22135 + tn7atm_kfree_skb(skb);
22136 +
22137 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22138 + priv->lut[dmachan].tx_used_bufs[priority]--;
22139 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22140 + return 1;
22141 + }
22142 +
22143 + /* check for whether tx queue is full or not */
22144 + //printk("bufs used = %d\n", priv->lut[dmachan].tx_used_bufs[1]);
22145 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22146 + if(priv->lut[dmachan].tx_used_bufs[1] >= (priv->lut[dmachan].tx_total_bufs - STOP_EMPTY_BUFF) ||
22147 + priv->lut[dmachan].tx_used_bufs[0] >= (priv->lut[dmachan].tx_total_bufs - STOP_EMPTY_BUFF))
22148 + {
22149 + //printk("net queue stoped\n");
22150 + netif_stop_queue(priv->lut[dmachan].net_device);
22151 + priv->lut[dmachan].netqueue_stop = 1;
22152 + }
22153 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22154 +
22155 + return 0;
22156 +}
22157 +
22158 +/* functions needed by SAR HAL */
22159 +
22160 +int tn7atm_send_complete(void *osSendInfo)
22161 +{
22162 + Tn7AtmPrivate *priv;
22163 + //struct atm_dev *dev;
22164 + struct sk_buff *skb;
22165 + struct atm_vcc *vcc;
22166 + int chan;
22167 +
22168 + dprintf(4, "tn7atm_send_complete()\n");
22169 +
22170 +
22171 + skb = (struct sk_buff *)osSendInfo;
22172 + //dev = (struct atm_dev *) (skb->dev);
22173 + priv = (Tn7AtmPrivate *)mydev->dev_data;
22174 + vcc =ATM_SKB(skb)->vcc;
22175 + if(vcc)
22176 + {
22177 + dprintf(4, "vcc->vci=%d\n",vcc->vci );
22178 + chan = tn7atm_lut_find(vcc->vpi, vcc->vci);
22179 + if(chan==ATM_NO_DMA_CHAN)
22180 + return 1;
22181 +
22182 + /*decreament packet queued number */
22183 + spin_lock_irqsave(&priv->netifqueueLock, priv->netifqueueLockFlag);
22184 + priv->lut[chan].tx_used_bufs[(int)skb->cb[47]] --;
22185 + if(priv->lut[chan].tx_used_bufs[1] < priv->lut[chan].tx_total_bufs - START_EMPTY_BUFF &&
22186 + priv->lut[chan].tx_used_bufs[0] < priv->lut[chan].tx_total_bufs - START_EMPTY_BUFF)
22187 + {
22188 + if(priv->lut[chan].netqueue_stop)
22189 + {
22190 + //printk("net queue restarted\n");
22191 + netif_wake_queue(priv->lut[chan].net_device);
22192 + priv->lut[chan].netqueue_stop = 0;
22193 + }
22194 + }
22195 + spin_unlock_irqrestore(&priv->netifqueueLock, priv->netifqueueLockFlag);
22196 +
22197 + if(vcc->pop)
22198 + {
22199 + dprintf(5, "free packet\n");
22200 + vcc->pop(vcc, skb);
22201 + }
22202 +
22203 +
22204 + }
22205 +
22206 +
22207 +
22208 + /* Update Stats: There may be a better place to do this, but this is a start */
22209 + priv->stats.tx_packets++;
22210 +#ifdef CONFIG_LED_MODULE
22211 +// led_operation(MOD_ADSL, DEF_ADSL_ACTIVITY);
22212 +#endif
22213 +
22214 + /* track number of buffer used */
22215 +
22216 + dprintf(4, "tn7atm_send_complete() done\n");
22217 +
22218 + return 0;
22219 +}
22220 +
22221 +void *tn7atm_allocate_rx_skb(void *os_dev, void **os_receive_info, unsigned int size)
22222 +{
22223 + struct sk_buff *skb;
22224 + dprintf(4, "tn7atm_allocate_rx_skb size=%d\n", size);
22225 + size = ((size+3)&0xfffffffc);
22226 + skb = dev_alloc_skb(size);
22227 + if(skb==NULL)
22228 + {
22229 + //printk("rx allocate skb failed\n");
22230 + return NULL;
22231 + }
22232 + *os_receive_info = (void *)skb;
22233 + return (skb->data);
22234 +}
22235 +
22236 +void tn7atm_free_rx_skb(void *skb)
22237 +{
22238 + dprintf(4, "tn7atm_free_rx_skb\n");
22239 + tn7atm_kfree_skb((struct sk_buff *)skb);
22240 +}
22241 +
22242 +
22243 +int tn7atm_receive(void *os_dev, int ch, unsigned int packet_size, void *os_receive_info, void *data)
22244 +{
22245 + Tn7AtmPrivate *priv;
22246 + struct atm_dev *dev;
22247 + struct sk_buff *skb;
22248 + struct atm_vcc *vcc;
22249 +
22250 +
22251 + dprintf(4, "tn7atm_receive()\n");
22252 + dev = (struct atm_dev *)os_dev;
22253 +
22254 + priv = (Tn7AtmPrivate *)dev->dev_data;
22255 +
22256 + if(priv->lConnected != 1 || priv->lut[ch].ready == 0)
22257 + {
22258 + //printk("channel not ready\n");
22259 + return 1;
22260 + }
22261 +
22262 + vcc = (struct atm_vcc *)priv->lut[ch].vcc;
22263 + if(vcc == NULL)
22264 + {
22265 + printk("vcc=Null");
22266 + return 1;
22267 + }
22268 +
22269 +
22270 + /* assume no fragment packet for now */
22271 + skb = (struct sk_buff *)os_receive_info;
22272 +
22273 + if(skb==NULL)
22274 + {
22275 + dprintf(1, "received empty skb.\n");
22276 + return 1;
22277 + }
22278 + /* see skbuff->cb definition in include/linux/skbuff.h */
22279 + ATM_SKB(skb)->vcc = vcc;
22280 +
22281 + skb->len = packet_size;
22282 + dprintf(3, "skb:[0x%p]:0x%x pdu_len: 0x%04x\n",skb,skb->len,packet_size);
22283 + dprintf(3, "data location: 0x%x, 0x%x\n", (unsigned int)skb->data, (unsigned int)data);
22284 +
22285 + /*skb_trim(skb,skb->len); */ /* skb size is incorrect for large packets > 1428 bytes ?? */
22286 + __skb_trim(skb,skb->len); /* change to correct > 1500 ping when firewall is on */
22287 +
22288 + dprintf(3, "pushing the skb...\n");
22289 + skb->stamp = xtime;
22290 +
22291 + xdump((unsigned char *)skb->data, skb->len, 5);
22292 +
22293 + if(atm_charge(vcc, skb->truesize) == 0)
22294 + {
22295 + dprintf(1,"Receive buffers saturated for %d.%d.%d - PDU dropped\n", vcc->itf, vcc->vci, vcc->vpi);
22296 + return 1;
22297 + }
22298 +
22299 + /*pass it up to kernel networking layer and update stats*/
22300 + vcc->push(vcc,skb);
22301 +
22302 + /* Update receive packet stats */
22303 + priv->stats.rx_packets++;
22304 + atomic_inc(&vcc->stats->rx);
22305 +
22306 +#ifdef CONFIG_LED_MODULE
22307 +// led_operation(MOD_ADSL, DEF_ADSL_ACTIVITY);
22308 +#endif
22309 + dprintf(3, "(a) Receiving:vpi/vci[%d/%d] chan_id: %d skb len:0x%x skb truesize:0x%x\n",
22310 + vcc->vpi,vcc->vci,ch,skb->len, skb->truesize);
22311 +
22312 + return 0;
22313 +}
22314 +
22315 +static int
22316 +tn7atm_proc_channels(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22317 +{
22318 + int len = 0;
22319 + int limit = count - 80;
22320 + int i;
22321 +
22322 + struct atm_dev *dev;
22323 + Tn7AtmPrivate *priv;
22324 +
22325 + dev = (struct atm_dev *)data;
22326 + priv = (Tn7AtmPrivate *)dev->dev_data;
22327 +
22328 + if(len<=limit)
22329 + len += sprintf(buf+len,"Chan Inuse ChanID VPI VCI \n");
22330 + if(len<=limit)
22331 + len += sprintf(buf+len,"------------------------------------------------------------------\n");
22332 +
22333 + for(i=0; i < MAX_DMA_CHAN; i++)
22334 + {
22335 + if(len<=limit)
22336 + {
22337 + len += sprintf(buf+len,
22338 + " %02d %05d %05d %05d %05d \n",
22339 + i,priv->lut[i].inuse,priv->lut[i].chanid,
22340 + priv->lut[i].vpi,priv->lut[i].vci);
22341 + }
22342 + }
22343 +
22344 + return len;
22345 +}
22346 +
22347 +static int
22348 +tn7atm_proc_private(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22349 +{
22350 + int len = 0;
22351 + int limit = count - 80;
22352 + struct atm_dev *dev;
22353 + Tn7AtmPrivate *priv;
22354 +
22355 + dev = (struct atm_dev *)data;
22356 + priv = (Tn7AtmPrivate *)dev->dev_data;
22357 +
22358 + if(len<=limit)
22359 + len += sprintf(buf+len, "\nPrivate Data Structure(%s):\n",priv->name);
22360 + if(len<=limit)
22361 + len += sprintf(buf+len, "----------------------------------------\n");
22362 + if(len<=limit)
22363 + len += sprintf(buf+len, "priv: 0x%p\n",priv);
22364 + if(len<=limit)
22365 + len += sprintf(buf+len, "next: 0x%p",priv->next);
22366 + if(len<=limit)
22367 + len += sprintf(buf+len, "\tdev: 0x%p\n",priv->dev);
22368 +
22369 + if(len<=limit)
22370 + len += sprintf(buf+len, "tx_irq: %02d",priv->sar_irq);
22371 + if(len<=limit)
22372 + len += sprintf(buf+len, "rx_irq: %02d",priv->dsl_irq);
22373 +
22374 +
22375 + return len;
22376 +}
22377 +
22378 +void tn7atm_sarhal_isr_register(void *os_dev, void *hal_isr, int interrupt_num)
22379 +{
22380 + struct atm_dev *dev;
22381 + Tn7AtmPrivate *priv;
22382 +
22383 + dprintf(4, "tn7atm_sarhal_isr_register()\n");
22384 +
22385 + dev = (struct atm_dev *)os_dev;
22386 + priv = (Tn7AtmPrivate *)dev->dev_data;
22387 + priv->halIsr = (void *)hal_isr;
22388 + priv->int_num = interrupt_num;
22389 +}
22390 +
22391 +
22392 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22393 + *
22394 + * Function: int tn7atm_exit(void)
22395 + *
22396 + * Description: Avalanche SAR exit function
22397 + *
22398 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22399 +
22400 +static void
22401 +tn7atm_exit (void)
22402 +{
22403 +
22404 + struct atm_dev *dev;
22405 +
22406 + Tn7AtmPrivate *priv;
22407 +
22408 + dprintf(4, "tn7atm_exit()\n");
22409 +
22410 + dev=mydev;
22411 + priv = (Tn7AtmPrivate *)dev->dev_data;
22412 + priv->lConnected = 0;
22413 + tn7dsl_exit();
22414 +
22415 + tn7sar_exit(dev, priv);
22416 +
22417 + /* freeup irq's */
22418 + free_irq(priv->dsl_irq,priv->dev);
22419 + free_irq(priv->sar_irq,priv->dev);
22420 +
22421 + kfree (dev->dev_data);
22422 +
22423 + // atm_dev_deregister (dev);
22424 + shutdown_atm_dev(dev);
22425 +
22426 + /* remove proc entries */
22427 + remove_proc_entry("tiatm/avsar_ver",NULL);
22428 + remove_proc_entry("tiatm/avsar_modem_stats",NULL);
22429 + remove_proc_entry("tiatm/avsar_modem_training",NULL);
22430 + remove_proc_entry("tiatm/avsar_channels",NULL);
22431 + remove_proc_entry("tiatm/avsar_private",NULL);
22432 + remove_proc_entry("tiatm/avsar_sarhal_stats",NULL);
22433 + remove_proc_entry("tiatm/avsar_oam_ping",NULL);
22434 + remove_proc_entry("tiatm/avsar_pvc_table",NULL);
22435 + remove_proc_entry("tiatm",NULL);
22436 + tn7dsl_dslmod_sysctl_unregister();
22437 +
22438 + printk ("Module Removed\n");
22439 +
22440 +}
22441 +
22442 +
22443 +
22444 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22445 + *
22446 + * Function: int tn7atm_registration(struct tn7* tn7)
22447 + *
22448 + * Description: ATM driver registration
22449 + *
22450 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22451 +
22452 +static int __init
22453 +tn7atm_register (Tn7AtmPrivate * priv)
22454 +{
22455 + /* allocate memory for the device */
22456 +
22457 + dprintf(4,"device %s being registered\n", priv->name);
22458 +
22459 + mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
22460 +
22461 + if (mydev == NULL)
22462 + {
22463 + printk ("atm_dev_register returning NULL\n");
22464 + return ATM_REG_FAILED;
22465 + }
22466 +
22467 + printk ("registered device %s\n", priv->name);
22468 +
22469 + mydev->dev_data = priv; /* setup device data in atm_dev struct */
22470 + priv->dev = mydev; /* setup atm_device in avalanche sar struct */
22471 +
22472 + mydev->ci_range.vpi_bits = ATM_CI_MAX; /* atm supports 11 bits */
22473 + mydev->ci_range.vci_bits = 16; /* atm VCI max = 16 bits */
22474 +
22475 +
22476 + return ATM_REG_OK;
22477 +}
22478 +
22479 +static int
22480 +tn7atm_proc_version(char* buf, char **start, off_t offset, int count,int *eof, void *data)
22481 +{
22482 + int len = 0;
22483 + char dslVer[8];
22484 + char dspVer[10];
22485 + char *pSarVer;
22486 + Tn7AtmPrivate *priv;
22487 + int i;
22488 + unsigned int pdspV1, pdspV2;
22489 +
22490 + priv = mydev->dev_data;
22491 +
22492 + len += sprintf(buf+len, "ATM Driver version:[%d.%02d.%02d.%02d]\n",LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
22493 + LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
22494 +
22495 + tn7dsl_get_dslhal_version(dslVer);
22496 +
22497 + len += sprintf(buf+len, "DSL HAL version: [%d.%02d.%02d.%02d]\n", dslVer[0], dslVer[1], dslVer[2],
22498 + dslVer[3]);
22499 + tn7dsl_get_dsp_version(dspVer);
22500 +
22501 + len += sprintf(buf+len, "DSP Datapump version: [%d.%02d.%02d.%02d] ", dspVer[4], dspVer[5], dspVer[6],
22502 + dspVer[7]);
22503 + if(dspVer[8]==2) // annex B
22504 + len += sprintf(buf+len, "Annex B\n");
22505 + else if(dspVer[8]==3) //annex c
22506 + len += sprintf(buf+len, "Annex c\n");
22507 + else
22508 + len += sprintf(buf+len, "Annex A\n");
22509 +
22510 + tn7sar_get_sar_version(priv, &pSarVer);
22511 +
22512 + len += sprintf(buf+len, "SAR HAL version: [");
22513 + for(i=0;i<8;i++)
22514 + {
22515 + len += sprintf(buf+len, "%c", pSarVer[i+7]);
22516 + }
22517 + len += sprintf(buf+len, "]\n");
22518 +
22519 + tn7sar_get_sar_firmware_version(&pdspV1, &pdspV2);
22520 + len += sprintf(buf+len, "PDSP Firmware version:[%01x.%02x]\n",
22521 + pdspV1,pdspV2);
22522 +
22523 + return len;
22524 +}
22525 +
22526 +/*
22527 +static struct net_device_stats
22528 +*tn7atm_get_stats(struct atm_dev *dev)
22529 +{
22530 + Tn7AtmPrivate *priv;
22531 + //unsigned long flags;
22532 +
22533 + //spin_lock_irqsave(&priv->stats_lock,flags);
22534 + priv= (Tn7AtmPrivate *)dev->dev_data;
22535 + //spin_unlock_irqrestore(&priv->stats_lock,flags);
22536 +
22537 + return &priv->stats;
22538 +
22539 +}
22540 +*/
22541 +/* Device detection */
22542 +
22543 +static int __init
22544 +tn7atm_detect (void)
22545 +{
22546 + Tn7AtmPrivate *priv;
22547 + //static struct proc_dir_entry *proc_dir;
22548 +
22549 + dprintf(4, "tn7atm_detect().\n");
22550 + /* Device allocated as a global static structure at top of code "mydev" */
22551 +
22552 + /* Alloc priv struct */
22553 + priv=kmalloc(sizeof(Tn7AtmPrivate),GFP_KERNEL);
22554 + if(!priv)
22555 + {
22556 + printk("unable to kmalloc priv structure. Killing autoprobe.\n");
22557 + return -ENODEV;
22558 + }
22559 + memset(priv, 0, sizeof(Tn7AtmPrivate));
22560 +#ifdef COMMON_NSP
22561 + priv->name = "TI Avalanche SAR";
22562 + priv->proc_name = "avsar";
22563 +#else
22564 + priv->name = "TI tnetd73xx ATM Driver";
22565 + priv->proc_name = "tn7";
22566 +#endif
22567 +
22568 + if ((tn7atm_register (priv)) == ATM_REG_FAILED)
22569 + return -ENODEV;
22570 +
22571 + tn7atm_init(mydev);
22572 +
22573 + /* Set up proc entry for atm stats */
22574 + proc_mkdir("tiatm", NULL);
22575 + create_proc_read_entry("tiatm/avsar_modem_stats",0,NULL,tn7dsl_proc_stats,NULL);
22576 + create_proc_read_entry("tiatm/avsar_modem_training",0,NULL,tn7dsl_proc_modem,NULL);
22577 + create_proc_read_entry("tiatm/avsar_ver",0,NULL,tn7atm_proc_version,NULL);
22578 + create_proc_read_entry("tiatm/avsar_channels",0,NULL,tn7atm_proc_channels,mydev);
22579 + create_proc_read_entry("tiatm/avsar_private",0,NULL,tn7atm_proc_private,mydev);
22580 + create_proc_read_entry("tiatm/avsar_sarhal_stats",0,NULL,tn7sar_proc_sar_stat,mydev);
22581 + create_proc_read_entry("tiatm/avsar_oam_ping",0,NULL,tn7sar_proc_oam_ping,mydev);
22582 + create_proc_read_entry("tiatm/avsar_pvc_table",0,NULL,tn7sar_proc_pvc_table,mydev);
22583 +
22584 + tn7dsl_dslmod_sysctl_register();
22585 +
22586 + printk("Texas Instruments ATM driver: version:[%d.%02d.%02d.%02d]\n",LINUXATM_VERSION_MAJOR, LINUXATM_VERSION_MINOR,
22587 + LINUXATM_VERSION_BUGFIX, LINUXATM_VERSION_BUILDNUM);
22588 + return 0;
22589 +}
22590 +
22591 +
22592 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22593 + *
22594 + * Function: int tn7atm_probe(void)
22595 + *
22596 + * Description: Avalanche SAR driver probe (see net/atm/pvc.c)
22597 + * this is utilized when the SAR driver is built
22598 + * into the kernel and needs to be configured.
22599 + *
22600 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22601 +int __init tn7atm_probe(void)
22602 +{
22603 + tn7atm_detect();
22604 + return -ENODEV;
22605 +}
22606 +
22607 +
22608 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22609 + *
22610 + * Function: int tn7atm_init(struct atm_dev *dev)
22611 + *
22612 + * Description: Device Initialization
22613 + *
22614 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
22615 +static int __init
22616 +tn7atm_init(struct atm_dev *dev)
22617 +{
22618 + Tn7AtmPrivate *priv;
22619 + char *ptr;
22620 +
22621 + dprintf(4, "tn7atm_init()\n");
22622 +
22623 + priv = (Tn7AtmPrivate *)dev->dev_data;
22624 +
22625 + if(tn7sar_init(dev, priv) != 0)
22626 + {
22627 + printk("Failed to init SAR.\n");
22628 + return -ENODEV;
22629 + }
22630 +
22631 + if(tn7dsl_init(priv) < 0)
22632 + {
22633 + printk("Failed to init DSL.\n");
22634 + return -ENODEV;
22635 + }
22636 +
22637 + if(tn7atm_get_ESI(dev) < 0) /* set ESI */
22638 + return -ENODEV;
22639 +
22640 + if(tn7atm_irq_request(dev) < 0)
22641 + return -EBUSY;
22642 +
22643 + priv->bTurboDsl = 1;
22644 + // read config for turbo dsl
22645 + ptr = prom_getenv("TurboDSL");
22646 + if(ptr)
22647 + {
22648 + priv->bTurboDsl = os_atoi(ptr);
22649 + }
22650 +
22651 + return 0;
22652 +}
22653 +
22654 +int tn7atm_device_connect_status(void *priv, int state)
22655 +{
22656 + Tn7AtmPrivate *priv1;
22657 +
22658 + dprintf(5, "tn7atm_device_connect_status()\n");
22659 + priv1 = (Tn7AtmPrivate *)priv;
22660 +
22661 + priv1->lConnected = state;
22662 + dprintf(5, "priv1->lConnected=%d\n", priv1->lConnected);
22663 + return 0;
22664 +}
22665 +
22666 +
22667 +#ifdef MODULE
22668 +module_init (tn7atm_detect);
22669 +module_exit (tn7atm_exit);
22670 +#endif /* MODULE */
22671 diff -urN linux.old/drivers/atm/sangam_atm/tn7atm.h linux.dev/drivers/atm/sangam_atm/tn7atm.h
22672 --- linux.old/drivers/atm/sangam_atm/tn7atm.h 1970-01-01 01:00:00.000000000 +0100
22673 +++ linux.dev/drivers/atm/sangam_atm/tn7atm.h 2005-08-23 04:46:50.107842176 +0200
22674 @@ -0,0 +1,115 @@
22675 +/*
22676 + * Tnetd73xx ATM driver.
22677 + * by Zhicheng Tang, ztang@ti.com
22678 + * 2000 (c) Texas Instruments Inc.
22679 + *
22680 + *
22681 +*/
22682 +
22683 +#ifndef __TN7ATM_H
22684 +#define __TN7ATM_H
22685 +
22686 +//#include "mips_support.h"
22687 +#include <linux/list.h>
22688 +
22689 +#define ATM_REG_OK 1
22690 +#define ATM_REG_FAILED 0
22691 +
22692 +#define TX_SERVICE_MAX 32
22693 +#define RX_SERVICE_MAX 20
22694 +#define TX_BUFFER_NUM 64
22695 +#define RX_BUFFER_NUM 28
22696 +#define TX_QUEUE_NUM 2
22697 +#define RX_BUFFER_SIZE 1582
22698 +
22699 +#define TX_DMA_CHAN 16 /* number of tx dma channels available */
22700 +#define MAX_DMA_CHAN 16
22701 +#define ATM_NO_DMA_CHAN MAX_DMA_CHAN + 1 /* no tx dma channels available */
22702 +#define ATM_SAR_INT 15
22703 +#define ATM_SAR_INT_PACING_BLOCK_NUM 2
22704 +#define ATM_DSL_INT 39
22705 +
22706 +#define CONFIG_ATM_TN7ATM_DEBUG 0 /* Debug level (0=no mtn7s 5=verbose) */
22707 +
22708 +#define TN7ATM_DEV(d) ((struct tn7atm*)((d)->dev_data))
22709 +
22710 +
22711 +/* Avalanche SAR state information */
22712 +
22713 +typedef enum tn7atm_state
22714 +{
22715 + TN7ATM_STATE_REGISTER /* device registered */
22716 +}tn7atm_state;
22717 +
22718 +typedef struct _sar_stat
22719 +{
22720 + unsigned int txErrors;
22721 + unsigned int rxErrors;
22722 + unsigned int rxPktCnt;
22723 + unsigned int txPktCnt;
22724 + unsigned int rxBytes;
22725 + unsigned int txBytes;
22726 +}sar_stat_t;
22727 +
22728 +/* Host based look up table to xref Channel Id's, VPI/VCI, LC, CID, packet type */
22729 +typedef struct _tn7atm_tx_lut
22730 +{
22731 + int inuse; /* is DMA channel available (1=y) */
22732 + int chanid; /* DMA channel ID (0-0x1f) This corresponds to the Channel ID
22733 + that is used in the connection config reg (TN7ATM_CONN_CONFIG) */
22734 + int vpi; /* Virtual path identifier */
22735 + int vci; /* Virtual channel identifier */
22736 + void *vcc;
22737 + int bClosing;
22738 + int ready;
22739 + void *net_device;
22740 + int tx_total_bufs;
22741 + int tx_used_bufs[2];
22742 + int netqueue_stop;
22743 +}tn7atm_lut_t;
22744 +
22745 +/* per device data */
22746 +
22747 +typedef struct _tn7atm_private
22748 +{
22749 + struct _tn7atm_private *next; /* next device */
22750 + struct atm_dev *dev; /* ATM device */
22751 + struct net_device_stats stats; /* Used to report Tx/Rx frames from ifconfig */
22752 + tn7atm_lut_t lut[MAX_DMA_CHAN]; /* Tx DMA look up table (LUT) */
22753 + int dsl_irq; /* ATM SAR TransmitA interrupt number */
22754 + int sar_irq; /* ATM SAR ReceiveA interrupt number */
22755 + char* name; /* device name */
22756 + char* proc_name; /* board name under /proc/atm */
22757 + unsigned int available_cell_rate; /* cell rate */
22758 + unsigned int connection_cell_rate; /* cell rate */
22759 + int lConnected;
22760 +
22761 + /* Tnetd73xx CPHAL */
22762 + void *pSarHalDev;
22763 + void *pSarHalFunc;
22764 + void *pSarOsFunc;
22765 + void *halIsr;
22766 + int int_num;
22767 +
22768 + /* turbo dsl */
22769 + int bTurboDsl;
22770 +
22771 + /* spin lock for netifqueue */
22772 + spinlock_t netifqueueLock;
22773 + int netifqueueLockFlag;
22774 + int xmitStop; /* temp fix for SAR problem */
22775 +}tn7atm_private_t, Tn7AtmPrivate;
22776 +
22777 +
22778 +
22779 +/* ATM adaptation layer id */
22780 +typedef enum tn7atm_aal {
22781 + TN7ATM_AAL0 = 0,
22782 + TN7ATM_AAL2 = 2,
22783 + TN7ATM_AAL5 = 5,
22784 +} tn7atm_aal_t;
22785 +
22786 +
22787 +
22788 +
22789 +#endif
22790 diff -urN linux.old/drivers/atm/sangam_atm/tn7dsl.c linux.dev/drivers/atm/sangam_atm/tn7dsl.c
22791 --- linux.old/drivers/atm/sangam_atm/tn7dsl.c 1970-01-01 01:00:00.000000000 +0100
22792 +++ linux.dev/drivers/atm/sangam_atm/tn7dsl.c 2005-08-23 04:46:50.109841872 +0200
22793 @@ -0,0 +1,1780 @@
22794 +/*
22795 + * $Id$
22796 + *
22797 + * Avalanche SAR driver
22798 + *
22799 + * Zhicheng Tang, ztang@ti.com
22800 + * 2000 (c) Texas Instruments Inc.
22801 + *
22802 + *
22803 +*/
22804 +#include <linux/config.h>
22805 +#include <linux/kernel.h>
22806 +#include <linux/module.h>
22807 +#include <linux/init.h>
22808 +#include <linux/atmdev.h>
22809 +#include <linux/delay.h>
22810 +#include <linux/spinlock.h>
22811 +#include <linux/smp_lock.h>
22812 +#include <asm/io.h>
22813 +#include <asm/mips-boards/prom.h>
22814 +#include <linux/proc_fs.h>
22815 +#include <linux/string.h>
22816 +#include <linux/ctype.h>
22817 +#include <linux/sysctl.h>
22818 +#include <linux/timer.h>
22819 +#include <linux/vmalloc.h>
22820 +#include <linux/file.h>
22821 +#include <asm/uaccess.h>
22822 +
22823 +#include "tn7atm.h"
22824 +#include "tn7api.h"
22825 +#include "dsl_hal_api.h"
22826 +
22827 +#ifdef CONFIG_LED_MODULE
22828 +#include <asm/ar7/ledapp.h>
22829 +#define MOD_ADSL 1
22830 +#define DEF_ADSL_IDLE 1
22831 +#define DEF_ADSL_TRAINING 2
22832 +#define DEF_ADSL_SYNC 3
22833 +#define DEF_ADSL_ACTIVITY 4
22834 +
22835 +#define LED_NUM_1 3
22836 +#define LED_NUM_2 4
22837 +
22838 +led_reg_t ledreg[2];
22839 +
22840 +static int led_on;
22841 +#endif
22842 +
22843 +extern int __guDbgLevel;
22844 +extern sar_stat_t sarStat;
22845 +static int dslInSync = 0;
22846 +static int bMarginThConfig;
22847 +static int bMarginRetrainEnable;
22848 +static char EOCVendorID[8]= {0xb5, 0x00, 0x54, 0x53, 0x54, 0x43, 0x00, 0x00};
22849 +
22850 +#define TC_SYNC 1
22851 +#define SYNC_TIME_DELAY 500000
22852 +
22853 +
22854 +#define DEV_DSLMOD 1
22855 +#define MAX_STR_SIZE 256
22856 +#define DSL_MOD_SIZE 256
22857 +
22858 +#define TRUE 1
22859 +#define FALSE 0
22860 +
22861 +
22862 +enum
22863 +{
22864 + NO_MODE,
22865 + MULTI_MODE,
22866 + T1413_MODE,
22867 + GDMT_MODE,
22868 + GLITE_MODE
22869 +};
22870 +
22871 +
22872 +
22873 +/* a structure to store all information we need
22874 + for our thread */
22875 +typedef struct kthread_struct
22876 +{
22877 + /* private data */
22878 +
22879 + /* Linux task structure of thread */
22880 + struct task_struct *thread;
22881 + /* Task queue need to launch thread */
22882 + struct tq_struct tq;
22883 + /* function to be started as thread */
22884 + void (*function) (struct kthread_struct *kthread);
22885 + /* semaphore needed on start and creation of thread. */
22886 + struct semaphore startstop_sem;
22887 +
22888 + /* public data */
22889 +
22890 + /* queue thread is waiting on. Gets initialized by
22891 + init_kthread, can be used by thread itself.
22892 + */
22893 + wait_queue_head_t queue;
22894 + /* flag to tell thread whether to die or not.
22895 + When the thread receives a signal, it must check
22896 + the value of terminate and call exit_kthread and terminate
22897 + if set.
22898 + */
22899 + int terminate;
22900 + /* additional data to pass to kernel thread */
22901 + void *arg;
22902 +} kthread_t;
22903 +
22904 +#ifndef ADIAG
22905 +#define DSP_FIRMWARE_PATH "/lib/modules/ar0700xx.bin"
22906 +#else
22907 +#define DSP_FIRMWARE_PATH "/var/tmp/ar0700xx_diag.bin"
22908 +#endif
22909 +
22910 +/* externs */
22911 +extern struct atm_dev *mydev;
22912 +extern unsigned int oamFarLBCount[4];
22913 +extern int dslhal_support_restoreTrainingInfo(PITIDSLHW_T pIhw);
22914 +/* gloabal functions */
22915 +
22916 +/* end of global functions */
22917 +
22918 +/* module wide declars */
22919 +static PITIDSLHW_T pIhw;
22920 +static char mod_req[16]={'\t'};
22921 +static volatile int bshutdown;
22922 +static char info[MAX_STR_SIZE];
22923 +static DECLARE_MUTEX_LOCKED(adsl_sem_overlay); /* Used for DSL Polling enable */
22924 +kthread_t overlay_thread;
22925 +/* end of module wide declars */
22926 +
22927 +/* Internal Functions */
22928 +static void tn7dsl_chng_modulation(void* data);
22929 +static void tn7dsl_set_modulation(void* data);
22930 +static int tn7dsl_reload_overlay(void);
22931 +static int dslmod_sysctl(ctl_table *ctl, int write, struct file * filp, void *buffer, size_t *lenp);
22932 +static void tn7dsl_register_dslss_led(void);
22933 +void tn7dsl_dslmod_sysctl_register(void);
22934 +void tn7dsl_dslmod_sysctl_unregister(void);
22935 +/* end of internal functions */
22936 +
22937 +
22938 +
22939 +
22940 +
22941 +/* prototypes */
22942 +
22943 +/* start new kthread (called by creator) */
22944 +void start_kthread(void (*func)(kthread_t *), kthread_t *kthread);
22945 +
22946 +/* stop a running thread (called by "killer") */
22947 +void stop_kthread(kthread_t *kthread);
22948 +
22949 +/* setup thread environment (called by new thread) */
22950 +void init_kthread(kthread_t *kthread, char *name);
22951 +
22952 +/* cleanup thread environment (called by thread upon receiving termination signal) */
22953 +void exit_kthread(kthread_t *kthread);
22954 +
22955 +
22956 +
22957 +/* private functions */
22958 +static void kthread_launcher(void *data)
22959 +{
22960 + kthread_t *kthread = data;
22961 + kernel_thread((int (*)(void *))kthread->function, (void *)kthread, 0);
22962 +
22963 +}
22964 +
22965 +/* public functions */
22966 +
22967 +/* create a new kernel thread. Called by the creator. */
22968 +void start_kthread(void (*func)(kthread_t *), kthread_t *kthread)
22969 +{
22970 + /* initialize the semaphore:
22971 + we start with the semaphore locked. The new kernel
22972 + thread will setup its stuff and unlock it. This
22973 + control flow (the one that creates the thread) blocks
22974 + in the down operation below until the thread has reached
22975 + the up() operation.
22976 + */
22977 + //init_MUTEX_LOCKED(&kthread->startstop_sem);
22978 +
22979 + /* store the function to be executed in the data passed to
22980 + the launcher */
22981 + kthread->function=func;
22982 +
22983 + /* create the new thread my running a task through keventd */
22984 +
22985 + /* initialize the task queue structure */
22986 + kthread->tq.sync = 0;
22987 + INIT_LIST_HEAD(&kthread->tq.list);
22988 + kthread->tq.routine = kthread_launcher;
22989 + kthread->tq.data = kthread;
22990 +
22991 + /* and schedule it for execution */
22992 + schedule_task(&kthread->tq);
22993 +
22994 + /* wait till it has reached the setup_thread routine */
22995 + //down(&kthread->startstop_sem);
22996 +
22997 +}
22998 +
22999 +/* stop a kernel thread. Called by the removing instance */
23000 +void stop_kthread(kthread_t *kthread)
23001 +{
23002 + if (kthread->thread == NULL)
23003 + {
23004 + printk("stop_kthread: killing non existing thread!\n");
23005 + return;
23006 + }
23007 +
23008 + /* this function needs to be protected with the big
23009 + kernel lock (lock_kernel()). The lock must be
23010 + grabbed before changing the terminate
23011 + flag and released after the down() call. */
23012 + lock_kernel();
23013 +
23014 + /* initialize the semaphore. We lock it here, the
23015 + leave_thread call of the thread to be terminated
23016 + will unlock it. As soon as we see the semaphore
23017 + unlocked, we know that the thread has exited.
23018 + */
23019 + //init_MUTEX_LOCKED(&kthread->startstop_sem);
23020 +
23021 + /* We need to do a memory barrier here to be sure that
23022 + the flags are visible on all CPUs.
23023 + */
23024 + mb();
23025 +
23026 + /* set flag to request thread termination */
23027 + kthread->terminate = 1;
23028 +
23029 + /* We need to do a memory barrier here to be sure that
23030 + the flags are visible on all CPUs.
23031 + */
23032 + mb();
23033 + kill_proc(kthread->thread->pid, SIGKILL, 1);
23034 +
23035 + /* block till thread terminated */
23036 + //down(&kthread->startstop_sem);
23037 +
23038 + /* release the big kernel lock */
23039 + unlock_kernel();
23040 +
23041 + /* now we are sure the thread is in zombie state. We
23042 + notify keventd to clean the process up.
23043 + */
23044 + kill_proc(2, SIGCHLD, 1);
23045 +
23046 +}
23047 +
23048 +/* initialize new created thread. Called by the new thread. */
23049 +void init_kthread(kthread_t *kthread, char *name)
23050 +{
23051 + /* lock the kernel. A new kernel thread starts without
23052 + the big kernel lock, regardless of the lock state
23053 + of the creator (the lock level is *not* inheritated)
23054 + */
23055 + lock_kernel();
23056 +
23057 + /* fill in thread structure */
23058 + kthread->thread = current;
23059 +
23060 + /* set signal mask to what we want to respond */
23061 + siginitsetinv(&current->blocked, sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM));
23062 +
23063 + /* initialise wait queue */
23064 + init_waitqueue_head(&kthread->queue);
23065 +
23066 + /* initialise termination flag */
23067 + kthread->terminate = 0;
23068 +
23069 + /* set name of this process (max 15 chars + 0 !) */
23070 + sprintf(current->comm, name);
23071 +
23072 + /* let others run */
23073 + unlock_kernel();
23074 +
23075 + /* tell the creator that we are ready and let him continue */
23076 + //up(&kthread->startstop_sem);
23077 +
23078 +}
23079 +
23080 +/* cleanup of thread. Called by the exiting thread. */
23081 +void exit_kthread(kthread_t *kthread)
23082 +{
23083 + /* we are terminating */
23084 +
23085 + /* lock the kernel, the exit will unlock it */
23086 + lock_kernel();
23087 + kthread->thread = NULL;
23088 + mb();
23089 +
23090 + /* notify the stop_kthread() routine that we are terminating. */
23091 + //up(&kthread->startstop_sem);
23092 + /* the kernel_thread that called clone() does a do_exit here. */
23093 +
23094 + /* there is no race here between execution of the "killer" and real termination
23095 + of the thread (race window between up and do_exit), since both the
23096 + thread and the "killer" function are running with the kernel lock held.
23097 + The kernel lock will be freed after the thread exited, so the code
23098 + is really not executed anymore as soon as the unload functions gets
23099 + the kernel lock back.
23100 + The init process may not have made the cleanup of the process here,
23101 + but the cleanup can be done safely with the module unloaded.
23102 + */
23103 +
23104 +}
23105 +
23106 +
23107 +
23108 +int os_atoi(const char *pStr)
23109 +{
23110 + int retVal = -1;
23111 +
23112 + if(*pStr=='-')
23113 + retVal = -simple_strtoul(pStr+1, (char **)NULL, 10);
23114 + else
23115 + retVal = simple_strtoul(pStr, (char **)NULL, 10);
23116 + return retVal ;
23117 +}
23118 +
23119 +
23120 +int os_atoh(const char *pStr)
23121 +{
23122 + int retVal = -1;
23123 +
23124 + if(*pStr=='-')
23125 + retVal = -simple_strtoul(pStr+1, (char **)NULL, 16);
23126 + else
23127 + retVal = simple_strtoul(pStr, (char **)NULL, 16);
23128 + return retVal ;
23129 +}
23130 +
23131 +unsigned long os_atoul(const char *pStr)
23132 +{
23133 + unsigned long retVal = -1;
23134 +
23135 + retVal = simple_strtoul(pStr, (char **)NULL, 10);
23136 + return retVal ;
23137 +}
23138 +
23139 +void dprintf( int uDbgLevel, char * szFmt, ...)
23140 +{
23141 +#ifdef DEBUG_BUILD
23142 + static char buff[256];
23143 + va_list ap;
23144 +
23145 + if( __guDbgLevel < uDbgLevel)
23146 + return;
23147 +
23148 + va_start( ap, szFmt);
23149 + vsprintf((char *)buff, szFmt, ap);
23150 + va_end(ap);
23151 + printk("%s", buff);
23152 +#endif
23153 +}
23154 +
23155 +/*int strcmp(const char *s1, const char *s2)
23156 +{
23157 +
23158 + int i=0;
23159 +
23160 + while(s1[i] !=0)
23161 + {
23162 + if(s2[i]==0)
23163 + return -1;
23164 + if(s1[i] != s2[i])
23165 + return 1;
23166 + i++;
23167 + }
23168 + if(s2[i] != 0)
23169 + return 1;
23170 + return 0;
23171 +}
23172 +*/
23173 +
23174 +int shim_osLoadFWImage(unsigned char *ptr)
23175 +{
23176 + unsigned int bytesRead;
23177 + mm_segment_t oldfs;
23178 + static struct file *filp;
23179 + unsigned int imageLength=0x4ffff;
23180 +
23181 +
23182 + dprintf(4, "tn7dsl_read_dsp()\n");
23183 +
23184 + dprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
23185 +
23186 + filp=filp_open(DSP_FIRMWARE_PATH
23187 + ,00,O_RDONLY);
23188 +
23189 + if(filp ==NULL)
23190 + {
23191 + printk("Failed: Could not open DSP binary file\n");
23192 + return -1;
23193 + }
23194 +
23195 + if (filp->f_op->read==NULL)
23196 + return -1; /* File(system) doesn't allow reads */
23197 +
23198 + /* Now read bytes from postion "StartPos" */
23199 + filp->f_pos = 0;
23200 + oldfs = get_fs();
23201 + set_fs(KERNEL_DS);
23202 + bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
23203 +
23204 + dprintf(4,"file length = %d\n", bytesRead);
23205 +
23206 + set_fs(oldfs);
23207 +
23208 + /* Close the file */
23209 + fput(filp);
23210 +
23211 + return bytesRead;
23212 +}
23213 +
23214 +unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
23215 +{
23216 + unsigned int bytesRead;
23217 + mm_segment_t oldfs;
23218 + struct file *filp;
23219 +
23220 + dprintf(4,"shim_read_overlay_page\n");
23221 + //dprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
23222 +
23223 + filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
23224 + if(filp ==NULL)
23225 + {
23226 + printk("Failed: Could not open DSP binary file\n");
23227 + return -1;
23228 + }
23229 +
23230 + if (filp->f_op->read==NULL)
23231 + return -1; /* File(system) doesn't allow reads */
23232 +
23233 + /* Now read bytes from postion "StartPos" */
23234 +
23235 + if(filp->f_op->llseek)
23236 + filp->f_op->llseek(filp,secOffset, 0);
23237 + oldfs = get_fs();
23238 + set_fs(KERNEL_DS);
23239 + filp->f_pos = secOffset;
23240 + bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
23241 +
23242 + set_fs(oldfs);
23243 + /* Close the file */
23244 + fput(filp);
23245 + return bytesRead;
23246 +}
23247 +
23248 +int shim_osLoadDebugFWImage(unsigned char *ptr)
23249 +{
23250 + return 0;
23251 +}
23252 +int shim_osStringCmp(const char *s1, const char *s2)
23253 +{
23254 + return strcmp(s1, s2);
23255 +}
23256 +
23257 +void *shim_osAllocateMemory(unsigned int size)
23258 +{
23259 + return ((void *)kmalloc(size, GFP_KERNEL));
23260 +}
23261 +
23262 +void *shim_osAllocateDmaMemory(unsigned int size)
23263 +{
23264 + /*
23265 + int order;
23266 +
23267 + order=1;
23268 + size=size/4096;
23269 + while(size >= 1)
23270 + {
23271 + order++;
23272 + size=size/2;
23273 + }
23274 +
23275 + return ( (void *)__get_free_pages(GFP_ATOMIC, order));
23276 + */
23277 + //return ((void *)kmalloc(size, GFP_ATOMIC));
23278 + //return ((void *)kmalloc(size, GFP_KERNEL));
23279 + void *ptr;
23280 +
23281 + ptr = kmalloc(size, GFP_ATOMIC);
23282 + if(ptr==NULL)
23283 + {
23284 + printk("failed atomic\n");
23285 + ptr = kmalloc(size, GFP_KERNEL);
23286 + if(ptr==NULL)
23287 + {
23288 + printk("failed kernel\n");
23289 + ptr = kmalloc(size, GFP_KERNEL|GFP_DMA);
23290 + }
23291 + }
23292 + printk("size=%d\n", size);
23293 + return ptr;
23294 +
23295 +}
23296 +
23297 +
23298 +void shim_osFreeMemory(void *ptr, unsigned int size)
23299 +{
23300 +
23301 + kfree(ptr);
23302 +}
23303 +
23304 +void shim_osFreeDmaMemory(void *ptr, unsigned int size)
23305 +{
23306 +/*
23307 + int order;
23308 +
23309 + order=1;
23310 + size=size/4096;
23311 + while(size >=1)
23312 + {
23313 + order++;
23314 + size=size/2;
23315 + }
23316 + free_pages(ptr, order);
23317 +*/
23318 + kfree(ptr);
23319 +}
23320 +
23321 +void *shim_osAllocateVMemory(unsigned int size)
23322 +{
23323 +
23324 + return ((void *)vmalloc(size));
23325 +}
23326 +
23327 +void shim_osFreeVMemory(void *ptr, unsigned int size)
23328 +{
23329 + vfree(ptr);
23330 +}
23331 +
23332 +void shim_osMoveMemory(char *dst, char *src, unsigned int numBytes)
23333 +{
23334 + memcpy(dst, src, numBytes);
23335 +}
23336 +
23337 +void shim_osZeroMemory(char *dst, unsigned int numBytes)
23338 +{
23339 + memset(dst, 0, numBytes);
23340 +}
23341 +
23342 +void shim_osWriteBackCache(void *addr, unsigned int size)
23343 +{
23344 + unsigned int i,Size=(((unsigned int)addr)&0xf)+size;
23345 +
23346 + for (i=0;i<Size;i+=16,addr+=16)
23347 + {
23348 + __asm__(" .set mips3 ");
23349 + __asm__(" cache 25, (%0)" : : "r" (addr));
23350 + __asm__(" .set mips0 ");
23351 + }
23352 +}
23353 +
23354 +void shim_osInvalidateCache(void *addr, unsigned int size)
23355 +{
23356 + unsigned int i,Size=(((unsigned int)addr)&0xf)+size;
23357 +
23358 + for (i=0;i<Size;i+=16,addr+=16)
23359 + {
23360 + __asm__(" .set mips3 ");
23361 + __asm__("cache 17, (%0)" : : "r" (addr));
23362 + __asm__(" .set mips0 ");
23363 + }
23364 +}
23365 +
23366 +void shim_osClockWait(int val)
23367 +{
23368 + unsigned int chkvalue;
23369 + chkvalue=val/64;
23370 +
23371 + if(chkvalue > 1000)
23372 + {
23373 + mdelay(chkvalue/1000);
23374 + return;
23375 + }
23376 + else
23377 + udelay(val/64);
23378 +} /* end of cwait() */
23379 +
23380 +unsigned int shim_osClockTick(int val)
23381 +{
23382 + return jiffies;
23383 +}
23384 +
23385 +int flags;
23386 +spinlock_t shimLock;
23387 +
23388 +void shim_osCriticalEnter(void)
23389 +{
23390 + spin_lock_irqsave(&shimLock, flags);
23391 +
23392 +}
23393 +
23394 +
23395 +void shim_osCriticalExit(void)
23396 +{
23397 + spin_unlock_irqrestore(&shimLock, flags);
23398 +}
23399 +
23400 +
23401 +int tn7dsl_proc_stats(char* buf, char **start, off_t offset, int count,
23402 + int *eof, void *data)
23403 +{
23404 +
23405 + int len = 0;
23406 + int limit = count - 80;
23407 + int F4count, F5count;
23408 +
23409 +
23410 + /* Read Ax5 Stats */
23411 + dslhal_api_gatherStatistics(pIhw);
23412 +
23413 + if(len<=limit)
23414 + len += sprintf(buf+len, "\nAR7 DSL Modem Statistics:\n");
23415 + if(len<=limit)
23416 + len += sprintf(buf+len, "--------------------------------\n");
23417 + /* us and ds Connection Rates */
23418 + if(len<=limit)
23419 + len += sprintf(buf+len, "[DSL Modem Stats]\n");
23420 +
23421 +
23422 + if(len<=limit)
23423 + {
23424 + if(pIhw->lConnected != 1)
23425 + {
23426 + pIhw->AppData.USConRate = 0;
23427 + pIhw->AppData.DSConRate = 0;
23428 + }
23429 + len += sprintf(buf+len, "\tUS Connection Rate:\t%u\tDS Connection Rate:\t%u\n",
23430 + (unsigned int)pIhw->AppData.USConRate,
23431 + (unsigned int)pIhw->AppData.DSConRate );
23432 + }
23433 + if(len<=limit)
23434 + len += sprintf(buf+len, "\tDS Line Attenuation:\t%u\tDS Margin:\t\t%u\n",
23435 + (unsigned int)pIhw->AppData.dsLineAttn/2,
23436 + (unsigned int)pIhw->AppData.dsMargin/2 );
23437 + if(len<=limit)
23438 + len += sprintf(buf+len, "\tUS Line Attenuation:\t%u\tUS Margin:\t\t%u\n",
23439 + (unsigned int)pIhw->AppData.usLineAttn,
23440 + (unsigned int)pIhw->AppData.usMargin );
23441 + if(len<=limit)
23442 + len += sprintf(buf+len, "\tUS Payload :\t\t%u\tDS Payload:\t\t%u\n",
23443 + ((unsigned int)pIhw->AppData.usAtm_count[0] + (unsigned int)pIhw->AppData.usAtm_count[1])*48,
23444 + ((unsigned int)pIhw->AppData.dsGood_count[0] + (unsigned int)pIhw->AppData.dsGood_count[1])*48);
23445 + /* Superframe Count */
23446 + if(len<=limit)
23447 + len += sprintf(buf+len, "\tUS Superframe Cnt :\t%u\tDS Superframe Cnt:\t%u\n",
23448 + (unsigned int)pIhw->AppData.usSuperFrmCnt,
23449 + (unsigned int)pIhw->AppData.dsSuperFrmCnt );
23450 +
23451 + /* US and DS power */
23452 + if(len<=limit)
23453 + len += sprintf(buf+len, "\tUS Transmit Power :\t%u\tDS Transmit Power:\t%u\n",
23454 + (unsigned int)pIhw->AppData.usTxPower/256,
23455 + (unsigned int)pIhw->AppData.dsTxPower/256 );
23456 + /* DSL Stats Errors*/
23457 + if(len<=limit)
23458 + len += sprintf(buf+len, "\tLOS errors:\t\t%u\tSEF errors:\t\t%u\n",
23459 + (unsigned int)pIhw->AppData.LOS_errors,
23460 + (unsigned int)pIhw->AppData.SEF_errors );
23461 + if(len<=limit)
23462 + len += sprintf(buf+len, "\tFrame mode:\t\t%u\tMax Frame mode:\t\t%u\n",
23463 + (unsigned int)pIhw->AppData.FrmMode,
23464 + (unsigned int)pIhw->AppData.MaxFrmMode );
23465 + if(len<=limit)
23466 + len += sprintf(buf+len, "\tTrained Path:\t\t%u\tUS Peak Cell Rate:\t%u\n",
23467 + (unsigned int)pIhw->AppData.TrainedPath,
23468 + (unsigned int)pIhw->AppData.USConRate*1000/8/53 );
23469 + if(len<=limit)
23470 + len += sprintf(buf+len, "\tTrained Mode:\t\t%u\tSelected Mode:\t\t%u\n",
23471 + (unsigned int)pIhw->AppData.TrainedMode, (unsigned int)pIhw->AppData.StdMode );
23472 +
23473 + if(len<=limit)
23474 + len += sprintf(buf+len, "\tATUC Vendor ID:\t%u\tATUC Revision:\t\t%u\n",
23475 + (unsigned int)pIhw->AppData.atucVendorId, pIhw->AppData.atucRevisionNum);
23476 + if(len<=limit)
23477 + len += sprintf(buf+len, "\tHybrid Selected:\t%u\n",
23478 + (unsigned int)pIhw->AppData.currentHybridNum);
23479 +
23480 + /* Upstream Interleaved Errors */
23481 + if(len<=limit)
23482 + len += sprintf(buf+len, "\n\t[Upstream (TX) Interleave path]\n");
23483 + if(len<=limit)
23484 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23485 + (unsigned int)pIhw->AppData.usICRC_errors,
23486 + (unsigned int)pIhw->AppData.usIFEC_errors,
23487 + (unsigned int)pIhw->AppData.usINCD_error);
23488 + if(len<=limit)
23489 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23490 + (unsigned int)pIhw->AppData.usILCD_errors,
23491 + (unsigned int)pIhw->AppData.usIHEC_errors);
23492 + /* Downstream Interleaved Errors */
23493 + if(len<=limit)
23494 + len += sprintf(buf+len, "\n\t[Downstream (RX) Interleave path]\n");
23495 + if(len<=limit)
23496 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23497 + (unsigned int)pIhw->AppData.dsICRC_errors,
23498 + (unsigned int)pIhw->AppData.dsIFEC_errors,
23499 + (unsigned int)pIhw->AppData.dsINCD_error);
23500 + if(len<=limit)
23501 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23502 + (unsigned int)pIhw->AppData.dsILCD_errors,
23503 + (unsigned int)pIhw->AppData.dsIHEC_errors);
23504 + /* Upstream Fast Errors */
23505 + if(len<=limit)
23506 + len += sprintf(buf+len, "\n\t[Upstream (TX) Fast path]\n");
23507 + if(len<=limit)
23508 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23509 + (unsigned int)pIhw->AppData.usFCRC_errors,
23510 + (unsigned int)pIhw->AppData.usFFEC_errors,
23511 + (unsigned int)pIhw->AppData.usFNCD_error);
23512 + if(len<=limit)
23513 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23514 + (unsigned int)pIhw->AppData.usFLCD_errors,
23515 + (unsigned int)pIhw->AppData.usFHEC_errors);
23516 + /* Downstream Fast Errors */
23517 + if(len<=limit)
23518 + len += sprintf(buf+len, "\n\t[Downstream (RX) Fast path]\n");
23519 + if(len<=limit)
23520 + len += sprintf(buf+len, "\tCRC: \t%u\tFEC: \t%u\tNCD: \t%u\n",
23521 + (unsigned int)pIhw->AppData.dsFCRC_errors,
23522 + (unsigned int)pIhw->AppData.dsFFEC_errors,
23523 + (unsigned int)pIhw->AppData.dsFNCD_error);
23524 + if(len<=limit)
23525 + len += sprintf(buf+len, "\tLCD: \t%u\tHEC: \t%u\n",
23526 + (unsigned int)pIhw->AppData.dsFLCD_errors,
23527 + (unsigned int)pIhw->AppData.dsFHEC_errors);
23528 + /* ATM stats upstream */
23529 + if(len<=limit)
23530 + len += sprintf(buf+len, "\n[ATM Stats]");
23531 + if(len<=limit)
23532 + len += sprintf(buf+len, "\n\t[Upstream/TX]\n");
23533 + if(len<=limit)
23534 + len += sprintf(buf+len, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\n",
23535 + (unsigned int)pIhw->AppData.usAtm_count[0] + (unsigned int)pIhw->AppData.usAtm_count[1],
23536 + (unsigned int)pIhw->AppData.usIdle_count[0] + (unsigned int)pIhw->AppData.usIdle_count[1]);
23537 + /* ATM stats downstream */
23538 + if(len<=limit)
23539 + len += sprintf(buf+len, "\n\t[Downstream/RX)]\n");
23540 + if(len<=limit)
23541 + len += sprintf(buf+len, "\tGood Cell Cnt:\t%u\n\tIdle Cell Cnt:\t%u\n\tBad Hec Cell Cnt:\t%u\n",
23542 + (unsigned int)pIhw->AppData.dsGood_count[0] + (unsigned int)pIhw->AppData.dsGood_count[1],
23543 + (unsigned int)pIhw->AppData.dsIdle_count[0] + (unsigned int)pIhw->AppData.dsIdle_count[1],
23544 + (unsigned int)pIhw->AppData.dsBadHec_count[0] + (unsigned int)pIhw->AppData.dsBadHec_count[1]);
23545 + if(len<=limit)
23546 + len += sprintf(buf+len, "\tOverflow Dropped Cell Cnt:\t%u\n",
23547 + (unsigned int)pIhw->AppData.dsOVFDrop_count[0] + (unsigned int)pIhw->AppData.dsOVFDrop_count[1]);
23548 + tn7sar_get_stats(pIhw->pOsContext);
23549 + if(len<=limit)
23550 + len += sprintf(buf+len, "\n[SAR AAL5 Stats]\n");
23551 + if(len<=limit)
23552 + len += sprintf(buf+len, "\tTx PDU's:\t%u\n\tRx PDU's:\t%u\n",
23553 + sarStat.txPktCnt,
23554 + sarStat.rxPktCnt);
23555 + if(len<=limit)
23556 + len += sprintf(buf+len, "\tTx Total Bytes:\t%u\n\tRx Total Bytes:\t%u\n",
23557 + sarStat.txBytes,
23558 + sarStat.rxBytes);
23559 + if(len<=limit)
23560 + len += sprintf(buf+len, "\tTx Total Error Counts:\t%u\n\tRx Total Error Counts:\t%u\n\n",
23561 + sarStat.txErrors,
23562 + sarStat.rxErrors);
23563 +
23564 + /* oam loopback info */
23565 + if(len<=limit)
23566 + len += sprintf(buf+len, "\n[OAM Stats]\n");
23567 +
23568 + tn7sar_get_near_end_loopback_count(&F4count, &F5count);
23569 +
23570 + if(len<=limit)
23571 + {
23572 + len += sprintf(buf+len, "\tNear End F5 Loop Back Count:\t%u\n\tNear End F4 Loop Back Count:\t%u\n\tFar End F5 Loop Back Count:\t%u\n\tFar End F4 Loop Back Count:\t%u\n",
23573 + F5count,
23574 + F4count,
23575 + oamFarLBCount[0] + oamFarLBCount[2],
23576 + oamFarLBCount[1] + oamFarLBCount[3]);
23577 + }
23578 + return len;
23579 +}
23580 +
23581 +int
23582 +tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,
23583 + int *eof, void *data)
23584 +{
23585 +
23586 + int len = 0;
23587 + int limit = count - 80;
23588 +
23589 + char *state;
23590 + int tag;
23591 +
23592 + tag= dslhal_api_pollTrainingStatus(pIhw);
23593 + tag = pIhw->AppData.bState;
23594 +
23595 + switch(tag){
23596 + case 0: state = "ACTREQ"; break;
23597 + case 1: state = "QUIET1"; break;
23598 + case 2: state = "IDLE"; break;
23599 + case 3: state = "INIT"; break;
23600 + case 4: state = "RTDL"; break;
23601 + case 5: state = "SHOWTIME"; break;
23602 + default: state = "unknown"; break;
23603 + }
23604 +
23605 + if(pIhw->lConnected == 1)
23606 + state = "SHOWTIME";
23607 + if(len<=limit)
23608 + len += sprintf(buf+len,"%s\n",state);
23609 +
23610 + return len;
23611 +}
23612 +
23613 +
23614 +
23615 +int tn7dsl_handle_interrupt(void)
23616 +{
23617 + int intsrc;
23618 + unsigned char cMsgRa[6];
23619 + short margin;
23620 +
23621 + dprintf(4, "tn7dsl_handle_dsl_interrupt()\n");
23622 + if(pIhw)
23623 + {
23624 + intsrc=dslhal_api_acknowledgeInterrupt(pIhw);
23625 + dslhal_api_handleTrainingInterrupt(pIhw, intsrc);
23626 +
23627 + if(pIhw->lConnected == TC_SYNC)
23628 + {
23629 +
23630 + if(dslInSync == 0)
23631 + {
23632 + printk("DSL in Sync\n");
23633 + tn7atm_device_connect_status(pIhw->pOsContext, 1);
23634 + dslhal_api_initStatistics(pIhw);
23635 + dslhal_api_gatherStatistics(pIhw);
23636 +#ifdef CONFIG_LED_MODULE
23637 +// led_operation(MOD_ADSL, DEF_ADSL_SYNC);
23638 + led_on = DEF_ADSL_SYNC;
23639 +#endif
23640 + /* add auto margin retrain */
23641 + if(pIhw->AppData.TrainedMode < 5)
23642 + {
23643 + if(bMarginRetrainEnable && bMarginThConfig == 0)
23644 + {
23645 + dslhal_support_getCMsgsRa(pIhw, cMsgRa);
23646 + margin = *(unsigned short *)&cMsgRa[4];
23647 + margin = (margin >> 6) & 0x3f;
23648 + if(margin & 0x20) // highest bit is 1
23649 + {
23650 + margin = -(margin & 0x1f);
23651 + }
23652 +
23653 + //printk("margin = %d, cmsg-ra = %02x %02x %02x %02x %02x %02x\n", margin, cMsgRa[0],cMsgRa[1],cMsgRa[2],cMsgRa[3],cMsgRa[4],cMsgRa[5]);
23654 + dslhal_api_setMarginThreshold(pIhw, margin*2); /* DSL margin is in 0.5db */
23655 + }
23656 + }
23657 +
23658 + }
23659 + dslInSync = 1;
23660 + }
23661 + else
23662 + {
23663 + if(dslInSync == 1)
23664 + {
23665 + dslInSync = 0;
23666 + tn7atm_device_connect_status(pIhw->pOsContext, 0);
23667 + up(&adsl_sem_overlay);
23668 + printk("DSL out of syn\n");
23669 + }
23670 +#ifdef CONFIG_LED_MODULE
23671 + if(pIhw->AppData.bState < RSTATE_INIT)
23672 + {
23673 + if(led_on != DEF_ADSL_IDLE)
23674 + {
23675 +// led_operation(MOD_ADSL, DEF_ADSL_IDLE);
23676 + led_on = DEF_ADSL_IDLE;
23677 + }
23678 + }
23679 + else
23680 + {
23681 + if(led_on != DEF_ADSL_TRAINING)
23682 + {
23683 +// led_operation(MOD_ADSL, DEF_ADSL_TRAINING);
23684 + led_on = DEF_ADSL_TRAINING;
23685 + }
23686 +
23687 + }
23688 +
23689 +#endif
23690 +
23691 + }
23692 + }
23693 + return 0;
23694 +}
23695 +
23696 +
23697 +int tn7dsl_get_dslhal_version(char *pVer)
23698 +{
23699 + dslVer ver;
23700 +
23701 + dslhal_api_getDslHalVersion(&ver);
23702 +
23703 + memcpy(pVer,&ver,8);
23704 + return 0;
23705 +}
23706 +
23707 +int tn7dsl_get_dsp_version(char *pVer)
23708 +{
23709 + dspVer ver;
23710 + dslhal_api_getDspVersion(pIhw, &ver);
23711 + memcpy(pVer, &ver, 9);
23712 + return 0;
23713 +}
23714 +
23715 +
23716 +static int
23717 +tn7dsl_get_modulation(void)
23718 +{
23719 + char *ptr = NULL;
23720 +
23721 + dprintf(4, "tn7dsl_get_modulation\n");
23722 + //printk("tn7dsl_get_modulation\n");
23723 + ptr = prom_getenv("modulation");
23724 +
23725 + if (!ptr) {
23726 + //printk("modulation is not set in adam2 env\n");
23727 + //printk("Using multimode\n");
23728 + return 0;
23729 + }
23730 + printk("dsl modulation = %s\n", ptr);
23731 +
23732 + tn7dsl_set_modulation(ptr);
23733 +
23734 + return 0;
23735 +}
23736 +
23737 +
23738 +static int tn7dsl_set_dsl(void)
23739 +{
23740 +
23741 + char *ptr = NULL;
23742 + int value;
23743 + int i, offset[2]={4,11},oamFeature=0;
23744 + char tmp[4];
23745 + char dspVer[10];
23746 +
23747 + // OAM Feature Configuration
23748 + dslhal_api_dspInterfaceRead(pIhw,(unsigned int)pIhw->pmainAddr, 2, (unsigned int *)&offset, (unsigned char *)&oamFeature, 4);
23749 + oamFeature |= dslhal_support_byteSwap32(0x0000000C);
23750 + dslhal_api_dspInterfaceWrite(pIhw,(unsigned int)pIhw->pmainAddr, 2, (unsigned int *)&offset, (unsigned char *)&oamFeature, 4);
23751 +
23752 + // modulation
23753 + ptr = prom_getenv("modulation");
23754 + if (ptr)
23755 + {
23756 + printk("dsl modulation = %s\n", ptr);
23757 + tn7dsl_set_modulation(ptr);
23758 + }
23759 +
23760 + // margin retrain
23761 + ptr = NULL;
23762 + ptr = prom_getenv("enable_margin_retrain");
23763 + if(ptr)
23764 + {
23765 + value = os_atoi(ptr);
23766 + if(value == 1)
23767 + {
23768 + dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
23769 + bMarginRetrainEnable = 1;
23770 + printk("enable showtime margin monitor.\n");
23771 + ptr = NULL;
23772 + ptr = prom_getenv("margin_threshold");
23773 + if(ptr)
23774 + {
23775 + value = os_atoi(ptr);
23776 + printk("Set margin threshold to %d x 0.5 db\n",value);
23777 + if(value >= 0)
23778 + {
23779 + dslhal_api_setMarginThreshold(pIhw, value);
23780 + bMarginThConfig=1;
23781 + }
23782 + }
23783 + }
23784 + }
23785 +
23786 + // rate adapt
23787 + ptr = NULL;
23788 + ptr = prom_getenv("enable_rate_adapt");
23789 + if(ptr)
23790 + {
23791 + dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
23792 + }
23793 +
23794 + // trellis
23795 + ptr = NULL;
23796 + ptr = prom_getenv("enable_trellis");
23797 + if(ptr)
23798 + {
23799 + dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
23800 + }
23801 +
23802 + // maximum bits per carrier
23803 + ptr = NULL;
23804 + ptr = prom_getenv("maximum_bits_per_carrier");
23805 + if(ptr)
23806 + {
23807 + dslhal_api_setMaxBitsPerCarrier(pIhw, os_atoi(ptr));
23808 + }
23809 +
23810 + // maximum interleave depth
23811 + ptr = NULL;
23812 + ptr = prom_getenv("maximum_interleave_depth");
23813 + if(ptr)
23814 + {
23815 + dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
23816 + }
23817 +
23818 + // inner and outer pairs
23819 + ptr = NULL;
23820 + ptr = prom_getenv("pair_selection");
23821 + if(ptr)
23822 + {
23823 + dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
23824 + }
23825 +
23826 + ptr = NULL;
23827 + ptr = prom_getenv("dgas_polarity");
23828 + if(ptr)
23829 + {
23830 + dslhal_api_configureDgaspLpr(pIhw, 1, 1);
23831 + dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
23832 + }
23833 +
23834 + ptr = NULL;
23835 + ptr = prom_getenv("los_alarm");
23836 + if(ptr)
23837 + {
23838 + dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
23839 + }
23840 +
23841 + ptr = NULL;
23842 + ptr = prom_getenv("eoc_vendor_id");
23843 + if(ptr)
23844 + {
23845 + for(i=0;i<8;i++)
23846 + {
23847 + tmp[0]=ptr[i*2];
23848 + tmp[1]=ptr[i*2+1];
23849 + tmp[2]=0;
23850 + EOCVendorID[i] = os_atoh(tmp);
23851 + //printk("tmp=%s--", tmp);
23852 + //printk("ID[%d]=0x%02x ", i, (unsigned char)EOCVendorID[i]);
23853 + }
23854 + tn7dsl_get_dsp_version(dspVer);
23855 + //printk("Annex =%d\n", dspVer[8]);
23856 + if(dspVer[8]==2) // annex b
23857 + {
23858 + //printk("EOCVendorID=%02x %02x %02x %02x %02x %02x %02x %02x\n", EOCVendorID[0], EOCVendorID[1], EOCVendorID[2], EOCVendorID[3],
23859 + // EOCVendorID[4], EOCVendorID[5], EOCVendorID[6], EOCVendorID[7]);
23860 + dslhal_api_setEocVendorId(pIhw, EOCVendorID);
23861 + }
23862 +
23863 + }
23864 +
23865 + return 0;
23866 +}
23867 +
23868 +
23869 +
23870 +
23871 +
23872 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23873 + *
23874 + * Function: static void tn7dsl_init(void)
23875 + *
23876 + * Description: This function initializes
23877 + * Ar7 DSL interface
23878 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
23879 +
23880 +int tn7dsl_init(void *priv)
23881 +{
23882 +
23883 + printk("Initializing DSL interface\n");
23884 +
23885 +
23886 + /* start dsl */
23887 + if(dslhal_api_dslStartup(&pIhw) !=0 )
23888 + {
23889 + printk("DSL start failed.\n");
23890 + return -1;
23891 + }
23892 +
23893 + // set dsl into overlay page reload mode
23894 + pIhw->bAutoRetrain = 1;
23895 +
23896 + // set default training properties
23897 + tn7dsl_set_dsl();
23898 +
23899 + pIhw->pOsContext = priv;
23900 +
23901 + //start_kthread(tn7dsl_reload_overlay, &overlay_thread);
23902 +
23903 + /*register dslss LED with led module */
23904 +#ifdef CONFIG_LED_MODULE
23905 + tn7dsl_register_dslss_led();
23906 +#endif
23907 +
23908 +
23909 + return 0; /* What do we return here? */
23910 +}
23911 +
23912 +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23913 + *
23914 + * Function: int avsar_exit(void)
23915 + *
23916 + * Description: Avalanche SAR exit function
23917 + *
23918 + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
23919 +
23920 +void tn7dsl_exit (void)
23921 +{
23922 +
23923 + bshutdown = 1;
23924 +#ifdef CONFIG_LED_MODULE
23925 +#ifdef DEREGISTER_LED
23926 + //down(&adsl_sem_overlay);
23927 + deregister_led_drv(LED_NUM_1);
23928 + deregister_led_drv(LED_NUM_2);
23929 +#else
23930 +// led_operation(MOD_ADSL,DEF_ADSL_IDLE);
23931 +#endif
23932 +#endif
23933 + stop_kthread(&overlay_thread);
23934 + dslhal_api_dslShutdown(pIhw);
23935 +
23936 +}
23937 +
23938 +
23939 +static int tn7dsl_process_oam_string(int *type, int *pvpi, int *pvci, int *pdelay)
23940 +{
23941 + int i=1;
23942 + int j=0;
23943 + int vci, vpi;
23944 + char tmp[16];
23945 + int chan;
23946 + int tt;
23947 +
23948 + while(j<8)
23949 + {
23950 + tmp[j] = mod_req[i];
23951 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23952 + if(tmp[j] == 0x50 || tmp[j] == 0x70)
23953 + break;
23954 + j++;
23955 + i++;
23956 + }
23957 +
23958 + tmp[j] = 0;
23959 + vpi = os_atoi(tmp);
23960 +
23961 + i++;
23962 + j=0;
23963 + while(j<8)
23964 + {
23965 + tmp[j] = mod_req[i];
23966 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23967 + if(tmp[j] == 0x43 || tmp[j] == 0x63)
23968 + break;
23969 +
23970 + j++;
23971 + i++;
23972 + }
23973 +
23974 + vci = os_atoi(tmp);
23975 +
23976 + if(vci==0) // f4 oam
23977 + *type = 1;
23978 + else
23979 + *type = 0;
23980 +
23981 +
23982 + tt=5000;
23983 + i++;
23984 + j=0;
23985 + tmp[j] = mod_req[i];
23986 + if(tmp[j]==0x44 || tmp[j]==0x64)
23987 + {
23988 + i++;
23989 + while(j<8)
23990 + {
23991 + tmp[j] = mod_req[i];
23992 +
23993 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
23994 + if(tmp[j] == 0x54 || tmp[j] == 0x74)
23995 + break;
23996 +
23997 + j++;
23998 + i++;
23999 + }
24000 + tt = os_atoi(tmp);
24001 + }
24002 +
24003 + chan = tn7atm_lut_find(vpi, vci);
24004 +
24005 + *pvci=vci;
24006 + *pvpi=vpi;
24007 + *pdelay =tt;
24008 + dprintf(2, "oam chan=%d, type =%d\n", chan, *type);
24009 +
24010 + return chan;
24011 +}
24012 +
24013 +static void tn7dsl_dump_memory(void)
24014 +{
24015 + unsigned int *pUi;
24016 + int i=1;
24017 + int j=0;
24018 + int addr, len;
24019 + char tmp[16];
24020 +
24021 +
24022 + while(j<8)
24023 + {
24024 + tmp[j] = mod_req[i];
24025 + j++;
24026 + i++;
24027 + }
24028 +
24029 + tmp[j] = 0;
24030 +
24031 + addr = os_atoh(tmp);
24032 +
24033 + printk("start dump address =0x%x\n", addr);
24034 + pUi = (unsigned int *)addr;
24035 + i++;
24036 + j=0;
24037 + while(j<8)
24038 + {
24039 + tmp[j] = mod_req[i];
24040 + //printk("tmp[%d]=%c, %d\n", j, tmp[j], tmp[j]);
24041 + if(tmp[j] == 0x43 || tmp[j] == 0x63)
24042 + break;
24043 +
24044 + j++;
24045 + i++;
24046 + }
24047 +
24048 + len = os_atoi(tmp);
24049 + j=0;
24050 + for(i=0; i<len; i++)
24051 + {
24052 + if(j==0)
24053 + printk("0x%08x: ", (unsigned int)pUi);
24054 + printk("%08x ", *pUi);
24055 + pUi++;
24056 + j++;
24057 + if(j==4)
24058 + {
24059 + printk("\n");
24060 + j=0;
24061 + }
24062 + }
24063 +
24064 +}
24065 +
24066 +
24067 +
24068 +static int dslmod_sysctl(ctl_table *ctl, int write, struct file * filp,
24069 + void *buffer, size_t *lenp)
24070 +{
24071 + char *ptr;
24072 + int ret, len = 0;
24073 + int chan;
24074 + int type;
24075 + int vpi,vci,timeout;
24076 +
24077 + if (!*lenp || (filp->f_pos && !write)) {
24078 + *lenp = 0;
24079 + return 0;
24080 + }
24081 + /* DSL MODULATION is changed */
24082 + if(write)
24083 + {
24084 + ret = proc_dostring(ctl, write, filp, buffer, lenp);
24085 +
24086 + switch (ctl->ctl_name)
24087 + {
24088 + case DEV_DSLMOD:
24089 + ptr = strpbrk(info, " \t");
24090 + strcpy(mod_req, info);
24091 +
24092 + /* parse the string to determine the action */
24093 + if(mod_req[0] == 0x45 || mod_req[0] == 0x65 ) // 'e', or 'E' f5 end to end
24094 + {
24095 + chan = tn7dsl_process_oam_string(&type, &vpi, &vci, &timeout);
24096 + tn7sar_oam_generation(pIhw->pOsContext, chan, type, vpi, vci, timeout);
24097 + }
24098 + else if(mod_req[0] == 0x53 || mod_req[0] == 0x73 ) // 's', or 'S' f5 seg to seg
24099 + {
24100 + chan=tn7dsl_process_oam_string(&type, &vpi, &vci,&timeout);
24101 + type = type | (1<<1);
24102 + tn7sar_oam_generation(pIhw->pOsContext, chan, type, vpi, vci,timeout);
24103 + }
24104 + //debug only. Dump memory
24105 + else if(mod_req[0] == 0x44 || mod_req[0] == 0x64 ) // 'd' or 'D'
24106 + tn7dsl_dump_memory();
24107 + else
24108 + tn7dsl_chng_modulation(info);
24109 + break;
24110 + }
24111 + }
24112 + else
24113 + {
24114 + len += sprintf(info+len, mod_req);
24115 + ret = proc_dostring(ctl, write, filp, buffer, lenp);
24116 + }
24117 + return ret;
24118 +}
24119 +
24120 +
24121 +ctl_table dslmod_table[] = {
24122 + {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl},
24123 + {0}
24124 + };
24125 +
24126 +/* Make sure that /proc/sys/dev is there */
24127 +ctl_table dslmod_root_table[] = {
24128 +#ifdef CONFIG_PROC_FS
24129 + {CTL_DEV, "dev", NULL, 0, 0555, dslmod_table},
24130 +#endif /* CONFIG_PROC_FS */
24131 + {0}
24132 + };
24133 +
24134 +static struct ctl_table_header *dslmod_sysctl_header;
24135 +
24136 +void tn7dsl_dslmod_sysctl_register(void)
24137 +{
24138 + static int initialized;
24139 +
24140 + if (initialized == 1)
24141 + return;
24142 +
24143 + dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
24144 + dslmod_root_table->child->de->owner = THIS_MODULE;
24145 +
24146 + /* set the defaults */
24147 + info[0] = 0;
24148 +
24149 + initialized = 1;
24150 +}
24151 +
24152 +void tn7dsl_dslmod_sysctl_unregister(void)
24153 +{
24154 + unregister_sysctl_table(dslmod_sysctl_header);
24155 +}
24156 +
24157 +static void
24158 +tn7dsl_set_modulation(void* data)
24159 +{
24160 + dprintf(4,"tn7dsl_set_modulation\n");
24161 +
24162 + if(!strcmp(data, "T1413"))
24163 + {
24164 + printk("retraining in T1413 mode\n");
24165 + dslhal_api_setTrainingMode(pIhw, T1413_MODE);
24166 + return;
24167 + }
24168 + if(!strcmp(data, "GDMT"))
24169 + {
24170 + dslhal_api_setTrainingMode(pIhw, GDMT_MODE);
24171 + return;
24172 + }
24173 + if(!strcmp(data, "GLITE"))
24174 + {
24175 + dslhal_api_setTrainingMode(pIhw, GLITE_MODE);
24176 + return;
24177 + }
24178 + if(!strcmp(data, "MMODE"))
24179 + {
24180 + dslhal_api_setTrainingMode(pIhw, MULTI_MODE);
24181 + return;
24182 + }
24183 + if(!strcmp(data, "NMODE"))
24184 + {
24185 + dslhal_api_setTrainingMode(pIhw, NO_MODE);
24186 + return;
24187 + }
24188 +
24189 + return;
24190 +}
24191 +
24192 +
24193 +/* Codes added for compiling tiadiag.o for Analog Diagnostic tests */
24194 +#ifdef ADIAG
24195 +
24196 +enum
24197 +{
24198 + HOST_ACTREQ, // Send R-ACKREQ and monitor for C-ACKx
24199 + HOST_QUIET, // Sit quietly doing nothing for about 60 seconds, DEFAULT STATE; R_IDLE
24200 + HOST_XMITBITSWAP, // Perform upstream bitswap - FOR INTERNAL USE ONLY
24201 + HOST_RCVBITSWAP, // Perform downstream bitswap - FOR INTERNAL USE ONLY
24202 + HOST_RTDLPKT, // Send a remote download packet - FOR INTERNAL USE ONLY
24203 + HOST_CHANGELED, // Read the LED settings and change accordingly
24204 + HOST_IDLE, // Sit quiet
24205 + HOST_REVERBTEST, // Generate REVERB for manufacturing test
24206 + HOST_CAGCTEST, // Set coarse receive gain for manufacturing test
24207 + HOST_DGASP, // send Dying Gasp messages through EOC channel
24208 + HOST_GHSREQ, // G.hs - FOR INTERNAL USE ONLY
24209 + HOST_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
24210 + HOST_GHS_SENDGALF, // G.hs - FOR INTERNAL USE ONLY
24211 + HOST_GHSEXIT, // G.hs - FOR INTERNAL USE ONLY
24212 + HOST_GHSMSG1, // G.hs - FOR INTERNAL USE ONLY
24213 + HOST_HYBRID, // Enable/Disable automatic hybrid switch
24214 + HOST_RJ11SELECT, // RJ11 inner/outer pair select
24215 + HOST_DIGITAL_MEM, // Digital Diags: run external memory tests
24216 + HOST_TXREVERB, // AFE Diags: TX path Reverb
24217 + HOST_TXMEDLEY, // AFE Diags: TX path Medley
24218 + HOST_RXNOISEPOWER, // AFE Diags: RX noise power
24219 + HOST_ECPOWER, // AFE Diags: RX eco power
24220 + HOST_ALL_ADIAG, // AFE Diags: all major analog diagnostic modes. Host is responsible to initiate each diagnostic sessions
24221 + HOST_USER_ADIAG, // AFE Diags: Host fills in analog diagnostic input data structure as specified and requests DSP to perform measurements as specified
24222 + HOST_QUIT_ADIAG, // AFE Diags: Host requests DSP to quit current diagnostic session. This is used for stopping the transmit REVERB/MEDLEY
24223 + HOST_NO_CMD, // All others - G.hs - FOR INTERNAL USE ONLY
24224 + HOST_DSLSS_SHUTDOWN, // Host initiated DSLSS shutdown message
24225 + HOST_SET_GENERIC, // Set generic CO profile
24226 + HOST_UNDO_GENERIC // Set profile previous to Generic
24227 +};
24228 +
24229 +enum
24230 +{
24231 + DSP_IDLE, // R_IDLE state entered
24232 + DSP_ACTMON, // R_ACTMON state entered
24233 + DSP_TRAIN, // R_TRAIN state entered
24234 + DSP_ACTIVE, // R_ACTIVE state entered
24235 + DSP_XMITBITSWAP, // Upstream bitswap complete - FOR INTERNAL USE ONLY
24236 + DSP_RCVBITSWAP, // Downstream bitswap complete - FOR INTERNAL USE ONLY
24237 + DSP_RTDL, // R_RTDL state entered - FOR INTERNAL USE ONLY
24238 + DSP_RRTDLPKT, // RTDL packet received - FOR INTERNAL USE ONLY
24239 + DSP_XRTDLPKT, // RTDL packet transmitted - FOR INTERNAL USE ONLY
24240 + DSP_ERROR, // Command rejected, wrong state for this command
24241 + DSP_REVERBTEST, // Manufacturing REVERB test mode entered
24242 + DSP_CAGCTEST, // Manufacturing receive gain test done
24243 + DSP_OVERLAY_START, // Notify host that page overlay has started - overlay number indicated by "tag"
24244 + DSP_OVERLAY_END, // Notify host that page overlay has ended - overlay number indicated by "tag"
24245 + DSP_CRATES1, // CRATES1 message is valid and should be copied to host memory now
24246 + DSP_SNR, // SNR calculations are ready and should be copied to host memory now
24247 + DSP_GHSMSG, // G.hs - FOR INTERNAL USE ONLY
24248 + DSP_RCVBITSWAP_TIMEOUT, // Acknowledge Message was not received within ~500 msec (26 Superframes).
24249 + DSP_ATM_TC_SYNC, // Indicates true TC sync on both the upstream and downstream. Phy layer ready for data xfer.
24250 + DSP_ATM_NO_TC_SYNC, // Indicates loss of sync on phy layer on either US or DS.
24251 + DSP_HYBRID, // DSP completed hybrid switch
24252 + DSP_RJ11SELECT, // DSP completed RJ11 inner/outer pair select
24253 + DSP_INVALID_CMD, // Manufacturing (Digital and AFE) diags: CMD received not recognized
24254 + DSP_TEST_PASSED, // Manufacturing diags: test passed
24255 + DSP_TEST_FAILED, // Manufacturing diags: test failed
24256 + DSP_TXREVERB, // Manufacturing AFE diags: Response to HOST_TXREVERB
24257 + DSP_TXMEDLEY, // Manufacturing AFE diags: Response to HOST_TXMEDLEY
24258 + DSP_RXNOISEPOWER, // Manufacturing AFE diags: Response to HOST_RXNOISEPOWER
24259 + DSP_ECPOWER, // Manufacturing AFE diags: Response to HOST_ECPOWER
24260 + DSP_ALL_ADIAG, // Manufacturing AFE diags: Response to HOST_ALL_ADIAG
24261 + DSP_USER_ADIAG, // Manufacturing AFE diags: Response to HOST_USER_ADIAG
24262 + DSP_QUIT_ADIAG, // Manufacturing AFE diags: Response to HOST_QUIT_ADIAG
24263 + DSP_DGASP // DSP Message to indicate dying gasp
24264 +};
24265 +
24266 +static unsigned char analogNoTonesTestArray[64]=
24267 + {
24268 + 0,0,0,0,0,0,0,0, // Tones 01-08
24269 + 0,0,0,0,0,0,0,0, // Tones 09-16
24270 + 0,0,0,0,0,0,0,0, // Tones 17-24
24271 + 0,0,0,0,0,0,0,0, // Tones 25-32
24272 + 0,0,0,0,0,0,0,0, // Tones 33-40
24273 + 0,0,0,0,0,0,0,0, // Tones 41-48
24274 + 0,0,0,0,0,0,0,0, // Tones 49-56
24275 + 0,0,0,0,0,0,0,0 // Tones 57-64
24276 + };
24277 +
24278 +static unsigned char analogAllTonesTestArray[64]=
24279 + {
24280 + 1,1,1,1,1,1,1,1, // Tones 01-08
24281 + 1,1,1,1,1,1,1,1, // Tones 09-16
24282 + 1,1,1,1,1,1,1,1, // Tones 17-24
24283 + 1,1,1,1,1,1,1,1, // Tones 25-32
24284 + 1,1,1,1,1,1,1,1, // Tones 33-40
24285 + 1,1,1,1,1,1,1,1, // Tones 41-48
24286 + 1,1,1,1,1,1,1,1, // Tones 49-56
24287 + 1,1,1,1,1,1,1,1 // Tones 57-64
24288 + };
24289 +
24290 +static unsigned char analogEvenTonesTestArray[64]=
24291 + {
24292 + 0,1,0,1,0,1,0,1, // Tones 01-08
24293 + 0,1,0,1,0,1,0,1, // Tones 09-16
24294 + 0,1,0,1,0,1,0,1, // Tones 17-24
24295 + 0,1,0,1,0,1,0,1, // Tones 25-32
24296 + 0,1,0,1,0,1,0,1, // Tones 33-40
24297 + 0,1,0,1,0,1,0,1, // Tones 41-48
24298 + 0,1,0,1,0,1,0,1, // Tones 49-56
24299 + 0,1,0,1,0,1,0,1 // Tones 57-64
24300 + };
24301 +
24302 +static unsigned char analogOddTonesTestArray[64]=
24303 + {
24304 + 1,0,1,0,1,0,1,0, // Tones 01-08
24305 + 1,0,1,0,1,0,1,0, // Tones 09-16
24306 + 1,0,1,0,1,0,1,0, // Tones 17-24
24307 + 1,0,1,0,1,0,1,0, // Tones 25-32
24308 + 1,0,1,0,1,0,1,0, // Tones 33-40
24309 + 1,0,1,0,1,0,1,0, // Tones 41-48
24310 + 1,0,1,0,1,0,1,0, // Tones 49-56
24311 + 1,0,1,0,1,0,1,0 // Tones 57-64
24312 + };
24313 +
24314 +unsigned int shim_osGetCpuFrequency(void)
24315 +{
24316 + return 150;
24317 +}
24318 +
24319 +static void tn7dsl_adiag(int Test, unsigned char *missingTones)
24320 +{
24321 + int rc,cmd, tag;
24322 +
24323 + rc = dslhal_diags_anlg_setMissingTones(pIhw,missingTones);
24324 + if(rc)
24325 + {
24326 + printk(" failed to set Missing town\n");
24327 + return;
24328 + }
24329 +
24330 +/*********** Start the actual test **********************/
24331 +
24332 + if(Test==0)
24333 + {
24334 + printk("TX REVERB Test\n");
24335 + rc = dslhal_support_writeHostMailbox(pIhw, HOST_TXREVERB, 0, 0, 0);
24336 + if (rc)
24337 + {
24338 + printk("HOST_TXREVERB failed\n");
24339 + return;
24340 + }
24341 +
24342 + }
24343 + if(Test==1)
24344 + {
24345 + dprintf(0,"TX MEDLEY Test\n");
24346 + rc = dslhal_support_writeHostMailbox(pIhw, HOST_TXMEDLEY, 0, 0, 0);
24347 + if (rc)
24348 + return;
24349 + }
24350 + dprintf(4,"dslhal_diags_anlg_testA() done\n");
24351 + return;
24352 +}
24353 +
24354 +
24355 +static void tn7dsl_diagnostic_test(char *data)
24356 +{
24357 + if(!strcmp(data, "ADIAGRALL"))
24358 + {
24359 + printk("TX Reverb All tone\n");
24360 + tn7dsl_adiag(0,analogAllTonesTestArray);
24361 + return;
24362 + }
24363 + if(!strcmp(data, "ADIAGRNONE"))
24364 + {
24365 + printk("TX Reverb No tone\n");
24366 + tn7dsl_adiag(0,analogNoTonesTestArray);
24367 + return;
24368 + }
24369 + if(!strcmp(data, "ADIAGREVEN"))
24370 + {
24371 + printk("TX Reverb Even tone\n");
24372 + tn7dsl_adiag(0,analogEvenTonesTestArray);
24373 + return;
24374 + }
24375 + if(!strcmp(data, "ADIAGRODD"))
24376 + {
24377 + printk("TX Reverb Odd tone\n");
24378 + tn7dsl_adiag(0,analogOddTonesTestArray);
24379 + return;
24380 + }
24381 + if(!strcmp(data, "ADIAGMALL"))
24382 + {
24383 + printk("TX Mdelay All tone\n");
24384 + tn7dsl_adiag(1,analogAllTonesTestArray);
24385 + return;
24386 + }
24387 + if(!strcmp(data, "ADIAGMNONE"))
24388 + {
24389 + printk("TX Mdelay No tone\n");
24390 + tn7dsl_adiag(1,analogNoTonesTestArray);
24391 + return;
24392 + }
24393 + if(!strcmp(data, "ADIAGMEVEN"))
24394 + {
24395 + printk("TX Mdelay Even tone\n");
24396 + tn7dsl_adiag(1,analogEvenTonesTestArray);
24397 + return;
24398 + }
24399 + if(!strcmp(data, "ADIAGMODD"))
24400 + {
24401 + printk("TX Mdelay Odd tone\n");
24402 + tn7dsl_adiag(1,analogOddTonesTestArray);
24403 + return;
24404 + }
24405 + if(!strcmp(data, "ADIAGQUIET"))
24406 + {
24407 + dslhal_api_sendIdle(pIhw);
24408 + return;
24409 + }
24410 + if(!strncmp(data, "ADIAGRN", 7))
24411 + {
24412 + char tones[64], tmp[4];
24413 + int nth, i;
24414 +
24415 + tmp[0]=data[7];
24416 + tmp[1]=data[8];
24417 + tmp[2]=data[9];
24418 +
24419 + nth = os_atoi(tmp);
24420 +
24421 + for(i=0;i<64;i++)
24422 + {
24423 + if(((i+1)% nth)==0)
24424 + {
24425 + tones[i]=0;
24426 + }
24427 + else
24428 + {
24429 + tones[i]=1;
24430 + }
24431 + }
24432 + printk("TX Reverb with %dth tones missing.\n", nth);
24433 + tn7dsl_adiag(0,tones);
24434 + return;
24435 + }
24436 + if(!strncmp(data, "ADIAGMN", 7))
24437 + {
24438 + char tones[64], tmp[4];
24439 + int nth, i;
24440 +
24441 + tmp[0]=data[7];
24442 + tmp[1]=data[8];
24443 + tmp[2]=data[9];
24444 + nth = os_atoi(tmp);
24445 +
24446 + for(i=0;i<64;i++)
24447 + {
24448 + if(((i+1)% nth)==0)
24449 + {
24450 + tones[i]=0;
24451 + }
24452 + else
24453 + {
24454 + tones[i]=1;
24455 + }
24456 + }
24457 + printk("TX Mdelay with %dth tones missing.\n", nth);
24458 + tn7dsl_adiag(1,tones);
24459 + return;
24460 + }
24461 +
24462 +
24463 +}
24464 +
24465 +#endif
24466 +
24467 +static void
24468 +tn7dsl_chng_modulation(void* data)
24469 +{
24470 + //printk("DSL Modem Retraining\n");
24471 +
24472 + if(!strcmp(data, "T1413"))
24473 + {
24474 + printk("retraining in T1413 mode\n");
24475 + dslhal_api_setTrainingMode(pIhw, T1413_MODE);
24476 + dslhal_api_sendQuiet(pIhw);
24477 + return;
24478 + }
24479 + if(!strcmp(data, "GDMT"))
24480 + {
24481 + dslhal_api_setTrainingMode(pIhw, GDMT_MODE);
24482 + dslhal_api_sendQuiet(pIhw);
24483 + return;
24484 + }
24485 + if(!strcmp(data, "GLITE"))
24486 + {
24487 + dslhal_api_setTrainingMode(pIhw, GLITE_MODE);
24488 + dslhal_api_sendQuiet(pIhw);
24489 + return;
24490 + }
24491 + if(!strcmp(data, "MMODE"))
24492 + {
24493 + dslhal_api_setTrainingMode(pIhw, MULTI_MODE);
24494 + dslhal_api_sendQuiet(pIhw);
24495 + return;
24496 + }
24497 + if(!strcmp(data, "NMODE"))
24498 + {
24499 + dslhal_api_setTrainingMode(pIhw, NO_MODE);
24500 + dslhal_api_sendQuiet(pIhw);
24501 + return;
24502 + }
24503 +
24504 +#ifdef ADIAG
24505 + tn7dsl_diagnostic_test(data);
24506 +#endif
24507 +
24508 +
24509 + return;
24510 +}
24511 +
24512 +#ifdef CONFIG_LED_MODULE
24513 +static void tn7dsl_led_on(unsigned long parm)
24514 +{
24515 + dslhal_api_configureLed(pIhw,parm, 0);
24516 +}
24517 +
24518 +
24519 +static void tn7dsl_led_off(unsigned long parm)
24520 +{
24521 + dslhal_api_configureLed(pIhw,parm, 1);
24522 +}
24523 +
24524 +static void tn7dsl_led_init(unsigned long parm)
24525 +{
24526 + dslhal_api_configureLed(pIhw,parm, 2);
24527 +}
24528 +#endif
24529 +
24530 +static void tn7dsl_register_dslss_led(void)
24531 +{
24532 +#ifdef CONFIG_LED_MODULE
24533 +
24534 + // register led0 with led module
24535 + ledreg[0].param = 0;
24536 + ledreg[0].init = (void *)tn7dsl_led_init;
24537 + ledreg[0].onfunc = (void *)tn7dsl_led_on;
24538 + ledreg[0].offfunc = (void *)tn7dsl_led_off;
24539 + register_led_drv(LED_NUM_1, &ledreg[0]);
24540 +
24541 + // register led1 output with led module
24542 + ledreg[1].param = 1;
24543 + ledreg[1].init = (void *)tn7dsl_led_init;
24544 + ledreg[1].onfunc = (void *)tn7dsl_led_on;
24545 + ledreg[1].offfunc = (void *)tn7dsl_led_off;
24546 + register_led_drv(LED_NUM_2, &ledreg[1]);
24547 +#endif
24548 +}
24549 +
24550 +static int tn7dsl_reload_overlay(void)
24551 +{
24552 + int overlayFlag;
24553 + spinlock_t overlayLock;
24554 +
24555 + init_kthread(&overlay_thread, "adsl");
24556 + down(&adsl_sem_overlay);
24557 + while(1)
24558 + {
24559 + mdelay(500);
24560 + if(pIhw->lConnected == 0)
24561 + {
24562 + spin_lock_irqsave(&overlayLock, overlayFlag);
24563 + dslhal_support_restoreTrainingInfo(pIhw);
24564 + spin_unlock_irqrestore(&overlayLock, overlayFlag);
24565 + }
24566 + down(&adsl_sem_overlay);
24567 + }
24568 + return 0;
24569 +}
24570 +
24571 +
24572 +
24573 +
24574 diff -urN linux.old/drivers/atm/sangam_atm/tn7sar.c linux.dev/drivers/atm/sangam_atm/tn7sar.c
24575 --- linux.old/drivers/atm/sangam_atm/tn7sar.c 1970-01-01 01:00:00.000000000 +0100
24576 +++ linux.dev/drivers/atm/sangam_atm/tn7sar.c 2005-08-23 04:46:50.110841720 +0200
24577 @@ -0,0 +1,1376 @@
24578 +/******************************************************************************
24579 + * FILE PURPOSE: OS files for CPSAR
24580 + ******************************************************************************
24581 + * FILE NAME: tn7sar.c
24582 + *
24583 + * DESCRIPTION: This file contains source for required os files for CPSAR
24584 + *
24585 + * (C) Copyright 2002, Texas Instruments Inc
24586 + *
24587 + *
24588 + * Revision History:
24589 + * 0/11/02 Zhicheng Tang, created.
24590 + *
24591 + *******************************************************************************/
24592 +
24593 +#include <linux/config.h>
24594 +#include <linux/kernel.h>
24595 +#include <linux/module.h>
24596 +#include <linux/init.h>
24597 +#include <linux/atmdev.h>
24598 +#include <linux/delay.h>
24599 +#include <linux/spinlock.h>
24600 +#include <linux/smp_lock.h>
24601 +#include <asm/io.h>
24602 +#include <asm/mips-boards/prom.h>
24603 +#include <linux/proc_fs.h>
24604 +#include <linux/string.h>
24605 +#include <linux/ctype.h>
24606 +
24607 +
24608 +#define _CPHAL_AAL5
24609 +#define _CPHAL_SAR
24610 +#define _CPHAL_HAL
24611 +typedef void OS_PRIVATE;
24612 +typedef void OS_DEVICE;
24613 +typedef void OS_SENDINFO;
24614 +typedef void OS_RECEIVEINFO;
24615 +typedef void OS_SETUP;
24616 +
24617 +#include "cpswhal_cpsar.h"
24618 +#include "tn7atm.h"
24619 +#include "tn7api.h"
24620 +
24621 +
24622 +/* PDSP Firmware files */
24623 +#include "tnetd7300_sar_firm.h"
24624 +
24625 +
24626 +enum
24627 +{
24628 + PACKET_TYPE_AAL5,
24629 + PACKET_TYPE_NULL,
24630 + PACKET_TYPE_OAM,
24631 + PACKET_TYPE_TRANS,
24632 + PACKET_TYPE_AAL2
24633 +}PACKET_TYPE;
24634 +
24635 +enum
24636 +{
24637 + OAM_PING_FAILED,
24638 + OAM_PING_SUCCESS,
24639 + OAM_PING_PENDING,
24640 + OAM_PING_NOT_STARTED
24641 +}OAM_PING;
24642 +
24643 +/* PDSP OAM General Purpose Registers (@todo: These need to be used in the HAL!) */
24644 +
24645 +#define SAR_PDSP_HOST_OAM_CONFIG_REG_ADDR 0xa3000020
24646 +#define SAR_PDSP_OAM_CORR_REG_ADDR 0xa3000024
24647 +#define SAR_PDSP_OAM_LB_RESULT_REG_ADDR 0xa3000028
24648 +#define SAR_PDSP_OAM_F5LB_COUNT_REG_ADDR 0xa300002c
24649 +#define SAR_PDSP_OAM_F4LB_COUNT_REG_ADDR 0xa3000030
24650 +
24651 +#define SAR_FREQUNCY 50000000
24652 +
24653 +#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
24654 +#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
24655 +#define RESET_PARM "id=ResetControl, base=0xA8611600"
24656 +#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
24657 +
24658 +#define MAX_PVC_TABLE_ENTRY 16
24659 +
24660 +sar_stat_t sarStat;
24661 +
24662 +typedef struct _channel_parm
24663 +{
24664 + unsigned int RxBufSize;
24665 + unsigned int RxNumBuffers;
24666 + unsigned int RxServiceMax;
24667 + unsigned int TxServiceMax;
24668 + unsigned int TxNumBuffers;
24669 + unsigned int CpcsUU;
24670 + unsigned int TxVc_CellRate;
24671 + unsigned int TxVc_AtmHeader;
24672 +}channel_parm_t;
24673 +
24674 +typedef struct _aal5_parm
24675 +{
24676 + unsigned int base;
24677 + unsigned int offset;
24678 + unsigned int int_line;
24679 + channel_parm_t chan[8];
24680 +}aal5_parm_t;
24681 +
24682 +
24683 +typedef struct _sar_parm
24684 +{
24685 + unsigned int base;
24686 + unsigned int reset_bit;
24687 + unsigned int offset;
24688 + unsigned int UniNni;
24689 +}sar_parm_t;
24690 +
24691 +typedef struct _pvc_table
24692 +{
24693 + int bInUse;
24694 + int vpi;
24695 + int vci;
24696 +}pvc_table;
24697 +
24698 +static aal5_parm_t aal5Parm;
24699 +static sar_parm_t sarParm;
24700 +static char *pAal5, *pSar, *pReset;
24701 +static int oam_type;
24702 +static unsigned int oamPingStatus;
24703 +static int oamAtmHdr;
24704 +static int oamLbTimeout;
24705 +static char parm_data[1024];
24706 +static char aal5Data[1024];
24707 +static char sarData[1024];
24708 +static char resetData[256];
24709 +static pvc_table pvc_result[MAX_PVC_TABLE_ENTRY];
24710 +
24711 +/* external function */
24712 +extern int __guDbgLevel;
24713 +
24714 +/* gloabal function */
24715 +unsigned int oamFarLBCount[4];
24716 +/* end of gloabal function */
24717 +
24718 +/* internal APIs */
24719 +static int tn7sar_atm_header(int vpi, int vci);
24720 +static void tn7sar_record_pvc(int atmheader);
24721 +
24722 +/*end of internal APIs */
24723 +spinlock_t sar_lock;
24724 +
24725 +/* HAL OS support functions */
24726 +
24727 +
24728 +unsigned long tn7sar_strtoul(const char *str, char **endptr, int base)
24729 +{
24730 + unsigned long ret;
24731 +
24732 + ret= simple_strtoul(str, endptr, base);
24733 + return ret;
24734 +}
24735 +
24736 +static void *tn7sar_malloc(unsigned int size)
24737 +{
24738 + return(kmalloc(size, GFP_KERNEL));
24739 +}
24740 +
24741 +static unsigned long lockflags;
24742 +static void tn7sar_critical_on(void)
24743 +{
24744 + spin_lock_irqsave(&sar_lock,lockflags);
24745 +}
24746 +
24747 +static void tn7sar_critical_off(void)
24748 +{
24749 + spin_unlock_irqrestore(&sar_lock,lockflags);
24750 +}
24751 +
24752 +static void tn7sar_data_invalidate(void *pmem, int size)
24753 +{
24754 + unsigned int i,Size=(((unsigned int)pmem)&0xf)+size;
24755 +
24756 + for (i=0;i<Size;i+=16,pmem+=16)
24757 + {
24758 + __asm__(" .set mips3 ");
24759 + __asm__("cache 17, (%0)" : : "r" (pmem));
24760 + __asm__(" .set mips0 ");
24761 + }
24762 +
24763 +}
24764 +
24765 +static void tn7sar_data_writeback(void *pmem, int size)
24766 +{
24767 + unsigned int i,Size=(((unsigned int)pmem)&0xf)+size;
24768 +
24769 + for (i=0;i<Size;i+=16,pmem+=16)
24770 + {
24771 + __asm__(" .set mips3 ");
24772 + __asm__(" cache 25, (%0)" : : "r" (pmem));
24773 + __asm__(" .set mips0 ");
24774 + }
24775 +}
24776 +
24777 +
24778 +static int
24779 +tn7sar_find_device(int unit, const char *find_name, void *device_info)
24780 +{
24781 + int ret_val = 0;
24782 + char **ptr;
24783 +
24784 + ptr = (char **)device_info;
24785 + dprintf(3,"tn7sar_find_device\n");
24786 + if(strcmp(find_name, "aal5")==0)
24787 + {
24788 + //dprintf(4,"pAal5=%s\n", pAal5);
24789 + *ptr = pAal5;
24790 + }
24791 + else if(strcmp(find_name, "sar")==0)
24792 + {
24793 + dprintf(3, "pSar=%s\n", pSar);
24794 + *ptr = pSar;
24795 + }
24796 + else if(strcmp(find_name, "reset")==0)
24797 + {
24798 + dprintf(3, "pReset=%s\n", pReset);
24799 + *ptr = pReset;
24800 + }
24801 +
24802 + device_info = NULL;
24803 +
24804 + return(ret_val);
24805 +}
24806 +
24807 +static int
24808 +tn7sar_get_device_parm_uint(void *dev_info, const char *param, unsigned int *value)
24809 +{
24810 + char *dev_str;
24811 + char *pMatch;
24812 + int i=0, j=0;
24813 + char val_str[64];
24814 + unsigned int val;
24815 + int base = 10;
24816 +
24817 + dprintf(6, "tn7sar_get_device_parm_uint()\n");
24818 +
24819 + dev_str = (char *)dev_info;
24820 + dprintf(3, "parm=%s\n", param);
24821 + pMatch = strstr(dev_str, param);
24822 + //dprintf(4, "pMatch=%s\n", pMatch);
24823 + if(pMatch)
24824 + {
24825 + //get "=" position
24826 + while(pMatch[i] != 0x3d)
24827 + {
24828 + i++;
24829 + }
24830 + i++;
24831 + // get rid of spaces
24832 + while(pMatch[i]==0x20)
24833 + {
24834 + i++;
24835 + }
24836 + //get rid of 0x
24837 + if(pMatch[i]==0x30)
24838 + {
24839 + if(pMatch[i+1] == 0x58 || pMatch[i+1] == 0x78)
24840 + {
24841 + i+=2;
24842 + base = 16;
24843 + }
24844 + }
24845 +
24846 + // get next delineator
24847 + while(pMatch[i] != 0x2c && pMatch[i] != 0x0)
24848 + {
24849 + val_str[j]=pMatch[i];
24850 + j++;
24851 + i++;
24852 + }
24853 + val_str[j]=0;
24854 + //dprintf(4, "val_str=\n%s\n", val_str);
24855 + //xdump(val_str, strlen(val_str) + 1, 4);
24856 + val = simple_strtoul(val_str, (char **)NULL, base);
24857 + dprintf(4, "val =%d\n", val);
24858 + *value = val;
24859 + return 0;
24860 + }
24861 +
24862 +
24863 + dprintf(3, "match not found.\n");
24864 + if(strcmp(dev_str, "debug")==0)
24865 + {
24866 + dprintf(6,"debug..\n");
24867 + *value = 6;
24868 + return 0;
24869 + }
24870 + return (1);
24871 +}
24872 +
24873 +static int tn7sar_get_device_parm_value(void *dev_info, const char *param, void *value)
24874 +{
24875 + char *dev_str;
24876 + char *pMatch;
24877 + int i=0, j=0;
24878 + char *pVal;
24879 +
24880 +
24881 + dprintf(3, "tn7sar_get_device_parm_value().\n");
24882 +
24883 + pVal = (char *) parm_data;
24884 + dev_str = (char *)dev_info;
24885 + dprintf(3, "dev_info: \n%s\n", dev_str);
24886 + dprintf(3, "param=%s\n", param);
24887 + if(strcmp(param, "Ch0")==0)
24888 + {
24889 + *(char **)value = CH0_PARM;
24890 + dprintf(3, "value =%s\n", *(char **)value);
24891 + return 0;
24892 + }
24893 +
24894 + pMatch = strstr(dev_str, param);
24895 + if(pMatch)
24896 + {
24897 + //get "=" position
24898 + while(pMatch[i] != 0x3d)
24899 + {
24900 + i++;
24901 + }
24902 + i++;
24903 + // get rid of spaces
24904 + while(pMatch[i]==0x20)
24905 + {
24906 + i++;
24907 + }
24908 +
24909 + if(pMatch[i] != 0x5b) //"["
24910 + {
24911 + // get next delineator
24912 + while(pMatch[i] != 0x2c && pMatch[i] != 0x0)
24913 + {
24914 + pVal[j] = pMatch[i];
24915 + j++;
24916 + i++;
24917 + }
24918 + pVal[j]=0;
24919 +
24920 + *(char **)value = pVal;
24921 + return 0;
24922 + }
24923 + else
24924 + {
24925 + i++; //skip "["
24926 + while(pMatch[i] != 0x5d)
24927 + {
24928 + if(pMatch[i] == 0x3b) //";"
24929 + pVal[j] = 0x2c;
24930 + else
24931 + pVal[j] = pMatch[i];
24932 + j++;
24933 + i++;
24934 + }
24935 + pVal[j] = 0;
24936 + *(char **)value = pVal;
24937 + return 0;
24938 + }
24939 +
24940 + }
24941 +
24942 + return (1);
24943 +}
24944 +
24945 +static void tn7sar_free(void *pmem)
24946 +{
24947 + kfree(pmem);
24948 +}
24949 +
24950 +static void
24951 +tn7sar_free_buffer(OS_RECEIVEINFO *os_receive_info, void *pmem)
24952 +{
24953 + tn7atm_free_rx_skb(os_receive_info);
24954 +}
24955 +
24956 +static void tn7sar_free_dev(void *pmem)
24957 +{
24958 + kfree(pmem);
24959 +}
24960 +
24961 +static void tn7sar_free_dma_xfer(void *pmem)
24962 +{
24963 + kfree(pmem);
24964 +}
24965 +
24966 +
24967 +static int
24968 +tn7sar_control(void *dev_info, const char *key, const char *action, void *value)
24969 +{
24970 + int ret_val = -1;
24971 +
24972 + if (strcmp(key, "Firmware") == 0)
24973 + {
24974 + if (strcmp(action, "Get") == 0)
24975 + {
24976 + *(int **)value = &SarPdspFirmware[0];
24977 + }
24978 + ret_val=0;
24979 + }
24980 +
24981 + if (strcmp(key, "FirmwareSize") == 0)
24982 + {
24983 + if (strcmp(action, "Get") == 0)
24984 + {
24985 + *(int *)value = sizeof(SarPdspFirmware);
24986 + }
24987 + ret_val=0;
24988 + }
24989 +
24990 + if (strcmp(key, "OamLbResult") == 0)
24991 + {
24992 + dprintf(2, "get looback source call back\n");
24993 + if (strcmp(action, "Set") == 0)
24994 + {
24995 + dprintf(2, "oam result = %d\n", *(unsigned int *)value);
24996 + oamFarLBCount[oam_type] = oamFarLBCount[oam_type] + *(unsigned int *)value;
24997 + if(oamPingStatus == OAM_PING_PENDING)
24998 + {
24999 + oamPingStatus = *(unsigned int *)value;
25000 + if(oamPingStatus == OAM_PING_SUCCESS)
25001 + {
25002 + /* record pvc */
25003 + tn7sar_record_pvc(oamAtmHdr);
25004 + }
25005 + }
25006 +
25007 + }
25008 + ret_val=0;
25009 + }
25010 +
25011 + if (strcmp(key, "SarFreq") == 0)
25012 + {
25013 + if (strcmp(action, "Get") == 0)
25014 + {
25015 + *(int *)value = SAR_FREQUNCY;
25016 + }
25017 + ret_val=0;
25018 + }
25019 + return(ret_val);
25020 +}
25021 +
25022 +
25023 +static void
25024 +tn7sar_sarhal_isr_register(OS_DEVICE *os_dev, int(*hal_isr)(HAL_DEVICE *, int *), int interrupt_num)
25025 +{
25026 + tn7atm_sarhal_isr_register(os_dev, hal_isr, interrupt_num);
25027 +}
25028 +
25029 +static void
25030 +tn7sar_isr_unregister(OS_DEVICE *os_dev, int interrupt_num)
25031 +{
25032 + /* TODO */
25033 +}
25034 +
25035 +
25036 +static void *
25037 +tn7sar_malloc_rxbuffer(unsigned int size, void *mem_base, unsigned int mem_range, HAL_DEVICE *hal_dev,
25038 + HAL_RECEIVEINFO *hal_info, OS_RECEIVEINFO **os_receive_info, OS_DEVICE *os_dev)
25039 +{
25040 + return tn7atm_allocate_rx_skb(os_dev, os_receive_info, size);
25041 +}
25042 +
25043 +static void *
25044 +tn7sar_malloc_dev(unsigned int size)
25045 +{
25046 + return(kmalloc(size, GFP_KERNEL));
25047 +}
25048 +
25049 +static void *
25050 +tn7sar_malloc_dma_xfer(unsigned int size, void *mem_base, unsigned int mem_range)
25051 +{
25052 + dprintf(4, "tn7sar_malloc_dma_xfer, size =%d\n", size);
25053 +
25054 + return (kmalloc(size, GFP_DMA |GFP_KERNEL));
25055 +
25056 +}
25057 +
25058 +static void *
25059 +tn7sar_memset(void *dst, int set_char, size_t count)
25060 +{
25061 + return (memset(dst, set_char, count));
25062 +}
25063 +
25064 +static int tn7sar_printf(const char *format, ...)
25065 +{
25066 + /* TODO: add debug levels */
25067 + static char buff[256];
25068 + va_list ap;
25069 +
25070 + va_start( ap, format);
25071 + vsprintf((char *)buff, format, ap);
25072 + va_end(ap);
25073 +
25074 + printk("SAR HAL: %s\n", buff);
25075 + return(0);
25076 +}
25077 +
25078 +static void tn7sar_record_pvc(int atmheader)
25079 +{
25080 + int vci,vpi;
25081 + int i;
25082 +
25083 + vci = 0xffff & (atmheader >> 4);
25084 + vpi = 0xff & (atmheader >> 20);
25085 + for(i=0;i<MAX_PVC_TABLE_ENTRY;i++)
25086 + {
25087 + if(pvc_result[i].bInUse)
25088 + {
25089 + if(pvc_result[i].vpi == vpi && pvc_result[i].vci == vci)
25090 + {
25091 + return;
25092 + }
25093 + }
25094 + }
25095 + for(i=0;i<MAX_PVC_TABLE_ENTRY;i++)
25096 + {
25097 + if(pvc_result[i].bInUse == 0)
25098 + {
25099 + pvc_result[i].bInUse = 1;
25100 + pvc_result[i].vpi = vpi;
25101 + pvc_result[i].vci = vci;
25102 + return;
25103 + }
25104 + }
25105 + return;
25106 +}
25107 +
25108 +static void tn7sar_clear_pvc_table(void)
25109 +{
25110 + int i;
25111 +
25112 + for(i=0;i<MAX_PVC_TABLE_ENTRY; i++)
25113 + {
25114 + pvc_result[i].bInUse = 0;
25115 + pvc_result[i].vpi = 0;
25116 + pvc_result[i].vci = 0;
25117 + }
25118 +}
25119 +
25120 +int tn7sar_process_unmatched_oam(FRAGLIST *frag_list, unsigned int frag_count, unsigned int packet_size, unsigned int mode)
25121 +{
25122 +
25123 + FRAGLIST *local_list;
25124 + int i;
25125 + unsigned int atmHdr;
25126 +
25127 + local_list = frag_list;
25128 +
25129 + for(i=0;i<(int)frag_count;i++)
25130 + {
25131 + tn7sar_data_invalidate(local_list->data, (int)local_list->len);
25132 + local_list ++;
25133 + }
25134 + local_list = frag_list;
25135 + if((mode>>31)) /*vci, vpi is attached */
25136 + {
25137 + atmHdr = *(unsigned int *)frag_list->data;
25138 + tn7sar_record_pvc(atmHdr);
25139 + if(atmHdr & 0x8) //oam cell
25140 + {
25141 + atmHdr &= 0xfffffff0;
25142 + if(atmHdr == oamAtmHdr)
25143 + {
25144 + if(oamPingStatus == OAM_PING_PENDING)
25145 + {
25146 + oamPingStatus = OAM_PING_SUCCESS;
25147 + oamFarLBCount[oam_type] = oamFarLBCount[oam_type] + 1;
25148 + }
25149 + return 0;
25150 + }
25151 + }
25152 + }
25153 +
25154 + return 0;
25155 +}
25156 +
25157 +
25158 +static int
25159 +tn7sar_receive(OS_DEVICE *os_dev,FRAGLIST *frag_list, unsigned int frag_count, unsigned int packet_size,
25160 + HAL_RECEIVEINFO *hal_receive_info, unsigned int mode)
25161 +{
25162 + int ch;
25163 + struct atm_dev *dev;
25164 + Tn7AtmPrivate *priv;
25165 + HAL_FUNCTIONS *pHalFunc;
25166 + HAL_DEVICE *pHalDev;
25167 + int bRet;
25168 +
25169 +
25170 + dprintf(4, "tn7sar_receive\n");
25171 +
25172 + dev = (struct atm_dev *)os_dev;
25173 + priv= (Tn7AtmPrivate *)dev->dev_data;
25174 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25175 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25176 +
25177 +
25178 + /* Mode contains channel info */
25179 + ch = (mode & 0xFF);
25180 +
25181 + if(ch == 15)
25182 + {
25183 + tn7sar_process_unmatched_oam(frag_list, frag_count, packet_size, mode);
25184 + pHalFunc->RxReturn(hal_receive_info, 0);
25185 + return 0;
25186 + }
25187 +
25188 + if(frag_count > 1 || frag_list->len == 0)
25189 + {
25190 + printk("Packet fragment count > 1, not handdle.\n");
25191 + return 1;
25192 + }
25193 +
25194 + tn7sar_data_invalidate(frag_list->data, (int)frag_list->len);
25195 + bRet=tn7atm_receive(os_dev, ch, packet_size, frag_list->OsInfo, frag_list->data);
25196 +
25197 + if(bRet==0)
25198 + {
25199 + sarStat.rxPktCnt++;
25200 + sarStat.rxBytes += packet_size;
25201 + pHalFunc->RxReturn(hal_receive_info, 1);
25202 + }
25203 + else
25204 + {
25205 + pHalFunc->RxReturn(hal_receive_info, 0);
25206 + }
25207 +
25208 + return bRet;
25209 +}
25210 +
25211 +static int
25212 +tn7sar_send_complete(OS_SENDINFO *osSendInfo)
25213 +{
25214 + return (tn7atm_send_complete(osSendInfo));
25215 +}
25216 +
25217 +void
25218 +tn7sar_teardown_complete(OS_DEVICE *OsDev, int ch, int Dir)
25219 +{
25220 + return;
25221 +}
25222 +
25223 +
25224 +/*
25225 +unsigned int tn7sar_virt(unsigned int address)
25226 +{
25227 + return phys_to_virt(address);
25228 +}
25229 +*/
25230 +
25231 +int tn7sar_init_module(OS_FUNCTIONS *os_funcs)
25232 +{
25233 + dprintf(4, "tn7sar_init_module\n");
25234 + if( os_funcs == 0 )
25235 + {
25236 + return(-1);
25237 + }
25238 + os_funcs->Control = tn7sar_control;
25239 + os_funcs->CriticalOn = tn7sar_critical_on;
25240 + os_funcs->CriticalOff = tn7sar_critical_off;
25241 + os_funcs->DataCacheHitInvalidate = tn7sar_data_invalidate;
25242 + os_funcs->DataCacheHitWriteback = tn7sar_data_writeback;
25243 + os_funcs->DeviceFindInfo = tn7sar_find_device;
25244 + os_funcs->DeviceFindParmUint = tn7sar_get_device_parm_uint;
25245 + os_funcs->DeviceFindParmValue = tn7sar_get_device_parm_value;
25246 + os_funcs->Free = tn7sar_free;
25247 + os_funcs->FreeRxBuffer = tn7sar_free_buffer;
25248 + os_funcs->FreeDev = tn7sar_free_dev;
25249 + os_funcs->FreeDmaXfer = tn7sar_free_dma_xfer;
25250 + os_funcs->IsrRegister = tn7sar_sarhal_isr_register;
25251 + os_funcs->IsrUnRegister = tn7sar_isr_unregister;
25252 + os_funcs->Malloc = tn7sar_malloc;
25253 + os_funcs->MallocRxBuffer = tn7sar_malloc_rxbuffer;
25254 + os_funcs->MallocDev = tn7sar_malloc_dev;
25255 + os_funcs->MallocDmaXfer = tn7sar_malloc_dma_xfer;
25256 + os_funcs->Memset = tn7sar_memset;
25257 + os_funcs->Printf = tn7sar_printf;
25258 + os_funcs->Receive = tn7sar_receive;
25259 + os_funcs->SendComplete = tn7sar_send_complete;
25260 + os_funcs->Strcmpi = strcmp;
25261 + os_funcs->Sprintf = sprintf;
25262 + os_funcs->Strlen = strlen;
25263 + os_funcs->Strstr = strstr;
25264 + os_funcs->Strtoul = tn7sar_strtoul;
25265 + os_funcs->TeardownComplete = tn7sar_teardown_complete;
25266 +
25267 + return(0);
25268 +}
25269 +
25270 +
25271 +static void tn7sar_init_dev_parm(void)
25272 +{
25273 + int i;
25274 +
25275 +
25276 + /* aal5 */
25277 + //strcpy(aal5Parm.id, "aal5");
25278 + aal5Parm.base = 0x03000000;
25279 + aal5Parm.offset = 0;
25280 + aal5Parm.int_line=15;
25281 + aal5Parm.chan[0].RxBufSize=1600;
25282 + aal5Parm.chan[0].RxNumBuffers = 32;
25283 + aal5Parm.chan[0].RxServiceMax = 50;
25284 + aal5Parm.chan[0].TxServiceMax=50;
25285 + aal5Parm.chan[0].TxNumBuffers=32;
25286 + aal5Parm.chan[0].CpcsUU=0x5aa5;
25287 + aal5Parm.chan[0].TxVc_CellRate=0x3000;
25288 + aal5Parm.chan[0].TxVc_AtmHeader=0x00000640;
25289 + for(i=1;i<8;i++)
25290 + {
25291 + memcpy(&aal5Parm.chan[i], &aal5Parm.chan[0], sizeof(aal5Parm.chan[0]));
25292 + }
25293 +
25294 +
25295 + /* sar */
25296 + //strcpy(sarParm.id, "sar");
25297 + sarParm.base = 0x03000000;
25298 + sarParm.reset_bit = 9;
25299 + sarParm.offset = 0;
25300 + sarParm.UniNni = 0;
25301 +
25302 + pAal5 = aal5Data;
25303 + pSar = sarData;
25304 + pReset = resetData;
25305 + strcpy(pAal5, AAL5_PARM);
25306 + strcpy(pSar, SAR_PARM);
25307 + strcpy(pReset, RESET_PARM);
25308 +
25309 +}
25310 +
25311 +
25312 +int tn7sar_get_stats(void *priv1)
25313 +{
25314 + HAL_FUNCTIONS *pHalFunc;
25315 + HAL_DEVICE *pHalDev;
25316 + Tn7AtmPrivate *priv;
25317 + int i, j;
25318 + unsigned int *pSarStat, *pStateBase;
25319 + char statString[64];
25320 + int len;
25321 +
25322 + dprintf(2, "tn7sar_get_stats\n");
25323 +
25324 + priv = (Tn7AtmPrivate *)priv1;
25325 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25326 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25327 +
25328 + //memset(&sarStat, 0, sizeof(sarStat));
25329 + sarStat.txErrors = 0;
25330 + sarStat.rxErrors = 0;
25331 + for(i=0;i<MAX_DMA_CHAN;i++)
25332 + {
25333 + if(priv->lut[i].inuse)
25334 + {
25335 + for(j=0;j<1;j++)
25336 + {
25337 + len=sprintf(statString, "Stats;0;%d", priv->lut[i].chanid);
25338 + statString[len]=0;
25339 + dprintf(2, "statString=%s\n",statString);
25340 + pHalFunc->Control(pHalDev, statString, "Get", &pSarStat);
25341 + pStateBase = pSarStat;
25342 + while(pSarStat)
25343 + {
25344 + if((char *)*pSarStat == NULL)
25345 + break;
25346 + dprintf(2, "%s\n", (char *) *pSarStat);
25347 + pSarStat++;
25348 + dprintf(2, "%s\n", (char *) *pSarStat);
25349 + sarStat.rxErrors += os_atoul((char *) *pSarStat);
25350 + pSarStat++;
25351 + }
25352 +
25353 + kfree(pStateBase);
25354 + }
25355 + }
25356 + }
25357 + return 0;
25358 +}
25359 +
25360 +int tn7sar_setup_oam_channel(Tn7AtmPrivate *priv)
25361 +{
25362 +
25363 + CHANNEL_INFO chInfo;
25364 + HAL_FUNCTIONS *pHalFunc;
25365 + HAL_DEVICE *pHalDev;
25366 + int chan=15;
25367 + dprintf(4, "tn7sar_setup_oam_channel\n");
25368 +
25369 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25370 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25371 +
25372 + memset(&chInfo, 0xff, sizeof(chInfo));
25373 +
25374 + /* channel specific */
25375 + chInfo.Channel = 15; /* hardcoded for last channel */
25376 + chInfo.Direction = 0;
25377 + chInfo.Vci = 30; /* just need below 32 */
25378 + chInfo.Vpi = 0;
25379 + chInfo.TxVc_QosType = 2;
25380 +
25381 + /*default */
25382 + chInfo.PktType = PACKET_TYPE_TRANS;
25383 + chInfo.TxServiceMax = 2;
25384 + chInfo.RxServiceMax = 2;
25385 + chInfo.TxNumQueues = 1;
25386 + chInfo.TxNumBuffers = 4;
25387 + chInfo.RxNumBuffers = 4;
25388 + chInfo.RxBufSize = 256;
25389 + chInfo.RxVc_OamToHost = 0;
25390 + chInfo.RxVp_OamToHost = 0;
25391 + chInfo.FwdUnkVc = 1; //enable forwarding of unknown vc
25392 + chInfo.TxVc_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, chInfo.Vci);
25393 + chInfo.RxVc_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, chInfo.Vci);
25394 + chInfo.TxVp_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, 0);
25395 + chInfo.RxVp_AtmHeader = tn7sar_atm_header((int)chInfo.Vpi, 0);
25396 +
25397 + dprintf(4, "TxVc_AtmHeader=0x%x\n", chInfo.TxVc_AtmHeader);
25398 +
25399 + if(pHalFunc->ChannelSetup(pHalDev, &chInfo, NULL))
25400 + {
25401 + printk("failed to setup channel =%d.\n", chan);
25402 + return -1;
25403 + }
25404 +
25405 + // claiming the channel
25406 + priv->lut[chan].vpi = 0;
25407 + priv->lut[chan].vci = 30;
25408 + priv->lut[chan].chanid = chan;
25409 + priv->lut[chan].inuse = 1;
25410 + return 0;
25411 +}
25412 +
25413 +int tn7sar_init(struct atm_dev *dev, Tn7AtmPrivate *priv)
25414 +{
25415 + int retCode;
25416 + int hal_funcs_size;
25417 +
25418 + HAL_FUNCTIONS *pHalFunc;
25419 + HAL_DEVICE *pHalDev;
25420 + OS_FUNCTIONS *pOsFunc;
25421 + int oamMod;
25422 + char *pLbTimeout;
25423 + int lbTimeout;
25424 +
25425 +
25426 + dprintf(4, "tn7sar_init\n");
25427 +
25428 + pOsFunc = (OS_FUNCTIONS *)kmalloc(sizeof(OS_FUNCTIONS), GFP_KERNEL);
25429 +
25430 +
25431 + priv->pSarOsFunc = ( void *)pOsFunc;
25432 +
25433 + /* init boot parms */
25434 + tn7sar_init_dev_parm();
25435 +
25436 + /* init sar os call back functions */
25437 + retCode = tn7sar_init_module(pOsFunc);
25438 + if (retCode != 0) /* error */
25439 + {
25440 + printk("Failed to init SAR OS Functions\n");
25441 + return (1);
25442 + }
25443 +
25444 + /* Init sar hal */
25445 + retCode = cpaal5InitModule(&pHalDev, (OS_DEVICE*) dev, &pHalFunc,
25446 + pOsFunc, sizeof(OS_FUNCTIONS), &hal_funcs_size, 0);
25447 + if (retCode != 0) /* error */
25448 + {
25449 + printk("Failed to init SAR HAL\n");
25450 + return (1);
25451 + }
25452 +
25453 + /* sanity check */
25454 + if (pHalDev == NULL || pHalFunc == NULL || hal_funcs_size != sizeof(HAL_FUNCTIONS) )
25455 + {
25456 + printk("Invalid SAR hal and/or functions.\n");
25457 + return (1);
25458 + }
25459 +
25460 + /* remeber HAL pointers */
25461 + priv->pSarHalDev = (void *)pHalDev;
25462 + priv->pSarHalFunc = (void *)pHalFunc;
25463 +
25464 + /* Probe for the Device to get hardware info from driver */
25465 + retCode = pHalFunc->Probe(pHalDev);
25466 + if (retCode !=0)
25467 + {
25468 + printk("SAR hal probing error.\n");
25469 + return (1);
25470 + }
25471 +
25472 + /* init sar hal */
25473 + retCode = pHalFunc->Init(pHalDev);
25474 + if (retCode != 0) /* error */
25475 + {
25476 +
25477 + printk("pHalFunc->Init failed. err code =%d\n", retCode);
25478 + return (1);
25479 + }
25480 +
25481 + /* open hal module */
25482 + retCode = pHalFunc->Open(pHalDev);
25483 + if (retCode != 0) /* error */
25484 + {
25485 + printk("pHalFunc->open failed, err code: %d\n",retCode );
25486 + return (1);
25487 + }
25488 +
25489 + /* init sar for firmware oam */
25490 + oamMod= 1;
25491 + pHalFunc->Control(pHalDev,"OamMode", "Set", &oamMod);
25492 +
25493 + /* read in oam lb timeout value */
25494 + pLbTimeout = prom_getenv("oam_lb_timeout");
25495 + if(pLbTimeout)
25496 + {
25497 + lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
25498 + oamLbTimeout = lbTimeout;
25499 + pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
25500 + }
25501 + else
25502 + {
25503 + oamLbTimeout = 5000;
25504 + }
25505 +
25506 + oamFarLBCount[0]=0;
25507 + oamFarLBCount[1]=0;
25508 + oamFarLBCount[2]=0;
25509 + oamFarLBCount[3]=0;
25510 +
25511 + memset(&sarStat, 0 , sizeof(sarStat));
25512 +
25513 + /* setup channel 15 for oam operation */
25514 + tn7sar_setup_oam_channel(priv);
25515 + dprintf(4, "tn7sar_init done");
25516 + return 0;
25517 +}
25518 +
25519 +static int
25520 +tn7sar_atm_header(int vpi, int vci)
25521 +{
25522 + union
25523 + {
25524 + unsigned char byte[4];
25525 + unsigned int dword;
25526 + }atm_h;
25527 + int itmp = 0;
25528 +
25529 + //vci
25530 + itmp = vci &0xf;
25531 + atm_h.byte[0] = 0;
25532 + atm_h.byte[0] |= (itmp << 4);
25533 + atm_h.byte[1] = ((vci & 0xff0) >> 4);
25534 + atm_h.byte[2] = 0;
25535 + atm_h.byte[2] |= ((vci & 0xf000) >>12);;
25536 + atm_h.byte[2] |= ((vpi & 0xf) << 4);
25537 + atm_h.byte[3] = 0;
25538 + atm_h.byte[3] = ((vpi & 0xff0) >> 4);
25539 + return atm_h.dword;
25540 +}
25541 +
25542 +int tn7sar_activate_vc(Tn7AtmPrivate *priv, short vpi, int vci, int pcr, int scr, int mbs, int cdvt, int chan, int qos)
25543 +{
25544 + CHANNEL_INFO chInfo;
25545 + HAL_FUNCTIONS *pHalFunc;
25546 + HAL_DEVICE *pHalDev;
25547 +
25548 + dprintf(4, "tn7sar_activate_vc\n");
25549 +
25550 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25551 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25552 +
25553 + memset(&chInfo, 0xff, sizeof(chInfo));
25554 +
25555 + /* channel specific */
25556 + chInfo.Channel = chan;
25557 + chInfo.Direction = 0;
25558 + chInfo.Vci = vci;
25559 + chInfo.Vpi = vpi;
25560 + chInfo.TxVc_QosType = qos;
25561 + chInfo.Priority = qos;
25562 +
25563 + if(chInfo.TxVc_QosType == 1) /* if the connection is VBR than set the DaMask value to tell the schedular to accumalte the credit */
25564 + {
25565 + chInfo.DaMask = 1;
25566 + }
25567 + chInfo.TxVc_Mbs = mbs; /* use pcr as MBS */
25568 + pcr = SAR_FREQUNCY/pcr;
25569 + scr = SAR_FREQUNCY/scr;
25570 + chInfo.TxVc_CellRate = scr;
25571 + chInfo.TxVc_Pcr = pcr;
25572 +
25573 + /*default */
25574 + chInfo.PktType = PACKET_TYPE_AAL5;
25575 + chInfo.TxServiceMax = TX_SERVICE_MAX;
25576 + chInfo.RxServiceMax = RX_SERVICE_MAX;
25577 + chInfo.TxNumQueues = TX_QUEUE_NUM;
25578 + chInfo.TxNumBuffers = TX_BUFFER_NUM;
25579 + chInfo.RxNumBuffers = RX_BUFFER_NUM;
25580 + chInfo.RxBufSize = RX_BUFFER_SIZE;
25581 + chInfo.RxVc_OamToHost = 0;
25582 + chInfo.RxVp_OamToHost = 0;
25583 + chInfo.TxVc_AtmHeader = tn7sar_atm_header((int)vpi, vci);
25584 + chInfo.RxVc_AtmHeader = tn7sar_atm_header((int)vpi, vci);
25585 + chInfo.TxVp_AtmHeader = tn7sar_atm_header((int)vpi, 0);
25586 + chInfo.RxVp_AtmHeader = tn7sar_atm_header((int)vpi, 0);
25587 + chInfo.CpcsUU = 0;
25588 +
25589 + dprintf(4, "TxVc_AtmHeader=0x%x\n", chInfo.TxVc_AtmHeader);
25590 +
25591 + if(pHalFunc->ChannelSetup(pHalDev, &chInfo, NULL))
25592 + {
25593 + printk("failed to setup channel =%d.\n", chan);
25594 + return -1;
25595 + }
25596 +
25597 +
25598 + return 0;
25599 +}
25600 +
25601 +int tn7sar_send_packet(Tn7AtmPrivate *priv, int chan, void *new_skb, void *data,unsigned int len, int priority)
25602 +{
25603 + FRAGLIST fragList;
25604 + unsigned int mode;
25605 + HAL_FUNCTIONS *pHalFunc;
25606 + HAL_DEVICE *pHalDev;
25607 +
25608 + dprintf(4, "tn7sar_send_packet\n");
25609 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25610 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25611 +
25612 + fragList.len = len;
25613 + fragList.data = (void *)data;
25614 +
25615 + xdump((char *)fragList.data , fragList.len, 6);
25616 +
25617 + /*mode bit
25618 + 31-19 unused
25619 + 18 oam cell, 1 = true, 0=false
25620 + 17-16 oam type, 0=F4 seg, 1=F4 End, 2=F5 seg, 3=F5 end
25621 + 15-08 transimit queue, current, 0=priority queue, 1=normal queue
25622 + 07-00 channel number
25623 + */
25624 + mode = 0;
25625 + mode |= (0xff & chan);
25626 + mode |= ((0xff & priority) << 8);
25627 +
25628 + dprintf(4, "mode = %d\n", mode);
25629 +
25630 + tn7sar_data_writeback(fragList.data, len);
25631 + if(pHalFunc->Send(pHalDev, &fragList, 1, len, new_skb, mode) != 0)
25632 + {
25633 + dprintf(1, "SAR hal failed to send packet.\n");
25634 + return 1;
25635 + }
25636 + //tn7sar_get_stats(priv);
25637 + sarStat.txPktCnt++;
25638 + sarStat.txBytes +=len;
25639 + return 0;
25640 +}
25641 +
25642 +
25643 +
25644 +int tn7sar_handle_interrupt(struct atm_dev *dev, Tn7AtmPrivate *priv)
25645 +{
25646 + int more;
25647 + int rc;
25648 + HAL_FUNCTIONS *pHalFunc;
25649 + HAL_DEVICE *pHalDev;
25650 + int (*halIsr)(HAL_DEVICE *halDev, int *work);
25651 +
25652 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25653 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25654 + halIsr = priv->halIsr;
25655 +
25656 + rc = halIsr(pHalDev, &more);
25657 +
25658 + pHalFunc->PacketProcessEnd(pHalDev);
25659 +
25660 + return rc;
25661 +}
25662 +
25663 +
25664 +int tn7sar_deactivate_vc(Tn7AtmPrivate *priv, int chan)
25665 +{
25666 + unsigned int mode;
25667 + HAL_FUNCTIONS *pHalFunc;
25668 + HAL_DEVICE *pHalDev;
25669 +
25670 + dprintf(4, "tn7sar_deactivate_vc\n");
25671 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25672 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25673 +
25674 + mode = 0xf; //tear down everything, wait for return;
25675 +
25676 + pHalFunc->ChannelTeardown(pHalDev, chan, mode);
25677 + return 0;
25678 +}
25679 +
25680 +void tn7sar_exit(struct atm_dev *dev, Tn7AtmPrivate *priv)
25681 +{
25682 + HAL_FUNCTIONS *pHalFunc;
25683 + HAL_DEVICE *pHalDev;
25684 +
25685 + dprintf(4, "tn7sar_exit()\n");
25686 +
25687 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25688 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25689 +
25690 + tn7sar_deactivate_vc(priv, 15); // de-activate oam channel
25691 +
25692 + pHalFunc->Close(pHalDev, 2);
25693 + pHalFunc->Shutdown(pHalDev);
25694 +
25695 + kfree(priv->pSarOsFunc);
25696 +
25697 +}
25698 +
25699 +void tn7sar_get_sar_version(Tn7AtmPrivate *priv, char **pVer)
25700 +{
25701 + HAL_FUNCTIONS *pHalFunc;
25702 + HAL_DEVICE *pHalDev;
25703 +
25704 + dprintf(4, "tn7sar_get_sar_version()\n");
25705 +
25706 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25707 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25708 + pHalFunc->Control(pHalDev, "Version", "Get", pVer);
25709 +}
25710 +
25711 +
25712 +int tn7sar_get_near_end_loopback_count(unsigned int *pF4count, unsigned int *pF5count)
25713 +{
25714 + unsigned int f4c, f5c;
25715 +
25716 + f4c = *(volatile unsigned int *)SAR_PDSP_OAM_F4LB_COUNT_REG_ADDR;
25717 + f5c = *(volatile unsigned int *)SAR_PDSP_OAM_F5LB_COUNT_REG_ADDR;
25718 + *pF4count = f4c;
25719 + *pF5count = f5c;
25720 +
25721 + return 0;
25722 +}
25723 +
25724 +
25725 +int tn7sar_unmatched_oam_generation(void *privContext, int vpi, int vci, int type)
25726 +{
25727 +
25728 + unsigned int regv = 0;
25729 + int chan=15;
25730 + static unsigned int tag;
25731 + HAL_FUNCTIONS *pHalFunc;
25732 + HAL_DEVICE *pHalDev;
25733 + Tn7AtmPrivate *priv;
25734 + unsigned int llid[4]={0xffffffff,0xffffffff,0xffffffff,0xffffffff};
25735 +
25736 + dprintf(4, "tn7sar_unknow_oam_generation()\n");
25737 +
25738 + priv = (Tn7AtmPrivate *)privContext;
25739 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25740 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25741 +
25742 + if(vci==0)
25743 + {
25744 + oamPingStatus = OAM_PING_FAILED;
25745 + return 0;
25746 + }
25747 + /* calculate atm header */
25748 + oamAtmHdr = tn7sar_atm_header(vpi,vci);
25749 +
25750 + /* config the atm header */
25751 + pHalFunc->Control(pHalDev,"TxVc_AtmHeader.15", "Set", &oamAtmHdr);
25752 +
25753 + /*record oam type */
25754 + oam_type = type;
25755 +
25756 + regv = (0xff & chan);
25757 +
25758 + switch(type)
25759 + {
25760 + case 0:
25761 + regv |= (1<<12); //f5 end
25762 + dprintf(2, "f5 loop back\n");
25763 + break;
25764 + case 1:
25765 + regv |= (1<<13); // f4 end
25766 + break;
25767 + case 2:
25768 + regv |= (1<<14); //f5 seg
25769 + break;
25770 + case 3:
25771 + regv |= (1<<15); //f4 seg
25772 + break;
25773 + default:
25774 + break;
25775 + }
25776 + oamPingStatus = OAM_PING_PENDING;
25777 + pHalFunc->OamLoopbackConfig(pHalDev, regv, llid, tag);
25778 + tag++;
25779 + return 0;
25780 +
25781 +}
25782 +
25783 +int tn7sar_oam_generation(void *privContext, int chan, int type, int vpi, int vci, int timeout)
25784 +{
25785 + unsigned int regv = 0;
25786 + static unsigned int tag;
25787 + HAL_FUNCTIONS *pHalFunc;
25788 + HAL_DEVICE *pHalDev;
25789 + Tn7AtmPrivate *priv;
25790 + unsigned int llid[4]={0xffffffff,0xffffffff,0xffffffff,0xffffffff};
25791 +
25792 + dprintf(2, "tn7sar_oam_generation()\n");
25793 +
25794 + priv = (Tn7AtmPrivate *)privContext;
25795 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25796 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25797 +
25798 + if(timeout >= 5000)
25799 + {
25800 + if(timeout == 6000)
25801 + {
25802 + tn7sar_clear_pvc_table();
25803 + return 0;
25804 + }
25805 + timeout = oamLbTimeout;
25806 + }
25807 +
25808 +
25809 + pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &timeout);
25810 +
25811 + if(chan == ATM_NO_DMA_CHAN)
25812 + {
25813 + tn7sar_unmatched_oam_generation(priv, vpi, vci, type);
25814 + return 0;
25815 + }
25816 +
25817 + /* calculate atm header */
25818 + oamAtmHdr = tn7sar_atm_header(vpi,vci);
25819 +
25820 + oam_type = type;
25821 +
25822 + regv = (0xff & chan);
25823 + switch(type)
25824 + {
25825 + case 0:
25826 + regv |= (1<<12); //f5 end
25827 + dprintf(2, "f5 loop back\n");
25828 + break;
25829 + case 1:
25830 + regv |= (1<<13); // f4 end
25831 + break;
25832 + case 2:
25833 + regv |= (1<<14); //f5 seg
25834 + break;
25835 + case 3:
25836 + regv |= (1<<15); //f4 seg
25837 + break;
25838 + default:
25839 + break;
25840 + }
25841 + oamPingStatus = OAM_PING_PENDING;
25842 + pHalFunc->OamLoopbackConfig(pHalDev, regv, llid, tag);
25843 + tag++;
25844 +
25845 + return 0;
25846 +}
25847 +
25848 +int tn7sar_proc_oam_ping(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25849 +{
25850 + int len = 0;
25851 +
25852 + len += sprintf(buf+len, "%d\n", oamPingStatus);
25853 +
25854 + return len;
25855 +}
25856 +
25857 +int tn7sar_proc_pvc_table(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25858 +{
25859 + int len = 0;
25860 + int i;
25861 +
25862 + for(i=0;i<16;i++)
25863 + {
25864 + if(pvc_result[i].bInUse)
25865 + {
25866 + len += sprintf(buf+len, "%d,%d\n", pvc_result[i].vpi,pvc_result[i].vci);
25867 + }
25868 + else
25869 + {
25870 + len += sprintf(buf+len, "0,0\n");
25871 + }
25872 + }
25873 + return len;
25874 +}
25875 +
25876 +
25877 +
25878 +int tn7sar_proc_sar_stat(char* buf, char **start, off_t offset, int count,int *eof, void *data)
25879 +{
25880 + int len = 0;
25881 + int limit = count - 80;
25882 + struct atm_dev *dev;
25883 + Tn7AtmPrivate *priv;
25884 + int i, j, k;
25885 + int stat_len;
25886 + char statString[32];
25887 + unsigned int *pStateBase, *pSarStat;
25888 + HAL_FUNCTIONS *pHalFunc;
25889 + HAL_DEVICE *pHalDev;
25890 + int dBytes;
25891 +
25892 + dev = (struct atm_dev *)data;
25893 + priv = (Tn7AtmPrivate *)dev->dev_data;
25894 +
25895 + pHalFunc = (HAL_FUNCTIONS *)priv->pSarHalFunc;
25896 + pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
25897 +
25898 + len += sprintf(buf+len, "SAR HAL Statistics\n");
25899 + for(i=0;i<MAX_DMA_CHAN;i++)
25900 + {
25901 + if(priv->lut[i].inuse)
25902 + {
25903 + if(len<=limit)
25904 + len += sprintf(buf+len, "\nChannel %d:\n",priv->lut[i].chanid);
25905 + k=0;
25906 + for(j=0;j<4;j++)
25907 + {
25908 + stat_len =sprintf(statString, "Stats;%d;%d", j,priv->lut[i].chanid);
25909 + statString[stat_len]=0;
25910 + pHalFunc->Control(pHalDev, statString, "Get", &pSarStat);
25911 + pStateBase = pSarStat;
25912 + while(pSarStat)
25913 + {
25914 + if((char *)*pSarStat == NULL)
25915 + break;
25916 + if(len<=limit)
25917 + {
25918 + dBytes = sprintf(buf+len, "%s: ",(char *) *pSarStat);
25919 + len += dBytes;
25920 + k += dBytes;
25921 + }
25922 + pSarStat++;
25923 + if(len<=limit)
25924 + {
25925 + dBytes = sprintf(buf+len, "%s; ",(char *) *pSarStat);
25926 + len += dBytes;
25927 + k += dBytes;
25928 + }
25929 + pSarStat++;
25930 +
25931 + if(k > 60)
25932 + {
25933 + k=0;
25934 + if(len<=limit)
25935 + len += sprintf(buf+len, "\n");
25936 + }
25937 + }
25938 +
25939 + kfree(pStateBase);
25940 + }
25941 + }
25942 + }
25943 +
25944 + return len;
25945 +}
25946 +
25947 +void tn7sar_get_sar_firmware_version(unsigned int *pdsp_version_ms, unsigned int *pdsp_version_ls)
25948 +{
25949 +
25950 + *pdsp_version_ms = (SarPdspFirmware[9]>>20) & 0xF;
25951 + *pdsp_version_ls = (SarPdspFirmware[9]>>12) & 0xFF;
25952 + return;
25953 +}
25954 diff -urN linux.old/drivers/atm/sangam_atm/tnetd7300_sar_firm.h linux.dev/drivers/atm/sangam_atm/tnetd7300_sar_firm.h
25955 --- linux.old/drivers/atm/sangam_atm/tnetd7300_sar_firm.h 1970-01-01 01:00:00.000000000 +0100
25956 +++ linux.dev/drivers/atm/sangam_atm/tnetd7300_sar_firm.h 2005-08-23 04:46:50.111841568 +0200
25957 @@ -0,0 +1,988 @@
25958 +//SarPdspFirmware Revision: 49
25959 +
25960 +static int SarPdspFirmware[] = {
25961 + 0xb0a8d1f1,
25962 + 0x000003d8,
25963 + 0x00000000,
25964 + 0x00000004,
25965 + 0x00000000,
25966 + 0x00000000,
25967 + 0x00000000,
25968 + 0x00000000,
25969 + 0x21000900,
25970 + 0x24049080,
25971 + 0x24000080,
25972 + 0x240000c0,
25973 + 0x10e0e0e1,
25974 + 0x10e0e0e2,
25975 + 0x10e0e0e3,
25976 + 0x10e0e0e4,
25977 + 0x10e0e0e5,
25978 + 0x10e0e0e6,
25979 + 0x10e0e0e7,
25980 + 0x10e0e0e8,
25981 + 0x10e0e0e9,
25982 + 0x10e0e0ea,
25983 + 0x10e0e0eb,
25984 + 0x10e0e0ec,
25985 + 0x10e0e0ed,
25986 + 0x10e0e0ee,
25987 + 0x10e0e0ef,
25988 + 0x10e0e0f0,
25989 + 0x10e0e0f1,
25990 + 0x10e0e0f2,
25991 + 0x10e0e0f3,
25992 + 0x10e0e0f4,
25993 + 0x10e0e0f5,
25994 + 0x10e0e0f6,
25995 + 0x10e0e0f7,
25996 + 0x10e0e0f8,
25997 + 0x10e0e0f9,
25998 + 0x10e0e0fa,
25999 + 0x10e0e0fb,
26000 + 0x10e0e0fc,
26001 + 0x10e0e0fd,
26002 + 0x10e0e0fe,
26003 + 0x10e0e0ff,
26004 + 0x81042680,
26005 + 0x810c2680,
26006 + 0x81042680,
26007 + 0x2483c080,
26008 + 0x81180b80,
26009 + 0x2484c080,
26010 + 0x811a0b80,
26011 + 0x2485c080,
26012 + 0x811c0b80,
26013 + 0x240100dd,
26014 + 0xa07d06fd,
26015 + 0x240400dd,
26016 + 0xa07d04fd,
26017 + 0x24c000dd,
26018 + 0x2400169d,
26019 + 0xa07d5cfd,
26020 + 0x511f9d03,
26021 + 0x01019d9d,
26022 + 0x7f0000fd,
26023 + 0xd11eff05,
26024 + 0x97c06890,
26025 + 0x1d00e5e5,
26026 + 0x2301229e,
26027 + 0x81bc2890,
26028 + 0x24000000,
26029 + 0xc917ff02,
26030 + 0x81000100,
26031 + 0x01010000,
26032 + 0xc918ff02,
26033 + 0x81000100,
26034 + 0x01010000,
26035 + 0xc919ff02,
26036 + 0x81000100,
26037 + 0xd110e70a,
26038 + 0xd11cff09,
26039 + 0x1d00e5e5,
26040 + 0xd100e704,
26041 + 0xd114ff06,
26042 + 0x2301179e,
26043 + 0x79000004,
26044 + 0xd70ffffd,
26045 + 0x91382486,
26046 + 0x2301059e,
26047 + 0xc903ff07,
26048 + 0xa06047e0,
26049 + 0xb10043e6,
26050 + 0xc910e602,
26051 + 0x81000106,
26052 + 0x24006025,
26053 + 0x2300d39e,
26054 + 0xd11dff09,
26055 + 0x1f00e5e5,
26056 + 0xc901e705,
26057 + 0xd111ff06,
26058 + 0x91382586,
26059 + 0x2301059e,
26060 + 0x79000003,
26061 + 0xd715fffc,
26062 + 0x2301179e,
26063 + 0xc910e706,
26064 + 0x110f2760,
26065 + 0x240000c6,
26066 + 0x24000086,
26067 + 0x13106006,
26068 + 0x7b00005a,
26069 + 0x11079f80,
26070 + 0x51008010,
26071 + 0xc912ff0f,
26072 + 0xd100ff04,
26073 + 0xd101ff05,
26074 + 0xa06046e0,
26075 + 0x79000004,
26076 + 0xa06044e0,
26077 + 0x79000002,
26078 + 0xa06045e0,
26079 + 0xb10043e6,
26080 + 0x61150602,
26081 + 0x2101c500,
26082 + 0xc910e602,
26083 + 0xa1001006,
26084 + 0x24000025,
26085 + 0x2300d39e,
26086 + 0xd11fff05,
26087 + 0x97c06a90,
26088 + 0x1f00e5e5,
26089 + 0x2301229e,
26090 + 0x81bc2a90,
26091 + 0xd11cff09,
26092 + 0x1d00e5e5,
26093 + 0xc900e705,
26094 + 0xd10fff06,
26095 + 0x91382486,
26096 + 0x2301059e,
26097 + 0x79000003,
26098 + 0xd714fffc,
26099 + 0x2301179e,
26100 + 0xc907ff07,
26101 + 0xa0604be0,
26102 + 0xb10043e6,
26103 + 0xc910e602,
26104 + 0x81000106,
26105 + 0x24006025,
26106 + 0x2300d39e,
26107 + 0xd111e70a,
26108 + 0xd11dff09,
26109 + 0x1f00e5e5,
26110 + 0xd101e704,
26111 + 0xd115ff06,
26112 + 0x2301179e,
26113 + 0x79000004,
26114 + 0xd711fffd,
26115 + 0x91382586,
26116 + 0x2301059e,
26117 + 0xc911e706,
26118 + 0x0b042760,
26119 + 0x240000c6,
26120 + 0x24000086,
26121 + 0x13106006,
26122 + 0x7b000024,
26123 + 0x11709f80,
26124 + 0x5100800e,
26125 + 0xc913ff0d,
26126 + 0xd104ff04,
26127 + 0xd105ff05,
26128 + 0xa0604ae0,
26129 + 0x79000004,
26130 + 0xa06048e0,
26131 + 0x79000002,
26132 + 0xa06049e0,
26133 + 0xb10043e6,
26134 + 0xc910e602,
26135 + 0xa1001106,
26136 + 0x24000025,
26137 + 0x2300d39e,
26138 + 0xc90bff02,
26139 + 0x7900000b,
26140 + 0xc90aff02,
26141 + 0x79000012,
26142 + 0xcf08ff89,
26143 + 0xb10002e0,
26144 + 0xcf18e087,
26145 + 0x790000b6,
26146 + 0x24000080,
26147 + 0x24fb00c0,
26148 + 0xa06003e0,
26149 + 0x7f000082,
26150 + 0xb10024e6,
26151 + 0xb10025e0,
26152 + 0xa06628e6,
26153 + 0xa06029e0,
26154 + 0x248000c6,
26155 + 0xa06624e6,
26156 + 0x671006f0,
26157 + 0x81082186,
26158 + 0x7f0000ee,
26159 + 0xb10027e6,
26160 + 0x61100604,
26161 + 0xa0662be6,
26162 + 0x810c2186,
26163 + 0x79000006,
26164 + 0xd70cffea,
26165 + 0xa0662be6,
26166 + 0x1f1be6e6,
26167 + 0x81382686,
26168 + 0x813c2680,
26169 + 0x248000c6,
26170 + 0xa06627e6,
26171 + 0x7f0000e3,
26172 + 0x110f0600,
26173 + 0x81100b00,
26174 + 0x01502545,
26175 + 0x90457888,
26176 + 0x5103091c,
26177 + 0x6901092a,
26178 + 0xc910e603,
26179 + 0xd108e90d,
26180 + 0x79000027,
26181 + 0x01582545,
26182 + 0x9045788a,
26183 + 0xd108e904,
26184 + 0x1f08e9e9,
26185 + 0x01552545,
26186 + 0x80451829,
26187 + 0x50eaeb20,
26188 + 0x0101ebeb,
26189 + 0x015c2545,
26190 + 0x8045388b,
26191 + 0x7900001c,
26192 + 0x015c2545,
26193 + 0x9045788b,
26194 + 0x6900eb05,
26195 + 0x1d08e9e9,
26196 + 0x01552545,
26197 + 0x80451829,
26198 + 0x79000004,
26199 + 0x0501ebeb,
26200 + 0x015c2545,
26201 + 0x8045388b,
26202 + 0x10ecece8,
26203 + 0x79000010,
26204 + 0x24000000,
26205 + 0x5110000e,
26206 + 0x690f6903,
26207 + 0x24000069,
26208 + 0x79000002,
26209 + 0x01016969,
26210 + 0x01010000,
26211 + 0x81100b69,
26212 + 0x01542545,
26213 + 0x90451809,
26214 + 0x6f0209f7,
26215 + 0xa1001069,
26216 + 0x81100b06,
26217 + 0x01572545,
26218 + 0x80451869,
26219 + 0xa06841e8,
26220 + 0xa1414006,
26221 + 0x209e0000,
26222 + 0x81100b06,
26223 + 0xd11fe603,
26224 + 0x9164388d,
26225 + 0x8108248d,
26226 + 0xd100e507,
26227 + 0x97406490,
26228 + 0x9108248d,
26229 + 0x813c2480,
26230 + 0x2302b4de,
26231 + 0x1d00e7e7,
26232 + 0x79000006,
26233 + 0x97406590,
26234 + 0x9108258d,
26235 + 0x813c2580,
26236 + 0x1d01e7e7,
26237 + 0x2302b9de,
26238 + 0x8164388d,
26239 + 0x209e0000,
26240 + 0x81040105,
26241 + 0x91002286,
26242 + 0x97086290,
26243 + 0x81042280,
26244 + 0xd100e504,
26245 + 0x2302b4de,
26246 + 0x1f00e7e7,
26247 + 0x209e0000,
26248 + 0x2302b9de,
26249 + 0x1f01e7e7,
26250 + 0x209e0000,
26251 + 0xd109ff00,
26252 + 0xa0702cf0,
26253 + 0x79000001,
26254 + 0xd109ff00,
26255 + 0xb1002de6,
26256 + 0xd11ee609,
26257 + 0xb1000de0,
26258 + 0xc91fe044,
26259 + 0x24c338c6,
26260 + 0x10000006,
26261 + 0x81382686,
26262 + 0x87406690,
26263 + 0x813c2680,
26264 + 0x7900003e,
26265 + 0x110f0600,
26266 + 0x81100b00,
26267 + 0x24000045,
26268 + 0x24000025,
26269 + 0x61100603,
26270 + 0x24006045,
26271 + 0x24006025,
26272 + 0x01704545,
26273 + 0x90451888,
26274 + 0x0b034600,
26275 + 0x11070000,
26276 + 0x69040004,
26277 + 0xc916ff2c,
26278 + 0x01019e9e,
26279 + 0x7900002f,
26280 + 0xc90cff04,
26281 + 0x6f0200fd,
26282 + 0xd308e8a1,
26283 + 0x7f0000fb,
26284 + 0x69020008,
26285 + 0xd308e89e,
26286 + 0xb1002fe6,
26287 + 0x91b82880,
26288 + 0xc91ce002,
26289 + 0x1f1ce6e6,
26290 + 0x10080806,
26291 + 0x79000015,
26292 + 0xb1002fe6,
26293 + 0x69030003,
26294 + 0x13c06666,
26295 + 0x79000011,
26296 + 0x91807809,
26297 + 0xc910ea09,
26298 + 0x81082689,
26299 + 0x01018a8a,
26300 + 0xc91ee60a,
26301 + 0x1d10eaea,
26302 + 0x240557c0,
26303 + 0x60c08a07,
26304 + 0x1f1de6e6,
26305 + 0x79000005,
26306 + 0x2400018a,
26307 + 0x1f10eaea,
26308 + 0x1f1fe6e6,
26309 + 0xd71ee6f8,
26310 + 0x51000002,
26311 + 0x11c76666,
26312 + 0x81382686,
26313 + 0x87406690,
26314 + 0x91082689,
26315 + 0x813c2680,
26316 + 0xb1002ee6,
26317 + 0xd103e609,
26318 + 0x81807809,
26319 + 0xc908e807,
26320 + 0x21039400,
26321 + 0x81002386,
26322 + 0x87086390,
26323 + 0x81042380,
26324 + 0xc908e802,
26325 + 0x21039400,
26326 + 0x209e0000,
26327 + 0xb10008ef,
26328 + 0x110f0f00,
26329 + 0x81100b00,
26330 + 0x24000025,
26331 + 0x61100f02,
26332 + 0x24005025,
26333 + 0x01952545,
26334 + 0x9045382e,
26335 + 0xc91def03,
26336 + 0x24000900,
26337 + 0x2301c09e,
26338 + 0xc91cef03,
26339 + 0x24001900,
26340 + 0x2301c09e,
26341 + 0xc91bef03,
26342 + 0x24000a00,
26343 + 0x2301c09e,
26344 + 0xc91aef03,
26345 + 0x24001a00,
26346 + 0x2301c09e,
26347 + 0x8045382e,
26348 + 0x01a82545,
26349 + 0x9045388e,
26350 + 0xc915ef03,
26351 + 0x24000000,
26352 + 0x2301c09e,
26353 + 0xc914ef03,
26354 + 0x24001000,
26355 + 0x2301c09e,
26356 + 0x8045388e,
26357 + 0x61100f02,
26358 + 0x24006025,
26359 + 0x016d2545,
26360 + 0x9045382e,
26361 + 0xc919ef03,
26362 + 0x24000900,
26363 + 0x2301c09e,
26364 + 0xc918ef03,
26365 + 0x24001900,
26366 + 0x2301c09e,
26367 + 0xc917ef03,
26368 + 0x24000a00,
26369 + 0x2301c09e,
26370 + 0xc916ef03,
26371 + 0x24001a00,
26372 + 0x2301c09e,
26373 + 0x8045382e,
26374 + 0x017c2545,
26375 + 0x9045388e,
26376 + 0xc913ef03,
26377 + 0x24000000,
26378 + 0x2301c09e,
26379 + 0xc912ef03,
26380 + 0x24001000,
26381 + 0x2301c09e,
26382 + 0x8045388e,
26383 + 0xd11eef19,
26384 + 0x11f02f00,
26385 + 0x51000017,
26386 + 0x24001520,
26387 + 0x81140b20,
26388 + 0x81b01a0f,
26389 + 0x1f02e7e7,
26390 + 0x24c000c0,
26391 + 0x24001580,
26392 + 0xa0605ce0,
26393 + 0xc90fef04,
26394 + 0x1d04e7e7,
26395 + 0x1d05e7e7,
26396 + 0x7900000c,
26397 + 0xc90eef04,
26398 + 0x1d04e7e7,
26399 + 0x1f05e7e7,
26400 + 0x79000008,
26401 + 0xc90def04,
26402 + 0x1f04e7e7,
26403 + 0x1d05e7e7,
26404 + 0x79000004,
26405 + 0xc90cef03,
26406 + 0x1f04e7e7,
26407 + 0x1f05e7e7,
26408 + 0x2100b900,
26409 + 0xd11eef03,
26410 + 0x1e00eeee,
26411 + 0x209e0000,
26412 + 0x1c00eeee,
26413 + 0x209e0000,
26414 + 0x110f0606,
26415 + 0x81140b06,
26416 + 0x13100606,
26417 + 0x91b01a83,
26418 + 0x24000025,
26419 + 0x61100304,
26420 + 0x24005025,
26421 + 0xc905e702,
26422 + 0x24006025,
26423 + 0x110f0300,
26424 + 0x81100b00,
26425 + 0x81120b00,
26426 + 0x51150611,
26427 + 0x61100302,
26428 + 0x24005025,
26429 + 0x1d01e5e5,
26430 + 0x51160639,
26431 + 0x511a0650,
26432 + 0x511c0657,
26433 + 0x5118065e,
26434 + 0x511e0685,
26435 + 0x61100302,
26436 + 0x24006025,
26437 + 0x1f01e5e5,
26438 + 0x51170634,
26439 + 0x511b064b,
26440 + 0x511d0652,
26441 + 0x51190658,
26442 + 0x511f067f,
26443 + 0xc903e708,
26444 + 0x1d03e7e7,
26445 + 0x24000060,
26446 + 0xa1000a60,
26447 + 0x244000c0,
26448 + 0x24001580,
26449 + 0xa0605ce0,
26450 + 0x21007d00,
26451 + 0xcf02e7fc,
26452 + 0x1d02e7e7,
26453 + 0x1f03e7e7,
26454 + 0xc904e703,
26455 + 0x1f08e3e3,
26456 + 0x79000002,
26457 + 0x1d08e3e3,
26458 + 0xc905e705,
26459 + 0x01682545,
26460 + 0x9045588d,
26461 + 0x2302879e,
26462 + 0x79000004,
26463 + 0x01902545,
26464 + 0x9045588d,
26465 + 0x2302819e,
26466 + 0x24001872,
26467 + 0x24000152,
26468 + 0xb10009e0,
26469 + 0x108080d3,
26470 + 0x10c0c092,
26471 + 0x2400102c,
26472 + 0x2302c8de,
26473 + 0x91021c97,
26474 + 0x91001cd8,
26475 + 0x91061c98,
26476 + 0x91041cd9,
26477 + 0x910a1c99,
26478 + 0x91081cda,
26479 + 0x910e1c9a,
26480 + 0x910c1cdb,
26481 + 0x91261d9b,
26482 + 0x91287d9c,
26483 + 0x23028dde,
26484 + 0x1f02e7e7,
26485 + 0x1d03e7e7,
26486 + 0x7d000070,
26487 + 0x01902545,
26488 + 0x9045798d,
26489 + 0x79000003,
26490 + 0x01682545,
26491 + 0x9045788d,
26492 + 0x0b09eee0,
26493 + 0x24001472,
26494 + 0xd108e303,
26495 + 0xc900e00b,
26496 + 0x79000002,
26497 + 0xc910e009,
26498 + 0xd101e503,
26499 + 0x2302819e,
26500 + 0x79000002,
26501 + 0x2302879e,
26502 + 0x91013d12,
26503 + 0x9504bd93,
26504 + 0x23028dde,
26505 + 0x7d00005d,
26506 + 0xd108ee03,
26507 + 0x1d10e7e7,
26508 + 0x7900009a,
26509 + 0x1d11e7e7,
26510 + 0x79000098,
26511 + 0x01902545,
26512 + 0x9045798d,
26513 + 0x79000003,
26514 + 0x01682545,
26515 + 0x9045788d,
26516 + 0x0b0aeee0,
26517 + 0x24001072,
26518 + 0x7f0000e8,
26519 + 0x01a02545,
26520 + 0x9045b98d,
26521 + 0x79000003,
26522 + 0x01742545,
26523 + 0x9045b88d,
26524 + 0x0b01efe0,
26525 + 0x24001172,
26526 + 0x7f0000e0,
26527 + 0x2302d1de,
26528 + 0x79000002,
26529 + 0x2302d6de,
26530 + 0x000c2545,
26531 + 0x9045198f,
26532 + 0xd100ef07,
26533 + 0x1d02efef,
26534 + 0xc901ef0c,
26535 + 0xc905ef0b,
26536 + 0x1d01efef,
26537 + 0x1d05efef,
26538 + 0x79000008,
26539 + 0xd102ef04,
26540 + 0x1f02efef,
26541 + 0x8045198f,
26542 + 0x79000078,
26543 + 0xd101ef04,
26544 + 0x1f01efef,
26545 + 0x1f05efef,
26546 + 0x8045198f,
26547 + 0x69180673,
26548 + 0x01ac2545,
26549 + 0x2302dbde,
26550 + 0xd100ef03,
26551 + 0x23036c9e,
26552 + 0x7900006e,
26553 + 0xc800e40b,
26554 + 0x110f0020,
26555 + 0x81100b20,
26556 + 0x100c0c45,
26557 + 0x61100002,
26558 + 0x01604545,
26559 + 0x9045188f,
26560 + 0xd101ef04,
26561 + 0x1f01efef,
26562 + 0x1f07efef,
26563 + 0x8045188f,
26564 + 0x01010000,
26565 + 0x6f1300f4,
26566 + 0x79000060,
26567 + 0x2302d1de,
26568 + 0x79000002,
26569 + 0x2302d6de,
26570 + 0x000c2545,
26571 + 0x9045198f,
26572 + 0xc903ef05,
26573 + 0x1d03efef,
26574 + 0x1f04efef,
26575 + 0x8045198f,
26576 + 0x79000056,
26577 + 0xc904ef55,
26578 + 0x1d04efef,
26579 + 0xc901ef04,
26580 + 0xc906ef03,
26581 + 0x1d01efef,
26582 + 0x1d06efef,
26583 + 0x8045198f,
26584 + 0x691e064e,
26585 + 0x01ac2545,
26586 + 0x2302dbde,
26587 + 0xc800e40c,
26588 + 0x110f0020,
26589 + 0x81100b20,
26590 + 0x100c0c45,
26591 + 0x61100002,
26592 + 0x01604545,
26593 + 0x9045188f,
26594 + 0xc901ef05,
26595 + 0xc908ef04,
26596 + 0x1d01efef,
26597 + 0x1d07efef,
26598 + 0x8045188f,
26599 + 0x01010000,
26600 + 0x6f1300f3,
26601 + 0x7900003d,
26602 + 0x10ededf0,
26603 + 0xc908e303,
26604 + 0x13401010,
26605 + 0x209e0000,
26606 + 0x13301010,
26607 + 0x209e0000,
26608 + 0x10ededf0,
26609 + 0xc908e303,
26610 + 0x130a1010,
26611 + 0x209e0000,
26612 + 0x13081010,
26613 + 0x209e0000,
26614 + 0x24000266,
26615 + 0x2400c800,
26616 + 0x24000020,
26617 + 0xd108ee17,
26618 + 0x01012020,
26619 + 0xc91cff09,
26620 + 0x6e0020fe,
26621 + 0xc910e702,
26622 + 0x20de0000,
26623 + 0x1f10e7e7,
26624 + 0x110f0600,
26625 + 0x11f02727,
26626 + 0x12002727,
26627 + 0x20de0000,
26628 + 0x1d10e7e7,
26629 + 0x2302b4de,
26630 + 0x511d0605,
26631 + 0x511c0602,
26632 + 0x7900001e,
26633 + 0x01a62545,
26634 + 0x79000002,
26635 + 0x01722545,
26636 + 0x90451880,
26637 + 0x01018080,
26638 + 0x80451880,
26639 + 0x79000017,
26640 + 0x01012020,
26641 + 0xc91dff09,
26642 + 0x6e0020fe,
26643 + 0xc911e702,
26644 + 0x20de0000,
26645 + 0x1f11e7e7,
26646 + 0x09040600,
26647 + 0x110f2727,
26648 + 0x12002727,
26649 + 0x20de0000,
26650 + 0x1d11e7e7,
26651 + 0x2302b9de,
26652 + 0x7f0000ea,
26653 + 0x81b82786,
26654 + 0x240000d1,
26655 + 0x87c06790,
26656 + 0x81bc2780,
26657 + 0x20de0000,
26658 + 0x81b82986,
26659 + 0x87c06990,
26660 + 0x81bc2980,
26661 + 0x20de0000,
26662 + 0x91b43a88,
26663 + 0x2301029e,
26664 + 0x51150608,
26665 + 0xc908e305,
26666 + 0x51120303,
26667 + 0x01010303,
26668 + 0x79000002,
26669 + 0x24000003,
26670 + 0x01012323,
26671 + 0x81b01a83,
26672 + 0x21007d00,
26673 + 0x902cfc88,
26674 + 0x10c8c893,
26675 + 0x108888d4,
26676 + 0x10c9c994,
26677 + 0x108989d5,
26678 + 0x10caca95,
26679 + 0x108a8ad6,
26680 + 0x10cbcb96,
26681 + 0x108b8bd7,
26682 + 0xd108e303,
26683 + 0x2400a80c,
26684 + 0x20de0000,
26685 + 0x2400aa0c,
26686 + 0x20de0000,
26687 + 0xd108e303,
26688 + 0x24007c0c,
26689 + 0x20de0000,
26690 + 0x24007e0c,
26691 + 0x20de0000,
26692 + 0x24000000,
26693 + 0x90453904,
26694 + 0xd108e303,
26695 + 0x24007c0c,
26696 + 0x20de0000,
26697 + 0x24007e0c,
26698 + 0x20de0000,
26699 + 0xb1002fe6,
26700 + 0x91b82880,
26701 + 0xc91ce002,
26702 + 0x209e0000,
26703 + 0xb1002ee6,
26704 + 0x69187279,
26705 + 0xd110f230,
26706 + 0xc903e769,
26707 + 0xc90be604,
26708 + 0xc904e767,
26709 + 0xd105e766,
26710 + 0x7900000c,
26711 + 0xc90ae604,
26712 + 0xd104e763,
26713 + 0xd105e762,
26714 + 0x79000008,
26715 + 0xc907e604,
26716 + 0xc904e75f,
26717 + 0xc905e75e,
26718 + 0x79000004,
26719 + 0xc906e65c,
26720 + 0xd104e75b,
26721 + 0xc905e75a,
26722 + 0x91003c80,
26723 + 0x6897c058,
26724 + 0x68d88057,
26725 + 0x91043c80,
26726 + 0x6898c055,
26727 + 0x68d98054,
26728 + 0x91083c80,
26729 + 0x6899c052,
26730 + 0x68da8051,
26731 + 0x910c3c80,
26732 + 0x689ac04f,
26733 + 0x68db804e,
26734 + 0xb10009e0,
26735 + 0x6892c04c,
26736 + 0x68d3804b,
26737 + 0x24000160,
26738 + 0xa1000a60,
26739 + 0x244000c0,
26740 + 0x24001580,
26741 + 0xa0605ce0,
26742 + 0x1d03e7e7,
26743 + 0x109393c8,
26744 + 0x10d4d488,
26745 + 0x109494c9,
26746 + 0x10d5d589,
26747 + 0x109595ca,
26748 + 0x10d6d68a,
26749 + 0x109696cb,
26750 + 0x10d7d78b,
26751 + 0x8110fc88,
26752 + 0x209e0000,
26753 + 0x91003c80,
26754 + 0x6893c00c,
26755 + 0x68d4800b,
26756 + 0x91043c80,
26757 + 0x6894c009,
26758 + 0x68d58008,
26759 + 0x91083c80,
26760 + 0x6895c006,
26761 + 0x68d68005,
26762 + 0x910c3c80,
26763 + 0x6896c003,
26764 + 0x68d78002,
26765 + 0x79000010,
26766 + 0x24ffff80,
26767 + 0x24ffffc0,
26768 + 0x68809306,
26769 + 0x68e0f405,
26770 + 0x68e0f504,
26771 + 0x68e0f603,
26772 + 0x6880d702,
26773 + 0x79000008,
26774 + 0x24000080,
26775 + 0x240000c0,
26776 + 0x68809323,
26777 + 0x68e0f422,
26778 + 0x68e0f521,
26779 + 0x68e0f620,
26780 + 0x6880d71f,
26781 + 0x1d10f2f2,
26782 + 0x2400002c,
26783 + 0x2302c8de,
26784 + 0x24000f80,
26785 + 0x240000c0,
26786 + 0x0101c0c0,
26787 + 0xd100e504,
26788 + 0xc91cff06,
26789 + 0x6e80c0fd,
26790 + 0x21016d00,
26791 + 0xc91dff03,
26792 + 0x6e80c0fa,
26793 + 0x21016d00,
26794 + 0xd104e606,
26795 + 0xc909e608,
26796 + 0xb1000ce0,
26797 + 0x0101e0e0,
26798 + 0xa0600ce0,
26799 + 0x79000004,
26800 + 0xb1000be0,
26801 + 0x0101e0e0,
26802 + 0xa0600be0,
26803 + 0xb1002fe6,
26804 + 0xd100e504,
26805 + 0x2302b4de,
26806 + 0x24000022,
26807 + 0x209e0000,
26808 + 0x2302b9de,
26809 + 0x24000042,
26810 + 0x209e0000,
26811 + 0xd104e609,
26812 + 0x01782545,
26813 + 0x9045180e,
26814 + 0x110f0e00,
26815 + 0x81100b00,
26816 + 0x2400a445,
26817 + 0x51002502,
26818 + 0x01504545,
26819 + 0x90451888,
26820 + 0xc909e87d,
26821 + 0xb1002fe6,
26822 + 0x1f1fe6e6,
26823 + 0x10080806,
26824 + 0x21015f00,
26825 + 0x6914721b,
26826 + 0x01782545,
26827 + 0x2303bade,
26828 + 0x900c188f,
26829 + 0x1d02efef,
26830 + 0xc901ef05,
26831 + 0xc905ef04,
26832 + 0x1d01efef,
26833 + 0x1d05efef,
26834 + 0x800c188f,
26835 + 0xc909e66e,
26836 + 0x2303d0de,
26837 + 0xc800e40c,
26838 + 0x110f0020,
26839 + 0x81100b20,
26840 + 0x100c0c45,
26841 + 0x61100002,
26842 + 0x01604545,
26843 + 0x9045188f,
26844 + 0xc901ef05,
26845 + 0xc907ef04,
26846 + 0x1d01efef,
26847 + 0x1d07efef,
26848 + 0x8045188f,
26849 + 0x01010000,
26850 + 0x6f1300f3,
26851 + 0x7900005e,
26852 + 0x6910725d,
26853 + 0x01782545,
26854 + 0x2303bade,
26855 + 0x900c188f,
26856 + 0x1f03efef,
26857 + 0xd101ef03,
26858 + 0x1f01efef,
26859 + 0x1f06efef,
26860 + 0x800c188f,
26861 + 0xc909e654,
26862 + 0x2303d0de,
26863 + 0xc800e40b,
26864 + 0x110f0020,
26865 + 0x81100b20,
26866 + 0x100c0c45,
26867 + 0x61100002,
26868 + 0x01604545,
26869 + 0x9045188f,
26870 + 0xd101ef04,
26871 + 0x1f01efef,
26872 + 0x1f08efef,
26873 + 0x8045188f,
26874 + 0x01010000,
26875 + 0x6f1300f4,
26876 + 0x79000045,
26877 + 0x01782545,
26878 + 0x9045788e,
26879 + 0x1d02efef,
26880 + 0x1d12efef,
26881 + 0xc905ef04,
26882 + 0x1d05efef,
26883 + 0x1d01efef,
26884 + 0x7900000c,
26885 + 0xc915ef04,
26886 + 0x1d15efef,
26887 + 0x1d11efef,
26888 + 0x79000008,
26889 + 0xc907ef04,
26890 + 0x1d07efef,
26891 + 0x1d01efef,
26892 + 0x79000004,
26893 + 0xc917ef03,
26894 + 0x1d17efef,
26895 + 0x1d11efef,
26896 + 0x017c2545,
26897 + 0x8045388f,
26898 + 0x110f0e00,
26899 + 0x81100b00,
26900 + 0x2400a845,
26901 + 0x51002502,
26902 + 0x01504545,
26903 + 0x9045388f,
26904 + 0x1d02efef,
26905 + 0x1d12efef,
26906 + 0xc905ef04,
26907 + 0x1d05efef,
26908 + 0x1d01efef,
26909 + 0x79000004,
26910 + 0xc915ef03,
26911 + 0x1d15efef,
26912 + 0x1d11efef,
26913 + 0x8045388f,
26914 + 0x7900001f,
26915 + 0xc909e60d,
26916 + 0x9045180e,
26917 + 0x110f0e00,
26918 + 0x81100b00,
26919 + 0xc90ae603,
26920 + 0x2400a80c,
26921 + 0x79000003,
26922 + 0xc90be617,
26923 + 0x2400aa0c,
26924 + 0x51002503,
26925 + 0x01500c0c,
26926 + 0x24005025,
26927 + 0x20de0000,
26928 + 0xc904e611,
26929 + 0xc906e603,
26930 + 0x24007c0c,
26931 + 0x79000003,
26932 + 0xc907e60d,
26933 + 0x24007e0c,
26934 + 0x51002502,
26935 + 0x01600c0c,
26936 + 0x20de0000,
26937 + 0x01ac2545,
26938 + 0x24000000,
26939 + 0x90453804,
26940 + 0xd10be603,
26941 + 0x24007c0c,
26942 + 0x20de0000,
26943 + 0x24007e0c,
26944 + 0x20de0000,
26945 + 0x209e0000};
26946 diff -urN linux.old/drivers/atm/sangam_atm/turbodsl.c linux.dev/drivers/atm/sangam_atm/turbodsl.c
26947 --- linux.old/drivers/atm/sangam_atm/turbodsl.c 1970-01-01 01:00:00.000000000 +0100
26948 +++ linux.dev/drivers/atm/sangam_atm/turbodsl.c 2005-08-23 04:46:50.111841568 +0200
26949 @@ -0,0 +1,223 @@
26950 +
26951 +
26952 +/*
26953 + *
26954 + * Turbo DSL Implementaion
26955 + *
26956 + * Zhicheng Tang ztang@ti.com
26957 + *
26958 + * 2002 (c) Texas Instruments Inc.
26959 + *
26960 +*/
26961 +
26962 +/* defines and variables */
26963 +#define RFC2684_BRIDGED_HDR_SIZE 10
26964 +unsigned char LLC_BRIDGED_HEADER_2684[RFC2684_BRIDGED_HDR_SIZE] =
26965 + {0xAA, 0xAA, 0x03, 0x00, 0x80, 0xC2, 0x00, 0x07, 0x00, 0x00};
26966 +
26967 +#define RFC2684_ROUTED_HDR_SIZE 6
26968 +unsigned char LLC_ROUTED_HEADER_2684[6] ={0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
26969 +
26970 +unsigned long PPP_LLC_HEADER = 0xCF03FEFE;
26971 +
26972 +/* struct definition */
26973 +enum
26974 +{
26975 + AAL5_ENCAP_PPP_LLC,
26976 + AAL5_ENCAP_PPP_VCMUX,
26977 + AAL5_ENCAP_RFC2684_LLC_BRIDGED,
26978 + AAL5_ENCAP_RFC2684_LLC_ROUTED
26979 +};
26980 +
26981 +/* Etherent header */
26982 +typedef struct _turbodsl_ether_header
26983 +{
26984 + unsigned char dst_mac_addr[6];
26985 + unsigned char src_mac_addr[6];
26986 + unsigned short ether_type;
26987 +} turbodsl_ether_header_t;
26988 +
26989 +
26990 +/* Ip header define */
26991 +typedef struct _turbodsl_ip_header
26992 +{
26993 +
26994 + unsigned short vit;
26995 + unsigned short total_length;
26996 + unsigned short ip_id;
26997 + unsigned char flag; /* bit 0 = 0, bit1 = don't fragment, bit2=more frag */
26998 + unsigned char fragment_offset; /* offset include remaining 5 bits above, which make it 13 bits */
26999 + unsigned char time_to_live;
27000 + unsigned char protocol;
27001 + unsigned short checksum;
27002 + unsigned int src_ip;
27003 + unsigned int dst_ip;
27004 +} turbodsl_ip_header_t;
27005 +
27006 +/* Arp packet define */
27007 +typedef struct _turbodsl_arp_header
27008 +{
27009 + unsigned short hardware_type;
27010 + unsigned short protocol_type;
27011 + unsigned char h_len;
27012 + unsigned char p_len;
27013 + unsigned short operation ;
27014 + unsigned char snd_hw_address[6];
27015 + unsigned char snd_pt_address[4];
27016 + unsigned char dst_hw_address[6];
27017 + unsigned char dst_pt_address[4];
27018 +} turbodsl_arp_header_t;
27019 +
27020 +#define FIN_FLAG 1
27021 +#define SYN_FLAG 1<<1
27022 +#define RST_FLAG 1<<2
27023 +#define PSH_FLAG 1<<3
27024 +#define ACK_FLAG 1<<4
27025 +#define URG_FLAG 1<<5
27026 +
27027 +typedef struct _turbodsl_tcp_header
27028 +{
27029 + unsigned short src_port;
27030 + unsigned short dst_port;
27031 + unsigned int seq_num;
27032 + unsigned int ack_num;
27033 + unsigned char offset; /* only bits 4-7 are for offset */
27034 + unsigned char flags; /* bits: 0-FIN, 1-SYN, 2-RST, 3-PSH, 4-ACK, 5-URG */
27035 + unsigned short windows;
27036 + unsigned short checksum;
27037 + unsigned short urgent_ptr;
27038 +} turbodsl_tcp_header_t;
27039 +
27040 +
27041 +
27042 +/***************************************************************************
27043 + * Function: turbodsl_memory_compare
27044 + * Descripation: Memory compare
27045 + ****************************************************************************/
27046 +int turbodsl_memory_compare(unsigned char *pIn, unsigned char *pOut, unsigned int len)
27047 + {
27048 + int i;
27049 +
27050 + for(i=0;i<(int)len; i++)
27051 + {
27052 + if(pIn[i] != pOut[i])
27053 + return 0;
27054 + }
27055 + return 1;
27056 + }
27057 +
27058 +/***************************************************************************
27059 + * Function: turbodsl_check_aal5_encap_type
27060 + * Descripation: Determine AAL5 Encapsulation type
27061 + * Input:
27062 + * unsigned char *pData, AAL5 Packet buffer pointer
27063 + ****************************************************************************/
27064 +int turbodsl_check_aal5_encap_type(unsigned char *pData)
27065 + {
27066 +
27067 + if(turbodsl_memory_compare(pData, LLC_BRIDGED_HEADER_2684, 6))
27068 + return AAL5_ENCAP_RFC2684_LLC_BRIDGED;
27069 + if(turbodsl_memory_compare(pData, LLC_ROUTED_HEADER_2684, 6))
27070 + return AAL5_ENCAP_RFC2684_LLC_ROUTED;
27071 + if(turbodsl_memory_compare(pData, (unsigned char *)&PPP_LLC_HEADER, sizeof(PPP_LLC_HEADER)))
27072 + return AAL5_ENCAP_PPP_LLC;
27073 +
27074 + return AAL5_ENCAP_PPP_VCMUX;
27075 + }
27076 +
27077 +/***************************************************************************
27078 + * Function: turbodsl_check_priority_type
27079 + * Descripation: Determine AAL5 Encapsulation type
27080 + * Input:
27081 + * unsigned char *pData, AAL5 Packet buffer pointer.
27082 + * short vpi, VPI.
27083 + * int vci, VCI
27084 + ****************************************************************************/
27085 +int turbodsl_check_priority_type(unsigned char *pData)
27086 + {
27087 + int encap;
27088 + unsigned char *pP;
27089 + unsigned short etherType;
27090 + turbodsl_ip_header_t *pIp;
27091 + turbodsl_tcp_header_t *pTcp;
27092 + unsigned short ip_length;
27093 +
27094 + dprintf(2, "turbodsl_check_priority_type ==>\n");
27095 +
27096 + encap = turbodsl_check_aal5_encap_type(pData);
27097 + pP = pData;
27098 +
27099 + switch(encap)
27100 + {
27101 + case AAL5_ENCAP_RFC2684_LLC_BRIDGED:
27102 + pP += RFC2684_BRIDGED_HDR_SIZE; //skip off aal5 encap
27103 + pP += 12; //skip of mac address
27104 + etherType = *(unsigned short *)pP;
27105 + if(etherType != 0x6488 && etherType != 0x0008)
27106 + {
27107 + //Not an IP packet
27108 + return 1;
27109 + }
27110 +
27111 + pP +=2; //skip ether type
27112 + if(etherType == 0x6488)
27113 + {
27114 + pP += 6;
27115 + }
27116 + break;
27117 + case AAL5_ENCAP_RFC2684_LLC_ROUTED:
27118 + pP += RFC2684_ROUTED_HDR_SIZE; //skip of encap
27119 + pP += 2; //skip ether type
27120 + break;
27121 + case AAL5_ENCAP_PPP_LLC:
27122 + pP += sizeof(PPP_LLC_HEADER);
27123 + if(*pP == 0xff && *(pP+1) == 0x03) //ppp hdlc header
27124 + pP += 2;
27125 + break;
27126 + case AAL5_ENCAP_PPP_VCMUX:
27127 + if(*pP == 0xff && *(pP+1) == 0x03) //ppp hdlc header
27128 + pP += 2;
27129 + break;
27130 + default:
27131 + return 1;
27132 + }
27133 +
27134 + pIp = (turbodsl_ip_header_t *)pP;
27135 + if(pIp->vit != 0x0045)
27136 + {
27137 + //Not a IP packet
27138 + return 1;
27139 + }
27140 +
27141 + if(pIp->protocol != 0x06)
27142 + {
27143 + //not tcp packet
27144 + return 1;
27145 + }
27146 +
27147 + pTcp = (turbodsl_tcp_header_t *)(pP + sizeof(turbodsl_ip_header_t));
27148 +
27149 + ip_length = (pIp->total_length>>8) + (pIp->total_length<<8);
27150 +
27151 + if((pTcp->flags & ACK_FLAG) && ip_length <=40)
27152 + return 0;
27153 +
27154 + return 1;
27155 + }
27156 +
27157 +
27158 +
27159 +
27160 +
27161 +
27162 +
27163 +
27164 +
27165 +
27166 +
27167 +
27168 +
27169 +
27170 +
27171 +
27172 +
27173 diff -urN linux.old/include/linux/atmdev.h linux.dev/include/linux/atmdev.h
27174 --- linux.old/include/linux/atmdev.h 2005-08-22 23:18:37.812526104 +0200
27175 +++ linux.dev/include/linux/atmdev.h 2005-08-23 06:33:33.425389944 +0200
27176 @@ -30,6 +30,9 @@
27177 #define ATM_DS3_PCR (8000*12)
27178 /* DS3: 12 cells in a 125 usec time slot */
27179
27180 +#define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer
27181 + quota per PDU */
27182 +
27183 #define ATM_SD(s) ((s)->sk->protinfo.af_atm)
27184
27185
27186 @@ -94,7 +97,8 @@
27187 /* set backend handler */
27188 #define ATM_NEWBACKENDIF _IOW('a',ATMIOC_SPECIAL+3,atm_backend_t)
27189 /* use backend to make new if */
27190 -
27191 +#define ATM_STOPTX _IOW('a',ATMIOC_SPECIAL+4,struct atmif_sioc)
27192 + /* Stop Tx on Sangam DSL */
27193 /*
27194 * These are backend handkers that can be set via the ATM_SETBACKEND call
27195 * above. In the future we may support dynamic loading of these - for now,
27196 @@ -199,7 +203,9 @@
27197 "SESSION", "HASSAP", "BOUND", "CLOSE"
27198
27199
27200 -#ifdef __KERNEL__
27201 +#ifndef __KERNEL__
27202 +#undef __AAL_STAT_ITEMS
27203 +#else
27204
27205 #include <linux/sched.h> /* wait_queue_head_t */
27206 #include <linux/time.h> /* struct timeval */
27207 @@ -291,6 +297,7 @@
27208 int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
27209 void *dev_data; /* per-device data */
27210 void *proto_data; /* per-protocol data */
27211 + struct timeval timestamp; /* AAL timestamps */
27212 struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
27213 wait_queue_head_t sleep; /* if socket is busy */
27214 struct sock *sk; /* socket backpointer */
27215 @@ -333,13 +340,14 @@
27216 struct k_atm_dev_stats stats; /* statistics */
27217 char signal; /* signal status (ATM_PHY_SIG_*) */
27218 int link_rate; /* link rate (default: OC3) */
27219 - atomic_t refcnt; /* reference count */
27220 - spinlock_t lock; /* protect internal members */
27221 + atomic_t refcnt; /* reference count */
27222 + spinlock_t lock; /* protect internal members */
27223 #ifdef CONFIG_PROC_FS
27224 struct proc_dir_entry *proc_entry; /* proc entry */
27225 char *proc_name; /* proc entry name */
27226 #endif
27227 - struct list_head dev_list; /* linkage */
27228 + struct list_head dev_list; /* linkage */
27229 +
27230 };
27231
27232
This page took 1.185774 seconds and 5 git commands to generate.