summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2010-09-01 11:52:36 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2010-09-01 11:52:36 +1000
commit739233d541de91f9ef64d48dd1b573ccbb8aa3c2 (patch)
treea852315b2aa98035acfaf624801d4edf00cf3f3e
parentb235f554105c08a1b61b4cc539a3a1d41451dfad (diff)
parent9b9913d80b2896ecd9e0a1a8f167ccad66fac79c (diff)
Merge remote branch 'staging-next/staging-next'
-rw-r--r--Documentation/ABI/testing/sysfs-block-zram99
-rw-r--r--drivers/staging/Kconfig8
-rw-r--r--drivers/staging/Makefile6
-rw-r--r--drivers/staging/adis16255/adis16255.c4
-rw-r--r--drivers/staging/comedi/drivers/adl_pci6208.c5
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9118.c5
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1710.c13
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1723.c5
-rw-r--r--drivers/staging/comedi/drivers/adv_pci_dio.c29
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c19
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c60
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidda.c15
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidio.c9
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdas.c6
-rw-r--r--drivers/staging/comedi/drivers/dt2817.c14
-rw-r--r--drivers/staging/comedi/drivers/dt3000.c17
-rw-r--r--drivers/staging/comedi/drivers/me4000.c29
-rw-r--r--drivers/staging/comedi/drivers/rtd520.c7
-rw-r--r--drivers/staging/comedi/drivers/skel.c7
-rw-r--r--drivers/staging/crystalhd/crystalhd_lnx.c1
-rw-r--r--drivers/staging/cx25821/cx25821-audio-upstream.c15
-rw-r--r--drivers/staging/cx25821/cx25821-audio.h16
-rw-r--r--drivers/staging/cx25821/cx25821-core.c13
-rw-r--r--drivers/staging/iio/Documentation/ring.txt6
-rw-r--r--drivers/staging/iio/Documentation/sysfs-class-iio72
-rw-r--r--drivers/staging/iio/Documentation/userspace.txt36
-rw-r--r--drivers/staging/iio/accel/accel.h42
-rw-r--r--drivers/staging/iio/accel/adis16209_core.c30
-rw-r--r--drivers/staging/iio/accel/adis16209_ring.c49
-rw-r--r--drivers/staging/iio/accel/adis16220_core.c14
-rw-r--r--drivers/staging/iio/accel/adis16240_core.c27
-rw-r--r--drivers/staging/iio/accel/adis16240_ring.c41
-rw-r--r--drivers/staging/iio/accel/inclinometer.h2
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_core.c2
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_ring.c62
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c4
-rw-r--r--drivers/staging/iio/accel/sca3000_ring.c12
-rw-r--r--drivers/staging/iio/adc/adc.h7
-rw-r--r--drivers/staging/iio/adc/max1363_core.c1
-rw-r--r--drivers/staging/iio/adc/max1363_ring.c18
-rw-r--r--drivers/staging/iio/gyro/adis16260_core.c22
-rw-r--r--drivers/staging/iio/gyro/adis16260_ring.c39
-rw-r--r--drivers/staging/iio/gyro/gyro.h46
-rw-r--r--drivers/staging/iio/iio.h98
-rw-r--r--drivers/staging/iio/imu/adis16300_core.c36
-rw-r--r--drivers/staging/iio/imu/adis16300_ring.c51
-rw-r--r--drivers/staging/iio/imu/adis16350_core.c45
-rw-r--r--drivers/staging/iio/imu/adis16350_ring.c55
-rw-r--r--drivers/staging/iio/imu/adis16400_core.c51
-rw-r--r--drivers/staging/iio/imu/adis16400_ring.c57
-rw-r--r--drivers/staging/iio/industrialio-core.c12
-rw-r--r--drivers/staging/iio/industrialio-ring.c46
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843.c61
-rw-r--r--drivers/staging/iio/ring_generic.h122
-rw-r--r--drivers/staging/iio/ring_sw.c79
-rw-r--r--drivers/staging/iio/ring_sw.h12
-rw-r--r--drivers/staging/iio/sysfs.h17
-rw-r--r--drivers/staging/line6/Kconfig67
-rw-r--r--drivers/staging/line6/audio.c16
-rw-r--r--drivers/staging/line6/audio.h7
-rw-r--r--drivers/staging/line6/capture.c231
-rw-r--r--drivers/staging/line6/capture.h25
-rw-r--r--drivers/staging/line6/control.c46
-rw-r--r--drivers/staging/line6/control.h190
-rw-r--r--drivers/staging/line6/driver.c569
-rw-r--r--drivers/staging/line6/driver.h57
-rw-r--r--drivers/staging/line6/dumprequest.c60
-rw-r--r--drivers/staging/line6/dumprequest.h28
-rw-r--r--drivers/staging/line6/midi.c96
-rw-r--r--drivers/staging/line6/midi.h9
-rw-r--r--drivers/staging/line6/midibuf.c90
-rw-r--r--drivers/staging/line6/midibuf.h31
-rw-r--r--drivers/staging/line6/pcm.c320
-rw-r--r--drivers/staging/line6/pcm.h144
-rw-r--r--drivers/staging/line6/playback.c313
-rw-r--r--drivers/staging/line6/playback.h28
-rw-r--r--drivers/staging/line6/pod.c758
-rw-r--r--drivers/staging/line6/pod.h127
-rw-r--r--drivers/staging/line6/revision.h2
-rw-r--r--drivers/staging/line6/toneport.c276
-rw-r--r--drivers/staging/line6/toneport.h33
-rw-r--r--drivers/staging/line6/usbdefs.h42
-rw-r--r--drivers/staging/line6/variax.c356
-rw-r--r--drivers/staging/line6/variax.h84
-rw-r--r--drivers/staging/lirc/lirc_imon.c7
-rw-r--r--drivers/staging/lirc/lirc_sasem.c2
-rw-r--r--drivers/staging/mrst-touchscreen/Makefile2
-rw-r--r--drivers/staging/mrst-touchscreen/intel-mid-touch.c29
-rw-r--r--drivers/staging/otus/80211core/ratectrl.c26
-rw-r--r--drivers/staging/pohmelfs/config.c34
-rw-r--r--drivers/staging/quickstart/quickstart.c7
-rw-r--r--drivers/staging/rt2860/ap.h20
-rw-r--r--drivers/staging/rt2860/eeprom.h4
-rw-r--r--drivers/staging/rt2860/iface/rtmp_pci.h42
-rw-r--r--drivers/staging/rt2860/iface/rtmp_usb.h110
-rw-r--r--drivers/staging/rt2860/oid.h2
-rw-r--r--drivers/staging/rt2860/rtmp.h18
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c4
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c10
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_module.c71
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c2
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c18
-rw-r--r--drivers/staging/rtl8192e/r8180_93cx6.c8
-rw-r--r--drivers/staging/rtl8192e/r8190_rtl8256.c2
-rw-r--r--drivers/staging/rtl8192e/r8192E.h7
-rw-r--r--drivers/staging/rtl8192e/r8192E_core.c155
-rw-r--r--drivers/staging/rtl8192e/r8192E_dm.c50
-rw-r--r--drivers/staging/rtl8192e/r8192E_dm.h2
-rw-r--r--drivers/staging/rtl8192e/r8192E_wx.c38
-rw-r--r--drivers/staging/rtl8192e/r8192_pm.c6
-rw-r--r--drivers/staging/rtl8192e/r819xE_firmware.c12
-rw-r--r--drivers/staging/rtl8192e/r819xE_phy.c23
-rw-r--r--drivers/staging/rtl8192su/Kconfig9
-rw-r--r--drivers/staging/rtl8192su/Makefile39
-rw-r--r--drivers/staging/rtl8192su/TODO21
-rw-r--r--drivers/staging/rtl8192su/authors1
-rw-r--r--drivers/staging/rtl8192su/ieee80211/Makefile30
-rw-r--r--drivers/staging/rtl8192su/ieee80211/dot11d.c224
-rw-r--r--drivers/staging/rtl8192su/ieee80211/dot11d.h111
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211.h1934
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c242
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h86
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c471
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c776
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c294
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_module.c301
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_r8192s.h449
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c2580
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c3291
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c625
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c916
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c772
-rw-r--r--drivers/staging/rtl8192su/ieee80211/readme162
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h79
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c745
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h530
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c1725
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h540
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h71
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c631
-rw-r--r--drivers/staging/rtl8192su/r8192SU_HWImg.c647
-rw-r--r--drivers/staging/rtl8192su/r8192SU_HWImg.h60
-rw-r--r--drivers/staging/rtl8192su/r8192SU_led.c2338
-rw-r--r--drivers/staging/rtl8192su/r8192SU_led.h93
-rw-r--r--drivers/staging/rtl8192su/r8192S_Efuse.c2199
-rw-r--r--drivers/staging/rtl8192su/r8192S_Efuse.h79
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.c481
-rw-r--r--drivers/staging/rtl8192su/r8192S_firmware.h210
-rw-r--r--drivers/staging/rtl8192su/r8192S_hw.h1445
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.c3634
-rw-r--r--drivers/staging/rtl8192su/r8192S_phy.h135
-rw-r--r--drivers/staging/rtl8192su/r8192S_phyreg.h1033
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.c842
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl6052.h87
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl8225.c292
-rw-r--r--drivers/staging/rtl8192su/r8192S_rtl8225.h30
-rw-r--r--drivers/staging/rtl8192su/r8192U.h1519
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c7712
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.c3982
-rw-r--r--drivers/staging/rtl8192su/r8192U_dm.h254
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.c72
-rw-r--r--drivers/staging/rtl8192su/r8192U_pm.h25
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.c1296
-rw-r--r--drivers/staging/rtl8192su/r8192U_wx.h22
-rw-r--r--drivers/staging/rtl8192su/r819xU_HTGen.h22
-rw-r--r--drivers/staging/rtl8192su/r819xU_HTType.h383
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.c512
-rw-r--r--drivers/staging/rtl8192su/r819xU_cmdpkt.h192
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c2
-rw-r--r--drivers/staging/rtl8712/Kconfig18
-rw-r--r--drivers/staging/rtl8712/Makefile34
-rw-r--r--drivers/staging/rtl8712/TODO16
-rw-r--r--drivers/staging/rtl8712/basic_types.h23
-rw-r--r--drivers/staging/rtl8712/big_endian.h69
-rw-r--r--drivers/staging/rtl8712/drv_types.h165
-rw-r--r--drivers/staging/rtl8712/ethernet.h23
-rw-r--r--drivers/staging/rtl8712/farray.h10197
-rw-r--r--drivers/staging/rtl8712/generic.h153
-rw-r--r--drivers/staging/rtl8712/hal_init.c358
-rw-r--r--drivers/staging/rtl8712/ieee80211.c454
-rw-r--r--drivers/staging/rtl8712/ieee80211.h770
-rw-r--r--drivers/staging/rtl8712/if_ether.h116
-rw-r--r--drivers/staging/rtl8712/ip.h137
-rw-r--r--drivers/staging/rtl8712/little_endian.h69
-rw-r--r--drivers/staging/rtl8712/mlme_linux.c170
-rw-r--r--drivers/staging/rtl8712/mlme_osdep.h18
-rw-r--r--drivers/staging/rtl8712/mp_custom_oid.h274
-rw-r--r--drivers/staging/rtl8712/os_intfs.c464
-rw-r--r--drivers/staging/rtl8712/osdep_intf.h19
-rw-r--r--drivers/staging/rtl8712/osdep_service.h260
-rw-r--r--drivers/staging/rtl8712/recv_linux.c169
-rw-r--r--drivers/staging/rtl8712/recv_osdep.h27
-rw-r--r--drivers/staging/rtl8712/rtl8712_bitdef.h19
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmd.c465
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmd.h157
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h89
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h15
-rw-r--r--drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h36
-rw-r--r--drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h28
-rw-r--r--drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h52
-rw-r--r--drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h18
-rw-r--r--drivers/staging/rtl8712/rtl8712_efuse.c568
-rw-r--r--drivers/staging/rtl8712/rtl8712_efuse.h43
-rw-r--r--drivers/staging/rtl8712/rtl8712_event.h73
-rw-r--r--drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h126
-rw-r--r--drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h57
-rw-r--r--drivers/staging/rtl8712/rtl8712_gp_bitdef.h54
-rw-r--r--drivers/staging/rtl8712/rtl8712_gp_regdef.h17
-rw-r--r--drivers/staging/rtl8712/rtl8712_hal.h124
-rw-r--r--drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h39
-rw-r--r--drivers/staging/rtl8712/rtl8712_io.c151
-rw-r--r--drivers/staging/rtl8712/rtl8712_led.c1815
-rw-r--r--drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h28
-rw-r--r--drivers/staging/rtl8712/rtl8712_macsetting_regdef.h16
-rw-r--r--drivers/staging/rtl8712/rtl8712_powersave_bitdef.h33
-rw-r--r--drivers/staging/rtl8712/rtl8712_powersave_regdef.h20
-rw-r--r--drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h30
-rw-r--r--drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h31
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.c1131
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.h128
-rw-r--r--drivers/staging/rtl8712/rtl8712_regdef.h19
-rw-r--r--drivers/staging/rtl8712/rtl8712_security_bitdef.h29
-rw-r--r--drivers/staging/rtl8712/rtl8712_spec.h110
-rw-r--r--drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h145
-rw-r--r--drivers/staging/rtl8712/rtl8712_syscfg_regdef.h31
-rw-r--r--drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h44
-rw-r--r--drivers/staging/rtl8712/rtl8712_timectrl_regdef.h20
-rw-r--r--drivers/staging/rtl8712/rtl8712_wmac_bitdef.h37
-rw-r--r--drivers/staging/rtl8712/rtl8712_wmac_regdef.h24
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.c509
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.h95
-rw-r--r--drivers/staging/rtl8712/rtl871x_byteorder.h13
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.c926
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.h719
-rw-r--r--drivers/staging/rtl8712/rtl871x_debug.h142
-rw-r--r--drivers/staging/rtl8712/rtl871x_eeprom.c233
-rw-r--r--drivers/staging/rtl8712/rtl871x_eeprom.h82
-rw-r--r--drivers/staging/rtl8712/rtl871x_event.h95
-rw-r--r--drivers/staging/rtl8712/rtl871x_ht.h19
-rw-r--r--drivers/staging/rtl8712/rtl871x_io.c163
-rw-r--r--drivers/staging/rtl8712/rtl871x_io.h233
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl.h97
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_linux.c2258
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_rtl.c535
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_rtl.h96
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_set.c379
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_set.h24
-rw-r--r--drivers/staging/rtl8712/rtl871x_led.h99
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.c1840
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.h208
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp.c736
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp.h318
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_ioctl.c1475
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_ioctl.h457
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h1025
-rw-r--r--drivers/staging/rtl8712/rtl871x_pwrctrl.c250
-rw-r--r--drivers/staging/rtl8712/rtl871x_pwrctrl.h127
-rw-r--r--drivers/staging/rtl8712/rtl871x_recv.c693
-rw-r--r--drivers/staging/rtl8712/rtl871x_recv.h330
-rw-r--r--drivers/staging/rtl8712/rtl871x_rf.h43
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.c1389
-rw-r--r--drivers/staging/rtl8712/rtl871x_security.h196
-rw-r--r--drivers/staging/rtl8712/rtl871x_sta_mgt.c299
-rw-r--r--drivers/staging/rtl8712/rtl871x_wlan_sme.h22
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.c1052
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.h260
-rw-r--r--drivers/staging/rtl8712/sta_info.h125
-rw-r--r--drivers/staging/rtl8712/swab.h106
-rw-r--r--drivers/staging/rtl8712/usb_halinit.c317
-rw-r--r--drivers/staging/rtl8712/usb_intf.c571
-rw-r--r--drivers/staging/rtl8712/usb_ops.c201
-rw-r--r--drivers/staging/rtl8712/usb_ops.h25
-rw-r--r--drivers/staging/rtl8712/usb_ops_linux.c529
-rw-r--r--drivers/staging/rtl8712/usb_osintf.h24
-rw-r--r--drivers/staging/rtl8712/usb_vendor_req.h33
-rw-r--r--drivers/staging/rtl8712/wifi.h622
-rw-r--r--drivers/staging/rtl8712/wlan_bssdef.h242
-rw-r--r--drivers/staging/rtl8712/xmit_linux.c182
-rw-r--r--drivers/staging/rtl8712/xmit_osdep.h38
-rw-r--r--drivers/staging/sbe-2t3e3/2t3e3.h894
-rw-r--r--drivers/staging/sbe-2t3e3/Kconfig13
-rw-r--r--drivers/staging/sbe-2t3e3/Makefile4
-rw-r--r--drivers/staging/sbe-2t3e3/TODO6
-rw-r--r--drivers/staging/sbe-2t3e3/cpld.c366
-rw-r--r--drivers/staging/sbe-2t3e3/ctrl.c362
-rw-r--r--drivers/staging/sbe-2t3e3/ctrl.h131
-rw-r--r--drivers/staging/sbe-2t3e3/dc.c502
-rw-r--r--drivers/staging/sbe-2t3e3/exar7250.c217
-rw-r--r--drivers/staging/sbe-2t3e3/exar7300.c182
-rw-r--r--drivers/staging/sbe-2t3e3/intr.c635
-rw-r--r--drivers/staging/sbe-2t3e3/io.c352
-rw-r--r--drivers/staging/sbe-2t3e3/main.c171
-rw-r--r--drivers/staging/sbe-2t3e3/maps.c104
-rw-r--r--drivers/staging/sbe-2t3e3/module.c210
-rw-r--r--drivers/staging/sbe-2t3e3/netdev.c142
-rw-r--r--drivers/staging/slicoss/slic.h8
-rw-r--r--drivers/staging/slicoss/slicoss.c42
-rw-r--r--drivers/staging/sm7xx/smtcfb.c13
-rw-r--r--drivers/staging/solo6x10/solo6010-core.c40
-rw-r--r--drivers/staging/solo6x10/solo6010-g723.c2
-rw-r--r--drivers/staging/spectra/lld_nand.c7
-rw-r--r--drivers/staging/ti-st/st.h1
-rw-r--r--drivers/staging/ti-st/st_core.c14
-rw-r--r--drivers/staging/ti-st/st_core.h2
-rw-r--r--drivers/staging/ti-st/st_kim.c22
-rw-r--r--drivers/staging/tidspbridge/Makefile4
-rw-r--r--drivers/staging/tidspbridge/core/chnl_sm.c1
-rw-r--r--drivers/staging/tidspbridge/core/dsp-clock.c1
-rw-r--r--drivers/staging/tidspbridge/core/io_sm.c1
-rw-r--r--drivers/staging/tidspbridge/core/sync.c (renamed from drivers/staging/tidspbridge/services/sync.c)17
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430.c1
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430_pwr.c4
-rw-r--r--drivers/staging/tidspbridge/core/tiomap_io.c1
-rw-r--r--drivers/staging/tidspbridge/gen/gb.c1
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/cfg.h222
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/services.h50
-rw-r--r--drivers/staging/tidspbridge/pmgr/chnl.c1
-rw-r--r--drivers/staging/tidspbridge/pmgr/cmm.c1
-rw-r--r--drivers/staging/tidspbridge/pmgr/dev.c69
-rw-r--r--drivers/staging/tidspbridge/pmgr/dspapi.c12
-rw-r--r--drivers/staging/tidspbridge/pmgr/io.c3
-rw-r--r--drivers/staging/tidspbridge/rmgr/drv.c59
-rw-r--r--drivers/staging/tidspbridge/rmgr/drv_interface.c14
-rw-r--r--drivers/staging/tidspbridge/rmgr/dspdrv.c12
-rw-r--r--drivers/staging/tidspbridge/rmgr/mgr.c52
-rw-r--r--drivers/staging/tidspbridge/rmgr/node.c1
-rw-r--r--drivers/staging/tidspbridge/rmgr/proc.c48
-rw-r--r--drivers/staging/tidspbridge/rmgr/strm.c1
-rw-r--r--drivers/staging/tidspbridge/services/cfg.c253
-rw-r--r--drivers/staging/tidspbridge/services/ntfy.c31
-rw-r--r--drivers/staging/tidspbridge/services/services.c70
-rw-r--r--drivers/staging/tm6000/tm6000-alsa.c7
-rw-r--r--drivers/staging/tm6000/tm6000-core.c6
-rw-r--r--drivers/staging/usbip/stub_dev.c2
-rw-r--r--drivers/staging/vt6655/device_main.c3
-rw-r--r--drivers/staging/vt6655/iwctl.c2
-rw-r--r--drivers/staging/vt6656/80211mgr.h10
-rw-r--r--drivers/staging/vt6656/baseband.c2
-rw-r--r--drivers/staging/vt6656/bssdb.c14
-rw-r--r--drivers/staging/vt6656/device.h19
-rw-r--r--drivers/staging/vt6656/dpc.c17
-rw-r--r--drivers/staging/vt6656/firmware.c4
-rw-r--r--drivers/staging/vt6656/ioctl.c2
-rw-r--r--drivers/staging/vt6656/iwctl.c20
-rw-r--r--drivers/staging/vt6656/iwctl.h3
-rw-r--r--drivers/staging/vt6656/key.c2
-rw-r--r--drivers/staging/vt6656/main_usb.c29
-rw-r--r--drivers/staging/vt6656/power.c6
-rw-r--r--drivers/staging/vt6656/rxtx.c26
-rw-r--r--drivers/staging/vt6656/tether.h34
-rw-r--r--drivers/staging/vt6656/usbpipe.c52
-rw-r--r--drivers/staging/vt6656/wcmd.c4
-rw-r--r--drivers/staging/vt6656/wmgr.c19
-rw-r--r--drivers/staging/vt6656/wmgr.h2
-rw-r--r--drivers/staging/vt6656/wpa.c8
-rw-r--r--drivers/staging/vt6656/wpactl.c6
-rw-r--r--drivers/staging/westbridge/Kconfig34
-rw-r--r--drivers/staging/westbridge/TODO7
-rw-r--r--drivers/staging/westbridge/astoria/Kconfig9
-rw-r--r--drivers/staging/westbridge/astoria/Makefile11
-rw-r--r--drivers/staging/westbridge/astoria/api/Makefile14
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasdma.c1107
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasintr.c143
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyaslep2pep.c358
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyaslowlevel.c1264
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasmisc.c3474
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasmtp.c1128
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasstorage.c4104
-rw-r--r--drivers/staging/westbridge/astoria/api/src/cyasusb.c3718
-rw-r--r--drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c2450
-rw-r--r--drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/cyashaldef.h55
-rw-r--r--drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h319
-rw-r--r--drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h555
-rw-r--r--drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h72
-rw-r--r--drivers/staging/westbridge/astoria/block/Kconfig9
-rw-r--r--drivers/staging/westbridge/astoria/block/Makefile11
-rw-r--r--drivers/staging/westbridge/astoria/block/cyasblkdev_block.c1628
-rw-r--r--drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c417
-rw-r--r--drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h64
-rw-r--r--drivers/staging/westbridge/astoria/device/Kconfig9
-rw-r--r--drivers/staging/westbridge/astoria/device/Makefile23
-rw-r--r--drivers/staging/westbridge/astoria/device/cyandevice_export.h132
-rw-r--r--drivers/staging/westbridge/astoria/device/cyasdevice.c394
-rw-r--r--drivers/staging/westbridge/astoria/gadget/Kconfig9
-rw-r--r--drivers/staging/westbridge/astoria/gadget/Makefile11
-rw-r--r--drivers/staging/westbridge/astoria/gadget/cyasgadget.c2211
-rw-r--r--drivers/staging/westbridge/astoria/gadget/cyasgadget.h193
-rw-r--r--drivers/staging/westbridge/astoria/gadget/cyasgadget_ioctl.h99
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanerr.h418
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmedia.h59
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmisc.h614
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanregs.h180
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyansdkversion.h30
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanstorage.h419
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyantioch.h35
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyantypes.h31
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyanusb.h619
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_end.h11
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_start.h11
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyascast.h35
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdevice.h1057
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdma.h375
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyaserr.h1094
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h108
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyashalcb.h44
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyashaldoc.h800
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasintr.h104
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslep2pep.h36
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h366
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmedia.h54
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h1549
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc_dep.h53
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmtp.h646
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasprotocol.h3838
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasregs.h201
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage.h2759
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage_dep.h309
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyastoria.h36
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyastsdkversion.h30
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyastypes.h71
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb.h1862
-rw-r--r--drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb_dep.h224
-rw-r--r--drivers/staging/xgifb/XGI_accel.h3
-rw-r--r--drivers/staging/xgifb/XGI_main.h30
-rw-r--r--drivers/staging/xgifb/XGI_main_26.c29
-rw-r--r--drivers/staging/xgifb/vb_ext.c14
-rw-r--r--drivers/staging/xgifb/vb_init.c108
-rw-r--r--drivers/staging/xgifb/vb_setmode.c63
-rw-r--r--drivers/staging/xgifb/vb_table.h620
-rw-r--r--drivers/staging/xgifb/vb_util.c7
-rw-r--r--drivers/staging/zram/Kconfig12
-rw-r--r--drivers/staging/zram/Makefile2
-rw-r--r--drivers/staging/zram/zram.txt58
-rw-r--r--drivers/staging/zram/zram_drv.c221
-rw-r--r--drivers/staging/zram/zram_drv.h57
-rw-r--r--drivers/staging/zram/zram_ioctl.h41
-rw-r--r--drivers/staging/zram/zram_sysfs.c224
438 files changed, 91774 insertions, 51420 deletions
diff --git a/Documentation/ABI/testing/sysfs-block-zram b/Documentation/ABI/testing/sysfs-block-zram
new file mode 100644
index 000000000000..c8b3b48ec62c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-block-zram
@@ -0,0 +1,99 @@
+What: /sys/block/zram<id>/disksize
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The disksize file is read-write and specifies the disk size
+ which represents the limit on the *uncompressed* worth of data
+ that can be stored in this disk.
+
+What: /sys/block/zram<id>/initstate
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The disksize file is read-only and shows the initialization
+ state of the device.
+
+What: /sys/block/zram<id>/reset
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The disksize file is write-only and allows resetting the
+ device. The reset operation frees all the memory assocaited
+ with this device.
+
+What: /sys/block/zram<id>/num_reads
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The num_reads file is read-only and specifies the number of
+ reads (failed or successful) done on this device.
+
+What: /sys/block/zram<id>/num_writes
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The num_writes file is read-only and specifies the number of
+ writes (failed or successful) done on this device.
+
+What: /sys/block/zram<id>/invalid_io
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The invalid_io file is read-only and specifies the number of
+ non-page-size-aligned I/O requests issued to this device.
+
+What: /sys/block/zram<id>/notify_free
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The notify_free file is read-only and specifies the number of
+ swap slot free notifications received by this device. These
+ notifications are send to a swap block device when a swap slot
+ is freed. This statistic is applicable only when this disk is
+ being used as a swap disk.
+
+What: /sys/block/zram<id>/discard
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The discard file is read-only and specifies the number of
+ discard requests received by this device. These requests
+ provide information to block device regarding blocks which are
+ no longer used by filesystem.
+
+What: /sys/block/zram<id>/zero_pages
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The zero_pages file is read-only and specifies number of zero
+ filled pages written to this disk. No memory is allocated for
+ such pages.
+
+What: /sys/block/zram<id>/orig_data_size
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The orig_data_size file is read-only and specifies uncompressed
+ size of data stored in this disk. This excludes zero-filled
+ pages (zero_pages) since no memory is allocated for them.
+ Unit: bytes
+
+What: /sys/block/zram<id>/compr_data_size
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The compr_data_size file is read-only and specifies compressed
+ size of data stored in this disk. So, compression ratio can be
+ calculated using orig_data_size and this statistic.
+ Unit: bytes
+
+What: /sys/block/zram<id>/mem_used_total
+Date: August 2010
+Contact: Nitin Gupta <ngupta@vflare.org>
+Description:
+ The mem_used_total file is read-only and specifies the amount
+ of memory, including allocator fragmentation and metadata
+ overhead, allocated for this disk. So, allocator space
+ efficiency can be calculated using compr_data_size and this
+ statistic.
+ Unit: bytes \ No newline at end of file
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 335311a98fdc..a3897c52afa0 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -73,12 +73,12 @@ source "drivers/staging/panel/Kconfig"
source "drivers/staging/rtl8187se/Kconfig"
-source "drivers/staging/rtl8192su/Kconfig"
-
source "drivers/staging/rtl8192u/Kconfig"
source "drivers/staging/rtl8192e/Kconfig"
+source "drivers/staging/rtl8712/Kconfig"
+
source "drivers/staging/frontier/Kconfig"
source "drivers/staging/dream/Kconfig"
@@ -153,5 +153,9 @@ source "drivers/staging/tidspbridge/Kconfig"
source "drivers/staging/quickstart/Kconfig"
+source "drivers/staging/westbridge/Kconfig"
+
+source "drivers/staging/sbe-2t3e3/Kconfig"
+
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index e3f1e1b6095e..dd2c66fdf979 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -20,9 +20,9 @@ obj-$(CONFIG_COMEDI) += comedi/
obj-$(CONFIG_ASUS_OLED) += asus_oled/
obj-$(CONFIG_PANEL) += panel/
obj-$(CONFIG_R8187SE) += rtl8187se/
-obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/
+obj-$(CONFIG_R8712U) += rtl8712/
obj-$(CONFIG_SPECTRA) += spectra/
obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_DREAM) += dream/
@@ -51,9 +51,11 @@ obj-$(CONFIG_CXT1E1) += cxt1e1/
obj-$(CONFIG_TI_ST) += ti-st/
obj-$(CONFIG_ADIS16255) += adis16255/
obj-$(CONFIG_FB_XGI) += xgifb/
-obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH) += mrst-touchscreen/
+obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += mrst-touchscreen/
obj-$(CONFIG_MSM_STAGING) += msm/
obj-$(CONFIG_EASYCAP) += easycap/
obj-$(CONFIG_SOLO6X10) += solo6x10/
obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge/
obj-$(CONFIG_ACPI_QUICKSTART) += quickstart/
+obj-$(CONFIG_WESTBRIDGE_ASTORIA) += westbridge/astoria/
+obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3/
diff --git a/drivers/staging/adis16255/adis16255.c b/drivers/staging/adis16255/adis16255.c
index c3e6a4d5f334..8d4d7cbab979 100644
--- a/drivers/staging/adis16255/adis16255.c
+++ b/drivers/staging/adis16255/adis16255.c
@@ -406,12 +406,14 @@ static int __devinit spi_adis16255_probe(struct spi_device *spi)
status = spi_adis16255_bringup(spiadis);
if (status != 0)
- goto irq_err;
+ goto sysfs_err;
dev_info(&spi->dev, "spi_adis16255 driver added!\n");
return status;
+sysfs_err:
+ sysfs_remove_group(&spiadis->spi->dev.kobj, &adis16255_attr_group);
irq_err:
free_irq(spiadis->irq, spiadis);
gpio_err:
diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index 073d0242c28e..4fc9e8520217 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -90,9 +90,8 @@ static const struct pci6208_board pci6208_boards[] = {
static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
- {
- PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index b0e39cb74774..a2bd4e6aff19 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -252,9 +252,8 @@ struct boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci9118_pci_table) = {
- {
- PCI_VENDOR_ID_AMCC, 0x80d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80d9) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pci9118_pci_table);
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index bdd6954cad96..466e69f94ef2 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -217,13 +217,12 @@ struct boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
- {
- PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index b133bb84c4fe..1b5682104a08 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -155,9 +155,8 @@ static const struct pci1723_board boardtypes[] = {
* Should only be used for PCI and ISA-PnP devices
*/
static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = {
- {
- PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1723) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index d018bb4e2890..9102667ab40e 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -256,21 +256,20 @@ struct dio_boardtype {
};
static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = {
- {
- PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1735, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1730) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1733) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1734) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1735) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1736) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1750) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1751) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1752) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1753) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1754) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1756) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1760) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1762) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pci_dio_pci_table);
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 6530b6c9d98b..3275fc50615f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -377,16 +377,15 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
};
static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
- {
- PCI_VENDOR_ID_CB, 0x0001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x000f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x001c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x004c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x001a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x001b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0010) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0019) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001c) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x004c) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001a) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001b) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 53e7015869fc..9b1dd3cc2120 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -1028,46 +1028,26 @@ static const struct pcidas64_board pcidas64_boards[] = {
};
static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = {
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pcidas64_pci_table);
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c
index 2d35143b8e52..6383fc93b83d 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/staging/comedi/drivers/cb_pcidda.c
@@ -196,14 +196,13 @@ static const struct cb_pcidda_board cb_pcidda_boards[] = {
};
static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
- {
- PCI_VENDOR_ID_CB, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0020) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0021) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0022) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0023) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0024) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0025) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c
index c1693c91a6d0..79477a595ef9 100644
--- a/drivers/staging/comedi/drivers/cb_pcidio.c
+++ b/drivers/staging/comedi/drivers/cb_pcidio.c
@@ -91,11 +91,10 @@ static const struct pcidio_board pcidio_boards[] = {
/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
* upstream. */
static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = {
- {
- PCI_VENDOR_ID_CB, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_CB, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0028) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0014) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000b) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
index ced346a7cae3..16c322d040fd 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -126,10 +126,8 @@ static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
/* This is used by modprobe to translate PCI IDs to drivers. Should
* only be used for PCI and ISA-PnP devices */
static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
- {
- PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c
index 651fe050d029..99c1584153d7 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/staging/comedi/drivers/dt2817.c
@@ -82,13 +82,13 @@ static int dt2817_dio_insn_config(struct comedi_device *dev,
return -EINVAL;
chan = CR_CHAN(insn->chanspec);
- if (chan < 8) {
+ if (chan < 8)
mask = 0xff;
- } else if (chan < 16) {
+ else if (chan < 16)
mask = 0xff00;
- } else if (chan < 24) {
+ else if (chan < 24)
mask = 0xff0000;
- } else
+ else
mask = 0xff000000;
if (data[0])
s->io_bits |= mask;
@@ -152,7 +152,7 @@ static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned long iobase;
iobase = it->options[0];
- printk("comedi%d: dt2817: 0x%04lx ", dev->minor, iobase);
+ printk(KERN_INFO "comedi%d: dt2817: 0x%04lx ", dev->minor, iobase);
if (!request_region(iobase, DT2817_SIZE, "dt2817")) {
printk("I/O port conflict\n");
return -EIO;
@@ -177,14 +177,14 @@ static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->state = 0;
outb(0, dev->iobase + DT2817_CR);
- printk("\n");
+ printk(KERN_INFO "\n");
return 0;
}
static int dt2817_detach(struct comedi_device *dev)
{
- printk("comedi%d: dt2817: remove\n", dev->minor);
+ printk(KERN_INFO "comedi%d: dt2817: remove\n", dev->minor);
if (dev->iobase)
release_region(dev->iobase, DT2817_SIZE);
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
index 656e7bbf2fcb..6170f7bac46e 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -165,15 +165,14 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
#define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
- {
- PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0022) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0027) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0023) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0024) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0028) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0025) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0026) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index 14713849564d..e6825c2569a5 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -71,21 +71,20 @@ broken.
===========================================================================*/
static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = {
- {
- PCI_VENDOR_ID_MEILHAUS, 0x4650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4661, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4662, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4670, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4671, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4672, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4673, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4681, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4682, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_MEILHAUS, 0x4683, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4650) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4660) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4661) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4662) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4663) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4670) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4671) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4672) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4673) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4680) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4681) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4682) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4683) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, me4000_pci_table);
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c
index 0367d2b9e2fa..5858d97fcd05 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -329,10 +329,9 @@ static const struct rtdBoard rtd520Boards[] = {
};
static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = {
- {
- PCI_VENDOR_ID_RTD, 0x7520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_RTD, 0x4520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x7520) },
+ { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x4520) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, rtd520_pci_table);
diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c
index 0b9ecb19511e..ed69008f0d39 100644
--- a/drivers/staging/comedi/drivers/skel.c
+++ b/drivers/staging/comedi/drivers/skel.c
@@ -116,10 +116,9 @@ static const struct skel_board skel_boards[] = {
* upstream. */
#define PCI_VENDOR_ID_SKEL 0xdafe
static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
- {
- PCI_VENDOR_ID_SKEL, 0x0100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- PCI_VENDOR_ID_SKEL, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
- 0}
+ { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0100) },
+ { PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0200) },
+ { 0 }
};
MODULE_DEVICE_TABLE(pci, skel_pci_table);
diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index fbb80f09a3d9..115e79b8b4eb 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -570,6 +570,7 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
rc = chd_pci_reserve_mem(pinfo);
if (rc) {
BCMLOG_ERR("Failed to setup memory regions.\n");
+ pci_disable_device(pdev);
return -ENOMEM;
}
diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c
index cdff49f409f2..27087dbe5b7d 100644
--- a/drivers/staging/cx25821/cx25821-audio-upstream.c
+++ b/drivers/staging/cx25821/cx25821-audio-upstream.c
@@ -40,8 +40,7 @@ MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
MODULE_LICENSE("GPL");
static int _intr_msk =
- FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | FLD_AUD_SRC_SYNC |
- FLD_AUD_SRC_OPC_ERR;
+FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | FLD_AUD_SRC_SYNC | FLD_AUD_SRC_OPC_ERR;
int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
struct sram_channel *ch,
@@ -506,7 +505,7 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num,
{
int i = 0;
u32 int_msk_tmp;
- struct sram_channel *channel = dev->channels[chan_num].sram_channels;
+ struct sram_channel *channel = dev->channels[chan_num].sram_channels;
dma_addr_t risc_phys_jump_addr;
__le32 *rp;
@@ -608,8 +607,8 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
if (!dev)
return -1;
- sram_ch = dev->channels[dev->_audio_upstream_channel_select].
- sram_channels;
+ sram_ch = dev->channels[dev->_audio_upstream_channel_select].
+ sram_channels;
msk_stat = cx_read(sram_ch->int_mstat);
audio_status = cx_read(sram_ch->int_stat);
@@ -733,7 +732,7 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
}
dev->_audio_upstream_channel_select = channel_select;
- sram_ch = dev->channels[channel_select].sram_channels;
+ sram_ch = dev->channels[channel_select].sram_channels;
/* Work queue */
INIT_WORK(&dev->_audio_work_entry, cx25821_audioups_handler);
@@ -764,9 +763,9 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
str_length + 1);
/* Default if filename is empty string */
- if (strcmp(dev->input_audiofilename, "") == 0) {
+ if (strcmp(dev->input_audiofilename, "") == 0)
dev->_audiofilename = "/root/audioGOOD.wav";
- }
+
} else {
str_length = strlen(_defaultAudioName);
dev->_audiofilename = kmalloc(str_length + 1, GFP_KERNEL);
diff --git a/drivers/staging/cx25821/cx25821-audio.h b/drivers/staging/cx25821/cx25821-audio.h
index 434b2a312a80..aa5725b09328 100644
--- a/drivers/staging/cx25821/cx25821-audio.h
+++ b/drivers/staging/cx25821/cx25821-audio.h
@@ -31,18 +31,21 @@
#define NUMBER_OF_PROGRAMS 8
/*
- Max size of the RISC program for a buffer. - worst case is 2 writes per line
- Space is also added for the 4 no-op instructions added on the end.
+* Max size of the RISC program for a buffer. - worst case is 2 writes per line
+* Space is also added for the 4 no-op instructions added on the end.
*/
#ifndef USE_RISC_NOOP
-#define MAX_BUFFER_PROGRAM_SIZE \
- (2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE*4)
+#define MAX_BUFFER_PROGRAM_SIZE \
+(2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + \
+ RISC_WRITECR_INSTRUCTION_SIZE*4)
+
#endif
/* MAE 12 July 2005 Try to use NOOP RISC instruction instead */
#ifdef USE_RISC_NOOP
#define MAX_BUFFER_PROGRAM_SIZE \
- (2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_NOOP_INSTRUCTION_SIZE*4)
+(2*LINES_PER_BUFFER*RISC_WRITE_INSTRUCTION_SIZE + RISC_NOOP_INSTRUCTION_SIZE*4l)
+
#endif
/* Sizes of various instructions in bytes. Used when adding instructions. */
@@ -53,6 +56,7 @@
#define RISC_WRITECR_INSTRUCTION_SIZE 16
#define RISC_NOOP_INSTRUCTION_SIZE 4
-#define MAX_AUDIO_DMA_BUFFER_SIZE (MAX_BUFFER_PROGRAM_SIZE * NUMBER_OF_PROGRAMS + RISC_SYNC_INSTRUCTION_SIZE)
+#define MAX_AUDIO_DMA_BUFFER_SIZE \
+(MAX_BUFFER_PROGRAM_SIZE * NUMBER_OF_PROGRAMS + RISC_SYNC_INSTRUCTION_SIZE)
#endif
diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c
index c487c19256b9..ad7ce013ba50 100644
--- a/drivers/staging/cx25821/cx25821-core.c
+++ b/drivers/staging/cx25821/cx25821-core.c
@@ -962,7 +962,7 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
dev->pci->subsystem_device);
cx25821_devcount--;
- return -ENODEV;
+ return -EBUSY;
}
/* PCIe stuff */
@@ -1412,9 +1412,12 @@ static int __devinit cx25821_initdev(struct pci_dev *pci_dev,
printk(KERN_INFO "cx25821 Athena pci enable !\n");
- if (cx25821_dev_setup(dev) < 0) {
- err = -EINVAL;
- goto fail_unregister_device;
+ err = cx25821_dev_setup(dev);
+ if (err) {
+ if (err == -EBUSY)
+ goto fail_unregister_device;
+ else
+ goto fail_unregister_pci;
}
/* print pci info */
@@ -1448,6 +1451,8 @@ fail_irq:
printk(KERN_INFO "cx25821 cx25821_initdev() can't get IRQ !\n");
cx25821_dev_unregister(dev);
+fail_unregister_pci:
+ pci_disable_device(pci_dev);
fail_unregister_device:
v4l2_device_unregister(&dev->v4l2_dev);
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt
index d2ca6834c169..3696c364e644 100644
--- a/drivers/staging/iio/Documentation/ring.txt
+++ b/drivers/staging/iio/Documentation/ring.txt
@@ -47,10 +47,8 @@ request_update
If parameters have changed that require reinitialization or configuration of
the ring buffer this will trigger it.
-get_bpd, set_bpd
- Get/set the number of bytes for a given reading (single element, not sample set)
- The value of bps (bytes per set) is created from a combination of this and the
- enabled scan elements.
+get_bytes_per_datum, set_bytes_per_datum
+ Get/set the number of bytes for a complete scan. (All samples + timestamp)
get_length / set_length
Get/set the number of sample sets that may be held by the buffer.
diff --git a/drivers/staging/iio/Documentation/sysfs-class-iio b/drivers/staging/iio/Documentation/sysfs-class-iio
index 714b4c57c82a..c13702037b08 100644
--- a/drivers/staging/iio/Documentation/sysfs-class-iio
+++ b/drivers/staging/iio/Documentation/sysfs-class-iio
@@ -158,7 +158,7 @@ Contact: linux-iio@vger.kernel.org
Description:
Magnetic field along axis x, y or z (may be arbitrarily assigned)
channel m (not present if only one magnetometer at this orientation).
- Data converted by application of offset then scale to Gauss
+ Data converted by application of offset then scale to Gauss.
Has all the equivalent modifiers as per in[m].
What: /sys/.../device[n]/device[n]:event[m]
@@ -212,39 +212,6 @@ Description:
The actual value of the threshold in raw device units obtained by
reverse application of scale and offfset to the acceleration in m/s^2.
-What: /sys/.../device[n]/scan_elements
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Directory containing interfaces for elements that will be captured
- for a single triggered sample set in the buffer.
-
-What: /sys/.../device[n]/scan_elements/[m]_accel_x0_en
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Scan element control for triggered data capture. m implies the
- ordering within the buffer. Next the type is specified with
- modifier and channel number as per the sysfs single channel
- access above.
-
-What: /sys/.../device[n]/scan_elements/accel[_x0]_precision
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Scan element precision within the buffer. Note that the
- data alignment must restrictions must be read from within
- buffer to work out full data alignment for data read
- via buffer_access chrdev. _x0 dropped if shared across all
- acceleration channels.
-
-What: /sys/.../device[n]/scan_elements/accel[_x0]_shift
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- A bit shift (to right) that must be applied prior to
- extracting the bits specified by accel[_x0]_precision.
-
What: /sys/.../device[n]/device[n]:buffer:event/dev
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
@@ -270,8 +237,8 @@ Contact: linux-iio@vger.kernel.org
Description:
Number of scans contained by the buffer.
-What: /sys/.../device[n]:buffer/bps
-KernelVersion: 2.6.35
+What: /sys/.../device[n]:buffer/bytes_per_datum
+KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Bytes per scan. Due to alignment fun, the scan may be larger
@@ -292,3 +259,36 @@ Description:
to the nearest power of 2 times this. (may not be true in weird
hardware buffers that pack data well)
+What: /sys/.../device[n]/buffer/scan_elements
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ Directory containing interfaces for elements that will be captured
+ for a single triggered sample set in the buffer.
+
+What: /sys/.../device[n]/buffer/scan_elements/[m]_accel_x0_en
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ Scan element control for triggered data capture. m implies the
+ ordering within the buffer. Next the type is specified with
+ modifier and channel number as per the sysfs single channel
+ access above.
+
+What: /sys/.../device[n]/buffer/scan_elements/accel[_x0]_precision
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ Scan element precision within the buffer. Note that the
+ data alignment must restrictions must be read from within
+ buffer to work out full data alignment for data read
+ via buffer_access chrdev. _x0 dropped if shared across all
+ acceleration channels.
+
+What: /sys/.../device[n]/buffer/scan_elements/accel[_x0]_shift
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ A bit shift (to right) that must be applied prior to
+ extracting the bits specified by accel[_x0]_precision.
+
diff --git a/drivers/staging/iio/Documentation/userspace.txt b/drivers/staging/iio/Documentation/userspace.txt
index 4838818f65ef..8bba2fa3ba07 100644
--- a/drivers/staging/iio/Documentation/userspace.txt
+++ b/drivers/staging/iio/Documentation/userspace.txt
@@ -7,17 +7,14 @@ Typical sysfs entries (pruned for clarity)
/sys/class/iio
device0 - iio_dev related elements
name - driver specific identifier (here lis3l02dq)
- accel_x - polled (or from ring) raw readout of acceleration
- accel_x_gain - hardware gain (calibration)
- accel_x_offset - hardware offset (calibration)
- available_sampling_frequency
+ accel_x_raw - polled (or from ring) raw readout of acceleration
+ accel_x_offset - offset to be applied to the raw reading
+ accel_x_scale - scale to be applied to the raw reading and offset
+ accel_x_calibbias - hardware offset (calibration)
+ accel_x_calibscale - hardware gain (calibration)
- available_sampling_frequency - what options are there
+ sampling_frequency_available - what options are there
sampling_frequency - control of internal sampling frequency
- scan_elements - controls which channels will be stored in the ring buffer
- scan_en_accel_x
- scan_en_accel_y
- scan_en_timestamp
device - link to underlying hardware device
uevent - udev related element
@@ -30,23 +27,28 @@ Typical sysfs entries (pruned for clarity)
dev - major:minor for the chrdev (note major allocation dynamic)
trigger - consumer attachement
current_trigger - name based association with a trigger
- ring_buffer0 - ring buffer interface
- bps - byptes per sample (read only), dependant on scan element selection
+ device0:buffer0 - ring buffer interface
+ bytes_per_datum - byptes per complete datum (read only),
+ dependant on scan element selection
length - (rw) specificy length fo software ring buffer (typically ro in hw case)
- ring_enable - turn the ring on. If its the first to be enabled attached to this
- trigger will also enable the trigger.
- ring_access0
+ enable - turn the ring on. If its the first to be enabled attached to this
+ trigger will also enable the trigger.
+ device0:buffer0:access0
dev - major:minor for ring buffer access chrdev
- ring_event_line0
+ device0:buffer0:event0
dev - major:minor for ring buffer event chrdev
+ scan_elements - controls which channels will be stored in the ring buffer
+ accel_x_en
+ accel_y_en
+ timestamp_en
trigger0 - data ready trigger elements
name - unqiue name of trigger
Udev will create the following entries under /dev by default:
-ring_access0 - ring access chrdev
-ring_event0 - ring event chrdev
+device0:buffer0:access0 - ring access chrdev
+device0:buffer0:event0 - ring event chrdev
event_line0 - general event chrdev.
For the example code we assume the following rules have been used to ensure
diff --git a/drivers/staging/iio/accel/accel.h b/drivers/staging/iio/accel/accel.h
index 1b6e37f76200..01e930201aa8 100644
--- a/drivers/staging/iio/accel/accel.h
+++ b/drivers/staging/iio/accel/accel.h
@@ -14,14 +14,44 @@
#define IIO_DEV_ATTR_ACCEL_Z_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(accel_z_offset, _mode, _show, _store, _addr)
-#define IIO_DEV_ATTR_ACCEL_X_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(accel_x_gain, _mode, _show, _store, _addr)
+#define IIO_CONST_ATTR_ACCEL_SCALE(_string) \
+ IIO_CONST_ATTR(accel_scale, _string)
-#define IIO_DEV_ATTR_ACCEL_Y_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(accel_y_gain, _mode, _show, _store, _addr)
+#define IIO_DEV_ATTR_ACCEL_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_scale, _mode, _show, _store, _addr)
-#define IIO_DEV_ATTR_ACCEL_Z_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(accel_z_gain, _mode, _show, _store, _addr)
+#define IIO_DEV_ATTR_ACCEL_X_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_x_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Y_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_y_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Z_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_z_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_x_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_y_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_z_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_calibscale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_X_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_x_calibscale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Y_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_y_calibscale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_ACCEL_Z_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(accel_z_calibscale, _mode, _show, _store, _addr)
#define IIO_DEV_ATTR_ACCEL(_show, _addr) \
IIO_DEVICE_ATTR(accel_raw, S_IRUGO, _show, NULL, _addr)
diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c
index 6c6923f2eaa5..9ee523a044d5 100644
--- a/drivers/staging/iio/accel/adis16209_core.c
+++ b/drivers/staging/iio/accel/adis16209_core.c
@@ -393,7 +393,7 @@ err_ret:
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16209_read_14bit_unsigned,
ADIS16209_SUPPLY_OUT);
-static IIO_CONST_ATTR(in_supply_scale, "0.30518");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.30518");
static IIO_DEV_ATTR_IN_RAW(0, adis16209_read_12bit_unsigned,
ADIS16209_AUX_ADC);
static IIO_CONST_ATTR(in0_scale, "0.6105");
@@ -402,40 +402,32 @@ static IIO_DEV_ATTR_ACCEL_X(adis16209_read_14bit_signed,
ADIS16209_XACCL_OUT);
static IIO_DEV_ATTR_ACCEL_Y(adis16209_read_14bit_signed,
ADIS16209_YACCL_OUT);
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16209_read_14bit_signed,
adis16209_write_16bit,
ADIS16209_XACCL_NULL);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16209_read_14bit_signed,
adis16209_write_16bit,
ADIS16209_YACCL_NULL);
-static IIO_CONST_ATTR(accel_scale, "0.24414");
+static IIO_CONST_ATTR_ACCEL_SCALE("0.002394195531");
static IIO_DEV_ATTR_INCLI_X(adis16209_read_14bit_signed,
ADIS16209_XINCL_OUT);
static IIO_DEV_ATTR_INCLI_Y(adis16209_read_14bit_signed,
ADIS16209_YINCL_OUT);
-static IIO_DEV_ATTR_INCLI_X_OFFSET(S_IWUSR | S_IRUGO,
- adis16209_read_14bit_signed,
- adis16209_write_16bit,
- ADIS16209_XACCL_NULL);
-static IIO_DEV_ATTR_INCLI_Y_OFFSET(S_IWUSR | S_IRUGO,
- adis16209_read_14bit_signed,
- adis16209_write_16bit,
- ADIS16209_YACCL_NULL);
-static IIO_CONST_ATTR(incli_scale, "0.025");
+static IIO_CONST_ATTR(incli_scale, "0.00043633231");
static IIO_DEVICE_ATTR(rot_raw, S_IRUGO, adis16209_read_14bit_signed,
NULL, ADIS16209_ROT_OUT);
static IIO_DEV_ATTR_TEMP(adis16209_read_temp);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "-0.47");
+static IIO_CONST_ATTR_TEMP_OFFSET("25");
+static IIO_CONST_ATTR_TEMP_SCALE("-0.47");
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
-static IIO_CONST_ATTR(name, "adis16209");
+static IIO_CONST_ATTR_NAME("adis16209");
static struct attribute *adis16209_event_attributes[] = {
NULL
@@ -457,13 +449,11 @@ static struct attribute *adis16209_attributes[] = {
&iio_const_attr_in0_scale.dev_attr.attr,
&iio_dev_attr_accel_x_raw.dev_attr.attr,
&iio_dev_attr_accel_y_raw.dev_attr.attr,
- &iio_dev_attr_accel_x_offset.dev_attr.attr,
- &iio_dev_attr_accel_y_offset.dev_attr.attr,
+ &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
&iio_const_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_incli_x_raw.dev_attr.attr,
&iio_dev_attr_incli_y_raw.dev_attr.attr,
- &iio_dev_attr_incli_x_offset.dev_attr.attr,
- &iio_dev_attr_incli_y_offset.dev_attr.attr,
&iio_const_attr_incli_scale.dev_attr.attr,
&iio_dev_attr_rot_raw.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c
index 25fde659d098..3eb1d559eb69 100644
--- a/drivers/staging/iio/accel/adis16209_ring.c
+++ b/drivers/staging/iio/accel/adis16209_ring.c
@@ -17,13 +17,13 @@
#include "../trigger.h"
#include "adis16209.h"
-static IIO_SCAN_EL_C(supply, ADIS16209_SCAN_SUPPLY, IIO_UNSIGNED(14),
+static IIO_SCAN_EL_C(in_supply, ADIS16209_SCAN_SUPPLY, IIO_UNSIGNED(14),
ADIS16209_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(accel_x, ADIS16209_SCAN_ACC_X, IIO_SIGNED(14),
ADIS16209_XACCL_OUT, NULL);
static IIO_SCAN_EL_C(accel_y, ADIS16209_SCAN_ACC_Y, IIO_SIGNED(14),
ADIS16209_YACCL_OUT, NULL);
-static IIO_SCAN_EL_C(aux_adc, ADIS16209_SCAN_AUX_ADC, IIO_UNSIGNED(12),
+static IIO_SCAN_EL_C(in0, ADIS16209_SCAN_AUX_ADC, IIO_UNSIGNED(12),
ADIS16209_AUX_ADC, NULL);
static IIO_SCAN_EL_C(temp, ADIS16209_SCAN_TEMP, IIO_UNSIGNED(12),
ADIS16209_TEMP_OUT, NULL);
@@ -37,10 +37,10 @@ static IIO_SCAN_EL_C(rot, ADIS16209_SCAN_ROT, IIO_SIGNED(14),
static IIO_SCAN_EL_TIMESTAMP(8);
static struct attribute *adis16209_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
- &iio_scan_el_aux_adc.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_temp.dev_attr.attr,
&iio_scan_el_incli_x.dev_attr.attr,
&iio_scan_el_incli_y.dev_attr.attr,
@@ -115,11 +115,11 @@ static void adis16209_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16209_state *st
= container_of(work_s, struct adis16209_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -127,19 +127,19 @@ static void adis16209_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16209_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
- (u8 *)data,
- st->last_timestamp);
+ ring->access.store_to(ring,
+ (u8 *)data,
+ st->last_timestamp);
iio_trigger_notify_done(st->indio_dev->trig);
kfree(data);
@@ -159,19 +159,6 @@ int adis16209_configure_ring(struct iio_dev *indio_dev)
struct adis16209_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16209_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_rot.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_aux_adc.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_incli_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_incli_y.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16209_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -182,11 +169,23 @@ int adis16209_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16209_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_rot.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+ iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16209_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c
index bb7d76539cd7..032616ee65af 100644
--- a/drivers/staging/iio/accel/adis16220_core.c
+++ b/drivers/staging/iio/accel/adis16220_core.c
@@ -487,7 +487,7 @@ static struct bin_attribute adc2_bin = {
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16220_read_12bit_unsigned,
ADIS16220_CAPT_SUPPLY);
-static IIO_CONST_ATTR(in_supply_scale, "0.0012207");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.0012207");
static IIO_DEV_ATTR_ACCEL(adis16220_read_16bit, ADIS16220_CAPT_BUFA);
static IIO_DEVICE_ATTR(accel_peak_raw, S_IRUGO, adis16220_read_16bit,
NULL, ADIS16220_CAPT_PEAKA);
@@ -495,9 +495,10 @@ static IIO_DEV_ATTR_ACCEL_OFFSET(S_IWUSR | S_IRUGO,
adis16220_read_16bit,
adis16220_write_16bit,
ADIS16220_ACCL_NULL);
+static IIO_CONST_ATTR_ACCEL_SCALE("0.18704223545");
static IIO_DEV_ATTR_TEMP_RAW(adis16220_read_12bit_unsigned);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "-0.47");
+static IIO_CONST_ATTR_TEMP_OFFSET("25");
+static IIO_CONST_ATTR_TEMP_SCALE("-0.47");
static IIO_DEV_ATTR_IN_RAW(0, adis16220_read_16bit, ADIS16220_CAPT_BUF1);
static IIO_DEV_ATTR_IN_RAW(1, adis16220_read_16bit, ADIS16220_CAPT_BUF2);
@@ -518,9 +519,9 @@ static IIO_DEV_ATTR_CAPTURE_COUNT(S_IWUSR | S_IRUGO,
adis16220_write_16bit,
ADIS16220_CAPT_PNTR);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("100200");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100200");
-static IIO_CONST_ATTR(name, "adis16220");
+static IIO_CONST_ATTR_NAME("adis16220");
static struct attribute *adis16220_attributes[] = {
&iio_dev_attr_in_supply_raw.dev_attr.attr,
@@ -528,12 +529,13 @@ static struct attribute *adis16220_attributes[] = {
&iio_dev_attr_accel_raw.dev_attr.attr,
&iio_dev_attr_accel_offset.dev_attr.attr,
&iio_dev_attr_accel_peak_raw.dev_attr.attr,
+ &iio_const_attr_accel_scale.dev_attr.attr,
&iio_dev_attr_temp_raw.dev_attr.attr,
&iio_dev_attr_in0_raw.dev_attr.attr,
&iio_dev_attr_in1_raw.dev_attr.attr,
&iio_const_attr_temp_offset.dev_attr.attr,
&iio_const_attr_temp_scale.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_dev_attr_capture.dev_attr.attr,
&iio_dev_attr_capture_count.dev_attr.attr,
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c
index 3e9531dd0000..49e172a6a0cd 100644
--- a/drivers/staging/iio/accel/adis16240_core.c
+++ b/drivers/staging/iio/accel/adis16240_core.c
@@ -380,7 +380,10 @@ static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16240_read_10bit_unsigned,
ADIS16240_SUPPLY_OUT);
static IIO_DEV_ATTR_IN_RAW(0, adis16240_read_10bit_signed,
ADIS16240_AUX_ADC);
-static IIO_CONST_ATTR(in_supply_scale, "0.00488");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.00488");
+
+static IIO_CONST_ATTR_ACCEL_SCALE("0.50406181");
+static IIO_CONST_ATTR(accel_peak_scale, "6.6292954");
static IIO_DEV_ATTR_ACCEL_X(adis16240_read_10bit_signed,
ADIS16240_XACCL_OUT);
static IIO_DEVICE_ATTR(accel_x_peak_raw, S_IRUGO,
@@ -400,26 +403,26 @@ static IIO_DEVICE_ATTR(accel_z_peak_raw, S_IRUGO,
static IIO_DEVICE_ATTR(accel_xyz_squared_peak_raw, S_IRUGO,
adis16240_read_12bit_signed, NULL,
ADIS16240_XYZPEAK_OUT);
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16240_read_10bit_signed,
adis16240_write_16bit,
ADIS16240_XACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16240_read_10bit_signed,
adis16240_write_16bit,
ADIS16240_YACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16240_read_10bit_signed,
adis16240_write_16bit,
ADIS16240_ZACCL_OFF);
static IIO_DEV_ATTR_TEMP_RAW(adis16240_read_10bit_unsigned);
-static IIO_CONST_ATTR(temp_scale, "0.244");
+static IIO_CONST_ATTR_TEMP_SCALE("0.244");
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("4096");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
-static IIO_CONST_ATTR(name, "adis16240");
+static IIO_CONST_ATTR_NAME("adis16240");
static struct attribute *adis16240_event_attributes[] = {
NULL
@@ -433,19 +436,21 @@ static struct attribute *adis16240_attributes[] = {
&iio_dev_attr_in_supply_raw.dev_attr.attr,
&iio_const_attr_in_supply_scale.dev_attr.attr,
&iio_dev_attr_in0_raw.dev_attr.attr,
+ &iio_const_attr_accel_scale.dev_attr.attr,
+ &iio_const_attr_accel_peak_scale.dev_attr.attr,
&iio_dev_attr_accel_x_raw.dev_attr.attr,
- &iio_dev_attr_accel_x_offset.dev_attr.attr,
+ &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
&iio_dev_attr_accel_x_peak_raw.dev_attr.attr,
&iio_dev_attr_accel_y_raw.dev_attr.attr,
- &iio_dev_attr_accel_y_offset.dev_attr.attr,
+ &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
&iio_dev_attr_accel_y_peak_raw.dev_attr.attr,
&iio_dev_attr_accel_z_raw.dev_attr.attr,
- &iio_dev_attr_accel_z_offset.dev_attr.attr,
+ &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_accel_z_peak_raw.dev_attr.attr,
&iio_dev_attr_accel_xyz_squared_peak_raw.dev_attr.attr,
&iio_dev_attr_temp_raw.dev_attr.attr,
&iio_const_attr_temp_scale.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c
index cd69a2e2bb9a..9282372e7a69 100644
--- a/drivers/staging/iio/accel/adis16240_ring.c
+++ b/drivers/staging/iio/accel/adis16240_ring.c
@@ -17,7 +17,7 @@
#include "../trigger.h"
#include "adis16240.h"
-static IIO_SCAN_EL_C(supply, ADIS16240_SCAN_SUPPLY, IIO_UNSIGNED(10),
+static IIO_SCAN_EL_C(in_supply, ADIS16240_SCAN_SUPPLY, IIO_UNSIGNED(10),
ADIS16240_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(accel_x, ADIS16240_SCAN_ACC_X, IIO_SIGNED(10),
ADIS16240_XACCL_OUT, NULL);
@@ -25,7 +25,7 @@ static IIO_SCAN_EL_C(accel_y, ADIS16240_SCAN_ACC_Y, IIO_SIGNED(10),
ADIS16240_YACCL_OUT, NULL);
static IIO_SCAN_EL_C(accel_z, ADIS16240_SCAN_ACC_Z, IIO_SIGNED(10),
ADIS16240_ZACCL_OUT, NULL);
-static IIO_SCAN_EL_C(aux_adc, ADIS16240_SCAN_AUX_ADC, IIO_UNSIGNED(10),
+static IIO_SCAN_EL_C(in0, ADIS16240_SCAN_AUX_ADC, IIO_UNSIGNED(10),
ADIS16240_AUX_ADC, NULL);
static IIO_SCAN_EL_C(temp, ADIS16240_SCAN_TEMP, IIO_UNSIGNED(10),
ADIS16240_TEMP_OUT, NULL);
@@ -33,11 +33,11 @@ static IIO_SCAN_EL_C(temp, ADIS16240_SCAN_TEMP, IIO_UNSIGNED(10),
static IIO_SCAN_EL_TIMESTAMP(6);
static struct attribute *adis16240_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
&iio_scan_el_accel_z.dev_attr.attr,
- &iio_scan_el_aux_adc.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_temp.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
NULL,
@@ -107,11 +107,11 @@ static void adis16240_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16240_state *st
= container_of(work_s, struct adis16240_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -119,17 +119,17 @@ static void adis16240_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16240_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
+ ring->access.store_to(ring,
(u8 *)data,
st->last_timestamp);
@@ -151,17 +151,6 @@ int adis16240_configure_ring(struct iio_dev *indio_dev)
struct adis16240_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16240_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_aux_adc.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16240_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -172,11 +161,21 @@ int adis16240_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16240_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16240_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/accel/inclinometer.h b/drivers/staging/iio/accel/inclinometer.h
index 5b49f835eac5..faf73d7892e0 100644
--- a/drivers/staging/iio/accel/inclinometer.h
+++ b/drivers/staging/iio/accel/inclinometer.h
@@ -21,3 +21,5 @@
#define IIO_DEV_ATTR_INCLI_Z_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(incli_z_offset, _mode, _show, _store, _addr)
+#define IIO_CONST_ATTR_INCLI_SCALE(_string) \
+ IIO_CONST_ATTR(incli_scale, _string)
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index 0ee933737545..655f2b7672e0 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -731,7 +731,7 @@ static struct attribute_group lis3l02dq_event_attribute_group = {
.attrs = lis3l02dq_event_attributes,
};
-static IIO_CONST_ATTR(name, "lis3l02dq");
+static IIO_CONST_ATTR_NAME("lis3l02dq");
static IIO_CONST_ATTR(accel_scale, "0.00958");
static struct attribute *lis3l02dq_attributes[] = {
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index a960a8ff3c40..a68a381836e1 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -150,38 +150,40 @@ ssize_t lis3l02dq_read_accel_from_ring(struct device *dev,
int ret, len = 0, i = 0;
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_ring_buffer *ring = dev_info->ring;
+ struct attribute_group *scan_el_attrs = ring->scan_el_attrs;
s16 *data;
- while (dev_info->scan_el_attrs->attrs[i]) {
+ while (scan_el_attrs->attrs[i]) {
el = to_iio_scan_el((struct device_attribute *)
- (dev_info->scan_el_attrs->attrs[i]));
+ (scan_el_attrs->attrs[i]));
/* label is in fact the address */
if (el->label == this_attr->address)
break;
i++;
}
- if (!dev_info->scan_el_attrs->attrs[i]) {
+ if (!scan_el_attrs->attrs[i]) {
ret = -EINVAL;
goto error_ret;
}
/* If this element is in the scan mask */
- ret = iio_scan_mask_query(dev_info, el->number);
+ ret = iio_scan_mask_query(ring, el->number);
if (ret < 0)
goto error_ret;
if (ret) {
- data = kmalloc(dev_info->ring->access.get_bpd(dev_info->ring),
+ data = kmalloc(ring->access.get_bytes_per_datum(ring),
GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
- ret = dev_info->ring->access.read_last(dev_info->ring,
- (u8 *)data);
+ ret = ring->access.read_last(ring,
+ (u8 *)data);
if (ret)
goto error_free_data;
} else {
ret = -EINVAL;
goto error_ret;
}
- len = iio_scan_mask_count_to_right(dev_info, el->number);
+ len = iio_scan_mask_count_to_right(ring, el->number);
if (len < 0) {
ret = len;
goto error_free_data;
@@ -211,11 +213,12 @@ static const u8 read_all_tx_array[] = {
**/
static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
{
+ struct iio_ring_buffer *ring = st->help.indio_dev->ring;
struct spi_transfer *xfers;
struct spi_message msg;
int ret, i, j = 0;
- xfers = kzalloc((st->help.indio_dev->scan_count) * 2
+ xfers = kzalloc((ring->scan_count) * 2
* sizeof(*xfers), GFP_KERNEL);
if (!xfers)
return -ENOMEM;
@@ -223,7 +226,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
mutex_lock(&st->buf_lock);
for (i = 0; i < ARRAY_SIZE(read_all_tx_array)/4; i++) {
- if (st->help.indio_dev->scan_mask & (1 << i)) {
+ if (ring->scan_mask & (1 << i)) {
/* lower byte */
xfers[j].tx_buf = st->tx + 2*j;
st->tx[2*j] = read_all_tx_array[i*4];
@@ -251,7 +254,7 @@ static int lis3l02dq_read_all(struct lis3l02dq_state *st, u8 *rx_array)
* values in alternate bytes
*/
spi_message_init(&msg);
- for (j = 0; j < st->help.indio_dev->scan_count * 2; j++)
+ for (j = 0; j < ring->scan_count * 2; j++)
spi_message_add_tail(&xfers[j], &msg);
ret = spi_sync(st->us, &msg);
@@ -279,13 +282,13 @@ static int lis3l02dq_get_ring_element(struct iio_sw_ring_helper_state *h,
u8 *rx_array ;
s16 *data = (s16 *)buf;
- rx_array = kzalloc(4 * (h->indio_dev->scan_count), GFP_KERNEL);
+ rx_array = kzalloc(4 * (h->indio_dev->ring->scan_count), GFP_KERNEL);
if (rx_array == NULL)
return -ENOMEM;
ret = lis3l02dq_read_all(lis3l02dq_h_to_s(h), rx_array);
if (ret < 0)
return ret;
- for (i = 0; i < h->indio_dev->scan_count; i++)
+ for (i = 0; i < h->indio_dev->ring->scan_count; i++)
data[i] = combine_8_to_16(rx_array[i*4+1],
rx_array[i*4+3]);
kfree(rx_array);
@@ -479,28 +482,29 @@ int lis3l02dq_configure_ring(struct iio_dev *indio_dev)
{
int ret;
struct iio_sw_ring_helper_state *h = iio_dev_get_devdata(indio_dev);
-
+ struct iio_ring_buffer *ring;
INIT_WORK(&h->work_trigger_to_ring, lis3l02dq_trigger_bh_to_ring);
- /* Set default scan mode */
h->get_ring_element = &lis3l02dq_get_ring_element;
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &lis3l02dq_scan_el_group;
- indio_dev->ring = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->ring)
+ ring = iio_sw_rb_allocate(indio_dev);
+ if (!ring)
return -ENOMEM;
+ indio_dev->ring = ring;
/* Effectively select the ring buffer implementation */
- iio_ring_sw_register_funcs(&indio_dev->ring->access);
- indio_dev->ring->bpe = 2;
- indio_dev->ring->preenable = &iio_sw_ring_preenable;
- indio_dev->ring->postenable = &iio_triggered_ring_postenable;
- indio_dev->ring->predisable = &iio_triggered_ring_predisable;
- indio_dev->ring->owner = THIS_MODULE;
+ iio_ring_sw_register_funcs(&ring->access);
+ ring->bpe = 2;
+ ring->scan_el_attrs = &lis3l02dq_scan_el_group;
+ ring->scan_timestamp = true;
+ ring->preenable = &iio_sw_ring_preenable;
+ ring->postenable = &iio_triggered_ring_postenable;
+ ring->predisable = &iio_triggered_ring_predisable;
+ ring->owner = THIS_MODULE;
+
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
ret = iio_alloc_pollfunc(indio_dev, NULL, &lis3l02dq_poll_func_th);
if (ret)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index b78b6b66ffe0..0eb2c4cdeb48 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -721,8 +721,8 @@ error_ret:
}
static IIO_DEV_ATTR_TEMP_RAW(sca3000_read_temp);
-static IIO_CONST_ATTR(temp_scale, "0.555556");
-static IIO_CONST_ATTR(temp_offset, "-214.6");
+static IIO_CONST_ATTR_TEMP_SCALE("0.555556");
+static IIO_CONST_ATTR_TEMP_OFFSET("-214.6");
/**
* sca3000_show_thresh() sysfs query of a threshold
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index 8e8c068d401b..6d19d15c6d77 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -100,7 +100,7 @@ static int sca3000_ring_get_length(struct iio_ring_buffer *r)
}
/* only valid if resolution is kept at 11bits */
-static int sca3000_ring_get_bpd(struct iio_ring_buffer *r)
+static int sca3000_ring_get_bytes_per_datum(struct iio_ring_buffer *r)
{
return 6;
}
@@ -111,7 +111,7 @@ static void sca3000_ring_release(struct device *dev)
}
static IIO_RING_ENABLE_ATTR;
-static IIO_RING_BPS_ATTR;
+static IIO_RING_BYTES_PER_DATUM_ATTR;
static IIO_RING_LENGTH_ATTR;
/**
@@ -218,8 +218,8 @@ static struct attribute_group sca3000_scan_el_group = {
*/
static struct attribute *sca3000_ring_attributes[] = {
&dev_attr_length.attr,
- &dev_attr_bps.attr,
- &dev_attr_ring_enable.attr,
+ &dev_attr_bytes_per_datum.attr,
+ &dev_attr_enable.attr,
NULL,
};
@@ -264,15 +264,15 @@ static inline void sca3000_rb_free(struct iio_ring_buffer *r)
int sca3000_configure_ring(struct iio_dev *indio_dev)
{
- indio_dev->scan_el_attrs = &sca3000_scan_el_group;
indio_dev->ring = sca3000_rb_allocate(indio_dev);
if (indio_dev->ring == NULL)
return -ENOMEM;
indio_dev->modes |= INDIO_RING_HARDWARE_BUFFER;
+ indio_dev->ring->scan_el_attrs = &sca3000_scan_el_group;
indio_dev->ring->access.rip_lots = &sca3000_rip_hw_rb;
indio_dev->ring->access.get_length = &sca3000_ring_get_length;
- indio_dev->ring->access.get_bpd = &sca3000_ring_get_bpd;
+ indio_dev->ring->access.get_bytes_per_datum = &sca3000_ring_get_bytes_per_datum;
return 0;
}
diff --git a/drivers/staging/iio/adc/adc.h b/drivers/staging/iio/adc/adc.h
index 7841e6ad4349..953b5ceec3af 100644
--- a/drivers/staging/iio/adc/adc.h
+++ b/drivers/staging/iio/adc/adc.h
@@ -27,5 +27,12 @@
NULL, \
_addr)
+
+#define IIO_CONST_ATTR_IN_NAMED_OFFSET(_name, _string) \
+ IIO_CONST_ATTR(in_##_name##_offset, _string)
+
+#define IIO_CONST_ATTR_IN_NAMED_SCALE(_name, _string) \
+ IIO_CONST_ATTR(in_##_name##_scale, _string)
+
#define IIO_EVENT_CODE_IN_HIGH_THRESH(a) (IIO_EVENT_CODE_ADC_BASE + a)
#define IIO_EVENT_CODE_IN_LOW_THRESH(a) (IIO_EVENT_CODE_ADC_BASE + a + 32)
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index 6435e509dd56..1dc428fc0cce 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -1631,7 +1631,6 @@ static int __devinit max1363_probe(struct i2c_client *client,
st->indio_dev->attrs = st->chip_info->dev_attrs;
/* Todo: this shouldn't be here. */
- st->indio_dev->scan_el_attrs = st->chip_info->scan_attrs;
st->indio_dev->dev_data = (void *)(st);
st->indio_dev->driver_module = THIS_MODULE;
st->indio_dev->modes = INDIO_DIRECT_MODE;
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index 786b17a0d6b0..1d6ce54e9a86 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -30,6 +30,7 @@
/* Todo: test this */
int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
{
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
unsigned long numvals;
int count = 0, ret;
u8 *ring_data;
@@ -44,8 +45,7 @@ int max1363_single_channel_from_ring(long mask, struct max1363_state *st)
ret = -ENOMEM;
goto error_ret;
}
- ret = st->indio_dev->ring->access.read_last(st->indio_dev->ring,
- ring_data);
+ ret = ring->access.read_last(ring, ring_data);
if (ret)
goto error_free_ring_data;
/* Need a count of channels prior to this one */
@@ -77,6 +77,7 @@ error_ret:
static int max1363_ring_preenable(struct iio_dev *indio_dev)
{
struct max1363_state *st = indio_dev->dev_data;
+ struct iio_ring_buffer *ring = indio_dev->ring;
size_t d_size;
unsigned long numvals;
@@ -84,7 +85,7 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
* Need to figure out the current mode based upon the requested
* scan mask in iio_dev
*/
- st->current_mode = max1363_match_mode(st->indio_dev->scan_mask,
+ st->current_mode = max1363_match_mode(ring->scan_mask,
st->chip_info);
if (!st->current_mode)
return -EINVAL;
@@ -92,14 +93,14 @@ static int max1363_ring_preenable(struct iio_dev *indio_dev)
max1363_set_scan_mode(st);
numvals = hweight_long(st->current_mode->modemask);
- if (indio_dev->ring->access.set_bpd) {
+ if (ring->access.set_bytes_per_datum) {
if (st->chip_info->bits != 8)
d_size = numvals*2 + sizeof(s64);
else
d_size = numvals + sizeof(s64);
if (d_size % 8)
d_size += 8 - (d_size % 8);
- indio_dev->ring->access.set_bpd(indio_dev->ring, d_size);
+ ring->access.set_bytes_per_datum(ring, d_size);
}
return 0;
@@ -135,7 +136,7 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
struct max1363_state *st = container_of(work_s, struct max1363_state,
poll_work);
struct iio_dev *indio_dev = st->indio_dev;
- struct iio_sw_ring_buffer *ring = iio_to_sw_ring(indio_dev->ring);
+ struct iio_sw_ring_buffer *sw_ring = iio_to_sw_ring(indio_dev->ring);
s64 time_ns;
__u8 *rxbuf;
int b_sent;
@@ -175,7 +176,7 @@ static void max1363_poll_bh_to_ring(struct work_struct *work_s)
memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
- indio_dev->ring->access.store_to(&ring->buf, rxbuf, time_ns);
+ indio_dev->ring->access.store_to(&sw_ring->buf, rxbuf, time_ns);
done:
kfree(rxbuf);
atomic_dec(&st->protect_ring);
@@ -193,12 +194,13 @@ int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev)
goto error_ret;
}
/* Effectively select the ring buffer implementation */
- iio_ring_sw_register_funcs(&st->indio_dev->ring->access);
+ iio_ring_sw_register_funcs(&indio_dev->ring->access);
ret = iio_alloc_pollfunc(indio_dev, NULL, &max1363_poll_func_th);
if (ret)
goto error_deallocate_sw_rb;
/* Ring buffer functions - here trigger setup related */
+ indio_dev->ring->scan_el_attrs = st->chip_info->scan_attrs;
indio_dev->ring->postenable = &iio_triggered_ring_postenable;
indio_dev->ring->preenable = &max1363_ring_preenable;
indio_dev->ring->predisable = &iio_triggered_ring_predisable;
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index 134dfaae2f0c..c1ad0c8f5f15 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -445,22 +445,23 @@ err_ret:
static IIO_DEV_ATTR_IN_NAMED_RAW(supply,
adis16260_read_12bit_unsigned,
ADIS16260_SUPPLY_OUT);
-static IIO_CONST_ATTR(in_supply_scale, "0.0018315");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.0018315");
static IIO_DEV_ATTR_GYRO(adis16260_read_14bit_signed,
ADIS16260_GYRO_OUT);
-static IIO_DEV_ATTR_GYRO_SCALE(S_IWUSR | S_IRUGO,
+static IIO_CONST_ATTR_GYRO_SCALE("0.00127862821");
+static IIO_DEV_ATTR_GYRO_CALIBSCALE(S_IWUSR | S_IRUGO,
adis16260_read_14bit_signed,
adis16260_write_16bit,
ADIS16260_GYRO_SCALE);
-static IIO_DEV_ATTR_GYRO_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_GYRO_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16260_read_12bit_signed,
adis16260_write_16bit,
ADIS16260_GYRO_OFF);
static IIO_DEV_ATTR_TEMP_RAW(adis16260_read_12bit_unsigned);
-static IIO_CONST_ATTR(temp_offset, "25");
-static IIO_CONST_ATTR(temp_scale, "0.1453");
+static IIO_CONST_ATTR_TEMP_OFFSET("25");
+static IIO_CONST_ATTR_TEMP_SCALE("0.1453");
static IIO_DEV_ATTR_IN_RAW(0, adis16260_read_12bit_unsigned,
ADIS16260_AUX_ADC);
@@ -474,9 +475,9 @@ static IIO_DEV_ATTR_ANGL(adis16260_read_14bit_signed,
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("256 2048");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("256 2048");
-static IIO_CONST_ATTR(name, "adis16260");
+static IIO_CONST_ATTR_NAME("adis16260");
static struct attribute *adis16260_event_attributes[] = {
NULL
@@ -490,8 +491,9 @@ static struct attribute *adis16260_attributes[] = {
&iio_dev_attr_in_supply_raw.dev_attr.attr,
&iio_const_attr_in_supply_scale.dev_attr.attr,
&iio_dev_attr_gyro_raw.dev_attr.attr,
- &iio_dev_attr_gyro_scale.dev_attr.attr,
- &iio_dev_attr_gyro_offset.dev_attr.attr,
+ &iio_const_attr_gyro_scale.dev_attr.attr,
+ &iio_dev_attr_gyro_calibscale.dev_attr.attr,
+ &iio_dev_attr_gyro_calibbias.dev_attr.attr,
&iio_dev_attr_angl_raw.dev_attr.attr,
&iio_dev_attr_temp_raw.dev_attr.attr,
&iio_const_attr_temp_offset.dev_attr.attr,
@@ -499,7 +501,7 @@ static struct attribute *adis16260_attributes[] = {
&iio_dev_attr_in0_raw.dev_attr.attr,
&iio_const_attr_in0_scale.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c
index 9ef7f9080dcd..659a672b1c5d 100644
--- a/drivers/staging/iio/gyro/adis16260_ring.c
+++ b/drivers/staging/iio/gyro/adis16260_ring.c
@@ -17,11 +17,11 @@
#include "../trigger.h"
#include "adis16260.h"
-static IIO_SCAN_EL_C(supply, ADIS16260_SCAN_SUPPLY, IIO_UNSIGNED(12),
+static IIO_SCAN_EL_C(in_supply, ADIS16260_SCAN_SUPPLY, IIO_UNSIGNED(12),
ADIS16260_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(gyro, ADIS16260_SCAN_GYRO, IIO_SIGNED(14),
ADIS16260_GYRO_OUT, NULL);
-static IIO_SCAN_EL_C(aux_adc, ADIS16260_SCAN_AUX_ADC, IIO_SIGNED(14),
+static IIO_SCAN_EL_C(in0, ADIS16260_SCAN_AUX_ADC, IIO_SIGNED(14),
ADIS16260_AUX_ADC, NULL);
static IIO_SCAN_EL_C(temp, ADIS16260_SCAN_TEMP, IIO_UNSIGNED(12),
ADIS16260_TEMP_OUT, NULL);
@@ -31,9 +31,9 @@ static IIO_SCAN_EL_C(angl, ADIS16260_SCAN_ANGL, IIO_UNSIGNED(12),
static IIO_SCAN_EL_TIMESTAMP(5);
static struct attribute *adis16260_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_gyro.dev_attr.attr,
- &iio_scan_el_aux_adc.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_temp.dev_attr.attr,
&iio_scan_el_angl.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
@@ -110,11 +110,11 @@ static void adis16260_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16260_state *st
= container_of(work_s, struct adis16260_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -122,17 +122,17 @@ static void adis16260_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16260_read_ring_data(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
+ ring->access.store_to(ring,
(u8 *)data,
st->last_timestamp);
@@ -154,16 +154,6 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
struct adis16260_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16260_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_aux_adc.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_angl.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16260_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -174,11 +164,20 @@ int adis16260_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16260_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp.number);
+ iio_scan_mask_set(ring, iio_scan_el_angl.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16260_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/gyro/gyro.h b/drivers/staging/iio/gyro/gyro.h
index f68edab8f30d..98b837b775a2 100644
--- a/drivers/staging/iio/gyro/gyro.h
+++ b/drivers/staging/iio/gyro/gyro.h
@@ -3,6 +3,9 @@
/* Gyroscope types of attribute */
+#define IIO_CONST_ATTR_GYRO_OFFSET(_string) \
+ IIO_CONST_ATTR(gyro_offset, _string)
+
#define IIO_DEV_ATTR_GYRO_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(gyro_offset, _mode, _show, _store, _addr)
@@ -15,18 +18,45 @@
#define IIO_DEV_ATTR_GYRO_Z_OFFSET(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(gyro_z_offset, _mode, _show, _store, _addr)
-#define IIO_DEV_ATTR_GYRO_X_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(gyro_x_gain, _mode, _show, _store, _addr)
-
-#define IIO_DEV_ATTR_GYRO_Y_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(gyro_y_gain, _mode, _show, _store, _addr)
-
-#define IIO_DEV_ATTR_GYRO_Z_GAIN(_mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(gyro_z_gain, _mode, _show, _store, _addr)
+#define IIO_CONST_ATTR_GYRO_SCALE(_string) \
+ IIO_CONST_ATTR(gyro_scale, _string)
#define IIO_DEV_ATTR_GYRO_SCALE(_mode, _show, _store, _addr) \
IIO_DEVICE_ATTR(gyro_scale, S_IRUGO, _show, _store, _addr)
+#define IIO_DEV_ATTR_GYRO_X_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_x_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Y_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_y_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Z_SCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_z_scale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_calibbias, S_IRUGO, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_X_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_x_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Y_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_y_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_z_calibbias, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_calibscale, S_IRUGO, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_X_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_x_calibscale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Y_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_y_calibscale, _mode, _show, _store, _addr)
+
+#define IIO_DEV_ATTR_GYRO_Z_CALIBSCALE(_mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(gyro_z_calibscale, _mode, _show, _store, _addr)
+
#define IIO_DEV_ATTR_GYRO(_show, _addr) \
IIO_DEVICE_ATTR(gyro_raw, S_IRUGO, _show, NULL, _addr)
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
index 9d0ca128679e..3072c4562212 100644
--- a/drivers/staging/iio/iio.h
+++ b/drivers/staging/iio/iio.h
@@ -90,12 +90,7 @@ void iio_remove_event_from_list(struct iio_event_handler_list *el,
* @ring: [DRIVER] any ring buffer present
* @mlock: [INTERN] lock used to prevent simultaneous device state
* changes
- * @scan_el_attrs: [DRIVER] control of scan elements if that scan mode
- * control method is used
- * @scan_count: [INTERN] the number of elements in the current scan mode
- * @scan_mask: [INTERN] bitmask used in masking scan mode elements
* @available_scan_masks: [DRIVER] optional array of allowed bitmasks
- * @scan_timestamp: [INTERN] does the scan mode include a timestamp
* @trig: [INTERN] current device trigger (ring buffer modes)
* @pollfunc: [DRIVER] function run on trigger being recieved
**/
@@ -118,104 +113,11 @@ struct iio_dev {
struct iio_ring_buffer *ring;
struct mutex mlock;
- struct attribute_group *scan_el_attrs;
- int scan_count;
-
- u32 scan_mask;
u32 *available_scan_masks;
- bool scan_timestamp;
struct iio_trigger *trig;
struct iio_poll_func *pollfunc;
};
-/*
- * These are mainly provided to allow for a change of implementation if a device
- * has a large number of scan elements
- */
-#define IIO_MAX_SCAN_LENGTH 31
-
-/* note 0 used as error indicator as it doesn't make sense. */
-static inline u32 iio_scan_mask_match(u32 *av_masks, u32 mask)
-{
- while (*av_masks) {
- if (!(~*av_masks & mask))
- return *av_masks;
- av_masks++;
- }
- return 0;
-}
-
-static inline int iio_scan_mask_query(struct iio_dev *dev_info, int bit)
-{
- u32 mask;
-
- if (bit > IIO_MAX_SCAN_LENGTH)
- return -EINVAL;
-
- if (!dev_info->scan_mask)
- return 0;
-
- if (dev_info->available_scan_masks)
- mask = iio_scan_mask_match(dev_info->available_scan_masks,
- dev_info->scan_mask);
- else
- mask = dev_info->scan_mask;
-
- if (!mask)
- return -EINVAL;
-
- return !!(mask & (1 << bit));
-};
-
-static inline int iio_scan_mask_set(struct iio_dev *dev_info, int bit)
-{
- u32 mask;
- u32 trialmask = dev_info->scan_mask | (1 << bit);
-
- if (bit > IIO_MAX_SCAN_LENGTH)
- return -EINVAL;
- if (dev_info->available_scan_masks) {
- mask = iio_scan_mask_match(dev_info->available_scan_masks,
- trialmask);
- if (!mask)
- return -EINVAL;
- }
- dev_info->scan_mask = trialmask;
- dev_info->scan_count++;
-
- return 0;
-};
-
-static inline int iio_scan_mask_clear(struct iio_dev *dev_info, int bit)
-{
- if (bit > IIO_MAX_SCAN_LENGTH)
- return -EINVAL;
- dev_info->scan_mask &= ~(1 << bit);
- dev_info->scan_count--;
- return 0;
-};
-
-/**
- * iio_scan_mask_count_to_right() - how many scan elements occur before here
- * @dev_info: the iio_device whose scan mode we are querying
- * @bit: which number scan element is this
- **/
-static inline int iio_scan_mask_count_to_right(struct iio_dev *dev_info,
- int bit)
-{
- int count = 0;
- int mask = (1 << bit);
- if (bit > IIO_MAX_SCAN_LENGTH)
- return -EINVAL;
- while (mask) {
- mask >>= 1;
- if (mask & dev_info->scan_mask)
- count++;
- }
-
- return count;
-}
-
/**
* iio_device_register() - register a device with the IIO subsystem
* @dev_info: Device structure filled by the device driver
diff --git a/drivers/staging/iio/imu/adis16300_core.c b/drivers/staging/iio/imu/adis16300_core.c
index f1950d56cb1f..3ed86cc1d2e7 100644
--- a/drivers/staging/iio/imu/adis16300_core.c
+++ b/drivers/staging/iio/imu/adis16300_core.c
@@ -503,28 +503,33 @@ err_ret:
return ret;
}
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_GYRO_X_CALIBBIAS(S_IWUSR | S_IRUGO,
+ adis16300_read_12bit_signed,
+ adis16300_write_16bit,
+ ADIS16300_XGYRO_OFF);
+
+static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16300_read_12bit_signed,
adis16300_write_16bit,
ADIS16300_XACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16300_read_12bit_signed,
adis16300_write_16bit,
ADIS16300_YACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16300_read_12bit_signed,
adis16300_write_16bit,
ADIS16300_ZACCL_OFF);
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16300_read_14bit_unsigned,
ADIS16300_SUPPLY_OUT);
-static IIO_CONST_ATTR(in_supply_scale, "0.00242");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.00242");
static IIO_DEV_ATTR_GYRO_X(adis16300_read_14bit_signed,
ADIS16300_XGYRO_OUT);
-static IIO_CONST_ATTR(gyro_scale, "0.05 deg/s");
+static IIO_CONST_ATTR_GYRO_SCALE("0.000872664");
static IIO_DEV_ATTR_ACCEL_X(adis16300_read_14bit_signed,
ADIS16300_XACCL_OUT);
@@ -532,17 +537,17 @@ static IIO_DEV_ATTR_ACCEL_Y(adis16300_read_14bit_signed,
ADIS16300_YACCL_OUT);
static IIO_DEV_ATTR_ACCEL_Z(adis16300_read_14bit_signed,
ADIS16300_ZACCL_OUT);
-static IIO_CONST_ATTR(accel_scale, "0.0006 g");
+static IIO_CONST_ATTR_ACCEL_SCALE("0.00588399");
static IIO_DEV_ATTR_INCLI_X(adis16300_read_13bit_signed,
ADIS16300_XINCLI_OUT);
static IIO_DEV_ATTR_INCLI_Y(adis16300_read_13bit_signed,
ADIS16300_YINCLI_OUT);
-static IIO_CONST_ATTR(incli_scale, "0.044 d");
+static IIO_CONST_ATTR_INCLI_SCALE("0.00076794487");
static IIO_DEV_ATTR_TEMP_RAW(adis16300_read_12bit_unsigned);
-static IIO_CONST_ATTR(temp_offset, "198.16 K");
-static IIO_CONST_ATTR(temp_scale, "0.14 K");
+static IIO_CONST_ATTR_TEMP_OFFSET("198.16");
+static IIO_CONST_ATTR_TEMP_SCALE("0.14");
static IIO_DEV_ATTR_IN_RAW(0, adis16300_read_12bit_unsigned,
ADIS16300_AUX_ADC);
@@ -554,9 +559,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16300_write_reset, 0);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("409 546 819 1638");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-static IIO_CONST_ATTR(name, "adis16300");
+static IIO_CONST_ATTR_NAME("adis16300");
static struct attribute *adis16300_event_attributes[] = {
NULL
@@ -567,9 +572,10 @@ static struct attribute_group adis16300_event_attribute_group = {
};
static struct attribute *adis16300_attributes[] = {
- &iio_dev_attr_accel_x_offset.dev_attr.attr,
- &iio_dev_attr_accel_y_offset.dev_attr.attr,
- &iio_dev_attr_accel_z_offset.dev_attr.attr,
+ &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_in_supply_raw.dev_attr.attr,
&iio_const_attr_in_supply_scale.dev_attr.attr,
&iio_dev_attr_gyro_x_raw.dev_attr.attr,
@@ -587,7 +593,7 @@ static struct attribute *adis16300_attributes[] = {
&iio_dev_attr_in0_raw.dev_attr.attr,
&iio_const_attr_in0_scale.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/imu/adis16300_ring.c b/drivers/staging/iio/imu/adis16300_ring.c
index fc93160acb26..0e09051e5545 100644
--- a/drivers/staging/iio/imu/adis16300_ring.c
+++ b/drivers/staging/iio/imu/adis16300_ring.c
@@ -17,7 +17,7 @@
#include "../trigger.h"
#include "adis16300.h"
-static IIO_SCAN_EL_C(supply, ADIS16300_SCAN_SUPPLY, IIO_UNSIGNED(14),
+static IIO_SCAN_EL_C(in_supply, ADIS16300_SCAN_SUPPLY, IIO_UNSIGNED(14),
ADIS16300_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(gyro_x, ADIS16300_SCAN_GYRO_X, IIO_SIGNED(14),
@@ -32,7 +32,7 @@ static IIO_SCAN_EL_C(accel_z, ADIS16300_SCAN_ACC_Z, IIO_SIGNED(14),
static IIO_SCAN_EL_C(temp, ADIS16300_SCAN_TEMP, IIO_UNSIGNED(12),
ADIS16300_TEMP_OUT, NULL);
-static IIO_SCAN_EL_C(adc_0, ADIS16300_SCAN_ADC_0, IIO_UNSIGNED(12),
+static IIO_SCAN_EL_C(in0, ADIS16300_SCAN_ADC_0, IIO_UNSIGNED(12),
ADIS16300_AUX_ADC, NULL);
static IIO_SCAN_EL_C(incli_x, ADIS16300_SCAN_INCLI_X, IIO_SIGNED(12),
@@ -43,7 +43,7 @@ static IIO_SCAN_EL_C(incli_y, ADIS16300_SCAN_INCLI_Y, IIO_SIGNED(12),
static IIO_SCAN_EL_TIMESTAMP(9);
static struct attribute *adis16300_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_gyro_x.dev_attr.attr,
&iio_scan_el_temp.dev_attr.attr,
&iio_scan_el_accel_x.dev_attr.attr,
@@ -51,7 +51,7 @@ static struct attribute *adis16300_scan_el_attrs[] = {
&iio_scan_el_accel_z.dev_attr.attr,
&iio_scan_el_incli_x.dev_attr.attr,
&iio_scan_el_incli_y.dev_attr.attr,
- &iio_scan_el_adc_0.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
NULL,
};
@@ -134,11 +134,11 @@ static void adis16300_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16300_state *st
= container_of(work_s, struct adis16300_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -146,19 +146,19 @@ static void adis16300_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16300_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
- (u8 *)data,
- st->last_timestamp);
+ ring->access.store_to(ring,
+ (u8 *)data,
+ st->last_timestamp);
iio_trigger_notify_done(st->indio_dev->trig);
kfree(data);
@@ -178,20 +178,6 @@ int adis16300_configure_ring(struct iio_dev *indio_dev)
struct adis16300_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16300_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_adc_0.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_incli_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_incli_y.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16300_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -202,11 +188,24 @@ int adis16300_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16300_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+ iio_scan_mask_set(ring, iio_scan_el_incli_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_incli_y.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16300_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/imu/adis16350_core.c b/drivers/staging/iio/imu/adis16350_core.c
index 1575b7b5d44f..cc33843bbc09 100644
--- a/drivers/staging/iio/imu/adis16350_core.c
+++ b/drivers/staging/iio/imu/adis16350_core.c
@@ -475,24 +475,39 @@ err_ret:
return ret;
}
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_GYRO_X_CALIBBIAS(S_IWUSR | S_IRUGO,
+ adis16350_read_12bit_signed,
+ adis16350_write_16bit,
+ ADIS16350_XGYRO_OFF);
+
+static IIO_DEV_ATTR_GYRO_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
+ adis16350_read_12bit_signed,
+ adis16350_write_16bit,
+ ADIS16350_YGYRO_OFF);
+
+static IIO_DEV_ATTR_GYRO_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
+ adis16350_read_12bit_signed,
+ adis16350_write_16bit,
+ ADIS16350_ZGYRO_OFF);
+
+static IIO_DEV_ATTR_ACCEL_X_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16350_read_12bit_signed,
adis16350_write_16bit,
ADIS16350_XACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Y_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16350_read_12bit_signed,
adis16350_write_16bit,
ADIS16350_YACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
+static IIO_DEV_ATTR_ACCEL_Z_CALIBBIAS(S_IWUSR | S_IRUGO,
adis16350_read_12bit_signed,
adis16350_write_16bit,
ADIS16350_ZACCL_OFF);
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16350_read_12bit_unsigned,
ADIS16350_SUPPLY_OUT);
-static IIO_CONST_ATTR(in_supply_scale, "0.002418");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.002418");
static IIO_DEV_ATTR_GYRO_X(adis16350_read_14bit_signed,
ADIS16350_XGYRO_OUT);
@@ -500,7 +515,7 @@ static IIO_DEV_ATTR_GYRO_Y(adis16350_read_14bit_signed,
ADIS16350_YGYRO_OUT);
static IIO_DEV_ATTR_GYRO_Z(adis16350_read_14bit_signed,
ADIS16350_ZGYRO_OUT);
-static IIO_CONST_ATTR(gyro_scale, "0.05");
+static IIO_CONST_ATTR_GYRO_SCALE("0.00127862821");
static IIO_DEV_ATTR_ACCEL_X(adis16350_read_14bit_signed,
ADIS16350_XACCL_OUT);
@@ -508,7 +523,7 @@ static IIO_DEV_ATTR_ACCEL_Y(adis16350_read_14bit_signed,
ADIS16350_YACCL_OUT);
static IIO_DEV_ATTR_ACCEL_Z(adis16350_read_14bit_signed,
ADIS16350_ZACCL_OUT);
-static IIO_CONST_ATTR(accel_scale, "0.00333");
+static IIO_CONST_ATTR_ACCEL_SCALE("0.0247323713");
static IIO_DEVICE_ATTR(temp_x_raw, S_IRUGO, adis16350_read_12bit_signed,
NULL, ADIS16350_XTEMP_OUT);
@@ -516,7 +531,8 @@ static IIO_DEVICE_ATTR(temp_y_raw, S_IRUGO, adis16350_read_12bit_signed,
NULL, ADIS16350_YTEMP_OUT);
static IIO_DEVICE_ATTR(temp_z_raw, S_IRUGO, adis16350_read_12bit_signed,
NULL, ADIS16350_ZTEMP_OUT);
-static IIO_CONST_ATTR(temp_scale, "0.0005");
+static IIO_CONST_ATTR_TEMP_SCALE("0.14534");
+static IIO_CONST_ATTR_TEMP_OFFSET("198.16");
static IIO_DEV_ATTR_IN_RAW(0, adis16350_read_12bit_unsigned,
ADIS16350_AUX_ADC);
@@ -529,14 +545,17 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
adis16350_write_reset, 0);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("409 546 819 1638");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-static IIO_CONST_ATTR(name, "adis16350");
+static IIO_CONST_ATTR_NAME("adis16350");
static struct attribute *adis16350_attributes[] = {
- &iio_dev_attr_accel_x_offset.dev_attr.attr,
- &iio_dev_attr_accel_y_offset.dev_attr.attr,
- &iio_dev_attr_accel_z_offset.dev_attr.attr,
+ &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_gyro_y_calibbias.dev_attr.attr,
+ &iio_dev_attr_gyro_z_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_in_supply_raw.dev_attr.attr,
&iio_const_attr_in_supply_scale.dev_attr.attr,
&iio_dev_attr_gyro_x_raw.dev_attr.attr,
@@ -554,7 +573,7 @@ static struct attribute *adis16350_attributes[] = {
&iio_dev_attr_in0_raw.dev_attr.attr,
&iio_const_attr_in0_scale.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/imu/adis16350_ring.c b/drivers/staging/iio/imu/adis16350_ring.c
index e053e9aaa2ed..aefbae589e76 100644
--- a/drivers/staging/iio/imu/adis16350_ring.c
+++ b/drivers/staging/iio/imu/adis16350_ring.c
@@ -17,7 +17,7 @@
#include "../trigger.h"
#include "adis16350.h"
-static IIO_SCAN_EL_C(supply, ADIS16350_SCAN_SUPPLY, IIO_UNSIGNED(12),
+static IIO_SCAN_EL_C(in_supply, ADIS16350_SCAN_SUPPLY, IIO_UNSIGNED(12),
ADIS16350_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(gyro_x, ADIS16350_SCAN_GYRO_X, IIO_SIGNED(14),
@@ -41,13 +41,13 @@ static IIO_SCAN_EL_C(temp_y, ADIS16350_SCAN_TEMP_Y, IIO_SIGNED(12),
static IIO_SCAN_EL_C(temp_z, ADIS16350_SCAN_TEMP_Z, IIO_SIGNED(12),
ADIS16350_ZTEMP_OUT, NULL);
-static IIO_SCAN_EL_C(adc_0, ADIS16350_SCAN_ADC_0, IIO_UNSIGNED(12),
+static IIO_SCAN_EL_C(in0, ADIS16350_SCAN_ADC_0, IIO_UNSIGNED(12),
ADIS16350_AUX_ADC, NULL);
static IIO_SCAN_EL_TIMESTAMP(11);
static struct attribute *adis16350_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_gyro_x.dev_attr.attr,
&iio_scan_el_gyro_y.dev_attr.attr,
&iio_scan_el_gyro_z.dev_attr.attr,
@@ -57,7 +57,7 @@ static struct attribute *adis16350_scan_el_attrs[] = {
&iio_scan_el_temp_x.dev_attr.attr,
&iio_scan_el_temp_y.dev_attr.attr,
&iio_scan_el_temp_z.dev_attr.attr,
- &iio_scan_el_adc_0.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
NULL,
};
@@ -134,11 +134,11 @@ static void adis16350_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16350_state *st
= container_of(work_s, struct adis16350_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -146,19 +146,19 @@ static void adis16350_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16350_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
- (u8 *)data,
- st->last_timestamp);
+ ring->access.store_to(ring,
+ (u8 *)data,
+ st->last_timestamp);
iio_trigger_notify_done(st->indio_dev->trig);
kfree(data);
@@ -178,22 +178,6 @@ int adis16350_configure_ring(struct iio_dev *indio_dev)
struct adis16350_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16350_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_adc_0.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16350_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -204,11 +188,26 @@ int adis16350_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16350_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16350_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 6013fee218e9..5f1643a341cb 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -490,24 +490,24 @@ err_ret:
return ret;
}
-static IIO_DEV_ATTR_ACCEL_X_OFFSET(S_IWUSR | S_IRUGO,
- adis16400_read_12bit_signed,
- adis16400_write_16bit,
- ADIS16400_XACCL_OFF);
+#define ADIS16400_DEV_ATTR_CALIBBIAS(_channel, _reg) \
+ IIO_DEV_ATTR_##_channel##_CALIBBIAS(S_IWUSR | S_IRUGO, \
+ adis16400_read_12bit_signed, \
+ adis16400_write_16bit, \
+ _reg)
-static IIO_DEV_ATTR_ACCEL_Y_OFFSET(S_IWUSR | S_IRUGO,
- adis16400_read_12bit_signed,
- adis16400_write_16bit,
- ADIS16400_YACCL_OFF);
+static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_X, ADIS16400_XGYRO_OFF);
+static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_Y, ADIS16400_XGYRO_OFF);
+static ADIS16400_DEV_ATTR_CALIBBIAS(GYRO_Z, ADIS16400_XGYRO_OFF);
+
+static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_X, ADIS16400_XACCL_OFF);
+static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_Y, ADIS16400_XACCL_OFF);
+static ADIS16400_DEV_ATTR_CALIBBIAS(ACCEL_Z, ADIS16400_XACCL_OFF);
-static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO,
- adis16400_read_12bit_signed,
- adis16400_write_16bit,
- ADIS16400_ZACCL_OFF);
static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16400_read_14bit_signed,
ADIS16400_SUPPLY_OUT);
-static IIO_CONST_ATTR(in_supply_scale, "0.002418");
+static IIO_CONST_ATTR_IN_NAMED_SCALE(supply, "0.002418 V");
static IIO_DEV_ATTR_GYRO_X(adis16400_read_14bit_signed,
ADIS16400_XGYRO_OUT);
@@ -515,7 +515,7 @@ static IIO_DEV_ATTR_GYRO_Y(adis16400_read_14bit_signed,
ADIS16400_YGYRO_OUT);
static IIO_DEV_ATTR_GYRO_Z(adis16400_read_14bit_signed,
ADIS16400_ZGYRO_OUT);
-static IIO_CONST_ATTR(gyro_scale, "0.05 deg/s");
+static IIO_CONST_ATTR(gyro_scale, "0.0008726646");
static IIO_DEV_ATTR_ACCEL_X(adis16400_read_14bit_signed,
ADIS16400_XACCL_OUT);
@@ -523,7 +523,7 @@ static IIO_DEV_ATTR_ACCEL_Y(adis16400_read_14bit_signed,
ADIS16400_YACCL_OUT);
static IIO_DEV_ATTR_ACCEL_Z(adis16400_read_14bit_signed,
ADIS16400_ZACCL_OUT);
-static IIO_CONST_ATTR(accel_scale, "0.00333 g");
+static IIO_CONST_ATTR(accel_scale, "0.0326561445");
static IIO_DEV_ATTR_MAGN_X(adis16400_read_14bit_signed,
ADIS16400_XMAGN_OUT);
@@ -535,12 +535,12 @@ static IIO_CONST_ATTR(magn_scale, "0.0005 Gs");
static IIO_DEV_ATTR_TEMP_RAW(adis16400_read_12bit_signed);
-static IIO_CONST_ATTR(temp_offset, "198.16 K");
-static IIO_CONST_ATTR(temp_scale, "0.14 K");
+static IIO_CONST_ATTR_TEMP_OFFSET("198.16 K");
+static IIO_CONST_ATTR_TEMP_SCALE("0.14 K");
static IIO_DEV_ATTR_IN_RAW(0, adis16400_read_12bit_unsigned,
ADIS16400_AUX_ADC);
-static IIO_CONST_ATTR(in0_scale, "0.000806");
+static IIO_CONST_ATTR(in0_scale, "0.000806 V");
static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16400_read_frequency,
@@ -548,9 +548,9 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("409 546 819 1638");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-static IIO_CONST_ATTR(name, "adis16400");
+static IIO_CONST_ATTR_NAME("adis16400");
static struct attribute *adis16400_event_attributes[] = {
NULL
@@ -561,9 +561,12 @@ static struct attribute_group adis16400_event_attribute_group = {
};
static struct attribute *adis16400_attributes[] = {
- &iio_dev_attr_accel_x_offset.dev_attr.attr,
- &iio_dev_attr_accel_y_offset.dev_attr.attr,
- &iio_dev_attr_accel_z_offset.dev_attr.attr,
+ &iio_dev_attr_gyro_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_gyro_y_calibbias.dev_attr.attr,
+ &iio_dev_attr_gyro_z_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_x_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_y_calibbias.dev_attr.attr,
+ &iio_dev_attr_accel_z_calibbias.dev_attr.attr,
&iio_dev_attr_in_supply_raw.dev_attr.attr,
&iio_const_attr_in_supply_scale.dev_attr.attr,
&iio_dev_attr_gyro_x_raw.dev_attr.attr,
@@ -584,7 +587,7 @@ static struct attribute *adis16400_attributes[] = {
&iio_dev_attr_in0_raw.dev_attr.attr,
&iio_const_attr_in0_scale.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
&iio_const_attr_name.dev_attr.attr,
NULL
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index 949db76283d7..de5ef5c1cfd0 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -17,7 +17,7 @@
#include "../trigger.h"
#include "adis16400.h"
-static IIO_SCAN_EL_C(supply, ADIS16400_SCAN_SUPPLY, IIO_SIGNED(14),
+static IIO_SCAN_EL_C(in_supply, ADIS16400_SCAN_SUPPLY, IIO_SIGNED(14),
ADIS16400_SUPPLY_OUT, NULL);
static IIO_SCAN_EL_C(gyro_x, ADIS16400_SCAN_GYRO_X, IIO_SIGNED(14),
@@ -43,13 +43,13 @@ static IIO_SCAN_EL_C(magn_z, ADIS16400_SCAN_MAGN_Z, IIO_SIGNED(14),
static IIO_SCAN_EL_C(temp, ADIS16400_SCAN_TEMP, IIO_SIGNED(12),
ADIS16400_TEMP_OUT, NULL);
-static IIO_SCAN_EL_C(adc_0, ADIS16400_SCAN_ADC_0, IIO_SIGNED(12),
+static IIO_SCAN_EL_C(in0, ADIS16400_SCAN_ADC_0, IIO_SIGNED(12),
ADIS16400_AUX_ADC, NULL);
static IIO_SCAN_EL_TIMESTAMP(12);
static struct attribute *adis16400_scan_el_attrs[] = {
- &iio_scan_el_supply.dev_attr.attr,
+ &iio_scan_el_in_supply.dev_attr.attr,
&iio_scan_el_gyro_x.dev_attr.attr,
&iio_scan_el_gyro_y.dev_attr.attr,
&iio_scan_el_gyro_z.dev_attr.attr,
@@ -60,7 +60,7 @@ static struct attribute *adis16400_scan_el_attrs[] = {
&iio_scan_el_magn_y.dev_attr.attr,
&iio_scan_el_magn_z.dev_attr.attr,
&iio_scan_el_temp.dev_attr.attr,
- &iio_scan_el_adc_0.dev_attr.attr,
+ &iio_scan_el_in0.dev_attr.attr,
&iio_scan_el_timestamp.dev_attr.attr,
NULL,
};
@@ -143,11 +143,11 @@ static void adis16400_trigger_bh_to_ring(struct work_struct *work_s)
struct adis16400_state *st
= container_of(work_s, struct adis16400_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int i = 0;
s16 *data;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
data = kmalloc(datasize , GFP_KERNEL);
if (data == NULL) {
@@ -155,19 +155,19 @@ static void adis16400_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
if (adis16400_spi_read_burst(&st->indio_dev->dev, st->rx) >= 0)
- for (; i < st->indio_dev->scan_count; i++)
+ for (; i < ring->scan_count; i++)
data[i] = be16_to_cpup(
(__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
- (u8 *)data,
- st->last_timestamp);
+ ring->access.store_to(ring,
+ (u8 *) data,
+ st->last_timestamp);
iio_trigger_notify_done(st->indio_dev->trig);
kfree(data);
@@ -187,23 +187,6 @@ int adis16400_configure_ring(struct iio_dev *indio_dev)
struct adis16400_state *st = indio_dev->dev_data;
struct iio_ring_buffer *ring;
INIT_WORK(&st->work_trigger_to_ring, adis16400_trigger_bh_to_ring);
- /* Set default scan mode */
-
- iio_scan_mask_set(indio_dev, iio_scan_el_supply.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_gyro_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_accel_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_magn_x.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_magn_y.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_magn_z.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_temp.number);
- iio_scan_mask_set(indio_dev, iio_scan_el_adc_0.number);
- indio_dev->scan_timestamp = true;
-
- indio_dev->scan_el_attrs = &adis16400_scan_el_group;
ring = iio_sw_rb_allocate(indio_dev);
if (!ring) {
@@ -214,11 +197,27 @@ int adis16400_configure_ring(struct iio_dev *indio_dev)
/* Effectively select the ring buffer implementation */
iio_ring_sw_register_funcs(&ring->access);
ring->bpe = 2;
+ ring->scan_el_attrs = &adis16400_scan_el_group;
+ ring->scan_timestamp = true;
ring->preenable = &iio_sw_ring_preenable;
ring->postenable = &iio_triggered_ring_postenable;
ring->predisable = &iio_triggered_ring_predisable;
ring->owner = THIS_MODULE;
+ /* Set default scan mode */
+ iio_scan_mask_set(ring, iio_scan_el_in_supply.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_gyro_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_accel_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_magn_x.number);
+ iio_scan_mask_set(ring, iio_scan_el_magn_y.number);
+ iio_scan_mask_set(ring, iio_scan_el_magn_z.number);
+ iio_scan_mask_set(ring, iio_scan_el_temp.number);
+ iio_scan_mask_set(ring, iio_scan_el_in0.number);
+
ret = iio_alloc_pollfunc(indio_dev, NULL, &adis16400_poll_func_th);
if (ret)
goto error_iio_sw_rb_free;
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index dd4d87a8bcaf..5c0e56a6935e 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -507,24 +507,12 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info)
goto error_ret;
}
- if (dev_info->scan_el_attrs) {
- ret = sysfs_create_group(&dev_info->dev.kobj,
- dev_info->scan_el_attrs);
- if (ret)
- dev_err(&dev_info->dev,
- "Failed to add sysfs scan els\n");
- }
-
error_ret:
return ret;
}
static void iio_device_unregister_sysfs(struct iio_dev *dev_info)
{
- if (dev_info->scan_el_attrs)
- sysfs_remove_group(&dev_info->dev.kobj,
- dev_info->scan_el_attrs);
-
sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs);
}
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index 6ab578e4f5f3..f3c87edddafd 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -279,6 +279,16 @@ int iio_ring_buffer_register(struct iio_ring_buffer *ring, int id)
if (ret)
goto error_free_ring_buffer_event_chrdev;
+ if (ring->scan_el_attrs) {
+ ret = sysfs_create_group(&ring->dev.kobj,
+ ring->scan_el_attrs);
+ if (ret) {
+ dev_err(&ring->dev,
+ "Failed to add sysfs scan elements\n");
+ goto error_free_ring_buffer_event_chrdev;
+ }
+ }
+
return ret;
error_free_ring_buffer_event_chrdev:
__iio_free_ring_buffer_event_chrdev(ring);
@@ -291,6 +301,10 @@ EXPORT_SYMBOL(iio_ring_buffer_register);
void iio_ring_buffer_unregister(struct iio_ring_buffer *ring)
{
+ if (ring->scan_el_attrs)
+ sysfs_remove_group(&ring->dev.kobj,
+ ring->scan_el_attrs);
+
__iio_free_ring_buffer_access_chrdev(ring);
__iio_free_ring_buffer_event_chrdev(ring);
device_del(&ring->dev);
@@ -338,20 +352,20 @@ EXPORT_SYMBOL(iio_read_ring_length);
}
EXPORT_SYMBOL(iio_write_ring_length);
-ssize_t iio_read_ring_bps(struct device *dev,
+ssize_t iio_read_ring_bytes_per_datum(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int len = 0;
struct iio_ring_buffer *ring = dev_get_drvdata(dev);
- if (ring->access.get_bpd)
+ if (ring->access.get_bytes_per_datum)
len = sprintf(buf, "%d\n",
- ring->access.get_bpd(ring));
+ ring->access.get_bytes_per_datum(ring));
return len;
}
-EXPORT_SYMBOL(iio_read_ring_bps);
+EXPORT_SYMBOL(iio_read_ring_bytes_per_datum);
ssize_t iio_store_ring_enable(struct device *dev,
struct device_attribute *attr,
@@ -465,10 +479,10 @@ ssize_t iio_scan_el_show(struct device *dev,
char *buf)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_ring_buffer *ring = dev_get_drvdata(dev);
struct iio_scan_el *this_el = to_iio_scan_el(attr);
- ret = iio_scan_mask_query(indio_dev, this_el->number);
+ ret = iio_scan_mask_query(ring, this_el->number);
if (ret < 0)
return ret;
return sprintf(buf, "%d\n", ret);
@@ -482,7 +496,8 @@ ssize_t iio_scan_el_store(struct device *dev,
{
int ret = 0;
bool state;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = ring->indio_dev;
struct iio_scan_el *this_el = to_iio_scan_el(attr);
state = !(buf[0] == '0');
@@ -491,19 +506,17 @@ ssize_t iio_scan_el_store(struct device *dev,
ret = -EBUSY;
goto error_ret;
}
- ret = iio_scan_mask_query(indio_dev, this_el->number);
+ ret = iio_scan_mask_query(ring, this_el->number);
if (ret < 0)
goto error_ret;
if (!state && ret) {
- ret = iio_scan_mask_clear(indio_dev, this_el->number);
+ ret = iio_scan_mask_clear(ring, this_el->number);
if (ret)
goto error_ret;
- indio_dev->scan_count--;
} else if (state && !ret) {
- ret = iio_scan_mask_set(indio_dev, this_el->number);
+ ret = iio_scan_mask_set(ring, this_el->number);
if (ret)
goto error_ret;
- indio_dev->scan_count++;
}
if (this_el->set_state)
ret = this_el->set_state(this_el, indio_dev, state);
@@ -519,8 +532,8 @@ ssize_t iio_scan_el_ts_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", indio_dev->scan_timestamp);
+ struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+ return sprintf(buf, "%d\n", ring->scan_timestamp);
}
EXPORT_SYMBOL(iio_scan_el_ts_show);
@@ -530,7 +543,8 @@ ssize_t iio_scan_el_ts_store(struct device *dev,
size_t len)
{
int ret = 0;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_ring_buffer *ring = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = ring->indio_dev;
bool state;
state = !(buf[0] == '0');
mutex_lock(&indio_dev->mlock);
@@ -538,7 +552,7 @@ ssize_t iio_scan_el_ts_store(struct device *dev,
ret = -EBUSY;
goto error_ret;
}
- indio_dev->scan_timestamp = state;
+ ring->scan_timestamp = state;
error_ret:
mutex_unlock(&indio_dev->mlock);
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index 92f6c6fb90fe..51689177e00e 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -95,15 +95,15 @@
#define CONF_NOT_USED 0x03
#define MEAS_CONF_MASK 0x03
-static const int regval_to_counts_per_mg[] = {
- 1620,
- 1300,
- 970,
- 780,
- 530,
- 460,
- 390,
- 280
+static const char *regval_to_scale[] = {
+ "0.0000006173",
+ "0.0000007692",
+ "0.0000010309",
+ "0.0000012821",
+ "0.0000018868",
+ "0.0000021739",
+ "0.0000025641",
+ "0.0000035714",
};
static const int regval_to_input_field_mg[] = {
700,
@@ -220,11 +220,15 @@ static ssize_t hmc5843_set_operating_mode(struct device *dev,
int error;
mutex_lock(&data->lock);
error = strict_strtoul(buf, 10, &operating_mode);
- if (error)
- return error;
+ if (error) {
+ count = error;
+ goto exit;
+ }
dev_dbg(dev, "set Conversion mode to %lu\n", operating_mode);
- if (operating_mode > MODE_SLEEP)
- return -EINVAL;
+ if (operating_mode > MODE_SLEEP) {
+ count = -EINVAL;
+ goto exit;
+ }
status = i2c_smbus_write_byte_data(client, this_attr->address,
operating_mode);
@@ -322,7 +326,7 @@ static IIO_DEVICE_ATTR(meas_conf,
* 6 | 50
* 7 | Not used
*/
-static IIO_CONST_ATTR_AVAIL_SAMP_FREQ("0.5 1 2 5 10 20 50");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("0.5 1 2 5 10 20 50");
static s32 hmc5843_set_rate(struct i2c_client *client,
u8 rate)
@@ -385,11 +389,11 @@ static ssize_t show_sampling_frequency(struct device *dev,
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- u32 rate;
+ s32 rate;
rate = i2c_smbus_read_byte_data(client, this_attr->address);
if (rate < 0)
- return -EINVAL;
+ return rate;
rate = (rate & RATE_BITMASK) >> RATE_OFFSET;
return sprintf(buf, "%s\n", regval_to_samp_freq[rate]);
}
@@ -437,18 +441,23 @@ static ssize_t set_range(struct device *dev,
int error;
mutex_lock(&data->lock);
error = strict_strtoul(buf, 10, &range);
- if (error)
- return error;
+ if (error) {
+ count = error;
+ goto exit;
+ }
dev_dbg(dev, "set range to %lu\n", range);
- if (range > RANGE_6_5)
- return -EINVAL;
+ if (range > RANGE_6_5) {
+ count = -EINVAL;
+ goto exit;
+ }
data->range = range;
range = range << RANGE_GAIN_OFFSET;
if (i2c_smbus_write_byte_data(client, this_attr->address, range))
count = -EINVAL;
+exit:
mutex_unlock(&data->lock);
return count;
@@ -459,17 +468,17 @@ static IIO_DEVICE_ATTR(magn_range,
set_range,
HMC5843_CONFIG_REG_B);
-static ssize_t show_gain(struct device *dev,
+static ssize_t show_scale(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct hmc5843_data *data = indio_dev->dev_data;
- return sprintf(buf, "%d\n", regval_to_counts_per_mg[data->range]);
+ return strlen(strcpy(buf, regval_to_scale[data->range]));
}
-static IIO_DEVICE_ATTR(magn_gain,
+static IIO_DEVICE_ATTR(magn_scale,
S_IRUGO,
- show_gain,
+ show_scale,
NULL , 0);
static struct attribute *hmc5843_attributes[] = {
@@ -477,11 +486,11 @@ static struct attribute *hmc5843_attributes[] = {
&iio_dev_attr_operating_mode.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_dev_attr_magn_range.dev_attr.attr,
- &iio_dev_attr_magn_gain.dev_attr.attr,
+ &iio_dev_attr_magn_scale.dev_attr.attr,
&iio_dev_attr_magn_x_raw.dev_attr.attr,
&iio_dev_attr_magn_y_raw.dev_attr.attr,
&iio_dev_attr_magn_z_raw.dev_attr.attr,
- &iio_const_attr_available_sampling_frequency.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
NULL
};
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h
index a872d3904a33..6124353b2ed1 100644
--- a/drivers/staging/iio/ring_generic.h
+++ b/drivers/staging/iio/ring_generic.h
@@ -52,8 +52,8 @@ int iio_push_or_escallate_ring_event(struct iio_ring_buffer *ring_buf,
* change.
* @request_update: if a parameter change has been marked, update underlying
* storage.
- * @get_bpd: get current bytes per datum
- * @set_bpd: set number of bytes per datum
+ * @get_bytes_per_datum: get current bytes per datum
+ * @set_bytes_per_datum: set number of bytes per datum
* @get_length: get number of datums in ring
* @set_length: set number of datums in ring
* @is_enabled: query if ring is currently being used
@@ -81,8 +81,8 @@ struct iio_ring_access_funcs {
int (*mark_param_change)(struct iio_ring_buffer *ring);
int (*request_update)(struct iio_ring_buffer *ring);
- int (*get_bpd)(struct iio_ring_buffer *ring);
- int (*set_bpd)(struct iio_ring_buffer *ring, size_t bpd);
+ int (*get_bytes_per_datum)(struct iio_ring_buffer *ring);
+ int (*set_bytes_per_datum)(struct iio_ring_buffer *ring, size_t bpd);
int (*get_length)(struct iio_ring_buffer *ring);
int (*set_length)(struct iio_ring_buffer *ring, int length);
@@ -99,9 +99,14 @@ struct iio_ring_access_funcs {
* @id: unique id number
* @access_id: device id number
* @length: [DEVICE] number of datums in ring
- * @bpd: [DEVICE] size of individual datum including timestamp
+ * @bytes_per_datum [DEVICE] size of individual datum including timestamp
* @bpe: [DEVICE] size of individual channel value
* @loopcount: [INTERN] number of times the ring has looped
+ * @scan_el_attrs: [DRIVER] control of scan elements if that scan mode
+ * control method is used
+ * @scan_count: [INTERN] the number of elements in the current scan mode
+ * @scan_mask: [INTERN] bitmask used in masking scan mode elements
+ * @scan_timestamp: [INTERN] does the scan mode include a timestamp
* @access_handler: [INTERN] chrdev access handling
* @ev_int: [INTERN] chrdev interface for the event chrdev
* @shared_ev_pointer: [INTERN] the shared event pointer to allow escalation of
@@ -121,9 +126,13 @@ struct iio_ring_buffer {
int id;
int access_id;
int length;
- int bpd;
+ int bytes_per_datum;
int bpe;
int loopcount;
+ struct attribute_group *scan_el_attrs;
+ int scan_count;
+ u32 scan_mask;
+ bool scan_timestamp;
struct iio_handler access_handler;
struct iio_event_interface ev_int;
struct iio_shared_ev_pointer shared_ev_pointer;
@@ -146,7 +155,7 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring,
static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring,
int bytes_per_datum, int length)
{
- ring->bpd = bytes_per_datum;
+ ring->bytes_per_datum = bytes_per_datum;
ring->length = length;
ring->loopcount = 0;
}
@@ -258,6 +267,97 @@ ssize_t iio_scan_el_ts_show(struct device *dev, struct device_attribute *attr,
iio_scan_el_ts_store), \
}
+/*
+ * These are mainly provided to allow for a change of implementation if a device
+ * has a large number of scan elements
+ */
+#define IIO_MAX_SCAN_LENGTH 31
+
+/* note 0 used as error indicator as it doesn't make sense. */
+static inline u32 iio_scan_mask_match(u32 *av_masks, u32 mask)
+{
+ while (*av_masks) {
+ if (!(~*av_masks & mask))
+ return *av_masks;
+ av_masks++;
+ }
+ return 0;
+}
+
+static inline int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit)
+{
+ struct iio_dev *dev_info = ring->indio_dev;
+ u32 mask;
+
+ if (bit > IIO_MAX_SCAN_LENGTH)
+ return -EINVAL;
+
+ if (!ring->scan_mask)
+ return 0;
+
+ if (dev_info->available_scan_masks)
+ mask = iio_scan_mask_match(dev_info->available_scan_masks,
+ ring->scan_mask);
+ else
+ mask = ring->scan_mask;
+
+ if (!mask)
+ return -EINVAL;
+
+ return !!(mask & (1 << bit));
+};
+
+static inline int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit)
+{
+ struct iio_dev *dev_info = ring->indio_dev;
+ u32 mask;
+ u32 trialmask = ring->scan_mask | (1 << bit);
+
+ if (bit > IIO_MAX_SCAN_LENGTH)
+ return -EINVAL;
+ if (dev_info->available_scan_masks) {
+ mask = iio_scan_mask_match(dev_info->available_scan_masks,
+ trialmask);
+ if (!mask)
+ return -EINVAL;
+ }
+ ring->scan_mask = trialmask;
+ ring->scan_count++;
+
+ return 0;
+};
+
+static inline int iio_scan_mask_clear(struct iio_ring_buffer *ring, int bit)
+{
+ if (bit > IIO_MAX_SCAN_LENGTH)
+ return -EINVAL;
+ ring->scan_mask &= ~(1 << bit);
+ ring->scan_count--;
+ return 0;
+};
+
+/**
+ * iio_scan_mask_count_to_right() - how many scan elements occur before here
+ * @dev_info: the iio_device whose scan mode we are querying
+ * @bit: which number scan element is this
+ **/
+static inline int iio_scan_mask_count_to_right(struct iio_ring_buffer *ring,
+ int bit)
+{
+ int count = 0;
+ int mask = (1 << bit);
+ if (bit > IIO_MAX_SCAN_LENGTH)
+ return -EINVAL;
+ while (mask) {
+ mask >>= 1;
+ if (mask & ring->scan_mask)
+ count++;
+ }
+
+ return count;
+}
+
+
static inline void iio_put_ring_buffer(struct iio_ring_buffer *ring)
{
put_device(&ring->dev);
@@ -277,7 +377,7 @@ ssize_t iio_write_ring_length(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t len);
-ssize_t iio_read_ring_bps(struct device *dev,
+ssize_t iio_read_ring_bytes_per_datum(struct device *dev,
struct device_attribute *attr,
char *buf);
ssize_t iio_store_ring_enable(struct device *dev,
@@ -290,9 +390,9 @@ ssize_t iio_show_ring_enable(struct device *dev,
#define IIO_RING_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR, \
iio_read_ring_length, \
iio_write_ring_length)
-#define IIO_RING_BPS_ATTR DEVICE_ATTR(bps, S_IRUGO | S_IWUSR, \
- iio_read_ring_bps, NULL)
-#define IIO_RING_ENABLE_ATTR DEVICE_ATTR(ring_enable, S_IRUGO | S_IWUSR, \
+#define IIO_RING_BYTES_PER_DATUM_ATTR DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR, \
+ iio_read_ring_bytes_per_datum, NULL)
+#define IIO_RING_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
iio_show_ring_enable, \
iio_store_ring_enable)
#else /* CONFIG_IIO_RING_BUFFER */
diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c
index e2f01c640baf..52624ace0bc5 100644
--- a/drivers/staging/iio/ring_sw.c
+++ b/drivers/staging/iio/ring_sw.c
@@ -21,7 +21,7 @@ static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring,
if ((length == 0) || (bytes_per_datum == 0))
return -EINVAL;
__iio_update_ring_buffer(&ring->buf, bytes_per_datum, length);
- ring->data = kmalloc(length*ring->buf.bpd, GFP_ATOMIC);
+ ring->data = kmalloc(length*ring->buf.bytes_per_datum, GFP_ATOMIC);
ring->read_p = NULL;
ring->write_p = NULL;
ring->last_written_p = NULL;
@@ -77,10 +77,10 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
* as long as the read pointer is valid before this
* passes it - guaranteed as set later in this function.
*/
- ring->half_p = ring->data - ring->buf.length*ring->buf.bpd/2;
+ ring->half_p = ring->data - ring->buf.length*ring->buf.bytes_per_datum/2;
}
/* Copy data to where ever the current write pointer says */
- memcpy(ring->write_p, data, ring->buf.bpd);
+ memcpy(ring->write_p, data, ring->buf.bytes_per_datum);
barrier();
/* Update the pointer used to get most recent value.
* Always valid as either points to latest or second latest value.
@@ -91,9 +91,9 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
/* temp_ptr used to ensure we never have an invalid pointer
* it may be slightly lagging, but never invalid
*/
- temp_ptr = ring->write_p + ring->buf.bpd;
+ temp_ptr = ring->write_p + ring->buf.bytes_per_datum;
/* End of ring, back to the beginning */
- if (temp_ptr == ring->data + ring->buf.length*ring->buf.bpd)
+ if (temp_ptr == ring->data + ring->buf.length*ring->buf.bytes_per_datum)
temp_ptr = ring->data;
/* Update the write pointer
* always valid as long as this is the only function able to write.
@@ -112,9 +112,9 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
*/
else if (ring->write_p == ring->read_p) {
change_test_ptr = ring->read_p;
- temp_ptr = change_test_ptr + ring->buf.bpd;
+ temp_ptr = change_test_ptr + ring->buf.bytes_per_datum;
if (temp_ptr
- == ring->data + ring->buf.length*ring->buf.bpd) {
+ == ring->data + ring->buf.length*ring->buf.bytes_per_datum) {
temp_ptr = ring->data;
}
/* We are moving pointer on one because the ring is full. Any
@@ -135,8 +135,8 @@ static int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring,
/* There are definite 'issues' with this and chances of
* simultaneous read */
/* Also need to use loop count to ensure this only happens once */
- ring->half_p += ring->buf.bpd;
- if (ring->half_p == ring->data + ring->buf.length*ring->buf.bpd)
+ ring->half_p += ring->buf.bytes_per_datum;
+ if (ring->half_p == ring->data + ring->buf.length*ring->buf.bytes_per_datum)
ring->half_p = ring->data;
if (ring->half_p == ring->read_p) {
spin_lock(&ring->buf.shared_ev_pointer.lock);
@@ -164,15 +164,15 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
* read something that is not a whole number of bpds.
* Return an error.
*/
- if (count % ring->buf.bpd) {
+ if (count % ring->buf.bytes_per_datum) {
ret = -EINVAL;
printk(KERN_INFO "Ring buffer read request not whole number of"
- "samples: Request bytes %zd, Current bpd %d\n",
- count, ring->buf.bpd);
+ "samples: Request bytes %zd, Current bytes per datum %d\n",
+ count, ring->buf.bytes_per_datum);
goto error_ret;
}
/* Limit size to whole of ring buffer */
- bytes_to_rip = min((size_t)(ring->buf.bpd*ring->buf.length), count);
+ bytes_to_rip = min((size_t)(ring->buf.bytes_per_datum*ring->buf.length), count);
*data = kmalloc(bytes_to_rip, GFP_KERNEL);
if (*data == NULL) {
@@ -214,7 +214,7 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
} else {
/* going through 'end' of ring buffer */
max_copied = ring->data
- + ring->buf.length*ring->buf.bpd - initial_read_p;
+ + ring->buf.length*ring->buf.bytes_per_datum - initial_read_p;
memcpy(*data, initial_read_p, max_copied);
/* possible we are done if we align precisely with end */
if (max_copied == bytes_to_rip)
@@ -240,7 +240,7 @@ int iio_rip_sw_rb(struct iio_ring_buffer *r,
if (initial_read_p <= current_read_p)
*dead_offset = current_read_p - initial_read_p;
else
- *dead_offset = ring->buf.length*ring->buf.bpd
+ *dead_offset = ring->buf.length*ring->buf.bytes_per_datum
- (initial_read_p - current_read_p);
/* possible issue if the initial write has been lapped or indeed
@@ -293,7 +293,7 @@ again:
/* Check there is anything here */
if (last_written_p_copy == NULL)
return -EAGAIN;
- memcpy(data, last_written_p_copy, ring->buf.bpd);
+ memcpy(data, last_written_p_copy, ring->buf.bytes_per_datum);
if (unlikely(ring->last_written_p != last_written_p_copy))
goto again;
@@ -322,7 +322,7 @@ int iio_request_update_sw_rb(struct iio_ring_buffer *r)
goto error_ret;
}
__iio_free_sw_ring_buffer(ring);
- ret = __iio_allocate_sw_ring_buffer(ring, ring->buf.bpd,
+ ret = __iio_allocate_sw_ring_buffer(ring, ring->buf.bytes_per_datum,
ring->buf.length);
error_ret:
spin_unlock(&ring->use_lock);
@@ -330,23 +330,23 @@ error_ret:
}
EXPORT_SYMBOL(iio_request_update_sw_rb);
-int iio_get_bpd_sw_rb(struct iio_ring_buffer *r)
+int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r)
{
struct iio_sw_ring_buffer *ring = iio_to_sw_ring(r);
- return ring->buf.bpd;
+ return ring->buf.bytes_per_datum;
}
-EXPORT_SYMBOL(iio_get_bpd_sw_rb);
+EXPORT_SYMBOL(iio_get_bytes_per_datum_sw_rb);
-int iio_set_bpd_sw_rb(struct iio_ring_buffer *r, size_t bpd)
+int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd)
{
- if (r->bpd != bpd) {
- r->bpd = bpd;
+ if (r->bytes_per_datum != bpd) {
+ r->bytes_per_datum = bpd;
if (r->access.mark_param_change)
r->access.mark_param_change(r);
}
return 0;
}
-EXPORT_SYMBOL(iio_set_bpd_sw_rb);
+EXPORT_SYMBOL(iio_set_bytes_per_datum_sw_rb);
int iio_get_length_sw_rb(struct iio_ring_buffer *r)
{
@@ -380,14 +380,14 @@ static void iio_sw_rb_release(struct device *dev)
}
static IIO_RING_ENABLE_ATTR;
-static IIO_RING_BPS_ATTR;
+static IIO_RING_BYTES_PER_DATUM_ATTR;
static IIO_RING_LENGTH_ATTR;
/* Standard set of ring buffer attributes */
static struct attribute *iio_ring_attributes[] = {
&dev_attr_length.attr,
- &dev_attr_bps.attr,
- &dev_attr_ring_enable.attr,
+ &dev_attr_bytes_per_datum.attr,
+ &dev_attr_enable.attr,
NULL,
};
@@ -435,23 +435,24 @@ EXPORT_SYMBOL(iio_sw_rb_free);
int iio_sw_ring_preenable(struct iio_dev *indio_dev)
{
+ struct iio_ring_buffer *ring = indio_dev->ring;
size_t size;
dev_dbg(&indio_dev->dev, "%s\n", __func__);
/* Check if there are any scan elements enabled, if not fail*/
- if (!(indio_dev->scan_count || indio_dev->scan_timestamp))
+ if (!(ring->scan_count || ring->scan_timestamp))
return -EINVAL;
- if (indio_dev->scan_timestamp)
- if (indio_dev->scan_count)
+ if (ring->scan_timestamp)
+ if (ring->scan_count)
/* Timestamp (aligned to s64) and data */
- size = (((indio_dev->scan_count * indio_dev->ring->bpe)
+ size = (((ring->scan_count * ring->bpe)
+ sizeof(s64) - 1)
& ~(sizeof(s64) - 1))
+ sizeof(s64);
else /* Timestamp only */
size = sizeof(s64);
else /* Data only */
- size = indio_dev->scan_count * indio_dev->ring->bpe;
- indio_dev->ring->access.set_bpd(indio_dev->ring, size);
+ size = ring->scan_count * ring->bpe;
+ ring->access.set_bytes_per_datum(ring, size);
return 0;
}
@@ -462,9 +463,9 @@ void iio_sw_trigger_bh_to_ring(struct work_struct *work_s)
struct iio_sw_ring_helper_state *st
= container_of(work_s, struct iio_sw_ring_helper_state,
work_trigger_to_ring);
+ struct iio_ring_buffer *ring = st->indio_dev->ring;
int len = 0;
- size_t datasize = st->indio_dev
- ->ring->access.get_bpd(st->indio_dev->ring);
+ size_t datasize = ring->access.get_bytes_per_datum(ring);
char *data = kmalloc(datasize, GFP_KERNEL);
if (data == NULL) {
@@ -473,16 +474,16 @@ void iio_sw_trigger_bh_to_ring(struct work_struct *work_s)
return;
}
- if (st->indio_dev->scan_count)
+ if (ring->scan_count)
len = st->get_ring_element(st, data);
/* Guaranteed to be aligned with 8 byte boundary */
- if (st->indio_dev->scan_timestamp)
+ if (ring->scan_timestamp)
*(s64 *)(((phys_addr_t)data + len
+ sizeof(s64) - 1) & ~(sizeof(s64) - 1))
= st->last_timestamp;
- st->indio_dev->ring->access.store_to(st->indio_dev->ring,
- (u8 *)data,
+ ring->access.store_to(ring,
+ (u8 *)data,
st->last_timestamp);
iio_trigger_notify_done(st->indio_dev->trig);
diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h
index 61f1ed650392..ad03d832c1b9 100644
--- a/drivers/staging/iio/ring_sw.h
+++ b/drivers/staging/iio/ring_sw.h
@@ -121,19 +121,19 @@ int iio_mark_update_needed_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_get_bpd_sw_rb() - get the datum size in bytes
+ * iio_get_bytes_per_datum_sw_rb() - get the datum size in bytes
* @r: pointer to a software ring buffer created by an
* iio_create_sw_rb call
**/
-int iio_get_bpd_sw_rb(struct iio_ring_buffer *r);
+int iio_get_bytes_per_datum_sw_rb(struct iio_ring_buffer *r);
/**
- * iio_set_bpd_sw_rb() - set the datum size in bytes
+ * iio_set_bytes_per_datum_sw_rb() - set the datum size in bytes
* @r: pointer to a software ring buffer created by an
* iio_create_sw_rb call
* @bpd: bytes per datum value
**/
-int iio_set_bpd_sw_rb(struct iio_ring_buffer *r, size_t bpd);
+int iio_set_bytes_per_datum_sw_rb(struct iio_ring_buffer *r, size_t bpd);
/**
* iio_get_length_sw_rb() - get how many datums the rb may contain
@@ -166,8 +166,8 @@ static inline void iio_ring_sw_register_funcs(struct iio_ring_access_funcs *ra)
ra->mark_param_change = &iio_mark_update_needed_sw_rb;
ra->request_update = &iio_request_update_sw_rb;
- ra->get_bpd = &iio_get_bpd_sw_rb;
- ra->set_bpd = &iio_set_bpd_sw_rb;
+ ra->get_bytes_per_datum = &iio_get_bytes_per_datum_sw_rb;
+ ra->set_bytes_per_datum = &iio_set_bytes_per_datum_sw_rb;
ra->get_length = &iio_get_length_sw_rb;
ra->set_length = &iio_set_length_sw_rb;
diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
index 60834162eb32..a4d4bb6725ca 100644
--- a/drivers/staging/iio/sysfs.h
+++ b/drivers/staging/iio/sysfs.h
@@ -130,6 +130,13 @@ struct iio_const_attr {
IIO_DEVICE_ATTR(name, S_IRUGO, _show, NULL, 0)
/**
+ * IIO_CONST_ATTR_NAME - constant identifier
+ * @_string: the name
+ **/
+#define IIO_CONST_ATTR_NAME(_string) \
+ IIO_CONST_ATTR(name, _string)
+
+/**
* IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
* @_mode: sysfs file mode/permissions
* @_show: output method for the attribute
@@ -156,10 +163,6 @@ struct iio_const_attr {
*
* Constant version
**/
-/* Deprecated */
-#define IIO_CONST_ATTR_AVAIL_SAMP_FREQ(_string) \
- IIO_CONST_ATTR(available_sampling_frequency, _string)
-
#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
IIO_CONST_ATTR(sampling_frequency_available, _string)
@@ -244,6 +247,12 @@ struct iio_const_attr {
#define IIO_DEV_ATTR_TEMP_RAW(_show) \
IIO_DEVICE_ATTR(temp_raw, S_IRUGO, _show, NULL, 0)
+#define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
+ IIO_CONST_ATTR(temp_offset, _string)
+
+#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
+ IIO_CONST_ATTR(temp_scale, _string)
+
/**
* IIO_EVENT_SH - generic shared event handler
* @_name: event name
diff --git a/drivers/staging/line6/Kconfig b/drivers/staging/line6/Kconfig
index bc1ffbed3c8a..43120ff2ab78 100644
--- a/drivers/staging/line6/Kconfig
+++ b/drivers/staging/line6/Kconfig
@@ -1,4 +1,4 @@
-config LINE6_USB
+menuconfig LINE6_USB
tristate "Line6 USB support"
depends on USB && SND
select SND_RAWMIDI
@@ -18,5 +18,68 @@ config LINE6_USB
* Signal routing (record clean/processed guitar signal,
re-amping)
- Preliminary support for the Variax Workbench is included.
+ Preliminary support for the Variax Workbench and TonePort
+ devices is included.
+if LINE6_USB
+
+config LINE6_USB_DEBUG
+ bool "print debug messages"
+ default n
+ help
+ Say Y here to write debug messages to the syslog.
+
+ If unsure, say N.
+
+config LINE6_USB_DUMP_CTRL
+ bool "dump control messages"
+ default n
+ help
+ Say Y here to write control messages sent to and received from
+ Line6 devices to the syslog.
+
+ If unsure, say N.
+
+config LINE6_USB_DUMP_MIDI
+ bool "dump MIDI messages"
+ default n
+ help
+ Say Y here to write MIDI messages sent to and received from
+ Line6 devices to the syslog.
+
+ If unsure, say N.
+
+config LINE6_USB_DUMP_PCM
+ bool "dump PCM data"
+ default n
+ help
+ Say Y here to write PCM data sent to and received from Line6
+ devices to the syslog. This will produce a huge amount of
+ syslog data during playback and capture.
+
+ If unsure, say N.
+
+config LINE6_USB_RAW
+ bool "raw data communication"
+ default n
+ help
+ Say Y here to create special files which allow to send raw data
+ to the device. This bypasses any sanity checks, so if you discover
+ the code to erase the firmware, feel free to render your device
+ useless, but only after reading the GPL section "NO WARRANTY".
+
+ If unsure, say N.
+
+config LINE6_USB_IMPULSE_RESPONSE
+ bool "measure impulse response"
+ default n
+ help
+ Say Y here to add code to measure the impulse response of a Line6
+ device. This is more accurate than user-space methods since it
+ bypasses any PCM data buffering (e.g., by ALSA or jack). This is
+ useful for assessing the performance of new devices, but is not
+ required for normal operation.
+
+ If unsure, say N.
+
+endif # LINE6_USB
diff --git a/drivers/staging/line6/audio.c b/drivers/staging/line6/audio.c
index e2ac8d60f8c2..b1488d321c7b 100644
--- a/drivers/staging/line6/audio.c
+++ b/drivers/staging/line6/audio.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,17 +9,15 @@
*
*/
-#include "driver.h"
-#include "audio.h"
-
#include <sound/core.h>
#include <sound/initval.h>
+#include "driver.h"
+#include "audio.h"
static int line6_index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
static char *line6_id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
-
/*
Initialize the Line6 USB audio system.
*/
@@ -36,10 +34,10 @@ int line6_init_audio(struct usb_line6 *line6)
line6->card = card;
+ strcpy(card->id, line6->properties->id);
strcpy(card->driver, DRIVER_NAME);
- strcpy(card->shortname, "Line6-USB");
- sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
- dev_name(line6->ifcdev)); /* 80 chars - see asound.h */
+ strcpy(card->shortname, line6->properties->name);
+ sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name, dev_name(line6->ifcdev)); /* 80 chars - see asound.h */
return 0;
}
diff --git a/drivers/staging/line6/audio.h b/drivers/staging/line6/audio.h
index cc0245adbcd9..5f8a09a0fa95 100644
--- a/drivers/staging/line6/audio.h
+++ b/drivers/staging/line6/audio.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,13 +12,10 @@
#ifndef AUDIO_H
#define AUDIO_H
-
#include "driver.h"
-
extern void line6_cleanup_audio(struct usb_line6 *);
extern int line6_init_audio(struct usb_line6 *);
extern int line6_register_audio(struct usb_line6 *);
-
#endif
diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c
index ca092247f363..a3c99244b359 100644
--- a/drivers/staging/line6/capture.c
+++ b/drivers/staging/line6/capture.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,37 +9,34 @@
*
*/
-#include "driver.h"
-
-#include <linux/slab.h>
-
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include "audio.h"
+#include "capture.h"
+#include "driver.h"
#include "pcm.h"
#include "pod.h"
-#include "capture.h"
/*
Find a free URB and submit it.
*/
-static int submit_audio_in_urb(struct snd_pcm_substream *substream)
+static int submit_audio_in_urb(struct snd_line6_pcm *line6pcm)
{
- unsigned int index;
+ int index;
unsigned long flags;
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
int i, urb_size;
+ int ret;
struct urb *urb_in;
spin_lock_irqsave(&line6pcm->lock_audio_in, flags);
index =
find_first_zero_bit(&line6pcm->active_urb_in, LINE6_ISO_BUFFERS);
- if (index >= LINE6_ISO_BUFFERS) {
+ if (index < 0 || index >= LINE6_ISO_BUFFERS) {
spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags);
- dev_err(s2m(substream), "no free URB found\n");
+ dev_err(line6pcm->line6->ifcdev, "no free URB found\n");
return -EINVAL;
}
@@ -58,13 +55,15 @@ static int submit_audio_in_urb(struct snd_pcm_substream *substream)
line6pcm->buffer_in +
index * LINE6_ISO_PACKETS * line6pcm->max_packet_size;
urb_in->transfer_buffer_length = urb_size;
- urb_in->context = substream;
+ urb_in->context = line6pcm;
+
+ ret = usb_submit_urb(urb_in, GFP_ATOMIC);
- if (usb_submit_urb(urb_in, GFP_ATOMIC) == 0)
+ if (ret == 0)
set_bit(index, &line6pcm->active_urb_in);
else
- dev_err(s2m(substream), "URB in #%d submission failed\n",
- index);
+ dev_err(line6pcm->line6->ifcdev,
+ "URB in #%d submission failed (%d)\n", index, ret);
spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags);
return 0;
@@ -73,12 +72,12 @@ static int submit_audio_in_urb(struct snd_pcm_substream *substream)
/*
Submit all currently available capture URBs.
*/
-static int submit_audio_in_all_urbs(struct snd_pcm_substream *substream)
+int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm)
{
int ret, i;
for (i = 0; i < LINE6_ISO_BUFFERS; ++i) {
- ret = submit_audio_in_urb(substream);
+ ret = submit_audio_in_urb(line6pcm);
if (ret < 0)
return ret;
}
@@ -89,7 +88,7 @@ static int submit_audio_in_all_urbs(struct snd_pcm_substream *substream)
/*
Unlink all currently active capture URBs.
*/
-static void unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm)
+void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm)
{
unsigned int i;
@@ -126,41 +125,83 @@ static void wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm)
} while (--timeout > 0);
if (alive)
snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
-
- line6pcm->active_urb_in = 0;
- line6pcm->unlink_urb_in = 0;
}
/*
Unlink all currently active capture URBs, and wait for finishing.
*/
-void unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm)
+void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm)
{
- unlink_audio_in_urbs(line6pcm);
+ line6_unlink_audio_in_urbs(line6pcm);
wait_clear_audio_in_urbs(line6pcm);
}
/*
- Callback for completed capture URB.
+ Copy data into ALSA capture buffer.
+*/
+void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize)
+{
+ struct snd_pcm_substream *substream =
+ get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE);
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ const int bytes_per_frame = line6pcm->properties->bytes_per_frame;
+ int frames = fsize / bytes_per_frame;
+
+ if (line6pcm->pos_in_done + frames > runtime->buffer_size) {
+ /*
+ The transferred area goes over buffer boundary,
+ copy two separate chunks.
+ */
+ int len;
+ len = runtime->buffer_size - line6pcm->pos_in_done;
+
+ if (len > 0) {
+ memcpy(runtime->dma_area +
+ line6pcm->pos_in_done * bytes_per_frame, fbuf,
+ len * bytes_per_frame);
+ memcpy(runtime->dma_area, fbuf + len * bytes_per_frame,
+ (frames - len) * bytes_per_frame);
+ } else
+ dev_err(line6pcm->line6->ifcdev, "driver bug: len = %d\n", len); /* this is somewhat paranoid */
+ } else {
+ /* copy single chunk */
+ memcpy(runtime->dma_area +
+ line6pcm->pos_in_done * bytes_per_frame, fbuf, fsize);
+ }
+
+ if ((line6pcm->pos_in_done += frames) >= runtime->buffer_size)
+ line6pcm->pos_in_done -= runtime->buffer_size;
+}
+
+void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length)
+{
+ struct snd_pcm_substream *substream =
+ get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE);
+
+ if ((line6pcm->bytes_in += length) >= line6pcm->period_in) {
+ line6pcm->bytes_in %= line6pcm->period_in;
+ snd_pcm_period_elapsed(substream);
+ }
+}
+
+/*
+ Callback for completed capture URB.
*/
static void audio_in_callback(struct urb *urb)
{
int i, index, length = 0, shutdown = 0;
- int frames;
unsigned long flags;
- struct snd_pcm_substream *substream =
- (struct snd_pcm_substream *)urb->context;
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
- const int bytes_per_frame = line6pcm->properties->bytes_per_frame;
- struct snd_pcm_runtime *runtime = substream->runtime;
+ struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
+
+ line6pcm->last_frame_in = urb->start_frame;
/* find index of URB */
for (index = 0; index < LINE6_ISO_BUFFERS; ++index)
if (urb == line6pcm->urb_audio_in[index])
break;
-#if DO_DUMP_PCM_RECEIVE
+#ifdef CONFIG_LINE6_USB_DUMP_PCM
for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
struct usb_iso_packet_descriptor *fout =
&urb->iso_frame_desc[i];
@@ -177,71 +218,53 @@ static void audio_in_callback(struct urb *urb)
int fsize;
struct usb_iso_packet_descriptor *fin = &urb->iso_frame_desc[i];
- if (fin->status == -18) {
+ if (fin->status == -EXDEV) {
shutdown = 1;
break;
}
fbuf = urb->transfer_buffer + fin->offset;
fsize = fin->actual_length;
+
+ if (fsize > line6pcm->max_packet_size) {
+ dev_err(line6pcm->line6->ifcdev,
+ "driver and/or device bug: packet too large (%d > %d)\n",
+ fsize, line6pcm->max_packet_size);
+ }
+
length += fsize;
- if (fsize > 0) {
- frames = fsize / bytes_per_frame;
-
- if (line6pcm->pos_in_done + frames >
- runtime->buffer_size) {
- /*
- The transferred area goes over buffer
- boundary, copy two separate chunks.
- */
- int len;
- len =
- runtime->buffer_size -
- line6pcm->pos_in_done;
-
- if (len > 0) {
- memcpy(runtime->dma_area +
- line6pcm->pos_in_done *
- bytes_per_frame, fbuf,
- len * bytes_per_frame);
- memcpy(runtime->dma_area,
- fbuf + len * bytes_per_frame,
- (frames -
- len) * bytes_per_frame);
- } else {
- /* this is somewhat paranoid */
- dev_err(s2m(substream),
- "driver bug: len = %d\n", len);
- }
- } else {
- /* copy single chunk */
- memcpy(runtime->dma_area +
- line6pcm->pos_in_done * bytes_per_frame,
- fbuf, fsize * bytes_per_frame);
- }
+ /* the following assumes LINE6_ISO_PACKETS == 1: */
+#if LINE6_BACKUP_MONITOR_SIGNAL
+ memcpy(line6pcm->prev_fbuf, fbuf, fsize);
+#else
+ line6pcm->prev_fbuf = fbuf;
+#endif
+ line6pcm->prev_fsize = fsize;
- line6pcm->pos_in_done += frames;
- if (line6pcm->pos_in_done >= runtime->buffer_size)
- line6pcm->pos_in_done -= runtime->buffer_size;
- }
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ if (!(line6pcm->flags & MASK_PCM_IMPULSE))
+#endif
+ if (test_bit(BIT_PCM_ALSA_CAPTURE, &line6pcm->flags)
+ && (fsize > 0))
+ line6_capture_copy(line6pcm, fbuf, fsize);
}
clear_bit(index, &line6pcm->active_urb_in);
- if (test_bit(index, &line6pcm->unlink_urb_in))
+ if (test_and_clear_bit(index, &line6pcm->unlink_urb_in))
shutdown = 1;
spin_unlock_irqrestore(&line6pcm->lock_audio_in, flags);
if (!shutdown) {
- submit_audio_in_urb(substream);
+ submit_audio_in_urb(line6pcm);
- line6pcm->bytes_in += length;
- if (line6pcm->bytes_in >= line6pcm->period_in) {
- line6pcm->bytes_in -= line6pcm->period_in;
- snd_pcm_period_elapsed(substream);
- }
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ if (!(line6pcm->flags & MASK_PCM_IMPULSE))
+#endif
+ if (test_bit(BIT_PCM_ALSA_CAPTURE, &line6pcm->flags))
+ line6_capture_check_period(line6pcm, length);
}
}
@@ -254,8 +277,8 @@ static int snd_line6_capture_open(struct snd_pcm_substream *substream)
err = snd_pcm_hw_constraint_ratdens(runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
- (&line6pcm->properties->
- snd_line6_rates));
+ (&line6pcm->
+ properties->snd_line6_rates));
if (err < 0)
return err;
@@ -294,54 +317,40 @@ static int snd_line6_capture_hw_params(struct snd_pcm_substream *substream,
return ret;
line6pcm->period_in = params_period_bytes(hw_params);
- line6pcm->buffer_in =
- kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
- LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL);
-
- if (!line6pcm->buffer_in) {
- dev_err(s2m(substream), "cannot malloc buffer_in\n");
- return -ENOMEM;
- }
-
return 0;
}
/* hw_free capture callback */
static int snd_line6_capture_hw_free(struct snd_pcm_substream *substream)
{
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
- unlink_wait_clear_audio_in_urbs(line6pcm);
-
- kfree(line6pcm->buffer_in);
- line6pcm->buffer_in = NULL;
-
return snd_pcm_lib_free_pages(substream);
}
/* trigger callback */
-int snd_line6_capture_trigger(struct snd_pcm_substream *substream, int cmd)
+int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd)
{
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
int err;
- line6pcm->count_in = 0;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
- if (!test_and_set_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags)) {
- err = submit_audio_in_all_urbs(substream);
+#ifdef CONFIG_PM
+ case SNDRV_PCM_TRIGGER_RESUME:
+#endif
+ err = line6_pcm_start(line6pcm, MASK_PCM_ALSA_CAPTURE);
- if (err < 0) {
- clear_bit(BIT_RUNNING_CAPTURE,
- &line6pcm->flags);
- return err;
- }
- }
+ if (err < 0)
+ return err;
break;
case SNDRV_PCM_TRIGGER_STOP:
- if (test_and_clear_bit(BIT_RUNNING_CAPTURE, &line6pcm->flags))
- unlink_audio_in_urbs(line6pcm);
+#ifdef CONFIG_PM
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+#endif
+ err = line6_pcm_stop(line6pcm, MASK_PCM_ALSA_CAPTURE);
+
+ if (err < 0)
+ return err;
break;
@@ -372,7 +381,7 @@ struct snd_pcm_ops snd_line6_capture_ops = {
.pointer = snd_line6_capture_pointer,
};
-int create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
+int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
{
int i;
@@ -392,8 +401,8 @@ int create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
urb->dev = line6pcm->line6->usbdev;
urb->pipe =
usb_rcvisocpipe(line6pcm->line6->usbdev,
- line6pcm->
- ep_audio_read & USB_ENDPOINT_NUMBER_MASK);
+ line6pcm->ep_audio_read &
+ USB_ENDPOINT_NUMBER_MASK);
urb->transfer_flags = URB_ISO_ASAP;
urb->start_frame = -1;
urb->number_of_packets = LINE6_ISO_PACKETS;
diff --git a/drivers/staging/line6/capture.h b/drivers/staging/line6/capture.h
index 5c44464d29d4..a7509fbbb954 100644
--- a/drivers/staging/line6/capture.h
+++ b/drivers/staging/line6/capture.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,21 +12,22 @@
#ifndef CAPTURE_H
#define CAPTURE_H
-
-#include "driver.h"
-
#include <sound/pcm.h>
+#include "driver.h"
#include "pcm.h"
-
extern struct snd_pcm_ops snd_line6_capture_ops;
-
-extern int create_audio_in_urbs(struct snd_line6_pcm *line6pcm);
-extern int snd_line6_capture_trigger(struct snd_pcm_substream *substream,
- int cmd);
-extern void unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm *line6pcm);
-
+extern void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf,
+ int fsize);
+extern void line6_capture_check_period(struct snd_line6_pcm *line6pcm,
+ int length);
+extern int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm);
+extern int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm);
+extern void line6_unlink_audio_in_urbs(struct snd_line6_pcm *line6pcm);
+extern void line6_unlink_wait_clear_audio_in_urbs(struct snd_line6_pcm
+ *line6pcm);
+extern int snd_line6_capture_trigger(struct snd_line6_pcm *line6pcm, int cmd);
#endif
diff --git a/drivers/staging/line6/control.c b/drivers/staging/line6/control.c
index 0b598526de62..22564aed61e4 100644
--- a/drivers/staging/line6/control.c
+++ b/drivers/staging/line6/control.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,11 +9,10 @@
*
*/
-#include "driver.h"
-
#include <linux/usb.h>
#include "control.h"
+#include "driver.h"
#include "pod.h"
#include "usbdefs.h"
#include "variax.h"
@@ -45,7 +44,7 @@ static ssize_t pod_get_param_int(struct device *dev, char *buf, int param)
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- int retval = line6_wait_dump(&pod->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&pod->dumpreq);
if (retval < 0)
return retval;
return sprintf(buf, "%d\n", pod->prog_data.control[param]);
@@ -63,7 +62,7 @@ static ssize_t pod_set_param_int(struct device *dev, const char *buf,
if (retval)
return retval;
- pod_transmit_parameter(pod, param, value);
+ line6_pod_transmit_parameter(pod, param, value);
return count;
}
@@ -71,7 +70,7 @@ static ssize_t variax_get_param_int(struct device *dev, char *buf, int param)
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_variax *variax = usb_get_intfdata(interface);
- int retval = line6_wait_dump(&variax->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&variax->dumpreq);
if (retval < 0)
return retval;
return sprintf(buf, "%d\n", variax->model_data.control[param]);
@@ -80,12 +79,11 @@ static ssize_t variax_get_param_int(struct device *dev, char *buf, int param)
static ssize_t variax_get_param_float(struct device *dev, char *buf, int param)
{
/*
- We do our own floating point handling here since floats in the
- kernel are problematic for at least two reasons: - many distros
- are still shipped with binary kernels optimized for the ancient
- 80386 without FPU
- - there isn't a printf("%f")
- (see http://www.kernelthread.com/publications/faq/335.html)
+ We do our own floating point handling here since at the time
+ this code was written (Jan 2006) it was highly discouraged to
+ use floating point arithmetic in the kernel. If you think that
+ this no longer applies, feel free to replace this by generic
+ floating point code.
*/
static const int BIAS = 0x7f;
@@ -97,7 +95,7 @@ static ssize_t variax_get_param_float(struct device *dev, char *buf, int param)
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_variax *variax = usb_get_intfdata(interface);
const unsigned char *p = variax->model_data.control + param;
- int retval = line6_wait_dump(&variax->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&variax->dumpreq);
if (retval < 0)
return retval;
@@ -530,7 +528,7 @@ static DEVICE_ATTR(mix1, S_IRUGO, variax_get_mix1, line6_nop_write);
static DEVICE_ATTR(pickup_wiring, S_IRUGO, variax_get_pickup_wiring,
line6_nop_write);
-int pod_create_files(int firmware, int type, struct device *dev)
+int line6_pod_create_files(int firmware, int type, struct device *dev)
{
int err;
CHECK_RETURN(device_create_file(dev, &dev_attr_tweak));
@@ -733,9 +731,10 @@ int pod_create_files(int firmware, int type, struct device *dev)
(dev, &dev_attr_band_6_gain__bass));
return 0;
}
-EXPORT_SYMBOL(pod_create_files);
-void pod_remove_files(int firmware, int type, struct device *dev)
+EXPORT_SYMBOL(line6_pod_create_files);
+
+void line6_pod_remove_files(int firmware, int type, struct device *dev)
{
device_remove_file(dev, &dev_attr_tweak);
device_remove_file(dev, &dev_attr_wah_position);
@@ -908,9 +907,10 @@ void pod_remove_files(int firmware, int type, struct device *dev)
if (firmware >= 200)
device_remove_file(dev, &dev_attr_band_6_gain__bass);
}
-EXPORT_SYMBOL(pod_remove_files);
-int variax_create_files(int firmware, int type, struct device *dev)
+EXPORT_SYMBOL(line6_pod_remove_files);
+
+int line6_variax_create_files(int firmware, int type, struct device *dev)
{
int err;
CHECK_RETURN(device_create_file(dev, &dev_attr_body));
@@ -954,9 +954,10 @@ int variax_create_files(int firmware, int type, struct device *dev)
CHECK_RETURN(device_create_file(dev, &dev_attr_pickup_wiring));
return 0;
}
-EXPORT_SYMBOL(variax_create_files);
-void variax_remove_files(int firmware, int type, struct device *dev)
+EXPORT_SYMBOL(line6_variax_create_files);
+
+void line6_variax_remove_files(int firmware, int type, struct device *dev)
{
device_remove_file(dev, &dev_attr_body);
device_remove_file(dev, &dev_attr_pickup1_enable);
@@ -998,4 +999,5 @@ void variax_remove_files(int firmware, int type, struct device *dev)
device_remove_file(dev, &dev_attr_mix1);
device_remove_file(dev, &dev_attr_pickup_wiring);
}
-EXPORT_SYMBOL(variax_remove_files);
+
+EXPORT_SYMBOL(line6_variax_remove_files);
diff --git a/drivers/staging/line6/control.h b/drivers/staging/line6/control.h
index 47e18ab6d5b0..e4c5d2ce2aae 100644
--- a/drivers/staging/line6/control.h
+++ b/drivers/staging/line6/control.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,54 +12,40 @@
#ifndef LINE6_CONTROL_H
#define LINE6_CONTROL_H
-
/**
List of PODxt Pro controls.
See Appendix C of the "PODxt (Pro) Pilot's Handbook" by Line6.
Comments after the number refer to the PODxt Pro firmware version required
for this feature.
+
+ Please *don't* reformat this file since "control.c" is created automatically
+ from "control.h", and this process depends on the exact formatting of the
+ code and the comments below!
*/
+
+/* *INDENT-OFF* */
+
enum {
POD_tweak = 1,
POD_wah_position = 4,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_compression_gain = 5,
-
+ POD_compression_gain = 5, /* device: LINE6_BITS_PODXTALL */
POD_vol_pedal_position = 7,
POD_compression_threshold = 9,
POD_pan = 10,
POD_amp_model_setup = 11,
- POD_amp_model = 12, /* firmware: 2.0 */
+ POD_amp_model = 12, /* firmware: 2.0 */
POD_drive = 13,
POD_bass = 14,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_mid = 15,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_lowmid = 15,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_treble = 16,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_highmid = 16,
-
+ POD_mid = 15, /* device: LINE6_BITS_PODXTALL */
+ POD_lowmid = 15, /* device: LINE6_BITS_BASSPODXTALL */
+ POD_treble = 16, /* device: LINE6_BITS_PODXTALL */
+ POD_highmid = 16, /* device: LINE6_BITS_BASSPODXTALL */
POD_chan_vol = 17,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_reverb_mix = 18,
-
+ POD_reverb_mix = 18, /* device: LINE6_BITS_PODXTALL */
POD_effect_setup = 19,
POD_band_1_frequency = 20, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_PODXTALL */
- POD_presence = 21,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_treble__bass = 21,
-
+ POD_presence = 21, /* device: LINE6_BITS_PODXTALL */
+ POD_treble__bass = 21, /* device: LINE6_BITS_BASSPODXTALL */
POD_noise_gate_enable = 22,
POD_gate_threshold = 23,
POD_gate_decay_time = 24,
@@ -70,137 +56,78 @@ enum {
POD_mod_param_1 = 29,
POD_delay_param_1 = 30,
POD_delay_param_1_note_value = 31,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_2_frequency__bass = 32, /* firmware: 2.0 */
-
+ POD_band_2_frequency__bass = 32, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_delay_param_2 = 33,
POD_delay_volume_mix = 34,
POD_delay_param_3 = 35,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_reverb_enable = 36,
- POD_reverb_type = 37,
- POD_reverb_decay = 38,
- POD_reverb_tone = 39,
- POD_reverb_pre_delay = 40,
- POD_reverb_pre_post = 41,
- POD_band_2_frequency = 42,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_3_frequency__bass = 42, /* firmware: 2.0 */
-
+ POD_reverb_enable = 36, /* device: LINE6_BITS_PODXTALL */
+ POD_reverb_type = 37, /* device: LINE6_BITS_PODXTALL */
+ POD_reverb_decay = 38, /* device: LINE6_BITS_PODXTALL */
+ POD_reverb_tone = 39, /* device: LINE6_BITS_PODXTALL */
+ POD_reverb_pre_delay = 40, /* device: LINE6_BITS_PODXTALL */
+ POD_reverb_pre_post = 41, /* device: LINE6_BITS_PODXTALL */
+ POD_band_2_frequency = 42, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_3_frequency__bass = 42, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_wah_enable = 43,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_modulation_lo_cut = 44,
- POD_delay_reverb_lo_cut = 45,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_volume_pedal_minimum = 46, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_eq_pre_post = 46, /* firmware: 2.0 */
-
+ POD_modulation_lo_cut = 44, /* device: LINE6_BITS_BASSPODXTALL */
+ POD_delay_reverb_lo_cut = 45, /* device: LINE6_BITS_BASSPODXTALL */
+ POD_volume_pedal_minimum = 46, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_eq_pre_post = 46, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_volume_pre_post = 47,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_di_model = 48,
- POD_di_delay = 49,
-
+ POD_di_model = 48, /* device: LINE6_BITS_BASSPODXTALL */
+ POD_di_delay = 49, /* device: LINE6_BITS_BASSPODXTALL */
POD_mod_enable = 50,
POD_mod_param_1_note_value = 51,
POD_mod_param_2 = 52,
POD_mod_param_3 = 53,
POD_mod_param_4 = 54,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_mod_param_5 = 55,
-
+ POD_mod_param_5 = 55, /* device: LINE6_BITS_BASSPODXTALL */
POD_mod_volume_mix = 56,
POD_mod_pre_post = 57,
POD_modulation_model = 58,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_band_3_frequency = 60, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_4_frequency__bass = 60, /* firmware: 2.0 */
-
+ POD_band_3_frequency = 60, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_4_frequency__bass = 60, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_mod_param_1_double_precision = 61,
POD_delay_param_1_double_precision = 62,
POD_eq_enable = 63, /* firmware: 2.0 */
POD_tap = 64,
POD_volume_tweak_pedal_assign = 65,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_5_frequency = 68, /* firmware: 2.0 */
-
+ POD_band_5_frequency = 68, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_tuner = 69,
POD_mic_selection = 70,
POD_cabinet_model = 71,
POD_stomp_model = 75,
POD_roomlevel = 76,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_band_4_frequency = 77, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_6_frequency = 77, /* firmware: 2.0 */
-
+ POD_band_4_frequency = 77, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_6_frequency = 77, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
POD_stomp_param_1_note_value = 78,
POD_stomp_param_2 = 79,
POD_stomp_param_3 = 80,
POD_stomp_param_4 = 81,
POD_stomp_param_5 = 82,
POD_stomp_param_6 = 83,
-
- /* device: LINE6_BITS_LIVE */
- POD_amp_switch_select = 84,
-
+ POD_amp_switch_select = 84, /* device: LINE6_BITS_LIVE */
POD_delay_param_4 = 85,
POD_delay_param_5 = 86,
POD_delay_pre_post = 87,
-
- /* device: LINE6_BITS_PODXTALL */
- POD_delay_model = 88,
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_delay_verb_model = 88,
-
+ POD_delay_model = 88, /* device: LINE6_BITS_PODXTALL */
+ POD_delay_verb_model = 88, /* device: LINE6_BITS_BASSPODXTALL */
POD_tempo_msb = 89,
POD_tempo_lsb = 90,
POD_wah_model = 91, /* firmware: 3.0 */
POD_bypass_volume = 105, /* firmware: 2.14 */
-
- /* device: LINE6_BITS_PRO */
- POD_fx_loop_on_off = 107,
-
+ POD_fx_loop_on_off = 107, /* device: LINE6_BITS_PRO */
POD_tweak_param_select = 108,
POD_amp1_engage = 111,
POD_band_1_gain = 114, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_2_gain__bass = 115, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_PODXTALL */
- POD_band_2_gain = 116, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_3_gain__bass = 116, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_PODXTALL */
- POD_band_3_gain = 117, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_4_gain__bass = 117, /* firmware: 2.0 */
- POD_band_5_gain__bass = 118, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_PODXTALL */
- POD_band_4_gain = 119, /* firmware: 2.0 */
-
- /* device: LINE6_BITS_BASSPODXTALL */
- POD_band_6_gain__bass = 119 /* firmware: 2.0 */
+ POD_band_2_gain__bass = 115, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
+ POD_band_2_gain = 116, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_3_gain__bass = 116, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
+ POD_band_3_gain = 117, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_4_gain__bass = 117, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
+ POD_band_5_gain__bass = 118, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
+ POD_band_4_gain = 119, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */
+ POD_band_6_gain__bass = 119 /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */
};
/**
@@ -218,8 +145,7 @@ enum {
VARIAX_pickup2_position = 23, /* type: 24 bit float */
VARIAX_pickup2_angle = 26, /* type: 24 bit float */
VARIAX_pickup2_level = 29, /* type: 24 bit float */
- VARIAX_pickup_phase = 32, /* 0: in phase,
- 1: out of phase */
+ VARIAX_pickup_phase = 32, /* 0: in phase, 1: out of phase */
VARIAX_capacitance = 33, /* type: 24 bit float */
VARIAX_tone_resistance = 36, /* type: 24 bit float */
VARIAX_volume_resistance = 39, /* type: 24 bit float */
@@ -257,11 +183,13 @@ enum {
VARIAXMIDI_tone = 79,
};
+/* *INDENT-ON* */
-extern int pod_create_files(int firmware, int type, struct device *dev);
-extern void pod_remove_files(int firmware, int type, struct device *dev);
-extern int variax_create_files(int firmware, int type, struct device *dev);
-extern void variax_remove_files(int firmware, int type, struct device *dev);
-
+extern int line6_pod_create_files(int firmware, int type, struct device *dev);
+extern void line6_pod_remove_files(int firmware, int type, struct device *dev);
+extern int line6_variax_create_files(int firmware, int type,
+ struct device *dev);
+extern void line6_variax_remove_files(int firmware, int type,
+ struct device *dev);
#endif
diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c
index 27b986a50a03..c671427350ef 100644
--- a/drivers/staging/line6/driver.c
+++ b/drivers/staging/line6/driver.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,8 +9,6 @@
*
*/
-#include "driver.h"
-
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -19,6 +17,7 @@
#include "audio.h"
#include "capture.h"
#include "control.h"
+#include "driver.h"
#include "midi.h"
#include "playback.h"
#include "pod.h"
@@ -27,58 +26,77 @@
#include "usbdefs.h"
#include "variax.h"
-
#define DRIVER_AUTHOR "Markus Grabner <grabner@icg.tugraz.at>"
#define DRIVER_DESC "Line6 USB Driver"
-#define DRIVER_VERSION "0.8.0"
-
+#define DRIVER_VERSION "0.9.1beta" DRIVER_REVISION
/* table of devices that work with this driver */
static const struct usb_device_id line6_id_table[] = {
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2) },
- { USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX) },
- { },
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXT)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTLIVE)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_BASSPODXTPRO)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_GUITARPORT)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_POCKETPOD)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_GX)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX1)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODSTUDIO_UX2)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODX3LIVE)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXT)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTLIVE)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_PODXTPRO)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_GX)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX1)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_TONEPORT_UX2)},
+ {USB_DEVICE(LINE6_VENDOR_ID, LINE6_DEVID_VARIAX)},
+ {},
};
+
MODULE_DEVICE_TABLE(usb, line6_id_table);
+/* *INDENT-OFF* */
static struct line6_properties line6_properties_table[] = {
- { "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM },
- { "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM },
- { "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM },
- { "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM },
- { "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL_PCM },
- { "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM },
- { "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM },
- { "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM },
- { "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM },
- { "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM },
- { "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM },
- { "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM },
- { "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM },
- { "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL }
+ { "BassPODxt", "BassPODxt", LINE6_BIT_BASSPODXT, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "BassPODxtLive", "BassPODxt Live", LINE6_BIT_BASSPODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "BassPODxtPro", "BassPODxt Pro", LINE6_BIT_BASSPODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "GuitarPort", "GuitarPort", LINE6_BIT_GUITARPORT, LINE6_BIT_PCM },
+ { "PocketPOD", "Pocket POD", LINE6_BIT_POCKETPOD, LINE6_BIT_CONTROL },
+ { "PODStudioGX", "POD Studio GX", LINE6_BIT_PODSTUDIO_GX, LINE6_BIT_PCM },
+ { "PODStudioUX1", "POD Studio UX1", LINE6_BIT_PODSTUDIO_UX1, LINE6_BIT_PCM },
+ { "PODStudioUX2", "POD Studio UX2", LINE6_BIT_PODSTUDIO_UX2, LINE6_BIT_PCM },
+ { "PODX3", "POD X3", LINE6_BIT_PODX3, LINE6_BIT_PCM },
+ { "PODX3Live", "POD X3 Live", LINE6_BIT_PODX3LIVE, LINE6_BIT_PCM },
+ { "PODxt", "PODxt", LINE6_BIT_PODXT, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "PODxtLive", "PODxt Live", LINE6_BIT_PODXTLIVE, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "PODxtPro", "PODxt Pro", LINE6_BIT_PODXTPRO, LINE6_BIT_CONTROL_PCM_HWMON },
+ { "TonePortGX", "TonePort GX", LINE6_BIT_TONEPORT_GX, LINE6_BIT_PCM },
+ { "TonePortUX1", "TonePort UX1", LINE6_BIT_TONEPORT_UX1, LINE6_BIT_PCM },
+ { "TonePortUX2", "TonePort UX2", LINE6_BIT_TONEPORT_UX2, LINE6_BIT_PCM },
+ { "Variax", "Variax Workbench", LINE6_BIT_VARIAX, LINE6_BIT_CONTROL }
};
-
+/* *INDENT-ON* */
/*
This is Line6's MIDI manufacturer ID.
*/
-const unsigned char line6_midi_id[] = { 0x00, 0x01, 0x0c };
+const unsigned char line6_midi_id[] = {
+ 0x00, 0x01, 0x0c
+};
-struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
-struct workqueue_struct *line6_workqueue;
+/*
+ Code to request version of POD, Variax interface
+ (and maybe other devices).
+*/
+static const char line6_request_version0[] = {
+ 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
+};
+/*
+ Copy of version request code with GFP_KERNEL flag for use in URB.
+*/
+static const char *line6_request_version;
+
+struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
/**
Class for asynchronous messages.
@@ -90,7 +108,6 @@ struct message {
int done;
};
-
/*
Forward declarations.
*/
@@ -98,21 +115,30 @@ static void line6_data_received(struct urb *urb);
static int line6_send_raw_message_async_part(struct message *msg,
struct urb *urb);
-
/*
Start to listen on endpoint.
*/
static int line6_start_listen(struct usb_line6 *line6)
{
+ int err;
usb_fill_int_urb(line6->urb_listen, line6->usbdev,
usb_rcvintpipe(line6->usbdev, line6->ep_control_read),
line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
line6_data_received, line6, line6->interval);
line6->urb_listen->actual_length = 0;
- return usb_submit_urb(line6->urb_listen, GFP_KERNEL);
+ err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC);
+ return err;
}
-#if DO_DUMP_ANY
+/*
+ Stop listening on endpoint.
+*/
+static void line6_stop_listen(struct usb_line6 *line6)
+{
+ usb_kill_urb(line6->urb_listen);
+}
+
+#ifdef CONFIG_LINE6_USB_DUMP_ANY
/*
Write hexdump to syslog.
*/
@@ -136,12 +162,13 @@ void line6_write_hexdump(struct usb_line6 *line6, char dir,
if (j < n) {
unsigned char val = buffer[i + j];
bytes = snprintf(p, hexdumpsize, " %02X", val);
- asc[j] = ((val >= 0x20) && (val < 0x7f)) ? val : '.';
+ asc[j] = ((val >= 0x20)
+ && (val < 0x7f)) ? val : '.';
} else
bytes = snprintf(p, hexdumpsize, " ");
if (bytes > hexdumpsize)
- break; /* buffer overflow */
+ break; /* buffer overflow */
p += bytes;
hexdumpsize -= bytes;
@@ -152,7 +179,7 @@ void line6_write_hexdump(struct usb_line6 *line6, char dir,
}
#endif
-#if DO_DUMP_URB_RECEIVE
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
/*
Dump URB data to syslog.
*/
@@ -169,19 +196,19 @@ static void line6_dump_urb(struct urb *urb)
#endif
/*
- Send raw message in pieces of max_packet_size bytes.
+ Send raw message in pieces of wMaxPacketSize bytes.
*/
int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
int size)
{
int i, done = 0;
- int actual_size;
-#if DO_DUMP_URB_SEND
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
line6_write_hexdump(line6, 'S', buffer, size);
#endif
- for (i = 0; i < size; i += actual_size) {
+ for (i = 0; i < size; i += line6->max_packet_size) {
+ int partial;
const char *frag_buf = buffer + i;
int frag_size = min(line6->max_packet_size, size - i);
int retval;
@@ -190,7 +217,7 @@ int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
usb_sndintpipe(line6->usbdev,
line6->ep_control_write),
(char *)frag_buf, frag_size,
- &actual_size, LINE6_TIMEOUT * HZ);
+ &partial, LINE6_TIMEOUT * HZ);
if (retval) {
dev_err(line6->ifcdev,
@@ -198,7 +225,7 @@ int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
break;
}
- done += actual_size;
+ done += frag_size;
}
return done;
@@ -234,7 +261,7 @@ static int line6_send_raw_message_async_part(struct message *msg,
(char *)msg->buffer + done, bytes,
line6_async_request_sent, msg, line6->interval);
-#if DO_DUMP_URB_SEND
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
line6_write_hexdump(line6, 'S', (char *)msg->buffer + done, bytes);
#endif
@@ -253,6 +280,17 @@ static int line6_send_raw_message_async_part(struct message *msg,
}
/*
+ Setup and start timer.
+*/
+void line6_start_timer(struct timer_list *timer, unsigned int msecs,
+ void (*function) (unsigned long), unsigned long data)
+{
+ setup_timer(timer, function, data);
+ timer->expires = jiffies + msecs * HZ / 1000;
+ add_timer(timer);
+}
+
+/*
Asynchronously send raw message.
*/
int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
@@ -289,12 +327,34 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
}
/*
+ Send asynchronous device version request.
+*/
+int line6_version_request_async(struct usb_line6 *line6)
+{
+ return line6_send_raw_message_async(line6, line6_request_version,
+ sizeof(line6_request_version0));
+}
+
+/*
Send sysex message in pieces of wMaxPacketSize bytes.
*/
int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
int size)
{
- return line6_send_raw_message(line6, buffer, size + SYSEX_EXTRA_SIZE) - SYSEX_EXTRA_SIZE;
+ return line6_send_raw_message(line6, buffer,
+ size + SYSEX_EXTRA_SIZE) -
+ SYSEX_EXTRA_SIZE;
+}
+
+/*
+ Send sysex message in pieces of wMaxPacketSize bytes.
+*/
+int line6_send_sysex_message_async(struct usb_line6 *line6, const char *buffer,
+ int size)
+{
+ return line6_send_raw_message_async(line6, buffer,
+ size + SYSEX_EXTRA_SIZE) -
+ SYSEX_EXTRA_SIZE;
}
/*
@@ -305,7 +365,7 @@ int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
int size)
{
- char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_KERNEL);
+ char *buffer = kmalloc(size + SYSEX_EXTRA_SIZE, GFP_ATOMIC);
if (!buffer) {
dev_err(line6->ifcdev, "out of memory\n");
@@ -332,29 +392,36 @@ static void line6_data_received(struct urb *urb)
if (urb->status == -ESHUTDOWN)
return;
-#if DO_DUMP_URB_RECEIVE
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
line6_dump_urb(urb);
#endif
- done = midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
+ done =
+ line6_midibuf_write(mb, urb->transfer_buffer, urb->actual_length);
if (done < urb->actual_length) {
- midibuf_ignore(mb, done);
- DEBUG_MESSAGES(dev_err(line6->ifcdev, "%d %d buffer overflow - message skipped\n", done, urb->actual_length));
+ line6_midibuf_ignore(mb, done);
+ DEBUG_MESSAGES(dev_err
+ (line6->ifcdev,
+ "%d %d buffer overflow - message skipped\n",
+ done, urb->actual_length));
}
for (;;) {
- done = midibuf_read(mb, line6->buffer_message, LINE6_MESSAGE_MAXLEN);
+ done =
+ line6_midibuf_read(mb, line6->buffer_message,
+ LINE6_MESSAGE_MAXLEN);
if (done == 0)
break;
/* MIDI input filter */
- if (midibuf_skip_message(mb, line6->line6midi->midi_mask_receive))
+ if (line6_midibuf_skip_message
+ (mb, line6->line6midi->midi_mask_receive))
continue;
line6->message_length = done;
-#if DO_DUMP_MIDI_RECEIVE
+#ifdef CONFIG_LINE6_USB_DUMP_MIDI
line6_write_hexdump(line6, 'r', line6->buffer_message, done);
#endif
line6_midi_receive(line6, line6->buffer_message, done);
@@ -366,26 +433,33 @@ static void line6_data_received(struct urb *urb)
case LINE6_DEVID_PODXT:
case LINE6_DEVID_PODXTPRO:
case LINE6_DEVID_POCKETPOD:
- pod_process_message((struct usb_line6_pod *)line6);
+ line6_pod_process_message((struct usb_line6_pod *)
+ line6);
break;
case LINE6_DEVID_PODXTLIVE:
switch (line6->interface_number) {
case PODXTLIVE_INTERFACE_POD:
- pod_process_message((struct usb_line6_pod *)line6);
+ line6_pod_process_message((struct usb_line6_pod
+ *)line6);
break;
case PODXTLIVE_INTERFACE_VARIAX:
- variax_process_message((struct usb_line6_variax *)line6);
+ line6_variax_process_message((struct
+ usb_line6_variax
+ *)line6);
break;
default:
- dev_err(line6->ifcdev, "PODxt Live interface %d not supported\n", line6->interface_number);
+ dev_err(line6->ifcdev,
+ "PODxt Live interface %d not supported\n",
+ line6->interface_number);
}
break;
case LINE6_DEVID_VARIAX:
- variax_process_message((struct usb_line6_variax *)line6);
+ line6_variax_process_message((struct usb_line6_variax *)
+ line6);
break;
default:
@@ -396,44 +470,17 @@ static void line6_data_received(struct urb *urb)
line6_start_listen(line6);
}
-static int line6_send(struct usb_line6 *line6, unsigned char *buf, size_t len)
-{
- int retval;
- int partial;
-
-#if DO_DUMP_URB_SEND
- line6_write_hexdump(line6, 'S', buf, len);
-#endif
-
- retval = usb_interrupt_msg(line6->usbdev,
- usb_sndintpipe(line6->usbdev,
- line6->ep_control_write),
- buf, len, &partial,
- LINE6_TIMEOUT * HZ);
-
- if (retval) {
- dev_err(line6->ifcdev,
- "usb_interrupt_msg failed (%d)\n", retval);
- }
-
- if (partial != len) {
- dev_err(line6->ifcdev,
- "usb_interrupt_msg sent partial message (%d)\n",
- retval);
- }
-
- return retval;
-}
-
/*
Send channel number (i.e., switch to a different sound).
*/
int line6_send_program(struct usb_line6 *line6, int value)
{
+ int retval;
unsigned char *buffer;
- size_t len = 2;
+ int partial;
+
+ buffer = kmalloc(2, GFP_KERNEL);
- buffer = kmalloc(len, GFP_KERNEL);
if (!buffer) {
dev_err(line6->ifcdev, "out of memory\n");
return -ENOMEM;
@@ -442,7 +489,21 @@ int line6_send_program(struct usb_line6 *line6, int value)
buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
buffer[1] = value;
- return line6_send(line6, buffer, len);
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
+ line6_write_hexdump(line6, 'S', buffer, 2);
+#endif
+
+ retval = usb_interrupt_msg(line6->usbdev,
+ usb_sndintpipe(line6->usbdev,
+ line6->ep_control_write),
+ buffer, 2, &partial, LINE6_TIMEOUT * HZ);
+
+ if (retval)
+ dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
+ retval);
+
+ kfree(buffer);
+ return retval;
}
/*
@@ -450,10 +511,12 @@ int line6_send_program(struct usb_line6 *line6, int value)
*/
int line6_transmit_parameter(struct usb_line6 *line6, int param, int value)
{
+ int retval;
unsigned char *buffer;
- size_t len = 3;
+ int partial;
+
+ buffer = kmalloc(3, GFP_KERNEL);
- buffer = kmalloc(len, GFP_KERNEL);
if (!buffer) {
dev_err(line6->ifcdev, "out of memory\n");
return -ENOMEM;
@@ -463,13 +526,28 @@ int line6_transmit_parameter(struct usb_line6 *line6, int param, int value)
buffer[1] = param;
buffer[2] = value;
- return line6_send(line6, buffer, len);
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
+ line6_write_hexdump(line6, 'S', buffer, 3);
+#endif
+
+ retval = usb_interrupt_msg(line6->usbdev,
+ usb_sndintpipe(line6->usbdev,
+ line6->ep_control_write),
+ buffer, 3, &partial, LINE6_TIMEOUT * HZ);
+
+ if (retval)
+ dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
+ retval);
+
+ kfree(buffer);
+ return retval;
}
/*
Read data from device.
*/
-int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen)
+int line6_read_data(struct usb_line6 *line6, int address, void *data,
+ size_t datalen)
{
struct usb_device *usbdev = line6->usbdev;
int ret;
@@ -477,10 +555,9 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t dat
/* query the serial number: */
ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
- USB_TYPE_VENDOR | USB_RECIP_DEVICE
- | USB_DIR_OUT,
- (datalen << 8) | 0x21, address,
- NULL, 0, LINE6_TIMEOUT * HZ);
+ USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
+ (datalen << 8) | 0x21, address,
+ NULL, 0, LINE6_TIMEOUT * HZ);
if (ret < 0) {
dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
@@ -558,8 +635,7 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data,
return ret;
}
}
- while (status == 0xff)
- ;
+ while (status == 0xff);
if (status != 0) {
dev_err(line6->ifcdev, "write failed (error %d)\n", ret);
@@ -575,7 +651,8 @@ int line6_write_data(struct usb_line6 *line6, int address, void *data,
*/
int line6_read_serial_number(struct usb_line6 *line6, int *serial_number)
{
- return line6_read_data(line6, 0x80d0, serial_number, sizeof(*serial_number));
+ return line6_read_data(line6, 0x80d0, serial_number,
+ sizeof(*serial_number));
}
/*
@@ -590,7 +667,7 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr,
/*
No operation (i.e., unsupported).
*/
-ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
+ssize_t line6_nop_write(struct device * dev, struct device_attribute * attr,
const char *buf, size_t count)
{
return count;
@@ -599,8 +676,8 @@ ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr,
/*
"write" request on "raw" special file.
*/
-#if CREATE_RAW_FILE
-ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
+#ifdef CONFIG_LINE6_USB_RAW
+ssize_t line6_set_raw(struct device * dev, struct device_attribute * attr,
const char *buf, size_t count)
{
struct usb_interface *interface = to_usb_interface(dev);
@@ -637,25 +714,11 @@ static void line6_destruct(struct usb_interface *interface)
kfree(line6);
}
-static void line6_list_devices(void)
-{
- int i;
-
- for (i = 0; i < LINE6_MAX_DEVICES; ++i) {
- struct usb_line6 *dev = line6_devices[i];
- printk(KERN_INFO "Line6 device %d: ", i);
-
- if (dev == NULL)
- printk("(not used)\n");
- else
- printk("%s:%d\n", dev->properties->name, dev->interface_number);
- }
-}
-
/*
Probe USB device.
*/
-static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id)
+static int line6_probe(struct usb_interface *interface,
+ const struct usb_device_id *id)
{
int devtype;
struct usb_device *usbdev = NULL;
@@ -674,10 +737,6 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
if (usbdev == NULL)
return -ENODEV;
- /* increment reference counters: */
- usb_get_intf(interface);
- usb_get_dev(usbdev);
-
/* we don't handle multiple configurations */
if (usbdev->descriptor.bNumConfigurations != 1) {
ret = -ENODEV;
@@ -689,8 +748,8 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor);
u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct);
- if (idVendor == line6_id_table[devtype].idVendor
- && idProduct == line6_id_table[devtype].idProduct)
+ if (idVendor == line6_id_table[devtype].idVendor &&
+ idProduct == line6_id_table[devtype].idProduct)
break;
}
@@ -719,12 +778,23 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
switch (product) {
case LINE6_DEVID_BASSPODXTLIVE:
- case LINE6_DEVID_POCKETPOD:
case LINE6_DEVID_PODXTLIVE:
case LINE6_DEVID_VARIAX:
alternate = 1;
break;
+ case LINE6_DEVID_POCKETPOD:
+ switch (interface_number) {
+ case 0:
+ return 0; /* this interface has no endpoints */
+ case 1:
+ alternate = 0;
+ break;
+ default:
+ MISSING_CASE;
+ }
+ break;
+
case LINE6_DEVID_PODX3:
case LINE6_DEVID_PODX3LIVE:
switch (interface_number) {
@@ -746,21 +816,27 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
alternate = 5;
break;
- case LINE6_DEVID_TONEPORT_GX:
case LINE6_DEVID_GUITARPORT:
- alternate = 2; /* 1..4 seem to be ok */
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_TONEPORT_GX:
+ case LINE6_DEVID_TONEPORT_UX1:
+ alternate = 2; /* 1..4 seem to be ok */
break;
- case LINE6_DEVID_TONEPORT_UX1:
case LINE6_DEVID_TONEPORT_UX2:
+ case LINE6_DEVID_PODSTUDIO_UX2:
switch (interface_number) {
case 0:
/* defaults to 44.1kHz, 16-bit */
alternate = 2;
break;
case 1:
- alternate = 0;
- break;
+ /* don't know yet what this is ...
+ alternate = 1;
+ break;
+ */
+ return -ENODEV;
default:
MISSING_CASE;
}
@@ -783,22 +859,30 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
case LINE6_DEVID_BASSPODXT:
case LINE6_DEVID_BASSPODXTLIVE:
case LINE6_DEVID_BASSPODXTPRO:
- case LINE6_DEVID_POCKETPOD:
case LINE6_DEVID_PODXT:
case LINE6_DEVID_PODXTPRO:
size = sizeof(struct usb_line6_pod);
- ep_read = 0x84;
+ ep_read = 0x84;
ep_write = 0x03;
break;
+ case LINE6_DEVID_POCKETPOD:
+ size = sizeof(struct usb_line6_pod);
+ ep_read = 0x82;
+ ep_write = 0x02;
+ break;
+
case LINE6_DEVID_PODX3:
case LINE6_DEVID_PODX3LIVE:
/* currently unused! */
size = sizeof(struct usb_line6_pod);
- ep_read = 0x81;
+ ep_read = 0x81;
ep_write = 0x01;
break;
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX2:
case LINE6_DEVID_TONEPORT_GX:
case LINE6_DEVID_TONEPORT_UX1:
case LINE6_DEVID_TONEPORT_UX2:
@@ -811,13 +895,13 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
switch (interface_number) {
case PODXTLIVE_INTERFACE_POD:
size = sizeof(struct usb_line6_pod);
- ep_read = 0x84;
+ ep_read = 0x84;
ep_write = 0x03;
break;
case PODXTLIVE_INTERFACE_VARIAX:
size = sizeof(struct usb_line6_variax);
- ep_read = 0x86;
+ ep_read = 0x86;
ep_write = 0x05;
break;
@@ -829,7 +913,7 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
case LINE6_DEVID_VARIAX:
size = sizeof(struct usb_line6_variax);
- ep_read = 0x82;
+ ep_read = 0x82;
ep_write = 0x01;
break;
@@ -840,7 +924,8 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
}
if (size == 0) {
- dev_err(line6->ifcdev, "driver bug: interface data size not set\n");
+ dev_err(line6->ifcdev,
+ "driver bug: interface data size not set\n");
ret = -ENODEV;
goto err_put;
}
@@ -865,16 +950,19 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
/* get data from endpoint descriptor (see usb_maxpacket): */
{
struct usb_host_endpoint *ep;
- unsigned epnum = usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read));
+ unsigned epnum =
+ usb_pipeendpoint(usb_rcvintpipe(usbdev, ep_read));
ep = usbdev->ep_in[epnum];
if (ep != NULL) {
line6->interval = ep->desc.bInterval;
- line6->max_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
+ line6->max_packet_size =
+ le16_to_cpu(ep->desc.wMaxPacketSize);
} else {
line6->interval = LINE6_FALLBACK_INTERVAL;
line6->max_packet_size = LINE6_FALLBACK_MAXPACKETSIZE;
- dev_err(line6->ifcdev, "endpoint not available, using fallback values");
+ dev_err(line6->ifcdev,
+ "endpoint not available, using fallback values");
}
}
@@ -882,7 +970,8 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
if (properties->capabilities & LINE6_BIT_CONTROL) {
/* initialize USB buffers: */
- line6->buffer_listen = kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL);
+ line6->buffer_listen =
+ kmalloc(LINE6_BUFSIZE_LISTEN, GFP_KERNEL);
if (line6->buffer_listen == NULL) {
dev_err(&interface->dev, "Out of memory\n");
@@ -890,7 +979,8 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
goto err_destruct;
}
- line6->buffer_message = kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL);
+ line6->buffer_message =
+ kmalloc(LINE6_MESSAGE_MAXLEN, GFP_KERNEL);
if (line6->buffer_message == NULL) {
dev_err(&interface->dev, "Out of memory\n");
@@ -925,17 +1015,21 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
case LINE6_DEVID_PODX3LIVE:
case LINE6_DEVID_PODXT:
case LINE6_DEVID_PODXTPRO:
- ret = pod_init(interface, (struct usb_line6_pod *)line6);
+ ret = line6_pod_init(interface, (struct usb_line6_pod *)line6);
break;
case LINE6_DEVID_PODXTLIVE:
switch (interface_number) {
case PODXTLIVE_INTERFACE_POD:
- ret = pod_init(interface, (struct usb_line6_pod *)line6);
+ ret =
+ line6_pod_init(interface,
+ (struct usb_line6_pod *)line6);
break;
case PODXTLIVE_INTERFACE_VARIAX:
- ret = variax_init(interface, (struct usb_line6_variax *)line6);
+ ret =
+ line6_variax_init(interface,
+ (struct usb_line6_variax *)line6);
break;
default:
@@ -948,14 +1042,21 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
break;
case LINE6_DEVID_VARIAX:
- ret = variax_init(interface, (struct usb_line6_variax *)line6);
+ ret =
+ line6_variax_init(interface,
+ (struct usb_line6_variax *)line6);
break;
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX2:
case LINE6_DEVID_TONEPORT_GX:
case LINE6_DEVID_TONEPORT_UX1:
case LINE6_DEVID_TONEPORT_UX2:
case LINE6_DEVID_GUITARPORT:
- ret = toneport_init(interface, (struct usb_line6_toneport *)line6);
+ ret =
+ line6_toneport_init(interface,
+ (struct usb_line6_toneport *)line6);
break;
default:
@@ -971,10 +1072,24 @@ static int line6_probe(struct usb_interface *interface, const struct usb_device_
if (ret < 0)
goto err_destruct;
+ /* creation of additional special files should go here */
+
dev_info(&interface->dev, "Line6 %s now attached\n",
line6->properties->name);
line6_devices[devnum] = line6;
- line6_list_devices();
+
+ switch (product) {
+ case LINE6_DEVID_PODX3:
+ case LINE6_DEVID_PODX3LIVE:
+ dev_info(&interface->dev,
+ "NOTE: the Line6 %s is detected, but not yet supported\n",
+ line6->properties->name);
+ }
+
+ /* increment reference counters: */
+ usb_get_intf(interface);
+ usb_get_dev(usbdev);
+
return 0;
err_destruct:
@@ -1000,6 +1115,8 @@ static void line6_disconnect(struct usb_interface *interface)
if (usbdev == NULL)
return;
+ /* removal of additional special files should go here */
+
sysfs_remove_link(&interface->dev.kobj, "usb_device");
interface_number = interface->cur_altsetting->desc.bInterfaceNumber;
@@ -1007,7 +1124,7 @@ static void line6_disconnect(struct usb_interface *interface)
if (line6 != NULL) {
if (line6->urb_listen != NULL)
- usb_kill_urb(line6->urb_listen);
+ line6_stop_listen(line6);
if (usbdev != line6->usbdev)
dev_err(line6->ifcdev,
@@ -1022,43 +1139,46 @@ static void line6_disconnect(struct usb_interface *interface)
case LINE6_DEVID_PODX3LIVE:
case LINE6_DEVID_PODXT:
case LINE6_DEVID_PODXTPRO:
- pod_disconnect(interface);
+ line6_pod_disconnect(interface);
break;
case LINE6_DEVID_PODXTLIVE:
switch (interface_number) {
case PODXTLIVE_INTERFACE_POD:
- pod_disconnect(interface);
+ line6_pod_disconnect(interface);
break;
case PODXTLIVE_INTERFACE_VARIAX:
- variax_disconnect(interface);
+ line6_variax_disconnect(interface);
break;
}
break;
case LINE6_DEVID_VARIAX:
- variax_disconnect(interface);
+ line6_variax_disconnect(interface);
break;
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX2:
case LINE6_DEVID_TONEPORT_GX:
case LINE6_DEVID_TONEPORT_UX1:
case LINE6_DEVID_TONEPORT_UX2:
case LINE6_DEVID_GUITARPORT:
- toneport_disconnect(interface);
+ line6_toneport_disconnect(interface);
break;
default:
MISSING_CASE;
}
- dev_info(&interface->dev, "Line6 %s now disconnected\n", line6->properties->name);
+ dev_info(&interface->dev, "Line6 %s now disconnected\n",
+ line6->properties->name);
- for (i = LINE6_MAX_DEVICES; i--;) {
+ for (i = LINE6_MAX_DEVICES; i--;)
if (line6_devices[i] == line6)
line6_devices[i] = NULL;
- }
}
line6_destruct(interface);
@@ -1066,14 +1186,78 @@ static void line6_disconnect(struct usb_interface *interface)
/* decrement reference counters: */
usb_put_intf(interface);
usb_put_dev(usbdev);
+}
+
+#ifdef CONFIG_PM
+
+/*
+ Suspend Line6 device.
+*/
+static int line6_suspend(struct usb_interface *interface, pm_message_t message)
+{
+ struct usb_line6 *line6 = usb_get_intfdata(interface);
+ struct snd_line6_pcm *line6pcm = line6->line6pcm;
+
+ snd_power_change_state(line6->card, SNDRV_CTL_POWER_D3hot);
+
+ if (line6->properties->capabilities & LINE6_BIT_CONTROL)
+ line6_stop_listen(line6);
+
+ if (line6pcm != NULL) {
+ snd_pcm_suspend_all(line6pcm->pcm);
+ line6_pcm_disconnect(line6pcm);
+ line6pcm->flags = 0;
+ }
- line6_list_devices();
+ return 0;
+}
+
+/*
+ Resume Line6 device.
+*/
+static int line6_resume(struct usb_interface *interface)
+{
+ struct usb_line6 *line6 = usb_get_intfdata(interface);
+
+ if (line6->properties->capabilities & LINE6_BIT_CONTROL)
+ line6_start_listen(line6);
+
+ snd_power_change_state(line6->card, SNDRV_CTL_POWER_D0);
+ return 0;
+}
+
+/*
+ Resume Line6 device after reset.
+*/
+static int line6_reset_resume(struct usb_interface *interface)
+{
+ struct usb_line6 *line6 = usb_get_intfdata(interface);
+
+ switch (line6->usbdev->descriptor.idProduct) {
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX2:
+ case LINE6_DEVID_TONEPORT_GX:
+ case LINE6_DEVID_TONEPORT_UX1:
+ case LINE6_DEVID_TONEPORT_UX2:
+ case LINE6_DEVID_GUITARPORT:
+ line6_toneport_reset_resume((struct usb_line6_toneport *)line6);
+ }
+
+ return line6_resume(interface);
}
+#endif /* CONFIG_PM */
+
static struct usb_driver line6_driver = {
.name = DRIVER_NAME,
.probe = line6_probe,
.disconnect = line6_disconnect,
+#ifdef CONFIG_PM
+ .suspend = line6_suspend,
+ .resume = line6_resume,
+ .reset_resume = line6_reset_resume,
+#endif
.id_table = line6_id_table,
};
@@ -1084,22 +1268,28 @@ static int __init line6_init(void)
{
int i, retval;
- printk(KERN_INFO "%s driver version %s%s\n",
- DRIVER_NAME, DRIVER_VERSION, DRIVER_REVISION);
- line6_workqueue = create_workqueue(DRIVER_NAME);
-
- if (line6_workqueue == NULL) {
- err("couldn't create workqueue");
- return -EINVAL;
- }
+ printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION);
for (i = LINE6_MAX_DEVICES; i--;)
line6_devices[i] = NULL;
retval = usb_register(&line6_driver);
- if (retval)
+ if (retval) {
err("usb_register failed. Error number %d", retval);
+ return retval;
+ }
+
+ line6_request_version = kmalloc(sizeof(line6_request_version0),
+ GFP_KERNEL);
+
+ if (line6_request_version == NULL) {
+ err("Out of memory");
+ return -ENOMEM;
+ }
+
+ memcpy((char *)line6_request_version, line6_request_version0,
+ sizeof(line6_request_version0));
return retval;
}
@@ -1109,8 +1299,27 @@ static int __init line6_init(void)
*/
static void __exit line6_exit(void)
{
- destroy_workqueue(line6_workqueue);
+ int i;
+ struct usb_line6 *line6;
+ struct snd_line6_pcm *line6pcm;
+
+ /* stop all PCM channels */
+ for (i = LINE6_MAX_DEVICES; i--;) {
+ line6 = line6_devices[i];
+
+ if (line6 == NULL)
+ continue;
+
+ line6pcm = line6->line6pcm;
+
+ if (line6pcm == NULL)
+ continue;
+
+ line6_pcm_stop(line6pcm, ~0);
+ }
+
usb_deregister(&line6_driver);
+ kfree(line6_request_version);
}
module_init(line6_init);
diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h
index 9908bfa6afaf..01fa27e75774 100644
--- a/drivers/staging/line6/driver.h
+++ b/drivers/staging/line6/driver.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,24 +12,23 @@
#ifndef DRIVER_H
#define DRIVER_H
-
-#include "config.h"
-
#include <linux/spinlock.h>
#include <linux/usb.h>
-#include <linux/wait.h>
#include <sound/core.h>
#include "midi.h"
#define DRIVER_NAME "line6usb"
+#if defined(CONFIG_LINE6_USB_DUMP_CTRL) || defined(CONFIG_LINE6_USB_DUMP_MIDI) || defined(CONFIG_LINE6_USB_DUMP_PCM)
+#define CONFIG_LINE6_USB_DUMP_ANY
+#endif
+
#define LINE6_TIMEOUT 1
#define LINE6_MAX_DEVICES 8
#define LINE6_BUFSIZE_LISTEN 32
#define LINE6_MESSAGE_MAXLEN 256
-
/*
Line6 MIDI control commands
*/
@@ -50,16 +49,20 @@
*/
#define LINE6_CHANNEL_DEVICE 0x02
-#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
+#define LINE6_CHANNEL_UNKNOWN 5 /* don't know yet what this is good for */
#define LINE6_CHANNEL_MASK 0x0f
+#ifdef CONFIG_LINE6_USB_DEBUG
+#define DEBUG_MESSAGES(x) (x)
+#else
+#define DEBUG_MESSAGES(x)
+#endif
#define MISSING_CASE \
printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
__FILE__, __LINE__)
-
#define CHECK_RETURN(x) \
do { \
err = x; \
@@ -67,21 +70,42 @@ do { \
return err; \
} while (0)
+#define CHECK_STARTUP_PROGRESS(x, n) \
+ if((x) >= (n)) \
+ return; \
+ x = (n);
extern const unsigned char line6_midi_id[3];
extern struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
-extern struct workqueue_struct *line6_workqueue;
static const int SYSEX_DATA_OFS = sizeof(line6_midi_id) + 3;
static const int SYSEX_EXTRA_SIZE = sizeof(line6_midi_id) + 4;
-
/**
Common properties of Line6 devices.
*/
struct line6_properties {
+ /**
+ Card id string (maximum 16 characters).
+ This can be used to address the device in ALSA programs as
+ "default:CARD=<id>"
+ */
+ const char *id;
+
+ /**
+ Card short name (maximum 32 characters).
+ */
const char *name;
+
+ /**
+ Bit identifying this device in the line6usb driver.
+ */
int device_bit;
+
+ /**
+ Bit vector defining this device's capabilities in the
+ line6usb driver.
+ */
int capabilities;
};
@@ -172,7 +196,6 @@ struct usb_line6 {
int message_length;
};
-
extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
int code2, int size);
extern ssize_t line6_nop_read(struct device *dev,
@@ -191,14 +214,22 @@ extern int line6_send_raw_message_async(struct usb_line6 *line6,
const char *buffer, int size);
extern int line6_send_sysex_message(struct usb_line6 *line6,
const char *buffer, int size);
+extern int line6_send_sysex_message_async(struct usb_line6 *line6,
+ const char *buffer, int size);
extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);
+extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
+ void (*function) (unsigned long),
+ unsigned long data);
extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
int value);
+extern int line6_version_request_async(struct usb_line6 *line6);
extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
size_t datalen);
+
+#ifdef CONFIG_LINE6_USB_DUMP_ANY
extern void line6_write_hexdump(struct usb_line6 *line6, char dir,
const unsigned char *buffer, int size);
-
+#endif
#endif
diff --git a/drivers/staging/line6/dumprequest.c b/drivers/staging/line6/dumprequest.c
index cd468c39da5c..60c7bae3ad3c 100644
--- a/drivers/staging/line6/dumprequest.c
+++ b/drivers/staging/line6/dumprequest.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,13 +9,11 @@
*
*/
-#include "driver.h"
-
#include <linux/slab.h>
+#include "driver.h"
#include "dumprequest.h"
-
/*
Set "dump in progress" flag.
*/
@@ -39,17 +37,17 @@ void line6_invalidate_current(struct line6_dump_request *l6dr)
void line6_dump_finished(struct line6_dump_request *l6dr)
{
l6dr->in_progress = LINE6_DUMP_NONE;
- wake_up_interruptible(&l6dr->wait);
+ wake_up(&l6dr->wait);
}
/*
Send an asynchronous channel dump request.
*/
int line6_dump_request_async(struct line6_dump_request *l6dr,
- struct usb_line6 *line6, int num)
+ struct usb_line6 *line6, int num, int dest)
{
int ret;
- line6_invalidate_current(l6dr);
+ line6_dump_started(l6dr, dest);
ret = line6_send_raw_message_async(line6, l6dr->reqbufs[num].buffer,
l6dr->reqbufs[num].length);
@@ -60,43 +58,30 @@ int line6_dump_request_async(struct line6_dump_request *l6dr,
}
/*
- Send an asynchronous dump request after a given interval.
+ Wait for completion (interruptible).
*/
-void line6_startup_delayed(struct line6_dump_request *l6dr, int seconds,
- void (*function)(unsigned long), void *data)
+int line6_dump_wait_interruptible(struct line6_dump_request *l6dr)
{
- l6dr->timer.expires = jiffies + seconds * HZ;
- l6dr->timer.function = function;
- l6dr->timer.data = (unsigned long)data;
- add_timer(&l6dr->timer);
+ return wait_event_interruptible(l6dr->wait,
+ l6dr->in_progress == LINE6_DUMP_NONE);
}
/*
Wait for completion.
*/
-int line6_wait_dump(struct line6_dump_request *l6dr, int nonblock)
+void line6_dump_wait(struct line6_dump_request *l6dr)
{
- int retval = 0;
- DECLARE_WAITQUEUE(wait, current);
- add_wait_queue(&l6dr->wait, &wait);
- current->state = TASK_INTERRUPTIBLE;
-
- while (l6dr->in_progress) {
- if (nonblock) {
- retval = -EAGAIN;
- break;
- }
-
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- } else
- schedule();
- }
+ wait_event(l6dr->wait, l6dr->in_progress == LINE6_DUMP_NONE);
+}
- current->state = TASK_RUNNING;
- remove_wait_queue(&l6dr->wait, &wait);
- return retval;
+/*
+ Wait for completion (with timeout).
+*/
+int line6_dump_wait_timeout(struct line6_dump_request *l6dr, long timeout)
+{
+ return wait_event_timeout(l6dr->wait,
+ l6dr->in_progress == LINE6_DUMP_NONE,
+ timeout);
}
/*
@@ -123,7 +108,6 @@ int line6_dumpreq_init(struct line6_dump_request *l6dr, const void *buf,
if (ret < 0)
return ret;
init_waitqueue_head(&l6dr->wait);
- init_timer(&l6dr->timer);
return 0;
}
@@ -148,6 +132,4 @@ void line6_dumpreq_destruct(struct line6_dump_request *l6dr)
if (l6dr->reqbufs[0].buffer == NULL)
return;
line6_dumpreq_destructbuf(l6dr, 0);
- l6dr->ok = 1;
- del_timer_sync(&l6dr->timer);
}
diff --git a/drivers/staging/line6/dumprequest.h b/drivers/staging/line6/dumprequest.h
index 1975d54b3c20..c17a262fad2e 100644
--- a/drivers/staging/line6/dumprequest.h
+++ b/drivers/staging/line6/dumprequest.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,19 +12,15 @@
#ifndef DUMPREQUEST_H
#define DUMPREQUEST_H
-
#include <linux/usb.h>
#include <linux/wait.h>
-
#include <sound/core.h>
-
enum {
LINE6_DUMP_NONE,
LINE6_DUMP_CURRENT
};
-
struct line6_dump_reqbuf {
/**
Buffer for dump requests.
@@ -56,16 +52,6 @@ struct line6_dump_request {
int in_progress;
/**
- Timer for delayed dump request.
- */
- struct timer_list timer;
-
- /**
- Flag if initial dump request has been successful.
- */
- char ok;
-
- /**
Dump request buffers
*/
struct line6_dump_reqbuf reqbufs[1];
@@ -73,7 +59,7 @@ struct line6_dump_request {
extern void line6_dump_finished(struct line6_dump_request *l6dr);
extern int line6_dump_request_async(struct line6_dump_request *l6dr,
- struct usb_line6 *line6, int num);
+ struct usb_line6 *line6, int num, int dest);
extern void line6_dump_started(struct line6_dump_request *l6dr, int dest);
extern void line6_dumpreq_destruct(struct line6_dump_request *l6dr);
extern void line6_dumpreq_destructbuf(struct line6_dump_request *l6dr, int num);
@@ -82,9 +68,9 @@ extern int line6_dumpreq_init(struct line6_dump_request *l6dr, const void *buf,
extern int line6_dumpreq_initbuf(struct line6_dump_request *l6dr,
const void *buf, size_t len, int num);
extern void line6_invalidate_current(struct line6_dump_request *l6dr);
-extern void line6_startup_delayed(struct line6_dump_request *l6dr, int seconds,
- void (*function)(unsigned long), void *data);
-extern int line6_wait_dump(struct line6_dump_request *l6dr, int nonblock);
-
+extern void line6_dump_wait(struct line6_dump_request *l6dr);
+extern int line6_dump_wait_interruptible(struct line6_dump_request *l6dr);
+extern int line6_dump_wait_timeout(struct line6_dump_request *l6dr,
+ long timeout);
#endif
diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c
index 32b6ca75cadb..fffd80503776 100644
--- a/drivers/staging/line6/midi.c
+++ b/drivers/staging/line6/midi.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,32 +9,23 @@
*
*/
-#include "driver.h"
-
-#include <linux/usb.h>
#include <linux/slab.h>
-
+#include <linux/usb.h>
#include <sound/core.h>
#include <sound/rawmidi.h>
#include "audio.h"
+#include "driver.h"
#include "midi.h"
#include "pod.h"
#include "usbdefs.h"
-
-#define USE_MIDIBUF 1
-#define OUTPUT_DUMP_ONLY 0
-
-
#define line6_rawmidi_substream_midi(substream) \
((struct snd_line6_midi *)((substream)->rmidi->private_data))
-
static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
int length);
-
/*
Pass data received via USB to MIDI.
*/
@@ -51,7 +42,8 @@ void line6_midi_receive(struct usb_line6 *line6, unsigned char *data,
*/
static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
{
- struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6;
+ struct usb_line6 *line6 =
+ line6_rawmidi_substream_midi(substream)->line6;
struct snd_line6_midi *line6midi = line6->line6midi;
struct MidiBuffer *mb = &line6midi->midibuf_out;
unsigned long flags;
@@ -61,26 +53,27 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
spin_lock_irqsave(&line6->line6midi->midi_transmit_lock, flags);
for (;;) {
- req = min(midibuf_bytes_free(mb), line6->max_packet_size);
+ req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size);
done = snd_rawmidi_transmit_peek(substream, chunk, req);
if (done == 0)
break;
-#if DO_DUMP_MIDI_SEND
+#ifdef CONFIG_LINE6_USB_DUMP_MIDI
line6_write_hexdump(line6, 's', chunk, done);
#endif
- midibuf_write(mb, chunk, done);
+ line6_midibuf_write(mb, chunk, done);
snd_rawmidi_transmit_ack(substream, done);
}
for (;;) {
- done = midibuf_read(mb, chunk, line6->max_packet_size);
+ done = line6_midibuf_read(mb, chunk, line6->max_packet_size);
if (done == 0)
break;
- if (midibuf_skip_message(mb, line6midi->midi_mask_transmit))
+ if (line6_midibuf_skip_message
+ (mb, line6midi->midi_mask_transmit))
continue;
send_midi_async(line6, chunk, done);
@@ -115,7 +108,7 @@ static void midi_sent(struct urb *urb)
}
if (num == 0)
- wake_up_interruptible(&line6->line6midi->send_wait);
+ wake_up(&line6->line6midi->send_wait);
spin_unlock_irqrestore(&line6->line6midi->send_urb_lock, flags);
}
@@ -138,8 +131,7 @@ static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
dev_err(line6->ifcdev, "Out of memory\n");
return -ENOMEM;
}
-
-#if DO_DUMP_URB_SEND
+#ifdef CONFIG_LINE6_USB_DUMP_CTRL
line6_write_hexdump(line6, 'S', data, length);
#endif
@@ -176,8 +168,11 @@ static int send_midi_async(struct usb_line6 *line6, unsigned char *data,
case LINE6_DEVID_PODXTLIVE:
case LINE6_DEVID_PODXTPRO:
case LINE6_DEVID_POCKETPOD:
- pod_midi_postprocess((struct usb_line6_pod *)line6, data,
- length);
+ line6_pod_midi_postprocess((struct usb_line6_pod *)line6, data,
+ length);
+ break;
+
+ case LINE6_DEVID_VARIAX:
break;
default:
@@ -201,7 +196,8 @@ static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream,
int up)
{
unsigned long flags;
- struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6;
+ struct usb_line6 *line6 =
+ line6_rawmidi_substream_midi(substream)->line6;
line6->line6midi->substream_transmit = substream;
spin_lock_irqsave(&line6->line6midi->send_urb_lock, flags);
@@ -214,20 +210,11 @@ static void line6_midi_output_trigger(struct snd_rawmidi_substream *substream,
static void line6_midi_output_drain(struct snd_rawmidi_substream *substream)
{
- struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6;
- wait_queue_head_t *head = &line6->line6midi->send_wait;
- DECLARE_WAITQUEUE(wait, current);
- add_wait_queue(head, &wait);
- current->state = TASK_INTERRUPTIBLE;
-
- while (line6->line6midi->num_active_send_urbs > 0)
- if (signal_pending(current))
- break;
- else
- schedule();
-
- current->state = TASK_RUNNING;
- remove_wait_queue(head, &wait);
+ struct usb_line6 *line6 =
+ line6_rawmidi_substream_midi(substream)->line6;
+ struct snd_line6_midi *midi = line6->line6midi;
+ wait_event_interruptible(midi->send_wait,
+ midi->num_active_send_urbs == 0);
}
static int line6_midi_input_open(struct snd_rawmidi_substream *substream)
@@ -243,7 +230,8 @@ static int line6_midi_input_close(struct snd_rawmidi_substream *substream)
static void line6_midi_input_trigger(struct snd_rawmidi_substream *substream,
int up)
{
- struct usb_line6 *line6 = line6_rawmidi_substream_midi(substream)->line6;
+ struct usb_line6 *line6 =
+ line6_rawmidi_substream_midi(substream)->line6;
if (up)
line6->line6midi->substream_receive = substream;
@@ -284,12 +272,12 @@ static int snd_line6_new_midi(struct snd_line6_midi *line6midi)
rmidi->private_data = line6midi;
rmidi->private_free = line6_cleanup_midi;
+ strcpy(rmidi->id, line6midi->line6->properties->id);
strcpy(rmidi->name, line6midi->line6->properties->name);
rmidi->info_flags =
- SNDRV_RAWMIDI_INFO_OUTPUT |
- SNDRV_RAWMIDI_INFO_INPUT |
- SNDRV_RAWMIDI_INFO_DUPLEX;
+ SNDRV_RAWMIDI_INFO_OUTPUT |
+ SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX;
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
&line6_midi_output_ops);
@@ -362,17 +350,21 @@ static ssize_t midi_set_midi_mask_receive(struct device *dev,
return count;
}
-static DEVICE_ATTR(midi_mask_transmit, S_IWUGO | S_IRUGO, midi_get_midi_mask_transmit, midi_set_midi_mask_transmit);
-static DEVICE_ATTR(midi_mask_receive, S_IWUGO | S_IRUGO, midi_get_midi_mask_receive, midi_set_midi_mask_receive);
+static DEVICE_ATTR(midi_mask_transmit, S_IWUGO | S_IRUGO,
+ midi_get_midi_mask_transmit, midi_set_midi_mask_transmit);
+static DEVICE_ATTR(midi_mask_receive, S_IWUGO | S_IRUGO,
+ midi_get_midi_mask_receive, midi_set_midi_mask_receive);
/* MIDI device destructor */
static int snd_line6_midi_free(struct snd_device *device)
{
struct snd_line6_midi *line6midi = device->device_data;
- device_remove_file(line6midi->line6->ifcdev, &dev_attr_midi_mask_transmit);
- device_remove_file(line6midi->line6->ifcdev, &dev_attr_midi_mask_receive);
- midibuf_destroy(&line6midi->midibuf_in);
- midibuf_destroy(&line6midi->midibuf_out);
+ device_remove_file(line6midi->line6->ifcdev,
+ &dev_attr_midi_mask_transmit);
+ device_remove_file(line6midi->line6->ifcdev,
+ &dev_attr_midi_mask_receive);
+ line6_midibuf_destroy(&line6midi->midibuf_in);
+ line6_midibuf_destroy(&line6midi->midibuf_out);
return 0;
}
@@ -389,18 +381,18 @@ int line6_init_midi(struct usb_line6 *line6)
struct snd_line6_midi *line6midi;
if (!(line6->properties->capabilities & LINE6_BIT_CONTROL))
- return 0; /* skip MIDI initialization and report success */
+ return 0; /* skip MIDI initialization and report success */
line6midi = kzalloc(sizeof(struct snd_line6_midi), GFP_KERNEL);
if (line6midi == NULL)
return -ENOMEM;
- err = midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0);
+ err = line6_midibuf_init(&line6midi->midibuf_in, MIDI_BUFFER_SIZE, 0);
if (err < 0)
return err;
- err = midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1);
+ err = line6_midibuf_init(&line6midi->midibuf_out, MIDI_BUFFER_SIZE, 1);
if (err < 0)
return err;
diff --git a/drivers/staging/line6/midi.h b/drivers/staging/line6/midi.h
index c69fd118957b..b73a025d8be9 100644
--- a/drivers/staging/line6/midi.h
+++ b/drivers/staging/line6/midi.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,15 +12,12 @@
#ifndef MIDI_H
#define MIDI_H
-
#include <sound/rawmidi.h>
#include "midibuf.h"
-
#define MIDI_BUFFER_SIZE 1024
-
struct snd_line6_midi {
/**
Pointer back to the Line6 driver data structure.
@@ -78,10 +75,8 @@ struct snd_line6_midi {
struct MidiBuffer midibuf_out;
};
-
extern int line6_init_midi(struct usb_line6 *line6);
extern void line6_midi_receive(struct usb_line6 *line6, unsigned char *data,
int length);
-
#endif
diff --git a/drivers/staging/line6/midibuf.c b/drivers/staging/line6/midibuf.c
index ab0a5f30fbca..7b532e5ce8b4 100644
--- a/drivers/staging/line6/midibuf.c
+++ b/drivers/staging/line6/midibuf.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,13 +9,10 @@
*
*/
-#include "config.h"
-
#include <linux/slab.h>
#include "midibuf.h"
-
static int midibuf_message_length(unsigned char code)
{
if (code < 0x80)
@@ -25,23 +22,34 @@ static int midibuf_message_length(unsigned char code)
return length[(code >> 4) - 8];
} else {
/*
- Note that according to the MIDI specification 0xf2 is
- the "Song Position Pointer", but this is used by Line6
- to send sysex messages to the host.
- */
+ Note that according to the MIDI specification 0xf2 is
+ the "Song Position Pointer", but this is used by Line6
+ to send sysex messages to the host.
+ */
static const int length[] = { -1, 2, -1, 2, -1, -1, 1, 1, 1, 1,
- 1, 1, 1, -1, 1, 1 };
+ 1, 1, 1, -1, 1, 1
+ };
return length[code & 0x0f];
}
}
-void midibuf_reset(struct MidiBuffer *this)
+static int midibuf_is_empty(struct MidiBuffer *this)
+{
+ return (this->pos_read == this->pos_write) && !this->full;
+}
+
+static int midibuf_is_full(struct MidiBuffer *this)
+{
+ return this->full;
+}
+
+void line6_midibuf_reset(struct MidiBuffer *this)
{
this->pos_read = this->pos_write = this->full = 0;
this->command_prev = -1;
}
-int midibuf_init(struct MidiBuffer *this, int size, int split)
+int line6_midibuf_init(struct MidiBuffer *this, int size, int split)
{
this->buf = kmalloc(size, GFP_KERNEL);
@@ -50,44 +58,37 @@ int midibuf_init(struct MidiBuffer *this, int size, int split)
this->size = size;
this->split = split;
- midibuf_reset(this);
+ line6_midibuf_reset(this);
return 0;
}
-void midibuf_status(struct MidiBuffer *this)
+void line6_midibuf_status(struct MidiBuffer *this)
{
printk(KERN_DEBUG "midibuf size=%d split=%d pos_read=%d pos_write=%d "
"full=%d command_prev=%02x\n", this->size, this->split,
this->pos_read, this->pos_write, this->full, this->command_prev);
}
-static int midibuf_is_empty(struct MidiBuffer *this)
-{
- return (this->pos_read == this->pos_write) && !this->full;
-}
-
-static int midibuf_is_full(struct MidiBuffer *this)
-{
- return this->full;
-}
-
-int midibuf_bytes_free(struct MidiBuffer *this)
+int line6_midibuf_bytes_free(struct MidiBuffer *this)
{
return
- midibuf_is_full(this) ?
- 0 :
- (this->pos_read - this->pos_write + this->size - 1) % this->size + 1;
+ midibuf_is_full(this) ?
+ 0 :
+ (this->pos_read - this->pos_write + this->size - 1) % this->size +
+ 1;
}
-int midibuf_bytes_used(struct MidiBuffer *this)
+int line6_midibuf_bytes_used(struct MidiBuffer *this)
{
return
- midibuf_is_empty(this) ?
- 0 :
- (this->pos_write - this->pos_read + this->size - 1) % this->size + 1;
+ midibuf_is_empty(this) ?
+ 0 :
+ (this->pos_write - this->pos_read + this->size - 1) % this->size +
+ 1;
}
-int midibuf_write(struct MidiBuffer *this, unsigned char *data, int length)
+int line6_midibuf_write(struct MidiBuffer *this, unsigned char *data,
+ int length)
{
int bytes_free;
int length1, length2;
@@ -102,7 +103,7 @@ int midibuf_write(struct MidiBuffer *this, unsigned char *data, int length)
skip_active_sense = 1;
}
- bytes_free = midibuf_bytes_free(this);
+ bytes_free = line6_midibuf_bytes_free(this);
if (length > bytes_free)
length = bytes_free;
@@ -129,7 +130,7 @@ int midibuf_write(struct MidiBuffer *this, unsigned char *data, int length)
return length + skip_active_sense;
}
-int midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
+int line6_midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
{
int bytes_used;
int length1, length2;
@@ -145,7 +146,7 @@ int midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
if (midibuf_is_empty(this))
return 0;
- bytes_used = midibuf_bytes_used(this);
+ bytes_used = line6_midibuf_bytes_used(this);
if (length > bytes_used)
length = bytes_used;
@@ -160,7 +161,8 @@ int midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
this->command_prev = command;
} else {
if (this->command_prev > 0) {
- int midi_length_prev = midibuf_message_length(this->command_prev);
+ int midi_length_prev =
+ midibuf_message_length(this->command_prev);
if (midi_length_prev > 0) {
midi_length = midi_length_prev - 1;
@@ -200,15 +202,15 @@ int midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
}
if (midi_length == length)
- midi_length = -1; /* end of message not found */
+ midi_length = -1; /* end of message not found */
}
if (midi_length < 0) {
if (!this->split)
- return 0; /* command is not yet complete */
+ return 0; /* command is not yet complete */
} else {
if (length < midi_length)
- return 0; /* command is not yet complete */
+ return 0; /* command is not yet complete */
length = midi_length;
}
@@ -232,9 +234,9 @@ int midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
return length + repeat;
}
-int midibuf_ignore(struct MidiBuffer *this, int length)
+int line6_midibuf_ignore(struct MidiBuffer *this, int length)
{
- int bytes_used = midibuf_bytes_used(this);
+ int bytes_used = line6_midibuf_bytes_used(this);
if (length > bytes_used)
length = bytes_used;
@@ -244,7 +246,7 @@ int midibuf_ignore(struct MidiBuffer *this, int length)
return length;
}
-int midibuf_skip_message(struct MidiBuffer *this, unsigned short mask)
+int line6_midibuf_skip_message(struct MidiBuffer *this, unsigned short mask)
{
int cmd = this->command_prev;
@@ -255,7 +257,7 @@ int midibuf_skip_message(struct MidiBuffer *this, unsigned short mask)
return 0;
}
-void midibuf_destroy(struct MidiBuffer *this)
+void line6_midibuf_destroy(struct MidiBuffer *this)
{
kfree(this->buf);
this->buf = NULL;
diff --git a/drivers/staging/line6/midibuf.h b/drivers/staging/line6/midibuf.h
index 9877581bcd9a..444cb3a12d72 100644
--- a/drivers/staging/line6/midibuf.h
+++ b/drivers/staging/line6/midibuf.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,7 +12,6 @@
#ifndef MIDIBUF_H
#define MIDIBUF_H
-
struct MidiBuffer {
unsigned char *buf;
int size;
@@ -22,18 +21,18 @@ struct MidiBuffer {
int command_prev;
};
-
-extern int midibuf_bytes_used(struct MidiBuffer *mb);
-extern int midibuf_bytes_free(struct MidiBuffer *mb);
-extern void midibuf_destroy(struct MidiBuffer *mb);
-extern int midibuf_ignore(struct MidiBuffer *mb, int length);
-extern int midibuf_init(struct MidiBuffer *mb, int size, int split);
-extern int midibuf_read(struct MidiBuffer *mb, unsigned char *data, int length);
-extern void midibuf_reset(struct MidiBuffer *mb);
-extern int midibuf_skip_message(struct MidiBuffer *mb, unsigned short mask);
-extern void midibuf_status(struct MidiBuffer *mb);
-extern int midibuf_write(struct MidiBuffer *mb, unsigned char *data,
- int length);
-
+extern int line6_midibuf_bytes_used(struct MidiBuffer *mb);
+extern int line6_midibuf_bytes_free(struct MidiBuffer *mb);
+extern void line6_midibuf_destroy(struct MidiBuffer *mb);
+extern int line6_midibuf_ignore(struct MidiBuffer *mb, int length);
+extern int line6_midibuf_init(struct MidiBuffer *mb, int size, int split);
+extern int line6_midibuf_read(struct MidiBuffer *mb, unsigned char *data,
+ int length);
+extern void line6_midibuf_reset(struct MidiBuffer *mb);
+extern int line6_midibuf_skip_message(struct MidiBuffer *mb,
+ unsigned short mask);
+extern void line6_midibuf_status(struct MidiBuffer *mb);
+extern int line6_midibuf_write(struct MidiBuffer *mb, unsigned char *data,
+ int length);
#endif
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index fbe4b083eac5..8fb5596efe9e 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,10 +9,7 @@
*
*/
-#include "driver.h"
-
#include <linux/slab.h>
-
#include <sound/core.h>
#include <sound/control.h>
#include <sound/pcm.h>
@@ -20,9 +17,184 @@
#include "audio.h"
#include "capture.h"
+#include "driver.h"
#include "playback.h"
#include "pod.h"
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+
+static struct snd_line6_pcm *dev2pcm(struct device *dev)
+{
+ struct usb_interface *interface = to_usb_interface(dev);
+ struct usb_line6 *line6 = usb_get_intfdata(interface);
+ struct snd_line6_pcm *line6pcm = line6->line6pcm;
+ return line6pcm;
+}
+
+/*
+ "read" request on "impulse_volume" special file.
+*/
+static ssize_t pcm_get_impulse_volume(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume);
+}
+
+/*
+ "write" request on "impulse_volume" special file.
+*/
+static ssize_t pcm_set_impulse_volume(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct snd_line6_pcm *line6pcm = dev2pcm(dev);
+ int value = simple_strtoul(buf, NULL, 10);
+ line6pcm->impulse_volume = value;
+
+ if (value > 0)
+ line6_pcm_start(line6pcm, MASK_PCM_IMPULSE);
+ else
+ line6_pcm_stop(line6pcm, MASK_PCM_IMPULSE);
+
+ return count;
+}
+
+/*
+ "read" request on "impulse_period" special file.
+*/
+static ssize_t pcm_get_impulse_period(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period);
+}
+
+/*
+ "write" request on "impulse_period" special file.
+*/
+static ssize_t pcm_set_impulse_period(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ dev2pcm(dev)->impulse_period = simple_strtoul(buf, NULL, 10);
+ return count;
+}
+
+static DEVICE_ATTR(impulse_volume, S_IWUGO | S_IRUGO, pcm_get_impulse_volume,
+ pcm_set_impulse_volume);
+static DEVICE_ATTR(impulse_period, S_IWUGO | S_IRUGO, pcm_get_impulse_period,
+ pcm_set_impulse_period);
+
+#endif
+
+int line6_pcm_start(struct snd_line6_pcm *line6pcm, int channels)
+{
+ unsigned long flags_old =
+ __sync_fetch_and_or(&line6pcm->flags, channels);
+ unsigned long flags_new = flags_old | channels;
+ int err = 0;
+
+#if LINE6_BACKUP_MONITOR_SIGNAL
+ if (!(line6pcm->line6->properties->capabilities & LINE6_BIT_HWMON)) {
+ line6pcm->prev_fbuf =
+ kmalloc(LINE6_ISO_PACKETS * line6pcm->max_packet_size,
+ GFP_KERNEL);
+
+ if (!line6pcm->prev_fbuf) {
+ dev_err(line6pcm->line6->ifcdev,
+ "cannot malloc monitor buffer\n");
+ return -ENOMEM;
+ }
+ }
+#else
+ line6pcm->prev_fbuf = NULL;
+#endif
+
+ if (((flags_old & MASK_CAPTURE) == 0) &&
+ ((flags_new & MASK_CAPTURE) != 0)) {
+ /*
+ Waiting for completion of active URBs in the stop handler is
+ a bug, we therefore report an error if capturing is restarted
+ too soon.
+ */
+ if (line6pcm->active_urb_in | line6pcm->unlink_urb_in)
+ return -EBUSY;
+
+ line6pcm->buffer_in =
+ kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
+ line6pcm->max_packet_size, GFP_KERNEL);
+
+ if (!line6pcm->buffer_in) {
+ dev_err(line6pcm->line6->ifcdev,
+ "cannot malloc capture buffer\n");
+ return -ENOMEM;
+ }
+
+ line6pcm->count_in = 0;
+ line6pcm->prev_fsize = 0;
+ err = line6_submit_audio_in_all_urbs(line6pcm);
+
+ if (err < 0) {
+ __sync_fetch_and_and(&line6pcm->flags, ~channels);
+ return err;
+ }
+ }
+
+ if (((flags_old & MASK_PLAYBACK) == 0) &&
+ ((flags_new & MASK_PLAYBACK) != 0)) {
+ /*
+ See comment above regarding PCM restart.
+ */
+ if (line6pcm->active_urb_out | line6pcm->unlink_urb_out)
+ return -EBUSY;
+
+ line6pcm->buffer_out =
+ kmalloc(LINE6_ISO_BUFFERS * LINE6_ISO_PACKETS *
+ line6pcm->max_packet_size, GFP_KERNEL);
+
+ if (!line6pcm->buffer_out) {
+ dev_err(line6pcm->line6->ifcdev,
+ "cannot malloc playback buffer\n");
+ return -ENOMEM;
+ }
+
+ line6pcm->count_out = 0;
+ err = line6_submit_audio_out_all_urbs(line6pcm);
+
+ if (err < 0) {
+ __sync_fetch_and_and(&line6pcm->flags, ~channels);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+int line6_pcm_stop(struct snd_line6_pcm *line6pcm, int channels)
+{
+ unsigned long flags_old =
+ __sync_fetch_and_and(&line6pcm->flags, ~channels);
+ unsigned long flags_new = flags_old & ~channels;
+
+ if (((flags_old & MASK_CAPTURE) != 0) &&
+ ((flags_new & MASK_CAPTURE) == 0)) {
+ line6_unlink_audio_in_urbs(line6pcm);
+ kfree(line6pcm->buffer_in);
+ line6pcm->buffer_in = NULL;
+ }
+
+ if (((flags_old & MASK_PLAYBACK) != 0) &&
+ ((flags_new & MASK_PLAYBACK) == 0)) {
+ line6_unlink_audio_out_urbs(line6pcm);
+ kfree(line6pcm->buffer_out);
+ line6pcm->buffer_out = NULL;
+ }
+#if LINE6_BACKUP_MONITOR_SIGNAL
+ if (line6pcm->prev_fbuf != NULL)
+ kfree(line6pcm->prev_fbuf);
+#endif
+
+ return 0;
+}
/* trigger callback */
int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -38,7 +210,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
snd_pcm_group_for_each_entry(s, substream) {
switch (s->stream) {
case SNDRV_PCM_STREAM_PLAYBACK:
- err = snd_line6_playback_trigger(s, cmd);
+ err = snd_line6_playback_trigger(line6pcm, cmd);
if (err < 0) {
spin_unlock_irqrestore(&line6pcm->lock_trigger,
@@ -49,7 +221,7 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
break;
case SNDRV_PCM_STREAM_CAPTURE:
- err = snd_line6_capture_trigger(s, cmd);
+ err = snd_line6_capture_trigger(line6pcm, cmd);
if (err < 0) {
spin_unlock_irqrestore(&line6pcm->lock_trigger,
@@ -60,8 +232,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
break;
default:
- dev_err(s2m(substream), "Unknown stream direction %d\n",
- s->stream);
+ dev_err(line6pcm->line6->ifcdev,
+ "Unknown stream direction %d\n", s->stream);
}
}
@@ -70,8 +242,8 @@ int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd)
}
/* control info callback */
-static int snd_line6_control_info(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_info *uinfo)
+static int snd_line6_control_playback_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
@@ -81,28 +253,30 @@ static int snd_line6_control_info(struct snd_kcontrol *kcontrol,
}
/* control get callback */
-static int snd_line6_control_get(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
+static int snd_line6_control_playback_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
int i;
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
for (i = 2; i--;)
- ucontrol->value.integer.value[i] = line6pcm->volume[i];
+ ucontrol->value.integer.value[i] = line6pcm->volume_playback[i];
return 0;
}
/* control put callback */
-static int snd_line6_control_put(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
+static int snd_line6_control_playback_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
{
int i, changed = 0;
struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
for (i = 2; i--;)
- if (line6pcm->volume[i] != ucontrol->value.integer.value[i]) {
- line6pcm->volume[i] = ucontrol->value.integer.value[i];
+ if (line6pcm->volume_playback[i] !=
+ ucontrol->value.integer.value[i]) {
+ line6pcm->volume_playback[i] =
+ ucontrol->value.integer.value[i];
changed = 1;
}
@@ -110,14 +284,14 @@ static int snd_line6_control_put(struct snd_kcontrol *kcontrol,
}
/* control definition */
-static struct snd_kcontrol_new line6_control = {
+static struct snd_kcontrol_new line6_control_playback = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "PCM Playback Volume",
.index = 0,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
- .info = snd_line6_control_info,
- .get = snd_line6_control_get,
- .put = snd_line6_control_put
+ .info = snd_line6_control_playback_info,
+ .get = snd_line6_control_playback_get,
+ .put = snd_line6_control_playback_put
};
/*
@@ -128,6 +302,11 @@ static void line6_cleanup_pcm(struct snd_pcm *pcm)
int i;
struct snd_line6_pcm *line6pcm = snd_pcm_chip(pcm);
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_volume);
+ device_remove_file(line6pcm->line6->ifcdev, &dev_attr_impulse_period);
+#endif
+
for (i = LINE6_ISO_BUFFERS; i--;) {
if (line6pcm->urb_audio_out[i]) {
usb_kill_urb(line6pcm->urb_audio_out[i]);
@@ -147,8 +326,8 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
int err;
err = snd_pcm_new(line6pcm->line6->card,
- (char *)line6pcm->line6->properties->name,
- 0, 1, 1, &pcm);
+ (char *)line6pcm->line6->properties->name,
+ 0, 1, 1, &pcm);
if (err < 0)
return err;
@@ -164,8 +343,9 @@ static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
/* pre-allocation of buffers */
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
- snd_dma_continuous_data(GFP_KERNEL),
- 64 * 1024, 128 * 1024);
+ snd_dma_continuous_data
+ (GFP_KERNEL), 64 * 1024,
+ 128 * 1024);
return 0;
}
@@ -177,6 +357,29 @@ static int snd_line6_pcm_free(struct snd_device *device)
}
/*
+ Stop substream if still running.
+*/
+static void pcm_disconnect_substream(struct snd_pcm_substream *substream)
+{
+ if (substream->runtime && snd_pcm_running(substream)) {
+ snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
+ }
+}
+
+/*
+ Stop PCM stream.
+*/
+void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm)
+{
+ pcm_disconnect_substream(get_substream
+ (line6pcm, SNDRV_PCM_STREAM_CAPTURE));
+ pcm_disconnect_substream(get_substream
+ (line6pcm, SNDRV_PCM_STREAM_PLAYBACK));
+ line6_unlink_wait_clear_audio_out_urbs(line6pcm);
+ line6_unlink_wait_clear_audio_in_urbs(line6pcm);
+}
+
+/*
Create and register the PCM device and mixer entries.
Create URBs for playback and capture.
*/
@@ -192,7 +395,7 @@ int line6_init_pcm(struct usb_line6 *line6,
struct snd_line6_pcm *line6pcm;
if (!(line6->properties->capabilities & LINE6_BIT_PCM))
- return 0; /* skip PCM initialization and report success */
+ return 0; /* skip PCM initialization and report success */
/* initialize PCM subsystem based on product id: */
switch (line6->product) {
@@ -202,37 +405,40 @@ int line6_init_pcm(struct usb_line6 *line6,
case LINE6_DEVID_PODXT:
case LINE6_DEVID_PODXTLIVE:
case LINE6_DEVID_PODXTPRO:
- ep_read = 0x82;
+ ep_read = 0x82;
ep_write = 0x01;
break;
case LINE6_DEVID_PODX3:
case LINE6_DEVID_PODX3LIVE:
- ep_read = 0x86;
+ ep_read = 0x86;
ep_write = 0x02;
break;
case LINE6_DEVID_POCKETPOD:
- ep_read = 0x82;
+ ep_read = 0x82;
ep_write = 0x02;
break;
case LINE6_DEVID_GUITARPORT:
+ case LINE6_DEVID_PODSTUDIO_GX:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX2:
case LINE6_DEVID_TONEPORT_GX:
- ep_read = 0x82;
- ep_write = 0x01;
- break;
-
case LINE6_DEVID_TONEPORT_UX1:
- ep_read = 0x00;
- ep_write = 0x00;
- break;
-
case LINE6_DEVID_TONEPORT_UX2:
- ep_read = 0x87;
- ep_write = 0x00;
+ ep_read = 0x82;
+ ep_write = 0x01;
break;
+ /* this is for interface_number == 1:
+ case LINE6_DEVID_TONEPORT_UX2:
+ case LINE6_DEVID_PODSTUDIO_UX2:
+ ep_read = 0x87;
+ ep_write = 0x00;
+ break;
+ */
+
default:
MISSING_CASE;
}
@@ -242,14 +448,14 @@ int line6_init_pcm(struct usb_line6 *line6,
if (line6pcm == NULL)
return -ENOMEM;
- line6pcm->volume[0] = line6pcm->volume[1] = 128;
+ line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255;
+ line6pcm->volume_monitor = 255;
line6pcm->line6 = line6;
line6pcm->ep_audio_read = ep_read;
line6pcm->ep_audio_write = ep_write;
line6pcm->max_packet_size = usb_maxpacket(line6->usbdev,
- usb_rcvintpipe(line6->usbdev,
- ep_read),
- 0);
+ usb_rcvintpipe(line6->usbdev,
+ ep_read), 0);
line6pcm->properties = properties;
line6->line6pcm = line6pcm;
@@ -268,19 +474,34 @@ int line6_init_pcm(struct usb_line6 *line6,
spin_lock_init(&line6pcm->lock_audio_in);
spin_lock_init(&line6pcm->lock_trigger);
- err = create_audio_out_urbs(line6pcm);
+ err = line6_create_audio_out_urbs(line6pcm);
if (err < 0)
return err;
- err = create_audio_in_urbs(line6pcm);
+ err = line6_create_audio_in_urbs(line6pcm);
if (err < 0)
return err;
/* mixer: */
- err = snd_ctl_add(line6->card, snd_ctl_new1(&line6_control, line6pcm));
+ err =
+ snd_ctl_add(line6->card,
+ snd_ctl_new1(&line6_control_playback, line6pcm));
+ if (err < 0)
+ return err;
+
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ /* impulse response test: */
+ err = device_create_file(line6->ifcdev, &dev_attr_impulse_volume);
if (err < 0)
return err;
+ err = device_create_file(line6->ifcdev, &dev_attr_impulse_period);
+ if (err < 0)
+ return err;
+
+ line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;
+#endif
+
return 0;
}
@@ -290,12 +511,11 @@ int snd_line6_prepare(struct snd_pcm_substream *substream)
struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
if (!test_and_set_bit(BIT_PREPARED, &line6pcm->flags)) {
- unlink_wait_clear_audio_out_urbs(line6pcm);
+ line6pcm->count_out = 0;
line6pcm->pos_out = 0;
line6pcm->pos_out_done = 0;
-
- unlink_wait_clear_audio_in_urbs(line6pcm);
line6pcm->bytes_out = 0;
+ line6pcm->count_in = 0;
line6pcm->pos_in_done = 0;
line6pcm->bytes_in = 0;
}
diff --git a/drivers/staging/line6/pcm.h b/drivers/staging/line6/pcm.h
index 53db217cd42d..3a50083cb30c 100644
--- a/drivers/staging/line6/pcm.h
+++ b/drivers/staging/line6/pcm.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -16,38 +16,89 @@
#ifndef PCM_H
#define PCM_H
-
#include <sound/pcm.h>
#include "driver.h"
#include "usbdefs.h"
-
/* number of URBs */
-#define LINE6_ISO_BUFFERS 8
+#define LINE6_ISO_BUFFERS 2
-/* number of USB frames per URB */
-#define LINE6_ISO_PACKETS 2
+/*
+ number of USB frames per URB
+ The Line6 Windows driver always transmits two frames per packet, but
+ the Linux driver performs significantly better (i.e., lower latency)
+ with only one frame per packet.
+*/
+#define LINE6_ISO_PACKETS 1
/* in a "full speed" device (such as the PODxt Pro) this means 1ms */
#define LINE6_ISO_INTERVAL 1
-/* this should be queried dynamically from the USB interface! */
-#define LINE6_ISO_PACKET_SIZE_MAX 252
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+#define LINE6_IMPULSE_DEFAULT_PERIOD 100
+#endif
+#define LINE6_BACKUP_MONITOR_SIGNAL 0
+#define LINE6_REUSE_DMA_AREA_FOR_PLAYBACK 0
/*
- Extract the messaging device from the substream instance
+ Get substream from Line6 PCM data structure
*/
-#define s2m(s) (((struct snd_line6_pcm *) \
- snd_pcm_substream_chip(s))->line6->ifcdev)
-
+#define get_substream(line6pcm, stream) (line6pcm->pcm->streams[stream].substream)
+/*
+ PCM mode bits and masks.
+ "ALSA": operations triggered by applications via ALSA
+ "MONITOR": software monitoring
+ "IMPULSE": optional impulse response operation
+*/
enum {
- BIT_RUNNING_PLAYBACK,
- BIT_RUNNING_CAPTURE,
+ /* individual bits: */
+ BIT_PCM_ALSA_PLAYBACK,
+ BIT_PCM_ALSA_CAPTURE,
+ BIT_PCM_MONITOR_PLAYBACK,
+ BIT_PCM_MONITOR_CAPTURE,
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ BIT_PCM_IMPULSE_PLAYBACK,
+ BIT_PCM_IMPULSE_CAPTURE,
+#endif
BIT_PAUSE_PLAYBACK,
- BIT_PREPARED
+ BIT_PREPARED,
+
+ /* individual masks: */
+/* *INDENT-OFF* */
+ MASK_PCM_ALSA_PLAYBACK = 1 << BIT_PCM_ALSA_PLAYBACK,
+ MASK_PCM_ALSA_CAPTURE = 1 << BIT_PCM_ALSA_CAPTURE,
+ MASK_PCM_MONITOR_PLAYBACK = 1 << BIT_PCM_MONITOR_PLAYBACK,
+ MASK_PCM_MONITOR_CAPTURE = 1 << BIT_PCM_MONITOR_CAPTURE,
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ MASK_PCM_IMPULSE_PLAYBACK = 1 << BIT_PCM_IMPULSE_PLAYBACK,
+ MASK_PCM_IMPULSE_CAPTURE = 1 << BIT_PCM_IMPULSE_CAPTURE,
+#endif
+ MASK_PAUSE_PLAYBACK = 1 << BIT_PAUSE_PLAYBACK,
+ MASK_PREPARED = 1 << BIT_PREPARED,
+/* *INDENT-ON* */
+
+ /* combined masks (by operation): */
+ MASK_PCM_ALSA = MASK_PCM_ALSA_PLAYBACK | MASK_PCM_ALSA_CAPTURE,
+ MASK_PCM_MONITOR = MASK_PCM_MONITOR_PLAYBACK | MASK_PCM_MONITOR_CAPTURE,
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ MASK_PCM_IMPULSE = MASK_PCM_IMPULSE_PLAYBACK | MASK_PCM_IMPULSE_CAPTURE,
+#endif
+
+ /* combined masks (by direction): */
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ MASK_PLAYBACK =
+ MASK_PCM_ALSA_PLAYBACK | MASK_PCM_MONITOR_PLAYBACK |
+ MASK_PCM_IMPULSE_PLAYBACK,
+ MASK_CAPTURE =
+ MASK_PCM_ALSA_CAPTURE | MASK_PCM_MONITOR_CAPTURE |
+ MASK_PCM_IMPULSE_CAPTURE
+#else
+ MASK_PLAYBACK = MASK_PCM_ALSA_PLAYBACK | MASK_PCM_MONITOR_PLAYBACK,
+ MASK_CAPTURE = MASK_PCM_ALSA_CAPTURE | MASK_PCM_MONITOR_CAPTURE
+#endif
};
struct line6_pcm_properties {
@@ -83,9 +134,11 @@ struct snd_line6_pcm {
struct urb *urb_audio_in[LINE6_ISO_BUFFERS];
/**
- Temporary buffer to hold data when playback buffer wraps.
+ Temporary buffer for playback.
+ Since the packet size is not known in advance, this buffer is
+ large enough to store maximum size packets.
*/
- unsigned char *wrap_out;
+ unsigned char *buffer_out;
/**
Temporary buffer for capture.
@@ -95,6 +148,21 @@ struct snd_line6_pcm {
unsigned char *buffer_in;
/**
+ Temporary buffer index for playback.
+ */
+ int index_out;
+
+ /**
+ Previously captured frame (for software monitoring).
+ */
+ unsigned char *prev_fbuf;
+
+ /**
+ Size of previously captured frame (for software monitoring).
+ */
+ int prev_fsize;
+
+ /**
Free frame position in the playback buffer.
*/
snd_pcm_uframes_t pos_out;
@@ -204,19 +272,53 @@ struct snd_line6_pcm {
/**
PCM playback volume (left and right).
*/
- int volume[2];
+ int volume_playback[2];
+
+ /**
+ PCM monitor volume.
+ */
+ int volume_monitor;
+
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ /**
+ Volume of impulse response test signal (if zero, test is disabled).
+ */
+ int impulse_volume;
+
+ /**
+ Period of impulse response test signal.
+ */
+ int impulse_period;
+
+ /**
+ Counter for impulse response test signal.
+ */
+ int impulse_count;
+#endif
/**
Several status bits (see BIT_*).
*/
unsigned long flags;
-};
+ int last_frame_in, last_frame_out;
+};
extern int line6_init_pcm(struct usb_line6 *line6,
struct line6_pcm_properties *properties);
extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd);
extern int snd_line6_prepare(struct snd_pcm_substream *substream);
-
+extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm);
+extern int line6_pcm_start(struct snd_line6_pcm *line6pcm, int channels);
+extern int line6_pcm_stop(struct snd_line6_pcm *line6pcm, int channels);
+
+#define PRINT_FRAME_DIFF(op) { \
+ static int diff_prev = 1000; \
+ int diff = line6pcm->last_frame_out - line6pcm->last_frame_in; \
+ if((diff != diff_prev) && (abs(diff) < 100)) { \
+ printk("%s frame diff = %d\n", op, diff); \
+ diff_prev = diff; \
+ } \
+ }
#endif
diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c
index fbcd6e150aaf..39218d686aa2 100644
--- a/drivers/staging/line6/playback.c
+++ b/drivers/staging/line6/playback.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,15 +9,13 @@
*
*/
-#include "driver.h"
-
-#include <linux/slab.h>
-
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include "audio.h"
+#include "capture.h"
+#include "driver.h"
#include "pcm.h"
#include "pod.h"
#include "playback.h"
@@ -59,22 +57,93 @@ static void change_volume(struct urb *urb_out, int volume[],
}
}
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+
+/*
+ Create signal for impulse response test.
+*/
+static void create_impulse_test_signal(struct snd_line6_pcm *line6pcm,
+ struct urb *urb_out, int bytes_per_frame)
+{
+ int frames = urb_out->transfer_buffer_length / bytes_per_frame;
+
+ if (bytes_per_frame == 4) {
+ int i;
+ short *pi = (short *)line6pcm->prev_fbuf;
+ short *po = (short *)urb_out->transfer_buffer;
+
+ for (i = 0; i < frames; ++i) {
+ po[0] = pi[0];
+ po[1] = 0;
+ pi += 2;
+ po += 2;
+ }
+ } else if (bytes_per_frame == 6) {
+ int i, j;
+ unsigned char *pi = line6pcm->prev_fbuf;
+ unsigned char *po = urb_out->transfer_buffer;
+
+ for (i = 0; i < frames; ++i) {
+ for (j = 0; j < bytes_per_frame / 2; ++j)
+ po[j] = pi[j];
+
+ for (; j < bytes_per_frame; ++j)
+ po[j] = 0;
+
+ pi += bytes_per_frame;
+ po += bytes_per_frame;
+ }
+ }
+ if (--line6pcm->impulse_count <= 0) {
+ ((unsigned char *)(urb_out->transfer_buffer))[bytes_per_frame -
+ 1] =
+ line6pcm->impulse_volume;
+ line6pcm->impulse_count = line6pcm->impulse_period;
+ }
+}
+
+#endif
+
+/*
+ Add signal to buffer for software monitoring.
+*/
+static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,
+ int volume, int bytes_per_frame)
+{
+ if (volume == 0)
+ return; /* zero volume - no change */
+
+ if (bytes_per_frame == 4) {
+ short *pi, *po, *buf_end;
+ pi = (short *)signal;
+ po = (short *)urb_out->transfer_buffer;
+ buf_end = po + urb_out->transfer_buffer_length / sizeof(*po);
+
+ for (; po < buf_end; ++pi, ++po)
+ *po += (*pi * volume) >> 8;
+ }
+
+ /*
+ We don't need to handle devices with 6 bytes per frame here
+ since they all support hardware monitoring.
+ */
+}
+
/*
Find a free URB, prepare audio data, and submit URB.
*/
-static int submit_audio_out_urb(struct snd_pcm_substream *substream)
+static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
{
int index;
unsigned long flags;
int i, urb_size, urb_frames;
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
+ int ret;
const int bytes_per_frame = line6pcm->properties->bytes_per_frame;
const int frame_increment =
line6pcm->properties->snd_line6_rates.rats[0].num_min;
const int frame_factor =
line6pcm->properties->snd_line6_rates.rats[0].den *
(USB_INTERVALS_PER_SECOND / LINE6_ISO_INTERVAL);
- struct snd_pcm_runtime *runtime = substream->runtime;
struct urb *urb_out;
spin_lock_irqsave(&line6pcm->lock_audio_out, flags);
@@ -83,7 +152,7 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream)
if (index < 0 || index >= LINE6_ISO_BUFFERS) {
spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags);
- dev_err(s2m(substream), "no free URB found\n");
+ dev_err(line6pcm->line6->ifcdev, "no free URB found\n");
return -EINVAL;
}
@@ -92,24 +161,49 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream)
for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
/* compute frame size for given sampling rate */
- int n, fs;
+ int fsize = 0;
struct usb_iso_packet_descriptor *fout =
&urb_out->iso_frame_desc[i];
- line6pcm->count_out += frame_increment;
- n = line6pcm->count_out / frame_factor;
- line6pcm->count_out -= n * frame_factor;
- fs = n * bytes_per_frame;
+
+ if (line6pcm->flags & MASK_CAPTURE) {
+ fsize = line6pcm->prev_fsize;
+ }
+
+ if (fsize == 0) {
+ int n;
+ line6pcm->count_out += frame_increment;
+ n = line6pcm->count_out / frame_factor;
+ line6pcm->count_out -= n * frame_factor;
+ fsize = n * bytes_per_frame;
+ }
+
fout->offset = urb_size;
- fout->length = fs;
- urb_size += fs;
+ fout->length = fsize;
+ urb_size += fsize;
+ }
+
+ if (urb_size == 0) {
+ /* can't determine URB size */
+ spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags);
+ dev_err(line6pcm->line6->ifcdev, "driver bug: urb_size = 0\n"); /* this is somewhat paranoid */
+ return -EINVAL;
}
urb_frames = urb_size / bytes_per_frame;
+ urb_out->transfer_buffer =
+ line6pcm->buffer_out +
+ line6pcm->max_packet_size * line6pcm->index_out;
+ urb_out->transfer_buffer_length = urb_size;
+ urb_out->context = line6pcm;
+
+ if (++line6pcm->index_out == LINE6_ISO_BUFFERS)
+ line6pcm->index_out = 0;
+
+ if (test_bit(BIT_PCM_ALSA_PLAYBACK, &line6pcm->flags) &&
+ !test_bit(BIT_PAUSE_PLAYBACK, &line6pcm->flags)) {
+ struct snd_pcm_runtime *runtime =
+ get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK)->runtime;
- if (test_bit(BIT_PAUSE_PLAYBACK, &line6pcm->flags)) {
- urb_out->transfer_buffer = line6pcm->wrap_out;
- memset(line6pcm->wrap_out, 0, urb_size);
- } else {
if (line6pcm->pos_out + urb_frames > runtime->buffer_size) {
/*
The transferred area goes over buffer boundary,
@@ -117,38 +211,69 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream)
*/
int len;
len = runtime->buffer_size - line6pcm->pos_out;
- urb_out->transfer_buffer = line6pcm->wrap_out;
if (len > 0) {
- memcpy(line6pcm->wrap_out,
+ memcpy(urb_out->transfer_buffer,
runtime->dma_area +
line6pcm->pos_out * bytes_per_frame,
len * bytes_per_frame);
- memcpy(line6pcm->wrap_out +
+ memcpy(urb_out->transfer_buffer +
len * bytes_per_frame, runtime->dma_area,
(urb_frames - len) * bytes_per_frame);
- } else {
- /* this is somewhat paranoid */
- dev_err(s2m(substream),
- "driver bug: len = %d\n", len);
- }
+ } else
+ dev_err(line6pcm->line6->ifcdev, "driver bug: len = %d\n", len); /* this is somewhat paranoid */
} else {
+#if LINE6_REUSE_DMA_AREA_FOR_PLAYBACK
/* set the buffer pointer */
urb_out->transfer_buffer =
runtime->dma_area +
line6pcm->pos_out * bytes_per_frame;
+#else
+ /* copy data */
+ memcpy(urb_out->transfer_buffer,
+ runtime->dma_area +
+ line6pcm->pos_out * bytes_per_frame,
+ urb_out->transfer_buffer_length);
+#endif
}
- }
- line6pcm->pos_out += urb_frames;
- if (line6pcm->pos_out >= runtime->buffer_size)
- line6pcm->pos_out -= runtime->buffer_size;
-
- urb_out->transfer_buffer_length = urb_size;
- urb_out->context = substream;
- change_volume(urb_out, line6pcm->volume, bytes_per_frame);
+ if ((line6pcm->pos_out += urb_frames) >= runtime->buffer_size)
+ line6pcm->pos_out -= runtime->buffer_size;
+ } else {
+ memset(urb_out->transfer_buffer, 0,
+ urb_out->transfer_buffer_length);
+ }
-#if DO_DUMP_PCM_SEND
+ change_volume(urb_out, line6pcm->volume_playback, bytes_per_frame);
+
+ if (line6pcm->prev_fbuf != 0) {
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ if (line6pcm->flags & MASK_PCM_IMPULSE) {
+ create_impulse_test_signal(line6pcm, urb_out,
+ bytes_per_frame);
+ if (line6pcm->flags & MASK_PCM_ALSA_CAPTURE) {
+ line6_capture_copy(line6pcm,
+ urb_out->transfer_buffer,
+ urb_out->
+ transfer_buffer_length);
+ line6_capture_check_period(line6pcm,
+ urb_out->transfer_buffer_length);
+ }
+ } else {
+#endif
+ if (!
+ (line6pcm->line6->
+ properties->capabilities & LINE6_BIT_HWMON)
+&& (line6pcm->flags & MASK_PLAYBACK)
+&& (line6pcm->flags & MASK_CAPTURE))
+ add_monitor_signal(urb_out, line6pcm->prev_fbuf,
+ line6pcm->volume_monitor,
+ bytes_per_frame);
+#ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
+ }
+#endif
+ }
+#ifdef CONFIG_LINE6_USB_DUMP_PCM
for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
struct usb_iso_packet_descriptor *fout =
&urb_out->iso_frame_desc[i];
@@ -158,11 +283,13 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream)
}
#endif
- if (usb_submit_urb(urb_out, GFP_ATOMIC) == 0)
+ ret = usb_submit_urb(urb_out, GFP_ATOMIC);
+
+ if (ret == 0)
set_bit(index, &line6pcm->active_urb_out);
else
- dev_err(s2m(substream), "URB out #%d submission failed\n",
- index);
+ dev_err(line6pcm->line6->ifcdev,
+ "URB out #%d submission failed (%d)\n", index, ret);
spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags);
return 0;
@@ -171,12 +298,12 @@ static int submit_audio_out_urb(struct snd_pcm_substream *substream)
/*
Submit all currently available playback URBs.
*/
-static int submit_audio_out_all_urbs(struct snd_pcm_substream *substream)
+int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm)
{
int ret, i;
for (i = 0; i < LINE6_ISO_BUFFERS; ++i) {
- ret = submit_audio_out_urb(substream);
+ ret = submit_audio_out_urb(line6pcm);
if (ret < 0)
return ret;
}
@@ -187,7 +314,7 @@ static int submit_audio_out_all_urbs(struct snd_pcm_substream *substream)
/*
Unlink all currently active playback URBs.
*/
-static void unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm)
+void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm)
{
unsigned int i;
@@ -202,7 +329,7 @@ static void unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm)
}
/*
- Wait until unlinking of all currently active playback URBs has been finished.
+ Wait until unlinking of all currently active playback URBs has been finished.
*/
static void wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm)
{
@@ -223,17 +350,14 @@ static void wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm)
} while (--timeout > 0);
if (alive)
snd_printk(KERN_ERR "timeout: still %d active urbs..\n", alive);
-
- line6pcm->active_urb_out = 0;
- line6pcm->unlink_urb_out = 0;
}
/*
Unlink all currently active playback URBs, and wait for finishing.
*/
-void unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm)
+void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm)
{
- unlink_audio_out_urbs(line6pcm);
+ line6_unlink_audio_out_urbs(line6pcm);
wait_clear_audio_out_urbs(line6pcm);
}
@@ -245,10 +369,15 @@ static void audio_out_callback(struct urb *urb)
int i, index, length = 0, shutdown = 0;
unsigned long flags;
+ struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
struct snd_pcm_substream *substream =
- (struct snd_pcm_substream *)urb->context;
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
- struct snd_pcm_runtime *runtime = substream->runtime;
+ get_substream(line6pcm, SNDRV_PCM_STREAM_PLAYBACK);
+
+#if USE_CLEAR_BUFFER_WORKAROUND
+ memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
+#endif
+
+ line6pcm->last_frame_out = urb->start_frame;
/* find index of URB */
for (index = LINE6_ISO_BUFFERS; index--;)
@@ -262,32 +391,38 @@ static void audio_out_callback(struct urb *urb)
length += urb->iso_frame_desc[i].length;
spin_lock_irqsave(&line6pcm->lock_audio_out, flags);
- line6pcm->pos_out_done +=
- length / line6pcm->properties->bytes_per_frame;
- if (line6pcm->pos_out_done >= runtime->buffer_size)
- line6pcm->pos_out_done -= runtime->buffer_size;
+ if (test_bit(BIT_PCM_ALSA_PLAYBACK, &line6pcm->flags)) {
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ line6pcm->pos_out_done +=
+ length / line6pcm->properties->bytes_per_frame;
+
+ if (line6pcm->pos_out_done >= runtime->buffer_size)
+ line6pcm->pos_out_done -= runtime->buffer_size;
+ }
clear_bit(index, &line6pcm->active_urb_out);
for (i = LINE6_ISO_PACKETS; i--;)
- if (urb->iso_frame_desc[i].status == -ESHUTDOWN) {
+ if (urb->iso_frame_desc[i].status == -EXDEV) {
shutdown = 1;
break;
}
- if (test_bit(index, &line6pcm->unlink_urb_out))
+ if (test_and_clear_bit(index, &line6pcm->unlink_urb_out))
shutdown = 1;
spin_unlock_irqrestore(&line6pcm->lock_audio_out, flags);
if (!shutdown) {
- submit_audio_out_urb(substream);
+ submit_audio_out_urb(line6pcm);
- line6pcm->bytes_out += length;
- if (line6pcm->bytes_out >= line6pcm->period_out) {
- line6pcm->bytes_out -= line6pcm->period_out;
- snd_pcm_period_elapsed(substream);
+ if (test_bit(BIT_PCM_ALSA_PLAYBACK, &line6pcm->flags)) {
+ if ((line6pcm->bytes_out +=
+ length) >= line6pcm->period_out) {
+ line6pcm->bytes_out %= line6pcm->period_out;
+ snd_pcm_period_elapsed(substream);
+ }
}
}
}
@@ -300,8 +435,8 @@ static int snd_line6_playback_open(struct snd_pcm_substream *substream)
struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
err = snd_pcm_hw_constraint_ratdens(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
- (&line6pcm->properties->
- snd_line6_rates));
+ (&line6pcm->
+ properties->snd_line6_rates));
if (err < 0)
return err;
@@ -340,52 +475,40 @@ static int snd_line6_playback_hw_params(struct snd_pcm_substream *substream,
return ret;
line6pcm->period_out = params_period_bytes(hw_params);
- line6pcm->wrap_out = kmalloc(2 * LINE6_ISO_PACKET_SIZE_MAX, GFP_KERNEL);
-
- if (!line6pcm->wrap_out) {
- dev_err(s2m(substream), "cannot malloc wrap_out\n");
- return -ENOMEM;
- }
-
return 0;
}
/* hw_free playback callback */
static int snd_line6_playback_hw_free(struct snd_pcm_substream *substream)
{
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
- unlink_wait_clear_audio_out_urbs(line6pcm);
-
- kfree(line6pcm->wrap_out);
- line6pcm->wrap_out = NULL;
-
return snd_pcm_lib_free_pages(substream);
}
/* trigger playback callback */
-int snd_line6_playback_trigger(struct snd_pcm_substream *substream, int cmd)
+int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd)
{
- struct snd_line6_pcm *line6pcm = snd_pcm_substream_chip(substream);
int err;
- line6pcm->count_out = 0;
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
- if (!test_and_set_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags)) {
- err = submit_audio_out_all_urbs(substream);
+#ifdef CONFIG_PM
+ case SNDRV_PCM_TRIGGER_RESUME:
+#endif
+ err = line6_pcm_start(line6pcm, MASK_PCM_ALSA_PLAYBACK);
- if (err < 0) {
- clear_bit(BIT_RUNNING_PLAYBACK,
- &line6pcm->flags);
- return err;
- }
- }
+ if (err < 0)
+ return err;
break;
case SNDRV_PCM_TRIGGER_STOP:
- if (test_and_clear_bit(BIT_RUNNING_PLAYBACK, &line6pcm->flags))
- unlink_audio_out_urbs(line6pcm);
+#ifdef CONFIG_PM
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+#endif
+ err = line6_pcm_stop(line6pcm, MASK_PCM_ALSA_PLAYBACK);
+
+ if (err < 0)
+ return err;
break;
@@ -424,7 +547,7 @@ struct snd_pcm_ops snd_line6_playback_ops = {
.pointer = snd_line6_playback_pointer,
};
-int create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
+int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
{
int i;
@@ -444,8 +567,8 @@ int create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
urb->dev = line6pcm->line6->usbdev;
urb->pipe =
usb_sndisocpipe(line6pcm->line6->usbdev,
- line6pcm->
- ep_audio_write & USB_ENDPOINT_NUMBER_MASK);
+ line6pcm->ep_audio_write &
+ USB_ENDPOINT_NUMBER_MASK);
urb->transfer_flags = URB_ISO_ASAP;
urb->start_frame = -1;
urb->number_of_packets = LINE6_ISO_PACKETS;
diff --git a/drivers/staging/line6/playback.h b/drivers/staging/line6/playback.h
index db1e48b3596e..c6f2a172d6f9 100644
--- a/drivers/staging/line6/playback.h
+++ b/drivers/staging/line6/playback.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,19 +12,27 @@
#ifndef PLAYBACK_H
#define PLAYBACK_H
+#include <sound/pcm.h>
#include "driver.h"
-#include <sound/pcm.h>
-
+/*
+ When the TonePort is used with jack in full duplex mode and the outputs are
+ not connected, the software monitor produces an ugly noise since everything
+ written to the output buffer (i.e., the input signal) will be repeated in the
+ next period (sounds like a delay effect). As a workaround, the output buffer
+ is cleared after the data have been read, but there must be a better
+ solution. Until one is found, this workaround can be used to fix the problem.
+*/
+#define USE_CLEAR_BUFFER_WORKAROUND 1
extern struct snd_pcm_ops snd_line6_playback_ops;
-
-extern int create_audio_out_urbs(struct snd_line6_pcm *line6pcm);
-extern int snd_line6_playback_trigger(struct snd_pcm_substream *substream,
- int cmd);
-extern void unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm *line6pcm);
-
+extern int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm);
+extern int line6_submit_audio_out_all_urbs(struct snd_line6_pcm *line6pcm);
+extern void line6_unlink_audio_out_urbs(struct snd_line6_pcm *line6pcm);
+extern void line6_unlink_wait_clear_audio_out_urbs(struct snd_line6_pcm
+ *line6pcm);
+extern int snd_line6_playback_trigger(struct snd_line6_pcm *line6pcm, int cmd);
#endif
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c
index 28f514611abc..e6a1c79cd851 100644
--- a/drivers/staging/line6/pod.c
+++ b/drivers/staging/line6/pod.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,20 +9,21 @@
*
*/
-#include "driver.h"
-
#include <linux/slab.h>
+#include <linux/wait.h>
+#include <sound/control.h>
#include "audio.h"
#include "capture.h"
#include "control.h"
+#include "driver.h"
#include "playback.h"
#include "pod.h"
-
#define POD_SYSEX_CODE 3
-#define POD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */
+#define POD_BYTES_PER_FRAME 6 /* 24bit audio (stereo) */
+/* *INDENT-OFF* */
enum {
POD_SYSEX_CLIP = 0x0f,
@@ -45,9 +46,11 @@ enum {
POD_tuner_freq = 0x15,
POD_tuner_note = 0x16,
POD_tuner_pitch = 0x17,
- POD_system_invalid = 0x7fff
+ POD_system_invalid = 0x10000
};
+/* *INDENT-ON* */
+
enum {
POD_DUMP_MEMORY = 2
};
@@ -60,7 +63,6 @@ enum {
POD_BUSY_MIDISEND
};
-
static struct snd_ratden pod_ratden = {
.num_min = 78125,
.num_max = 78125,
@@ -69,54 +71,65 @@ static struct snd_ratden pod_ratden = {
};
static struct line6_pcm_properties pod_pcm_properties = {
- .snd_line6_playback_hw = {
- .info = (SNDRV_PCM_INFO_MMAP |
- SNDRV_PCM_INFO_INTERLEAVED |
- SNDRV_PCM_INFO_BLOCK_TRANSFER |
- SNDRV_PCM_INFO_MMAP_VALID |
- SNDRV_PCM_INFO_PAUSE |
- SNDRV_PCM_INFO_SYNC_START),
- .formats = SNDRV_PCM_FMTBIT_S24_3LE,
- .rates = SNDRV_PCM_RATE_KNOT,
- .rate_min = 39062,
- .rate_max = 39063,
- .channels_min = 2,
- .channels_max = 2,
- .buffer_bytes_max = 60000,
- .period_bytes_min = LINE6_ISO_PACKET_SIZE_MAX * POD_BYTES_PER_FRAME, /* at least one URB must fit into one period */
- .period_bytes_max = 8192,
- .periods_min = 1,
- .periods_max = 1024
- },
- .snd_line6_capture_hw = {
- .info = (SNDRV_PCM_INFO_MMAP |
- SNDRV_PCM_INFO_INTERLEAVED |
- SNDRV_PCM_INFO_BLOCK_TRANSFER |
- SNDRV_PCM_INFO_MMAP_VALID |
- SNDRV_PCM_INFO_SYNC_START),
- .formats = SNDRV_PCM_FMTBIT_S24_3LE,
- .rates = SNDRV_PCM_RATE_KNOT,
- .rate_min = 39062,
- .rate_max = 39063,
- .channels_min = 2,
- .channels_max = 2,
- .buffer_bytes_max = 60000,
- .period_bytes_min = LINE6_ISO_PACKET_SIZE_MAX * POD_BYTES_PER_FRAME, /* at least one URB must fit into one period */
- .period_bytes_max = 8192,
- .periods_min = 1,
- .periods_max = 1024
- },
+ .snd_line6_playback_hw = {
+ .info = (SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_MMAP_VALID |
+ SNDRV_PCM_INFO_PAUSE |
+#ifdef CONFIG_PM
+ SNDRV_PCM_INFO_RESUME |
+#endif
+ SNDRV_PCM_INFO_SYNC_START),
+ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
+ .rates = SNDRV_PCM_RATE_KNOT,
+ .rate_min = 39062,
+ .rate_max = 39063,
+ .channels_min = 2,
+ .channels_max = 2,
+ .buffer_bytes_max = 60000,
+ .period_bytes_min = 64,
+ .period_bytes_max = 8192,
+ .periods_min = 1,
+ .periods_max = 1024},
+ .snd_line6_capture_hw = {
+ .info = (SNDRV_PCM_INFO_MMAP |
+ SNDRV_PCM_INFO_INTERLEAVED |
+ SNDRV_PCM_INFO_BLOCK_TRANSFER |
+ SNDRV_PCM_INFO_MMAP_VALID |
+#ifdef CONFIG_PM
+ SNDRV_PCM_INFO_RESUME |
+#endif
+ SNDRV_PCM_INFO_SYNC_START),
+ .formats = SNDRV_PCM_FMTBIT_S24_3LE,
+ .rates = SNDRV_PCM_RATE_KNOT,
+ .rate_min = 39062,
+ .rate_max = 39063,
+ .channels_min = 2,
+ .channels_max = 2,
+ .buffer_bytes_max = 60000,
+ .period_bytes_min = 64,
+ .period_bytes_max = 8192,
+ .periods_min = 1,
+ .periods_max = 1024},
.snd_line6_rates = {
- .nrats = 1,
- .rats = &pod_ratden
- },
+ .nrats = 1,
+ .rats = &pod_ratden},
.bytes_per_frame = POD_BYTES_PER_FRAME
};
-static const char pod_request_version[] = { 0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7 };
-static const char pod_request_channel[] = { 0xf0, 0x00, 0x01, 0x0c, 0x03, 0x75, 0xf7 };
-static const char pod_version_header[] = { 0xf2, 0x7e, 0x7f, 0x06, 0x02 };
+static const char pod_request_channel[] = {
+ 0xf0, 0x00, 0x01, 0x0c, 0x03, 0x75, 0xf7
+};
+
+static const char pod_version_header[] = {
+ 0xf2, 0x7e, 0x7f, 0x06, 0x02
+};
+/* forward declarations: */
+static void pod_startup2(unsigned long data);
+static void pod_startup3(struct usb_line6_pod *pod);
+static void pod_startup4(struct usb_line6_pod *pod);
/*
Mark all parameters as dirty and notify waiting processes.
@@ -129,63 +142,11 @@ static void pod_mark_batch_all_dirty(struct usb_line6_pod *pod)
set_bit(i, pod->param_dirty);
}
-/*
- Send an asynchronous request for the POD firmware version and device ID.
-*/
-static int pod_version_request_async(struct usb_line6_pod *pod)
-{
- return line6_send_raw_message_async(&pod->line6, pod->buffer_versionreq, sizeof(pod_request_version));
-}
-
-static void pod_create_files_work(struct work_struct *work)
-{
- struct usb_line6_pod *pod = container_of(work, struct usb_line6_pod, create_files_work);
-
- pod_create_files(pod->firmware_version, pod->line6.properties->device_bit, pod->line6.ifcdev);
-}
-
-static void pod_startup_timeout(unsigned long arg)
+static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code,
+ int size)
{
- enum {
- REQUEST_NONE,
- REQUEST_DUMP,
- REQUEST_VERSION
- };
-
- int request = REQUEST_NONE;
- struct usb_line6_pod *pod = (struct usb_line6_pod *)arg;
-
- if (pod->dumpreq.ok) {
- if (!pod->versionreq_ok)
- request = REQUEST_VERSION;
- } else {
- if (pod->versionreq_ok)
- request = REQUEST_DUMP;
- else if (pod->startup_count++ & 1)
- request = REQUEST_DUMP;
- else
- request = REQUEST_VERSION;
- }
-
- switch (request) {
- case REQUEST_DUMP:
- line6_dump_request_async(&pod->dumpreq, &pod->line6, 0);
- break;
-
- case REQUEST_VERSION:
- pod_version_request_async(pod);
- break;
-
- default:
- return;
- }
-
- line6_startup_delayed(&pod->dumpreq, 1, pod_startup_timeout, pod);
-}
-
-static char *pod_alloc_sysex_buffer(struct usb_line6_pod *pod, int code, int size)
-{
- return line6_alloc_sysex_buffer(&pod->line6, POD_SYSEX_CODE, code, size);
+ return line6_alloc_sysex_buffer(&pod->line6, POD_SYSEX_CODE, code,
+ size);
}
/*
@@ -218,9 +179,10 @@ static void pod_store_parameter(struct usb_line6_pod *pod, int param, int value)
}
/*
- Handle SAVE button
+ Handle SAVE button.
*/
-static void pod_save_button_pressed(struct usb_line6_pod *pod, int type, int index)
+static void pod_save_button_pressed(struct usb_line6_pod *pod, int type,
+ int index)
{
pod->dirty = 0;
set_bit(POD_SAVE_PRESSED, &pod->atomic_flags);
@@ -229,7 +191,7 @@ static void pod_save_button_pressed(struct usb_line6_pod *pod, int type, int ind
/*
Process a completely received message.
*/
-void pod_process_message(struct usb_line6_pod *pod)
+void line6_pod_process_message(struct usb_line6_pod *pod)
{
const unsigned char *buf = pod->line6.buffer_message;
@@ -238,10 +200,10 @@ void pod_process_message(struct usb_line6_pod *pod)
case LINE6_PARAM_CHANGE:
case LINE6_PROGRAM_CHANGE:
case LINE6_SYSEX_BEGIN:
- break; /* handle these further down */
+ break; /* handle these further down */
default:
- return; /* ignore all others */
+ return; /* ignore all others */
}
/* process all remaining messages */
@@ -254,7 +216,8 @@ void pod_process_message(struct usb_line6_pod *pod)
if ((buf[1] == POD_amp_model_setup) ||
(buf[1] == POD_effect_setup))
/* these also affect other settings */
- line6_dump_request_async(&pod->dumpreq, &pod->line6, 0);
+ line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
+ LINE6_DUMP_CURRENT);
break;
@@ -263,7 +226,8 @@ void pod_process_message(struct usb_line6_pod *pod)
pod->channel_num = buf[1];
pod->dirty = 0;
set_bit(POD_CHANNEL_DIRTY, &pod->atomic_flags);
- line6_dump_request_async(&pod->dumpreq, &pod->line6, 0);
+ line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
+ LINE6_DUMP_CURRENT);
break;
case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE:
@@ -271,54 +235,82 @@ void pod_process_message(struct usb_line6_pod *pod)
if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) {
switch (buf[5]) {
case POD_SYSEX_DUMP:
- if (pod->line6.message_length == sizeof(pod->prog_data) + 7) {
+ if (pod->line6.message_length ==
+ sizeof(pod->prog_data) + 7) {
switch (pod->dumpreq.in_progress) {
case LINE6_DUMP_CURRENT:
- memcpy(&pod->prog_data, buf + 7, sizeof(pod->prog_data));
+ memcpy(&pod->prog_data, buf + 7,
+ sizeof(pod->prog_data));
pod_mark_batch_all_dirty(pod);
- pod->dumpreq.ok = 1;
break;
case POD_DUMP_MEMORY:
- memcpy(&pod->prog_data_buf, buf + 7, sizeof(pod->prog_data_buf));
+ memcpy(&pod->prog_data_buf,
+ buf + 7,
+ sizeof
+ (pod->prog_data_buf));
break;
default:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "unknown dump code %02X\n", pod->dumpreq.in_progress));
+ DEBUG_MESSAGES(dev_err
+ (pod->
+ line6.ifcdev,
+ "unknown dump code %02X\n",
+ pod->
+ dumpreq.in_progress));
}
line6_dump_finished(&pod->dumpreq);
+ pod_startup3(pod);
} else
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "wrong size of channel dump message (%d instead of %d)\n",
- pod->line6.message_length, (int)sizeof(pod->prog_data) + 7));
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "wrong size of channel dump message (%d instead of %d)\n",
+ pod->
+ line6.message_length,
+ (int)
+ sizeof(pod->prog_data) +
+ 7));
break;
- case POD_SYSEX_SYSTEM: {
- short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) | ((int)buf[9] << 4) | (int)buf[10];
+ case POD_SYSEX_SYSTEM:{
+ short value =
+ ((int)buf[7] << 12) | ((int)buf[8]
+ << 8) |
+ ((int)buf[9] << 4) | (int)buf[10];
#define PROCESS_SYSTEM_PARAM(x) \
case POD_ ## x: \
pod->x.value = value; \
- wake_up_interruptible(&pod->x.wait); \
+ wake_up(&pod->x.wait); \
break;
- switch (buf[6]) {
- PROCESS_SYSTEM_PARAM(monitor_level);
- PROCESS_SYSTEM_PARAM(routing);
- PROCESS_SYSTEM_PARAM(tuner_mute);
- PROCESS_SYSTEM_PARAM(tuner_freq);
- PROCESS_SYSTEM_PARAM(tuner_note);
- PROCESS_SYSTEM_PARAM(tuner_pitch);
+ switch (buf[6]) {
+ PROCESS_SYSTEM_PARAM
+ (monitor_level);
+ PROCESS_SYSTEM_PARAM(routing);
+ PROCESS_SYSTEM_PARAM
+ (tuner_mute);
+ PROCESS_SYSTEM_PARAM
+ (tuner_freq);
+ PROCESS_SYSTEM_PARAM
+ (tuner_note);
+ PROCESS_SYSTEM_PARAM
+ (tuner_pitch);
#undef PROCESS_SYSTEM_PARAM
- default:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "unknown tuner/system response %02X\n", buf[6]));
- }
+ default:
+ DEBUG_MESSAGES(dev_err
+ (pod->
+ line6.ifcdev,
+ "unknown tuner/system response %02X\n",
+ buf[6]));
+ }
- break;
- }
+ break;
+ }
case POD_SYSEX_FINISH:
/* do we need to respond to this? */
@@ -329,32 +321,40 @@ void pod_process_message(struct usb_line6_pod *pod)
break;
case POD_SYSEX_CLIP:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "audio clipped\n"));
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "audio clipped\n"));
pod->clipping.value = 1;
- wake_up_interruptible(&pod->clipping.wait);
+ wake_up(&pod->clipping.wait);
break;
case POD_SYSEX_STORE:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "message %02X not yet implemented\n", buf[5]));
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "message %02X not yet implemented\n",
+ buf[5]));
break;
default:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "unknown sysex message %02X\n", buf[5]));
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "unknown sysex message %02X\n",
+ buf[5]));
}
- } else if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) {
- if (pod->versionreq_ok == 0) {
- pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15];
- pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)buf[10];
- pod->versionreq_ok = 1;
-
- /* Now we know the firmware version, so we schedule a bottom half
- handler to create the special files: */
- INIT_WORK(&pod->create_files_work, pod_create_files_work);
- queue_work(line6_workqueue, &pod->create_files_work);
- } else
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "multiple firmware version message\n"));
} else
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "unknown sysex header\n"));
+ if (memcmp
+ (buf, pod_version_header,
+ sizeof(pod_version_header)) == 0) {
+ pod->firmware_version =
+ buf[13] * 100 + buf[14] * 10 + buf[15];
+ pod->device_id =
+ ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)
+ buf[10];
+ pod_startup4(pod);
+ } else
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "unknown sysex header\n"));
break;
@@ -362,7 +362,9 @@ void pod_process_message(struct usb_line6_pod *pod)
break;
default:
- DEBUG_MESSAGES(dev_err(pod->line6.ifcdev, "POD: unknown message %02X\n", buf[0]));
+ DEBUG_MESSAGES(dev_err
+ (pod->line6.ifcdev,
+ "POD: unknown message %02X\n", buf[0]));
}
}
@@ -377,7 +379,8 @@ void pod_process_message(struct usb_line6_pod *pod)
*) This method fails if a param change message is "chopped" after the first
byte.
*/
-void pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data, int length)
+void line6_pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data,
+ int length)
{
int i;
@@ -388,8 +391,11 @@ void pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data, int le
if (data[i] == (LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST)) {
line6_invalidate_current(&pod->dumpreq);
break;
- } else if ((data[i] == (LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST)) && (i < length - 1))
- if ((data[i + 1] == POD_amp_model_setup) || (data[i + 1] == POD_effect_setup)) {
+ } else
+ if ((data[i] == (LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST))
+ && (i < length - 1))
+ if ((data[i + 1] == POD_amp_model_setup)
+ || (data[i + 1] == POD_effect_setup)) {
line6_invalidate_current(&pod->dumpreq);
break;
}
@@ -412,19 +418,21 @@ static void pod_send_channel(struct usb_line6_pod *pod, int value)
/*
Transmit PODxt Pro control parameter.
*/
-void pod_transmit_parameter(struct usb_line6_pod *pod, int param, int value)
+void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
+ int value)
{
if (line6_transmit_parameter(&pod->line6, param, value) == 0)
pod_store_parameter(pod, param, value);
- if ((param == POD_amp_model_setup) || (param == POD_effect_setup)) /* these also affect other settings */
+ if ((param == POD_amp_model_setup) || (param == POD_effect_setup)) /* these also affect other settings */
line6_invalidate_current(&pod->dumpreq);
}
/*
Resolve value to memory location.
*/
-static int pod_resolve(const char *buf, short block0, short block1, unsigned char *location)
+static int pod_resolve(const char *buf, short block0, short block1,
+ unsigned char *location)
{
unsigned long value;
short block;
@@ -444,7 +452,8 @@ static int pod_resolve(const char *buf, short block0, short block1, unsigned cha
/*
Send command to store channel/effects setup/amp setup to PODxt Pro.
*/
-static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_t count, short block0, short block1)
+static ssize_t pod_send_store_command(struct device *dev, const char *buf,
+ size_t count, short block0, short block1)
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
@@ -455,14 +464,15 @@ static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_
if (!sysex)
return 0;
- sysex[SYSEX_DATA_OFS] = 5; /* see pod_dump() */
+ sysex[SYSEX_DATA_OFS] = 5; /* see pod_dump() */
ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
if (ret) {
kfree(sysex);
return ret;
}
- memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf, sizeof(pod->prog_data_buf));
+ memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf,
+ sizeof(pod->prog_data_buf));
line6_send_sysex_message(&pod->line6, sysex, size);
kfree(sysex);
@@ -473,7 +483,9 @@ static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_
/*
Send command to retrieve channel/effects setup/amp setup to PODxt Pro.
*/
-static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf, size_t count, short block0, short block1)
+static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf,
+ size_t count, short block0,
+ short block1)
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
@@ -504,14 +516,15 @@ static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf, si
/*
Generic get name function.
*/
-static ssize_t get_name_generic(struct usb_line6_pod *pod, const char *str, char *buf)
+static ssize_t get_name_generic(struct usb_line6_pod *pod, const char *str,
+ char *buf)
{
int length = 0;
const char *p1;
char *p2;
char *last_non_space = buf;
- int retval = line6_wait_dump(&pod->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&pod->dumpreq);
if (retval < 0)
return retval;
@@ -566,7 +579,8 @@ static ssize_t pod_get_name(struct device *dev, struct device_attribute *attr,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- return get_name_generic(pod, pod->prog_data.header + POD_NAME_OFFSET, buf);
+ return get_name_generic(pod, pod->prog_data.header + POD_NAME_OFFSET,
+ buf);
}
/*
@@ -577,7 +591,9 @@ static ssize_t pod_get_name_buf(struct device *dev,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- return get_name_generic(pod, pod->prog_data_buf.header + POD_NAME_OFFSET, buf);
+ return get_name_generic(pod,
+ pod->prog_data_buf.header + POD_NAME_OFFSET,
+ buf);
}
/*
@@ -588,7 +604,7 @@ static ssize_t pod_get_dump(struct device *dev, struct device_attribute *attr,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- int retval = line6_wait_dump(&pod->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&pod->dumpreq);
if (retval < 0)
return retval;
memcpy(buf, &pod->prog_data, sizeof(pod->prog_data));
@@ -606,8 +622,8 @@ static ssize_t pod_set_dump(struct device *dev, struct device_attribute *attr,
if (count != sizeof(pod->prog_data)) {
dev_err(pod->line6.ifcdev,
- "data block must be exactly %zu bytes\n",
- sizeof(pod->prog_data));
+ "data block must be exactly %d bytes\n",
+ (int)sizeof(pod->prog_data));
return -EINVAL;
}
@@ -616,86 +632,116 @@ static ssize_t pod_set_dump(struct device *dev, struct device_attribute *attr,
}
/*
- Request system parameter.
+ Identify system parameters related to the tuner.
+*/
+static bool pod_is_tuner(int code)
+{
+ return
+ (code == POD_tuner_mute) ||
+ (code == POD_tuner_freq) ||
+ (code == POD_tuner_note) || (code == POD_tuner_pitch);
+}
+
+/*
+ Get system parameter (as integer).
@param tuner non-zero, if code refers to a tuner parameter
*/
-static ssize_t pod_get_system_param(struct usb_line6_pod *pod, char *buf, int code, struct ValueWait *param, int tuner, int sign)
+static int pod_get_system_param_int(struct usb_line6_pod *pod, int *value,
+ int code, struct ValueWait *param, int sign)
{
char *sysex;
- int value;
static const int size = 1;
int retval = 0;
- DECLARE_WAITQUEUE(wait, current);
- if (((pod->prog_data.control[POD_tuner] & 0x40) == 0) && tuner)
+ if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
+ && pod_is_tuner(code))
return -ENODEV;
- /* send value request to tuner: */
+ /* send value request to device: */
param->value = POD_system_invalid;
sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEMREQ, size);
+
if (!sysex)
- return 0;
+ return -ENOMEM;
+
sysex[SYSEX_DATA_OFS] = code;
line6_send_sysex_message(&pod->line6, sysex, size);
kfree(sysex);
- /* wait for tuner to respond: */
- add_wait_queue(&param->wait, &wait);
- current->state = TASK_INTERRUPTIBLE;
+ /* wait for device to respond: */
+ retval =
+ wait_event_interruptible(param->wait,
+ param->value != POD_system_invalid);
- while (param->value == POD_system_invalid) {
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- } else
- schedule();
- }
+ if (retval < 0)
+ return retval;
- current->state = TASK_RUNNING;
- remove_wait_queue(&param->wait, &wait);
+ *value = sign ? (int)(signed short)param->value : (int)(unsigned short)
+ param->value;
+
+ if (*value == POD_system_invalid)
+ *value = 0; /* don't report uninitialized values */
+
+ return 0;
+}
+
+/*
+ Get system parameter (as string).
+ @param tuner non-zero, if code refers to a tuner parameter
+*/
+static ssize_t pod_get_system_param_string(struct usb_line6_pod *pod, char *buf,
+ int code, struct ValueWait *param,
+ int sign)
+{
+ int retval, value = 0;
+ retval = pod_get_system_param_int(pod, &value, code, param, sign);
if (retval < 0)
return retval;
- value = sign ? (int)(signed short)param->value : (int)(unsigned short)param->value;
return sprintf(buf, "%d\n", value);
}
/*
- Send system parameter.
+ Send system parameter (from integer).
@param tuner non-zero, if code refers to a tuner parameter
*/
-static ssize_t pod_set_system_param(struct usb_line6_pod *pod, const char *buf,
- int count, int code, unsigned short mask,
- int tuner)
+static int pod_set_system_param_int(struct usb_line6_pod *pod, int value,
+ int code)
{
char *sysex;
static const int size = 5;
- unsigned short value;
- unsigned long result;
- int ret;
- if (((pod->prog_data.control[POD_tuner] & 0x40) == 0) && tuner)
+ if (((pod->prog_data.control[POD_tuner] & 0x40) == 0)
+ && pod_is_tuner(code))
return -EINVAL;
/* send value to tuner: */
sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size);
if (!sysex)
- return 0;
-
- ret = strict_strtoul(buf, 10, &result);
- if (ret)
- return ret;
-
- value = result & mask;
+ return -ENOMEM;
sysex[SYSEX_DATA_OFS] = code;
sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f;
- sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
- sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f;
- sysex[SYSEX_DATA_OFS + 4] = (value ) & 0x0f;
+ sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
+ sysex[SYSEX_DATA_OFS + 3] = (value >> 4) & 0x0f;
+ sysex[SYSEX_DATA_OFS + 4] = (value) & 0x0f;
line6_send_sysex_message(&pod->line6, sysex, size);
kfree(sysex);
- return count;
+ return 0;
+}
+
+/*
+ Send system parameter (from string).
+ @param tuner non-zero, if code refers to a tuner parameter
+*/
+static ssize_t pod_set_system_param_string(struct usb_line6_pod *pod,
+ const char *buf, int count, int code,
+ unsigned short mask)
+{
+ int retval;
+ unsigned short value = simple_strtoul(buf, NULL, 10) & mask;
+ retval = pod_set_system_param_int(pod, value, code);
+ return (retval < 0) ? retval : count;
}
/*
@@ -706,7 +752,7 @@ static ssize_t pod_get_dump_buf(struct device *dev,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- int retval = line6_wait_dump(&pod->dumpreq, 0);
+ int retval = line6_dump_wait_interruptible(&pod->dumpreq);
if (retval < 0)
return retval;
memcpy(buf, &pod->prog_data_buf, sizeof(pod->prog_data_buf));
@@ -725,8 +771,8 @@ static ssize_t pod_set_dump_buf(struct device *dev,
if (count != sizeof(pod->prog_data)) {
dev_err(pod->line6.ifcdev,
- "data block must be exactly %zu bytes\n",
- sizeof(pod->prog_data));
+ "data block must be exactly %d bytes\n",
+ (int)sizeof(pod->prog_data));
return -EINVAL;
}
@@ -900,87 +946,203 @@ static ssize_t pod_wait_for_clip(struct device *dev,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- int err = 0;
- DECLARE_WAITQUEUE(wait, current);
- pod->clipping.value = 0;
- add_wait_queue(&pod->clipping.wait, &wait);
- current->state = TASK_INTERRUPTIBLE;
-
- while (pod->clipping.value == 0) {
- if (signal_pending(current)) {
- err = -ERESTARTSYS;
- break;
- } else
- schedule();
- }
+ return wait_event_interruptible(pod->clipping.wait,
+ pod->clipping.value != 0);
+}
- current->state = TASK_RUNNING;
- remove_wait_queue(&pod->clipping.wait, &wait);
- return err;
+/*
+ POD startup procedure.
+ This is a sequence of functions with special requirements (e.g., must
+ not run immediately after initialization, must not run in interrupt
+ context). After the last one has finished, the device is ready to use.
+*/
+
+static void pod_startup1(struct usb_line6_pod *pod)
+{
+ CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_INIT);
+
+ /* delay startup procedure: */
+ line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
+ (unsigned long)pod);
}
-#define POD_GET_SYSTEM_PARAM(code, tuner, sign) \
+static void pod_startup2(unsigned long data)
+{
+ struct usb_line6_pod *pod = (struct usb_line6_pod *)data;
+
+ /* schedule another startup procedure until startup is complete: */
+ if (pod->startup_progress >= POD_STARTUP_LAST)
+ return;
+
+ pod->startup_progress = POD_STARTUP_DUMPREQ;
+ line6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,
+ (unsigned long)pod);
+
+ /* current channel dump: */
+ line6_dump_request_async(&pod->dumpreq, &pod->line6, 0,
+ LINE6_DUMP_CURRENT);
+}
+
+static void pod_startup3(struct usb_line6_pod *pod)
+{
+ struct usb_line6 *line6 = &pod->line6;
+ CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_VERSIONREQ);
+
+ /* request firmware version: */
+ line6_version_request_async(line6);
+}
+
+static void pod_startup4(struct usb_line6_pod *pod)
+{
+ CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_WORKQUEUE);
+
+ /* schedule work for global work queue: */
+ schedule_work(&pod->startup_work);
+}
+
+static void pod_startup5(struct work_struct *work)
+{
+ struct usb_line6_pod *pod =
+ container_of(work, struct usb_line6_pod, startup_work);
+ struct usb_line6 *line6 = &pod->line6;
+
+ CHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_SETUP);
+
+ /* serial number: */
+ line6_read_serial_number(&pod->line6, &pod->serial_number);
+
+ /* ALSA audio interface: */
+ line6_register_audio(line6);
+
+ /* device files: */
+ line6_pod_create_files(pod->firmware_version,
+ line6->properties->device_bit, line6->ifcdev);
+}
+
+#define POD_GET_SYSTEM_PARAM(code, sign) \
static ssize_t pod_get_ ## code(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct usb_interface *interface = to_usb_interface(dev); \
struct usb_line6_pod *pod = usb_get_intfdata(interface); \
- return pod_get_system_param(pod, buf, POD_ ## code, &pod->code, \
- tuner, sign); \
+ return pod_get_system_param_string(pod, buf, POD_ ## code, \
+ &pod->code, sign); \
}
-#define POD_GET_SET_SYSTEM_PARAM(code, mask, tuner, sign) \
-POD_GET_SYSTEM_PARAM(code, tuner, sign) \
+#define POD_GET_SET_SYSTEM_PARAM(code, mask, sign) \
+POD_GET_SYSTEM_PARAM(code, sign) \
static ssize_t pod_set_ ## code(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
struct usb_interface *interface = to_usb_interface(dev); \
struct usb_line6_pod *pod = usb_get_intfdata(interface); \
- return pod_set_system_param(pod, buf, count, POD_ ## code, mask, \
- tuner); \
+ return pod_set_system_param_string(pod, buf, count, POD_ ## code, mask); \
}
-POD_GET_SET_SYSTEM_PARAM(monitor_level, 0xffff, 0, 0);
-POD_GET_SET_SYSTEM_PARAM(routing, 0x0003, 0, 0);
-POD_GET_SET_SYSTEM_PARAM(tuner_mute, 0x0001, 1, 0);
-POD_GET_SET_SYSTEM_PARAM(tuner_freq, 0xffff, 1, 0);
-POD_GET_SYSTEM_PARAM(tuner_note, 1, 1);
-POD_GET_SYSTEM_PARAM(tuner_pitch, 1, 1);
+POD_GET_SET_SYSTEM_PARAM(monitor_level, 0xffff, 0);
+POD_GET_SET_SYSTEM_PARAM(routing, 0x0003, 0);
+POD_GET_SET_SYSTEM_PARAM(tuner_mute, 0x0001, 0);
+POD_GET_SET_SYSTEM_PARAM(tuner_freq, 0xffff, 0);
+POD_GET_SYSTEM_PARAM(tuner_note, 1);
+POD_GET_SYSTEM_PARAM(tuner_pitch, 1);
#undef GET_SET_SYSTEM_PARAM
#undef GET_SYSTEM_PARAM
/* POD special files: */
-static DEVICE_ATTR(channel, S_IWUGO | S_IRUGO, pod_get_channel, pod_set_channel);
+static DEVICE_ATTR(channel, S_IWUGO | S_IRUGO, pod_get_channel,
+ pod_set_channel);
static DEVICE_ATTR(clip, S_IRUGO, pod_wait_for_clip, line6_nop_write);
static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write);
static DEVICE_ATTR(dirty, S_IRUGO, pod_get_dirty, line6_nop_write);
static DEVICE_ATTR(dump, S_IWUGO | S_IRUGO, pod_get_dump, pod_set_dump);
-static DEVICE_ATTR(dump_buf, S_IWUGO | S_IRUGO, pod_get_dump_buf, pod_set_dump_buf);
+static DEVICE_ATTR(dump_buf, S_IWUGO | S_IRUGO, pod_get_dump_buf,
+ pod_set_dump_buf);
static DEVICE_ATTR(finish, S_IWUGO, line6_nop_read, pod_set_finish);
-static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version, line6_nop_write);
-static DEVICE_ATTR(midi_postprocess, S_IWUGO | S_IRUGO, pod_get_midi_postprocess, pod_set_midi_postprocess);
-static DEVICE_ATTR(monitor_level, S_IWUGO | S_IRUGO, pod_get_monitor_level, pod_set_monitor_level);
+static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version,
+ line6_nop_write);
+static DEVICE_ATTR(midi_postprocess, S_IWUGO | S_IRUGO,
+ pod_get_midi_postprocess, pod_set_midi_postprocess);
+static DEVICE_ATTR(monitor_level, S_IWUGO | S_IRUGO, pod_get_monitor_level,
+ pod_set_monitor_level);
static DEVICE_ATTR(name, S_IRUGO, pod_get_name, line6_nop_write);
static DEVICE_ATTR(name_buf, S_IRUGO, pod_get_name_buf, line6_nop_write);
-static DEVICE_ATTR(retrieve_amp_setup, S_IWUGO, line6_nop_read, pod_set_retrieve_amp_setup);
-static DEVICE_ATTR(retrieve_channel, S_IWUGO, line6_nop_read, pod_set_retrieve_channel);
-static DEVICE_ATTR(retrieve_effects_setup, S_IWUGO, line6_nop_read, pod_set_retrieve_effects_setup);
-static DEVICE_ATTR(routing, S_IWUGO | S_IRUGO, pod_get_routing, pod_set_routing);
-static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number, line6_nop_write);
-static DEVICE_ATTR(store_amp_setup, S_IWUGO, line6_nop_read, pod_set_store_amp_setup);
-static DEVICE_ATTR(store_channel, S_IWUGO, line6_nop_read, pod_set_store_channel);
-static DEVICE_ATTR(store_effects_setup, S_IWUGO, line6_nop_read, pod_set_store_effects_setup);
-static DEVICE_ATTR(tuner_freq, S_IWUGO | S_IRUGO, pod_get_tuner_freq, pod_set_tuner_freq);
-static DEVICE_ATTR(tuner_mute, S_IWUGO | S_IRUGO, pod_get_tuner_mute, pod_set_tuner_mute);
+static DEVICE_ATTR(retrieve_amp_setup, S_IWUGO, line6_nop_read,
+ pod_set_retrieve_amp_setup);
+static DEVICE_ATTR(retrieve_channel, S_IWUGO, line6_nop_read,
+ pod_set_retrieve_channel);
+static DEVICE_ATTR(retrieve_effects_setup, S_IWUGO, line6_nop_read,
+ pod_set_retrieve_effects_setup);
+static DEVICE_ATTR(routing, S_IWUGO | S_IRUGO, pod_get_routing,
+ pod_set_routing);
+static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number,
+ line6_nop_write);
+static DEVICE_ATTR(store_amp_setup, S_IWUGO, line6_nop_read,
+ pod_set_store_amp_setup);
+static DEVICE_ATTR(store_channel, S_IWUGO, line6_nop_read,
+ pod_set_store_channel);
+static DEVICE_ATTR(store_effects_setup, S_IWUGO, line6_nop_read,
+ pod_set_store_effects_setup);
+static DEVICE_ATTR(tuner_freq, S_IWUGO | S_IRUGO, pod_get_tuner_freq,
+ pod_set_tuner_freq);
+static DEVICE_ATTR(tuner_mute, S_IWUGO | S_IRUGO, pod_get_tuner_mute,
+ pod_set_tuner_mute);
static DEVICE_ATTR(tuner_note, S_IRUGO, pod_get_tuner_note, line6_nop_write);
static DEVICE_ATTR(tuner_pitch, S_IRUGO, pod_get_tuner_pitch, line6_nop_write);
-#if CREATE_RAW_FILE
+#ifdef CONFIG_LINE6_USB_RAW
static DEVICE_ATTR(raw, S_IWUGO, line6_nop_read, line6_set_raw);
#endif
+/* control info callback */
+static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 65535;
+ return 0;
+}
+
+/* control get callback */
+static int snd_pod_control_monitor_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+ struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
+ ucontrol->value.integer.value[0] = pod->monitor_level.value;
+ return 0;
+}
+
+/* control put callback */
+static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+ struct usb_line6_pod *pod = (struct usb_line6_pod *)line6pcm->line6;
+
+ if (ucontrol->value.integer.value[0] == pod->monitor_level.value)
+ return 0;
+
+ pod->monitor_level.value = ucontrol->value.integer.value[0];
+ pod_set_system_param_int(pod, ucontrol->value.integer.value[0],
+ POD_monitor_level);
+ return 1;
+}
+
+/* control definition */
+static struct snd_kcontrol_new pod_control_monitor = {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Monitor Playback Volume",
+ .index = 0,
+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
+ .info = snd_pod_control_monitor_info,
+ .get = snd_pod_control_monitor_get,
+ .put = snd_pod_control_monitor_put
+};
+
/*
POD destructor.
*/
@@ -996,10 +1158,11 @@ static void pod_destruct(struct usb_interface *interface)
return;
line6_cleanup_audio(line6);
+ del_timer(&pod->startup_timer);
+ cancel_work_sync(&pod->startup_work);
+
/* free dump request data: */
line6_dumpreq_destruct(&pod->dumpreq);
-
- kfree(pod->buffer_versionreq);
}
/*
@@ -1034,7 +1197,7 @@ static int pod_create_files2(struct device *dev)
CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_note));
CHECK_RETURN(device_create_file(dev, &dev_attr_tuner_pitch));
-#if CREATE_RAW_FILE
+#ifdef CONFIG_LINE6_USB_RAW
CHECK_RETURN(device_create_file(dev, &dev_attr_raw));
#endif
@@ -1042,13 +1205,17 @@ static int pod_create_files2(struct device *dev)
}
/*
- Init POD device.
+ Try to init POD device.
*/
-int pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
+static int pod_try_init(struct usb_interface *interface,
+ struct usb_line6_pod *pod)
{
int err;
struct usb_line6 *line6 = &pod->line6;
+ init_timer(&pod->startup_timer);
+ INIT_WORK(&pod->startup_work, pod_startup5);
+
if ((interface == NULL) || (pod == NULL))
return -ENODEV;
@@ -1070,69 +1237,75 @@ int pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
sizeof(pod_request_channel));
if (err < 0) {
dev_err(&interface->dev, "Out of memory\n");
- pod_destruct(interface);
- return -ENOMEM;
- }
-
- pod->buffer_versionreq = kmemdup(pod_request_version,
- sizeof(pod_request_version),
- GFP_KERNEL);
-
- if (pod->buffer_versionreq == NULL) {
- dev_err(&interface->dev, "Out of memory\n");
- pod_destruct(interface);
return -ENOMEM;
}
/* create sysfs entries: */
err = pod_create_files2(&interface->dev);
if (err < 0) {
- pod_destruct(interface);
return err;
}
/* initialize audio system: */
err = line6_init_audio(line6);
if (err < 0) {
- pod_destruct(interface);
return err;
}
/* initialize MIDI subsystem: */
err = line6_init_midi(line6);
if (err < 0) {
- pod_destruct(interface);
return err;
}
/* initialize PCM subsystem: */
err = line6_init_pcm(line6, &pod_pcm_properties);
if (err < 0) {
- pod_destruct(interface);
return err;
}
- /* register audio system: */
- err = line6_register_audio(line6);
+ /* register monitor control: */
+ err =
+ snd_ctl_add(line6->card,
+ snd_ctl_new1(&pod_control_monitor, line6->line6pcm));
if (err < 0) {
- pod_destruct(interface);
return err;
}
+ /*
+ When the sound card is registered at this point, the PODxt Live
+ displays "Invalid Code Error 07", so we do it later in the event
+ handler.
+ */
+
if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) {
- /* query some data: */
- line6_startup_delayed(&pod->dumpreq, POD_STARTUP_DELAY,
- pod_startup_timeout, pod);
- line6_read_serial_number(&pod->line6, &pod->serial_number);
+ pod->monitor_level.value = POD_system_invalid;
+
+ /* initiate startup procedure: */
+ pod_startup1(pod);
}
return 0;
}
/*
+ Init POD device (and clean up in case of failure).
+*/
+int line6_pod_init(struct usb_interface *interface, struct usb_line6_pod *pod)
+{
+ int err = pod_try_init(interface, pod);
+
+ if (err < 0) {
+ pod_destruct(interface);
+ }
+
+ return err;
+}
+
+/*
POD device disconnected.
*/
-void pod_disconnect(struct usb_interface *interface)
+void line6_pod_disconnect(struct usb_interface *interface)
{
struct usb_line6_pod *pod;
@@ -1145,14 +1318,14 @@ void pod_disconnect(struct usb_interface *interface)
struct device *dev = &interface->dev;
if (line6pcm != NULL) {
- unlink_wait_clear_audio_out_urbs(line6pcm);
- unlink_wait_clear_audio_in_urbs(line6pcm);
+ line6_pcm_disconnect(line6pcm);
}
if (dev != NULL) {
/* remove sysfs entries: */
- if (pod->versionreq_ok)
- pod_remove_files(pod->firmware_version, pod->line6.properties->device_bit, dev);
+ line6_pod_remove_files(pod->firmware_version,
+ pod->line6.
+ properties->device_bit, dev);
device_remove_file(dev, &dev_attr_channel);
device_remove_file(dev, &dev_attr_clip);
@@ -1168,7 +1341,8 @@ void pod_disconnect(struct usb_interface *interface)
device_remove_file(dev, &dev_attr_name_buf);
device_remove_file(dev, &dev_attr_retrieve_amp_setup);
device_remove_file(dev, &dev_attr_retrieve_channel);
- device_remove_file(dev, &dev_attr_retrieve_effects_setup);
+ device_remove_file(dev,
+ &dev_attr_retrieve_effects_setup);
device_remove_file(dev, &dev_attr_routing);
device_remove_file(dev, &dev_attr_serial_number);
device_remove_file(dev, &dev_attr_store_amp_setup);
@@ -1179,7 +1353,7 @@ void pod_disconnect(struct usb_interface *interface)
device_remove_file(dev, &dev_attr_tuner_note);
device_remove_file(dev, &dev_attr_tuner_pitch);
-#if CREATE_RAW_FILE
+#ifdef CONFIG_LINE6_USB_RAW
device_remove_file(dev, &dev_attr_raw);
#endif
}
diff --git a/drivers/staging/line6/pod.h b/drivers/staging/line6/pod.h
index 7051ca613819..18b9d08c3288 100644
--- a/drivers/staging/line6/pod.h
+++ b/drivers/staging/line6/pod.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,19 +12,16 @@
#ifndef POD_H
#define POD_H
-
-#include "driver.h"
-
+#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/wait.h>
-#include <linux/workqueue.h>
#include <sound/core.h>
+#include "driver.h"
#include "dumprequest.h"
-
/*
PODxt Live interfaces
*/
@@ -42,163 +39,167 @@
*/
#define POD_CONTROL_SIZE 0x80
#define POD_BUFSIZE_DUMPREQ 7
-#define POD_STARTUP_DELAY 3
+#define POD_STARTUP_DELAY 1000
+/*
+ Stages of POD startup procedure
+*/
+enum {
+ POD_STARTUP_INIT = 1,
+ POD_STARTUP_DUMPREQ,
+ POD_STARTUP_VERSIONREQ,
+ POD_STARTUP_WORKQUEUE,
+ POD_STARTUP_SETUP,
+ POD_STARTUP_LAST = POD_STARTUP_SETUP - 1
+};
/**
- Data structure for values that need to be requested explicitly.
- This is the case for system and tuner settings.
+ Data structure for values that need to be requested explicitly.
+ This is the case for system and tuner settings.
*/
struct ValueWait {
- unsigned short value;
+ int value;
wait_queue_head_t wait;
};
/**
- Binary PodXT Pro program dump
+ Binary PODxt Pro program dump
*/
struct pod_program {
/**
- Header information (including program name).
+ Header information (including program name).
*/
unsigned char header[0x20];
/**
- Program parameters.
+ Program parameters.
*/
unsigned char control[POD_CONTROL_SIZE];
};
struct usb_line6_pod {
/**
- Generic Line6 USB data.
+ Generic Line6 USB data.
*/
struct usb_line6 line6;
/**
- Dump request structure.
+ Dump request structure.
*/
struct line6_dump_request dumpreq;
/**
- Current program number.
+ Current program number.
*/
unsigned char channel_num;
/**
- Current program settings.
+ Current program settings.
*/
struct pod_program prog_data;
/**
- Buffer for data retrieved from or to be stored on PODxt Pro.
+ Buffer for data retrieved from or to be stored on PODxt Pro.
*/
struct pod_program prog_data_buf;
/**
- Buffer for requesting version number.
- */
- unsigned char *buffer_versionreq;
-
- /**
- Tuner mute mode.
+ Tuner mute mode.
*/
struct ValueWait tuner_mute;
/**
- Tuner base frequency (typically 440Hz).
+ Tuner base frequency (typically 440Hz).
*/
struct ValueWait tuner_freq;
/**
- Note received from tuner.
+ Note received from tuner.
*/
struct ValueWait tuner_note;
/**
- Pitch value received from tuner.
+ Pitch value received from tuner.
*/
struct ValueWait tuner_pitch;
/**
- Instrument monitor level.
+ Instrument monitor level.
*/
struct ValueWait monitor_level;
/**
- Audio routing mode.
- 0: send processed guitar
- 1: send clean guitar
- 2: send clean guitar re-amp playback
- 3: send re-amp playback
+ Audio routing mode.
+ 0: send processed guitar
+ 1: send clean guitar
+ 2: send clean guitar re-amp playback
+ 3: send re-amp playback
*/
struct ValueWait routing;
/**
- Wait for audio clipping event.
+ Wait for audio clipping event.
*/
struct ValueWait clipping;
/**
- Bottom-half for creation of sysfs special files.
+ Timer for device initializaton.
*/
- struct work_struct create_files_work;
+ struct timer_list startup_timer;
/**
- Dirty flags for access to parameter data.
+ Work handler for device initializaton.
*/
- unsigned long param_dirty[POD_CONTROL_SIZE / sizeof(unsigned long)];
+ struct work_struct startup_work;
/**
- Some atomic flags.
+ Current progress in startup procedure.
*/
- unsigned long atomic_flags;
+ int startup_progress;
+
+ /**
+ Dirty flags for access to parameter data.
+ */
+ unsigned long param_dirty[POD_CONTROL_SIZE / sizeof(unsigned long)];
/**
- Counter for startup process.
+ Some atomic flags.
*/
- int startup_count;
+ unsigned long atomic_flags;
/**
- Serial number of device.
+ Serial number of device.
*/
int serial_number;
/**
- Firmware version (x 100).
+ Firmware version (x 100).
*/
int firmware_version;
/**
- Device ID.
+ Device ID.
*/
int device_id;
/**
- Flag to indicate modification of current program settings.
+ Flag to indicate modification of current program settings.
*/
char dirty;
/**
- Flag if initial firmware version request has been successful.
- */
- char versionreq_ok;
-
- /**
- Flag to enable MIDI postprocessing.
+ Flag to enable MIDI postprocessing.
*/
char midi_postprocess;
};
-
-extern void pod_disconnect(struct usb_interface *interface);
-extern int pod_init(struct usb_interface *interface, struct usb_line6_pod *pod);
-extern void pod_midi_postprocess(struct usb_line6_pod *pod,
- unsigned char *data, int length);
-extern void pod_process_message(struct usb_line6_pod *pod);
-extern void pod_receive_parameter(struct usb_line6_pod *pod, int param);
-extern void pod_transmit_parameter(struct usb_line6_pod *pod, int param,
- int value);
-
+extern void line6_pod_disconnect(struct usb_interface *interface);
+extern int line6_pod_init(struct usb_interface *interface,
+ struct usb_line6_pod *pod);
+extern void line6_pod_midi_postprocess(struct usb_line6_pod *pod,
+ unsigned char *data, int length);
+extern void line6_pod_process_message(struct usb_line6_pod *pod);
+extern void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
+ int value);
#endif
diff --git a/drivers/staging/line6/revision.h b/drivers/staging/line6/revision.h
index b2a0a85efe69..e9883f6d2ecc 100644
--- a/drivers/staging/line6/revision.h
+++ b/drivers/staging/line6/revision.h
@@ -1,4 +1,4 @@
#ifndef DRIVER_REVISION
/* current subversion revision */
-#define DRIVER_REVISION " (revision 529)"
+#define DRIVER_REVISION " (revision 684)"
#endif
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index e6770ea17936..d4ac734d744f 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
* Emil Myhrman (emil.myhrman@gmail.com)
*
* This program is free software; you can redistribute it and/or
@@ -10,15 +10,19 @@
*
*/
-#include "driver.h"
+#include <linux/wait.h>
+#include <sound/control.h>
#include "audio.h"
#include "capture.h"
+#include "driver.h"
#include "playback.h"
#include "toneport.h"
static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2);
+#define TONEPORT_PCM_DELAY 1
+
static struct snd_ratden toneport_ratden = {
.num_min = 44100,
.num_max = 44100,
@@ -33,6 +37,9 @@ static struct line6_pcm_properties toneport_pcm_properties = {
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_PAUSE |
+#ifdef CONFIG_PM
+ SNDRV_PCM_INFO_RESUME |
+#endif
SNDRV_PCM_INFO_SYNC_START),
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rates = SNDRV_PCM_RATE_KNOT,
@@ -41,7 +48,7 @@ static struct line6_pcm_properties toneport_pcm_properties = {
.channels_min = 2,
.channels_max = 2,
.buffer_bytes_max = 60000,
- .period_bytes_min = 180 * 4,
+ .period_bytes_min = 64,
.period_bytes_max = 8192,
.periods_min = 1,
.periods_max = 1024},
@@ -50,6 +57,9 @@ static struct line6_pcm_properties toneport_pcm_properties = {
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_MMAP_VALID |
+#ifdef CONFIG_PM
+ SNDRV_PCM_INFO_RESUME |
+#endif
SNDRV_PCM_INFO_SYNC_START),
.formats = SNDRV_PCM_FMTBIT_S16_LE,
.rates = SNDRV_PCM_RATE_KNOT,
@@ -58,7 +68,7 @@ static struct line6_pcm_properties toneport_pcm_properties = {
.channels_min = 2,
.channels_max = 2,
.buffer_bytes_max = 60000,
- .period_bytes_min = 188 * 4,
+ .period_bytes_min = 64,
.period_bytes_max = 8192,
.periods_min = 1,
.periods_max = 1024},
@@ -77,6 +87,26 @@ static struct line6_pcm_properties toneport_pcm_properties = {
static int led_red = 0x00;
static int led_green = 0x26;
+struct ToneportSourceInfo {
+ const char *name;
+ int code;
+};
+
+static const struct ToneportSourceInfo toneport_source_info[] = {
+ {"Microphone", 0x0a01},
+ {"Line", 0x0801},
+ {"Instrument", 0x0b01},
+ {"Inst & Mic", 0x0901}
+};
+
+static bool toneport_has_led(short product)
+{
+ return
+ (product == LINE6_DEVID_GUITARPORT) ||
+ (product == LINE6_DEVID_TONEPORT_GX);
+ /* add your device here if you are missing support for the LEDs */
+}
+
static void toneport_update_led(struct device *dev)
{
struct usb_interface *interface = to_usb_interface(dev);
@@ -145,6 +175,120 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
return 0;
}
+/* monitor info callback */
+static int snd_toneport_monitor_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 256;
+ return 0;
+}
+
+/* monitor get callback */
+static int snd_toneport_monitor_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+ ucontrol->value.integer.value[0] = line6pcm->volume_monitor;
+ return 0;
+}
+
+/* monitor put callback */
+static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+
+ if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
+ return 0;
+
+ line6pcm->volume_monitor = ucontrol->value.integer.value[0];
+
+ if (line6pcm->volume_monitor > 0)
+ line6_pcm_start(line6pcm, MASK_PCM_MONITOR);
+ else
+ line6_pcm_stop(line6pcm, MASK_PCM_MONITOR);
+
+ return 1;
+}
+
+/* source info callback */
+static int snd_toneport_source_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo)
+{
+ const int size = ARRAY_SIZE(toneport_source_info);
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+ uinfo->count = 1;
+ uinfo->value.enumerated.items = size;
+
+ if (uinfo->value.enumerated.item >= size)
+ uinfo->value.enumerated.item = size - 1;
+
+ strcpy(uinfo->value.enumerated.name,
+ toneport_source_info[uinfo->value.enumerated.item].name);
+
+ return 0;
+}
+
+/* source get callback */
+static int snd_toneport_source_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+ struct usb_line6_toneport *toneport =
+ (struct usb_line6_toneport *)line6pcm->line6;
+ ucontrol->value.enumerated.item[0] = toneport->source;
+ return 0;
+}
+
+/* source put callback */
+static int snd_toneport_source_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+ struct usb_line6_toneport *toneport =
+ (struct usb_line6_toneport *)line6pcm->line6;
+
+ if (ucontrol->value.enumerated.item[0] == toneport->source)
+ return 0;
+
+ toneport->source = ucontrol->value.enumerated.item[0];
+ toneport_send_cmd(toneport->line6.usbdev,
+ toneport_source_info[toneport->source].code, 0x0000);
+ return 1;
+}
+
+static void toneport_start_pcm(unsigned long arg)
+{
+ struct usb_line6_toneport *toneport = (struct usb_line6_toneport *)arg;
+ struct usb_line6 *line6 = &toneport->line6;
+ line6_pcm_start(line6->line6pcm, MASK_PCM_MONITOR);
+}
+
+/* control definition */
+static struct snd_kcontrol_new toneport_control_monitor = {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Monitor Playback Volume",
+ .index = 0,
+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
+ .info = snd_toneport_monitor_info,
+ .get = snd_toneport_monitor_get,
+ .put = snd_toneport_monitor_put
+};
+
+/* source selector definition */
+static struct snd_kcontrol_new toneport_control_source = {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "PCM Capture Source",
+ .index = 0,
+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
+ .info = snd_toneport_source_info,
+ .get = snd_toneport_source_get,
+ .put = snd_toneport_source_put
+};
+
/*
Toneport destructor.
*/
@@ -162,14 +306,43 @@ static void toneport_destruct(struct usb_interface *interface)
}
/*
- Init Toneport device.
+ Setup Toneport device.
+*/
+static void toneport_setup(struct usb_line6_toneport *toneport)
+{
+ int ticks;
+ struct usb_line6 *line6 = &toneport->line6;
+ struct usb_device *usbdev = line6->usbdev;
+
+ /* sync time on device with host: */
+ ticks = (int)get_seconds();
+ line6_write_data(line6, 0x80c6, &ticks, 4);
+
+ /* enable device: */
+ toneport_send_cmd(usbdev, 0x0301, 0x0000);
+
+ /* initialize source select: */
+ switch (usbdev->descriptor.idProduct) {
+ case LINE6_DEVID_TONEPORT_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ toneport_send_cmd(usbdev,
+ toneport_source_info[toneport->source].code,
+ 0x0000);
+ }
+
+ if (toneport_has_led(usbdev->descriptor.idProduct))
+ toneport_update_led(&usbdev->dev);
+}
+
+/*
+ Try to init Toneport device.
*/
-int toneport_init(struct usb_interface *interface,
- struct usb_line6_toneport *toneport)
+static int toneport_try_init(struct usb_interface *interface,
+ struct usb_line6_toneport *toneport)
{
- int err, ticks;
+ int err;
struct usb_line6 *line6 = &toneport->line6;
- struct usb_device *usbdev;
+ struct usb_device *usbdev = line6->usbdev;
if ((interface == NULL) || (toneport == NULL))
return -ENODEV;
@@ -177,64 +350,101 @@ int toneport_init(struct usb_interface *interface,
/* initialize audio system: */
err = line6_init_audio(line6);
if (err < 0) {
- toneport_destruct(interface);
return err;
}
/* initialize PCM subsystem: */
err = line6_init_pcm(line6, &toneport_pcm_properties);
if (err < 0) {
- toneport_destruct(interface);
return err;
}
+ /* register monitor control: */
+ err =
+ snd_ctl_add(line6->card,
+ snd_ctl_new1(&toneport_control_monitor,
+ line6->line6pcm));
+ if (err < 0) {
+ return err;
+ }
+
+ /* register source select control: */
+ switch (usbdev->descriptor.idProduct) {
+ case LINE6_DEVID_TONEPORT_UX1:
+ case LINE6_DEVID_PODSTUDIO_UX1:
+ err =
+ snd_ctl_add(line6->card,
+ snd_ctl_new1(&toneport_control_source,
+ line6->line6pcm));
+ if (err < 0) {
+ return err;
+ }
+ }
+
/* register audio system: */
err = line6_register_audio(line6);
if (err < 0) {
- toneport_destruct(interface);
return err;
}
- usbdev = line6->usbdev;
line6_read_serial_number(line6, &toneport->serial_number);
line6_read_data(line6, 0x80c2, &toneport->firmware_version, 1);
- /* sync time on device with host: */
- ticks = (int)get_seconds();
- line6_write_data(line6, 0x80c6, &ticks, 4);
-
- /*
- seems to work without the first two...
- */
- /* toneport_send_cmd(usbdev, 0x0201, 0x0002); */
- /* toneport_send_cmd(usbdev, 0x0801, 0x0000); */
- /* only one that works for me; on GP, TP might be different? */
- toneport_send_cmd(usbdev, 0x0301, 0x0000);
-
- if (usbdev->descriptor.idProduct != LINE6_DEVID_GUITARPORT) {
+ if (toneport_has_led(usbdev->descriptor.idProduct)) {
CHECK_RETURN(device_create_file
(&interface->dev, &dev_attr_led_red));
CHECK_RETURN(device_create_file
(&interface->dev, &dev_attr_led_green));
- toneport_update_led(&usbdev->dev);
}
+ toneport_setup(toneport);
+
+ init_timer(&toneport->timer);
+ toneport->timer.expires = jiffies + TONEPORT_PCM_DELAY * HZ;
+ toneport->timer.function = toneport_start_pcm;
+ toneport->timer.data = (unsigned long)toneport;
+ add_timer(&toneport->timer);
+
return 0;
}
/*
+ Init Toneport device (and clean up in case of failure).
+*/
+int line6_toneport_init(struct usb_interface *interface,
+ struct usb_line6_toneport *toneport)
+{
+ int err = toneport_try_init(interface, toneport);
+
+ if (err < 0) {
+ toneport_destruct(interface);
+ }
+
+ return err;
+}
+
+/*
+ Resume Toneport device after reset.
+*/
+void line6_toneport_reset_resume(struct usb_line6_toneport *toneport)
+{
+ toneport_setup(toneport);
+}
+
+/*
Toneport device disconnected.
*/
-void toneport_disconnect(struct usb_interface *interface)
+void line6_toneport_disconnect(struct usb_interface *interface)
{
struct usb_line6_toneport *toneport;
if (interface == NULL)
return;
+
toneport = usb_get_intfdata(interface);
+ del_timer_sync(&toneport->timer);
- if (toneport->line6.usbdev->descriptor.idProduct !=
- LINE6_DEVID_GUITARPORT) {
+ if (toneport_has_led(toneport->line6.usbdev->descriptor.idProduct)) {
device_remove_file(&interface->dev, &dev_attr_led_red);
device_remove_file(&interface->dev, &dev_attr_led_green);
}
@@ -243,8 +453,8 @@ void toneport_disconnect(struct usb_interface *interface)
struct snd_line6_pcm *line6pcm = toneport->line6.line6pcm;
if (line6pcm != NULL) {
- unlink_wait_clear_audio_out_urbs(line6pcm);
- unlink_wait_clear_audio_in_urbs(line6pcm);
+ line6_pcm_stop(line6pcm, MASK_PCM_MONITOR);
+ line6_pcm_disconnect(line6pcm);
}
}
diff --git a/drivers/staging/line6/toneport.h b/drivers/staging/line6/toneport.h
index bddc58dd7e3a..8576b7263648 100644
--- a/drivers/staging/line6/toneport.h
+++ b/drivers/staging/line6/toneport.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,34 +12,41 @@
#ifndef TONEPORT_H
#define TONEPORT_H
-
-#include "driver.h"
-
#include <linux/usb.h>
#include <sound/core.h>
+#include "driver.h"
struct usb_line6_toneport {
/**
- Generic Line6 USB data.
+ Generic Line6 USB data.
*/
struct usb_line6 line6;
/**
- Serial number of device.
+ Source selector.
+ */
+ int source;
+
+ /**
+ Serial number of device.
*/
int serial_number;
/**
- Firmware version (x 100).
+ Firmware version (x 100).
*/
int firmware_version;
-};
-
-extern void toneport_disconnect(struct usb_interface *interface);
-extern int toneport_init(struct usb_interface *interface,
- struct usb_line6_toneport *toneport);
+ /**
+ Timer for delayed PCM startup.
+ */
+ struct timer_list timer;
+};
+extern void line6_toneport_disconnect(struct usb_interface *interface);
+extern int line6_toneport_init(struct usb_interface *interface,
+ struct usb_line6_toneport *toneport);
+extern void line6_toneport_reset_resume(struct usb_line6_toneport *toneport);
#endif
diff --git a/drivers/staging/line6/usbdefs.h b/drivers/staging/line6/usbdefs.h
index c38f31f2f421..a8a43a28a972 100644
--- a/drivers/staging/line6/usbdefs.h
+++ b/drivers/staging/line6/usbdefs.h
@@ -1,5 +1,5 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
* Copyright (C) 2005-2008 Markus Grabner (grabner@icg.tugraz.at)
*
@@ -12,7 +12,6 @@
#ifndef USBDEFS_H
#define USBDEFS_H
-
#define LINE6_VENDOR_ID 0x0e41
#define USB_INTERVALS_PER_SECOND 1000
@@ -25,6 +24,9 @@
#define LINE6_DEVID_BASSPODXTPRO 0x4252
#define LINE6_DEVID_GUITARPORT 0x4750
#define LINE6_DEVID_POCKETPOD 0x5051
+#define LINE6_DEVID_PODSTUDIO_GX 0x4153
+#define LINE6_DEVID_PODSTUDIO_UX1 0x4150
+#define LINE6_DEVID_PODSTUDIO_UX2 0x4151
#define LINE6_DEVID_PODX3 0x414a
#define LINE6_DEVID_PODX3LIVE 0x414b
#define LINE6_DEVID_PODXT 0x5044
@@ -35,20 +37,23 @@
#define LINE6_DEVID_TONEPORT_UX2 0x4142
#define LINE6_DEVID_VARIAX 0x534d
-#define LINE6_BIT_BASSPODXT (1 << 0)
-#define LINE6_BIT_BASSPODXTLIVE (1 << 1)
-#define LINE6_BIT_BASSPODXTPRO (1 << 2)
-#define LINE6_BIT_GUITARPORT (1 << 3)
-#define LINE6_BIT_POCKETPOD (1 << 4)
-#define LINE6_BIT_PODX3 (1 << 5)
-#define LINE6_BIT_PODX3LIVE (1 << 6)
-#define LINE6_BIT_PODXT (1 << 7)
-#define LINE6_BIT_PODXTLIVE (1 << 8)
-#define LINE6_BIT_PODXTPRO (1 << 9)
-#define LINE6_BIT_TONEPORT_GX (1 << 10)
-#define LINE6_BIT_TONEPORT_UX1 (1 << 11)
-#define LINE6_BIT_TONEPORT_UX2 (1 << 12)
-#define LINE6_BIT_VARIAX (1 << 13)
+#define LINE6_BIT_BASSPODXT (1 << 0)
+#define LINE6_BIT_BASSPODXTLIVE (1 << 1)
+#define LINE6_BIT_BASSPODXTPRO (1 << 2)
+#define LINE6_BIT_GUITARPORT (1 << 3)
+#define LINE6_BIT_POCKETPOD (1 << 4)
+#define LINE6_BIT_PODSTUDIO_GX (1 << 5)
+#define LINE6_BIT_PODSTUDIO_UX1 (1 << 6)
+#define LINE6_BIT_PODSTUDIO_UX2 (1 << 7)
+#define LINE6_BIT_PODX3 (1 << 8)
+#define LINE6_BIT_PODX3LIVE (1 << 9)
+#define LINE6_BIT_PODXT (1 << 10)
+#define LINE6_BIT_PODXTLIVE (1 << 11)
+#define LINE6_BIT_PODXTPRO (1 << 12)
+#define LINE6_BIT_TONEPORT_GX (1 << 13)
+#define LINE6_BIT_TONEPORT_UX1 (1 << 14)
+#define LINE6_BIT_TONEPORT_UX2 (1 << 15)
+#define LINE6_BIT_VARIAX (1 << 16)
#define LINE6_BITS_PRO (LINE6_BIT_BASSPODXTPRO | \
LINE6_BIT_PODXTPRO)
@@ -66,7 +71,10 @@
#define LINE6_BIT_CONTROL (1 << 0)
/* device supports PCM input/output via USB */
#define LINE6_BIT_PCM (1 << 1)
-#define LINE6_BIT_CONTROL_PCM (LINE6_BIT_CONTROL | LINE6_BIT_PCM)
+/* device support hardware monitoring */
+#define LINE6_BIT_HWMON (1 << 2)
+
+#define LINE6_BIT_CONTROL_PCM_HWMON (LINE6_BIT_CONTROL | LINE6_BIT_PCM | LINE6_BIT_HWMON)
#define LINE6_FALLBACK_INTERVAL 10
#define LINE6_FALLBACK_MAXPACKETSIZE 16
diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c
index 58ddbe6393ff..3a46104a14a1 100644
--- a/drivers/staging/line6/variax.c
+++ b/drivers/staging/line6/variax.c
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -9,15 +9,13 @@
*
*/
-#include "driver.h"
-
#include <linux/slab.h>
#include "audio.h"
#include "control.h"
+#include "driver.h"
#include "variax.h"
-
#define VARIAX_SYSEX_CODE 7
#define VARIAX_SYSEX_PARAM 0x3b
#define VARIAX_SYSEX_ACTIVATE 0x2a
@@ -25,25 +23,57 @@
#define VARIAX_MODEL_MESSAGE_LENGTH 199
#define VARIAX_OFFSET_ACTIVATE 7
+/*
+ This message is sent by the device during initialization and identifies
+ the connected guitar model.
+*/
+static const char variax_init_model[] = {
+ 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x69, 0x02,
+ 0x00
+};
+
+/*
+ This message is sent by the device during initialization and identifies
+ the connected guitar version.
+*/
+static const char variax_init_version[] = {
+ 0xf0, 0x7e, 0x7f, 0x06, 0x02, 0x00, 0x01, 0x0c,
+ 0x07, 0x00, 0x00, 0x00
+};
+
+/*
+ This message is the last one sent by the device during initialization.
+*/
+static const char variax_init_done[] = {
+ 0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6b
+};
static const char variax_activate[] = {
0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x2a, 0x01,
0xf7
};
+
static const char variax_request_bank[] = {
0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x6d, 0xf7
};
+
static const char variax_request_model1[] = {
0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x05, 0x03,
0x00, 0x00, 0x00, 0xf7
};
+
static const char variax_request_model2[] = {
0xf0, 0x00, 0x01, 0x0c, 0x07, 0x00, 0x3c, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x03,
0x00, 0x00, 0x00, 0xf7
};
+/* forward declarations: */
+static int variax_create_files2(struct device *dev);
+static void variax_startup2(unsigned long data);
+static void variax_startup4(unsigned long data);
+static void variax_startup5(unsigned long data);
/*
Decode data transmitted by workbench.
@@ -60,42 +90,108 @@ static void variax_decode(const unsigned char *raw_data, unsigned char *data,
}
}
-static void variax_activate_timeout(unsigned long arg)
+static void variax_activate_async(struct usb_line6_variax *variax, int a)
{
- struct usb_line6_variax *variax = (struct usb_line6_variax *)arg;
- variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = 1;
+ variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = a;
line6_send_raw_message_async(&variax->line6, variax->buffer_activate,
sizeof(variax_activate));
}
/*
- Send an asynchronous activation request after a given interval.
+ Variax startup procedure.
+ This is a sequence of functions with special requirements (e.g., must
+ not run immediately after initialization, must not run in interrupt
+ context). After the last one has finished, the device is ready to use.
*/
-static void variax_activate_delayed(struct usb_line6_variax *variax,
- int seconds)
+
+static void variax_startup1(struct usb_line6_variax *variax)
{
- variax->activate_timer.expires = jiffies + seconds * HZ;
- variax->activate_timer.function = variax_activate_timeout;
- variax->activate_timer.data = (unsigned long)variax;
- add_timer(&variax->activate_timer);
+ CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_INIT);
+
+ /* delay startup procedure: */
+ line6_start_timer(&variax->startup_timer1, VARIAX_STARTUP_DELAY1,
+ variax_startup2, (unsigned long)variax);
}
-static void variax_startup_timeout(unsigned long arg)
+static void variax_startup2(unsigned long data)
{
- struct usb_line6_variax *variax = (struct usb_line6_variax *)arg;
+ struct usb_line6_variax *variax = (struct usb_line6_variax *)data;
+ struct usb_line6 *line6 = &variax->line6;
- if (variax->dumpreq.ok)
+ /* schedule another startup procedure until startup is complete: */
+ if (variax->startup_progress >= VARIAX_STARTUP_LAST)
return;
- line6_dump_request_async(&variax->dumpreq, &variax->line6, 0);
- line6_startup_delayed(&variax->dumpreq, 1, variax_startup_timeout,
- variax);
+ variax->startup_progress = VARIAX_STARTUP_VERSIONREQ;
+ line6_start_timer(&variax->startup_timer1, VARIAX_STARTUP_DELAY1,
+ variax_startup2, (unsigned long)variax);
+
+ /* request firmware version: */
+ line6_version_request_async(line6);
+}
+
+static void variax_startup3(struct usb_line6_variax *variax)
+{
+ CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_WAIT);
+
+ /* delay startup procedure: */
+ line6_start_timer(&variax->startup_timer2, VARIAX_STARTUP_DELAY3,
+ variax_startup4, (unsigned long)variax);
+}
+
+static void variax_startup4(unsigned long data)
+{
+ struct usb_line6_variax *variax = (struct usb_line6_variax *)data;
+ CHECK_STARTUP_PROGRESS(variax->startup_progress,
+ VARIAX_STARTUP_ACTIVATE);
+
+ /* activate device: */
+ variax_activate_async(variax, 1);
+ line6_start_timer(&variax->startup_timer2, VARIAX_STARTUP_DELAY4,
+ variax_startup5, (unsigned long)variax);
+}
+
+static void variax_startup5(unsigned long data)
+{
+ struct usb_line6_variax *variax = (struct usb_line6_variax *)data;
+ CHECK_STARTUP_PROGRESS(variax->startup_progress,
+ VARIAX_STARTUP_DUMPREQ);
+
+ /* current model dump: */
+ line6_dump_request_async(&variax->dumpreq, &variax->line6, 0,
+ VARIAX_DUMP_PASS1);
+ /* passes 2 and 3 are performed implicitly before entering variax_startup6 */
+}
+
+static void variax_startup6(struct usb_line6_variax *variax)
+{
+ CHECK_STARTUP_PROGRESS(variax->startup_progress,
+ VARIAX_STARTUP_WORKQUEUE);
+
+ /* schedule work for global work queue: */
+ schedule_work(&variax->startup_work);
+}
+
+static void variax_startup7(struct work_struct *work)
+{
+ struct usb_line6_variax *variax =
+ container_of(work, struct usb_line6_variax, startup_work);
+ struct usb_line6 *line6 = &variax->line6;
+
+ CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP);
+
+ /* ALSA audio interface: */
+ line6_register_audio(&variax->line6);
+
+ /* device files: */
+ line6_variax_create_files(0, 0, line6->ifcdev);
+ variax_create_files2(line6->ifcdev);
}
/*
Process a completely received message.
*/
-void variax_process_message(struct usb_line6_variax *variax)
+void line6_variax_process_message(struct usb_line6_variax *variax)
{
const unsigned char *buf = variax->line6.buffer_message;
@@ -115,12 +211,12 @@ void variax_process_message(struct usb_line6_variax *variax)
case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
variax->model = buf[1];
- line6_dump_request_async(&variax->dumpreq, &variax->line6, 0);
+ line6_dump_request_async(&variax->dumpreq, &variax->line6, 0,
+ VARIAX_DUMP_PASS1);
break;
case LINE6_RESET:
dev_info(variax->line6.ifcdev, "VARIAX reset\n");
- variax_activate_delayed(variax, VARIAX_ACTIVATE_DELAY);
break;
case LINE6_SYSEX_BEGIN:
@@ -130,32 +226,65 @@ void variax_process_message(struct usb_line6_variax *variax)
VARIAX_MODEL_MESSAGE_LENGTH) {
switch (variax->dumpreq.in_progress) {
case VARIAX_DUMP_PASS1:
- variax_decode(buf + VARIAX_MODEL_HEADER_LENGTH, (unsigned char *)&variax->model_data,
- (sizeof(variax->model_data.name) + sizeof(variax->model_data.control) / 2) * 2);
- line6_dump_request_async(&variax->dumpreq, &variax->line6, 1);
- line6_dump_started(&variax->dumpreq, VARIAX_DUMP_PASS2);
+ variax_decode(buf +
+ VARIAX_MODEL_HEADER_LENGTH,
+ (unsigned char *)
+ &variax->model_data,
+ (sizeof
+ (variax->model_data.
+ name) +
+ sizeof(variax->
+ model_data.
+ control)
+ / 2) * 2);
+ line6_dump_request_async
+ (&variax->dumpreq, &variax->line6,
+ 1, VARIAX_DUMP_PASS2);
break;
case VARIAX_DUMP_PASS2:
/* model name is transmitted twice, so skip it here: */
- variax_decode(buf + VARIAX_MODEL_HEADER_LENGTH,
- (unsigned char *)&variax->model_data.control + sizeof(variax->model_data.control) / 2,
- sizeof(variax->model_data.control) / 2 * 2);
- variax->dumpreq.ok = 1;
- line6_dump_request_async(&variax->dumpreq, &variax->line6, 2);
- line6_dump_started(&variax->dumpreq, VARIAX_DUMP_PASS3);
+ variax_decode(buf +
+ VARIAX_MODEL_HEADER_LENGTH,
+ (unsigned char *)
+ &variax->
+ model_data.control +
+ sizeof(variax->model_data.
+ control)
+ / 2,
+ sizeof(variax->model_data.
+ control)
+ / 2 * 2);
+ line6_dump_request_async
+ (&variax->dumpreq, &variax->line6,
+ 2, VARIAX_DUMP_PASS3);
}
} else {
- DEBUG_MESSAGES(dev_err(variax->line6.ifcdev, "illegal length %d of model data\n", variax->line6.message_length));
+ DEBUG_MESSAGES(dev_err
+ (variax->line6.ifcdev,
+ "illegal length %d of model data\n",
+ variax->line6.message_length));
line6_dump_finished(&variax->dumpreq);
}
} else if (memcmp(buf + 1, variax_request_bank + 1,
- sizeof(variax_request_bank) - 2) == 0) {
+ sizeof(variax_request_bank) - 2) == 0) {
memcpy(variax->bank,
buf + sizeof(variax_request_bank) - 1,
sizeof(variax->bank));
- variax->dumpreq.ok = 1;
line6_dump_finished(&variax->dumpreq);
+ variax_startup6(variax);
+ } else if (memcmp(buf + 1, variax_init_model + 1,
+ sizeof(variax_init_model) - 1) == 0) {
+ memcpy(variax->guitar,
+ buf + sizeof(variax_init_model),
+ sizeof(variax->guitar));
+ } else if (memcmp(buf + 1, variax_init_version + 1,
+ sizeof(variax_init_version) - 1) == 0) {
+ variax_startup3(variax);
+ } else if (memcmp(buf + 1, variax_init_done + 1,
+ sizeof(variax_init_done) - 1) == 0) {
+ /* notify of complete initialization: */
+ variax_startup4((unsigned long)variax);
}
break;
@@ -164,7 +293,9 @@ void variax_process_message(struct usb_line6_variax *variax)
break;
default:
- DEBUG_MESSAGES(dev_err(variax->line6.ifcdev, "Variax: unknown message %02X\n", buf[0]));
+ DEBUG_MESSAGES(dev_err
+ (variax->line6.ifcdev,
+ "Variax: unknown message %02X\n", buf[0]));
}
}
@@ -174,7 +305,8 @@ void variax_process_message(struct usb_line6_variax *variax)
static ssize_t variax_get_volume(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
return sprintf(buf, "%d\n", variax->volume);
}
@@ -185,7 +317,8 @@ static ssize_t variax_set_volume(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
unsigned long value;
int ret;
@@ -206,7 +339,8 @@ static ssize_t variax_set_volume(struct device *dev,
static ssize_t variax_get_model(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
return sprintf(buf, "%d\n", variax->model);
}
@@ -217,7 +351,8 @@ static ssize_t variax_set_model(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
unsigned long value;
int ret;
@@ -237,8 +372,10 @@ static ssize_t variax_set_model(struct device *dev,
static ssize_t variax_get_active(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
- return sprintf(buf, "%d\n", variax->buffer_activate[VARIAX_OFFSET_ACTIVATE]);
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
+ return sprintf(buf, "%d\n",
+ variax->buffer_activate[VARIAX_OFFSET_ACTIVATE]);
}
/*
@@ -248,7 +385,8 @@ static ssize_t variax_set_active(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
unsigned long value;
int ret;
@@ -256,9 +394,7 @@ static ssize_t variax_set_active(struct device *dev,
if (ret)
return ret;
- variax->buffer_activate[VARIAX_OFFSET_ACTIVATE] = value ? 1 : 0;
- line6_send_raw_message_async(&variax->line6, variax->buffer_activate,
- sizeof(variax_activate));
+ variax_activate_async(variax, value ? 1 : 0);
return count;
}
@@ -268,7 +404,8 @@ static ssize_t variax_set_active(struct device *dev,
static ssize_t variax_get_tone(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
return sprintf(buf, "%d\n", variax->tone);
}
@@ -279,7 +416,8 @@ static ssize_t variax_set_tone(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
unsigned long value;
int ret;
@@ -316,8 +454,9 @@ static ssize_t get_string(char *buf, const char *data, int length)
static ssize_t variax_get_name(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
- line6_wait_dump(&variax->dumpreq, 0);
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
+ line6_dump_wait_interruptible(&variax->dumpreq);
return get_string(buf, variax->model_data.name,
sizeof(variax->model_data.name));
}
@@ -328,8 +467,9 @@ static ssize_t variax_get_name(struct device *dev,
static ssize_t variax_get_bank(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
- line6_wait_dump(&variax->dumpreq, 0);
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
+ line6_dump_wait_interruptible(&variax->dumpreq);
return get_string(buf, variax->bank, sizeof(variax->bank));
}
@@ -339,9 +479,10 @@ static ssize_t variax_get_bank(struct device *dev,
static ssize_t variax_get_dump(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
int retval;
- retval = line6_wait_dump(&variax->dumpreq, 0);
+ retval = line6_dump_wait_interruptible(&variax->dumpreq);
if (retval < 0)
return retval;
memcpy(buf, &variax->model_data.control,
@@ -349,7 +490,25 @@ static ssize_t variax_get_dump(struct device *dev,
return sizeof(variax->model_data.control);
}
-#if CREATE_RAW_FILE
+/*
+ "read" request on "guitar" special file.
+*/
+static ssize_t variax_get_guitar(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
+ return sprintf(buf, "%s\n", variax->guitar);
+}
+
+#ifdef CONFIG_LINE6_USB_RAW
+
+static char *variax_alloc_sysex_buffer(struct usb_line6_variax *variax,
+ int code, int size)
+{
+ return line6_alloc_sysex_buffer(&variax->line6, VARIAX_SYSEX_CODE, code,
+ size);
+}
/*
"write" request on "raw" special file.
@@ -358,7 +517,8 @@ static ssize_t variax_set_raw2(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct usb_line6_variax *variax = usb_get_intfdata(to_usb_interface(dev));
+ struct usb_line6_variax *variax =
+ usb_get_intfdata(to_usb_interface(dev));
int size;
int i;
char *sysex;
@@ -389,20 +549,23 @@ static ssize_t variax_set_raw2(struct device *dev,
#endif
/* Variax workbench special files: */
-static DEVICE_ATTR(model, S_IWUGO | S_IRUGO, variax_get_model, variax_set_model);
-static DEVICE_ATTR(volume, S_IWUGO | S_IRUGO, variax_get_volume, variax_set_volume);
+static DEVICE_ATTR(model, S_IWUGO | S_IRUGO, variax_get_model,
+ variax_set_model);
+static DEVICE_ATTR(volume, S_IWUGO | S_IRUGO, variax_get_volume,
+ variax_set_volume);
static DEVICE_ATTR(tone, S_IWUGO | S_IRUGO, variax_get_tone, variax_set_tone);
static DEVICE_ATTR(name, S_IRUGO, variax_get_name, line6_nop_write);
static DEVICE_ATTR(bank, S_IRUGO, variax_get_bank, line6_nop_write);
static DEVICE_ATTR(dump, S_IRUGO, variax_get_dump, line6_nop_write);
-static DEVICE_ATTR(active, S_IWUGO | S_IRUGO, variax_get_active, variax_set_active);
+static DEVICE_ATTR(active, S_IWUGO | S_IRUGO, variax_get_active,
+ variax_set_active);
+static DEVICE_ATTR(guitar, S_IRUGO, variax_get_guitar, line6_nop_write);
-#if CREATE_RAW_FILE
+#ifdef CONFIG_LINE6_USB_RAW
static DEVICE_ATTR(raw, S_IWUGO, line6_nop_read, line6_set_raw);
static DEVICE_ATTR(raw2, S_IWUGO, line6_nop_read, variax_set_raw2);
#endif
-
/*
Variax destructor.
*/
@@ -418,13 +581,16 @@ static void variax_destruct(struct usb_interface *interface)
return;
line6_cleanup_audio(line6);
+ del_timer(&variax->startup_timer1);
+ del_timer(&variax->startup_timer2);
+ cancel_work_sync(&variax->startup_work);
+
/* free dump request data: */
line6_dumpreq_destructbuf(&variax->dumpreq, 2);
line6_dumpreq_destructbuf(&variax->dumpreq, 1);
line6_dumpreq_destruct(&variax->dumpreq);
kfree(variax->buffer_activate);
- del_timer_sync(&variax->activate_timer);
}
/*
@@ -440,7 +606,8 @@ static int variax_create_files2(struct device *dev)
CHECK_RETURN(device_create_file(dev, &dev_attr_bank));
CHECK_RETURN(device_create_file(dev, &dev_attr_dump));
CHECK_RETURN(device_create_file(dev, &dev_attr_active));
-#if CREATE_RAW_FILE
+ CHECK_RETURN(device_create_file(dev, &dev_attr_guitar));
+#ifdef CONFIG_LINE6_USB_RAW
CHECK_RETURN(device_create_file(dev, &dev_attr_raw));
CHECK_RETURN(device_create_file(dev, &dev_attr_raw2));
#endif
@@ -448,13 +615,17 @@ static int variax_create_files2(struct device *dev)
}
/*
- Init workbench device.
+ Try to init workbench device.
*/
-int variax_init(struct usb_interface *interface,
- struct usb_line6_variax *variax)
+static int variax_try_init(struct usb_interface *interface,
+ struct usb_line6_variax *variax)
{
int err;
+ init_timer(&variax->startup_timer1);
+ init_timer(&variax->startup_timer2);
+ INIT_WORK(&variax->startup_work, variax_startup7);
+
if ((interface == NULL) || (variax == NULL))
return -ENODEV;
@@ -464,7 +635,6 @@ int variax_init(struct usb_interface *interface,
if (err < 0) {
dev_err(&interface->dev, "Out of memory\n");
- variax_destruct(interface);
return err;
}
@@ -473,7 +643,6 @@ int variax_init(struct usb_interface *interface,
if (err < 0) {
dev_err(&interface->dev, "Out of memory\n");
- variax_destruct(interface);
return err;
}
@@ -482,7 +651,6 @@ int variax_init(struct usb_interface *interface,
if (err < 0) {
dev_err(&interface->dev, "Out of memory\n");
- variax_destruct(interface);
return err;
}
@@ -491,56 +659,45 @@ int variax_init(struct usb_interface *interface,
if (variax->buffer_activate == NULL) {
dev_err(&interface->dev, "Out of memory\n");
- variax_destruct(interface);
return -ENOMEM;
}
- init_timer(&variax->activate_timer);
-
- /* create sysfs entries: */
- err = variax_create_files(0, 0, &interface->dev);
- if (err < 0) {
- variax_destruct(interface);
- return err;
- }
-
- err = variax_create_files2(&interface->dev);
- if (err < 0) {
- variax_destruct(interface);
- return err;
- }
-
/* initialize audio system: */
err = line6_init_audio(&variax->line6);
if (err < 0) {
- variax_destruct(interface);
return err;
}
/* initialize MIDI subsystem: */
err = line6_init_midi(&variax->line6);
if (err < 0) {
- variax_destruct(interface);
return err;
}
- /* register audio system: */
- err = line6_register_audio(&variax->line6);
+ /* initiate startup procedure: */
+ variax_startup1(variax);
+ return 0;
+}
+
+/*
+ Init workbench device (and clean up in case of failure).
+*/
+int line6_variax_init(struct usb_interface *interface,
+ struct usb_line6_variax *variax)
+{
+ int err = variax_try_init(interface, variax);
+
if (err < 0) {
variax_destruct(interface);
- return err;
}
- variax_activate_delayed(variax, VARIAX_ACTIVATE_DELAY);
- line6_startup_delayed(&variax->dumpreq, VARIAX_STARTUP_DELAY,
- variax_startup_timeout, variax);
- return 0;
+ return err;
}
/*
Workbench device disconnected.
*/
-void variax_disconnect(struct usb_interface *interface)
+void line6_variax_disconnect(struct usb_interface *interface)
{
struct device *dev;
@@ -550,7 +707,7 @@ void variax_disconnect(struct usb_interface *interface)
if (dev != NULL) {
/* remove sysfs entries: */
- variax_remove_files(0, 0, dev);
+ line6_variax_remove_files(0, 0, dev);
device_remove_file(dev, &dev_attr_model);
device_remove_file(dev, &dev_attr_volume);
device_remove_file(dev, &dev_attr_tone);
@@ -558,7 +715,8 @@ void variax_disconnect(struct usb_interface *interface)
device_remove_file(dev, &dev_attr_bank);
device_remove_file(dev, &dev_attr_dump);
device_remove_file(dev, &dev_attr_active);
-#if CREATE_RAW_FILE
+ device_remove_file(dev, &dev_attr_guitar);
+#ifdef CONFIG_LINE6_USB_RAW
device_remove_file(dev, &dev_attr_raw);
device_remove_file(dev, &dev_attr_raw2);
#endif
diff --git a/drivers/staging/line6/variax.h b/drivers/staging/line6/variax.h
index ee330ba30898..e2999ab41b08 100644
--- a/drivers/staging/line6/variax.h
+++ b/drivers/staging/line6/variax.h
@@ -1,7 +1,7 @@
/*
- * Line6 Linux USB driver - 0.8.0
+ * Line6 Linux USB driver - 0.9.1beta
*
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
+ * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -12,21 +12,31 @@
#ifndef VARIAX_H
#define VARIAX_H
-
-#include "driver.h"
-
#include <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/wait.h>
-
#include <sound/core.h>
+#include "driver.h"
#include "dumprequest.h"
+#define VARIAX_STARTUP_DELAY1 1000
+#define VARIAX_STARTUP_DELAY3 100
+#define VARIAX_STARTUP_DELAY4 100
-#define VARIAX_ACTIVATE_DELAY 10
-#define VARIAX_STARTUP_DELAY 3
-
+/*
+ Stages of Variax startup procedure
+*/
+enum {
+ VARIAX_STARTUP_INIT = 1,
+ VARIAX_STARTUP_VERSIONREQ,
+ VARIAX_STARTUP_WAIT,
+ VARIAX_STARTUP_ACTIVATE,
+ VARIAX_STARTUP_DUMPREQ,
+ VARIAX_STARTUP_WORKQUEUE,
+ VARIAX_STARTUP_SETUP,
+ VARIAX_STARTUP_LAST = VARIAX_STARTUP_SETUP - 1
+};
enum {
VARIAX_DUMP_PASS1 = LINE6_DUMP_CURRENT,
@@ -34,75 +44,89 @@ enum {
VARIAX_DUMP_PASS3
};
-
/**
- Binary Variax model dump
+ Binary Variax model dump
*/
struct variax_model {
/**
- Header information (including program name).
+ Header information (including program name).
*/
unsigned char name[18];
/**
- Model parameters.
+ Model parameters.
*/
unsigned char control[78 * 2];
};
struct usb_line6_variax {
/**
- Generic Line6 USB data.
+ Generic Line6 USB data.
*/
struct usb_line6 line6;
/**
- Dump request structure.
- Append two extra buffers for 3-pass data query.
+ Dump request structure.
+ Append two extra buffers for 3-pass data query.
*/
- struct line6_dump_request dumpreq; struct line6_dump_reqbuf extrabuf[2];
+ struct line6_dump_request dumpreq;
+ struct line6_dump_reqbuf extrabuf[2];
/**
- Buffer for activation code.
+ Buffer for activation code.
*/
unsigned char *buffer_activate;
/**
- Model number.
+ Model number.
*/
int model;
/**
- Current model settings.
+ Current model settings.
*/
struct variax_model model_data;
/**
- Name of current model bank.
+ Name of connected guitar.
+ */
+ unsigned char guitar[18];
+
+ /**
+ Name of current model bank.
*/
unsigned char bank[18];
/**
- Position of volume dial.
+ Position of volume dial.
*/
int volume;
/**
- Position of tone control dial.
+ Position of tone control dial.
*/
int tone;
/**
- Timer for delayed activation request.
+ Handler for device initializaton.
*/
- struct timer_list activate_timer;
-};
+ struct work_struct startup_work;
+ /**
+ Timers for device initializaton.
+ */
+ struct timer_list startup_timer1;
+ struct timer_list startup_timer2;
-extern void variax_disconnect(struct usb_interface *interface);
-extern int variax_init(struct usb_interface *interface,
- struct usb_line6_variax *variax);
-extern void variax_process_message(struct usb_line6_variax *variax);
+ /**
+ Current progress in startup procedure.
+ */
+ int startup_progress;
+};
+extern void line6_variax_disconnect(struct usb_interface *interface);
+extern int line6_variax_init(struct usb_interface *interface,
+ struct usb_line6_variax *variax);
+extern void line6_variax_process_message(struct usb_line6_variax *variax);
#endif
diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c
index 66493253042e..818bec0bb912 100644
--- a/drivers/staging/lirc/lirc_imon.c
+++ b/drivers/staging/lirc/lirc_imon.c
@@ -320,7 +320,6 @@ static int send_packet(struct imon_context *context)
unsigned int pipe;
int interval = 0;
int retval = 0;
- struct usb_ctrlrequest *control_req = NULL;
/* Check if we need to use control or interrupt urb */
pipe = usb_sndintpipe(context->usbdev,
@@ -355,8 +354,6 @@ static int send_packet(struct imon_context *context)
err("%s: packet tx failed (%d)", __func__, retval);
}
- kfree(control_req);
-
return retval;
}
@@ -599,7 +596,7 @@ static void imon_incoming_packet(struct imon_context *context,
struct device *dev = context->driver->dev;
int octet, bit;
unsigned char mask;
- int i, chunk_num;
+ int i;
/*
* just bail out if no listening IR client
@@ -658,7 +655,7 @@ static void imon_incoming_packet(struct imon_context *context,
}
}
- if (chunk_num == 10) {
+ if (buf[7] == 10) {
if (context->rx.count) {
submit_data(context);
context->rx.count = 0;
diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c
index 73166c3f581f..856487eecd24 100644
--- a/drivers/staging/lirc/lirc_sasem.c
+++ b/drivers/staging/lirc/lirc_sasem.c
@@ -512,7 +512,7 @@ exit:
mutex_unlock(&context->ctx_lock);
mutex_unlock(&disconnect_lock);
- return 0;
+ return retval;
}
/**
diff --git a/drivers/staging/mrst-touchscreen/Makefile b/drivers/staging/mrst-touchscreen/Makefile
index 2d638b0d70bf..155f58b57dbe 100644
--- a/drivers/staging/mrst-touchscreen/Makefile
+++ b/drivers/staging/mrst-touchscreen/Makefile
@@ -1,3 +1,3 @@
-obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) := intel_mid_touch.o
+obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) := intel-mid-touch.o
diff --git a/drivers/staging/mrst-touchscreen/intel-mid-touch.c b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
index abba22f921be..031b2f8f5558 100644
--- a/drivers/staging/mrst-touchscreen/intel-mid-touch.c
+++ b/drivers/staging/mrst-touchscreen/intel-mid-touch.c
@@ -157,8 +157,8 @@ static int mrstouch_pmic_id(uint *vendor, uint *rev)
*/
static int mrstouch_chan_parse(struct mrstouch_dev *tsdev)
{
- int err, i, j, found;
- u32 r32;
+ int err, i, found;
+ u8 r8;
found = -1;
@@ -166,15 +166,13 @@ static int mrstouch_chan_parse(struct mrstouch_dev *tsdev)
if (found >= 0)
break;
- err = intel_scu_ipc_ioread32(PMICADDR0, &r32);
+ err = intel_scu_ipc_ioread8(PMICADDR0 + i, &r8);
if (err)
return err;
- for (j = 0; j < 32; j+= 8) {
- if (((r32 >> j) & 0xFF) == END_OF_CHANNEL) {
- found = i;
- break;
- }
+ if (r8 == END_OF_CHANNEL) {
+ found = i;
+ break;
}
}
if (found < 0)
@@ -284,20 +282,17 @@ static int mrstouch_ts_chan_read(u16 offset, u16 chan, u16 *vp, u16 *vm)
*/
static int mrstouch_ts_chan_set(uint offset)
{
- int count;
u16 chan;
- u16 reg[5];
- u8 data[5];
+
+ int ret, count;
chan = PMICADDR0 + offset;
for (count = 0; count <= 3; count++) {
- reg[count] = chan++;
- data[count] = MRST_TS_CHAN10 + count;
+ ret = intel_scu_ipc_iowrite8(chan++, MRST_TS_CHAN10 + count);
+ if (ret)
+ return ret;
}
- reg[count] = chan;
- data[count] = END_OF_CHANNEL;
-
- return intel_scu_ipc_writev(reg, data, 5);
+ return intel_scu_ipc_iowrite8(chan++, END_OF_CHANNEL);
}
/* Initialize ADC */
diff --git a/drivers/staging/otus/80211core/ratectrl.c b/drivers/staging/otus/80211core/ratectrl.c
index a1abe2f4f342..283b2b52638c 100644
--- a/drivers/staging/otus/80211core/ratectrl.c
+++ b/drivers/staging/otus/80211core/ratectrl.c
@@ -422,23 +422,15 @@ u8_t zfRateCtrlRateDiff(struct zsRcCell* rcCell, u8_t retryRate)
u16_t i;
/* Find retryRate in operationRateSet[] */
- for (i=0; i<rcCell->operationRateCount; i++)
- {
- if (retryRate == rcCell->operationRateSet[i])
- {
- if (i < rcCell->currentRateIndex)
- {
- return ((rcCell->currentRateIndex - i)+1)>>1;
- }
- else if (i == rcCell->currentRateIndex == 0)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
+ for (i = 0; i < rcCell->operationRateCount; i++) {
+ if (retryRate == rcCell->operationRateSet[i]) {
+ if (i < rcCell->currentRateIndex)
+ return ((rcCell->currentRateIndex - i)+1)>>1;
+ else if (i == rcCell->currentRateIndex && i == 0)
+ return 1;
+ else
+ return 0;
+ }
}
/* TODO : retry rate not in operation rate set */
zm_msg1_tx(ZM_LV_0, "Not in operation rate set:", retryRate);
diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c
index 8c8d1c282e7e..89279ba1b737 100644
--- a/drivers/staging/pohmelfs/config.c
+++ b/drivers/staging/pohmelfs/config.c
@@ -301,10 +301,8 @@ static int pohmelfs_cn_dump(struct cn_msg *msg)
mutex_lock(&pohmelfs_config_lock);
- list_for_each_entry(g, &pohmelfs_config_list, group_entry) {
- if (g)
- total_msg += g->num_entry;
- }
+ list_for_each_entry(g, &pohmelfs_config_list, group_entry)
+ total_msg += g->num_entry;
if (total_msg == 0) {
if (pohmelfs_send_reply(err, 0, POHMELFS_NOINFO_ACK, msg, NULL))
err = -ENOMEM;
@@ -312,15 +310,16 @@ static int pohmelfs_cn_dump(struct cn_msg *msg)
}
list_for_each_entry(g, &pohmelfs_config_list, group_entry) {
- if (g) {
- list_for_each_entry_safe(c, tmp, &g->config_list, config_entry) {
- struct pohmelfs_ctl *sc = &c->state.ctl;
- if (pohmelfs_send_reply(err, total_msg - i, POHMELFS_CTLINFO_ACK, msg, sc)) {
- err = -ENOMEM;
- goto out_unlock;
- }
- i += 1;
+ list_for_each_entry_safe(c, tmp, &g->config_list,
+ config_entry) {
+ struct pohmelfs_ctl *sc = &c->state.ctl;
+ if (pohmelfs_send_reply(err, total_msg - i,
+ POHMELFS_CTLINFO_ACK, msg,
+ sc)) {
+ err = -ENOMEM;
+ goto out_unlock;
}
+ i += 1;
}
}
@@ -354,12 +353,11 @@ static int pohmelfs_cn_flush(struct cn_msg *msg)
}
} else {
list_for_each_entry(g, &pohmelfs_config_list, group_entry) {
- if (g) {
- list_for_each_entry_safe(c, tmp, &g->config_list, config_entry) {
- list_del(&c->config_entry);
- g->num_entry--;
- kfree(c);
- }
+ list_for_each_entry_safe(c, tmp, &g->config_list,
+ config_entry) {
+ list_del(&c->config_entry);
+ g->num_entry--;
+ kfree(c);
}
}
}
diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c
index 66122479d529..33c09fad1856 100644
--- a/drivers/staging/quickstart/quickstart.c
+++ b/drivers/staging/quickstart/quickstart.c
@@ -398,16 +398,15 @@ static int __init quickstart_init_input(void)
static int __init quickstart_init(void)
{
int ret;
- acpi_status status = 0;
/* ACPI Check */
if (acpi_disabled)
return -ENODEV;
/* ACPI driver register */
- status = acpi_bus_register_driver(&quickstart_acpi_driver);
- if (status < 0)
- return -ENODEV;
+ ret = acpi_bus_register_driver(&quickstart_acpi_driver);
+ if (ret)
+ return ret;
/* If existing bus with no devices */
if (!quickstart_data.btn_lst) {
diff --git a/drivers/staging/rt2860/ap.h b/drivers/staging/rt2860/ap.h
index faac85d931d1..2737c0c022f9 100644
--- a/drivers/staging/rt2860/ap.h
+++ b/drivers/staging/rt2860/ap.h
@@ -24,18 +24,18 @@
* *
*************************************************************************
- Module Name:
- ap.h
+Module Name:
+ap.h
- Abstract:
- Miniport generic portion header file
+Abstract:
+Miniport generic portion header file
- Revision History:
- Who When What
- -------- ---------- ----------------------------------------------
- Paul Lin 08-01-2002 created
- James Tan 09-06-2002 modified (Revise NTCRegTable)
- John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
+Revision History:
+Who When What
+-------- ---------- ----------------------------------------------
+Paul Lin 08-01-2002 created
+James Tan 09-06-2002 modified (Revise NTCRegTable)
+John Chang 12-22-2004 modified for RT2561/2661. merge with STA driver
*/
#ifndef __AP_H__
#define __AP_H__
diff --git a/drivers/staging/rt2860/eeprom.h b/drivers/staging/rt2860/eeprom.h
index 039801a97099..72c8fb941655 100644
--- a/drivers/staging/rt2860/eeprom.h
+++ b/drivers/staging/rt2860/eeprom.h
@@ -42,7 +42,7 @@
* Public function declarations for prom-based chipset
************************************************************************/
int rtmp_ee_prom_read16(struct rt_rtmp_adapter *pAd,
- u16 Offset, u16 * pValue);
+ u16 Offset, u16 *pValue);
#endif /* RTMP_PCI_SUPPORT // */
#ifdef RTMP_USB_SUPPORT
/*************************************************************************
@@ -55,7 +55,7 @@ int RTUSBReadEEPROM16(struct rt_rtmp_adapter *pAd,
#ifdef RT30xx
#ifdef RTMP_EFUSE_SUPPORT
int rtmp_ee_efuse_read16(struct rt_rtmp_adapter *pAd,
- u16 Offset, u16 * pValue);
+ u16 Offset, u16 *pValue);
#endif /* RTMP_EFUSE_SUPPORT // */
#endif /* RT30xx // */
diff --git a/drivers/staging/rt2860/iface/rtmp_pci.h b/drivers/staging/rt2860/iface/rtmp_pci.h
index 7759d56a3043..3d66e386bd8a 100644
--- a/drivers/staging/rt2860/iface/rtmp_pci.h
+++ b/drivers/staging/rt2860/iface/rtmp_pci.h
@@ -32,7 +32,7 @@
((struct os_cookie *)handle)->pci_dev = dev_p;
#ifdef LINUX
-// set driver data
+/* set driver data */
#define RT28XX_DRVDATA_SET(_a) pci_set_drvdata(_a, net_dev);
#define RT28XX_PUT_DEVICE(dev_p)
@@ -42,7 +42,8 @@
#ifdef PCI_MSI_SUPPORT
#define RTMP_MSI_ENABLE(_pAd) \
{ struct os_cookie *_pObj = (struct os_cookie *)(_pAd->OS_Cookie); \
- (_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) == 0 ? TRUE : FALSE; \
+ (_pAd)->HaveMsi = pci_enable_msi(_pObj->pci_dev) \
+ == 0 ? TRUE : FALSE; \
}
#define RTMP_MSI_DISABLE(_pAd) \
@@ -52,27 +53,28 @@
_pAd->HaveMsi = FALSE; \
}
#else
-#define RTMP_MSI_ENABLE(_pAd) do{}while(0)
-#define RTMP_MSI_DISABLE(_pAd) do{}while(0)
-#endif // PCI_MSI_SUPPORT //
+#define RTMP_MSI_ENABLE(_pAd) do {} while (0)
+#define RTMP_MSI_DISABLE(_pAd) do {} while (0)
+#endif /* PCI_MSI_SUPPORT */
-#define RTMP_PCI_DEV_UNMAP() \
-{ if (net_dev->base_addr) { \
- iounmap((void *)(net_dev->base_addr)); \
+#define RTMP_PCI_DEV_UNMAP() \
+{ if (net_dev->base_addr) { \
+ iounmap((void *)(net_dev->base_addr)); \
release_mem_region(pci_resource_start(dev_p, 0), \
- pci_resource_len(dev_p, 0)); } \
- if (net_dev->irq) pci_release_regions(dev_p); }
+ pci_resource_len(dev_p, 0)); } \
+ if (net_dev->irq) \
+ pci_release_regions(dev_p); }
-#define PCI_REG_READ_WORD(pci_dev, offset, Configuration) \
- if (pci_read_config_word(pci_dev, offset, &reg16) == 0) \
- Configuration = le2cpu16(reg16); \
- else \
- Configuration = 0;
+#define PCI_REG_READ_WORD(pci_dev, offset, Configuration) {\
+ if (pci_read_config_word(pci_dev, offset, &reg16) == 0) \
+ Configuration = le2cpu16(reg16); \
+ else \
+ Configuration = 0; }
-#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration) \
- reg16 = cpu2le16(Configuration); \
- pci_write_config_word(pci_dev, offset, reg16);
+#define PCI_REG_WIRTE_WORD(pci_dev, offset, Configuration) {\
+ reg16 = cpu2le16(Configuration); \
+ pci_write_config_word(pci_dev, offset, reg16); }
-#endif // LINUX //
+#endif /* LINUX */
-#endif // __RTMP_PCI_H__ //
+#endif /* __RTMP_PCI_H__ */
diff --git a/drivers/staging/rt2860/iface/rtmp_usb.h b/drivers/staging/rt2860/iface/rtmp_usb.h
index 33479cc443a5..571289637973 100644
--- a/drivers/staging/rt2860/iface/rtmp_usb.h
+++ b/drivers/staging/rt2860/iface/rtmp_usb.h
@@ -32,41 +32,40 @@
#ifdef LINUX
#include <linux/usb.h>
-#endif // LINUX //
+#endif /* LINUX */
extern u8 EpToQueue[6];
#define RXBULKAGGRE_ZISE 12
-#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
-#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
-#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
+#define MAX_TXBULK_LIMIT (LOCAL_TXBUF_SIZE*(BULKAGGRE_ZISE-1))
+#define MAX_TXBULK_SIZE (LOCAL_TXBUF_SIZE*BULKAGGRE_ZISE)
+#define MAX_RXBULK_SIZE (LOCAL_TXBUF_SIZE*RXBULKAGGRE_ZISE)
#define MAX_MLME_HANDLER_MEMORY 20
-// Flags for Bulkflags control for bulk out data
-//
+/* Flags for Bulkflags control for bulk out data */
#define fRTUSB_BULK_OUT_DATA_NULL 0x00000001
-#define fRTUSB_BULK_OUT_RTS 0x00000002
-#define fRTUSB_BULK_OUT_MLME 0x00000004
+#define fRTUSB_BULK_OUT_RTS 0x00000002
+#define fRTUSB_BULK_OUT_MLME 0x00000004
-#define fRTUSB_BULK_OUT_PSPOLL 0x00000010
+#define fRTUSB_BULK_OUT_PSPOLL 0x00000010
#define fRTUSB_BULK_OUT_DATA_FRAG 0x00000020
-#define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000040
-#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000080
-#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000100
+#define fRTUSB_BULK_OUT_DATA_FRAG_2 0x00000040
+#define fRTUSB_BULK_OUT_DATA_FRAG_3 0x00000080
+#define fRTUSB_BULK_OUT_DATA_FRAG_4 0x00000100
-#define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000
+#define fRTUSB_BULK_OUT_DATA_NORMAL 0x00010000
#define fRTUSB_BULK_OUT_DATA_NORMAL_2 0x00020000
#define fRTUSB_BULK_OUT_DATA_NORMAL_3 0x00040000
#define fRTUSB_BULK_OUT_DATA_NORMAL_4 0x00080000
-// TODO:move to ./ate/include/iface/ate_usb.h
+/* TODO:move to ./ate/include/iface/ate_usb.h */
#define FREE_HTTX_RING(_pCookie, _pipeId, _txContext) \
-{ \
- if ((_txContext)->ENextBulkOutPosition == (_txContext)->CurWritePosition) \
- { \
+{ \
+ if ((_txContext)->ENextBulkOutPosition == \
+ (_txContext)->CurWritePosition) {\
(_txContext)->bRingEmpty = TRUE; \
- } \
+ } \
/*NdisInterlockedDecrement(&(_p)->TxCount); */\
}
@@ -77,16 +76,32 @@ extern u8 EpToQueue[6];
******************************************************************************/
#ifdef LINUX
-#define BULKAGGRE_ZISE 100
-#define RT28XX_PUT_DEVICE usb_put_dev
-#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
-#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, GFP_ATOMIC)
-#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, BufSize, pDma_addr) usb_alloc_coherent(pUsb_Dev, BufSize, GFP_ATOMIC, pDma_addr)
-#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, BufSize, pTransferBuf, Dma_addr) usb_free_coherent(pUsb_Dev, BufSize, pTransferBuf, Dma_addr)
+#define BULKAGGRE_ZISE 100
+#define RT28XX_PUT_DEVICE usb_put_dev
+#define RTUSB_ALLOC_URB(iso) usb_alloc_urb(iso, GFP_ATOMIC)
+#define RTUSB_SUBMIT_URB(pUrb) usb_submit_urb(pUrb, \
+ GFP_ATOMIC)
+#define RTUSB_URB_ALLOC_BUFFER(pUsb_Dev, \
+ BufSize, \
+ pDma_addr) \
+ usb_alloc_coherent(\
+ pUsb_Dev, \
+ BufSize, \
+ GFP_ATOMIC, \
+ pDma_addr)
+#define RTUSB_URB_FREE_BUFFER(pUsb_Dev, \
+ BufSize, \
+ pTransferBuf, \
+ Dma_addr) \
+ usb_free_coherent( \
+ pUsb_Dev, \
+ BufSize, \
+ pTransferBuf, \
+ Dma_addr)
#define RTUSB_FREE_URB(pUrb) usb_free_urb(pUrb)
-// unlink urb
+/* unlink urb */
#define RTUSB_UNLINK_URB(pUrb) usb_kill_urb(pUrb)
extern void dump_urb(struct urb *purb);
@@ -97,9 +112,9 @@ extern void dump_urb(struct urb *purb);
#define NdisInterlockedDecrement atomic_dec
#define InterlockedExchange atomic_set
-#endif // LINUX //
+#endif /* LINUX */
-#define NT_SUCCESS(status) (((status) >=0) ? (TRUE):(FALSE))
+#define NT_SUCCESS(status) (((status) >= 0) ? (TRUE) : (FALSE))
#define USBD_TRANSFER_DIRECTION_OUT 0
#define USBD_TRANSFER_DIRECTION_IN 0
@@ -112,8 +127,8 @@ extern void dump_urb(struct urb *purb);
#define USB_ST_NOERROR 0
#endif
-// vendor-specific control operations
-#define CONTROL_TIMEOUT_JIFFIES ( (100 * OS_HZ) / 1000)
+/* vendor-specific control operations */
+#define CONTROL_TIMEOUT_JIFFIES ((100 * OS_HZ) / 1000)
#define UNLINK_TIMEOUT_MS 3
void RTUSBBulkOutDataPacketComplete(struct urb *purb, struct pt_regs *pt_regs);
@@ -125,50 +140,49 @@ void RTUSBBulkRxComplete(struct urb *pUrb, struct pt_regs *pt_regs);
#ifdef KTHREAD_SUPPORT
#define RTUSBMlmeUp(pAd) \
- do{ \
+ do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
- if (_pTask->kthread_task) \
- { \
+ if (_pTask->kthread_task) {\
_pTask->kthread_running = TRUE; \
- wake_up(&_pTask->kthread_q); \
+ wake_up(&_pTask->kthread_q); \
} \
- }while(0)
+ } while (0)
#else
#define RTUSBMlmeUp(pAd) \
- do{ \
+ do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->mlmeTask);\
CHECK_PID_LEGALITY(_pTask->taskPID) \
{ \
RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
- }\
- }while(0)
+ } \
+ } while (0)
#endif
#ifdef KTHREAD_SUPPORT
#define RTUSBCMDUp(pAd) \
- do{ \
+ do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask); \
{ \
_pTask->kthread_running = TRUE; \
- wake_up(&_pTask->kthread_q); \
+ wake_up(&_pTask->kthread_q); \
} \
- }while(0)
+ } while (0)
#else
#define RTUSBCMDUp(pAd) \
- do{ \
+ do { \
struct rt_rtmp_os_task *_pTask = &((pAd)->cmdQTask); \
CHECK_PID_LEGALITY(_pTask->taskPID) \
{\
RTMP_SEM_EVENT_UP(&(_pTask->taskSema)); \
- }\
- }while(0)
+ } \
+ } while (0)
#endif
#define DEVICE_VENDOR_REQUEST_OUT 0x40
#define DEVICE_VENDOR_REQUEST_IN 0xc0
-//#define INTERFACE_VENDOR_REQUEST_OUT 0x41
-//#define INTERFACE_VENDOR_REQUEST_IN 0xc1
+/*#define INTERFACE_VENDOR_REQUEST_OUT 0x41*/
+/*#define INTERFACE_VENDOR_REQUEST_IN 0xc1*/
#define BULKOUT_MGMT_RESET_FLAG 0x80
@@ -176,7 +190,7 @@ void RTUSBBulkRxComplete(struct urb *pUrb, struct pt_regs *pt_regs);
#define RTUSB_CLEAR_BULK_FLAG(_M, _F) ((_M)->BulkFlags &= ~(_F))
#define RTUSB_TEST_BULK_FLAG(_M, _F) (((_M)->BulkFlags & (_F)) != 0)
-#define RTMP_IRQ_REQUEST(net_dev) do{}while(0)
-#define RTMP_IRQ_RELEASE(net_dev) do{}while(0)
+#define RTMP_IRQ_REQUEST(net_dev) do {} while (0)
+#define RTMP_IRQ_RELEASE(net_dev) do {} while (0)
-#endif // __RTMP_USB_H__ //
+#endif /* __RTMP_USB_H__ */
diff --git a/drivers/staging/rt2860/oid.h b/drivers/staging/rt2860/oid.h
index fd1c14192451..1704c27b2736 100644
--- a/drivers/staging/rt2860/oid.h
+++ b/drivers/staging/rt2860/oid.h
@@ -701,7 +701,7 @@ struct PACKED rt_rt_802_11_acl {
struct rt_802_11_wds {
unsigned long Num;
- NDIS_802_11_MAC_ADDRESS Entry[24 /*MAX_NUM_OF_WDS_LINK */ ];
+ NDIS_802_11_MAC_ADDRESS Entry[24 /*MAX_NUM_OF_WDS_LINK */];
unsigned long KeyLength;
u8 KeyMaterial[32];
};
diff --git a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h
index 282935caba2c..f133c8cb6807 100644
--- a/drivers/staging/rt2860/rtmp.h
+++ b/drivers/staging/rt2860/rtmp.h
@@ -2239,15 +2239,15 @@ struct rt_tx_blk {
unsigned long Priv; /* Hardware specific value saved in here. */
};
-#define fTX_bRtsRequired 0x0001 /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
-#define fTX_bAckRequired 0x0002 /* the packet need ack response */
-#define fTX_bPiggyBack 0x0004 /* Legacy device use Piggback or not */
-#define fTX_bHTRate 0x0008 /* allow to use HT rate */
-#define fTX_bForceNonQoS 0x0010 /* force to transmit frame without WMM-QoS in HT mode */
-#define fTX_bAllowFrag 0x0020 /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
-#define fTX_bMoreData 0x0040 /* there are more data packets in PowerSave Queue */
-#define fTX_bWMM 0x0080 /* QOS Data */
-#define fTX_bClearEAPFrame 0x0100
+#define fTX_bRtsRequired 0x0001 /* Indicate if need send RTS frame for protection. Not used in RT2860/RT2870. */
+#define fTX_bAckRequired 0x0002 /* the packet need ack response */
+#define fTX_bPiggyBack 0x0004 /* Legacy device use Piggback or not */
+#define fTX_bHTRate 0x0008 /* allow to use HT rate */
+#define fTX_bForceNonQoS 0x0010 /* force to transmit frame without WMM-QoS in HT mode */
+#define fTX_bAllowFrag 0x0020 /* allow to fragment the packet, A-MPDU, A-MSDU, A-Ralink is not allowed to fragment */
+#define fTX_bMoreData 0x0040 /* there are more data packets in PowerSave Queue */
+#define fTX_bWMM 0x0080 /* QOS Data */
+#define fTX_bClearEAPFrame 0x0100
#define TX_BLK_SET_FLAG(_pTxBlk, _flag) (_pTxBlk->Flags |= _flag)
#define TX_BLK_TEST_FLAG(_pTxBlk, _flag) (((_pTxBlk->Flags & _flag) == _flag) ? 1 : 0)
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 1b838a266e0d..652d879509e6 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -454,7 +454,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
goto out; /* scan completed */
}while(!channel_map[ch]);
- /* this fuction can be called in two situations
+ /* this function can be called in two situations
* 1- We have switched to ad-hoc mode and we are
* performing a complete syncro scan before conclude
* there are no interesting cell and to create a
@@ -517,7 +517,7 @@ void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee)
// printk("=======hh===============>ips scan\n");
while(1)
{
- /* this fuction can be called in two situations
+ /* this function can be called in two situations
* 1- We have switched to ad-hoc mode and we are
* performing a complete syncro scan before conclude
* there are no interesting cell and to create a
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index ed7457bc24ea..70ab0084e5f5 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -3547,6 +3547,7 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
struct net_device *dev = NULL;
struct r8180_priv *priv = NULL;
u8 unit = 0;
+ int ret = -ENODEV;
unsigned long pmem_start, pmem_len, pmem_flags;
@@ -3561,8 +3562,10 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
pci_set_dma_mask(pdev, 0xffffff00ULL);
pci_set_consistent_dma_mask(pdev, 0xffffff00ULL);
dev = alloc_ieee80211(sizeof(struct r8180_priv));
- if (!dev)
- return -ENOMEM;
+ if (!dev) {
+ ret = -ENOMEM;
+ goto fail_free;
+ }
priv = ieee80211_priv(dev);
priv->ieee80211 = netdev_priv(dev);
@@ -3641,11 +3644,12 @@ fail:
free_ieee80211(dev);
}
+fail_free:
pci_disable_device(pdev);
DMESG("wlan driver load failed\n");
pci_set_drvdata(pdev, NULL);
- return -ENODEV;
+ return ret;
}
static void __devexit rtl8180_pci_remove(struct pci_dev *pdev)
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
index 7edf5c897a68..08bfdb1a4c6e 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
@@ -69,7 +69,7 @@ static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
GFP_KERNEL);
if (!ieee->networks) {
printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
- ieee->dev->name);
+ ieee->dev->name);
return -ENOMEM;
}
@@ -99,7 +99,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
{
struct ieee80211_device *ieee;
struct net_device *dev;
- int i,err;
+ int i, err;
IEEE80211_DEBUG_INFO("Initializing...\n");
@@ -111,7 +111,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
ieee = netdev_priv(dev);
- memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
+ memset(ieee, 0, sizeof(struct ieee80211_device) + sizeof_priv);
ieee->dev = dev;
err = ieee80211_networks_allocate(ieee);
@@ -142,7 +142,8 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
spin_lock_init(&ieee->wpax_suitlist_lock);
spin_lock_init(&ieee->bw_spinlock);
spin_lock_init(&ieee->reorder_spinlock);
- //added by WB
+
+ /* added by WB */
atomic_set(&(ieee->atm_chnlop), 0);
atomic_set(&(ieee->atm_swbw), 0);
@@ -153,8 +154,8 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
ieee->privacy_invoked = 0;
ieee->ieee802_1x = 1;
ieee->raw_tx = 0;
- //ieee->hwsec_support = 1; //default support hw security. //use module_param instead.
- ieee->hwsec_active = 0; //disable hwsec, switch it on when necessary.
+ /* ieee->hwsec_support = 1; default support hw security: use module_param instead */
+ ieee->hwsec_active = 0; /* disable hwsec, switch it on when necessary */
ieee80211_softmac_init(ieee);
@@ -165,25 +166,25 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
return NULL;
}
HTUpdateDefaultSetting(ieee);
- HTInitializeHTInfo(ieee); //may move to other place.
+ HTInitializeHTInfo(ieee); /* may move to other place */
TSInitialize(ieee);
for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
for (i = 0; i < 17; i++) {
- ieee->last_rxseq_num[i] = -1;
- ieee->last_rxfrag_num[i] = -1;
- ieee->last_packet_time[i] = 0;
+ ieee->last_rxseq_num[i] = -1;
+ ieee->last_rxfrag_num[i] = -1;
+ ieee->last_packet_time[i] = 0;
}
-//These function were added to load crypte module autoly
+ /* Functions to load crypt module automatically */
ieee80211_tkip_null();
ieee80211_wep_null();
ieee80211_ccmp_null();
return dev;
- failed:
+failed:
if (dev)
free_netdev(dev);
return NULL;
@@ -222,35 +223,35 @@ void free_ieee80211(struct net_device *dev)
u32 ieee80211_debug_level = 0;
static int debug = \
- // IEEE80211_DL_INFO |
- // IEEE80211_DL_WX |
- // IEEE80211_DL_SCAN |
- // IEEE80211_DL_STATE |
- // IEEE80211_DL_MGMT |
- // IEEE80211_DL_FRAG |
- // IEEE80211_DL_EAP |
- // IEEE80211_DL_DROP |
- // IEEE80211_DL_TX |
- // IEEE80211_DL_RX |
- //IEEE80211_DL_QOS |
- // IEEE80211_DL_HT |
- // IEEE80211_DL_TS |
-// IEEE80211_DL_BA |
- // IEEE80211_DL_REORDER|
-// IEEE80211_DL_TRACE |
- //IEEE80211_DL_DATA |
- IEEE80211_DL_ERR //awayls open this flags to show error out
- ;
+ /* IEEE80211_DL_INFO | */
+ /* IEEE80211_DL_WX | */
+ /* IEEE80211_DL_SCAN | */
+ /* IEEE80211_DL_STATE | */
+ /* IEEE80211_DL_MGMT | */
+ /* IEEE80211_DL_FRAG | */
+ /* IEEE80211_DL_EAP | */
+ /* IEEE80211_DL_DROP | */
+ /* IEEE80211_DL_TX | */
+ /* IEEE80211_DL_RX | */
+ /* IEEE80211_DL_QOS | */
+ /* IEEE80211_DL_HT | */
+ /* IEEE80211_DL_TS | */
+ /* IEEE80211_DL_BA | */
+ /* IEEE80211_DL_REORDER | */
+ /* IEEE80211_DL_TRACE | */
+ /* IEEE80211_DL_DATA | */
+ IEEE80211_DL_ERR /* always open this flag to show error out */
+ ;
struct proc_dir_entry *ieee80211_proc = NULL;
static int show_debug_level(char *page, char **start, off_t offset,
- int count, int *eof, void *data)
+ int count, int *eof, void *data)
{
return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
}
static int store_debug_level(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, void *data)
{
char buf[] = "0x00000000";
unsigned long len = min(sizeof(buf) - 1, (u32)count);
@@ -269,7 +270,7 @@ static int store_debug_level(struct file *file, const char *buffer,
val = simple_strtoul(p, &p, 10);
if (p == buf)
printk(KERN_INFO DRV_NAME
- ": %s is not in hex or decimal form.\n", buf);
+ ": %s is not in hex or decimal form.\n", buf);
else
ieee80211_debug_level = val;
@@ -320,7 +321,7 @@ int __init ieee80211_rtl_init(void)
return -EIO;
}
e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
- ieee80211_proc);
+ ieee80211_proc);
if (!e) {
remove_proc_entry(DRV_NAME, init_net.proc_net);
ieee80211_proc = NULL;
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
index aaf9b9dc45e6..9318695042fb 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
@@ -2579,7 +2579,7 @@ static inline void update_network(struct ieee80211_network *dst,
if(src->wmm_param[0].ac_aci_acm_aifsn|| \
src->wmm_param[1].ac_aci_acm_aifsn|| \
src->wmm_param[2].ac_aci_acm_aifsn|| \
- src->wmm_param[1].ac_aci_acm_aifsn) {
+ src->wmm_param[3].ac_aci_acm_aifsn) {
memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
}
//dst->QoS_Enable = src->QoS_Enable;
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
index b7ec1ddee704..54c9c2471ec3 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
@@ -455,7 +455,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
}while(!ieee->channel_map[ch]);
#endif
- /* this fuction can be called in two situations
+ /* this function can be called in two situations
* 1- We have switched to ad-hoc mode and we are
* performing a complete syncro scan before conclude
* there are no interesting cell and to create a
@@ -527,16 +527,16 @@ void ieee80211_softmac_scan_wq(struct work_struct *work)
do{
ieee->current_network.channel =
(ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
- if (watchdog++ > MAX_CHANNEL_NUMBER)
- {
- //if current channel is not in channel map, set to default channel.
- #ifdef ENABLE_DOT11D
- if (!channel_map[ieee->current_network.channel]);
- #else
- if (!ieee->channel_map[ieee->current_network.channel]);
- #endif
+ if (watchdog++ > MAX_CHANNEL_NUMBER) {
+ /* if current channel is not in channel map, set to default channel. */
+#ifdef ENABLE_DOT11D
+ if (!channel_map[ieee->current_network.channel]) {
+#else
+ if (!ieee->channel_map[ieee->current_network.channel]) {
+#endif
ieee->current_network.channel = 6;
goto out; /* no good chans */
+ }
}
#ifdef ENABLE_DOT11D
}while(!channel_map[ieee->current_network.channel]);
diff --git a/drivers/staging/rtl8192e/r8180_93cx6.c b/drivers/staging/rtl8192e/r8180_93cx6.c
index 262ed5fd086a..a554627a0bcf 100644
--- a/drivers/staging/rtl8192e/r8180_93cx6.c
+++ b/drivers/staging/rtl8192e/r8180_93cx6.c
@@ -24,10 +24,10 @@ static void eprom_cs(struct net_device *dev, short bit)
{
if (bit)
write_nic_byte(dev, EPROM_CMD,
- (1<<EPROM_CS_SHIFT) | \
+ (1<<EPROM_CS_SHIFT) |
read_nic_byte(dev, EPROM_CMD)); //enable EPROM
else
- write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)\
+ write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)
&~(1<<EPROM_CS_SHIFT)); //disable EPROM
force_pci_posting(dev);
@@ -51,10 +51,10 @@ static void eprom_ck_cycle(struct net_device *dev)
static void eprom_w(struct net_device *dev, short bit)
{
if (bit)
- write_nic_byte(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) | \
+ write_nic_byte(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) |
read_nic_byte(dev, EPROM_CMD));
else
- write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)\
+ write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)
&~(1<<EPROM_W_SHIFT));
force_pci_posting(dev);
diff --git a/drivers/staging/rtl8192e/r8190_rtl8256.c b/drivers/staging/rtl8192e/r8190_rtl8256.c
index 8bd5b173a7d2..e2abfd7fd246 100644
--- a/drivers/staging/rtl8192e/r8190_rtl8256.c
+++ b/drivers/staging/rtl8192e/r8190_rtl8256.c
@@ -80,7 +80,6 @@ void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth)
}
}
- return;
}
/*--------------------------------------------------------------------------
* Overview: Interface to config 8256
@@ -414,7 +413,6 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel)
#endif
#endif
- return;
}
#define MAX_DOZE_WAITING_TIMES_9x 64
diff --git a/drivers/staging/rtl8192e/r8192E.h b/drivers/staging/rtl8192e/r8192E.h
index 865cdc008975..1e3375c58cca 100644
--- a/drivers/staging/rtl8192e/r8192E.h
+++ b/drivers/staging/rtl8192e/r8192E.h
@@ -1505,10 +1505,9 @@ void rtl8187_set_rxconf(struct net_device *dev);
void CamResetAllEntry(struct net_device* dev);
void EnableHWSecurityConfig8192(struct net_device *dev);
void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent );
-void CamPrintDbgReg(struct net_device* dev);
-extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14);
-extern void firmware_init_param(struct net_device *dev);
-extern RT_STATUS cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len);
+void dm_cck_txpower_adjust(struct net_device *dev, bool binch14);
+void firmware_init_param(struct net_device *dev);
+RT_STATUS cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len);
void rtl8192_hw_wakeup_wq (struct work_struct *work);
short rtl8192_is_tx_queue_empty(struct net_device *dev);
diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c
index 17a806f9ee77..ac4815d44698 100644
--- a/drivers/staging/rtl8192e/r8192E_core.c
+++ b/drivers/staging/rtl8192e/r8192E_core.c
@@ -71,7 +71,7 @@
#endif
//set here to open your trace code. //WB
-u32 rt_global_debug_component = \
+u32 rt_global_debug_component =
// COMP_INIT |
// COMP_EPROM |
// COMP_PHY |
@@ -160,6 +160,11 @@ static void rtl8192_prepare_beacon(struct r8192_priv *priv);
static irqreturn_t rtl8192_interrupt(int irq, void *netdev);
static void rtl8192_try_wake_queue(struct net_device *dev, int pri);
static void rtl819xE_tx_cmd(struct net_device *dev, struct sk_buff *skb);
+static void rtl8192_update_ratr_table(struct net_device* dev);
+static void rtl8192_restart(struct work_struct *work);
+static void watch_dog_timer_callback(unsigned long data);
+static int _rtl8192_up(struct net_device *dev);
+static void rtl8192_cancel_deferred_work(struct r8192_priv* priv);
#ifdef ENABLE_DOT11D
@@ -363,8 +368,8 @@ u8 rtl8192e_ap_sec_type(struct ieee80211_device *ieee)
crypt = ieee->crypt[ieee->tx_keyidx];
- encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||\
- (ieee->host_encrypt && crypt && crypt->ops && \
+ encrypt = (ieee->current_network.capability & WLAN_CAPABILITY_PRIVACY) ||
+ (ieee->host_encrypt && crypt && crypt->ops &&
(0 == strcmp(crypt->ops->name,"WEP")));
/* simply judge */
@@ -498,13 +503,9 @@ void force_pci_posting(struct net_device *dev)
}
-//warning message WB
//static struct net_device_stats *rtl8192_stats(struct net_device *dev);
-//void rtl8192_restart(struct net_device *dev);
-void rtl8192_restart(struct work_struct *work);
//void rtl8192_rq_tx_ack(struct work_struct *work);
-void watch_dog_timer_callback(unsigned long data);
/****************************************************************************
-----------------------------PROCFS STUFF-------------------------
*****************************************************************************/
@@ -812,11 +813,7 @@ short check_nic_enough_desc(struct net_device *dev, int prio)
/* for now we reserve two free descriptor as a safety boundary
* between the tail and the head
*/
- if (ring->entries - skb_queue_len(&ring->queue) >= 2) {
- return 1;
- } else {
- return 0;
- }
+ return (ring->entries - skb_queue_len(&ring->queue) >= 2);
}
static void tx_timeout(struct net_device *dev)
@@ -1109,7 +1106,6 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset)
}
skb_queue_purge(&priv->skb_queue);
- return;
}
#if 0
@@ -1168,7 +1164,7 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
/* shall not be referred by command packet */
assert(queue_index != TXCMD_QUEUE);
- if((priv->bHwRadioOff == true)||(!priv->up))
+ if (priv->bHwRadioOff ||(!priv->up))
{
kfree_skb(skb);
return;
@@ -1198,7 +1194,6 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
//spin_unlock_irqrestore(&priv->tx_lock,flags);
// return ret;
- return;
}
/* This is a rough attempt to TX a frame
@@ -1217,7 +1212,7 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
u8 queue_index = tcb_desc->queue_index;
if(queue_index != TXCMD_QUEUE){
- if((priv->bHwRadioOff == true)||(!priv->up))
+ if (priv->bHwRadioOff ||(!priv->up))
{
kfree_skb(skb);
return 0;
@@ -1713,7 +1708,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb)
pdesc = &ring->desc[idx];
if((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) {
- RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d,%x", \
+ RT_TRACE(COMP_ERR,"No more TX desc@%d, ring->idx = %d,idx = %d,%x",
tcb_desc->queue_index,ring->idx, idx,skb->len);
spin_unlock_irqrestore(&priv->irq_th_lock,flags);
return skb->len;
@@ -1919,7 +1914,6 @@ static void rtl8192_pci_resetdescring(struct net_device *dev)
}
#if 1
-extern void rtl8192_update_ratr_table(struct net_device* dev);
static void rtl8192_link_change(struct net_device *dev)
{
// int i;
@@ -1962,7 +1956,7 @@ static void rtl8192_link_change(struct net_device *dev)
#endif
-static struct ieee80211_qos_parameters def_qos_parameters = {
+static const struct ieee80211_qos_parameters def_qos_parameters = {
{3,3,3,3},/* cw_min */
{7,7,7,7},/* cw_max */
{2,2,2,2},/* aifs */
@@ -2049,7 +2043,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
"qos_activate\n");
}
} else {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,
&def_qos_parameters, size);
if ((network->qos_data.active == 1) && (active_network == 1)) {
@@ -2101,24 +2095,24 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
spin_lock_irqsave(&priv->ieee80211->lock, flags);
if(network->flags & NETWORK_HAS_QOS_PARAMETERS) {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
- &network->qos_data.parameters,\
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,
+ &network->qos_data.parameters,
sizeof(struct ieee80211_qos_parameters));
priv->ieee80211->current_network.qos_data.active = 1;
#if 0
- if((priv->ieee80211->current_network.qos_data.param_count != \
+ if((priv->ieee80211->current_network.qos_data.param_count !=
network->qos_data.param_count))
#endif
{
set_qos_param = 1;
/* update qos parameter for current network */
- priv->ieee80211->current_network.qos_data.old_param_count = \
+ priv->ieee80211->current_network.qos_data.old_param_count =
priv->ieee80211->current_network.qos_data.param_count;
- priv->ieee80211->current_network.qos_data.param_count = \
+ priv->ieee80211->current_network.qos_data.param_count =
network->qos_data.param_count;
}
} else {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
+ memcpy(&priv->ieee80211->current_network.qos_data.parameters,
&def_qos_parameters, size);
priv->ieee80211->current_network.qos_data.active = 0;
priv->ieee80211->current_network.qos_data.supported = 0;
@@ -2146,7 +2140,7 @@ static int rtl8192_handle_assoc_response(struct net_device *dev,
//updateRATRTabel for MCS only. Basic rate is not implement.
-void rtl8192_update_ratr_table(struct net_device* dev)
+static void rtl8192_update_ratr_table(struct net_device* dev)
// POCTET_STRING posLegacyRate,
// u8* pMcsRate)
// PRT_WLAN_STA pEntry)
@@ -2207,12 +2201,8 @@ static bool GetNmodeSupportBySecCfg8190Pci(struct net_device*dev)
struct r8192_priv *priv = ieee80211_priv(dev);
struct ieee80211_device *ieee = priv->ieee80211;
- if (ieee->rtllib_ap_sec_type &&
- (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP))) {
- return false;
- } else {
- return true;
- }
+ return !(ieee->rtllib_ap_sec_type &&
+ (ieee->rtllib_ap_sec_type(ieee)&(SEC_ALG_WEP|SEC_ALG_TKIP)));
#else
struct r8192_priv* priv = ieee80211_priv(dev);
struct ieee80211_device* ieee = priv->ieee80211;
@@ -2256,7 +2246,6 @@ static void rtl8192_refresh_supportrate(struct r8192_priv* priv)
}
else
memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
- return;
}
static u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
@@ -2331,16 +2320,10 @@ static void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
static bool GetHalfNmodeSupportByAPs819xPci(struct net_device* dev)
{
- bool Reval;
struct r8192_priv* priv = ieee80211_priv(dev);
struct ieee80211_device* ieee = priv->ieee80211;
- if(ieee->bHalfWirelessN24GMode == true)
- Reval = true;
- else
- Reval = false;
-
- return Reval;
+ return ieee->bHalfWirelessN24GMode;
}
short rtl8192_is_tx_queue_empty(struct net_device *dev)
@@ -2605,9 +2588,9 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
RCR_AAP | ((u32)7<<RCR_MXDMA_OFFSET) |
((u32)7 << RCR_FIFO_OFFSET) | RCR_ONLYERLPKT;
- priv->irq_mask = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |\
- IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |\
- IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |\
+ priv->irq_mask = (u32)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK |
+ IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK |
+ IMR_BDOK | IMR_RXCMDOK | IMR_TIMEOUT0 | IMR_RDU | IMR_RXFOVW |
IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
priv->AcmControl = 0;
@@ -3330,7 +3313,7 @@ static void rtl8192_hwconfig(struct net_device* dev)
// Set Retry Limit here
//
write_nic_word(dev, RETRY_LIMIT,
- priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \
+ priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT |
priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT);
// Set Contention Window here
@@ -3485,12 +3468,12 @@ static RT_STATUS rtl8192_adapter_start(struct net_device *dev)
//2Set Tx dma burst
#ifdef RTL8190P
- write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<<MXDMA2_RX_SHIFT) | \
- (MXDMA2_NoLimit<<MXDMA2_TX_SHIFT) | \
- (1<<MULRW_SHIFT)));
+ write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<<MXDMA2_RX_SHIFT) |
+ (MXDMA2_NoLimit<<MXDMA2_TX_SHIFT) |
+ (1<<MULRW_SHIFT)));
#else
#ifdef RTL8192E
- write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<<MXDMA2_RX_SHIFT) |\
+ write_nic_byte(dev, PCIF, ((MXDMA2_NoLimit<<MXDMA2_RX_SHIFT) |
(MXDMA2_NoLimit<<MXDMA2_TX_SHIFT) ));
#endif
#endif
@@ -3504,25 +3487,25 @@ static RT_STATUS rtl8192_adapter_start(struct net_device *dev)
#ifdef TO_DO_LIST
if(priv->bInHctTest)
{
- PlatformEFIOWrite4Byte(Adapter, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\
- NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \
- NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \
+ PlatformEFIOWrite4Byte(Adapter, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
+ NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
+ NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM <<RSVD_FW_QUEUE_PAGE_VO_SHIFT);
PlatformEFIOWrite4Byte(Adapter, RQPN2, NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT);
- PlatformEFIOWrite4Byte(Adapter, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW| \
- NUM_OF_PAGE_IN_FW_QUEUE_BCN<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT|\
+ PlatformEFIOWrite4Byte(Adapter, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW|
+ NUM_OF_PAGE_IN_FW_QUEUE_BCN<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT|
NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM<<RSVD_FW_QUEUE_PAGE_PUB_SHIFT);
}
else
#endif
{
- write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |\
- NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | \
- NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | \
+ write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT |
+ NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT |
+ NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT |
NUM_OF_PAGE_IN_FW_QUEUE_VO <<RSVD_FW_QUEUE_PAGE_VO_SHIFT);
write_nic_dword(dev, RQPN2, NUM_OF_PAGE_IN_FW_QUEUE_MGNT << RSVD_FW_QUEUE_PAGE_MGNT_SHIFT);
- write_nic_dword(dev, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW| \
- NUM_OF_PAGE_IN_FW_QUEUE_BCN<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT|\
+ write_nic_dword(dev, RQPN3, APPLIED_RESERVED_QUEUE_IN_FW|
+ NUM_OF_PAGE_IN_FW_QUEUE_BCN<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT|
NUM_OF_PAGE_IN_FW_QUEUE_PUB<<RSVD_FW_QUEUE_PAGE_PUB_SHIFT);
}
@@ -4246,9 +4229,6 @@ static void CamRestoreAllEntry(struct net_device *dev)
}
}
-void rtl8192_cancel_deferred_work(struct r8192_priv* priv);
-int _rtl8192_up(struct net_device *dev);
-
/*
* This function is used to fix Tx/Rx stop bug temporarily.
* This function will do "system reset" to NIC when Tx or Rx is stuck.
@@ -4400,7 +4380,7 @@ void InactivePsWorkItemCallback(struct net_device *dev)
//
pPSC->bSwRfProcessing = TRUE;
- RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n", \
+ RT_TRACE(COMP_RF, "InactivePsWorkItemCallback(): Set RF to %s.\n",
pPSC->eInactivePowerState == eRfOff?"OFF":"ON");
@@ -4673,7 +4653,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
static u8 last_time = 0;
bool bEnterPS = false;
- if((!priv->up) || (priv->bHwRadioOff == true))
+ if ((!priv->up) || priv->bHwRadioOff)
return;
if(!priv->up)
@@ -4683,8 +4663,8 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
// printk("watch_dog ENABLE_IPS\n");
if(ieee->actscanning == false){
//printk("%d,%d,%d,%d\n", ieee->eRFPowerState, ieee->is_set_key, ieee->proto_stoppping, ieee->wx_set_enc);
- if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) &&\
- (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&\
+ if((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_NOLINK) &&
+ (ieee->eRFPowerState == eRfOn)&&!ieee->is_set_key &&
(!ieee->proto_stoppping) && !ieee->wx_set_enc){
if(ieee->PowerSaveControl.ReturnPoint == IPS_CALLBACK_NONE){
//printk("====================>haha:IPSEnter()\n");
@@ -4811,7 +4791,8 @@ void watch_dog_timer_callback(unsigned long data)
mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
}
-int _rtl8192_up(struct net_device *dev)
+
+static int _rtl8192_up(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
//int i;
@@ -4961,7 +4942,7 @@ void rtl8192_commit(struct net_device *dev)
_rtl8192_up(dev);
}
-void rtl8192_restart(struct work_struct *work)
+static void rtl8192_restart(struct work_struct *work)
{
struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
struct net_device *dev = priv->ieee80211->dev;
@@ -5629,7 +5610,7 @@ rtl819x_evm_dbtopercentage(
ret_val*=3;
if(ret_val == 99)
ret_val = 100;
- return(ret_val);
+ return ret_val;
}
//
@@ -6325,6 +6306,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
struct net_device *dev = NULL;
struct r8192_priv *priv= NULL;
u8 unit = 0;
+ int ret = -ENODEV;
#ifdef CONFIG_RTL8192_IO_MAP
unsigned long pio_start, pio_len, pio_flags;
@@ -6344,8 +6326,10 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
pci_set_dma_mask(pdev, 0xffffff00ULL);
pci_set_consistent_dma_mask(pdev,0xffffff00ULL);
dev = alloc_ieee80211(sizeof(struct r8192_priv));
- if (!dev)
- return -ENOMEM;
+ if (!dev) {
+ ret = -ENOMEM;
+ goto fail_free;
+ }
pci_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
@@ -6494,18 +6478,19 @@ fail:
free_ieee80211(dev);
}
+fail_free:
pci_disable_device(pdev);
DMESG("wlan driver load failed\n");
pci_set_drvdata(pdev, NULL);
- return -ENODEV;
+ return ret;
}
/* detach all the work and timer structure declared or inititialized
* in r8192_init function.
* */
-void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
+static void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
{
/* call cancel_work_sync instead of cancel_delayed_work if and only if Linux_version_code
* is or is newer than 2.6.20 and work structure is defined to be struct work_struct.
@@ -6825,7 +6810,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
SECR_value &= ~SCR_RxDecEnable;
}
- RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, \
+ RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__,
ieee->hwsec_active, ieee->pairwise_key_type, SECR_value);
{
write_nic_byte(dev, SECR, SECR_value);//SECR_value | SCR_UseDK );
@@ -6910,26 +6895,6 @@ void setKey( struct net_device *dev,
}
RT_TRACE(COMP_SEC,"=========>after set key, usconfig:%x\n", usConfig);
}
-// This function seems not ready! WB
-void CamPrintDbgReg(struct net_device* dev)
-{
- unsigned long rvalue;
- unsigned char ucValue;
- write_nic_dword(dev, DCAM, 0x80000000);
- msleep(40);
- rvalue = read_nic_dword(dev, DCAM); //delay_ms(40);
- RT_TRACE(COMP_SEC, " TX CAM=%8lX ",rvalue);
- if((rvalue & 0x40000000) != 0x4000000)
- RT_TRACE(COMP_SEC, "-->TX Key Not Found ");
- msleep(20);
- write_nic_dword(dev, DCAM, 0x00000000); //delay_ms(40);
- rvalue = read_nic_dword(dev, DCAM); //delay_ms(40);
- RT_TRACE(COMP_SEC, "RX CAM=%8lX ",rvalue);
- if((rvalue & 0x40000000) != 0x4000000)
- RT_TRACE(COMP_SEC, "-->CAM Key Not Found ");
- ucValue = read_nic_byte(dev, SECR);
- RT_TRACE(COMP_SEC, "WPA_Config=%x \n",ucValue);
-}
bool NicIFEnableNIC(struct net_device* dev)
{
@@ -6963,7 +6928,7 @@ bool NicIFEnableNIC(struct net_device* dev)
rtl8192_irq_enable(dev);
priv->bdisable_nic = false;
//RT_TRACE(COMP_PS,"<===========%s()\n",__FUNCTION__);
- return (init_status == RT_STATUS_SUCCESS) ? true:false;
+ return (init_status == RT_STATUS_SUCCESS);
}
bool NicIFDisableNIC(struct net_device* dev)
{
diff --git a/drivers/staging/rtl8192e/r8192E_dm.c b/drivers/staging/rtl8192e/r8192E_dm.c
index a5884c6bcc25..8d7c35bd2bb3 100644
--- a/drivers/staging/rtl8192e/r8192E_dm.c
+++ b/drivers/staging/rtl8192e/r8192E_dm.c
@@ -52,8 +52,6 @@ static const u32 edca_setting_UL[HT_IOT_PEER_MAX] =
/*------------------------Define global variable-----------------------------*/
// Debug variable ?
dig_t dm_digtable;
-// Store current shoftware write register content for MAC PHY.
-u8 dm_shadow[16][256] = {{0}};
// For Dynamic Rx Path Selection by Signal Strength
DRxPathSel DM_RxPathSelTable;
/*------------------------Define global variable-----------------------------*/
@@ -90,7 +88,6 @@ extern void dm_rf_operation_test_callback(unsigned long data);
extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
extern void dm_fsync_timer_callback(unsigned long data);
extern void dm_check_fsync(struct net_device *dev);
-extern void dm_shadow_init(struct net_device *dev);
extern void dm_initialize_txpower_tracking(struct net_device *dev);
#ifdef RTL8192E
@@ -298,9 +295,7 @@ void dm_check_ac_dc_power(struct net_device *dev)
return;
}
call_usermodehelper(ac_dc_check_script_path,argv,envp,1);
-
- return;
-};
+}
void hal_dm_watchdog(struct net_device *dev)
{
@@ -2948,14 +2943,14 @@ void dm_gpio_change_rf_callback(struct work_struct *work)
eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff;
- if( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn))
+ if (priv->bHwRadioOff && (eRfPowerStateToSet == eRfOn))
{
RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n");
priv->bHwRadioOff = false;
bActuallySet = true;
}
- else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff))
+ else if ( (!priv->bHwRadioOff) && (eRfPowerStateToSet == eRfOff))
{
RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n");
priv->bHwRadioOff = true;
@@ -3722,45 +3717,6 @@ void dm_check_fsync(struct net_device *dev)
}
}
-
-/*-----------------------------------------------------------------------------
- * Function: dm_shadow_init()
- *
- * Overview: Store all NIC MAC/BB register content.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/29/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-void dm_shadow_init(struct net_device *dev)
-{
- u8 page;
- u16 offset;
-
- for (page = 0; page < 5; page++)
- for (offset = 0; offset < 256; offset++)
- {
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
- //DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);
- }
-
- for (page = 8; page < 11; page++)
- for (offset = 0; offset < 256; offset++)
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
-
- for (page = 12; page < 15; page++)
- for (offset = 0; offset < 256; offset++)
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
-
-} /* dm_shadow_init */
-
/*---------------------------Define function prototype------------------------*/
/*-----------------------------------------------------------------------------
* Function: DM_DynamicTxPower()
diff --git a/drivers/staging/rtl8192e/r8192E_dm.h b/drivers/staging/rtl8192e/r8192E_dm.h
index f74a880506f1..237c30db8c3f 100644
--- a/drivers/staging/rtl8192e/r8192E_dm.h
+++ b/drivers/staging/rtl8192e/r8192E_dm.h
@@ -261,7 +261,6 @@ typedef struct tag_Tx_Config_Cmd_Format
/*------------------------Export global variable----------------------------*/
extern dig_t dm_digtable;
-extern u8 dm_shadow[16][256];
extern DRxPathSel DM_RxPathSelTable;
/*------------------------Export global variable----------------------------*/
@@ -302,7 +301,6 @@ extern void dm_fsync_timer_callback(unsigned long data);
extern bool dm_check_lbus_status(struct net_device *dev);
#endif
extern void dm_check_fsync(struct net_device *dev);
-extern void dm_shadow_init(struct net_device *dev);
extern void dm_initialize_txpower_tracking(struct net_device *dev);
diff --git a/drivers/staging/rtl8192e/r8192E_wx.c b/drivers/staging/rtl8192e/r8192E_wx.c
index 5742cee81203..5ae65164af5c 100644
--- a/drivers/staging/rtl8192e/r8192E_wx.c
+++ b/drivers/staging/rtl8192e/r8192E_wx.c
@@ -70,7 +70,7 @@ static int r8192_wx_set_rate(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -90,7 +90,7 @@ static int r8192_wx_set_rts(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -117,7 +117,7 @@ static int r8192_wx_set_power(struct net_device *dev,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -144,7 +144,7 @@ static int r8192_wx_set_rawtx(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -182,7 +182,7 @@ static int r8192_wx_set_crcmon(struct net_device *dev,
int enable = (parms[0] > 0);
short prev = priv->crcmon;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -212,7 +212,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
RT_RF_POWER_STATE rtState;
int ret;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
rtState = priv->ieee80211->eRFPowerState;
@@ -383,7 +383,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
RT_RF_POWER_STATE rtState;
int ret;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
rtState = priv->ieee80211->eRFPowerState;
@@ -452,7 +452,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
if(!priv->up) return -ENETDOWN;
@@ -474,7 +474,7 @@ static int r8192_wx_set_essid(struct net_device *dev,
RT_RF_POWER_STATE rtState;
int ret;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
rtState = priv->ieee80211->eRFPowerState;
@@ -518,7 +518,7 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
int ret;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -544,7 +544,7 @@ static int r8192_wx_set_frag(struct net_device *dev,
{
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
if (wrqu->frag.disabled)
@@ -585,7 +585,7 @@ static int r8192_wx_set_wap(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
// struct sockaddr *temp = (struct sockaddr *)awrq;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -641,7 +641,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
{0x00,0x00,0x00,0x00,0x00,0x03} };
int i;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
if(!priv->up) return -ENETDOWN;
@@ -786,7 +786,7 @@ static int r8192_wx_set_retry(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
int err = 0;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -882,7 +882,7 @@ static int r8192_wx_set_sens(struct net_device *dev,
short err = 0;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -911,7 +911,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
struct r8192_priv *priv = ieee80211_priv(dev);
struct ieee80211_device* ieee = priv->ieee80211;
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -1016,7 +1016,7 @@ static int r8192_wx_set_auth(struct net_device *dev,
//printk("====>%s()\n", __FUNCTION__);
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -1034,7 +1034,7 @@ static int r8192_wx_set_mlme(struct net_device *dev,
int ret=0;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
@@ -1051,7 +1051,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,
int ret=0;
struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->bHwRadioOff == true)
+ if (priv->bHwRadioOff)
return 0;
down(&priv->wx_sem);
diff --git a/drivers/staging/rtl8192e/r8192_pm.c b/drivers/staging/rtl8192e/r8192_pm.c
index 521d49f8f8ea..c691bc9d88bb 100644
--- a/drivers/staging/rtl8192e/r8192_pm.c
+++ b/drivers/staging/rtl8192e/r8192_pm.c
@@ -17,7 +17,7 @@
int rtl8192E_save_state (struct pci_dev *dev, pm_message_t state)
{
printk(KERN_NOTICE "r8192E save state call (state %u).\n", state.event);
- return(-EAGAIN);
+ return -EAGAIN;
}
@@ -104,7 +104,7 @@ out_pci_suspend:
netif_device_detach(dev);
pci_save_state(pdev);
pci_disable_device(pdev);
- pci_enable_wake(pdev, pci_choose_state(pdev,state),\
+ pci_enable_wake(pdev, pci_choose_state(pdev,state),
priv->ieee80211->bSupportRemoteWakeUp?1:0);
pci_set_power_state(pdev,pci_choose_state(pdev,state));
@@ -166,5 +166,5 @@ int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable)
{
printk(KERN_NOTICE "r8192E enable wake call (state %u, enable %d).\n",
state.event, enable);
- return(-EAGAIN);
+ return -EAGAIN;
}
diff --git a/drivers/staging/rtl8192e/r819xE_firmware.c b/drivers/staging/rtl8192e/r819xE_firmware.c
index 793a17545554..f1c859d43656 100644
--- a/drivers/staging/rtl8192e/r819xE_firmware.c
+++ b/drivers/staging/rtl8192e/r819xE_firmware.c
@@ -91,16 +91,16 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
* Transform from little endian to big endian and pending zero
*/
for (i = 0; i < frag_length; i += 4) {
- *seg_ptr++ = ((i+0) < frag_length) ? \
+ *seg_ptr++ = ((i+0) < frag_length) ?
code_virtual_address[i+3] : 0;
- *seg_ptr++ = ((i+1) < frag_length) ? \
+ *seg_ptr++ = ((i+1) < frag_length) ?
code_virtual_address[i+2] : 0;
- *seg_ptr++ = ((i+2) < frag_length) ? \
+ *seg_ptr++ = ((i+2) < frag_length) ?
code_virtual_address[i+1] : 0;
- *seg_ptr++ = ((i+3) < frag_length) ? \
+ *seg_ptr++ = ((i+3) < frag_length) ?
code_virtual_address[i+0] : 0;
}
tcb_desc->txbuf_size = (u16)i;
@@ -249,7 +249,7 @@ bool init_firmware(struct net_device *dev)
* Download boot, main, and data image for System reset.
* Download data image for firmware reseta
*/
- for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; \
+ for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA;
init_step++) {
/*
* Open Image file, and map file to contineous memory if open file success.
@@ -266,7 +266,7 @@ bool init_firmware(struct net_device *dev)
}
if (fw_entry->size > sizeof(pfirmware->firmware_buf[init_step])) {
- RT_TRACE(COMP_FIRMWARE, \
+ RT_TRACE(COMP_FIRMWARE,
"img file size exceed the container buffer fail!\n");
goto download_firmware_fail;
}
diff --git a/drivers/staging/rtl8192e/r819xE_phy.c b/drivers/staging/rtl8192e/r819xE_phy.c
index ffd1e97e27b9..48e27bb1bf2c 100644
--- a/drivers/staging/rtl8192e/r819xE_phy.c
+++ b/drivers/staging/rtl8192e/r819xE_phy.c
@@ -1477,7 +1477,6 @@ void rtl8192_setBBreg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask, u32
write_nic_dword(dev, dwRegAddr, NewValue);
}else
write_nic_dword(dev, dwRegAddr, dwData);
- return;
}
/******************************************************************************
*function: This function reads specific bits from BB register
@@ -1496,7 +1495,7 @@ u32 rtl8192_QueryBBReg(struct net_device* dev, u32 dwRegAddr, u32 dwBitMask)
BitShift = rtl8192_CalculateBitShift(dwBitMask);
Ret = (OriginalValue & dwBitMask) >> BitShift;
- return (Ret);
+ return Ret;
}
/******************************************************************************
*function: This function read register from RF chip
@@ -1705,8 +1704,6 @@ static void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E
#endif
#endif
}
-
- return;
}
/******************************************************************************
@@ -1764,7 +1761,6 @@ void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32
}
//spin_unlock_irqrestore(&priv->rf_lock, flags);
//up(&priv->rf_sem);
- return;
}
/******************************************************************************
@@ -1801,7 +1797,7 @@ u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u3
Readback_Value = (Original_Value & BitMask) >> BitShift;
up(&priv->rf_sem);
// udelay(200);
- return (Readback_Value);
+ return Readback_Value;
}
/******************************************************************************
@@ -1857,11 +1853,11 @@ static u32 phy_FwRFSerialRead(
udelay(10);
}
else
- return (0);
+ return 0;
}
retValue = read_nic_dword(dev, RF_DATA);
- return (retValue);
+ return retValue;
} /* phy_FwRFSerialRead */
@@ -1967,8 +1963,6 @@ if(Adapter->bInHctTest)
}
rtl8192_setBBreg(dev, pdwArray[i], pdwArray[i+1], pdwArray[i+2]);
}
- return;
-
}
/******************************************************************************
@@ -2039,9 +2033,6 @@ void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType)
RT_TRACE(COMP_DBG, "i:%x, The rtl819XAGCTAB_Array[0] is %x rtl819XAGCTAB_Array[1] is %x \n",i, Rtl819XAGCTAB_Array_Table[i], Rtl819XAGCTAB_Array_Table[i+1]);
}
}
- return;
-
-
}
/******************************************************************************
*function: This function initialize Register definition offset for Radio Path
@@ -2381,7 +2372,6 @@ void rtl8192_phy_getTxPower(struct net_device* dev)
rOFDM0_RxDetector3, priv->framesync);
// read SIFS (save the value read fome MACPHY_REG.txt)
priv->SifsTime = read_nic_word(dev, SIFS);
- return;
}
/******************************************************************************
@@ -2503,7 +2493,6 @@ void rtl8192_phy_setTxPower(struct net_device* dev, u8 channel)
RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n", __FUNCTION__);
break;
}
- return;
}
/******************************************************************************
@@ -2546,7 +2535,6 @@ RT_STATUS rtl8192_phy_RFConfig(struct net_device* dev)
* ***************************************************************************/
void rtl8192_phy_updateInitGain(struct net_device* dev)
{
- return;
}
/******************************************************************************
@@ -2653,7 +2641,6 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n");
break;
}
- return;
}
/****************************************************************************************
*function: This function set command table variable(struct SwChnlCmd).
@@ -3088,7 +3075,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
struct r8192_priv *priv = ieee80211_priv(dev);
u8 regBwOpMode;
- RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n", \
+ RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem() Switch to %s bandwidth\n",
priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz")
diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig
deleted file mode 100644
index 27b89a432670..000000000000
--- a/drivers/staging/rtl8192su/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-config RTL8192SU
- tristate "RealTek RTL8192SU Wireless LAN NIC driver"
- depends on PCI && WLAN && USB
- select WIRELESS_EXT
- select WEXT_PRIV
- select EEPROM_93CX6
- select CRYPTO
- default N
- ---help---
diff --git a/drivers/staging/rtl8192su/Makefile b/drivers/staging/rtl8192su/Makefile
deleted file mode 100644
index 7133894afe76..000000000000
--- a/drivers/staging/rtl8192su/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-NIC_SELECT = RTL8192SU
-
-EXTRA_CFLAGS += -std=gnu89
-EXTRA_CFLAGS += -O2
-
-EXTRA_CFLAGS += -DJACKSON_NEW_RX
-EXTRA_CFLAGS += -DTHOMAS_BEACON
-
-#EXTRA_CFLAGS += -DMUTIPLE_BULK_OUT
-
-r8192s_usb-objs := \
- r8192U_wx.o \
- r8192S_phy.o \
- r8192S_rtl6052.o \
- r8192S_rtl8225.o \
- r819xU_cmdpkt.o \
- r8192U_dm.o \
- r8192SU_HWImg.o \
- r8192S_firmware.o \
- r8192S_Efuse.o \
- r8192U_core.o \
- r8192U_pm.o \
- r8192SU_led.o \
- ieee80211/ieee80211_crypt.o \
- ieee80211/ieee80211_crypt_tkip.o \
- ieee80211/ieee80211_crypt_ccmp.o \
- ieee80211/ieee80211_crypt_wep.o \
- ieee80211/ieee80211_rx.o \
- ieee80211/ieee80211_softmac.o \
- ieee80211/ieee80211_tx.o \
- ieee80211/ieee80211_wx.o \
- ieee80211/ieee80211_module.o \
- ieee80211/ieee80211_softmac_wx.o\
- ieee80211/rtl819x_HTProc.o \
- ieee80211/rtl819x_TSProc.o \
- ieee80211/rtl819x_BAProc.o \
- ieee80211/dot11d.o
-
-obj-$(CONFIG_RTL8192SU) += r8192s_usb.o
diff --git a/drivers/staging/rtl8192su/TODO b/drivers/staging/rtl8192su/TODO
deleted file mode 100644
index b15204ea4ec4..000000000000
--- a/drivers/staging/rtl8192su/TODO
+++ /dev/null
@@ -1,21 +0,0 @@
-TODO:
-- merge realteks bugfixes and new features into the driver:
- - an updated version of this driver can be found here:
- http://www.getnet.eu/products_GN-621U.html
- - note:
- realtek has stripped alomost all comments from the source,
- so please leave all comments that may help in development in the code.
-- prepare private ieee80211 stack for merge with rtl8187se's version:
- - remove rtl8192su's specific dead code
- - cleanup ieee80211.h
- - move rtl8192su's specific code out from ieee80211.h
- - abstract rtl819su's specific code
-- switch to use shared "librtl" instead of private ieee80211 stack
-- switch to use LIB80211
-- switch to use MAC80211
-- use kernel coding style
-- checkpatch.pl fixes
-- sparse fixes
-- integrate with drivers/net/wireless/rtl818x
-
-Please send any patches to Greg Kroah-Hartman <greg@kroah.com>.
diff --git a/drivers/staging/rtl8192su/authors b/drivers/staging/rtl8192su/authors
deleted file mode 100644
index b08bbae39e72..000000000000
--- a/drivers/staging/rtl8192su/authors
+++ /dev/null
@@ -1 +0,0 @@
-Andrea Merello <andreamrl@tiscali.it>
diff --git a/drivers/staging/rtl8192su/ieee80211/Makefile b/drivers/staging/rtl8192su/ieee80211/Makefile
deleted file mode 100644
index a500bfaeaef2..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-NIC_SELECT = RTL8192SU
-
-EXTRA_CFLAGS += -O2
-EXTRA_CFLAGS += -DRTL8192S_DISABLE_FW_DM=0
-EXTRA_CFLAGS += -DRTL8192SU
-#EXTRA_CFLAGS += -DJOHN_NOCPY
-EXTRA_CFLAGS += -DTHOMAS_TURBO
-
-ieee80211-rsl-objs := ieee80211_rx.o \
- ieee80211_softmac.o \
- ieee80211_tx.o \
- ieee80211_wx.o \
- ieee80211_module.o \
- ieee80211_softmac_wx.o\
- rtl819x_HTProc.o\
- rtl819x_TSProc.o\
- rtl819x_BAProc.o\
- dot11d.o
-
-ieee80211_crypt-rsl-objs := ieee80211_crypt.o
-ieee80211_crypt_tkip-rsl-objs := ieee80211_crypt_tkip.o
-ieee80211_crypt_ccmp-rsl-objs := ieee80211_crypt_ccmp.o
-ieee80211_crypt_wep-rsl-objs := ieee80211_crypt_wep.o
-
-obj-m +=ieee80211-rsl.o
-obj-m +=ieee80211_crypt-rsl.o
-obj-m +=ieee80211_crypt_wep-rsl.o
-obj-m +=ieee80211_crypt_tkip-rsl.o
-obj-m +=ieee80211_crypt_ccmp-rsl.o
-
diff --git a/drivers/staging/rtl8192su/ieee80211/dot11d.c b/drivers/staging/rtl8192su/ieee80211/dot11d.c
deleted file mode 100644
index 6275cc75ec85..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/dot11d.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-#include "dot11d.h"
-
-void
-Dot11d_Init(struct ieee80211_device *ieee)
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
-
- pDot11dInfo->bEnabled = 0;
-
- pDot11dInfo->State = DOT11D_STATE_NONE;
- pDot11dInfo->CountryIeLen = 0;
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
- RESET_CIE_WATCHDOG(ieee);
-
- printk("Dot11d_Init()\n");
-}
-
-//
-// Description:
-// Reset to the state as we are just entering a regulatory domain.
-//
-void
-Dot11d_Reset(struct ieee80211_device *ieee)
-{
- u32 i;
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
-
- // Clear old channel map
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
- // Set new channel map
- for (i=1; i<=11; i++) {
- (pDot11dInfo->channel_map)[i] = 1;
- }
- for (i=12; i<=14; i++) {
- (pDot11dInfo->channel_map)[i] = 2;
- }
-
- pDot11dInfo->State = DOT11D_STATE_NONE;
- pDot11dInfo->CountryIeLen = 0;
- RESET_CIE_WATCHDOG(ieee);
-
-}
-
-//
-// Description:
-// Update country IE from Beacon or Probe Resopnse
-// and configure PHY for operation in the regulatory domain.
-//
-// TODO:
-// Configure Tx power.
-//
-// Assumption:
-// 1. IS_DOT11D_ENABLE() is TRUE.
-// 2. Input IE is an valid one.
-//
-void
-Dot11d_UpdateCountryIe(
- struct ieee80211_device *dev,
- u8 * pTaddr,
- u16 CoutryIeLen,
- u8 * pCoutryIe
- )
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
- u8 i, j, NumTriples, MaxChnlNum;
- PCHNL_TXPOWER_TRIPLE pTriple;
-
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
- MaxChnlNum = 0;
- NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
- pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
- for(i = 0; i < NumTriples; i++)
- {
- if(MaxChnlNum >= pTriple->FirstChnl)
- { // It is not in a monotonically increasing order, so stop processing.
- printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
- return;
- }
- if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls))
- { // It is not a valid set of channel id, so stop processing.
- printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
- return;
- }
-
- for(j = 0 ; j < pTriple->NumChnls; j++)
- {
- pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
- pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
- MaxChnlNum = pTriple->FirstChnl + j;
- }
-
- pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
- }
-#if 1
- printk("Channel List:");
- for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
- if(pDot11dInfo->channel_map[i] > 0)
- printk(" %d", i);
- printk("\n");
-#endif
-
- UPDATE_CIE_SRC(dev, pTaddr);
-
- pDot11dInfo->CountryIeLen = CoutryIeLen;
- memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen);
- pDot11dInfo->State = DOT11D_STATE_LEARNED;
-}
-
-
-u8
-DOT11D_GetMaxTxPwrInDbm(
- struct ieee80211_device *dev,
- u8 Channel
- )
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
- u8 MaxTxPwrInDbm = 255;
-
- if(MAX_CHANNEL_NUMBER < Channel)
- {
- printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
- return MaxTxPwrInDbm;
- }
- if(pDot11dInfo->channel_map[Channel])
- {
- MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
- }
-
- return MaxTxPwrInDbm;
-}
-
-
-void
-DOT11D_ScanComplete(
- struct ieee80211_device * dev
- )
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
-
- switch(pDot11dInfo->State)
- {
- case DOT11D_STATE_LEARNED:
- pDot11dInfo->State = DOT11D_STATE_DONE;
- break;
-
- case DOT11D_STATE_DONE:
- if( GET_CIE_WATCHDOG(dev) == 0 )
- { // Reset country IE if previous one is gone.
- Dot11d_Reset(dev);
- }
- break;
- case DOT11D_STATE_NONE:
- break;
- }
-}
-
-int IsLegalChannel(
- struct ieee80211_device * dev,
- u8 channel
-)
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
-
- if(MAX_CHANNEL_NUMBER < channel)
- {
- printk("IsLegalChannel(): Invalid Channel\n");
- return 0;
- }
- if(pDot11dInfo->channel_map[channel] > 0)
- return 1;
- return 0;
-}
-
-int ToLegalChannel(
- struct ieee80211_device * dev,
- u8 channel
-)
-{
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
- u8 default_chn = 0;
- u32 i = 0;
-
- for (i=1; i<= MAX_CHANNEL_NUMBER; i++)
- {
- if(pDot11dInfo->channel_map[i] > 0)
- {
- default_chn = i;
- break;
- }
- }
-
- if(MAX_CHANNEL_NUMBER < channel)
- {
- printk("IsLegalChannel(): Invalid Channel\n");
- return default_chn;
- }
-
- if(pDot11dInfo->channel_map[channel] > 0)
- return channel;
-
- return default_chn;
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/dot11d.h b/drivers/staging/rtl8192su/ieee80211/dot11d.h
deleted file mode 100644
index 62a2c905e1fa..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/dot11d.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef __INC_DOT11D_H
-#define __INC_DOT11D_H
-
-#include "ieee80211.h"
-
-typedef struct _CHNL_TXPOWER_TRIPLE {
- u8 FirstChnl;
- u8 NumChnls;
- u8 MaxTxPowerInDbm;
-}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
-
-typedef enum _DOT11D_STATE {
- DOT11D_STATE_NONE = 0,
- DOT11D_STATE_LEARNED,
- DOT11D_STATE_DONE,
-}DOT11D_STATE;
-
-typedef struct _RT_DOT11D_INFO {
-
- bool bEnabled; // dot11MultiDomainCapabilityEnabled
-
- u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
- u8 CountryIeBuf[MAX_IE_LEN];
- u8 CountryIeSrcAddr[6]; // Source AP of the country IE.
- u8 CountryIeWatchdog;
-
- u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
- u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
-
- DOT11D_STATE State;
-}RT_DOT11D_INFO, *PRT_DOT11D_INFO;
-#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
-#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
-#define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
-
-#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
-#define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
-
-#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
-#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
-
-#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
- (((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
- FALSE : \
- (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
-
-#define CIE_WATCHDOG_TH 1
-#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
-#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
-#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
-
-#define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
-
-
-void
-Dot11d_Init(
- struct ieee80211_device *dev
- );
-
-void
-Dot11d_Reset(
- struct ieee80211_device *dev
- );
-
-void
-Dot11d_UpdateCountryIe(
- struct ieee80211_device *dev,
- u8 * pTaddr,
- u16 CoutryIeLen,
- u8 * pCoutryIe
- );
-
-u8
-DOT11D_GetMaxTxPwrInDbm(
- struct ieee80211_device *dev,
- u8 Channel
- );
-
-void
-DOT11D_ScanComplete(
- struct ieee80211_device * dev
- );
-
-int IsLegalChannel(
- struct ieee80211_device * dev,
- u8 channel
-);
-
-int ToLegalChannel(
- struct ieee80211_device * dev,
- u8 channel
-);
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211.h b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
deleted file mode 100644
index 1d6789db4e4d..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211.h
+++ /dev/null
@@ -1,1934 +0,0 @@
-/*
- * Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
- * remains copyright by the original authors
- *
- * Portions of the merged code are based on Host AP (software wireless
- * LAN access point) driver for Intersil Prism2/2.5/3.
- *
- * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- * <jkmaline@cc.hut.fi>
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * Adaption to a generic IEEE 802.11 stack by James Ketrenos
- * <jketreno@linux.intel.com>
- * Copyright (c) 2004, Intel Corporation
- *
- * Modified for Realtek's wi-fi cards by Andrea Merello
- * <andreamrl@tiscali.it>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- */
-#ifndef IEEE80211_H
-#define IEEE80211_H
-#include <linux/if_ether.h> /* ETH_ALEN */
-#include <linux/kernel.h> /* ARRAY_SIZE */
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/jiffies.h>
-#include <linux/timer.h>
-#include <linux/sched.h>
-#include <linux/semaphore.h>
-
-#include <linux/delay.h>
-#include <linux/wireless.h>
-#include <linux/ieee80211.h>
-
-#include "rtl819x_HT.h"
-#include "rtl819x_BA.h"
-#include "rtl819x_TS.h"
-
-#define KEY_TYPE_NA 0x0
-#define KEY_TYPE_WEP40 0x1
-#define KEY_TYPE_TKIP 0x2
-#define KEY_TYPE_CCMP 0x4
-#define KEY_TYPE_WEP104 0x5
-
-#define aSifsTime (((priv->ieee80211->current_network.mode == IEEE_A) || \
- (priv->ieee80211->current_network.mode == IEEE_N_24G) || \
- (priv->ieee80211->current_network.mode == IEEE_N_5G)) \
- ? 16 : 10)
-
-#define MGMT_QUEUE_NUM 5
-
-#define IEEE_CMD_SET_WPA_PARAM 1
-#define IEEE_CMD_SET_WPA_IE 2
-#define IEEE_CMD_SET_ENCRYPTION 3
-#define IEEE_CMD_MLME 4
-
-#define IEEE_PARAM_WPA_ENABLED 1
-#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
-#define IEEE_PARAM_DROP_UNENCRYPTED 3
-#define IEEE_PARAM_PRIVACY_INVOKED 4
-#define IEEE_PARAM_AUTH_ALGS 5
-#define IEEE_PARAM_IEEE_802_1X 6
-//It should consistent with the driver_XXX.c
-// David, 2006.9.26
-#define IEEE_PARAM_WPAX_SELECT 7
-//Added for notify the encryption type selection
-// David, 2006.9.26
-#define IEEE_PROTO_WPA 1
-#define IEEE_PROTO_RSN 2
-//Added for notify the encryption type selection
-// David, 2006.9.26
-#define IEEE_WPAX_USEGROUP 0
-#define IEEE_WPAX_WEP40 1
-#define IEEE_WPAX_TKIP 2
-#define IEEE_WPAX_WRAP 3
-#define IEEE_WPAX_CCMP 4
-#define IEEE_WPAX_WEP104 5
-
-#define IEEE_KEY_MGMT_IEEE8021X 1
-#define IEEE_KEY_MGMT_PSK 2
-
-#define IEEE_MLME_STA_DEAUTH 1
-#define IEEE_MLME_STA_DISASSOC 2
-
-
-#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
-#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
-#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
-#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
-#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
-#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
-
-
-#define IEEE_CRYPT_ALG_NAME_LEN 16
-
-#define MAX_IE_LEN 0xff
-
-typedef struct ieee_param {
- u32 cmd;
- u8 sta_addr[ETH_ALEN];
- union {
- struct {
- u8 name;
- u32 value;
- } wpa_param;
- struct {
- u32 len;
- u8 reserved[32];
- u8 data[0];
- } wpa_ie;
- struct{
- int command;
- int reason_code;
- } mlme;
- struct {
- u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
- u8 set_tx;
- u32 err;
- u8 idx;
- u8 seq[8]; /* sequence counter (set: RX, get: TX) */
- u16 key_len;
- u8 key[0];
- } crypt;
- } u;
-}ieee_param;
-
-#define MSECS(t) msecs_to_jiffies(t)
-#define msleep_interruptible_rsl msleep_interruptible
-
-#define IEEE80211_DATA_LEN 2304
-/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
- 6.2.1.1.2.
-
- The figure in section 7.1.2 suggests a body size of up to 2312
- bytes is allowed, which is a bit confusing, I suspect this
- represents the 2304 bytes of real data, plus a possible 8 bytes of
- WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
-#define IEEE80211_1ADDR_LEN 10
-#define IEEE80211_2ADDR_LEN 16
-#define IEEE80211_3ADDR_LEN 24
-#define IEEE80211_4ADDR_LEN 30
-#define IEEE80211_FCS_LEN 4
-#define IEEE80211_HLEN IEEE80211_4ADDR_LEN
-#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
-#define IEEE80211_MGMT_HDR_LEN 24
-#define IEEE80211_DATA_HDR3_LEN 24
-#define IEEE80211_DATA_HDR4_LEN 30
-
-#define MIN_FRAG_THRESHOLD 256U
-#define MAX_FRAG_THRESHOLD 2346U
-
-
-/* Frame control field constants */
-#define IEEE80211_FCTL_FRAMETYPE 0x00fc
-#define IEEE80211_FCTL_DSTODS 0x0300 //added by david
-#define IEEE80211_FCTL_WEP 0x4000
-
-/* management */
-#define IEEE80211_STYPE_MANAGE_ACT 0x00D0
-
-/* control */
-#define IEEE80211_STYPE_BLOCKACK 0x0094
-
-/* QOS control */
-#define IEEE80211_QCTL_TID 0x000F
-
-#define OUI_SUBTYPE_WMM_INFO 0
-#define OUI_SUBTYPE_WMM_PARAM 1
-#define OUI_SUBTYPE_QOS_CAPABI 5
-
-/* debug macros */
-#define CONFIG_IEEE80211_DEBUG
-#ifdef CONFIG_IEEE80211_DEBUG
-extern u32 ieee80211_debug_level;
-#define IEEE80211_DEBUG(level, fmt, args...) \
- do { \
- if (ieee80211_debug_level & (level)) \
- printk(KERN_DEBUG "ieee80211: " fmt, ## args); \
- } while (0)
-#define IEEE80211_DEBUG_DATA(level, data, datalen) \
- do { \
- if ((ieee80211_debug_level & (level)) == (level)) { \
- u8 *pdata = (u8 *)data; \
- int i; \
- printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \
- for (i = 0; i < (int)(datalen); i++) { \
- printk("%2x ", pdata[i]); \
- if ((i + 1) % 16 == 0) \
- printk("\n"); \
- } \
- printk("\n"); \
- } \
- } while (0)
-#else
-#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
-#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0)
-#endif /* CONFIG_IEEE80211_DEBUG */
-
-/*
- * To use the debug system;
- *
- * If you are defining a new debug classification, simply add it to the #define
- * list here in the form of:
- *
- * #define IEEE80211_DL_xxxx VALUE
- *
- * shifting value to the left one bit from the previous entry. xxxx should be
- * the name of the classification (for example, WEP)
- *
- * You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
- * classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
- * to send output to that classification.
- *
- * To add your debug level to the list of levels seen when you perform
- *
- * % cat /proc/net/ipw/debug_level
- *
- * you simply need to add your entry to the ipw_debug_levels array.
- *
- * If you do not see debug_level in /proc/net/ipw then you do not have
- * CONFIG_IEEE80211_DEBUG defined in your kernel configuration
- *
- */
-
-#define IEEE80211_DL_INFO (1<<0)
-#define IEEE80211_DL_WX (1<<1)
-#define IEEE80211_DL_SCAN (1<<2)
-#define IEEE80211_DL_STATE (1<<3)
-#define IEEE80211_DL_MGMT (1<<4)
-#define IEEE80211_DL_FRAG (1<<5)
-#define IEEE80211_DL_EAP (1<<6)
-#define IEEE80211_DL_DROP (1<<7)
-
-#define IEEE80211_DL_TX (1<<8)
-#define IEEE80211_DL_RX (1<<9)
-
-#define IEEE80211_DL_HT (1 << 10)
-#define IEEE80211_DL_BA (1 << 11)
-#define IEEE80211_DL_TS (1 << 12)
-#define IEEE80211_DL_QOS (1 << 13)
-#define IEEE80211_DL_REORDER (1 << 14)
-#define IEEE80211_DL_IOT (1 << 15)
-#define IEEE80211_DL_IPS (1 << 16)
-#define IEEE80211_DL_TRACE (1 << 29)
-#define IEEE80211_DL_DATA (1 << 30)
-#define IEEE80211_DL_ERR (1 << 31)
-
-#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
-#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
-#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
-
-#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
-#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
-#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
-#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
-#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
-#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
-#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
-#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
-#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
-#define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
-
-#include <linux/netdevice.h>
-#include <linux/if_arp.h> /* ARPHRD_ETHER */
-
-#ifndef WIRELESS_SPY
-#define WIRELESS_SPY // enable iwspy support
-#endif
-#include <net/iw_handler.h> // new driver API
-
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif /* ETH_P_PAE */
-
-#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
-
-#ifndef ETH_P_80211_RAW
-#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
-#endif
-
-/* IEEE 802.11 defines */
-
-#define P80211_OUI_LEN 3
-
-struct ieee80211_snap_hdr {
-
- u8 dsap; /* always 0xAA */
- u8 ssap; /* always 0xAA */
- u8 ctrl; /* always 0x03 */
- u8 oui[P80211_OUI_LEN]; /* organizational universal id */
-
-} __attribute__ ((packed));
-
-#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
-
-#define WLAN_FC_GET_VERS(fc) ((fc) & IEEE80211_FCTL_VERS)
-#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
-#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
-
-#define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & IEEE80211_FCTL_FRAMETYPE)
-#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
-#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
-
-#define RTL_WLAN_AUTH_LEAP 2
-
-#define WLAN_CAPABILITY_BSS (1<<0)
-#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
-
-#define IEEE80211_STATMASK_SIGNAL (1<<0)
-#define IEEE80211_STATMASK_RSSI (1<<1)
-#define IEEE80211_STATMASK_NOISE (1<<2)
-#define IEEE80211_STATMASK_RATE (1<<3)
-#define IEEE80211_STATMASK_WEMASK 0x7
-
-#define IEEE80211_CCK_MODULATION (1<<0)
-#define IEEE80211_OFDM_MODULATION (1<<1)
-
-#define IEEE80211_24GHZ_BAND (1<<0)
-#define IEEE80211_52GHZ_BAND (1<<1)
-
-#define IEEE80211_CCK_RATE_LEN 4
-#define IEEE80211_CCK_RATE_1MB 0x02
-#define IEEE80211_CCK_RATE_2MB 0x04
-#define IEEE80211_CCK_RATE_5MB 0x0B
-#define IEEE80211_CCK_RATE_11MB 0x16
-#define IEEE80211_OFDM_RATE_LEN 8
-#define IEEE80211_OFDM_RATE_6MB 0x0C
-#define IEEE80211_OFDM_RATE_9MB 0x12
-#define IEEE80211_OFDM_RATE_12MB 0x18
-#define IEEE80211_OFDM_RATE_18MB 0x24
-#define IEEE80211_OFDM_RATE_24MB 0x30
-#define IEEE80211_OFDM_RATE_36MB 0x48
-#define IEEE80211_OFDM_RATE_48MB 0x60
-#define IEEE80211_OFDM_RATE_54MB 0x6C
-#define IEEE80211_BASIC_RATE_MASK 0x80
-
-#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
-#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
-#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
-#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
-#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
-#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
-#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
-#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
-#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
-#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
-#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
-#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
-
-#define IEEE80211_CCK_RATES_MASK 0x0000000F
-#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
- IEEE80211_CCK_RATE_2MB_MASK)
-#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
- IEEE80211_CCK_RATE_5MB_MASK | \
- IEEE80211_CCK_RATE_11MB_MASK)
-
-#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
-#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
- IEEE80211_OFDM_RATE_12MB_MASK | \
- IEEE80211_OFDM_RATE_24MB_MASK)
-#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
- IEEE80211_OFDM_RATE_9MB_MASK | \
- IEEE80211_OFDM_RATE_18MB_MASK | \
- IEEE80211_OFDM_RATE_36MB_MASK | \
- IEEE80211_OFDM_RATE_48MB_MASK | \
- IEEE80211_OFDM_RATE_54MB_MASK)
-#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
- IEEE80211_CCK_DEFAULT_RATES_MASK)
-
-#define IEEE80211_NUM_OFDM_RATES 8
-#define IEEE80211_NUM_CCK_RATES 4
-#define IEEE80211_OFDM_SHIFT_MASK_A 4
-
-
-/* this is stolen and modified from the madwifi driver*/
-#define IEEE80211_FC0_TYPE_MASK 0x0c
-#define IEEE80211_FC0_TYPE_DATA 0x08
-#define IEEE80211_FC0_SUBTYPE_MASK 0xB0
-#define IEEE80211_FC0_SUBTYPE_QOS 0x80
-
-#define IEEE80211_QOS_HAS_SEQ(fc) \
- (((fc) & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == \
- (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS))
-
-/* this is stolen from ipw2200 driver */
-#define IEEE_IBSS_MAC_HASH_SIZE 31
-struct ieee_ibss_seq {
- u8 mac[ETH_ALEN];
- u16 seq_num[17];
- u16 frag_num[17];
- unsigned long packet_time[17];
- struct list_head list;
-};
-
-/* NOTE: This data is for statistical purposes; not all hardware provides this
- * information for frames received. Not setting these will not cause
- * any adverse affects. */
-struct ieee80211_rx_stats {
- u32 mac_time[2];
- s8 rssi;
- u8 signal;
- u8 noise;
- u16 rate; /* in 100 kbps */
- u8 received_channel;
- u8 control;
- u8 mask;
- u8 freq;
- u16 len;
- u64 tsf;
- u32 beacon_time;
- u8 nic_type;
-
- u16 Length;
- u8 SignalQuality; /* in 0-100 index */
- /* real power in dBm for this packet, no beautification & aggregation */
- s32 RecvSignalPower;
- s8 RxPower; /* in dBm Translate from PWdB */
- u8 SignalStrength; /* in 0-100 index */
- u16 bHwError:1;
- u16 bCRC:1;
- u16 bICV:1;
- u16 bShortPreamble:1;
- u16 Antenna:1; /* RTL8185 */
- u16 Decrypted:1; /* RTL8185, RTL8187 */
- u16 Wakeup:1; /* RTL8185 */
- u16 Reserved0:1; /* RTL8185 */
- u8 AGC;
- u32 TimeStampLow;
- u32 TimeStampHigh;
- bool bShift;
- bool bIsQosData;
- u8 UserPriority;
-
- /* < 11n or 8190 specific code */
- u8 RxDrvInfoSize;
- u8 RxBufShift;
- bool bIsAMPDU;
- bool bFirstMPDU;
- bool bContainHTC;
- bool RxIs40MHzPacket;
- u32 RxPWDBAll;
- u8 RxMIMOSignalStrength[4]; /* in 0~100 index */
- s8 RxMIMOSignalQuality[2];
- bool bPacketMatchBSSID;
- bool bIsCCK;
- bool bPacketToSelf;
-
- u8 *virtual_address;
- /* total packet length: must equal to sum of all FragLength */
- u16 packetlength;
- /* FragLength should equal to PacketLength in non-fragment case */
- u16 fraglength;
- u16 fragoffset; /* data offset for this fragment */
- u16 ntotalfrag;
- bool bisrxaggrsubframe;
- bool bPacketBeacon; /* for rssi */
- bool bToSelfBA; /* for rssi */
- char cck_adc_pwdb[4]; /* for rx path selection */
- u16 Seq_Num;
- u8 nTotalAggPkt; /* number of aggregated packets */
-};
-
-/* IEEE 802.11 requires that STA supports concurrent reception of at least
- * three fragmented frames. This define can be increased to support more
- * concurrent frames, but it should be noted that each entry can consume about
- * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
-#define IEEE80211_FRAG_CACHE_LEN 4
-
-struct ieee80211_frag_entry {
- unsigned long first_frag_time;
- unsigned int seq;
- unsigned int last_frag;
- struct sk_buff *skb;
- u8 src_addr[ETH_ALEN];
- u8 dst_addr[ETH_ALEN];
-};
-
-struct ieee80211_stats {
- unsigned int tx_unicast_frames;
- unsigned int tx_multicast_frames;
- unsigned int tx_fragments;
- unsigned int tx_unicast_octets;
- unsigned int tx_multicast_octets;
- unsigned int tx_deferred_transmissions;
- unsigned int tx_single_retry_frames;
- unsigned int tx_multiple_retry_frames;
- unsigned int tx_retry_limit_exceeded;
- unsigned int tx_discards;
- unsigned int rx_unicast_frames;
- unsigned int rx_multicast_frames;
- unsigned int rx_fragments;
- unsigned int rx_unicast_octets;
- unsigned int rx_multicast_octets;
- unsigned int rx_fcs_errors;
- unsigned int rx_discards_no_buffer;
- unsigned int tx_discards_wrong_sa;
- unsigned int rx_discards_undecryptable;
- unsigned int rx_message_in_msg_fragments;
- unsigned int rx_message_in_bad_msg_fragments;
-};
-
-struct ieee80211_device;
-
-#include "ieee80211_crypt.h"
-
-#define SEC_KEY_1 (1<<0)
-#define SEC_KEY_2 (1<<1)
-#define SEC_KEY_3 (1<<2)
-#define SEC_KEY_4 (1<<3)
-#define SEC_ACTIVE_KEY (1<<4)
-#define SEC_AUTH_MODE (1<<5)
-#define SEC_UNICAST_GROUP (1<<6)
-#define SEC_LEVEL (1<<7)
-#define SEC_ENABLED (1<<8)
-
-#define SEC_LEVEL_0 0 /* None */
-#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
-#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
-#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
-#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
-
-#define WEP_KEYS 4
-#define WEP_KEY_LEN 13
-#define SCM_KEY_LEN 32
-
-struct ieee80211_security {
- u16 active_key:2,
- enabled:1,
- auth_mode:2,
- auth_algo:4,
- unicast_uses_group:1,
- encrypt:1;
- u8 key_sizes[WEP_KEYS];
- u8 keys[WEP_KEYS][SCM_KEY_LEN];
- u8 level;
- u16 flags;
-} __attribute__ ((packed));
-
-
-/*
- 802.11 data frame from AP
- ,-------------------------------------------------------------------.
-Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
- |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
- | | tion | (BSSID) | | | ence | data | |
- `-------------------------------------------------------------------'
-Total: 28-2340 bytes
-*/
-
-/* Management Frame Information Element Types */
-enum {
- MFIE_TYPE_SSID = 0,
- MFIE_TYPE_RATES = 1,
- MFIE_TYPE_FH_SET = 2,
- MFIE_TYPE_DS_SET = 3,
- MFIE_TYPE_CF_SET = 4,
- MFIE_TYPE_TIM = 5,
- MFIE_TYPE_IBSS_SET = 6,
- MFIE_TYPE_COUNTRY = 7,
- MFIE_TYPE_HOP_PARAMS = 8,
- MFIE_TYPE_HOP_TABLE = 9,
- MFIE_TYPE_REQUEST = 10,
- MFIE_TYPE_CHALLENGE = 16,
- MFIE_TYPE_POWER_CONSTRAINT = 32,
- MFIE_TYPE_POWER_CAPABILITY = 33,
- MFIE_TYPE_TPC_REQUEST = 34,
- MFIE_TYPE_TPC_REPORT = 35,
- MFIE_TYPE_SUPP_CHANNELS = 36,
- MFIE_TYPE_CSA = 37,
- MFIE_TYPE_MEASURE_REQUEST = 38,
- MFIE_TYPE_MEASURE_REPORT = 39,
- MFIE_TYPE_QUIET = 40,
- MFIE_TYPE_IBSS_DFS = 41,
- MFIE_TYPE_ERP = 42,
- MFIE_TYPE_RSN = 48,
- MFIE_TYPE_RATES_EX = 50,
- MFIE_TYPE_HT_CAP= 45,
- MFIE_TYPE_HT_INFO= 61,
- MFIE_TYPE_AIRONET=133,
- MFIE_TYPE_GENERIC = 221,
- MFIE_TYPE_QOS_PARAMETER = 222,
-};
-
-/* Minimal header; can be used for passing 802.11 frames with sufficient
- * information to determine what type of underlying data type is actually
- * stored in the data. */
-struct rtl_ieee80211_hdr {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 payload[0];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_1addr {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 payload[0];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_2addr {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 payload[0];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_4addr {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- __le16 seq_ctl;
- u8 addr4[ETH_ALEN];
- u8 payload[0];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_3addrqos {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- __le16 seq_ctl;
- u8 payload[0];
- __le16 qos_ctl;
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_4addrqos {
- __le16 frame_ctl;
- __le16 duration_id;
- u8 addr1[ETH_ALEN];
- u8 addr2[ETH_ALEN];
- u8 addr3[ETH_ALEN];
- __le16 seq_ctl;
- u8 addr4[ETH_ALEN];
- u8 payload[0];
- __le16 qos_ctl;
-} __attribute__ ((packed));
-
-struct ieee80211_info_element {
- u8 id;
- u8 len;
- u8 data[0];
-} __attribute__ ((packed));
-
-struct ieee80211_authentication {
- struct ieee80211_hdr_3addr header;
- __le16 algorithm;
- __le16 transaction;
- __le16 status;
- /* challenge */
- struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_disassoc {
- struct ieee80211_hdr_3addr header;
- __le16 reason;
-} __attribute__ ((packed));
-
-struct ieee80211_probe_request {
- struct ieee80211_hdr_3addr header;
- /* SSID, supported rates */
- struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_probe_response {
- struct ieee80211_hdr_3addr header;
- u32 time_stamp[2];
- __le16 beacon_interval;
- __le16 capability;
- /* SSID, supported rates, FH params, DS params,
- * CF params, IBSS params, TIM (if beacon), RSN */
- struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_assoc_request_frame {
- struct ieee80211_hdr_3addr header;
- __le16 capability;
- __le16 listen_interval;
- /* SSID, supported rates, RSN */
- struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_reassoc_request_frame {
- struct ieee80211_hdr_3addr header;
- __le16 capability;
- __le16 listen_interval;
- u8 current_ap[ETH_ALEN];
- /* SSID, supported rates, RSN */
- struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_assoc_response_frame {
- struct ieee80211_hdr_3addr header;
- __le16 capability;
- __le16 status;
- __le16 aid;
- struct ieee80211_info_element info_element[0]; /* supported rates */
-} __attribute__ ((packed));
-
-struct ieee80211_txb {
- u8 nr_frags;
- u8 encrypted;
- u8 queue_index;
- u8 rts_included;
- u16 reserved;
- __le16 frag_size;
- __le16 payload_size;
- struct sk_buff *fragments[0];
-};
-
-#define MAX_SUBFRAME_COUNT 64
-struct ieee80211_rxb {
- u8 nr_subframes;
- struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
- u8 dst[ETH_ALEN];
- u8 src[ETH_ALEN];
-}__attribute__((packed));
-
-/* SWEEP TABLE ENTRIES NUMBER */
-#define MAX_SWEEP_TAB_ENTRIES 42
-#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
-/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
- * only use 8, and then use extended rates for the remaining supported
- * rates. Other APs, however, stick all of their supported rates on the
- * main rates information element... */
-#define MAX_RATES_LENGTH ((u8)12)
-#define MAX_RATES_EX_LENGTH ((u8)16)
-#define MAX_NETWORK_COUNT 128
-
-#define MAX_CHANNEL_NUMBER 161
-
-#define IEEE80211_SOFTMAC_SCAN_TIME 100 /* (HZ / 2) */
-#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
-
-#define CRC_LENGTH 4U
-
-#define MAX_WPA_IE_LEN 64
-
-#define NETWORK_EMPTY_ESSID (1 << 0)
-#define NETWORK_HAS_OFDM (1 << 1)
-#define NETWORK_HAS_CCK (1 << 2)
-
-/* QoS structure */
-#define NETWORK_HAS_QOS_PARAMETERS (1 << 3)
-#define NETWORK_HAS_QOS_INFORMATION (1 << 4)
-#define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
- NETWORK_HAS_QOS_INFORMATION)
-
-#define NETWORK_HAS_ERP_VALUE (1 << 10)
-
-#define QOS_QUEUE_NUM 4
-#define QOS_OUI_LEN 3
-#define QOS_OUI_TYPE 2
-#define QOS_ELEMENT_ID 221
-#define QOS_OUI_INFO_SUB_TYPE 0
-#define QOS_OUI_PARAM_SUB_TYPE 1
-#define QOS_VERSION_1 1
-#define QOS_AIFSN_MIN_VALUE 2
-
-struct ieee80211_qos_information_element {
- u8 elementID;
- u8 length;
- u8 qui[QOS_OUI_LEN];
- u8 qui_type;
- u8 qui_subtype;
- u8 version;
- u8 ac_info;
-} __attribute__ ((packed));
-
-struct ieee80211_qos_ac_parameter {
- u8 aci_aifsn;
- u8 ecw_min_max;
- __le16 tx_op_limit;
-} __attribute__ ((packed));
-
-struct ieee80211_qos_parameter_info {
- struct ieee80211_qos_information_element info_element;
- u8 reserved;
- struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
-} __attribute__ ((packed));
-
-struct ieee80211_qos_parameters {
- __le16 cw_min[QOS_QUEUE_NUM];
- __le16 cw_max[QOS_QUEUE_NUM];
- u8 aifs[QOS_QUEUE_NUM];
- u8 flag[QOS_QUEUE_NUM];
- __le16 tx_op_limit[QOS_QUEUE_NUM];
-} __attribute__ ((packed));
-
-struct ieee80211_qos_data {
- struct ieee80211_qos_parameters parameters;
- int active;
- int supported;
- u8 param_count;
- u8 old_param_count;
-};
-
-struct ieee80211_tim_parameters {
- u8 tim_count;
- u8 tim_period;
-} __attribute__ ((packed));
-
-struct ieee80211_wmm_ac_param {
- u8 ac_aci_acm_aifsn;
- u8 ac_ecwmin_ecwmax;
- u16 ac_txop_limit;
-};
-
-struct ieee80211_wmm_ts_info {
- u8 ac_dir_tid;
- u8 ac_up_psb;
- u8 reserved;
-} __attribute__ ((packed));
-
-struct ieee80211_wmm_tspec_elem {
- struct ieee80211_wmm_ts_info ts_info;
- u16 norm_msdu_size;
- u16 max_msdu_size;
- u32 min_serv_inter;
- u32 max_serv_inter;
- u32 inact_inter;
- u32 suspen_inter;
- u32 serv_start_time;
- u32 min_data_rate;
- u32 mean_data_rate;
- u32 peak_data_rate;
- u32 max_burst_size;
- u32 delay_bound;
- u32 min_phy_rate;
- u16 surp_band_allow;
- u16 medium_time;
-}__attribute__((packed));
-
-enum eap_type {
- EAP_PACKET = 0,
- EAPOL_START,
- EAPOL_LOGOFF,
- EAPOL_KEY,
- EAPOL_ENCAP_ASF_ALERT
-};
-
-static const char *eap_types[] = {
- [EAP_PACKET] = "EAP-Packet",
- [EAPOL_START] = "EAPOL-Start",
- [EAPOL_LOGOFF] = "EAPOL-Logoff",
- [EAPOL_KEY] = "EAPOL-Key",
- [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
-};
-
-static inline const char *eap_get_type(int type)
-{
- return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
-}
-
-struct eapol {
- u8 snap[6];
- u16 ethertype;
- u8 version;
- u8 type;
- u16 length;
-} __attribute__ ((packed));
-
-struct ieee80211_softmac_stats {
- unsigned int rx_ass_ok;
- unsigned int rx_ass_err;
- unsigned int rx_probe_rq;
- unsigned int tx_probe_rs;
- unsigned int tx_beacons;
- unsigned int rx_auth_rq;
- unsigned int rx_auth_rs_ok;
- unsigned int rx_auth_rs_err;
- unsigned int tx_auth_rq;
- unsigned int no_auth_rs;
- unsigned int no_ass_rs;
- unsigned int tx_ass_rq;
- unsigned int rx_ass_rq;
- unsigned int tx_probe_rq;
- unsigned int reassoc;
- unsigned int swtxstop;
- unsigned int swtxawake;
- unsigned char CurrentShowTxate;
- unsigned char last_packet_rate;
- unsigned int txretrycount;
-};
-
-#define BEACON_PROBE_SSID_ID_POSITION 12
-
-struct ieee80211_info_element_hdr {
- u8 id;
- u8 len;
-} __attribute__ ((packed));
-
-/*
- * These are the data types that can make up management packets
- *
- u16 auth_algorithm;
- u16 auth_sequence;
- u16 beacon_interval;
- u16 capability;
- u8 current_ap[ETH_ALEN];
- u16 listen_interval;
- struct {
- u16 association_id:14, reserved:2;
- } __attribute__ ((packed));
- u32 time_stamp[2];
- u16 reason;
- u16 status;
-*/
-
-#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
-#define IEEE80211_DEFAULT_BASIC_RATE 2 /* 1Mbps */
-
-enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame};
-#define MAX_SP_Len (WMM_all_frame << 4)
-#define IEEE80211_QOS_TID 0x0f
-#define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
-
-#define IEEE80211_DTIM_MBCAST 4
-#define IEEE80211_DTIM_UCAST 2
-#define IEEE80211_DTIM_VALID 1
-#define IEEE80211_DTIM_INVALID 0
-
-#define IEEE80211_PS_DISABLED 0
-#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
-#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
-
-//added by David for QoS 2006/6/30
-//#define WMM_Hang_8187
-#ifdef WMM_Hang_8187
-#undef WMM_Hang_8187
-#endif
-
-#define WME_AC_BK 0x00
-#define WME_AC_BE 0x01
-#define WME_AC_VI 0x02
-#define WME_AC_VO 0x03
-#define WME_ACI_MASK 0x03
-#define WME_AIFSN_MASK 0x03
-#define WME_AC_PRAM_LEN 16
-
-//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
-//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1))
-#define UP2AC(up) ( \
- ((up) < 1) ? WME_AC_BE : \
- ((up) < 3) ? WME_AC_BK : \
- ((up) < 4) ? WME_AC_BE : \
- ((up) < 6) ? WME_AC_VI : \
- WME_AC_VO)
-
-//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue
-#define AC2UP(_ac) ( \
- ((_ac) == WME_AC_VO) ? 6 : \
- ((_ac) == WME_AC_VI) ? 5 : \
- ((_ac) == WME_AC_BK) ? 1 : \
- 0)
-
-#define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
-
-/* length of two Ethernet address plus ether type */
-#define ETHERNET_HEADER_SIZE 14
-
-struct ether_header {
- u8 ether_dhost[ETHER_ADDR_LEN];
- u8 ether_shost[ETHER_ADDR_LEN];
- u16 ether_type;
-} __attribute__((packed));
-
-#ifndef ETHERTYPE_PAE
-#define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
-#endif
-#ifndef ETHERTYPE_IP
-#define ETHERTYPE_IP 0x0800 /* IP protocol */
-#endif
-
-struct ieee80211_network {
- /* These entries are used to identify a unique network */
- u8 bssid[ETH_ALEN];
- u8 channel;
- /* Ensure null-terminated for any debug msgs */
- u8 ssid[IW_ESSID_MAX_SIZE + 1];
- u8 ssid_len;
-
- struct ieee80211_qos_data qos_data;
-
- /* for LEAP */
- bool bWithAironetIE;
- bool bCkipSupported;
- bool bCcxRmEnable;
- u16 CcxRmState[2];
-
- /* CCXv4 S59, MBSSID. */
- bool bMBssidValid;
- u8 MBssidMask;
- u8 MBssid[6];
-
- /* CCX 2 S38, WLAN Device Version Number element. */
- bool bWithCcxVerNum;
- u8 BssCcxVerNumber;
-
- /* These are network statistics */
- struct ieee80211_rx_stats stats;
- u16 capability;
- u8 rates[MAX_RATES_LENGTH];
- u8 rates_len;
- u8 rates_ex[MAX_RATES_EX_LENGTH];
- u8 rates_ex_len;
- unsigned long last_scanned;
- u8 mode;
- u32 flags;
- u32 last_associate;
- u32 time_stamp[2];
- u16 beacon_interval;
- u16 listen_interval;
- u16 atim_window;
- u8 erp_value;
- u8 wpa_ie[MAX_WPA_IE_LEN];
- size_t wpa_ie_len;
- u8 rsn_ie[MAX_WPA_IE_LEN];
- size_t rsn_ie_len;
-
- struct ieee80211_tim_parameters tim;
- u8 dtim_period;
- u8 dtim_data;
- u32 last_dtim_sta_time[2];
-
- //appeded for QoS
- u8 wmm_info;
- struct ieee80211_wmm_ac_param wmm_param[4];
- u8 QoS_Enable;
- u8 Turbo_Enable;//enable turbo mode, added by thomas
- u16 CountryIeLen;
- u8 CountryIeBuf[MAX_IE_LEN];
-
- /* HT Related */
- BSS_HT bssht;
- /* Added to handle broadcom AP management frame CCK rate. */
- bool broadcom_cap_exist;
- bool realtek_cap_exit;
- bool marvell_cap_exist;
- bool ralink_cap_exist;
- bool atheros_cap_exist;
- bool cisco_cap_exist;
- bool unknown_cap_exist;
- bool berp_info_valid;
- bool buseprotection;
-
- struct list_head list; /* put at the end of the structure */
-};
-
-enum ieee80211_state {
-
- /* the card is not linked at all */
- IEEE80211_NOLINK = 0,
-
- /* IEEE80211_ASSOCIATING* are for BSS client mode
- * the driver shall not perform RX filtering unless
- * the state is LINKED.
- * The driver shall just check for the state LINKED and
- * defaults to NOLINK for ALL the other states (including
- * LINKED_SCANNING)
- */
-
- /* the association procedure will start (wq scheduling)*/
- IEEE80211_ASSOCIATING,
- IEEE80211_ASSOCIATING_RETRY,
-
- /* the association procedure is sending AUTH request*/
- IEEE80211_ASSOCIATING_AUTHENTICATING,
-
- /* the association procedure has successfully authentcated
- * and is sending association request
- */
- IEEE80211_ASSOCIATING_AUTHENTICATED,
-
- /* the link is ok. the card associated to a BSS or linked
- * to a ibss cell or acting as an AP and creating the bss
- */
- IEEE80211_LINKED,
-
- /* same as LINKED, but the driver shall apply RX filter
- * rules as we are in NO_LINK mode. As the card is still
- * logically linked, but it is doing a syncro site survey
- * then it will be back to LINKED state.
- */
- IEEE80211_LINKED_SCANNING,
-
-};
-
-#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
-#define DEFAULT_FTS 2346
-
-#define CFG_IEEE80211_RESERVE_FCS (1<<0)
-#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
-
-#define IEEE80211_24GHZ_MIN_CHANNEL 1
-#define IEEE80211_24GHZ_MAX_CHANNEL 14
-#define IEEE80211_24GHZ_CHANNELS (IEEE80211_24GHZ_MAX_CHANNEL - \
- IEEE80211_24GHZ_MIN_CHANNEL + 1)
-
-#define IEEE80211_52GHZ_MIN_CHANNEL 34
-#define IEEE80211_52GHZ_MAX_CHANNEL 165
-#define IEEE80211_52GHZ_CHANNELS (IEEE80211_52GHZ_MAX_CHANNEL - \
- IEEE80211_52GHZ_MIN_CHANNEL + 1)
-
-typedef struct tx_pending_t{
- int frag;
- struct ieee80211_txb *txb;
-}tx_pending_t;
-
-enum {
- COUNTRY_CODE_FCC = 0,
- COUNTRY_CODE_IC = 1,
- COUNTRY_CODE_ETSI = 2,
- COUNTRY_CODE_SPAIN = 3,
- COUNTRY_CODE_FRANCE = 4,
- COUNTRY_CODE_MKK = 5,
- COUNTRY_CODE_MKK1 = 6,
- COUNTRY_CODE_ISRAEL = 7,
- COUNTRY_CODE_TELEC = 8,
- COUNTRY_CODE_MIC = 9,
- COUNTRY_CODE_GLOBAL_DOMAIN = 10,
- COUNTRY_CODE_WORLD_WIDE_13 = 11,
- COUNTRY_CODE_TELEC_NETGEAR = 12,
- COUNTRY_CODE_MAX
-};
-
-#define NUM_PMKID_CACHE 16
-
-typedef struct _RT_PMKID_LIST
-{
- u8 bUsed;
- u8 Bssid[6];
- u8 PMKID[16];
- u8 SsidBuf[33];
- u8* ssid_octet;
- u16 ssid_length;
-} RT_PMKID_LIST, *PRT_PMKID_LIST;
-
-
-#include "ieee80211_r8192s.h"
-
-struct ieee80211_device {
- struct net_device *dev;
- struct ieee80211_security sec;
-
- /* hw security related */
- u8 hwsec_active;
- bool is_silent_reset;
- bool force_mic_error;
- bool is_roaming;
- bool ieee_up;
- bool bSupportRemoteWakeUp;
- RT_PS_MODE dot11PowerSaveMode;
- bool actscanning;
- bool be_scan_inprogress;
- bool beinretry;
- RT_RF_POWER_STATE eRFPowerState;
- u32 RfOffReason;
- bool is_set_key;
-
- /* 11n HT below */
- PRT_HIGH_THROUGHPUT pHTInfo;
- spinlock_t bw_spinlock;
-
- spinlock_t reorder_spinlock;
- /*
- * for HT operation rate set, we use this one for HT data rate to
- * separate different descriptors the way fill this is the same as
- * in the IE
- */
- u8 Regdot11HTOperationalRateSet[16]; /* use RATR format */
- u8 dot11HTOperationalRateSet[16]; /* use RATR format */
- u8 RegHTSuppRateSet[16];
- u8 HTCurrentOperaRate;
- u8 HTHighestOperaRate;
- /* for rate operation mode to firmware */
- u8 bTxDisableRateFallBack;
- u8 bTxUseDriverAssingedRate;
- atomic_t atm_chnlop;
- atomic_t atm_swbw;
-
- /* 802.11e and WMM Traffic Stream Info (TX) */
- struct list_head Tx_TS_Admit_List;
- struct list_head Tx_TS_Pending_List;
- struct list_head Tx_TS_Unused_List;
- TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM];
- /* 802.11e and WMM Traffic Stream Info (RX) */
- struct list_head Rx_TS_Admit_List;
- struct list_head Rx_TS_Pending_List;
- struct list_head Rx_TS_Unused_List;
- RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM];
-
- RX_REORDER_ENTRY RxReorderEntry[128];
- struct list_head RxReorder_Unused_List;
-
- /* Qos related */
- /* Force per-packet priority 1~7. (default: 0, not to force it.) */
- u8 ForcedPriority;
-
- /* Bookkeeping structures */
- struct net_device_stats stats;
- struct ieee80211_stats ieee_stats;
- struct ieee80211_softmac_stats softmac_stats;
-
- /* Probe / Beacon management */
- struct list_head network_free_list;
- struct list_head network_list;
- struct ieee80211_network *networks;
- int scans;
- int scan_age;
-
- int iw_mode; /* operating mode (IW_MODE_*) */
- struct iw_spy_data spy_data;
-
- spinlock_t lock;
- spinlock_t wpax_suitlist_lock;
-
- int tx_headroom; /* Set to size of any additional room needed at front
- * of allocated Tx SKBs */
- u32 config;
-
- /* WEP and other encryption related settings at the device level */
- int open_wep; /* Set to 1 to allow unencrypted frames */
- int auth_mode;
- int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
- * WEP key changes */
-
- /* If the host performs {en,de}cryption, then set to 1 */
- int host_encrypt;
- int host_encrypt_msdu;
- int host_decrypt;
- /* host performs multicast decryption */
- int host_mc_decrypt;
-
- /* host should strip IV and ICV from protected frames */
- /* meaningful only when hardware decryption is being used */
- int host_strip_iv_icv;
-
- int host_open_frag;
- int host_build_iv;
- int ieee802_1x; /* is IEEE 802.1X used */
-
- /* WPA data */
- bool bHalfWirelessN24GMode;
- int wpa_enabled;
- int drop_unencrypted;
- int tkip_countermeasures;
- int privacy_invoked;
- size_t wpa_ie_len;
- u8 *wpa_ie;
- u8 ap_mac_addr[6];
- u16 pairwise_key_type;
- u16 group_key_type;
- struct list_head crypt_deinit_list;
- struct ieee80211_crypt_data *crypt[WEP_KEYS];
- int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
- struct timer_list crypt_deinit_timer;
- int crypt_quiesced;
-
- int bcrx_sta_key; /* use individual keys to override default keys even
- * with RX of broad/multicast frames */
-
- RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
- /* Fragmentation structures */
- // each streaming contain a entry
- struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
- unsigned int frag_next_idx[17];
- u16 fts; /* Fragmentation Threshold */
-#define DEFAULT_RTS_THRESHOLD 2346U
-#define MIN_RTS_THRESHOLD 1
-#define MAX_RTS_THRESHOLD 2346U
- u16 rts; /* RTS threshold */
-
- /* Association info */
- u8 bssid[ETH_ALEN];
-
- /* This stores infos for the current network.
- * Either the network we are associated in INFRASTRUCTURE
- * or the network that we are creating in MASTER mode.
- * ad-hoc is a mixture ;-).
- * Note that in infrastructure mode, even when not associated,
- * fields bssid and essid may be valid (if wpa_set and essid_set
- * are true) as thy carry the value set by the user via iwconfig
- */
- struct ieee80211_network current_network;
-
- enum ieee80211_state state;
-
- int short_slot;
- int reg_mode;
- int mode; /* A, B, G */
- int modulation; /* CCK, OFDM */
- int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
- int abg_true; /* ABG flag */
-
- /* used for forcing the ibss workqueue to terminate
- * without wait for the syncro scan to terminate
- */
- short sync_scan_hurryup;
- u16 scan_watch_dog;
- int perfect_rssi;
- int worst_rssi;
-
- u16 prev_seq_ctl; /* used to drop duplicate frames */
-
- /*
- * map of allowed channels. 0 is dummy, FIXME: remeber to default to
- * a basic channel plan depending of the PHY type
- */
- void *pDot11dInfo;
- bool bGlobalDomain;
-
- u8 IbssStartChnl;
- u8 ibss_maxjoin_chal;
-
- int rate; /* current rate */
- int basic_rate;
- //FIXME: pleace callback, see if redundant with softmac_features
- short active_scan;
-
- /* this contains flags for selectively enable softmac support */
- u16 softmac_features;
-
- /* if the sequence control field is not filled by HW */
- u16 seq_ctrl[5];
-
- /* association procedure transaction sequence number */
- u16 associate_seq;
-
- /* AID for RTXed association responses */
- u16 assoc_id;
-
- /* power save mode related*/
- u8 ack_tx_to_ieee;
- short ps;
- short sta_sleep;
- int ps_timeout;
- int ps_period;
- struct tasklet_struct ps_task;
- u32 ps_th;
- u32 ps_tl;
-
- short raw_tx;
- /* used if IEEE_SOFTMAC_TX_QUEUE is set */
- short queue_stop;
- short scanning;
- short proto_started;
-
- struct semaphore wx_sem;
- struct semaphore scan_sem;
-
- spinlock_t mgmt_tx_lock;
- spinlock_t beacon_lock;
-
- short beacon_txing;
-
- short wap_set;
- short ssid_set;
-
- u8 wpax_type_set; //{added by David, 2006.9.28}
- u32 wpax_type_notify; //{added by David, 2006.9.26}
-
- /* QoS related flag */
- char init_wmmparam_flag;
- /* set on initialization */
- u8 qos_support;
-
- /* for discarding duplicated packets in IBSS */
- struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
-
- /* for discarding duplicated packets in BSS */
- u16 last_rxseq_num[17]; /* rx seq previous per-tid */
- u16 last_rxfrag_num[17];/* tx frag previous per-tid */
- unsigned long last_packet_time[17];
-
- /* for PS mode */
- unsigned long last_rx_ps_time;
-
- /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
- struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
- int mgmt_queue_head;
- int mgmt_queue_tail;
-
-/* rtl819x start */
- u8 AsocRetryCount;
- unsigned int hw_header;
- struct sk_buff_head skb_waitQ[MAX_QUEUE_SIZE];
- struct sk_buff_head skb_aggQ[MAX_QUEUE_SIZE];
- struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE];
- u32 sta_edca_param[4];
- bool aggregation;
- /* Enable/Disable Rx immediate BA capability. */
- bool enable_rx_imm_BA;
- bool bibsscoordinator;
-
- /* Dynamic Tx power for near/far range enable/disable. */
- bool bdynamic_txpower_enable;
-
- bool bCTSToSelfEnable;
- u8 CTSToSelfTH;
-
- u32 fsync_time_interval;
- u32 fsync_rate_bitmap;
- u8 fsync_rssi_threshold;
- bool bfsync_enable;
-
- u8 fsync_multiple_timeinterval; /* value * FsyncTimeInterval */
- u32 fsync_firstdiff_ratethreshold; /* low threshold */
- u32 fsync_seconddiff_ratethreshold; /* decrease threshold */
- Fsync_State fsync_state;
- bool bis_any_nonbepkts;
- /* 20Mhz 40Mhz AutoSwitch Threshold */
- struct bandwidth_autoswitch bandwidth_auto_switch;
- /* for txpower tracking */
- bool FwRWRF;
-
- /* for AP roaming */
- struct rt_link_detect LinkDetectInfo;
-
- struct rt_power_save_control PowerSaveControl;
-/* rtl819x end */
-
- /* used if IEEE_SOFTMAC_TX_QUEUE is set */
- struct tx_pending_t tx_pending;
-
- /* used if IEEE_SOFTMAC_ASSOCIATE is set */
- struct timer_list associate_timer;
-
- /* used if IEEE_SOFTMAC_BEACONS is set */
- struct timer_list beacon_timer;
- struct work_struct associate_complete_wq;
- struct work_struct associate_procedure_wq;
- struct delayed_work softmac_scan_wq;
- struct delayed_work associate_retry_wq;
- struct delayed_work start_ibss_wq;
- struct delayed_work hw_wakeup_wq;
- struct delayed_work hw_sleep_wq;
- struct delayed_work link_change_wq;
- struct work_struct wx_sync_scan_wq;
- struct workqueue_struct *wq;
-
- /* Callback functions */
- void (*set_security)(struct net_device *dev,
- struct ieee80211_security *sec);
-
- /* Used to TX data frame by using txb structs.
- * this is not used if in the softmac_features
- * is set the flag IEEE_SOFTMAC_TX_QUEUE
- */
- int (*hard_start_xmit)(struct ieee80211_txb *txb,
- struct net_device *dev);
-
- int (*reset_port)(struct net_device *dev);
- int (*is_queue_full)(struct net_device *dev, int pri);
-
- int (*handle_management)(struct net_device *dev,
- struct ieee80211_network *network, u16 type);
- int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
-
- /* Softmac-generated frames (mamagement) are TXed via this
- * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
- * not set. As some cards may have different HW queues that
- * one might want to use for data and management frames
- * the option to have two callbacks might be useful.
- * This fucntion can't sleep.
- */
- int (*softmac_hard_start_xmit)(struct sk_buff *skb,
- struct net_device *dev);
-
- /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
- * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
- * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
- * then also management frames are sent via this callback.
- * This function can't sleep.
- */
- void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
- struct net_device *dev,int rate);
-
- /* stops the HW queue for DATA frames. Useful to avoid
- * waste time to TX data frame when we are reassociating
- * This function can sleep.
- */
- void (*data_hard_stop)(struct net_device *dev);
-
- /* OK this is complementar to data_poll_hard_stop */
- void (*data_hard_resume)(struct net_device *dev);
-
- /* ask to the driver to retune the radio .
- * This function can sleep. the driver should ensure
- * the radio has been swithced before return.
- */
- void (*set_chan)(struct net_device *dev,short ch);
-
- /* These are not used if the ieee stack takes care of
- * scanning (IEEE_SOFTMAC_SCAN feature set).
- * In this case only the set_chan is used.
- *
- * The syncro version is similar to the start_scan but
- * does not return until all channels has been scanned.
- * this is called in user context and should sleep,
- * it is called in a work_queue when swithcing to ad-hoc mode
- * or in behalf of iwlist scan when the card is associated
- * and root user ask for a scan.
- * the fucntion stop_scan should stop both the syncro and
- * background scanning and can sleep.
- * The fucntion start_scan should initiate the background
- * scanning and can't sleep.
- */
- void (*scan_syncro)(struct net_device *dev);
- void (*start_scan)(struct net_device *dev);
- void (*stop_scan)(struct net_device *dev);
-
- /* indicate the driver that the link state is changed
- * for example it may indicate the card is associated now.
- * Driver might be interested in this to apply RX filter
- * rules or simply light the LINK led
- */
- void (*link_change)(struct net_device *dev);
-
- /* these two function indicates to the HW when to start
- * and stop to send beacons. This is used when the
- * IEEE_SOFTMAC_BEACONS is not set. For now the
- * stop_send_bacons is NOT guaranteed to be called only
- * after start_send_beacons.
- */
- void (*start_send_beacons) (struct net_device *dev);
- void (*stop_send_beacons) (struct net_device *dev);
-
- /* power save mode related */
- void (*sta_wake_up) (struct net_device *dev);
- void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
- short (*ps_is_queue_empty) (struct net_device *dev);
-
- int (*handle_beacon)(struct net_device *dev,
- struct ieee80211_probe_response *beacon,
- struct ieee80211_network *network);
- int (*handle_assoc_response)(struct net_device *dev,
- struct ieee80211_assoc_response_frame *resp,
- struct ieee80211_network *network);
-
- /* check whether Tx hw resouce available */
- short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
- /* HT related */
- void (*SetBWModeHandler)(struct net_device *dev,
- HT_CHANNEL_WIDTH Bandwidth,
- HT_EXTCHNL_OFFSET Offset);
- bool (*GetNmodeSupportBySecCfg)(struct net_device* dev);
- void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode);
- bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev);
- bool (*is_ap_in_wep_tkip)(struct net_device* dev);
- void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
- bool (*SetFwCmdHandler)(struct net_device *dev, FW_CMD_IO_TYPE FwCmdIO);
- void (*LedControlHandler)(struct net_device *dev,
- LED_CTL_MODE LedAction);
- /* This must be the last item so that it points to the data
- * allocated beyond this structure by alloc_ieee80211 */
- u8 priv[0];
-};
-
-#define IEEE_A (1<<0)
-#define IEEE_B (1<<1)
-#define IEEE_G (1<<2)
-#define IEEE_N_24G (1<<4)
-#define IEEE_N_5G (1<<5)
-#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
-
-/* Generate a 802.11 header */
-
-/* Uses the channel change callback directly
- * instead of [start/stop] scan callbacks
- */
-#define IEEE_SOFTMAC_SCAN (1<<2)
-
-/* Perform authentication and association handshake */
-#define IEEE_SOFTMAC_ASSOCIATE (1<<3)
-
-/* Generate probe requests */
-#define IEEE_SOFTMAC_PROBERQ (1<<4)
-
-/* Generate respones to probe requests */
-#define IEEE_SOFTMAC_PROBERS (1<<5)
-
-/* The ieee802.11 stack will manages the netif queue
- * wake/stop for the driver, taking care of 802.11
- * fragmentation. See softmac.c for details. */
-#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
-
-/* Uses only the softmac_data_hard_start_xmit
- * even for TX management frames.
- */
-#define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
-
-/* Generate beacons. The stack will enqueue beacons
- * to the card
- */
-#define IEEE_SOFTMAC_BEACONS (1<<6)
-
-static inline void *ieee80211_priv(struct net_device *dev)
-{
- return ((struct ieee80211_device *)netdev_priv(dev))->priv;
-}
-
-extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
-{
- /* Single white space is for Linksys APs */
- if (essid_len == 1 && essid[0] == ' ')
- return 1;
-
- /* Otherwise, if the entire essid is 0, we assume it is hidden */
- while (essid_len) {
- essid_len--;
- if (essid[essid_len] != '\0')
- return 0;
- }
-
- return 1;
-}
-
-extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
-{
- /*
- * It is possible for both access points and our device to support
- * combinations of modes, so as long as there is one valid combination
- * of ap/device supported modes, then return success
- *
- */
- if ((mode & IEEE_A) &&
- (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
- (ieee->freq_band & IEEE80211_52GHZ_BAND))
- return 1;
-
- if ((mode & IEEE_G) &&
- (ieee->modulation & IEEE80211_OFDM_MODULATION) &&
- (ieee->freq_band & IEEE80211_24GHZ_BAND))
- return 1;
-
- if ((mode & IEEE_B) &&
- (ieee->modulation & IEEE80211_CCK_MODULATION) &&
- (ieee->freq_band & IEEE80211_24GHZ_BAND))
- return 1;
-
- return 0;
-}
-
-extern inline int ieee80211_get_hdrlen(u16 fc)
-{
- int hdrlen = IEEE80211_3ADDR_LEN;
-
- switch (WLAN_FC_GET_TYPE(fc)) {
- case IEEE80211_FTYPE_DATA:
- if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
- hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */
- if(IEEE80211_QOS_HAS_SEQ(fc))
- hdrlen += 2; /* QOS ctrl*/
- break;
- case IEEE80211_FTYPE_CTL:
- switch (WLAN_FC_GET_STYPE(fc)) {
- case IEEE80211_STYPE_CTS:
- case IEEE80211_STYPE_ACK:
- hdrlen = IEEE80211_1ADDR_LEN;
- break;
- default:
- hdrlen = IEEE80211_2ADDR_LEN;
- break;
- }
- break;
- }
-
- return hdrlen;
-}
-
-static inline u8 *ieee80211_get_payload(struct rtl_ieee80211_hdr *hdr)
-{
- switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
- case IEEE80211_1ADDR_LEN:
- return ((struct ieee80211_hdr_1addr *)hdr)->payload;
- case IEEE80211_2ADDR_LEN:
- return ((struct ieee80211_hdr_2addr *)hdr)->payload;
- case IEEE80211_3ADDR_LEN:
- return (void *)hdr+sizeof(struct ieee80211_hdr_3addr);
- case IEEE80211_4ADDR_LEN:
- return ((struct ieee80211_hdr_4addr *)hdr)->payload;
- }
- return NULL;
-}
-
-static inline int ieee80211_is_ofdm_rate(u8 rate)
-{
- switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
- case IEEE80211_OFDM_RATE_6MB:
- case IEEE80211_OFDM_RATE_9MB:
- case IEEE80211_OFDM_RATE_12MB:
- case IEEE80211_OFDM_RATE_18MB:
- case IEEE80211_OFDM_RATE_24MB:
- case IEEE80211_OFDM_RATE_36MB:
- case IEEE80211_OFDM_RATE_48MB:
- case IEEE80211_OFDM_RATE_54MB:
- return 1;
- }
- return 0;
-}
-
-static inline int ieee80211_is_cck_rate(u8 rate)
-{
- switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
- case IEEE80211_CCK_RATE_1MB:
- case IEEE80211_CCK_RATE_2MB:
- case IEEE80211_CCK_RATE_5MB:
- case IEEE80211_CCK_RATE_11MB:
- return 1;
- }
- return 0;
-}
-
-
-/* ieee80211.c */
-extern void free_ieee80211(struct net_device *dev);
-extern struct net_device *alloc_ieee80211(int sizeof_priv);
-
-extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
-
-/* ieee80211_tx.c */
-
-extern int ieee80211_encrypt_fragment(
- struct ieee80211_device *ieee,
- struct sk_buff *frag,
- int hdr_len);
-
-extern int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb,
- struct net_device *dev);
-extern void ieee80211_txb_free(struct ieee80211_txb *);
-
-
-/* ieee80211_rx.c */
-extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats);
-extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header,
- struct ieee80211_rx_stats *stats);
-
-/* ieee80211_wx.c */
-extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *key);
-extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *key);
-extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *key);
-extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data* wrqu, char *extra);
-extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- struct iw_param *data, char *extra);
-extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len);
-
-/* ieee80211_softmac.c */
-extern short ieee80211_is_54g(struct ieee80211_network net);
-extern short ieee80211_is_shortslot(struct ieee80211_network net);
-extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats, u16 type,
- u16 stype);
-extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
-
-void SendDisassociation(struct ieee80211_device *ieee, u8* asSta, u8 asRsn);
-extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
-
-extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
-extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
-extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
-extern void ieee80211_start_bss(struct ieee80211_device *ieee);
-extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
-extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
-extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
-extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
-extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
-extern void ieee80211_disassociate(struct ieee80211_device *ieee);
-extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
-extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
-extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
-extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
-extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
-extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
-extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
-extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
-extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
-extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
-extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
-extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
-extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
-extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
-extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
-extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
-
-extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee);
-
-/* ieee80211_crypt_ccmp&tkip&wep.c */
-extern void ieee80211_tkip_null(void);
-extern void ieee80211_wep_null(void);
-extern void ieee80211_ccmp_null(void);
-
-/* ieee80211_softmac_wx.c */
-
-extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *ext);
-
-extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *awrq,
- char *extra);
-
-extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
-
-extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b);
-
-extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b);
-
-extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b);
-
-extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b);
-
-extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b);
-
-extern void ieee80211_wx_sync_scan_wq(struct work_struct *work);
-
-extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra);
-
-extern void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee);
-
-extern const long ieee80211_wlan_frequencies[];
-
-extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
-{
- ieee->scans++;
-}
-
-extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
-{
- return ieee->scans;
-}
-
-static inline const char *escape_essid(const char *essid, u8 essid_len) {
- static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
- const char *s = essid;
- char *d = escaped;
-
- if (ieee80211_is_empty_essid(essid, essid_len)) {
- memcpy(escaped, "<hidden>", sizeof("<hidden>"));
- return escaped;
- }
-
- essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
- while (essid_len--) {
- if (*s == '\0') {
- *d++ = '\\';
- *d++ = '0';
- s++;
- } else {
- *d++ = *s++;
- }
- }
- *d = '\0';
- return escaped;
-}
-
-/* For the function is more related to hardware setting, it's better to use the
- * ieee handler to refer to it.
- */
-extern short check_nic_enough_desc(struct net_device *dev, int queue_index);
-extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev);
-extern int ieee80211_parse_info_param(struct ieee80211_device *ieee,
- struct ieee80211_info_element *info_element,
- u16 length,
- struct ieee80211_network *network,
- struct ieee80211_rx_stats *stats);
-
-extern void ieee80211_indicate_packets(struct ieee80211_device *ieee,
- struct ieee80211_rxb **prxbIndicateArray,
- u8 index);
-#define RT_ASOC_RETRY_LIMIT 5
-#endif /* IEEE80211_H */
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
deleted file mode 100644
index 24e7d595e3ce..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Host AP crypto routines
- *
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- * Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- *
- */
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <asm/string.h>
-#include <asm/errno.h>
-
-#include "ieee80211.h"
-
-MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("HostAP crypto");
-MODULE_LICENSE("GPL");
-
-struct ieee80211_crypto_alg {
- struct list_head list;
- struct ieee80211_crypto_ops *ops;
-};
-
-
-struct ieee80211_crypto {
- struct list_head algs;
- spinlock_t lock;
-};
-
-static struct ieee80211_crypto *hcrypt;
-
-void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
- int force)
-{
- struct list_head *ptr, *n;
- struct ieee80211_crypt_data *entry;
-
- for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
- ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
- entry = list_entry(ptr, struct ieee80211_crypt_data, list);
-
- if (atomic_read(&entry->refcnt) != 0 && !force)
- continue;
-
- list_del(ptr);
-
- if (entry->ops)
- entry->ops->deinit(entry->priv);
- kfree(entry);
- }
-}
-
-void ieee80211_crypt_deinit_handler(unsigned long data)
-{
- struct ieee80211_device *ieee = (struct ieee80211_device *)data;
- unsigned long flags;
-
- spin_lock_irqsave(&ieee->lock, flags);
- ieee80211_crypt_deinit_entries(ieee, 0);
- if (!list_empty(&ieee->crypt_deinit_list)) {
- printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
- "deletion list\n", ieee->dev->name);
- ieee->crypt_deinit_timer.expires = jiffies + HZ;
- add_timer(&ieee->crypt_deinit_timer);
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-
-}
-
-void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
- struct ieee80211_crypt_data **crypt)
-{
- struct ieee80211_crypt_data *tmp;
- unsigned long flags;
-
- if (*crypt == NULL)
- return;
-
- tmp = *crypt;
- *crypt = NULL;
-
- /* must not run ops->deinit() while there may be pending encrypt or
- * decrypt operations. Use a list of delayed deinits to avoid needing
- * locking. */
-
- spin_lock_irqsave(&ieee->lock, flags);
- list_add(&tmp->list, &ieee->crypt_deinit_list);
- if (!timer_pending(&ieee->crypt_deinit_timer)) {
- ieee->crypt_deinit_timer.expires = jiffies + HZ;
- add_timer(&ieee->crypt_deinit_timer);
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-}
-
-int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
-{
- unsigned long flags;
- struct ieee80211_crypto_alg *alg;
-
- if (hcrypt == NULL)
- return -1;
-
- alg = kzalloc(sizeof(*alg), GFP_KERNEL);
- if (alg == NULL)
- return -ENOMEM;
-
- alg->ops = ops;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- list_add(&alg->list, &hcrypt->algs);
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n",
- ops->name);
-
- return 0;
-}
-
-int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
-{
- unsigned long flags;
- struct list_head *ptr;
- struct ieee80211_crypto_alg *del_alg = NULL;
-
- if (hcrypt == NULL)
- return -1;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
- struct ieee80211_crypto_alg *alg =
- (struct ieee80211_crypto_alg *) ptr;
- if (alg->ops == ops) {
- list_del(&alg->list);
- del_alg = alg;
- break;
- }
- }
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- if (del_alg) {
- printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
- "'%s'\n", ops->name);
- kfree(del_alg);
- }
-
- return del_alg ? 0 : -1;
-}
-
-
-struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
-{
- unsigned long flags;
- struct list_head *ptr;
- struct ieee80211_crypto_alg *found_alg = NULL;
-
- if (hcrypt == NULL)
- return NULL;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
- struct ieee80211_crypto_alg *alg =
- (struct ieee80211_crypto_alg *) ptr;
- if (strcmp(alg->ops->name, name) == 0) {
- found_alg = alg;
- break;
- }
- }
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- if (found_alg)
- return found_alg->ops;
- else
- return NULL;
-}
-
-
-static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
-static void ieee80211_crypt_null_deinit(void *priv) {}
-
-static struct ieee80211_crypto_ops ieee80211_crypt_null = {
- .name = "NULL",
- .init = ieee80211_crypt_null_init,
- .deinit = ieee80211_crypt_null_deinit,
- .encrypt_mpdu = NULL,
- .decrypt_mpdu = NULL,
- .encrypt_msdu = NULL,
- .decrypt_msdu = NULL,
- .set_key = NULL,
- .get_key = NULL,
- .extra_prefix_len = 0,
- .extra_postfix_len = 0,
- .owner = THIS_MODULE,
-};
-
-int ieee80211_crypto_init(void)
-{
- int ret = -ENOMEM;
-
- hcrypt = kzalloc(sizeof(*hcrypt), GFP_KERNEL);
- if (!hcrypt)
- goto out;
-
- INIT_LIST_HEAD(&hcrypt->algs);
- spin_lock_init(&hcrypt->lock);
-
- ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
- if (ret < 0) {
- kfree(hcrypt);
- hcrypt = NULL;
- }
-out:
- return ret;
-}
-
-void ieee80211_crypto_deinit(void)
-{
- struct list_head *ptr, *n;
- struct ieee80211_crypto_alg *alg = NULL;
-
- if (hcrypt == NULL)
- return;
-
- list_for_each_safe(ptr, n, &hcrypt->algs) {
- alg = list_entry(ptr, struct ieee80211_crypto_alg, list);
- if (alg) {
- list_del(ptr);
- printk(KERN_DEBUG
- "ieee80211_crypt: unregistered algorithm '%s' (deinit)\n",
- alg->ops->name);
- kfree(alg);
- }
- }
- kfree(hcrypt);
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
deleted file mode 100644
index 42e52aedd292..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Original code based on Host AP (software wireless LAN access point) driver
- * for Intersil Prism2/2.5/3.
- *
- * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- * <jkmaline@cc.hut.fi>
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * Adaption to a generic IEEE 802.11 stack by James Ketrenos
- * <jketreno@linux.intel.com>
- *
- * Copyright (c) 2004, Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- */
-
-/*
- * This file defines the interface to the ieee80211 crypto module.
- */
-#ifndef IEEE80211_CRYPT_H
-#define IEEE80211_CRYPT_H
-
-#include <linux/skbuff.h>
-
-struct ieee80211_crypto_ops {
- const char *name;
-
- /* init new crypto context (e.g., allocate private data space,
- * select IV, etc.); returns NULL on failure or pointer to allocated
- * private data on success */
- void * (*init)(int keyidx);
-
- /* deinitialize crypto context and free allocated private data */
- void (*deinit)(void *priv);
-
- /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
- * value from decrypt_mpdu is passed as the keyidx value for
- * decrypt_msdu. skb must have enough head and tail room for the
- * encryption; if not, error will be returned; these functions are
- * called for all MPDUs (i.e., fragments).
- */
- int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
- int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
-
- /* These functions are called for full MSDUs, i.e. full frames.
- * These can be NULL if full MSDU operations are not needed. */
- int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
- int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
- void *priv, struct ieee80211_device* ieee);
-
- int (*set_key)(void *key, int len, u8 *seq, void *priv);
- int (*get_key)(void *key, int len, u8 *seq, void *priv);
-
- /* procfs handler for printing out key information and possible
- * statistics */
- char * (*print_stats)(char *p, void *priv);
-
- /* maximum number of bytes added by encryption; encrypt buf is
- * allocated with extra_prefix_len bytes, copy of in_buf, and
- * extra_postfix_len; encrypt need not use all this space, but
- * the result must start at the beginning of the buffer and correct
- * length must be returned */
- int extra_prefix_len, extra_postfix_len;
-
- struct module *owner;
-};
-
-struct ieee80211_crypt_data {
- struct list_head list; /* delayed deletion list */
- struct ieee80211_crypto_ops *ops;
- void *priv;
- atomic_t refcnt;
-};
-
-int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
-int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
-struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
-void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
-void ieee80211_crypt_deinit_handler(unsigned long);
-void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
- struct ieee80211_crypt_data **crypt);
-
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
deleted file mode 100644
index caee44ba3bc3..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_ccmp.c
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Host AP crypt: host-based CCMP encryption implementation for Host AP driver
- *
- * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- */
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/skbuff.h>
-#include <linux/netdevice.h>
-#include <linux/if_ether.h>
-#include <linux/if_arp.h>
-#include <asm/string.h>
-#include <linux/wireless.h>
-
-#include "ieee80211.h"
-
-#include <linux/crypto.h>
-#include <linux/scatterlist.h>
-
-MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: CCMP");
-MODULE_LICENSE("GPL");
-
-#define AES_BLOCK_LEN 16
-#define CCMP_HDR_LEN 8
-#define CCMP_MIC_LEN 8
-#define CCMP_TK_LEN 16
-#define CCMP_PN_LEN 6
-
-struct ieee80211_ccmp_data {
- u8 key[CCMP_TK_LEN];
- int key_set;
-
- u8 tx_pn[CCMP_PN_LEN];
- u8 rx_pn[CCMP_PN_LEN];
-
- u32 dot11RSNAStatsCCMPFormatErrors;
- u32 dot11RSNAStatsCCMPReplays;
- u32 dot11RSNAStatsCCMPDecryptErrors;
-
- int key_idx;
-
- struct crypto_tfm *tfm;
-
- /* scratch buffers for virt_to_page() (crypto API) */
- u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
- tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
- u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
-};
-
-void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
- const u8 pt[16], u8 ct[16])
-{
- crypto_cipher_encrypt_one((void*)tfm, ct, pt);
-}
-
-static void * ieee80211_ccmp_init(int key_idx)
-{
- struct ieee80211_ccmp_data *priv;
-
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
- if (priv == NULL)
- goto fail;
- priv->key_idx = key_idx;
-
- priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->tfm)) {
- printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
- "crypto API aes\n");
- priv->tfm = NULL;
- goto fail;
- }
-
- return priv;
-
-fail:
- if (priv) {
- if (priv->tfm)
- crypto_free_cipher((void*)priv->tfm);
- kfree(priv);
- }
-
- return NULL;
-}
-
-
-static void ieee80211_ccmp_deinit(void *priv)
-{
- struct ieee80211_ccmp_data *_priv = priv;
-
- if (_priv && _priv->tfm)
- crypto_free_cipher((void*)_priv->tfm);
- kfree(priv);
-}
-
-
-static inline void xor_block(u8 *b, u8 *a, size_t len)
-{
- int i;
- for (i = 0; i < len; i++)
- b[i] ^= a[i];
-}
-
-
-
-static void ccmp_init_blocks(struct crypto_tfm *tfm,
- struct ieee80211_hdr_4addr *hdr,
- u8 *pn, size_t dlen, u8 *b0, u8 *auth,
- u8 *s0)
-{
- u8 *pos, qc = 0;
- size_t aad_len;
- u16 fc;
- int a4_included, qc_included;
- u8 aad[2 * AES_BLOCK_LEN];
-
- fc = le16_to_cpu(hdr->frame_ctl);
- a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
- (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS));
- /*
- qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
- (WLAN_FC_GET_STYPE(fc) & 0x08));
- */
- qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
- (WLAN_FC_GET_STYPE(fc) & 0x80));
- aad_len = 22;
- if (a4_included)
- aad_len += 6;
- if (qc_included) {
- pos = (u8 *) &hdr->addr4;
- if (a4_included)
- pos += 6;
- qc = *pos & 0x0f;
- aad_len += 2;
- }
- /* CCM Initial Block:
- * Flag (Include authentication header, M=3 (8-octet MIC),
- * L=1 (2-octet Dlen))
- * Nonce: 0x00 | A2 | PN
- * Dlen */
- b0[0] = 0x59;
- b0[1] = qc;
- memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
- memcpy(b0 + 8, pn, CCMP_PN_LEN);
- b0[14] = (dlen >> 8) & 0xff;
- b0[15] = dlen & 0xff;
-
- /* AAD:
- * FC with bits 4..6 and 11..13 masked to zero; 14 is always one
- * A1 | A2 | A3
- * SC with bits 4..15 (seq#) masked to zero
- * A4 (if present)
- * QC (if present)
- */
- pos = (u8 *) hdr;
- aad[0] = 0; /* aad_len >> 8 */
- aad[1] = aad_len & 0xff;
- aad[2] = pos[0] & 0x8f;
- aad[3] = pos[1] & 0xc7;
- memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
- pos = (u8 *) &hdr->seq_ctl;
- aad[22] = pos[0] & 0x0f;
- aad[23] = 0; /* all bits masked */
- memset(aad + 24, 0, 8);
- if (a4_included)
- memcpy(aad + 24, hdr->addr4, ETH_ALEN);
- if (qc_included) {
- aad[a4_included ? 30 : 24] = qc;
- /* rest of QC masked */
- }
-
- /* Start with the first block and AAD */
- ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
- xor_block(auth, aad, AES_BLOCK_LEN);
- ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
- xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
- ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
- b0[0] &= 0x07;
- b0[14] = b0[15] = 0;
- ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
-}
-
-
-
-static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct ieee80211_ccmp_data *key = priv;
- int data_len, i;
- u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
-
- if (skb_headroom(skb) < CCMP_HDR_LEN ||
- skb_tailroom(skb) < CCMP_MIC_LEN ||
- skb->len < hdr_len)
- return -1;
-
- data_len = skb->len - hdr_len;
- pos = skb_push(skb, CCMP_HDR_LEN);
- memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
- pos += hdr_len;
-
- i = CCMP_PN_LEN - 1;
- while (i >= 0) {
- key->tx_pn[i]++;
- if (key->tx_pn[i] != 0)
- break;
- i--;
- }
-
- *pos++ = key->tx_pn[5];
- *pos++ = key->tx_pn[4];
- *pos++ = 0;
- *pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
- *pos++ = key->tx_pn[3];
- *pos++ = key->tx_pn[2];
- *pos++ = key->tx_pn[1];
- *pos++ = key->tx_pn[0];
-
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- if (!tcb_desc->bHwSec)
- {
- int blocks, last, len;
- u8 *mic;
- u8 *b0 = key->tx_b0;
- u8 *b = key->tx_b;
- u8 *e = key->tx_e;
- u8 *s0 = key->tx_s0;
-
- mic = skb_put(skb, CCMP_MIC_LEN);
-
- ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
-
- blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
- last = data_len % AES_BLOCK_LEN;
-
- for (i = 1; i <= blocks; i++) {
- len = (i == blocks && last) ? last : AES_BLOCK_LEN;
- /* Authentication */
- xor_block(b, pos, len);
- ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
- /* Encryption, with counter */
- b0[14] = (i >> 8) & 0xff;
- b0[15] = i & 0xff;
- ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
- xor_block(pos, e, len);
- pos += len;
- }
-
- for (i = 0; i < CCMP_MIC_LEN; i++)
- mic[i] = b[i] ^ s0[i];
- }
- return 0;
-}
-
-
-static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct ieee80211_ccmp_data *key = priv;
- u8 keyidx, *pos;
- struct ieee80211_hdr_4addr *hdr;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- u8 pn[6];
-
- if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
- key->dot11RSNAStatsCCMPFormatErrors++;
- return -1;
- }
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- pos = skb->data + hdr_len;
- keyidx = pos[3];
- if (!(keyidx & (1 << 5))) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "CCMP: received packet without ExtIV"
- " flag from %pM\n", hdr->addr2);
- }
- key->dot11RSNAStatsCCMPFormatErrors++;
- return -2;
- }
- keyidx >>= 6;
- if (key->key_idx != keyidx) {
- printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame "
- "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
- return -6;
- }
- if (!key->key_set) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "CCMP: received packet from %pM"
- " with keyid=%d that does not have a configured"
- " key\n", hdr->addr2, keyidx);
- }
- return -3;
- }
-
- pn[0] = pos[7];
- pn[1] = pos[6];
- pn[2] = pos[5];
- pn[3] = pos[4];
- pn[4] = pos[1];
- pn[5] = pos[0];
- pos += 8;
-
- if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "CCMP: replay detected: STA=%pM"
- " previous PN %pm received PN %pm\n",
- hdr->addr2, key->rx_pn, pn);
- }
- key->dot11RSNAStatsCCMPReplays++;
- return -4;
- }
- if (!tcb_desc->bHwSec)
- {
- size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
- u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
- u8 *b0 = key->rx_b0;
- u8 *b = key->rx_b;
- u8 *a = key->rx_a;
- int i, blocks, last, len;
-
-
- ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
- xor_block(mic, b, CCMP_MIC_LEN);
-
- blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
- last = data_len % AES_BLOCK_LEN;
-
- for (i = 1; i <= blocks; i++) {
- len = (i == blocks && last) ? last : AES_BLOCK_LEN;
- /* Decrypt, with counter */
- b0[14] = (i >> 8) & 0xff;
- b0[15] = i & 0xff;
- ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
- xor_block(pos, b, len);
- /* Authentication */
- xor_block(a, pos, len);
- ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
- pos += len;
- }
-
- if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "CCMP: decrypt failed: STA="
- "%pM\n", hdr->addr2);
- }
- key->dot11RSNAStatsCCMPDecryptErrors++;
- return -5;
- }
-
- memcpy(key->rx_pn, pn, CCMP_PN_LEN);
- }
- /* Remove hdr and MIC */
- memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
- skb_pull(skb, CCMP_HDR_LEN);
- skb_trim(skb, skb->len - CCMP_MIC_LEN);
-
- return keyidx;
-}
-
-
-static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
-{
- struct ieee80211_ccmp_data *data = priv;
- int keyidx;
- struct crypto_tfm *tfm = data->tfm;
-
- keyidx = data->key_idx;
- memset(data, 0, sizeof(*data));
- data->key_idx = keyidx;
- data->tfm = tfm;
- if (len == CCMP_TK_LEN) {
- memcpy(data->key, key, CCMP_TK_LEN);
- data->key_set = 1;
- if (seq) {
- data->rx_pn[0] = seq[5];
- data->rx_pn[1] = seq[4];
- data->rx_pn[2] = seq[3];
- data->rx_pn[3] = seq[2];
- data->rx_pn[4] = seq[1];
- data->rx_pn[5] = seq[0];
- }
- crypto_cipher_setkey((void*)data->tfm, data->key, CCMP_TK_LEN);
- } else if (len == 0)
- data->key_set = 0;
- else
- return -1;
-
- return 0;
-}
-
-
-static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
-{
- struct ieee80211_ccmp_data *data = priv;
-
- if (len < CCMP_TK_LEN)
- return -1;
-
- if (!data->key_set)
- return 0;
- memcpy(key, data->key, CCMP_TK_LEN);
-
- if (seq) {
- seq[0] = data->tx_pn[5];
- seq[1] = data->tx_pn[4];
- seq[2] = data->tx_pn[3];
- seq[3] = data->tx_pn[2];
- seq[4] = data->tx_pn[1];
- seq[5] = data->tx_pn[0];
- }
-
- return CCMP_TK_LEN;
-}
-
-
-static char * ieee80211_ccmp_print_stats(char *p, void *priv)
-{
- struct ieee80211_ccmp_data *ccmp = priv;
- p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
- "tx_pn=%pm rx_pn=%pm "
- "format_errors=%d replays=%d decrypt_errors=%d\n",
- ccmp->key_idx, ccmp->key_set,
- ccmp->tx_pn, ccmp->rx_pn,
- ccmp->dot11RSNAStatsCCMPFormatErrors,
- ccmp->dot11RSNAStatsCCMPReplays,
- ccmp->dot11RSNAStatsCCMPDecryptErrors);
-
- return p;
-}
-
-void ieee80211_ccmp_null(void)
-{
- return;
-}
-
-static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
- .name = "CCMP",
- .init = ieee80211_ccmp_init,
- .deinit = ieee80211_ccmp_deinit,
- .encrypt_mpdu = ieee80211_ccmp_encrypt,
- .decrypt_mpdu = ieee80211_ccmp_decrypt,
- .encrypt_msdu = NULL,
- .decrypt_msdu = NULL,
- .set_key = ieee80211_ccmp_set_key,
- .get_key = ieee80211_ccmp_get_key,
- .print_stats = ieee80211_ccmp_print_stats,
- .extra_prefix_len = CCMP_HDR_LEN,
- .extra_postfix_len = CCMP_MIC_LEN,
- .owner = THIS_MODULE,
-};
-
-int __init ieee80211_crypto_ccmp_init(void)
-{
- return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
-}
-
-void ieee80211_crypto_ccmp_exit(void)
-{
- ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
deleted file mode 100644
index 5ab94a9665e5..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_tkip.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- * Host AP crypt: host-based TKIP encryption implementation for Host AP driver
- *
- * Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- */
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/skbuff.h>
-#include <linux/netdevice.h>
-#include <linux/if_ether.h>
-#include <linux/if_arp.h>
-#include <asm/string.h>
-
-#include "ieee80211.h"
-
-#include <linux/crypto.h>
-#include <linux/scatterlist.h>
-#include <linux/crc32.h>
-
-MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: TKIP");
-MODULE_LICENSE("GPL");
-
-struct ieee80211_tkip_data {
-#define TKIP_KEY_LEN 32
- u8 key[TKIP_KEY_LEN];
- int key_set;
-
- u32 tx_iv32;
- u16 tx_iv16;
- u16 tx_ttak[5];
- int tx_phase1_done;
-
- u32 rx_iv32;
- u16 rx_iv16;
- bool initialized;
- u16 rx_ttak[5];
- int rx_phase1_done;
- u32 rx_iv32_new;
- u16 rx_iv16_new;
-
- u32 dot11RSNAStatsTKIPReplays;
- u32 dot11RSNAStatsTKIPICVErrors;
- u32 dot11RSNAStatsTKIPLocalMICFailures;
-
- int key_idx;
-
- struct crypto_blkcipher *rx_tfm_arc4;
- struct crypto_hash *rx_tfm_michael;
- struct crypto_blkcipher *tx_tfm_arc4;
- struct crypto_hash *tx_tfm_michael;
-
- /* scratch buffers for virt_to_page() (crypto API) */
- u8 rx_hdr[16], tx_hdr[16];
-};
-
-static void * ieee80211_tkip_init(int key_idx)
-{
- struct ieee80211_tkip_data *priv;
-
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
- if (priv == NULL)
- goto fail;
- priv->key_idx = key_idx;
-
- priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
- CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->tx_tfm_arc4)) {
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
- "crypto API arc4\n");
- priv->tx_tfm_arc4 = NULL;
- goto fail;
- }
-
- priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
- CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->tx_tfm_michael)) {
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
- "crypto API michael_mic\n");
- priv->tx_tfm_michael = NULL;
- goto fail;
- }
-
- priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
- CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->rx_tfm_arc4)) {
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
- "crypto API arc4\n");
- priv->rx_tfm_arc4 = NULL;
- goto fail;
- }
-
- priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
- CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->rx_tfm_michael)) {
- printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
- "crypto API michael_mic\n");
- priv->rx_tfm_michael = NULL;
- goto fail;
- }
-
- return priv;
-
-fail:
- if (priv) {
- if (priv->tx_tfm_michael)
- crypto_free_hash(priv->tx_tfm_michael);
- if (priv->tx_tfm_arc4)
- crypto_free_blkcipher(priv->tx_tfm_arc4);
- if (priv->rx_tfm_michael)
- crypto_free_hash(priv->rx_tfm_michael);
- if (priv->rx_tfm_arc4)
- crypto_free_blkcipher(priv->rx_tfm_arc4);
- kfree(priv);
- }
-
- return NULL;
-}
-
-
-static void ieee80211_tkip_deinit(void *priv)
-{
- struct ieee80211_tkip_data *_priv = priv;
-
- if (_priv) {
- if (_priv->tx_tfm_michael)
- crypto_free_hash(_priv->tx_tfm_michael);
- if (_priv->tx_tfm_arc4)
- crypto_free_blkcipher(_priv->tx_tfm_arc4);
- if (_priv->rx_tfm_michael)
- crypto_free_hash(_priv->rx_tfm_michael);
- if (_priv->rx_tfm_arc4)
- crypto_free_blkcipher(_priv->rx_tfm_arc4);
- }
- kfree(priv);
-}
-
-
-static inline u16 RotR1(u16 val)
-{
- return (val >> 1) | (val << 15);
-}
-
-
-static inline u8 Lo8(u16 val)
-{
- return val & 0xff;
-}
-
-
-static inline u8 Hi8(u16 val)
-{
- return val >> 8;
-}
-
-
-static inline u16 Lo16(u32 val)
-{
- return val & 0xffff;
-}
-
-
-static inline u16 Hi16(u32 val)
-{
- return val >> 16;
-}
-
-
-static inline u16 Mk16(u8 hi, u8 lo)
-{
- return lo | (((u16) hi) << 8);
-}
-
-
-static inline u16 Mk16_le(u16 *v)
-{
- return le16_to_cpu(*v);
-}
-
-
-static const u16 Sbox[256] =
-{
- 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
- 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
- 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
- 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
- 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
- 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
- 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
- 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
- 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
- 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
- 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
- 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
- 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
- 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
- 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
- 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
- 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
- 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
- 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
- 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
- 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
- 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
- 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
- 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
- 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
- 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
- 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
- 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
- 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
- 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
- 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
- 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
-};
-
-
-static inline u16 _S_(u16 v)
-{
- u16 t = Sbox[Hi8(v)];
- return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
-}
-
-
-#define PHASE1_LOOP_COUNT 8
-
-
-static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
-{
- int i, j;
-
- /* Initialize the 80-bit TTAK from TSC (IV32) and TA[0..5] */
- TTAK[0] = Lo16(IV32);
- TTAK[1] = Hi16(IV32);
- TTAK[2] = Mk16(TA[1], TA[0]);
- TTAK[3] = Mk16(TA[3], TA[2]);
- TTAK[4] = Mk16(TA[5], TA[4]);
-
- for (i = 0; i < PHASE1_LOOP_COUNT; i++) {
- j = 2 * (i & 1);
- TTAK[0] += _S_(TTAK[4] ^ Mk16(TK[1 + j], TK[0 + j]));
- TTAK[1] += _S_(TTAK[0] ^ Mk16(TK[5 + j], TK[4 + j]));
- TTAK[2] += _S_(TTAK[1] ^ Mk16(TK[9 + j], TK[8 + j]));
- TTAK[3] += _S_(TTAK[2] ^ Mk16(TK[13 + j], TK[12 + j]));
- TTAK[4] += _S_(TTAK[3] ^ Mk16(TK[1 + j], TK[0 + j])) + i;
- }
-}
-
-
-static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
- u16 IV16)
-{
- /* Make temporary area overlap WEP seed so that the final copy can be
- * avoided on little endian hosts. */
- u16 *PPK = (u16 *) &WEPSeed[4];
-
- /* Step 1 - make copy of TTAK and bring in TSC */
- PPK[0] = TTAK[0];
- PPK[1] = TTAK[1];
- PPK[2] = TTAK[2];
- PPK[3] = TTAK[3];
- PPK[4] = TTAK[4];
- PPK[5] = TTAK[4] + IV16;
-
- /* Step 2 - 96-bit bijective mixing using S-box */
- PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
- PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
- PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
- PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
- PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
- PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
-
- PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
- PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
- PPK[2] += RotR1(PPK[1]);
- PPK[3] += RotR1(PPK[2]);
- PPK[4] += RotR1(PPK[3]);
- PPK[5] += RotR1(PPK[4]);
-
- /* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value
- * WEPSeed[0..2] is transmitted as WEP IV */
- WEPSeed[0] = Hi8(IV16);
- WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
- WEPSeed[2] = Lo8(IV16);
- WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
-
-#ifdef __BIG_ENDIAN
- {
- int i;
- for (i = 0; i < 6; i++)
- PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8);
- }
-#endif
-}
-
-
-static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct ieee80211_tkip_data *tkey = priv;
- int len;
- u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
- int ret = 0;
- u8 rc4key[16], *icv;
- u32 crc;
- struct scatterlist sg;
-
- if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
- skb->len < hdr_len)
- return -1;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
-
- if (!tcb_desc->bHwSec)
- {
- if (!tkey->tx_phase1_done) {
- tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
- tkey->tx_iv32);
- tkey->tx_phase1_done = 1;
- }
- tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
- }
- else
- tkey->tx_phase1_done = 1;
-
-
- len = skb->len - hdr_len;
- pos = skb_push(skb, 8);
- memmove(pos, pos + 8, hdr_len);
- pos += hdr_len;
-
- if (tcb_desc->bHwSec)
- {
- *pos++ = Hi8(tkey->tx_iv16);
- *pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F;
- *pos++ = Lo8(tkey->tx_iv16);
- }
- else
- {
- *pos++ = rc4key[0];
- *pos++ = rc4key[1];
- *pos++ = rc4key[2];
- }
-
- *pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
- *pos++ = tkey->tx_iv32 & 0xff;
- *pos++ = (tkey->tx_iv32 >> 8) & 0xff;
- *pos++ = (tkey->tx_iv32 >> 16) & 0xff;
- *pos++ = (tkey->tx_iv32 >> 24) & 0xff;
-
- if (!tcb_desc->bHwSec)
- {
- icv = skb_put(skb, 4);
- crc = ~crc32_le(~0, pos, len);
- icv[0] = crc;
- icv[1] = crc >> 8;
- icv[2] = crc >> 16;
- icv[3] = crc >> 24;
- crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
- sg_init_one(&sg, pos, len + 4);
- ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
- }
-
- tkey->tx_iv16++;
- if (tkey->tx_iv16 == 0) {
- tkey->tx_phase1_done = 0;
- tkey->tx_iv32++;
- }
-
- if (!tcb_desc->bHwSec)
- return ret;
- else
- return 0;
-
-
-}
-
-static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct ieee80211_tkip_data *tkey = priv;
- u8 keyidx, *pos;
- u32 iv32;
- u16 iv16;
- struct ieee80211_hdr_4addr *hdr;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
- u8 rc4key[16];
- u8 icv[4];
- u32 crc;
- struct scatterlist sg;
- int plen;
- if (skb->len < hdr_len + 8 + 4)
- return -1;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- pos = skb->data + hdr_len;
- keyidx = pos[3];
- if (!(keyidx & (1 << 5))) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "TKIP: received packet without ExtIV"
- " flag from %pM\n", hdr->addr2);
- }
- return -2;
- }
- keyidx >>= 6;
- if (tkey->key_idx != keyidx) {
- printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "
- "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);
- return -6;
- }
- if (!tkey->key_set) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "TKIP: received packet from %pM"
- " with keyid=%d that does not have a configured"
- " key\n", hdr->addr2, keyidx);
- }
- return -3;
- }
- iv16 = (pos[0] << 8) | pos[2];
- iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
- pos += 8;
-
- if (!tcb_desc->bHwSec)
- {
- if ((iv32 < tkey->rx_iv32 ||
- (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16))&&tkey->initialized) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "TKIP: replay detected: STA=%pM"
- " previous TSC %08x%04x received TSC "
- "%08x%04x\n", hdr->addr2,
- tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
- }
- tkey->dot11RSNAStatsTKIPReplays++;
- return -4;
- }
- tkey->initialized = true;
-
- if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
- tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
- tkey->rx_phase1_done = 1;
- }
- tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
-
- plen = skb->len - hdr_len - 12;
- sg_init_one(&sg, pos, plen+4);
- crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
- if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG ": TKIP: failed to decrypt "
- "received packet from %pM\n",
- hdr->addr2);
- }
- return -7;
- }
-
- crc = ~crc32_le(~0, pos, plen);
- icv[0] = crc;
- icv[1] = crc >> 8;
- icv[2] = crc >> 16;
- icv[3] = crc >> 24;
-
- if (memcmp(icv, pos + plen, 4) != 0) {
- if (iv32 != tkey->rx_iv32) {
- /* Previously cached Phase1 result was already lost, so
- * it needs to be recalculated for the next packet. */
- tkey->rx_phase1_done = 0;
- }
- if (net_ratelimit()) {
- printk(KERN_DEBUG "TKIP: ICV error detected: STA="
- "%pM\n", hdr->addr2);
- }
- tkey->dot11RSNAStatsTKIPICVErrors++;
- return -5;
- }
-
- }
-
- /* Update real counters only after Michael MIC verification has
- * completed */
- tkey->rx_iv32_new = iv32;
- tkey->rx_iv16_new = iv16;
-
- /* Remove IV and ICV */
- memmove(skb->data + 8, skb->data, hdr_len);
- skb_pull(skb, 8);
- skb_trim(skb, skb->len - 4);
-
- return keyidx;
-}
-
-static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
- u8 * data, size_t data_len, u8 * mic)
-{
- struct hash_desc desc;
- struct scatterlist sg[2];
-
- if (tfm_michael == NULL) {
- printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
- return -1;
- }
-
- sg_init_table(sg, 2);
- sg_set_buf(&sg[0], hdr, 16);
- sg_set_buf(&sg[1], data, data_len);
-
- if (crypto_hash_setkey(tfm_michael, key, 8))
- return -1;
-
- desc.tfm = tfm_michael;
- desc.flags = 0;
- return crypto_hash_digest(&desc, sg, data_len + 16, mic);
-}
-
-static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
-{
- struct ieee80211_hdr_4addr *hdr11;
-
- hdr11 = (struct ieee80211_hdr_4addr *) skb->data;
- switch (le16_to_cpu(hdr11->frame_ctl) &
- (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
- case IEEE80211_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
- break;
- case IEEE80211_FCTL_FROMDS:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
- break;
- case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
- break;
- case 0:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
- break;
- }
-
- hdr[12] = 0; /* priority */
-
- hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
-}
-
-
-static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct ieee80211_tkip_data *tkey = priv;
- u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
-
- if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
- printk(KERN_DEBUG "Invalid packet for Michael MIC add "
- "(tailroom=%d hdr_len=%d skb->len=%d)\n",
- skb_tailroom(skb), hdr_len, skb->len);
- return -1;
- }
-
- michael_mic_hdr(skb, tkey->tx_hdr);
-
- if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) {
- tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
- }
- pos = skb_put(skb, 8);
-
- if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
- skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
- return -1;
-
- return 0;
-}
-
-static void ieee80211_michael_mic_failure(struct net_device *dev,
- struct ieee80211_hdr_4addr *hdr,
- int keyidx)
-{
- union iwreq_data wrqu;
- struct iw_michaelmicfailure ev;
-
- /* TODO: needed parameters: count, keyid, key type, TSC */
- memset(&ev, 0, sizeof(ev));
- ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
- if (hdr->addr1[0] & 0x01)
- ev.flags |= IW_MICFAILURE_GROUP;
- else
- ev.flags |= IW_MICFAILURE_PAIRWISE;
- ev.src_addr.sa_family = ARPHRD_ETHER;
- memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
- memset(&wrqu, 0, sizeof(wrqu));
- wrqu.data.length = sizeof(ev);
- wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
-}
-
-static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
- int hdr_len, void *priv, struct ieee80211_device* ieee)
-{
- struct ieee80211_tkip_data *tkey = priv;
- u8 mic[8];
- struct ieee80211_hdr_4addr *hdr;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
-
- if (!tkey->key_set)
- return -1;
-
- michael_mic_hdr(skb, tkey->rx_hdr);
- if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) {
- tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07;
- }
-
- if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
- skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
- return -1;
- if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
- struct ieee80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- printk(KERN_DEBUG "%s: Michael MIC verification failed for "
- "MSDU from %pM keyidx=%d\n",
- skb->dev ? skb->dev->name : "N/A", hdr->addr2,
- keyidx);
- printk("%d, force_mic_error = %d\n", (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\
- ieee->force_mic_error);
- if (skb->dev) {
- printk("skb->dev != NULL\n");
- ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
- }
- tkey->dot11RSNAStatsTKIPLocalMICFailures++;
- ieee->force_mic_error = false;
- return -1;
- }
-
- /* Update TSC counters for RX now that the packet verification has
- * completed. */
- tkey->rx_iv32 = tkey->rx_iv32_new;
- tkey->rx_iv16 = tkey->rx_iv16_new;
-
- skb_trim(skb, skb->len - 8);
-
- return 0;
-}
-
-
-static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
-{
- struct ieee80211_tkip_data *tkey = priv;
- int keyidx;
- struct crypto_hash *tfm = tkey->tx_tfm_michael;
- struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
- struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
- struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
-
- keyidx = tkey->key_idx;
- memset(tkey, 0, sizeof(*tkey));
- tkey->key_idx = keyidx;
- tkey->tx_tfm_michael = tfm;
- tkey->tx_tfm_arc4 = tfm2;
- tkey->rx_tfm_michael = tfm3;
- tkey->rx_tfm_arc4 = tfm4;
-
- if (len == TKIP_KEY_LEN) {
- memcpy(tkey->key, key, TKIP_KEY_LEN);
- tkey->key_set = 1;
- tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
- if (seq) {
- tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) |
- (seq[3] << 8) | seq[2];
- tkey->rx_iv16 = (seq[1] << 8) | seq[0];
- }
- } else if (len == 0)
- tkey->key_set = 0;
- else
- return -1;
-
- return 0;
-}
-
-
-static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
-{
- struct ieee80211_tkip_data *tkey = priv;
-
- if (len < TKIP_KEY_LEN)
- return -1;
-
- if (!tkey->key_set)
- return 0;
- memcpy(key, tkey->key, TKIP_KEY_LEN);
-
- if (seq) {
- /* Return the sequence number of the last transmitted frame. */
- u16 iv16 = tkey->tx_iv16;
- u32 iv32 = tkey->tx_iv32;
- if (iv16 == 0)
- iv32--;
- iv16--;
- seq[0] = tkey->tx_iv16;
- seq[1] = tkey->tx_iv16 >> 8;
- seq[2] = tkey->tx_iv32;
- seq[3] = tkey->tx_iv32 >> 8;
- seq[4] = tkey->tx_iv32 >> 16;
- seq[5] = tkey->tx_iv32 >> 24;
- }
-
- return TKIP_KEY_LEN;
-}
-
-
-static char * ieee80211_tkip_print_stats(char *p, void *priv)
-{
- struct ieee80211_tkip_data *tkip = priv;
- p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
- "tx_pn=%02x%02x%02x%02x%02x%02x "
- "rx_pn=%02x%02x%02x%02x%02x%02x "
- "replays=%d icv_errors=%d local_mic_failures=%d\n",
- tkip->key_idx, tkip->key_set,
- (tkip->tx_iv32 >> 24) & 0xff,
- (tkip->tx_iv32 >> 16) & 0xff,
- (tkip->tx_iv32 >> 8) & 0xff,
- tkip->tx_iv32 & 0xff,
- (tkip->tx_iv16 >> 8) & 0xff,
- tkip->tx_iv16 & 0xff,
- (tkip->rx_iv32 >> 24) & 0xff,
- (tkip->rx_iv32 >> 16) & 0xff,
- (tkip->rx_iv32 >> 8) & 0xff,
- tkip->rx_iv32 & 0xff,
- (tkip->rx_iv16 >> 8) & 0xff,
- tkip->rx_iv16 & 0xff,
- tkip->dot11RSNAStatsTKIPReplays,
- tkip->dot11RSNAStatsTKIPICVErrors,
- tkip->dot11RSNAStatsTKIPLocalMICFailures);
- return p;
-}
-
-
-static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
- .name = "TKIP",
- .init = ieee80211_tkip_init,
- .deinit = ieee80211_tkip_deinit,
- .encrypt_mpdu = ieee80211_tkip_encrypt,
- .decrypt_mpdu = ieee80211_tkip_decrypt,
- .encrypt_msdu = ieee80211_michael_mic_add,
- .decrypt_msdu = ieee80211_michael_mic_verify,
- .set_key = ieee80211_tkip_set_key,
- .get_key = ieee80211_tkip_get_key,
- .print_stats = ieee80211_tkip_print_stats,
- .extra_prefix_len = 4 + 4, /* IV + ExtIV */
- .extra_postfix_len = 8 + 4, /* MIC + ICV */
- .owner = THIS_MODULE,
-};
-
-int ieee80211_crypto_tkip_init(void)
-{
- return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
-}
-
-void ieee80211_crypto_tkip_exit(void)
-{
- ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
-}
-
-void ieee80211_tkip_null(void)
-{
- return;
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
deleted file mode 100644
index 5219bfd4ea8e..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_crypt_wep.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Host AP crypt: host-based WEP encryption implementation for Host AP driver
- *
- * Copyright (c) 2002-2004, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- */
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/skbuff.h>
-#include <asm/string.h>
-
-#include "ieee80211.h"
-
-#include <linux/crypto.h>
-#include <linux/scatterlist.h>
-#include <linux/crc32.h>
-
-MODULE_AUTHOR("Jouni Malinen");
-MODULE_DESCRIPTION("Host AP crypt: WEP");
-MODULE_LICENSE("GPL");
-
-struct prism2_wep_data {
- u32 iv;
-#define WEP_KEY_LEN 13
- u8 key[WEP_KEY_LEN + 1];
- u8 key_len;
- u8 key_idx;
- struct crypto_blkcipher *tx_tfm;
- struct crypto_blkcipher *rx_tfm;
-};
-
-
-static void * prism2_wep_init(int keyidx)
-{
- struct prism2_wep_data *priv;
-
- priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
- if (priv == NULL)
- goto fail;
- priv->key_idx = keyidx;
-
- priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->tx_tfm)) {
- printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
- "crypto API arc4\n");
- priv->tx_tfm = NULL;
- goto fail;
- }
- priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
- if (IS_ERR(priv->rx_tfm)) {
- printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
- "crypto API arc4\n");
- priv->rx_tfm = NULL;
- goto fail;
- }
-
- /* start WEP IV from a random value */
- get_random_bytes(&priv->iv, 4);
-
- return priv;
-
-fail:
- if (priv) {
- if (priv->tx_tfm)
- crypto_free_blkcipher(priv->tx_tfm);
- if (priv->rx_tfm)
- crypto_free_blkcipher(priv->rx_tfm);
- kfree(priv);
- }
-
- return NULL;
-}
-
-
-static void prism2_wep_deinit(void *priv)
-{
- struct prism2_wep_data *_priv = priv;
-
- if (_priv) {
- if (_priv->tx_tfm)
- crypto_free_blkcipher(_priv->tx_tfm);
- if (_priv->rx_tfm)
- crypto_free_blkcipher(_priv->rx_tfm);
- }
- kfree(priv);
-}
-
-/* Perform WEP encryption on given skb that has at least 4 bytes of headroom
- * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted,
- * so the payload length increases with 8 bytes.
- *
- * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
- */
-static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct prism2_wep_data *wep = priv;
- u32 klen, len;
- u8 key[WEP_KEY_LEN + 3];
- u8 *pos;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
- u32 crc;
- u8 *icv;
- struct scatterlist sg;
- if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
- skb->len < hdr_len)
- return -1;
-
- len = skb->len - hdr_len;
- pos = skb_push(skb, 4);
- memmove(pos, pos + 4, hdr_len);
- pos += hdr_len;
-
- klen = 3 + wep->key_len;
-
- wep->iv++;
-
- /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
- * scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
- * can be used to speedup attacks, so avoid using them. */
- if ((wep->iv & 0xff00) == 0xff00) {
- u8 B = (wep->iv >> 16) & 0xff;
- if (B >= 3 && B < klen)
- wep->iv += 0x0100;
- }
-
- /* Prepend 24-bit IV to RC4 key and TX frame */
- *pos++ = key[0] = (wep->iv >> 16) & 0xff;
- *pos++ = key[1] = (wep->iv >> 8) & 0xff;
- *pos++ = key[2] = wep->iv & 0xff;
- *pos++ = wep->key_idx << 6;
-
- /* Copy rest of the WEP key (the secret part) */
- memcpy(key + 3, wep->key, wep->key_len);
-
- if (!tcb_desc->bHwSec)
- {
-
- /* Append little-endian CRC32 and encrypt it to produce ICV */
- crc = ~crc32_le(~0, pos, len);
- icv = skb_put(skb, 4);
- icv[0] = crc;
- icv[1] = crc >> 8;
- icv[2] = crc >> 16;
- icv[3] = crc >> 24;
-
- crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
- sg_init_one(&sg, pos, len+4);
-
- return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
- }
-
- return 0;
-}
-
-
-/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
- * the frame: IV (4 bytes), encrypted payload (including SNAP header),
- * ICV (4 bytes). len includes both IV and ICV.
- *
- * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
- * failure. If frame is OK, IV and ICV will be removed.
- */
-static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
-{
- struct prism2_wep_data *wep = priv;
- u32 klen, plen;
- u8 key[WEP_KEY_LEN + 3];
- u8 keyidx, *pos;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
- u32 crc;
- u8 icv[4];
- struct scatterlist sg;
- if (skb->len < hdr_len + 8)
- return -1;
-
- pos = skb->data + hdr_len;
- key[0] = *pos++;
- key[1] = *pos++;
- key[2] = *pos++;
- keyidx = *pos++ >> 6;
- if (keyidx != wep->key_idx)
- return -1;
-
- klen = 3 + wep->key_len;
-
- /* Copy rest of the WEP key (the secret part) */
- memcpy(key + 3, wep->key, wep->key_len);
-
- /* Apply RC4 to data and compute CRC32 over decrypted data */
- plen = skb->len - hdr_len - 8;
-
- if (!tcb_desc->bHwSec)
- {
- crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
- sg_init_one(&sg, pos, plen + 4);
-
- if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
- return -7;
-
- crc = ~crc32_le(~0, pos, plen);
- icv[0] = crc;
- icv[1] = crc >> 8;
- icv[2] = crc >> 16;
- icv[3] = crc >> 24;
- if (memcmp(icv, pos + plen, 4) != 0) {
- /* ICV mismatch - drop frame */
- return -2;
- }
- }
- /* Remove IV and ICV */
- memmove(skb->data + 4, skb->data, hdr_len);
- skb_pull(skb, 4);
- skb_trim(skb, skb->len - 4);
-
- return 0;
-}
-
-
-static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
-{
- struct prism2_wep_data *wep = priv;
-
- if (len < 0 || len > WEP_KEY_LEN)
- return -1;
-
- memcpy(wep->key, key, len);
- wep->key_len = len;
-
- return 0;
-}
-
-
-static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
-{
- struct prism2_wep_data *wep = priv;
-
- if (len < wep->key_len)
- return -1;
-
- memcpy(key, wep->key, wep->key_len);
-
- return wep->key_len;
-}
-
-
-static char * prism2_wep_print_stats(char *p, void *priv)
-{
- struct prism2_wep_data *wep = priv;
- p += sprintf(p, "key[%d] alg=WEP len=%d\n",
- wep->key_idx, wep->key_len);
- return p;
-}
-
-
-static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
- .name = "WEP",
- .init = prism2_wep_init,
- .deinit = prism2_wep_deinit,
- .encrypt_mpdu = prism2_wep_encrypt,
- .decrypt_mpdu = prism2_wep_decrypt,
- .encrypt_msdu = NULL,
- .decrypt_msdu = NULL,
- .set_key = prism2_wep_set_key,
- .get_key = prism2_wep_get_key,
- .print_stats = prism2_wep_print_stats,
- .extra_prefix_len = 4, /* IV */
- .extra_postfix_len = 4, /* ICV */
- .owner = THIS_MODULE,
-};
-
-int ieee80211_crypto_wep_init(void)
-{
- return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
-}
-
-void ieee80211_crypto_wep_exit(void)
-{
- ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
-}
-
-void ieee80211_wep_null(void)
-{
- return;
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
deleted file mode 100644
index 4945b3dbf72b..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_module.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
-
- Copyright(c) 2004 Intel Corporation. All rights reserved.
-
- Portions of this file are based on the WEP enablement code provided by the
- Host AP project hostap-drivers v0.1.3
- Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- <jkmaline@cc.hut.fi>
- Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59
- Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The full GNU General Public License is included in this distribution in the
- file called LICENSE.
-
- Contact Information:
- James P. Ketrenos <ipw2100-admin@linux.intel.com>
- Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-*******************************************************************************/
-
-#include <linux/compiler.h>
-#include <linux/errno.h>
-#include <linux/if_arp.h>
-#include <linux/in6.h>
-#include <linux/in.h>
-#include <linux/ip.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
-#include <linux/skbuff.h>
-#include <linux/slab.h>
-#include <linux/tcp.h>
-#include <linux/types.h>
-#include <linux/version.h>
-#include <linux/wireless.h>
-#include <linux/etherdevice.h>
-#include <asm/uaccess.h>
-#include <net/arp.h>
-
-#include "ieee80211.h"
-
-MODULE_DESCRIPTION("802.11 data/management/control stack");
-MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation <jketreno@linux.intel.com>");
-MODULE_LICENSE("GPL");
-
-#define DRV_NAME "ieee80211"
-
-static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
-{
- if (ieee->networks)
- return 0;
-
- ieee->networks = kcalloc(
- MAX_NETWORK_COUNT, sizeof(struct ieee80211_network),
- GFP_KERNEL);
- if (!ieee->networks) {
- printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
- ieee->dev->name);
- return -ENOMEM;
- }
-
- return 0;
-}
-
-static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
-{
- if (!ieee->networks)
- return;
- kfree(ieee->networks);
- ieee->networks = NULL;
-}
-
-static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
-{
- int i;
-
- INIT_LIST_HEAD(&ieee->network_free_list);
- INIT_LIST_HEAD(&ieee->network_list);
- for (i = 0; i < MAX_NETWORK_COUNT; i++)
- list_add_tail(&ieee->networks[i].list, &ieee->network_free_list);
-}
-
-
-struct net_device *alloc_ieee80211(int sizeof_priv)
-{
- struct ieee80211_device *ieee;
- struct net_device *dev;
- int i,err;
-
- IEEE80211_DEBUG_INFO("Initializing...\n");
-
- dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
- if (!dev) {
- IEEE80211_ERROR("Unable to network device.\n");
- goto failed;
- }
-
- ieee = netdev_priv(dev);
- memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
- ieee->dev = dev;
-
- err = ieee80211_networks_allocate(ieee);
- if (err) {
- IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
- err);
- goto failed;
- }
- ieee80211_networks_initialize(ieee);
-
-
- /* Default fragmentation threshold is maximum payload size */
- ieee->fts = DEFAULT_FTS;
- ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
- ieee->open_wep = 1;
-
- /* Default to enabling full open WEP with host based encrypt/decrypt */
- ieee->host_encrypt = 1;
- ieee->host_decrypt = 1;
- ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
-
- INIT_LIST_HEAD(&ieee->crypt_deinit_list);
- init_timer(&ieee->crypt_deinit_timer);
- ieee->crypt_deinit_timer.data = (unsigned long)ieee;
- ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
-
- spin_lock_init(&ieee->lock);
- spin_lock_init(&ieee->wpax_suitlist_lock);
- spin_lock_init(&ieee->bw_spinlock);
- spin_lock_init(&ieee->reorder_spinlock);
- atomic_set(&(ieee->atm_chnlop), 0);
- atomic_set(&(ieee->atm_swbw), 0);
-
- ieee->wpax_type_set = 0;
- ieee->wpa_enabled = 0;
- ieee->tkip_countermeasures = 0;
- ieee->drop_unencrypted = 0;
- ieee->privacy_invoked = 0;
- ieee->ieee802_1x = 1;
- ieee->raw_tx = 0;
- ieee->hwsec_active = 0; //disable hwsec, switch it on when necessary.
-
- ieee80211_softmac_init(ieee);
-
- ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL);
- if (ieee->pHTInfo == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n");
- return NULL;
- }
- HTUpdateDefaultSetting(ieee);
- HTInitializeHTInfo(ieee); //may move to other place.
- TSInitialize(ieee);
-
- for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
- INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
-
- for (i = 0; i < 17; i++) {
- ieee->last_rxseq_num[i] = -1;
- ieee->last_rxfrag_num[i] = -1;
- ieee->last_packet_time[i] = 0;
- }
-
-//These function were added to load crypte module autoly
- ieee80211_tkip_null();
- ieee80211_wep_null();
- ieee80211_ccmp_null();
-
- return dev;
-
- failed:
- if (dev)
- free_netdev(dev);
-
- return NULL;
-}
-
-
-void free_ieee80211(struct net_device *dev)
-{
- struct ieee80211_device *ieee = netdev_priv(dev);
- int i;
-#if 1
- if (ieee->pHTInfo != NULL)
- {
- kfree(ieee->pHTInfo);
- ieee->pHTInfo = NULL;
- }
-#endif
- RemoveAllTS(ieee);
- ieee80211_softmac_free(ieee);
- del_timer_sync(&ieee->crypt_deinit_timer);
- ieee80211_crypt_deinit_entries(ieee, 1);
-
- for (i = 0; i < WEP_KEYS; i++) {
- struct ieee80211_crypt_data *crypt = ieee->crypt[i];
- if (crypt) {
- if (crypt->ops)
- crypt->ops->deinit(crypt->priv);
- kfree(crypt);
- ieee->crypt[i] = NULL;
- }
- }
-
- ieee80211_networks_free(ieee);
- free_netdev(dev);
-}
-
-#ifdef CONFIG_IEEE80211_DEBUG
-
-u32 ieee80211_debug_level = 0;
-static int debug = \
- IEEE80211_DL_ERR //awayls open this flags to show error out
- ;
-struct proc_dir_entry *ieee80211_proc = NULL;
-
-static int show_debug_level(char *page, char **start, off_t offset,
- int count, int *eof, void *data)
-{
- return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
-}
-
-static int store_debug_level(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- char buf[] = "0x00000000";
- unsigned long len = min_t(unsigned long, sizeof(buf) - 1, count);
- char *p = (char *)buf;
- unsigned long val;
-
- if (copy_from_user(buf, buffer, len))
- return count;
- buf[len] = 0;
- if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
- p++;
- if (p[0] == 'x' || p[0] == 'X')
- p++;
- val = simple_strtoul(p, &p, 16);
- } else
- val = simple_strtoul(p, &p, 10);
- if (p == buf)
- printk(KERN_INFO DRV_NAME
- ": %s is not in hex or decimal form.\n", buf);
- else
- ieee80211_debug_level = val;
-
- return strnlen(buf, count);
-}
-
-int ieee80211_debug_init(void)
-{
- struct proc_dir_entry *e;
-
- ieee80211_debug_level = debug;
-
- ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, init_net.proc_net);
- if (ieee80211_proc == NULL) {
- IEEE80211_ERROR("Unable to create " DRV_NAME
- " proc directory\n");
- return -EIO;
- }
- e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
- ieee80211_proc);
- if (!e) {
- remove_proc_entry(DRV_NAME, init_net.proc_net);
- ieee80211_proc = NULL;
- return -EIO;
- }
- e->read_proc = show_debug_level;
- e->write_proc = store_debug_level;
- e->data = NULL;
-
- return 0;
-}
-
-void ieee80211_debug_exit(void)
-{
- if (ieee80211_proc) {
- remove_proc_entry("debug_level", ieee80211_proc);
- remove_proc_entry(DRV_NAME, init_net.proc_net);
- ieee80211_proc = NULL;
- }
-}
-
-#include <linux/moduleparam.h>
-module_param(debug, int, 0444);
-MODULE_PARM_DESC(debug, "debug output mask");
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_r8192s.h b/drivers/staging/rtl8192su/ieee80211/ieee80211_r8192s.h
deleted file mode 100644
index 7e7fbb269800..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_r8192s.h
+++ /dev/null
@@ -1,449 +0,0 @@
-#ifndef __IEEE80211_R8192S_H
-#define __IEEE80211_R8192S_H
-
-/* added for rtl819x tx procedure */
-#define MAX_QUEUE_SIZE 0x10
-
-/* 8190 queue mapping */
-enum {
- BK_QUEUE = 0,
- BE_QUEUE = 1,
- VI_QUEUE = 2,
- VO_QUEUE = 3,
- HCCA_QUEUE = 4,
- TXCMD_QUEUE = 5,
- MGNT_QUEUE = 6,
- HIGH_QUEUE = 7,
- BEACON_QUEUE = 8,
-
- LOW_QUEUE = BE_QUEUE,
- NORMAL_QUEUE = MGNT_QUEUE
-};
-
-#define SWRF_TIMEOUT 50
-
-/* LEAP related */
-/* Flag byte: byte 8, numbered from 0. */
-#define IE_CISCO_FLAG_POSITION 0x08
-#define SUPPORT_CKIP_MIC 0x08 /* bit3 */
-#define SUPPORT_CKIP_PK 0x10 /* bit4 */
-
-/* defined for skb cb field, at most 28 byte */
-typedef struct cb_desc {
- /* Tx Desc Related flags (8-9) */
- u8 bLastIniPkt:1;
- u8 bCmdOrInit:1;
- u8 bFirstSeg:1;
- u8 bLastSeg:1;
- u8 bEncrypt:1;
- u8 bTxDisableRateFallBack:1;
- u8 bTxUseDriverAssingedRate:1;
- u8 bHwSec:1; /* indicate whether use Hw security */
-
- u8 reserved1;
-
- /* Tx Firmware Relaged flags (10-11) */
- u8 bCTSEnable:1;
- u8 bRTSEnable:1;
- u8 bUseShortGI:1;
- u8 bUseShortPreamble:1;
- u8 bTxEnableFwCalcDur:1;
- u8 bAMPDUEnable:1;
- u8 bRTSSTBC:1;
- u8 RTSSC:1;
-
- u8 bRTSBW:1;
- u8 bPacketBW:1;
- u8 bRTSUseShortPreamble:1;
- u8 bRTSUseShortGI:1;
- u8 bMulticast:1;
- u8 bBroadcast:1;
- u8 drv_agg_enable:1;
- u8 reserved2:1;
-
- /* Tx Desc related element(12-19) */
- u8 rata_index;
- u8 queue_index;
- u16 txbuf_size;
- u8 RATRIndex;
- u8 reserved6;
- u8 reserved7;
- u8 reserved8;
-
- /* Tx firmware related element(20-27) */
- u8 data_rate;
- u8 rts_rate;
- u8 ampdu_factor;
- u8 ampdu_density;
- u8 DrvAggrNum;
- u16 pkt_size;
- u8 reserved12;
-} cb_desc, *pcb_desc;
-
-enum {
- MGN_1M = 0x02,
- MGN_2M = 0x04,
- MGN_5_5M = 0x0b,
- MGN_11M = 0x16,
-
- MGN_6M = 0x0c,
- MGN_9M = 0x12,
- MGN_12M = 0x18,
- MGN_18M = 0x24,
- MGN_24M = 0x30,
- MGN_36M = 0x48,
- MGN_48M = 0x60,
- MGN_54M = 0x6c,
-
- MGN_MCS0 = 0x80,
- MGN_MCS1 = 0x81,
- MGN_MCS2 = 0x82,
- MGN_MCS3 = 0x83,
- MGN_MCS4 = 0x84,
- MGN_MCS5 = 0x85,
- MGN_MCS6 = 0x86,
- MGN_MCS7 = 0x87,
- MGN_MCS8 = 0x88,
- MGN_MCS9 = 0x89,
- MGN_MCS10 = 0x8a,
- MGN_MCS11 = 0x8b,
- MGN_MCS12 = 0x8c,
- MGN_MCS13 = 0x8d,
- MGN_MCS14 = 0x8e,
- MGN_MCS15 = 0x8f,
-
- MGN_MCS0_SG = 0x90,
- MGN_MCS1_SG = 0x91,
- MGN_MCS2_SG = 0x92,
- MGN_MCS3_SG = 0x93,
- MGN_MCS4_SG = 0x94,
- MGN_MCS5_SG = 0x95,
- MGN_MCS6_SG = 0x96,
- MGN_MCS7_SG = 0x97,
- MGN_MCS8_SG = 0x98,
- MGN_MCS9_SG = 0x99,
- MGN_MCS10_SG = 0x9a,
- MGN_MCS11_SG = 0x9b,
- MGN_MCS12_SG = 0x9c,
- MGN_MCS13_SG = 0x9d,
- MGN_MCS14_SG = 0x9e,
- MGN_MCS15_SG = 0x9f,
-};
-
-#define FC_QOS_BIT BIT7
-
-#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
-#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT)))
-#define IsQoSDataFrame(pframe) \
- ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) \
- == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA))
-
-#define Frame_Order(pframe) (*(u16 *)pframe & IEEE80211_FCTL_ORDER)
-
-#define SN_LESS(a, b) (((a - b) & 0x800) != 0)
-#define SN_EQUAL(a, b) (a == b)
-
-#define MAX_DEV_ADDR_SIZE 8
-
-enum {
- /* ACT_CATEGORY */
- ACT_CAT_QOS = 1,
- ACT_CAT_DLS = 2,
- ACT_CAT_BA = 3,
- ACT_CAT_HT = 7,
- ACT_CAT_WMM = 17,
-
- /* TS_ACTION */
- ACT_ADDTSREQ = 0,
- ACT_ADDTSRSP = 1,
- ACT_DELTS = 2,
- ACT_SCHEDULE = 3,
-
- /* BA_ACTION */
- ACT_ADDBAREQ = 0,
- ACT_ADDBARSP = 1,
- ACT_DELBA = 2,
-};
-
-/* InitialGainOpType */
-enum {
- IG_Backup = 0,
- IG_Restore,
- IG_Max
-};
-
-typedef enum _LED_CTL_MODE{
- LED_CTL_POWER_ON = 1,
- LED_CTL_LINK = 2,
- LED_CTL_NO_LINK = 3,
- LED_CTL_TX = 4,
- LED_CTL_RX = 5,
- LED_CTL_SITE_SURVEY = 6,
- LED_CTL_POWER_OFF = 7,
- LED_CTL_START_TO_LINK = 8,
- LED_CTL_START_WPS = 9,
- LED_CTL_STOP_WPS = 10,
- LED_CTL_START_WPS_BOTTON = 11,
- LED_CTL_STOP_WPS_FAIL = 12,
- LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
-} LED_CTL_MODE;
-
-typedef union _frameqos {
- u16 shortdata;
- u8 chardata[2];
- struct {
- u16 tid:4;
- u16 eosp:1;
- u16 ack_policy:2;
- u16 reserved:1;
- u16 txop:8;
- } field;
-} frameqos;
-
-static inline u8 Frame_QoSTID(u8 *buf)
-{
- struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)buf;
- u16 fc = le16_to_cpu(hdr->frame_control);
-
- return (u8)((frameqos *)(buf +
- (((fc & IEEE80211_FCTL_TODS) &&
- (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
-}
-
-enum {
- ERP_NonERPpresent = 1,
- ERP_UseProtection = 2,
- ERP_BarkerPreambleMode = 4,
-};
-
-struct bandwidth_autoswitch {
- long threshold_20Mhzto40Mhz;
- long threshold_40Mhzto20Mhz;
- bool bforced_tx20Mhz;
- bool bautoswitch_enable;
-};
-
-#define REORDER_WIN_SIZE 128
-#define REORDER_ENTRY_NUM 128
-typedef struct _RX_REORDER_ENTRY {
- struct list_head List;
- u16 SeqNum;
- struct ieee80211_rxb *prxb;
-} RX_REORDER_ENTRY, *PRX_REORDER_ENTRY;
-
-typedef enum _Fsync_State{
- Default_Fsync,
- HW_Fsync,
- SW_Fsync
-} Fsync_State;
-
-/* Power save mode configured. */
-typedef enum _RT_PS_MODE {
- eActive, /* Active/Continuous access. */
- eMaxPs, /* Max power save mode. */
- eFastPs /* Fast power save mode. */
-} RT_PS_MODE;
-
-typedef enum _IPS_CALLBACK_FUNCION {
- IPS_CALLBACK_NONE = 0,
- IPS_CALLBACK_MGNT_LINK_REQUEST = 1,
- IPS_CALLBACK_JOIN_REQUEST = 2,
-} IPS_CALLBACK_FUNCION;
-
-typedef enum _RT_JOIN_ACTION {
- RT_JOIN_INFRA = 1,
- RT_JOIN_IBSS = 2,
- RT_START_IBSS = 3,
- RT_NO_ACTION = 4,
-} RT_JOIN_ACTION;
-
-struct ibss_parms {
- u16 atimWin;
-};
-
-/* Max num of support rates element: 8, Max num of ext. support rate: 255. */
-#define MAX_NUM_RATES 264
-
-typedef enum _RT_RF_POWER_STATE {
- eRfOn,
- eRfSleep,
- eRfOff
-} RT_RF_POWER_STATE;
-
-struct rt_power_save_control {
- /* Inactive Power Save (IPS): disable RF when disconnected */
- bool bInactivePs;
- bool bIPSModeBackup;
- bool bHaltAdapterClkRQ;
- bool bSwRfProcessing;
- RT_RF_POWER_STATE eInactivePowerState;
- struct work_struct InactivePsWorkItem;
- struct timer_list InactivePsTimer;
-
- /* return point for join action */
- IPS_CALLBACK_FUNCION ReturnPoint;
-
- /* Recored Parameters for rescheduled JoinRequest */
- bool bTmpBssDesc;
- RT_JOIN_ACTION tmpJoinAction;
- struct ieee80211_network tmpBssDesc;
-
- /* Recored Parameters for rescheduled MgntLinkRequest */
- bool bTmpScanOnly;
- bool bTmpActiveScan;
- bool bTmpFilterHiddenAP;
- bool bTmpUpdateParms;
- u8 tmpSsidBuf[33];
- OCTET_STRING tmpSsid2Scan;
- bool bTmpSsid2Scan;
- u8 tmpNetworkType;
- u8 tmpChannelNumber;
- u16 tmpBcnPeriod;
- u8 tmpDtimPeriod;
- u16 tmpmCap;
- OCTET_STRING tmpSuppRateSet;
- u8 tmpSuppRateBuf[MAX_NUM_RATES];
- bool bTmpSuppRate;
- struct ibss_parms tmpIbpm;
- bool bTmpIbpm;
-
- /* Leisre Poswer Save: disable RF if connected but traffic isn't busy */
- bool bLeisurePs;
- u32 PowerProfile;
- u8 LpsIdleCount;
- u8 RegMaxLPSAwakeIntvl;
- u8 LPSAwakeIntvl;
-
- /* RF OFF Level */
- u32 CurPsLevel;
- u32 RegRfPsLevel;
-
- /* Fw Control LPS */
- bool bFwCtrlLPS;
- u8 FWCtrlPSMode;
-
- /* Record if there is a link request in IPS RF off progress. */
- bool LinkReqInIPSRFOffPgs;
- /*
- * To make sure that connect info should be executed, so we set the
- * bit to filter the link info which comes after the connect info.
- */
- bool BufConnectinfoBefore;
-};
-
-enum {
- RF_CHANGE_BY_SW = BIT31,
- RF_CHANGE_BY_HW = BIT30,
- RF_CHANGE_BY_PS = BIT29,
- RF_CHANGE_BY_IPS = BIT28,
-};
-
-/* Firmware related CMD IO. */
-typedef enum _FW_CMD_IO_TYPE{
- FW_CMD_DIG_ENABLE = 0, /* for DIG DM */
- FW_CMD_DIG_DISABLE = 1,
- FW_CMD_DIG_HALT = 2,
- FW_CMD_DIG_RESUME = 3,
- FW_CMD_HIGH_PWR_ENABLE = 4, /* for DIG DM */
- FW_CMD_HIGH_PWR_DISABLE = 5,
- FW_CMD_RA_RESET = 6, /* for DIG DM */
- FW_CMD_RA_ACTIVE= 7,
- FW_CMD_RA_REFRESH_N= 8,
- FW_CMD_RA_REFRESH_BG= 9,
- FW_CMD_RA_INIT= 10, /* for FW supported IQK */
- FW_CMD_IQK_ENABLE = 11, /* Tx power tracking switch */
- FW_CMD_TXPWR_TRACK_ENABLE = 12, /* Tx power tracking switch */
- FW_CMD_TXPWR_TRACK_DISABLE = 13,
- FW_CMD_TXPWR_TRACK_THERMAL = 14,
- FW_CMD_PAUSE_DM_BY_SCAN = 15,
- /* indicate firmware that driver enters LPS, for PS-Poll hardware bug */
- FW_CMD_RESUME_DM_BY_SCAN = 16,
- /* indicate firmware that driver leave LPS */
- FW_CMD_RA_REFRESH_N_COMB = 17,
- FW_CMD_RA_REFRESH_BG_COMB = 18,
- FW_CMD_ANTENNA_SW_ENABLE = 19,
- FW_CMD_ANTENNA_SW_DISABLE = 20,
- FW_CMD_TX_FEEDBACK_CCX_ENABLE = 21,
- FW_CMD_LPS_ENTER = 22,
- FW_CMD_LPS_LEAVE = 23,
- FW_CMD_DIG_MODE_SS = 24,
- FW_CMD_DIG_MODE_FA = 25,
- FW_CMD_ADD_A2_ENTRY = 26,
- FW_CMD_CTRL_DM_BY_DRIVER = 27,
- FW_CMD_CTRL_DM_BY_DRIVER_NEW = 28,
-}FW_CMD_IO_TYPE,*PFW_CMD_IO_TYPE;
-
-#define RT_MAX_LD_SLOT_NUM 10
-struct rt_link_detect {
- u32 NumRecvBcnInPeriod;
- u32 NumRecvDataInPeriod;
-
- /* number of Rx beacon / CheckForHang_period to determine link status */
- u32 RxBcnNum[RT_MAX_LD_SLOT_NUM];
- /* number of Rx data / CheckForHang_period to determine link status */
- u32 RxDataNum[RT_MAX_LD_SLOT_NUM];
- /* number of CheckForHang period to determine link status */
- u16 SlotNum;
- u16 SlotIndex;
-
- u32 NumTxOkInPeriod;
- u32 NumRxOkInPeriod;
- bool bBusyTraffic;
-};
-
-/* HT */
-#define MAX_RECEIVE_BUFFER_SIZE 9100
-extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
-extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
-
-extern void HTSetConnectBwMode(struct ieee80211_device *ieee,
- HT_CHANNEL_WIDTH Bandwidth,
- HT_EXTCHNL_OFFSET Offset);
-extern void HTUpdateDefaultSetting(struct ieee80211_device *ieee);
-extern void HTConstructCapabilityElement(struct ieee80211_device *ieee,
- u8 *posHTCap, u8 *len, u8 isEncrypt);
-extern void HTConstructInfoElement(struct ieee80211_device *ieee,
- u8 *posHTInfo, u8 *len, u8 isEncrypt);
-extern void HTConstructRT2RTAggElement(struct ieee80211_device *ieee,
- u8 *posRT2RTAgg, u8 *len);
-extern void HTOnAssocRsp(struct ieee80211_device *ieee);
-extern void HTInitializeHTInfo(struct ieee80211_device *ieee);
-extern void HTInitializeBssDesc(PBSS_HT pBssHT);
-extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee,
- struct ieee80211_network *pNetwork);
-extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,
- struct ieee80211_network *pNetwork);
-extern u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet,
- u8 *pMCSFilter);
-extern u8 MCS_FILTER_ALL[];
-extern u16 MCS_DATA_RATE[2][2][77] ;
-extern u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame);
-extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo);
-extern bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee);
-extern u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate);
-extern u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate);
-extern u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate);
-extern int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee,
- struct sk_buff *skb);
-extern int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee,
- struct sk_buff *skb);
-extern int ieee80211_rx_DELBA(struct ieee80211_device *ieee,
- struct sk_buff *skb);
-extern void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS,
- u8 Policy, u8 bOverwritePending);
-extern void TsInitDelBA(struct ieee80211_device *ieee,
- PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect);
-extern void BaSetupTimeOut(unsigned long data);
-extern void TxBaInactTimeout(unsigned long data);
-extern void RxBaInactTimeout(unsigned long data);
-extern void ResetBaEntry(PBA_RECORD pBA);
-extern bool GetTs(struct ieee80211_device *ieee, PTS_COMMON_INFO *ppTS,
- u8 *Addr, u8 TID, TR_SELECT TxRxSelect, /* Rx:1, Tx:0 */
- bool bAddNewTs);
-extern void TSInitialize(struct ieee80211_device *ieee);
-extern void TsStartAddBaProcess(struct ieee80211_device *ieee,
- PTX_TS_RECORD pTxTS);
-extern void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr);
-extern void RemoveAllTS(struct ieee80211_device *ieee);
-
-#endif /* __IEEE80211_R8192S_H */
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
deleted file mode 100644
index 09a02f7e39ff..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
+++ /dev/null
@@ -1,2580 +0,0 @@
-/*
- * Original code based Host AP (software wireless LAN access point) driver
- * for Intersil Prism2/2.5/3 - hostap.o module, common routines
- *
- * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- * <jkmaline@cc.hut.fi>
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- * Copyright (c) 2004, Intel Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation. See README and COPYING for
- * more details.
- ******************************************************************************
-
- Few modifications for Realtek's Wi-Fi drivers by
- Andrea Merello <andreamrl@tiscali.it>
-
- A special thanks goes to Realtek for their support !
-
-******************************************************************************/
-
-
-#include <linux/compiler.h>
-//#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/if_arp.h>
-#include <linux/in6.h>
-#include <linux/in.h>
-#include <linux/ip.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
-#include <linux/skbuff.h>
-#include <linux/slab.h>
-#include <linux/tcp.h>
-#include <linux/types.h>
-#include <linux/wireless.h>
-#include <linux/etherdevice.h>
-#include <asm/uaccess.h>
-#include <linux/ctype.h>
-
-#include "ieee80211.h"
-#include "dot11d.h"
-static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
- struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats)
-{
- struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data;
- u16 fc = le16_to_cpu(hdr->frame_ctl);
-
- skb->dev = ieee->dev;
- skb_reset_mac_header(skb);
-
- skb_pull(skb, ieee80211_get_hdrlen(fc));
- skb->pkt_type = PACKET_OTHERHOST;
- skb->protocol = __constant_htons(ETH_P_80211_RAW);
- memset(skb->cb, 0, sizeof(skb->cb));
- netif_rx(skb);
-}
-
-
-/* Called only as a tasklet (software IRQ) */
-static struct ieee80211_frag_entry *
-ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
- unsigned int frag, u8 tid,u8 *src, u8 *dst)
-{
- struct ieee80211_frag_entry *entry;
- int i;
-
- for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
- entry = &ieee->frag_cache[tid][i];
- if (entry->skb != NULL &&
- time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
- IEEE80211_DEBUG_FRAG(
- "expiring fragment cache entry "
- "seq=%u last_frag=%u\n",
- entry->seq, entry->last_frag);
- dev_kfree_skb_any(entry->skb);
- entry->skb = NULL;
- }
-
- if (entry->skb != NULL && entry->seq == seq &&
- (entry->last_frag + 1 == frag || frag == -1) &&
- memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
- memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
- return entry;
- }
-
- return NULL;
-}
-
-/* Called only as a tasklet (software IRQ) */
-static struct sk_buff *
-ieee80211_frag_cache_get(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *hdr)
-{
- struct sk_buff *skb = NULL;
- u16 fc = le16_to_cpu(hdr->frame_ctl);
- u16 sc = le16_to_cpu(hdr->seq_ctl);
- unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
- unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
- struct ieee80211_frag_entry *entry;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
- u8 tid;
-
- if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
- tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
- tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else {
- tid = 0;
- }
-
- if (frag == 0) {
- /* Reserve enough space to fit maximum frame length */
- skb = dev_alloc_skb(ieee->dev->mtu +
- sizeof(struct ieee80211_hdr_4addr) +
- 8 /* LLC */ +
- 2 /* alignment */ +
- 8 /* WEP */ +
- ETH_ALEN /* WDS */ +
- (IEEE80211_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */);
- if (skb == NULL)
- return NULL;
-
- entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]];
- ieee->frag_next_idx[tid]++;
- if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
- ieee->frag_next_idx[tid] = 0;
-
- if (entry->skb != NULL)
- dev_kfree_skb_any(entry->skb);
-
- entry->first_frag_time = jiffies;
- entry->seq = seq;
- entry->last_frag = frag;
- entry->skb = skb;
- memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
- memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
- } else {
- /* received a fragment of a frame for which the head fragment
- * should have already been received */
- entry = ieee80211_frag_cache_find(ieee, seq, frag, tid,hdr->addr2,
- hdr->addr1);
- if (entry != NULL) {
- entry->last_frag = frag;
- skb = entry->skb;
- }
- }
-
- return skb;
-}
-
-
-/* Called only as a tasklet (software IRQ) */
-static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *hdr)
-{
- u16 fc = le16_to_cpu(hdr->frame_ctl);
- u16 sc = le16_to_cpu(hdr->seq_ctl);
- unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
- struct ieee80211_frag_entry *entry;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
- u8 tid;
-
- if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
- tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
- tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else {
- tid = 0;
- }
-
- entry = ieee80211_frag_cache_find(ieee, seq, -1, tid,hdr->addr2,
- hdr->addr1);
-
- if (entry == NULL) {
- IEEE80211_DEBUG_FRAG(
- "could not invalidate fragment cache "
- "entry (seq=%u)\n", seq);
- return -1;
- }
-
- entry->skb = NULL;
- return 0;
-}
-
-
-
-/* ieee80211_rx_frame_mgtmt
- *
- * Responsible for handling management control frames
- *
- * Called by ieee80211_rtl_rx */
-static inline int
-ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats, u16 type,
- u16 stype)
-{
- /* On the struct stats definition there is written that
- * this is not mandatory.... but seems that the probe
- * response parser uses it
- */
- struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data;
-
- rx_stats->len = skb->len;
- ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
- //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
- if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
- {
- dev_kfree_skb_any(skb);
- return 0;
- }
-
- ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
-
- dev_kfree_skb_any(skb);
-
- return 0;
-
-}
-
-
-
-/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
-/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
-static unsigned char rfc1042_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
-static unsigned char bridge_tunnel_header[] =
-{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-/* No encapsulation header if EtherType < 0x600 (=length) */
-
-/* Called by ieee80211_rx_frame_decrypt */
-static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
- struct sk_buff *skb, size_t hdrlen)
-{
- struct net_device *dev = ieee->dev;
- u16 fc, ethertype;
- struct ieee80211_hdr_4addr *hdr;
- u8 *pos;
-
- if (skb->len < 24)
- return 0;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- fc = le16_to_cpu(hdr->frame_ctl);
-
- /* check that the frame is unicast frame to us */
- if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
- IEEE80211_FCTL_TODS &&
- memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
- memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
- /* ToDS frame with own addr BSSID and DA */
- } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
- IEEE80211_FCTL_FROMDS &&
- memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
- /* FromDS frame with own addr as DA */
- } else
- return 0;
-
- if (skb->len < 24 + 8)
- return 0;
-
- /* check for port access entity Ethernet type */
-// pos = skb->data + 24;
- pos = skb->data + hdrlen;
- ethertype = (pos[6] << 8) | pos[7];
- if (ethertype == ETH_P_PAE)
- return 1;
-
- return 0;
-}
-
-/* Called only as a tasklet (software IRQ), by ieee80211_rtl_rx */
-static inline int
-ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
- struct ieee80211_crypt_data *crypt)
-{
- struct ieee80211_hdr_4addr *hdr;
- int res, hdrlen;
-
- if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
- return 0;
-#if 1
- if (ieee->hwsec_active)
- {
- cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
- tcb_desc->bHwSec = 1;
- }
-#endif
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
-
-#ifdef CONFIG_IEEE80211_CRYPT_TKIP
- if (ieee->tkip_countermeasures &&
- strcmp(crypt->ops->name, "TKIP") == 0) {
- if (net_ratelimit()) {
- printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
- "received packet from %pM\n",
- ieee->dev->name, hdr->addr2);
- }
- return -1;
- }
-#endif
-
- atomic_inc(&crypt->refcnt);
- res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
- atomic_dec(&crypt->refcnt);
- if (res < 0) {
- IEEE80211_DEBUG_DROP(
- "decryption failed (SA=%pM"
- ") res=%d\n", hdr->addr2, res);
- if (res == -2)
- IEEE80211_DEBUG_DROP("Decryption failed ICV "
- "mismatch (key %d)\n",
- skb->data[hdrlen + 3] >> 6);
- ieee->ieee_stats.rx_discards_undecryptable++;
- return -1;
- }
-
- return res;
-}
-
-
-/* Called only as a tasklet (software IRQ), by ieee80211_rx */
-static inline int
-ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
- int keyidx, struct ieee80211_crypt_data *crypt)
-{
- struct ieee80211_hdr_4addr *hdr;
- int res, hdrlen;
-
- if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
- return 0;
- if (ieee->hwsec_active)
- {
- cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
- tcb_desc->bHwSec = 1;
- }
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
-
- atomic_inc(&crypt->refcnt);
- res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv,ieee);
- atomic_dec(&crypt->refcnt);
- if (res < 0) {
- printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
- " (SA=%pM keyidx=%d)\n",
- ieee->dev->name, hdr->addr2, keyidx);
- return -1;
- }
-
- return 0;
-}
-
-
-/* this function is stolen from ipw2200 driver*/
-#define IEEE_PACKET_RETRY_TIME (5*HZ)
-static int is_duplicate_packet(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header)
-{
- u16 fc = le16_to_cpu(header->frame_ctl);
- u16 sc = le16_to_cpu(header->seq_ctl);
- u16 seq = WLAN_GET_SEQ_SEQ(sc);
- u16 frag = WLAN_GET_SEQ_FRAG(sc);
- u16 *last_seq, *last_frag;
- unsigned long *last_time;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
- u8 tid;
-
-
- //TO2DS and QoS
- if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header;
- tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos*)header;
- tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
- tid = UP2AC(tid);
- tid ++;
- } else { // no QoS
- tid = 0;
- }
-
- switch (ieee->iw_mode) {
- case IW_MODE_ADHOC:
- {
- struct list_head *p;
- struct ieee_ibss_seq *entry = NULL;
- u8 *mac = header->addr2;
- int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
- //for (pos = (head)->next; pos != (head); pos = pos->next)
- //__list_for_each(p, &ieee->ibss_mac_hash[index]) {
- list_for_each(p, &ieee->ibss_mac_hash[index]) {
- entry = list_entry(p, struct ieee_ibss_seq, list);
- if (!memcmp(entry->mac, mac, ETH_ALEN))
- break;
- }
- // if (memcmp(entry->mac, mac, ETH_ALEN)){
- if (p == &ieee->ibss_mac_hash[index]) {
- entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
- if (!entry) {
- printk(KERN_WARNING "Cannot malloc new mac entry\n");
- return 0;
- }
- memcpy(entry->mac, mac, ETH_ALEN);
- entry->seq_num[tid] = seq;
- entry->frag_num[tid] = frag;
- entry->packet_time[tid] = jiffies;
- list_add(&entry->list, &ieee->ibss_mac_hash[index]);
- return 0;
- }
- last_seq = &entry->seq_num[tid];
- last_frag = &entry->frag_num[tid];
- last_time = &entry->packet_time[tid];
- break;
- }
-
- case IW_MODE_INFRA:
- last_seq = &ieee->last_rxseq_num[tid];
- last_frag = &ieee->last_rxfrag_num[tid];
- last_time = &ieee->last_packet_time[tid];
-
- break;
- default:
- return 0;
- }
-
-// if(tid != 0) {
-// printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
-// }
- if ((*last_seq == seq) &&
- time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
- if (*last_frag == frag){
- //printk(KERN_WARNING "[1] go drop!\n");
- goto drop;
-
- }
- if (*last_frag + 1 != frag)
- /* out-of-order fragment */
- //printk(KERN_WARNING "[2] go drop!\n");
- goto drop;
- } else
- *last_seq = seq;
-
- *last_frag = frag;
- *last_time = jiffies;
- return 0;
-
-drop:
-// BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
-// printk("DUP\n");
-
- return 1;
-}
-bool
-AddReorderEntry(
- PRX_TS_RECORD pTS,
- PRX_REORDER_ENTRY pReorderEntry
- )
-{
- struct list_head *pList = &pTS->RxPendingPktList;
-#if 1
- while(pList->next != &pTS->RxPendingPktList)
- {
- if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
- {
- pList = pList->next;
- }
- else if( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
- {
- return false;
- }
- else
- {
- break;
- }
- }
-#endif
- pReorderEntry->List.next = pList->next;
- pReorderEntry->List.next->prev = &pReorderEntry->List;
- pReorderEntry->List.prev = pList;
- pList->next = &pReorderEntry->List;
-
- return true;
-}
-
-void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index)
-{
- u8 i = 0 , j=0;
- u16 ethertype;
-// if(index > 1)
-// IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index);
- for(j = 0; j<index; j++)
- {
-//added by amy for reorder
- struct ieee80211_rxb* prxb = prxbIndicateArray[j];
- for(i = 0; i<prxb->nr_subframes; i++) {
- struct sk_buff *sub_skb = prxb->subframes[i];
-
- /* convert hdr + possible LLC headers into Ethernet header */
- ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
- if (sub_skb->len >= 8 &&
- ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
- ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
- memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
- /* remove RFC1042 or Bridge-Tunnel encapsulation and
- * replace EtherType */
- skb_pull(sub_skb, SNAP_SIZE);
- memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
- } else {
- u16 len;
- /* Leave Ethernet header part of hdr and full payload */
- len = htons(sub_skb->len);
- memcpy(skb_push(sub_skb, 2), &len, 2);
- memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
- }
- //stats->rx_packets++;
- //stats->rx_bytes += sub_skb->len;
-
- /* Indicat the packets to upper layer */
- if (sub_skb) {
- //printk("0skb_len(%d)\n", skb->len);
- sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
- memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
- sub_skb->dev = ieee->dev;
- sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
- //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
- ieee->last_rx_ps_time = jiffies;
- //printk("1skb_len(%d)\n", skb->len);
- netif_rx(sub_skb);
- }
- }
- kfree(prxb);
- prxb = NULL;
- }
-}
-
-
-void RxReorderIndicatePacket( struct ieee80211_device *ieee,
- struct ieee80211_rxb* prxb,
- PRX_TS_RECORD pTS,
- u16 SeqNum)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- PRX_REORDER_ENTRY pReorderEntry = NULL;
- struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE];
- u8 WinSize = pHTInfo->RxReorderWinSize;
- u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096;
- u8 index = 0;
- bool bMatchWinStart = false, bPktInBuf = false;
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize);
- /* Rx Reorder initialize condition.*/
- if(pTS->RxIndicateSeq == 0xffff) {
- pTS->RxIndicateSeq = SeqNum;
- }
-
- /* Drop out the packet which SeqNum is smaller than WinStart */
- if(SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
- pHTInfo->RxReorderDropCounter++;
- {
- int i;
- for(i =0; i < prxb->nr_subframes; i++) {
- dev_kfree_skb(prxb->subframes[i]);
- }
- kfree(prxb);
- prxb = NULL;
- }
- return;
- }
-
- /*
- * Sliding window manipulation. Conditions includes:
- * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
- * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
- */
- if(SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
- pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
- bMatchWinStart = true;
- } else if(SN_LESS(WinEnd, SeqNum)) {
- if(SeqNum >= (WinSize - 1)) {
- pTS->RxIndicateSeq = SeqNum + 1 -WinSize;
- } else {
- pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1;
- }
- IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
- }
-
- /*
- * Indication process.
- * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
- * with the SeqNum smaller than latest WinStart and buffer other packets.
- */
- /* For Rx Reorder condition:
- * 1. All packets with SeqNum smaller than WinStart => Indicate
- * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
- */
- if(bMatchWinStart) {
- /* Current packet is going to be indicated.*/
- IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
- pTS->RxIndicateSeq, SeqNum);
- prxbIndicateArray[0] = prxb;
-// printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,SeqNum);
- index = 1;
- } else {
- /* Current packet is going to be inserted into pending list.*/
- //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
- if(!list_empty(&ieee->RxReorder_Unused_List)) {
- pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List);
- list_del_init(&pReorderEntry->List);
-
- /* Make a reorder entry and insert into a the packet list.*/
- pReorderEntry->SeqNum = SeqNum;
- pReorderEntry->prxb = prxb;
- // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
-
-#if 1
- if(!AddReorderEntry(pTS, pReorderEntry)) {
- IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
- __FUNCTION__, pTS->RxIndicateSeq, SeqNum);
- list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
- {
- int i;
- for(i =0; i < prxb->nr_subframes; i++) {
- dev_kfree_skb(prxb->subframes[i]);
- }
- kfree(prxb);
- prxb = NULL;
- }
- } else {
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,
- "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
- }
-#endif
- }
- else {
- /*
- * Packets are dropped if there is not enough reorder entries.
- * This part shall be modified!! We can just indicate all the
- * packets in buffer and get reorder entries.
- */
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
- {
- int i;
- for(i =0; i < prxb->nr_subframes; i++) {
- dev_kfree_skb(prxb->subframes[i]);
- }
- kfree(prxb);
- prxb = NULL;
- }
- }
- }
-
- /* Check if there is any packet need indicate.*/
- while(!list_empty(&pTS->RxPendingPktList)) {
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__FUNCTION__);
-#if 1
- pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
- if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
- SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
- {
- /* This protect buffer from overflow. */
- if(index >= REORDER_WIN_SIZE) {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n");
- bPktInBuf = true;
- break;
- }
-
- list_del_init(&pReorderEntry->List);
-
- if(SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
- pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
-
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
- prxbIndicateArray[index] = pReorderEntry->prxb;
- // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
- index++;
-
- list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
- } else {
- bPktInBuf = true;
- break;
- }
-#endif
- }
-
- /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
- if(index>0) {
- // Cancel previous pending timer.
- if(timer_pending(&pTS->RxPktPendingTimer))
- {
- del_timer_sync(&pTS->RxPktPendingTimer);
- }
- // del_timer_sync(&pTS->RxPktPendingTimer);
- pTS->RxTimeoutIndicateSeq = 0xffff;
-
- // Indicate packets
- if(index>REORDER_WIN_SIZE){
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
- return;
- }
- ieee80211_indicate_packets(ieee, prxbIndicateArray, index);
- bPktInBuf = false;
- }
-
-#if 1
- if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
- // Set new pending timer.
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__);
- pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
- mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime));
- }
-#endif
-}
-
-u8 parse_subframe(struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats,
- struct ieee80211_rxb *rxb,u8* src,u8* dst)
-{
- struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr* )skb->data;
- u16 fc = le16_to_cpu(hdr->frame_control);
-
- u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr);
- u16 ChkLength;
- bool bIsAggregateFrame = false;
- u16 nSubframe_Length;
- u8 nPadding_Length = 0;
- u16 SeqNum=0;
-
- struct sk_buff *sub_skb;
- u8 *data_ptr;
- /* just for debug purpose */
- SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctrl));
-
- if((IEEE80211_QOS_HAS_SEQ(fc))&&\
- (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) {
- bIsAggregateFrame = true;
- }
-
- if(IEEE80211_QOS_HAS_SEQ(fc)) {
- LLCOffset += 2;
- }
-
- if(rx_stats->bContainHTC) {
- LLCOffset += sHTCLng;
- }
- //printk("ChkLength = %d\n", LLCOffset);
- // Null packet, don't indicate it to upper layer
- ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
-
- if( skb->len <= ChkLength ) {
- return 0;
- }
-
- skb_pull(skb, LLCOffset);
-
- if(!bIsAggregateFrame) {
- rxb->nr_subframes = 1;
-#ifdef JOHN_NOCPY
- rxb->subframes[0] = skb;
-#else
- rxb->subframes[0] = skb_copy(skb, GFP_ATOMIC);
-#endif
-
- memcpy(rxb->src,src,ETH_ALEN);
- memcpy(rxb->dst,dst,ETH_ALEN);
- //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
- return 1;
- } else {
- rxb->nr_subframes = 0;
- memcpy(rxb->src,src,ETH_ALEN);
- memcpy(rxb->dst,dst,ETH_ALEN);
- while(skb->len > ETHERNET_HEADER_SIZE) {
- /* Offset 12 denote 2 mac address */
- nSubframe_Length = *((u16*)(skb->data + 12));
- //==m==>change the length order
- nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8);
-
- if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
- printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
- __FUNCTION__,rxb->nr_subframes);
- printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length);
- printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length);
- printk("The Packet SeqNum is %d\n",SeqNum);
- return 0;
- }
-
- /* move the data point to data content */
- skb_pull(skb, ETHERNET_HEADER_SIZE);
-
-#ifdef JOHN_NOCPY
- sub_skb = skb_clone(skb, GFP_ATOMIC);
- sub_skb->len = nSubframe_Length;
- sub_skb->tail = sub_skb->data + nSubframe_Length;
-#else
- /* Allocate new skb for releasing to upper layer */
- sub_skb = dev_alloc_skb(nSubframe_Length + 12);
- skb_reserve(sub_skb, 12);
- data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
- memcpy(data_ptr,skb->data,nSubframe_Length);
-#endif
- rxb->subframes[rxb->nr_subframes++] = sub_skb;
- if(rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
- IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
- break;
- }
- skb_pull(skb,nSubframe_Length);
-
- if(skb->len != 0) {
- nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4);
- if(nPadding_Length == 4) {
- nPadding_Length = 0;
- }
-
- if(skb->len < nPadding_Length) {
- return 0;
- }
-
- skb_pull(skb,nPadding_Length);
- }
- }
-#ifdef JOHN_NOCPY
- dev_kfree_skb(skb);
-#endif
- //{just for debug added by david
- //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
- //}
- return rxb->nr_subframes;
- }
-}
-
-/* All received frames are sent to this function. @skb contains the frame in
- * IEEE 802.11 format, i.e., in the format it was sent over air.
- * This function is called only as a tasklet (software IRQ). */
-int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats)
-{
- struct net_device *dev = ieee->dev;
- struct ieee80211_hdr_4addr *hdr;
- //struct ieee80211_hdr_3addrqos *hdr;
-
- size_t hdrlen;
- u16 fc, type, stype, sc;
- struct net_device_stats *stats;
- unsigned int frag;
- u8 *payload;
- u16 ethertype;
- //added by amy for reorder
- u8 TID = 0;
- u16 SeqNum = 0;
- PRX_TS_RECORD pTS = NULL;
- //bool bIsAggregateFrame = false;
- //added by amy for reorder
-// u16 qos_ctl = 0;
- u8 dst[ETH_ALEN];
- u8 src[ETH_ALEN];
- u8 bssid[ETH_ALEN];
- struct ieee80211_crypt_data *crypt = NULL;
- int keyidx = 0;
-
- int i;
- struct ieee80211_rxb* rxb = NULL;
- // cheat the the hdr type
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
- stats = &ieee->stats;
-
- if (skb->len < 10) {
- printk(KERN_INFO "%s: SKB length < 10\n",
- dev->name);
- goto rx_dropped;
- }
-
- fc = le16_to_cpu(hdr->frame_ctl);
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
- sc = le16_to_cpu(hdr->seq_ctl);
-
- frag = WLAN_GET_SEQ_FRAG(sc);
- hdrlen = ieee80211_get_hdrlen(fc);
-
- if(HTCCheck(ieee, skb->data))
- {
- if(net_ratelimit())
- printk("find HTCControl\n");
- hdrlen += 4;
- rx_stats->bContainHTC = 1;
- }
-
- //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
-
- if (ieee->iw_mode == IW_MODE_MONITOR) {
- ieee80211_monitor_rx(ieee, skb, rx_stats);
- stats->rx_packets++;
- stats->rx_bytes += skb->len;
- return 1;
- }
-
- if (ieee->host_decrypt) {
- int idx = 0;
- if (skb->len >= hdrlen + 3)
- idx = skb->data[hdrlen + 3] >> 6;
- crypt = ieee->crypt[idx];
-
- /* allow NULL decrypt to indicate an station specific override
- * for default encryption */
- if (crypt && (crypt->ops == NULL ||
- crypt->ops->decrypt_mpdu == NULL))
- crypt = NULL;
-
- if (!crypt && (fc & IEEE80211_FCTL_WEP)) {
- /* This seems to be triggered by some (multicast?)
- * frames from other than current BSS, so just drop the
- * frames silently instead of filling system log with
- * these reports. */
- IEEE80211_DEBUG_DROP("Decryption failed (not set)"
- " (SA=%pM)\n",
- hdr->addr2);
- ieee->ieee_stats.rx_discards_undecryptable++;
- goto rx_dropped;
- }
- }
-
- if (skb->len < IEEE80211_DATA_HDR3_LEN)
- goto rx_dropped;
-
- // if QoS enabled, should check the sequence for each of the AC
- if( (ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)){
- if (is_duplicate_packet(ieee, hdr))
- goto rx_dropped;
-
- }
- else
- {
- PRX_TS_RECORD pRxTS = NULL;
- //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid);
-#if 1
- if(GetTs(
- ieee,
- (PTS_COMMON_INFO*) &pRxTS,
- hdr->addr2,
- (u8)Frame_QoSTID((u8*)(skb->data)),
- RX_DIR,
- true))
- {
-
- // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
- if( (fc & (1<<11)) &&
- (frag == pRxTS->RxLastFragNum) &&
- (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) )
- {
- goto rx_dropped;
- }
- else
- {
- pRxTS->RxLastFragNum = frag;
- pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
- }
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__FUNCTION__);
- goto rx_dropped;
- }
- }
-#endif
- if (type == IEEE80211_FTYPE_MGMT) {
-
- //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
- if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
- goto rx_dropped;
- else
- goto rx_exit;
- }
-
- /* Data frame - extract src/dst addresses */
- switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
- case IEEE80211_FCTL_FROMDS:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr3, ETH_ALEN);
- memcpy(bssid, hdr->addr2, ETH_ALEN);
- break;
- case IEEE80211_FCTL_TODS:
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr1, ETH_ALEN);
- break;
- case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
- if (skb->len < IEEE80211_DATA_HDR4_LEN)
- goto rx_dropped;
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr4, ETH_ALEN);
- memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
- break;
- case 0:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr3, ETH_ALEN);
- break;
- }
-
-
- dev->last_rx = jiffies;
-
- //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
- /* Nullfunc frames may have PS-bit set, so they must be passed to
- * hostap_handle_sta_rx() before being dropped here. */
- if (stype != IEEE80211_STYPE_DATA &&
- stype != IEEE80211_STYPE_DATA_CFACK &&
- stype != IEEE80211_STYPE_DATA_CFPOLL &&
- stype != IEEE80211_STYPE_DATA_CFACKPOLL&&
- stype != IEEE80211_STYPE_QOS_DATA//add by David,2006.8.4
- ) {
- if (stype != IEEE80211_STYPE_NULLFUNC)
- IEEE80211_DEBUG_DROP(
- "RX: dropped data frame "
- "with no data (type=0x%02x, "
- "subtype=0x%02x, len=%d)\n",
- type, stype, skb->len);
- goto rx_dropped;
- }
- if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
- goto rx_dropped;
-
- /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
-
- if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
- (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
- {
- printk("decrypt frame error\n");
- goto rx_dropped;
- }
-
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
-
- /* skb: hdr + (possibly fragmented) plaintext payload */
- // PR: FIXME: hostap has additional conditions in the "if" below:
- // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
- if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
- int flen;
- struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
- IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
-
- if (!frag_skb) {
- IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
- "Rx cannot get skb from fragment "
- "cache (morefrag=%d seq=%u frag=%u)\n",
- (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
- WLAN_GET_SEQ_SEQ(sc), frag);
- goto rx_dropped;
- }
- flen = skb->len;
- if (frag != 0)
- flen -= hdrlen;
-
- if (frag_skb->tail + flen > frag_skb->end) {
- printk(KERN_WARNING "%s: host decrypted and "
- "reassembled frame did not fit skb\n",
- dev->name);
- ieee80211_frag_cache_invalidate(ieee, hdr);
- goto rx_dropped;
- }
-
- if (frag == 0) {
- /* copy first fragment (including full headers) into
- * beginning of the fragment cache skb */
- memcpy(skb_put(frag_skb, flen), skb->data, flen);
- } else {
- /* append frame payload to the end of the fragment
- * cache skb */
- memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
- flen);
- }
- dev_kfree_skb_any(skb);
- skb = NULL;
-
- if (fc & IEEE80211_FCTL_MOREFRAGS) {
- /* more fragments expected - leave the skb in fragment
- * cache for now; it will be delivered to upper layers
- * after all fragments have been received */
- goto rx_exit;
- }
-
- /* this was the last fragment and the frame will be
- * delivered, so remove skb from fragment cache */
- skb = frag_skb;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- ieee80211_frag_cache_invalidate(ieee, hdr);
- }
-
- /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
- * encrypted/authenticated */
- if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
- ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
- {
- printk("==>decrypt msdu error\n");
- goto rx_dropped;
- }
-
- //added by amy for AP roaming
- ieee->LinkDetectInfo.NumRecvDataInPeriod++;
- ieee->LinkDetectInfo.NumRxOkInPeriod++;
-
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
- if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
- if (/*ieee->ieee802_1x &&*/
- ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
-
-#ifdef CONFIG_IEEE80211_DEBUG
- /* pass unencrypted EAPOL frames even if encryption is
- * configured */
- struct eapol *eap = (struct eapol *)(skb->data +
- 24);
- IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
- eap_get_type(eap->type));
-#endif
- } else {
- IEEE80211_DEBUG_DROP(
- "encryption configured, but RX "
- "frame not encrypted (SA=%pM)\n",
- hdr->addr2);
- goto rx_dropped;
- }
- }
-
-#ifdef CONFIG_IEEE80211_DEBUG
- if (crypt && !(fc & IEEE80211_FCTL_WEP) &&
- ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
- struct eapol *eap = (struct eapol *)(skb->data +
- 24);
- IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
- eap_get_type(eap->type));
- }
-#endif
-
- if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
- !ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
- IEEE80211_DEBUG_DROP(
- "dropped unencrypted RX data "
- "frame from %pM"
- " (drop_unencrypted=1)\n",
- hdr->addr2);
- goto rx_dropped;
- }
-/*
- if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
- printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
- }
-*/
-//added by amy for reorder
-#if 1
- if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
- && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1))
- {
- TID = Frame_QoSTID(skb->data);
- SeqNum = WLAN_GET_SEQ_SEQ(sc);
- GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true);
- if(TID !=0 && TID !=3)
- {
- ieee->bis_any_nonbepkts = true;
- }
- }
-#endif
-//added by amy for reorder
- /* skb: hdr + (possible reassembled) full plaintext payload */
- payload = skb->data + hdrlen;
- //ethertype = (payload[6] << 8) | payload[7];
- rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC);
- if(rxb == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__FUNCTION__);
- goto rx_dropped;
- }
- /* to parse amsdu packets */
- /* qos data packets & reserved bit is 1 */
- if(parse_subframe(skb,rx_stats,rxb,src,dst) == 0) {
- /* only to free rxb, and not submit the packets to upper layer */
- for(i =0; i < rxb->nr_subframes; i++) {
- dev_kfree_skb(rxb->subframes[i]);
- }
- kfree(rxb);
- rxb = NULL;
- goto rx_dropped;
- }
-
- ieee->last_rx_ps_time = jiffies;
-//added by amy for reorder
- if(ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL){
-//added by amy for reorder
- for(i = 0; i<rxb->nr_subframes; i++) {
- struct sk_buff *sub_skb = rxb->subframes[i];
-
- if (sub_skb) {
- /* convert hdr + possible LLC headers into Ethernet header */
- ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
- if (sub_skb->len >= 8 &&
- ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
- ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
- memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
- /* remove RFC1042 or Bridge-Tunnel encapsulation and
- * replace EtherType */
- skb_pull(sub_skb, SNAP_SIZE);
- memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
- } else {
- u16 len;
- /* Leave Ethernet header part of hdr and full payload */
- len = htons(sub_skb->len);
- memcpy(skb_push(sub_skb, 2), &len, 2);
- memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
- }
-
- stats->rx_packets++;
- stats->rx_bytes += sub_skb->len;
- if(is_multicast_ether_addr(dst)) {
- stats->multicast++;
- }
-
- /* Indicat the packets to upper layer */
- //printk("0skb_len(%d)\n", skb->len);
- sub_skb->protocol = eth_type_trans(sub_skb, dev);
- memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
- sub_skb->dev = dev;
- sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
- //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
- //printk("1skb_len(%d)\n", skb->len);
- netif_rx(sub_skb);
- }
- }
- kfree(rxb);
- rxb = NULL;
-
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__);
- RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
- }
-#ifndef JOHN_NOCPY
- dev_kfree_skb(skb);
-#endif
-
- rx_exit:
- return 1;
-
- rx_dropped:
- if (rxb != NULL)
- {
- kfree(rxb);
- rxb = NULL;
- }
- stats->rx_dropped++;
-
- /* Returning 0 indicates to caller that we have not handled the SKB--
- * so it is still allocated and can be used again by underlying
- * hardware as a DMA target */
- return 0;
-}
-
-#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
-
-static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
-
-/*
-* Make ther structure we read from the beacon packet has
-* the right values
-*/
-static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
- *info_element, int sub_type)
-{
-
- if (info_element->qui_subtype != sub_type)
- return -1;
- if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
- return -1;
- if (info_element->qui_type != QOS_OUI_TYPE)
- return -1;
- if (info_element->version != QOS_VERSION_1)
- return -1;
-
- return 0;
-}
-
-
-/*
- * Parse a QoS parameter element
- */
-static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
- *element_param, struct ieee80211_info_element
- *info_element)
-{
- int ret = 0;
- u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
-
- if ((info_element == NULL) || (element_param == NULL))
- return -1;
-
- if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
- memcpy(element_param->info_element.qui, info_element->data,
- info_element->len);
- element_param->info_element.elementID = info_element->id;
- element_param->info_element.length = info_element->len;
- } else
- ret = -1;
- if (ret == 0)
- ret = ieee80211_verify_qos_info(&element_param->info_element,
- QOS_OUI_PARAM_SUB_TYPE);
- return ret;
-}
-
-/*
- * Parse a QoS information element
- */
-static int ieee80211_read_qos_info_element(struct
- ieee80211_qos_information_element
- *element_info, struct ieee80211_info_element
- *info_element)
-{
- int ret = 0;
- u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
-
- if (element_info == NULL)
- return -1;
- if (info_element == NULL)
- return -1;
-
- if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
- memcpy(element_info->qui, info_element->data,
- info_element->len);
- element_info->elementID = info_element->id;
- element_info->length = info_element->len;
- } else
- ret = -1;
-
- if (ret == 0)
- ret = ieee80211_verify_qos_info(element_info,
- QOS_OUI_INFO_SUB_TYPE);
- return ret;
-}
-
-
-/*
- * Write QoS parameters from the ac parameters.
- */
-static int ieee80211_qos_convert_ac_to_parameters(struct
- ieee80211_qos_parameter_info
- *param_elm, struct
- ieee80211_qos_parameters
- *qos_param)
-{
- int rc = 0;
- int i;
- struct ieee80211_qos_ac_parameter *ac_params;
- u8 aci;
- //u8 cw_min;
- //u8 cw_max;
-
- for (i = 0; i < QOS_QUEUE_NUM; i++) {
- ac_params = &(param_elm->ac_params_record[i]);
-
- aci = (ac_params->aci_aifsn & 0x60) >> 5;
-
- if(aci >= QOS_QUEUE_NUM)
- continue;
- qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
-
- /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
- qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
-
- qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
-
- qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
-
- qos_param->flag[aci] =
- (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
- qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
- }
- return rc;
-}
-
-/*
- * we have a generic data element which it may contain QoS information or
- * parameters element. check the information element length to decide
- * which type to read
- */
-static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
- *info_element,
- struct ieee80211_network *network)
-{
- int rc = 0;
- struct ieee80211_qos_parameters *qos_param = NULL;
- struct ieee80211_qos_information_element qos_info_element;
-
- rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
-
- if (rc == 0) {
- network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
- network->flags |= NETWORK_HAS_QOS_INFORMATION;
- } else {
- struct ieee80211_qos_parameter_info param_element;
-
- rc = ieee80211_read_qos_param_element(&param_element,
- info_element);
- if (rc == 0) {
- qos_param = &(network->qos_data.parameters);
- ieee80211_qos_convert_ac_to_parameters(&param_element,
- qos_param);
- network->flags |= NETWORK_HAS_QOS_PARAMETERS;
- network->qos_data.param_count =
- param_element.info_element.ac_info & 0x0F;
- }
- }
-
- if (rc == 0) {
- IEEE80211_DEBUG_QOS("QoS is supported\n");
- network->qos_data.supported = 1;
- }
- return rc;
-}
-
-#ifdef CONFIG_IEEE80211_DEBUG
-#define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
-
-static const char *get_info_element_string(u16 id)
-{
- switch (id) {
- MFIE_STRING(SSID);
- MFIE_STRING(RATES);
- MFIE_STRING(FH_SET);
- MFIE_STRING(DS_SET);
- MFIE_STRING(CF_SET);
- MFIE_STRING(TIM);
- MFIE_STRING(IBSS_SET);
- MFIE_STRING(COUNTRY);
- MFIE_STRING(HOP_PARAMS);
- MFIE_STRING(HOP_TABLE);
- MFIE_STRING(REQUEST);
- MFIE_STRING(CHALLENGE);
- MFIE_STRING(POWER_CONSTRAINT);
- MFIE_STRING(POWER_CAPABILITY);
- MFIE_STRING(TPC_REQUEST);
- MFIE_STRING(TPC_REPORT);
- MFIE_STRING(SUPP_CHANNELS);
- MFIE_STRING(CSA);
- MFIE_STRING(MEASURE_REQUEST);
- MFIE_STRING(MEASURE_REPORT);
- MFIE_STRING(QUIET);
- MFIE_STRING(IBSS_DFS);
- // MFIE_STRING(ERP_INFO);
- MFIE_STRING(RSN);
- MFIE_STRING(RATES_EX);
- MFIE_STRING(GENERIC);
- MFIE_STRING(QOS_PARAMETER);
- default:
- return "UNKNOWN";
- }
-}
-#endif
-
-static inline void ieee80211_extract_country_ie(
- struct ieee80211_device *ieee,
- struct ieee80211_info_element *info_element,
- struct ieee80211_network *network,
- u8 * addr2
-)
-{
- if(IS_DOT11D_ENABLE(ieee))
- {
- if(info_element->len!= 0)
- {
- memcpy(network->CountryIeBuf, info_element->data, info_element->len);
- network->CountryIeLen = info_element->len;
-
- if(!IS_COUNTRY_IE_VALID(ieee))
- {
- Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
- }
- }
-
- //
- // 070305, rcnjko: I update country IE watch dog here because
- // some AP (e.g. Cisco 1242) don't include country IE in their
- // probe response frame.
- //
- if(IS_EQUAL_CIE_SRC(ieee, addr2) )
- {
- UPDATE_CIE_WATCHDOG(ieee);
- }
- }
-
-}
-
-int ieee80211_parse_info_param(struct ieee80211_device *ieee,
- struct ieee80211_info_element *info_element,
- u16 length,
- struct ieee80211_network *network,
- struct ieee80211_rx_stats *stats)
-{
- u8 i;
- short offset;
- u16 tmp_htcap_len=0;
- u16 tmp_htinfo_len=0;
- u16 ht_realtek_agg_len=0;
- u8 ht_realtek_agg_buf[MAX_IE_LEN];
-// u16 broadcom_len = 0;
-#ifdef CONFIG_IEEE80211_DEBUG
- char rates_str[64];
- char *p;
-#endif
-
- while (length >= sizeof(*info_element)) {
- if (sizeof(*info_element) + info_element->len > length) {
- IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
- "info_element->len + 2 > left : "
- "info_element->len+2=%zd left=%d, id=%d.\n",
- info_element->len +
- sizeof(*info_element),
- length, info_element->id);
- /* We stop processing but don't return an error here
- * because some misbehaviour APs break this rule. ie.
- * Orinoco AP1000. */
- break;
- }
-
- switch (info_element->id) {
- case MFIE_TYPE_SSID:
- if (ieee80211_is_empty_essid(info_element->data,
- info_element->len)) {
- network->flags |= NETWORK_EMPTY_ESSID;
- break;
- }
-
- network->ssid_len = min(info_element->len,
- (u8) IW_ESSID_MAX_SIZE);
- memcpy(network->ssid, info_element->data, network->ssid_len);
- if (network->ssid_len < IW_ESSID_MAX_SIZE)
- memset(network->ssid + network->ssid_len, 0,
- IW_ESSID_MAX_SIZE - network->ssid_len);
-
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
- network->ssid, network->ssid_len);
- break;
-
- case MFIE_TYPE_RATES:
-#ifdef CONFIG_IEEE80211_DEBUG
- p = rates_str;
-#endif
- network->rates_len = min(info_element->len,
- MAX_RATES_LENGTH);
- for (i = 0; i < network->rates_len; i++) {
- network->rates[i] = info_element->data[i];
-#ifdef CONFIG_IEEE80211_DEBUG
- p += snprintf(p, sizeof(rates_str) -
- (p - rates_str), "%02X ",
- network->rates[i]);
-#endif
- if (ieee80211_is_ofdm_rate
- (info_element->data[i])) {
- network->flags |= NETWORK_HAS_OFDM;
- if (info_element->data[i] &
- IEEE80211_BASIC_RATE_MASK)
- network->flags &=
- ~NETWORK_HAS_CCK;
- }
- }
-
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
- rates_str, network->rates_len);
- break;
-
- case MFIE_TYPE_RATES_EX:
-#ifdef CONFIG_IEEE80211_DEBUG
- p = rates_str;
-#endif
- network->rates_ex_len = min(info_element->len,
- MAX_RATES_EX_LENGTH);
- for (i = 0; i < network->rates_ex_len; i++) {
- network->rates_ex[i] = info_element->data[i];
-#ifdef CONFIG_IEEE80211_DEBUG
- p += snprintf(p, sizeof(rates_str) -
- (p - rates_str), "%02X ",
- network->rates[i]);
-#endif
- if (ieee80211_is_ofdm_rate
- (info_element->data[i])) {
- network->flags |= NETWORK_HAS_OFDM;
- if (info_element->data[i] &
- IEEE80211_BASIC_RATE_MASK)
- network->flags &=
- ~NETWORK_HAS_CCK;
- }
- }
-
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
- rates_str, network->rates_ex_len);
- break;
-
- case MFIE_TYPE_DS_SET:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
- info_element->data[0]);
- network->channel = info_element->data[0];
- break;
-
- case MFIE_TYPE_FH_SET:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
- break;
-
- case MFIE_TYPE_CF_SET:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
- break;
-
- case MFIE_TYPE_TIM:
- if(info_element->len < 4)
- break;
-
- network->tim.tim_count = info_element->data[0];
- network->tim.tim_period = info_element->data[1];
-
- network->dtim_period = info_element->data[1];
- if(ieee->state != IEEE80211_LINKED)
- break;
- //we use jiffies for legacy Power save
- network->last_dtim_sta_time[0] = jiffies;
- network->last_dtim_sta_time[1] = stats->mac_time[1];
-
- network->dtim_data = IEEE80211_DTIM_VALID;
-
- if(info_element->data[0] != 0)
- break;
-
- if(info_element->data[2] & 1)
- network->dtim_data |= IEEE80211_DTIM_MBCAST;
-
- offset = (info_element->data[2] >> 1)*2;
-
- //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
-
- if(ieee->assoc_id < 8*offset ||
- ieee->assoc_id > 8*(offset + info_element->len -3))
-
- break;
-
- offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ;
-
- if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
- network->dtim_data |= IEEE80211_DTIM_UCAST;
-
- //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
- break;
-
- case MFIE_TYPE_ERP:
- network->erp_value = info_element->data[0];
- network->flags |= NETWORK_HAS_ERP_VALUE;
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
- network->erp_value);
- break;
- case MFIE_TYPE_IBSS_SET:
- network->atim_window = info_element->data[0];
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
- network->atim_window);
- break;
-
- case MFIE_TYPE_CHALLENGE:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
- break;
-
- case MFIE_TYPE_GENERIC:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
- info_element->len);
- if (!ieee80211_parse_qos_info_param_IE(info_element,
- network))
- break;
-
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 &&
- info_element->data[2] == 0xf2 &&
- info_element->data[3] == 0x01) {
- network->wpa_ie_len = min(info_element->len + 2,
- MAX_WPA_IE_LEN);
- memcpy(network->wpa_ie, info_element,
- network->wpa_ie_len);
- break;
- }
-
- if (info_element->len == 7 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x01 &&
- info_element->data[4] == 0x02) {
- network->Turbo_Enable = 1;
- }
-
- //for HTcap and HTinfo parameters
- if(tmp_htcap_len == 0){
- if(info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x033){
-
- tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
- if(tmp_htcap_len != 0){
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
- sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
- memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
- }
- }
- if(tmp_htcap_len != 0){
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
- }else{
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
- }
- }
-
-
- if(tmp_htinfo_len == 0){
- if(info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x034){
-
- tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
- if(tmp_htinfo_len != 0){
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- if(tmp_htinfo_len){
- network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
- sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
- memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
- }
-
- }
-
- }
- }
-
- if(ieee->aggregation){
- if(network->bssht.bdSupportHT){
- if(info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x02){
-
- ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN);
- memcpy(ht_realtek_agg_buf,info_element->data,info_element->len);
-
- }
- if(ht_realtek_agg_len >= 5){
- network->realtek_cap_exit = true;
- network->bssht.bdRT2RTAggregation = true;
-
- if((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02))
- network->bssht.bdRT2RTLongSlotTime = true;
-
- if((ht_realtek_agg_buf[4]==1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
- {
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
- //bssDesc->Vender = HT_IOT_PEER_REALTEK_92SE;
- }
- }
- }
-
- }
-
- //if(tmp_htcap_len !=0 || tmp_htinfo_len != 0)
- {
- if((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x05 &&
- info_element->data[2] == 0xb5) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0a &&
- info_element->data[2] == 0xf7) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x10 &&
- info_element->data[2] == 0x18)){
-
- network->broadcom_cap_exist = true;
-
- }
- }
- if(info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0c &&
- info_element->data[2] == 0x43)
- {
- network->ralink_cap_exist = true;
- }
- else
- network->ralink_cap_exist = false;
- //added by amy for atheros AP
- if((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x03 &&
- info_element->data[2] == 0x7f) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x13 &&
- info_element->data[2] == 0x74))
- {
- // printk("========>%s(): athros AP is exist\n",__FUNCTION__);
- network->atheros_cap_exist = true;
- }
- else
- network->atheros_cap_exist = false;
-
- if ((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 &&
- info_element->data[2] == 0x43) )
- {
- network->marvell_cap_exist = true;
- }
- else
- network->marvell_cap_exist = false;
-
- if(info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96)
- {
- network->cisco_cap_exist = true;
- }
- else
- network->cisco_cap_exist = false;
- //added by amy for LEAP of cisco
- if(info_element->len > 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x01)
- {
- if(info_element->len == 6)
- {
- memcpy(network->CcxRmState, &info_element[4], 2);
- if(network->CcxRmState[0] != 0)
- {
- network->bCcxRmEnable = true;
- }
- else
- network->bCcxRmEnable = false;
- //
- // CCXv4 Table 59-1 MBSSID Masks.
- //
- network->MBssidMask = network->CcxRmState[1] & 0x07;
- if(network->MBssidMask != 0)
- {
- network->bMBssidValid = true;
- network->MBssidMask = 0xff << (network->MBssidMask);
- cpMacAddr(network->MBssid, network->bssid);
- network->MBssid[5] &= network->MBssidMask;
- }
- else
- {
- network->bMBssidValid = false;
- }
- }
- else
- {
- network->bCcxRmEnable = false;
- }
- }
- if(info_element->len > 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x03)
- {
- if(info_element->len == 5)
- {
- network->bWithCcxVerNum = true;
- network->BssCcxVerNumber = info_element->data[4];
- }
- else
- {
- network->bWithCcxVerNum = false;
- network->BssCcxVerNumber = 0;
- }
- }
- break;
-
- case MFIE_TYPE_RSN:
- IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
- info_element->len);
- network->rsn_ie_len = min(info_element->len + 2,
- MAX_WPA_IE_LEN);
- memcpy(network->rsn_ie, info_element,
- network->rsn_ie_len);
- break;
-
- //HT related element.
- case MFIE_TYPE_HT_CAP:
- IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
- info_element->len);
- tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
- if(tmp_htcap_len != 0){
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
- sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
- memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
-
- //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
- // windows driver will update WMM parameters each beacon received once connected
- // Linux driver is a bit different.
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((PHT_CAPABILITY_ELE)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
- }
- else{
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
- }
- break;
-
-
- case MFIE_TYPE_HT_INFO:
- IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
- info_element->len);
- tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
- if(tmp_htinfo_len){
- network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
- network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
- sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
- memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
- }
- break;
-
- case MFIE_TYPE_AIRONET:
- IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
- info_element->len);
- if(info_element->len >IE_CISCO_FLAG_POSITION)
- {
- network->bWithAironetIE = true;
-
- // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
- // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
- // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
- if( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) ||
- (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) )
- {
- network->bCkipSupported = true;
- }
- else
- {
- network->bCkipSupported = false;
- }
- }
- else
- {
- network->bWithAironetIE = false;
- network->bCkipSupported = false;
- }
- break;
- case MFIE_TYPE_QOS_PARAMETER:
- printk(KERN_ERR
- "QoS Error need to parse QOS_PARAMETER IE\n");
- break;
-
- case MFIE_TYPE_COUNTRY:
- IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
- info_element->len);
- //printk("=====>Receive <%s> Country IE\n",network->ssid);
- ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP
- break;
- default:
- IEEE80211_DEBUG_MGMT
- ("Unsupported info element: %s (%d)\n",
- get_info_element_string(info_element->id),
- info_element->id);
- break;
- }
-
- length -= sizeof(*info_element) + info_element->len;
- info_element =
- (struct ieee80211_info_element *)&info_element->
- data[info_element->len];
- }
-
- if(!network->atheros_cap_exist && !network->broadcom_cap_exist &&
- !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation)
- {
- network->unknown_cap_exist = true;
- }
- else
- {
- network->unknown_cap_exist = false;
- }
- return 0;
-}
-
-static inline u8 ieee80211_SignalStrengthTranslate(
- u8 CurrSS
- )
-{
- u8 RetSS;
-
- // Step 1. Scale mapping.
- if(CurrSS >= 71 && CurrSS <= 100)
- {
- RetSS = 90 + ((CurrSS - 70) / 3);
- }
- else if(CurrSS >= 41 && CurrSS <= 70)
- {
- RetSS = 78 + ((CurrSS - 40) / 3);
- }
- else if(CurrSS >= 31 && CurrSS <= 40)
- {
- RetSS = 66 + (CurrSS - 30);
- }
- else if(CurrSS >= 21 && CurrSS <= 30)
- {
- RetSS = 54 + (CurrSS - 20);
- }
- else if(CurrSS >= 5 && CurrSS <= 20)
- {
- RetSS = 42 + (((CurrSS - 5) * 2) / 3);
- }
- else if(CurrSS == 4)
- {
- RetSS = 36;
- }
- else if(CurrSS == 3)
- {
- RetSS = 27;
- }
- else if(CurrSS == 2)
- {
- RetSS = 18;
- }
- else if(CurrSS == 1)
- {
- RetSS = 9;
- }
- else
- {
- RetSS = CurrSS;
- }
- //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
-
- // Step 2. Smoothing.
-
- //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
-
- return RetSS;
-}
-
-long ieee80211_translate_todbm(u8 signal_strength_index )// 0-100 index.
-{
- long signal_power; // in dBm.
-
- // Translate to dBm (x=0.5y-95).
- signal_power = (long)((signal_strength_index + 1) >> 1);
- signal_power -= 95;
-
- return signal_power;
-}
-
-static inline int ieee80211_network_init(
- struct ieee80211_device *ieee,
- struct ieee80211_probe_response *beacon,
- struct ieee80211_network *network,
- struct ieee80211_rx_stats *stats)
-{
-#ifdef CONFIG_IEEE80211_DEBUG
- //char rates_str[64];
- //char *p;
-#endif
-
- network->qos_data.active = 0;
- network->qos_data.supported = 0;
- network->qos_data.param_count = 0;
- network->qos_data.old_param_count = 0;
-
- /* Pull out fixed field data */
- memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
- network->capability = le16_to_cpu(beacon->capability);
- network->last_scanned = jiffies;
- network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
- network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
- network->beacon_interval = le32_to_cpu(beacon->beacon_interval);
- /* Where to pull this? beacon->listen_interval;*/
- network->listen_interval = 0x0A;
- network->rates_len = network->rates_ex_len = 0;
- network->last_associate = 0;
- network->ssid_len = 0;
- network->flags = 0;
- network->atim_window = 0;
- network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
- 0x3 : 0x0;
- network->berp_info_valid = false;
- network->broadcom_cap_exist = false;
- network->ralink_cap_exist = false;
- network->atheros_cap_exist = false;
- network->cisco_cap_exist = false;
- network->unknown_cap_exist = false;
- network->realtek_cap_exit = false;
- network->marvell_cap_exist = false;
- network->Turbo_Enable = 0;
- network->CountryIeLen = 0;
- memset(network->CountryIeBuf, 0, MAX_IE_LEN);
-//Initialize HT parameters
- //ieee80211_ht_initialize(&network->bssht);
- HTInitializeBssDesc(&network->bssht);
- if (stats->freq == IEEE80211_52GHZ_BAND) {
- /* for A band (No DS info) */
- network->channel = stats->received_channel;
- } else
- network->flags |= NETWORK_HAS_CCK;
-
- network->wpa_ie_len = 0;
- network->rsn_ie_len = 0;
-
- if (ieee80211_parse_info_param
- (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats))
- return 1;
-
- network->mode = 0;
- if (stats->freq == IEEE80211_52GHZ_BAND)
- network->mode = IEEE_A;
- else {
- if (network->flags & NETWORK_HAS_OFDM)
- network->mode |= IEEE_G;
- if (network->flags & NETWORK_HAS_CCK)
- network->mode |= IEEE_B;
- }
-
- if (network->mode == 0) {
- IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' "
- "network.\n",
- escape_essid(network->ssid,
- network->ssid_len),
- network->bssid);
- return 1;
- }
-
- if(network->bssht.bdSupportHT){
- if(network->mode == IEEE_A)
- network->mode = IEEE_N_5G;
- else if(network->mode & (IEEE_G | IEEE_B))
- network->mode = IEEE_N_24G;
- }
- if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
- network->flags |= NETWORK_EMPTY_ESSID;
-
-#if 1
- stats->signal = 30 + (stats->SignalStrength * 70) / 100;
- //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
- stats->noise = ieee80211_translate_todbm((u8)(100-stats->signal)) -25;
-#endif
-
- memcpy(&network->stats, stats, sizeof(network->stats));
-
- return 0;
-}
-
-static inline int is_same_network(struct ieee80211_network *src,
- struct ieee80211_network *dst, struct ieee80211_device* ieee)
-{
- /* A network is only a duplicate if the channel, BSSID, ESSID
- * and the capability field (in particular IBSS and BSS) all match.
- * We treat all <hidden> with the same BSSID and channel
- * as one network */
- return //((src->ssid_len == dst->ssid_len) &&
- (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
- (src->channel == dst->channel) &&
- !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
- //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
- (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
- ((src->capability & WLAN_CAPABILITY_IBSS) ==
- (dst->capability & WLAN_CAPABILITY_IBSS)) &&
- ((src->capability & WLAN_CAPABILITY_BSS) ==
- (dst->capability & WLAN_CAPABILITY_BSS)));
-}
-
-static inline void update_network(struct ieee80211_network *dst,
- struct ieee80211_network *src)
-{
- int qos_active;
- u8 old_param;
-
- memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
- dst->capability = src->capability;
- memcpy(dst->rates, src->rates, src->rates_len);
- dst->rates_len = src->rates_len;
- memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
- dst->rates_ex_len = src->rates_ex_len;
- if(src->ssid_len > 0)
- {
- memset(dst->ssid, 0, dst->ssid_len);
- dst->ssid_len = src->ssid_len;
- memcpy(dst->ssid, src->ssid, src->ssid_len);
- }
- dst->mode = src->mode;
- dst->flags = src->flags;
- dst->time_stamp[0] = src->time_stamp[0];
- dst->time_stamp[1] = src->time_stamp[1];
- if (src->flags & NETWORK_HAS_ERP_VALUE)
- {
- dst->erp_value = src->erp_value;
- dst->berp_info_valid = src->berp_info_valid = true;
- }
- dst->beacon_interval = src->beacon_interval;
- dst->listen_interval = src->listen_interval;
- dst->atim_window = src->atim_window;
- dst->dtim_period = src->dtim_period;
- dst->dtim_data = src->dtim_data;
- dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
- dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
- memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters));
-
- dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
- dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
- dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen;
- memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen);
- dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen;
- memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen);
- dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
- dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
- dst->broadcom_cap_exist = src->broadcom_cap_exist;
- dst->ralink_cap_exist = src->ralink_cap_exist;
- dst->atheros_cap_exist = src->atheros_cap_exist;
- dst->realtek_cap_exit = src->realtek_cap_exit;
- dst->marvell_cap_exist = src->marvell_cap_exist;
- dst->cisco_cap_exist = src->cisco_cap_exist;
- dst->unknown_cap_exist = src->unknown_cap_exist;
- memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
- dst->wpa_ie_len = src->wpa_ie_len;
- memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
- dst->rsn_ie_len = src->rsn_ie_len;
-
- dst->last_scanned = jiffies;
- /* qos related parameters */
- //qos_active = src->qos_data.active;
- qos_active = dst->qos_data.active;
- //old_param = dst->qos_data.old_param_count;
- old_param = dst->qos_data.param_count;
- if(dst->flags & NETWORK_HAS_QOS_MASK){
- //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
- // printk("====>%s(), aifs:%x, %x\n", __FUNCTION__, dst->qos_data.parameters.aifs[0], src->qos_data.parameters.aifs[0]);
- // memcpy(&dst->qos_data, &src->qos_data,
- // sizeof(struct ieee80211_qos_data));
- }
- else {
- dst->qos_data.supported = src->qos_data.supported;
- dst->qos_data.param_count = src->qos_data.param_count;
- }
-
- if(dst->qos_data.supported == 1) {
- dst->QoS_Enable = 1;
- if(dst->ssid_len)
- IEEE80211_DEBUG_QOS
- ("QoS the network %s is QoS supported\n",
- dst->ssid);
- else
- IEEE80211_DEBUG_QOS
- ("QoS the network is QoS supported\n");
- }
- dst->qos_data.active = qos_active;
- dst->qos_data.old_param_count = old_param;
-
- /* dst->last_associate is not overwritten */
-#if 1
- dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
- if(src->wmm_param[0].ac_aci_acm_aifsn|| \
- src->wmm_param[1].ac_aci_acm_aifsn|| \
- src->wmm_param[2].ac_aci_acm_aifsn|| \
- src->wmm_param[1].ac_aci_acm_aifsn) {
- memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
- }
- //dst->QoS_Enable = src->QoS_Enable;
-#else
- dst->QoS_Enable = 1;//for Rtl8187 simulation
-#endif
- dst->Turbo_Enable = src->Turbo_Enable;
-
- dst->CountryIeLen = src->CountryIeLen;
- memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen);
-
- //added by amy for LEAP
- dst->bWithAironetIE = src->bWithAironetIE;
- dst->bCkipSupported = src->bCkipSupported;
- memcpy(dst->CcxRmState,src->CcxRmState,2);
- dst->bCcxRmEnable = src->bCcxRmEnable;
- dst->MBssidMask = src->MBssidMask;
- dst->bMBssidValid = src->bMBssidValid;
- memcpy(dst->MBssid,src->MBssid,6);
- dst->bWithCcxVerNum = src->bWithCcxVerNum;
- dst->BssCcxVerNumber = src->BssCcxVerNumber;
-
-}
-
-static inline int is_beacon(__le16 fc)
-{
- return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
-}
-
-static inline void ieee80211_process_probe_response(
- struct ieee80211_device *ieee,
- struct ieee80211_probe_response *beacon,
- struct ieee80211_rx_stats *stats)
-{
- struct ieee80211_network network;
- struct ieee80211_network *target;
- struct ieee80211_network *oldest = NULL;
-#ifdef CONFIG_IEEE80211_DEBUG
- struct ieee80211_info_element *info_element = &beacon->info_element[0];
-#endif
- unsigned long flags;
- short renew;
- //u8 wmm_info;
-
- memset(&network, 0, sizeof(struct ieee80211_network));
- IEEE80211_DEBUG_SCAN(
- "'%s' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
- escape_essid(info_element->data, info_element->len),
- beacon->header.addr3,
- (beacon->capability & (1<<0xf)) ? '1' : '0',
- (beacon->capability & (1<<0xe)) ? '1' : '0',
- (beacon->capability & (1<<0xd)) ? '1' : '0',
- (beacon->capability & (1<<0xc)) ? '1' : '0',
- (beacon->capability & (1<<0xb)) ? '1' : '0',
- (beacon->capability & (1<<0xa)) ? '1' : '0',
- (beacon->capability & (1<<0x9)) ? '1' : '0',
- (beacon->capability & (1<<0x8)) ? '1' : '0',
- (beacon->capability & (1<<0x7)) ? '1' : '0',
- (beacon->capability & (1<<0x6)) ? '1' : '0',
- (beacon->capability & (1<<0x5)) ? '1' : '0',
- (beacon->capability & (1<<0x4)) ? '1' : '0',
- (beacon->capability & (1<<0x3)) ? '1' : '0',
- (beacon->capability & (1<<0x2)) ? '1' : '0',
- (beacon->capability & (1<<0x1)) ? '1' : '0',
- (beacon->capability & (1<<0x0)) ? '1' : '0');
-
- if (ieee80211_network_init(ieee, beacon, &network, stats)) {
- IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
- escape_essid(info_element->data,
- info_element->len),
- beacon->header.addr3,
- WLAN_FC_GET_STYPE(beacon->header.frame_control) ==
- IEEE80211_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
- return;
- }
-
- // For Asus EeePc request,
- // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
- // wireless adapter should follow the country code.
- // (2) If there is no any country code in beacon,
- // then wireless adapter should do active scan from ch1~11 and
- // passive scan from ch12~14
-
- if( !IsLegalChannel(ieee, network.channel) )
- return;
- if(ieee->bGlobalDomain)
- {
- if (WLAN_FC_GET_STYPE(beacon->header.frame_control) == IEEE80211_STYPE_PROBE_RESP)
- {
- // Case 1: Country code
- if(IS_COUNTRY_IE_VALID(ieee) )
- {
- if( !IsLegalChannel(ieee, network.channel) )
- {
- printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel);
- return;
- }
- }
- // Case 2: No any country code.
- else
- {
- // Filter over channel ch12~14
- if(network.channel > 11)
- {
- printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network.channel);
- return;
- }
- }
- }
- else
- {
- // Case 1: Country code
- if(IS_COUNTRY_IE_VALID(ieee) )
- {
- if( !IsLegalChannel(ieee, network.channel) )
- {
- printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel);
- return;
- }
- }
- // Case 2: No any country code.
- else
- {
- // Filter over channel ch12~14
- if(network.channel > 14)
- {
- printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network.channel);
- return;
- }
- }
- }
- }
-
- /* The network parsed correctly -- so now we scan our known networks
- * to see if we can find it in our list.
- *
- * NOTE: This search is definitely not optimized. Once its doing
- * the "right thing" we'll optimize it for efficiency if
- * necessary */
-
- /* Search for this entry in the list and update it if it is
- * already there. */
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- if(is_same_network(&ieee->current_network, &network, ieee)) {
- update_network(&ieee->current_network, &network);
- if((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G)
- && ieee->current_network.berp_info_valid){
- if(ieee->current_network.erp_value& ERP_UseProtection)
- ieee->current_network.buseprotection = true;
- else
- ieee->current_network.buseprotection = false;
- }
- if(is_beacon(beacon->header.frame_control))
- {
- if(ieee->state == IEEE80211_LINKED)
- ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
- }
- else //hidden AP
- network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & ieee->current_network.flags);
- }
-
- list_for_each_entry(target, &ieee->network_list, list) {
- if (is_same_network(target, &network, ieee))
- break;
- if ((oldest == NULL) ||
- (target->last_scanned < oldest->last_scanned))
- oldest = target;
- }
-
- /* If we didn't find a match, then get a new network slot to initialize
- * with this beacon's information */
- if (&target->list == &ieee->network_list) {
- if (list_empty(&ieee->network_free_list)) {
- /* If there are no more slots, expire the oldest */
- list_del(&oldest->list);
- target = oldest;
- IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from "
- "network list.\n",
- escape_essid(target->ssid,
- target->ssid_len),
- target->bssid);
- } else {
- /* Otherwise just pull from the free list */
- target = list_entry(ieee->network_free_list.next,
- struct ieee80211_network, list);
- list_del(ieee->network_free_list.next);
- }
-
-
-#ifdef CONFIG_IEEE80211_DEBUG
- IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
- escape_essid(network.ssid,
- network.ssid_len),
- network.bssid,
- WLAN_FC_GET_STYPE(beacon->header.frame_control) ==
- IEEE80211_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
-#endif
- memcpy(target, &network, sizeof(*target));
- list_add_tail(&target->list, &ieee->network_list);
- if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
- ieee80211_softmac_new_net(ieee,&network);
- } else {
- IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
- escape_essid(target->ssid,
- target->ssid_len),
- target->bssid,
- WLAN_FC_GET_STYPE(beacon->header.frame_control) ==
- IEEE80211_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
-
- /* we have an entry and we are going to update it. But this entry may
- * be already expired. In this case we do the same as we found a new
- * net and call the new_net handler
- */
- renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
- //YJ,add,080819,for hidden ap
- if(is_beacon(beacon->header.frame_control) == 0)
- network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & target->flags);
- //if(strncmp(network.ssid, "linksys-c",9) == 0)
- // printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
- if(((network.flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \
- && (((network.ssid_len > 0) && (strncmp(target->ssid, network.ssid, network.ssid_len)))\
- ||((ieee->current_network.ssid_len == network.ssid_len)&&(strncmp(ieee->current_network.ssid, network.ssid, network.ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK))))
- renew = 1;
- //YJ,add,080819,for hidden ap,end
-
- update_network(target, &network);
- if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
- ieee80211_softmac_new_net(ieee,&network);
- }
-
- spin_unlock_irqrestore(&ieee->lock, flags);
- if (is_beacon(beacon->header.frame_control)&&is_same_network(&ieee->current_network, &network, ieee)&&\
- (ieee->state == IEEE80211_LINKED)) {
- if(ieee->handle_beacon != NULL) {
- ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
- }
- }
-}
-
-void ieee80211_rx_mgt(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header,
- struct ieee80211_rx_stats *stats)
-{
- if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
- ieee->iw_mode == IW_MODE_INFRA &&
- ieee->state == IEEE80211_LINKED))
- {
- tasklet_schedule(&ieee->ps_task);
- }
-
- if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
- WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
- ieee->last_rx_ps_time = jiffies;
-
- switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
-
- case IEEE80211_STYPE_BEACON:
- IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
- WLAN_FC_GET_STYPE(header->frame_ctl));
- IEEE80211_DEBUG_SCAN("Beacon\n");
- ieee80211_process_probe_response(
- ieee, (struct ieee80211_probe_response *)header, stats);
- break;
-
- case IEEE80211_STYPE_PROBE_RESP:
- IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
- WLAN_FC_GET_STYPE(header->frame_ctl));
- IEEE80211_DEBUG_SCAN("Probe response\n");
- ieee80211_process_probe_response(
- ieee, (struct ieee80211_probe_response *)header, stats);
- break;
-
- }
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
deleted file mode 100644
index 02850479dd62..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
+++ /dev/null
@@ -1,3291 +0,0 @@
-/* IEEE 802.11 SoftMAC layer
- * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
- *
- * Mostly extracted from the rtl8180-sa2400 driver for the
- * in-kernel generic ieee802.11 stack.
- *
- * Few lines might be stolen from other part of the ieee80211
- * stack. Copyright who own it's copyright
- *
- * WPA code stolen from the ipw2200 driver.
- * Copyright who own it's copyright.
- *
- * released under the GPL
- */
-
-
-#include "ieee80211.h"
-
-#include <linux/random.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/version.h>
-#include <asm/uaccess.h>
-#include "dot11d.h"
-
-u8 rsn_authen_cipher_suite[16][4] = {
- {0x00,0x0F,0xAC,0x00}, //Use group key, //Reserved
- {0x00,0x0F,0xAC,0x01}, //WEP-40 //RSNA default
- {0x00,0x0F,0xAC,0x02}, //TKIP //NONE //{used just as default}
- {0x00,0x0F,0xAC,0x03}, //WRAP-historical
- {0x00,0x0F,0xAC,0x04}, //CCMP
- {0x00,0x0F,0xAC,0x05}, //WEP-104
-};
-
-short ieee80211_is_54g(struct ieee80211_network net)
-{
- return ((net.rates_ex_len > 0) || (net.rates_len > 4));
-}
-
-short ieee80211_is_shortslot(struct ieee80211_network net)
-{
- return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
-}
-
-/* returns the total length needed for pleacing the RATE MFIE
- * tag and the EXTENDED RATE MFIE tag if needed.
- * It encludes two bytes per tag for the tag itself and its len
- */
-unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
-{
- unsigned int rate_len = 0;
-
- if (ieee->modulation & IEEE80211_CCK_MODULATION)
- rate_len = IEEE80211_CCK_RATE_LEN + 2;
-
- if (ieee->modulation & IEEE80211_OFDM_MODULATION)
-
- rate_len += IEEE80211_OFDM_RATE_LEN + 2;
-
- return rate_len;
-}
-
-/* pleace the MFIE rate, tag to the memory (double) poined.
- * Then it updates the pointer so that
- * it points after the new MFIE tag added.
- */
-void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
-{
- u8 *tag = *tag_p;
-
- if (ieee->modulation & IEEE80211_CCK_MODULATION){
- *tag++ = MFIE_TYPE_RATES;
- *tag++ = 4;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
- }
-
- /* We may add an option for custom rates that specific HW might support */
- *tag_p = tag;
-}
-
-void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
-{
- u8 *tag = *tag_p;
-
- if (ieee->modulation & IEEE80211_OFDM_MODULATION){
-
- *tag++ = MFIE_TYPE_RATES_EX;
- *tag++ = 8;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
- *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
-
- }
-
- /* We may add an option for custom rates that specific HW might support */
- *tag_p = tag;
-}
-
-
-void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) {
- u8 *tag = *tag_p;
-
- *tag++ = MFIE_TYPE_GENERIC; //0
- *tag++ = 7;
- *tag++ = 0x00;
- *tag++ = 0x50;
- *tag++ = 0xf2;
- *tag++ = 0x02;//5
- *tag++ = 0x00;
- *tag++ = 0x01;
-#ifdef SUPPORT_USPD
- if(ieee->current_network.wmm_info & 0x80) {
- *tag++ = 0x0f|MAX_SP_Len;
- } else {
- *tag++ = MAX_SP_Len;
- }
-#else
- *tag++ = MAX_SP_Len;
-#endif
- *tag_p = tag;
-}
-
-void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) {
- u8 *tag = *tag_p;
-
- *tag++ = MFIE_TYPE_GENERIC; //0
- *tag++ = 7;
- *tag++ = 0x00;
- *tag++ = 0xe0;
- *tag++ = 0x4c;
- *tag++ = 0x01;//5
- *tag++ = 0x02;
- *tag++ = 0x11;
- *tag++ = 0x00;
-
- *tag_p = tag;
- printk(KERN_ALERT "This is enable turbo mode IE process\n");
-}
-
-void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
-{
- int nh;
- nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
-
-/*
- * if the queue is full but we have newer frames then
- * just overwrites the oldest.
- *
- * if (nh == ieee->mgmt_queue_tail)
- * return -1;
- */
- ieee->mgmt_queue_head = nh;
- ieee->mgmt_queue_ring[nh] = skb;
-
-}
-
-struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
-{
- struct sk_buff *ret;
-
- if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
- return NULL;
-
- ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
-
- ieee->mgmt_queue_tail =
- (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
-
- return ret;
-}
-
-void init_mgmt_queue(struct ieee80211_device *ieee)
-{
- ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
-}
-
-u8
-MgntQuery_TxRateExcludeCCKRates(struct ieee80211_device *ieee)
-{
- u16 i;
- u8 QueryRate = 0;
- u8 BasicRate;
-
-
- for( i = 0; i < ieee->current_network.rates_len; i++)
- {
- BasicRate = ieee->current_network.rates[i]&0x7F;
- if(!ieee80211_is_cck_rate(BasicRate))
- {
- if(QueryRate == 0)
- {
- QueryRate = BasicRate;
- }
- else
- {
- if(BasicRate < QueryRate)
- {
- QueryRate = BasicRate;
- }
- }
- }
- }
-
- if(QueryRate == 0)
- {
- QueryRate = 12;
- printk("No BasicRate found!!\n");
- }
- return QueryRate;
-}
-u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- u8 rate;
-
- if(pHTInfo->IOTAction & HT_IOT_ACT_WA_IOT_Broadcom)
- {
- rate = MgntQuery_TxRateExcludeCCKRates(ieee);
- }
- else
- rate = ieee->basic_rate & 0x7f;
-
- if(rate == 0){
- if(ieee->mode == IEEE_A||
- ieee->mode== IEEE_N_5G||
- (ieee->mode== IEEE_N_24G&&!pHTInfo->bCurSuppCCK))
- rate = 0x0c;
- else
- rate = 0x02;
- }
- return rate;
-}
-
-
-void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
-
-inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
-{
- unsigned long flags;
- short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
- struct ieee80211_hdr_3addr *header=
- (struct ieee80211_hdr_3addr *) skb->data;
-
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8);
- spin_lock_irqsave(&ieee->lock, flags);
-
- /* called with 2nd param 0, no mgmt lock required */
- ieee80211_sta_wakeup(ieee,0);
-
- tcb_desc->queue_index = MGNT_QUEUE;
- tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee);
- tcb_desc->RATRIndex = 7;
- tcb_desc->bTxDisableRateFallBack = 1;
- tcb_desc->bTxUseDriverAssingedRate = 1;
-
- if(single){
- if(ieee->queue_stop){
- enqueue_mgmt(ieee,skb);
- }else{
- header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0]<<4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- /* avoid watchdog triggers */
- ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
- }
-
- spin_unlock_irqrestore(&ieee->lock, flags);
- }else{
- spin_unlock_irqrestore(&ieee->lock, flags);
- spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
-
- header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- /* check wether the managed packet queued greater than 5 */
- if(!ieee->check_nic_enough_desc(ieee->dev,tcb_desc->queue_index)||\
- (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0)||\
- (ieee->queue_stop) ) {
- /* insert the skb packet to the management queue */
- /* as for the completion function, it does not need
- * to check it any more.
- * */
- printk("%s():insert to waitqueue!\n",__FUNCTION__);
- skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb);
- } else {
- ieee->softmac_hard_start_xmit(skb,ieee->dev);
- }
- spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
- }
-}
-
-inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
-{
-
- short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
- struct ieee80211_hdr_3addr *header =
- (struct ieee80211_hdr_3addr *) skb->data;
- u16 fc,type,stype;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8);
-
- fc = header->frame_control;
- type = WLAN_FC_GET_TYPE(fc);
- stype = WLAN_FC_GET_STYPE(fc);
-
-
- if(stype != IEEE80211_STYPE_PSPOLL)
- tcb_desc->queue_index = MGNT_QUEUE;
- else
- tcb_desc->queue_index = HIGH_QUEUE;
- tcb_desc->data_rate = MgntQuery_MgntFrameTxRate(ieee);
- tcb_desc->RATRIndex = 7;
- tcb_desc->bTxDisableRateFallBack = 1;
- tcb_desc->bTxUseDriverAssingedRate = 1;
- if(single){
- if(!(type == IEEE80211_FTYPE_CTL)) {
- header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- }
- /* avoid watchdog triggers */
- ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
-
- }else{
- if(!(type == IEEE80211_FTYPE_CTL)) {
- header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- }
- ieee->softmac_hard_start_xmit(skb,ieee->dev);
-
- }
-}
-
-inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
-{
- unsigned int len,rate_len;
- u8 *tag;
- struct sk_buff *skb;
- struct ieee80211_probe_request *req;
-
- len = ieee->current_network.ssid_len;
-
- rate_len = ieee80211_MFIE_rate_len(ieee);
-
- skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
- 2 + len + rate_len + ieee->tx_headroom);
- if (!skb)
- return NULL;
-
- skb_reserve(skb, ieee->tx_headroom);
-
- req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
- req->header.frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
- req->header.duration_id = 0; //FIXME: is this OK ?
-
- memset(req->header.addr1, 0xff, ETH_ALEN);
- memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memset(req->header.addr3, 0xff, ETH_ALEN);
-
- tag = (u8 *) skb_put(skb,len+2+rate_len);
-
- *tag++ = MFIE_TYPE_SSID;
- *tag++ = len;
- memcpy(tag, ieee->current_network.ssid, len);
- tag += len;
-
- ieee80211_MFIE_Brate(ieee,&tag);
- ieee80211_MFIE_Grate(ieee,&tag);
- return skb;
-}
-
-struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
-void ieee80211_send_beacon(struct ieee80211_device *ieee)
-{
- struct sk_buff *skb;
- if(!ieee->ieee_up)
- return;
- skb = ieee80211_get_beacon_(ieee);
-
- if (skb){
- softmac_mgmt_xmit(skb, ieee);
- ieee->softmac_stats.tx_beacons++;
- }
-
- if(ieee->beacon_txing && ieee->ieee_up){
- mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5)));
- }
-}
-
-
-void ieee80211_send_beacon_cb(unsigned long _ieee)
-{
- struct ieee80211_device *ieee =
- (struct ieee80211_device *) _ieee;
- unsigned long flags;
-
- spin_lock_irqsave(&ieee->beacon_lock, flags);
- ieee80211_send_beacon(ieee);
- spin_unlock_irqrestore(&ieee->beacon_lock, flags);
-}
-
-
-void ieee80211_send_probe(struct ieee80211_device *ieee)
-{
- struct sk_buff *skb;
-
- skb = ieee80211_probe_req(ieee);
- if (skb){
- softmac_mgmt_xmit(skb, ieee);
- ieee->softmac_stats.tx_probe_rq++;
- }
-}
-
-void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
-{
- if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
- ieee80211_send_probe(ieee);
- ieee80211_send_probe(ieee);
- }
-}
-
-/* this performs syncro scan blocking the caller until all channels
- * in the allowed channel map has been checked.
- */
-void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
-{
- short ch = 0;
- u8 channel_map[MAX_CHANNEL_NUMBER+1];
- memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
- ieee->be_scan_inprogress = true;
- down(&ieee->scan_sem);
-
- while(1)
- {
-
- do{
- ch++;
- if (ch > MAX_CHANNEL_NUMBER)
- goto out; /* scan completed */
- }while(!channel_map[ch]);
-
- /* this fuction can be called in two situations
- * 1- We have switched to ad-hoc mode and we are
- * performing a complete syncro scan before conclude
- * there are no interesting cell and to create a
- * new one. In this case the link state is
- * IEEE80211_NOLINK until we found an interesting cell.
- * If so the ieee8021_new_net, called by the RX path
- * will set the state to IEEE80211_LINKED, so we stop
- * scanning
- * 2- We are linked and the root uses run iwlist scan.
- * So we switch to IEEE80211_LINKED_SCANNING to remember
- * that we are still logically linked (not interested in
- * new network events, despite for updating the net list,
- * but we are temporarly 'unlinked' as the driver shall
- * not filter RX frames and the channel is changing.
- * So the only situation in witch are interested is to check
- * if the state become LINKED because of the #1 situation
- */
-
- if (ieee->state == IEEE80211_LINKED)
- goto out;
- ieee->set_chan(ieee->dev, ch);
- if(channel_map[ch] == 1)
- ieee80211_send_probe_requests(ieee);
-
- /* this prevent excessive time wait when we
- * need to wait for a syncro scan to end..
- */
- if(ieee->state < IEEE80211_LINKED)
- ;
- else
- if (ieee->sync_scan_hurryup)
- goto out;
-
-
- msleep_interruptible_rsl(IEEE80211_SOFTMAC_SCAN_TIME);
-
- }
-out:
- if(ieee->state < IEEE80211_LINKED){
- ieee->actscanning = false;
- up(&ieee->scan_sem);
- ieee->be_scan_inprogress = false;
- }
- else{
- ieee->sync_scan_hurryup = 0;
- if(IS_DOT11D_ENABLE(ieee))
- DOT11D_ScanComplete(ieee);
- up(&ieee->scan_sem);
- ieee->be_scan_inprogress = false;
-}
-}
-
-void ieee80211_softmac_scan_wq(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work, struct delayed_work, work);
- struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
- u8 last_channel = ieee->current_network.channel; //recored init channel inorder not change current channel when comming out the scan unexpectedly. WB.
- u8 channel_map[MAX_CHANNEL_NUMBER+1];
- memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
- if(!ieee->ieee_up)
- return;
- down(&ieee->scan_sem);
- do{
- ieee->current_network.channel =
- (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
- if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER)
- {
- //if current channel is not in channel map, set to default channel.
- if (!channel_map[ieee->current_network.channel]);
- ieee->current_network.channel = 6;
- goto out; /* no good chans */
- }
- }while(!channel_map[ieee->current_network.channel]);
- if (ieee->scanning == 0 )
- goto out;
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- if(channel_map[ieee->current_network.channel] == 1)
- ieee80211_send_probe_requests(ieee);
-
- queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
-
- up(&ieee->scan_sem);
- return;
-out:
- if(IS_DOT11D_ENABLE(ieee))
- DOT11D_ScanComplete(ieee);
- ieee->current_network.channel = last_channel;
- ieee->actscanning = false;
- ieee->scan_watch_dog = 0;
- ieee->scanning = 0;
- up(&ieee->scan_sem);
-}
-
-void ieee80211_beacons_start(struct ieee80211_device *ieee)
-{
- unsigned long flags;
- spin_lock_irqsave(&ieee->beacon_lock,flags);
-
- ieee->beacon_txing = 1;
- ieee80211_send_beacon(ieee);
-
- spin_unlock_irqrestore(&ieee->beacon_lock,flags);
-}
-
-void ieee80211_beacons_stop(struct ieee80211_device *ieee)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&ieee->beacon_lock,flags);
-
- ieee->beacon_txing = 0;
- del_timer_sync(&ieee->beacon_timer);
-
- spin_unlock_irqrestore(&ieee->beacon_lock,flags);
-
-}
-
-
-void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
-{
- if(ieee->stop_send_beacons)
- ieee->stop_send_beacons(ieee->dev);
- if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
- ieee80211_beacons_stop(ieee);
-}
-
-
-void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
-{
- if(ieee->start_send_beacons)
- ieee->start_send_beacons(ieee->dev);
- if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
- ieee80211_beacons_start(ieee);
-}
-
-
-void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
-{
-
- down(&ieee->scan_sem);
- ieee->scan_watch_dog = 0;
- if (ieee->scanning == 1){
- ieee->scanning = 0;
-
- cancel_delayed_work(&ieee->softmac_scan_wq);
- }
-
- up(&ieee->scan_sem);
-}
-
-void ieee80211_stop_scan(struct ieee80211_device *ieee)
-{
- if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
- ieee80211_softmac_stop_scan(ieee);
- else
- ieee->stop_scan(ieee->dev);
-}
-
-/* called with ieee->lock held */
-void ieee80211_rtl_start_scan(struct ieee80211_device *ieee)
-{
- if(IS_DOT11D_ENABLE(ieee) )
- {
- if(IS_COUNTRY_IE_VALID(ieee))
- {
- RESET_CIE_WATCHDOG(ieee);
- }
- }
- if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
- if (ieee->scanning == 0){
- ieee->scanning = 1;
- queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
- }
- }else
- ieee->start_scan(ieee->dev);
-
-}
-
-/* called with wx_sem held */
-void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
-{
- if(IS_DOT11D_ENABLE(ieee) )
- {
- if(IS_COUNTRY_IE_VALID(ieee))
- {
- RESET_CIE_WATCHDOG(ieee);
- }
- }
- ieee->sync_scan_hurryup = 0;
- if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
- ieee80211_softmac_scan_syncro(ieee);
- else
- ieee->scan_syncro(ieee->dev);
-
-}
-
-inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
- struct ieee80211_device *ieee, int challengelen)
-{
- struct sk_buff *skb;
- struct ieee80211_authentication *auth;
- int len = sizeof(struct ieee80211_authentication) + challengelen + ieee->tx_headroom;
-
-
- skb = dev_alloc_skb(len);
- if (!skb) return NULL;
-
- skb_reserve(skb, ieee->tx_headroom);
- auth = (struct ieee80211_authentication *)
- skb_put(skb, sizeof(struct ieee80211_authentication));
-
- auth->header.frame_control = IEEE80211_STYPE_AUTH;
- if (challengelen) auth->header.frame_control |= IEEE80211_FCTL_WEP;
-
- auth->header.duration_id = 0x013a; //FIXME
-
- memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
-
- if(ieee->auth_mode == 0)
- auth->algorithm = WLAN_AUTH_OPEN;
- else if(ieee->auth_mode == 1)
- auth->algorithm = WLAN_AUTH_SHARED_KEY;
- else if(ieee->auth_mode == 2)
- auth->algorithm = WLAN_AUTH_OPEN;//0x80;
- printk("=================>%s():auth->algorithm is %d\n",__FUNCTION__,auth->algorithm);
- auth->transaction = cpu_to_le16(ieee->associate_seq);
- ieee->associate_seq++;
-
- auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
-
- return skb;
-
-}
-
-void constructWMMIE(u8* wmmie, u8* wmm_len,u8 oui_subtype)
-{
- u8 szQoSOUI[] ={221, 0, 0x00, 0x50, 0xf2, 0x02, 0, 1};
-
- if (oui_subtype == OUI_SUBTYPE_QOS_CAPABI)
- {
- szQoSOUI[0] = 46;
- szQoSOUI[1] = *wmm_len;
- memcpy(wmmie,szQoSOUI,3);
- *wmm_len = 3;
- }
- else
- {
- szQoSOUI[1] = *wmm_len + 6;
- szQoSOUI[6] = oui_subtype;
- memcpy(wmmie, szQoSOUI, 8);
- *(wmmie+8) = 0;
- *wmm_len = 9;
- }
-}
-
-static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
-{
- u8 *tag;
- int beacon_size;
- struct ieee80211_probe_response *beacon_buf;
- struct sk_buff *skb = NULL;
- int encrypt;
- int atim_len,erp_len;
- struct ieee80211_crypt_data* crypt;
-
- char *ssid = ieee->current_network.ssid;
- int ssid_len = ieee->current_network.ssid_len;
- int rate_len = ieee->current_network.rates_len+2;
- int rate_ex_len = ieee->current_network.rates_ex_len;
- int wpa_ie_len = ieee->wpa_ie_len;
- u8 erpinfo_content = 0;
-
- u8* tmp_ht_cap_buf=NULL;
- u8 tmp_ht_cap_len=0;
- u8* tmp_ht_info_buf=NULL;
- u8 tmp_ht_info_len=0;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- u8* tmp_generic_ie_buf=NULL;
- u8 tmp_generic_ie_len=0;
-
-
- u8 wmmie[9] = {0};
- u8 wmm_len = 0;
-
- if(rate_ex_len > 0) rate_ex_len+=2;
-
- if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
- atim_len = 4;
- else
- atim_len = 0;
-
-#if 0
- if(ieee80211_is_54g(ieee->current_network))
- erp_len = 3;
- else
- erp_len = 0;
-#else
- if((ieee->current_network.mode == IEEE_G)
- ||( ieee->current_network.mode == IEEE_N_24G && ieee->pHTInfo->bCurSuppCCK)) {
- erp_len = 3;
- erpinfo_content = 0;
- if(ieee->current_network.buseprotection)
- erpinfo_content |= ERP_UseProtection;
- }
- else
- erp_len = 0;
-#endif
-
-
- crypt = ieee->crypt[ieee->tx_keyidx];
-
-
- encrypt = ieee->host_encrypt && crypt && crypt->ops &&
- ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
- //HT ralated element
-#if 1
- if(ieee->pHTInfo->bCurrentHTSupport){
- tmp_ht_cap_buf =(u8*) &(ieee->pHTInfo->SelfHTCap);
- tmp_ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
- tmp_ht_info_buf =(u8*) &(ieee->pHTInfo->SelfHTInfo);
- tmp_ht_info_len = sizeof(ieee->pHTInfo->SelfHTInfo);
-
- HTConstructCapabilityElement(ieee, tmp_ht_cap_buf, &tmp_ht_cap_len,encrypt);
-
- HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt);
-
-
- if(pHTInfo->bRegRT2RTAggregation)
- {
- tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
- tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
- HTConstructRT2RTAggElement(ieee, tmp_generic_ie_buf, &tmp_generic_ie_len);
- }
- }
-#endif
-
- if(ieee->qos_support){
-
- if(ieee->iw_mode == IW_MODE_ADHOC)
- {
- wmm_len = 1;
- constructWMMIE(wmmie,&wmm_len,OUI_SUBTYPE_WMM_INFO);
- }
- }
-
- beacon_size = sizeof(struct ieee80211_probe_response)+2+
- ssid_len
- +3 //channel
- +rate_len
- +rate_ex_len
- +atim_len
- +erp_len
- +wpa_ie_len
- // +tmp_ht_cap_len
- // +tmp_ht_info_len
- // +tmp_generic_ie_len
-// +wmm_len+2
- +ieee->tx_headroom;
- skb = dev_alloc_skb(beacon_size);
- if (!skb)
- return NULL;
- skb_reserve(skb, ieee->tx_headroom);
- beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, (beacon_size - ieee->tx_headroom));
- memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
- memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
-
- beacon_buf->header.duration_id = 0; //FIXME
- beacon_buf->beacon_interval =
- cpu_to_le16(ieee->current_network.beacon_interval);
- beacon_buf->capability =
- cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
- beacon_buf->capability |=
- cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE); //add short preamble here
-
- if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
- cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
-
- crypt = ieee->crypt[ieee->tx_keyidx];
-
- if (encrypt)
- beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
-
-
- beacon_buf->header.frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
- beacon_buf->info_element[0].id = MFIE_TYPE_SSID;
- beacon_buf->info_element[0].len = ssid_len;
-
- tag = (u8*) beacon_buf->info_element[0].data;
-
- memcpy(tag, ssid, ssid_len);
-
- tag += ssid_len;
-
- *(tag++) = MFIE_TYPE_RATES;
- *(tag++) = rate_len-2;
- memcpy(tag,ieee->current_network.rates,rate_len-2);
- tag+=rate_len-2;
-
- *(tag++) = MFIE_TYPE_DS_SET;
- *(tag++) = 1;
- *(tag++) = ieee->current_network.channel;
-
- if(atim_len){
- u16 val16;
- *(tag++) = MFIE_TYPE_IBSS_SET;
- *(tag++) = 2;
- val16 = cpu_to_le16(ieee->current_network.atim_window);
- memcpy((u8 *)tag, (u8 *)&val16, 2);
- tag+=2;
- }
-
- if(erp_len){
- *(tag++) = MFIE_TYPE_ERP;
- *(tag++) = 1;
- *(tag++) = erpinfo_content;
- }
-
- if(rate_ex_len){
- *(tag++) = MFIE_TYPE_RATES_EX;
- *(tag++) = rate_ex_len-2;
- memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
- tag+=rate_ex_len-2;
- }
-
- if (wpa_ie_len)
- {
- if (ieee->iw_mode == IW_MODE_ADHOC)
- {//as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07
- memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4);
- }
- memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
- tag += wpa_ie_len;
- }
-
- return skb;
-}
-
-
-struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
-{
- struct sk_buff *skb;
- u8* tag;
-
- struct ieee80211_crypt_data* crypt;
- struct ieee80211_assoc_response_frame *assoc;
- short encrypt;
-
- unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
- int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len + ieee->tx_headroom;
-
- skb = dev_alloc_skb(len);
-
- if (!skb)
- return NULL;
-
- skb_reserve(skb, ieee->tx_headroom);
-
- assoc = (struct ieee80211_assoc_response_frame *)
- skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
-
- assoc->header.frame_control = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
- memcpy(assoc->header.addr1, dest,ETH_ALEN);
- memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
- WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
-
-
- if(ieee->short_slot)
- assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
-
- if (ieee->host_encrypt)
- crypt = ieee->crypt[ieee->tx_keyidx];
- else crypt = NULL;
-
- encrypt = ( crypt && crypt->ops);
-
- if (encrypt)
- assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
-
- assoc->status = 0;
- assoc->aid = cpu_to_le16(ieee->assoc_id);
- if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
- else ieee->assoc_id++;
-
- tag = (u8*) skb_put(skb, rate_len);
-
- ieee80211_MFIE_Brate(ieee, &tag);
- ieee80211_MFIE_Grate(ieee, &tag);
-
- return skb;
-}
-
-struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
-{
- struct sk_buff *skb;
- struct ieee80211_authentication *auth;
- int len = ieee->tx_headroom + sizeof(struct ieee80211_authentication)+1;
-
- skb = dev_alloc_skb(len);
-
- if (!skb)
- return NULL;
-
- skb->len = sizeof(struct ieee80211_authentication);
-
- auth = (struct ieee80211_authentication *)skb->data;
-
- auth->status = cpu_to_le16(status);
- auth->transaction = cpu_to_le16(2);
- auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
-
- memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr1, dest, ETH_ALEN);
- auth->header.frame_control = cpu_to_le16(IEEE80211_STYPE_AUTH);
- return skb;
-
-
-}
-
-struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
-{
- struct sk_buff *skb;
- struct ieee80211_hdr_3addr* hdr;
-
- skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
-
- if (!skb)
- return NULL;
-
- hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
-
- memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
- memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
-
- hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
- IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
- (pwr ? IEEE80211_FCTL_PM:0));
-
- return skb;
-
-
-}
-
-
-void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
-{
- struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
-
- if (buf)
- softmac_mgmt_xmit(buf, ieee);
-}
-
-
-void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
-{
- struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
-
- if (buf)
- softmac_mgmt_xmit(buf, ieee);
-}
-
-
-void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
-{
-
-
- struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
- if (buf)
- softmac_mgmt_xmit(buf, ieee);
-}
-
-
-inline int SecIsInPMKIDList(struct ieee80211_device *ieee, u8 *bssid)
-{
- int i = 0;
-
- do
- {
- if ((ieee->PMKIDList[i].bUsed) && (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0))
- {
- break;
- }
- else
- {
- i++;
- }
- } while (i < NUM_PMKID_CACHE);
-
- if (i == NUM_PMKID_CACHE)
- {
- i = -1;
- }
- else
- {
- }
-
- return (i);
-
-}
-inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
-{
- struct sk_buff *skb;
-
- struct ieee80211_assoc_request_frame *hdr;
- u8 *tag;//,*rsn_ie;
- u8* ht_cap_buf = NULL;
- u8 ht_cap_len=0;
- u8* realtek_ie_buf=NULL;
- u8 realtek_ie_len=0;
- int wpa_ie_len= ieee->wpa_ie_len;
- unsigned int ckip_ie_len=0;
- unsigned int ccxrm_ie_len=0;
- unsigned int cxvernum_ie_len=0;
- struct ieee80211_crypt_data* crypt;
- int encrypt;
- int PMKCacheIdx;
-
- unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
- unsigned int wmm_info_len = beacon->qos_data.supported?9:0;
- unsigned int turbo_info_len = beacon->Turbo_Enable?9:0;
-
- int len = 0;
-
- crypt = ieee->crypt[ieee->tx_keyidx];
- encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len));
-
- //Include High Throuput capability && Realtek proprietary
- if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
- {
- ht_cap_buf = (u8*)&(ieee->pHTInfo->SelfHTCap);
- ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
- HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt);
- if(ieee->pHTInfo->bCurrentRT2RTAggregation)
- {
- realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
- realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer);
- HTConstructRT2RTAggElement(ieee, realtek_ie_buf, &realtek_ie_len);
-
- }
- }
- if(ieee->qos_support){
- wmm_info_len = beacon->qos_data.supported?9:0;
- }
-
-
- if(beacon->bCkipSupported)
- {
- ckip_ie_len = 30+2;
- }
- if(beacon->bCcxRmEnable)
- {
- ccxrm_ie_len = 6+2;
- }
- if( beacon->BssCcxVerNumber >= 2 )
- {
- cxvernum_ie_len = 5+2;
- }
-
- PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid);
- if (PMKCacheIdx >= 0)
- {
- wpa_ie_len += 18;
- printk("[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len);
- }
-
- len = sizeof(struct ieee80211_assoc_request_frame)+ 2
- + beacon->ssid_len//essid tagged val
- + rate_len//rates tagged val
- + wpa_ie_len
- + wmm_info_len
- + turbo_info_len
- + ht_cap_len
- + realtek_ie_len
- + ckip_ie_len
- + ccxrm_ie_len
- + cxvernum_ie_len
- + ieee->tx_headroom;
-
- skb = dev_alloc_skb(len);
-
- if (!skb)
- return NULL;
-
- skb_reserve(skb, ieee->tx_headroom);
-
- hdr = (struct ieee80211_assoc_request_frame *)
- skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)+2);
-
-
- hdr->header.frame_control = IEEE80211_STYPE_ASSOC_REQ;
- hdr->header.duration_id= 37; //FIXME
- memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
-
- memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);//for HW security, John
-
- hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
- if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
- hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
-
- if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
- hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); //add short_preamble here
-
- if(ieee->short_slot)
- hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
- if (wmm_info_len) //QOS
- hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS);
-
- hdr->listen_interval = 0xa; //FIXME
-
- hdr->info_element[0].id = MFIE_TYPE_SSID;
-
- hdr->info_element[0].len = beacon->ssid_len;
- tag = skb_put(skb, beacon->ssid_len);
- memcpy(tag, beacon->ssid, beacon->ssid_len);
-
- tag = skb_put(skb, rate_len);
-
- ieee80211_MFIE_Brate(ieee, &tag);
- ieee80211_MFIE_Grate(ieee, &tag);
- // For CCX 1 S13, CKIP. Added by Annie, 2006-08-14.
- if( beacon->bCkipSupported )
- {
- static u8 AironetIeOui[] = {0x00, 0x01, 0x66}; // "4500-client"
- u8 CcxAironetBuf[30];
- OCTET_STRING osCcxAironetIE;
-
- memset(CcxAironetBuf, 0,30);
- osCcxAironetIE.Octet = CcxAironetBuf;
- osCcxAironetIE.Length = sizeof(CcxAironetBuf);
- //
- // Ref. CCX test plan v3.61, 3.2.3.1 step 13.
- // We want to make the device type as "4500-client". 060926, by CCW.
- //
- memcpy(osCcxAironetIE.Octet, AironetIeOui, sizeof(AironetIeOui));
-
- // CCX1 spec V1.13, A01.1 CKIP Negotiation (page23):
- // "The CKIP negotiation is started with the associate request from the client to the access point,
- // containing an Aironet element with both the MIC and KP bits set."
- osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= (SUPPORT_CKIP_PK|SUPPORT_CKIP_MIC) ;
- tag = skb_put(skb, ckip_ie_len);
- *tag++ = MFIE_TYPE_AIRONET;
- *tag++ = osCcxAironetIE.Length;
- memcpy(tag,osCcxAironetIE.Octet,osCcxAironetIE.Length);
- tag += osCcxAironetIE.Length;
- }
-
- if(beacon->bCcxRmEnable)
- {
- static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
- OCTET_STRING osCcxRmCap;
-
- osCcxRmCap.Octet = CcxRmCapBuf;
- osCcxRmCap.Length = sizeof(CcxRmCapBuf);
- tag = skb_put(skb,ccxrm_ie_len);
- *tag++ = MFIE_TYPE_GENERIC;
- *tag++ = osCcxRmCap.Length;
- memcpy(tag,osCcxRmCap.Octet,osCcxRmCap.Length);
- tag += osCcxRmCap.Length;
- }
-
- if( beacon->BssCcxVerNumber >= 2 )
- {
- u8 CcxVerNumBuf[] = {0x00, 0x40, 0x96, 0x03, 0x00};
- OCTET_STRING osCcxVerNum;
- CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
- osCcxVerNum.Octet = CcxVerNumBuf;
- osCcxVerNum.Length = sizeof(CcxVerNumBuf);
- tag = skb_put(skb,cxvernum_ie_len);
- *tag++ = MFIE_TYPE_GENERIC;
- *tag++ = osCcxVerNum.Length;
- memcpy(tag,osCcxVerNum.Octet,osCcxVerNum.Length);
- tag += osCcxVerNum.Length;
- }
- //HT cap element
- if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
- if(ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC)
- {
- tag = skb_put(skb, ht_cap_len);
- *tag++ = MFIE_TYPE_HT_CAP;
- *tag++ = ht_cap_len - 2;
- memcpy(tag, ht_cap_buf,ht_cap_len -2);
- tag += ht_cap_len -2;
- }
- }
-
-
- //choose what wpa_supplicant gives to associate.
- tag = skb_put(skb, wpa_ie_len);
- if (wpa_ie_len){
- memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
- if (PMKCacheIdx >= 0)
- {
- tag = skb_put(skb, 18);
- *tag = 1;
- *(tag + 1) = 0;
- memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, 16);
- }
- }
-
- tag = skb_put(skb,wmm_info_len);
- if(wmm_info_len) {
- ieee80211_WMM_Info(ieee, &tag);
- }
- tag = skb_put(skb,turbo_info_len);
- if(turbo_info_len) {
- ieee80211_TURBO_Info(ieee, &tag);
- }
-
- if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
- if(ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC)
- {
- tag = skb_put(skb, ht_cap_len);
- *tag++ = MFIE_TYPE_GENERIC;
- *tag++ = ht_cap_len - 2;
- memcpy(tag, ht_cap_buf,ht_cap_len - 2);
- tag += ht_cap_len -2;
- }
-
- if(ieee->pHTInfo->bCurrentRT2RTAggregation){
- tag = skb_put(skb, realtek_ie_len);
- *tag++ = MFIE_TYPE_GENERIC;
- *tag++ = realtek_ie_len - 2;
- memcpy(tag, realtek_ie_buf,realtek_ie_len -2 );
- }
- }
- return skb;
-}
-
-void ieee80211_associate_abort(struct ieee80211_device *ieee)
-{
-
- unsigned long flags;
- spin_lock_irqsave(&ieee->lock, flags);
-
- ieee->associate_seq++;
-
- /* don't scan, and avoid to have the RX path possibily
- * try again to associate. Even do not react to AUTH or
- * ASSOC response. Just wait for the retry wq to be scheduled.
- * Here we will check if there are good nets to associate
- * with, so we retry or just get back to NO_LINK and scanning
- */
- if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
- IEEE80211_DEBUG_MGMT("Authentication failed\n");
- ieee->softmac_stats.no_auth_rs++;
- }else{
- IEEE80211_DEBUG_MGMT("Association failed\n");
- ieee->softmac_stats.no_ass_rs++;
- }
-
- ieee->state = IEEE80211_ASSOCIATING_RETRY;
-
- queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, \
- IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
-
- spin_unlock_irqrestore(&ieee->lock, flags);
-}
-
-void ieee80211_associate_abort_cb(unsigned long dev)
-{
- ieee80211_associate_abort((struct ieee80211_device *) dev);
-}
-
-
-void ieee80211_associate_step1(struct ieee80211_device *ieee)
-{
- struct ieee80211_network *beacon = &ieee->current_network;
- struct sk_buff *skb;
-
- IEEE80211_DEBUG_MGMT("Stopping scan\n");
-
- ieee->softmac_stats.tx_auth_rq++;
- skb=ieee80211_authentication_req(beacon, ieee, 0);
-
- if (!skb)
- ieee80211_associate_abort(ieee);
- else{
- ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
- IEEE80211_DEBUG_MGMT("Sending authentication request\n");
- softmac_mgmt_xmit(skb, ieee);
- //BUGON when you try to add_timer twice, using mod_timer may be better, john0709
- if(!timer_pending(&ieee->associate_timer)){
- ieee->associate_timer.expires = jiffies + (HZ / 2);
- add_timer(&ieee->associate_timer);
- }
- //dev_kfree_skb_any(skb);//edit by thomas
- }
-}
-
-void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
-{
- u8 *c;
- struct sk_buff *skb;
- struct ieee80211_network *beacon = &ieee->current_network;
-
- ieee->associate_seq++;
- ieee->softmac_stats.tx_auth_rq++;
-
- skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
- if (!skb)
- ieee80211_associate_abort(ieee);
- else{
- c = skb_put(skb, chlen+2);
- *(c++) = MFIE_TYPE_CHALLENGE;
- *(c++) = chlen;
- memcpy(c, challenge, chlen);
-
- IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
-
- ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
-
- softmac_mgmt_xmit(skb, ieee);
- mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
- }
- kfree(challenge);
-}
-
-void ieee80211_associate_step2(struct ieee80211_device *ieee)
-{
- struct sk_buff* skb;
- struct ieee80211_network *beacon = &ieee->current_network;
-
- del_timer_sync(&ieee->associate_timer);
-
- IEEE80211_DEBUG_MGMT("Sending association request\n");
-
- ieee->softmac_stats.tx_ass_rq++;
- skb=ieee80211_association_req(beacon, ieee);
- if (!skb)
- ieee80211_associate_abort(ieee);
- else{
- softmac_mgmt_xmit(skb, ieee);
- mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
- }
-}
-
-void ieee80211_associate_complete_wq(struct work_struct *work)
-{
- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
-
- printk(KERN_INFO "Associated successfully\n");
- ieee->is_roaming = false;
- if(ieee80211_is_54g(ieee->current_network) &&
- (ieee->modulation & IEEE80211_OFDM_MODULATION)){
-
- ieee->rate = 108;
- printk(KERN_INFO"Using G rates:%d\n", ieee->rate);
- }else{
- ieee->rate = 22;
- printk(KERN_INFO"Using B rates:%d\n", ieee->rate);
- }
- if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
- {
- printk("Successfully associated, ht enabled\n");
- HTOnAssocRsp(ieee);
- }
- else
- {
- printk("Successfully associated, ht not enabled(%d, %d)\n", ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bEnableHT);
- memset(ieee->dot11HTOperationalRateSet, 0, 16);
- }
- ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500);
- // To prevent the immediately calling watch_dog after association.
- if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
- {
- ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
- ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
- }
- ieee->link_change(ieee->dev);
- if(ieee->is_silent_reset == 0){
- printk("============>normal associate\n");
- notify_wx_assoc_event(ieee);
- }
- else if(ieee->is_silent_reset == 1)
- {
- printk("==================>silent reset associate\n");
- ieee->is_silent_reset = 0;
- }
-
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
- netif_carrier_on(ieee->dev);
-}
-
-void ieee80211_associate_complete(struct ieee80211_device *ieee)
-{
-// int i;
-// struct net_device* dev = ieee->dev;
- del_timer_sync(&ieee->associate_timer);
-
- ieee->state = IEEE80211_LINKED;
- queue_work(ieee->wq, &ieee->associate_complete_wq);
-}
-
-void ieee80211_associate_procedure_wq(struct work_struct *work)
-{
- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
-
- ieee->sync_scan_hurryup = 1;
- down(&ieee->wx_sem);
-
- if (ieee->data_hard_stop)
- ieee->data_hard_stop(ieee->dev);
-
- ieee80211_stop_scan(ieee);
- printk("===>%s(), chan:%d\n", __FUNCTION__, ieee->current_network.channel);
- HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
-
- if(ieee->eRFPowerState == eRfOff)
- {
- printk("=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",__FUNCTION__);
- up(&ieee->wx_sem);
- return;
- }
- ieee->associate_seq = 1;
- ieee80211_associate_step1(ieee);
-
- up(&ieee->wx_sem);
-}
-
-inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
-{
- u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
- int tmp_ssid_len = 0;
-
- short apset,ssidset,ssidbroad,apmatch,ssidmatch;
-
- /* we are interested in new new only if we are not associated
- * and we are not associating / authenticating
- */
- if (ieee->state != IEEE80211_NOLINK)
- return;
-
- if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
- return;
-
- if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
- return;
-
- if ((ieee->iw_mode == IW_MODE_ADHOC) && (net->channel > ieee->ibss_maxjoin_chal))
- return;
-
- if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
- /* if the user specified the AP MAC, we need also the essid
- * This could be obtained by beacons or, if the network does not
- * broadcast it, it can be put manually.
- */
- apset = ieee->wap_set;
- ssidset = ieee->ssid_set;
- ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
- apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
- ssidmatch = (ieee->current_network.ssid_len == net->ssid_len)&&\
- (!strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
-
-
- if ( /* if the user set the AP check if match.
- * if the network does not broadcast essid we check the user supplyed ANY essid
- * if the network does broadcast and the user does not set essid it is OK
- * if the network does broadcast and the user did set essid chech if essid match
- */
- ( apset && apmatch &&
- ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
- /* if the ap is not set, check that the user set the bssid
- * and the network does bradcast and that those two bssid matches
- */
- (!apset && ssidset && ssidbroad && ssidmatch)
- ){
- /* if the essid is hidden replace it with the
- * essid provided by the user.
- */
- if (!ssidbroad){
- strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
- tmp_ssid_len = ieee->current_network.ssid_len;
- }
- memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
-
- if (!ssidbroad){
- strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
- ieee->current_network.ssid_len = tmp_ssid_len;
- }
- printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT, ieee->current_network.mode);
-
- //ieee->pHTInfo->IOTAction = 0;
- HTResetIOTSetting(ieee->pHTInfo);
- if (ieee->iw_mode == IW_MODE_INFRA){
- /* Join the network for the first time */
- ieee->AsocRetryCount = 0;
- //for HT by amy 080514
- if((ieee->current_network.qos_data.supported == 1) &&
- ieee->current_network.bssht.bdSupportHT)
-/*WB, 2008.09.09:bCurrentHTSupport and bEnableHT two flags are going to put together to check whether we are in HT now, so needn't to check bEnableHT flags here. That's is to say we will set to HT support whenever joined AP has the ability to support HT. And whether we are in HT or not, please check bCurrentHTSupport&&bEnableHT now please.*/
- {
- // ieee->pHTInfo->bCurrentHTSupport = true;
- HTResetSelfAndSavePeerSetting(ieee, &(ieee->current_network));
- }
- else
- {
- ieee->pHTInfo->bCurrentHTSupport = false;
- }
-
- ieee->state = IEEE80211_ASSOCIATING;
- if(ieee->LedControlHandler != NULL)
- ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK);
- queue_work(ieee->wq, &ieee->associate_procedure_wq);
- }else{
- if(ieee80211_is_54g(ieee->current_network) &&
- (ieee->modulation & IEEE80211_OFDM_MODULATION)){
- ieee->rate = 108;
- ieee->SetWirelessMode(ieee->dev, IEEE_G);
- printk(KERN_INFO"Using G rates\n");
- }else{
- ieee->rate = 22;
- ieee->SetWirelessMode(ieee->dev, IEEE_B);
- printk(KERN_INFO"Using B rates\n");
- }
- memset(ieee->dot11HTOperationalRateSet, 0, 16);
- ieee->state = IEEE80211_LINKED;
- }
-
- }
- }
-
-}
-
-void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
-{
- unsigned long flags;
- struct ieee80211_network *target;
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- list_for_each_entry(target, &ieee->network_list, list) {
-
- /* if the state become different that NOLINK means
- * we had found what we are searching for
- */
-
- if (ieee->state != IEEE80211_NOLINK)
- break;
-
- if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
- ieee80211_softmac_new_net(ieee, target);
- }
-
- spin_unlock_irqrestore(&ieee->lock, flags);
-
-}
-
-
-static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
-{
- struct ieee80211_authentication *a;
- u8 *t;
- if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
- IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
- return 0xcafe;
- }
- *challenge = NULL;
- a = (struct ieee80211_authentication*) skb->data;
- if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
- t = skb->data + sizeof(struct ieee80211_authentication);
-
- if(*(t++) == MFIE_TYPE_CHALLENGE){
- *chlen = *(t++);
- *challenge = kmalloc(*chlen, GFP_ATOMIC);
- memcpy(*challenge, t, *chlen);
- }
- }
-
- return cpu_to_le16(a->status);
-
-}
-
-
-int auth_rq_parse(struct sk_buff *skb,u8* dest)
-{
- struct ieee80211_authentication *a;
-
- if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
- IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
- return -1;
- }
- a = (struct ieee80211_authentication*) skb->data;
-
- memcpy(dest,a->header.addr2, ETH_ALEN);
-
- if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
- return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
-
- return WLAN_STATUS_SUCCESS;
-}
-
-static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
-{
- u8 *tag;
- u8 *skbend;
- u8 *ssid=NULL;
- u8 ssidlen = 0;
-
- struct ieee80211_hdr_3addr *header =
- (struct ieee80211_hdr_3addr *) skb->data;
-
- if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
- return -1; /* corrupted */
-
- if((memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) != 0)&&
- (memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) != 0)) {
- return -1;
- }
-
- if(memcmp(header->addr3,ieee->current_network.bssid,ETH_ALEN) == 0) {
- }
-
- if(memcmp(header->addr3,"\xff\xff\xff\xff\xff\xff",ETH_ALEN) == 0) {
- }
- memcpy(src,header->addr2, ETH_ALEN);
-
- skbend = (u8*)skb->data + skb->len;
-
- tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
-
- while (tag+1 < skbend){
- if (*tag == 0){
- ssid = tag+2;
- ssidlen = *(tag+1);
- break;
- }
- tag++; /* point to the len field */
- tag = tag + *(tag); /* point to the last data byte of the tag */
- tag++; /* point to the next tag */
- }
-
- if (ssidlen == 0) return 1;
-
- if (!ssid) return 1; /* ssid not found in tagged param */
- return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
-
-}
-
-int assoc_rq_parse(struct sk_buff *skb,u8* dest)
-{
- struct ieee80211_assoc_request_frame *a;
-
- if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
- sizeof(struct ieee80211_info_element))) {
-
- IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
- return -1;
- }
-
- a = (struct ieee80211_assoc_request_frame*) skb->data;
-
- memcpy(dest,a->header.addr2,ETH_ALEN);
-
- return 0;
-}
-
-static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb, int *aid)
-{
- struct ieee80211_assoc_response_frame *response_head;
- u16 status_code;
-
- if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
- IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
- return 0xcafe;
- }
-
- response_head = (struct ieee80211_assoc_response_frame*) skb->data;
- *aid = le16_to_cpu(response_head->aid) & 0x3fff;
-
- status_code = le16_to_cpu(response_head->status);
- if((status_code==WLAN_STATUS_ASSOC_DENIED_RATES || \
- status_code==WLAN_STATUS_CAPS_UNSUPPORTED)&&
- ((ieee->mode == IEEE_G) &&
- (ieee->current_network.mode == IEEE_N_24G) &&
- (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT-1)))) {
- ieee->pHTInfo->IOTAction |= HT_IOT_ACT_PURE_N_MODE;
- }else {
- ieee->AsocRetryCount = 0;
- }
-
- return le16_to_cpu(response_head->status);
-}
-
-static inline void
-ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
-{
- u8 dest[ETH_ALEN];
-
- ieee->softmac_stats.rx_probe_rq++;
- if (probe_rq_parse(ieee, skb, dest)){
- ieee->softmac_stats.tx_probe_rs++;
- ieee80211_resp_to_probe(ieee, dest);
- }
-}
-
-static inline void
-ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
-{
- u8 dest[ETH_ALEN];
- int status;
- ieee->softmac_stats.rx_auth_rq++;
-
- status = auth_rq_parse(skb, dest);
- if (status != -1) {
- ieee80211_resp_to_auth(ieee, status, dest);
- }
-
-}
-
-static inline void
-ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
-{
-
- u8 dest[ETH_ALEN];
-
- ieee->softmac_stats.rx_ass_rq++;
- if (assoc_rq_parse(skb,dest) != -1){
- ieee80211_resp_to_assoc_rq(ieee, dest);
- }
-
- printk(KERN_INFO"New client associated: %pM\n", dest);
- //FIXME
-}
-
-
-
-void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
-{
-
- struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
-
- if (buf)
- softmac_ps_mgmt_xmit(buf, ieee);
-
-}
-
-
-short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
-{
- int timeout = ieee->ps_timeout;
- u8 dtim;
- /*if(ieee->ps == IEEE80211_PS_DISABLED ||
- ieee->iw_mode != IW_MODE_INFRA ||
- ieee->state != IEEE80211_LINKED)
-
- return 0;
- */
- dtim = ieee->current_network.dtim_data;
- if(!(dtim & IEEE80211_DTIM_VALID))
- return 0;
- timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval
- //printk("VALID\n");
- ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
-
- if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
- return 2;
-
- if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
- return 0;
-
- if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
- return 0;
-
- if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
- (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
- return 0;
-
- if(time_l){
- *time_l = ieee->current_network.last_dtim_sta_time[0]
- + (ieee->current_network.beacon_interval);
- }
-
- if(time_h){
- *time_h = ieee->current_network.last_dtim_sta_time[1];
- if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
- *time_h += 1;
- }
-
- return 1;
-
-
-}
-
-inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
-{
-
- u32 th,tl;
- short sleep;
-
- unsigned long flags,flags2;
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- if((ieee->ps == IEEE80211_PS_DISABLED ||
- ieee->iw_mode != IW_MODE_INFRA ||
- ieee->state != IEEE80211_LINKED)){
-
- spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
-
- ieee80211_sta_wakeup(ieee, 1);
-
- spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
- }
-
- sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
- /* 2 wake, 1 sleep, 0 do nothing */
- if(sleep == 0)
- goto out;
-
- if(sleep == 1){
-
- if(ieee->sta_sleep == 1)
- ieee->enter_sleep_state(ieee->dev,th,tl);
-
- else if(ieee->sta_sleep == 0){
- spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
-
- if(ieee->ps_is_queue_empty(ieee->dev)){
-
-
- ieee->sta_sleep = 2;
-
- ieee->ack_tx_to_ieee = 1;
-
- ieee80211_sta_ps_send_null_frame(ieee,1);
-
- ieee->ps_th = th;
- ieee->ps_tl = tl;
- }
- spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
-
- }
-
-
- }else if(sleep == 2){
-//#warning CHECK_LOCK_HERE
- spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
-
- ieee80211_sta_wakeup(ieee,1);
-
- spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
- }
-
-out:
- spin_unlock_irqrestore(&ieee->lock, flags);
-
-}
-
-void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
-{
- if(ieee->sta_sleep == 0){
- if(nl){
- printk("Warning: driver is probably failing to report TX ps error\n");
- ieee->ack_tx_to_ieee = 1;
- ieee80211_sta_ps_send_null_frame(ieee, 0);
- }
- return;
-
- }
-
- if(ieee->sta_sleep == 1)
- ieee->sta_wake_up(ieee->dev);
-
- ieee->sta_sleep = 0;
-
- if(nl){
- ieee->ack_tx_to_ieee = 1;
- ieee80211_sta_ps_send_null_frame(ieee, 0);
- }
-}
-
-void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
-{
- unsigned long flags,flags2;
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- if(ieee->sta_sleep == 2){
- /* Null frame with PS bit set */
- if(success){
- ieee->sta_sleep = 1;
- ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl);
- }
- /* if the card report not success we can't be sure the AP
- * has not RXed so we can't assume the AP believe us awake
- */
- }
- /* 21112005 - tx again null without PS bit if lost */
- else {
-
- if((ieee->sta_sleep == 0) && !success){
- spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
- ieee80211_sta_ps_send_null_frame(ieee, 0);
- spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
- }
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-}
-void ieee80211_process_action(struct ieee80211_device* ieee, struct sk_buff* skb)
-{
- struct rtl_ieee80211_hdr *header =
- (struct rtl_ieee80211_hdr *)skb->data;
- u8* act = ieee80211_get_payload(header);
- u8 tmp = 0;
-// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- if (act == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n");
- return;
- }
- tmp = *act;
- act ++;
- switch (tmp)
- {
- case ACT_CAT_BA:
- if (*act == ACT_ADDBAREQ)
- ieee80211_rx_ADDBAReq(ieee, skb);
- else if (*act == ACT_ADDBARSP)
- ieee80211_rx_ADDBARsp(ieee, skb);
- else if (*act == ACT_DELBA)
- ieee80211_rx_DELBA(ieee, skb);
- break;
- default:
- break;
- }
- return;
-
-}
-inline int
-ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
- struct ieee80211_rx_stats *rx_stats, u16 type,
- u16 stype)
-{
- struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data;
- u16 errcode;
- u8* challenge;
- int chlen=0;
- int aid;
- struct ieee80211_assoc_response_frame *assoc_resp;
- bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode
-
- if(!ieee->proto_started)
- return 0;
-
- switch (WLAN_FC_GET_STYPE(header->frame_control)) {
-
- case IEEE80211_STYPE_ASSOC_RESP:
- case IEEE80211_STYPE_REASSOC_RESP:
-
- IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
- WLAN_FC_GET_STYPE(header->frame_control));
- if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
- ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
- ieee->iw_mode == IW_MODE_INFRA){
- struct ieee80211_network network_resp;
- struct ieee80211_network *network = &network_resp;
-
- if (0 == (errcode=assoc_parse(ieee,skb, &aid))){
- ieee->state=IEEE80211_LINKED;
- ieee->assoc_id = aid;
- ieee->softmac_stats.rx_ass_ok++;
- /* station support qos */
- /* Let the register setting defaultly with Legacy station */
- if(ieee->qos_support) {
- assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data;
- memset(network, 0, sizeof(*network));
- if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\
- rx_stats->len - sizeof(*assoc_resp),\
- network,rx_stats)){
- return 1;
- }
- else
- { //filling the PeerHTCap. //maybe not neccesary as we can get its info from current_network.
- memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen);
- memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen);
- }
- if (ieee->handle_assoc_response != NULL)
- ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network);
- }
- ieee80211_associate_complete(ieee);
- } else {
- /* aid could not been allocated */
- ieee->softmac_stats.rx_ass_err++;
- printk(
- "Association response status code 0x%x\n",
- errcode);
- IEEE80211_DEBUG_MGMT(
- "Association response status code 0x%x\n",
- errcode);
- if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) {
- queue_work(ieee->wq, &ieee->associate_procedure_wq);
- } else {
- ieee80211_associate_abort(ieee);
- }
- }
- }
- break;
-
- case IEEE80211_STYPE_ASSOC_REQ:
- case IEEE80211_STYPE_REASSOC_REQ:
-
- if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
- ieee->iw_mode == IW_MODE_MASTER)
-
- ieee80211_rx_assoc_rq(ieee, skb);
- break;
-
- case IEEE80211_STYPE_AUTH:
-
- if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
- if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
- ieee->iw_mode == IW_MODE_INFRA){
-
- IEEE80211_DEBUG_MGMT("Received authentication response");
-
- if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
- if(ieee->open_wep || !challenge){
- ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
- ieee->softmac_stats.rx_auth_rs_ok++;
- if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE))
- {
- if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
- {
- // WEP or TKIP encryption
- if(IsHTHalfNmodeAPs(ieee))
- {
- bSupportNmode = true;
- bHalfSupportNmode = true;
- }
- else
- {
- bSupportNmode = false;
- bHalfSupportNmode = false;
- }
- printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode);
- }
- }
- /* Dummy wirless mode setting to avoid encryption issue */
- if(bSupportNmode) {
- //N mode setting
- ieee->SetWirelessMode(ieee->dev, \
- ieee->current_network.mode);
- }else{
- //b/g mode setting
- /*TODO*/
- ieee->SetWirelessMode(ieee->dev, IEEE_G);
- }
-
- if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true)
- {
- printk("===============>entern half N mode\n");
- ieee->bHalfWirelessN24GMode = true;
- }
- else
- ieee->bHalfWirelessN24GMode = false;
-
- ieee80211_associate_step2(ieee);
- }else{
- ieee80211_rtl_auth_challenge(ieee, challenge, chlen);
- }
- }else{
- ieee->softmac_stats.rx_auth_rs_err++;
- IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
-
- printk("Authentication respose status code 0x%x",errcode);
- ieee80211_associate_abort(ieee);
- }
-
- }else if (ieee->iw_mode == IW_MODE_MASTER){
- ieee80211_rx_auth_rq(ieee, skb);
- }
- }
- break;
-
- case IEEE80211_STYPE_PROBE_REQ:
-
- if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
- ((ieee->iw_mode == IW_MODE_ADHOC ||
- ieee->iw_mode == IW_MODE_MASTER) &&
- ieee->state == IEEE80211_LINKED)){
- ieee80211_rx_probe_rq(ieee, skb);
- }
- break;
-
- case IEEE80211_STYPE_DISASSOC:
- case IEEE80211_STYPE_DEAUTH:
- /* FIXME for now repeat all the association procedure
- * both for disassociation and deauthentication
- */
- if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
- ieee->state == IEEE80211_LINKED &&
- ieee->iw_mode == IW_MODE_INFRA){
- printk("==========>received disassoc/deauth(%x) frame, reason code:%x\n",WLAN_FC_GET_STYPE(header->frame_control), ((struct ieee80211_disassoc*)skb->data)->reason);
- ieee->state = IEEE80211_ASSOCIATING;
- ieee->softmac_stats.reassoc++;
- ieee->is_roaming = true;
- ieee80211_disassociate(ieee);
- RemovePeerTS(ieee, header->addr2);
- if(ieee->LedControlHandler != NULL)
- ieee->LedControlHandler(ieee->dev, LED_CTL_START_TO_LINK); //added by amy for LED 090318
- queue_work(ieee->wq, &ieee->associate_procedure_wq);
- }
- break;
- case IEEE80211_STYPE_MANAGE_ACT:
- ieee80211_process_action(ieee,skb);
- break;
- default:
- return -1;
- break;
- }
-
- return 0;
-}
-
-/* following are for a simplier TX queue management.
- * Instead of using netif_[stop/wake]_queue the driver
- * will uses these two function (plus a reset one), that
- * will internally uses the kernel netif_* and takes
- * care of the ieee802.11 fragmentation.
- * So the driver receives a fragment per time and might
- * call the stop function when it want without take care
- * to have enough room to TX an entire packet.
- * This might be useful if each fragment need it's own
- * descriptor, thus just keep a total free memory > than
- * the max fragmentation threshold is not enough.. If the
- * ieee802.11 stack passed a TXB struct then you needed
- * to keep N free descriptors where
- * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
- * In this way you need just one and the 802.11 stack
- * will take care of buffering fragments and pass them to
- * to the driver later, when it wakes the queue.
- */
-void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
-{
-
- unsigned int queue_index = txb->queue_index;
- unsigned long flags;
- int i;
- cb_desc *tcb_desc = NULL;
-
- spin_lock_irqsave(&ieee->lock,flags);
-
- /* called with 2nd parm 0, no tx mgmt lock required */
- ieee80211_sta_wakeup(ieee,0);
-
- /* update the tx status */
- ieee->stats.tx_bytes += txb->payload_size;
- ieee->stats.tx_packets++;
- tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
- if(tcb_desc->bMulticast) {
- ieee->stats.multicast++;
- }
-#if 1
- /* if xmit available, just xmit it immediately, else just insert it to the wait queue */
- for(i = 0; i < txb->nr_frags; i++) {
- if ((skb_queue_len(&ieee->skb_waitQ[queue_index]) != 0) ||
- (!ieee->check_nic_enough_desc(ieee->dev,queue_index))||\
- (ieee->queue_stop)) {
- /* insert the skb packet to the wait queue */
- /* as for the completion function, it does not need
- * to check it any more.
- * */
- skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]);
- }else{
- ieee->softmac_data_hard_start_xmit(
- txb->fragments[i],
- ieee->dev,ieee->rate);
- }
- }
-#endif
- ieee80211_txb_free(txb);
-
- spin_unlock_irqrestore(&ieee->lock,flags);
-
-}
-
-/* called with ieee->lock acquired */
-void ieee80211_resume_tx(struct ieee80211_device *ieee)
-{
- int i;
- for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
-
- if (ieee->queue_stop){
- ieee->tx_pending.frag = i;
- return;
- }else{
-
- ieee->softmac_data_hard_start_xmit(
- ieee->tx_pending.txb->fragments[i],
- ieee->dev,ieee->rate);
- ieee->stats.tx_packets++;
- }
- }
-
-
- ieee80211_txb_free(ieee->tx_pending.txb);
- ieee->tx_pending.txb = NULL;
-}
-
-
-void ieee80211_reset_queue(struct ieee80211_device *ieee)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&ieee->lock,flags);
- init_mgmt_queue(ieee);
- if (ieee->tx_pending.txb){
- ieee80211_txb_free(ieee->tx_pending.txb);
- ieee->tx_pending.txb = NULL;
- }
- ieee->queue_stop = 0;
- spin_unlock_irqrestore(&ieee->lock,flags);
-
-}
-
-void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee)
-{
-
- unsigned long flags;
- struct sk_buff *skb;
- struct ieee80211_hdr_3addr *header;
-
- spin_lock_irqsave(&ieee->lock,flags);
- if (! ieee->queue_stop) goto exit;
-
- ieee->queue_stop = 0;
-
- if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
- while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
-
- header = (struct ieee80211_hdr_3addr *) skb->data;
-
- header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
- }
- }
- if (!ieee->queue_stop && ieee->tx_pending.txb)
- ieee80211_resume_tx(ieee);
-
- if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
- ieee->softmac_stats.swtxawake++;
- netif_wake_queue(ieee->dev);
- }
-
-exit :
- spin_unlock_irqrestore(&ieee->lock,flags);
-}
-
-
-void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
-{
-
- if (! netif_queue_stopped(ieee->dev)){
- netif_stop_queue(ieee->dev);
- ieee->softmac_stats.swtxstop++;
- }
- ieee->queue_stop = 1;
-
-}
-
-
-inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
-{
-
- get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
-
- /* an IBSS cell address must have the two less significant
- * bits of the first byte = 2
- */
- ieee->current_network.bssid[0] &= ~0x01;
- ieee->current_network.bssid[0] |= 0x02;
-}
-
-/* called in user context only */
-void ieee80211_start_master_bss(struct ieee80211_device *ieee)
-{
- ieee->assoc_id = 1;
-
- if (ieee->current_network.ssid_len == 0){
- strncpy(ieee->current_network.ssid,
- IEEE80211_DEFAULT_TX_ESSID,
- IW_ESSID_MAX_SIZE);
-
- ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
- ieee->ssid_set = 1;
- }
-
- memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
-
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- ieee->state = IEEE80211_LINKED;
- ieee->link_change(ieee->dev);
- notify_wx_assoc_event(ieee);
-
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
-
- netif_carrier_on(ieee->dev);
-}
-
-void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
-{
- if(ieee->raw_tx){
-
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
-
- netif_carrier_on(ieee->dev);
- }
-}
-
-void ieee80211_start_ibss_wq(struct work_struct *work)
-{
-
- struct delayed_work *dwork = container_of(work, struct delayed_work, work);
- struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);
- /* iwconfig mode ad-hoc will schedule this and return
- * on the other hand this will block further iwconfig SET
- * operations because of the wx_sem hold.
- * Anyway some most set operations set a flag to speed-up
- * (abort) this wq (when syncro scanning) before sleeping
- * on the semaphore
- */
- if(!ieee->proto_started){
- printk("==========oh driver down return\n");
- return;
- }
- down(&ieee->wx_sem);
- //FIXME:set back to 20M whenever HT for ibss is not ready. Otherwise,after being connected to 40M AP, it will still stay in 40M when set to ibss mode. WB 2009.02.04
- HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
-
- if (ieee->current_network.ssid_len == 0){
- strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
- ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
- ieee->ssid_set = 1;
- }
-
- /* check if we have this cell in our network list */
- ieee80211_softmac_check_all_nets(ieee);
-
-
-// if((IS_DOT11D_ENABLE(ieee)) && (ieee->state == IEEE80211_NOLINK))
- if (ieee->state == IEEE80211_NOLINK)
- ieee->current_network.channel = ieee->IbssStartChnl;
- /* if not then the state is not linked. Maybe the user swithced to
- * ad-hoc mode just after being in monitor mode, or just after
- * being very few time in managed mode (so the card have had no
- * time to scan all the chans..) or we have just run up the iface
- * after setting ad-hoc mode. So we have to give another try..
- * Here, in ibss mode, should be safe to do this without extra care
- * (in bss mode we had to make sure no-one tryed to associate when
- * we had just checked the ieee->state and we was going to start the
- * scan) beacause in ibss mode the ieee80211_new_net function, when
- * finds a good net, just set the ieee->state to IEEE80211_LINKED,
- * so, at worst, we waste a bit of time to initiate an unneeded syncro
- * scan, that will stop at the first round because it sees the state
- * associated.
- */
- if (ieee->state == IEEE80211_NOLINK)
- ieee80211_start_scan_syncro(ieee);
-
- /* the network definitively is not here.. create a new cell */
- if (ieee->state == IEEE80211_NOLINK){
- printk("creating new IBSS cell\n");
- if(!ieee->wap_set)
- ieee80211_randomize_cell(ieee);
-
- if(ieee->modulation & IEEE80211_CCK_MODULATION){
-
- ieee->current_network.rates_len = 4;
-
- ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
- ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
- ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
- ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
-
- }else
- ieee->current_network.rates_len = 0;
-
- if(ieee->modulation & IEEE80211_OFDM_MODULATION){
- ieee->current_network.rates_ex_len = 8;
-
- ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
- ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
- ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
- ieee->current_network.rates_ex[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_18MB;
- ieee->current_network.rates_ex[4] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_24MB;
- ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
- ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
- ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
-
- ieee->rate = 108;
- }else{
- ieee->current_network.rates_ex_len = 0;
- ieee->rate = 22;
- }
-
- // By default, WMM function will be disabled in IBSS mode
- ieee->current_network.QoS_Enable = 0;
- ieee->SetWirelessMode(ieee->dev, IEEE_G);
- ieee->current_network.atim_window = 0;
- ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
- if(ieee->short_slot)
- ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
-
- }
-
- ieee->state = IEEE80211_LINKED;
-
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- ieee->link_change(ieee->dev);
- if(ieee->LedControlHandler != NULL)
- ieee->LedControlHandler(ieee->dev,LED_CTL_LINK);
- notify_wx_assoc_event(ieee);
-
- ieee80211_start_send_beacons(ieee);
-
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
- netif_carrier_on(ieee->dev);
-
- up(&ieee->wx_sem);
-}
-
-inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
-{
- queue_delayed_work(ieee->wq, &ieee->start_ibss_wq, 150);
-}
-
-/* this is called only in user context, with wx_sem held */
-void ieee80211_start_bss(struct ieee80211_device *ieee)
-{
- unsigned long flags;
- //
- // Ref: 802.11d 11.1.3.3
- // STA shall not start a BSS unless properly formed Beacon frame including a Country IE.
- //
- if(IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee))
- {
- if(! ieee->bGlobalDomain)
- {
- return;
- }
- }
- /* check if we have already found the net we
- * are interested in (if any).
- * if not (we are disassociated and we are not
- * in associating / authenticating phase) start the background scanning.
- */
- ieee80211_softmac_check_all_nets(ieee);
-
- /* ensure no-one start an associating process (thus setting
- * the ieee->state to ieee80211_ASSOCIATING) while we
- * have just cheked it and we are going to enable scan.
- * The ieee80211_new_net function is always called with
- * lock held (from both ieee80211_softmac_check_all_nets and
- * the rx path), so we cannot be in the middle of such function
- */
- spin_lock_irqsave(&ieee->lock, flags);
-
- if (ieee->state == IEEE80211_NOLINK){
- ieee->actscanning = true;
- ieee80211_rtl_start_scan(ieee);
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-}
-
-void ieee80211_link_change_wq(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work, struct delayed_work, work);
- struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, link_change_wq);
-
- ieee->link_change(ieee->dev);
-}
-/* called only in userspace context */
-void ieee80211_disassociate(struct ieee80211_device *ieee)
-{
-
-
- netif_carrier_off(ieee->dev);
- if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
- ieee80211_reset_queue(ieee);
-
- if (ieee->data_hard_stop)
- ieee->data_hard_stop(ieee->dev);
- if(IS_DOT11D_ENABLE(ieee))
- Dot11d_Reset(ieee);
- ieee->state = IEEE80211_NOLINK;
- ieee->is_set_key = false;
-
- queue_delayed_work(ieee->wq, &ieee->link_change_wq, 0);
-
-
- notify_wx_assoc_event(ieee);
-
-}
-
-void ieee80211_associate_retry_wq(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work, struct delayed_work, work);
- struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
- unsigned long flags;
-
- down(&ieee->wx_sem);
- if(!ieee->proto_started)
- goto exit;
-
- if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
- goto exit;
-
- /* until we do not set the state to IEEE80211_NOLINK
- * there are no possibility to have someone else trying
- * to start an association procdure (we get here with
- * ieee->state = IEEE80211_ASSOCIATING).
- * When we set the state to IEEE80211_NOLINK it is possible
- * that the RX path run an attempt to associate, but
- * both ieee80211_softmac_check_all_nets and the
- * RX path works with ieee->lock held so there are no
- * problems. If we are still disassociated then start a scan.
- * the lock here is necessary to ensure no one try to start
- * an association procedure when we have just checked the
- * state and we are going to start the scan.
- */
- ieee->beinretry = true;
- ieee->state = IEEE80211_NOLINK;
-
- ieee80211_softmac_check_all_nets(ieee);
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- if(ieee->state == IEEE80211_NOLINK)
- {
- ieee->actscanning = true;
- ieee80211_rtl_start_scan(ieee);
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-
- ieee->beinretry = false;
-exit:
- up(&ieee->wx_sem);
-}
-
-struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
-{
- u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
-
- struct sk_buff *skb;
- struct ieee80211_probe_response *b;
-
- skb = ieee80211_probe_resp(ieee, broadcast_addr);
-
- if (!skb)
- return NULL;
-
- b = (struct ieee80211_probe_response *) skb->data;
- b->header.frame_control = cpu_to_le16(IEEE80211_STYPE_BEACON);
-
- return skb;
-
-}
-
-struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
-{
- struct sk_buff *skb;
- struct ieee80211_probe_response *b;
-
- skb = ieee80211_get_beacon_(ieee);
- if(!skb)
- return NULL;
-
- b = (struct ieee80211_probe_response *) skb->data;
- b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
-
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
-
- return skb;
-}
-
-void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
-{
- ieee->sync_scan_hurryup = 1;
- down(&ieee->wx_sem);
- ieee80211_stop_protocol(ieee);
- up(&ieee->wx_sem);
-}
-
-
-void ieee80211_stop_protocol(struct ieee80211_device *ieee)
-{
- if (!ieee->proto_started)
- return;
-
- ieee->proto_started = 0;
-
- ieee80211_stop_send_beacons(ieee);
- del_timer_sync(&ieee->associate_timer);
- cancel_delayed_work(&ieee->associate_retry_wq);
- cancel_delayed_work(&ieee->start_ibss_wq);
- cancel_delayed_work(&ieee->link_change_wq);
- ieee80211_stop_scan(ieee);
-
- ieee80211_disassociate(ieee);
- RemoveAllTS(ieee); //added as we disconnect from the previous BSS, Remove all TS
-}
-
-void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
-{
- ieee->sync_scan_hurryup = 0;
- down(&ieee->wx_sem);
- ieee80211_start_protocol(ieee);
- up(&ieee->wx_sem);
-}
-
-void ieee80211_start_protocol(struct ieee80211_device *ieee)
-{
- short ch = 0;
- int i = 0;
- if (ieee->proto_started)
- return;
-
- ieee->proto_started = 1;
-
- if (ieee->current_network.channel == 0){
- do{
- ch++;
- if (ch > MAX_CHANNEL_NUMBER)
- return; /* no channel found */
- }while(!GET_DOT11D_INFO(ieee)->channel_map[ch]);
- ieee->current_network.channel = ch;
- }
-
- if (ieee->current_network.beacon_interval == 0)
- ieee->current_network.beacon_interval = 100;
-
- for(i = 0; i < 17; i++) {
- ieee->last_rxseq_num[i] = -1;
- ieee->last_rxfrag_num[i] = -1;
- ieee->last_packet_time[i] = 0;
- }
-
- ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers.
-
-
- /* if the user set the MAC of the ad-hoc cell and then
- * switch to managed mode, shall we make sure that association
- * attempts does not fail just because the user provide the essid
- * and the nic is still checking for the AP MAC ??
- */
- if (ieee->iw_mode == IW_MODE_INFRA)
- ieee80211_start_bss(ieee);
-
- else if (ieee->iw_mode == IW_MODE_ADHOC)
- ieee80211_start_ibss(ieee);
-
- else if (ieee->iw_mode == IW_MODE_MASTER)
- ieee80211_start_master_bss(ieee);
-
- else if(ieee->iw_mode == IW_MODE_MONITOR)
- ieee80211_start_monitor_mode(ieee);
-}
-
-
-#define DRV_NAME "Ieee80211"
-void ieee80211_softmac_init(struct ieee80211_device *ieee)
-{
- int i;
- memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
-
- ieee->state = IEEE80211_NOLINK;
- ieee->sync_scan_hurryup = 0;
- for(i = 0; i < 5; i++) {
- ieee->seq_ctrl[i] = 0;
- }
- ieee->pDot11dInfo = kzalloc(sizeof(RT_DOT11D_INFO), GFP_ATOMIC);
- if (!ieee->pDot11dInfo)
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for DOT11D\n");
- //added for AP roaming
- ieee->LinkDetectInfo.SlotNum = 2;
- ieee->LinkDetectInfo.NumRecvBcnInPeriod=0;
- ieee->LinkDetectInfo.NumRecvDataInPeriod=0;
-
- ieee->assoc_id = 0;
- ieee->queue_stop = 0;
- ieee->scanning = 0;
- ieee->softmac_features = 0; //so IEEE2100-like driver are happy
- ieee->wap_set = 0;
- ieee->ssid_set = 0;
- ieee->proto_started = 0;
- ieee->basic_rate = IEEE80211_DEFAULT_BASIC_RATE;
- ieee->rate = 22;
- ieee->ps = IEEE80211_PS_DISABLED;
- ieee->sta_sleep = 0;
- ieee->Regdot11HTOperationalRateSet[0]= 0xff;//support MCS 0~7
- ieee->Regdot11HTOperationalRateSet[1]= 0xff;//support MCS 8~15
- ieee->Regdot11HTOperationalRateSet[4]= 0x01;
- ieee->actscanning = false;
- ieee->beinretry = false;
- ieee->is_set_key = false;
- init_mgmt_queue(ieee);
-
- ieee->sta_edca_param[0] = 0x0000A403;
- ieee->sta_edca_param[1] = 0x0000A427;
- ieee->sta_edca_param[2] = 0x005E4342;
- ieee->sta_edca_param[3] = 0x002F3262;
- ieee->aggregation = true;
- ieee->enable_rx_imm_BA = 1;
- ieee->tx_pending.txb = NULL;
-
- init_timer(&ieee->associate_timer);
- ieee->associate_timer.data = (unsigned long)ieee;
- ieee->associate_timer.function = ieee80211_associate_abort_cb;
-
- init_timer(&ieee->beacon_timer);
- ieee->beacon_timer.data = (unsigned long) ieee;
- ieee->beacon_timer.function = ieee80211_send_beacon_cb;
-
-#ifdef PF_SYNCTHREAD
- ieee->wq = create_workqueue(DRV_NAME,0);
-#else
- ieee->wq = create_workqueue(DRV_NAME);
-#endif
-
- INIT_DELAYED_WORK(&ieee->link_change_wq,ieee80211_link_change_wq);
- INIT_DELAYED_WORK(&ieee->start_ibss_wq,ieee80211_start_ibss_wq);
- INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq);
- INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq);
- INIT_DELAYED_WORK(&ieee->softmac_scan_wq,ieee80211_softmac_scan_wq);
- INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq);
- INIT_WORK(&ieee->wx_sync_scan_wq,ieee80211_wx_sync_scan_wq);
-
- sema_init(&ieee->wx_sem, 1);
- sema_init(&ieee->scan_sem, 1);
-
- spin_lock_init(&ieee->mgmt_tx_lock);
- spin_lock_init(&ieee->beacon_lock);
-
- tasklet_init(&ieee->ps_task,
- (void(*)(unsigned long)) ieee80211_sta_ps,
- (unsigned long)ieee);
-
-}
-
-void ieee80211_softmac_free(struct ieee80211_device *ieee)
-{
- down(&ieee->wx_sem);
- if(NULL != ieee->pDot11dInfo)
- {
- kfree(ieee->pDot11dInfo);
- ieee->pDot11dInfo = NULL;
- }
- del_timer_sync(&ieee->associate_timer);
-
- cancel_delayed_work(&ieee->associate_retry_wq);
- destroy_workqueue(ieee->wq);
-
- up(&ieee->wx_sem);
-}
-
-/********************************************************
- * Start of WPA code. *
- * this is stolen from the ipw2200 driver *
- ********************************************************/
-
-
-static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
-{
- /* This is called when wpa_supplicant loads and closes the driver
- * interface. */
- printk("%s WPA\n",value ? "enabling" : "disabling");
- ieee->wpa_enabled = value;
- memset(ieee->ap_mac_addr, 0, 6); //reset ap_mac_addr everytime it starts wpa.
- return 0;
-}
-
-
-void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
-{
- /* make sure WPA is enabled */
- ieee80211_wpa_enable(ieee, 1);
-
- ieee80211_disassociate(ieee);
-}
-
-
-static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
-{
-
- int ret = 0;
-
- switch (command) {
- case IEEE_MLME_STA_DEAUTH:
- // silently ignore
- break;
-
- case IEEE_MLME_STA_DISASSOC:
- ieee80211_disassociate(ieee);
- break;
-
- default:
- printk("Unknown MLME request: %d\n", command);
- ret = -EOPNOTSUPP;
- }
-
- return ret;
-}
-
-
-static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
- struct ieee_param *param, int plen)
-{
- u8 *buf;
-
- if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
- (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL))
- return -EINVAL;
-
- if (param->u.wpa_ie.len) {
- buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len,
- GFP_KERNEL);
- if (buf == NULL)
- return -ENOMEM;
-
- kfree(ieee->wpa_ie);
- ieee->wpa_ie = buf;
- ieee->wpa_ie_len = param->u.wpa_ie.len;
- } else {
- kfree(ieee->wpa_ie);
- ieee->wpa_ie = NULL;
- ieee->wpa_ie_len = 0;
- }
-
- ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
- return 0;
-}
-
-#define AUTH_ALG_OPEN_SYSTEM 0x1
-#define AUTH_ALG_SHARED_KEY 0x2
-#define AUTH_ALG_LEAP 0x4
-static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
-{
-
- struct ieee80211_security sec = {
- .flags = SEC_AUTH_MODE,
- };
- int ret = 0;
-
- if (value & AUTH_ALG_SHARED_KEY) {
- sec.auth_mode = WLAN_AUTH_SHARED_KEY;
- ieee->open_wep = 0;
- ieee->auth_mode = 1;
- } else if (value & AUTH_ALG_OPEN_SYSTEM){
- sec.auth_mode = WLAN_AUTH_OPEN;
- ieee->open_wep = 1;
- ieee->auth_mode = 0;
- }
- else if (value & AUTH_ALG_LEAP){
- sec.auth_mode = RTL_WLAN_AUTH_LEAP;
- ieee->open_wep = 1;
- ieee->auth_mode = 2;
- }
-
-
- if (ieee->set_security)
- ieee->set_security(ieee->dev, &sec);
-
- return ret;
-}
-
-static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
-{
- int ret=0;
- unsigned long flags;
-
- switch (name) {
- case IEEE_PARAM_WPA_ENABLED:
- ret = ieee80211_wpa_enable(ieee, value);
- break;
-
- case IEEE_PARAM_TKIP_COUNTERMEASURES:
- ieee->tkip_countermeasures=value;
- break;
-
- case IEEE_PARAM_DROP_UNENCRYPTED: {
- /* HACK:
- *
- * wpa_supplicant calls set_wpa_enabled when the driver
- * is loaded and unloaded, regardless of if WPA is being
- * used. No other calls are made which can be used to
- * determine if encryption will be used or not prior to
- * association being expected. If encryption is not being
- * used, drop_unencrypted is set to false, else true -- we
- * can use this to determine if the CAP_PRIVACY_ON bit should
- * be set.
- */
- struct ieee80211_security sec = {
- .flags = SEC_ENABLED,
- .enabled = value,
- };
- ieee->drop_unencrypted = value;
- /* We only change SEC_LEVEL for open mode. Others
- * are set by ipw_wpa_set_encryption.
- */
- if (!value) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_0;
- }
- else {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_1;
- }
- if (ieee->set_security)
- ieee->set_security(ieee->dev, &sec);
- break;
- }
-
- case IEEE_PARAM_PRIVACY_INVOKED:
- ieee->privacy_invoked=value;
- break;
-
- case IEEE_PARAM_AUTH_ALGS:
- ret = ieee80211_wpa_set_auth_algs(ieee, value);
- break;
-
- case IEEE_PARAM_IEEE_802_1X:
- ieee->ieee802_1x=value;
- break;
- case IEEE_PARAM_WPAX_SELECT:
- // added for WPA2 mixed mode
- spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags);
- ieee->wpax_type_set = 1;
- ieee->wpax_type_notify = value;
- spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags);
- break;
-
- default:
- printk("Unknown WPA param: %d\n",name);
- ret = -EOPNOTSUPP;
- }
-
- return ret;
-}
-
-/* implementation borrowed from hostap driver */
-
-static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
- struct ieee_param *param, int param_len)
-{
- int ret = 0;
-
- struct ieee80211_crypto_ops *ops;
- struct ieee80211_crypt_data **crypt;
-
- struct ieee80211_security sec = {
- .flags = 0,
- };
-
- param->u.crypt.err = 0;
- param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
-
- if (param_len !=
- (int) ((char *) param->u.crypt.key - (char *) param) +
- param->u.crypt.key_len) {
- printk("Len mismatch %d, %d\n", param_len,
- param->u.crypt.key_len);
- return -EINVAL;
- }
- if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
- param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
- param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
- if (param->u.crypt.idx >= WEP_KEYS)
- return -EINVAL;
- crypt = &ieee->crypt[param->u.crypt.idx];
- } else {
- return -EINVAL;
- }
-
- if (strcmp(param->u.crypt.alg, "none") == 0) {
- if (crypt) {
- sec.enabled = 0;
- // FIXME FIXME
- //sec.encrypt = 0;
- sec.level = SEC_LEVEL_0;
- sec.flags |= SEC_ENABLED | SEC_LEVEL;
- ieee80211_crypt_delayed_deinit(ieee, crypt);
- }
- goto done;
- }
- sec.enabled = 1;
-// FIXME FIXME
-// sec.encrypt = 1;
- sec.flags |= SEC_ENABLED;
-
- /* IPW HW cannot build TKIP MIC, host decryption still needed. */
- if (!(ieee->host_encrypt || ieee->host_decrypt) &&
- strcmp(param->u.crypt.alg, "TKIP"))
- goto skip_host_crypt;
-
- ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
- if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0)
- ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
- /* set WEP40 first, it will be modified according to WEP104 or
- * WEP40 at other place */
- else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0)
- ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
- else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0)
- ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
- if (ops == NULL) {
- printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
- param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
- ret = -EINVAL;
- goto done;
- }
-
- if (*crypt == NULL || (*crypt)->ops != ops) {
- struct ieee80211_crypt_data *new_crypt;
-
- ieee80211_crypt_delayed_deinit(ieee, crypt);
-
- new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL) {
- ret = -ENOMEM;
- goto done;
- }
- memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
- new_crypt->ops = ops;
-
- if (new_crypt->ops)
- new_crypt->priv =
- new_crypt->ops->init(param->u.crypt.idx);
-
- if (new_crypt->priv == NULL) {
- kfree(new_crypt);
- param->u.crypt.err = IEEE_CRYPT_ERR_CRYPT_INIT_FAILED;
- ret = -EINVAL;
- goto done;
- }
-
- *crypt = new_crypt;
- }
-
- if (param->u.crypt.key_len > 0 && (*crypt)->ops->set_key &&
- (*crypt)->ops->set_key(param->u.crypt.key,
- param->u.crypt.key_len, param->u.crypt.seq,
- (*crypt)->priv) < 0) {
- printk("key setting failed\n");
- param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED;
- ret = -EINVAL;
- goto done;
- }
-
- skip_host_crypt:
- if (param->u.crypt.set_tx) {
- ieee->tx_keyidx = param->u.crypt.idx;
- sec.active_key = param->u.crypt.idx;
- sec.flags |= SEC_ACTIVE_KEY;
- } else
- sec.flags &= ~SEC_ACTIVE_KEY;
-
- if (param->u.crypt.alg != NULL) {
- memcpy(sec.keys[param->u.crypt.idx],
- param->u.crypt.key,
- param->u.crypt.key_len);
- sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
- sec.flags |= (1 << param->u.crypt.idx);
-
- if (strcmp(param->u.crypt.alg, "WEP") == 0) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_1;
- } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_2;
- } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_3;
- }
- }
- done:
- if (ieee->set_security)
- ieee->set_security(ieee->dev, &sec);
-
- /* Do not reset port if card is in Managed mode since resetting will
- * generate new IEEE 802.11 authentication which may end up in looping
- * with IEEE 802.1X. If your hardware requires a reset after WEP
- * configuration (for example... Prism2), implement the reset_port in
- * the callbacks structures used to initialize the 802.11 stack. */
- if (ieee->reset_on_keychange &&
- ieee->iw_mode != IW_MODE_INFRA &&
- ieee->reset_port &&
- ieee->reset_port(ieee->dev)) {
- printk("reset_port failed\n");
- param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED;
- return -EINVAL;
- }
-
- return ret;
-}
-
-inline struct sk_buff *ieee80211_disassociate_skb(
- struct ieee80211_network *beacon,
- struct ieee80211_device *ieee,
- u8 asRsn)
-{
- struct sk_buff *skb;
- struct ieee80211_disassoc *disass;
-
- skb = dev_alloc_skb(sizeof(struct ieee80211_disassoc));
- if (!skb)
- return NULL;
-
- disass = (struct ieee80211_disassoc *) skb_put(skb,sizeof(struct ieee80211_disassoc));
- disass->header.frame_control = cpu_to_le16(IEEE80211_STYPE_DISASSOC);
- disass->header.duration_id = 0;
-
- memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN);
-
- disass->reason = asRsn;
- return skb;
-}
-
-
-void
-SendDisassociation(
- struct ieee80211_device *ieee,
- u8* asSta,
- u8 asRsn
-)
-{
- struct ieee80211_network *beacon = &ieee->current_network;
- struct sk_buff *skb;
- skb = ieee80211_disassociate_skb(beacon,ieee,asRsn);
- if (skb){
- softmac_mgmt_xmit(skb, ieee);
- //dev_kfree_skb_any(skb);//edit by thomas
- }
-}
-
-int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
-{
- struct ieee_param *param;
- int ret=0;
-
- down(&ieee->wx_sem);
-
- if (p->length < sizeof(struct ieee_param) || !p->pointer){
- ret = -EINVAL;
- goto out;
- }
-
- param = kmalloc(p->length, GFP_KERNEL);
- if (param == NULL){
- ret = -ENOMEM;
- goto out;
- }
- if (copy_from_user(param, p->pointer, p->length)) {
- kfree(param);
- ret = -EFAULT;
- goto out;
- }
-
- switch (param->cmd) {
-
- case IEEE_CMD_SET_WPA_PARAM:
- ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
- param->u.wpa_param.value);
- break;
-
- case IEEE_CMD_SET_WPA_IE:
- ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
- break;
-
- case IEEE_CMD_SET_ENCRYPTION:
- ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
- break;
-
- case IEEE_CMD_MLME:
- ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
- param->u.mlme.reason_code);
- break;
-
- default:
- printk("Unknown WPA supplicant request: %d\n",param->cmd);
- ret = -EOPNOTSUPP;
- break;
- }
-
- if (ret == 0 && copy_to_user(p->pointer, param, p->length))
- ret = -EFAULT;
-
- kfree(param);
-out:
- up(&ieee->wx_sem);
-
- return ret;
-}
-
-void notify_wx_assoc_event(struct ieee80211_device *ieee)
-{
- union iwreq_data wrqu;
- wrqu.ap_addr.sa_family = ARPHRD_ETHER;
- if (ieee->state == IEEE80211_LINKED)
- memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN);
- else
- memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
- wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
deleted file mode 100644
index 9ded253e1f9a..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac_wx.c
+++ /dev/null
@@ -1,625 +0,0 @@
-/* IEEE 802.11 SoftMAC layer
- * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
- *
- * Mostly extracted from the rtl8180-sa2400 driver for the
- * in-kernel generic ieee802.11 stack.
- *
- * Some pieces of code might be stolen from ipw2100 driver
- * copyright of who own it's copyright ;-)
- *
- * PS wx handler mostly stolen from hostap, copyright who
- * own it's copyright ;-)
- *
- * released under the GPL
- */
-
-
-#include "ieee80211.h"
-#include "dot11d.h"
-/* FIXME: add A freqs */
-
-const long ieee80211_wlan_frequencies[] = {
- 2412, 2417, 2422, 2427,
- 2432, 2437, 2442, 2447,
- 2452, 2457, 2462, 2467,
- 2472, 2484
-};
-
-
-int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- int ret;
- struct iw_freq *fwrq = & wrqu->freq;
-
- down(&ieee->wx_sem);
-
- if(ieee->iw_mode == IW_MODE_INFRA){
- ret = -EOPNOTSUPP;
- goto out;
- }
-
- /* if setting by freq convert to channel */
- if (fwrq->e == 1) {
- if ((fwrq->m >= (int) 2.412e8 &&
- fwrq->m <= (int) 2.487e8)) {
- int f = fwrq->m / 100000;
- int c = 0;
-
- while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
- c++;
-
- /* hack to fall through */
- fwrq->e = 0;
- fwrq->m = c + 1;
- }
- }
-
- if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
- ret = -EOPNOTSUPP;
- goto out;
-
- }else { /* Set the channel */
-
- if (!(GET_DOT11D_INFO(ieee)->channel_map)[fwrq->m]) {
- ret = -EINVAL;
- goto out;
- }
- ieee->current_network.channel = fwrq->m;
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
-
- if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
- if(ieee->state == IEEE80211_LINKED){
-
- ieee80211_stop_send_beacons(ieee);
- ieee80211_start_send_beacons(ieee);
- }
- }
-
- ret = 0;
-out:
- up(&ieee->wx_sem);
- return ret;
-}
-
-
-int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct iw_freq *fwrq = & wrqu->freq;
-
- if (ieee->current_network.channel == 0)
- return -1;
- //NM 0.7.0 will not accept channel any more.
- fwrq->m = ieee80211_wlan_frequencies[ieee->current_network.channel-1] * 100000;
- fwrq->e = 1;
-// fwrq->m = ieee->current_network.channel;
-// fwrq->e = 0;
-
- return 0;
-}
-
-int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- unsigned long flags;
-
- wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-
- if (ieee->iw_mode == IW_MODE_MONITOR)
- return -1;
-
- /* We want avoid to give to the user inconsistent infos*/
- spin_lock_irqsave(&ieee->lock, flags);
-
- if (ieee->state != IEEE80211_LINKED &&
- ieee->state != IEEE80211_LINKED_SCANNING &&
- ieee->wap_set == 0)
-
- memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
- else
- memcpy(wrqu->ap_addr.sa_data,
- ieee->current_network.bssid, ETH_ALEN);
-
- spin_unlock_irqrestore(&ieee->lock, flags);
-
- return 0;
-}
-
-
-int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *awrq,
- char *extra)
-{
-
- int ret = 0;
- u8 zero[] = {0,0,0,0,0,0};
- unsigned long flags;
-
- short ifup = ieee->proto_started;//dev->flags & IFF_UP;
- struct sockaddr *temp = (struct sockaddr *)awrq;
-
- ieee->sync_scan_hurryup = 1;
-
- down(&ieee->wx_sem);
- /* use ifconfig hw ether */
- if (ieee->iw_mode == IW_MODE_MASTER){
- ret = -1;
- goto out;
- }
-
- if (temp->sa_family != ARPHRD_ETHER){
- ret = -EINVAL;
- goto out;
- }
-
- if (ifup)
- ieee80211_stop_protocol(ieee);
-
- /* just to avoid to give inconsistent infos in the
- * get wx method. not really needed otherwise
- */
- spin_lock_irqsave(&ieee->lock, flags);
-
- memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
- ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
-
- spin_unlock_irqrestore(&ieee->lock, flags);
-
- if (ifup)
- ieee80211_start_protocol(ieee);
-out:
- up(&ieee->wx_sem);
- return ret;
-}
-
- int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
-{
- int len,ret = 0;
- unsigned long flags;
-
- if (ieee->iw_mode == IW_MODE_MONITOR)
- return -1;
-
- /* We want avoid to give to the user inconsistent infos*/
- spin_lock_irqsave(&ieee->lock, flags);
-
- if (ieee->current_network.ssid[0] == '\0' ||
- ieee->current_network.ssid_len == 0){
- ret = -1;
- goto out;
- }
-
- if (ieee->state != IEEE80211_LINKED &&
- ieee->state != IEEE80211_LINKED_SCANNING &&
- ieee->ssid_set == 0){
- ret = -1;
- goto out;
- }
- len = ieee->current_network.ssid_len;
- wrqu->essid.length = len;
- strncpy(b,ieee->current_network.ssid,len);
- wrqu->essid.flags = 1;
-
-out:
- spin_unlock_irqrestore(&ieee->lock, flags);
-
- return ret;
-
-}
-
-int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
-
- u32 target_rate = wrqu->bitrate.value;
-
- ieee->rate = target_rate/100000;
- //FIXME: we might want to limit rate also in management protocols.
- return 0;
-}
-
-
-
-int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- u32 tmp_rate = 0;
- //printk("===>mode:%d, halfNmode:%d\n", ieee->mode, ieee->bHalfWirelessN24GMode);
- if (ieee->mode & (IEEE_A | IEEE_B | IEEE_G))
- tmp_rate = ieee->rate;
- else if (ieee->mode & IEEE_N_5G)
- tmp_rate = 580;
- else if (ieee->mode & IEEE_N_24G)
- {
- if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
- tmp_rate = HTHalfMcsToDataRate(ieee, 15);
- else
- tmp_rate = HTMcsToDataRate(ieee, 15);
- }
- wrqu->bitrate.value = tmp_rate * 500000;
-
- return 0;
-}
-
-
-int ieee80211_wx_set_rts(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- if (wrqu->rts.disabled || !wrqu->rts.fixed)
- ieee->rts = DEFAULT_RTS_THRESHOLD;
- else
- {
- if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
- wrqu->rts.value > MAX_RTS_THRESHOLD)
- return -EINVAL;
- ieee->rts = wrqu->rts.value;
- }
- return 0;
-}
-
-int ieee80211_wx_get_rts(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- wrqu->rts.value = ieee->rts;
- wrqu->rts.fixed = 0; /* no auto select */
- wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD);
- return 0;
-}
-int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
-
- ieee->sync_scan_hurryup = 1;
-
- down(&ieee->wx_sem);
-
- if (wrqu->mode == ieee->iw_mode)
- goto out;
-
- if (wrqu->mode == IW_MODE_MONITOR){
-
- ieee->dev->type = ARPHRD_IEEE80211;
- }else{
- ieee->dev->type = ARPHRD_ETHER;
- }
-
- if (!ieee->proto_started){
- ieee->iw_mode = wrqu->mode;
- }else{
- ieee80211_stop_protocol(ieee);
- ieee->iw_mode = wrqu->mode;
- ieee80211_start_protocol(ieee);
- }
-
-out:
- up(&ieee->wx_sem);
- return 0;
-}
-
-void ieee80211_wx_sync_scan_wq(struct work_struct *work)
-{
- struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
- short chan;
- HT_EXTCHNL_OFFSET chan_offset=0;
- HT_CHANNEL_WIDTH bandwidth=0;
- int b40M = 0;
- static int count = 0;
- chan = ieee->current_network.channel;
- netif_carrier_off(ieee->dev);
-
- if (ieee->data_hard_stop)
- ieee->data_hard_stop(ieee->dev);
-
- ieee80211_stop_send_beacons(ieee);
-
- ieee->state = IEEE80211_LINKED_SCANNING;
- ieee->link_change(ieee->dev);
- ieee->InitialGainHandler(ieee->dev,IG_Backup);
- if (ieee->SetFwCmdHandler)
- {
- ieee->SetFwCmdHandler(ieee->dev, FW_CMD_DIG_HALT);
- ieee->SetFwCmdHandler(ieee->dev, FW_CMD_HIGH_PWR_DISABLE);
- }
- if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT && ieee->pHTInfo->bCurBW40MHz) {
- b40M = 1;
- chan_offset = ieee->pHTInfo->CurSTAExtChnlOffset;
- bandwidth = (HT_CHANNEL_WIDTH)ieee->pHTInfo->bCurBW40MHz;
- printk("Scan in 40M, force to 20M first:%d, %d\n", chan_offset, bandwidth);
- ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
- }
- ieee80211_start_scan_syncro(ieee);
- if (b40M) {
- printk("Scan in 20M, back to 40M\n");
- if (chan_offset == HT_EXTCHNL_OFFSET_UPPER)
- ieee->set_chan(ieee->dev, chan + 2);
- else if (chan_offset == HT_EXTCHNL_OFFSET_LOWER)
- ieee->set_chan(ieee->dev, chan - 2);
- else
- ieee->set_chan(ieee->dev, chan);
- ieee->SetBWModeHandler(ieee->dev, bandwidth, chan_offset);
- } else {
- ieee->set_chan(ieee->dev, chan);
- }
-
- ieee->InitialGainHandler(ieee->dev,IG_Restore);
- if (ieee->SetFwCmdHandler)
- {
- ieee->SetFwCmdHandler(ieee->dev, FW_CMD_DIG_RESUME);
- ieee->SetFwCmdHandler(ieee->dev, FW_CMD_HIGH_PWR_ENABLE);
- }
- ieee->state = IEEE80211_LINKED;
- ieee->link_change(ieee->dev);
- // To prevent the immediately calling watch_dog after scan.
- if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
- {
- ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
- ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
- }
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
-
- if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
- ieee80211_start_send_beacons(ieee);
-
- netif_carrier_on(ieee->dev);
- count = 0;
- up(&ieee->wx_sem);
-
-}
-
-int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- int ret = 0;
-
- down(&ieee->wx_sem);
-
- if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
- ret = -1;
- goto out;
- }
-
- if ( ieee->state == IEEE80211_LINKED){
- queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
- /* intentionally forget to up sem */
- return 0;
- }
-
-out:
- up(&ieee->wx_sem);
- return ret;
-}
-
-int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *extra)
-{
-
- int ret=0,len;
- short proto_started;
- unsigned long flags;
-
- ieee->sync_scan_hurryup = 1;
- down(&ieee->wx_sem);
-
- proto_started = ieee->proto_started;
-
- if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
- ret= -E2BIG;
- goto out;
- }
-
- if (ieee->iw_mode == IW_MODE_MONITOR){
- ret= -1;
- goto out;
- }
-
- if(proto_started)
- ieee80211_stop_protocol(ieee);
-
-
- /* this is just to be sure that the GET wx callback
- * has consisten infos. not needed otherwise
- */
- spin_lock_irqsave(&ieee->lock, flags);
-
- if (wrqu->essid.flags && wrqu->essid.length) {
- //first flush current network.ssid
- len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
- strncpy(ieee->current_network.ssid, extra, len+1);
- ieee->current_network.ssid_len = len+1;
- ieee->ssid_set = 1;
- }
- else{
- ieee->ssid_set = 0;
- ieee->current_network.ssid[0] = '\0';
- ieee->current_network.ssid_len = 0;
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
-
- if (proto_started)
- ieee80211_start_protocol(ieee);
-out:
- up(&ieee->wx_sem);
- return ret;
-}
-
- int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
-
- wrqu->mode = ieee->iw_mode;
- return 0;
-}
-
- int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
-
- int *parms = (int *)extra;
- int enable = (parms[0] > 0);
- short prev = ieee->raw_tx;
-
- down(&ieee->wx_sem);
-
- if(enable)
- ieee->raw_tx = 1;
- else
- ieee->raw_tx = 0;
-
- printk(KERN_INFO"raw TX is %s\n",
- ieee->raw_tx ? "enabled" : "disabled");
-
- if(ieee->iw_mode == IW_MODE_MONITOR)
- {
- if(prev == 0 && ieee->raw_tx){
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
-
- netif_carrier_on(ieee->dev);
- }
-
- if(prev && ieee->raw_tx == 1)
- netif_carrier_off(ieee->dev);
- }
-
- up(&ieee->wx_sem);
-
- return 0;
-}
-
-int ieee80211_wx_get_name(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- strlcpy(wrqu->name, "802.11", IFNAMSIZ);
- if(ieee->modulation & IEEE80211_CCK_MODULATION){
- strlcat(wrqu->name, "b", IFNAMSIZ);
- if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strlcat(wrqu->name, "/g", IFNAMSIZ);
- }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
- strlcat(wrqu->name, "g", IFNAMSIZ);
- if (ieee->mode & (IEEE_N_24G | IEEE_N_5G))
- strlcat(wrqu->name, "/n", IFNAMSIZ);
-
- if((ieee->state == IEEE80211_LINKED) ||
- (ieee->state == IEEE80211_LINKED_SCANNING))
- strlcat(wrqu->name, " link", IFNAMSIZ);
- else if(ieee->state != IEEE80211_NOLINK)
- strlcat(wrqu->name, " .....", IFNAMSIZ);
-
-
- return 0;
-}
-
-
-/* this is mostly stolen from hostap */
-int ieee80211_wx_set_power(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret = 0;
-#if 1
- if(
- (!ieee->sta_wake_up) ||
- // (!ieee->ps_request_tx_ack) ||
- (!ieee->enter_sleep_state) ||
- (!ieee->ps_is_queue_empty)){
-
- // printk("ERROR. PS mode is tryied to be use but driver missed a callback\n\n");
-
- return -1;
- }
-#endif
- down(&ieee->wx_sem);
-
- if (wrqu->power.disabled){
- ieee->ps = IEEE80211_PS_DISABLED;
- goto exit;
- }
- if (wrqu->power.flags & IW_POWER_TIMEOUT) {
- //ieee->ps_period = wrqu->power.value / 1000;
- ieee->ps_timeout = wrqu->power.value / 1000;
- }
-
- if (wrqu->power.flags & IW_POWER_PERIOD) {
-
- //ieee->ps_timeout = wrqu->power.value / 1000;
- ieee->ps_period = wrqu->power.value / 1000;
- //wrq->value / 1024;
-
- }
- switch (wrqu->power.flags & IW_POWER_MODE) {
- case IW_POWER_UNICAST_R:
- ieee->ps = IEEE80211_PS_UNICAST;
- break;
- case IW_POWER_MULTICAST_R:
- ieee->ps = IEEE80211_PS_MBCAST;
- break;
- case IW_POWER_ALL_R:
- ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
- break;
-
- case IW_POWER_ON:
- // ieee->ps = IEEE80211_PS_DISABLED;
- break;
-
- default:
- ret = -EINVAL;
- goto exit;
-
- }
-exit:
- up(&ieee->wx_sem);
- return ret;
-
-}
-
-/* this is stolen from hostap */
-int ieee80211_wx_get_power(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret =0;
-
- down(&ieee->wx_sem);
-
- if(ieee->ps == IEEE80211_PS_DISABLED){
- wrqu->power.disabled = 1;
- goto exit;
- }
-
- wrqu->power.disabled = 0;
-
- if ((wrqu->power.flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
- wrqu->power.flags = IW_POWER_TIMEOUT;
- wrqu->power.value = ieee->ps_timeout * 1000;
- } else {
-// ret = -EOPNOTSUPP;
-// goto exit;
- wrqu->power.flags = IW_POWER_PERIOD;
- wrqu->power.value = ieee->ps_period * 1000;
-//ieee->current_network.dtim_period * ieee->current_network.beacon_interval * 1024;
- }
-
- if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST))
- wrqu->power.flags |= IW_POWER_ALL_R;
- else if (ieee->ps & IEEE80211_PS_MBCAST)
- wrqu->power.flags |= IW_POWER_MULTICAST_R;
- else
- wrqu->power.flags |= IW_POWER_UNICAST_R;
-
-exit:
- up(&ieee->wx_sem);
- return ret;
-
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
deleted file mode 100644
index a6a5d68df3aa..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
+++ /dev/null
@@ -1,916 +0,0 @@
-/******************************************************************************
-
- Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59
- Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The full GNU General Public License is included in this distribution in the
- file called LICENSE.
-
- Contact Information:
- James P. Ketrenos <ipw2100-admin@linux.intel.com>
- Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-******************************************************************************
-
- Few modifications for Realtek's Wi-Fi drivers by
- Andrea Merello <andreamrl@tiscali.it>
-
- A special thanks goes to Realtek for their support !
-
-******************************************************************************/
-
-#include <linux/compiler.h>
-#include <linux/errno.h>
-#include <linux/if_arp.h>
-#include <linux/in6.h>
-#include <linux/in.h>
-#include <linux/ip.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
-#include <linux/skbuff.h>
-#include <linux/slab.h>
-#include <linux/tcp.h>
-#include <linux/types.h>
-#include <linux/wireless.h>
-#include <linux/etherdevice.h>
-#include <asm/uaccess.h>
-#include <linux/if_vlan.h>
-
-#include "ieee80211.h"
-
-
-/*
-
-
-802.11 Data Frame
-
-
-802.11 frame_contorl for data frames - 2 bytes
- ,-----------------------------------------------------------------------------------------.
-bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e |
- |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
-val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x |
- |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
-desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep |
- | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | |
- '-----------------------------------------------------------------------------------------'
- /\
- |
-802.11 Data Frame |
- ,--------- 'ctrl' expands to >-----------'
- |
- ,--'---,-------------------------------------------------------------.
-Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
- |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs |
- | | tion | (BSSID) | | | ence | data | |
- `--------------------------------------------------| |------'
-Total: 28 non-data bytes `----.----'
- |
- .- 'Frame data' expands to <---------------------------'
- |
- V
- ,---------------------------------------------------.
-Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 |
- |------|------|---------|----------|------|---------|
-Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP |
- | DSAP | SSAP | | | | Packet |
- | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | |
- `-----------------------------------------| |
-Total: 8 non-data bytes `----.----'
- |
- .- 'IP Packet' expands, if WEP enabled, to <--'
- |
- V
- ,-----------------------.
-Bytes | 4 | 0-2296 | 4 |
- |-----|-----------|-----|
-Desc. | IV | Encrypted | ICV |
- | | IP Packet | |
- `-----------------------'
-Total: 8 non-data bytes
-
-
-802.3 Ethernet Data Frame
-
- ,-----------------------------------------.
-Bytes | 6 | 6 | 2 | Variable | 4 |
- |-------|-------|------|-----------|------|
-Desc. | Dest. | Source| Type | IP Packet | fcs |
- | MAC | MAC | | | |
- `-----------------------------------------'
-Total: 18 non-data bytes
-
-In the event that fragmentation is required, the incoming payload is split into
-N parts of size ieee->fts. The first fragment contains the SNAP header and the
-remaining packets are just data.
-
-If encryption is enabled, each fragment payload size is reduced by enough space
-to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
-So if you have 1500 bytes of payload with ieee->fts set to 500 without
-encryption it will take 3 frames. With WEP it will take 4 frames as the
-payload of each frame is reduced to 492 bytes.
-
-* SKB visualization
-*
-* ,- skb->data
-* |
-* | ETHERNET HEADER ,-<-- PAYLOAD
-* | | 14 bytes from skb->data
-* | 2 bytes for Type --> ,T. | (sizeof ethhdr)
-* | | | |
-* |,-Dest.--. ,--Src.---. | | |
-* | 6 bytes| | 6 bytes | | | |
-* v | | | | | |
-* 0 | v 1 | v | v 2
-* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-* ^ | ^ | ^ |
-* | | | | | |
-* | | | | `T' <---- 2 bytes for Type
-* | | | |
-* | | '---SNAP--' <-------- 6 bytes for SNAP
-* | |
-* `-IV--' <-------------------- 4 bytes for IV (WEP)
-*
-* SNAP HEADER
-*
-*/
-
-static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
-static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
-
-static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
-{
- struct ieee80211_snap_hdr *snap;
- u8 *oui;
-
- snap = (struct ieee80211_snap_hdr *)data;
- snap->dsap = 0xaa;
- snap->ssap = 0xaa;
- snap->ctrl = 0x03;
-
- if (h_proto == 0x8137 || h_proto == 0x80f3)
- oui = P802_1H_OUI;
- else
- oui = RFC1042_OUI;
- snap->oui[0] = oui[0];
- snap->oui[1] = oui[1];
- snap->oui[2] = oui[2];
-
- *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
-
- return SNAP_SIZE + sizeof(u16);
-}
-
-int ieee80211_encrypt_fragment(
- struct ieee80211_device *ieee,
- struct sk_buff *frag,
- int hdr_len)
-{
- struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx];
- int res;
-
- if (!(crypt && crypt->ops))
- {
- printk("=========>%s(), crypt is null\n", __FUNCTION__);
- return -1;
- }
-#ifdef CONFIG_IEEE80211_CRYPT_TKIP
- struct rtl_ieee80211_hdr *header;
-
- if (ieee->tkip_countermeasures &&
- crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
- header = (struct rtl_ieee80211_hdr *)frag->data;
- if (net_ratelimit()) {
- printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
- "TX packet to %pM\n",
- ieee->dev->name, header->addr1);
- }
- return -1;
- }
-#endif
- /* To encrypt, frame format is:
- * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
-
- /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
- * call both MSDU and MPDU encryption functions from here. */
- atomic_inc(&crypt->refcnt);
- res = 0;
- if (crypt->ops->encrypt_msdu)
- res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv);
- if (res == 0 && crypt->ops->encrypt_mpdu)
- res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv);
-
- atomic_dec(&crypt->refcnt);
- if (res < 0) {
- printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
- ieee->dev->name, frag->len);
- ieee->ieee_stats.tx_discards++;
- return -1;
- }
-
- return 0;
-}
-
-
-void ieee80211_txb_free(struct ieee80211_txb *txb) {
- if (unlikely(!txb))
- return;
- kfree(txb);
-}
-
-struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
- int gfp_mask)
-{
- struct ieee80211_txb *txb;
- int i;
- txb = kmalloc(
- sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags),
- gfp_mask);
- if (!txb)
- return NULL;
-
- memset(txb, 0, sizeof(struct ieee80211_txb));
- txb->nr_frags = nr_frags;
- txb->frag_size = txb_size;
-
- for (i = 0; i < nr_frags; i++) {
- txb->fragments[i] = dev_alloc_skb(txb_size);
- if (unlikely(!txb->fragments[i])) {
- i--;
- break;
- }
- memset(txb->fragments[i]->cb, 0, sizeof(txb->fragments[i]->cb));
- }
- if (unlikely(i != nr_frags)) {
- while (i >= 0)
- dev_kfree_skb_any(txb->fragments[i--]);
- kfree(txb);
- return NULL;
- }
- return txb;
-}
-
-// Classify the to-be send data packet
-// Need to acquire the sent queue index.
-static int
-ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
-{
- struct ethhdr *eth;
- struct iphdr *ip;
- eth = (struct ethhdr *)skb->data;
- if (eth->h_proto != htons(ETH_P_IP))
- return 0;
-
- ip = ip_hdr(skb);
-
- switch (ip->tos & 0xfc) {
- case 0x20:
- return 2;
- case 0x40:
- return 1;
- case 0x60:
- return 3;
- case 0x80:
- return 4;
- case 0xa0:
- return 5;
- case 0xc0:
- return 6;
- case 0xe0:
- return 7;
- default:
- return 0;
- }
-}
-
-void ieee80211_tx_query_agg_cap(struct ieee80211_device* ieee, struct sk_buff* skb, cb_desc* tcb_desc)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- PTX_TS_RECORD pTxTs = NULL;
- struct ieee80211_hdr_1addr* hdr = (struct ieee80211_hdr_1addr*)skb->data;
-
- if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
- return;
- if (!IsQoSDataFrame(skb->data))
- return;
-
- if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1))
- return;
- //check packet and mode later
-#ifdef TO_DO_LIST
- if(pTcb->PacketLength >= 4096)
- return;
- // For RTL819X, if pairwisekey = wep/tkip, we don't aggrregation.
- if(!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter))
- return;
-#endif
-
- if(pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION)
- return;
-
-#if 1
- if(!ieee->GetNmodeSupportBySecCfg(ieee->dev))
- {
- return;
- }
-#endif
- if(pHTInfo->bCurrentAMPDUEnable)
- {
- if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true))
- {
- printk("===>can't get TS\n");
- return;
- }
- if (pTxTs->TxAdmittedBARecord.bValid == false)
- {
- //as some AP will refuse our action frame until key handshake has been finished. WB
- if (ieee->wpa_ie_len && (ieee->pairwise_key_type == KEY_TYPE_NA))
- ;
- else
- TsStartAddBaProcess(ieee, pTxTs);
- goto FORCED_AGG_SETTING;
- }
- else if (pTxTs->bUsingBa == false)
- {
- if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096))
- pTxTs->bUsingBa = true;
- else
- goto FORCED_AGG_SETTING;
- }
-
- if (ieee->iw_mode == IW_MODE_INFRA)
- {
- tcb_desc->bAMPDUEnable = true;
- tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor;
- tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity;
- }
- }
-FORCED_AGG_SETTING:
- switch(pHTInfo->ForcedAMPDUMode )
- {
- case HT_AGG_AUTO:
- break;
-
- case HT_AGG_FORCE_ENABLE:
- tcb_desc->bAMPDUEnable = true;
- tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity;
- tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor;
- break;
-
- case HT_AGG_FORCE_DISABLE:
- tcb_desc->bAMPDUEnable = false;
- tcb_desc->ampdu_density = 0;
- tcb_desc->ampdu_factor = 0;
- break;
-
- }
- return;
-}
-
-extern void ieee80211_qurey_ShortPreambleMode(struct ieee80211_device* ieee, cb_desc* tcb_desc)
-{
- tcb_desc->bUseShortPreamble = false;
- if (tcb_desc->data_rate == 2)
- {//// 1M can only use Long Preamble. 11B spec
- return;
- }
- else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
- {
- tcb_desc->bUseShortPreamble = true;
- }
- return;
-}
-extern void
-ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, cb_desc *tcb_desc)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- tcb_desc->bUseShortGI = false;
-
- if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
- return;
-
- if(pHTInfo->bForcedShortGI)
- {
- tcb_desc->bUseShortGI = true;
- return;
- }
-
- if((pHTInfo->bCurBW40MHz==true) && pHTInfo->bCurShortGI40MHz)
- tcb_desc->bUseShortGI = true;
- else if((pHTInfo->bCurBW40MHz==false) && pHTInfo->bCurShortGI20MHz)
- tcb_desc->bUseShortGI = true;
-}
-
-void ieee80211_query_BandwidthMode(struct ieee80211_device* ieee, cb_desc *tcb_desc)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- tcb_desc->bPacketBW = false;
-
- if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
- return;
-
- if(tcb_desc->bMulticast || tcb_desc->bBroadcast)
- return;
-
- if((tcb_desc->data_rate & 0x80)==0) // If using legacy rate, it shall use 20MHz channel.
- return;
- //BandWidthAutoSwitch is for auto switch to 20 or 40 in long distance
- if(pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && !ieee->bandwidth_auto_switch.bforced_tx20Mhz)
- tcb_desc->bPacketBW = true;
- return;
-}
-
-void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_desc, struct sk_buff* skb)
-{
- // Common Settings
- tcb_desc->bRTSSTBC = false;
- tcb_desc->bRTSUseShortGI = false; // Since protection frames are always sent by legacy rate, ShortGI will never be used.
- tcb_desc->bCTSEnable = false; // Most of protection using RTS/CTS
- tcb_desc->RTSSC = 0; // 20MHz: Don't care; 40MHz: Duplicate.
- tcb_desc->bRTSBW = false; // RTS frame bandwidth is always 20MHz
-
- if(tcb_desc->bBroadcast || tcb_desc->bMulticast)//only unicast frame will use rts/cts
- return;
-
- if (is_broadcast_ether_addr(skb->data+16)) //check addr3 as infrastructure add3 is DA.
- return;
-
- if (ieee->mode < IEEE_N_24G) //b, g mode
- {
- // (1) RTS_Threshold is compared to the MPDU, not MSDU.
- // (2) If there are more than one frag in this MSDU, only the first frag uses protection frame.
- // Other fragments are protected by previous fragment.
- // So we only need to check the length of first fragment.
- if (skb->len > ieee->rts)
- {
- tcb_desc->bRTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- }
- else if (ieee->current_network.buseprotection)
- {
- // Use CTS-to-SELF in protection mode.
- tcb_desc->bRTSEnable = true;
- tcb_desc->bCTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- }
- //otherwise return;
- return;
- }
- else
- {// 11n High throughput case.
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- while (true)
- {
- //check IOT action
- if(pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF)
- {
- tcb_desc->bCTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- tcb_desc->bRTSEnable = false;
- break;
- }
- else if(pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_PURE_N_MODE))
- {
- tcb_desc->bRTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- break;
- }
- //check ERP protection
- if (ieee->current_network.buseprotection)
- {// CTS-to-SELF
- tcb_desc->bRTSEnable = true;
- tcb_desc->bCTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- break;
- }
- //check HT op mode
- if(pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT)
- {
- u8 HTOpMode = pHTInfo->CurrentOpMode;
- if((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || HTOpMode == 3)) ||
- (!pHTInfo->bCurBW40MHz && HTOpMode == 3) )
- {
- tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
- tcb_desc->bRTSEnable = true;
- break;
- }
- }
- //check rts
- if (skb->len > ieee->rts)
- {
- tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
- tcb_desc->bRTSEnable = true;
- break;
- }
- //to do list: check MIMO power save condition.
- //check AMPDU aggregation for TXOP
- if(tcb_desc->bAMPDUEnable)
- {
- tcb_desc->rts_rate = MGN_24M; // Rate is 24Mbps.
- // According to 8190 design, firmware sends CF-End only if RTS/CTS is enabled. However, it degrads
- // throughput around 10M, so we disable of this mechanism. 2007.08.03 by Emily
- tcb_desc->bRTSEnable = false;
- break;
- }
- // Totally no protection case!!
- goto NO_PROTECTION;
- }
- }
- // For test , CTS replace with RTS
- if( 0 )
- {
- tcb_desc->bCTSEnable = true;
- tcb_desc->rts_rate = MGN_24M;
- tcb_desc->bRTSEnable = true;
- }
- if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
- tcb_desc->bUseShortPreamble = true;
- if (ieee->mode == IW_MODE_MASTER)
- goto NO_PROTECTION;
- return;
-NO_PROTECTION:
- tcb_desc->bRTSEnable = false;
- tcb_desc->bCTSEnable = false;
- tcb_desc->rts_rate = 0;
- tcb_desc->RTSSC = 0;
- tcb_desc->bRTSBW = false;
-}
-
-
-void ieee80211_txrate_selectmode(struct ieee80211_device* ieee, cb_desc* tcb_desc)
-{
-#ifdef TO_DO_LIST
- if(!IsDataFrame(pFrame))
- {
- pTcb->bTxDisableRateFallBack = TRUE;
- pTcb->bTxUseDriverAssingedRate = TRUE;
- pTcb->RATRIndex = 7;
- return;
- }
-
- if(pMgntInfo->ForcedDataRate!= 0)
- {
- pTcb->bTxDisableRateFallBack = TRUE;
- pTcb->bTxUseDriverAssingedRate = TRUE;
- return;
- }
-#endif
- if(ieee->bTxDisableRateFallBack)
- tcb_desc->bTxDisableRateFallBack = true;
-
- if(ieee->bTxUseDriverAssingedRate)
- tcb_desc->bTxUseDriverAssingedRate = true;
- if(!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate)
- {
- if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC)
- tcb_desc->RATRIndex = 0;
- }
-}
-
-void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u8* dst)
-{
- if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst))
- return;
- if (IsQoSDataFrame(skb->data)) //we deal qos data only
- {
- PTX_TS_RECORD pTS = NULL;
- if (!GetTs(ieee, (PTS_COMMON_INFO*)(&pTS), dst, skb->priority, TX_DIR, true))
- {
- return;
- }
- pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096;
- }
-}
-
-int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct ieee80211_device *ieee = netdev_priv(dev);
- struct ieee80211_txb *txb = NULL;
- struct ieee80211_hdr_3addrqos *frag_hdr;
- int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
- unsigned long flags;
- struct net_device_stats *stats = &ieee->stats;
- int ether_type = 0, encrypt;
- int bytes, fc, qos_ctl = 0, hdr_len;
- struct sk_buff *skb_frag;
- struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */
- .duration_id = 0,
- .seq_ctl = 0,
- .qos_ctl = 0
- };
- u8 dest[ETH_ALEN], src[ETH_ALEN];
- int qos_actived = ieee->current_network.qos_data.active;
-
- struct ieee80211_crypt_data* crypt;
-
- cb_desc *tcb_desc;
-
- spin_lock_irqsave(&ieee->lock, flags);
-
- /* If there is no driver handler to take the TXB, dont' bother
- * creating it... */
- if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))||
- ((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) {
- printk(KERN_WARNING "%s: No xmit handler.\n",
- ieee->dev->name);
- goto success;
- }
-
-
- if(likely(ieee->raw_tx == 0)){
- if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
- printk(KERN_WARNING "%s: skb too small (%d).\n",
- ieee->dev->name, skb->len);
- goto success;
- }
-
- memset(skb->cb, 0, sizeof(skb->cb));
- ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
-
- crypt = ieee->crypt[ieee->tx_keyidx];
-
- encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
- ieee->host_encrypt && crypt && crypt->ops;
-
- if (!encrypt && ieee->ieee802_1x &&
- ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
- stats->tx_dropped++;
- goto success;
- }
- #ifdef CONFIG_IEEE80211_DEBUG
- if (crypt && !encrypt && ether_type == ETH_P_PAE) {
- struct eapol *eap = (struct eapol *)(skb->data +
- sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16));
- IEEE80211_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n",
- eap_get_type(eap->type));
- }
- #endif
-
- /* Save source and destination addresses */
- memcpy(&dest, skb->data, ETH_ALEN);
- memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
-
- /* Advance the SKB to the start of the payload */
- skb_pull(skb, sizeof(struct ethhdr));
-
- /* Determine total amount of storage required for TXB packets */
- bytes = skb->len + SNAP_SIZE + sizeof(u16);
-
- if (encrypt)
- fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_WEP;
- else
- fc = IEEE80211_FTYPE_DATA;
-
- if(qos_actived)
- fc |= IEEE80211_STYPE_QOS_DATA;
- else
- fc |= IEEE80211_STYPE_DATA;
-
- if (ieee->iw_mode == IW_MODE_INFRA) {
- fc |= IEEE80211_FCTL_TODS;
- /* To DS: Addr1 = BSSID, Addr2 = SA,
- Addr3 = DA */
- memcpy(&header.addr1, ieee->current_network.bssid, ETH_ALEN);
- memcpy(&header.addr2, &src, ETH_ALEN);
- memcpy(&header.addr3, &dest, ETH_ALEN);
- } else if (ieee->iw_mode == IW_MODE_ADHOC) {
- /* not From/To DS: Addr1 = DA, Addr2 = SA,
- Addr3 = BSSID */
- memcpy(&header.addr1, dest, ETH_ALEN);
- memcpy(&header.addr2, src, ETH_ALEN);
- memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
- }
-
- header.frame_ctl = cpu_to_le16(fc);
-
- /* Determine fragmentation size based on destination (multicast
- * and broadcast are not fragmented) */
- if (is_multicast_ether_addr(header.addr1) ||
- is_broadcast_ether_addr(header.addr1)) {
- frag_size = MAX_FRAG_THRESHOLD;
- qos_ctl |= QOS_CTL_NOTCONTAIN_ACK;
- }
- else {
- frag_size = ieee->fts;//default:392
- qos_ctl = 0;
- }
-
- //if (ieee->current_network.QoS_Enable)
- if(qos_actived)
- {
- hdr_len = IEEE80211_3ADDR_LEN + 2;
-
- skb->priority = ieee80211_classify(skb, &ieee->current_network);
- qos_ctl |= skb->priority; //set in the ieee80211_classify
- header.qos_ctl = cpu_to_le16(qos_ctl & IEEE80211_QOS_TID);
- } else {
- hdr_len = IEEE80211_3ADDR_LEN;
- }
- /* Determine amount of payload per fragment. Regardless of if
- * this stack is providing the full 802.11 header, one will
- * eventually be affixed to this fragment -- so we must account for
- * it when determining the amount of payload space. */
- bytes_per_frag = frag_size - hdr_len;
- if (ieee->config &
- (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
- bytes_per_frag -= IEEE80211_FCS_LEN;
-
- /* Each fragment may need to have room for encryptiong pre/postfix */
- if (encrypt)
- bytes_per_frag -= crypt->ops->extra_prefix_len +
- crypt->ops->extra_postfix_len;
-
- /* Number of fragments is the total bytes_per_frag /
- * payload_per_fragment */
- nr_frags = bytes / bytes_per_frag;
- bytes_last_frag = bytes % bytes_per_frag;
- if (bytes_last_frag)
- nr_frags++;
- else
- bytes_last_frag = bytes_per_frag;
-
- /* When we allocate the TXB we allocate enough space for the reserve
- * and full fragment bytes (bytes_per_frag doesn't include prefix,
- * postfix, header, FCS, etc.) */
- txb = ieee80211_alloc_txb(nr_frags, frag_size + ieee->tx_headroom, GFP_ATOMIC);
- if (unlikely(!txb)) {
- printk(KERN_WARNING "%s: Could not allocate TXB\n",
- ieee->dev->name);
- goto failed;
- }
- txb->encrypted = encrypt;
- txb->payload_size = bytes;
-
- if(qos_actived)
- {
- txb->queue_index = UP2AC(skb->priority);
- } else {
- txb->queue_index = WME_AC_BK;;
- }
-
-
-
- for (i = 0; i < nr_frags; i++) {
- skb_frag = txb->fragments[i];
- tcb_desc = (cb_desc *)(skb_frag->cb + MAX_DEV_ADDR_SIZE);
- if(qos_actived){
- skb_frag->priority = skb->priority;//UP2AC(skb->priority);
- tcb_desc->queue_index = UP2AC(skb->priority);
- } else {
- skb_frag->priority = WME_AC_BK;
- tcb_desc->queue_index = WME_AC_BK;
- }
- skb_reserve(skb_frag, ieee->tx_headroom);
-
- if (encrypt){
- if (ieee->hwsec_active)
- tcb_desc->bHwSec = 1;
- else
- tcb_desc->bHwSec = 0;
- skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
- }
- else
- {
- tcb_desc->bHwSec = 0;
- }
- frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
- memcpy(frag_hdr, &header, hdr_len);
-
- /* If this is not the last fragment, then add the MOREFRAGS
- * bit to the frame control */
- if (i != nr_frags - 1) {
- frag_hdr->frame_ctl = cpu_to_le16(
- fc | IEEE80211_FCTL_MOREFRAGS);
- bytes = bytes_per_frag;
-
- } else {
- /* The last fragment takes the remaining length */
- bytes = bytes_last_frag;
- }
- if(qos_actived)
- {
- // add 1 only indicate to corresponding seq number control 2006/7/12
- frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[UP2AC(skb->priority)+1]<<4 | i);
- } else {
- frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0]<<4 | i);
- }
-
- /* Put a SNAP header on the first fragment */
- if (i == 0) {
- ieee80211_put_snap(
- skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
- ether_type);
- bytes -= SNAP_SIZE + sizeof(u16);
- }
-
- memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
-
- /* Advance the SKB... */
- skb_pull(skb, bytes);
-
- /* Encryption routine will move the header forward in order
- * to insert the IV between the header and the payload */
- if (encrypt)
- ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
- if (ieee->config &
- (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
- skb_put(skb_frag, 4);
- }
-
- if(qos_actived)
- {
- if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF)
- ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0;
- else
- ieee->seq_ctrl[UP2AC(skb->priority) + 1]++;
- } else {
- if (ieee->seq_ctrl[0] == 0xFFF)
- ieee->seq_ctrl[0] = 0;
- else
- ieee->seq_ctrl[0]++;
- }
- }else{
- if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
- printk(KERN_WARNING "%s: skb too small (%d).\n",
- ieee->dev->name, skb->len);
- goto success;
- }
-
- txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
- if(!txb){
- printk(KERN_WARNING "%s: Could not allocate TXB\n",
- ieee->dev->name);
- goto failed;
- }
-
- txb->encrypted = 0;
- txb->payload_size = skb->len;
- memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
- }
-
- success:
-//WB add to fill data tcb_desc here. only first fragment is considered, need to change, and you may remove to other place.
- if (txb)
- {
-#if 1
- cb_desc *tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
- tcb_desc->bTxEnableFwCalcDur = 1;
- if (is_multicast_ether_addr(header.addr1))
- tcb_desc->bMulticast = 1;
- if (is_broadcast_ether_addr(header.addr1))
- tcb_desc->bBroadcast = 1;
- ieee80211_txrate_selectmode(ieee, tcb_desc);
- if ( tcb_desc->bMulticast || tcb_desc->bBroadcast)
- tcb_desc->data_rate = ieee->basic_rate;
- else
- tcb_desc->data_rate = CURRENT_RATE(ieee->mode, ieee->rate, ieee->HTCurrentOperaRate);
- ieee80211_qurey_ShortPreambleMode(ieee, tcb_desc);
- ieee80211_tx_query_agg_cap(ieee, txb->fragments[0], tcb_desc);
- ieee80211_query_HTCapShortGI(ieee, tcb_desc);
- ieee80211_query_BandwidthMode(ieee, tcb_desc);
- ieee80211_query_protectionmode(ieee, tcb_desc, txb->fragments[0]);
- ieee80211_query_seqnum(ieee, txb->fragments[0], header.addr1);
-#endif
- }
- spin_unlock_irqrestore(&ieee->lock, flags);
- dev_kfree_skb_any(skb);
- if (txb) {
- if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
- ieee80211_softmac_xmit(txb, ieee);
- }else{
- if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
- stats->tx_packets++;
- stats->tx_bytes += txb->payload_size;
- return 0;
- }
- ieee80211_txb_free(txb);
- }
- }
-
- return 0;
-
- failed:
- spin_unlock_irqrestore(&ieee->lock, flags);
- netif_stop_queue(dev);
- stats->tx_errors++;
- return 1;
-
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
deleted file mode 100644
index 984a3608561c..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
+++ /dev/null
@@ -1,772 +0,0 @@
-/******************************************************************************
-
- Copyright(c) 2004 Intel Corporation. All rights reserved.
-
- Portions of this file are based on the WEP enablement code provided by the
- Host AP project hostap-drivers v0.1.3
- Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- <jkmaline@cc.hut.fi>
- Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of version 2 of the GNU General Public License as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- more details.
-
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc., 59
- Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- The full GNU General Public License is included in this distribution in the
- file called LICENSE.
-
- Contact Information:
- James P. Ketrenos <ipw2100-admin@linux.intel.com>
- Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
-
-******************************************************************************/
-#include <linux/wireless.h>
-#include <linux/kmod.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-
-#include "ieee80211.h"
-
-struct modes_unit {
- char *mode_string;
- int mode_size;
-};
-struct modes_unit ieee80211_modes[] = {
- {"a",1},
- {"b",1},
- {"g",1},
- {"?",1},
- {"N-24G",5},
- {"N-5G",4},
-};
-
-#define iwe_stream_add_event_rsl iwe_stream_add_event
-
-#define MAX_CUSTOM_LEN 64
-static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,
- char *start, char *stop,
- struct ieee80211_network *network,
- struct iw_request_info *info)
-{
- char custom[MAX_CUSTOM_LEN];
- char proto_name[IFNAMSIZ];
- char *pname = proto_name;
- char *p;
- struct iw_event iwe;
- int i, j;
- u16 max_rate, rate;
- static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
-
- /* First entry *MUST* be the AP MAC address */
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
- memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_ADDR_LEN);
-
- /* Remaining entries will be displayed in the order we provide them */
-
- /* Add the ESSID */
- iwe.cmd = SIOCGIWESSID;
- iwe.u.data.flags = 1;
- if (network->ssid_len == 0) {
- iwe.u.data.length = sizeof("<hidden>");
- start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>");
- } else {
- iwe.u.data.length = min(network->ssid_len, (u8)32);
- start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
- }
- /* Add the protocol name */
- iwe.cmd = SIOCGIWNAME;
- for(i=0; i<ARRAY_SIZE(ieee80211_modes); i++) {
- if(network->mode&(1<<i)) {
- sprintf(pname,ieee80211_modes[i].mode_string,ieee80211_modes[i].mode_size);
- pname +=ieee80211_modes[i].mode_size;
- }
- }
- *pname = '\0';
- snprintf(iwe.u.name, IFNAMSIZ, "IEEE802.11%s", proto_name);
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_CHAR_LEN);
- /* Add mode */
- iwe.cmd = SIOCGIWMODE;
- if (network->capability &
- (WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) {
- if (network->capability & WLAN_CAPABILITY_BSS)
- iwe.u.mode = IW_MODE_MASTER;
- else
- iwe.u.mode = IW_MODE_ADHOC;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_UINT_LEN);
- }
-
- /* Add frequency/channel */
- iwe.cmd = SIOCGIWFREQ;
-/* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
- iwe.u.freq.e = 3; */
- iwe.u.freq.m = network->channel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_FREQ_LEN);
- /* Add encryption capability */
- iwe.cmd = SIOCGIWENCODE;
- if (network->capability & WLAN_CAPABILITY_PRIVACY)
- iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- else
- iwe.u.data.flags = IW_ENCODE_DISABLED;
- iwe.u.data.length = 0;
- start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
- /* Add basic and extended rates */
- max_rate = 0;
- p = custom;
- p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
- for (i = 0, j = 0; i < network->rates_len; ) {
- if (j < network->rates_ex_len &&
- ((network->rates_ex[j] & 0x7F) <
- (network->rates[i] & 0x7F)))
- rate = network->rates_ex[j++] & 0x7F;
- else
- rate = network->rates[i++] & 0x7F;
- if (rate > max_rate)
- max_rate = rate;
- p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
- "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
- }
- for (; j < network->rates_ex_len; j++) {
- rate = network->rates_ex[j] & 0x7F;
- p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
- "%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
- if (rate > max_rate)
- max_rate = rate;
- }
-
- if (network->mode >= IEEE_N_24G)//add N rate here;
- {
- PHT_CAPABILITY_ELE ht_cap = NULL;
- bool is40M = false, isShortGI = false;
- u8 max_mcs = 0;
- if (!memcmp(network->bssht.bdHTCapBuf, EWC11NHTCap, 4))
- ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[4];
- else
- ht_cap = (PHT_CAPABILITY_ELE)&network->bssht.bdHTCapBuf[0];
- is40M = (ht_cap->ChlWidth)?1:0;
- isShortGI = (ht_cap->ChlWidth)?
- ((ht_cap->ShortGI40Mhz)?1:0):
- ((ht_cap->ShortGI20Mhz)?1:0);
-
- max_mcs = HTGetHighestMCSRate(ieee, ht_cap->MCS, MCS_FILTER_ALL);
- rate = MCS_DATA_RATE[is40M][isShortGI][max_mcs&0x7f];
- if (rate > max_rate)
- max_rate = rate;
- }
-
- iwe.cmd = SIOCGIWRATE;
- iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
- iwe.u.bitrate.value = max_rate * 500000;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe,
- IW_EV_PARAM_LEN);
-
- iwe.cmd = IWEVCUSTOM;
- iwe.u.data.length = p - custom;
- if (iwe.u.data.length)
- start = iwe_stream_add_point(info, start, stop, &iwe, custom);
-
- /* Add quality statistics */
- /* TODO: Fix these values... */
- iwe.cmd = IWEVQUAL;
- iwe.u.qual.qual = network->stats.signal;
- iwe.u.qual.level = network->stats.rssi;
- iwe.u.qual.noise = network->stats.noise;
- iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK;
- if (!(network->stats.mask & IEEE80211_STATMASK_RSSI))
- iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
- if (!(network->stats.mask & IEEE80211_STATMASK_NOISE))
- iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
- if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
- iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
- iwe.u.qual.updated = 7;
- start = iwe_stream_add_event_rsl(info, start, stop, &iwe, IW_EV_QUAL_LEN);
- iwe.cmd = IWEVCUSTOM;
- p = custom;
-
- iwe.u.data.length = p - custom;
- if (iwe.u.data.length)
- start = iwe_stream_add_point(info, start, stop, &iwe, custom);
-
- memset(&iwe, 0, sizeof(iwe));
- if (network->wpa_ie_len)
- {
- char buf[MAX_WPA_IE_LEN];
- memcpy(buf, network->wpa_ie, network->wpa_ie_len);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = network->wpa_ie_len;
- start = iwe_stream_add_point(info, start, stop, &iwe, buf);
- }
- memset(&iwe, 0, sizeof(iwe));
- if (network->rsn_ie_len)
- {
- char buf[MAX_WPA_IE_LEN];
- memcpy(buf, network->rsn_ie, network->rsn_ie_len);
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = network->rsn_ie_len;
- start = iwe_stream_add_point(info, start, stop, &iwe, buf);
- }
-
- /* Add EXTRA: Age to display seconds since last beacon/probe response
- * for given network. */
- iwe.cmd = IWEVCUSTOM;
- p = custom;
- p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
- " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100));
- iwe.u.data.length = p - custom;
- if (iwe.u.data.length)
- start = iwe_stream_add_point(info, start, stop, &iwe, custom);
-
- return start;
-}
-
-int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct ieee80211_network *network;
- unsigned long flags;
-
- char *ev = extra;
- char *stop = ev + wrqu->data.length;//IW_SCAN_MAX_DATA;
- int i = 0;
- int err = 0;
- IEEE80211_DEBUG_WX("Getting scan\n");
- down(&ieee->wx_sem);
- spin_lock_irqsave(&ieee->lock, flags);
-
- list_for_each_entry(network, &ieee->network_list, list) {
- i++;
- if((stop-ev)<200)
- {
- err = -E2BIG;
- break;
- }
- if (ieee->scan_age == 0 ||
- time_after(network->last_scanned + ieee->scan_age, jiffies))
- ev = rtl819x_translate_scan(ieee, ev, stop, network, info);
- else
- IEEE80211_DEBUG_SCAN(
- "Not showing network '%s ("
- "%pM)' due to age (%lums).\n",
- escape_essid(network->ssid,
- network->ssid_len),
- network->bssid,
- (jiffies - network->last_scanned) / (HZ / 100));
- }
-
- spin_unlock_irqrestore(&ieee->lock, flags);
- up(&ieee->wx_sem);
- wrqu->data.length = ev - extra;
- wrqu->data.flags = 0;
-
- IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i);
-
- return err;
-}
-
-int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *keybuf)
-{
- struct iw_point *erq = &(wrqu->encoding);
- struct net_device *dev = ieee->dev;
- struct ieee80211_security sec = {
- .flags = 0
- };
- int i, key, key_provided, len;
- struct ieee80211_crypt_data **crypt;
-
- IEEE80211_DEBUG_WX("SET_ENCODE\n");
-
- key = erq->flags & IW_ENCODE_INDEX;
- if (key) {
- if (key > WEP_KEYS)
- return -EINVAL;
- key--;
- key_provided = 1;
- } else {
- key_provided = 0;
- key = ieee->tx_keyidx;
- }
-
- IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
- "provided" : "default");
- crypt = &ieee->crypt[key];
-
- if (erq->flags & IW_ENCODE_DISABLED) {
- if (key_provided && *crypt) {
- IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
- key);
- ieee80211_crypt_delayed_deinit(ieee, crypt);
- } else
- IEEE80211_DEBUG_WX("Disabling encryption.\n");
-
- /* Check all the keys to see if any are still configured,
- * and if no key index was provided, de-init them all */
- for (i = 0; i < WEP_KEYS; i++) {
- if (ieee->crypt[i] != NULL) {
- if (key_provided)
- break;
- ieee80211_crypt_delayed_deinit(
- ieee, &ieee->crypt[i]);
- }
- }
-
- if (i == WEP_KEYS) {
- sec.enabled = 0;
- sec.level = SEC_LEVEL_0;
- sec.flags |= SEC_ENABLED | SEC_LEVEL;
- }
-
- goto done;
- }
-
-
-
- sec.enabled = 1;
- sec.flags |= SEC_ENABLED;
-
- if (*crypt != NULL && (*crypt)->ops != NULL &&
- strcmp((*crypt)->ops->name, "WEP") != 0) {
- /* changing to use WEP; deinit previously used algorithm
- * on this key */
- ieee80211_crypt_delayed_deinit(ieee, crypt);
- }
-
- if (*crypt == NULL) {
- struct ieee80211_crypt_data *new_crypt;
-
- /* take WEP into use */
- new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
- GFP_KERNEL);
- if (new_crypt == NULL)
- return -ENOMEM;
- new_crypt->ops = ieee80211_get_crypto_ops("WEP");
- if (!new_crypt->ops)
- new_crypt->ops = ieee80211_get_crypto_ops("WEP");
- if (new_crypt->ops)
- new_crypt->priv = new_crypt->ops->init(key);
-
- if (!new_crypt->ops || !new_crypt->priv) {
- kfree(new_crypt);
- new_crypt = NULL;
-
- printk(KERN_WARNING "%s: could not initialize WEP: "
- "load module ieee80211_crypt_wep\n",
- dev->name);
- return -EOPNOTSUPP;
- }
- *crypt = new_crypt;
- }
-
- /* If a new key was provided, set it up */
- if (erq->length > 0) {
- len = erq->length <= 5 ? 5 : 13;
- memcpy(sec.keys[key], keybuf, erq->length);
- if (len > erq->length)
- memset(sec.keys[key] + erq->length, 0,
- len - erq->length);
- IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
- key, escape_essid(sec.keys[key], len),
- erq->length, len);
- sec.key_sizes[key] = len;
- (*crypt)->ops->set_key(sec.keys[key], len, NULL,
- (*crypt)->priv);
- sec.flags |= (1 << key);
- /* This ensures a key will be activated if no key is
- * explicitely set */
- if (key == sec.active_key)
- sec.flags |= SEC_ACTIVE_KEY;
- ieee->tx_keyidx = key;
-
- } else {
- len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN,
- NULL, (*crypt)->priv);
- if (len == 0) {
- /* Set a default key of all 0 */
- printk("Setting key %d to all zero.\n",
- key);
-
- IEEE80211_DEBUG_WX("Setting key %d to all zero.\n",
- key);
- memset(sec.keys[key], 0, 13);
- (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
- (*crypt)->priv);
- sec.key_sizes[key] = 13;
- sec.flags |= (1 << key);
- }
-
- /* No key data - just set the default TX key index */
- if (key_provided) {
- IEEE80211_DEBUG_WX(
- "Setting key %d to default Tx key.\n", key);
- ieee->tx_keyidx = key;
- sec.active_key = key;
- sec.flags |= SEC_ACTIVE_KEY;
- }
- }
-
- done:
- ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED);
- ieee->auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
- sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
- sec.flags |= SEC_AUTH_MODE;
- IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
- "OPEN" : "SHARED KEY");
-
- /* For now we just support WEP, so only set that security level...
- * TODO: When WPA is added this is one place that needs to change */
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
-
- if (ieee->set_security)
- ieee->set_security(dev, &sec);
-
- /* Do not reset port if card is in Managed mode since resetting will
- * generate new IEEE 802.11 authentication which may end up in looping
- * with IEEE 802.1X. If your hardware requires a reset after WEP
- * configuration (for example... Prism2), implement the reset_port in
- * the callbacks structures used to initialize the 802.11 stack. */
- if (ieee->reset_on_keychange &&
- ieee->iw_mode != IW_MODE_INFRA &&
- ieee->reset_port && ieee->reset_port(dev)) {
- printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
- return -EINVAL;
- }
- return 0;
-}
-
-int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *keybuf)
-{
- struct iw_point *erq = &(wrqu->encoding);
- int len, key;
- struct ieee80211_crypt_data *crypt;
-
- IEEE80211_DEBUG_WX("GET_ENCODE\n");
-
- if(ieee->iw_mode == IW_MODE_MONITOR)
- return -1;
-
- key = erq->flags & IW_ENCODE_INDEX;
- if (key) {
- if (key > WEP_KEYS)
- return -EINVAL;
- key--;
- } else
- key = ieee->tx_keyidx;
-
- crypt = ieee->crypt[key];
- erq->flags = key + 1;
-
- if (crypt == NULL || crypt->ops == NULL) {
- erq->length = 0;
- erq->flags |= IW_ENCODE_DISABLED;
- return 0;
- }
-
- len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
- erq->length = (len >= 0 ? len : 0);
-
- erq->flags |= IW_ENCODE_ENABLED;
-
- if (ieee->open_wep)
- erq->flags |= IW_ENCODE_OPEN;
- else
- erq->flags |= IW_ENCODE_RESTRICTED;
-
- return 0;
-}
-
-int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret = 0;
- struct net_device *dev = ieee->dev;
- struct iw_point *encoding = &wrqu->encoding;
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- int i, idx;
- int group_key = 0;
- const char *alg;
- struct ieee80211_crypto_ops *ops;
- struct ieee80211_crypt_data **crypt;
-
- struct ieee80211_security sec = {
- .flags = 0,
- };
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx) {
- if (idx < 1 || idx > WEP_KEYS)
- return -EINVAL;
- idx--;
- } else
- idx = ieee->tx_keyidx;
-
- if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-
- crypt = &ieee->crypt[idx];
-
- group_key = 1;
- } else {
- /* some Cisco APs use idx>0 for unicast in dynamic WEP */
- //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg);
- if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP)
- return -EINVAL;
- if (ieee->iw_mode == IW_MODE_INFRA)
-
- crypt = &ieee->crypt[idx];
-
- else
- return -EINVAL;
- }
-
- sec.flags |= SEC_ENABLED;
-
- if ((encoding->flags & IW_ENCODE_DISABLED) ||
- ext->alg == IW_ENCODE_ALG_NONE) {
- if (*crypt)
- ieee80211_crypt_delayed_deinit(ieee, crypt);
-
- for (i = 0; i < WEP_KEYS; i++)
-
- if (ieee->crypt[i] != NULL)
-
- break;
-
- if (i == WEP_KEYS) {
- sec.enabled = 0;
- // sec.encrypt = 0;
- sec.level = SEC_LEVEL_0;
- sec.flags |= SEC_LEVEL;
- }
- //printk("disabled: flag:%x\n", encoding->flags);
- goto done;
- }
-
- sec.enabled = 1;
-
- switch (ext->alg) {
- case IW_ENCODE_ALG_WEP:
- alg = "WEP";
- break;
- case IW_ENCODE_ALG_TKIP:
- alg = "TKIP";
- break;
- case IW_ENCODE_ALG_CCMP:
- alg = "CCMP";
- break;
- default:
- IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
- dev->name, ext->alg);
- ret = -EINVAL;
- goto done;
- }
- IEEE80211_DEBUG_WX("alg name: %s\n", alg);
-
- ops = ieee80211_get_crypto_ops(alg);
- if (ops == NULL)
- ops = ieee80211_get_crypto_ops(alg);
- if (ops == NULL) {
- IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
- dev->name, ext->alg);
- printk("========>unknown crypto alg %d\n", ext->alg);
- ret = -EINVAL;
- goto done;
- }
-
- if (*crypt == NULL || (*crypt)->ops != ops) {
- struct ieee80211_crypt_data *new_crypt;
-
- ieee80211_crypt_delayed_deinit(ieee, crypt);
-
- new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL) {
- ret = -ENOMEM;
- goto done;
- }
- new_crypt->ops = ops;
- if (new_crypt->ops)
- new_crypt->priv = new_crypt->ops->init(idx);
- if (new_crypt->priv == NULL) {
- kfree(new_crypt);
- ret = -EINVAL;
- goto done;
- }
- *crypt = new_crypt;
-
- }
-
- if (ext->key_len > 0 && (*crypt)->ops->set_key &&
- (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
- (*crypt)->priv) < 0) {
- IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name);
- printk("key setting failed\n");
- ret = -EINVAL;
- goto done;
- }
-#if 1
- if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
- ieee->tx_keyidx = idx;
- sec.active_key = idx;
- sec.flags |= SEC_ACTIVE_KEY;
- }
-
- if (ext->alg != IW_ENCODE_ALG_NONE) {
- sec.key_sizes[idx] = ext->key_len;
- sec.flags |= (1 << idx);
- if (ext->alg == IW_ENCODE_ALG_WEP) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_1;
- } else if (ext->alg == IW_ENCODE_ALG_TKIP) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_2;
- } else if (ext->alg == IW_ENCODE_ALG_CCMP) {
- sec.flags |= SEC_LEVEL;
- sec.level = SEC_LEVEL_3;
- }
- /* Don't set sec level for group keys. */
- if (group_key)
- sec.flags &= ~SEC_LEVEL;
- }
-#endif
-done:
- if (ieee->set_security)
- ieee->set_security(ieee->dev, &sec);
-
- if (ieee->reset_on_keychange &&
- ieee->iw_mode != IW_MODE_INFRA &&
- ieee->reset_port && ieee->reset_port(dev)) {
- IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
- return -EINVAL;
- }
-
- return ret;
-}
-
-int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct iw_mlme *mlme = (struct iw_mlme *) extra;
-
- switch (mlme->cmd) {
- case IW_MLME_DEAUTH:
- case IW_MLME_DISASSOC:
- ieee80211_disassociate(ieee);
- break;
- default:
- return -EOPNOTSUPP;
- }
-
- return 0;
-}
-
-int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
- struct iw_request_info *info,
- struct iw_param *data, char *extra)
-{
- switch (data->flags & IW_AUTH_INDEX) {
- case IW_AUTH_WPA_VERSION:
- /*need to support wpa2 here*/
- break;
- case IW_AUTH_CIPHER_PAIRWISE:
- case IW_AUTH_CIPHER_GROUP:
- case IW_AUTH_KEY_MGMT:
- /*
- * * Host AP driver does not use these parameters and allows
- * * wpa_supplicant to control them internally.
- * */
- break;
- case IW_AUTH_TKIP_COUNTERMEASURES:
- ieee->tkip_countermeasures = data->value;
- break;
- case IW_AUTH_DROP_UNENCRYPTED:
- ieee->drop_unencrypted = data->value;
- break;
-
- case IW_AUTH_80211_AUTH_ALG:
- if(data->value & IW_AUTH_ALG_SHARED_KEY){
- ieee->open_wep = 0;
- ieee->auth_mode = 1;
- }
- else if(data->value & IW_AUTH_ALG_OPEN_SYSTEM){
- ieee->open_wep = 1;
- ieee->auth_mode = 0;
- }
- else if(data->value & IW_AUTH_ALG_LEAP){
- ieee->open_wep = 1;
- ieee->auth_mode = 2;
- }
- else
- return -EINVAL;
- break;
-
-#if 1
- case IW_AUTH_WPA_ENABLED:
- ieee->wpa_enabled = (data->value)?1:0;
- break;
-
-#endif
- case IW_AUTH_RX_UNENCRYPTED_EAPOL:
- ieee->ieee802_1x = data->value;
- break;
- case IW_AUTH_PRIVACY_INVOKED:
- ieee->privacy_invoked = data->value;
- break;
- default:
- return -EOPNOTSUPP;
- }
-
- return 0;
-}
-
-#if 1
-int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
-{
- u8 *buf;
-
- if (len>MAX_WPA_IE_LEN || (len && ie == NULL))
- {
- return -EINVAL;
- }
-
-
- if (len)
- {
- if (len != ie[1]+2)
- {
- printk("len: %Zd, ie:%d\n", len, ie[1]);
- return -EINVAL;
- }
- buf = kmemdup(ie, len, GFP_KERNEL);
- if (buf == NULL)
- return -ENOMEM;
- kfree(ieee->wpa_ie);
- ieee->wpa_ie = buf;
- ieee->wpa_ie_len = len;
- }
- else{
- if (ieee->wpa_ie)
- kfree(ieee->wpa_ie);
- ieee->wpa_ie = NULL;
- ieee->wpa_ie_len = 0;
- }
-
- return 0;
-
-}
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/readme b/drivers/staging/rtl8192su/ieee80211/readme
deleted file mode 100644
index 7ba177ba3e33..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/readme
+++ /dev/null
@@ -1,162 +0,0 @@
-What this layer should do
-
-- It mantain the old mechanism as alternative, so the
- ipw2100 driver works with really few changes.
-- Encapsulate / Decapsulate ieee80211 packet
-- Handle fragmentation
-- Optionally provide an alterantive mechanism for netif queue stop/wake,
- so that the ieee80211 layer will pass one fragment per time instead of
- one txb struct per time. so the driver can stop the queue in the middle
- of a packet.
-- Provide two different TX interfaces for cards that can handle management
- frames on one HW queue, and data on another, and for cards that have only
- one HW queue (the latter untested and very, very rough).
-- Optionally provide the logic for handling IBSS/MASTER/MONITOR/BSS modes
- and for the channel, essid and wap get/set wireless extension requests.
- so that the driver has only to change channel when the ieee stack tell it.
-- Optionally provide a scanning mechanism so that the driver has not to
- worry about this, just implement the set channel calback and pass
- frames to the upper layer
-- Optionally provide the bss client protocol handshaking (just with open
- authentication)
-- Optionally provide the probe request send mechanism
-- Optionally provide the bss master mode logic to handle association
- protocol (only open authentication) and probe responses.
-- SW wep encryption (with open authentication)
-- It collects some stats
-- It provides beacons to the card when it ask for them
-
-What this layer doesn't do (yet)
-- Perform shared authentication
-- Have full support for master mode (the AP should loop back in the air
- frames from an associated client to another. This could be done easily
- with few lines of code, and it is done in my previous version of the
- stach, but a table of association must be keept and a disassociation
- policy must be decided and implemented.
-- Handle cleanly the full ieee 802.11 protocol. In AP mode it never
- disassociate clients, and it is really prone to always allow access.
- In bss client mode it is a bit rough with AP deauth and disassoc requests.
-- It has not any entry point to view the collected stats.
-- Although it takes care of the card supported rates in the management frame
- it sends, support for rate changing on TXed packet is not complete.
-- Give up once associated in bss client mode (it never detect a
- signal loss condition to disassociate and restart scanning)
-- Provide a mechanism for enabling the TX in monitor mode, so
- userspace programs can TX raw packets.
-- Provide a mechanism for cards that need that the SW take care of beacon
- TX completely, in sense that the SW has to enqueue by itself beacons
- to the card so it TX them (if any...)
-APIs
-
-Callback functions in the original stack has been mantained.
-following has been added (from ieee80211.h)
-
- /* Softmac-generated frames (mamagement) are TXed via this
- * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
- * not set. As some cards may have different HW queues that
- * one might want to use for data and management frames
- * the option to have two callbacks might be useful.
- * This fucntion can't sleep.
- */
- int (*softmac_hard_start_xmit)(struct sk_buff *skb,
- struct net_device *dev);
-
- /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
- * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
- * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
- * then also management frames are sent via this callback.
- * This function can't sleep.
- */
- void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
- struct net_device *dev);
-
- /* stops the HW queue for DATA frames. Useful to avoid
- * waste time to TX data frame when we are reassociating
- * This function can sleep.
- */
- void (*data_hard_stop)(struct net_device *dev);
-
- /* OK this is complementar to data_poll_hard_stop */
- void (*data_hard_resume)(struct net_device *dev);
-
- /* ask to the driver to retune the radio .
- * This function can sleep. the driver should ensure
- * the radio has been swithced before return.
- */
- void (*set_chan)(struct net_device *dev,short ch);
-
- /* These are not used if the ieee stack takes care of
- * scanning (IEEE_SOFTMAC_SCAN feature set).
- * In this case only the set_chan is used.
- *
- * The syncro version is similar to the start_scan but
- * does not return until all channels has been scanned.
- * this is called in user context and should sleep,
- * it is called in a work_queue when swithcing to ad-hoc mode
- * or in behalf of iwlist scan when the card is associated
- * and root user ask for a scan.
- * the fucntion stop_scan should stop both the syncro and
- * background scanning and can sleep.
- * The fucntion start_scan should initiate the background
- * scanning and can't sleep.
- */
- void (*scan_syncro)(struct net_device *dev);
- void (*start_scan)(struct net_device *dev);
- void (*stop_scan)(struct net_device *dev);
-
- /* indicate the driver that the link state is changed
- * for example it may indicate the card is associated now.
- * Driver might be interested in this to apply RX filter
- * rules or simply light the LINK led
- */
- void (*link_change)(struct net_device *dev);
-
-Functions hard_data_[resume/stop] are optional and should not be used
-if the driver decides to uses data+management frames enqueue in a
-single HQ queue (thus using just the softmac_hard_data_start_xmit
-callback).
-
-Function that the driver can use are:
-
-ieee80211_get_beacon - this is called by the driver when
- the HW needs a beacon.
-ieee80211_softmac_start_protocol - this should normally be called in the
- driver open function
-ieee80211_softmac_stop_protocol - the opposite of the above
-ieee80211_wake_queue - this is similar to netif_wake_queue
-ieee80211_reset_queue - this throw away fragments pending(if any)
-ieee80211_stop_queue - this is similar to netif_stop_queue
-
-
-known BUGS:
-- When performing syncro scan (possiblily when swithcing to ad-hoc mode
- and when running iwlist scan when associated) there is still an odd
- behaviour.. I have not looked in this more accurately (yet).
-
-locking:
-locking is done by means of three structures.
-1- ieee->lock (by means of spin_[un]lock_irq[save/restore]
-2- ieee->wx_sem
-3- ieee->scan_sem
-
-the lock 1 is what protect most of the critical sections in the ieee stack.
-the lock 2 is used to avoid that more than one of the SET wireless extension
-handlers (as well as start/stop protocol function) are running at the same time.
-the lock 1 is used when we need to modify or read the shared data in the wx handlers.
-In other words the lock 2 will prevent one SET action will run across another SET
-action (by make sleep the 2nd one) but allow GET actions, while the lock 1
-make atomic those little shared data access in both GET and SET operation.
-So get operation will be never be delayed really: they will never sleep..
-Furthermore in the top of some SET operations a flag is set before acquiring
-the lock. This is an help to make the previous running SET operation to
-finish faster if needed (just in case the second one will totally undo the
-first, so there is not need to complete the 1st really.. ).
-The background scanning mechaninsm is protected by the lock 1 except for the
-workqueue. this wq is here just to let the set_chan callback sleep (I thinked it
-might be appreciated by USB network card driver developer). In this case the lock 3
-take its turn.
-Thus the stop function needs both the locks.
-Funny in the syncro scan the lock 2 play its role (as both the syncro_scan
-function and the stop scan function are called with this semaphore held).
-
-
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h
deleted file mode 100644
index 1c2a40b75a19..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_BA.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef _BATYPE_H_
-#define _BATYPE_H_
-
-#define TOTAL_TXBA_NUM 16
-#define TOTAL_RXBA_NUM 16
-
-#define BA_SETUP_TIMEOUT 200
-#define BA_INACT_TIMEOUT 60000
-
-#define BA_POLICY_DELAYED 0
-#define BA_POLICY_IMMEDIATE 1
-
-#define ADDBA_STATUS_SUCCESS 0
-#define ADDBA_STATUS_REFUSED 37
-#define ADDBA_STATUS_INVALID_PARAM 38
-
-#define DELBA_REASON_QSTA_LEAVING 36
-#define DELBA_REASON_END_BA 37
-#define DELBA_REASON_UNKNOWN_BA 38
-#define DELBA_REASON_TIMEOUT 39
-
-typedef union _SEQUENCE_CONTROL{
- u16 ShortData;
- struct
- {
- u16 FragNum:4;
- u16 SeqNum:12;
- }field;
-}SEQUENCE_CONTROL, *PSEQUENCE_CONTROL;
-
-typedef union _BA_PARAM_SET {
- u8 charData[2];
- u16 shortData;
- struct {
- u16 AMSDU_Support:1;
- u16 BAPolicy:1;
- u16 TID:4;
- u16 BufferSize:10;
- } field;
-} BA_PARAM_SET, *PBA_PARAM_SET;
-
-typedef union _DELBA_PARAM_SET {
- u8 charData[2];
- u16 shortData;
- struct {
- u16 Reserved:11;
- u16 Initiator:1;
- u16 TID:4;
- } field;
-} DELBA_PARAM_SET, *PDELBA_PARAM_SET;
-
-typedef struct _BA_RECORD {
- struct timer_list Timer;
- u8 bValid;
- u8 DialogToken;
- BA_PARAM_SET BaParamSet;
- u16 BaTimeoutValue;
- SEQUENCE_CONTROL BaStartSeqCtrl;
-} BA_RECORD, *PBA_RECORD;
-
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
deleted file mode 100644
index ca611faf17bc..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_BAProc.c
+++ /dev/null
@@ -1,745 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "ieee80211.h"
-#include "rtl819x_BA.h"
-
-/********************************************************************************************************************
- *function: Activate BA entry. And if Time is nozero, start timer.
- * input: PBA_RECORD pBA //BA entry to be enabled
- * u16 Time //indicate time delay.
- * output: none
-********************************************************************************************************************/
-void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
-{
- pBA->bValid = true;
- if(Time != 0)
- mod_timer(&pBA->Timer, jiffies + MSECS(Time));
-}
-
-/********************************************************************************************************************
- *function: deactivate BA entry, including its timer.
- * input: PBA_RECORD pBA //BA entry to be disabled
- * output: none
-********************************************************************************************************************/
-void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
-{
- pBA->bValid = false;
- del_timer_sync(&pBA->Timer);
-}
-/********************************************************************************************************************
- *function: deactivete BA entry in Tx Ts, and send DELBA.
- * input:
- * PTX_TS_RECORD pTxTs //Tx Ts which is to deactivate BA entry.
- * output: none
- * notice: As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
-********************************************************************************************************************/
-u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs)
-{
- PBA_RECORD pAdmittedBa = &pTxTs->TxAdmittedBARecord; //These two BA entries must exist in TS structure
- PBA_RECORD pPendingBa = &pTxTs->TxPendingBARecord;
- u8 bSendDELBA = false;
-
- // Delete pending BA
- if(pPendingBa->bValid)
- {
- DeActivateBAEntry(ieee, pPendingBa);
- bSendDELBA = true;
- }
-
- // Delete admitted BA
- if(pAdmittedBa->bValid)
- {
- DeActivateBAEntry(ieee, pAdmittedBa);
- bSendDELBA = true;
- }
-
- return bSendDELBA;
-}
-
-/********************************************************************************************************************
- *function: deactivete BA entry in Tx Ts, and send DELBA.
- * input:
- * PRX_TS_RECORD pRxTs //Rx Ts which is to deactivate BA entry.
- * output: none
- * notice: As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above
-********************************************************************************************************************/
-u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs)
-{
- PBA_RECORD pBa = &pRxTs->RxAdmittedBARecord;
- u8 bSendDELBA = false;
-
- if(pBa->bValid)
- {
- DeActivateBAEntry(ieee, pBa);
- bSendDELBA = true;
- }
-
- return bSendDELBA;
-}
-
-/********************************************************************************************************************
- *function: reset BA entry
- * input:
- * PBA_RECORD pBA //entry to be reset
- * output: none
-********************************************************************************************************************/
-void ResetBaEntry( PBA_RECORD pBA)
-{
- pBA->bValid = false;
- pBA->BaParamSet.shortData = 0;
- pBA->BaTimeoutValue = 0;
- pBA->DialogToken = 0;
- pBA->BaStartSeqCtrl.ShortData = 0;
-}
-//These functions need porting here or not?
-/*******************************************************************************************************************************
- *function: construct ADDBAREQ and ADDBARSP frame here together.
- * input: u8* Dst //ADDBA frame's destination
- * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA.
- * u16 StatusCode //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
- * u8 type //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
- * output: none
- * return: sk_buff* skb //return constructed skb to xmit
-*******************************************************************************************************************************/
-static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
-{
- struct sk_buff *skb = NULL;
- struct ieee80211_hdr_3addr* BAReq = NULL;
- u8* tag = NULL;
- u16 tmp = 0;
- u16 len = ieee->tx_headroom + 9;
- IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), frame(%d) sentd to:%pM, ieee->dev:%p\n", __FUNCTION__, type, Dst, ieee->dev);
- if (pBA == NULL||ieee == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA(%p) is NULL or ieee(%p) is NULL\n", pBA, ieee);
- return NULL;
- }
- skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
- if (skb == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
- return NULL;
- }
-
- memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
- skb_reserve(skb, ieee->tx_headroom);
-
- BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
-
- memcpy(BAReq->addr1, Dst, ETH_ALEN);
- memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
-
- memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
-
- BAReq->frame_control = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
-
- tag = (u8*)skb_put(skb, 9);
- *tag ++= ACT_CAT_BA;
- *tag ++= type;
- // Dialog Token
- *tag ++= pBA->DialogToken;
-
- if (ACT_ADDBARSP == type)
- {
- // Status Code
- printk("=====>to send ADDBARSP\n");
- tmp = cpu_to_le16(StatusCode);
- memcpy(tag, (u8*)&tmp, 2);
- tag += 2;
- }
- // BA Parameter Set
- tmp = cpu_to_le16(pBA->BaParamSet.shortData);
- memcpy(tag, (u8*)&tmp, 2);
- tag += 2;
- // BA Timeout Value
- tmp = cpu_to_le16(pBA->BaTimeoutValue);
- memcpy(tag, (u8*)&tmp, 2);
- tag += 2;
-
- if (ACT_ADDBAREQ == type)
- {
- // BA Start SeqCtrl
- memcpy(tag,(u8*)&(pBA->BaStartSeqCtrl), 2);
- tag += 2;
- }
-
- IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- return skb;
-}
-
-/********************************************************************************************************************
- *function: construct DELBA frame
- * input: u8* dst //DELBA frame's destination
- * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
- * TR_SELECT TxRxSelect //TX RX direction
- * u16 ReasonCode //status code.
- * output: none
- * return: sk_buff* skb //return constructed skb to xmit
-********************************************************************************************************************/
-static struct sk_buff* ieee80211_DELBA(
- struct ieee80211_device* ieee,
- u8* dst,
- PBA_RECORD pBA,
- TR_SELECT TxRxSelect,
- u16 ReasonCode
- )
-{
- DELBA_PARAM_SET DelbaParamSet;
- struct sk_buff *skb = NULL;
- struct ieee80211_hdr_3addr* Delba = NULL;
- u8* tag = NULL;
- u16 tmp = 0;
- u16 len = 6 + ieee->tx_headroom;
-
- if (net_ratelimit())
- IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "========>%s(), ReasonCode(%d) sentd to:%pM\n", __FUNCTION__, ReasonCode, dst);
-
- memset(&DelbaParamSet, 0, 2);
-
- DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
- DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
-
- skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
- if (skb == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
- return NULL;
- }
- skb_reserve(skb, ieee->tx_headroom);
-
- Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
-
- memcpy(Delba->addr1, dst, ETH_ALEN);
- memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
- Delba->frame_control = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
-
- tag = (u8*)skb_put(skb, 6);
-
- *tag ++= ACT_CAT_BA;
- *tag ++= ACT_DELBA;
-
- // DELBA Parameter Set
- tmp = cpu_to_le16(DelbaParamSet.shortData);
- memcpy(tag, (u8*)&tmp, 2);
- tag += 2;
- // Reason Code
- tmp = cpu_to_le16(ReasonCode);
- memcpy(tag, (u8*)&tmp, 2);
- tag += 2;
-
- IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- if (net_ratelimit())
- IEEE80211_DEBUG(IEEE80211_DL_TRACE | IEEE80211_DL_BA, "<=====%s()\n", __FUNCTION__);
- return skb;
-}
-
-/********************************************************************************************************************
- *function: send ADDBAReq frame out
- * input: u8* dst //ADDBAReq frame's destination
- * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
- * output: none
- * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
-********************************************************************************************************************/
-void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA)
-{
- struct sk_buff *skb = NULL;
- skb = ieee80211_ADDBA(ieee, dst, pBA, 0, ACT_ADDBAREQ); //construct ACT_ADDBAREQ frames so set statuscode zero.
-
- if (skb)
- {
- softmac_mgmt_xmit(skb, ieee);
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
- }
- return;
-}
-
-/********************************************************************************************************************
- *function: send ADDBARSP frame out
- * input: u8* dst //DELBA frame's destination
- * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
- * u16 StatusCode //RSP StatusCode
- * output: none
- * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
-********************************************************************************************************************/
-void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, u16 StatusCode)
-{
- struct sk_buff *skb = NULL;
- skb = ieee80211_ADDBA(ieee, dst, pBA, StatusCode, ACT_ADDBARSP); //construct ACT_ADDBARSP frames
- if (skb)
- {
- softmac_mgmt_xmit(skb, ieee);
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
- }
-
- return;
-
-}
-/********************************************************************************************************************
- *function: send ADDBARSP frame out
- * input: u8* dst //DELBA frame's destination
- * PBA_RECORD pBA //BA_RECORD entry which stores the necessary information for BA
- * TR_SELECT TxRxSelect //TX or RX
- * u16 ReasonCode //DEL ReasonCode
- * output: none
- * notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
-********************************************************************************************************************/
-
-void ieee80211_send_DELBA(struct ieee80211_device* ieee, u8* dst, PBA_RECORD pBA, TR_SELECT TxRxSelect, u16 ReasonCode)
-{
- struct sk_buff *skb = NULL;
- skb = ieee80211_DELBA(ieee, dst, pBA, TxRxSelect, ReasonCode); //construct ACT_ADDBARSP frames
- if (skb)
- {
- softmac_mgmt_xmit(skb, ieee);
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "alloc skb error in function %s()\n", __FUNCTION__);
- }
- return ;
-}
-
-/********************************************************************************************************************
- *function: RX ADDBAReq
- * input: struct sk_buff * skb //incoming ADDBAReq skb.
- * return: 0(pass), other(fail)
- * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
-********************************************************************************************************************/
-int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
-{
- struct ieee80211_hdr_3addr* req = NULL;
- u16 rc = 0;
- u8 * dst = NULL, *pDialogToken = NULL, *tag = NULL;
- PBA_RECORD pBA = NULL;
- PBA_PARAM_SET pBaParamSet = NULL;
- u16* pBaTimeoutVal = NULL;
- PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
- PRX_TS_RECORD pTS = NULL;
-
- if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR,
- " Invalid skb len in BAREQ(%d / %zd)\n",
- skb->len,
- sizeof(struct ieee80211_hdr_3addr) + 9);
- return -1;
- }
-
- IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
-
- req = ( struct ieee80211_hdr_3addr*) skb->data;
- tag = (u8*)req;
- dst = (u8*)(&req->addr2[0]);
- tag += sizeof( struct ieee80211_hdr_3addr);
- pDialogToken = tag + 2; //category+action
- pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
- pBaTimeoutVal = (u16*)(tag + 5);
- pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7);
-
- printk("====================>rx ADDBAREQ from :%pM\n", dst);
-//some other capability is not ready now.
- if( (ieee->current_network.qos_data.active == 0) ||
- (ieee->pHTInfo->bCurrentHTSupport == false) ||
- (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ))
- {
- rc = ADDBA_STATUS_REFUSED;
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
- goto OnADDBAReq_Fail;
- }
- // Search for related traffic stream.
- // If there is no matched TS, reject the ADDBA request.
- if( !GetTs(
- ieee,
- (PTS_COMMON_INFO*)(&pTS),
- dst,
- (u8)(pBaParamSet->field.TID),
- RX_DIR,
- true) )
- {
- rc = ADDBA_STATUS_REFUSED;
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
- goto OnADDBAReq_Fail;
- }
- pBA = &pTS->RxAdmittedBARecord;
- // To Determine the ADDBA Req content
- // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
- // I want to check StartSeqCtrl to make sure when we start aggregation!!!
- //
- if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
- {
- rc = ADDBA_STATUS_INVALID_PARAM;
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __FUNCTION__);
- goto OnADDBAReq_Fail;
- }
- // Admit the ADDBA Request
- DeActivateBAEntry(ieee, pBA);
- pBA->DialogToken = *pDialogToken;
- pBA->BaParamSet = *pBaParamSet;
- pBA->BaTimeoutValue = *pBaTimeoutVal;
- pBA->BaStartSeqCtrl = *pBaStartSeqCtrl;
- //for half N mode we only aggregate 1 frame
- if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)||
- (ieee->pHTInfo->IOTAction & HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT))
- pBA->BaParamSet.field.BufferSize = 1;
- else
- pBA->BaParamSet.field.BufferSize = 32;
- ActivateBAEntry(ieee, pBA, 0);
- ieee80211_send_ADDBARsp(ieee, dst, pBA, ADDBA_STATUS_SUCCESS);
-
- return 0;
-
-OnADDBAReq_Fail:
- {
- BA_RECORD BA;
- BA.BaParamSet = *pBaParamSet;
- BA.BaTimeoutValue = *pBaTimeoutVal;
- BA.DialogToken = *pDialogToken;
- BA.BaParamSet.field.BAPolicy = BA_POLICY_IMMEDIATE;
- ieee80211_send_ADDBARsp(ieee, dst, &BA, rc);
- return 0; //we send RSP out.
- }
-
-}
-
-/********************************************************************************************************************
- *function: RX ADDBARSP
- * input: struct sk_buff * skb //incoming ADDBAReq skb.
- * return: 0(pass), other(fail)
- * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
-********************************************************************************************************************/
-int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
-{
- struct ieee80211_hdr_3addr* rsp = NULL;
- PBA_RECORD pPendingBA, pAdmittedBA;
- PTX_TS_RECORD pTS = NULL;
- u8* dst = NULL, *pDialogToken = NULL, *tag = NULL;
- u16* pStatusCode = NULL, *pBaTimeoutVal = NULL;
- PBA_PARAM_SET pBaParamSet = NULL;
- u16 ReasonCode;
-
- if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR,
- " Invalid skb len in BARSP(%d / %zd)\n",
- skb->len,
- sizeof(struct ieee80211_hdr_3addr) + 9);
- return -1;
- }
- rsp = ( struct ieee80211_hdr_3addr*)skb->data;
- tag = (u8*)rsp;
- dst = (u8*)(&rsp->addr2[0]);
- tag += sizeof( struct ieee80211_hdr_3addr);
- pDialogToken = tag + 2;
- pStatusCode = (u16*)(tag + 3);
- pBaParamSet = (PBA_PARAM_SET)(tag + 5);
- pBaTimeoutVal = (u16*)(tag + 7);
-
- // Check the capability
- // Since we can always receive A-MPDU, we just check if it is under HT mode.
- if( ieee->current_network.qos_data.active == 0 ||
- ieee->pHTInfo->bCurrentHTSupport == false ||
- ieee->pHTInfo->bCurrentAMPDUEnable == false )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable);
- ReasonCode = DELBA_REASON_UNKNOWN_BA;
- goto OnADDBARsp_Reject;
- }
-
-
- //
- // Search for related TS.
- // If there is no TS found, we wil reject ADDBA Rsp by sending DELBA frame.
- //
- if (!GetTs(
- ieee,
- (PTS_COMMON_INFO*)(&pTS),
- dst,
- (u8)(pBaParamSet->field.TID),
- TX_DIR,
- false) )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS in %s()\n", __FUNCTION__);
- ReasonCode = DELBA_REASON_UNKNOWN_BA;
- goto OnADDBARsp_Reject;
- }
-
- pTS->bAddBaReqInProgress = false;
- pPendingBA = &pTS->TxPendingBARecord;
- pAdmittedBA = &pTS->TxAdmittedBARecord;
-
-
- //
- // Check if related BA is waiting for setup.
- // If not, reject by sending DELBA frame.
- //
- if((pAdmittedBA->bValid==true))
- {
- // Since BA is already setup, we ignore all other ADDBA Response.
- IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n");
- return -1;
- }
- else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken))
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n");
- ReasonCode = DELBA_REASON_UNKNOWN_BA;
- goto OnADDBARsp_Reject;
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n", *pStatusCode);
- DeActivateBAEntry(ieee, pPendingBA);
- }
-
-
- if(*pStatusCode == ADDBA_STATUS_SUCCESS)
- {
- //
- // Determine ADDBA Rsp content here.
- // We can compare the value of BA parameter set that Peer returned and Self sent.
- // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
- //
- if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
- {
- // Since this is a kind of ADDBA failed, we delay next ADDBA process.
- pTS->bAddBaReqDelayed = true;
- DeActivateBAEntry(ieee, pAdmittedBA);
- ReasonCode = DELBA_REASON_END_BA;
- goto OnADDBARsp_Reject;
- }
-
-
- //
- // Admitted condition
- //
- pAdmittedBA->DialogToken = *pDialogToken;
- pAdmittedBA->BaTimeoutValue = *pBaTimeoutVal;
- pAdmittedBA->BaStartSeqCtrl = pPendingBA->BaStartSeqCtrl;
- pAdmittedBA->BaParamSet = *pBaParamSet;
- DeActivateBAEntry(ieee, pAdmittedBA);
- ActivateBAEntry(ieee, pAdmittedBA, *pBaTimeoutVal);
- } else {
- pTS->bAddBaReqDelayed = true;
- pTS->bDisable_AddBa = true;
- ReasonCode = DELBA_REASON_END_BA;
- goto OnADDBARsp_Reject;
- }
-
- // End of procedure
- return 0;
-
-OnADDBARsp_Reject:
- {
- BA_RECORD BA;
- BA.BaParamSet = *pBaParamSet;
- ieee80211_send_DELBA(ieee, dst, &BA, TX_DIR, ReasonCode);
- return 0;
- }
-
-}
-
-/********************************************************************************************************************
- *function: RX DELBA
- * input: struct sk_buff * skb //incoming ADDBAReq skb.
- * return: 0(pass), other(fail)
- * notice: As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
-********************************************************************************************************************/
-int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
-{
- struct ieee80211_hdr_3addr* delba = NULL;
- PDELBA_PARAM_SET pDelBaParamSet = NULL;
- u16* pReasonCode = NULL;
- u8* dst = NULL;
-
- if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR,
- " Invalid skb len in DELBA(%d / %zd)\n",
- skb->len,
- sizeof(struct ieee80211_hdr_3addr) + 6);
- return -1;
- }
-
- if(ieee->current_network.qos_data.active == 0 ||
- ieee->pHTInfo->bCurrentHTSupport == false )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
- return -1;
- }
-
- IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- delba = ( struct ieee80211_hdr_3addr*)skb->data;
- dst = (u8*)(&delba->addr2[0]);
- delba += sizeof( struct ieee80211_hdr_3addr);
- pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
- pReasonCode = (u16*)(delba+4);
-
- if(pDelBaParamSet->field.Initiator == 1)
- {
- PRX_TS_RECORD pRxTs;
-
- if( !GetTs(
- ieee,
- (PTS_COMMON_INFO*)&pRxTs,
- dst,
- (u8)pDelBaParamSet->field.TID,
- RX_DIR,
- false) )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for RXTS in %s()\n", __FUNCTION__);
- return -1;
- }
-
- RxTsDeleteBA(ieee, pRxTs);
- }
- else
- {
- PTX_TS_RECORD pTxTs;
-
- if(!GetTs(
- ieee,
- (PTS_COMMON_INFO*)&pTxTs,
- dst,
- (u8)pDelBaParamSet->field.TID,
- TX_DIR,
- false) )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't get TS for TXTS in %s()\n", __FUNCTION__);
- return -1;
- }
-
- pTxTs->bUsingBa = false;
- pTxTs->bAddBaReqInProgress = false;
- pTxTs->bAddBaReqDelayed = false;
- del_timer_sync(&pTxTs->TsAddBaTimer);
- TxTsDeleteBA(ieee, pTxTs);
- }
- return 0;
-}
-
-//
-// ADDBA initiate. This can only be called by TX side.
-//
-void
-TsInitAddBA(
- struct ieee80211_device* ieee,
- PTX_TS_RECORD pTS,
- u8 Policy,
- u8 bOverwritePending
- )
-{
- PBA_RECORD pBA = &pTS->TxPendingBARecord;
-
- if(pBA->bValid==true && bOverwritePending==false)
- return;
-
- // Set parameters to "Pending" variable set
- DeActivateBAEntry(ieee, pBA);
-
- pBA->DialogToken++; // DialogToken: Only keep the latest dialog token
- pBA->BaParamSet.field.AMSDU_Support = 0; // Do not support A-MSDU with A-MPDU now!!
- pBA->BaParamSet.field.BAPolicy = Policy; // Policy: Delayed or Immediate
- pBA->BaParamSet.field.TID = pTS->TsCommonInfo.TSpec.f.TSInfo.field.ucTSID; // TID
- // BufferSize: This need to be set according to A-MPDU vector
- pBA->BaParamSet.field.BufferSize = 32; // BufferSize: This need to be set according to A-MPDU vector
- pBA->BaTimeoutValue = 0; // Timeout value: Set 0 to disable Timer
- pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096; // Block Ack will start after 3 packets later.
-
- ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
-
- ieee80211_send_ADDBAReq(ieee, pTS->TsCommonInfo.Addr, pBA);
-}
-
-void
-TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect)
-{
-
- if(TxRxSelect == TX_DIR)
- {
- PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)pTsCommonInfo;
-
- if(TxTsDeleteBA(ieee, pTxTs))
- ieee80211_send_DELBA(
- ieee,
- pTsCommonInfo->Addr,
- (pTxTs->TxAdmittedBARecord.bValid)?(&pTxTs->TxAdmittedBARecord):(&pTxTs->TxPendingBARecord),
- TxRxSelect,
- DELBA_REASON_END_BA);
- }
- else if(TxRxSelect == RX_DIR)
- {
- PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)pTsCommonInfo;
- if(RxTsDeleteBA(ieee, pRxTs))
- ieee80211_send_DELBA(
- ieee,
- pTsCommonInfo->Addr,
- &pRxTs->RxAdmittedBARecord,
- TxRxSelect,
- DELBA_REASON_END_BA );
- }
-}
-/********************************************************************************************************************
- *function: BA setup timer
- * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
- * return: NULL
- * notice:
-********************************************************************************************************************/
-void BaSetupTimeOut(unsigned long data)
-{
- PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
-
- pTxTs->bAddBaReqInProgress = false;
- pTxTs->bAddBaReqDelayed = true;
- pTxTs->TxPendingBARecord.bValid = false;
-}
-
-void TxBaInactTimeout(unsigned long data)
-{
- PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
- struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[pTxTs->num]);
- TxTsDeleteBA(ieee, pTxTs);
- ieee80211_send_DELBA(
- ieee,
- pTxTs->TsCommonInfo.Addr,
- &pTxTs->TxAdmittedBARecord,
- TX_DIR,
- DELBA_REASON_TIMEOUT);
-}
-
-void RxBaInactTimeout(unsigned long data)
-{
- PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
- struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
-
- RxTsDeleteBA(ieee, pRxTs);
- ieee80211_send_DELBA(
- ieee,
- pRxTs->TsCommonInfo.Addr,
- &pRxTs->RxAdmittedBARecord,
- RX_DIR,
- DELBA_REASON_TIMEOUT);
- return ;
-}
-
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
deleted file mode 100644
index 171218914332..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_HT.h
+++ /dev/null
@@ -1,530 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef _RTL819XU_HTTYPE_H_
-#define _RTL819XU_HTTYPE_H_
-
-//------------------------------------------------------------
-// The HT Capability element is present in beacons, association request,
-// reassociation request and probe response frames
-//------------------------------------------------------------
-
-//
-// Operation mode value
-//
-#define HT_OPMODE_NO_PROTECT 0
-#define HT_OPMODE_OPTIONAL 1
-#define HT_OPMODE_40MHZ_PROTECT 2
-#define HT_OPMODE_MIXED 3
-
-//
-// MIMO Power Save Setings
-//
-#define MIMO_PS_STATIC 0
-#define MIMO_PS_DYNAMIC 1
-#define MIMO_PS_NOLIMIT 3
-
-
-//
-// There should be 128 bits to cover all of the MCS rates. However, since
-// 8190 does not support too much rates, one integer is quite enough.
-//
-
-#define sHTCLng 4
-
-
-#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff
-#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00
-#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
-
-
-typedef enum _HT_MCS_RATE{
- HT_MCS0 = 0x00000001,
- HT_MCS1 = 0x00000002,
- HT_MCS2 = 0x00000004,
- HT_MCS3 = 0x00000008,
- HT_MCS4 = 0x00000010,
- HT_MCS5 = 0x00000020,
- HT_MCS6 = 0x00000040,
- HT_MCS7 = 0x00000080,
- HT_MCS8 = 0x00000100,
- HT_MCS9 = 0x00000200,
- HT_MCS10 = 0x00000400,
- HT_MCS11 = 0x00000800,
- HT_MCS12 = 0x00001000,
- HT_MCS13 = 0x00002000,
- HT_MCS14 = 0x00004000,
- HT_MCS15 = 0x00008000,
- // Do not define MCS32 here although 8190 support MCS32
-}HT_MCS_RATE,*PHT_MCS_RATE;
-
-//
-// Represent Channel Width in HT Capabilities
-//
-typedef enum _HT_CHANNEL_WIDTH{
- HT_CHANNEL_WIDTH_20 = 0,
- HT_CHANNEL_WIDTH_20_40 = 1,
-}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH;
-
-//
-// Represent Extention Channel Offset in HT Capabilities
-// This is available only in 40Mhz mode.
-//
-typedef enum _HT_EXTCHNL_OFFSET{
- HT_EXTCHNL_OFFSET_NO_EXT = 0,
- HT_EXTCHNL_OFFSET_UPPER = 1,
- HT_EXTCHNL_OFFSET_NO_DEF = 2,
- HT_EXTCHNL_OFFSET_LOWER = 3,
-}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET;
-
-typedef enum _CHNLOP{
- CHNLOP_NONE = 0, // No Action now
- CHNLOP_SCAN = 1, // Scan in progress
- CHNLOP_SWBW = 2, // Bandwidth switching in progress
- CHNLOP_SWCHNL = 3, // Software Channel switching in progress
-} CHNLOP, *PCHNLOP;
-
-// Determine if the Channel Operation is in progress
-#define CHHLOP_IN_PROGRESS(_pHTInfo) \
- ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
-
-/*
-typedef union _HT_CAPABILITY{
- u16 ShortData;
- u8 CharData[2];
- struct
- {
- u16 AdvCoding:1;
- u16 ChlWidth:1;
- u16 MimoPwrSave:2;
- u16 GreenField:1;
- u16 ShortGI20Mhz:1;
- u16 ShortGI40Mhz:1;
- u16 STBC:1;
- u16 BeamForm:1;
- u16 DelayBA:1;
- u16 MaxAMSDUSize:1;
- u16 DssCCk:1;
- u16 PSMP:1;
- u16 Rsvd:3;
- }Field;
-}HT_CAPABILITY, *PHT_CAPABILITY;
-
-typedef union _HT_CAPABILITY_MACPARA{
- u8 ShortData;
- u8 CharData[1];
- struct
- {
- u8 MaxRxAMPDU:2;
- u8 MPDUDensity:2;
- u8 Rsvd:4;
- }Field;
-}HT_CAPABILITY_MACPARA, *PHT_CAPABILITY_MACPARA;
-*/
-
-typedef enum _HT_ACTION{
- ACT_RECOMMAND_WIDTH = 0,
- ACT_MIMO_PWR_SAVE = 1,
- ACT_PSMP = 2,
- ACT_SET_PCO_PHASE = 3,
- ACT_MIMO_CHL_MEASURE = 4,
- ACT_RECIPROCITY_CORRECT = 5,
- ACT_MIMO_CSI_MATRICS = 6,
- ACT_MIMO_NOCOMPR_STEER = 7,
- ACT_MIMO_COMPR_STEER = 8,
- ACT_ANTENNA_SELECT = 9,
-} HT_ACTION, *PHT_ACTION;
-
-
-/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */
-typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{
- SC_MODE_DUPLICATE = 0,
- SC_MODE_LOWER = 1,
- SC_MODE_UPPER = 2,
- SC_MODE_FULL40MHZ = 3,
-}HT_BW40_SC_E;
-
-typedef struct _HT_CAPABILITY_ELE{
-
- //HT capability info
- u8 AdvCoding:1;
- u8 ChlWidth:1;
- u8 MimoPwrSave:2;
- u8 GreenField:1;
- u8 ShortGI20Mhz:1;
- u8 ShortGI40Mhz:1;
- u8 TxSTBC:1;
- u8 RxSTBC:2;
- u8 DelayBA:1;
- u8 MaxAMSDUSize:1;
- u8 DssCCk:1;
- u8 PSMP:1;
- u8 Rsvd1:1;
- u8 LSigTxopProtect:1;
-
- //MAC HT parameters info
- u8 MaxRxAMPDUFactor:2;
- u8 MPDUDensity:3;
- u8 Rsvd2:3;
-
- //Supported MCS set
- u8 MCS[16];
-
-
- //Extended HT Capability Info
- u16 ExtHTCapInfo;
-
- //TXBF Capabilities
- u8 TxBFCap[4];
-
- //Antenna Selection Capabilities
- u8 ASCap;
-
-} __attribute__ ((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
-
-//------------------------------------------------------------
-// The HT Information element is present in beacons
-// Only AP is required to include this element
-//------------------------------------------------------------
-
-typedef struct _HT_INFORMATION_ELE{
- u8 ControlChl;
-
- u8 ExtChlOffset:2;
- u8 RecommemdedTxWidth:1;
- u8 RIFS:1;
- u8 PSMPAccessOnly:1;
- u8 SrvIntGranularity:3;
-
- u8 OptMode:2;
- u8 NonGFDevPresent:1;
- u8 Revd1:5;
- u8 Revd2:8;
-
- u8 Rsvd3:6;
- u8 DualBeacon:1;
- u8 DualCTSProtect:1;
-
- u8 SecondaryBeacon:1;
- u8 LSigTxopProtectFull:1;
- u8 PcoActive:1;
- u8 PcoPhase:1;
- u8 Rsvd4:4;
-
- u8 BasicMSC[16];
-} __attribute__ ((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
-
-//
-// MIMO Power Save control field.
-// This is appear in MIMO Power Save Action Frame
-//
-typedef struct _MIMOPS_CTRL{
- u8 MimoPsEnable:1;
- u8 MimoPsMode:1;
- u8 Reserved:6;
-} MIMOPS_CTRL, *PMIMOPS_CTRL;
-
-typedef enum _HT_SPEC_VER{
- HT_SPEC_VER_IEEE = 0,
- HT_SPEC_VER_EWC = 1,
-}HT_SPEC_VER, *PHT_SPEC_VER;
-
-typedef enum _HT_AGGRE_MODE_E{
- HT_AGG_AUTO = 0,
- HT_AGG_FORCE_ENABLE = 1,
- HT_AGG_FORCE_DISABLE = 2,
-}HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variables when card is
-// configured as non-AP STA mode. **Note** Current_xxx should be set
-// to default value in HTInitializeHTInfo()
-//------------------------------------------------------------
-
-typedef struct _RT_HIGH_THROUGHPUT{
- u8 bEnableHT;
- u8 bCurrentHTSupport;
-
- u8 bRegBW40MHz; // Tx 40MHz channel capablity
- u8 bCurBW40MHz; // Tx 40MHz channel capability
-
- u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz
- u8 bCurShortGI40MHz; // Tx Short GI for 40MHz
-
- u8 bRegShortGI20MHz; // Tx Short GI for 20MHz
- u8 bCurShortGI20MHz; // Tx Short GI for 20MHz
-
- u8 bRegSuppCCK; // Tx CCK rate capability
- u8 bCurSuppCCK; // Tx CCK rate capability
-
- // 802.11n spec version for "peer"
- HT_SPEC_VER ePeerHTSpecVer;
-
-
- // HT related information for "Self"
- HT_CAPABILITY_ELE SelfHTCap; // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
- HT_INFORMATION_ELE SelfHTInfo; // This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
-
- // HT related information for "Peer"
- u8 PeerHTCapBuf[32];
- u8 PeerHTInfoBuf[32];
-
-
- // A-MSDU related
- u8 bAMSDU_Support; // This indicates Tx A-MSDU capability
- u16 nAMSDU_MaxSize; // This indicates Tx A-MSDU capability
- u8 bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability
- u16 nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability
-
-
- // AMPDU related <2006.08.10 Emily>
- u8 bAMPDUEnable; // This indicate Tx A-MPDU capability
- u8 bCurrentAMPDUEnable; // This indicate Tx A-MPDU capability
- u8 AMPDU_Factor; // This indicate Tx A-MPDU capability
- u8 CurrentAMPDUFactor; // This indicate Tx A-MPDU capability
- u8 MPDU_Density; // This indicate Tx A-MPDU capability
- u8 CurrentMPDUDensity; // This indicate Tx A-MPDU capability
-
- // Forced A-MPDU enable
- HT_AGGRE_MODE_E ForcedAMPDUMode;
- u8 ForcedAMPDUFactor;
- u8 ForcedMPDUDensity;
-
- // Forced A-MSDU enable
- HT_AGGRE_MODE_E ForcedAMSDUMode;
- u16 ForcedAMSDUMaxSize;
-
- u8 bForcedShortGI;
-
- u8 CurrentOpMode;
-
- // MIMO PS related
- u8 SelfMimoPs;
- u8 PeerMimoPs;
-
- // 40MHz Channel Offset settings.
- HT_EXTCHNL_OFFSET CurSTAExtChnlOffset;
- u8 bCurTxBW40MHz; // If we use 40 MHz to Tx
- u8 PeerBandwidth;
-
- // For Bandwidth Switching
- u8 bSwBwInProgress;
- CHNLOP ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
- u8 SwBwStep;
- //struct timer_list SwBwTimer; //moved to ieee80211_device. as timer_list need include some header file here.
-
- // For Realtek proprietary A-MPDU factor for aggregation
- u8 bRegRT2RTAggregation;
- u8 RT2RT_HT_Mode;
- u8 bCurrentRT2RTAggregation;
- u8 bCurrentRT2RTLongSlotTime;
- u8 szRT2RTAggBuffer[10];
-
- // Rx Reorder control
- u8 bRegRxReorderEnable;
- u8 bCurRxReorderEnable;
- u8 RxReorderWinSize;
- u8 RxReorderPendingTime;
- u16 RxReorderDropCounter;
-
-
- // Add for Broadcom(Linksys) IOT. Joseph
- u8 bIsPeerBcm;
-
- // For IOT issue.
- u8 IOTPeer;
- u32 IOTAction;
- u8 IOTRaFunc;
-} __attribute__ ((packed)) RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
-
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variable for "each Sta"
-// when card is configured as "AP mode"
-//------------------------------------------------------------
-
-typedef struct _RT_HTINFO_STA_ENTRY{
- u8 bEnableHT;
-
- u8 bSupportCck;
-
- u16 AMSDU_MaxSize;
-
- u8 AMPDU_Factor;
- u8 MPDU_Density;
-
- u8 HTHighestOperaRate;
-
- u8 bBw40MHz;
-
- u8 MimoPs;
-
- u8 McsRateSet[16];
-
-
-}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY;
-
-
-
-
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variable for "each AP"
-// when card is configured as "STA mode"
-//------------------------------------------------------------
-
-typedef struct _BSS_HT{
-
- u8 bdSupportHT;
-
- // HT related elements
- u8 bdHTCapBuf[32];
- u16 bdHTCapLen;
- u8 bdHTInfoBuf[32];
- u16 bdHTInfoLen;
-
- HT_SPEC_VER bdHTSpecVer;
- HT_CHANNEL_WIDTH bdBandWidth;
-
- u8 bdRT2RTAggregation;
- u8 bdRT2RTLongSlotTime;
- u8 RT2RT_HT_Mode;
- bool bdHT1R;
-} __attribute__ ((packed)) BSS_HT, *PBSS_HT;
-
-typedef struct _MIMO_RSSI{
- u32 EnableAntenna;
- u32 AntennaA;
- u32 AntennaB;
- u32 AntennaC;
- u32 AntennaD;
- u32 Average;
-}MIMO_RSSI, *PMIMO_RSSI;
-
-typedef struct _MIMO_EVM{
- u32 EVM1;
- u32 EVM2;
-}MIMO_EVM, *PMIMO_EVM;
-
-typedef struct _FALSE_ALARM_STATISTICS{
- u32 Cnt_Parity_Fail;
- u32 Cnt_Rate_Illegal;
- u32 Cnt_Crc8_fail;
- u32 Cnt_all;
-}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS;
-
-
-extern u8 MCS_FILTER_ALL[16];
-extern u8 MCS_FILTER_1SS[16];
-
-/* 2007/07/11 MH Modify the macro. Becaus STA may link with a N-AP. If we set
- STA in A/B/G mode and AP is still in N mode. The macro will be wrong. We have
- to add a macro to judge wireless mode. */
-#define PICK_RATE(_nLegacyRate, _nMcsRate) \
- (_nMcsRate==0)?(_nLegacyRate&0x7f):(_nMcsRate)
-/* 2007/07/12 MH We only define legacy and HT wireless mode now. */
-#define LEGACY_WIRELESS_MODE IEEE_MODE_MASK
-
-#define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \
- ((WirelessMode & (LEGACY_WIRELESS_MODE))!=0)?\
- (LegacyRate):\
- (PICK_RATE(LegacyRate, HTRate))
-
-
-
-// MCS Bw 40 {1~7, 12~15,32}
-#define RATE_ADPT_1SS_MASK 0xFF
-#define RATE_ADPT_2SS_MASK 0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily
-#define RATE_ADPT_MCS32_MASK 0x01
-
-#define IS_11N_MCS_RATE(rate) (rate&0x80)
-
-typedef enum _HT_AGGRE_SIZE{
- HT_AGG_SIZE_8K = 0,
- HT_AGG_SIZE_16K = 1,
- HT_AGG_SIZE_32K = 2,
- HT_AGG_SIZE_64K = 3,
-}HT_AGGRE_SIZE_E, *PHT_AGGRE_SIZE_E;
-
-/* Indicate different AP vendor for IOT issue */
-typedef enum _HT_IOT_PEER
-{
- HT_IOT_PEER_UNKNOWN = 0,
- HT_IOT_PEER_REALTEK = 1,
- HT_IOT_PEER_REALTEK_92SE = 2,
- HT_IOT_PEER_BROADCOM = 3,
- HT_IOT_PEER_RALINK = 4,
- HT_IOT_PEER_ATHEROS = 5,
- HT_IOT_PEER_CISCO= 6,
- HT_IOT_PEER_MARVELL=7,
- HT_IOT_PEER_92U_SOFTAP = 8,
- HT_IOT_PEER_SELF_SOFTAP = 9,
- HT_IOT_PEER_MAX = 10,
-}HT_IOT_PEER_E, *PHTIOT_PEER_E;
-
-//
-// IOT Action for different AP
-//
-typedef enum _HT_IOT_ACTION{
- HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
- HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
- HT_IOT_ACT_DISABLE_MCS14 = 0x00000004,
- HT_IOT_ACT_DISABLE_MCS15 = 0x00000008,
- HT_IOT_ACT_DISABLE_ALL_2SS = 0x00000010,
- HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000020,
- HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000040,
- HT_IOT_ACT_CDD_FSYNC = 0x00000080,
- HT_IOT_ACT_PURE_N_MODE = 0x00000100,
- HT_IOT_ACT_FORCED_CTS2SELF = 0x00000200,
- HT_IOT_ACT_FORCED_RTS = 0x00000400,
- HT_IOT_ACT_AMSDU_ENABLE = 0x00000800,
- HT_IOT_ACT_REJECT_ADDBA_REQ = 0x00001000,
- HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT = 0x00002000,
- HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00004000,
-
- HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000,
- HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000,
- HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000,
- HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000,
- HT_IOT_ACT_TX_NO_AGGREGATION = 0x00100000,
- HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000,
-
- HT_IOT_ACT_MID_HIGHPOWER = 0x00400000,
- HT_IOT_ACT_NULL_DATA_POWER_SAVING = 0x00800000,
-
- HT_IOT_ACT_DISABLE_CCK_RATE = 0x01000000,
- HT_IOT_ACT_FORCED_ENABLE_BE_TXOP = 0x02000000,
- HT_IOT_ACT_WA_IOT_Broadcom = 0x04000000,
-}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
-
-typedef enum _HT_IOT_RAFUNC{
- HT_IOT_RAFUNC_DISABLE_ALL = 0x00,
- HT_IOT_RAFUNC_PEER_1R = 0x01,
- HT_IOT_RAFUNC_TX_AMSDU = 0x02,
-}HT_IOT_RAFUNC, *PHT_IOT_RAFUNC;
-
-typedef enum _RT_HT_CAP{
- RT_HT_CAP_USE_TURBO_AGGR = 0x01,
- RT_HT_CAP_USE_LONG_PREAMBLE = 0x02,
- RT_HT_CAP_USE_AMPDU = 0x04,
- RT_HT_CAP_USE_WOW = 0x8,
- RT_HT_CAP_USE_SOFTAP = 0x10,
- RT_HT_CAP_USE_92SE = 0x20,
-}RT_HT_CAPBILITY, *PRT_HT_CAPBILITY;
-
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
deleted file mode 100644
index cfd9a1a5b38d..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_HTProc.c
+++ /dev/null
@@ -1,1725 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "ieee80211.h"
-#include "rtl819x_HT.h"
-u8 MCS_FILTER_ALL[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-u8 MCS_FILTER_1SS[16] = {0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-u16 MCS_DATA_RATE[2][2][77] =
- { { {13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78 ,104, 156, 208, 234, 260,
- 39, 78, 117, 234, 312, 351, 390, 52, 104, 156, 208, 312, 416, 468, 520,
- 0, 78, 104, 130, 117, 156, 195, 104, 130, 130, 156, 182, 182, 208, 156, 195,
- 195, 234, 273, 273, 312, 130, 156, 181, 156, 181, 208, 234, 208, 234, 260, 260,
- 286, 195, 234, 273, 234, 273, 312, 351, 312, 351, 390, 390, 429},
- {14, 29, 43, 58, 87, 116, 130, 144, 29, 58, 87, 116, 173, 231, 260, 289,
- 43, 87, 130, 173, 260, 347, 390, 433, 58, 116, 173, 231, 347, 462, 520, 578,
- 0, 87, 116, 144, 130, 173, 217, 116, 144, 144, 173, 202, 202, 231, 173, 217,
- 217, 260, 303, 303, 347, 144, 173, 202, 173, 202, 231, 260, 231, 260, 289, 289,
- 318, 217, 260, 303, 260, 303, 347, 390, 347, 390, 433, 433, 477} },
- { {27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
- 81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
- 12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
- 405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
- 594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891},
- {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
- 90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
- 13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
- 450, 540, 630, 630, 720, 300, 360, 420, 360, 420, 480, 540, 480, 540, 600, 600,
- 660, 450, 540, 630, 540, 630, 720, 810, 720, 810, 900, 900, 990} }
- };
-
-static u8 UNKNOWN_BORADCOM[3] = {0x00, 0x14, 0xbf};
-static u8 LINKSYSWRT330_LINKSYSWRT300_BROADCOM[3] = {0x00, 0x1a, 0x70};
-static u8 LINKSYSWRT350_LINKSYSWRT150_BROADCOM[3] = {0x00, 0x1d, 0x7e};
-static u8 BELKINF5D8233V1_RALINK[3] = {0x00, 0x17, 0x3f};
-static u8 BELKINF5D82334V3_RALINK[3] = {0x00, 0x1c, 0xdf};
-static u8 PCI_RALINK[3] = {0x00, 0x90, 0xcc};
-static u8 EDIMAX_RALINK[3] = {0x00, 0x0e, 0x2e};
-static u8 AIRLINK_RALINK[3] = {0x00, 0x18, 0x02};
-static u8 DLINK_ATHEROS_1[3] = {0x00, 0x1c, 0xf0};
-static u8 DLINK_ATHEROS_2[3] = {0x00, 0x21, 0x91};
-static u8 CISCO_BROADCOM[3] = {0x00, 0x17, 0x94};
-static u8 NETGEAR_BROADCOM[3] = {0x00, 0x1f, 0x33};
-static u8 LINKSYS_MARVELL_4400N[3] = {0x00, 0x14, 0xa4};
-
-/********************************************************************************************************************
- *function: This function update default settings in pHTInfo structure
- * input: PRT_HIGH_THROUGHPUT pHTInfo
- * output: none
- * return: none
- * notice: These value need be modified if any changes.
- * *****************************************************************************************************************/
-void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- // ShortGI support
- pHTInfo->bRegShortGI20MHz= 1;
- pHTInfo->bRegShortGI40MHz= 1;
-
- // 40MHz channel support
- pHTInfo->bRegBW40MHz = 1;
-
- // CCK rate support in 40MHz channel
- if(pHTInfo->bRegBW40MHz)
- pHTInfo->bRegSuppCCK = 1;
- else
- pHTInfo->bRegSuppCCK = true;
-
- // AMSDU related
- pHTInfo->nAMSDU_MaxSize = 7935UL;
- pHTInfo->bAMSDU_Support = 0;
-
- // AMPDU related
- pHTInfo->bAMPDUEnable = 1; //YJ,test,090311
- pHTInfo->AMPDU_Factor = 2; //// 0: 2n13(8K), 1:2n14(16K), 2:2n15(32K), 3:2n16(64k)
- pHTInfo->MPDU_Density = 0;// 0: No restriction, 1: 1/8usec, 2: 1/4usec, 3: 1/2usec, 4: 1usec, 5: 2usec, 6: 4usec, 7:8usec
-
- // MIMO Power Save
- pHTInfo->SelfMimoPs = 3;// 0: Static Mimo Ps, 1: Dynamic Mimo Ps, 3: No Limitation, 2: Reserved(Set to 3 automatically.)
- if(pHTInfo->SelfMimoPs == 2)
- pHTInfo->SelfMimoPs = 3;
- // 8190 only. Assign rate operation mode to firmware
- ieee->bTxDisableRateFallBack = 0;
- ieee->bTxUseDriverAssingedRate = 0;
-
-#ifdef TO_DO_LIST
- // 8190 only. Assign duration operation mode to firmware
- pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
-#endif
- // 8190 only, Realtek proprietary aggregation mode
- // Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
- pHTInfo->bRegRT2RTAggregation = 1;//0: Set MPDUDensity=2, 1: Set MPDUDensity=2(32k) for Realtek AP and set MPDUDensity=0(8k) for others
-
- // For Rx Reorder Control
- pHTInfo->bRegRxReorderEnable = 1;//YJ,test,090311
- pHTInfo->RxReorderWinSize = 64;
- pHTInfo->RxReorderPendingTime = 30;
-
-
-
-}
-/********************************************************************************************************************
- *function: This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
- * input: u8* CapIE //Capability IE to be printed out
- * u8* TitleString //mainly print out caller function
- * output: none
- * return: none
- * notice: Driver should not print out this message by default.
- * *****************************************************************************************************************/
-void HTDebugHTCapability(u8* CapIE, u8* TitleString )
-{
-
- static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
- PHT_CAPABILITY_ELE pCapELE;
-
- if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
- {
- //EWC IE
- IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
- pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[4]);
- }else
- pCapELE = (PHT_CAPABILITY_ELE)(&CapIE[0]);
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Capability>. Called by %s\n", TitleString );
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupported Channel Width = %s\n", (pCapELE->ChlWidth)?"20MHz": "20/40MHz");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 20M = %s\n", (pCapELE->ShortGI20Mhz)?"YES": "NO");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport Short GI for 40M = %s\n", (pCapELE->ShortGI40Mhz)?"YES": "NO");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport TX STBC = %s\n", (pCapELE->TxSTBC)?"YES": "NO");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMSDU Size = %s\n", (pCapELE->MaxAMSDUSize)?"3839": "7935");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSupport CCK in 20/40 mode = %s\n", (pCapELE->DssCCk)?"YES": "NO");
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMax AMPDU Factor = %d\n", pCapELE->MaxRxAMPDUFactor);
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMPDU Density = %d\n", pCapELE->MPDUDensity);
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n", pCapELE->MCS[0],\
- pCapELE->MCS[1], pCapELE->MCS[2], pCapELE->MCS[3], pCapELE->MCS[4]);
- return;
-
-}
-/********************************************************************************************************************
- *function: This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
- * input: u8* InfoIE //Capability IE to be printed out
- * u8* TitleString //mainly print out caller function
- * output: none
- * return: none
- * notice: Driver should not print out this message by default.
- * *****************************************************************************************************************/
-void HTDebugHTInfo(u8* InfoIE, u8* TitleString)
-{
-
- static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
- PHT_INFORMATION_ELE pHTInfoEle;
-
- if(!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
- {
- // Not EWC IE
- IEEE80211_DEBUG(IEEE80211_DL_HT, "EWC IE in %s()\n", __FUNCTION__);
- pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[4]);
- }else
- pHTInfoEle = (PHT_INFORMATION_ELE)(&InfoIE[0]);
-
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "<Log HT Information Element>. Called by %s\n", TitleString);
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tPrimary channel = %d\n", pHTInfoEle->ControlChl);
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tSenondary channel =");
- switch(pHTInfoEle->ExtChlOffset)
- {
- case 0:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "Not Present\n");
- break;
- case 1:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "Upper channel\n");
- break;
- case 2:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "Reserved. Eooro!!!\n");
- break;
- case 3:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "Lower Channel\n");
- break;
- }
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tRecommended channel width = %s\n", (pHTInfoEle->RecommemdedTxWidth)?"20Mhz": "40Mhz");
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tOperation mode for protection = ");
- switch(pHTInfoEle->OptMode)
- {
- case 0:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "No Protection\n");
- break;
- case 1:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "HT non-member protection mode\n");
- break;
- case 2:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "Suggest to open protection\n");
- break;
- case 3:
- IEEE80211_DEBUG(IEEE80211_DL_HT, "HT mixed mode\n");
- break;
- }
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x][%x]\n", pHTInfoEle->BasicMSC[0],\
- pHTInfoEle->BasicMSC[1], pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3], pHTInfoEle->BasicMSC[4]);
- return;
-}
-
-/*
-* Return: true if station in half n mode and AP supports 40 bw
-*/
-bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
-{
- bool retValue = false;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
- retValue = false;
- else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw
- retValue = false;
- else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
- retValue = false;
- else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
- retValue = true;
- else
- retValue = false;
-
- return retValue;
-}
-
-bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
-{
- bool retValue = false;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode
- retValue = false;
- else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode
- retValue = false;
- else if(is40MHz) // ap support 40 bw
- {
- if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI40Mhz) // ap support 40 bw short GI
- retValue = true;
- else
- retValue = false;
- }
- else
- {
- if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ShortGI20Mhz) // ap support 40 bw short GI
- retValue = true;
- else
- retValue = false;
- }
-
- return retValue;
-}
-
-u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate)
-{
-
- u8 is40MHz;
- u8 isShortGI;
-
- is40MHz = (IsHTHalfNmode40Bandwidth(ieee))?1:0;
- isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz))? 1:0;
-
- return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
-}
-
-
-u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- u8 is40MHz = (pHTInfo->bCurBW40MHz)?1:0;
- u8 isShortGI = (pHTInfo->bCurBW40MHz)?
- ((pHTInfo->bCurShortGI40MHz)?1:0):
- ((pHTInfo->bCurShortGI20MHz)?1:0);
- return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate&0x7f)];
-}
-
-/********************************************************************************************************************
- *function: This function returns current datarate.
- * input: struct ieee80211_device* ieee
- * u8 nDataRate
- * output: none
- * return: tx rate
- * notice: quite unsure about how to use this function //wb
- * *****************************************************************************************************************/
-u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate)
-{
- u16 CCKOFDMRate[12] = {0x02 , 0x04 , 0x0b , 0x16 , 0x0c , 0x12 , 0x18 , 0x24 , 0x30 , 0x48 , 0x60 , 0x6c};
- u8 is40MHz = 0;
- u8 isShortGI = 0;
-
- if(nDataRate < 12)
- {
- return CCKOFDMRate[nDataRate];
- }
- else
- {
- if (nDataRate >= 0x10 && nDataRate <= 0x1f)//if(nDataRate > 11 && nDataRate < 28 )
- {
- is40MHz = 0;
- isShortGI = 0;
-
- }
- else if(nDataRate >=0x20 && nDataRate <= 0x2f ) //(27, 44)
- {
- is40MHz = 1;
- isShortGI = 0;
-
- }
- else if(nDataRate >= 0x30 && nDataRate <= 0x3f ) //(43, 60)
- {
- is40MHz = 0;
- isShortGI = 1;
-
- }
- else if(nDataRate >= 0x40 && nDataRate <= 0x4f ) //(59, 76)
- {
- is40MHz = 1;
- isShortGI = 1;
-
- }
- return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
- }
-}
-
-
-
-bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
-{
- bool retValue = false;
- struct ieee80211_network* net = &ieee->current_network;
-
- if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
- (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
- (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
- (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
- (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
- (net->ralink_cap_exist))
- retValue = true;
- else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
- (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
- (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0)||
- (net->broadcom_cap_exist))
- retValue = true;
- else if(net->bssht.bdRT2RTAggregation)
- retValue = true;
- else
- retValue = false;
-
- return retValue;
-}
-
-/********************************************************************************************************************
- *function: This function returns peer IOT.
- * input: struct ieee80211_device* ieee
- * output: none
- * return:
- * notice:
- * *****************************************************************************************************************/
-void HTIOTPeerDetermine(struct ieee80211_device* ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- struct ieee80211_network* net = &ieee->current_network;
- //FIXME: need to decide 92U_SOFTAP //LZM,090320
- if(net->bssht.bdRT2RTAggregation){
- pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK;
- if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_92SE){
- pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE;
- }
- if(net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP){
- pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP;
- }
- }
- else if(net->broadcom_cap_exist)
- pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
- else if((memcmp(net->bssid, UNKNOWN_BORADCOM, 3)==0) ||
- (memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0)||
- (memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)==0))
- pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM;
- else if((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3)==0) ||
- (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3)==0) ||
- (memcmp(net->bssid, PCI_RALINK, 3)==0) ||
- (memcmp(net->bssid, EDIMAX_RALINK, 3)==0) ||
- (memcmp(net->bssid, AIRLINK_RALINK, 3)==0) ||
- net->ralink_cap_exist)
- pHTInfo->IOTPeer = HT_IOT_PEER_RALINK;
- else if((net->atheros_cap_exist )||
- (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0)||
- (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0))
- pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS;
- else if ((memcmp(net->bssid, CISCO_BROADCOM, 3)==0)||net->cisco_cap_exist)
- pHTInfo->IOTPeer = HT_IOT_PEER_CISCO;
- else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) ||
- net->marvell_cap_exist)
- pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL;
- else
- pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
-
- IEEE80211_DEBUG(IEEE80211_DL_IOT, "Joseph debug!! IOTPEER: %x\n", pHTInfo->IOTPeer);
-}
-/********************************************************************************************************************
- *function: Check whether driver should declare received rate up to MCS13 only since some chipset is not good
- * at receiving MCS14~15 frame from some AP.
- * input: struct ieee80211_device* ieee
- * u8 * PeerMacAddr
- * output: none
- * return: return 1 if driver should declare MCS13 only(otherwise return 0)
- * *****************************************************************************************************************/
-u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
-{
- u8 ret = 0;
-
- return ret;
- }
-
-
-/**
-* Function: HTIOTActIsDisableMCS15
-*
-* Overview: Check whether driver should declare capability of receving MCS15
-*
-* Input:
-* PADAPTER Adapter,
-*
-* Output: None
-* Return: true if driver should disable MCS15
-* 2008.04.15 Emily
-*/
-bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
-{
- bool retValue = false;
- return retValue;
-}
-
-/**
-* Function: HTIOTActIsDisableMCSTwoSpatialStream
-*
-* Overview: Check whether driver should declare capability of receving All 2 ss packets
-*
-* Input:
-* PADAPTER Adapter,
-*
-* Output: None
-* Return: true if driver should disable all two spatial stream packet
-* 2008.04.21 Emily
-*/
-bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee)
-{
- bool retValue = false;
-#ifdef TODO
- // Apply for 819u only
-//#if (HAL_CODE_BASE==RTL8192)
-
- //This rule only apply to Belkin(Ralink) AP
- if(IS_UNDER_11N_AES_MODE(Adapter))
- {
- if((PlatformCompareMemory(PeerMacAddr, BELKINF5D8233V1_RALINK, 3)==0) ||
- (PlatformCompareMemory(PeerMacAddr, PCI_RALINK, 3)==0) ||
- (PlatformCompareMemory(PeerMacAddr, EDIMAX_RALINK, 3)==0))
- {
- //Set True to disable this function. Disable by default, Emily, 2008.04.23
- retValue = false;
- }
- }
-
-//#endif
-#endif
-#if 1
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
- {
- if( (pHTInfo->IOTPeer != HT_IOT_PEER_ATHEROS) &&
- (pHTInfo->IOTPeer != HT_IOT_PEER_UNKNOWN) &&
- (pHTInfo->IOTPeer != HT_IOT_PEER_MARVELL) )
- retValue = true;
- }
-#endif
- return retValue;
-}
-
-/********************************************************************************************************************
- *function: Check whether driver should disable EDCA turbo mode
- * input: struct ieee80211_device* ieee
- * u8* PeerMacAddr
- * output: none
- * return: return 1 if driver should disable EDCA turbo mode(otherwise return 0)
- * *****************************************************************************************************************/
-u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
-{
- u8 retValue = false; // default enable EDCA Turbo mode.
- // Set specific EDCA parameter for different AP in DM handler.
-
- return retValue;
-}
-
-/********************************************************************************************************************
- *function: Check whether we need to use OFDM to sned MGNT frame for broadcom AP
- * input: struct ieee80211_network *network //current network we live
- * output: none
- * return: return 1 if true
- * *****************************************************************************************************************/
-u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
- // 2008/01/28 MH We must prevent that we select null bssid to link.
-
- if(network->broadcom_cap_exist)
- {
- retValue = 1;
- }
-
- return retValue;
-}
-
-u8 HTIOTActIsForcedCTS2Self(struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- if(network->marvell_cap_exist)
- {
- retValue = 1;
- }
-
- return retValue;
-}
-
-u8 HTIOTActIsForcedRTSCTS(struct ieee80211_device *ieee, struct ieee80211_network *network)
-{
- u8 retValue = 0;
- printk("============>%s(), %d\n", __FUNCTION__, network->realtek_cap_exit);
- // Force protection
- if(ieee->pHTInfo->bCurrentHTSupport)
- {
- //if(!network->realtek_cap_exit)
- if((ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK)&&
- (ieee->pHTInfo->IOTPeer != HT_IOT_PEER_REALTEK_92SE))
- {
- if((ieee->pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) == 0)
- retValue = 1;
- }
- }
- return retValue;
-}
-
-u8
-HTIOTActIsForcedAMSDU8K(struct ieee80211_device *ieee, struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- return retValue;
-}
-
-u8 HTIOTActIsCCDFsync(u8* PeerMacAddr)
-{
- u8 retValue = 0;
- if( (memcmp(PeerMacAddr, UNKNOWN_BORADCOM, 3)==0) ||
- (memcmp(PeerMacAddr, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3)==0) ||
- (memcmp(PeerMacAddr, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3) ==0))
- {
- retValue = 1;
- }
- return retValue;
-}
-
-/*
- * 819xS single chip b-cut series cannot handle BAR
- */
-u8
-HTIOCActRejcectADDBARequest(struct ieee80211_network *network)
-{
- u8 retValue = 0;
- //if(IS_HARDWARE_TYPE_8192SE(Adapter) ||
- // IS_HARDWARE_TYPE_8192SU(Adapter)
- //)
- {
- // Do not reject ADDBA REQ because some of the AP may
- // keep on sending ADDBA REQ qhich cause DHCP fail or ping loss!
- // by HPFan, 2008/12/30
-
- //if(pBssDesc->Vender == HT_IOT_PEER_MARVELL)
- // return FALSE;
-
- }
-
- return retValue;
-
-}
-
-/*
- * EDCA parameters bias on downlink
- */
- u8
- HTIOTActIsEDCABiasRx(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- {
- if(pHTInfo->IOTPeer==HT_IOT_PEER_ATHEROS ||
- pHTInfo->IOTPeer==HT_IOT_PEER_BROADCOM ||
- pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
- return 1;
-
- }
- return retValue;
-}
-
-u8
-HTIOTActDisableShortGI(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK)
- {
- retValue = 1;
- }
-
- return retValue;
-}
-
-u8
-HTIOTActDisableHighPower(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- if(pHTInfo->IOTPeer==HT_IOT_PEER_RALINK ||
- pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK ||
- pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK_92SE)
- {
- retValue = 1;
- }
-
- return retValue;
-}
-
-void
-HTIOTActDetermineRaFunc(struct ieee80211_device* ieee, bool bPeerRx2ss)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- pHTInfo->IOTRaFunc &= HT_IOT_RAFUNC_DISABLE_ALL;
-
- if(pHTInfo->IOTPeer == HT_IOT_PEER_RALINK && !bPeerRx2ss)
- pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_PEER_1R;
-
- if(pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
- pHTInfo->IOTRaFunc |= HT_IOT_RAFUNC_TX_AMSDU;
-
- printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTRaFunc = %8.8x\n", pHTInfo->IOTRaFunc);
-}
-
-
-u8
-HTIOTActIsDisableTx40MHz(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP104 == ieee->group_key_type) ||
- (KEY_TYPE_WEP40 == ieee->group_key_type) ||
- (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
- {
- if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
- retValue = 1;
- }
-
- return retValue;
-}
-
-u8
-HTIOTActIsTxNoAggregation(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP104 == ieee->group_key_type) ||
- (KEY_TYPE_WEP40 == ieee->group_key_type) ||
- (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
- {
- if(pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK)
- retValue = 1;
- }
-
- return retValue;
-}
-
-
-u8
-HTIOTActIsDisableTx2SS(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- u8 retValue = 0;
-
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if( (KEY_TYPE_WEP104 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP40 == ieee->pairwise_key_type) ||
- (KEY_TYPE_WEP104 == ieee->group_key_type) ||
- (KEY_TYPE_WEP40 == ieee->group_key_type) ||
- (KEY_TYPE_TKIP == ieee->pairwise_key_type) )
- {
- if((pHTInfo->IOTPeer==HT_IOT_PEER_REALTEK) && (network->bssht.bdSupportHT))
- retValue = 1;
- }
-
- return retValue;
-}
-
-
-bool HTIOCActAllowPeerAggOnePacket(struct ieee80211_device* ieee,struct ieee80211_network *network)
-{
- bool retValue = false;
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
- {
- if((memcmp(network->bssid, NETGEAR_BROADCOM, 3)==0)
- && (network->bssht.bdBandWidth == HT_CHANNEL_WIDTH_20_40))
- return true;
- }
- return retValue;
-}
-
-void HTResetIOTSetting(
- PRT_HIGH_THROUGHPUT pHTInfo
-)
-{
- pHTInfo->IOTAction = 0;
- pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
- pHTInfo->IOTRaFunc = 0;
-}
-
-
-/********************************************************************************************************************
- *function: Construct Capablility Element in Beacon... if HTEnable is turned on
- * input: struct ieee80211_device* ieee
- * u8* posHTCap //pointer to store Capability Ele
- * u8* len //store length of CE
- * u8 IsEncrypt //whether encrypt, needed further
- * output: none
- * return: none
- * notice: posHTCap can't be null and should be initialized before.
- * *****************************************************************************************************************/
-void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
-{
- PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
- PHT_CAPABILITY_ELE pCapELE = NULL;
-
- if ((posHTCap == NULL) || (pHT == NULL))
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
- return;
- }
- memset(posHTCap, 0, *len);
- if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
- {
- u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
- memcpy(posHTCap, EWC11NHTCap, sizeof(EWC11NHTCap));
- pCapELE = (PHT_CAPABILITY_ELE)&(posHTCap[4]);
- }else
- {
- pCapELE = (PHT_CAPABILITY_ELE)posHTCap;
- }
-
-
- //HT capability info
- pCapELE->AdvCoding = 0; // This feature is not supported now!!
- if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
- {
- pCapELE->ChlWidth = 0;
- }
- else
- {
- pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
- }
-
- pCapELE->MimoPwrSave = pHT->SelfMimoPs;
- pCapELE->GreenField = 0; // This feature is not supported now!!
- pCapELE->ShortGI20Mhz = 1; // We can receive Short GI!!
- pCapELE->ShortGI40Mhz = 1; // We can receive Short GI!!
-
- pCapELE->TxSTBC = 1;
- pCapELE->RxSTBC = 0;
- pCapELE->DelayBA = 0; // Do not support now!!
- pCapELE->MaxAMSDUSize = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
- pCapELE->DssCCk = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
- pCapELE->PSMP = 0; // Do not support now!!
- pCapELE->LSigTxopProtect = 0; // Do not support now!!
-
-
- //MAC HT parameters info
- // TODO: Nedd to take care of this part
- IEEE80211_DEBUG(IEEE80211_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
-
- if( IsEncrypt)
- {
- pCapELE->MPDUDensity = 7; // 8us
- pCapELE->MaxRxAMPDUFactor = 2; // 2 is for 32 K and 3 is 64K
- }
- else
- {
- pCapELE->MaxRxAMPDUFactor = 3; // 2 is for 32 K and 3 is 64K
- pCapELE->MPDUDensity = 0; // no density
- }
-
- //Supported MCS set
- memcpy(pCapELE->MCS, ieee->Regdot11HTOperationalRateSet, 16);
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS15)
- pCapELE->MCS[1] &= 0x7f;
-
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_MCS14)
- pCapELE->MCS[1] &= 0xbf;
-
- if(pHT->IOTAction & HT_IOT_ACT_DISABLE_ALL_2SS)
- pCapELE->MCS[1] &= 0x00;
-
- // 2008.06.12
- // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
- if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
- {
- int i;
- for(i = 1; i< 16; i++)
- pCapELE->MCS[i] = 0;
- }
-
- //Extended HT Capability Info
- memset(&pCapELE->ExtHTCapInfo, 0, 2);
-
-
- //TXBF Capabilities
- memset(pCapELE->TxBFCap, 0, 4);
-
- //Antenna Selection Capabilities
- pCapELE->ASCap = 0;
-//add 2 to give space for element ID and len when construct frames
- if(pHT->ePeerHTSpecVer == HT_SPEC_VER_EWC)
- *len = 30 + 2;
- else
- *len = 26 + 2;
-
- return;
-
-}
-/********************************************************************************************************************
- *function: Construct Information Element in Beacon... if HTEnable is turned on
- * input: struct ieee80211_device* ieee
- * u8* posHTCap //pointer to store Information Ele
- * u8* len //store len of
- * u8 IsEncrypt //whether encrypt, needed further
- * output: none
- * return: none
- * notice: posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
- * *****************************************************************************************************************/
-void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 IsEncrypt)
-{
- PRT_HIGH_THROUGHPUT pHT = ieee->pHTInfo;
- PHT_INFORMATION_ELE pHTInfoEle = (PHT_INFORMATION_ELE)posHTInfo;
- if ((posHTInfo == NULL) || (pHTInfoEle == NULL))
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
- return;
- }
-
- memset(posHTInfo, 0, *len);
- if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
- {
- pHTInfoEle->ControlChl = ieee->current_network.channel;
- pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
- (ieee->current_network.channel<=6)?
- HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
- pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz;
- pHTInfoEle->RIFS = 0;
- pHTInfoEle->PSMPAccessOnly = 0;
- pHTInfoEle->SrvIntGranularity = 0;
- pHTInfoEle->OptMode = pHT->CurrentOpMode;
- pHTInfoEle->NonGFDevPresent = 0;
- pHTInfoEle->DualBeacon = 0;
- pHTInfoEle->SecondaryBeacon = 0;
- pHTInfoEle->LSigTxopProtectFull = 0;
- pHTInfoEle->PcoActive = 0;
- pHTInfoEle->PcoPhase = 0;
-
- memset(pHTInfoEle->BasicMSC, 0, 16);
-
-
- *len = 22 + 2; //same above
-
- }
- else
- {
- //STA should not generate High Throughput Information Element
- *len = 0;
- }
- return;
-}
-
-/*
- * According to experiment, Realtek AP to STA (based on rtl8190) may achieve best performance
- * if both STA and AP set limitation of aggregation size to 32K, that is, set AMPDU density to 2
- * (Ref: IEEE 11n specification). However, if Realtek STA associates to other AP, STA should set
- * limitation of aggregation size to 8K, otherwise, performance of traffic stream from STA to AP
- * will be much less than the traffic stream from AP to STA if both of the stream runs concurrently
- * at the same time.
- *
- * Frame Format
- * Element ID Length OUI Type1 Reserved
- * 1 byte 1 byte 3 bytes 1 byte 1 byte
- *
- * OUI = 0x00, 0xe0, 0x4c,
- * Type = 0x02
- * Reserved = 0x00
- *
- * 2007.8.21 by Emily
-*/
-/********************************************************************************************************************
- *function: Construct Information Element in Beacon... in RT2RT condition
- * input: struct ieee80211_device* ieee
- * u8* posRT2RTAgg //pointer to store Information Ele
- * u8* len //store len
- * output: none
- * return: none
- * notice:
- * *****************************************************************************************************************/
-void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len)
-{
- if (posRT2RTAgg == NULL) {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
- return;
- }
- memset(posRT2RTAgg, 0, *len);
- *posRT2RTAgg++ = 0x00;
- *posRT2RTAgg++ = 0xe0;
- *posRT2RTAgg++ = 0x4c;
- *posRT2RTAgg++ = 0x02;
- *posRT2RTAgg++ = 0x01;
- *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
-
- if(ieee->bSupportRemoteWakeUp) {
- *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
- }
-
- *len = 6 + 2;
- return;
-#ifdef TODO
-#if(HAL_CODE_BASE == RTL8192 && DEV_BUS_TYPE == USB_INTERFACE)
- /*
- //Emily. If it is required to Ask Realtek AP to send AMPDU during AES mode, enable this
- section of code.
- if(IS_UNDER_11N_AES_MODE(Adapter))
- {
- posRT2RTAgg->Octet[5] |=RT_HT_CAP_USE_AMPDU;
- }else
- {
- posRT2RTAgg->Octet[5] &= 0xfb;
- }
- */
-
-#else
-#endif
-
- posRT2RTAgg->Length = 6;
-#endif
-
-
-
-
-}
-
-
-/********************************************************************************************************************
- *function: Pick the right Rate Adaptive table to use
- * input: struct ieee80211_device* ieee
- * u8* pOperateMCS //A pointer to MCS rate bitmap
- * return: always we return true
- * notice:
- * *****************************************************************************************************************/
-u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
-{
- u8 i;
- if (pOperateMCS == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "pOperateMCS can't be null in HT_PickMCSRate()\n");
- return false;
- }
-
- switch(ieee->mode)
- {
- case IEEE_A:
- case IEEE_B:
- case IEEE_G:
- //legacy rate routine handled at selectedrate
-
- //no MCS rate
- for(i=0;i<=15;i++){
- pOperateMCS[i] = 0;
- }
- break;
-
- case IEEE_N_24G: //assume CCK rate ok
- case IEEE_N_5G:
- // Legacy part we only use 6, 5.5,2,1 for N_24G and 6 for N_5G.
- // Legacy part shall be handled at SelectRateSet().
-
- //HT part
- // TODO: may be different if we have different number of antenna
- pOperateMCS[0] &=RATE_ADPT_1SS_MASK; //support MCS 0~7
- pOperateMCS[1] &=RATE_ADPT_2SS_MASK;
- pOperateMCS[3] &=RATE_ADPT_MCS32_MASK;
- break;
-
- //should never reach here
- default:
-
- break;
-
- }
-
- return true;
-}
-
-/*
-* Description:
-* This function will get the highest speed rate in input MCS set.
-*
-* /param Adapter Pionter to Adapter entity
-* pMCSRateSet Pointer to MCS rate bitmap
-* pMCSFilter Pointer to MCS rate filter
-*
-* /return Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter.
-*
-*/
-/********************************************************************************************************************
- *function: This function will get the highest speed rate in input MCS set.
- * input: struct ieee80211_device* ieee
- * u8* pMCSRateSet //Pointer to MCS rate bitmap
- * u8* pMCSFilter //Pointer to MCS rate filter
- * return: Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
- * notice:
- * *****************************************************************************************************************/
-u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter)
-{
- u8 i, j;
- u8 bitMap;
- u8 mcsRate = 0;
- u8 availableMcsRate[16];
- if (pMCSRateSet == NULL || pMCSFilter == NULL)
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
- return false;
- }
- for(i=0; i<16; i++)
- availableMcsRate[i] = pMCSRateSet[i] & pMCSFilter[i];
-
- for(i = 0; i < 16; i++)
- {
- if(availableMcsRate[i] != 0)
- break;
- }
- if(i == 16)
- return false;
-
- for(i = 0; i < 16; i++)
- {
- if(availableMcsRate[i] != 0)
- {
- bitMap = availableMcsRate[i];
- for(j = 0; j < 8; j++)
- {
- if((bitMap%2) != 0)
- {
- if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
- mcsRate = (8*i+j);
- }
- bitMap = bitMap>>1;
- }
- }
- }
- return (mcsRate|0x80);
-}
-
-
-
-/*
-**
-**1.Filter our operation rate set with AP's rate set
-**2.shall reference channel bandwidth, STBC, Antenna number
-**3.generate rate adative table for firmware
-**David 20060906
-**
-** \pHTSupportedCap: the connected STA's supported rate Capability element
-*/
-u8 HTFilterMCSRate( struct ieee80211_device* ieee, u8* pSupportMCS, u8* pOperateMCS)
-{
-
- u8 i=0;
-
- // filter out operational rate set not supported by AP, the lenth of it is 16
- for(i=0;i<=15;i++){
- pOperateMCS[i] = ieee->Regdot11HTOperationalRateSet[i]&pSupportMCS[i];
- }
-
-
- // TODO: adjust our operational rate set according to our channel bandwidth, STBC and Antenna number
-
- // TODO: fill suggested rate adaptive rate index and give firmware info using Tx command packet
- // we also shall suggested the first start rate set according to our singal strength
- HT_PickMCSRate(ieee, pOperateMCS);
-
- // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
- if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
- pOperateMCS[1] = 0;
-
- //
- // For RTL819X, we support only MCS0~15.
- // And also, we do not know how to use MCS32 now.
- //
- for(i=2; i<=15; i++)
- pOperateMCS[i] = 0;
-
- return true;
-}
-void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset);
-
-void HTOnAssocRsp(struct ieee80211_device *ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
- PHT_CAPABILITY_ELE pPeerHTCap = NULL;
- PHT_INFORMATION_ELE pPeerHTInfo = NULL;
- u16 nMaxAMSDUSize = 0;
- u8* pMcsFilter = NULL;
-
- static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily
- static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily
-
- if( pHTInfo->bCurrentHTSupport == false )
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n");
- return;
- }
- IEEE80211_DEBUG(IEEE80211_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
-
- if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap)))
- pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]);
- else
- pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf);
-
- if(!memcmp(pHTInfo->PeerHTInfoBuf, EWC11NHTInfo, sizeof(EWC11NHTInfo)))
- pPeerHTInfo = (PHT_INFORMATION_ELE)(&pHTInfo->PeerHTInfoBuf[4]);
- else
- pPeerHTInfo = (PHT_INFORMATION_ELE)(pHTInfo->PeerHTInfoBuf);
-
-
- ////////////////////////////////////////////////////////
- // Configurations:
- ////////////////////////////////////////////////////////
- IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_HT, pPeerHTCap, sizeof(HT_CAPABILITY_ELE));
-
- HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset));
-
- if(pHTInfo->bCurBW40MHz == true)
- pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false);
-
- //
- // Update short GI/ long GI setting
- //
- // TODO:
- pHTInfo->bCurShortGI20MHz=
- ((pHTInfo->bRegShortGI20MHz)?((pPeerHTCap->ShortGI20Mhz==1)?true:false):false);
- pHTInfo->bCurShortGI40MHz=
- ((pHTInfo->bRegShortGI40MHz)?((pPeerHTCap->ShortGI40Mhz==1)?true:false):false);
-
- //
- // Config TX STBC setting
- //
- // TODO:
-
- //
- // Config DSSS/CCK mode in 40MHz mode
- //
- // TODO:
- pHTInfo->bCurSuppCCK =
- ((pHTInfo->bRegSuppCCK)?((pPeerHTCap->DssCCk==1)?true:false):false);
-
-
- //
- // Config and configure A-MSDU setting
- //
- pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
-
- nMaxAMSDUSize = (pPeerHTCap->MaxAMSDUSize==0)?3839:7935;
-
- if(pHTInfo->nAMSDU_MaxSize > nMaxAMSDUSize )
- pHTInfo->nCurrent_AMSDU_MaxSize = nMaxAMSDUSize;
- else
- pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
-
- //
- // Config A-MPDU setting
- //
- pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
- if(ieee->is_ap_in_wep_tkip && ieee->is_ap_in_wep_tkip(ieee->dev))
- {
- if( (pHTInfo->IOTPeer== HT_IOT_PEER_ATHEROS) ||
- (pHTInfo->IOTPeer == HT_IOT_PEER_UNKNOWN) )
- pHTInfo->bCurrentAMPDUEnable = false;
- }
-
- // <1> Decide AMPDU Factor
-
- // By Emily
- if(!pHTInfo->bRegRT2RTAggregation)
- {
- // Decide AMPDU Factor according to protocol handshake
- if(pHTInfo->AMPDU_Factor > pPeerHTCap->MaxRxAMPDUFactor)
- pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
- else
- pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
-
- }else
- {
- // Set MPDU density to 2 to Realtek AP, and set it to 0 for others
- // Replace MPDU factor declared in original association response frame format. 2007.08.20 by Emily
- if (ieee->current_network.bssht.bdRT2RTAggregation)
- {
- if( ieee->pairwise_key_type != KEY_TYPE_NA)
- // Realtek may set 32k in security mode and 64k for others
- pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
- else
- pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_64K;
- }else
- {
- if(pPeerHTCap->MaxRxAMPDUFactor < HT_AGG_SIZE_32K)
- pHTInfo->CurrentAMPDUFactor = pPeerHTCap->MaxRxAMPDUFactor;
- else
- pHTInfo->CurrentAMPDUFactor = HT_AGG_SIZE_32K;
- }
- }
-
- // <2> Set AMPDU Minimum MPDU Start Spacing
- // 802.11n 3.0 section 9.7d.3
-#if 0
- if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
- pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
- else
- pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
- if(ieee->pairwise_key_type != KEY_TYPE_NA )
- pHTInfo->CurrentMPDUDensity = 7; // 8us
-#else
- if(pHTInfo->MPDU_Density > pPeerHTCap->MPDUDensity)
- pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
- else
- pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
-#endif
- // Force TX AMSDU
-
- // Lanhsin: mark for tmp to avoid deauth by ap from s3
- //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
- if(pHTInfo->IOTAction & HT_IOT_ACT_TX_USE_AMSDU_8K)
- {
-
- pHTInfo->bCurrentAMPDUEnable = false;
- pHTInfo->ForcedAMSDUMode = HT_AGG_FORCE_ENABLE;
- pHTInfo->ForcedAMSDUMaxSize = 7935;
- }
-
- // Rx Reorder Setting
- pHTInfo->bCurRxReorderEnable = pHTInfo->bRegRxReorderEnable;
-
- //
- // Filter out unsupported HT rate for this AP
- // Update RATR table
- // This is only for 8190 ,8192 or later product which using firmware to handle rate adaptive mechanism.
- //
-
- // Handle Ralink AP bad MCS rate set condition. Joseph.
- // This fix the bug of Ralink AP. This may be removed in the future.
- if(pPeerHTCap->MCS[0] == 0)
- pPeerHTCap->MCS[0] = 0xff;
-
- // Joseph test //LZM ADD 090318
- HTIOTActDetermineRaFunc(ieee, ((pPeerHTCap->MCS[1])!=0));
-
- HTFilterMCSRate(ieee, pPeerHTCap->MCS, ieee->dot11HTOperationalRateSet);
-
- //
- // Config MIMO Power Save setting
- //
- pHTInfo->PeerMimoPs = pPeerHTCap->MimoPwrSave;
- if(pHTInfo->PeerMimoPs == MIMO_PS_STATIC)
- pMcsFilter = MCS_FILTER_1SS;
- else
- pMcsFilter = MCS_FILTER_ALL;
- //WB add for MCS8 bug
-// pMcsFilter = MCS_FILTER_1SS;
- ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, pMcsFilter);
- ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
-
- //
- // Config current operation mode.
- //
- pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
-
-
-
-}
-
-void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
-/********************************************************************************************************************
- *function: initialize HT info(struct PRT_HIGH_THROUGHPUT)
- * input: struct ieee80211_device* ieee
- * output: none
- * return: none
- * notice: This function is called when * (1) MPInitialization Phase * (2) Receiving of Deauthentication from AP
-********************************************************************************************************************/
-// TODO: Should this funciton be called when receiving of Disassociation?
-void HTInitializeHTInfo(struct ieee80211_device* ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- //
- // These parameters will be reset when receiving deauthentication packet
- //
- IEEE80211_DEBUG(IEEE80211_DL_HT, "===========>%s()\n", __FUNCTION__);
- pHTInfo->bCurrentHTSupport = false;
-
- // 40MHz channel support
- pHTInfo->bCurBW40MHz = false;
- pHTInfo->bCurTxBW40MHz = false;
-
- // Short GI support
- pHTInfo->bCurShortGI20MHz = false;
- pHTInfo->bCurShortGI40MHz = false;
- pHTInfo->bForcedShortGI = false;
-
- // CCK rate support
- // This flag is set to true to support CCK rate by default.
- // It will be affected by "pHTInfo->bRegSuppCCK" and AP capabilities only when associate to
- // 11N BSS.
- pHTInfo->bCurSuppCCK = true;
-
- // AMSDU related
- pHTInfo->bCurrent_AMSDU_Support = false;
- pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
-
- // AMPUD related
- pHTInfo->CurrentMPDUDensity = pHTInfo->MPDU_Density;
- pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
-
-
-
- // Initialize all of the parameters related to 11n
- memset((void*)(&(pHTInfo->SelfHTCap)), 0, sizeof(pHTInfo->SelfHTCap));
- memset((void*)(&(pHTInfo->SelfHTInfo)), 0, sizeof(pHTInfo->SelfHTInfo));
- memset((void*)(&(pHTInfo->PeerHTCapBuf)), 0, sizeof(pHTInfo->PeerHTCapBuf));
- memset((void*)(&(pHTInfo->PeerHTInfoBuf)), 0, sizeof(pHTInfo->PeerHTInfoBuf));
-
- pHTInfo->bSwBwInProgress = false;
- pHTInfo->ChnlOp = CHNLOP_NONE;
-
- // Set default IEEE spec for Draft N
- pHTInfo->ePeerHTSpecVer = HT_SPEC_VER_IEEE;
-
- // Realtek proprietary aggregation mode
- pHTInfo->bCurrentRT2RTAggregation = false;
- pHTInfo->bCurrentRT2RTLongSlotTime = false;
- pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
-
- pHTInfo->IOTPeer = 0;
- pHTInfo->IOTAction = 0;
- pHTInfo->IOTRaFunc = 0;
-
- //MCS rate initialized here
- {
- u8* RegHTSuppRateSets = &(ieee->RegHTSuppRateSet[0]);
- RegHTSuppRateSets[0] = 0xFF; //support MCS 0~7
- RegHTSuppRateSets[1] = 0xFF; //support MCS 8~15
- RegHTSuppRateSets[4] = 0x01; //support MCS 32
- }
-}
-/********************************************************************************************************************
- *function: initialize Bss HT structure(struct PBSS_HT)
- * input: PBSS_HT pBssHT //to be initialized
- * output: none
- * return: none
- * notice: This function is called when initialize network structure
-********************************************************************************************************************/
-void HTInitializeBssDesc(PBSS_HT pBssHT)
-{
-
- pBssHT->bdSupportHT = false;
- memset(pBssHT->bdHTCapBuf, 0, sizeof(pBssHT->bdHTCapBuf));
- pBssHT->bdHTCapLen = 0;
- memset(pBssHT->bdHTInfoBuf, 0, sizeof(pBssHT->bdHTInfoBuf));
- pBssHT->bdHTInfoLen = 0;
-
- pBssHT->bdHTSpecVer= HT_SPEC_VER_IEEE;
-
- pBssHT->bdRT2RTAggregation = false;
- pBssHT->bdRT2RTLongSlotTime = false;
- pBssHT->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
-}
-
-/********************************************************************************************************************
- *function: initialize Bss HT structure(struct PBSS_HT)
- * input: struct ieee80211_device *ieee
- * struct ieee80211_network *pNetwork //usually current network we are live in
- * output: none
- * return: none
- * notice: This function should ONLY be called before association
-********************************************************************************************************************/
-void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-// u16 nMaxAMSDUSize;
-// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
-// PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
-// u8* pMcsFilter;
- u8 bIOTAction = 0;
-
- //
- // Save Peer Setting before Association
- //
- IEEE80211_DEBUG(IEEE80211_DL_HT, "==============>%s()\n", __FUNCTION__);
- /*unmark bEnableHT flag here is the same reason why unmarked in function ieee80211_softmac_new_net. WB 2008.09.10*/
-// if( pHTInfo->bEnableHT && pNetwork->bssht.bdSupportHT)
- if (pNetwork->bssht.bdSupportHT)
- {
- pHTInfo->bCurrentHTSupport = true;
- pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
-
- // Save HTCap and HTInfo information Element
- if(pNetwork->bssht.bdHTCapLen > 0 && pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
- memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
-
- if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
- memcpy(pHTInfo->PeerHTInfoBuf, pNetwork->bssht.bdHTInfoBuf, pNetwork->bssht.bdHTInfoLen);
-
- // Check whether RT to RT aggregation mode is enabled
- if(pHTInfo->bRegRT2RTAggregation)
- {
- pHTInfo->bCurrentRT2RTAggregation = pNetwork->bssht.bdRT2RTAggregation;
- pHTInfo->bCurrentRT2RTLongSlotTime = pNetwork->bssht.bdRT2RTLongSlotTime;
- pHTInfo->RT2RT_HT_Mode = pNetwork->bssht.RT2RT_HT_Mode;
- }
- else
- {
- pHTInfo->bCurrentRT2RTAggregation = false;
- pHTInfo->bCurrentRT2RTLongSlotTime = false;
- pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
- }
-
- // Determine the IOT Peer Vendor.
- HTIOTPeerDetermine(ieee);
-
- // Decide IOT Action
- // Must be called after the parameter of pHTInfo->bCurrentRT2RTAggregation is decided
- pHTInfo->IOTAction = 0;
- bIOTAction = HTIOTActIsDisableMCS14(ieee, pNetwork->bssid);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS14;
-
- bIOTAction = HTIOTActIsDisableMCS15(ieee);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_MCS15;
-
- bIOTAction = HTIOTActIsDisableMCSTwoSpatialStream(ieee);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_ALL_2SS;
-
-
- bIOTAction = HTIOTActIsDisableEDCATurbo(ieee, pNetwork->bssid);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
-
- bIOTAction = HTIOTActIsMgntUseCCK6M(pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_MGNT_USE_CCK_6M;
-
- bIOTAction = HTIOTActIsCCDFsync(pNetwork->bssid);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_CDD_FSYNC;
-
- bIOTAction = HTIOTActIsForcedCTS2Self(pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
-
- //bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
- //if(bIOTAction)
- // pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
-
- bIOTAction = HTIOCActRejcectADDBARequest(pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_REJECT_ADDBA_REQ;
-
- bIOTAction = HTIOCActAllowPeerAggOnePacket(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_ALLOW_PEER_AGG_ONE_PKT;
-
- bIOTAction = HTIOTActIsEDCABiasRx(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_EDCA_BIAS_ON_RX;
-
- bIOTAction = HTIOTActDisableShortGI(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_SHORT_GI;
-
- bIOTAction = HTIOTActDisableHighPower(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_HIGH_POWER;
-
- bIOTAction = HTIOTActIsForcedAMSDU8K(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_TX_USE_AMSDU_8K;
-
- bIOTAction = HTIOTActIsTxNoAggregation(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_TX_NO_AGGREGATION;
-
- bIOTAction = HTIOTActIsDisableTx40MHz(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_40_MHZ;
-
- bIOTAction = HTIOTActIsDisableTx2SS(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_TX_2SS;
- //must after HT_IOT_ACT_TX_NO_AGGREGATION
- bIOTAction = HTIOTActIsForcedRTSCTS(ieee, pNetwork);
- if(bIOTAction)
- pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_RTS;
-
- printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!IOTAction = %8.8x\n", pHTInfo->IOTAction);
- }
- else
- {
- pHTInfo->bCurrentHTSupport = false;
- pHTInfo->bCurrentRT2RTAggregation = false;
- pHTInfo->bCurrentRT2RTLongSlotTime = false;
- pHTInfo->RT2RT_HT_Mode = (RT_HT_CAPBILITY)0;
-
- pHTInfo->IOTAction = 0;
- pHTInfo->IOTRaFunc = 0;
- }
-
-}
-
-void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-// PHT_CAPABILITY_ELE pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
- PHT_INFORMATION_ELE pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
-
- if(pHTInfo->bCurrentHTSupport)
- {
- //
- // Config current operation mode.
- //
- if(pNetwork->bssht.bdHTInfoLen != 0)
- pHTInfo->CurrentOpMode = pPeerHTInfo->OptMode;
-
- //
- // <TODO: Config according to OBSS non-HT STA present!!>
- //
- }
-}
-
-void HTUseDefaultSetting(struct ieee80211_device* ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-// u8 regBwOpMode;
-
- if(pHTInfo->bEnableHT)
- {
- pHTInfo->bCurrentHTSupport = true;
-
- pHTInfo->bCurSuppCCK = pHTInfo->bRegSuppCCK;
-
- pHTInfo->bCurBW40MHz = pHTInfo->bRegBW40MHz;
-
- pHTInfo->bCurShortGI20MHz= pHTInfo->bRegShortGI20MHz;
-
- pHTInfo->bCurShortGI40MHz= pHTInfo->bRegShortGI40MHz;
-
- pHTInfo->bCurrent_AMSDU_Support = pHTInfo->bAMSDU_Support;
-
- pHTInfo->nCurrent_AMSDU_MaxSize = pHTInfo->nAMSDU_MaxSize;
-
- pHTInfo->bCurrentAMPDUEnable = pHTInfo->bAMPDUEnable;
-
- pHTInfo->CurrentAMPDUFactor = pHTInfo->AMPDU_Factor;
-
- pHTInfo->CurrentMPDUDensity = pHTInfo->CurrentMPDUDensity;
-
- // Set BWOpMode register
-
- //update RATR index0
- HTFilterMCSRate(ieee, ieee->Regdot11HTOperationalRateSet, ieee->dot11HTOperationalRateSet);
- //function below is not implemented at all. WB
-#ifdef TODO
- Adapter->HalFunc.InitHalRATRTableHandler( Adapter, &pMgntInfo->dot11OperationalRateSet, pMgntInfo->dot11HTOperationalRateSet);
-#endif
- ieee->HTHighestOperaRate = HTGetHighestMCSRate(ieee, ieee->dot11HTOperationalRateSet, MCS_FILTER_ALL);
- ieee->HTCurrentOperaRate = ieee->HTHighestOperaRate;
-
- }
- else
- {
- pHTInfo->bCurrentHTSupport = false;
- }
- return;
-}
-/********************************************************************************************************************
- *function: check whether HT control field exists
- * input: struct ieee80211_device *ieee
- * u8* pFrame //coming skb->data
- * output: none
- * return: return true if HT control field exists(false otherwise)
- * notice:
-********************************************************************************************************************/
-u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame)
-{
- if(ieee->pHTInfo->bCurrentHTSupport)
- {
- if( (IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1)
- {
- IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
- return true;
- }
- }
- return false;
-}
-
-//
-// This function set bandwidth mode in protocol layer.
-//
-void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-// u32 flags = 0;
-
- if(pHTInfo->bRegBW40MHz == false)
- return;
-
-
-
- // To reduce dummy operation
-// if((pHTInfo->bCurBW40MHz==false && Bandwidth==HT_CHANNEL_WIDTH_20) ||
-// (pHTInfo->bCurBW40MHz==true && Bandwidth==HT_CHANNEL_WIDTH_20_40 && Offset==pHTInfo->CurSTAExtChnlOffset))
-// return;
-
-// spin_lock_irqsave(&(ieee->bw_spinlock), flags);
- if(pHTInfo->bSwBwInProgress) {
-// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
- return;
- }
- //if in half N mode, set to 20M bandwidth please 09.08.2008 WB.
- if(Bandwidth==HT_CHANNEL_WIDTH_20_40 && (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)))
- {
- // Handle Illegal extention channel offset!!
- if(ieee->current_network.channel<2 && Offset==HT_EXTCHNL_OFFSET_LOWER)
- Offset = HT_EXTCHNL_OFFSET_NO_EXT;
- if(Offset==HT_EXTCHNL_OFFSET_UPPER || Offset==HT_EXTCHNL_OFFSET_LOWER) {
- pHTInfo->bCurBW40MHz = true;
- pHTInfo->CurSTAExtChnlOffset = Offset;
- } else {
- pHTInfo->bCurBW40MHz = false;
- pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
- }
- } else {
- pHTInfo->bCurBW40MHz = false;
- pHTInfo->CurSTAExtChnlOffset = HT_EXTCHNL_OFFSET_NO_EXT;
- }
-
- pHTInfo->bSwBwInProgress = true;
-
- // TODO: 2007.7.13 by Emily Wait 2000ms in order to garantee that switching
- // bandwidth is executed after scan is finished. It is a temporal solution
- // because software should ganrantee the last operation of switching bandwidth
- // is executed properlly.
- HTSetConnectBwModeCallback(ieee);
-
-// spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
-}
-
-void HTSetConnectBwModeCallback(struct ieee80211_device* ieee)
-{
- PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
-
- IEEE80211_DEBUG(IEEE80211_DL_HT, "======>%s()\n", __FUNCTION__);
- if(pHTInfo->bCurBW40MHz)
- {
- if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_UPPER)
- ieee->set_chan(ieee->dev, ieee->current_network.channel+2);
- else if(pHTInfo->CurSTAExtChnlOffset==HT_EXTCHNL_OFFSET_LOWER)
- ieee->set_chan(ieee->dev, ieee->current_network.channel-2);
- else
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
-
- ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20_40, pHTInfo->CurSTAExtChnlOffset);
- } else {
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- ieee->SetBWModeHandler(ieee->dev, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
- }
-
- pHTInfo->bSwBwInProgress = false;
-}
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
deleted file mode 100644
index 928062f35713..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_Qos.h
+++ /dev/null
@@ -1,540 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef __INC_QOS_TYPE_H
-#define __INC_QOS_TYPE_H
-
-#define BIT0 0x00000001
-#define BIT1 0x00000002
-#define BIT2 0x00000004
-#define BIT3 0x00000008
-#define BIT4 0x00000010
-#define BIT5 0x00000020
-#define BIT6 0x00000040
-#define BIT7 0x00000080
-#define BIT8 0x00000100
-#define BIT9 0x00000200
-#define BIT10 0x00000400
-#define BIT11 0x00000800
-#define BIT12 0x00001000
-#define BIT13 0x00002000
-#define BIT14 0x00004000
-#define BIT15 0x00008000
-#define BIT16 0x00010000
-#define BIT17 0x00020000
-#define BIT18 0x00040000
-#define BIT19 0x00080000
-#define BIT20 0x00100000
-#define BIT21 0x00200000
-#define BIT22 0x00400000
-#define BIT23 0x00800000
-#define BIT24 0x01000000
-#define BIT25 0x02000000
-#define BIT26 0x04000000
-#define BIT27 0x08000000
-#define BIT28 0x10000000
-#define BIT29 0x20000000
-#define BIT30 0x40000000
-#define BIT31 0x80000000
-
-#define MAX_WMMELE_LENGTH 64
-
-typedef u32 QOS_MODE, *PQOS_MODE;
-#define QOS_DISABLE 0
-#define QOS_WMM 1
-#define QOS_WMMSA 2
-#define QOS_EDCA 4
-#define QOS_HCCA 8
-#define QOS_WMM_UAPSD 16 //WMM Power Save, 2006-06-14 Isaiah
-
-#define AC_PARAM_SIZE 4
-#define WMM_PARAM_ELE_BODY_LEN 18
-
-//
-// QoS ACK Policy Field Values
-// Ref: WMM spec 2.1.6: QoS Control Field, p.10.
-//
-typedef enum _ACK_POLICY{
- eAckPlc0_ACK = 0x00,
- eAckPlc1_NoACK = 0x01,
-}ACK_POLICY,*PACK_POLICY;
-
-#define WMM_PARAM_ELEMENT_SIZE (8+(4*AC_PARAM_SIZE))
-
-//
-// QoS Control Field
-// Ref:
-// 1. WMM spec 2.1.6: QoS Control Field, p.9.
-// 2. 802.11e/D13.0 7.1.3.5, p.26.
-//
-typedef union _QOS_CTRL_FIELD{
- u8 charData[2];
- u16 shortData;
-
- // WMM spec
- struct
- {
- u8 UP:3;
- u8 usRsvd1:1;
- u8 EOSP:1;
- u8 AckPolicy:2;
- u8 usRsvd2:1;
- u8 ucRsvdByte;
- }WMM;
-
- // 802.11e: QoS data type frame sent by non-AP QSTAs.
- struct
- {
- u8 TID:4;
- u8 bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
- u8 AckPolicy:2;
- u8 usRsvd:1;
- u8 TxopOrQsize; // (BIT4=0)TXOP Duration Requested or (BIT4=1)Queue Size.
- }BySta;
-
- // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
- struct
- {
- u8 TID:4;
- u8 EOSP:1;
- u8 AckPolicy:2;
- u8 usRsvd:1;
- u8 PSBufState; // QAP PS Buffer State.
- }ByHc_Data;
-
- // 802.11e: QoS (+) CF-Poll frames sent by HC.
- struct
- {
- u8 TID:4;
- u8 EOSP:1;
- u8 AckPolicy:2;
- u8 usRsvd:1;
- u8 TxopLimit; // TXOP Limit.
- }ByHc_CFP;
-
-}QOS_CTRL_FIELD, *PQOS_CTRL_FIELD;
-
-
-//
-// QoS Info Field
-// Ref:
-// 1. WMM spec 2.2.1: WME Information Element, p.11.
-// 2. 8185 QoS code: QOS_INFO [def. in QoS_mp.h]
-//
-typedef union _QOS_INFO_FIELD{
- u8 charData;
-
- struct
- {
- u8 ucParameterSetCount:4;
- u8 ucReserved:4;
- }WMM;
-
- struct
- {
- //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
- u8 ucAC_VO_UAPSD:1;
- u8 ucAC_VI_UAPSD:1;
- u8 ucAC_BE_UAPSD:1;
- u8 ucAC_BK_UAPSD:1;
- u8 ucReserved1:1;
- u8 ucMaxSPLen:2;
- u8 ucReserved2:1;
-
- }ByWmmPsSta;
-
- struct
- {
- //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
- u8 ucParameterSetCount:4;
- u8 ucReserved:3;
- u8 ucApUapsd:1;
- }ByWmmPsAp;
-
- struct
- {
- u8 ucAC3_UAPSD:1;
- u8 ucAC2_UAPSD:1;
- u8 ucAC1_UAPSD:1;
- u8 ucAC0_UAPSD:1;
- u8 ucQAck:1;
- u8 ucMaxSPLen:2;
- u8 ucMoreDataAck:1;
- } By11eSta;
-
- struct
- {
- u8 ucParameterSetCount:4;
- u8 ucQAck:1;
- u8 ucQueueReq:1;
- u8 ucTXOPReq:1;
- u8 ucReserved:1;
- } By11eAp;
-
- struct
- {
- u8 ucReserved1:4;
- u8 ucQAck:1;
- u8 ucReserved2:2;
- u8 ucMoreDataAck:1;
- } ByWmmsaSta;
-
- struct
- {
- u8 ucReserved1:4;
- u8 ucQAck:1;
- u8 ucQueueReq:1;
- u8 ucTXOPReq:1;
- u8 ucReserved2:1;
- } ByWmmsaAp;
-
- struct
- {
- u8 ucAC3_UAPSD:1;
- u8 ucAC2_UAPSD:1;
- u8 ucAC1_UAPSD:1;
- u8 ucAC0_UAPSD:1;
- u8 ucQAck:1;
- u8 ucMaxSPLen:2;
- u8 ucMoreDataAck:1;
- } ByAllSta;
-
- struct
- {
- u8 ucParameterSetCount:4;
- u8 ucQAck:1;
- u8 ucQueueReq:1;
- u8 ucTXOPReq:1;
- u8 ucApUapsd:1;
- } ByAllAp;
-
-}QOS_INFO_FIELD, *PQOS_INFO_FIELD;
-
-typedef u32 AC_CODING;
-#define AC0_BE 0 // ACI: 0x00 // Best Effort
-#define AC1_BK 1 // ACI: 0x01 // Background
-#define AC2_VI 2 // ACI: 0x10 // Video
-#define AC3_VO 3 // ACI: 0x11 // Voice
-#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum.
-
-//
-// ACI/AIFSN Field.
-// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
-//
-typedef union _ACI_AIFSN{
- u8 charData;
-
- struct
- {
- u8 AIFSN:4;
- u8 ACM:1;
- u8 ACI:2;
- u8 Reserved:1;
- }f;
-}ACI_AIFSN, *PACI_AIFSN;
-
-//
-// ECWmin/ECWmax field.
-// Ref: WMM spec 2.2.2: WME Parameter Element, p.13.
-//
-typedef union _ECW{
- u8 charData;
- struct
- {
- u8 ECWmin:4;
- u8 ECWmax:4;
- }f;
-}ECW, *PECW;
-
-//
-// AC Parameters Record Format.
-// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
-//
-typedef union _AC_PARAM{
- u32 longData;
- u8 charData[4];
-
- struct
- {
- ACI_AIFSN AciAifsn;
- ECW Ecw;
- u16 TXOPLimit;
- }f;
-}AC_PARAM, *PAC_PARAM;
-
-
-
-//
-// QoS element subtype
-//
-typedef enum _QOS_ELE_SUBTYPE{
- QOSELE_TYPE_INFO = 0x00, // 0x00: Information element
- QOSELE_TYPE_PARAM = 0x01, // 0x01: parameter element
-}QOS_ELE_SUBTYPE,*PQOS_ELE_SUBTYPE;
-
-
-//
-// Direction Field Values.
-// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
-//
-typedef enum _DIRECTION_VALUE{
- DIR_UP = 0, // 0x00 // UpLink
- DIR_DOWN = 1, // 0x01 // DownLink
- DIR_DIRECT = 2, // 0x10 // DirectLink
- DIR_BI_DIR = 3, // 0x11 // Bi-Direction
-}DIRECTION_VALUE,*PDIRECTION_VALUE;
-
-
-//
-// TS Info field in WMM TSPEC Element.
-// Ref:
-// 1. WMM spec 2.2.11: WME TSPEC Element, p.18.
-// 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
-//
-typedef union _QOS_TSINFO{
- u8 charData[3];
- struct {
- u8 ucTrafficType:1; //WMM is reserved
- u8 ucTSID:4;
- u8 ucDirection:2;
- u8 ucAccessPolicy:2; //WMM: bit8=0, bit7=1
- u8 ucAggregation:1; //WMM is reserved
- u8 ucPSB:1; //WMMSA is APSD
- u8 ucUP:3;
- u8 ucTSInfoAckPolicy:2; //WMM is reserved
- u8 ucSchedule:1; //WMM is reserved
- u8 ucReserved:7;
- }field;
-}QOS_TSINFO, *PQOS_TSINFO;
-
-//
-// WMM TSPEC Body.
-// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
-//
-typedef union _TSPEC_BODY{
- u8 charData[55];
-
- struct
- {
- QOS_TSINFO TSInfo; //u8 TSInfo[3];
- u16 NominalMSDUsize;
- u16 MaxMSDUsize;
- u32 MinServiceItv;
- u32 MaxServiceItv;
- u32 InactivityItv;
- u32 SuspenItv;
- u32 ServiceStartTime;
- u32 MinDataRate;
- u32 MeanDataRate;
- u32 PeakDataRate;
- u32 MaxBurstSize;
- u32 DelayBound;
- u32 MinPhyRate;
- u16 SurplusBandwidthAllowance;
- u16 MediumTime;
- } f;
-}TSPEC_BODY, *PTSPEC_BODY;
-
-
-//
-// WMM TSPEC Element.
-// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
-//
-typedef struct _WMM_TSPEC{
- u8 ID;
- u8 Length;
- u8 OUI[3];
- u8 OUI_Type;
- u8 OUI_SubType;
- u8 Version;
- TSPEC_BODY Body;
-} WMM_TSPEC, *PWMM_TSPEC;
-
-//
-// ACM implementation method.
-// Annie, 2005-12-13.
-//
-typedef enum _ACM_METHOD{
- eAcmWay0_SwAndHw = 0, // By SW and HW.
- eAcmWay1_HW = 1, // By HW.
- eAcmWay2_SW = 2, // By SW.
-}ACM_METHOD,*PACM_METHOD;
-
-
-typedef struct _ACM{
- u64 UsedTime;
- u64 MediumTime;
- u8 HwAcmCtl; // TRUE: UsedTime exceed => Do NOT USE this AC. It wll be written to ACM_CONTROL(0xBF BIT 0/1/2 in 8185B).
-}ACM, *PACM;
-
-typedef u8 AC_UAPSD, *PAC_UAPSD;
-
-#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0)
-#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0)
-
-#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1)
-#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1)
-
-#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2)
-#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2)
-
-#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3)
-#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3)
-
-typedef union _QOS_TCLAS{
-
- struct _TYPE_GENERAL{
- u8 Priority;
- u8 ClassifierType;
- u8 Mask;
- } TYPE_GENERAL;
-
- struct _TYPE0_ETH{
- u8 Priority;
- u8 ClassifierType;
- u8 Mask;
- u8 SrcAddr[6];
- u8 DstAddr[6];
- u16 Type;
- } TYPE0_ETH;
-
- struct _TYPE1_IPV4{
- u8 Priority;
- u8 ClassifierType;
- u8 Mask;
- u8 Version;
- u8 SrcIP[4];
- u8 DstIP[4];
- u16 SrcPort;
- u16 DstPort;
- u8 DSCP;
- u8 Protocol;
- u8 Reserved;
- } TYPE1_IPV4;
-
- struct _TYPE1_IPV6{
- u8 Priority;
- u8 ClassifierType;
- u8 Mask;
- u8 Version;
- u8 SrcIP[16];
- u8 DstIP[16];
- u16 SrcPort;
- u16 DstPort;
- u8 FlowLabel[3];
- } TYPE1_IPV6;
-
- struct _TYPE2_8021Q{
- u8 Priority;
- u8 ClassifierType;
- u8 Mask;
- u16 TagType;
- } TYPE2_8021Q;
-} QOS_TCLAS, *PQOS_TCLAS;
-
-typedef struct _QOS_TSTREAM{
- u8 AC;
- WMM_TSPEC TSpec;
- QOS_TCLAS TClass;
-} QOS_TSTREAM, *PQOS_TSTREAM;
-
-//----------------------------------------------------------------------------
-// 802.11 Management frame Status Code field
-//----------------------------------------------------------------------------
-typedef struct _OCTET_STRING{
- u8 *Octet;
- u16 Length;
-}OCTET_STRING, *POCTET_STRING;
-
-//
-// STA QoS data.
-// Ref: DOT11_QOS in 8185 code. [def. in QoS_mp.h]
-//
-typedef struct _STA_QOS{
- u8 WMMIEBuf[MAX_WMMELE_LENGTH];
- u8* WMMIE;
-
- // Part 1. Self QoS Mode.
- QOS_MODE QosCapability; //QoS Capability, 2006-06-14 Isaiah
- QOS_MODE CurrentQosMode;
-
- // For WMM Power Save Mode :
- // ACs are trigger/delivery enabled or legacy power save enabled. 2006-06-13 Isaiah
- AC_UAPSD b4ac_Uapsd; //VoUapsd(bit0), ViUapsd(bit1), BkUapsd(bit2), BeUapsd(bit3),
- AC_UAPSD Curr4acUapsd;
- u8 bInServicePeriod;
- u8 MaxSPLength;
- int NumBcnBeforeTrigger;
-
- // Part 2. EDCA Parameter (perAC)
- u8 * pWMMInfoEle;
- u8 WMMParamEle[WMM_PARAM_ELEMENT_SIZE];
- u8 WMMPELength;
-
- // <Bruce_Note>
- //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
- // By Bruce, 2008-01-30.
- // Part 2. EDCA Parameter (perAC)
- QOS_INFO_FIELD QosInfoField_STA; // Maintained by STA
- QOS_INFO_FIELD QosInfoField_AP; // Retrieved from AP
-
- AC_PARAM CurAcParameters[4];
-
- // Part 3. ACM
- ACM acm[4];
- ACM_METHOD AcmMethod;
-
- // Part 4. Per TID (Part 5: TCLASS will be described by TStream)
- QOS_TSTREAM TStream[16];
- WMM_TSPEC TSpec;
-
- u32 QBssWirelessMode;
-
- // No Ack Setting
- u8 bNoAck;
-
- // Enable/Disable Rx immediate BA capability.
- u8 bEnableRxImmBA;
-
-}STA_QOS, *PSTA_QOS;
-
-//
-// BSS QOS data.
-// Ref: BssDscr in 8185 code. [def. in BssDscr.h]
-//
-typedef struct _BSS_QOS{
- QOS_MODE bdQoSMode;
-
- u8 bdWMMIEBuf[MAX_WMMELE_LENGTH];
- u8* bdWMMIE;
-
- QOS_ELE_SUBTYPE EleSubType;
-
- u8 * pWMMInfoEle;
- u8 * pWMMParamEle;
-
- QOS_INFO_FIELD QosInfoField;
- AC_PARAM AcParameter[4];
-}BSS_QOS, *PBSS_QOS;
-
-#define sQoSCtlLng 2
-#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE)? sQoSCtlLng : 0)
-
-#define IsACValid(ac) ((ac<=7 )?true:false )
-
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h b/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h
deleted file mode 100644
index a07b2344a6f8..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_TS.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef _TSTYPE_H_
-#define _TSTYPE_H_
-#include "rtl819x_Qos.h"
-#define TS_SETUP_TIMEOUT 60 // In millisecond
-#define TS_INACT_TIMEOUT 60
-#define TS_ADDBA_DELAY 60
-
-#define TOTAL_TS_NUM 16
-#define TCLAS_NUM 4
-
-// This define the Tx/Rx directions
-typedef enum _TR_SELECT {
- TX_DIR = 0,
- RX_DIR = 1,
-} TR_SELECT, *PTR_SELECT;
-
-typedef struct _TS_COMMON_INFO{
- struct list_head List;
- struct timer_list SetupTimer;
- struct timer_list InactTimer;
- u8 Addr[6];
- TSPEC_BODY TSpec;
- QOS_TCLAS TClass[TCLAS_NUM];
- u8 TClasProc;
- u8 TClasNum;
-} TS_COMMON_INFO, *PTS_COMMON_INFO;
-
-typedef struct _TX_TS_RECORD{
- TS_COMMON_INFO TsCommonInfo;
- u16 TxCurSeq;
- BA_RECORD TxPendingBARecord; // For BA Originator
- BA_RECORD TxAdmittedBARecord; // For BA Originator
- u8 bAddBaReqInProgress;
- u8 bAddBaReqDelayed;
- u8 bUsingBa;
- u8 bDisable_AddBa;
- struct timer_list TsAddBaTimer;
- u8 num;
-} TX_TS_RECORD, *PTX_TS_RECORD;
-
-typedef struct _RX_TS_RECORD {
- TS_COMMON_INFO TsCommonInfo;
- u16 RxIndicateSeq;
- u16 RxTimeoutIndicateSeq;
- struct list_head RxPendingPktList;
- struct timer_list RxPktPendingTimer;
- BA_RECORD RxAdmittedBARecord; // For BA Recepient
- u16 RxLastSeqNum;
- u8 RxLastFragNum;
- u8 num;
-} RX_TS_RECORD, *PRX_TS_RECORD;
-
-#endif
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
deleted file mode 100644
index 7ffc06ca89a8..000000000000
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
+++ /dev/null
@@ -1,631 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "ieee80211.h"
-#include <linux/etherdevice.h>
-#include <linux/slab.h>
-#include "rtl819x_TS.h"
-
-void TsSetupTimeOut(unsigned long data)
-{
- // Not implement yet
- // This is used for WMMSA and ACM , that would send ADDTSReq frame.
-}
-
-void TsInactTimeout(unsigned long data)
-{
- // Not implement yet
- // This is used for WMMSA and ACM.
- // This function would be call when TS is no Tx/Rx for some period of time.
-}
-
-/********************************************************************************************************************
- *function: I still not understand this function, so wait for further implementation
- * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
- * return: NULL
- * notice:
-********************************************************************************************************************/
-void RxPktPendingTimeout(unsigned long data)
-{
- PRX_TS_RECORD pRxTs = (PRX_TS_RECORD)data;
- struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
-
- PRX_REORDER_ENTRY pReorderEntry = NULL;
-
- unsigned long flags = 0;
- struct ieee80211_rxb *stats_IndicateArray[REORDER_WIN_SIZE];
- u8 index = 0;
- bool bPktInBuf = false;
-
-
- spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"==================>%s()\n",__FUNCTION__);
- if(pRxTs->RxTimeoutIndicateSeq != 0xffff)
- {
- // Indicate the pending packets sequentially according to SeqNum until meet the gap.
- while(!list_empty(&pRxTs->RxPendingPktList))
- {
- pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTs->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
- if(index == 0)
- pRxTs->RxIndicateSeq = pReorderEntry->SeqNum;
-
- if( SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ||
- SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) )
- {
- list_del_init(&pReorderEntry->List);
-
- if(SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq))
- pRxTs->RxIndicateSeq = (pRxTs->RxIndicateSeq + 1) % 4096;
-
- IEEE80211_DEBUG(IEEE80211_DL_REORDER,"RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum);
- stats_IndicateArray[index] = pReorderEntry->prxb;
- index++;
-
- list_add_tail(&pReorderEntry->List, &ieee->RxReorder_Unused_List);
- }
- else
- {
- bPktInBuf = true;
- break;
- }
- }
- }
-
- if(index>0)
- {
- pRxTs->RxTimeoutIndicateSeq = 0xffff;
-
- // Indicate packets
- if(index > REORDER_WIN_SIZE){
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
- spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
- return;
- }
- ieee80211_indicate_packets(ieee, stats_IndicateArray, index);
- bPktInBuf = false;
- }
-
- if(bPktInBuf && (pRxTs->RxTimeoutIndicateSeq==0xffff))
- {
- pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
- mod_timer(&pRxTs->RxPktPendingTimer, jiffies + MSECS(ieee->pHTInfo->RxReorderPendingTime));
- }
- spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
- //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
-}
-
-/********************************************************************************************************************
- *function: Add BA timer function
- * input: unsigned long data //acturally we send TX_TS_RECORD or RX_TS_RECORD to these timer
- * return: NULL
- * notice:
-********************************************************************************************************************/
-void TsAddBaProcess(unsigned long data)
-{
- PTX_TS_RECORD pTxTs = (PTX_TS_RECORD)data;
- u8 num = pTxTs->num;
- struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]);
-
- TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
- IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n");
-}
-
-
-void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo)
-{
- memset(pTsCommonInfo->Addr, 0, 6);
- memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY));
- memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM);
- pTsCommonInfo->TClasProc = 0;
- pTsCommonInfo->TClasNum = 0;
-}
-
-void ResetTxTsEntry(PTX_TS_RECORD pTS)
-{
- ResetTsCommonInfo(&pTS->TsCommonInfo);
- pTS->TxCurSeq = 0;
- pTS->bAddBaReqInProgress = false;
- pTS->bAddBaReqDelayed = false;
- pTS->bUsingBa = false;
- pTS->bDisable_AddBa = false;
- ResetBaEntry(&pTS->TxAdmittedBARecord); //For BA Originator
- ResetBaEntry(&pTS->TxPendingBARecord);
-}
-
-void ResetRxTsEntry(PRX_TS_RECORD pTS)
-{
- ResetTsCommonInfo(&pTS->TsCommonInfo);
- pTS->RxIndicateSeq = 0xffff; // This indicate the RxIndicateSeq is not used now!!
- pTS->RxTimeoutIndicateSeq = 0xffff; // This indicate the RxTimeoutIndicateSeq is not used now!!
- ResetBaEntry(&pTS->RxAdmittedBARecord); // For BA Recepient
-}
-
-void TSInitialize(struct ieee80211_device *ieee)
-{
- PTX_TS_RECORD pTxTS = ieee->TxTsRecord;
- PRX_TS_RECORD pRxTS = ieee->RxTsRecord;
- PRX_REORDER_ENTRY pRxReorderEntry = ieee->RxReorderEntry;
- u8 count = 0;
- IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __FUNCTION__);
- // Initialize Tx TS related info.
- INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
- INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
- INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
-
- for(count = 0; count < TOTAL_TS_NUM; count++)
- {
- //
- pTxTS->num = count;
- // The timers for the operation of Traffic Stream and Block Ack.
- // DLS related timer will be add here in the future!!
- init_timer(&pTxTS->TsCommonInfo.SetupTimer);
- pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS;
- pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
- init_timer(&pTxTS->TsCommonInfo.InactTimer);
- pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS;
- pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
- init_timer(&pTxTS->TsAddBaTimer);
- pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS;
- pTxTS->TsAddBaTimer.function = TsAddBaProcess;
-
- init_timer(&pTxTS->TxPendingBARecord.Timer);
- pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS;
- pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut;
-
- init_timer(&pTxTS->TxAdmittedBARecord.Timer);
- pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS;
- pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout;
-
- ResetTxTsEntry(pTxTS);
- list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List);
- pTxTS++;
- }
-
- // Initialize Rx TS related info.
- INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List);
- INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List);
- INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
- for(count = 0; count < TOTAL_TS_NUM; count++)
- {
- pRxTS->num = count;
- INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
-
- init_timer(&pRxTS->TsCommonInfo.SetupTimer);
- pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS;
- pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
- init_timer(&pRxTS->TsCommonInfo.InactTimer);
- pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS;
- pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
- init_timer(&pRxTS->RxAdmittedBARecord.Timer);
- pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS;
- pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout;
-
- init_timer(&pRxTS->RxPktPendingTimer);
- pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS;
- pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout;
-
- ResetRxTsEntry(pRxTS);
- list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
- pRxTS++;
- }
- // Initialize unused Rx Reorder List.
- INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
- for(count = 0; count < REORDER_ENTRY_NUM; count++)
- {
- list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
- if(count == (REORDER_ENTRY_NUM-1))
- break;
- pRxReorderEntry = &ieee->RxReorderEntry[count+1];
- }
-
-}
-
-void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 InactTime)
-{
- del_timer_sync(&pTsCommonInfo->SetupTimer);
- del_timer_sync(&pTsCommonInfo->InactTimer);
-
- if(InactTime!=0)
- mod_timer(&pTsCommonInfo->InactTimer, jiffies + MSECS(InactTime));
-}
-
-
-PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect)
-{
- u8 dir;
- bool search_dir[4] = {0, 0, 0, 0};
- struct list_head* psearch_list; //FIXME
- PTS_COMMON_INFO pRet = NULL;
- if(ieee->iw_mode == IW_MODE_MASTER) //ap mode
- {
- if(TxRxSelect == TX_DIR)
- {
- search_dir[DIR_DOWN] = true;
- search_dir[DIR_BI_DIR]= true;
- }
- else
- {
- search_dir[DIR_UP] = true;
- search_dir[DIR_BI_DIR]= true;
- }
- }
- else if(ieee->iw_mode == IW_MODE_ADHOC)
- {
- if(TxRxSelect == TX_DIR)
- search_dir[DIR_UP] = true;
- else
- search_dir[DIR_DOWN] = true;
- }
- else
- {
- if(TxRxSelect == TX_DIR)
- {
- search_dir[DIR_UP] = true;
- search_dir[DIR_BI_DIR]= true;
- search_dir[DIR_DIRECT]= true;
- }
- else
- {
- search_dir[DIR_DOWN] = true;
- search_dir[DIR_BI_DIR]= true;
- search_dir[DIR_DIRECT]= true;
- }
- }
-
- if(TxRxSelect == TX_DIR)
- psearch_list = &ieee->Tx_TS_Admit_List;
- else
- psearch_list = &ieee->Rx_TS_Admit_List;
-
- for(dir = 0; dir <= DIR_BI_DIR; dir++)
- {
- if(search_dir[dir] ==false )
- continue;
- list_for_each_entry(pRet, psearch_list, List){
- if (memcmp(pRet->Addr, Addr, 6) == 0)
- if (pRet->TSpec.f.TSInfo.field.ucTSID == TID)
- if(pRet->TSpec.f.TSInfo.field.ucDirection == dir)
- {
- break;
- }
-
- }
- if(&pRet->List != psearch_list)
- break;
- }
-
- if(&pRet->List != psearch_list){
- return pRet ;
- }
- else
- return NULL;
-}
-
-void MakeTSEntry(
- PTS_COMMON_INFO pTsCommonInfo,
- u8* Addr,
- PTSPEC_BODY pTSPEC,
- PQOS_TCLAS pTCLAS,
- u8 TCLAS_Num,
- u8 TCLAS_Proc
- )
-{
- u8 count;
-
- if(pTsCommonInfo == NULL)
- return;
-
- memcpy(pTsCommonInfo->Addr, Addr, 6);
-
- if(pTSPEC != NULL)
- memcpy((u8*)(&(pTsCommonInfo->TSpec)), (u8*)pTSPEC, sizeof(TSPEC_BODY));
-
- for(count = 0; count < TCLAS_Num; count++)
- memcpy((u8*)(&(pTsCommonInfo->TClass[count])), (u8*)pTCLAS, sizeof(QOS_TCLAS));
-
- pTsCommonInfo->TClasProc = TCLAS_Proc;
- pTsCommonInfo->TClasNum = TCLAS_Num;
-}
-
-
-bool GetTs(
- struct ieee80211_device* ieee,
- PTS_COMMON_INFO *ppTS,
- u8* Addr,
- u8 TID,
- TR_SELECT TxRxSelect, //Rx:1, Tx:0
- bool bAddNewTs
- )
-{
- u8 UP = 0;
- //
- // We do not build any TS for Broadcast or Multicast stream.
- // So reject these kinds of search here.
- //
- if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr))
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "ERR! get TS for Broadcast or Multicast\n");
- return false;
- }
- if (ieee->current_network.qos_data.supported == 0)
- UP = 0;
- else
- {
- // In WMM case: we use 4 TID only
- if (!IsACValid(TID))
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "ERR! in %s(), TID(%d) is not valid\n", __FUNCTION__, TID);
- return false;
- }
-
- switch(TID)
- {
- case 0:
- case 3:
- UP = 0;
- break;
-
- case 1:
- case 2:
- UP = 2;
- break;
-
- case 4:
- case 5:
- UP = 5;
- break;
-
- case 6:
- case 7:
- UP = 7;
- break;
- }
- }
-
- *ppTS = SearchAdmitTRStream(
- ieee,
- Addr,
- UP,
- TxRxSelect);
- if(*ppTS != NULL)
- {
- return true;
- }
- else
- {
- if(bAddNewTs == false)
- {
- IEEE80211_DEBUG(IEEE80211_DL_TS, "add new TS failed(tid:%d)\n", UP);
- return false;
- }
- else
- {
- //
- // Create a new Traffic stream for current Tx/Rx
- // This is for EDCA and WMM to add a new TS.
- // For HCCA or WMMSA, TS cannot be addmit without negotiation.
- //
- TSPEC_BODY TSpec;
- PQOS_TSINFO pTSInfo = &TSpec.f.TSInfo;
- struct list_head* pUnusedList =
- (TxRxSelect == TX_DIR)?
- (&ieee->Tx_TS_Unused_List):
- (&ieee->Rx_TS_Unused_List);
-
- struct list_head* pAddmitList =
- (TxRxSelect == TX_DIR)?
- (&ieee->Tx_TS_Admit_List):
- (&ieee->Rx_TS_Admit_List);
-
- DIRECTION_VALUE Dir = (ieee->iw_mode == IW_MODE_MASTER)?
- ((TxRxSelect==TX_DIR)?DIR_DOWN:DIR_UP):
- ((TxRxSelect==TX_DIR)?DIR_UP:DIR_DOWN);
- IEEE80211_DEBUG(IEEE80211_DL_TS, "to add Ts\n");
- if(!list_empty(pUnusedList))
- {
- (*ppTS) = list_entry(pUnusedList->next, TS_COMMON_INFO, List);
- list_del_init(&(*ppTS)->List);
- if(TxRxSelect==TX_DIR)
- {
- PTX_TS_RECORD tmp = container_of(*ppTS, TX_TS_RECORD, TsCommonInfo);
- ResetTxTsEntry(tmp);
- }
- else{
- PRX_TS_RECORD tmp = container_of(*ppTS, RX_TS_RECORD, TsCommonInfo);
- ResetRxTsEntry(tmp);
- }
-
- IEEE80211_DEBUG(IEEE80211_DL_TS, "to init current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr);
- // Prepare TS Info releated field
- pTSInfo->field.ucTrafficType = 0; // Traffic type: WMM is reserved in this field
- pTSInfo->field.ucTSID = UP; // TSID
- pTSInfo->field.ucDirection = Dir; // Direction: if there is DirectLink, this need additional consideration.
- pTSInfo->field.ucAccessPolicy = 1; // Access policy
- pTSInfo->field.ucAggregation = 0; // Aggregation
- pTSInfo->field.ucPSB = 0; // Aggregation
- pTSInfo->field.ucUP = UP; // User priority
- pTSInfo->field.ucTSInfoAckPolicy = 0; // Ack policy
- pTSInfo->field.ucSchedule = 0; // Schedule
-
- MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
- AdmitTS(ieee, *ppTS, 0);
- list_add_tail(&((*ppTS)->List), pAddmitList);
- // if there is DirectLink, we need to do additional operation here!!
-
- return true;
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "in function %s() There is not enough TS record to be used!!", __FUNCTION__);
- return false;
- }
- }
- }
-}
-
-void RemoveTsEntry(
- struct ieee80211_device* ieee,
- PTS_COMMON_INFO pTs,
- TR_SELECT TxRxSelect
- )
-{
- unsigned long flags = 0;
- del_timer_sync(&pTs->SetupTimer);
- del_timer_sync(&pTs->InactTimer);
- TsInitDelBA(ieee, pTs, TxRxSelect);
-
- if(TxRxSelect == RX_DIR)
- {
- PRX_REORDER_ENTRY pRxReorderEntry;
- PRX_TS_RECORD pRxTS = (PRX_TS_RECORD)pTs;
- if(timer_pending(&pRxTS->RxPktPendingTimer))
- del_timer_sync(&pRxTS->RxPktPendingTimer);
-
- while(!list_empty(&pRxTS->RxPendingPktList))
- {
- spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
- pRxReorderEntry = (PRX_REORDER_ENTRY)list_entry(pRxTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
- list_del_init(&pRxReorderEntry->List);
- {
- int i = 0;
- struct ieee80211_rxb * prxb = pRxReorderEntry->prxb;
- if (unlikely(!prxb))
- {
- spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
- return;
- }
- for(i =0; i < prxb->nr_subframes; i++) {
- dev_kfree_skb(prxb->subframes[i]);
- }
- kfree(prxb);
- prxb = NULL;
- }
- list_add_tail(&pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
- spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
- }
- }
- else
- {
- PTX_TS_RECORD pTxTS = (PTX_TS_RECORD)pTs;
- del_timer_sync(&pTxTS->TsAddBaTimer);
- }
-}
-
-void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr)
-{
- PTS_COMMON_INFO pTS, pTmpTS;
-
- printk("===========>RemovePeerTS,%pM\n", Addr);
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
- {
- if (memcmp(pTS->Addr, Addr, 6) == 0)
- {
- RemoveTsEntry(ieee, pTS, TX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
- }
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
- {
- if (memcmp(pTS->Addr, Addr, 6) == 0)
- {
- printk("====>remove Tx_TS_admin_list\n");
- RemoveTsEntry(ieee, pTS, TX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
- }
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
- {
- if (memcmp(pTS->Addr, Addr, 6) == 0)
- {
- RemoveTsEntry(ieee, pTS, RX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
- }
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
- {
- if (memcmp(pTS->Addr, Addr, 6) == 0)
- {
- RemoveTsEntry(ieee, pTS, RX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
- }
- }
-}
-
-void RemoveAllTS(struct ieee80211_device* ieee)
-{
- PTS_COMMON_INFO pTS, pTmpTS;
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List)
- {
- RemoveTsEntry(ieee, pTS, TX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List)
- {
- RemoveTsEntry(ieee, pTS, TX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Pending_List, List)
- {
- RemoveTsEntry(ieee, pTS, RX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
- }
-
- list_for_each_entry_safe(pTS, pTmpTS, &ieee->Rx_TS_Admit_List, List)
- {
- RemoveTsEntry(ieee, pTS, RX_DIR);
- list_del_init(&pTS->List);
- list_add_tail(&pTS->List, &ieee->Rx_TS_Unused_List);
- }
-}
-
-void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS)
-{
- if(pTxTS->bAddBaReqInProgress == false)
- {
- pTxTS->bAddBaReqInProgress = true;
- if(pTxTS->bAddBaReqDelayed)
- {
- IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
- mod_timer(&pTxTS->TsAddBaTimer, jiffies + MSECS(TS_ADDBA_DELAY));
- }
- else
- {
- IEEE80211_DEBUG(IEEE80211_DL_BA,"TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
- mod_timer(&pTxTS->TsAddBaTimer, jiffies+10); //set 10 ticks
- }
- }
- else
- IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s()==>BA timer is already added\n", __FUNCTION__);
-}
diff --git a/drivers/staging/rtl8192su/r8192SU_HWImg.c b/drivers/staging/rtl8192su/r8192SU_HWImg.c
deleted file mode 100644
index 7c4fd18d89c6..000000000000
--- a/drivers/staging/rtl8192su/r8192SU_HWImg.c
+++ /dev/null
@@ -1,647 +0,0 @@
-/*Created on 2009/ 1/15, 3:10*/
-
-#include "r8192SU_HWImg.h"
-
-u8 Rtl8192SUFwMainArray[MainArrayLength] = {
-0x0, };
-
-u8 Rtl8192SUFwDataArray[DataArrayLength] = {
-0x0, };
-
-u32 Rtl8192SUPHY_REG_2T2RArray[PHY_REG_2T2RArrayLength] = {
-0x01c,0x07000000,
-0x800,0x00040000,
-0x804,0x00008003,
-0x808,0x0000fc00,
-0x80c,0x0000000a,
-0x810,0x10005088,
-0x814,0x020c3d10,
-0x818,0x00200185,
-0x81c,0x00000000,
-0x820,0x01000000,
-0x824,0x00390004,
-0x828,0x01000000,
-0x82c,0x00390004,
-0x830,0x00000004,
-0x834,0x00690200,
-0x838,0x00000004,
-0x83c,0x00690200,
-0x840,0x00010000,
-0x844,0x00010000,
-0x848,0x00000000,
-0x84c,0x00000000,
-0x850,0x00000000,
-0x854,0x00000000,
-0x858,0x48484848,
-0x85c,0x65a965a9,
-0x860,0x0f7f0130,
-0x864,0x0f7f0130,
-0x868,0x0f7f0130,
-0x86c,0x0f7f0130,
-0x870,0x03000700,
-0x874,0x03000300,
-0x878,0x00020002,
-0x87c,0x004f0201,
-0x880,0xa8300ac1,
-0x884,0x00000058,
-0x888,0x00000008,
-0x88c,0x00000004,
-0x890,0x00000000,
-0x894,0xfffffffe,
-0x898,0x40302010,
-0x89c,0x00706050,
-0x8b0,0x00000000,
-0x8e0,0x00000000,
-0x8e4,0x00000000,
-0xe00,0x30333333,
-0xe04,0x2a2d2e2f,
-0xe08,0x00003232,
-0xe10,0x30333333,
-0xe14,0x2a2d2e2f,
-0xe18,0x30333333,
-0xe1c,0x2a2d2e2f,
-0xe30,0x01007c00,
-0xe34,0x01004800,
-0xe38,0x1000dc1f,
-0xe3c,0x10008c1f,
-0xe40,0x021400a0,
-0xe44,0x281600a0,
-0xe48,0xf8000001,
-0xe4c,0x00002910,
-0xe50,0x01007c00,
-0xe54,0x01004800,
-0xe58,0x1000dc1f,
-0xe5c,0x10008c1f,
-0xe60,0x021400a0,
-0xe64,0x281600a0,
-0xe6c,0x00002910,
-0xe70,0x31ed92fb,
-0xe74,0x361536fb,
-0xe78,0x361536fb,
-0xe7c,0x361536fb,
-0xe80,0x361536fb,
-0xe84,0x000d92fb,
-0xe88,0x000d92fb,
-0xe8c,0x31ed92fb,
-0xed0,0x31ed92fb,
-0xed4,0x31ed92fb,
-0xed8,0x000d92fb,
-0xedc,0x000d92fb,
-0xee0,0x000d92fb,
-0xee4,0x015e5448,
-0xee8,0x21555448,
-0x900,0x00000000,
-0x904,0x00000023,
-0x908,0x00000000,
-0x90c,0x01121313,
-0xa00,0x00d047c8,
-0xa04,0x80ff0008,
-0xa08,0x8ccd8300,
-0xa0c,0x2e62120f,
-0xa10,0x9500bb78,
-0xa14,0x11144028,
-0xa18,0x00881117,
-0xa1c,0x89140f00,
-0xa20,0x1a1b0000,
-0xa24,0x090e1317,
-0xa28,0x00000204,
-0xa2c,0x10d30000,
-0xc00,0x40071d40,
-0xc04,0x00a05633,
-0xc08,0x000000e4,
-0xc0c,0x6c6c6c6c,
-0xc10,0x08800000,
-0xc14,0x40000100,
-0xc18,0x08000000,
-0xc1c,0x40000100,
-0xc20,0x08000000,
-0xc24,0x40000100,
-0xc28,0x08000000,
-0xc2c,0x40000100,
-0xc30,0x6de9ac44,
-0xc34,0x469652cf,
-0xc38,0x49795994,
-0xc3c,0x0a979764,
-0xc40,0x1f7c403f,
-0xc44,0x000100b7,
-0xc48,0xec020000,
-0xc4c,0x007f037f,
-0xc50,0x69543420,
-0xc54,0x433c0094,
-0xc58,0x69543420,
-0xc5c,0x433c0094,
-0xc60,0x69543420,
-0xc64,0x433c0094,
-0xc68,0x69543420,
-0xc6c,0x433c0094,
-0xc70,0x2c7f000d,
-0xc74,0x0186175b,
-0xc78,0x0000001f,
-0xc7c,0x00b91612,
-0xc80,0x40000100,
-0xc84,0x20f60000,
-0xc88,0x20000080,
-0xc8c,0x20200000,
-0xc90,0x40000100,
-0xc94,0x00000000,
-0xc98,0x40000100,
-0xc9c,0x00000000,
-0xca0,0x00492492,
-0xca4,0x00000000,
-0xca8,0x00000000,
-0xcac,0x00000000,
-0xcb0,0x00000000,
-0xcb4,0x00000000,
-0xcb8,0x00000000,
-0xcbc,0x28000000,
-0xcc0,0x00000000,
-0xcc4,0x00000000,
-0xcc8,0x00000000,
-0xccc,0x00000000,
-0xcd0,0x00000000,
-0xcd4,0x00000000,
-0xcd8,0x64b22427,
-0xcdc,0x00766932,
-0xce0,0x00222222,
-0xce4,0x00000000,
-0xce8,0x37644302,
-0xcec,0x2f97d40c,
-0xd00,0x00000750,
-0xd04,0x00000403,
-0xd08,0x0000907f,
-0xd0c,0x00000001,
-0xd10,0xa0633333,
-0xd14,0x33333c63,
-0xd18,0x6a8f5b6b,
-0xd1c,0x00000000,
-0xd20,0x00000000,
-0xd24,0x00000000,
-0xd28,0x00000000,
-0xd2c,0xcc979975,
-0xd30,0x00000000,
-0xd34,0x00000000,
-0xd38,0x00000000,
-0xd3c,0x00027293,
-0xd40,0x00000000,
-0xd44,0x00000000,
-0xd48,0x00000000,
-0xd50,0x6437140a,
-0xd54,0x024dbd02,
-0xd58,0x00000000,
-0xd5c,0x30032064,
-0xd60,0x4653de68,
-0xd64,0x00518a3c,
-0xd68,0x00002101,
-0xf14,0x00000003,
-0xf4c,0x00000000,
-0xf00,0x00000300,
-};
-
-u32 Rtl8192SUPHY_REG_1T2RArray[PHY_REG_1T2RArrayLength] = {
-0x0, };
-
-u32 Rtl8192SUPHY_ChangeTo_1T1RArray[PHY_ChangeTo_1T1RArrayLength] = {
-0x844,0xffffffff,0x00010000,
-0x804,0x0000000f,0x00000001,
-0x824,0x00f0000f,0x00300004,
-0x82c,0x00f0000f,0x00100002,
-0x870,0x04000000,0x00000001,
-0x864,0x00000400,0x00000000,
-0x878,0x000f000f,0x00000002,
-0xe74,0x0f000000,0x00000002,
-0xe78,0x0f000000,0x00000002,
-0xe7c,0x0f000000,0x00000002,
-0xe80,0x0f000000,0x00000002,
-0x90c,0x000000ff,0x00000011,
-0xc04,0x000000ff,0x00000011,
-0xd04,0x0000000f,0x00000001,
-0x1f4,0xffff0000,0x00007777,
-0x234,0xf8000000,0x0000000a,
-};
-
-u32 Rtl8192SUPHY_ChangeTo_1T2RArray[PHY_ChangeTo_1T2RArrayLength] = {
-0x804,0x0000000f,0x00000003,
-0x824,0x00f0000f,0x00300004,
-0x82c,0x00f0000f,0x00300002,
-0x870,0x04000000,0x00000001,
-0x864,0x00000400,0x00000000,
-0x878,0x000f000f,0x00000002,
-0xe74,0x0f000000,0x00000002,
-0xe78,0x0f000000,0x00000002,
-0xe7c,0x0f000000,0x00000002,
-0xe80,0x0f000000,0x00000002,
-0x90c,0x000000ff,0x00000011,
-0xc04,0x000000ff,0x00000033,
-0xd04,0x0000000f,0x00000003,
-0x1f4,0xffff0000,0x00007777,
-0x234,0xf8000000,0x0000000a,
-};
-
-u32 Rtl8192SUPHY_ChangeTo_2T2RArray[PHY_ChangeTo_2T2RArrayLength] = {
-0x804,0x0000000f,0x00000003,
-0x824,0x00f0000f,0x00300004,
-0x82c,0x00f0000f,0x00300004,
-0x870,0x04000000,0x00000001,
-0x864,0x00000400,0x00000001,
-0x878,0x000f000f,0x00020002,
-0xe74,0x0f000000,0x00000006,
-0xe78,0x0f000000,0x00000006,
-0xe7c,0x0f000000,0x00000006,
-0xe80,0x0f000000,0x00000006,
-0x90c,0x000000ff,0x00000033,
-0xc04,0x000000ff,0x00000033,
-0xd04,0x0000000f,0x00000003,
-0x1f4,0xffff0000,0x0000ffff,
-0x234,0xf8000000,0x00000013,
-};
-
-u32 Rtl8192SUPHY_REG_Array_PG[PHY_REG_Array_PGLength] = {
-0xe00,0xffffffff,0x04060606,
-0xe04,0xffffffff,0x00020204,
-0xe08,0x0000ff00,0x00000000,
-0xe10,0xffffffff,0x0408080a,
-0xe14,0xffffffff,0x00020204,
-0xe18,0xffffffff,0x0408080a,
-0xe1c,0xffffffff,0x00020204,
-0xe00,0xffffffff,0x00000000,
-0xe04,0xffffffff,0x00000000,
-0xe08,0x0000ff00,0x00000000,
-0xe10,0xffffffff,0x00000000,
-0xe14,0xffffffff,0x00000000,
-0xe18,0xffffffff,0x00000000,
-0xe1c,0xffffffff,0x00000000,
-0xe00,0xffffffff,0x00000000,
-0xe04,0xffffffff,0x00000000,
-0xe08,0x0000ff00,0x00000000,
-0xe10,0xffffffff,0x00000000,
-0xe14,0xffffffff,0x00000000,
-0xe18,0xffffffff,0x00000000,
-0xe1c,0xffffffff,0x00000000,
-0xe00,0xffffffff,0x00000000,
-0xe04,0xffffffff,0x00000000,
-0xe08,0x0000ff00,0x00000000,
-0xe10,0xffffffff,0x00000000,
-0xe14,0xffffffff,0x00000000,
-0xe18,0xffffffff,0x00000000,
-0xe1c,0xffffffff,0x00000000,
-};
-
-u32 Rtl8192SURadioA_1T_Array[RadioA_1T_ArrayLength] = {
-0x000,0x00030159,
-0x001,0x00030250,
-0x002,0x00010000,
-0x010,0x0008000f,
-0x011,0x000231fc,
-0x010,0x000c000f,
-0x011,0x0003f9f8,
-0x010,0x0002000f,
-0x011,0x00020101,
-0x014,0x0001093e,
-0x014,0x0009093e,
-0x015,0x000198f4,
-0x017,0x000f6500,
-0x01a,0x00013056,
-0x01b,0x00060000,
-0x01c,0x00000300,
-0x01e,0x00031059,
-0x021,0x00054000,
-0x022,0x0000083c,
-0x023,0x00001558,
-0x024,0x00000060,
-0x025,0x00022583,
-0x026,0x0000f200,
-0x027,0x000eacf1,
-0x028,0x0009bd54,
-0x029,0x00004582,
-0x02a,0x00000001,
-0x02b,0x00021334,
-0x02a,0x00000000,
-0x02b,0x0000000a,
-0x02a,0x00000001,
-0x02b,0x00000808,
-0x02b,0x00053333,
-0x02c,0x0000000c,
-0x02a,0x00000002,
-0x02b,0x00000808,
-0x02b,0x0005b333,
-0x02c,0x0000000d,
-0x02a,0x00000003,
-0x02b,0x00000808,
-0x02b,0x00063333,
-0x02c,0x0000000d,
-0x02a,0x00000004,
-0x02b,0x00000808,
-0x02b,0x0006b333,
-0x02c,0x0000000d,
-0x02a,0x00000005,
-0x02b,0x00000709,
-0x02b,0x00053333,
-0x02c,0x0000000d,
-0x02a,0x00000006,
-0x02b,0x00000709,
-0x02b,0x0005b333,
-0x02c,0x0000000d,
-0x02a,0x00000007,
-0x02b,0x00000709,
-0x02b,0x00063333,
-0x02c,0x0000000d,
-0x02a,0x00000008,
-0x02b,0x00000709,
-0x02b,0x0006b333,
-0x02c,0x0000000d,
-0x02a,0x00000009,
-0x02b,0x0000060a,
-0x02b,0x00053333,
-0x02c,0x0000000d,
-0x02a,0x0000000a,
-0x02b,0x0000060a,
-0x02b,0x0005b333,
-0x02c,0x0000000d,
-0x02a,0x0000000b,
-0x02b,0x0000060a,
-0x02b,0x00063333,
-0x02c,0x0000000d,
-0x02a,0x0000000c,
-0x02b,0x0000060a,
-0x02b,0x0006b333,
-0x02c,0x0000000d,
-0x02a,0x0000000d,
-0x02b,0x0000050b,
-0x02b,0x00053333,
-0x02c,0x0000000d,
-0x02a,0x0000000e,
-0x02b,0x0000050b,
-0x02b,0x00066623,
-0x02c,0x0000001a,
-0x02a,0x000e4000,
-0x030,0x00020000,
-0x031,0x000b9631,
-0x032,0x0000130d,
-0x033,0x00000187,
-0x013,0x00019e6c,
-0x013,0x00015e94,
-0x000,0x00010159,
-0x018,0x0000f401,
-0x0fe,0x00000000,
-0x01e,0x0003105b,
-0x0fe,0x00000000,
-0x000,0x00030159,
-0x010,0x0004000f,
-0x011,0x000203f9,
-};
-
-u32 Rtl8192SURadioB_Array[RadioB_ArrayLength] = {
-0x000,0x00030159,
-0x001,0x00001041,
-0x002,0x00011000,
-0x005,0x00080fc0,
-0x007,0x000fc803,
-0x013,0x00017cb0,
-0x013,0x00011cc0,
-0x013,0x0000dc60,
-0x013,0x00008c60,
-0x013,0x00004450,
-0x013,0x00000020,
-};
-
-u32 Rtl8192SURadioA_to1T_Array[RadioA_to1T_ArrayLength] = {
-0x000,0x00000000,
-};
-
-u32 Rtl8192SURadioA_to2T_Array[RadioA_to2T_ArrayLength] = {
-0x000,0x00000000,
-};
-
-u32 Rtl8192SURadioB_GM_Array[RadioB_GM_ArrayLength] = {
-0x000,0x00030159,
-0x001,0x00001041,
-0x002,0x00011000,
-0x005,0x00080fc0,
-0x007,0x000fc803,
-0x013,0x0000bef0,
-0x013,0x00007e90,
-0x013,0x00003e30,
-};
-
-u32 Rtl8192SUMAC_2T_Array[MAC_2T_ArrayLength] = {
-0x020,0x00000035,
-0x048,0x0000000e,
-0x049,0x000000f0,
-0x04a,0x00000077,
-0x04b,0x00000083,
-0x0b5,0x00000021,
-0x0dc,0x000000ff,
-0x0dd,0x000000ff,
-0x0de,0x000000ff,
-0x0df,0x000000ff,
-0x116,0x00000000,
-0x117,0x00000000,
-0x118,0x00000000,
-0x119,0x00000000,
-0x11a,0x00000000,
-0x11b,0x00000000,
-0x11c,0x00000000,
-0x11d,0x00000000,
-0x160,0x0000000b,
-0x161,0x0000000b,
-0x162,0x0000000b,
-0x163,0x0000000b,
-0x164,0x0000000b,
-0x165,0x0000000b,
-0x166,0x0000000b,
-0x167,0x0000000b,
-0x168,0x0000000b,
-0x169,0x0000000b,
-0x16a,0x0000000b,
-0x16b,0x0000000b,
-0x16c,0x0000000b,
-0x16d,0x0000000b,
-0x16e,0x0000000b,
-0x16f,0x0000000b,
-0x170,0x0000000b,
-0x171,0x0000000b,
-0x172,0x0000000b,
-0x173,0x0000000b,
-0x174,0x0000000b,
-0x175,0x0000000b,
-0x176,0x0000000b,
-0x177,0x0000000b,
-0x178,0x0000000b,
-0x179,0x0000000b,
-0x17a,0x0000000b,
-0x17b,0x0000000b,
-0x17c,0x0000000b,
-0x17d,0x0000000b,
-0x17e,0x0000000b,
-0x17f,0x0000000b,
-0x236,0x0000000c,
-0x503,0x00000022,
-0x560,0x00000009,
-};
-
-u32 Rtl8192SUMACPHY_Array_PG[MACPHY_Array_PGLength] = {
-0x0, };
-
-u32 Rtl8192SUAGCTAB_Array[AGCTAB_ArrayLength] = {
-0xc78,0x7f000001,
-0xc78,0x7f010001,
-0xc78,0x7e020001,
-0xc78,0x7d030001,
-0xc78,0x7c040001,
-0xc78,0x7b050001,
-0xc78,0x7a060001,
-0xc78,0x79070001,
-0xc78,0x78080001,
-0xc78,0x77090001,
-0xc78,0x760a0001,
-0xc78,0x750b0001,
-0xc78,0x740c0001,
-0xc78,0x730d0001,
-0xc78,0x720e0001,
-0xc78,0x710f0001,
-0xc78,0x70100001,
-0xc78,0x6f110001,
-0xc78,0x6f120001,
-0xc78,0x6e130001,
-0xc78,0x6d140001,
-0xc78,0x6d150001,
-0xc78,0x6c160001,
-0xc78,0x6b170001,
-0xc78,0x6a180001,
-0xc78,0x6a190001,
-0xc78,0x691a0001,
-0xc78,0x681b0001,
-0xc78,0x671c0001,
-0xc78,0x661d0001,
-0xc78,0x651e0001,
-0xc78,0x641f0001,
-0xc78,0x63200001,
-0xc78,0x4c210001,
-0xc78,0x4b220001,
-0xc78,0x4a230001,
-0xc78,0x49240001,
-0xc78,0x48250001,
-0xc78,0x47260001,
-0xc78,0x46270001,
-0xc78,0x45280001,
-0xc78,0x44290001,
-0xc78,0x2c2a0001,
-0xc78,0x2b2b0001,
-0xc78,0x2a2c0001,
-0xc78,0x292d0001,
-0xc78,0x282e0001,
-0xc78,0x272f0001,
-0xc78,0x26300001,
-0xc78,0x25310001,
-0xc78,0x24320001,
-0xc78,0x23330001,
-0xc78,0x22340001,
-0xc78,0x09350001,
-0xc78,0x08360001,
-0xc78,0x07370001,
-0xc78,0x06380001,
-0xc78,0x05390001,
-0xc78,0x043a0001,
-0xc78,0x033b0001,
-0xc78,0x023c0001,
-0xc78,0x013d0001,
-0xc78,0x003e0001,
-0xc78,0x003f0001,
-0xc78,0x7f400001,
-0xc78,0x7f410001,
-0xc78,0x7e420001,
-0xc78,0x7d430001,
-0xc78,0x7c440001,
-0xc78,0x7b450001,
-0xc78,0x7a460001,
-0xc78,0x79470001,
-0xc78,0x78480001,
-0xc78,0x77490001,
-0xc78,0x764a0001,
-0xc78,0x754b0001,
-0xc78,0x744c0001,
-0xc78,0x734d0001,
-0xc78,0x724e0001,
-0xc78,0x714f0001,
-0xc78,0x70500001,
-0xc78,0x6f510001,
-0xc78,0x6f520001,
-0xc78,0x6e530001,
-0xc78,0x6d540001,
-0xc78,0x6d550001,
-0xc78,0x6c560001,
-0xc78,0x6b570001,
-0xc78,0x6a580001,
-0xc78,0x6a590001,
-0xc78,0x695a0001,
-0xc78,0x685b0001,
-0xc78,0x675c0001,
-0xc78,0x665d0001,
-0xc78,0x655e0001,
-0xc78,0x645f0001,
-0xc78,0x63600001,
-0xc78,0x4c610001,
-0xc78,0x4b620001,
-0xc78,0x4a630001,
-0xc78,0x49640001,
-0xc78,0x48650001,
-0xc78,0x47660001,
-0xc78,0x46670001,
-0xc78,0x45680001,
-0xc78,0x44690001,
-0xc78,0x2c6a0001,
-0xc78,0x2b6b0001,
-0xc78,0x2a6c0001,
-0xc78,0x296d0001,
-0xc78,0x286e0001,
-0xc78,0x276f0001,
-0xc78,0x26700001,
-0xc78,0x25710001,
-0xc78,0x24720001,
-0xc78,0x23730001,
-0xc78,0x22740001,
-0xc78,0x09750001,
-0xc78,0x08760001,
-0xc78,0x07770001,
-0xc78,0x06780001,
-0xc78,0x05790001,
-0xc78,0x047a0001,
-0xc78,0x037b0001,
-0xc78,0x027c0001,
-0xc78,0x017d0001,
-0xc78,0x007e0001,
-0xc78,0x007f0001,
-0xc78,0x3000001e,
-0xc78,0x3001001e,
-0xc78,0x3002001e,
-0xc78,0x3003001e,
-0xc78,0x3004001e,
-0xc78,0x3405001e,
-0xc78,0x3806001e,
-0xc78,0x3e07001e,
-0xc78,0x3e08001e,
-0xc78,0x4409001e,
-0xc78,0x460a001e,
-0xc78,0x480b001e,
-0xc78,0x480c001e,
-0xc78,0x4e0d001e,
-0xc78,0x560e001e,
-0xc78,0x5a0f001e,
-0xc78,0x5e10001e,
-0xc78,0x6211001e,
-0xc78,0x6c12001e,
-0xc78,0x7213001e,
-0xc78,0x7214001e,
-0xc78,0x7215001e,
-0xc78,0x7216001e,
-0xc78,0x7217001e,
-0xc78,0x7218001e,
-0xc78,0x7219001e,
-0xc78,0x721a001e,
-0xc78,0x721b001e,
-0xc78,0x721c001e,
-0xc78,0x721d001e,
-0xc78,0x721e001e,
-0xc78,0x721f001e,
-};
-
diff --git a/drivers/staging/rtl8192su/r8192SU_HWImg.h b/drivers/staging/rtl8192su/r8192SU_HWImg.h
deleted file mode 100644
index 69a66c399606..000000000000
--- a/drivers/staging/rtl8192su/r8192SU_HWImg.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef __INC_HAL8192SU_FW_IMG_H
-#define __INC_HAL8192SU_FW_IMG_H
-
-#include <linux/types.h>
-
-/*Created on 2009/ 3/ 6, 5:29*/
-
-#define MainArrayLength 1
-extern u8 Rtl8192SUFwMainArray[MainArrayLength];
-#define DataArrayLength 1
-extern u8 Rtl8192SUFwDataArray[DataArrayLength];
-#define PHY_REG_2T2RArrayLength 372
-extern u32 Rtl8192SUPHY_REG_2T2RArray[PHY_REG_2T2RArrayLength];
-#define PHY_REG_1T2RArrayLength 1
-extern u32 Rtl8192SUPHY_REG_1T2RArray[PHY_REG_1T2RArrayLength];
-#define PHY_ChangeTo_1T1RArrayLength 48
-extern u32 Rtl8192SUPHY_ChangeTo_1T1RArray[PHY_ChangeTo_1T1RArrayLength];
-#define PHY_ChangeTo_1T2RArrayLength 45
-extern u32 Rtl8192SUPHY_ChangeTo_1T2RArray[PHY_ChangeTo_1T2RArrayLength];
-#define PHY_ChangeTo_2T2RArrayLength 45
-extern u32 Rtl8192SUPHY_ChangeTo_2T2RArray[PHY_ChangeTo_2T2RArrayLength];
-#define PHY_REG_Array_PGLength 84
-extern u32 Rtl8192SUPHY_REG_Array_PG[PHY_REG_Array_PGLength];
-#define RadioA_1T_ArrayLength 202
-extern u32 Rtl8192SURadioA_1T_Array[RadioA_1T_ArrayLength];
-#define RadioB_ArrayLength 22
-extern u32 Rtl8192SURadioB_Array[RadioB_ArrayLength];
-#define RadioA_to1T_ArrayLength 2
-extern u32 Rtl8192SURadioA_to1T_Array[RadioA_to1T_ArrayLength];
-#define RadioA_to2T_ArrayLength 2
-extern u32 Rtl8192SURadioA_to2T_Array[RadioA_to2T_ArrayLength];
-#define RadioB_GM_ArrayLength 16
-extern u32 Rtl8192SURadioB_GM_Array[RadioB_GM_ArrayLength];
-#define MAC_2T_ArrayLength 106
-extern u32 Rtl8192SUMAC_2T_Array[MAC_2T_ArrayLength];
-#define MACPHY_Array_PGLength 1
-extern u32 Rtl8192SUMACPHY_Array_PG[MACPHY_Array_PGLength];
-#define AGCTAB_ArrayLength 320
-extern u32 Rtl8192SUAGCTAB_Array[AGCTAB_ArrayLength];
-
-#endif
-
diff --git a/drivers/staging/rtl8192su/r8192SU_led.c b/drivers/staging/rtl8192su/r8192SU_led.c
deleted file mode 100644
index 5d96b356bf12..000000000000
--- a/drivers/staging/rtl8192su/r8192SU_led.c
+++ /dev/null
@@ -1,2338 +0,0 @@
-/*
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
- */
-
-#include "r8192U.h"
-#include "r8192S_hw.h"
-#include "r8192SU_led.h"
-
-#define LED_BLINK_NORMAL_INTERVAL 100
-#define LED_BLINK_SLOWLY_INTERVAL 200
-#define LED_BLINK_LONG_INTERVAL 400
-
-#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
-#define LED_BLINK_LINK_INTERVAL_ALPHA 500
-#define LED_BLINK_SCAN_INTERVAL_ALPHA 180
-#define LED_BLINK_FASTER_INTERVAL_ALPHA 50
-#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
-
-
-
-static void BlinkTimerCallback (unsigned long data);
-
-static void BlinkWorkItemCallback (struct work_struct *work);
-
-void InitLed819xUsb (struct net_device *dev, PLED_819xUsb pLed,
- LED_PIN_819xUsb LedPin)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- pLed->dev = dev;
- pLed->LedPin = LedPin;
- pLed->CurrLedState = LED_OFF;
- pLed->bLedOn = FALSE;
-
- pLed->bLedBlinkInProgress = FALSE;
- pLed->BlinkTimes = 0;
- pLed->BlinkingLedState = LED_OFF;
-
- init_timer(&pLed->BlinkTimer);
- pLed->BlinkTimer.data = (unsigned long)dev;
- pLed->BlinkTimer.function = BlinkTimerCallback;
-
- INIT_WORK(&priv->BlinkWorkItem, (void*)BlinkWorkItemCallback);
- priv->pLed = pLed;
-}
-
-
-void DeInitLed819xUsb (PLED_819xUsb pLed)
-{
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
-}
-
-void SwLedOn (struct net_device *dev, PLED_819xUsb pLed)
-{
- u8 LedCfg;
-
- LedCfg = read_nic_byte(dev, LEDCFG);
- switch (pLed->LedPin) {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- write_nic_byte(dev, LEDCFG, LedCfg&0xf0);
- break;
- case LED_PIN_LED1:
- write_nic_byte(dev, LEDCFG, LedCfg&0x0f);
- break;
- default:
- break;
- }
- pLed->bLedOn = TRUE;
-}
-
-void SwLedOff (struct net_device *dev, PLED_819xUsb pLed)
-{
- u8 LedCfg;
-
- LedCfg = read_nic_byte(dev, LEDCFG);
- switch (pLed->LedPin) {
- case LED_PIN_GPIO0:
- break;
- case LED_PIN_LED0:
- LedCfg &= 0xf0;
- write_nic_byte(dev, LEDCFG, (LedCfg|BIT3));
- break;
- case LED_PIN_LED1:
- LedCfg &= 0x0f;
- write_nic_byte(dev, LEDCFG, (LedCfg|BIT7));
- break;
- default:
- break;
- }
- pLed->bLedOn = FALSE;
-}
-
-
-void
-InitSwLeds(
- struct net_device *dev
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- InitLed819xUsb(dev, &(priv->SwLed0), LED_PIN_LED0);
-
- InitLed819xUsb(dev,&(priv->SwLed1), LED_PIN_LED1);
-}
-
-
-void
-DeInitSwLeds(
- struct net_device *dev
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- DeInitLed819xUsb( &(priv->SwLed0) );
- DeInitLed819xUsb( &(priv->SwLed1) );
-}
-
-
-void
-SwLedBlink(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bStopBlinking = FALSE;
-
- if( pLed->BlinkingLedState == LED_ON )
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
- pLed->BlinkTimes--;
- switch(pLed->CurrLedState)
- {
-
- case LED_BLINK_NORMAL:
- if(pLed->BlinkTimes == 0)
- {
- bStopBlinking = TRUE;
- }
- break;
-
- case LED_BLINK_StartToBlink:
- if( (priv->ieee80211->state == IEEE80211_LINKED) && (priv->ieee80211->iw_mode == IW_MODE_INFRA))
- {
- bStopBlinking = TRUE;
- }
- else if((priv->ieee80211->state == IEEE80211_LINKED) && (priv->ieee80211->iw_mode == IW_MODE_ADHOC))
- {
- bStopBlinking = TRUE;
- }
- else if(pLed->BlinkTimes == 0)
- {
- bStopBlinking = TRUE;
- }
- break;
-
- case LED_BLINK_WPS:
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
- break;
-
-
- default:
- bStopBlinking = TRUE;
- break;
-
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if( (priv->ieee80211->state == IEEE80211_LINKED) && (pLed->bLedOn == false))
- {
- SwLedOn(dev, pLed);
- }
- else if( (priv->ieee80211->state != IEEE80211_LINKED) && pLed->bLedOn == true)
- {
- SwLedOff(dev, pLed);
- }
-
- pLed->BlinkTimes = 0;
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( pLed->BlinkingLedState == LED_ON )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
-
- switch( pLed->CurrLedState )
- {
- case LED_BLINK_NORMAL:
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- break;
-
- case LED_BLINK_SLOWLY:
- case LED_BLINK_StartToBlink:
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- break;
-
- case LED_BLINK_WPS:
- {
- if( pLed->BlinkingLedState == LED_ON )
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LONG_INTERVAL));
- else
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LONG_INTERVAL));
- }
- break;
-
- default:
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- break;
- }
- }
-}
-
-
-void
-SwLedBlink1(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed1 = &(priv->SwLed1);
- bool bStopBlinking = FALSE;
-
- if(priv->CustomerID == RT_CID_819x_CAMEO)
- pLed = &(priv->SwLed1);
-
- if( pLed->BlinkingLedState == LED_ON )
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
-
- if(priv->CustomerID == RT_CID_DEFAULT)
- {
- if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- if(!pLed1->bSWLedCtrl)
- {
- SwLedOn(dev, pLed1);
- pLed1->bSWLedCtrl = TRUE;
- }
- else if(!pLed1->bLedOn)
- SwLedOn(dev, pLed1);
- RT_TRACE(COMP_LED, "Blinktimes (): turn on pLed1\n");
- }
- else
- {
- if(!pLed1->bSWLedCtrl)
- {
- SwLedOff(dev, pLed1);
- pLed1->bSWLedCtrl = TRUE;
- }
- else if(pLed1->bLedOn)
- SwLedOff(dev, pLed1);
- RT_TRACE(COMP_LED, "Blinktimes (): turn off pLed1\n");
- }
- }
-
- switch(pLed->CurrLedState)
- {
- case LED_BLINK_SLOWLY:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- break;
-
- case LED_BLINK_NORMAL:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- break;
-
- case LED_SCAN_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->bLedLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_NORMAL;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
-
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_TXRX_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->bLedLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_NORMAL;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->BlinkTimes = 0;
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_BLINK_WPS:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- break;
-
- case LED_BLINK_WPS_STOP:
- if(pLed->BlinkingLedState == LED_ON)
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
- bStopBlinking = FALSE;
- }
- else
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->bLedLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_NORMAL;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
- break;
-
- default:
- break;
- }
-
-}
-
-void
-SwLedBlink2(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bStopBlinking = FALSE;
-
- if( pLed->BlinkingLedState == LED_ON)
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
- switch(pLed->CurrLedState)
- {
- case LED_SCAN_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "eRFPowerState %d\n", priv->ieee80211->eRFPowerState);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "stop scan blink CurrLedState %d\n", pLed->CurrLedState);
-
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "stop scan blink CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_TXRX_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "stop CurrLedState %d\n", pLed->CurrLedState);
-
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "stop CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- }
- break;
-
- default:
- break;
- }
-
-}
-
-void
-SwLedBlink3(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bStopBlinking = FALSE;
-
- if( pLed->BlinkingLedState == LED_ON )
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- if(pLed->CurrLedState != LED_BLINK_WPS_STOP)
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
- switch(pLed->CurrLedState)
- {
- case LED_SCAN_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- if( !pLed->bLedOn )
- SwLedOn(dev, pLed);
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- if( pLed->bLedOn )
- SwLedOff(dev, pLed);
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_TXRX_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
-
- if( !pLed->bLedOn )
- SwLedOn(dev, pLed);
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- else if(priv->ieee80211->state != IEEE80211_LINKED)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
-
- if( pLed->bLedOn )
- SwLedOff(dev, pLed);
-
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_BLINK_WPS:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- break;
-
- case LED_BLINK_WPS_STOP:
- if(pLed->BlinkingLedState == LED_ON)
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
- bStopBlinking = FALSE;
- }
- else
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
- break;
-
-
- default:
- break;
- }
-
-}
-
-
-void
-SwLedBlink4(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed1 = &(priv->SwLed1);
- bool bStopBlinking = FALSE;
-
- if( pLed->BlinkingLedState == LED_ON )
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
- if(!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN)
- {
- pLed1->BlinkingLedState = LED_OFF;
- pLed1->CurrLedState = LED_OFF;
- SwLedOff(dev, pLed1);
- }
-
- switch(pLed->CurrLedState)
- {
- case LED_BLINK_SLOWLY:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- break;
-
- case LED_BLINK_StartToBlink:
- if( pLed->bLedOn )
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
- break;
-
- case LED_SCAN_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- }
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_TXRX_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- }
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- }
- break;
-
- case LED_BLINK_WPS:
- if( pLed->bLedOn )
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
- break;
-
- case LED_BLINK_WPS_STOP:
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
-
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- break;
-
- case LED_BLINK_WPS_STOP_OVERLAP:
- pLed->BlinkTimes--;
- if(pLed->BlinkTimes == 0)
- {
- if(pLed->bLedOn)
- {
- pLed->BlinkTimes = 1;
- }
- else
- {
- bStopBlinking = TRUE;
- }
- }
-
- if(bStopBlinking)
- {
- pLed->BlinkTimes = 10;
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
-
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
- break;
-
-
- default:
- break;
- }
-
- RT_TRACE(COMP_LED, "SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState);
-
-
-}
-
-void
-SwLedBlink5(
- PLED_819xUsb pLed
- )
-{
- struct net_device *dev = (struct net_device *)(pLed->dev);
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bStopBlinking = FALSE;
-
- if( pLed->BlinkingLedState == LED_ON )
- {
- SwLedOn(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn on\n", pLed->BlinkTimes);
- }
- else
- {
- SwLedOff(dev, pLed);
- RT_TRACE(COMP_LED, "Blinktimes (%d): turn off\n", pLed->BlinkTimes);
- }
-
- switch(pLed->CurrLedState)
- {
- case LED_SCAN_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- if(pLed->bLedOn)
- SwLedOff(dev, pLed);
- }
- else
- { pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- if(!pLed->bLedOn)
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
-
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
- }
- }
- break;
-
-
- case LED_TXRX_BLINK:
- pLed->BlinkTimes--;
- if( pLed->BlinkTimes == 0 )
- {
- bStopBlinking = TRUE;
- }
-
- if(bStopBlinking)
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- if(pLed->bLedOn)
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- if(!pLed->bLedOn)
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
-
- pLed->bLedBlinkInProgress = FALSE;
- }
- else
- {
- if( priv->ieee80211->eRFPowerState != eRfOn && priv->ieee80211->RfOffReason > RF_CHANGE_BY_PS)
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- }
- break;
-
- default:
- break;
- }
-
- RT_TRACE(COMP_LED, "SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState);
-
-
-}
-
-
-void
-BlinkTimerCallback(
- unsigned long data
- )
-{
- struct net_device *dev = (struct net_device *)data;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- schedule_work(&(priv->BlinkWorkItem));
-}
-
-
-void BlinkWorkItemCallback(struct work_struct *work)
-{
- struct r8192_priv *priv = container_of(work, struct r8192_priv, BlinkWorkItem);
-
- PLED_819xUsb pLed = priv->pLed;
-
- switch(priv->LedStrategy)
- {
- case SW_LED_MODE0:
- SwLedBlink(pLed);
- break;
-
- case SW_LED_MODE1:
- SwLedBlink1(pLed);
- break;
-
- case SW_LED_MODE2:
- SwLedBlink2(pLed);
- break;
-
- case SW_LED_MODE3:
- SwLedBlink3(pLed);
- break;
-
- case SW_LED_MODE4:
- SwLedBlink4(pLed);
- break;
-
- case SW_LED_MODE5:
- SwLedBlink5(pLed);
- break;
-
- default:
- SwLedBlink(pLed);
- break;
- }
-}
-
-
-
-
-void
-SwLedControlMode0(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed1);
-
- switch(LedAction)
- {
- case LED_CTL_TX:
- case LED_CTL_RX:
- if( pLed->bLedBlinkInProgress == FALSE )
- {
- pLed->bLedBlinkInProgress = TRUE;
-
- pLed->CurrLedState = LED_BLINK_NORMAL;
- pLed->BlinkTimes = 2;
-
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
- break;
-
- case LED_CTL_START_TO_LINK:
- if( pLed->bLedBlinkInProgress == FALSE )
- {
- pLed->bLedBlinkInProgress = TRUE;
-
- pLed->CurrLedState = LED_BLINK_StartToBlink;
- pLed->BlinkTimes = 24;
-
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- }
- else
- {
- pLed->CurrLedState = LED_BLINK_StartToBlink;
- }
- break;
-
- case LED_CTL_LINK:
- pLed->CurrLedState = LED_ON;
- if( pLed->bLedBlinkInProgress == FALSE )
- {
- SwLedOn(dev, pLed);
- }
- break;
-
- case LED_CTL_NO_LINK:
- pLed->CurrLedState = LED_OFF;
- if( pLed->bLedBlinkInProgress == FALSE )
- {
- SwLedOff(dev, pLed);
- }
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- if(pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- SwLedOff(dev, pLed);
- break;
-
- case LED_CTL_START_WPS:
- if( pLed->bLedBlinkInProgress == FALSE || pLed->CurrLedState == LED_ON)
- {
- pLed->bLedBlinkInProgress = TRUE;
-
- pLed->CurrLedState = LED_BLINK_WPS;
- pLed->BlinkTimes = 20;
-
- if( pLed->bLedOn )
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LONG_INTERVAL));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LONG_INTERVAL));
- }
- }
- break;
-
- case LED_CTL_STOP_WPS:
- if(pLed->bLedBlinkInProgress)
- {
- pLed->CurrLedState = LED_OFF;
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- break;
-
-
- default:
- break;
- }
-
- RT_TRACE(COMP_LED, "Led %d\n", pLed->CurrLedState);
-
-}
-
-void
-SwLedControlMode1(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed0);
-
- if(priv->CustomerID == RT_CID_819x_CAMEO)
- pLed = &(priv->SwLed1);
-
- switch(LedAction)
- {
- case LED_CTL_START_TO_LINK:
- case LED_CTL_NO_LINK:
- if( pLed->bLedNoLinkBlinkInProgress == FALSE )
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
- if( pLed->bLedLinkBlinkInProgress == TRUE )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_LINK:
- if( pLed->bLedLinkBlinkInProgress == FALSE )
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_NORMAL;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_LINK_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_SITE_SURVEY:
- if((priv->ieee80211->LinkDetectInfo.bBusyTraffic) && (priv->ieee80211->state == IEEE80211_LINKED))
- ;
- else if(pLed->bLedScanBlinkInProgress ==FALSE)
- {
- if(IS_LED_WPS_BLINKING(pLed))
- return;
-
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress == TRUE )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedScanBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_SCAN_BLINK;
- pLed->BlinkTimes = 24;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_TX:
- case LED_CTL_RX:
- if(pLed->bLedBlinkInProgress ==FALSE)
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- }
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress == TRUE )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- pLed->bLedBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_TXRX_BLINK;
- pLed->BlinkTimes = 2;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_START_WPS:
- case LED_CTL_START_WPS_BOTTON:
- if(pLed->bLedWPSBlinkInProgress ==FALSE)
- {
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress == TRUE )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedScanBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- pLed->bLedWPSBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_WPS;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
-
- case LED_CTL_STOP_WPS:
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress == TRUE )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedScanBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- }
- else
- {
- pLed->bLedWPSBlinkInProgress = TRUE;
- }
-
- pLed->CurrLedState = LED_BLINK_WPS_STOP;
- if(pLed->bLedOn)
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), 0);
- }
- break;
-
- case LED_CTL_STOP_WPS_FAIL:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- if( pLed->bLedNoLinkBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedWPSBlinkInProgress )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
-
- SwLedOff(dev, pLed);
- break;
-
- default:
- break;
-
- }
-
- RT_TRACE(COMP_LED, "Led %d\n", pLed->CurrLedState);
-}
-
-void
-SwLedControlMode2(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed0);
-
- switch(LedAction)
- {
- case LED_CTL_SITE_SURVEY:
- if(priv->ieee80211->LinkDetectInfo.bBusyTraffic)
- ;
- else if(pLed->bLedScanBlinkInProgress ==FALSE)
- {
- if(IS_LED_WPS_BLINKING(pLed))
- return;
-
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedScanBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_SCAN_BLINK;
- pLed->BlinkTimes = 24;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_TX:
- case LED_CTL_RX:
- if((pLed->bLedBlinkInProgress ==FALSE) && (priv->ieee80211->state == IEEE80211_LINKED))
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
-
- pLed->bLedBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_TXRX_BLINK;
- pLed->BlinkTimes = 2;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_LINK:
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
-
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- case LED_CTL_START_WPS:
- case LED_CTL_START_WPS_BOTTON:
- if(pLed->bLedWPSBlinkInProgress ==FALSE)
- {
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedScanBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- pLed->bLedWPSBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), 0);
- }
- break;
-
- case LED_CTL_STOP_WPS:
- pLed->bLedWPSBlinkInProgress = FALSE;
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), 0);
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- break;
-
- case LED_CTL_STOP_WPS_FAIL:
- pLed->bLedWPSBlinkInProgress = FALSE;
- if( priv->ieee80211->eRFPowerState != eRfOn )
- {
- SwLedOff(dev, pLed);
- }
- else
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), 0);
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
- }
- break;
-
- case LED_CTL_START_TO_LINK:
- case LED_CTL_NO_LINK:
- if(!IS_LED_BLINKING(pLed))
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), 0);
- }
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- if( pLed->bLedWPSBlinkInProgress )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- default:
- break;
-
- }
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
-}
-
- void
- SwLedControlMode3(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed0);
-
- switch(LedAction)
- {
- case LED_CTL_SITE_SURVEY:
- if(priv->ieee80211->LinkDetectInfo.bBusyTraffic)
- ;
- else if(pLed->bLedScanBlinkInProgress ==FALSE)
- {
- if(IS_LED_WPS_BLINKING(pLed))
- return;
-
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedScanBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_SCAN_BLINK;
- pLed->BlinkTimes = 24;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_TX:
- case LED_CTL_RX:
- if((pLed->bLedBlinkInProgress ==FALSE) && (priv->ieee80211->state == IEEE80211_LINKED))
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
-
- pLed->bLedBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_TXRX_BLINK;
- pLed->BlinkTimes = 2;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_LINK:
- if(IS_LED_WPS_BLINKING(pLed))
- return;
-
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
-
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- case LED_CTL_START_WPS:
- case LED_CTL_START_WPS_BOTTON:
- if(pLed->bLedWPSBlinkInProgress ==FALSE)
- {
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedScanBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- pLed->bLedWPSBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_WPS;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_STOP_WPS:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
- else
- {
- pLed->bLedWPSBlinkInProgress = TRUE;
- }
-
- pLed->CurrLedState = LED_BLINK_WPS_STOP;
- if(pLed->bLedOn)
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), 0);
- }
-
- break;
-
-
- case LED_CTL_STOP_WPS_FAIL:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- case LED_CTL_START_TO_LINK:
- case LED_CTL_NO_LINK:
- if(!IS_LED_BLINKING(pLed))
- {
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), 0);
- }
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- if( pLed->bLedWPSBlinkInProgress )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- default:
- break;
-
- }
-
- RT_TRACE(COMP_LED, "CurrLedState %d\n", pLed->CurrLedState);
-}
-
-
-void
-SwLedControlMode4(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed0);
- PLED_819xUsb pLed1 = &(priv->SwLed1);
-
- switch(LedAction)
- {
- case LED_CTL_START_TO_LINK:
- if(pLed1->bLedWPSBlinkInProgress)
- {
- pLed1->bLedWPSBlinkInProgress = FALSE;
- del_timer_sync(&(pLed1->BlinkTimer));
-
- pLed1->BlinkingLedState = LED_OFF;
- pLed1->CurrLedState = LED_OFF;
-
- if(pLed1->bLedOn)
- mod_timer(&(pLed1->BlinkTimer), 0);
- }
-
- if( pLed->bLedStartToLinkBlinkInProgress == FALSE )
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedNoLinkBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
-
- pLed->bLedStartToLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_StartToBlink;
- if( pLed->bLedOn )
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
- }
- break;
-
- case LED_CTL_LINK:
- case LED_CTL_NO_LINK:
- if(LedAction == LED_CTL_LINK)
- {
- if(pLed1->bLedWPSBlinkInProgress)
- {
- pLed1->bLedWPSBlinkInProgress = FALSE;
- del_timer_sync(&(pLed1->BlinkTimer));
-
- pLed1->BlinkingLedState = LED_OFF;
- pLed1->CurrLedState = LED_OFF;
-
- if(pLed1->bLedOn)
- mod_timer(&(pLed1->BlinkTimer), 0);
- }
- }
-
- if( pLed->bLedNoLinkBlinkInProgress == FALSE )
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
- }
-
- break;
-
- case LED_CTL_SITE_SURVEY:
- if((priv->ieee80211->LinkDetectInfo.bBusyTraffic) && (priv->ieee80211->state == IEEE80211_LINKED))
- ;
- else if(pLed->bLedScanBlinkInProgress ==FALSE)
- {
- if(IS_LED_WPS_BLINKING(pLed))
- return;
-
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedScanBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_SCAN_BLINK;
- pLed->BlinkTimes = 24;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_TX:
- case LED_CTL_RX:
- if(pLed->bLedBlinkInProgress ==FALSE)
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK || IS_LED_WPS_BLINKING(pLed))
- {
- return;
- }
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- pLed->bLedBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_TXRX_BLINK;
- pLed->BlinkTimes = 2;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_START_WPS:
- case LED_CTL_START_WPS_BOTTON:
- if(pLed1->bLedWPSBlinkInProgress)
- {
- pLed1->bLedWPSBlinkInProgress = FALSE;
- del_timer_sync(&(pLed1->BlinkTimer));
-
- pLed1->BlinkingLedState = LED_OFF;
- pLed1->CurrLedState = LED_OFF;
-
- if(pLed1->bLedOn)
- mod_timer(&(pLed1->BlinkTimer), 0);
- }
-
- if(pLed->bLedWPSBlinkInProgress ==FALSE)
- {
- if(pLed->bLedNoLinkBlinkInProgress == TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if(pLed->bLedScanBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- pLed->bLedWPSBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_WPS;
- if( pLed->bLedOn )
- {
- pLed->BlinkingLedState = LED_OFF;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SLOWLY_INTERVAL));
- }
- else
- {
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
- }
-
- }
- break;
-
- case LED_CTL_STOP_WPS:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
-
- break;
-
- case LED_CTL_STOP_WPS_FAIL:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
-
- if(pLed1->bLedWPSBlinkInProgress)
- del_timer_sync(&(pLed1->BlinkTimer));
- else
- pLed1->bLedWPSBlinkInProgress = TRUE;
-
- pLed1->CurrLedState = LED_BLINK_WPS_STOP;
- if( pLed1->bLedOn )
- pLed1->BlinkingLedState = LED_OFF;
- else
- pLed1->BlinkingLedState = LED_ON;
- mod_timer(&(pLed1->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
-
- break;
-
- case LED_CTL_STOP_WPS_FAIL_OVERLAP:
- if(pLed->bLedWPSBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
-
- pLed->bLedNoLinkBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_BLINK_SLOWLY;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
-
- if(pLed1->bLedWPSBlinkInProgress)
- del_timer_sync(&(pLed1->BlinkTimer));
- else
- pLed1->bLedWPSBlinkInProgress = TRUE;
-
- pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP;
- pLed1->BlinkTimes = 10;
- if( pLed1->bLedOn )
- pLed1->BlinkingLedState = LED_OFF;
- else
- pLed1->BlinkingLedState = LED_ON;
- mod_timer(&(pLed1->BlinkTimer), jiffies + MSECS(LED_BLINK_NORMAL_INTERVAL));
-
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
-
- if( pLed->bLedNoLinkBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedNoLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedLinkBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedLinkBlinkInProgress = FALSE;
- }
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- if( pLed->bLedWPSBlinkInProgress )
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedWPSBlinkInProgress = FALSE;
- }
- if( pLed->bLedScanBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedScanBlinkInProgress = FALSE;
- }
- if( pLed->bLedStartToLinkBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedStartToLinkBlinkInProgress = FALSE;
- }
-
- if( pLed1->bLedWPSBlinkInProgress )
- {
- del_timer_sync(&(pLed1->BlinkTimer));
- pLed1->bLedWPSBlinkInProgress = FALSE;
- }
-
-
- pLed1->BlinkingLedState = LED_UNKNOWN;
- SwLedOff(dev, pLed);
- SwLedOff(dev, pLed1);
- break;
-
- default:
- break;
-
- }
-
- RT_TRACE(COMP_LED, "Led %d\n", pLed->CurrLedState);
-}
-
-
-
-void
-SwLedControlMode5(
- struct net_device *dev,
- LED_CTL_MODE LedAction
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PLED_819xUsb pLed = &(priv->SwLed0);
-
- if(priv->CustomerID == RT_CID_819x_CAMEO)
- pLed = &(priv->SwLed1);
-
- switch(LedAction)
- {
- case LED_CTL_POWER_ON:
- case LED_CTL_NO_LINK:
- case LED_CTL_LINK:
- if(pLed->CurrLedState == LED_SCAN_BLINK)
- {
- return;
- }
- pLed->CurrLedState = LED_ON;
- pLed->BlinkingLedState = LED_ON;
- pLed->bLedBlinkInProgress = FALSE;
- mod_timer(&(pLed->BlinkTimer), 0);
- break;
-
- case LED_CTL_SITE_SURVEY:
- if((priv->ieee80211->LinkDetectInfo.bBusyTraffic) && (priv->ieee80211->state == IEEE80211_LINKED))
- ;
- else if(pLed->bLedScanBlinkInProgress ==FALSE)
- {
- if(pLed->bLedBlinkInProgress ==TRUE)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
- pLed->bLedScanBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_SCAN_BLINK;
- pLed->BlinkTimes = 24;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_SCAN_INTERVAL_ALPHA));
-
- }
- break;
-
- case LED_CTL_TX:
- case LED_CTL_RX:
- if(pLed->bLedBlinkInProgress ==FALSE)
- {
- if(pLed->CurrLedState == LED_SCAN_BLINK)
- {
- return;
- }
- pLed->bLedBlinkInProgress = TRUE;
- pLed->CurrLedState = LED_TXRX_BLINK;
- pLed->BlinkTimes = 2;
- if( pLed->bLedOn )
- pLed->BlinkingLedState = LED_OFF;
- else
- pLed->BlinkingLedState = LED_ON;
- mod_timer(&(pLed->BlinkTimer), jiffies + MSECS(LED_BLINK_FASTER_INTERVAL_ALPHA));
- }
- break;
-
- case LED_CTL_POWER_OFF:
- pLed->CurrLedState = LED_OFF;
- pLed->BlinkingLedState = LED_OFF;
-
- if( pLed->bLedBlinkInProgress)
- {
- del_timer_sync(&(pLed->BlinkTimer));
- pLed->bLedBlinkInProgress = FALSE;
- }
-
- SwLedOff(dev, pLed);
- break;
-
- default:
- break;
-
- }
-
- RT_TRACE(COMP_LED, "Led %d\n", pLed->CurrLedState);
-}
-
-
-void
-LedControl8192SUsb(
- struct net_device *dev,
- LED_CTL_MODE LedAction
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if( priv->bRegUseLed == FALSE)
- return;
-
- if (!priv->up)
- return;
-
- if(priv->bInHctTest)
- return;
-
- if( priv->ieee80211->eRFPowerState != eRfOn &&
- (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX ||
- LedAction == LED_CTL_SITE_SURVEY ||
- LedAction == LED_CTL_LINK ||
- LedAction == LED_CTL_NO_LINK ||
- LedAction == LED_CTL_POWER_ON) )
- {
- return;
- }
-
- switch(priv->LedStrategy)
- {
- case SW_LED_MODE0:
- break;
-
- case SW_LED_MODE1:
- SwLedControlMode1(dev, LedAction);
- break;
- case SW_LED_MODE2:
- SwLedControlMode2(dev, LedAction);
- break;
-
- case SW_LED_MODE3:
- SwLedControlMode3(dev, LedAction);
- break;
-
- case SW_LED_MODE4:
- SwLedControlMode4(dev, LedAction);
- break;
-
- case SW_LED_MODE5:
- SwLedControlMode5(dev, LedAction);
- break;
-
- default:
- break;
- }
-
- RT_TRACE(COMP_LED, "LedStrategy:%d, LedAction %d\n", priv->LedStrategy,LedAction);
-}
-
-
diff --git a/drivers/staging/rtl8192su/r8192SU_led.h b/drivers/staging/rtl8192su/r8192SU_led.h
deleted file mode 100644
index acedae4a59ca..000000000000
--- a/drivers/staging/rtl8192su/r8192SU_led.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef __INC_HAL8192USBLED_H
-#define __INC_HAL8192USBLED_H
-
-#include <linux/types.h>
-#include <linux/timer.h>
-
-typedef enum _LED_STATE_819xUsb{
- LED_UNKNOWN = 0,
- LED_ON = 1,
- LED_OFF = 2,
- LED_BLINK_NORMAL = 3,
- LED_BLINK_SLOWLY = 4,
- LED_POWER_ON_BLINK = 5,
- LED_SCAN_BLINK = 6,
- LED_NO_LINK_BLINK = 7,
- LED_BLINK_StartToBlink = 8,
- LED_BLINK_WPS = 9,
- LED_TXRX_BLINK = 10,
- LED_BLINK_WPS_STOP = 11,
- LED_BLINK_WPS_STOP_OVERLAP = 12,
-
-}LED_STATE_819xUsb;
-
-#define IS_LED_WPS_BLINKING(_LED_819xUsb) (((PLED_819xUsb)_LED_819xUsb)->CurrLedState==LED_BLINK_WPS \
- || ((PLED_819xUsb)_LED_819xUsb)->CurrLedState==LED_BLINK_WPS_STOP \
- || ((PLED_819xUsb)_LED_819xUsb)->bLedWPSBlinkInProgress)
-
-#define IS_LED_BLINKING(_LED_819xUsb) (((PLED_819xUsb)_LED_819xUsb)->bLedWPSBlinkInProgress \
- ||((PLED_819xUsb)_LED_819xUsb)->bLedScanBlinkInProgress)
-
-typedef enum _LED_PIN_819xUsb{
- LED_PIN_GPIO0,
- LED_PIN_LED0,
- LED_PIN_LED1
-}LED_PIN_819xUsb;
-
-typedef enum _LED_STRATEGY_819xUsb{
- SW_LED_MODE0, /* SW control 1 LED via GPIO0. It is default option. */
- SW_LED_MODE1, /* SW control for PCI Express */
- SW_LED_MODE2, /* SW control for Cameo. */
- SW_LED_MODE3, /* SW contorl for RunTop. */
- SW_LED_MODE4, /* SW control for Netcore */
- SW_LED_MODE5,
- HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes) */
-}LED_STRATEGY_819xUsb, *PLED_STRATEGY_819xUsb;
-
-typedef struct _LED_819xUsb{
- struct net_device *dev;
-
- LED_PIN_819xUsb LedPin;
-
- LED_STATE_819xUsb CurrLedState;
- bool bLedOn;
-
- bool bSWLedCtrl;
-
- bool bLedBlinkInProgress;
- bool bLedNoLinkBlinkInProgress;
- bool bLedLinkBlinkInProgress;
- bool bLedStartToLinkBlinkInProgress;
- bool bLedScanBlinkInProgress;
- bool bLedWPSBlinkInProgress;
-
- u32 BlinkTimes;
- LED_STATE_819xUsb BlinkingLedState;
-
- struct timer_list BlinkTimer;
-} LED_819xUsb, *PLED_819xUsb;
-
-void InitSwLeds(struct net_device *dev);
-void DeInitSwLeds(struct net_device *dev);
-void LedControl8192SUsb(struct net_device *dev,LED_CTL_MODE LedAction);
-
-#endif
-
diff --git a/drivers/staging/rtl8192su/r8192S_Efuse.c b/drivers/staging/rtl8192su/r8192S_Efuse.c
deleted file mode 100644
index bbefd0f30348..000000000000
--- a/drivers/staging/rtl8192su/r8192S_Efuse.c
+++ /dev/null
@@ -1,2199 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * Based on the r8180 driver, which is:
- * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "r8192U.h"
-#include "r8192S_hw.h"
-#include "r8192S_phy.h"
-#include "r8192S_phyreg.h"
-#include "r8192S_Efuse.h"
-
-#include <linux/types.h>
-#include <linux/ctype.h>
-
-#define _POWERON_DELAY_
-#define _PRE_EXECUTE_READ_CMD_
-
-#define EFUSE_REPEAT_THRESHOLD_ 3
-#define EFUSE_ERROE_HANDLE 1
-
-typedef struct _EFUSE_MAP_A{
- u8 offset; //0~15
- u8 word_start; //0~3
- u8 byte_start; //0 or 1
- u8 byte_cnts;
-
-}EFUSE_MAP, *PEFUSE_MAP;
-
-typedef struct PG_PKT_STRUCT_A{
- u8 offset;
- u8 word_en;
- u8 data[8];
-}PGPKT_STRUCT,*PPGPKT_STRUCT;
-
-typedef enum _EFUSE_DATA_ITEM{
- EFUSE_CHIP_ID=0,
- EFUSE_LDO_SETTING,
- EFUSE_CLK_SETTING,
- EFUSE_SDIO_SETTING,
- EFUSE_CCCR,
- EFUSE_SDIO_MODE,
- EFUSE_OCR,
- EFUSE_F0CIS,
- EFUSE_F1CIS,
- EFUSE_MAC_ADDR,
- EFUSE_EEPROM_VER,
- EFUSE_CHAN_PLAN,
- EFUSE_TXPW_TAB
-} EFUSE_DATA_ITEM;
-
-struct efuse_priv
-{
- u8 id[2];
- u8 ldo_setting[2];
- u8 clk_setting[2];
- u8 cccr;
- u8 sdio_mode;
- u8 ocr[3];
- u8 cis0[17];
- u8 cis1[48];
- u8 mac_addr[6];
- u8 eeprom_verno;
- u8 channel_plan;
- u8 tx_power_b[14];
- u8 tx_power_g[14];
-};
-
-const u8 MAX_PGPKT_SIZE = 9; //header+ 2* 4 words (BYTES)
-const u8 PGPKT_DATA_SIZE = 8; //BYTES sizeof(u8)*8
-const u32 EFUSE_MAX_SIZE = 512;
-
-const u8 EFUSE_OOB_PROTECT_BYTES = 14;
-
-const EFUSE_MAP RTL8712_SDIO_EFUSE_TABLE[]={
- //offset word_s byte_start byte_cnts
-/*ID*/ {0 ,0 ,0 ,2 }, // 00~01h
-/*LDO Setting*/ {0 ,1 ,0 ,2 }, // 02~03h
-/*CLK Setting*/ {0 ,2 ,0 ,2 }, // 04~05h
-/*SDIO Setting*/ {1 ,0 ,0 ,1 }, // 08h
-/*CCCR*/ {1 ,0 ,1 ,1 }, // 09h
-/*SDIO MODE*/ {1 ,1 ,0 ,1 }, // 0Ah
-/*OCR*/ {1 ,1 ,1 ,3 }, // 0B~0Dh
-/*CCIS*/ {1 ,3 ,0 ,17 }, // 0E~1Eh 2...1
-/*F1CIS*/ {3 ,3 ,1 ,48 }, // 1F~4Eh 6...0
-/*MAC Addr*/ {10 ,0 ,0 ,6 }, // 50~55h
-/*EEPROM ver*/ {10 ,3 ,0 ,1 }, // 56h
-/*Channel plan*/ {10 ,3 ,1 ,1 }, // 57h
-/*TxPwIndex */ {11 ,0 ,0 ,28 } // 58~73h 3...4
-};
-
-//
-// From WMAC Efuse one byte R/W
-//
-extern void
-EFUSE_Initialize(struct net_device* dev);
-extern u8
-EFUSE_Read1Byte(struct net_device* dev, u16 Address);
-extern void
-EFUSE_Write1Byte(struct net_device* dev, u16 Address,u8 Value);
-
-//
-// Efuse Shadow Area operation
-//
-static void
-efuse_ShadowRead1Byte(struct net_device* dev,u16 Offset,u8 *Value);
-static void
-efuse_ShadowRead2Byte(struct net_device* dev, u16 Offset,u16 *Value );
-static void
-efuse_ShadowRead4Byte(struct net_device* dev, u16 Offset,u32 *Value );
-static void
-efuse_ShadowWrite1Byte(struct net_device* dev, u16 Offset, u8 Value);
-static void
-efuse_ShadowWrite2Byte(struct net_device* dev, u16 Offset,u16 Value);
-static void
-efuse_ShadowWrite4Byte(struct net_device* dev, u16 Offset,u32 Value);
-
-//
-// Real Efuse operation
-//
-static u8
-efuse_OneByteRead(struct net_device* dev,u16 addr,u8 *data);
-static u8
-efuse_OneByteWrite(struct net_device* dev,u16 addr, u8 data);
-
-//
-// HW setting map file operation
-//
-static void
-efuse_ReadAllMap(struct net_device* dev,u8 *Efuse);
-#ifdef TO_DO_LIST
-static void
-efuse_WriteAllMap(struct net_device* dev,u8 *eeprom,u32 eeprom_size);
-static bool
-efuse_ParsingMap(char* szStr,u32* pu4bVal,u32* pu4bMove);
-#endif
-//
-// Reald Efuse R/W or other operation API.
-//
-static u8
-efuse_PgPacketRead( struct net_device* dev,u8 offset,u8 *data);
-static u32
-efuse_PgPacketWrite(struct net_device* dev,u8 offset,u8 word_en,u8 *data);
-static void
-efuse_WordEnableDataRead( u8 word_en,u8 *sourdata,u8 *targetdata);
-static u8
-efuse_WordEnableDataWrite( struct net_device* dev, u16 efuse_addr, u8 word_en, u8 *data);
-static void
-efuse_PowerSwitch(struct net_device* dev,u8 PwrState);
-static u16
-efuse_GetCurrentSize(struct net_device* dev);
-static u8
-efuse_CalculateWordCnts(u8 word_en);
-//
-// API for power on power off!!!
-//
-#ifdef TO_DO_LIST
-static void efuse_reg_ctrl(struct net_device* dev, u8 bPowerOn);
-#endif
-
-
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_Initialize
- *
- * Overview: Copy from WMAC fot EFUSE testing setting init.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 09/23/2008 MHC Copy from WMAC.
- *
- *---------------------------------------------------------------------------*/
-extern void
-EFUSE_Initialize(struct net_device* dev)
-{
- u8 Bytetemp = {0x00};
- u8 temp = {0x00};
-
- //Enable Digital Core Vdd : 0x2[13]=1
- Bytetemp = read_nic_byte(dev, SYS_FUNC_EN+1);
- temp = Bytetemp | 0x20;
- write_nic_byte(dev, SYS_FUNC_EN+1, temp);
-
- //EE loader to retention path1: attach 0x0[8]=0
- Bytetemp = read_nic_byte(dev, SYS_ISO_CTRL+1);
- temp = Bytetemp & 0xFE;
- write_nic_byte(dev, SYS_ISO_CTRL+1, temp);
-
-
- //Enable E-fuse use 2.5V LDO : 0x37[7]=1
- Bytetemp = read_nic_byte(dev, EFUSE_TEST+3);
- temp = Bytetemp | 0x80;
- write_nic_byte(dev, EFUSE_TEST+3, temp);
-
- //E-fuse clk switch from 500k to 40M : 0x2F8[1:0]=11b
- write_nic_byte(dev, 0x2F8, 0x3);
-
- //Set E-fuse program time & read time : 0x30[30:24]=1110010b
- write_nic_byte(dev, EFUSE_CTRL+3, 0x72);
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_Read1Byte
- *
- * Overview: Copy from WMAC fot EFUSE read 1 byte.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 09/23/2008 MHC Copy from WMAC.
- *
- *---------------------------------------------------------------------------*/
-extern u8
-EFUSE_Read1Byte(struct net_device* dev, u16 Address)
-{
- u8 data;
- u8 Bytetemp = {0x00};
- u8 temp = {0x00};
- u32 k=0;
-
- if (Address < EFUSE_MAC_LEN) //E-fuse 512Byte
- {
- //Write E-fuse Register address bit0~7
- temp = Address & 0xFF;
- write_nic_byte(dev, EFUSE_CTRL+1, temp);
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+2);
- //Write E-fuse Register address bit8~9
- temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
- write_nic_byte(dev, EFUSE_CTRL+2, temp);
-
- //Write 0x30[31]=0
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- temp = Bytetemp & 0x7F;
- write_nic_byte(dev, EFUSE_CTRL+3, temp);
-
- //Wait Write-ready (0x30[31]=1)
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- while(!(Bytetemp & 0x80))
- {
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- k++;
- if(k==1000)
- {
- k=0;
- break;
- }
- }
- data=read_nic_byte(dev, EFUSE_CTRL);
- return data;
- }
- else
- return 0xFF;
-
-}
-
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_Write1Byte
- *
- * Overview: Copy from WMAC fot EFUSE write 1 byte.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 09/23/2008 MHC Copy from WMAC.
- *
- *---------------------------------------------------------------------------*/
-extern void
-EFUSE_Write1Byte(struct net_device* dev, u16 Address,u8 Value)
-{
- u8 Bytetemp = {0x00};
- u8 temp = {0x00};
- u32 k=0;
-
- if( Address < EFUSE_MAC_LEN) //E-fuse 512Byte
- {
- write_nic_byte(dev, EFUSE_CTRL, Value);
-
- //Write E-fuse Register address bit0~7
- temp = Address & 0xFF;
- write_nic_byte(dev, EFUSE_CTRL+1, temp);
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+2);
-
- //Write E-fuse Register address bit8~9
- temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC);
- write_nic_byte(dev, EFUSE_CTRL+2, temp);
-
- //Write 0x30[31]=1
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- temp = Bytetemp | 0x80;
- write_nic_byte(dev, EFUSE_CTRL+3, temp);
-
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- while(Bytetemp & 0x80)
- {
- Bytetemp = read_nic_byte(dev, EFUSE_CTRL+3);
- k++;
- if(k==100)
- {
- k=0;
- break;
- }
- }
- }
-
-}
-
-#ifdef EFUSE_FOR_92SU
-//
-// Description:
-// 1. Process CR93C46 Data polling cycle.
-// 2. Refered from SD1 Richard.
-//
-// Assumption:
-// 1. Boot from E-Fuse and successfully auto-load.
-// 2. PASSIVE_LEVEL (USB interface)
-//
-// Created by Roger, 2008.10.21.
-//
-void do_93c46(struct net_device* dev, u8 addorvalue)
-{
- u8 cs[1] = {0x88}; // cs=1 , sk=0 , di=0 , do=0
- u8 cssk[1] = {0x8c}; // cs=1 , sk=1 , di=0 , do=0
- u8 csdi[1] = {0x8a}; // cs=1 , sk=0 , di=1 , do=0
- u8 csskdi[1] = {0x8e}; // cs=1 , sk=1 , di=1 , do=0
- u8 count;
-
- for(count=0 ; count<8 ; count++)
- {
- if((addorvalue&0x80)!=0)
- {
- write_nic_byte(dev, EPROM_CMD, csdi[0]);
- write_nic_byte(dev, EPROM_CMD, csskdi[0]);
- }
- else
- {
- write_nic_byte(dev, EPROM_CMD, cs[0]);
- write_nic_byte(dev, EPROM_CMD, cssk[0]);
- }
- addorvalue = addorvalue << 1;
- }
-}
-
-
-//
-// Description:
-// Process CR93C46 Data read polling cycle.
-// Refered from SD1 Richard.
-//
-// Assumption:
-// 1. Boot from E-Fuse and successfully auto-load.
-// 2. PASSIVE_LEVEL (USB interface)
-//
-// Created by Roger, 2008.10.21.
-//
-u16 Read93C46(struct net_device* dev, u16 Reg )
-{
-
- u8 clear[1] = {0x0}; // cs=0 , sk=0 , di=0 , do=0
- u8 cs[1] = {0x88}; // cs=1 , sk=0 , di=0 , do=0
- u8 cssk[1] = {0x8c}; // cs=1 , sk=1 , di=0 , do=0
- u8 csdi[1] = {0x8a}; // cs=1 , sk=0 , di=1 , do=0
- u8 csskdi[1] = {0x8e}; // cs=1 , sk=1 , di=1 , do=0
- u8 EepromSEL[1]={0x00};
- u8 address;
-
- u16 storedataF[1] = {0x0}; //93c46 data packet for 16bits
- u8 t,data[1],storedata[1];
-
-
- address = (u8)Reg;
-
- *EepromSEL= read_nic_byte(dev, EPROM_CMD);
-
- if((*EepromSEL & 0x10) == 0x10) // select 93c46
- {
- address = address | 0x80;
-
- write_nic_byte(dev, EPROM_CMD, csdi[0]);
- write_nic_byte(dev, EPROM_CMD, csskdi[0]);
- do_93c46(dev, address);
- }
-
-
- for(t=0 ; t<16 ; t++) //if read 93c46 , t=16
- {
- write_nic_byte(dev, EPROM_CMD, cs[0]);
- write_nic_byte(dev, EPROM_CMD, cssk[0]);
- *data= read_nic_byte(dev, EPROM_CMD);
-
- if(*data & 0x8d) //original code
- {
- *data = *data & 0x01;
- *storedata = *data;
- }
- else
- {
- *data = *data & 0x01 ;
- *storedata = *data;
- }
- *storedataF = (*storedataF << 1 ) + *storedata;
- }
- write_nic_byte(dev, EPROM_CMD, cs[0]);
- write_nic_byte(dev, EPROM_CMD, clear[0]);
-
- return *storedataF;
-}
-
-
-//
-// Description:
-// Execute E-Fuse read byte operation.
-// Refered from SD1 Richard.
-//
-// Assumption:
-// 1. Boot from E-Fuse and successfully auto-load.
-// 2. PASSIVE_LEVEL (USB interface)
-//
-// Created by Roger, 2008.10.21.
-//
-void
-ReadEFuseByte(struct net_device* dev,u16 _offset, u8 *pbuf)
-{
- u32 value32;
- u8 readbyte;
- u16 retry;
-
- //Write Address
- write_nic_byte(dev, EFUSE_CTRL+1, (_offset & 0xff));
- readbyte = read_nic_byte(dev, EFUSE_CTRL+2);
- write_nic_byte(dev, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc));
-
- //Write bit 32 0
- readbyte = read_nic_byte(dev, EFUSE_CTRL+3);
- write_nic_byte(dev, EFUSE_CTRL+3, (readbyte & 0x7f));
-
- //Check bit 32 read-ready
- retry = 0;
- value32 = read_nic_dword(dev, EFUSE_CTRL);
- while(!(((value32 >> 24) & 0xff) & 0x80) && (retry<10000))
- {
- value32 = read_nic_dword(dev, EFUSE_CTRL);
- retry++;
- }
- *pbuf = (u8)(value32 & 0xff);
-}
-
-
-#define EFUSE_READ_SWITCH 1
-//
-// Description:
-// 1. Execute E-Fuse read byte operation according as map offset and
-// save to E-Fuse table.
-// 2. Refered from SD1 Richard.
-//
-// Assumption:
-// 1. Boot from E-Fuse and successfully auto-load.
-// 2. PASSIVE_LEVEL (USB interface)
-//
-// Created by Roger, 2008.10.21.
-//
-void
-ReadEFuse(struct net_device* dev, u16 _offset, u16 _size_byte, u8 *pbuf)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 efuseTbl[EFUSE_MAP_LEN];
- u8 rtemp8[1];
- u16 eFuse_Addr = 0;
- u8 offset, wren;
- u16 i, j;
- u16 eFuseWord[EFUSE_MAX_SECTION][EFUSE_MAX_WORD_UNIT];
- u16 efuse_utilized = 0;
- u16 efuse_usage = 0;
-
- if((_offset + _size_byte)>EFUSE_MAP_LEN)
- {
- printk("ReadEFuse(): Invalid offset with read bytes!!\n");
- return;
- }
-
- for(i = 0; i < EFUSE_MAX_SECTION; i++)
- for(j = 0; j < EFUSE_MAX_WORD_UNIT; j++)
- eFuseWord[i][j]=0xFFFF;
-
-#if (EFUSE_READ_SWITCH == 1)
- ReadEFuseByte(dev, eFuse_Addr, rtemp8);
-#else
- rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr);
-#endif
- if(*rtemp8 != 0xFF){
- efuse_utilized++;
- RT_TRACE(COMP_EPROM, "Addr=%d\n", eFuse_Addr);
- eFuse_Addr++;
- }
-
- while((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN))
- {
- offset = ((*rtemp8 >> 4) & 0x0f);
- if(offset < EFUSE_MAX_SECTION)
- {
- wren = (*rtemp8 & 0x0f);
- RT_TRACE(COMP_EPROM, "Offset-%d Worden=%x\n", offset, wren);
-
- for(i = 0; i < EFUSE_MAX_WORD_UNIT; i++)
- {
- if(!(wren & 0x01))
- {
- RT_TRACE(COMP_EPROM, "Addr=%d\n", eFuse_Addr);
-#if (EFUSE_READ_SWITCH == 1)
- ReadEFuseByte(dev, eFuse_Addr, rtemp8); eFuse_Addr++;
-#else
- rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
-#endif
- efuse_utilized++;
- eFuseWord[offset][i] = (*rtemp8 & 0xff);
- if(eFuse_Addr >= EFUSE_REAL_CONTENT_LEN)
- break;
-
- RT_TRACE(COMP_EPROM, "Addr=%d\n", eFuse_Addr);
-#if (EFUSE_READ_SWITCH == 1)
- ReadEFuseByte(dev, eFuse_Addr, rtemp8); eFuse_Addr++;
-#else
- rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
-#endif
- efuse_utilized++;
- eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00);
- if(eFuse_Addr >= EFUSE_REAL_CONTENT_LEN)
- break;
- }
- wren >>= 1;
- }
- }
-
- RT_TRACE(COMP_EPROM, "Addr=%d\n", eFuse_Addr);
-#if (EFUSE_READ_SWITCH == 1)
- ReadEFuseByte(dev, eFuse_Addr, rtemp8);
-#else
- rtemp8[0] = EFUSE_Read1Byte(dev, eFuse_Addr); eFuse_Addr++;
-#endif
- if(*rtemp8 != 0xFF && (eFuse_Addr < 512))
- {
- efuse_utilized++;
- eFuse_Addr++;
- }
- }
-
- for(i=0; i<EFUSE_MAX_SECTION; i++)
- {
- for(j=0; j<EFUSE_MAX_WORD_UNIT; j++)
- {
- efuseTbl[(i*8)+(j*2)]=(eFuseWord[i][j] & 0xff);
- efuseTbl[(i*8)+((j*2)+1)]=((eFuseWord[i][j] >> 8) & 0xff);
- }
- }
- for(i=0; i<_size_byte; i++)
- pbuf[i] = efuseTbl[_offset+i];
-
- efuse_usage = (u8)((efuse_utilized*100)/EFUSE_REAL_CONTENT_LEN);
- priv->EfuseUsedBytes = efuse_utilized;
- priv->EfuseUsedPercentage = (u8)efuse_usage;
-}
-#endif
-
-extern bool
-EFUSE_ShadowUpdateChk(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 SectionIdx, i, Base;
- u16 WordsNeed = 0, HdrNum = 0, TotalBytes = 0, EfuseUsed = 0;
- bool bWordChanged, bResult = true;
-
- for (SectionIdx = 0; SectionIdx < 16; SectionIdx++)
- {
- Base = SectionIdx * 8;
- bWordChanged = false;
-
- for (i = 0; i < 8; i=i+2)
- {
- if((priv->EfuseMap[EFUSE_INIT_MAP][Base+i] !=
- priv->EfuseMap[EFUSE_MODIFY_MAP][Base+i]) ||
- (priv->EfuseMap[EFUSE_INIT_MAP][Base+i+1] !=
- priv->EfuseMap[EFUSE_MODIFY_MAP][Base+i+1]))
- {
- WordsNeed++;
- bWordChanged = true;
- }
- }
-
- if( bWordChanged==true )
- HdrNum++;
- }
-
- TotalBytes = HdrNum + WordsNeed*2;
- EfuseUsed = priv->EfuseUsedBytes;
-
- if( (TotalBytes + EfuseUsed) >= (EFUSE_MAX_SIZE-EFUSE_OOB_PROTECT_BYTES))
- bResult = true;
-
- RT_TRACE(COMP_EPROM, "EFUSE_ShadowUpdateChk(): TotalBytes(%x), HdrNum(%x), WordsNeed(%x), EfuseUsed(%d)\n",
- TotalBytes, HdrNum, WordsNeed, EfuseUsed);
-
- return bResult;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_ShadowRead
- *
- * Overview: Read from efuse init map !!!!!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern void
-EFUSE_ShadowRead( struct net_device* dev, u8 Type, u16 Offset, u32 *Value)
-{
- if (Type == 1)
- efuse_ShadowRead1Byte(dev, Offset, (u8 *)Value);
- else if (Type == 2)
- efuse_ShadowRead2Byte(dev, Offset, (u16 *)Value);
- else if (Type == 4)
- efuse_ShadowRead4Byte(dev, Offset, (u32 *)Value);
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_ShadowWrite
- *
- * Overview: Write efuse modify map for later update operation to use!!!!!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern void
-EFUSE_ShadowWrite( struct net_device* dev, u8 Type, u16 Offset,u32 Value)
-{
- if (Offset >= 0x18 && Offset <= 0x1F)
- return;
-
- if (Type == 1)
- efuse_ShadowWrite1Byte(dev, Offset, (u8)Value);
- else if (Type == 2)
- efuse_ShadowWrite2Byte(dev, Offset, (u16)Value);
- else if (Type == 4)
- efuse_ShadowWrite4Byte(dev, Offset, (u32)Value);
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_ShadowUpdate
- *
- * Overview: Compare init and modify map to update Efuse!!!!!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern bool
-EFUSE_ShadowUpdate(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 i, offset, base = 0;
- u8 word_en = 0x0F;
- bool first_pg = false;
-
- RT_TRACE(COMP_EPROM, "--->EFUSE_ShadowUpdate()\n");
-
- if(!EFUSE_ShadowUpdateChk(dev))
- {
- efuse_ReadAllMap(dev, &priv->EfuseMap[EFUSE_INIT_MAP][0]);
- memcpy((void *)&priv->EfuseMap[EFUSE_MODIFY_MAP][0],
- (void *)&priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
-
- RT_TRACE(COMP_EPROM, "<---EFUSE_ShadowUpdate(): Efuse out of capacity!!\n");
- return false;
- }
- efuse_PowerSwitch(dev, TRUE);
-
- //
- // Efuse support 16 write are with PG header packet!!!!
- //
- for (offset = 0; offset < 16; offset++)
- {
- // Offset 0x18-1F are reserved now!!!
- word_en = 0x0F;
- base = offset * 8;
-
- //
- // Decide Word Enable Bit for the Efuse section
- // One section contain 4 words = 8 bytes!!!!!
- //
- for (i = 0; i < 8; i++)
- {
- if (first_pg == TRUE)
- {
- word_en &= ~(1<<(i/2));
- RT_TRACE(COMP_EPROM,"Section(%x) Addr[%x] %x update to %x, Word_En=%02x\n",
- offset, base+i, priv->EfuseMap[EFUSE_INIT_MAP][base+i],
- priv->EfuseMap[EFUSE_MODIFY_MAP][base+i],word_en);
- priv->EfuseMap[EFUSE_INIT_MAP][base+i] =
- priv->EfuseMap[EFUSE_MODIFY_MAP][base+i];
- }else
- {
- if ( priv->EfuseMap[EFUSE_INIT_MAP][base+i] !=
- priv->EfuseMap[EFUSE_MODIFY_MAP][base+i])
- {
- word_en &= ~(EFUSE_BIT(i/2));
- RT_TRACE(COMP_EPROM, "Section(%x) Addr[%x] %x update to %x, Word_En=%02x\n",
- offset, base+i, priv->EfuseMap[0][base+i],
- priv->EfuseMap[1][base+i],word_en);
-
- // Update init table!!!
- priv->EfuseMap[EFUSE_INIT_MAP][base+i] =
- priv->EfuseMap[EFUSE_MODIFY_MAP][base+i];
- }
- }
- }
-
- //
- // Call Efuse real write section !!!!
- //
- if (word_en != 0x0F)
- {
- u8 tmpdata[8];
-
- memcpy((void *)tmpdata, (void *)&(priv->EfuseMap[EFUSE_MODIFY_MAP][base]), 8);
- RT_TRACE(COMP_INIT, "U-EFUSE\n");
-
- if(!efuse_PgPacketWrite(dev,(u8)offset,word_en,tmpdata))
- {
- RT_TRACE(COMP_EPROM,"EFUSE_ShadowUpdate(): PG section(%x) fail!!\n", offset);
- break;
- }
- }
-
- }
- // For warm reboot, we must resume Efuse clock to 500K.
-
- efuse_PowerSwitch(dev, FALSE);
-
- efuse_ReadAllMap(dev, &priv->EfuseMap[EFUSE_INIT_MAP][0]);
- memcpy((void *)&priv->EfuseMap[EFUSE_MODIFY_MAP][0],
- (void *)&priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
-
- return true;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_ShadowMapUpdate
- *
- * Overview: Transfer current EFUSE content to shadow init and modify map.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/13/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern void EFUSE_ShadowMapUpdate(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if (priv->AutoloadFailFlag == true){
- memset(&(priv->EfuseMap[EFUSE_INIT_MAP][0]), 0xff, 128);
- }else{
- efuse_ReadAllMap(dev, &priv->EfuseMap[EFUSE_INIT_MAP][0]);
- }
- memcpy((void *)&priv->EfuseMap[EFUSE_MODIFY_MAP][0],
- (void *)&priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
-
-}
-
-extern void
-EFUSE_ForceWriteVendorId( struct net_device* dev)
-{
- u8 tmpdata[8] = {0xFF, 0xFF, 0xEC, 0x10, 0xFF, 0xFF, 0xFF, 0xFF};
-
- efuse_PowerSwitch(dev, TRUE);
-
- efuse_PgPacketWrite(dev, 1, 0xD, tmpdata);
-
- efuse_PowerSwitch(dev, FALSE);
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_ShadowRead1Byte
- * efuse_ShadowRead2Byte
- * efuse_ShadowRead4Byte
- *
- * Overview: Read from efuse init map by one/two/four bytes !!!!!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void
-efuse_ShadowRead1Byte(struct net_device* dev, u16 Offset, u8 *Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
-
-}
-
-//---------------Read Two Bytes
-static void
-efuse_ShadowRead2Byte(struct net_device* dev, u16 Offset, u16 *Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
- *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1]<<8;
-
-}
-
-//---------------Read Four Bytes
-static void
-efuse_ShadowRead4Byte(struct net_device* dev, u16 Offset, u32 *Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- *Value = priv->EfuseMap[EFUSE_MODIFY_MAP][Offset];
- *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1]<<8;
- *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+2]<<16;
- *Value |= priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+3]<<24;
-
-}
-
-
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_ShadowWrite1Byte
- * efuse_ShadowWrite2Byte
- * efuse_ShadowWrite4Byte
- *
- * Overview: Write efuse modify map by one/two/four byte.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void
-efuse_ShadowWrite1Byte(struct net_device* dev, u16 Offset, u8 Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = Value;
-
-}
-
-//---------------Write Two Bytes
-static void
-efuse_ShadowWrite2Byte(struct net_device* dev, u16 Offset, u16 Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = Value&0x00FF;
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1] = Value>>8;
-
-}
-
-//---------------Write Four Bytes
-static void
-efuse_ShadowWrite4Byte(struct net_device* dev, u16 Offset, u32 Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset] = (u8)(Value&0x000000FF);
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+1] = (u8)((Value>>8)&0x0000FF);
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+2] = (u8)((Value>>16)&0x00FF);
- priv->EfuseMap[EFUSE_MODIFY_MAP][Offset+3] = (u8)((Value>>24)&0xFF);
-
-}
-
-static u8
-efuse_OneByteRead(struct net_device* dev, u16 addr,u8 *data)
-{
- u8 tmpidx = 0;
- u8 bResult;
-
- // -----------------e-fuse reg ctrl ---------------------------------
- //address
- write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff));
- write_nic_byte(dev, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03) ) |
- (read_nic_byte(dev, EFUSE_CTRL+2)&0xFC ));
-
- write_nic_byte(dev, EFUSE_CTRL+3, 0x72);//read cmd
-
- while(!(0x80 &read_nic_byte(dev, EFUSE_CTRL+3))&&(tmpidx<100))
- {
- tmpidx++;
- }
- if(tmpidx<100)
- {
- *data=read_nic_byte(dev, EFUSE_CTRL);
- bResult = TRUE;
- }
- else
- {
- *data = 0xff;
- bResult = FALSE;
- }
- return bResult;
-}
-
-/* 11/16/2008 MH Write one byte to reald Efuse. */
-static u8
-efuse_OneByteWrite(struct net_device* dev, u16 addr, u8 data)
-{
- u8 tmpidx = 0;
- u8 bResult;
-
- // -----------------e-fuse reg ctrl ---------------------------------
- //address
- write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff));
- write_nic_byte(dev, EFUSE_CTRL+2,
- read_nic_byte(dev, EFUSE_CTRL+2)|(u8)((addr>>8)&0x03) );
-
- write_nic_byte(dev, EFUSE_CTRL, data);//data
- write_nic_byte(dev, EFUSE_CTRL+3, 0xF2);//write cmd
-
- while((0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
- tmpidx++;
- }
-
- if(tmpidx<100)
- {
- bResult = TRUE;
- }
- else
- {
- bResult = FALSE;
- }
-
- return bResult;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_ReadAllMap
- *
- * Overview: Read All Efuse content
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/11/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void
-efuse_ReadAllMap(struct net_device* dev, u8 *Efuse)
-{
- //
- // We must enable clock and LDO 2.5V otherwise, read all map will be fail!!!!
- //
- efuse_PowerSwitch(dev, TRUE);
- ReadEFuse(dev, 0, 128, Efuse);
- efuse_PowerSwitch(dev, FALSE);
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_WriteAllMap
- *
- * Overview: Write All Efuse content
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/11/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-#ifdef TO_DO_LIST
-static void
-efuse_WriteAllMap(struct net_device* dev,u8 *eeprom, u32 eeprom_size)
-{
- unsigned char word_en = 0x00;
-
- unsigned char tmpdata[8];
- unsigned char offset;
-
- // For Efuse write action, we must enable LDO2.5V and 40MHZ clk.
- efuse_PowerSwitch(dev, TRUE);
-
- //sdio contents
- for(offset=0 ; offset< eeprom_size/PGPKT_DATA_SIZE ; offset++)
- {
- // 92S will only reserv 0x18-1F 8 bytes now. The 3rd efuse write area!
- if (IS_HARDWARE_TYPE_8192SE(dev))
- {
- // Refer to
- // 0x18-1f Reserve >0x50 Reserve for tx power
- if (offset == 3/* || offset > 9*/)
- continue;//word_en = 0x0F;
- else
- word_en = 0x00;
- }
-
- memcpy(tmpdata, (eeprom+(offset*PGPKT_DATA_SIZE)), 8);
- efuse_PgPacketWrite(dev,offset,word_en,tmpdata);
-
-
- }
-
- // For warm reboot, we must resume Efuse clock to 500K.
- efuse_PowerSwitch(dev, FALSE);
-
-}
-#endif
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_PgPacketRead
- *
- * Overview: Receive dedicated Efuse are content. For92s, we support 16
- * area now. It will return 8 bytes content for every area.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/16/2008 MHC Reorganize code Arch and assign as local API.
- *
- *---------------------------------------------------------------------------*/
-static u8
-efuse_PgPacketRead( struct net_device* dev, u8 offset, u8 *data)
-{
- u8 ReadState = PG_STATE_HEADER;
-
- bool bContinual = TRUE;
- bool bDataEmpty = TRUE ;
-
- u8 efuse_data,word_cnts=0;
- u16 efuse_addr = 0;
- u8 hoffset=0,hworden=0;
- u8 tmpidx=0;
- u8 tmpdata[8];
-
- if(data==NULL) return FALSE;
- if(offset>15) return FALSE;
-
- memset(data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE);
- memset(tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE);
-
- while(bContinual && (efuse_addr < EFUSE_MAX_SIZE) )
- {
- //------- Header Read -------------
- if(ReadState & PG_STATE_HEADER)
- {
- if(efuse_OneByteRead(dev, efuse_addr ,&efuse_data)&&(efuse_data!=0xFF)){
- hoffset = (efuse_data>>4) & 0x0F;
- hworden = efuse_data & 0x0F;
- word_cnts = efuse_CalculateWordCnts(hworden);
- bDataEmpty = TRUE ;
-
- if(hoffset==offset){
- for(tmpidx = 0;tmpidx< word_cnts*2 ;tmpidx++){
- if(efuse_OneByteRead(dev, efuse_addr+1+tmpidx ,&efuse_data) ){
- tmpdata[tmpidx] = efuse_data;
- if(efuse_data!=0xff){
- bDataEmpty = FALSE;
- }
- }
- }
- if(bDataEmpty==FALSE){
- ReadState = PG_STATE_DATA;
- }else{//read next header
- efuse_addr = efuse_addr + (word_cnts*2)+1;
- ReadState = PG_STATE_HEADER;
- }
- }
- else{//read next header
- efuse_addr = efuse_addr + (word_cnts*2)+1;
- ReadState = PG_STATE_HEADER;
- }
-
- }
- else{
- bContinual = FALSE ;
- }
- }
- //------- Data section Read -------------
- else if(ReadState & PG_STATE_DATA)
- {
- efuse_WordEnableDataRead(hworden,tmpdata,data);
- efuse_addr = efuse_addr + (word_cnts*2)+1;
- ReadState = PG_STATE_HEADER;
- }
-
- }
-
- if( (data[0]==0xff) &&(data[1]==0xff) && (data[2]==0xff) && (data[3]==0xff) &&
- (data[4]==0xff) &&(data[5]==0xff) && (data[6]==0xff) && (data[7]==0xff))
- return FALSE;
- else
- return TRUE;
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_PgPacketWrite
- *
- * Overview: Send A G package for different section in real efuse area.
- * For 92S, One PG package contain 8 bytes content and 4 word
- * unit. PG header = 0x[bit7-4=offset][bit3-0word enable]
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/16/2008 MHC Reorganize code Arch and assign as local API.
- *
- *---------------------------------------------------------------------------*/
-static u32 efuse_PgPacketWrite(struct net_device* dev, u8 offset, u8 word_en,u8 *data)
-{
- u8 WriteState = PG_STATE_HEADER;
-
- bool bContinual = TRUE,bDataEmpty=TRUE, bResult = TRUE;
- u16 efuse_addr = 0;
- u8 efuse_data;
-
- u8 pg_header = 0;
-
- u8 tmp_word_cnts=0,target_word_cnts=0;
- u8 tmp_header,match_word_en,tmp_word_en;
-
- PGPKT_STRUCT target_pkt;
- PGPKT_STRUCT tmp_pkt;
-
- u8 originaldata[sizeof(u8)*8];
- u8 tmpindex = 0,badworden = 0x0F;
-
- static u32 repeat_times = 0;
-
- if( efuse_GetCurrentSize(dev) >= EFUSE_MAX_SIZE)
- {
- printk("efuse_PgPacketWrite error \n");
- return FALSE;
- }
-
- // Init the 8 bytes content as 0xff
- target_pkt.offset = offset;
- target_pkt.word_en= word_en;
-
- //PlatformFillMemory((PVOID)target_pkt.data, sizeof(u8)*8, 0xFF);
- memset(target_pkt.data,0xFF,sizeof(u8)*8);
-
- efuse_WordEnableDataRead(word_en,data,target_pkt.data);
- target_word_cnts = efuse_CalculateWordCnts(target_pkt.word_en);
-
- printk("EFUSE Power ON\n");
-
- while( bContinual && (efuse_addr < EFUSE_MAX_SIZE) )
- {
-
- if(WriteState==PG_STATE_HEADER)
- {
- bDataEmpty=TRUE;
- badworden = 0x0F;
- //************ so *******************
- printk("EFUSE PG_STATE_HEADER\n");
- if ( efuse_OneByteRead(dev, efuse_addr ,&efuse_data) &&
- (efuse_data!=0xFF))
- {
- tmp_header = efuse_data;
-
- tmp_pkt.offset = (tmp_header>>4) & 0x0F;
- tmp_pkt.word_en = tmp_header & 0x0F;
- tmp_word_cnts = efuse_CalculateWordCnts(tmp_pkt.word_en);
-
- //************ so-1 *******************
- if(tmp_pkt.offset != target_pkt.offset)
- {
- efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState = PG_STATE_HEADER;
- #endif
- }
- else
- {
- //************ so-2 *******************
- for(tmpindex=0 ; tmpindex<(tmp_word_cnts*2) ; tmpindex++)
- {
- if(efuse_OneByteRead(dev, (efuse_addr+1+tmpindex) ,&efuse_data)&&(efuse_data != 0xFF)){
- bDataEmpty = FALSE;
- }
- }
- //************ so-2-1 *******************
- if(bDataEmpty == FALSE)
- {
- efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState=PG_STATE_HEADER;
- #endif
- }
- else
- {//************ so-2-2 *******************
- match_word_en = 0x0F;
- if( !( (target_pkt.word_en&BIT0)|(tmp_pkt.word_en&BIT0) ))
- {
- match_word_en &= (~BIT0);
- }
- if( !( (target_pkt.word_en&BIT1)|(tmp_pkt.word_en&BIT1) ))
- {
- match_word_en &= (~BIT1);
- }
- if( !( (target_pkt.word_en&BIT2)|(tmp_pkt.word_en&BIT2) ))
- {
- match_word_en &= (~BIT2);
- }
- if( !( (target_pkt.word_en&BIT3)|(tmp_pkt.word_en&BIT3) ))
- {
- match_word_en &= (~BIT3);
- }
-
- //************ so-2-2-A *******************
- if((match_word_en&0x0F)!=0x0F)
- {
- badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1, tmp_pkt.word_en ,target_pkt.data);
-
- //************ so-2-2-A-1 *******************
- if(0x0F != (badworden&0x0F))
- {
- u8 reorg_offset = offset;
- u8 reorg_worden=badworden;
- efuse_PgPacketWrite(dev,reorg_offset,reorg_worden,originaldata);
- }
-
- tmp_word_en = 0x0F;
- if( (target_pkt.word_en&BIT0)^(match_word_en&BIT0) )
- {
- tmp_word_en &= (~BIT0);
- }
- if( (target_pkt.word_en&BIT1)^(match_word_en&BIT1) )
- {
- tmp_word_en &= (~BIT1);
- }
- if( (target_pkt.word_en&BIT2)^(match_word_en&BIT2) )
- {
- tmp_word_en &= (~BIT2);
- }
- if( (target_pkt.word_en&BIT3)^(match_word_en&BIT3) )
- {
- tmp_word_en &=(~BIT3);
- }
-
- //************ so-2-2-A-2 *******************
- if((tmp_word_en&0x0F)!=0x0F){
- //reorganize other pg packet
-
- efuse_addr = efuse_GetCurrentSize(dev);
-
- target_pkt.offset = offset;
- target_pkt.word_en= tmp_word_en;
-
- }else{
- bContinual = FALSE;
- }
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState=PG_STATE_HEADER;
- repeat_times++;
- if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
- bContinual = FALSE;
- bResult = FALSE;
- }
- #endif
- }
- else{//************ so-2-2-B *******************
- //reorganize other pg packet
- efuse_addr = efuse_addr + (2*tmp_word_cnts) +1;//next pg packet addr
- target_pkt.offset = offset;
- target_pkt.word_en= target_pkt.word_en;
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState=PG_STATE_HEADER;
- #endif
- }
- }
- }
- printk("EFUSE PG_STATE_HEADER-1\n");
- }
- else //************ s1: header == oxff *******************
- {
- pg_header = ((target_pkt.offset << 4)&0xf0) |target_pkt.word_en;
-
- efuse_OneByteWrite(dev,efuse_addr, pg_header);
- efuse_OneByteRead(dev,efuse_addr, &tmp_header);
-
- if(tmp_header == pg_header)
- { //************ s1-1*******************
- WriteState = PG_STATE_DATA;
- }
- #if (EFUSE_ERROE_HANDLE == 1)
- else if(tmp_header == 0xFF){//************ s1-3: if Write or read func doesn't work *******************
- //efuse_addr doesn't change
- WriteState = PG_STATE_HEADER;
- repeat_times++;
- if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
- bContinual = FALSE;
- bResult = FALSE;
- }
- }
- #endif
- else
- {//************ s1-2 : fixed the header procedure *******************
- tmp_pkt.offset = (tmp_header>>4) & 0x0F;
- tmp_pkt.word_en= tmp_header & 0x0F;
- tmp_word_cnts = efuse_CalculateWordCnts(tmp_pkt.word_en);
-
- //************ s1-2-A :cover the exist data *******************
- memset(originaldata,0xff,sizeof(u8)*8);
-
- if(efuse_PgPacketRead( dev, tmp_pkt.offset,originaldata))
- { //check if data exist
- badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1,tmp_pkt.word_en,originaldata);
- if(0x0F != (badworden&0x0F))
- {
- u8 reorg_offset = tmp_pkt.offset;
- u8 reorg_worden=badworden;
- efuse_PgPacketWrite(dev,reorg_offset,reorg_worden,originaldata);
- efuse_addr = efuse_GetCurrentSize(dev);
- }
- else{
- efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
- }
- }
- //************ s1-2-B: wrong address*******************
- else
- {
- efuse_addr = efuse_addr + (tmp_word_cnts*2) +1; //Next pg_packet
- }
-
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState=PG_STATE_HEADER;
- repeat_times++;
- if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
- bContinual = FALSE;
- bResult = FALSE;
- }
- #endif
-
- printk("EFUSE PG_STATE_HEADER-2\n");
- }
-
- }
-
- }
- //write data state
- else if(WriteState==PG_STATE_DATA)
- { //************ s1-1 *******************
- printk("EFUSE PG_STATE_DATA\n");
- badworden = 0x0f;
- badworden = efuse_WordEnableDataWrite(dev,efuse_addr+1,target_pkt.word_en,target_pkt.data);
- if((badworden&0x0F)==0x0F)
- { //************ s1-1-A *******************
- bContinual = FALSE;
- }
- else
- {//reorganize other pg packet //************ s1-1-B *******************
- efuse_addr = efuse_addr + (2*target_word_cnts) +1;//next pg packet addr
-
- target_pkt.offset = offset;
- target_pkt.word_en= badworden;
- target_word_cnts = efuse_CalculateWordCnts(target_pkt.word_en);
- #if (EFUSE_ERROE_HANDLE == 1)
- WriteState=PG_STATE_HEADER;
- repeat_times++;
- if(repeat_times>EFUSE_REPEAT_THRESHOLD_){
- bContinual = FALSE;
- bResult = FALSE;
- }
- #endif
- printk("EFUSE PG_STATE_HEADER-3\n");
- }
- }
- }
-
- if(efuse_addr >= (EFUSE_MAX_SIZE-EFUSE_OOB_PROTECT_BYTES))
- {
- RT_TRACE(COMP_EPROM, "efuse_PgPacketWrite(): efuse_addr(%x) Out of size!!\n", efuse_addr);
- }
- return TRUE;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_WordEnableDataRead
- *
- * Overview: Read allowed word in current efuse section data.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/16/2008 MHC Create Version 0.
- * 11/21/2008 MHC Fix Write bug when we only enable late word.
- *
- *---------------------------------------------------------------------------*/
-static void
-efuse_WordEnableDataRead( u8 word_en,u8 *sourdata,u8 *targetdata)
-{
-
- if (!(word_en&BIT0))
- {
- targetdata[0] = sourdata[0];//sourdata[tmpindex++];
- targetdata[1] = sourdata[1];//sourdata[tmpindex++];
- }
- if (!(word_en&BIT1))
- {
- targetdata[2] = sourdata[2];//sourdata[tmpindex++];
- targetdata[3] = sourdata[3];//sourdata[tmpindex++];
- }
- if (!(word_en&BIT2))
- {
- targetdata[4] = sourdata[4];//sourdata[tmpindex++];
- targetdata[5] = sourdata[5];//sourdata[tmpindex++];
- }
- if (!(word_en&BIT3))
- {
- targetdata[6] = sourdata[6];//sourdata[tmpindex++];
- targetdata[7] = sourdata[7];//sourdata[tmpindex++];
- }
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_WordEnableDataWrite
- *
- * Overview: Write necessary word unit into current efuse section!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/16/2008 MHC Reorganize Efuse operate flow!!.
- *
- *---------------------------------------------------------------------------*/
-static u8
-efuse_WordEnableDataWrite( struct net_device* dev, u16 efuse_addr, u8 word_en, u8 *data)
-{
- u16 tmpaddr = 0;
- u16 start_addr = efuse_addr;
- u8 badworden = 0x0F;
- u8 tmpdata[8];
-
- memset(tmpdata,0xff,PGPKT_DATA_SIZE);
-
- if(!(word_en&BIT0))
- {
- tmpaddr = start_addr;
- efuse_OneByteWrite(dev,start_addr++, data[0]);
- efuse_OneByteWrite(dev,start_addr++, data[1]);
-
- efuse_OneByteRead(dev,tmpaddr, &tmpdata[0]);
- efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[1]);
- if((data[0]!=tmpdata[0])||(data[1]!=tmpdata[1])){
- badworden &= (~BIT0);
- }
- }
- if(!(word_en&BIT1))
- {
- tmpaddr = start_addr;
- efuse_OneByteWrite(dev,start_addr++, data[2]);
- efuse_OneByteWrite(dev,start_addr++, data[3]);
-
- efuse_OneByteRead(dev,tmpaddr , &tmpdata[2]);
- efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[3]);
- if((data[2]!=tmpdata[2])||(data[3]!=tmpdata[3])){
- badworden &=( ~BIT1);
- }
- }
- if(!(word_en&BIT2))
- {
- tmpaddr = start_addr;
- efuse_OneByteWrite(dev,start_addr++, data[4]);
- efuse_OneByteWrite(dev,start_addr++, data[5]);
-
- efuse_OneByteRead(dev,tmpaddr, &tmpdata[4]);
- efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[5]);
- if((data[4]!=tmpdata[4])||(data[5]!=tmpdata[5])){
- badworden &=( ~BIT2);
- }
- }
- if(!(word_en&BIT3))
- {
- tmpaddr = start_addr;
- efuse_OneByteWrite(dev,start_addr++, data[6]);
- efuse_OneByteWrite(dev,start_addr++, data[7]);
-
- efuse_OneByteRead(dev,tmpaddr, &tmpdata[6]);
- efuse_OneByteRead(dev,tmpaddr+1, &tmpdata[7]);
- if((data[6]!=tmpdata[6])||(data[7]!=tmpdata[7])){
- badworden &=( ~BIT3);
- }
- }
- return badworden;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_PowerSwitch
- *
- * Overview: When we want to enable write operation, we should change to
- * pwr on state. When we stop write, we should switch to 500k mode
- * and disable LDO 2.5V.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/17/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void
-efuse_PowerSwitch(struct net_device* dev, u8 PwrState)
-{
- u8 tempval;
- if (PwrState == TRUE)
- {
- // Enable LDO 2.5V for write action
- tempval = read_nic_byte(dev, EFUSE_TEST+3);
- write_nic_byte(dev, EFUSE_TEST+3, (tempval | 0x80));
-
- // Change Efuse Clock for write action to 40MHZ
- write_nic_byte(dev, EFUSE_CLK, 0x03);
- }
- else
- {
- // Enable LDO 2.5V for write action
- tempval = read_nic_byte(dev, EFUSE_TEST+3);
- write_nic_byte(dev, EFUSE_TEST+3, (tempval & 0x7F));
-
- // Change Efuse Clock for write action to 500K
- write_nic_byte(dev, EFUSE_CLK, 0x02);
- }
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_GetCurrentSize
- *
- * Overview: Get current efuse size!!!
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/16/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static u16
-efuse_GetCurrentSize(struct net_device* dev)
-{
- bool bContinual = TRUE;
-
- u16 efuse_addr = 0;
- u8 hoffset=0,hworden=0;
- u8 efuse_data,word_cnts=0;
-
- while ( bContinual &&
- efuse_OneByteRead(dev, efuse_addr ,&efuse_data) &&
- (efuse_addr < EFUSE_MAX_SIZE) )
- {
- if(efuse_data!=0xFF)
- {
- hoffset = (efuse_data>>4) & 0x0F;
- hworden = efuse_data & 0x0F;
- word_cnts = efuse_CalculateWordCnts(hworden);
- //read next header
- efuse_addr = efuse_addr + (word_cnts*2)+1;
- }
- else
- {
- bContinual = FALSE ;
- }
- }
-
- return efuse_addr;
-
-}
-
-/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */
-static u8
-efuse_CalculateWordCnts(u8 word_en)
-{
- u8 word_cnts = 0;
- if(!(word_en & BIT0)) word_cnts++; // 0 : write enable
- if(!(word_en & BIT1)) word_cnts++;
- if(!(word_en & BIT2)) word_cnts++;
- if(!(word_en & BIT3)) word_cnts++;
- return word_cnts;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: EFUSE_ProgramMap
- *
- * Overview: Read EFUSE map file and execute PG.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/10/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
- #ifdef TO_DO_LIST
-extern bool // 0=Shadow 1=Real Efuse
-EFUSE_ProgramMap(struct net_device* dev, char* pFileName,u8 TableType)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- s4Byte nLinesRead, ithLine;
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
- char* szLine;
- u32 u4bRegValue, u4RegMask;
- u32 u4bMove;
- u16 index = 0;
- u16 i;
- u8 eeprom[HWSET_MAX_SIZE_92S];
-
- rtStatus = PlatformReadFile(
- dev,
- pFileName,
- (u8*)(priv->BufOfLines),
- MAX_LINES_HWCONFIG_TXT,
- MAX_BYTES_LINE_HWCONFIG_TXT,
- &nLinesRead
- );
-
- if(rtStatus == RT_STATUS_SUCCESS)
- {
- memcp(pHalData->BufOfLines3, pHalData->BufOfLines,
- nLinesRead*MAX_BYTES_LINE_HWCONFIG_TXT);
- pHalData->nLinesRead3 = nLinesRead;
- }
-
- if(rtStatus == RT_STATUS_SUCCESS)
- {
- printk("szEepromFile(): read %s ok\n", pFileName);
- for(ithLine = 0; ithLine < nLinesRead; ithLine++)
- {
- szLine = pHalData->BufOfLines[ithLine];
- printk("Line-%d String =%s\n", ithLine, szLine);
-
- if(!IsCommentString(szLine))
- {
- // EEPROM map one line has 8 words content.
- for (i = 0; i < 8; i++)
- {
- u32 j;
-
- efuse_ParsingMap(szLine, &u4bRegValue, &u4bMove);
-
- // Get next hex value as EEPROM value.
- szLine += u4bMove;
- eeprom[index++] = (u8)(u4bRegValue&0xff);
- eeprom[index++] = (u8)((u4bRegValue>>8)&0xff);
-
- printk("Addr-%d = %x\n", (ithLine*8+i), u4bRegValue);
- }
- }
-
- }
-
- }
- else
- {
- printk("szEepromFile(): Fail read%s\n", pFileName);
- return RT_STATUS_FAILURE;
- }
-
- // Use map file to update real Efuse or shadow modify table.
- if (TableType == 1)
- {
- efuse_WriteAllMap(dev, eeprom, HWSET_MAX_SIZE_92S);
- }
- else
- {
- // Modify shadow table.
- for (i = 0; i < HWSET_MAX_SIZE_92S; i++)
- EFUSE_ShadowWrite(dev, 1, i, (u32)eeprom[i]);
- }
-
- return rtStatus;
-}
-
-#endif
-
-/*-----------------------------------------------------------------------------
- * Function: efuse_ParsingMap
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/08/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-#ifdef TO_DO_LIST
-static bool
-efuse_ParsingMap(char* szStr,u32* pu4bVal,u32* pu4bMove)
-{
- char* szScan = szStr;
-
- // Check input parameter.
- if(szStr == NULL || pu4bVal == NULL || pu4bMove == NULL)
- {
- return FALSE;
- }
-
- // Initialize output.
- *pu4bMove = 0;
- *pu4bVal = 0;
-
- // Skip leading space.
- while( *szScan != '\0' &&
- (*szScan == ' ' || *szScan == '\t') )
- {
- szScan++;
- (*pu4bMove)++;
- }
-
- // Check if szScan is now pointer to a character for hex digit,
- // if not, it means this is not a valid hex number.
- if (!isxdigit(*szScan))
- return FALSE;
-
- // Parse each digit.
- do
- {
- *pu4bVal = (*pu4bVal << 4) + hex_to_bin(*szScan);
-
- szScan++;
- (*pu4bMove)++;
- } while (isxdigit(*szScan));
-
- return TRUE;
-
-}
-#endif
-
-int efuse_one_byte_rw(struct net_device* dev, u8 bRead, u16 addr, u8 *data)
-{
- u32 bResult;
- u8 tmpidx = 0;
- u8 tmpv8=0;
-
- // -----------------e-fuse reg ctrl ---------------------------------
-
- write_nic_byte(dev, EFUSE_CTRL+1, (u8)(addr&0xff)); //address
- tmpv8 = ((u8)((addr>>8) &0x03) ) | (read_nic_byte(dev, EFUSE_CTRL+2)&0xFC );
- write_nic_byte(dev, EFUSE_CTRL+2, tmpv8);
-
- if(TRUE==bRead){
-
- write_nic_byte(dev, EFUSE_CTRL+3, 0x72);//read cmd
-
- while(!(0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
- tmpidx++;
- }
- if(tmpidx<100){
- *data=read_nic_byte(dev, EFUSE_CTRL);
- bResult = TRUE;
- }
- else
- {
- *data = 0;
- bResult = FALSE;
- }
-
- }
- else{
- write_nic_byte(dev, EFUSE_CTRL, *data);//data
-
- write_nic_byte(dev, EFUSE_CTRL+3, 0xF2);//write cmd
-
- while((0x80 & read_nic_byte(dev, EFUSE_CTRL+3)) && (tmpidx<100) ){
- tmpidx++;
- }
- if(tmpidx<100)
- {
- *data=read_nic_byte(dev, EFUSE_CTRL);
- bResult = TRUE;
- }
- else
- {
- *data = 0;
- bResult = FALSE;
- }
-
- }
- return bResult;
-}
-
-void efuse_access(struct net_device* dev, u8 bRead,u16 start_addr, u8 cnts, u8 *data)
-{
- u8 efuse_clk_ori,efuse_clk_new;//,tmp8;
- u32 i = 0;
-
- if(start_addr>0x200) return;
- // -----------------SYS_FUNC_EN Digital Core Vdd enable ---------------------------------
- efuse_clk_ori = read_nic_byte(dev,SYS_FUNC_EN+1);
- efuse_clk_new = efuse_clk_ori|0x20;
-
- if(efuse_clk_new!= efuse_clk_ori){
- write_nic_byte(dev, SYS_FUNC_EN+1, efuse_clk_new);
- }
-#ifdef _POWERON_DELAY_
- mdelay(10);
-#endif
- // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
- write_nic_byte(dev, EFUSE_TEST+3, (read_nic_byte(dev, EFUSE_TEST+3)|0x80));
- write_nic_byte(dev, EFUSE_CLK_CTRL, (read_nic_byte(dev, EFUSE_CLK_CTRL)|0x03));
-
-#ifdef _PRE_EXECUTE_READ_CMD_
- {
- unsigned char tmpdata;
- efuse_OneByteRead(dev, 0,&tmpdata);
- }
-#endif
-
- //-----------------e-fuse one byte read / write ------------------------------
- for(i=0;i<cnts;i++){
- efuse_one_byte_rw(dev,bRead, start_addr+i , data+i);
-
- }
- write_nic_byte(dev, EFUSE_TEST+3, read_nic_byte(dev, EFUSE_TEST+3)&0x7f);
- write_nic_byte(dev, EFUSE_CLK_CTRL, read_nic_byte(dev, EFUSE_CLK_CTRL)&0xfd);
-
- // -----------------SYS_FUNC_EN Digital Core Vdd disable ---------------------------------
- if(efuse_clk_new != efuse_clk_ori) write_nic_byte(dev, 0x10250003, efuse_clk_ori);
-
-}
-
-#ifdef TO_DO_LIST
-static void efuse_reg_ctrl(struct net_device* dev, u8 bPowerOn)
-{
- if(TRUE==bPowerOn){
- // -----------------SYS_FUNC_EN Digital Core Vdd enable ---------------------------------
- write_nic_byte(dev, SYS_FUNC_EN+1, read_nic_byte(dev,SYS_FUNC_EN+1)|0x20);
-#ifdef _POWERON_DELAY_
- mdelay(10);
-#endif
- // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
- write_nic_byte(dev, EFUSE_TEST+4, (read_nic_byte(dev, EFUSE_TEST+4)|0x80));
- write_nic_byte(dev, EFUSE_CLK_CTRL, (read_nic_byte(dev, EFUSE_CLK_CTRL)|0x03));
-#ifdef _PRE_EXECUTE_READ_CMD_
- {
- unsigned char tmpdata;
- efuse_OneByteRead(dev, 0,&tmpdata);
- }
-
-#endif
- }
- else{
- // -----------------e-fuse pwr & clk reg ctrl ---------------------------------
- write_nic_byte(dev, EFUSE_TEST+4, read_nic_byte(dev, EFUSE_TEST+4)&0x7f);
- write_nic_byte(dev, EFUSE_CLK_CTRL, read_nic_byte(dev, EFUSE_CLK_CTRL)&0xfd);
- // -----------------SYS_FUNC_EN Digital Core Vdd disable ---------------------------------
-
- }
-
-
-}
-#endif
-
-void efuse_read_data(struct net_device* dev,u8 efuse_read_item,u8 *data,u32 data_size)
-{
- u8 offset, word_start,byte_start,byte_cnts;
- u8 efusedata[EFUSE_MAC_LEN];
- u8 *tmpdata = NULL;
-
- u8 pg_pkt_cnts ;
-
- u8 tmpidx;
- u8 pg_data[8];
-
- if(efuse_read_item> (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
- return ;
- }
-
- offset = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].offset ;
- word_start = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].word_start;
- byte_start = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].byte_start;
- byte_cnts = RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].byte_cnts;
-
- if(data_size!=byte_cnts){
- return;
- }
-
- pg_pkt_cnts = (byte_cnts /PGPKT_DATA_SIZE) +1;
-
- if(pg_pkt_cnts > 1){
- tmpdata = efusedata;
-
- if(tmpdata!=NULL)
- {
- memset(tmpdata,0xff,pg_pkt_cnts*PGPKT_DATA_SIZE);
-
- for(tmpidx=0;tmpidx<pg_pkt_cnts;tmpidx++)
- {
- memset(pg_data,0xff,PGPKT_DATA_SIZE);
- if(TRUE== efuse_PgPacketRead(dev,offset+tmpidx,pg_data))
- {
- memcpy(tmpdata+(PGPKT_DATA_SIZE*tmpidx),pg_data,PGPKT_DATA_SIZE);
- }
- }
- memcpy(data,(tmpdata+ (2*word_start)+byte_start ),data_size);
- }
- }
- else
- {
- memset(pg_data,0xff,PGPKT_DATA_SIZE);
- if(TRUE==efuse_PgPacketRead(dev,offset,pg_data)){
- memcpy(data,pg_data+ (2*word_start)+byte_start ,data_size);
- }
- }
-
-}
-
-//per interface doesn't alike
-void efuse_write_data(struct net_device* dev,u8 efuse_write_item,u8 *data,u32 data_size,u32 bWordUnit)
-{
- u8 offset, word_start,byte_start,byte_cnts;
- u8 word_en = 0x0f,word_cnts;
- u8 pg_pkt_cnts ;
-
- u8 tmpidx,tmpbitmask;
- u8 pg_data[8],tmpbytes=0;
-
- if(efuse_write_item> (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
- return ;
- }
-
- offset = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].offset ;
- word_start = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].word_start;
- byte_start = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].byte_start;
- byte_cnts = RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].byte_cnts;
-
- if(data_size > byte_cnts){
- return;
- }
- pg_pkt_cnts = (byte_cnts /PGPKT_DATA_SIZE) +1;
- word_cnts = byte_cnts /2 ;
-
- if(byte_cnts %2){
- word_cnts+=1;
- }
- if((byte_start==1)||((byte_cnts%2)==1)){//situation A
-
- if((efuse_write_item==EFUSE_F0CIS)||(efuse_write_item==EFUSE_F1CIS)){
- memset(pg_data,0xff,PGPKT_DATA_SIZE);
- efuse_PgPacketRead(dev,offset,pg_data);
-
- if(efuse_write_item==EFUSE_F0CIS){
- word_en = 0x07;
- memcpy(pg_data+word_start*2+byte_start,data,sizeof(u8)*2);
- efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
-
- word_en = 0x00;
- efuse_PgPacketWrite(dev,(offset+1),word_en,data+2);
-
- word_en = 0x00;
- efuse_PgPacketRead(dev,offset+2,pg_data);
- memcpy(pg_data,data+2+8,sizeof(u8)*7);
-
- efuse_PgPacketWrite(dev,(offset+2),word_en,pg_data);
- }
- else if(efuse_write_item==EFUSE_F1CIS){
- word_en = 0x07;
- efuse_PgPacketRead(dev,offset,pg_data);
- pg_data[7] = data[0];
- efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
-
- word_en = 0x00;
- for(tmpidx = 0 ;tmpidx<(word_cnts/4);tmpidx++){
- efuse_PgPacketWrite(dev,(offset+1+tmpidx),word_en,data+1+(tmpidx*PGPKT_DATA_SIZE));
- }
- }
-
- }
- else{
- memset(pg_data,0xff,PGPKT_DATA_SIZE);
- if((efuse_write_item==EFUSE_SDIO_SETTING)||(efuse_write_item==EFUSE_CCCR)){
- word_en = 0x0e ;
- tmpbytes = 2;
- }
- else if(efuse_write_item == EFUSE_SDIO_MODE){
- word_en = 0x0d ;
- tmpbytes = 2;
- }
- else if(efuse_write_item == EFUSE_OCR){
- word_en = 0x09 ;
- tmpbytes = 4;
- }
- else if((efuse_write_item == EFUSE_EEPROM_VER)||(efuse_write_item==EFUSE_CHAN_PLAN)){
- word_en = 0x07 ;
- tmpbytes = 2;
- }
- if(bWordUnit==TRUE){
- memcpy(pg_data+word_start*2 ,data,sizeof(u8)*tmpbytes);
- }
- else{
- efuse_PgPacketRead(dev,offset,pg_data);
- memcpy(pg_data+(2*word_start)+byte_start,data,sizeof(u8)*byte_cnts);
- }
-
- efuse_PgPacketWrite(dev,offset,word_en,pg_data+(word_start*2));
-
- }
-
- }
- else if(pg_pkt_cnts>1){//situation B
- if(word_start==0){
- word_en = 0x00;
- for(tmpidx = 0 ;tmpidx<(word_cnts/4);tmpidx++)
- {
- efuse_PgPacketWrite(dev,(offset+tmpidx),word_en,data+(tmpidx*PGPKT_DATA_SIZE));
- }
- word_en = 0x0f;
- for(tmpidx= 0; tmpidx<(word_cnts%4) ; tmpidx++)
- {
- tmpbitmask =tmpidx;
- word_en &= (~(EFUSE_BIT(tmpbitmask)));
- //BIT0
- }
- efuse_PgPacketWrite(dev,offset+(word_cnts/4),word_en,data+((word_cnts/4)*PGPKT_DATA_SIZE));
- }else
- {
-
- }
- }
- else{//situation C
- word_en = 0x0f;
- for(tmpidx= 0; tmpidx<word_cnts ; tmpidx++)
- {
- tmpbitmask = word_start + tmpidx ;
- word_en &= (~(EFUSE_BIT(tmpbitmask)));
- }
- efuse_PgPacketWrite(dev,offset,word_en,data);
- }
-
-}
-
-void efuset_test_func_read(struct net_device* dev)
-{
- u8 chipid[2];
- u8 ocr[3];
- u8 macaddr[6];
- u8 txpowertable[28];
-
- memset(chipid,0,sizeof(u8)*2);
- efuse_read_data(dev,EFUSE_CHIP_ID,chipid,sizeof(chipid));
-
- memset(ocr,0,sizeof(u8)*3);
- efuse_read_data(dev,EFUSE_CCCR,ocr,sizeof(ocr));
-
- memset(macaddr,0,sizeof(u8)*6);
- efuse_read_data(dev,EFUSE_MAC_ADDR,macaddr,sizeof(macaddr));
-
- memset(txpowertable,0,sizeof(u8)*28);
- efuse_read_data(dev,EFUSE_TXPW_TAB,txpowertable,sizeof(txpowertable));
-}
-
-void efuset_test_func_write(struct net_device* dev)
-{
- u32 bWordUnit = TRUE;
- u8 CCCR=0x02,SDIO_SETTING = 0xFF;
- u8 tmpdata[2];
-
- u8 macaddr[6] = {0x00,0xe0,0x4c,0x87,0x12,0x66};
- efuse_write_data(dev,EFUSE_MAC_ADDR,macaddr,sizeof(macaddr),bWordUnit);
-
- bWordUnit = FALSE;
- efuse_write_data(dev,EFUSE_CCCR,&CCCR,sizeof(u8),bWordUnit);
-
- bWordUnit = FALSE;
- efuse_write_data(dev,EFUSE_SDIO_SETTING,&SDIO_SETTING,sizeof(u8),bWordUnit);
-
- bWordUnit = TRUE;
- tmpdata[0] =SDIO_SETTING ;
- tmpdata[1] =CCCR ;
- efuse_write_data(dev,EFUSE_SDIO_SETTING,tmpdata,sizeof(tmpdata),bWordUnit);
-
-}
diff --git a/drivers/staging/rtl8192su/r8192S_Efuse.h b/drivers/staging/rtl8192su/r8192S_Efuse.h
deleted file mode 100644
index c48a11bc06fe..000000000000
--- a/drivers/staging/rtl8192su/r8192S_Efuse.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * Based on the r8180 driver, which is:
- * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-#ifndef __INC_EFUSE_H
-#define __INC_EFUSE_H
-
-#define EFUSE_FOR_92SU 1
-
-#define EFUSE_MAC_LEN 0x200
-#define EFUSE_REAL_CONTENT_LEN 512
-#define EFUSE_MAP_LEN 128
-#define EFUSE_MAX_SECTION 16
-#define EFUSE_MAX_WORD_UNIT 4
-
-#define EFUSE_INIT_MAP 0
-#define EFUSE_MODIFY_MAP 1
-
-#define EFUSE_CLK_CTRL EFUSE_CTRL
-#define EFUSE_BIT(x) (1 << (x))
-
-#define PG_STATE_HEADER 0x01
-#define PG_STATE_WORD_0 0x02
-#define PG_STATE_WORD_1 0x04
-#define PG_STATE_WORD_2 0x08
-#define PG_STATE_WORD_3 0x10
-#define PG_STATE_DATA 0x20
-
-#define PG_SWBYTE_H 0x01
-#define PG_SWBYTE_L 0x02
-
-extern void
-EFUSE_Initialize(struct net_device* dev);
-extern u8
-EFUSE_Read1Byte(struct net_device* dev,u16 Address);
-extern void
-EFUSE_Write1Byte(struct net_device* dev,u16 Address,u8 Value);
-
-#ifdef EFUSE_FOR_92SU
-extern void
-ReadEFuse(struct net_device* dev,u16 _offset,u16 _size_byte,u8* pbuf);
-extern void
-ReadEFuseByte(struct net_device* dev,u16 _offset,u8 *pbuf);
-#endif
-
-extern void
-EFUSE_ShadowRead(struct net_device* dev,unsigned char Type,unsigned short Offset,u32 *Value);
-extern void
-EFUSE_ShadowWrite(struct net_device* dev,unsigned char Type,unsigned short Offset,u32 Value);
-extern bool
-EFUSE_ShadowUpdate(struct net_device* dev);
-extern void
-EFUSE_ShadowMapUpdate(struct net_device* dev);
-
-extern bool
-EFUSE_ProgramMap(struct net_device* dev,char* pFileName, u8 TableType); // 0=Shadow 1=Real Efuse
-
-#endif
diff --git a/drivers/staging/rtl8192su/r8192S_firmware.c b/drivers/staging/rtl8192su/r8192S_firmware.c
deleted file mode 100644
index db0d2d5fc61b..000000000000
--- a/drivers/staging/rtl8192su/r8192S_firmware.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-#include "r8192U.h"
-#include "r8192S_firmware.h"
-#include <linux/unistd.h>
-
-#include "r8192S_hw.h"
-#include "r8192SU_HWImg.h"
-
-#include <linux/firmware.h>
-
-#define byte(x,n) ( (x >> (8 * n)) & 0xff )
-
-//
-// Description: This routine will intialize firmware. If any error occurs during the initialization
-// process, the routine shall terminate immediately and return fail.
-//
-// Arguments: The pointer of the adapter
-// Code address (Virtual address, should fill descriptor with physical address)
-// Code size
-// Created by Roger, 2008.04.10.
-//
-bool FirmwareDownloadCode(struct net_device *dev,
- u8 *code_virtual_address,
- u32 buffer_len)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool rt_status = true;
- /* Fragmentation might be required in 90/92 but not in 92S */
- u16 frag_threshold = MAX_FIRMWARE_CODE_SIZE;
- u16 frag_length, frag_offset = 0;
- struct sk_buff *skb;
- unsigned char *seg_ptr;
- cb_desc *tcb_desc;
- u8 bLastIniPkt = 0;
- u16 ExtraDescOffset = 0;
-
- if (buffer_len >= MAX_FIRMWARE_CODE_SIZE - USB_HWDESC_HEADER_LEN) {
- RT_TRACE(COMP_ERR, "(%s): Firmware exceeds"
- " MAX_FIRMWARE_CODE_SIZE\n", __func__);
- goto cmdsend_downloadcode_fail;
- }
- ExtraDescOffset = USB_HWDESC_HEADER_LEN;
- do {
- if((buffer_len-frag_offset) > frag_threshold)
- frag_length = frag_threshold + ExtraDescOffset;
- else {
- frag_length = (u16)(buffer_len -
- frag_offset + ExtraDescOffset);
- bLastIniPkt = 1;
- }
- /*
- * Allocate skb buffer to contain firmware info
- * and tx descriptor info.
- */
- skb = dev_alloc_skb(frag_length);
- if (skb == NULL) {
- RT_TRACE(COMP_ERR, "(%s): unable to alloc skb buffer\n",
- __func__);
- goto cmdsend_downloadcode_fail;
- }
- memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
-
- tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE);
- tcb_desc->queue_index = TXCMD_QUEUE;
- tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT;
- tcb_desc->bLastIniPkt = bLastIniPkt;
-
- skb_reserve(skb, ExtraDescOffset);
-
- seg_ptr = (u8 *)skb_put(skb,
- (u32)(frag_length - ExtraDescOffset));
-
- memcpy(seg_ptr, code_virtual_address + frag_offset,
- (u32)(frag_length-ExtraDescOffset));
-
- tcb_desc->txbuf_size = frag_length;
-
- if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
- (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||
- (priv->ieee80211->queue_stop)) {
- RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n");
- skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
- } else
- priv->ieee80211->softmac_hard_start_xmit(skb, dev);
-
- frag_offset += (frag_length - ExtraDescOffset);
-
- } while (frag_offset < buffer_len);
- return rt_status ;
-
-cmdsend_downloadcode_fail:
- rt_status = false;
- RT_TRACE(COMP_ERR, "(%s): failed\n", __func__);
- return rt_status;
-}
-
-
-bool FirmwareEnableCPU(struct net_device *dev)
-{
- bool rtStatus = true;
- u8 tmpU1b, CPUStatus = 0;
- u16 tmpU2b;
- u32 iCheckTime = 200;
-
- /* Enable CPU. */
- tmpU1b = read_nic_byte(dev, SYS_CLKR);
- /* AFE source */
- write_nic_byte(dev, SYS_CLKR, (tmpU1b|SYS_CPU_CLKSEL));
- tmpU2b = read_nic_word(dev, SYS_FUNC_EN);
- write_nic_word(dev, SYS_FUNC_EN, (tmpU2b|FEN_CPUEN));
- /* Poll IMEM Ready after CPU has refilled. */
- do {
- CPUStatus = read_nic_byte(dev, TCR);
- if (CPUStatus & IMEM_RDY)
- /* success */
- break;
- udelay(100);
- } while (iCheckTime--);
- if (!(CPUStatus & IMEM_RDY)) {
- RT_TRACE(COMP_ERR, "%s(): failed to enable CPU", __func__);
- rtStatus = false;
- }
- return rtStatus;
-}
-
-FIRMWARE_8192S_STATUS
-FirmwareGetNextStatus(FIRMWARE_8192S_STATUS FWCurrentStatus)
-{
- FIRMWARE_8192S_STATUS NextFWStatus = 0;
-
- switch(FWCurrentStatus)
- {
- case FW_STATUS_INIT:
- NextFWStatus = FW_STATUS_LOAD_IMEM;
- break;
-
- case FW_STATUS_LOAD_IMEM:
- NextFWStatus = FW_STATUS_LOAD_EMEM;
- break;
-
- case FW_STATUS_LOAD_EMEM:
- NextFWStatus = FW_STATUS_LOAD_DMEM;
- break;
-
- case FW_STATUS_LOAD_DMEM:
- NextFWStatus = FW_STATUS_READY;
- break;
-
- default:
- RT_TRACE(COMP_ERR,"Invalid FW Status(%#x)!!\n", FWCurrentStatus);
- break;
- }
- return NextFWStatus;
-}
-
-bool FirmwareCheckReady(struct net_device *dev, u8 LoadFWStatus)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool rtStatus = true;
- rt_firmware *pFirmware = priv->pFirmware;
- int PollingCnt = 1000;
- u8 CPUStatus = 0;
- u32 tmpU4b;
-
- pFirmware->FWStatus = (FIRMWARE_8192S_STATUS)LoadFWStatus;
- switch (LoadFWStatus) {
- case FW_STATUS_LOAD_IMEM:
- do { /* Polling IMEM code done. */
- CPUStatus = read_nic_byte(dev, TCR);
- if(CPUStatus& IMEM_CODE_DONE)
- break;
- udelay(5);
- } while (PollingCnt--);
- if (!(CPUStatus & IMEM_CHK_RPT) || PollingCnt <= 0) {
- RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_IMEM FAIL CPU, Status=%x\r\n", CPUStatus);
- goto FirmwareCheckReadyFail;
- }
- break;
- case FW_STATUS_LOAD_EMEM: /* Check Put Code OK and Turn On CPU */
- do { /* Polling EMEM code done. */
- CPUStatus = read_nic_byte(dev, TCR);
- if(CPUStatus& EMEM_CODE_DONE)
- break;
- udelay(5);
- } while (PollingCnt--);
- if (!(CPUStatus & EMEM_CHK_RPT)) {
- RT_TRACE(COMP_ERR, "FW_STATUS_LOAD_EMEM FAIL CPU, Status=%x\r\n", CPUStatus);
- goto FirmwareCheckReadyFail;
- }
- /* Turn On CPU */
- if (FirmwareEnableCPU(dev) != true) {
- RT_TRACE(COMP_ERR, "%s(): failed to enable CPU",
- __func__);
- goto FirmwareCheckReadyFail;
- }
- break;
- case FW_STATUS_LOAD_DMEM:
- do { /* Polling DMEM code done */
- CPUStatus = read_nic_byte(dev, TCR);
- if(CPUStatus& DMEM_CODE_DONE)
- break;
-
- udelay(5);
- } while (PollingCnt--);
-
- if (!(CPUStatus & DMEM_CODE_DONE)) {
- RT_TRACE(COMP_ERR, "Polling DMEM code done fail ! CPUStatus(%#x)\n", CPUStatus);
- goto FirmwareCheckReadyFail;
- }
-
- RT_TRACE(COMP_FIRMWARE, "%s(): DMEM code download success, "
- "CPUStatus(%#x)",
- __func__, CPUStatus);
-
- PollingCnt = 10000; /* Set polling cycle to 10ms. */
-
- do { /* Polling Load Firmware ready */
- CPUStatus = read_nic_byte(dev, TCR);
- if(CPUStatus & FWRDY)
- break;
- udelay(100);
- } while (PollingCnt--);
-
- RT_TRACE(COMP_FIRMWARE, "%s(): polling load firmware ready, "
- "CPUStatus(%x)",
- __func__, CPUStatus);
-
- if ((CPUStatus & LOAD_FW_READY) != LOAD_FW_READY) {
- RT_TRACE(COMP_ERR, "Polling Load Firmware ready failed "
- "CPUStatus(%x)\n", CPUStatus);
- goto FirmwareCheckReadyFail;
- }
- /*
- * USB interface will update
- * reserved followings parameters later
- */
-
- //
- // <Roger_Notes> If right here, we can set TCR/RCR to desired value
- // and config MAC lookback mode to normal mode. 2008.08.28.
- //
- tmpU4b = read_nic_dword(dev,TCR);
- write_nic_dword(dev, TCR, (tmpU4b&(~TCR_ICV)));
-
- tmpU4b = read_nic_dword(dev, RCR);
- write_nic_dword(dev, RCR,
- (tmpU4b|RCR_APPFCS|RCR_APP_ICV|RCR_APP_MIC));
-
- RT_TRACE(COMP_FIRMWARE, "%s(): Current RCR settings(%#x)",
- __func__, tmpU4b);
- // Set to normal mode.
- write_nic_byte(dev, LBKMD_SEL, LBK_NORMAL);
- break;
- default:
- break;
- }
- RT_TRACE(COMP_FIRMWARE, "%s(): LoadFWStatus(%d), success",
- __func__, LoadFWStatus);
- return rtStatus;
-
-FirmwareCheckReadyFail:
- rtStatus = false;
- RT_TRACE(COMP_FIRMWARE, "%s(): LoadFWStatus(%d), failed",
- __func__, LoadFWStatus);
- return rtStatus;
-}
-
-//
-// Description: This routine is to update the RF types in FW header partially.
-//
-// Created by Roger, 2008.12.24.
-//
-u8 FirmwareHeaderMapRfType(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- switch(priv->rf_type)
- {
- case RF_1T1R: return 0x11;
- case RF_1T2R: return 0x12;
- case RF_2T2R: return 0x22;
- case RF_2T2R_GREEN: return 0x92;
- default:
- RT_TRACE(COMP_INIT, "Unknown RF type(%x)\n",priv->rf_type);
- break;
- }
- return 0x22;
-}
-
-
-//
-// Description: This routine is to update the private parts in FW header partially.
-//
-// Created by Roger, 2008.12.18.
-//
-void FirmwareHeaderPriveUpdate(struct net_device *dev, PRT_8192S_FIRMWARE_PRIV pFwPriv)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- // Update USB endpoint number for RQPN settings.
- pFwPriv->usb_ep_num = priv->EEPROMUsbEndPointNumber; // endpoint number: 4, 6 and 11.
- RT_TRACE(COMP_INIT, "FirmwarePriveUpdate(): usb_ep_num(%#x)\n", pFwPriv->usb_ep_num);
-
- // Update RF types for RATR settings.
- pFwPriv->rf_config = FirmwareHeaderMapRfType(dev);
-}
-
-bool FirmwareRequest92S(struct net_device *dev, rt_firmware *pFirmware)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool rtStatus = true;
- const char *pFwImageFileName[1] = {"RTL8192SU/rtl8192sfw.bin"};
- u8 *pucMappedFile = NULL;
- u32 ulInitStep = 0;
- u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE;
- PRT_8192S_FIRMWARE_HDR pFwHdr = NULL;
- u32 file_length = 0;
- int rc;
- const struct firmware *fw_entry;
-
- rc = request_firmware(&fw_entry,
- pFwImageFileName[ulInitStep],
- &priv->udev->dev);
- if (rc < 0)
- goto RequestFirmware_Fail;
-
- if (fw_entry->size > sizeof(pFirmware->szFwTmpBuffer)) {
- RT_TRACE(COMP_ERR, "%s(): image file too large"
- "for container buffer", __func__);
- release_firmware(fw_entry);
- goto RequestFirmware_Fail;
- }
-
- memcpy(pFirmware->szFwTmpBuffer, fw_entry->data, fw_entry->size);
- pFirmware->szFwTmpBufferLen = fw_entry->size;
- release_firmware(fw_entry);
-
- pucMappedFile = pFirmware->szFwTmpBuffer;
- file_length = pFirmware->szFwTmpBufferLen;
-
- /* Retrieve FW header. */
- pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile;
- pFwHdr = pFirmware->pFwHeader;
-
- RT_TRACE(COMP_FIRMWARE, "%s(): signature: %x, version: %x, "
- "size: %x, imemsize: %x, sram size: %x",
- __func__, pFwHdr->Signature, pFwHdr->Version,
- pFwHdr->DMEMSize, pFwHdr->IMG_IMEM_SIZE,
- pFwHdr->IMG_SRAM_SIZE);
-
- pFirmware->FirmwareVersion = byte(pFwHdr->Version , 0);
-
- if ((pFwHdr->IMG_IMEM_SIZE == 0) ||
- (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM))) {
- RT_TRACE(COMP_ERR, "%s(): memory for data image is less than"
- " IMEM requires", __func__);
- goto RequestFirmware_Fail;
- } else {
- pucMappedFile += FwHdrSize;
- /* Retrieve IMEM image. */
- memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE);
- pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE;
- }
-
- if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM)) {
- RT_TRACE(COMP_ERR, "%s(): memory for data image is less than"
- " EMEM requires", __func__);
- goto RequestFirmware_Fail;
- } else {
- pucMappedFile += pFirmware->FwIMEMLen;
- /* Retriecve EMEM image */
- memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE);
- pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE;
- }
- return rtStatus;
-
-RequestFirmware_Fail:
- RT_TRACE(COMP_ERR, "%s(): failed with TCR-Status: %x\n",
- __func__, read_nic_word(dev, TCR));
- rtStatus = false;
- return rtStatus;
-}
-
-bool FirmwareDownload92S(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool rtStatus = true;
- u8 *pucMappedFile = NULL;
- u32 ulFileLength;
- u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE;
- rt_firmware *pFirmware = priv->pFirmware;
- u8 FwStatus = FW_STATUS_INIT;
- PRT_8192S_FIRMWARE_HDR pFwHdr = NULL;
- PRT_8192S_FIRMWARE_PRIV pFwPriv = NULL;
-
- pFirmware->FWStatus = FW_STATUS_INIT;
- /*
- * Load the firmware from RTL8192SU/rtl8192sfw.bin if necessary
- */
- if (pFirmware->szFwTmpBufferLen == 0) {
- if (FirmwareRequest92S(dev, pFirmware) != true)
- goto DownloadFirmware_Fail;
- }
- FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus);
- while (FwStatus != FW_STATUS_READY) {
- /* Image buffer redirection. */
- switch (FwStatus) {
- case FW_STATUS_LOAD_IMEM:
- pucMappedFile = pFirmware->FwIMEM;
- ulFileLength = pFirmware->FwIMEMLen;
- break;
-
- case FW_STATUS_LOAD_EMEM:
- pucMappedFile = pFirmware->FwEMEM;
- ulFileLength = pFirmware->FwEMEMLen;
- break;
-
- case FW_STATUS_LOAD_DMEM:
- /* Partial update the content of private header */
- pFwHdr = pFirmware->pFwHeader;
- pFwPriv = (PRT_8192S_FIRMWARE_PRIV)&pFwHdr->FWPriv;
- FirmwareHeaderPriveUpdate(dev, pFwPriv);
- pucMappedFile = (u8 *)(pFirmware->pFwHeader) +
- RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE;
-
- ulFileLength = FwHdrSize -
- RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE;
- break;
-
- default:
- RT_TRACE(COMP_ERR, "Unexpected Download step!!\n");
- goto DownloadFirmware_Fail;
- break;
- }
-
- /* <2> Download image file */
-
- rtStatus = FirmwareDownloadCode(dev,
- pucMappedFile,
- ulFileLength);
-
- if(rtStatus != true)
- goto DownloadFirmware_Fail;
-
- /* <3> Check whether load FW process is ready */
-
- rtStatus = FirmwareCheckReady(dev, FwStatus);
-
- if(rtStatus != true)
- goto DownloadFirmware_Fail;
-
- FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus);
- }
-
- RT_TRACE(COMP_FIRMWARE, "%s(): Firmware Download Success", __func__);
- return rtStatus;
-
-DownloadFirmware_Fail:
- RT_TRACE(COMP_ERR, "%s(): failed with TCR-Status: %x\n",
- __func__, read_nic_word(dev, TCR));
- rtStatus = false;
- return rtStatus;
-}
-
-MODULE_FIRMWARE("RTL8192SU/rtl8192sfw.bin");
diff --git a/drivers/staging/rtl8192su/r8192S_firmware.h b/drivers/staging/rtl8192su/r8192S_firmware.h
deleted file mode 100644
index 7f268a8de5e8..000000000000
--- a/drivers/staging/rtl8192su/r8192S_firmware.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#ifndef __INC_FIRMWARE_H
-#define __INC_FIRMWARE_H
-
-
-#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
-#define MAX_FIRMWARE_CODE_SIZE 0xFF00 // Firmware Local buffer size.
-#define RTL8190_CPU_START_OFFSET 0x80
-#define RTL8192S_FW_PKT_FRAG_SIZE 0x4000
-#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN)
-
-
-#ifdef RTL8192S
-typedef enum _firmware_init_step{
- FW_INIT_STEP0_IMEM = 0,
- FW_INIT_STEP1_MAIN = 1,
- FW_INIT_STEP2_DATA = 2,
-}firmware_init_step_e;
-#else
-typedef enum _firmware_init_step{
- FW_INIT_STEP0_BOOT = 0,
- FW_INIT_STEP1_MAIN = 1,
- FW_INIT_STEP2_DATA = 2,
-}firmware_init_step_e;
-#endif
-
-/* due to rtl8192 firmware */
-typedef enum _desc_packet_type_e{
- DESC_PACKET_TYPE_INIT = 0,
- DESC_PACKET_TYPE_NORMAL = 1,
-}desc_packet_type_e;
-
-typedef enum _opt_rst_type{
- OPT_SYSTEM_RESET = 0,
- OPT_FIRMWARE_RESET = 1,
-}opt_rst_type_e;
-
-//--------------------------------------------------------------------------------
-// RTL8192S Firmware related
-//--------------------------------------------------------------------------------
-typedef struct _RT_8192S_FIRMWARE_PRIV { //8-bytes alignment required
-
- //--- long word 0 ----
- u8 signature_0; //0x12: CE product, 0x92: IT product
- u8 signature_1; //0x87: CE product, 0x81: IT product
- u8 hci_sel; //0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP, 0x12: 72S-U, 03:SDIO
- u8 chip_version; //the same value as reigster value
- u8 customer_ID_0; //customer ID low byte
- u8 customer_ID_1; //customer ID high byte
- u8 rf_config; //0x11: 1T1R, 0x12: 1T2R, 0x92: 1T2R turbo, 0x22: 2T2R
- u8 usb_ep_num; // 4: 4EP, 6: 6EP, 11: 11EP
-
- //--- long word 1 ----
- u8 regulatory_class_0; //regulatory class bit map 0
- u8 regulatory_class_1; //regulatory class bit map 1
- u8 regulatory_class_2; //regulatory class bit map 2
- u8 regulatory_class_3; //regulatory class bit map 3
- u8 rfintfs; // 0:SWSI, 1:HWSI, 2:HWPI
- u8 def_nettype;
- u8 rsvd010;
- u8 rsvd011;
-
-
- //--- long word 2 ----
- u8 lbk_mode; //0x00: normal, 0x03: MACLBK, 0x01: PHYLBK
- u8 mp_mode; // 1: for MP use, 0: for normal driver (to be discussed)
- u8 rsvd020;
- u8 rsvd021;
- u8 rsvd022;
- u8 rsvd023;
- u8 rsvd024;
- u8 rsvd025;
-
- //--- long word 3 ----
- u8 qos_en; // QoS enable
- u8 bw_40MHz_en; // 40MHz BW enable
- u8 AMSDU2AMPDU_en; // 4181 convert AMSDU to AMPDU, 0: disable
- u8 AMPDU_en; // 11n AMPDU enable
- u8 rate_control_offload;//FW offloads, 0: driver handles
- u8 aggregation_offload; // FW offloads, 0: driver handles
- u8 rsvd030;
- u8 rsvd031;
-
-
- //--- long word 4 ----
- unsigned char beacon_offload; // 1. FW offloads, 0: driver handles
- unsigned char MLME_offload; // 2. FW offloads, 0: driver handles
- unsigned char hwpc_offload; // 3. FW offloads, 0: driver handles
- unsigned char tcp_checksum_offload; // 4. FW offloads, 0: driver handles
- unsigned char tcp_offload; // 5. FW offloads, 0: driver handles
- unsigned char ps_control_offload; // 6. FW offloads, 0: driver handles
- unsigned char WWLAN_offload; // 7. FW offloads, 0: driver handles
- unsigned char rsvd040;
-
- //--- long word 5 ----
- u8 tcp_tx_frame_len_L; //tcp tx packet length low byte
- u8 tcp_tx_frame_len_H; //tcp tx packet length high byte
- u8 tcp_rx_frame_len_L; //tcp rx packet length low byte
- u8 tcp_rx_frame_len_H; //tcp rx packet length high byte
- u8 rsvd050;
- u8 rsvd051;
- u8 rsvd052;
- u8 rsvd053;
-}RT_8192S_FIRMWARE_PRIV, *PRT_8192S_FIRMWARE_PRIV;
-
-typedef struct _RT_8192S_FIRMWARE_HDR {//8-byte alinment required
-
- //--- LONG WORD 0 ----
- u16 Signature;
- u16 Version; //0x8000 ~ 0x8FFF for FPGA version, 0x0000 ~ 0x7FFF for ASIC version,
- u32 DMEMSize; //define the size of boot loader
-
-
- //--- LONG WORD 1 ----
- u32 IMG_IMEM_SIZE; //define the size of FW in IMEM
- u32 IMG_SRAM_SIZE; //define the size of FW in SRAM
-
- //--- LONG WORD 2 ----
- u32 FW_PRIV_SIZE; //define the size of DMEM variable
- u32 Rsvd0;
-
- //--- LONG WORD 3 ----
- u32 Rsvd1;
- u32 Rsvd2;
-
- RT_8192S_FIRMWARE_PRIV FWPriv;
-
-}RT_8192S_FIRMWARE_HDR, *PRT_8192S_FIRMWARE_HDR;
-
-#define RT_8192S_FIRMWARE_HDR_SIZE 80
-#define RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE 32
-
-typedef enum _FIRMWARE_8192S_STATUS{
- FW_STATUS_INIT = 0,
- FW_STATUS_LOAD_IMEM = 1,
- FW_STATUS_LOAD_EMEM = 2,
- FW_STATUS_LOAD_DMEM = 3,
- FW_STATUS_READY = 4,
-}FIRMWARE_8192S_STATUS;
-
-#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 //64k
-
-typedef struct _rt_firmware{
- PRT_8192S_FIRMWARE_HDR pFwHeader;
- FIRMWARE_8192S_STATUS FWStatus;
- u8 FwIMEM[RTL8190_MAX_FIRMWARE_CODE_SIZE];
- u8 FwEMEM[RTL8190_MAX_FIRMWARE_CODE_SIZE];
- u32 FwIMEMLen;
- u32 FwEMEMLen;
- u8 szFwTmpBuffer[164000];
- u32 szFwTmpBufferLen;
- u16 CmdPacketFragThresold;
- u16 FirmwareVersion;
-}rt_firmware, *prt_firmware;
-
-#define FW_DIG_ENABLE_CTL BIT0
-#define FW_HIGH_PWR_ENABLE_CTL BIT1
-#define FW_SS_CTL BIT2
-#define FW_RA_INIT_CTL BIT3
-#define FW_RA_BG_CTL BIT4
-#define FW_RA_N_CTL BIT5
-#define FW_PWR_TRK_CTL BIT6
-#define FW_IQK_CTL BIT7
-#define FW_ANTENNA_SW BIT8
-#define FW_DISABLE_ALL_DM 0
-
-#define FW_PWR_TRK_PARAM_CLR 0x0000ffff
-#define FW_RA_PARAM_CLR 0xffff0000
-
-#define FW_CMD_IO_CLR(_pdev, _Bit) \
- udelay(1000); \
- ((struct r8192_priv *)ieee80211_priv(_pdev))->FwCmdIOMap &= (~_Bit);
-
-#define FW_CMD_IO_UPDATE(_pdev, _val) \
- ((struct r8192_priv *)ieee80211_priv(_pdev))->FwCmdIOMap = _val;
-
-#define FW_CMD_IO_SET(_pdev, _val) \
- write_nic_word(_pdev, LBUS_MON_ADDR, (u16)_val); \
- FW_CMD_IO_UPDATE(_pdev, _val);
-
-#define FW_CMD_PARA_SET(_pdev, _val) \
- write_nic_dword(_pdev, LBUS_ADDR_MASK, _val); \
- ((struct r8192_priv *)ieee80211_priv(_pdev))->FwCmdIOParam = _val;
-
-#define FW_CMD_IO_QUERY(_pdev) (u16)(((struct r8192_priv *)ieee80211_priv(_pdev))->FwCmdIOMap)
-#define FW_CMD_IO_PARA_QUERY(_pdev) (u32)(((struct r8192_priv *)ieee80211_priv(_pdev))->FwCmdIOParam)
-
-
-
-bool FirmwareDownload92S(struct net_device *dev);
-
-#endif
-
diff --git a/drivers/staging/rtl8192su/r8192S_hw.h b/drivers/staging/rtl8192su/r8192S_hw.h
deleted file mode 100644
index e62b79df5ba5..000000000000
--- a/drivers/staging/rtl8192su/r8192S_hw.h
+++ /dev/null
@@ -1,1445 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-#ifndef R8192S_HW
-#define R8192S_HW
-
-typedef enum _VERSION_8192S{
- VERSION_8192S_ACUT,
- VERSION_8192S_BCUT,
- VERSION_8192S_CCUT
-}VERSION_8192S,*PVERSION_8192S;
-
-typedef enum _VERSION_8192SUsb{
- VERSION_8192SU_A, //A-Cut
- VERSION_8192SU_B, //B-Cut
- VERSION_8192SU_C, //C-Cut
-}VERSION_8192SUsb, *PVERSION_8192SUsb;
-
-
-/* RF type. */
-typedef enum _RT_RF_TYPE_DEFINITION
-{
- RF_1T2R = 0,
- RF_2T4R,
- RF_2T2R,
- RF_1T1R,
- RF_2T2R_GREEN,
- RF_819X_MAX_TYPE
-}RT_RF_TYPE_DEF_E;
-
-typedef enum _BaseBand_Config_Type{
- BaseBand_Config_PHY_REG = 0, //Radio Path A
- BaseBand_Config_AGC_TAB = 1, //Radio Path B
-}BaseBand_Config_Type, *PBaseBand_Config_Type;
-
-#define RTL8187_REQT_READ 0xc0
-#define RTL8187_REQT_WRITE 0x40
-#define RTL8187_REQ_GET_REGS 0x05
-#define RTL8187_REQ_SET_REGS 0x05
-
-#define MAX_TX_URB 5
-#define MAX_RX_URB 8
-
-#define R8180_MAX_RETRY 255
-#define RX_URB_SIZE 0x4000
-
-#define BB_ANTATTEN_CHAN14 0x0c
-#define BB_ANTENNA_B 0x40
-
-#define BB_HOST_BANG (1<<30)
-#define BB_HOST_BANG_EN (1<<2)
-#define BB_HOST_BANG_CLK (1<<1)
-#define BB_HOST_BANG_RW (1<<3)
-#define BB_HOST_BANG_DATA 1
-
-
-//============================================================
-// 8192S Regsiter bit
-//============================================================
-#define BB_GLOBAL_RESET_BIT 0x1
-
-#define CR_RST 0x10
-#define CR_RE 0x08
-#define CR_TE 0x04
-#define CR_MulRW 0x01
-
-#define MAC_FILTER_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<5) | \
- (1<<12) | (1<<18) | (1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23))
-
-#define RX_FIFO_THRESHOLD_MASK ((1<<13) | (1<<14) | (1<<15))
-#define RX_FIFO_THRESHOLD_SHIFT 13
-#define RX_FIFO_THRESHOLD_128 3
-#define RX_FIFO_THRESHOLD_256 4
-#define RX_FIFO_THRESHOLD_512 5
-#define RX_FIFO_THRESHOLD_1024 6
-#define RX_FIFO_THRESHOLD_NONE 7
-
-#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
-
-//----------------------------------------------------------------------------
-// 8190 CPU General Register (offset 0x100, 4 byte)
-//----------------------------------------------------------------------------
-#define CPU_CCK_LOOPBACK 0x00030000
-#define CPU_GEN_SYSTEM_RESET 0x00000001
-#define CPU_GEN_FIRMWARE_RESET 0x00000008
-#define CPU_GEN_BOOT_RDY 0x00000010
-#define CPU_GEN_FIRM_RDY 0x00000020
-#define CPU_GEN_PUT_CODE_OK 0x00000080
-#define CPU_GEN_BB_RST 0x00000100
-#define CPU_GEN_PWR_STB_CPU 0x00000004
-#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
-#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
-//----------------------------------------------------------------------------
-////
-//// 8190 AcmHwCtrl bits (offset 0x171, 1 byte)
-////----------------------------------------------------------------------------
-#define MSR_LINK_MASK ((1<<0)|(1<<1))
-#define MSR_LINK_MANAGED 2
-#define MSR_LINK_NONE 0
-#define MSR_LINK_SHIFT 0
-#define MSR_LINK_ADHOC 1
-#define MSR_LINK_MASTER 3
-#define MSR_LINK_ENEDCA (1<<4)
-
-
-#define EPROM_CMD_RESERVED_MASK (1<<5)
-#define EPROM_CMD_OPERATING_MODE_SHIFT 6
-#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6))
-#define EPROM_CMD_CONFIG 0x3
-#define EPROM_CMD_NORMAL 0
-#define EPROM_CMD_LOAD 1
-#define EPROM_CMD_PROGRAM 2
-#define EPROM_CS_SHIFT 3
-#define EPROM_CK_SHIFT 2
-#define EPROM_W_SHIFT 1
-#define EPROM_R_SHIFT 0
-
-//============================================================
-// 8192S Regsiter offset definition
-//============================================================
-
-//
-// MAC register 0x0 - 0x5xx
-// 1. System configuration registers.
-// 2. Command Control Registers
-// 3. MACID Setting Registers
-// 4. Timing Control Registers
-// 5. FIFO Control Registers
-// 6. Adaptive Control Registers
-// 7. EDCA Setting Registers
-// 8. WMAC, BA and CCX related Register.
-// 9. Security Control Registers
-// 10. Power Save Control Registers
-// 11. General Purpose Registers
-// 12. Host Interrupt Status Registers
-// 13. Test Mode and Debug Control Registers
-// 14. PCIE config register
-//
-
-
-//
-// 1. System Configuration Registers (Offset: 0x0000 - 0x003F)
-//
-#define SYS_ISO_CTRL 0x0000 // System Isolation Interface Control.
-#define SYS_FUNC_EN 0x0002 // System Function Enable.
-#define PMC_FSM 0x0004 // Power Sequence Control.
-#define SYS_CLKR 0x0008 // System Clock.
-#define EPROM_CMD 0x000A // 93C46/93C56 Command Register. (win CR93C46)
-#define EE_VPD 0x000C // EEPROM VPD Data.
-#define AFE_MISC 0x0010 // AFE Misc.
-#define SPS0_CTRL 0x0011 // Switching Power Supply 0 Control.
-#define SPS1_CTRL 0x0018 // Switching Power Supply 1 Control.
-#define RF_CTRL 0x001F // RF Block Control.
-#define LDOA15_CTRL 0x0020 // V15 Digital LDO Control.
-#define LDOV12D_CTRL 0x0021 // V12 Digital LDO Control.
-#define LDOHCI12_CTRL 0x0022 // V12 Digital LDO Control.
-#define LDO_USB_SDIO 0x0023 // LDO USB Control.
-#define LPLDO_CTRL 0x0024 // Low Power LDO Control.
-#define AFE_XTAL_CTRL 0x0026 // AFE Crystal Control.
-#define AFE_PLL_CTRL 0x0028 // System Function Enable.
-#define EFUSE_CTRL 0x0030 // E-Fuse Control.
-#define EFUSE_TEST 0x0034 // E-Fuse Test.
-#define PWR_DATA 0x0038 // Power on date.
-#define DBG_PORT 0x003A // MAC debug port select
-#define DPS_TIMER 0x003C // Deep Power Save Timer Register.
-#define RCLK_MON 0x003E // Retention Clock Monitor.
-
-//
-// 2. Command Control Registers (Offset: 0x0040 - 0x004F)
-//
-#define CMDR 0x0040 // MAC Command Register.
-#define TXPAUSE 0x0042 // Transmission Pause Register.
-#define LBKMD_SEL 0x0043 // Loopback Mode Select Register.
-#define TCR 0x0044 // Transmit Configuration Register
-#define RCR 0x0048 // Receive Configuration Register
-#define MSR 0x004C // Media Status register
-#define SYSF_CFG 0x004D // System Function Configuration.
-#define RX_PKY_LIMIT 0x004E // RX packet length limit
-#define MBIDCTRL 0x004F // MBSSID Control.
-
-//
-// 3. MACID Setting Registers (Offset: 0x0050 - 0x007F)
-//
-#define MACIDR 0x0050 // MAC ID Register, Offset 0x0050-0x0055
-#define MACIDR0 0x0050 // MAC ID Register, Offset 0x0050-0x0053
-#define MACIDR4 0x0054 // MAC ID Register, Offset 0x0054-0x0055
-#define BSSIDR 0x0058 // BSSID Register, Offset 0x0058-0x005D
-#define HWVID 0x005E // HW Version ID.
-#define MAR 0x0060 // Multicase Address.
-#define MBIDCAMCONTENT 0x0068 // MBSSID CAM Content.
-#define MBIDCAMCFG 0x0070 // MBSSID CAM Configuration.
-#define BUILDTIME 0x0074 // Build Time Register.
-#define BUILDUSER 0x0078 // Build User Register.
-
-// Redifine MACID register, to compatible prior ICs.
-#define IDR0 MACIDR0
-#define IDR4 MACIDR4
-
-//
-// 4. Timing Control Registers (Offset: 0x0080 - 0x009F)
-//
-#define TSFR 0x0080 // Timing Sync Function Timer Register.
-#define SLOT_TIME 0x0089 // Slot Time Register, in us.
-#define USTIME 0x008A // EDCA/TSF clock unit time us unit.
-#define SIFS_CCK 0x008C // SIFS for CCK, in us.
-#define SIFS_OFDM 0x008E // SIFS for OFDM, in us.
-#define PIFS_TIME 0x0090 // PIFS time register.
-#define ACK_TIMEOUT 0x0091 // Ack Timeout Register
-#define EIFSTR 0x0092 // EIFS time regiser.
-#define BCN_INTERVAL 0x0094 // Beacon Interval, in TU.
-#define ATIMWND 0x0096 // ATIM Window width, in TU.
-#define BCN_DRV_EARLY_INT 0x0098 // Driver Early Interrupt.
-#define BCN_DMATIME 0x009A // Beacon DMA and ATIM INT Time.
-#define BCN_ERR_THRESH 0x009C // Beacon Error Threshold.
-#define MLT 0x009D // MSDU Lifetime.
-#define RSVD_MAC_TUNE_US 0x009E // MAC Internal USE.
-
-//
-// 5. FIFO Control Registers (Offset: 0x00A0 - 0x015F)
-//
-#define RQPN 0x00A0
-#define RQPN1 0x00A0 // Reserved Queue Page Number for BK
-#define RQPN2 0x00A1 // Reserved Queue Page Number for BE
-#define RQPN3 0x00A2 // Reserved Queue Page Number for VI
-#define RQPN4 0x00A3 // Reserved Queue Page Number for VO
-#define RQPN5 0x00A4 // Reserved Queue Page Number for HCCA
-#define RQPN6 0x00A5 // Reserved Queue Page Number for CMD
-#define RQPN7 0x00A6 // Reserved Queue Page Number for MGNT
-#define RQPN8 0x00A7 // Reserved Queue Page Number for HIGH
-#define RQPN9 0x00A8 // Reserved Queue Page Number for Beacon
-#define RQPN10 0x00A9 // Reserved Queue Page Number for Public
-#define LD_RQPN 0x00AB //
-#define RXFF_BNDY 0x00AC //
-#define RXRPT_BNDY 0x00B0 //
-#define TXPKTBUF_PGBNDY 0x00B4 //
-#define PBP 0x00B5 //
-#define RXDRVINFO_SZ 0x00B6 //
-#define TXFF_STATUS 0x00B7 //
-#define RXFF_STATUS 0x00B8 //
-#define TXFF_EMPTY_TH 0x00B9 //
-#define SDIO_RX_BLKSZ 0x00BC //
-#define RXDMA 0x00BD //
-#define RXPKT_NUM 0x00BE //
-#define C2HCMD_UDT_SIZE 0x00C0 //
-#define C2HCMD_UDT_ADDR 0x00C2 //
-#define FIFOPAGE1 0x00C4 // Available public queue page number
-#define FIFOPAGE2 0x00C8 //
-#define FIFOPAGE3 0x00CC //
-#define FIFOPAGE4 0x00D0 //
-#define FIFOPAGE5 0x00D4 //
-#define FW_RSVD_PG_CRTL 0x00D8 //
-#define RXDMA_AGG_PG_TH 0x00D9 //
-#define TXRPTFF_RDPTR 0x00E0 //
-#define TXRPTFF_WTPTR 0x00E4 //
-#define C2HFF_RDPTR 0x00E8 //FIFO Read pointer register.
-#define C2HFF_WTPTR 0x00EC //FIFO Write pointer register.
-#define RXFF0_RDPTR 0x00F0 //
-#define RXFF0_WTPTR 0x00F4 //
-#define RXFF1_RDPTR 0x00F8 //
-#define RXFF1_WTPTR 0x00FC //
-#define RXRPT0_RDPTR 0x0100 //
-#define RXRPT0_WTPTR 0x0104 //
-#define RXRPT1_RDPTR 0x0108 //
-#define RXRPT1_WTPTR 0x010C //
-#define RX0_UDT_SIZE 0x0110 //
-#define RX1PKTNUM 0x0114 //
-#define RXFILTERMAP 0x0116 //
-#define RXFILTERMAP_GP1 0x0118 //
-#define RXFILTERMAP_GP2 0x011A //
-#define RXFILTERMAP_GP3 0x011C //
-#define BCNQ_CTRL 0x0120 //
-#define MGTQ_CTRL 0x0124 //
-#define HIQ_CTRL 0x0128 //
-#define VOTID7_CTRL 0x012c //
-#define VOTID6_CTRL 0x0130 //
-#define VITID5_CTRL 0x0134 //
-#define VITID4_CTRL 0x0138 //
-#define BETID3_CTRL 0x013c //
-#define BETID0_CTRL 0x0140 //
-#define BKTID2_CTRL 0x0144 //
-#define BKTID1_CTRL 0x0148 //
-#define CMDQ_CTRL 0x014c //
-#define TXPKT_NUM_CTRL 0x0150 //
-#define TXQ_PGADD 0x0152 //
-#define TXFF_PG_NUM 0x0154 //
-#define TRXDMA_STATUS 0x0156 //
-
-//
-// 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF)
-//
-#define INIMCS_SEL 0x0160 // Init MCSrate for 32 MACID 0x160-17f
-#define TX_RATE_REG INIMCS_SEL //Current Tx rate register
-#define INIRTSMCS_SEL 0x0180 // Init RTSMCSrate
-#define RRSR 0x0181 // Response rate setting.
-#define ARFR0 0x0184 // Auto Rate Fallback 0 Register.
-#define ARFR1 0x0188 //
-#define ARFR2 0x018C //
-#define ARFR3 0x0190 //
-#define ARFR4 0x0194 //
-#define ARFR5 0x0198 //
-#define ARFR6 0x019C //
-#define ARFR7 0x01A0 //
-#define AGGLEN_LMT_H 0x01A7 // Aggregation Length Limit for High-MCS
-#define AGGLEN_LMT_L 0x01A8 // Aggregation Length Limit for Low-MCS.
-#define DARFRC 0x01B0 // Data Auto Rate Fallback Retry Count.
-#define RARFRC 0x01B8 // Response Auto Rate Fallback Count.
-#define MCS_TXAGC 0x01C0
-#define CCK_TXAGC 0x01C8
-
-//
-// 7. EDCA Setting Registers (Offset: 0x01D0 - 0x01FF)
-//
-#define EDCAPARA_VO 0x01D0 // EDCA Parameter Register for VO queue.
-#define EDCAPARA_VI 0x01D4 // EDCA Parameter Register for VI queue.
-#define EDCAPARA_BE 0x01D8 // EDCA Parameter Register for BE queue.
-#define EDCAPARA_BK 0x01DC // EDCA Parameter Register for BK queue.
-#define BCNTCFG 0x01E0 // Beacon Time Configuration Register.
-#define CWRR 0x01E2 // Contention Window Report Register.
-#define ACMAVG 0x01E4 // ACM Average Register.
-#define AcmHwCtrl 0x01E7
-#define VO_ADMTM 0x01E8 // Admission Time Register.
-#define VI_ADMTM 0x01EC
-#define BE_ADMTM 0x01F0
-#define RETRY_LIMIT 0x01F4 // Retry Limit Registers[15:8]-short, [7:0]-long
-#define SG_RATE 0x01F6 // Max MCS Rate Available Register, which we Set the hightst SG rate.
-
-//
-// 8. WMAC, BA and CCX related Register. (Offset: 0x0200 - 0x023F)
-//
-#define NAV_CTRL 0x0200
-#define BW_OPMODE 0x0203
-#define BACAMCMD 0x0204
-#define BACAMCONTENT 0x0208 // Block ACK CAM R/W Register.
-
-// Roger had defined the 0x2xx register WMAC definition
-#define LBDLY 0x0210 // Loopback Delay Register.
-#define FWDLY 0x0211 // FW Delay Register.
-#define HWPC_RX_CTRL 0x0218 // HW Packet Conversion RX Control Reg
-#define MQIR 0x0220 // Mesh Qos Type Indication Register.
-#define MAIR 0x0222 // Mesh ACK.
-#define MSIR 0x0224 // Mesh HW Security Requirement Indication Reg
-#define CLM_RESULT 0x0227 // CCA Busy Fraction(Channel Load)
-#define NHM_RPI_CNT 0x0228 // Noise Histogram Measurement (NHM) RPI Report.
-#define RXERR_RPT 0x0230 // Rx Error Report.
-#define NAV_PROT_LEN 0x0234 // NAV Protection Length.
-#define CFEND_TH 0x0236 // CF-End Threshold.
-#define AMPDU_MIN_SPACE 0x0237 // AMPDU Min Space.
-#define TXOP_STALL_CTRL 0x0238
-
-//
-// 9. Security Control Registers (Offset: 0x0240 - 0x025F)
-//
-#define RWCAM 0x0240 //IN 8190 Data Sheet is called CAMcmd
-#define WCAMI 0x0244 // Software write CAM input content
-#define RCAMO 0x0248 // Software read/write CAM config
-#define CAMDBG 0x024C
-#define SECR 0x0250 //Security Configuration Register
-
-//
-// 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF)
-//
-#define WOW_CTRL 0x0260 //Wake On WLAN Control.
-#define PSSTATUS 0x0261 // Power Save Status.
-#define PSSWITCH 0x0262 // Power Save Switch.
-#define MIMOPS_WAIT_PERIOD 0x0263
-#define LPNAV_CTRL 0x0264
-#define WFM0 0x0270 // Wakeup Frame Mask.
-#define WFM1 0x0280 //
-#define WFM2 0x0290 //
-#define WFM3 0x02A0 //
-#define WFM4 0x02B0 //
-#define WFM5 0x02C0 // FW Control register.
-#define WFCRC 0x02D0 // Wakeup Frame CRC.
-#define RPWM 0x02DC // Host Request Power Mode.
-#define CPWM 0x02DD // Current Power Mode.
-#define FW_RPT_REG 0x02c4
-
-//
-// 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)
-//
-#define PSTIME 0x02E0 // Power Save Timer Register
-#define TIMER0 0x02E4 //
-#define TIMER1 0x02E8 //
-#define GPIO_CTRL 0x02EC // GPIO Control Register
-#define GPIO_IN 0x02EC // GPIO pins input value
-#define GPIO_OUT 0x02ED // GPIO pins output value
-#define GPIO_IO_SEL 0x02EE // GPIO pins output enable when a bit is set to "1"; otherwise, input is configured.
-#define GPIO_MOD 0x02EF //
-#define GPIO_INTCTRL 0x02F0 // GPIO Interrupt Control Register[7:0]
-#define MAC_PINMUX_CFG 0x02F1 // MAC PINMUX Configuration Reg[7:0]
-#define LEDCFG 0x02F2 // System PINMUX Configuration Reg[7:0]
-#define PHY_REG 0x02F3 // RPT: PHY REG Access Report Reg[7:0]
-#define PHY_REG_DATA 0x02F4 // PHY REG Read DATA Register [31:0]
-#define EFUSE_CLK 0x02F8 // CTRL: E-FUSE Clock Control Reg[7:0]
-//#define GPIO_INTCTRL 0x02F9 // GPIO Interrupt Control Register[7:0]
-
-//
-// 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F)
-//
-#define IMR 0x0300 // Interrupt Mask Register
-#define ISR 0x0308 // Interrupt Status Register
-
-//
-// 13. Test Mode and Debug Control Registers (Offset: 0x0310 - 0x034F)
-//
-#define DBG_PORT_SWITCH 0x003A
-#define BIST 0x0310 // Bist reg definition
-#define DBS 0x0314 // Debug Select ???
-#define CPUINST 0x0318 // CPU Instruction Read Register
-#define CPUCAUSE 0x031C // CPU Cause Register
-#define LBUS_ERR_ADDR 0x0320 // Lexra Bus Error Address Register
-#define LBUS_ERR_CMD 0x0324 // Lexra Bus Error Command Register
-#define LBUS_ERR_DATA_L 0x0328 // Lexra Bus Error Data Low DW Register
-#define LBUS_ERR_DATA_H 0x032C //
-#define LX_EXCEPTION_ADDR 0x0330 // Lexra Bus Exception Address Register
-#define WDG_CTRL 0x0334 // Watch Dog Control Register
-#define INTMTU 0x0338 // Interrupt Mitigation Time Unit Reg
-#define INTM 0x033A // Interrupt Mitigation Register
-#define FDLOCKTURN0 0x033C // FW/DRV Lock Turn 0 Register
-#define FDLOCKTURN1 0x033D // FW/DRV Lock Turn 1 Register
-#define TRXPKTBUF_DBG_DATA 0x0340 // TRX Packet Buffer Debug Data Register
-#define TRXPKTBUF_DBG_CTRL 0x0348 // TRX Packet Buffer Debug Control Reg
-#define DPLL 0x034A // DPLL Monitor Register [15:0]
-#define CBUS_ERR_ADDR 0x0350 // CPU Bus Error Address Register
-#define CBUS_ERR_CMD 0x0354 // CPU Bus Error Command Register
-#define CBUS_ERR_DATA_L 0x0358 // CPU Bus Error Data Low DW Register
-#define CBUS_ERR_DATA_H 0x035C //
-#define USB_SIE_INTF_ADDR 0x0360 // USB SIE Access Interface Address Reg
-#define USB_SIE_INTF_WD 0x0361 // USB SIE Access Interface WData Reg
-#define USB_SIE_INTF_RD 0x0362 // USB SIE Access Interface RData Reg
-#define USB_SIE_INTF_CTRL 0x0363 // USB SIE Access Interface Control Reg
-
-// Boundary is 0x37F
-
-//
-// 14. PCIE config register (Offset 0x500-)
-//
-#define TPPoll 0x0500 // Transmit Polling
-#define PM_CTRL 0x0502 // PCIE power management control Register
-#define PCIF 0x0503 // PCI Function Register 0x0009h~0x000bh
-
-#define THPDA 0x0514 // Transmit High Priority Desc Addr
-#define TMDA 0x0518 // Transmit Management Desc Addr
-#define TCDA 0x051C // Transmit Command Desc Addr
-#define HDA 0x0520 // HCCA Desc Addr
-#define TVODA 0x0524 // Transmit VO Desc Addr
-#define TVIDA 0x0528 // Transmit VI Desc Addr
-#define TBEDA 0x052C // Transmit BE Desc Addr
-#define TBKDA 0x0530 // Transmit BK Desc Addr
-#define TBDA 0x0534 // Transmit Beacon Desc Addr
-#define RCDA 0x0538 // Receive Command Desc Addr
-#define RDSA 0x053C // Receive Desc Starting Addr
-#define DBI_WDATA 0x0540 // DBI write data Register
-#define DBI_RDATA 0x0544 // DBI read data Register
-#define DBI_CTRL 0x0548 // PCIE DBI control Register
-#define MDIO_DATA 0x0550 // PCIE MDIO data Register
-#define MDIO_CTRL 0x0554 // PCIE MDIO control Register
-#define PCI_RPWM 0x0561 // PCIE RPWM register
-#define PCI_CPWM 0x0563 // Current Power Mode.
-
-//
-// Config register (Offset 0x800-)
-//
-#define PHY_CCA 0x803 // CCA related register
-
-//============================================================================
-// 8192S USB specific Regsiter Offset and Content definition,
-// 2008.08.28, added by Roger.
-//============================================================================
-// Rx Aggregation time-out reg.
-#define USB_RX_AGG_TIMEOUT 0xFE5B
-
-// Firware reserved Tx page control.
-#define FW_OFFLOAD_EN BIT7
-
-// Min Spacing related settings.
-#define MAX_MSS_DENSITY 0x13
-#define MAX_MSS_DENSITY_2T 0x13
-#define MAX_MSS_DENSITY_1T 0x0A
-
-// Rx DMA Control related settings
-#define RXDMA_AGG_EN BIT7
-
-// USB Rx Aggregation TimeOut settings
-#define RXDMA_AGG_TIMEOUT_DISABLE 0x00
-#define RXDMA_AGG_TIMEOUT_17MS 0x01
-#define RXDMA_AGG_TIMEOUT_17_2_MS 0x02
-#define RXDMA_AGG_TIMEOUT_17_4_MS 0x04
-#define RXDMA_AGG_TIMEOUT_17_10_MS 0x0A
-// USB RPWM register
-#define USB_RPWM 0xFE58
-
-//============================================================================
-// 8190 Regsiter offset definition
-//============================================================================
-#if 1 // Delete the register later
-#define AFR 0x010 // AutoLoad Function Register
-#define BCN_TCFG 0x062 // Beacon Time Configuration
-#define RATR0 0x320 // Rate Adaptive Table register1
-#endif
-// TODO: Remove unused register, We must declare backward compatiable
-//Undefined register set in 8192S. 0x320/350 DW is useless
-#define UnusedRegister 0x0320
-#define PSR UnusedRegister // Page Select Register
-//Security Related
-#define DCAM UnusedRegister // Debug CAM Interface
-//PHY Configuration related
-#define BBAddr UnusedRegister // Phy register address register
-#define PhyDataR UnusedRegister // Phy register data read
-#define UFWP UnusedRegister
-
-
-//============================================================================
-// 8192S Regsiter Bit and Content definition
-//============================================================================
-
-//
-// 1. System Configuration Registers (Offset: 0x0000 - 0x003F)
-//
-//----------------------------------------------------------------------------
-// 8192S SYS_ISO_CTRL bits (Offset 0x0, 16bit)
-//----------------------------------------------------------------------------
-#define ISO_MD2PP BIT0 // MACTOP/BB/PCIe Digital to Power On.
-#define ISO_PA2PCIE BIT3 // PCIe Analog 1.2V to PCIe 3.3V
-#define ISO_PLL2MD BIT4 // AFE PLL to MACTOP/BB/PCIe Digital.
-#define ISO_PWC_DV2RP BIT11 // Digital Vdd to Retention Path
-#define ISO_PWC_RV2RP BIT12 // LPLDOR12 to Retenrion Path, 1: isolation, 0: attach.
-
-//----------------------------------------------------------------------------
-// 8192S SYS_FUNC_EN bits (Offset 0x2, 16bit)
-//----------------------------------------------------------------------------
-#define FEN_MREGEN BIT15 // MAC I/O Registers Enable.
-#define FEN_DCORE BIT11 // Enable Core Digital.
-#define FEN_CPUEN BIT10 // Enable CPU Core Digital.
-// 8192S PMC_FSM bits (Offset 0x4, 32bit)
-//----------------------------------------------------------------------------
-#define PAD_HWPD_IDN BIT22 // HWPDN PAD status Indicator
-
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// 8192S SYS_CLKR bits (Offset 0x8, 16bit)
-//----------------------------------------------------------------------------
-#define SYS_CLKSEL_80M BIT0 // System Clock 80MHz
-#define SYS_PS_CLKSEL BIT1 //System power save clock select.
-#define SYS_CPU_CLKSEL BIT2 // System Clock select, 1: AFE source, 0: System clock(L-Bus)
-#define SYS_MAC_CLK_EN BIT11 // MAC Clock Enable.
-#define SYS_SWHW_SEL BIT14 // Load done, control path seitch.
-#define SYS_FWHW_SEL BIT15 // Sleep exit, control path swith.
-
-
-//----------------------------------------------------------------------------
-// 8192S Cmd9346CR bits (Offset 0xA, 16bit)
-//----------------------------------------------------------------------------
-#define CmdEEPROM_En BIT5 // EEPROM enable when set 1
-#define CmdEERPOMSEL BIT4 // System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346
-#define Cmd9346CR_9356SEL BIT4
-#define AutoLoadEEPROM (CmdEEPROM_En|CmdEERPOMSEL)
-#define AutoLoadEFUSE CmdEEPROM_En
-
-
-//----------------------------------------------------------------------------
-// 8192S AFE_MISC bits AFE Misc (Offset 0x10, 8bits)
-//----------------------------------------------------------------------------
-#define AFE_MBEN BIT1 // Enable AFE Macro Block's Mbias.
-#define AFE_BGEN BIT0 // Enable AFE Macro Block's Bandgap.
-
-//----------------------------------------------------------------------------
-// 8192S SPS1_CTRL bits (Offset 0x18-1E, 56bits)
-//----------------------------------------------------------------------------
-#define SPS1_SWEN BIT1 // Enable vsps18 SW Macro Block.
-#define SPS1_LDEN BIT0 // Enable VSPS12 LDO Macro block.
-
-//----------------------------------------------------------------------------
-// 8192S RF_CTRL bits (Offset 0x1F, 8bits)
-//----------------------------------------------------------------------------
-#define RF_EN BIT0 // Enable RF module.
-#define RF_RSTB BIT1 // Reset RF module.
-#define RF_SDMRSTB BIT2 // Reset RF SDM module.
-
-//----------------------------------------------------------------------------
-// 8192S LDOA15_CTRL bits (Offset 0x20, 8bits)
-//----------------------------------------------------------------------------
-#define LDA15_EN BIT0 // Enable LDOA15 Macro Block
-
-//----------------------------------------------------------------------------
-// 8192S LDOV12D_CTRL bits (Offset 0x21, 8bits)
-//----------------------------------------------------------------------------
-#define LDV12_EN BIT0 // Enable LDOVD12 Macro Block
-#define LDV12_SDBY BIT1 // LDOVD12 standby mode
-
-//----------------------------------------------------------------------------
-// 8192S AFE_XTAL_CTRL bits AFE Crystal Control. (Offset 0x26,16bits)
-//----------------------------------------------------------------------------
-#define XTAL_GATE_AFE BIT10
-// Gated Control. 1: AFE Clock source gated, 0: Clock enable.
-
-//----------------------------------------------------------------------------
-// 8192S AFE_PLL_CTRL bits System Function Enable (Offset 0x28,64bits)
-//----------------------------------------------------------------------------
-#define APLL_EN BIT0 // Enable AFE PLL Macro Block.
-
-// Find which card bus type
-#define AFR_CardBEn BIT0
-#define AFR_CLKRUN_SEL BIT1
-#define AFR_FuncRegEn BIT2
-
-//
-// 2. Command Control Registers (Offset: 0x0040 - 0x004F)
-//
-//----------------------------------------------------------------------------
-// 8192S (CMD) command register bits (Offset 0x40, 16 bits)
-//----------------------------------------------------------------------------
-#define APSDOFF_STATUS BIT15 //
-#define APSDOFF BIT14 //
-#define BBRSTn BIT13 //Enable OFDM/CCK
-#define BB_GLB_RSTn BIT12 //Enable BB
-#define SCHEDULE_EN BIT10 //Enable MAC scheduler
-#define MACRXEN BIT9 //
-#define MACTXEN BIT8 //
-#define DDMA_EN BIT7 //FW off load function enable
-#define FW2HW_EN BIT6 //MAC every module reset as below
-#define RXDMA_EN BIT5 //
-#define TXDMA_EN BIT4 //
-#define HCI_RXDMA_EN BIT3 //
-#define HCI_TXDMA_EN BIT2 //
-
-//----------------------------------------------------------------------------
-// 8192S (TXPAUSE) transmission pause (Offset 0x42, 8 bits)
-//----------------------------------------------------------------------------
-#define StopHCCA BIT6
-#define StopHigh BIT5
-#define StopMgt BIT4
-#define StopVO BIT3
-#define StopVI BIT2
-#define StopBE BIT1
-#define StopBK BIT0
-
-//----------------------------------------------------------------------------
-// 8192S (LBKMD) LoopBack Mode Select (Offset 0x43, 8 bits)
-//----------------------------------------------------------------------------
-//
-// [3] no buffer, 1: no delay, 0: delay; [2] dmalbk, [1] no_txphy, [0] diglbk.
-// 0000: Normal
-// 1011: MAC loopback (involving CPU)
-// 0011: MAC Delay Loopback
-// 0001: PHY loopback (not yet implemented)
-// 0111: DMA loopback (only uses TxPktBuffer and DMA engine)
-// All other combinations are reserved.
-// Default: 0000b.
-//
-#define LBK_NORMAL 0x00
-#define LBK_MAC_LB (BIT0|BIT1|BIT3)
-#define LBK_MAC_DLB (BIT0|BIT1)
-#define LBK_DMA_LB (BIT0|BIT1|BIT2)
-
-//----------------------------------------------------------------------------
-// 8192S (TCR) transmission Configuration Register (Offset 0x44, 32 bits)
-//----------------------------------------------------------------------------
-#define TCP_OFDL_EN BIT25 //For CE packet conversion
-#define HWPC_TX_EN BIT24 //""
-#define TXDMAPRE2FULL BIT23 //TXDMA enable pre2full sync
-#define DISCW BIT20 //CW disable
-#define TCRICV BIT19 //Append ICV or not
-#define CfendForm BIT17 //AP mode
-#define TCRCRC BIT16 //Append CRC32
-#define FAKE_IMEM_EN BIT15 //
-#define TSFRST BIT9 //
-#define TSFEN BIT8 //
-// For TCR FW download ready --> write by FW Bit0-7 must all one
-#define FWALLRDY (BIT0|BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7)
-#define FWRDY BIT7
-#define BASECHG BIT6
-#define IMEM BIT5
-#define DMEM_CODE_DONE BIT4
-#define EXT_IMEM_CHK_RPT BIT3
-#define EXT_IMEM_CODE_DONE BIT2
-#define IMEM_CHK_RPT BIT1
-#define IMEM_CODE_DONE BIT0
-// Copy fomr 92SU definition
-#define IMEM_CODE_DONE BIT0
-#define IMEM_CHK_RPT BIT1
-#define EMEM_CODE_DONE BIT2
-#define EMEM_CHK_RPT BIT3
-#define DMEM_CODE_DONE BIT4
-#define IMEM_RDY BIT5
-#define BASECHG BIT6
-#define FWRDY BIT7
-#define LOAD_FW_READY (IMEM_CODE_DONE|IMEM_CHK_RPT|EMEM_CODE_DONE|\
- EMEM_CHK_RPT|DMEM_CODE_DONE|IMEM_RDY|BASECHG|\
- FWRDY)
-#define TCR_TSFEN BIT8 // TSF function on or off.
-#define TCR_TSFRST BIT9 // Reset TSF function to zero.
-#define TCR_FAKE_IMEM_EN BIT15
-#define TCR_CRC BIT16
-#define TCR_ICV BIT19 // Integrity Check Value.
-#define TCR_DISCW BIT20 // Disable Contention Windows Backoff.
-#define TCR_HWPC_TX_EN BIT24
-#define TCR_TCP_OFDL_EN BIT25
-#define TXDMA_INIT_VALUE (IMEM_CHK_RPT|EXT_IMEM_CHK_RPT)
-//----------------------------------------------------------------------------
-// 8192S (RCR) Receive Configuration Register (Offset 0x48, 32 bits)
-//----------------------------------------------------------------------------
-#define RCR_APPFCS BIT31 //WMAC append FCS after pauload
-#define RCR_DIS_ENC_2BYTE BIT30 //HW encrypt 2 or 1 byte mode
-#define RCR_DIS_AES_2BYTE BIT29 //
-#define RCR_HTC_LOC_CTRL BIT28 //MFC<--HTC=1 MFC-->HTC=0
-#define RCR_ENMBID BIT27 //Enable Multiple BssId.
-#define RCR_RX_TCPOFDL_EN BIT26 //
-#define RCR_APP_PHYST_RXFF BIT25 //
-#define RCR_APP_PHYST_STAFF BIT24 //
-#define RCR_CBSSID BIT23 //Accept BSSID match packet
-#define RCR_APWRMGT BIT22 //Accept power management packet
-#define RCR_ADD3 BIT21 //Accept address 3 match packet
-#define RCR_AMF BIT20 //Accept management type frame
-#define RCR_ACF BIT19 //Accept control type frame
-#define RCR_ADF BIT18 //Accept data type frame
-#define RCR_APP_MIC BIT17 //
-#define RCR_APP_ICV BIT16 //
-#define RCR_RXFTH BIT13 //Rx FIFO Threshold Bot 13 - 15
-#define RCR_AICV BIT12 //Accept ICV error packet
-#define RCR_RXDESC_LK_EN BIT11 //Accept to update rx desc length
-#define RCR_APP_BA_SSN BIT6 //Accept BA SSN
-#define RCR_ACRC32 BIT5 //Accept CRC32 error packet
-#define RCR_RXSHFT_EN BIT4 //Accept broadcast packet
-#define RCR_AB BIT3 //Accept broadcast packet
-#define RCR_AM BIT2 //Accept multicast packet
-#define RCR_APM BIT1 //Accept physical match packet
-#define RCR_AAP BIT0 //Accept all unicast packet
-#define RCR_MXDMA_OFFSET 8
-#define RCR_FIFO_OFFSET 13
-
-#define RCR_ONLYERLPKT BIT31 // Early Receiving based on Packet Size.
-#define RCR_ENCS2 BIT30 // Enable Carrier Sense Detection Method 2
-#define RCR_ENCS1 BIT29 // Enable Carrier Sense Detection Method 1
-#define RCR_ACKTXBW (BIT24|BIT25) // TXBW Setting of ACK frames
-
-//----------------------------------------------------------------------------
-// 8192S (MSR) Media Status Register (Offset 0x4C, 8 bits)
-//----------------------------------------------------------------------------
-/*
-Network Type
-00: No link
-01: Link in ad hoc network
-10: Link in infrastructure network
-11: AP mode
-Default: 00b.
-*/
-#define MSR_NOLINK 0x00
-#define MSR_ADHOC 0x01
-#define MSR_INFRA 0x02
-#define MSR_AP 0x03
-
-//----------------------------------------------------------------------------
-// 8192S (SYSF_CFG) system Fucntion Config Reg (Offset 0x4D, 8 bits)
-//----------------------------------------------------------------------------
-#define ENUART BIT7
-#define ENJTAG BIT3
-#define BTMODE (BIT2|BIT1)
-#define ENBT BIT0
-
-//----------------------------------------------------------------------------
-// 8192S (MBIDCTRL) MBSSID Control Register (Offset 0x4F, 8 bits)
-//----------------------------------------------------------------------------
-#define ENMBID BIT7
-#define BCNUM (BIT6|BIT5|BIT4)
-
-//
-// 3. MACID Setting Registers (Offset: 0x0050 - 0x007F)
-//
-
-//
-// 4. Timing Control Registers (Offset: 0x0080 - 0x009F)
-//
-//----------------------------------------------------------------------------
-// 8192S (USTIME) US Time Tunning Register (Offset 0x8A, 16 bits)
-//----------------------------------------------------------------------------
-#define USTIME_EDCA 0xFF00
-#define USTIME_TSF 0x00FF
-
-//----------------------------------------------------------------------------
-// 8192S (SIFS_CCK/OFDM) US Time Tunning Register (Offset 0x8C/8E,16 bits)
-//----------------------------------------------------------------------------
-#define SIFS_TRX 0xFF00
-#define SIFS_CTX 0x00FF
-
-//----------------------------------------------------------------------------
-// 8192S (DRVERLYINT) Driver Early Interrupt Reg (Offset 0x98, 16bit)
-//----------------------------------------------------------------------------
-#define ENSWBCN BIT15
-#define DRVERLY_TU 0x0FF0
-#define DRVERLY_US 0x000F
-#define BCN_TCFG_CW_SHIFT 8
-#define BCN_TCFG_IFS 0
-
-//
-// 5. FIFO Control Registers (Offset: 0x00A0 - 0x015F)
-//
-
-//
-// 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF)
-//
-//----------------------------------------------------------------------------
-// 8192S Response Rate Set Register (offset 0x181, 24bits)
-//----------------------------------------------------------------------------
-#define RRSR_RSC_OFFSET 21
-#define RRSR_SHORT_OFFSET 23
-#define RRSR_RSC_BW_40M 0x600000
-#define RRSR_RSC_UPSUBCHNL 0x400000
-#define RRSR_RSC_LOWSUBCHNL 0x200000
-#define RRSR_SHORT 0x800000
-#define RRSR_1M BIT0
-#define RRSR_2M BIT1
-#define RRSR_5_5M BIT2
-#define RRSR_11M BIT3
-#define RRSR_6M BIT4
-#define RRSR_9M BIT5
-#define RRSR_12M BIT6
-#define RRSR_18M BIT7
-#define RRSR_24M BIT8
-#define RRSR_36M BIT9
-#define RRSR_48M BIT10
-#define RRSR_54M BIT11
-#define RRSR_MCS0 BIT12
-#define RRSR_MCS1 BIT13
-#define RRSR_MCS2 BIT14
-#define RRSR_MCS3 BIT15
-#define RRSR_MCS4 BIT16
-#define RRSR_MCS5 BIT17
-#define RRSR_MCS6 BIT18
-#define RRSR_MCS7 BIT19
-#define BRSR_AckShortPmb BIT23
-
-#define RRSR_RSC_UPSUBCHANL 0x200000
-// CCK ACK: use Short Preamble or not
-
-//----------------------------------------------------------------------------
-// 8192S Rate Definition
-//----------------------------------------------------------------------------
-//CCK
-#define RATR_1M 0x00000001
-#define RATR_2M 0x00000002
-#define RATR_55M 0x00000004
-#define RATR_11M 0x00000008
-//OFDM
-#define RATR_6M 0x00000010
-#define RATR_9M 0x00000020
-#define RATR_12M 0x00000040
-#define RATR_18M 0x00000080
-#define RATR_24M 0x00000100
-#define RATR_36M 0x00000200
-#define RATR_48M 0x00000400
-#define RATR_54M 0x00000800
-//MCS 1 Spatial Stream
-#define RATR_MCS0 0x00001000
-#define RATR_MCS1 0x00002000
-#define RATR_MCS2 0x00004000
-#define RATR_MCS3 0x00008000
-#define RATR_MCS4 0x00010000
-#define RATR_MCS5 0x00020000
-#define RATR_MCS6 0x00040000
-#define RATR_MCS7 0x00080000
-//MCS 2 Spatial Stream
-#define RATR_MCS8 0x00100000
-#define RATR_MCS9 0x00200000
-#define RATR_MCS10 0x00400000
-#define RATR_MCS11 0x00800000
-#define RATR_MCS12 0x01000000
-#define RATR_MCS13 0x02000000
-#define RATR_MCS14 0x04000000
-#define RATR_MCS15 0x08000000
-// ALL CCK Rate
-#define RATE_ALL_CCK RATR_1M|RATR_2M|RATR_55M|RATR_11M
-#define RATE_ALL_OFDM_AG RATR_6M|RATR_9M|RATR_12M|RATR_18M|RATR_24M|\
- RATR_36M|RATR_48M|RATR_54M
-#define RATE_ALL_OFDM_1SS RATR_MCS0|RATR_MCS1|RATR_MCS2|RATR_MCS3 |\
- RATR_MCS4|RATR_MCS5|RATR_MCS6 |RATR_MCS7
-#define RATE_ALL_OFDM_2SS RATR_MCS8|RATR_MCS9 |RATR_MCS10|RATR_MCS11|\
- RATR_MCS12|RATR_MCS13|RATR_MCS14|RATR_MCS15
-
-//
-// 7. EDCA Setting Registers (Offset: 0x01D0 - 0x01FF)
-//
-//----------------------------------------------------------------------------
-// 8192S EDCA Setting (offset 0x1D0-1DF, 4DW VO/VI/BE/BK)
-//----------------------------------------------------------------------------
-#define AC_PARAM_TXOP_LIMIT_OFFSET 16
-#define AC_PARAM_ECW_MAX_OFFSET 12
-#define AC_PARAM_ECW_MIN_OFFSET 8
-#define AC_PARAM_AIFS_OFFSET 0
-
-//----------------------------------------------------------------------------
-// 8192S AcmHwCtrl bits (offset 0x1E7, 1 byte)
-//----------------------------------------------------------------------------
-#define AcmHw_HwEn BIT0
-#define AcmHw_BeqEn BIT1
-#define AcmHw_ViqEn BIT2
-#define AcmHw_VoqEn BIT3
-#define AcmHw_BeqStatus BIT4
-#define AcmHw_ViqStatus BIT5
-#define AcmHw_VoqStatus BIT6
-
-//----------------------------------------------------------------------------
-// 8192S Retry Limit (Offset 0x1F4, 16bit)
-//----------------------------------------------------------------------------
-#define RETRY_LIMIT_SHORT_SHIFT 8
-#define RETRY_LIMIT_LONG_SHIFT 0
-
-//
-// 8. WMAC, BA and CCX related Register. (Offset: 0x0200 - 0x023F)
-//
-//----------------------------------------------------------------------------
-// 8192S NAV_CTRL bits (Offset 0x200, 24bit)
-//----------------------------------------------------------------------------
-#define NAV_UPPER_EN BIT16
-#define NAV_UPPER 0xFF00
-#define NAV_RTSRST 0xFF
-//----------------------------------------------------------------------------
-// 8192S BW_OPMODE bits (Offset 0x203, 8bit)
-//----------------------------------------------------------------------------
-#define BW_OPMODE_20MHZ BIT2
-#define BW_OPMODE_5G BIT1
-#define BW_OPMODE_11J BIT0
-//----------------------------------------------------------------------------
-// 8192S BW_OPMODE bits (Offset 0x230, 4 Byte)
-//----------------------------------------------------------------------------
-#define RXERR_RPT_RST BIT27 // Write "one" to set the counter to zero.
-// RXERR_RPT_SEL
-#define RXERR_OFDM_PPDU 0
-#define RXERR_OFDM_FALSE_ALARM 1
-#define RXERR_OFDM_MPDU_OK 2
-#define RXERR_OFDM_MPDU_FAIL 3
-#define RXERR_CCK_PPDU 4
-#define RXERR_CCK_FALSE_ALARM 5
-#define RXERR_CCK_MPDU_OK 6
-#define RXERR_CCK_MPDU_FAIL 7
-#define RXERR_HT_PPDU 8
-#define RXERR_HT_FALSE_ALARM 9
-#define RXERR_HT_MPDU_TOTAL 10
-#define RXERR_HT_MPDU_OK 11
-#define RXERR_HT_MPDU_FAIL 12
-#define RXERR_RX_FULL_DROP 15
-
-//
-// 9. Security Control Registers (Offset: 0x0240 - 0x025F)
-//
-//----------------------------------------------------------------------------
-// 8192S RWCAM CAM Command Register (offset 0x240, 4 byte)
-//----------------------------------------------------------------------------
-#define CAM_CM_SecCAMPolling BIT31 //Security CAM Polling
-#define CAM_CM_SecCAMClr BIT30 //Clear all bits in CAM
-#define CAM_CM_SecCAMWE BIT16 //Security CAM enable
-#define CAM_ADDR 0xFF //CAM Address Offset
-
-//----------------------------------------------------------------------------
-// 8192S CAMDBG Debug CAM Register (offset 0x24C, 4 byte)
-//----------------------------------------------------------------------------
-#define Dbg_CAM_TXSecCAMInfo BIT31 //Retrieve lastest Tx Info
-#define Dbg_CAM_SecKeyFound BIT30 //Security KEY Found
-
-
-//----------------------------------------------------------------------------
-// 8192S SECR Security Configuration Register (offset 0x250, 1 byte)
-//----------------------------------------------------------------------------
-#define SCR_TxUseDK BIT0 //Force Tx Use Default Key
-#define SCR_RxUseDK BIT1 //Force Rx Use Default Key
-#define SCR_TxEncEnable BIT2 //Enable Tx Encryption
-#define SCR_RxDecEnable BIT3 //Enable Rx Decryption
-#define SCR_SKByA2 BIT4 //Search kEY BY A2
-#define SCR_NoSKMC BIT5 //No Key Search Multicast
-//----------------------------------------------------------------------------
-// 8192S CAM Config Setting (offset 0x250, 1 byte)
-//----------------------------------------------------------------------------
-#define CAM_VALID BIT15
-#define CAM_NOTVALID 0x0000
-#define CAM_USEDK BIT5
-
-#define CAM_NONE 0x0
-#define CAM_WEP40 0x01
-#define CAM_TKIP 0x02
-#define CAM_AES 0x04
-#define CAM_WEP104 0x05
-
-#define TOTAL_CAM_ENTRY 32
-
-#define CAM_CONFIG_USEDK TRUE
-#define CAM_CONFIG_NO_USEDK FALSE
-
-#define CAM_WRITE BIT16
-#define CAM_READ 0x00000000
-#define CAM_POLLINIG BIT31
-
-#define SCR_UseDK 0x01
-#define SCR_TxSecEnable 0x02
-#define SCR_RxSecEnable 0x04
-
-//
-// 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF)
-//
-#define WOW_PMEN BIT0 // Power management Enable.
-#define WOW_WOMEN BIT1 // WoW function on or off.
-#define WOW_MAGIC BIT2 // Magic packet
-#define WOW_UWF BIT3 // Unicast Wakeup frame.
-
-//
-// 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)
-// 8192S GPIO Config Setting (offset 0x2F1, 1 byte)
-//----------------------------------------------------------------------------
-#define GPIOMUX_EN BIT3 // When this bit is set to "1", GPIO PINs will switch to MAC GPIO Function
-#define GPIOSEL_GPIO 0 // UART or JTAG or pure GPIO
-#define GPIOSEL_PHYDBG 1 // PHYDBG
-#define GPIOSEL_BT 2 // BT_coex
-#define GPIOSEL_WLANDBG 3 // WLANDBG
-#define GPIOSEL_GPIO_MASK ~(BIT0|BIT1)
-
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// PHY REG Access Report Register definition
-//----------------------------------------------------------------------------
-#define HST_RDBUSY BIT0
-#define CPU_WTBUSY BIT1
-
-//
-// 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F)
-//
-//----------------------------------------------------------------------------
-// 8190 IMR/ISR bits (offset 0xfd, 8bits)
-//----------------------------------------------------------------------------
-#define IMR8190_DISABLED 0x0
-
-// IMR DW1 Bit 0-31
-#define IMR_CPUERR BIT5 // CPU error interrupt
-#define IMR_ATIMEND BIT4 // ATIM Window End Interrupt
-#define IMR_TBDOK BIT3 // Transmit Beacon OK Interrupt
-#define IMR_TBDER BIT2 // Transmit Beacon Error Interrupt
-#define IMR_BCNDMAINT8 BIT1 // Beacon DMA Interrupt 8
-#define IMR_BCNDMAINT7 BIT0 // Beacon DMA Interrupt 7
-// IMR DW0 Bit 0-31
-
-#define IMR_BCNDMAINT6 BIT31 // Beacon DMA Interrupt 6
-#define IMR_BCNDMAINT5 BIT30 // Beacon DMA Interrupt 5
-#define IMR_BCNDMAINT4 BIT29 // Beacon DMA Interrupt 4
-#define IMR_BCNDMAINT3 BIT28 // Beacon DMA Interrupt 3
-#define IMR_BCNDMAINT2 BIT27 // Beacon DMA Interrupt 2
-#define IMR_BCNDMAINT1 BIT26 // Beacon DMA Interrupt 1
-#define IMR_BCNDOK8 BIT25 // Beacon Queue DMA OK Interrup 8
-#define IMR_BCNDOK7 BIT24 // Beacon Queue DMA OK Interrup 7
-#define IMR_BCNDOK6 BIT23 // Beacon Queue DMA OK Interrup 6
-#define IMR_BCNDOK5 BIT22 // Beacon Queue DMA OK Interrup 5
-#define IMR_BCNDOK4 BIT21 // Beacon Queue DMA OK Interrup 4
-#define IMR_BCNDOK3 BIT20 // Beacon Queue DMA OK Interrup 3
-#define IMR_BCNDOK2 BIT19 // Beacon Queue DMA OK Interrup 2
-#define IMR_BCNDOK1 BIT18 // Beacon Queue DMA OK Interrup 1
-#define IMR_TIMEOUT2 BIT17 // Timeout interrupt 2
-#define IMR_TIMEOUT1 BIT16 // Timeout interrupt 1
-#define IMR_TXFOVW BIT15 // Transmit FIFO Overflow
-#define IMR_PSTIMEOUT BIT14 // Power save time out interrupt
-#define IMR_BcnInt BIT13 // Beacon DMA Interrupt 0
-#define IMR_RXFOVW BIT12 // Receive FIFO Overflow
-#define IMR_RDU BIT11 // Receive Descriptor Unavailable
-#define IMR_RXCMDOK BIT10 // Receive Command Packet OK
-#define IMR_BDOK BIT9 // Beacon Queue DMA OK Interrup
-#define IMR_HIGHDOK BIT8 // High Queue DMA OK Interrupt
-#define IMR_COMDOK BIT7 // Command Queue DMA OK Interrupt
-#define IMR_MGNTDOK BIT6 // Management Queue DMA OK Interrupt
-#define IMR_HCCADOK BIT5 // HCCA Queue DMA OK Interrupt
-#define IMR_BKDOK BIT4 // AC_BK DMA OK Interrupt
-#define IMR_BEDOK BIT3 // AC_BE DMA OK Interrupt
-#define IMR_VIDOK BIT2 // AC_VI DMA OK Interrupt
-#define IMR_VODOK BIT1 // AC_VO DMA Interrupt
-#define IMR_ROK BIT0 // Receive DMA OK Interrupt
-
-//
-// 13. Test Mode and Debug Control Registers (Offset: 0x0310 - 0x034F)
-//
-
-//
-// 14. PCIE config register (Offset 0x500-)
-//
-//----------------------------------------------------------------------------
-// 8190 TPPool bits (offset 0xd9, 2 byte)
-//----------------------------------------------------------------------------
-#define TPPoll_BKQ BIT0 // BK queue polling
-#define TPPoll_BEQ BIT1 // BE queue polling
-#define TPPoll_VIQ BIT2 // VI queue polling
-#define TPPoll_VOQ BIT3 // VO queue polling
-#define TPPoll_BQ BIT4 // Beacon queue polling
-#define TPPoll_CQ BIT5 // Command queue polling
-#define TPPoll_MQ BIT6 // Management queue polling
-#define TPPoll_HQ BIT7 // High queue polling
-#define TPPoll_HCCAQ BIT8 // HCCA queue polling
-#define TPPoll_StopBK BIT9 // Stop BK queue
-#define TPPoll_StopBE BIT10 // Stop BE queue
-#define TPPoll_StopVI BIT11 // Stop VI queue
-#define TPPoll_StopVO BIT12 // Stop VO queue
-#define TPPoll_StopMgt BIT13 // Stop Mgnt queue
-#define TPPoll_StopHigh BIT14 // Stop High queue
-#define TPPoll_StopHCCA BIT15 // Stop HCCA queue
-#define TPPoll_SHIFT 8 // Queue ID mapping
-
-//----------------------------------------------------------------------------
-// 8192S PCIF (Offset 0x500, 32bit)
-//----------------------------------------------------------------------------
-#define MXDMA2_16bytes 0x000
-#define MXDMA2_32bytes 0x001
-#define MXDMA2_64bytes 0x010
-#define MXDMA2_128bytes 0x011
-#define MXDMA2_256bytes 0x100
-#define MXDMA2_512bytes 0x101
-#define MXDMA2_1024bytes 0x110
-#define MXDMA2_NoLimit 0x7
-
-#define MULRW_SHIFT 3
-#define MXDMA2_RX_SHIFT 4
-#define MXDMA2_TX_SHIFT 0
-
-//----------------------------------------------------------------------------
-// 8190 CCX_COMMAND_REG Setting (offset 0x25A, 1 byte)
-//----------------------------------------------------------------------------
-#define CCX_CMD_CLM_ENABLE BIT0 // Enable Channel Load
-#define CCX_CMD_NHM_ENABLE BIT1 // Enable Noise Histogram
-#define CCX_CMD_FUNCTION_ENABLE BIT8
-// CCX function (Channel Load/RPI/Noise Histogram).
-#define CCX_CMD_IGNORE_CCA BIT9
-// Treat CCA period as IDLE time for NHM.
-#define CCX_CMD_IGNORE_TXON BIT10
-// Treat TXON period as IDLE time for NHM.
-#define CCX_CLM_RESULT_READY BIT16
-// 1: Indicate the result of Channel Load is ready.
-#define CCX_NHM_RESULT_READY BIT16
-// 1: Indicate the result of Noise histogram is ready.
-#define CCX_CMD_RESET 0x0
-// Clear all the result of CCX measurement and disable the CCX function.
-
-
-//----------------------------------------------------------------------------
-// 8192S EFUSE
-//----------------------------------------------------------------------------
-//#define HWSET_MAX_SIZE_92S 128
-
-
-//----------------------------------------------------------------------------
-// 8192S EEPROM/EFUSE share register definition.
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// 8192S EEROM and Compatible E-Fuse definition. Added by Roger, 2008.10.21.
-//----------------------------------------------------------------------------
-#define RTL8190_EEPROM_ID 0x8129
-#define EEPROM_HPON 0x02 // LDO settings.
-#define EEPROM_VID 0x08 // USB Vendor ID.
-#define EEPROM_PID 0x0A // USB Product ID.
-#define EEPROM_USB_OPTIONAL 0x0C // For optional function.
-#define EEPROM_USB_PHY_PARA1 0x0D // For fine tune USB PHY.
-#define EEPROM_NODE_ADDRESS_BYTE_0 0x12 // MAC address.
-#define EEPROM_TxPowerDiff 0x1F
-
-#define EEPROM_Version 0x50
-#define EEPROM_ChannelPlan 0x51 // Map of supported channels.
-#define EEPROM_CustomID 0x52
-#define EEPROM_SubCustomID 0x53 // Reserved for customer use.
-
-
- // <Roger_Notes> The followin are for different version of EEPROM contents purpose. 2008.11.22.
-#define EEPROM_BoardType 0x54 //0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU
-#define EEPROM_TxPwIndex 0x55 //0x55-0x66, Tx Power index.
-#define EEPROM_PwDiff 0x67 // Difference of gain index between legacy and high throughput OFDM.
-#define EEPROM_ThermalMeter 0x68 // Thermal meter default value.
-#define EEPROM_CrystalCap 0x69 // Crystal Cap.
-#define EEPROM_TxPowerBase 0x6a // Tx Power of serving station.
-#define EEPROM_TSSI_A 0x6b //TSSI value of path A.
-#define EEPROM_TSSI_B 0x6c //TSSI value of path B.
-#define EEPROM_TxPwTkMode 0x6d //Tx Power tracking mode.
-//#define EEPROM_Reserved 0x6e //0x6e-0x7f, reserved.
-
-// 2009/02/09 Cosa Add for SD3 requirement
-#define EEPROM_TX_PWR_HT20_DIFF 0x6e// HT20 Tx Power Index Difference
-#define DEFAULT_HT20_TXPWR_DIFF 2 // HT20<->40 default Tx Power Index Difference
-#define EEPROM_TX_PWR_OFDM_DIFF 0x71// OFDM Tx Power Index Difference
-#define EEPROM_TX_PWR_BAND_EDGE 0x73// TX Power offset at band-edge channel
-#define TX_PWR_BAND_EDGE_CHK 0x79// Check if band-edge scheme is enabled
-#define EEPROM_Default_LegacyHTTxPowerDiff 0x3
-#define EEPROM_USB_Default_OPTIONAL_FUNC 0x8
-#define EEPROM_USB_Default_PHY_PARAM 0x0
-#define EEPROM_Default_TSSI 0x0
-#define EEPROM_Default_TxPwrTkMode 0x0
-#define EEPROM_Default_TxPowerDiff 0x0
-#define EEPROM_Default_TxPowerBase 0x0
-#define EEPROM_Default_ThermalMeter 0x7
-#define EEPROM_Default_PwDiff 0x4
-#define EEPROM_Default_CrystalCap 0x5
-#define EEPROM_Default_TxPower 0x1010
-#define EEPROM_Default_BoardType 0x02 // Default: 2X2, RTL8192SU(QFPN68)
-#define EEPROM_Default_HT2T_TxPwr 0x10
-#define EEPROM_USB_SN BIT0
-#define EEPROM_USB_REMOTE_WAKEUP BIT1
-#define EEPROM_USB_DEVICE_PWR BIT2
-#define EEPROM_EP_NUMBER (BIT3|BIT4)
-
-#define EEPROM_CHANNEL_PLAN_FCC 0x0
-#define EEPROM_CHANNEL_PLAN_IC 0x1
-#define EEPROM_CHANNEL_PLAN_ETSI 0x2
-#define EEPROM_CHANNEL_PLAN_SPAIN 0x3
-#define EEPROM_CHANNEL_PLAN_FRANCE 0x4
-#define EEPROM_CHANNEL_PLAN_MKK 0x5
-#define EEPROM_CHANNEL_PLAN_MKK1 0x6
-#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7
-#define EEPROM_CHANNEL_PLAN_TELEC 0x8
-#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMAIN 0x9
-#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA
-#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80
-#define EEPROM_CID_DEFAULT 0x0
-#define EEPROM_CID_ALPHA 0x1
-#define EEPROM_CID_Senao 0x3
-#define EEPROM_CID_CAMEO 0X8
-#define EEPROM_CID_SITECOM 0x9
-#define EEPROM_CID_COREGA 0xB
-#define EEPROM_CID_EDIMAX_BELKIN 0xC
-#define EEPROM_CID_SERCOMM_BELKIN 0xE
-#define EEPROM_CID_CAMEO1 0xF
-#define EEPROM_CID_WHQL 0xFE
-#define EEPROM_CID_NetCore 0x5
-
-
-//-----------------------------------------------------------------
-// 0x2c0 FW Command Control register definition, added by Roger, 2008.11.27.
-//-----------------------------------------------------------------
-#define FW_DIG_DISABLE 0xfd00cc00
-#define FW_DIG_ENABLE 0xfd000000
-#define FW_DIG_HALT 0xfd000001
-#define FW_DIG_RESUME 0xfd000002
-#define FW_HIGH_PWR_DISABLE 0xfd000008
-#define FW_HIGH_PWR_ENABLE 0xfd000009
-#define FW_TXPWR_TRACK_ENABLE 0xfd000017
-#define FW_TXPWR_TRACK_DISABLE 0xfd000018
-#define FW_TXPWR_TRACK_THERMAL 0xfd000019
-#define FW_RA_INIT 0xfd000026
-#define FW_RA_IOT_BG_COMB 0xfd000030
-#define FW_RA_IOT_N_COMB 0xfd000031
-#define FW_RA_REFRESH 0xfd0000a0
-#define FW_RA_DISABLE 0xfd0000a4
-#define FW_RA_ACTIVE 0xfd0000a6
-#define FW_RA_DISABLE_RSSI_MASK 0xfd0000ac
-#define FW_RA_ENABLE_RSSI_MASK 0xfd0000ad
-#define FW_RA_RESET 0xfd0000af
-#define FW_DM_DISABLE 0xfd00aa00
-#define FW_IQK_ENABLE 0xf0000020
-#define FW_IQK_SUCCESS 0x0000dddd
-#define FW_IQK_FAIL 0x0000ffff
-#define FW_OP_FAILURE 0xffffffff
-#define FW_TX_FEEDBACK_NONE 0xfb000000
-#define FW_TX_FEEDBACK_DTM_ENABLE (FW_TX_FEEDBACK_NONE | 0x1)
-#define FW_TX_FEEDBACK_CCX_ENABLE (FW_TX_FEEDBACK_NONE | 0x2)
-#define FW_BB_RESET_ENABLE 0xff00000d
-#define FW_BB_RESET_DISABLE 0xff00000e
-#define FW_LPS_ENTER 0xfe000010
-#define FW_LPS_LEAVE 0xfe000011
-#define FW_INDIRECT_READ 0xf2000000
-#define FW_INDIRECT_WRITE 0xf2000001
-#define FW_TXANT_SWITCH_ENABLE 0xfd000023
-#define FW_TXANT_SWITCH_DISABLE 0xfd000024
-//
-//--------------92SU require delete or move to other place later
-//
-
-
-
-//
-//
-// 2008/08/06 MH For share the same 92S source/header files, we copy some
-// definition to pass 92SU compiler. But we must delete thm later.
-//
-//
-
-//============================================================================
-// 819xUsb Regsiter offset definition
-//============================================================================
-
-//2 define it temp!!!
-#define RFPC 0x5F // Rx FIFO Packet Count
-#define RCR_9356SEL BIT6
-#define TCR_LRL_OFFSET 0
-#define TCR_SRL_OFFSET 8
-#define TCR_MXDMA_OFFSET 21
-#define TCR_MXDMA_2048 7
-#define TCR_SAT BIT24 // Enable Rate depedent ack timeout timer
-#define RCR_MXDMA_OFFSET 8
-#define RCR_FIFO_OFFSET 13
-#define RCR_OnlyErlPkt BIT31 // Rx Early mode is performed for packet size greater than 1536
-#define CWR 0xDC // Contention window register
-#define RetryCTR 0xDE // Retry Count register
-
-
-// For backward compatible for 9xUSB
-#define LED1Cfg UnusedRegister // LED1 Configuration Register
-#define LED0Cfg UnusedRegister // LED0 Configuration Register
-#define GPI UnusedRegister // LED0 Configuration Register
-#define BRSR UnusedRegister // LED0 Configuration Register
-#define CPU_GEN UnusedRegister // LED0 Configuration Register
-#define SIFS UnusedRegister // LED0 Configuration Register
-
-//----------------------------------------------------------------------------
-// 8190 CPU General Register (offset 0x100, 4 byte)
-//----------------------------------------------------------------------------
-//#define CPU_CCK_LOOPBACK 0x00030000
-#define CPU_GEN_SYSTEM_RESET 0x00000001
-//#define CPU_GEN_FIRMWARE_RESET 0x00000008
-//#define CPU_GEN_BOOT_RDY 0x00000010
-//#define CPU_GEN_FIRM_RDY 0x00000020
-//#define CPU_GEN_PUT_CODE_OK 0x00000080
-//#define CPU_GEN_BB_RST 0x00000100
-//#define CPU_GEN_PWR_STB_CPU 0x00000004
-//#define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF // Set bit18,17,16 to 0. Set bit19
-//#define CPU_GEN_NO_LOOPBACK_SET 0x00080000 // Set BIT19 to 1
-
-//----------------------------------------------------------------------------
-// 8192S EEROM
-//----------------------------------------------------------------------------
-
-//#define RTL8190_EEPROM_ID 0x8129
-//#define EEPROM_VID 0x08
-//#define EEPROM_PID 0x0A
-//#define EEPROM_USB_OPTIONAL 0x0C
-//#define EEPROM_NODE_ADDRESS_BYTE_0 0x12
-//
-//#define EEPROM_TxPowerDiff 0x1F
-//#define EEPROM_ThermalMeter 0x20
-//#define EEPROM_PwDiff 0x21 //0x21
-//#define EEPROM_CrystalCap 0x22 //0x22
-//
-//#define EEPROM_TxPwIndex_CCK 0x23 //0x23
-//#define EEPROM_TxPwIndex_OFDM_24G 0x24 //0x24~0x26
-#define EEPROM_TxPwIndex_CCK_V1 0x29 //0x29~0x2B
-#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C //0x2C~0x2E
-#define EEPROM_TxPwIndex_Ver 0x27 //0x27
-//
-//#define EEPROM_Default_TxPowerDiff 0x0
-//#define EEPROM_Default_ThermalMeter 0x7
-//#define EEPROM_Default_PwDiff 0x4
-//#define EEPROM_Default_CrystalCap 0x5
-//#define EEPROM_Default_TxPower 0x1010
-//#define EEPROM_Customer_ID 0x7B //0x7B:CustomerID
-//#define EEPROM_Version 0x50 // 0x50
-//#define EEPROM_CustomID 0x52
-//#define EEPROM_ChannelPlan 0x7c //0x7C
-//#define EEPROM_IC_VER 0x7d //0x7D
-//#define EEPROM_CRC 0x7e //0x7E~0x7F
-//
-//
-//#define EEPROM_CID_DEFAULT 0x0
-//#define EEPROM_CID_CAMEO 0x1
-//#define EEPROM_CID_RUNTOP 0x2
-//#define EEPROM_CID_Senao 0x3
-//#define EEPROM_CID_TOSHIBA 0x4 // Toshiba setting, Merge by Jacken, 2008/01/31
-//#define EEPROM_CID_NetCore 0x5
-
-
-//
-//--------------92SU require delete or move to other place later
-//
-
-//============================================================
-// CCX Related Register
-//============================================================
-#define CCX_COMMAND_REG 0x890
-// CCX Measurement Command Register. 4 Bytes.
-// Bit[0]: R_CLM_En, 1=enable, 0=disable. Enable or disable "Channel Load
-// Measurement (CLM)".
-// Bit[1]: R_NHM_En, 1=enable, 0=disable. Enable or disalbe "Noise Histogram
-// Measurement (NHM)".
-// Bit[2~7]: Reserved
-// Bit[8]: R_CCX_En: 1=enable, 0=disable. Enable or disable CCX function.
-// Note: After clearing this bit, all the result of all NHM_Result and CLM_
-// Result are cleared concurrently.
-// Bit[9]: R_Ignore_CCA: 1=enable, 0=disable. Enable means that treat CCA
-// period as idle time for NHM.
-// Bit[10]: R_Ignore_TXON: 1=enable, 0=disable. Enable means that treat TXON
-// period as idle time for NHM.
-// Bit[11~31]: Reserved.
-#define CLM_PERIOD_REG 0x894
-// CCX Measurement Period Register, in unit of 4us. 2 Bytes.
-#define NHM_PERIOD_REG 0x896
-// Noise Histogram Measurement Period Register, in unit of 4us. 2Bytes.
-#define NHM_THRESHOLD0 0x898 // Noise Histogram Meashorement0
-#define NHM_THRESHOLD1 0x899 // Noise Histogram Meashorement1
-#define NHM_THRESHOLD2 0x89A // Noise Histogram Meashorement2
-#define NHM_THRESHOLD3 0x89B // Noise Histogram Meashorement3
-#define NHM_THRESHOLD4 0x89C // Noise Histogram Meashorement4
-#define NHM_THRESHOLD5 0x89D // Noise Histogram Meashorement5
-#define NHM_THRESHOLD6 0x89E // Noise Histogram Meashorement6
-#define CLM_RESULT_REG 0x8D0
-// Channel Load result register. 4 Bytes.
-// Bit[0~15]: Total measured duration of CLM. The CCA busy fraction is caculate
-// by CLM_RESULT_REG/CLM_PERIOD_REG.
-// Bit[16]: Indicate the CLM result is ready.
-// Bit[17~31]: Reserved.
-#define NHM_RESULT_REG 0x8D4
-// Noise Histogram result register. 4 Bytes.
-// Bit[0~15]: Total measured duration of NHM. If R_Ignore_CCA=1 or
-// R_Ignore_TXON=1, this value will be less than NHM_PERIOD_REG.
-// Bit[16]: Indicate the NHM result is ready.
-// Bit[17~31]: Reserved.
-#define NHM_RPI_COUNTER0 0x8D8
-// NHM RPI counter0, the fraction of signal strength < NHM_THRESHOLD0.
-#define NHM_RPI_COUNTER1 0x8D9
-// NHM RPI counter1, the fraction of signal stren in NHM_THRESH0, NHM_THRESH1
-#define NHM_RPI_COUNTER2 0x8DA
-// NHM RPI counter2, the fraction of signal stren in NHM_THRESH2, NHM_THRESH3
-#define NHM_RPI_COUNTER3 0x8DB
-// NHM RPI counter3, the fraction of signal stren in NHM_THRESH4, NHM_THRESH5
-#define NHM_RPI_COUNTER4 0x8DC
-// NHM RPI counter4, the fraction of signal stren in NHM_THRESH6, NHM_THRESH7
-#define NHM_RPI_COUNTER5 0x8DD
-// NHM RPI counter5, the fraction of signal stren in NHM_THRESH8, NHM_THRESH9
-#define NHM_RPI_COUNTER6 0x8DE
-// NHM RPI counter6, the fraction of signal stren in NHM_THRESH10, NHM_THRESH11
-#define NHM_RPI_COUNTER7 0x8DF
-// NHM RPI counter7, the fraction of signal stren in NHM_THRESH12, NHM_THRESH13
-
-#define HAL_RETRY_LIMIT_INFRA 48
-#define HAL_RETRY_LIMIT_AP_ADHOC 7
-
-// HW Readio OFF switch (GPIO BIT)
-#define HAL_8192S_HW_GPIO_OFF_BIT BIT3
-#define HAL_8192S_HW_GPIO_OFF_MASK 0xF7
-#define HAL_8192S_HW_GPIO_WPS_BIT BIT4
-
-#endif
diff --git a/drivers/staging/rtl8192su/r8192S_phy.c b/drivers/staging/rtl8192su/r8192S_phy.c
deleted file mode 100644
index a5fc2d1cb062..000000000000
--- a/drivers/staging/rtl8192su/r8192S_phy.c
+++ /dev/null
@@ -1,3634 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "r8192U.h"
-#include "r8192U_dm.h"
-#include "r8192S_rtl6052.h"
-
-#include "r8192S_hw.h"
-#include "r8192S_phy.h"
-#include "r8192S_phyreg.h"
-#include "r8192SU_HWImg.h"
-
-#include "ieee80211/dot11d.h"
-
-/* Channel switch:The size of command tables for switch channel*/
-#define MAX_PRECMD_CNT 16
-#define MAX_RFDEPENDCMD_CNT 16
-#define MAX_POSTCMD_CNT 16
-#define MAX_DOZE_WAITING_TIMES_9x 64
-
-static u32
-phy_CalculateBitShift(u32 BitMask);
-static RT_STATUS
-phy_ConfigMACWithHeaderFile(struct net_device* dev);
-static void
-phy_InitBBRFRegisterDefinition(struct net_device* dev);
-static RT_STATUS
-phy_BB8192S_Config_ParaFile(struct net_device* dev);
-static RT_STATUS
-phy_ConfigBBWithHeaderFile(struct net_device* dev,u8 ConfigType);
-static bool
-phy_SetRFPowerState8192SU(struct net_device* dev,RT_RF_POWER_STATE eRFPowerState);
-void
-SetBWModeCallback8192SUsbWorkItem(struct net_device *dev);
-void
-SetBWModeCallback8192SUsbWorkItem(struct net_device *dev);
-void
-SwChnlCallback8192SUsbWorkItem(struct net_device *dev );
-static void
-phy_FinishSwChnlNow(struct net_device* dev,u8 channel);
-static bool
-phy_SwChnlStepByStep(
- struct net_device* dev,
- u8 channel,
- u8 *stage,
- u8 *step,
- u32 *delay
- );
-static RT_STATUS
-phy_ConfigBBWithPgHeaderFile(struct net_device* dev,u8 ConfigType);
-static long phy_TxPwrIdxToDbm( struct net_device* dev, WIRELESS_MODE WirelessMode, u8 TxPwrIdx);
-static u8 phy_DbmToTxPwrIdx( struct net_device* dev, WIRELESS_MODE WirelessMode, long PowerInDbm);
-void phy_SetFwCmdIOCallback(struct net_device* dev);
-
-//
-// Description:
-// Base Band read by 4181 to make sure that operation could be done in unlimited cycle.
-//
-// Assumption:
-// - Only use on RTL8192S USB interface.
-// - PASSIVE LEVEL
-//
-//use in phy only
-u32 phy_QueryUsbBBReg(struct net_device* dev, u32 RegAddr)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 ReturnValue = 0xffffffff;
- u8 PollingCnt = 50;
- u8 BBWaitCounter = 0;
-
-
- //
- // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
- // We have to make sure that previous BB I/O has been done.
- // 2008.08.20.
- //
- while(priv->bChangeBBInProgress)
- {
- BBWaitCounter ++;
- RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): Wait 1 ms (%d times)...\n", BBWaitCounter);
- msleep(1); // 1 ms
-
- // Wait too long, return FALSE to avoid to be stuck here.
- if((BBWaitCounter > 100) )
- {
- RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): (%d) Wait too logn to query BB!!\n", BBWaitCounter);
- return ReturnValue;
- }
- }
-
- priv->bChangeBBInProgress = true;
-
- read_nic_dword(dev, RegAddr);
-
- do
- {// Make sure that access could be done.
- if((read_nic_byte(dev, PHY_REG)&HST_RDBUSY) == 0)
- break;
- }while( --PollingCnt );
-
- if(PollingCnt == 0)
- {
- RT_TRACE(COMP_RF, "Fail!!!phy_QueryUsbBBReg(): RegAddr(%#x) = %#x\n", RegAddr, ReturnValue);
- }
- else
- {
- // Data FW read back.
- ReturnValue = read_nic_dword(dev, PHY_REG_DATA);
- RT_TRACE(COMP_RF, "phy_QueryUsbBBReg(): RegAddr(%#x) = %#x, PollingCnt(%d)\n", RegAddr, ReturnValue, PollingCnt);
- }
-
- priv->bChangeBBInProgress = false;
-
- return ReturnValue;
-}
-
-
-
-//
-// Description:
-// Base Band wrote by 4181 to make sure that operation could be done in unlimited cycle.
-//
-// Assumption:
-// - Only use on RTL8192S USB interface.
-// - PASSIVE LEVEL
-//use in phy only
-void
-phy_SetUsbBBReg(struct net_device* dev,u32 RegAddr,u32 Data)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 BBWaitCounter = 0;
-
- RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): RegAddr(%#x) <= %#x\n", RegAddr, Data);
-
- //
- // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
- // We have to make sure that previous BB I/O has been done.
- // 2008.08.20.
- //
- while(priv->bChangeBBInProgress)
- {
- BBWaitCounter ++;
- RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): Wait 1 ms (%d times)...\n", BBWaitCounter);
- msleep(1); // 1 ms
-
- if((BBWaitCounter > 100))// || RT_USB_CANNOT_IO(Adapter))
- {
- RT_TRACE(COMP_RF, "phy_SetUsbBBReg(): (%d) Wait too logn to query BB!!\n", BBWaitCounter);
- return;
- }
- }
-
- priv->bChangeBBInProgress = true;
- write_nic_dword(dev, RegAddr, Data);
-
- priv->bChangeBBInProgress = false;
-}
-
-
-
-//
-// Description:
-// RF read by 4181 to make sure that operation could be done in unlimited cycle.
-//
-// Assumption:
-// - Only use on RTL8192S USB interface.
-// - PASSIVE LEVEL
-// - RT_RF_OPERATE_SPINLOCK is acquired and keep on holding to the end.FIXLZM
-//
-// Created by Roger, 2008.09.06.
-//
-//use in phy only
-u32 phy_QueryUsbRFReg( struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 ReturnValue = 0;
- u8 PollingCnt = 50;
- u8 RFWaitCounter = 0;
-
-
- //
- // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
- // We have to make sure that previous RF I/O has been done.
- // 2008.08.20.
- //
- while(priv->bChangeRFInProgress)
- {
- down(&priv->rf_sem);
-
- RFWaitCounter ++;
- RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): Wait 1 ms (%d times)...\n", RFWaitCounter);
- msleep(1); // 1 ms
-
- if((RFWaitCounter > 100)) //|| RT_USB_CANNOT_IO(Adapter))
- {
- RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): (%d) Wait too logn to query BB!!\n", RFWaitCounter);
- return 0xffffffff;
- }
- else
- {
- }
- }
-
- priv->bChangeRFInProgress = true;
- Offset &= 0x3f; //RF_Offset= 0x00~0x3F
-
- write_nic_dword(dev, RF_BB_CMD_ADDR, 0xF0000002|
- (Offset<<8)| //RF_Offset= 0x00~0x3F
- (eRFPath<<16)); //RF_Path = 0(A) or 1(B)
-
- do
- {// Make sure that access could be done.
- if(read_nic_dword(dev, RF_BB_CMD_ADDR) == 0)
- break;
- }while( --PollingCnt );
-
- // Data FW read back.
- ReturnValue = read_nic_dword(dev, RF_BB_CMD_DATA);
-
- up(&priv->rf_sem);
- priv->bChangeRFInProgress = false;
-
- RT_TRACE(COMP_RF, "phy_QueryUsbRFReg(): eRFPath(%d), Offset(%#x) = %#x\n", eRFPath, Offset, ReturnValue);
-
- return ReturnValue;
-
-}
-
-
-//
-// Description:
-// RF wrote by 4181 to make sure that operation could be done in unlimited cycle.
-//
-// Assumption:
-// - Only use on RTL8192S USB interface.
-// - PASSIVE LEVEL
-// - RT_RF_OPERATE_SPINLOCK is acquired and keep on holding to the end.FIXLZM
-//
-// Created by Roger, 2008.09.06.
-//
-//use in phy only
-void phy_SetUsbRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath,u32 RegAddr,u32 Data)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 PollingCnt = 50;
- u8 RFWaitCounter = 0;
-
-
- //
- // <Roger_Notes> Due to PASSIVE_LEVEL, so we ONLY simply busy waiting for a while here.
- // We have to make sure that previous BB I/O has been done.
- // 2008.08.20.
- //
- while(priv->bChangeRFInProgress)
- {
- down(&priv->rf_sem);
-
- RFWaitCounter ++;
- RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): Wait 1 ms (%d times)...\n", RFWaitCounter);
- msleep(1); // 1 ms
-
- if((RFWaitCounter > 100))
- {
- RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): (%d) Wait too logn to query BB!!\n", RFWaitCounter);
- return;
- }
- else
- {
- }
- }
-
- priv->bChangeRFInProgress = true;
-
-
- RegAddr &= 0x3f; //RF_Offset= 0x00~0x3F
-
- write_nic_dword(dev, RF_BB_CMD_DATA, Data);
- write_nic_dword(dev, RF_BB_CMD_ADDR, 0xF0000003|
- (RegAddr<<8)| //RF_Offset= 0x00~0x3F
- (eRFPath<<16)); //RF_Path = 0(A) or 1(B)
-
- do
- {// Make sure that access could be done.
- if(read_nic_dword(dev, RF_BB_CMD_ADDR) == 0)
- break;
- }while( --PollingCnt );
-
- if(PollingCnt == 0)
- {
- RT_TRACE(COMP_RF, "phy_SetUsbRFReg(): Set RegAddr(%#x) = %#x Fail!!!\n", RegAddr, Data);
- }
-
- up(&priv->rf_sem);
- priv->bChangeRFInProgress = false;
-
-}
-
-//
-// 1. BB register R/W API
-//
-/**
-* Function: PHY_QueryBBReg
-*
-* OverView: Read "sepcific bits" from BB register
-*
-* Input:
-* PADAPTER Adapter,
-* u32 RegAddr, //The target address to be readback
-* u32 BitMask //The target bit position in the target address
-* //to be readback
-* Output: None
-* Return: u32 Data //The readback register value
-* Note: This function is equal to "GetRegSetting" in PHY programming guide
-*/
-u32 rtl8192_QueryBBReg(struct net_device* dev, u32 RegAddr, u32 BitMask)
-{
-
- u32 ReturnValue = 0, OriginalValue, BitShift;
-
-
- RT_TRACE(COMP_RF, "--->PHY_QueryBBReg(): RegAddr(%#x), BitMask(%#x)\n", RegAddr, BitMask);
-
- //
- // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
- // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
- // infinite cycle.
- // 2008.09.06.
- //
- if(IS_BB_REG_OFFSET_92S(RegAddr))
- {
-
- if((RegAddr & 0x03) != 0)
- {
- printk("%s: Not DWORD alignment!!\n", __FUNCTION__);
- return 0;
- }
-
- OriginalValue = phy_QueryUsbBBReg(dev, RegAddr);
- }
- else
- {
- OriginalValue = read_nic_dword(dev, RegAddr);
- }
-
- BitShift = phy_CalculateBitShift(BitMask);
- ReturnValue = (OriginalValue & BitMask) >> BitShift;
-
-
- RT_TRACE(COMP_RF, "<---PHY_QueryBBReg(): RegAddr(%#x), BitMask(%#x), OriginalValue(%#x)\n", RegAddr, BitMask, OriginalValue);
- return (ReturnValue);
-}
-
-/**
-* Function: PHY_SetBBReg
-*
-* OverView: Write "Specific bits" to BB register (page 8~)
-*
-* Input:
-* PADAPTER Adapter,
-* u32 RegAddr, //The target address to be modified
-* u32 BitMask //The target bit position in the target address
-* //to be modified
-* u32 Data //The new register value in the target bit position
-* //of the target address
-*
-* Output: None
-* Return: None
-* Note: This function is equal to "PutRegSetting" in PHY programming guide
-*/
-void rtl8192_setBBreg(struct net_device* dev, u32 RegAddr, u32 BitMask, u32 Data)
-{
- u32 OriginalValue, BitShift, NewValue;
-
-
- RT_TRACE(COMP_RF, "--->PHY_SetBBReg(): RegAddr(%#x), BitMask(%#x), Data(%#x)\n", RegAddr, BitMask, Data);
-
- //
- // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
- // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
- // infinite cycle.
- // 2008.09.06.
- //
- if(IS_BB_REG_OFFSET_92S(RegAddr))
- {
- if((RegAddr & 0x03) != 0)
- {
- printk("%s: Not DWORD alignment!!\n", __FUNCTION__);
- return;
- }
-
- if(BitMask!= bMaskDWord)
- {//if not "double word" write
- OriginalValue = phy_QueryUsbBBReg(dev, RegAddr);
- BitShift = phy_CalculateBitShift(BitMask);
- NewValue = (((OriginalValue) & (~BitMask))|(Data << BitShift));
- phy_SetUsbBBReg(dev, RegAddr, NewValue);
- }else
- phy_SetUsbBBReg(dev, RegAddr, Data);
- }
- else
- {
- if(BitMask!= bMaskDWord)
- {//if not "double word" write
- OriginalValue = read_nic_dword(dev, RegAddr);
- BitShift = phy_CalculateBitShift(BitMask);
- NewValue = (((OriginalValue) & (~BitMask)) | (Data << BitShift));
- write_nic_dword(dev, RegAddr, NewValue);
- }else
- write_nic_dword(dev, RegAddr, Data);
- }
-
-
- return;
-}
-
-
-//
-// 2. RF register R/W API
-//
-/**
-* Function: PHY_QueryRFReg
-*
-* OverView: Query "Specific bits" to RF register (page 8~)
-*
-* Input:
-* PADAPTER Adapter,
-* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
-* u32 RegAddr, //The target address to be read
-* u32 BitMask //The target bit position in the target address
-* //to be read
-*
-* Output: None
-* Return: u32 Readback value
-* Note: This function is equal to "GetRFRegSetting" in PHY programming guide
-*/
-u32 rtl8192_phy_QueryRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask)
-{
- u32 Original_Value, Readback_Value, BitShift;//, flags;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-
- RT_TRACE(COMP_RF, "--->PHY_QueryRFReg(): RegAddr(%#x), eRFPath(%#x), BitMask(%#x)\n", RegAddr, eRFPath,BitMask);
-
- if (!((priv->rf_pathmap >> eRFPath) & 0x1))
- {
- printk("EEEEEError: rfpath off! rf_pathmap=%x eRFPath=%x\n", priv->rf_pathmap, eRFPath);
- return 0;
- }
-
- if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
- {
- printk("EEEEEError: not legal rfpath! eRFPath=%x\n", eRFPath);
- return 0;
- }
-
- down(&priv->rf_sem);
- //
- // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
- // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
- // infinite cycle.
- // 2008.09.06.
- //
- Original_Value = phy_QueryUsbRFReg(dev, eRFPath, RegAddr);
-
- BitShift = phy_CalculateBitShift(BitMask);
- Readback_Value = (Original_Value & BitMask) >> BitShift;
- up(&priv->rf_sem);
-
- return (Readback_Value);
-}
-
-/**
-* Function: PHY_SetRFReg
-*
-* OverView: Write "Specific bits" to RF register (page 8~)
-*
-* Input:
-* PADAPTER Adapter,
-* RF90_RADIO_PATH_E eRFPath, //Radio path of A/B/C/D
-* u32 RegAddr, //The target address to be modified
-* u32 BitMask //The target bit position in the target address
-* //to be modified
-* u32 Data //The new register Data in the target bit position
-* //of the target address
-*
-* Output: None
-* Return: None
-* Note: This function is equal to "PutRFRegSetting" in PHY programming guide
-*/
-void rtl8192_phy_SetRFReg(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 Original_Value, BitShift, New_Value;//, flags;
-
- RT_TRACE(COMP_RF, "--->PHY_SetRFReg(): RegAddr(%#x), BitMask(%#x), Data(%#x), eRFPath(%#x)\n",
- RegAddr, BitMask, Data, eRFPath);
-
- if (!((priv->rf_pathmap >> eRFPath) & 0x1))
- {
- printk("EEEEEError: rfpath off! rf_pathmap=%x eRFPath=%x\n", priv->rf_pathmap, eRFPath);
- return ;
- }
- if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
- {
- printk("EEEEEError: not legal rfpath! eRFPath=%x\n", eRFPath);
- return;
- }
-
- down(&priv->rf_sem);
- //
- // <Roger_Notes> Due to 8051 operation cycle (limitation cycle: 6us) and 1-Byte access issue, we should use
- // 4181 to access Base Band instead of 8051 on USB interface to make sure that access could be done in
- // infinite cycle.
-
- if (BitMask != bRFRegOffsetMask) // RF data is 12 bits only
- {
- Original_Value = phy_QueryUsbRFReg(dev, eRFPath, RegAddr);
- BitShift = phy_CalculateBitShift(BitMask);
- New_Value = (((Original_Value)&(~BitMask))|(Data<< BitShift));
- phy_SetUsbRFReg(dev, eRFPath, RegAddr, New_Value);
- }
- else
- phy_SetUsbRFReg(dev, eRFPath, RegAddr, Data);
- up(&priv->rf_sem);
- RT_TRACE(COMP_RF, "<---PHY_SetRFReg(): RegAddr(%#x), BitMask(%#x), Data(%#x), eRFPath(%#x)\n",
- RegAddr, BitMask, Data, eRFPath);
-
-}
-
-/**
-* Function: phy_CalculateBitShift
-*
-* OverView: Get shifted position of the BitMask
-*
-* Input:
-* u32 BitMask,
-*
-* Output: none
-* Return: u32 Return the shift bit bit position of the mask
-*/
-//use in phy only
-static u32 phy_CalculateBitShift(u32 BitMask)
-{
- u32 i;
-
- for(i=0; i<=31; i++)
- {
- if ( ((BitMask>>i) & 0x1 ) == 1)
- break;
- }
-
- return (i);
-}
-
-
-//
-// 3. Initial MAC/BB/RF config by reading MAC/BB/RF txt.
-//
-/*-----------------------------------------------------------------------------
- * Function: PHY_MACConfig8192S
- *
- * Overview: Condig MAC by header file or parameter file.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 08/12/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-//adapter_start
-extern bool PHY_MACConfig8192S(struct net_device* dev)
-{
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
-
- //
- // Config MAC
- //
- rtStatus = phy_ConfigMACWithHeaderFile(dev);
- return (rtStatus == RT_STATUS_SUCCESS) ? true:false;
-
-}
-
-//adapter_start
-extern bool
-PHY_BBConfig8192S(struct net_device* dev)
-{
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
-
- u8 PathMap = 0, index = 0, rf_num = 0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- phy_InitBBRFRegisterDefinition(dev);
-
-
- rtStatus = phy_BB8192S_Config_ParaFile(dev);
-
- PathMap = (u8)(rtl8192_QueryBBReg(dev, rFPGA0_TxInfo, 0xf) |
- rtl8192_QueryBBReg(dev, rOFDM0_TRxPathEnable, 0xf));
- priv->rf_pathmap = PathMap;
- for(index = 0; index<4; index++)
- {
- if((PathMap>>index)&0x1)
- rf_num++;
- }
-
- if((priv->rf_type==RF_1T1R && rf_num!=1) ||
- (priv->rf_type==RF_1T2R && rf_num!=2) ||
- (priv->rf_type==RF_2T2R && rf_num!=2) ||
- (priv->rf_type==RF_2T2R_GREEN && rf_num!=2) ||
- (priv->rf_type==RF_2T4R && rf_num!=4))
- {
- RT_TRACE( COMP_INIT, "PHY_BBConfig8192S: RF_Type(%x) does not match RF_Num(%x)!!\n", priv->rf_type, rf_num);
- }
- return (rtStatus == RT_STATUS_SUCCESS) ? 1:0;
-}
-
-//adapter_start
-extern bool
-PHY_RFConfig8192S(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
-
- //Set priv->rf_chip = RF_8225 to do real PHY FPGA initilization
-
- //<Roger_EXP> We assign RF type here temporally. 2008.09.12.
- priv->rf_chip = RF_6052;
-
- //
- // RF config
- //
- switch(priv->rf_chip)
- {
- case RF_8225:
- case RF_6052:
- rtStatus = PHY_RF6052_Config(dev);
- break;
-
- case RF_8256:
- //rtStatus = PHY_RF8256_Config(dev);
- break;
-
- case RF_8258:
- break;
-
- case RF_PSEUDO_11N:
- //rtStatus = PHY_RF8225_Config(dev);
- break;
- default:
- break;
- }
-
- return (rtStatus == RT_STATUS_SUCCESS) ? 1:0;
-}
-
-
-#ifdef TO_DO_LIST
-static RT_STATUS
-phy_BB8190_Config_HardCode(struct net_device* dev)
-{
- return RT_STATUS_SUCCESS;
-}
-#endif
-
-/*-----------------------------------------------------------------------------
- * Function: phy_SetBBtoDiffRFWithHeaderFile()
- *
- * Overview: This function
- *
- *
- * Input: PADAPTER Adapter
- * u1Byte ConfigType 0 => PHY_CONFIG
- *
- * Output: NONE
- *
- * Return: RT_STATUS_SUCCESS: configuration file exist
- * When Who Remark
- * 2008/11/10 tynli
- * use in phy only
- *---------------------------------------------------------------------------*/
-static RT_STATUS
-phy_SetBBtoDiffRFWithHeaderFile(struct net_device* dev, u8 ConfigType)
-{
- int i;
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32* Rtl819XPHY_REGArraytoXTXR_Table;
- u16 PHY_REGArraytoXTXRLen;
-
-
- if(priv->rf_type == RF_1T1R)
- {
- Rtl819XPHY_REGArraytoXTXR_Table = Rtl819XPHY_REG_to1T1R_Array;
- PHY_REGArraytoXTXRLen = PHY_ChangeTo_1T1RArrayLength;
- }
- else if(priv->rf_type == RF_1T2R)
- {
- Rtl819XPHY_REGArraytoXTXR_Table = Rtl819XPHY_REG_to1T2R_Array;
- PHY_REGArraytoXTXRLen = PHY_ChangeTo_1T2RArrayLength;
- }
- else
- {
- return RT_STATUS_FAILURE;
- }
-
- if(ConfigType == BaseBand_Config_PHY_REG)
- {
- for(i=0;i<PHY_REGArraytoXTXRLen;i=i+3)
- {
- if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfe)
- mdelay(50);
- else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfd)
- mdelay(5);
- else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfc)
- mdelay(1);
- else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfb)
- udelay(50);
- else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xfa)
- udelay(5);
- else if (Rtl819XPHY_REGArraytoXTXR_Table[i] == 0xf9)
- udelay(1);
- rtl8192_setBBreg(dev, Rtl819XPHY_REGArraytoXTXR_Table[i], Rtl819XPHY_REGArraytoXTXR_Table[i+1], Rtl819XPHY_REGArraytoXTXR_Table[i+2]);
- }
- }
- else {
- RT_TRACE(COMP_SEND, "phy_SetBBtoDiffRFWithHeaderFile(): ConfigType != BaseBand_Config_PHY_REG\n");
- }
- return RT_STATUS_SUCCESS;
-}
-
-
-//use in phy only
-static RT_STATUS
-phy_BB8192S_Config_ParaFile(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
-
- RT_TRACE(COMP_INIT, "==>phy_BB8192S_Config_ParaFile\n");
-
- //
- // 1. Read PHY_REG.TXT BB INIT!!
- // We will separate as 1T1R/1T2R/1T2R_GREEN/2T2R
- //
- if (priv->rf_type == RF_1T2R || priv->rf_type == RF_2T2R ||
- priv->rf_type == RF_1T1R ||priv->rf_type == RF_2T2R_GREEN)
- {
- rtStatus = phy_ConfigBBWithHeaderFile(dev,BaseBand_Config_PHY_REG);
- if(priv->rf_type != RF_2T2R && priv->rf_type != RF_2T2R_GREEN)
- {//2008.11.10 Added by tynli. The default PHY_REG.txt we read is for 2T2R,
- //so we should reconfig BB reg with the right PHY parameters.
- rtStatus = phy_SetBBtoDiffRFWithHeaderFile(dev,BaseBand_Config_PHY_REG);
- }
- }else
- rtStatus = RT_STATUS_FAILURE;
-
- if(rtStatus != RT_STATUS_SUCCESS){
- RT_TRACE(COMP_INIT, "phy_BB8192S_Config_ParaFile():Write BB Reg Fail!!");
- goto phy_BB8190_Config_ParaFile_Fail;
- }
-
- //
- // 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt
- //
- if (priv->AutoloadFailFlag == false)
- {
- rtStatus = phy_ConfigBBWithPgHeaderFile(dev,BaseBand_Config_PHY_REG);
- }
- if(rtStatus != RT_STATUS_SUCCESS){
- RT_TRACE(COMP_INIT, "phy_BB8192S_Config_ParaFile():BB_PG Reg Fail!!");
- goto phy_BB8190_Config_ParaFile_Fail;
- }
-
- //
- // 3. BB AGC table Initialization
- //
- rtStatus = phy_ConfigBBWithHeaderFile(dev,BaseBand_Config_AGC_TAB);
-
- if(rtStatus != RT_STATUS_SUCCESS){
- printk( "phy_BB8192S_Config_ParaFile():AGC Table Fail\n");
- goto phy_BB8190_Config_ParaFile_Fail;
- }
-
-
- // Check if the CCK HighPower is turned ON.
- // This is used to calculate PWDB.
- priv->bCckHighPower = (bool)(rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter2, 0x200));
-
-
-phy_BB8190_Config_ParaFile_Fail:
- return rtStatus;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: phy_ConfigMACWithHeaderFile()
- *
- * Overview: This function read BB parameters from Header file we gen, and do register
- * Read/Write
- *
- * Input: PADAPTER Adapter
- * char* pFileName
- *
- * Output: NONE
- *
- * Return: RT_STATUS_SUCCESS: configuration file exist
- *
- * Note: The format of MACPHY_REG.txt is different from PHY and RF.
- * [Register][Mask][Value]
- *---------------------------------------------------------------------------*/
-//use in phy only
-static RT_STATUS
-phy_ConfigMACWithHeaderFile(struct net_device* dev)
-{
- u32 i = 0;
- u32 ArrayLength = 0;
- u32* ptrArray;
-
- { //2008.11.06 Modified by tynli.
- RT_TRACE(COMP_INIT, "Read Rtl819XMACPHY_Array\n");
- ArrayLength = MAC_2T_ArrayLength;
- ptrArray = Rtl819XMAC_Array;
- }
-
- for(i = 0 ;i < ArrayLength;i=i+2){ // Add by tynli for 2 column
- write_nic_byte(dev, ptrArray[i], (u8)ptrArray[i+1]);
- }
- return RT_STATUS_SUCCESS;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: phy_ConfigBBWithHeaderFile()
- *
- * Overview: This function read BB parameters from general file format, and do register
- * Read/Write
- *
- * Input: PADAPTER Adapter
- * u8 ConfigType 0 => PHY_CONFIG
- * 1 =>AGC_TAB
- *
- * Output: NONE
- *
- * Return: RT_STATUS_SUCCESS: configuration file exist
- *
- *---------------------------------------------------------------------------*/
-//use in phy only
-static RT_STATUS
-phy_ConfigBBWithHeaderFile(struct net_device* dev,u8 ConfigType)
-{
- int i;
- u32* Rtl819XPHY_REGArray_Table;
- u32* Rtl819XAGCTAB_Array_Table;
- u16 PHY_REGArrayLen, AGCTAB_ArrayLen;
-
- AGCTAB_ArrayLen = AGCTAB_ArrayLength;
- Rtl819XAGCTAB_Array_Table = Rtl819XAGCTAB_Array;
- PHY_REGArrayLen = PHY_REG_2T2RArrayLength; // Default RF_type: 2T2R
- Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_Array;
-
- if(ConfigType == BaseBand_Config_PHY_REG)
- {
- for(i=0;i<PHY_REGArrayLen;i=i+2)
- {
- if (Rtl819XPHY_REGArray_Table[i] == 0xfe)
- mdelay(50);
- else if (Rtl819XPHY_REGArray_Table[i] == 0xfd)
- mdelay(5);
- else if (Rtl819XPHY_REGArray_Table[i] == 0xfc)
- mdelay(1);
- else if (Rtl819XPHY_REGArray_Table[i] == 0xfb)
- udelay(50);
- else if (Rtl819XPHY_REGArray_Table[i] == 0xfa)
- udelay(5);
- else if (Rtl819XPHY_REGArray_Table[i] == 0xf9)
- udelay(1);
- rtl8192_setBBreg(dev, Rtl819XPHY_REGArray_Table[i], bMaskDWord, Rtl819XPHY_REGArray_Table[i+1]);
-
- }
- }
- else if(ConfigType == BaseBand_Config_AGC_TAB){
- for(i=0;i<AGCTAB_ArrayLen;i=i+2)
- {
- rtl8192_setBBreg(dev, Rtl819XAGCTAB_Array_Table[i], bMaskDWord, Rtl819XAGCTAB_Array_Table[i+1]);
- }
- }
- return RT_STATUS_SUCCESS;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: phy_ConfigBBWithPgHeaderFile
- *
- * Overview: Config PHY_REG_PG array
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/06/2008 MHC Add later!!!!!!.. Please modify for new files!!!!
- * 11/10/2008 tynli Modify to mew files.
- //use in phy only
- *---------------------------------------------------------------------------*/
-static RT_STATUS
-phy_ConfigBBWithPgHeaderFile(struct net_device* dev,u8 ConfigType)
-{
- int i;
- u32* Rtl819XPHY_REGArray_Table_PG;
- u16 PHY_REGArrayPGLen;
-
- PHY_REGArrayPGLen = PHY_REG_Array_PGLength;
- Rtl819XPHY_REGArray_Table_PG = Rtl819XPHY_REG_Array_PG;
-
- if(ConfigType == BaseBand_Config_PHY_REG)
- {
- for(i=0;i<PHY_REGArrayPGLen;i=i+3)
- {
- if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfe)
- mdelay(50);
- else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfd)
- mdelay(5);
- else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfc)
- mdelay(1);
- else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfb)
- udelay(50);
- else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xfa)
- udelay(5);
- else if (Rtl819XPHY_REGArray_Table_PG[i] == 0xf9)
- udelay(1);
- rtl8192_setBBreg(dev, Rtl819XPHY_REGArray_Table_PG[i], Rtl819XPHY_REGArray_Table_PG[i+1], Rtl819XPHY_REGArray_Table_PG[i+2]);
- }
- }else{
- RT_TRACE(COMP_SEND, "phy_ConfigBBWithPgHeaderFile(): ConfigType != BaseBand_Config_PHY_REG\n");
- }
- return RT_STATUS_SUCCESS;
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_ConfigRFWithHeaderFile()
- *
- * Overview: This function read RF parameters from general file format, and do RF 3-wire
- *
- * Input: PADAPTER Adapter
- * char* pFileName
- * RF90_RADIO_PATH_E eRFPath
- *
- * Output: NONE
- *
- * Return: RT_STATUS_SUCCESS: configuration file exist
- *
- * Note: Delay may be required for RF configuration
- *---------------------------------------------------------------------------*/
-u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E eRFPath)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- int i;
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
- u32 *Rtl819XRadioA_Array_Table;
- u32 *Rtl819XRadioB_Array_Table;
- u16 RadioA_ArrayLen,RadioB_ArrayLen;
-
- { //2008.11.06 Modified by tynli
- RadioA_ArrayLen = RadioA_1T_ArrayLength;
- Rtl819XRadioA_Array_Table=Rtl819XRadioA_Array;
- Rtl819XRadioB_Array_Table=Rtl819XRadioB_Array;
- RadioB_ArrayLen = RadioB_ArrayLength;
- }
-
- if( priv->rf_type == RF_2T2R_GREEN )
- {
- Rtl819XRadioB_Array_Table = Rtl819XRadioB_GM_Array;
- RadioB_ArrayLen = RadioB_GM_ArrayLength;
- }
- else
- {
- Rtl819XRadioB_Array_Table = Rtl819XRadioB_Array;
- RadioB_ArrayLen = RadioB_ArrayLength;
- }
-
- rtStatus = RT_STATUS_SUCCESS;
-
-
- switch(eRFPath){
- case RF90_PATH_A:
- for(i = 0;i<RadioA_ArrayLen; i=i+2){
- if(Rtl819XRadioA_Array_Table[i] == 0xfe)
- { // Deay specific ms. Only RF configuration require delay.
- mdelay(1000);
- }
- else if (Rtl819XRadioA_Array_Table[i] == 0xfd)
- mdelay(5);
- else if (Rtl819XRadioA_Array_Table[i] == 0xfc)
- mdelay(1);
- else if (Rtl819XRadioA_Array_Table[i] == 0xfb)
- udelay(50);
- else if (Rtl819XRadioA_Array_Table[i] == 0xfa)
- udelay(5);
- else if (Rtl819XRadioA_Array_Table[i] == 0xf9)
- udelay(1);
- else
- {
- rtl8192_phy_SetRFReg(dev, eRFPath, Rtl819XRadioA_Array_Table[i], bRFRegOffsetMask, Rtl819XRadioA_Array_Table[i+1]);
- }
- }
- break;
- case RF90_PATH_B:
- for(i = 0;i<RadioB_ArrayLen; i=i+2){
- if(Rtl819XRadioB_Array_Table[i] == 0xfe)
- { // Deay specific ms. Only RF configuration require delay.
- mdelay(1000);
- }
- else if (Rtl819XRadioB_Array_Table[i] == 0xfd)
- mdelay(5);
- else if (Rtl819XRadioB_Array_Table[i] == 0xfc)
- mdelay(1);
- else if (Rtl819XRadioB_Array_Table[i] == 0xfb)
- udelay(50);
- else if (Rtl819XRadioB_Array_Table[i] == 0xfa)
- udelay(5);
- else if (Rtl819XRadioB_Array_Table[i] == 0xf9)
- udelay(1);
- else
- {
- rtl8192_phy_SetRFReg(dev, eRFPath, Rtl819XRadioB_Array_Table[i], bRFRegOffsetMask, Rtl819XRadioB_Array_Table[i+1]);
- }
- }
- break;
- case RF90_PATH_C:
- break;
- case RF90_PATH_D:
- break;
- default:
- break;
- }
-
- return rtStatus;
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_CheckBBAndRFOK()
- *
- * Overview: This function is write register and then readback to make sure whether
- * BB[PHY0, PHY1], RF[Patha, path b, path c, path d] is Ok
- *
- * Input: PADAPTER Adapter
- * HW90_BLOCK_E CheckBlock
- * RF90_RADIO_PATH_E eRFPath // it is used only when CheckBlock is HW90_BLOCK_RF
- *
- * Output: NONE
- *
- * Return: RT_STATUS_SUCCESS: PHY is OK
- *
- * Note: This function may be removed in the ASIC
- *---------------------------------------------------------------------------*/
-//in 8256 phy_RF8256_Config_HardCode
-//but we don't use it temp
-RT_STATUS
-PHY_CheckBBAndRFOK(
- struct net_device* dev,
- HW90_BLOCK_E CheckBlock,
- RF90_RADIO_PATH_E eRFPath
- )
-{
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
- u32 i, CheckTimes = 4,ulRegRead = 0;
- u32 WriteAddr[4];
- u32 WriteData[] = {0xfffff027, 0xaa55a02f, 0x00000027, 0x55aa502f};
-
- // Initialize register address offset to be checked
- WriteAddr[HW90_BLOCK_MAC] = 0x100;
- WriteAddr[HW90_BLOCK_PHY0] = 0x900;
- WriteAddr[HW90_BLOCK_PHY1] = 0x800;
- WriteAddr[HW90_BLOCK_RF] = 0x3;
-
- for(i=0 ; i < CheckTimes ; i++)
- {
-
- //
- // Write Data to register and readback
- //
- switch(CheckBlock)
- {
- case HW90_BLOCK_MAC:
- RT_TRACE(COMP_INIT, "PHY_CheckBBRFOK(): Never Write 0x100 here!\n");
- break;
-
- case HW90_BLOCK_PHY0:
- case HW90_BLOCK_PHY1:
- write_nic_dword(dev, WriteAddr[CheckBlock], WriteData[i]);
- ulRegRead = read_nic_dword(dev, WriteAddr[CheckBlock]);
- break;
-
- case HW90_BLOCK_RF:
- WriteData[i] &= 0xfff;
- rtl8192_phy_SetRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bRFRegOffsetMask, WriteData[i]);
- // TODO: we should not delay for such a long time. Ask SD3
- mdelay(10);
- ulRegRead = rtl8192_phy_QueryRFReg(dev, eRFPath, WriteAddr[HW90_BLOCK_RF], bMaskDWord);
- mdelay(10);
- break;
-
- default:
- rtStatus = RT_STATUS_FAILURE;
- break;
- }
-
-
- //
- // Check whether readback data is correct
- //
- if(ulRegRead != WriteData[i])
- {
- RT_TRACE(COMP_ERR, "read back error(read:%x, write:%x)\n", ulRegRead, WriteData[i]);
- rtStatus = RT_STATUS_FAILURE;
- break;
- }
- }
-
- return rtStatus;
-}
-
-#ifdef TO_DO_LIST
-void
-PHY_SetRFPowerState8192SUsb(
- struct net_device* dev,
- RF_POWER_STATE RFPowerState
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool WaitShutDown = FALSE;
- u32 DWordContent;
- u8 eRFPath;
- BB_REGISTER_DEFINITION_T *pPhyReg;
-
- if(priv->SetRFPowerStateInProgress == TRUE)
- return;
-
- priv->SetRFPowerStateInProgress = TRUE;
-
-
- if(RFPowerState==RF_SHUT_DOWN)
- {
- RFPowerState=RF_OFF;
- WaitShutDown=TRUE;
- }
-
-
- priv->RFPowerState = RFPowerState;
- switch( priv->rf_chip )
- {
- case RF_8225:
- case RF_6052:
- switch( RFPowerState )
- {
- case RF_ON:
- break;
-
- case RF_SLEEP:
- break;
-
- case RF_OFF:
- break;
- }
- break;
-
- case RF_8256:
- switch( RFPowerState )
- {
- case RF_ON:
- break;
-
- case RF_SLEEP:
- break;
-
- case RF_OFF:
- for(eRFPath=(RF90_RADIO_PATH_E)RF90_PATH_A; eRFPath < RF90_PATH_MAX; eRFPath++)
- {
- if (!rtl8192_phy_CheckIsLegalRFPath(dev, eRFPath))
- continue;
-
- pPhyReg = &priv->PHYRegDef[eRFPath];
- rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, bRFSI_RFENV);
- rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0);
- }
- break;
- }
- break;
-
- case RF_8258:
- break;
- }
-
- priv->SetRFPowerStateInProgress = FALSE;
-}
-#endif
-
-#ifdef RTL8192U
-void
-PHY_UpdateInitialGain(
- struct net_device* dev
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-
- switch(priv->rf_chip)
- {
- case RF_8225:
- break;
- case RF_8256:
- break;
- case RF_8258:
- break;
- case RF_PSEUDO_11N:
- break;
- case RF_6052:
- break;
- default:
- RT_TRACE(COMP_DBG, "PHY_UpdateInitialGain(): unknown rf_chip: %#X\n", priv->rf_chip);
- break;
- }
-}
-#endif
-
-void PHY_GetHWRegOriginalValue(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- // read tx power offset
- // Simulate 8192
- priv->MCSTxPowerLevelOriginalOffset[0] =
- rtl8192_QueryBBReg(dev, rTxAGC_Rate18_06, bMaskDWord);
- priv->MCSTxPowerLevelOriginalOffset[1] =
- rtl8192_QueryBBReg(dev, rTxAGC_Rate54_24, bMaskDWord);
- priv->MCSTxPowerLevelOriginalOffset[2] =
- rtl8192_QueryBBReg(dev, rTxAGC_Mcs03_Mcs00, bMaskDWord);
- priv->MCSTxPowerLevelOriginalOffset[3] =
- rtl8192_QueryBBReg(dev, rTxAGC_Mcs07_Mcs04, bMaskDWord);
- priv->MCSTxPowerLevelOriginalOffset[4] =
- rtl8192_QueryBBReg(dev, rTxAGC_Mcs11_Mcs08, bMaskDWord);
- priv->MCSTxPowerLevelOriginalOffset[5] =
- rtl8192_QueryBBReg(dev, rTxAGC_Mcs15_Mcs12, bMaskDWord);
-
- // Read CCK offset
- priv->MCSTxPowerLevelOriginalOffset[6] =
- rtl8192_QueryBBReg(dev, rTxAGC_CCK_Mcs32, bMaskDWord);
- RT_TRACE(COMP_INIT, "Legacy OFDM =%08x/%08x HT_OFDM=%08x/%08x/%08x/%08x\n",
- priv->MCSTxPowerLevelOriginalOffset[0], priv->MCSTxPowerLevelOriginalOffset[1] ,
- priv->MCSTxPowerLevelOriginalOffset[2], priv->MCSTxPowerLevelOriginalOffset[3] ,
- priv->MCSTxPowerLevelOriginalOffset[4], priv->MCSTxPowerLevelOriginalOffset[5] );
-
- // read rx initial gain
- priv->DefaultInitialGain[0] = rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bMaskByte0);
- priv->DefaultInitialGain[1] = rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bMaskByte0);
- priv->DefaultInitialGain[2] = rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bMaskByte0);
- priv->DefaultInitialGain[3] = rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bMaskByte0);
- RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x) \n",
- priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
- priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
-
- // read framesync
- priv->framesync = rtl8192_QueryBBReg(dev, rOFDM0_RxDetector3, bMaskByte0);
- priv->framesyncC34 = rtl8192_QueryBBReg(dev, rOFDM0_RxDetector2, bMaskDWord);
- RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n",
- rOFDM0_RxDetector3, priv->framesync);
-}
-//YJ,modified,090107,end
-
-
-
-/**
-* Function: phy_InitBBRFRegisterDefinition
-*
-* OverView: Initialize Register definition offset for Radio Path A/B/C/D
-*
-* Input:
-* PADAPTER Adapter,
-*
-* Output: None
-* Return: None
-* Note: The initialization value is constant and it should never be changes
-*/
-//use in phy only
-static void phy_InitBBRFRegisterDefinition( struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- // RF Interface Sowrtware Control
- priv->PHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870
- priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872)
- priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 LSBs if read 32-bit from 0x874
- priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876)
-
- // RF Interface Readback Value
- priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; // 16 LSBs if read 32-bit from 0x8E0
- priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2)
- priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 LSBs if read 32-bit from 0x8E4
- priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;// 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6)
-
- // RF Interface Output (and Enable)
- priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x860
- priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; // 16 LSBs if read 32-bit from 0x864
- priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x868
- priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE;// 16 LSBs if read 32-bit from 0x86C
-
- // RF Interface (Output and) Enable
- priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862)
- priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; // 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866)
- priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86A (16-bit for 0x86A)
- priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86C (16-bit for 0x86E)
-
- //Addr of LSSI. Wirte RF register by driver
- priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter
- priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter;
- priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter;
- priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter;
-
- // RF parameter
- priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; //BB Band Select
- priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter;
- priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter;
- priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter;
-
- // Tx AGC Gain Stage (same for all path. Should we remove this?)
- priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
- priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
- priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
- priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; //Tx gain stage
-
- // Tranceiver A~D HSSI Parameter-1
- priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; //wire control parameter1
- priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; //wire control parameter1
- priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; //wire control parameter1
- priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; //wire control parameter1
-
- // Tranceiver A~D HSSI Parameter-2
- priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; //wire control parameter2
- priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; //wire control parameter2
- priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; //wire control parameter2
- priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; //wire control parameter1
-
- // RF switch Control
- priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; //TR/Ant switch control
- priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl;
- priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl;
- priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl;
-
- // AGC control 1
- priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1;
- priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1;
- priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1;
- priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1;
-
- // AGC control 2
- priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2;
- priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2;
- priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2;
- priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2;
-
- // RX AFE control 1
- priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance;
- priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance;
- priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance;
- priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance;
-
- // RX AFE control 1
- priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE;
- priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE;
- priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE;
- priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE;
-
- // Tx AFE control 1
- priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance;
- priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance;
- priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance;
- priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance;
-
- // Tx AFE control 2
- priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE;
- priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE;
- priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE;
- priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE;
-
- // Tranceiver LSSI Readback SI mode
- priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
- priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack;
- priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack;
- priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack;
-
- // Tranceiver LSSI Readback PI mode
- priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback;
- priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback;
-
-}
-
-
-//
-// Description: Change RF power state.
-//
-// Assumption: This function must be executed in re-schdulable context,
-// ie. PASSIVE_LEVEL.
-//
-
-bool PHY_SetRFPowerState(struct net_device* dev, RT_RF_POWER_STATE eRFPowerState)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bResult = FALSE;
-
- RT_TRACE(COMP_RF, "---------> PHY_SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState);
-
- if(eRFPowerState == priv->ieee80211->eRFPowerState)
- {
- RT_TRACE(COMP_RF, "<--------- PHY_SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState);
- return bResult;
- }
-
- bResult = phy_SetRFPowerState8192SU(dev, eRFPowerState);
-
- RT_TRACE(COMP_RF, "<--------- PHY_SetRFPowerState(): bResult(%d)\n", bResult);
-
- return bResult;
-}
-
-//use in phy only
-static bool phy_SetRFPowerState8192SU(struct net_device* dev,RT_RF_POWER_STATE eRFPowerState)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bResult = TRUE;
- u8 u1bTmp;
-
- if(priv->SetRFPowerStateInProgress == TRUE)
- return FALSE;
-
- priv->SetRFPowerStateInProgress = TRUE;
-
- switch(priv->rf_chip )
- {
- default:
- switch( eRFPowerState )
- {
- case eRfOn:
- write_nic_dword(dev, WFM5, FW_BB_RESET_ENABLE);
- write_nic_word(dev, CMDR, 0x37FC);
- write_nic_byte(dev, PHY_CCA, 0x3);
- write_nic_byte(dev, TXPAUSE, 0x00);
- write_nic_byte(dev, SPS1_CTRL, 0x64);
- break;
-
- //
- // In current solution, RFSleep=RFOff in order to save power under 802.11 power save.
- // By Bruce, 2008-01-16.
- //
- case eRfSleep:
- case eRfOff:
- if (priv->ieee80211->eRFPowerState == eRfSleep || priv->ieee80211->eRFPowerState == eRfOff)
- break;
- //
- //RF Off/Sleep sequence. Designed/tested from SD4 Scott, SD1 Grent and Jonbon.
- // (0) Disable FW BB reset checking
- write_nic_dword(dev, WFM5, FW_BB_RESET_DISABLE);
-
- // (1) Switching Power Supply Register : Disable LD12 & SW12 (for IT)
- u1bTmp = read_nic_byte(dev, LDOV12D_CTRL);
- u1bTmp |= BIT0;
- write_nic_byte(dev, LDOV12D_CTRL, u1bTmp);
-
- write_nic_byte(dev, SPS1_CTRL, 0x0);
- write_nic_byte(dev, TXPAUSE, 0xFF);
-
- // (2) MAC Tx/Rx enable, BB enable, CCK/OFDM enable
- write_nic_word(dev, CMDR, 0x77FC);
- write_nic_byte(dev, PHY_CCA, 0x0);
- udelay(100);
-
- write_nic_word(dev, CMDR, 0x37FC);
- udelay(10);
-
- write_nic_word(dev, CMDR, 0x77FC);
- udelay(10);
-
- // (3) Reset BB TRX blocks
- write_nic_word(dev, CMDR, 0x57FC);
- break;
-
- default:
- bResult = FALSE;
- break;
- }
- break;
-
- }
- priv->ieee80211->eRFPowerState = eRFPowerState;
-#ifdef TO_DO_LIST
- if(bResult)
- {
- // Update current RF state variable.
- priv->ieee80211->eRFPowerState = eRFPowerState;
-
- switch(priv->rf_chip )
- {
- case RF_8256:
- switch(priv->ieee80211->eRFPowerState)
- {
- case eRfOff:
- //
- //If Rf off reason is from IPS, Led should blink with no link, by Maddest 071015
- //
- if(pMgntInfo->RfOffReason==RF_CHANGE_BY_IPS )
- {
- dev->HalFunc.LedControlHandler(dev,LED_CTL_NO_LINK);
- }
- else
- {
- // Turn off LED if RF is not ON.
- dev->HalFunc.LedControlHandler(dev, LED_CTL_POWER_OFF);
- }
- break;
-
- case eRfOn:
- // Turn on RF we are still linked, which might happen when
- // we quickly turn off and on HW RF. 2006.05.12, by rcnjko.
- if( pMgntInfo->bMediaConnect == TRUE )
- {
- dev->HalFunc.LedControlHandler(dev, LED_CTL_LINK);
- }
- else
- {
- // Turn off LED if RF is not ON.
- dev->HalFunc.LedControlHandler(dev, LED_CTL_NO_LINK);
- }
- break;
-
- default:
- // do nothing.
- break;
- }// Switch RF state
-
- break;
-
- default:
- RT_TRACE(COMP_RF, "phy_SetRFPowerState8192SU(): Unknown RF type\n");
- break;
- }// Switch rf_chip
- }
-#endif
- priv->SetRFPowerStateInProgress = FALSE;
-
- return bResult;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: GetTxPowerLevel8190()
- *
- * Overview: This function is export to "common" moudule
- *
- * Input: PADAPTER Adapter
- * psByte Power Level
- *
- * Output: NONE
- *
- * Return: NONE
- *
- *---------------------------------------------------------------------------*/
- // no use temp
- void
-PHY_GetTxPowerLevel8192S(
- struct net_device* dev,
- long* powerlevel
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 TxPwrLevel = 0;
- long TxPwrDbm;
- //
- // Because the Tx power indexes are different, we report the maximum of them to
- // meet the CCX TPC request. By Bruce, 2008-01-31.
- //
-
- // CCK
- TxPwrLevel = priv->CurrentCckTxPwrIdx;
- TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_B, TxPwrLevel);
-
- // Legacy OFDM
- TxPwrLevel = priv->CurrentOfdm24GTxPwrIdx + priv->LegacyHTTxPowerDiff;
-
- // Compare with Legacy OFDM Tx power.
- if(phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm)
- TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_G, TxPwrLevel);
-
- // HT OFDM
- TxPwrLevel = priv->CurrentOfdm24GTxPwrIdx;
-
- // Compare with HT OFDM Tx power.
- if(phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm)
- TxPwrDbm = phy_TxPwrIdxToDbm(dev, WIRELESS_MODE_N_24G, TxPwrLevel);
-
- *powerlevel = TxPwrDbm;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: SetTxPowerLevel8190()
- *
- * Overview: This function is export to "HalCommon" moudule
- *
- * Input: PADAPTER Adapter
- * u1Byte channel
- *
- * Output: NONE
- *
- * Return: NONE
- * 2008/11/04 MHC We remove EEPROM_93C56.
- * We need to move CCX relative code to independet file.
-* 2009/01/21 MHC Support new EEPROM format from SD3 requirement.
- *---------------------------------------------------------------------------*/
- void PHY_SetTxPowerLevel8192S(struct net_device* dev, u8 channel)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 powerlevel = (u8)EEPROM_Default_TxPower, powerlevelOFDM24G = 0x10;
- s8 ant_pwr_diff = 0;
- u32 u4RegValue;
- u8 index = (channel -1);
- // 2009/01/22 MH Add for new EEPROM format from SD3
- u8 pwrdiff[2] = {0};
- u8 ht20pwr[2] = {0}, ht40pwr[2] = {0};
- u8 rfpath = 0, rfpathnum = 2;
-
- if(priv->bTXPowerDataReadFromEEPORM == FALSE)
- return;
-
- /*
- * Read predefined TX power index in EEPROM
- */
- {
- //
- // Mainly we use RF-A Tx Power to write the Tx Power registers, but the RF-B Tx
- // Power must be calculated by the antenna diff.
- // So we have to rewrite Antenna gain offset register here.
- // Please refer to BB register 0x80c
- // 1. For CCK.
- // 2. For OFDM 1T or 2T
- //
-
- // 1. CCK
- powerlevel = priv->RfTxPwrLevelCck[0][index];
-
- if (priv->rf_type == RF_1T2R || priv->rf_type == RF_1T1R)
- {
- // Read HT 40 OFDM TX power
- powerlevelOFDM24G = priv->RfTxPwrLevelOfdm1T[0][index];
- // RF B HT OFDM pwr-RFA HT OFDM pwr
- // Only one RF we need not to decide B <-> A pwr diff
-
- // Legacy<->HT pwr diff, we only care about path A.
-
- // We only assume 1T as RF path A
- rfpathnum = 1;
- ht20pwr[0] = ht40pwr[0] = priv->RfTxPwrLevelOfdm1T[0][index];
- }
- else if (priv->rf_type == RF_2T2R)
- {
- // Read HT 40 OFDM TX power
- powerlevelOFDM24G = priv->RfTxPwrLevelOfdm2T[0][index];
- // RF B HT OFDM pwr-RFA HT OFDM pwr
- ant_pwr_diff = priv->RfTxPwrLevelOfdm2T[1][index] -
- priv->RfTxPwrLevelOfdm2T[0][index];
-
- ht20pwr[0] = ht40pwr[0] = priv->RfTxPwrLevelOfdm2T[0][index];
- ht20pwr[1] = ht40pwr[1] = priv->RfTxPwrLevelOfdm2T[1][index];
- }
-
- //
- // 2009/01/21 MH Support new EEPROM format from SD3 requirement
- // 2009/02/10 Cosa, Here is only for reg B/C/D to A gain diff.
- //
- if (priv->EEPROMVersion == 2) // Defined by SD1 Jong
- {
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- {
- for (rfpath = 0; rfpath < rfpathnum; rfpath++)
- {
- // HT 20<->40 pwr diff
- pwrdiff[rfpath] = priv->TxPwrHt20Diff[rfpath][index];
-
- // Calculate Antenna pwr diff
- if (pwrdiff[rfpath] < 8) // 0~+7
- {
- ht20pwr[rfpath] += pwrdiff[rfpath];
- }
- else // index8-15=-8~-1
- {
- ht20pwr[rfpath] -= (15-pwrdiff[rfpath]);
- }
- }
-
- // RF B HT OFDM pwr-RFA HT OFDM pwr
- if (priv->rf_type == RF_2T2R)
- ant_pwr_diff = ht20pwr[1] - ht20pwr[0];
- }
-
- // Band Edge scheme is enabled for FCC mode
- if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
- {
- for (rfpath = 0; rfpath < rfpathnum; rfpath++)
- {
- pwrdiff[rfpath] = 0;
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
- {
- if (channel <= 3)
- pwrdiff[rfpath] = priv->TxPwrbandEdgeHt40[rfpath][0];
- else if (channel >= 9)
- pwrdiff[rfpath] = priv->TxPwrbandEdgeHt40[rfpath][1];
- else
- pwrdiff[rfpath] = 0;
-
- ht40pwr[rfpath] -= pwrdiff[rfpath];
- }
- else if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- {
- if (channel == 1)
- pwrdiff[rfpath] = priv->TxPwrbandEdgeHt20[rfpath][0];
- else if (channel >= 11)
- pwrdiff[rfpath] = priv->TxPwrbandEdgeHt20[rfpath][1];
- else
- pwrdiff[rfpath] = 0;
-
- ht20pwr[rfpath] -= pwrdiff[rfpath];
- }
- }
-
- if (priv->rf_type == RF_2T2R)
- {
- // HT 20/40 must decide if they need to minus BD pwr offset
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
- ant_pwr_diff = ht40pwr[1] - ht40pwr[0];
- else
- ant_pwr_diff = ht20pwr[1] - ht20pwr[0];
- }
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- {
- if (channel <= 1 || channel >= 11)
- {
- }
- }
- else
- {
- if (channel <= 3 || channel >= 9)
- {
- }
- }
- }
- }
-
- //Cosa added for protection, the reg rFPGA0_TxGainStage
- // range is from 7~-8, index = 0x0~0xf
- if(ant_pwr_diff > 7)
- ant_pwr_diff = 7;
- if(ant_pwr_diff < -8)
- ant_pwr_diff = -8;
-
- ant_pwr_diff &= 0xf;
-
- // Antenna TX power difference
- priv->AntennaTxPwDiff[2] = 0;// RF-D, don't care
- priv->AntennaTxPwDiff[1] = 0;// RF-C, don't care
- priv->AntennaTxPwDiff[0] = (u8)(ant_pwr_diff); // RF-B
-
- // Antenna gain offset from B/C/D to A
- u4RegValue = ( priv->AntennaTxPwDiff[2]<<8 |
- priv->AntennaTxPwDiff[1]<<4 |
- priv->AntennaTxPwDiff[0] );
-
- // Notify Tx power difference for B/C/D to A!!!
- rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), u4RegValue);
- }
-
- //
- // CCX 2 S31, AP control of client transmit power:
- // 1. We shall not exceed Cell Power Limit as possible as we can.
- // 2. Tolerance is +/- 5dB.
- // 3. 802.11h Power Contraint takes higher precedence over CCX Cell Power Limit.
- //
- // TODO:
- // 1. 802.11h power contraint
- //
- //
-#ifdef TODO //WB, 11h has not implemented now.
- if( priv->ieee80211->iw_mode != IW_MODE_INFRA && priv->bWithCcxCellPwr &&
- channel == priv->ieee80211->current_network.channel)// & priv->ieee80211->mAssoc )
- {
- u8 CckCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_B, priv->CcxCellPwr);
- u8 LegacyOfdmCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_G, priv->CcxCellPwr);
- u8 OfdmCellPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, priv->CcxCellPwr);
-
- RT_TRACE(COMP_TXAGC,
- ("CCX Cell Limit: %d dbm => CCK Tx power index : %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n",
- priv->CcxCellPwr, CckCellPwrIdx, LegacyOfdmCellPwrIdx, OfdmCellPwrIdx));
- RT_TRACE(COMP_TXAGC,
- ("EEPROM channel(%d) => CCK Tx power index: %d, Legacy OFDM Tx power index : %d, OFDM Tx power index: %d\n",
- channel, powerlevel, powerlevelOFDM24G + priv->LegacyHTTxPowerDiff, powerlevelOFDM24G));
-
- // CCK
- if(powerlevel > CckCellPwrIdx)
- powerlevel = CckCellPwrIdx;
- // Legacy OFDM, HT OFDM
- if(powerlevelOFDM24G + priv->LegacyHTTxPowerDiff > LegacyOfdmCellPwrIdx)
- {
- if((OfdmCellPwrIdx - priv->LegacyHTTxPowerDiff) > 0)
- {
- powerlevelOFDM24G = OfdmCellPwrIdx - priv->LegacyHTTxPowerDiff;
- }
- else
- {
- powerlevelOFDM24G = 0;
- }
- }
-
- RT_TRACE(COMP_TXAGC,
- ("Altered CCK Tx power index : %d, Legacy OFDM Tx power index: %d, OFDM Tx power index: %d\n",
- powerlevel, powerlevelOFDM24G + priv->LegacyHTTxPowerDiff, powerlevelOFDM24G));
- }
-#endif
-
- priv->CurrentCckTxPwrIdx = powerlevel;
- priv->CurrentOfdm24GTxPwrIdx = powerlevelOFDM24G;
-
- switch(priv->rf_chip)
- {
- case RF_8225:
- break;
-
- case RF_8256:
- break;
-
- case RF_6052:
- PHY_RF6052SetCckTxPower(dev, powerlevel);
- PHY_RF6052SetOFDMTxPower(dev, powerlevelOFDM24G);
- break;
-
- case RF_8258:
- break;
- default:
- break;
- }
-
-}
-
-//
-// Description:
-// Update transmit power level of all channel supported.
-//
-// TODO:
-// A mode.
-bool PHY_UpdateTxPowerDbm8192S(struct net_device* dev, long powerInDbm)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 idx;
- u8 rf_path;
-
- // TODO: A mode Tx power.
- u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_B, powerInDbm);
- u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(dev, WIRELESS_MODE_N_24G, powerInDbm);
-
- if(OfdmTxPwrIdx - priv->LegacyHTTxPowerDiff > 0)
- OfdmTxPwrIdx -= priv->LegacyHTTxPowerDiff;
- else
- OfdmTxPwrIdx = 0;
-
- for(idx = 0; idx < 14; idx++)
- {
- priv->TxPowerLevelCCK[idx] = CckTxPwrIdx;
- priv->TxPowerLevelCCK_A[idx] = CckTxPwrIdx;
- priv->TxPowerLevelCCK_C[idx] = CckTxPwrIdx;
- priv->TxPowerLevelOFDM24G[idx] = OfdmTxPwrIdx;
- priv->TxPowerLevelOFDM24G_A[idx] = OfdmTxPwrIdx;
- priv->TxPowerLevelOFDM24G_C[idx] = OfdmTxPwrIdx;
-
- for (rf_path = 0; rf_path < 2; rf_path++)
- {
- priv->RfTxPwrLevelCck[rf_path][idx] = CckTxPwrIdx;
- priv->RfTxPwrLevelOfdm1T[rf_path][idx] = \
- priv->RfTxPwrLevelOfdm2T[rf_path][idx] = OfdmTxPwrIdx;
- }
- }
-
- PHY_SetTxPowerLevel8192S(dev, priv->chan);
-
- return TRUE;
-}
-
-/*
- Description:
- When beacon interval is changed, the values of the
- hw registers should be modified.
-*/
-
-extern void PHY_SetBeaconHwReg( struct net_device* dev, u16 BeaconInterval)
-{
- u32 NewBeaconNum;
-
- NewBeaconNum = BeaconInterval *32 - 64;
- write_nic_dword(dev, WFM3+4, NewBeaconNum);
- write_nic_dword(dev, WFM3, 0xB026007C);
-}
-
-//
-// Description:
-// Map dBm into Tx power index according to
-// current HW model, for example, RF and PA, and
-// current wireless mode.
-// use in phy only
-static u8 phy_DbmToTxPwrIdx(
- struct net_device* dev,
- WIRELESS_MODE WirelessMode,
- long PowerInDbm
- )
-{
- u8 TxPwrIdx = 0;
- long Offset = 0;
-
-
- //
- // Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to
- // 3dbm, and OFDM HT equals to 0dbm repectively.
- // Note:
- // The mapping may be different by different NICs. Do not use this formula for what needs accurate result.
- //
- switch(WirelessMode)
- {
- case WIRELESS_MODE_B:
- Offset = -7;
- break;
-
- case WIRELESS_MODE_G:
- case WIRELESS_MODE_N_24G:
- Offset = -8;
- break;
- default:
- break;
- }
-
- if((PowerInDbm - Offset) > 0)
- {
- TxPwrIdx = (u8)((PowerInDbm - Offset) * 2);
- }
- else
- {
- TxPwrIdx = 0;
- }
-
- // Tx Power Index is too large.
- if(TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S)
- TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S;
-
- return TxPwrIdx;
-}
-//
-// Description:
-// Map Tx power index into dBm according to
-// current HW model, for example, RF and PA, and
-// current wireless mode.
-// use in phy only
-static long phy_TxPwrIdxToDbm(
- struct net_device* dev,
- WIRELESS_MODE WirelessMode,
- u8 TxPwrIdx
- )
-{
- //struct r8192_priv *priv = ieee80211_priv(dev);
- long Offset = 0;
- long PwrOutDbm = 0;
-
- //
- // Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to
- // 3dbm, and OFDM HT equals to 0dbm repectively.
- // Note:
- // The mapping may be different by different NICs. Do not use this formula for what needs accurate result.
- //
- switch(WirelessMode)
- {
- case WIRELESS_MODE_B:
- Offset = -7;
- break;
-
- case WIRELESS_MODE_G:
- case WIRELESS_MODE_N_24G:
- Offset = -8;
- break;
- default:
- break;
- }
-
- PwrOutDbm = TxPwrIdx / 2 + Offset; // Discard the decimal part.
-
- return PwrOutDbm;
-}
-
-#ifdef TO_DO_LIST
-extern VOID
-PHY_ScanOperationBackup8192S(
- IN PADAPTER Adapter,
- IN u1Byte Operation
- )
-{
-
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- u4Byte BitMask;
- u1Byte initial_gain;
-
-
-
-
-
- if(!Adapter->bDriverStopped)
- {
- switch(Operation)
- {
- case SCAN_OPT_BACKUP:
- //
- // <Roger_Notes> We halt FW DIG and disable high ppower both two DMs here
- // and resume both two DMs while scan complete.
- // 2008.11.27.
- //
- Adapter->HalFunc.SetFwCmdHandler(Adapter, FW_CMD_PAUSE_DM_BY_SCAN);
- break;
-
- case SCAN_OPT_RESTORE:
- //
- // <Roger_Notes> We resume DIG and enable high power both two DMs here and
- // recover earlier DIG settings.
- // 2008.11.27.
- //
- Adapter->HalFunc.SetFwCmdHandler(Adapter, FW_CMD_RESUME_DM_BY_SCAN);
- break;
-
- default:
- RT_TRACE(COMP_SCAN, DBG_LOUD, ("Unknown Scan Backup Operation. \n"));
- break;
- }
- }
-}
-#endif
-
-//nouse temp
-void PHY_InitialGain8192S(struct net_device* dev,u8 Operation )
-{
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: SetBWModeCallback8190Pci()
- *
- * Overview: Timer callback function for SetSetBWMode
- *
- * Input: PRT_TIMER pTimer
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: (1) We do not take j mode into consideration now
- * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run
- * concurrently?
- *---------------------------------------------------------------------------*/
-// use in phy only (in win it's timer)
-void PHY_SetBWModeCallback8192S(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 regBwOpMode;
-
- u8 regRRSR_RSC;
-
- RT_TRACE(COMP_SWBW, "==>SetBWModeCallback8190Pci() Switch to %s bandwidth\n", \
- priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz");
-
- if(priv->rf_chip == RF_PSEUDO_11N)
- {
- priv->SetBWModeInProgress= FALSE;
- return;
- }
-
- if(!priv->up)
- return;
-
-
- //3//
- //3//<1>Set MAC register
- //3//
- regBwOpMode = read_nic_byte(dev, BW_OPMODE);
- regRRSR_RSC = read_nic_byte(dev, RRSR+2);
-
- switch(priv->CurrentChannelBW)
- {
- case HT_CHANNEL_WIDTH_20:
-
- regBwOpMode |= BW_OPMODE_20MHZ;
- // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- break;
-
- case HT_CHANNEL_WIDTH_20_40:
-
- regBwOpMode &= ~BW_OPMODE_20MHZ;
- // 2007/02/07 Mark by Emily becasue we have not verify whether this register works
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5);
- write_nic_byte(dev, RRSR+2, regRRSR_RSC);
- break;
-
- default:
- RT_TRACE(COMP_DBG, "SetBWModeCallback8190Pci(): unknown Bandwidth: %#X\n",
- priv->CurrentChannelBW);
- break;
- }
-
- //3//
- //3//<2>Set PHY related register
- //3//
- switch(priv->CurrentChannelBW)
- {
- /* 20 MHz channel*/
- case HT_CHANNEL_WIDTH_20:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
-
- if (priv->card_8192_version >= VERSION_8192S_BCUT)
- write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
-
-
- break;
-
- /* 40 MHz channel*/
- case HT_CHANNEL_WIDTH_20_40:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
-
-
- // Set Control channel to upper or lower. These settings are required only for 40MHz
- rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
- rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
-
- if (priv->card_8192_version >= VERSION_8192S_BCUT)
- write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
-
- break;
-
- default:
- RT_TRACE(COMP_DBG, "SetBWModeCallback8190Pci(): unknown Bandwidth: %#X\n"\
- ,priv->CurrentChannelBW);
- break;
-
- }
- //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
-
-
- //3<3>Set RF related register
- switch( priv->rf_chip )
- {
- case RF_8225:
- //PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
- break;
-
- case RF_8256:
- // Please implement this function in Hal8190PciPhy8256.c
- //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
- break;
-
- case RF_8258:
- // Please implement this function in Hal8190PciPhy8258.c
- // PHY_SetRF8258Bandwidth();
- break;
-
- case RF_PSEUDO_11N:
- // Do Nothing
- break;
-
- case RF_6052:
- PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
- break;
- default:
- printk("Unknown rf_chip: %d\n", priv->rf_chip);
- break;
- }
-
- priv->SetBWModeInProgress= FALSE;
-
- RT_TRACE(COMP_SWBW, "<==SetBWModeCallback8190Pci() \n" );
-}
-
-
- /*-----------------------------------------------------------------------------
- * Function: SetBWMode8190Pci()
- *
- * Overview: This function is export to "HalCommon" moudule
- *
- * Input: PADAPTER Adapter
- * HT_CHANNEL_WIDTH Bandwidth //20M or 40M
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: We do not take j mode into consideration now
- *---------------------------------------------------------------------------*/
-void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- HT_CHANNEL_WIDTH tmpBW = priv->CurrentChannelBW;
-
- if(priv->SetBWModeInProgress)
- return;
-
- priv->SetBWModeInProgress= TRUE;
-
- priv->CurrentChannelBW = Bandwidth;
-
- if(Offset==HT_EXTCHNL_OFFSET_LOWER)
- priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER;
- else if(Offset==HT_EXTCHNL_OFFSET_UPPER)
- priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER;
- else
- priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
-
- if((priv->up) )
- {
- SetBWModeCallback8192SUsbWorkItem(dev);
- }
- else
- {
- RT_TRACE(COMP_SCAN, "PHY_SetBWMode8192S() SetBWModeInProgress FALSE driver sleep or unload\n");
- priv->SetBWModeInProgress= FALSE;
- priv->CurrentChannelBW = tmpBW;
- }
-}
-
-// use in phy only (in win it's timer)
-void PHY_SwChnlCallback8192S(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 delay;
-
- RT_TRACE(COMP_CH, "==>SwChnlCallback8190Pci(), switch to channel %d\n", priv->chan);
-
- if(!priv->up)
- return;
-
- if(priv->rf_chip == RF_PSEUDO_11N)
- {
- priv->SwChnlInProgress=FALSE;
- return; //return immediately if it is peudo-phy
- }
-
- do{
- if(!priv->SwChnlInProgress)
- break;
-
- if(!phy_SwChnlStepByStep(dev, priv->chan, &priv->SwChnlStage, &priv->SwChnlStep, &delay))
- {
- if(delay>0)
- {
- mdelay(delay);
- }
- else
- continue;
- }
- else
- {
- priv->SwChnlInProgress=FALSE;
- break;
- }
- }while(true);
-}
-
-// Call after initialization
-u8 rtl8192_phy_SwChnl(struct net_device* dev, u8 channel)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if(!priv->up)
- return false;
-
- if(priv->SwChnlInProgress)
- return false;
-
- if(priv->SetBWModeInProgress)
- return false;
-
- switch(priv->ieee80211->mode)
- {
- case WIRELESS_MODE_A:
- case WIRELESS_MODE_N_5G:
- if (channel<=14){
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14");
- return false;
- }
- break;
-
- case WIRELESS_MODE_B:
- if (channel>14){
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14");
- return false;
- }
- break;
-
- case WIRELESS_MODE_G:
- case WIRELESS_MODE_N_24G:
- if (channel>14){
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14");
- return false;
- }
- break;
-
- default:
- ;
- break;
- }
-
- priv->SwChnlInProgress = TRUE;
- if( channel == 0)
- channel = 1;
-
- priv->chan=channel;
-
- priv->SwChnlStage=0;
- priv->SwChnlStep=0;
-
- if((priv->up))
- {
- SwChnlCallback8192SUsbWorkItem(dev);
-#ifdef TO_DO_LIST
- if(bResult)
- {
- RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress TRUE schdule workitem done\n");
- }
- else
- {
- RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress FALSE schdule workitem error\n");
- priv->SwChnlInProgress = false;
- priv->CurrentChannel = tmpchannel;
- }
-#endif
- }
- else
- {
- RT_TRACE(COMP_SCAN, "PHY_SwChnl8192S SwChnlInProgress FALSE driver sleep or unload\n");
- priv->SwChnlInProgress = false;
- }
- return true;
-}
-
-
-//
-// Description:
-// Switch channel synchronously. Called by SwChnlByDelayHandler.
-//
-// Implemented by Bruce, 2008-02-14.
-// The following procedure is operted according to SwChanlCallback8190Pci().
-// However, this procedure is performed synchronously which should be running under
-// passive level.
-
-void PHY_SwChnlPhy8192S( // Only called during initialize
- struct net_device* dev,
- u8 channel
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- RT_TRACE(COMP_SCAN, "==>PHY_SwChnlPhy8192S(), switch to channel %d.\n", priv->chan);
-
-#ifdef TO_DO_LIST
- // Cannot IO.
- if(RT_CANNOT_IO(dev))
- return;
-#endif
-
- // Channel Switching is in progress.
- if(priv->SwChnlInProgress)
- return;
-
- //return immediately if it is peudo-phy
- if(priv->rf_chip == RF_PSEUDO_11N)
- {
- priv->SwChnlInProgress=FALSE;
- return;
- }
-
- priv->SwChnlInProgress = TRUE;
- if( channel == 0)
- channel = 1;
-
- priv->chan=channel;
-
- priv->SwChnlStage = 0;
- priv->SwChnlStep = 0;
-
- phy_FinishSwChnlNow(dev,channel);
-
- priv->SwChnlInProgress = FALSE;
-}
-
-// use in phy only
-static bool
-phy_SetSwChnlCmdArray(
- SwChnlCmd* CmdTable,
- u32 CmdTableIdx,
- u32 CmdTableSz,
- SwChnlCmdID CmdID,
- u32 Para1,
- u32 Para2,
- u32 msDelay
- )
-{
- SwChnlCmd* pCmd;
-
- if(CmdTable == NULL)
- {
- return FALSE;
- }
- if(CmdTableIdx >= CmdTableSz)
- {
- return FALSE;
- }
-
- pCmd = CmdTable + CmdTableIdx;
- pCmd->CmdID = CmdID;
- pCmd->Para1 = Para1;
- pCmd->Para2 = Para2;
- pCmd->msDelay = msDelay;
-
- return TRUE;
-}
-
-// use in phy only
-static bool
-phy_SwChnlStepByStep(
- struct net_device* dev,
- u8 channel,
- u8 *stage,
- u8 *step,
- u32 *delay
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- SwChnlCmd PreCommonCmd[MAX_PRECMD_CNT];
- u32 PreCommonCmdCnt;
- SwChnlCmd PostCommonCmd[MAX_POSTCMD_CNT];
- u32 PostCommonCmdCnt;
- SwChnlCmd RfDependCmd[MAX_RFDEPENDCMD_CNT];
- u32 RfDependCmdCnt;
- SwChnlCmd *CurrentCmd = NULL;
- u8 eRFPath;
-
- RT_TRACE(COMP_CH, "===========>%s(), channel:%d, stage:%d, step:%d\n", __FUNCTION__, channel, *stage, *step);
- if (!IsLegalChannel(priv->ieee80211, channel))
- {
- RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n", channel);
- return true; //return true to tell upper caller function this channel setting is finished! Or it will in while loop.
- }
-
- // <1> Fill up pre common command.
- PreCommonCmdCnt = 0;
- phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
- CmdID_SetTxPowerLevel, 0, 0, 0);
- phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, MAX_PRECMD_CNT,
- CmdID_End, 0, 0, 0);
-
- // <2> Fill up post common command.
- PostCommonCmdCnt = 0;
-
- phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, MAX_POSTCMD_CNT,
- CmdID_End, 0, 0, 0);
-
- // <3> Fill up RF dependent command.
- RfDependCmdCnt = 0;
- switch( priv->rf_chip )
- {
- case RF_8225:
- if (channel < 1 || channel > 14)
- RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
-
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_RF_WriteReg, rRfChannel, channel, 10);
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_End, 0, 0, 0);
- break;
-
- case RF_8256:
- if (channel < 1 || channel > 14)
- RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_RF_WriteReg, rRfChannel, channel, 10);
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_End, 0, 0, 0);
- break;
-
- case RF_6052:
- if (channel < 1 || channel > 14)
- RT_TRACE(COMP_ERR, "illegal channel for zebra:%d\n", channel);
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_RF_WriteReg, RF_CHNLBW, channel, 10);
- phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
- CmdID_End, 0, 0, 0);
- break;
-
- case RF_8258:
- break;
-
- default:
- return FALSE;
- break;
- }
-
-
- do{
- switch(*stage)
- {
- case 0:
- CurrentCmd=&PreCommonCmd[*step];
- break;
- case 1:
- CurrentCmd=&RfDependCmd[*step];
- break;
- case 2:
- CurrentCmd=&PostCommonCmd[*step];
- break;
- }
-
- if(CurrentCmd->CmdID==CmdID_End)
- {
- if((*stage)==2)
- {
- return TRUE;
- }
- else
- {
- (*stage)++;
- (*step)=0;
- continue;
- }
- }
-
- switch(CurrentCmd->CmdID)
- {
- case CmdID_SetTxPowerLevel:
- PHY_SetTxPowerLevel8192S(dev,channel);
- break;
- case CmdID_WritePortUlong:
- write_nic_dword(dev, CurrentCmd->Para1, CurrentCmd->Para2);
- break;
- case CmdID_WritePortUshort:
- write_nic_word(dev, CurrentCmd->Para1, (u16)CurrentCmd->Para2);
- break;
- case CmdID_WritePortUchar:
- write_nic_byte(dev, CurrentCmd->Para1, (u8)CurrentCmd->Para2);
- break;
- case CmdID_RF_WriteReg: // Only modify channel for the register now !!!!!
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- {
- // For new T65 RF 0222d register 0x18 bit 0-9 = channel number.
- rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)eRFPath, CurrentCmd->Para1, 0x1f, (CurrentCmd->Para2));
- }
- break;
- default:
- break;
- }
-
- break;
- }while(TRUE);
-
- (*delay)=CurrentCmd->msDelay;
- (*step)++;
- RT_TRACE(COMP_CH, "<===========%s(), channel:%d, stage:%d, step:%d\n", __FUNCTION__, channel, *stage, *step);
- return FALSE;
-}
-
-//called PHY_SwChnlPhy8192S, SwChnlCallback8192SUsbWorkItem
-// use in phy only
-static void
-phy_FinishSwChnlNow( // We should not call this function directly
- struct net_device* dev,
- u8 channel
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 delay;
-
- while(!phy_SwChnlStepByStep(dev,channel,&priv->SwChnlStage,&priv->SwChnlStep,&delay))
- {
- if(delay>0)
- mdelay(delay);
- if(!priv->up)
- break;
- }
-}
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHYCheckIsLegalRfPath8190Pci()
- *
- * Overview: Check different RF type to execute legal judgement. If RF Path is illegal
- * We will return false.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/15/2007 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev, u32 eRFPath)
-{
- bool rtValue = TRUE;
-
- // NOt check RF Path now.!
- return rtValue;
-
-} /* PHY_CheckIsLegalRfPath8192S */
-
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_IQCalibrate8192S()
- *
- * Overview: After all MAC/PHY/RF is configued. We must execute IQ calibration
- * to improve RF EVM!!?
- *
- * Input: IN PADAPTER pAdapter
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 10/07/2008 MHC Create. Document from SD3 RFSI Jenyu.
- *
- *---------------------------------------------------------------------------*/
- //called by InitializeAdapter8192SE
-void
-PHY_IQCalibrate( struct net_device* dev)
-{
- u32 i, reg;
- u32 old_value;
- long X, Y, TX0[4];
- u32 TXA[4];
-
- // 1. Check QFN68 or 64 92S (Read from EEPROM)
-
- //
- // 2. QFN 68
- //
- // For 1T2R IQK only now !!!
- for (i = 0; i < 10; i++)
- {
- // IQK
- rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05430);
- udelay(5);
- rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000800e4);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x80800000);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe40, bMaskDWord, 0x02140148);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe44, bMaskDWord, 0x681604a2);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe4c, bMaskDWord, 0x000028d1);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe60, bMaskDWord, 0x0214014d);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe64, bMaskDWord, 0x281608ba);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe6c, bMaskDWord, 0x000028d1);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000001);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000001);
- udelay(2000);
- rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05433);
- udelay(5);
- rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000000e4);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x0);
-
-
- reg = rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord);
-
- // Readback IQK value and rewrite
- if (!(reg&(BIT27|BIT28|BIT30|BIT31)))
- {
- old_value = (rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord) & 0x3FF);
-
- // Calibrate init gain for A path for TX0
- X = (rtl8192_QueryBBReg(dev, 0xe94, bMaskDWord) & 0x03FF0000)>>16;
- TXA[RF90_PATH_A] = (X * old_value)/0x100;
- reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
- reg = (reg & 0xFFFFFC00) | (u32)TXA[RF90_PATH_A];
- rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate init gain for C path for TX0
- Y = ( rtl8192_QueryBBReg(dev, 0xe9C, bMaskDWord) & 0x03FF0000)>>16;
- TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
- reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
- reg = (reg & 0xffc0ffff) |((u32) (TX0[RF90_PATH_C]&0x3F)<<16);
- rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
- reg = rtl8192_QueryBBReg(dev, 0xc94, bMaskDWord);
- reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
- rtl8192_setBBreg(dev, 0xc94, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate RX A and B for RX0
- reg = rtl8192_QueryBBReg(dev, 0xc14, bMaskDWord);
- X = (rtl8192_QueryBBReg(dev, 0xea4, bMaskDWord) & 0x03FF0000)>>16;
- reg = (reg & 0xFFFFFC00) |X;
- rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
- Y = (rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord) & 0x003F0000)>>16;
- reg = (reg & 0xFFFF03FF) |Y<<10;
- rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
- udelay(5);
- old_value = (rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord) & 0x3FF);
-
- // Calibrate init gain for A path for TX1 !!!!!!
- X = (rtl8192_QueryBBReg(dev, 0xeb4, bMaskDWord) & 0x03FF0000)>>16;
- reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
- TXA[RF90_PATH_A] = (X * old_value) / 0x100;
- reg = (reg & 0xFFFFFC00) | TXA[RF90_PATH_A];
- rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate init gain for C path for TX1
- Y = (rtl8192_QueryBBReg(dev, 0xebc, bMaskDWord)& 0x03FF0000)>>16;
- TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
- reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
- reg = (reg & 0xffc0ffff) |( (TX0[RF90_PATH_C]&0x3F)<<16);
- rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
- reg = rtl8192_QueryBBReg(dev, 0xc9c, bMaskDWord);
- reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
- rtl8192_setBBreg(dev, 0xc9c, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate RX A and B for RX1
- reg = rtl8192_QueryBBReg(dev, 0xc1c, bMaskDWord);
- X = (rtl8192_QueryBBReg(dev, 0xec4, bMaskDWord) & 0x03FF0000)>>16;
- reg = (reg & 0xFFFFFC00) |X;
- rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
-
- Y = (rtl8192_QueryBBReg(dev, 0xecc, bMaskDWord) & 0x003F0000)>>16;
- reg = (reg & 0xFFFF03FF) |Y<<10;
- rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
- udelay(5);
-
- RT_TRACE(COMP_INIT, "PHY_IQCalibrate OK\n");
- break;
- }
-
- }
-
-
- //
- // 3. QFN64. Not enabled now !!! We must use different gain table for 1T2R.
- //
-
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_IQCalibrateBcut()
- *
- * Overview: After all MAC/PHY/RF is configued. We must execute IQ calibration
- * to improve RF EVM!!?
- *
- * Input: IN PADAPTER pAdapter
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/18/2008 MHC Create. Document from SD3 RFSI Jenyu.
- * 92S B-cut QFN 68 pin IQ calibration procedure.doc
- *
- *---------------------------------------------------------------------------*/
-extern void PHY_IQCalibrateBcut(struct net_device* dev)
-{
- u32 i, reg;
- u32 old_value;
- long X, Y, TX0[4];
- u32 TXA[4];
- u32 calibrate_set[13] = {0};
- u32 load_value[13];
- u8 RfPiEnable=0;
-
- // 0. Check QFN68 or 64 92S (Read from EEPROM/EFUSE)
-
- //
- // 1. Save e70~ee0 register setting, and load calibration setting
- //
- calibrate_set [0] = 0xee0;
- calibrate_set [1] = 0xedc;
- calibrate_set [2] = 0xe70;
- calibrate_set [3] = 0xe74;
- calibrate_set [4] = 0xe78;
- calibrate_set [5] = 0xe7c;
- calibrate_set [6] = 0xe80;
- calibrate_set [7] = 0xe84;
- calibrate_set [8] = 0xe88;
- calibrate_set [9] = 0xe8c;
- calibrate_set [10] = 0xed0;
- calibrate_set [11] = 0xed4;
- calibrate_set [12] = 0xed8;
- for (i = 0; i < 13; i++)
- {
- load_value[i] = rtl8192_QueryBBReg(dev, calibrate_set[i], bMaskDWord);
- rtl8192_setBBreg(dev, calibrate_set[i], bMaskDWord, 0x3fed92fb);
-
- }
-
- RfPiEnable = (u8)rtl8192_QueryBBReg(dev, rFPGA0_XA_HSSIParameter1, BIT8);
-
- //
- // 2. QFN 68
- //
- // For 1T2R IQK only now !!!
- for (i = 0; i < 10; i++)
- {
- RT_TRACE(COMP_INIT, "IQK -%d\n", i);
- //BB switch to PI mode. If default is PI mode, ignoring 2 commands below.
- if (!RfPiEnable) //if original is SI mode, then switch to PI mode.
- {
- rtl8192_setBBreg(dev, 0x820, bMaskDWord, 0x01000100);
- rtl8192_setBBreg(dev, 0x828, bMaskDWord, 0x01000100);
- }
-
- // IQK
- // 2. IQ calibration & LO leakage calibration
- rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05430);
- udelay(5);
- rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000800e4);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x80800000);
- udelay(5);
- //path-A IQ K and LO K gain setting
- rtl8192_setBBreg(dev, 0xe40, bMaskDWord, 0x02140102);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe44, bMaskDWord, 0x681604c2);
- udelay(5);
- //set LO calibration
- rtl8192_setBBreg(dev, 0xe4c, bMaskDWord, 0x000028d1);
- udelay(5);
- //path-B IQ K and LO K gain setting
- rtl8192_setBBreg(dev, 0xe60, bMaskDWord, 0x02140102);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe64, bMaskDWord, 0x28160d05);
- udelay(5);
- //K idac_I & IQ
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000000);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000000);
- udelay(5);
-
- // delay 2ms
- udelay(2000);
-
- //idac_Q setting
- rtl8192_setBBreg(dev, 0xe6c, bMaskDWord, 0x020028d1);
- udelay(5);
- //K idac_Q & IQ
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xfb000000);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe48, bMaskDWord, 0xf8000000);
-
- // delay 2ms
- udelay(2000);
-
- rtl8192_setBBreg(dev, 0xc04, bMaskDWord, 0x00a05433);
- udelay(5);
- rtl8192_setBBreg(dev, 0xc08, bMaskDWord, 0x000000e4);
- udelay(5);
- rtl8192_setBBreg(dev, 0xe28, bMaskDWord, 0x0);
-
- if (!RfPiEnable) //if original is SI mode, then switch to PI mode.
- {
- rtl8192_setBBreg(dev, 0x820, bMaskDWord, 0x01000000);
- rtl8192_setBBreg(dev, 0x828, bMaskDWord, 0x01000000);
- }
-
-
- reg = rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord);
-
- // 3. check fail bit, and fill BB IQ matrix
- // Readback IQK value and rewrite
- if (!(reg&(BIT27|BIT28|BIT30|BIT31)))
- {
- old_value = (rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord) & 0x3FF);
-
- // Calibrate init gain for A path for TX0
- X = (rtl8192_QueryBBReg(dev, 0xe94, bMaskDWord) & 0x03FF0000)>>16;
- TXA[RF90_PATH_A] = (X * old_value)/0x100;
- reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
- reg = (reg & 0xFFFFFC00) | (u32)TXA[RF90_PATH_A];
- rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate init gain for C path for TX0
- Y = ( rtl8192_QueryBBReg(dev, 0xe9C, bMaskDWord) & 0x03FF0000)>>16;
- TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
- reg = rtl8192_QueryBBReg(dev, 0xc80, bMaskDWord);
- reg = (reg & 0xffc0ffff) |((u32) (TX0[RF90_PATH_C]&0x3F)<<16);
- rtl8192_setBBreg(dev, 0xc80, bMaskDWord, reg);
- reg = rtl8192_QueryBBReg(dev, 0xc94, bMaskDWord);
- reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
- rtl8192_setBBreg(dev, 0xc94, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate RX A and B for RX0
- reg = rtl8192_QueryBBReg(dev, 0xc14, bMaskDWord);
- X = (rtl8192_QueryBBReg(dev, 0xea4, bMaskDWord) & 0x03FF0000)>>16;
- reg = (reg & 0xFFFFFC00) |X;
- rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
- Y = (rtl8192_QueryBBReg(dev, 0xeac, bMaskDWord) & 0x003F0000)>>16;
- reg = (reg & 0xFFFF03FF) |Y<<10;
- rtl8192_setBBreg(dev, 0xc14, bMaskDWord, reg);
- udelay(5);
- old_value = (rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord) & 0x3FF);
-
- // Calibrate init gain for A path for TX1 !!!!!!
- X = (rtl8192_QueryBBReg(dev, 0xeb4, bMaskDWord) & 0x03FF0000)>>16;
- reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
- TXA[RF90_PATH_A] = (X * old_value) / 0x100;
- reg = (reg & 0xFFFFFC00) | TXA[RF90_PATH_A];
- rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate init gain for C path for TX1
- Y = (rtl8192_QueryBBReg(dev, 0xebc, bMaskDWord)& 0x03FF0000)>>16;
- TX0[RF90_PATH_C] = ((Y * old_value)/0x100);
- reg = rtl8192_QueryBBReg(dev, 0xc88, bMaskDWord);
- reg = (reg & 0xffc0ffff) |( (TX0[RF90_PATH_C]&0x3F)<<16);
- rtl8192_setBBreg(dev, 0xc88, bMaskDWord, reg);
- reg = rtl8192_QueryBBReg(dev, 0xc9c, bMaskDWord);
- reg = (reg & 0x0fffffff) |(((Y&0x3c0)>>6)<<28);
- rtl8192_setBBreg(dev, 0xc9c, bMaskDWord, reg);
- udelay(5);
-
- // Calibrate RX A and B for RX1
- reg = rtl8192_QueryBBReg(dev, 0xc1c, bMaskDWord);
- X = (rtl8192_QueryBBReg(dev, 0xec4, bMaskDWord) & 0x03FF0000)>>16;
- reg = (reg & 0xFFFFFC00) |X;
- rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
-
- Y = (rtl8192_QueryBBReg(dev, 0xecc, bMaskDWord) & 0x003F0000)>>16;
- reg = (reg & 0xFFFF03FF) |Y<<10;
- rtl8192_setBBreg(dev, 0xc1c, bMaskDWord, reg);
- udelay(5);
-
- RT_TRACE(COMP_INIT, "PHY_IQCalibrate OK\n");
- break;
- }
-
- }
-
- //
- // 4. Reload e70~ee0 register setting.
- //
- for (i = 0; i < 13; i++)
- rtl8192_setBBreg(dev, calibrate_set[i], bMaskDWord, load_value[i]);
-
-
- //
- // 3. QFN64. Not enabled now !!! We must use different gain table for 1T2R.
- //
-
-
-
-}
-
-
-//
-// Move from phycfg.c to gen.c to be code independent later
-//
-
-// use in phy only (in win it's timer)
-void SwChnlCallback8192SUsb(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 delay;
-
- RT_TRACE(COMP_SCAN, "==>SwChnlCallback8190Pci(), switch to channel %d\n",
- priv->chan);
-
-
- if(!priv->up)
- return;
-
- if(priv->rf_chip == RF_PSEUDO_11N)
- {
- priv->SwChnlInProgress=FALSE;
- return; //return immediately if it is peudo-phy
- }
-
- do{
- if(!priv->SwChnlInProgress)
- break;
-
- if(!phy_SwChnlStepByStep(dev, priv->chan, &priv->SwChnlStage, &priv->SwChnlStep, &delay))
- {
- if(delay>0)
- {
-
- }
- else
- continue;
- }
- else
- {
- priv->SwChnlInProgress=FALSE;
- }
- break;
- }while(TRUE);
-}
-
-
-//
-// Callback routine of the work item for switch channel.
-//
-// use in phy only (in win it's work)
-void SwChnlCallback8192SUsbWorkItem(struct net_device *dev )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- RT_TRACE(COMP_TRACE, "==> SwChnlCallback8192SUsbWorkItem()\n");
-#ifdef TO_DO_LIST
- if(pAdapter->bInSetPower && RT_USB_CANNOT_IO(pAdapter))
- {
- RT_TRACE(COMP_SCAN, DBG_LOUD, ("<== SwChnlCallback8192SUsbWorkItem() SwChnlInProgress FALSE driver sleep or unload\n"));
-
- pHalData->SwChnlInProgress = FALSE;
- return;
- }
-#endif
- phy_FinishSwChnlNow(dev, priv->chan);
- priv->SwChnlInProgress = FALSE;
-
- RT_TRACE(COMP_TRACE, "<== SwChnlCallback8192SUsbWorkItem()\n");
-}
-
-
-/*-----------------------------------------------------------------------------
- * Function: SetBWModeCallback8192SUsb()
- *
- * Overview: Timer callback function for SetSetBWMode
- *
- * Input: PRT_TIMER pTimer
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: (1) We do not take j mode into consideration now
- * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run
- * concurrently?
- *---------------------------------------------------------------------------*/
-// use in phy only
-void SetBWModeCallback8192SUsb(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 regBwOpMode;
-
- u8 regRRSR_RSC;
-
- RT_TRACE(COMP_SCAN, "==>SetBWModeCallback8190Pci() Switch to %s bandwidth\n", \
- priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz");
-
- if(priv->rf_chip == RF_PSEUDO_11N)
- {
- priv->SetBWModeInProgress= FALSE;
- return;
- }
-
- if(!priv->up)
- return;
-
-
- //3<1>Set MAC register
- regBwOpMode = read_nic_byte(dev, BW_OPMODE);
- regRRSR_RSC = read_nic_byte(dev, RRSR+2);
-
- switch(priv->CurrentChannelBW)
- {
- case HT_CHANNEL_WIDTH_20:
- regBwOpMode |= BW_OPMODE_20MHZ;
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- break;
-
- case HT_CHANNEL_WIDTH_20_40:
- regBwOpMode &= ~BW_OPMODE_20MHZ;
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
-
- regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5);
- write_nic_byte(dev, RRSR+2, regRRSR_RSC);
- break;
-
- default:
- RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci(): unknown Bandwidth: %#X\n",
- priv->CurrentChannelBW);
- break;
- }
-
- //3 <2>Set PHY related register
- switch(priv->CurrentChannelBW)
- {
- case HT_CHANNEL_WIDTH_20:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
-
- if (priv->card_8192_version >= VERSION_8192S_BCUT)
- rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
-
- break;
- case HT_CHANNEL_WIDTH_20_40:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
- rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1));
- rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC);
-
- if (priv->card_8192_version >= VERSION_8192S_BCUT)
- rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
-
- break;
- default:
- RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci(): unknown Bandwidth: %#X\n"\
- ,priv->CurrentChannelBW);
- break;
-
- }
- //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315
-
-#if 1
- //3<3>Set RF related register
- switch( priv->rf_chip )
- {
- case RF_8225:
- PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
- break;
-
- case RF_8256:
- // Please implement this function in Hal8190PciPhy8256.c
- //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW);
- break;
-
- case RF_6052:
- PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
- break;
-
- case RF_8258:
- // Please implement this function in Hal8190PciPhy8258.c
- // PHY_SetRF8258Bandwidth();
- break;
-
- case RF_PSEUDO_11N:
- // Do Nothing
- break;
-
- default:
- break;
- }
-#endif
- priv->SetBWModeInProgress= FALSE;
-
- RT_TRACE(COMP_SCAN, "<==SetBWMode8190Pci()" );
-}
-
-/*
- * Callback routine of the work item for set bandwidth mode.
- *
- * use in phy only (in win it's work)
- */
-void SetBWModeCallback8192SUsbWorkItem(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 regBwOpMode;
- u8 regRRSR_RSC;
-
- RT_TRACE(COMP_SCAN, "%s(): Switch to %s bandwidth", __func__,
- priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? "20MHz" : "40MHz");
-
- if (priv->rf_chip == RF_PSEUDO_11N) {
- priv->SetBWModeInProgress= FALSE;
- return;
- }
- if(!priv->up)
- return;
- /* Set MAC register */
- regBwOpMode = read_nic_byte(dev, BW_OPMODE);
- regRRSR_RSC = read_nic_byte(dev, RRSR+2);
- switch (priv->CurrentChannelBW) {
- case HT_CHANNEL_WIDTH_20:
- regBwOpMode |= BW_OPMODE_20MHZ;
- /* we have not verified whether this register works */
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- break;
- case HT_CHANNEL_WIDTH_20_40:
- regBwOpMode &= ~BW_OPMODE_20MHZ;
- /* we have not verified whether this register works */
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- regRRSR_RSC = (regRRSR_RSC&0x90) | (priv->nCur40MhzPrimeSC<<5);
- write_nic_byte(dev, RRSR+2, regRRSR_RSC);
- break;
- default:
- RT_TRACE(COMP_DBG, "%s(): unknown Bandwidth: %#X", __func__,
- priv->CurrentChannelBW);
- break;
- }
- /* Set PHY related register */
- switch (priv->CurrentChannelBW) {
- case HT_CHANNEL_WIDTH_20:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0);
- rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
- break;
- case HT_CHANNEL_WIDTH_20_40:
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1);
- rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1);
- /*
- * Set Control channel to upper or lower.
- * These settings are required only for 40MHz
- */
- rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand,
- (priv->nCur40MhzPrimeSC>>1));
- rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00,
- priv->nCur40MhzPrimeSC);
- rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
- break;
- default:
- RT_TRACE(COMP_DBG, "%s(): unknown Bandwidth: %#X", __func__,
- priv->CurrentChannelBW);
- break;
-
- }
- /*
- * Skip over setting of J-mode in BB register here.
- * Default value is "None J mode".
- */
-
- /* Set RF related register */
- switch (priv->rf_chip) {
- case RF_8225:
- PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW);
- break;
- case RF_8256:
- /* Please implement this function in Hal8190PciPhy8256.c */
- /* PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); */
- break;
- case RF_6052:
- PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW);
- break;
- case RF_8258:
- /* Please implement this function in Hal8190PciPhy8258.c */
- /* PHY_SetRF8258Bandwidth(); */
- break;
- case RF_PSEUDO_11N:
- /* Do Nothing */
- break;
- default:
- RT_TRACE(COMP_DBG, "%s(): unknown rf_chip: %d", __func__,
- priv->rf_chip);
- break;
- }
- priv->SetBWModeInProgress= FALSE;
-}
-
-void InitialGain8192S(struct net_device *dev, u8 Operation)
-{
-#ifdef TO_DO_LIST
- struct r8192_priv *priv = ieee80211_priv(dev);
-#endif
-
-}
-
-void InitialGain819xUsb(struct net_device *dev, u8 Operation)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->InitialGainOperateType = Operation;
-
- if(priv->up)
- {
- queue_delayed_work(priv->priv_wq,&priv->initialgain_operate_wq,0);
- }
-}
-
-extern void InitialGainOperateWorkItemCallBack(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,initialgain_operate_wq);
- struct net_device *dev = priv->ieee80211->dev;
-#define SCAN_RX_INITIAL_GAIN 0x17
-#define POWER_DETECTION_TH 0x08
- u32 BitMask;
- u8 initial_gain;
- u8 Operation;
-
- Operation = priv->InitialGainOperateType;
-
- switch(Operation)
- {
- case IG_Backup:
- RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial gain.\n");
- initial_gain = SCAN_RX_INITIAL_GAIN;//priv->DefaultInitialGain[0];//
- BitMask = bMaskByte0;
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
- priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, BitMask);
- priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, BitMask);
- priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, BitMask);
- priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, BitMask);
- BitMask = bMaskByte2;
- priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, BitMask);
-
- RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
-
- RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n", initial_gain);
- write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
- RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n", POWER_DETECTION_TH);
- write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH);
- break;
- case IG_Restore:
- RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial gain.\n");
- BitMask = 0x7f; //Bit0~ Bit6
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // FW DIG OFF
-
- rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, BitMask, (u32)priv->initgain_backup.xaagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, BitMask, (u32)priv->initgain_backup.xbagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, BitMask, (u32)priv->initgain_backup.xcagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, BitMask, (u32)priv->initgain_backup.xdagccore1);
- BitMask = bMaskByte2;
- rtl8192_setBBreg(dev, rCCK0_CCA, BitMask, (u32)priv->initgain_backup.cca);
-
- RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
-
- PHY_SetTxPowerLevel8192S(dev,priv->ieee80211->current_network.channel);
-
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // FW DIG ON
- break;
- default:
- RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n");
- break;
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Description:
-// Schedule workitem to send specific CMD IO to FW.
-// Added by Roger, 2008.12.03.
-//
-//-----------------------------------------------------------------------------
-bool HalSetFwCmd8192S(struct net_device* dev, FW_CMD_IO_TYPE FwCmdIO)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 FwCmdWaitCounter = 0;
-
- u16 FwCmdWaitLimit = 1000;
-
- if(priv->bInHctTest)
- return true;
-
- RT_TRACE(COMP_CMD, "-->HalSetFwCmd8192S(): Set FW Cmd(%x), SetFwCmdInProgress(%d)\n", (u32)FwCmdIO, priv->SetFwCmdInProgress);
-
- // Will be done by high power respectively.
- if(FwCmdIO==FW_CMD_DIG_HALT || FwCmdIO==FW_CMD_DIG_RESUME)
- {
- RT_TRACE(COMP_CMD, "<--HalSetFwCmd8192S(): Set FW Cmd(%x)\n", (u32)FwCmdIO);
- return false;
- }
-
-#if 1
- while(priv->SetFwCmdInProgress && FwCmdWaitCounter<FwCmdWaitLimit)
- {
-
- RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): previous workitem not finish!!\n");
- return false;
- FwCmdWaitCounter ++;
- RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): Wait 10 ms (%d times)...\n", FwCmdWaitCounter);
- udelay(100);
- }
-
- if(FwCmdWaitCounter == FwCmdWaitLimit)
- {
- RT_TRACE(COMP_CMD, "HalSetFwCmd8192S(): Wait too logn to set FW CMD\n");
- }
-#endif
- if (priv->SetFwCmdInProgress)
- {
- RT_TRACE(COMP_ERR, "<--HalSetFwCmd8192S(): Set FW Cmd(%#x)\n", FwCmdIO);
- return false;
- }
- priv->SetFwCmdInProgress = TRUE;
- priv->CurrentFwCmdIO = FwCmdIO; // Update current FW Cmd for callback use.
-
- phy_SetFwCmdIOCallback(dev);
- return true;
-}
-void ChkFwCmdIoDone(struct net_device* dev)
-{
- u16 PollingCnt = 1000;
- u32 tmpValue;
-
- do
- {// Make sure that CMD IO has be accepted by FW.
-#ifdef TO_DO_LIST
- if(RT_USB_CANNOT_IO(Adapter))
- {
- RT_TRACE(COMP_CMD, "ChkFwCmdIoDone(): USB can NOT IO!!\n");
- return;
- }
-#endif
- udelay(10); // sleep 20us
- tmpValue = read_nic_dword(dev, WFM5);
- if(tmpValue == 0)
- {
- RT_TRACE(COMP_CMD, "[FW CMD] Set FW Cmd success!!\n");
- break;
- }
- else
- {
- RT_TRACE(COMP_CMD, "[FW CMD] Polling FW Cmd PollingCnt(%d)!!\n", PollingCnt);
- }
- }while( --PollingCnt );
-
- if(PollingCnt == 0)
- {
- RT_TRACE(COMP_ERR, "[FW CMD] Set FW Cmd fail!!\n");
- }
-}
-// Callback routine of the timer callback for FW Cmd IO.
-//
-// Description:
-// This routine will send specific CMD IO to FW and check whether it is done.
-//
-void phy_SetFwCmdIOCallback(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
- rt_firmware *pFirmware = priv->pFirmware;
- u32 input, CurrentAID = 0;;
- if(!priv->up)
- {
- RT_TRACE(COMP_CMD, "SetFwCmdIOTimerCallback(): driver is going to unload\n");
- return;
- }
-
- RT_TRACE(COMP_CMD, "--->SetFwCmdIOTimerCallback(): Cmd(%#x), SetFwCmdInProgress(%d)\n", priv->CurrentFwCmdIO, priv->SetFwCmdInProgress);
-
- if(pFirmware->FirmwareVersion >= 0x34)
- {
- switch(priv->CurrentFwCmdIO)
- {
- case FW_CMD_RA_REFRESH_N:
- priv->CurrentFwCmdIO = FW_CMD_RA_REFRESH_N_COMB;
- break;
- case FW_CMD_RA_REFRESH_BG:
- priv->CurrentFwCmdIO = FW_CMD_RA_REFRESH_BG_COMB;
- break;
- default:
- break;
- }
- }
- switch(priv->CurrentFwCmdIO)
- {
-
- case FW_CMD_RA_RESET:
- write_nic_dword(dev, WFM5, FW_RA_RESET);
- break;
-
- case FW_CMD_RA_ACTIVE:
- write_nic_dword(dev, WFM5, FW_RA_ACTIVE);
- break;
-
- case FW_CMD_RA_REFRESH_N:
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA n refresh!!\n");
- if(pHTInfo->IOTRaFunc & HT_IOT_RAFUNC_DISABLE_ALL)
- input = FW_RA_REFRESH;
- else
- input = FW_RA_REFRESH | (pHTInfo->IOTRaFunc << 8);
- write_nic_dword(dev, WFM5, input);
- ChkFwCmdIoDone(dev);
- write_nic_dword(dev, WFM5, FW_RA_ENABLE_RSSI_MASK);
- ChkFwCmdIoDone(dev);
- break;
- case FW_CMD_RA_REFRESH_BG:
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA BG refresh!!\n");
- write_nic_dword(dev, WFM5, FW_RA_REFRESH);
- ChkFwCmdIoDone(dev);
- write_nic_dword(dev, WFM5, FW_RA_DISABLE_RSSI_MASK);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_RA_REFRESH_N_COMB:
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA n Combo refresh!!\n");
- if(pHTInfo->IOTRaFunc & HT_IOT_RAFUNC_DISABLE_ALL)
- input = FW_RA_IOT_N_COMB;
- else
- input = FW_RA_IOT_N_COMB | (((pHTInfo->IOTRaFunc)&0x0f) << 8);
- input = input |((pHTInfo->IOTPeer & 0xf) <<12);
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA/IOT Comb in n mode!! input(%#x)\n", input);
- write_nic_dword(dev, WFM5, input);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_RA_REFRESH_BG_COMB:
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA B/G Combo refresh!!\n");
- if(pHTInfo->IOTRaFunc & HT_IOT_RAFUNC_DISABLE_ALL)
- input = FW_RA_IOT_BG_COMB;
- else
- input = FW_RA_IOT_BG_COMB | (((pHTInfo->IOTRaFunc)&0x0f) << 8);
- input = input |((pHTInfo->IOTPeer & 0xf) <<12);
- RT_TRACE(COMP_CMD, "[FW CMD] Set RA/IOT Comb in B/G mode!! input(%#x)\n", input);
- write_nic_dword(dev, WFM5, input);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_IQK_ENABLE:
- write_nic_dword(dev, WFM5, FW_IQK_ENABLE);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_TXPWR_TRACK_ENABLE:
- write_nic_dword(dev, WFM5, FW_TXPWR_TRACK_ENABLE);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_TXPWR_TRACK_DISABLE:
- write_nic_dword(dev, WFM5, FW_TXPWR_TRACK_DISABLE);
- ChkFwCmdIoDone(dev);
- break;
-
- case FW_CMD_PAUSE_DM_BY_SCAN:
- RT_TRACE(COMP_CMD,"[FW CMD] Pause DM by Scan!!\n");
- rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, 0x17);
- rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, 0x17);
- rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x40);
- break;
-
- case FW_CMD_RESUME_DM_BY_SCAN:
- RT_TRACE(COMP_CMD, "[FW CMD] Resume DM by Scan!!\n");
- rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x83);
- PHY_SetTxPowerLevel8192S(dev, priv->chan);
- break;
- case FW_CMD_HIGH_PWR_DISABLE:
- RT_TRACE(COMP_CMD, "[FW CMD] High Pwr Disable!!\n");
- if(priv->DMFlag & HAL_DM_HIPWR_DISABLE)
- break;
- rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bMaskByte0, 0x17);
- rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bMaskByte0, 0x17);
- rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x40);
- break;
-
- case FW_CMD_HIGH_PWR_ENABLE:
- RT_TRACE(COMP_CMD, "[FW CMD] High Pwr Enable!!\n");
- if(priv->DMFlag & HAL_DM_HIPWR_DISABLE)
- break;
- rtl8192_setBBreg(dev, rCCK0_CCA, bMaskByte2, 0x83);
- break;
-
- case FW_CMD_LPS_ENTER:
- RT_TRACE(COMP_CMD, "[FW CMD] Enter LPS mode!!\n");
- CurrentAID = priv->ieee80211->assoc_id;
- write_nic_dword(dev, WFM5, (FW_LPS_ENTER| ((CurrentAID|0xc000)<<8)) );
- ChkFwCmdIoDone(dev);
- pHTInfo->IOTAction |= HT_IOT_ACT_DISABLE_EDCA_TURBO;
- break;
-
- case FW_CMD_LPS_LEAVE:
- RT_TRACE(COMP_CMD, "[FW CMD] Leave LPS mode!!\n");
- write_nic_dword(dev, WFM5, FW_LPS_LEAVE );
- ChkFwCmdIoDone(dev);
- pHTInfo->IOTAction &= (~HT_IOT_ACT_DISABLE_EDCA_TURBO);
- break;
-
- default:
- break;
- }
-
- priv->SetFwCmdInProgress = false;
- RT_TRACE(COMP_CMD, "<---SetFwCmdIOWorkItemCallback()\n");
-
-}
-
diff --git a/drivers/staging/rtl8192su/r8192S_phy.h b/drivers/staging/rtl8192su/r8192S_phy.h
deleted file mode 100644
index b752fa35a7ae..000000000000
--- a/drivers/staging/rtl8192su/r8192S_phy.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*****************************************************************************
- * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
- *
- * Module: __INC_HAL8192SPHYCFG_H
- *
- *
- * Note:
- *
- *
- * Export: Constants, macro, functions(API), global variables(None).
- *
- * Abbrev:
- *
- * History:
- * Data Who Remark
- * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
- * 2. Reorganize code architecture.
- *
- *****************************************************************************/
- /* Check to see if the file has been included already. */
-#ifndef _R8192S_PHY_H
-#define _R8192S_PHY_H
-
-
-/*--------------------------Define Parameters-------------------------------*/
-#define LOOP_LIMIT 5
-#define MAX_STALL_TIME 50 //us
-#define AntennaDiversityValue 0x80 //(dev->bSoftwareAntennaDiversity ? 0x00:0x80)
-#define MAX_TXPWR_IDX_NMODE_92S 63
-
-//#define delay_ms(_t) PlatformStallExecution(1000*(_t))
-//#define delay_us(_t) PlatformStallExecution(_t)
-
-/* Channel switch:The size of command tables for switch channel*/
-#define MAX_PRECMD_CNT 16
-#define MAX_RFDEPENDCMD_CNT 16
-#define MAX_POSTCMD_CNT 16
-
-
-/*------------------------------Define structure----------------------------*/
-typedef enum _SwChnlCmdID{
- CmdID_End,
- CmdID_SetTxPowerLevel,
- CmdID_BBRegWrite10,
- CmdID_WritePortUlong,
- CmdID_WritePortUshort,
- CmdID_WritePortUchar,
- CmdID_RF_WriteReg,
-}SwChnlCmdID;
-
-
-/* 1. Switch channel related */
-typedef struct _SwChnlCmd{
- SwChnlCmdID CmdID;
- u32 Para1;
- u32 Para2;
- u32 msDelay;
-}__attribute__ ((packed)) SwChnlCmd;
-
-extern u32 rtl819XMACPHY_Array_PG[];
-extern u32 rtl819XPHY_REG_1T2RArray[];
-extern u32 rtl819XAGCTAB_Array[];
-extern u32 rtl819XRadioA_Array[];
-extern u32 rtl819XRadioB_Array[];
-extern u32 rtl819XRadioC_Array[];
-extern u32 rtl819XRadioD_Array[];
-
-typedef enum _HW90_BLOCK{
- HW90_BLOCK_MAC = 0,
- HW90_BLOCK_PHY0 = 1,
- HW90_BLOCK_PHY1 = 2,
- HW90_BLOCK_RF = 3,
- HW90_BLOCK_MAXIMUM = 4, // Never use this
-}HW90_BLOCK_E, *PHW90_BLOCK_E;
-
-typedef enum _RF90_RADIO_PATH{
- RF90_PATH_A = 0, //Radio Path A
- RF90_PATH_B = 1, //Radio Path B
- RF90_PATH_C = 2, //Radio Path C
- RF90_PATH_D = 3, //Radio Path D
- RF90_PATH_MAX = 4, //Max RF number 90 support
-}RF90_RADIO_PATH_E, *PRF90_RADIO_PATH_E;
-
-#define bMaskByte0 0xff
-#define bMaskByte1 0xff00
-#define bMaskByte2 0xff0000
-#define bMaskByte3 0xff000000
-#define bMaskHWord 0xffff0000
-#define bMaskLWord 0x0000ffff
-#define bMaskDWord 0xffffffff
-
-typedef enum _VERSION_8190{
- // RTL8190
- VERSION_8190_BD=0x3,
- VERSION_8190_BE
-}VERSION_8190,*PVERSION_8190;
-
-//
-// BB and RF register read/write
-//
-
-extern u32 rtl8192_QueryBBReg(struct net_device* dev,u32 RegAddr, u32 BitMask);
-extern void rtl8192_setBBreg(struct net_device* dev,u32 RegAddr, u32 BitMask,u32 Data);
-extern u32 rtl8192_phy_QueryRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath, u32 RegAddr, u32 BitMask);
-extern void rtl8192_phy_SetRFReg(struct net_device* dev,RF90_RADIO_PATH_E eRFPath, u32 RegAddr,u32 BitMask,u32 Data);
-
-bool rtl8192_phy_checkBBAndRF(struct net_device* dev, HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath);
-
-
-/* MAC/BB/RF HAL config */
-extern bool PHY_MACConfig8192S(struct net_device* dev);
-extern bool PHY_BBConfig8192S(struct net_device* dev);
-extern bool PHY_RFConfig8192S(struct net_device* dev);
-
-extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev,RF90_RADIO_PATH_E eRFPath);
-extern void rtl8192_SetBWMode(struct net_device* dev,HT_CHANNEL_WIDTH ChnlWidth,HT_EXTCHNL_OFFSET Offset );
-extern u8 rtl8192_phy_SwChnl(struct net_device* dev,u8 channel);
-extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device* dev,u32 eRFPath );
-extern void rtl8192_BBConfig(struct net_device* dev);
-extern void PHY_IQCalibrateBcut(struct net_device* dev);
-extern void PHY_IQCalibrate(struct net_device* dev);
-extern void PHY_GetHWRegOriginalValue(struct net_device* dev);
-
-extern void InitialGainOperateWorkItemCallBack(struct work_struct *work);
-
-void PHY_SetTxPowerLevel8192S(struct net_device* dev, u8 channel);
-void PHY_InitialGain8192S(struct net_device* dev,u8 Operation );
-
-/*--------------------------Exported Function prototype---------------------*/
-bool HalSetFwCmd8192S(struct net_device* dev, FW_CMD_IO_TYPE FwCmdIO);
-extern void PHY_SetBeaconHwReg( struct net_device* dev, u16 BeaconInterval);
-void ChkFwCmdIoDone(struct net_device* dev);
-
-#endif // __INC_HAL8192SPHYCFG_H
-
diff --git a/drivers/staging/rtl8192su/r8192S_phyreg.h b/drivers/staging/rtl8192su/r8192S_phyreg.h
deleted file mode 100644
index 2e4d76d196aa..000000000000
--- a/drivers/staging/rtl8192su/r8192S_phyreg.h
+++ /dev/null
@@ -1,1033 +0,0 @@
-/*****************************************************************************
- * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
- *
- * Module: __INC_HAL8192SPHYREG_H
- *
- *
- * Note: 1. Define PMAC/BB register map
- * 2. Define RF register map
- * 3. PMAC/BB register bit mask.
- * 4. RF reg bit mask.
- * 5. Other BB/RF relative definition.
- *
- *
- * Export: Constants, macro, functions(API), global variables(None).
- *
- * Abbrev:
- *
- * History:
- * Data Who Remark
- * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
- * 2. Reorganize code architecture.
- * 09/25/2008 MH 1. Add RL6052 register definition
- *
- *****************************************************************************/
-#ifndef __INC_HAL8192SPHYREG_H
-#define __INC_HAL8192SPHYREG_H
-
-
-/*--------------------------Define Parameters-------------------------------*/
-
-//============================================================
-// 8192S Regsiter offset definition
-//============================================================
-
-//
-// BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF
-// 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
-// 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00
-// 3. RF register 0x00-2E
-// 4. Bit Mask for BB/RF register
-// 5. Other definition for BB/RF R/W
-//
-
-
-//
-// 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
-// 1. Page1(0x100)
-//
-#define rPMAC_Reset 0x100
-#define rPMAC_TxStart 0x104
-#define rPMAC_TxLegacySIG 0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum 0x118
-#define rPMAC_TxIdle 0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType 0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble 0x140
-#define rPMAC_CCKPLCPHeader 0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK 0x170
-#define rPMAC_OFDMRxCRC32Er 0x174
-#define rPMAC_OFDMRxParityEr 0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-//
-// 2. Page2(0x200)
-//
-// The following two definition are only used for USB interface.
-#define RF_BB_CMD_ADDR 0x02c0 // RF/BB read/write command address.
-#define RF_BB_CMD_DATA 0x02c4 // RF/BB read/write command data.
-
-//
-// 3. Page8(0x800)
-//
-#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC // RF BW Setting??
-
-#define rFPGA0_TxInfo 0x804 // Status report??
-#define rFPGA0_PSDFunction 0x808
-
-#define rFPGA0_TxGainStage 0x80c // Set TX PWR init gain?
-
-#define rFPGA0_RFTiming1 0x810 // Useless now
-#define rFPGA0_RFTiming2 0x814
-//#define rFPGA0_XC_RFTiming 0x818
-//#define rFPGA0_XD_RFTiming 0x81c
-
-#define rFPGA0_XA_HSSIParameter1 0x820 // RF 3 wire register
-#define rFPGA0_XA_HSSIParameter2 0x824
-#define rFPGA0_XB_HSSIParameter1 0x828
-#define rFPGA0_XB_HSSIParameter2 0x82c
-#define rFPGA0_XC_HSSIParameter1 0x830
-#define rFPGA0_XC_HSSIParameter2 0x834
-#define rFPGA0_XD_HSSIParameter1 0x838
-#define rFPGA0_XD_HSSIParameter2 0x83c
-#define rFPGA0_XA_LSSIParameter 0x840
-#define rFPGA0_XB_LSSIParameter 0x844
-#define rFPGA0_XC_LSSIParameter 0x848
-#define rFPGA0_XD_LSSIParameter 0x84c
-
-#define rFPGA0_RFWakeUpParameter 0x850 // Useless now
-#define rFPGA0_RFSleepUpParameter 0x854
-
-#define rFPGA0_XAB_SwitchControl 0x858 // RF Channel switch
-#define rFPGA0_XCD_SwitchControl 0x85c
-
-#define rFPGA0_XA_RFInterfaceOE 0x860 // RF Channel switch
-#define rFPGA0_XB_RFInterfaceOE 0x864
-#define rFPGA0_XC_RFInterfaceOE 0x868
-#define rFPGA0_XD_RFInterfaceOE 0x86c
-
-#define rFPGA0_XAB_RFInterfaceSW 0x870 // RF Interface Software Control
-#define rFPGA0_XCD_RFInterfaceSW 0x874
-
-#define rFPGA0_XAB_RFParameter 0x878 // RF Parameter
-#define rFPGA0_XCD_RFParameter 0x87c
-
-#define rFPGA0_AnalogParameter1 0x880 // Crystal cap setting RF-R/W protection for parameter4??
-#define rFPGA0_AnalogParameter2 0x884
-#define rFPGA0_AnalogParameter3 0x888 // Useless now
-#define rFPGA0_AnalogParameter4 0x88c
-
-#define rFPGA0_XA_LSSIReadBack 0x8a0 // Tranceiver LSSI Readback
-#define rFPGA0_XB_LSSIReadBack 0x8a4
-#define rFPGA0_XC_LSSIReadBack 0x8a8
-#define rFPGA0_XD_LSSIReadBack 0x8ac
-
-#define rFPGA0_PSDReport 0x8b4 // Useless now
-#define TransceiverA_HSPI_Readback 0x8b8 // Transceiver A HSPI Readback
-#define TransceiverB_HSPI_Readback 0x8bc // Transceiver B HSPI Readback
-#define rFPGA0_XAB_RFInterfaceRB 0x8e0 // Useless now // RF Interface Readback Value
-#define rFPGA0_XCD_RFInterfaceRB 0x8e4 // Useless now
-
-//
-// 4. Page9(0x900)
-//
-#define rFPGA1_RFMOD 0x900 //RF mode & OFDM TxSC // RF BW Setting??
-
-#define rFPGA1_TxBlock 0x904 // Useless now
-#define rFPGA1_DebugSelect 0x908 // Useless now
-#define rFPGA1_TxInfo 0x90c // Useless now // Status report??
-
-//
-// 5. PageA(0xA00)
-//
-// Set Control channel to upper or lower. These settings are required only for 40MHz
-#define rCCK0_System 0xa00
-
-#define rCCK0_AFESetting 0xa04 // Disable init gain now // Select RX path by RSSI
-#define rCCK0_CCA 0xa08 // Disable init gain now // Init gain
-
-#define rCCK0_RxAGC1 0xa0c //AGC default value, saturation level // Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series
-#define rCCK0_RxAGC2 0xa10 //AGC & DAGC
-
-#define rCCK0_RxHP 0xa14
-
-#define rCCK0_DSPParameter1 0xa18 //Timing recovery & Channel estimation threshold
-#define rCCK0_DSPParameter2 0xa1c //SQ threshold
-
-#define rCCK0_TxFilter1 0xa20
-#define rCCK0_TxFilter2 0xa24
-#define rCCK0_DebugPort 0xa28 //debug port and Tx filter3
-#define rCCK0_FalseAlarmReport 0xa2c //0xa2d useless now 0xa30-a4f channel report
-#define rCCK0_TRSSIReport 0xa50
-#define rCCK0_RxReport 0xa54 //0xa57
-#define rCCK0_FACounterLower 0xa5c //0xa5b
-#define rCCK0_FACounterUpper 0xa58 //0xa5c
-
-//
-// 6. PageC(0xC00)
-//
-#define rOFDM0_LSTF 0xc00
-
-#define rOFDM0_TRxPathEnable 0xc04
-#define rOFDM0_TRMuxPar 0xc08
-#define rOFDM0_TRSWIsolation 0xc0c
-
-#define rOFDM0_XARxAFE 0xc10 //RxIQ DC offset, Rx digital filter, DC notch filter
-#define rOFDM0_XARxIQImbalance 0xc14 //RxIQ imblance matrix
-#define rOFDM0_XBRxAFE 0xc18
-#define rOFDM0_XBRxIQImbalance 0xc1c
-#define rOFDM0_XCRxAFE 0xc20
-#define rOFDM0_XCRxIQImbalance 0xc24
-#define rOFDM0_XDRxAFE 0xc28
-#define rOFDM0_XDRxIQImbalance 0xc2c
-
-#define rOFDM0_RxDetector1 0xc30 //PD,BW & SBD // DM tune init gain
-#define rOFDM0_RxDetector2 0xc34 //SBD & Fame Sync.
-#define rOFDM0_RxDetector3 0xc38 //Frame Sync.
-#define rOFDM0_RxDetector4 0xc3c //PD, SBD, Frame Sync & Short-GI
-
-#define rOFDM0_RxDSP 0xc40 //Rx Sync Path
-#define rOFDM0_CFOandDAGC 0xc44 //CFO & DAGC
-#define rOFDM0_CCADropThreshold 0xc48 //CCA Drop threshold
-#define rOFDM0_ECCAThreshold 0xc4c // energy CCA
-
-#define rOFDM0_XAAGCCore1 0xc50 // DIG
-#define rOFDM0_XAAGCCore2 0xc54
-#define rOFDM0_XBAGCCore1 0xc58
-#define rOFDM0_XBAGCCore2 0xc5c
-#define rOFDM0_XCAGCCore1 0xc60
-#define rOFDM0_XCAGCCore2 0xc64
-#define rOFDM0_XDAGCCore1 0xc68
-#define rOFDM0_XDAGCCore2 0xc6c
-
-#define rOFDM0_AGCParameter1 0xc70
-#define rOFDM0_AGCParameter2 0xc74
-#define rOFDM0_AGCRSSITable 0xc78
-#define rOFDM0_HTSTFAGC 0xc7c
-
-#define rOFDM0_XATxIQImbalance 0xc80 // TX PWR TRACK and DIG
-#define rOFDM0_XATxAFE 0xc84
-#define rOFDM0_XBTxIQImbalance 0xc88
-#define rOFDM0_XBTxAFE 0xc8c
-#define rOFDM0_XCTxIQImbalance 0xc90
-#define rOFDM0_XCTxAFE 0xc94
-#define rOFDM0_XDTxIQImbalance 0xc98
-#define rOFDM0_XDTxAFE 0xc9c
-
-#define rOFDM0_RxHPParameter 0xce0
-#define rOFDM0_TxPseudoNoiseWgt 0xce4
-#define rOFDM0_FrameSync 0xcf0
-#define rOFDM0_DFSReport 0xcf4
-#define rOFDM0_TxCoeff1 0xca4
-#define rOFDM0_TxCoeff2 0xca8
-#define rOFDM0_TxCoeff3 0xcac
-#define rOFDM0_TxCoeff4 0xcb0
-#define rOFDM0_TxCoeff5 0xcb4
-#define rOFDM0_TxCoeff6 0xcb8
-
-
-//
-// 7. PageD(0xD00)
-//
-#define rOFDM1_LSTF 0xd00
-#define rOFDM1_TRxPathEnable 0xd04
-#define rOFDM1_CFO 0xd08 // No setting now
-#define rOFDM1_CSI1 0xd10
-#define rOFDM1_SBD 0xd14
-#define rOFDM1_CSI2 0xd18
-#define rOFDM1_CFOTracking 0xd2c
-#define rOFDM1_TRxMesaure1 0xd34
-#define rOFDM1_IntfDet 0xd3c
-#define rOFDM1_PseudoNoiseStateAB 0xd50
-#define rOFDM1_PseudoNoiseStateCD 0xd54
-#define rOFDM1_RxPseudoNoiseWgt 0xd58
-
-#define rOFDM_PHYCounter1 0xda0 //cca, parity fail
-#define rOFDM_PHYCounter2 0xda4 //rate illegal, crc8 fail
-#define rOFDM_PHYCounter3 0xda8 //MCS not support
-#define rOFDM_ShortCFOAB 0xdac // No setting now
-#define rOFDM_ShortCFOCD 0xdb0
-#define rOFDM_LongCFOAB 0xdb4
-#define rOFDM_LongCFOCD 0xdb8
-#define rOFDM_TailCFOAB 0xdbc
-#define rOFDM_TailCFOCD 0xdc0
-#define rOFDM_PWMeasure1 0xdc4
-#define rOFDM_PWMeasure2 0xdc8
-#define rOFDM_BWReport 0xdcc
-#define rOFDM_AGCReport 0xdd0
-#define rOFDM_RxSNR 0xdd4
-#define rOFDM_RxEVMCSI 0xdd8
-#define rOFDM_SIGReport 0xddc
-
-
-//
-// 8. PageE(0xE00)
-//
-#define rTxAGC_Rate18_06 0xe00
-#define rTxAGC_Rate54_24 0xe04
-#define rTxAGC_CCK_Mcs32 0xe08
-#define rTxAGC_Mcs03_Mcs00 0xe10
-#define rTxAGC_Mcs07_Mcs04 0xe14
-#define rTxAGC_Mcs11_Mcs08 0xe18
-#define rTxAGC_Mcs15_Mcs12 0xe1c
-
-//
-// 7. RF Register 0x00-0x2E (RF 8256)
-// RF-0222D 0x00-3F
-//
-//Zebra1
-#define rZebra1_HSSIEnable 0x0 // Useless now
-#define rZebra1_TRxEnable1 0x1
-#define rZebra1_TRxEnable2 0x2
-#define rZebra1_AGC 0x4
-#define rZebra1_ChargePump 0x5
-//#if (RTL92SE_FPGA_VERIFY == 1)
-#define rZebra1_Channel 0x7 // RF channel switch
-//#else
-
-//#endif
-#define rZebra1_TxGain 0x8 // Useless now
-#define rZebra1_TxLPF 0x9
-#define rZebra1_RxLPF 0xb
-#define rZebra1_RxHPFCorner 0xc
-
-//Zebra4
-#define rGlobalCtrl 0 // Useless now
-#define rRTL8256_TxLPF 19
-#define rRTL8256_RxLPF 11
-
-//RTL8258
-#define rRTL8258_TxLPF 0x11 // Useless now
-#define rRTL8258_RxLPF 0x13
-#define rRTL8258_RSSILPF 0xa
-
-//
-// RL6052 Register definition
-//
-#define RF_AC 0x00 //
-
-#define RF_IQADJ_G1 0x01 //
-#define RF_IQADJ_G2 0x02 //
-#define RF_POW_TRSW 0x05 //
-
-#define RF_GAIN_RX 0x06 //
-#define RF_GAIN_TX 0x07 //
-
-#define RF_TXM_IDAC 0x08 //
-#define RF_BS_IQGEN 0x0F //
-
-#define RF_MODE1 0x10 //
-#define RF_MODE2 0x11 //
-
-#define RF_RX_AGC_HP 0x12 //
-#define RF_TX_AGC 0x13 //
-#define RF_BIAS 0x14 //
-#define RF_IPA 0x15 //
-#define RF_POW_ABILITY 0x17 //
-#define RF_MODE_AG 0x18 //
-#define rRfChannel 0x18 // RF channel and BW switch
-#define RF_CHNLBW 0x18 // RF channel and BW switch
-#define RF_TOP 0x19 //
-
-#define RF_RX_G1 0x1A //
-#define RF_RX_G2 0x1B //
-
-#define RF_RX_BB2 0x1C //
-#define RF_RX_BB1 0x1D //
-
-#define RF_RCK1 0x1E //
-#define RF_RCK2 0x1F //
-
-#define RF_TX_G1 0x20 //
-#define RF_TX_G2 0x21 //
-#define RF_TX_G3 0x22 //
-
-#define RF_TX_BB1 0x23 //
-
-#define RF_T_METER 0x24 //
-
-#define RF_SYN_G1 0x25 // RF TX Power control
-#define RF_SYN_G2 0x26 // RF TX Power control
-#define RF_SYN_G3 0x27 // RF TX Power control
-#define RF_SYN_G4 0x28 // RF TX Power control
-#define RF_SYN_G5 0x29 // RF TX Power control
-#define RF_SYN_G6 0x2A // RF TX Power control
-#define RF_SYN_G7 0x2B // RF TX Power control
-#define RF_SYN_G8 0x2C // RF TX Power control
-
-#define RF_RCK_OS 0x30 // RF TX PA control
-
-#define RF_TXPA_G1 0x31 // RF TX PA control
-#define RF_TXPA_G2 0x32 // RF TX PA control
-#define RF_TXPA_G3 0x33 // RF TX PA control
-
-//
-//Bit Mask
-//
-// 1. Page1(0x100)
-#define bBBResetB 0x100 // Useless now?
-#define bGlobalResetB 0x200
-#define bOFDMTxStart 0x4
-#define bCCKTxStart 0x8
-#define bCRC32Debug 0x100
-#define bPMACLoopback 0x10
-#define bTxLSIG 0xffffff
-#define bOFDMTxRate 0xf
-#define bOFDMTxReserved 0x10
-#define bOFDMTxLength 0x1ffe0
-#define bOFDMTxParity 0x20000
-#define bTxHTSIG1 0xffffff
-#define bTxHTMCSRate 0x7f
-#define bTxHTBW 0x80
-#define bTxHTLength 0xffff00
-#define bTxHTSIG2 0xffffff
-#define bTxHTSmoothing 0x1
-#define bTxHTSounding 0x2
-#define bTxHTReserved 0x4
-#define bTxHTAggreation 0x8
-#define bTxHTSTBC 0x30
-#define bTxHTAdvanceCoding 0x40
-#define bTxHTShortGI 0x80
-#define bTxHTNumberHT_LTF 0x300
-#define bTxHTCRC8 0x3fc00
-#define bCounterReset 0x10000
-#define bNumOfOFDMTx 0xffff
-#define bNumOfCCKTx 0xffff0000
-#define bTxIdleInterval 0xffff
-#define bOFDMService 0xffff0000
-#define bTxMACHeader 0xffffffff
-#define bTxDataInit 0xff
-#define bTxHTMode 0x100
-#define bTxDataType 0x30000
-#define bTxRandomSeed 0xffffffff
-#define bCCKTxPreamble 0x1
-#define bCCKTxSFD 0xffff0000
-#define bCCKTxSIG 0xff
-#define bCCKTxService 0xff00
-#define bCCKLengthExt 0x8000
-#define bCCKTxLength 0xffff0000
-#define bCCKTxCRC16 0xffff
-#define bCCKTxStatus 0x1
-#define bOFDMTxStatus 0x2
-
-#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff))
-
-// 2. Page8(0x800)
-#define bRFMOD 0x1 // Reg 0x800 rFPGA0_RFMOD
-#define bJapanMode 0x2
-#define bCCKTxSC 0x30
-#define bCCKEn 0x1000000
-#define bOFDMEn 0x2000000
-
-#define bOFDMRxADCPhase 0x10000 // Useless now
-#define bOFDMTxDACPhase 0x40000
-#define bXATxAGC 0x3f
-
-#define bXBTxAGC 0xf00 // Reg 80c rFPGA0_TxGainStage
-#define bXCTxAGC 0xf000
-#define bXDTxAGC 0xf0000
-
-#define bPAStart 0xf0000000 // Useless now
-#define bTRStart 0x00f00000
-#define bRFStart 0x0000f000
-#define bBBStart 0x000000f0
-#define bBBCCKStart 0x0000000f
-#define bPAEnd 0xf //Reg0x814
-#define bTREnd 0x0f000000
-#define bRFEnd 0x000f0000
-#define bCCAMask 0x000000f0 //T2R
-#define bR2RCCAMask 0x00000f00
-#define bHSSI_R2TDelay 0xf8000000
-#define bHSSI_T2RDelay 0xf80000
-#define bContTxHSSI 0x400 //channel gain at continue Tx
-#define bIGFromCCK 0x200
-#define bAGCAddress 0x3f
-#define bRxHPTx 0x7000
-#define bRxHPT2R 0x38000
-#define bRxHPCCKIni 0xc0000
-#define bAGCTxCode 0xc00000
-#define bAGCRxCode 0x300000
-
-#define b3WireDataLength 0x800 // Reg 0x820~84f rFPGA0_XA_HSSIParameter1
-#define b3WireAddressLength 0x400
-
-#define b3WireRFPowerDown 0x1 // Useless now
-//#define bHWSISelect 0x8
-#define b5GPAPEPolarity 0x40000000
-#define b2GPAPEPolarity 0x80000000
-#define bRFSW_TxDefaultAnt 0x3
-#define bRFSW_TxOptionAnt 0x30
-#define bRFSW_RxDefaultAnt 0x300
-#define bRFSW_RxOptionAnt 0x3000
-#define bRFSI_3WireData 0x1
-#define bRFSI_3WireClock 0x2
-#define bRFSI_3WireLoad 0x4
-#define bRFSI_3WireRW 0x8
-#define bRFSI_3Wire 0xf
-
-#define bRFSI_RFENV 0x10 // Reg 0x870 rFPGA0_XAB_RFInterfaceSW
-
-#define bRFSI_TRSW 0x20 // Useless now
-#define bRFSI_TRSWB 0x40
-#define bRFSI_ANTSW 0x100
-#define bRFSI_ANTSWB 0x200
-#define bRFSI_PAPE 0x400
-#define bRFSI_PAPE5G 0x800
-#define bBandSelect 0x1
-#define bHTSIG2_GI 0x80
-#define bHTSIG2_Smoothing 0x01
-#define bHTSIG2_Sounding 0x02
-#define bHTSIG2_Aggreaton 0x08
-#define bHTSIG2_STBC 0x30
-#define bHTSIG2_AdvCoding 0x40
-#define bHTSIG2_NumOfHTLTF 0x300
-#define bHTSIG2_CRC8 0x3fc
-#define bHTSIG1_MCS 0x7f
-#define bHTSIG1_BandWidth 0x80
-#define bHTSIG1_HTLength 0xffff
-#define bLSIG_Rate 0xf
-#define bLSIG_Reserved 0x10
-#define bLSIG_Length 0x1fffe
-#define bLSIG_Parity 0x20
-#define bCCKRxPhase 0x4
-#define bLSSIReadAddress 0x7f800000 // T65 RF
-#define bLSSIReadEdge 0x80000000 //LSSI "Read" edge signal
-#define bLSSIReadBackData 0xfffff // T65 RF
-#define bLSSIReadOKFlag 0x1000 // Useless now
-#define bCCKSampleRate 0x8 //0: 44MHz, 1:88MHz
-#define bRegulator0Standby 0x1
-#define bRegulatorPLLStandby 0x2
-#define bRegulator1Standby 0x4
-#define bPLLPowerUp 0x8
-#define bDPLLPowerUp 0x10
-#define bDA10PowerUp 0x20
-#define bAD7PowerUp 0x200
-#define bDA6PowerUp 0x2000
-#define bXtalPowerUp 0x4000
-#define b40MDClkPowerUP 0x8000
-#define bDA6DebugMode 0x20000
-#define bDA6Swing 0x380000
-
-#define bADClkPhase 0x4000000 // Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ
-
-#define b80MClkDelay 0x18000000 // Useless
-#define bAFEWatchDogEnable 0x20000000
-
-#define bXtalCap01 0xc0000000 // Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap
-#define bXtalCap23 0x3
-#define bXtalCap92x 0x0f000000
-#define bXtalCap 0x0f000000
-
-#define bIntDifClkEnable 0x400 // Useless
-#define bExtSigClkEnable 0x800
-#define bBandgapMbiasPowerUp 0x10000
-#define bAD11SHGain 0xc0000
-#define bAD11InputRange 0x700000
-#define bAD11OPCurrent 0x3800000
-#define bIPathLoopback 0x4000000
-#define bQPathLoopback 0x8000000
-#define bAFELoopback 0x10000000
-#define bDA10Swing 0x7e0
-#define bDA10Reverse 0x800
-#define bDAClkSource 0x1000
-#define bAD7InputRange 0x6000
-#define bAD7Gain 0x38000
-#define bAD7OutputCMMode 0x40000
-#define bAD7InputCMMode 0x380000
-#define bAD7Current 0xc00000
-#define bRegulatorAdjust 0x7000000
-#define bAD11PowerUpAtTx 0x1
-#define bDA10PSAtTx 0x10
-#define bAD11PowerUpAtRx 0x100
-#define bDA10PSAtRx 0x1000
-#define bCCKRxAGCFormat 0x200
-#define bPSDFFTSamplepPoint 0xc000
-#define bPSDAverageNum 0x3000
-#define bIQPathControl 0xc00
-#define bPSDFreq 0x3ff
-#define bPSDAntennaPath 0x30
-#define bPSDIQSwitch 0x40
-#define bPSDRxTrigger 0x400000
-#define bPSDTxTrigger 0x80000000
-#define bPSDSineToneScale 0x7f000000
-#define bPSDReport 0xffff
-
-// 3. Page9(0x900)
-#define bOFDMTxSC 0x30000000 // Useless
-#define bCCKTxOn 0x1
-#define bOFDMTxOn 0x2
-#define bDebugPage 0xfff //reset debug page and also HWord, LWord
-#define bDebugItem 0xff //reset debug page and LWord
-#define bAntL 0x10
-#define bAntNonHT 0x100
-#define bAntHT1 0x1000
-#define bAntHT2 0x10000
-#define bAntHT1S1 0x100000
-#define bAntNonHTS1 0x1000000
-
-// 4. PageA(0xA00)
-#define bCCKBBMode 0x3 // Useless
-#define bCCKTxPowerSaving 0x80
-#define bCCKRxPowerSaving 0x40
-
-#define bCCKSideBand 0x10 // Reg 0xa00 rCCK0_System 20/40 switch
-
-#define bCCKScramble 0x8 // Useless
-#define bCCKAntDiversity 0x8000
-#define bCCKCarrierRecovery 0x4000
-#define bCCKTxRate 0x3000
-#define bCCKDCCancel 0x0800
-#define bCCKISICancel 0x0400
-#define bCCKMatchFilter 0x0200
-#define bCCKEqualizer 0x0100
-#define bCCKPreambleDetect 0x800000
-#define bCCKFastFalseCCA 0x400000
-#define bCCKChEstStart 0x300000
-#define bCCKCCACount 0x080000
-#define bCCKcs_lim 0x070000
-#define bCCKBistMode 0x80000000
-#define bCCKCCAMask 0x40000000
-#define bCCKTxDACPhase 0x4
-#define bCCKRxADCPhase 0x20000000 //r_rx_clk
-#define bCCKr_cp_mode0 0x0100
-#define bCCKTxDCOffset 0xf0
-#define bCCKRxDCOffset 0xf
-#define bCCKCCAMode 0xc000
-#define bCCKFalseCS_lim 0x3f00
-#define bCCKCS_ratio 0xc00000
-#define bCCKCorgBit_sel 0x300000
-#define bCCKPD_lim 0x0f0000
-#define bCCKNewCCA 0x80000000
-#define bCCKRxHPofIG 0x8000
-#define bCCKRxIG 0x7f00
-#define bCCKLNAPolarity 0x800000
-#define bCCKRx1stGain 0x7f0000
-#define bCCKRFExtend 0x20000000 //CCK Rx Iinital gain polarity
-#define bCCKRxAGCSatLevel 0x1f000000
-#define bCCKRxAGCSatCount 0xe0
-#define bCCKRxRFSettle 0x1f //AGCsamp_dly
-#define bCCKFixedRxAGC 0x8000
-//#define bCCKRxAGCFormat 0x4000 //remove to HSSI register 0x824
-#define bCCKAntennaPolarity 0x2000
-#define bCCKTxFilterType 0x0c00
-#define bCCKRxAGCReportType 0x0300
-#define bCCKRxDAGCEn 0x80000000
-#define bCCKRxDAGCPeriod 0x20000000
-#define bCCKRxDAGCSatLevel 0x1f000000
-#define bCCKTimingRecovery 0x800000
-#define bCCKTxC0 0x3f0000
-#define bCCKTxC1 0x3f000000
-#define bCCKTxC2 0x3f
-#define bCCKTxC3 0x3f00
-#define bCCKTxC4 0x3f0000
-#define bCCKTxC5 0x3f000000
-#define bCCKTxC6 0x3f
-#define bCCKTxC7 0x3f00
-#define bCCKDebugPort 0xff0000
-#define bCCKDACDebug 0x0f000000
-#define bCCKFalseAlarmEnable 0x8000
-#define bCCKFalseAlarmRead 0x4000
-#define bCCKTRSSI 0x7f
-#define bCCKRxAGCReport 0xfe
-#define bCCKRxReport_AntSel 0x80000000
-#define bCCKRxReport_MFOff 0x40000000
-#define bCCKRxRxReport_SQLoss 0x20000000
-#define bCCKRxReport_Pktloss 0x10000000
-#define bCCKRxReport_Lockedbit 0x08000000
-#define bCCKRxReport_RateError 0x04000000
-#define bCCKRxReport_RxRate 0x03000000
-#define bCCKRxFACounterLower 0xff
-#define bCCKRxFACounterUpper 0xff000000
-#define bCCKRxHPAGCStart 0xe000
-#define bCCKRxHPAGCFinal 0x1c00
-#define bCCKRxFalseAlarmEnable 0x8000
-#define bCCKFACounterFreeze 0x4000
-#define bCCKTxPathSel 0x10000000
-#define bCCKDefaultRxPath 0xc000000
-#define bCCKOptionRxPath 0x3000000
-
-// 5. PageC(0xC00)
-#define bNumOfSTF 0x3 // Useless
-#define bShift_L 0xc0
-#define bGI_TH 0xc
-#define bRxPathA 0x1
-#define bRxPathB 0x2
-#define bRxPathC 0x4
-#define bRxPathD 0x8
-#define bTxPathA 0x1
-#define bTxPathB 0x2
-#define bTxPathC 0x4
-#define bTxPathD 0x8
-#define bTRSSIFreq 0x200
-#define bADCBackoff 0x3000
-#define bDFIRBackoff 0xc000
-#define bTRSSILatchPhase 0x10000
-#define bRxIDCOffset 0xff
-#define bRxQDCOffset 0xff00
-#define bRxDFIRMode 0x1800000
-#define bRxDCNFType 0xe000000
-#define bRXIQImb_A 0x3ff
-#define bRXIQImb_B 0xfc00
-#define bRXIQImb_C 0x3f0000
-#define bRXIQImb_D 0xffc00000
-#define bDC_dc_Notch 0x60000
-#define bRxNBINotch 0x1f000000
-#define bPD_TH 0xf
-#define bPD_TH_Opt2 0xc000
-#define bPWED_TH 0x700
-#define bIfMF_Win_L 0x800
-#define bPD_Option 0x1000
-#define bMF_Win_L 0xe000
-#define bBW_Search_L 0x30000
-#define bwin_enh_L 0xc0000
-#define bBW_TH 0x700000
-#define bED_TH2 0x3800000
-#define bBW_option 0x4000000
-#define bRatio_TH 0x18000000
-#define bWindow_L 0xe0000000
-#define bSBD_Option 0x1
-#define bFrame_TH 0x1c
-#define bFS_Option 0x60
-#define bDC_Slope_check 0x80
-#define bFGuard_Counter_DC_L 0xe00
-#define bFrame_Weight_Short 0x7000
-#define bSub_Tune 0xe00000
-#define bFrame_DC_Length 0xe000000
-#define bSBD_start_offset 0x30000000
-#define bFrame_TH_2 0x7
-#define bFrame_GI2_TH 0x38
-#define bGI2_Sync_en 0x40
-#define bSarch_Short_Early 0x300
-#define bSarch_Short_Late 0xc00
-#define bSarch_GI2_Late 0x70000
-#define bCFOAntSum 0x1
-#define bCFOAcc 0x2
-#define bCFOStartOffset 0xc
-#define bCFOLookBack 0x70
-#define bCFOSumWeight 0x80
-#define bDAGCEnable 0x10000
-#define bTXIQImb_A 0x3ff
-#define bTXIQImb_B 0xfc00
-#define bTXIQImb_C 0x3f0000
-#define bTXIQImb_D 0xffc00000
-#define bTxIDCOffset 0xff
-#define bTxQDCOffset 0xff00
-#define bTxDFIRMode 0x10000
-#define bTxPesudoNoiseOn 0x4000000
-#define bTxPesudoNoise_A 0xff
-#define bTxPesudoNoise_B 0xff00
-#define bTxPesudoNoise_C 0xff0000
-#define bTxPesudoNoise_D 0xff000000
-#define bCCADropOption 0x20000
-#define bCCADropThres 0xfff00000
-#define bEDCCA_H 0xf
-#define bEDCCA_L 0xf0
-#define bLambda_ED 0x300
-#define bRxInitialGain 0x7f
-#define bRxAntDivEn 0x80
-#define bRxAGCAddressForLNA 0x7f00
-#define bRxHighPowerFlow 0x8000
-#define bRxAGCFreezeThres 0xc0000
-#define bRxFreezeStep_AGC1 0x300000
-#define bRxFreezeStep_AGC2 0xc00000
-#define bRxFreezeStep_AGC3 0x3000000
-#define bRxFreezeStep_AGC0 0xc000000
-#define bRxRssi_Cmp_En 0x10000000
-#define bRxQuickAGCEn 0x20000000
-#define bRxAGCFreezeThresMode 0x40000000
-#define bRxOverFlowCheckType 0x80000000
-#define bRxAGCShift 0x7f
-#define bTRSW_Tri_Only 0x80
-#define bPowerThres 0x300
-#define bRxAGCEn 0x1
-#define bRxAGCTogetherEn 0x2
-#define bRxAGCMin 0x4
-#define bRxHP_Ini 0x7
-#define bRxHP_TRLNA 0x70
-#define bRxHP_RSSI 0x700
-#define bRxHP_BBP1 0x7000
-#define bRxHP_BBP2 0x70000
-#define bRxHP_BBP3 0x700000
-#define bRSSI_H 0x7f0000 //the threshold for high power
-#define bRSSI_Gen 0x7f000000 //the threshold for ant diversity
-#define bRxSettle_TRSW 0x7
-#define bRxSettle_LNA 0x38
-#define bRxSettle_RSSI 0x1c0
-#define bRxSettle_BBP 0xe00
-#define bRxSettle_RxHP 0x7000
-#define bRxSettle_AntSW_RSSI 0x38000
-#define bRxSettle_AntSW 0xc0000
-#define bRxProcessTime_DAGC 0x300000
-#define bRxSettle_HSSI 0x400000
-#define bRxProcessTime_BBPPW 0x800000
-#define bRxAntennaPowerShift 0x3000000
-#define bRSSITableSelect 0xc000000
-#define bRxHP_Final 0x7000000
-#define bRxHTSettle_BBP 0x7
-#define bRxHTSettle_HSSI 0x8
-#define bRxHTSettle_RxHP 0x70
-#define bRxHTSettle_BBPPW 0x80
-#define bRxHTSettle_Idle 0x300
-#define bRxHTSettle_Reserved 0x1c00
-#define bRxHTRxHPEn 0x8000
-#define bRxHTAGCFreezeThres 0x30000
-#define bRxHTAGCTogetherEn 0x40000
-#define bRxHTAGCMin 0x80000
-#define bRxHTAGCEn 0x100000
-#define bRxHTDAGCEn 0x200000
-#define bRxHTRxHP_BBP 0x1c00000
-#define bRxHTRxHP_Final 0xe0000000
-#define bRxPWRatioTH 0x3
-#define bRxPWRatioEn 0x4
-#define bRxMFHold 0x3800
-#define bRxPD_Delay_TH1 0x38
-#define bRxPD_Delay_TH2 0x1c0
-#define bRxPD_DC_COUNT_MAX 0x600
-//#define bRxMF_Hold 0x3800
-#define bRxPD_Delay_TH 0x8000
-#define bRxProcess_Delay 0xf0000
-#define bRxSearchrange_GI2_Early 0x700000
-#define bRxFrame_Guard_Counter_L 0x3800000
-#define bRxSGI_Guard_L 0xc000000
-#define bRxSGI_Search_L 0x30000000
-#define bRxSGI_TH 0xc0000000
-#define bDFSCnt0 0xff
-#define bDFSCnt1 0xff00
-#define bDFSFlag 0xf0000
-#define bMFWeightSum 0x300000
-#define bMinIdxTH 0x7f000000
-#define bDAFormat 0x40000
-#define bTxChEmuEnable 0x01000000
-#define bTRSWIsolation_A 0x7f
-#define bTRSWIsolation_B 0x7f00
-#define bTRSWIsolation_C 0x7f0000
-#define bTRSWIsolation_D 0x7f000000
-#define bExtLNAGain 0x7c00
-
-// 6. PageE(0xE00)
-#define bSTBCEn 0x4 // Useless
-#define bAntennaMapping 0x10
-#define bNss 0x20
-#define bCFOAntSumD 0x200
-#define bPHYCounterReset 0x8000000
-#define bCFOReportGet 0x4000000
-#define bOFDMContinueTx 0x10000000
-#define bOFDMSingleCarrier 0x20000000
-#define bOFDMSingleTone 0x40000000
-//#define bRxPath1 0x01
-//#define bRxPath2 0x02
-//#define bRxPath3 0x04
-//#define bRxPath4 0x08
-//#define bTxPath1 0x10
-//#define bTxPath2 0x20
-#define bHTDetect 0x100
-#define bCFOEn 0x10000
-#define bCFOValue 0xfff00000
-#define bSigTone_Re 0x3f
-#define bSigTone_Im 0x7f00
-#define bCounter_CCA 0xffff
-#define bCounter_ParityFail 0xffff0000
-#define bCounter_RateIllegal 0xffff
-#define bCounter_CRC8Fail 0xffff0000
-#define bCounter_MCSNoSupport 0xffff
-#define bCounter_FastSync 0xffff
-#define bShortCFO 0xfff
-#define bShortCFOTLength 12 //total
-#define bShortCFOFLength 11 //fraction
-#define bLongCFO 0x7ff
-#define bLongCFOTLength 11
-#define bLongCFOFLength 11
-#define bTailCFO 0x1fff
-#define bTailCFOTLength 13
-#define bTailCFOFLength 12
-#define bmax_en_pwdB 0xffff
-#define bCC_power_dB 0xffff0000
-#define bnoise_pwdB 0xffff
-#define bPowerMeasTLength 10
-#define bPowerMeasFLength 3
-#define bRx_HT_BW 0x1
-#define bRxSC 0x6
-#define bRx_HT 0x8
-#define bNB_intf_det_on 0x1
-#define bIntf_win_len_cfg 0x30
-#define bNB_Intf_TH_cfg 0x1c0
-#define bRFGain 0x3f
-#define bTableSel 0x40
-#define bTRSW 0x80
-#define bRxSNR_A 0xff
-#define bRxSNR_B 0xff00
-#define bRxSNR_C 0xff0000
-#define bRxSNR_D 0xff000000
-#define bSNREVMTLength 8
-#define bSNREVMFLength 1
-#define bCSI1st 0xff
-#define bCSI2nd 0xff00
-#define bRxEVM1st 0xff0000
-#define bRxEVM2nd 0xff000000
-#define bSIGEVM 0xff
-#define bPWDB 0xff00
-#define bSGIEN 0x10000
-
-#define bSFactorQAM1 0xf // Useless
-#define bSFactorQAM2 0xf0
-#define bSFactorQAM3 0xf00
-#define bSFactorQAM4 0xf000
-#define bSFactorQAM5 0xf0000
-#define bSFactorQAM6 0xf0000
-#define bSFactorQAM7 0xf00000
-#define bSFactorQAM8 0xf000000
-#define bSFactorQAM9 0xf0000000
-#define bCSIScheme 0x100000
-
-#define bNoiseLvlTopSet 0x3 // Useless
-#define bChSmooth 0x4
-#define bChSmoothCfg1 0x38
-#define bChSmoothCfg2 0x1c0
-#define bChSmoothCfg3 0xe00
-#define bChSmoothCfg4 0x7000
-#define bMRCMode 0x800000
-#define bTHEVMCfg 0x7000000
-
-#define bLoopFitType 0x1 // Useless
-#define bUpdCFO 0x40
-#define bUpdCFOOffData 0x80
-#define bAdvUpdCFO 0x100
-#define bAdvTimeCtrl 0x800
-#define bUpdClko 0x1000
-#define bFC 0x6000
-#define bTrackingMode 0x8000
-#define bPhCmpEnable 0x10000
-#define bUpdClkoLTF 0x20000
-#define bComChCFO 0x40000
-#define bCSIEstiMode 0x80000
-#define bAdvUpdEqz 0x100000
-#define bUChCfg 0x7000000
-#define bUpdEqz 0x8000000
-
-#define bTxAGCRate18_06 0x7f7f7f7f // Useless
-#define bTxAGCRate54_24 0x7f7f7f7f
-#define bTxAGCRateMCS32 0x7f
-#define bTxAGCRateCCK 0x7f00
-#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
-#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
-#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
-#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
-
-//Rx Pseduo noise
-#define bRxPesudoNoiseOn 0x20000000 // Useless
-#define bRxPesudoNoise_A 0xff
-#define bRxPesudoNoise_B 0xff00
-#define bRxPesudoNoise_C 0xff0000
-#define bRxPesudoNoise_D 0xff000000
-#define bPesudoNoiseState_A 0xffff
-#define bPesudoNoiseState_B 0xffff0000
-#define bPesudoNoiseState_C 0xffff
-#define bPesudoNoiseState_D 0xffff0000
-
-//7. RF Register
-//Zebra1
-#define bZebra1_HSSIEnable 0x8 // Useless
-#define bZebra1_TRxControl 0xc00
-#define bZebra1_TRxGainSetting 0x07f
-#define bZebra1_RxCorner 0xc00
-#define bZebra1_TxChargePump 0x38
-#define bZebra1_RxChargePump 0x7
-#define bZebra1_ChannelNum 0xf80
-#define bZebra1_TxLPFBW 0x400
-#define bZebra1_RxLPFBW 0x600
-
-//Zebra4
-#define bRTL8256RegModeCtrl1 0x100 // Useless
-#define bRTL8256RegModeCtrl0 0x40
-#define bRTL8256_TxLPFBW 0x18
-#define bRTL8256_RxLPFBW 0x600
-
-//RTL8258
-#define bRTL8258_TxLPFBW 0xc // Useless
-#define bRTL8258_RxLPFBW 0xc00
-#define bRTL8258_RSSILPFBW 0xc0
-
-
-//
-// Other Definition
-//
-
-//byte endable for sb_write
-#define bByte0 0x1 // Useless
-#define bByte1 0x2
-#define bByte2 0x4
-#define bByte3 0x8
-#define bWord0 0x3
-#define bWord1 0xc
-#define bDWord 0xf
-
-//for PutRegsetting & GetRegSetting BitMask
-#define bMaskByte0 0xff // Reg 0xc50 rOFDM0_XAAGCCore~0xC6f
-#define bMaskByte1 0xff00
-#define bMaskByte2 0xff0000
-#define bMaskByte3 0xff000000
-#define bMaskHWord 0xffff0000
-#define bMaskLWord 0x0000ffff
-#define bMaskDWord 0xffffffff
-
-//for PutRFRegsetting & GetRFRegSetting BitMask
-#define bMask12Bits 0xfffff // RF Reg mask bits
-#define bMask20Bits 0xfffff // RF Reg mask bits T65 RF
-#define bRFRegOffsetMask 0xfffff
-
-#define bEnable 0x1 // Useless
-#define bDisable 0x0
-
-#define LeftAntenna 0x0 // Useless
-#define RightAntenna 0x1
-
-#define tCheckTxStatus 500 //500ms // Useless
-#define tUpdateRxCounter 100 //100ms
-
-#define rateCCK 0 // Useless
-#define rateOFDM 1
-#define rateHT 2
-
-//define Register-End
-#define bPMAC_End 0x1ff // Useless
-#define bFPGAPHY0_End 0x8ff
-#define bFPGAPHY1_End 0x9ff
-#define bCCKPHY0_End 0xaff
-#define bOFDMPHY0_End 0xcff
-#define bOFDMPHY1_End 0xdff
-
-//define max debug item in each debug page
-//#define bMaxItem_FPGA_PHY0 0x9
-//#define bMaxItem_FPGA_PHY1 0x3
-//#define bMaxItem_PHY_11B 0x16
-//#define bMaxItem_OFDM_PHY0 0x29
-//#define bMaxItem_OFDM_PHY1 0x0
-
-#define bPMACControl 0x0 // Useless
-#define bWMACControl 0x1
-#define bWNICControl 0x2
-
-#define PathA 0x0 // Useless
-#define PathB 0x1
-#define PathC 0x2
-#define PathD 0x3
-
-/*--------------------------Define Parameters-------------------------------*/
-
-
-#endif //__INC_HAL8192SPHYREG_H
-
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.c b/drivers/staging/rtl8192su/r8192S_rtl6052.c
deleted file mode 100644
index 22398099adae..000000000000
--- a/drivers/staging/rtl8192su/r8192S_rtl6052.c
+++ /dev/null
@@ -1,842 +0,0 @@
-/******************************************************************************
- *
- * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
- *
- * Module: HalRf6052.c ( Source C File)
- *
- * Note: Provide RF 6052 series relative API.
- *
- * Function:
- *
- * Export:
- *
- * Abbrev:
- *
- * History:
- * Data Who Remark
- *
- * 09/25/2008 MHC Create initial version.
- * 11/05/2008 MHC Add API for tw power setting.
- *
- *
-******************************************************************************/
-#include "r8192U.h"
-#include "r8192S_rtl6052.h"
-
-#include "r8192S_hw.h"
-#include "r8192S_phyreg.h"
-#include "r8192S_phy.h"
-
-
-/*---------------------------Define Local Constant---------------------------*/
-// Define local structure for debug!!!!!
-typedef struct RF_Shadow_Compare_Map {
- // Shadow register value
- u32 Value;
- // Compare or not flag
- u8 Compare;
- // Record If it had ever modified unpredicted
- u8 ErrorOrNot;
- // Recorver Flag
- u8 Recorver;
- //
- u8 Driver_Write;
-}RF_SHADOW_T;
-/*---------------------------Define Local Constant---------------------------*/
-
-
-/*------------------------Define global variable-----------------------------*/
-/*------------------------Define global variable-----------------------------*/
-
-
-
-
-/*---------------------Define local function prototype-----------------------*/
-void phy_RF6052_Config_HardCode(struct net_device* dev);
-
-RT_STATUS phy_RF6052_Config_ParaFile(struct net_device* dev);
-/*---------------------Define local function prototype-----------------------*/
-
-/*------------------------Define function prototype--------------------------*/
-extern void RF_ChangeTxPath(struct net_device* dev, u16 DataRate);
-
-/*------------------------Define function prototype--------------------------*/
-
-/*------------------------Define local variable------------------------------*/
-// 2008/11/20 MH For Debug only, RF
-static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];// = {{0}};//FIXLZM
-/*------------------------Define local variable------------------------------*/
-
-/*------------------------Define function prototype--------------------------*/
-/*-----------------------------------------------------------------------------
- * Function: RF_ChangeTxPath
- *
- * Overview: For RL6052, we must change some RF settign for 1T or 2T.
- *
- * Input: u16 DataRate // 0x80-8f, 0x90-9f
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 09/25/2008 MHC Create Version 0.
- * Firmwaer support the utility later.
- *
- *---------------------------------------------------------------------------*/
-extern void RF_ChangeTxPath(struct net_device* dev, u16 DataRate)
-{
-} /* RF_ChangeTxPath */
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_RF6052SetBandwidth()
- *
- * Overview: This function is called by SetBWModeCallback8190Pci() only
- *
- * Input: PADAPTER Adapter
- * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: For RF type 0222D
- *---------------------------------------------------------------------------*/
-void PHY_RF6052SetBandwidth(struct net_device* dev, HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
-{
- //u8 eRFPath;
- //struct r8192_priv *priv = ieee80211_priv(dev);
-
-
- //if (priv->card_8192 == NIC_8192SE)
- {
- switch(Bandwidth)
- {
- case HT_CHANNEL_WIDTH_20:
- //if (priv->card_8192_version >= VERSION_8192S_BCUT)
- // rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);
-
- rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x01);
- break;
- case HT_CHANNEL_WIDTH_20_40:
- //if (priv->card_8192_version >= VERSION_8192S_BCUT)
- // rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18);
-
- rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x00);
- break;
- default:
- RT_TRACE(COMP_DBG, "PHY_SetRF6052Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth);
- break;
- }
- }
-// else
-}
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_RF6052SetCckTxPower
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/05/2008 MHC Simulate 8192series..
- *
- *---------------------------------------------------------------------------*/
-extern void PHY_RF6052SetCckTxPower(struct net_device* dev, u8 powerlevel)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 TxAGC=0;
-
- if(priv->ieee80211->scanning == 1)
- TxAGC = 0x3f;
- else if(priv->bDynamicTxLowPower == true)//cosa 04282008 for cck long range
- TxAGC = 0x22;
- else
- TxAGC = powerlevel;
-
- //cosa add for lenovo, to pass the safety spec, don't increase power index for different rates.
- if(priv->bIgnoreDiffRateTxPowerOffset)
- TxAGC = powerlevel;
-
- if(TxAGC > RF6052_MAX_TX_PWR)
- TxAGC = RF6052_MAX_TX_PWR;
-
- //printk("CCK PWR= %x\n", TxAGC);
- rtl8192_setBBreg(dev, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
-
-} /* PHY_RF6052SetCckTxPower */
-
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_RF6052SetOFDMTxPower
- *
- * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for
- * different channel and read original value in TX power register area from
- * 0xe00. We increase offset and original value to be correct tx pwr.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/05/2008 MHC Simulate 8192 series method.
-* 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to
- * A/B pwr difference or legacy/HT pwr diff.
- * 2. We concern with path B legacy/HT OFDM difference.
- * 01/22/2009 MHC Support new EPRO format from SD3.
- *---------------------------------------------------------------------------*/
- #if 1
-extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 writeVal, powerBase0, powerBase1;
- u8 index = 0;
- u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
- //u8 byte0, byte1, byte2, byte3;
- u8 Channel = priv->ieee80211->current_network.channel;
- u8 rfa_pwr[4];
- u8 rfa_lower_bound = 0, rfa_upper_bound = 0 /*, rfa_htpwr, rfa_legacypwr*/;
- u8 i;
- u8 rf_pwr_diff = 0;
- u8 Legacy_pwrdiff=0, HT20_pwrdiff=0, BandEdge_Pwrdiff=0;
- u8 ofdm_bandedge_chnl_low=0, ofdm_bandedge_chnl_high=0;
-
-
- // We only care about the path A for legacy.
- if (priv->EEPROMVersion != 2)
- powerBase0 = powerlevel + (priv->LegacyHTTxPowerDiff & 0xf);
- else if (priv->EEPROMVersion == 2) // Defined by SD1 Jong
- {
- //
- // 2009/01/21 MH Support new EEPROM format from SD3 requirement
- //
- Legacy_pwrdiff = priv->TxPwrLegacyHtDiff[RF90_PATH_A][Channel-1];
- // For legacy OFDM, tx pwr always > HT OFDM pwr. We do not care Path B
- // legacy OFDM pwr diff. NO BB register to notify HW.
- powerBase0 = powerlevel + Legacy_pwrdiff;
- //RTPRINT(FPHY, PHY_TXPWR, (" [LagacyToHT40 pwr diff = %d]\n", Legacy_pwrdiff));
-
- // Band Edge scheme is enabled for FCC mode
- if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
- {
- ofdm_bandedge_chnl_low = 1;
- ofdm_bandedge_chnl_high = 11;
- BandEdge_Pwrdiff = 0;
- if (Channel <= ofdm_bandedge_chnl_low)
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0];
- else if (Channel >= ofdm_bandedge_chnl_high)
- {
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1];
- }
- powerBase0 -= BandEdge_Pwrdiff;
- if (Channel <= ofdm_bandedge_chnl_low || Channel >= ofdm_bandedge_chnl_high)
- {
- //RTPRINT(FPHY, PHY_TXPWR, (" [OFDM band-edge channel = %d, pwr diff = %d]\n",
- //Channel, BandEdge_Pwrdiff));
- }
- }
- //RTPRINT(FPHY, PHY_TXPWR, (" [OFDM power base index = 0x%x]\n", powerBase0));
- }
- powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
-
- //MCS rates
- if(priv->EEPROMVersion == 2)
- {
- //Cosa add for new EEPROM content. 02102009
-
- //Check HT20 to HT40 diff
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- {
- // HT 20<->40 pwr diff
- HT20_pwrdiff = priv->TxPwrHt20Diff[RF90_PATH_A][Channel-1];
-
- // Calculate Antenna pwr diff
- if (HT20_pwrdiff < 8) // 0~+7
- powerlevel += HT20_pwrdiff;
- else // index8-15=-8~-1
- powerlevel -= (16-HT20_pwrdiff);
-
- //RTPRINT(FPHY, PHY_TXPWR, (" [HT20 to HT40 pwrdiff = %d]\n", HT20_pwrdiff));
- //RTPRINT(FPHY, PHY_TXPWR, (" [MCS power base index = 0x%x]\n", powerlevel));
- }
-
- // Band Edge scheme is enabled for FCC mode
- if (priv->TxPwrbandEdgeFlag == 1/* && pHalData->ChannelPlan == 0*/)
- {
- BandEdge_Pwrdiff = 0;
- if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
- {
- if (Channel <= 3)
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt40[RF90_PATH_A][0];
- else if (Channel >= 9)
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt40[RF90_PATH_A][1];
- if (Channel <= 3 || Channel >= 9)
- {
- //RTPRINT(FPHY, PHY_TXPWR, (" [HT40 band-edge channel = %d, pwr diff = %d]\n",
- //Channel, BandEdge_Pwrdiff));
- }
- }
- else if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- {
- if (Channel <= 1)
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt20[RF90_PATH_A][0];
- else if (Channel >= 11)
- BandEdge_Pwrdiff = priv->TxPwrbandEdgeHt20[RF90_PATH_A][1];
- if (Channel <= 1 || Channel >= 11)
- {
- //RTPRINT(FPHY, PHY_TXPWR, (" [HT20 band-edge channel = %d, pwr diff = %d]\n",
- //Channel, BandEdge_Pwrdiff));
- }
- }
- powerlevel -= BandEdge_Pwrdiff;
- //RTPRINT(FPHY, PHY_TXPWR, (" [MCS power base index = 0x%x]\n", powerlevel));
- }
- }
- powerBase1 = powerlevel;
- powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
-
- //RTPRINT(FPHY, PHY_TXPWR, (" [Legacy/HT power index= %x/%x]\n", powerBase0, powerBase1));
-
- for(index=0; index<6; index++)
- {
- //
- // Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate
- //
- //cosa add for lenovo, to pass the safety spec, don't increase power index for different rates.
- if(priv->bIgnoreDiffRateTxPowerOffset)
- writeVal = ((index<2)?powerBase0:powerBase1);
- else
- writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
-
- //RTPRINT(FPHY, PHY_TXPWR, ("Reg 0x%x, Original=%x writeVal=%x\n",
- //RegOffset[index], priv->MCSTxPowerLevelOriginalOffset[index], writeVal));
-
- //
- // If path A and Path B coexist, we must limit Path A tx power.
- // Protect Path B pwr over or underflow. We need to calculate upper and
- // lower bound of path A tx power.
- //
- if (priv->rf_type == RF_2T2R)
- {
- rf_pwr_diff = priv->AntennaTxPwDiff[0];
- //RTPRINT(FPHY, PHY_TXPWR, ("2T2R RF-B to RF-A PWR DIFF=%d\n", rf_pwr_diff));
-
- if (rf_pwr_diff >= 8) // Diff=-8~-1
- { // Prevent underflow!!
- rfa_lower_bound = 0x10-rf_pwr_diff;
- //RTPRINT(FPHY, PHY_TXPWR, ("rfa_lower_bound= %d\n", rfa_lower_bound));
- }
- else if (rf_pwr_diff >= 0) // Diff = 0-7
- {
- rfa_upper_bound = RF6052_MAX_TX_PWR-rf_pwr_diff;
- //RTPRINT(FPHY, PHY_TXPWR, ("rfa_upper_bound= %d\n", rfa_upper_bound));
- }
- }
-
- for (i= 0; i <4; i++)
- {
- rfa_pwr[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8));
- if (rfa_pwr[i] > RF6052_MAX_TX_PWR)
- rfa_pwr[i] = RF6052_MAX_TX_PWR;
-
- //
- // If path A and Path B coexist, we must limit Path A tx power.
- // Protect Path B pwr under/over flow. We need to calculate upper and
- // lower bound of path A tx power.
- //
- if (priv->rf_type == RF_2T2R)
- {
- if (rf_pwr_diff >= 8) // Diff=-8~-1
- { // Prevent underflow!!
- if (rfa_pwr[i] <rfa_lower_bound)
- {
- //RTPRINT(FPHY, PHY_TXPWR, ("Underflow"));
- rfa_pwr[i] = rfa_lower_bound;
- }
- }
- else if (rf_pwr_diff >= 1) // Diff = 0-7
- { // Prevent overflow
- if (rfa_pwr[i] > rfa_upper_bound)
- {
- //RTPRINT(FPHY, PHY_TXPWR, ("Overflow"));
- rfa_pwr[i] = rfa_upper_bound;
- }
- }
- //RTPRINT(FPHY, PHY_TXPWR, ("rfa_pwr[%d]=%x\n", i, rfa_pwr[i]));
- }
-
- }
-
- //
- // Add description: PWDB > threshold!!!High power issue!!
- // We must decrease tx power !! Why is the value ???
- //
- if(priv->bDynamicTxHighPower == TRUE)
- {
- // For MCS rate
- if(index > 1)
- {
- writeVal = 0x03030303;
- }
- // For Legacy rate
- else
- {
- writeVal = (rfa_pwr[3]<<24) | (rfa_pwr[2]<<16) |(rfa_pwr[1]<<8) |rfa_pwr[0];
- }
- //RTPRINT(FPHY, PHY_TXPWR, ("HighPower=%08x\n", writeVal));
- }
- else
- {
- writeVal = (rfa_pwr[3]<<24) | (rfa_pwr[2]<<16) |(rfa_pwr[1]<<8) |rfa_pwr[0];
- //RTPRINT(FPHY, PHY_TXPWR, ("NormalPower=%08x\n", writeVal));
- }
-
- //
- // Write different rate set tx power index.
- //
- //if (DCMD_Test_Flag == 0)
- rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
- }
-
-} /* PHY_RF6052SetOFDMTxPower */
-#else
-extern void PHY_RF6052SetOFDMTxPower(struct net_device* dev, u8 powerlevel)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 writeVal, powerBase0, powerBase1;
- u8 index = 0;
- u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
- u8 byte0, byte1, byte2, byte3;
- u8 channel = priv->ieee80211->current_network.channel;
-
- //Legacy OFDM rates
- powerBase0 = powerlevel + (priv->LegacyHTTxPowerDiff & 0xf);
- powerBase0 = (powerBase0<<24) | (powerBase0<<16) |(powerBase0<<8) |powerBase0;
-
- //MCS rates HT OFDM
- powerBase1 = powerlevel;
- powerBase1 = (powerBase1<<24) | (powerBase1<<16) |(powerBase1<<8) |powerBase1;
-
- //printk("Legacy/HT PWR= %x/%x\n", powerBase0, powerBase1);
-
- for(index=0; index<6; index++)
- {
- //
- // Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate
- //
- writeVal = priv->MCSTxPowerLevelOriginalOffset[index] + ((index<2)?powerBase0:powerBase1);
-
- //printk("Index = %d Original=%x writeVal=%x\n", index, priv->MCSTxPowerLevelOriginalOffset[index], writeVal);
-
- byte0 = (u8)(writeVal & 0x7f);
- byte1 = (u8)((writeVal & 0x7f00)>>8);
- byte2 = (u8)((writeVal & 0x7f0000)>>16);
- byte3 = (u8)((writeVal & 0x7f000000)>>24);
-
- // Max power index = 0x3F Range = 0-0x3F
- if(byte0 > RF6052_MAX_TX_PWR)
- byte0 = RF6052_MAX_TX_PWR;
- if(byte1 > RF6052_MAX_TX_PWR)
- byte1 = RF6052_MAX_TX_PWR;
- if(byte2 > RF6052_MAX_TX_PWR)
- byte2 = RF6052_MAX_TX_PWR;
- if(byte3 > RF6052_MAX_TX_PWR)
- byte3 = RF6052_MAX_TX_PWR;
-
- //
- // Add description: PWDB > threshold!!!High power issue!!
- // We must decrease tx power !! Why is the value ???
- //
- if(priv->bDynamicTxHighPower == true)
- {
- // For MCS rate
- if(index > 1)
- {
- writeVal = 0x03030303;
- }
- // For Legacy rate
- else
- {
- writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
- }
- }
- else
- {
- writeVal = (byte3<<24) | (byte2<<16) |(byte1<<8) |byte0;
- }
-
- //
- // Write different rate set tx power index.
- //
- rtl8192_setBBreg(dev, RegOffset[index], 0x7f7f7f7f, writeVal);
- }
-
-} /* PHY_RF6052SetOFDMTxPower */
-#endif
-
-RT_STATUS PHY_RF6052_Config(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
- //RF90_RADIO_PATH_E eRFPath;
- //BB_REGISTER_DEFINITION_T *pPhyReg;
- //u32 OrgStoreRFIntSW[RF90_PATH_D+1];
-
- //
- // Initialize general global value
- //
- // TODO: Extend RF_PATH_C and RF_PATH_D in the future
- if(priv->rf_type == RF_1T1R)
- priv->NumTotalRFPath = 1;
- else
- priv->NumTotalRFPath = 2;
-
- //
- // Config BB and RF
- //
-// switch( priv->bRegHwParaFile )
-// {
-// case 0:
-// phy_RF6052_Config_HardCode(dev);
-// break;
-
-// case 1:
- rtStatus = phy_RF6052_Config_ParaFile(dev);
-// break;
-
-// case 2:
- // Partial Modify.
-// phy_RF6052_Config_HardCode(dev);
-// phy_RF6052_Config_ParaFile(dev);
-// break;
-
-// default:
-// phy_RF6052_Config_HardCode(dev);
-// break;
-// }
- return rtStatus;
-
-}
-
-void phy_RF6052_Config_HardCode(struct net_device* dev)
-{
-
- // Set Default Bandwidth to 20M
- //Adapter->HalFunc .SetBWModeHandler(Adapter, HT_CHANNEL_WIDTH_20);
-
- // TODO: Set Default Channel to channel one for RTL8225
-
-}
-
-RT_STATUS phy_RF6052_Config_ParaFile(struct net_device* dev)
-{
- u32 u4RegValue = 0;
- //static s1Byte szRadioAFile[] = RTL819X_PHY_RADIO_A;
- //static s1Byte szRadioBFile[] = RTL819X_PHY_RADIO_B;
- //static s1Byte szRadioBGMFile[] = RTL819X_PHY_RADIO_B_GM;
- u8 eRFPath;
- RT_STATUS rtStatus = RT_STATUS_SUCCESS;
- struct r8192_priv *priv = ieee80211_priv(dev);
- BB_REGISTER_DEFINITION_T *pPhyReg;
- //u8 eCheckItem;
-
-
- //3//-----------------------------------------------------------------
- //3// <2> Initialize RF
- //3//-----------------------------------------------------------------
- //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- {
-
- pPhyReg = &priv->PHYRegDef[eRFPath];
-
- /*----Store original RFENV control type----*/
- switch(eRFPath)
- {
- case RF90_PATH_A:
- case RF90_PATH_C:
- u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
- break;
- case RF90_PATH_B :
- case RF90_PATH_D:
- u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
- break;
- }
-
- /*----Set RF_ENV enable----*/
- rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
-
- /*----Set RF_ENV output high----*/
- rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
-
- /* Set bit number of Address and Data for RF register */
- rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
- rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
-
-
- /*----Initialize RF fom connfiguration file----*/
- switch(eRFPath)
- {
- case RF90_PATH_A:
- rtStatus= rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
- break;
- case RF90_PATH_B:
- rtStatus= rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
- break;
- case RF90_PATH_C:
- break;
- case RF90_PATH_D:
- break;
- }
-
- /*----Restore RFENV control type----*/;
- switch(eRFPath)
- {
- case RF90_PATH_A:
- case RF90_PATH_C:
- rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
- break;
- case RF90_PATH_B :
- case RF90_PATH_D:
- rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
- break;
- }
-
- if(rtStatus != RT_STATUS_SUCCESS){
- printk("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath);
- goto phy_RF6052_Config_ParaFile_Fail;
- }
-
- }
-
- RT_TRACE(COMP_INIT, "<---phy_RF6052_Config_ParaFile()\n");
- return rtStatus;
-
-phy_RF6052_Config_ParaFile_Fail:
- return rtStatus;
-}
-
-
-//
-// ==> RF shadow Operation API Code Section!!!
-//
-/*-----------------------------------------------------------------------------
- * Function: PHY_RFShadowRead
- * PHY_RFShadowWrite
- * PHY_RFShadowCompare
- * PHY_RFShadowRecorver
- * PHY_RFShadowCompareAll
- * PHY_RFShadowRecorverAll
- * PHY_RFShadowCompareFlagSet
- * PHY_RFShadowRecorverFlagSet
- *
- * Overview: When we set RF register, we must write shadow at first.
- * When we are running, we must compare shadow abd locate error addr.
- * Decide to recorver or not.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 11/20/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern u32 PHY_RFShadowRead(
- struct net_device * dev,
- RF90_RADIO_PATH_E eRFPath,
- u32 Offset)
-{
- return RF_Shadow[eRFPath][Offset].Value;
-
-} /* PHY_RFShadowRead */
-
-
-extern void PHY_RFShadowWrite(
- struct net_device * dev,
- u32 eRFPath,
- u32 Offset,
- u32 Data)
-{
- //RF_Shadow[eRFPath][Offset].Value = (Data & bMask20Bits);
- RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
- RF_Shadow[eRFPath][Offset].Driver_Write = true;
-
-} /* PHY_RFShadowWrite */
-
-
-extern void PHY_RFShadowCompare(
- struct net_device * dev,
- RF90_RADIO_PATH_E eRFPath,
- u32 Offset)
-{
- u32 reg;
-
- // Check if we need to check the register
- if (RF_Shadow[eRFPath][Offset].Compare == true)
- {
- reg = rtl8192_phy_QueryRFReg(dev, eRFPath, Offset, bRFRegOffsetMask);
- // Compare shadow and real rf register for 20bits!!
- if (RF_Shadow[eRFPath][Offset].Value != reg)
- {
- // Locate error position.
- RF_Shadow[eRFPath][Offset].ErrorOrNot = true;
- RT_TRACE(COMP_INIT, "PHY_RFShadowCompare RF-%d Addr%02xErr = %05x", eRFPath, Offset, reg);
- }
- }
-
-} /* PHY_RFShadowCompare */
-
-extern void PHY_RFShadowRecorver(
- struct net_device * dev,
- RF90_RADIO_PATH_E eRFPath,
- u32 Offset)
-{
- // Check if the address is error
- if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true)
- {
- // Check if we need to recorver the register.
- if (RF_Shadow[eRFPath][Offset].Recorver == true)
- {
- rtl8192_phy_SetRFReg(dev, eRFPath, Offset, bRFRegOffsetMask, RF_Shadow[eRFPath][Offset].Value);
- RT_TRACE(COMP_INIT, "PHY_RFShadowRecorver RF-%d Addr%02x=%05x",
- eRFPath, Offset, RF_Shadow[eRFPath][Offset].Value);
- }
- }
-
-} /* PHY_RFShadowRecorver */
-
-
-extern void PHY_RFShadowCompareAll(struct net_device * dev)
-{
- u32 eRFPath;
- u32 Offset;
-
- for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
- {
- for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
- {
- PHY_RFShadowCompare(dev, (RF90_RADIO_PATH_E)eRFPath, Offset);
- }
- }
-
-} /* PHY_RFShadowCompareAll */
-
-
-extern void PHY_RFShadowRecorverAll(struct net_device * dev)
-{
- u32 eRFPath;
- u32 Offset;
-
- for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
- {
- for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
- {
- PHY_RFShadowRecorver(dev, (RF90_RADIO_PATH_E)eRFPath, Offset);
- }
- }
-
-} /* PHY_RFShadowRecorverAll */
-
-
-extern void PHY_RFShadowCompareFlagSet(
- struct net_device * dev,
- RF90_RADIO_PATH_E eRFPath,
- u32 Offset,
- u8 Type)
-{
- // Set True or False!!!
- RF_Shadow[eRFPath][Offset].Compare = Type;
-
-} /* PHY_RFShadowCompareFlagSet */
-
-
-extern void PHY_RFShadowRecorverFlagSet(
- struct net_device * dev,
- RF90_RADIO_PATH_E eRFPath,
- u32 Offset,
- u8 Type)
-{
- // Set True or False!!!
- RF_Shadow[eRFPath][Offset].Recorver= Type;
-
-} /* PHY_RFShadowRecorverFlagSet */
-
-
-extern void PHY_RFShadowCompareFlagSetAll(struct net_device * dev)
-{
- u32 eRFPath;
- u32 Offset;
-
- for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
- {
- for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
- {
- // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
- if (Offset != 0x26 && Offset != 0x27)
- PHY_RFShadowCompareFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, FALSE);
- else
- PHY_RFShadowCompareFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, TRUE);
- }
- }
-
-} /* PHY_RFShadowCompareFlagSetAll */
-
-
-extern void PHY_RFShadowRecorverFlagSetAll(struct net_device * dev)
-{
- u32 eRFPath;
- u32 Offset;
-
- for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
- {
- for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
- {
- // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
- if (Offset != 0x26 && Offset != 0x27)
- PHY_RFShadowRecorverFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, FALSE);
- else
- PHY_RFShadowRecorverFlagSet(dev, (RF90_RADIO_PATH_E)eRFPath, Offset, TRUE);
- }
- }
-
-} /* PHY_RFShadowCompareFlagSetAll */
-
-
-
-extern void PHY_RFShadowRefresh(struct net_device * dev)
-{
- u32 eRFPath;
- u32 Offset;
-
- for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
- {
- for (Offset = 0; Offset <= RF6052_MAX_REG; Offset++)
- {
- RF_Shadow[eRFPath][Offset].Value = 0;
- RF_Shadow[eRFPath][Offset].Compare = false;
- RF_Shadow[eRFPath][Offset].Recorver = false;
- RF_Shadow[eRFPath][Offset].ErrorOrNot = false;
- RF_Shadow[eRFPath][Offset].Driver_Write = false;
- }
- }
-
-} /* PHY_RFShadowRead */
-
-/* End of HalRf6052.c */
diff --git a/drivers/staging/rtl8192su/r8192S_rtl6052.h b/drivers/staging/rtl8192su/r8192S_rtl6052.h
deleted file mode 100644
index 3dcc9bb76394..000000000000
--- a/drivers/staging/rtl8192su/r8192S_rtl6052.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/******************************************************************************
- *
- * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved.
- *
- * Module: HalRf.h ( Header File)
- *
- * Note: Collect every HAL RF type exter API or constant.
- *
- * Function:
- *
- * Export:
- *
- * Abbrev:
- *
- * History:
- * Data Who Remark
- *
- * 09/25/2008 MHC Create initial version.
- *
- *
-******************************************************************************/
-/* Check to see if the file has been included already. */
-
-
-/*--------------------------Define Parameters-------------------------------*/
-
-//
-// For RF 6052 Series
-//
-#define RF6052_MAX_TX_PWR 0x3F
-#define RF6052_MAX_REG 0x3F
-#define RF6052_MAX_PATH 4
-/*--------------------------Define Parameters-------------------------------*/
-
-
-/*------------------------------Define structure----------------------------*/
-
-/*------------------------------Define structure----------------------------*/
-
-
-/*------------------------Export global variable----------------------------*/
-/*------------------------Export global variable----------------------------*/
-
-/*------------------------Export Marco Definition---------------------------*/
-
-/*------------------------Export Marco Definition---------------------------*/
-
-
-/*--------------------------Exported Function prototype---------------------*/
-//======================================================
-#if 1
-// Function prototypes for HalPhy8225.c
-//1======================================================
-extern void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); //20M or 40M;
-extern void PHY_SetRF8225Bandwidth( struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
-extern bool PHY_RF8225_Config(struct net_device* dev );
-extern void phy_RF8225_Config_HardCode(struct net_device* dev);
-extern bool phy_RF8225_Config_ParaFile(struct net_device* dev);
-extern void PHY_SetRF8225CckTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel);
-
-//1======================================================
-// Function prototypes for HalPhy8256.c
-//1======================================================
-extern void PHY_SetRF8256Bandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
-extern void PHY_RF8256_Config(struct net_device* dev);
-extern void phy_RF8256_Config_ParaFile(struct net_device* dev);
-extern void PHY_SetRF8256CCKTxPower(struct net_device* dev, u8 powerlevel);
-extern void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel);
-#endif
-
-//
-// RF RL6052 Series API
-//
-extern void RF_ChangeTxPath(struct net_device * dev, u16 DataRate);
-extern void PHY_RF6052SetBandwidth(struct net_device * dev,HT_CHANNEL_WIDTH Bandwidth);
-extern void PHY_RF6052SetCckTxPower(struct net_device * dev, u8 powerlevel);
-extern void PHY_RF6052SetOFDMTxPower(struct net_device * dev, u8 powerlevel);
-extern RT_STATUS PHY_RF6052_Config(struct net_device * dev);
-extern void PHY_RFShadowRefresh( struct net_device * dev);
-extern void PHY_RFShadowWrite( struct net_device* dev, u32 eRFPath, u32 Offset, u32 Data);
-/*--------------------------Exported Function prototype---------------------*/
-
-
-/* End of HalRf.h */
diff --git a/drivers/staging/rtl8192su/r8192S_rtl8225.c b/drivers/staging/rtl8192su/r8192S_rtl8225.c
deleted file mode 100644
index 09465df2def6..000000000000
--- a/drivers/staging/rtl8192su/r8192S_rtl8225.c
+++ /dev/null
@@ -1,292 +0,0 @@
-
-#include "r8192U.h"
-#include "r8192S_hw.h"
-#include "r8192S_phyreg.h"
-#include "r8192S_phy.h"
-#include "r8192S_rtl8225.h"
-
-/*---------------------Define local function prototype-----------------------*/
-void phy_RF8225_Config_HardCode(struct net_device* dev );
-bool phy_RF8225_Config_ParaFile(struct net_device* dev );
-/*---------------------Define local function prototype-----------------------*/
-void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel)
-{
-
-}
-
-
-
-void PHY_SetRF8225CckTxPower( struct net_device* dev , u8 powerlevel)
-{
-
-}
-
-
-// TODO: The following RF 022D related function should be removed to HalPhy0222D.c.
-void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel)
-{
- //TODO: We should set RF TxPower for RF 0222D here!!
-}
-
-
-
-void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel)
-{
- //TODO: We should set RF TxPower for RF 0222D here!!
-}
-
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_SetRF0222DBandwidth()
- *
- * Overview: This function is called by SetBWModeCallback8190Pci() only
- *
- * Input: PADAPTER Adapter
- * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: For RF type 0222D
- *---------------------------------------------------------------------------*/
- //just in phy
-void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
-{
- u8 eRFPath;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-
- //if (IS_HARDWARE_TYPE_8192S(dev))
- if (1)
- {
-#ifndef RTL92SE_FPGA_VERIFY
- switch(Bandwidth)
- {
- case HT_CHANNEL_WIDTH_20:
-#ifdef FIB_MODIFICATION
- write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x58);
-#endif
- rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x01);
- break;
- case HT_CHANNEL_WIDTH_20_40:
-#ifdef FIB_MODIFICATION
- write_nic_byte(dev, rFPGA0_AnalogParameter2, 0x18);
-#endif
- rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, BIT10|BIT11, 0x00);
- break;
- default:
- ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
- break;
- }
-#endif
- }
- else
- {
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- {
- switch(Bandwidth)
- {
- case HT_CHANNEL_WIDTH_20:
- //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x01);
- break;
- case HT_CHANNEL_WIDTH_20_40:
- //rtl8192_phy_SetRFReg(Adapter, (RF90_RADIO_PATH_E)RF90_PATH_A, RF_CHNLBW, (BIT10|BIT11), 0x00);
- break;
- default:
- ;//RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth ));
- break;
-
- }
- }
- }
-
-}
-
-// TODO: Aabove RF 022D related function should be removed to HalPhy0222D.c.
-
-/*-----------------------------------------------------------------------------
- * Function: PHY_SetRF8225Bandwidth()
- *
- * Overview: This function is called by SetBWModeCallback8190Pci() only
- *
- * Input: PADAPTER Adapter
- * WIRELESS_BANDWIDTH_E Bandwidth //20M or 40M
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Note: 8225(zebra1) support 20M only
- *---------------------------------------------------------------------------*/
- //just in phy
-void PHY_SetRF8225Bandwidth(struct net_device* dev ,HT_CHANNEL_WIDTH Bandwidth) //20M or 40M
-{
- u8 eRFPath;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- {
- switch(Bandwidth)
- {
- case HT_CHANNEL_WIDTH_20:
- // TODO: Update the parameters here
- break;
- case HT_CHANNEL_WIDTH_20_40:
- RT_TRACE(COMP_DBG, "SetChannelBandwidth8190Pci():8225 does not support 40M mode\n");
- break;
- default:
- RT_TRACE(COMP_DBG, "PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n",Bandwidth );
- break;
-
- }
- }
-
-}
-
-//just in phy
-bool PHY_RF8225_Config(struct net_device* dev )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool rtStatus = true;
- //RF90_RADIO_PATH_E eRFPath;
- //BB_REGISTER_DEFINITION_T *pPhyReg;
- //u32 OrgStoreRFIntSW[RF90_PATH_D+1];
-
- //
- // Initialize general global value
- //
- // TODO: Extend RF_PATH_C and RF_PATH_D in the future
- priv->NumTotalRFPath = 2;
-
- //
- // Config BB and RF
- //
- //switch( Adapter->MgntInfo.bRegHwParaFile )
- //{
- // case 0:
- // phy_RF8225_Config_HardCode(dev);
- // break;
-
- // case 1:
- // rtStatus = phy_RF8225_Config_ParaFile(dev);
- // break;
-
- // case 2:
- // Partial Modify.
- phy_RF8225_Config_HardCode(dev);
- phy_RF8225_Config_ParaFile(dev);
- // break;
-
- // default:
- // phy_RF8225_Config_HardCode(dev);
- // break;
- //}
- return rtStatus;
-
-}
-
-//just in 8225
-void phy_RF8225_Config_HardCode(struct net_device* dev)
-{
-
- // Set Default Bandwidth to 20M
- //Adapter->HalFunc .SetBWModeHandler(Adapter, HT_CHANNEL_WIDTH_20);
-
- // TODO: Set Default Channel to channel one for RTL8225
-
-}
-
-//just in 8225
-bool phy_RF8225_Config_ParaFile(struct net_device* dev)
-{
- u32 u4RegValue = 0;
- //static char szRadioAFile[] = RTL819X_PHY_RADIO_A;
- //static char szRadioBFile[] = RTL819X_PHY_RADIO_B;
- u8 eRFPath;
- bool rtStatus = true;
- struct r8192_priv *priv = ieee80211_priv(dev);
- BB_REGISTER_DEFINITION_T *pPhyReg;
- //u8 eCheckItem;
-
-#if 1
- //3//-----------------------------------------------------------------
- //3// <2> Initialize RF
- //3//-----------------------------------------------------------------
- //for(eRFPath = RF90_PATH_A; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- {
-
- pPhyReg = &priv->PHYRegDef[eRFPath];
-
- /*----Store original RFENV control type----*/
- switch(eRFPath)
- {
- case RF90_PATH_A:
- case RF90_PATH_C:
- u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV);
- break;
- case RF90_PATH_B :
- case RF90_PATH_D:
- u4RegValue = rtl8192_QueryBBReg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16);
- break;
- }
-
- /*----Set RF_ENV enable----*/
- rtl8192_setBBreg(dev, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1);
-
- /*----Set RF_ENV output high----*/
- rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
-
- /* Set bit number of Address and Data for RF register */
- rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); // Set 1 to 4 bits for 8255
- rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); // Set 0 to 12 bits for 8255
-
-
- /*----Initialize RF fom connfiguration file----*/
- switch(eRFPath)
- {
- case RF90_PATH_A:
- //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioAFile, (RF90_RADIO_PATH_E)eRFPath);
- rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
- break;
- case RF90_PATH_B:
- //rtStatus = PHY_ConfigRFWithParaFile(dev, (char* )&szRadioBFile, (RF90_RADIO_PATH_E)eRFPath);
- rtStatus = rtl8192_phy_ConfigRFWithHeaderFile(dev,(RF90_RADIO_PATH_E)eRFPath);
- break;
- case RF90_PATH_C:
- break;
- case RF90_PATH_D:
- break;
- }
-
- /*----Restore RFENV control type----*/;
- switch(eRFPath)
- {
- case RF90_PATH_A:
- case RF90_PATH_C:
- rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue);
- break;
- case RF90_PATH_B :
- case RF90_PATH_D:
- rtl8192_setBBreg(dev, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue);
- break;
- }
-
- if(rtStatus == false){
- //RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF8225_Config_ParaFile():Radio[%d] Fail!!", eRFPath));
- goto phy_RF8225_Config_ParaFile_Fail;
- }
-
- }
-
- //RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF8225_Config_ParaFile()\n"));
- return rtStatus;
-
-phy_RF8225_Config_ParaFile_Fail:
-#endif
- return rtStatus;
-}
-
-
diff --git a/drivers/staging/rtl8192su/r8192S_rtl8225.h b/drivers/staging/rtl8192su/r8192S_rtl8225.h
deleted file mode 100644
index 8a647284af35..000000000000
--- a/drivers/staging/rtl8192su/r8192S_rtl8225.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- This is part of the rtl8180-sa2400 driver
- released under the GPL (See file COPYING for details).
- Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
-
- This files contains programming code for the rtl8256
- radio frontend.
-
- *Many* thanks to Realtek Corp. for their great support!
-
-*/
-
-#ifndef RTL8225H
-#define RTL8225H
-
-#ifdef RTL8190P
-#define RTL819X_TOTAL_RF_PATH 4 //for 90P
-#else
-#define RTL819X_TOTAL_RF_PATH 2 //for 8192U
-#endif
-extern void PHY_SetRF0222DBandwidth(struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth); //20M or 40M;
-extern void PHY_SetRF8225Bandwidth( struct net_device* dev , HT_CHANNEL_WIDTH Bandwidth);
-extern bool PHY_RF8225_Config(struct net_device* dev );
-extern void phy_RF8225_Config_HardCode(struct net_device* dev);
-extern bool phy_RF8225_Config_ParaFile(struct net_device* dev);
-extern void PHY_SetRF8225CckTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF8225OfdmTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF0222DOfdmTxPower(struct net_device* dev ,u8 powerlevel);
-extern void PHY_SetRF0222DCckTxPower(struct net_device* dev ,u8 powerlevel);
-#endif
diff --git a/drivers/staging/rtl8192su/r8192U.h b/drivers/staging/rtl8192su/r8192U.h
deleted file mode 100644
index 741c6bf9a018..000000000000
--- a/drivers/staging/rtl8192su/r8192U.h
+++ /dev/null
@@ -1,1519 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- * Linux device driver for RTL8192U
- *
- * Based on the r8187 driver, which is:
- * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-#ifndef R819xU_H
-#define R819xU_H
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/netdevice.h>
-#include <linux/usb.h>
-#include <linux/etherdevice.h>
-#include <linux/delay.h>
-#include <linux/rtnetlink.h> //for rtnl_lock()
-#include <linux/wireless.h>
-#include <linux/timer.h>
-#include <linux/proc_fs.h> // Necessary because we use the proc fs
-#include <linux/if_arp.h>
-#include <linux/random.h>
-#include <linux/version.h>
-#include <asm/io.h>
-
-#include "ieee80211/ieee80211.h"
-
-#include "r8192S_firmware.h"
-#include "r8192SU_led.h"
-
-/* EEPROM defs for use with linux/eeprom_93cx6.h */
-#define RTL819X_EEPROM_CMD_READ (1 << 0)
-#define RTL819X_EEPROM_CMD_WRITE (1 << 1)
-#define RTL819X_EEPROM_CMD_CK (1 << 2)
-#define RTL819X_EEPROM_CMD_CS (1 << 3)
-
-#define RTL819xU_MODULE_NAME "rtl819xU"
-#define FALSE 0
-#define TRUE 1
-#define MAX_KEY_LEN 61
-#define KEY_BUF_SIZE 5
-
-#define BIT0 0x00000001
-#define BIT1 0x00000002
-#define BIT2 0x00000004
-#define BIT3 0x00000008
-#define BIT4 0x00000010
-#define BIT5 0x00000020
-#define BIT6 0x00000040
-#define BIT7 0x00000080
-#define BIT8 0x00000100
-#define BIT9 0x00000200
-#define BIT10 0x00000400
-#define BIT11 0x00000800
-#define BIT12 0x00001000
-#define BIT13 0x00002000
-#define BIT14 0x00004000
-#define BIT15 0x00008000
-#define BIT16 0x00010000
-#define BIT17 0x00020000
-#define BIT18 0x00040000
-#define BIT19 0x00080000
-#define BIT20 0x00100000
-#define BIT21 0x00200000
-#define BIT22 0x00400000
-#define BIT23 0x00800000
-#define BIT24 0x01000000
-#define BIT25 0x02000000
-#define BIT26 0x04000000
-#define BIT27 0x08000000
-#define BIT28 0x10000000
-#define BIT29 0x20000000
-#define BIT30 0x40000000
-#define BIT31 0x80000000
-
-// Rx smooth factor
-#define Rx_Smooth_Factor 20
-#define DMESG(x,a...)
-#define DMESGW(x,a...)
-#define DMESGE(x,a...)
-extern u32 rt_global_debug_component;
-#define RT_TRACE(component, x, args...) \
-do { if(rt_global_debug_component & component) \
- printk(KERN_DEBUG RTL819xU_MODULE_NAME ":" x "\n" , \
- ##args);\
-}while(0);
-//----------------------------------------------------------------------
-//// Get 8192SU Rx descriptor. Added by Roger, 2008.04.15.
-////----------------------------------------------------------------------
-#define RX_DESC_SIZE 24
-#define RX_DRV_INFO_SIZE_UNIT 8
-
-#define IS_UNDER_11N_AES_MODE(_ieee) ((_ieee->pHTInfo->bCurrentHTSupport==TRUE) &&\
- (_ieee->pairwise_key_type==KEY_TYPE_CCMP))
-
-#define COMP_TRACE BIT0 // For function call tracing.
-#define COMP_DBG BIT1 // Only for temporary debug message.
-#define COMP_MLME BIT1
-#define COMP_INIT BIT2 // during driver initialization / halt / reset.
-
-
-#define COMP_RECV BIT3 // Reveive part data path.
-#define COMP_SEND BIT4 // Send part path.
-#define COMP_IO BIT5 // I/O Related. Added by Annie, 2006-03-02.
-#define COMP_POWER BIT6 // 802.11 Power Save mode or System/Device Power state related.
-#define COMP_EPROM BIT7 // 802.11 link related: join/start BSS, leave BSS.
-#define COMP_SWBW BIT8 // For bandwidth switch.
-#define COMP_POWER_TRACKING BIT9 //FOR 8190 TX POWER TRACKING
-#define COMP_TURBO BIT10 // For Turbo Mode related. By Annie, 2005-10-21.
-#define COMP_QOS BIT11 // For QoS.
-#define COMP_RATE BIT12 // For Rate Adaptive mechanism, 2006.07.02, by rcnjko.
-#define COMP_LPS BIT13 // For Radio Measurement.
-#define COMP_DIG BIT14 // For DIG, 2006.09.25, by rcnjko.
-#define COMP_PHY BIT15
-#define COMP_CH BIT16 //channel setting debug
-#define COMP_TXAGC BIT17 // For Tx power, 060928, by rcnjko.
-#define COMP_HIPWR BIT18 // For High Power Mechanism, 060928, by rcnjko.
-#define COMP_HALDM BIT19 // For HW Dynamic Mechanism, 061010, by rcnjko.
-#define COMP_SEC BIT20 // Event handling
-#define COMP_LED BIT21 // For LED.
-#define COMP_RF BIT22 // For RF.
-#define COMP_RXDESC BIT23
-
-#define COMP_RXDESC BIT23 // Show Rx desc information for SD3 debug. Added by Annie, 2006-07-15.
-
-#define COMP_FIRMWARE BIT24 //for firmware downloading
-#define COMP_HT BIT25 // For 802.11n HT related information. by Emily 2006-8-11
-#define COMP_AMSDU BIT26 // For A-MSDU Debugging
-#define COMP_PS BIT26
-
-#define COMP_SCAN BIT27
-#define COMP_CMD BIT28
-#define COMP_DOWN BIT29 //for rm driver module
-#define COMP_RESET BIT30 //for silent reset
-#define COMP_ERR BIT31 //for error out, always on
-
-#define RTL819x_DEBUG
-#ifdef RTL819x_DEBUG
-#define assert(expr) \
- if (!(expr)) { \
- printk( "Assertion failed! %s,%s,%s,line=%d\n", \
- #expr,__FILE__,__FUNCTION__,__LINE__); \
- }
-
-#define RT_DEBUG_DATA(level, data, datalen) \
- do{ if ((rt_global_debug_component & (level)) == (level)) \
- { \
- int i; \
- u8* pdata = (u8*) data; \
- printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__); \
- for(i=0; i<(int)(datalen); i++) \
- { \
- printk("%2x ", pdata[i]); \
- if ((i+1)%16 == 0) printk("\n"); \
- } \
- printk("\n"); \
- } \
- } while (0)
-#else
-#define assert(expr) do {} while (0)
-#define RT_DEBUG_DATA(level, data, datalen) do {} while(0)
-#endif /* RTL8169_DEBUG */
-
- //2TODO: We should define 8192S firmware related macro settings here!!
- #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
- #define RTL819X_TOTAL_RF_PATH 2
-
- #define Rtl819XMACPHY_Array_PG Rtl8192UsbMACPHY_Array_PG
- #define Rtl819XMACPHY_Array Rtl8192UsbMACPHY_Array
- #define Rtl819XPHY_REGArray Rtl8192UsbPHY_REGArray
- #define Rtl819XPHY_REG_1T2RArray Rtl8192UsbPHY_REG_1T2RArray
- #define Rtl819XRadioC_Array Rtl8192UsbRadioC_Array
- #define Rtl819XRadioD_Array Rtl8192UsbRadioD_Array
-
- #define Rtl819XFwImageArray Rtl8192SUFwImgArray
- #define Rtl819XMAC_Array Rtl8192SUMAC_2T_Array
- #define Rtl819XAGCTAB_Array Rtl8192SUAGCTAB_Array
- #define Rtl819XPHY_REG_Array Rtl8192SUPHY_REG_2T2RArray
- #define Rtl819XPHY_REG_to1T1R_Array Rtl8192SUPHY_ChangeTo_1T1RArray
- #define Rtl819XPHY_REG_to1T2R_Array Rtl8192SUPHY_ChangeTo_1T2RArray
- #define Rtl819XPHY_REG_to2T2R_Array Rtl8192SUPHY_ChangeTo_2T2RArray
- #define Rtl819XPHY_REG_Array_PG Rtl8192SUPHY_REG_Array_PG
- #define Rtl819XRadioA_Array Rtl8192SURadioA_1T_Array
- #define Rtl819XRadioB_Array Rtl8192SURadioB_Array
- #define Rtl819XRadioB_GM_Array Rtl8192SURadioB_GM_Array
- #define Rtl819XRadioA_to1T_Array Rtl8192SURadioA_to1T_Array
- #define Rtl819XRadioA_to2T_Array Rtl8192SURadioA_to2T_Array
-//
-// Queue Select Value in TxDesc
-//
-#define QSLT_BK 0x1
-#define QSLT_BE 0x0
-#define QSLT_VI 0x4
-#define QSLT_VO 0x6
-#define QSLT_BEACON 0x10
-#define QSLT_HIGH 0x11
-#define QSLT_MGNT 0x12
-#define QSLT_CMD 0x13
-
-#define DESC90_RATE1M 0x00
-#define DESC90_RATE2M 0x01
-#define DESC90_RATE5_5M 0x02
-#define DESC90_RATE11M 0x03
-#define DESC90_RATE6M 0x04
-#define DESC90_RATE9M 0x05
-#define DESC90_RATE12M 0x06
-#define DESC90_RATE18M 0x07
-#define DESC90_RATE24M 0x08
-#define DESC90_RATE36M 0x09
-#define DESC90_RATE48M 0x0a
-#define DESC90_RATE54M 0x0b
-#define DESC90_RATEMCS0 0x00
-#define DESC90_RATEMCS1 0x01
-#define DESC90_RATEMCS2 0x02
-#define DESC90_RATEMCS3 0x03
-#define DESC90_RATEMCS4 0x04
-#define DESC90_RATEMCS5 0x05
-#define DESC90_RATEMCS6 0x06
-#define DESC90_RATEMCS7 0x07
-#define DESC90_RATEMCS8 0x08
-#define DESC90_RATEMCS9 0x09
-#define DESC90_RATEMCS10 0x0a
-#define DESC90_RATEMCS11 0x0b
-#define DESC90_RATEMCS12 0x0c
-#define DESC90_RATEMCS13 0x0d
-#define DESC90_RATEMCS14 0x0e
-#define DESC90_RATEMCS15 0x0f
-#define DESC90_RATEMCS32 0x20
-
-// CCK Rates, TxHT = 0
-#define DESC92S_RATE1M 0x00
-#define DESC92S_RATE2M 0x01
-#define DESC92S_RATE5_5M 0x02
-#define DESC92S_RATE11M 0x03
-
-// OFDM Rates, TxHT = 0
-#define DESC92S_RATE6M 0x04
-#define DESC92S_RATE9M 0x05
-#define DESC92S_RATE12M 0x06
-#define DESC92S_RATE18M 0x07
-#define DESC92S_RATE24M 0x08
-#define DESC92S_RATE36M 0x09
-#define DESC92S_RATE48M 0x0a
-#define DESC92S_RATE54M 0x0b
-
-// MCS Rates, TxHT = 1
-#define DESC92S_RATEMCS0 0x0c
-#define DESC92S_RATEMCS1 0x0d
-#define DESC92S_RATEMCS2 0x0e
-#define DESC92S_RATEMCS3 0x0f
-#define DESC92S_RATEMCS4 0x10
-#define DESC92S_RATEMCS5 0x11
-#define DESC92S_RATEMCS6 0x12
-#define DESC92S_RATEMCS7 0x13
-#define DESC92S_RATEMCS8 0x14
-#define DESC92S_RATEMCS9 0x15
-#define DESC92S_RATEMCS10 0x16
-#define DESC92S_RATEMCS11 0x17
-#define DESC92S_RATEMCS12 0x18
-#define DESC92S_RATEMCS13 0x19
-#define DESC92S_RATEMCS14 0x1a
-#define DESC92S_RATEMCS15 0x1b
-#define DESC92S_RATEMCS15_SG 0x1c
-#define DESC92S_RATEMCS32 0x20
-
-#define RTL819X_DEFAULT_RF_TYPE RF_1T2R
-
-#define IEEE80211_WATCH_DOG_TIME 2000
-#define PHY_Beacon_RSSI_SLID_WIN_MAX 10
-//for txpowertracking
-#define OFDM_Table_Length 19
-#define CCK_Table_length 12
-
-//
-//Tx Descriptor for RLT8192SU(Normal mode)
-//
-typedef struct _tx_desc_819x_usb {
- // DWORD 0
- u16 PktSize;//:16;
- u8 Offset;//:8;
- u8 Type:2; // Reserved for MAC header Frame Type subfield.
- u8 LastSeg:1;
- u8 FirstSeg:1;
- u8 LINIP:1;
- u8 AMSDU:1;
- u8 GF:1;
- u8 OWN:1;
-
- // DWORD 1
- u8 MacID:5;
- u8 MoreData:1;
- u8 MOREFRAG:1;
- u8 PIFS:1;
- u8 QueueSelect:5;
- u8 AckPolicy:2;
- u8 NoACM:1;
- u8 NonQos:1;
- u8 KeyID:2;
- u8 OUI:1;
- u8 PktType:1;
- u8 EnDescID:1;
- u8 SecType:2;
- u8 HTC:1; //padding0
- u8 WDS:1; //padding1
- u8 PktOffset:5; //padding_len (hw)
- u8 HWPC:1;
-
- // DWORD 2
- u32 DataRetryLmt:6;
- u32 RetryLmtEn:1;
- u32 TSFL:5;
- u32 RTSRC:6; // Reserved for HW RTS Retry Count.
- u32 DATARC:6; // Reserved for HW DATA Retry Count.
- u32 Rsvd1:5;
- u32 AllowAggregation:1;
- u32 BK:1; //Aggregation break.
- u32 OwnMAC:1;
-
- // DWORD 3
- u8 NextHeadPage;//:8;
- u8 TailPage;//:8;
- u16 Seq:12;
- u16 Frag:4;
-
- // DWORD 4
- u32 RTSRate:6;
- u32 DisRTSFB:1;
- u32 RTSRateFBLmt:4;
- u32 CTS2Self:1;
- u32 RTSEn:1;
- u32 RaBRSRID:3; //Rate adaptive BRSR ID.
- u32 TxHT:1;
- u32 TxShort:1;//for data
- u32 TxBandwidth:1;
- u32 TxSubCarrier:2;
- u32 STBC:2;
- u32 RD:1;
- u32 RTSHT:1;
- u32 RTSShort:1;
- u32 RTSBW:1;
- u32 RTSSubcarrier:2;
- u32 RTSSTBC:2;
- u32 USERATE:1;
- // DWORD 5
- u32 PktID:9;
- u32 TxRate:6;
- u32 DISFB:1;
- u32 DataRateFBLmt:5;
- u32 TxAGC:11;
-
- // DWORD 6
- u16 IPChkSum;//:16;
- u16 TCPChkSum;//:16;
-
- // DWORD 7
- //u16 TxBuffSize;//:16;//pcie
- u16 TxBufferSize;
- u16 IPHdrOffset:8;
- u16 Rsvd2:7;
- u16 TCPEn:1;
-}tx_desc_819x_usb, *ptx_desc_819x_usb;
-typedef struct _tx_status_desc_8192s_usb{
-
- //DWORD 0
- u8 TxRate:6;
- u8 Rsvd1:1;
- u8 BandWidth:1;
- u8 RTSRate:6;
- u8 AGGLS:1;
- u8 AGG:1;
- u8 RTSRC:6;
- u8 DataRC:6;
- u8 FailCause:2;
- u8 TxOK:1;
- u8 Own:1;
-
- //DWORD 1
- u16 Seq:12;
- u8 QueueSel:5;
- u8 MACID:5;
- u8 PwrMgt:1;
- u8 MoreData:1;
- u8 Rsvd2;
-
- //DWORD 2
- u8 RxAGC1;
- u8 RxAGC2;
- u8 RxAGC3;
- u8 RxAGC4;
-}tx_status_desc_8192s_usb, *ptx_status_desc_8192s_usb;
-
-
-
-//
-//Tx Descriptor for RLT8192SU(Load FW mode)
-//
-typedef struct _tx_desc_cmd_819x_usb{
- // DWORD 0
- u16 PktSize;
- u8 Offset;
- u8 Rsvd0:4;
- u8 LINIP:1;
- u8 Rsvd1:2;
- u8 OWN:1;
-
- // DWORD 1, 2, 3, 4, 5, 6 are all reserved.
- u32 Rsvd2;
- u32 Rsvd3;
- u32 Rsvd4;
- u32 Rsvd5;
- u32 Rsvd6;
- u32 Rsvd7;
-
- // DWORD 7
- u16 TxBuffSize;//pcie
- u16 Rsvd8;
-}tx_desc_cmd_819x_usb, *ptx_desc_cmd_819x_usb;
-//
-//H2C Command for RLT8192SU(Host TxCmd)
-//
-typedef struct _tx_h2c_desc_cmd_8192s_usb{
- // DWORD 0
- u32 PktSize:16;
- u32 Offset:8;
- u32 Rsvd0:7;
- u32 OWN:1;
-
- // DWORD 1
- u32 Rsvd1:8;
- u32 QSEL:5;
- u32 Rsvd2:19;
-
- // DWORD 2
- u32 Rsvd3;
-
- // DWORD 3
- u32 NextHeadPage:8;
- u32 TailPage:8;
- u32 Rsvd4:16;
-
- // DWORD 4, 5, 6, 7
- u32 Rsvd5;
- u32 Rsvd6;
- u32 Rsvd7;
- u32 Rsvd8;
-}tx_h2c_desc_cmd_8192s_usb, *ptx_h2c_desc_cmd_8192s_usb;
-
-
-typedef struct _tx_h2c_cmd_hdr_8192s_usb{
- // DWORD 0
- u32 CmdLen:16;
- u32 ElementID:8;
- u32 CmdSeq:8;
-
- // DWORD 1
- u32 Rsvd0;
-}tx_h2c_cmd_hdr_8192s_usb, *ptx_h2c_cmd_hdr_8192s_usb;
-
-typedef struct _tx_fwinfo_819x_usb{
- //DWORD 0
- u8 TxRate:7;
- u8 CtsEnable:1;
- u8 RtsRate:7;
- u8 RtsEnable:1;
- u8 TxHT:1;
- u8 Short:1; //Short PLCP for CCK, or short GI for 11n MCS
- u8 TxBandwidth:1; // This is used for HT MCS rate only.
- u8 TxSubCarrier:2; // This is used for legacy OFDM rate only.
- u8 STBC:2;
- u8 AllowAggregation:1;
- u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate
- u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS
- u8 RtsBandwidth:1; // This is used for HT MCS rate only.
- u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only.
- u8 RtsSTBC:2;
- u8 EnableCPUDur:1; //Enable firmware to recalculate and assign packet duration
-
- //DWORD 1
- u32 RxMF:2;
- u32 RxAMD:3;
- u32 Reserved1:3;
- u32 TxAGCOffSet:4;//TxAGCOffset:4;
- u32 TxAGCSign:1;
- u32 Tx_INFO_RSVD:6;
- u32 PacketID:13;
-}tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
-
-typedef struct rtl8192_rx_info {
- struct urb *urb;
- struct net_device *dev;
- u8 out_pipe;
-}rtl8192_rx_info ;
-
-typedef struct rx_desc_819x_usb{
- //DWORD 0
- u16 Length:14;
- u16 CRC32:1;
- u16 ICV:1;
- u8 RxDrvInfoSize:4;
- u8 Security:3;
- u8 Qos:1;
- u8 Shift:2;
- u8 PHYStatus:1;
- u8 SWDec:1;
- u8 LastSeg:1;
- u8 FirstSeg:1;
- u8 EOR:1;
- u8 Own:1;
-
- //DWORD 1
- u16 MACID:5;
- u16 TID:4;
- u16 HwRsvd:5;
- u16 PAGGR:1;
- u16 FAGGR:1;
- u8 A1_FIT:4;
- u8 A2_FIT:4;
- u8 PAM:1;
- u8 PWR:1;
- u8 MoreData:1;
- u8 MoreFrag:1;
- u8 Type:2;
- u8 MC:1;
- u8 BC:1;
-
- //DWORD 2
- u16 Seq:12;
- u16 Frag:4;
- u8 NextPktLen;//:8;
- u8 Rsvd0:6;
- u8 NextIND:1;
- u8 Rsvd1:1;
-
- //DWORD 3
- u8 RxMCS:6;
- u8 RxHT:1;
- u8 AMSDU:1;
- u8 SPLCP:1;
- u8 BW:1;
- u8 HTC:1;
- u8 TCPChkRpt:1;
- u8 IPChkRpt:1;
- u8 TCPChkValID:1;
- u8 HwPCErr:1;
- u8 HwPCInd:1;
- u16 IV0;//:16;
-
- //DWORD 4
- u32 IV1;
-
- //DWORD 5
- u32 TSFL;
-}rx_desc_819x_usb, *prx_desc_819x_usb;
-
-
-//
-// Driver info are written to the begining of the RxBuffer
-//
-typedef struct rx_drvinfo_819x_usb{
- u8 gain_trsw[4];
-
- //DWORD 1
- u8 pwdb_all;
- u8 cfosho[4];
-
- //DWORD 2
- u8 cfotail[4];
-
- //DWORD 3
- char rxevm[2];
- char rxsnr[4];
-
- //DWORD 4
- u8 pdsnr[2];
-
- //DWORD 5
- u8 csi_current[2];
- u8 csi_target[2];
-
- //DWORD 6
- u8 sigevm;
- u8 max_ex_pwr;
- u8 ex_intf_flag:1;
- u8 sgi_en:1;
- u8 rxsc:2;
- u8 reserve:4;
-
-}rx_drvinfo_819x_usb, *prx_drvinfo_819x_usb;
-
- #define HWSET_MAX_SIZE_92S 128
- #define MAX_802_11_HEADER_LENGTH 40
- #define MAX_PKT_AGG_NUM 256
- #define TX_PACKET_SHIFT_BYTES USB_HWDESC_HEADER_LEN
-
-#define MAX_DEV_ADDR_SIZE 8 /* support till 64 bit bus width OS */
-#define MAX_FIRMWARE_INFORMATION_SIZE 32 /*2006/04/30 by Emily forRTL8190*/
-#define ENCRYPTION_MAX_OVERHEAD 128
-#define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb)
-#define MAX_FRAGMENT_COUNT 8
-#ifdef RTL8192U
-#define MAX_TRANSMIT_BUFFER_SIZE 8000
-#else
-#define MAX_TRANSMIT_BUFFER_SIZE (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT)
-#endif
-#define scrclng 4 // octets for crc32 (FCS, ICV)
-
-#define HAL_DM_DIG_DISABLE BIT0
-#define HAL_DM_HIPWR_DISABLE BIT1
-
-typedef enum rf_optype
-{
- RF_OP_By_SW_3wire = 0,
- RF_OP_By_FW,
- RF_OP_MAX
-}rf_op_type;
-
-/* for rtl819x */
-typedef enum _RT_STATUS{
- RT_STATUS_SUCCESS = 0,
- RT_STATUS_FAILURE = 1,
- RT_STATUS_PENDING = 2,
- RT_STATUS_RESOURCE = 3
-}RT_STATUS,*PRT_STATUS;
-
-typedef enum _RTL8192SUSB_LOOPBACK{
- RTL8192SU_NO_LOOPBACK = 0,
- RTL8192SU_MAC_LOOPBACK = 1,
- RTL8192SU_DMA_LOOPBACK = 2,
- RTL8192SU_CCK_LOOPBACK = 3,
-}RTL8192SUSB_LOOPBACK_E;
-
-#define MAX_RECEIVE_BUFFER_SIZE 9100 // Add this to 9100 bytes to receive A-MSDU from RT-AP
-
-
-/* Firmware Queue Layout */
-#define NUM_OF_FIRMWARE_QUEUE 10
-#define NUM_OF_PAGES_IN_FW 0x100
-
-
-#define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x020
-#define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x020
-#define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x040
-#define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x040
-#define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
-#define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x4
-#define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x20
-#define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
-#define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4
-#define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x18
-
-
-#define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000
-#define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00
-#define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08
-#define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10
-#define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18
-#define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10
-#define RSVD_FW_QUEUE_PAGE_CMD_SHIFT 0x08
-#define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00
-#define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08
-
-#define DEFAULT_FRAG_THRESHOLD 2342U
-#define MIN_FRAG_THRESHOLD 256U
-#define DEFAULT_BEACONINTERVAL 0x64U
-#define DEFAULT_BEACON_ESSID "Rtl819xU"
-
-#define DEFAULT_SSID ""
-#define DEFAULT_RETRY_RTS 7
-#define DEFAULT_RETRY_DATA 7
-#define PRISM_HDR_SIZE 64
-
-#define PHY_RSSI_SLID_WIN_MAX 100
-
-
-typedef enum _WIRELESS_MODE {
- WIRELESS_MODE_UNKNOWN = 0x00,
- WIRELESS_MODE_A = 0x01,
- WIRELESS_MODE_B = 0x02,
- WIRELESS_MODE_G = 0x04,
- WIRELESS_MODE_AUTO = 0x08,
- WIRELESS_MODE_N_24G = 0x10,
- WIRELESS_MODE_N_5G = 0x20
-} WIRELESS_MODE;
-
-
-#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
-
-typedef struct buffer
-{
- struct buffer *next;
- u32 *buf;
-
-} buffer;
-
-typedef struct rtl_reg_debug{
- unsigned int cmd;
- struct {
- unsigned char type;
- unsigned char addr;
- unsigned char page;
- unsigned char length;
- } head;
- unsigned char buf[0xff];
-}rtl_reg_debug;
-
-typedef struct _rt_9x_tx_rate_history {
- u32 cck[4];
- u32 ofdm[8];
- u32 ht_mcs[4][16];
-}rt_tx_rahis_t, *prt_tx_rahis_t;
-typedef struct _RT_SMOOTH_DATA_4RF {
- char elements[4][100];//array to store values
- u32 index; //index to current array to store
- u32 TotalNum; //num of valid elements
- u32 TotalVal[4]; //sum of valid elements
-}RT_SMOOTH_DATA_4RF, *PRT_SMOOTH_DATA_4RF;
-
-#define MAX_8192U_RX_SIZE 8192 // This maybe changed for D-cut larger aggregation size
-//stats seems messed up, clean it ASAP
-typedef struct Stats
-{
- unsigned long txrdu;
- unsigned long rxok;
- unsigned long rxframgment;
- unsigned long rxcmdpkt[4]; //08/05/08 amy rx cmd element txfeedback/bcn report/cfg set/query
- unsigned long rxurberr;
- unsigned long rxstaterr;
- unsigned long received_rate_histogram[4][32]; //0: Total, 1:OK, 2:CRC, 3:ICV, 2007 07 03 cosa
- unsigned long received_preamble_GI[2][32]; //0: Long preamble/GI, 1:Short preamble/GI
- unsigned long rx_AMPDUsize_histogram[5]; // level: (<4K), (4K~8K), (8K~16K), (16K~32K), (32K~64K)
- unsigned long rx_AMPDUnum_histogram[5]; // level: (<5), (5~10), (10~20), (20~40), (>40)
- unsigned long numpacket_matchbssid; // debug use only.
- unsigned long numpacket_toself; // debug use only.
- unsigned long num_process_phyinfo; // debug use only.
- unsigned long numqry_phystatus;
- unsigned long numqry_phystatusCCK;
- unsigned long numqry_phystatusHT;
- unsigned long received_bwtype[5]; //0: 20M, 1: funn40M, 2: upper20M, 3: lower20M, 4: duplicate
- unsigned long txnperr;
- unsigned long txnpdrop;
- unsigned long txresumed;
- unsigned long txnpokint;
- unsigned long txoverflow;
- unsigned long txlpokint;
- unsigned long txlpdrop;
- unsigned long txlperr;
- unsigned long txbeokint;
- unsigned long txbedrop;
- unsigned long txbeerr;
- unsigned long txbkokint;
- unsigned long txbkdrop;
- unsigned long txbkerr;
- unsigned long txviokint;
- unsigned long txvidrop;
- unsigned long txvierr;
- unsigned long txvookint;
- unsigned long txvodrop;
- unsigned long txvoerr;
- unsigned long txbeaconokint;
- unsigned long txbeacondrop;
- unsigned long txbeaconerr;
- unsigned long txmanageokint;
- unsigned long txmanagedrop;
- unsigned long txmanageerr;
- unsigned long txdatapkt;
- unsigned long txfeedback;
- unsigned long txfeedbackok;
-
- unsigned long txoktotal;
- unsigned long txokbytestotal;
- unsigned long txokinperiod;
- unsigned long txmulticast;
- unsigned long txbytesmulticast;
- unsigned long txbroadcast;
- unsigned long txbytesbroadcast;
- unsigned long txunicast;
- unsigned long txbytesunicast;
-
- unsigned long rxoktotal;
- unsigned long rxbytesunicast;
- unsigned long txfeedbackfail;
- unsigned long txerrtotal;
- unsigned long txerrbytestotal;
- unsigned long txerrmulticast;
- unsigned long txerrbroadcast;
- unsigned long txerrunicast;
- unsigned long txretrycount;
- unsigned long txfeedbackretry;
- u8 last_packet_rate;
- unsigned long slide_signal_strength[100];
- unsigned long slide_evm[100];
- unsigned long slide_rssi_total; // For recording sliding window's RSSI value
- unsigned long slide_evm_total; // For recording sliding window's EVM value
- long signal_strength; // Transformed, in dbm. Beautified signal strength for UI, not correct.
- long signal_quality;
- long last_signal_strength_inpercent;
- long recv_signal_power; // Correct smoothed ss in Dbm, only used in driver to report real power now.
- u8 rx_rssi_percentage[4];
- u8 rx_evm_percentage[2];
- long rxSNRdB[4];
- rt_tx_rahis_t txrate;
- u32 Slide_Beacon_pwdb[100]; //cosa add for beacon rssi
- u32 Slide_Beacon_Total; //cosa add for beacon rssi
- RT_SMOOTH_DATA_4RF cck_adc_pwdb;
-
- u32 CurrentShowTxate;
-} Stats;
-
-// Bandwidth Offset
-#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
-#define HAL_PRIME_CHNL_OFFSET_LOWER 1
-#define HAL_PRIME_CHNL_OFFSET_UPPER 2
-
-typedef struct ChnlAccessSetting {
- u16 SIFS_Timer;
- u16 DIFS_Timer;
- u16 SlotTimeTimer;
- u16 EIFS_Timer;
- u16 CWminIndex;
- u16 CWmaxIndex;
-}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING;
-
-typedef struct _BB_REGISTER_DEFINITION{
- u32 rfintfs; // set software control: // 0x870~0x877[8 bytes]
- u32 rfintfi; // readback data: // 0x8e0~0x8e7[8 bytes]
- u32 rfintfo; // output data: // 0x860~0x86f [16 bytes]
- u32 rfintfe; // output enable: // 0x860~0x86f [16 bytes]
- u32 rf3wireOffset; // LSSI data: // 0x840~0x84f [16 bytes]
- u32 rfLSSI_Select; // BB Band Select: // 0x878~0x87f [8 bytes]
- u32 rfTxGainStage; // Tx gain stage: // 0x80c~0x80f [4 bytes]
- u32 rfHSSIPara1; // wire parameter control1 : // 0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes]
- u32 rfHSSIPara2; // wire parameter control2 : // 0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
- u32 rfSwitchControl; //Tx Rx antenna control : // 0x858~0x85f [16 bytes]
- u32 rfAGCControl1; //AGC parameter control1 : // 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes]
- u32 rfAGCControl2; //AGC parameter control2 : // 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
- u32 rfRxIQImbalance; //OFDM Rx IQ imbalance matrix : // 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
- u32 rfRxAFE; //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : // 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes]
- u32 rfTxIQImbalance; //OFDM Tx IQ imbalance matrix // 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes]
- u32 rfTxAFE; //Tx IQ DC Offset and Tx DFIR type // 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
- u32 rfLSSIReadBack; //LSSI RF readback data // 0x8a0~0x8af [16 bytes]
- u32 rfLSSIReadBackPi; //LSSI RF readback data PI mode 0x8b8-8bc for Path A and B
-}BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
-
-typedef enum _RT_RF_TYPE_819xU{
- RF_TYPE_MIN = 0,
- RF_8225,
- RF_8256,
- RF_8258,
- RF_6052=4, // 4 11b/g/n RF
- RF_PSEUDO_11N = 5,
-}RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
-
-typedef enum _RF_POWER_STATE{
- RF_ON,
- RF_SLEEP,
- RF_OFF,
- RF_SHUT_DOWN,
-}RF_POWER_STATE, *PRF_POWER_STATE;
-
-typedef struct _rate_adaptive
-{
- u8 rate_adaptive_disabled;
- u8 ratr_state;
- u16 reserve;
-
- u32 high_rssi_thresh_for_ra;
- u32 high2low_rssi_thresh_for_ra;
- u8 low2high_rssi_thresh_for_ra40M;
- u32 low_rssi_thresh_for_ra40M;
- u8 low2high_rssi_thresh_for_ra20M;
- u32 low_rssi_thresh_for_ra20M;
- u32 upper_rssi_threshold_ratr;
- u32 middle_rssi_threshold_ratr;
- u32 low_rssi_threshold_ratr;
- u32 low_rssi_threshold_ratr_40M;
- u32 low_rssi_threshold_ratr_20M;
- u8 ping_rssi_enable; //cosa add for test
- u32 ping_rssi_ratr; //cosa add for test
- u32 ping_rssi_thresh_for_ra;//cosa add for test
- u32 last_ratr;
-
-} rate_adaptive, *prate_adaptive;
-
-#define TxBBGainTableLength 37
-#define CCKTxBBGainTableLength 23
-
-typedef struct _txbbgain_struct
-{
- long txbb_iq_amplifygain;
- u32 txbbgain_value;
-} txbbgain_struct, *ptxbbgain_struct;
-
-typedef struct _ccktxbbgain_struct
-{
- //The Value is from a22 to a29 one Byte one time is much Safer
- u8 ccktxbb_valuearray[8];
-} ccktxbbgain_struct,*pccktxbbgain_struct;
-
-
-typedef struct _init_gain
-{
- u8 xaagccore1;
- u8 xbagccore1;
- u8 xcagccore1;
- u8 xdagccore1;
- u8 cca;
-
-} init_gain, *pinit_gain;
-
-typedef struct _phy_ofdm_rx_status_report_819xusb
-{
- u8 trsw_gain_X[4];
- u8 pwdb_all;
- u8 cfosho_X[4];
- u8 cfotail_X[4];
- u8 rxevm_X[2];
- u8 rxsnr_X[4];
- u8 pdsnr_X[2];
- u8 csi_current_X[2];
- u8 csi_target_X[2];
- u8 sigevm;
- u8 max_ex_pwr;
- u8 sgi_en;
- u8 rxsc_sgien_exflg;
-}phy_sts_ofdm_819xusb_t;
-
-typedef struct _phy_cck_rx_status_report_819xusb
-{
- /* For CCK rate descriptor. This is a unsigned 8:1 variable. LSB bit presend
- 0.5. And MSB 7 bts presend a signed value. Range from -64~+63.5. */
- u8 adc_pwdb_X[4];
- u8 sq_rpt;
- u8 cck_agc_rpt;
-}phy_sts_cck_819xusb_t;
-
-
-typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag{
- u8 reserved:4;
- u8 rxsc:2;
- u8 sgi_en:1;
- u8 ex_intf_flag:1;
-}phy_ofdm_rx_status_rxsc_sgien_exintfflag;
-
-typedef enum _RT_CUSTOMER_ID
-{
- RT_CID_DEFAULT = 0,
- RT_CID_8187_ALPHA0 = 1,
- RT_CID_8187_SERCOMM_PS = 2,
- RT_CID_8187_HW_LED = 3,
- RT_CID_8187_NETGEAR = 4,
- RT_CID_WHQL = 5,
- RT_CID_819x_CAMEO = 6,
- RT_CID_819x_RUNTOP = 7,
- RT_CID_819x_Senao = 8,
- RT_CID_TOSHIBA = 9, // Merge by Jacken, 2008/01/31.
- RT_CID_819x_Netcore = 10,
- RT_CID_Nettronix = 11,
- RT_CID_DLINK = 12,
- RT_CID_PRONET = 13,
- RT_CID_COREGA = 14,
- RT_CID_819x_ALPHA = 15,
- RT_CID_819x_Sitecom = 16,
- RT_CID_CCX = 17,
- RT_CID_819x_Lenovo = 18,
- RT_CID_819x_QMI = 19,
- RT_CID_819x_Edimax_Belkin = 20,
- RT_CID_819x_Sercomm_Belkin = 21,
- RT_CID_819x_CAMEO1 = 22,
- RT_CID_819x_MSI = 23,
- RT_CID_819x_Acer = 24,
-}RT_CUSTOMER_ID, *PRT_CUSTOMER_ID;
-
-typedef enum _RT_OP_MODE{
- RT_OP_MODE_AP,
- RT_OP_MODE_INFRASTRUCTURE,
- RT_OP_MODE_IBSS,
- RT_OP_MODE_NO_LINK,
-}RT_OP_MODE, *PRT_OP_MODE;
-
-typedef enum _RESET_TYPE {
- RESET_TYPE_NORESET = 0x00,
- RESET_TYPE_NORMAL = 0x01,
- RESET_TYPE_SILENT = 0x02
-} RESET_TYPE;
-
-/* The simple tx command OP code. */
-typedef enum _tag_TxCmd_Config_Index{
- TXCMD_TXRA_HISTORY_CTRL = 0xFF900000,
- TXCMD_RESET_TX_PKT_BUFF = 0xFF900001,
- TXCMD_RESET_RX_PKT_BUFF = 0xFF900002,
- TXCMD_SET_TX_DURATION = 0xFF900003,
- TXCMD_SET_RX_RSSI = 0xFF900004,
- TXCMD_SET_TX_PWR_TRACKING = 0xFF900005,
- TXCMD_XXXX_CTRL,
-}DCMD_TXCMD_OP;
-
-typedef enum{
- NIC_8192U = 1,
- NIC_8190P = 2,
- NIC_8192E = 3,
- NIC_8192SE = 4,
- NIC_8192SU = 5,
- } nic_t;
-
-struct rtl819x_ops{
- nic_t nic_type;
- void (* rtl819x_read_eeprom_info)(struct net_device *dev);
- short (* rtl819x_tx)(struct net_device *dev, struct sk_buff* skb);
- short (* rtl819x_tx_cmd)(struct net_device *dev, struct sk_buff *skb);
- void (* rtl819x_rx_nomal)(struct sk_buff* skb);
- void (* rtl819x_rx_cmd)(struct sk_buff *skb);
- bool (* rtl819x_adapter_start)(struct net_device *dev);
- void (* rtl819x_link_change)(struct net_device *dev);
- void (* rtl819x_initial_gain)(struct net_device *dev,u8 Operation);
- void (* rtl819x_query_rxdesc_status)(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe);
-};
-
-typedef struct r8192_priv
-{
- struct rtl819x_ops* ops;
- struct usb_device *udev;
- /* added for maintain info from eeprom */
- short epromtype;
- u16 eeprom_vid;
- u16 eeprom_pid;
- u8 eeprom_CustomerID;
- u8 eeprom_SubCustomerID;
- u16 eeprom_ChannelPlan;
- RT_CUSTOMER_ID CustomerID;
- LED_STRATEGY_819xUsb LedStrategy;
- u8 txqueue_to_outpipemap[9];
- u8 RtOutPipes[16];
- u8 RtInPipes[16];
- u8 ep_in_num;
- u8 ep_out_num;
- u8 ep_num;
- int irq;
- struct ieee80211_device *ieee80211;
-
- u8 RATRTableBitmap;
-
- u32 IC_Cut;
- short card_8192; /* O: rtl8192, 1:rtl8185 V B/C, 2:rtl8185 V D */
- u32 card_8192_version; /* if TCR reports card V B/C this discriminates */
- short enable_gpio0;
- enum card_type {PCI,MINIPCI,CARDBUS,USB}card_type;
- short hw_plcp_len;
- short plcp_preamble_mode;
-
- spinlock_t irq_lock;
- spinlock_t tx_lock;
- spinlock_t ps_lock;
- struct mutex mutex;
- bool ps_force;
- spinlock_t rf_lock; //used to lock rf write operation added by wb
- spinlock_t rf_ps_lock;
-
- u16 irq_mask;
- short chan;
- short sens;
- short max_sens;
-
- short up;
- short crcmon; //if 1 allow bad crc frame reception in monitor mode
- bool bSurpriseRemoved;
-
- struct semaphore wx_sem;
- struct semaphore rf_sem; //used to lock rf write operation added by wb, modified by david
-
- u8 rf_type; //0 means 1T2R, 1 means 2T4R
- RT_RF_TYPE_819xU rf_chip;
-
- short (*rf_set_sens)(struct net_device *dev,short sens);
- u8 (*rf_set_chan)(struct net_device *dev,u8 ch);
- void (*rf_close)(struct net_device *dev);
- void (*rf_init)(struct net_device *dev);
- short promisc;
- u32 mc_filter[2];
- /*stats*/
- struct Stats stats;
- struct iw_statistics wstats;
- struct proc_dir_entry *dir_dev;
-
- /*RX stuff*/
- struct urb **rx_urb;
- struct urb **rx_cmd_urb;
-
-/* for Rx process */
- struct sk_buff_head rx_queue;
- struct sk_buff_head skb_queue;
-
- struct work_struct qos_activate;
-
- short tx_urb_index;
- atomic_t tx_pending[0x10];//UART_PRIORITY+1
-
-
- struct tasklet_struct irq_rx_tasklet;
- struct tasklet_struct irq_tx_tasklet;
- struct urb *rxurb_task;
-
- //2 Tx Related variables
- u16 ShortRetryLimit;
- u16 LongRetryLimit;
- u32 TransmitConfig;
- u8 RegCWinMin; // For turbo mode CW adaptive. Added by Annie, 2005-10-27.
-
- u32 LastRxDescTSFHigh;
- u32 LastRxDescTSFLow;
-
-
- //2 Rx Related variables
- u16 EarlyRxThreshold;
- u32 ReceiveConfig;
- u8 AcmControl;
-
- u8 RFProgType;
-
- u8 retry_data;
- u8 retry_rts;
- u16 rts;
-
- struct ChnlAccessSetting ChannelAccessSetting;
-
- struct work_struct reset_wq;
- struct work_struct mcast_wq;
-
-/**********************************************************/
- //for rtl819xUsb
- u16 basic_rate;
- u8 short_preamble;
- u8 slot_time;
- bool bDcut;
- bool bCurrentRxAggrEnable;
- u8 Rf_Mode; //add for Firmware RF -R/W switch
- u8 FwRsvdTxPageCfg;
- prt_firmware pFirmware;
- RTL8192SUSB_LOOPBACK_E LoopbackMode;
- bool usb_error;
-
- u16 EEPROMTxPowerDiff;
- u8 EEPROMThermalMeter;
- u8 EEPROMPwDiff;
- u8 EEPROMCrystalCap;
- u8 EEPROMBluetoothCoexist;
- u8 EEPROM_Def_Ver;
- u8 EEPROMTxPowerLevelCCK;// CCK channel 1~14
- u8 EEPROMTxPowerLevelCCK_V1[3];
- u8 EEPROMTxPowerLevelOFDM24G[3]; // OFDM 2.4G channel 1~14
- u8 EEPROMTxPowerLevelOFDM5G[24]; // OFDM 5G
-
- u8 EEPROMOptional;
- u8 ShowRateMode;
- bool bForcedShowRxRate;
-
- u32 RfRegChnlVal[2];
-
- bool bDmDisableProtect;
- bool bIgnoreDiffRateTxPowerOffset;
-
- // For EEPROM TX Power Index like 8190 series
- u8 EEPROMRfACCKChnl1TxPwLevel[3]; //RF-A CCK Tx Power Level at channel 7
- u8 EEPROMRfAOfdmChnlTxPwLevel[3];//RF-A CCK Tx Power Level at [0],[1],[2] = channel 1,7,13
- u8 EEPROMRfCCCKChnl1TxPwLevel[3]; //RF-C CCK Tx Power Level at channel 7
- u8 EEPROMRfCOfdmChnlTxPwLevel[3];//RF-C CCK Tx Power Level at [0],[1],[2] = channel 1,7,13
-
- // F92S new definition
- //RF-A&B CCK/OFDM Tx Power Level at three channel are [1-3] [4-9] [10-14]
- u8 RfCckChnlAreaTxPwr[2][3];
- u8 RfOfdmChnlAreaTxPwr1T[2][3];
- u8 RfOfdmChnlAreaTxPwr2T[2][3];
-
- // Add For EEPROM Efuse switch and Efuse Shadow map Setting
- bool EepromOrEfuse;
- bool bBootFromEfuse; // system boot form EFUSE
- u8 EfuseMap[2][HWSET_MAX_SIZE_92S];
- u16 EfuseUsedBytes;
- u8 EfuseUsedPercentage;
-
-
- u8 EEPROMUsbOption;
- u8 EEPROMUsbPhyParam[5];
- u8 EEPROMTxPwrBase;
- u8 EEPROMBoardType;
- bool bBootFromEEPROM; // system boot from EEPROM
- u8 EEPROMTSSI_A;
- u8 EEPROMTSSI_B;
- u8 EEPROMHT2T_TxPwr[6]; // For channel 1, 7 and 13 on path A/B.
- u8 EEPROMTxPwrTkMode;
-
- u8 bTXPowerDataReadFromEEPORM;
- u8 EEPROMRegulatory;
- u8 EEPROMPwrGroup[2][3];
-
- u8 EEPROMVersion;
- u8 EEPROMUsbEndPointNumber;
-
- bool AutoloadFailFlag;
- u8 RfTxPwrLevelCck[2][14];
- u8 RfTxPwrLevelOfdm1T[2][14];
- u8 RfTxPwrLevelOfdm2T[2][14];
- // new EEPROM format.
- u8 TxPwrHt20Diff[2][14]; // HT 20<->40 Pwr diff
- u8 TxPwrLegacyHtDiff[2][14]; // For HT<->legacy pwr diff
- u8 TxPwrbandEdgeHt40[2][2]; // Band edge for HY 40MHZlow/up channel
- u8 TxPwrbandEdgeHt20[2][2]; // Band edge for HY 40MHZ low/up channel
- u8 TxPwrbandEdgeLegacyOfdm[2][2]; // Band edge for legacy ofdm low/up channel
- u8 TxPwrbandEdgeFlag; // Band edge enable flag
-
- // L1 and L2 high power threshold.
- u8 MidHighPwrTHR_L1;
- u8 MidHighPwrTHR_L2;
- u8 TxPwrSafetyFlag; // for Tx power safety spec
-
-/*PHY related*/
- BB_REGISTER_DEFINITION_T PHYRegDef[4]; //Radio A/B/C/D
- // Read/write are allow for following hardware information variables
- u32 MCSTxPowerLevelOriginalOffset[7];//FIXLZM
- u32 CCKTxPowerLevelOriginalOffset;
- u8 TxPowerLevelCCK[14]; // CCK channel 1~14
- u8 TxPowerLevelOFDM24G[14]; // OFDM 2.4G channel 1~14
- u8 TxPowerLevelOFDM5G[14]; // OFDM 5G
- u32 Pwr_Track;
- u8 TxPowerDiff;
- u8 AntennaTxPwDiff[2]; // Antenna gain offset, index 0 for B, 1 for C, and 2 for D
- u8 ThermalMeter[2]; // ThermalMeter, index 0 for RFIC0, and 1 for RFIC1
- u8 ThermalValue;
- u8 CrystalCap; // CrystalCap.
- u8 BluetoothCoexist;
- u8 ExternalPA;
-
- u8 CckPwEnl;
- // Use to calculate PWBD.
- u8 bCckHighPower;
- long undecorated_smoothed_pwdb;
-
- //for set channel
- u8 SwChnlInProgress;
- u8 SwChnlStage;
- u8 SwChnlStep;
- u8 SetBWModeInProgress;
- HT_CHANNEL_WIDTH CurrentChannelBW;
- bool bChnlPlanFromHW;
- u8 ChannelPlan;
- u16 RegChannelPlan;
- u8 pwrGroupCnt;
- // 8190 40MHz mode
- //
- u8 nCur40MhzPrimeSC; // Control channel sub-carrier
-
- u32 RfReg0Value[4];
- u8 NumTotalRFPath;
- bool brfpath_rxenable[4];
- //RF set related
- bool SetRFPowerStateInProgress;
-
- struct timer_list watch_dog_timer;
-
- bool bdynamic_txpower; //bDynamicTxPower
- bool bDynamicTxHighPower; // Tx high power state
- bool bDynamicTxLowPower; // Tx low power state
- bool bLastDTPFlag_High;
- bool bLastDTPFlag_Low;
-
- bool bstore_last_dtpflag;
- bool bstart_txctrl_bydtp; //Define to discriminate on High power State or on sitesuvey to change Tx gain index
-
- rate_adaptive rate_adaptive;
- // TX power tracking
- txbbgain_struct txbbgain_table[TxBBGainTableLength];
- u8 EEPROMTxPowerTrackEnable;
- u8 txpower_count;//For 6 sec do tracking again
- bool btxpower_trackingInit;
- u8 OFDM_index;
- u8 CCK_index;
- u8 Record_CCK_20Mindex;
- u8 Record_CCK_40Mindex;
- // CCK TX Power Tracking
- ccktxbbgain_struct cck_txbbgain_table[CCKTxBBGainTableLength];
- ccktxbbgain_struct cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
- u8 rfa_txpowertrackingindex;
- u8 rfa_txpowertrackingindex_real;
- u8 rfa_txpowertracking_default;
- u8 rfc_txpowertrackingindex;
- u8 rfc_txpowertrackingindex_real;
-
- s8 cck_present_attentuation;
- u8 cck_present_attentuation_20Mdefault;
- u8 cck_present_attentuation_40Mdefault;
- char cck_present_attentuation_difference;
- bool btxpower_tracking;
- bool bcck_in_ch14;
- bool btxpowerdata_readfromEEPORM;
- u16 TSSI_13dBm;
- u8 CCKPresentAttentuation_20Mdefault;
- u8 CCKPresentAttentuation_40Mdefault;
- char CCKPresentAttentuation_difference;
- char CCKPresentAttentuation;
- bool bDMInitialGainEnable;
- //For Backup Initial Gain
- init_gain initgain_backup;
- u8 DefaultInitialGain[4];
- // For EDCA Turbo mode
- bool bis_any_nonbepkts;
- bool bcurrent_turbo_EDCA;
- bool bis_cur_rdlstate;
- struct timer_list fsync_timer;
- bool bfsync_processing; // 500ms Fsync timer is active or not
- u32 rate_record;
- u32 rateCountDiffRecord;
- u32 ContiuneDiffCount;
- bool bswitch_fsync;
-
- u8 framesync;
- u32 framesyncC34;
- u8 framesyncMonitor;
- // RX related
- u16 nrxAMPDU_size;
- u8 nrxAMPDU_aggr_num;
-
- // gpio
- bool bHwRadioOff;
-
- bool isRFOff;
- bool bInPowerSaveMode;
-
- bool RFChangeInProgress;
- bool RegRfOff;
- u8 bHwRfOffAction;
-
- u32 reset_count;
- bool bpbc_pressed;
- // debug
- u32 txpower_checkcnt;
- u32 txpower_tracking_callback_cnt;
- u8 thermal_read_val[40];
- u8 thermal_readback_index;
- u32 ccktxpower_adjustcnt_not_ch14;
- u32 ccktxpower_adjustcnt_ch14;
- u8 tx_fwinfo_force_subcarriermode;
- u8 tx_fwinfo_force_subcarrierval;
- // silent reset
- RESET_TYPE ResetProgress;
- bool bForcedSilentReset;
- bool bDisableNormalResetCheck;
- u16 TxCounter;
- u16 RxCounter;
- int IrpPendingCount;
- bool bResetInProgress;
- bool force_reset;
- bool force_lps;
- u8 InitialGainOperateType;
-
- u16 SifsTime;
-
- struct delayed_work update_beacon_wq;
- struct delayed_work watch_dog_wq;
- struct delayed_work txpower_tracking_wq;
- struct delayed_work rfpath_check_wq;
- struct delayed_work gpio_change_rf_wq;
- struct delayed_work initialgain_operate_wq;
-
- struct workqueue_struct *priv_wq;
-
- u32 IntrMask;
- // RF and BB access related synchronization flags.
- bool bChangeBBInProgress; // BaseBand RW is still in progress.
- bool bChangeRFInProgress; // RF RW is still in progress.
-
- u32 CCKTxPowerAdjustCntCh14; //debug only
- u32 CCKTxPowerAdjustCntNotCh14; //debug only
- u32 TXPowerTrackingCallbackCnt; //debug only
- u32 TxPowerCheckCnt; //debug only
- u32 RFWritePageCnt[3]; //debug only
- u32 RFReadPageCnt[3]; //debug only
- u8 ThermalReadBackIndex; //debug only
- u8 ThermalReadVal[40]; //debug only
-
- // not realize true, just define it, set it 0 default, because some func use it
- bool bInHctTest;
-
- // The current Tx Power Level
- u8 CurrentCckTxPwrIdx;
- u8 CurrentOfdm24GTxPwrIdx;
-
- // For pass 92S common phycfg.c compiler
- u8 TxPowerLevelCCK_A[14]; // RF-A, CCK channel 1~14
- u8 TxPowerLevelOFDM24G_A[14]; // RF-A, OFDM 2.4G channel 1~14
- u8 TxPowerLevelCCK_C[14]; // RF-C, CCK channel 1~14
- u8 TxPowerLevelOFDM24G_C[14]; // RF-C, OFDM 2.4G channel 1~14
- u8 LegacyHTTxPowerDiff; // Legacy to HT rate power diff
- char RF_C_TxPwDiff; // Antenna gain offset, rf-c to rf-a
-
- bool bRFSiOrPi;//0=si, 1=pi.
-
- bool SetFwCmdInProgress; //is set FW CMD in Progress? 92S only
- u8 CurrentFwCmdIO;
-
- u8 MinSpaceCfg;
-
- u16 rf_pathmap;
-
- /* added for led control */
- PLED_819xUsb pLed;
- LED_819xUsb SwLed0;
- LED_819xUsb SwLed1;
- u8 bRegUseLed;
- struct work_struct BlinkWorkItem;
- /* added for led control */
- u16 FwCmdIOMap;
- u32 FwCmdIOParam;
- u8 DMFlag;
-
-
-
-
-}r8192_priv;
-
-//for rtl8187B
-typedef enum{
- BULK_PRIORITY = 0x01,
- //RSVD0,
- //RSVD1,
- LOW_PRIORITY,
- NORM_PRIORITY,
- VO_PRIORITY,
- VI_PRIORITY, //0x05
- BE_PRIORITY,
- BK_PRIORITY,
- RSVD2,
- RSVD3,
- BEACON_PRIORITY, //0x0A
- HIGH_PRIORITY,
- MANAGE_PRIORITY,
- RSVD4,
- RSVD5,
- UART_PRIORITY //0x0F
-} priority_t;
-
-#ifdef JOHN_HWSEC
-struct ssid_thread {
- struct net_device *dev;
- u8 name[IW_ESSID_MAX_SIZE + 1];
-};
-#endif
-
-void LedControl8192SUsb(struct net_device *dev, LED_CTL_MODE LedAction);
-void InitSwLeds(struct net_device *dev);
-void DeInitSwLeds(struct net_device *dev);
-short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
-short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb);
-bool FirmwareDownload92S(struct net_device *dev);
-
-short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
-short rtl8192_tx(struct net_device *dev, struct sk_buff* skb);
-
-u32 read_cam(struct net_device *dev, u8 addr);
-void write_cam(struct net_device *dev, u8 addr, u32 data);
-
-u8 read_nic_byte(struct net_device *dev, int x);
-u8 read_nic_byte_E(struct net_device *dev, int x);
-u32 read_nic_dword(struct net_device *dev, int x);
-u16 read_nic_word(struct net_device *dev, int x) ;
-void write_nic_byte(struct net_device *dev, int x,u8 y);
-void write_nic_byte_E(struct net_device *dev, int x,u8 y);
-void write_nic_word(struct net_device *dev, int x,u16 y);
-void write_nic_dword(struct net_device *dev, int x,u32 y);
-void force_pci_posting(struct net_device *dev);
-
-void rtl8192_rtx_disable(struct net_device *);
-void rtl8192_rx_enable(struct net_device *);
-void rtl8192_tx_enable(struct net_device *);
-
-void rtl8192_disassociate(struct net_device *dev);
-void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a);
-
-void rtl8192_set_anaparam(struct net_device *dev,u32 a);
-void rtl8185_set_anaparam2(struct net_device *dev,u32 a);
-void rtl8192_update_msr(struct net_device *dev);
-int rtl8192_down(struct net_device *dev);
-int rtl8192_up(struct net_device *dev);
-void rtl8192_commit(struct net_device *dev);
-void rtl8192_set_chan(struct net_device *dev,short ch);
-void write_phy(struct net_device *dev, u8 adr, u8 data);
-void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
-void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
-void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
-void rtl8192_set_rxconf(struct net_device *dev);
-extern void rtl819xusb_beacon_tx(struct net_device *dev,u16 tx_rate);
-void CamResetAllEntry(struct net_device* dev);
-void EnableHWSecurityConfig8192(struct net_device *dev);
-void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent );
-short rtl8192_is_tx_queue_empty(struct net_device *dev);
-
-#endif
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
deleted file mode 100644
index df5b52baf893..000000000000
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ /dev/null
@@ -1,7712 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- * Linux device driver for RTL8192U
- *
- * Based on the r8187 driver, which is:
- * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * Jerry chuang <wlanfae@realtek.com>
- */
-
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/eeprom_93cx6.h>
-#include <linux/notifier.h>
-
-#undef LOOP_TEST
-#undef DUMP_RX
-#undef DUMP_TX
-#undef DEBUG_TX_DESC2
-#undef RX_DONT_PASS_UL
-#undef DEBUG_EPROM
-#undef DEBUG_RX_VERBOSE
-#undef DUMMY_RX
-#undef DEBUG_ZERO_RX
-#undef DEBUG_RX_SKB
-#undef DEBUG_TX_FRAG
-#undef DEBUG_RX_FRAG
-#undef DEBUG_TX_FILLDESC
-#undef DEBUG_TX
-#undef DEBUG_IRQ
-#undef DEBUG_RX
-#undef DEBUG_RXALLOC
-#undef DEBUG_REGISTERS
-#undef DEBUG_RING
-#undef DEBUG_IRQ_TASKLET
-#undef DEBUG_TX_ALLOC
-#undef DEBUG_TX_DESC
-
-#define CONFIG_RTL8192_IO_MAP
-
-#include <asm/uaccess.h>
-#include "r8192U.h"
-#include "r8192U_wx.h"
-
-#include "r8192S_rtl8225.h"
-#include "r8192S_hw.h"
-#include "r8192S_phy.h"
-#include "r8192S_phyreg.h"
-#include "r8192S_Efuse.h"
-
-#include "r819xU_cmdpkt.h"
-#include "r8192U_dm.h"
-//#include "r8192xU_phyreg.h"
-#include <linux/usb.h>
-
-#include "r8192U_pm.h"
-
-#include "ieee80211/dot11d.h"
-
-
-
-u32 rt_global_debug_component = \
-// COMP_TRACE |
-// COMP_DBG |
-// COMP_INIT |
-// COMP_RECV |
-// COMP_SEND |
-// COMP_IO |
- COMP_POWER |
-// COMP_EPROM |
- COMP_SWBW |
- COMP_POWER_TRACKING |
- COMP_TURBO |
- COMP_QOS |
-// COMP_RATE |
-// COMP_RM |
- COMP_DIG |
-// COMP_EFUSE |
-// COMP_CH |
-// COMP_TXAGC |
- COMP_HIPWR |
-// COMP_HALDM |
- COMP_SEC |
- COMP_LED |
-// COMP_RF |
-// COMP_RXDESC |
- COMP_FIRMWARE |
- COMP_HT |
- COMP_AMSDU |
- COMP_SCAN |
-// COMP_CMD |
- COMP_DOWN |
- COMP_RESET |
- COMP_ERR; //always open err flags on
-
-#define TOTAL_CAM_ENTRY 32
-#define CAM_CONTENT_COUNT 8
-
-static const struct usb_device_id rtl8192_usb_id_tbl[] = {
- {USB_DEVICE(0x0bda, 0x8171)}, /* Realtek */
- {USB_DEVICE(0x0bda, 0x8172)},
- {USB_DEVICE(0x0bda, 0x8173)},
- {USB_DEVICE(0x0bda, 0x8174)},
- {USB_DEVICE(0x0bda, 0x8712)},
- {USB_DEVICE(0x0bda, 0x8713)},
- {USB_DEVICE(0x07aa, 0x0047)},
- {USB_DEVICE(0x07d1, 0x3303)},
- {USB_DEVICE(0x07d1, 0x3302)},
- {USB_DEVICE(0x07d1, 0x3300)},
- {USB_DEVICE(0x1740, 0x9603)},
- {USB_DEVICE(0x1740, 0x9605)},
- {USB_DEVICE(0x050d, 0x815F)},
- {USB_DEVICE(0x06f8, 0xe031)},
- {USB_DEVICE(0x7392, 0x7611)},
- {USB_DEVICE(0x7392, 0x7612)},
- {USB_DEVICE(0x7392, 0x7622)},
- {USB_DEVICE(0x0DF6, 0x0045)},
- {USB_DEVICE(0x0E66, 0x0015)},
- {USB_DEVICE(0x0E66, 0x0016)},
- {USB_DEVICE(0x0b05, 0x1786)},
- /* these are not in the official list */
- {USB_DEVICE(0x0df6, 0x004b)}, /* WL-349 */
- {}
-};
-
-MODULE_LICENSE("GPL");
-MODULE_VERSION("V 1.1");
-MODULE_DEVICE_TABLE(usb, rtl8192_usb_id_tbl);
-MODULE_DESCRIPTION("Linux driver for Realtek RTL8192 USB WiFi cards");
-
-static char ifname[IFNAMSIZ] = "wlan%d";
-static int hwwep = 1; //default use hw. set 0 to use software security
-static int channels = 0x3fff;
-
-
-
-module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR);
-//module_param(hwseqnum,int, S_IRUGO|S_IWUSR);
-module_param(hwwep,int, S_IRUGO|S_IWUSR);
-module_param(channels,int, S_IRUGO|S_IWUSR);
-
-MODULE_PARM_DESC(ifname," Net interface name, wlan%d=default");
-//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
-MODULE_PARM_DESC(hwwep," Try to use hardware security support. ");
-MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
-
-static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id);
-static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf);
-static const struct net_device_ops rtl8192_netdev_ops;
-static struct notifier_block proc_netdev_notifier;
-
-static struct usb_driver rtl8192_usb_driver = {
- .name = RTL819xU_MODULE_NAME, /* Driver name */
- .id_table = rtl8192_usb_id_tbl, /* PCI_ID table */
- .probe = rtl8192_usb_probe, /* probe fn */
- .disconnect = rtl8192_usb_disconnect, /* remove fn */
- .suspend = rtl8192U_suspend, /* PM suspend fn */
- .resume = rtl8192U_resume, /* PM resume fn */
- .reset_resume = rtl8192U_resume, /* PM reset resume fn */
-};
-
-
-static void rtl8192SU_read_eeprom_info(struct net_device *dev);
-short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb);
-void rtl8192SU_rx_nomal(struct sk_buff* skb);
-void rtl8192SU_rx_cmd(struct sk_buff *skb);
-bool rtl8192SU_adapter_start(struct net_device *dev);
-short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb);
-void rtl8192SU_link_change(struct net_device *dev);
-void InitialGain8192S(struct net_device *dev,u8 Operation);
-void rtl8192SU_query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe);
-
-struct rtl819x_ops rtl8192su_ops = {
- .nic_type = NIC_8192SU,
- .rtl819x_read_eeprom_info = rtl8192SU_read_eeprom_info,
- .rtl819x_tx = rtl8192SU_tx,
- .rtl819x_tx_cmd = rtl8192SU_tx_cmd,
- .rtl819x_rx_nomal = rtl8192SU_rx_nomal,
- .rtl819x_rx_cmd = rtl8192SU_rx_cmd,
- .rtl819x_adapter_start = rtl8192SU_adapter_start,
- .rtl819x_link_change = rtl8192SU_link_change,
- .rtl819x_initial_gain = InitialGain8192S,
- .rtl819x_query_rxdesc_status = rtl8192SU_query_rxdesc_status,
-};
-
-
-typedef struct _CHANNEL_LIST
-{
- u8 Channel[32];
- u8 Len;
-}CHANNEL_LIST, *PCHANNEL_LIST;
-
-static CHANNEL_LIST ChannelPlan[] = {
- {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC
- {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI
- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI.
- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI.
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1
- {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel.
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC
- {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626
-};
-
-static void rtl819x_eeprom_register_read(struct eeprom_93cx6 *eeprom)
-{
- struct net_device *dev = eeprom->data;
- u8 reg = read_nic_byte(dev, EPROM_CMD);
-
- eeprom->reg_data_in = reg & RTL819X_EEPROM_CMD_WRITE;
- eeprom->reg_data_out = reg & RTL819X_EEPROM_CMD_READ;
- eeprom->reg_data_clock = reg & RTL819X_EEPROM_CMD_CK;
- eeprom->reg_chip_select = reg & RTL819X_EEPROM_CMD_CS;
-}
-
-static void rtl819x_eeprom_register_write(struct eeprom_93cx6 *eeprom)
-{
- struct net_device *dev = eeprom->data;
- u8 reg = 2 << 6;
-
- if (eeprom->reg_data_in)
- reg |= RTL819X_EEPROM_CMD_WRITE;
- if (eeprom->reg_data_out)
- reg |= RTL819X_EEPROM_CMD_READ;
- if (eeprom->reg_data_clock)
- reg |= RTL819X_EEPROM_CMD_CK;
- if (eeprom->reg_chip_select)
- reg |= RTL819X_EEPROM_CMD_CS;
-
- write_nic_byte(dev, EPROM_CMD, reg);
- read_nic_byte(dev, EPROM_CMD);
- udelay(10);
-}
-
-static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
-{
- int i, max_chan=-1, min_chan=-1;
- struct ieee80211_device* ieee = priv->ieee80211;
-
- ieee->bGlobalDomain = false;
- switch (priv->rf_chip) {
- case RF_8225:
- case RF_8256:
- case RF_6052:
- min_chan = 1;
- max_chan = 14;
- break;
- default:
- pr_err("%s(): unknown rf chip, can't set channel map\n",
- __func__);
- break;
- }
- if (ChannelPlan[channel_plan].Len != 0) {
- memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
- sizeof(GET_DOT11D_INFO(ieee)->channel_map));
-
- for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
- if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
- break;
- GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
- }
- }
- switch (channel_plan) {
- case COUNTRY_CODE_GLOBAL_DOMAIN:
- ieee->bGlobalDomain = true;
- for (i = 12; i <= 14; i++)
- GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
- ieee->IbssStartChnl = 10;
- ieee->ibss_maxjoin_chal = 11;
- break;
- case COUNTRY_CODE_WORLD_WIDE_13:
- printk(KERN_INFO "world wide 13\n");
- for (i = 12; i <= 13; i++)
- GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
- ieee->IbssStartChnl = 10;
- ieee->ibss_maxjoin_chal = 11;
- break;
- default:
- ieee->IbssStartChnl = 1;
- ieee->ibss_maxjoin_chal = 14;
- break;
- }
- return;
-}
-
-#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
-
-#define rx_hal_is_cck_rate(_pDesc)\
- ((_pDesc->RxMCS == DESC92S_RATE1M ||\
- _pDesc->RxMCS == DESC92S_RATE2M ||\
- _pDesc->RxMCS == DESC92S_RATE5_5M ||\
- _pDesc->RxMCS == DESC92S_RATE11M) &&\
- !_pDesc->RxHT)
-
-#define tx_hal_is_cck_rate(_DataRate)\
- ( _DataRate == MGN_1M ||\
- _DataRate == MGN_2M ||\
- _DataRate == MGN_5_5M ||\
- _DataRate == MGN_11M )
-
-
-
-
-void CamResetAllEntry(struct net_device *dev)
-{
-#if 1
- u32 ulcommand = 0;
- //2004/02/11 In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA associate to AP.
- // However, ResetKey is called on OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest
- // In this condition, Cam can not be reset because upper layer will not set this static key again.
- //if(Adapter->EncAlgorithm == WEP_Encryption)
- // return;
-//debug
- //DbgPrint("========================================\n");
- //DbgPrint(" Call ResetAllEntry \n");
- //DbgPrint("========================================\n\n");
- ulcommand |= BIT31|BIT30;
- write_nic_dword(dev, RWCAM, ulcommand);
-#else
- for(ucIndex=0;ucIndex<TOTAL_CAM_ENTRY;ucIndex++)
- CAM_mark_invalid(dev, ucIndex);
- for(ucIndex=0;ucIndex<TOTAL_CAM_ENTRY;ucIndex++)
- CAM_empty_entry(dev, ucIndex);
-#endif
-
-}
-
-
-void write_cam(struct net_device *dev, u8 addr, u32 data)
-{
- write_nic_dword(dev, WCAMI, data);
- write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff) );
-}
-
-u32 read_cam(struct net_device *dev, u8 addr)
-{
- write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff) );
- return read_nic_dword(dev, 0xa8);
-}
-
-void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
-{
- int status;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
- RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
- indx|0xfe00, 0, &data, 1, HZ / 2);
-
- if (status < 0)
- {
- printk("write_nic_byte_E TimeOut! status:%d\n", status);
- }
-}
-
-u8 read_nic_byte_E(struct net_device *dev, int indx)
-{
- int status;
- u8 data;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
- RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
- indx|0xfe00, 0, &data, 1, HZ / 2);
-
- if (status < 0)
- {
- printk("read_nic_byte_E TimeOut! status:%d\n", status);
- }
-
- return data;
-}
-//as 92U has extend page from 4 to 16, so modify functions below.
-void write_nic_byte(struct net_device *dev, int indx, u8 data)
-{
- int status;
-
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
- RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
- indx, 0, &data, 1, HZ / 2);
-
- if (status < 0)
- {
- printk("write_nic_byte TimeOut! status:%d\n", status);
- }
-
-
-}
-
-
-void write_nic_word(struct net_device *dev, int indx, u16 data)
-{
-
- int status;
-
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
- RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
- indx, 0, &data, 2, HZ / 2);
-
- if (status < 0)
- {
- printk("write_nic_word TimeOut! status:%d\n", status);
- }
-
-}
-
-
-void write_nic_dword(struct net_device *dev, int indx, u32 data)
-{
-
- int status;
-
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
- RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
- indx, 0, &data, 4, HZ / 2);
-
-
- if (status < 0)
- {
- printk("write_nic_dword TimeOut! status:%d\n", status);
- }
-
-}
-
-
-
-u8 read_nic_byte(struct net_device *dev, int indx)
-{
- u8 data;
- int status;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
- RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
- indx, 0, &data, 1, HZ / 2);
-
- if (status < 0)
- {
- printk("read_nic_byte TimeOut! status:%d\n", status);
- }
-
- return data;
-}
-
-
-
-u16 read_nic_word(struct net_device *dev, int indx)
-{
- u16 data;
- int status;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
- RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
- indx, 0, &data, 2, HZ / 2);
-
- if (status < 0)
- {
- printk("read_nic_word TimeOut! status:%d\n", status);
- }
-
-
- return data;
-}
-
-u16 read_nic_word_E(struct net_device *dev, int indx)
-{
- u16 data;
- int status;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
- RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
- indx|0xfe00, 0, &data, 2, HZ / 2);
-
- if (status < 0)
- {
- printk("read_nic_word TimeOut! status:%d\n", status);
- }
-
-
- return data;
-}
-
-u32 read_nic_dword(struct net_device *dev, int indx)
-{
- u32 data;
- int status;
-// int result;
-
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct usb_device *udev = priv->udev;
-
- status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
- RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
- indx, 0, &data, 4, HZ / 2);
-// if(0 != result) {
-// printk(KERN_WARNING "read size of data = %d\, date = %d\n", result, data);
-// }
-
- if (status < 0)
- {
- printk("read_nic_dword TimeOut! status:%d\n", status);
- if(status == -ENODEV) {
- priv->usb_error = true;
- }
- }
-
-
-
- return data;
-}
-
-
-//u8 read_phy_cck(struct net_device *dev, u8 adr);
-//u8 read_phy_ofdm(struct net_device *dev, u8 adr);
-/* this might still called in what was the PHY rtl8185/rtl8192 common code
- * plans are to possibilty turn it again in one common code...
- */
-inline void force_pci_posting(struct net_device *dev)
-{
-}
-
-
-static struct net_device_stats *rtl8192_stats(struct net_device *dev);
-void rtl8192_commit(struct net_device *dev);
-//void rtl8192_restart(struct net_device *dev);
-void rtl8192_restart(struct work_struct *work);
-//void rtl8192_rq_tx_ack(struct work_struct *work);
-
-void watch_dog_timer_callback(unsigned long data);
-
-/****************************************************************************
- -----------------------------PROCFS STUFF-------------------------
-*****************************************************************************/
-
-static struct proc_dir_entry *rtl8192_proc = NULL;
-
-
-
-static int proc_get_stats_ap(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
- struct ieee80211_network *target;
-
- int len = 0;
-
- list_for_each_entry(target, &ieee->network_list, list) {
-
- len += snprintf(page + len, count - len,
- "%s ", target->ssid);
-
- if(target->wpa_ie_len>0 || target->rsn_ie_len>0){
- len += snprintf(page + len, count - len,
- "WPA\n");
- }
- else{
- len += snprintf(page + len, count - len,
- "non_WPA\n");
- }
-
- }
-
- *eof = 1;
- return len;
-}
-
-static int proc_get_registers(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0,page1,page2;
-
- int max=0xff;
- page0 = 0x000;
- page1 = 0x100;
- page2 = 0x800;
-
- /* This dump the current register page */
- if(!IS_BB_REG_OFFSET_92S(page0)){
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len,
- "\nD: %2x > ",n);
- for(i=0;i<16 && n<=max;i++,n++)
- len += snprintf(page + len, count - len,
- "%2.2x ",read_nic_byte(dev,(page0|n)));
- }
- }else{
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-
-}
-static int proc_get_registers_1(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0x100;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len,
- "\nD: %2x > ",n);
- for(i=0;i<16 && n<=max;i++,n++)
- len += snprintf(page + len, count - len,
- "%2.2x ",read_nic_byte(dev,(page0|n)));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-
-}
-static int proc_get_registers_2(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0x200;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len,
- "\nD: %2x > ",n);
- for(i=0;i<16 && n<=max;i++,n++)
- len += snprintf(page + len, count - len,
- "%2.2x ",read_nic_byte(dev,(page0|n)));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-
-}
-static int proc_get_registers_8(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0x800;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-
- }
-static int proc_get_registers_9(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0x900;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-}
-static int proc_get_registers_a(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0xa00;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-}
-static int proc_get_registers_b(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0xb00;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
- }
-static int proc_get_registers_c(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0xc00;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-}
-static int proc_get_registers_d(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0xd00;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-}
-static int proc_get_registers_e(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
- int i,n,page0;
-
- int max=0xff;
- page0 = 0xe00;
-
- /* This dump the current register page */
- len += snprintf(page + len, count - len,
- "\n####################page %x##################\n ", (page0>>8));
- for(n=0;n<=max;)
- {
- len += snprintf(page + len, count - len, "\nD: %2x > ",n);
- for(i=0;i<4 && n<=max;n+=4,i++)
- len += snprintf(page + len, count - len,
- "%8.8x ",rtl8192_QueryBBReg(dev,(page0|n), bMaskDWord));
- }
- len += snprintf(page + len, count - len,"\n");
- *eof = 1;
- return len;
-}
-
-static int proc_get_stats_tx(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
-
- len += snprintf(page + len, count - len,
- "TX VI priority ok int: %lu\n"
- "TX VI priority error int: %lu\n"
- "TX VO priority ok int: %lu\n"
- "TX VO priority error int: %lu\n"
- "TX BE priority ok int: %lu\n"
- "TX BE priority error int: %lu\n"
- "TX BK priority ok int: %lu\n"
- "TX BK priority error int: %lu\n"
- "TX MANAGE priority ok int: %lu\n"
- "TX MANAGE priority error int: %lu\n"
- "TX BEACON priority ok int: %lu\n"
- "TX BEACON priority error int: %lu\n"
-// "TX high priority ok int: %lu\n"
-// "TX high priority failed error int: %lu\n"
- "TX queue resume: %lu\n"
- "TX queue stopped?: %d\n"
- "TX fifo overflow: %lu\n"
-// "TX beacon: %lu\n"
- "TX VI queue: %d\n"
- "TX VO queue: %d\n"
- "TX BE queue: %d\n"
- "TX BK queue: %d\n"
-// "TX HW queue: %d\n"
- "TX VI dropped: %lu\n"
- "TX VO dropped: %lu\n"
- "TX BE dropped: %lu\n"
- "TX BK dropped: %lu\n"
- "TX total data packets %lu\n",
-// "TX beacon aborted: %lu\n",
- priv->stats.txviokint,
- priv->stats.txvierr,
- priv->stats.txvookint,
- priv->stats.txvoerr,
- priv->stats.txbeokint,
- priv->stats.txbeerr,
- priv->stats.txbkokint,
- priv->stats.txbkerr,
- priv->stats.txmanageokint,
- priv->stats.txmanageerr,
- priv->stats.txbeaconokint,
- priv->stats.txbeaconerr,
-// priv->stats.txhpokint,
-// priv->stats.txhperr,
- priv->stats.txresumed,
- netif_queue_stopped(dev),
- priv->stats.txoverflow,
-// priv->stats.txbeacon,
- atomic_read(&(priv->tx_pending[VI_PRIORITY])),
- atomic_read(&(priv->tx_pending[VO_PRIORITY])),
- atomic_read(&(priv->tx_pending[BE_PRIORITY])),
- atomic_read(&(priv->tx_pending[BK_PRIORITY])),
-// read_nic_byte(dev, TXFIFOCOUNT),
- priv->stats.txvidrop,
- priv->stats.txvodrop,
- priv->stats.txbedrop,
- priv->stats.txbkdrop,
- priv->stats.txdatapkt
-// priv->stats.txbeaconerr
- );
-
- *eof = 1;
- return len;
-}
-
-
-
-static int proc_get_stats_rx(char *page, char **start,
- off_t offset, int count,
- int *eof, void *data)
-{
- struct net_device *dev = data;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- int len = 0;
-
- len += snprintf(page + len, count - len,
- "RX packets: %lu\n"
- "RX urb status error: %lu\n"
- "RX invalid urb error: %lu\n",
- priv->stats.rxoktotal,
- priv->stats.rxstaterr,
- priv->stats.rxurberr);
-
- *eof = 1;
- return len;
-}
-
-int rtl8192_proc_module_init(void)
-{
- int ret;
-
- RT_TRACE(COMP_INIT, "Initializing proc filesystem");
- rtl8192_proc=create_proc_entry(RTL819xU_MODULE_NAME, S_IFDIR, init_net.proc_net);
- if (!rtl8192_proc)
- return -ENOMEM;
- ret = register_netdevice_notifier(&proc_netdev_notifier);
- if (ret)
- remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
- return ret;
-}
-
-
-void rtl8192_proc_module_remove(void)
-{
- unregister_netdevice_notifier(&proc_netdev_notifier);
- remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net);
-}
-
-
-void rtl8192_proc_remove_one(struct net_device *dev)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
-
- if (priv->dir_dev) {
- // remove_proc_entry("stats-hw", priv->dir_dev);
- remove_proc_entry("stats-tx", priv->dir_dev);
- remove_proc_entry("stats-rx", priv->dir_dev);
- // remove_proc_entry("stats-ieee", priv->dir_dev);
- remove_proc_entry("stats-ap", priv->dir_dev);
- remove_proc_entry("registers", priv->dir_dev);
- remove_proc_entry("registers-1", priv->dir_dev);
- remove_proc_entry("registers-2", priv->dir_dev);
- remove_proc_entry("registers-8", priv->dir_dev);
- remove_proc_entry("registers-9", priv->dir_dev);
- remove_proc_entry("registers-a", priv->dir_dev);
- remove_proc_entry("registers-b", priv->dir_dev);
- remove_proc_entry("registers-c", priv->dir_dev);
- remove_proc_entry("registers-d", priv->dir_dev);
- remove_proc_entry("registers-e", priv->dir_dev);
- // remove_proc_entry("cck-registers",priv->dir_dev);
- // remove_proc_entry("ofdm-registers",priv->dir_dev);
- remove_proc_entry(priv->dir_dev->name, rtl8192_proc);
- priv->dir_dev = NULL;
- }
-}
-
-
-void rtl8192_proc_init_one(struct net_device *dev)
-{
- struct proc_dir_entry *e;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- priv->dir_dev = create_proc_entry(dev->name,
- S_IFDIR | S_IRUGO | S_IXUGO,
- rtl8192_proc);
- if (!priv->dir_dev) {
- RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
- dev->name);
- return;
- }
- e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_stats_rx, dev);
-
- if (!e) {
- RT_TRACE(COMP_ERR,"Unable to initialize "
- "/proc/net/rtl8192/%s/stats-rx\n",
- dev->name);
- }
-
-
- e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_stats_tx, dev);
-
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/stats-tx\n",
- dev->name);
- }
-
- e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_stats_ap, dev);
-
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/stats-ap\n",
- dev->name);
- }
-
- e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-1", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_1, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-1\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-2", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_2, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-2\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-8", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_8, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-8\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-9", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_9, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-9\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-a", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_a, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-a\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-b", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_b, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-b\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-c", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_c, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-c\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-d", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_d, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-d\n",
- dev->name);
- }
- e = create_proc_read_entry("registers-e", S_IFREG | S_IRUGO,
- priv->dir_dev, proc_get_registers_e, dev);
- if (!e) {
- RT_TRACE(COMP_ERR, "Unable to initialize "
- "/proc/net/rtl8192/%s/registers-e\n",
- dev->name);
- }
-}
-
-static int proc_netdev_event(struct notifier_block *this,
- unsigned long event, void *ptr)
-{
- struct net_device *net_dev = ptr;
-
- if (net_dev->netdev_ops == &rtl8192_netdev_ops &&
- event == NETDEV_CHANGENAME) {
- rtl8192_proc_remove_one(net_dev);
- rtl8192_proc_init_one(net_dev);
- }
-
- return NOTIFY_DONE;
-}
-
-static struct notifier_block proc_netdev_notifier = {
- .notifier_call = proc_netdev_event,
-};
-
-/****************************************************************************
- -----------------------------MISC STUFF-------------------------
-*****************************************************************************/
-
-/* this is only for debugging */
-void print_buffer(u32 *buffer, int len)
-{
- int i;
- u8 *buf =(u8*)buffer;
-
- printk("ASCII BUFFER DUMP (len: %x):\n",len);
-
- for(i=0;i<len;i++)
- printk("%c",buf[i]);
-
- printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
-
- for(i=0;i<len;i++)
- printk("%x",buf[i]);
-
- printk("\n");
-}
-
-//short check_nic_enough_desc(struct net_device *dev, priority_t priority)
-short check_nic_enough_desc(struct net_device *dev,int queue_index)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int used = atomic_read(&priv->tx_pending[queue_index]);
-
- return (used < MAX_TX_URB);
-}
-
-void tx_timeout(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //rtl8192_commit(dev);
-
- schedule_work(&priv->reset_wq);
- //DMESG("TXTIMEOUT");
-}
-
-/* this is only for debug */
-void rtl8192_dump_reg(struct net_device *dev)
-{
- int i;
- int n;
- int max=0x1ff;
-
- RT_TRACE(COMP_PHY, "Dumping NIC register map");
-
- for(n=0;n<=max;)
- {
- printk( "\nD: %2x> ", n);
- for(i=0;i<16 && n<=max;i++,n++)
- printk("%2x ",read_nic_byte(dev,n));
- }
- printk("\n");
-}
-
-/****************************************************************************
- ------------------------------HW STUFF---------------------------
-*****************************************************************************/
-
-void rtl8192_set_mode(struct net_device *dev,int mode)
-{
- u8 ecmd;
- ecmd=read_nic_byte(dev, EPROM_CMD);
- ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK;
- ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT);
- ecmd=ecmd &~ (1<<EPROM_CS_SHIFT);
- ecmd=ecmd &~ (1<<EPROM_CK_SHIFT);
- write_nic_byte(dev, EPROM_CMD, ecmd);
-}
-
-
-void rtl8192_update_msr(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- LED_CTL_MODE LedAction = LED_CTL_NO_LINK;
- u8 msr;
-
- msr = read_nic_byte(dev, MSR);
- msr &= ~ MSR_LINK_MASK;
-
- /* do not change in link_state != WLAN_LINK_ASSOCIATED.
- * msr must be updated if the state is ASSOCIATING.
- * this is intentional and make sense for ad-hoc and
- * master (see the create BSS/IBSS func)
- */
- if (priv->ieee80211->state == IEEE80211_LINKED) {
-
- if (priv->ieee80211->iw_mode == IW_MODE_INFRA) {
- msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
- LedAction = LED_CTL_LINK;
- } else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
- else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
- msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
-
- } else
- msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
-
- write_nic_byte(dev, MSR, msr);
-
- if(priv->ieee80211->LedControlHandler != NULL)
- priv->ieee80211->LedControlHandler(dev, LedAction);
-}
-
-void rtl8192_set_chan(struct net_device *dev,short ch)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-// u32 tx;
- RT_TRACE(COMP_CH, "=====>%s()====ch:%d\n", __FUNCTION__, ch);
- //printk("=====>%s()====ch:%d\n", __FUNCTION__, ch);
- priv->chan=ch;
-
- /* this hack should avoid frame TX during channel setting*/
-
-
-// tx = read_nic_dword(dev,TX_CONF);
-// tx &= ~TX_LOOPBACK_MASK;
-
-#ifndef LOOP_TEST
-// write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
-
- //need to implement rf set channel here WB
-
- if (priv->rf_set_chan)
- priv->rf_set_chan(dev,priv->chan);
- mdelay(10);
-// write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
-#endif
-}
-
-static void rtl8192_rx_isr(struct urb *urb);
-
-u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats)
-{
-
- return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize
- + pstats->RxBufShift);
-
-}
-static int rtl8192_rx_initiate(struct net_device*dev)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct urb *entry;
- struct sk_buff *skb;
- struct rtl8192_rx_info *info;
-
- /* nomal packet rx procedure */
- while (skb_queue_len(&priv->rx_queue) < MAX_RX_URB) {
- skb = __dev_alloc_skb(RX_URB_SIZE, GFP_KERNEL);
- if (!skb)
- break;
- entry = usb_alloc_urb(0, GFP_KERNEL);
- if (!entry) {
- kfree_skb(skb);
- break;
- }
- usb_fill_bulk_urb(entry, priv->udev,
- usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb),
- RX_URB_SIZE, rtl8192_rx_isr, skb);
- info = (struct rtl8192_rx_info *) skb->cb;
- info->urb = entry;
- info->dev = dev;
- info->out_pipe = 3; //denote rx normal packet queue
- skb_queue_tail(&priv->rx_queue, skb);
- usb_submit_urb(entry, GFP_KERNEL);
- }
-
- /* command packet rx procedure */
- while (skb_queue_len(&priv->rx_queue) < MAX_RX_URB + 3) {
- skb = __dev_alloc_skb(RX_URB_SIZE ,GFP_KERNEL);
- if (!skb)
- break;
- entry = usb_alloc_urb(0, GFP_KERNEL);
- if (!entry) {
- kfree_skb(skb);
- break;
- }
- usb_fill_bulk_urb(entry, priv->udev,
- usb_rcvbulkpipe(priv->udev, 9), skb_tail_pointer(skb),
- RX_URB_SIZE, rtl8192_rx_isr, skb);
- info = (struct rtl8192_rx_info *) skb->cb;
- info->urb = entry;
- info->dev = dev;
- info->out_pipe = 9; //denote rx cmd packet queue
- skb_queue_tail(&priv->rx_queue, skb);
- usb_submit_urb(entry, GFP_KERNEL);
- }
-
- return 0;
-}
-
-void rtl8192_set_rxconf(struct net_device *dev)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- u32 rxconf;
-
- rxconf=read_nic_dword(dev,RCR);
- rxconf = rxconf &~ MAC_FILTER_MASK;
- rxconf = rxconf | RCR_AMF;
- rxconf = rxconf | RCR_ADF;
- rxconf = rxconf | RCR_AB;
- rxconf = rxconf | RCR_AM;
- //rxconf = rxconf | RCR_ACF;
-
- if (dev->flags & IFF_PROMISC) {DMESG ("NIC in promisc mode");}
-
- if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
- dev->flags & IFF_PROMISC){
- rxconf = rxconf | RCR_AAP;
- } /*else if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
- rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
- rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
- }*/else{
- rxconf = rxconf | RCR_APM;
- rxconf = rxconf | RCR_CBSSID;
- }
-
-
- if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
- rxconf = rxconf | RCR_AICV;
- rxconf = rxconf | RCR_APWRMGT;
- }
-
- if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
- rxconf = rxconf | RCR_ACRC32;
-
-
- rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
- rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
- rxconf = rxconf &~ MAX_RX_DMA_MASK;
- rxconf = rxconf | ((u32)7<<RCR_MXDMA_OFFSET);
-
-// rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
- rxconf = rxconf | RCR_ONLYERLPKT;
-
-// rxconf = rxconf &~ RCR_CS_MASK;
-// rxconf = rxconf | (1<<RCR_CS_SHIFT);
-
- write_nic_dword(dev, RCR, rxconf);
-
- #ifdef DEBUG_RX
- DMESG("rxconf: %x %x",rxconf ,read_nic_dword(dev,RCR));
- #endif
-}
-//wait to be removed
-void rtl8192_rx_enable(struct net_device *dev)
-{
- //u8 cmd;
-
- //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- rtl8192_rx_initiate(dev);
-
-// rtl8192_set_rxconf(dev);
-}
-
-
-void rtl8192_tx_enable(struct net_device *dev)
-{
-}
-
-void rtl8192_rtx_disable(struct net_device *dev)
-{
- u8 cmd;
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct sk_buff *skb;
- struct rtl8192_rx_info *info;
-
- cmd=read_nic_byte(dev,CMDR);
- write_nic_byte(dev, CMDR, cmd &~ \
- (CR_TE|CR_RE));
- force_pci_posting(dev);
- mdelay(10);
-
- while ((skb = __skb_dequeue(&priv->rx_queue))) {
- info = (struct rtl8192_rx_info *) skb->cb;
- if (!info->urb)
- continue;
-
- usb_kill_urb(info->urb);
- kfree_skb(skb);
- }
-
- if (skb_queue_len(&priv->skb_queue)) {
- printk(KERN_WARNING "skb_queue not empty\n");
- }
-
- skb_queue_purge(&priv->skb_queue);
- return;
-}
-
-
-int alloc_tx_beacon_desc_ring(struct net_device *dev, int count)
-{
- return 0;
-}
-
-inline u16 ieeerate2rtlrate(int rate)
-{
- switch(rate){
- case 10:
- return 0;
- case 20:
- return 1;
- case 55:
- return 2;
- case 110:
- return 3;
- case 60:
- return 4;
- case 90:
- return 5;
- case 120:
- return 6;
- case 180:
- return 7;
- case 240:
- return 8;
- case 360:
- return 9;
- case 480:
- return 10;
- case 540:
- return 11;
- default:
- return 3;
-
- }
-}
-static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
-inline u16 rtl8192_rate2rate(short rate)
-{
- if (rate >11) return 0;
- return rtl_rate[rate];
-}
-
-static void rtl8192_rx_isr(struct urb *urb)
-{
- struct sk_buff *skb = (struct sk_buff *) urb->context;
- struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
- struct net_device *dev = info->dev;
- struct r8192_priv *priv = ieee80211_priv(dev);
- int out_pipe = info->out_pipe;
- int err;
- if(!priv->up)
- return;
- if (unlikely(urb->status)) {
- info->urb = NULL;
- priv->stats.rxstaterr++;
- priv->ieee80211->stats.rx_errors++;
- usb_free_urb(urb);
- // printk("%s():rx status err\n",__FUNCTION__);
- return;
- }
-
- skb_unlink(skb, &priv->rx_queue);
- skb_put(skb, urb->actual_length);
-
- skb_queue_tail(&priv->skb_queue, skb);
- tasklet_schedule(&priv->irq_rx_tasklet);
-
- skb = dev_alloc_skb(RX_URB_SIZE);
- if (unlikely(!skb)) {
- usb_free_urb(urb);
- printk("%s():can,t alloc skb\n",__FUNCTION__);
- /* TODO check rx queue length and refill *somewhere* */
- return;
- }
-
- usb_fill_bulk_urb(urb, priv->udev,
- usb_rcvbulkpipe(priv->udev, out_pipe),
- skb_tail_pointer(skb),
- RX_URB_SIZE, rtl8192_rx_isr, skb);
-
- info = (struct rtl8192_rx_info *) skb->cb;
- info->urb = urb;
- info->dev = dev;
- info->out_pipe = out_pipe;
-
- urb->transfer_buffer = skb_tail_pointer(skb);
- urb->context = skb;
- skb_queue_tail(&priv->rx_queue, skb);
- err = usb_submit_urb(urb, GFP_ATOMIC);
- if(err && err != -EPERM)
- printk("can not submit rxurb, err is %x,URB status is %x\n",err,urb->status);
-}
-
-u32
-rtl819xusb_rx_command_packet(
- struct net_device *dev,
- struct ieee80211_rx_stats *pstats
- )
-{
- u32 status;
-
- //RT_TRACE(COMP_RECV, DBG_TRACE, ("---> RxCommandPacketHandle819xUsb()\n"));
-
- status = cmpk_message_handle_rx(dev, pstats);
- if (status)
- {
- DMESG("rxcommandpackethandle819xusb: It is a command packet\n");
- }
- else
- {
- //RT_TRACE(COMP_RECV, DBG_TRACE, ("RxCommandPacketHandle819xUsb: It is not a command packet\n"));
- }
-
- //RT_TRACE(COMP_RECV, DBG_TRACE, ("<--- RxCommandPacketHandle819xUsb()\n"));
- return status;
-}
-
-void rtl8192_data_hard_stop(struct net_device *dev)
-{
- //FIXME !!
-}
-
-
-void rtl8192_data_hard_resume(struct net_device *dev)
-{
- // FIXME !!
-}
-
-/* this function TX data frames when the ieee80211 stack requires this.
- * It checks also if we need to stop the ieee tx queue, eventually do it
- */
-void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- int ret;
- unsigned long flags;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- u8 queue_index = tcb_desc->queue_index;
-
- /* shall not be referred by command packet */
- assert(queue_index != TXCMD_QUEUE);
-
- spin_lock_irqsave(&priv->tx_lock,flags);
-
- memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
-// tcb_desc->RATRIndex = 7;
-// tcb_desc->bTxDisableRateFallBack = 1;
-// tcb_desc->bTxUseDriverAssingedRate = 1;
- tcb_desc->bTxEnableFwCalcDur = 1;
- skb_push(skb, priv->ieee80211->tx_headroom);
- ret = priv->ops->rtl819x_tx(dev, skb);
-
- //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
- //priv->ieee80211->stats.tx_packets++;
-
- spin_unlock_irqrestore(&priv->tx_lock,flags);
-
-// return ret;
- return;
-}
-
-/* This is a rough attempt to TX a frame
- * This is called by the ieee 80211 stack to TX management frames.
- * If the ring is full packet are dropped (for data frame the queue
- * is stopped before this can happen).
- */
-int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- int ret;
- unsigned long flags;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- u8 queue_index = tcb_desc->queue_index;
-
-
- spin_lock_irqsave(&priv->tx_lock,flags);
-
- memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
- if(queue_index == TXCMD_QUEUE) {
- skb_push(skb, USB_HWDESC_HEADER_LEN);
- priv->ops->rtl819x_tx_cmd(dev, skb);
- ret = 1;
- spin_unlock_irqrestore(&priv->tx_lock,flags);
- return ret;
- } else {
- skb_push(skb, priv->ieee80211->tx_headroom);
- ret = priv->ops->rtl819x_tx(dev, skb);
- }
-
- spin_unlock_irqrestore(&priv->tx_lock,flags);
-
- return ret;
-}
-
-
-void rtl8192_try_wake_queue(struct net_device *dev, int pri);
-
-
-static void rtl8192_tx_isr(struct urb *tx_urb)
-{
- struct sk_buff *skb = (struct sk_buff*)tx_urb->context;
- struct net_device *dev = NULL;
- struct r8192_priv *priv = NULL;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- u8 queue_index = tcb_desc->queue_index;
-// bool bToSend0Byte;
-// u16 BufLen = skb->len;
-
- memcpy(&dev,(struct net_device*)(skb->cb),sizeof(struct net_device*));
- priv = ieee80211_priv(dev);
-
- if(tcb_desc->queue_index != TXCMD_QUEUE) {
- if(tx_urb->status == 0) {
- // dev->trans_start = jiffies;
- // As act as station mode, destion shall be unicast address.
- //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
- //priv->ieee80211->stats.tx_packets++;
- priv->stats.txoktotal++;
- priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++;
- priv->stats.txbytesunicast += (skb->len - priv->ieee80211->tx_headroom);
- } else {
- priv->ieee80211->stats.tx_errors++;
- //priv->stats.txmanageerr++;
- /* TODO */
- }
- }
-
- /* free skb and tx_urb */
- if(skb != NULL) {
- dev_kfree_skb_any(skb);
- usb_free_urb(tx_urb);
- atomic_dec(&priv->tx_pending[queue_index]);
- }
-
- {
- //
- // Handle HW Beacon:
- // We had transfer our beacon frame to host controler at this moment.
- //
- //
- // Caution:
- // Handling the wait queue of command packets.
- // For Tx command packets, we must not do TCB fragment because it is not handled right now.
- // We must cut the packets to match the size of TX_CMD_PKT before we send it.
- //
- if (queue_index == MGNT_QUEUE){
- if (priv->ieee80211->ack_tx_to_ieee){
- if (rtl8192_is_tx_queue_empty(dev)){
- priv->ieee80211->ack_tx_to_ieee = 0;
- ieee80211_ps_tx_ack(priv->ieee80211, 1);
- }
- }
- }
- /* Handle MPDU in wait queue. */
- if(queue_index != BEACON_QUEUE) {
- /* Don't send data frame during scanning.*/
- if((skb_queue_len(&priv->ieee80211->skb_waitQ[queue_index]) != 0)&&\
- (!(priv->ieee80211->queue_stop))) {
- if(NULL != (skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index]))))
- priv->ieee80211->softmac_hard_start_xmit(skb, dev);
-
- return; //modified by david to avoid further processing AMSDU
- }
- }
- }
-}
-
-void rtl8192_beacon_stop(struct net_device *dev)
-{
- u8 msr, msrm, msr2;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- msr = read_nic_byte(dev, MSR);
- msrm = msr & MSR_LINK_MASK;
- msr2 = msr & ~MSR_LINK_MASK;
-
- if(NIC_8192U == priv->card_8192) {
- usb_kill_urb(priv->rx_urb[MAX_RX_URB]);
- }
- if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
- (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
- write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
- write_nic_byte(dev, MSR, msr);
- }
-}
-
-void rtl8192_config_rate(struct net_device* dev, u16* rate_config)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_network *net;
- u8 i=0, basic_rate = 0;
- net = & priv->ieee80211->current_network;
-
- for (i=0; i<net->rates_len; i++)
- {
- basic_rate = net->rates[i]&0x7f;
- switch(basic_rate)
- {
- case MGN_1M: *rate_config |= RRSR_1M; break;
- case MGN_2M: *rate_config |= RRSR_2M; break;
- case MGN_5_5M: *rate_config |= RRSR_5_5M; break;
- case MGN_11M: *rate_config |= RRSR_11M; break;
- case MGN_6M: *rate_config |= RRSR_6M; break;
- case MGN_9M: *rate_config |= RRSR_9M; break;
- case MGN_12M: *rate_config |= RRSR_12M; break;
- case MGN_18M: *rate_config |= RRSR_18M; break;
- case MGN_24M: *rate_config |= RRSR_24M; break;
- case MGN_36M: *rate_config |= RRSR_36M; break;
- case MGN_48M: *rate_config |= RRSR_48M; break;
- case MGN_54M: *rate_config |= RRSR_54M; break;
- }
- }
- for (i=0; i<net->rates_ex_len; i++)
- {
- basic_rate = net->rates_ex[i]&0x7f;
- switch(basic_rate)
- {
- case MGN_1M: *rate_config |= RRSR_1M; break;
- case MGN_2M: *rate_config |= RRSR_2M; break;
- case MGN_5_5M: *rate_config |= RRSR_5_5M; break;
- case MGN_11M: *rate_config |= RRSR_11M; break;
- case MGN_6M: *rate_config |= RRSR_6M; break;
- case MGN_9M: *rate_config |= RRSR_9M; break;
- case MGN_12M: *rate_config |= RRSR_12M; break;
- case MGN_18M: *rate_config |= RRSR_18M; break;
- case MGN_24M: *rate_config |= RRSR_24M; break;
- case MGN_36M: *rate_config |= RRSR_36M; break;
- case MGN_48M: *rate_config |= RRSR_48M; break;
- case MGN_54M: *rate_config |= RRSR_54M; break;
- }
- }
-}
-
-
-#define SHORT_SLOT_TIME 9
-#define NON_SHORT_SLOT_TIME 20
-
-void rtl8192_update_cap(struct net_device* dev, u16 cap)
-{
- //u32 tmp = 0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_network *net = &priv->ieee80211->current_network;
- priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE;
-
- //LZM MOD 090303 HW_VAR_ACK_PREAMBLE
- if(0)
- {
- u8 tmp = 0;
- tmp = ((priv->nCur40MhzPrimeSC) << 5);
- if (priv->short_preamble)
- tmp |= 0x80;
- write_nic_byte(dev, RRSR+2, tmp);
- }
-
- if (net->mode & (IEEE_G|IEEE_N_24G))
- {
- u8 slot_time = 0;
- if ((cap & WLAN_CAPABILITY_SHORT_SLOT)&&(!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime))
- {//short slot time
- slot_time = SHORT_SLOT_TIME;
- }
- else //long slot time
- slot_time = NON_SHORT_SLOT_TIME;
- priv->slot_time = slot_time;
- write_nic_byte(dev, SLOT_TIME, slot_time);
- }
-
-}
-void rtl8192_net_update(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_network *net;
- u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
- u16 rate_config = 0;
- net = & priv->ieee80211->current_network;
-
- rtl8192_config_rate(dev, &rate_config);
- priv->basic_rate = rate_config &= 0x15f;
-
- write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]);
- write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]);
- //for(i=0;i<ETH_ALEN;i++)
- // write_nic_byte(dev,BSSID+i,net->bssid[i]);
-
- rtl8192_update_msr(dev);
-// rtl8192_update_cap(dev, net->capability);
- if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- {
- write_nic_word(dev, ATIMWND, 2);
- write_nic_word(dev, BCN_DMATIME, 1023);
- write_nic_word(dev, BCN_INTERVAL, net->beacon_interval);
-// write_nic_word(dev, BcnIntTime, 100);
- write_nic_word(dev, BCN_DRV_EARLY_INT, 1);
- write_nic_byte(dev, BCN_ERR_THRESH, 100);
- BcnTimeCfg |= (BcnCW<<BCN_TCFG_CW_SHIFT);
- // TODO: BcnIFS may required to be changed on ASIC
- BcnTimeCfg |= BcnIFS<<BCN_TCFG_IFS;
-
- write_nic_word(dev, BCN_TCFG, BcnTimeCfg);
- }
-
-
-
-}
-
-//temporary hw beacon is not used any more.
-//open it when necessary
-#if 1
-void rtl819xusb_beacon_tx(struct net_device *dev,u16 tx_rate)
-{
-}
-#endif
-inline u8 rtl8192_IsWirelessBMode(u16 rate)
-{
- if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
- return 1;
- else return 0;
-}
-
-u16 N_DBPSOfRate(u16 DataRate);
-
-u16 ComputeTxTime(
- u16 FrameLength,
- u16 DataRate,
- u8 bManagementFrame,
- u8 bShortPreamble
-)
-{
- u16 FrameTime;
- u16 N_DBPS;
- u16 Ceiling;
-
- if( rtl8192_IsWirelessBMode(DataRate) )
- {
- if( bManagementFrame || !bShortPreamble || DataRate == 10 )
- { // long preamble
- FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10)));
- }
- else
- { // Short preamble
- FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10)));
- }
- if( ( FrameLength*8 % (DataRate/10) ) != 0 ) //Get the Ceilling
- FrameTime ++;
- } else { //802.11g DSSS-OFDM PLCP length field calculation.
- N_DBPS = N_DBPSOfRate(DataRate);
- Ceiling = (16 + 8*FrameLength + 6) / N_DBPS
- + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0);
- FrameTime = (u16)(16 + 4 + 4*Ceiling + 6);
- }
- return FrameTime;
-}
-
-u16 N_DBPSOfRate(u16 DataRate)
-{
- u16 N_DBPS = 24;
-
- switch(DataRate)
- {
- case 60:
- N_DBPS = 24;
- break;
-
- case 90:
- N_DBPS = 36;
- break;
-
- case 120:
- N_DBPS = 48;
- break;
-
- case 180:
- N_DBPS = 72;
- break;
-
- case 240:
- N_DBPS = 96;
- break;
-
- case 360:
- N_DBPS = 144;
- break;
-
- case 480:
- N_DBPS = 192;
- break;
-
- case 540:
- N_DBPS = 216;
- break;
-
- default:
- break;
- }
-
- return N_DBPS;
-}
-
-void rtl819xU_cmd_isr(struct urb *tx_cmd_urb, struct pt_regs *regs)
-{
- usb_free_urb(tx_cmd_urb);
-}
-
-unsigned int txqueue2outpipe(struct r8192_priv* priv,unsigned int tx_queue) {
-
- if(tx_queue >= 9)
- {
- RT_TRACE(COMP_ERR,"%s():Unknown queue ID!!!\n",__FUNCTION__);
- return 0x04;
- }
- return priv->txqueue_to_outpipemap[tx_queue];
-}
-
-short rtl8192SU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int status;
- struct urb *tx_urb;
- unsigned int idx_pipe;
- tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data;
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- u8 queue_index = tcb_desc->queue_index;
- u32 PktSize = 0;
-
- //printk("\n %s::::::::::::::::::::::queue_index = %d\n",__FUNCTION__, queue_index);
- atomic_inc(&priv->tx_pending[queue_index]);
-
- tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
- if(!tx_urb){
- dev_kfree_skb(skb);
- return -ENOMEM;
- }
-
- memset(pdesc, 0, USB_HWDESC_HEADER_LEN);
-
- /* Tx descriptor ought to be set according to the skb->cb */
- pdesc->LINIP = tcb_desc->bLastIniPkt;
- PktSize = (u16)(skb->len - USB_HWDESC_HEADER_LEN);
- pdesc->PktSize = PktSize;
- //printk("PKTSize = %d %x\n",pdesc->PktSize,pdesc->PktSize);
- //----------------------------------------------------------------------------
- // Fill up USB_OUT_CONTEXT.
- //----------------------------------------------------------------------------
- // Get index to out pipe from specified QueueID.
- idx_pipe = txqueue2outpipe(priv,queue_index);
- //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,queue_index,priv->RtOutPipes[idx_pipe]);
-
- usb_fill_bulk_urb(tx_urb,
- priv->udev,
- usb_sndbulkpipe(priv->udev,priv->RtOutPipes[idx_pipe]),
- skb->data,
- skb->len,
- rtl8192_tx_isr,
- skb);
-
- status = usb_submit_urb(tx_urb, GFP_ATOMIC);
- if (!status){
- return 0;
- }else{
- printk("Error TX CMD URB, error %d",
- status);
- return -1;
- }
-}
-
-/*
- * Mapping Software/Hardware descriptor queue id to "Queue Select Field"
- * in TxFwInfo data structure
- * 2006.10.30 by Emily
- *
- * \param QUEUEID Software Queue
-*/
-u8 MapHwQueueToFirmwareQueue(u8 QueueID)
-{
- u8 QueueSelect = 0x0; //defualt set to
-
- switch(QueueID) {
- case BE_QUEUE:
- QueueSelect = QSLT_BE; //or QSelect = pTcb->priority;
- break;
-
- case BK_QUEUE:
- QueueSelect = QSLT_BK; //or QSelect = pTcb->priority;
- break;
-
- case VO_QUEUE:
- QueueSelect = QSLT_VO; //or QSelect = pTcb->priority;
- break;
-
- case VI_QUEUE:
- QueueSelect = QSLT_VI; //or QSelect = pTcb->priority;
- break;
- case MGNT_QUEUE:
- QueueSelect = QSLT_MGNT;
- break;
-
- case BEACON_QUEUE:
- QueueSelect = QSLT_BEACON;
- break;
-
- // TODO: 2006.10.30 mark other queue selection until we verify it is OK
- // TODO: Remove Assertions
-//#if (RTL819X_FPGA_VER & RTL819X_FPGA_GUANGAN_070502)
- case TXCMD_QUEUE:
- QueueSelect = QSLT_CMD;
- break;
-//#endif
- case HIGH_QUEUE:
- QueueSelect = QSLT_HIGH;
- break;
-
- default:
- RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID);
- break;
- }
- return QueueSelect;
-}
-
-u8 MRateToHwRate8190Pci(u8 rate)
-{
- u8 ret = DESC92S_RATE1M;
-
- switch(rate)
- {
- // CCK and OFDM non-HT rates
- case MGN_1M: ret = DESC92S_RATE1M; break;
- case MGN_2M: ret = DESC92S_RATE2M; break;
- case MGN_5_5M: ret = DESC92S_RATE5_5M; break;
- case MGN_11M: ret = DESC92S_RATE11M; break;
- case MGN_6M: ret = DESC92S_RATE6M; break;
- case MGN_9M: ret = DESC92S_RATE9M; break;
- case MGN_12M: ret = DESC92S_RATE12M; break;
- case MGN_18M: ret = DESC92S_RATE18M; break;
- case MGN_24M: ret = DESC92S_RATE24M; break;
- case MGN_36M: ret = DESC92S_RATE36M; break;
- case MGN_48M: ret = DESC92S_RATE48M; break;
- case MGN_54M: ret = DESC92S_RATE54M; break;
-
- // HT rates since here
- case MGN_MCS0: ret = DESC92S_RATEMCS0; break;
- case MGN_MCS1: ret = DESC92S_RATEMCS1; break;
- case MGN_MCS2: ret = DESC92S_RATEMCS2; break;
- case MGN_MCS3: ret = DESC92S_RATEMCS3; break;
- case MGN_MCS4: ret = DESC92S_RATEMCS4; break;
- case MGN_MCS5: ret = DESC92S_RATEMCS5; break;
- case MGN_MCS6: ret = DESC92S_RATEMCS6; break;
- case MGN_MCS7: ret = DESC92S_RATEMCS7; break;
- case MGN_MCS8: ret = DESC92S_RATEMCS8; break;
- case MGN_MCS9: ret = DESC92S_RATEMCS9; break;
- case MGN_MCS10: ret = DESC92S_RATEMCS10; break;
- case MGN_MCS11: ret = DESC92S_RATEMCS11; break;
- case MGN_MCS12: ret = DESC92S_RATEMCS12; break;
- case MGN_MCS13: ret = DESC92S_RATEMCS13; break;
- case MGN_MCS14: ret = DESC92S_RATEMCS14; break;
- case MGN_MCS15: ret = DESC92S_RATEMCS15; break;
-
- // Set the highest SG rate
- case MGN_MCS0_SG:
- case MGN_MCS1_SG:
- case MGN_MCS2_SG:
- case MGN_MCS3_SG:
- case MGN_MCS4_SG:
- case MGN_MCS5_SG:
- case MGN_MCS6_SG:
- case MGN_MCS7_SG:
- case MGN_MCS8_SG:
- case MGN_MCS9_SG:
- case MGN_MCS10_SG:
- case MGN_MCS11_SG:
- case MGN_MCS12_SG:
- case MGN_MCS13_SG:
- case MGN_MCS14_SG:
- case MGN_MCS15_SG:
- {
- ret = DESC92S_RATEMCS15_SG;
- break;
- }
-
- default: break;
- }
- return ret;
-}
-
-u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc)
-{
- u8 tmp_Short;
-
- tmp_Short = (TxHT==1)?((tcb_desc->bUseShortGI)?1:0):((tcb_desc->bUseShortPreamble)?1:0);
-
- if(TxHT==1 && TxRate != DESC90_RATEMCS15)
- tmp_Short = 0;
-
- return tmp_Short;
-}
-
-static void tx_zero_isr(struct urb *tx_urb)
-{
- return;
-}
-
-
-/*
- * The tx procedure is just as following, skb->cb will contain all the following
- *information: * priority, morefrag, rate, &dev.
- * */
- // <Note> Buffer format for 8192S Usb bulk out:
-//
-// --------------------------------------------------
-// | 8192S Usb Tx Desc | 802_11_MAC_header | data |
-// --------------------------------------------------
-// | 32 bytes | 24 bytes |0-2318 bytes|
-// --------------------------------------------------
-// |<------------ BufferLen ------------------------->|
-
-short rtl8192SU_tx(struct net_device *dev, struct sk_buff* skb)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data;
- struct usb_device *udev = priv->udev;
- int pend;
- int status;
- struct urb *tx_urb = NULL, *tx_urb_zero = NULL;
- unsigned int idx_pipe;
- u16 MPDUOverhead = 0;
- u16 type = 0;
-
- pend = atomic_read(&priv->tx_pending[tcb_desc->queue_index]);
- /* we are locked here so the two atomic_read and inc are executed
- * without interleaves * !!! For debug purpose */
- if( pend > MAX_TX_URB){
- switch (tcb_desc->queue_index) {
- case VO_PRIORITY:
- priv->stats.txvodrop++;
- break;
- case VI_PRIORITY:
- priv->stats.txvidrop++;
- break;
- case BE_PRIORITY:
- priv->stats.txbedrop++;
- break;
- default://BK_PRIORITY
- priv->stats.txbkdrop++;
- break;
- }
- printk("To discard skb packet!\n");
- dev_kfree_skb_any(skb);
- return -1;
- }
-
- tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
- if(!tx_urb){
- dev_kfree_skb_any(skb);
- return -ENOMEM;
- }
-
- memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
-
-
- tx_desc->NonQos = (IsQoSDataFrame(skb->data)==TRUE)? 0:1;
-
- /* Fill Tx descriptor */
- //memset(tx_fwinfo,0,sizeof(tx_fwinfo_819x_usb));
-
- // This part can just fill to the first descriptor of the frame.
- /* DWORD 0 */
- tx_desc->TxHT = (tcb_desc->data_rate&0x80)?1:0;
-
-
- tx_desc->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate);
- //tx_desc->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
- tx_desc->TxShort = QueryIsShort(tx_desc->TxHT, tx_desc->TxRate, tcb_desc);
-
-
- // Aggregation related
- if(tcb_desc->bAMPDUEnable) {//AMPDU enabled
- tx_desc->AllowAggregation = 1;
- /* DWORD 1 */
- //tx_fwinfo->RxMF = tcb_desc->ampdu_factor;
- //tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity
- } else {
- tx_desc->AllowAggregation = 0;
- /* DWORD 1 */
- //tx_fwinfo->RxMF = 0;
- //tx_fwinfo->RxAMD = 0;
- }
-
- //
- // <Roger_Notes> For AMPDU case, we must insert SSN into TX_DESC,
- // FW according as this SSN to do necessary packet retry.
- // 2008.06.06.
- //
- {
- u8 *pSeq;
- u16 Temp;
- //pSeq = (u8 *)(VirtualAddress+USB_HWDESC_HEADER_LEN + FRAME_OFFSET_SEQUENCE);
- pSeq = (u8 *)(skb->data+USB_HWDESC_HEADER_LEN + 22);
- Temp = pSeq[0];
- Temp <<= 12;
- Temp |= (*(u16 *)pSeq)>>4;
- tx_desc->Seq = Temp;
- }
-
- /* Protection mode related */
- tx_desc->RTSEn = (tcb_desc->bRTSEnable)?1:0;
- tx_desc->CTS2Self = (tcb_desc->bCTSEnable)?1:0;
- tx_desc->RTSSTBC = (tcb_desc->bRTSSTBC)?1:0;
- tx_desc->RTSHT = (tcb_desc->rts_rate&0x80)?1:0;
- tx_desc->RTSRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate);
- tx_desc->RTSSubcarrier = (tx_desc->RTSHT==0)?(tcb_desc->RTSSC):0;
- tx_desc->RTSBW = (tx_desc->RTSHT==1)?((tcb_desc->bRTSBW)?1:0):0;
- tx_desc->RTSShort = (tx_desc->RTSHT==0)?(tcb_desc->bRTSUseShortPreamble?1:0):\
- (tcb_desc->bRTSUseShortGI?1:0);
- //LZM 090219
- tx_desc->DisRTSFB = 0;
- tx_desc->RTSRateFBLmt = 0xf;
-
- // <Roger_EXP> 2008.09.22. We disable RTS rate fallback temporarily.
- //tx_desc->DisRTSFB = 0x01;
-
- /* Set Bandwidth and sub-channel settings. */
- if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40)
- {
- if(tcb_desc->bPacketBW) {
- tx_desc->TxBandwidth = 1;
- tx_desc->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode
- } else {
- tx_desc->TxBandwidth = 0;
- tx_desc->TxSubCarrier = priv->nCur40MhzPrimeSC;
- }
- } else {
- tx_desc->TxBandwidth = 0;
- tx_desc->TxSubCarrier = 0;
- }
-
-
- //memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
- /* DWORD 0 */
- tx_desc->LINIP = 0;
- //tx_desc->CmdInit = 1; //92su del
- tx_desc->Offset = USB_HWDESC_HEADER_LEN;
-
- {
- tx_desc->PktSize = (skb->len - USB_HWDESC_HEADER_LEN) & 0xffff;
- }
-
- /*DWORD 1*/
- //tx_desc->SecCAMID= 0;//92su del
- tx_desc->RaBRSRID= tcb_desc->RATRIndex;
-//#ifdef RTL8192S_PREPARE_FOR_NORMAL_RELEASE
-
- {
- MPDUOverhead = 0;
- //tx_desc->NoEnc = 1;//92su del
- }
-
- tx_desc->SecType = 0x0;
-
- if (tcb_desc->bHwSec)
- {
- switch (priv->ieee80211->pairwise_key_type)
- {
- case KEY_TYPE_WEP40:
- case KEY_TYPE_WEP104:
- tx_desc->SecType = 0x1;
- //tx_desc->NoEnc = 0;//92su del
- break;
- case KEY_TYPE_TKIP:
- tx_desc->SecType = 0x2;
- //tx_desc->NoEnc = 0;//92su del
- break;
- case KEY_TYPE_CCMP:
- tx_desc->SecType = 0x3;
- //tx_desc->NoEnc = 0;//92su del
- break;
- case KEY_TYPE_NA:
- tx_desc->SecType = 0x0;
- //tx_desc->NoEnc = 1;//92su del
- break;
- default:
- tx_desc->SecType = 0x0;
- //tx_desc->NoEnc = 1;//92su del
- break;
- }
- }
-
- //tx_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb);//92su del
-
-
- tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate;
- tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack;
- tx_desc->DataRateFBLmt = 0x1F;// Alwasy enable all rate fallback range
-
- tx_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index);
-
-
- /* Fill fields that are required to be initialized in all of the descriptors */
- //DWORD 0
- tx_desc->FirstSeg = 1;
- tx_desc->LastSeg = 1;
- tx_desc->OWN = 1;
-
- {
- //DWORD 2
- //tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN);
- tx_desc->TxBufferSize = (u32)(skb->len);//92su mod FIXLZM
- }
-
- /* Get index to out pipe from specified QueueID */
- idx_pipe = txqueue2outpipe(priv,tcb_desc->queue_index);
- //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,tcb_desc->queue_index,priv->RtOutPipes[idx_pipe]);
-
- //RT_DEBUG_DATA(COMP_SEND,tx_fwinfo,sizeof(tx_fwinfo_819x_usb));
- //RT_DEBUG_DATA(COMP_SEND,tx_desc,sizeof(tx_desc_819x_usb));
-
- /* To submit bulk urb */
- usb_fill_bulk_urb(tx_urb,
- udev,
- usb_sndbulkpipe(udev,priv->RtOutPipes[idx_pipe]),
- skb->data,
- skb->len, rtl8192_tx_isr, skb);
-
- if (type == IEEE80211_FTYPE_DATA) {
- if (priv->ieee80211->LedControlHandler != NULL)
- priv->ieee80211->LedControlHandler(dev, LED_CTL_TX);
- }
-
- status = usb_submit_urb(tx_urb, GFP_ATOMIC);
- if (!status) {
- /*
- * we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted.
- * Otherwise, it will be halt to wait for another packet. WB. 2008.08.27
- */
- bool bSend0Byte = false;
- u8 zero = 0;
- if(udev->speed == USB_SPEED_HIGH) {
- if (skb->len > 0 && skb->len % 512 == 0)
- bSend0Byte = true;
- }
- else {
- if (skb->len > 0 && skb->len % 64 == 0)
- bSend0Byte = true;
- }
- if (bSend0Byte) {
- tx_urb_zero = usb_alloc_urb(0,GFP_ATOMIC);
- if(!tx_urb_zero) {
- RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n");
- return -ENOMEM;
- }
- usb_fill_bulk_urb(tx_urb_zero,udev,
- usb_sndbulkpipe(udev,idx_pipe), &zero,
- 0, tx_zero_isr, dev);
- status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC);
- switch (status) {
- case 0:
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- break;
- default:
- RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d",
- atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status);
- return -1;
- }
- }
- dev->trans_start = jiffies;
- atomic_inc(&priv->tx_pending[tcb_desc->queue_index]);
- return 0;
- } else {
- RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
- status);
- return -1;
- }
-}
-
-void rtl8192SU_net_update(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- struct ieee80211_network *net = &priv->ieee80211->current_network;
- //u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
- u16 rate_config = 0;
- u32 regTmp = 0;
- u8 rateIndex = 0;
- u8 retrylimit = 0x30;
- u16 cap = net->capability;
-
- priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE;
-
-//HW_VAR_BASIC_RATE
- //update Basic rate: RR, BRSR
- rtl8192_config_rate(dev, &rate_config); //HalSetBrateCfg
-
- priv->basic_rate = rate_config = rate_config & 0x15f;
-
- // Set RRSR rate table.
- write_nic_byte(dev, RRSR, rate_config&0xff);
- write_nic_byte(dev, RRSR+1, (rate_config>>8)&0xff);
-
- // Set RTS initial rate
- while(rate_config > 0x1)
- {
- rate_config = (rate_config>> 1);
- rateIndex++;
- }
- write_nic_byte(dev, INIRTSMCS_SEL, rateIndex);
-//HW_VAR_BASIC_RATE
-
- //set ack preample
- regTmp = (priv->nCur40MhzPrimeSC) << 5;
- if (priv->short_preamble)
- regTmp |= 0x80;
- write_nic_byte(dev, RRSR+2, regTmp);
-
- write_nic_dword(dev,BSSIDR,((u32*)net->bssid)[0]);
- write_nic_word(dev,BSSIDR+4,((u16*)net->bssid)[2]);
-
- write_nic_word(dev, BCN_INTERVAL, net->beacon_interval);
- //2008.10.24 added by tynli for beacon changed.
- PHY_SetBeaconHwReg( dev, net->beacon_interval);
-
- rtl8192_update_cap(dev, cap);
-
- if (ieee->iw_mode == IW_MODE_ADHOC){
- retrylimit = 7;
- //we should enable ibss interrupt here, but disable it temporarily
- if (0){
- priv->irq_mask |= (IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
- //rtl8192_irq_disable(dev);
- //rtl8192_irq_enable(dev);
- }
- }
- else{
- if (0){
- priv->irq_mask &= ~(IMR_BcnInt | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
- //rtl8192_irq_disable(dev);
- //rtl8192_irq_enable(dev);
- }
- }
-
- priv->ShortRetryLimit = priv->LongRetryLimit = retrylimit;
-
- write_nic_word(dev, RETRY_LIMIT,
- retrylimit << RETRY_LIMIT_SHORT_SHIFT | \
- retrylimit << RETRY_LIMIT_LONG_SHIFT);
-}
-
-void rtl8192SU_update_ratr_table(struct net_device* dev)
-{
- struct r8192_priv* priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- u8* pMcsRate = ieee->dot11HTOperationalRateSet;
- //struct ieee80211_network *net = &ieee->current_network;
- u32 ratr_value = 0;
-
- u8 rate_index = 0;
- int WirelessMode = ieee->mode;
- u8 MimoPs = ieee->pHTInfo->PeerMimoPs;
-
- u8 bNMode = 0;
-
- rtl8192_config_rate(dev, (u16*)(&ratr_value));
- ratr_value |= (*(u16*)(pMcsRate)) << 12;
-
- //switch (ieee->mode)
- switch (WirelessMode)
- {
- case IEEE_A:
- ratr_value &= 0x00000FF0;
- break;
- case IEEE_B:
- ratr_value &= 0x0000000D;
- break;
- case IEEE_G:
- ratr_value &= 0x00000FF5;
- break;
- case IEEE_N_24G:
- case IEEE_N_5G:
- {
- bNMode = 1;
-
- if (MimoPs == 0) //MIMO_PS_STATIC
- {
- ratr_value &= 0x0007F005;
- }
- else
- { // MCS rate only => for 11N mode.
- u32 ratr_mask;
-
- // 1T2R or 1T1R, Spatial Stream 2 should be disabled
- if ( priv->rf_type == RF_1T2R ||
- priv->rf_type == RF_1T1R ||
- (ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_TX_2SS) )
- ratr_mask = 0x000ff005;
- else
- ratr_mask = 0x0f0ff005;
-
- if((ieee->pHTInfo->bCurTxBW40MHz) &&
- !(ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_TX_40_MHZ))
- ratr_mask |= 0x00000010; // Set 6MBps
-
- // Select rates for rate adaptive mechanism.
- ratr_value &= ratr_mask;
- }
- }
- break;
- default:
- if(0)
- {
- if(priv->rf_type == RF_1T2R) // 1T2R, Spatial Stream 2 should be disabled
- {
- ratr_value &= 0x000ff0f5;
- }
- else
- {
- ratr_value &= 0x0f0ff0f5;
- }
- }
- //printk("====>%s(), mode is not correct:%x\n", __FUNCTION__, ieee->mode);
- break;
- }
-
- ratr_value &= 0x0FFFFFFF;
-
- // Get MAX MCS available.
- if ( (bNMode && ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_SHORT_GI)==0)) &&
- ((ieee->pHTInfo->bCurBW40MHz && ieee->pHTInfo->bCurShortGI40MHz) ||
- (!ieee->pHTInfo->bCurBW40MHz && ieee->pHTInfo->bCurShortGI20MHz)))
- {
- u8 shortGI_rate = 0;
- u32 tmp_ratr_value = 0;
- ratr_value |= 0x10000000;//???
- tmp_ratr_value = (ratr_value>>12);
- for(shortGI_rate=15; shortGI_rate>0; shortGI_rate--)
- {
- if((1<<shortGI_rate) & tmp_ratr_value)
- break;
- }
- shortGI_rate = (shortGI_rate<<12)|(shortGI_rate<<8)|(shortGI_rate<<4)|(shortGI_rate);
- write_nic_byte(dev, SG_RATE, shortGI_rate);
- //printk("==>SG_RATE:%x\n", read_nic_byte(dev, SG_RATE));
- }
- write_nic_dword(dev, ARFR0+rate_index*4, ratr_value);
- printk("=============>ARFR0+rate_index*4:%#x\n", ratr_value);
-
- //2 UFWP
- if (ratr_value & 0xfffff000){
- //printk("===>set to N mode\n");
- HalSetFwCmd8192S(dev, FW_CMD_RA_REFRESH_N);
- }
- else {
- //printk("===>set to B/G mode\n");
- HalSetFwCmd8192S(dev, FW_CMD_RA_REFRESH_BG);
- }
-}
-
-void rtl8192SU_link_change(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
- u32 reg = 0;
-
- reg = read_nic_dword(dev, RCR);
- if (ieee->state == IEEE80211_LINKED) {
- rtl8192SU_net_update(dev);
- rtl8192SU_update_ratr_table(dev);
- ieee->SetFwCmdHandler(dev, FW_CMD_HIGH_PWR_ENABLE);
- priv->ReceiveConfig = reg |= RCR_CBSSID;
-
- } else
- priv->ReceiveConfig = reg &= ~RCR_CBSSID;
- write_nic_dword(dev, RCR, reg);
- rtl8192_update_msr(dev);
-}
-
-static struct ieee80211_qos_parameters def_qos_parameters = {
- {3,3,3,3},/* cw_min */
- {7,7,7,7},/* cw_max */
- {2,2,2,2},/* aifs */
- {0,0,0,0},/* flags */
- {0,0,0,0} /* tx_op_limit */
-};
-
-
-void rtl8192_update_beacon(struct work_struct * work)
-{
- struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
- struct net_device *dev = priv->ieee80211->dev;
- struct ieee80211_device* ieee = priv->ieee80211;
- struct ieee80211_network* net = &ieee->current_network;
-
- if (ieee->pHTInfo->bCurrentHTSupport)
- HTUpdateSelfAndPeerSetting(ieee, net);
- ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime;
- // Joseph test for turbo mode with AP
- ieee->pHTInfo->RT2RT_HT_Mode = net->bssht.RT2RT_HT_Mode;
- rtl8192_update_cap(dev, net->capability);
-}
-/*
-* background support to run QoS activate functionality
-*/
-int WDCAPARA_ADD[] = {EDCAPARA_BE,EDCAPARA_BK,EDCAPARA_VI,EDCAPARA_VO};
-
-void rtl8192_qos_activate(struct work_struct * work)
-{
- struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate);
- struct net_device *dev = priv->ieee80211->dev;
- struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
- u8 mode = priv->ieee80211->current_network.mode;
- //u32 size = sizeof(struct ieee80211_qos_parameters);
- u8 u1bAIFS;
- u32 u4bAcParam;
- int i;
-
- if (priv == NULL)
- return;
-
- mutex_lock(&priv->mutex);
-
- if(priv->ieee80211->state != IEEE80211_LINKED)
- goto success;
- RT_TRACE(COMP_QOS,"qos active process with associate response received\n");
- /* It better set slot time at first */
- /* For we just support b/g mode at present, let the slot time at 9/20 selection */
- /* update the ac parameter to related registers */
- for(i = 0; i < QOS_QUEUE_NUM; i++) {
- //Mode G/A: slotTimeTimer = 9; Mode B: 20
- u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime;
- u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[i]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
- (((u32)(qos_parameters->cw_max[i]))<< AC_PARAM_ECW_MAX_OFFSET)|
- (((u32)(qos_parameters->cw_min[i]))<< AC_PARAM_ECW_MIN_OFFSET)|
- ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
-
- write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);
- //write_nic_dword(dev, WDCAPARA_ADD[i], 0x005e4322);
- }
-
-success:
- mutex_unlock(&priv->mutex);
-}
-
-static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
- int active_network,
- struct ieee80211_network *network)
-{
- int ret = 0;
- u32 size = sizeof(struct ieee80211_qos_parameters);
-
- if(priv->ieee80211->state !=IEEE80211_LINKED)
- return ret;
-
- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA))
- return ret;
-
- if (network->flags & NETWORK_HAS_QOS_MASK) {
- if (active_network &&
- (network->flags & NETWORK_HAS_QOS_PARAMETERS))
- network->qos_data.active = network->qos_data.supported;
-
- if ((network->qos_data.active == 1) && (active_network == 1) &&
- (network->flags & NETWORK_HAS_QOS_PARAMETERS) &&
- (network->qos_data.old_param_count !=
- network->qos_data.param_count)) {
- network->qos_data.old_param_count =
- network->qos_data.param_count;
- queue_work(priv->priv_wq, &priv->qos_activate);
- RT_TRACE (COMP_QOS, "QoS parameters change call "
- "qos_activate\n");
- }
- } else {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
- &def_qos_parameters, size);
-
- if ((network->qos_data.active == 1) && (active_network == 1)) {
- queue_work(priv->priv_wq, &priv->qos_activate);
- RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n");
- }
- network->qos_data.active = 0;
- network->qos_data.supported = 0;
- }
-
- return 0;
-}
-
-/* handle manage frame frame beacon and probe response */
-static int rtl8192_handle_beacon(struct net_device * dev,
- struct ieee80211_probe_response *beacon,
- struct ieee80211_network *network)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- rtl8192_qos_handle_probe_response(priv,1,network);
- queue_delayed_work(priv->priv_wq, &priv->update_beacon_wq, 0);
-
- return 0;
-
-}
-
-/*
-* handling the beaconing responses. if we get different QoS setting
-* off the network from the associated setting, adjust the QoS
-* setting
-*/
-static int rtl8192_qos_association_resp(struct r8192_priv *priv,
- struct ieee80211_network *network)
-{
- int ret = 0;
- unsigned long flags;
- u32 size = sizeof(struct ieee80211_qos_parameters);
- int set_qos_param = 0;
-
- if ((priv == NULL) || (network == NULL))
- return ret;
-
- if(priv->ieee80211->state !=IEEE80211_LINKED)
- return ret;
-
- if ((priv->ieee80211->iw_mode != IW_MODE_INFRA))
- return ret;
-
- spin_lock_irqsave(&priv->ieee80211->lock, flags);
- if(network->flags & NETWORK_HAS_QOS_PARAMETERS) {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
- &network->qos_data.parameters,\
- sizeof(struct ieee80211_qos_parameters));
- priv->ieee80211->current_network.qos_data.active = 1;
- {
- set_qos_param = 1;
- /* update qos parameter for current network */
- priv->ieee80211->current_network.qos_data.old_param_count = \
- priv->ieee80211->current_network.qos_data.param_count;
- priv->ieee80211->current_network.qos_data.param_count = \
- network->qos_data.param_count;
- }
- } else {
- memcpy(&priv->ieee80211->current_network.qos_data.parameters,\
- &def_qos_parameters, size);
- priv->ieee80211->current_network.qos_data.active = 0;
- priv->ieee80211->current_network.qos_data.supported = 0;
- set_qos_param = 1;
- }
-
- spin_unlock_irqrestore(&priv->ieee80211->lock, flags);
-
- RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n",__FUNCTION__,network->flags ,priv->ieee80211->current_network.qos_data.active);
- if (set_qos_param == 1)
- queue_work(priv->priv_wq, &priv->qos_activate);
-
- return ret;
-}
-
-
-static int rtl8192_handle_assoc_response(struct net_device *dev,
- struct ieee80211_assoc_response_frame *resp,
- struct ieee80211_network *network)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- rtl8192_qos_association_resp(priv, network);
- return 0;
-}
-
-
-void rtl8192_update_ratr_table(struct net_device* dev)
- // POCTET_STRING posLegacyRate,
- // u8* pMcsRate)
- // PRT_WLAN_STA pEntry)
-{
- struct r8192_priv* priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- u8* pMcsRate = ieee->dot11HTOperationalRateSet;
- //struct ieee80211_network *net = &ieee->current_network;
- u32 ratr_value = 0;
- u8 rate_index = 0;
- rtl8192_config_rate(dev, (u16*)(&ratr_value));
- ratr_value |= (*(u16*)(pMcsRate)) << 12;
-// switch (net->mode)
- switch (ieee->mode)
- {
- case IEEE_A:
- ratr_value &= 0x00000FF0;
- break;
- case IEEE_B:
- ratr_value &= 0x0000000F;
- break;
- case IEEE_G:
- ratr_value &= 0x00000FF7;
- break;
- case IEEE_N_24G:
- case IEEE_N_5G:
- if (ieee->pHTInfo->PeerMimoPs == 0) //MIMO_PS_STATIC
- ratr_value &= 0x0007F007;
- else{
- if (priv->rf_type == RF_1T2R)
- ratr_value &= 0x000FF007;
- else
- ratr_value &= 0x0F81F007;
- }
- break;
- default:
- break;
- }
- ratr_value &= 0x0FFFFFFF;
- if(ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz){
- ratr_value |= 0x80000000;
- }else if(!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz){
- ratr_value |= 0x80000000;
- }
- write_nic_dword(dev, RATR0+rate_index*4, ratr_value);
- write_nic_byte(dev, UFWP, 1);
-}
-
-static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04};
-static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
-bool GetNmodeSupportBySecCfg8192(struct net_device*dev)
-{
-#if 1
- struct r8192_priv* priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- struct ieee80211_network * network = &ieee->current_network;
- int wpa_ie_len= ieee->wpa_ie_len;
- struct ieee80211_crypt_data* crypt;
- int encrypt;
- return TRUE;
-
- crypt = ieee->crypt[ieee->tx_keyidx];
- //we use connecting AP's capability instead of only security config on our driver to distinguish whether it should use N mode or G mode
- encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || (ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name,"WEP")));
-
- /* simply judge */
- if(encrypt && (wpa_ie_len == 0)) {
- /* wep encryption, no N mode setting */
- return false;
-// } else if((wpa_ie_len != 0)&&(memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) {
- } else if((wpa_ie_len != 0)) {
- /* parse pairwise key type */
- //if((pairwisekey = WEP40)||(pairwisekey = WEP104)||(pairwisekey = TKIP))
- if (((ieee->wpa_ie[0] == 0xdd) && (!memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) || ((ieee->wpa_ie[0] == 0x30) && (!memcmp(&ieee->wpa_ie[10],ccmp_rsn_ie, 4))))
- return true;
- else
- return false;
- } else {
- return true;
- }
-
- return true;
-#endif
-}
-
-bool GetHalfNmodeSupportByAPs819xUsb(struct net_device* dev)
-{
- bool Reval;
- struct r8192_priv* priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
-
-// Added by Roger, 2008.08.29.
- return false;
-
- if(ieee->bHalfWirelessN24GMode == true)
- Reval = true;
- else
- Reval = false;
-
- return Reval;
-}
-
-void rtl8192_refresh_supportrate(struct r8192_priv* priv)
-{
- struct ieee80211_device* ieee = priv->ieee80211;
- //we donot consider set support rate for ABG mode, only HT MCS rate is set here.
- if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G)
- {
- memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
- //RT_DEBUG_DATA(COMP_INIT, ieee->RegHTSuppRateSet, 16);
- //RT_DEBUG_DATA(COMP_INIT, ieee->Regdot11HTOperationalRateSet, 16);
- }
- else
- memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
- return;
-}
-
-u8 rtl8192_getSupportedWireleeMode(struct net_device*dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 ret = 0;
- switch(priv->rf_chip)
- {
- case RF_8225:
- case RF_8256:
- case RF_PSEUDO_11N:
- case RF_6052:
- ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B);
- break;
- case RF_8258:
- ret = (WIRELESS_MODE_A|WIRELESS_MODE_N_5G);
- break;
- default:
- ret = WIRELESS_MODE_B;
- break;
- }
- return ret;
-}
-void rtl8192_SetWirelessMode(struct net_device* dev, u8 wireless_mode)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev);
-
-#if 1
- if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode)==0))
- {
- if(bSupportMode & WIRELESS_MODE_N_24G)
- {
- wireless_mode = WIRELESS_MODE_N_24G;
- }
- else if(bSupportMode & WIRELESS_MODE_N_5G)
- {
- wireless_mode = WIRELESS_MODE_N_5G;
- }
- else if((bSupportMode & WIRELESS_MODE_A))
- {
- wireless_mode = WIRELESS_MODE_A;
- }
- else if((bSupportMode & WIRELESS_MODE_G))
- {
- wireless_mode = WIRELESS_MODE_G;
- }
- else if((bSupportMode & WIRELESS_MODE_B))
- {
- wireless_mode = WIRELESS_MODE_B;
- }
- else{
- RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__,bSupportMode);
- wireless_mode = WIRELESS_MODE_B;
- }
- }
-#ifdef TO_DO_LIST //// TODO: this function doesn't work well at this time, we should wait for FPGA
- ActUpdateChannelAccessSetting( pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting );
-#endif
- //LZM 090306 usb crash here, mark it temp
- //write_nic_word(dev, SIFS_OFDM, 0x0e0e);
- priv->ieee80211->mode = wireless_mode;
-
- if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G))
- priv->ieee80211->pHTInfo->bEnableHT = 1;
- else
- priv->ieee80211->pHTInfo->bEnableHT = 0;
- RT_TRACE(COMP_INIT, "Current Wireless Mode is %x\n", wireless_mode);
- rtl8192_refresh_supportrate(priv);
-#endif
-
-}
-
-
-short rtl8192_is_tx_queue_empty(struct net_device *dev)
-{
- int i=0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- //struct ieee80211_device* ieee = priv->ieee80211;
- for (i=0; i<=MGNT_QUEUE; i++)
- {
- if ((i== TXCMD_QUEUE) || (i == HCCA_QUEUE) )
- continue;
- if (atomic_read(&priv->tx_pending[i]))
- {
- printk("===>tx queue is not empty:%d, %d\n", i, atomic_read(&priv->tx_pending[i]));
- return 0;
- }
- }
- return 1;
-}
-
-void rtl8192_hw_sleep_down(struct net_device *dev)
-{
- RT_TRACE(COMP_POWER, "%s()============>come to sleep down\n", __FUNCTION__);
-#ifdef TODO
-// MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
-#endif
-}
-
-void rtl8192_hw_sleep_wq (struct work_struct *work)
-{
-// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
-// struct ieee80211_device * ieee = (struct ieee80211_device*)
-// container_of(work, struct ieee80211_device, watch_dog_wq);
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);
- struct net_device *dev = ieee->dev;
-
- //printk("=========>%s()\n", __FUNCTION__);
- rtl8192_hw_sleep_down(dev);
-}
-// printk("dev is %d\n",dev);
-// printk("&*&(^*(&(&=========>%s()\n", __FUNCTION__);
-void rtl8192_hw_wakeup(struct net_device* dev)
-{
-// u32 flags = 0;
-
-// spin_lock_irqsave(&priv->ps_lock,flags);
- RT_TRACE(COMP_POWER, "%s()============>come to wake up\n", __FUNCTION__);
-#ifdef TODO
-// MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
-#endif
- //FIXME: will we send package stored while nic is sleep?
-// spin_unlock_irqrestore(&priv->ps_lock,flags);
-}
-
-void rtl8192_hw_wakeup_wq (struct work_struct *work)
-{
-// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
-// struct ieee80211_device * ieee = (struct ieee80211_device*)
-// container_of(work, struct ieee80211_device, watch_dog_wq);
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);
- struct net_device *dev = ieee->dev;
-
- rtl8192_hw_wakeup(dev);
-}
-
-#define MIN_SLEEP_TIME 50
-#define MAX_SLEEP_TIME 10000
-void rtl8192_hw_to_sleep(struct net_device *dev, u32 th, u32 tl)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- u32 rb = jiffies;
- unsigned long flags;
-
- spin_lock_irqsave(&priv->ps_lock,flags);
-
- /* Writing HW register with 0 equals to disable
- * the timer, that is not really what we want
- */
- tl -= MSECS(4+16+7);
-
- //if(tl == 0) tl = 1;
-
- /* FIXME HACK FIXME HACK */
-// force_pci_posting(dev);
- //mdelay(1);
-
-// rb = read_nic_dword(dev, TSFTR);
-
- /* If the interval in witch we are requested to sleep is too
- * short then give up and remain awake
- */
- if(((tl>=rb)&& (tl-rb) <= MSECS(MIN_SLEEP_TIME))
- ||((rb>tl)&& (rb-tl) < MSECS(MIN_SLEEP_TIME))) {
- spin_unlock_irqrestore(&priv->ps_lock,flags);
- printk("too short to sleep\n");
- return;
- }
-
-// write_nic_dword(dev, TimerInt, tl);
-// rb = read_nic_dword(dev, TSFTR);
- {
- u32 tmp = (tl>rb)?(tl-rb):(rb-tl);
- // if (tl<rb)
-
- queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); //as tl may be less than rb
- }
- /* if we suspect the TimerInt is gone beyond tl
- * while setting it, then give up
- */
-#if 1
- if(((tl > rb) && ((tl-rb) > MSECS(MAX_SLEEP_TIME)))||
- ((tl < rb) && ((rb-tl) > MSECS(MAX_SLEEP_TIME)))) {
- printk("========>too long to sleep:%x, %x, %lx\n", tl, rb, MSECS(MAX_SLEEP_TIME));
- spin_unlock_irqrestore(&priv->ps_lock,flags);
- return;
- }
-#endif
-// if(priv->rf_sleep)
-// priv->rf_sleep(dev);
-
- //printk("<=========%s()\n", __FUNCTION__);
- queue_delayed_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_sleep_wq,0);
-
- spin_unlock_irqrestore(&priv->ps_lock,flags);
-}
-//init priv variables here. only non_zero value should be initialized here.
-static void rtl8192_init_priv_variable(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 i;
- priv->card_8192 = NIC_8192U;
- priv->chan = 1; //set to channel 1
- priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO
- priv->ieee80211->iw_mode = IW_MODE_INFRA;
- priv->ieee80211->ieee_up=0;
- priv->retry_rts = DEFAULT_RETRY_RTS;
- priv->retry_data = DEFAULT_RETRY_DATA;
- priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD;
- priv->ieee80211->rate = 110; //11 mbps
- priv->ieee80211->short_slot = 1;
- priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
- priv->CckPwEnl = 6;
- //for silent reset
- priv->IrpPendingCount = 1;
- priv->ResetProgress = RESET_TYPE_NORESET;
- priv->bForcedSilentReset = 0;
- priv->bDisableNormalResetCheck = false;
- priv->force_reset = false;
-
- priv->ieee80211->FwRWRF = 0; //we don't use FW read/write RF until stable firmware is available.
- priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
- priv->ieee80211->iw_mode = IW_MODE_INFRA;
- priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
- IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
- IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
- IEEE_SOFTMAC_BEACONS;//added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE;
-
- priv->ieee80211->active_scan = 1;
- priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
- priv->ieee80211->host_encrypt = 1;
- priv->ieee80211->host_decrypt = 1;
- priv->ieee80211->start_send_beacons = NULL;//rtl819xusb_beacon_tx;//-by amy 080604
- priv->ieee80211->stop_send_beacons = NULL;//rtl8192_beacon_stop;//-by amy 080604
- priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit;
- priv->ieee80211->set_chan = rtl8192_set_chan;
- priv->ieee80211->link_change = priv->ops->rtl819x_link_change;
- priv->ieee80211->softmac_data_hard_start_xmit = rtl8192_hard_data_xmit;
- priv->ieee80211->data_hard_stop = rtl8192_data_hard_stop;
- priv->ieee80211->data_hard_resume = rtl8192_data_hard_resume;
- priv->ieee80211->init_wmmparam_flag = 0;
- priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
- priv->ieee80211->check_nic_enough_desc = check_nic_enough_desc;
- priv->ieee80211->tx_headroom = TX_PACKET_SHIFT_BYTES;
- priv->ieee80211->qos_support = 1;
-
- //added by WB
-// priv->ieee80211->SwChnlByTimerHandler = rtl8192_phy_SwChnl;
- priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode;
- priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response;
- priv->ieee80211->handle_beacon = rtl8192_handle_beacon;
- //for LPS
- priv->ieee80211->sta_wake_up = rtl8192_hw_wakeup;
-// priv->ieee80211->ps_request_tx_ack = rtl8192_rq_tx_ack;
- priv->ieee80211->enter_sleep_state = rtl8192_hw_to_sleep;
- priv->ieee80211->ps_is_queue_empty = rtl8192_is_tx_queue_empty;
- //added by david
- priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8192;
- priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xUsb;
- priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode;
- //added by amy
- priv->ieee80211->InitialGainHandler = priv->ops->rtl819x_initial_gain;
- priv->card_type = USB;
-
-//1 RTL8192SU/
- priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
- priv->ieee80211->SetFwCmdHandler = HalSetFwCmd8192S;
- priv->bRFSiOrPi = 0;//o=si,1=pi;
- //lzm add
- priv->bInHctTest = false;
-
- priv->MidHighPwrTHR_L1 = 0x3B;
- priv->MidHighPwrTHR_L2 = 0x40;
-
- if(priv->bInHctTest)
- {
- priv->ShortRetryLimit = HAL_RETRY_LIMIT_AP_ADHOC;
- priv->LongRetryLimit = HAL_RETRY_LIMIT_AP_ADHOC;
- }
- else
- {
- priv->ShortRetryLimit = HAL_RETRY_LIMIT_INFRA;
- priv->LongRetryLimit = HAL_RETRY_LIMIT_INFRA;
- }
-
- priv->SetFwCmdInProgress = false; //is set FW CMD in Progress? 92S only
- priv->CurrentFwCmdIO = 0;
-
- priv->MinSpaceCfg = 0;
-
- priv->EarlyRxThreshold = 7;
- priv->enable_gpio0 = 0;
- priv->TransmitConfig =
- ((u32)TCR_MXDMA_2048<<TCR_MXDMA_OFFSET) | // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
- (priv->ShortRetryLimit<<TCR_SRL_OFFSET) | // Short retry limit
- (priv->LongRetryLimit<<TCR_LRL_OFFSET) | // Long retry limit
- (false ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
- if(priv->bInHctTest)
- priv->ReceiveConfig = //priv->CSMethod |
- RCR_AMF | RCR_ADF | //RCR_AAP | //accept management/data
- RCR_ACF |RCR_APPFCS| //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
- RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC
- RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet
- RCR_APP_PHYST_STAFF | RCR_APP_PHYST_RXFF | // Accept PHY status
- ((u32)7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
- (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold.
- (priv->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt:0);
- else
- priv->ReceiveConfig = //priv->CSMethod |
- RCR_AMF | RCR_ADF | RCR_AB |
- RCR_AM | RCR_APM |RCR_AAP |RCR_ADD3|RCR_APP_ICV|
- RCR_APP_PHYST_STAFF | RCR_APP_PHYST_RXFF | // Accept PHY status
- RCR_APP_MIC | RCR_APPFCS;
-
- // <Roger_EXP> 2008.06.16.
- priv->IntrMask = (u16)(IMR_ROK | IMR_VODOK | IMR_VIDOK | IMR_BEDOK | IMR_BKDOK | \
- IMR_HCCADOK | IMR_MGNTDOK | IMR_COMDOK | IMR_HIGHDOK | \
- IMR_BDOK | IMR_RXCMDOK | /*IMR_TIMEOUT0 |*/ IMR_RDU | IMR_RXFOVW | \
- IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);
-
-//1 End
-
-
- priv->AcmControl = 0;
- priv->pFirmware = (rt_firmware*)vmalloc(sizeof(rt_firmware));
- if (priv->pFirmware)
- memset(priv->pFirmware, 0, sizeof(rt_firmware));
-
- /* rx related queue */
- skb_queue_head_init(&priv->rx_queue);
- skb_queue_head_init(&priv->skb_queue);
-
- /* Tx related queue */
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_head_init(&priv->ieee80211->skb_waitQ [i]);
- }
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_head_init(&priv->ieee80211->skb_aggQ [i]);
- }
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_head_init(&priv->ieee80211->skb_drv_aggQ [i]);
- }
- priv->rf_set_chan = rtl8192_phy_SwChnl;
-}
-
-//init lock here
-static void rtl8192_init_priv_lock(struct r8192_priv* priv)
-{
- spin_lock_init(&priv->tx_lock);
- spin_lock_init(&priv->irq_lock);//added by thomas
- //spin_lock_init(&priv->rf_lock);//use rf_sem, or will crash in some OS.
- sema_init(&priv->wx_sem,1);
- sema_init(&priv->rf_sem,1);
- spin_lock_init(&priv->ps_lock);
- mutex_init(&priv->mutex);
-}
-
-extern void rtl819x_watchdog_wqcallback(struct work_struct *work);
-
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
-//init tasklet and wait_queue here. only 2.6 above kernel is considered
-#define DRV_NAME "wlan0"
-static void rtl8192_init_priv_task(struct net_device* dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-#ifdef PF_SYNCTHREAD
- priv->priv_wq = create_workqueue(DRV_NAME,0);
-#else
- priv->priv_wq = create_workqueue(DRV_NAME);
-#endif
-
- INIT_WORK(&priv->reset_wq, rtl8192_restart);
-
- //INIT_DELAYED_WORK(&priv->watch_dog_wq, hal_dm_watchdog);
- INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback);
- INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback);
-// INIT_DELAYED_WORK(&priv->gpio_change_rf_wq, dm_gpio_change_rf_callback);
- INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback);
- INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon);
- INIT_DELAYED_WORK(&priv->initialgain_operate_wq, InitialGainOperateWorkItemCallBack);
- //INIT_WORK(&priv->SwChnlWorkItem, rtl8192_SwChnl_WorkItem);
- //INIT_WORK(&priv->SetBWModeWorkItem, rtl8192_SetBWModeWorkItem);
- INIT_WORK(&priv->qos_activate, rtl8192_qos_activate);
- INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8192_hw_wakeup_wq);
- INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8192_hw_sleep_wq);
-
- tasklet_init(&priv->irq_rx_tasklet,
- (void(*)(unsigned long))rtl8192_irq_rx_tasklet,
- (unsigned long)priv);
-}
-
-//used to swap endian. as ntohl & htonl are not neccessary to swap endian, so use this instead.
-static inline u16 endian_swap(u16* data)
-{
- u16 tmp = *data;
- *data = (tmp >> 8) | (tmp << 8);
- return *data;
-}
-
-u8 rtl8192SU_UsbOptionToEndPointNumber(u8 UsbOption)
-{
- u8 nEndPoint = 0;
- switch(UsbOption)
- {
- case 0:
- nEndPoint = 6;
- break;
- case 1:
- nEndPoint = 11;
- break;
- case 2:
- nEndPoint = 4;
- break;
- default:
- RT_TRACE(COMP_INIT, "UsbOptionToEndPointNumber(): Invalid UsbOption(%#x)\n", UsbOption);
- break;
- }
- return nEndPoint;
-}
-
-u8 rtl8192SU_BoardTypeToRFtype(struct net_device* dev, u8 Boardtype)
-{
- u8 RFtype = RF_1T2R;
-
- switch(Boardtype)
- {
- case 0:
- RFtype = RF_1T1R;
- break;
- case 1:
- RFtype = RF_1T2R;
- break;
- case 2:
- RFtype = RF_2T2R;
- break;
- case 3:
- RFtype = RF_2T2R_GREEN;
- break;
- default:
- break;
- }
-
- return RFtype;
-}
-
-void update_hal_variables(struct r8192_priv *priv)
-{
- int rf_path;
- int i;
- u8 index;
-
- for (rf_path = 0; rf_path < 2; rf_path++) {
- for (i = 0; i < 3; i++) {
- RT_TRACE((COMP_INIT), "CCK RF-%d CHan_Area-%d = 0x%x\n", rf_path, i, priv->RfCckChnlAreaTxPwr[rf_path][i]);
- RT_TRACE((COMP_INIT), "OFDM-1T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i, priv->RfOfdmChnlAreaTxPwr1T[rf_path][i]);
- RT_TRACE((COMP_INIT), "OFDM-2T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i, priv->RfOfdmChnlAreaTxPwr2T[rf_path][i]);
- }
- /* Assign dedicated channel tx power */
- for(i = 0; i < 14; i++) {
- /* channel 1-3 use the same Tx Power Level. */
- if (i < 3) /* Channel 1-3 */
- index = 0;
- else if (i < 9) /* Channel 4-9 */
- index = 1;
- else /* Channel 10-14 */
- index = 2;
- /* Record A & B CCK /OFDM - 1T/2T Channel area tx power */
- priv->RfTxPwrLevelCck[rf_path][i] = priv->RfCckChnlAreaTxPwr[rf_path][index];
- priv->RfTxPwrLevelOfdm1T[rf_path][i] = priv->RfOfdmChnlAreaTxPwr1T[rf_path][index];
- priv->RfTxPwrLevelOfdm2T[rf_path][i] = priv->RfOfdmChnlAreaTxPwr2T[rf_path][index];
- if (rf_path == 0) {
- priv->TxPowerLevelOFDM24G[i] = priv->RfTxPwrLevelOfdm1T[rf_path][i] ;
- priv->TxPowerLevelCCK[i] = priv->RfTxPwrLevelCck[rf_path][i];
- }
- }
- for(i = 0; i < 14; i++) {
- RT_TRACE((COMP_INIT),
- "Rf-%d TxPwr CH-%d CCK OFDM_1T OFDM_2T= 0x%x/0x%x/0x%x\n",
- rf_path, i, priv->RfTxPwrLevelCck[rf_path][i],
- priv->RfTxPwrLevelOfdm1T[rf_path][i] ,
- priv->RfTxPwrLevelOfdm2T[rf_path][i] );
- }
- }
-}
-
-/*
- * Description:
- * Config HW adapter information into initial value.
- *
- * Assumption:
- * 1. After Auto load fail(i.e, check CR9346 fail)
- *
- */
-void rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 rf_path; /* For EEPROM/EFUSE After V0.6_1117 */
- int i;
-
- RT_TRACE(COMP_INIT, "====> ConfigAdapterInfo8192SForAutoLoadFail\n");
-
- /* Isolation signals from Loader */
- write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8);
- mdelay(10);
- write_nic_byte(dev, PMC_FSM, 0x02); /* Enable Loader Data Keep */
-
- /* Initialize IC Version && Channel Plan */
- priv->eeprom_vid = 0;
- priv->eeprom_pid = 0;
- priv->card_8192_version = 0;
- priv->eeprom_ChannelPlan = 0;
- priv->eeprom_CustomerID = 0;
- priv->eeprom_SubCustomerID = 0;
- priv->bIgnoreDiffRateTxPowerOffset = false;
-
- RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
- RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
- RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n",
- priv->eeprom_CustomerID);
- RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n",
- priv->eeprom_SubCustomerID);
- RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n",
- priv->eeprom_ChannelPlan);
- RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n",
- priv->bIgnoreDiffRateTxPowerOffset);
-
- priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
- RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
-
- for(i=0; i<5; i++)
- priv->EEPROMUsbPhyParam[i] = EEPROM_USB_Default_PHY_PARAM;
-
- {
- /*
- * In this case, we randomly assign a MAC address here.
- */
- static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
- for(i = 0; i < 6; i++)
- dev->dev_addr[i] = sMacAddr[i];
- }
- /* NicIFSetMacAddress(Adapter, Adapter->PermanentAddress); */
- write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
- write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
-
- RT_TRACE(COMP_INIT,
- "ReadAdapterInfo8192SEFuse(), Permanent Address = %pM\n",
- dev->dev_addr);
-
- priv->EEPROMBoardType = EEPROM_Default_BoardType;
- priv->rf_type = RF_1T2R; /* RF_2T2R */
- priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
- priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
- priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
- priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
- priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
- priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
- priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode;
-
- for (rf_path = 0; rf_path < 2; rf_path++)
- {
- for (i = 0; i < 3; i++)
- {
- /* Read CCK RF A & B Tx power */
- priv->RfCckChnlAreaTxPwr[rf_path][i] =
- priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] =
- priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] =
- (u8)(EEPROM_Default_TxPower & 0xff);
- }
- }
-
- update_hal_variables(priv);
-
- /*
- * Update remaining HAL variables.
- */
- priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
- priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff; /* new */
- priv->TxPowerDiff = priv->EEPROMTxPowerDiff;
- /* Antenna B gain offset to antenna A, bit0~3 */
- /* priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf); */
- /* Antenna C gain offset to antenna A, bit4~7 */
- /* priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4); */
- /* CrystalCap, bit12~15 */
- priv->CrystalCap = priv->EEPROMCrystalCap;
- /* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 */
- priv->ThermalMeter[0] = priv->EEPROMThermalMeter;
- priv->LedStrategy = SW_LED_MODE0;
-
- init_rate_adaptive(dev);
-
- RT_TRACE(COMP_INIT, "<==== ConfigAdapterInfo8192SForAutoLoadFail\n");
-}
-
-/*
- * Description:
- * Read HW adapter information by E-Fuse
- * or EEPROM according CR9346 reported.
- *
- * Assumption:
- * 1. CR9346 regiser has verified.
- * 2. PASSIVE_LEVEL (USB interface)
- */
-void rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 i;
- u8 tmpU1b, tempval;
- u16 EEPROMId;
- u8 hwinfo[HWSET_MAX_SIZE_92S];
- u8 rf_path, index; /* For EEPROM/EFUSE After V0.6_1117 */
- struct eeprom_93cx6 eeprom;
- u16 eeprom_val;
-
- eeprom.data = dev;
- eeprom.register_read = rtl819x_eeprom_register_read;
- eeprom.register_write = rtl819x_eeprom_register_write;
- eeprom.width = PCI_EEPROM_WIDTH_93C46;
-
- /*
- * The following operation are prevent Efuse leakage by turn on 2.5V.
- */
- tmpU1b = read_nic_byte(dev, EFUSE_TEST+3);
- write_nic_byte(dev, EFUSE_TEST+3, tmpU1b|0x80);
- mdelay(10);
- write_nic_byte(dev, EFUSE_TEST+3, (tmpU1b&(~BIT7)));
-
- /* Retrieve Chip version. */
- priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF);
- RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version);
-
- switch (priv->card_8192_version) {
- case 0:
- RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n");
- break;
- case 1:
- RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n");
- break;
- case 2:
- RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n");
- break;
- default:
- RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n");
- priv->card_8192_version = VERSION_8192S_BCUT;
- break;
- }
-
- if (priv->EepromOrEfuse) { /* Read from EEPROM */
- /* Isolation signals from Loader */
- write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8);
- mdelay(10);
- /* Enable Loader Data Keep */
- write_nic_byte(dev, PMC_FSM, 0x02);
- /* Read all Content from EEPROM or EFUSE. */
- for (i = 0; i < HWSET_MAX_SIZE_92S; i += 2) {
- eeprom_93cx6_read(&eeprom, (u16) (i>>1), &eeprom_val);
- *((u16 *)(&hwinfo[i])) = eeprom_val;
- }
- } else if (!(priv->EepromOrEfuse)) { /* Read from EFUSE */
- /* Read EFUSE real map to shadow. */
- EFUSE_ShadowMapUpdate(dev);
- memcpy(hwinfo, &priv->EfuseMap[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE_92S);
- } else {
- RT_TRACE(COMP_INIT, "%s(): Invalid boot type", __func__);
- }
-
- /*
- * Even though CR9346 regiser can verify whether Autoload
- * is success or not, but we still double check ID codes for 92S here
- * (e.g., due to HW GPIO polling fail issue)
- */
- EEPROMId = *((u16 *)&hwinfo[0]);
- if (EEPROMId != RTL8190_EEPROM_ID) {
- RT_TRACE(COMP_INIT, "ID(%#x) is invalid!!\n", EEPROMId);
- priv->bTXPowerDataReadFromEEPORM = FALSE;
- priv->AutoloadFailFlag=TRUE;
- } else {
- priv->AutoloadFailFlag=FALSE;
- priv->bTXPowerDataReadFromEEPORM = TRUE;
- }
- /* Read IC Version && Channel Plan */
- if (!priv->AutoloadFailFlag) {
- /* VID, PID */
- priv->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID];
- priv->eeprom_pid = *(u16 *)&hwinfo[EEPROM_PID];
- priv->bIgnoreDiffRateTxPowerOffset = false; //cosa for test
-
-
- /* EEPROM Version ID, Channel plan */
- priv->EEPROMVersion = *(u8 *)&hwinfo[EEPROM_Version];
- priv->eeprom_ChannelPlan = *(u8 *)&hwinfo[EEPROM_ChannelPlan];
-
- /* Customer ID, 0x00 and 0xff are reserved for Realtek. */
- priv->eeprom_CustomerID = *(u8 *)&hwinfo[EEPROM_CustomID];
- priv->eeprom_SubCustomerID = *(u8 *)&hwinfo[EEPROM_SubCustomID];
- } else {
- rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev);
- return;
- }
-
- RT_TRACE(COMP_INIT, "EEPROM Id = 0x%4x\n", EEPROMId);
- RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid);
- RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid);
- RT_TRACE(COMP_INIT, "EEPROM Version ID: 0x%2x\n", priv->EEPROMVersion);
- RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID);
- RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID);
- RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan);
- RT_TRACE(COMP_INIT, "bIgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset);
-
- /* Read USB optional function. */
- if (!priv->AutoloadFailFlag) {
- priv->EEPROMUsbOption = *(u8 *)&hwinfo[EEPROM_USB_OPTIONAL];
- } else {
- priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC;
- }
-
- priv->EEPROMUsbEndPointNumber = rtl8192SU_UsbOptionToEndPointNumber((priv->EEPROMUsbOption&EEPROM_EP_NUMBER)>>3);
-
- RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption);
- RT_TRACE(COMP_INIT, "EndPoint Number = %#x\n", priv->EEPROMUsbEndPointNumber);
-
-#ifdef TO_DO_LIST
- //
- // Decide CustomerID according to VID/DID or EEPROM
- //
- switch(pHalData->EEPROMCustomerID)
- {
- case EEPROM_CID_ALPHA:
- pMgntInfo->CustomerID = RT_CID_819x_ALPHA;
- break;
-
- case EEPROM_CID_CAMEO:
- pMgntInfo->CustomerID = RT_CID_819x_CAMEO;
- break;
-
- case EEPROM_CID_SITECOM:
- pMgntInfo->CustomerID = RT_CID_819x_Sitecom;
- RT_TRACE(COMP_INIT, DBG_LOUD, ("CustomerID = 0x%4x\n", pMgntInfo->CustomerID));
-
- break;
-
- case EEPROM_CID_WHQL:
- Adapter->bInHctTest = TRUE;
-
- pMgntInfo->bSupportTurboMode = FALSE;
- pMgntInfo->bAutoTurboBy8186 = FALSE;
-
- pMgntInfo->PowerSaveControl.bInactivePs = FALSE;
- pMgntInfo->PowerSaveControl.bIPSModeBackup = FALSE;
- pMgntInfo->PowerSaveControl.bLeisurePs = FALSE;
- pMgntInfo->keepAliveLevel = 0;
- break;
-
- default:
- pMgntInfo->CustomerID = RT_CID_DEFAULT;
- break;
-
- }
-
- //
- // Led mode
- //
- switch(pMgntInfo->CustomerID)
- {
- case RT_CID_DEFAULT:
- case RT_CID_819x_ALPHA:
- pHalData->LedStrategy = SW_LED_MODE1;
- pHalData->bRegUseLed = TRUE;
- pHalData->SwLed1.bLedOn = TRUE;
- break;
- case RT_CID_819x_CAMEO:
- pHalData->LedStrategy = SW_LED_MODE1;
- pHalData->bRegUseLed = TRUE;
- break;
-
- case RT_CID_819x_Sitecom:
- pHalData->LedStrategy = SW_LED_MODE2;
- pHalData->bRegUseLed = TRUE;
- break;
-
- default:
- pHalData->LedStrategy = SW_LED_MODE0;
- break;
- }
-#endif
-
- // Read USB PHY parameters.
- for(i=0; i<5; i++)
- priv->EEPROMUsbPhyParam[i] = *(u8 *)&hwinfo[EEPROM_USB_PHY_PARA1+i];
-
- //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("USB PHY Param: \n"), pHalData->EEPROMUsbPhyParam, 5);
-
-
- //Read Permanent MAC address
- for(i=0; i<6; i++)
- dev->dev_addr[i] = *(u8 *)&hwinfo[EEPROM_NODE_ADDRESS_BYTE_0+i];
-
- //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
- write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
- write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
-
- RT_TRACE(COMP_INIT,
- "ReadAdapterInfo8192SEFuse(), Permanent Address = %pM\n",
- dev->dev_addr);
-
- //
- // Get CustomerID(Boad Type)
- // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
- // Others: Reserved. Default is 0x2: RTL8192SU.
- //
- //if(!priv->AutoloadFailFlag)
- //{
- priv->EEPROMBoardType = *(u8 *)&hwinfo[EEPROM_BoardType];
- priv->rf_type = rtl8192SU_BoardTypeToRFtype(dev, priv->EEPROMBoardType);
- //}
- //else
- //{
- // priv->EEPROMBoardType = EEPROM_Default_BoardType;
- // priv->rf_type = RF_1T2R;
- //}
-
- priv->rf_chip = RF_6052;
-
- priv->rf_chip = RF_6052;//lzm test
- RT_TRACE(COMP_INIT, "BoardType = 0x%2x\n", priv->EEPROMBoardType);
- RT_TRACE(COMP_INIT, "RF_Type = 0x%2x\n", priv->rf_type);
-
- //
- // Read antenna tx power offset of B/C/D to A from EEPROM
- // and read ThermalMeter from EEPROM
- //
- //if(!priv->AutoloadFailFlag)
- {
- priv->EEPROMTxPowerDiff = *(u8 *)&hwinfo[EEPROM_PwDiff];
- priv->EEPROMThermalMeter = *(u8 *)&hwinfo[EEPROM_ThermalMeter];
- }
- //else
- //{
- // priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
- // priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
- //}
-
- RT_TRACE(COMP_INIT, "PwDiff = %#x\n", priv->EEPROMTxPowerDiff);
- RT_TRACE(COMP_INIT, "ThermalMeter = %#x\n", priv->EEPROMThermalMeter);
-
- //
- // Read Tx Power gain offset of legacy OFDM to HT rate.
- // Read CrystalCap from EEPROM
- //
- //if(!priv->AutoloadFailFlag)
- {
- priv->EEPROMCrystalCap = *(u8 *)&hwinfo[EEPROM_CrystalCap];
- }
- //else
- //{
- // priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
- //}
-
- RT_TRACE(COMP_INIT, "CrystalCap = %#x\n", priv->EEPROMCrystalCap);
-
- //
- // Get Tx Power Base.
- //
- //if(!priv->AutoloadFailFlag)
- {
- priv->EEPROMTxPwrBase = *(u8 *)&hwinfo[EEPROM_TxPowerBase];
- }
- //else
- //{
- // priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
- //}
-
- RT_TRACE(COMP_INIT, "TxPwrBase = %#x\n", priv->EEPROMTxPwrBase);
-
-
- //
- // Get TSSI value for each path.
- //
- //if(!priv->AutoloadFailFlag)
- {
- priv->EEPROMTSSI_A = *(u8 *)&hwinfo[EEPROM_TSSI_A];
- priv->EEPROMTSSI_B = *(u8 *)&hwinfo[EEPROM_TSSI_B];
- }
- //else
- //{ // Default setting for Empty EEPROM
- // priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
- // priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
- //}
-
- RT_TRACE(COMP_INIT, "TSSI_A = %#x, TSSI_B = %#x\n", priv->EEPROMTSSI_A, priv->EEPROMTSSI_B);
-
- //
- // Get Tx Power tracking mode.
- //
- //if(!priv->AutoloadFailFlag)
- {
- priv->EEPROMTxPwrTkMode = *(u8 *)&hwinfo[EEPROM_TxPwTkMode];
- }
-
- RT_TRACE(COMP_INIT, "TxPwrTkMod = %#x\n", priv->EEPROMTxPwrTkMode);
-
-
- {
- //
- // Buffer TxPwIdx(i.e., from offset 0x55~0x66, total 18Bytes)
- // Update CCK, OFDM (1T/2T)Tx Power Index from above buffer.
- //
-
- //
- // Get Tx Power Level by Channel
- //
- //if(!priv->AutoloadFailFlag)
- {
- // Read Tx power of Channel 1 ~ 14 from EFUSE.
- // 92S suupport RF A & B
- for (rf_path = 0; rf_path < 2; rf_path++)
- {
- for (i = 0; i < 3; i++)
- {
- // Read CCK RF A & B Tx power
- priv->RfCckChnlAreaTxPwr[rf_path][i] =
- hwinfo[EEPROM_TxPwIndex+rf_path*3+i];
-
- // Read OFDM RF A & B Tx power for 1T
- priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] =
- hwinfo[EEPROM_TxPwIndex+6+rf_path*3+i];
-
- // Read OFDM RF A & B Tx power for 2T
- priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] =
- hwinfo[EEPROM_TxPwIndex+12+rf_path*3+i];
- }
- }
-
- }
- update_hal_variables(priv);
- }
-
- //
- // 2009/02/09 Cosa add for new EEPROM format
- //
- for(i=0; i<14; i++) // channel 1~3 use the same Tx Power Level.
- {
- // Read tx power difference between HT OFDM 20/40 MHZ
- if (i < 3) // Cjanel 1-3
- index = 0;
- else if (i < 9) // Channel 4-9
- index = 1;
- else // Channel 10-14
- index = 2;
-
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_HT20_DIFF+index])&0xff;
- priv->TxPwrHt20Diff[RF90_PATH_A][i] = (tempval&0xF);
- priv->TxPwrHt20Diff[RF90_PATH_B][i] = ((tempval>>4)&0xF);
-
- // Read OFDM<->HT tx power diff
- if (i < 3) // Cjanel 1-3
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF])&0xff;
- else if (i < 9) // Channel 4-9
- tempval = (*(u8 *)&hwinfo[EEPROM_PwDiff])&0xff;
- else // Channel 10-14
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF+1])&0xff;
-
- //cosa tempval = (*(u1Byte *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF+index])&0xff;
- priv->TxPwrLegacyHtDiff[RF90_PATH_A][i] = (tempval&0xF);
- priv->TxPwrLegacyHtDiff[RF90_PATH_B][i] = ((tempval>>4)&0xF);
-
- //
- // Read Band Edge tx power offset and check if user enable the ability
- //
- // HT 40 band edge channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE])&0xff;
- priv->TxPwrbandEdgeHt40[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeHt40[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+1])&0xff;
- priv->TxPwrbandEdgeHt40[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeHt40[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
- // HT 20 band edge channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+2])&0xff;
- priv->TxPwrbandEdgeHt20[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeHt20[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+3])&0xff;
- priv->TxPwrbandEdgeHt20[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeHt20[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
- // OFDM band edge channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+4])&0xff;
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1] = ((tempval>>4)&0xF); // Band edge high channel
- tempval = (*(u8 *)&hwinfo[EEPROM_TX_PWR_BAND_EDGE+5])&0xff;
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][0] = (tempval&0xF); // Band edge low channel
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][1] = ((tempval>>4)&0xF); // Band edge high channel
-
- priv->TxPwrbandEdgeFlag = (*(u8 *)&hwinfo[TX_PWR_BAND_EDGE_CHK]);
- }
-
- for(i=0; i<14; i++)
- RT_TRACE(COMP_INIT, "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrHt20Diff[RF90_PATH_A][i]);
- for(i=0; i<14; i++)
- RT_TRACE(COMP_INIT, "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i, priv->TxPwrLegacyHtDiff[RF90_PATH_A][i]);
- for(i=0; i<14; i++)
- RT_TRACE(COMP_INIT, "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrHt20Diff[RF90_PATH_B][i]);
- for(i=0; i<14; i++)
- RT_TRACE(COMP_INIT, "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i, priv->TxPwrLegacyHtDiff[RF90_PATH_B][i]);
- RT_TRACE(COMP_INIT, "RF-A HT40 band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeHt40[RF90_PATH_A][0],
- priv->TxPwrbandEdgeHt40[RF90_PATH_A][1]);
- RT_TRACE((COMP_INIT&COMP_DBG), "RF-B HT40 band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeHt40[RF90_PATH_B][0],
- priv->TxPwrbandEdgeHt40[RF90_PATH_B][1]);
-
- RT_TRACE((COMP_INIT&COMP_DBG), "RF-A HT20 band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeHt20[RF90_PATH_A][0],
- priv->TxPwrbandEdgeHt20[RF90_PATH_A][1]);
- RT_TRACE((COMP_INIT&COMP_DBG), "RF-B HT20 band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeHt20[RF90_PATH_B][0],
- priv->TxPwrbandEdgeHt20[RF90_PATH_B][1]);
-
- RT_TRACE((COMP_INIT&COMP_DBG), "RF-A OFDM band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][0],
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_A][1]);
- RT_TRACE((COMP_INIT&COMP_DBG), "RF-B OFDM band-edge low/high power diff = 0x%x/0x%x\n",
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][0],
- priv->TxPwrbandEdgeLegacyOfdm[RF90_PATH_B][1]);
- RT_TRACE((COMP_INIT&COMP_DBG), "Band-edge enable flag = %d\n", priv->TxPwrbandEdgeFlag);
-
- //
- // Update remained HAL variables.
- //
- priv->TSSI_13dBm = priv->EEPROMThermalMeter *100;
- priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff;
- priv->TxPowerDiff = priv->EEPROMTxPowerDiff;
- //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit[3:0]
- //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit[7:4]
- priv->CrystalCap = priv->EEPROMCrystalCap; // CrystalCap, bit[15:12]
- priv->ThermalMeter[0] = (priv->EEPROMThermalMeter&0x1f);// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
- priv->LedStrategy = SW_LED_MODE0;
-
- init_rate_adaptive(dev);
-
- RT_TRACE(COMP_INIT, "<==== ReadAdapterInfo8192SUsb\n");
-
- //return RT_STATUS_SUCCESS;
-}
-
-
-//
-// Description:
-// Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
-//
-// Assumption:
-// 1. CR9346 regiser has verified.
-// 2. PASSIVE_LEVEL (USB interface)
-//
-// Created by Roger, 2008.10.21.
-//
-static void rtl8192SU_read_eeprom_info(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 tmpU1b;
-
- RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SUsb\n");
-
- // Retrieve Chip version.
- priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF);
- RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version);
-
- tmpU1b = read_nic_byte(dev, EPROM_CMD);//CR9346
-
- // To check system boot selection.
- if (tmpU1b & CmdEERPOMSEL)
- {
- RT_TRACE(COMP_INIT, "Boot from EEPROM\n");
- priv->EepromOrEfuse = TRUE;
- }
- else
- {
- RT_TRACE(COMP_INIT, "Boot from EFUSE\n");
- priv->EepromOrEfuse = FALSE;
- }
-
- // To check autoload success or not.
- if (tmpU1b & CmdEEPROM_En)
- {
- RT_TRACE(COMP_INIT, "Autoload OK!!\n");
- priv->AutoloadFailFlag=FALSE;
- rtl8192SU_ReadAdapterInfo8192SUsb(dev);//eeprom or e-fuse
- }
- else
- { // Auto load fail.
- RT_TRACE(COMP_INIT, "AutoLoad Fail reported from CR9346!!\n");
- priv->AutoloadFailFlag=TRUE;
- rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev);
-
- //if (IS_BOOT_FROM_EFUSE(Adapter))
- if(!priv->EepromOrEfuse)
- {
- RT_TRACE(COMP_INIT, "Update shadow map for EFuse future use!!\n");
- EFUSE_ShadowMapUpdate(dev);
- }
- }
-#ifdef TO_DO_LIST
- if((priv->RegChannelPlan >= RT_CHANNEL_DOMAIN_MAX) || (pHalData->EEPROMChannelPlan & EEPROM_CHANNEL_PLAN_BY_HW_MASK))
- {
- pMgntInfo->ChannelPlan = HalMapChannelPlan8192S(Adapter, (pHalData->EEPROMChannelPlan & (~(EEPROM_CHANNEL_PLAN_BY_HW_MASK))));
- pMgntInfo->bChnlPlanFromHW = (pHalData->EEPROMChannelPlan & EEPROM_CHANNEL_PLAN_BY_HW_MASK) ? TRUE : FALSE; // User cannot change channel plan.
- }
- else
- {
- pMgntInfo->ChannelPlan = (RT_CHANNEL_DOMAIN)pMgntInfo->RegChannelPlan;
- }
-
- switch(pMgntInfo->ChannelPlan)
- {
- case RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN:
- {
- PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(pMgntInfo);
-
- pDot11dInfo->bEnabled = TRUE;
- }
- RT_TRACE(COMP_INIT, DBG_LOUD, ("ReadAdapterInfo8187(): Enable dot11d when RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN!\n"));
- break;
- }
-
- RT_TRACE(COMP_INIT, DBG_LOUD, ("RegChannelPlan(%d) EEPROMChannelPlan(%d)", pMgntInfo->RegChannelPlan, pHalData->EEPROMChannelPlan));
- RT_TRACE(COMP_INIT, DBG_LOUD, ("ChannelPlan = %d\n" , pMgntInfo->ChannelPlan));
-
- RT_TRACE(COMP_INIT, DBG_LOUD, ("<==== ReadAdapterInfo8192S\n"));
-#endif
-
- RT_TRACE(COMP_INIT, "<==== ReadAdapterInfo8192SUsb\n");
-
- //return RT_STATUS_SUCCESS;
-}
-
-short rtl8192_get_channel_map(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->ChannelPlan > COUNTRY_CODE_GLOBAL_DOMAIN){
- printk("rtl8180_init:Error channel plan! Set to default.\n");
- priv->ChannelPlan= 0;
- }
- RT_TRACE(COMP_INIT, "Channel plan is %d\n",priv->ChannelPlan);
-
- rtl819x_set_channel_map(priv->ChannelPlan, priv);
- return 0;
-}
-
-short rtl8192_init(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- rtl8192_init_priv_variable(dev);
- rtl8192_init_priv_lock(priv);
- rtl8192_init_priv_task(dev);
- priv->ops->rtl819x_read_eeprom_info(dev);
- rtl8192_get_channel_map(dev);
- init_hal_dm(dev);
- init_timer(&priv->watch_dog_timer);
- priv->watch_dog_timer.data = (unsigned long)dev;
- priv->watch_dog_timer.function = watch_dog_timer_callback;
- return 0;
-}
-
-/******************************************************************************
- *function: This function actually only set RRSR, RATR and BW_OPMODE registers
- * not to do all the hw config as its name says
- * input: net_device dev
- * output: none
- * return: none
- * notice: This part need to modified according to the rate set we filtered
- * ****************************************************************************/
-void rtl8192_hwconfig(struct net_device* dev)
-{
- u32 regRATR = 0, regRRSR = 0;
- u8 regBwOpMode = 0, regTmp = 0;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-// Set RRSR, RATR, and BW_OPMODE registers
- //
- switch(priv->ieee80211->mode)
- {
- case WIRELESS_MODE_B:
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK;
- regRRSR = RATE_ALL_CCK;
- break;
- case WIRELESS_MODE_A:
- regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_G:
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_AUTO:
-#ifdef TO_DO_LIST
- if (Adapter->bInHctTest)
- {
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- }
- else
-#endif
- {
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- }
- break;
- case WIRELESS_MODE_N_24G:
- // It support CCK rate by default.
- // CCK rate will be filtered out only when associated AP does not support it.
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_N_5G:
- regBwOpMode = BW_OPMODE_5G;
- regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_OFDM_AG;
- break;
- }
-
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
- {
- u32 ratr_value = 0;
- ratr_value = regRATR;
- if (priv->rf_type == RF_1T2R)
- {
- ratr_value &= ~(RATE_ALL_OFDM_2SS);
- }
- write_nic_dword(dev, RATR0, ratr_value);
- write_nic_byte(dev, UFWP, 1);
- }
- regTmp = read_nic_byte(dev, 0x313);
- regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff);
- write_nic_dword(dev, RRSR, regRRSR);
-
- //
- // Set Retry Limit here
- //
- write_nic_word(dev, RETRY_LIMIT,
- priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | \
- priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT);
- // Set Contention Window here
-
- // Set Tx AGC
-
- // Set Tx Antenna including Feedback control
-
- // Set Auto Rate fallback control
-
-
-}
-
-
-//
-// Description:
-// Initial HW relted registers.
-//
-// Assumption:
-// Config RTL8192S USB MAC, we should config MAC before download FW.
-//
-// 2008.09.03, Added by Roger.
-//
-static void rtl8192SU_MacConfigBeforeFwDownloadASIC(struct net_device *dev)
-{
- u8 tmpU1b;// i;
-// u16 tmpU2b;
-// u32 tmpU4b;
- u8 PollingCnt = 20;
-
- RT_TRACE(COMP_INIT, "--->MacConfigBeforeFwDownloadASIC()\n");
-
- //2MAC Initialization for power on sequence, Revised by Roger. 2008.09.03.
-
- //
- //<Roger_Notes> Set control path switch to HW control and reset Digital Core, CPU Core and
- // MAC I/O to solve FW download fail when system from resume sate.
- // 2008.11.04.
- //
- tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
- if(tmpU1b & 0x80)
- {
- tmpU1b &= 0x3f;
- write_nic_byte(dev, SYS_CLKR+1, tmpU1b);
- }
- // Clear FW RPWM for FW control LPS. by tynli. 2009.02.23
- write_nic_byte(dev, RPWM, 0x0);
-
- tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
- tmpU1b &= 0x73;
- write_nic_byte(dev, SYS_FUNC_EN+1, tmpU1b);
- udelay(1000);
-
- //Revised POS, suggested by SD1 Alex, 2008.09.27.
- write_nic_byte(dev, SPS0_CTRL+1, 0x53);
- write_nic_byte(dev, SPS0_CTRL, 0x57);
-
- //Enable AFE Macro Block's Bandgap adn Enable AFE Macro Block's Mbias
- tmpU1b = read_nic_byte(dev, AFE_MISC);
- write_nic_byte(dev, AFE_MISC, (tmpU1b|AFE_BGEN|AFE_MBEN));
-
- //Enable PLL Power (LDOA15V)
- tmpU1b = read_nic_byte(dev, LDOA15_CTRL);
- write_nic_byte(dev, LDOA15_CTRL, (tmpU1b|LDA15_EN));
-
- //Enable LDOV12D block
- tmpU1b = read_nic_byte(dev, LDOV12D_CTRL);
- write_nic_byte(dev, LDOV12D_CTRL, (tmpU1b|LDV12_EN));
-
- //mpU1b = read_nic_byte(Adapter, SPS1_CTRL);
- //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_LDEN));
-
- //PlatformSleepUs(2000);
-
- //Enable Switch Regulator Block
- //tmpU1b = read_nic_byte(Adapter, SPS1_CTRL);
- //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_SWEN));
-
- //write_nic_dword(Adapter, SPS1_CTRL, 0x00a7b267);
-
- tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL+1);
- write_nic_byte(dev, SYS_ISO_CTRL+1, (tmpU1b|0x08));
-
- //Engineer Packet CP test Enable
- tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
- write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x20));
-
- //Support 64k IMEM, suggested by SD1 Alex.
- tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL+1);
- write_nic_byte(dev, SYS_ISO_CTRL+1, (tmpU1b& 0x68));
-
- //Enable AFE clock
- tmpU1b = read_nic_byte(dev, AFE_XTAL_CTRL+1);
- write_nic_byte(dev, AFE_XTAL_CTRL+1, (tmpU1b& 0xfb));
-
- //Enable AFE PLL Macro Block
- tmpU1b = read_nic_byte(dev, AFE_PLL_CTRL);
- write_nic_byte(dev, AFE_PLL_CTRL, (tmpU1b|0x11));
-
- //Attatch AFE PLL to MACTOP/BB/PCIe Digital
- tmpU1b = read_nic_byte(dev, SYS_ISO_CTRL);
- write_nic_byte(dev, SYS_ISO_CTRL, (tmpU1b&0xEE));
-
- // Switch to 40M clock
- write_nic_byte(dev, SYS_CLKR, 0x00);
-
- //SSC Disable
- tmpU1b = read_nic_byte(dev, SYS_CLKR);
- //write_nic_byte(dev, SYS_CLKR, (tmpU1b&0x5f));
- write_nic_byte(dev, SYS_CLKR, (tmpU1b|0xa0));
-
- //Enable MAC clock
- tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
- write_nic_byte(dev, SYS_CLKR+1, (tmpU1b|0x18));
-
- //Revised POS, suggested by SD1 Alex, 2008.09.27.
- write_nic_byte(dev, PMC_FSM, 0x02);
-
- //Enable Core digital and enable IOREG R/W
- tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
- write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x08));
-
- //Enable REG_EN
- tmpU1b = read_nic_byte(dev, SYS_FUNC_EN+1);
- write_nic_byte(dev, SYS_FUNC_EN+1, (tmpU1b|0x80));
-
- //Switch the control path to FW
- tmpU1b = read_nic_byte(dev, SYS_CLKR+1);
- write_nic_byte(dev, SYS_CLKR+1, (tmpU1b|0x80)& 0xBF);
-
- write_nic_byte(dev, CMDR, 0xFC);
- write_nic_byte(dev, CMDR+1, 0x37);
-
- //Fix the RX FIFO issue(usb error), 970410
- tmpU1b = read_nic_byte_E(dev, 0x5c);
- write_nic_byte_E(dev, 0x5c, (tmpU1b|BIT7));
-
- //For power save, used this in the bit file after 970621
- tmpU1b = read_nic_byte(dev, SYS_CLKR);
- write_nic_byte(dev, SYS_CLKR, tmpU1b&(~SYS_CPU_CLKSEL));
-
- // Revised for 8051 ROM code wrong operation. Added by Roger. 2008.10.16.
- write_nic_byte_E(dev, 0x1c, 0x80);
-
- //
- // <Roger_EXP> To make sure that TxDMA can ready to download FW.
- // We should reset TxDMA if IMEM RPT was not ready.
- // Suggested by SD1 Alex. 2008.10.23.
- //
- do
- {
- tmpU1b = read_nic_byte(dev, TCR);
- if((tmpU1b & TXDMA_INIT_VALUE) == TXDMA_INIT_VALUE)
- break;
- //PlatformStallExecution(5);
- udelay(5);
- }while(PollingCnt--); // Delay 1ms
-
- if(PollingCnt <= 0 )
- {
- RT_TRACE(COMP_INIT, "MacConfigBeforeFwDownloadASIC(): Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n", tmpU1b);
- tmpU1b = read_nic_byte(dev, CMDR);
- write_nic_byte(dev, CMDR, tmpU1b&(~TXDMA_EN));
- udelay(2);
- write_nic_byte(dev, CMDR, tmpU1b|TXDMA_EN);// Reset TxDMA
- }
-
-
- RT_TRACE(COMP_INIT, "<---MacConfigBeforeFwDownloadASIC()\n");
-}
-
-//
-// Description:
-// Initial HW relted registers.
-//
-// Assumption:
-// 1. This function is only invoked at driver intialization once.
-// 2. PASSIVE LEVEL.
-//
-// 2008.06.10, Added by Roger.
-//
-static void rtl8192SU_MacConfigAfterFwDownload(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
- //PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
- //u8 tmpU1b, RxPageCfg, i;
- u16 tmpU2b;
- u8 tmpU1b;//, i;
-
-
- RT_TRACE(COMP_INIT, "--->MacConfigAfterFwDownload()\n");
-
- // Enable Tx/Rx
- tmpU2b = (BBRSTn|BB_GLB_RSTn|SCHEDULE_EN|MACRXEN|MACTXEN|DDMA_EN|
- FW2HW_EN|RXDMA_EN|TXDMA_EN|HCI_RXDMA_EN|HCI_TXDMA_EN); //3
- //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_COMMAND, &tmpU1b );
- write_nic_word(dev, CMDR, tmpU2b); //LZM REGISTER COM 090305
-
- // Loopback mode or not
- priv->LoopbackMode = RTL8192SU_NO_LOOPBACK; // Set no loopback as default.
- if(priv->LoopbackMode == RTL8192SU_NO_LOOPBACK)
- tmpU1b = LBK_NORMAL;
- else if (priv->LoopbackMode == RTL8192SU_MAC_LOOPBACK )
- tmpU1b = LBK_MAC_DLB;
- else
- RT_TRACE(COMP_INIT, "Serious error: wrong loopback mode setting\n");
-
- //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_LBK_MODE, &tmpU1b);
- write_nic_byte(dev, LBKMD_SEL, tmpU1b);
-
- // Set RCR
- write_nic_dword(dev, RCR, priv->ReceiveConfig);
- RT_TRACE(COMP_INIT, "MacConfigAfterFwDownload(): Current RCR settings(%#x)\n", priv->ReceiveConfig);
-
-
- // Set RQPN
- //
- // <Roger_Notes> 2008.08.18.
- // 6 endpoints:
- // (1) Page number on CMDQ is 0x03.
- // (2) Page number on BCNQ, HQ and MGTQ is 0.
- // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
- // (4) Page number on PUBQ is 0xdd
- //
- // 11 endpoints:
- // (1) Page number on CMDQ is 0x00.
- // (2) Page number on BCNQ is 0x02, HQ and MGTQ are 0x03.
- // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
- // (4) Page number on PUBQ is 0xd8
- //
- //write_nic_dword(Adapter, 0xa0, 0x07070707); //BKQ, BEQ, VIQ and VOQ
- //write_nic_byte(dev, 0xa4, 0x00); // HCCAQ
-
- // Fix the RX FIFO issue(USB error), Rivesed by Roger, 2008-06-14
- tmpU1b = read_nic_byte_E(dev, 0x5C);
- write_nic_byte_E(dev, 0x5C, tmpU1b|BIT7);
-
- // For EFUSE init configuration.
- //if (IS_BOOT_FROM_EFUSE(Adapter)) // We may R/W EFUSE in EFUSE mode
- if (priv->bBootFromEfuse)
- {
- u8 tempval;
-
- tempval = read_nic_byte(dev, SYS_ISO_CTRL+1);
- tempval &= 0xFE;
- write_nic_byte(dev, SYS_ISO_CTRL+1, tempval);
-
- // Enable LDO 2.5V for write action
- //tempval = read_nic_byte(Adapter, EFUSE_TEST+3);
- //write_nic_byte(Adapter, EFUSE_TEST+3, (tempval | 0x80));
-
- // Change Efuse Clock for write action
- //write_nic_byte(Adapter, EFUSE_CLK, 0x03);
-
- // Change Program timing
- write_nic_byte(dev, EFUSE_CTRL+3, 0x72);
- //printk("!!!!!!!!!!!!!!!!!!!!!%s: write 0x33 with 0x72\n",__FUNCTION__);
- RT_TRACE(COMP_INIT, "EFUSE CONFIG OK\n");
- }
-
-
- RT_TRACE(COMP_INIT, "<---MacConfigAfterFwDownload()\n");
-}
-
-void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 regBwOpMode = 0;
- u32 regRATR = 0, regRRSR = 0;
- u8 regTmp = 0;
- u32 i = 0;
-
- //1 This part need to modified according to the rate set we filtered!!
- //
- // Set RRSR, RATR, and BW_OPMODE registers
- //
- switch(priv->ieee80211->mode)
- {
- case WIRELESS_MODE_B:
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK;
- regRRSR = RATE_ALL_CCK;
- break;
- case WIRELESS_MODE_A:
- regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_G:
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_AUTO:
- if (priv->bInHctTest)
- {
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- }
- else
- {
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- }
- break;
- case WIRELESS_MODE_N_24G:
- // It support CCK rate by default.
- // CCK rate will be filtered out only when associated AP does not support it.
- regBwOpMode = BW_OPMODE_20MHZ;
- regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
- break;
- case WIRELESS_MODE_N_5G:
- regBwOpMode = BW_OPMODE_5G;
- regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
- regRRSR = RATE_ALL_OFDM_AG;
- break;
- }
-
- //
- // <Roger_Notes> We disable CCK response rate until FIB CCK rate IC's back.
- // 2008.09.23.
- //
- regTmp = read_nic_byte(dev, INIRTSMCS_SEL);
- regRRSR = ((regRRSR & 0x000fffff)<<8) | regTmp;
-
- //
- // Update SIFS timing.
- //
- //priv->SifsTime = 0x0e0e0a0a;
- //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_SIFS, (pu1Byte)&pHalData->SifsTime);
- { u8 val[4] = {0x0e, 0x0e, 0x0a, 0x0a};
- // SIFS for CCK Data ACK
- write_nic_byte(dev, SIFS_CCK, val[0]);
- // SIFS for CCK consecutive tx like CTS data!
- write_nic_byte(dev, SIFS_CCK+1, val[1]);
-
- // SIFS for OFDM Data ACK
- write_nic_byte(dev, SIFS_OFDM, val[2]);
- // SIFS for OFDM consecutive tx like CTS data!
- write_nic_byte(dev, SIFS_OFDM+1, val[3]);
- }
-
- write_nic_dword(dev, INIRTSMCS_SEL, regRRSR);
- write_nic_byte(dev, BW_OPMODE, regBwOpMode);
-
- //
- // Suggested by SD1 Alex, 2008-06-14.
- //
- //PlatformEFIOWrite1Byte(Adapter, TXOP_STALL_CTRL, 0x80);//NAV to protect all TXOP.
-
- //
- // Set Data Auto Rate Fallback Retry Count register.
- //
- write_nic_dword(dev, DARFRC, 0x02010000);
- write_nic_dword(dev, DARFRC+4, 0x06050403);
- write_nic_dword(dev, RARFRC, 0x02010000);
- write_nic_dword(dev, RARFRC+4, 0x06050403);
-
- // Set Data Auto Rate Fallback Reg. Added by Roger, 2008.09.22.
- for (i = 0; i < 8; i++)
- write_nic_dword(dev, ARFR0+i*4, 0x1f0ffff0);
-
- //
- // Aggregation length limit. Revised by Roger. 2008.09.22.
- //
- write_nic_byte(dev, AGGLEN_LMT_H, 0x0f); // Set AMPDU length to 12Kbytes for ShortGI case.
- write_nic_dword(dev, AGGLEN_LMT_L, 0xddd77442); // Long GI
- write_nic_dword(dev, AGGLEN_LMT_L+4, 0xfffdd772);
-
- // Set NAV protection length
- write_nic_word(dev, NAV_PROT_LEN, 0x0080);
-
- // Set TXOP stall control for several queue/HI/BCN/MGT/
- write_nic_byte(dev, TXOP_STALL_CTRL, 0x00); // NAV Protect next packet.
-
- // Set MSDU lifetime.
- write_nic_byte(dev, MLT, 0x8f);
-
- // Set CCK/OFDM SIFS
- write_nic_word(dev, SIFS_CCK, 0x0a0a); // CCK SIFS shall always be 10us.
- write_nic_word(dev, SIFS_OFDM, 0x0e0e);
-
- write_nic_byte(dev, ACK_TIMEOUT, 0x40);
-
- // CF-END Threshold
- write_nic_byte(dev, CFEND_TH, 0xFF);
-
- //
- // For Min Spacing configuration.
- //
- switch(priv->rf_type)
- {
- case RF_1T2R:
- case RF_1T1R:
- RT_TRACE(COMP_INIT, "Initializeadapter: RF_Type%s\n", (priv->rf_type==RF_1T1R? "(1T1R)":"(1T2R)"));
- priv->MinSpaceCfg = (MAX_MSS_DENSITY_1T<<3);
- break;
- case RF_2T2R:
- case RF_2T2R_GREEN:
- RT_TRACE(COMP_INIT, "Initializeadapter:RF_Type(2T2R)\n");
- priv->MinSpaceCfg = (MAX_MSS_DENSITY_2T<<3);
- break;
- }
- write_nic_byte(dev, AMPDU_MIN_SPACE, priv->MinSpaceCfg);
-
- //LZM 090219
- //
- // For Min Spacing configuration.
- //
- //priv->MinSpaceCfg = 0x00;
- //rtl8192SU_SetHwRegAmpduMinSpace(dev, priv->MinSpaceCfg);
-}
-
-
-// Description: Initial HW relted registers.
-//
-// Assumption: This function is only invoked at driver intialization once.
-//
-// 2008.06.10, Added by Roger.
-bool rtl8192SU_adapter_start(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //u32 dwRegRead = 0;
- //bool init_status = true;
- //u32 ulRegRead;
- bool rtStatus = true;
- //u8 PipeIndex;
- //u8 eRFPath, tmpU1b;
- u8 fw_download_times = 1;
-
-
- RT_TRACE(COMP_INIT, "--->InitializeAdapter8192SUsb()\n");
-
- //pHalData->bGPIOChangeRF = FALSE;
-
-
- //
- // <Roger_Notes> 2008.06.15.
- //
- // Initialization Steps on RTL8192SU:
- // a. MAC initialization prior to sending down firmware code.
- // b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
- // c. MAC configuration after firmware has been download successfully.
- // d. Initialize BB related configurations.
- // e. Initialize RF related configurations.
- // f. Start to BulkIn transfer.
- //
-
- //
- //a. MAC initialization prior to send down firmware code.
- //
-start:
- rtl8192SU_MacConfigBeforeFwDownloadASIC(dev);
-
- //
- //b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
- //
- rtStatus = FirmwareDownload92S(dev);
- if(rtStatus != true)
- {
- if(fw_download_times == 1){
- RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Download Firmware failed once, Download again!!\n");
- fw_download_times = fw_download_times + 1;
- goto start;
- }else{
- RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Download Firmware failed twice, end!!\n");
- goto end;
- }
- }
- //
- //c. MAC configuration after firmware has been download successfully.
- //
- rtl8192SU_MacConfigAfterFwDownload(dev);
-
- //priv->bLbusEnable = TRUE;
- //if(priv->RegRfOff == TRUE)
- // priv->eRFPowerState = eRfOff;
-
- // Save target channel
- // <Roger_Notes> Current Channel will be updated again later.
- //priv->CurrentChannel = Channel;
- rtStatus = PHY_MACConfig8192S(dev);//===>ok
- if(rtStatus != true)
- {
- RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure MAC!!\n");
- goto end;
- }
- if (1){
- int i;
- for (i=0; i<4; i++)
- write_nic_dword(dev,WDCAPARA_ADD[i], 0x5e4322);
- write_nic_byte(dev,AcmHwCtrl, 0x01);
- }
-
-
- //
- //d. Initialize BB related configurations.
- //
-
- rtStatus = PHY_BBConfig8192S(dev);//===>ok
- if(rtStatus != true)
- {
- RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure BB!!\n");
- goto end;
- }
-
- rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58);//===>ok
-
- //
- // e. Initialize RF related configurations.
- //
- // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W.
- priv->Rf_Mode = RF_OP_By_SW_3wire;
-
- // For RF test only from Scott's suggestion
- //write_nic_byte(dev, 0x27, 0xDB);
- //write_nic_byte(dev, 0x1B, 0x07);
-
-
- write_nic_byte(dev, AFE_XTAL_CTRL+1, 0xDB);
-
- // <Roger_Notes> The following IOs are configured for each RF modules.
- // Enable RF module and reset RF and SDM module. 2008.11.17.
- if(priv->card_8192_version == VERSION_8192S_ACUT)
- write_nic_byte(dev, SPS1_CTRL+3, (u8)(RF_EN|RF_RSTB|RF_SDMRSTB)); // Fix A-Cut bug.
- else
- write_nic_byte(dev, RF_CTRL, (u8)(RF_EN|RF_RSTB|RF_SDMRSTB));
-
- rtStatus = PHY_RFConfig8192S(dev);//===>ok
- if(rtStatus != true)
- {
- RT_TRACE(COMP_INIT, "InitializeAdapter8192SUsb(): Fail to configure RF!!\n");
- goto end;
- }
-
-
- // Set CCK and OFDM Block "ON"
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
-
- //
- // Turn off Radio B while RF type is 1T1R by SD3 Wilsion's request.
- // Revised by Roger, 2008.12.18.
- //
- if(priv->rf_type == RF_1T1R)
- {
- // This is needed for PHY_REG after 20081219
- rtl8192_setBBreg(dev, rFPGA0_RFMOD, 0xff000000, 0x03);
- // This is needed for PHY_REG before 20081219
- //PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, bMaskByte0, 0x11);
- }
-
-
- //LZM 090219
- // Set CCK and OFDM Block "ON"
- //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
- //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
-
-
- //3//Get hardware version, do it in read eeprom?
- //GetHardwareVersion819xUsb(Adapter);
-
- //3//
- //3 //Set Hardware
- //3//
- rtl8192SU_HwConfigureRTL8192SUsb(dev);//==>ok
-
- //
- // <Roger_Notes> We set MAC address here if autoload was failed before,
- // otherwise IDR0 will NOT contain any value.
- //
- write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]);
- write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]);
- if(!priv->bInHctTest)
- {
- if(priv->ResetProgress == RESET_TYPE_NORESET)
- {
- //RT_TRACE(COMP_MLME, DBG_LOUD, ("Initializeadapter8192SUsb():RegWirelessMode(%#x) \n", Adapter->RegWirelessMode));
- //Adapter->HalFunc.SetWirelessModeHandler(Adapter, Adapter->RegWirelessMode);
- rtl8192_SetWirelessMode(dev, priv->ieee80211->mode);//===>ok
- }
- }
- else
- {
- priv->ieee80211->mode = WIRELESS_MODE_G;
- rtl8192_SetWirelessMode(dev, WIRELESS_MODE_G);
- }
-
- //Security related.
- //-----------------------------------------------------------------------------
- // Set up security related. 070106, by rcnjko:
- // 1. Clear all H/W keys.
- // 2. Enable H/W encryption/decryption.
- //-----------------------------------------------------------------------------
- //CamResetAllEntry(Adapter);
- //Adapter->HalFunc.EnableHWSecCfgHandler(Adapter);
-
- //SecClearAllKeys(Adapter);
- CamResetAllEntry(dev);
- //SecInit(Adapter);
- {
- u8 SECR_value = 0x0;
- SECR_value |= SCR_TxEncEnable;
- SECR_value |= SCR_RxDecEnable;
- SECR_value |= SCR_NoSKMC;
- write_nic_byte(dev, SECR, SECR_value);
- }
-
-#ifdef TO_DO_LIST
-
- //PHY_UpdateInitialGain(dev);
-
- if(priv->RegRfOff == true)
- { // User disable RF via registry.
- u8 eRFPath = 0;
-
- RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): Turn off RF for RegRfOff ----------\n");
- MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW);
- // Those action will be discard in MgntActSet_RF_State because off the same state
- for(eRFPath = 0; eRFPath <priv->NumTotalRFPath; eRFPath++)
- rtl8192_setBBreg(dev, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
- }
- else if(priv->RfOffReason > RF_CHANGE_BY_PS)
- { // H/W or S/W RF OFF before sleep.
- RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): Turn off RF for RfOffReason(%d) ----------\n", priv->RfOffReason);
- MgntActSet_RF_State(dev, eRfOff, priv->RfOffReason);
- }
- else
- {
- priv->eRFPowerState = eRfOn;
- priv->RfOffReason = 0;
- RT_TRACE((COMP_INIT|COMP_RF), "InitializeAdapter8192SUsb(): RF is on ----------\n");
- }
-
-#endif
-
-
-//
-// f. Start to BulkIn transfer.
-//
-#ifdef TO_DO_LIST
-
-#ifndef UNDER_VISTA
- {
- u8 i;
- PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
-
- for(PipeIndex=0; PipeIndex < MAX_RX_QUEUE; PipeIndex++)
- {
- if (PipeIndex == 0)
- {
- for(i=0; i<32; i++)
- HalUsbInMpdu(Adapter, PipeIndex);
- }
- else
- {
- //HalUsbInMpdu(Adapter, PipeIndex);
- //HalUsbInMpdu(Adapter, PipeIndex);
- //HalUsbInMpdu(Adapter, PipeIndex);
- }
- }
- PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
- }
-#else
- // Joseph add to 819X code base for Vista USB platform.
- // This part may need to be add to Hal819xU code base. too.
- PlatformUsbEnableInPipes(Adapter);
-#endif
-
- RT_TRACE(COMP_INIT, "HighestOperaRate = %x\n", Adapter->MgntInfo.HighestOperaRate);
-
- PlatformStartWorkItem( &(pHalData->RtUsbCheckForHangWorkItem) );
-
- //
- // <Roger_EXP> The following configurations are for ASIC verification temporally.
- // 2008.07.10.
- //
-
-#endif
-
- //
- // Read EEPROM TX power index and PHY_REG_PG.txt to capture correct
- // TX power index for different rate set.
- //
- //if(priv->card_8192_version >= VERSION_8192S_ACUT)
- {
- // Get original hw reg values
- PHY_GetHWRegOriginalValue(dev);
-
- // Write correct tx power index//FIXLZM
- PHY_SetTxPowerLevel8192S(dev, priv->chan);
- }
-
- {
- u8 tmpU1b = 0;
- // EEPROM R/W workaround
- tmpU1b = read_nic_byte(dev, MAC_PINMUX_CFG);
- write_nic_byte(dev, MAC_PINMUX_CFG, tmpU1b&(~GPIOMUX_EN));
- }
-
-//
-//<Roger_Notes> 2008.08.19.
-// We return status here for temporal FPGA verification, 2008.08.19.
-
-#ifdef RTL8192SU_FW_IQK
- write_nic_dword(dev, WFM5, FW_IQK_ENABLE);
- ChkFwCmdIoDone(dev);
-#endif
-
- //
- // <Roger_Notes> We enable high power mechanism after NIC initialized.
- // 2008.11.27.
- //
- write_nic_dword(dev, WFM5, FW_RA_RESET);
- ChkFwCmdIoDone(dev);
- write_nic_dword(dev, WFM5, FW_RA_ACTIVE);
- ChkFwCmdIoDone(dev);
- write_nic_dword(dev, WFM5, FW_RA_REFRESH);
- ChkFwCmdIoDone(dev);
- write_nic_dword(dev, WFM5, FW_BB_RESET_ENABLE);
-
-// <Roger_Notes> We return status here for temporal FPGA verification. 2008.05.12.
-//
-
-end:
-return rtStatus;
-}
-
-/***************************************************************************
- -------------------------------NET STUFF---------------------------
-***************************************************************************/
-
-static struct net_device_stats *rtl8192_stats(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- return &priv->ieee80211->stats;
-}
-
-bool
-HalTxCheckStuck819xUsb(
- struct net_device *dev
- )
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 RegTxCounter = read_nic_word(dev, 0x128);
- bool bStuck = FALSE;
- RT_TRACE(COMP_RESET,"%s():RegTxCounter is %d,TxCounter is %d\n",__FUNCTION__,RegTxCounter,priv->TxCounter);
- if(priv->TxCounter==RegTxCounter)
- bStuck = TRUE;
-
- priv->TxCounter = RegTxCounter;
-
- return bStuck;
-}
-
-/*
-* <Assumption: RT_TX_SPINLOCK is acquired.>
-* First added: 2006.11.19 by emily
-*/
-RESET_TYPE
-TxCheckStuck(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 QueueID;
-// PRT_TCB pTcb;
-// u8 ResetThreshold;
- bool bCheckFwTxCnt = false;
- //unsigned long flags;
-
- //
- // Decide Stuch threshold according to current power save mode
- //
-
-// RT_TRACE(COMP_RESET, " ==> TxCheckStuck()\n");
-// PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
-// spin_lock_irqsave(&priv->ieee80211->lock,flags);
- for (QueueID = 0; QueueID<=BEACON_QUEUE;QueueID ++)
- {
- if(QueueID == TXCMD_QUEUE)
- continue;
-#if 1
- if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
- continue;
-#endif
-
- bCheckFwTxCnt = true;
- }
-// PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
-// spin_unlock_irqrestore(&priv->ieee80211->lock,flags);
-// RT_TRACE(COMP_RESET,"bCheckFwTxCnt is %d\n",bCheckFwTxCnt);
-#if 1
- if(bCheckFwTxCnt)
- {
- if(HalTxCheckStuck819xUsb(dev))
- {
- RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n");
- return RESET_TYPE_SILENT;
- }
- }
-#endif
- return RESET_TYPE_NORESET;
-}
-
-bool
-HalRxCheckStuck819xUsb(struct net_device *dev)
-{
- u16 RegRxCounter = read_nic_word(dev, 0x130);
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bStuck = FALSE;
-//#ifdef RTL8192SU
-
-//#else
- static u8 rx_chk_cnt = 0;
- RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n",__FUNCTION__,RegRxCounter,priv->RxCounter);
- // If rssi is small, we should check rx for long time because of bad rx.
- // or maybe it will continuous silent reset every 2 seconds.
- rx_chk_cnt++;
- if(priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5))
- {
- rx_chk_cnt = 0; //high rssi, check rx stuck right now.
- }
- else if(priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) &&
- ((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_40M) ||
- (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb>=RateAdaptiveTH_Low_20M)) )
- {
- if(rx_chk_cnt < 2)
- {
- return bStuck;
- }
- else
- {
- rx_chk_cnt = 0;
- }
- }
- else if(((priv->CurrentChannelBW!=HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb<RateAdaptiveTH_Low_40M) ||
- (priv->CurrentChannelBW==HT_CHANNEL_WIDTH_20&&priv->undecorated_smoothed_pwdb<RateAdaptiveTH_Low_20M)) &&
- priv->undecorated_smoothed_pwdb >= VeryLowRSSI)
- {
- if(rx_chk_cnt < 4)
- {
- //DbgPrint("RSSI < %d && RSSI >= %d, no check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
- return bStuck;
- }
- else
- {
- rx_chk_cnt = 0;
- //DbgPrint("RSSI < %d && RSSI >= %d, check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
- }
- }
- else
- {
- if(rx_chk_cnt < 8)
- {
- //DbgPrint("RSSI <= %d, no check this time \n", VeryLowRSSI);
- return bStuck;
- }
- else
- {
- rx_chk_cnt = 0;
- //DbgPrint("RSSI <= %d, check this time \n", VeryLowRSSI);
- }
- }
-//#endif
-
- if(priv->RxCounter==RegRxCounter)
- bStuck = TRUE;
-
- priv->RxCounter = RegRxCounter;
-
- return bStuck;
-}
-
-RESET_TYPE
-RxCheckStuck(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //int i;
- bool bRxCheck = FALSE;
-
-// RT_TRACE(COMP_RESET," ==> RxCheckStuck()\n");
- //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
-
- if(priv->IrpPendingCount > 1)
- bRxCheck = TRUE;
- //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
-
-// RT_TRACE(COMP_RESET,"bRxCheck is %d \n",bRxCheck);
- if(bRxCheck)
- {
- if(HalRxCheckStuck819xUsb(dev))
- {
- RT_TRACE(COMP_RESET, "RxStuck Condition\n");
- return RESET_TYPE_SILENT;
- }
- }
- return RESET_TYPE_NORESET;
-}
-
-
-/**
-* This function is called by Checkforhang to check whether we should ask OS to reset driver
-*
-* \param pAdapter The adapter context for this miniport
-*
-* Note:NIC with USB interface sholud not call this function because we cannot scan descriptor
-* to judge whether there is tx stuck.
-* Note: This function may be required to be rewrite for Vista OS.
-* <<<Assumption: Tx spinlock has been acquired >>>
-*
-* 8185 and 8185b does not implement this function. This is added by Emily at 2006.11.24
-*/
-RESET_TYPE
-rtl819x_ifcheck_resetornot(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- RESET_TYPE TxResetType = RESET_TYPE_NORESET;
- RESET_TYPE RxResetType = RESET_TYPE_NORESET;
- RT_RF_POWER_STATE rfState;
-
- return RESET_TYPE_NORESET;
-
- rfState = priv->ieee80211->eRFPowerState;
-
- TxResetType = TxCheckStuck(dev);
-#if 1
- if( rfState != eRfOff ||
- /*ADAPTER_TEST_STATUS_FLAG(Adapter, ADAPTER_STATUS_FW_DOWNLOAD_FAILURE)) &&*/
- (priv->ieee80211->iw_mode != IW_MODE_ADHOC))
- {
- // If driver is in the status of firmware download failure , driver skips RF initialization and RF is
- // in turned off state. Driver should check whether Rx stuck and do silent reset. And
- // if driver is in firmware download failure status, driver should initialize RF in the following
- // silent reset procedure Emily, 2008.01.21
-
- // Driver should not check RX stuck in IBSS mode because it is required to
- // set Check BSSID in order to send beacon, however, if check BSSID is
- // set, STA cannot hear any packet a all. Emily, 2008.04.12
- RxResetType = RxCheckStuck(dev);
- }
-#endif
- if(TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL)
- return RESET_TYPE_NORMAL;
- else if(TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT){
- RT_TRACE(COMP_RESET,"%s():silent reset\n",__FUNCTION__);
- return RESET_TYPE_SILENT;
- }
- else
- return RESET_TYPE_NORESET;
-
-}
-
-void rtl8192_cancel_deferred_work(struct r8192_priv* priv);
-int _rtl8192_up(struct net_device *dev);
-int rtl8192_close(struct net_device *dev);
-
-
-
-void
-CamRestoreAllEntry( struct net_device *dev)
-{
- u8 EntryId = 0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8* MacAddr = priv->ieee80211->current_network.bssid;
-
- static u8 CAM_CONST_ADDR[4][6] = {
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
- static u8 CAM_CONST_BROAD[] =
- {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
- RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n");
-
-
- if ((priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP40)||
- (priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP104))
- {
-
- for(EntryId=0; EntryId<4; EntryId++)
- {
- {
- MacAddr = CAM_CONST_ADDR[EntryId];
- setKey(dev,
- EntryId ,
- EntryId,
- priv->ieee80211->pairwise_key_type,
- MacAddr,
- 0,
- NULL);
- }
- }
-
- }
- else if(priv->ieee80211->pairwise_key_type == KEY_TYPE_TKIP)
- {
-
- {
- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- setKey(dev,
- 4,
- 0,
- priv->ieee80211->pairwise_key_type,
- (u8*)dev->dev_addr,
- 0,
- NULL);
- else
- setKey(dev,
- 4,
- 0,
- priv->ieee80211->pairwise_key_type,
- MacAddr,
- 0,
- NULL);
- }
- }
- else if(priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP)
- {
-
- {
- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- setKey(dev,
- 4,
- 0,
- priv->ieee80211->pairwise_key_type,
- (u8*)dev->dev_addr,
- 0,
- NULL);
- else
- setKey(dev,
- 4,
- 0,
- priv->ieee80211->pairwise_key_type,
- MacAddr,
- 0,
- NULL);
- }
- }
-
-
-
- if(priv->ieee80211->group_key_type == KEY_TYPE_TKIP)
- {
- MacAddr = CAM_CONST_BROAD;
- for(EntryId=1 ; EntryId<4 ; EntryId++)
- {
- {
- setKey(dev,
- EntryId,
- EntryId,
- priv->ieee80211->group_key_type,
- MacAddr,
- 0,
- NULL);
- }
- }
- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- setKey(dev,
- 0,
- 0,
- priv->ieee80211->group_key_type,
- CAM_CONST_ADDR[0],
- 0,
- NULL);
- }
- else if(priv->ieee80211->group_key_type == KEY_TYPE_CCMP)
- {
- MacAddr = CAM_CONST_BROAD;
- for(EntryId=1; EntryId<4 ; EntryId++)
- {
- {
- setKey(dev,
- EntryId ,
- EntryId,
- priv->ieee80211->group_key_type,
- MacAddr,
- 0,
- NULL);
- }
- }
-
- if(priv->ieee80211->iw_mode == IW_MODE_ADHOC)
- setKey(dev,
- 0 ,
- 0,
- priv->ieee80211->group_key_type,
- CAM_CONST_ADDR[0],
- 0,
- NULL);
- }
-}
-//////////////////////////////////////////////////////////////
-// This function is used to fix Tx/Rx stop bug temporarily.
-// This function will do "system reset" to NIC when Tx or Rx is stuck.
-// The method checking Tx/Rx stuck of this function is supported by FW,
-// which reports Tx and Rx counter to register 0x128 and 0x130.
-//////////////////////////////////////////////////////////////
-void
-rtl819x_ifsilentreset(struct net_device *dev)
-{
- //OCTET_STRING asocpdu;
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 reset_times = 0;
- int reset_status = 0;
- struct ieee80211_device *ieee = priv->ieee80211;
-
-
- // 2007.07.20. If we need to check CCK stop, please uncomment this line.
- //bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter);
-
- if(priv->ResetProgress==RESET_TYPE_NORESET)
- {
-RESET_START:
-
- RT_TRACE(COMP_RESET,"=========>Reset progress!! \n");
-
- // Set the variable for reset.
- priv->ResetProgress = RESET_TYPE_SILENT;
-// rtl8192_close(dev);
-#if 1
- down(&priv->wx_sem);
- if(priv->up == 0)
- {
- RT_TRACE(COMP_ERR,"%s():the driver is not up! return\n",__FUNCTION__);
- up(&priv->wx_sem);
- return ;
- }
- priv->up = 0;
- RT_TRACE(COMP_RESET,"%s():======>start to down the driver\n",__FUNCTION__);
-// if(!netif_queue_stopped(dev))
-// netif_stop_queue(dev);
-
- rtl8192_rtx_disable(dev);
- rtl8192_cancel_deferred_work(priv);
- deinit_hal_dm(dev);
- del_timer_sync(&priv->watch_dog_timer);
-
- ieee->sync_scan_hurryup = 1;
- if(ieee->state == IEEE80211_LINKED)
- {
- down(&ieee->wx_sem);
- printk("ieee->state is IEEE80211_LINKED\n");
- ieee80211_stop_send_beacons(priv->ieee80211);
- del_timer_sync(&ieee->associate_timer);
- cancel_delayed_work(&ieee->associate_retry_wq);
- ieee80211_stop_scan(ieee);
- netif_carrier_off(dev);
- up(&ieee->wx_sem);
- }
- else{
- printk("ieee->state is NOT LINKED\n");
- ieee80211_softmac_stop_protocol(priv->ieee80211); }
- up(&priv->wx_sem);
- RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__FUNCTION__);
- //rtl8192_irq_disable(dev);
- RT_TRACE(COMP_RESET,"%s():===========>start to up the driver\n",__FUNCTION__);
- reset_status = _rtl8192_up(dev);
-
- RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__FUNCTION__);
- if(reset_status == -EAGAIN)
- {
- if(reset_times < 3)
- {
- reset_times++;
- goto RESET_START;
- }
- else
- {
- RT_TRACE(COMP_ERR," ERR!!! %s(): Reset Failed!!\n", __FUNCTION__);
- }
- }
-#endif
- ieee->is_silent_reset = 1;
-#if 1
- EnableHWSecurityConfig8192(dev);
-#if 1
- if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA)
- {
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
-
-#if 1
- queue_work(ieee->wq, &ieee->associate_complete_wq);
-#endif
-
- }
- else if(ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_ADHOC)
- {
- ieee->set_chan(ieee->dev, ieee->current_network.channel);
- ieee->link_change(ieee->dev);
-
- // notify_wx_assoc_event(ieee);
-
- ieee80211_start_send_beacons(ieee);
-
- if (ieee->data_hard_resume)
- ieee->data_hard_resume(ieee->dev);
- netif_carrier_on(ieee->dev);
- }
-#endif
-
- CamRestoreAllEntry(dev);
-
- priv->ResetProgress = RESET_TYPE_NORESET;
- priv->reset_count++;
-
- priv->bForcedSilentReset =false;
- priv->bResetInProgress = false;
-
- // For test --> force write UFWP.
- write_nic_byte(dev, UFWP, 1);
- RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count);
-#endif
- }
-}
-
-void CAM_read_entry(
- struct net_device *dev,
- u32 iIndex
-)
-{
- u32 target_command=0;
- u32 target_content=0;
- u8 entry_i=0;
- u32 ulStatus;
- s32 i=100;
-// printk("=======>start read CAM\n");
- for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++)
- {
- // polling bit, and No Write enable, and address
- target_command= entry_i+CAM_CONTENT_COUNT*iIndex;
- target_command= target_command | BIT31;
-
- //Check polling bit is clear
-// mdelay(1);
-#if 1
- while((i--)>=0)
- {
- ulStatus = read_nic_dword(dev, RWCAM);
- if(ulStatus & BIT31){
- continue;
- }
- else{
- break;
- }
- }
-#endif
- write_nic_dword(dev, RWCAM, target_command);
- RT_TRACE(COMP_SEC,"CAM_read_entry(): WRITE A0: %x \n",target_command);
- // printk("CAM_read_entry(): WRITE A0: %lx \n",target_command);
- target_content = read_nic_dword(dev, RCAMO);
- RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n",target_content);
- // printk("CAM_read_entry(): WRITE A8: %lx \n",target_content);
- }
- printk("\n");
-}
-
-void rtl819x_update_rxcounts(
- struct r8192_priv *priv,
- u32* TotalRxBcnNum,
- u32* TotalRxDataNum
-)
-{
- u16 SlotIndex;
- u8 i;
-
- *TotalRxBcnNum = 0;
- *TotalRxDataNum = 0;
-
- SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum);
- priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
- priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
- for( i=0; i<priv->ieee80211->LinkDetectInfo.SlotNum; i++ ){
- *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i];
- *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i];
- }
-}
-
-void rtl819x_watchdog_wqcallback(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work,
- struct delayed_work,
- work);
- struct r8192_priv *priv = container_of(dwork,
- struct r8192_priv,
- watch_dog_wq);
- struct net_device *dev = priv->ieee80211->dev;
- struct ieee80211_device* ieee = priv->ieee80211;
- RESET_TYPE ResetType = RESET_TYPE_NORESET;
- static u8 check_reset_cnt;
- u32 TotalRxBcnNum = 0;
- u32 TotalRxDataNum = 0;
- bool bBusyTraffic = false;
-
- if(!priv->up)
- return;
- hal_dm_watchdog(dev);
- /* to get busy traffic condition */
- if (ieee->state == IEEE80211_LINKED) {
- if (ieee->LinkDetectInfo.NumRxOkInPeriod > 666 ||
- ieee->LinkDetectInfo.NumTxOkInPeriod > 666)
- bBusyTraffic = true;
-
- ieee->LinkDetectInfo.NumRxOkInPeriod = 0;
- ieee->LinkDetectInfo.NumTxOkInPeriod = 0;
- ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
- }
-
- if (priv->ieee80211->state == IEEE80211_LINKED &&
- priv->ieee80211->iw_mode == IW_MODE_INFRA) {
- rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum);
- if ((TotalRxBcnNum + TotalRxDataNum) == 0) {
- RT_TRACE(COMP_ERR, "%s(): AP is powered off,"
- "connect another one\n", __func__);
- /* Dot11d_Reset(dev); */
- priv->ieee80211->state = IEEE80211_ASSOCIATING;
- notify_wx_assoc_event(priv->ieee80211);
- RemovePeerTS(priv->ieee80211,
- priv->ieee80211->current_network.bssid);
- ieee->is_roaming = true;
- priv->ieee80211->link_change(dev);
- if(ieee->LedControlHandler != NULL)
- ieee->LedControlHandler(ieee->dev,
- LED_CTL_START_TO_LINK);
- queue_work(priv->ieee80211->wq,
- &priv->ieee80211->associate_procedure_wq);
- }
- }
- priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod = 0;
- priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod = 0;
-
- /*
- * CAM_read_entry(dev,4);
- * check if reset the driver
- */
- if (check_reset_cnt++ >= 3 && !ieee->is_roaming) {
- ResetType = rtl819x_ifcheck_resetornot(dev);
- check_reset_cnt = 3;
- }
- if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET &&
- (priv->bForcedSilentReset ||
- (!priv->bDisableNormalResetCheck &&
- /* This is control by OID set in Pomelo */
- ResetType == RESET_TYPE_SILENT)))) {
- RT_TRACE(COMP_RESET, "%s(): priv->force_reset is %d,"
- "priv->ResetProgress is %d, "
- "priv->bForcedSilentReset is %d, "
- "priv->bDisableNormalResetCheck is %d, "
- "ResetType is %d",
- __func__,
- priv->force_reset,
- priv->ResetProgress,
- priv->bForcedSilentReset,
- priv->bDisableNormalResetCheck,
- ResetType);
- rtl819x_ifsilentreset(dev);
- }
- priv->force_reset = false;
- priv->bForcedSilentReset = false;
- priv->bResetInProgress = false;
-}
-
-void watch_dog_timer_callback(unsigned long data)
-{
- struct r8192_priv *priv = ieee80211_priv((struct net_device *) data);
- //printk("===============>watch_dog timer\n");
- queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq, 0);
- mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
-}
-int _rtl8192_up(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //int i;
- int init_status = 0;
- priv->up=1;
- priv->ieee80211->ieee_up=1;
- RT_TRACE(COMP_INIT, "Bringing up iface");
- init_status = priv->ops->rtl819x_adapter_start(dev);
- if(!init_status)
- {
- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n", __FUNCTION__);
- priv->up=priv->ieee80211->ieee_up = 0;
- return -EAGAIN;
- }
- RT_TRACE(COMP_INIT, "start adapter finished\n");
- rtl8192_rx_enable(dev);
-// rtl8192_tx_enable(dev);
- if(priv->ieee80211->state != IEEE80211_LINKED)
- ieee80211_softmac_start_protocol(priv->ieee80211);
- ieee80211_reset_queue(priv->ieee80211);
- watch_dog_timer_callback((unsigned long) dev);
- if(!netif_queue_stopped(dev))
- netif_start_queue(dev);
- else
- netif_wake_queue(dev);
-
- /*
- * Make sure that drop_unencrypted is initialized as "0"
- * No packets will be sent in non-security mode if we had set drop_unencrypted.
- * ex, After kill wpa_supplicant process, make the driver up again.
- * drop_unencrypted remains as "1", which is set by wpa_supplicant. 2008/12/04.john
- */
- priv->ieee80211->drop_unencrypted = 0;
-
- return 0;
-}
-
-
-int rtl8192_open(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int ret;
- down(&priv->wx_sem);
- ret = rtl8192_up(dev);
- up(&priv->wx_sem);
- return ret;
-
-}
-
-
-int rtl8192_up(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if (priv->up == 1) return -1;
-
- return _rtl8192_up(dev);
-}
-
-
-int rtl8192_close(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int ret;
-
- down(&priv->wx_sem);
-
- ret = rtl8192_down(dev);
-
- up(&priv->wx_sem);
-
- return ret;
-
-}
-
-int rtl8192_down(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int i;
-
- if (priv->up == 0) return -1;
-
- priv->up=0;
- priv->ieee80211->ieee_up = 0;
- RT_TRACE(COMP_DOWN, "==========>%s()\n", __FUNCTION__);
-/* FIXME */
- if (!netif_queue_stopped(dev))
- netif_stop_queue(dev);
-
- rtl8192_rtx_disable(dev);
- //rtl8192_irq_disable(dev);
-
- /* Tx related queue release */
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_purge(&priv->ieee80211->skb_waitQ [i]);
- }
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_purge(&priv->ieee80211->skb_aggQ [i]);
- }
-
- for(i = 0; i < MAX_QUEUE_SIZE; i++) {
- skb_queue_purge(&priv->ieee80211->skb_drv_aggQ [i]);
- }
-
- //as cancel_delayed_work will del work->timer, so if work is not definedas struct delayed_work, it will corrupt
-// flush_scheduled_work();
- rtl8192_cancel_deferred_work(priv);
- deinit_hal_dm(dev);
- del_timer_sync(&priv->watch_dog_timer);
-
-
- ieee80211_softmac_stop_protocol(priv->ieee80211);
- memset(&priv->ieee80211->current_network, 0 , offsetof(struct ieee80211_network, list));
- RT_TRACE(COMP_DOWN, "<==========%s()\n", __FUNCTION__);
-
- return 0;
-}
-
-
-void rtl8192_commit(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int reset_status = 0;
- //u8 reset_times = 0;
- if (priv->up == 0) return ;
- priv->up = 0;
-
- rtl8192_cancel_deferred_work(priv);
- del_timer_sync(&priv->watch_dog_timer);
- //cancel_delayed_work(&priv->SwChnlWorkItem);
-
- ieee80211_softmac_stop_protocol(priv->ieee80211);
-
- //rtl8192_irq_disable(dev);
- rtl8192_rtx_disable(dev);
- reset_status = _rtl8192_up(dev);
-
-}
-
-/*
-void rtl8192_restart(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-*/
-void rtl8192_restart(struct work_struct *work)
-{
- struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
- struct net_device *dev = priv->ieee80211->dev;
-
- down(&priv->wx_sem);
-
- rtl8192_commit(dev);
-
- up(&priv->wx_sem);
-}
-
-static void r8192_set_multicast(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- short promisc;
-
- //down(&priv->wx_sem);
-
- /* FIXME FIXME */
-
- promisc = (dev->flags & IFF_PROMISC) ? 1:0;
-
- if (promisc != priv->promisc)
- // rtl8192_commit(dev);
-
- priv->promisc = promisc;
-
- //schedule_work(&priv->reset_wq);
- //up(&priv->wx_sem);
-}
-
-
-int r8192_set_mac_adr(struct net_device *dev, void *mac)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct sockaddr *addr = mac;
-
- down(&priv->wx_sem);
-
- memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
-
- schedule_work(&priv->reset_wq);
-
- up(&priv->wx_sem);
-
- return 0;
-}
-
-/* based on ipw2200 driver */
-int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct iwreq *wrq = (struct iwreq *)rq;
- int ret=-1;
- struct ieee80211_device *ieee = priv->ieee80211;
- u32 key[4];
- u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
- u8 zero_addr[6] = {0};
- struct iw_point *p = &wrq->u.data;
- struct ieee_param *ipw = NULL;//(struct ieee_param *)wrq->u.data.pointer;
-
- down(&priv->wx_sem);
-
-
- if (p->length < sizeof(struct ieee_param) || !p->pointer){
- ret = -EINVAL;
- goto out;
- }
-
- ipw = kmalloc(p->length, GFP_KERNEL);
- if (ipw == NULL){
- ret = -ENOMEM;
- goto out;
- }
- if (copy_from_user(ipw, p->pointer, p->length)) {
- kfree(ipw);
- ret = -EFAULT;
- goto out;
- }
-
- switch (cmd) {
- case RTL_IOCTL_WPA_SUPPLICANT:
- //parse here for HW security
- if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION)
- {
- if (ipw->u.crypt.set_tx)
- {
- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
- ieee->pairwise_key_type = KEY_TYPE_CCMP;
- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
- ieee->pairwise_key_type = KEY_TYPE_TKIP;
- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
- {
- if (ipw->u.crypt.key_len == 13)
- ieee->pairwise_key_type = KEY_TYPE_WEP104;
- else if (ipw->u.crypt.key_len == 5)
- ieee->pairwise_key_type = KEY_TYPE_WEP40;
- }
- else
- ieee->pairwise_key_type = KEY_TYPE_NA;
-
- if (ieee->pairwise_key_type)
- {
- // FIXME:these two lines below just to fix ipw interface bug, that is, it will never set mode down to driver. So treat it as ADHOC mode, if no association procedure. WB. 2009.02.04
- if (memcmp(ieee->ap_mac_addr, zero_addr, 6) == 0)
- ieee->iw_mode = IW_MODE_ADHOC;
- memcpy((u8*)key, ipw->u.crypt.key, 16);
- EnableHWSecurityConfig8192(dev);
- //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching!
- //added by WB.
- setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
- if (ieee->iw_mode == IW_MODE_ADHOC)
- setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
- }
- }
- else //if (ipw->u.crypt.idx) //group key use idx > 0
- {
- memcpy((u8*)key, ipw->u.crypt.key, 16);
- if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
- ieee->group_key_type= KEY_TYPE_CCMP;
- else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
- ieee->group_key_type = KEY_TYPE_TKIP;
- else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
- {
- if (ipw->u.crypt.key_len == 13)
- ieee->group_key_type = KEY_TYPE_WEP104;
- else if (ipw->u.crypt.key_len == 5)
- ieee->group_key_type = KEY_TYPE_WEP40;
- }
- else
- ieee->group_key_type = KEY_TYPE_NA;
-
- if (ieee->group_key_type)
- {
- setKey( dev,
- ipw->u.crypt.idx,
- ipw->u.crypt.idx, //KeyIndex
- ieee->group_key_type, //KeyType
- broadcast_addr, //MacAddr
- 0, //DefaultKey
- key); //KeyContent
- }
- }
- }
-#ifdef JOHN_HWSEC_DEBUG
- //john's test 0711
- printk("@@ wrq->u pointer = ");
- for(i=0;i<wrq->u.data.length;i++){
- if(i%10==0) printk("\n");
- printk( "%8x|", ((u32*)wrq->u.data.pointer)[i] );
- }
- printk("\n");
-#endif /*JOHN_HWSEC_DEBUG*/
- ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
- break;
-
- default:
- ret = -EOPNOTSUPP;
- break;
- }
- kfree(ipw);
- ipw = NULL;
-out:
- up(&priv->wx_sem);
- return ret;
-}
-
-u8 rtl8192SU_HwRateToMRate(bool bIsHT, u8 rate,bool bFirstAMPDU)
-{
-
- u8 ret_rate = 0x02;
-
- if( bFirstAMPDU )
- {
- if(!bIsHT)
- {
- switch(rate)
- {
-
- case DESC92S_RATE1M: ret_rate = MGN_1M; break;
- case DESC92S_RATE2M: ret_rate = MGN_2M; break;
- case DESC92S_RATE5_5M: ret_rate = MGN_5_5M; break;
- case DESC92S_RATE11M: ret_rate = MGN_11M; break;
- case DESC92S_RATE6M: ret_rate = MGN_6M; break;
- case DESC92S_RATE9M: ret_rate = MGN_9M; break;
- case DESC92S_RATE12M: ret_rate = MGN_12M; break;
- case DESC92S_RATE18M: ret_rate = MGN_18M; break;
- case DESC92S_RATE24M: ret_rate = MGN_24M; break;
- case DESC92S_RATE36M: ret_rate = MGN_36M; break;
- case DESC92S_RATE48M: ret_rate = MGN_48M; break;
- case DESC92S_RATE54M: ret_rate = MGN_54M; break;
-
- default:
- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
- break;
- }
- }
- else
- {
- switch(rate)
- {
-
- case DESC92S_RATEMCS0: ret_rate = MGN_MCS0; break;
- case DESC92S_RATEMCS1: ret_rate = MGN_MCS1; break;
- case DESC92S_RATEMCS2: ret_rate = MGN_MCS2; break;
- case DESC92S_RATEMCS3: ret_rate = MGN_MCS3; break;
- case DESC92S_RATEMCS4: ret_rate = MGN_MCS4; break;
- case DESC92S_RATEMCS5: ret_rate = MGN_MCS5; break;
- case DESC92S_RATEMCS6: ret_rate = MGN_MCS6; break;
- case DESC92S_RATEMCS7: ret_rate = MGN_MCS7; break;
- case DESC92S_RATEMCS8: ret_rate = MGN_MCS8; break;
- case DESC92S_RATEMCS9: ret_rate = MGN_MCS9; break;
- case DESC92S_RATEMCS10: ret_rate = MGN_MCS10; break;
- case DESC92S_RATEMCS11: ret_rate = MGN_MCS11; break;
- case DESC92S_RATEMCS12: ret_rate = MGN_MCS12; break;
- case DESC92S_RATEMCS13: ret_rate = MGN_MCS13; break;
- case DESC92S_RATEMCS14: ret_rate = MGN_MCS14; break;
- case DESC92S_RATEMCS15: ret_rate = MGN_MCS15; break;
- case DESC92S_RATEMCS32: ret_rate = (0x80|0x20); break;
-
- default:
- RT_TRACE(COMP_RECV, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT );
- break;
- }
-
- }
- }
- else
- {
- switch(rate)
- {
-
- case DESC92S_RATE1M: ret_rate = MGN_1M; break;
- case DESC92S_RATE2M: ret_rate = MGN_2M; break;
- case DESC92S_RATE5_5M: ret_rate = MGN_5_5M; break;
- case DESC92S_RATE11M: ret_rate = MGN_11M; break;
- case DESC92S_RATE6M: ret_rate = MGN_6M; break;
- case DESC92S_RATE9M: ret_rate = MGN_9M; break;
- case DESC92S_RATE12M: ret_rate = MGN_12M; break;
- case DESC92S_RATE18M: ret_rate = MGN_18M; break;
- case DESC92S_RATE24M: ret_rate = MGN_24M; break;
- case DESC92S_RATE36M: ret_rate = MGN_36M; break;
- case DESC92S_RATE48M: ret_rate = MGN_48M; break;
- case DESC92S_RATE54M: ret_rate = MGN_54M; break;
- case DESC92S_RATEMCS0: ret_rate = MGN_MCS0; break;
- case DESC92S_RATEMCS1: ret_rate = MGN_MCS1; break;
- case DESC92S_RATEMCS2: ret_rate = MGN_MCS2; break;
- case DESC92S_RATEMCS3: ret_rate = MGN_MCS3; break;
- case DESC92S_RATEMCS4: ret_rate = MGN_MCS4; break;
- case DESC92S_RATEMCS5: ret_rate = MGN_MCS5; break;
- case DESC92S_RATEMCS6: ret_rate = MGN_MCS6; break;
- case DESC92S_RATEMCS7: ret_rate = MGN_MCS7; break;
- case DESC92S_RATEMCS8: ret_rate = MGN_MCS8; break;
- case DESC92S_RATEMCS9: ret_rate = MGN_MCS9; break;
- case DESC92S_RATEMCS10: ret_rate = MGN_MCS10; break;
- case DESC92S_RATEMCS11: ret_rate = MGN_MCS11; break;
- case DESC92S_RATEMCS12: ret_rate = MGN_MCS12; break;
- case DESC92S_RATEMCS13: ret_rate = MGN_MCS13; break;
- case DESC92S_RATEMCS14: ret_rate = MGN_MCS14; break;
- case DESC92S_RATEMCS15: ret_rate = MGN_MCS15; break;
- case DESC92S_RATEMCS32: ret_rate = (0x80|0x20); break;
-
- default:
- RT_TRACE(COMP_RECV, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT );
- break;
- }
- }
- return ret_rate;
-}
-
-u8 HwRateToMRate90(bool bIsHT, u8 rate)
-{
- u8 ret_rate = 0xff;
-
- if(!bIsHT) {
- switch(rate) {
- case DESC90_RATE1M: ret_rate = MGN_1M; break;
- case DESC90_RATE2M: ret_rate = MGN_2M; break;
- case DESC90_RATE5_5M: ret_rate = MGN_5_5M; break;
- case DESC90_RATE11M: ret_rate = MGN_11M; break;
- case DESC90_RATE6M: ret_rate = MGN_6M; break;
- case DESC90_RATE9M: ret_rate = MGN_9M; break;
- case DESC90_RATE12M: ret_rate = MGN_12M; break;
- case DESC90_RATE18M: ret_rate = MGN_18M; break;
- case DESC90_RATE24M: ret_rate = MGN_24M; break;
- case DESC90_RATE36M: ret_rate = MGN_36M; break;
- case DESC90_RATE48M: ret_rate = MGN_48M; break;
- case DESC90_RATE54M: ret_rate = MGN_54M; break;
-
- default:
- ret_rate = 0xff;
- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
- break;
- }
-
- } else {
- switch(rate) {
- case DESC90_RATEMCS0: ret_rate = MGN_MCS0; break;
- case DESC90_RATEMCS1: ret_rate = MGN_MCS1; break;
- case DESC90_RATEMCS2: ret_rate = MGN_MCS2; break;
- case DESC90_RATEMCS3: ret_rate = MGN_MCS3; break;
- case DESC90_RATEMCS4: ret_rate = MGN_MCS4; break;
- case DESC90_RATEMCS5: ret_rate = MGN_MCS5; break;
- case DESC90_RATEMCS6: ret_rate = MGN_MCS6; break;
- case DESC90_RATEMCS7: ret_rate = MGN_MCS7; break;
- case DESC90_RATEMCS8: ret_rate = MGN_MCS8; break;
- case DESC90_RATEMCS9: ret_rate = MGN_MCS9; break;
- case DESC90_RATEMCS10: ret_rate = MGN_MCS10; break;
- case DESC90_RATEMCS11: ret_rate = MGN_MCS11; break;
- case DESC90_RATEMCS12: ret_rate = MGN_MCS12; break;
- case DESC90_RATEMCS13: ret_rate = MGN_MCS13; break;
- case DESC90_RATEMCS14: ret_rate = MGN_MCS14; break;
- case DESC90_RATEMCS15: ret_rate = MGN_MCS15; break;
- case DESC90_RATEMCS32: ret_rate = (0x80|0x20); break;
-
- default:
- ret_rate = 0xff;
- RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT);
- break;
- }
- }
-
- return ret_rate;
-}
-
-/**
- * Function: UpdateRxPktTimeStamp
- * Overview: Recored down the TSF time stamp when receiving a packet
- *
- * Input:
- * PADAPTER Adapter
- * PRT_RFD pRfd,
- *
- * Output:
- * PRT_RFD pRfd
- * (pRfd->Status.TimeStampHigh is updated)
- * (pRfd->Status.TimeStampLow is updated)
- * Return:
- * None
- */
-void UpdateRxPktTimeStamp8190 (struct net_device *dev, struct ieee80211_rx_stats *stats)
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- if(stats->bIsAMPDU && !stats->bFirstMPDU) {
- stats->mac_time[0] = priv->LastRxDescTSFLow;
- stats->mac_time[1] = priv->LastRxDescTSFHigh;
- } else {
- priv->LastRxDescTSFLow = stats->mac_time[0];
- priv->LastRxDescTSFHigh = stats->mac_time[1];
- }
-}
-
-//by amy 080606
-
-long rtl819x_translate_todbm(u8 signal_strength_index )// 0-100 index.
-{
- long signal_power; // in dBm.
-
- // Translate to dBm (x=0.5y-95).
- signal_power = (long)((signal_strength_index + 1) >> 1);
- signal_power -= 95;
-
- return signal_power;
-}
-
-
-/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to
- be a local static. Otherwise, it may increase when we return from S3/S4. The
- value will be kept in memory or disk. We must delcare the value in adapter
- and it will be reinitialized when return from S3/S4. */
-void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats)
-{
- bool bcheck = false;
- u8 rfpath;
- u32 nspatial_stream, tmp_val;
- //u8 i;
- static u32 slide_rssi_index=0, slide_rssi_statistics=0;
- static u32 slide_evm_index=0, slide_evm_statistics=0;
- static u32 last_rssi=0, last_evm=0;
-
- static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0;
- static u32 last_beacon_adc_pwdb=0;
-
- struct ieee80211_hdr_3addr *hdr;
- u16 sc ;
- unsigned int frag,seq;
- hdr = (struct ieee80211_hdr_3addr *)buffer;
- sc = le16_to_cpu(hdr->seq_ctrl);
- frag = WLAN_GET_SEQ_FRAG(sc);
- seq = WLAN_GET_SEQ_SEQ(sc);
- //cosa add 04292008 to record the sequence number
- pcurrent_stats->Seq_Num = seq;
- //
- // Check whether we should take the previous packet into accounting
- //
- if(!pprevious_stats->bIsAMPDU)
- {
- // if previous packet is not aggregated packet
- bcheck = true;
- }else
- {
- }
-
-
- if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX)
- {
- slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX;
- last_rssi = priv->stats.slide_signal_strength[slide_rssi_index];
- priv->stats.slide_rssi_total -= last_rssi;
- }
- priv->stats.slide_rssi_total += pprevious_stats->SignalStrength;
-
- priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength;
- if(slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX)
- slide_rssi_index = 0;
-
- // <1> Showed on UI for user, in dbm
- tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics;
- priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val);
- pcurrent_stats->rssi = priv->stats.signal_strength;
- //
- // If the previous packet does not match the criteria, neglect it
- //
- if(!pprevious_stats->bPacketMatchBSSID)
- {
- if(!pprevious_stats->bToSelfBA)
- return;
- }
-
- if(!bcheck)
- return;
-
-
- //rtl8190_process_cck_rxpathsel(priv,pprevious_stats);//only rtl8190 supported
-
- //
- // Check RSSI
- //
- priv->stats.num_process_phyinfo++;
-
- /* record the general signal strength to the sliding window. */
-
-
- // <2> Showed on UI for engineering
- // hardware does not provide rssi information for each rf path in CCK
- if(!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA))
- {
- for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++)
- {
- if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, rfpath))
- continue;
-
- //Fixed by Jacken 2008-03-20
- if(priv->stats.rx_rssi_percentage[rfpath] == 0)
- {
- priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath];
- //DbgPrint("MIMO RSSI initialize \n");
- }
- if(pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath])
- {
- priv->stats.rx_rssi_percentage[rfpath] =
- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) +
- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor);
- priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1;
- }
- else
- {
- priv->stats.rx_rssi_percentage[rfpath] =
- ( (priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) +
- (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor);
- }
- RT_TRACE(COMP_DBG,"priv->stats.rx_rssi_percentage[rfPath] = %d \n" ,priv->stats.rx_rssi_percentage[rfpath] );
- }
- }
-
-
- //
- // Check PWDB.
- //
- RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
- pprevious_stats->bIsCCK? "CCK": "OFDM",
- pprevious_stats->RxPWDBAll);
-
- if(pprevious_stats->bPacketBeacon)
- {
-/* record the beacon pwdb to the sliding window. */
- if(slide_beacon_adc_pwdb_statistics++ >= PHY_Beacon_RSSI_SLID_WIN_MAX)
- {
- slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX;
- last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
- priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
- //DbgPrint("slide_beacon_adc_pwdb_index = %d, last_beacon_adc_pwdb = %d, Adapter->RxStats.Slide_Beacon_Total = %d\n",
- // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total);
- }
- priv->stats.Slide_Beacon_Total += pprevious_stats->RxPWDBAll;
- priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->RxPWDBAll;
- //DbgPrint("slide_beacon_adc_pwdb_index = %d, pPreviousRfd->Status.RxPWDBAll = %d\n", slide_beacon_adc_pwdb_index, pPreviousRfd->Status.RxPWDBAll);
- slide_beacon_adc_pwdb_index++;
- if(slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX)
- slide_beacon_adc_pwdb_index = 0;
- pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics;
- if(pprevious_stats->RxPWDBAll >= 3)
- pprevious_stats->RxPWDBAll -= 3;
- }
-
- RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n",
- pprevious_stats->bIsCCK? "CCK": "OFDM",
- pprevious_stats->RxPWDBAll);
-
-
- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA)
- {
- if(priv->undecorated_smoothed_pwdb < 0) // initialize
- {
- priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll;
- //DbgPrint("First pwdb initialize \n");
- }
-#if 1
- if(pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb)
- {
- priv->undecorated_smoothed_pwdb =
- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) +
- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor);
- priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1;
- }
- else
- {
- priv->undecorated_smoothed_pwdb =
- ( ((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) +
- (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor);
- }
-#else
- //Fixed by Jacken 2008-03-20
- if(pPreviousRfd->Status.RxPWDBAll > (u32)pHalData->UndecoratedSmoothedPWDB)
- {
- pHalData->UndecoratedSmoothedPWDB =
- ( ((pHalData->UndecoratedSmoothedPWDB)* 5) + (pPreviousRfd->Status.RxPWDBAll)) / 6;
- pHalData->UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB + 1;
- }
- else
- {
- pHalData->UndecoratedSmoothedPWDB =
- ( ((pHalData->UndecoratedSmoothedPWDB)* 5) + (pPreviousRfd->Status.RxPWDBAll)) / 6;
- }
-#endif
-
- }
-
- //
- // Check EVM
- //
- /* record the general EVM to the sliding window. */
- if(pprevious_stats->SignalQuality == 0)
- {
- }
- else
- {
- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA){
- if(slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX){
- slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX;
- last_evm = priv->stats.slide_evm[slide_evm_index];
- priv->stats.slide_evm_total -= last_evm;
- }
-
- priv->stats.slide_evm_total += pprevious_stats->SignalQuality;
-
- priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality;
- if(slide_evm_index >= PHY_RSSI_SLID_WIN_MAX)
- slide_evm_index = 0;
-
- // <1> Showed on UI for user, in percentage.
- tmp_val = priv->stats.slide_evm_total/slide_evm_statistics;
- priv->stats.signal_quality = tmp_val;
- //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality.
- priv->stats.last_signal_strength_inpercent = tmp_val;
- }
-
- // <2> Showed on UI for engineering
- if(pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA)
- {
- for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++) // 2 spatial stream
- {
- if(pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1)
- {
- if(priv->stats.rx_evm_percentage[nspatial_stream] == 0) // initialize
- {
- priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream];
- }
- priv->stats.rx_evm_percentage[nspatial_stream] =
- ( (priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) +
- (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor);
- }
- }
- }
- }
-
-
-}
-
-/*-----------------------------------------------------------------------------
- * Function: rtl819x_query_rxpwrpercentage()
- *
- * Overview:
- *
- * Input: char antpower
- *
- * Output: NONE
- *
- * Return: 0-100 percentage
- *
- * Revised History:
- * When Who Remark
- * 05/26/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static u8 rtl819x_query_rxpwrpercentage(
- char antpower
- )
-{
- if ((antpower <= -100) || (antpower >= 20))
- {
- return 0;
- }
- else if (antpower >= 0)
- {
- return 100;
- }
- else
- {
- return (100+antpower);
- }
-
-} /* QueryRxPwrPercentage */
-
-static u8
-rtl819x_evm_dbtopercentage(
- char value
- )
-{
- char ret_val;
-
- ret_val = value;
-
- if(ret_val >= 0)
- ret_val = 0;
- if(ret_val <= -33)
- ret_val = -33;
- ret_val = 0 - ret_val;
- ret_val*=3;
- if(ret_val == 99)
- ret_val = 100;
- return(ret_val);
-}
-//
-// Description:
-// We want good-looking for signal strength/quality
-// 2007/7/19 01:09, by cosa.
-//
-long
-rtl819x_signal_scale_mapping(
- long currsig
- )
-{
- long retsig;
-
- // Step 1. Scale mapping.
- if(currsig >= 61 && currsig <= 100)
- {
- retsig = 90 + ((currsig - 60) / 4);
- }
- else if(currsig >= 41 && currsig <= 60)
- {
- retsig = 78 + ((currsig - 40) / 2);
- }
- else if(currsig >= 31 && currsig <= 40)
- {
- retsig = 66 + (currsig - 30);
- }
- else if(currsig >= 21 && currsig <= 30)
- {
- retsig = 54 + (currsig - 20);
- }
- else if(currsig >= 5 && currsig <= 20)
- {
- retsig = 42 + (((currsig - 5) * 2) / 3);
- }
- else if(currsig == 4)
- {
- retsig = 36;
- }
- else if(currsig == 3)
- {
- retsig = 27;
- }
- else if(currsig == 2)
- {
- retsig = 18;
- }
- else if(currsig == 1)
- {
- retsig = 9;
- }
- else
- {
- retsig = currsig;
- }
-
- return retsig;
-}
-
-/*-----------------------------------------------------------------------------
- * Function: QueryRxPhyStatus8192S()
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 06/01/2007 MHC Create Version 0.
- * 06/05/2007 MHC Accordign to HW's new data sheet, we add CCK and OFDM
- * descriptor definition.
- * 07/04/2007 MHC According to Jerry and Bryant's document. We read
- * ir_isolation and ext_lna for RF's init value and use
- * to compensate RSSI after receiving packets.
- * 09/10/2008 MHC Modify name and PHY status field for 92SE.
- * 09/19/2008 MHC Add CCK/OFDM SS/SQ for 92S series.
- *
- *---------------------------------------------------------------------------*/
-static void rtl8192SU_query_rxphystatus(
- struct r8192_priv * priv,
- struct ieee80211_rx_stats * pstats,
- rx_desc_819x_usb *pDesc,
- rx_drvinfo_819x_usb * pdrvinfo,
- struct ieee80211_rx_stats * precord_stats,
- bool bpacket_match_bssid,
- bool bpacket_toself,
- bool bPacketBeacon,
- bool bToSelfBA
- )
-{
- //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status);
- //PHY_STS_CCK_8192S_T *pCck_buf;
- phy_sts_cck_819xusb_t * pcck_buf;
- phy_ofdm_rx_status_rxsc_sgien_exintfflag* prxsc;
- //u8 *prxpkt;
- //u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
- u8 i, max_spatial_stream, rxsc_sgien_exflg;
- char rx_pwr[4], rx_pwr_all=0;
- //long rx_avg_pwr = 0;
- //char rx_snrX, rx_evmX;
- u8 evm, pwdb_all;
- u32 RSSI, total_rssi=0;//, total_evm=0;
-// long signal_strength_index = 0;
- u8 is_cck_rate=0;
- u8 rf_rx_num = 0;
-
-
-
- priv->stats.numqry_phystatus++;
-
- is_cck_rate = rx_hal_is_cck_rate(pDesc);
-
- // Record it for next packet processing
- memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats));
- pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid;
- pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself;
- pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate;//RX_HAL_IS_CCK_RATE(pDrvInfo);
- pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon;
- pstats->bToSelfBA = precord_stats->bToSelfBA = bToSelfBA;
-
-
- pstats->RxMIMOSignalQuality[0] = -1;
- pstats->RxMIMOSignalQuality[1] = -1;
- precord_stats->RxMIMOSignalQuality[0] = -1;
- precord_stats->RxMIMOSignalQuality[1] = -1;
-
- if(is_cck_rate)
- {
- u8 report;//, tmp_pwdb;
- //char cck_adc_pwdb[4];
-
- // CCK Driver info Structure is not the same as OFDM packet.
- pcck_buf = (phy_sts_cck_819xusb_t *)pdrvinfo;
-
- //
- // (1)Hardware does not provide RSSI for CCK
- //
-
- //
- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
- //
-
- priv->stats.numqry_phystatusCCK++;
-
- if(!priv->bCckHighPower)
- {
- report = pcck_buf->cck_agc_rpt & 0xc0;
- report = report>>6;
- switch(report)
- {
- //Fixed by Jacken from Bryant 2008-03-20
- //Original value is -38 , -26 , -14 , -2
- //Fixed value is -35 , -23 , -11 , 6
- case 0x3:
- rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e);
- break;
- case 0x2:
- rx_pwr_all = -23 - (pcck_buf->cck_agc_rpt & 0x3e);
- break;
- case 0x1:
- rx_pwr_all = -11 - (pcck_buf->cck_agc_rpt & 0x3e);
- break;
- case 0x0:
- rx_pwr_all = 8 - (pcck_buf->cck_agc_rpt & 0x3e);//6->8
- break;
- }
- }
- else
- {
- report = pdrvinfo->cfosho[0] & 0x60;
- report = report>>5;
- switch(report)
- {
- case 0x3:
- rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
- break;
- case 0x2:
- rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1);
- break;
- case 0x1:
- rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;
- break;
- case 0x0:
- rx_pwr_all = -8 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1) ;//6->-8
- break;
- }
- }
-
- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);//check it
- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
- //pstats->RecvSignalPower = pwdb_all;
- pstats->RecvSignalPower = rx_pwr_all;
-
- //
- // (3) Get Signal Quality (EVM)
- //
- //if(bpacket_match_bssid)
- {
- u8 sq;
-
- if(pstats->RxPWDBAll > 40)
- {
- sq = 100;
- }else
- {
- sq = pcck_buf->sq_rpt;
-
- if(pcck_buf->sq_rpt > 64)
- sq = 0;
- else if (pcck_buf->sq_rpt < 20)
- sq = 100;
- else
- sq = ((64-sq) * 100) / 44;
- }
- pstats->SignalQuality = precord_stats->SignalQuality = sq;
- pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq;
- pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1;
- }
- }
- else
- {
- priv->stats.numqry_phystatusHT++;
-
- // 2008/09/19 MH For 92S debug, RX RF path always enable!!
- priv->brfpath_rxenable[0] = priv->brfpath_rxenable[1] = TRUE;
-
- //
- // (1)Get RSSI for HT rate
- //
- //for(i=RF90_PATH_A; i<priv->NumTotalRFPath; i++)
- for(i=RF90_PATH_A; i<RF90_PATH_MAX; i++)
- {
- // 2008/01/30 MH we will judge RF RX path now.
- if (priv->brfpath_rxenable[i])
- rf_rx_num++;
- //else
- // continue;
-
- //if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
- // continue;
-
- //Fixed by Jacken from Bryant 2008-03-20
- //Original value is 106
- //rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106;
- rx_pwr[i] = ((pdrvinfo->gain_trsw[i]&0x3F)*2) - 110;
-
- /* Translate DBM to percentage. */
- RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]); //check ok
- total_rssi += RSSI;
- RT_TRACE(COMP_RF, "RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI);
-
- //Get Rx snr value in DB
- //tmp_rxsnr = pofdm_buf->rxsnr_X[i];
- //rx_snrX = (char)(tmp_rxsnr);
- //rx_snrX /= 2;
- //priv->stats.rxSNRdB[i] = (long)rx_snrX;
- priv->stats.rxSNRdB[i] = (long)(pdrvinfo->rxsnr[i]/2);
-
- /* Translate DBM to percentage. */
- //RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]);
- //total_rssi += RSSI;
-
- /* Record Signal Strength for next packet */
- //if(bpacket_match_bssid)
- {
- pstats->RxMIMOSignalStrength[i] =(u8) RSSI;
- precord_stats->RxMIMOSignalStrength[i] =(u8) RSSI;
- }
- }
-
-
- //
- // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
- //
- //Fixed by Jacken from Bryant 2008-03-20
- //Original value is 106
- //rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106;
- rx_pwr_all = (((pdrvinfo->pwdb_all ) >> 1 )& 0x7f) -106;
- pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all);
-
- pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all;
- pstats->RxPower = precord_stats->RxPower = rx_pwr_all;
- pstats->RecvSignalPower = rx_pwr_all;
-
- //
- // (3)EVM of HT rate
- //
- //if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 &&
- // pdrvinfo->RxRate<=DESC90_RATEMCS15)
- if(pDesc->RxHT && pDesc->RxMCS>=DESC92S_RATEMCS8 &&
- pDesc->RxMCS<=DESC92S_RATEMCS15)
- max_spatial_stream = 2; //both spatial stream make sense
- else
- max_spatial_stream = 1; //only spatial stream 1 makes sense
-
- for(i=0; i<max_spatial_stream; i++)
- {
- //tmp_rxevm = pofdm_buf->rxevm_X[i];
- //rx_evmX = (char)(tmp_rxevm);
-
- // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
- // fill most significant bit to "zero" when doing shifting operation which may change a negative
- // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
- //rx_evmX /= 2; //dbm
-
- //evm = rtl819x_evm_dbtopercentage(rx_evmX);
- evm = rtl819x_evm_dbtopercentage( (pdrvinfo->rxevm[i] /*/ 2*/)); //dbm
- RT_TRACE(COMP_RF, "RXRATE=%x RXEVM=%x EVM=%s%d\n", pDesc->RxMCS, pdrvinfo->rxevm[i], "%", evm);
-
- //if(bpacket_match_bssid)
- {
- if(i==0) // Fill value in RFD, Get the first spatial stream only
- pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff);
- pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff);
- }
- }
-
-
- /* record rx statistics for debug */
- //rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
- prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg;
- //if(pdrvinfo->BW) //40M channel
- if(pDesc->BW) //40M channel
- priv->stats.received_bwtype[1+pdrvinfo->rxsc]++;
- else //20M channel
- priv->stats.received_bwtype[0]++;
- }
-
- //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
- //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
- if(is_cck_rate)
- {
- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all));//PWDB_ALL;//check ok
-
- }
- else
- {
- //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u8)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u8)(total_rssi/=RF90_PATH_MAX);
- // We can judge RX path number now.
- if (rf_rx_num != 0)
- pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi/=rf_rx_num)));
- }
-}/* QueryRxPhyStatus8192S */
-
-void
-rtl8192_record_rxdesc_forlateruse(
- struct ieee80211_rx_stats * psrc_stats,
- struct ieee80211_rx_stats * ptarget_stats
-)
-{
- ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
- ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
- ptarget_stats->Seq_Num = psrc_stats->Seq_Num;
-}
-
-static void rtl8192SU_query_rxphystatus(
- struct r8192_priv * priv,
- struct ieee80211_rx_stats * pstats,
- rx_desc_819x_usb *pDesc,
- rx_drvinfo_819x_usb * pdrvinfo,
- struct ieee80211_rx_stats * precord_stats,
- bool bpacket_match_bssid,
- bool bpacket_toself,
- bool bPacketBeacon,
- bool bToSelfBA
- );
-void rtl8192SU_TranslateRxSignalStuff(struct sk_buff *skb,
- struct ieee80211_rx_stats * pstats,
- rx_desc_819x_usb *pDesc,
- rx_drvinfo_819x_usb *pdrvinfo)
-{
- // TODO: We must only check packet for current MAC address. Not finish
- rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
- struct net_device *dev=info->dev;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- bool bpacket_match_bssid, bpacket_toself;
- bool bPacketBeacon=FALSE, bToSelfBA=FALSE;
- static struct ieee80211_rx_stats previous_stats;
- struct ieee80211_hdr_3addr *hdr;//by amy
- u16 fc,type;
-
- // Get Signal Quality for only RX data queue (but not command queue)
-
- u8* tmp_buf;
- //u16 tmp_buf_len = 0;
- u8 *praddr;
-
- /* Get MAC frame start address. */
- tmp_buf = (u8*)skb->data;// + get_rxpacket_shiftbytes_819xusb(pstats);
-
- hdr = (struct ieee80211_hdr_3addr *)tmp_buf;
- fc = le16_to_cpu(hdr->frame_control);
- type = WLAN_FC_GET_TYPE(fc);
- praddr = hdr->addr1;
-
- /* Check if the received packet is acceptabe. */
- bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) &&
- (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3))
- && (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV));
- bpacket_toself = bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
-
-#if 1//cosa
- if(WLAN_FC_GET_FRAMETYPE(fc)== IEEE80211_STYPE_BEACON)
- {
- bPacketBeacon = true;
- //DbgPrint("Beacon 2, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
- }
- if(WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BLOCKACK)
- {
- if((eqMacAddr(praddr,dev->dev_addr)))
- bToSelfBA = true;
- //DbgPrint("BlockAck, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
- }
-
-#endif
-
-
- if(bpacket_match_bssid)
- {
- priv->stats.numpacket_matchbssid++;
- }
- if(bpacket_toself){
- priv->stats.numpacket_toself++;
- }
- //
- // Process PHY information for previous packet (RSSI/PWDB/EVM)
- //
- // Because phy information is contained in the last packet of AMPDU only, so driver
- // should process phy information of previous packet
- rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats);
- rtl8192SU_query_rxphystatus(priv, pstats, pDesc, pdrvinfo, &previous_stats, bpacket_match_bssid,bpacket_toself,bPacketBeacon,bToSelfBA);
- rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats);
-
-}
-
-/**
-* Function: UpdateReceivedRateHistogramStatistics
-* Overview: Recored down the received data rate
-*
-* Input:
-* struct net_device *dev
-* struct ieee80211_rx_stats *stats
-*
-* Output:
-*
-* (priv->stats.ReceivedRateHistogram[] is updated)
-* Return:
-* None
-*/
-void
-UpdateReceivedRateHistogramStatistics8190(
- struct net_device *dev,
- struct ieee80211_rx_stats *stats
- )
-{
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- u32 rcvType=1; //0: Total, 1:OK, 2:CRC, 3:ICV
- u32 rateIndex;
- u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI
-
-
- if(stats->bCRC)
- rcvType = 2;
- else if(stats->bICV)
- rcvType = 3;
-
- if(stats->bShortPreamble)
- preamble_guardinterval = 1;// short
- else
- preamble_guardinterval = 0;// long
-
- switch(stats->rate)
- {
- //
- // CCK rate
- //
- case MGN_1M: rateIndex = 0; break;
- case MGN_2M: rateIndex = 1; break;
- case MGN_5_5M: rateIndex = 2; break;
- case MGN_11M: rateIndex = 3; break;
- //
- // Legacy OFDM rate
- //
- case MGN_6M: rateIndex = 4; break;
- case MGN_9M: rateIndex = 5; break;
- case MGN_12M: rateIndex = 6; break;
- case MGN_18M: rateIndex = 7; break;
- case MGN_24M: rateIndex = 8; break;
- case MGN_36M: rateIndex = 9; break;
- case MGN_48M: rateIndex = 10; break;
- case MGN_54M: rateIndex = 11; break;
- //
- // 11n High throughput rate
- //
- case MGN_MCS0: rateIndex = 12; break;
- case MGN_MCS1: rateIndex = 13; break;
- case MGN_MCS2: rateIndex = 14; break;
- case MGN_MCS3: rateIndex = 15; break;
- case MGN_MCS4: rateIndex = 16; break;
- case MGN_MCS5: rateIndex = 17; break;
- case MGN_MCS6: rateIndex = 18; break;
- case MGN_MCS7: rateIndex = 19; break;
- case MGN_MCS8: rateIndex = 20; break;
- case MGN_MCS9: rateIndex = 21; break;
- case MGN_MCS10: rateIndex = 22; break;
- case MGN_MCS11: rateIndex = 23; break;
- case MGN_MCS12: rateIndex = 24; break;
- case MGN_MCS13: rateIndex = 25; break;
- case MGN_MCS14: rateIndex = 26; break;
- case MGN_MCS15: rateIndex = 27; break;
- default: rateIndex = 28; break;
- }
- priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++;
- priv->stats.received_rate_histogram[0][rateIndex]++; //total
- priv->stats.received_rate_histogram[rcvType][rateIndex]++;
-}
-
-void rtl8192SU_query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe)
-{
- rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
- struct net_device *dev=info->dev;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- //rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
- rx_drvinfo_819x_usb *driver_info = NULL;
-
- //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
- //PHAL_DATA_8192SUSB pHalData = GET_HAL_DATA(Adapter);
- //pu1Byte pDesc = (pu1Byte)pDescIn;
- //PRX_DRIVER_INFO_8192S pDrvInfo;
-
- rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
-
- if(0)
- {
- int m = 0;
- printk("========================");
- for(m=0; m<skb->len; m++){
- if((m%32) == 0)
- printk("\n");
- printk("%2x ",((u8*)skb->data)[m]);
- }
- printk("\n========================\n");
-
- }
-
-
- //
- //Get Rx Descriptor Raw Information
- //
- stats->Length = desc->Length ;
- stats->RxDrvInfoSize = desc->RxDrvInfoSize*RX_DRV_INFO_SIZE_UNIT;
- stats->RxBufShift = (desc->Shift)&0x03;
- stats->bICV = desc->ICV;
- stats->bCRC = desc->CRC32;
- stats->bHwError = stats->bCRC|stats->bICV;
- stats->Decrypted = !desc->SWDec;//RTL8190 set this bit to indicate that Hw does not decrypt packet
- stats->bIsAMPDU = (desc->AMSDU==1);
- stats->bFirstMPDU = (desc->PAGGR==1) && (desc->FAGGR==1);
- stats->bShortPreamble = desc->SPLCP;
- stats->RxIs40MHzPacket = (desc->BW==1);
- stats->TimeStampLow = desc->TSFL;
-
- if((desc->FAGGR==1) || (desc->PAGGR==1))
- {// Rx A-MPDU
- RT_TRACE(COMP_RXDESC, "FirstAGGR = %d, PartAggr = %d\n", desc->FAGGR, desc->PAGGR);
- }
-//YJ,test,090310
-if(stats->bHwError)
-{
- if(stats->bICV)
- printk("%s: Receive ICV error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__);
- if(stats->bCRC)
- printk("%s: Receive CRC error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__);
-}
-
- if(IS_UNDER_11N_AES_MODE(priv->ieee80211))
- {
- // Always received ICV error packets in AES mode.
- // This fixed HW later MIC write bug.
- if(stats->bICV && !stats->bCRC)
- {
- stats->bICV = FALSE;
- stats->bHwError = FALSE;
- }
- }
-
- // Transform HwRate to MRate
- if(!stats->bHwError)
- //stats->DataRate = HwRateToMRate(
- // (BOOLEAN)GET_RX_DESC_RXHT(pDesc),
- // (u1Byte)GET_RX_DESC_RXMCS(pDesc),
- // (BOOLEAN)GET_RX_DESC_PAGGR(pDesc));
- stats->rate = rtl8192SU_HwRateToMRate(desc->RxHT, desc->RxMCS, desc->PAGGR);
- else
- stats->rate = MGN_1M;
-
- //
- // Collect Rx rate/AMPDU/TSFL
- //
- //UpdateRxdRateHistogramStatistics8192S(Adapter, pRfd);
- //UpdateRxAMPDUHistogramStatistics8192S(Adapter, pRfd);
- //UpdateRxPktTimeStamp8192S(Adapter, pRfd);
- UpdateReceivedRateHistogramStatistics8190(dev, stats);
- //UpdateRxAMPDUHistogramStatistics8192S(dev, stats); //FIXLZM
- UpdateRxPktTimeStamp8190(dev, stats);
-
- //
- // Get PHY Status and RSVD parts.
- // <Roger_Notes> It only appears on last aggregated packet.
- //
- if (desc->PHYStatus)
- {
- //driver_info = (rx_drvinfo_819x_usb *)(skb->data + RX_DESC_SIZE + stats->RxBufShift);
- driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) + \
- stats->RxBufShift);
- if(0)
- {
- int m = 0;
- printk("========================\n");
- printk("RX_DESC_SIZE:%d, RxBufShift:%d, RxDrvInfoSize:%d\n",
- RX_DESC_SIZE, stats->RxBufShift, stats->RxDrvInfoSize);
- for(m=0; m<32; m++){
- printk("%2x ",((u8*)driver_info)[m]);
- }
- printk("\n========================\n");
-
- }
-
- }
-
- //YJ,add,090107
- skb_pull(skb, sizeof(rx_desc_819x_usb));
- //YJ,add,090107,end
-
- //
- // Get Total offset of MPDU Frame Body
- //
- if((stats->RxBufShift + stats->RxDrvInfoSize) > 0)
- {
- stats->bShift = 1;
- //YJ,add,090107
- skb_pull(skb, stats->RxBufShift + stats->RxDrvInfoSize);
- //YJ,add,090107,end
- }
-
- //
- // Get PHY Status and RSVD parts.
- // <Roger_Notes> It only appears on last aggregated packet.
- //
- if (desc->PHYStatus)
- {
- rtl8192SU_TranslateRxSignalStuff(skb, stats, desc, driver_info);
- }
-}
-
-//
-// Description:
-// The strarting address of wireless lan header will shift 1 or 2 or 3 or "more" bytes for the following reason :
-// (1) QoS control : shift 2 bytes
-// (2) Mesh Network : shift 1 or 3 bytes
-// (3) RxDriverInfo occupies the front parts of Rx Packets buffer(shift units is in 8Bytes)
-//
-// It is because Lextra CPU used by 8186 or 865x series assert exception if the statrting address
-// of IP header is not double word alignment.
-// This features is supported in 818xb and 8190 only, but not 818x.
-//
-// parameter: PRT_RFD, Pointer of Reeceive frame descriptor which is initialized according to
-// Rx Descriptor
-// return value: unsigned int, number of total shifted bytes
-//
-// Notes: 2008/06/28, created by Roger
-//
-u32 GetRxPacketShiftBytes8192SU(struct ieee80211_rx_stats *Status, bool bIsRxAggrSubframe)
-{
- //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
-
- return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize + Status->RxBufShift);
-}
-
-void rtl8192SU_rx_nomal(struct sk_buff* skb)
-{
- rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
- struct net_device *dev=info->dev;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct ieee80211_rx_stats stats = {
- .signal = 0,
- .noise = -98,
- .rate = 0,
- // .mac_time = jiffies,
- .freq = IEEE80211_24GHZ_BAND,
- };
- u32 rx_pkt_len = 0;
- struct ieee80211_hdr_1addr *ieee80211_hdr = NULL;
- bool unicast_packet = false;
-
- //printk("**********skb->len = %d\n", skb->len);
- /* 20 is for ps-poll */
- if((skb->len >=(20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) {
-
- /* first packet should not contain Rx aggregation header */
- rtl8192SU_query_rxdesc_status(skb, &stats, false);
- /* TODO */
-
- /* hardware related info */
- priv->stats.rxoktotal++; //YJ,test,090108
-
- /* Process the MPDU recevied */
- skb_trim(skb, skb->len - 4/*sCrcLng*/);//FIXLZM
-
- rx_pkt_len = skb->len;
- ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
- unicast_packet = false;
- if(is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
- //TODO
- }else if(is_multicast_ether_addr(ieee80211_hdr->addr1)){
- //TODO
- }else {
- /* unicast packet */
- unicast_packet = true;
- }
-
- if(!ieee80211_rtl_rx(priv->ieee80211,skb, &stats)) {
- dev_kfree_skb_any(skb);
- } else {
- // priv->stats.rxoktotal++; //YJ,test,090108
- if(unicast_packet) {
- priv->stats.rxbytesunicast += rx_pkt_len;
- }
- }
-
- //up is firs pkt, follow is next and next
- }
- else
- {
- priv->stats.rxurberr++;
- printk("actual_length:%d\n", skb->len);
- dev_kfree_skb_any(skb);
- }
-
-}
-
-void
-rtl819xusb_process_received_packet(
- struct net_device *dev,
- struct ieee80211_rx_stats *pstats
- )
-{
-// bool bfreerfd=false, bqueued=false;
- u8* frame;
- u16 frame_len=0;
- struct r8192_priv *priv = ieee80211_priv(dev);
-// u8 index = 0;
-// u8 TID = 0;
- //u16 seqnum = 0;
- //PRX_TS_RECORD pts = NULL;
-
- // Get shifted bytes of Starting address of 802.11 header. 2006.09.28, by Emily
- //porting by amy 080508
- pstats->virtual_address += get_rxpacket_shiftbytes_819xusb(pstats);
- frame = pstats->virtual_address;
- frame_len = pstats->packetlength;
-#ifdef TODO // by amy about HCT
- if(!Adapter->bInHctTest)
- CountRxErrStatistics(Adapter, pRfd);
-#endif
- {
- #ifdef ENABLE_PS //by amy for adding ps function in future
- RT_RF_POWER_STATE rtState;
- // When RF is off, we should not count the packet for hw/sw synchronize
- // reason, ie. there may be a duration while sw switch is changed and hw
- // switch is being changed. 2006.12.04, by shien chang.
- Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (u8* )(&rtState));
- if (rtState == eRfOff)
- {
- return;
- }
- #endif
- priv->stats.rxframgment++;
-
- }
-#ifdef TODO
- RmMonitorSignalStrength(Adapter, pRfd);
-#endif
- /* 2007/01/16 MH Add RX command packet handle here. */
- /* 2007/03/01 MH We have to release RFD and return if rx pkt is cmd pkt. */
- if (rtl819xusb_rx_command_packet(dev, pstats))
- {
- return;
- }
-
-#ifdef SW_CRC_CHECK
- SwCrcCheck();
-#endif
-
-
-}
-
-void query_rx_cmdpkt_desc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats)
-{
-// rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
-// struct net_device *dev=info->dev;
-// struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
-// rx_drvinfo_819x_usb *driver_info;
-
- //
- //Get Rx Descriptor Information
- //
- stats->virtual_address = (u8*)skb->data;
- stats->Length = desc->Length;
- stats->RxDrvInfoSize = 0;
- stats->RxBufShift = 0;
- stats->packetlength = stats->Length-scrclng;
- stats->fraglength = stats->packetlength;
- stats->fragoffset = 0;
- stats->ntotalfrag = 1;
-}
-
-void rtl8192SU_rx_cmd(struct sk_buff *skb)
-{
- struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
- struct net_device *dev = info->dev;
-
- /* TODO */
- struct ieee80211_rx_stats stats = {
- .signal = 0,
- .noise = -98,
- .rate = 0,
- // .mac_time = jiffies,
- .freq = IEEE80211_24GHZ_BAND,
- };
-
- //
- // Check buffer length to determine if this is a valid MPDU.
- //
- if( (skb->len >= sizeof(rx_desc_819x_usb)) && (skb->len <= RX_URB_SIZE) )//&&
- //(pHalData->SwChnlInProgress == FALSE))
- {
- //
- // Collection information in Rx descriptor.
- //
- query_rx_cmdpkt_desc_status(skb,&stats);
- // this is to be done by amy 080508 prfd->queue_id = 1;
-
- //
- // Process the MPDU recevied.
- //
- rtl819xusb_process_received_packet(dev,&stats);
-
- dev_kfree_skb_any(skb);
- }
- else
- {
- //RTInsertTailListWithCnt(&pAdapter->RfdIdleQueue, &pRfd->List, &pAdapter->NumIdleRfd);
- //RT_ASSERT(pAdapter->NumIdleRfd <= pAdapter->NumRfd, ("HalUsbInCommandComplete8192SUsb(): Adapter->NumIdleRfd(%d)\n", pAdapter->NumIdleRfd));
- //RT_TRACE(COMP_RECV, DBG_LOUD, ("HalUsbInCommandComplete8192SUsb(): NOT enough Resources!! BufLenUsed(%d), NumIdleRfd(%d)\n",
- //pContext->BufLenUsed, pAdapter->NumIdleRfd));
- }
-
- //
- // Reuse USB_IN_CONTEXT since we had finished processing the
- // buffer in USB_IN_CONTEXT.
- //
- //HalUsbReturnInContext(pAdapter, pContext);
-
- //
- // Issue another bulk IN transfer.
- //
- //HalUsbInMpdu(pAdapter, PipeIndex);
-
- RT_TRACE(COMP_RECV, "<--- HalUsbInCommandComplete8192SUsb()\n");
-
-}
-
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
-{
- struct sk_buff *skb;
- struct rtl8192_rx_info *info;
-
- while (NULL != (skb = skb_dequeue(&priv->skb_queue))) {
- info = (struct rtl8192_rx_info *)skb->cb;
- switch (info->out_pipe) {
- /* Nomal packet pipe */
- case 3:
- //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe);
- priv->IrpPendingCount--;
- priv->ops->rtl819x_rx_nomal(skb);
- break;
-
- /* Command packet pipe */
- case 9:
- RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\
- info->out_pipe);
- priv->ops->rtl819x_rx_cmd(skb);
- break;
-
- default: /* should never get here! */
- RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\
- info->out_pipe);
- dev_kfree_skb(skb);
- break;
-
- }
- }
-}
-
-
-
-/****************************************************************************
- ---------------------------- USB_STUFF---------------------------
-*****************************************************************************/
-//LZM Merge from windows HalUsbSetQueuePipeMapping8192SUsb 090319
-static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface *intf, struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct usb_host_interface *iface_desc;
- struct usb_endpoint_descriptor *endpoint;
- u8 i = 0;
-
- priv->ep_in_num = 0;
- priv->ep_out_num = 0;
- memset(priv->RtOutPipes,0,16);
- memset(priv->RtInPipes,0,16);
-
- iface_desc = intf->cur_altsetting;
- priv->ep_num = iface_desc->desc.bNumEndpoints;
-
- for (i = 0; i < priv->ep_num; ++i) {
- endpoint = &iface_desc->endpoint[i].desc;
- if (usb_endpoint_is_bulk_in(endpoint)) {
- priv->RtInPipes[priv->ep_in_num] = usb_endpoint_num(endpoint);
- priv->ep_in_num ++;
- //printk("in_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
- } else if (usb_endpoint_is_bulk_out(endpoint)) {
- priv->RtOutPipes[priv->ep_out_num] = usb_endpoint_num(endpoint);
- priv->ep_out_num ++;
- //printk("out_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
- }
- }
- {
- memset(priv->txqueue_to_outpipemap,0,9);
- if (priv->ep_num == 6) {
- // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
- u8 queuetopipe[] = {3, 2, 1, 0, 4, 4, 4, 4, 4};
-
- memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
- } else if (priv->ep_num == 4) {
- // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
- u8 queuetopipe[] = {1, 1, 0, 0, 2, 2, 2, 2, 2};
-
- memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
- } else if (priv->ep_num > 9) {
- // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
- u8 queuetopipe[] = {3, 2, 1, 0, 4, 8, 7, 6, 5};
-
- memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
- } else {//use sigle pipe
- // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
- u8 queuetopipe[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
- memcpy(priv->txqueue_to_outpipemap,queuetopipe,9);
- }
- }
- printk("==>ep_num:%d, in_ep_num:%d, out_ep_num:%d\n", priv->ep_num, priv->ep_in_num, priv->ep_out_num);
-
- printk("==>RtInPipes:");
- for(i=0; i < priv->ep_in_num; i++)
- printk("%d ", priv->RtInPipes[i]);
- printk("\n");
-
- printk("==>RtOutPipes:");
- for(i=0; i < priv->ep_out_num; i++)
- printk("%d ", priv->RtOutPipes[i]);
- printk("\n");
-
- printk("==>txqueue_to_outpipemap for BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON:\n");
- for(i=0; i < 9; i++)
- printk("%d ", priv->txqueue_to_outpipemap[i]);
- printk("\n");
-
- return;
-}
-
-static const struct net_device_ops rtl8192_netdev_ops = {
- .ndo_open = rtl8192_open,
- .ndo_stop = rtl8192_close,
- .ndo_get_stats = rtl8192_stats,
- .ndo_tx_timeout = tx_timeout,
- .ndo_do_ioctl = rtl8192_ioctl,
- .ndo_set_multicast_list = r8192_set_multicast,
- .ndo_set_mac_address = r8192_set_mac_adr,
- .ndo_validate_addr = eth_validate_addr,
- .ndo_change_mtu = eth_change_mtu,
- .ndo_start_xmit = rtl8192_ieee80211_rtl_xmit,
-};
-
-static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
-// unsigned long ioaddr = 0;
- struct net_device *dev = NULL;
- struct r8192_priv *priv= NULL;
- struct usb_device *udev = interface_to_usbdev(intf);
-
- RT_TRACE(COMP_INIT, "Oops: i'm coming\n");
-
- dev = alloc_ieee80211(sizeof(struct r8192_priv));
- if (dev == NULL)
- return -ENOMEM;
-
- usb_set_intfdata(intf, dev);
- SET_NETDEV_DEV(dev, &intf->dev);
- priv = ieee80211_priv(dev);
- priv->ieee80211 = netdev_priv(dev);
- priv->udev=udev;
-
- HalUsbSetQueuePipeMapping8192SUsb(intf, dev);
-
- //printk("===============>NIC 8192SU\n");
- priv->ops = &rtl8192su_ops;
-
- dev->netdev_ops = &rtl8192_netdev_ops;
-
- //DMESG("Oops: i'm coming\n");
- dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def;
-
- dev->type=ARPHRD_ETHER;
-
- dev->watchdog_timeo = HZ*3; //modified by john, 0805
-
- if (dev_alloc_name(dev, ifname) < 0){
- RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n");
- strcpy(ifname, "wlan%d");
- dev_alloc_name(dev, ifname);
- }
-
- RT_TRACE(COMP_INIT, "Driver probe completed1\n");
-#if 1
- if(rtl8192_init(dev)!=0){
- RT_TRACE(COMP_ERR, "Initialization failed");
- goto fail;
- }
-#endif
- netif_carrier_off(dev);
- netif_stop_queue(dev);
-
- if (register_netdev(dev))
- goto fail;
- RT_TRACE(COMP_INIT, "dev name=======> %s\n",dev->name);
- rtl8192_proc_init_one(dev);
-
-
- RT_TRACE(COMP_INIT, "Driver probe completed\n");
- return 0;
-fail:
- free_ieee80211(dev);
-
- RT_TRACE(COMP_ERR, "wlan driver load failed\n");
- return -ENODEV;
-}
-
-//detach all the work and timer structure declared or inititialize in r8192U_init function.
-void rtl8192_cancel_deferred_work(struct r8192_priv* priv)
-{
- cancel_work_sync(&priv->reset_wq);
- cancel_work_sync(&priv->qos_activate);
- cancel_delayed_work(&priv->watch_dog_wq);
- cancel_delayed_work(&priv->update_beacon_wq);
- cancel_delayed_work(&priv->ieee80211->hw_wakeup_wq);
- cancel_delayed_work(&priv->ieee80211->hw_sleep_wq);
- //cancel_work_sync(&priv->SetBWModeWorkItem);
- //cancel_work_sync(&priv->SwChnlWorkItem);
-}
-
-static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf)
-{
- struct net_device *dev = usb_get_intfdata(intf);
- struct r8192_priv *priv = ieee80211_priv(dev);
- if(dev){
-
- unregister_netdev(dev);
-
- RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n");
- rtl8192_proc_remove_one(dev);
-
- rtl8192_down(dev);
- if (priv->pFirmware)
- {
- vfree(priv->pFirmware);
- priv->pFirmware = NULL;
- }
- // priv->rf_close(dev);
-// rtl8192_SetRFPowerState(dev, eRfOff);
- destroy_workqueue(priv->priv_wq);
- //rtl8192_irq_disable(dev);
- //rtl8192_reset(dev);
- mdelay(10);
-
- }
- free_ieee80211(dev);
- RT_TRACE(COMP_DOWN, "wlan driver removed\n");
-}
-
-/* fun with the built-in ieee80211 stack... */
-extern int ieee80211_debug_init(void);
-extern void ieee80211_debug_exit(void);
-extern int ieee80211_crypto_init(void);
-extern void ieee80211_crypto_deinit(void);
-extern int ieee80211_crypto_tkip_init(void);
-extern void ieee80211_crypto_tkip_exit(void);
-extern int ieee80211_crypto_ccmp_init(void);
-extern void ieee80211_crypto_ccmp_exit(void);
-extern int ieee80211_crypto_wep_init(void);
-extern void ieee80211_crypto_wep_exit(void);
-
-static int __init rtl8192_usb_module_init(void)
-{
- int ret;
-
-#ifdef CONFIG_IEEE80211_DEBUG
- ret = ieee80211_debug_init();
- if (ret) {
- printk(KERN_ERR "ieee80211_debug_init() failed %d\n", ret);
- return ret;
- }
-#endif
- ret = ieee80211_crypto_init();
- if (ret) {
- printk(KERN_ERR "ieee80211_crypto_init() failed %d\n", ret);
- goto fail_crypto;
- }
-
- ret = ieee80211_crypto_tkip_init();
- if (ret) {
- printk(KERN_ERR "ieee80211_crypto_tkip_init() failed %d\n",
- ret);
- goto fail_crypto_tkip;
- }
-
- ret = ieee80211_crypto_ccmp_init();
- if (ret) {
- printk(KERN_ERR "ieee80211_crypto_ccmp_init() failed %d\n",
- ret);
- goto fail_crypto_ccmp;
- }
-
- ret = ieee80211_crypto_wep_init();
- if (ret) {
- printk(KERN_ERR "ieee80211_crypto_wep_init() failed %d\n", ret);
- goto fail_crypto_wep;
- }
-
- printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n");
- printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n");
- RT_TRACE(COMP_INIT, "Initializing module");
- RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT);
-
- ret = rtl8192_proc_module_init();
- if (ret) {
- pr_err("rtl8192_proc_module_init() failed %d\n", ret);
- goto fail_proc;
- }
-
- ret = usb_register(&rtl8192_usb_driver);
- if (ret) {
- pr_err("usb_register() failed %d\n", ret);
- goto fail_usb;
- }
-
- return 0;
-
-fail_usb:
- rtl8192_proc_module_remove();
-fail_proc:
- ieee80211_crypto_wep_exit();
-fail_crypto_wep:
- ieee80211_crypto_ccmp_exit();
-fail_crypto_ccmp:
- ieee80211_crypto_tkip_exit();
-fail_crypto_tkip:
- ieee80211_crypto_deinit();
-fail_crypto:
-#ifdef CONFIG_IEEE80211_DEBUG
- ieee80211_debug_exit();
-#endif
- return ret;
-}
-
-
-static void __exit rtl8192_usb_module_exit(void)
-{
- usb_deregister(&rtl8192_usb_driver);
-
- RT_TRACE(COMP_DOWN, "Exiting");
- rtl8192_proc_module_remove();
-
- ieee80211_crypto_tkip_exit();
- ieee80211_crypto_ccmp_exit();
- ieee80211_crypto_wep_exit();
- ieee80211_crypto_deinit();
-#ifdef CONFIG_IEEE80211_DEBUG
- ieee80211_debug_exit();
-#endif
-}
-
-
-void rtl8192_try_wake_queue(struct net_device *dev, int pri)
-{
- unsigned long flags;
- short enough_desc;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
- spin_lock_irqsave(&priv->tx_lock,flags);
- enough_desc = check_nic_enough_desc(dev,pri);
- spin_unlock_irqrestore(&priv->tx_lock,flags);
-
- if(enough_desc)
- ieee80211_rtl_wake_queue(priv->ieee80211);
-}
-
-void EnableHWSecurityConfig8192(struct net_device *dev)
-{
- u8 SECR_value = 0x0;
- struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
-
- SECR_value = SCR_TxEncEnable | SCR_RxDecEnable;
- switch (ieee->pairwise_key_type) {
- case KEY_TYPE_WEP40:
- case KEY_TYPE_WEP104:
- if (priv->ieee80211->auth_mode != 2) {
- SECR_value |= SCR_RxUseDK;
- SECR_value |= SCR_TxUseDK;
- }
- break;
- case KEY_TYPE_TKIP:
- case KEY_TYPE_CCMP:
- if (ieee->iw_mode == IW_MODE_ADHOC) {
- SECR_value |= SCR_RxUseDK;
- SECR_value |= SCR_TxUseDK;
- }
- break;
- default:
- break;
- }
-
- /*
- * add HWSec active enable here.
- * default using hwsec.
- * when peer AP is in N mode only and pairwise_key_type is none_aes
- * (which HT_IOT_ACT_PURE_N_MODE indicates it),
- * use software security.
- * when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes
- * use g mode hw security.
- */
- ieee->hwsec_active = 1;
-
- /* add hwsec_support flag to totol control hw_sec on/off */
- if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) {
- ieee->hwsec_active = 0;
- SECR_value &= ~SCR_RxDecEnable;
- }
-
- RT_TRACE(COMP_SEC, "%s(): hwsec: %d, pairwise_key: %d, "
- "SECR_value: %x",
- __func__, ieee->hwsec_active,
- ieee->pairwise_key_type, SECR_value);
-
- write_nic_byte(dev, SECR, SECR_value); /* SECR_value | SCR_UseDK ); */
-}
-
-
-void setKey(struct net_device *dev,
- u8 EntryNo,
- u8 KeyIndex,
- u16 KeyType,
- u8 *MacAddr,
- u8 DefaultKey,
- u32 *KeyContent)
-{
- u32 TargetCommand = 0;
- u32 TargetContent = 0;
- u16 usConfig = 0;
- u8 i;
-
- if (EntryNo >= TOTAL_CAM_ENTRY)
- RT_TRACE(COMP_ERR, "%s(): cam entry exceeds TOTAL_CAM_ENTRY",
- __func__);
-
- RT_TRACE(COMP_SEC, "%s(): dev: %p, EntryNo: %d, "
- "KeyIndex: %d, KeyType: %d, MacAddr: %pM",
- __func__, dev, EntryNo,
- KeyIndex, KeyType, MacAddr);
-
- if (DefaultKey)
- usConfig |= BIT15 | (KeyType << 2);
- else
- usConfig |= BIT15 | (KeyType << 2) | KeyIndex;
-
- for (i = 0 ; i < CAM_CONTENT_COUNT; i++) {
- TargetCommand = i + CAM_CONTENT_COUNT * EntryNo;
- TargetCommand |= BIT31|BIT16;
- switch (i) {
- case 0: /* MAC|Config */
- TargetContent = (u32)(*(MacAddr + 0)) << 16|
- (u32)(*(MacAddr + 1)) << 24|
- (u32)usConfig;
-
- write_nic_dword(dev, WCAMI, TargetContent);
- write_nic_dword(dev, RWCAM, TargetCommand);
- continue;
- case 1: /* MAC */
- TargetContent = (u32)(*(MacAddr + 2))|
- (u32)(*(MacAddr + 3)) << 8|
- (u32)(*(MacAddr + 4)) << 16|
- (u32)(*(MacAddr + 5)) << 24;
- write_nic_dword(dev, WCAMI, TargetContent);
- write_nic_dword(dev, RWCAM, TargetCommand);
- continue;
- default: /* Key Material */
- if (KeyContent != NULL) {
- write_nic_dword(dev, WCAMI,
- (u32)(*(KeyContent+i-2)));
- write_nic_dword(dev, RWCAM,
- TargetCommand);
- }
- continue;
- }
- }
-}
-
-/***************************************************************************
- ------------------- module init / exit stubs ----------------
-****************************************************************************/
-module_init(rtl8192_usb_module_init);
-module_exit(rtl8192_usb_module_exit);
diff --git a/drivers/staging/rtl8192su/r8192U_dm.c b/drivers/staging/rtl8192su/r8192U_dm.c
deleted file mode 100644
index ce7e1ee4c3a7..000000000000
--- a/drivers/staging/rtl8192su/r8192U_dm.c
+++ /dev/null
@@ -1,3982 +0,0 @@
-/*++
-Copyright-c Realtek Semiconductor Corp. All rights reserved.
-
-Module Name:
- r8192U_dm.c
-
-Abstract:
- HW dynamic mechanism.
-
-Major Change History:
- When Who What
- ---------- --------------- -------------------------------
- 2008-05-14 amy create version 0 porting from windows code.
-
---*/
-
-
-#include "r8192U.h"
-#include "r8192U_dm.h"
-#include "r819xU_cmdpkt.h"
-#include "r8192S_hw.h"
-#include "r8192S_phy.h"
-#include "r8192S_phyreg.h"
-
-/*---------------------------Define Local Constant---------------------------*/
-//
-// Indicate different AP vendor for IOT issue.
-//
-#if 1
- static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
- // UNKNOWN REALTEK_90 /*REALTEK_92SE*/ BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP
- { 0xa44f, 0x5ea44f, 0x5ea44f, 0xa44f, 0xa44f, 0xa44f, 0xa630, 0xa42b, 0x5e4322, 0x5e4322};
- static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
- // UNKNOWN REALTEK /*REALTEK_92SE*/ BROADCOM RALINK ATHEROS CISCO MARVELL 92U_AP SELF_AP
- { 0x5ea44f, 0xa44f, 0x5ea44f, 0x5e4322, 0x5ea422, 0x5e4322, 0x3ea44f, 0x5ea42b, 0x5e4322, 0x5e4322};
-
-#endif
-
-#define RTK_UL_EDCA 0xa44f
-#define RTK_DL_EDCA 0x5e4322
-/*---------------------------Define Local Constant---------------------------*/
-
-
-/*------------------------Define global variable-----------------------------*/
-// Debug variable ?
-dig_t dm_digtable;
-// Store current shoftware write register content for MAC PHY.
-u8 dm_shadow[16][256] = {{0}};
-// For Dynamic Rx Path Selection by Signal Strength
-DRxPathSel DM_RxPathSelTable;
-/*------------------------Define global variable-----------------------------*/
-
-
-/*------------------------Define local variable------------------------------*/
-/*------------------------Define local variable------------------------------*/
-
-
-/*--------------------Define export function prototype-----------------------*/
-#ifdef TO_DO_LIST
-static void dm_CheckProtection(struct net_device *dev);
-#endif
-extern void init_hal_dm(struct net_device *dev);
-extern void deinit_hal_dm(struct net_device *dev);
-
-extern void hal_dm_watchdog(struct net_device *dev);
-
-
-extern void init_rate_adaptive(struct net_device *dev);
-extern void dm_txpower_trackingcallback(struct work_struct *work);
-extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14);
-extern void dm_restore_dynamic_mechanism_state(struct net_device *dev);
-extern void dm_backup_dynamic_mechanism_state(struct net_device *dev);
-extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
- u32 dm_type,
- u32 dm_value);
-extern void DM_ChangeFsyncSetting(struct net_device *dev,
- s32 DM_Type,
- s32 DM_Value);
-extern void dm_force_tx_fw_info(struct net_device *dev,
- u32 force_type,
- u32 force_value);
-extern void dm_init_edca_turbo(struct net_device *dev);
-extern void dm_rf_operation_test_callback(unsigned long data);
-extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
-extern void dm_fsync_timer_callback(unsigned long data);
-extern void dm_check_fsync(struct net_device *dev);
-extern void dm_shadow_init(struct net_device *dev);
-
-
-/*--------------------Define export function prototype-----------------------*/
-
-
-/*---------------------Define local function prototype-----------------------*/
-// DM --> Rate Adaptive
-static void dm_check_rate_adaptive(struct net_device *dev);
-
-// DM --> Bandwidth switch
-static void dm_init_bandwidth_autoswitch(struct net_device *dev);
-static void dm_bandwidth_autoswitch( struct net_device *dev);
-
-// DM --> TX power control
-//static void dm_initialize_txpower_tracking(struct net_device *dev);
-
-static void dm_check_txpower_tracking(struct net_device *dev);
-
-
-
-//static void dm_txpower_reset_recovery(struct net_device *dev);
-
-
-// DM --> BB init gain restore
-#ifndef RTL8192U
-static void dm_bb_initialgain_restore(struct net_device *dev);
-
-
-// DM --> BB init gain backup
-static void dm_bb_initialgain_backup(struct net_device *dev);
-#endif
-// DM --> Dynamic Init Gain by RSSI
-static void dm_dig_init(struct net_device *dev);
-static void dm_ctrl_initgain_byrssi(struct net_device *dev);
-static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev);
-static void dm_ctrl_initgain_byrssi_by_driverrssi( struct net_device *dev);
-static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(struct net_device *dev);
-static void dm_initial_gain(struct net_device *dev);
-static void dm_pd_th(struct net_device *dev);
-static void dm_cs_ratio(struct net_device *dev);
-
-static void dm_init_ctstoself(struct net_device *dev);
-// DM --> EDCA turboe mode control
-static void dm_check_edca_turbo(struct net_device *dev);
-
-// DM --> HW RF control
-static void dm_check_rfctrl_gpio(struct net_device *dev);
-
-#ifndef RTL8190P
-//static void dm_gpio_change_rf(struct net_device *dev);
-#endif
-// DM --> Check PBC
-static void dm_check_pbc_gpio(struct net_device *dev);
-
-
-// DM --> Check current RX RF path state
-static void dm_check_rx_path_selection(struct net_device *dev);
-static void dm_init_rxpath_selection(struct net_device *dev);
-static void dm_rxpath_sel_byrssi(struct net_device *dev);
-
-
-// DM --> Fsync for broadcom ap
-static void dm_init_fsync(struct net_device *dev);
-static void dm_deInit_fsync(struct net_device *dev);
-
-//Added by vivi, 20080522
-static void dm_check_txrateandretrycount(struct net_device *dev);
-
-/*---------------------Define local function prototype-----------------------*/
-
-/*---------------------Define of Tx Power Control For Near/Far Range --------*/ //Add by Jacken 2008/02/18
-static void dm_init_dynamic_txpower(struct net_device *dev);
-static void dm_dynamic_txpower(struct net_device *dev);
-
-
-// DM --> For rate adaptive and DIG, we must send RSSI to firmware
-static void dm_send_rssi_tofw(struct net_device *dev);
-static void dm_ctstoself(struct net_device *dev);
-/*---------------------------Define function prototype------------------------*/
-//================================================================================
-// HW Dynamic mechanism interface.
-//================================================================================
-static void dm_CheckAggrPolicy(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
- //u8 QueueId;
- //PRT_TCB pTcb;
- bool bAmsduEnable = false;
-
- static u8 lastTxOkCnt = 0;
- static u8 lastRxOkCnt = 0;
- u8 curTxOkCnt = 0;
- u8 curRxOkCnt = 0;
-
- // Determine if A-MSDU policy.
- if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_HYBRID_AGGREGATION)
- {
- if(read_nic_byte(dev, INIMCS_SEL) > DESC92S_RATE54M)
- bAmsduEnable = true;
- }
- else if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
- {
- if(read_nic_byte(dev, INIMCS_SEL) > DESC92S_RATE54M)
- {
- curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
- curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
-
- if(curRxOkCnt <= 4*curTxOkCnt)
- bAmsduEnable = true;
- }
- }
- else
- {
- // Do not need to switch aggregation policy.
- return;
- }
-
- // Switch A-MSDU
- if(bAmsduEnable && !pHTInfo->bCurrent_AMSDU_Support)
- {
- pHTInfo->bCurrent_AMSDU_Support = true;
- }
- else if(!bAmsduEnable && pHTInfo->bCurrent_AMSDU_Support)
- {
-#ifdef TO_DO_LIST
- //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
- for(QueueId = 0; QueueId < MAX_TX_QUEUE; QueueId++)
- {
- while(!RTIsListEmpty(&dev->TcbAggrQueue[QueueId]))
- {
- pTcb = (PRT_TCB)RTRemoveHeadList(&dev->TcbAggrQueue[QueueId]);
- dev->TcbCountInAggrQueue[QueueId]--;
- PreTransmitTCB(dev, pTcb);
- }
- }
- //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
- pHTInfo->bCurrent_AMSDU_Support = false;
-#endif
- }
-
- // Determine A-MPDU policy
- if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_AMSDU_ENABLE)
- {
- if(!bAmsduEnable)
- pHTInfo->bCurrentAMPDUEnable = true;
- }
-
- // Update local static variables.
- lastTxOkCnt = priv->stats.txbytesunicast;
- lastRxOkCnt = priv->stats.rxbytesunicast;
-}
-//
-// Description:
-// Prepare SW resource for HW dynamic mechanism.
-//
-// Assumption:
-// This function is only invoked at driver intialization once.
-//
-//
-extern void
-init_hal_dm(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- // Undecorated Smoothed Signal Strength, it can utilized to dynamic mechanism.
- priv->undecorated_smoothed_pwdb = -1;
-
- //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
- dm_init_dynamic_txpower(dev);
- init_rate_adaptive(dev);
- dm_initialize_txpower_tracking(dev);
- dm_dig_init(dev);
- dm_init_edca_turbo(dev);
- dm_init_bandwidth_autoswitch(dev);
- dm_init_fsync(dev);
- dm_init_rxpath_selection(dev);
- dm_init_ctstoself(dev);
-
-} // InitHalDm
-
-extern void deinit_hal_dm(struct net_device *dev)
-{
-
- dm_deInit_fsync(dev);
-
-}
-
-
-
-
-//#if 0
-extern void hal_dm_watchdog(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if(priv->bInHctTest)
- return;
-
-
- dm_check_rfctrl_gpio(dev);
-
- // Add by hpfan 2008-03-11
- dm_check_pbc_gpio(dev);
- dm_check_txrateandretrycount(dev); //moved by tynli
- dm_check_edca_turbo(dev);
-
- dm_CheckAggrPolicy(dev);
-
-#ifdef TO_DO_LIST
- dm_CheckProtection(dev);
-#endif
-
- // ====================================================
- // If any dynamic mechanism is ready, put it above this return;
- // ====================================================
- //if (IS_HARDWARE_TYPE_8192S(dev))
- return;
-
-#ifdef TO_DO_LIST
- if(Adapter->MgntInfo.mActingAsAp)
- {
- AP_dm_CheckRateAdaptive(dev);
- //return;
- }
- else
-#endif
- {
- dm_check_rate_adaptive(dev);
- }
- dm_dynamic_txpower(dev);
-
- dm_check_txpower_tracking(dev);
- dm_ctrl_initgain_byrssi(dev);//LZM TMP 090302
-
- dm_bandwidth_autoswitch(dev);
-
- dm_check_rx_path_selection(dev);//LZM TMP 090302
- dm_check_fsync(dev);
-
- dm_send_rssi_tofw(dev);
-
- dm_ctstoself(dev);
-
-} //HalDmWatchDog
-
-/*
- * Decide Rate Adaptive Set according to distance (signal strength)
- * 01/11/2008 MHC Modify input arguments and RATR table level.
- * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call
- * the function after making sure RF_Type.
- */
-extern void init_rate_adaptive(struct net_device * dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive;
-
- pra->ratr_state = DM_RATR_STA_MAX;
- pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High;
- pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5;
- pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5;
-
- pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5;
- pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M;
- pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M;
-
- if(priv->CustomerID == RT_CID_819x_Netcore)
- pra->ping_rssi_enable = 1;
- else
- pra->ping_rssi_enable = 0;
- pra->ping_rssi_thresh_for_ra = 15;
-
-
- if (priv->rf_type == RF_2T4R)
- {
- // 07/10/08 MH Modify for RA smooth scheme.
- /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/
- pra->upper_rssi_threshold_ratr = 0x8f0f0000;
- pra->middle_rssi_threshold_ratr = 0x8f0ff000;
- pra->low_rssi_threshold_ratr = 0x8f0ff001;
- pra->low_rssi_threshold_ratr_40M = 0x8f0ff005;
- pra->low_rssi_threshold_ratr_20M = 0x8f0ff001;
- pra->ping_rssi_ratr = 0x0000000d;//cosa add for test
- }
- else if (priv->rf_type == RF_1T2R)
- {
- pra->upper_rssi_threshold_ratr = 0x000f0000;
- pra->middle_rssi_threshold_ratr = 0x000ff000;
- pra->low_rssi_threshold_ratr = 0x000ff001;
- pra->low_rssi_threshold_ratr_40M = 0x000ff005;
- pra->low_rssi_threshold_ratr_20M = 0x000ff001;
- pra->ping_rssi_ratr = 0x0000000d;//cosa add for test
- }
-
-} // InitRateAdaptive
-
-
-/*-----------------------------------------------------------------------------
- * Function: dm_check_rate_adaptive()
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/26/08 amy Create version 0 proting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static void dm_check_rate_adaptive(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
- prate_adaptive pra = (prate_adaptive)&priv->rate_adaptive;
- u32 currentRATR, targetRATR = 0;
- u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
- bool bshort_gi_enabled = false;
- static u8 ping_rssi_state=0;
-
-
- if(!priv->up)
- {
- RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
- return;
- }
-
- if(pra->rate_adaptive_disabled)//this variable is set by ioctl.
- return;
-
- // TODO: Only 11n mode is implemented currently,
- if( !(priv->ieee80211->mode == WIRELESS_MODE_N_24G ||
- priv->ieee80211->mode == WIRELESS_MODE_N_5G))
- return;
-
- if( priv->ieee80211->state == IEEE80211_LINKED )
- {
- // RT_TRACE(COMP_RATE, "dm_CheckRateAdaptive(): \t");
-
- //
- // Check whether Short GI is enabled
- //
- bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) ||
- (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz);
-
-
- pra->upper_rssi_threshold_ratr =
- (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
-
- pra->middle_rssi_threshold_ratr =
- (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
-
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- pra->low_rssi_threshold_ratr =
- (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
- }
- else
- {
- pra->low_rssi_threshold_ratr =
- (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
- }
- //cosa add for test
- pra->ping_rssi_ratr =
- (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled)? BIT31:0) ;
-
- /* 2007/10/08 MH We support RA smooth scheme now. When it is the first
- time to link with AP. We will not change upper/lower threshold. If
- STA stay in high or low level, we must change two different threshold
- to prevent jumping frequently. */
- if (pra->ratr_state == DM_RATR_STA_HIGH)
- {
- HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
- (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
- }
- else if (pra->ratr_state == DM_RATR_STA_LOW)
- {
- HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
- (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M);
- }
- else
- {
- HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
- (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
- }
-
- //DbgPrint("[DM] THresh H/L=%d/%d\n\r", RATR.HighRSSIThreshForRA, RATR.LowRSSIThreshForRA);
- if(priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA)
- {
- //DbgPrint("[DM] RSSI=%d STA=HIGH\n\r", pHalData->UndecoratedSmoothedPWDB);
- pra->ratr_state = DM_RATR_STA_HIGH;
- targetRATR = pra->upper_rssi_threshold_ratr;
- }else if(priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA)
- {
- //DbgPrint("[DM] RSSI=%d STA=Middle\n\r", pHalData->UndecoratedSmoothedPWDB);
- pra->ratr_state = DM_RATR_STA_MIDDLE;
- targetRATR = pra->middle_rssi_threshold_ratr;
- }else
- {
- //DbgPrint("[DM] RSSI=%d STA=LOW\n\r", pHalData->UndecoratedSmoothedPWDB);
- pra->ratr_state = DM_RATR_STA_LOW;
- targetRATR = pra->low_rssi_threshold_ratr;
- }
-
- //cosa add for test
- if(pra->ping_rssi_enable)
- {
- //pHalData->UndecoratedSmoothedPWDB = 19;
- if(priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5))
- {
- if( (priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) ||
- ping_rssi_state )
- {
- //DbgPrint("TestRSSI = %d, set RATR to 0x%x \n", pHalData->UndecoratedSmoothedPWDB, pRA->TestRSSIRATR);
- pra->ratr_state = DM_RATR_STA_LOW;
- targetRATR = pra->ping_rssi_ratr;
- ping_rssi_state = 1;
- }
- //else
- // DbgPrint("TestRSSI is between the range. \n");
- }
- else
- {
- //DbgPrint("TestRSSI Recover to 0x%x \n", targetRATR);
- ping_rssi_state = 0;
- }
- }
-
- // 2008.04.01
-#if 1
- // For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7.
- if(priv->ieee80211->GetHalfNmodeSupportByAPsHandler(dev))
- targetRATR &= 0xf00fffff;
-#endif
-
- //
- // Check whether updating of RATR0 is required
- //
- currentRATR = read_nic_dword(dev, RATR0);
- if( targetRATR != currentRATR )
- {
- u32 ratr_value;
- ratr_value = targetRATR;
- RT_TRACE(COMP_RATE,"currentRATR = %x, targetRATR = %x\n", currentRATR, targetRATR);
- if(priv->rf_type == RF_1T2R)
- {
- ratr_value &= ~(RATE_ALL_OFDM_2SS);
- }
- write_nic_dword(dev, RATR0, ratr_value);
- write_nic_byte(dev, UFWP, 1);
-
- pra->last_ratr = targetRATR;
- }
-
- }
- else
- {
- pra->ratr_state = DM_RATR_STA_MAX;
- }
-
-} // dm_CheckRateAdaptive
-
-
-static void dm_init_bandwidth_autoswitch(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz = BW_AUTO_SWITCH_LOW_HIGH;
- priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz = BW_AUTO_SWITCH_HIGH_LOW;
- priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false;
- priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable = false;
-
-} // dm_init_bandwidth_autoswitch
-
-
-static void dm_bandwidth_autoswitch(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||!priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable){
- return;
- }else{
- if(priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz == false){//If send packets in 40 Mhz in 20/40
- if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
- priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = true;
- }else{//in force send packets in 20 Mhz in 20/40
- if(priv->undecorated_smoothed_pwdb >= priv->ieee80211->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
- priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = false;
-
- }
- }
-} // dm_BandwidthAutoSwitch
-
-//OFDM default at 0db, index=6.
-static u32 OFDMSwingTable[OFDM_Table_Length] = {
- 0x7f8001fe, // 0, +6db
- 0x71c001c7, // 1, +5db
- 0x65400195, // 2, +4db
- 0x5a400169, // 3, +3db
- 0x50800142, // 4, +2db
- 0x47c0011f, // 5, +1db
- 0x40000100, // 6, +0db ===> default, upper for higher temperature, lower for low temperature
- 0x390000e4, // 7, -1db
- 0x32c000cb, // 8, -2db
- 0x2d4000b5, // 9, -3db
- 0x288000a2, // 10, -4db
- 0x24000090, // 11, -5db
- 0x20000080, // 12, -6db
- 0x1c800072, // 13, -7db
- 0x19800066, // 14, -8db
- 0x26c0005b, // 15, -9db
- 0x24400051, // 16, -10db
- 0x12000048, // 17, -11db
- 0x10000040 // 18, -12db
-};
-
-static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = {
- {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0db ===> CCK40M default
- {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 1, -1db
- {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 2, -2db
- {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 3, -3db
- {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 4, -4db
- {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 5, -5db
- {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 6, -6db ===> CCK20M default
- {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 7, -7db
- {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 8, -8db
- {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 9, -9db
- {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 10, -10db
- {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} // 11, -11db
-};
-
-static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = {
- {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0db ===> CCK40M default
- {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 1, -1db
- {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 2, -2db
- {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 3, -3db
- {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 4, -4db
- {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 5, -5db
- {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 6, -6db ===> CCK20M default
- {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 7, -7db
- {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 8, -8db
- {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 9, -9db
- {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 10, -10db
- {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00} // 11, -11db
-};
-
-static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- bool bHighpowerstate, viviflag = FALSE;
- DCMD_TXCMD_T tx_cmd;
- u8 powerlevelOFDM24G;
- int i =0, j = 0, k = 0;
- u8 RF_Type, tmp_report[5]={0, 0, 0, 0, 0};
- u32 Value;
- u8 Pwr_Flag;
- u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0;
- //RT_STATUS rtStatus = RT_STATUS_SUCCESS;
-#ifdef RTL8192U
- bool rtStatus = true;
-#endif
- u32 delta=0;
-
- write_nic_byte(dev, 0x1ba, 0);
-
- priv->ieee80211->bdynamic_txpower_enable = false;
- bHighpowerstate = priv->bDynamicTxHighPower;
-
- powerlevelOFDM24G = (u8)(priv->Pwr_Track>>24);
- RF_Type = priv->rf_type;
- Value = (RF_Type<<8) | powerlevelOFDM24G;
-
- RT_TRACE(COMP_POWER_TRACKING, "powerlevelOFDM24G = %x\n", powerlevelOFDM24G);
-
- for(j = 0; j<=30; j++)
-{ //fill tx_cmd
-
- tx_cmd.Op = TXCMD_SET_TX_PWR_TRACKING;
- tx_cmd.Length = 4;
- tx_cmd.Value = Value;
-#ifdef RTL8192U
- rtStatus = SendTxCommandPacket(dev, &tx_cmd, 12);
- if (rtStatus == false)
- {
- RT_TRACE(COMP_POWER_TRACKING, "Set configuration with tx cmd queue fail!\n");
- }
-#else
- cmpk_message_handle_tx(dev, (u8*)&tx_cmd,
- DESC_PACKET_TYPE_INIT, sizeof(DCMD_TXCMD_T));
-#endif
- mdelay(1);
- //DbgPrint("hi, vivi, strange\n");
- for(i = 0;i <= 30; i++)
- {
- Pwr_Flag = read_nic_byte(dev, 0x1ba);
-
- if (Pwr_Flag == 0)
- {
- mdelay(1);
- continue;
- }
-#ifdef RTL8190P
- Avg_TSSI_Meas = read_nic_word(dev, 0x1bc);
-#else
- Avg_TSSI_Meas = read_nic_word(dev, 0x13c);
-#endif
- if(Avg_TSSI_Meas == 0)
- {
- write_nic_byte(dev, 0x1ba, 0);
- break;
- }
-
- for(k = 0;k < 5; k++)
- {
-#ifdef RTL8190P
- tmp_report[k] = read_nic_byte(dev, 0x1d8+k);
-#else
- if(k !=4)
- tmp_report[k] = read_nic_byte(dev, 0x134+k);
- else
- tmp_report[k] = read_nic_byte(dev, 0x13e);
-#endif
- RT_TRACE(COMP_POWER_TRACKING, "TSSI_report_value = %d\n", tmp_report[k]);
- }
-
- //check if the report value is right
- for(k = 0;k < 5; k++)
- {
- if(tmp_report[k] <= 20)
- {
- viviflag =TRUE;
- break;
- }
- }
- if(viviflag ==TRUE)
- {
- write_nic_byte(dev, 0x1ba, 0);
- viviflag = FALSE;
- RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n");
- for(k = 0;k < 5; k++)
- tmp_report[k] = 0;
- break;
- }
-
- for(k = 0;k < 5; k++)
- {
- Avg_TSSI_Meas_from_driver += tmp_report[k];
- }
-
- Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5;
- RT_TRACE(COMP_POWER_TRACKING, "Avg_TSSI_Meas_from_driver = %d\n", Avg_TSSI_Meas_from_driver);
- TSSI_13dBm = priv->TSSI_13dBm;
- RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm);
-
- //if(abs(Avg_TSSI_Meas_from_driver - TSSI_13dBm) <= E_FOR_TX_POWER_TRACK)
- // For MacOS-compatible
- if(Avg_TSSI_Meas_from_driver > TSSI_13dBm)
- delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
- else
- delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver;
-
- if(delta <= E_FOR_TX_POWER_TRACK)
- {
- priv->ieee80211->bdynamic_txpower_enable = TRUE;
- write_nic_byte(dev, 0x1ba, 0);
- RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n");
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
-#ifdef RTL8190P
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
-#endif
- RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation_difference = %d\n", priv->cck_present_attentuation_difference);
- RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation = %d\n", priv->cck_present_attentuation);
- return;
- }
- else
- {
- if(Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK)
- {
- if((priv->rfa_txpowertrackingindex > 0)
-#ifdef RTL8190P
- &&(priv->rfc_txpowertrackingindex > 0)
-#endif
- )
- {
- priv->rfa_txpowertrackingindex--;
- if(priv->rfa_txpowertrackingindex_real > 4)
- {
- priv->rfa_txpowertrackingindex_real--;
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
- }
-#ifdef RTL8190P
- priv->rfc_txpowertrackingindex--;
- if(priv->rfc_txpowertrackingindex_real > 4)
- {
- priv->rfc_txpowertrackingindex_real--;
- rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
- }
-#endif
- }
- }
- else
- {
- if((priv->rfa_txpowertrackingindex < 36)
-#ifdef RTL8190P
- &&(priv->rfc_txpowertrackingindex < 36)
-#endif
- )
- {
- priv->rfa_txpowertrackingindex++;
- priv->rfa_txpowertrackingindex_real++;
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
-
-#ifdef RTL8190P
- priv->rfc_txpowertrackingindex++;
- priv->rfc_txpowertrackingindex_real++;
- rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
-#endif
- }
- }
- priv->cck_present_attentuation_difference
- = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
-
- if(priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
- priv->cck_present_attentuation
- = priv->cck_present_attentuation_20Mdefault + priv->cck_present_attentuation_difference;
- else
- priv->cck_present_attentuation
- = priv->cck_present_attentuation_40Mdefault + priv->cck_present_attentuation_difference;
-
- if(priv->cck_present_attentuation > -1&&priv->cck_present_attentuation <23)
- {
- if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14)
- {
- priv->bcck_in_ch14 = TRUE;
- dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
- }
- else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14)
- {
- priv->bcck_in_ch14 = FALSE;
- dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
- }
- else
- dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
- }
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex_real = %d\n", priv->rfa_txpowertrackingindex_real);
-#ifdef RTL8190P
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex = %d\n", priv->rfc_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "priv->rfc_txpowertrackingindex_real = %d\n", priv->rfc_txpowertrackingindex_real);
-#endif
- RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation_difference = %d\n", priv->cck_present_attentuation_difference);
- RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation = %d\n", priv->cck_present_attentuation);
-
- if (priv->cck_present_attentuation_difference <= -12||priv->cck_present_attentuation_difference >= 24)
- {
- priv->ieee80211->bdynamic_txpower_enable = TRUE;
- write_nic_byte(dev, 0x1ba, 0);
- RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
- return;
- }
-
-
- }
- write_nic_byte(dev, 0x1ba, 0);
- Avg_TSSI_Meas_from_driver = 0;
- for(k = 0;k < 5; k++)
- tmp_report[k] = 0;
- break;
- }
-}
- priv->ieee80211->bdynamic_txpower_enable = TRUE;
- write_nic_byte(dev, 0x1ba, 0);
-}
-
-static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
-{
-#define ThermalMeterVal 9
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 tmpRegA, TempCCk;
- u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval;
- int i =0, CCKSwingNeedUpdate=0;
-
- if(!priv->btxpower_trackingInit)
- {
- //Query OFDM default setting
- tmpRegA= rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
- for(i=0; i<OFDM_Table_Length; i++) //find the index
- {
- if(tmpRegA == OFDMSwingTable[i])
- {
- priv->OFDM_index= (u8)i;
- RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index=0x%x\n",
- rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index);
- }
- }
-
- //Query CCK default setting From 0xa22
- TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2);
- for(i=0 ; i<CCK_Table_length ; i++)
- {
- if(TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0])
- {
- priv->CCK_index =(u8) i;
- RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, CCK_index=0x%x\n",
- rCCK0_TxFilter1, TempCCk, priv->CCK_index);
- break;
- }
- }
- priv->btxpower_trackingInit = TRUE;
- //pHalData->TXPowercount = 0;
- return;
- }
-
- // read and filter out unreasonable value
- tmpRegA = rtl8192_phy_QueryRFReg(dev, RF90_PATH_A, 0x12, 0x078); // 0x12: RF Reg[10:7]
- RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA);
- if(tmpRegA < 3 || tmpRegA > 13)
- return;
- if(tmpRegA >= 12) // if over 12, TP will be bad when high temperature
- tmpRegA = 12;
- RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA);
- priv->ThermalMeter[0] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
- priv->ThermalMeter[1] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
-
- //Get current RF-A temperature index
- if(priv->ThermalMeter[0] >= (u8)tmpRegA) //lower temperature
- {
- tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA);
- tmpCCK40Mindex = tmpCCK20Mindex - 6;
- if(tmpOFDMindex >= OFDM_Table_Length)
- tmpOFDMindex = OFDM_Table_Length-1;
- if(tmpCCK20Mindex >= CCK_Table_length)
- tmpCCK20Mindex = CCK_Table_length-1;
- if(tmpCCK40Mindex >= CCK_Table_length)
- tmpCCK40Mindex = CCK_Table_length-1;
- }
- else
- {
- tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]);
- if(tmpval >= 6) // higher temperature
- tmpOFDMindex = tmpCCK20Mindex = 0; // max to +6dB
- else
- tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval;
- tmpCCK40Mindex = 0;
- }
- //DbgPrint("%ddb, tmpOFDMindex = %d, tmpCCK20Mindex = %d, tmpCCK40Mindex = %d",
- //((u1Byte)tmpRegA - pHalData->ThermalMeter[0]),
- //tmpOFDMindex, tmpCCK20Mindex, tmpCCK40Mindex);
- if(priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) //40M
- tmpCCKindex = tmpCCK40Mindex;
- else
- tmpCCKindex = tmpCCK20Mindex;
-
- if(priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14)
- {
- priv->bcck_in_ch14 = TRUE;
- CCKSwingNeedUpdate = 1;
- }
- else if(priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14)
- {
- priv->bcck_in_ch14 = FALSE;
- CCKSwingNeedUpdate = 1;
- }
-
- if(priv->CCK_index != tmpCCKindex)
- {
- priv->CCK_index = tmpCCKindex;
- CCKSwingNeedUpdate = 1;
- }
-
- if(CCKSwingNeedUpdate)
- {
- //DbgPrint("Update CCK Swing, CCK_index = %d\n", pHalData->CCK_index);
- dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
- }
- if(priv->OFDM_index != tmpOFDMindex)
- {
- priv->OFDM_index = tmpOFDMindex;
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable[priv->OFDM_index]);
- RT_TRACE(COMP_POWER_TRACKING, "Update OFDMSwing[%d] = 0x%x\n",
- priv->OFDM_index, OFDMSwingTable[priv->OFDM_index]);
- }
- priv->txpower_count = 0;
-}
-
-extern void dm_txpower_trackingcallback(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,txpower_tracking_wq);
- struct net_device *dev = priv->ieee80211->dev;
-
-#ifdef RTL8190P
- dm_TXPowerTrackingCallback_TSSI(dev);
-#else
- if(priv->bDcut == TRUE)
- dm_TXPowerTrackingCallback_TSSI(dev);
- else
- dm_TXPowerTrackingCallback_ThermalMeter(dev);
-#endif
-}
-
-
-static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- //Initial the Tx BB index and mapping value
- priv->txbbgain_table[0].txbb_iq_amplifygain = 12;
- priv->txbbgain_table[0].txbbgain_value=0x7f8001fe;
- priv->txbbgain_table[1].txbb_iq_amplifygain = 11;
- priv->txbbgain_table[1].txbbgain_value=0x788001e2;
- priv->txbbgain_table[2].txbb_iq_amplifygain = 10;
- priv->txbbgain_table[2].txbbgain_value=0x71c001c7;
- priv->txbbgain_table[3].txbb_iq_amplifygain = 9;
- priv->txbbgain_table[3].txbbgain_value=0x6b8001ae;
- priv->txbbgain_table[4].txbb_iq_amplifygain = 8;
- priv->txbbgain_table[4].txbbgain_value=0x65400195;
- priv->txbbgain_table[5].txbb_iq_amplifygain = 7;
- priv->txbbgain_table[5].txbbgain_value=0x5fc0017f;
- priv->txbbgain_table[6].txbb_iq_amplifygain = 6;
- priv->txbbgain_table[6].txbbgain_value=0x5a400169;
- priv->txbbgain_table[7].txbb_iq_amplifygain = 5;
- priv->txbbgain_table[7].txbbgain_value=0x55400155;
- priv->txbbgain_table[8].txbb_iq_amplifygain = 4;
- priv->txbbgain_table[8].txbbgain_value=0x50800142;
- priv->txbbgain_table[9].txbb_iq_amplifygain = 3;
- priv->txbbgain_table[9].txbbgain_value=0x4c000130;
- priv->txbbgain_table[10].txbb_iq_amplifygain = 2;
- priv->txbbgain_table[10].txbbgain_value=0x47c0011f;
- priv->txbbgain_table[11].txbb_iq_amplifygain = 1;
- priv->txbbgain_table[11].txbbgain_value=0x43c0010f;
- priv->txbbgain_table[12].txbb_iq_amplifygain = 0;
- priv->txbbgain_table[12].txbbgain_value=0x40000100;
- priv->txbbgain_table[13].txbb_iq_amplifygain = -1;
- priv->txbbgain_table[13].txbbgain_value=0x3c8000f2;
- priv->txbbgain_table[14].txbb_iq_amplifygain = -2;
- priv->txbbgain_table[14].txbbgain_value=0x390000e4;
- priv->txbbgain_table[15].txbb_iq_amplifygain = -3;
- priv->txbbgain_table[15].txbbgain_value=0x35c000d7;
- priv->txbbgain_table[16].txbb_iq_amplifygain = -4;
- priv->txbbgain_table[16].txbbgain_value=0x32c000cb;
- priv->txbbgain_table[17].txbb_iq_amplifygain = -5;
- priv->txbbgain_table[17].txbbgain_value=0x300000c0;
- priv->txbbgain_table[18].txbb_iq_amplifygain = -6;
- priv->txbbgain_table[18].txbbgain_value=0x2d4000b5;
- priv->txbbgain_table[19].txbb_iq_amplifygain = -7;
- priv->txbbgain_table[19].txbbgain_value=0x2ac000ab;
- priv->txbbgain_table[20].txbb_iq_amplifygain = -8;
- priv->txbbgain_table[20].txbbgain_value=0x288000a2;
- priv->txbbgain_table[21].txbb_iq_amplifygain = -9;
- priv->txbbgain_table[21].txbbgain_value=0x26000098;
- priv->txbbgain_table[22].txbb_iq_amplifygain = -10;
- priv->txbbgain_table[22].txbbgain_value=0x24000090;
- priv->txbbgain_table[23].txbb_iq_amplifygain = -11;
- priv->txbbgain_table[23].txbbgain_value=0x22000088;
- priv->txbbgain_table[24].txbb_iq_amplifygain = -12;
- priv->txbbgain_table[24].txbbgain_value=0x20000080;
- priv->txbbgain_table[25].txbb_iq_amplifygain = -13;
- priv->txbbgain_table[25].txbbgain_value=0x1a00006c;
- priv->txbbgain_table[26].txbb_iq_amplifygain = -14;
- priv->txbbgain_table[26].txbbgain_value=0x1c800072;
- priv->txbbgain_table[27].txbb_iq_amplifygain = -15;
- priv->txbbgain_table[27].txbbgain_value=0x18000060;
- priv->txbbgain_table[28].txbb_iq_amplifygain = -16;
- priv->txbbgain_table[28].txbbgain_value=0x19800066;
- priv->txbbgain_table[29].txbb_iq_amplifygain = -17;
- priv->txbbgain_table[29].txbbgain_value=0x15800056;
- priv->txbbgain_table[30].txbb_iq_amplifygain = -18;
- priv->txbbgain_table[30].txbbgain_value=0x26c0005b;
- priv->txbbgain_table[31].txbb_iq_amplifygain = -19;
- priv->txbbgain_table[31].txbbgain_value=0x14400051;
- priv->txbbgain_table[32].txbb_iq_amplifygain = -20;
- priv->txbbgain_table[32].txbbgain_value=0x24400051;
- priv->txbbgain_table[33].txbb_iq_amplifygain = -21;
- priv->txbbgain_table[33].txbbgain_value=0x1300004c;
- priv->txbbgain_table[34].txbb_iq_amplifygain = -22;
- priv->txbbgain_table[34].txbbgain_value=0x12000048;
- priv->txbbgain_table[35].txbb_iq_amplifygain = -23;
- priv->txbbgain_table[35].txbbgain_value=0x11000044;
- priv->txbbgain_table[36].txbb_iq_amplifygain = -24;
- priv->txbbgain_table[36].txbbgain_value=0x10000040;
-
- //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
- //This Table is for CH1~CH13
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04;
-
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04;
-
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01;
-
- //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
- //This Table is for CH14
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00;
-
- priv->btxpower_tracking = TRUE;
- priv->txpower_count = 0;
- priv->btxpower_trackingInit = FALSE;
-
-}
-
-
-void dm_initialize_txpower_tracking(struct net_device *dev)
-{
-#if (defined RTL8190P)
- dm_InitializeTXPowerTracking_TSSI(dev);
-#else
- // 2009/01/12 MH Enable for 92S series channel 1-14 CCK tx pwer setting for MP.
- //
- dm_InitializeTXPowerTracking_TSSI(dev);
-#endif
-}// dm_InitializeTXPowerTracking
-
-
-static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u32 tx_power_track_counter = 0;
-
- if(!priv->btxpower_tracking)
- return;
- else
- {
- if((tx_power_track_counter % 30 == 0)&&(tx_power_track_counter != 0))
- {
- queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
- }
- tx_power_track_counter++;
- }
-
-}
-
-
-static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u8 TM_Trigger=0;
-
- //DbgPrint("dm_CheckTXPowerTracking() \n");
- if(!priv->btxpower_tracking)
- return;
- else
- {
- if(priv->txpower_count <= 2)
- {
- priv->txpower_count++;
- return;
- }
- }
-
- if(!TM_Trigger)
- {
- //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash
- //actually write reg0x02 bit1=0, then bit1=1.
- //DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
- rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4d);
- rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4f);
- rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4d);
- rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bRFRegOffsetMask, 0x4f);
- TM_Trigger = 1;
- return;
- }
- else
- {
- //DbgPrint("Schedule TxPowerTrackingWorkItem\n");
- queue_delayed_work(priv->priv_wq,&priv->txpower_tracking_wq,0);
- TM_Trigger = 0;
- }
-}
-
-
-static void dm_check_txpower_tracking(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //static u32 tx_power_track_counter = 0;
-
-#ifdef RTL8190P
- dm_CheckTXPowerTracking_TSSI(dev);
-#else
- if(priv->bDcut == TRUE)
- dm_CheckTXPowerTracking_TSSI(dev);
- else
- dm_CheckTXPowerTracking_ThermalMeter(dev);
-#endif
-
-} // dm_CheckTXPowerTracking
-
-
-static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14)
-{
- u32 TempVal;
- struct r8192_priv *priv = ieee80211_priv(dev);
- //Write 0xa22 0xa23
- TempVal = 0;
- if(!bInCH14){
- //Write 0xa22 0xa23
- TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
- (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
- //Write 0xa24 ~ 0xa27
- TempVal = 0;
- TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
- (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
- (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+
- (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
- rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
- //Write 0xa28 0xa29
- TempVal = 0;
- TempVal = priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
- (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
- }
- else
- {
- TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
- (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
- //Write 0xa24 ~ 0xa27
- TempVal = 0;
- TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
- (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[3]<<8) +
- (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[4]<<16 )+
- (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[5]<<24);
- rtl8192_setBBreg(dev, rCCK0_TxFilter2,bMaskDWord, TempVal);
- //Write 0xa28 0xa29
- TempVal = 0;
- TempVal = priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
- (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
- }
-
-
-}
-
-static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14)
-{
- u32 TempVal;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- TempVal = 0;
- if(!bInCH14)
- {
- //Write 0xa22 0xa23
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ;
- rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter1, TempVal);
- //Write 0xa24 ~ 0xa27
- TempVal = 0;
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24);
- rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter2, TempVal);
- //Write 0xa28 0xa29
- TempVal = 0;
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_DebugPort, TempVal);
- }
- else
- {
-// priv->CCKTxPowerAdjustCntNotCh14++; //cosa add for debug.
- //Write 0xa22 0xa23
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] +
- (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter1, TempVal);
- //Write 0xa24 ~ 0xa27
- TempVal = 0;
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] +
- (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
- (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+
- (CCKSwingTable_Ch14[priv->CCK_index][5]<<24);
- rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter2, TempVal);
- //Write 0xa28 0xa29
- TempVal = 0;
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] +
- (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
-
- rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING,"CCK chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_DebugPort, TempVal);
- }
-}
-
-
-
-extern void dm_cck_txpower_adjust(
- struct net_device *dev,
- bool binch14
-)
-{ // dm_CCKTxPowerAdjust
-
- struct r8192_priv *priv = ieee80211_priv(dev);
-#ifdef RTL8190P
- dm_CCKTxPowerAdjust_TSSI(dev, binch14);
-#else
- if(priv->bDcut == TRUE)
- dm_CCKTxPowerAdjust_TSSI(dev, binch14);
- else
- dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
-#endif
-}
-
-
-#ifndef RTL8192U
-static void dm_txpower_reset_recovery(
- struct net_device *dev
-)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n");
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",priv->rfa_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",priv->cck_present_attentuation);
- dm_cck_txpower_adjust(dev,priv->bcck_in_ch14);
-
- rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",priv->rfc_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain);
-
-} // dm_TXPowerResetRecovery
-
-extern void dm_restore_dynamic_mechanism_state(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 reg_ratr = priv->rate_adaptive.last_ratr;
-
- if(!priv->up)
- {
- RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
- return;
- }
-
- //
- // Restore previous state for rate adaptive
- //
- if(priv->rate_adaptive.rate_adaptive_disabled)
- return;
- // TODO: Only 11n mode is implemented currently,
- if( !(priv->ieee80211->mode==WIRELESS_MODE_N_24G ||
- priv->ieee80211->mode==WIRELESS_MODE_N_5G))
- return;
- {
- /* 2007/11/15 MH Copy from 8190PCI. */
- u32 ratr_value;
- ratr_value = reg_ratr;
- if(priv->rf_type == RF_1T2R) // 1T2R, Spatial Stream 2 should be disabled
- {
- ratr_value &=~ (RATE_ALL_OFDM_2SS);
- //DbgPrint("HW_VAR_TATR_0 from 0x%x ==> 0x%x\n", ((pu4Byte)(val))[0], ratr_value);
- }
- //DbgPrint("set HW_VAR_TATR_0 = 0x%x\n", ratr_value);
- //cosa PlatformEFIOWrite4Byte(Adapter, RATR0, ((pu4Byte)(val))[0]);
- write_nic_dword(dev, RATR0, ratr_value);
- write_nic_byte(dev, UFWP, 1);
- }
- //Resore TX Power Tracking Index
- if(priv->btxpower_trackingInit && priv->btxpower_tracking){
- dm_txpower_reset_recovery(dev);
- }
-
- //
- //Restore BB Initial Gain
- //
- dm_bb_initialgain_restore(dev);
-
-} // DM_RestoreDynamicMechanismState
-
-static void dm_bb_initialgain_restore(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 bit_mask = 0x7f; //Bit0~ Bit6
-
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
- return;
-
- //Disable Initial Gain
- //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
- rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1);
- bit_mask = bMaskByte2;
- rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca);
-
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",priv->initgain_backup.cca);
- //Enable Initial Gain
- //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x100);
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
-
-} // dm_BBInitialGainRestore
-
-
-extern void dm_backup_dynamic_mechanism_state(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- // Fsync to avoid reset
- priv->bswitch_fsync = false;
- priv->bfsync_processing = false;
- //Backup BB InitialGain
- dm_bb_initialgain_backup(dev);
-
-} // DM_BackupDynamicMechanismState
-
-
-static void dm_bb_initialgain_backup(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 bit_mask = bMaskByte0; //Bit0~ Bit6
-
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
- return;
-
- //PHY_SetBBReg(Adapter, UFWP, bMaskLWord, 0x800);
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
- priv->initgain_backup.xaagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XAAGCCore1, bit_mask);
- priv->initgain_backup.xbagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XBAGCCore1, bit_mask);
- priv->initgain_backup.xcagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XCAGCCore1, bit_mask);
- priv->initgain_backup.xdagccore1 = (u8)rtl8192_QueryBBReg(dev, rOFDM0_XDAGCCore1, bit_mask);
- bit_mask = bMaskByte2;
- priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
-
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",priv->initgain_backup.cca);
-
-} // dm_BBInitialGainBakcup
-
-#endif
-/*-----------------------------------------------------------------------------
- * Function: dm_change_dynamic_initgain_thresh()
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/29/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
- u32 dm_type,
- u32 dm_value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- if(dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
- priv->MidHighPwrTHR_L2 = (u8)dm_value;
- else if(dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW)
- priv->MidHighPwrTHR_L1 = (u8)dm_value;
- return;
- if (dm_type == DIG_TYPE_THRESH_HIGH)
- {
- dm_digtable.rssi_high_thresh = dm_value;
- }
- else if (dm_type == DIG_TYPE_THRESH_LOW)
- {
- dm_digtable.rssi_low_thresh = dm_value;
- }
- else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
- {
- dm_digtable.rssi_high_power_highthresh = dm_value;
- }
- else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)
- {
- dm_digtable.rssi_high_power_highthresh = dm_value;
- }
- else if (dm_type == DIG_TYPE_ENABLE)
- {
- dm_digtable.dig_state = DM_STA_DIG_MAX;
- dm_digtable.dig_enable_flag = true;
- }
- else if (dm_type == DIG_TYPE_DISABLE)
- {
- dm_digtable.dig_state = DM_STA_DIG_MAX;
- dm_digtable.dig_enable_flag = false;
- }
- else if (dm_type == DIG_TYPE_DBG_MODE)
- {
- if(dm_value >= DM_DBG_MAX)
- dm_value = DM_DBG_OFF;
- dm_digtable.dbg_mode = (u8)dm_value;
- }
- else if (dm_type == DIG_TYPE_RSSI)
- {
- if(dm_value > 100)
- dm_value = 30;
- dm_digtable.rssi_val = (long)dm_value;
- }
- else if (dm_type == DIG_TYPE_ALGORITHM)
- {
- if (dm_value >= DIG_ALGO_MAX)
- dm_value = DIG_ALGO_BY_FALSE_ALARM;
- if(dm_digtable.dig_algorithm != (u8)dm_value)
- dm_digtable.dig_algorithm_switch = 1;
- dm_digtable.dig_algorithm = (u8)dm_value;
- }
- else if (dm_type == DIG_TYPE_BACKOFF)
- {
- if(dm_value > 30)
- dm_value = 30;
- dm_digtable.backoff_val = (u8)dm_value;
- }
- else if(dm_type == DIG_TYPE_RX_GAIN_MIN)
- {
- if(dm_value == 0)
- dm_value = 0x1;
- dm_digtable.rx_gain_range_min = (u8)dm_value;
- }
- else if(dm_type == DIG_TYPE_RX_GAIN_MAX)
- {
- if(dm_value > 0x50)
- dm_value = 0x50;
- dm_digtable.rx_gain_range_max = (u8)dm_value;
- }
-} /* DM_ChangeDynamicInitGainThresh */
-extern void
-dm_change_fsync_setting(
- struct net_device *dev,
- s32 DM_Type,
- s32 DM_Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if (DM_Type == 0) // monitor 0xc38 register
- {
- if(DM_Value > 1)
- DM_Value = 1;
- priv->framesyncMonitor = (u8)DM_Value;
- //DbgPrint("pHalData->framesyncMonitor = %d", pHalData->framesyncMonitor);
- }
-}
-
-extern void
-dm_change_rxpath_selection_setting(
- struct net_device *dev,
- s32 DM_Type,
- s32 DM_Value)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- prate_adaptive pRA = (prate_adaptive)&(priv->rate_adaptive);
-
-
- if(DM_Type == 0)
- {
- if(DM_Value > 1)
- DM_Value = 1;
- DM_RxPathSelTable.Enable = (u8)DM_Value;
- }
- else if(DM_Type == 1)
- {
- if(DM_Value > 1)
- DM_Value = 1;
- DM_RxPathSelTable.DbgMode = (u8)DM_Value;
- }
- else if(DM_Type == 2)
- {
- if(DM_Value > 40)
- DM_Value = 40;
- DM_RxPathSelTable.SS_TH_low = (u8)DM_Value;
- }
- else if(DM_Type == 3)
- {
- if(DM_Value > 25)
- DM_Value = 25;
- DM_RxPathSelTable.diff_TH = (u8)DM_Value;
- }
- else if(DM_Type == 4)
- {
- if(DM_Value >= CCK_Rx_Version_MAX)
- DM_Value = CCK_Rx_Version_1;
- DM_RxPathSelTable.cck_method= (u8)DM_Value;
- }
- else if(DM_Type == 10)
- {
- if(DM_Value > 100)
- DM_Value = 50;
- DM_RxPathSelTable.rf_rssi[0] = (u8)DM_Value;
- }
- else if(DM_Type == 11)
- {
- if(DM_Value > 100)
- DM_Value = 50;
- DM_RxPathSelTable.rf_rssi[1] = (u8)DM_Value;
- }
- else if(DM_Type == 12)
- {
- if(DM_Value > 100)
- DM_Value = 50;
- DM_RxPathSelTable.rf_rssi[2] = (u8)DM_Value;
- }
- else if(DM_Type == 13)
- {
- if(DM_Value > 100)
- DM_Value = 50;
- DM_RxPathSelTable.rf_rssi[3] = (u8)DM_Value;
- }
- else if(DM_Type == 20)
- {
- if(DM_Value > 1)
- DM_Value = 1;
- pRA->ping_rssi_enable = (u8)DM_Value;
- }
- else if(DM_Type == 21)
- {
- if(DM_Value > 30)
- DM_Value = 30;
- pRA->ping_rssi_thresh_for_ra = DM_Value;
- }
-}
-
-/*-----------------------------------------------------------------------------
- * Function: dm_dig_init()
- *
- * Overview: Set DIG scheme init value.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/15/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static void dm_dig_init(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- /* 2007/10/05 MH Disable DIG scheme now. Not tested. */
- dm_digtable.dig_enable_flag = true;
- dm_digtable.dig_algorithm = DIG_ALGO_BY_RSSI;
- dm_digtable.dbg_mode = DM_DBG_OFF; //off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig
- dm_digtable.dig_algorithm_switch = 0;
-
- /* 2007/10/04 MH Define init gain threshol. */
- dm_digtable.dig_state = DM_STA_DIG_MAX;
- dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
- dm_digtable.initialgain_lowerbound_state = false;
-
- dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW;
- dm_digtable.rssi_high_thresh = DM_DIG_THRESH_HIGH;
-
- dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW;
- dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH;
-
- dm_digtable.rssi_val = 50; //for new dig debug rssi value
- dm_digtable.backoff_val = DM_DIG_BACKOFF;
- dm_digtable.rx_gain_range_max = DM_DIG_MAX;
- if(priv->CustomerID == RT_CID_819x_Netcore)
- dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore;
- else
- dm_digtable.rx_gain_range_min = DM_DIG_MIN;
-
-} /* dm_dig_init */
-
-
-/*-----------------------------------------------------------------------------
- * Function: dm_ctrl_initgain_byrssi()
- *
- * Overview: Driver must monitor RSSI and notify firmware to change initial
- * gain according to different threshold. BB team provide the
- * suggested solution.
- *
- * Input: struct net_device *dev
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/27/2008 amy Create Version 0 porting from windows code.
- *---------------------------------------------------------------------------*/
-static void dm_ctrl_initgain_byrssi(struct net_device *dev)
-{
-
- if (dm_digtable.dig_enable_flag == false)
- return;
-
- if(dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM)
- dm_ctrl_initgain_byrssi_by_fwfalse_alarm(dev);
- else if(dm_digtable.dig_algorithm == DIG_ALGO_BY_RSSI)
- dm_ctrl_initgain_byrssi_by_driverrssi(dev);
-// ;
- else
- return;
-}
-
-
-static void dm_ctrl_initgain_byrssi_by_driverrssi(
- struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 i;
- static u8 fw_dig=0;
-
- if (dm_digtable.dig_enable_flag == false)
- return;
-
- //DbgPrint("Dig by Sw Rssi \n");
- if(dm_digtable.dig_algorithm_switch) // if swithed algorithm, we have to disable FW Dig.
- fw_dig = 0;
- if(fw_dig <= 3) // execute several times to make sure the FW Dig is disabled
- {// FW DIG Off
- for(i=0; i<3; i++)
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
- fw_dig++;
- dm_digtable.dig_state = DM_STA_DIG_OFF; //fw dig off.
- }
-
- if(priv->ieee80211->state == IEEE80211_LINKED)
- dm_digtable.cur_connect_state = DIG_CONNECT;
- else
- dm_digtable.cur_connect_state = DIG_DISCONNECT;
-
- //DbgPrint("DM_DigTable.PreConnectState = %d, DM_DigTable.CurConnectState = %d \n",
- //DM_DigTable.PreConnectState, DM_DigTable.CurConnectState);
-
- if(dm_digtable.dbg_mode == DM_DBG_OFF)
- dm_digtable.rssi_val = priv->undecorated_smoothed_pwdb;
- //DbgPrint("DM_DigTable.Rssi_val = %d \n", DM_DigTable.Rssi_val);
- dm_initial_gain(dev);
- dm_pd_th(dev);
- dm_cs_ratio(dev);
- if(dm_digtable.dig_algorithm_switch)
- dm_digtable.dig_algorithm_switch = 0;
- dm_digtable.pre_connect_state = dm_digtable.cur_connect_state;
-
-} /* dm_CtrlInitGainByRssi */
-
-static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
- struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u32 reset_cnt = 0;
- u8 i;
-
- if (dm_digtable.dig_enable_flag == false)
- return;
-
- if(dm_digtable.dig_algorithm_switch)
- {
- dm_digtable.dig_state = DM_STA_DIG_MAX;
- // Fw DIG On.
- for(i=0; i<3; i++)
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
- dm_digtable.dig_algorithm_switch = 0;
- }
-
- if (priv->ieee80211->state != IEEE80211_LINKED)
- return;
-
- // For smooth, we can not change DIG state.
- if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) &&
- (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh))
- {
- return;
- }
- //DbgPrint("Dig by Fw False Alarm\n");
- //if (DM_DigTable.Dig_State == DM_STA_DIG_OFF)
- /*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
- pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
- DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
- /* 1. When RSSI decrease, We have to judge if it is smaller than a treshold
- and then execute below step. */
- if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh))
- {
- /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters
- will be reset to init value. We must prevent the condition. */
- if (dm_digtable.dig_state == DM_STA_DIG_OFF &&
- (priv->reset_count == reset_cnt))
- {
- return;
- }
- else
- {
- reset_cnt = priv->reset_count;
- }
-
- // If DIG is off, DIG high power state must reset.
- dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
- dm_digtable.dig_state = DM_STA_DIG_OFF;
-
- // 1.1 DIG Off.
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8); // Only clear byte 1 and rewrite.
-
- // 1.2 Set initial gain.
- write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x17);
- write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x17);
- write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x17);
- write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x17);
-
- // 1.3 Lower PD_TH for OFDM.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
- // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
- rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x00);
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(pAdapter, rOFDM0_RxDetector1, 0x40);
- */
- //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
-
-
- //else
- //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x40);
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
-
- // 1.4 Lower CS ratio for CCK.
- write_nic_byte(dev, 0xa0a, 0x08);
-
- // 1.5 Higher EDCCA.
- //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x325);
- return;
-
- }
-
- /* 2. When RSSI increase, We have to judge if it is larger than a treshold
- and then execute below step. */
- if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) )
- {
- u8 reset_flag = 0;
-
- if (dm_digtable.dig_state == DM_STA_DIG_ON &&
- (priv->reset_count == reset_cnt))
- {
- dm_ctrl_initgain_byrssi_highpwr(dev);
- return;
- }
- else
- {
- if (priv->reset_count != reset_cnt)
- reset_flag = 1;
-
- reset_cnt = priv->reset_count;
- }
-
- dm_digtable.dig_state = DM_STA_DIG_ON;
- //DbgPrint("DIG ON\n\r");
-
- // 2.1 Set initial gain.
- // 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment.
- if (reset_flag == 1)
- {
- write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x2c);
- write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x2c);
- write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x2c);
- write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x2c);
- }
- else
- {
- write_nic_byte(dev, rOFDM0_XAAGCCore1, 0x20);
- write_nic_byte(dev, rOFDM0_XBAGCCore1, 0x20);
- write_nic_byte(dev, rOFDM0_XCAGCCore1, 0x20);
- write_nic_byte(dev, rOFDM0_XDAGCCore1, 0x20);
- }
-
- // 2.2 Higher PD_TH for OFDM.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
- // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- #else
- write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
- #endif
- /*
- else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- */
- //else if (pAdapter->HardwareType == HARDWARE_TYPE_RTL8192E)
-
- //else
- //PlatformEFIOWrite1Byte(pAdapter, rOFDM0_RxDetector1, 0x42);
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
-
- // 2.3 Higher CS ratio for CCK.
- write_nic_byte(dev, 0xa0a, 0xcd);
-
- // 2.4 Lower EDCCA.
- /* 2008/01/11 MH 90/92 series are the same. */
- //PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);
-
- // 2.5 DIG On.
- rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1); // Only clear byte 1 and rewrite.
-
- }
-
- dm_ctrl_initgain_byrssi_highpwr(dev);
-
-} /* dm_CtrlInitGainByRssi */
-
-
-/*-----------------------------------------------------------------------------
- * Function: dm_ctrl_initgain_byrssi_highpwr()
- *
- * Overview:
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/28/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static void dm_ctrl_initgain_byrssi_highpwr(
- struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u32 reset_cnt_highpwr = 0;
-
- // For smooth, we can not change high power DIG state in the range.
- if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) &&
- (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh))
- {
- return;
- }
-
- /* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if
- it is larger than a treshold and then execute below step. */
- // 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue.
- if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh)
- {
- if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON &&
- (priv->reset_count == reset_cnt_highpwr))
- return;
- else
- dm_digtable.dig_highpwr_state = DM_STA_DIG_ON;
-
- // 3.1 Higher PD_TH for OFDM for high power state.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x10);
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
- */
-
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
- }
- else
- {
- if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF&&
- (priv->reset_count == reset_cnt_highpwr))
- return;
- else
- dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF;
-
- if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh &&
- priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)
- {
- // 3.2 Recover PD_TH for OFDM for normal power region.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- #else
- write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
- #endif
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- */
-
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
- }
- }
-
- reset_cnt_highpwr = priv->reset_count;
-
-} /* dm_CtrlInitGainByRssiHighPwr */
-
-
-static void dm_initial_gain(
- struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 initial_gain=0;
- static u8 initialized=0, force_write=0;
- static u32 reset_cnt=0;
-
- if(dm_digtable.dig_algorithm_switch)
- {
- initialized = 0;
- reset_cnt = 0;
- }
-
- if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
- {
- if(dm_digtable.cur_connect_state == DIG_CONNECT)
- {
- if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max)
- dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max;
- else if((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min)
- dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min;
- else
- dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val;
- }
- else //current state is disconnected
- {
- if(dm_digtable.cur_ig_value == 0)
- dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
- else
- dm_digtable.cur_ig_value = dm_digtable.pre_ig_value;
- }
- }
- else // disconnected -> connected or connected -> disconnected
- {
- dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
- dm_digtable.pre_ig_value = 0;
- }
- //DbgPrint("DM_DigTable.CurIGValue = 0x%x, DM_DigTable.PreIGValue = 0x%x\n", DM_DigTable.CurIGValue, DM_DigTable.PreIGValue);
-
- // if silent reset happened, we should rewrite the values back
- if(priv->reset_count != reset_cnt)
- {
- force_write = 1;
- reset_cnt = priv->reset_count;
- }
-
- if(dm_digtable.pre_ig_value != read_nic_byte(dev, rOFDM0_XAAGCCore1))
- force_write = 1;
-
- {
- if((dm_digtable.pre_ig_value != dm_digtable.cur_ig_value)
- || !initialized || force_write)
- {
- initial_gain = (u8)dm_digtable.cur_ig_value;
- //DbgPrint("Write initial gain = 0x%x\n", initial_gain);
- // Set initial gain.
- write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
- write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
- dm_digtable.pre_ig_value = dm_digtable.cur_ig_value;
- initialized = 1;
- force_write = 0;
- }
- }
-}
-
-static void dm_pd_th(
- struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u8 initialized=0, force_write=0;
- static u32 reset_cnt = 0;
-
- if(dm_digtable.dig_algorithm_switch)
- {
- initialized = 0;
- reset_cnt = 0;
- }
-
- if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
- {
- if(dm_digtable.cur_connect_state == DIG_CONNECT)
- {
- if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh)
- dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER;
- else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
- dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
- else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) &&
- (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh))
- dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER;
- else
- dm_digtable.curpd_thstate = dm_digtable.prepd_thstate;
- }
- else
- {
- dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
- }
- }
- else // disconnected -> connected or connected -> disconnected
- {
- dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
- }
-
- // if silent reset happened, we should rewrite the values back
- if(priv->reset_count != reset_cnt)
- {
- force_write = 1;
- reset_cnt = priv->reset_count;
- }
-
- {
- if((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) ||
- (initialized<=3) || force_write)
- {
- //DbgPrint("Write PD_TH state = %d\n", DM_DigTable.CurPD_THState);
- if(dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER)
- {
- // Lower PD_TH for OFDM.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
- // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
- rtl8192_setBBreg(dev, (rOFDM0_XATxAFE+3), bMaskByte0, 0x00);
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x40);
- */
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- }
- else if(dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER)
- {
- // Higher PD_TH for OFDM.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- /* 2008/01/11 MH 40MHZ 90/92 register are not the same. */
- // 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same.
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- #else
- write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
- #endif
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- */
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x44);
- }
- else if(dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER)
- {
- // Higher PD_TH for OFDM for high power state.
- if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
- {
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
- #else
- write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
- #endif
- /*else if (priv->card_8192 == HARDWARE_TYPE_RTL8190P)
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x41);
- */
- }
- else
- write_nic_byte(dev, rOFDM0_RxDetector1, 0x43);
- }
- dm_digtable.prepd_thstate = dm_digtable.curpd_thstate;
- if(initialized <= 3)
- initialized++;
- force_write = 0;
- }
- }
-}
-
-static void dm_cs_ratio(
- struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- static u8 initialized=0,force_write=0;
- static u32 reset_cnt = 0;
-
- if(dm_digtable.dig_algorithm_switch)
- {
- initialized = 0;
- reset_cnt = 0;
- }
-
- if(dm_digtable.pre_connect_state == dm_digtable.cur_connect_state)
- {
- if(dm_digtable.cur_connect_state == DIG_CONNECT)
- {
- if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
- dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
- else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) )
- dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER;
- else
- dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state;
- }
- else
- {
- dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
- }
- }
- else // disconnected -> connected or connected -> disconnected
- {
- dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
- }
-
- // if silent reset happened, we should rewrite the values back
- if(priv->reset_count != reset_cnt)
- {
- force_write = 1;
- reset_cnt = priv->reset_count;
- }
-
-
- {
- if((dm_digtable.precs_ratio_state != dm_digtable.curcs_ratio_state) ||
- !initialized || force_write)
- {
- //DbgPrint("Write CS_ratio state = %d\n", DM_DigTable.CurCS_ratioState);
- if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_LOWER)
- {
- // Lower CS ratio for CCK.
- write_nic_byte(dev, 0xa0a, 0x08);
- }
- else if(dm_digtable.curcs_ratio_state == DIG_CS_RATIO_HIGHER)
- {
- // Higher CS ratio for CCK.
- write_nic_byte(dev, 0xa0a, 0xcd);
- }
- dm_digtable.precs_ratio_state = dm_digtable.curcs_ratio_state;
- initialized = 1;
- force_write = 0;
- }
- }
-}
-
-extern void dm_init_edca_turbo(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->bcurrent_turbo_EDCA = false;
- priv->ieee80211->bis_any_nonbepkts = false;
- priv->bis_cur_rdlstate = false;
-} // dm_init_edca_turbo
-
-#if 1
-static void dm_check_edca_turbo(
- struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
-
- // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
- static unsigned long lastTxOkCnt = 0;
- static unsigned long lastRxOkCnt = 0;
- unsigned long curTxOkCnt = 0;
- unsigned long curRxOkCnt = 0;
-
- u32 EDCA_BE_UL = edca_setting_UL[pHTInfo->IOTPeer];
- u32 EDCA_BE_DL = edca_setting_DL[pHTInfo->IOTPeer];
- #if 1
- if(priv->ieee80211->state != IEEE80211_LINKED)
- goto dm_CheckEdcaTurbo_EXIT;
- #endif
- // We do not turn on EDCA turbo mode for some AP that has IOT issue
- if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO)
- goto dm_CheckEdcaTurbo_EXIT;
-
- if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_FORCED_ENABLE_BE_TXOP)
- {
- if(!(EDCA_BE_UL & 0xffff0000))
- EDCA_BE_UL |= 0x005e0000;
- if(!(EDCA_BE_DL & 0xffff0000))
- EDCA_BE_DL |= 0x005e0000;
- }
-
- {
- u8* peername[11] = {"unknown", "realtek", "realtek_92se", "broadcom", "ralink", "atheros", "cisco", "marvell", "92u_softap", "self_softap"};
- static int wb_tmp = 0;
- if (wb_tmp == 0){
- printk("%s():iot peer is %#x:%s, bssid:%pM\n",__FUNCTION__,pHTInfo->IOTPeer,peername[pHTInfo->IOTPeer], priv->ieee80211->current_network.bssid);
- wb_tmp = 1;
- }
- }
- // Check the status for current condition.
- if(!priv->ieee80211->bis_any_nonbepkts)
- {
- curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
- curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
- // Modify EDCA parameters selection bias
- // For some APs, use downlink EDCA parameters for uplink+downlink
- if(priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX)
- {
- if(curTxOkCnt > 4*curRxOkCnt)
- {
- if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
- {
- write_nic_dword(dev, EDCAPARA_BE, EDCA_BE_UL);
- priv->bis_cur_rdlstate = false;
- }
- }
- else
- {
- if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
- {
- write_nic_dword(dev, EDCAPARA_BE, EDCA_BE_DL);
- priv->bis_cur_rdlstate = true;
- }
- }
- priv->bcurrent_turbo_EDCA = true;
- }
- else
- {
- if(curRxOkCnt > 4*curTxOkCnt)
- {
- if(!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
- {
- write_nic_dword(dev, EDCAPARA_BE, EDCA_BE_DL);
- priv->bis_cur_rdlstate = true;
- }
- }
- else
- {
- if(priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA)
- {
- write_nic_dword(dev, EDCAPARA_BE, EDCA_BE_UL);
- priv->bis_cur_rdlstate = false;
- }
- }
- priv->bcurrent_turbo_EDCA = true;
- }
- }
- else
- {
- //
- // Turn Off EDCA turbo here.
- // Restore original EDCA according to the declaration of AP.
- //
- if(priv->bcurrent_turbo_EDCA)
- {
-
- {
- u8 u1bAIFS;
- u32 u4bAcParam;
- struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters;
- u8 mode = priv->ieee80211->mode;
-
- // For Each time updating EDCA parameter, reset EDCA turbo mode status.
- dm_init_edca_turbo(dev);
- u1bAIFS = qos_parameters->aifs[0] * ((mode&(IEEE_G|IEEE_N_24G)) ?9:20) + aSifsTime;
- u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[0]))<< AC_PARAM_TXOP_LIMIT_OFFSET)|
- (((u32)(qos_parameters->cw_max[0]))<< AC_PARAM_ECW_MAX_OFFSET)|
- (((u32)(qos_parameters->cw_min[0]))<< AC_PARAM_ECW_MIN_OFFSET)|
- ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
-
- write_nic_dword(dev, EDCAPARA_BE, u4bAcParam);
-
- // Check ACM bit.
- // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.
- {
- // TODO: Modified this part and try to set acm control in only 1 IO processing!!
-
- PACI_AIFSN pAciAifsn = (PACI_AIFSN)&(qos_parameters->aifs[0]);
- u8 AcmCtrl = priv->AcmControl | 0x1;
- if( pAciAifsn->f.ACM )
- { // ACM bit is 1.
- AcmCtrl |= AcmHw_BeqEn;
- }
- else
- { // ACM bit is 0.
- AcmCtrl &= (~AcmHw_BeqEn);
- }
-
- RT_TRACE( COMP_QOS,"SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ) ;
- write_nic_byte(dev, AcmHwCtrl, AcmCtrl );
- }
- }
- priv->bcurrent_turbo_EDCA = false;
- }
- }
-
-
-dm_CheckEdcaTurbo_EXIT:
- // Set variables for next time.
- priv->ieee80211->bis_any_nonbepkts = false;
- lastTxOkCnt = priv->stats.txbytesunicast;
- lastRxOkCnt = priv->stats.rxbytesunicast;
-}
-#endif
-
-extern void DM_CTSToSelfSetting(struct net_device * dev,u32 DM_Type, u32 DM_Value)
-{
- struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
-
- if (DM_Type == 0) // CTS to self disable/enable
- {
- if(DM_Value > 1)
- DM_Value = 1;
- priv->ieee80211->bCTSToSelfEnable = (bool)DM_Value;
- //DbgPrint("pMgntInfo->bCTSToSelfEnable = %d\n", pMgntInfo->bCTSToSelfEnable);
- }
- else if(DM_Type == 1) //CTS to self Th
- {
- if(DM_Value >= 50)
- DM_Value = 50;
- priv->ieee80211->CTSToSelfTH = (u8)DM_Value;
- //DbgPrint("pMgntInfo->CTSToSelfTH = %d\n", pMgntInfo->CTSToSelfTH);
- }
-}
-
-static void dm_init_ctstoself(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
-
- priv->ieee80211->bCTSToSelfEnable = TRUE;
- priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal;
-}
-
-static void dm_ctstoself(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
- PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
- static unsigned long lastTxOkCnt = 0;
- static unsigned long lastRxOkCnt = 0;
- unsigned long curTxOkCnt = 0;
- unsigned long curRxOkCnt = 0;
-
- if(priv->ieee80211->bCTSToSelfEnable != TRUE)
- {
- pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
- return;
- }
- /*
- 1. Uplink
- 2. Linksys350/Linksys300N
- 3. <50 disable, >55 enable
- */
-
- if(pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM)
- {
- curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt;
- curRxOkCnt = priv->stats.rxbytesunicast - lastRxOkCnt;
- if(curRxOkCnt > 4*curTxOkCnt) //downlink, disable CTS to self
- {
- pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
- //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled -- downlink\n");
- }
- else //uplink
- {
- #if 1
- pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
- #else
- if(priv->undecorated_smoothed_pwdb < priv->ieee80211->CTSToSelfTH) // disable CTS to self
- {
- pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
- //DbgPrint("dm_CTSToSelf() ==> CTS to self disabled\n");
- }
- else if(priv->undecorated_smoothed_pwdb >= (priv->ieee80211->CTSToSelfTH+5)) // enable CTS to self
- {
- pHTInfo->IOTAction |= HT_IOT_ACT_FORCED_CTS2SELF;
- //DbgPrint("dm_CTSToSelf() ==> CTS to self enabled\n");
- }
- #endif
- }
-
- lastTxOkCnt = priv->stats.txbytesunicast;
- lastRxOkCnt = priv->stats.rxbytesunicast;
- }
-}
-
-/*-----------------------------------------------------------------------------
- * Function: dm_check_rfctrl_gpio()
- *
- * Overview: Copy 8187B template for 9xseries.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/28/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-#if 1
-static void dm_check_rfctrl_gpio(struct net_device * dev)
-{
- //struct r8192_priv *priv = ieee80211_priv(dev);
-
- // Walk around for DTM test, we will not enable HW - radio on/off because r/w
- // page 1 register before Lextra bus is enabled cause system fails when resuming
- // from S4. 20080218, Emily
-
- // Stop to execute workitem to prevent S3/S4 bug.
-#ifdef RTL8190P
- return;
-#endif
-#ifdef RTL8192U
- return;
-#endif
- return;
-#ifdef RTL8192E
- queue_delayed_work(priv->priv_wq,&priv->gpio_change_rf_wq,0);
-#endif
-
-} /* dm_CheckRfCtrlGPIO */
-
-#endif
-/*-----------------------------------------------------------------------------
- * Function: dm_check_pbc_gpio()
- *
- * Overview: Check if PBC button is pressed.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/28/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static void dm_check_pbc_gpio(struct net_device *dev)
-{
-#ifdef RTL8192U
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 tmp1byte;
-
-
- tmp1byte = read_nic_byte(dev,GPI);
- if(tmp1byte == 0xff)
- return;
-
- if (tmp1byte&BIT6 || tmp1byte&BIT0)
- {
- // Here we only set bPbcPressed to TRUE
- // After trigger PBC, the variable will be set to FALSE
- RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n");
- priv->bpbc_pressed = true;
- }
-#endif
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 tmp1byte;
-
- write_nic_byte(dev, MAC_PINMUX_CFG, (GPIOMUX_EN | GPIOSEL_GPIO));
-
- tmp1byte = read_nic_byte(dev, GPIO_IO_SEL);
- tmp1byte &= ~(HAL_8192S_HW_GPIO_WPS_BIT);
- write_nic_byte(dev, GPIO_IO_SEL, tmp1byte);
-
- tmp1byte = read_nic_byte(dev, GPIO_IN);
-
- RT_TRACE(COMP_IO, "CheckPbcGPIO - %x\n", tmp1byte);
-
- // Add by hpfan 2008.07.07 to fix read GPIO error from S3
- if (tmp1byte == 0xff)
- return ;
-
- if (tmp1byte&HAL_8192S_HW_GPIO_WPS_BIT)
- {
- // Here we only set bPbcPressed to TRUE
- // After trigger PBC, the variable will be set to FALSE
- RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n");
- priv->bpbc_pressed = true;
- }
-
-
-
-}
-
-#ifdef RTL8192E
-
-/*-----------------------------------------------------------------------------
- * Function: dm_GPIOChangeRF
- * Overview: PCI will not support workitem call back HW radio on-off control.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 02/21/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern void dm_gpio_change_rf_callback(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,gpio_change_rf_wq);
- struct net_device *dev = priv->ieee80211->dev;
- u8 tmp1byte;
- RT_RF_POWER_STATE eRfPowerStateToSet;
- bool bActuallySet = false;
-
- do{
- bActuallySet=false;
-
- if(!priv->up)
- {
- RT_TRACE((COMP_INIT | COMP_POWER | COMP_RF),"dm_gpio_change_rf_callback(): Callback function breaks out!!\n");
- }
- else
- {
- // 0x108 GPIO input register is read only
- //set 0x108 B1= 1: RF-ON; 0: RF-OFF.
- tmp1byte = read_nic_byte(dev,GPI);
-
- eRfPowerStateToSet = (tmp1byte&BIT1) ? eRfOn : eRfOff;
-
- if( (priv->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn))
- {
- RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio ON\n");
-
- priv->bHwRadioOff = false;
- bActuallySet = true;
- }
- else if ( (priv->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff))
- {
- RT_TRACE(COMP_RF, "gpiochangeRF - HW Radio OFF\n");
- priv->bHwRadioOff = true;
- bActuallySet = true;
- }
-
- if(bActuallySet)
- {
- #ifdef TO_DO
- MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW);
- //DrvIFIndicateCurrentPhyStatus(pAdapter);
- #endif
- }
- else
- {
- msleep(2000);
- }
-
- }
- }while(TRUE)
-
-} /* dm_GPIOChangeRF */
-
-#endif
-/*-----------------------------------------------------------------------------
- * Function: DM_RFPathCheckWorkItemCallBack()
- *
- * Overview: Check if Current RF RX path is enabled
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 01/30/2008 MHC Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work)
-{
- struct delayed_work *dwork = container_of(work,struct delayed_work,work);
- struct r8192_priv *priv = container_of(dwork,struct r8192_priv,rfpath_check_wq);
- struct net_device *dev =priv->ieee80211->dev;
- //bool bactually_set = false;
- u8 rfpath = 0, i;
-
-
- /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will
- always be the same. We only read 0xc04 now. */
- rfpath = read_nic_byte(dev, 0xc04);
-
- // Check Bit 0-3, it means if RF A-D is enabled.
- for (i = 0; i < RF90_PATH_MAX; i++)
- {
- if (rfpath & (0x01<<i))
- priv->brfpath_rxenable[i] = 1;
- else
- priv->brfpath_rxenable[i] = 0;
- }
- if(!DM_RxPathSelTable.Enable)
- return;
-
- dm_rxpath_sel_byrssi(dev);
-} /* DM_RFPathCheckWorkItemCallBack */
-
-static void dm_init_rxpath_selection(struct net_device * dev)
-{
- u8 i;
- struct r8192_priv *priv = ieee80211_priv(dev);
- DM_RxPathSelTable.Enable = 1; //default enabled
- DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low;
- DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH;
- if(priv->CustomerID == RT_CID_819x_Netcore)
- DM_RxPathSelTable.cck_method = CCK_Rx_Version_2;
- else
- DM_RxPathSelTable.cck_method = CCK_Rx_Version_1;
- DM_RxPathSelTable.DbgMode = DM_DBG_OFF;
- DM_RxPathSelTable.disabledRF = 0;
- for(i=0; i<4; i++)
- {
- DM_RxPathSelTable.rf_rssi[i] = 50;
- DM_RxPathSelTable.cck_pwdb_sta[i] = -64;
- DM_RxPathSelTable.rf_enable_rssi_th[i] = 100;
- }
-}
-
-static void dm_rxpath_sel_byrssi(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 i, max_rssi_index=0, min_rssi_index=0, sec_rssi_index=0, rf_num=0;
- u8 tmp_max_rssi=0, tmp_min_rssi=0, tmp_sec_rssi=0;
- u8 cck_default_Rx=0x2; //RF-C
- u8 cck_optional_Rx=0x3;//RF-D
- long tmp_cck_max_pwdb=0, tmp_cck_min_pwdb=0, tmp_cck_sec_pwdb=0;
- u8 cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0;
- u8 cur_rf_rssi;
- long cur_cck_pwdb;
- static u8 disabled_rf_cnt=0, cck_Rx_Path_initialized=0;
- u8 update_cck_rx_path;
-
- if(priv->rf_type != RF_2T4R)
- return;
-
- if(!cck_Rx_Path_initialized)
- {
- DM_RxPathSelTable.cck_Rx_path = (read_nic_byte(dev, 0xa07)&0xf);
- cck_Rx_Path_initialized = 1;
- }
-
- DM_RxPathSelTable.disabledRF = 0xf;
- DM_RxPathSelTable.disabledRF &=~ (read_nic_byte(dev, 0xc04));
-
- if(priv->ieee80211->mode == WIRELESS_MODE_B)
- {
- DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; //pure B mode, fixed cck version2
- //DbgPrint("Pure B mode, use cck rx version2 \n");
- }
-
- //decide max/sec/min rssi index
- for (i=0; i<RF90_PATH_MAX; i++)
- {
- if(!DM_RxPathSelTable.DbgMode)
- DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i];
-
- if(priv->brfpath_rxenable[i])
- {
- rf_num++;
- cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i];
-
- if(rf_num == 1) // find first enabled rf path and the rssi values
- { //initialize, set all rssi index to the same one
- max_rssi_index = min_rssi_index = sec_rssi_index = i;
- tmp_max_rssi = tmp_min_rssi = tmp_sec_rssi = cur_rf_rssi;
- }
- else if(rf_num == 2)
- { // we pick up the max index first, and let sec and min to be the same one
- if(cur_rf_rssi >= tmp_max_rssi)
- {
- tmp_max_rssi = cur_rf_rssi;
- max_rssi_index = i;
- }
- else
- {
- tmp_sec_rssi = tmp_min_rssi = cur_rf_rssi;
- sec_rssi_index = min_rssi_index = i;
- }
- }
- else
- {
- if(cur_rf_rssi > tmp_max_rssi)
- {
- tmp_sec_rssi = tmp_max_rssi;
- sec_rssi_index = max_rssi_index;
- tmp_max_rssi = cur_rf_rssi;
- max_rssi_index = i;
- }
- else if(cur_rf_rssi == tmp_max_rssi)
- { // let sec and min point to the different index
- tmp_sec_rssi = cur_rf_rssi;
- sec_rssi_index = i;
- }
- else if((cur_rf_rssi < tmp_max_rssi) &&(cur_rf_rssi > tmp_sec_rssi))
- {
- tmp_sec_rssi = cur_rf_rssi;
- sec_rssi_index = i;
- }
- else if(cur_rf_rssi == tmp_sec_rssi)
- {
- if(tmp_sec_rssi == tmp_min_rssi)
- { // let sec and min point to the different index
- tmp_sec_rssi = cur_rf_rssi;
- sec_rssi_index = i;
- }
- else
- {
- // This case we don't need to set any index
- }
- }
- else if((cur_rf_rssi < tmp_sec_rssi) && (cur_rf_rssi > tmp_min_rssi))
- {
- // This case we don't need to set any index
- }
- else if(cur_rf_rssi == tmp_min_rssi)
- {
- if(tmp_sec_rssi == tmp_min_rssi)
- { // let sec and min point to the different index
- tmp_min_rssi = cur_rf_rssi;
- min_rssi_index = i;
- }
- else
- {
- // This case we don't need to set any index
- }
- }
- else if(cur_rf_rssi < tmp_min_rssi)
- {
- tmp_min_rssi = cur_rf_rssi;
- min_rssi_index = i;
- }
- }
- }
- }
-
- rf_num = 0;
- // decide max/sec/min cck pwdb index
- if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2)
- {
- for (i=0; i<RF90_PATH_MAX; i++)
- {
- if(priv->brfpath_rxenable[i])
- {
- rf_num++;
- cur_cck_pwdb = DM_RxPathSelTable.cck_pwdb_sta[i];
-
- if(rf_num == 1) // find first enabled rf path and the rssi values
- { //initialize, set all rssi index to the same one
- cck_rx_ver2_max_index = cck_rx_ver2_min_index = cck_rx_ver2_sec_index = i;
- tmp_cck_max_pwdb = tmp_cck_min_pwdb = tmp_cck_sec_pwdb = cur_cck_pwdb;
- }
- else if(rf_num == 2)
- { // we pick up the max index first, and let sec and min to be the same one
- if(cur_cck_pwdb >= tmp_cck_max_pwdb)
- {
- tmp_cck_max_pwdb = cur_cck_pwdb;
- cck_rx_ver2_max_index = i;
- }
- else
- {
- tmp_cck_sec_pwdb = tmp_cck_min_pwdb = cur_cck_pwdb;
- cck_rx_ver2_sec_index = cck_rx_ver2_min_index = i;
- }
- }
- else
- {
- if(cur_cck_pwdb > tmp_cck_max_pwdb)
- {
- tmp_cck_sec_pwdb = tmp_cck_max_pwdb;
- cck_rx_ver2_sec_index = cck_rx_ver2_max_index;
- tmp_cck_max_pwdb = cur_cck_pwdb;
- cck_rx_ver2_max_index = i;
- }
- else if(cur_cck_pwdb == tmp_cck_max_pwdb)
- { // let sec and min point to the different index
- tmp_cck_sec_pwdb = cur_cck_pwdb;
- cck_rx_ver2_sec_index = i;
- }
- else if((cur_cck_pwdb < tmp_cck_max_pwdb) &&(cur_cck_pwdb > tmp_cck_sec_pwdb))
- {
- tmp_cck_sec_pwdb = cur_cck_pwdb;
- cck_rx_ver2_sec_index = i;
- }
- else if(cur_cck_pwdb == tmp_cck_sec_pwdb)
- {
- if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb)
- { // let sec and min point to the different index
- tmp_cck_sec_pwdb = cur_cck_pwdb;
- cck_rx_ver2_sec_index = i;
- }
- else
- {
- // This case we don't need to set any index
- }
- }
- else if((cur_cck_pwdb < tmp_cck_sec_pwdb) && (cur_cck_pwdb > tmp_cck_min_pwdb))
- {
- // This case we don't need to set any index
- }
- else if(cur_cck_pwdb == tmp_cck_min_pwdb)
- {
- if(tmp_cck_sec_pwdb == tmp_cck_min_pwdb)
- { // let sec and min point to the different index
- tmp_cck_min_pwdb = cur_cck_pwdb;
- cck_rx_ver2_min_index = i;
- }
- else
- {
- // This case we don't need to set any index
- }
- }
- else if(cur_cck_pwdb < tmp_cck_min_pwdb)
- {
- tmp_cck_min_pwdb = cur_cck_pwdb;
- cck_rx_ver2_min_index = i;
- }
- }
-
- }
- }
- }
-
-
- // Set CCK Rx path
- // reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path.
- update_cck_rx_path = 0;
- if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_2)
- {
- cck_default_Rx = cck_rx_ver2_max_index;
- cck_optional_Rx = cck_rx_ver2_sec_index;
- if(tmp_cck_max_pwdb != -64)
- update_cck_rx_path = 1;
- }
-
- if(tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2)
- {
- if((tmp_max_rssi - tmp_min_rssi) >= DM_RxPathSelTable.diff_TH)
- {
- //record the enabled rssi threshold
- DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5;
- //disable the BB Rx path, OFDM
- rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xc04[3:0]
- rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<min_rssi_index, 0x0); // 0xd04[3:0]
- disabled_rf_cnt++;
- }
- if(DM_RxPathSelTable.cck_method == CCK_Rx_Version_1)
- {
- cck_default_Rx = max_rssi_index;
- cck_optional_Rx = sec_rssi_index;
- if(tmp_max_rssi)
- update_cck_rx_path = 1;
- }
- }
-
- if(update_cck_rx_path)
- {
- DM_RxPathSelTable.cck_Rx_path = (cck_default_Rx<<2)|(cck_optional_Rx);
- rtl8192_setBBreg(dev, rCCK0_AFESetting, 0x0f000000, DM_RxPathSelTable.cck_Rx_path);
- }
-
- if(DM_RxPathSelTable.disabledRF)
- {
- for(i=0; i<4; i++)
- {
- if((DM_RxPathSelTable.disabledRF>>i) & 0x1) //disabled rf
- {
- if(tmp_max_rssi >= DM_RxPathSelTable.rf_enable_rssi_th[i])
- {
- //enable the BB Rx path
- //DbgPrint("RF-%d is enabled. \n", 0x1<<i);
- rtl8192_setBBreg(dev, rOFDM0_TRxPathEnable, 0x1<<i, 0x1); // 0xc04[3:0]
- rtl8192_setBBreg(dev, rOFDM1_TRxPathEnable, 0x1<<i, 0x1); // 0xd04[3:0]
- DM_RxPathSelTable.rf_enable_rssi_th[i] = 100;
- disabled_rf_cnt--;
- }
- }
- }
- }
-}
-
-/*-----------------------------------------------------------------------------
- * Function: dm_check_rx_path_selection()
- *
- * Overview: Call a workitem to check current RXRF path and Rx Path selection by RSSI.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/28/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-static void dm_check_rx_path_selection(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- queue_delayed_work(priv->priv_wq,&priv->rfpath_check_wq,0);
-} /* dm_CheckRxRFPath */
-
-
-static void dm_init_fsync (struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- priv->ieee80211->fsync_time_interval = 500;
- priv->ieee80211->fsync_rate_bitmap = 0x0f000800;
- priv->ieee80211->fsync_rssi_threshold = 30;
-#ifdef RTL8190P
- priv->ieee80211->bfsync_enable = true;
-#else
- priv->ieee80211->bfsync_enable = false;
-#endif
- priv->ieee80211->fsync_multiple_timeinterval = 3;
- priv->ieee80211->fsync_firstdiff_ratethreshold= 100;
- priv->ieee80211->fsync_seconddiff_ratethreshold= 200;
- priv->ieee80211->fsync_state = Default_Fsync;
- priv->framesyncMonitor = 1; // current default 0xc38 monitor on
-
- init_timer(&priv->fsync_timer);
- priv->fsync_timer.data = (unsigned long)dev;
- priv->fsync_timer.function = dm_fsync_timer_callback;
-}
-
-
-static void dm_deInit_fsync(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- del_timer_sync(&priv->fsync_timer);
-}
-
-extern void dm_fsync_timer_callback(unsigned long data)
-{
- struct net_device *dev = (struct net_device *)data;
- struct r8192_priv *priv = ieee80211_priv((struct net_device *)data);
- u32 rate_index, rate_count = 0, rate_count_diff=0;
- bool bSwitchFromCountDiff = false;
- bool bDoubleTimeInterval = false;
-
- if( priv->ieee80211->state == IEEE80211_LINKED &&
- priv->ieee80211->bfsync_enable &&
- (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC))
- {
- // Count rate 54, MCS [7], [12, 13, 14, 15]
- u32 rate_bitmap;
- for(rate_index = 0; rate_index <= 27; rate_index++)
- {
- rate_bitmap = 1 << rate_index;
- if(priv->ieee80211->fsync_rate_bitmap & rate_bitmap)
- rate_count+= priv->stats.received_rate_histogram[1][rate_index];
- }
-
- if(rate_count < priv->rate_record)
- rate_count_diff = 0xffffffff - rate_count + priv->rate_record;
- else
- rate_count_diff = rate_count - priv->rate_record;
- if(rate_count_diff < priv->rateCountDiffRecord)
- {
-
- u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff;
- // Contiune count
- if(DiffNum >= priv->ieee80211->fsync_seconddiff_ratethreshold)
- priv->ContiuneDiffCount++;
- else
- priv->ContiuneDiffCount = 0;
-
- // Contiune count over
- if(priv->ContiuneDiffCount >=2)
- {
- bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
- }
- }
- else
- {
- // Stop contiune count
- priv->ContiuneDiffCount = 0;
- }
-
- //If Count diff <= FsyncRateCountThreshold
- if(rate_count_diff <= priv->ieee80211->fsync_firstdiff_ratethreshold)
- {
- bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
- }
- priv->rate_record = rate_count;
- priv->rateCountDiffRecord = rate_count_diff;
- RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
- // if we never receive those mcs rate and rssi > 30 % then switch fsyn
- if(priv->undecorated_smoothed_pwdb > priv->ieee80211->fsync_rssi_threshold && bSwitchFromCountDiff)
- {
- bDoubleTimeInterval = true;
- priv->bswitch_fsync = !priv->bswitch_fsync;
- if(priv->bswitch_fsync)
- {
- #ifdef RTL8190P
- write_nic_byte(dev, 0xC36, 0x00);
- #else
- write_nic_byte(dev,0xC36, 0x1c);
- #endif
- write_nic_byte(dev, 0xC3e, 0x90);
- }
- else
- {
- #ifdef RTL8190P
- write_nic_byte(dev, 0xC36, 0x40);
- #else
- write_nic_byte(dev, 0xC36, 0x5c);
- #endif
- write_nic_byte(dev, 0xC3e, 0x96);
- }
- }
- else if(priv->undecorated_smoothed_pwdb <= priv->ieee80211->fsync_rssi_threshold)
- {
- if(priv->bswitch_fsync)
- {
- priv->bswitch_fsync = false;
- #ifdef RTL8190P
- write_nic_byte(dev, 0xC36, 0x40);
- #else
- write_nic_byte(dev, 0xC36, 0x5c);
- #endif
- write_nic_byte(dev, 0xC3e, 0x96);
- }
- }
- if(bDoubleTimeInterval){
- if(timer_pending(&priv->fsync_timer))
- del_timer_sync(&priv->fsync_timer);
- priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval);
- add_timer(&priv->fsync_timer);
- }
- else{
- if(timer_pending(&priv->fsync_timer))
- del_timer_sync(&priv->fsync_timer);
- priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval);
- add_timer(&priv->fsync_timer);
- }
- }
- else
- {
- // Let Register return to default value;
- if(priv->bswitch_fsync)
- {
- priv->bswitch_fsync = false;
- #ifdef RTL8190P
- write_nic_byte(dev, 0xC36, 0x40);
- #else
- write_nic_byte(dev, 0xC36, 0x5c);
- #endif
- write_nic_byte(dev, 0xC3e, 0x96);
- }
- priv->ContiuneDiffCount = 0;
- rtl8192_setBBreg(dev, rOFDM0_RxDetector2, bMaskDWord, 0x164052cd);
- }
- RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount);
- RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
-}
-
-static void dm_StartHWFsync(struct net_device *dev)
-{
- RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
- write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cf);
- write_nic_byte(dev, 0xc3b, 0x41);
-}
-
-static void dm_EndSWFsync(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- RT_TRACE(COMP_HALDM, "%s\n", __FUNCTION__);
- del_timer_sync(&(priv->fsync_timer));
-
- // Let Register return to default value;
- if(priv->bswitch_fsync)
- {
- priv->bswitch_fsync = false;
-
- #ifdef RTL8190P
- write_nic_byte(dev, 0xC36, 0x40);
- #else
- write_nic_byte(dev, 0xC36, 0x5c);
- #endif
-
- write_nic_byte(dev, 0xC3e, 0x96);
- }
-
- priv->ContiuneDiffCount = 0;
-#ifndef RTL8190P
- write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
-#endif
-
-}
-
-static void dm_StartSWFsync(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 rateIndex;
- u32 rateBitmap;
-
- RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
- // Initial rate record to zero, start to record.
- priv->rate_record = 0;
- // Initial contiune diff count to zero, start to record.
- priv->ContiuneDiffCount = 0;
- priv->rateCountDiffRecord = 0;
- priv->bswitch_fsync = false;
-
- if(priv->ieee80211->mode == WIRELESS_MODE_N_24G)
- {
- priv->ieee80211->fsync_firstdiff_ratethreshold= 600;
- priv->ieee80211->fsync_seconddiff_ratethreshold = 0xffff;
- }
- else
- {
- priv->ieee80211->fsync_firstdiff_ratethreshold= 200;
- priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
- }
- for(rateIndex = 0; rateIndex <= 27; rateIndex++)
- {
- rateBitmap = 1 << rateIndex;
- if(priv->ieee80211->fsync_rate_bitmap & rateBitmap)
- priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex];
- }
- if(timer_pending(&priv->fsync_timer))
- del_timer_sync(&priv->fsync_timer);
- priv->fsync_timer.expires = jiffies + MSECS(priv->ieee80211->fsync_time_interval);
- add_timer(&priv->fsync_timer);
-
-#ifndef RTL8190P
- write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
-#endif
-
-}
-
-static void dm_EndHWFsync(struct net_device *dev)
-{
- RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
- write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
- write_nic_byte(dev, 0xc3b, 0x49);
-
-}
-
-void dm_check_fsync(struct net_device *dev)
-{
-#define RegC38_Default 0
-#define RegC38_NonFsync_Other_AP 1
-#define RegC38_Fsync_AP_BCM 2
- struct r8192_priv *priv = ieee80211_priv(dev);
- //u32 framesyncC34;
- static u8 reg_c38_State=RegC38_Default;
- static u32 reset_cnt=0;
-
- RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->ieee80211->fsync_rssi_threshold, priv->ieee80211->fsync_time_interval, priv->ieee80211->fsync_multiple_timeinterval);
- RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->ieee80211->fsync_rate_bitmap, priv->ieee80211->fsync_firstdiff_ratethreshold, priv->ieee80211->fsync_seconddiff_ratethreshold);
-
- if( priv->ieee80211->state == IEEE80211_LINKED &&
- (priv->ieee80211->pHTInfo->IOTAction & HT_IOT_ACT_CDD_FSYNC))
- {
- if(priv->ieee80211->bfsync_enable == 0)
- {
- switch(priv->ieee80211->fsync_state)
- {
- case Default_Fsync:
- dm_StartHWFsync(dev);
- priv->ieee80211->fsync_state = HW_Fsync;
- break;
- case SW_Fsync:
- dm_EndSWFsync(dev);
- dm_StartHWFsync(dev);
- priv->ieee80211->fsync_state = HW_Fsync;
- break;
- case HW_Fsync:
- default:
- break;
- }
- }
- else
- {
- switch(priv->ieee80211->fsync_state)
- {
- case Default_Fsync:
- dm_StartSWFsync(dev);
- priv->ieee80211->fsync_state = SW_Fsync;
- break;
- case HW_Fsync:
- dm_EndHWFsync(dev);
- dm_StartSWFsync(dev);
- priv->ieee80211->fsync_state = SW_Fsync;
- break;
- case SW_Fsync:
- default:
- break;
-
- }
- }
- if(priv->framesyncMonitor)
- {
- if(reg_c38_State != RegC38_Fsync_AP_BCM)
- { //For broadcom AP we write different default value
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector3, 0x15);
- #else
- write_nic_byte(dev, rOFDM0_RxDetector3, 0x95);
- #endif
-
- reg_c38_State = RegC38_Fsync_AP_BCM;
- }
- }
- }
- else
- {
- switch(priv->ieee80211->fsync_state)
- {
- case HW_Fsync:
- dm_EndHWFsync(dev);
- priv->ieee80211->fsync_state = Default_Fsync;
- break;
- case SW_Fsync:
- dm_EndSWFsync(dev);
- priv->ieee80211->fsync_state = Default_Fsync;
- break;
- case Default_Fsync:
- default:
- break;
- }
-
- if(priv->framesyncMonitor)
- {
- if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- if(priv->undecorated_smoothed_pwdb <= RegC38_TH)
- {
- if(reg_c38_State != RegC38_NonFsync_Other_AP)
- {
- #ifdef RTL8190P
- write_nic_byte(dev, rOFDM0_RxDetector3, 0x10);
- #else
- write_nic_byte(dev, rOFDM0_RxDetector3, 0x90);
- #endif
-
- reg_c38_State = RegC38_NonFsync_Other_AP;
- }
- }
- else if(priv->undecorated_smoothed_pwdb >= (RegC38_TH+5))
- {
- if(reg_c38_State)
- {
- write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
- reg_c38_State = RegC38_Default;
- //DbgPrint("Fsync is idle, rssi>=40, write 0xc38 = 0x%x \n", pHalData->framesync);
- }
- }
- }
- else
- {
- if(reg_c38_State)
- {
- write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
- reg_c38_State = RegC38_Default;
- //DbgPrint("Fsync is idle, not connected, write 0xc38 = 0x%x \n", pHalData->framesync);
- }
- }
- }
- }
- if(priv->framesyncMonitor)
- {
- if(priv->reset_count != reset_cnt)
- { //After silent reset, the reg_c38_State will be returned to default value
- write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
- reg_c38_State = RegC38_Default;
- reset_cnt = priv->reset_count;
- //DbgPrint("reg_c38_State = 0 for silent reset. \n");
- }
- }
- else
- {
- if(reg_c38_State)
- {
- write_nic_byte(dev, rOFDM0_RxDetector3, priv->framesync);
- reg_c38_State = RegC38_Default;
- //DbgPrint("framesync no monitor, write 0xc38 = 0x%x \n", pHalData->framesync);
- }
- }
-}
-
-/*-----------------------------------------------------------------------------
- * Function: dm_shadow_init()
- *
- * Overview: Store all NIC MAC/BB register content.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/29/2008 amy Create Version 0 porting from windows code.
- *
- *---------------------------------------------------------------------------*/
-extern void dm_shadow_init(struct net_device *dev)
-{
- u8 page;
- u16 offset;
-
- for (page = 0; page < 5; page++)
- for (offset = 0; offset < 256; offset++)
- {
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
- //DbgPrint("P-%d/O-%02x=%02x\r\n", page, offset, DM_Shadow[page][offset]);
- }
-
- for (page = 8; page < 11; page++)
- for (offset = 0; offset < 256; offset++)
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
-
- for (page = 12; page < 15; page++)
- for (offset = 0; offset < 256; offset++)
- dm_shadow[page][offset] = read_nic_byte(dev, offset+page*256);
-
-} /* dm_shadow_init */
-
-/*---------------------------Define function prototype------------------------*/
-/*-----------------------------------------------------------------------------
- * Function: DM_DynamicTxPower()
- *
- * Overview: Detect Signal strength to control TX Registry
- Tx Power Control For Near/Far Range
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 03/06/2008 Jacken Create Version 0.
- *
- *---------------------------------------------------------------------------*/
-static void dm_init_dynamic_txpower(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- //Initial TX Power Control for near/far range , add by amy 2008/05/15, porting from windows code.
- priv->ieee80211->bdynamic_txpower_enable = true; //Default to enable Tx Power Control
- priv->bLastDTPFlag_High = false;
- priv->bLastDTPFlag_Low = false;
- priv->bDynamicTxHighPower = false;
- priv->bDynamicTxLowPower = false;
-}
-
-static void dm_dynamic_txpower(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- unsigned int txhipower_threshhold=0;
- unsigned int txlowpower_threshold=0;
- if(priv->ieee80211->bdynamic_txpower_enable != true)
- {
- priv->bDynamicTxHighPower = false;
- priv->bDynamicTxLowPower = false;
- return;
- }
- //printk("priv->ieee80211->current_network.unknown_cap_exist is %d ,priv->ieee80211->current_network.broadcom_cap_exist is %d\n",priv->ieee80211->current_network.unknown_cap_exist,priv->ieee80211->current_network.broadcom_cap_exist);
- if((priv->ieee80211->current_network.atheros_cap_exist ) && (priv->ieee80211->mode == IEEE_G)){
- txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH;
- txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW;
- }
- else
- {
- txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH;
- txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW;
- }
-
-// printk("=======>%s(): txhipower_threshhold is %d,txlowpower_threshold is %d\n",__FUNCTION__,txhipower_threshhold,txlowpower_threshold);
- RT_TRACE(COMP_TXAGC,"priv->undecorated_smoothed_pwdb = %ld \n" , priv->undecorated_smoothed_pwdb);
-
- if(priv->ieee80211->state == IEEE80211_LINKED)
- {
- if(priv->undecorated_smoothed_pwdb >= txhipower_threshhold)
- {
- priv->bDynamicTxHighPower = true;
- priv->bDynamicTxLowPower = false;
- }
- else
- {
- // high power state check
- if(priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true)
- {
- priv->bDynamicTxHighPower = false;
- }
- // low power state check
- if(priv->undecorated_smoothed_pwdb < 35)
- {
- priv->bDynamicTxLowPower = true;
- }
- else if(priv->undecorated_smoothed_pwdb >= 40)
- {
- priv->bDynamicTxLowPower = false;
- }
- }
- }
- else
- {
- //pHalData->bTXPowerCtrlforNearFarRange = !pHalData->bTXPowerCtrlforNearFarRange;
- priv->bDynamicTxHighPower = false;
- priv->bDynamicTxLowPower = false;
- }
-
- if( (priv->bDynamicTxHighPower != priv->bLastDTPFlag_High ) ||
- (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low ) )
- {
- RT_TRACE(COMP_TXAGC,"SetTxPowerLevel8190() channel = %d \n" , priv->ieee80211->current_network.channel);
- }
- priv->bLastDTPFlag_High = priv->bDynamicTxHighPower;
- priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower;
-
-} /* dm_dynamic_txpower */
-
-//added by vivi, for read tx rate and retrycount
-static void dm_check_txrateandretrycount(struct net_device * dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- //for 11n tx rate
-// priv->stats.CurrentShowTxate = read_nic_byte(dev, Current_Tx_Rate_Reg);
- ieee->softmac_stats.CurrentShowTxate = read_nic_byte(dev, TX_RATE_REG);
- //printk("=============>tx_rate_reg:%x\n", ieee->softmac_stats.CurrentShowTxate);
- //for initial tx rate
-// priv->stats.last_packet_rate = read_nic_byte(dev, Initial_Tx_Rate_Reg);
- ieee->softmac_stats.last_packet_rate = read_nic_byte(dev ,Initial_Tx_Rate_Reg);
- //for tx tx retry count
-// priv->stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
- ieee->softmac_stats.txretrycount = read_nic_dword(dev, Tx_Retry_Count_Reg);
-}
-
-static void dm_send_rssi_tofw(struct net_device *dev)
-{
-}
-
-#ifdef TO_DO_LIST
-static void
-dm_CheckProtection(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- //PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- u8 CurRate;
-
- if(priv->ieee80211->pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS|HT_IOT_ACT_FORCED_CTS2SELF))
- {
- CurRate = read_nic_byte(dev, INIMCS_SEL);
- if(CurRate <= DESC92S_RATE11M)
- priv->bDmDisableProtect = true;
- else
- priv->bDmDisableProtect = fasle;
- }
-}
-#endif
-
-/*---------------------------Define function prototype------------------------*/
-
diff --git a/drivers/staging/rtl8192su/r8192U_dm.h b/drivers/staging/rtl8192su/r8192U_dm.h
deleted file mode 100644
index 1b48436ce1ad..000000000000
--- a/drivers/staging/rtl8192su/r8192U_dm.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*****************************************************************************
- * Copyright(c) 2007, RealTEK Technology Inc. All Right Reserved.
- *
- * Module: Hal819xUsbDM.h (RTL8192 Header H File)
- *
- *
- * Note: For dynamic control definition constant structure.
- *
- *
- * Export:
- *
- * Abbrev:
- *
- * History:
- * Data Who Remark
- * 10/04/2007 MHC Create initial version.
- *
- *****************************************************************************/
- /* Check to see if the file has been included already. */
-#ifndef __R8192UDM_H__
-#define __R8192UDM_H__
-
-
-/*--------------------------Define Parameters-------------------------------*/
-#define DM_DIG_THRESH_HIGH 40
-#define DM_DIG_THRESH_LOW 35
-
-#define DM_DIG_HIGH_PWR_THRESH_HIGH 75
-#define DM_DIG_HIGH_PWR_THRESH_LOW 70
-
-#define BW_AUTO_SWITCH_HIGH_LOW 25
-#define BW_AUTO_SWITCH_LOW_HIGH 30
-
-#define DM_check_fsync_time_interval 500
-
-
-#define DM_DIG_BACKOFF 12
-#define DM_DIG_MAX 0x36
-#define DM_DIG_MIN 0x1c
-#define DM_DIG_MIN_Netcore 0x12
-
-#define RxPathSelection_SS_TH_low 30
-#define RxPathSelection_diff_TH 18
-
-#define RateAdaptiveTH_High 50
-#define RateAdaptiveTH_Low_20M 30
-#define RateAdaptiveTH_Low_40M 10
-#define VeryLowRSSI 15
-#define CTSToSelfTHVal 30
-
-//defined by vivi, for tx power track
-#define E_FOR_TX_POWER_TRACK 300
-//Dynamic Tx Power Control Threshold
-#define TX_POWER_NEAR_FIELD_THRESH_HIGH 68
-#define TX_POWER_NEAR_FIELD_THRESH_LOW 62
-//added by amy for atheros AP
-#define TX_POWER_ATHEROAP_THRESH_HIGH 78
-#define TX_POWER_ATHEROAP_THRESH_LOW 72
-
-//defined by vivi, for showing on UI
-#define Current_Tx_Rate_Reg 0x1b8
-#define Initial_Tx_Rate_Reg 0x1b9
-#define Tx_Retry_Count_Reg 0x1ac
-#define RegC38_TH 20
-/*--------------------------Define Parameters-------------------------------*/
-
-
-/*------------------------------Define structure----------------------------*/
-/* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
-typedef struct _dynamic_initial_gain_threshold_
-{
- u8 dig_enable_flag;
- u8 dig_algorithm;
- u8 dbg_mode;
- u8 dig_algorithm_switch;
-
- long rssi_low_thresh;
- long rssi_high_thresh;
-
- long rssi_high_power_lowthresh;
- long rssi_high_power_highthresh;
-
- u8 dig_state;
- u8 dig_highpwr_state;
- u8 cur_connect_state;
- u8 pre_connect_state;
-
- u8 curpd_thstate;
- u8 prepd_thstate;
- u8 curcs_ratio_state;
- u8 precs_ratio_state;
-
- u32 pre_ig_value;
- u32 cur_ig_value;
-
- u8 backoff_val;
- u8 rx_gain_range_max;
- u8 rx_gain_range_min;
- bool initialgain_lowerbound_state;
-
- long rssi_val;
-}dig_t;
-
-typedef enum tag_dynamic_init_gain_state_definition
-{
- DM_STA_DIG_OFF = 0,
- DM_STA_DIG_ON,
- DM_STA_DIG_MAX
-}dm_dig_sta_e;
-
-
-/* 2007/10/08 MH Define RATR state. */
-typedef enum tag_dynamic_ratr_state_definition
-{
- DM_RATR_STA_HIGH = 0,
- DM_RATR_STA_MIDDLE = 1,
- DM_RATR_STA_LOW = 2,
- DM_RATR_STA_MAX
-}dm_ratr_sta_e;
-
-/* 2007/10/11 MH Define DIG operation type. */
-typedef enum tag_dynamic_init_gain_operation_type_definition
-{
- DIG_TYPE_THRESH_HIGH = 0,
- DIG_TYPE_THRESH_LOW = 1,
- DIG_TYPE_THRESH_HIGHPWR_HIGH = 2,
- DIG_TYPE_THRESH_HIGHPWR_LOW = 3,
- DIG_TYPE_DBG_MODE = 4,
- DIG_TYPE_RSSI = 5,
- DIG_TYPE_ALGORITHM = 6,
- DIG_TYPE_BACKOFF = 7,
- DIG_TYPE_PWDB_FACTOR = 8,
- DIG_TYPE_RX_GAIN_MIN = 9,
- DIG_TYPE_RX_GAIN_MAX = 10,
- DIG_TYPE_ENABLE = 20,
- DIG_TYPE_DISABLE = 30,
- DIG_OP_TYPE_MAX
-}dm_dig_op_e;
-
-typedef enum tag_dig_algorithm_definition
-{
- DIG_ALGO_BY_FALSE_ALARM = 0,
- DIG_ALGO_BY_RSSI = 1,
- DIG_ALGO_MAX
-}dm_dig_alg_e;
-
-typedef enum tag_dig_dbgmode_definition
-{
- DIG_DBG_OFF = 0,
- DIG_DBG_ON = 1,
- DIG_DBG_MAX
-}dm_dig_dbg_e;
-
-typedef enum tag_dig_connect_definition
-{
- DIG_DISCONNECT = 0,
- DIG_CONNECT = 1,
- DIG_CONNECT_MAX
-}dm_dig_connect_e;
-
-typedef enum tag_dig_packetdetection_threshold_definition
-{
- DIG_PD_AT_LOW_POWER = 0,
- DIG_PD_AT_NORMAL_POWER = 1,
- DIG_PD_AT_HIGH_POWER = 2,
- DIG_PD_MAX
-}dm_dig_pd_th_e;
-
-typedef enum tag_dig_cck_cs_ratio_state_definition
-{
- DIG_CS_RATIO_LOWER = 0,
- DIG_CS_RATIO_HIGHER = 1,
- DIG_CS_MAX
-}dm_dig_cs_ratio_e;
-typedef struct _Dynamic_Rx_Path_Selection_
-{
- u8 Enable;
- u8 DbgMode;
- u8 cck_method;
- u8 cck_Rx_path;
-
- u8 SS_TH_low;
- u8 diff_TH;
- u8 disabledRF;
- u8 reserved;
-
- u8 rf_rssi[4];
- u8 rf_enable_rssi_th[4];
- long cck_pwdb_sta[4];
-}DRxPathSel;
-
-typedef enum tag_CCK_Rx_Path_Method_Definition
-{
- CCK_Rx_Version_1 = 0,
- CCK_Rx_Version_2= 1,
- CCK_Rx_Version_MAX
-}DM_CCK_Rx_Path_Method;
-
-typedef enum tag_DM_DbgMode_Definition
-{
- DM_DBG_OFF = 0,
- DM_DBG_ON = 1,
- DM_DBG_MAX
-}DM_DBG_E;
-
-typedef struct tag_Tx_Config_Cmd_Format
-{
- u32 Op; /* Command packet type. */
- u32 Length; /* Command packet length. */
- u32 Value;
-}DCMD_TXCMD_T, *PDCMD_TXCMD_T;
-/*------------------------------Define structure----------------------------*/
-
-
-/*------------------------Export global variable----------------------------*/
-extern dig_t dm_digtable;
-extern u8 dm_shadow[16][256];
-extern DRxPathSel DM_RxPathSelTable;
-/*------------------------Export global variable----------------------------*/
-
-
-/*------------------------Export Marco Definition---------------------------*/
-
-/*------------------------Export Marco Definition---------------------------*/
-
-
-/*--------------------------Exported Function prototype---------------------*/
-extern void init_hal_dm(struct net_device *dev);
-extern void deinit_hal_dm(struct net_device *dev);
-
-extern void hal_dm_watchdog(struct net_device *dev);
-
-extern void init_rate_adaptive(struct net_device *dev);
-extern void dm_txpower_trackingcallback(struct work_struct *work);
-extern void dm_restore_dynamic_mechanism_state(struct net_device *dev);
-extern void dm_backup_dynamic_mechanism_state(struct net_device *dev);
-extern void dm_change_dynamic_initgain_thresh(struct net_device *dev,
- u32 dm_type, u32 dm_value);
-extern void dm_force_tx_fw_info(struct net_device *dev,u32 force_type, u32 force_value);
-extern void dm_init_edca_turbo(struct net_device *dev);
-extern void dm_rf_operation_test_callback(unsigned long data);
-extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
-extern void dm_fsync_timer_callback(unsigned long data);
-extern void dm_cck_txpower_adjust(struct net_device *dev,bool binch14);
-extern void dm_shadow_init(struct net_device *dev);
-extern void dm_initialize_txpower_tracking(struct net_device *dev);
-/*--------------------------Exported Function prototype---------------------*/
-
-
-#endif /*__R8192UDM_H__ */
-
-
-/* End of r8192U_dm.h */
-
diff --git a/drivers/staging/rtl8192su/r8192U_pm.c b/drivers/staging/rtl8192su/r8192U_pm.c
deleted file mode 100644
index 60d739b85eb7..000000000000
--- a/drivers/staging/rtl8192su/r8192U_pm.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Power management interface routines.
- Written by Mariusz Matuszek.
- This code is currently just a placeholder for later work and
- does not do anything useful.
-
- This is part of rtl8180 OpenSource driver.
- Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
- Released under the terms of GPL (General Public Licence)
-*/
-
-#include "r8192U.h"
-#include "r8192U_pm.h"
-
-/*****************************************************************************/
-int rtl8192U_save_state (struct pci_dev *dev, u32 state)
-{
- printk(KERN_NOTICE "r8192U save state call (state %u).\n", state);
- return(-EAGAIN);
-}
-
-int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state)
-{
- struct net_device *dev = usb_get_intfdata(intf);
-
- RT_TRACE(COMP_POWER, "============> r8192U suspend call.\n");
-
- if(dev) {
- if (!netif_running(dev)) {
- printk(KERN_WARNING "netif not running, go out suspend function\n");
- return 0;
- }
-
- if (dev->netdev_ops->ndo_stop)
- dev->netdev_ops->ndo_stop(dev);
-
- mdelay(10);
-
- netif_device_detach(dev);
- }
-
- return 0;
-}
-
-int rtl8192U_resume (struct usb_interface *intf)
-{
- struct net_device *dev = usb_get_intfdata(intf);
-
- RT_TRACE(COMP_POWER, "================>r8192U resume call.");
-
- if(dev) {
- if (!netif_running(dev)){
- printk(KERN_WARNING "netif not running, go out resume function\n");
- return 0;
- }
-
- netif_device_attach(dev);
-
- if (dev->netdev_ops->ndo_open)
- dev->netdev_ops->ndo_open(dev);
- }
-
- return 0;
-}
-
-int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable)
-{
- printk(KERN_NOTICE "r8192U enable wake call (state %u, enable %d).\n",
- state, enable);
- return(-EAGAIN);
-}
-
diff --git a/drivers/staging/rtl8192su/r8192U_pm.h b/drivers/staging/rtl8192su/r8192U_pm.h
deleted file mode 100644
index d89e423ea5cd..000000000000
--- a/drivers/staging/rtl8192su/r8192U_pm.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- Power management interface routines.
- Written by Mariusz Matuszek.
- This code is currently just a placeholder for later work and
- does not do anything useful.
-
- This is part of rtl8180 OpenSource driver.
- Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
- Released under the terms of GPL (General Public Licence)
-
-*/
-
-
-#ifndef R8192_PM_H
-#define R8192_PM_H
-
-#include <linux/types.h>
-#include <linux/usb.h>
-
-int rtl8192U_save_tate (struct pci_dev *dev, u32 state);
-int rtl8192U_suspend(struct usb_interface *intf, pm_message_t state);
-int rtl8192U_resume (struct usb_interface *intf);
-int rtl8192U_enable_wake (struct pci_dev *dev, u32 state, int enable);
-
-#endif //R8192U_PM_H
diff --git a/drivers/staging/rtl8192su/r8192U_wx.c b/drivers/staging/rtl8192su/r8192U_wx.c
deleted file mode 100644
index 2005b811ebab..000000000000
--- a/drivers/staging/rtl8192su/r8192U_wx.c
+++ /dev/null
@@ -1,1296 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- * Linux device driver for RTL8192U
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-
-
-#include <linux/string.h>
-#include "r8192U.h"
-#include "r8192S_hw.h"
-
-#include "ieee80211/dot11d.h"
-
-#define RATE_COUNT 12
-u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
- 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000};
-
-
-#ifndef ENETDOWN
-#define ENETDOWN 1
-#endif
-
-static int r8192_wx_get_freq(struct net_device *dev,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
-}
-
-static int r8192_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct r8192_priv *priv=ieee80211_priv(dev);
-
- return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
-}
-
-
-
-static int r8192_wx_get_rate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
-}
-
-
-
-static int r8192_wx_set_rate(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-
-static int r8192_wx_set_rts(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_rts(priv->ieee80211,info,wrqu,extra);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-static int r8192_wx_get_rts(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- return ieee80211_wx_get_rts(priv->ieee80211,info,wrqu,extra);
-}
-
-static int r8192_wx_set_power(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_power(priv->ieee80211,info,wrqu,extra);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-static int r8192_wx_get_power(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- return ieee80211_wx_get_power(priv->ieee80211,info,wrqu,extra);
-}
-
-#ifdef JOHN_IOCTL
-u16 read_rtl8225(struct net_device *dev, u8 addr);
-void write_rtl8225(struct net_device *dev, u8 adr, u16 data);
-u32 john_read_rtl8225(struct net_device *dev, u8 adr);
-void _write_rtl8225(struct net_device *dev, u8 adr, u16 data);
-
-static int r8192_wx_read_regs(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 addr;
- u16 data1;
-
- down(&priv->wx_sem);
-
-
- get_user(addr,(u8*)wrqu->data.pointer);
- data1 = read_rtl8225(dev, addr);
- wrqu->data.length = data1;
-
- up(&priv->wx_sem);
- return 0;
-
-}
-
-static int r8192_wx_write_regs(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 addr;
-
- down(&priv->wx_sem);
-
- get_user(addr, (u8*)wrqu->data.pointer);
- write_rtl8225(dev, addr, wrqu->data.length);
-
- up(&priv->wx_sem);
- return 0;
-
-}
-
-void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data);
-u8 rtl8187_read_phy(struct net_device *dev,u8 adr, u32 data);
-
-static int r8192_wx_read_bb(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 databb;
-
- down(&priv->wx_sem);
-
- databb = rtl8187_read_phy(dev, (u8)wrqu->data.length, 0x00000000);
- wrqu->data.length = databb;
-
- up(&priv->wx_sem);
- return 0;
-}
-
-void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data);
-static int r8192_wx_write_bb(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u8 databb;
-
- down(&priv->wx_sem);
-
- get_user(databb, (u8*)wrqu->data.pointer);
- rtl8187_write_phy(dev, wrqu->data.length, databb);
-
- up(&priv->wx_sem);
- return 0;
-
-}
-
-
-static int r8192_wx_write_nicb(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 addr;
-
- down(&priv->wx_sem);
-
- get_user(addr, (u32*)wrqu->data.pointer);
- write_nic_byte(dev, addr, wrqu->data.length);
-
- up(&priv->wx_sem);
- return 0;
-
-}
-static int r8192_wx_read_nicb(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u32 addr;
- u16 data1;
-
- down(&priv->wx_sem);
-
- get_user(addr,(u32*)wrqu->data.pointer);
- data1 = read_nic_byte(dev, addr);
- wrqu->data.length = data1;
-
- up(&priv->wx_sem);
- return 0;
-}
-
-static int r8192_wx_get_ap_status(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
- struct ieee80211_network *target;
- struct ieee80211_network *latest = NULL;
- int name_len;
-
- down(&priv->wx_sem);
-
- //count the length of input ssid
- for(name_len=0 ; ((char*)wrqu->data.pointer)[name_len]!='\0' ; name_len++);
-
- //search for the correspoding info which is received
- list_for_each_entry(target, &ieee->network_list, list) {
- if ( (target->ssid_len == name_len) &&
- (strncmp(target->ssid, (char*)wrqu->data.pointer, name_len)==0)){
- if ((latest == NULL) ||(target->last_scanned > latest->last_scanned))
- latest = target;
-
- }
- }
-
- if(latest != NULL)
- {
- wrqu->data.length = latest->SignalStrength;
-
- if(latest->wpa_ie_len>0 || latest->rsn_ie_len>0 ) {
- wrqu->data.flags = 1;
- } else {
- wrqu->data.flags = 0;
- }
- }
-
- up(&priv->wx_sem);
- return 0;
-}
-
-
-
-#endif
-static int r8192_wx_force_reset(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- printk("%s(): force reset ! extra is %d\n",__FUNCTION__, *extra);
- priv->force_reset = *extra;
- up(&priv->wx_sem);
- return 0;
-
-}
-
-static int r8191su_wx_get_firm_version(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 firmware_version;
-
- down(&priv->wx_sem);
- firmware_version = priv->pFirmware->FirmwareVersion;
- wrqu->value = firmware_version;
- wrqu->fixed = 1;
-
- up(&priv->wx_sem);
- return 0;
-}
-
-
-
-static int r8192_wx_set_rawtx(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int ret;
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
-
- up(&priv->wx_sem);
-
- return ret;
-
-}
-
-static int r8192_wx_set_crcmon(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int *parms = (int *)extra;
- int enable = (parms[0] > 0);
- short prev = priv->crcmon;
-
- down(&priv->wx_sem);
-
- if(enable)
- priv->crcmon=1;
- else
- priv->crcmon=0;
-
- DMESG("bad CRC in monitor mode are %s",
- priv->crcmon ? "accepted" : "rejected");
-
- if(prev != priv->crcmon && priv->up){
- //rtl8180_down(dev);
- //rtl8180_up(dev);
- }
-
- up(&priv->wx_sem);
-
- return 0;
-}
-
-static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int ret;
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
-
- rtl8192_set_rxconf(dev);
-
- up(&priv->wx_sem);
- return ret;
-}
-
-struct iw_range_with_scan_capa
-{
- /* Informative stuff (to choose between different interface) */
- __u32 throughput; /* To give an idea... */
- /* In theory this value should be the maximum benchmarked
- * TCP/IP throughput, because with most of these devices the
- * bit rate is meaningless (overhead an co) to estimate how
- * fast the connection will go and pick the fastest one.
- * I suggest people to play with Netperf or any benchmark...
- */
-
- /* NWID (or domain id) */
- __u32 min_nwid; /* Minimal NWID we are able to set */
- __u32 max_nwid; /* Maximal NWID we are able to set */
-
- /* Old Frequency (backward compat - moved lower ) */
- __u16 old_num_channels;
- __u8 old_num_frequency;
-
- /* Scan capabilities */
- __u8 scan_capa;
-};
-static int rtl8180_wx_get_range(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct iw_range *range = (struct iw_range *)extra;
- struct iw_range_with_scan_capa* tmp = (struct iw_range_with_scan_capa*)range;
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 val;
- int i;
-
- wrqu->data.length = sizeof(*range);
- memset(range, 0, sizeof(*range));
-
- /* Let's try to keep this struct in the same order as in
- * linux/include/wireless.h
- */
-
- /* TODO: See what values we can set, and remove the ones we can't
- * set, or fill them with some default data.
- */
-
- /* ~5 Mb/s real (802.11b) */
- range->throughput = 5 * 1000 * 1000;
-
- // TODO: Not used in 802.11b?
-// range->min_nwid; /* Minimal NWID we are able to set */
- // TODO: Not used in 802.11b?
-// range->max_nwid; /* Maximal NWID we are able to set */
-
- /* Old Frequency (backward compat - moved lower ) */
-// range->old_num_channels;
-// range->old_num_frequency;
-// range->old_freq[6]; /* Filler to keep "version" at the same offset */
- if(priv->rf_set_sens != NULL)
- range->sensitivity = priv->max_sens; /* signal level threshold range */
-
- range->max_qual.qual = 100;
- /* TODO: Find real max RSSI and stick here */
- range->max_qual.level = 0;
- range->max_qual.noise = -98;
- range->max_qual.updated = 7; /* Updated all three */
-
- range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
- /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
- range->avg_qual.level = 20 + -98;
- range->avg_qual.noise = 0;
- range->avg_qual.updated = 7; /* Updated all three */
-
- range->num_bitrates = RATE_COUNT;
-
- for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
- range->bitrate[i] = rtl8180_rates[i];
- }
-
- range->min_frag = MIN_FRAG_THRESHOLD;
- range->max_frag = MAX_FRAG_THRESHOLD;
-
- range->min_pmp=0;
- range->max_pmp = 5000000;
- range->min_pmt = 0;
- range->max_pmt = 65535*1000;
- range->pmp_flags = IW_POWER_PERIOD;
- range->pmt_flags = IW_POWER_TIMEOUT;
- range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
-
- range->we_version_compiled = WIRELESS_EXT;
- range->we_version_source = 16;
-
-
- for (i = 0, val = 0; i < 14; i++) {
-
- // Include only legal frequencies for some countries
- if ((GET_DOT11D_INFO(priv->ieee80211)->channel_map)[i+1]) {
- range->freq[val].i = i + 1;
- range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
- range->freq[val].e = 1;
- val++;
- } else {
- // FIXME: do we need to set anything for channels
- // we don't use ?
- }
-
- if (val == IW_MAX_FREQUENCIES)
- break;
- }
- range->num_frequency = val;
- range->num_channels = val;
- range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
- IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
- tmp->scan_capa = 0x01;
- return 0;
-}
-
-
-static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- int ret = 0;
-
- if(!priv->up) return -ENETDOWN;
-
- if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true)
- return -EAGAIN;
-
- if (wrqu->data.flags & IW_SCAN_THIS_ESSID)
- {
- struct iw_scan_req* req = (struct iw_scan_req*)b;
- if (req->essid_len)
- {
- //printk("==**&*&*&**===>scan set ssid:%s\n", req->essid);
- ieee->current_network.ssid_len = req->essid_len;
- memcpy(ieee->current_network.ssid, req->essid, req->essid_len);
- //printk("=====>network ssid:%s\n", ieee->current_network.ssid);
- }
- }
-
- down(&priv->wx_sem);
- if(priv->ieee80211->state != IEEE80211_LINKED){
- priv->ieee80211->scanning = 0;
- ieee80211_softmac_scan_syncro(priv->ieee80211);
- ret = 0;
- }
- else
- ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
- up(&priv->wx_sem);
- return ret;
-}
-
-
-static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
-
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if(!priv->up) return -ENETDOWN;
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-static int r8192_wx_set_essid(struct net_device *dev,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int ret;
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-
-
-
-static int r8192_wx_get_essid(struct net_device *dev,
- struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
-
- up(&priv->wx_sem);
-
- return ret;
-}
-
-
-static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu, char *b)
-{
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
-
- up(&priv->wx_sem);
- return ret;
-}
-
-static int r8192_wx_get_name(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
-}
-
-
-static int r8192_wx_set_frag(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- if (wrqu->frag.disabled)
- priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
- else {
- if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
- wrqu->frag.value > MAX_FRAG_THRESHOLD)
- return -EINVAL;
-
- priv->ieee80211->fts = wrqu->frag.value & ~0x1;
- }
-
- return 0;
-}
-
-
-static int r8192_wx_get_frag(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- wrqu->frag.value = priv->ieee80211->fts;
- wrqu->frag.fixed = 0; /* no auto select */
- wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD);
-
- return 0;
-}
-
-
-static int r8192_wx_set_wap(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *awrq,
- char *extra)
-{
-
- int ret;
- struct r8192_priv *priv = ieee80211_priv(dev);
-// struct sockaddr *temp = (struct sockaddr *)awrq;
- down(&priv->wx_sem);
-
- ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
-
- up(&priv->wx_sem);
-
- return ret;
-
-}
-
-
-static int r8192_wx_get_wap(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
-}
-
-
-static int r8192_wx_get_enc(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *key)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
-}
-
-static int r8192_wx_set_enc(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *key)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
- int ret;
-
- //u32 TargetContent;
- u32 hwkey[4]={0,0,0,0};
- u8 mask=0xff;
- u32 key_idx=0;
- //u8 broadcast_addr[6] ={ 0xff,0xff,0xff,0xff,0xff,0xff};
- u8 zero_addr[4][6] ={ {0x00,0x00,0x00,0x00,0x00,0x00},
- {0x00,0x00,0x00,0x00,0x00,0x01},
- {0x00,0x00,0x00,0x00,0x00,0x02},
- {0x00,0x00,0x00,0x00,0x00,0x03} };
- int i;
-
- if(!priv->up) return -ENETDOWN;
-
- down(&priv->wx_sem);
-
- RT_TRACE(COMP_SEC, "Setting SW wep key");
- ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
-
- up(&priv->wx_sem);
-
-
-
- //sometimes, the length is zero while we do not type key value
- if(wrqu->encoding.length!=0){
-
- for(i=0 ; i<4 ; i++){
- hwkey[i] |= key[4*i+0]&mask;
- if(i==1&&(4*i+1)==wrqu->encoding.length) mask=0x00;
- if(i==3&&(4*i+1)==wrqu->encoding.length) mask=0x00;
- hwkey[i] |= (key[4*i+1]&mask)<<8;
- hwkey[i] |= (key[4*i+2]&mask)<<16;
- hwkey[i] |= (key[4*i+3]&mask)<<24;
- }
-
- #define CONF_WEP40 0x4
- #define CONF_WEP104 0x14
-
- switch(wrqu->encoding.flags & IW_ENCODE_INDEX){
- case 0: key_idx = ieee->tx_keyidx; break;
- case 1: key_idx = 0; break;
- case 2: key_idx = 1; break;
- case 3: key_idx = 2; break;
- case 4: key_idx = 3; break;
- default: break;
- }
-
- if(wrqu->encoding.length==0x5){
- ieee->pairwise_key_type = KEY_TYPE_WEP40;
- EnableHWSecurityConfig8192(dev);
-
- setKey( dev,
- key_idx, //EntryNo
- key_idx, //KeyIndex
- KEY_TYPE_WEP40, //KeyType
- zero_addr[key_idx],
- 0, //DefaultKey
- hwkey); //KeyContent
-
- }
-
- else if(wrqu->encoding.length==0xd){
- ieee->pairwise_key_type = KEY_TYPE_WEP104;
- EnableHWSecurityConfig8192(dev);
-
- setKey( dev,
- key_idx, //EntryNo
- key_idx, //KeyIndex
- KEY_TYPE_WEP104, //KeyType
- zero_addr[key_idx],
- 0, //DefaultKey
- hwkey); //KeyContent
-
- }
- else printk("wrong type in WEP, not WEP40 and WEP104\n");
-
- }
-
- return ret;
-}
-
-
-static int r8192_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
- iwreq_data *wrqu, char *p){
-
- struct r8192_priv *priv = ieee80211_priv(dev);
- int *parms=(int*)p;
- int mode=parms[0];
-
- priv->ieee80211->active_scan = mode;
-
- return 1;
-}
-
-
-
-static int r8192_wx_set_retry(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int err = 0;
-
- down(&priv->wx_sem);
-
- if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
- wrqu->retry.disabled){
- err = -EINVAL;
- goto exit;
- }
- if (!(wrqu->retry.flags & IW_RETRY_LIMIT)){
- err = -EINVAL;
- goto exit;
- }
-
- if(wrqu->retry.value > R8180_MAX_RETRY){
- err= -EINVAL;
- goto exit;
- }
- if (wrqu->retry.flags & IW_RETRY_MAX) {
- priv->retry_rts = wrqu->retry.value;
- DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
-
- }else {
- priv->retry_data = wrqu->retry.value;
- DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
- }
-
- /* FIXME !
- * We might try to write directly the TX config register
- * or to restart just the (R)TX process.
- * I'm unsure if whole reset is really needed
- */
-
- rtl8192_commit(dev);
- /*
- if(priv->up){
- rtl8180_rtx_disable(dev);
- rtl8180_rx_enable(dev);
- rtl8180_tx_enable(dev);
-
- }
- */
-exit:
- up(&priv->wx_sem);
-
- return err;
-}
-
-static int r8192_wx_get_retry(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-
- wrqu->retry.disabled = 0; /* can't be disabled */
-
- if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
- IW_RETRY_LIFETIME)
- return -EINVAL;
-
- if (wrqu->retry.flags & IW_RETRY_MAX) {
- wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
- wrqu->retry.value = priv->retry_rts;
- } else {
- wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
- wrqu->retry.value = priv->retry_data;
- }
- //printk("returning %d",wrqu->retry.value);
-
-
- return 0;
-}
-
-static int r8192_wx_get_sens(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- if(priv->rf_set_sens == NULL)
- return -1; /* we have not this support for this radio */
- wrqu->sens.value = priv->sens;
- return 0;
-}
-
-
-static int r8192_wx_set_sens(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
-
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- short err = 0;
- down(&priv->wx_sem);
- //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value);
- if(priv->rf_set_sens == NULL) {
- err= -1; /* we have not this support for this radio */
- goto exit;
- }
- if(priv->rf_set_sens(dev, wrqu->sens.value) == 0)
- priv->sens = wrqu->sens.value;
- else
- err= -EINVAL;
-
-exit:
- up(&priv->wx_sem);
-
- return err;
-}
-
-//hw security need to reorganized.
-static int r8192_wx_set_enc_ext(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret=0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- //printk("===>%s()\n", __FUNCTION__);
-
-
- down(&priv->wx_sem);
- ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra);
-
- {
- u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
- u8 zero[6] = {0};
- u32 key[4] = {0};
- struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
- struct iw_point *encoding = &wrqu->encoding;
- u8 idx = 0, alg = 0, group = 0;
- if ((encoding->flags & IW_ENCODE_DISABLED) ||
- ext->alg == IW_ENCODE_ALG_NONE) //none is not allowed to use hwsec WB 2008.07.01
- {
- ieee->pairwise_key_type = ieee->group_key_type = KEY_TYPE_NA;
- CamResetAllEntry(dev);
- goto end_hw_sec;
- }
- alg = (ext->alg == IW_ENCODE_ALG_CCMP)?KEY_TYPE_CCMP:ext->alg; // as IW_ENCODE_ALG_CCMP is defined to be 3 and KEY_TYPE_CCMP is defined to 4;
- idx = encoding->flags & IW_ENCODE_INDEX;
- if (idx)
- idx --;
- group = ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY;
-
- if ((!group) || (IW_MODE_ADHOC == ieee->iw_mode) || (alg == KEY_TYPE_WEP40))
- {
- if ((ext->key_len == 13) && (alg == KEY_TYPE_WEP40) )
- alg = KEY_TYPE_WEP104;
- ieee->pairwise_key_type = alg;
- EnableHWSecurityConfig8192(dev);
- }
- memcpy((u8*)key, ext->key, 16); //we only get 16 bytes key.why? WB 2008.7.1
-
- if ((alg & KEY_TYPE_WEP40) && (ieee->auth_mode !=2) )
- {
-
- setKey( dev,
- idx,//EntryNo
- idx, //KeyIndex
- alg, //KeyType
- zero, //MacAddr
- 0, //DefaultKey
- key); //KeyContent
- }
- else if (group)
- {
- ieee->group_key_type = alg;
- setKey( dev,
- idx,//EntryNo
- idx, //KeyIndex
- alg, //KeyType
- broadcast_addr, //MacAddr
- 0, //DefaultKey
- key); //KeyContent
- }
- else //pairwise key
- {
- setKey( dev,
- 4,//EntryNo
- idx, //KeyIndex
- alg, //KeyType
- (u8*)ieee->ap_mac_addr, //MacAddr
- 0, //DefaultKey
- key); //KeyContent
- }
-
-
- }
-
-end_hw_sec:
-
- up(&priv->wx_sem);
- return ret;
-}
-static int r8192_wx_set_auth(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *data, char *extra)
-{
- int ret=0;
-
- //printk("====>%s()\n", __FUNCTION__);
- struct r8192_priv *priv = ieee80211_priv(dev);
- down(&priv->wx_sem);
- ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra);
- up(&priv->wx_sem);
- return ret;
-}
-
-static int r8192_wx_set_mlme(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- //printk("====>%s()\n", __FUNCTION__);
-
- int ret=0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- down(&priv->wx_sem);
- ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra);
- up(&priv->wx_sem);
- return ret;
-}
-
-static int r8192_wx_set_pmkid(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int i;
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- struct iw_pmksa* pPMK = (struct iw_pmksa*)extra;
- int intReturn = false;
-
- switch (pPMK->cmd)
- {
- case IW_PMKSA_ADD:
- for (i = 0; i < NUM_PMKID_CACHE; i++)
- {
- if (memcmp(ieee->PMKIDList[i].Bssid, pPMK->bssid.sa_data, ETH_ALEN) == 0)
- {
- memcpy(ieee->PMKIDList[i].PMKID, pPMK->pmkid, IW_PMKID_LEN);
- memcpy(ieee->PMKIDList[i].Bssid, pPMK->bssid.sa_data, ETH_ALEN);
- ieee->PMKIDList[i].bUsed = true;
- intReturn = true;
- goto __EXIT__;
- }
- }
-
- for (i = 0; i < NUM_PMKID_CACHE; i++)
- {
- if (ieee->PMKIDList[i].bUsed == false)
- {
- memcpy(ieee->PMKIDList[i].PMKID, pPMK->pmkid, IW_PMKID_LEN);
- memcpy(ieee->PMKIDList[i].Bssid, pPMK->bssid.sa_data, ETH_ALEN);
- ieee->PMKIDList[i].bUsed = true;
- intReturn = true;
- goto __EXIT__;
- }
- }
- break;
-
- case IW_PMKSA_REMOVE:
- for (i = 0; i < NUM_PMKID_CACHE; i++)
- {
- if (memcmp(ieee->PMKIDList[i].Bssid, pPMK->bssid.sa_data, ETH_ALEN) == true)
- {
- memset(&ieee->PMKIDList[i], 0x00, sizeof(RT_PMKID_LIST));
- intReturn = true;
- break;
- }
- }
- break;
-
- case IW_PMKSA_FLUSH:
- memset(&ieee->PMKIDList[0], 0x00, (sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE));
- intReturn = true;
- break;
-
- default:
- break;
- }
-
-__EXIT__:
- return (intReturn);
-
-}
-
-static int r8192_wx_set_gen_ie(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *data, char *extra)
-{
- //printk("====>%s(), len:%d\n", __FUNCTION__, data->length);
- int ret=0;
- struct r8192_priv *priv = ieee80211_priv(dev);
- down(&priv->wx_sem);
-#if 1
- ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length);
-#endif
- up(&priv->wx_sem);
- //printk("<======%s(), ret:%d\n", __FUNCTION__, ret);
- return ret;
-
-
-}
-
-static int dummy(struct net_device *dev, struct iw_request_info *a,
- union iwreq_data *wrqu,char *b)
-{
- return -1;
-}
-
-
-static iw_handler r8192_wx_handlers[] =
-{
- NULL, /* SIOCSIWCOMMIT */
- r8192_wx_get_name, /* SIOCGIWNAME */
- dummy, /* SIOCSIWNWID */
- dummy, /* SIOCGIWNWID */
- r8192_wx_set_freq, /* SIOCSIWFREQ */
- r8192_wx_get_freq, /* SIOCGIWFREQ */
- r8192_wx_set_mode, /* SIOCSIWMODE */
- r8192_wx_get_mode, /* SIOCGIWMODE */
- r8192_wx_set_sens, /* SIOCSIWSENS */
- r8192_wx_get_sens, /* SIOCGIWSENS */
- NULL, /* SIOCSIWRANGE */
- rtl8180_wx_get_range, /* SIOCGIWRANGE */
- NULL, /* SIOCSIWPRIV */
- NULL, /* SIOCGIWPRIV */
- NULL, /* SIOCSIWSTATS */
- NULL, /* SIOCGIWSTATS */
- dummy, /* SIOCSIWSPY */
- dummy, /* SIOCGIWSPY */
- NULL, /* SIOCGIWTHRSPY */
- NULL, /* SIOCWIWTHRSPY */
- r8192_wx_set_wap, /* SIOCSIWAP */
- r8192_wx_get_wap, /* SIOCGIWAP */
- r8192_wx_set_mlme, /* MLME-- */
- dummy, /* SIOCGIWAPLIST -- depricated */
- r8192_wx_set_scan, /* SIOCSIWSCAN */
- r8192_wx_get_scan, /* SIOCGIWSCAN */
- r8192_wx_set_essid, /* SIOCSIWESSID */
- r8192_wx_get_essid, /* SIOCGIWESSID */
- dummy, /* SIOCSIWNICKN */
- dummy, /* SIOCGIWNICKN */
- NULL, /* -- hole -- */
- NULL, /* -- hole -- */
- r8192_wx_set_rate, /* SIOCSIWRATE */
- r8192_wx_get_rate, /* SIOCGIWRATE */
- r8192_wx_set_rts, /* SIOCSIWRTS */
- r8192_wx_get_rts, /* SIOCGIWRTS */
- r8192_wx_set_frag, /* SIOCSIWFRAG */
- r8192_wx_get_frag, /* SIOCGIWFRAG */
- dummy, /* SIOCSIWTXPOW */
- dummy, /* SIOCGIWTXPOW */
- r8192_wx_set_retry, /* SIOCSIWRETRY */
- r8192_wx_get_retry, /* SIOCGIWRETRY */
- r8192_wx_set_enc, /* SIOCSIWENCODE */
- r8192_wx_get_enc, /* SIOCGIWENCODE */
- r8192_wx_set_power, /* SIOCSIWPOWER */
- r8192_wx_get_power, /* SIOCGIWPOWER */
- NULL, /*---hole---*/
- NULL, /*---hole---*/
- r8192_wx_set_gen_ie,//NULL, /* SIOCSIWGENIE */
- NULL, /* SIOCSIWGENIE */
-
- r8192_wx_set_auth,//NULL, /* SIOCSIWAUTH */
- NULL,//r8192_wx_get_auth,//NULL, /* SIOCSIWAUTH */
- r8192_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
- NULL,//r8192_wx_get_enc_ext,//NULL, /* SIOCSIWENCODEEXT */
- r8192_wx_set_pmkid, /* SIOCSIWPMKSA */
- NULL, /*---hole---*/
-
-};
-
-
-static const struct iw_priv_args r8192_private_args[] = {
-
- {
- SIOCIWFIRSTPRIV + 0x0,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
- },
-
- {
- SIOCIWFIRSTPRIV + 0x1,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
-
- },
- {
- SIOCIWFIRSTPRIV + 0x2,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
- }
-#ifdef JOHN_IOCTL
- ,
- {
- SIOCIWFIRSTPRIV + 0x3,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readRF"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x4,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writeRF"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x5,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readBB"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x6,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writeBB"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x7,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "readnicb"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x8,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "writenicb"
- }
- ,
- {
- SIOCIWFIRSTPRIV + 0x9,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo"
- }
-
-#endif
- ,
- {
- SIOCIWFIRSTPRIV + 0x3,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
- }
-
- ,
- {
- SIOCIWFIRSTPRIV + 0x5,
- IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
- "firm_ver"
- }
-};
-
-
-static iw_handler r8192_private_handler[] = {
-// r8192_wx_set_monitor, /* SIOCIWFIRSTPRIV */
- r8192_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
-// r8192_wx_set_forceassociate,
-// r8192_wx_set_beaconinterval,
-// r8192_wx_set_monitor_type,
- r8192_wx_set_scan_type,
- r8192_wx_set_rawtx,
-#ifdef JOHN_IOCTL
- r8192_wx_read_regs,
- r8192_wx_write_regs,
- r8192_wx_read_bb,
- r8192_wx_write_bb,
- r8192_wx_read_nicb,
- r8192_wx_write_nicb,
- r8192_wx_get_ap_status,
-#endif
- r8192_wx_force_reset,
- (iw_handler)NULL,
- (iw_handler)r8191su_wx_get_firm_version,
-};
-
-struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device* ieee = priv->ieee80211;
- struct iw_statistics* wstats = &priv->wstats;
- int tmp_level = 0;
- int tmp_qual = 0;
- int tmp_noise = 0;
- if(ieee->state < IEEE80211_LINKED)
- {
- wstats->qual.qual = 0;
- wstats->qual.level = 0;
- wstats->qual.noise = 0;
- wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
- return wstats;
- }
-
- tmp_level = (&ieee->current_network)->stats.rssi;
- tmp_qual = (&ieee->current_network)->stats.signal;
- tmp_noise = (&ieee->current_network)->stats.noise;
- //printk("level:%d, qual:%d, noise:%d\n", tmp_level, tmp_qual, tmp_noise);
-
- wstats->qual.level = tmp_level;
- wstats->qual.qual = tmp_qual;
- wstats->qual.noise = tmp_noise;
- wstats->qual.updated = IW_QUAL_ALL_UPDATED| IW_QUAL_DBM;
- return wstats;
-}
-
-struct iw_handler_def r8192_wx_handlers_def={
- .standard = r8192_wx_handlers,
- .num_standard = ARRAY_SIZE(r8192_wx_handlers),
- .private = r8192_private_handler,
- .num_private = ARRAY_SIZE(r8192_private_handler),
- .num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args),
- .get_wireless_stats = r8192_get_wireless_stats,
- .private_args = (struct iw_priv_args *)r8192_private_args,
-};
diff --git a/drivers/staging/rtl8192su/r8192U_wx.h b/drivers/staging/rtl8192su/r8192U_wx.h
deleted file mode 100644
index 61a2c2652536..000000000000
--- a/drivers/staging/rtl8192su/r8192U_wx.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- This is part of rtl8180 OpenSource driver - v 0.3
- Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
- Released under the terms of GPL (General Public Licence)
-
- Parts of this driver are based on the GPL part of the official realtek driver
- Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
- Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
-
- We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
-*/
-
-/* this file (will) contains wireless extension handlers*/
-
-#ifndef R8180_WX_H
-#define R8180_WX_H
-//#include <linux/wireless.h>
-extern struct iw_handler_def r8192_wx_handlers_def;
-/* Enable the rtl819x_core.c to share this function, david 2008.9.22 */
-extern struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev);
-
-#endif
diff --git a/drivers/staging/rtl8192su/r819xU_HTGen.h b/drivers/staging/rtl8192su/r819xU_HTGen.h
deleted file mode 100644
index 7a60480c4b8e..000000000000
--- a/drivers/staging/rtl8192su/r819xU_HTGen.h
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// IOT Action for different AP
-//
-typedef enum _HT_IOT_ACTION{
- HT_IOT_ACT_TX_USE_AMSDU_4K = 0x00000001,
- HT_IOT_ACT_TX_USE_AMSDU_8K = 0x00000002,
- HT_IOT_ACT_DECLARE_MCS13 = 0x00000004,
- HT_IOT_ACT_DISABLE_EDCA_TURBO = 0x00000008,
- HT_IOT_ACT_MGNT_USE_CCK_6M = 0x00000010,
- HT_IOT_ACT_CDD_FSYNC = 0x00000020,
- HT_IOT_ACT_PURE_N_MODE = 0x00000040,
-
- //LZM ADD 090224
- HT_IOT_ACT_EDCA_BIAS_ON_RX = 0x00004000,
- HT_IOT_ACT_HYBRID_AGGREGATION = 0x00010000,
- HT_IOT_ACT_AMSDU_ENABLE = 0x00000800,
- HT_IOT_ACT_DISABLE_SHORT_GI = 0x00020000,
- HT_IOT_ACT_DISABLE_HIGH_POWER = 0x00040000,
- HT_IOT_ACT_DISABLE_TX_2SS = 0x00200000,
- HT_IOT_ACT_DISABLE_TX_40_MHZ = 0x00080000,
-}HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
-
diff --git a/drivers/staging/rtl8192su/r819xU_HTType.h b/drivers/staging/rtl8192su/r819xU_HTType.h
deleted file mode 100644
index 3f379e0d9d31..000000000000
--- a/drivers/staging/rtl8192su/r819xU_HTType.h
+++ /dev/null
@@ -1,383 +0,0 @@
-#ifndef _R819XU_HTTYPE_H_
-#define _R819XU_HTTYPE_H_
-
-
-//------------------------------------------------------------
-// The HT Capability element is present in beacons, association request,
-// reassociation request and probe response frames
-//------------------------------------------------------------
-
-//
-// Operation mode value
-//
-#define HT_OPMODE_NO_PROTECT 0
-#define HT_OPMODE_OPTIONAL 1
-#define HT_OPMODE_40MHZ_PROTECT 2
-#define HT_OPMODE_MIXED 3
-
-//
-// MIMO Power Save Setings
-//
-#define MIMO_PS_STATIC 0
-#define MIMO_PS_DYNAMIC 1
-#define MIMO_PS_NOLIMIT 3
-
-
-//
-// There should be 128 bits to cover all of the MCS rates. However, since
-// 8190 does not support too much rates, one integer is quite enough.
-//
-
-#define sHTCLng 4
-
-
-#define HT_SUPPORTED_MCS_1SS_BITMAP 0x000000ff
-#define HT_SUPPORTED_MCS_2SS_BITMAP 0x0000ff00
-#define HT_SUPPORTED_MCS_1SS_2SS_BITMAP HT_MCS_1SS_BITMAP|HT_MCS_1SS_2SS_BITMAP
-
-
-typedef enum _HT_MCS_RATE{
- HT_MCS0 = 0x00000001,
- HT_MCS1 = 0x00000002,
- HT_MCS2 = 0x00000004,
- HT_MCS3 = 0x00000008,
- HT_MCS4 = 0x00000010,
- HT_MCS5 = 0x00000020,
- HT_MCS6 = 0x00000040,
- HT_MCS7 = 0x00000080,
- HT_MCS8 = 0x00000100,
- HT_MCS9 = 0x00000200,
- HT_MCS10 = 0x00000400,
- HT_MCS11 = 0x00000800,
- HT_MCS12 = 0x00001000,
- HT_MCS13 = 0x00002000,
- HT_MCS14 = 0x00004000,
- HT_MCS15 = 0x00008000,
- // Do not define MCS32 here although 8190 support MCS32
-}HT_MCS_RATE,*PHT_MCS_RATE;
-
-//
-// Represent Channel Width in HT Capabilities
-//
-typedef enum _HT_CHANNEL_WIDTH{
- HT_CHANNEL_WIDTH_20 = 0,
- HT_CHANNEL_WIDTH_20_40 = 1,
-}HT_CHANNEL_WIDTH, *PHT_CHANNEL_WIDTH;
-
-//
-// Represent Extention Channel Offset in HT Capabilities
-// This is available only in 40Mhz mode.
-//
-typedef enum _HT_EXTCHNL_OFFSET{
- HT_EXTCHNL_OFFSET_NO_EXT = 0,
- HT_EXTCHNL_OFFSET_UPPER = 1,
- HT_EXTCHNL_OFFSET_NO_DEF = 2,
- HT_EXTCHNL_OFFSET_LOWER = 3,
-}HT_EXTCHNL_OFFSET, *PHT_EXTCHNL_OFFSET;
-
-typedef enum _CHNLOP{
- CHNLOP_NONE = 0, // No Action now
- CHNLOP_SCAN = 1, // Scan in progress
- CHNLOP_SWBW = 2, // Bandwidth switching in progress
- CHNLOP_SWCHNL = 3, // Software Channel switching in progress
-} CHNLOP, *PCHNLOP;
-
-// Determine if the Channel Operation is in progress
-#define CHHLOP_IN_PROGRESS(_pHTInfo) \
- ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? TRUE : FALSE
-
-
-typedef enum _HT_ACTION{
- ACT_RECOMMAND_WIDTH = 0,
- ACT_MIMO_PWR_SAVE = 1,
- ACT_PSMP = 2,
- ACT_SET_PCO_PHASE = 3,
- ACT_MIMO_CHL_MEASURE = 4,
- ACT_RECIPROCITY_CORRECT = 5,
- ACT_MIMO_CSI_MATRICS = 6,
- ACT_MIMO_NOCOMPR_STEER = 7,
- ACT_MIMO_COMPR_STEER = 8,
- ACT_ANTENNA_SELECT = 9,
-} HT_ACTION, *PHT_ACTION;
-
-
-/* 2007/06/07 MH Define sub-carrier mode for 40MHZ. */
-typedef enum _HT_Bandwidth_40MHZ_Sub_Carrier{
- SC_MODE_DUPLICATE = 0,
- SC_MODE_LOWER = 1,
- SC_MODE_UPPER = 2,
- SC_MODE_FULL40MHZ = 3,
-}HT_BW40_SC_E;
-
-typedef struct _HT_CAPABILITY_ELE{
-
- //HT capability info
- u8 AdvCoding:1;
- u8 ChlWidth:1;
- u8 MimoPwrSave:2;
- u8 GreenField:1;
- u8 ShortGI20Mhz:1;
- u8 ShortGI40Mhz:1;
- u8 TxSTBC:1;
- u8 RxSTBC:2;
- u8 DelayBA:1;
- u8 MaxAMSDUSize:1;
- u8 DssCCk:1;
- u8 PSMP:1;
- u8 Rsvd1:1;
- u8 LSigTxopProtect:1;
-
- //MAC HT parameters info
- u8 MaxRxAMPDUFactor:2;
- u8 MPDUDensity:3;
- u8 Rsvd2:3;
-
- //Supported MCS set
- u8 MCS[16];
-
-
- //Extended HT Capability Info
- u16 ExtHTCapInfo;
-
- //TXBF Capabilities
- u8 TxBFCap[4];
-
- //Antenna Selection Capabilities
- u8 ASCap;
-
-}__attribute__((packed)) HT_CAPABILITY_ELE, *PHT_CAPABILITY_ELE;
-
-//------------------------------------------------------------
-// The HT Information element is present in beacons
-// Only AP is required to include this element
-//------------------------------------------------------------
-
-typedef struct _HT_INFORMATION_ELE{
- u8 ControlChl;
-
- u8 ExtChlOffset:2;
- u8 RecommemdedTxWidth:1;
- u8 RIFS:1;
- u8 PSMPAccessOnly:1;
- u8 SrvIntGranularity:3;
-
- u8 OptMode:2;
- u8 NonGFDevPresent:1;
- u8 Revd1:5;
- u8 Revd2:8;
-
- u8 Rsvd3:6;
- u8 DualBeacon:1;
- u8 DualCTSProtect:1;
-
- u8 SecondaryBeacon:1;
- u8 LSigTxopProtectFull:1;
- u8 PcoActive:1;
- u8 PcoPhase:1;
- u8 Rsvd4:4;
-
- u8 BasicMSC[16];
-}__attribute__((packed)) HT_INFORMATION_ELE, *PHT_INFORMATION_ELE;
-
-//
-// MIMO Power Save control field.
-// This is appear in MIMO Power Save Action Frame
-//
-typedef struct _MIMOPS_CTRL{
- u8 MimoPsEnable:1;
- u8 MimoPsMode:1;
- u8 Reserved:6;
-} MIMOPS_CTRL, *PMIMOPS_CTRL;
-
-typedef enum _HT_SPEC_VER{
- HT_SPEC_VER_IEEE = 0,
- HT_SPEC_VER_EWC = 1,
-}HT_SPEC_VER, *PHT_SPEC_VER;
-
-typedef enum _HT_AGGRE_MODE_E{
- HT_AGG_AUTO = 0,
- HT_AGG_FORCE_ENABLE = 1,
- HT_AGG_FORCE_DISABLE = 2,
-}HT_AGGRE_MODE_E, *PHT_AGGRE_MODE_E;
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variables when card is
-// configured as non-AP STA mode. **Note** Current_xxx should be set
-// to default value in HTInitializeHTInfo()
-//------------------------------------------------------------
-
-typedef struct _RT_HIGH_THROUGHPUT{
-// DECLARE_RT_OBJECT(_RT_HIGH_THROUGHPUT);
- u8 bEnableHT;
- u8 bCurrentHTSupport;
-
- u8 bRegBW40MHz; // Tx 40MHz channel capablity
- u8 bCurBW40MHz; // Tx 40MHz channel capability
-
- u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz
- u8 bCurShortGI40MHz; // Tx Short GI for 40MHz
-
- u8 bRegShortGI20MHz; // Tx Short GI for 20MHz
- u8 bCurShortGI20MHz; // Tx Short GI for 20MHz
-
- u8 bRegSuppCCK; // Tx CCK rate capability
- u8 bCurSuppCCK; // Tx CCK rate capability
-
- // 802.11n spec version for "peer"
- HT_SPEC_VER ePeerHTSpecVer;
-
-
- // HT related information for "Self"
- HT_CAPABILITY_ELE SelfHTCap; // This is HT cap element sent to peer STA, which also indicate HT Rx capabilities.
- HT_INFORMATION_ELE SelfHTInfo; // This is HT info element sent to peer STA, which also indicate HT Rx capabilities.
-
- // HT related information for "Peer"
- u8 PeerHTCapBuf[32];
- u8 PeerHTInfoBuf[32];
-
-
- // A-MSDU related
- u8 bAMSDU_Support; // This indicates Tx A-MSDU capability
- u16 nAMSDU_MaxSize; // This indicates Tx A-MSDU capability
- u8 bCurrent_AMSDU_Support; // This indicates Tx A-MSDU capability
- u16 nCurrent_AMSDU_MaxSize; // This indicates Tx A-MSDU capability
-
-
- // AMPDU related <2006.08.10 Emily>
- u8 bAMPDUEnable; // This indicate Tx A-MPDU capability
- u8 bCurrentAMPDUEnable; // This indicate Tx A-MPDU capability
- u8 AMPDU_Factor; // This indicate Tx A-MPDU capability
- u8 CurrentAMPDUFactor; // This indicate Tx A-MPDU capability
- u8 MPDU_Density; // This indicate Tx A-MPDU capability
- u8 CurrentMPDUDensity; // This indicate Tx A-MPDU capability
-
- // Forced A-MPDU enable
- HT_AGGRE_MODE_E ForcedAMPDUMode;
- u8 ForcedAMPDUFactor;
- u8 ForcedMPDUDensity;
-
- // Forced A-MSDU enable
- HT_AGGRE_MODE_E ForcedAMSDUMode;
- u16 ForcedAMSDUMaxSize;
-
- u8 bForcedShortGI;
-
- u8 CurrentOpMode;
-
- // MIMO PS related
- u8 SelfMimoPs;
- u8 PeerMimoPs;
-
- // 40MHz Channel Offset settings.
- HT_EXTCHNL_OFFSET CurSTAExtChnlOffset;
- u8 bCurTxBW40MHz; // If we use 40 MHz to Tx
- u8 PeerBandwidth;
-
- // For Bandwidth Switching
- u8 bSwBwInProgress;
- CHNLOP ChnlOp; // software switching channel in progress. By Bruce, 2008-02-15.
- u8 SwBwStep;
- //RT_TIMER SwBwTimer;
- struct timer_list SwBwTimer;
-
- // For Realtek proprietary A-MPDU factor for aggregation
- u8 bRegRT2RTAggregation;
- u8 bCurrentRT2RTAggregation;
- u8 bCurrentRT2RTLongSlotTime;
- u8 szRT2RTAggBuffer[10];
-
- // Rx Reorder control
- u8 bRegRxReorderEnable;
- u8 bCurRxReorderEnable;
- u8 RxReorderWinSize;
- u8 RxReorderPendingTime;
- u16 RxReorderDropCounter;
-
-
- // Add for Broadcom(Linksys) IOT. Joseph
- u8 bIsPeerBcm;
-
- // For IOT issue.
- u32 IOTAction;
-}RT_HIGH_THROUGHPUT, *PRT_HIGH_THROUGHPUT;
-
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variable for "each Sta"
-// when card is configured as "AP mode"
-//------------------------------------------------------------
-
-typedef struct _RT_HTINFO_STA_ENTRY{
- u8 bEnableHT;
-
- u8 bSupportCck;
-
- u16 AMSDU_MaxSize;
-
- u8 AMPDU_Factor;
- u8 MPDU_Density;
-
- u8 HTHighestOperaRate;
-
- u8 bBw40MHz;
-
- u8 MimoPs;
-
- u8 McsRateSet[16];
-
-
-}RT_HTINFO_STA_ENTRY, *PRT_HTINFO_STA_ENTRY;
-
-
-
-
-
-//------------------------------------------------------------
-// The Data structure is used to keep HT related variable for "each AP"
-// when card is configured as "STA mode"
-//------------------------------------------------------------
-
-typedef struct _BSS_HT{
-
- u8 bdSupportHT;
-
- // HT related elements
- u8 bdHTCapBuf[32];
- u16 bdHTCapLen;
- u8 bdHTInfoBuf[32];
- u16 bdHTInfoLen;
-
- HT_SPEC_VER bdHTSpecVer;
- //HT_CAPABILITY_ELE bdHTCapEle;
- //HT_INFORMATION_ELE bdHTInfoEle;
-
- u8 bdRT2RTAggregation;
- u8 bdRT2RTLongSlotTime;
- bool bdHT1R;
-}BSS_HT, *PBSS_HT;
-
-typedef struct _MIMO_RSSI{
- u32 EnableAntenna;
- u32 AntennaA;
- u32 AntennaB;
- u32 AntennaC;
- u32 AntennaD;
- u32 Average;
-}MIMO_RSSI, *PMIMO_RSSI;
-
-typedef struct _MIMO_EVM{
- u32 EVM1;
- u32 EVM2;
-}MIMO_EVM, *PMIMO_EVM;
-
-typedef struct _FALSE_ALARM_STATISTICS{
- u32 Cnt_Parity_Fail;
- u32 Cnt_Rate_Illegal;
- u32 Cnt_Crc8_fail;
- u32 Cnt_all;
-}FALSE_ALARM_STATISTICS, *PFALSE_ALARM_STATISTICS;
-
-
-
-#endif //__INC_HTTYPE_H
-
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.c b/drivers/staging/rtl8192su/r819xU_cmdpkt.c
deleted file mode 100644
index 7ab9e22f8957..000000000000
--- a/drivers/staging/rtl8192su/r819xU_cmdpkt.c
+++ /dev/null
@@ -1,512 +0,0 @@
-/******************************************************************************
- * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
- * Linux device driver for RTL8192U
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * The full GNU General Public License is included in this distribution in the
- * file called LICENSE.
- *
- * Contact Information:
- * wlanfae <wlanfae@realtek.com>
-******************************************************************************/
-#include "r8192U.h"
-#include "r819xU_cmdpkt.h"
-
-bool SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen)
-{
- bool rtStatus = true;
- struct r8192_priv *priv = ieee80211_priv(dev);
- struct sk_buff *skb;
- cb_desc *tcb_desc;
- unsigned char *ptr_buf;
-
- /*
- * Get TCB and local buffer from common pool.
- * (It is shared by CmdQ, MgntQ, and USB coalesce DataQ)
- */
- skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4);
- if (!skb)
- return false;
- memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
- tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
- tcb_desc->queue_index = TXCMD_QUEUE;
- tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL;
- tcb_desc->bLastIniPkt = 0;
- skb_reserve(skb, USB_HWDESC_HEADER_LEN);
- ptr_buf = skb_put(skb, DataLen);
- memcpy(ptr_buf, pData, DataLen);
- tcb_desc->txbuf_size = (u16)DataLen;
-
- if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
- (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||
- (priv->ieee80211->queue_stop)) {
- RT_TRACE(COMP_FIRMWARE, "NULL packet => tx full\n");
- skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb);
- } else {
- priv->ieee80211->softmac_hard_start_xmit(skb, dev);
- }
-
- return rtStatus;
-}
-
-/*
- * Function: cmpk_message_handle_tx()
- *
- * Overview: Driver internal module can call the API to send message to
- * firmware side. For example, you can send a debug command packet.
- * Or you can send a request for FW to modify RLX4181 LBUS HW bank.
- * Otherwise, you can change MAC/PHT/RF register by firmware at
- * run time. We do not support message more than one segment now.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- */
- extern bool cmpk_message_handle_tx(
- struct net_device *dev,
- u8 *codevirtualaddress,
- u32 packettype,
- u32 buffer_len)
-{
- bool rt_status = true;
- return rt_status;
-}
-
-/*
- * Function: cmpk_counttxstatistic()
- */
-static void
-cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-#ifdef ENABLE_PS
- RT_RF_POWER_STATE rtState;
-
- pAdapter->HalFunc.GetHwRegHandler(pAdapter,
- HW_VAR_RF_STATE,
- (pu1Byte)(&rtState));
-
- /*
- * When RF is off, we should not count the packet for hw/sw synchronize
- * reason, ie. there may be a duration while sw switch is changed and hw
- * switch is being changed.
- */
- if (rtState == eRfOff)
- return;
-#endif
-
-#ifdef TODO
- if (pAdapter->bInHctTest)
- return;
-#endif
- /*
- * We can not know the packet length and transmit type:
- * broadcast or uni or multicast.
- * So the relative statistics must be collected in tx feedback info
- */
- if (pstx_fb->tok) {
- priv->stats.txfeedbackok++;
- priv->stats.txoktotal++;
- priv->stats.txokbytestotal += pstx_fb->pkt_length;
- priv->stats.txokinperiod++;
- /* We can not make sure broadcast/multicast or unicast mode. */
- if (pstx_fb->pkt_type == PACKET_MULTICAST) {
- priv->stats.txmulticast++;
- priv->stats.txbytesmulticast += pstx_fb->pkt_length;
- } else if (pstx_fb->pkt_type == PACKET_BROADCAST) {
- priv->stats.txbroadcast++;
- priv->stats.txbytesbroadcast += pstx_fb->pkt_length;
- } else {
- priv->stats.txunicast++;
- priv->stats.txbytesunicast += pstx_fb->pkt_length;
- }
- } else {
- priv->stats.txfeedbackfail++;
- priv->stats.txerrtotal++;
- priv->stats.txerrbytestotal += pstx_fb->pkt_length;
- /* We can not make sure broadcast/multicast or unicast mode. */
- if (pstx_fb->pkt_type == PACKET_MULTICAST)
- priv->stats.txerrmulticast++;
- else if (pstx_fb->pkt_type == PACKET_BROADCAST)
- priv->stats.txerrbroadcast++;
- else
- priv->stats.txerrunicast++;
- }
- priv->stats.txretrycount += pstx_fb->retry_cnt;
- priv->stats.txfeedbackretry += pstx_fb->retry_cnt;
-}
-
-/*
- * Function: cmpk_handle_tx_feedback()
- *
- * Overview: The function is responsible for extract the message inside TX
- * feedbck message from firmware. It will contain dedicated info in
- * ws-06-0063-rtl8190-command-packet-specification. Please
- * refer to chapter "TX Feedback Element". We have to read 20 bytes
- * in the command packet.
- *
- * Input: struct net_device * dev
- * u8 *pmsg - Msg Ptr of the command packet.
- *
- * Output: NONE
- *
- * Return: NONE
- */
-static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- cmpk_txfb_t rx_tx_fb;
-
- priv->stats.txfeedback++;
-
- /* 1. Extract TX feedback info from RFD to temp structure buffer. */
- memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t));
-
- /* 2. Use tx feedback info to count TX statistics. */
- cmpk_count_txstatistic(dev, &rx_tx_fb);
-}
-
-void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- u16 tx_rate;
-
- if (priv->ieee80211->current_network.mode == IEEE_A ||
- priv->ieee80211->current_network.mode == IEEE_N_5G ||
- (priv->ieee80211->current_network.mode == IEEE_N_24G &&
- (!priv->ieee80211->pHTInfo->bCurSuppCCK))) {
- tx_rate = 60;
- DMESG("send beacon frame tx rate is 6Mbpm\n");
- } else {
- tx_rate = 10;
- DMESG("send beacon frame tx rate is 1Mbpm\n");
- }
- rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */
-}
-
-/*
- * Function: cmpk_handle_interrupt_status()
- *
- * Overview: The function is responsible for extract the message from
- * firmware. It will contain dedicated info in
- * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc.
- * Please refer to chapter "Interrupt Status Element".
- *
- * Input: struct net_device *dev,
- * u8* pmsg - Message Pointer of the command packet.
- *
- * Output: NONE
- *
- * Return: NONE
- */
-static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
-{
- cmpk_intr_sta_t rx_intr_status; /* */
- struct r8192_priv *priv = ieee80211_priv(dev);
-
- DMESG("---> cmpk_Handle_Interrupt_Status()\n");
-
- /* 1. Extract TX feedback info from RFD to temp structure buffer. */
- rx_intr_status.length = pmsg[1];
- if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) {
- DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n");
- return;
- }
- /* Statistics of beacon for ad-hoc mode. */
- if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) {
- //2 maybe need endian transform?
- rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4));
-
- DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status);
-
- if (rx_intr_status.interrupt_status & ISR_TxBcnOk) {
- priv->ieee80211->bibsscoordinator = true;
- priv->stats.txbeaconokint++;
- } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) {
- priv->ieee80211->bibsscoordinator = false;
- priv->stats.txbeaconerr++;
- }
-
- if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr)
- cmdpkt_beacontimerinterrupt_819xusb(dev);
- }
- /* Other informations in interrupt status we need? */
- DMESG("<---- cmpk_handle_interrupt_status()\n");
-}
-
-/*
- * Function: cmpk_handle_query_config_rx()
- *
- * Overview: The function is responsible for extract the message from
- * firmware. It will contain dedicated info in
- * ws-06-0063-rtl8190-command-packet-specification
- * Please refer to chapter "Beacon State Element".
- *
- * Input: u8 * pmsg - Message Pointer of the command packet.
- *
- * Output: NONE
- *
- * Return: NONE
- *
- */
-static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg)
-{
- cmpk_query_cfg_t rx_query_cfg;
- /*
- * Extract TX feedback info from RFD to temp structure buffer.
- */
- rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000) >> 31;
- rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5;
- rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3;
- rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0;
- rx_query_cfg.cfg_offset = pmsg[7];
- rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) |
- (pmsg[10] << 8) | (pmsg[11] << 0);
- rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) |
- (pmsg[14] << 8) | (pmsg[15] << 0);
-}
-
-/*
- * Function: cmpk_count_tx_status()
- *
- * Overview: Count aggregated tx status from firmware of one type rx command
- * packet element id = RX_TX_STATUS.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- */
-static void cmpk_count_tx_status(struct net_device *dev,
- cmpk_tx_status_t *pstx_status)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-#ifdef ENABLE_PS
-
- RT_RF_POWER_STATE rtstate;
-
- pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
-
- /*
- * When RF is off, we should not count the packet for hw/sw synchronize
- * reason, ie. there may be a duration while sw switch is changed and hw
- * switch is being changed.
- */
- if (rtState == eRfOff)
- return;
-#endif
-
- priv->stats.txfeedbackok += pstx_status->txok;
- priv->stats.txoktotal += pstx_status->txok;
-
- priv->stats.txfeedbackfail += pstx_status->txfail;
- priv->stats.txerrtotal += pstx_status->txfail;
-
- priv->stats.txretrycount += pstx_status->txretry;
- priv->stats.txfeedbackretry += pstx_status->txretry;
-
- priv->stats.txmulticast += pstx_status->txmcok;
- priv->stats.txbroadcast += pstx_status->txbcok;
- priv->stats.txunicast += pstx_status->txucok;
-
- priv->stats.txerrmulticast += pstx_status->txmcfail;
- priv->stats.txerrbroadcast += pstx_status->txbcfail;
- priv->stats.txerrunicast += pstx_status->txucfail;
-
- priv->stats.txbytesmulticast += pstx_status->txmclength;
- priv->stats.txbytesbroadcast += pstx_status->txbclength;
- priv->stats.txbytesunicast += pstx_status->txuclength;
-
- priv->stats.last_packet_rate = pstx_status->rate;
-}
-
-/*
- * Function: cmpk_handle_tx_status()
- *
- * Overview: Firmware add a new tx feedback status to reduce rx command
- * packet buffer operation load.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- */
-static void
-cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg)
-{
- cmpk_tx_status_t rx_tx_sts;
-
- memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(cmpk_tx_status_t));
- /* 2. Use tx feedback info to count TX statistics. */
- cmpk_count_tx_status(dev, &rx_tx_sts);
-}
-
-/*
- * Function: cmpk_handle_tx_rate_history()
- *
- * Overview: Firmware add a new tx rate history
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- */
-static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg)
-{
- cmpk_tx_rahis_t *ptxrate;
- u8 i, j;
- u16 length = sizeof(cmpk_tx_rahis_t);
- u32 *ptemp;
- struct r8192_priv *priv = ieee80211_priv(dev);
-
-#ifdef ENABLE_PS
- pAdapter->HalFunc.GetHwRegHandler(pAdapter,
- HW_VAR_RF_STATE,
- (pu1Byte)(&rtState));
- /*
- * When RF is off, we should not count the packet for hw/sw synchronize
- * reason, ie. there may be a duration while sw switch is changed and hw
- * switch is being changed.
- */
- if (rtState == eRfOff)
- return;
-#endif
- ptemp = (u32 *)pmsg;
-
- /*
- * Do endian transfer to word alignment(16 bits) for windows system.
- * You must do different endian transfer for linux and MAC OS
- */
- for (i = 0; i < (length/4); i++) {
- u16 temp1, temp2;
- temp1 = ptemp[i] & 0x0000FFFF;
- temp2 = ptemp[i] >> 16;
- ptemp[i] = (temp1 << 16) | temp2;
- }
-
- ptxrate = (cmpk_tx_rahis_t *)pmsg;
-
- if (ptxrate == NULL)
- return;
-
- for (i = 0; i < 16; i++) {
- /* Collect CCK rate packet num */
- if (i < 4)
- priv->stats.txrate.cck[i] += ptxrate->cck[i];
- /* Collect OFDM rate packet num */
- if (i < 8)
- priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i];
- for (j = 0; j < 4; j++)
- priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i];
- }
-
-}
-
-/*
- * Function: cmpk_message_handle_rx()
- *
- * Overview: In the function, we will capture different RX command packet
- * info. Every RX command packet element has different message
- * length and meaning in content. We only support three type of RX
- * command packet now. Please refer to document
- * ws-06-0063-rtl8190-command-packet-specification.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- */
-extern u32
-cmpk_message_handle_rx(
- struct net_device *dev,
- struct ieee80211_rx_stats *pstats)
-{
- struct r8192_priv *priv = ieee80211_priv(dev);
- int total_length;
- u8 cmd_length, exe_cnt = 0;
- u8 element_id;
- u8 *pcmd_buff;
-
- /*
- * 0. Check input arguments.
- * If is is a command queue message or pointer is null
- */
- if ((pstats == NULL))
- return 0; /* This is not a command packet. */
-
- /* 1. Read received command packet message length from RFD. */
- total_length = pstats->Length;
-
- /* 2. Read virtual address from RFD. */
- pcmd_buff = pstats->virtual_address;
-
- /* 3. Read command pakcet element id and length. */
- element_id = pcmd_buff[0];
-
- /*
- * 4. Check every received command packet conent according to different
- * element type. Because FW may aggregate RX command packet to minimize
- * transmit time between DRV and FW.
- */
-
- /* Add a counter to prevent to locked in the loop too long */
- while (total_length > 0 || exe_cnt++ > 100) {
- /* We support aggregation of different cmd in the same packet */
- element_id = pcmd_buff[0];
- switch (element_id) {
- case RX_TX_FEEDBACK:
- cmpk_handle_tx_feedback(dev, pcmd_buff);
- cmd_length = CMPK_RX_TX_FB_SIZE;
- break;
- case RX_INTERRUPT_STATUS:
- cmpk_handle_interrupt_status(dev, pcmd_buff);
- cmd_length = sizeof(cmpk_intr_sta_t);
- break;
- case BOTH_QUERY_CONFIG:
- cmpk_handle_query_config_rx(dev, pcmd_buff);
- cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE;
- break;
- case RX_TX_STATUS:
- cmpk_handle_tx_status(dev, pcmd_buff);
- cmd_length = CMPK_RX_TX_STS_SIZE;
- break;
- case RX_TX_PER_PKT_FEEDBACK:
- cmd_length = CMPK_RX_TX_FB_SIZE;
- break;
- case RX_TX_RATE_HISTORY:
- cmpk_handle_tx_rate_history(dev, pcmd_buff);
- cmd_length = CMPK_TX_RAHIS_SIZE;
- break;
- case RX_TX_TSSI_MEAN_BACK:
- {
- u32 *pMsg;
- pMsg = (u32 *)pcmd_buff;
- }
- cmd_length = 32;
- break;
- default:
- RT_TRACE(COMP_ERR, "(%s): unknown CMD Element\n",
- __func__);
- return 1; /* This is a command packet. */
- }
- priv->stats.rxcmdpkt[element_id]++;
- total_length -= cmd_length;
- pcmd_buff += cmd_length;
- }
- return 1; /* This is a command packet. */
-}
diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.h b/drivers/staging/rtl8192su/r819xU_cmdpkt.h
deleted file mode 100644
index 95885bee7a48..000000000000
--- a/drivers/staging/rtl8192su/r819xU_cmdpkt.h
+++ /dev/null
@@ -1,192 +0,0 @@
-#ifndef R819XUSB_CMDPKT_H
-#define R819XUSB_CMDPKT_H
-
-/*
- * Different command packets have dedicated message length and definition.
- */
-#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) /* 20 */
-#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */
-#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */
-#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t)
-#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t)
-#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t)
-
-/* For USB constant. */
-#define ISR_TxBcnOk BIT27 /* Transmit Beacon OK */
-#define ISR_TxBcnErr BIT26 /* Transmit Beacon Error */
-#define ISR_BcnTimerIntr BIT13 /* Beacon Timer Interrupt */
-
-/*
- * Define different command packet structures
- *
- * 1. RX side: TX feedback packet.
- */
-typedef struct tag_cmd_pkt_tx_feedback {
- /* DWORD 0 */
- u8 element_id; /* Command packet type. */
- u8 length; /* Command packet length. */
- /* TX Feedback Info Field */
- u8 TID:4;
- u8 fail_reason:3;
- u8 tok:1; /* Transmit ok. */
- u8 reserve1:4;
- u8 pkt_type:2;
- u8 bandwidth:1;
- u8 qos_pkt:1;
-
- /* DWORD 1 */
- u8 reserve2;
- /* TX Feedback Info Field */
- u8 retry_cnt;
- u16 pkt_id;
-
- /* DWORD 3 */
- u16 seq_num;
- u8 s_rate; /* Start rate. */
- u8 f_rate; /* Final rate. */
-
- /* DWORD 4 */
- u8 s_rts_rate;
- u8 f_rts_rate;
- u16 pkt_length;
-
- /* DWORD 5 */
- u16 reserve3;
- u16 duration;
-} cmpk_txfb_t;
-
-/*
- * 2. RX side: Interrupt status packet.
- * It includes Beacon State, Beacon Timer Interrupt
- * and other useful informations in MAC ISR Reg.
- */
-typedef struct tag_cmd_pkt_interrupt_status {
- u8 element_id; /* Command packet type. */
- u8 length; /* Command packet length. */
- u16 reserve;
- u32 interrupt_status; /* Interrupt Status. */
-} cmpk_intr_sta_t;
-
-
-/*
- * 3. TX side: Set configuration packet.
- */
-typedef struct tag_cmd_pkt_set_configuration {
- u8 element_id; /* Command packet type. */
- u8 length; /* Command packet length. */
- u16 reserve1;
- u8 cfg_reserve1:3;
- u8 cfg_size:2; /* Configuration info. */
- u8 cfg_type:2; /* Configuration info. */
- u8 cfg_action:1; /* Configuration info. */
- u8 cfg_reserve2; /* Configuration info. */
- u8 cfg_page:4; /* Configuration info. */
- u8 cfg_reserve3:4; /* Configuration info. */
- u8 cfg_offset; /* Configuration info. */
- u32 value;
- u32 mask;
-} cmpk_set_cfg_t;
-
-/*
- * 4. Both side : TX/RX query configuraton packet.
- * The query structure is the same as set configuration.
- */
-#define cmpk_query_cfg_t cmpk_set_cfg_t
-
-/*
- * 5. Multi packet feedback status.
- */
-typedef struct tag_tx_stats_feedback {
- /*
- * For endian transfer
- * Driver will not the same as firmware structure.
- */
- /* DW 0 */
- u16 reserve1;
- u8 length; /* Command packet length */
- u8 element_id; /* Command packet type */
-
- /* DW 1 */
- u16 txfail; /* Tx Fail count */
- u16 txok; /* Tx ok count */
-
- /* DW 2 */
- u16 txmcok; /* tx multicast */
- u16 txretry; /* Tx Retry count */
-
- /* DW 3 */
- u16 txucok; /* tx unicast */
- u16 txbcok; /* tx broadcast */
-
- /* DW 4 */
- u16 txbcfail;
- u16 txmcfail;
-
- /* DW 5 */
- u16 reserve2;
- u16 txucfail;
-
- /* DW 6-8 */
- u32 txmclength;
- u32 txbclength;
- u32 txuclength;
-
- /* DW 9 */
- u16 reserve3_23;
- u8 reserve3_1;
- u8 rate;
-} __attribute__((packed)) cmpk_tx_status_t;
-
-/*
- * 6. Debug feedback message.
- */
-typedef struct tag_rx_debug_message_feedback {
- /* For endian transfer --> for driver */
- /* DW 0 */
- u16 reserve1;
- u8 length; /* Command packet length */
- u8 element_id; /* Command packet type */
-} cmpk_rx_dbginfo_t;
-
-/*
- * Define transmit rate history. For big endian format.
- */
-typedef struct tag_tx_rate_history {
- /* For endian transfer --> for driver */
- /* DW 0 */
- u8 element_id; /* Command packet type */
- u8 length; /* Command packet length */
- u16 reserved1;
- /* DW 1-2 CCK rate counter */
- u16 cck[4];
- /* DW 3-6 */
- u16 ofdm[8];
- u16 ht_mcs[4][16];
-} __attribute__((packed)) cmpk_tx_rahis_t;
-
-typedef enum tag_command_packet_directories {
- RX_TX_FEEDBACK = 0,
- RX_INTERRUPT_STATUS = 1,
- TX_SET_CONFIG = 2,
- BOTH_QUERY_CONFIG = 3,
- RX_TX_STATUS = 4,
- RX_DBGINFO_FEEDBACK = 5,
- RX_TX_PER_PKT_FEEDBACK = 6,
- RX_TX_RATE_HISTORY = 7,
- RX_TX_TSSI_MEAN_BACK = 8,
- RX_CMD_ELE_MAX
-} cmpk_element_e;
-
-extern bool cmpk_message_handle_tx(struct net_device *dev,
- u8 *codevirtualaddress,
- u32 packettype,
- u32 buffer_len);
-
-extern u32 cmpk_message_handle_rx(struct net_device *dev,
- struct ieee80211_rx_stats *pstats);
-
-extern bool SendTxCommandPacket(struct net_device *dev,
- void *pData,
- u32 DataLen);
-
-#endif
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 192123fbec7f..c8ca9d8ed5d2 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -2391,7 +2391,7 @@ static inline void update_network(struct ieee80211_network *dst,
if(src->wmm_param[0].ac_aci_acm_aifsn|| \
src->wmm_param[1].ac_aci_acm_aifsn|| \
src->wmm_param[2].ac_aci_acm_aifsn|| \
- src->wmm_param[1].ac_aci_acm_aifsn) {
+ src->wmm_param[3].ac_aci_acm_aifsn) {
memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
}
//dst->QoS_Enable = src->QoS_Enable;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index a2e84c578579..bc8c42533693 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -449,7 +449,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
}while(!ieee->channel_map[ch]);
#endif
- /* this fuction can be called in two situations
+ /* this function can be called in two situations
* 1- We have switched to ad-hoc mode and we are
* performing a complete syncro scan before conclude
* there are no interesting cell and to create a
diff --git a/drivers/staging/rtl8712/Kconfig b/drivers/staging/rtl8712/Kconfig
new file mode 100644
index 000000000000..1e9a230a4db1
--- /dev/null
+++ b/drivers/staging/rtl8712/Kconfig
@@ -0,0 +1,18 @@
+config R8712U
+ tristate "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver"
+ depends on WLAN && USB
+ select WIRELESS_EXT
+ select WEXT_PRIV
+ default N
+ ---help---
+ This option adds the Realtek RTL8712 USB device such as the D-Link DWA-130.
+ If built as a module, it will be called r8712u.
+
+config R8712_AP
+ bool "Realtek RTL8712U AP code"
+ depends on R8712U
+ default N
+ ---help---
+ This option allows the Realtek RTL8712 USB device to be an Access Point.
+
+
diff --git a/drivers/staging/rtl8712/Makefile b/drivers/staging/rtl8712/Makefile
new file mode 100644
index 000000000000..1ccd251fde47
--- /dev/null
+++ b/drivers/staging/rtl8712/Makefile
@@ -0,0 +1,34 @@
+r8712u-objs := \
+ rtl871x_cmd.o \
+ rtl8712_cmd.o \
+ rtl871x_security.o \
+ rtl871x_eeprom.o \
+ rtl8712_efuse.o \
+ hal_init.o \
+ usb_halinit.o \
+ usb_ops.o \
+ usb_ops_linux.o \
+ rtl871x_io.o \
+ rtl8712_io.o \
+ rtl871x_ioctl_linux.o \
+ rtl871x_ioctl_rtl.o \
+ rtl871x_ioctl_set.o \
+ rtl8712_led.o \
+ rtl871x_mlme.o \
+ ieee80211.o \
+ rtl871x_mp_ioctl.o \
+ rtl871x_mp.o \
+ mlme_linux.o \
+ recv_linux.o \
+ xmit_linux.o \
+ usb_intf.o \
+ os_intfs.o \
+ rtl871x_pwrctrl.o \
+ rtl8712_recv.o \
+ rtl871x_recv.o \
+ rtl871x_sta_mgt.o \
+ rtl871x_xmit.o \
+ rtl8712_xmit.o
+
+obj-$(CONFIG_R8712U) := r8712u.o
+
diff --git a/drivers/staging/rtl8712/TODO b/drivers/staging/rtl8712/TODO
new file mode 100644
index 000000000000..5c888214666e
--- /dev/null
+++ b/drivers/staging/rtl8712/TODO
@@ -0,0 +1,16 @@
+TODO:
+- merge Realtek's bugfixes and new features into the driver
+- switch to use LIB80211
+- switch to use MAC80211
+- checkpatch.pl fixes - only a few remain
+- sparse fixes
+- switch from large inline firmware file to use the firmware interface
+ and add the file to the linux-firmware package.
+
+Please send any patches to Greg Kroah-Hartman <greg@kroah.com>,
+Larry Finger <Larry.Finger@lwfinger.net> and
+Florian Schilhabel <florian.c.schilhabel@googlemail.com>.
+
+
+
+
diff --git a/drivers/staging/rtl8712/basic_types.h b/drivers/staging/rtl8712/basic_types.h
new file mode 100644
index 000000000000..a0538a8a6703
--- /dev/null
+++ b/drivers/staging/rtl8712/basic_types.h
@@ -0,0 +1,23 @@
+#ifndef __BASIC_TYPES_H__
+#define __BASIC_TYPES_H__
+
+#define SUCCESS 0
+#define FAIL (-1)
+
+#include <linux/types.h>
+
+#define SIZE_T __kernel_size_t
+#define sint signed int
+#define FIELD_OFFSET(s, field) ((addr_t)&((s *)(0))->field)
+
+/* Should we extend this to be host_addr_t and target_addr_t for case:
+ * host : x86_64
+ * target : mips64
+ */
+#define addr_t unsigned long
+
+#define MEM_ALIGNMENT_OFFSET (sizeof(SIZE_T))
+#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
+
+#endif /*__BASIC_TYPES_H__*/
+
diff --git a/drivers/staging/rtl8712/big_endian.h b/drivers/staging/rtl8712/big_endian.h
new file mode 100644
index 000000000000..8512d1b5919d
--- /dev/null
+++ b/drivers/staging/rtl8712/big_endian.h
@@ -0,0 +1,69 @@
+#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H
+#define _LINUX_BYTEORDER_BIG_ENDIAN_H
+
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+#ifndef __BIG_ENDIAN_BITFIELD
+#define __BIG_ENDIAN_BITFIELD
+#endif
+
+#include "swab.h"
+
+#define __constant_htonl(x) ((__u32)(x))
+#define __constant_ntohl(x) ((__u32)(x))
+#define __constant_htons(x) ((__u16)(x))
+#define __constant_ntohs(x) ((__u16)(x))
+#define __constant_cpu_to_le64(x) ___constant_swab64((x))
+#define __constant_le64_to_cpu(x) ___constant_swab64((x))
+#define __constant_cpu_to_le32(x) ___constant_swab32((x))
+#define __constant_le32_to_cpu(x) ___constant_swab32((x))
+#define __constant_cpu_to_le16(x) ___constant_swab16((x))
+#define __constant_le16_to_cpu(x) ___constant_swab16((x))
+#define __constant_cpu_to_be64(x) ((__u64)(x))
+#define __constant_be64_to_cpu(x) ((__u64)(x))
+#define __constant_cpu_to_be32(x) ((__u32)(x))
+#define __constant_be32_to_cpu(x) ((__u32)(x))
+#define __constant_cpu_to_be16(x) ((__u16)(x))
+#define __constant_be16_to_cpu(x) ((__u16)(x))
+#define __cpu_to_le64(x) __swab64((x))
+#define __le64_to_cpu(x) __swab64((x))
+#define __cpu_to_le32(x) __swab32((x))
+#define __le32_to_cpu(x) __swab32((x))
+#define __cpu_to_le16(x) __swab16((x))
+#define __le16_to_cpu(x) __swab16((x))
+#define __cpu_to_be64(x) ((__u64)(x))
+#define __be64_to_cpu(x) ((__u64)(x))
+#define __cpu_to_be32(x) ((__u32)(x))
+#define __be32_to_cpu(x) ((__u32)(x))
+#define __cpu_to_be16(x) ((__u16)(x))
+#define __be16_to_cpu(x) ((__u16)(x))
+#define __cpu_to_le64p(x) __swab64p((x))
+#define __le64_to_cpup(x) __swab64p((x))
+#define __cpu_to_le32p(x) __swab32p((x))
+#define __le32_to_cpup(x) __swab32p((x))
+#define __cpu_to_le16p(x) __swab16p((x))
+#define __le16_to_cpup(x) __swab16p((x))
+#define __cpu_to_be64p(x) (*(__u64 *)(x))
+#define __be64_to_cpup(x) (*(__u64 *)(x))
+#define __cpu_to_be32p(x) (*(__u32 *)(x))
+#define __be32_to_cpup(x) (*(__u32 *)(x))
+#define __cpu_to_be16p(x) (*(__u16 *)(x))
+#define __be16_to_cpup(x) (*(__u16 *)(x))
+#define __cpu_to_le64s(x) __swab64s((x))
+#define __le64_to_cpus(x) __swab64s((x))
+#define __cpu_to_le32s(x) __swab32s((x))
+#define __le32_to_cpus(x) __swab32s((x))
+#define __cpu_to_le16s(x) __swab16s((x))
+#define __le16_to_cpus(x) __swab16s((x))
+#define __cpu_to_be64s(x) do {} while (0)
+#define __be64_to_cpus(x) do {} while (0)
+#define __cpu_to_be32s(x) do {} while (0)
+#define __be32_to_cpus(x) do {} while (0)
+#define __cpu_to_be16s(x) do {} while (0)
+#define __be16_to_cpus(x) do {} while (0)
+
+#include "generic.h"
+
+#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
+
diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h
new file mode 100644
index 000000000000..3bb66dc2eb2c
--- /dev/null
+++ b/drivers/staging/rtl8712/drv_types.h
@@ -0,0 +1,165 @@
+/*---------------------------------------------------------------------
+
+ For type defines and data structure defines
+
+-----------------------------------------------------------------------*/
+#ifndef __DRV_TYPES_H__
+#define __DRV_TYPES_H__
+
+struct _adapter;
+
+#include "osdep_service.h"
+#include "wlan_bssdef.h"
+#include "rtl8712_spec.h"
+#include "rtl8712_hal.h"
+
+enum _NIC_VERSION {
+ RTL8711_NIC,
+ RTL8712_NIC,
+ RTL8713_NIC,
+ RTL8716_NIC
+};
+
+struct _adapter;
+
+struct qos_priv {
+ /* bit mask option: u-apsd, s-apsd, ts, block ack... */
+ unsigned int qos_option;
+};
+
+#include "rtl871x_ht.h"
+#include "rtl871x_cmd.h"
+#include "wlan_bssdef.h"
+#include "rtl871x_xmit.h"
+#include "rtl871x_recv.h"
+#include "rtl871x_security.h"
+#include "rtl871x_pwrctrl.h"
+#include "rtl871x_io.h"
+#include "rtl871x_eeprom.h"
+#include "sta_info.h"
+#include "rtl871x_mlme.h"
+#include "rtl871x_mp.h"
+#include "rtl871x_debug.h"
+#include "rtl871x_rf.h"
+#include "rtl871x_event.h"
+#include "rtl871x_led.h"
+
+#define SPEC_DEV_ID_NONE BIT(0)
+#define SPEC_DEV_ID_DISABLE_HT BIT(1)
+#define SPEC_DEV_ID_ENABLE_PS BIT(2)
+
+struct specific_device_id {
+ u32 flags;
+ u16 idVendor;
+ u16 idProduct;
+
+};
+
+struct registry_priv {
+ u8 chip_version;
+ u8 rfintfs;
+ u8 lbkmode;
+ u8 hci;
+ u8 network_mode; /*infra, ad-hoc, auto*/
+ struct ndis_802_11_ssid ssid;
+ u8 channel;/* ad-hoc support requirement */
+ u8 wireless_mode;/* A, B, G, auto */
+ u8 vrtl_carrier_sense; /*Enable, Disable, Auto*/
+ u8 vcs_type;/*RTS/CTS, CTS-to-self*/
+ u16 rts_thresh;
+ u16 frag_thresh;
+ u8 preamble;/*long, short, auto*/
+ u8 scan_mode;/*active, passive*/
+ u8 adhoc_tx_pwr;
+ u8 soft_ap;
+ u8 smart_ps;
+ u8 power_mgnt;
+ u8 radio_enable;
+ u8 long_retry_lmt;
+ u8 short_retry_lmt;
+ u16 busy_thresh;
+ u8 ack_policy;
+ u8 mp_mode;
+ u8 software_encrypt;
+ u8 software_decrypt;
+ /* UAPSD */
+ u8 wmm_enable;
+ u8 uapsd_enable;
+ u8 uapsd_max_sp;
+ u8 uapsd_acbk_en;
+ u8 uapsd_acbe_en;
+ u8 uapsd_acvi_en;
+ u8 uapsd_acvo_en;
+
+ struct wlan_bssid_ex dev_network;
+
+ u8 ht_enable;
+ u8 cbw40_enable;
+ u8 ampdu_enable;/*for tx*/
+ u8 rf_config;
+ u8 low_power;
+ u8 wifi_test;
+};
+
+/* For registry parameters */
+#define RGTRY_OFT(field) ((addr_t)FIELD_OFFSET(struct registry_priv, field))
+#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field)
+#define BSSID_OFT(field) ((addr_t)FIELD_OFFSET(struct ndis_wlan_bssid_ex, \
+ field))
+#define BSSID_SZ(field) sizeof(((struct ndis_wlan_bssid_ex *)0)->field)
+
+struct dvobj_priv {
+ struct _adapter *padapter;
+ u32 nr_endpoint;
+ u8 ishighspeed;
+ uint(*inirp_init)(struct _adapter *adapter);
+ uint(*inirp_deinit)(struct _adapter *adapter);
+ struct semaphore usb_suspend_sema;
+ struct usb_device *pusbdev;
+};
+
+struct _adapter {
+ struct dvobj_priv dvobjpriv;
+ struct mlme_priv mlmepriv;
+ struct cmd_priv cmdpriv;
+ struct evt_priv evtpriv;
+ struct io_queue *pio_queue;
+ struct xmit_priv xmitpriv;
+ struct recv_priv recvpriv;
+ struct sta_priv stapriv;
+ struct security_priv securitypriv;
+ struct registry_priv registrypriv;
+ struct wlan_acl_pool acl_list;
+ struct pwrctrl_priv pwrctrlpriv;
+ struct eeprom_priv eeprompriv;
+ struct hal_priv halpriv;
+ struct led_priv ledpriv;
+ struct mp_priv mppriv;
+ s32 bDriverStopped;
+ s32 bSurpriseRemoved;
+ u32 IsrContent;
+ u32 ImrContent;
+ u8 EepromAddressSize;
+ u8 hw_init_completed;
+ struct task_struct *cmdThread;
+ pid_t evtThread;
+ struct task_struct *xmitThread;
+ pid_t recvThread;
+ uint(*dvobj_init)(struct _adapter *adapter);
+ void (*dvobj_deinit)(struct _adapter *adapter);
+ struct net_device *pnetdev;
+ int bup;
+ struct net_device_stats stats;
+ struct iw_statistics iwstats;
+ int pid; /*process id from UI*/
+};
+
+static inline u8 *myid(struct eeprom_priv *peepriv)
+{
+ return peepriv->mac_addr;
+}
+
+u8 r8712_usb_hal_bus_init(struct _adapter *adapter);
+
+#endif /*__DRV_TYPES_H__*/
+
diff --git a/drivers/staging/rtl8712/ethernet.h b/drivers/staging/rtl8712/ethernet.h
new file mode 100644
index 000000000000..ba8d777d8e10
--- /dev/null
+++ b/drivers/staging/rtl8712/ethernet.h
@@ -0,0 +1,23 @@
+#ifndef __INC_ETHERNET_H
+#define __INC_ETHERNET_H
+
+#define ETHERNET_ADDRESS_LENGTH 6 /*!< Ethernet Address Length*/
+#define ETHERNET_HEADER_SIZE 14 /*!< Ethernet Header Length*/
+#define LLC_HEADER_SIZE 6 /*!< LLC Header Length*/
+#define TYPE_LENGTH_FIELD_SIZE 2 /*!< Type/Length Size*/
+#define MINIMUM_ETHERNET_PACKET_SIZE 60 /*!< Min Ethernet Packet Size*/
+#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /*!< Max Ethernet Packet Size*/
+
+/*!< Is Multicast Address? */
+#define RT_ETH_IS_MULTICAST(_pAddr) ((((u8 *)(_pAddr))[0]&0x01) != 0)
+/*!< Is Broadcast Address? */
+#define RT_ETH_IS_BROADCAST(_pAddr) ( \
+ ((u8 *)(_pAddr))[0] == 0xff && \
+ ((u8 *)(_pAddr))[1] == 0xff && \
+ ((u8 *)(_pAddr))[2] == 0xff && \
+ ((u8 *)(_pAddr))[3] == 0xff && \
+ ((u8 *)(_pAddr))[4] == 0xff && \
+ ((u8 *)(_pAddr))[5] == 0xff)
+
+#endif /* #ifndef __INC_ETHERNET_H */
+
diff --git a/drivers/staging/rtl8712/farray.h b/drivers/staging/rtl8712/farray.h
new file mode 100644
index 000000000000..921777269709
--- /dev/null
+++ b/drivers/staging/rtl8712/farray.h
@@ -0,0 +1,10197 @@
+/* Firmware */
+static const unsigned char f_array[122328] = {
+0x12, 0x87, 0xEC, 0x11, 0x30, 0x00, 0x00, 0x00, 0x08, 0xE8, 0x00, 0x00,
+0x50, 0xF5, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x98, 0xF3, 0x00, 0x00,
+0xF2, 0x00, 0x00, 0x00, 0x05, 0x30, 0x16, 0x53, 0x87, 0x12, 0x12, 0x01,
+0x00, 0x00, 0x12, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01,
+0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x1A, 0x3C, 0x80, 0x03, 0x5A, 0x37, 0x00, 0x80, 0x1B, 0x3C,
+0x80, 0x00, 0x7B, 0x37, 0x00, 0x00, 0x5B, 0xAF, 0x25, 0xB0, 0x1A, 0x3C,
+0x18, 0x03, 0x5A, 0x37, 0x00, 0x80, 0x1B, 0x3C, 0x80, 0x00, 0x7B, 0x37,
+0x00, 0x00, 0x5B, 0xAF, 0x01, 0x80, 0x1A, 0x3C, 0x24, 0xE2, 0x5A, 0x27,
+0x08, 0x00, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xA1, 0xAF, 0x08, 0x00, 0xA2, 0xAF,
+0x0C, 0x00, 0xA3, 0xAF, 0x10, 0x00, 0xA4, 0xAF, 0x14, 0x00, 0xA5, 0xAF,
+0x18, 0x00, 0xA6, 0xAF, 0x1C, 0x00, 0xA7, 0xAF, 0x20, 0x00, 0xA8, 0xAF,
+0x24, 0x00, 0xA9, 0xAF, 0x28, 0x00, 0xAA, 0xAF, 0x2C, 0x00, 0xAB, 0xAF,
+0x30, 0x00, 0xAC, 0xAF, 0x34, 0x00, 0xAD, 0xAF, 0x38, 0x00, 0xAE, 0xAF,
+0x3C, 0x00, 0xAF, 0xAF, 0x12, 0x40, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00,
+0x00, 0x70, 0x0A, 0x40, 0x40, 0x00, 0xB0, 0xAF, 0x44, 0x00, 0xB1, 0xAF,
+0x48, 0x00, 0xB2, 0xAF, 0x4C, 0x00, 0xB3, 0xAF, 0x50, 0x00, 0xB4, 0xAF,
+0x54, 0x00, 0xB5, 0xAF, 0x58, 0x00, 0xB6, 0xAF, 0x5C, 0x00, 0xB7, 0xAF,
+0x60, 0x00, 0xB8, 0xAF, 0x64, 0x00, 0xB9, 0xAF, 0x68, 0x00, 0xBC, 0xAF,
+0x6C, 0x00, 0xBD, 0xAF, 0x70, 0x00, 0xBE, 0xAF, 0x74, 0x00, 0xBF, 0xAF,
+0x78, 0x00, 0xA8, 0xAF, 0x7C, 0x00, 0xA9, 0xAF, 0x80, 0x00, 0xAA, 0xAF,
+0x17, 0x38, 0x00, 0x08, 0x21, 0x20, 0xA0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xBD, 0x27,
+0x14, 0x00, 0xB1, 0xAF, 0x00, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x11, 0x3C,
+0x18, 0x03, 0x23, 0x36, 0x00, 0x03, 0x42, 0x24, 0x00, 0x00, 0x62, 0xAC,
+0x18, 0x00, 0xB2, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x1C, 0x00, 0xBF, 0xAF,
+0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x42, 0xB0, 0x02, 0x3C,
+0x03, 0x00, 0x47, 0x34, 0x00, 0x00, 0xE3, 0x90, 0x02, 0x80, 0x0A, 0x3C,
+0x02, 0x80, 0x0B, 0x3C, 0xFF, 0x00, 0x70, 0x30, 0x00, 0x36, 0x10, 0x00,
+0x10, 0x00, 0x02, 0x32, 0x03, 0x36, 0x06, 0x00, 0x17, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x12, 0x3C, 0xFC, 0x5C, 0x42, 0x8D, 0x60, 0x1B, 0x44, 0x26,
+0x64, 0x37, 0x83, 0x94, 0x01, 0x00, 0x45, 0x24, 0x10, 0x00, 0x02, 0x24,
+0xB0, 0x03, 0x29, 0x36, 0x1C, 0x03, 0x28, 0x36, 0x00, 0x00, 0xE2, 0xA0,
+0x07, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x68, 0x37, 0x82, 0x94,
+0x64, 0x37, 0x80, 0xA4, 0x68, 0x37, 0x80, 0xA4, 0x00, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x02, 0xAD, 0x00, 0x00, 0x20, 0xAD, 0x10, 0x5E, 0x62, 0x8D,
+0x01, 0x00, 0x63, 0x24, 0xFC, 0x5C, 0x45, 0xAD, 0x01, 0x00, 0x42, 0x24,
+0x10, 0x5E, 0x62, 0xAD, 0x64, 0x37, 0x83, 0xA4, 0x29, 0x00, 0xC0, 0x04,
+0x42, 0xB0, 0x02, 0x3C, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x40, 0x00, 0x02, 0x32, 0x0F, 0x00, 0x40, 0x14, 0x60, 0x1B, 0x44, 0x26,
+0xE0, 0x1B, 0x83, 0x94, 0xDC, 0x1B, 0x85, 0x94, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x80, 0x00, 0x63, 0x30, 0x41, 0xB0, 0x02, 0x3C, 0x25, 0x18, 0x65, 0x00,
+0x08, 0x00, 0x42, 0x34, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x43, 0xA4,
+0x08, 0x00, 0xE0, 0x03, 0xDC, 0x1B, 0x83, 0xA4, 0x42, 0xB0, 0x02, 0x3C,
+0x40, 0x00, 0x03, 0x24, 0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0,
+0x25, 0x62, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x44, 0x26,
+0xE0, 0x1B, 0x83, 0x94, 0xDC, 0x1B, 0x85, 0x94, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x80, 0x00, 0x63, 0x30, 0x41, 0xB0, 0x02, 0x3C, 0x25, 0x18, 0x65, 0x00,
+0x08, 0x00, 0x42, 0x34, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x43, 0xA4,
+0x08, 0x00, 0xE0, 0x03, 0xDC, 0x1B, 0x83, 0xA4, 0x80, 0xFF, 0x03, 0x24,
+0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0, 0x44, 0x22, 0x00, 0x74,
+0x00, 0x00, 0x00, 0x00, 0xEF, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x84, 0x30, 0x0B, 0x00, 0x82, 0x2C, 0xFF, 0xFF, 0xE7, 0x30,
+0x10, 0x00, 0xA8, 0x93, 0x19, 0x00, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x80, 0x10, 0x04, 0x00, 0x88, 0xE6, 0x63, 0x24,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0xB0, 0x02, 0x3C,
+0x78, 0x00, 0x44, 0x34, 0x07, 0x00, 0xE2, 0x30, 0x00, 0x00, 0x85, 0xAC,
+0x04, 0x00, 0x86, 0xAC, 0x04, 0x00, 0x40, 0x18, 0x00, 0x00, 0x00, 0x00,
+0xF8, 0xFF, 0xE2, 0x30, 0x08, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x47, 0x30,
+0x21, 0x10, 0xE8, 0x00, 0x00, 0x80, 0x03, 0x3C, 0x08, 0x00, 0x82, 0xAC,
+0x25, 0x10, 0x43, 0x00, 0x08, 0x00, 0x82, 0xAC, 0x01, 0x00, 0x03, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x6C, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x60, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x54, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x48, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x3C, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x30, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x24, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x18, 0x00, 0x44, 0x34, 0x43, 0xB0, 0x02, 0x3C,
+0x2E, 0x01, 0x00, 0x08, 0x0C, 0x00, 0x44, 0x34, 0x2E, 0x01, 0x00, 0x08,
+0x43, 0xB0, 0x04, 0x3C, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x18, 0x03, 0x42, 0x34, 0x6C, 0x05, 0x63, 0x24, 0x00, 0x00, 0x43, 0xAC,
+0x01, 0x00, 0x05, 0x24, 0x43, 0xB0, 0x02, 0x3C, 0x04, 0x28, 0x85, 0x00,
+0x88, 0x00, 0x44, 0x34, 0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24,
+0xFF, 0xFF, 0x42, 0x30, 0x05, 0x00, 0x43, 0x2C, 0xFD, 0xFF, 0x60, 0x14,
+0x01, 0x00, 0x42, 0x24, 0x00, 0x00, 0x82, 0x94, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xFF, 0x42, 0x30, 0x24, 0x10, 0x45, 0x00, 0xF5, 0xFF, 0x40, 0x1C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x08, 0x3C, 0x00, 0x80, 0x02, 0x3C, 0xC8, 0xFF, 0xBD, 0x27,
+0x18, 0x03, 0x03, 0x35, 0xC8, 0x05, 0x42, 0x24, 0x00, 0x00, 0x62, 0xAC,
+0x30, 0x00, 0xB6, 0xAF, 0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x34, 0x00, 0xBF, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x20, 0x00, 0xB2, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x0C, 0x00, 0xF2, 0x84,
+0x08, 0x00, 0xF5, 0x8C, 0xFF, 0x00, 0xC6, 0x30, 0x00, 0x01, 0x02, 0x24,
+0x23, 0x10, 0x46, 0x00, 0xFF, 0xFF, 0x51, 0x30, 0xD0, 0x03, 0x08, 0x35,
+0xFF, 0x00, 0x96, 0x30, 0x00, 0x00, 0x12, 0xAD, 0x21, 0xA0, 0xA0, 0x00,
+0x21, 0x30, 0xC5, 0x00, 0x00, 0x00, 0x15, 0xAD, 0x21, 0x20, 0xC0, 0x02,
+0x21, 0x28, 0xA0, 0x02, 0x21, 0x38, 0x20, 0x02, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x23, 0x18, 0x51, 0x02, 0xFF, 0xFF, 0x82, 0x32,
+0x00, 0x94, 0x03, 0x00, 0x03, 0x94, 0x12, 0x00, 0xB4, 0x01, 0x00, 0x08,
+0x02, 0x9A, 0x02, 0x00, 0x28, 0xB0, 0x03, 0x3C, 0xC0, 0x10, 0x13, 0x00,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x90, 0x25, 0xB0, 0x10, 0x3C,
+0x20, 0x10, 0x02, 0x3C, 0xFF, 0x00, 0x93, 0x30, 0x00, 0x22, 0x13, 0x00,
+0xFF, 0xFF, 0x43, 0x32, 0x01, 0x01, 0x45, 0x2A, 0x21, 0xA0, 0x82, 0x00,
+0x21, 0xA8, 0xB1, 0x02, 0xD0, 0x03, 0x02, 0x36, 0x00, 0x01, 0x11, 0x24,
+0x0B, 0x88, 0x65, 0x00, 0x21, 0x20, 0xC0, 0x02, 0x00, 0x00, 0x53, 0xAC,
+0x5B, 0x01, 0x00, 0x0C, 0xB0, 0x03, 0x10, 0x36, 0x21, 0x30, 0x80, 0x02,
+0x21, 0x20, 0xC0, 0x02, 0x21, 0x28, 0xA0, 0x02, 0x21, 0x38, 0x20, 0x02,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x23, 0x18, 0x51, 0x02,
+0x00, 0x94, 0x03, 0x00, 0x03, 0x94, 0x12, 0x00, 0x00, 0x00, 0x12, 0xAE,
+0xE2, 0xFF, 0x40, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0x21, 0x50, 0x80, 0x00, 0x04, 0x00, 0x8D, 0x8C, 0x0C, 0x00, 0x4B, 0x8D,
+0x08, 0x00, 0x84, 0x8C, 0xFF, 0xE0, 0x02, 0x3C, 0x10, 0x00, 0x47, 0x8D,
+0xFF, 0xFF, 0x42, 0x34, 0x1F, 0x00, 0xA9, 0x31, 0x24, 0x20, 0x82, 0x00,
+0x00, 0x1E, 0x09, 0x00, 0x02, 0x14, 0x0B, 0x00, 0x25, 0x40, 0x83, 0x00,
+0x21, 0x78, 0xA0, 0x00, 0xB7, 0x00, 0xE0, 0x04, 0x07, 0x00, 0x44, 0x30,
+0x00, 0x00, 0x42, 0x95, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x0F, 0x42, 0x28,
+0xB9, 0x00, 0x40, 0x10, 0xFF, 0xDF, 0x02, 0x3C, 0x02, 0x80, 0x0E, 0x3C,
+0x08, 0x00, 0x48, 0xAD, 0x60, 0x1B, 0xC3, 0x25, 0xC6, 0x3D, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x40, 0x14, 0xC0, 0x30, 0x09, 0x00,
+0xC6, 0x40, 0x62, 0x90, 0xFF, 0xDF, 0x03, 0x3C, 0xFF, 0xFF, 0x63, 0x34,
+0x07, 0x10, 0x82, 0x00, 0x01, 0x00, 0x42, 0x30, 0x24, 0x18, 0x03, 0x01,
+0x40, 0x17, 0x02, 0x00, 0x25, 0x40, 0x62, 0x00, 0x08, 0x00, 0x48, 0xAD,
+0xC0, 0x30, 0x09, 0x00, 0x21, 0x10, 0xC9, 0x00, 0x80, 0x10, 0x02, 0x00,
+0x21, 0x10, 0x49, 0x00, 0x80, 0x10, 0x02, 0x00, 0x60, 0x1B, 0xC9, 0x25,
+0x21, 0x28, 0x49, 0x00, 0x08, 0x25, 0xA3, 0x8C, 0x01, 0x00, 0x0C, 0x24,
+0x02, 0x13, 0x03, 0x00, 0x01, 0x00, 0x42, 0x30, 0xB5, 0x00, 0x4C, 0x10,
+0x42, 0x18, 0x03, 0x00, 0x82, 0x11, 0x08, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0xC0, 0xFF, 0x02, 0x24,
+0x24, 0x10, 0x02, 0x01, 0x04, 0x00, 0x48, 0x34, 0x08, 0x00, 0x48, 0xAD,
+0x02, 0x80, 0x02, 0x3C, 0xD1, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x6A, 0x00, 0x60, 0x14, 0x21, 0x20, 0xC9, 0x00, 0xD4, 0x23, 0x83, 0x8C,
+0xBF, 0xFF, 0x02, 0x24, 0x24, 0x10, 0xE2, 0x00, 0x40, 0x00, 0x63, 0x30,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0xD4, 0x23, 0x83, 0x8C,
+0x7F, 0xF8, 0x02, 0x24, 0x24, 0x10, 0xE2, 0x00, 0x80, 0x07, 0x63, 0x30,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0xC6, 0x3D, 0x22, 0x91,
+0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x40, 0x14, 0x42, 0x17, 0x08, 0x00,
+0x01, 0x00, 0x44, 0x30, 0xB1, 0x00, 0x8C, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0xC4, 0x25, 0x21, 0x20, 0xC4, 0x00, 0xD4, 0x23, 0x83, 0x8C,
+0xFF, 0xF7, 0x02, 0x24, 0x24, 0x10, 0xE2, 0x00, 0x00, 0x08, 0x63, 0x30,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0xD4, 0x23, 0x83, 0x8C,
+0xFF, 0xEF, 0x02, 0x24, 0x24, 0x10, 0xE2, 0x00, 0x00, 0x10, 0x63, 0x30,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0x60, 0x1B, 0xC5, 0x25,
+0x21, 0x30, 0xC5, 0x00, 0xD4, 0x23, 0xC4, 0x8C, 0xFD, 0xFF, 0x02, 0x3C,
+0x02, 0x00, 0x03, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x83, 0x00,
+0x24, 0x10, 0xE2, 0x00, 0x25, 0x38, 0x44, 0x00, 0x10, 0x00, 0x47, 0xAD,
+0xB0, 0x1B, 0xA3, 0x94, 0xFB, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0xC2, 0x1B, 0x03, 0x00, 0x24, 0x10, 0xE2, 0x00, 0x80, 0x1C, 0x03, 0x00,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0x3B, 0x41, 0xA3, 0x90,
+0xE7, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x03, 0x00, 0x63, 0x30,
+0x24, 0x10, 0xE2, 0x00, 0xC0, 0x1C, 0x03, 0x00, 0x25, 0x38, 0x43, 0x00,
+0x10, 0x00, 0x47, 0xAD, 0xD4, 0x23, 0xC4, 0x8C, 0xFF, 0xFD, 0x02, 0x3C,
+0x00, 0x02, 0x03, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x83, 0x00,
+0x24, 0x10, 0xE2, 0x00, 0x25, 0x38, 0x44, 0x00, 0x10, 0x00, 0x47, 0xAD,
+0xB0, 0x1B, 0xA3, 0x94, 0xFF, 0xFB, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0xC2, 0x1B, 0x03, 0x00, 0x24, 0x10, 0xE2, 0x00, 0x80, 0x1E, 0x03, 0x00,
+0x25, 0x38, 0x43, 0x00, 0x10, 0x00, 0x47, 0xAD, 0x3B, 0x41, 0xA3, 0x90,
+0xFF, 0xE7, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x03, 0x00, 0x63, 0x30,
+0x24, 0x10, 0xE2, 0x00, 0xC0, 0x1E, 0x03, 0x00, 0x25, 0x38, 0x43, 0x00,
+0x10, 0x00, 0x47, 0xAD, 0xD4, 0x23, 0xC3, 0x8C, 0xC0, 0xFF, 0x02, 0x24,
+0x24, 0x10, 0xE2, 0x00, 0x3F, 0x00, 0x63, 0x30, 0x25, 0x10, 0x43, 0x00,
+0x10, 0x00, 0x42, 0xAD, 0xD8, 0x23, 0xC4, 0x8C, 0x14, 0x00, 0x43, 0x8D,
+0xFF, 0xFF, 0x02, 0x3C, 0xFF, 0x7F, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x80, 0x84, 0x30, 0x25, 0x18, 0x64, 0x00, 0x14, 0x00, 0x43, 0xAD,
+0xDA, 0x23, 0xC4, 0x94, 0xE0, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x1F, 0x00, 0x84, 0x30, 0x24, 0x18, 0x62, 0x00, 0x00, 0x24, 0x04, 0x00,
+0x25, 0x18, 0x64, 0x00, 0x14, 0x00, 0x43, 0xAD, 0x02, 0x00, 0x43, 0x91,
+0x02, 0x14, 0x0D, 0x00, 0x01, 0x00, 0x42, 0x30, 0x27, 0x00, 0x40, 0x10,
+0x21, 0x30, 0x6F, 0x00, 0x60, 0x1B, 0xC4, 0x25, 0xE4, 0x1D, 0x85, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xA2, 0x24, 0xE4, 0x1D, 0x82, 0xA4,
+0x0C, 0x00, 0x43, 0x8D, 0x00, 0xF0, 0x02, 0x3C, 0xFF, 0x0F, 0xA5, 0x30,
+0xFF, 0xFF, 0x42, 0x34, 0x00, 0x24, 0x05, 0x00, 0x24, 0x18, 0x62, 0x00,
+0x25, 0x58, 0x83, 0x00, 0x0C, 0x00, 0x4B, 0xAD, 0x16, 0x00, 0xC2, 0x94,
+0x00, 0x19, 0x05, 0x00, 0x60, 0x1B, 0xC4, 0x25, 0x0F, 0x00, 0x42, 0x30,
+0x25, 0x10, 0x43, 0x00, 0x16, 0x00, 0xC2, 0xA4, 0x00, 0x00, 0x43, 0x95,
+0x40, 0x41, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x43, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x40, 0x41, 0x82, 0xAC, 0x14, 0x00, 0x42, 0x8D,
+0x00, 0x00, 0x00, 0x00, 0x42, 0x12, 0x02, 0x00, 0x3F, 0x00, 0x42, 0x30,
+0x0C, 0x00, 0x42, 0x28, 0x44, 0xFF, 0x40, 0x10, 0xFF, 0xDF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x40, 0x02, 0x01, 0x00, 0x40, 0x03, 0x3C,
+0x25, 0x40, 0x03, 0x01, 0xE3, 0x01, 0x00, 0x08, 0x02, 0x80, 0x0E, 0x3C,
+0x60, 0x1B, 0xC3, 0x25, 0xC6, 0x3D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x1D, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xC2, 0x13, 0x0B, 0x00,
+0x0E, 0x00, 0x42, 0x30, 0x21, 0x10, 0x43, 0x00, 0xD4, 0x1D, 0x45, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xA3, 0x24, 0xD4, 0x1D, 0x43, 0xA4,
+0x0C, 0x00, 0x44, 0x8D, 0x00, 0xF0, 0x02, 0x3C, 0xFF, 0x0F, 0xA5, 0x30,
+0xFF, 0xFF, 0x42, 0x34, 0x00, 0x1C, 0x05, 0x00, 0x77, 0x02, 0x00, 0x08,
+0x24, 0x20, 0x82, 0x00, 0x7F, 0xFF, 0x02, 0x24, 0x24, 0x10, 0x02, 0x01,
+0x80, 0x00, 0x63, 0x30, 0x25, 0x40, 0x43, 0x00, 0x08, 0x00, 0x48, 0xAD,
+0x08, 0x25, 0xA3, 0x8C, 0xFF, 0xFF, 0x02, 0x3C, 0xFF, 0x1F, 0x42, 0x34,
+0x07, 0x00, 0x63, 0x30, 0x24, 0x10, 0xE2, 0x00, 0x40, 0x1B, 0x03, 0x00,
+0x25, 0x38, 0x43, 0x00, 0xF1, 0x01, 0x00, 0x08, 0x10, 0x00, 0x47, 0xAD,
+0x02, 0x14, 0x0B, 0x00, 0xFF, 0x0F, 0x45, 0x30, 0x16, 0x00, 0xC2, 0x94,
+0x00, 0x19, 0x05, 0x00, 0x60, 0x1B, 0xC4, 0x25, 0x0F, 0x00, 0x42, 0x30,
+0x25, 0x10, 0x43, 0x00, 0x16, 0x00, 0xC2, 0xA4, 0x00, 0x00, 0x43, 0x95,
+0x40, 0x41, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x43, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x40, 0x41, 0x82, 0xAC, 0xCE, 0x5C, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x4E, 0xFF, 0x64, 0x14, 0x60, 0x1B, 0xC4, 0x25,
+0x3C, 0x41, 0x22, 0x91, 0xFF, 0xF7, 0x03, 0x24, 0x24, 0x18, 0xE3, 0x00,
+0x01, 0x00, 0x42, 0x30, 0xC0, 0x12, 0x02, 0x00, 0x25, 0x38, 0x62, 0x00,
+0x10, 0x00, 0x47, 0xAD, 0x3D, 0x41, 0x22, 0x91, 0xFF, 0xEF, 0x03, 0x24,
+0x24, 0x18, 0xE3, 0x00, 0x01, 0x00, 0x42, 0x30, 0x00, 0x13, 0x02, 0x00,
+0x25, 0x38, 0x43, 0x00, 0x1F, 0x02, 0x00, 0x08, 0x10, 0x00, 0x47, 0xAD,
+0xD8, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xB2, 0xAF, 0x18, 0x00, 0xB0, 0xAF,
+0x24, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB1, 0xAF, 0x04, 0x00, 0x8B, 0x8C,
+0x21, 0x80, 0x80, 0x00, 0x08, 0x00, 0x84, 0x8C, 0x0E, 0x00, 0x07, 0x96,
+0xFF, 0xE0, 0x02, 0x3C, 0x10, 0x00, 0x08, 0x8E, 0x1F, 0x00, 0x6A, 0x31,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x82, 0x00, 0x00, 0x1E, 0x0A, 0x00,
+0x25, 0x48, 0x83, 0x00, 0x21, 0x90, 0xA0, 0x00, 0x21, 0x60, 0xC0, 0x00,
+0xCF, 0x00, 0x00, 0x05, 0x07, 0x00, 0xE7, 0x30, 0x00, 0x00, 0x02, 0x96,
+0x00, 0x00, 0x00, 0x00, 0xFD, 0x0F, 0x42, 0x28, 0xD1, 0x00, 0x40, 0x10,
+0xFF, 0xDF, 0x02, 0x3C, 0x02, 0x80, 0x11, 0x3C, 0x08, 0x00, 0x09, 0xAE,
+0x60, 0x1B, 0x23, 0x26, 0xC6, 0x3D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x40, 0x62, 0x90,
+0xFF, 0xDF, 0x03, 0x3C, 0xFF, 0xFF, 0x63, 0x34, 0x07, 0x10, 0xE2, 0x00,
+0x01, 0x00, 0x42, 0x30, 0x24, 0x18, 0x23, 0x01, 0x40, 0x17, 0x02, 0x00,
+0x25, 0x48, 0x62, 0x00, 0x08, 0x00, 0x09, 0xAE, 0x1C, 0x00, 0x02, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x40, 0x04, 0x04, 0x00, 0x03, 0x24,
+0xC0, 0x30, 0x0A, 0x00, 0x21, 0x10, 0xCA, 0x00, 0x80, 0x10, 0x02, 0x00,
+0x21, 0x10, 0x4A, 0x00, 0x80, 0x10, 0x02, 0x00, 0x60, 0x1B, 0x27, 0x26,
+0x21, 0x28, 0x47, 0x00, 0x08, 0x25, 0xA3, 0x8C, 0x01, 0x00, 0x0A, 0x24,
+0x02, 0x13, 0x03, 0x00, 0x01, 0x00, 0x42, 0x30, 0xE7, 0x00, 0x4A, 0x10,
+0x42, 0x18, 0x03, 0x00, 0x82, 0x11, 0x09, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0xC0, 0xFF, 0x02, 0x24,
+0x24, 0x10, 0x22, 0x01, 0x04, 0x00, 0x49, 0x34, 0x08, 0x00, 0x09, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0xD1, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x6C, 0x00, 0x60, 0x14, 0x21, 0x28, 0xC7, 0x00, 0xD4, 0x23, 0xA4, 0x8C,
+0x10, 0x00, 0x02, 0x8E, 0xBF, 0xFF, 0x03, 0x24, 0x40, 0x00, 0x84, 0x30,
+0x24, 0x10, 0x43, 0x00, 0x25, 0x40, 0x44, 0x00, 0x10, 0x00, 0x08, 0xAE,
+0xD4, 0x23, 0xA3, 0x8C, 0x7F, 0xF8, 0x02, 0x24, 0x24, 0x10, 0x02, 0x01,
+0x80, 0x07, 0x63, 0x30, 0x25, 0x40, 0x43, 0x00, 0x10, 0x00, 0x08, 0xAE,
+0xC6, 0x3D, 0xE2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x40, 0x14,
+0x60, 0x1B, 0x25, 0x26, 0x42, 0x17, 0x09, 0x00, 0x01, 0x00, 0x44, 0x30,
+0x08, 0x01, 0x8A, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x24, 0x26,
+0x21, 0x20, 0xC4, 0x00, 0xD4, 0x23, 0x83, 0x8C, 0xFF, 0xF7, 0x02, 0x24,
+0x24, 0x10, 0x02, 0x01, 0x00, 0x08, 0x63, 0x30, 0x25, 0x40, 0x43, 0x00,
+0x10, 0x00, 0x08, 0xAE, 0xD4, 0x23, 0x83, 0x8C, 0xFF, 0xEF, 0x02, 0x24,
+0x24, 0x10, 0x02, 0x01, 0x00, 0x10, 0x63, 0x30, 0x25, 0x40, 0x43, 0x00,
+0x10, 0x00, 0x08, 0xAE, 0x60, 0x1B, 0x25, 0x26, 0x21, 0x30, 0xC5, 0x00,
+0xD4, 0x23, 0xC4, 0x8C, 0xFD, 0xFF, 0x02, 0x3C, 0x02, 0x00, 0x03, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x83, 0x00, 0x24, 0x10, 0x02, 0x01,
+0x25, 0x40, 0x44, 0x00, 0x10, 0x00, 0x08, 0xAE, 0xB0, 0x1B, 0xA3, 0x94,
+0xFB, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0xC2, 0x1B, 0x03, 0x00,
+0x24, 0x10, 0x02, 0x01, 0x80, 0x1C, 0x03, 0x00, 0x25, 0x40, 0x43, 0x00,
+0x10, 0x00, 0x08, 0xAE, 0x3B, 0x41, 0xA3, 0x90, 0xE7, 0xFF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x03, 0x00, 0x63, 0x30, 0x24, 0x10, 0x02, 0x01,
+0xC0, 0x1C, 0x03, 0x00, 0x25, 0x40, 0x43, 0x00, 0x10, 0x00, 0x08, 0xAE,
+0xD4, 0x23, 0xC4, 0x8C, 0xFF, 0xFD, 0x02, 0x3C, 0x00, 0x02, 0x03, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x83, 0x00, 0x24, 0x10, 0x02, 0x01,
+0x25, 0x40, 0x44, 0x00, 0x10, 0x00, 0x08, 0xAE, 0xB0, 0x1B, 0xA3, 0x94,
+0xFF, 0xFB, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0xC2, 0x1B, 0x03, 0x00,
+0x24, 0x10, 0x02, 0x01, 0x80, 0x1E, 0x03, 0x00, 0x25, 0x40, 0x43, 0x00,
+0x10, 0x00, 0x08, 0xAE, 0x3B, 0x41, 0xA3, 0x90, 0xFF, 0xE7, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x03, 0x00, 0x63, 0x30, 0x24, 0x10, 0x02, 0x01,
+0xC0, 0x1E, 0x03, 0x00, 0x25, 0x40, 0x43, 0x00, 0x10, 0x00, 0x08, 0xAE,
+0xD4, 0x23, 0xC3, 0x8C, 0xC0, 0xFF, 0x02, 0x24, 0x24, 0x10, 0x02, 0x01,
+0x3F, 0x00, 0x63, 0x30, 0x25, 0x10, 0x43, 0x00, 0x10, 0x00, 0x02, 0xAE,
+0xD8, 0x23, 0xC4, 0x8C, 0x14, 0x00, 0x03, 0x8E, 0xFF, 0xFF, 0x02, 0x3C,
+0xFF, 0x7F, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00, 0x00, 0x80, 0x84, 0x30,
+0x25, 0x18, 0x64, 0x00, 0x14, 0x00, 0x03, 0xAE, 0xDA, 0x23, 0xC4, 0x94,
+0xE0, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x1F, 0x00, 0x84, 0x30,
+0x24, 0x18, 0x62, 0x00, 0x00, 0x24, 0x04, 0x00, 0x25, 0x18, 0x64, 0x00,
+0x14, 0x00, 0x03, 0xAE, 0x02, 0x00, 0x02, 0x92, 0x02, 0x24, 0x0B, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x21, 0x10, 0x4C, 0x00, 0xFF, 0xFF, 0x42, 0x30,
+0x01, 0x00, 0x84, 0x30, 0x36, 0x00, 0x80, 0x10, 0x25, 0x30, 0x43, 0x00,
+0x60, 0x1B, 0x24, 0x26, 0xE4, 0x1D, 0x85, 0x94, 0x80, 0x00, 0x07, 0x24,
+0x01, 0x00, 0xA2, 0x24, 0xE4, 0x1D, 0x82, 0xA4, 0x0C, 0x00, 0x03, 0x8E,
+0x00, 0xF0, 0x02, 0x3C, 0xFF, 0x0F, 0xA5, 0x30, 0xFF, 0xFF, 0x42, 0x34,
+0x00, 0x24, 0x05, 0x00, 0x24, 0x18, 0x62, 0x00, 0x25, 0x18, 0x64, 0x00,
+0x0C, 0x00, 0x03, 0xAE, 0x16, 0x00, 0xC2, 0x94, 0x00, 0x19, 0x05, 0x00,
+0x02, 0x00, 0x04, 0x24, 0x0F, 0x00, 0x42, 0x30, 0x25, 0x10, 0x43, 0x00,
+0x16, 0x00, 0xC2, 0xA4, 0x21, 0x28, 0x80, 0x01, 0x21, 0x30, 0x40, 0x02,
+0x01, 0x00, 0x02, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x52, 0xAC,
+0x5B, 0x01, 0x00, 0x0C, 0x02, 0x00, 0x04, 0x24, 0x60, 0x1B, 0x24, 0x26,
+0x00, 0x00, 0x03, 0x96, 0x40, 0x41, 0x82, 0x8C, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x43, 0x00, 0x28, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03,
+0x40, 0x41, 0x82, 0xAC, 0x14, 0x00, 0x02, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x42, 0x12, 0x02, 0x00, 0x3F, 0x00, 0x42, 0x30, 0x0C, 0x00, 0x42, 0x28,
+0x2C, 0xFF, 0x40, 0x10, 0xFF, 0xDF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x48, 0x22, 0x01, 0x00, 0x40, 0x03, 0x3C, 0x25, 0x48, 0x23, 0x01,
+0xFC, 0x02, 0x00, 0x08, 0x02, 0x80, 0x11, 0x3C, 0x60, 0x1B, 0x23, 0x26,
+0xC6, 0x3D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x40, 0x14,
+0x80, 0x00, 0x07, 0x24, 0x0E, 0x00, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x42, 0x30, 0x40, 0x10, 0x02, 0x00, 0x21, 0x10, 0x43, 0x00,
+0xD4, 0x1D, 0x45, 0x94, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xA3, 0x24,
+0xD4, 0x1D, 0x43, 0xA4, 0x0C, 0x00, 0x04, 0x8E, 0x00, 0xF0, 0x02, 0x3C,
+0xFF, 0x0F, 0xA5, 0x30, 0xFF, 0xFF, 0x42, 0x34, 0x00, 0x1C, 0x05, 0x00,
+0x24, 0x20, 0x82, 0x00, 0x25, 0x20, 0x83, 0x00, 0x0C, 0x00, 0x04, 0xAE,
+0x16, 0x00, 0xC2, 0x94, 0x00, 0x19, 0x05, 0x00, 0x02, 0x00, 0x04, 0x24,
+0x0F, 0x00, 0x42, 0x30, 0x25, 0x10, 0x43, 0x00, 0x16, 0x00, 0xC2, 0xA4,
+0x21, 0x28, 0x80, 0x01, 0x21, 0x30, 0x40, 0x02, 0x01, 0x00, 0x02, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x52, 0xAC, 0x5B, 0x01, 0x00, 0x0C,
+0x02, 0x00, 0x04, 0x24, 0x60, 0x1B, 0x24, 0x26, 0x00, 0x00, 0x03, 0x96,
+0x40, 0x41, 0x82, 0x8C, 0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x43, 0x00,
+0x28, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03, 0x40, 0x41, 0x82, 0xAC,
+0x7F, 0xFF, 0x02, 0x24, 0x24, 0x10, 0x22, 0x01, 0x80, 0x00, 0x63, 0x30,
+0x25, 0x48, 0x43, 0x00, 0x08, 0x00, 0x09, 0xAE, 0x08, 0x25, 0xA3, 0x8C,
+0x10, 0x00, 0x04, 0x8E, 0xFF, 0xFF, 0x02, 0x3C, 0x07, 0x00, 0x63, 0x30,
+0xFF, 0x1F, 0x42, 0x34, 0x24, 0x20, 0x82, 0x00, 0x40, 0x1B, 0x03, 0x00,
+0x25, 0x40, 0x83, 0x00, 0x0E, 0x03, 0x00, 0x08, 0x10, 0x00, 0x08, 0xAE,
+0x1E, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x21, 0x30, 0x50, 0x00,
+0x00, 0x00, 0xC4, 0x90, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x82, 0x30,
+0x02, 0x29, 0x02, 0x00, 0x3F, 0x00, 0xA3, 0x10, 0x06, 0x00, 0x02, 0x24,
+0xF4, 0xFE, 0xA2, 0x14, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x02, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x39, 0x00, 0xC2, 0xA0, 0x1E, 0x00, 0x03, 0x92,
+0x1A, 0x00, 0x02, 0x96, 0x21, 0x18, 0x70, 0x00, 0x03, 0x12, 0x02, 0x00,
+0x38, 0x00, 0x62, 0xA0, 0x04, 0x00, 0x0B, 0x8E, 0x08, 0x00, 0x09, 0x8E,
+0x02, 0x03, 0x00, 0x08, 0xC0, 0x30, 0x0A, 0x00, 0x0E, 0x00, 0x02, 0x96,
+0x02, 0x00, 0x04, 0x24, 0xFF, 0x0F, 0x45, 0x30, 0x16, 0x00, 0xC2, 0x94,
+0x00, 0x19, 0x05, 0x00, 0x21, 0x28, 0x80, 0x01, 0x0F, 0x00, 0x42, 0x30,
+0x25, 0x10, 0x43, 0x00, 0x16, 0x00, 0xC2, 0xA4, 0x21, 0x30, 0x40, 0x02,
+0x01, 0x00, 0x02, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x52, 0xAC,
+0x5B, 0x01, 0x00, 0x0C, 0x02, 0x00, 0x04, 0x24, 0x60, 0x1B, 0x24, 0x26,
+0x00, 0x00, 0x03, 0x96, 0x40, 0x41, 0x82, 0x8C, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x43, 0x00, 0x28, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03,
+0x40, 0x41, 0x82, 0xAC, 0xCE, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xF7, 0xFE, 0x64, 0x14, 0x60, 0x1B, 0x24, 0x26, 0x3C, 0x41, 0xE2, 0x90,
+0xFF, 0xF7, 0x03, 0x24, 0x24, 0x18, 0x03, 0x01, 0x01, 0x00, 0x42, 0x30,
+0xC0, 0x12, 0x02, 0x00, 0x25, 0x40, 0x62, 0x00, 0x10, 0x00, 0x08, 0xAE,
+0x3D, 0x41, 0xE2, 0x90, 0xFF, 0xEF, 0x03, 0x24, 0x24, 0x18, 0x03, 0x01,
+0x01, 0x00, 0x42, 0x30, 0x00, 0x13, 0x02, 0x00, 0x25, 0x40, 0x43, 0x00,
+0x3E, 0x03, 0x00, 0x08, 0x10, 0x00, 0x08, 0xAE, 0x1A, 0x00, 0x05, 0x96,
+0x0F, 0x00, 0x84, 0x30, 0x80, 0x20, 0x04, 0x00, 0x21, 0x18, 0xC4, 0x00,
+0x11, 0x00, 0x65, 0xA0, 0x1E, 0x00, 0x02, 0x92, 0x1A, 0x00, 0x03, 0x96,
+0x21, 0x10, 0x50, 0x00, 0x21, 0x10, 0x44, 0x00, 0x03, 0x1A, 0x03, 0x00,
+0x10, 0x00, 0x43, 0xA0, 0x04, 0x00, 0x0B, 0x8E, 0x08, 0x00, 0x09, 0x8E,
+0x02, 0x03, 0x00, 0x08, 0xC0, 0x30, 0x0A, 0x00, 0x00, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x64, 0x11, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xC0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x2C, 0x00, 0xB5, 0xAF,
+0x25, 0xB0, 0x03, 0x3C, 0x60, 0x1B, 0x55, 0x24, 0x00, 0x80, 0x02, 0x3C,
+0x38, 0x00, 0xBE, 0xAF, 0x80, 0x11, 0x42, 0x24, 0xB0, 0x03, 0x7E, 0x34,
+0x18, 0x03, 0x63, 0x34, 0x00, 0x00, 0x62, 0xAC, 0x3C, 0x00, 0xBF, 0xAF,
+0x34, 0x00, 0xB7, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x28, 0x00, 0xB4, 0xAF,
+0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x96, 0x40, 0x00, 0x0C, 0x18, 0x00, 0xB0, 0xAF, 0x8E, 0x04, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0xAE, 0x08, 0x38, 0x46, 0x8E,
+0x21, 0x28, 0x60, 0x02, 0x80, 0x00, 0x07, 0x24, 0x01, 0x00, 0x04, 0x24,
+0x01, 0x00, 0x14, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xB4, 0xAF,
+0x08, 0x38, 0x43, 0x8E, 0x01, 0x00, 0x04, 0x24, 0x00, 0x00, 0xC3, 0xAE,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x1C, 0x42, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x40, 0x10, 0x2A, 0xB0, 0x02, 0x3C,
+0x09, 0x00, 0x42, 0x34, 0x02, 0x00, 0x03, 0x24, 0x00, 0x00, 0x54, 0xA0,
+0x00, 0x00, 0x43, 0xA0, 0xFF, 0x00, 0x03, 0x24, 0x71, 0x00, 0x23, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x38, 0xA2, 0x8E, 0x70, 0x38, 0xB3, 0x8E,
+0x01, 0x00, 0x04, 0x24, 0x00, 0x00, 0xC2, 0xAF, 0x08, 0x38, 0xA2, 0xAE,
+0x00, 0x00, 0xD3, 0xAF, 0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x70, 0x38, 0xA4, 0x8E, 0x74, 0x38, 0xA3, 0x8E, 0x02, 0x80, 0x02, 0x3C,
+0xB4, 0xE6, 0x42, 0x24, 0x00, 0x00, 0x52, 0x8C, 0x80, 0x00, 0x84, 0x24,
+0xFF, 0x00, 0x62, 0x24, 0x2B, 0x10, 0x44, 0x00, 0x0A, 0x18, 0x82, 0x00,
+0x70, 0x38, 0xA3, 0xAE, 0x02, 0x80, 0x03, 0x3C, 0xB8, 0xE6, 0x63, 0x24,
+0x70, 0x38, 0x42, 0x8E, 0x00, 0x00, 0x76, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC2, 0xAE, 0x02, 0x80, 0x17, 0x3C, 0xFF, 0xFF, 0x62, 0x32,
+0x25, 0x80, 0x57, 0x00, 0x00, 0x00, 0xD0, 0xAE, 0x0C, 0x00, 0x02, 0x92,
+0x21, 0x28, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xAE, 0x02, 0x00, 0x04, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x93, 0x00, 0xFF, 0xFF, 0x84, 0x30,
+0xE0, 0x61, 0x00, 0x0C, 0x25, 0x20, 0x97, 0x00, 0x0C, 0x00, 0x11, 0x92,
+0x20, 0x10, 0x02, 0x3C, 0x01, 0x00, 0x04, 0x24, 0x00, 0x1A, 0x11, 0x00,
+0x21, 0x18, 0x62, 0x00, 0xFF, 0x00, 0x02, 0x24, 0x21, 0x30, 0x60, 0x00,
+0x06, 0x00, 0x22, 0x12, 0x80, 0x00, 0x07, 0x24, 0x70, 0x38, 0x45, 0x8E,
+0x04, 0x38, 0x43, 0xAE, 0xA8, 0x37, 0x51, 0xA2, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x04, 0x00, 0x04, 0x8E, 0x08, 0x00, 0x03, 0x8E,
+0xFF, 0xE0, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x1F, 0x00, 0x84, 0x30,
+0x24, 0x18, 0x62, 0x00, 0x00, 0x26, 0x04, 0x00, 0xFF, 0xDF, 0x02, 0x3C,
+0x25, 0x18, 0x64, 0x00, 0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x40, 0x04, 0x3C, 0x25, 0x18, 0x64, 0x00, 0xC0, 0xFF, 0x05, 0x24,
+0x82, 0x11, 0x03, 0x00, 0x24, 0x20, 0x65, 0x00, 0x01, 0x00, 0x42, 0x30,
+0xA3, 0xFF, 0x40, 0x10, 0x04, 0x00, 0x84, 0x34, 0x08, 0x00, 0x03, 0xAE,
+0x08, 0x38, 0x46, 0x8E, 0x21, 0x28, 0x60, 0x02, 0x80, 0x00, 0x07, 0x24,
+0x01, 0x00, 0x04, 0x24, 0x01, 0x00, 0x14, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xB4, 0xAF, 0x08, 0x38, 0x43, 0x8E, 0x01, 0x00, 0x04, 0x24,
+0x00, 0x00, 0xC3, 0xAE, 0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x2A, 0x1C, 0x42, 0x92, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xFF, 0x40, 0x14,
+0x2A, 0xB0, 0x02, 0x3C, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x2A, 0x1C, 0x54, 0xA2, 0x02, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0x53, 0x00, 0xFF, 0xFF, 0x42, 0x30, 0x25, 0x10, 0x57, 0x00,
+0x02, 0x00, 0x43, 0x94, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x64, 0x30,
+0x00, 0xC0, 0x84, 0x24, 0x2B, 0x1C, 0x43, 0xA2, 0xA3, 0x31, 0x00, 0x0C,
+0xFF, 0xFF, 0x84, 0x30, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x2A, 0xB0, 0x02, 0x3C, 0x09, 0x00, 0x42, 0x34, 0x02, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x54, 0xA0, 0x00, 0x00, 0x43, 0xA0, 0xFF, 0x00, 0x03, 0x24,
+0x91, 0xFF, 0x23, 0x16, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x62, 0x24,
+0xD0, 0x1B, 0x43, 0x8C, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F,
+0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x00, 0x38, 0x63, 0x34,
+0x41, 0xB0, 0x04, 0x3C, 0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x83, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0x43, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x4C, 0x14, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xC0, 0xFF, 0xBD, 0x27, 0x34, 0x00, 0xB7, 0xAF, 0x3C, 0x00, 0xBF, 0xAF,
+0x38, 0x00, 0xBE, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x06, 0x3C,
+0xC0, 0x5D, 0xC5, 0x90, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x18, 0x03, 0x42, 0x34, 0x68, 0x14, 0x63, 0x24, 0x40, 0x00, 0xA4, 0x30,
+0x00, 0x00, 0x43, 0xAC, 0x21, 0xB8, 0x00, 0x00, 0x03, 0x00, 0x80, 0x10,
+0x7F, 0x00, 0xA2, 0x30, 0xBF, 0x00, 0xA2, 0x30, 0x01, 0x00, 0x17, 0x24,
+0xC0, 0x5D, 0xC2, 0xA0, 0x96, 0x40, 0x00, 0x0C, 0x02, 0x80, 0x1E, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x60, 0x1B, 0xD3, 0x27, 0xB0, 0x03, 0x55, 0x34,
+0x59, 0x05, 0x00, 0x08, 0x02, 0x80, 0x16, 0x3C, 0x84, 0x37, 0x91, 0xA2,
+0x60, 0x1B, 0xC2, 0x27, 0xBC, 0x37, 0x46, 0x8C, 0x28, 0x38, 0x45, 0x8C,
+0x03, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x60, 0x1B, 0xD4, 0x27, 0xC0, 0x37, 0x85, 0x8E,
+0x21, 0x20, 0x00, 0x02, 0xD4, 0x02, 0x00, 0x0C, 0x21, 0x30, 0x40, 0x02,
+0x2A, 0xB0, 0x07, 0x3C, 0x0D, 0x00, 0xE2, 0x34, 0x04, 0x00, 0x43, 0x24,
+0x0B, 0x10, 0x77, 0x00, 0x01, 0x00, 0x04, 0x24, 0x02, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x44, 0xA0, 0x00, 0x00, 0x43, 0xA0, 0x0C, 0x5D, 0xC4, 0x96,
+0x25, 0xB0, 0x06, 0x3C, 0x66, 0x03, 0xC5, 0x34, 0x01, 0x00, 0x84, 0x24,
+0x0C, 0x5D, 0xC4, 0xA6, 0x0C, 0x5D, 0xC2, 0x96, 0xFF, 0x00, 0x03, 0x24,
+0x00, 0x00, 0xA2, 0xA4, 0x2F, 0x00, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00,
+0xBC, 0x37, 0x62, 0x8E, 0x28, 0x38, 0x72, 0x8E, 0x03, 0x00, 0x04, 0x24,
+0x00, 0x00, 0xA2, 0xAE, 0xC0, 0x37, 0x62, 0xAE, 0x00, 0x00, 0xB2, 0xAE,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x28, 0x38, 0x64, 0x8E,
+0x2C, 0x38, 0x63, 0x8E, 0x02, 0x80, 0x02, 0x3C, 0xBC, 0xE6, 0x42, 0x24,
+0x00, 0x00, 0x54, 0x8C, 0x80, 0x00, 0x84, 0x24, 0xFF, 0x00, 0x62, 0x24,
+0x2B, 0x10, 0x44, 0x00, 0x0A, 0x18, 0x82, 0x00, 0x28, 0x38, 0x63, 0xAE,
+0x28, 0x38, 0x82, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xAE,
+0x02, 0x80, 0x03, 0x3C, 0xFF, 0xFF, 0x42, 0x32, 0x25, 0x80, 0x43, 0x00,
+0x00, 0x00, 0xB0, 0xAE, 0x0C, 0x00, 0x02, 0x92, 0x01, 0x00, 0x05, 0x24,
+0x00, 0x00, 0xA2, 0xAE, 0x02, 0x00, 0x04, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x20, 0x92, 0x00, 0xFF, 0xFF, 0x84, 0x30, 0xE0, 0x61, 0x00, 0x0C,
+0x25, 0x20, 0x83, 0x00, 0x0C, 0x00, 0x11, 0x92, 0x20, 0x10, 0x02, 0x3C,
+0xFF, 0x00, 0x03, 0x24, 0x00, 0x22, 0x11, 0x00, 0xC2, 0xFF, 0x23, 0x12,
+0x21, 0x20, 0x82, 0x00, 0xB8, 0xFF, 0xE0, 0x16, 0xBC, 0x37, 0x84, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x3B, 0x05, 0x00, 0x08,
+0x80, 0x37, 0x51, 0xA0, 0x1E, 0x00, 0xE0, 0x12, 0x40, 0x00, 0xE4, 0x34,
+0x84, 0x37, 0x83, 0x92, 0x41, 0x00, 0xE4, 0x34, 0xB0, 0x03, 0xC5, 0x34,
+0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC, 0x96, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA4, 0x8C, 0x01, 0x00, 0x02, 0x3C,
+0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x00, 0x80, 0x42, 0x34, 0x25, 0x20, 0x82, 0x00,
+0x41, 0xB0, 0x03, 0x3C, 0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x64, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA4, 0xAC, 0x80, 0x37, 0x83, 0x92,
+0xB0, 0x03, 0xC5, 0x34, 0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC,
+0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA4, 0x8C,
+0x01, 0x00, 0x02, 0x3C, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F,
+0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x00, 0x80, 0x42, 0x34,
+0x25, 0x20, 0x82, 0x00, 0x41, 0xB0, 0x03, 0x3C, 0x40, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0x64, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA4, 0xAC,
+0xC0, 0xFF, 0xBD, 0x27, 0x34, 0x00, 0xB7, 0xAF, 0x3C, 0x00, 0xBF, 0xAF,
+0x38, 0x00, 0xBE, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x06, 0x3C,
+0xC0, 0x5D, 0xC5, 0x90, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x18, 0x03, 0x42, 0x34, 0x08, 0x17, 0x63, 0x24, 0x10, 0x00, 0xA4, 0x30,
+0x00, 0x00, 0x43, 0xAC, 0x21, 0xB8, 0x00, 0x00, 0x03, 0x00, 0x80, 0x10,
+0xDF, 0x00, 0xA2, 0x30, 0xEF, 0x00, 0xA2, 0x30, 0x01, 0x00, 0x17, 0x24,
+0xC0, 0x5D, 0xC2, 0xA0, 0xC0, 0x5D, 0xC3, 0x90, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x02, 0x80, 0x1E, 0x3C,
+0x00, 0x00, 0x43, 0xAC, 0x21, 0xA8, 0x40, 0x00, 0x96, 0x40, 0x00, 0x0C,
+0x60, 0x1B, 0xD3, 0x27, 0x05, 0x06, 0x00, 0x08, 0x02, 0x80, 0x16, 0x3C,
+0x8C, 0x37, 0x91, 0xA2, 0x60, 0x1B, 0xC2, 0x27, 0xC8, 0x37, 0x46, 0x8C,
+0x34, 0x38, 0x45, 0x8C, 0x04, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x60, 0x1B, 0xD4, 0x27,
+0xCC, 0x37, 0x85, 0x8E, 0x21, 0x20, 0x00, 0x02, 0xD4, 0x02, 0x00, 0x0C,
+0x21, 0x30, 0x40, 0x02, 0x2A, 0xB0, 0x07, 0x3C, 0x15, 0x00, 0xE2, 0x34,
+0x04, 0x00, 0x43, 0x24, 0x0B, 0x10, 0x77, 0x00, 0x01, 0x00, 0x04, 0x24,
+0x02, 0x00, 0x03, 0x24, 0x00, 0x00, 0x44, 0xA0, 0x00, 0x00, 0x43, 0xA0,
+0x0C, 0x5D, 0xC4, 0x96, 0x25, 0xB0, 0x06, 0x3C, 0x66, 0x03, 0xC5, 0x34,
+0x01, 0x00, 0x84, 0x24, 0x0C, 0x5D, 0xC4, 0xA6, 0x0C, 0x5D, 0xC2, 0x96,
+0xFF, 0x00, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xA4, 0x2F, 0x00, 0x23, 0x12,
+0x00, 0x00, 0x00, 0x00, 0xC8, 0x37, 0x62, 0x8E, 0x34, 0x38, 0x72, 0x8E,
+0x04, 0x00, 0x04, 0x24, 0x00, 0x00, 0xA2, 0xAE, 0xCC, 0x37, 0x62, 0xAE,
+0x00, 0x00, 0xB2, 0xAE, 0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x34, 0x38, 0x64, 0x8E, 0x38, 0x38, 0x63, 0x8E, 0x02, 0x80, 0x02, 0x3C,
+0xC0, 0xE6, 0x42, 0x24, 0x00, 0x00, 0x54, 0x8C, 0x80, 0x00, 0x84, 0x24,
+0xFF, 0x00, 0x62, 0x24, 0x2B, 0x10, 0x44, 0x00, 0x0A, 0x18, 0x82, 0x00,
+0x34, 0x38, 0x63, 0xAE, 0x34, 0x38, 0x82, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xA2, 0xAE, 0x02, 0x80, 0x03, 0x3C, 0xFF, 0xFF, 0x42, 0x32,
+0x25, 0x80, 0x43, 0x00, 0x00, 0x00, 0xB0, 0xAE, 0x0C, 0x00, 0x02, 0x92,
+0x02, 0x00, 0x05, 0x24, 0x00, 0x00, 0xA2, 0xAE, 0x02, 0x00, 0x04, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x92, 0x00, 0xFF, 0xFF, 0x84, 0x30,
+0xE0, 0x61, 0x00, 0x0C, 0x25, 0x20, 0x83, 0x00, 0x0C, 0x00, 0x11, 0x92,
+0x20, 0x10, 0x02, 0x3C, 0xFF, 0x00, 0x03, 0x24, 0x00, 0x22, 0x11, 0x00,
+0xC2, 0xFF, 0x23, 0x12, 0x21, 0x20, 0x82, 0x00, 0xB8, 0xFF, 0xE0, 0x16,
+0xC8, 0x37, 0x84, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0xE7, 0x05, 0x00, 0x08, 0x88, 0x37, 0x51, 0xA0, 0x1D, 0x00, 0xE0, 0x12,
+0x42, 0x00, 0xE4, 0x34, 0x8C, 0x37, 0x83, 0x92, 0x43, 0x00, 0xE4, 0x34,
+0xB0, 0x03, 0xC5, 0x34, 0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC,
+0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA2, 0x8C,
+0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x06, 0x00, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00,
+0x41, 0xB0, 0x04, 0x3C, 0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x82, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA2, 0xAC, 0x88, 0x37, 0x83, 0x92,
+0xB0, 0x03, 0xC5, 0x34, 0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC,
+0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA2, 0x8C,
+0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x06, 0x00, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00,
+0x41, 0xB0, 0x04, 0x3C, 0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x82, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA2, 0xAC, 0xC0, 0xFF, 0xBD, 0x27,
+0x34, 0x00, 0xB7, 0xAF, 0x3C, 0x00, 0xBF, 0xAF, 0x38, 0x00, 0xBE, 0xAF,
+0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF, 0x28, 0x00, 0xB4, 0xAF,
+0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x06, 0x3C, 0xC0, 0x5D, 0xC5, 0x90,
+0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C, 0x18, 0x03, 0x42, 0x34,
+0xB0, 0x19, 0x63, 0x24, 0x01, 0x00, 0xA4, 0x30, 0x00, 0x00, 0x43, 0xAC,
+0x21, 0xB8, 0x00, 0x00, 0x03, 0x00, 0x80, 0x10, 0xF7, 0x00, 0xA2, 0x30,
+0xFE, 0x00, 0xA2, 0x30, 0x01, 0x00, 0x17, 0x24, 0xC0, 0x5D, 0xC2, 0xA0,
+0xC0, 0x5D, 0xC3, 0x90, 0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34,
+0x02, 0x80, 0x1E, 0x3C, 0x00, 0x00, 0x43, 0xAC, 0x21, 0xA8, 0x40, 0x00,
+0x96, 0x40, 0x00, 0x0C, 0x60, 0x1B, 0xD3, 0x27, 0xAE, 0x06, 0x00, 0x08,
+0x02, 0x80, 0x16, 0x3C, 0x9C, 0x37, 0x91, 0xA2, 0x60, 0x1B, 0xC2, 0x27,
+0xD4, 0x37, 0x46, 0x8C, 0x40, 0x38, 0x45, 0x8C, 0x05, 0x00, 0x04, 0x24,
+0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF,
+0x60, 0x1B, 0xD4, 0x27, 0xD8, 0x37, 0x85, 0x8E, 0x21, 0x20, 0x00, 0x02,
+0xD4, 0x02, 0x00, 0x0C, 0x21, 0x30, 0x40, 0x02, 0x2A, 0xB0, 0x07, 0x3C,
+0x1D, 0x00, 0xE2, 0x34, 0x04, 0x00, 0x43, 0x24, 0x0B, 0x10, 0x77, 0x00,
+0x01, 0x00, 0x04, 0x24, 0x02, 0x00, 0x03, 0x24, 0x00, 0x00, 0x44, 0xA0,
+0x00, 0x00, 0x43, 0xA0, 0x0C, 0x5D, 0xC4, 0x96, 0x25, 0xB0, 0x06, 0x3C,
+0x66, 0x03, 0xC5, 0x34, 0x01, 0x00, 0x84, 0x24, 0x0C, 0x5D, 0xC4, 0xA6,
+0x0C, 0x5D, 0xC2, 0x96, 0xFF, 0x00, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xA4,
+0x2F, 0x00, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00, 0xD4, 0x37, 0x62, 0x8E,
+0x40, 0x38, 0x72, 0x8E, 0x05, 0x00, 0x04, 0x24, 0x00, 0x00, 0xA2, 0xAE,
+0xD8, 0x37, 0x62, 0xAE, 0x00, 0x00, 0xB2, 0xAE, 0x5B, 0x01, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x64, 0x8E, 0x44, 0x38, 0x63, 0x8E,
+0x02, 0x80, 0x02, 0x3C, 0xC4, 0xE6, 0x42, 0x24, 0x00, 0x00, 0x54, 0x8C,
+0x80, 0x00, 0x84, 0x24, 0xFF, 0x00, 0x62, 0x24, 0x2B, 0x10, 0x44, 0x00,
+0x0A, 0x18, 0x82, 0x00, 0x40, 0x38, 0x63, 0xAE, 0x40, 0x38, 0x82, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xAE, 0x02, 0x80, 0x03, 0x3C,
+0xFF, 0xFF, 0x42, 0x32, 0x25, 0x80, 0x43, 0x00, 0x00, 0x00, 0xB0, 0xAE,
+0x0C, 0x00, 0x02, 0x92, 0x08, 0x00, 0x05, 0x24, 0x00, 0x00, 0xA2, 0xAE,
+0x02, 0x00, 0x04, 0x92, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x92, 0x00,
+0xFF, 0xFF, 0x84, 0x30, 0xE0, 0x61, 0x00, 0x0C, 0x25, 0x20, 0x83, 0x00,
+0x0C, 0x00, 0x11, 0x92, 0x20, 0x10, 0x02, 0x3C, 0xFF, 0x00, 0x03, 0x24,
+0x00, 0x22, 0x11, 0x00, 0xC2, 0xFF, 0x23, 0x12, 0x21, 0x20, 0x82, 0x00,
+0xB8, 0xFF, 0xE0, 0x16, 0xD4, 0x37, 0x84, 0xAE, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x42, 0x24, 0x90, 0x06, 0x00, 0x08, 0x90, 0x37, 0x51, 0xA0,
+0x1D, 0x00, 0xE0, 0x12, 0x44, 0x00, 0xE4, 0x34, 0x9C, 0x37, 0x83, 0x92,
+0x45, 0x00, 0xE4, 0x34, 0xB0, 0x03, 0xC5, 0x34, 0x00, 0x00, 0x83, 0xA0,
+0x00, 0x00, 0xA3, 0xAC, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xC5, 0x27,
+0xD0, 0x1B, 0xA2, 0x8C, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F,
+0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x18, 0x00, 0x03, 0x3C,
+0x25, 0x10, 0x43, 0x00, 0x41, 0xB0, 0x04, 0x3C, 0x40, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0x82, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA2, 0xAC,
+0x90, 0x37, 0x83, 0x92, 0xB0, 0x03, 0xC5, 0x34, 0x00, 0x00, 0x83, 0xA0,
+0x00, 0x00, 0xA3, 0xAC, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xC5, 0x27,
+0xD0, 0x1B, 0xA2, 0x8C, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F,
+0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x18, 0x00, 0x03, 0x3C,
+0x25, 0x10, 0x43, 0x00, 0x41, 0xB0, 0x04, 0x3C, 0x40, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0x82, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA2, 0xAC,
+0xC0, 0xFF, 0xBD, 0x27, 0x34, 0x00, 0xB7, 0xAF, 0x3C, 0x00, 0xBF, 0xAF,
+0x38, 0x00, 0xBE, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x06, 0x3C,
+0xC0, 0x5D, 0xC5, 0x90, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x18, 0x03, 0x42, 0x34, 0x54, 0x1C, 0x63, 0x24, 0x02, 0x00, 0xA4, 0x30,
+0x00, 0x00, 0x43, 0xAC, 0x21, 0xB8, 0x00, 0x00, 0x03, 0x00, 0x80, 0x10,
+0xFB, 0x00, 0xA2, 0x30, 0xFD, 0x00, 0xA2, 0x30, 0x01, 0x00, 0x17, 0x24,
+0xC0, 0x5D, 0xC2, 0xA0, 0xC0, 0x5D, 0xC3, 0x90, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0x02, 0x80, 0x1E, 0x3C, 0x00, 0x00, 0x43, 0xAC,
+0x21, 0xA8, 0x40, 0x00, 0x96, 0x40, 0x00, 0x0C, 0x60, 0x1B, 0xD3, 0x27,
+0x57, 0x07, 0x00, 0x08, 0x02, 0x80, 0x16, 0x3C, 0x98, 0x37, 0x91, 0xA2,
+0x60, 0x1B, 0xC2, 0x27, 0xE0, 0x37, 0x46, 0x8C, 0x4C, 0x38, 0x45, 0x8C,
+0x06, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x60, 0x1B, 0xD4, 0x27, 0xE4, 0x37, 0x85, 0x8E,
+0x21, 0x20, 0x00, 0x02, 0xD4, 0x02, 0x00, 0x0C, 0x21, 0x30, 0x40, 0x02,
+0x2A, 0xB0, 0x07, 0x3C, 0x25, 0x00, 0xE2, 0x34, 0x04, 0x00, 0x43, 0x24,
+0x0B, 0x10, 0x77, 0x00, 0x01, 0x00, 0x04, 0x24, 0x02, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x44, 0xA0, 0x00, 0x00, 0x43, 0xA0, 0x0C, 0x5D, 0xC4, 0x96,
+0x25, 0xB0, 0x06, 0x3C, 0x66, 0x03, 0xC5, 0x34, 0x01, 0x00, 0x84, 0x24,
+0x0C, 0x5D, 0xC4, 0xA6, 0x0C, 0x5D, 0xC2, 0x96, 0xFF, 0x00, 0x03, 0x24,
+0x00, 0x00, 0xA2, 0xA4, 0x2F, 0x00, 0x23, 0x12, 0x00, 0x00, 0x00, 0x00,
+0xE0, 0x37, 0x62, 0x8E, 0x4C, 0x38, 0x72, 0x8E, 0x06, 0x00, 0x04, 0x24,
+0x00, 0x00, 0xA2, 0xAE, 0xE4, 0x37, 0x62, 0xAE, 0x00, 0x00, 0xB2, 0xAE,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x38, 0x64, 0x8E,
+0x50, 0x38, 0x63, 0x8E, 0x02, 0x80, 0x02, 0x3C, 0xC8, 0xE6, 0x42, 0x24,
+0x00, 0x00, 0x54, 0x8C, 0x80, 0x00, 0x84, 0x24, 0xFF, 0x00, 0x62, 0x24,
+0x2B, 0x10, 0x44, 0x00, 0x0A, 0x18, 0x82, 0x00, 0x4C, 0x38, 0x63, 0xAE,
+0x4C, 0x38, 0x82, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xAE,
+0x02, 0x80, 0x03, 0x3C, 0xFF, 0xFF, 0x42, 0x32, 0x25, 0x80, 0x43, 0x00,
+0x00, 0x00, 0xB0, 0xAE, 0x0C, 0x00, 0x02, 0x92, 0x04, 0x00, 0x05, 0x24,
+0x00, 0x00, 0xA2, 0xAE, 0x02, 0x00, 0x04, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x20, 0x92, 0x00, 0xFF, 0xFF, 0x84, 0x30, 0xE0, 0x61, 0x00, 0x0C,
+0x25, 0x20, 0x83, 0x00, 0x0C, 0x00, 0x11, 0x92, 0x20, 0x10, 0x02, 0x3C,
+0xFF, 0x00, 0x03, 0x24, 0x00, 0x22, 0x11, 0x00, 0xC2, 0xFF, 0x23, 0x12,
+0x21, 0x20, 0x82, 0x00, 0xB8, 0xFF, 0xE0, 0x16, 0xE0, 0x37, 0x84, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x39, 0x07, 0x00, 0x08,
+0x94, 0x37, 0x51, 0xA0, 0x1D, 0x00, 0xE0, 0x12, 0x46, 0x00, 0xE4, 0x34,
+0x98, 0x37, 0x83, 0x92, 0x47, 0x00, 0xE4, 0x34, 0xB0, 0x03, 0xC5, 0x34,
+0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC, 0x96, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA2, 0x8C, 0x3C, 0x00, 0xBF, 0x8F,
+0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x60, 0x00, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00, 0x41, 0xB0, 0x04, 0x3C,
+0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x82, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xD0, 0x1B, 0xA2, 0xAC, 0x94, 0x37, 0x83, 0x92, 0xB0, 0x03, 0xC5, 0x34,
+0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xA3, 0xAC, 0x96, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0xC5, 0x27, 0xD0, 0x1B, 0xA2, 0x8C, 0x3C, 0x00, 0xBF, 0x8F,
+0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x60, 0x00, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00, 0x41, 0xB0, 0x04, 0x3C,
+0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x82, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xD0, 0x1B, 0xA2, 0xAC, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0xF8, 0x1E, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34, 0xE8, 0xFF, 0xBD, 0x27,
+0x00, 0x00, 0x43, 0xAC, 0x10, 0x00, 0xBF, 0xAF, 0x96, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24, 0xD8, 0x1B, 0xA2, 0x8C,
+0xD0, 0x1B, 0xA4, 0x8C, 0x00, 0x08, 0x03, 0x3C, 0x10, 0x00, 0xBF, 0x8F,
+0x24, 0x10, 0x43, 0x00, 0x25, 0x20, 0x82, 0x00, 0x41, 0xB0, 0x03, 0x3C,
+0x18, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x64, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xD0, 0x1B, 0xA4, 0xAC, 0xC0, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xB0, 0xAF,
+0x00, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x10, 0x3C, 0x18, 0x03, 0x03, 0x36,
+0x58, 0x1F, 0x42, 0x24, 0x00, 0x00, 0x62, 0xAC, 0x34, 0x00, 0xB5, 0xAF,
+0x02, 0x80, 0x15, 0x3C, 0x38, 0x00, 0xBF, 0xAF, 0x2C, 0x00, 0xB3, 0xAF,
+0x28, 0x00, 0xB2, 0xAF, 0x60, 0x1B, 0xB3, 0x26, 0x24, 0x00, 0xB1, 0xAF,
+0x96, 0x40, 0x00, 0x0C, 0x30, 0x00, 0xB4, 0xAF, 0xFC, 0x00, 0x02, 0x36,
+0x00, 0x00, 0x45, 0x8C, 0xAC, 0x1B, 0x64, 0x96, 0xCC, 0x38, 0x63, 0x96,
+0xC4, 0x38, 0x66, 0x8E, 0x23, 0x28, 0xA4, 0x00, 0x21, 0x10, 0xA3, 0x00,
+0x23, 0x88, 0x46, 0x00, 0x23, 0x20, 0x23, 0x02, 0xB0, 0x03, 0x10, 0x36,
+0x2B, 0x10, 0x71, 0x00, 0x00, 0x00, 0x03, 0xAE, 0x00, 0x00, 0x11, 0xAE,
+0x0B, 0x88, 0x82, 0x00, 0x21, 0x20, 0x20, 0x02, 0x53, 0x21, 0x00, 0x0C,
+0xC8, 0x38, 0x65, 0xAE, 0x21, 0x90, 0x40, 0x00, 0x4D, 0x00, 0x40, 0x10,
+0x18, 0x00, 0xA4, 0x27, 0x0C, 0x00, 0x51, 0xAC, 0xC4, 0x38, 0x68, 0x8E,
+0xC8, 0x38, 0x62, 0x8E, 0x08, 0x00, 0x45, 0x8E, 0x20, 0xBD, 0x03, 0x3C,
+0x88, 0x03, 0x63, 0x34, 0x2B, 0x10, 0x48, 0x00, 0x40, 0x10, 0x14, 0x3C,
+0x21, 0x20, 0x00, 0x00, 0xFF, 0xFF, 0x27, 0x32, 0x00, 0x00, 0x65, 0xAC,
+0x2A, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xAC, 0x1B, 0x66, 0x96,
+0x08, 0x00, 0x42, 0x96, 0x40, 0x10, 0x05, 0x3C, 0x21, 0x20, 0x00, 0x00,
+0x21, 0x30, 0x06, 0x01, 0x25, 0x28, 0x45, 0x00, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x18, 0x00, 0xA4, 0x27,
+0x02, 0x80, 0x02, 0x3C, 0x88, 0x54, 0x42, 0x24, 0x04, 0x00, 0x43, 0x8C,
+0x00, 0x00, 0x42, 0xAE, 0x04, 0x00, 0x52, 0xAC, 0x21, 0x20, 0x00, 0x00,
+0x00, 0x00, 0x72, 0xAC, 0x5B, 0x01, 0x00, 0x0C, 0x04, 0x00, 0x43, 0xAE,
+0x60, 0x1B, 0xA5, 0x26, 0xC8, 0x38, 0xA6, 0x8C, 0xAC, 0x1B, 0xA3, 0x94,
+0x25, 0xB0, 0x02, 0x3C, 0xF8, 0x00, 0x42, 0x34, 0x21, 0x18, 0xC3, 0x00,
+0x00, 0x00, 0x43, 0xAC, 0x18, 0x00, 0xA4, 0x27, 0xC4, 0x38, 0xA6, 0xAC,
+0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0xBF, 0x8F, 0x34, 0x00, 0xB5, 0x8F,
+0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F,
+0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x40, 0x00, 0xBD, 0x27, 0xCC, 0x38, 0x70, 0x8E, 0x08, 0x00, 0x45, 0x96,
+0xAC, 0x1B, 0x66, 0x96, 0x23, 0x80, 0x08, 0x02, 0xFF, 0xFF, 0x10, 0x32,
+0x21, 0x30, 0x06, 0x01, 0x25, 0x28, 0xB4, 0x00, 0x21, 0x38, 0x00, 0x02,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x5B, 0x01, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x00, 0x08, 0x00, 0x45, 0x96, 0xAC, 0x1B, 0x62, 0x96,
+0x23, 0x38, 0x30, 0x02, 0x25, 0x28, 0xB4, 0x00, 0x21, 0x10, 0x06, 0x3C,
+0x21, 0x28, 0xB0, 0x00, 0x21, 0x30, 0x46, 0x00, 0xFF, 0xFF, 0xE7, 0x30,
+0x0D, 0x08, 0x00, 0x08, 0x21, 0x20, 0x00, 0x00, 0x8A, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C, 0xC4, 0x5D, 0x62, 0x8C,
+0x18, 0x00, 0xA4, 0x27, 0x08, 0x00, 0x42, 0x34, 0x23, 0x08, 0x00, 0x08,
+0xC4, 0x5D, 0x62, 0xAC, 0x25, 0xB0, 0x05, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0xC0, 0xFF, 0xBD, 0x27, 0x18, 0x03, 0xA4, 0x34, 0x38, 0x21, 0x42, 0x24,
+0x2A, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x82, 0xAC, 0x3C, 0x00, 0xBF, 0xAF,
+0x38, 0x00, 0xBE, 0xAF, 0x34, 0x00, 0xB7, 0xAF, 0x30, 0x00, 0xB6, 0xAF,
+0x2C, 0x00, 0xB5, 0xAF, 0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF,
+0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF,
+0x2C, 0x00, 0x63, 0x34, 0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x24, 0x31, 0x48, 0x00, 0x82, 0x10, 0x00, 0x80, 0x22, 0x31,
+0x37, 0x00, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x14, 0x00, 0x82, 0x10,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x70, 0x24, 0xFF, 0x00, 0x23, 0x31,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x7C, 0x38, 0x05, 0x8E, 0x25, 0xB0, 0x02, 0x3C, 0xFF, 0x00, 0x28, 0x31,
+0x7C, 0x03, 0x42, 0x34, 0x00, 0x00, 0x48, 0xA4, 0x21, 0x30, 0x60, 0x00,
+0x10, 0x38, 0x03, 0xAE, 0xAC, 0x37, 0x09, 0xA2, 0x0A, 0x00, 0x04, 0x24,
+0x00, 0x01, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF,
+0x01, 0x00, 0x03, 0x24, 0x84, 0x38, 0x03, 0xA2, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x50, 0x24, 0x84, 0x38, 0x03, 0x92, 0x01, 0x00, 0x02, 0x24,
+0x31, 0x00, 0x62, 0x10, 0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0x90, 0x24,
+0x85, 0x38, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40, 0x10,
+0x00, 0x04, 0x03, 0x3C, 0xD8, 0x1B, 0x02, 0x8E, 0xD0, 0x1B, 0x04, 0x8E,
+0x24, 0x10, 0x43, 0x00, 0x25, 0x20, 0x82, 0x00, 0x41, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0x64, 0xAC, 0xD0, 0x1B, 0x04, 0xAE, 0x3C, 0x00, 0xBF, 0x8F,
+0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x40, 0x00, 0xBD, 0x27, 0x24, 0x10, 0x22, 0x01,
+0xCB, 0xFF, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x43, 0x24, 0xAC, 0x37, 0x62, 0x90, 0x20, 0xB0, 0x03, 0x3C,
+0xB0, 0x03, 0xA4, 0x34, 0x00, 0x12, 0x02, 0x00, 0x21, 0x10, 0x43, 0x00,
+0x0C, 0x00, 0x49, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0xAC,
+0x69, 0x08, 0x00, 0x08, 0xFF, 0x00, 0x24, 0x31, 0x02, 0x80, 0x04, 0x3C,
+0x60, 0x1B, 0x82, 0x24, 0x84, 0x38, 0x40, 0xA0, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x50, 0x24, 0x84, 0x38, 0x03, 0x92, 0x01, 0x00, 0x02, 0x24,
+0xD1, 0xFF, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00, 0x96, 0x40, 0x00, 0x0C,
+0x21, 0x88, 0x00, 0x02, 0x25, 0xB0, 0x02, 0x3C, 0x2A, 0xB0, 0x03, 0x3C,
+0x2C, 0x00, 0x7E, 0x34, 0x02, 0x80, 0x17, 0x3C, 0xB0, 0x03, 0x56, 0x34,
+0x01, 0x00, 0x13, 0x24, 0x21, 0xA0, 0x00, 0x02, 0x21, 0xA8, 0x00, 0x02,
+0x7C, 0x38, 0x30, 0x8E, 0x0A, 0x00, 0x04, 0x24, 0x00, 0x00, 0xD0, 0xAE,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0xFF, 0xFF, 0x08, 0x32, 0x25, 0x80, 0x02, 0x01, 0xC2, 0x5C, 0xE3, 0x92,
+0x02, 0x00, 0x04, 0x92, 0x02, 0x00, 0x02, 0x24, 0x0F, 0x00, 0x63, 0x30,
+0x52, 0x00, 0x62, 0x10, 0x21, 0x38, 0x04, 0x02, 0x20, 0x00, 0x02, 0x24,
+0x54, 0x00, 0x82, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x54, 0xF5, 0x47, 0xAC,
+0x02, 0x00, 0xE2, 0x90, 0x85, 0x38, 0x84, 0x92, 0x03, 0x00, 0xE3, 0x90,
+0xFF, 0x00, 0x52, 0x30, 0x01, 0x00, 0x02, 0x24, 0x21, 0x28, 0xE0, 0x00,
+0x7F, 0x00, 0x66, 0x30, 0x08, 0x00, 0xE7, 0x24, 0x57, 0x00, 0x82, 0x10,
+0x02, 0x80, 0x09, 0x3C, 0x0E, 0x00, 0x02, 0x24, 0x51, 0x00, 0x42, 0x12,
+0x37, 0x00, 0x02, 0x24, 0x4F, 0x00, 0x42, 0x12, 0x10, 0x00, 0x02, 0x24,
+0x4E, 0x00, 0x42, 0x12, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0x38, 0xD7, 0x42, 0x24, 0xC0, 0x18, 0x12, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x34, 0xD7, 0x26, 0xA1, 0x04, 0x00, 0x62, 0x8C, 0x02, 0x80, 0x03, 0x3C,
+0x21, 0x20, 0xE0, 0x00, 0x09, 0xF8, 0x40, 0x00, 0x4C, 0xF5, 0x62, 0xAC,
+0x03, 0x00, 0x40, 0x10, 0x39, 0x00, 0x02, 0x24, 0x3B, 0x00, 0x42, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x85, 0x38, 0x33, 0xA2, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x39, 0x00, 0x02, 0x24, 0x03, 0x00, 0x42, 0x12, 0x02, 0x00, 0x02, 0x24,
+0x01, 0x00, 0xD3, 0xA3, 0x01, 0x00, 0xC2, 0xA3, 0x85, 0x38, 0xA3, 0x92,
+0x01, 0x00, 0x02, 0x24, 0x42, 0x00, 0x62, 0x14, 0xFF, 0x00, 0x02, 0x24,
+0x0C, 0x00, 0x03, 0x92, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x68, 0x30,
+0x3E, 0x00, 0x02, 0x11, 0x02, 0x80, 0x02, 0x3C, 0xAC, 0x37, 0xA3, 0xA2,
+0xAC, 0x37, 0x22, 0x92, 0x7C, 0x38, 0x25, 0x8E, 0x20, 0x10, 0x03, 0x3C,
+0x00, 0x12, 0x02, 0x00, 0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0xC8, 0xAE,
+0x21, 0x30, 0x40, 0x00, 0x10, 0x38, 0x22, 0xAE, 0x0A, 0x00, 0x04, 0x24,
+0x00, 0x01, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF,
+0x7C, 0x38, 0x30, 0x8E, 0x0A, 0x00, 0x04, 0x24, 0x00, 0x00, 0xD0, 0xAE,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0xFF, 0xFF, 0x08, 0x32, 0x25, 0x80, 0x02, 0x01, 0xC2, 0x5C, 0xE3, 0x92,
+0x02, 0x00, 0x04, 0x92, 0x02, 0x00, 0x02, 0x24, 0x0F, 0x00, 0x63, 0x30,
+0xB0, 0xFF, 0x62, 0x14, 0x21, 0x38, 0x04, 0x02, 0x00, 0x00, 0x02, 0x8E,
+0x00, 0x0C, 0x03, 0x3C, 0x24, 0x10, 0x43, 0x00, 0xAE, 0xFF, 0x43, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x95, 0x58, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x7A, 0x37, 0x22, 0x96, 0x85, 0x38, 0x33, 0xA2, 0x01, 0x00, 0x42, 0x24,
+0xF5, 0x08, 0x00, 0x08, 0x7A, 0x37, 0x22, 0xA6, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xF3, 0x08, 0x00, 0x08, 0x85, 0x38, 0x20, 0xA2,
+0x02, 0x80, 0x02, 0x3C, 0xE2, 0x08, 0x00, 0x08, 0x25, 0x38, 0x02, 0x01,
+0x34, 0xD7, 0x22, 0x91, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x42, 0x30,
+0x13, 0x00, 0xC2, 0x10, 0x25, 0xB0, 0x04, 0x3C, 0x6A, 0x37, 0x82, 0x96,
+0x1E, 0x03, 0x84, 0x34, 0x10, 0x00, 0x42, 0x34, 0x3B, 0x00, 0x43, 0x2E,
+0x00, 0x00, 0x82, 0xA4, 0x9F, 0xFF, 0x60, 0x14, 0x6A, 0x37, 0x82, 0xA6,
+0xF6, 0x08, 0x00, 0x08, 0x39, 0x00, 0x02, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0xB0, 0x5D, 0x44, 0x8C, 0x25, 0xB0, 0x03, 0x3C, 0xB0, 0x03, 0x63, 0x34,
+0x00, 0x00, 0x64, 0xAC, 0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x85, 0x08, 0x00, 0x08, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x00, 0xA5, 0x90,
+0x34, 0xD7, 0x27, 0x91, 0x02, 0x80, 0x04, 0x3C, 0xCC, 0xE6, 0x84, 0x24,
+0xFF, 0x00, 0xA5, 0x30, 0x13, 0x58, 0x00, 0x0C, 0xFF, 0x00, 0xE7, 0x30,
+0xF6, 0x08, 0x00, 0x08, 0x39, 0x00, 0x02, 0x24, 0xC0, 0xFF, 0xBD, 0x27,
+0x34, 0x00, 0xB7, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0x21, 0xB8, 0xA0, 0x00,
+0xFF, 0xFF, 0xA5, 0x30, 0x25, 0x40, 0xA2, 0x00, 0x20, 0x00, 0xB2, 0xAF,
+0x38, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x03, 0x8D, 0xFF, 0xFF, 0xD2, 0x30,
+0x08, 0x00, 0x45, 0x26, 0x00, 0xC0, 0x02, 0x24, 0x04, 0x00, 0x06, 0x8D,
+0x24, 0x18, 0x62, 0x00, 0xFF, 0x3F, 0xA5, 0x30, 0xF0, 0xFF, 0x02, 0x3C,
+0x25, 0x18, 0x65, 0x00, 0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x80, 0x05, 0x3C, 0x25, 0x18, 0x65, 0x00, 0xFF, 0x01, 0xC6, 0x34,
+0x00, 0x00, 0x03, 0xAD, 0x04, 0x00, 0x06, 0xAD, 0x21, 0x48, 0x80, 0x00,
+0xFF, 0xFF, 0xE7, 0x30, 0x18, 0x00, 0x06, 0x25, 0x18, 0x00, 0x12, 0xA5,
+0x02, 0x00, 0xC7, 0xA0, 0x18, 0x00, 0x03, 0x8D, 0xFF, 0x7F, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00, 0x02, 0x80, 0x16, 0x3C,
+0x18, 0x00, 0x03, 0xAD, 0x60, 0x1B, 0xC5, 0x26, 0x66, 0x37, 0xA4, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x82, 0x24, 0x66, 0x37, 0xA2, 0xA0,
+0x18, 0x00, 0x03, 0x8D, 0xFF, 0x80, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x7F, 0x00, 0x84, 0x30, 0x00, 0x26, 0x04, 0x00, 0x24, 0x18, 0x62, 0x00,
+0x25, 0x18, 0x64, 0x00, 0x18, 0x00, 0x03, 0xAD, 0x02, 0x80, 0x02, 0x3C,
+0xC2, 0x5C, 0x44, 0x90, 0x20, 0x00, 0x43, 0x26, 0xFF, 0xFF, 0x72, 0x30,
+0x02, 0x00, 0x84, 0x30, 0x04, 0x00, 0x80, 0x10, 0x21, 0x18, 0x40, 0x02,
+0x1F, 0x00, 0x42, 0x32, 0x5C, 0x00, 0x40, 0x10, 0x08, 0x00, 0x42, 0x26,
+0xFF, 0xFF, 0x63, 0x30, 0x5D, 0x00, 0x43, 0x12, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0xC2, 0x8C, 0x21, 0x90, 0x60, 0x00, 0x00, 0xC0, 0x04, 0x24,
+0x01, 0x00, 0x42, 0x34, 0x04, 0x00, 0xC2, 0xAC, 0x00, 0x00, 0x03, 0x8D,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x62, 0x30, 0x08, 0x00, 0x42, 0x24,
+0x24, 0x18, 0x64, 0x00, 0xFF, 0x3F, 0x42, 0x30, 0x25, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x03, 0xAD, 0x25, 0xB0, 0x02, 0x3C, 0xC0, 0x00, 0x42, 0x34,
+0x07, 0x00, 0x43, 0x32, 0x00, 0x00, 0x52, 0xA4, 0x03, 0x00, 0x60, 0x10,
+0xF8, 0xFF, 0x53, 0x32, 0x08, 0x00, 0x42, 0x26, 0xF8, 0xFF, 0x53, 0x30,
+0x60, 0x1B, 0xD5, 0x26, 0xEC, 0x38, 0xA6, 0x8E, 0xF0, 0x38, 0xB0, 0x8E,
+0x21, 0x10, 0xD3, 0x00, 0x2B, 0x10, 0x02, 0x02, 0x32, 0x00, 0x40, 0x10,
+0xFF, 0x00, 0x34, 0x31, 0x23, 0x80, 0x06, 0x02, 0x21, 0x28, 0xE0, 0x02,
+0xFF, 0xFF, 0x07, 0x32, 0x01, 0x00, 0x11, 0x24, 0x21, 0x20, 0x80, 0x02,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xB1, 0xAF, 0x23, 0x18, 0x70, 0x02,
+0xFF, 0xFF, 0x72, 0x30, 0x22, 0x10, 0x02, 0x3C, 0x21, 0x10, 0x42, 0x02,
+0x21, 0x20, 0x80, 0x02, 0x5B, 0x01, 0x00, 0x0C, 0xEC, 0x38, 0xA2, 0xAE,
+0x21, 0x28, 0xF0, 0x02, 0x21, 0x38, 0x40, 0x02, 0x21, 0x20, 0x80, 0x02,
+0x22, 0x10, 0x06, 0x3C, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xB1, 0xAF,
+0x60, 0x1B, 0xD1, 0x26, 0xEC, 0x38, 0x23, 0x8E, 0x25, 0xB0, 0x10, 0x3C,
+0xB0, 0x03, 0x02, 0x36, 0x21, 0x20, 0x80, 0x02, 0x00, 0x00, 0x43, 0xAC,
+0x5B, 0x01, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x38, 0x25, 0x8E,
+0xEC, 0x00, 0x02, 0x36, 0xBD, 0x00, 0x04, 0x36, 0x00, 0x00, 0x45, 0xAC,
+0x00, 0x00, 0x83, 0x90, 0xC2, 0x00, 0x10, 0x36, 0x38, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0x63, 0x34, 0x00, 0x00, 0x83, 0xA0, 0x34, 0x00, 0xB7, 0x8F,
+0x00, 0x00, 0x05, 0xA6, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x40, 0x00, 0xBD, 0x27, 0x01, 0x00, 0x02, 0x24,
+0x21, 0x28, 0xE0, 0x02, 0x21, 0x20, 0x80, 0x02, 0x21, 0x38, 0x60, 0x02,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0xEC, 0x38, 0xA3, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x73, 0x00, 0xC4, 0x09, 0x00, 0x08,
+0xEC, 0x38, 0xA3, 0xAE, 0xFF, 0xFF, 0x43, 0x30, 0xFF, 0xFF, 0x63, 0x30,
+0xA5, 0xFF, 0x43, 0x16, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xC2, 0x8C,
+0xFE, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00, 0xA1, 0x09, 0x00, 0x08,
+0x04, 0x00, 0xC2, 0xAC, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x14, 0x00, 0x03, 0x8E, 0x16, 0x00, 0x02, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x0A, 0x00, 0x62, 0x10, 0x08, 0x00, 0x06, 0x24,
+0x08, 0x00, 0x02, 0x96, 0x02, 0x80, 0x04, 0x3C, 0xEC, 0x54, 0x00, 0x0C,
+0x25, 0x20, 0x44, 0x00, 0x08, 0x00, 0x05, 0x8E, 0x0C, 0x00, 0x06, 0x96,
+0x14, 0x00, 0x07, 0x96, 0x51, 0x09, 0x00, 0x0C, 0x09, 0x00, 0x04, 0x24,
+0x04, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x02, 0x8E, 0x21, 0x20, 0x00, 0x02,
+0x00, 0x00, 0x62, 0xAC, 0x04, 0x00, 0x43, 0xAC, 0x00, 0x00, 0x10, 0xAE,
+0x74, 0x21, 0x00, 0x0C, 0x04, 0x00, 0x10, 0xAE, 0x90, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xBF, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x25, 0xB0, 0x02, 0x3C,
+0xBF, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x63, 0x2C, 0x05, 0x00, 0x60, 0x10, 0x02, 0x80, 0x05, 0x3C,
+0x90, 0x54, 0xA3, 0x8C, 0x90, 0x54, 0xA2, 0x24, 0x0D, 0x00, 0x62, 0x10,
+0x21, 0x20, 0x00, 0x02, 0x90, 0x54, 0xA2, 0x24, 0x04, 0x00, 0x43, 0x8C,
+0x00, 0x00, 0x02, 0xAE, 0x04, 0x00, 0x50, 0xAC, 0x00, 0x00, 0x70, 0xAC,
+0x04, 0x00, 0x03, 0xAE, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xF5, 0x09, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xD8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x08, 0xE7, 0x84, 0x24, 0x24, 0x00, 0xBF, 0xAF,
+0x20, 0x00, 0xB2, 0xAF, 0x13, 0x58, 0x00, 0x0C, 0x1C, 0x00, 0xB1, 0xAF,
+0x00, 0x00, 0x04, 0x96, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x83, 0x24,
+0x07, 0x00, 0x62, 0x30, 0x6A, 0x00, 0x40, 0x10, 0xC2, 0x10, 0x03, 0x00,
+0x28, 0x00, 0x82, 0x24, 0xC2, 0x10, 0x02, 0x00, 0x53, 0x21, 0x00, 0x0C,
+0xC0, 0x20, 0x02, 0x00, 0x68, 0x00, 0x40, 0x10, 0x21, 0x88, 0x40, 0x00,
+0x02, 0x80, 0x12, 0x3C, 0x02, 0x00, 0x06, 0x92, 0x60, 0x1B, 0x50, 0x26,
+0x10, 0x38, 0x05, 0x8E, 0x08, 0x00, 0xC6, 0x24, 0x0A, 0x00, 0x04, 0x24,
+0x72, 0x01, 0x00, 0x0C, 0x21, 0x38, 0x40, 0x00, 0xB0, 0x1B, 0x03, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x62, 0x30, 0x67, 0x00, 0x40, 0x14,
+0x01, 0x00, 0x62, 0x30, 0x02, 0x80, 0x02, 0x3C, 0x4B, 0xF5, 0x43, 0x90,
+0x60, 0x1B, 0x50, 0x26, 0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0xE8, 0x39, 0x00, 0xAE, 0x04, 0x3A, 0x00, 0xAE, 0xFC, 0x40, 0x00, 0xAE,
+0xBC, 0x40, 0x00, 0xAE, 0xC6, 0x40, 0x00, 0xA2, 0x8A, 0x40, 0x00, 0x0C,
+0xC6, 0x5C, 0x43, 0xA0, 0xA3, 0x6A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x87, 0x6B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x90, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C, 0xD2, 0x5C, 0x48, 0x90,
+0x25, 0xB0, 0x04, 0x3C, 0x2F, 0x00, 0x02, 0x3C, 0xD0, 0x01, 0x85, 0x34,
+0x17, 0x32, 0x42, 0x34, 0x00, 0x00, 0xA2, 0xAC, 0x5E, 0x00, 0x03, 0x3C,
+0x10, 0x00, 0x02, 0x3C, 0xDC, 0x01, 0x87, 0x34, 0xD4, 0x01, 0x86, 0x34,
+0x17, 0x43, 0x63, 0x34, 0x20, 0x53, 0x42, 0x34, 0xD8, 0x01, 0x84, 0x34,
+0x00, 0x00, 0xC3, 0xAC, 0x00, 0x00, 0x82, 0xAC, 0x44, 0xA4, 0x03, 0x34,
+0x01, 0x00, 0x02, 0x24, 0x00, 0x00, 0xE3, 0xAC, 0x52, 0x00, 0x02, 0x11,
+0xFF, 0xF7, 0x03, 0x24, 0xFC, 0x23, 0x02, 0x8E, 0xFF, 0xEF, 0x04, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x24, 0x10, 0x44, 0x00, 0xFC, 0x23, 0x02, 0xAE,
+0x60, 0x1B, 0x42, 0x8E, 0xDF, 0xFF, 0x03, 0x24, 0xFB, 0xFF, 0x04, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x24, 0x10, 0x44, 0x00, 0xFE, 0xFF, 0x03, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x50, 0x0C, 0x04, 0x24, 0x60, 0x1B, 0x50, 0x26,
+0x30, 0x5C, 0x00, 0x0C, 0x60, 0x1B, 0x42, 0xAE, 0x38, 0x3E, 0x02, 0xA2,
+0x30, 0x5C, 0x00, 0x0C, 0x58, 0x0C, 0x04, 0x24, 0x39, 0x3E, 0x02, 0xA2,
+0x50, 0x0C, 0x04, 0x24, 0x1A, 0x5C, 0x00, 0x0C, 0x17, 0x00, 0x05, 0x24,
+0x17, 0x00, 0x05, 0x24, 0x1A, 0x5C, 0x00, 0x0C, 0x58, 0x0C, 0x04, 0x24,
+0x5B, 0x01, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24, 0x08, 0x00, 0x22, 0x96,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x04, 0x3C, 0x25, 0x28, 0x45, 0x00,
+0x74, 0x03, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0xB0, 0x55, 0x84, 0x24,
+0x74, 0x21, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02, 0x98, 0x3A, 0x02, 0x8E,
+0x49, 0x4B, 0x00, 0x0C, 0xC4, 0x3D, 0x02, 0xA2, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x53, 0x21, 0x00, 0x0C, 0xC0, 0x20, 0x02, 0x00, 0x9A, 0xFF, 0x40, 0x14,
+0x21, 0x88, 0x40, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x18, 0xE7, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0xFC, 0xE6, 0xA5, 0x24,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0x20, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x87, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x05, 0x3C,
+0x4C, 0x00, 0xA2, 0x34, 0x00, 0x00, 0x40, 0xA0, 0x48, 0x00, 0xA5, 0x34,
+0xB0, 0x1B, 0x03, 0x96, 0x00, 0x00, 0xA4, 0x8C, 0x7B, 0xFF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x82, 0x00, 0xFF, 0xFE, 0x63, 0x30,
+0xB0, 0x1B, 0x03, 0xA6, 0x00, 0x00, 0xA4, 0xAC, 0x5F, 0x0A, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0xD3, 0x5C, 0x44, 0x90,
+0x02, 0x00, 0x03, 0x24, 0x06, 0x00, 0x83, 0x10, 0xFF, 0xF7, 0x03, 0x24,
+0xFC, 0x23, 0x02, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x43, 0x00,
+0x89, 0x0A, 0x00, 0x08, 0x00, 0x10, 0x42, 0x34, 0xFC, 0x23, 0x02, 0x8E,
+0xFF, 0xEF, 0x03, 0x24, 0x00, 0x08, 0x42, 0x34, 0x89, 0x0A, 0x00, 0x08,
+0x24, 0x10, 0x43, 0x00, 0x02, 0x80, 0x04, 0x3C, 0xB4, 0x55, 0x84, 0x24,
+0x1C, 0x4F, 0x00, 0x0C, 0x03, 0x00, 0x05, 0x24, 0xC6, 0x0A, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x00, 0x00, 0x84, 0x90, 0x02, 0x80, 0x06, 0x3C, 0x01, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x83, 0x30, 0x0C, 0x00, 0x62, 0x10, 0x60, 0x1B, 0xC5, 0x24,
+0x04, 0x00, 0x02, 0x24, 0x13, 0x00, 0x62, 0x10, 0x60, 0x1B, 0xC2, 0x24,
+0xC6, 0x3D, 0x45, 0x90, 0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C,
+0x24, 0xE7, 0x84, 0x24, 0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xC6, 0x3D, 0xA4, 0xA0,
+0x60, 0x1B, 0xC2, 0x24, 0xC6, 0x3D, 0x45, 0x90, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0x24, 0xE7, 0x84, 0x24, 0x10, 0x00, 0xBF, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0x60, 0x1B, 0xC3, 0x24, 0xB0, 0x1B, 0x62, 0x94, 0xC6, 0x3D, 0x64, 0xA0,
+0x02, 0x80, 0x04, 0x3C, 0x04, 0x00, 0x42, 0x34, 0xB0, 0x1B, 0x62, 0xA4,
+0x60, 0x1B, 0xC2, 0x24, 0xC6, 0x3D, 0x45, 0x90, 0x13, 0x58, 0x00, 0x0C,
+0x24, 0xE7, 0x84, 0x24, 0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27,
+0x20, 0x00, 0xB2, 0xAF, 0x02, 0x80, 0x12, 0x3C, 0x24, 0x00, 0xB3, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x2C, 0x00, 0xBF, 0xAF, 0x28, 0x00, 0xB4, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0x51, 0x26, 0xB0, 0x1B, 0x22, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x42, 0x30, 0x0A, 0x00, 0x40, 0x10,
+0x21, 0x98, 0x80, 0x00, 0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0x10, 0x00, 0xA4, 0x27, 0x8A, 0x40, 0x00, 0x0C,
+0x02, 0x80, 0x14, 0x3C, 0xEE, 0x5D, 0x82, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0x04, 0x00, 0x42, 0x28, 0x89, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x60, 0x1B, 0x42, 0x8E, 0xDF, 0xFF, 0x03, 0x24, 0xFB, 0xFF, 0x04, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x24, 0x10, 0x44, 0x00, 0xFE, 0xFF, 0x03, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x50, 0x0C, 0x04, 0x24, 0x30, 0x5C, 0x00, 0x0C,
+0x60, 0x1B, 0x42, 0xAE, 0x38, 0x3E, 0x22, 0xA2, 0x30, 0x5C, 0x00, 0x0C,
+0x58, 0x0C, 0x04, 0x24, 0x39, 0x3E, 0x22, 0xA2, 0x50, 0x0C, 0x04, 0x24,
+0x1A, 0x5C, 0x00, 0x0C, 0x17, 0x00, 0x05, 0x24, 0x17, 0x00, 0x05, 0x24,
+0x1A, 0x5C, 0x00, 0x0C, 0x58, 0x0C, 0x04, 0x24, 0xB0, 0x1B, 0x22, 0x96,
+0x02, 0x80, 0x04, 0x3C, 0x34, 0xE7, 0x84, 0x24, 0x00, 0x10, 0x42, 0x34,
+0x13, 0x58, 0x00, 0x0C, 0xB0, 0x1B, 0x22, 0xA6, 0x01, 0x00, 0x02, 0x24,
+0x25, 0xB0, 0x03, 0x3C, 0x04, 0x3E, 0x22, 0xAE, 0x4C, 0x00, 0x63, 0x34,
+0xB0, 0x1B, 0x22, 0x96, 0x00, 0x00, 0x66, 0x90, 0x08, 0x00, 0x65, 0x8E,
+0xC4, 0x3D, 0x27, 0x92, 0xC5, 0x3D, 0x28, 0x92, 0x3B, 0x41, 0x29, 0x92,
+0xD0, 0x3D, 0x2A, 0x92, 0xFF, 0x3D, 0x2B, 0x92, 0x00, 0x80, 0x42, 0x30,
+0x37, 0x3E, 0x26, 0xA2, 0x0C, 0x3E, 0x25, 0xAE, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x60, 0xA0, 0x31, 0x3E, 0x27, 0xA2, 0x32, 0x3E, 0x28, 0xA2,
+0x34, 0x3E, 0x22, 0xA6, 0x36, 0x3E, 0x29, 0xA2, 0xC4, 0x3D, 0x2A, 0xA2,
+0xC5, 0x3D, 0x2B, 0xA2, 0x3C, 0x3E, 0x20, 0xAE, 0x40, 0x3E, 0x20, 0xAE,
+0x8A, 0x40, 0x00, 0x0C, 0x33, 0x3E, 0x20, 0xA2, 0x10, 0x00, 0xA4, 0x27,
+0x90, 0x40, 0x00, 0x0C, 0x52, 0x41, 0x20, 0xA2, 0x21, 0x20, 0x00, 0x00,
+0x95, 0x0E, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x08, 0x00, 0x66, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0xC0, 0x14, 0x0C, 0x00, 0x70, 0x26,
+0x00, 0x00, 0x62, 0x8E, 0x21, 0x20, 0x20, 0x02, 0x44, 0x3E, 0x23, 0x26,
+0x08, 0x3E, 0x22, 0xAE, 0x3F, 0x00, 0x02, 0x24, 0xFF, 0xFF, 0x42, 0x24,
+0x00, 0x00, 0x60, 0xA0, 0xFD, 0xFF, 0x41, 0x04, 0x07, 0x00, 0x63, 0x24,
+0xB0, 0x1B, 0x83, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x62, 0x30,
+0x09, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x50, 0x26, 0x01, 0x00, 0x62, 0x30,
+0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x5D, 0x82, 0x92,
+0x0C, 0x00, 0x03, 0x24, 0x0F, 0x00, 0x42, 0x30, 0x37, 0x00, 0x43, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xC4, 0x3D, 0x04, 0x92, 0x75, 0x0D, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xC4, 0x3D, 0x04, 0x92, 0x38, 0x0D, 0x00, 0x0C,
+0x01, 0x00, 0x05, 0x24, 0x25, 0xB0, 0x04, 0x3C, 0x48, 0x00, 0x84, 0x34,
+0x00, 0x00, 0x83, 0x8C, 0x08, 0x3E, 0x05, 0x8E, 0x7B, 0xFF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x83, 0xAC, 0x0C, 0x00, 0xA2, 0x10, 0x60, 0x1B, 0x43, 0x26,
+0x3C, 0x00, 0x02, 0x24, 0x94, 0x39, 0x62, 0xAC, 0x2C, 0x00, 0xBF, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0xC4, 0x3D, 0x02, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x42, 0x2C, 0xF1, 0xFF, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x12, 0x49, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x43, 0x26, 0x3C, 0x00, 0x02, 0x24, 0xA0, 0x0B, 0x00, 0x08,
+0x94, 0x39, 0x62, 0xAC, 0x02, 0x80, 0x04, 0x3C, 0x21, 0x28, 0x00, 0x02,
+0xF4, 0x54, 0x00, 0x0C, 0x70, 0x59, 0x84, 0x24, 0x02, 0x80, 0x04, 0x3C,
+0x44, 0xE7, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x02,
+0x77, 0x0B, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x24,
+0x4B, 0x2E, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0x36, 0x0B, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x51, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x8D, 0x0B, 0x00, 0x08, 0x60, 0x1B, 0x50, 0x26, 0xE8, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x00, 0x00, 0x02, 0x92, 0x02, 0x80, 0x04, 0x3C, 0x21, 0x28, 0x40, 0x00,
+0x04, 0x00, 0x42, 0x2C, 0x06, 0x00, 0x40, 0x14, 0x50, 0xE7, 0x84, 0x24,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x13, 0x58, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x92, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x02, 0x80, 0x02, 0x3C, 0x84, 0x5B, 0x43, 0xAC,
+0x18, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C, 0xD0, 0xFF, 0xBD, 0x27,
+0x18, 0x03, 0x42, 0x34, 0x80, 0x2F, 0x63, 0x24, 0x24, 0x00, 0xB3, 0xAF,
+0x28, 0x00, 0xBF, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x43, 0xAC, 0x02, 0x80, 0x04, 0x3C,
+0xEC, 0x5D, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x13, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x06, 0x5E, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x60, 0x14, 0x01, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x0F, 0x5E, 0x44, 0xA0, 0x02, 0x80, 0x03, 0x3C,
+0xED, 0x5D, 0x64, 0x90, 0x01, 0x00, 0x05, 0x24, 0x4B, 0x2E, 0x00, 0x0C,
+0xFF, 0x00, 0x84, 0x30, 0x02, 0x80, 0x02, 0x3C, 0x98, 0x54, 0x43, 0x8C,
+0x98, 0x54, 0x42, 0x24, 0xA2, 0x00, 0x62, 0x10, 0x02, 0x80, 0x13, 0x3C,
+0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x02, 0x3C,
+0x36, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x90, 0x60, 0x1B, 0x66, 0x26,
+0xF4, 0x38, 0xC5, 0x8C, 0xC0, 0x18, 0x03, 0x00, 0x23, 0xB0, 0x04, 0x3C,
+0xF0, 0x07, 0x63, 0x30, 0xFF, 0x1F, 0x02, 0x3C, 0x21, 0x18, 0x64, 0x00,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x62, 0x00, 0x23, 0x88, 0x85, 0x00,
+0x00, 0x04, 0x22, 0x26, 0x2B, 0x28, 0x85, 0x00, 0x98, 0x38, 0xC3, 0x8C,
+0x0B, 0x88, 0x45, 0x00, 0xE1, 0x01, 0x22, 0x2E, 0x94, 0x38, 0xC3, 0xAC,
+0xF8, 0x38, 0xC4, 0xAC, 0x9E, 0x38, 0xC0, 0xA4, 0x14, 0x00, 0x40, 0x14,
+0x9D, 0x38, 0xC0, 0xA0, 0x20, 0xFE, 0x82, 0x24, 0x20, 0x02, 0x83, 0x24,
+0x0A, 0x18, 0x45, 0x00, 0x23, 0x10, 0x02, 0x3C, 0xFF, 0x03, 0x42, 0x34,
+0x2B, 0x10, 0x43, 0x00, 0x21, 0x28, 0x60, 0x00, 0x32, 0x00, 0x40, 0x14,
+0xF4, 0x38, 0xC3, 0xAC, 0xF8, 0x38, 0xC2, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x18, 0x45, 0x00, 0x23, 0x88, 0x45, 0x00, 0x03, 0x00, 0x60, 0x10,
+0xE1, 0x01, 0x22, 0x2E, 0x00, 0x04, 0x31, 0x26, 0xE1, 0x01, 0x22, 0x2E,
+0x0E, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x70, 0x26, 0x60, 0x1B, 0x70, 0x26,
+0xF8, 0x38, 0x03, 0x8E, 0xF4, 0x38, 0x04, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0x83, 0x00, 0x2C, 0x00, 0x40, 0x14, 0x2B, 0x10, 0x64, 0x00,
+0x56, 0x00, 0x40, 0x14, 0x25, 0xB0, 0x02, 0x3C, 0x80, 0x00, 0x03, 0x24,
+0xD0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x60, 0x1B, 0x70, 0x26,
+0xF4, 0x38, 0x03, 0x96, 0x2A, 0xB0, 0x02, 0x3C, 0x35, 0x00, 0x42, 0x34,
+0xC2, 0x88, 0x03, 0x00, 0x00, 0x00, 0x51, 0xA0, 0x73, 0x23, 0x00, 0x74,
+0x00, 0x00, 0x00, 0x00, 0x9E, 0x38, 0x03, 0x96, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xD0, 0x1B, 0x02, 0x8E, 0x80, 0x00, 0x03, 0x3C,
+0x41, 0xB0, 0x04, 0x3C, 0x25, 0x10, 0x43, 0x00, 0x00, 0x00, 0x82, 0xAC,
+0x28, 0x00, 0xBF, 0x8F, 0xD0, 0x1B, 0x02, 0xAE, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0x00, 0xFC, 0xA5, 0x24,
+0x23, 0x0C, 0x00, 0x08, 0xF4, 0x38, 0xC5, 0xAC, 0x24, 0x2D, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xA2, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xE2, 0x2C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x0B, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0x94, 0x38, 0x05, 0x8E, 0x21, 0x30, 0x80, 0x00,
+0xFF, 0xFF, 0x27, 0x32, 0x09, 0x00, 0x04, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x94, 0x38, 0x03, 0x8E, 0x9E, 0x38, 0x05, 0x96,
+0xF4, 0x38, 0x02, 0x8E, 0x21, 0x18, 0x71, 0x00, 0x21, 0x28, 0x25, 0x02,
+0x21, 0x10, 0x51, 0x00, 0x09, 0x00, 0x04, 0x24, 0xF4, 0x38, 0x02, 0xAE,
+0x94, 0x38, 0x03, 0xAE, 0x5B, 0x01, 0x00, 0x0C, 0x9E, 0x38, 0x05, 0xA6,
+0x60, 0x1B, 0x70, 0x26, 0xF4, 0x38, 0x03, 0x96, 0x2A, 0xB0, 0x02, 0x3C,
+0x35, 0x00, 0x42, 0x34, 0xC2, 0x88, 0x03, 0x00, 0x00, 0x00, 0x51, 0xA0,
+0x73, 0x23, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x9E, 0x38, 0x03, 0x96,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x1B, 0x02, 0x8E,
+0x80, 0x00, 0x03, 0x3C, 0x41, 0xB0, 0x04, 0x3C, 0x25, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x82, 0xAC, 0x28, 0x00, 0xBF, 0x8F, 0xD0, 0x1B, 0x02, 0xAE,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xFC, 0x38, 0x02, 0x8E, 0x94, 0x38, 0x05, 0x8E, 0x21, 0x30, 0x80, 0x00,
+0x23, 0x88, 0x44, 0x00, 0xFF, 0xFF, 0x27, 0x32, 0x09, 0x00, 0x04, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x94, 0x38, 0x03, 0x8E,
+0x9E, 0x38, 0x02, 0x96, 0xF8, 0x38, 0x12, 0x96, 0x21, 0x18, 0x71, 0x00,
+0x21, 0x10, 0x22, 0x02, 0x23, 0x10, 0x11, 0x3C, 0x94, 0x38, 0x03, 0xAE,
+0x9E, 0x38, 0x02, 0xA6, 0x15, 0x00, 0x40, 0x16, 0xF4, 0x38, 0x11, 0xAE,
+0x09, 0x00, 0x04, 0x24, 0x5B, 0x01, 0x00, 0x0C, 0x60, 0x1B, 0x70, 0x26,
+0x71, 0x0C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x24, 0x2D, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x5C, 0xFF, 0x40, 0x10, 0x60, 0x1B, 0x63, 0x26,
+0x2A, 0x1C, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x58, 0xFF, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x4C, 0x3A, 0x64, 0x94, 0x2A, 0x1C, 0x60, 0xA0,
+0x00, 0xC0, 0x84, 0x24, 0xA3, 0x31, 0x00, 0x0C, 0xFF, 0xFF, 0x84, 0x30,
+0x01, 0x0C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x01, 0x00, 0x0C,
+0x09, 0x00, 0x04, 0x24, 0x94, 0x38, 0x05, 0x8E, 0x09, 0x00, 0x04, 0x24,
+0x23, 0x10, 0x06, 0x3C, 0x21, 0x38, 0x40, 0x02, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x94, 0x38, 0x03, 0x8E, 0x9E, 0x38, 0x02, 0x96,
+0x21, 0x20, 0x51, 0x02, 0x21, 0x18, 0x72, 0x00, 0x21, 0x10, 0x42, 0x02,
+0xF4, 0x38, 0x04, 0xAE, 0x09, 0x00, 0x04, 0x24, 0x94, 0x38, 0x03, 0xAE,
+0x9E, 0x0C, 0x00, 0x08, 0x9E, 0x38, 0x02, 0xA6, 0x08, 0x00, 0xE0, 0x03,
+0x09, 0x00, 0x02, 0x24, 0xFF, 0x00, 0x86, 0x30, 0x02, 0x80, 0x02, 0x3C,
+0x40, 0x00, 0xC3, 0x2C, 0x4A, 0xF5, 0x47, 0x90, 0x00, 0x00, 0x63, 0x38,
+0x3F, 0x00, 0x02, 0x24, 0x0A, 0x30, 0x43, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x0E, 0x04, 0x24, 0x00, 0x7F, 0x05, 0x24, 0x03, 0x00, 0xE2, 0x10,
+0x31, 0x00, 0xC3, 0x2C, 0xC1, 0x43, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x30, 0x00, 0x02, 0x24, 0xC1, 0x43, 0x00, 0x08, 0x0A, 0x30, 0x43, 0x00,
+0xC0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x03, 0x3C, 0x38, 0x00, 0xB4, 0xAF,
+0x34, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xB2, 0xAF, 0x2C, 0x00, 0xB1, 0xAF,
+0x28, 0x00, 0xB0, 0xAF, 0xA4, 0xE7, 0x62, 0x24, 0x3C, 0x00, 0xBF, 0xAF,
+0x0A, 0x00, 0x4A, 0x94, 0x02, 0x00, 0x48, 0x94, 0x06, 0x00, 0x49, 0x94,
+0xFF, 0x00, 0x84, 0x30, 0xFF, 0x00, 0xA5, 0x30, 0xA4, 0xE7, 0x6B, 0x94,
+0x04, 0x00, 0x4C, 0x94, 0x08, 0x00, 0x4D, 0x94, 0x00, 0x1C, 0x05, 0x00,
+0x00, 0x14, 0x04, 0x00, 0x00, 0x3E, 0x05, 0x00, 0x00, 0x36, 0x04, 0x00,
+0x25, 0x38, 0xE3, 0x00, 0x25, 0x30, 0xC2, 0x00, 0x00, 0x44, 0x08, 0x00,
+0x00, 0x12, 0x05, 0x00, 0x00, 0x4C, 0x09, 0x00, 0x00, 0x54, 0x0A, 0x00,
+0x00, 0x1A, 0x04, 0x00, 0x25, 0x38, 0xE2, 0x00, 0x25, 0x40, 0x0B, 0x01,
+0x25, 0x48, 0x2C, 0x01, 0x25, 0x50, 0x4D, 0x01, 0x25, 0x30, 0xC3, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x10, 0x00, 0xA8, 0xAF, 0x14, 0x00, 0xA9, 0xAF,
+0x18, 0x00, 0xAA, 0xAF, 0x25, 0x98, 0xE5, 0x00, 0x25, 0x90, 0xC4, 0x00,
+0x60, 0x1B, 0x54, 0x24, 0x21, 0x80, 0x00, 0x00, 0x10, 0x00, 0xB1, 0x27,
+0x02, 0x00, 0x02, 0x2E, 0x32, 0x00, 0x40, 0x10, 0x80, 0x10, 0x10, 0x00,
+0x21, 0x10, 0x54, 0x00, 0xF0, 0x1C, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x40, 0x73, 0x00, 0x21, 0x38, 0x00, 0x00, 0x7F, 0x00, 0x09, 0x24,
+0xC0, 0x20, 0x07, 0x00, 0x04, 0x10, 0x89, 0x00, 0x24, 0x10, 0x48, 0x00,
+0x06, 0x10, 0x82, 0x00, 0x01, 0x00, 0xE5, 0x24, 0xFF, 0x00, 0x43, 0x30,
+0x21, 0x30, 0x27, 0x02, 0x40, 0x00, 0x63, 0x2C, 0xFF, 0x00, 0xA7, 0x30,
+0x02, 0x00, 0x60, 0x14, 0x04, 0x00, 0xE4, 0x2C, 0x3F, 0x00, 0x02, 0x24,
+0xF3, 0xFF, 0x80, 0x14, 0x10, 0x00, 0xC2, 0xA0, 0x23, 0x00, 0xA6, 0x93,
+0x22, 0x00, 0xA2, 0x93, 0x21, 0x00, 0xA5, 0x93, 0x40, 0x18, 0x10, 0x00,
+0x00, 0x14, 0x02, 0x00, 0x21, 0x18, 0x71, 0x00, 0x20, 0x00, 0xA7, 0x93,
+0x00, 0x36, 0x06, 0x00, 0x25, 0x30, 0xC2, 0x00, 0x00, 0x2A, 0x05, 0x00,
+0x00, 0x00, 0x64, 0x94, 0x25, 0x30, 0xC5, 0x00, 0x7F, 0x7F, 0x05, 0x3C,
+0x25, 0x30, 0xC7, 0x00, 0xC1, 0x43, 0x00, 0x0C, 0x7F, 0x7F, 0xA5, 0x34,
+0x01, 0x00, 0x02, 0x26, 0xFF, 0x00, 0x50, 0x30, 0x06, 0x00, 0x03, 0x2E,
+0xD5, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0xBF, 0x8F,
+0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F,
+0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x40, 0x00, 0xBD, 0x27, 0x21, 0x10, 0x54, 0x00, 0xF0, 0x1C, 0x43, 0x8C,
+0x07, 0x0D, 0x00, 0x08, 0x21, 0x40, 0x72, 0x00, 0xD8, 0xFF, 0xBD, 0x27,
+0x14, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x02, 0x3C,
+0xC6, 0x5C, 0x43, 0x90, 0x02, 0x80, 0x07, 0x3C, 0x60, 0x1B, 0xE2, 0x24,
+0xFF, 0x00, 0x91, 0x30, 0x21, 0x20, 0x22, 0x02, 0x20, 0x00, 0x62, 0x30,
+0x10, 0x00, 0x63, 0x30, 0x63, 0x1D, 0x93, 0x90, 0x27, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x8D, 0x1D, 0x82, 0x90, 0x7F, 0x1D, 0x83, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x23, 0x10, 0x43, 0x00, 0x00, 0x36, 0x02, 0x00,
+0x03, 0x36, 0x06, 0x00, 0xFF, 0x00, 0x70, 0x30, 0x60, 0x1B, 0xE7, 0x24,
+0x21, 0x40, 0x27, 0x02, 0xB7, 0x1D, 0x02, 0x91, 0xB0, 0x1B, 0xE3, 0x84,
+0x0F, 0x00, 0x05, 0x3C, 0x0F, 0x00, 0x42, 0x30, 0x21, 0x10, 0x50, 0x00,
+0x0C, 0x08, 0x04, 0x24, 0x0F, 0x00, 0xC6, 0x30, 0x00, 0xFF, 0xA5, 0x34,
+0x06, 0x00, 0x60, 0x04, 0xFF, 0x00, 0x52, 0x30, 0xC5, 0x1D, 0x02, 0x91,
+0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x21, 0x10, 0x50, 0x00,
+0xFF, 0x00, 0x50, 0x30, 0xC1, 0x43, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xC5, 0x0C, 0x00, 0x0C, 0x21, 0x20, 0x60, 0x02, 0x21, 0x20, 0x00, 0x02,
+0x21, 0x28, 0x40, 0x02, 0x21, 0x30, 0x20, 0x02, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0xD6, 0x0C, 0x00, 0x08, 0x28, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0xA9, 0x1D, 0x82, 0x90,
+0x9B, 0x1D, 0x83, 0x90, 0x4D, 0x0D, 0x00, 0x08, 0x23, 0x10, 0x43, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x02, 0x3C,
+0x18, 0x00, 0xBF, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0xD1, 0x5C, 0x43, 0x90,
+0x01, 0x00, 0x02, 0x24, 0x09, 0x00, 0x62, 0x10, 0xFF, 0x00, 0x90, 0x30,
+0x21, 0x30, 0x00, 0x02, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x18, 0x00, 0x04, 0x24, 0xFF, 0x03, 0x05, 0x24,
+0x83, 0x45, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27, 0x0F, 0x00, 0x05, 0x3C,
+0xFF, 0xFF, 0xA5, 0x34, 0x15, 0x00, 0x04, 0x24, 0x0A, 0x00, 0x03, 0x12,
+0xF4, 0xA8, 0x06, 0x34, 0x0F, 0x00, 0x05, 0x3C, 0x0B, 0x00, 0x02, 0x24,
+0xFF, 0xFF, 0xA5, 0x34, 0x05, 0x00, 0x02, 0x12, 0xF5, 0xF8, 0x06, 0x34,
+0x0F, 0x00, 0x05, 0x3C, 0xF4, 0xF8, 0x06, 0x34, 0x15, 0x00, 0x04, 0x24,
+0xFF, 0xFF, 0xA5, 0x34, 0x83, 0x45, 0x00, 0x0C, 0x0F, 0x00, 0x11, 0x3C,
+0x02, 0x80, 0x02, 0x3C, 0x48, 0xF5, 0x46, 0x90, 0xFE, 0x00, 0x03, 0x24,
+0x15, 0x00, 0x04, 0x24, 0xE3, 0xFF, 0xC3, 0x14, 0xFF, 0xFF, 0x25, 0x36,
+0xAC, 0x45, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x46, 0x30,
+0x00, 0xFF, 0x23, 0x36, 0x24, 0x10, 0x43, 0x00, 0x01, 0x00, 0xC6, 0x24,
+0x25, 0x30, 0x46, 0x00, 0xFF, 0xFF, 0x25, 0x36, 0x83, 0x45, 0x00, 0x0C,
+0x15, 0x00, 0x04, 0x24, 0x7F, 0x0D, 0x00, 0x08, 0x21, 0x30, 0x00, 0x02,
+0xFC, 0x00, 0x84, 0x30, 0x80, 0x00, 0x02, 0x24, 0x11, 0x00, 0x82, 0x10,
+0x06, 0x00, 0x03, 0x24, 0x81, 0x00, 0x82, 0x28, 0x10, 0x00, 0x40, 0x10,
+0xB0, 0x00, 0x02, 0x24, 0x20, 0x00, 0x02, 0x24, 0x0B, 0x00, 0x82, 0x10,
+0x02, 0x00, 0x03, 0x24, 0x21, 0x00, 0x82, 0x28, 0x15, 0x00, 0x40, 0x10,
+0x40, 0x00, 0x02, 0x24, 0x06, 0x00, 0x80, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x01, 0x00, 0x03, 0x24, 0x10, 0x00, 0x02, 0x24, 0x02, 0x00, 0x82, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x60, 0x00, 0xFD, 0xFF, 0x82, 0x10, 0x09, 0x00, 0x03, 0x24,
+0xB1, 0x00, 0x82, 0x28, 0x0F, 0x00, 0x40, 0x10, 0xC8, 0x00, 0x02, 0x24,
+0x90, 0x00, 0x02, 0x24, 0xF7, 0xFF, 0x82, 0x10, 0x07, 0x00, 0x03, 0x24,
+0x08, 0x00, 0x03, 0x24, 0xB9, 0x0D, 0x00, 0x08, 0xA0, 0x00, 0x02, 0x24,
+0xF2, 0xFF, 0x82, 0x10, 0x04, 0x00, 0x03, 0x24, 0x41, 0x00, 0x82, 0x28,
+0x0F, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x24,
+0xB9, 0x0D, 0x00, 0x08, 0x30, 0x00, 0x02, 0x24, 0xEA, 0xFF, 0x82, 0x10,
+0x0C, 0x00, 0x03, 0x24, 0xC9, 0x00, 0x82, 0x28, 0x04, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x03, 0x24, 0xB9, 0x0D, 0x00, 0x08,
+0xC0, 0x00, 0x02, 0x24, 0x0B, 0x00, 0x03, 0x24, 0xB9, 0x0D, 0x00, 0x08,
+0xD0, 0x00, 0x02, 0x24, 0x05, 0x00, 0x03, 0x24, 0xB9, 0x0D, 0x00, 0x08,
+0x50, 0x00, 0x02, 0x24, 0xD0, 0xFF, 0xBD, 0x27, 0x2C, 0x00, 0xBF, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x08, 0x00, 0x83, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x08, 0x00, 0x90, 0x94, 0x02, 0x80, 0x02, 0x3C, 0x21, 0x90, 0x80, 0x00,
+0x25, 0x80, 0x02, 0x02, 0xFF, 0x00, 0xB4, 0x30, 0x21, 0x20, 0x00, 0x02,
+0xFF, 0x00, 0xD1, 0x30, 0x21, 0x28, 0x00, 0x00, 0x08, 0x00, 0x06, 0x24,
+0xEC, 0x54, 0x00, 0x0C, 0xFF, 0x00, 0xF3, 0x30, 0x04, 0x00, 0x06, 0x8E,
+0x08, 0x00, 0x05, 0x8E, 0xFF, 0xDF, 0x02, 0x3C, 0xFF, 0xE0, 0x03, 0x24,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x30, 0xC3, 0x00, 0x24, 0x28, 0xA2, 0x00,
+0x3F, 0xFF, 0x02, 0x3C, 0x10, 0x00, 0x08, 0x8E, 0xFF, 0xFF, 0x42, 0x34,
+0x00, 0x12, 0xC6, 0x34, 0x00, 0x40, 0x03, 0x3C, 0x24, 0x30, 0xC2, 0x00,
+0x05, 0x00, 0x07, 0x24, 0x04, 0x00, 0x02, 0x24, 0x0B, 0x38, 0x54, 0x00,
+0x25, 0x28, 0xA3, 0x00, 0x01, 0x00, 0x84, 0x32, 0x7F, 0xFF, 0x03, 0x24,
+0x00, 0x80, 0x02, 0x3C, 0x14, 0x00, 0x09, 0x8E, 0x24, 0x28, 0xA3, 0x00,
+0xC0, 0x21, 0x04, 0x00, 0x25, 0x40, 0x02, 0x01, 0x03, 0x00, 0x31, 0x32,
+0xFF, 0xE0, 0x02, 0x3C, 0x80, 0x8D, 0x11, 0x00, 0x25, 0x28, 0xA4, 0x00,
+0xFF, 0xFF, 0x42, 0x34, 0x0C, 0x00, 0x4A, 0x8E, 0x25, 0x30, 0xD1, 0x00,
+0xFF, 0x81, 0x03, 0x24, 0xE0, 0xFF, 0x04, 0x24, 0x24, 0x28, 0xA2, 0x00,
+0x3F, 0x00, 0x73, 0x32, 0xFB, 0xFF, 0x02, 0x3C, 0x24, 0x48, 0x23, 0x01,
+0x24, 0x30, 0xC4, 0x00, 0x00, 0x1E, 0x07, 0x00, 0x40, 0x9A, 0x13, 0x00,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x40, 0x02, 0x01, 0x25, 0x48, 0x33, 0x01,
+0x25, 0x28, 0xA3, 0x00, 0x25, 0x30, 0xC7, 0x00, 0x20, 0x00, 0x02, 0x24,
+0x08, 0x00, 0x05, 0xAE, 0x00, 0x00, 0x0A, 0xA6, 0x02, 0x00, 0x02, 0xA2,
+0x10, 0x00, 0x08, 0xAE, 0x14, 0x00, 0x09, 0xAE, 0x04, 0x00, 0x06, 0xAE,
+0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x98, 0x54, 0x42, 0x24, 0x04, 0x00, 0x43, 0x8C, 0x00, 0x00, 0x42, 0xAE,
+0x04, 0x00, 0x52, 0xAC, 0x00, 0x00, 0x72, 0xAC, 0x04, 0x00, 0x43, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x2C, 0x00, 0xBF, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0xFF, 0xFF, 0x90, 0x30, 0x10, 0x00, 0xA4, 0x27, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x24, 0x00, 0xBF, 0xAF, 0xFF, 0x00, 0xB1, 0x30,
+0x8A, 0x40, 0x00, 0x0C, 0xFF, 0x00, 0xD2, 0x30, 0x00, 0x80, 0x02, 0x34,
+0x20, 0x00, 0x02, 0x12, 0x21, 0x20, 0x20, 0x02, 0x75, 0x0D, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x03, 0x3C, 0x03, 0x02, 0x63, 0x34,
+0x00, 0x00, 0x62, 0x90, 0x00, 0x08, 0x04, 0x24, 0x01, 0x00, 0x05, 0x24,
+0x04, 0x00, 0x42, 0x34, 0x00, 0x00, 0x62, 0xA0, 0x35, 0x45, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x00, 0x09, 0x04, 0x24, 0x01, 0x00, 0x05, 0x24,
+0x35, 0x45, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x84, 0x08, 0x04, 0x24,
+0xFF, 0xFF, 0x05, 0x24, 0x35, 0x45, 0x00, 0x0C, 0x58, 0x00, 0x06, 0x24,
+0x18, 0x00, 0x04, 0x24, 0x00, 0x0C, 0x05, 0x24, 0x83, 0x45, 0x00, 0x0C,
+0x01, 0x00, 0x06, 0x24, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x01, 0x00, 0x02, 0x24, 0x02, 0x00, 0x42, 0x12, 0x02, 0x00, 0x24, 0x26,
+0xFE, 0xFF, 0x24, 0x26, 0x75, 0x0D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x07, 0x3C, 0x03, 0x02, 0xE7, 0x34, 0x00, 0x00, 0xE3, 0x90,
+0xFB, 0xFF, 0x02, 0x24, 0x00, 0x08, 0x04, 0x24, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x00, 0xE3, 0xA0, 0x01, 0x00, 0x05, 0x24, 0x35, 0x45, 0x00, 0x0C,
+0x01, 0x00, 0x06, 0x24, 0x03, 0x00, 0x50, 0x32, 0x00, 0x09, 0x04, 0x24,
+0x01, 0x00, 0x05, 0x24, 0x35, 0x45, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24,
+0x42, 0x30, 0x10, 0x00, 0x00, 0x0A, 0x04, 0x24, 0x35, 0x45, 0x00, 0x0C,
+0x10, 0x00, 0x05, 0x24, 0x21, 0x30, 0x00, 0x02, 0x00, 0x0D, 0x04, 0x24,
+0x35, 0x45, 0x00, 0x0C, 0x00, 0x0C, 0x05, 0x24, 0x84, 0x08, 0x04, 0x24,
+0xFF, 0xFF, 0x05, 0x24, 0x35, 0x45, 0x00, 0x0C, 0x18, 0x00, 0x06, 0x24,
+0x18, 0x00, 0x04, 0x24, 0x00, 0x0C, 0x05, 0x24, 0x83, 0x45, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0xD0, 0xFF, 0xBD, 0x27, 0x24, 0x00, 0xB3, 0xAF, 0x02, 0x80, 0x13, 0x3C,
+0x20, 0x00, 0xB2, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0x72, 0x26,
+0xFF, 0xFF, 0x90, 0x30, 0x10, 0x00, 0xA4, 0x27, 0x1C, 0x00, 0xB1, 0xAF,
+0x28, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0xFF, 0x00, 0xB1, 0x30,
+0xB0, 0x1B, 0x42, 0x96, 0x10, 0x00, 0xA4, 0x27, 0x00, 0x80, 0x42, 0x30,
+0x11, 0x00, 0x50, 0x10, 0x21, 0x30, 0x20, 0x02, 0xC4, 0x3D, 0x45, 0x92,
+0x3C, 0x0E, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02, 0x00, 0x80, 0x02, 0x34,
+0x14, 0x00, 0x02, 0x12, 0x00, 0x80, 0x02, 0x24, 0xB0, 0x1B, 0x42, 0x96,
+0x3B, 0x41, 0x51, 0xA2, 0xFF, 0x7F, 0x42, 0x30, 0xB0, 0x1B, 0x42, 0xA6,
+0x60, 0x1B, 0x62, 0x26, 0xB0, 0x1B, 0x45, 0x94, 0xC4, 0x3D, 0x44, 0x90,
+0x38, 0x0D, 0x00, 0x0C, 0x00, 0x10, 0xA5, 0x30, 0x10, 0x00, 0xA4, 0x27,
+0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0xBF, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xB0, 0x1B, 0x43, 0x96, 0x3B, 0x41, 0x51, 0xA2, 0x25, 0x18, 0x62, 0x00,
+0xB0, 0x0E, 0x00, 0x08, 0xB0, 0x1B, 0x43, 0xA6, 0xE0, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x14, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xBF, 0xAF, 0x53, 0x21, 0x00, 0x0C, 0x28, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0x21, 0x88, 0x40, 0x00, 0x21, 0x28, 0x00, 0x02,
+0x06, 0x00, 0x06, 0x24, 0x15, 0x00, 0x40, 0x10, 0xAC, 0xE8, 0x84, 0x24,
+0x08, 0x00, 0x44, 0x94, 0x08, 0x00, 0x02, 0x24, 0x0C, 0x00, 0x22, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0x0C, 0x00, 0x03, 0x24, 0x25, 0x20, 0x82, 0x00,
+0x14, 0x00, 0x23, 0xAE, 0xF4, 0x54, 0x00, 0x0C, 0x20, 0x00, 0x84, 0x24,
+0x17, 0x0A, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0x04, 0xE9, 0x84, 0x24, 0x21, 0x10, 0x00, 0x00,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x05, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xEC, 0xE8, 0xA5, 0x24, 0xE0, 0x0E, 0x00, 0x08,
+0xFF, 0xFF, 0x02, 0x24, 0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB3, 0xAF,
+0x21, 0x98, 0x80, 0x00, 0x2C, 0x00, 0x04, 0x24, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x21, 0x90, 0xA0, 0x00, 0x20, 0x00, 0xBF, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x04, 0x3C,
+0x02, 0x80, 0x05, 0x3C, 0x21, 0x88, 0x40, 0x00, 0x28, 0xE9, 0x84, 0x24,
+0x21, 0x30, 0x40, 0x02, 0x19, 0x00, 0x40, 0x10, 0x10, 0xE9, 0xA5, 0x24,
+0x05, 0x00, 0x65, 0x92, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x30, 0x96, 0x02, 0x80, 0x02, 0x3C, 0x0B, 0x00, 0x03, 0x24,
+0x25, 0x80, 0x02, 0x02, 0x20, 0x00, 0x10, 0x26, 0x0C, 0x00, 0x02, 0x24,
+0x21, 0x20, 0x00, 0x02, 0x0C, 0x00, 0x22, 0xAE, 0x14, 0x00, 0x23, 0xAE,
+0x21, 0x28, 0x60, 0x02, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x08, 0x00, 0x12, 0xAE, 0x21, 0x20, 0x20, 0x02, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x17, 0x0A, 0x00, 0x08, 0x28, 0x00, 0xBD, 0x27,
+0x02, 0x80, 0x04, 0x3C, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0xAC, 0xE8, 0x84, 0x24, 0x13, 0x58, 0x00, 0x08, 0x28, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90,
+0x02, 0x80, 0x11, 0x3C, 0x04, 0x00, 0x04, 0x24, 0x0F, 0x00, 0x63, 0x30,
+0x04, 0x00, 0x63, 0x28, 0x3A, 0x00, 0x60, 0x14, 0x01, 0x00, 0x05, 0x24,
+0x40, 0xDF, 0x23, 0x8E, 0x0F, 0x00, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xFF, 0xFF, 0xA5, 0x34, 0x24, 0x00, 0x04, 0x24, 0x60, 0x00, 0x06, 0x24,
+0x12, 0x00, 0x60, 0x14, 0x60, 0x1B, 0x50, 0x24, 0x83, 0x45, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x48, 0x41, 0x05, 0x92, 0xD0, 0x07, 0x02, 0x24,
+0x01, 0x00, 0x03, 0x24, 0x0A, 0x10, 0x05, 0x00, 0x3C, 0x3A, 0x02, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0xED, 0x5D, 0x44, 0x90, 0x40, 0xDF, 0x23, 0xAE,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x01, 0x00, 0x05, 0x24, 0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08,
+0x20, 0x00, 0xBD, 0x27, 0x0F, 0x00, 0x05, 0x3C, 0xFF, 0xFF, 0xA5, 0x34,
+0xAC, 0x45, 0x00, 0x0C, 0x24, 0x00, 0x04, 0x24, 0x49, 0x41, 0x04, 0x92,
+0xFF, 0x00, 0x43, 0x30, 0x00, 0x2C, 0x03, 0x00, 0x0A, 0x00, 0x64, 0x10,
+0x4A, 0x41, 0x02, 0xA2, 0x02, 0x80, 0x02, 0x3C, 0x49, 0xF5, 0x44, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x04, 0x00, 0x12, 0x27, 0x00, 0x74,
+0x25, 0x20, 0xA4, 0x00, 0x4A, 0x41, 0x03, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x49, 0x41, 0x03, 0xA2, 0x48, 0x41, 0x03, 0x92, 0x10, 0x27, 0x02, 0x24,
+0x40, 0xDF, 0x20, 0xAE, 0x0A, 0x10, 0x03, 0x00, 0x3C, 0x3A, 0x02, 0xAE,
+0x02, 0x80, 0x02, 0x3C, 0xED, 0x5D, 0x44, 0x90, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27,
+0x4B, 0x2E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x28, 0x0F, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xC8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x34, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xBE, 0xAF,
+0x2C, 0x00, 0xB7, 0xAF, 0x28, 0x00, 0xB6, 0xAF, 0x24, 0x00, 0xB5, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x21, 0x80, 0x80, 0x00, 0x45, 0x00, 0xA0, 0x14, 0x21, 0x90, 0x00, 0x00,
+0x08, 0x00, 0x82, 0x90, 0x02, 0x80, 0x13, 0x3C, 0x60, 0x1B, 0x63, 0x26,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x40, 0x62, 0xAC, 0x25, 0xB0, 0x02, 0x3C,
+0x0A, 0x00, 0x10, 0x26, 0xD0, 0x01, 0x57, 0x34, 0x02, 0x80, 0x14, 0x3C,
+0xD8, 0x01, 0x5E, 0x34, 0xDC, 0x01, 0x55, 0x34, 0xD4, 0x01, 0x56, 0x34,
+0x03, 0x00, 0x11, 0x24, 0x00, 0x00, 0x06, 0x92, 0x60, 0x1B, 0x62, 0x26,
+0xB8, 0x40, 0x47, 0x90, 0x0F, 0x00, 0xC3, 0x30, 0x01, 0x00, 0x05, 0x92,
+0x18, 0x00, 0x67, 0x00, 0x03, 0x00, 0x04, 0x92, 0x02, 0x00, 0x02, 0x92,
+0x0F, 0x00, 0xA7, 0x30, 0x00, 0x3A, 0x07, 0x00, 0x02, 0x29, 0x05, 0x00,
+0x00, 0x22, 0x04, 0x00, 0x25, 0x20, 0x82, 0x00, 0x00, 0x2B, 0x05, 0x00,
+0x42, 0x11, 0x06, 0x00, 0x00, 0x24, 0x04, 0x00, 0x03, 0x00, 0x49, 0x30,
+0x02, 0x31, 0x06, 0x00, 0x01, 0x00, 0x02, 0x24, 0x01, 0x00, 0xC6, 0x30,
+0x12, 0x18, 0x00, 0x00, 0x0A, 0x00, 0x63, 0x24, 0xFF, 0x00, 0x63, 0x30,
+0x25, 0x18, 0x67, 0x00, 0x25, 0x18, 0x65, 0x00, 0x30, 0x00, 0x22, 0x11,
+0x25, 0x38, 0x64, 0x00, 0x02, 0x00, 0x22, 0x29, 0x3E, 0x00, 0x40, 0x14,
+0x02, 0x00, 0x02, 0x24, 0x38, 0x00, 0x22, 0x11, 0x03, 0x00, 0x02, 0x24,
+0x40, 0x00, 0x22, 0x11, 0x00, 0x00, 0x00, 0x00, 0x21, 0x28, 0x20, 0x01,
+0x64, 0xE9, 0x84, 0x26, 0x13, 0x58, 0x00, 0x0C, 0xFF, 0xFF, 0x31, 0x26,
+0xD9, 0xFF, 0x21, 0x06, 0x04, 0x00, 0x10, 0x26, 0x25, 0xB0, 0x02, 0x3C,
+0xE7, 0x01, 0x42, 0x34, 0x00, 0x00, 0x52, 0xA0, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xBE, 0x8F, 0x2C, 0x00, 0xB7, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x13, 0x3C,
+0x08, 0x00, 0x83, 0x90, 0x60, 0x1B, 0x62, 0x26, 0xC0, 0x40, 0x44, 0x8C,
+0x0F, 0x00, 0x63, 0x30, 0xBB, 0xFF, 0x83, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xBE, 0x8F, 0x2C, 0x00, 0xB7, 0x8F,
+0x28, 0x00, 0xB6, 0x8F, 0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0xA7, 0xAE, 0x21, 0x20, 0x00, 0x00, 0x25, 0xB0, 0x08, 0x3C,
+0x07, 0x10, 0x92, 0x00, 0x01, 0x00, 0x42, 0x30, 0x01, 0x00, 0x84, 0x24,
+0x02, 0x00, 0x40, 0x10, 0x03, 0x00, 0x85, 0x2C, 0xD0, 0x01, 0x07, 0xAD,
+0xF9, 0xFF, 0xA0, 0x14, 0x04, 0x00, 0x08, 0x25, 0xA3, 0x0F, 0x00, 0x08,
+0x21, 0x28, 0x20, 0x01, 0x0D, 0x00, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xA2, 0x0F, 0x00, 0x08, 0x02, 0x00, 0x52, 0x36, 0xC7, 0xFF, 0x20, 0x15,
+0x21, 0x28, 0x20, 0x01, 0x0D, 0x00, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xA3, 0x0F, 0x00, 0x08, 0x04, 0x00, 0x52, 0x36, 0x06, 0x00, 0xC0, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xA2, 0x0F, 0x00, 0x08, 0x01, 0x00, 0x52, 0x36,
+0x00, 0x00, 0xC7, 0xAE, 0xA3, 0x0F, 0x00, 0x08, 0x21, 0x28, 0x20, 0x01,
+0x00, 0x00, 0xE7, 0xAE, 0xA3, 0x0F, 0x00, 0x08, 0x21, 0x28, 0x20, 0x01,
+0x00, 0x00, 0xC7, 0xAF, 0xA3, 0x0F, 0x00, 0x08, 0x21, 0x28, 0x20, 0x01,
+0xB8, 0xFF, 0xBD, 0x27, 0x24, 0x00, 0xB1, 0xAF, 0x21, 0x88, 0x80, 0x00,
+0x00, 0x01, 0x04, 0x24, 0x2C, 0x00, 0xB3, 0xAF, 0x44, 0x00, 0xBF, 0xAF,
+0x40, 0x00, 0xBE, 0xAF, 0x3C, 0x00, 0xB7, 0xAF, 0x38, 0x00, 0xB6, 0xAF,
+0x34, 0x00, 0xB5, 0xAF, 0x30, 0x00, 0xB4, 0xAF, 0x28, 0x00, 0xB2, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0x20, 0x00, 0xB0, 0xAF, 0xAC, 0x00, 0x40, 0x10,
+0x21, 0x98, 0x40, 0x00, 0x08, 0x00, 0x50, 0x94, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x28, 0x20, 0x02, 0x25, 0x80, 0x02, 0x02, 0x24, 0x00, 0x04, 0x26,
+0x20, 0x00, 0x00, 0xA6, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x05, 0x3C, 0x2A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0xB4, 0x55, 0xA5, 0x24, 0x06, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x30, 0x00, 0x04, 0x26, 0x20, 0x00, 0x03, 0x96, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x54, 0x24, 0x03, 0xFF, 0x63, 0x30, 0x50, 0x00, 0x63, 0x34,
+0x20, 0x00, 0x03, 0xA6, 0xE4, 0x1D, 0x82, 0x96, 0x02, 0x80, 0x03, 0x3C,
+0xB0, 0x55, 0x63, 0x24, 0x74, 0x00, 0x72, 0x24, 0xFF, 0x0F, 0x43, 0x30,
+0x00, 0x19, 0x03, 0x00, 0x01, 0x00, 0x42, 0x24, 0x02, 0x22, 0x03, 0x00,
+0xE4, 0x1D, 0x82, 0xA6, 0x20, 0x00, 0x11, 0x26, 0x20, 0x00, 0x02, 0x24,
+0x16, 0x00, 0x23, 0xA2, 0x17, 0x00, 0x24, 0xA2, 0x21, 0x20, 0x40, 0x02,
+0xFB, 0x51, 0x00, 0x0C, 0x0C, 0x00, 0x62, 0xAE, 0x40, 0x00, 0x11, 0x26,
+0x21, 0x20, 0x20, 0x02, 0x21, 0x28, 0x40, 0x00, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x0C, 0x00, 0x63, 0x8E, 0x21, 0x20, 0x40, 0x02,
+0x42, 0x00, 0x11, 0x26, 0x02, 0x00, 0x63, 0x24, 0x16, 0x52, 0x00, 0x0C,
+0x0C, 0x00, 0x63, 0xAE, 0x21, 0x28, 0x40, 0x00, 0x21, 0x20, 0x20, 0x02,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24, 0x0C, 0x00, 0x63, 0x8E,
+0x02, 0x80, 0x02, 0x3C, 0xB0, 0x55, 0x42, 0x24, 0x02, 0x00, 0x63, 0x24,
+0x0C, 0x00, 0x63, 0xAE, 0x0C, 0x00, 0x46, 0x8C, 0x44, 0x00, 0x04, 0x26,
+0x0C, 0x00, 0x76, 0x26, 0x60, 0x00, 0x50, 0x24, 0x21, 0x28, 0x00, 0x00,
+0x10, 0x00, 0x47, 0x24, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB6, 0xAF,
+0x21, 0x20, 0x00, 0x02, 0x1B, 0x53, 0x00, 0x0C, 0x21, 0x88, 0x40, 0x00,
+0x09, 0x00, 0x43, 0x2C, 0x08, 0x00, 0x06, 0x24, 0x21, 0x20, 0x20, 0x02,
+0x0B, 0x30, 0x43, 0x00, 0x21, 0x38, 0x00, 0x02, 0x01, 0x00, 0x05, 0x24,
+0x18, 0x00, 0xA3, 0xAF, 0x21, 0xB8, 0x40, 0x00, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xB6, 0xAF, 0x21, 0x20, 0x40, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0xB0, 0x55, 0x42, 0x24, 0x03, 0x00, 0x05, 0x24, 0x01, 0x00, 0x06, 0x24,
+0x48, 0x00, 0x47, 0x24, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB6, 0xAF,
+0x21, 0x88, 0x40, 0x00, 0xC0, 0x3A, 0x82, 0x8E, 0x0C, 0x00, 0x10, 0x24,
+0x2B, 0x10, 0x02, 0x02, 0x3A, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x26, 0x56, 0x5E, 0x24, 0x68, 0x10, 0x00, 0x08, 0x21, 0xA8, 0x80, 0x02,
+0x21, 0x10, 0x12, 0x02, 0x01, 0x00, 0x43, 0x90, 0xC0, 0x3A, 0xA4, 0x8E,
+0x21, 0x18, 0x70, 0x00, 0x02, 0x00, 0x70, 0x24, 0x2B, 0x20, 0x04, 0x02,
+0x2F, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x12, 0x02,
+0x00, 0x00, 0x47, 0x90, 0x02, 0x80, 0x14, 0x3C, 0x2D, 0x00, 0x03, 0x24,
+0x21, 0x28, 0x1E, 0x02, 0x64, 0x5C, 0x84, 0x26, 0xF1, 0xFF, 0xE3, 0x14,
+0x20, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x41, 0xA3, 0x96, 0x02, 0x80, 0x02, 0x3C, 0xC6, 0x5C, 0x47, 0x90,
+0xBD, 0xFF, 0x63, 0x30, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0x0C, 0x00, 0x63, 0x34, 0x01, 0x00, 0xE7, 0x30, 0x44, 0xDF, 0xA5, 0x24,
+0x67, 0x5C, 0x44, 0x24, 0x10, 0x00, 0x06, 0x24, 0x06, 0x00, 0xE0, 0x14,
+0x04, 0x41, 0xA3, 0xA6, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x54, 0xDF, 0xA5, 0x24, 0x67, 0x5C, 0x64, 0x24, 0x10, 0x00, 0x06, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x12, 0x02,
+0x01, 0x00, 0x46, 0x90, 0x21, 0x20, 0x20, 0x02, 0x64, 0x5C, 0x87, 0x26,
+0x2D, 0x00, 0x05, 0x24, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB6, 0xAF,
+0x21, 0x88, 0x40, 0x00, 0x21, 0x10, 0x12, 0x02, 0x01, 0x00, 0x43, 0x90,
+0xC0, 0x3A, 0xA4, 0x8E, 0x21, 0x18, 0x70, 0x00, 0x02, 0x00, 0x70, 0x24,
+0x2B, 0x20, 0x04, 0x02, 0xD4, 0xFF, 0x80, 0x14, 0x21, 0x10, 0x12, 0x02,
+0x18, 0x00, 0xA2, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, 0x10,
+0x21, 0x20, 0x60, 0x02, 0x44, 0x00, 0xBF, 0x8F, 0x40, 0x00, 0xBE, 0x8F,
+0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F, 0x34, 0x00, 0xB5, 0x8F,
+0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F,
+0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0x21, 0x30, 0x00, 0x00, 0x21, 0x38, 0x00, 0x00, 0xDF, 0x0D, 0x00, 0x08,
+0x48, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x44, 0x00, 0xBF, 0x8F, 0x40, 0x00, 0xBE, 0x8F, 0x3C, 0x00, 0xB7, 0x8F,
+0x38, 0x00, 0xB6, 0x8F, 0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F,
+0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F,
+0x20, 0x00, 0xB0, 0x8F, 0x58, 0xE9, 0x84, 0x24, 0xAC, 0xE9, 0xA5, 0x24,
+0x13, 0x58, 0x00, 0x08, 0x48, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x03, 0x3C,
+0xB0, 0x55, 0x63, 0x24, 0x21, 0x20, 0x20, 0x02, 0xF8, 0xFF, 0xE6, 0x26,
+0x68, 0x00, 0x67, 0x24, 0x32, 0x00, 0x05, 0x24, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xB6, 0xAF, 0x21, 0x20, 0x60, 0x02, 0x44, 0x00, 0xBF, 0x8F,
+0x40, 0x00, 0xBE, 0x8F, 0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F,
+0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F,
+0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F,
+0x01, 0x00, 0x05, 0x24, 0x21, 0x30, 0x00, 0x00, 0x21, 0x38, 0x00, 0x00,
+0xDF, 0x0D, 0x00, 0x08, 0x48, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x20, 0x00, 0xBF, 0xAF,
+0x02, 0x00, 0x82, 0x90, 0x02, 0x80, 0x03, 0x3C, 0x10, 0x37, 0x65, 0x94,
+0x0F, 0x00, 0x42, 0x30, 0x00, 0x00, 0x83, 0x8C, 0xC0, 0x10, 0x02, 0x00,
+0x21, 0x20, 0x44, 0x00, 0x00, 0x10, 0xA8, 0x30, 0x02, 0x80, 0x02, 0x3C,
+0x00, 0x08, 0xA5, 0x30, 0xB0, 0x55, 0x51, 0x24, 0xFF, 0x3F, 0x63, 0x30,
+0x06, 0x00, 0xA0, 0x10, 0x18, 0x00, 0x90, 0x24, 0xE8, 0xFF, 0x67, 0x24,
+0x30, 0x00, 0x84, 0x24, 0x21, 0x28, 0x00, 0x00, 0x07, 0x00, 0x00, 0x11,
+0x10, 0x00, 0xA6, 0x27, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xAB, 0x1A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xF7, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x44, 0x24,
+0x10, 0x00, 0xA2, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x10,
+0x10, 0x00, 0x25, 0x26, 0x0C, 0x00, 0x26, 0x8E, 0x1D, 0x55, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xED, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x26, 0x53, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02, 0xEE, 0x0F, 0x00, 0x0C,
+0x21, 0x20, 0x40, 0x00, 0xE8, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0xA0, 0xFF, 0xBD, 0x27, 0x58, 0x00, 0xBE, 0xAF, 0x5C, 0x00, 0xBF, 0xAF,
+0x54, 0x00, 0xB7, 0xAF, 0x50, 0x00, 0xB6, 0xAF, 0x4C, 0x00, 0xB5, 0xAF,
+0x48, 0x00, 0xB4, 0xAF, 0x44, 0x00, 0xB3, 0xAF, 0x40, 0x00, 0xB2, 0xAF,
+0x3C, 0x00, 0xB1, 0xAF, 0x38, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x3F, 0x46, 0x30, 0xE8, 0xFF, 0xC5, 0x24,
+0x01, 0x03, 0xA2, 0x2C, 0x16, 0x00, 0x40, 0x14, 0x21, 0xF0, 0x80, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x63, 0x24, 0x40, 0x3E, 0x62, 0x8C,
+0x02, 0x80, 0x04, 0x3C, 0xD0, 0xE9, 0x84, 0x24, 0x01, 0x00, 0x42, 0x24,
+0x40, 0x3E, 0x62, 0xAC, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x5C, 0x00, 0xBF, 0x8F, 0x58, 0x00, 0xBE, 0x8F, 0x54, 0x00, 0xB7, 0x8F,
+0x50, 0x00, 0xB6, 0x8F, 0x4C, 0x00, 0xB5, 0x8F, 0x48, 0x00, 0xB4, 0x8F,
+0x44, 0x00, 0xB3, 0x8F, 0x40, 0x00, 0xB2, 0x8F, 0x3C, 0x00, 0xB1, 0x8F,
+0x38, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x60, 0x00, 0xBD, 0x27,
+0x7C, 0x00, 0xC4, 0x24, 0x5C, 0x00, 0xC6, 0x24, 0x53, 0x21, 0x00, 0x0C,
+0x24, 0x00, 0xA6, 0xAF, 0x74, 0x00, 0x40, 0x10, 0x20, 0x00, 0xA2, 0xAF,
+0x20, 0x00, 0xA3, 0x8F, 0x24, 0x00, 0xA6, 0x8F, 0x21, 0x28, 0x00, 0x00,
+0x08, 0x00, 0x62, 0x94, 0x02, 0x80, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00,
+0x20, 0x00, 0x57, 0x24, 0xE3, 0x54, 0x00, 0x0C, 0x21, 0x20, 0xE0, 0x02,
+0x02, 0x80, 0x03, 0x3C, 0xE8, 0xE9, 0x62, 0x24, 0xE8, 0xE9, 0x67, 0x90,
+0x01, 0x00, 0x44, 0x90, 0x02, 0x00, 0xC3, 0x93, 0x02, 0x00, 0x45, 0x90,
+0x03, 0x00, 0x46, 0x90, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x50, 0x24,
+0x00, 0x00, 0xC2, 0x8F, 0x00, 0x22, 0x04, 0x00, 0x0F, 0x00, 0x63, 0x30,
+0x25, 0x20, 0x87, 0x00, 0x00, 0x2C, 0x05, 0x00, 0xC0, 0x18, 0x03, 0x00,
+0x4B, 0x41, 0x07, 0x92, 0x21, 0x18, 0x7E, 0x00, 0x25, 0x28, 0xA4, 0x00,
+0xFF, 0x3F, 0x42, 0x30, 0x00, 0x36, 0x06, 0x00, 0x25, 0x30, 0xC5, 0x00,
+0x30, 0x00, 0xA2, 0xAF, 0x22, 0x00, 0x64, 0x24, 0x18, 0x00, 0x62, 0x24,
+0x10, 0x00, 0xA6, 0xAF, 0x2C, 0x00, 0xA4, 0xAF, 0x28, 0x00, 0xA2, 0xAF,
+0x53, 0x00, 0xE0, 0x14, 0x28, 0x00, 0x76, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x54, 0x24, 0xA5, 0x59, 0x73, 0x24,
+0x21, 0x90, 0x00, 0x00, 0x01, 0x00, 0x15, 0x24, 0x64, 0x11, 0x00, 0x08,
+0x21, 0x80, 0x00, 0x00, 0x1D, 0x55, 0x00, 0x0C, 0x01, 0x00, 0x52, 0x26,
+0x07, 0x00, 0x10, 0x26, 0x32, 0x00, 0x40, 0x10, 0x40, 0x00, 0x43, 0x2A,
+0x0C, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x88, 0x14, 0x02,
+0x44, 0x3E, 0x22, 0x92, 0x21, 0x20, 0x13, 0x02, 0x21, 0x28, 0xC0, 0x02,
+0xF4, 0xFF, 0x55, 0x10, 0x06, 0x00, 0x06, 0x24, 0x21, 0x20, 0x13, 0x02,
+0x21, 0x28, 0xC0, 0x02, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x44, 0x3E, 0x35, 0xA2, 0x30, 0x00, 0xA4, 0x8F, 0x74, 0x00, 0xF4, 0x26,
+0x80, 0x00, 0xF3, 0x26, 0x5C, 0x00, 0x83, 0x24, 0xE8, 0xFF, 0x82, 0x24,
+0x1C, 0x00, 0xA2, 0xAF, 0x00, 0x00, 0xE3, 0xAE, 0x28, 0x00, 0xA3, 0x8F,
+0x1C, 0x00, 0xA2, 0x8F, 0x21, 0x20, 0x80, 0x02, 0x18, 0x00, 0x65, 0x24,
+0x21, 0x30, 0x40, 0x00, 0xF4, 0x54, 0x00, 0x0C, 0x70, 0x00, 0xE2, 0xAE,
+0x70, 0x00, 0xE7, 0x8E, 0x21, 0x20, 0x60, 0x02, 0x21, 0x28, 0x00, 0x00,
+0xF4, 0xFF, 0xE7, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x1C, 0x00, 0xA6, 0x27,
+0x0F, 0x00, 0x40, 0x10, 0x21, 0x80, 0x40, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x60, 0x1B, 0x91, 0x24, 0x0C, 0x3E, 0x26, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x32, 0x00, 0xC0, 0x18, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xA2, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x29, 0x00, 0xC2, 0x10, 0x02, 0x80, 0x04, 0x3C,
+0xC0, 0x10, 0x12, 0x00, 0x23, 0x10, 0x52, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x44, 0x3E, 0x40, 0xA0, 0x20, 0x00, 0xA4, 0x8F, 0x74, 0x21, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x5C, 0x00, 0xBF, 0x8F, 0x58, 0x00, 0xBE, 0x8F,
+0x54, 0x00, 0xB7, 0x8F, 0x50, 0x00, 0xB6, 0x8F, 0x4C, 0x00, 0xB5, 0x8F,
+0x48, 0x00, 0xB4, 0x8F, 0x44, 0x00, 0xB3, 0x8F, 0x40, 0x00, 0xB2, 0x8F,
+0x3C, 0x00, 0xB1, 0x8F, 0x38, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x60, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0xAC, 0xE8, 0x84, 0x24, 0x1B, 0x11, 0x00, 0x08, 0xBC, 0xE9, 0xA5, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0xAC, 0x5C, 0x84, 0x24, 0x21, 0x28, 0xC0, 0x02,
+0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0xA8, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x8A, 0x40, 0x00, 0x0C, 0x18, 0x00, 0xA4, 0x27,
+0x52, 0x41, 0x02, 0x92, 0x18, 0x00, 0xA4, 0x27, 0x01, 0x00, 0x42, 0x24,
+0x90, 0x40, 0x00, 0x0C, 0x52, 0x41, 0x02, 0xA2, 0x56, 0x11, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0x70, 0x59, 0x84, 0x24, 0x1D, 0x55, 0x00, 0x0C,
+0x02, 0x00, 0x05, 0x26, 0xD5, 0xFF, 0x40, 0x14, 0xC0, 0x10, 0x12, 0x00,
+0x01, 0x00, 0x06, 0x92, 0x00, 0x00, 0x00, 0x00, 0x69, 0x00, 0xC0, 0x14,
+0x10, 0x00, 0xE4, 0x26, 0x0C, 0x00, 0xE0, 0xAE, 0x02, 0x00, 0xC2, 0x97,
+0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x04, 0x00, 0x42, 0x28,
+0x5E, 0x00, 0x40, 0x10, 0x21, 0x20, 0xC0, 0x03, 0x34, 0x00, 0xE0, 0xAE,
+0x60, 0x00, 0xF1, 0x26, 0x21, 0x20, 0x20, 0x02, 0x21, 0x28, 0x00, 0x00,
+0xE3, 0x54, 0x00, 0x0C, 0x10, 0x00, 0x06, 0x24, 0x70, 0x00, 0xE7, 0x8E,
+0x21, 0x20, 0x60, 0x02, 0x01, 0x00, 0x05, 0x24, 0xF4, 0xFF, 0xE7, 0x24,
+0xAB, 0x1A, 0x00, 0x0C, 0x1C, 0x00, 0xA6, 0x27, 0x06, 0x00, 0x40, 0x10,
+0x21, 0x90, 0x00, 0x00, 0x1C, 0x00, 0xA6, 0x8F, 0x02, 0x00, 0x45, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02, 0x1C, 0x00, 0xB2, 0x8F,
+0x70, 0x00, 0xE7, 0x8E, 0x21, 0x20, 0x60, 0x02, 0x32, 0x00, 0x05, 0x24,
+0xF4, 0xFF, 0xE7, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x1C, 0x00, 0xA6, 0x27,
+0x05, 0x00, 0x40, 0x10, 0x21, 0x20, 0xF2, 0x02, 0x1C, 0x00, 0xA6, 0x8F,
+0x60, 0x00, 0x84, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x45, 0x24,
+0x1C, 0x00, 0xA5, 0x8F, 0x21, 0x20, 0x20, 0x02, 0x61, 0x53, 0x00, 0x0C,
+0x21, 0x28, 0xB2, 0x00, 0x21, 0x18, 0x40, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x40, 0x00, 0x62, 0x10, 0x03, 0x00, 0x02, 0x24, 0x38, 0x00, 0xE2, 0xAE,
+0x70, 0x00, 0xE7, 0x8E, 0x21, 0x20, 0x60, 0x02, 0x03, 0x00, 0x05, 0x24,
+0xF4, 0xFF, 0xE7, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x1C, 0x00, 0xA6, 0x27,
+0x48, 0x00, 0xE0, 0xAE, 0x04, 0x00, 0x40, 0x10, 0x3C, 0x00, 0xE0, 0xAE,
+0x02, 0x00, 0x42, 0x90, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0xE2, 0xAE,
+0xFB, 0x51, 0x00, 0x0C, 0x21, 0x20, 0x80, 0x02, 0x21, 0x28, 0x40, 0x00,
+0x40, 0x00, 0xE4, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24,
+0x18, 0x52, 0x00, 0x0C, 0x21, 0x20, 0xE0, 0x02, 0xFF, 0xFF, 0x50, 0x30,
+0x01, 0x00, 0x02, 0x32, 0x1A, 0x00, 0x40, 0x10, 0x21, 0x28, 0xC0, 0x02,
+0x01, 0x00, 0x02, 0x24, 0x5C, 0x00, 0xE2, 0xAE, 0x2C, 0x00, 0xA5, 0x8F,
+0x04, 0x00, 0xE4, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x10, 0x00, 0x02, 0x32, 0x13, 0x00, 0x40, 0x10, 0x01, 0x00, 0x02, 0x24,
+0x30, 0x00, 0xE2, 0xAE, 0x02, 0x80, 0x03, 0x3C, 0x44, 0x00, 0xE0, 0xAE,
+0x60, 0x1B, 0x62, 0x24, 0x3C, 0x3E, 0x43, 0x8C, 0x20, 0x00, 0xA4, 0x8F,
+0x01, 0x00, 0x63, 0x24, 0x3C, 0x3E, 0x43, 0xAC, 0x24, 0x00, 0xA3, 0x8F,
+0x08, 0x00, 0x02, 0x24, 0x0C, 0x00, 0x83, 0xAC, 0x20, 0x00, 0xA3, 0x8F,
+0x17, 0x0A, 0x00, 0x0C, 0x14, 0x00, 0x62, 0xAC, 0x1D, 0x11, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0x12, 0x00, 0x08, 0x5C, 0x00, 0xE0, 0xAE,
+0x11, 0x12, 0x00, 0x08, 0x30, 0x00, 0xE0, 0xAE, 0xE3, 0x17, 0x00, 0x0C,
+0x18, 0x00, 0xC5, 0x27, 0xC8, 0x11, 0x00, 0x08, 0x34, 0x00, 0xE2, 0xAE,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x05, 0x26, 0x01, 0x00, 0x03, 0x92,
+0xC1, 0x11, 0x00, 0x08, 0x0C, 0x00, 0xE3, 0xAE, 0xEF, 0x11, 0x00, 0x08,
+0x38, 0x00, 0xE3, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x44, 0x24,
+0xFC, 0x40, 0x83, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x60, 0x10,
+0x01, 0x00, 0x05, 0x24, 0xB6, 0x40, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x42, 0x2C, 0x07, 0x00, 0x40, 0x10, 0x21, 0x28, 0x00, 0x00,
+0xC7, 0x3D, 0x83, 0x90, 0x01, 0x00, 0x02, 0x24, 0x03, 0x00, 0x62, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x01, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0x82, 0x24, 0x44, 0x41, 0x45, 0x8C,
+0x40, 0x41, 0x46, 0x8C, 0x21, 0x20, 0x40, 0x00, 0x40, 0x18, 0x05, 0x00,
+0x40, 0x10, 0x06, 0x00, 0x2B, 0x18, 0x66, 0x00, 0x2B, 0x38, 0x45, 0x00,
+0x04, 0x00, 0x60, 0x14, 0x21, 0x28, 0x00, 0x00, 0x01, 0x00, 0x05, 0x24,
+0x02, 0x00, 0x02, 0x24, 0x0A, 0x28, 0x47, 0x00, 0x21, 0x10, 0xA0, 0x00,
+0x40, 0x41, 0x80, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x44, 0x41, 0x80, 0xAC,
+0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF,
+0x43, 0x12, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x80, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xCE, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x12, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x2F, 0x12, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x24, 0x0D, 0x00, 0x43, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x16, 0x5C, 0x44, 0x90, 0x02, 0x80, 0x02, 0x3C,
+0xD4, 0xDD, 0x42, 0x24, 0x40, 0x18, 0x04, 0x00, 0x21, 0x18, 0x64, 0x00,
+0x21, 0x18, 0x70, 0x00, 0x80, 0x18, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x64, 0x8C, 0x25, 0xB0, 0x02, 0x3C, 0xD8, 0x01, 0x42, 0x34,
+0x00, 0x00, 0x44, 0xAC, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x02, 0x00, 0x84, 0x90, 0x02, 0x80, 0x05, 0x3C, 0x48, 0x37, 0xA5, 0x24,
+0x0F, 0x00, 0x84, 0x30, 0xC0, 0x20, 0x04, 0x00, 0x21, 0x20, 0x90, 0x00,
+0x1C, 0x00, 0x84, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x06, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x10, 0x37, 0x43, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x63, 0x30, 0x06, 0x00, 0x60, 0x14,
+0x21, 0x20, 0x00, 0x02, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0x02, 0x11, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0xE0, 0xFF, 0xBD, 0x27, 0x54, 0x4A, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x18, 0x00, 0xB0, 0xAF, 0x1C, 0x00, 0xBF, 0xAF, 0x00, 0x00, 0x43, 0xAC,
+0x02, 0x00, 0x82, 0x90, 0x02, 0x80, 0x05, 0x3C, 0xB4, 0x55, 0xA5, 0x24,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x10, 0x02, 0x00, 0x21, 0x10, 0x44, 0x00,
+0x28, 0x00, 0x44, 0x24, 0x06, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C,
+0x18, 0x00, 0x50, 0x24, 0x06, 0x00, 0x40, 0x10, 0x21, 0x20, 0x00, 0x02,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x39, 0x53, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x48, 0x37, 0x84, 0x24,
+0x21, 0x28, 0x40, 0x00, 0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0xF3, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x02, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x42, 0x30, 0xEE, 0xFF, 0x40, 0x10,
+0x10, 0x00, 0xA4, 0x27, 0x8A, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xEC, 0x5D, 0x43, 0x90, 0x05, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x63, 0x30, 0x05, 0x00, 0x62, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0xA9, 0x12, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x37, 0x43, 0x94, 0x02, 0x80, 0x04, 0x3C,
+0x00, 0x01, 0x63, 0x30, 0xF8, 0xFF, 0x60, 0x10, 0x01, 0x00, 0x05, 0x24,
+0x07, 0x5E, 0x83, 0x90, 0xFB, 0xFF, 0x02, 0x24, 0x24, 0x18, 0x62, 0x00,
+0x07, 0x5E, 0x83, 0xA0, 0x02, 0x80, 0x02, 0x3C, 0xED, 0x5D, 0x44, 0x90,
+0x4B, 0x2E, 0x00, 0x0C, 0xFF, 0x00, 0x84, 0x30, 0x90, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0xA9, 0x12, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0xD8, 0xFF, 0xBD, 0x27, 0x28, 0x00, 0xA4, 0xA3, 0x00, 0x01, 0x04, 0x24,
+0x18, 0x00, 0xB2, 0xAF, 0x24, 0x00, 0xBF, 0xAF, 0x20, 0x00, 0xB4, 0xAF,
+0x1C, 0x00, 0xB3, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x2C, 0x00, 0xA5, 0xA3, 0x53, 0x21, 0x00, 0x0C, 0x30, 0x00, 0xA6, 0xA7,
+0xA4, 0x00, 0x40, 0x10, 0x21, 0x90, 0x40, 0x00, 0x30, 0x00, 0xA7, 0x97,
+0x28, 0x00, 0xA5, 0x93, 0x2C, 0x00, 0xA6, 0x93, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xB0, 0xEA, 0x84, 0x24, 0x08, 0x00, 0x50, 0x96,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x11, 0x3C, 0x25, 0x80, 0x02, 0x02,
+0xB4, 0x55, 0x31, 0x26, 0x21, 0x28, 0x20, 0x02, 0x24, 0x00, 0x04, 0x26,
+0x06, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x20, 0x00, 0x00, 0xA6,
+0x02, 0x80, 0x05, 0x3C, 0x48, 0x37, 0xA5, 0x24, 0x2A, 0x00, 0x04, 0x26,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x21, 0x28, 0x20, 0x02,
+0x30, 0x00, 0x04, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x20, 0x00, 0x03, 0x96, 0x18, 0x00, 0x02, 0x24, 0x02, 0x80, 0x14, 0x3C,
+0x03, 0xFF, 0x63, 0x30, 0xD0, 0x00, 0x63, 0x34, 0x20, 0x00, 0x03, 0xA6,
+0x60, 0x1B, 0x93, 0x26, 0x0C, 0x00, 0x42, 0xAE, 0xE4, 0x1D, 0x62, 0x96,
+0x20, 0x00, 0x05, 0x26, 0x0C, 0x00, 0x51, 0x26, 0xFF, 0x0F, 0x43, 0x30,
+0x00, 0x19, 0x03, 0x00, 0x02, 0x22, 0x03, 0x00, 0x01, 0x00, 0x42, 0x24,
+0xE4, 0x1D, 0x62, 0xA6, 0x28, 0x00, 0xA6, 0x27, 0x16, 0x00, 0xA3, 0xA0,
+0x17, 0x00, 0xA4, 0xA0, 0x21, 0x38, 0x20, 0x02, 0x38, 0x00, 0x04, 0x26,
+0x4C, 0x52, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0x21, 0x20, 0x40, 0x00,
+0x01, 0x00, 0x05, 0x24, 0x2C, 0x00, 0xA6, 0x27, 0x4C, 0x52, 0x00, 0x0C,
+0x21, 0x38, 0x20, 0x02, 0x28, 0x00, 0xA3, 0x93, 0x21, 0x20, 0x40, 0x00,
+0x03, 0x00, 0x02, 0x24, 0x12, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x82, 0x26, 0xB6, 0x40, 0x43, 0x90, 0x04, 0x00, 0x07, 0x24,
+0x21, 0x20, 0x40, 0x02, 0x01, 0x00, 0x63, 0x38, 0x0B, 0x38, 0x03, 0x00,
+0x21, 0x28, 0x00, 0x00, 0xDF, 0x0D, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27, 0x2C, 0x00, 0xA3, 0x93,
+0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x60, 0x14, 0x01, 0x00, 0x02, 0x24,
+0xC5, 0x40, 0x63, 0x92, 0x21, 0x80, 0x60, 0x02, 0x01, 0x00, 0x68, 0x24,
+0xFF, 0x00, 0x02, 0x31, 0xFD, 0xFF, 0x40, 0x10, 0x21, 0x18, 0x00, 0x01,
+0x02, 0x80, 0x06, 0x3C, 0x21, 0x38, 0x20, 0x02, 0xC5, 0x40, 0x08, 0xA2,
+0x25, 0x5C, 0xC6, 0x24, 0x4C, 0x52, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24,
+0xC8, 0x40, 0x08, 0x8E, 0x30, 0x00, 0xA4, 0x97, 0xC3, 0xFF, 0x03, 0x24,
+0x02, 0x00, 0x08, 0x35, 0x0F, 0x00, 0x84, 0x30, 0x24, 0x40, 0x03, 0x01,
+0x80, 0x20, 0x04, 0x00, 0xFF, 0xFF, 0x03, 0x3C, 0x3F, 0x00, 0x63, 0x34,
+0x25, 0x40, 0x04, 0x01, 0x24, 0x40, 0x03, 0x01, 0x00, 0x08, 0x08, 0x35,
+0x02, 0x80, 0x06, 0x3C, 0x21, 0x38, 0x20, 0x02, 0xC8, 0x40, 0x08, 0xAE,
+0x28, 0x5C, 0xC6, 0x24, 0x21, 0x20, 0x40, 0x00, 0x4C, 0x52, 0x00, 0x0C,
+0x02, 0x00, 0x05, 0x24, 0x02, 0x80, 0x06, 0x3C, 0x21, 0x38, 0x20, 0x02,
+0x2A, 0x5C, 0xC6, 0x24, 0x21, 0x20, 0x40, 0x00, 0x02, 0x00, 0x05, 0x24,
+0x4C, 0x52, 0x00, 0x0C, 0xCA, 0x40, 0x00, 0xA6, 0x30, 0x00, 0xA3, 0x97,
+0x21, 0x20, 0x40, 0x00, 0x02, 0x80, 0x06, 0x3C, 0x07, 0x00, 0x63, 0x30,
+0x40, 0x18, 0x03, 0x00, 0x21, 0x18, 0x70, 0x00, 0xD4, 0x1D, 0x62, 0x94,
+0x2C, 0x5C, 0xC6, 0x24, 0x21, 0x38, 0x20, 0x02, 0x00, 0x11, 0x02, 0x00,
+0x02, 0x00, 0x05, 0x24, 0x4C, 0x52, 0x00, 0x0C, 0xCC, 0x40, 0x02, 0xA6,
+0x22, 0x13, 0x00, 0x08, 0x60, 0x1B, 0x82, 0x26, 0xB5, 0xFF, 0x62, 0x14,
+0x02, 0x80, 0x06, 0x3C, 0x21, 0x38, 0x20, 0x02, 0x24, 0x5C, 0xC6, 0x24,
+0x4C, 0x52, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0x21, 0x20, 0x40, 0x00,
+0x30, 0x00, 0xA6, 0x27, 0x21, 0x38, 0x20, 0x02, 0x4C, 0x52, 0x00, 0x0C,
+0x02, 0x00, 0x05, 0x24, 0xC8, 0x40, 0x68, 0x8E, 0xFF, 0xFF, 0x03, 0x3C,
+0x3F, 0x00, 0x63, 0x34, 0x24, 0x40, 0x03, 0x01, 0x00, 0x08, 0x08, 0x35,
+0x02, 0x80, 0x06, 0x3C, 0x21, 0x38, 0x20, 0x02, 0x21, 0x20, 0x40, 0x00,
+0x28, 0x5C, 0xC6, 0x24, 0x02, 0x00, 0x05, 0x24, 0x4C, 0x52, 0x00, 0x0C,
+0xC8, 0x40, 0x68, 0xAE, 0x02, 0x80, 0x06, 0x3C, 0x21, 0x20, 0x40, 0x00,
+0x2A, 0x5C, 0xC6, 0x24, 0x21, 0x38, 0x20, 0x02, 0x4C, 0x52, 0x00, 0x0C,
+0x02, 0x00, 0x05, 0x24, 0x22, 0x13, 0x00, 0x08, 0x60, 0x1B, 0x82, 0x26,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0xAC, 0xE8, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0xA0, 0xEA, 0xA5, 0x24, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xBF, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x82, 0x90,
+0x02, 0x80, 0x11, 0x3C, 0x21, 0x80, 0x80, 0x00, 0x60, 0x1B, 0x31, 0x26,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x00, 0x06, 0x24, 0x01, 0x00, 0x05, 0x26,
+0x28, 0x5C, 0x84, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0xC4, 0x40, 0x22, 0xA2,
+0x04, 0x00, 0x03, 0x92, 0x03, 0x00, 0x02, 0x92, 0x00, 0x1A, 0x03, 0x00,
+0x25, 0x18, 0x62, 0x00, 0xCA, 0x40, 0x23, 0xA6, 0x06, 0x00, 0x02, 0x92,
+0x05, 0x00, 0x03, 0x92, 0x00, 0x12, 0x02, 0x00, 0x25, 0x10, 0x43, 0x00,
+0xCC, 0x40, 0x22, 0xA6, 0x01, 0x00, 0x05, 0x92, 0x06, 0x00, 0x04, 0x92,
+0x05, 0x00, 0x02, 0x92, 0x82, 0x28, 0x05, 0x00, 0x00, 0x22, 0x04, 0x00,
+0x25, 0x20, 0x82, 0x00, 0x6A, 0x48, 0x00, 0x0C, 0x0F, 0x00, 0xA5, 0x30,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x03, 0x00, 0x04, 0x24, 0x01, 0x00, 0x05, 0x24, 0x21, 0x30, 0x00, 0x00,
+0xD9, 0x12, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x03, 0x42, 0x34,
+0xFC, 0x4E, 0x63, 0x24, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB2, 0xAF, 0x00, 0x00, 0x43, 0xAC,
+0x02, 0x00, 0x82, 0x90, 0x02, 0x80, 0x05, 0x3C, 0xB4, 0x55, 0xA5, 0x24,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x10, 0x02, 0x00, 0x21, 0x88, 0x44, 0x00,
+0x28, 0x00, 0x24, 0x26, 0x06, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C,
+0x18, 0x00, 0x30, 0x26, 0x08, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x39, 0x53, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02,
+0x02, 0x80, 0x04, 0x3C, 0x48, 0x37, 0x84, 0x24, 0x21, 0x28, 0x40, 0x00,
+0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0xF1, 0xFF, 0x40, 0x14,
+0x03, 0x00, 0x02, 0x24, 0x30, 0x00, 0x23, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xED, 0xFF, 0x62, 0x14, 0x30, 0x00, 0x24, 0x26, 0x02, 0x80, 0x07, 0x3C,
+0x60, 0x1B, 0xE5, 0x24, 0xFC, 0x40, 0xA2, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0xE7, 0xFF, 0x40, 0x10, 0x01, 0x00, 0x06, 0x24, 0x01, 0x00, 0x83, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x66, 0x10, 0x02, 0x00, 0x62, 0x28,
+0x2E, 0x00, 0x40, 0x14, 0x02, 0x00, 0x02, 0x24, 0xDF, 0xFF, 0x62, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x83, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x62, 0x30, 0x0A, 0x00, 0x40, 0x14, 0x02, 0x11, 0x03, 0x00,
+0xC6, 0x40, 0xA3, 0x90, 0x04, 0x10, 0x46, 0x00, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x10, 0x43, 0x00, 0xC6, 0x40, 0xA2, 0xA0, 0x05, 0x00, 0x83, 0x90,
+0x04, 0x00, 0x82, 0x90, 0x00, 0x1A, 0x03, 0x00, 0x25, 0x90, 0x62, 0x00,
+0xC6, 0x40, 0xA5, 0x90, 0x02, 0x80, 0x04, 0x3C, 0xCC, 0xEA, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x21, 0x30, 0x40, 0x02, 0xD5, 0x13, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x82, 0x90, 0x05, 0x00, 0x83, 0x90,
+0x03, 0x00, 0x84, 0x90, 0x00, 0x12, 0x02, 0x00, 0x82, 0x18, 0x03, 0x00,
+0x25, 0x10, 0x44, 0x00, 0x15, 0x00, 0x40, 0x14, 0x07, 0x00, 0x64, 0x30,
+0xC6, 0x40, 0xA3, 0x90, 0x04, 0x10, 0x86, 0x00, 0x25, 0x10, 0x43, 0x00,
+0xC6, 0x40, 0xA2, 0xA0, 0x60, 0x1B, 0xE2, 0x24, 0xF8, 0x40, 0x43, 0x90,
+0xC6, 0x40, 0x45, 0x90, 0x02, 0x80, 0x04, 0x3C, 0x21, 0x18, 0x62, 0x00,
+0xDC, 0xEA, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0xF0, 0x40, 0x60, 0xA0,
+0xD5, 0x13, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xB2, 0xFF, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x97, 0x13, 0x00, 0x0C, 0x32, 0x00, 0x24, 0x26,
+0xD5, 0x13, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x40, 0xA3, 0x90,
+0x04, 0x10, 0x86, 0x00, 0x27, 0x10, 0x02, 0x00, 0x17, 0x14, 0x00, 0x08,
+0x24, 0x10, 0x43, 0x00, 0xB8, 0xFF, 0xBD, 0x27, 0x38, 0x00, 0xB6, 0xAF,
+0xFF, 0xFF, 0x96, 0x30, 0x00, 0x01, 0x04, 0x24, 0x3C, 0x00, 0xB7, 0xAF,
+0x28, 0x00, 0xB2, 0xAF, 0x40, 0x00, 0xBF, 0xAF, 0x34, 0x00, 0xB5, 0xAF,
+0x30, 0x00, 0xB4, 0xAF, 0x2C, 0x00, 0xB3, 0xAF, 0x24, 0x00, 0xB1, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0x20, 0x00, 0xB0, 0xAF, 0x21, 0x90, 0x40, 0x00,
+0x81, 0x00, 0x40, 0x10, 0x21, 0xB8, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xF8, 0xEA, 0x84, 0x24, 0x08, 0x00, 0x50, 0x96,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x11, 0x3C, 0x25, 0x80, 0x02, 0x02,
+0xB4, 0x55, 0x31, 0x26, 0x24, 0x00, 0x04, 0x26, 0x21, 0x28, 0x20, 0x02,
+0x20, 0x00, 0x00, 0xA6, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x05, 0x3C, 0x2A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x30, 0x00, 0x04, 0x26,
+0x21, 0x28, 0x20, 0x02, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x20, 0x00, 0x03, 0x96, 0x18, 0x00, 0x02, 0x24, 0x02, 0x80, 0x15, 0x3C,
+0x03, 0xFF, 0x63, 0x30, 0xB0, 0x00, 0x63, 0x34, 0x20, 0x00, 0x03, 0xA6,
+0x60, 0x1B, 0xA8, 0x26, 0x0C, 0x00, 0x42, 0xAE, 0xE4, 0x1D, 0x02, 0x95,
+0x20, 0x00, 0x14, 0x26, 0x0C, 0x00, 0x51, 0x26, 0xFF, 0x0F, 0x43, 0x30,
+0x00, 0x19, 0x03, 0x00, 0x02, 0x22, 0x03, 0x00, 0x01, 0x00, 0x42, 0x24,
+0xE4, 0x1D, 0x02, 0xA5, 0x17, 0x00, 0x84, 0xA2, 0x16, 0x00, 0x83, 0xA2,
+0x20, 0x40, 0x04, 0x8D, 0x03, 0x00, 0x02, 0x24, 0x31, 0x00, 0x82, 0x10,
+0x38, 0x00, 0x10, 0x26, 0x60, 0x1B, 0xB3, 0x26, 0x24, 0x40, 0x62, 0x8E,
+0x21, 0x20, 0x00, 0x02, 0x02, 0x00, 0x05, 0x24, 0x01, 0x00, 0x42, 0x38,
+0x01, 0x00, 0x42, 0x2C, 0x18, 0x00, 0xA6, 0x27, 0x21, 0x38, 0x20, 0x02,
+0x4C, 0x52, 0x00, 0x0C, 0x18, 0x00, 0xA2, 0xA7, 0x20, 0x40, 0x63, 0x8E,
+0x21, 0x20, 0x40, 0x00, 0x02, 0x00, 0x05, 0x24, 0x18, 0x00, 0xA6, 0x27,
+0x21, 0x38, 0x20, 0x02, 0x4C, 0x52, 0x00, 0x0C, 0x18, 0x00, 0xA3, 0xA7,
+0x21, 0x20, 0x40, 0x00, 0x02, 0x00, 0x05, 0x24, 0x18, 0x00, 0xA6, 0x27,
+0x21, 0x38, 0x20, 0x02, 0x4C, 0x52, 0x00, 0x0C, 0x18, 0x00, 0xB6, 0xA7,
+0x20, 0x40, 0x63, 0x8E, 0x21, 0x80, 0x40, 0x00, 0x03, 0x00, 0x02, 0x24,
+0x28, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0xA2, 0x26,
+0xB6, 0x40, 0x43, 0x90, 0x04, 0x00, 0x07, 0x24, 0x21, 0x20, 0x40, 0x02,
+0x01, 0x00, 0x63, 0x38, 0x21, 0x30, 0xE0, 0x02, 0x0B, 0x38, 0x03, 0x00,
+0xDF, 0x0D, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x40, 0x00, 0xBF, 0x8F,
+0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F, 0x34, 0x00, 0xB5, 0x8F,
+0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F,
+0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x48, 0x00, 0xBD, 0x27, 0xB0, 0x1B, 0x02, 0x95, 0x00, 0x00, 0x00, 0x00,
+0x40, 0x00, 0x42, 0x30, 0xCD, 0xFF, 0x40, 0x10, 0x60, 0x1B, 0xB3, 0x26,
+0x2C, 0x40, 0x03, 0x8D, 0x30, 0x40, 0x02, 0x8D, 0x21, 0x20, 0x00, 0x02,
+0x80, 0x1F, 0x03, 0x00, 0x25, 0x18, 0x43, 0x00, 0x04, 0x00, 0x05, 0x24,
+0x01, 0x00, 0x42, 0x24, 0x1C, 0x00, 0xA6, 0x27, 0x21, 0x38, 0x20, 0x02,
+0x30, 0x40, 0x02, 0xAD, 0x4C, 0x52, 0x00, 0x0C, 0x1C, 0x00, 0xA3, 0xAF,
+0x69, 0x14, 0x00, 0x08, 0x21, 0x80, 0x40, 0x00, 0xB0, 0x1B, 0x62, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x42, 0x30, 0xD6, 0xFF, 0x40, 0x10,
+0x60, 0x1B, 0xA2, 0x26, 0x02, 0x80, 0x07, 0x3C, 0x21, 0x20, 0x00, 0x02,
+0x94, 0x5B, 0xE7, 0x24, 0x10, 0x00, 0x05, 0x24, 0x80, 0x00, 0x06, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB1, 0xAF, 0x00, 0x00, 0x83, 0x96,
+0x01, 0x00, 0x17, 0x24, 0x00, 0x40, 0x63, 0x34, 0x85, 0x14, 0x00, 0x08,
+0x00, 0x00, 0x83, 0xA6, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0xAC, 0xE8, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0xEC, 0xEA, 0xA5, 0x24,
+0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F,
+0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F,
+0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27, 0xB0, 0xFF, 0xBD, 0x27,
+0x38, 0x00, 0xB4, 0xAF, 0x34, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xB2, 0xAF,
+0x2C, 0x00, 0xB1, 0xAF, 0x28, 0x00, 0xB0, 0xAF, 0x48, 0x00, 0xBF, 0xAF,
+0x44, 0x00, 0xB7, 0xAF, 0x40, 0x00, 0xB6, 0xAF, 0x3C, 0x00, 0xB5, 0xAF,
+0x02, 0x00, 0x82, 0x90, 0x02, 0x80, 0x12, 0x3C, 0x21, 0xA0, 0x80, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x10, 0x02, 0x00, 0x21, 0x80, 0x44, 0x00,
+0x28, 0x00, 0x11, 0x26, 0xB4, 0x55, 0x45, 0x26, 0x21, 0x20, 0x20, 0x02,
+0x06, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x18, 0x00, 0x13, 0x26,
+0x9F, 0x00, 0x40, 0x10, 0x21, 0x20, 0x60, 0x02, 0x02, 0x80, 0x15, 0x3C,
+0x60, 0x1B, 0xA2, 0x26, 0x4B, 0x41, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x82, 0x00, 0x60, 0x10, 0x3C, 0x00, 0x04, 0x26, 0x60, 0x1B, 0xB0, 0x26,
+0xB0, 0x1B, 0x03, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x62, 0x30,
+0x6D, 0x00, 0x40, 0x14, 0x10, 0x00, 0x62, 0x30, 0x13, 0x00, 0x40, 0x14,
+0x10, 0x00, 0x76, 0x26, 0x60, 0x1B, 0xB0, 0x26, 0xB0, 0x1B, 0x02, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30, 0x8F, 0x00, 0x40, 0x14,
+0x21, 0x18, 0x00, 0x00, 0x48, 0x00, 0xBF, 0x8F, 0x44, 0x00, 0xB7, 0x8F,
+0x40, 0x00, 0xB6, 0x8F, 0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F,
+0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F,
+0x28, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x50, 0x00, 0xBD, 0x27, 0x21, 0x20, 0xC0, 0x02, 0xB4, 0x55, 0x45, 0x26,
+0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0xE9, 0xFF, 0x40, 0x14,
+0x07, 0x00, 0x02, 0x24, 0xB6, 0x40, 0x02, 0xA2, 0xE8, 0x39, 0x00, 0xAE,
+0x00, 0x00, 0x84, 0x8E, 0x0C, 0x00, 0x12, 0x24, 0xFF, 0x3F, 0x82, 0x30,
+0xE8, 0xFF, 0x42, 0x24, 0x2A, 0x10, 0x42, 0x02, 0x9C, 0x00, 0x40, 0x10,
+0x21, 0xB8, 0x00, 0x02, 0x1F, 0x15, 0x00, 0x08, 0x21, 0x80, 0x72, 0x02,
+0x19, 0x00, 0x03, 0x92, 0xFF, 0x3F, 0x82, 0x30, 0xE8, 0xFF, 0x42, 0x24,
+0x21, 0x18, 0x72, 0x00, 0x02, 0x00, 0x72, 0x24, 0x2A, 0x10, 0x42, 0x02,
+0x93, 0x00, 0x40, 0x10, 0x60, 0x1B, 0xB0, 0x26, 0x21, 0x80, 0x72, 0x02,
+0x18, 0x00, 0x03, 0x92, 0xDD, 0x00, 0x02, 0x24, 0xF4, 0xFF, 0x62, 0x14,
+0x1A, 0x00, 0x11, 0x26, 0x02, 0x80, 0x05, 0x3C, 0x64, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x55, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x60, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x4F, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x54, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x44, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x50, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x3E, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x4C, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x38, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x44, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x3B, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x40, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x53, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x48, 0xDE, 0xA5, 0x24,
+0x21, 0x20, 0x20, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x47, 0x01, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x21, 0x20, 0x20, 0x02,
+0x34, 0xDE, 0xA5, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x04, 0x00, 0x06, 0x24,
+0x2F, 0x01, 0x40, 0x10, 0x02, 0x00, 0x02, 0x24, 0x00, 0x00, 0x84, 0x8E,
+0x16, 0x15, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x11, 0x00, 0x0C,
+0x21, 0x20, 0x80, 0x02, 0x21, 0x18, 0x00, 0x00, 0x48, 0x00, 0xBF, 0x8F,
+0x44, 0x00, 0xB7, 0x8F, 0x40, 0x00, 0xB6, 0x8F, 0x3C, 0x00, 0xB5, 0x8F,
+0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F,
+0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x50, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x87, 0x8E,
+0x07, 0x00, 0x05, 0x24, 0xFF, 0x3F, 0xE7, 0x30, 0xDC, 0xFF, 0xE7, 0x24,
+0xAB, 0x1A, 0x00, 0x0C, 0x20, 0x00, 0xA6, 0x27, 0x78, 0xFF, 0x40, 0x10,
+0x21, 0x38, 0x40, 0x00, 0x20, 0x00, 0xA5, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x06, 0x00, 0xA2, 0x28, 0x73, 0xFF, 0x40, 0x14, 0xFD, 0xFF, 0xA5, 0x24,
+0x05, 0x00, 0xE4, 0x24, 0xE5, 0x4B, 0x00, 0x0C, 0xFF, 0x00, 0xA5, 0x30,
+0x02, 0x80, 0x04, 0x3C, 0xAC, 0x5C, 0x84, 0x24, 0x21, 0x28, 0x20, 0x02,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0xEC, 0x14, 0x00, 0x08,
+0x60, 0x1B, 0xB0, 0x26, 0xB9, 0x2B, 0x00, 0x0C, 0x21, 0x28, 0x80, 0x02,
+0xE6, 0x14, 0x00, 0x08, 0x02, 0x80, 0x15, 0x3C, 0xB4, 0x55, 0x45, 0x26,
+0x10, 0x00, 0x64, 0x26, 0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0xD4, 0xFF, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00, 0x21, 0x20, 0x80, 0x02,
+0xE3, 0x17, 0x00, 0x0C, 0x18, 0x00, 0x85, 0x26, 0x21, 0x20, 0x40, 0x00,
+0x8D, 0x17, 0x00, 0x0C, 0x05, 0x00, 0x05, 0x24, 0xB0, 0x1B, 0x03, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x62, 0x30, 0x0C, 0x00, 0x40, 0x14,
+0x04, 0x00, 0x62, 0x30, 0x4B, 0x00, 0x40, 0x14, 0x60, 0x1B, 0xB0, 0x26,
+0xB7, 0x40, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x44, 0x24,
+0xFF, 0x00, 0x83, 0x30, 0x15, 0x00, 0x02, 0x24, 0x5D, 0x00, 0x62, 0x10,
+0x21, 0x18, 0x00, 0x00, 0xF9, 0x14, 0x00, 0x08, 0xB7, 0x40, 0x04, 0xA2,
+0x8A, 0x40, 0x00, 0x0C, 0x24, 0x00, 0xA4, 0x27, 0xE8, 0x1E, 0x03, 0x8E,
+0xEC, 0x1E, 0x02, 0x8E, 0x24, 0x00, 0xA4, 0x27, 0x01, 0x00, 0x63, 0x24,
+0x01, 0x00, 0x42, 0x24, 0xEC, 0x1E, 0x02, 0xAE, 0x90, 0x40, 0x00, 0x0C,
+0xE8, 0x1E, 0x03, 0xAE, 0x9A, 0x15, 0x00, 0x08, 0x60, 0x1B, 0xB0, 0x26,
+0x60, 0x1B, 0xB0, 0x26, 0xB6, 0x40, 0x03, 0x92, 0x07, 0x00, 0x02, 0x24,
+0x21, 0x00, 0x62, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x04, 0x3C,
+0x5C, 0xEB, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xCE, 0x5C, 0x46, 0x90, 0x01, 0x00, 0x03, 0x24,
+0x0F, 0x00, 0xC3, 0x10, 0x60, 0x1B, 0xA4, 0x26, 0xD5, 0x4E, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0xBF, 0x8F, 0x44, 0x00, 0xB7, 0x8F,
+0x40, 0x00, 0xB6, 0x8F, 0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F,
+0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F,
+0x28, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x50, 0x00, 0xBD, 0x27, 0xB6, 0x40, 0x83, 0x90, 0x03, 0x00, 0x02, 0x24,
+0x2A, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x3D, 0x41, 0x86, 0xA0,
+0xD5, 0x4E, 0x00, 0x0C, 0x3C, 0x41, 0x80, 0xA0, 0xBF, 0x15, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x5C, 0xDE, 0xA5, 0x24, 0x21, 0x20, 0xC0, 0x02,
+0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24, 0x07, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x05, 0x3C, 0x21, 0x20, 0xC0, 0x02, 0x58, 0xDE, 0xA5, 0x24,
+0x1D, 0x55, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24, 0xD5, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x70, 0xEB, 0x84, 0x24,
+0xB6, 0x15, 0x00, 0x08, 0xB6, 0x40, 0x00, 0xA2, 0x0A, 0x00, 0x76, 0x26,
+0x1F, 0x54, 0x00, 0x0C, 0x21, 0x20, 0xC0, 0x02, 0x20, 0x00, 0x10, 0x24,
+0x37, 0x00, 0x50, 0x10, 0x21, 0x88, 0x40, 0x00, 0x8A, 0x40, 0x00, 0x0C,
+0x24, 0x00, 0xA4, 0x27, 0x40, 0x10, 0x11, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x60, 0x1B, 0xA4, 0x26, 0x00, 0x11, 0x02, 0x00, 0x21, 0x10, 0x44, 0x00,
+0xF8, 0x1D, 0x43, 0x8C, 0x24, 0x00, 0xA4, 0x27, 0x01, 0x00, 0x63, 0x24,
+0x90, 0x40, 0x00, 0x0C, 0xF8, 0x1D, 0x43, 0xAC, 0x60, 0x15, 0x00, 0x08,
+0x21, 0x18, 0x00, 0x00, 0x3C, 0x41, 0x86, 0xA0, 0xD5, 0x4E, 0x00, 0x0C,
+0x3D, 0x41, 0x80, 0xA0, 0xBF, 0x15, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x55, 0x12, 0x00, 0x0C, 0xB7, 0x40, 0x00, 0xA2, 0x02, 0x80, 0x02, 0x3C,
+0xD2, 0x5C, 0x44, 0x90, 0x02, 0x00, 0x03, 0x24, 0x5D, 0xFF, 0x83, 0x14,
+0x21, 0x18, 0x00, 0x00, 0x00, 0x00, 0x87, 0x8E, 0x24, 0x00, 0x64, 0x26,
+0x2A, 0x00, 0x05, 0x24, 0xFF, 0x3F, 0xE7, 0x30, 0xDC, 0xFF, 0xE7, 0x24,
+0xAB, 0x1A, 0x00, 0x0C, 0x20, 0x00, 0xA6, 0x27, 0x54, 0xFF, 0x40, 0x10,
+0x21, 0x18, 0x00, 0x00, 0x02, 0x00, 0x44, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x82, 0x30, 0x95, 0x00, 0x40, 0x10, 0x60, 0x1B, 0xA5, 0x26,
+0x01, 0x00, 0x82, 0x30, 0x92, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C,
+0xD3, 0x5C, 0x44, 0x90, 0x01, 0x00, 0x03, 0x24, 0x9F, 0x00, 0x83, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xFC, 0x23, 0x02, 0x8E, 0xFF, 0xEF, 0x03, 0x24,
+0x00, 0x08, 0x42, 0x34, 0x24, 0x10, 0x43, 0x00, 0xFC, 0x23, 0x02, 0xAE,
+0x60, 0x15, 0x00, 0x08, 0x21, 0x18, 0x00, 0x00, 0xFF, 0xFF, 0x04, 0x24,
+0xC7, 0x53, 0x00, 0x0C, 0x21, 0x28, 0xC0, 0x02, 0xC6, 0xFF, 0x50, 0x10,
+0x21, 0x88, 0x40, 0x00, 0x00, 0x00, 0x87, 0x8E, 0x24, 0x00, 0x77, 0x26,
+0x21, 0x20, 0xE0, 0x02, 0xFF, 0x3F, 0xE7, 0x30, 0xDC, 0xFF, 0xE7, 0x24,
+0x01, 0x00, 0x05, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x20, 0x00, 0xA6, 0x27,
+0xCB, 0xFE, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00, 0x20, 0x00, 0xA6, 0x8F,
+0x02, 0x00, 0x45, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x87, 0x8E, 0x21, 0x20, 0xE0, 0x02, 0x32, 0x00, 0x05, 0x24,
+0xFF, 0x3F, 0xE7, 0x30, 0xDC, 0xFF, 0xE7, 0x24, 0x20, 0x00, 0xB0, 0x8F,
+0xAB, 0x1A, 0x00, 0x0C, 0x20, 0x00, 0xA6, 0x27, 0x08, 0x00, 0x40, 0x10,
+0x10, 0x00, 0xA4, 0x27, 0x20, 0x00, 0xA6, 0x8F, 0x21, 0x20, 0x90, 0x00,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x45, 0x24, 0x20, 0x00, 0xA3, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x80, 0x03, 0x02, 0x10, 0x00, 0xA4, 0x27,
+0x61, 0x53, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x02, 0x21, 0x28, 0x00, 0x02,
+0x10, 0x00, 0xA4, 0x27, 0xA6, 0x53, 0x00, 0x0C, 0x0F, 0x00, 0x53, 0x30,
+0x00, 0x00, 0x87, 0x8E, 0x21, 0x20, 0xE0, 0x02, 0x2D, 0x00, 0x05, 0x24,
+0xFF, 0x3F, 0xE7, 0x30, 0xDC, 0xFF, 0xE7, 0x24, 0x20, 0x00, 0xA6, 0x27,
+0xAB, 0x1A, 0x00, 0x0C, 0x21, 0x90, 0x40, 0x00, 0x11, 0x00, 0x40, 0x10,
+0x00, 0x81, 0x11, 0x00, 0x06, 0x00, 0x44, 0x90, 0x05, 0x00, 0x43, 0x90,
+0x02, 0x80, 0x02, 0x3C, 0xC6, 0x5C, 0x45, 0x90, 0x00, 0x1B, 0x03, 0x00,
+0x00, 0x25, 0x04, 0x00, 0x25, 0x18, 0x64, 0x00, 0x10, 0x00, 0xA5, 0x30,
+0x25, 0x90, 0x43, 0x02, 0x02, 0x00, 0xA0, 0x14, 0x0F, 0x00, 0x02, 0x3C,
+0xFF, 0x0F, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34, 0x24, 0x90, 0x42, 0x02,
+0x08, 0x00, 0x73, 0x36, 0x00, 0x81, 0x11, 0x00, 0x25, 0x80, 0x13, 0x02,
+0xFF, 0xFF, 0x10, 0x32, 0x02, 0x80, 0x04, 0x3C, 0x21, 0x28, 0x20, 0x02,
+0x21, 0x30, 0x00, 0x02, 0x21, 0x38, 0x40, 0x02, 0x13, 0x58, 0x00, 0x0C,
+0x8C, 0xEB, 0x84, 0x24, 0x21, 0x20, 0x00, 0x02, 0x63, 0x5E, 0x00, 0x74,
+0x21, 0x28, 0x40, 0x02, 0x60, 0x1B, 0xA3, 0x26, 0x3A, 0x41, 0x62, 0x90,
+0x21, 0x20, 0xC0, 0x02, 0x21, 0x28, 0x20, 0x02, 0x01, 0x00, 0x42, 0x24,
+0xEA, 0x0E, 0x00, 0x0C, 0x3A, 0x41, 0x62, 0xA0, 0xEA, 0x15, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x01, 0x00, 0x02, 0x24,
+0xA0, 0xEB, 0x84, 0x24, 0xB6, 0x15, 0x00, 0x08, 0xB6, 0x40, 0xE2, 0xA2,
+0x02, 0x80, 0x04, 0x3C, 0xB8, 0xEB, 0x84, 0x24, 0xB6, 0x15, 0x00, 0x08,
+0xB6, 0x40, 0xE0, 0xA2, 0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0xA3, 0x26,
+0x03, 0x00, 0x02, 0x24, 0xCC, 0xEB, 0x84, 0x24, 0xB6, 0x15, 0x00, 0x08,
+0xB6, 0x40, 0x62, 0xA0, 0x1E, 0x00, 0x03, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x62, 0x14, 0x02, 0x80, 0x04, 0x3C, 0x20, 0x00, 0x02, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30, 0x05, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0xC8, 0xDF, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x1A, 0x00, 0x60, 0x14, 0x11, 0x00, 0x03, 0x24, 0x13, 0x58, 0x00, 0x0C,
+0xE0, 0xEB, 0x84, 0x24, 0x05, 0x00, 0x02, 0x24, 0xB8, 0x15, 0x00, 0x08,
+0xB6, 0x40, 0xE2, 0xA2, 0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0xA3, 0x26,
+0x02, 0x00, 0x02, 0x24, 0xF8, 0xEB, 0x84, 0x24, 0xB6, 0x15, 0x00, 0x08,
+0xB6, 0x40, 0x62, 0xA0, 0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0xA3, 0x26,
+0x04, 0x00, 0x02, 0x24, 0x0C, 0xEC, 0x84, 0x24, 0xB6, 0x15, 0x00, 0x08,
+0xB6, 0x40, 0x62, 0xA0, 0xFC, 0x23, 0xA2, 0x8C, 0xFF, 0xEF, 0x03, 0x24,
+0xFF, 0xF7, 0x04, 0x24, 0x24, 0x10, 0x43, 0x00, 0x24, 0x10, 0x44, 0x00,
+0x21, 0x18, 0x00, 0x00, 0x60, 0x15, 0x00, 0x08, 0xFC, 0x23, 0xA2, 0xAC,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x20, 0xEC, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0xC6, 0x5C, 0x43, 0xA0, 0x60, 0x1B, 0xA3, 0x26,
+0x06, 0x00, 0x02, 0x24, 0xB8, 0x15, 0x00, 0x08, 0xB6, 0x40, 0x62, 0xA0,
+0xFC, 0x23, 0x02, 0x8E, 0xFF, 0xF7, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x00, 0x10, 0x42, 0x34, 0x1E, 0x16, 0x00, 0x08, 0xFC, 0x23, 0x02, 0xAE,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x10, 0x3C, 0x60, 0x1B, 0x02, 0x26,
+0x14, 0x00, 0xBF, 0xAF, 0xB0, 0x1B, 0x43, 0x94, 0x21, 0x28, 0x00, 0x00,
+0x00, 0x01, 0x62, 0x30, 0x03, 0x00, 0x40, 0x10, 0x01, 0x00, 0x64, 0x30,
+0x06, 0x00, 0x80, 0x14, 0x00, 0x10, 0x62, 0x30, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0xA0, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x08, 0x00, 0x40, 0x14, 0x60, 0x1B, 0x04, 0x26,
+0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90, 0x0C, 0x00, 0x02, 0x24,
+0x0F, 0x00, 0x63, 0x30, 0x09, 0x00, 0x62, 0x10, 0x21, 0x20, 0x00, 0x00,
+0x60, 0x1B, 0x04, 0x26, 0x60, 0xEA, 0x03, 0x34, 0x04, 0x3A, 0x83, 0xAC,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0xA0, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x0E, 0x51, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x04, 0x26, 0x60, 0xEA, 0x03, 0x34,
+0xDB, 0x16, 0x00, 0x08, 0x04, 0x3A, 0x83, 0xAC, 0xD8, 0xFF, 0xBD, 0x27,
+0x1C, 0x00, 0xB1, 0xAF, 0x02, 0x80, 0x11, 0x3C, 0x18, 0x00, 0xB0, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x60, 0x1B, 0x30, 0x26, 0x04, 0x3E, 0x02, 0x8E,
+0x00, 0x10, 0x03, 0x3C, 0x24, 0x10, 0x43, 0x00, 0x12, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x33, 0x3E, 0x03, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x63, 0x24, 0xFF, 0x00, 0x62, 0x30, 0x21, 0x10, 0x50, 0x00,
+0xD0, 0x3D, 0x45, 0x90, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xA4, 0x30,
+0x18, 0x00, 0x80, 0x10, 0x33, 0x3E, 0x03, 0xA2, 0xFF, 0x3D, 0x02, 0x92,
+0xC4, 0x3D, 0x05, 0xA2, 0x75, 0x0D, 0x00, 0x0C, 0xC5, 0x3D, 0x02, 0xA2,
+0xC4, 0x3D, 0x04, 0x92, 0x38, 0x0D, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24,
+0x08, 0x3E, 0x03, 0x8E, 0x01, 0x00, 0x02, 0x24, 0x52, 0x00, 0x62, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x25, 0x26, 0x04, 0x3E, 0xA4, 0x8C,
+0x00, 0x10, 0x02, 0x3C, 0x3C, 0x00, 0x03, 0x24, 0x26, 0x20, 0x82, 0x00,
+0x94, 0x39, 0xA3, 0xAC, 0x04, 0x3E, 0xA4, 0xAC, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xB0, 0x1B, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xEF, 0x42, 0x30, 0x00, 0x01, 0x43, 0x30, 0x49, 0x00, 0x60, 0x14,
+0xB0, 0x1B, 0x02, 0xA6, 0x31, 0x3E, 0x06, 0x92, 0x37, 0x3E, 0x03, 0x92,
+0x32, 0x3E, 0x05, 0x92, 0x25, 0xB0, 0x02, 0x3C, 0x4C, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xA0, 0xFF, 0x00, 0xC4, 0x30, 0xC5, 0x3D, 0x05, 0xA2,
+0x75, 0x0D, 0x00, 0x0C, 0xC4, 0x3D, 0x06, 0xA2, 0xC4, 0x3D, 0x04, 0x92,
+0x38, 0x0D, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0xB0, 0x1B, 0x03, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x62, 0x30, 0x09, 0x00, 0x40, 0x10,
+0x01, 0x00, 0x62, 0x30, 0x08, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x30, 0x26,
+0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90, 0x0C, 0x00, 0x02, 0x24,
+0x0F, 0x00, 0x63, 0x30, 0x58, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x30, 0x26, 0x34, 0x3E, 0x04, 0x96, 0x36, 0x3E, 0x05, 0x92,
+0x95, 0x0E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x11, 0x48, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xA4, 0x27, 0x8A, 0x40, 0x00, 0x0C,
+0x04, 0x3E, 0x00, 0xAE, 0xB0, 0x1B, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x42, 0x30, 0x2A, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0xEC, 0x5D, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x60, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0xEE, 0x5D, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x04, 0x00, 0x42, 0x28,
+0x3A, 0x00, 0x40, 0x14, 0x04, 0x00, 0x04, 0x24, 0x02, 0x80, 0x03, 0x3C,
+0x0E, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x42, 0x24, 0x0E, 0x5E, 0x62, 0xA0, 0x72, 0x17, 0x00, 0x08,
+0x60, 0x1B, 0x30, 0x26, 0xC4, 0x3D, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0x42, 0x2C, 0xAB, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x12, 0x49, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x07, 0x17, 0x00, 0x08,
+0x60, 0x1B, 0x25, 0x26, 0x25, 0xB0, 0x05, 0x3C, 0x48, 0x00, 0xA5, 0x34,
+0x00, 0x00, 0xA3, 0x8C, 0x60, 0x1B, 0x24, 0x8E, 0x84, 0x00, 0x02, 0x3C,
+0x25, 0x18, 0x62, 0x00, 0x25, 0x00, 0x84, 0x34, 0x00, 0x00, 0xA3, 0xAC,
+0x18, 0x17, 0x00, 0x08, 0x60, 0x1B, 0x24, 0xAE, 0x02, 0x80, 0x02, 0x3C,
+0x0E, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90,
+0x01, 0x00, 0x05, 0x24, 0x4B, 0x2E, 0x00, 0x0C, 0xFF, 0x00, 0x84, 0x30,
+0x60, 0x1B, 0x30, 0x26, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x52, 0x41, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x96, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0x2C, 0x59, 0x84, 0x24,
+0xA0, 0xDD, 0xA5, 0x24, 0x34, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x4B, 0x41, 0x00, 0xA2, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x0D, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x4B, 0x2E, 0x00, 0x0C,
+0x01, 0x00, 0x05, 0x24, 0x4D, 0x17, 0x00, 0x08, 0x02, 0x80, 0x03, 0x3C,
+0x0E, 0x51, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0x33, 0x17, 0x00, 0x08,
+0x60, 0x1B, 0x30, 0x26, 0x02, 0x80, 0x09, 0x3C, 0x60, 0x1B, 0x28, 0x25,
+0x6C, 0x37, 0x06, 0x8D, 0xFF, 0xFF, 0x02, 0x34, 0x44, 0x00, 0xC2, 0x10,
+0x21, 0x38, 0x80, 0x00, 0x2B, 0x10, 0xC7, 0x00, 0x34, 0x00, 0x40, 0x10,
+0x02, 0x19, 0x06, 0x00, 0x21, 0x10, 0xC7, 0x00, 0x23, 0x10, 0x43, 0x00,
+0x10, 0x00, 0x46, 0x24, 0x6C, 0x37, 0x06, 0xAD, 0x70, 0x37, 0x02, 0xAD,
+0x60, 0x1B, 0x26, 0x25, 0x05, 0x00, 0xC4, 0x90, 0xFF, 0xFF, 0x02, 0x34,
+0xFF, 0x00, 0x83, 0x30, 0x33, 0x00, 0x62, 0x10, 0x00, 0x11, 0x07, 0x00,
+0xFF, 0x00, 0x84, 0x30, 0x2B, 0x10, 0x87, 0x00, 0x20, 0x00, 0x40, 0x10,
+0x03, 0x19, 0x04, 0x00, 0x03, 0x11, 0x04, 0x00, 0x21, 0x18, 0x87, 0x00,
+0x23, 0x18, 0x62, 0x00, 0x10, 0x00, 0x64, 0x24, 0x05, 0x00, 0xC4, 0xA0,
+0x70, 0x37, 0xC3, 0xAC, 0xC0, 0x10, 0x05, 0x00, 0x21, 0x10, 0x45, 0x00,
+0x80, 0x10, 0x02, 0x00, 0x21, 0x10, 0x45, 0x00, 0x60, 0x1B, 0x23, 0x25,
+0x80, 0x10, 0x02, 0x00, 0x21, 0x28, 0x43, 0x00, 0xF8, 0x24, 0xA6, 0x8C,
+0x00, 0x21, 0x07, 0x00, 0xFF, 0xFF, 0xC2, 0x38, 0x0A, 0x30, 0x82, 0x00,
+0x2B, 0x18, 0xC7, 0x00, 0x07, 0x00, 0x60, 0x10, 0x21, 0x10, 0xC7, 0x00,
+0x02, 0x19, 0x06, 0x00, 0x23, 0x10, 0x43, 0x00, 0x10, 0x00, 0x46, 0x24,
+0xF8, 0x24, 0xA6, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0xFC, 0x24, 0xA2, 0xAC,
+0x02, 0x19, 0x06, 0x00, 0x23, 0x10, 0x43, 0x00, 0xF8, 0x24, 0xA2, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xFC, 0x24, 0xA2, 0xAC, 0x21, 0x10, 0x87, 0x00,
+0x23, 0x10, 0x43, 0x00, 0x05, 0x00, 0xC2, 0xA0, 0xAB, 0x17, 0x00, 0x08,
+0x70, 0x37, 0xC2, 0xAC, 0x21, 0x10, 0xC7, 0x00, 0x23, 0x10, 0x43, 0x00,
+0x6C, 0x37, 0x02, 0xAD, 0x70, 0x37, 0x02, 0xAD, 0x60, 0x1B, 0x26, 0x25,
+0x05, 0x00, 0xC4, 0x90, 0xFF, 0xFF, 0x02, 0x34, 0xFF, 0x00, 0x83, 0x30,
+0xCF, 0xFF, 0x62, 0x14, 0x00, 0x11, 0x07, 0x00, 0x21, 0x20, 0x40, 0x00,
+0xA1, 0x17, 0x00, 0x08, 0x05, 0x00, 0xC2, 0xA0, 0x00, 0x31, 0x04, 0x00,
+0x93, 0x17, 0x00, 0x08, 0x6C, 0x37, 0x06, 0xAD, 0x63, 0x00, 0x82, 0x24,
+0x77, 0x00, 0x42, 0x2C, 0x00, 0x00, 0x85, 0x28, 0x04, 0x00, 0x40, 0x10,
+0x21, 0x18, 0x00, 0x00, 0x64, 0x00, 0x82, 0x24, 0x64, 0x00, 0x03, 0x24,
+0x0B, 0x18, 0x45, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF, 0x0C, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x42, 0x30, 0x04, 0x00, 0x42, 0x28,
+0x08, 0x00, 0x40, 0x14, 0x25, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0xA4, 0x8C,
+0x10, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xBD, 0x27, 0x3F, 0x00, 0x84, 0x30,
+0x40, 0x20, 0x04, 0x00, 0xD9, 0x17, 0x00, 0x08, 0x96, 0xFF, 0x84, 0x24,
+0x24, 0x08, 0x42, 0x34, 0x00, 0x00, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x02, 0x63, 0x30, 0x1B, 0x00, 0x60, 0x14, 0x01, 0x00, 0x02, 0x24,
+0x05, 0x00, 0xA3, 0x90, 0x00, 0x00, 0x00, 0x00, 0x82, 0x31, 0x03, 0x00,
+0x3C, 0x00, 0xC2, 0x10, 0x02, 0x00, 0xC2, 0x28, 0x57, 0x00, 0x40, 0x14,
+0x02, 0x00, 0x02, 0x24, 0x46, 0x00, 0xC2, 0x10, 0x03, 0x00, 0x02, 0x24,
+0x2E, 0x00, 0xC2, 0x10, 0x3E, 0x00, 0x63, 0x30, 0xD9, 0x17, 0x00, 0x0C,
+0x21, 0x20, 0xE0, 0x00, 0x06, 0x00, 0x45, 0x24, 0x65, 0x00, 0xA4, 0x2C,
+0x64, 0x00, 0x03, 0x24, 0x0A, 0x28, 0x64, 0x00, 0xDD, 0xFF, 0xA2, 0x24,
+0x08, 0x00, 0x42, 0x2C, 0x1F, 0x00, 0x40, 0x10, 0xE5, 0xFF, 0xA2, 0x24,
+0xFE, 0xFF, 0xA5, 0x24, 0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0xA0, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x05, 0x00, 0xA3, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x66, 0x30, 0x42, 0x31, 0x06, 0x00,
+0x25, 0x00, 0xC2, 0x10, 0x02, 0x00, 0xC2, 0x28, 0x36, 0x00, 0x40, 0x14,
+0x02, 0x00, 0x02, 0x24, 0x2F, 0x00, 0xC2, 0x10, 0x03, 0x00, 0x02, 0x24,
+0xE6, 0xFF, 0xC2, 0x14, 0x1F, 0x00, 0x62, 0x30, 0x40, 0x10, 0x02, 0x00,
+0xD8, 0xFF, 0x03, 0x24, 0x23, 0x38, 0x62, 0x00, 0xD9, 0x17, 0x00, 0x0C,
+0x21, 0x20, 0xE0, 0x00, 0x06, 0x00, 0x45, 0x24, 0x65, 0x00, 0xA4, 0x2C,
+0x64, 0x00, 0x03, 0x24, 0x0A, 0x28, 0x64, 0x00, 0xDD, 0xFF, 0xA2, 0x24,
+0x08, 0x00, 0x42, 0x2C, 0xE3, 0xFF, 0x40, 0x14, 0xE5, 0xFF, 0xA2, 0x24,
+0x08, 0x00, 0x42, 0x2C, 0x06, 0x00, 0x40, 0x10, 0xF1, 0xFF, 0xA2, 0x24,
+0x0E, 0x18, 0x00, 0x08, 0xFA, 0xFF, 0xA5, 0x24, 0xD8, 0xFF, 0x02, 0x24,
+0x03, 0x18, 0x00, 0x08, 0x23, 0x38, 0x43, 0x00, 0x0C, 0x00, 0x42, 0x2C,
+0x0C, 0x00, 0x40, 0x10, 0xFB, 0xFF, 0xA2, 0x24, 0x0E, 0x18, 0x00, 0x08,
+0xF8, 0xFF, 0xA5, 0x24, 0x3E, 0x00, 0x63, 0x30, 0xFE, 0xFF, 0x02, 0x24,
+0x03, 0x18, 0x00, 0x08, 0x23, 0x38, 0x43, 0x00, 0x1F, 0x00, 0x62, 0x30,
+0x40, 0x10, 0x02, 0x00, 0xFE, 0xFF, 0x03, 0x24, 0x21, 0x18, 0x00, 0x08,
+0x23, 0x38, 0x62, 0x00, 0x0A, 0x00, 0x42, 0x2C, 0xCB, 0xFF, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x18, 0x00, 0x08, 0xFC, 0xFF, 0xA5, 0x24,
+0x3E, 0x00, 0x63, 0x30, 0xEC, 0xFF, 0x02, 0x24, 0x03, 0x18, 0x00, 0x08,
+0x23, 0x38, 0x43, 0x00, 0x1F, 0x00, 0x62, 0x30, 0x40, 0x10, 0x02, 0x00,
+0xEC, 0xFF, 0x03, 0x24, 0x21, 0x18, 0x00, 0x08, 0x23, 0x38, 0x62, 0x00,
+0xB3, 0xFF, 0xC0, 0x14, 0x1F, 0x00, 0x62, 0x30, 0x40, 0x10, 0x02, 0x00,
+0x0E, 0x00, 0x03, 0x24, 0x21, 0x18, 0x00, 0x08, 0x23, 0x38, 0x62, 0x00,
+0xAD, 0xFF, 0xC0, 0x14, 0x3E, 0x00, 0x63, 0x30, 0x0E, 0x00, 0x02, 0x24,
+0x03, 0x18, 0x00, 0x08, 0x23, 0x38, 0x43, 0x00, 0x98, 0xFF, 0xBD, 0x27,
+0x64, 0x00, 0xBF, 0xAF, 0x60, 0x00, 0xBE, 0xAF, 0x5C, 0x00, 0xB7, 0xAF,
+0x58, 0x00, 0xB6, 0xAF, 0x54, 0x00, 0xB5, 0xAF, 0x50, 0x00, 0xB4, 0xAF,
+0x4C, 0x00, 0xB3, 0xAF, 0x48, 0x00, 0xB2, 0xAF, 0x44, 0x00, 0xB1, 0xAF,
+0x40, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0x88, 0x54, 0x45, 0x8C,
+0x00, 0x80, 0x04, 0x3C, 0x68, 0x61, 0x83, 0x24, 0x88, 0x54, 0x44, 0x24,
+0x25, 0xB0, 0x02, 0x3C, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x81, 0x00, 0xA4, 0x10, 0x02, 0x80, 0x02, 0x3C, 0xE8, 0xEC, 0x42, 0x24,
+0x00, 0x00, 0x5E, 0x8C, 0x02, 0x80, 0x03, 0x3C, 0xEC, 0xEC, 0x63, 0x24,
+0x00, 0x00, 0x75, 0x8C, 0x28, 0x39, 0xD6, 0x8F, 0x21, 0xB8, 0x00, 0x00,
+0x08, 0x00, 0xC2, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xAE,
+0x08, 0x00, 0xC3, 0x96, 0x02, 0x80, 0x02, 0x3C, 0x9E, 0x18, 0x00, 0x08,
+0x25, 0xA0, 0x62, 0x00, 0x17, 0x00, 0x25, 0x92, 0x16, 0x00, 0x26, 0x92,
+0xC8, 0x3D, 0xC2, 0x97, 0xFF, 0x00, 0xA3, 0x30, 0x00, 0x1A, 0x03, 0x00,
+0xFF, 0x00, 0xC4, 0x30, 0x25, 0x18, 0x64, 0x00, 0x14, 0x00, 0x43, 0x10,
+0xFF, 0x00, 0xA2, 0x30, 0xFF, 0x00, 0xC3, 0x30, 0x00, 0x12, 0x02, 0x00,
+0x25, 0x10, 0x43, 0x00, 0xC8, 0x3D, 0xC2, 0xA7, 0x01, 0x00, 0x24, 0x92,
+0x18, 0x00, 0x42, 0x92, 0x00, 0x22, 0x04, 0x00, 0xA8, 0x0D, 0x00, 0x0C,
+0x25, 0x20, 0x82, 0x00, 0x40, 0x18, 0x02, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x98, 0xDE, 0x82, 0x24, 0x80, 0x18, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x08, 0x00, 0x62, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x09, 0xF8, 0x40, 0x00, 0x21, 0x20, 0x60, 0x02, 0x0C, 0x00, 0xC2, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x2B, 0x10, 0xE2, 0x02, 0x41, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x8E, 0x02, 0x80, 0x03, 0x3C,
+0x48, 0x37, 0x64, 0x24, 0x42, 0x1B, 0x02, 0x00, 0x78, 0x00, 0x63, 0x30,
+0x02, 0x2E, 0x02, 0x00, 0xFF, 0x3F, 0x42, 0x30, 0x21, 0x10, 0x43, 0x00,
+0x03, 0x00, 0xA5, 0x30, 0x21, 0x10, 0x45, 0x00, 0x18, 0x00, 0x42, 0x24,
+0xFF, 0xFF, 0x50, 0x30, 0x7F, 0x00, 0x02, 0x32, 0x21, 0x98, 0x80, 0x02,
+0x06, 0x00, 0x06, 0x24, 0x80, 0x00, 0x03, 0x26, 0x00, 0x00, 0xB0, 0xAE,
+0x02, 0x00, 0x40, 0x10, 0x80, 0xFF, 0x05, 0x32, 0x80, 0xFF, 0x65, 0x30,
+0x00, 0x00, 0xA5, 0xAE, 0x02, 0x00, 0x62, 0x96, 0x21, 0x18, 0xE5, 0x02,
+0xFF, 0xFF, 0x77, 0x30, 0x0F, 0x00, 0x42, 0x30, 0x00, 0x00, 0xA2, 0xAE,
+0x00, 0x00, 0x63, 0x8E, 0x21, 0xA0, 0x85, 0x02, 0x42, 0x13, 0x03, 0x00,
+0x78, 0x00, 0x42, 0x30, 0x02, 0x1E, 0x03, 0x00, 0x03, 0x00, 0x63, 0x30,
+0x21, 0x10, 0x53, 0x00, 0x21, 0x90, 0x43, 0x00, 0x1C, 0x00, 0x50, 0x26,
+0x18, 0x00, 0x51, 0x26, 0x21, 0x28, 0x00, 0x02, 0x00, 0x00, 0xB1, 0xAE,
+0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x21, 0x28, 0x00, 0x02, 0x06, 0x00, 0x06, 0x24, 0x0B, 0x00, 0x40, 0x14,
+0x90, 0xDE, 0x64, 0x24, 0x01, 0x00, 0x22, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x12, 0x02, 0x00, 0x00, 0x08, 0x42, 0x30, 0xAD, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x26, 0x92, 0x17, 0x00, 0x25, 0x92,
+0x86, 0x18, 0x00, 0x08, 0xFF, 0x00, 0xA2, 0x30, 0x1D, 0x55, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0xC2, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x10, 0xE2, 0x02,
+0xC1, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x40, 0x00, 0x0C,
+0x38, 0x00, 0xA4, 0x27, 0x04, 0x00, 0xC3, 0x8E, 0x00, 0x00, 0xC2, 0x8E,
+0x21, 0x20, 0xC0, 0x02, 0x00, 0x00, 0x62, 0xAC, 0x04, 0x00, 0x43, 0xAC,
+0x00, 0x00, 0xD6, 0xAE, 0x74, 0x21, 0x00, 0x0C, 0x04, 0x00, 0xD6, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x38, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x88, 0x54, 0x43, 0x8C, 0x88, 0x54, 0x42, 0x24, 0x86, 0xFF, 0x62, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C, 0xE8, 0xEC, 0x63, 0x24,
+0x00, 0x00, 0x71, 0x8C, 0x25, 0xB0, 0x10, 0x3C, 0x04, 0x01, 0x02, 0x36,
+0x00, 0x00, 0x43, 0x8C, 0xDC, 0x38, 0x27, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x77, 0x00, 0xE3, 0x10, 0xE0, 0x38, 0x23, 0xAE, 0x2B, 0x10, 0x67, 0x00,
+0x81, 0x00, 0x40, 0x14, 0x2B, 0x10, 0xE3, 0x00, 0xA9, 0x00, 0x40, 0x14,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x44, 0x24, 0xB0, 0x38, 0x83, 0x94,
+0x02, 0x80, 0x02, 0x3C, 0x21, 0x80, 0x00, 0x00, 0x34, 0x00, 0xE0, 0x1A,
+0x25, 0x90, 0x62, 0x00, 0x21, 0x88, 0x80, 0x00, 0x21, 0x18, 0x00, 0x00,
+0x01, 0x00, 0x14, 0x24, 0x00, 0xC0, 0x15, 0x3C, 0x0E, 0x19, 0x00, 0x08,
+0x03, 0x00, 0x1E, 0x24, 0x80, 0x18, 0x10, 0x00, 0x2A, 0x10, 0x77, 0x00,
+0x2A, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x98, 0x72, 0x00,
+0x00, 0x00, 0x62, 0x8E, 0x44, 0x41, 0x23, 0x8E, 0x38, 0x00, 0xA4, 0x27,
+0xFF, 0x3F, 0x42, 0x30, 0x21, 0x18, 0x62, 0x00, 0x8A, 0x40, 0x00, 0x0C,
+0x44, 0x41, 0x23, 0xAE, 0xE8, 0x1E, 0x22, 0x8E, 0xF0, 0x1E, 0x23, 0x8E,
+0x38, 0x00, 0xA4, 0x27, 0x01, 0x00, 0x42, 0x24, 0x01, 0x00, 0x63, 0x24,
+0xE8, 0x1E, 0x22, 0xAE, 0x90, 0x40, 0x00, 0x0C, 0xF0, 0x1E, 0x23, 0xAE,
+0xEC, 0x2C, 0x00, 0x0C, 0x21, 0x20, 0x60, 0x02, 0x00, 0x00, 0x63, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0x14, 0x06, 0x00, 0x02, 0x26,
+0x01, 0x00, 0x02, 0x26, 0xFF, 0xFF, 0x50, 0x30, 0x82, 0x16, 0x03, 0x00,
+0x01, 0x00, 0x42, 0x30, 0xE1, 0xFF, 0x54, 0x14, 0x02, 0x80, 0x04, 0x3C,
+0x60, 0x1B, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x42, 0x11, 0x02, 0x00,
+0x01, 0x00, 0x42, 0x30, 0x0C, 0x00, 0x54, 0x10, 0xC2, 0x13, 0x03, 0x00,
+0x1E, 0x00, 0x42, 0x30, 0x21, 0x10, 0x50, 0x00, 0xFF, 0xFF, 0x50, 0x30,
+0x80, 0x18, 0x10, 0x00, 0x2A, 0x10, 0x77, 0x00, 0xD8, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x74, 0x21, 0x00, 0x0C, 0x21, 0x20, 0xC0, 0x02,
+0x75, 0x19, 0x00, 0x08, 0x02, 0x80, 0x03, 0x3C, 0x01, 0x00, 0x22, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x63, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x03, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0x11, 0x00, 0x40, 0x14, 0x02, 0x17, 0x03, 0x00,
+0x03, 0x00, 0x44, 0x30, 0x07, 0x00, 0x80, 0x10, 0x24, 0x10, 0x75, 0x00,
+0x0C, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x9E, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x80, 0x28, 0x10, 0x00, 0x21, 0x28, 0xB2, 0x00, 0xE3, 0x17, 0x00, 0x0C,
+0x21, 0x20, 0x60, 0x02, 0x21, 0x20, 0x40, 0x00, 0x8D, 0x17, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x00, 0x01, 0x00, 0x22, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x7B, 0x00, 0x54, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x23, 0x92,
+0x02, 0x00, 0x02, 0x24, 0x63, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x4C, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x63, 0x30, 0x08, 0x00, 0x74, 0x10,
+0xD0, 0x02, 0x02, 0x24, 0x00, 0x00, 0x63, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0xC2, 0x13, 0x03, 0x00, 0x1E, 0x00, 0x42, 0x30, 0x21, 0x10, 0x50, 0x00,
+0x33, 0x19, 0x00, 0x08, 0xFF, 0xFF, 0x50, 0x30, 0x6C, 0x37, 0x22, 0xAE,
+0x00, 0x00, 0x63, 0x8E, 0x67, 0x19, 0x00, 0x08, 0xC2, 0x13, 0x03, 0x00,
+0x00, 0x01, 0x02, 0x36, 0x00, 0x00, 0x47, 0xAC, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x42, 0x24, 0xDC, 0x38, 0x47, 0xAC, 0x02, 0x80, 0x03, 0x3C,
+0x08, 0x04, 0x64, 0x24, 0x21, 0x28, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00,
+0x76, 0x39, 0x00, 0x0C, 0x21, 0x38, 0x00, 0x00, 0x66, 0x18, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0xE4, 0x38, 0x22, 0x8E, 0xFF, 0xFF, 0x73, 0x30,
+0x23, 0x10, 0x47, 0x00, 0xFF, 0xFF, 0x52, 0x30, 0x21, 0x18, 0x53, 0x02,
+0xFF, 0xFF, 0x77, 0x30, 0x53, 0x21, 0x00, 0x0C, 0x21, 0x20, 0xE0, 0x02,
+0xEF, 0xFF, 0x40, 0x10, 0x21, 0xB0, 0x40, 0x00, 0x08, 0x00, 0x42, 0x8C,
+0xDC, 0x38, 0x26, 0x8E, 0x21, 0x38, 0x40, 0x02, 0x21, 0x18, 0x57, 0x00,
+0xAC, 0x38, 0x23, 0xAE, 0x21, 0x28, 0x40, 0x00, 0x08, 0x00, 0x04, 0x24,
+0xB0, 0x38, 0x22, 0xAE, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF,
+0x5B, 0x01, 0x00, 0x0C, 0x08, 0x00, 0x04, 0x24, 0xB0, 0x38, 0x25, 0x8E,
+0x24, 0x10, 0x02, 0x3C, 0x00, 0x01, 0x10, 0x36, 0x00, 0x00, 0x02, 0xAE,
+0x21, 0x38, 0x60, 0x02, 0x21, 0x28, 0xB2, 0x00, 0x08, 0x00, 0x04, 0x24,
+0x24, 0x10, 0x06, 0x3C, 0xDC, 0x38, 0x22, 0xAE, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0xE0, 0x38, 0x23, 0x8E, 0x08, 0x00, 0x04, 0x24,
+0x5B, 0x01, 0x00, 0x0C, 0xDC, 0x38, 0x23, 0xAE, 0xDC, 0x38, 0x22, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xAE, 0xFE, 0x18, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0x23, 0x10, 0x67, 0x00, 0xFF, 0xFF, 0x57, 0x30,
+0x53, 0x21, 0x00, 0x0C, 0x21, 0x20, 0xE0, 0x02, 0x44, 0x00, 0x40, 0x10,
+0x21, 0xB0, 0x40, 0x00, 0x08, 0x00, 0x42, 0x8C, 0xDC, 0x38, 0x26, 0x8E,
+0x08, 0x00, 0x04, 0x24, 0x21, 0x18, 0x57, 0x00, 0xAC, 0x38, 0x23, 0xAE,
+0x21, 0x28, 0x40, 0x00, 0x21, 0x38, 0xE0, 0x02, 0xB0, 0x38, 0x22, 0xAE,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0xE0, 0x38, 0x23, 0x8E,
+0x08, 0x00, 0x04, 0x24, 0x5B, 0x01, 0x00, 0x0C, 0xDC, 0x38, 0x23, 0xAE,
+0xDC, 0x38, 0x23, 0x8E, 0x00, 0x01, 0x02, 0x36, 0x00, 0x00, 0x43, 0xAC,
+0xFE, 0x18, 0x00, 0x08, 0x02, 0x80, 0x02, 0x3C, 0x04, 0x00, 0x63, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x14, 0x03, 0x00, 0x0F, 0x00, 0x42, 0x30,
+0x08, 0x00, 0x42, 0x28, 0x99, 0xFF, 0x40, 0x10, 0x25, 0xB0, 0x02, 0x3C,
+0x02, 0x17, 0x03, 0x00, 0x03, 0x00, 0x42, 0x30, 0x94, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x80, 0x28, 0x10, 0x00, 0x21, 0x28, 0xB2, 0x00,
+0xE3, 0x17, 0x00, 0x0C, 0x21, 0x20, 0x60, 0x02, 0x21, 0x20, 0x40, 0x00,
+0x8D, 0x17, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x5E, 0x19, 0x00, 0x08,
+0x25, 0xB0, 0x02, 0x3C, 0x04, 0x00, 0x63, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x14, 0x03, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x08, 0x00, 0x42, 0x28,
+0x06, 0x00, 0x40, 0x10, 0x24, 0x10, 0x75, 0x00, 0x02, 0x17, 0x03, 0x00,
+0x03, 0x00, 0x42, 0x30, 0x0A, 0x00, 0x40, 0x10, 0x80, 0x28, 0x10, 0x00,
+0x24, 0x10, 0x75, 0x00, 0x79, 0xFF, 0x40, 0x14, 0x02, 0x17, 0x03, 0x00,
+0x03, 0x00, 0x42, 0x30, 0x76, 0xFF, 0x5E, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x74, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x80, 0x28, 0x10, 0x00,
+0x21, 0x28, 0xB2, 0x00, 0xE3, 0x17, 0x00, 0x0C, 0x21, 0x20, 0x60, 0x02,
+0x21, 0x20, 0x40, 0x00, 0x8D, 0x17, 0x00, 0x0C, 0x05, 0x00, 0x05, 0x24,
+0x59, 0x19, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x38, 0x23, 0x8E,
+0x00, 0x01, 0x02, 0x36, 0x00, 0x00, 0x43, 0xAC, 0x74, 0x19, 0x00, 0x08,
+0xDC, 0x38, 0x23, 0xAE, 0xB8, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x03, 0x3C,
+0x44, 0x00, 0xBF, 0xAF, 0x40, 0x00, 0xBE, 0xAF, 0x3C, 0x00, 0xB7, 0xAF,
+0x38, 0x00, 0xB6, 0xAF, 0x34, 0x00, 0xB5, 0xAF, 0x30, 0x00, 0xB4, 0xAF,
+0x2C, 0x00, 0xB3, 0xAF, 0x28, 0x00, 0xB2, 0xAF, 0x24, 0x00, 0xB1, 0xAF,
+0x20, 0x00, 0xB0, 0xAF, 0x44, 0x00, 0x63, 0x34, 0x00, 0x00, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x02, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x0E, 0x00, 0x40, 0x04, 0x1C, 0x00, 0xA0, 0xAF, 0x21, 0x20, 0x60, 0x00,
+0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x42, 0x30,
+0x64, 0x00, 0x43, 0x2C, 0xFD, 0xFF, 0x60, 0x14, 0x01, 0x00, 0x42, 0x24,
+0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x02, 0x00,
+0x03, 0x16, 0x02, 0x00, 0xF6, 0xFF, 0x41, 0x04, 0x21, 0x10, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x98, 0x54, 0x43, 0x8C, 0x00, 0x80, 0x06, 0x3C,
+0xD0, 0x67, 0xC2, 0x24, 0x25, 0xB0, 0x05, 0x3C, 0x02, 0x80, 0x06, 0x3C,
+0x18, 0x03, 0xA4, 0x34, 0x98, 0x54, 0xD1, 0x24, 0x00, 0x00, 0x82, 0xAC,
+0x4B, 0x00, 0x71, 0x10, 0x01, 0x00, 0x15, 0x24, 0x11, 0x11, 0x02, 0x3C,
+0x2A, 0xB0, 0x03, 0x3C, 0x22, 0x22, 0x57, 0x34, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0xB0, 0x80, 0x00, 0x06, 0x00, 0x7E, 0x34, 0x05, 0x00, 0x73, 0x34,
+0x60, 0x1B, 0x54, 0x24, 0x01, 0x00, 0x12, 0x24, 0x00, 0x00, 0xD7, 0xAE,
+0x05, 0x00, 0xA0, 0x12, 0x02, 0x80, 0x03, 0x3C, 0xEC, 0x5D, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x40, 0x14, 0x21, 0xA8, 0x00, 0x00,
+0x00, 0x00, 0xC2, 0x97, 0x38, 0x39, 0x90, 0x8E, 0x25, 0xB0, 0x03, 0x3C,
+0xB0, 0x03, 0x63, 0x34, 0x00, 0xFF, 0x42, 0x30, 0x00, 0x00, 0x70, 0xAC,
+0x0F, 0x00, 0x40, 0x18, 0x02, 0x80, 0x06, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xF0, 0xEC, 0xC6, 0x24, 0xF4, 0xEC, 0x42, 0x24, 0x00, 0x00, 0xC5, 0x8C,
+0x00, 0x00, 0x44, 0x8C, 0x02, 0x80, 0x06, 0x3C, 0xF8, 0xEC, 0xC6, 0x24,
+0x00, 0x00, 0xC3, 0x8C, 0x00, 0x00, 0xA4, 0xAC, 0x00, 0x00, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x42, 0x30, 0xFB, 0xFF, 0x40, 0x1C,
+0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x62, 0x30, 0x60, 0x00, 0x40, 0x14, 0x08, 0x00, 0x62, 0x24,
+0xC2, 0x10, 0x03, 0x00, 0x08, 0x00, 0x05, 0x8E, 0xF8, 0x37, 0x86, 0x8E,
+0xC0, 0x10, 0x02, 0x00, 0x20, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x47, 0x30,
+0x01, 0x00, 0x04, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xB2, 0xAF,
+0x5B, 0x01, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24, 0x02, 0x00, 0x02, 0x24,
+0x18, 0x00, 0xA4, 0x27, 0x00, 0x00, 0x72, 0xA2, 0x00, 0x00, 0x62, 0xA2,
+0x8A, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x8E,
+0x04, 0x00, 0x03, 0x8E, 0x21, 0x20, 0x00, 0x02, 0x00, 0x00, 0x62, 0xAC,
+0x04, 0x00, 0x43, 0xAC, 0x00, 0x00, 0x10, 0xAE, 0x74, 0x21, 0x00, 0x0C,
+0x04, 0x00, 0x10, 0xAE, 0x90, 0x40, 0x00, 0x0C, 0x18, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x51, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xA2, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0xEC, 0x5D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x40, 0x14,
+0x1C, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0x08, 0x08, 0x44, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00, 0x76, 0x39, 0x00, 0x0C,
+0x21, 0x38, 0x00, 0x00, 0x15, 0x1A, 0x00, 0x08, 0x02, 0x80, 0x02, 0x3C,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x06, 0x3C,
+0xEE, 0x5D, 0xC2, 0x90, 0x01, 0x00, 0x03, 0x24, 0x0F, 0x00, 0x42, 0x30,
+0x04, 0x00, 0x42, 0x28, 0x0F, 0x00, 0x40, 0x14, 0x1C, 0x00, 0xA3, 0xAF,
+0x02, 0x80, 0x06, 0x3C, 0xC6, 0x5C, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x42, 0x30, 0x12, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x08, 0x04, 0x24, 0x00, 0x02, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C,
+0x01, 0x00, 0x06, 0x24, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x2F, 0x1A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x24,
+0x4B, 0x2E, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0x02, 0x80, 0x06, 0x3C,
+0xC6, 0x5C, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x42, 0x30,
+0xF0, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x2D, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x8A, 0x1A, 0x00, 0x08, 0x00, 0x08, 0x04, 0x24,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x06, 0x3C,
+0xED, 0x5D, 0xC4, 0x90, 0x01, 0x00, 0x05, 0x24, 0x4B, 0x2E, 0x00, 0x0C,
+0xFF, 0x00, 0x84, 0x30, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x73, 0x1A, 0x00, 0x08, 0x02, 0x80, 0x02, 0x3C, 0x4B, 0x1A, 0x00, 0x08,
+0xC2, 0x10, 0x02, 0x00, 0x10, 0x00, 0xE0, 0x18, 0x21, 0x18, 0x00, 0x00,
+0x00, 0x00, 0xC0, 0xAC, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x82, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x45, 0x10, 0x21, 0x18, 0x80, 0x00,
+0x01, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x48, 0x00,
+0x02, 0x00, 0x68, 0x24, 0x21, 0x10, 0x82, 0x00, 0x2B, 0x18, 0x07, 0x01,
+0xF5, 0xFF, 0x60, 0x14, 0x02, 0x00, 0x44, 0x24, 0x21, 0x18, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00, 0x01, 0x00, 0x82, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x60, 0x00, 0x02, 0x80, 0x07, 0x3C, 0x60, 0x1B, 0xE5, 0x24,
+0xCE, 0x40, 0xA3, 0x90, 0xFF, 0x00, 0x84, 0x30, 0x80, 0x10, 0x04, 0x00,
+0x0C, 0x00, 0x60, 0x14, 0x21, 0x30, 0x45, 0x00, 0xC8, 0x00, 0x02, 0x24,
+0x20, 0x3A, 0xA2, 0xAC, 0x01, 0x00, 0x03, 0x24, 0x60, 0x1B, 0xE2, 0x24,
+0x04, 0x18, 0x83, 0x00, 0xF8, 0x40, 0xA4, 0xA0, 0xCE, 0x40, 0x44, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x18, 0x64, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0xCE, 0x40, 0x43, 0xA0, 0x20, 0x3A, 0xA3, 0x8C, 0xC8, 0x00, 0x02, 0x24,
+0x23, 0x10, 0x43, 0x00, 0xD0, 0x40, 0xC2, 0xAC, 0x01, 0x00, 0x03, 0x24,
+0x60, 0x1B, 0xE2, 0x24, 0x04, 0x18, 0x83, 0x00, 0xCE, 0x40, 0x44, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x18, 0x64, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0xCE, 0x40, 0x43, 0xA0, 0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF,
+0x02, 0x80, 0x11, 0x3C, 0x10, 0x00, 0xB0, 0xAF, 0x18, 0x00, 0xBF, 0xAF,
+0x60, 0x1B, 0x25, 0x26, 0xF8, 0x40, 0xA6, 0x90, 0x01, 0x00, 0x02, 0x24,
+0x04, 0x10, 0xC2, 0x00, 0x06, 0x00, 0x40, 0x14, 0xC9, 0x00, 0x10, 0x24,
+0xC6, 0x40, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x23, 0x00, 0x40, 0x14, 0x21, 0x20, 0xC5, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x46, 0x24, 0x21, 0x20, 0x00, 0x00, 0xD0, 0x40, 0xC5, 0x24,
+0x00, 0x00, 0xA2, 0x8C, 0x04, 0x00, 0xA5, 0x24, 0x05, 0x00, 0x40, 0x10,
+0x2B, 0x18, 0x50, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x80, 0x40, 0x00, 0xF8, 0x40, 0xC4, 0xA0, 0x01, 0x00, 0x84, 0x24,
+0x08, 0x00, 0x82, 0x2C, 0xF5, 0xFF, 0x40, 0x14, 0xC9, 0x00, 0x02, 0x24,
+0x21, 0x00, 0x02, 0x12, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x45, 0x24,
+0x07, 0x00, 0x04, 0x24, 0xD0, 0x40, 0xA2, 0x8C, 0xFF, 0xFF, 0x84, 0x24,
+0x02, 0x00, 0x40, 0x10, 0x23, 0x18, 0x50, 0x00, 0xD0, 0x40, 0xA3, 0xAC,
+0xFA, 0xFF, 0x81, 0x04, 0x04, 0x00, 0xA5, 0x24, 0x60, 0x1B, 0x22, 0x26,
+0x20, 0x3A, 0x50, 0xAC, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xF0, 0x40, 0x83, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x63, 0x24,
+0xFF, 0x00, 0x62, 0x30, 0x03, 0x00, 0x42, 0x2C, 0xD8, 0xFF, 0x40, 0x10,
+0xF0, 0x40, 0x83, 0xA0, 0x80, 0x18, 0x06, 0x00, 0x21, 0x18, 0x65, 0x00,
+0xC8, 0x00, 0x02, 0x24, 0x03, 0x00, 0x04, 0x24, 0x21, 0x28, 0x00, 0x00,
+0xD9, 0x12, 0x00, 0x0C, 0xD0, 0x40, 0x62, 0xAC, 0xF2, 0x1A, 0x00, 0x08,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x22, 0x26, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x20, 0x00, 0xBD, 0x27,
+0xCE, 0x40, 0x40, 0xA0, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x3A, 0x40, 0xAC,
+0xB8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x08, 0x3C, 0x02, 0x80, 0x0B, 0x3C,
+0x02, 0x80, 0x0C, 0x3C, 0x40, 0x00, 0xBF, 0xAF, 0x3C, 0x00, 0xB5, 0xAF,
+0x38, 0x00, 0xB4, 0xAF, 0x34, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xB2, 0xAF,
+0x2C, 0x00, 0xB1, 0xAF, 0x28, 0x00, 0xB0, 0xAF, 0xE4, 0xEE, 0x63, 0x25,
+0xE0, 0xEE, 0x02, 0x25, 0xE8, 0xEE, 0x84, 0x25, 0x01, 0x00, 0x45, 0x90,
+0x01, 0x00, 0x66, 0x90, 0x01, 0x00, 0x87, 0x90, 0xE0, 0xEE, 0x0F, 0x91,
+0x02, 0x00, 0x4A, 0x90, 0xE4, 0xEE, 0x6E, 0x91, 0x02, 0x00, 0x69, 0x90,
+0xE8, 0xEE, 0x8D, 0x91, 0x02, 0x00, 0x88, 0x90, 0x03, 0x00, 0x4B, 0x90,
+0x03, 0x00, 0x6C, 0x90, 0x03, 0x00, 0x82, 0x90, 0x00, 0x2A, 0x05, 0x00,
+0x00, 0x32, 0x06, 0x00, 0x00, 0x3A, 0x07, 0x00, 0x25, 0x28, 0xAF, 0x00,
+0x25, 0x30, 0xCE, 0x00, 0x25, 0x38, 0xED, 0x00, 0x00, 0x54, 0x0A, 0x00,
+0x00, 0x4C, 0x09, 0x00, 0x00, 0x44, 0x08, 0x00, 0x25, 0x50, 0x45, 0x01,
+0x25, 0x48, 0x26, 0x01, 0x25, 0x40, 0x07, 0x01, 0x00, 0x5E, 0x0B, 0x00,
+0x00, 0x66, 0x0C, 0x00, 0x00, 0x16, 0x02, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x25, 0x58, 0x6A, 0x01, 0x25, 0x60, 0x89, 0x01, 0x25, 0x10, 0x48, 0x00,
+0xB0, 0x55, 0x84, 0x24, 0x10, 0x00, 0xAB, 0xAF, 0x18, 0x00, 0xAC, 0xAF,
+0x18, 0x52, 0x00, 0x0C, 0x20, 0x00, 0xA2, 0xAF, 0x10, 0x00, 0x42, 0x30,
+0x29, 0x00, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00, 0x02, 0x80, 0x13, 0x3C,
+0x60, 0x1B, 0x63, 0x26, 0xC0, 0x3A, 0x62, 0x8C, 0x0C, 0x00, 0x10, 0x24,
+0x2B, 0x10, 0x02, 0x02, 0x2C, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x24, 0x56, 0x51, 0x24, 0x2E, 0x56, 0x72, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x26, 0x56, 0x54, 0x24,
+0x7C, 0x1B, 0x00, 0x08, 0x32, 0x56, 0x75, 0x24, 0xDD, 0x00, 0x02, 0x24,
+0x21, 0x20, 0x14, 0x02, 0x2B, 0x00, 0x62, 0x10, 0x10, 0x00, 0xA5, 0x27,
+0x21, 0x10, 0x11, 0x02, 0x01, 0x00, 0x43, 0x90, 0x60, 0x1B, 0x64, 0x26,
+0xC0, 0x3A, 0x82, 0x8C, 0x21, 0x18, 0x70, 0x00, 0x02, 0x00, 0x70, 0x24,
+0x2B, 0x10, 0x02, 0x02, 0x17, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0x11, 0x02, 0x00, 0x00, 0x43, 0x90, 0x30, 0x00, 0x02, 0x24,
+0x21, 0x20, 0x12, 0x02, 0x20, 0x00, 0xA5, 0x27, 0xED, 0xFF, 0x62, 0x14,
+0x04, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xEE, 0xFF, 0x40, 0x14, 0x21, 0x10, 0x11, 0x02, 0x01, 0x00, 0x03, 0x24,
+0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F,
+0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F,
+0x28, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x48, 0x00, 0xBD, 0x27, 0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB5, 0x8F,
+0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F,
+0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F, 0x21, 0x18, 0x00, 0x00,
+0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27,
+0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x15, 0x02,
+0x18, 0x00, 0xA5, 0x27, 0xD1, 0xFF, 0x40, 0x14, 0x04, 0x00, 0x06, 0x24,
+0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xFF, 0x40, 0x14,
+0x21, 0x10, 0x11, 0x02, 0x88, 0x1B, 0x00, 0x08, 0x01, 0x00, 0x03, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x65, 0x24, 0xB0, 0x1B, 0xA2, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x34, 0x08, 0x00, 0x40, 0x10,
+0x70, 0x17, 0x04, 0x24, 0xB6, 0x40, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFB, 0xFF, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30, 0x02, 0x00, 0x42, 0x2C,
+0x0A, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xB4, 0x40, 0xA3, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x80, 0x18, 0x03, 0x00, 0x70, 0x17, 0x62, 0x28,
+0x04, 0x00, 0x40, 0x14, 0x70, 0x17, 0x04, 0x24, 0x21, 0x4E, 0x62, 0x28,
+0x20, 0x4E, 0x04, 0x24, 0x0B, 0x20, 0x62, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x80, 0x00, 0x21, 0x38, 0x80, 0x00, 0x08, 0x00, 0xC0, 0x10,
+0xFF, 0xFF, 0xC3, 0x24, 0xFF, 0xFF, 0x06, 0x24, 0x00, 0x00, 0xA2, 0x8C,
+0xFF, 0xFF, 0x63, 0x24, 0x04, 0x00, 0xA5, 0x24, 0x00, 0x00, 0xE2, 0xAC,
+0xFB, 0xFF, 0x66, 0x14, 0x04, 0x00, 0xE7, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x80, 0x00, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x10, 0xF0, 0x00, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x00, 0xF3,
+0x18, 0x4A, 0x2D, 0xF7, 0x19, 0x4B, 0xF9, 0x63, 0x60, 0xDA, 0x00, 0x6A,
+0x0C, 0x62, 0x0B, 0xD1, 0x0A, 0xD0, 0x07, 0xD2, 0xC9, 0xF7, 0x1B, 0x6A,
+0x4B, 0xEA, 0x40, 0x31, 0x20, 0x31, 0x10, 0xF0, 0x00, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x10, 0xF3, 0x68, 0x41, 0x2D, 0xF7, 0x19, 0x4A, 0x40, 0xDB,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x66, 0xF7, 0x48, 0xAB, 0x01, 0x4A, 0x66, 0xF7, 0x48, 0xCB, 0x00, 0x1C,
+0x9B, 0x40, 0x00, 0x65, 0xC0, 0xF0, 0x46, 0x41, 0x40, 0xAA, 0x11, 0x5A,
+0x12, 0x61, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x10, 0xF0,
+0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0xAB, 0xF5, 0x50, 0x9C, 0xCB, 0xF5,
+0x68, 0x9D, 0x6D, 0xEA, 0xAB, 0xF5, 0x50, 0xDC, 0x00, 0x6A, 0xCB, 0xF5,
+0x48, 0xDD, 0x00, 0x1C, 0x96, 0x40, 0x00, 0x65, 0x70, 0xF3, 0x60, 0x41,
+0xE0, 0x9B, 0x06, 0x27, 0x07, 0x92, 0xFF, 0xF7, 0x1F, 0x6C, 0x01, 0x4A,
+0x8C, 0xEA, 0x07, 0xD2, 0xFF, 0x6D, 0x01, 0x4D, 0xA0, 0x36, 0xC0, 0x30,
+0x4F, 0x40, 0xE3, 0xEA, 0x0D, 0x65, 0x80, 0xF0, 0x1E, 0x60, 0xFF, 0x6A,
+0x01, 0x4A, 0x4B, 0xEA, 0x40, 0x35, 0xA0, 0x35, 0xF0, 0xF0, 0x4F, 0x45,
+0x62, 0x67, 0x2A, 0x65, 0x00, 0xF3, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x34,
+0x80, 0x34, 0x47, 0x44, 0xEC, 0xEB, 0x11, 0x4A, 0x4A, 0xEB, 0x80, 0xF0,
+0x17, 0x60, 0x63, 0xEA, 0xA0, 0xF0, 0x04, 0x61, 0x01, 0xF6, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x35, 0xA0, 0x35, 0x41, 0x45, 0x4A, 0xEB, 0xC0, 0xF0,
+0x04, 0x60, 0x63, 0xEA, 0x00, 0xF1, 0x09, 0x61, 0x02, 0xF0, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x34, 0x80, 0x34, 0x43, 0x44, 0x4A, 0xEB, 0x40, 0xF1,
+0x17, 0x60, 0x63, 0xEA, 0xC0, 0xF1, 0x18, 0x61, 0x8A, 0xEB, 0x00, 0xF3,
+0x12, 0x60, 0x63, 0xEC, 0x80, 0xF3, 0x08, 0x61, 0x04, 0xF0, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x6E, 0xEA, 0xE0, 0xF3, 0x12, 0x22,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x00, 0x6B,
+0x60, 0xF3, 0x10, 0x4A, 0x60, 0xDA, 0x07, 0xD3, 0xC9, 0xF7, 0x1B, 0x68,
+0x0B, 0xE8, 0x00, 0x30, 0x00, 0x30, 0x10, 0xF0, 0x00, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x10, 0xF3, 0x68, 0x40, 0x2E, 0xF0, 0x19, 0x4A, 0x40, 0xDB,
+0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30, 0x00, 0x1C, 0x9B, 0x40,
+0xFF, 0x69, 0x63, 0xF3, 0x00, 0x48, 0x10, 0x10, 0xC9, 0xF7, 0x1B, 0x6D,
+0xAB, 0xED, 0xA0, 0x35, 0xA0, 0x35, 0x7F, 0x4D, 0x40, 0x4D, 0x40, 0xA5,
+0x2C, 0xEA, 0x04, 0x5A, 0x0F, 0x60, 0x27, 0xF1, 0x90, 0x98, 0x00, 0x1C,
+0xF5, 0x09, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x8A, 0xF4, 0x10, 0x4C, 0x00, 0x1C, 0x6A, 0x58, 0x00, 0x65, 0xE6, 0x22,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xEB, 0xF5, 0x4E, 0xA3,
+0x0F, 0x6B, 0xFF, 0x6C, 0x6C, 0xEA, 0x02, 0x72, 0x0B, 0x61, 0x10, 0xF0,
+0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0xEB, 0xF5, 0x4D, 0xA5, 0x8C, 0xEA,
+0x6C, 0xEA, 0x01, 0x72, 0x40, 0xF4, 0x00, 0x60, 0x00, 0x1C, 0x96, 0x40,
+0x00, 0x65, 0x00, 0x6D, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x02, 0xF0, 0x08, 0x4C, 0xC5, 0x67, 0x00, 0x1C, 0x76, 0x39, 0xE5, 0x67,
+0x19, 0x17, 0x07, 0x94, 0x0A, 0xF0, 0x00, 0x5C, 0xA5, 0x61, 0x00, 0x6A,
+0x40, 0xDB, 0x07, 0xD2, 0x01, 0x6A, 0x70, 0xF3, 0x64, 0x41, 0x4B, 0xEA,
+0x40, 0xDB, 0x9C, 0x17, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x0C, 0xF0, 0x00, 0x6A, 0x63, 0xF3, 0x00, 0x4D, 0x4B, 0xEA, 0x62, 0x9D,
+0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0x62, 0xDD, 0x82, 0x17,
+0xA0, 0xF0, 0x4C, 0x44, 0x4A, 0xEB, 0x00, 0xF4, 0x17, 0x60, 0x63, 0xEA,
+0x39, 0x61, 0xA0, 0xF0, 0x42, 0x44, 0x4A, 0xEB, 0x20, 0xF4, 0x0D, 0x60,
+0x63, 0xEA, 0xE0, 0xF0, 0x02, 0x61, 0x47, 0x44, 0x21, 0x4A, 0x4A, 0xEB,
+0x40, 0xF4, 0x11, 0x60, 0x63, 0xEA, 0xC0, 0xF1, 0x1D, 0x61, 0x47, 0x44,
+0x12, 0x4A, 0x6E, 0xEA, 0x7F, 0xF7, 0x06, 0x2A, 0xC9, 0xF7, 0x1B, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x00, 0x6B, 0x60, 0xF3, 0x10, 0x4A,
+0x60, 0xDA, 0x00, 0x18, 0x12, 0x27, 0x87, 0x67, 0x59, 0x17, 0x70, 0xF3,
+0x44, 0x41, 0xE0, 0x9A, 0x02, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x40, 0x32,
+0xFF, 0x4A, 0x4C, 0xEF, 0xE3, 0xEE, 0x5F, 0xF7, 0x0D, 0x60, 0x0A, 0xF0,
+0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x4D, 0xEF, 0x70, 0xF3,
+0x48, 0x41, 0xC0, 0x9A, 0xC0, 0xDF, 0x42, 0x17, 0x00, 0xF2, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x36, 0xC0, 0x36, 0x47, 0x46, 0x0B, 0x4A, 0x4A, 0xEB,
+0xC0, 0xF3, 0x17, 0x60, 0x63, 0xEA, 0xC0, 0xF0, 0x01, 0x61, 0xA0, 0xF0,
+0x4F, 0x44, 0x4A, 0xEB, 0x20, 0xF4, 0x15, 0x60, 0x63, 0xEA, 0x60, 0xF1,
+0x18, 0x61, 0xA0, 0xF0, 0x4D, 0x44, 0x6E, 0xEA, 0x60, 0xF4, 0x09, 0x22,
+0xA0, 0xF0, 0x4E, 0x44, 0x6E, 0xEA, 0x3F, 0xF7, 0x03, 0x2A, 0x1F, 0xF7,
+0x00, 0x6A, 0xE2, 0x34, 0x4C, 0xEC, 0x4C, 0xEF, 0x82, 0x34, 0x00, 0x18,
+0x3B, 0x5D, 0xE2, 0x35, 0xC9, 0xF7, 0x1B, 0x6B, 0x6B, 0xEB, 0x60, 0x33,
+0x60, 0x33, 0x60, 0xF3, 0x14, 0x4B, 0x40, 0xC3, 0x11, 0x17, 0x01, 0xF0,
+0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x35, 0xA0, 0x35, 0x47, 0x45, 0x0F, 0x4A,
+0x4A, 0xEB, 0xC0, 0xF3, 0x1A, 0x60, 0x63, 0xEA, 0xA0, 0xF0, 0x19, 0x61,
+0x01, 0xF4, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x4A, 0xEB,
+0x00, 0xF4, 0x06, 0x60, 0x63, 0xEA, 0xE0, 0xF1, 0x13, 0x61, 0x01, 0xF5,
+0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x6E, 0xEA, 0xFF, 0xF6,
+0x11, 0x2A, 0x1F, 0xF7, 0x00, 0x6A, 0xEC, 0xEA, 0x42, 0x30, 0x01, 0xF7,
+0x00, 0x6B, 0xE2, 0x32, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x6C, 0xEA, 0x63, 0xF3, 0x00, 0x4D, 0x42, 0x36, 0x28, 0xF1, 0xDB, 0xC5,
+0x20, 0xF3, 0x06, 0x26, 0xA3, 0xF3, 0x50, 0xAD, 0x10, 0xF0, 0x00, 0x6B,
+0x6B, 0xEB, 0x10, 0xF0, 0x00, 0x6C, 0x6D, 0xEA, 0xA3, 0xF3, 0x50, 0xCD,
+0x1E, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x4C, 0xEF, 0xFF, 0x6A, 0x4C, 0xE8,
+0x00, 0xF5, 0xE2, 0x31, 0x4C, 0xEE, 0x00, 0x1C, 0x3C, 0x0E, 0xB0, 0x67,
+0x90, 0x67, 0x00, 0x1C, 0x38, 0x0D, 0xB1, 0x67, 0xC9, 0xF7, 0x1B, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x60, 0xF3, 0x10, 0x4A, 0x00, 0x6B,
+0x60, 0xDA, 0xBA, 0x16, 0x1F, 0xF7, 0x00, 0x6B, 0xE2, 0x32, 0x6C, 0xEA,
+0x42, 0x32, 0xEC, 0xEB, 0x06, 0xD2, 0x62, 0x37, 0x80, 0xF3, 0x08, 0x22,
+0x01, 0x72, 0x01, 0x6C, 0x01, 0x60, 0x00, 0x6C, 0x00, 0x1C, 0xF0, 0x42,
+0x09, 0xD7, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x09, 0x97, 0x70, 0xF3, 0x24, 0x42, 0xC0, 0x99, 0x02, 0xF0, 0x00, 0x68,
+0x00, 0x30, 0x87, 0x67, 0xAF, 0x40, 0x00, 0x1C, 0x83, 0x45, 0x09, 0xD7,
+0x09, 0x97, 0xAF, 0x40, 0x00, 0x1C, 0xAC, 0x45, 0x87, 0x67, 0x40, 0xD9,
+0x91, 0x16, 0xA0, 0xF0, 0x45, 0x44, 0x4A, 0xEB, 0x60, 0xF3, 0x06, 0x60,
+0x63, 0xEA, 0x00, 0xF1, 0x0D, 0x61, 0xA0, 0xF0, 0x43, 0x44, 0x6E, 0xEA,
+0x40, 0xF1, 0x02, 0x22, 0xA0, 0xF0, 0x44, 0x44, 0x6E, 0xEA, 0x7F, 0xF6,
+0x1F, 0x2A, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0xFF, 0xF7, 0x1F, 0x6A, 0x27, 0xF1, 0x44, 0xDB, 0x74, 0x16,
+0x47, 0x46, 0x13, 0x4A, 0x4A, 0xEB, 0x80, 0xF0, 0x16, 0x60, 0x63, 0xEA,
+0x00, 0xF1, 0x1B, 0x61, 0x47, 0x46, 0x11, 0x4A, 0x6E, 0xEA, 0xE0, 0xF3,
+0x05, 0x22, 0x47, 0x46, 0x12, 0x4A, 0x6E, 0xEA, 0x7F, 0xF6, 0x02, 0x2A,
+0x00, 0x1C, 0x9B, 0x40, 0x00, 0x65, 0xC9, 0xF7, 0x1B, 0x6A, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x4B, 0xEA, 0x63, 0xF3, 0x00, 0x4B,
+0x40, 0x32, 0x23, 0xF4, 0x6A, 0xA3, 0x40, 0x32, 0x60, 0xF3, 0x14, 0x4A,
+0x60, 0xDA, 0x00, 0x1C, 0x96, 0x40, 0x00, 0x65, 0x4B, 0x16, 0x47, 0x44,
+0x4A, 0xEB, 0x80, 0xF3, 0x03, 0x60, 0x63, 0xEA, 0x00, 0xF1, 0x0C, 0x61,
+0x47, 0x45, 0x10, 0x4A, 0x6E, 0xEA, 0xC0, 0xF3, 0x11, 0x22, 0x47, 0x45,
+0x11, 0x4A, 0x6E, 0xEA, 0x3F, 0xF6, 0x1A, 0x2A, 0x00, 0x1C, 0x2B, 0x20,
+0x00, 0x65, 0x36, 0x16, 0x01, 0xF7, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x36,
+0xC0, 0x36, 0x42, 0x46, 0x4A, 0xEB, 0x3F, 0xF6, 0x0D, 0x60, 0x63, 0xEA,
+0x80, 0xF1, 0x04, 0x61, 0x47, 0x44, 0x01, 0x4A, 0x6E, 0xEA, 0xE0, 0xF1,
+0x01, 0x22, 0x43, 0x67, 0xCE, 0xEA, 0x3F, 0xF6, 0x01, 0x2A, 0xFF, 0x6A,
+0x01, 0x4A, 0x40, 0x32, 0x40, 0x32, 0x80, 0x4A, 0x80, 0x4A, 0x4C, 0xEF,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0xE2, 0x33, 0x63, 0xF3,
+0x00, 0x4C, 0xA3, 0xF3, 0x7A, 0xCC, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC,
+0x80, 0x34, 0x80, 0x34, 0x90, 0xF0, 0x44, 0x44, 0x60, 0xCA, 0x90, 0xF0,
+0xAA, 0x44, 0x00, 0xF4, 0x00, 0x6A, 0x40, 0xCD, 0x90, 0xF0, 0xA8, 0x44,
+0xA0, 0x6A, 0x40, 0xCD, 0xC9, 0xF7, 0x1A, 0x6D, 0xAB, 0xED, 0xA0, 0x35,
+0x04, 0x6E, 0x90, 0xF0, 0x46, 0x44, 0xA0, 0x35, 0xC0, 0xCA, 0x47, 0x45,
+0x73, 0x4A, 0xC0, 0xC2, 0xFF, 0xF7, 0x1F, 0x6A, 0x4C, 0xEB, 0x74, 0x33,
+0xC8, 0x43, 0xC8, 0x4E, 0xB0, 0xF3, 0x40, 0x44, 0xC0, 0xDA, 0x60, 0xF0,
+0xDC, 0xCD, 0x40, 0xF0, 0x64, 0xAC, 0x00, 0xF2, 0x01, 0x6A, 0x4B, 0xEA,
+0x6C, 0xEA, 0x40, 0xF0, 0x44, 0xCC, 0x40, 0xF0, 0x64, 0xAC, 0x00, 0xF2,
+0x00, 0x6A, 0x6D, 0xEA, 0x40, 0xF0, 0x44, 0xCC, 0xD9, 0x15, 0x0F, 0xF7,
+0x40, 0x40, 0x4C, 0xEF, 0xE2, 0x37, 0x87, 0x67, 0xFF, 0xF7, 0x1F, 0x6D,
+0xAC, 0xEC, 0x01, 0x74, 0x06, 0xD4, 0xA0, 0xF0, 0x18, 0x60, 0x02, 0x54,
+0x20, 0xF3, 0x13, 0x61, 0x06, 0x92, 0x03, 0x72, 0xE0, 0xF1, 0x19, 0x60,
+0xC9, 0xF7, 0x1B, 0x6A, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x4B, 0xEA, 0x63, 0xF3, 0x00, 0x4B, 0x40, 0x32, 0x23, 0xF4, 0x64, 0xAB,
+0x40, 0x32, 0x60, 0xF3, 0x14, 0x4A, 0x60, 0xDA, 0xB5, 0x15, 0x47, 0x46,
+0x09, 0x4A, 0x6E, 0xEA, 0xE0, 0xF2, 0x16, 0x22, 0x47, 0x46, 0x0A, 0x4A,
+0x6E, 0xEA, 0xBF, 0xF5, 0x0B, 0x2A, 0x00, 0x1C, 0x9B, 0x40, 0x09, 0xD7,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x00, 0x6A, 0x63, 0xF3,
+0x00, 0x4B, 0x23, 0xF4, 0x4A, 0xC3, 0xFF, 0x6A, 0x01, 0x4A, 0x40, 0x32,
+0x40, 0x32, 0x09, 0x97, 0x80, 0x4A, 0x80, 0x4A, 0x4C, 0xEF, 0xE0, 0x34,
+0x82, 0x34, 0x00, 0x1C, 0xA3, 0x31, 0x82, 0x34, 0x00, 0x1C, 0x96, 0x40,
+0x00, 0x65, 0x8E, 0x15, 0xA0, 0xF0, 0x40, 0x44, 0x6E, 0xEA, 0x80, 0xF0,
+0x1B, 0x22, 0xA0, 0xF0, 0x41, 0x44, 0x6E, 0xEA, 0x9F, 0xF5, 0x04, 0x2A,
+0xE2, 0x34, 0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEC, 0x00, 0x18, 0x11, 0x22,
+0x82, 0x34, 0x7C, 0x15, 0xA0, 0xF0, 0x46, 0x44, 0x6E, 0xEA, 0xC0, 0xF2,
+0x1B, 0x22, 0xA0, 0xF0, 0x47, 0x44, 0x6E, 0xEA, 0x7F, 0xF5, 0x12, 0x2A,
+0x1F, 0xF7, 0x00, 0x6A, 0xE2, 0x33, 0x4C, 0xEF, 0xE2, 0x36, 0x4C, 0xEB,
+0x01, 0x76, 0x62, 0x35, 0xA0, 0xF1, 0x17, 0x61, 0xAC, 0x32, 0xA9, 0xE2,
+0x48, 0x32, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0xA9, 0xE2,
+0xC9, 0xF7, 0x1B, 0x6B, 0x63, 0xF3, 0x00, 0x4C, 0x48, 0x32, 0x6B, 0xEB,
+0x89, 0xE2, 0x60, 0x33, 0x04, 0xF5, 0x40, 0x9A, 0x60, 0x33, 0x60, 0xF3,
+0x14, 0x4B, 0x40, 0xDB, 0x51, 0x15, 0x47, 0x45, 0x08, 0x4A, 0x6E, 0xEA,
+0x71, 0x22, 0x47, 0x45, 0x09, 0x4A, 0x6E, 0xEA, 0x5F, 0xF5, 0x08, 0x2A,
+0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEF, 0x4A, 0xEF, 0xDF, 0xF6, 0x03, 0x60,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x00, 0x6A, 0x27, 0xF1, 0x44, 0xDB, 0x38, 0x15, 0x47, 0x44, 0x0D, 0x4A,
+0x6E, 0xEA, 0x69, 0x22, 0x47, 0x44, 0x10, 0x4A, 0x6E, 0xEA, 0x3F, 0xF5,
+0x0F, 0x2A, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34,
+0x60, 0xF3, 0xA8, 0x44, 0x60, 0x9D, 0xFF, 0xF7, 0x1F, 0x6A, 0x60, 0xF3,
+0x04, 0x4C, 0x4C, 0xEB, 0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEF, 0xE0, 0x32,
+0x6D, 0xEA, 0x40, 0xDD, 0x60, 0xA4, 0xFF, 0x6A, 0x6C, 0xEA, 0x40, 0x6B,
+0x6D, 0xEA, 0x40, 0xC4, 0x15, 0x15, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x23, 0xF4, 0x42, 0xAA, 0xFF, 0xF7,
+0x1F, 0x6D, 0x70, 0xF3, 0x64, 0x41, 0xAC, 0xEA, 0x40, 0xDB, 0x06, 0x15,
+0x01, 0x4A, 0x6E, 0xEA, 0xA0, 0xF0, 0x0D, 0x22, 0x47, 0x45, 0x0E, 0x4A,
+0x6E, 0xEA, 0xFF, 0xF4, 0x1D, 0x2A, 0x00, 0x1C, 0xAE, 0x1F, 0x00, 0x65,
+0xF9, 0x14, 0x0F, 0xF7, 0x40, 0x40, 0xEC, 0xEA, 0x42, 0x37, 0x2D, 0xE7,
+0xC0, 0x9B, 0x70, 0xF3, 0x44, 0x41, 0xC0, 0xDA, 0xC0, 0x9B, 0xEE, 0x14,
+0x01, 0xF7, 0x00, 0x6A, 0x4C, 0xEF, 0xE2, 0x32, 0x01, 0x72, 0x01, 0x6C,
+0x07, 0x60, 0x02, 0x72, 0x02, 0x6C, 0x04, 0x60, 0x03, 0x72, 0x03, 0x6C,
+0x01, 0x60, 0x00, 0x6C, 0x00, 0x18, 0x92, 0x5D, 0x00, 0x65, 0xDC, 0x14,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x40, 0xF1,
+0x16, 0x4A, 0xFF, 0x6B, 0x60, 0xCA, 0x01, 0x6A, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0xEB, 0xF4, 0x50, 0xC3, 0xCB, 0x14, 0x0F, 0xF7,
+0x40, 0x40, 0xEC, 0xEA, 0xDF, 0xF4, 0x06, 0x22, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0x44, 0x9B,
+0xA9, 0x67, 0x88, 0x67, 0xAC, 0xEA, 0x8D, 0xEA, 0x00, 0xF3, 0x44, 0xDB,
+0x1F, 0xF7, 0x00, 0x6C, 0xE2, 0x32, 0x8C, 0xEA, 0x42, 0x32, 0x00, 0xF3,
+0x5C, 0xC3, 0x8C, 0xEF, 0xFB, 0x4A, 0x00, 0xF3, 0x5D, 0xC3, 0xE2, 0x32,
+0x00, 0xF3, 0x5E, 0xC3, 0xFB, 0x4A, 0x00, 0xF3, 0x5F, 0xC3, 0xA6, 0x14,
+0x44, 0x46, 0x6E, 0xEA, 0x6D, 0x22, 0x43, 0x67, 0xAE, 0xEA, 0x9F, 0xF4,
+0x1F, 0x2A, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x33, 0x60, 0x33,
+0x70, 0xF3, 0x44, 0x43, 0xE0, 0x9A, 0x02, 0xF0, 0x00, 0x6A, 0x40, 0x32,
+0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEF, 0xFF, 0x6A, 0x01, 0x4A, 0x40, 0x32,
+0xE3, 0xEA, 0x9F, 0xF4, 0x0B, 0x60, 0x0A, 0xF0, 0x00, 0x6A, 0x4B, 0xEA,
+0x40, 0x32, 0x40, 0x32, 0x4D, 0xEF, 0xC0, 0x9F, 0x70, 0xF3, 0x48, 0x43,
+0xC0, 0xDA, 0x80, 0x14, 0x41, 0x44, 0x6E, 0xEA, 0x5E, 0x22, 0x42, 0x44,
+0x6E, 0xEA, 0x7F, 0xF4, 0x19, 0x2A, 0x1F, 0xF7, 0x00, 0x6B, 0xE2, 0x32,
+0x6C, 0xEA, 0x42, 0x32, 0xEC, 0xEB, 0x06, 0xD2, 0x62, 0x37, 0x20, 0xF2,
+0x0C, 0x22, 0x01, 0x72, 0x01, 0x6C, 0x01, 0x60, 0x00, 0x6C, 0x00, 0x1C,
+0xF0, 0x42, 0x09, 0xD7, 0x09, 0x97, 0x02, 0xF0, 0x00, 0x68, 0x00, 0x30,
+0xAF, 0x40, 0x00, 0x1C, 0xAC, 0x45, 0x87, 0x67, 0xFF, 0x48, 0x4C, 0xE8,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x60, 0xF3,
+0x14, 0x4A, 0x00, 0xDA, 0x55, 0x14, 0xC9, 0xF7, 0x1B, 0x6A, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x4B, 0xEA, 0x63, 0xF3, 0x00, 0x4B,
+0x40, 0x32, 0xC4, 0xF7, 0x7C, 0xAB, 0x40, 0x32, 0x60, 0xF3, 0x14, 0x4A,
+0x60, 0xDA, 0x44, 0x14, 0x1F, 0xF7, 0x00, 0x6A, 0xEC, 0xEA, 0x42, 0x37,
+0x87, 0x67, 0x04, 0x27, 0x01, 0x77, 0x01, 0x6C, 0x01, 0x60, 0x00, 0x6C,
+0x00, 0x1C, 0xF0, 0x42, 0x00, 0x65, 0x36, 0x14, 0x1F, 0xF7, 0x00, 0x6B,
+0x47, 0x67, 0x6C, 0xEA, 0x42, 0x32, 0x06, 0xD2, 0xE2, 0x32, 0x6C, 0xEA,
+0x42, 0x36, 0x07, 0x5E, 0x3F, 0xF4, 0x0A, 0x60, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0xC8, 0x32, 0x1D, 0xF7, 0x14, 0x4B, 0x69, 0xE2,
+0x40, 0x9A, 0x00, 0xEA, 0x00, 0x65, 0x0F, 0xF7, 0x40, 0x40, 0xEC, 0xEA,
+0x42, 0x37, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x70, 0xF3, 0x64, 0x42, 0xC0, 0x9B, 0x49, 0xE7, 0xC0, 0xDA, 0xC0, 0x9A,
+0xC0, 0xDB, 0x0E, 0x14, 0x1F, 0xF7, 0x00, 0x6A, 0xEC, 0xEA, 0x42, 0x32,
+0xFF, 0x72, 0x71, 0x61, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x60, 0xF3, 0x04, 0x4A, 0x60, 0xAA, 0x88, 0x67, 0x6D, 0xEC,
+0x80, 0xCA, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x06, 0xF0,
+0x00, 0x6A, 0x63, 0xF3, 0x00, 0x4C, 0x4B, 0xEA, 0xE0, 0xF2, 0x64, 0x9C,
+0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0xE0, 0xF2, 0x64, 0xDC,
+0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEF, 0x19, 0xF4, 0x00, 0x77, 0xFF, 0xF3,
+0x05, 0x61, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x06, 0xF0,
+0x00, 0x6A, 0x63, 0xF3, 0x00, 0x4C, 0x4B, 0xEA, 0xE0, 0xF2, 0x64, 0x9C,
+0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0x02, 0xF0, 0x00, 0x6A,
+0x40, 0x32, 0x40, 0x32, 0x4D, 0xEB, 0xE0, 0xF2, 0x64, 0xDC, 0xDF, 0xF3,
+0x0D, 0x10, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xC9, 0xF7,
+0x1B, 0x6A, 0x63, 0xF3, 0x00, 0x4B, 0x4B, 0xEA, 0x23, 0xF4, 0x66, 0xAB,
+0x40, 0x32, 0x40, 0x32, 0xFF, 0xF7, 0x1F, 0x6C, 0x60, 0xF3, 0x14, 0x4A,
+0x8C, 0xEB, 0x60, 0xDA, 0xBF, 0xF3, 0x18, 0x10, 0xA3, 0xF3, 0x50, 0xAD,
+0xEF, 0xF7, 0x1F, 0x6B, 0x86, 0x67, 0x6C, 0xEA, 0xDB, 0x14, 0x02, 0x76,
+0x27, 0x61, 0xAC, 0x32, 0xA9, 0xE2, 0x48, 0x32, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0xA9, 0xE2, 0xC9, 0xF7, 0x1B, 0x6B, 0x63, 0xF3,
+0x00, 0x4C, 0x48, 0x32, 0x6B, 0xEB, 0x89, 0xE2, 0x60, 0x33, 0x04, 0xF5,
+0x44, 0x9A, 0x60, 0x33, 0x60, 0xF3, 0x14, 0x4B, 0x40, 0xDB, 0x9F, 0xF3,
+0x17, 0x10, 0xAA, 0x2A, 0xC9, 0xF7, 0x1B, 0x6B, 0x6B, 0xEB, 0x60, 0x33,
+0x60, 0x33, 0x60, 0xF3, 0x04, 0x4B, 0x80, 0xAB, 0xFF, 0x6A, 0x02, 0x4A,
+0x4B, 0xEA, 0x8C, 0xEA, 0x40, 0xCB, 0x8B, 0x17, 0x03, 0x76, 0x9F, 0xF3,
+0x05, 0x61, 0xAC, 0x32, 0xA9, 0xE2, 0x48, 0x32, 0xA9, 0xE2, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xC9, 0xF7, 0x1B, 0x6C, 0x48, 0x32,
+0x68, 0xF0, 0x08, 0x4B, 0x8B, 0xEC, 0x69, 0xE2, 0x80, 0x34, 0x40, 0x9A,
+0x80, 0x34, 0x60, 0xF3, 0x14, 0x4C, 0x40, 0xDC, 0x7F, 0xF3, 0x0E, 0x10,
+0xEB, 0xF5, 0x4D, 0xA5, 0x01, 0x6D, 0x00, 0x1C, 0x4B, 0x2E, 0x4C, 0xEC,
+0xBF, 0xF3, 0x18, 0x10, 0x00, 0x18, 0x84, 0x5C, 0x87, 0x67, 0x7F, 0xF3,
+0x01, 0x10, 0x00, 0x1C, 0x9B, 0x40, 0x09, 0xD7, 0x09, 0x97, 0x0F, 0xF7,
+0x40, 0x40, 0xFF, 0xF7, 0x1F, 0x6D, 0x4C, 0xEF, 0xE2, 0x32, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xAC, 0xEA, 0x63, 0xF3, 0x00, 0x4B,
+0x23, 0xF4, 0x4B, 0xC3, 0x00, 0x1C, 0x96, 0x40, 0x00, 0x65, 0x5F, 0xF3,
+0x09, 0x10, 0x0F, 0xF7, 0x40, 0x40, 0x4C, 0xEF, 0xE2, 0x37, 0x87, 0x67,
+0xFF, 0xF7, 0x1F, 0x6D, 0xAC, 0xEC, 0x06, 0xD4, 0x70, 0xF3, 0x04, 0x41,
+0xA0, 0x98, 0x00, 0x18, 0x63, 0x5E, 0x00, 0x65, 0xC0, 0x98, 0x06, 0x95,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x3D, 0xF7, 0x10, 0x4C,
+0x00, 0x1C, 0x13, 0x58, 0x00, 0x65, 0x3F, 0xF3, 0x0D, 0x10, 0x00, 0x1C,
+0xFA, 0x1F, 0x00, 0x65, 0x3F, 0xF3, 0x08, 0x10, 0x06, 0x94, 0x7A, 0x14,
+0xE2, 0x34, 0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEC, 0x00, 0x18, 0x8F, 0x5E,
+0x82, 0x34, 0x1F, 0xF3, 0x1D, 0x10, 0x02, 0xF0, 0x00, 0x68, 0x00, 0x30,
+0x60, 0x6E, 0xAF, 0x40, 0x00, 0x1C, 0x83, 0x45, 0x24, 0x6C, 0xE0, 0xF3,
+0x08, 0x6C, 0x00, 0x1C, 0x2C, 0x1F, 0x00, 0x65, 0x00, 0x1C, 0x9B, 0x40,
+0x00, 0x65, 0x24, 0x6C, 0x00, 0x1C, 0xAC, 0x45, 0xAF, 0x40, 0x1F, 0x6E,
+0x4C, 0xEE, 0x00, 0x1C, 0x96, 0x40, 0x08, 0xD6, 0x00, 0x1C, 0x5B, 0x1F,
+0x64, 0x6C, 0x08, 0x96, 0x70, 0xF3, 0x44, 0x41, 0xC0, 0xC2, 0xFF, 0xF2,
+0x1B, 0x10, 0x00, 0x18, 0x75, 0x5D, 0x00, 0x65, 0xFF, 0xF2, 0x16, 0x10,
+0x0F, 0xF7, 0x40, 0x40, 0x4C, 0xEF, 0xE2, 0x32, 0x01, 0x6B, 0xA2, 0x67,
+0x6C, 0xED, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x46, 0x36,
+0x6C, 0xEE, 0xDB, 0xF7, 0xA8, 0xDC, 0x4A, 0x37, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x4E, 0x32, 0x6C, 0xEA, 0x6C, 0xEF, 0xCB, 0xF4,
+0xD9, 0xC4, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x10, 0xF0,
+0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0xDB, 0xF7, 0xE4, 0xDC, 0x63, 0xF3,
+0x00, 0x4B, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0xC7, 0xF5,
+0x47, 0xC3, 0x5D, 0xF7, 0x0C, 0x4C, 0x00, 0x1C, 0x13, 0x58, 0x04, 0xD2,
+0xDF, 0xF2, 0x04, 0x10, 0x00, 0x18, 0xED, 0x60, 0x87, 0x67, 0xBF, 0xF2,
+0x1F, 0x10, 0x00, 0x18, 0x92, 0x5C, 0x87, 0x67, 0xBF, 0xF2, 0x1A, 0x10,
+0x00, 0x1C, 0x9B, 0x40, 0x09, 0xD7, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x23, 0xF4, 0x4A, 0xA3, 0x09, 0x97,
+0x5F, 0xF4, 0x1D, 0x2A, 0x01, 0x6A, 0x23, 0xF4, 0x4A, 0xC3, 0x0F, 0xF7,
+0x40, 0x40, 0x4C, 0xEF, 0xE0, 0x32, 0x42, 0x32, 0x42, 0x32, 0x23, 0xF4,
+0x4B, 0xC3, 0x82, 0x67, 0x00, 0x1C, 0xA3, 0x31, 0x06, 0xD2, 0x0A, 0x15,
+0x00, 0x18, 0x94, 0x5E, 0x00, 0x65, 0x9F, 0xF2, 0x17, 0x10, 0xDF, 0xF4,
+0x0F, 0x2C, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xC9, 0xF7,
+0x1B, 0x6A, 0x63, 0xF3, 0x00, 0x4B, 0x4B, 0xEA, 0x23, 0xF4, 0x60, 0xAB,
+0x40, 0x32, 0x40, 0x32, 0xFF, 0xF7, 0x1F, 0x6C, 0x60, 0xF3, 0x14, 0x4A,
+0x8C, 0xEB, 0xC7, 0x16, 0x00, 0x1C, 0x9B, 0x40, 0x00, 0x65, 0xC9, 0xF7,
+0x1B, 0x6A, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x4B, 0xEA,
+0x63, 0xF3, 0x00, 0x4B, 0x40, 0x32, 0x23, 0xF4, 0x6B, 0xA3, 0x40, 0x32,
+0x60, 0xF3, 0x14, 0x4A, 0x60, 0xDA, 0x1F, 0x14, 0x00, 0x1C, 0x5C, 0x20,
+0x00, 0x65, 0x7F, 0xF2, 0x09, 0x10, 0x06, 0x95, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0xC9, 0xF7, 0x1B, 0x6C, 0xB0, 0x32, 0x63, 0xF3,
+0x00, 0x4B, 0x8B, 0xEC, 0x69, 0xE2, 0x80, 0x34, 0x20, 0xF3, 0x55, 0xA2,
+0x80, 0x34, 0x60, 0xF3, 0x14, 0x4C, 0xE5, 0x16, 0x06, 0x93, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x70, 0x32, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x69, 0xE2, 0x80, 0x34, 0x20, 0xF3,
+0x54, 0xA2, 0x80, 0x34, 0x60, 0xF3, 0x14, 0x4C, 0xD2, 0x16, 0x06, 0x94,
+0xD6, 0x15, 0x06, 0x93, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x70, 0x32,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x69, 0xE2, 0x80, 0x34, 0x20, 0xF3, 0x56, 0xAA, 0x80, 0x34, 0x60, 0xF3,
+0x14, 0x4C, 0xBD, 0x16, 0x06, 0x95, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0xC9, 0xF7, 0x1B, 0x6C, 0xB0, 0x32, 0x63, 0xF3, 0x00, 0x4B,
+0x8B, 0xEC, 0x69, 0xE2, 0x80, 0x34, 0x20, 0xF3, 0x52, 0xAA, 0x80, 0x34,
+0x60, 0xF3, 0x14, 0x4C, 0xAA, 0x16, 0x06, 0x93, 0xC9, 0xF7, 0x1B, 0x6C,
+0x8B, 0xEC, 0x70, 0x32, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x63, 0xF3, 0x00, 0x4B, 0x69, 0xE2, 0x80, 0x34, 0x20, 0xF3, 0x50, 0xAA,
+0x80, 0x34, 0x60, 0xF3, 0x14, 0x4C, 0x97, 0x16, 0x06, 0x95, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0xB0, 0x32,
+0xC9, 0xF7, 0x1B, 0x6C, 0x69, 0xE2, 0x8B, 0xEC, 0x20, 0xF3, 0x4C, 0x9A,
+0x80, 0x34, 0x80, 0x34, 0x60, 0xF3, 0x14, 0x4C, 0x40, 0xF6, 0x42, 0x32,
+0x82, 0x16, 0x06, 0x93, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x70, 0x32,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x69, 0xE2, 0x20, 0xF3, 0x4F, 0xA2, 0x80, 0x34, 0x80, 0x34, 0x01, 0x6B,
+0x60, 0xF3, 0x14, 0x4C, 0x6C, 0xEA, 0x6D, 0x16, 0x00, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x18, 0x03, 0x42, 0x34, 0xB0, 0x7C, 0x63, 0x24,
+0x00, 0x00, 0x43, 0xAC, 0x02, 0x80, 0x05, 0x3C, 0xCC, 0x5D, 0xA5, 0x8C,
+0x04, 0x00, 0x02, 0x24, 0x1E, 0x00, 0xA2, 0x10, 0x05, 0x00, 0xA2, 0x2C,
+0x10, 0x00, 0x40, 0x10, 0x05, 0x00, 0x02, 0x24, 0x03, 0x00, 0x02, 0x24,
+0x08, 0x00, 0xA2, 0x10, 0x00, 0x19, 0x04, 0x00, 0x80, 0x10, 0x04, 0x00,
+0x21, 0x10, 0x44, 0x00, 0xC0, 0x10, 0x02, 0x00, 0x23, 0x10, 0x44, 0x00,
+0x00, 0x11, 0x02, 0x00, 0x21, 0x10, 0x44, 0x00, 0x40, 0x19, 0x02, 0x00,
+0xFF, 0xFF, 0x63, 0x24, 0xFE, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0xA2, 0x10,
+0x06, 0x00, 0x02, 0x24, 0xF2, 0xFF, 0xA2, 0x14, 0x80, 0x10, 0x04, 0x00,
+0x40, 0x11, 0x04, 0x00, 0x23, 0x10, 0x44, 0x00, 0x80, 0x10, 0x02, 0x00,
+0x21, 0x10, 0x44, 0x00, 0x00, 0x19, 0x02, 0x00, 0x23, 0x18, 0x62, 0x00,
+0x42, 0x1F, 0x00, 0x08, 0x00, 0x19, 0x03, 0x00, 0x80, 0x10, 0x04, 0x00,
+0x21, 0x10, 0x44, 0x00, 0xC0, 0x10, 0x02, 0x00, 0x23, 0x10, 0x44, 0x00,
+0x00, 0x11, 0x02, 0x00, 0x21, 0x10, 0x44, 0x00, 0x42, 0x1F, 0x00, 0x08,
+0x00, 0x19, 0x02, 0x00, 0x00, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x6C, 0x7D, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x02, 0x80, 0x05, 0x3C, 0xCC, 0x5D, 0xA3, 0x8C, 0x05, 0x00, 0x02, 0x24,
+0x06, 0x00, 0x62, 0x10, 0x06, 0x00, 0x62, 0x2C, 0x0C, 0x00, 0x40, 0x10,
+0x06, 0x00, 0x02, 0x24, 0x04, 0x00, 0x02, 0x24, 0x0E, 0x00, 0x62, 0x10,
+0x80, 0x10, 0x04, 0x00, 0x80, 0x10, 0x04, 0x00, 0x21, 0x10, 0x44, 0x00,
+0x80, 0x10, 0x02, 0x00, 0xFF, 0xFF, 0x42, 0x24, 0xFE, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xF7, 0xFF, 0x62, 0x14, 0x00, 0x11, 0x04, 0x00, 0x23, 0x10, 0x44, 0x00,
+0x6D, 0x1F, 0x00, 0x08, 0x40, 0x10, 0x02, 0x00, 0x21, 0x10, 0x44, 0x00,
+0x6D, 0x1F, 0x00, 0x08, 0x40, 0x10, 0x02, 0x00, 0xFF, 0xFF, 0x85, 0x30,
+0x21, 0x30, 0x00, 0x00, 0x25, 0xB0, 0x03, 0x3C, 0x2A, 0xB0, 0x04, 0x3C,
+0xB4, 0x00, 0x63, 0x34, 0x01, 0x00, 0xA2, 0x24, 0x31, 0x00, 0x84, 0x34,
+0x00, 0x00, 0x65, 0xA0, 0x00, 0x00, 0x85, 0xA0, 0xFF, 0xFF, 0x45, 0x30,
+0x12, 0x00, 0xA0, 0x10, 0x01, 0x00, 0x03, 0x24, 0x28, 0xB0, 0x07, 0x3C,
+0x8F, 0x1F, 0x00, 0x08, 0xFF, 0xFF, 0x08, 0x24, 0x00, 0x00, 0x83, 0xA0,
+0x01, 0x00, 0x63, 0x24, 0xFF, 0xFF, 0x63, 0x30, 0x2B, 0x10, 0xA3, 0x00,
+0x09, 0x00, 0x40, 0x14, 0x08, 0x00, 0xC6, 0x24, 0xF9, 0xFF, 0x65, 0x14,
+0x21, 0x20, 0xC7, 0x00, 0x01, 0x00, 0x63, 0x24, 0xFF, 0xFF, 0x63, 0x30,
+0x2B, 0x10, 0xA3, 0x00, 0x00, 0x00, 0x88, 0xA0, 0xF9, 0xFF, 0x40, 0x10,
+0x08, 0x00, 0xC6, 0x24, 0x00, 0x01, 0xA2, 0x2C, 0x13, 0x00, 0x40, 0x10,
+0x21, 0x18, 0xA0, 0x00, 0xFF, 0x00, 0x08, 0x24, 0x28, 0xB0, 0x07, 0x3C,
+0xA3, 0x1F, 0x00, 0x08, 0xFF, 0xFF, 0x09, 0x24, 0xFF, 0xFF, 0x43, 0x30,
+0x00, 0x00, 0xA2, 0xA0, 0x00, 0x01, 0x62, 0x2C, 0x0A, 0x00, 0x40, 0x10,
+0x08, 0x00, 0xC6, 0x24, 0x01, 0x00, 0x62, 0x24, 0xF9, 0xFF, 0x68, 0x14,
+0x21, 0x28, 0xC7, 0x00, 0x00, 0x01, 0x02, 0x24, 0xFF, 0xFF, 0x43, 0x30,
+0x00, 0x01, 0x62, 0x2C, 0x00, 0x00, 0xA9, 0xA0, 0xF8, 0xFF, 0x40, 0x14,
+0x08, 0x00, 0xC6, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xD0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF, 0x25, 0xB0, 0x12, 0x3C,
+0xFF, 0xFF, 0x02, 0x24, 0x28, 0x00, 0xB6, 0xAF, 0x1C, 0x00, 0xB3, 0xAF,
+0x42, 0x00, 0x56, 0x36, 0x14, 0x00, 0xB1, 0xAF, 0xFC, 0x77, 0x13, 0x24,
+0x40, 0x00, 0x51, 0x36, 0x00, 0x00, 0xC2, 0xA2, 0x10, 0x00, 0xB0, 0xAF,
+0x00, 0x00, 0x33, 0xA6, 0xFC, 0x57, 0x10, 0x24, 0x32, 0x00, 0x04, 0x24,
+0x2C, 0x00, 0xBF, 0xAF, 0x24, 0x00, 0xB5, 0xAF, 0x5B, 0x1F, 0x00, 0x0C,
+0x20, 0x00, 0xB4, 0xAF, 0x00, 0x00, 0x30, 0xA6, 0x5B, 0x1F, 0x00, 0x0C,
+0x32, 0x00, 0x04, 0x24, 0xFC, 0x37, 0x02, 0x24, 0x00, 0x00, 0x22, 0xA6,
+0x5B, 0x1F, 0x00, 0x0C, 0x32, 0x00, 0x04, 0x24, 0x00, 0x00, 0x33, 0xA6,
+0x5B, 0x1F, 0x00, 0x0C, 0x32, 0x00, 0x04, 0x24, 0x00, 0x00, 0x30, 0xA6,
+0x5B, 0x1F, 0x00, 0x0C, 0x32, 0x00, 0x04, 0x24, 0x00, 0x10, 0x02, 0x24,
+0x00, 0x00, 0x22, 0xA6, 0xD8, 0x00, 0x45, 0x36, 0x00, 0x00, 0xA2, 0x90,
+0xA0, 0x00, 0x54, 0x36, 0xA4, 0x00, 0x55, 0x36, 0x7F, 0x00, 0x42, 0x30,
+0x00, 0x00, 0xA2, 0xA0, 0xA8, 0x00, 0x53, 0x36, 0x00, 0x80, 0x02, 0x3C,
+0xFC, 0x17, 0x03, 0x24, 0x00, 0x00, 0x80, 0xAE, 0x00, 0x00, 0xA0, 0xAE,
+0x00, 0x00, 0x62, 0xAE, 0x00, 0x00, 0x23, 0xA6, 0x00, 0x00, 0xA3, 0x90,
+0x02, 0x80, 0x10, 0x3C, 0x60, 0x1B, 0x10, 0x26, 0xAA, 0x1B, 0x04, 0x92,
+0x80, 0xFF, 0x02, 0x24, 0x25, 0x18, 0x62, 0x00, 0x56, 0x01, 0x52, 0x36,
+0xFF, 0x0F, 0x02, 0x24, 0x00, 0x00, 0xA3, 0xA0, 0x00, 0x00, 0x42, 0xA6,
+0x7A, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x04, 0x8E,
+0x14, 0x1C, 0x02, 0x8E, 0x18, 0x1C, 0x03, 0x8E, 0x2C, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x82, 0xAE, 0x18, 0x00, 0xB2, 0x8F, 0x00, 0x00, 0xA3, 0xAE,
+0x20, 0x00, 0xB4, 0x8F, 0x00, 0x00, 0x64, 0xAE, 0x24, 0x00, 0xB5, 0x8F,
+0x00, 0x00, 0xC0, 0xA2, 0x1C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0xC8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0x10, 0x00, 0xA4, 0x27, 0x25, 0xB0, 0x10, 0x3C, 0x34, 0x00, 0xBF, 0xAF,
+0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF, 0x28, 0x00, 0xB4, 0xAF,
+0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x1C, 0x00, 0xB1, 0xAF, 0x40, 0x00, 0x05, 0x36, 0x00, 0x00, 0xA2, 0x94,
+0x24, 0xFA, 0x03, 0x24, 0xA8, 0x00, 0x13, 0x36, 0x24, 0x10, 0x43, 0x00,
+0x00, 0x00, 0xA2, 0xA4, 0xA0, 0x00, 0x12, 0x36, 0xA4, 0x00, 0x10, 0x36,
+0x00, 0x00, 0x55, 0x8E, 0x00, 0x00, 0x16, 0x8E, 0x00, 0x00, 0x71, 0x8E,
+0x00, 0x80, 0x14, 0x3C, 0xFC, 0x37, 0x02, 0x24, 0x00, 0x00, 0x40, 0xAE,
+0x21, 0x88, 0x34, 0x02, 0x00, 0x00, 0x00, 0xAE, 0xFD, 0x00, 0x04, 0x24,
+0x00, 0x00, 0x74, 0xAE, 0x00, 0x00, 0xA2, 0xA4, 0x7A, 0x1F, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAE, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x16, 0xAE, 0x00, 0x00, 0x71, 0xAE, 0x90, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27, 0xC8, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0x10, 0x00, 0xA4, 0x27, 0x25, 0xB0, 0x10, 0x3C,
+0x34, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x1C, 0x00, 0xB1, 0xAF, 0x40, 0x00, 0x05, 0x36,
+0x00, 0x00, 0xA2, 0x94, 0xAF, 0xFF, 0x03, 0x24, 0xA8, 0x00, 0x13, 0x36,
+0x24, 0x10, 0x43, 0x00, 0x00, 0x00, 0xA2, 0xA4, 0xA0, 0x00, 0x12, 0x36,
+0xA4, 0x00, 0x10, 0x36, 0x00, 0x00, 0x55, 0x8E, 0x00, 0x00, 0x16, 0x8E,
+0x00, 0x00, 0x71, 0x8E, 0x00, 0x80, 0x14, 0x3C, 0xFC, 0x37, 0x02, 0x24,
+0x00, 0x00, 0x40, 0xAE, 0x21, 0x88, 0x34, 0x02, 0x00, 0x00, 0x00, 0xAE,
+0xFD, 0x00, 0x04, 0x24, 0x00, 0x00, 0x74, 0xAE, 0x00, 0x00, 0xA2, 0xA4,
+0x7A, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAE,
+0x10, 0x00, 0xA4, 0x27, 0x00, 0x00, 0x16, 0xAE, 0x00, 0x00, 0x71, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x25, 0xB0, 0x05, 0x3C, 0x40, 0x00, 0xA5, 0x34,
+0x00, 0x00, 0xA2, 0x94, 0xD8, 0xFD, 0x03, 0x24, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x10, 0x43, 0x00, 0xFC, 0x37, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xA4,
+0x00, 0x00, 0xA3, 0xA4, 0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x00, 0xBF, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27, 0xFF, 0x00, 0x82, 0x30,
+0x10, 0x00, 0xA4, 0x27, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x21, 0x88, 0xC0, 0x00,
+0x21, 0x80, 0xE0, 0x00, 0xC0, 0x90, 0x02, 0x00, 0x28, 0x00, 0xBF, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0xFF, 0xFF, 0xB3, 0x30, 0x25, 0xB0, 0x02, 0x3C,
+0x40, 0x02, 0x49, 0x34, 0xF8, 0xFF, 0x10, 0x26, 0x21, 0x30, 0x00, 0x00,
+0x01, 0x00, 0x0A, 0x24, 0x44, 0x02, 0x48, 0x34, 0x99, 0x20, 0x00, 0x08,
+0x01, 0x80, 0x07, 0x3C, 0x2E, 0x00, 0xCA, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x02, 0x92, 0x00, 0x00, 0x04, 0x92, 0x02, 0x00, 0x03, 0x92,
+0x03, 0x00, 0x05, 0x92, 0x00, 0x12, 0x02, 0x00, 0x25, 0x20, 0x82, 0x00,
+0x00, 0x1C, 0x03, 0x00, 0x25, 0x20, 0x83, 0x00, 0x21, 0x10, 0x46, 0x02,
+0x00, 0x2E, 0x05, 0x00, 0x01, 0x00, 0xC6, 0x24, 0x25, 0x20, 0x85, 0x00,
+0x25, 0x10, 0x47, 0x00, 0x06, 0x00, 0xC3, 0x2C, 0x00, 0x00, 0x04, 0xAD,
+0x04, 0x00, 0x10, 0x26, 0x00, 0x00, 0x22, 0xAD, 0x12, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xEA, 0xFF, 0xC0, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x22, 0x92, 0x01, 0x00, 0x23, 0x92, 0x04, 0x00, 0x10, 0x26,
+0x00, 0x14, 0x02, 0x00, 0x25, 0x10, 0x62, 0x02, 0x00, 0x1E, 0x03, 0x00,
+0x25, 0x20, 0x43, 0x00, 0x21, 0x10, 0x46, 0x02, 0x01, 0x00, 0xC6, 0x24,
+0x25, 0x10, 0x47, 0x00, 0x06, 0x00, 0xC3, 0x2C, 0x00, 0x00, 0x04, 0xAD,
+0x00, 0x00, 0x22, 0xAD, 0xF0, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x28, 0x00, 0xBF, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0x03, 0x00, 0x22, 0x92, 0x02, 0x00, 0x24, 0x92, 0x04, 0x00, 0x23, 0x92,
+0x05, 0x00, 0x25, 0x92, 0x8B, 0x20, 0x00, 0x08, 0x00, 0x12, 0x02, 0x00,
+0xFF, 0xFF, 0x84, 0x30, 0x42, 0xB0, 0x08, 0x3C, 0x80, 0x10, 0x04, 0x00,
+0x21, 0x10, 0x48, 0x00, 0x04, 0x00, 0x46, 0xAC, 0x00, 0x00, 0x07, 0x91,
+0x40, 0x18, 0x04, 0x00, 0x03, 0x00, 0x06, 0x24, 0xFF, 0x00, 0xE7, 0x30,
+0x04, 0x30, 0x66, 0x00, 0x01, 0x00, 0x02, 0x24, 0x04, 0x10, 0x62, 0x00,
+0x25, 0x30, 0xC7, 0x00, 0xFF, 0xFF, 0xA5, 0x30, 0x25, 0x10, 0x47, 0x00,
+0x02, 0x00, 0xA0, 0x14, 0xFF, 0x00, 0xC7, 0x30, 0xFF, 0x00, 0x47, 0x30,
+0x42, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x47, 0xA0, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x83, 0x90, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x00, 0x86, 0xAC, 0x18, 0x00, 0x85, 0xAC, 0x00, 0x00, 0x84, 0xAC,
+0x03, 0x00, 0x62, 0x10, 0x04, 0x00, 0x84, 0xAC, 0x5F, 0x5C, 0x00, 0x08,
+0x0C, 0x00, 0x80, 0xAC, 0x0C, 0x00, 0x82, 0x8C, 0x5F, 0x5C, 0x00, 0x08,
+0x10, 0x00, 0x82, 0xAC, 0xC8, 0xFF, 0xBD, 0x27, 0x28, 0x00, 0xB6, 0xAF,
+0x25, 0xB0, 0x02, 0x3C, 0x02, 0x80, 0x16, 0x3C, 0x2C, 0x00, 0xB7, 0xAF,
+0x24, 0x00, 0xB5, 0xAF, 0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x30, 0x00, 0xBF, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x18, 0x03, 0x55, 0x34, 0x01, 0x80, 0x17, 0x3C,
+0x02, 0x80, 0x13, 0x3C, 0x02, 0x80, 0x14, 0x3C, 0xD0, 0xDF, 0xD2, 0x26,
+0x6C, 0x83, 0xE2, 0x26, 0x00, 0x00, 0xA2, 0xAE, 0xD0, 0xDF, 0xD0, 0x8E,
+0x9B, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x5C, 0x71, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x20, 0x12, 0x00, 0x00, 0x00, 0x00,
+0x96, 0x40, 0x00, 0x0C, 0xFC, 0x5C, 0x60, 0xAE, 0x22, 0x00, 0x12, 0x12,
+0x08, 0x0C, 0x84, 0x26, 0x14, 0x00, 0x03, 0x92, 0x01, 0x00, 0x02, 0x24,
+0x2A, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x60, 0x14,
+0x02, 0x00, 0x02, 0x24, 0x0C, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0x23, 0x02, 0x1D, 0x00, 0x40, 0x10, 0x23, 0x10, 0x71, 0x00,
+0x0C, 0x00, 0x02, 0xAE, 0x00, 0x00, 0x10, 0x8E, 0xF7, 0x20, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0x60, 0x10,
+0x2B, 0x10, 0x23, 0x02, 0xF5, 0xFF, 0x40, 0x14, 0x23, 0x10, 0x71, 0x00,
+0x08, 0x00, 0x02, 0x8E, 0x18, 0x00, 0x04, 0x8E, 0x09, 0xF8, 0x40, 0x00,
+0x0C, 0x00, 0x00, 0xAE, 0x00, 0x00, 0x10, 0x8E, 0xF7, 0x20, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x96, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x0C, 0x84, 0x26, 0x21, 0x28, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00,
+0x76, 0x39, 0x00, 0x0C, 0x21, 0x38, 0x00, 0x00, 0xED, 0x20, 0x00, 0x08,
+0x6C, 0x83, 0xE2, 0x26, 0x08, 0x00, 0x02, 0x8E, 0x18, 0x00, 0x04, 0x8E,
+0x09, 0xF8, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x21, 0x00, 0x08,
+0x0C, 0x00, 0x02, 0xAE, 0x0C, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0x23, 0x02, 0xDA, 0xFF, 0x40, 0x14, 0x23, 0x10, 0x71, 0x00,
+0x08, 0x00, 0x02, 0x8E, 0x18, 0x00, 0x04, 0x8E, 0x09, 0xF8, 0x40, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0x03, 0xAE, 0x00, 0x00, 0x10, 0x8E, 0xF7, 0x20, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xD8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0xC0, 0x54, 0x42, 0x24, 0x18, 0x00, 0xB0, 0xAF, 0xC0, 0x80, 0x04, 0x00,
+0x21, 0x80, 0x02, 0x02, 0x1C, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xBF, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x00, 0x00, 0x02, 0x8E,
+0x10, 0x00, 0xA4, 0x27, 0x09, 0x00, 0x50, 0x10, 0x21, 0x88, 0x00, 0x00,
+0x04, 0x00, 0x43, 0x8C, 0x21, 0x88, 0x40, 0x00, 0x00, 0x00, 0x42, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0xAC, 0x04, 0x00, 0x43, 0xAC,
+0x00, 0x00, 0x31, 0xAE, 0x04, 0x00, 0x31, 0xAE, 0x90, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x20, 0x02, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27, 0x01, 0x01, 0x82, 0x2C,
+0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x21, 0x18, 0x00, 0x00, 0x10, 0x00, 0x40, 0x14, 0x01, 0x00, 0x04, 0x24,
+0x01, 0x02, 0x02, 0x2E, 0x0D, 0x00, 0x40, 0x14, 0x02, 0x00, 0x04, 0x24,
+0x01, 0x08, 0x02, 0x2E, 0x0A, 0x00, 0x40, 0x14, 0x03, 0x00, 0x04, 0x24,
+0x01, 0x10, 0x02, 0x2E, 0x06, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x04, 0x00, 0x04, 0x24,
+0x35, 0x21, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xF7, 0xFF, 0x40, 0x10,
+0x21, 0x18, 0x40, 0x00, 0x0C, 0x00, 0x50, 0xAC, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x10, 0x00, 0x03, 0x8E, 0x02, 0x80, 0x02, 0x3C,
+0xC0, 0x54, 0x42, 0x24, 0xC0, 0x18, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x64, 0x8C, 0x02, 0x80, 0x06, 0x3C, 0x02, 0x80, 0x07, 0x3C,
+0x00, 0x00, 0x04, 0xAE, 0x04, 0x00, 0x90, 0xAC, 0x04, 0x00, 0x03, 0xAE,
+0xC4, 0x5D, 0xC5, 0x8C, 0x10, 0x00, 0xA4, 0x27, 0x05, 0x00, 0xA0, 0x10,
+0x00, 0x00, 0x70, 0xAC, 0xB0, 0x5D, 0xE2, 0x8C, 0xC4, 0x5D, 0xC0, 0xAC,
+0x25, 0x10, 0x45, 0x00, 0xB0, 0x5D, 0xE2, 0xAC, 0x90, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xC9, 0xF7, 0x1B, 0x6B,
+0x6B, 0xEB, 0x60, 0x33, 0xFF, 0x6A, 0x60, 0x33, 0x4C, 0xEC, 0x60, 0xF1,
+0x00, 0x4B, 0xAC, 0xEA, 0x69, 0xE2, 0x80, 0xC2, 0x20, 0xE8, 0x00, 0x65,
+0xFF, 0x6A, 0x8C, 0xEA, 0x15, 0x5A, 0x0E, 0x60, 0x01, 0x6B, 0x83, 0x67,
+0x84, 0xEA, 0x02, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0xEE, 0xF0, 0x10, 0x4A,
+0x8C, 0xEA, 0x05, 0x2A, 0x0F, 0x6A, 0x8C, 0xEA, 0x02, 0x6B, 0x01, 0x2A,
+0x00, 0x6B, 0x20, 0xE8, 0x43, 0x67, 0x00, 0x00, 0xFF, 0x63, 0x00, 0xD0,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x8C, 0x30, 0x0A, 0x65,
+0x89, 0xE0, 0x48, 0x32, 0x89, 0xE2, 0x68, 0x67, 0x63, 0xF3, 0x00, 0x4B,
+0x48, 0x32, 0x69, 0xE2, 0x01, 0xD1, 0x00, 0x6B, 0x04, 0xF5, 0x6A, 0xC2,
+0x04, 0xF5, 0x6B, 0xC2, 0x04, 0xF5, 0x64, 0x9A, 0x1C, 0x6D, 0x22, 0x67,
+0x01, 0x6F, 0xFF, 0x6E, 0x02, 0x10, 0xFF, 0x4D, 0xCC, 0xED, 0x47, 0x67,
+0x44, 0xED, 0x6C, 0xEA, 0xFA, 0x22, 0x04, 0xF5, 0xAA, 0xC1, 0x00, 0x6D,
+0x1D, 0x5D, 0x13, 0x60, 0x89, 0xE0, 0x48, 0x32, 0x68, 0x67, 0x89, 0xE2,
+0x63, 0xF3, 0x00, 0x4B, 0x48, 0x32, 0x79, 0xE2, 0x04, 0xF5, 0x44, 0x9E,
+0x01, 0x6B, 0x64, 0xED, 0x6C, 0xEA, 0x09, 0x2A, 0x01, 0x4D, 0xFF, 0x6A,
+0x4C, 0xED, 0x1D, 0x5D, 0xED, 0x61, 0x01, 0x91, 0x00, 0x90, 0x20, 0xE8,
+0x01, 0x63, 0x01, 0x91, 0x00, 0x90, 0x04, 0xF5, 0xAB, 0xC6, 0x20, 0xE8,
+0x01, 0x63, 0x00, 0x00, 0xFB, 0x63, 0x07, 0xD1, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0x00, 0x6A, 0x63, 0xF3, 0x00, 0x49, 0x08, 0x62,
+0x06, 0xD0, 0x04, 0xD2, 0x34, 0x10, 0x03, 0x54, 0x62, 0x60, 0x01, 0x74,
+0x6E, 0x60, 0x04, 0xF5, 0x88, 0x99, 0x07, 0x6A, 0xFF, 0x6B, 0x82, 0x34,
+0x86, 0x34, 0x4C, 0xEC, 0x04, 0x58, 0x6C, 0xEC, 0x12, 0x60, 0x00, 0x18,
+0xA1, 0x5C, 0xB0, 0x67, 0xC9, 0xF7, 0x1B, 0x6C, 0x04, 0xF5, 0x60, 0x99,
+0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x4C, 0xEB, 0x80, 0xF1, 0x04, 0x4C,
+0x08, 0x32, 0x89, 0xE2, 0x04, 0xF5, 0x64, 0xD9, 0x60, 0xDA, 0x00, 0x18,
+0xA5, 0x21, 0x04, 0x94, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x04, 0x93,
+0x80, 0x34, 0x80, 0x34, 0x60, 0xF1, 0x00, 0x4C, 0x89, 0xE3, 0x40, 0xA2,
+0x04, 0x92, 0x7F, 0x49, 0x15, 0x49, 0x01, 0x4A, 0x20, 0x5A, 0x04, 0xD2,
+0x48, 0x60, 0x04, 0xF5, 0xA8, 0x99, 0x01, 0x6B, 0xA2, 0x34, 0x92, 0x32,
+0x6C, 0xEA, 0xFF, 0x6B, 0x6C, 0xEA, 0xF0, 0x22, 0xE4, 0xF4, 0x78, 0x99,
+0xFF, 0x6A, 0x86, 0x34, 0x72, 0x33, 0x4C, 0xEB, 0x7F, 0x6A, 0x4C, 0xEB,
+0x07, 0x6A, 0x4C, 0xEC, 0xFF, 0x6A, 0x4C, 0xEC, 0x07, 0x68, 0xAC, 0xE8,
+0x02, 0x74, 0x4C, 0xE8, 0xB2, 0x61, 0x38, 0x5B, 0x0A, 0x61, 0x01, 0xF6,
+0x01, 0x6A, 0x4B, 0xEA, 0xAC, 0xEA, 0x00, 0xF2, 0x00, 0x6B, 0x6D, 0xEA,
+0x04, 0xF5, 0x48, 0xD9, 0xAA, 0x17, 0x14, 0x5B, 0xA8, 0x60, 0x01, 0xF6,
+0x01, 0x6A, 0x4B, 0xEA, 0xAC, 0xEA, 0x00, 0xF6, 0x00, 0x6B, 0x6D, 0xEA,
+0xF3, 0x17, 0x03, 0x74, 0x9E, 0x61, 0x1A, 0x5B, 0x9C, 0x61, 0x01, 0xF6,
+0x01, 0x6A, 0x4B, 0xEA, 0xAC, 0xEA, 0x00, 0xF4, 0x00, 0x6C, 0x8D, 0xEA,
+0x04, 0xF5, 0x48, 0xD9, 0x92, 0x17, 0x32, 0x5B, 0x90, 0x60, 0x01, 0xF6,
+0x01, 0x6A, 0x4B, 0xEA, 0xAC, 0xEA, 0x00, 0xF4, 0x00, 0x6B, 0x6D, 0xEA,
+0xDB, 0x17, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x00, 0x6A, 0x00, 0xEF,
+0x05, 0x63, 0x00, 0x00, 0x20, 0xE8, 0x00, 0x65, 0xA4, 0x67, 0xC9, 0xF7,
+0x1B, 0x6C, 0xFC, 0x63, 0x8B, 0xEC, 0x06, 0xD0, 0x80, 0x34, 0xAC, 0x30,
+0xA1, 0xE0, 0x80, 0x34, 0x07, 0x62, 0x80, 0xF1, 0x40, 0x44, 0x08, 0x30,
+0x40, 0xA2, 0xA1, 0xE0, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0x08, 0x30, 0x41, 0xE0, 0x04, 0xF5, 0x48, 0x98,
+0x07, 0x6B, 0x80, 0xF1, 0x04, 0x4C, 0x6C, 0xEA, 0x48, 0x32, 0x89, 0xE2,
+0x04, 0xF5, 0x60, 0x98, 0x40, 0x9A, 0x85, 0x67, 0x6C, 0xEA, 0x04, 0xF5,
+0x44, 0xD8, 0x00, 0x18, 0xA5, 0x21, 0x04, 0xD5, 0x04, 0x95, 0x04, 0xF5,
+0x8A, 0xA0, 0xFF, 0x6A, 0x00, 0x18, 0x93, 0x21, 0x4C, 0xED, 0x07, 0x97,
+0x06, 0x90, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x00, 0xFF, 0xF7, 0x1F, 0x6B,
+0x8C, 0xEB, 0x00, 0xF2, 0x00, 0x6A, 0x0B, 0x6C, 0x6C, 0xEA, 0x6C, 0xEC,
+0x07, 0x6B, 0x0E, 0x2A, 0x0C, 0x5C, 0x0B, 0x60, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x88, 0x32, 0x7D, 0xF7, 0x08, 0x4B, 0x69, 0xE2,
+0x40, 0x9A, 0x00, 0xEA, 0x00, 0x65, 0x07, 0x6B, 0x20, 0xE8, 0x43, 0x67,
+0x06, 0x6B, 0x20, 0xE8, 0x43, 0x67, 0x05, 0x6B, 0x20, 0xE8, 0x43, 0x67,
+0x04, 0x6B, 0x20, 0xE8, 0x43, 0x67, 0x03, 0x6B, 0x20, 0xE8, 0x43, 0x67,
+0x02, 0x6B, 0x20, 0xE8, 0x43, 0x67, 0x01, 0x6B, 0x20, 0xE8, 0x43, 0x67,
+0x00, 0x6B, 0x20, 0xE8, 0x43, 0x67, 0x00, 0x00, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0xF7, 0x63, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0x6A,
+0x0F, 0xD1, 0x23, 0x67, 0x10, 0x62, 0x0E, 0xD0, 0x04, 0xD2, 0x05, 0xD3,
+0x06, 0xD3, 0x07, 0xD3, 0x08, 0xD2, 0x09, 0xD2, 0x0A, 0xD2, 0x0B, 0xD2,
+0x0C, 0xD2, 0xE4, 0xF4, 0x08, 0x49, 0x48, 0x99, 0x01, 0x6B, 0xFF, 0x6C,
+0x42, 0x32, 0x52, 0x32, 0x6C, 0xEA, 0x8C, 0xEA, 0x80, 0xF0, 0x11, 0x22,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x04, 0x96, 0x40, 0x32,
+0x60, 0xF1, 0x00, 0x4A, 0x49, 0xE6, 0x40, 0xA2, 0xFF, 0x6B, 0x4C, 0xEC,
+0x05, 0x92, 0x0C, 0x65, 0x51, 0xE4, 0xC0, 0xF4, 0x4A, 0xA4, 0x6C, 0xEA,
+0x61, 0x99, 0x58, 0xEB, 0xE0, 0xF4, 0x47, 0xA4, 0xFF, 0x6B, 0x6C, 0xEA,
+0x62, 0x99, 0x12, 0xED, 0x00, 0x65, 0x00, 0x65, 0x58, 0xEB, 0x12, 0xEA,
+0x55, 0xE5, 0xFF, 0xF7, 0x4C, 0x99, 0xA3, 0xEA, 0x40, 0xF1, 0x0F, 0x61,
+0xAB, 0xE2, 0xFF, 0xF7, 0x4C, 0xD9, 0x61, 0x99, 0x42, 0x99, 0xC8, 0x67,
+0xFF, 0xF7, 0xEC, 0x99, 0x55, 0xE3, 0xFF, 0xF7, 0x70, 0x99, 0xFF, 0xF7,
+0x54, 0x99, 0x51, 0xE3, 0xFF, 0xF7, 0x7C, 0x99, 0x40, 0x99, 0x41, 0xE3,
+0x05, 0x93, 0x69, 0xE6, 0x20, 0xF5, 0x5E, 0xA2, 0xFF, 0x6E, 0xCC, 0xEA,
+0xC5, 0x67, 0x0F, 0x25, 0xA3, 0xEA, 0xD8, 0x67, 0x0D, 0x2E, 0x48, 0x67,
+0x07, 0x5A, 0x04, 0x61, 0x0C, 0x72, 0x02, 0x60, 0x0D, 0x72, 0x05, 0x61,
+0xAC, 0x32, 0xAB, 0xE2, 0x4E, 0x32, 0x83, 0xEA, 0x10, 0x61, 0x79, 0x26,
+0x05, 0x92, 0x68, 0x67, 0x68, 0x34, 0x51, 0xE4, 0x06, 0x92, 0x69, 0xE2,
+0x44, 0xF5, 0x66, 0xA2, 0xFF, 0x6A, 0x4C, 0xEB, 0x60, 0xF5, 0x40, 0x9C,
+0x44, 0xEB, 0xE3, 0xEA, 0x6A, 0x60, 0x01, 0x68, 0x5F, 0x99, 0x70, 0x67,
+0x88, 0x67, 0x64, 0xEC, 0x6C, 0xEA, 0x00, 0xF1, 0x1C, 0x22, 0x06, 0x96,
+0x95, 0xE6, 0x44, 0xF5, 0x66, 0xA5, 0x04, 0xF5, 0xEC, 0xA5, 0xFF, 0x6E,
+0x46, 0x67, 0xCC, 0xEB, 0x0A, 0x6C, 0xEC, 0xEA, 0x84, 0xEB, 0x82, 0xEA,
+0x00, 0xF1, 0x0D, 0x60, 0x41, 0x47, 0x04, 0xF5, 0x4C, 0xC5, 0xCC, 0xEA,
+0x8E, 0xEA, 0x02, 0x2A, 0x24, 0xF5, 0x09, 0xC5, 0x05, 0x94, 0x68, 0x67,
+0x68, 0x32, 0x89, 0xE2, 0xC0, 0xF5, 0x94, 0x9A, 0x60, 0xF5, 0x40, 0x9A,
+0x84, 0x33, 0x8D, 0xE3, 0x69, 0xE2, 0x4A, 0x37, 0xFF, 0xF7, 0xEC, 0xD9,
+0x05, 0x96, 0x27, 0xF1, 0x44, 0x9E, 0xFF, 0xF7, 0x1F, 0x72, 0xC0, 0xF0,
+0x1B, 0x61, 0x00, 0x6B, 0x61, 0xD9, 0x62, 0xD9, 0xFF, 0xF7, 0x70, 0xD9,
+0xFF, 0xF7, 0x74, 0xD9, 0xFF, 0xF7, 0x78, 0xD9, 0xFF, 0xF7, 0x7C, 0xD9,
+0x60, 0xD9, 0x04, 0x94, 0x0C, 0x96, 0x0B, 0x92, 0x01, 0x4C, 0x0A, 0x93,
+0x04, 0xD4, 0x09, 0x94, 0x7F, 0x4E, 0x7F, 0x4A, 0x7F, 0x4B, 0x15, 0x4E,
+0x15, 0x4A, 0x15, 0x4B, 0x7F, 0x4C, 0x15, 0x4C, 0x0C, 0xD6, 0x0B, 0xD2,
+0x08, 0x96, 0x07, 0x92, 0x0A, 0xD3, 0x06, 0x93, 0x09, 0xD4, 0x04, 0x94,
+0x7F, 0x4E, 0x7F, 0x4A, 0x7F, 0x4B, 0x15, 0x4E, 0x15, 0x4A, 0x15, 0x4B,
+0x7F, 0x49, 0x20, 0x54, 0x08, 0xD6, 0x07, 0xD2, 0x06, 0xD3, 0x15, 0x49,
+0x3F, 0xF7, 0x15, 0x61, 0x10, 0x97, 0x0F, 0x91, 0x0E, 0x90, 0x00, 0xEF,
+0x09, 0x63, 0xA0, 0xF0, 0x0E, 0x25, 0xA0, 0xF0, 0x0E, 0x2E, 0xA4, 0x32,
+0xA9, 0xE2, 0x4A, 0x32, 0x03, 0xEA, 0xC1, 0x60, 0x06, 0x96, 0x48, 0x67,
+0x00, 0x6B, 0x51, 0xE6, 0x04, 0xF5, 0x6C, 0xC4, 0x01, 0x6B, 0x64, 0xEA,
+0x5F, 0x99, 0x6F, 0xEB, 0x6C, 0xEA, 0x5F, 0xD9, 0x24, 0xF5, 0x49, 0xA4,
+0xFF, 0x6C, 0x8C, 0xEA, 0x01, 0x72, 0x10, 0x60, 0x09, 0x96, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x00, 0x6D, 0x63, 0xF3, 0x00, 0x4A,
+0x4D, 0xE6, 0x85, 0x67, 0xA9, 0xE3, 0x01, 0x4D, 0x1D, 0x55, 0x44, 0xF5,
+0x86, 0xC2, 0xFA, 0x61, 0x06, 0x93, 0x88, 0x67, 0x00, 0x6E, 0x89, 0xE3,
+0x24, 0xF5, 0xC9, 0xC2, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x9D, 0xF7, 0x18, 0x4A, 0x00, 0x9A, 0x10, 0xF0, 0x02, 0x6F, 0x00, 0xF4,
+0xE0, 0x37, 0x10, 0xF0, 0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x00, 0x6D,
+0x5C, 0xF4, 0x00, 0x4F, 0xDC, 0xF3, 0x0C, 0x4E, 0xA8, 0x32, 0xED, 0xE2,
+0x60, 0x9B, 0x11, 0xE2, 0xC9, 0xE2, 0xC0, 0xF5, 0x74, 0xDC, 0x40, 0x9A,
+0x01, 0x4D, 0x1D, 0x55, 0x60, 0xF5, 0x40, 0xDC, 0xF3, 0x61, 0x68, 0x67,
+0x20, 0x23, 0x07, 0x94, 0xA8, 0x67, 0xFF, 0x4D, 0x04, 0xF5, 0x4B, 0xA4,
+0xFF, 0x68, 0x42, 0xED, 0x18, 0x61, 0x08, 0x96, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x69, 0xE6, 0x04, 0xF5,
+0x8B, 0xA2, 0x04, 0xF5, 0xC4, 0x9A, 0x01, 0x6F, 0x0C, 0xEC, 0x67, 0x67,
+0x64, 0xED, 0x46, 0x67, 0x6C, 0xEA, 0x6E, 0xEA, 0x00, 0xF1, 0x03, 0x22,
+0xFF, 0x4D, 0x82, 0xED, 0xF6, 0x60, 0x88, 0x67, 0x10, 0xF0, 0x02, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x88, 0x32, 0x63, 0xF3, 0x00, 0x4E, 0xC9, 0xE2,
+0xC0, 0xF5, 0x94, 0x9A, 0x60, 0xF5, 0x40, 0x9A, 0x84, 0x33, 0x8D, 0xE3,
+0x69, 0xE2, 0x4A, 0x37, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0xCB, 0xF4, 0x46, 0xA2, 0xFF, 0x6B, 0x6C, 0xEA, 0x22, 0x72, 0xC0, 0xF0,
+0x17, 0x61, 0x88, 0x67, 0x13, 0x74, 0x3F, 0xF7, 0x0D, 0x60, 0x07, 0x96,
+0x01, 0x6B, 0x64, 0xEC, 0x64, 0xF5, 0x44, 0x9E, 0xFF, 0xF7, 0xEC, 0xD9,
+0x6D, 0xEA, 0x64, 0xF5, 0x44, 0xDE, 0x05, 0x96, 0x27, 0xF1, 0x44, 0x9E,
+0xFF, 0xF7, 0x1F, 0x72, 0x3F, 0xF7, 0x05, 0x60, 0x04, 0x95, 0xFF, 0x6A,
+0x88, 0x67, 0x00, 0x18, 0x93, 0x21, 0x4C, 0xED, 0x1E, 0x17, 0x00, 0x6B,
+0xFF, 0xF7, 0x6C, 0xD9, 0xB0, 0x16, 0x1F, 0xF7, 0x18, 0x26, 0x05, 0x94,
+0x68, 0x67, 0x68, 0x32, 0x89, 0xE2, 0xC0, 0xF5, 0x54, 0x9A, 0x43, 0xEF,
+0x4E, 0x17, 0x48, 0x67, 0x1C, 0x5A, 0xFF, 0xF6, 0x17, 0x60, 0x06, 0x94,
+0x4D, 0xE4, 0x24, 0xF5, 0x49, 0xA3, 0xFF, 0x6C, 0x01, 0x72, 0x53, 0x60,
+0x0C, 0x96, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x00, 0x6D,
+0x63, 0xF3, 0x00, 0x4A, 0x4D, 0xE6, 0x85, 0x67, 0xA9, 0xE3, 0x01, 0x4D,
+0x1D, 0x55, 0x44, 0xF5, 0x86, 0xC2, 0xFA, 0x61, 0x06, 0x93, 0x88, 0x67,
+0x00, 0x6E, 0x89, 0xE3, 0x01, 0x6C, 0x04, 0xF5, 0xCC, 0xC2, 0x24, 0xF5,
+0xC9, 0xC2, 0x64, 0x67, 0x48, 0x67, 0x64, 0xEA, 0x5F, 0x99, 0x6F, 0xEB,
+0x6C, 0xEA, 0x68, 0x67, 0x5F, 0xD9, 0x4E, 0x23, 0x20, 0xF0, 0x42, 0xA1,
+0xA8, 0x67, 0x01, 0x4D, 0xA2, 0xEA, 0xFF, 0x68, 0x17, 0x61, 0x0A, 0x93,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x63, 0xF3, 0x00, 0x4C,
+0x89, 0xE3, 0x04, 0xF5, 0x8A, 0xA2, 0x04, 0xF5, 0xC4, 0x9A, 0x01, 0x6F,
+0x0C, 0xEC, 0x67, 0x67, 0x64, 0xED, 0x46, 0x67, 0x6C, 0xEA, 0x6E, 0xEA,
+0x6F, 0x22, 0x01, 0x4D, 0xA2, 0xEC, 0xF7, 0x60, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0xCB, 0xF4, 0x46, 0xA2, 0x22, 0x72, 0xBF, 0xF6,
+0x07, 0x61, 0x48, 0x67, 0xEE, 0x4A, 0xFF, 0x6B, 0x6C, 0xEA, 0x02, 0x5A,
+0xBF, 0xF6, 0x00, 0x60, 0x18, 0x6E, 0x0E, 0x65, 0x9D, 0x16, 0xC8, 0x67,
+0x18, 0x5E, 0x3F, 0x61, 0x44, 0xF5, 0x46, 0xA3, 0x4C, 0xEC, 0x05, 0x5C,
+0x03, 0x60, 0x01, 0x4A, 0x44, 0xF5, 0x46, 0xC3, 0x06, 0x93, 0x88, 0x67,
+0x00, 0x6E, 0x89, 0xE3, 0x01, 0x6C, 0x04, 0xF5, 0xCC, 0xC2, 0x24, 0xF5,
+0xC9, 0xC2, 0x64, 0x67, 0x48, 0x67, 0x64, 0xEA, 0x5F, 0x99, 0x6F, 0xEB,
+0x6C, 0xEA, 0x68, 0x67, 0x5F, 0xD9, 0xB2, 0x2B, 0x20, 0xF0, 0x42, 0xA1,
+0xA4, 0x67, 0xFF, 0x68, 0xAD, 0x22, 0x0B, 0x94, 0x10, 0xF0, 0x02, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x63, 0xF3, 0x00, 0x4E, 0xC9, 0xE4, 0x04, 0xF5,
+0x8A, 0xA2, 0xE5, 0x67, 0x04, 0xF5, 0xC4, 0x9A, 0x0C, 0xEC, 0x67, 0x67,
+0x64, 0xED, 0x46, 0x67, 0x6C, 0xEA, 0x6E, 0xEA, 0x09, 0x22, 0x01, 0x4D,
+0xA2, 0xEC, 0x96, 0x61, 0x67, 0x67, 0x64, 0xED, 0x46, 0x67, 0x6C, 0xEA,
+0x6E, 0xEA, 0xF7, 0x2A, 0x0C, 0xED, 0x0D, 0x65, 0x8D, 0x17, 0x48, 0x67,
+0x05, 0x5A, 0x05, 0x60, 0x44, 0xF5, 0x46, 0xA3, 0x4C, 0xEC, 0x03, 0x5C,
+0xBD, 0x17, 0x44, 0xF5, 0x46, 0xA3, 0x4C, 0xEC, 0x04, 0x5C, 0xB8, 0x17,
+0x07, 0x94, 0x48, 0x67, 0x01, 0x6B, 0x64, 0xEA, 0x64, 0xF5, 0x44, 0x9C,
+0x6D, 0xEA, 0x64, 0xF5, 0x44, 0xDC, 0x50, 0x16, 0x0C, 0xED, 0x0D, 0x65,
+0x91, 0x17, 0x0C, 0xED, 0x0D, 0x65, 0xFD, 0x16, 0xFC, 0x63, 0x10, 0xF0,
+0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x05, 0xD1, 0x06, 0x62, 0x04, 0xD0,
+0x63, 0xF3, 0x00, 0x4C, 0x87, 0xF0, 0x58, 0x9C, 0x87, 0xF0, 0x7D, 0xA4,
+0x65, 0xE2, 0x87, 0xF0, 0x54, 0x9C, 0x43, 0xE9, 0xE0, 0xF0, 0x04, 0x60,
+0x04, 0x67, 0x0C, 0x10, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30,
+0x63, 0xF3, 0x00, 0x48, 0x87, 0xF0, 0x54, 0x98, 0x10, 0x49, 0x43, 0xE9,
+0xC0, 0xF0, 0x16, 0x60, 0x87, 0xF0, 0x5D, 0xA0, 0xFF, 0xF7, 0x1F, 0x6D,
+0x2C, 0xED, 0x10, 0x4A, 0x87, 0xF0, 0x5D, 0xC0, 0xEF, 0xF7, 0x1E, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4,
+0x80, 0x34, 0xAA, 0xF2, 0x14, 0x4C, 0x4D, 0xED, 0x00, 0x1C, 0xF4, 0x54,
+0x10, 0x6E, 0x46, 0xF7, 0xB8, 0x98, 0x1F, 0x6B, 0x40, 0xF4, 0xA2, 0x34,
+0x6C, 0xEC, 0x8C, 0x32, 0x89, 0xE2, 0x48, 0x32, 0x89, 0xE2, 0x48, 0x32,
+0x19, 0xE2, 0x04, 0xF5, 0x48, 0x9E, 0x01, 0x6B, 0x42, 0x32, 0x52, 0x32,
+0x6C, 0xEA, 0xFF, 0x6B, 0x6C, 0xEA, 0xC8, 0x22, 0xC9, 0xF7, 0x1B, 0x6B,
+0x6B, 0xEB, 0x60, 0x33, 0x60, 0x33, 0x60, 0xF1, 0x00, 0x4B, 0x69, 0xE4,
+0x40, 0xA2, 0xFF, 0x6B, 0xFF, 0x6F, 0x4C, 0xEB, 0x0B, 0x65, 0x46, 0xF7,
+0x74, 0x98, 0x3F, 0x68, 0x80, 0xF5, 0x62, 0x32, 0x0C, 0xEA, 0x05, 0x52,
+0x4C, 0xEF, 0x01, 0x61, 0x04, 0x6F, 0xC0, 0xF7, 0x62, 0x32, 0x0E, 0x2A,
+0xE4, 0xF4, 0x54, 0x9E, 0x04, 0x6F, 0x01, 0x4A, 0xE4, 0xF4, 0x54, 0xDE,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A,
+0x46, 0xF7, 0xB8, 0x9A, 0xA2, 0x32, 0x52, 0x32, 0x1F, 0x6B, 0x6C, 0xEA,
+0x08, 0x52, 0x52, 0x60, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x63, 0xF3, 0x00, 0x4D, 0x46, 0xF7, 0x54, 0x9D, 0x0C, 0xEA, 0x08, 0x67,
+0x0E, 0xEA, 0x46, 0x2A, 0x74, 0x27, 0x01, 0x77, 0x05, 0x61, 0xC4, 0xF4,
+0x5C, 0x9E, 0x01, 0x4A, 0xC4, 0xF4, 0x5C, 0xDE, 0x02, 0x77, 0x05, 0x61,
+0xE4, 0xF4, 0x40, 0x9E, 0x01, 0x4A, 0xE4, 0xF4, 0x40, 0xDE, 0x03, 0x77,
+0x05, 0x61, 0xE4, 0xF4, 0x44, 0x9E, 0x01, 0x4A, 0xE4, 0xF4, 0x44, 0xDE,
+0x04, 0x77, 0x05, 0x61, 0xE4, 0xF4, 0x48, 0x9E, 0x01, 0x4A, 0xE4, 0xF4,
+0x48, 0xDE, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30, 0xA8, 0x67,
+0x63, 0xF3, 0x00, 0x48, 0x09, 0xE5, 0xE4, 0xF4, 0x78, 0x9E, 0x00, 0xF5,
+0x44, 0xA2, 0xFF, 0x6D, 0x72, 0x33, 0xAC, 0xEA, 0x43, 0xEB, 0x4D, 0x61,
+0xE4, 0xF4, 0x4C, 0x9E, 0x08, 0x67, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x01, 0x4A, 0xE4, 0xF4, 0x4C, 0xDE, 0x08, 0x32, 0x63, 0xF3,
+0x00, 0x4B, 0x09, 0xE2, 0x69, 0xE2, 0xE9, 0xE2, 0xA0, 0xF3, 0x68, 0xA2,
+0xAC, 0xEB, 0xC4, 0xF4, 0x54, 0x9E, 0x69, 0xE2, 0xC4, 0xF4, 0x54, 0xDE,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x08, 0xF0, 0x54, 0x9B, 0x3F, 0xF7, 0x1E, 0x22, 0x05, 0x74, 0x3F, 0xF7,
+0x1B, 0x61, 0x46, 0xF7, 0x54, 0x9B, 0xC0, 0xF7, 0x42, 0x32, 0x3F, 0xF7,
+0x15, 0x22, 0x00, 0x6A, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30, 0x08, 0xF0, 0x54, 0xDB,
+0x9D, 0xF7, 0x1C, 0x4C, 0x63, 0xF3, 0x00, 0x48, 0x00, 0x1C, 0x13, 0x58,
+0x10, 0x49, 0x87, 0xF0, 0x54, 0x98, 0x43, 0xE9, 0x3F, 0xF7, 0x0A, 0x61,
+0x06, 0x97, 0x05, 0x91, 0x04, 0x90, 0x00, 0xEF, 0x04, 0x63, 0xC4, 0xF4,
+0x58, 0x9E, 0x01, 0x4A, 0xC4, 0xF4, 0x58, 0xDE, 0x86, 0x17, 0xE4, 0xF4,
+0x50, 0x9E, 0xA8, 0x67, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30,
+0x01, 0x4A, 0xE4, 0xF4, 0x50, 0xDE, 0xA8, 0x32, 0xA9, 0xE2, 0x63, 0xF3,
+0x00, 0x48, 0x09, 0xE2, 0xE9, 0xE2, 0x20, 0xF4, 0x79, 0xA2, 0xFF, 0x6A,
+0x4C, 0xEB, 0xB1, 0x17, 0xE0, 0x63, 0x00, 0x6A, 0x3E, 0x62, 0x3D, 0xD1,
+0x3C, 0xD0, 0xFC, 0x63, 0x1D, 0xD2, 0x62, 0x67, 0x1D, 0x94, 0x04, 0x05,
+0x07, 0x68, 0x94, 0x32, 0xA9, 0xE2, 0x1E, 0xD0, 0x60, 0xDA, 0x1E, 0x94,
+0x04, 0x4A, 0xFF, 0x4C, 0x00, 0x54, 0x1E, 0xD4, 0xF9, 0x60, 0x1D, 0x95,
+0x01, 0x4D, 0x03, 0x5D, 0x1D, 0xD5, 0xEE, 0x61, 0xC9, 0xF7, 0x1B, 0x6A,
+0x4B, 0xEA, 0x40, 0x31, 0x20, 0x31, 0xC0, 0xF2, 0x44, 0x41, 0x1D, 0xD3,
+0x60, 0xDA, 0x41, 0x99, 0x01, 0xF7, 0x00, 0x6B, 0x01, 0xF4, 0x84, 0x41,
+0x42, 0x32, 0x6C, 0xEA, 0x42, 0x32, 0x00, 0x1C, 0xFA, 0x5B, 0x33, 0xD2,
+0x01, 0xF4, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x31, 0xD2, 0x9D, 0x67,
+0x70, 0x4C, 0x00, 0x1C, 0x8A, 0x40, 0x32, 0xD2, 0x1D, 0x94, 0x10, 0x6D,
+0xA4, 0xED, 0x00, 0x1C, 0xAC, 0x45, 0xFF, 0x4D, 0x9D, 0x67, 0x70, 0x4C,
+0x00, 0x1C, 0x90, 0x40, 0x1F, 0xD2, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x00, 0x1C, 0xF0, 0x42, 0x01, 0x6C, 0x9D, 0x67, 0x00, 0x1C, 0x8A, 0x40,
+0x70, 0x4C, 0x1D, 0x94, 0x10, 0x6D, 0xA4, 0xED, 0x00, 0x1C, 0xAC, 0x45,
+0xFF, 0x4D, 0x9D, 0x67, 0x70, 0x4C, 0x00, 0x1C, 0x90, 0x40, 0x20, 0xD2,
+0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42, 0x1D, 0x94,
+0xE1, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xD1, 0xF6,
+0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x21, 0xD2, 0x71, 0xF6, 0x80, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x22, 0xD2, 0x71, 0xF6, 0x84, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x23, 0xD2, 0x71, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x24, 0xD2, 0x71, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x25, 0xD2,
+0x81, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x26, 0xD2, 0x81, 0xF6,
+0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x27, 0xD2, 0x81, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x28, 0xD2, 0x81, 0xF6, 0x8C, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x29, 0xD2, 0xD1, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x2A, 0xD2, 0xD1, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x2B, 0xD2,
+0xD1, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x2C, 0xD2, 0x2D, 0xD2,
+0xE7, 0xF7, 0x0E, 0x6A, 0x40, 0x32, 0x40, 0x32, 0xA2, 0x67, 0xE1, 0xF6,
+0x80, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x36, 0xD2,
+0x36, 0x95, 0xD1, 0xF6, 0x8C, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x71, 0xF6, 0x80, 0x41, 0xF2, 0xF2,
+0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x71, 0xF6,
+0x84, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x36, 0x95, 0x71, 0xF6, 0x88, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x71, 0xF6, 0x8C, 0x41, 0xF2, 0xF2,
+0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x81, 0xF6,
+0x80, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x36, 0x95, 0x81, 0xF6, 0x84, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x81, 0xF6, 0x88, 0x41, 0xF2, 0xF2,
+0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0x81, 0xF6,
+0x8C, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x36, 0x95, 0xD1, 0xF6, 0x80, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0xD1, 0xF6, 0x84, 0x41, 0xF2, 0xF2,
+0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x36, 0x95, 0xD1, 0xF6,
+0x88, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x33, 0x93, 0x01, 0x6A, 0x1D, 0x90, 0x4E, 0xEB, 0x43, 0xEB, 0x58, 0x67,
+0x39, 0xD2, 0x0F, 0xF7, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x10, 0xF0,
+0x00, 0x4A, 0x43, 0xD2, 0x00, 0xF5, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x1E, 0xD0, 0x37, 0xD2, 0x11, 0x67, 0x01, 0xF0, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x00, 0x6B, 0x40, 0x32, 0x1D, 0xD3, 0x38, 0xD2,
+0x33, 0x94, 0x60, 0xF1, 0x13, 0x24, 0x39, 0x95, 0xE0, 0xF1, 0x0C, 0x2D,
+0xA1, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x05, 0xF0,
+0x00, 0x6B, 0x6B, 0xEB, 0x60, 0x33, 0x60, 0x33, 0x4C, 0xEB, 0x01, 0x5B,
+0x58, 0x67, 0x91, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x35, 0xD2,
+0xE0, 0xF3, 0x1F, 0x6B, 0x60, 0x33, 0x60, 0x33, 0x6C, 0xEA, 0x42, 0x32,
+0x42, 0x32, 0xB1, 0xF6, 0x84, 0x40, 0x3D, 0xD3, 0x00, 0x1C, 0xFA, 0x5B,
+0x2E, 0xD2, 0x3D, 0x94, 0x8C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x91, 0xF6,
+0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x2F, 0xD2, 0x3D, 0x95, 0xB1, 0xF6,
+0x8C, 0x40, 0xAC, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x00, 0x1C, 0xFA, 0x5B,
+0x30, 0xD2, 0x3D, 0x93, 0x2E, 0x94, 0x4C, 0xEB, 0x62, 0x32, 0x20, 0xF1,
+0x00, 0x74, 0x42, 0x32, 0xA0, 0xF2, 0x15, 0x60, 0x2F, 0x95, 0x20, 0xF1,
+0x00, 0x75, 0xA0, 0xF2, 0x10, 0x60, 0x30, 0x93, 0x20, 0x73, 0xA0, 0xF2,
+0x0C, 0x60, 0x20, 0x72, 0x01, 0x6B, 0xA0, 0xF2, 0x08, 0x60, 0x2E, 0x94,
+0x80, 0x74, 0xA0, 0xF2, 0x02, 0x60, 0x2F, 0x95, 0x80, 0x75, 0x80, 0xF2,
+0x1E, 0x60, 0x30, 0x94, 0xE0, 0xF3, 0x00, 0x74, 0x80, 0xF2, 0x19, 0x60,
+0xE0, 0xF3, 0x00, 0x72, 0x01, 0x6A, 0x80, 0xF2, 0x14, 0x60, 0x35, 0x95,
+0x03, 0x25, 0x02, 0x23, 0x20, 0xF4, 0x19, 0x2A, 0x1D, 0x95, 0x01, 0x4D,
+0x0A, 0x5D, 0x1D, 0xD5, 0x97, 0x61, 0x1E, 0x92, 0x01, 0x4A, 0x03, 0x5A,
+0x1E, 0xD2, 0x8A, 0x61, 0x04, 0x90, 0x20, 0xF4, 0x09, 0x28, 0x0C, 0x91,
+0x03, 0x29, 0x14, 0x92, 0xFF, 0x6C, 0x2B, 0x22, 0x90, 0x67, 0x00, 0x18,
+0xA1, 0x5E, 0xB1, 0x67, 0x03, 0x5A, 0x07, 0x60, 0x05, 0x94, 0x00, 0x18,
+0xA1, 0x5E, 0x0D, 0x95, 0x03, 0x5A, 0x00, 0x6C, 0x1E, 0x61, 0x14, 0x93,
+0x90, 0x67, 0xA3, 0x67, 0x00, 0x18, 0xA1, 0x5E, 0x40, 0xD3, 0x03, 0x5A,
+0x07, 0x60, 0x05, 0x94, 0x00, 0x18, 0xA1, 0x5E, 0x15, 0x95, 0x03, 0x5A,
+0x00, 0x6C, 0x0F, 0x61, 0x40, 0x95, 0x00, 0x18, 0xA1, 0x5E, 0x91, 0x67,
+0x03, 0x5A, 0x40, 0xF2, 0x1E, 0x60, 0x0D, 0x94, 0x00, 0x18, 0xA1, 0x5E,
+0x15, 0x95, 0x03, 0x5A, 0x01, 0x6C, 0x40, 0xF2, 0x16, 0x60, 0xFF, 0x74,
+0x40, 0xF2, 0x17, 0x60, 0x04, 0x05, 0x94, 0x34, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0xB1, 0xE4, 0x63, 0xF3, 0x00, 0x49, 0x60, 0x9C,
+0x43, 0x99, 0x00, 0xF4, 0x00, 0x68, 0xE0, 0xF3, 0x1F, 0x6F, 0x0B, 0xE8,
+0xEC, 0xEB, 0x0C, 0xEA, 0x6D, 0xEA, 0x61, 0x9C, 0x02, 0xF0, 0x00, 0x6E,
+0xCB, 0xEE, 0xEC, 0xEB, 0xC0, 0x36, 0xE0, 0xF3, 0x1F, 0x4E, 0x60, 0x33,
+0x68, 0x33, 0xCC, 0xEA, 0xE7, 0xF7, 0x10, 0x6D, 0x6D, 0xEA, 0xAB, 0xED,
+0x62, 0x9C, 0xA0, 0x35, 0xA0, 0x35, 0xFF, 0x4D, 0xEC, 0xEB, 0x00, 0xF5,
+0x60, 0x33, 0xAC, 0xEA, 0x6D, 0xEA, 0x43, 0xD9, 0x63, 0x9C, 0x44, 0x99,
+0xEC, 0xEB, 0x0C, 0xEA, 0x6D, 0xEA, 0x64, 0x9C, 0xCC, 0xEA, 0xEC, 0xEB,
+0x60, 0x33, 0x68, 0x33, 0x6D, 0xEA, 0x65, 0x9C, 0xAC, 0xEA, 0xEC, 0xEB,
+0x00, 0xF5, 0x60, 0x33, 0x6D, 0xEA, 0x44, 0xD9, 0x46, 0x9C, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x4A, 0xC9,
+0x47, 0x9C, 0x4B, 0xC9, 0x44, 0x9B, 0x80, 0xF7, 0x42, 0x32, 0x01, 0x72,
+0xC0, 0xF2, 0x1E, 0x61, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x31,
+0x20, 0x31, 0xE1, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x21, 0x95,
+0xD1, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x22, 0x95, 0x71, 0xF6,
+0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x23, 0x95, 0x71, 0xF6, 0x84, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x24, 0x95, 0x71, 0xF6, 0x88, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x25, 0x95, 0x71, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x26, 0x95, 0x81, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x27, 0x95,
+0x81, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x28, 0x95, 0x81, 0xF6,
+0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x29, 0x95, 0x81, 0xF6, 0x8C, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x2A, 0x95, 0xD1, 0xF6, 0x80, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x2B, 0x95, 0xD1, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x2C, 0x95, 0x81, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x2D, 0x95,
+0x1F, 0x96, 0x10, 0x6D, 0xA4, 0xED, 0xFF, 0x4D, 0x00, 0x1C, 0x83, 0x45,
+0x00, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42,
+0x01, 0x6C, 0x20, 0x96, 0x10, 0x6D, 0xA4, 0xED, 0xFF, 0x4D, 0x00, 0x1C,
+0x83, 0x45, 0x00, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C,
+0xF0, 0x42, 0x00, 0x6C, 0x10, 0x6D, 0xA4, 0xED, 0x1E, 0x6C, 0x00, 0x1C,
+0xAC, 0x45, 0xFF, 0x4D, 0x01, 0x6E, 0x22, 0x67, 0x4D, 0xEE, 0x10, 0x6D,
+0x03, 0x6A, 0x4B, 0xEA, 0xA4, 0xED, 0x4C, 0xEE, 0xFF, 0x4D, 0x00, 0x1C,
+0x83, 0x45, 0x1E, 0x6C, 0x00, 0x1C, 0x2C, 0x1F, 0x03, 0x6C, 0x10, 0x6D,
+0x03, 0x6A, 0xD1, 0x67, 0xA4, 0xED, 0x1E, 0x6C, 0xFF, 0x4D, 0x00, 0x1C,
+0x83, 0x45, 0x4D, 0xEE, 0x04, 0x63, 0x3E, 0x97, 0x3D, 0x91, 0x3C, 0x90,
+0x00, 0xEF, 0x20, 0x63, 0xA0, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x01, 0xF4,
+0x84, 0x40, 0x2A, 0xF4, 0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x08, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x7F, 0x4D, 0x01, 0xF4, 0x88, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x65, 0x4D, 0x8F, 0xF7, 0x00, 0x6D, 0xAB, 0xED,
+0xA0, 0x35, 0x21, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0xA0, 0x35,
+0x00, 0xF2, 0x14, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x41, 0xF6, 0x80, 0x40,
+0x40, 0xF1, 0x08, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x0D, 0xF0,
+0x16, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x41, 0xF6, 0x84, 0x40, 0xA0, 0xF4,
+0x02, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x41, 0xF6, 0x8C, 0x40,
+0xC5, 0xF0, 0x11, 0x6D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0xF2,
+0x14, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x61, 0xF6, 0x80, 0x40, 0x40, 0xF1,
+0x0D, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x05, 0xF0, 0x16, 0x6D,
+0xA0, 0x35, 0xA0, 0x35, 0x61, 0xF6, 0x84, 0x40, 0xA1, 0xF0, 0x1A, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x61, 0xF6, 0x8C, 0x40, 0xC5, 0xF0,
+0x11, 0x6D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x37, 0x95, 0x41, 0xF6,
+0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x01, 0x4D, 0x38, 0x95, 0x41, 0xF6,
+0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x01, 0x4D, 0x00, 0x1C, 0x2C, 0x1F,
+0x03, 0x6C, 0xA0, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x01, 0xF4, 0x84, 0x40,
+0x2A, 0xF4, 0x13, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x01, 0xF4,
+0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0xE4, 0x6D, 0x21, 0xF6, 0x88, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x33, 0x95, 0x39, 0x95, 0x1F, 0xF6, 0x14, 0x25,
+0x21, 0xF0, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xFF, 0x6D,
+0x01, 0x4D, 0xAC, 0xEA, 0x42, 0x32, 0x34, 0xD2, 0x02, 0x22, 0x01, 0x6A,
+0x34, 0xD2, 0xA0, 0x35, 0xA0, 0x35, 0x21, 0xF0, 0x80, 0x41, 0x3A, 0xD5,
+0x00, 0xF1, 0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x3A, 0x95,
+0x21, 0xF0, 0x88, 0x41, 0x00, 0xF1, 0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xA0, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x01, 0xF4, 0x84, 0x41,
+0x2A, 0xF4, 0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x08, 0x6D,
+0xA0, 0x35, 0xA0, 0x35, 0x7F, 0x4D, 0x01, 0xF4, 0x88, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x65, 0x4D, 0x43, 0x93, 0x21, 0xF6, 0x88, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x60, 0x35, 0x3A, 0x95, 0x31, 0xF6, 0x80, 0x41, 0x0F, 0xF4,
+0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x3A, 0x95, 0x31, 0xF6,
+0x84, 0x41, 0x09, 0xF0, 0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x02, 0xF0, 0x01, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x31, 0xF6, 0x88, 0x41,
+0x3B, 0xD5, 0x1B, 0xF4, 0x1F, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x3B, 0x95, 0x31, 0xF6, 0x8C, 0x41, 0x11, 0xF4, 0x1F, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x00, 0xF2, 0x14, 0x6D, 0xA0, 0x35, 0xA0, 0x35,
+0x41, 0xF6, 0x80, 0x41, 0x00, 0xF1, 0x02, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x0D, 0xF0, 0x16, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x41, 0xF6,
+0x84, 0x41, 0xC0, 0xF4, 0x07, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x41, 0xF6, 0x8C, 0x41, 0xC5, 0xF0, 0x11, 0x6D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x61, 0xF6, 0x8C, 0x41, 0xC5, 0xF0, 0x11, 0x6D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x3A, 0x95, 0x51, 0xF6, 0x80, 0x41, 0x0F, 0xF4,
+0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x3A, 0x95, 0x51, 0xF6,
+0x84, 0x41, 0x09, 0xF0, 0x00, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x3B, 0x95, 0x51, 0xF6, 0x88, 0x41, 0x3B, 0xF4, 0x03, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x3B, 0x95, 0x51, 0xF6, 0x8C, 0x41, 0x31, 0xF4,
+0x03, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0xF2, 0x14, 0x6D,
+0xA0, 0x35, 0xA0, 0x35, 0x61, 0xF6, 0x80, 0x41, 0x00, 0xF1, 0x02, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x05, 0xF0, 0x16, 0x6D, 0xA0, 0x35,
+0xA0, 0x35, 0x61, 0xF6, 0x84, 0x41, 0x01, 0xF5, 0x07, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x41, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x37, 0x95, 0x41, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x38, 0x95,
+0x00, 0x1C, 0x2C, 0x1F, 0x03, 0x6C, 0x00, 0xF2, 0x00, 0x6A, 0x40, 0x32,
+0x40, 0x32, 0xA2, 0x67, 0x41, 0xF6, 0x8C, 0x41, 0xC5, 0xF0, 0x11, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x3C, 0xD2, 0x3C, 0x95, 0x61, 0xF6, 0x8C, 0x41,
+0xC5, 0xF0, 0x11, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x41, 0xF6,
+0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x37, 0x95, 0x41, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x38, 0x95, 0x00, 0x1C, 0x2C, 0x1F, 0x03, 0x6C,
+0x01, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x31, 0x95, 0x01, 0xF4,
+0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x32, 0x95, 0x21, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x6D, 0x34, 0x93, 0x1F, 0xF5, 0x1E, 0x2B,
+0x21, 0xF0, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x3A, 0x95, 0x21, 0xF0,
+0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x3A, 0x95, 0x13, 0x15, 0x00, 0x6A,
+0x6A, 0x15, 0x00, 0x6B, 0x56, 0x15, 0xFF, 0x6C, 0xFF, 0x74, 0xBF, 0xF5,
+0x09, 0x61, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34,
+0x41, 0xD4, 0x81, 0xF6, 0x14, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0xE0, 0xF3, 0x1F, 0x6B, 0x60, 0x31, 0x20, 0x31, 0x2C, 0xEA, 0x42, 0x32,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x63, 0xF3, 0x00, 0x4C,
+0x42, 0x32, 0x6C, 0xEA, 0x63, 0x9C, 0x00, 0xF4, 0x00, 0x6D, 0xAB, 0xED,
+0xAC, 0xEB, 0x4D, 0xEB, 0x63, 0xDC, 0x41, 0x94, 0xE0, 0xF3, 0x1F, 0x68,
+0x81, 0xF6, 0x1C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x2C, 0xEA,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x10, 0x6D, 0x63, 0xF3,
+0x00, 0x4C, 0x42, 0x32, 0xAB, 0xED, 0x63, 0x9C, 0x42, 0x32, 0xA0, 0x35,
+0x0C, 0xEA, 0xA0, 0x35, 0xE0, 0xF3, 0x1F, 0x4D, 0x40, 0x32, 0xAC, 0xEB,
+0x48, 0x32, 0x4D, 0xEB, 0x63, 0xDC, 0x41, 0x94, 0xA1, 0xF6, 0x04, 0x4C,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x2C, 0xEA, 0x42, 0x32, 0x42, 0x32,
+0x0C, 0xEA, 0xE7, 0xF7, 0x10, 0x6C, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4,
+0x00, 0x30, 0x63, 0xF3, 0x00, 0x48, 0x8B, 0xEC, 0x63, 0x98, 0x80, 0x34,
+0x80, 0x34, 0xFF, 0x4C, 0x00, 0xF5, 0x40, 0x32, 0x8C, 0xEB, 0x4D, 0xEB,
+0x63, 0xD8, 0x41, 0x94, 0xA1, 0xF6, 0x0C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x2C, 0xEA, 0x64, 0x98, 0x42, 0x32, 0x00, 0xF4, 0x00, 0x68,
+0xE0, 0xF3, 0x1F, 0x6D, 0x0B, 0xE8, 0x42, 0x32, 0xAC, 0xEA, 0x0C, 0xEB,
+0x4D, 0xEB, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3,
+0x00, 0x4A, 0x64, 0xDA, 0x41, 0x94, 0xE0, 0xF3, 0x1F, 0x68, 0xA1, 0xF6,
+0x14, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x2C, 0xEA, 0x42, 0x32,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x10, 0x6D, 0x63, 0xF3,
+0x00, 0x4C, 0xE0, 0xF3, 0x1F, 0x6B, 0x42, 0x32, 0xAB, 0xED, 0x6C, 0xEA,
+0xA0, 0x35, 0x64, 0x9C, 0xA0, 0x35, 0xE0, 0xF3, 0x1F, 0x4D, 0x40, 0x32,
+0xAC, 0xEB, 0x48, 0x32, 0x4D, 0xEB, 0x64, 0xDC, 0x41, 0x94, 0xA1, 0xF6,
+0x1C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0xE7, 0xF7, 0x10, 0x6D, 0x63, 0xF3, 0x00, 0x4C,
+0x2C, 0xEA, 0xAB, 0xED, 0x64, 0x9C, 0x42, 0x32, 0xA0, 0x35, 0x42, 0x32,
+0xA0, 0x35, 0xFF, 0x4D, 0x0C, 0xEA, 0xAC, 0xEB, 0x00, 0xF5, 0x40, 0x32,
+0x4D, 0xEB, 0x64, 0xDC, 0x41, 0x94, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4,
+0x00, 0x30, 0x63, 0xF3, 0x00, 0x48, 0xC1, 0xF6, 0x04, 0x4C, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x2C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x4A, 0xC8,
+0x41, 0x94, 0xC1, 0xF6, 0x0C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x4C, 0xE9, 0x22, 0x32, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x42, 0x32, 0x63, 0xF3, 0x00, 0x4B, 0x4B, 0xC8, 0x44, 0x9B, 0x80, 0xF7,
+0x42, 0x32, 0x01, 0x72, 0x3F, 0xF5, 0x02, 0x60, 0xC9, 0xF7, 0x1B, 0x6A,
+0x4B, 0xEA, 0x40, 0x31, 0x20, 0x31, 0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x82, 0x67, 0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4,
+0x00, 0x30, 0x40, 0x6A, 0x4B, 0xEA, 0x63, 0xF3, 0x00, 0x48, 0x40, 0x32,
+0xC3, 0x98, 0x40, 0x32, 0x8C, 0xEA, 0xE0, 0xF3, 0x1F, 0x6B, 0x80, 0xF5,
+0x42, 0x35, 0xCC, 0xEB, 0x00, 0xF2, 0x00, 0x6A, 0x6C, 0xEA, 0x04, 0x22,
+0x00, 0xF4, 0x00, 0x6A, 0x4B, 0xEA, 0x4D, 0xEB, 0xB8, 0xEB, 0xE0, 0xF3,
+0x1F, 0x68, 0x12, 0xEA, 0x42, 0x33, 0x0C, 0xEB, 0xC2, 0x30, 0xE0, 0xF3,
+0x1F, 0x6A, 0x0A, 0x30, 0x4C, 0xE8, 0x00, 0xF2, 0x00, 0x6A, 0x0C, 0xEA,
+0x04, 0x22, 0x00, 0xF4, 0x00, 0x6A, 0x4B, 0xEA, 0x4D, 0xE8, 0xB8, 0xE8,
+0xE0, 0xF3, 0x1F, 0x6D, 0x12, 0xEA, 0x42, 0x30, 0x3F, 0x6A, 0x4B, 0xEA,
+0xAC, 0xE8, 0x40, 0x32, 0x3F, 0x6D, 0x42, 0xD5, 0x40, 0x32, 0x0C, 0xED,
+0x1F, 0xF4, 0x00, 0x4A, 0xA0, 0x35, 0x4C, 0xEC, 0xA0, 0x35, 0x8D, 0xED,
+0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x6D, 0xED, 0x91, 0xF4,
+0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x02, 0xF0, 0x00, 0x6B,
+0x60, 0x33, 0x60, 0x33, 0xFF, 0x4B, 0xC0, 0xF3, 0x00, 0x6C, 0x6C, 0xEA,
+0x8C, 0xE8, 0x80, 0xF5, 0x00, 0x33, 0xA2, 0x67, 0x91, 0xF4, 0x84, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x6D, 0xED, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0xBD, 0xF7, 0x10, 0x4D, 0x82, 0x67, 0x40, 0x9D, 0x8C, 0xEA, 0x80, 0xF5,
+0x42, 0x35, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3,
+0x00, 0x4A, 0x04, 0x9A, 0xE0, 0xF3, 0x1F, 0x6A, 0x02, 0x33, 0x6A, 0x33,
+0x4C, 0xEB, 0x00, 0xF2, 0x00, 0x6A, 0x6C, 0xEA, 0x04, 0x22, 0x00, 0xF4,
+0x00, 0x6A, 0x4B, 0xEA, 0x4D, 0xEB, 0xB8, 0xEB, 0x00, 0xF5, 0x02, 0x30,
+0x12, 0xEA, 0x42, 0x33, 0xE0, 0xF3, 0x1F, 0x6A, 0x4C, 0xE8, 0x4C, 0xEB,
+0x00, 0xF2, 0x00, 0x6A, 0x0C, 0xEA, 0x04, 0x22, 0x00, 0xF4, 0x00, 0x6A,
+0x4B, 0xEA, 0x4D, 0xE8, 0xB8, 0xE8, 0xE0, 0xF3, 0x1F, 0x6D, 0x12, 0xEA,
+0x42, 0x30, 0xAC, 0xE8, 0x3F, 0x6A, 0x42, 0x95, 0x4B, 0xEA, 0x40, 0x32,
+0x0C, 0xED, 0x40, 0x32, 0x1F, 0xF4, 0x00, 0x4A, 0x42, 0xD5, 0xA0, 0x35,
+0x4C, 0xEC, 0xA0, 0x35, 0x8D, 0xED, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x6D, 0xED, 0x91, 0xF4, 0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xBD, 0xF7,
+0x14, 0x4B, 0xA0, 0x9B, 0xC0, 0xF3, 0x00, 0x6C, 0x8C, 0xE8, 0x4C, 0xED,
+0x80, 0xF5, 0x00, 0x32, 0x91, 0xF4, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x4D, 0xED, 0x58, 0x14, 0x0C, 0x91, 0xDF, 0xF3, 0x19, 0x10, 0x1E, 0x93,
+0x04, 0x04, 0x74, 0x32, 0x91, 0xE2, 0x3E, 0xD4, 0x91, 0xF6, 0x84, 0x40,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3, 0x1F, 0x6B, 0x60, 0x33,
+0x60, 0x33, 0x3E, 0x95, 0x6C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x3F, 0xD3,
+0x91, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x40, 0xDD, 0x3F, 0x93,
+0x3E, 0x94, 0x6C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x41, 0xDC, 0xA1, 0xF6,
+0x84, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x3F, 0x95, 0x3E, 0x93,
+0xA1, 0xF6, 0x8C, 0x40, 0xAC, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x00, 0x1C,
+0xFA, 0x5B, 0x42, 0xDB, 0x3F, 0x94, 0x3E, 0x95, 0x8C, 0xEA, 0x42, 0x32,
+0x42, 0x32, 0xB1, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x43, 0xDD,
+0x3F, 0x93, 0x3E, 0x94, 0x6C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x44, 0xDC,
+0xB1, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x3F, 0x95,
+0x3E, 0x93, 0xC1, 0xF6, 0x84, 0x40, 0xAC, 0xEA, 0x42, 0x32, 0x42, 0x32,
+0x00, 0x1C, 0xFA, 0x5B, 0x45, 0xDB, 0x3F, 0x94, 0x3E, 0x95, 0x8C, 0xEA,
+0x42, 0x32, 0x42, 0x32, 0xC1, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B,
+0x46, 0xDD, 0x3F, 0x93, 0x3E, 0x94, 0x4C, 0xEB, 0x62, 0x32, 0x42, 0x32,
+0x47, 0xDC, 0x7F, 0xF3, 0x0E, 0x10, 0x00, 0x00, 0xFB, 0x63, 0x07, 0xD1,
+0x0C, 0xF0, 0x00, 0x6A, 0x10, 0xF0, 0x02, 0x69, 0x00, 0xF4, 0x20, 0x31,
+0x63, 0xF3, 0x00, 0x49, 0x08, 0x62, 0x0A, 0xD4, 0x06, 0xD0, 0x4B, 0xEA,
+0x62, 0x99, 0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0xC9, 0xF7,
+0x1B, 0x6C, 0x04, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x8B, 0xEC, 0x40, 0x32,
+0x80, 0x34, 0x4D, 0xEB, 0x80, 0x34, 0x62, 0xD9, 0x04, 0xD4, 0x81, 0xF6,
+0x14, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3, 0x1F, 0x6B,
+0x60, 0x30, 0x00, 0x30, 0x0C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x6C, 0xEA,
+0x63, 0x99, 0x00, 0xF4, 0x00, 0x6C, 0x8B, 0xEC, 0x8C, 0xEB, 0x4D, 0xEB,
+0x63, 0xD9, 0x04, 0x94, 0x81, 0xF6, 0x1C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0x10, 0x6C, 0xE0, 0xF3, 0x1F, 0x6B,
+0x42, 0x32, 0x8B, 0xEC, 0x6C, 0xEA, 0x80, 0x34, 0x63, 0x99, 0x80, 0x34,
+0xE0, 0xF3, 0x1F, 0x4C, 0x40, 0x32, 0x48, 0x32, 0x8C, 0xEB, 0x4D, 0xEB,
+0x63, 0xD9, 0x04, 0x94, 0xA1, 0xF6, 0x04, 0x4C, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0xE7, 0xF7, 0x10, 0x6C, 0xE0, 0xF3,
+0x1F, 0x6B, 0x42, 0x32, 0x8B, 0xEC, 0x6C, 0xEA, 0x80, 0x34, 0x63, 0x99,
+0x80, 0x34, 0xFF, 0x4C, 0x00, 0xF5, 0x40, 0x32, 0x8C, 0xEB, 0x4D, 0xEB,
+0x63, 0xD9, 0x04, 0x94, 0xA1, 0xF6, 0x0C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0xE0, 0xF3, 0x1F, 0x6B, 0x42, 0x32,
+0x6C, 0xEA, 0x64, 0x99, 0x00, 0xF4, 0x00, 0x6C, 0x8B, 0xEC, 0x8C, 0xEB,
+0x4D, 0xEB, 0x64, 0xD9, 0x04, 0x94, 0xA1, 0xF6, 0x14, 0x4C, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0x10, 0x6C, 0xE0, 0xF3,
+0x1F, 0x6B, 0x42, 0x32, 0x8B, 0xEC, 0x6C, 0xEA, 0x80, 0x34, 0x64, 0x99,
+0x80, 0x34, 0xE0, 0xF3, 0x1F, 0x4C, 0x40, 0x32, 0x48, 0x32, 0x8C, 0xEB,
+0x4D, 0xEB, 0x64, 0xD9, 0x04, 0x94, 0xA1, 0xF6, 0x1C, 0x4C, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0xE7, 0xF7, 0x10, 0x6C,
+0xE0, 0xF3, 0x1F, 0x6B, 0x42, 0x32, 0x8B, 0xEC, 0x6C, 0xEA, 0x80, 0x34,
+0x64, 0x99, 0x80, 0x34, 0xFF, 0x4C, 0x00, 0xF5, 0x40, 0x32, 0x8C, 0xEB,
+0x4D, 0xEB, 0x64, 0xD9, 0x04, 0x94, 0xC1, 0xF6, 0x04, 0x4C, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x0C, 0xEA, 0x42, 0x32, 0x42, 0x32, 0x4A, 0xC9,
+0x04, 0x94, 0xC1, 0xF6, 0x0C, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x4C, 0xE8, 0xFF, 0x6A, 0x01, 0x4A, 0x40, 0x32, 0x40, 0x32, 0x0A, 0x93,
+0x80, 0x4A, 0x02, 0x30, 0x80, 0x4A, 0x02, 0x30, 0x6C, 0xEA, 0x0B, 0xC9,
+0x14, 0x22, 0x1F, 0xF7, 0x00, 0x6A, 0x0A, 0x94, 0x4C, 0xEB, 0x62, 0x33,
+0xC0, 0xF2, 0x63, 0xC1, 0x82, 0x33, 0x4C, 0xEB, 0x62, 0x33, 0xC0, 0xF2,
+0x67, 0xC1, 0x00, 0x18, 0x0A, 0x5F, 0x00, 0x65, 0x08, 0x97, 0x07, 0x91,
+0x06, 0x90, 0x00, 0xEF, 0x05, 0x63, 0x12, 0x6A, 0xC0, 0xF2, 0x43, 0xC1,
+0xC0, 0xF2, 0x47, 0xC1, 0x00, 0x18, 0x0A, 0x5F, 0x00, 0x65, 0x08, 0x97,
+0x07, 0x91, 0x06, 0x90, 0x00, 0xEF, 0x05, 0x63, 0xC9, 0xF7, 0x1B, 0x6A,
+0xFB, 0x63, 0x4B, 0xEA, 0x06, 0xD0, 0x40, 0x30, 0x07, 0xD1, 0x08, 0x62,
+0x00, 0x30, 0x40, 0xF0, 0x4C, 0xA0, 0x03, 0x69, 0x4C, 0xE9, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x62, 0x67, 0x04, 0xD2, 0x63, 0xF3,
+0x00, 0x4B, 0xC3, 0xF3, 0x41, 0xA3, 0x2E, 0xEA, 0x1A, 0x22, 0x05, 0x29,
+0xE0, 0xF2, 0x66, 0xA3, 0xFF, 0x6A, 0x4C, 0xEB, 0x1A, 0x23, 0x04, 0x92,
+0xC9, 0xF7, 0x17, 0x6C, 0x8B, 0xEC, 0x63, 0xF3, 0x00, 0x4A, 0x04, 0xD2,
+0xC3, 0xF3, 0x21, 0xC2, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x76, 0x9A, 0x80, 0x34, 0x80, 0x34, 0x60, 0xDC, 0x57, 0x9A,
+0x41, 0xDC, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x00, 0x6A, 0x00, 0xEF,
+0x05, 0x63, 0x51, 0xF4, 0x80, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x1C, 0x6D,
+0x51, 0xF4, 0x88, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x1C, 0x6D, 0xDB, 0x17,
+0xF9, 0x63, 0x0A, 0xD0, 0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8, 0x00, 0x30,
+0x00, 0x30, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x0B, 0xD1,
+0xA1, 0xF5, 0x82, 0x40, 0x22, 0x67, 0x63, 0xF3, 0x00, 0x49, 0x0C, 0x62,
+0x00, 0x1C, 0xFD, 0x5B, 0x06, 0xD2, 0xC0, 0xF2, 0x58, 0xC9, 0xA1, 0xF5,
+0x84, 0x40, 0x00, 0x1C, 0xFD, 0x5B, 0x00, 0x65, 0xC0, 0xF2, 0x5A, 0xC9,
+0xA1, 0xF5, 0x86, 0x40, 0x00, 0x1C, 0xFD, 0x5B, 0x00, 0x65, 0xC0, 0xF2,
+0x5C, 0xC9, 0xA1, 0xF5, 0x88, 0x40, 0x00, 0x1C, 0xFD, 0x5B, 0x00, 0x65,
+0x82, 0x67, 0xC0, 0xF2, 0x7A, 0xA9, 0xC0, 0xF2, 0x5E, 0xC9, 0xC0, 0xF2,
+0x58, 0xA9, 0x69, 0xE2, 0xC0, 0xF2, 0x7C, 0xA9, 0x69, 0xE2, 0x51, 0xE4,
+0x04, 0xD4, 0x21, 0xF2, 0x8D, 0x40, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65,
+0x00, 0xF6, 0x40, 0x35, 0x00, 0xF6, 0xA3, 0x35, 0x40, 0x6A, 0xFF, 0x6B,
+0x4D, 0xED, 0x6C, 0xED, 0x21, 0xF2, 0x8D, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0x05, 0xD3, 0x51, 0xF2, 0x8B, 0x40, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65,
+0x40, 0x32, 0x51, 0xF2, 0x8C, 0x40, 0xE0, 0xF2, 0x44, 0xC9, 0x00, 0x1C,
+0x00, 0x5C, 0x00, 0x65, 0xE0, 0xF2, 0x64, 0xA9, 0x61, 0xF4, 0x84, 0x40,
+0x75, 0xE2, 0x04, 0x93, 0xFF, 0xF7, 0x1F, 0x6A, 0xE0, 0xF2, 0xA4, 0xC9,
+0x4C, 0xED, 0x69, 0xE5, 0xE0, 0xF2, 0x40, 0xD9, 0xFF, 0xF7, 0x1F, 0x6A,
+0x00, 0x1C, 0xE6, 0x5B, 0x4C, 0xED, 0x43, 0xA9, 0xFF, 0xF7, 0x1F, 0x6B,
+0x6C, 0xEA, 0x10, 0x52, 0x05, 0x60, 0xE0, 0xF2, 0x40, 0x99, 0x1F, 0x5A,
+0xA0, 0xF0, 0x1E, 0x61, 0x00, 0x6A, 0xC0, 0xF2, 0x54, 0xC1, 0xC0, 0xF2,
+0x55, 0xA1, 0x05, 0x93, 0x01, 0x4A, 0x4C, 0xEB, 0x03, 0x53, 0xA0, 0xF0,
+0x0B, 0x60, 0xC0, 0xF2, 0x55, 0xC1, 0x06, 0x94, 0x00, 0x6A, 0x11, 0x6B,
+0x63, 0xF3, 0x00, 0x4C, 0x43, 0xCC, 0xE0, 0xF2, 0x44, 0xCC, 0x40, 0x9C,
+0x6C, 0xEA, 0x01, 0x72, 0x80, 0xF0, 0x13, 0x61, 0xE0, 0xF2, 0x44, 0x9C,
+0x03, 0x6B, 0x00, 0xF7, 0x42, 0x32, 0x6C, 0xEA, 0x80, 0xF0, 0x0B, 0x2A,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x40, 0xF0,
+0x4C, 0xA2, 0x4C, 0xEB, 0x01, 0x73, 0xA0, 0xF0, 0x04, 0x60, 0x06, 0x94,
+0x63, 0xF3, 0x00, 0x4C, 0xE0, 0xF2, 0x46, 0xA4, 0xA0, 0xF0, 0x0B, 0x2A,
+0x40, 0x9C, 0x01, 0x6B, 0x56, 0x32, 0x6C, 0xEA, 0xA0, 0xF0, 0x05, 0x22,
+0x3E, 0x6A, 0xC0, 0xF2, 0x50, 0xC4, 0x1C, 0x6A, 0xC0, 0xF2, 0x51, 0xC4,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x40, 0xF0,
+0x6C, 0xA2, 0xFF, 0x6A, 0x6C, 0xEA, 0x03, 0x6B, 0x6C, 0xEA, 0x61, 0x22,
+0x66, 0xF7, 0x4C, 0x9C, 0xFF, 0xF7, 0x1F, 0x72, 0x5C, 0x60, 0xE0, 0xF2,
+0x40, 0x9C, 0xE0, 0xF3, 0x09, 0x5A, 0x00, 0xF1, 0x03, 0x61, 0xC0, 0xF2,
+0x72, 0xA4, 0x00, 0xF6, 0x60, 0x32, 0x00, 0xF6, 0x43, 0x32, 0xFE, 0x4A,
+0xFF, 0xF7, 0x1C, 0x52, 0x04, 0x6A, 0x4B, 0xEA, 0x01, 0x61, 0x4E, 0x43,
+0xC0, 0xF2, 0x52, 0xC4, 0x06, 0x96, 0x7F, 0x6B, 0x63, 0xF3, 0x00, 0x4E,
+0x66, 0xF7, 0x4C, 0x9E, 0xC0, 0xF2, 0x8E, 0xA6, 0x52, 0x32, 0x6C, 0xEA,
+0xA7, 0x42, 0xC0, 0xF2, 0x52, 0xA6, 0x03, 0x4D, 0xFF, 0x6B, 0x4B, 0xE5,
+0x00, 0xF6, 0x40, 0x35, 0x43, 0x67, 0x00, 0xF6, 0xA3, 0x35, 0x8C, 0xEA,
+0xA2, 0xEA, 0xE0, 0xF0, 0x0C, 0x60, 0x00, 0xF6, 0x80, 0x35, 0x00, 0xF6,
+0xA3, 0x35, 0x06, 0x92, 0x63, 0xF3, 0x00, 0x4A, 0x06, 0xD2, 0xE0, 0xF2,
+0x40, 0x9A, 0x04, 0xF7, 0x11, 0x5A, 0xC0, 0xF0, 0x01, 0x61, 0x32, 0x55,
+0xA0, 0xF0, 0x1E, 0x60, 0x32, 0x6D, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA,
+0x40, 0x32, 0x40, 0x32, 0x21, 0xF4, 0x10, 0x4A, 0x44, 0x6B, 0xC9, 0xF7,
+0x1B, 0x68, 0x0B, 0xE8, 0x60, 0xC2, 0x00, 0x30, 0xFF, 0x6A, 0xAC, 0xEA,
+0x00, 0x30, 0xA2, 0x67, 0x51, 0xF4, 0x80, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0x08, 0xD2, 0x08, 0x92, 0x51, 0xF4, 0x88, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0xA2, 0x67, 0x00, 0x18, 0x08, 0x61, 0x00, 0x65, 0x0C, 0x97, 0x0B, 0x91,
+0x0A, 0x90, 0x00, 0x6A, 0x00, 0xEF, 0x07, 0x63, 0x03, 0x6A, 0xC0, 0xF2,
+0x55, 0xC1, 0x40, 0x99, 0x08, 0x6B, 0x6D, 0xEA, 0x40, 0xD9, 0x4F, 0x17,
+0x00, 0x6A, 0xC0, 0xF2, 0x55, 0xC1, 0xC0, 0xF2, 0x54, 0xA1, 0x05, 0x93,
+0x01, 0x4A, 0x4C, 0xEB, 0x03, 0x53, 0x14, 0x61, 0x03, 0x6A, 0xC0, 0xF2,
+0x54, 0xC1, 0x40, 0x99, 0x09, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA, 0x40, 0xD9,
+0x3C, 0x17, 0xE0, 0xF2, 0x66, 0xA4, 0xFF, 0x6A, 0x4C, 0xEB, 0x5F, 0xF7,
+0x16, 0x2B, 0x01, 0x6A, 0x4B, 0xEA, 0xE0, 0xF2, 0x46, 0xC4, 0x51, 0x17,
+0xC0, 0xF2, 0x54, 0xC1, 0x2E, 0x17, 0x06, 0x90, 0xFF, 0x6D, 0x63, 0xF3,
+0x00, 0x48, 0xE0, 0xF2, 0x46, 0xA0, 0xAA, 0xEA, 0xC6, 0x61, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x41, 0xF4, 0x10, 0x4C,
+0x00, 0x1C, 0x00, 0x5C, 0x09, 0xD5, 0x09, 0x95, 0x00, 0xF6, 0x40, 0x31,
+0x00, 0xF6, 0x23, 0x31, 0x7F, 0x6A, 0xAC, 0xE9, 0x4C, 0xE9, 0xE0, 0xF2,
+0x60, 0x98, 0xC0, 0xF2, 0x48, 0xA8, 0xFF, 0xF7, 0x1F, 0x6C, 0x43, 0xEB,
+0x38, 0x61, 0xC0, 0xF2, 0x4A, 0xA8, 0x8C, 0xEA, 0x43, 0xEB, 0x07, 0x61,
+0xC0, 0xF2, 0x4C, 0xA8, 0x8C, 0xEA, 0x43, 0xEB, 0x69, 0x60, 0x01, 0x49,
+0xAC, 0xE9, 0x06, 0x93, 0x63, 0xF3, 0x00, 0x4B, 0xC0, 0xF2, 0x50, 0xA3,
+0x23, 0xEA, 0x32, 0x60, 0x22, 0x67, 0x06, 0x93, 0x63, 0xF3, 0x00, 0x4B,
+0x06, 0xD3, 0xE0, 0xF2, 0x40, 0x9B, 0x04, 0xF7, 0x11, 0x5A, 0x1D, 0x61,
+0x32, 0x69, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x21, 0xF4, 0x10, 0x4A, 0x44, 0x6B, 0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8,
+0x00, 0x30, 0x00, 0x30, 0x51, 0xF4, 0x80, 0x40, 0xB1, 0x67, 0x60, 0xC2,
+0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0x51, 0xF4, 0x88, 0x40, 0x00, 0x1C,
+0xF0, 0x5B, 0xB1, 0x67, 0x74, 0x17, 0xFF, 0x49, 0xD1, 0x17, 0x3A, 0x59,
+0xE2, 0x61, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x21, 0xF4, 0x10, 0x4A, 0x48, 0x6B, 0xE1, 0x17, 0xC0, 0xF2, 0x71, 0xA3,
+0xFF, 0x6A, 0x4C, 0xEB, 0x63, 0xE9, 0xC9, 0x60, 0x23, 0x67, 0xC7, 0x17,
+0x3A, 0x55, 0x5F, 0xF7, 0x00, 0x61, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA,
+0x40, 0x32, 0x40, 0x32, 0x21, 0xF4, 0x10, 0x4A, 0x48, 0x6B, 0x3F, 0x17,
+0x80, 0xF1, 0x10, 0x5A, 0x1F, 0xF7, 0x08, 0x60, 0xC0, 0xF2, 0x72, 0xA4,
+0x00, 0xF6, 0x60, 0x32, 0x00, 0xF6, 0x43, 0x32, 0x02, 0x4A, 0x0D, 0x52,
+0x0C, 0x6A, 0xFF, 0xF6, 0x1B, 0x60, 0x42, 0x43, 0xF9, 0x16, 0xC0, 0xF2,
+0x4F, 0xA6, 0x4C, 0xEB, 0x62, 0xED, 0x1F, 0xF7, 0x12, 0x60, 0x00, 0xF6,
+0x40, 0x35, 0x0D, 0x17, 0x02, 0x49, 0x96, 0x17, 0xFB, 0x63, 0x06, 0xD0,
+0x02, 0xF0, 0x00, 0x68, 0x00, 0x30, 0xAF, 0x40, 0xFF, 0xF0, 0x10, 0x6E,
+0x15, 0x6C, 0x08, 0x62, 0x00, 0x1C, 0x83, 0x45, 0x07, 0xD1, 0x00, 0x1C,
+0x5B, 0x1F, 0x64, 0x6C, 0x1A, 0x6C, 0x46, 0xF0, 0x16, 0x6E, 0x00, 0x1C,
+0x83, 0x45, 0xAF, 0x40, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x04, 0xD2, 0x63, 0xF3, 0x40, 0x9A,
+0x01, 0x6B, 0x4E, 0x32, 0x6C, 0xEA, 0x0A, 0x22, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0x47, 0xA3,
+0x01, 0x72, 0x1C, 0x61, 0x04, 0x92, 0x63, 0xF3, 0x20, 0x9A, 0x01, 0x6A,
+0x2E, 0x31, 0x4C, 0xE9, 0x09, 0x29, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0x47, 0xA3, 0x5A, 0x2A,
+0x04, 0x93, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x63, 0xF3, 0x00, 0x4B,
+0x04, 0xD3, 0x04, 0x6A, 0x00, 0xF3, 0x44, 0xC3, 0x00, 0xEF, 0x05, 0x63,
+0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x31, 0x24, 0xF2, 0x02, 0x68,
+0x20, 0x31, 0x00, 0x30, 0x01, 0xF6, 0x88, 0x41, 0x24, 0xF2, 0x02, 0x6D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x30, 0x01, 0xF6, 0x80, 0x41, 0x24, 0xF2,
+0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x01, 0xF6, 0x84, 0x41,
+0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x11, 0xF6,
+0x80, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x11, 0xF6, 0x84, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x11, 0xF6, 0x88, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x11, 0xF6, 0x8C, 0x41, 0x24, 0xF2, 0xA2, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x01, 0x6B, 0x63, 0xF3, 0x00, 0x4A, 0x00, 0xF3, 0x67, 0xC2,
+0x04, 0x93, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x63, 0xF3, 0x00, 0x4B,
+0x04, 0xD3, 0x04, 0x6A, 0x00, 0xF3, 0x44, 0xC3, 0x00, 0xEF, 0x05, 0x63,
+0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8, 0x00, 0xF3, 0xB4, 0x9B, 0x00, 0x30,
+0x00, 0x30, 0x01, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A,
+0x00, 0xF3, 0xB4, 0x9A, 0x01, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0x00, 0xF3, 0xB8, 0x9B, 0x01, 0xF6, 0x88, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0x00, 0xF3, 0xB4, 0x9A, 0x11, 0xF6, 0x80, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0xB4, 0x9B, 0x11, 0xF6,
+0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x00, 0xF3, 0xB4, 0x9A,
+0x11, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3,
+0xB4, 0x9B, 0x11, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A,
+0x00, 0xF3, 0x27, 0xC2, 0x04, 0x93, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90,
+0x63, 0xF3, 0x00, 0x4B, 0x04, 0xD3, 0x04, 0x6A, 0x00, 0xF3, 0x44, 0xC3,
+0x00, 0xEF, 0x05, 0x63, 0xFB, 0x63, 0x06, 0xD0, 0x02, 0xF0, 0x00, 0x68,
+0x00, 0x30, 0xAF, 0x40, 0xFF, 0xF0, 0x10, 0x6E, 0x15, 0x6C, 0x08, 0x62,
+0x00, 0x1C, 0x83, 0x45, 0x07, 0xD1, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x1A, 0x6C, 0x46, 0xF0, 0x16, 0x6E, 0x00, 0x1C, 0x83, 0x45, 0xAF, 0x40,
+0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x05, 0xD2, 0x63, 0xF3, 0x40, 0x9A, 0x01, 0x6B, 0x4E, 0x32,
+0x6C, 0xEA, 0x0A, 0x22, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0x47, 0xA3, 0x01, 0x72, 0x1D, 0x61,
+0x05, 0x92, 0x63, 0xF3, 0x20, 0x9A, 0x01, 0x6A, 0x2E, 0x31, 0x4C, 0xE9,
+0x09, 0x29, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0x00, 0xF3, 0x47, 0xA3, 0x5C, 0x2A, 0x05, 0x92, 0x08, 0x97,
+0x07, 0x91, 0x63, 0xF3, 0x00, 0x4A, 0x05, 0xD2, 0x05, 0x93, 0x06, 0x90,
+0x01, 0x6A, 0x00, 0xF3, 0x44, 0xC3, 0x00, 0xEF, 0x05, 0x63, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x31, 0x24, 0xF2, 0x02, 0x68, 0x20, 0x31,
+0x00, 0x30, 0x01, 0xF6, 0x88, 0x41, 0x24, 0xF2, 0x02, 0x6D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x30, 0x01, 0xF6, 0x80, 0x41, 0x24, 0xF2, 0xA2, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x01, 0xF6, 0x84, 0x41, 0x24, 0xF2,
+0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x11, 0xF6, 0x80, 0x41,
+0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x11, 0xF6,
+0x84, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x11, 0xF6, 0x88, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x11, 0xF6, 0x8C, 0x41, 0x24, 0xF2, 0xA2, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x01, 0x6B, 0x63, 0xF3, 0x00, 0x4A, 0x00, 0xF3, 0x67, 0xC2, 0x05, 0x92,
+0x08, 0x97, 0x07, 0x91, 0x63, 0xF3, 0x00, 0x4A, 0x05, 0xD2, 0x05, 0x93,
+0x06, 0x90, 0x01, 0x6A, 0x00, 0xF3, 0x44, 0xC3, 0x00, 0xEF, 0x05, 0x63,
+0xC9, 0xF7, 0x1B, 0x68, 0x02, 0xF0, 0x10, 0x6A, 0x0B, 0xE8, 0x40, 0x32,
+0x40, 0x32, 0x00, 0x30, 0xA2, 0x67, 0x00, 0x30, 0x01, 0xF6, 0x80, 0x40,
+0x02, 0xF0, 0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x04, 0xD2, 0x04, 0x95,
+0x01, 0xF6, 0x84, 0x40, 0x02, 0xF0, 0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x01, 0xF6, 0x88, 0x40, 0x02, 0xF0, 0x10, 0x6D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x04, 0x95, 0x11, 0xF6, 0x80, 0x40, 0x02, 0xF0,
+0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x04, 0x95, 0x11, 0xF6,
+0x84, 0x40, 0x02, 0xF0, 0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x04, 0x95, 0x11, 0xF6, 0x88, 0x40, 0x02, 0xF0, 0x10, 0x4D, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x04, 0x95, 0x11, 0xF6, 0x8C, 0x40, 0x02, 0xF0,
+0x10, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x00, 0xF3, 0x27, 0xC3,
+0x05, 0x92, 0x08, 0x97, 0x07, 0x91, 0x63, 0xF3, 0x00, 0x4A, 0x05, 0xD2,
+0x05, 0x93, 0x06, 0x90, 0x01, 0x6A, 0x00, 0xF3, 0x44, 0xC3, 0x00, 0xEF,
+0x05, 0x63, 0x00, 0x00, 0xFC, 0x63, 0x05, 0xD1, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0x06, 0x62, 0x04, 0xD0, 0x63, 0xF3, 0x00, 0x49,
+0x00, 0xF3, 0xCC, 0x99, 0x02, 0xF0, 0x00, 0x68, 0x00, 0x30, 0xAF, 0x40,
+0x00, 0x1C, 0x83, 0x45, 0x15, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x00, 0xF3, 0xD0, 0x99, 0x1A, 0x6C, 0x00, 0x1C, 0x83, 0x45, 0xAF, 0x40,
+0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0xF3, 0x44, 0xA1, 0x0E, 0x2A,
+0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x01, 0xF6,
+0x00, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0x6C, 0x99,
+0x6E, 0xEA, 0x36, 0x22, 0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8, 0xE0, 0xF2,
+0xA8, 0x99, 0x00, 0x30, 0x00, 0x30, 0x01, 0xF6, 0x88, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xAC, 0x99, 0x01, 0xF6, 0x80, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xB0, 0x99, 0x01, 0xF6,
+0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xB4, 0x99,
+0x11, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2,
+0xB8, 0x99, 0x11, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0xE0, 0xF2, 0xBC, 0x99, 0x11, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x00, 0xF3, 0xA0, 0x99, 0x11, 0xF6, 0x8C, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x06, 0x97, 0x05, 0x91, 0x04, 0x90, 0x63, 0xF3, 0x00, 0x4A, 0x00, 0x6B,
+0x00, 0xF3, 0x64, 0xC2, 0x02, 0x6B, 0x00, 0xF3, 0x67, 0xC2, 0x00, 0xEF,
+0x04, 0x63, 0x00, 0x00, 0xFC, 0x63, 0x05, 0xD1, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0x06, 0x62, 0x04, 0xD0, 0x63, 0xF3, 0x00, 0x49,
+0x00, 0xF3, 0xCC, 0x99, 0x02, 0xF0, 0x00, 0x68, 0x00, 0x30, 0xAF, 0x40,
+0x00, 0x1C, 0x83, 0x45, 0x15, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x00, 0xF3, 0xD0, 0x99, 0x1A, 0x6C, 0x00, 0x1C, 0x83, 0x45, 0xAF, 0x40,
+0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0xF3, 0x44, 0xA1, 0x03, 0x72,
+0x5B, 0x60, 0xE0, 0xF2, 0xAC, 0x99, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA,
+0x40, 0x30, 0x00, 0x30, 0x01, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xE0, 0xF2, 0xB0, 0x99, 0x01, 0xF6, 0x84, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xB4, 0x99, 0x11, 0xF6, 0x80, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xB8, 0x99, 0x11, 0xF6,
+0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0xBC, 0x99,
+0x11, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0xF3,
+0xA0, 0x99, 0x11, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x00, 0xF3, 0x48, 0x99, 0xE0, 0xF2, 0x68, 0x99, 0x55, 0xE3, 0x1F, 0xF7,
+0x00, 0x6A, 0xAC, 0xEA, 0x07, 0xF7, 0x01, 0x5A, 0x16, 0x60, 0x01, 0xF6,
+0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0x06, 0x97, 0x05, 0x91, 0x04, 0x90, 0x63, 0xF3,
+0x00, 0x4A, 0x03, 0x6B, 0x00, 0xF3, 0x64, 0xC2, 0x02, 0x6B, 0x00, 0xF3,
+0x67, 0xC2, 0x00, 0xEF, 0x04, 0x63, 0xFF, 0x6A, 0x01, 0x4A, 0x4B, 0xEA,
+0x40, 0x32, 0xE0, 0xF0, 0x1F, 0x4A, 0x4C, 0xED, 0x07, 0xF7, 0x00, 0x6A,
+0x4D, 0xED, 0xDF, 0x17, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34,
+0x80, 0x34, 0x01, 0xF6, 0x00, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0xE0, 0xF2, 0xAC, 0x99, 0xAA, 0xEA, 0x99, 0x61, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0x06, 0x97, 0x05, 0x91, 0x04, 0x90, 0x63, 0xF3,
+0x00, 0x4A, 0x03, 0x6B, 0x00, 0xF3, 0x64, 0xC2, 0x02, 0x6B, 0x00, 0xF3,
+0x67, 0xC2, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x00, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x40, 0x9B, 0x10, 0x6B, 0xFB, 0x63,
+0x6D, 0xEA, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x40, 0xDB, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x07, 0xD1, 0x40, 0x31,
+0x20, 0x31, 0x51, 0xF4, 0x80, 0x41, 0x08, 0x62, 0x00, 0x1C, 0x00, 0x5C,
+0x06, 0xD0, 0x00, 0xF6, 0x40, 0x32, 0x00, 0xF6, 0x43, 0x32, 0x51, 0xF4,
+0x80, 0x41, 0x1A, 0x6D, 0x00, 0x1C, 0xF0, 0x5B, 0x04, 0xD2, 0xF1, 0xF0,
+0x88, 0x41, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65, 0x04, 0x93, 0x00, 0xF6,
+0x40, 0x32, 0x00, 0xF6, 0x43, 0x32, 0x49, 0xE3, 0x08, 0x42, 0x9A, 0x48,
+0xBF, 0xF7, 0x1B, 0x50, 0x09, 0x61, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x43, 0xAB, 0x01, 0x4A, 0x43, 0xCB,
+0x04, 0x95, 0xFF, 0x6A, 0x51, 0xF4, 0x80, 0x41, 0x00, 0x1C, 0xF0, 0x5B,
+0x4C, 0xED, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x40, 0x9B, 0x11, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x40, 0xDB, 0x0B, 0xED, 0xFF, 0x6A,
+0x91, 0xF4, 0x82, 0x41, 0x00, 0x1C, 0xF0, 0x5B, 0x4C, 0xED, 0x08, 0x97,
+0x07, 0x91, 0x06, 0x90, 0x00, 0x6A, 0x00, 0xEF, 0x05, 0x63, 0x00, 0x00,
+0xF9, 0x63, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0x0C, 0x62, 0x0B, 0xD1, 0x0A, 0xD0, 0x66, 0xF7, 0x4C, 0x9B,
+0x52, 0x32, 0x05, 0xD2, 0x05, 0x94, 0x7F, 0x6A, 0x4C, 0xEC, 0x05, 0xD4,
+0x00, 0xF3, 0x44, 0xA3, 0x06, 0xD2, 0x40, 0x9B, 0x84, 0x6B, 0x6C, 0xEA,
+0x80, 0x72, 0x2A, 0x61, 0x06, 0x93, 0x01, 0x73, 0x02, 0x60, 0x04, 0x73,
+0x1B, 0x61, 0x02, 0xF0, 0x00, 0x68, 0x00, 0xF2, 0x00, 0x6E, 0x00, 0x30,
+0xC0, 0x36, 0xAF, 0x40, 0xF3, 0xF0, 0x14, 0x4E, 0x00, 0x1C, 0x83, 0x45,
+0x15, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0xFF, 0x6E, 0x01, 0x4E,
+0xC0, 0x36, 0x1A, 0x6C, 0x46, 0xF0, 0x16, 0x4E, 0x00, 0x1C, 0x83, 0x45,
+0xAF, 0x40, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x01, 0x6A, 0x4B, 0xEA,
+0x00, 0xF3, 0x44, 0xC3, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x30,
+0x00, 0x30, 0x40, 0xF0, 0x6C, 0xA0, 0x03, 0x6A, 0x6C, 0xEA, 0x0A, 0x22,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x63, 0xF3, 0x40, 0x9C,
+0x01, 0x6B, 0x5E, 0x32, 0x6C, 0xEA, 0x7C, 0x22, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x63, 0xF3, 0x00, 0x4C, 0x00, 0xF3, 0x44, 0x9C,
+0xFF, 0xF7, 0x1F, 0x6B, 0x42, 0x32, 0x6C, 0xEA, 0x16, 0x2A, 0xC9, 0xF7,
+0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x80, 0xF1, 0x04, 0x4A,
+0x40, 0x9A, 0x0D, 0x72, 0x58, 0x61, 0x46, 0x6A, 0x00, 0xF3, 0x5C, 0xC4,
+0x41, 0x6A, 0x00, 0xF3, 0x5D, 0xC4, 0x40, 0x6A, 0x00, 0xF3, 0x5E, 0xC4,
+0x3B, 0x6A, 0x00, 0xF3, 0x5F, 0xC4, 0x10, 0xF0, 0x02, 0x69, 0x00, 0xF4,
+0x20, 0x31, 0x63, 0xF3, 0x00, 0x49, 0xE4, 0xF4, 0xB8, 0x99, 0xC9, 0xF7,
+0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x30, 0xFF, 0x6E, 0xB2, 0x35, 0x00, 0x30,
+0xCC, 0xED, 0x61, 0xF4, 0x80, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x08, 0xD6,
+0x60, 0x99, 0x84, 0x6A, 0x08, 0x96, 0x6C, 0xEA, 0x84, 0x72, 0x2B, 0x61,
+0xE4, 0xF4, 0x58, 0x99, 0xFF, 0xF7, 0x1F, 0x72, 0x26, 0x60, 0x76, 0x32,
+0x01, 0x6B, 0x6C, 0xEA, 0x22, 0x22, 0x40, 0xF0, 0x4C, 0xA0, 0x03, 0x6B,
+0xCC, 0xEA, 0x6C, 0xEA, 0x1C, 0x22, 0x06, 0x92, 0x6A, 0xEA, 0xA0, 0xF0,
+0x13, 0x60, 0x04, 0x52, 0xA0, 0xF0, 0x1B, 0x60, 0xC0, 0xF0, 0x18, 0x22,
+0x01, 0x72, 0x11, 0x61, 0x00, 0xF3, 0x5C, 0xA1, 0x05, 0x93, 0xCC, 0xEA,
+0x43, 0xEB, 0xC0, 0xF0, 0x0B, 0x60, 0x00, 0xF3, 0x5F, 0xA1, 0x05, 0x94,
+0xCC, 0xEA, 0x83, 0xEA, 0xA0, 0xF0, 0x1A, 0x61, 0x00, 0x18, 0x96, 0x29,
+0x00, 0x65, 0x0C, 0x97, 0x0B, 0x91, 0x0A, 0x90, 0x00, 0x6A, 0x00, 0xEF,
+0x07, 0x63, 0x4A, 0x6A, 0x00, 0xF3, 0x5C, 0xC4, 0x45, 0x6A, 0x00, 0xF3,
+0x5D, 0xC4, 0x46, 0x6A, 0x00, 0xF3, 0x5E, 0xC4, 0x40, 0x6A, 0x00, 0xF3,
+0x5F, 0xC4, 0xA7, 0x17, 0x01, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x0E, 0x2A, 0x11, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x27, 0xF7, 0x1F, 0x6B, 0x60, 0x33, 0x60, 0x33, 0x27, 0xF7,
+0x1F, 0x4B, 0x6E, 0xEA, 0x7F, 0xF7, 0x10, 0x22, 0x9D, 0x67, 0x00, 0x1C,
+0x8A, 0x40, 0x10, 0x4C, 0x10, 0xF0, 0x02, 0x69, 0x00, 0xF4, 0x20, 0x31,
+0x01, 0xF6, 0x88, 0x40, 0x63, 0xF3, 0x00, 0x49, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0xE0, 0xF2, 0x48, 0xD9, 0x01, 0xF6, 0x80, 0x40, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0x4C, 0xD9, 0x01, 0xF6, 0x84, 0x40,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0x50, 0xD9, 0x11, 0xF6,
+0x80, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF2, 0x54, 0xD9,
+0x11, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF2,
+0x58, 0xD9, 0x11, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0xE0, 0xF2, 0x5C, 0xD9, 0x11, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x65, 0x00, 0xF3, 0x40, 0xD9, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0xCB, 0xF4, 0x46, 0xA2, 0xFF, 0x6B, 0x6C, 0xEA, 0x22, 0x72,
+0x02, 0x60, 0x92, 0x72, 0x1A, 0x61, 0x01, 0xF0, 0x8D, 0x40, 0x00, 0x1C,
+0x00, 0x5C, 0x00, 0x65, 0x0F, 0x6B, 0x4C, 0xEB, 0x0F, 0x6A, 0x6E, 0xEA,
+0xFF, 0x6C, 0x8C, 0xEA, 0x08, 0x5B, 0xA1, 0x42, 0x0C, 0x61, 0xA0, 0x34,
+0x80, 0x33, 0x00, 0xF6, 0xA0, 0x32, 0x6D, 0xEA, 0x8D, 0xEA, 0xAD, 0xEA,
+0xAD, 0xEC, 0x00, 0xF3, 0x54, 0xD9, 0x00, 0xF3, 0x98, 0xD9, 0x9D, 0x67,
+0x00, 0x1C, 0x90, 0x40, 0x10, 0x4C, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x40, 0x9B, 0x80, 0x6B, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x6D, 0xEA, 0x63, 0xF3, 0x40, 0xDC, 0xFC, 0x16,
+0x20, 0xF3, 0x40, 0xA1, 0x05, 0x93, 0xCC, 0xEA, 0x43, 0xEB, 0x5F, 0xF7,
+0x1B, 0x60, 0x00, 0x18, 0xD2, 0x29, 0x00, 0x65, 0x5A, 0x17, 0x06, 0x93,
+0x04, 0x73, 0x12, 0x60, 0xFF, 0x73, 0x5F, 0xF7, 0x14, 0x61, 0x00, 0xF3,
+0x5E, 0xA1, 0x05, 0x94, 0xCC, 0xEA, 0x43, 0xEC, 0x24, 0x61, 0x00, 0xF3,
+0x5C, 0xA1, 0xCC, 0xEA, 0x43, 0xEC, 0x0A, 0x60, 0x00, 0x18, 0x1E, 0x29,
+0x00, 0x65, 0x45, 0x17, 0x00, 0xF3, 0x5D, 0xA1, 0x05, 0x94, 0xCC, 0xEA,
+0x83, 0xEA, 0xF6, 0x60, 0x00, 0x18, 0x9B, 0x28, 0x00, 0x65, 0x3B, 0x17,
+0x00, 0xF3, 0x5E, 0xA1, 0x05, 0x93, 0xCC, 0xEA, 0x43, 0xEB, 0xEC, 0x60,
+0x20, 0xF3, 0x41, 0xA1, 0x05, 0x94, 0xCC, 0xEA, 0x83, 0xEA, 0x3F, 0xF7,
+0x0B, 0x61, 0x00, 0x18, 0xD2, 0x29, 0x00, 0x65, 0x2A, 0x17, 0x20, 0xF3,
+0x41, 0xA1, 0x05, 0x93, 0xCC, 0xEA, 0x63, 0xEA, 0xF6, 0x60, 0x20, 0x17,
+0xFB, 0x63, 0x10, 0xF0, 0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x07, 0xD1,
+0x26, 0x67, 0x06, 0xD0, 0x08, 0x62, 0x63, 0xF3, 0x00, 0x49, 0x66, 0xF7,
+0x8C, 0x99, 0x7F, 0x6A, 0x92, 0x30, 0x4C, 0xE8, 0xE0, 0xF2, 0x46, 0xA1,
+0x0F, 0x2A, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x35, 0xA0, 0x35,
+0x40, 0xF0, 0x4C, 0xA5, 0xFF, 0x6B, 0x6C, 0xEA, 0x03, 0x6B, 0x6C, 0xEA,
+0x03, 0x22, 0xFF, 0xF7, 0x1F, 0x74, 0x06, 0x61, 0x08, 0x97, 0x07, 0x91,
+0x06, 0x90, 0x00, 0x6A, 0x00, 0xEF, 0x05, 0x63, 0x01, 0xF0, 0x80, 0x45,
+0x04, 0xD5, 0x00, 0x1C, 0x00, 0x5C, 0x05, 0xD6, 0x01, 0x6B, 0x6C, 0xEA,
+0x04, 0x95, 0x05, 0x96, 0x2C, 0x22, 0x4B, 0x58, 0x06, 0x61, 0xC0, 0xF2,
+0x53, 0xA1, 0xFF, 0x6C, 0x8C, 0xEA, 0x6A, 0xEA, 0x74, 0x61, 0x48, 0x40,
+0xE0, 0x4A, 0xFF, 0x6B, 0x6C, 0xEA, 0x1E, 0x5A, 0x07, 0x60, 0x86, 0x67,
+0x63, 0xF3, 0x00, 0x4C, 0xC0, 0xF2, 0x53, 0xA4, 0x6C, 0xEA, 0x43, 0x2A,
+0x23, 0x58, 0xD8, 0x60, 0x66, 0x67, 0x63, 0xF3, 0x00, 0x4B, 0xC0, 0xF2,
+0x53, 0xA3, 0x02, 0x72, 0xD1, 0x60, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC,
+0x80, 0x34, 0x02, 0x6A, 0x80, 0x34, 0xC0, 0xF2, 0x53, 0xC3, 0x81, 0xF4,
+0x07, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x6D, 0xC3, 0x17, 0x4B, 0x58,
+0x06, 0x61, 0xC0, 0xF2, 0x53, 0xA1, 0xFF, 0x6C, 0x8C, 0xEA, 0x01, 0x72,
+0x40, 0x61, 0x48, 0x40, 0xE0, 0x4A, 0xFF, 0x6B, 0x6C, 0xEA, 0x1E, 0x5A,
+0x07, 0x60, 0x86, 0x67, 0x63, 0xF3, 0x00, 0x4C, 0xC0, 0xF2, 0x53, 0xA4,
+0x6C, 0xEA, 0x25, 0x2A, 0x23, 0x58, 0xAC, 0x60, 0x66, 0x67, 0x63, 0xF3,
+0x00, 0x4B, 0xC0, 0xF2, 0x53, 0xA3, 0x02, 0x72, 0xA5, 0x60, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x02, 0x6A, 0x80, 0x34, 0xC0, 0xF2,
+0x53, 0xC3, 0x21, 0xF4, 0x10, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x42, 0x6D,
+0x97, 0x17, 0x00, 0x6A, 0xC0, 0xF2, 0x53, 0xC4, 0xC9, 0xF7, 0x1B, 0x6C,
+0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x81, 0xF4, 0x07, 0x4C, 0x00, 0x1C,
+0xF0, 0x5B, 0x20, 0x6D, 0x89, 0x17, 0x00, 0x6A, 0xC0, 0xF2, 0x53, 0xC4,
+0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x21, 0xF4,
+0x10, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x44, 0x6D, 0x7B, 0x17, 0x31, 0xF4,
+0x80, 0x45, 0xC0, 0xF2, 0x73, 0xC1, 0x00, 0x1C, 0xF0, 0x5B, 0x43, 0x6D,
+0x73, 0x17, 0x81, 0xF4, 0x87, 0x45, 0xC0, 0xF2, 0x73, 0xC1, 0x00, 0x1C,
+0xF0, 0x5B, 0x10, 0x6D, 0x6B, 0x17, 0x00, 0x65, 0xE8, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xBF, 0xAF, 0x24, 0x63, 0x00, 0x0C, 0x21, 0x38, 0x00, 0x00,
+0x10, 0x00, 0xBF, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0x01, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x10, 0x3C, 0x14, 0xAE, 0x42, 0x24,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x03, 0x11, 0x36, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x22, 0xAE, 0x20, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x30, 0x03, 0x10, 0x36, 0x20, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x05, 0x3C,
+0x00, 0x00, 0x02, 0xAE, 0x01, 0x80, 0x02, 0x3C, 0x15, 0xAE, 0x44, 0x24,
+0x33, 0x03, 0xA3, 0x34, 0x00, 0x00, 0x24, 0xAE, 0x00, 0x00, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x42, 0x30, 0xFB, 0xFF, 0x40, 0x10,
+0x30, 0x03, 0xA2, 0x34, 0x00, 0x00, 0x46, 0x8C, 0x0F, 0x00, 0x03, 0x3C,
+0xFF, 0xFF, 0x63, 0x34, 0x24, 0x30, 0xC3, 0x00, 0x40, 0x11, 0x06, 0x00,
+0x23, 0x10, 0x46, 0x00, 0x80, 0x10, 0x02, 0x00, 0x21, 0x10, 0x46, 0x00,
+0xAF, 0x0F, 0x05, 0x3C, 0xC0, 0x10, 0x02, 0x00, 0x00, 0xA0, 0xA5, 0x34,
+0x1B, 0x00, 0xA2, 0x00, 0x02, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x63, 0x24,
+0xC2, 0x30, 0x06, 0x00, 0x10, 0x00, 0xA4, 0x27, 0x54, 0x41, 0x66, 0xAC,
+0x12, 0x28, 0x00, 0x00, 0x90, 0x40, 0x00, 0x0C, 0x58, 0x41, 0x65, 0xAC,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27, 0xC0, 0xFF, 0xBD, 0x27,
+0x2C, 0x00, 0xB5, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x21, 0xA8, 0x80, 0x00,
+0x02, 0x80, 0x12, 0x3C, 0x10, 0x00, 0xA4, 0x27, 0x38, 0x00, 0xBE, 0xAF,
+0x30, 0x00, 0xB6, 0xAF, 0x3C, 0x00, 0xBF, 0xAF, 0x34, 0x00, 0xB7, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x44, 0x00, 0xA5, 0xAF,
+0xEC, 0x5D, 0x42, 0x92, 0x21, 0xF0, 0x00, 0x00, 0xC5, 0x00, 0x40, 0x10,
+0x21, 0xB0, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x43, 0x24,
+0xB0, 0x1B, 0x62, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30,
+0xBE, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x3E, 0x62, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0xBA, 0x00, 0x40, 0x14, 0x02, 0x80, 0x17, 0x3C,
+0x0E, 0x5E, 0xE2, 0x92, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x0E, 0x5E, 0xE2, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xFF, 0x42, 0x24, 0x0E, 0x5E, 0xE2, 0xA2, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xF2, 0x5D, 0x40, 0xA0, 0x14, 0x5E, 0x60, 0xAC,
+0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x62, 0x90, 0xFD, 0xFF, 0x03, 0x24,
+0x42, 0xB0, 0x13, 0x3C, 0x24, 0x10, 0x43, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x07, 0x5E, 0x62, 0xA0, 0x00, 0x00, 0x63, 0x92, 0xEF, 0xFF, 0x02, 0x24,
+0x03, 0x00, 0x64, 0x36, 0x24, 0x18, 0x62, 0x00, 0x40, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x63, 0xA2, 0x00, 0x00, 0x82, 0xA0, 0x02, 0x80, 0x04, 0x3C,
+0xF4, 0x5D, 0x82, 0x94, 0x20, 0x00, 0xA3, 0x96, 0xFF, 0xFF, 0x42, 0x30,
+0x0A, 0x00, 0x43, 0x10, 0x02, 0x80, 0x14, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x94, 0x00, 0x42, 0x34, 0xF4, 0x5D, 0x83, 0xA4, 0x00, 0x00, 0x43, 0xA4,
+0xF4, 0x5D, 0x83, 0x94, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x63, 0x30,
+0x80, 0x1A, 0x03, 0x00, 0xF8, 0x5D, 0x83, 0xAE, 0x25, 0xB0, 0x04, 0x3C,
+0x84, 0x00, 0x82, 0x34, 0x00, 0x00, 0x50, 0x8C, 0x80, 0x00, 0x84, 0x34,
+0x00, 0x00, 0x82, 0x8C, 0x21, 0x18, 0x00, 0x00, 0xF8, 0x5D, 0x86, 0x8E,
+0x00, 0x88, 0x10, 0x00, 0x21, 0x80, 0x00, 0x00, 0x25, 0x80, 0x02, 0x02,
+0x25, 0x88, 0x23, 0x02, 0x21, 0x20, 0x00, 0x02, 0x7D, 0x2B, 0x00, 0x0C,
+0x21, 0x28, 0x20, 0x02, 0xF8, 0x5D, 0x88, 0x8E, 0x02, 0x80, 0x0A, 0x3C,
+0xFC, 0x5D, 0x43, 0x95, 0x23, 0x48, 0x02, 0x01, 0x21, 0x20, 0x30, 0x01,
+0x21, 0x28, 0x00, 0x00, 0x2B, 0x10, 0x90, 0x00, 0xFF, 0xFF, 0x63, 0x30,
+0x21, 0x28, 0xB1, 0x00, 0x80, 0x1A, 0x03, 0x00, 0x21, 0x28, 0xA2, 0x00,
+0x21, 0x38, 0x00, 0x00, 0x2B, 0x40, 0x83, 0x00, 0x23, 0x28, 0xA7, 0x00,
+0x23, 0x20, 0x83, 0x00, 0x23, 0x28, 0xA8, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x18, 0x5E, 0x64, 0xAC, 0x1C, 0x5E, 0x65, 0xAC, 0xFC, 0x5D, 0x42, 0x95,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x42, 0x30, 0x80, 0x12, 0x02, 0x00,
+0x2B, 0x10, 0x49, 0x00, 0x97, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xFC, 0x5D, 0x42, 0x95, 0x00, 0x00, 0x64, 0x92, 0xFB, 0xFF, 0x03, 0x24,
+0xFF, 0xFF, 0x42, 0x30, 0x80, 0x12, 0x02, 0x00, 0x24, 0x20, 0x83, 0x00,
+0x23, 0x48, 0x22, 0x01, 0x00, 0x00, 0x64, 0xA2, 0x01, 0x00, 0x06, 0x24,
+0x04, 0x00, 0x20, 0x11, 0x01, 0x00, 0x04, 0x24, 0x80, 0x10, 0x09, 0x00,
+0x21, 0x10, 0x49, 0x00, 0x80, 0x30, 0x02, 0x00, 0xB9, 0x20, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x00, 0x42, 0xB0, 0x02, 0x3C, 0x22, 0x00, 0x03, 0x24,
+0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0, 0x44, 0x00, 0xA2, 0x8F,
+0x05, 0x00, 0x05, 0x24, 0x24, 0x00, 0xA4, 0x26, 0x00, 0x00, 0x47, 0x8C,
+0x14, 0x00, 0xA6, 0x27, 0xFF, 0x3F, 0xE7, 0x30, 0xAB, 0x1A, 0x00, 0x0C,
+0xDC, 0xFF, 0xE7, 0x24, 0x2C, 0x00, 0x40, 0x10, 0x21, 0x28, 0x40, 0x00,
+0xEC, 0x5D, 0x42, 0x92, 0x02, 0x00, 0x03, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x83, 0x00, 0x43, 0x10, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x00, 0xA2, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0xA3, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x62, 0x30,
+0x04, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x01, 0x00, 0x16, 0x24,
+0x0B, 0x5E, 0x56, 0xA0, 0x04, 0x00, 0xA3, 0x90, 0x14, 0x00, 0xA7, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0xE2, 0x28, 0x16, 0x00, 0x40, 0x14,
+0xFE, 0x00, 0x66, 0x30, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x43, 0x24,
+0x4C, 0x3A, 0x64, 0x94, 0xC0, 0x10, 0x06, 0x00, 0x2A, 0x10, 0x82, 0x00,
+0x10, 0x00, 0x40, 0x14, 0x02, 0x80, 0x03, 0x3C, 0x21, 0x10, 0xC7, 0x00,
+0xFD, 0xFF, 0x42, 0x24, 0xC0, 0x10, 0x02, 0x00, 0x2A, 0x10, 0x44, 0x00,
+0x0A, 0x00, 0x40, 0x14, 0xC2, 0x10, 0x04, 0x00, 0x23, 0x30, 0x46, 0x00,
+0x21, 0x18, 0xA6, 0x00, 0x05, 0x00, 0x62, 0x90, 0x07, 0x00, 0x84, 0x30,
+0x01, 0x00, 0x03, 0x24, 0x07, 0x10, 0x82, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x0B, 0xF0, 0x62, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x62, 0x90,
+0xEF, 0xFF, 0x03, 0x24, 0x21, 0x20, 0xC0, 0x02, 0x24, 0x10, 0x43, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x62, 0xA0, 0xEC, 0x5D, 0x43, 0x92,
+0x02, 0x80, 0x02, 0x3C, 0xE0, 0xE4, 0x42, 0x24, 0xFF, 0x00, 0x63, 0x30,
+0x80, 0x18, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x00, 0x00, 0x66, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x09, 0xF8, 0xC0, 0x00, 0x21, 0x28, 0xC0, 0x03,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x3C, 0x00, 0xBF, 0x8F,
+0x38, 0x00, 0xBE, 0x8F, 0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x40, 0x00, 0xBD, 0x27, 0xEC, 0x5D, 0x42, 0x92,
+0x00, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x03, 0x3C,
+0x60, 0x1B, 0x70, 0x24, 0xB0, 0x1B, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x42, 0x30, 0xE9, 0xFF, 0x40, 0x10, 0x05, 0x00, 0x05, 0x24,
+0x44, 0x00, 0xA2, 0x8F, 0x24, 0x00, 0xA4, 0x26, 0x00, 0x00, 0x47, 0x8C,
+0x14, 0x00, 0xA6, 0x27, 0xFF, 0x3F, 0xE7, 0x30, 0xAB, 0x1A, 0x00, 0x0C,
+0xDC, 0xFF, 0xE7, 0x24, 0xE0, 0xFF, 0x40, 0x10, 0x21, 0x28, 0x40, 0x00,
+0x14, 0x00, 0xA7, 0x8F, 0x04, 0x00, 0x42, 0x90, 0x04, 0x00, 0xE3, 0x28,
+0xDB, 0xFF, 0x60, 0x14, 0xFE, 0x00, 0x46, 0x30, 0x4C, 0x3A, 0x04, 0x96,
+0xC0, 0x10, 0x06, 0x00, 0x2A, 0x10, 0x82, 0x00, 0xD6, 0xFF, 0x40, 0x14,
+0x21, 0x10, 0xC7, 0x00, 0xFD, 0xFF, 0x42, 0x24, 0xC0, 0x10, 0x02, 0x00,
+0x2A, 0x10, 0x44, 0x00, 0xD1, 0xFF, 0x40, 0x14, 0xC2, 0x10, 0x04, 0x00,
+0x23, 0x30, 0x46, 0x00, 0x21, 0x18, 0xA6, 0x00, 0x05, 0x00, 0x62, 0x90,
+0x07, 0x00, 0x84, 0x30, 0x07, 0x10, 0x82, 0x00, 0x01, 0x00, 0x42, 0x30,
+0xC9, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x51, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x00, 0x83, 0x2C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x0E, 0x5E, 0xE2, 0x92, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x5E, 0xE2, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x42, 0x24, 0x0E, 0x5E, 0xE2, 0xA2, 0x00, 0x00, 0x62, 0x92,
+0xFB, 0xFF, 0x03, 0x24, 0x01, 0x00, 0x06, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x62, 0xA2, 0x32, 0x2C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x03, 0x00, 0xA2, 0x90, 0x02, 0x80, 0x07, 0x3C, 0x09, 0x5E, 0xE2, 0xA0,
+0x02, 0x00, 0xA3, 0x90, 0x21, 0x30, 0x80, 0x00, 0x0A, 0x5E, 0x83, 0xA0,
+0x0A, 0x5E, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x09, 0x5E, 0xE2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x5E, 0xC2, 0xA0, 0x4C, 0x2C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x5E, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x5E, 0xC2, 0xA0,
+0x4C, 0x2C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x0D, 0x5E, 0x43, 0xA0, 0xD0, 0x07, 0x04, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0xDC, 0x5D, 0x44, 0xAC,
+0x0C, 0x5E, 0x60, 0xA0, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x04, 0x00, 0x82, 0x8C, 0x02, 0x00, 0x03, 0x24,
+0x21, 0x80, 0x80, 0x00, 0x02, 0x17, 0x02, 0x00, 0x03, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x43, 0x10, 0x02, 0x80, 0x11, 0x3C, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xEC, 0x5D, 0x22, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xF8, 0xFF, 0x40, 0x10, 0x10, 0x00, 0xA4, 0x27, 0x8A, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xEC, 0x5D, 0x23, 0x92, 0x02, 0x80, 0x02, 0x3C,
+0xB4, 0xE4, 0x42, 0x24, 0xFF, 0x00, 0x63, 0x30, 0x80, 0x18, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x00, 0x00, 0x66, 0x8C, 0x00, 0x00, 0x04, 0x8E,
+0x04, 0x00, 0x05, 0x8E, 0x09, 0xF8, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90, 0x0C, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x63, 0x30, 0x05, 0x00, 0x62, 0x10, 0x10, 0x00, 0xA4, 0x27,
+0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x2C, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x06, 0x5E, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0x60, 0x10, 0x02, 0x80, 0x05, 0x3C,
+0x0C, 0x5E, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24,
+0x0C, 0x5E, 0xA2, 0xA0, 0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xF7, 0x2C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x04, 0x3C,
+0x28, 0x00, 0x85, 0x34, 0x02, 0x00, 0x82, 0x94, 0x04, 0x00, 0x84, 0x24,
+0x05, 0x00, 0x40, 0x14, 0x2B, 0x18, 0xA4, 0x00, 0xFB, 0xFF, 0x60, 0x10,
+0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x25, 0xB0, 0x03, 0x3C,
+0xBE, 0x00, 0x63, 0x34, 0x00, 0x00, 0x62, 0x94, 0x08, 0x00, 0xE0, 0x03,
+0x01, 0x00, 0x42, 0x2C, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x24, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x19, 0x00, 0x40, 0x10, 0x98, 0x54, 0x64, 0x24, 0x98, 0x54, 0x62, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x44, 0x14, 0x02, 0x80, 0x02, 0x3C,
+0x0D, 0x5E, 0x43, 0x90, 0x01, 0x00, 0x02, 0x24, 0xFF, 0x00, 0x63, 0x30,
+0x10, 0x00, 0x62, 0x10, 0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x05, 0x00, 0x42, 0x28,
+0x0A, 0x00, 0x40, 0x10, 0x01, 0x00, 0x04, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x64, 0x59, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x60, 0x14,
+0x21, 0x10, 0x80, 0x00, 0x10, 0x00, 0xBF, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0x8F,
+0x21, 0x20, 0x00, 0x00, 0x21, 0x10, 0x80, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x24, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x98, 0x54, 0x43, 0x8C, 0x98, 0x54, 0x42, 0x24,
+0x28, 0x00, 0x62, 0x14, 0x02, 0x80, 0x03, 0x3C, 0x05, 0x5E, 0x62, 0x90,
+0x01, 0x00, 0x04, 0x24, 0xFF, 0x00, 0x42, 0x30, 0x23, 0x00, 0x44, 0x10,
+0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0x03, 0x00, 0x42, 0x28, 0x1D, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x42, 0x30, 0x18, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x42, 0x30,
+0x13, 0x00, 0x40, 0x14, 0x02, 0x80, 0x03, 0x3C, 0x0D, 0x5E, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x42, 0x30, 0x0E, 0x00, 0x44, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x0E, 0x5E, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x60, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0x04, 0x3E, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x60, 0x14,
+0x21, 0x18, 0x00, 0x00, 0x3C, 0x3A, 0x42, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x40, 0x14, 0x01, 0x00, 0x03, 0x24, 0x21, 0x18, 0x00, 0x00,
+0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x30, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x0E, 0x00, 0x40, 0x10, 0x90, 0x54, 0x65, 0x24, 0x90, 0x54, 0x62, 0x8C,
+0x02, 0x80, 0x04, 0x3C, 0x88, 0x54, 0x86, 0x24, 0x09, 0x00, 0x45, 0x14,
+0x01, 0x00, 0x03, 0x24, 0x88, 0x54, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x05, 0x00, 0x46, 0x14, 0x21, 0x10, 0x60, 0x00, 0x10, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0x10, 0x00, 0xBF, 0x8F, 0x21, 0x18, 0x00, 0x00, 0x21, 0x10, 0x60, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0xFF, 0x00, 0x90, 0x30, 0x10, 0x00, 0xA4, 0x27,
+0x20, 0x00, 0xB2, 0xAF, 0x24, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x02, 0x80, 0x12, 0x3C, 0x0F, 0x00, 0x00, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x3C, 0x5E, 0x43, 0x92, 0x01, 0x00, 0x02, 0x24,
+0x04, 0x0C, 0x04, 0x24, 0xFF, 0x00, 0x63, 0x30, 0x2A, 0x00, 0x62, 0x10,
+0x80, 0x01, 0x10, 0x3C, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x3C, 0x5E, 0x43, 0x92, 0x02, 0x00, 0x02, 0x24, 0x21, 0x28, 0x00, 0x00,
+0xFF, 0x00, 0x63, 0x30, 0xF3, 0xFF, 0x62, 0x14, 0x44, 0x08, 0x04, 0x24,
+0x03, 0x5C, 0x00, 0x0C, 0x7F, 0xFE, 0x10, 0x3C, 0x30, 0x5C, 0x00, 0x0C,
+0x04, 0x0C, 0x04, 0x24, 0xFD, 0x00, 0x45, 0x30, 0x1A, 0x5C, 0x00, 0x0C,
+0x04, 0x0C, 0x04, 0x24, 0x30, 0x5C, 0x00, 0x0C, 0x04, 0x0D, 0x04, 0x24,
+0xFD, 0x00, 0x45, 0x30, 0x1A, 0x5C, 0x00, 0x0C, 0x04, 0x0D, 0x04, 0x24,
+0x26, 0x5C, 0x00, 0x0C, 0x70, 0x0E, 0x04, 0x24, 0xFF, 0xFF, 0x10, 0x36,
+0x24, 0x28, 0x50, 0x00, 0x03, 0x5C, 0x00, 0x0C, 0x70, 0x0E, 0x04, 0x24,
+0x26, 0x5C, 0x00, 0x0C, 0x8C, 0x0E, 0x04, 0x24, 0x24, 0x28, 0x50, 0x00,
+0x03, 0x5C, 0x00, 0x0C, 0x8C, 0x0E, 0x04, 0x24, 0x01, 0x00, 0x02, 0x24,
+0x3C, 0x5E, 0x42, 0xA2, 0xB9, 0x2D, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x30, 0x5C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x42, 0x34,
+0xFF, 0x00, 0x45, 0x30, 0x1A, 0x5C, 0x00, 0x0C, 0x04, 0x0C, 0x04, 0x24,
+0x30, 0x5C, 0x00, 0x0C, 0x04, 0x0D, 0x04, 0x24, 0x02, 0x00, 0x42, 0x34,
+0xFF, 0x00, 0x45, 0x30, 0x1A, 0x5C, 0x00, 0x0C, 0x04, 0x0D, 0x04, 0x24,
+0x26, 0x5C, 0x00, 0x0C, 0x70, 0x0E, 0x04, 0x24, 0x25, 0x28, 0x50, 0x00,
+0x03, 0x5C, 0x00, 0x0C, 0x70, 0x0E, 0x04, 0x24, 0x26, 0x5C, 0x00, 0x0C,
+0x8C, 0x0E, 0x04, 0x24, 0x25, 0x28, 0x50, 0x00, 0x03, 0x5C, 0x00, 0x0C,
+0x8C, 0x0E, 0x04, 0x24, 0x03, 0x00, 0x05, 0x3C, 0x59, 0x01, 0xA5, 0x34,
+0x03, 0x5C, 0x00, 0x0C, 0x44, 0x08, 0x04, 0x24, 0x02, 0x00, 0x02, 0x24,
+0x3C, 0x5E, 0x42, 0xA2, 0xB9, 0x2D, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x42, 0x00, 0x46, 0x34, 0xFC, 0x37, 0x03, 0x24,
+0x40, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA4, 0x03, 0x08, 0x04, 0x24,
+0x03, 0x00, 0x05, 0x24, 0x00, 0x00, 0xC0, 0xA0, 0x1A, 0x5C, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x02, 0x3C, 0xEC, 0x5D, 0x43, 0x90, 0xFC, 0x57, 0x12, 0x24,
+0x0B, 0x00, 0x60, 0x10, 0xFC, 0x77, 0x11, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0xC6, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x63, 0x30,
+0x2A, 0x00, 0x60, 0x14, 0x21, 0x20, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00,
+0x00, 0x02, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C, 0x00, 0x08, 0x04, 0x24,
+0x25, 0xB0, 0x03, 0x3C, 0x21, 0x00, 0x65, 0x34, 0x00, 0x00, 0xA2, 0x90,
+0x18, 0x00, 0x66, 0x34, 0x40, 0x00, 0x70, 0x34, 0x01, 0x00, 0x42, 0x34,
+0x42, 0x00, 0x63, 0x34, 0x00, 0x00, 0xA2, 0xA0, 0xFF, 0xFF, 0x02, 0x24,
+0x00, 0x00, 0xC0, 0xA0, 0x64, 0x00, 0x04, 0x24, 0x00, 0x00, 0x62, 0xA0,
+0x00, 0x00, 0x12, 0xA6, 0x5B, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x11, 0xA6, 0x5B, 0x1F, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x1A, 0x5C, 0x00, 0x0C, 0x03, 0x08, 0x04, 0x24,
+0x5B, 0x1F, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24, 0xFC, 0x37, 0x02, 0x24,
+0x00, 0x00, 0x02, 0xA6, 0x5B, 0x1F, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24,
+0x00, 0x00, 0x11, 0xA6, 0x5B, 0x1F, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24,
+0x00, 0x00, 0x12, 0xA6, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xA8, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x30, 0x00, 0x00, 0x00, 0x02, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C,
+0x00, 0x08, 0x04, 0x24, 0x1F, 0x2E, 0x00, 0x08, 0x25, 0xB0, 0x03, 0x3C,
+0xB8, 0xFF, 0xBD, 0x27, 0x2C, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x13, 0x3C, 0xFF, 0x00, 0x90, 0x30, 0x18, 0x00, 0xA4, 0x27,
+0x30, 0x00, 0xB4, 0xAF, 0x28, 0x00, 0xB2, 0xAF, 0x24, 0x00, 0xB1, 0xAF,
+0x40, 0x00, 0xBF, 0xAF, 0x3C, 0x00, 0xB7, 0xAF, 0x38, 0x00, 0xB6, 0xAF,
+0x34, 0x00, 0xB5, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0xFF, 0x00, 0xB2, 0x30,
+0xEE, 0x5D, 0x62, 0x92, 0x0F, 0x00, 0x11, 0x32, 0x0F, 0x00, 0x42, 0x30,
+0x13, 0x00, 0x51, 0x10, 0x21, 0xA0, 0x00, 0x00, 0x04, 0x00, 0x02, 0x32,
+0x40, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x5D, 0x62, 0x92,
+0x0C, 0x00, 0x03, 0x24, 0x0F, 0x00, 0x42, 0x30, 0x8F, 0x00, 0x43, 0x10,
+0x08, 0x00, 0x02, 0x32, 0xEE, 0x5D, 0x62, 0x92, 0x04, 0x00, 0x03, 0x24,
+0x0F, 0x00, 0x42, 0x30, 0xD2, 0x01, 0x43, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xEE, 0x5D, 0x62, 0x92, 0x02, 0x00, 0x03, 0x24, 0x0F, 0x00, 0x42, 0x30,
+0x9B, 0x00, 0x43, 0x10, 0x06, 0x00, 0x02, 0x32, 0x02, 0x80, 0x10, 0x3C,
+0xED, 0x5D, 0x03, 0x92, 0xEE, 0x5D, 0x62, 0x92, 0x0F, 0x00, 0x63, 0x30,
+0x0F, 0x00, 0x42, 0x30, 0x2A, 0x10, 0x43, 0x00, 0x1C, 0x00, 0x40, 0x14,
+0x02, 0x80, 0x12, 0x3C, 0xED, 0x5D, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x40, 0x00, 0x42, 0x30, 0x17, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0xC2, 0x5C, 0x42, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x43, 0x30,
+0x52, 0x00, 0x60, 0x14, 0x04, 0x00, 0x42, 0x30, 0x10, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xEE, 0x5D, 0x43, 0x92, 0x02, 0x80, 0x06, 0x3C,
+0x14, 0xE5, 0xC5, 0x90, 0x0F, 0x00, 0x63, 0x30, 0x25, 0xB0, 0x02, 0x3C,
+0x25, 0x18, 0x65, 0x00, 0xDD, 0x02, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0,
+0xED, 0x5D, 0x04, 0x92, 0x80, 0xFF, 0x02, 0x24, 0xBF, 0xFF, 0x03, 0x24,
+0x26, 0x28, 0xA2, 0x00, 0x24, 0x20, 0x83, 0x00, 0x14, 0xE5, 0xC5, 0xA0,
+0xED, 0x5D, 0x04, 0xA2, 0x90, 0x40, 0x00, 0x0C, 0x18, 0x00, 0xA4, 0x27,
+0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F,
+0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F,
+0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27, 0xEE, 0x5D, 0x62, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x42, 0x30, 0x4C, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xEE, 0x5D, 0x62, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x42, 0x30, 0x03, 0x00, 0x40, 0x10, 0x08, 0x00, 0x02, 0x32,
+0x1B, 0x00, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C, 0xEE, 0x5D, 0x62, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x42, 0x30, 0x0C, 0x00, 0x40, 0x14,
+0x08, 0x00, 0x02, 0x32, 0x0A, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x40, 0x12, 0x02, 0x80, 0x03, 0x3C, 0x10, 0x37, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30, 0x03, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x51, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00,
+0xEE, 0x5D, 0x62, 0x92, 0xF0, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0xEE, 0x5D, 0x62, 0xA2, 0xEE, 0x5D, 0x63, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x25, 0x18, 0x23, 0x02, 0xEE, 0x5D, 0x63, 0xA2, 0x72, 0x2E, 0x00, 0x08,
+0x02, 0x80, 0x10, 0x3C, 0x10, 0x37, 0x62, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x42, 0x30, 0xF2, 0xFF, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x0D, 0x5E, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xFF, 0x60, 0x14,
+0x01, 0x00, 0x04, 0x24, 0x0E, 0x51, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xBD, 0x2E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x53, 0x21, 0x00, 0x0C,
+0x24, 0x00, 0x04, 0x24, 0x76, 0x01, 0x40, 0x10, 0x21, 0x88, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xEC, 0x5D, 0x45, 0x90, 0xEE, 0x5D, 0x44, 0x92,
+0xED, 0x5D, 0x02, 0x92, 0xBF, 0xFF, 0x03, 0x24, 0x0F, 0x00, 0x84, 0x30,
+0x24, 0x10, 0x43, 0x00, 0xED, 0x5D, 0x02, 0xA2, 0x10, 0x00, 0xA5, 0xA3,
+0x11, 0x00, 0xA4, 0xA3, 0x08, 0x00, 0x24, 0x96, 0x02, 0x80, 0x02, 0x3C,
+0x10, 0x00, 0xA5, 0x27, 0x25, 0x20, 0x82, 0x00, 0x20, 0x00, 0x84, 0x24,
+0xC2, 0x1B, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24, 0x04, 0x00, 0x03, 0x24,
+0x17, 0x00, 0x02, 0x24, 0x0C, 0x00, 0x23, 0xAE, 0x14, 0x00, 0x22, 0xAE,
+0x17, 0x0A, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02, 0x94, 0x2E, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xA6, 0x2E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x35, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x77, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x5D, 0x62, 0x92,
+0xF0, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00, 0xEE, 0x5D, 0x62, 0xA2,
+0x02, 0x80, 0x03, 0x3C, 0xEE, 0x5D, 0x62, 0x92, 0x10, 0x37, 0x64, 0x94,
+0x04, 0x00, 0x42, 0x34, 0x00, 0x01, 0x84, 0x30, 0xEE, 0x5D, 0x62, 0xA2,
+0x61, 0xFF, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x51, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x67, 0x2E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x65, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x8F, 0x2D, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x61, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xEE, 0x5D, 0x62, 0x92, 0xF0, 0xFF, 0x03, 0x24, 0x41, 0xB0, 0x04, 0x3C,
+0x24, 0x10, 0x43, 0x00, 0xEE, 0x5D, 0x62, 0xA2, 0xEE, 0x5D, 0x63, 0x92,
+0x08, 0x00, 0x85, 0x34, 0x82, 0x00, 0x02, 0x24, 0x01, 0x00, 0x63, 0x34,
+0x02, 0x80, 0x17, 0x3C, 0xEE, 0x5D, 0x63, 0xA2, 0x00, 0x00, 0x80, 0xAC,
+0x00, 0x00, 0xA2, 0xA4, 0x42, 0xB0, 0x04, 0x3C, 0x60, 0x1B, 0xE2, 0x26,
+0xB0, 0x1B, 0x45, 0x94, 0x00, 0x00, 0x83, 0x90, 0xBE, 0xFF, 0x02, 0x24,
+0x03, 0x00, 0x86, 0x34, 0x24, 0x18, 0x62, 0x00, 0x00, 0x01, 0xA5, 0x30,
+0x90, 0xFF, 0x02, 0x24, 0x00, 0x00, 0x83, 0xA0, 0x00, 0x00, 0xC2, 0xA0,
+0x38, 0x00, 0xA0, 0x10, 0x25, 0xB0, 0x06, 0x3C, 0x25, 0xB0, 0x04, 0x3C,
+0x84, 0x00, 0x82, 0x34, 0x00, 0x00, 0x46, 0x8C, 0x80, 0x00, 0x84, 0x34,
+0x00, 0x00, 0x82, 0x8C, 0x02, 0x80, 0x0B, 0x3C, 0x14, 0x5E, 0x64, 0x8D,
+0x00, 0x38, 0x06, 0x00, 0x21, 0x30, 0x00, 0x00, 0x25, 0xA0, 0xC2, 0x00,
+0x21, 0x18, 0x00, 0x00, 0x02, 0x80, 0x0A, 0x3C, 0x25, 0xA8, 0xE3, 0x00,
+0x21, 0x28, 0x00, 0x00, 0x1C, 0x5E, 0x42, 0x8D, 0x21, 0x20, 0x94, 0x00,
+0x2B, 0x18, 0x94, 0x00, 0x21, 0x28, 0xB5, 0x00, 0x21, 0x28, 0xA3, 0x00,
+0x2B, 0x10, 0xA2, 0x00, 0x24, 0x01, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x5E, 0x42, 0x8D, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x45, 0x10,
+0x01, 0x00, 0x05, 0x24, 0x60, 0x1B, 0xE2, 0x26, 0x58, 0x41, 0x43, 0x8C,
+0x42, 0xB0, 0x07, 0x3C, 0x00, 0x00, 0xE6, 0x90, 0x18, 0x00, 0x65, 0x00,
+0xFB, 0xFF, 0x02, 0x24, 0x24, 0x30, 0xC2, 0x00, 0x00, 0x00, 0xE6, 0xA0,
+0x67, 0x46, 0x06, 0x3C, 0xCF, 0xAC, 0xC6, 0x34, 0x01, 0x00, 0x04, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x12, 0x18, 0x00, 0x00, 0x82, 0x1A, 0x03, 0x00,
+0x40, 0x10, 0x03, 0x00, 0x21, 0x10, 0x43, 0x00, 0xC0, 0x10, 0x02, 0x00,
+0x21, 0x10, 0x43, 0x00, 0x80, 0x10, 0x02, 0x00, 0x19, 0x00, 0x46, 0x00,
+0x10, 0x30, 0x00, 0x00, 0x23, 0x10, 0x46, 0x00, 0x42, 0x10, 0x02, 0x00,
+0x21, 0x30, 0xC2, 0x00, 0x02, 0x33, 0x06, 0x00, 0x01, 0x00, 0x02, 0x24,
+0xB9, 0x20, 0x00, 0x0C, 0x0A, 0x30, 0x46, 0x00, 0x25, 0xB0, 0x06, 0x3C,
+0xF2, 0x02, 0xC3, 0x34, 0x88, 0xFF, 0x02, 0x24, 0x00, 0x00, 0x62, 0xA0,
+0x11, 0x00, 0xC7, 0x34, 0x00, 0x00, 0xE2, 0x90, 0x08, 0x00, 0xC5, 0x34,
+0x60, 0x1B, 0xE4, 0x26, 0x01, 0x00, 0x42, 0x34, 0x00, 0x00, 0xE2, 0xA0,
+0x00, 0x00, 0xA3, 0x94, 0xB0, 0x1B, 0x82, 0x94, 0xFF, 0xFF, 0x64, 0x30,
+0x10, 0x00, 0x84, 0x34, 0x00, 0x00, 0xA4, 0xA4, 0xFB, 0xFF, 0x84, 0x30,
+0x00, 0x00, 0xA4, 0xA4, 0x00, 0x01, 0x42, 0x30, 0x02, 0x00, 0x84, 0x34,
+0x00, 0x00, 0xA4, 0xA4, 0x04, 0x00, 0x40, 0x10, 0x42, 0xB0, 0x02, 0x3C,
+0x22, 0x00, 0x03, 0x24, 0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0,
+0xFF, 0xF7, 0x84, 0x30, 0x00, 0x00, 0xA4, 0xA4, 0x28, 0x00, 0xC4, 0x34,
+0x00, 0x00, 0x83, 0x94, 0xEF, 0xFE, 0x02, 0x24, 0xFE, 0xFF, 0x08, 0x24,
+0x24, 0x18, 0x62, 0x00, 0x00, 0x00, 0x83, 0xA4, 0x00, 0x00, 0x82, 0x94,
+0x26, 0x00, 0xC5, 0x34, 0x02, 0x80, 0x03, 0x3C, 0x24, 0x10, 0x48, 0x00,
+0x00, 0x00, 0x82, 0xA4, 0xC2, 0x5C, 0x64, 0x90, 0x00, 0x00, 0xA2, 0x94,
+0x04, 0x00, 0x84, 0x30, 0x00, 0x24, 0x42, 0x34, 0x00, 0x00, 0xA2, 0xA4,
+0x09, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x48, 0x00, 0x00, 0x00, 0xA2, 0xA4,
+0x00, 0x00, 0xE3, 0x90, 0xFD, 0xFF, 0x02, 0x24, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x00, 0xE3, 0xA0, 0x00, 0x68, 0x02, 0x40, 0x00, 0x08, 0x42, 0x30,
+0xFD, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x12, 0x3C,
+0x11, 0x00, 0x43, 0x36, 0x00, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x42, 0x34, 0x00, 0x00, 0x62, 0xA0, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x26, 0x00, 0x44, 0x36, 0x00, 0x00, 0x82, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x34, 0x00, 0x00, 0x82, 0xA4,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x94,
+0xFF, 0xDB, 0x02, 0x24, 0x28, 0x00, 0x45, 0x36, 0x24, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x83, 0xA4, 0x00, 0x00, 0xA2, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x42, 0x34, 0x00, 0x00, 0xA2, 0xA4, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x01, 0x42, 0x34, 0x00, 0x00, 0xA2, 0xA4, 0x08, 0x00, 0x51, 0x36,
+0x00, 0x00, 0x23, 0x96, 0x60, 0x1B, 0xF6, 0x26, 0xB0, 0x1B, 0xC2, 0x96,
+0xFF, 0xFF, 0x70, 0x30, 0x00, 0x18, 0x10, 0x36, 0x00, 0x00, 0x30, 0xA6,
+0x00, 0x01, 0x42, 0x30, 0xFD, 0xFF, 0x10, 0x32, 0x00, 0x00, 0x30, 0xA6,
+0x05, 0x00, 0x40, 0x10, 0x42, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x43, 0x90,
+0xFB, 0xFF, 0x04, 0x24, 0x24, 0x18, 0x64, 0x00, 0x00, 0x00, 0x43, 0xA0,
+0x04, 0x00, 0x10, 0x36, 0x5B, 0x1F, 0x00, 0x0C, 0x32, 0x00, 0x04, 0x24,
+0x00, 0x00, 0x30, 0xA6, 0x22, 0x00, 0x02, 0x24, 0xF2, 0x02, 0x43, 0x36,
+0xEF, 0xFF, 0x10, 0x32, 0x00, 0x00, 0x30, 0xA6, 0xC8, 0x00, 0x04, 0x24,
+0x00, 0x00, 0x62, 0xA0, 0x5B, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xB0, 0x1B, 0xC2, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30,
+0x41, 0x00, 0x40, 0x10, 0x42, 0xB0, 0x06, 0x3C, 0x84, 0x00, 0x42, 0x36,
+0x00, 0x00, 0x44, 0x8C, 0x80, 0x00, 0x46, 0x36, 0x00, 0x00, 0xC2, 0x8C,
+0x00, 0x28, 0x04, 0x00, 0x21, 0x18, 0x00, 0x00, 0x21, 0x20, 0x00, 0x00,
+0x25, 0x30, 0x82, 0x00, 0x25, 0x38, 0xA3, 0x00, 0x58, 0x41, 0xC3, 0x8E,
+0x23, 0x28, 0xD4, 0x00, 0x80, 0x12, 0x05, 0x00, 0x1B, 0x00, 0x43, 0x00,
+0x02, 0x00, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00,
+0x02, 0x80, 0x0B, 0x3C, 0x14, 0x5E, 0x63, 0x8D, 0x12, 0x10, 0x00, 0x00,
+0x23, 0x10, 0x45, 0x00, 0x21, 0x10, 0x43, 0x00, 0x14, 0x5E, 0x62, 0xAD,
+0x14, 0x5E, 0x63, 0x8D, 0x42, 0xB0, 0x02, 0x3C, 0x03, 0x00, 0x42, 0x34,
+0x58, 0x1B, 0x63, 0x24, 0x14, 0x5E, 0x63, 0xAD, 0x00, 0x00, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x63, 0x30, 0x20, 0x00, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x5E, 0x62, 0x8D, 0x02, 0x80, 0x0A, 0x3C,
+0x1C, 0x5E, 0x44, 0x8D, 0x21, 0x40, 0x46, 0x00, 0x2B, 0x28, 0x06, 0x01,
+0x21, 0x48, 0x67, 0x00, 0x21, 0x48, 0x25, 0x01, 0x2B, 0x20, 0x24, 0x01,
+0x59, 0x00, 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x5E, 0x42, 0x8D,
+0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x49, 0x10, 0x01, 0x00, 0x05, 0x24,
+0x42, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x43, 0x90, 0xFB, 0xFF, 0x04, 0x24,
+0x01, 0x00, 0x06, 0x24, 0x24, 0x18, 0x64, 0x00, 0x00, 0x00, 0x43, 0xA0,
+0x04, 0x00, 0xA0, 0x10, 0x01, 0x00, 0x04, 0x24, 0x80, 0x10, 0x05, 0x00,
+0x21, 0x10, 0x45, 0x00, 0x80, 0x30, 0x02, 0x00, 0xB9, 0x20, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x00, 0x42, 0xB0, 0x02, 0x3C, 0x22, 0x00, 0x03, 0x24,
+0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0, 0x42, 0xB0, 0x06, 0x3C,
+0x00, 0x00, 0xC2, 0x90, 0x60, 0x1B, 0xE5, 0x26, 0xD0, 0x1B, 0xA8, 0x8C,
+0xDC, 0x1B, 0xA7, 0x94, 0x41, 0xB0, 0x03, 0x3C, 0x41, 0x00, 0x42, 0x34,
+0x08, 0x00, 0x64, 0x34, 0x00, 0x00, 0xC2, 0xA0, 0x00, 0x00, 0x68, 0xAC,
+0x00, 0x00, 0x87, 0xA4, 0xEE, 0x5D, 0x63, 0x92, 0xF0, 0xFF, 0x02, 0x24,
+0xDC, 0x1B, 0xA7, 0xA4, 0x24, 0x18, 0x62, 0x00, 0xEE, 0x5D, 0x63, 0xA2,
+0xEE, 0x5D, 0x62, 0x92, 0xD0, 0x1B, 0xA8, 0xAC, 0x02, 0x00, 0x42, 0x34,
+0xEE, 0x5D, 0x62, 0xA2, 0x72, 0x2E, 0x00, 0x08, 0x02, 0x80, 0x10, 0x3C,
+0x59, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x31, 0xFE, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0x2E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xEE, 0x5D, 0x62, 0x92, 0xF0, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0xEE, 0x5D, 0x62, 0xA2, 0xEE, 0x5D, 0x63, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x63, 0x34, 0xEE, 0x5D, 0x63, 0xA2, 0x6C, 0x2E, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x97, 0x99, 0x63, 0x34, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x94, 0x2E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x18, 0x5E, 0x42, 0x8D,
+0x00, 0x00, 0x00, 0x00, 0x2B, 0x10, 0x82, 0x00, 0x0C, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x18, 0x5E, 0x42, 0x8D, 0x45, 0x2F, 0x00, 0x08,
+0x01, 0x00, 0x05, 0x24, 0x18, 0x5E, 0x42, 0x8D, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0x02, 0x01, 0x0A, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x5E, 0x42, 0x8D, 0x16, 0x30, 0x00, 0x08, 0x01, 0x00, 0x05, 0x24,
+0x18, 0x5E, 0x42, 0x8D, 0x1C, 0x5E, 0x43, 0x8D, 0x14, 0x5E, 0x64, 0x8D,
+0x23, 0x10, 0x54, 0x00, 0x45, 0x2F, 0x00, 0x08, 0x23, 0x28, 0x44, 0x00,
+0x18, 0x5E, 0x42, 0x8D, 0x1C, 0x5E, 0x43, 0x8D, 0x14, 0x5E, 0x64, 0x8D,
+0x23, 0x10, 0x46, 0x00, 0x16, 0x30, 0x00, 0x08, 0x23, 0x28, 0x44, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xEC, 0x5D, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x60, 0x10, 0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90,
+0x04, 0x00, 0x04, 0x24, 0x0F, 0x00, 0x63, 0x30, 0x04, 0x00, 0x63, 0x28,
+0x03, 0x00, 0x60, 0x14, 0x01, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x4B, 0x2E, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x03, 0x3C, 0xE0, 0xFF, 0xBD, 0x27,
+0xFC, 0xC1, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x62, 0xAC, 0x18, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x0C, 0x5E, 0x82, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x40, 0x10, 0x01, 0x00, 0x05, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0xD0, 0x07, 0x03, 0x24, 0x0C, 0x5E, 0x80, 0xA0,
+0x10, 0x00, 0xA4, 0x27, 0x90, 0x40, 0x00, 0x0C, 0xDC, 0x5D, 0x43, 0xAC,
+0x18, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x03, 0x3C, 0x01, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x0F, 0x5E, 0x44, 0xA0, 0x02, 0x80, 0x02, 0x3C,
+0x0D, 0x5E, 0x60, 0xA0, 0xED, 0x5D, 0x44, 0x90, 0x4B, 0x2E, 0x00, 0x0C,
+0xFF, 0x00, 0x84, 0x30, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x18, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x42, 0x11, 0x05, 0x00, 0x0F, 0x00, 0x46, 0x30,
+0xE8, 0xFF, 0xBD, 0x27, 0x09, 0x00, 0xC3, 0x28, 0x14, 0x00, 0xBF, 0xAF,
+0x14, 0x00, 0x60, 0x10, 0x10, 0x00, 0xB0, 0xAF, 0x82, 0x16, 0x05, 0x00,
+0x01, 0x00, 0x42, 0x30, 0x14, 0x00, 0x40, 0x10, 0x00, 0xC0, 0x02, 0x3C,
+0x24, 0x10, 0xA2, 0x00, 0x43, 0x00, 0x40, 0x14, 0xC2, 0x15, 0x04, 0x00,
+0x01, 0x00, 0x42, 0x30, 0x50, 0x00, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x0C, 0xE5, 0x63, 0x24, 0x21, 0x18, 0xC3, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x08, 0x5E, 0x85, 0x90, 0x00, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x10, 0x45, 0x00, 0x47, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x24, 0x10, 0xA2, 0x00, 0x1E, 0x00, 0x40, 0x10,
+0xC2, 0x15, 0x04, 0x00, 0x02, 0x80, 0x06, 0x3C, 0x07, 0x5E, 0xC2, 0x90,
+0xFD, 0xFF, 0x03, 0x24, 0x42, 0xB0, 0x04, 0x3C, 0x24, 0x10, 0x43, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0xC2, 0xA0, 0x0B, 0x5E, 0x60, 0xA0,
+0x00, 0x00, 0x82, 0x90, 0xEF, 0xFF, 0x03, 0x24, 0x03, 0x00, 0x85, 0x34,
+0x24, 0x10, 0x43, 0x00, 0x40, 0x00, 0x03, 0x24, 0x00, 0x00, 0x82, 0xA0,
+0x00, 0x00, 0xA3, 0xA0, 0x07, 0x5E, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x42, 0x30, 0xE6, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C,
+0x05, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0x01, 0x00, 0x42, 0x30, 0x25, 0x00, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x0C, 0xE5, 0x63, 0x24, 0x21, 0x18, 0xC3, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x08, 0x5E, 0x85, 0x90, 0x00, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x10, 0x45, 0x00, 0xE7, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x06, 0x3C,
+0x07, 0x5E, 0xC2, 0x90, 0xFE, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x07, 0x5E, 0xC2, 0xA0, 0xD7, 0x30, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x42, 0xB0, 0x07, 0x3C, 0x00, 0x00, 0xE3, 0x90, 0xEF, 0xFF, 0x02, 0x24,
+0x03, 0x00, 0xF0, 0x34, 0x24, 0x18, 0x62, 0x00, 0x40, 0x00, 0x02, 0x24,
+0x00, 0x00, 0xE3, 0xA0, 0x02, 0x00, 0x04, 0x24, 0x00, 0x00, 0x02, 0xA2,
+0x21, 0x28, 0x00, 0x00, 0xB9, 0x20, 0x00, 0x0C, 0x00, 0xF0, 0x06, 0x34,
+0x44, 0x00, 0x02, 0x24, 0x00, 0x00, 0x02, 0xA2, 0xC1, 0x30, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x01, 0x00, 0x04, 0x24, 0xE1, 0x51, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0x02, 0x80, 0x06, 0x3C, 0x07, 0x5E, 0xC2, 0x90, 0xFE, 0xFF, 0x03, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x07, 0x5E, 0xC2, 0xA0, 0xD7, 0x30, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x82, 0x16, 0x05, 0x00, 0xE8, 0xFF, 0xBD, 0x27,
+0x01, 0x00, 0x42, 0x30, 0x14, 0x00, 0xBF, 0xAF, 0x0E, 0x00, 0x40, 0x10,
+0x10, 0x00, 0xB0, 0xAF, 0x00, 0xC0, 0x02, 0x3C, 0x24, 0x10, 0xA2, 0x00,
+0x37, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x06, 0x5E, 0x43, 0x90,
+0x02, 0x00, 0x02, 0x24, 0xFF, 0x00, 0x63, 0x30, 0x44, 0x00, 0x62, 0x10,
+0x01, 0x00, 0x04, 0x24, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0xE1, 0x51, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0x00, 0xC0, 0x02, 0x3C,
+0x24, 0x10, 0xA2, 0x00, 0x0E, 0x00, 0x40, 0x14, 0x02, 0x80, 0x06, 0x3C,
+0x07, 0x5E, 0xC2, 0x90, 0xFE, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x07, 0x5E, 0xC2, 0xA0, 0x07, 0x5E, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x00, 0x42, 0x30, 0x18, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x07, 0x5E, 0xC2, 0x90, 0xFD, 0xFF, 0x03, 0x24,
+0x42, 0xB0, 0x04, 0x3C, 0x24, 0x10, 0x43, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x07, 0x5E, 0xC2, 0xA0, 0x0B, 0x5E, 0x60, 0xA0, 0x00, 0x00, 0x82, 0x90,
+0xEF, 0xFF, 0x03, 0x24, 0x03, 0x00, 0x85, 0x34, 0x24, 0x10, 0x43, 0x00,
+0x40, 0x00, 0x03, 0x24, 0x00, 0x00, 0x82, 0xA0, 0x00, 0x00, 0xA3, 0xA0,
+0x07, 0x5E, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x42, 0x30,
+0xEA, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x05, 0x5E, 0x40, 0xA0,
+0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x05, 0x24, 0xFF, 0x00, 0x84, 0x30,
+0x4B, 0x2E, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0x42, 0xB0, 0x07, 0x3C,
+0x00, 0x00, 0xE3, 0x90, 0xEF, 0xFF, 0x02, 0x24, 0x03, 0x00, 0xF0, 0x34,
+0x24, 0x18, 0x62, 0x00, 0x40, 0x00, 0x02, 0x24, 0x00, 0x00, 0xE3, 0xA0,
+0x02, 0x00, 0x04, 0x24, 0x00, 0x00, 0x02, 0xA2, 0x21, 0x28, 0x00, 0x00,
+0xB9, 0x20, 0x00, 0x0C, 0x00, 0xF0, 0x06, 0x34, 0x44, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x02, 0xA2, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xE2, 0x2C, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x0C, 0x00, 0x04, 0x24, 0x01, 0x00, 0x05, 0x24, 0x4B, 0x2E, 0x00, 0x08,
+0x18, 0x00, 0xBD, 0x27, 0x01, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x03, 0x3C,
+0xE8, 0xFF, 0xBD, 0x27, 0xB4, 0xC5, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34,
+0x10, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x62, 0xAC, 0x02, 0x80, 0x10, 0x3C,
+0xED, 0x5D, 0x02, 0x92, 0x14, 0x00, 0xBF, 0xAF, 0x0F, 0x00, 0x42, 0x30,
+0x03, 0x00, 0x42, 0x28, 0x05, 0x00, 0x40, 0x10, 0x01, 0x00, 0x05, 0x24,
+0x59, 0x2D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0x10,
+0x01, 0x00, 0x05, 0x24, 0xED, 0x5D, 0x04, 0x92, 0x4B, 0x2E, 0x00, 0x0C,
+0xFF, 0x00, 0x84, 0x30, 0x02, 0x80, 0x04, 0x3C, 0x60, 0x1B, 0x84, 0x24,
+0xE0, 0x1B, 0x83, 0x94, 0xDC, 0x1B, 0x85, 0x94, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x02, 0x00, 0x63, 0x30, 0x41, 0xB0, 0x02, 0x3C,
+0x25, 0x18, 0x65, 0x00, 0x08, 0x00, 0x42, 0x34, 0x18, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0x43, 0xA4, 0x08, 0x00, 0xE0, 0x03, 0xDC, 0x1B, 0x83, 0xA4,
+0xE0, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x02, 0x3C, 0x01, 0x80, 0x03, 0x3C,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x03, 0x52, 0x34, 0x40, 0xC6, 0x71, 0x24,
+0x02, 0x80, 0x10, 0x3C, 0x08, 0x14, 0x04, 0x26, 0x21, 0x28, 0x00, 0x00,
+0x21, 0x30, 0x00, 0x00, 0x21, 0x38, 0x00, 0x00, 0x00, 0x00, 0x51, 0xAE,
+0x76, 0x39, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x9B, 0x31, 0x00, 0x08,
+0x08, 0x14, 0x04, 0x26, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0xFF, 0xFF, 0x90, 0x30, 0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x06, 0x3C, 0x60, 0x1B, 0xCD, 0x24,
+0x2A, 0x1C, 0xA2, 0x91, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x40, 0x10,
+0x2A, 0xB0, 0x02, 0x3C, 0x25, 0xB0, 0x03, 0x3C, 0x38, 0x02, 0x64, 0x34,
+0x80, 0xFF, 0x02, 0x24, 0x00, 0x00, 0x82, 0xA0, 0x34, 0x02, 0x6A, 0x34,
+0xD2, 0x01, 0x65, 0x34, 0xD6, 0x01, 0x66, 0x34, 0xDA, 0x01, 0x67, 0x34,
+0xDE, 0x01, 0x63, 0x34, 0x00, 0x00, 0xA8, 0x94, 0x00, 0x00, 0xC9, 0x94,
+0x00, 0x00, 0xEB, 0x94, 0x00, 0x00, 0x6C, 0x94, 0x00, 0x00, 0x44, 0x95,
+0xB0, 0xFE, 0x02, 0x26, 0xFF, 0xFF, 0x50, 0x30, 0x28, 0x1C, 0xA4, 0xA5,
+0x00, 0x00, 0xA0, 0xA4, 0x10, 0x00, 0xA4, 0x27, 0x20, 0x1C, 0xA8, 0xA5,
+0x00, 0x00, 0xC0, 0xA4, 0x22, 0x1C, 0xA9, 0xA5, 0x00, 0x00, 0xE0, 0xA4,
+0x24, 0x1C, 0xAB, 0xA5, 0x00, 0x00, 0x60, 0xA4, 0x00, 0x00, 0x50, 0xA5,
+0x90, 0x40, 0x00, 0x0C, 0x26, 0x1C, 0xAC, 0xA5, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x0A, 0x00, 0x45, 0x34, 0x63, 0x00, 0x03, 0x24, 0xFF, 0xFF, 0x04, 0x34,
+0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x40, 0x10,
+0x64, 0x00, 0x02, 0x24, 0xFF, 0xFF, 0x42, 0x24, 0xFF, 0xFF, 0x42, 0x30,
+0xFE, 0xFF, 0x40, 0x14, 0xFF, 0xFF, 0x42, 0x24, 0xFF, 0xFF, 0x62, 0x24,
+0xFF, 0xFF, 0x43, 0x30, 0xF5, 0xFF, 0x64, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0xC2, 0x24, 0x28, 0x1C, 0x48, 0x94, 0x26, 0x1C, 0x47, 0x94,
+0x20, 0x1C, 0x49, 0x94, 0x22, 0x1C, 0x4A, 0x94, 0x24, 0x1C, 0x4B, 0x94,
+0x25, 0xB0, 0x03, 0x3C, 0x38, 0x02, 0x6C, 0x34, 0x34, 0x02, 0x62, 0x34,
+0xD2, 0x01, 0x64, 0x34, 0xD6, 0x01, 0x65, 0x34, 0xDA, 0x01, 0x66, 0x34,
+0xDE, 0x01, 0x63, 0x34, 0x00, 0x00, 0x48, 0xA4, 0x00, 0x00, 0x89, 0xA4,
+0x00, 0x00, 0xAA, 0xA4, 0x10, 0x00, 0xA4, 0x27, 0x00, 0x00, 0xCB, 0xA4,
+0x00, 0x00, 0x67, 0xA4, 0x00, 0x00, 0x80, 0xA1, 0x90, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27,
+0x28, 0x00, 0xB4, 0xAF, 0x2C, 0x00, 0xBF, 0xAF, 0x24, 0x00, 0xB3, 0xAF,
+0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF,
+0xFF, 0xFF, 0x14, 0x24, 0x02, 0x80, 0x13, 0x3C, 0x41, 0xB0, 0x02, 0x3C,
+0x60, 0x1B, 0x63, 0x26, 0x04, 0x00, 0x42, 0x34, 0x00, 0x00, 0x45, 0x8C,
+0xD4, 0x1B, 0x64, 0x8C, 0xD0, 0x1B, 0x66, 0x8C, 0x02, 0x80, 0x02, 0x3C,
+0xF0, 0x5C, 0x47, 0x90, 0x25, 0xB0, 0x08, 0x3C, 0xB0, 0x03, 0x02, 0x35,
+0x25, 0x90, 0x85, 0x00, 0x00, 0x00, 0x52, 0xAC, 0x00, 0x00, 0x46, 0xAC,
+0x01, 0x00, 0x02, 0x24, 0x89, 0x03, 0xE2, 0x10, 0xD4, 0x1B, 0x72, 0xAC,
+0x60, 0x1B, 0x64, 0x26, 0xD0, 0x1B, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x10, 0x52, 0x00, 0x01, 0x00, 0x42, 0x30, 0x0E, 0x00, 0x40, 0x10,
+0x60, 0x1B, 0x67, 0x26, 0x25, 0xB0, 0x10, 0x3C, 0xB0, 0x03, 0x02, 0x36,
+0x01, 0x00, 0x05, 0x24, 0x00, 0x00, 0x45, 0xAC, 0x04, 0x00, 0x0B, 0x36,
+0xD4, 0x1B, 0x83, 0x8C, 0x00, 0x00, 0x69, 0x8D, 0x40, 0x00, 0x02, 0x3C,
+0x01, 0x00, 0x63, 0x38, 0x24, 0x10, 0x22, 0x01, 0x26, 0x01, 0x40, 0x10,
+0xD4, 0x1B, 0x83, 0xAC, 0x60, 0x1B, 0x67, 0x26, 0xD0, 0x1B, 0xE2, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x52, 0x00, 0x04, 0x00, 0x42, 0x30,
+0x14, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x71, 0x26, 0x25, 0xB0, 0x03, 0x3C,
+0xB0, 0x03, 0x64, 0x34, 0x04, 0x00, 0x02, 0x24, 0x00, 0x00, 0x82, 0xAC,
+0xD4, 0x1B, 0xE2, 0x8C, 0xC4, 0x38, 0xE6, 0x8C, 0xFC, 0x00, 0x63, 0x34,
+0xAC, 0x1B, 0xE4, 0x94, 0x00, 0x00, 0x65, 0x8C, 0x04, 0x00, 0x42, 0x38,
+0x21, 0x48, 0xC4, 0x00, 0x06, 0x00, 0xA9, 0x10, 0xD4, 0x1B, 0xE2, 0xAC,
+0x02, 0x80, 0x03, 0x3C, 0xB0, 0x5D, 0x62, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x42, 0x34, 0xB0, 0x5D, 0x62, 0xAC, 0x60, 0x1B, 0x71, 0x26,
+0xD0, 0x1B, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x52, 0x00,
+0x08, 0x00, 0x42, 0x30, 0x0A, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xB0, 0x1B, 0x22, 0x96, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x42, 0x30,
+0x5D, 0x03, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0xD4, 0x1B, 0x22, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x42, 0x38, 0xD4, 0x1B, 0x22, 0xAE,
+0x60, 0x1B, 0x70, 0x26, 0xD0, 0x1B, 0x02, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x20, 0x52, 0x00, 0x00, 0x08, 0x83, 0x30, 0x06, 0x00, 0x60, 0x10,
+0x00, 0x10, 0x82, 0x30, 0xD4, 0x1B, 0x02, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x08, 0x42, 0x38, 0xD4, 0x1B, 0x02, 0xAE, 0x00, 0x10, 0x82, 0x30,
+0x05, 0x03, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x70, 0x26,
+0xD0, 0x1B, 0x03, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x72, 0x00,
+0x00, 0x20, 0x42, 0x30, 0xF7, 0x02, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x10, 0x72, 0x00, 0x00, 0x80, 0x42, 0x30, 0xB9, 0x01, 0x40, 0x14,
+0x01, 0x00, 0x03, 0x3C, 0x60, 0x1B, 0x70, 0x26, 0xD0, 0x1B, 0x02, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x54, 0x00,
+0x24, 0x10, 0x43, 0x00, 0xF1, 0x01, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0xD0, 0x1B, 0x02, 0x8E, 0x02, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x43, 0x00, 0x28, 0x02, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x70, 0x26, 0xD0, 0x1B, 0x02, 0x8E, 0x04, 0x00, 0x03, 0x3C,
+0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x54, 0x00, 0x24, 0x10, 0x43, 0x00,
+0x62, 0x02, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x70, 0x26,
+0xD0, 0x1B, 0x02, 0x8E, 0x08, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x43, 0x00, 0x9B, 0x02, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x70, 0x26, 0xD0, 0x1B, 0x02, 0x8E, 0x10, 0x00, 0x03, 0x3C,
+0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x54, 0x00, 0x24, 0x10, 0x43, 0x00,
+0x5A, 0x01, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x70, 0x26,
+0xD0, 0x1B, 0x02, 0x8E, 0x20, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x43, 0x00, 0x18, 0x01, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x70, 0x26, 0xD0, 0x1B, 0x02, 0x8E, 0x40, 0x00, 0x03, 0x3C,
+0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x54, 0x00, 0x24, 0x10, 0x43, 0x00,
+0xD6, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x65, 0x26,
+0xD0, 0x1B, 0xA2, 0x8C, 0x00, 0x04, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x43, 0x00, 0x3D, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x66, 0x26,
+0x2A, 0xB0, 0x02, 0x3C, 0x2C, 0x00, 0x43, 0x34, 0x00, 0x00, 0x69, 0x8C,
+0xFF, 0x00, 0x02, 0x24, 0xFF, 0x00, 0x24, 0x31, 0x29, 0x03, 0x82, 0x10,
+0x00, 0x80, 0x22, 0x31, 0xF9, 0x02, 0x40, 0x14, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0xFF, 0x02, 0x3C, 0x24, 0x10, 0x22, 0x01, 0x0B, 0x00, 0x40, 0x10,
+0xFF, 0x00, 0x02, 0x24, 0xAC, 0x37, 0xA2, 0x90, 0x20, 0xB0, 0x03, 0x3C,
+0x00, 0x12, 0x02, 0x00, 0x21, 0x10, 0x43, 0x00, 0x0C, 0x00, 0x49, 0x8C,
+0x25, 0xB0, 0x03, 0x3C, 0xB0, 0x03, 0x63, 0x34, 0x00, 0x00, 0x69, 0xAC,
+0xFF, 0x00, 0x24, 0x31, 0xFF, 0x00, 0x02, 0x24, 0x1B, 0x00, 0x82, 0x10,
+0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31, 0x7C, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x10, 0x38, 0x03, 0xAE, 0x0A, 0x00, 0x04, 0x24,
+0xAC, 0x37, 0x09, 0xA2, 0x00, 0x01, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0xD0, 0x1B, 0x05, 0x8E, 0x02, 0x80, 0x06, 0x3C,
+0xB0, 0x5D, 0xC4, 0x8C, 0x00, 0x04, 0x02, 0x3C, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x28, 0xA2, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x00, 0x80, 0x84, 0x34,
+0xB0, 0x03, 0x42, 0x34, 0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x44, 0xAC,
+0x00, 0x00, 0x65, 0xAC, 0xB0, 0x5D, 0xC4, 0xAC, 0xD0, 0x1B, 0x05, 0xAE,
+0x60, 0x1B, 0x65, 0x26, 0xD4, 0x1B, 0xA4, 0x8C, 0x00, 0x04, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x26, 0x20, 0x83, 0x00, 0xB0, 0x03, 0x42, 0x34,
+0x00, 0x00, 0x44, 0xAC, 0xD4, 0x1B, 0xA4, 0xAC, 0x60, 0x1B, 0x66, 0x26,
+0xD0, 0x1B, 0xC7, 0x8C, 0x00, 0x08, 0x04, 0x3C, 0x24, 0x28, 0xF2, 0x00,
+0x24, 0x10, 0xA4, 0x00, 0x08, 0x00, 0x40, 0x10, 0x80, 0x00, 0x08, 0x3C,
+0xD4, 0x1B, 0xC3, 0x8C, 0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34,
+0x26, 0x18, 0x64, 0x00, 0x00, 0x00, 0x44, 0xAC, 0xD4, 0x1B, 0xC3, 0xAC,
+0x80, 0x00, 0x08, 0x3C, 0x24, 0x10, 0xA8, 0x00, 0x21, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xD4, 0x1B, 0xC3, 0x8C, 0x25, 0xB0, 0x09, 0x3C,
+0xB0, 0x03, 0x2A, 0x35, 0x2A, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x43, 0xAD,
+0x36, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x90, 0x23, 0xB0, 0x04, 0x3C,
+0xFF, 0x1F, 0x02, 0x3C, 0xC0, 0x18, 0x03, 0x00, 0xF0, 0x07, 0x63, 0x30,
+0xF4, 0x38, 0xC5, 0x8C, 0x21, 0x18, 0x64, 0x00, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x18, 0x62, 0x00, 0xCE, 0x02, 0x65, 0x10, 0xF8, 0x38, 0xC3, 0xAC,
+0x02, 0x80, 0x05, 0x3C, 0xB0, 0x5D, 0xA3, 0x8C, 0x27, 0x20, 0x08, 0x00,
+0x24, 0x20, 0xE4, 0x00, 0x00, 0x10, 0x63, 0x34, 0x41, 0xB0, 0x02, 0x3C,
+0x00, 0x00, 0x43, 0xAD, 0x00, 0x00, 0x44, 0xAC, 0xB0, 0x5D, 0xA3, 0xAC,
+0xD0, 0x1B, 0xC4, 0xAC, 0x60, 0x1B, 0x62, 0x26, 0xD4, 0x1B, 0x43, 0x8C,
+0x80, 0x00, 0x04, 0x3C, 0x26, 0x18, 0x64, 0x00, 0xD4, 0x1B, 0x43, 0xAC,
+0x60, 0x1B, 0x66, 0x26, 0xD0, 0x1B, 0xC3, 0x8C, 0x00, 0x01, 0x05, 0x3C,
+0x24, 0x20, 0x72, 0x00, 0x24, 0x10, 0x85, 0x00, 0x06, 0x00, 0x40, 0x10,
+0x25, 0xB0, 0x02, 0x3C, 0xD4, 0x1B, 0xC3, 0x8C, 0xB0, 0x03, 0x42, 0x34,
+0x26, 0x18, 0x65, 0x00, 0x00, 0x00, 0x45, 0xAC, 0xD4, 0x1B, 0xC3, 0xAC,
+0x00, 0x02, 0x05, 0x3C, 0x24, 0x10, 0x85, 0x00, 0x06, 0x00, 0x40, 0x10,
+0x25, 0xB0, 0x02, 0x3C, 0xD4, 0x1B, 0xC3, 0x8C, 0xB0, 0x03, 0x42, 0x34,
+0x26, 0x18, 0x65, 0x00, 0x00, 0x00, 0x45, 0xAC, 0xD4, 0x1B, 0xC3, 0xAC,
+0x00, 0x10, 0x05, 0x3C, 0x24, 0x10, 0x85, 0x00, 0x0C, 0x00, 0x40, 0x10,
+0x60, 0x1B, 0x63, 0x26, 0xB0, 0x1B, 0xC3, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x62, 0x30, 0x02, 0x00, 0x40, 0x10, 0x00, 0x08, 0x62, 0x34,
+0xB0, 0x1B, 0xC2, 0xA4, 0xD4, 0x1B, 0xC2, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x26, 0x10, 0x45, 0x00, 0xD4, 0x1B, 0xC2, 0xAC, 0x60, 0x1B, 0x63, 0x26,
+0xD0, 0x1B, 0x62, 0x8C, 0x00, 0x20, 0x05, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x45, 0x00, 0x0B, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xB0, 0x1B, 0x64, 0x94, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x82, 0x30,
+0x02, 0x00, 0x40, 0x10, 0xFF, 0xF7, 0x82, 0x30, 0xB0, 0x1B, 0x62, 0xA4,
+0xD4, 0x1B, 0x62, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x26, 0x10, 0x45, 0x00,
+0xD4, 0x1B, 0x62, 0xAC, 0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0x20, 0xBD, 0x02, 0x3C, 0xEC, 0x02, 0x03, 0x36, 0x4D, 0x00, 0x07, 0x36,
+0xF1, 0x02, 0x08, 0x36, 0x08, 0x00, 0x06, 0x24, 0x78, 0x02, 0x42, 0x34,
+0x00, 0x00, 0x45, 0xA4, 0x00, 0x00, 0xE0, 0xA0, 0x00, 0x00, 0x06, 0xA1,
+0x00, 0x00, 0x60, 0xAC, 0x00, 0x00, 0x62, 0x8C, 0xFF, 0x00, 0x04, 0x3C,
+0x00, 0x00, 0xE0, 0xA0, 0xFF, 0x00, 0x49, 0x30, 0x25, 0x48, 0x24, 0x01,
+0x00, 0x00, 0x06, 0xA1, 0xF2, 0x02, 0x05, 0x36, 0x00, 0x00, 0x64, 0xAC,
+0x0A, 0x00, 0x0A, 0x36, 0x00, 0x00, 0x69, 0xAC, 0x80, 0xFF, 0x03, 0x24,
+0x00, 0x00, 0xA0, 0xA0, 0x00, 0x00, 0x43, 0xA1, 0x00, 0x00, 0x62, 0x8D,
+0x80, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x43, 0x00, 0x02, 0x00, 0x40, 0x10,
+0x84, 0xFF, 0x02, 0x24, 0x00, 0x00, 0x42, 0xA1, 0x2C, 0x1F, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x02, 0x00, 0x02, 0x36, 0x00, 0x00, 0x43, 0x94,
+0xFF, 0xBF, 0x04, 0x24, 0x24, 0x18, 0x64, 0x00, 0x00, 0x00, 0x43, 0xA4,
+0x25, 0x32, 0x00, 0x08, 0x60, 0x1B, 0x67, 0x26, 0x70, 0x30, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x2A, 0xB0, 0x06, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0x00, 0x00, 0x54, 0xAC, 0x28, 0x00, 0xC3, 0x34,
+0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x05, 0x24, 0xFF, 0x00, 0x24, 0x31,
+0x6D, 0x03, 0x85, 0x10, 0x25, 0xBD, 0x02, 0x3C, 0x00, 0x80, 0x22, 0x31,
+0x59, 0x02, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x21, 0x00, 0x82, 0x10,
+0xFF, 0x00, 0x23, 0x31, 0x60, 0x1B, 0x70, 0x26, 0x4C, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x98, 0x37, 0x09, 0xA2, 0xE0, 0x37, 0x03, 0xAE,
+0x06, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x09, 0x3C, 0xC0, 0x5D, 0x27, 0x91,
+0x02, 0x80, 0x08, 0x3C, 0xB0, 0x5D, 0x05, 0x8D, 0xD0, 0x1B, 0x06, 0x8E,
+0x60, 0x00, 0x02, 0x3C, 0x02, 0x00, 0xE7, 0x34, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x30, 0xC2, 0x00, 0x00, 0x08, 0xA5, 0x34, 0x00, 0x26, 0x07, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x42, 0x34,
+0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x66, 0xAC,
+0xB0, 0x5D, 0x05, 0xAD, 0xC0, 0x5D, 0x27, 0xA1, 0xD0, 0x1B, 0x06, 0xAE,
+0x60, 0x1B, 0x62, 0x26, 0xD4, 0x1B, 0x43, 0x8C, 0x40, 0x00, 0x04, 0x3C,
+0x26, 0x18, 0x64, 0x00, 0x9A, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x43, 0xAC,
+0x70, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x05, 0x3C,
+0x24, 0x00, 0xA3, 0x34, 0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x06, 0x24,
+0xFF, 0x00, 0x24, 0x31, 0x48, 0x03, 0x86, 0x10, 0x25, 0xB0, 0x02, 0x3C,
+0x00, 0x80, 0x22, 0x31, 0x64, 0x02, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24,
+0x25, 0x00, 0x82, 0x10, 0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31,
+0x4C, 0x38, 0x05, 0x8E, 0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x21, 0x30, 0x60, 0x00, 0x94, 0x37, 0x09, 0xA2,
+0xE0, 0x37, 0x03, 0xAE, 0x06, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x0A, 0x3C,
+0xC0, 0x5D, 0x47, 0x91, 0x02, 0x80, 0x09, 0x3C, 0xB0, 0x5D, 0x25, 0x8D,
+0xD0, 0x1B, 0x06, 0x8E, 0x60, 0x00, 0x02, 0x3C, 0x04, 0x00, 0xE7, 0x34,
+0x27, 0x10, 0x02, 0x00, 0x24, 0x30, 0xC2, 0x00, 0x00, 0x08, 0xA5, 0x34,
+0x25, 0xB0, 0x03, 0x3C, 0x40, 0x00, 0x02, 0x3C, 0x00, 0x26, 0x07, 0x00,
+0x26, 0xA0, 0x82, 0x02, 0xB0, 0x03, 0x68, 0x34, 0x25, 0x20, 0x85, 0x00,
+0x80, 0x03, 0x63, 0x34, 0x41, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x64, 0xAC,
+0x00, 0x00, 0x46, 0xAC, 0xB0, 0x5D, 0x25, 0xAD, 0xC0, 0x5D, 0x47, 0xA1,
+0xD0, 0x1B, 0x06, 0xAE, 0x00, 0x00, 0x14, 0xAD, 0x60, 0x1B, 0x62, 0x26,
+0xD4, 0x1B, 0x43, 0x8C, 0x20, 0x00, 0x04, 0x3C, 0x26, 0x18, 0x64, 0x00,
+0x92, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x43, 0xAC, 0x70, 0x30, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x05, 0x3C, 0xB0, 0x03, 0xA2, 0x34,
+0x2A, 0xB0, 0x07, 0x3C, 0x00, 0x00, 0x54, 0xAC, 0x20, 0x00, 0xE3, 0x34,
+0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x06, 0x24, 0xFF, 0x00, 0x24, 0x31,
+0x07, 0x03, 0x86, 0x10, 0x90, 0x03, 0xA2, 0x34, 0x00, 0x80, 0x22, 0x31,
+0x05, 0x02, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x21, 0x00, 0x82, 0x10,
+0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31, 0x40, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x9C, 0x37, 0x09, 0xA2, 0xD4, 0x37, 0x03, 0xAE,
+0x05, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x09, 0x3C, 0xC0, 0x5D, 0x27, 0x91,
+0x02, 0x80, 0x08, 0x3C, 0xB0, 0x5D, 0x05, 0x8D, 0xD0, 0x1B, 0x06, 0x8E,
+0x18, 0x00, 0x02, 0x3C, 0x01, 0x00, 0xE7, 0x34, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x30, 0xC2, 0x00, 0x00, 0x04, 0xA5, 0x34, 0x00, 0x26, 0x07, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x42, 0x34,
+0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x66, 0xAC,
+0xB0, 0x5D, 0x05, 0xAD, 0xC0, 0x5D, 0x27, 0xA1, 0xD0, 0x1B, 0x06, 0xAE,
+0x60, 0x1B, 0x62, 0x26, 0xD4, 0x1B, 0x43, 0x8C, 0x10, 0x00, 0x04, 0x3C,
+0x26, 0x18, 0x64, 0x00, 0x8B, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x43, 0xAC,
+0x70, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x05, 0x3C,
+0x0C, 0x00, 0xA3, 0x34, 0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x06, 0x24,
+0xFF, 0x00, 0x24, 0x31, 0xC6, 0x02, 0x86, 0x10, 0x00, 0x80, 0x22, 0x31,
+0x54, 0x02, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x24, 0x00, 0x82, 0x10,
+0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31, 0x28, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x80, 0x37, 0x09, 0xA2, 0xBC, 0x37, 0x03, 0xAE,
+0x03, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x0A, 0x3C, 0xC0, 0x5D, 0x47, 0x91,
+0x02, 0x80, 0x09, 0x3C, 0xB0, 0x5D, 0x25, 0x8D, 0xD0, 0x1B, 0x06, 0x8E,
+0x01, 0x00, 0x08, 0x3C, 0x80, 0xFF, 0x02, 0x24, 0x25, 0x38, 0xE2, 0x00,
+0x00, 0x80, 0x03, 0x35, 0x00, 0x01, 0xA5, 0x34, 0x27, 0x18, 0x03, 0x00,
+0x00, 0x26, 0x07, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x24, 0x30, 0xC3, 0x00,
+0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x42, 0x34, 0x41, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0x44, 0xAC, 0x27, 0xA0, 0x08, 0x00, 0x00, 0x00, 0x66, 0xAC,
+0xB0, 0x5D, 0x25, 0xAD, 0xC0, 0x5D, 0x47, 0xA1, 0xD0, 0x1B, 0x06, 0xAE,
+0x60, 0x1B, 0x63, 0x26, 0xD4, 0x1B, 0x62, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x80, 0x42, 0x38, 0xD4, 0x1B, 0x62, 0xAC, 0x60, 0x1B, 0x70, 0x26,
+0xD0, 0x1B, 0x02, 0x8E, 0x01, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x54, 0x00, 0x24, 0x10, 0x43, 0x00, 0x11, 0xFE, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x70, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x2A, 0xB0, 0x05, 0x3C, 0x10, 0x00, 0xA3, 0x34, 0x00, 0x00, 0x69, 0x8C,
+0xFF, 0x00, 0x06, 0x24, 0xFF, 0x00, 0x24, 0x31, 0x7C, 0x02, 0x86, 0x10,
+0x25, 0xB0, 0x02, 0x3C, 0x00, 0x80, 0x22, 0x31, 0xD0, 0x01, 0x40, 0x10,
+0x00, 0x80, 0x02, 0x3C, 0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24,
+0x22, 0x00, 0x82, 0x10, 0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31,
+0x28, 0x38, 0x05, 0x8E, 0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x21, 0x30, 0x60, 0x00, 0x84, 0x37, 0x09, 0xA2,
+0xBC, 0x37, 0x03, 0xAE, 0x03, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x09, 0x3C,
+0xC0, 0x5D, 0x27, 0x91, 0x02, 0x80, 0x08, 0x3C, 0xB0, 0x5D, 0x05, 0x8D,
+0xD0, 0x1B, 0x06, 0x8E, 0x01, 0x00, 0x02, 0x3C, 0x00, 0x80, 0x42, 0x34,
+0x40, 0x00, 0xE7, 0x34, 0x27, 0x10, 0x02, 0x00, 0x24, 0x30, 0xC2, 0x00,
+0x00, 0x01, 0xA5, 0x34, 0x00, 0x26, 0x07, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x42, 0x34, 0x41, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x66, 0xAC, 0xB0, 0x5D, 0x05, 0xAD,
+0xC0, 0x5D, 0x27, 0xA1, 0xD0, 0x1B, 0x06, 0xAE, 0x60, 0x1B, 0x62, 0x26,
+0xD4, 0x1B, 0x43, 0x8C, 0x01, 0x00, 0x04, 0x3C, 0x60, 0x1B, 0x70, 0x26,
+0x26, 0x18, 0x64, 0x00, 0xD4, 0x1B, 0x43, 0xAC, 0xD0, 0x1B, 0x02, 0x8E,
+0x02, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x43, 0x00,
+0xDB, 0xFD, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x70, 0x30, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x05, 0x3C, 0x14, 0x00, 0xA3, 0x34,
+0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x06, 0x24, 0xFF, 0x00, 0x24, 0x31,
+0x64, 0x02, 0x86, 0x10, 0x25, 0xB0, 0x02, 0x3C, 0x00, 0x80, 0x22, 0x31,
+0xFA, 0x01, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x25, 0x00, 0x82, 0x10,
+0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31, 0x34, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x88, 0x37, 0x09, 0xA2, 0xC8, 0x37, 0x03, 0xAE,
+0x04, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x0A, 0x3C, 0xC0, 0x5D, 0x47, 0x91,
+0x02, 0x80, 0x09, 0x3C, 0xB0, 0x5D, 0x25, 0x8D, 0xD0, 0x1B, 0x06, 0x8E,
+0x06, 0x00, 0x02, 0x3C, 0x20, 0x00, 0xE7, 0x34, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x30, 0xC2, 0x00, 0x00, 0x02, 0xA5, 0x34, 0x25, 0xB0, 0x03, 0x3C,
+0x04, 0x00, 0x02, 0x3C, 0x00, 0x26, 0x07, 0x00, 0x26, 0xA0, 0x82, 0x02,
+0xB0, 0x03, 0x68, 0x34, 0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x63, 0x34,
+0x41, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x64, 0xAC, 0x00, 0x00, 0x46, 0xAC,
+0xB0, 0x5D, 0x25, 0xAD, 0xC0, 0x5D, 0x47, 0xA1, 0xD0, 0x1B, 0x06, 0xAE,
+0x00, 0x00, 0x14, 0xAD, 0x60, 0x1B, 0x62, 0x26, 0xD4, 0x1B, 0x43, 0x8C,
+0x02, 0x00, 0x04, 0x3C, 0x60, 0x1B, 0x70, 0x26, 0x26, 0x18, 0x64, 0x00,
+0xD4, 0x1B, 0x43, 0xAC, 0xD0, 0x1B, 0x02, 0x8E, 0x04, 0x00, 0x03, 0x3C,
+0x24, 0x10, 0x52, 0x00, 0x24, 0x10, 0x54, 0x00, 0x24, 0x10, 0x43, 0x00,
+0xA1, 0xFD, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x70, 0x30, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x03, 0x3C, 0xB0, 0x03, 0x62, 0x34,
+0x2A, 0xB0, 0x07, 0x3C, 0x00, 0x00, 0x54, 0xAC, 0x18, 0x00, 0xE5, 0x34,
+0x00, 0x00, 0xA9, 0x8C, 0xFF, 0x00, 0x06, 0x24, 0xFF, 0x00, 0x24, 0x31,
+0x16, 0x02, 0x86, 0x10, 0x04, 0x00, 0x02, 0x24, 0x00, 0x80, 0x22, 0x31,
+0xD6, 0x01, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0xA2, 0xAC, 0xFF, 0x00, 0x02, 0x24, 0x21, 0x00, 0x82, 0x10,
+0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31, 0x34, 0x38, 0x05, 0x8E,
+0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00,
+0x21, 0x30, 0x60, 0x00, 0x8C, 0x37, 0x09, 0xA2, 0xC8, 0x37, 0x03, 0xAE,
+0x04, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C,
+0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x09, 0x3C, 0xC0, 0x5D, 0x27, 0x91,
+0x02, 0x80, 0x08, 0x3C, 0xB0, 0x5D, 0x05, 0x8D, 0xD0, 0x1B, 0x06, 0x8E,
+0x06, 0x00, 0x02, 0x3C, 0x10, 0x00, 0xE7, 0x34, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x30, 0xC2, 0x00, 0x00, 0x02, 0xA5, 0x34, 0x00, 0x26, 0x07, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x25, 0x20, 0x85, 0x00, 0x80, 0x03, 0x42, 0x34,
+0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x66, 0xAC,
+0xB0, 0x5D, 0x05, 0xAD, 0xC0, 0x5D, 0x27, 0xA1, 0xD0, 0x1B, 0x06, 0xAE,
+0x60, 0x1B, 0x62, 0x26, 0xD4, 0x1B, 0x43, 0x8C, 0x04, 0x00, 0x04, 0x3C,
+0x60, 0x1B, 0x70, 0x26, 0x26, 0x18, 0x64, 0x00, 0xD4, 0x1B, 0x43, 0xAC,
+0xD0, 0x1B, 0x02, 0x8E, 0x08, 0x00, 0x03, 0x3C, 0x24, 0x10, 0x52, 0x00,
+0x24, 0x10, 0x43, 0x00, 0x68, 0xFD, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x70, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x05, 0x3C,
+0x1C, 0x00, 0xA3, 0x34, 0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x06, 0x24,
+0xFF, 0x00, 0x24, 0x31, 0xDD, 0x01, 0x86, 0x10, 0x25, 0xB0, 0x02, 0x3C,
+0x00, 0x80, 0x22, 0x31, 0x33, 0x01, 0x40, 0x10, 0x00, 0xFF, 0x02, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x00, 0x00, 0x62, 0xAC, 0xFF, 0x00, 0x02, 0x24,
+0x25, 0x00, 0x82, 0x10, 0x60, 0x1B, 0x70, 0x26, 0xFF, 0x00, 0x23, 0x31,
+0x40, 0x38, 0x05, 0x8E, 0x20, 0x10, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x21, 0x30, 0x60, 0x00, 0x90, 0x37, 0x09, 0xA2,
+0xD4, 0x37, 0x03, 0xAE, 0x05, 0x00, 0x04, 0x24, 0x80, 0x00, 0x07, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF, 0x02, 0x80, 0x0A, 0x3C,
+0xC0, 0x5D, 0x47, 0x91, 0x02, 0x80, 0x09, 0x3C, 0xB0, 0x5D, 0x25, 0x8D,
+0xD0, 0x1B, 0x06, 0x8E, 0x18, 0x00, 0x02, 0x3C, 0x08, 0x00, 0xE7, 0x34,
+0x27, 0x10, 0x02, 0x00, 0x24, 0x30, 0xC2, 0x00, 0x00, 0x04, 0xA5, 0x34,
+0x25, 0xB0, 0x03, 0x3C, 0x10, 0x00, 0x02, 0x3C, 0x00, 0x26, 0x07, 0x00,
+0x26, 0xA0, 0x82, 0x02, 0xB0, 0x03, 0x68, 0x34, 0x25, 0x20, 0x85, 0x00,
+0x80, 0x03, 0x63, 0x34, 0x41, 0xB0, 0x02, 0x3C, 0x00, 0x00, 0x64, 0xAC,
+0x00, 0x00, 0x46, 0xAC, 0xB0, 0x5D, 0x25, 0xAD, 0xC0, 0x5D, 0x47, 0xA1,
+0xD0, 0x1B, 0x06, 0xAE, 0x00, 0x00, 0x14, 0xAD, 0x60, 0x1B, 0x62, 0x26,
+0xD4, 0x1B, 0x43, 0x8C, 0x08, 0x00, 0x04, 0x3C, 0x26, 0x18, 0x64, 0x00,
+0x83, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x43, 0xAC, 0x70, 0x30, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xD4, 0x1B, 0x02, 0x8E, 0xD0, 0x1B, 0x03, 0x8E,
+0x00, 0x20, 0x42, 0x38, 0x62, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x02, 0xAE,
+0x70, 0x30, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2A, 0xB0, 0x02, 0x3C,
+0x08, 0x00, 0x43, 0x34, 0x00, 0x00, 0x69, 0x8C, 0xFF, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x24, 0x31, 0x2C, 0x00, 0x82, 0x10, 0x00, 0x80, 0x22, 0x31,
+0x34, 0x01, 0x40, 0x14, 0x00, 0x80, 0x02, 0x3C, 0x00, 0xFF, 0x02, 0x3C,
+0x24, 0x10, 0x22, 0x01, 0x0B, 0x00, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0xA8, 0x37, 0x02, 0x92, 0x20, 0xB0, 0x03, 0x3C, 0x00, 0x12, 0x02, 0x00,
+0x21, 0x10, 0x43, 0x00, 0x0C, 0x00, 0x49, 0x8C, 0x25, 0xB0, 0x03, 0x3C,
+0xB0, 0x03, 0x63, 0x34, 0x00, 0x00, 0x69, 0xAC, 0xFF, 0x00, 0x24, 0x31,
+0xFF, 0x00, 0x02, 0x24, 0x1A, 0x00, 0x82, 0x10, 0x60, 0x1B, 0x70, 0x26,
+0xFF, 0x00, 0x23, 0x31, 0x70, 0x38, 0x05, 0x8E, 0x20, 0x10, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x21, 0x30, 0x60, 0x00,
+0x04, 0x38, 0x03, 0xAE, 0x01, 0x00, 0x04, 0x24, 0xA8, 0x37, 0x09, 0xA2,
+0x80, 0x00, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA0, 0xAF,
+0xD0, 0x1B, 0x05, 0x8E, 0x02, 0x80, 0x06, 0x3C, 0xB0, 0x5D, 0xC4, 0x8C,
+0xFF, 0xC7, 0x02, 0x24, 0x24, 0x28, 0xA2, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x10, 0x00, 0x84, 0x34, 0x80, 0x03, 0x42, 0x34, 0x41, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x65, 0xAC, 0xB0, 0x5D, 0xC4, 0xAC,
+0xD0, 0x1B, 0x05, 0xAE, 0x60, 0x1B, 0x63, 0x26, 0xD4, 0x1B, 0x62, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x42, 0x38, 0x5B, 0x32, 0x00, 0x08,
+0xD4, 0x1B, 0x62, 0xAC, 0x56, 0x01, 0x02, 0x35, 0x00, 0x00, 0x43, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x74, 0xFC, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x7E, 0x58, 0x00, 0x0C, 0x07, 0x00, 0x04, 0x24, 0x12, 0x32, 0x00, 0x08,
+0x60, 0x1B, 0x64, 0x26, 0x00, 0x00, 0x62, 0xAC, 0xB8, 0x32, 0x00, 0x08,
+0xFF, 0x00, 0x02, 0x24, 0xE4, 0x1D, 0x24, 0x96, 0x58, 0x38, 0x26, 0x96,
+0x01, 0x00, 0x84, 0x24, 0x00, 0x19, 0x04, 0x00, 0x25, 0x30, 0xC2, 0x00,
+0xF0, 0xFF, 0x63, 0x30, 0x20, 0x00, 0xC5, 0x24, 0x02, 0x12, 0x03, 0x00,
+0xE4, 0x1D, 0x24, 0xA6, 0x17, 0x00, 0xA2, 0xA0, 0x16, 0x00, 0xA3, 0xA0,
+0x0C, 0x00, 0xC4, 0x8C, 0x00, 0xF0, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0xFF, 0x0F, 0x63, 0x30, 0x00, 0x1C, 0x03, 0x00, 0x24, 0x20, 0x82, 0x00,
+0x25, 0x20, 0x83, 0x00, 0x0C, 0x00, 0xC4, 0xAC, 0x58, 0x38, 0x25, 0x8E,
+0x01, 0x00, 0x10, 0x24, 0x01, 0x00, 0x04, 0x24, 0x31, 0x10, 0x06, 0x3C,
+0x00, 0x01, 0x07, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF,
+0x5B, 0x01, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24, 0x2A, 0xB0, 0x02, 0x3C,
+0x01, 0x00, 0x42, 0x34, 0x02, 0x00, 0x03, 0x24, 0x00, 0x00, 0x50, 0xA0,
+0x00, 0x00, 0x43, 0xA0, 0xD4, 0x1B, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x42, 0x38, 0x4D, 0x32, 0x00, 0x08, 0xD4, 0x1B, 0x22, 0xAE,
+0xD0, 0x03, 0x23, 0x35, 0x80, 0x00, 0x02, 0x24, 0x00, 0x00, 0x62, 0xAC,
+0x09, 0x33, 0x00, 0x08, 0x60, 0x1B, 0x62, 0x26, 0x25, 0xB0, 0x02, 0x3C,
+0x01, 0x00, 0x03, 0x24, 0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0xD5, 0x32, 0x00, 0x08, 0x60, 0x1B, 0x65, 0x26, 0x24, 0x10, 0x22, 0x01,
+0xA9, 0xFD, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24, 0x47, 0x00, 0xC6, 0x34,
+0x00, 0x00, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x44, 0x30,
+0x0E, 0x00, 0x85, 0x10, 0x60, 0x1B, 0x62, 0x26, 0x98, 0x37, 0x04, 0xA2,
+0x00, 0x00, 0xC2, 0x90, 0xFF, 0x00, 0x83, 0x30, 0xFF, 0x00, 0x44, 0x30,
+0x07, 0x00, 0x83, 0x10, 0x21, 0x38, 0x00, 0x02, 0x21, 0x28, 0xC0, 0x00,
+0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00, 0xFD, 0xFF, 0x62, 0x14,
+0xFF, 0x00, 0x44, 0x30, 0x98, 0x37, 0xE3, 0xA0, 0x60, 0x1B, 0x62, 0x26,
+0x98, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31, 0x00, 0x00, 0x49, 0xAC,
+0x81, 0x33, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24, 0x24, 0x10, 0x22, 0x01,
+0xFD, 0xFD, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24, 0x45, 0x00, 0xE5, 0x34,
+0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x44, 0x30,
+0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26, 0x9C, 0x37, 0x04, 0xA2,
+0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30, 0xFF, 0x00, 0x44, 0x30,
+0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26, 0x21, 0x30, 0x00, 0x02,
+0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00, 0xFD, 0xFF, 0x62, 0x14,
+0xFF, 0x00, 0x44, 0x30, 0x9C, 0x37, 0xC3, 0xA0, 0x60, 0x1B, 0x62, 0x26,
+0x9C, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31, 0x00, 0x00, 0x49, 0xAC,
+0xF6, 0x33, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24, 0x24, 0x10, 0x22, 0x01,
+0x9E, 0xFD, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24, 0x46, 0x00, 0xA5, 0x34,
+0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x44, 0x30,
+0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26, 0x94, 0x37, 0x04, 0xA2,
+0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30, 0xFF, 0x00, 0x44, 0x30,
+0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26, 0x21, 0x30, 0x00, 0x02,
+0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00, 0xFD, 0xFF, 0x62, 0x14,
+0xFF, 0x00, 0x44, 0x30, 0x94, 0x37, 0xC3, 0xA0, 0x60, 0x1B, 0x62, 0x26,
+0x94, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C, 0x00, 0x1A, 0x03, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C, 0x25, 0xB0, 0x02, 0x3C,
+0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31, 0x00, 0x00, 0x49, 0xAC,
+0xB8, 0x33, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24, 0x00, 0xFF, 0x02, 0x3C,
+0x24, 0x10, 0x22, 0x01, 0x30, 0xFE, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0x41, 0x00, 0xA5, 0x34, 0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x44, 0x30, 0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x84, 0x37, 0x04, 0xA2, 0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30,
+0xFF, 0x00, 0x44, 0x30, 0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x21, 0x30, 0x00, 0x02, 0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00,
+0xFD, 0xFF, 0x62, 0x14, 0xFF, 0x00, 0x44, 0x30, 0x84, 0x37, 0xC3, 0xA0,
+0x60, 0x1B, 0x62, 0x26, 0x84, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31,
+0x00, 0x00, 0x49, 0xAC, 0x6C, 0x34, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x24, 0x10, 0x22, 0x01, 0xCF, 0xFE, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0x44, 0x00, 0xA5, 0x34, 0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x44, 0x30, 0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x90, 0x37, 0x04, 0xA2, 0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30,
+0xFF, 0x00, 0x44, 0x30, 0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x21, 0x30, 0x00, 0x02, 0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00,
+0xFD, 0xFF, 0x62, 0x14, 0xFF, 0x00, 0x44, 0x30, 0x90, 0x37, 0xC3, 0xA0,
+0x60, 0x1B, 0x62, 0x26, 0x90, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31,
+0x00, 0x00, 0x49, 0xAC, 0x2C, 0x35, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x24, 0x10, 0x22, 0x01, 0xAE, 0xFD, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0x40, 0x00, 0xA5, 0x34, 0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x44, 0x30, 0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x80, 0x37, 0x04, 0xA2, 0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30,
+0xFF, 0x00, 0x44, 0x30, 0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x21, 0x30, 0x00, 0x02, 0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00,
+0xFD, 0xFF, 0x62, 0x14, 0xFF, 0x00, 0x44, 0x30, 0x80, 0x37, 0xC3, 0xA0,
+0x60, 0x1B, 0x62, 0x26, 0x80, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31,
+0x00, 0x00, 0x49, 0xAC, 0x2C, 0x34, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x62, 0xAC, 0x78, 0x35, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x24, 0x10, 0x22, 0x01, 0x08, 0xFE, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0x42, 0x00, 0xA5, 0x34, 0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x44, 0x30, 0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x88, 0x37, 0x04, 0xA2, 0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30,
+0xFF, 0x00, 0x44, 0x30, 0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x21, 0x30, 0x00, 0x02, 0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00,
+0xFD, 0xFF, 0x62, 0x14, 0xFF, 0x00, 0x44, 0x30, 0x88, 0x37, 0xC3, 0xA0,
+0x60, 0x1B, 0x62, 0x26, 0x88, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31,
+0x00, 0x00, 0x49, 0xAC, 0xAA, 0x34, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x24, 0x10, 0x22, 0x01, 0x2C, 0xFE, 0x40, 0x10, 0xFF, 0x00, 0x02, 0x24,
+0x43, 0x00, 0xE5, 0x34, 0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x44, 0x30, 0x0E, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x8C, 0x37, 0x04, 0xA2, 0x00, 0x00, 0xA2, 0x90, 0xFF, 0x00, 0x83, 0x30,
+0xFF, 0x00, 0x44, 0x30, 0x08, 0x00, 0x83, 0x10, 0x60, 0x1B, 0x62, 0x26,
+0x21, 0x30, 0x00, 0x02, 0x00, 0x00, 0xA2, 0x90, 0x21, 0x18, 0x80, 0x00,
+0xFD, 0xFF, 0x62, 0x14, 0xFF, 0x00, 0x44, 0x30, 0x8C, 0x37, 0xC3, 0xA0,
+0x60, 0x1B, 0x62, 0x26, 0x8C, 0x37, 0x43, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0x00, 0x1A, 0x03, 0x00, 0x21, 0x18, 0x62, 0x00, 0x0C, 0x00, 0x69, 0x8C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x03, 0x42, 0x34, 0xFF, 0x00, 0x24, 0x31,
+0x00, 0x00, 0x49, 0xAC, 0xEF, 0x34, 0x00, 0x08, 0xFF, 0x00, 0x02, 0x24,
+0x06, 0x00, 0x03, 0x24, 0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x90, 0x34, 0x00, 0x08, 0x60, 0x1B, 0x62, 0x26, 0x01, 0x00, 0x03, 0x24,
+0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0xA4, 0x33, 0x00, 0x08,
+0x60, 0x1B, 0x62, 0x26, 0x25, 0xB0, 0x02, 0x3C, 0x07, 0x00, 0x03, 0x24,
+0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x60, 0x1B, 0x63, 0x26,
+0xD4, 0x1B, 0x62, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x42, 0x38,
+0x56, 0x34, 0x00, 0x08, 0xD4, 0x1B, 0x62, 0xAC, 0x00, 0x00, 0x40, 0xAC,
+0x19, 0x34, 0x00, 0x08, 0x60, 0x1B, 0x62, 0x26, 0x02, 0x00, 0x03, 0x24,
+0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0xDF, 0x33, 0x00, 0x08,
+0x60, 0x1B, 0x62, 0x26, 0x90, 0x03, 0x63, 0x34, 0x00, 0x00, 0x62, 0xAC,
+0x12, 0x35, 0x00, 0x08, 0x60, 0x1B, 0x62, 0x26, 0x03, 0x00, 0x03, 0x24,
+0x90, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x53, 0x35, 0x00, 0x08,
+0x60, 0x1B, 0x62, 0x26, 0x05, 0x00, 0x03, 0x24, 0x90, 0x03, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0xD1, 0x34, 0x00, 0x08, 0x60, 0x1B, 0x62, 0x26,
+0xE0, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x25, 0xB0, 0x0C, 0x3C,
+0x01, 0x80, 0x02, 0x3C, 0x18, 0x03, 0x83, 0x35, 0x30, 0xDC, 0x42, 0x24,
+0x02, 0x80, 0x12, 0x3C, 0x41, 0xB0, 0x0B, 0x3C, 0x00, 0x00, 0x62, 0xAC,
+0x60, 0x1B, 0x4A, 0x26, 0x0A, 0x00, 0x62, 0x35, 0x00, 0x00, 0x44, 0x94,
+0xDE, 0x1B, 0x43, 0x95, 0xDC, 0x1B, 0x49, 0x95, 0x25, 0x30, 0x64, 0x00,
+0xFF, 0xFF, 0xD0, 0x30, 0x24, 0x10, 0x09, 0x02, 0x02, 0x00, 0x42, 0x30,
+0xC2, 0x00, 0x40, 0x10, 0xC0, 0x03, 0x83, 0x35, 0x02, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x62, 0xAC, 0x02, 0x80, 0x08, 0x3C, 0xB0, 0x5D, 0x04, 0x8D,
+0xDC, 0x02, 0x82, 0x35, 0x00, 0x00, 0x47, 0x90, 0xFD, 0xFF, 0x03, 0x24,
+0x00, 0x80, 0x02, 0x3C, 0x24, 0x18, 0x23, 0x01, 0x25, 0x20, 0x82, 0x00,
+0x02, 0x00, 0xC6, 0x38, 0x08, 0x00, 0x65, 0x35, 0x02, 0x80, 0x02, 0x3C,
+0xED, 0x5D, 0x47, 0xA0, 0xB0, 0x5D, 0x04, 0xAD, 0xDE, 0x1B, 0x46, 0xA5,
+0x21, 0x48, 0x60, 0x00, 0x00, 0x00, 0xA3, 0xA4, 0xDC, 0x1B, 0x43, 0xA5,
+0x24, 0x38, 0x09, 0x02, 0x04, 0x00, 0xE2, 0x30, 0x0A, 0x00, 0x40, 0x10,
+0x08, 0x00, 0xE2, 0x30, 0xDE, 0x1B, 0x43, 0x95, 0x0C, 0x00, 0x64, 0x35,
+0xC0, 0x03, 0x85, 0x35, 0x04, 0x00, 0x63, 0x38, 0x04, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x86, 0x90, 0x00, 0x00, 0xA2, 0xAC, 0xDE, 0x1B, 0x43, 0xA5,
+0x08, 0x00, 0xE2, 0x30, 0x08, 0x00, 0x40, 0x10, 0x10, 0x00, 0xE2, 0x30,
+0xDE, 0x1B, 0x42, 0x95, 0xC0, 0x03, 0x84, 0x35, 0x08, 0x00, 0x03, 0x24,
+0x08, 0x00, 0x42, 0x38, 0x00, 0x00, 0x83, 0xAC, 0xDE, 0x1B, 0x42, 0xA5,
+0x10, 0x00, 0xE2, 0x30, 0x08, 0x00, 0x40, 0x10, 0x20, 0x00, 0xE2, 0x30,
+0xDE, 0x1B, 0x42, 0x95, 0xC0, 0x03, 0x84, 0x35, 0x10, 0x00, 0x03, 0x24,
+0x10, 0x00, 0x42, 0x38, 0x00, 0x00, 0x83, 0xAC, 0xDE, 0x1B, 0x42, 0xA5,
+0x20, 0x00, 0xE2, 0x30, 0x08, 0x00, 0x40, 0x10, 0x80, 0x00, 0xE2, 0x30,
+0xDE, 0x1B, 0x42, 0x95, 0xC0, 0x03, 0x84, 0x35, 0x20, 0x00, 0x03, 0x24,
+0x20, 0x00, 0x42, 0x38, 0x00, 0x00, 0x83, 0xAC, 0xDE, 0x1B, 0x42, 0xA5,
+0x80, 0x00, 0xE2, 0x30, 0x74, 0x00, 0x40, 0x10, 0x60, 0x1B, 0x47, 0x26,
+0xC0, 0x03, 0x83, 0x35, 0x80, 0x00, 0x02, 0x24, 0x42, 0xB0, 0x0B, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0x03, 0x00, 0x71, 0x35, 0xDE, 0x1B, 0x42, 0x95,
+0x00, 0x00, 0x23, 0x92, 0x80, 0x00, 0x42, 0x38, 0x20, 0x00, 0x63, 0x30,
+0x59, 0x00, 0x60, 0x10, 0xDE, 0x1B, 0x42, 0xA5, 0x20, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x22, 0xA2, 0x02, 0x80, 0x03, 0x3C, 0x0F, 0x5E, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x75, 0x00, 0x40, 0x14, 0x21, 0x40, 0x00, 0x00,
+0xB0, 0x1B, 0x42, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30,
+0x4E, 0x00, 0x40, 0x10, 0x02, 0x80, 0x06, 0x3C, 0x02, 0x80, 0x07, 0x3C,
+0xEC, 0x5D, 0xE2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x09, 0x3C, 0x02, 0x80, 0x04, 0x3C, 0xF8, 0x5D, 0x82, 0x8C,
+0x18, 0x5E, 0x24, 0x8D, 0x1C, 0x5E, 0x25, 0x8D, 0x21, 0x18, 0x00, 0x00,
+0x21, 0x10, 0x44, 0x00, 0x2B, 0x30, 0x44, 0x00, 0x21, 0x18, 0x65, 0x00,
+0x21, 0x18, 0x66, 0x00, 0x18, 0x5E, 0x22, 0xAD, 0x1C, 0x5E, 0x23, 0xAD,
+0xEC, 0x5D, 0xE4, 0x90, 0x02, 0x00, 0x02, 0x24, 0xFF, 0x00, 0x84, 0x30,
+0x07, 0x00, 0x82, 0x10, 0x02, 0x80, 0x04, 0x3C, 0xEC, 0x5D, 0xE2, 0x90,
+0x03, 0x00, 0x03, 0x24, 0xFF, 0x00, 0x42, 0x30, 0x5A, 0x00, 0x43, 0x14,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x04, 0x3C, 0x0A, 0x5E, 0x82, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x42, 0x24, 0x0A, 0x5E, 0x82, 0xA0,
+0x0A, 0x5E, 0x83, 0x90, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x60, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0xF2, 0x5D, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x03, 0x00, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x00, 0x11,
+0x80, 0x00, 0x86, 0x35, 0x0A, 0x5E, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x06, 0x00, 0x40, 0x14, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0x09, 0x5E, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x5E, 0x83, 0xA0,
+0x02, 0x80, 0x05, 0x3C, 0x07, 0x5E, 0xA2, 0x90, 0x02, 0x80, 0x03, 0x3C,
+0x02, 0x00, 0x04, 0x24, 0x10, 0x00, 0x42, 0x34, 0x07, 0x5E, 0xA2, 0xA0,
+0xF1, 0x5D, 0x62, 0x90, 0x21, 0x28, 0x00, 0x00, 0xFF, 0x00, 0x42, 0x30,
+0x80, 0x30, 0x02, 0x00, 0x21, 0x30, 0xC2, 0x00, 0xB9, 0x20, 0x00, 0x0C,
+0x00, 0x33, 0x06, 0x00, 0x42, 0xB0, 0x02, 0x3C, 0x44, 0x00, 0x04, 0x24,
+0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x44, 0xA0, 0x02, 0x80, 0x03, 0x3C,
+0xEE, 0x5D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30,
+0x04, 0x00, 0x42, 0x28, 0x05, 0x00, 0x40, 0x10, 0x02, 0x80, 0x06, 0x3C,
+0x04, 0x00, 0x04, 0x24, 0x4B, 0x2E, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24,
+0x02, 0x80, 0x06, 0x3C, 0xB0, 0x5D, 0xC4, 0x8C, 0x60, 0x1B, 0x47, 0x26,
+0xDC, 0x1B, 0xE5, 0x94, 0x10, 0x00, 0x02, 0x3C, 0x25, 0x20, 0x82, 0x00,
+0x41, 0xB0, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C, 0x7F, 0xFF, 0xA5, 0x30,
+0xB0, 0x03, 0x42, 0x34, 0x08, 0x00, 0x63, 0x34, 0x00, 0x00, 0x44, 0xAC,
+0x00, 0x00, 0x65, 0xA4, 0xB0, 0x5D, 0xC4, 0xAC, 0xDC, 0x1B, 0xE5, 0xA4,
+0x60, 0x1B, 0x47, 0x26, 0xDC, 0x1B, 0xE2, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x10, 0x50, 0x00, 0x00, 0x30, 0x42, 0x30, 0x06, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xDE, 0x1B, 0xE2, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x10, 0x42, 0x38, 0x00, 0x20, 0x42, 0x34, 0xDE, 0x1B, 0xE2, 0xA4,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x36, 0x37, 0x00, 0x08, 0xDE, 0x1B, 0x46, 0xA5, 0x01, 0x00, 0x08, 0x24,
+0x0F, 0x5E, 0x60, 0xA0, 0x72, 0x37, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x07, 0x5E, 0xA2, 0x90, 0x02, 0x80, 0x03, 0x3C, 0x02, 0x00, 0x04, 0x24,
+0x10, 0x00, 0x42, 0x34, 0x07, 0x5E, 0xA2, 0xA0, 0xF1, 0x5D, 0x62, 0x90,
+0x21, 0x28, 0x00, 0x00, 0xFF, 0x00, 0x42, 0x30, 0x80, 0x30, 0x02, 0x00,
+0x21, 0x30, 0xC2, 0x00, 0xB9, 0x20, 0x00, 0x0C, 0x00, 0x33, 0x06, 0x00,
+0x44, 0x00, 0x02, 0x24, 0x00, 0x00, 0x22, 0xA2, 0xBA, 0x37, 0x00, 0x08,
+0x02, 0x80, 0x03, 0x3C, 0x84, 0x00, 0x84, 0x35, 0x00, 0x00, 0x82, 0x8C,
+0x02, 0x80, 0x08, 0x3C, 0x00, 0x00, 0xC4, 0x8C, 0x14, 0x5E, 0x06, 0x8D,
+0x21, 0x10, 0x00, 0x00, 0x18, 0x5E, 0x28, 0x8D, 0x1C, 0x5E, 0x29, 0x8D,
+0x00, 0x00, 0x65, 0x91, 0x25, 0x10, 0x44, 0x00, 0x21, 0x10, 0x46, 0x00,
+0xFB, 0xFF, 0x04, 0x24, 0x24, 0x28, 0xA4, 0x00, 0x23, 0x40, 0x02, 0x01,
+0x00, 0x00, 0x65, 0xA1, 0x04, 0x00, 0x00, 0x11, 0x01, 0x00, 0x06, 0x24,
+0x80, 0x10, 0x08, 0x00, 0x21, 0x10, 0x48, 0x00, 0x80, 0x30, 0x02, 0x00,
+0x01, 0x00, 0x04, 0x24, 0xB9, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0x42, 0xB0, 0x02, 0x3C, 0x22, 0x00, 0x03, 0x24, 0x03, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xA0, 0xC4, 0x37, 0x00, 0x08, 0x02, 0x80, 0x06, 0x3C,
+0xF0, 0xFF, 0xBD, 0x27, 0x08, 0x00, 0xB2, 0xAF, 0x04, 0x00, 0xB1, 0xAF,
+0x00, 0x00, 0xB0, 0xAF, 0x00, 0x40, 0x09, 0x40, 0x00, 0x68, 0x0A, 0x40,
+0x00, 0x70, 0x02, 0x40, 0x00, 0x60, 0x0B, 0x40, 0x25, 0xB0, 0x05, 0x3C,
+0x18, 0x03, 0xA7, 0x34, 0x00, 0x00, 0xE6, 0x8C, 0x01, 0x80, 0x02, 0x3C,
+0x1C, 0x03, 0xA3, 0x34, 0x5C, 0xE0, 0x42, 0x24, 0x00, 0x00, 0x66, 0xAC,
+0x00, 0x00, 0xE2, 0xAC, 0x80, 0x00, 0x83, 0x8C, 0x7C, 0x02, 0xA2, 0x34,
+0x80, 0x02, 0xA6, 0x34, 0x84, 0x02, 0xA7, 0x34, 0x88, 0x02, 0xA8, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0x00, 0x00, 0xC9, 0xAC, 0x00, 0x00, 0xEA, 0xAC,
+0x00, 0x00, 0x0B, 0xAD, 0x74, 0x00, 0x83, 0x8C, 0x8C, 0x02, 0xA2, 0x34,
+0x90, 0x02, 0xA7, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x08, 0x00, 0x86, 0x8C,
+0x94, 0x02, 0xA8, 0x34, 0x98, 0x02, 0xA9, 0x34, 0x00, 0x00, 0xE6, 0xAC,
+0x0C, 0x00, 0x82, 0x8C, 0x9C, 0x02, 0xA6, 0x34, 0xA0, 0x02, 0xA7, 0x34,
+0x00, 0x00, 0x02, 0xAD, 0x10, 0x00, 0x83, 0x8C, 0xA4, 0x02, 0xA8, 0x34,
+0xA8, 0x02, 0xAA, 0x34, 0x00, 0x00, 0x23, 0xAD, 0x14, 0x00, 0x82, 0x8C,
+0xAC, 0x02, 0xA9, 0x34, 0xB0, 0x02, 0xAB, 0x34, 0x00, 0x00, 0xC2, 0xAC,
+0x18, 0x00, 0x83, 0x8C, 0xB4, 0x02, 0xAC, 0x34, 0xB8, 0x02, 0xAD, 0x34,
+0x00, 0x00, 0xE3, 0xAC, 0x1C, 0x00, 0x82, 0x8C, 0xBC, 0x02, 0xA7, 0x34,
+0xC0, 0x02, 0xAE, 0x34, 0x00, 0x00, 0x02, 0xAD, 0x20, 0x00, 0x83, 0x8C,
+0xC4, 0x02, 0xA8, 0x34, 0xC8, 0x02, 0xAF, 0x34, 0x00, 0x00, 0x43, 0xAD,
+0x24, 0x00, 0x82, 0x8C, 0xCC, 0x02, 0xAA, 0x34, 0xD0, 0x02, 0xB0, 0x34,
+0x00, 0x00, 0x22, 0xAD, 0x28, 0x00, 0x83, 0x8C, 0xD4, 0x02, 0xA9, 0x34,
+0xD8, 0x02, 0xB1, 0x34, 0x00, 0x00, 0x63, 0xAD, 0x2C, 0x00, 0x86, 0x8C,
+0x70, 0x02, 0xAB, 0x34, 0x74, 0x02, 0xB2, 0x34, 0x00, 0x00, 0x86, 0xAD,
+0x30, 0x00, 0x82, 0x8C, 0x78, 0x02, 0xA6, 0x34, 0x6C, 0x03, 0xAC, 0x34,
+0x00, 0x00, 0xA2, 0xAD, 0x34, 0x00, 0x83, 0x8C, 0x02, 0x80, 0x02, 0x3C,
+0x00, 0x00, 0xE3, 0xAC, 0x38, 0x00, 0x85, 0x8C, 0xE0, 0xC8, 0x47, 0x8C,
+0x00, 0x00, 0xC5, 0xAD, 0x3C, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x02, 0xAD, 0x40, 0x00, 0x83, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xE3, 0xAD, 0x44, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x42, 0xAD, 0x48, 0x00, 0x83, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x03, 0xAE, 0x4C, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x22, 0xAD, 0x50, 0x00, 0x83, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x23, 0xAE, 0x54, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x62, 0xAD, 0x58, 0x00, 0x83, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x43, 0xAE, 0x5C, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC2, 0xAC, 0x21, 0x10, 0xE0, 0x00, 0x00, 0x00, 0x82, 0xAD,
+0x01, 0x00, 0xE7, 0x24, 0x21, 0x10, 0xE0, 0x00, 0x01, 0x00, 0xE7, 0x24,
+0x00, 0x00, 0x82, 0xAD, 0x82, 0x38, 0x00, 0x08, 0x21, 0x10, 0xE0, 0x00,
+0x01, 0x80, 0x1B, 0x3C, 0x24, 0xE2, 0x7B, 0x27, 0x25, 0xB0, 0x1A, 0x3C,
+0x18, 0x03, 0x5A, 0x27, 0x00, 0x00, 0x5B, 0xAF, 0x21, 0xD8, 0xA0, 0x03,
+0x82, 0xDA, 0x1B, 0x00, 0x80, 0xDA, 0x1B, 0x00, 0x08, 0x00, 0x7B, 0x27,
+0x04, 0x00, 0x61, 0xAF, 0x08, 0x00, 0x62, 0xAF, 0x0C, 0x00, 0x63, 0xAF,
+0x10, 0x00, 0x64, 0xAF, 0x14, 0x00, 0x65, 0xAF, 0x18, 0x00, 0x66, 0xAF,
+0x1C, 0x00, 0x67, 0xAF, 0x20, 0x00, 0x68, 0xAF, 0x24, 0x00, 0x69, 0xAF,
+0x28, 0x00, 0x6A, 0xAF, 0x2C, 0x00, 0x6B, 0xAF, 0x30, 0x00, 0x6C, 0xAF,
+0x34, 0x00, 0x6D, 0xAF, 0x38, 0x00, 0x6E, 0xAF, 0x3C, 0x00, 0x6F, 0xAF,
+0x12, 0x40, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00, 0x00, 0x70, 0x0A, 0x40,
+0x40, 0x00, 0x70, 0xAF, 0x44, 0x00, 0x71, 0xAF, 0x48, 0x00, 0x72, 0xAF,
+0x4C, 0x00, 0x73, 0xAF, 0x50, 0x00, 0x74, 0xAF, 0x54, 0x00, 0x75, 0xAF,
+0x58, 0x00, 0x76, 0xAF, 0x5C, 0x00, 0x77, 0xAF, 0x60, 0x00, 0x78, 0xAF,
+0x64, 0x00, 0x79, 0xAF, 0x68, 0x00, 0x7C, 0xAF, 0x6C, 0x00, 0x7D, 0xAF,
+0x70, 0x00, 0x7E, 0xAF, 0x74, 0x00, 0x7F, 0xAF, 0x78, 0x00, 0x68, 0xAF,
+0x7C, 0x00, 0x69, 0xAF, 0x80, 0x00, 0x6A, 0xAF, 0x00, 0x68, 0x1A, 0x40,
+0x25, 0xB0, 0x1B, 0x3C, 0x1C, 0x03, 0x7B, 0x37, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x7A, 0xAF, 0x7F, 0x00, 0x5B, 0x33, 0x30, 0x00, 0x60, 0x13,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x1B, 0x3C, 0x30, 0x03, 0x7B, 0x37,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xAF, 0x00, 0x00, 0x00, 0x00,
+0x21, 0xD8, 0xA0, 0x03, 0x82, 0xDA, 0x1B, 0x00, 0x80, 0xDA, 0x1B, 0x00,
+0x08, 0x00, 0x7B, 0x27, 0x04, 0x00, 0x61, 0xAF, 0x08, 0x00, 0x62, 0xAF,
+0x0C, 0x00, 0x63, 0xAF, 0x10, 0x00, 0x64, 0xAF, 0x14, 0x00, 0x65, 0xAF,
+0x18, 0x00, 0x66, 0xAF, 0x1C, 0x00, 0x67, 0xAF, 0x20, 0x00, 0x68, 0xAF,
+0x24, 0x00, 0x69, 0xAF, 0x28, 0x00, 0x6A, 0xAF, 0x2C, 0x00, 0x6B, 0xAF,
+0x30, 0x00, 0x6C, 0xAF, 0x34, 0x00, 0x6D, 0xAF, 0x38, 0x00, 0x6E, 0xAF,
+0x3C, 0x00, 0x6F, 0xAF, 0x12, 0x40, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00,
+0x00, 0x70, 0x0A, 0x40, 0x40, 0x00, 0x70, 0xAF, 0x44, 0x00, 0x71, 0xAF,
+0x48, 0x00, 0x72, 0xAF, 0x4C, 0x00, 0x73, 0xAF, 0x50, 0x00, 0x74, 0xAF,
+0x54, 0x00, 0x75, 0xAF, 0x58, 0x00, 0x76, 0xAF, 0x5C, 0x00, 0x77, 0xAF,
+0x60, 0x00, 0x78, 0xAF, 0x64, 0x00, 0x79, 0xAF, 0x68, 0x00, 0x7C, 0xAF,
+0x6C, 0x00, 0x7D, 0xAF, 0x70, 0x00, 0x7E, 0xAF, 0x74, 0x00, 0x7F, 0xAF,
+0x78, 0x00, 0x68, 0xAF, 0x7C, 0x00, 0x69, 0xAF, 0x80, 0x00, 0x6A, 0xAF,
+0x17, 0x38, 0x00, 0x08, 0x21, 0x20, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x08, 0x3C, 0x20, 0x03, 0x08, 0x35, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x1A, 0xAD, 0x00, 0x04, 0x5B, 0x33, 0x0A, 0x00, 0x60, 0x13,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x08, 0x3C, 0xE0, 0xC7, 0x08, 0x25,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x1B, 0x3C, 0x24, 0x03, 0x7B, 0x37,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xAF, 0x09, 0xF8, 0x00, 0x01,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x5B, 0x33, 0x25, 0xB0, 0x08, 0x3C,
+0x28, 0x03, 0x08, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xAD,
+0x06, 0x00, 0x60, 0x13, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x08, 0x3C,
+0x30, 0xDC, 0x08, 0x25, 0x00, 0x00, 0x00, 0x00, 0x09, 0xF8, 0x00, 0x01,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x1A, 0x3C, 0xB0, 0x5D, 0x5A, 0x27,
+0x04, 0x00, 0x5B, 0x97, 0x25, 0xB0, 0x08, 0x3C, 0x30, 0x03, 0x08, 0x35,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xAD, 0x18, 0x00, 0x60, 0x13,
+0x00, 0x00, 0x00, 0x00, 0x08, 0xE8, 0x9B, 0x27, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x61, 0x8F, 0xFC, 0x03, 0x70, 0x7B, 0x7C, 0x00, 0x62, 0x7B,
+0xBC, 0x00, 0x64, 0x7B, 0xFC, 0x00, 0x66, 0x7B, 0x3C, 0x01, 0x68, 0x7B,
+0x13, 0x00, 0x00, 0x02, 0x11, 0x00, 0x20, 0x02, 0x7C, 0x01, 0x6A, 0x7B,
+0xBC, 0x01, 0x6C, 0x7B, 0xFC, 0x01, 0x6E, 0x7B, 0x3C, 0x02, 0x70, 0x7B,
+0x7C, 0x02, 0x72, 0x7B, 0xBC, 0x02, 0x74, 0x7B, 0xFC, 0x02, 0x76, 0x7B,
+0x3C, 0x03, 0x78, 0x7B, 0x7C, 0x03, 0x7C, 0x7B, 0xBC, 0x03, 0x7E, 0x7B,
+0x80, 0x00, 0x7B, 0x8F, 0x74, 0x39, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x21, 0xD8, 0xA0, 0x03, 0x82, 0xDA, 0x1B, 0x00, 0x80, 0xDA, 0x1B, 0x00,
+0x08, 0x00, 0x7B, 0x27, 0x08, 0x00, 0x5B, 0xAF, 0xFC, 0xEB, 0x9D, 0x27,
+0x00, 0x00, 0x4A, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x40, 0x11,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x08, 0x3C, 0x10, 0x5D, 0x08, 0x25,
+0x21, 0x48, 0x00, 0x00, 0x21, 0x58, 0x00, 0x00, 0x01, 0x00, 0x6B, 0x25,
+0x1A, 0x00, 0x40, 0x11, 0x24, 0x70, 0x4B, 0x01, 0x14, 0x00, 0xC0, 0x11,
+0x01, 0x00, 0x04, 0x24, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x44, 0xA3,
+0x26, 0x50, 0x4B, 0x01, 0x00, 0x00, 0x4A, 0xAF, 0x80, 0x80, 0x09, 0x00,
+0x21, 0x80, 0x08, 0x02, 0x00, 0x00, 0x10, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x09, 0xF8, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x1B, 0x3C,
+0xFC, 0xE4, 0x7B, 0x27, 0x25, 0xB0, 0x1A, 0x3C, 0x18, 0x03, 0x5A, 0x27,
+0x00, 0x00, 0x5B, 0xAF, 0x02, 0x80, 0x1A, 0x3C, 0xB0, 0x5D, 0x5A, 0x27,
+0xE1, 0xFF, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x29, 0x25,
+0x40, 0x58, 0x0B, 0x00, 0x37, 0x39, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x1B, 0x3C, 0xB0, 0x5D, 0x7B, 0x27, 0x21, 0x60, 0x00, 0x00,
+0x04, 0x00, 0x6C, 0xA7, 0x08, 0x00, 0x7A, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0xF8, 0xFF, 0x5A, 0x27, 0x00, 0x00, 0x5A, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x5A, 0x27, 0x84, 0x00, 0x44, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0xF9, 0xFF, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x41, 0x8F,
+0xFC, 0x03, 0x50, 0x7B, 0x7C, 0x00, 0x42, 0x7B, 0xBC, 0x00, 0x44, 0x7B,
+0xFC, 0x00, 0x46, 0x7B, 0x3C, 0x01, 0x48, 0x7B, 0x13, 0x00, 0x00, 0x02,
+0x11, 0x00, 0x20, 0x02, 0x7C, 0x01, 0x4A, 0x7B, 0xBC, 0x01, 0x4C, 0x7B,
+0xFC, 0x01, 0x4E, 0x7B, 0x3C, 0x02, 0x50, 0x7B, 0x7C, 0x02, 0x52, 0x7B,
+0xBC, 0x02, 0x54, 0x7B, 0xFC, 0x02, 0x56, 0x7B, 0x3C, 0x03, 0x58, 0x7B,
+0x7C, 0x03, 0x5C, 0x7B, 0xBC, 0x03, 0x5E, 0x7B, 0x80, 0x00, 0x5B, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x60, 0x03, 0x10, 0x00, 0x00, 0x42,
+0x00, 0x60, 0x05, 0x40, 0x42, 0x28, 0x05, 0x00, 0x40, 0x28, 0x05, 0x00,
+0x00, 0x60, 0x85, 0x40, 0x04, 0x00, 0x81, 0xAC, 0x08, 0x00, 0x82, 0xAC,
+0x0C, 0x00, 0x83, 0xAC, 0x20, 0x00, 0x88, 0xAC, 0x24, 0x00, 0x89, 0xAC,
+0x28, 0x00, 0x8A, 0xAC, 0x2C, 0x00, 0x8B, 0xAC, 0x30, 0x00, 0x8C, 0xAC,
+0x34, 0x00, 0x8D, 0xAC, 0x38, 0x00, 0x8E, 0xAC, 0x3C, 0x00, 0x8F, 0xAC,
+0x12, 0x40, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00, 0x40, 0x00, 0x90, 0xAC,
+0x44, 0x00, 0x91, 0xAC, 0x48, 0x00, 0x92, 0xAC, 0x4C, 0x00, 0x93, 0xAC,
+0x50, 0x00, 0x94, 0xAC, 0x54, 0x00, 0x95, 0xAC, 0x58, 0x00, 0x96, 0xAC,
+0x5C, 0x00, 0x97, 0xAC, 0x60, 0x00, 0x98, 0xAC, 0x64, 0x00, 0x99, 0xAC,
+0x68, 0x00, 0x9C, 0xAC, 0x6C, 0x00, 0x9D, 0xAC, 0x70, 0x00, 0x9E, 0xAC,
+0x74, 0x00, 0x9F, 0xAC, 0x78, 0x00, 0x88, 0xAC, 0x7C, 0x00, 0x89, 0xAC,
+0x80, 0x00, 0x9F, 0xAC, 0xF8, 0xFF, 0x84, 0x24, 0x00, 0x00, 0x84, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x84, 0x24, 0x84, 0x00, 0x86, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0xF9, 0xFF, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x21, 0xD8, 0x80, 0x00, 0x01, 0x00, 0xBA, 0x34, 0x04, 0x00, 0x61, 0x8F,
+0xFC, 0x03, 0x70, 0x7B, 0x7C, 0x00, 0x62, 0x7B, 0xBC, 0x00, 0x64, 0x7B,
+0xFC, 0x00, 0x66, 0x7B, 0x3C, 0x01, 0x68, 0x7B, 0x13, 0x00, 0x00, 0x02,
+0x11, 0x00, 0x20, 0x02, 0x7C, 0x01, 0x6A, 0x7B, 0xBC, 0x01, 0x6C, 0x7B,
+0xFC, 0x01, 0x6E, 0x7B, 0x3C, 0x02, 0x70, 0x7B, 0x7C, 0x02, 0x72, 0x7B,
+0xBC, 0x02, 0x74, 0x7B, 0xFC, 0x02, 0x76, 0x7B, 0x3C, 0x03, 0x78, 0x7B,
+0x7C, 0x03, 0x7C, 0x7B, 0xBC, 0x03, 0x7E, 0x7B, 0x80, 0x00, 0x7B, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x60, 0x03, 0x00, 0x60, 0x9A, 0x40,
+0x00, 0x60, 0x05, 0x40, 0x42, 0x28, 0x05, 0x00, 0x40, 0x28, 0x05, 0x00,
+0x00, 0x60, 0x85, 0x40, 0x04, 0x00, 0x81, 0xAC, 0x08, 0x00, 0x82, 0xAC,
+0x0C, 0x00, 0x83, 0xAC, 0x20, 0x00, 0x88, 0xAC, 0x24, 0x00, 0x89, 0xAC,
+0x28, 0x00, 0x8A, 0xAC, 0x2C, 0x00, 0x8B, 0xAC, 0x30, 0x00, 0x8C, 0xAC,
+0x34, 0x00, 0x8D, 0xAC, 0x38, 0x00, 0x8E, 0xAC, 0x3C, 0x00, 0x8F, 0xAC,
+0x12, 0x40, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00, 0x40, 0x00, 0x90, 0xAC,
+0x44, 0x00, 0x91, 0xAC, 0x48, 0x00, 0x92, 0xAC, 0x4C, 0x00, 0x93, 0xAC,
+0x50, 0x00, 0x94, 0xAC, 0x54, 0x00, 0x94, 0xAC, 0x58, 0x00, 0x96, 0xAC,
+0x5C, 0x00, 0x96, 0xAC, 0x60, 0x00, 0x98, 0xAC, 0x64, 0x00, 0x99, 0xAC,
+0x68, 0x00, 0x9C, 0xAC, 0x6C, 0x00, 0x9D, 0xAC, 0x70, 0x00, 0x9E, 0xAC,
+0x78, 0x00, 0x88, 0xAC, 0x7C, 0x00, 0x89, 0xAC, 0x80, 0x00, 0x9F, 0xAC,
+0x84, 0x00, 0x80, 0xAC, 0xF8, 0xFF, 0x84, 0x24, 0x00, 0x00, 0x84, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x84, 0x24, 0x84, 0x00, 0x86, 0x8C,
+0xFA, 0xFF, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0xD8, 0x80, 0x00,
+0x01, 0x00, 0xBA, 0x24, 0x04, 0x00, 0x61, 0x8F, 0xFC, 0x03, 0x70, 0x7B,
+0x7C, 0x00, 0x62, 0x7B, 0xBC, 0x00, 0x64, 0x7B, 0xFC, 0x00, 0x66, 0x7B,
+0x3C, 0x01, 0x68, 0x7B, 0x13, 0x00, 0x00, 0x02, 0x11, 0x00, 0x20, 0x02,
+0x7C, 0x01, 0x6A, 0x7B, 0xBC, 0x01, 0x6C, 0x7B, 0xFC, 0x01, 0x6E, 0x7B,
+0x3C, 0x02, 0x70, 0x7B, 0x7C, 0x02, 0x72, 0x7B, 0xBC, 0x02, 0x74, 0x7B,
+0xFC, 0x02, 0x76, 0x7B, 0x3C, 0x03, 0x78, 0x7B, 0x7C, 0x03, 0x7C, 0x7B,
+0xBC, 0x03, 0x7E, 0x7B, 0x80, 0x00, 0x7B, 0x8F, 0x08, 0x00, 0x60, 0x03,
+0x00, 0x60, 0x9A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x23, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x1B, 0x3C,
+0x00, 0x00, 0x7B, 0x27, 0x25, 0xB0, 0x1A, 0x3C, 0x18, 0x03, 0x5A, 0x27,
+0x00, 0x00, 0x5B, 0xAF, 0x00, 0x00, 0x05, 0x24, 0x03, 0x00, 0xA4, 0x24,
+0x00, 0xA0, 0x80, 0x40, 0x00, 0xA0, 0x84, 0x40, 0x01, 0x80, 0x04, 0x3C,
+0x40, 0x00, 0x84, 0x24, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x80, 0x1B, 0x3C, 0x40, 0x00, 0x7B, 0x27, 0x25, 0xB0, 0x1A, 0x3C,
+0x18, 0x03, 0x5A, 0x27, 0x00, 0x00, 0x5B, 0xAF, 0x02, 0x80, 0x1A, 0x3C,
+0x00, 0x00, 0x5A, 0x27, 0xFC, 0x03, 0x5D, 0x27, 0x02, 0x80, 0x1C, 0x3C,
+0x00, 0x18, 0x9C, 0x27, 0x00, 0xF0, 0x08, 0x3C, 0x00, 0x0C, 0x08, 0x35,
+0x00, 0x60, 0x88, 0x40, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x84, 0x24,
+0xFF, 0x7F, 0x05, 0x3C, 0xFF, 0xFF, 0xA5, 0x34, 0x24, 0x20, 0x85, 0x00,
+0x00, 0x20, 0x84, 0x4C, 0xFF, 0xFF, 0x05, 0x34, 0x21, 0x28, 0xA4, 0x00,
+0x00, 0x28, 0x85, 0x4C, 0x02, 0x80, 0x08, 0x3C, 0x00, 0x00, 0x08, 0x25,
+0x00, 0x00, 0x00, 0xAD, 0x03, 0x80, 0x09, 0x3C, 0x04, 0xDD, 0x29, 0x25,
+0x04, 0x00, 0x08, 0x25, 0xFE, 0xFF, 0x09, 0x15, 0x00, 0x00, 0x00, 0xAD,
+0x00, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x84, 0x24, 0xFF, 0x7F, 0x05, 0x3C,
+0xFF, 0xFF, 0xA5, 0x34, 0x24, 0x20, 0x85, 0x00, 0x00, 0x00, 0x84, 0x4C,
+0xFF, 0xFF, 0x06, 0x34, 0x21, 0x30, 0xC4, 0x00, 0x24, 0x30, 0xC5, 0x00,
+0x00, 0x08, 0x86, 0x4C, 0x00, 0xA0, 0x04, 0x40, 0x10, 0x00, 0x84, 0x34,
+0x00, 0xA0, 0x84, 0x40, 0x01, 0x80, 0x1B, 0x3C, 0xEC, 0x00, 0x7B, 0x27,
+0x25, 0xB0, 0x1A, 0x3C, 0x18, 0x03, 0x5A, 0x27, 0x00, 0x00, 0x5B, 0xAF,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x04, 0x3C, 0x44, 0x00, 0x84, 0x34,
+0x00, 0x00, 0x85, 0x84, 0x20, 0x00, 0x06, 0x24, 0x25, 0x28, 0xA6, 0x00,
+0x00, 0x00, 0x85, 0xA4, 0x01, 0x80, 0x1B, 0x3C, 0x1C, 0x01, 0x7B, 0x27,
+0x25, 0xB0, 0x1A, 0x3C, 0x18, 0x03, 0x5A, 0x27, 0x00, 0x00, 0x5B, 0xAF,
+0x25, 0xB0, 0x04, 0x3C, 0x44, 0x00, 0x84, 0x34, 0x00, 0x00, 0x85, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xA5, 0x30, 0xFC, 0xFF, 0xA0, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x07, 0x3C, 0xFF, 0xFF, 0xE7, 0x34,
+0x02, 0x80, 0x05, 0x3C, 0xC0, 0x5C, 0xA5, 0x24, 0xFF, 0xFF, 0xA5, 0x30,
+0x40, 0xB0, 0x04, 0x3C, 0x25, 0x28, 0xA4, 0x00, 0x24, 0x28, 0xA7, 0x00,
+0x21, 0x30, 0x00, 0x00, 0x43, 0xB0, 0x02, 0x3C, 0x00, 0x80, 0x04, 0x3C,
+0x40, 0x00, 0x84, 0x34, 0x00, 0x00, 0x45, 0xAC, 0x04, 0x00, 0x46, 0xAC,
+0x08, 0x00, 0x44, 0xAC, 0x5F, 0x67, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x04, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x64, 0x30, 0x02, 0x1C, 0x03, 0x00,
+0x08, 0x00, 0x80, 0x10, 0x0F, 0x00, 0x63, 0x30, 0x01, 0x00, 0x02, 0x24,
+0x0C, 0x00, 0x62, 0x10, 0x03, 0x00, 0x02, 0x24, 0x0E, 0x00, 0x62, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x03, 0x00, 0x60, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x08, 0x00, 0xE0, 0x03,
+0xC3, 0x5C, 0x40, 0xA0, 0x01, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0xC3, 0x5C, 0x43, 0xA0, 0x02, 0x00, 0x03, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x08, 0x00, 0xE0, 0x03, 0xC3, 0x5C, 0x43, 0xA0, 0x04, 0x00, 0x03, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x08, 0x00, 0xE0, 0x03, 0xC3, 0x5C, 0x43, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x02, 0x24,
+0xFF, 0xFF, 0x42, 0x24, 0xFF, 0xFF, 0x41, 0x04, 0xFF, 0xFF, 0x42, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x42, 0x24, 0x00, 0x60, 0x02, 0x40,
+0x01, 0x00, 0x41, 0x34, 0x01, 0x00, 0x21, 0x38, 0x00, 0x60, 0x81, 0x40,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x82, 0xAC, 0x00, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x40, 0x00, 0x00, 0x60, 0x83, 0x40,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x82, 0xAC, 0x00, 0x60, 0x01, 0x40,
+0x01, 0x00, 0x21, 0x34, 0x00, 0x60, 0x81, 0x40, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x40, 0x01, 0x00, 0x21, 0x34,
+0x01, 0x00, 0x21, 0x38, 0x00, 0x60, 0x81, 0x40, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x84, 0x02, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x04, 0x00, 0x85, 0x8C, 0x00, 0xA0, 0x03, 0x3C, 0x01, 0x00, 0x02, 0x24,
+0x25, 0x28, 0xA3, 0x00, 0x00, 0x00, 0xA4, 0x8C, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0xB4, 0x02, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x04, 0x00, 0x82, 0x8C, 0x02, 0x00, 0x83, 0x94, 0x00, 0xA0, 0x07, 0x3C,
+0x25, 0x28, 0x47, 0x00, 0x00, 0x00, 0xA2, 0x8C, 0x10, 0x00, 0x02, 0x24,
+0x13, 0x00, 0x62, 0x10, 0x11, 0x00, 0x66, 0x28, 0x06, 0x00, 0xC0, 0x10,
+0x20, 0x00, 0x02, 0x24, 0x08, 0x00, 0x02, 0x24, 0x17, 0x00, 0x62, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24,
+0xFD, 0xFF, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x83, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xAC, 0x04, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x10, 0x47, 0x00, 0x00, 0x00, 0x42, 0x8C,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xA4, 0x04, 0x00, 0x83, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x18, 0x67, 0x00, 0x00, 0x00, 0x62, 0x94,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xA0, 0x04, 0x00, 0x83, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x18, 0x67, 0x00, 0x00, 0x00, 0x62, 0x90,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x47, 0x24, 0x24, 0x38, 0xE3, 0x90, 0xFF, 0xFF, 0xA5, 0x30,
+0x09, 0x00, 0xA3, 0x10, 0x21, 0x20, 0xC0, 0x00, 0x94, 0x38, 0xE2, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xC2, 0xAC, 0x9E, 0x38, 0xE3, 0x94,
+0x0E, 0x00, 0x02, 0x24, 0x14, 0x00, 0xC2, 0xAC, 0x17, 0x0A, 0x00, 0x08,
+0x0C, 0x00, 0xC3, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x02, 0x80, 0x11, 0x3C,
+0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB2, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x60, 0x1B, 0x31, 0x26, 0x7C, 0x38, 0x30, 0x96, 0x02, 0x80, 0x02, 0x3C,
+0x01, 0x80, 0x03, 0x3C, 0x25, 0x80, 0x02, 0x02, 0x25, 0xB0, 0x02, 0x3C,
+0xB8, 0x03, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34, 0x60, 0x00, 0x04, 0x26,
+0x80, 0x00, 0x05, 0x26, 0x00, 0x00, 0x43, 0xAC, 0xC2, 0x1B, 0x00, 0x0C,
+0x03, 0x00, 0x06, 0x24, 0x21, 0x20, 0x00, 0x02, 0x21, 0x28, 0x00, 0x00,
+0xEC, 0x54, 0x00, 0x0C, 0x08, 0x00, 0x06, 0x24, 0x7C, 0x38, 0x22, 0x8E,
+0x0C, 0x00, 0x03, 0x24, 0x0C, 0x00, 0x43, 0xAE, 0x08, 0x00, 0x42, 0xAE,
+0x12, 0x00, 0x02, 0x24, 0x14, 0x00, 0x42, 0xAE, 0x21, 0x20, 0x40, 0x02,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x17, 0x0A, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0xD8, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xB1, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x0D, 0x00, 0x03, 0x92, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0x14,
+0x21, 0x88, 0x00, 0x00, 0x01, 0x00, 0x03, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0xF0, 0x5D, 0x43, 0xA0, 0x0C, 0x00, 0x02, 0x92, 0x02, 0x80, 0x05, 0x3C,
+0x06, 0x5E, 0xA2, 0xA0, 0x00, 0x00, 0x04, 0x92, 0x05, 0x00, 0x02, 0x24,
+0xFF, 0x00, 0x83, 0x30, 0x41, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x03, 0x00, 0x02, 0x24, 0x31, 0x00, 0x62, 0x10, 0xFF, 0x00, 0x84, 0x30,
+0x09, 0x00, 0x82, 0x2C, 0x25, 0x00, 0x40, 0x10, 0x02, 0x80, 0x10, 0x3C,
+0xEC, 0x5D, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x42, 0x30,
+0x21, 0x00, 0x82, 0x10, 0x00, 0x00, 0x00, 0x00, 0x99, 0x61, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xEC, 0x5D, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x37, 0x00, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C, 0x10, 0x37, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30, 0x54, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x0E, 0x5E, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x0E, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24,
+0x0E, 0x5E, 0x62, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0xEE, 0x5D, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x04, 0x00, 0x42, 0x28,
+0x06, 0x00, 0x40, 0x10, 0x04, 0x00, 0x04, 0x24, 0x4B, 0x2E, 0x00, 0x0C,
+0x01, 0x00, 0x05, 0x24, 0x5B, 0x41, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x00, 0x11, 0x24, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x21, 0x10, 0x20, 0x02, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x0B, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x40, 0x14,
+0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x01, 0x00, 0x02, 0x24,
+0x09, 0x5E, 0x62, 0xA0, 0x09, 0x5E, 0x63, 0x90, 0x02, 0x80, 0x02, 0x3C,
+0x0A, 0x5E, 0x43, 0xA0, 0x00, 0x00, 0x04, 0x92, 0x33, 0x41, 0x00, 0x08,
+0xFF, 0x00, 0x84, 0x30, 0x06, 0x5E, 0xA0, 0xA0, 0x0C, 0x00, 0x03, 0x92,
+0x02, 0x80, 0x02, 0x3C, 0x04, 0x5E, 0x43, 0xA0, 0x00, 0x00, 0x04, 0x92,
+0x30, 0x41, 0x00, 0x08, 0xFF, 0x00, 0x83, 0x30, 0x42, 0xB0, 0x06, 0x3C,
+0x00, 0x00, 0xC3, 0x90, 0xEF, 0xFF, 0x02, 0x24, 0x03, 0x00, 0xC7, 0x34,
+0x24, 0x18, 0x62, 0x00, 0x40, 0x00, 0x02, 0x24, 0x00, 0x00, 0xC3, 0xA0,
+0x0C, 0x00, 0x04, 0x24, 0x00, 0x00, 0xE2, 0xA0, 0x4B, 0x2E, 0x00, 0x0C,
+0x01, 0x00, 0x05, 0x24, 0x02, 0x80, 0x03, 0x3C, 0xC6, 0x5C, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x42, 0x30, 0x15, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x24, 0x00, 0x02, 0x05, 0x3C,
+0xC1, 0x43, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x42, 0x24, 0x2A, 0x1C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xCA, 0xFF, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x3A, 0x44, 0x94,
+0x2A, 0x1C, 0x40, 0xA0, 0x00, 0xC0, 0x84, 0x24, 0xA3, 0x31, 0x00, 0x0C,
+0xFF, 0xFF, 0x84, 0x30, 0x5B, 0x41, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x0E, 0x5E, 0x40, 0xA0, 0x5B, 0x41, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0xA8, 0x2D, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24, 0x89, 0x41, 0x00, 0x08,
+0x00, 0x08, 0x04, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x02, 0x80, 0x11, 0x3C,
+0x10, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0x30, 0x26, 0xB0, 0x1B, 0x07, 0x96,
+0x18, 0x00, 0xBF, 0xAF, 0xFF, 0xFF, 0xE3, 0x30, 0x00, 0x01, 0x62, 0x30,
+0x0E, 0x00, 0x40, 0x10, 0x01, 0x00, 0x66, 0x30, 0x02, 0x80, 0x04, 0x3C,
+0xB4, 0x55, 0x84, 0x24, 0x03, 0x00, 0x05, 0x24, 0x1E, 0x00, 0xC0, 0x14,
+0x04, 0x00, 0x62, 0x30, 0x02, 0x00, 0x40, 0x10, 0xFB, 0xF6, 0xE3, 0x30,
+0xB0, 0x1B, 0x03, 0xA6, 0x87, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x4C, 0x00, 0x42, 0x34, 0x00, 0x00, 0x40, 0xA0,
+0x21, 0x20, 0x00, 0x00, 0x95, 0x0E, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0x25, 0xB0, 0x06, 0x3C, 0x48, 0x00, 0xC6, 0x34, 0x00, 0x00, 0xC5, 0x8C,
+0x60, 0x1B, 0x24, 0x26, 0x7B, 0xFF, 0x03, 0x3C, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xFF, 0xFF, 0x63, 0x34,
+0x21, 0x10, 0x00, 0x00, 0x24, 0x28, 0xA3, 0x00, 0x20, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0xC5, 0xAC, 0xBC, 0x40, 0x80, 0xAC, 0xE8, 0x39, 0x80, 0xAC,
+0x04, 0x3A, 0x80, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0xFC, 0x40, 0x80, 0xAC,
+0x1C, 0x4F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xB0, 0x1B, 0x02, 0x96,
+0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x42, 0x30, 0x87, 0x54, 0x00, 0x0C,
+0xB0, 0x1B, 0x02, 0xA6, 0x25, 0xB0, 0x02, 0x3C, 0x4C, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x40, 0xA0, 0xBB, 0x41, 0x00, 0x08, 0x21, 0x20, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x01, 0x00, 0x83, 0x90, 0x02, 0x80, 0x02, 0x3C, 0x21, 0x38, 0x80, 0x00,
+0x8C, 0x5B, 0x43, 0xAC, 0x01, 0x00, 0x84, 0x90, 0x00, 0x00, 0xE2, 0x90,
+0x02, 0x80, 0x06, 0x3C, 0xFF, 0x00, 0x85, 0x30, 0x80, 0x10, 0x02, 0x00,
+0x25, 0x28, 0xA2, 0x00, 0x88, 0xDE, 0xC6, 0x24, 0xFF, 0x00, 0x84, 0x30,
+0x00, 0x80, 0xA5, 0x34, 0x6F, 0x20, 0x00, 0x0C, 0x03, 0x00, 0xE7, 0x24,
+0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x03, 0x3C, 0x1C, 0x00, 0xBF, 0xAF, 0x10, 0x37, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x43, 0x30, 0x00, 0x01, 0x42, 0x30,
+0x04, 0x00, 0x40, 0x10, 0x21, 0x80, 0x80, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x06, 0x00, 0x60, 0x14, 0x60, 0xE7, 0x84, 0x24, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x06, 0x00, 0x07, 0x92, 0x07, 0x00, 0x02, 0x26, 0x21, 0x20, 0x00, 0x02,
+0x80, 0x38, 0x07, 0x00, 0x00, 0x80, 0xE7, 0x34, 0x05, 0x00, 0x05, 0x24,
+0x21, 0x30, 0x00, 0x00, 0x02, 0x54, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27,
+0x02, 0x80, 0x02, 0x3C, 0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF,
+0x60, 0x1B, 0x45, 0x24, 0xFC, 0x40, 0xA3, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x06, 0x00, 0x60, 0x14, 0x21, 0x80, 0x80, 0x00, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xF8, 0x40, 0xA2, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0x45, 0x00, 0xF0, 0x40, 0x40, 0xA0, 0x00, 0x00, 0x84, 0x8C,
+0xC3, 0x1A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8E,
+0x03, 0x00, 0x04, 0x24, 0xD9, 0x12, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x84, 0x90,
+0x75, 0x0D, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xD8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x10, 0x3C,
+0x20, 0x00, 0xB2, 0xAF, 0x60, 0x1B, 0x02, 0x26, 0x24, 0x00, 0xBF, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0xB0, 0x1B, 0x45, 0x94, 0x21, 0x90, 0x80, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C, 0x80, 0xE7, 0x84, 0x24,
+0x00, 0x00, 0x42, 0x96, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x43, 0x24,
+0x20, 0x00, 0x42, 0x24, 0xC2, 0x18, 0x03, 0x00, 0xC2, 0x28, 0x02, 0x00,
+0x07, 0x00, 0x42, 0x30, 0x02, 0x00, 0x40, 0x14, 0xC0, 0x20, 0x03, 0x00,
+0xC0, 0x20, 0x05, 0x00, 0x53, 0x21, 0x00, 0x0C, 0x60, 0x1B, 0x11, 0x26,
+0x02, 0x80, 0x05, 0x3C, 0x21, 0x38, 0x40, 0x00, 0x21, 0x80, 0x40, 0x00,
+0x0A, 0x00, 0x04, 0x24, 0x22, 0x00, 0x40, 0x10, 0x70, 0xE7, 0xA5, 0x24,
+0x02, 0x00, 0x46, 0x92, 0x10, 0x38, 0x25, 0x8E, 0x72, 0x01, 0x00, 0x0C,
+0x08, 0x00, 0xC6, 0x24, 0x5B, 0x01, 0x00, 0x0C, 0x0A, 0x00, 0x04, 0x24,
+0x08, 0x00, 0x02, 0x96, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x04, 0x3C,
+0x25, 0x28, 0x45, 0x00, 0x74, 0x03, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0xB0, 0x55, 0x84, 0x24, 0x74, 0x21, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02,
+0x31, 0x46, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x37, 0x26, 0x8E,
+0x58, 0x38, 0x25, 0x8E, 0x01, 0x00, 0x04, 0x24, 0x00, 0x01, 0x07, 0x24,
+0x01, 0x00, 0x02, 0x24, 0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF,
+0x5B, 0x01, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C, 0x18, 0xE7, 0x84, 0x24,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x82, 0x90, 0x02, 0x80, 0x03, 0x3C,
+0x60, 0x1B, 0x63, 0x24, 0x07, 0x00, 0x40, 0x10, 0x21, 0x20, 0x60, 0x00,
+0xD0, 0x07, 0x02, 0x24, 0x3C, 0x3A, 0x62, 0xAC, 0x01, 0x00, 0x03, 0x24,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x48, 0x41, 0x83, 0xA0,
+0x21, 0x10, 0x00, 0x00, 0x3C, 0x3A, 0x60, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x48, 0x41, 0x60, 0xA0, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x25, 0xB0, 0x10, 0x3C, 0x21, 0x28, 0x80, 0x00, 0x06, 0x00, 0x06, 0x24,
+0x14, 0x00, 0xBF, 0xAF, 0xF4, 0x54, 0x00, 0x0C, 0x50, 0x00, 0x04, 0x36,
+0x02, 0x80, 0x04, 0x3C, 0x50, 0x00, 0x05, 0x36, 0x48, 0x37, 0x84, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0x94, 0xE7, 0x84, 0x24, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x25, 0xB0, 0x05, 0x3C, 0x01, 0x80, 0x03, 0x3C,
+0xE8, 0xFF, 0xBD, 0x27, 0x21, 0x30, 0x80, 0x00, 0x18, 0x03, 0xA2, 0x34,
+0xC0, 0x0B, 0x63, 0x24, 0x01, 0x00, 0x04, 0x24, 0x14, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x43, 0xAC, 0x66, 0x00, 0xC4, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x09, 0x00, 0xC0, 0x10, 0x02, 0x00, 0x02, 0x24,
+0x36, 0x00, 0xC2, 0x10, 0x03, 0x00, 0x02, 0x24, 0x8B, 0x00, 0xC2, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x50, 0x24, 0x70, 0x08, 0x02, 0x24, 0x34, 0x1C, 0x02, 0xAE,
+0xE0, 0x08, 0x03, 0x24, 0x40, 0x08, 0x02, 0x24, 0x38, 0x1C, 0x03, 0xAE,
+0x44, 0x1C, 0x02, 0xAE, 0x78, 0x08, 0x03, 0x24, 0x0C, 0x08, 0x02, 0x24,
+0x48, 0x1C, 0x03, 0xAE, 0x4C, 0x1C, 0x02, 0xAE, 0x10, 0x08, 0x03, 0x24,
+0x20, 0x08, 0x02, 0x24, 0x50, 0x1C, 0x03, 0xAE, 0x54, 0x1C, 0x02, 0xAE,
+0x24, 0x08, 0x03, 0x24, 0x58, 0x08, 0x02, 0x24, 0x58, 0x1C, 0x03, 0xAE,
+0x5C, 0x1C, 0x02, 0xAE, 0x50, 0x0C, 0x03, 0x24, 0x54, 0x0C, 0x02, 0x24,
+0x60, 0x1C, 0x03, 0xAE, 0x64, 0x1C, 0x02, 0xAE, 0x14, 0x0C, 0x03, 0x24,
+0x10, 0x0C, 0x02, 0x24, 0x20, 0x08, 0xA4, 0x34, 0x68, 0x1C, 0x03, 0xAE,
+0x60, 0x08, 0x05, 0x24, 0x6C, 0x1C, 0x02, 0xAE, 0x80, 0x0C, 0x03, 0x24,
+0x84, 0x0C, 0x02, 0x24, 0x40, 0x1C, 0x05, 0xAE, 0x70, 0x1C, 0x03, 0xAE,
+0x74, 0x1C, 0x02, 0xAE, 0x31, 0x1C, 0x00, 0xA2, 0xFA, 0x5B, 0x00, 0x0C,
+0x3C, 0x1C, 0x05, 0xAE, 0x00, 0x01, 0x42, 0x30, 0x31, 0x00, 0x40, 0x14,
+0xB8, 0x08, 0x02, 0x24, 0xA0, 0x08, 0x02, 0x24, 0x78, 0x1C, 0x02, 0xAE,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0xA8, 0x08, 0x03, 0x24, 0x78, 0x1C, 0x43, 0xAC, 0x74, 0x08, 0x03, 0x24,
+0xE4, 0x08, 0x04, 0x24, 0x34, 0x1C, 0x43, 0xAC, 0x48, 0x08, 0x03, 0x24,
+0x38, 0x1C, 0x44, 0xAC, 0x44, 0x1C, 0x43, 0xAC, 0x7C, 0x08, 0x04, 0x24,
+0x0C, 0x08, 0x03, 0x24, 0x48, 0x1C, 0x44, 0xAC, 0x4C, 0x1C, 0x43, 0xAC,
+0x18, 0x08, 0x04, 0x24, 0x30, 0x08, 0x03, 0x24, 0x50, 0x1C, 0x44, 0xAC,
+0x54, 0x1C, 0x43, 0xAC, 0x34, 0x08, 0x04, 0x24, 0x5C, 0x08, 0x03, 0x24,
+0x58, 0x1C, 0x44, 0xAC, 0x5C, 0x1C, 0x43, 0xAC, 0x60, 0x0C, 0x04, 0x24,
+0x64, 0x0C, 0x03, 0x24, 0x60, 0x1C, 0x44, 0xAC, 0x64, 0x1C, 0x43, 0xAC,
+0x24, 0x0C, 0x04, 0x24, 0x20, 0x0C, 0x03, 0x24, 0x68, 0x08, 0x05, 0x24,
+0x68, 0x1C, 0x44, 0xAC, 0x6C, 0x1C, 0x43, 0xAC, 0x90, 0x0C, 0x04, 0x24,
+0x94, 0x0C, 0x03, 0x24, 0x31, 0x1C, 0x46, 0xA0, 0x40, 0x1C, 0x45, 0xAC,
+0x70, 0x1C, 0x44, 0xAC, 0x74, 0x1C, 0x43, 0xAC, 0x3C, 0x1C, 0x45, 0xAC,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x31, 0x43, 0x00, 0x08, 0x78, 0x1C, 0x02, 0xAE,
+0x60, 0x1B, 0x50, 0x24, 0x70, 0x08, 0x02, 0x24, 0x34, 0x1C, 0x02, 0xAE,
+0xE0, 0x08, 0x03, 0x24, 0x44, 0x08, 0x02, 0x24, 0x38, 0x1C, 0x03, 0xAE,
+0x44, 0x1C, 0x02, 0xAE, 0x78, 0x08, 0x03, 0x24, 0x0C, 0x08, 0x02, 0x24,
+0x48, 0x1C, 0x03, 0xAE, 0x4C, 0x1C, 0x02, 0xAE, 0x14, 0x08, 0x03, 0x24,
+0x28, 0x08, 0x02, 0x24, 0x50, 0x1C, 0x03, 0xAE, 0x54, 0x1C, 0x02, 0xAE,
+0x2C, 0x08, 0x03, 0x24, 0x58, 0x08, 0x02, 0x24, 0x58, 0x1C, 0x03, 0xAE,
+0x5C, 0x1C, 0x02, 0xAE, 0x58, 0x0C, 0x03, 0x24, 0x5C, 0x0C, 0x02, 0x24,
+0x60, 0x1C, 0x03, 0xAE, 0x64, 0x1C, 0x02, 0xAE, 0x1C, 0x0C, 0x03, 0x24,
+0x18, 0x0C, 0x02, 0x24, 0x28, 0x08, 0xA4, 0x34, 0x68, 0x1C, 0x03, 0xAE,
+0x64, 0x08, 0x05, 0x24, 0x6C, 0x1C, 0x02, 0xAE, 0x88, 0x0C, 0x03, 0x24,
+0x8C, 0x0C, 0x02, 0x24, 0x31, 0x1C, 0x06, 0xA2, 0x40, 0x1C, 0x05, 0xAE,
+0x70, 0x1C, 0x03, 0xAE, 0x74, 0x1C, 0x02, 0xAE, 0xFA, 0x5B, 0x00, 0x0C,
+0x3C, 0x1C, 0x05, 0xAE, 0x00, 0x01, 0x42, 0x30, 0x2B, 0x00, 0x40, 0x14,
+0xBC, 0x08, 0x02, 0x24, 0xA4, 0x08, 0x02, 0x24, 0x31, 0x43, 0x00, 0x08,
+0x78, 0x1C, 0x02, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0xAC, 0x08, 0x03, 0x24, 0x78, 0x1C, 0x43, 0xAC, 0x74, 0x08, 0x03, 0x24,
+0xE4, 0x08, 0x04, 0x24, 0x34, 0x1C, 0x43, 0xAC, 0x4C, 0x08, 0x03, 0x24,
+0x38, 0x1C, 0x44, 0xAC, 0x44, 0x1C, 0x43, 0xAC, 0x7C, 0x08, 0x04, 0x24,
+0x0C, 0x08, 0x03, 0x24, 0x48, 0x1C, 0x44, 0xAC, 0x4C, 0x1C, 0x43, 0xAC,
+0x1C, 0x08, 0x04, 0x24, 0x38, 0x08, 0x03, 0x24, 0x50, 0x1C, 0x44, 0xAC,
+0x54, 0x1C, 0x43, 0xAC, 0x3C, 0x08, 0x04, 0x24, 0x5C, 0x08, 0x03, 0x24,
+0x58, 0x1C, 0x44, 0xAC, 0x5C, 0x1C, 0x43, 0xAC, 0x68, 0x0C, 0x04, 0x24,
+0x6C, 0x0C, 0x03, 0x24, 0x60, 0x1C, 0x44, 0xAC, 0x64, 0x1C, 0x43, 0xAC,
+0x2C, 0x0C, 0x04, 0x24, 0x28, 0x0C, 0x03, 0x24, 0x6C, 0x08, 0x05, 0x24,
+0x68, 0x1C, 0x44, 0xAC, 0x6C, 0x1C, 0x43, 0xAC, 0x98, 0x0C, 0x04, 0x24,
+0x9C, 0x0C, 0x03, 0x24, 0x31, 0x1C, 0x46, 0xA0, 0x40, 0x1C, 0x45, 0xAC,
+0x70, 0x1C, 0x44, 0xAC, 0x74, 0x1C, 0x43, 0xAC, 0x5B, 0x43, 0x00, 0x08,
+0x3C, 0x1C, 0x45, 0xAC, 0x31, 0x43, 0x00, 0x08, 0x78, 0x1C, 0x02, 0xAE,
+0xBA, 0x43, 0x00, 0x08, 0x21, 0x18, 0x00, 0x00, 0x20, 0x00, 0x62, 0x2C,
+0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x64, 0x00,
+0x01, 0x00, 0x42, 0x30, 0xFA, 0xFF, 0x40, 0x10, 0x01, 0x00, 0x63, 0x24,
+0xFF, 0xFF, 0x63, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0xD8, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0xFF, 0xFF, 0x02, 0x24,
+0x21, 0x88, 0xA0, 0x00, 0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x90, 0xC0, 0x00,
+0x21, 0x28, 0xC0, 0x00, 0x0B, 0x00, 0x22, 0x12, 0x21, 0x98, 0x80, 0x00,
+0x26, 0x5C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x20, 0x02,
+0xB5, 0x43, 0x00, 0x0C, 0x21, 0x80, 0x40, 0x00, 0x27, 0x28, 0x11, 0x00,
+0x24, 0x28, 0xB0, 0x00, 0x04, 0x10, 0x52, 0x00, 0x25, 0x28, 0xA2, 0x00,
+0x21, 0x20, 0x60, 0x02, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x03, 0x5C, 0x00, 0x08, 0x28, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x30, 0x80, 0x00, 0xA4, 0x37, 0x44, 0x8C, 0xC1, 0x43, 0x00, 0x08,
+0xFF, 0xFF, 0x05, 0x24, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xBF, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x26, 0x5C, 0x00, 0x0C,
+0x21, 0x88, 0xA0, 0x00, 0x21, 0x80, 0x40, 0x00, 0xB5, 0x43, 0x00, 0x0C,
+0x21, 0x20, 0x20, 0x02, 0x24, 0x80, 0x11, 0x02, 0x06, 0x10, 0x50, 0x00,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB2, 0xAF, 0x02, 0x80, 0x12, 0x3C, 0x60, 0x1B, 0x52, 0x26,
+0x14, 0x00, 0xB1, 0xAF, 0x21, 0x88, 0x80, 0x00, 0x24, 0x08, 0x04, 0x24,
+0x24, 0x00, 0xBF, 0xAF, 0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF,
+0x26, 0x5C, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF, 0x58, 0x1C, 0x44, 0x8E,
+0x21, 0xA0, 0x40, 0x00, 0x26, 0x5C, 0x00, 0x0C, 0xC0, 0x8D, 0x11, 0x00,
+0xFF, 0x7F, 0x05, 0x3C, 0x7F, 0x80, 0x03, 0x3C, 0xFF, 0xFF, 0xA5, 0x34,
+0xFF, 0xFF, 0x63, 0x34, 0x24, 0x28, 0x85, 0x02, 0x24, 0x08, 0x04, 0x24,
+0x03, 0x5C, 0x00, 0x0C, 0x24, 0x80, 0x43, 0x00, 0x2C, 0x1F, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x00, 0x80, 0x13, 0x3C, 0x58, 0x1C, 0x44, 0x8E,
+0x25, 0x80, 0x11, 0x02, 0x25, 0x80, 0x13, 0x02, 0x03, 0x5C, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x02, 0x2C, 0x1F, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x25, 0x28, 0x93, 0x02, 0x03, 0x5C, 0x00, 0x0C, 0x24, 0x08, 0x04, 0x24,
+0x2C, 0x1F, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24, 0x78, 0x1C, 0x44, 0x8E,
+0x0F, 0x00, 0x05, 0x3C, 0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0xFF, 0xFF, 0xA5, 0x34, 0xE3, 0x43, 0x00, 0x08,
+0x28, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF,
+0x02, 0x80, 0x11, 0x3C, 0x10, 0x00, 0xB0, 0xAF, 0x18, 0x00, 0xBF, 0xAF,
+0x60, 0x1B, 0x27, 0x26, 0x33, 0x1C, 0xE5, 0x90, 0x01, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x94, 0x10, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x02, 0x00, 0x06, 0x24, 0x00, 0x00, 0x43, 0xAC, 0x34, 0x00, 0xA6, 0x10,
+0x21, 0x80, 0x80, 0x00, 0x03, 0x00, 0x03, 0x24, 0x3A, 0x00, 0xA3, 0x10,
+0x2E, 0x00, 0x02, 0x2E, 0x10, 0x00, 0x02, 0x2E, 0x07, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x04, 0x32, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xF3, 0x43, 0x00, 0x08,
+0x20, 0x00, 0xBD, 0x27, 0xFA, 0xFF, 0xA6, 0x14, 0xFF, 0x00, 0x04, 0x32,
+0x31, 0x1C, 0xE4, 0x90, 0x01, 0x00, 0x02, 0x24, 0x33, 0x00, 0x82, 0x10,
+0x02, 0x00, 0x82, 0x28, 0x38, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x38, 0x00, 0x85, 0x10, 0x60, 0x1B, 0x22, 0x26, 0x2E, 0x00, 0x83, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x24, 0xE3, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0xFF, 0xFC, 0x06, 0x3C, 0xFF, 0xFF, 0xC6, 0x34,
+0x24, 0x30, 0x46, 0x00, 0x00, 0x08, 0x04, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0x60, 0x1B, 0x22, 0x26, 0x31, 0x1C, 0x44, 0x90,
+0x01, 0x00, 0x03, 0x24, 0x07, 0x00, 0x83, 0x10, 0x02, 0x00, 0x82, 0x28,
+0x2C, 0x00, 0x40, 0x14, 0x02, 0x00, 0x02, 0x24, 0x2C, 0x00, 0x82, 0x10,
+0x03, 0x00, 0x02, 0x24, 0xDB, 0xFF, 0x82, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x22, 0x26, 0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x3C,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x3B, 0x44, 0x00, 0x08,
+0xFF, 0x00, 0x04, 0x32, 0x25, 0x00, 0x82, 0x2C, 0xCC, 0xFF, 0x40, 0x14,
+0x03, 0x00, 0x03, 0x24, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xC7, 0xFF, 0x40, 0x14, 0x10, 0x00, 0x02, 0x2E,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x60, 0x1B, 0x22, 0x26, 0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x3C,
+0xC1, 0x43, 0x00, 0x0C, 0x0F, 0x00, 0x06, 0x24, 0x4D, 0x44, 0x00, 0x08,
+0x00, 0x08, 0x04, 0x24, 0xCC, 0xFF, 0x80, 0x14, 0x60, 0x1B, 0x22, 0x26,
+0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x0F, 0x00, 0x06, 0x24, 0x4D, 0x44, 0x00, 0x08, 0x00, 0x08, 0x04, 0x24,
+0xB2, 0xFF, 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x22, 0x26,
+0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x3B, 0x44, 0x00, 0x08, 0xFF, 0x00, 0x04, 0x32,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x02, 0x80, 0x11, 0x3C,
+0x60, 0x1B, 0x28, 0x26, 0x33, 0x1C, 0x06, 0x91, 0x01, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x40, 0x12, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x02, 0x00, 0x07, 0x24, 0x18, 0x00, 0xB2, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x1C, 0x00, 0xBF, 0xAF, 0x00, 0x00, 0x43, 0xAC, 0x21, 0x90, 0xA0, 0x00,
+0x39, 0x00, 0xC7, 0x10, 0xFF, 0x00, 0x90, 0x30, 0x03, 0x00, 0x03, 0x24,
+0x3F, 0x00, 0xC3, 0x10, 0x2E, 0x00, 0x02, 0x2E, 0x10, 0x00, 0x02, 0x2E,
+0x0C, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x04, 0x3C,
+0xFF, 0xFF, 0x84, 0x34, 0x24, 0x20, 0x44, 0x02, 0x00, 0x15, 0x10, 0x00,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x25, 0x20, 0x44, 0x00, 0xDE, 0x43, 0x00, 0x08,
+0x20, 0x00, 0xBD, 0x27, 0xF5, 0xFF, 0xC7, 0x14, 0x0F, 0x00, 0x04, 0x3C,
+0x31, 0x1C, 0x04, 0x91, 0x01, 0x00, 0x02, 0x24, 0x33, 0x00, 0x82, 0x10,
+0x02, 0x00, 0x82, 0x28, 0x38, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x38, 0x00, 0x86, 0x10, 0x60, 0x1B, 0x22, 0x26, 0x2E, 0x00, 0x83, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x24, 0xE3, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0xFF, 0xFC, 0x06, 0x3C, 0xFF, 0xFF, 0xC6, 0x34,
+0x24, 0x30, 0x46, 0x00, 0x00, 0x08, 0x04, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0x60, 0x1B, 0x22, 0x26, 0x31, 0x1C, 0x44, 0x90,
+0x01, 0x00, 0x03, 0x24, 0x07, 0x00, 0x83, 0x10, 0x02, 0x00, 0x82, 0x28,
+0x2C, 0x00, 0x40, 0x14, 0x02, 0x00, 0x02, 0x24, 0x2C, 0x00, 0x82, 0x10,
+0x03, 0x00, 0x02, 0x24, 0xD6, 0xFF, 0x82, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x60, 0x1B, 0x22, 0x26, 0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x3C,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0xA8, 0x44, 0x00, 0x08,
+0x0F, 0x00, 0x04, 0x3C, 0x25, 0x00, 0x02, 0x2E, 0xC7, 0xFF, 0x40, 0x14,
+0x03, 0x00, 0x03, 0x24, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xC1, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x60, 0x1B, 0x22, 0x26, 0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x3C,
+0xC1, 0x43, 0x00, 0x0C, 0x0F, 0x00, 0x06, 0x24, 0xBF, 0x44, 0x00, 0x08,
+0x00, 0x08, 0x04, 0x24, 0xCC, 0xFF, 0x80, 0x14, 0x60, 0x1B, 0x22, 0x26,
+0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x0F, 0x00, 0x06, 0x24, 0xBF, 0x44, 0x00, 0x08, 0x00, 0x08, 0x04, 0x24,
+0xAD, 0xFF, 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x22, 0x26,
+0x34, 0x1C, 0x44, 0x8C, 0x0F, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0xA8, 0x44, 0x00, 0x08, 0x0F, 0x00, 0x04, 0x3C,
+0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x14, 0x00, 0xBF, 0xAF, 0xF3, 0x43, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00,
+0x40, 0x01, 0x44, 0x34, 0x21, 0x18, 0x40, 0x00, 0x1F, 0x00, 0x02, 0x2E,
+0x00, 0x23, 0x04, 0x00, 0x10, 0x00, 0x40, 0x10, 0x10, 0x00, 0x05, 0x2E,
+0x00, 0x01, 0x64, 0x34, 0x06, 0x00, 0xA0, 0x10, 0x00, 0x23, 0x04, 0x00,
+0x21, 0x10, 0x00, 0x02, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xDE, 0x43, 0x00, 0x0C,
+0xF1, 0xFF, 0x10, 0x26, 0x21, 0x10, 0x00, 0x02, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0xDE, 0x43, 0x00, 0x0C, 0xE2, 0xFF, 0x10, 0x26, 0x21, 0x10, 0x00, 0x02,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x02, 0x3C,
+0x18, 0x00, 0xBF, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x21, 0x20, 0x82, 0x00, 0x00, 0x00, 0x90, 0x8C, 0x21, 0x88, 0xA0, 0x00,
+0xB5, 0x43, 0x00, 0x0C, 0x21, 0x20, 0xA0, 0x00, 0x24, 0x80, 0x11, 0x02,
+0x06, 0x10, 0x50, 0x00, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xD8, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x02, 0x3C, 0x18, 0x00, 0xB2, 0xAF,
+0x21, 0x90, 0x82, 0x00, 0xFF, 0xFF, 0x02, 0x24, 0x1C, 0x00, 0xB3, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x21, 0x88, 0xA0, 0x00, 0x21, 0x20, 0xA0, 0x00, 0x21, 0x18, 0x40, 0x02,
+0x10, 0x00, 0xA2, 0x10, 0x21, 0x98, 0xC0, 0x00, 0x00, 0x00, 0x50, 0x8E,
+0xB5, 0x43, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x27, 0x18, 0x11, 0x00,
+0x24, 0x18, 0x70, 0x00, 0x04, 0x10, 0x53, 0x00, 0x25, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x43, 0xAE, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x28, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x66, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x21, 0x38, 0x82, 0x00, 0xFF, 0xFF, 0x02, 0x24, 0x27, 0x40, 0x05, 0x00,
+0x08, 0x00, 0xA2, 0x10, 0x24, 0x18, 0xC5, 0x00, 0x00, 0x00, 0xE2, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x02, 0x01, 0x25, 0x10, 0x43, 0x00,
+0x00, 0x00, 0xE2, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xE6, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0xFF, 0xFF, 0x02, 0x24,
+0x21, 0x80, 0xA0, 0x00, 0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x1C, 0x00, 0xBF, 0xAF, 0x21, 0x88, 0xC0, 0x00, 0x21, 0x28, 0xC0, 0x00,
+0x08, 0x00, 0x02, 0x12, 0x21, 0x90, 0x80, 0x00, 0x26, 0x5C, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x27, 0x28, 0x10, 0x00, 0x24, 0x28, 0xA2, 0x00,
+0x24, 0x10, 0x30, 0x02, 0x25, 0x28, 0xA2, 0x00, 0x21, 0x20, 0x40, 0x02,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x03, 0x5C, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27,
+0x01, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x03, 0x3C, 0xD0, 0xFF, 0xBD, 0x27,
+0x0C, 0x16, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34, 0x20, 0x00, 0xB2, 0xAF,
+0x00, 0x00, 0x62, 0xAC, 0x21, 0x90, 0x80, 0x00, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x00, 0xB3, 0xAF, 0x1C, 0x00, 0xB1, 0xAF, 0x21, 0x98, 0xC0, 0x00,
+0x21, 0x88, 0xA0, 0x00, 0x28, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x18, 0x00, 0xB0, 0xAF, 0x0F, 0x00, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x21, 0x20, 0x40, 0x02, 0x0A, 0x00, 0x22, 0x12, 0x21, 0x28, 0x60, 0x02,
+0x25, 0x44, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x20, 0x02,
+0xB5, 0x43, 0x00, 0x0C, 0x21, 0x80, 0x40, 0x00, 0x27, 0x28, 0x11, 0x00,
+0x24, 0x28, 0xB0, 0x00, 0x04, 0x10, 0x53, 0x00, 0x25, 0x28, 0xA2, 0x00,
+0x90, 0x44, 0x00, 0x0C, 0xFF, 0x00, 0x44, 0x32, 0x90, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0x01, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0xB0, 0x16, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0xE0, 0xFF, 0xBD, 0x27, 0x00, 0x00, 0x43, 0xAC, 0x18, 0x00, 0xBF, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x25, 0x44, 0x00, 0x0C,
+0x21, 0x88, 0xA0, 0x00, 0x21, 0x80, 0x40, 0x00, 0xB5, 0x43, 0x00, 0x0C,
+0x21, 0x20, 0x20, 0x02, 0x24, 0x80, 0x11, 0x02, 0x06, 0x10, 0x50, 0x00,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27,
+0x24, 0x00, 0xB5, 0xAF, 0xFF, 0x00, 0x84, 0x30, 0x21, 0xA8, 0xC0, 0x00,
+0x28, 0x00, 0xB6, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x2C, 0x00, 0xBF, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x21, 0xB0, 0xA0, 0x00, 0xF0, 0x42, 0x00, 0x0C,
+0x21, 0x98, 0x00, 0x00, 0x21, 0x00, 0xA0, 0x16, 0x80, 0x10, 0x13, 0x00,
+0xFF, 0x45, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xFD, 0x00, 0x02, 0x24,
+0x23, 0x00, 0x02, 0x12, 0x05, 0x00, 0x04, 0x24, 0xFC, 0x00, 0x02, 0x24,
+0x37, 0x00, 0x02, 0x12, 0x00, 0x00, 0x00, 0x00, 0xFB, 0x00, 0x02, 0x24,
+0x30, 0x00, 0x02, 0x12, 0x32, 0x00, 0x04, 0x24, 0xFA, 0x00, 0x02, 0x24,
+0x2D, 0x00, 0x02, 0x12, 0x05, 0x00, 0x04, 0x24, 0xF9, 0x00, 0x02, 0x24,
+0x29, 0x00, 0x02, 0x12, 0x0F, 0x00, 0x05, 0x3C, 0x04, 0x00, 0xD1, 0x8C,
+0xFF, 0xFF, 0xA5, 0x34, 0x21, 0x20, 0x00, 0x02, 0x83, 0x45, 0x00, 0x0C,
+0x21, 0x30, 0x20, 0x02, 0x2C, 0x1F, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x19, 0x00, 0x02, 0x24, 0x28, 0x00, 0x02, 0x12, 0x21, 0x90, 0x00, 0x00,
+0x02, 0x00, 0x62, 0x26, 0xFF, 0x00, 0x53, 0x30, 0x2B, 0x18, 0x75, 0x02,
+0x0F, 0x00, 0x60, 0x10, 0x80, 0x10, 0x13, 0x00, 0x21, 0x30, 0x56, 0x00,
+0x00, 0x00, 0xD0, 0x8C, 0xFF, 0x00, 0x02, 0x24, 0x0A, 0x00, 0x02, 0x12,
+0xFE, 0x00, 0x02, 0x24, 0xDC, 0xFF, 0x02, 0x16, 0x32, 0x00, 0x04, 0x24,
+0x2C, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x62, 0x26,
+0xFF, 0x00, 0x53, 0x30, 0x2B, 0x18, 0x75, 0x02, 0xF3, 0xFF, 0x60, 0x14,
+0x80, 0x10, 0x13, 0x00, 0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0x01, 0x00, 0x04, 0x24, 0x5B, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xED, 0x45, 0x00, 0x08, 0x02, 0x00, 0x62, 0x26, 0x2C, 0x1F, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0xFB, 0x45, 0x00, 0x08, 0x02, 0x00, 0x62, 0x26,
+0x0F, 0x00, 0x14, 0x3C, 0x21, 0x20, 0x00, 0x02, 0xAC, 0x45, 0x00, 0x0C,
+0xFF, 0xFF, 0x85, 0x36, 0x21, 0x20, 0x00, 0x02, 0xFF, 0xFF, 0x85, 0x36,
+0xD2, 0xFF, 0x51, 0x10, 0x21, 0x30, 0x20, 0x02, 0x83, 0x45, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x2C, 0x1F, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x01, 0x00, 0x42, 0x26, 0xFF, 0x00, 0x52, 0x30, 0x0A, 0x00, 0x43, 0x2E,
+0xF2, 0xFF, 0x60, 0x14, 0x21, 0x20, 0x00, 0x02, 0xF0, 0x42, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x00, 0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xB0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x4C, 0x00, 0xBF, 0xAF,
+0x48, 0x00, 0xBE, 0xAF, 0x40, 0x00, 0xB6, 0xAF, 0x3C, 0x00, 0xB5, 0xAF,
+0x38, 0x00, 0xB4, 0xAF, 0x34, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xB2, 0xAF,
+0x2C, 0x00, 0xB1, 0xAF, 0x28, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0x55, 0x24,
+0x44, 0x00, 0xB7, 0xAF, 0x58, 0x38, 0xA3, 0x96, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x05, 0x3C, 0x25, 0x98, 0x62, 0x00, 0x90, 0xDE, 0xA5, 0x24,
+0x24, 0x00, 0x64, 0x26, 0x06, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x20, 0x00, 0x60, 0xA6, 0x02, 0x80, 0x05, 0x3C, 0x48, 0x37, 0xA5, 0x24,
+0x2A, 0x00, 0x64, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x05, 0x3C, 0xB4, 0x55, 0xA5, 0x24, 0x06, 0x00, 0x06, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x30, 0x00, 0x64, 0x26, 0x20, 0x00, 0x63, 0x96,
+0x02, 0x80, 0x02, 0x3C, 0xB0, 0x55, 0x42, 0x24, 0x03, 0xFF, 0x63, 0x30,
+0x80, 0x00, 0x63, 0x34, 0x74, 0x00, 0x54, 0x24, 0x20, 0x00, 0x63, 0xA6,
+0x21, 0x20, 0x80, 0x02, 0x20, 0x00, 0x02, 0x24, 0x40, 0x00, 0x72, 0x26,
+0xFB, 0x51, 0x00, 0x0C, 0x1C, 0x00, 0xA2, 0xAF, 0x21, 0x28, 0x40, 0x00,
+0x21, 0x20, 0x40, 0x02, 0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24,
+0x1C, 0x00, 0xA2, 0x8F, 0x21, 0x20, 0x80, 0x02, 0x42, 0x00, 0x72, 0x26,
+0x02, 0x00, 0x42, 0x24, 0x16, 0x52, 0x00, 0x0C, 0x1C, 0x00, 0xA2, 0xAF,
+0x21, 0x28, 0x40, 0x00, 0x21, 0x20, 0x40, 0x02, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x02, 0x80, 0x03, 0x3C, 0xB0, 0x55, 0x63, 0x24,
+0x1C, 0x00, 0xA2, 0x8F, 0x0C, 0x00, 0x66, 0x8C, 0x60, 0x00, 0x71, 0x24,
+0x1C, 0x00, 0xB0, 0x27, 0x10, 0x00, 0x67, 0x24, 0x21, 0x28, 0x00, 0x00,
+0x02, 0x00, 0x42, 0x24, 0x44, 0x00, 0x64, 0x26, 0x1C, 0x00, 0xA2, 0xAF,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x20, 0x20, 0x02,
+0x1B, 0x53, 0x00, 0x0C, 0x21, 0x90, 0x40, 0x00, 0x21, 0xB0, 0x40, 0x00,
+0x08, 0x00, 0x06, 0x24, 0x09, 0x00, 0x42, 0x2C, 0x21, 0x20, 0x40, 0x02,
+0x21, 0x38, 0x20, 0x02, 0x0B, 0x30, 0xC2, 0x02, 0x01, 0x00, 0x05, 0x24,
+0x20, 0x00, 0xA2, 0xAF, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x03, 0x3C, 0xB0, 0x55, 0x63, 0x24, 0x48, 0x00, 0x67, 0x24,
+0x21, 0x20, 0x40, 0x00, 0x03, 0x00, 0x05, 0x24, 0x01, 0x00, 0x06, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x20, 0x40, 0x00,
+0x06, 0x00, 0x05, 0x24, 0x02, 0x00, 0x06, 0x24, 0x18, 0x00, 0xA7, 0x27,
+0x18, 0x00, 0xA0, 0xA7, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB0, 0xAF,
+0x18, 0x00, 0xA5, 0x97, 0x02, 0x80, 0x04, 0x3C, 0x58, 0xE8, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x21, 0x90, 0x40, 0x00, 0xC0, 0x3A, 0xA2, 0x8E,
+0x0C, 0x00, 0x11, 0x24, 0x2B, 0x10, 0x22, 0x02, 0x3B, 0x00, 0x40, 0x10,
+0x21, 0xF0, 0x00, 0x02, 0x02, 0x80, 0x02, 0x3C, 0x21, 0x80, 0x80, 0x02,
+0xAA, 0x46, 0x00, 0x08, 0x26, 0x56, 0x57, 0x24, 0x21, 0x10, 0x30, 0x02,
+0x01, 0x00, 0x43, 0x90, 0xC0, 0x3A, 0xA4, 0x8E, 0x21, 0x18, 0x71, 0x00,
+0x02, 0x00, 0x71, 0x24, 0x2B, 0x20, 0x24, 0x02, 0x2F, 0x00, 0x80, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x30, 0x02, 0x00, 0x00, 0x47, 0x90,
+0x02, 0x80, 0x14, 0x3C, 0x2D, 0x00, 0x03, 0x24, 0x21, 0x28, 0x37, 0x02,
+0x64, 0x5C, 0x84, 0x26, 0xF1, 0xFF, 0xE3, 0x14, 0x20, 0x00, 0x06, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x41, 0xA3, 0x96,
+0x02, 0x80, 0x02, 0x3C, 0xC6, 0x5C, 0x47, 0x90, 0xBD, 0xFF, 0x63, 0x30,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x0C, 0x00, 0x63, 0x34,
+0x01, 0x00, 0xE7, 0x30, 0x44, 0xDF, 0xA5, 0x24, 0x67, 0x5C, 0x44, 0x24,
+0x10, 0x00, 0x06, 0x24, 0x06, 0x00, 0xE0, 0x14, 0x04, 0x41, 0xA3, 0xA6,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x54, 0xDF, 0xA5, 0x24,
+0x67, 0x5C, 0x64, 0x24, 0x10, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x30, 0x02, 0x01, 0x00, 0x46, 0x90,
+0x21, 0x20, 0x40, 0x02, 0x64, 0x5C, 0x87, 0x26, 0x2D, 0x00, 0x05, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xBE, 0xAF, 0x21, 0x90, 0x40, 0x00,
+0x21, 0x10, 0x30, 0x02, 0x01, 0x00, 0x43, 0x90, 0xC0, 0x3A, 0xA4, 0x8E,
+0x21, 0x18, 0x71, 0x00, 0x02, 0x00, 0x71, 0x24, 0x2B, 0x20, 0x24, 0x02,
+0xD4, 0xFF, 0x80, 0x14, 0x21, 0x10, 0x30, 0x02, 0x20, 0x00, 0xA2, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x1C, 0x00, 0xA2, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x42, 0x24,
+0x01, 0x01, 0x42, 0x2C, 0x1A, 0x00, 0x40, 0x14, 0x21, 0x20, 0x60, 0x02,
+0x4C, 0x00, 0xBF, 0x8F, 0x48, 0x00, 0xBE, 0x8F, 0x44, 0x00, 0xB7, 0x8F,
+0x40, 0x00, 0xB6, 0x8F, 0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F,
+0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F,
+0x28, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x50, 0x00, 0xBD, 0x27,
+0xB0, 0x55, 0x63, 0x24, 0x21, 0x20, 0x40, 0x02, 0xF8, 0xFF, 0xC6, 0x26,
+0x68, 0x00, 0x67, 0x24, 0x32, 0x00, 0x05, 0x24, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xBE, 0xAF, 0x1C, 0x00, 0xA2, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x20, 0x00, 0x42, 0x24, 0x01, 0x01, 0x42, 0x2C, 0xE8, 0xFF, 0x40, 0x10,
+0x21, 0x20, 0x60, 0x02, 0x21, 0x28, 0x00, 0x00, 0xEC, 0x54, 0x00, 0x0C,
+0x08, 0x00, 0x06, 0x24, 0x08, 0x00, 0x64, 0x8E, 0x04, 0x00, 0x65, 0x8E,
+0xFF, 0xDF, 0x02, 0x3C, 0x10, 0x00, 0x66, 0x8E, 0x14, 0x00, 0x67, 0x8E,
+0xFF, 0xFF, 0x42, 0x34, 0x1C, 0x00, 0xA8, 0x8F, 0x24, 0x20, 0x82, 0x00,
+0x00, 0x40, 0x03, 0x3C, 0xFF, 0xE0, 0x02, 0x24, 0x24, 0x28, 0xA2, 0x00,
+0x25, 0x20, 0x83, 0x00, 0x00, 0x80, 0x02, 0x3C, 0xFF, 0x81, 0x03, 0x24,
+0x25, 0x30, 0xC2, 0x00, 0x24, 0x38, 0xE3, 0x00, 0x00, 0x10, 0xA5, 0x34,
+0x02, 0x80, 0x03, 0x3C, 0x80, 0x00, 0x84, 0x34, 0x20, 0x00, 0x02, 0x24,
+0x08, 0x00, 0x64, 0xAE, 0x00, 0x00, 0x68, 0xA6, 0x02, 0x00, 0x62, 0xA2,
+0x14, 0x00, 0x67, 0xAE, 0x04, 0x00, 0x65, 0xAE, 0x10, 0x00, 0x66, 0xAE,
+0x60, 0x1B, 0x62, 0x24, 0xEC, 0x37, 0x46, 0x8C, 0x58, 0x38, 0x45, 0x8C,
+0x01, 0x00, 0x04, 0x24, 0x00, 0x01, 0x07, 0x24, 0x01, 0x00, 0x02, 0x24,
+0x1E, 0x01, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0x5B, 0x01, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x4C, 0x00, 0xBF, 0x8F, 0x48, 0x00, 0xBE, 0x8F,
+0x44, 0x00, 0xB7, 0x8F, 0x40, 0x00, 0xB6, 0x8F, 0x3C, 0x00, 0xB5, 0x8F,
+0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F, 0x30, 0x00, 0xB2, 0x8F,
+0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x50, 0x00, 0xBD, 0x27, 0xA0, 0xFF, 0xBD, 0x27, 0x5C, 0x00, 0xBF, 0xAF,
+0x58, 0x00, 0xBE, 0xAF, 0x54, 0x00, 0xB7, 0xAF, 0x50, 0x00, 0xB6, 0xAF,
+0x4C, 0x00, 0xB5, 0xAF, 0x48, 0x00, 0xB4, 0xAF, 0x44, 0x00, 0xB3, 0xAF,
+0x40, 0x00, 0xB2, 0xAF, 0x3C, 0x00, 0xB1, 0xAF, 0x38, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x0B, 0x3C, 0x64, 0xE8, 0x82, 0x24,
+0x78, 0xE8, 0x63, 0x25, 0x78, 0xE8, 0x6B, 0x91, 0x01, 0x00, 0x45, 0x90,
+0x0D, 0x00, 0x48, 0x90, 0x0C, 0x00, 0x58, 0x90, 0x64, 0xE8, 0x97, 0x90,
+0x02, 0x00, 0x54, 0x90, 0x0E, 0x00, 0x50, 0x90, 0x01, 0x00, 0x69, 0x90,
+0x30, 0x00, 0xAB, 0xAF, 0x03, 0x00, 0x4B, 0x90, 0x04, 0x00, 0x76, 0x90,
+0x05, 0x00, 0x6A, 0x90, 0x02, 0x00, 0x6F, 0x90, 0x06, 0x00, 0x64, 0x90,
+0x07, 0x00, 0x75, 0x90, 0x03, 0x00, 0x71, 0x90, 0x00, 0x2A, 0x05, 0x00,
+0x30, 0x00, 0xA3, 0x8F, 0x00, 0x42, 0x08, 0x00, 0x25, 0x40, 0x18, 0x01,
+0x25, 0x28, 0xB7, 0x00, 0x00, 0xA4, 0x14, 0x00, 0x00, 0x84, 0x10, 0x00,
+0x25, 0xA0, 0x85, 0x02, 0x25, 0x80, 0x08, 0x02, 0x00, 0x4A, 0x09, 0x00,
+0x00, 0x5E, 0x0B, 0x00, 0x02, 0x80, 0x08, 0x3C, 0x05, 0x00, 0x46, 0x90,
+0x09, 0x00, 0x47, 0x90, 0x25, 0x48, 0x23, 0x01, 0x00, 0x52, 0x0A, 0x00,
+0x60, 0x1B, 0x03, 0x25, 0x25, 0x58, 0x74, 0x01, 0x04, 0x00, 0x5E, 0x90,
+0x06, 0x00, 0x53, 0x90, 0x08, 0x00, 0x59, 0x90, 0x0A, 0x00, 0x52, 0x90,
+0x07, 0x00, 0x4C, 0x90, 0x0B, 0x00, 0x4D, 0x90, 0x0F, 0x00, 0x4E, 0x90,
+0x11, 0x00, 0x58, 0x90, 0x25, 0x50, 0x56, 0x01, 0x10, 0x00, 0x56, 0x90,
+0x10, 0x00, 0xAB, 0xAF, 0x06, 0x41, 0x62, 0x90, 0x00, 0x32, 0x06, 0x00,
+0x00, 0x3A, 0x07, 0x00, 0x00, 0x7C, 0x0F, 0x00, 0x00, 0x24, 0x04, 0x00,
+0x25, 0x30, 0xDE, 0x00, 0x25, 0x38, 0xF9, 0x00, 0x25, 0x20, 0x8A, 0x00,
+0x1C, 0x00, 0x43, 0x30, 0x00, 0x9C, 0x13, 0x00, 0x00, 0x94, 0x12, 0x00,
+0x25, 0x78, 0xE9, 0x01, 0x00, 0x8E, 0x11, 0x00, 0x00, 0xAE, 0x15, 0x00,
+0x25, 0x98, 0x66, 0x02, 0x25, 0x90, 0x47, 0x02, 0x03, 0x00, 0x46, 0x30,
+0x25, 0xA8, 0xA4, 0x02, 0x25, 0x88, 0x2F, 0x02, 0x10, 0x00, 0xA7, 0x27,
+0x83, 0x18, 0x03, 0x00, 0x02, 0x00, 0xC4, 0x24, 0x28, 0x00, 0xB1, 0xAF,
+0x2C, 0x00, 0xB5, 0xAF, 0x21, 0x18, 0xE3, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x04, 0x10, 0x82, 0x00, 0x18, 0x00, 0x65, 0x90, 0xFF, 0x00, 0x46, 0x30,
+0x00, 0x66, 0x0C, 0x00, 0x00, 0x6E, 0x0D, 0x00, 0x00, 0x76, 0x0E, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0x25, 0x60, 0x93, 0x01, 0x25, 0x68, 0xB2, 0x01,
+0x25, 0x70, 0xD0, 0x01, 0x10, 0x00, 0xC4, 0x2C, 0x37, 0x02, 0x42, 0x34,
+0x0F, 0x00, 0x03, 0x24, 0x14, 0x00, 0xAC, 0xAF, 0x18, 0x00, 0xAD, 0xAF,
+0x1C, 0x00, 0xAE, 0xAF, 0x20, 0x00, 0xB6, 0xA3, 0x21, 0x00, 0xB8, 0xA3,
+0x0A, 0x30, 0x64, 0x00, 0x00, 0x00, 0x45, 0xA0, 0x21, 0x28, 0x00, 0x00,
+0x21, 0x20, 0xE5, 0x00, 0x00, 0x00, 0x82, 0x90, 0x01, 0x00, 0xA5, 0x24,
+0x2B, 0x10, 0xC2, 0x00, 0x02, 0x00, 0x40, 0x10, 0x11, 0x00, 0xA3, 0x2C,
+0x00, 0x00, 0x86, 0xA0, 0xF9, 0xFF, 0x60, 0x14, 0x21, 0x20, 0xE5, 0x00,
+0x21, 0x30, 0xE0, 0x00, 0x21, 0x28, 0x00, 0x00, 0x25, 0xB0, 0x07, 0x3C,
+0x01, 0x00, 0xC2, 0x90, 0x00, 0x00, 0xC3, 0x90, 0x21, 0x20, 0xA7, 0x00,
+0x00, 0x11, 0x02, 0x00, 0x25, 0x10, 0x43, 0x00, 0x01, 0x00, 0xA5, 0x24,
+0xFF, 0x00, 0x42, 0x30, 0x08, 0x00, 0xA3, 0x2C, 0xA8, 0x01, 0x82, 0xA0,
+0xF6, 0xFF, 0x60, 0x14, 0x02, 0x00, 0xC6, 0x24, 0x21, 0x00, 0xA2, 0x93,
+0x20, 0x00, 0xA4, 0x93, 0x02, 0x80, 0x03, 0x3C, 0x00, 0x11, 0x02, 0x00,
+0xD9, 0x5C, 0x66, 0x90, 0x25, 0x10, 0x44, 0x00, 0xFF, 0x00, 0x42, 0x30,
+0xA7, 0x01, 0xE3, 0x34, 0x00, 0x00, 0x62, 0xA0, 0x01, 0x00, 0x02, 0x24,
+0x0F, 0x00, 0xC2, 0x10, 0x60, 0x1B, 0x07, 0x25, 0x60, 0x1B, 0x02, 0x25,
+0x00, 0x41, 0x40, 0xAC, 0x5C, 0x00, 0xBF, 0x8F, 0x58, 0x00, 0xBE, 0x8F,
+0x54, 0x00, 0xB7, 0x8F, 0x50, 0x00, 0xB6, 0x8F, 0x4C, 0x00, 0xB5, 0x8F,
+0x48, 0x00, 0xB4, 0x8F, 0x44, 0x00, 0xB3, 0x8F, 0x40, 0x00, 0xB2, 0x8F,
+0x3C, 0x00, 0xB1, 0x8F, 0x38, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x60, 0x00, 0xBD, 0x27, 0x04, 0x41, 0xE2, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x42, 0x30, 0xEF, 0xFF, 0x40, 0x10, 0x60, 0x1B, 0x02, 0x25,
+0x25, 0x41, 0xE3, 0x90, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x62, 0x30,
+0xEA, 0xFF, 0x40, 0x10, 0x60, 0x1B, 0x02, 0x25, 0x03, 0x00, 0x63, 0x30,
+0x10, 0x00, 0x66, 0x10, 0x03, 0x00, 0x02, 0x24, 0x07, 0x00, 0x62, 0x10,
+0x60, 0x1B, 0x02, 0x25, 0x00, 0x41, 0x40, 0xAC, 0x21, 0x20, 0x00, 0x00,
+0x95, 0x0E, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0xBE, 0x47, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x34, 0x02, 0x00, 0x05, 0x24,
+0x00, 0x41, 0xE6, 0xAC, 0x95, 0x0E, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xBE, 0x47, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x34,
+0x01, 0x00, 0x05, 0x24, 0xE2, 0x47, 0x00, 0x08, 0x00, 0x41, 0xE6, 0xAC,
+0xE8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x06, 0x3C, 0x14, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0xB4, 0x55, 0xC2, 0x24, 0x01, 0x00, 0x44, 0x90,
+0xB4, 0x55, 0xC3, 0x90, 0x02, 0x00, 0x45, 0x90, 0x03, 0x00, 0x46, 0x90,
+0x05, 0x00, 0x47, 0x90, 0x04, 0x00, 0x48, 0x90, 0x00, 0x22, 0x04, 0x00,
+0x25, 0x18, 0x64, 0x00, 0x00, 0x2C, 0x05, 0x00, 0x25, 0xB0, 0x10, 0x3C,
+0x25, 0x18, 0x65, 0x00, 0x00, 0x36, 0x06, 0x00, 0x00, 0x3A, 0x07, 0x00,
+0x25, 0x18, 0x66, 0x00, 0x58, 0x00, 0x02, 0x36, 0x5C, 0x00, 0x05, 0x36,
+0x25, 0x40, 0x07, 0x01, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x43, 0xAC,
+0xB0, 0x55, 0x84, 0x24, 0x00, 0x00, 0xA8, 0xAC, 0xFD, 0x51, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x03, 0x36, 0x00, 0x00, 0x62, 0xA4,
+0x48, 0x00, 0x10, 0x36, 0x00, 0x00, 0x02, 0x8E, 0x84, 0x00, 0x03, 0x3C,
+0x14, 0x00, 0xBF, 0x8F, 0x25, 0x10, 0x43, 0x00, 0x00, 0x00, 0x02, 0xAE,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0x24, 0x00, 0x04, 0x24, 0x21, 0x30, 0x40, 0x00,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x50, 0x24,
+0x21, 0x20, 0xC0, 0x00, 0x13, 0x00, 0xC0, 0x10, 0x80, 0xE8, 0xA5, 0x24,
+0x04, 0x00, 0x02, 0x24, 0x09, 0x00, 0x03, 0x24, 0x0C, 0x00, 0xC2, 0xAC,
+0x14, 0x00, 0xC3, 0xAC, 0x08, 0x00, 0xC5, 0x94, 0x3C, 0x3E, 0x03, 0x8E,
+0x02, 0x80, 0x02, 0x3C, 0x25, 0x28, 0xA2, 0x00, 0x17, 0x0A, 0x00, 0x0C,
+0x20, 0x00, 0xA3, 0xAC, 0x40, 0x3E, 0x06, 0x8E, 0x3C, 0x3E, 0x05, 0x8E,
+0x02, 0x80, 0x04, 0x3C, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x94, 0xE8, 0x84, 0x24, 0x13, 0x58, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0x02, 0x80, 0x04, 0x3C, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0xAC, 0xE8, 0x84, 0x24, 0x13, 0x58, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x02, 0x3C, 0xB0, 0x55, 0x43, 0x8C, 0x21, 0x90, 0x80, 0x00,
+0x3C, 0x00, 0x64, 0x24, 0x53, 0x21, 0x00, 0x0C, 0x1C, 0x00, 0x73, 0x24,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x04, 0x3C, 0x21, 0x88, 0x40, 0x00,
+0xB0, 0x55, 0xA5, 0x24, 0x74, 0x03, 0x06, 0x24, 0x19, 0x00, 0x40, 0x10,
+0xC8, 0xE8, 0x84, 0x24, 0x08, 0x00, 0x50, 0x94, 0x0A, 0x00, 0x02, 0x24,
+0x14, 0x00, 0x22, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x25, 0x80, 0x02, 0x02,
+0x0C, 0x00, 0x33, 0xAE, 0x3C, 0x00, 0x04, 0x26, 0xF4, 0x54, 0x00, 0x0C,
+0x20, 0x00, 0x10, 0x26, 0x18, 0x00, 0x12, 0xAE, 0x21, 0x20, 0x20, 0x02,
+0x17, 0x0A, 0x00, 0x0C, 0x14, 0x00, 0x12, 0xAE, 0x02, 0x80, 0x04, 0x3C,
+0x21, 0x28, 0x40, 0x02, 0x21, 0x30, 0x60, 0x02, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0xD8, 0xE8, 0x84, 0x24, 0x13, 0x58, 0x00, 0x08,
+0x28, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x06, 0x3C, 0x21, 0x28, 0x60, 0x02,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xB8, 0xE8, 0xC6, 0x24,
+0x13, 0x58, 0x00, 0x08, 0x28, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB2, 0xAF, 0xFF, 0xFF, 0x92, 0x30, 0x2A, 0x00, 0x04, 0x24,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x1C, 0x00, 0xBF, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0xFF, 0x00, 0xB1, 0x30, 0x02, 0x80, 0x05, 0x3C,
+0x21, 0x80, 0x40, 0x00, 0xB4, 0x55, 0xA5, 0x24, 0x13, 0x00, 0x40, 0x10,
+0x06, 0x00, 0x06, 0x24, 0x08, 0x00, 0x44, 0x94, 0x0A, 0x00, 0x02, 0x24,
+0x0C, 0x00, 0x02, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x25, 0x20, 0x82, 0x00,
+0x20, 0x00, 0x84, 0x24, 0x19, 0x00, 0x03, 0x24, 0x14, 0x00, 0x03, 0xAE,
+0x06, 0x00, 0x92, 0xA4, 0xF4, 0x54, 0x00, 0x0C, 0x08, 0x00, 0x91, 0xA0,
+0x21, 0x20, 0x00, 0x02, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x17, 0x0A, 0x00, 0x08,
+0x20, 0x00, 0xBD, 0x27, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xBF, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x02, 0x00, 0x82, 0x90,
+0x02, 0x80, 0x12, 0x3C, 0x60, 0x1B, 0x51, 0x26, 0xB0, 0x1B, 0x25, 0x96,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x10, 0x02, 0x00, 0x21, 0x80, 0x44, 0x00,
+0x00, 0x01, 0xA3, 0x30, 0x04, 0x00, 0x60, 0x10, 0x18, 0x00, 0x04, 0x26,
+0x00, 0x10, 0xA2, 0x30, 0x0B, 0x00, 0x40, 0x10, 0x04, 0x00, 0xA2, 0x30,
+0x21, 0x18, 0x00, 0x00, 0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xF5, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x39, 0x53, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x48, 0x37, 0x84, 0x24, 0x21, 0x28, 0x40, 0x00, 0x1D, 0x55, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0xED, 0xFF, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xB4, 0x55, 0x53, 0x24, 0x22, 0x00, 0x14, 0x26,
+0x21, 0x20, 0x80, 0x02, 0x21, 0x28, 0x60, 0x02, 0x1D, 0x55, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0xE4, 0xFF, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00,
+0x28, 0x00, 0x04, 0x26, 0x21, 0x28, 0x60, 0x02, 0x1D, 0x55, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0xDE, 0xFF, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C, 0x38, 0xE9, 0x84, 0x24,
+0xB0, 0x1B, 0x24, 0x96, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x83, 0x30,
+0x01, 0x00, 0x62, 0x30, 0x08, 0x00, 0x40, 0x10, 0x00, 0x20, 0x62, 0x30,
+0x1B, 0x00, 0x40, 0x10, 0xFF, 0xDE, 0x82, 0x30, 0xB0, 0x1B, 0x22, 0xA6,
+0xFE, 0xFF, 0x04, 0x24, 0xCC, 0x39, 0x20, 0xAE, 0x35, 0x48, 0x00, 0x0C,
+0xB0, 0x39, 0x20, 0xAE, 0x25, 0xB0, 0x10, 0x3C, 0x60, 0x1B, 0x51, 0x26,
+0x4C, 0x00, 0x02, 0x36, 0x00, 0x00, 0x40, 0xA0, 0x48, 0x00, 0x10, 0x36,
+0x21, 0x20, 0x00, 0x00, 0x21, 0x28, 0x00, 0x00, 0x95, 0x0E, 0x00, 0x0C,
+0x37, 0x3E, 0x20, 0xA2, 0x00, 0x00, 0x03, 0x8E, 0x7B, 0xFF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00, 0x00, 0x00, 0x03, 0xAE,
+0xBC, 0x40, 0x20, 0xAE, 0xE8, 0x39, 0x20, 0xAE, 0x04, 0x3A, 0x20, 0xAE,
+0x87, 0x54, 0x00, 0x0C, 0xFC, 0x40, 0x20, 0xAE, 0xA5, 0x48, 0x00, 0x08,
+0x21, 0x18, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x0C, 0x21, 0x20, 0x80, 0x02,
+0xB5, 0xFF, 0x40, 0x14, 0xFF, 0xFF, 0x03, 0x24, 0xB0, 0x1B, 0x22, 0x96,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x42, 0x30, 0xD8, 0x48, 0x00, 0x08,
+0xB0, 0x1B, 0x22, 0xA6, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x10, 0x3C, 0x60, 0x1B, 0x10, 0x26, 0x02, 0x00, 0x02, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0x00, 0x80, 0x06, 0x3C, 0x44, 0x3A, 0x02, 0xA2,
+0x90, 0x55, 0x84, 0x24, 0x21, 0x28, 0x00, 0x00, 0x3C, 0x3A, 0x00, 0xAE,
+0x14, 0x00, 0xBF, 0xAF, 0xCF, 0x20, 0x00, 0x0C, 0x70, 0x3C, 0xC6, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0xD1, 0x5C, 0x44, 0x90, 0x02, 0x80, 0x03, 0x3C,
+0x49, 0xF5, 0x65, 0x90, 0x10, 0x27, 0x02, 0x24, 0x0B, 0x10, 0x04, 0x00,
+0x01, 0x00, 0x84, 0x2C, 0x3C, 0x3A, 0x02, 0xAE, 0x49, 0x41, 0x05, 0xA2,
+0x48, 0x41, 0x04, 0xA2, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xB8, 0xFF, 0xBD, 0x27,
+0x00, 0x01, 0x04, 0x24, 0x3C, 0x00, 0xB3, 0xAF, 0x38, 0x00, 0xB2, 0xAF,
+0x34, 0x00, 0xB1, 0xAF, 0x40, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xB0, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0x02, 0x80, 0x13, 0x3C, 0x02, 0x80, 0x04, 0x3C,
+0x21, 0x88, 0x40, 0x00, 0x90, 0xDE, 0x65, 0x26, 0x06, 0x00, 0x06, 0x24,
+0x0C, 0x00, 0x52, 0x24, 0x4D, 0x00, 0x40, 0x10, 0x58, 0xE9, 0x84, 0x24,
+0x08, 0x00, 0x50, 0x94, 0x02, 0x80, 0x02, 0x3C, 0x25, 0x80, 0x02, 0x02,
+0x24, 0x00, 0x04, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x20, 0x00, 0x00, 0xA6,
+0x02, 0x80, 0x05, 0x3C, 0x2A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x30, 0x00, 0x04, 0x26,
+0x90, 0xDE, 0x65, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x20, 0x00, 0x03, 0x96, 0x18, 0x00, 0x02, 0x24, 0x02, 0x80, 0x04, 0x3C,
+0x03, 0xFF, 0x63, 0x30, 0x40, 0x00, 0x63, 0x34, 0x20, 0x00, 0x03, 0xA6,
+0x60, 0x1B, 0x84, 0x24, 0x0C, 0x00, 0x22, 0xAE, 0xE4, 0x1D, 0x82, 0x94,
+0x20, 0x00, 0x06, 0x26, 0x02, 0x80, 0x07, 0x3C, 0xFF, 0x0F, 0x43, 0x30,
+0x00, 0x19, 0x03, 0x00, 0x02, 0x2A, 0x03, 0x00, 0x01, 0x00, 0x42, 0x24,
+0xE4, 0x1D, 0x82, 0xA4, 0x16, 0x00, 0xC3, 0xA0, 0x17, 0x00, 0xC5, 0xA0,
+0x0C, 0x3E, 0x86, 0x8C, 0x70, 0x59, 0xE7, 0x24, 0x38, 0x00, 0x04, 0x26,
+0x21, 0x28, 0x00, 0x00, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB2, 0xAF,
+0x18, 0x00, 0xA4, 0x27, 0x28, 0x00, 0xA5, 0x27, 0x05, 0x53, 0x00, 0x0C,
+0x21, 0x80, 0x40, 0x00, 0x28, 0x00, 0xA3, 0x8F, 0x21, 0x20, 0x00, 0x02,
+0x18, 0x00, 0xA7, 0x27, 0x09, 0x00, 0x62, 0x28, 0x01, 0x00, 0x05, 0x24,
+0x13, 0x00, 0x40, 0x10, 0x08, 0x00, 0x06, 0x24, 0x21, 0x20, 0x00, 0x02,
+0x21, 0x30, 0x60, 0x00, 0x01, 0x00, 0x05, 0x24, 0x18, 0x00, 0xA7, 0x27,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB2, 0xAF, 0x21, 0x20, 0x20, 0x02,
+0x01, 0x00, 0x05, 0x24, 0x21, 0x30, 0x00, 0x00, 0xDF, 0x0D, 0x00, 0x0C,
+0x21, 0x38, 0x00, 0x00, 0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB3, 0x8F,
+0x38, 0x00, 0xB2, 0x8F, 0x34, 0x00, 0xB1, 0x8F, 0x30, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xB2, 0xAF, 0x28, 0x00, 0xA6, 0x8F, 0x21, 0x20, 0x40, 0x00,
+0x32, 0x00, 0x05, 0x24, 0xF8, 0xFF, 0xC6, 0x24, 0x58, 0x49, 0x00, 0x08,
+0x20, 0x00, 0xA7, 0x27, 0x02, 0x80, 0x05, 0x3C, 0x13, 0x58, 0x00, 0x0C,
+0x48, 0xE9, 0xA5, 0x24, 0x40, 0x00, 0xBF, 0x8F, 0x3C, 0x00, 0xB3, 0x8F,
+0x38, 0x00, 0xB2, 0x8F, 0x34, 0x00, 0xB1, 0x8F, 0x30, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0xA8, 0xFF, 0xBD, 0x27, 0x48, 0x00, 0xB6, 0xAF,
+0x3C, 0x00, 0xB3, 0xAF, 0x38, 0x00, 0xB2, 0xAF, 0x30, 0x00, 0xB0, 0xAF,
+0x54, 0x00, 0xBF, 0xAF, 0x50, 0x00, 0xBE, 0xAF, 0x4C, 0x00, 0xB7, 0xAF,
+0x44, 0x00, 0xB5, 0xAF, 0x40, 0x00, 0xB4, 0xAF, 0x34, 0x00, 0xB1, 0xAF,
+0x02, 0x00, 0x82, 0x90, 0x00, 0x00, 0x83, 0x8C, 0x21, 0xB0, 0x00, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0xC0, 0x10, 0x02, 0x00, 0x21, 0x80, 0x44, 0x00,
+0x18, 0x00, 0x12, 0x26, 0x21, 0x20, 0x40, 0x02, 0x39, 0x53, 0x00, 0x0C,
+0xFF, 0x3F, 0x73, 0x30, 0x02, 0x80, 0x04, 0x3C, 0x48, 0x37, 0x84, 0x24,
+0x21, 0x28, 0x40, 0x00, 0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x0B, 0x00, 0x40, 0x14, 0x02, 0x80, 0x15, 0x3C, 0x60, 0x1B, 0xB1, 0x26,
+0xB0, 0x1B, 0x23, 0x96, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x62, 0x30,
+0x05, 0x00, 0x40, 0x10, 0x00, 0x10, 0x62, 0x30, 0x03, 0x00, 0x40, 0x14,
+0x00, 0x01, 0x62, 0x30, 0x0E, 0x00, 0x40, 0x10, 0x20, 0x00, 0xB4, 0x27,
+0x54, 0x00, 0xBF, 0x8F, 0x50, 0x00, 0xBE, 0x8F, 0x4C, 0x00, 0xB7, 0x8F,
+0x48, 0x00, 0xB6, 0x8F, 0x44, 0x00, 0xB5, 0x8F, 0x40, 0x00, 0xB4, 0x8F,
+0x3C, 0x00, 0xB3, 0x8F, 0x38, 0x00, 0xB2, 0x8F, 0x34, 0x00, 0xB1, 0x8F,
+0x30, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x58, 0x00, 0xBD, 0x27, 0x32, 0x00, 0x05, 0x26, 0x21, 0x20, 0x80, 0x02,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24, 0x20, 0x00, 0xA5, 0x97,
+0x00, 0x00, 0x00, 0x00, 0xB8, 0x00, 0xA0, 0x14, 0x02, 0x80, 0x04, 0x3C,
+0x21, 0x20, 0x80, 0x02, 0x34, 0x00, 0x05, 0x26, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x20, 0x00, 0xA2, 0x97, 0x21, 0x20, 0x80, 0x02,
+0x30, 0x00, 0x05, 0x26, 0xFF, 0x3F, 0x42, 0x30, 0x02, 0x00, 0x06, 0x24,
+0x4C, 0x3A, 0x22, 0xA6, 0xF4, 0x54, 0x00, 0x0C, 0x28, 0x00, 0xA2, 0xAF,
+0x20, 0x00, 0xA3, 0x97, 0x21, 0x40, 0x20, 0x02, 0x00, 0x04, 0x63, 0x30,
+0x02, 0x00, 0x60, 0x14, 0x09, 0x00, 0x02, 0x24, 0x14, 0x00, 0x02, 0x24,
+0x1E, 0x00, 0x5E, 0x26, 0xE2, 0xFF, 0x77, 0x26, 0x21, 0x20, 0xC0, 0x03,
+0x01, 0x00, 0x05, 0x24, 0x24, 0x00, 0xA6, 0x27, 0x21, 0x38, 0xE0, 0x02,
+0xAB, 0x1A, 0x00, 0x0C, 0xB8, 0x40, 0x02, 0xA1, 0x9E, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0xA6, 0x8F, 0x02, 0x00, 0x45, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x21, 0x20, 0xC0, 0x03,
+0x32, 0x00, 0x05, 0x24, 0x24, 0x00, 0xA6, 0x27, 0x24, 0x00, 0xB4, 0x8F,
+0xAB, 0x1A, 0x00, 0x0C, 0x21, 0x38, 0xE0, 0x02, 0x08, 0x00, 0x40, 0x10,
+0x10, 0x00, 0xA4, 0x27, 0x24, 0x00, 0xA6, 0x8F, 0x21, 0x20, 0x94, 0x00,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x45, 0x24, 0x24, 0x00, 0xA3, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x21, 0xA0, 0x83, 0x02, 0x02, 0x80, 0x02, 0x3C,
+0xD2, 0x5C, 0x44, 0x90, 0x02, 0x00, 0x03, 0x24, 0xDA, 0x00, 0x83, 0x10,
+0x21, 0x20, 0xC0, 0x03, 0x60, 0x1B, 0xA4, 0x26, 0xBC, 0x40, 0x82, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x40, 0x10, 0x60, 0x1B, 0xB1, 0x26,
+0x02, 0x80, 0x02, 0x3C, 0xCE, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x1D, 0x00, 0x60, 0x14, 0x23, 0x10, 0xD2, 0x03, 0x2B, 0x10, 0x53, 0x00,
+0x1A, 0x00, 0x40, 0x10, 0x21, 0x80, 0xC0, 0x03, 0x02, 0x80, 0x11, 0x3C,
+0x21, 0x20, 0x00, 0x02, 0xDD, 0x00, 0x05, 0x24, 0x24, 0x00, 0xA6, 0x27,
+0xAB, 0x1A, 0x00, 0x0C, 0x21, 0x38, 0xE0, 0x02, 0x21, 0x80, 0x40, 0x00,
+0x02, 0x00, 0x44, 0x24, 0x68, 0xDE, 0x25, 0x26, 0x03, 0x01, 0x40, 0x10,
+0x06, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x05, 0x01, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0xA2, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x02, 0x02, 0x02, 0x00, 0x70, 0x24,
+0x23, 0x20, 0x12, 0x02, 0xF8, 0x00, 0x40, 0x10, 0x2B, 0x20, 0x93, 0x00,
+0xEB, 0xFF, 0x80, 0x14, 0x21, 0x20, 0x00, 0x02, 0x60, 0x1B, 0xB1, 0x26,
+0xFC, 0x40, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x40, 0x14,
+0x24, 0x00, 0xA6, 0x27, 0xA9, 0x1B, 0x00, 0x0C, 0x60, 0x1B, 0xB2, 0x26,
+0xB0, 0x1B, 0x45, 0x96, 0x25, 0xB0, 0x17, 0x3C, 0x02, 0x00, 0x03, 0x24,
+0x4C, 0x00, 0xE4, 0x36, 0x00, 0x00, 0x83, 0xA0, 0x00, 0x01, 0xA5, 0x34,
+0xE8, 0x39, 0x42, 0xAE, 0x60, 0xEA, 0x02, 0x34, 0x04, 0x3A, 0x42, 0xAE,
+0xEA, 0x47, 0x00, 0x0C, 0xB0, 0x1B, 0x45, 0xA6, 0x10, 0x00, 0xA4, 0x27,
+0x61, 0x53, 0x00, 0x0C, 0x21, 0x28, 0x80, 0x02, 0x0F, 0x00, 0x50, 0x30,
+0x10, 0x00, 0xA4, 0x27, 0x7A, 0x53, 0x00, 0x0C, 0x21, 0x28, 0x80, 0x02,
+0x40, 0x02, 0x13, 0x36, 0x21, 0x20, 0x60, 0x02, 0x63, 0x5E, 0x00, 0x74,
+0x21, 0x28, 0x40, 0x00, 0x21, 0x28, 0x80, 0x02, 0xA6, 0x53, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x21, 0x88, 0x40, 0x00, 0xFC, 0x40, 0x42, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x40, 0x10, 0x50, 0x00, 0x13, 0x36,
+0x07, 0x41, 0x42, 0x92, 0x08, 0x41, 0x43, 0x92, 0xB6, 0x40, 0x44, 0x92,
+0x00, 0x13, 0x02, 0x00, 0x00, 0x1D, 0x03, 0x00, 0x25, 0x10, 0x43, 0x00,
+0x04, 0x00, 0x03, 0x24, 0x9C, 0x00, 0x83, 0x10, 0x25, 0x88, 0x22, 0x02,
+0x00, 0x41, 0x43, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x60, 0x14,
+0x01, 0x00, 0x02, 0x24, 0x04, 0x41, 0x42, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x20, 0x00, 0x42, 0x30, 0x9D, 0x00, 0x40, 0x14, 0x00, 0x10, 0x02, 0x3C,
+0x01, 0x00, 0x02, 0x24, 0x94, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x94, 0xE9, 0x84, 0x24, 0x21, 0x28, 0x60, 0x02,
+0x21, 0x38, 0xC0, 0x02, 0x13, 0x58, 0x00, 0x0C, 0x21, 0x30, 0x20, 0x02,
+0x21, 0x20, 0x60, 0x02, 0x63, 0x5E, 0x00, 0x74, 0x21, 0x28, 0x20, 0x02,
+0x60, 0x1B, 0xA2, 0x26, 0xB6, 0x40, 0x43, 0x90, 0xB0, 0x1B, 0x44, 0x94,
+0x60, 0x1B, 0xA5, 0x8E, 0xFC, 0xFF, 0x63, 0x24, 0xFF, 0x00, 0x63, 0x30,
+0xFF, 0xDF, 0x84, 0x30, 0x03, 0x00, 0x63, 0x2C, 0xB0, 0x1B, 0x44, 0xA4,
+0xB0, 0x39, 0x40, 0xAC, 0xCC, 0x39, 0x40, 0xAC, 0x40, 0x41, 0x40, 0xAC,
+0x44, 0x41, 0x40, 0xAC, 0x08, 0x00, 0x60, 0x10, 0x25, 0x00, 0xA5, 0x34,
+0x28, 0x00, 0xA4, 0x8F, 0xFB, 0xFF, 0x02, 0x24, 0x24, 0x10, 0xA2, 0x00,
+0x35, 0x48, 0x00, 0x0C, 0x60, 0x1B, 0xA2, 0xAE, 0xA0, 0x49, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0xA4, 0x8F, 0x35, 0x48, 0x00, 0x0C,
+0x60, 0x1B, 0xA5, 0xAE, 0xA0, 0x49, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x13, 0x58, 0x00, 0x0C, 0x78, 0xE9, 0x84, 0x24, 0xFF, 0xFF, 0x02, 0x24,
+0x51, 0x4A, 0x00, 0x08, 0x28, 0x00, 0xA2, 0xAF, 0x21, 0x20, 0xC0, 0x03,
+0x2D, 0x00, 0x05, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x21, 0x38, 0xE0, 0x02,
+0x91, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0xAB, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x60, 0x19, 0x21, 0x40, 0x00, 0x00,
+0x02, 0x00, 0x49, 0x24, 0x21, 0x50, 0x20, 0x02, 0x02, 0x00, 0x0C, 0x24,
+0x89, 0x4A, 0x00, 0x08, 0x21, 0x68, 0x20, 0x01, 0x04, 0x41, 0x82, 0x90,
+0x00, 0x00, 0x23, 0x91, 0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x43, 0x00,
+0x04, 0x41, 0x82, 0xA0, 0x01, 0x00, 0x08, 0x25, 0x2A, 0x10, 0x0B, 0x01,
+0x11, 0x00, 0x40, 0x10, 0x01, 0x00, 0x29, 0x25, 0xF6, 0xFF, 0x0C, 0x15,
+0x21, 0x20, 0x0A, 0x01, 0x06, 0x41, 0x43, 0x91, 0x00, 0x00, 0x25, 0x91,
+0x02, 0x00, 0xA2, 0x91, 0x1C, 0x00, 0x64, 0x30, 0x1C, 0x00, 0xA5, 0x30,
+0x03, 0x00, 0x42, 0x30, 0x03, 0x00, 0x63, 0x30, 0x2A, 0x30, 0x43, 0x00,
+0x2A, 0x38, 0xA4, 0x00, 0x0A, 0x10, 0x66, 0x00, 0x0A, 0x20, 0xA7, 0x00,
+0x25, 0x10, 0x44, 0x00, 0x85, 0x4A, 0x00, 0x08, 0x06, 0x41, 0x42, 0xA1,
+0x02, 0x80, 0x02, 0x3C, 0xC6, 0x5C, 0x43, 0x90, 0x02, 0x80, 0x02, 0x3C,
+0x44, 0xDF, 0x47, 0x24, 0x10, 0x00, 0x65, 0x30, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x54, 0xDF, 0x66, 0x24, 0x60, 0x1B, 0x44, 0x24,
+0xAC, 0x4A, 0x00, 0x08, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x43, 0x90,
+0x07, 0x41, 0x82, 0x90, 0x01, 0x00, 0x08, 0x25, 0x24, 0x10, 0x43, 0x00,
+0x07, 0x41, 0x82, 0xA0, 0x10, 0x00, 0x02, 0x29, 0x07, 0x00, 0x40, 0x10,
+0x01, 0x00, 0x84, 0x24, 0x21, 0x10, 0x07, 0x01, 0xF6, 0xFF, 0xA0, 0x14,
+0x21, 0x18, 0x06, 0x01, 0x00, 0x00, 0x63, 0x90, 0xA5, 0x4A, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0xC0, 0x03, 0x21, 0x38, 0xE0, 0x02,
+0x3D, 0x00, 0x05, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x24, 0x00, 0xA6, 0x27,
+0x48, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0xA6, 0x8F,
+0x02, 0x80, 0x04, 0x3C, 0x84, 0x5C, 0x84, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x45, 0x24, 0x2E, 0x47, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x13, 0x4A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x05, 0x24,
+0x24, 0x00, 0xA6, 0x27, 0xAB, 0x1A, 0x00, 0x0C, 0x21, 0x38, 0xE0, 0x02,
+0x30, 0x00, 0x40, 0x10, 0x60, 0x1B, 0xA5, 0x26, 0x02, 0x00, 0x42, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x42, 0x30, 0x2B, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0xD3, 0x5C, 0x44, 0x90, 0x01, 0x00, 0x03, 0x24,
+0x3E, 0x00, 0x83, 0x10, 0x60, 0x1B, 0xA2, 0x26, 0xFC, 0x23, 0x43, 0x8C,
+0xFF, 0xEF, 0x04, 0x24, 0x00, 0x08, 0x63, 0x34, 0x24, 0x18, 0x64, 0x00,
+0xE9, 0x49, 0x00, 0x08, 0xFC, 0x23, 0x43, 0xAC, 0xF6, 0x01, 0xE2, 0x36,
+0x00, 0x00, 0x40, 0xA4, 0x49, 0x4A, 0x00, 0x08, 0x02, 0x80, 0x04, 0x3C,
+0x04, 0x41, 0x42, 0x96, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x42, 0x30,
+0x6A, 0xFF, 0x40, 0x10, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x10, 0x02, 0x3C,
+0x25, 0x88, 0x22, 0x02, 0x0F, 0x00, 0x08, 0x24, 0x01, 0x00, 0x03, 0x24,
+0x0C, 0x00, 0x02, 0x25, 0x04, 0x10, 0x43, 0x00, 0x24, 0x10, 0x51, 0x00,
+0x16, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x08, 0x25,
+0xFA, 0xFF, 0x01, 0x05, 0x0C, 0x00, 0x02, 0x25, 0x00, 0x12, 0x16, 0x00,
+0x00, 0x1B, 0x16, 0x00, 0x25, 0x18, 0x62, 0x00, 0x00, 0x21, 0x16, 0x00,
+0x25, 0x18, 0x64, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x25, 0x18, 0x76, 0x00,
+0xF6, 0x01, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA4, 0x49, 0x4A, 0x00, 0x08,
+0x02, 0x80, 0x04, 0x3C, 0xFC, 0x23, 0xA2, 0x8C, 0xFF, 0xF7, 0x03, 0x24,
+0xFF, 0xEF, 0x04, 0x24, 0x24, 0x10, 0x43, 0x00, 0x24, 0x10, 0x44, 0x00,
+0xE9, 0x49, 0x00, 0x08, 0xFC, 0x23, 0xA2, 0xAC, 0xEC, 0x4A, 0x00, 0x08,
+0xFF, 0x00, 0x16, 0x31, 0x60, 0x1B, 0xA2, 0x26, 0x13, 0x4A, 0x00, 0x08,
+0xFC, 0x40, 0x40, 0xAC, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0x0E, 0x4A, 0x00, 0x08, 0xBC, 0x40, 0x40, 0xAC, 0x13, 0x4A, 0x00, 0x08,
+0xFC, 0x40, 0x20, 0xAE, 0x21, 0x20, 0x00, 0x02, 0x65, 0x0F, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x00, 0x0F, 0x4A, 0x00, 0x08, 0x60, 0x1B, 0xB1, 0x26,
+0xFC, 0x23, 0x43, 0x8C, 0xFF, 0xF7, 0x04, 0x24, 0x24, 0x18, 0x64, 0x00,
+0x00, 0x10, 0x63, 0x34, 0xE9, 0x49, 0x00, 0x08, 0xFC, 0x23, 0x43, 0xAC,
+0x02, 0x80, 0x04, 0x3C, 0xB0, 0x55, 0x84, 0x24, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xBF, 0xAF, 0xFB, 0x51, 0x00, 0x0C, 0x74, 0x00, 0x84, 0x24,
+0x21, 0x28, 0x40, 0x00, 0x10, 0x00, 0xA4, 0x27, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x10, 0x00, 0xA2, 0x97, 0x25, 0xB0, 0x04, 0x3C,
+0x94, 0x00, 0x85, 0x34, 0x9A, 0x00, 0x87, 0x34, 0x26, 0xB0, 0x06, 0x3C,
+0x00, 0x08, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xA4, 0x0A, 0x00, 0x0B, 0x24,
+0x00, 0x00, 0xE3, 0xA4, 0x98, 0x00, 0x88, 0x34, 0x96, 0x00, 0x89, 0x34,
+0x7A, 0x00, 0xCA, 0x34, 0x50, 0x00, 0x02, 0x24, 0x04, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x02, 0xA5, 0x00, 0x00, 0x2B, 0xA5, 0x00, 0x00, 0x43, 0xA1,
+0x10, 0x00, 0xA2, 0x97, 0x89, 0x00, 0x83, 0x34, 0x14, 0x00, 0x07, 0x24,
+0x40, 0x11, 0x02, 0x00, 0xA0, 0xFF, 0x42, 0x24, 0xFF, 0xFF, 0x42, 0x30,
+0x9C, 0x00, 0x85, 0x34, 0x7C, 0x00, 0xC6, 0x34, 0x00, 0x00, 0xC2, 0xA4,
+0x44, 0x00, 0x84, 0x34, 0x00, 0x00, 0x67, 0xA0, 0x00, 0x00, 0xAB, 0xA0,
+0x00, 0x00, 0x82, 0x94, 0xFF, 0xFD, 0x03, 0x24, 0x18, 0x00, 0xBF, 0x8F,
+0x24, 0x10, 0x43, 0x00, 0x00, 0x00, 0x82, 0xA4, 0x00, 0x00, 0x83, 0x94,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x00, 0x02, 0x63, 0x34,
+0x20, 0x00, 0xBD, 0x27, 0x3A, 0x41, 0x40, 0xA0, 0x00, 0x00, 0x83, 0xA4,
+0x08, 0x00, 0xE0, 0x03, 0xB8, 0x40, 0x47, 0xA0, 0xD0, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x10, 0x3C, 0xB0, 0x55, 0x04, 0x26,
+0x28, 0x00, 0xBF, 0xAF, 0x24, 0x00, 0xB5, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x52, 0x00, 0x0C,
+0x18, 0x00, 0xB2, 0xAF, 0xFF, 0xFF, 0x51, 0x30, 0xB0, 0x55, 0x04, 0x26,
+0xFD, 0x51, 0x00, 0x0C, 0x02, 0x80, 0x15, 0x3C, 0x60, 0x1B, 0xA3, 0x26,
+0x01, 0x00, 0x24, 0x32, 0xB4, 0x40, 0x62, 0xA4, 0x03, 0x00, 0x80, 0x14,
+0x02, 0x00, 0x05, 0x24, 0x40, 0x10, 0x11, 0x00, 0x04, 0x00, 0x45, 0x30,
+0x02, 0x00, 0x02, 0x24, 0x5F, 0x00, 0xA2, 0x10, 0x60, 0x1B, 0xA2, 0x26,
+0x10, 0x00, 0x80, 0x10, 0x02, 0x00, 0x03, 0x24, 0x04, 0x00, 0x02, 0x24,
+0x12, 0x00, 0x62, 0x10, 0x60, 0x1B, 0xB3, 0x26, 0x02, 0x80, 0x04, 0x3C,
+0x21, 0x28, 0x20, 0x02, 0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB5, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xEC, 0xE9, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x08, 0x30, 0x00, 0xBD, 0x27, 0x40, 0x10, 0x11, 0x00,
+0x04, 0x00, 0x43, 0x30, 0x04, 0x00, 0x02, 0x24, 0xF0, 0xFF, 0x62, 0x14,
+0x60, 0x1B, 0xB3, 0x26, 0xB4, 0x40, 0x66, 0x96, 0xC4, 0x3D, 0x65, 0x92,
+0x02, 0x80, 0x04, 0x3C, 0xB0, 0x1B, 0x63, 0xA6, 0xFC, 0xE9, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x25, 0xB0, 0x10, 0x3C, 0x50, 0x02, 0x03, 0x36,
+0x0F, 0x00, 0x02, 0x24, 0x00, 0x00, 0x62, 0xA0, 0x21, 0x28, 0x00, 0x00,
+0x95, 0x0E, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0xC4, 0x3D, 0x64, 0x92,
+0x01, 0x00, 0x14, 0x24, 0x75, 0x0D, 0x00, 0x0C, 0x4C, 0x00, 0x10, 0x36,
+0x02, 0x80, 0x11, 0x3C, 0x00, 0x00, 0x14, 0xA2, 0xEA, 0x47, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x1B, 0x53, 0x00, 0x0C, 0x10, 0x56, 0x24, 0x26,
+0x21, 0x28, 0x40, 0x00, 0x10, 0x56, 0x24, 0x26, 0x61, 0x53, 0x00, 0x0C,
+0x21, 0x90, 0x40, 0x00, 0x0F, 0x00, 0x50, 0x30, 0x10, 0x56, 0x24, 0x26,
+0x7A, 0x53, 0x00, 0x0C, 0x21, 0x28, 0x40, 0x02, 0x40, 0x02, 0x10, 0x36,
+0x02, 0x80, 0x04, 0x3C, 0x21, 0x88, 0x40, 0x00, 0x21, 0x30, 0x40, 0x00,
+0x21, 0x28, 0x00, 0x02, 0x13, 0x58, 0x00, 0x0C, 0x2C, 0xEA, 0x84, 0x24,
+0x21, 0x20, 0x00, 0x02, 0x63, 0x5E, 0x00, 0x74, 0x21, 0x28, 0x20, 0x02,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0x37, 0x3A, 0x84, 0x24,
+0xB4, 0x55, 0xA5, 0x24, 0x06, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0xD6, 0x1E, 0x74, 0xA2, 0x31, 0x46, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x4B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xB0, 0x1B, 0x62, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x34, 0xA9, 0x1B, 0x00, 0x0C,
+0xB0, 0x1B, 0x62, 0xA6, 0xE8, 0x39, 0x62, 0xAE, 0x35, 0x48, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0x60, 0x1B, 0xA2, 0x8E, 0x28, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x21, 0x00, 0x42, 0x34, 0x60, 0x1B, 0xA2, 0xAE,
+0x1C, 0x00, 0xB3, 0x8F, 0x24, 0x00, 0xB5, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0x24, 0x40, 0x44, 0x8C, 0x01, 0x20, 0x03, 0x24,
+0xB0, 0x1B, 0x43, 0xA4, 0x02, 0x00, 0x85, 0x10, 0x0C, 0x00, 0x03, 0x24,
+0x0F, 0x00, 0x03, 0x24, 0x25, 0xB0, 0x02, 0x3C, 0x50, 0x02, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xA0, 0x60, 0x1B, 0xB0, 0x26, 0xB0, 0x1B, 0x02, 0x96,
+0xB4, 0x40, 0x06, 0x96, 0xC4, 0x3D, 0x05, 0x92, 0x10, 0x00, 0x42, 0x34,
+0x02, 0x80, 0x04, 0x3C, 0xB0, 0x1B, 0x02, 0xA6, 0x40, 0xEA, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x14, 0x40, 0x00, 0xAE, 0x21, 0x28, 0x00, 0x00,
+0x95, 0x0E, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0xC4, 0x3D, 0x04, 0x92,
+0x75, 0x0D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xA9, 0x1B, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0x39, 0x02, 0xAE, 0x28, 0x00, 0xBF, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27,
+0x20, 0x00, 0xB2, 0xAF, 0x21, 0x90, 0x80, 0x00, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0xFF, 0x00, 0xB0, 0x30, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x51, 0x24, 0x10, 0x00, 0xA4, 0x27, 0x01, 0x00, 0x02, 0x24,
+0x90, 0x40, 0x00, 0x0C, 0x4B, 0x41, 0x22, 0xA2, 0x02, 0x80, 0x04, 0x3C,
+0x30, 0x59, 0x84, 0x24, 0x21, 0x28, 0x00, 0x00, 0xE3, 0x54, 0x00, 0x0C,
+0x0F, 0x00, 0x06, 0x24, 0x21, 0x40, 0x00, 0x00, 0x18, 0x00, 0x00, 0x12,
+0x21, 0x60, 0x00, 0x00, 0x21, 0x68, 0x20, 0x02, 0x21, 0x10, 0x92, 0x01,
+0x01, 0x00, 0x49, 0x90, 0x00, 0x00, 0x4A, 0x90, 0x0D, 0x00, 0x20, 0x11,
+0x21, 0x30, 0x00, 0x00, 0x21, 0x58, 0xA0, 0x01, 0x01, 0x00, 0xC2, 0x24,
+0x21, 0x38, 0x46, 0x01, 0x01, 0x00, 0x03, 0x25, 0xFF, 0x00, 0x46, 0x30,
+0x0E, 0x00, 0x02, 0x2D, 0x21, 0x28, 0x0B, 0x01, 0x2B, 0x20, 0xC9, 0x00,
+0x08, 0x00, 0x40, 0x10, 0xFF, 0x00, 0x68, 0x30, 0xF6, 0xFF, 0x80, 0x14,
+0xD0, 0x3D, 0xA7, 0xA0, 0x03, 0x00, 0x82, 0x25, 0xFF, 0x00, 0x4C, 0x30,
+0x2B, 0x18, 0x90, 0x01, 0xEC, 0xFF, 0x60, 0x14, 0x21, 0x10, 0x92, 0x01,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27,
+0x10, 0x00, 0xBF, 0xAF, 0x90, 0x48, 0x00, 0x0C, 0xFE, 0xFF, 0x05, 0x24,
+0x10, 0x00, 0xBF, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x90, 0x48, 0x00, 0x0C, 0xFF, 0xFF, 0x05, 0x24, 0x10, 0x00, 0xBF, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0x25, 0xB0, 0x03, 0x3C, 0x01, 0x80, 0x02, 0x3C, 0xB0, 0x03, 0x65, 0x34,
+0xAC, 0x30, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34, 0x00, 0x00, 0x62, 0xAC,
+0x00, 0x00, 0xA4, 0xAC, 0x00, 0x00, 0x83, 0x8C, 0x21, 0x10, 0x00, 0x00,
+0xFF, 0x3F, 0x63, 0x30, 0x00, 0x00, 0xA3, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x06, 0x3C,
+0x02, 0x80, 0x08, 0x3C, 0x78, 0x00, 0xBE, 0xAF, 0x7C, 0x00, 0xBF, 0xAF,
+0x74, 0x00, 0xB7, 0xAF, 0x70, 0x00, 0xB6, 0xAF, 0x6C, 0x00, 0xB5, 0xAF,
+0x68, 0x00, 0xB4, 0xAF, 0x64, 0x00, 0xB3, 0xAF, 0x60, 0x00, 0xB2, 0xAF,
+0x5C, 0x00, 0xB1, 0xAF, 0x58, 0x00, 0xB0, 0xAF, 0xE8, 0xE9, 0xC2, 0x24,
+0x74, 0xEA, 0x03, 0x25, 0x01, 0x00, 0x44, 0x90, 0x01, 0x00, 0x65, 0x90,
+0xE8, 0xE9, 0xCB, 0x90, 0x74, 0xEA, 0x0A, 0x91, 0x02, 0x00, 0x47, 0x90,
+0x02, 0x00, 0x66, 0x90, 0x03, 0x00, 0x48, 0x90, 0x03, 0x00, 0x69, 0x90,
+0x00, 0x22, 0x04, 0x00, 0x00, 0x2A, 0x05, 0x00, 0x25, 0x20, 0x8B, 0x00,
+0x25, 0x28, 0xAA, 0x00, 0x00, 0x3C, 0x07, 0x00, 0x00, 0x34, 0x06, 0x00,
+0x25, 0x38, 0xE4, 0x00, 0x25, 0x30, 0xC5, 0x00, 0x00, 0x46, 0x08, 0x00,
+0x00, 0x4E, 0x09, 0x00, 0x25, 0x40, 0x07, 0x01, 0x25, 0x48, 0x26, 0x01,
+0x00, 0x02, 0x04, 0x24, 0x40, 0x00, 0xA8, 0xAF, 0x53, 0x21, 0x00, 0x0C,
+0x48, 0x00, 0xA9, 0xAF, 0xCF, 0x01, 0x40, 0x10, 0x21, 0xF0, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x52, 0x24, 0xC0, 0x3A, 0x45, 0x8E,
+0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C, 0x78, 0xEA, 0x84, 0x24,
+0x08, 0x00, 0xD1, 0x97, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x10, 0x3C,
+0x25, 0x88, 0x22, 0x02, 0xB4, 0x55, 0x10, 0x26, 0x24, 0x00, 0x24, 0x26,
+0x21, 0x28, 0x00, 0x02, 0x20, 0x00, 0x20, 0xA6, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C, 0x2A, 0x00, 0x24, 0x26,
+0x48, 0x37, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x21, 0x28, 0x00, 0x02, 0x06, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x30, 0x00, 0x24, 0x26, 0x18, 0x00, 0x03, 0x24, 0x0C, 0x00, 0xC3, 0xAF,
+0xE4, 0x1D, 0x42, 0x96, 0x20, 0x00, 0x25, 0x26, 0x38, 0x00, 0x37, 0x26,
+0xFF, 0x0F, 0x43, 0x30, 0x00, 0x19, 0x03, 0x00, 0x02, 0x22, 0x03, 0x00,
+0x01, 0x00, 0x42, 0x24, 0xE4, 0x1D, 0x42, 0xA6, 0x17, 0x00, 0xA4, 0xA0,
+0x02, 0x80, 0x04, 0x3C, 0x16, 0x00, 0xA3, 0xA0, 0x16, 0x52, 0x00, 0x0C,
+0x24, 0x56, 0x84, 0x24, 0x21, 0x28, 0x40, 0x00, 0x21, 0x20, 0xE0, 0x02,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24, 0x3A, 0x00, 0x24, 0x26,
+0x18, 0x00, 0xA5, 0x27, 0x02, 0x00, 0x06, 0x24, 0x03, 0x00, 0x02, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0x18, 0x00, 0xA2, 0xA7, 0x0C, 0x00, 0xC3, 0x8F,
+0x02, 0x80, 0x07, 0x3C, 0x3C, 0x00, 0x24, 0x26, 0x04, 0x00, 0x63, 0x24,
+0x0C, 0x00, 0xC3, 0xAF, 0x5C, 0x3A, 0x46, 0x8E, 0x0C, 0x00, 0xC3, 0x27,
+0xC0, 0x55, 0xE7, 0x24, 0x21, 0x28, 0x00, 0x00, 0x54, 0x00, 0xA3, 0xAF,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF, 0x20, 0x00, 0xA4, 0x27,
+0x50, 0x00, 0xA5, 0x27, 0x05, 0x53, 0x00, 0x0C, 0x21, 0xB8, 0x40, 0x00,
+0x50, 0x00, 0xA8, 0x8F, 0x21, 0x88, 0x00, 0x00, 0x52, 0x00, 0x00, 0x11,
+0x21, 0x80, 0x00, 0x00, 0x21, 0x38, 0x40, 0x02, 0x18, 0x00, 0xA9, 0x27,
+0x21, 0x10, 0x31, 0x01, 0x08, 0x00, 0x46, 0x90, 0x21, 0x20, 0x00, 0x00,
+0x7F, 0x00, 0xC5, 0x30, 0x21, 0x10, 0x87, 0x00, 0xB0, 0x3A, 0x43, 0x90,
+0x01, 0x00, 0x84, 0x24, 0x7F, 0x00, 0x63, 0x30, 0x3D, 0x00, 0xA3, 0x10,
+0x0D, 0x00, 0x82, 0x2C, 0xFA, 0xFF, 0x40, 0x14, 0x21, 0x10, 0x87, 0x00,
+0x01, 0x00, 0x31, 0x26, 0x2B, 0x10, 0x28, 0x02, 0xF2, 0xFF, 0x40, 0x14,
+0x21, 0x10, 0x31, 0x01, 0x09, 0x00, 0x02, 0x2E, 0x3D, 0x00, 0x40, 0x14,
+0x21, 0x20, 0xE0, 0x02, 0x54, 0x00, 0xA2, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0x08, 0x00, 0x06, 0x24, 0x30, 0x00, 0xA7, 0x27, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xA2, 0xAF, 0x54, 0x00, 0xA3, 0x8F, 0x21, 0x20, 0x40, 0x00,
+0xF8, 0xFF, 0x06, 0x26, 0x32, 0x00, 0x05, 0x24, 0x38, 0x00, 0xA7, 0x27,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF, 0x21, 0xB8, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x44, 0x24, 0x24, 0x40, 0x83, 0x8C,
+0x02, 0x00, 0x02, 0x24, 0x37, 0x00, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00,
+0xC0, 0x3A, 0x83, 0x8C, 0x0C, 0x00, 0x11, 0x24, 0x2B, 0x10, 0x23, 0x02,
+0x32, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x24, 0x56, 0x46, 0x24,
+0x21, 0x20, 0x60, 0x00, 0xE0, 0x4C, 0x00, 0x08, 0x30, 0x00, 0x05, 0x24,
+0x01, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x02, 0x00, 0x51, 0x24, 0x2B, 0x18, 0x24, 0x02, 0x27, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x26, 0x02, 0x00, 0x00, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xF5, 0xFF, 0x45, 0x14, 0x02, 0x80, 0x07, 0x3C,
+0x01, 0x00, 0x66, 0x90, 0x54, 0x00, 0xA2, 0x8F, 0x26, 0x56, 0xE7, 0x24,
+0x21, 0x20, 0xE0, 0x02, 0x21, 0x38, 0x27, 0x02, 0x30, 0x00, 0x05, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0x06, 0x4D, 0x00, 0x08,
+0x21, 0xB8, 0x40, 0x00, 0x21, 0x10, 0x30, 0x01, 0x18, 0x00, 0x46, 0xA0,
+0x50, 0x00, 0xA8, 0x8F, 0x01, 0x00, 0x31, 0x26, 0x2B, 0x10, 0x28, 0x02,
+0xB4, 0xFF, 0x40, 0x14, 0x01, 0x00, 0x10, 0x26, 0xBA, 0x4C, 0x00, 0x08,
+0x09, 0x00, 0x02, 0x2E, 0x54, 0x00, 0xA3, 0x8F, 0x21, 0x20, 0xE0, 0x02,
+0x21, 0x30, 0x00, 0x02, 0x01, 0x00, 0x05, 0x24, 0x30, 0x00, 0xA7, 0x27,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF, 0x21, 0xB8, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x44, 0x24, 0x24, 0x40, 0x83, 0x8C,
+0x02, 0x00, 0x02, 0x24, 0xCB, 0xFF, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x1B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x40, 0x14,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x43, 0x24, 0xC0, 0x3A, 0x62, 0x8C,
+0x0C, 0x00, 0x11, 0x24, 0x2B, 0x10, 0x22, 0x02, 0x11, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x21, 0x80, 0x60, 0x00, 0x24, 0x56, 0x52, 0x24,
+0x21, 0xA8, 0x60, 0x00, 0x02, 0x80, 0x13, 0x3C, 0x21, 0x20, 0x32, 0x02,
+0x00, 0x00, 0x83, 0x90, 0x2D, 0x00, 0x02, 0x24, 0xD6, 0x00, 0x62, 0x10,
+0x02, 0x80, 0x05, 0x3C, 0x01, 0x00, 0x82, 0x90, 0xC0, 0x3A, 0x03, 0x8E,
+0x21, 0x10, 0x51, 0x00, 0x02, 0x00, 0x51, 0x24, 0x2B, 0x18, 0x23, 0x02,
+0xF6, 0xFF, 0x60, 0x14, 0x21, 0x20, 0x32, 0x02, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x44, 0x24, 0x24, 0x40, 0x83, 0x8C, 0x02, 0x00, 0x02, 0x24,
+0x86, 0x00, 0x62, 0x10, 0x0C, 0x00, 0x11, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x43, 0x24, 0xC0, 0x3A, 0x62, 0x8C, 0x0C, 0x00, 0x11, 0x24,
+0x2B, 0x10, 0x22, 0x02, 0x26, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x24, 0x56, 0x56, 0x24, 0x21, 0xA8, 0x60, 0x00, 0xDD, 0x00, 0x14, 0x24,
+0x39, 0x4D, 0x00, 0x08, 0x02, 0x80, 0x13, 0x3C, 0x01, 0x00, 0x02, 0x92,
+0xC0, 0x3A, 0xA3, 0x8E, 0x21, 0x10, 0x51, 0x00, 0x02, 0x00, 0x51, 0x24,
+0x2B, 0x18, 0x23, 0x02, 0x1B, 0x00, 0x60, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x21, 0x80, 0x36, 0x02, 0x00, 0x00, 0x02, 0x92, 0x02, 0x00, 0x12, 0x26,
+0x21, 0x20, 0x40, 0x02, 0x70, 0xDE, 0x65, 0x26, 0xF3, 0xFF, 0x54, 0x14,
+0x06, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xEF, 0xFF, 0x40, 0x14, 0x21, 0x20, 0xE0, 0x02, 0x54, 0x00, 0xA2, 0x8F,
+0xDD, 0x00, 0x05, 0x24, 0x21, 0x38, 0x40, 0x02, 0x07, 0x00, 0x06, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0x08, 0x00, 0x04, 0x92,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x65, 0x24, 0x21, 0xB8, 0x40, 0x00,
+0x01, 0x00, 0x03, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x08, 0x5E, 0x44, 0xA0,
+0xBC, 0x40, 0xA3, 0xAC, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x64, 0x24,
+0xC0, 0x3A, 0x82, 0x8C, 0x0C, 0x00, 0x11, 0x24, 0x2B, 0x10, 0x22, 0x02,
+0x20, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x24, 0x56, 0x56, 0x24, 0x26, 0x56, 0x75, 0x24, 0x21, 0xA0, 0x80, 0x00,
+0x66, 0x4D, 0x00, 0x08, 0xDD, 0x00, 0x13, 0x24, 0x01, 0x00, 0x02, 0x92,
+0xC0, 0x3A, 0x83, 0x8E, 0x21, 0x10, 0x51, 0x00, 0x02, 0x00, 0x51, 0x24,
+0x2B, 0x18, 0x23, 0x02, 0x14, 0x00, 0x60, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x80, 0x36, 0x02, 0x00, 0x00, 0x02, 0x92, 0x21, 0x90, 0x35, 0x02,
+0x21, 0x20, 0x40, 0x02, 0x48, 0x00, 0xA5, 0x27, 0xF3, 0xFF, 0x53, 0x14,
+0x04, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xEF, 0xFF, 0x40, 0x14, 0x21, 0x20, 0xE0, 0x02, 0x01, 0x00, 0x06, 0x92,
+0x54, 0x00, 0xA2, 0x8F, 0x21, 0x38, 0x40, 0x02, 0xDD, 0x00, 0x05, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF, 0x21, 0xB8, 0x40, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x44, 0x24, 0xFC, 0x40, 0x83, 0x8C,
+0x01, 0x00, 0x02, 0x24, 0x61, 0x00, 0x62, 0x10, 0x06, 0x00, 0x02, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x62, 0x24, 0xC0, 0x3A, 0x43, 0x8C,
+0x0C, 0x00, 0x11, 0x24, 0x2B, 0x10, 0x23, 0x02, 0x10, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x24, 0x56, 0x46, 0x24, 0x21, 0x20, 0x60, 0x00,
+0x44, 0x00, 0x05, 0x24, 0x21, 0x80, 0x26, 0x02, 0x00, 0x00, 0x02, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x45, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x02, 0x00, 0x51, 0x24, 0x2B, 0x18, 0x24, 0x02, 0xF6, 0xFF, 0x60, 0x14,
+0x21, 0x80, 0x26, 0x02, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x62, 0x24,
+0xB6, 0x40, 0x43, 0x90, 0x04, 0x00, 0x07, 0x24, 0x21, 0x20, 0xC0, 0x03,
+0x01, 0x00, 0x63, 0x38, 0x0B, 0x38, 0x03, 0x00, 0x21, 0x28, 0x00, 0x00,
+0xDF, 0x0D, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x21, 0x10, 0x00, 0x00,
+0x7C, 0x00, 0xBF, 0x8F, 0x78, 0x00, 0xBE, 0x8F, 0x74, 0x00, 0xB7, 0x8F,
+0x70, 0x00, 0xB6, 0x8F, 0x6C, 0x00, 0xB5, 0x8F, 0x68, 0x00, 0xB4, 0x8F,
+0x64, 0x00, 0xB3, 0x8F, 0x60, 0x00, 0xB2, 0x8F, 0x5C, 0x00, 0xB1, 0x8F,
+0x58, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x80, 0x00, 0xBD, 0x27,
+0xC0, 0x3A, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x10, 0x22, 0x02,
+0x77, 0xFF, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x24, 0x56, 0x56, 0x24, 0x26, 0x56, 0x75, 0x24, 0x21, 0xA0, 0x80, 0x00,
+0xBD, 0x4D, 0x00, 0x08, 0xDD, 0x00, 0x13, 0x24, 0x01, 0x00, 0x02, 0x92,
+0xC0, 0x3A, 0x83, 0x8E, 0x21, 0x10, 0x51, 0x00, 0x02, 0x00, 0x51, 0x24,
+0x2B, 0x18, 0x23, 0x02, 0x6B, 0xFF, 0x60, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x80, 0x36, 0x02, 0x00, 0x00, 0x02, 0x92, 0x21, 0x90, 0x35, 0x02,
+0x21, 0x20, 0x40, 0x02, 0x40, 0x00, 0xA5, 0x27, 0xF3, 0xFF, 0x53, 0x14,
+0x04, 0x00, 0x06, 0x24, 0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xEF, 0xFF, 0x40, 0x14, 0x21, 0x20, 0xE0, 0x02, 0x01, 0x00, 0x06, 0x92,
+0x54, 0x00, 0xA3, 0x8F, 0x21, 0x38, 0x40, 0x02, 0xDD, 0x00, 0x05, 0x24,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF, 0x26, 0x4D, 0x00, 0x08,
+0x21, 0xB8, 0x40, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C,
+0x8C, 0xEA, 0x84, 0x24, 0x01, 0x00, 0x06, 0x92, 0x54, 0x00, 0xA2, 0x8F,
+0x02, 0x80, 0x07, 0x3C, 0x26, 0x56, 0xE7, 0x24, 0x21, 0x38, 0x27, 0x02,
+0x21, 0x20, 0xE0, 0x02, 0x44, 0x00, 0x05, 0x24, 0x25, 0x52, 0x00, 0x0C,
+0x10, 0x00, 0xA2, 0xAF, 0x95, 0x4D, 0x00, 0x08, 0x02, 0x80, 0x03, 0x3C,
+0xB6, 0x40, 0x83, 0x90, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x62, 0x10,
+0x05, 0x00, 0x02, 0x24, 0x9C, 0xFF, 0x62, 0x14, 0x02, 0x80, 0x03, 0x3C,
+0x02, 0x80, 0x07, 0x3C, 0x21, 0x20, 0xE0, 0x02, 0x34, 0xDE, 0xE7, 0x24,
+0xDD, 0x00, 0x05, 0x24, 0x06, 0x00, 0x06, 0x24, 0x54, 0x00, 0xA3, 0x8F,
+0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF, 0x7E, 0x4D, 0x00, 0x08,
+0x21, 0xB8, 0x40, 0x00, 0x02, 0x80, 0x14, 0x3C, 0x26, 0x56, 0xA5, 0x24,
+0x21, 0x28, 0x25, 0x02, 0x64, 0x5C, 0x84, 0x26, 0xF4, 0x54, 0x00, 0x0C,
+0x20, 0x00, 0x06, 0x24, 0x02, 0x80, 0x03, 0x3C, 0xD9, 0x5C, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x41, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00, 0xBD, 0xFF, 0x42, 0x30,
+0x04, 0x41, 0x02, 0xA6, 0x02, 0x80, 0x02, 0x3C, 0xC4, 0xDF, 0x44, 0x8C,
+0x04, 0x41, 0xA3, 0x96, 0x20, 0x00, 0x80, 0x10, 0x0C, 0x00, 0x62, 0x34,
+0x00, 0x01, 0x42, 0x34, 0x04, 0x41, 0xA2, 0xA6, 0x02, 0x80, 0x03, 0x3C,
+0xC6, 0x5C, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x15, 0x00, 0x40, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x67, 0x5C, 0x64, 0x26, 0x44, 0xDF, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x10, 0x00, 0x06, 0x24, 0x21, 0x10, 0x32, 0x02, 0x01, 0x00, 0x46, 0x90,
+0x54, 0x00, 0xA3, 0x8F, 0x21, 0x20, 0xE0, 0x02, 0x64, 0x5C, 0x87, 0x26,
+0x2D, 0x00, 0x05, 0x24, 0x25, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA3, 0xAF,
+0x21, 0xB8, 0x40, 0x00, 0x01, 0x00, 0x02, 0x24, 0x20, 0x4D, 0x00, 0x08,
+0xFC, 0x40, 0x02, 0xAE, 0x04, 0x41, 0x02, 0x96, 0xFC, 0x4D, 0x00, 0x08,
+0x02, 0x00, 0x42, 0x34, 0x67, 0x5C, 0x64, 0x26, 0x0D, 0x4E, 0x00, 0x08,
+0x54, 0xDF, 0xA5, 0x24, 0x04, 0x4E, 0x00, 0x08, 0x04, 0x41, 0xA2, 0xA6,
+0x02, 0x80, 0x02, 0x3C, 0x34, 0xDE, 0x42, 0x24, 0x06, 0x00, 0x48, 0x90,
+0x02, 0x00, 0x03, 0x24, 0x21, 0x20, 0xE0, 0x02, 0x01, 0x00, 0x08, 0x35,
+0x21, 0x38, 0x40, 0x00, 0xDD, 0x00, 0x05, 0x24, 0x07, 0x00, 0x06, 0x24,
+0x04, 0x00, 0x43, 0xA0, 0xE9, 0x4D, 0x00, 0x08, 0x06, 0x00, 0x48, 0xA0,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0xAC, 0xE8, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x64, 0xEA, 0xA5, 0x24, 0x9F, 0x4D, 0x00, 0x08,
+0xFF, 0xFF, 0x02, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0xB0, 0x1B, 0x43, 0x94, 0x32, 0x00, 0x04, 0x24, 0xCC, 0x39, 0x44, 0xAC,
+0x9F, 0xFE, 0x63, 0x30, 0x80, 0x00, 0x63, 0x34, 0xB0, 0x1B, 0x43, 0xA4,
+0x18, 0x40, 0x40, 0xAC, 0x1C, 0x40, 0x40, 0xAC, 0x38, 0x4C, 0x00, 0x08,
+0xB0, 0x39, 0x40, 0xAC, 0xE8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF, 0x60, 0x1B, 0x50, 0x24,
+0x1C, 0x40, 0x03, 0x8E, 0xFE, 0xFF, 0x04, 0x24, 0x01, 0x00, 0x63, 0x24,
+0x03, 0x00, 0x62, 0x2C, 0x12, 0x00, 0x40, 0x10, 0x1C, 0x40, 0x03, 0xAE,
+0xB0, 0x1B, 0x02, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x30,
+0x05, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0x38, 0x4C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x03, 0x24,
+0xCC, 0x39, 0x03, 0xAE, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xB0, 0x1B, 0x02, 0x96,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xDF, 0x42, 0x30, 0x35, 0x48, 0x00, 0x0C,
+0xB0, 0x1B, 0x02, 0xA6, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x2C, 0x00, 0xBF, 0xAF,
+0x02, 0x00, 0x82, 0x90, 0x02, 0x80, 0x14, 0x3C, 0x60, 0x1B, 0x92, 0x26,
+0xB0, 0x1B, 0x43, 0x96, 0x00, 0x00, 0x85, 0x8C, 0x0F, 0x00, 0x42, 0x30,
+0xC0, 0x10, 0x02, 0x00, 0x21, 0x80, 0x44, 0x00, 0x01, 0x00, 0x63, 0x30,
+0xFF, 0x3F, 0xB3, 0x30, 0x18, 0x00, 0x11, 0x26, 0x0A, 0x00, 0x60, 0x14,
+0x21, 0x20, 0x00, 0x00, 0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x80, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0x39, 0x53, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02,
+0x02, 0x80, 0x04, 0x3C, 0x48, 0x37, 0x84, 0x24, 0x21, 0x28, 0x40, 0x00,
+0x1D, 0x55, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0xEF, 0xFF, 0x40, 0x14,
+0x21, 0x20, 0x00, 0x00, 0xB0, 0x1B, 0x42, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x10, 0x42, 0x30, 0xEA, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x00, 0x03, 0x96, 0x04, 0x00, 0x04, 0x24, 0x21, 0x10, 0x80, 0x00,
+0x00, 0x40, 0x63, 0x30, 0x0A, 0x10, 0x03, 0x00, 0x21, 0x10, 0x22, 0x02,
+0x1C, 0x00, 0x43, 0x94, 0x1A, 0x00, 0x45, 0x94, 0x2F, 0x00, 0x60, 0x14,
+0x02, 0x00, 0x02, 0x24, 0x14, 0x00, 0xA2, 0x10, 0x01, 0x00, 0x02, 0x24,
+0x0E, 0x00, 0xA4, 0x14, 0x02, 0x80, 0x04, 0x3C, 0x24, 0x40, 0x43, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x62, 0x10, 0x60, 0x1B, 0x83, 0x26,
+0xB0, 0x1B, 0x62, 0x94, 0xFF, 0xFF, 0x04, 0x24, 0xFF, 0xDF, 0x42, 0x30,
+0x7B, 0x4E, 0x00, 0x08, 0xB0, 0x1B, 0x62, 0xA4, 0x36, 0x4E, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x7B, 0x4E, 0x00, 0x08, 0x21, 0x20, 0x00, 0x00,
+0x13, 0x58, 0x00, 0x0C, 0x04, 0xEB, 0x84, 0x24, 0xA4, 0x4E, 0x00, 0x08,
+0x60, 0x1B, 0x83, 0x26, 0x24, 0x40, 0x43, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0xF5, 0xFF, 0x62, 0x14, 0xE2, 0xFF, 0x67, 0x26, 0x36, 0x00, 0x04, 0x26,
+0x10, 0x00, 0x05, 0x24, 0xAB, 0x1A, 0x00, 0x0C, 0x10, 0x00, 0xA6, 0x27,
+0x16, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xA6, 0x8F,
+0x02, 0x80, 0x04, 0x3C, 0x94, 0x5B, 0x84, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x45, 0x24, 0xB0, 0x1B, 0x43, 0x96, 0x21, 0x20, 0x00, 0x00,
+0x03, 0x00, 0x02, 0x24, 0xDF, 0xFF, 0x63, 0x30, 0x40, 0x00, 0x63, 0x34,
+0xB0, 0x1B, 0x43, 0xA6, 0x2D, 0x14, 0x00, 0x0C, 0x20, 0x40, 0x42, 0xAE,
+0x7B, 0x4E, 0x00, 0x08, 0x21, 0x20, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x2C, 0xEB, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x21, 0x28, 0x60, 0x00,
+0xA4, 0x4E, 0x00, 0x08, 0x60, 0x1B, 0x83, 0x26, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0x48, 0xEB, 0x84, 0x24, 0xA4, 0x4E, 0x00, 0x08,
+0x60, 0x1B, 0x83, 0x26, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x63, 0x24,
+0xB0, 0x1B, 0x62, 0x94, 0x01, 0x00, 0x05, 0x24, 0x21, 0x20, 0x00, 0x00,
+0xEF, 0xFF, 0x42, 0x30, 0x20, 0x00, 0x42, 0x34, 0xB0, 0x1B, 0x62, 0xA4,
+0x32, 0x00, 0x02, 0x24, 0x20, 0x40, 0x65, 0xAC, 0xB0, 0x39, 0x62, 0xAC,
+0xCC, 0x39, 0x60, 0xAC, 0x18, 0x40, 0x60, 0xAC, 0x2D, 0x14, 0x00, 0x08,
+0x1C, 0x40, 0x60, 0xAC, 0xE8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x07, 0x3C,
+0x14, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0xE6, 0x24,
+0x18, 0x40, 0xC2, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x45, 0x24,
+0x03, 0x00, 0xA3, 0x2C, 0x0E, 0x00, 0x60, 0x14, 0x60, 0x1B, 0xF0, 0x24,
+0x24, 0x40, 0xC3, 0x8C, 0x03, 0x00, 0x02, 0x24, 0x16, 0x00, 0x62, 0x10,
+0xFF, 0xFF, 0x04, 0x24, 0xB0, 0x1B, 0xC2, 0x94, 0x18, 0x40, 0xC5, 0xAC,
+0xFF, 0xDF, 0x42, 0x30, 0x35, 0x48, 0x00, 0x0C, 0xB0, 0x1B, 0xC2, 0xA4,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xB0, 0x1B, 0x03, 0x96, 0xBF, 0xFF, 0x02, 0x24,
+0x18, 0x40, 0xC5, 0xAC, 0x24, 0x10, 0x62, 0x00, 0x80, 0x00, 0x63, 0x30,
+0x21, 0x20, 0x00, 0x00, 0x0F, 0x00, 0x60, 0x10, 0x20, 0x00, 0x45, 0x34,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xB0, 0x1B, 0x03, 0x96, 0x01, 0x00, 0x02, 0x24,
+0x24, 0x40, 0xC2, 0xAC, 0xBF, 0xFF, 0x02, 0x24, 0x24, 0x10, 0x62, 0x00,
+0x80, 0x00, 0x63, 0x30, 0x18, 0x40, 0xC0, 0xAC, 0x21, 0x20, 0x00, 0x00,
+0xF3, 0xFF, 0x60, 0x14, 0x20, 0x00, 0x45, 0x34, 0x01, 0x00, 0x02, 0x24,
+0x20, 0x40, 0x02, 0xAE, 0x2D, 0x14, 0x00, 0x0C, 0xB0, 0x1B, 0x05, 0xA6,
+0x32, 0x00, 0x03, 0x24, 0xB0, 0x39, 0x03, 0xAE, 0x14, 0x00, 0xBF, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0xD0, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xB2, 0xAF, 0x21, 0x90, 0x80, 0x00,
+0x00, 0x01, 0x04, 0x24, 0x24, 0x00, 0xB3, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x21, 0x98, 0xA0, 0x00, 0x28, 0x00, 0xBF, 0xAF, 0x53, 0x21, 0x00, 0x0C,
+0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x21, 0x88, 0x40, 0x00, 0x58, 0xEC, 0x84, 0x24, 0x38, 0x00, 0x40, 0x10,
+0x48, 0xEC, 0xA5, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x30, 0x96, 0x02, 0x80, 0x02, 0x3C, 0x21, 0x28, 0x40, 0x02,
+0x25, 0x80, 0x02, 0x02, 0x24, 0x00, 0x04, 0x26, 0x20, 0x00, 0x00, 0xA6,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0x2A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C, 0x30, 0x00, 0x04, 0x26,
+0xB4, 0x55, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x20, 0x00, 0x03, 0x96, 0x18, 0x00, 0x02, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0x03, 0xFF, 0x63, 0x30, 0xC0, 0x00, 0x63, 0x34, 0x20, 0x00, 0x03, 0xA6,
+0x60, 0x1B, 0xA5, 0x24, 0x0C, 0x00, 0x22, 0xAE, 0xE4, 0x1D, 0xA3, 0x94,
+0x20, 0x00, 0x07, 0x26, 0x38, 0x00, 0x04, 0x26, 0xFF, 0x0F, 0x62, 0x30,
+0x00, 0x11, 0x02, 0x00, 0x02, 0x32, 0x02, 0x00, 0x01, 0x00, 0x63, 0x24,
+0xE4, 0x1D, 0xA3, 0xA4, 0x17, 0x00, 0xE6, 0xA0, 0x16, 0x00, 0xE2, 0xA0,
+0x10, 0x00, 0xA6, 0x27, 0x0C, 0x00, 0x27, 0x26, 0x02, 0x00, 0x05, 0x24,
+0x4C, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB3, 0xA7, 0x21, 0x20, 0x20, 0x02,
+0x21, 0x28, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00, 0xDF, 0x0D, 0x00, 0x0C,
+0x21, 0x38, 0x00, 0x00, 0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xAC, 0xE8, 0x84, 0x24, 0x28, 0x00, 0xBF, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xD0, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB1, 0xAF, 0x21, 0x88, 0x80, 0x00,
+0x00, 0x01, 0x04, 0x24, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x21, 0x98, 0xA0, 0x00, 0x28, 0x00, 0xBF, 0xAF, 0x53, 0x21, 0x00, 0x0C,
+0x18, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x21, 0x90, 0x40, 0x00, 0x78, 0xEC, 0x84, 0x24, 0x3B, 0x00, 0x40, 0x10,
+0x68, 0xEC, 0xA5, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x50, 0x96, 0x02, 0x80, 0x02, 0x3C, 0x21, 0x28, 0x20, 0x02,
+0x25, 0x80, 0x02, 0x02, 0x24, 0x00, 0x04, 0x26, 0x20, 0x00, 0x00, 0xA6,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0x2A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C, 0x30, 0x00, 0x04, 0x26,
+0xB4, 0x55, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x20, 0x00, 0x03, 0x96, 0x18, 0x00, 0x02, 0x24, 0x02, 0x80, 0x11, 0x3C,
+0x03, 0xFF, 0x63, 0x30, 0xA0, 0x00, 0x63, 0x34, 0x20, 0x00, 0x03, 0xA6,
+0x60, 0x1B, 0x31, 0x26, 0x0C, 0x00, 0x42, 0xAE, 0xE4, 0x1D, 0x23, 0x96,
+0x20, 0x00, 0x06, 0x26, 0x38, 0x00, 0x04, 0x26, 0xFF, 0x0F, 0x62, 0x30,
+0x00, 0x11, 0x02, 0x00, 0x02, 0x2A, 0x02, 0x00, 0x01, 0x00, 0x63, 0x24,
+0xE4, 0x1D, 0x23, 0xA6, 0x0C, 0x00, 0x47, 0x26, 0x17, 0x00, 0xC5, 0xA0,
+0x16, 0x00, 0xC2, 0xA0, 0x02, 0x00, 0x05, 0x24, 0x10, 0x00, 0xA6, 0x27,
+0x4C, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xB3, 0xA7, 0xB6, 0x40, 0x23, 0x92,
+0x04, 0x00, 0x07, 0x24, 0x21, 0x20, 0x40, 0x02, 0x01, 0x00, 0x63, 0x38,
+0x0B, 0x38, 0x03, 0x00, 0x21, 0x28, 0x00, 0x00, 0xDF, 0x0D, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xAC, 0xE8, 0x84, 0x24, 0x28, 0x00, 0xBF, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xC8, 0xFF, 0xBD, 0x27, 0x2C, 0x00, 0xB1, 0xAF, 0xFF, 0xFF, 0x05, 0x24,
+0x21, 0x88, 0x80, 0x00, 0x02, 0x00, 0x06, 0x24, 0x10, 0x00, 0xA4, 0x27,
+0x34, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xB2, 0xAF, 0xEC, 0x54, 0x00, 0x0C,
+0x28, 0x00, 0xB0, 0xAF, 0x08, 0x00, 0x30, 0x96, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x28, 0x00, 0x00, 0x25, 0x80, 0x02, 0x02, 0x21, 0x20, 0x00, 0x02,
+0xEC, 0x54, 0x00, 0x0C, 0x10, 0x00, 0x06, 0x24, 0x20, 0x00, 0x02, 0x96,
+0x24, 0x00, 0x04, 0x26, 0x10, 0x00, 0xA5, 0x27, 0x03, 0xFF, 0x42, 0x30,
+0xC8, 0x00, 0x42, 0x34, 0x20, 0x00, 0x02, 0xA6, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x25, 0xB0, 0x03, 0x3C, 0x50, 0x00, 0x62, 0x34,
+0x00, 0x00, 0x44, 0x8C, 0x54, 0x00, 0x65, 0x34, 0x58, 0x00, 0x66, 0x34,
+0x18, 0x00, 0xA4, 0xAF, 0x00, 0x00, 0xA2, 0x8C, 0x5C, 0x00, 0x63, 0x34,
+0x2A, 0x00, 0x04, 0x26, 0x1C, 0x00, 0xA2, 0xAF, 0x00, 0x00, 0xC7, 0x8C,
+0x18, 0x00, 0xA5, 0x27, 0x06, 0x00, 0x06, 0x24, 0x20, 0x00, 0xA7, 0xAF,
+0x00, 0x00, 0x62, 0x8C, 0x1A, 0x00, 0x12, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x24, 0x00, 0xA2, 0xAF, 0x30, 0x00, 0x04, 0x26, 0x20, 0x00, 0xA5, 0x27,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x13, 0x00, 0x03, 0x24,
+0x14, 0x00, 0x23, 0xAE, 0x0C, 0x00, 0x32, 0xAE, 0x08, 0x00, 0x05, 0x8E,
+0x04, 0x00, 0x04, 0x8E, 0xFF, 0xDF, 0x02, 0x3C, 0x14, 0x00, 0x06, 0x8E,
+0xFF, 0xFF, 0x42, 0x34, 0x10, 0x00, 0x07, 0x8E, 0xFF, 0xE0, 0x03, 0x24,
+0x24, 0x28, 0xA2, 0x00, 0x00, 0x40, 0x02, 0x3C, 0x24, 0x20, 0x83, 0x00,
+0x25, 0x28, 0xA2, 0x00, 0xFF, 0x81, 0x03, 0x24, 0xFE, 0xFF, 0x02, 0x3C,
+0x24, 0x30, 0xC3, 0x00, 0xFF, 0xFF, 0x42, 0x34, 0x00, 0x12, 0x84, 0x34,
+0x00, 0x80, 0x03, 0x3C, 0x24, 0x20, 0x82, 0x00, 0x25, 0x38, 0xE3, 0x00,
+0x00, 0x26, 0xC6, 0x34, 0x80, 0x00, 0xA5, 0x34, 0x20, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x12, 0xA6, 0x10, 0x00, 0x07, 0xAE, 0x02, 0x00, 0x02, 0xA2,
+0x14, 0x00, 0x06, 0xAE, 0x04, 0x00, 0x04, 0xAE, 0x08, 0x00, 0x05, 0xAE,
+0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F,
+0x28, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0xB0, 0xFF, 0xBD, 0x27, 0x3C, 0x00, 0xB5, 0xAF, 0x34, 0x00, 0xB3, 0xAF,
+0xFF, 0xFF, 0xF5, 0x30, 0x25, 0xB0, 0x13, 0x3C, 0x01, 0x80, 0x02, 0x3C,
+0x2C, 0x00, 0xB1, 0xAF, 0x18, 0x03, 0x63, 0x36, 0x54, 0x40, 0x42, 0x24,
+0x20, 0x00, 0xB1, 0x26, 0x48, 0x00, 0xBE, 0xAF, 0x44, 0x00, 0xB7, 0xAF,
+0x38, 0x00, 0xB4, 0xAF, 0x64, 0x00, 0xB7, 0x93, 0x60, 0x00, 0xB4, 0x93,
+0x21, 0xF0, 0x80, 0x00, 0x00, 0x00, 0x62, 0xAC, 0x21, 0x20, 0x20, 0x02,
+0x40, 0x00, 0xB6, 0xAF, 0x30, 0x00, 0xB2, 0xAF, 0x4C, 0x00, 0xBF, 0xAF,
+0x28, 0x00, 0xB0, 0xAF, 0xFF, 0x00, 0xB6, 0x30, 0x53, 0x21, 0x00, 0x0C,
+0xFF, 0x00, 0xD2, 0x30, 0x12, 0x00, 0x40, 0x14, 0x24, 0x00, 0xA2, 0xAF,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0xAC, 0xE8, 0x84, 0x24,
+0x13, 0x58, 0x00, 0x0C, 0x88, 0xEC, 0xA5, 0x24, 0x4C, 0x00, 0xBF, 0x8F,
+0x48, 0x00, 0xBE, 0x8F, 0x44, 0x00, 0xB7, 0x8F, 0x40, 0x00, 0xB6, 0x8F,
+0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F,
+0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x50, 0x00, 0xBD, 0x27, 0x08, 0x00, 0x43, 0x8C,
+0xB0, 0x03, 0x62, 0x36, 0x02, 0x80, 0x10, 0x3C, 0x00, 0x00, 0x43, 0xAC,
+0x24, 0x00, 0xA2, 0x8F, 0x21, 0x30, 0x20, 0x02, 0x21, 0x28, 0x00, 0x00,
+0x08, 0x00, 0x44, 0x94, 0xE3, 0x54, 0x00, 0x0C, 0x25, 0x20, 0x90, 0x00,
+0x24, 0x00, 0xA3, 0x8F, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x88, 0x50, 0x00, 0x5C, 0x00, 0x80, 0x16,
+0x20, 0x00, 0x30, 0x26, 0x20, 0x00, 0x32, 0xA6, 0x48, 0x00, 0x02, 0x24,
+0x7A, 0x00, 0x42, 0x12, 0xC8, 0x00, 0x02, 0x24, 0x79, 0x00, 0x42, 0x12,
+0x50, 0x00, 0x62, 0x36, 0x04, 0x00, 0x02, 0x24, 0x56, 0x00, 0xC2, 0x16,
+0x21, 0x28, 0xC0, 0x03, 0xA4, 0x00, 0x02, 0x24, 0x9F, 0x00, 0x42, 0x12,
+0x02, 0x80, 0x02, 0x3C, 0x24, 0x00, 0xA2, 0x8F, 0x25, 0xB0, 0x10, 0x3C,
+0xB0, 0x03, 0x10, 0x36, 0x0C, 0x00, 0x55, 0xAC, 0x24, 0x00, 0xA2, 0x8F,
+0x12, 0x00, 0x03, 0x24, 0x21, 0x28, 0x00, 0x00, 0x14, 0x00, 0x43, 0xAC,
+0x00, 0x00, 0x15, 0xAE, 0x24, 0x00, 0xA2, 0x8F, 0x08, 0x00, 0x06, 0x24,
+0x08, 0x00, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xAE,
+0x24, 0x00, 0xA2, 0x8F, 0x02, 0x80, 0x03, 0x3C, 0x08, 0x00, 0x44, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x88, 0x83, 0x00, 0xEC, 0x54, 0x00, 0x0C,
+0x21, 0x20, 0x20, 0x02, 0x04, 0x00, 0x25, 0x8E, 0x08, 0x00, 0x24, 0x8E,
+0xFF, 0xDF, 0x02, 0x3C, 0xFF, 0xE0, 0x03, 0x24, 0xFF, 0xFF, 0x42, 0x34,
+0x14, 0x00, 0x26, 0x8E, 0x24, 0x28, 0xA3, 0x00, 0x24, 0x20, 0x82, 0x00,
+0x00, 0x40, 0x02, 0x3C, 0x10, 0x00, 0x27, 0x8E, 0x25, 0x20, 0x82, 0x00,
+0xE0, 0xFF, 0x03, 0x24, 0x00, 0x12, 0xA5, 0x34, 0xFF, 0xE0, 0x02, 0x3C,
+0x24, 0x28, 0xA3, 0x00, 0xFF, 0xFF, 0x42, 0x34, 0xFF, 0x81, 0x03, 0x24,
+0x24, 0x30, 0xC3, 0x00, 0x24, 0x20, 0x82, 0x00, 0x00, 0x05, 0x03, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x25, 0x38, 0xE2, 0x00, 0x25, 0x20, 0x83, 0x00,
+0x05, 0x00, 0xA5, 0x34, 0x20, 0x00, 0x02, 0x24, 0x08, 0x00, 0x24, 0xAE,
+0x00, 0x00, 0x35, 0xA6, 0x02, 0x00, 0x22, 0xA2, 0x14, 0x00, 0x26, 0xAE,
+0x10, 0x00, 0x27, 0xAE, 0x04, 0x00, 0x25, 0xAE, 0x8A, 0x40, 0x00, 0x0C,
+0x20, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x24, 0x00, 0xA3, 0x8F,
+0x98, 0x54, 0x42, 0x24, 0x04, 0x00, 0x44, 0x8C, 0x00, 0x00, 0x62, 0xAC,
+0x04, 0x00, 0x43, 0xAC, 0x24, 0x00, 0xA2, 0x27, 0x00, 0x00, 0x83, 0xAC,
+0x04, 0x00, 0x64, 0xAC, 0x20, 0x00, 0xA4, 0x27, 0x00, 0x00, 0x02, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x00, 0xBF, 0x8F,
+0x48, 0x00, 0xBE, 0x8F, 0x44, 0x00, 0xB7, 0x8F, 0x40, 0x00, 0xB6, 0x8F,
+0x3C, 0x00, 0xB5, 0x8F, 0x38, 0x00, 0xB4, 0x8F, 0x34, 0x00, 0xB3, 0x8F,
+0x30, 0x00, 0xB2, 0x8F, 0x2C, 0x00, 0xB1, 0x8F, 0x28, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x50, 0x00, 0xBD, 0x27, 0x00, 0x10, 0x42, 0x36,
+0x53, 0x50, 0x00, 0x08, 0x20, 0x00, 0x22, 0xA6, 0x04, 0x00, 0x04, 0x26,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0x48, 0x37, 0xA5, 0x24, 0x0A, 0x00, 0x04, 0x26, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C, 0xB4, 0x55, 0xA5, 0x24,
+0x10, 0x00, 0x04, 0x26, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x00, 0x1E, 0x12, 0x00, 0x03, 0x1E, 0x03, 0x00, 0x28, 0x00, 0x60, 0x04,
+0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24, 0xE4, 0x1D, 0xA6, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC2, 0x24, 0x00, 0x21, 0x06, 0x00,
+0xFF, 0xFF, 0x46, 0x30, 0xFF, 0xFF, 0x84, 0x30, 0x00, 0x10, 0xC2, 0x2C,
+0x0A, 0x30, 0x02, 0x00, 0x02, 0x1A, 0x04, 0x00, 0x17, 0x00, 0x03, 0xA2,
+0x16, 0x00, 0x04, 0xA2, 0x5E, 0x50, 0x00, 0x08, 0xE4, 0x1D, 0xA6, 0xA4,
+0x50, 0x00, 0x62, 0x36, 0x00, 0x00, 0x43, 0x8C, 0x54, 0x00, 0x64, 0x36,
+0x58, 0x00, 0x65, 0x36, 0x10, 0x00, 0xA3, 0xAF, 0x00, 0x00, 0x82, 0x8C,
+0x5C, 0x00, 0x67, 0x36, 0x2A, 0x00, 0x24, 0x26, 0x14, 0x00, 0xA2, 0xAF,
+0x00, 0x00, 0xA3, 0x8C, 0x06, 0x00, 0x06, 0x24, 0x10, 0x00, 0xA5, 0x27,
+0x18, 0x00, 0xA3, 0xAF, 0x00, 0x00, 0xE2, 0x8C, 0xF4, 0x54, 0x00, 0x0C,
+0x1C, 0x00, 0xA2, 0xAF, 0x30, 0x00, 0x24, 0x26, 0x18, 0x00, 0xA5, 0x27,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x20, 0x00, 0x23, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x63, 0x34, 0x58, 0x50, 0x00, 0x08,
+0x20, 0x00, 0x23, 0xA6, 0x02, 0x80, 0x02, 0x3C, 0xFF, 0xFF, 0xE3, 0x32,
+0x60, 0x1B, 0x42, 0x24, 0x40, 0x28, 0x17, 0x00, 0x18, 0x00, 0x03, 0xA2,
+0x21, 0x28, 0xA2, 0x00, 0x19, 0x00, 0x00, 0xA2, 0xD4, 0x1D, 0xA6, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC2, 0x24, 0x00, 0x21, 0x06, 0x00,
+0xFF, 0xFF, 0x46, 0x30, 0xFF, 0xFF, 0x84, 0x30, 0x00, 0x10, 0xC2, 0x2C,
+0x0A, 0x30, 0x02, 0x00, 0x02, 0x1A, 0x04, 0x00, 0x17, 0x00, 0x03, 0xA2,
+0x16, 0x00, 0x04, 0xA2, 0x5E, 0x50, 0x00, 0x08, 0xD4, 0x1D, 0xA6, 0xA4,
+0xAC, 0x55, 0x43, 0x94, 0x02, 0x80, 0x05, 0x3C, 0x04, 0x00, 0x04, 0x26,
+0x00, 0xC0, 0x63, 0x24, 0xFF, 0xFF, 0x63, 0x30, 0x02, 0x12, 0x03, 0x00,
+0xB4, 0x55, 0xA5, 0x24, 0x03, 0x00, 0x02, 0xA2, 0x02, 0x00, 0x03, 0xA2,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x02, 0x80, 0x05, 0x3C,
+0x0A, 0x00, 0x04, 0x26, 0x48, 0x37, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x5E, 0x50, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x82, 0x30, 0x02, 0x80, 0x04, 0x3C, 0xE0, 0xFF, 0xBD, 0x27,
+0xB4, 0x55, 0x84, 0x24, 0x08, 0x00, 0x05, 0x24, 0x48, 0x00, 0x06, 0x24,
+0x18, 0x00, 0x07, 0x24, 0x18, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xA2, 0xAF,
+0x15, 0x50, 0x00, 0x0C, 0x14, 0x00, 0xA0, 0xAF, 0x18, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xC8, 0xFF, 0xBD, 0x27, 0x2C, 0x00, 0xB5, 0xAF, 0x02, 0x80, 0x15, 0x3C,
+0x1C, 0x00, 0xB1, 0xAF, 0x34, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xB6, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0xB1, 0x26, 0xB0, 0x1B, 0x23, 0x96,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x62, 0x30, 0x37, 0x00, 0x40, 0x14,
+0x00, 0x01, 0x62, 0x30, 0x2A, 0x00, 0x40, 0x10, 0x00, 0x10, 0x62, 0x30,
+0x25, 0x00, 0x40, 0x14, 0x01, 0x00, 0x62, 0x30, 0x45, 0x00, 0x40, 0x14,
+0x04, 0x00, 0x62, 0x30, 0x21, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x21, 0x98, 0x20, 0x02, 0x47, 0x39, 0x56, 0x24, 0x01, 0x00, 0x14, 0x24,
+0x20, 0x01, 0x11, 0x24, 0x3E, 0x51, 0x00, 0x08, 0x19, 0x00, 0x12, 0x24,
+0xFF, 0xFF, 0x52, 0x26, 0x18, 0x00, 0x40, 0x06, 0x30, 0x00, 0x31, 0x26,
+0x21, 0x80, 0x33, 0x02, 0xE6, 0x1D, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xF9, 0xFF, 0x54, 0x14, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1D, 0x02, 0x8E,
+0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x40, 0x14, 0x10, 0x00, 0xA4, 0x27,
+0x3A, 0x41, 0x62, 0x92, 0x21, 0x20, 0x36, 0x02, 0xFF, 0xFF, 0x42, 0x24,
+0x3A, 0x41, 0x62, 0xA2, 0xC4, 0x0E, 0x00, 0x0C, 0xE6, 0x1D, 0x00, 0xA2,
+0x3C, 0x51, 0x00, 0x08, 0xFF, 0xFF, 0x52, 0x26, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x10, 0x00, 0xA4, 0x27, 0x14, 0x40, 0x20, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0xE8, 0x1E, 0x20, 0xAE, 0xA9, 0x1B, 0x00, 0x0C,
+0x60, 0x1B, 0xB0, 0x26, 0xE8, 0x39, 0x02, 0xAE, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F,
+0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x38, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C,
+0x98, 0xEC, 0x84, 0x24, 0xB0, 0x1B, 0x22, 0x96, 0xE8, 0x39, 0x20, 0xAE,
+0xFD, 0xFF, 0x04, 0x24, 0xEF, 0xDF, 0x42, 0x30, 0x35, 0x48, 0x00, 0x0C,
+0xB0, 0x1B, 0x22, 0xA6, 0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xB6, 0x8F,
+0x2C, 0x00, 0xB5, 0x8F, 0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F,
+0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0xE8, 0x1E, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00, 0xD5, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x40, 0x22, 0x8E, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x00, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0xEE, 0x5D, 0x43, 0x90,
+0x01, 0x00, 0x04, 0x24, 0x0F, 0x00, 0x63, 0x30, 0x05, 0x00, 0x63, 0x28,
+0x0E, 0x00, 0x60, 0x10, 0x14, 0x40, 0x24, 0xAE, 0x0E, 0x51, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xA9, 0x1B, 0x00, 0x0C, 0x60, 0x1B, 0xB0, 0x26,
+0x58, 0x51, 0x00, 0x08, 0xE8, 0x39, 0x02, 0xAE, 0x8A, 0x40, 0x00, 0x0C,
+0xFF, 0xFF, 0x52, 0x26, 0x10, 0x00, 0xA4, 0x27, 0x90, 0x40, 0x00, 0x0C,
+0xF8, 0x1D, 0x00, 0xAE, 0x3C, 0x51, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x0E, 0x51, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0x87, 0x51, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C,
+0xB8, 0xEC, 0x84, 0x24, 0x25, 0xB0, 0x06, 0x3C, 0x4C, 0x00, 0xC2, 0x34,
+0x00, 0x00, 0x40, 0xA0, 0x48, 0x00, 0xC6, 0x34, 0x00, 0x00, 0xC3, 0x8C,
+0xB0, 0x1B, 0x27, 0x96, 0x7B, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x18, 0x62, 0x00, 0xFE, 0xFE, 0xE7, 0x30, 0x00, 0x00, 0xC3, 0xAC,
+0x21, 0x28, 0x00, 0x00, 0xB0, 0x1B, 0x27, 0xA6, 0x21, 0x20, 0x00, 0x00,
+0x37, 0x3E, 0x20, 0xA2, 0x95, 0x0E, 0x00, 0x0C, 0xD6, 0x1E, 0x20, 0xA2,
+0x02, 0x80, 0x04, 0x3C, 0xC4, 0x0E, 0x00, 0x0C, 0xB4, 0x55, 0x84, 0x24,
+0xA9, 0x1B, 0x00, 0x0C, 0x60, 0x1B, 0xB0, 0x26, 0x58, 0x51, 0x00, 0x08,
+0xE8, 0x39, 0x02, 0xAE, 0xFF, 0x00, 0x84, 0x30, 0x02, 0x00, 0x02, 0x24,
+0x03, 0x00, 0x83, 0x28, 0x0D, 0x00, 0x82, 0x10, 0x21, 0x28, 0x00, 0x00,
+0x06, 0x00, 0x60, 0x10, 0x04, 0x00, 0x02, 0x24, 0x01, 0x00, 0x02, 0x24,
+0x0B, 0x00, 0x82, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0xA0, 0x00, 0xFD, 0xFF, 0x82, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x04, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x06, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB1, 0xAF, 0xFF, 0x00, 0x91, 0x30,
+0x02, 0x80, 0x04, 0x3C, 0x18, 0x00, 0xB0, 0xAF, 0xD4, 0xEC, 0x84, 0x24,
+0xFF, 0x00, 0xB0, 0x30, 0x20, 0x00, 0xBF, 0xAF, 0x13, 0x58, 0x00, 0x0C,
+0x21, 0x28, 0x20, 0x02, 0xB1, 0x51, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02,
+0x02, 0x80, 0x04, 0x3C, 0xB4, 0x55, 0x84, 0x24, 0x08, 0x00, 0x05, 0x24,
+0xC8, 0x00, 0x06, 0x24, 0x1A, 0x00, 0x07, 0x24, 0x10, 0x00, 0xB1, 0xAF,
+0x15, 0x50, 0x00, 0x0C, 0x14, 0x00, 0xA2, 0xAF, 0x20, 0x00, 0xBF, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x05, 0x3C,
+0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x60, 0x1B, 0xA5, 0x24,
+0x4C, 0x3A, 0xA2, 0x94, 0x01, 0x00, 0x03, 0x24, 0xFF, 0x00, 0x90, 0x30,
+0x00, 0xC0, 0x42, 0x24, 0xFF, 0xFF, 0x44, 0x30, 0xA3, 0x31, 0x00, 0x0C,
+0x2A, 0x1C, 0xA3, 0xA0, 0x02, 0x80, 0x04, 0x3C, 0xB4, 0x55, 0x84, 0x24,
+0x04, 0x00, 0x05, 0x24, 0xA4, 0x00, 0x06, 0x24, 0x10, 0x00, 0x07, 0x24,
+0x10, 0x00, 0xB0, 0xAF, 0x15, 0x50, 0x00, 0x0C, 0x14, 0x00, 0xA0, 0xAF,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x80, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x08, 0x00, 0x82, 0x24, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xBF, 0xAF, 0xFB, 0x51, 0x00, 0x0C, 0x74, 0x00, 0x84, 0x24,
+0x21, 0x28, 0x40, 0x00, 0x10, 0x00, 0xA4, 0x27, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x10, 0x00, 0xA2, 0x97, 0x18, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xBF, 0xAF, 0xFB, 0x51, 0x00, 0x0C,
+0x10, 0x00, 0xA5, 0xA7, 0x21, 0x20, 0x40, 0x00, 0x10, 0x00, 0xA5, 0x27,
+0xF4, 0x54, 0x00, 0x0C, 0x02, 0x00, 0x06, 0x24, 0x18, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0xE0, 0x03, 0x0A, 0x00, 0x82, 0x24, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xBF, 0xAF, 0x16, 0x52, 0x00, 0x0C, 0x74, 0x00, 0x84, 0x24,
+0x21, 0x28, 0x40, 0x00, 0x10, 0x00, 0xA4, 0x27, 0xF4, 0x54, 0x00, 0x0C,
+0x02, 0x00, 0x06, 0x24, 0x10, 0x00, 0xA2, 0x97, 0x18, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x00, 0x00, 0x05, 0xA2, 0x01, 0x00, 0x06, 0xA2, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF, 0x21, 0x88, 0xC0, 0x00,
+0x02, 0x00, 0x84, 0x24, 0x30, 0x00, 0xB2, 0x8F, 0x0D, 0x00, 0xC0, 0x14,
+0x21, 0x28, 0xE0, 0x00, 0x00, 0x00, 0x43, 0x8E, 0x21, 0x10, 0x11, 0x02,
+0x1C, 0x00, 0xBF, 0x8F, 0x21, 0x18, 0x71, 0x00, 0x02, 0x00, 0x63, 0x24,
+0x00, 0x00, 0x43, 0xAE, 0x14, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x02, 0x00, 0x42, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xF4, 0x54, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x43, 0x8E, 0x21, 0x10, 0x11, 0x02, 0x1C, 0x00, 0xBF, 0x8F,
+0x21, 0x18, 0x71, 0x00, 0x02, 0x00, 0x63, 0x24, 0x00, 0x00, 0x43, 0xAE,
+0x14, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x02, 0x00, 0x42, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0xA0, 0x00,
+0x18, 0x00, 0xB2, 0xAF, 0x21, 0x28, 0xC0, 0x00, 0x21, 0x90, 0xE0, 0x00,
+0x21, 0x30, 0x00, 0x02, 0x1C, 0x00, 0xBF, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0xF4, 0x54, 0x00, 0x0C, 0x21, 0x88, 0x80, 0x00, 0x00, 0x00, 0x43, 0x8E,
+0x21, 0x10, 0x30, 0x02, 0x1C, 0x00, 0xBF, 0x8F, 0x21, 0x18, 0x70, 0x00,
+0x00, 0x00, 0x43, 0xAE, 0x14, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x7F, 0x00, 0x84, 0x30, 0x6D, 0x00, 0x82, 0x2C, 0x0A, 0x00, 0x40, 0x10,
+0x21, 0x28, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x80, 0x10, 0x04, 0x00,
+0xFC, 0xEC, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x28, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x0B, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x0A, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x09, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x08, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x07, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x06, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x03, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x05, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x04, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x02, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x01, 0x00, 0x05, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x7F, 0x00, 0x84, 0x30, 0x0C, 0x00, 0x82, 0x2C, 0x0A, 0x00, 0x40, 0x10,
+0x21, 0x18, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x80, 0x10, 0x04, 0x00,
+0xB0, 0xEE, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x6C, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x60, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x48, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x30, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x24, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x18, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x12, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x0C, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x16, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x0B, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x04, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x02, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0xC8, 0xFF, 0xBD, 0x27, 0x24, 0x00, 0xB5, 0xAF, 0x02, 0x80, 0x15, 0x3C,
+0x2C, 0x00, 0xB7, 0xAF, 0x28, 0x00, 0xB6, 0xAF, 0x20, 0x00, 0xB4, 0xAF,
+0x1C, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0xB8, 0x80, 0x00,
+0x21, 0xA0, 0x00, 0x00, 0x21, 0x98, 0x00, 0x00, 0x60, 0x1B, 0xB6, 0x26,
+0x60, 0x1B, 0xA2, 0x26, 0x21, 0x10, 0x62, 0x02, 0xFB, 0x1B, 0x51, 0x90,
+0xFE, 0x00, 0x03, 0x24, 0x1E, 0x00, 0x23, 0x12, 0xFF, 0x00, 0x02, 0x24,
+0x21, 0x00, 0x22, 0x12, 0x21, 0x10, 0x80, 0x02, 0x91, 0x52, 0x00, 0x0C,
+0x21, 0x20, 0x20, 0x02, 0x21, 0x88, 0x40, 0x00, 0x21, 0x80, 0x00, 0x00,
+0x21, 0x90, 0xC0, 0x02, 0x21, 0x10, 0x12, 0x02, 0xEE, 0x1B, 0x44, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x82, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x02, 0x00, 0x42, 0x2C, 0x05, 0x00, 0x40, 0x14, 0x01, 0x00, 0x10, 0x26,
+0x91, 0x52, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x51, 0x10,
+0x01, 0x00, 0x03, 0x24, 0x0D, 0x00, 0x02, 0x2A, 0xF3, 0xFF, 0x40, 0x14,
+0x21, 0x10, 0x12, 0x02, 0x21, 0x18, 0x00, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x14, 0x00, 0x62, 0x10, 0xFF, 0x00, 0x22, 0x32, 0x21, 0x10, 0xF4, 0x02,
+0x00, 0x00, 0x51, 0xA0, 0x01, 0x00, 0x94, 0x26, 0x01, 0x00, 0x73, 0x26,
+0x0D, 0x00, 0x62, 0x2A, 0xDB, 0xFF, 0x40, 0x14, 0x60, 0x1B, 0xA2, 0x26,
+0x21, 0x10, 0x80, 0x02, 0x30, 0x00, 0xBF, 0x8F, 0x2C, 0x00, 0xB7, 0x8F,
+0x28, 0x00, 0xB6, 0x8F, 0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27,
+0xF0, 0x52, 0x00, 0x08, 0x80, 0x00, 0x51, 0x34, 0xD0, 0xFF, 0xBD, 0x27,
+0x24, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xB0, 0xAF, 0x21, 0x88, 0x80, 0x00,
+0x21, 0x80, 0xA0, 0x00, 0x0D, 0x00, 0x06, 0x24, 0x21, 0x28, 0x00, 0x00,
+0x28, 0x00, 0xBF, 0xAF, 0xE3, 0x54, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0xC1, 0x52, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x00, 0x00, 0x02, 0xAE,
+0x21, 0x20, 0x20, 0x02, 0x10, 0x00, 0xA5, 0x27, 0xF4, 0x54, 0x00, 0x0C,
+0x21, 0x30, 0x40, 0x00, 0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB1, 0x8F,
+0x20, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0x21, 0x28, 0x00, 0x00, 0x21, 0x10, 0x85, 0x00, 0x00, 0x00, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x60, 0x10, 0x0D, 0x00, 0xA2, 0x2C,
+0xFA, 0xFF, 0x40, 0x14, 0x01, 0x00, 0xA5, 0x24, 0xFF, 0xFF, 0xA5, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00, 0x00, 0x00, 0x82, 0x94,
+0x21, 0x30, 0x80, 0x00, 0x10, 0x00, 0x85, 0x24, 0x42, 0x1A, 0x02, 0x00,
+0xC2, 0x11, 0x02, 0x00, 0x02, 0x00, 0x42, 0x30, 0x01, 0x00, 0x63, 0x30,
+0x25, 0x18, 0x43, 0x00, 0x01, 0x00, 0x04, 0x24, 0x07, 0x00, 0x64, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x60, 0x10, 0x0A, 0x00, 0xC5, 0x24,
+0x02, 0x00, 0x02, 0x24, 0x02, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x00, 0xC5, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xA0, 0x00,
+0x00, 0x00, 0x82, 0x94, 0x21, 0x30, 0x80, 0x00, 0x04, 0x00, 0x85, 0x24,
+0x42, 0x1A, 0x02, 0x00, 0xC2, 0x11, 0x02, 0x00, 0x02, 0x00, 0x42, 0x30,
+0x01, 0x00, 0x63, 0x30, 0x25, 0x18, 0x43, 0x00, 0x01, 0x00, 0x04, 0x24,
+0x04, 0x00, 0x64, 0x10, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xC5, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0xA0, 0x00, 0x13, 0x00, 0xA0, 0x18, 0x21, 0x30, 0x00, 0x00,
+0x02, 0x00, 0x07, 0x24, 0x04, 0x00, 0x08, 0x24, 0x0B, 0x00, 0x09, 0x24,
+0x16, 0x00, 0x0A, 0x24, 0x21, 0x10, 0x86, 0x00, 0x00, 0x00, 0x43, 0x90,
+0x01, 0x00, 0xC6, 0x24, 0x7F, 0x00, 0x63, 0x30, 0x07, 0x00, 0x67, 0x10,
+0x2A, 0x10, 0xC5, 0x00, 0x05, 0x00, 0x68, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x03, 0x00, 0x69, 0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x6A, 0x14,
+0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x14, 0x00, 0xBF, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0x5C, 0x5C, 0x43, 0x8C,
+0x08, 0x00, 0x10, 0x24, 0x06, 0x00, 0xA0, 0x14, 0x0A, 0x80, 0x03, 0x00,
+0x21, 0x10, 0x00, 0x02, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x49, 0x53, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x36, 0x01, 0x00, 0x42, 0x38,
+0x03, 0x00, 0x04, 0x36, 0x21, 0x80, 0x60, 0x00, 0x0B, 0x80, 0x82, 0x00,
+0x21, 0x10, 0x00, 0x02, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27,
+0x14, 0x00, 0xB1, 0xAF, 0x0E, 0x00, 0xA3, 0x2C, 0x21, 0x88, 0xA0, 0x00,
+0x0D, 0x00, 0x02, 0x24, 0x0A, 0x88, 0x43, 0x00, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xBF, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x21, 0x98, 0x80, 0x00, 0x21, 0x90, 0x00, 0x00,
+0x15, 0x00, 0x20, 0x12, 0x21, 0x80, 0x00, 0x00, 0x8E, 0x53, 0x00, 0x08,
+0x01, 0x00, 0x14, 0x24, 0x2B, 0x10, 0x11, 0x02, 0x11, 0x00, 0x40, 0x10,
+0x21, 0x10, 0x40, 0x02, 0x21, 0x18, 0x70, 0x02, 0x00, 0x00, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x44, 0x30, 0x00, 0x16, 0x02, 0x00,
+0x03, 0x16, 0x02, 0x00, 0xF6, 0xFF, 0x41, 0x04, 0x01, 0x00, 0x10, 0x26,
+0x61, 0x52, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x54, 0x00,
+0x25, 0x90, 0x42, 0x02, 0x2B, 0x10, 0x11, 0x02, 0xF3, 0xFF, 0x40, 0x14,
+0x21, 0x18, 0x70, 0x02, 0x21, 0x10, 0x40, 0x02, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF,
+0x0E, 0x00, 0xA3, 0x2C, 0x21, 0x88, 0xA0, 0x00, 0x0D, 0x00, 0x02, 0x24,
+0x0A, 0x88, 0x43, 0x00, 0x20, 0x00, 0xB4, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB3, 0xAF,
+0x21, 0xA0, 0x80, 0x00, 0x21, 0x90, 0x00, 0x00, 0x0A, 0x00, 0x20, 0x12,
+0x21, 0x80, 0x00, 0x00, 0x01, 0x00, 0x13, 0x24, 0x21, 0x10, 0x90, 0x02,
+0x00, 0x00, 0x44, 0x90, 0x61, 0x52, 0x00, 0x0C, 0x01, 0x00, 0x10, 0x26,
+0x04, 0x10, 0x53, 0x00, 0x2B, 0x18, 0x11, 0x02, 0xF9, 0xFF, 0x60, 0x14,
+0x25, 0x90, 0x42, 0x02, 0x21, 0x10, 0x40, 0x02, 0x24, 0x00, 0xBF, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xE8, 0xFF, 0xBD, 0x27, 0xFF, 0xFF, 0x02, 0x24,
+0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF, 0x21, 0x30, 0xA0, 0x00,
+0x1B, 0x00, 0x82, 0x10, 0x20, 0x00, 0x10, 0x24, 0x20, 0x00, 0x82, 0x28,
+0x06, 0x00, 0x40, 0x14, 0x40, 0x18, 0x04, 0x00, 0x21, 0x10, 0x00, 0x02,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x21, 0x18, 0x64, 0x00, 0x21, 0x80, 0x80, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x19, 0x03, 0x00,
+0x60, 0x1B, 0x42, 0x24, 0x47, 0x39, 0x84, 0x24, 0x21, 0x20, 0x64, 0x00,
+0x21, 0x18, 0x62, 0x00, 0x01, 0x00, 0x02, 0x24, 0x06, 0x00, 0x06, 0x24,
+0xF4, 0x54, 0x00, 0x0C, 0xE6, 0x1D, 0x62, 0xA0, 0x21, 0x10, 0x00, 0x02,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0xF0, 0x00, 0x47, 0x24, 0x05, 0x00, 0x10, 0x24, 0xD6, 0x1E, 0x43, 0x24,
+0xF4, 0x53, 0x00, 0x08, 0xF0, 0x00, 0x05, 0x24, 0x01, 0x00, 0x10, 0x26,
+0x20, 0x00, 0x02, 0x2E, 0x30, 0x00, 0xA5, 0x24, 0xDE, 0xFF, 0x40, 0x10,
+0x30, 0x00, 0xE7, 0x24, 0x00, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xF8, 0xFF, 0x40, 0x14, 0x30, 0x00, 0x63, 0x24, 0x02, 0x80, 0x04, 0x3C,
+0x47, 0x39, 0x84, 0x24, 0x01, 0x00, 0x02, 0x24, 0x21, 0x20, 0xA4, 0x00,
+0xE6, 0x1D, 0xE2, 0xA0, 0x21, 0x28, 0xC0, 0x00, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0xE4, 0x53, 0x00, 0x08, 0x21, 0x10, 0x00, 0x02,
+0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x30, 0x00, 0xB2, 0x8F, 0x21, 0x88, 0x80, 0x00, 0x21, 0x20, 0xA0, 0x00,
+0x21, 0x28, 0x20, 0x02, 0x10, 0x00, 0xB0, 0xAF, 0x1C, 0x00, 0xBF, 0xAF,
+0xC7, 0x53, 0x00, 0x0C, 0xFF, 0xFF, 0xF0, 0x30, 0x20, 0x00, 0x03, 0x24,
+0xFF, 0x00, 0x44, 0x30, 0x21, 0x28, 0x00, 0x02, 0x21, 0x30, 0x20, 0x02,
+0x07, 0x00, 0x43, 0x10, 0x21, 0x38, 0x40, 0x02, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x6F, 0x20, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xD0, 0xFF, 0xBD, 0x27,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x24, 0x00, 0xB5, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0x21, 0xA8, 0x80, 0x00,
+0x60, 0x1B, 0x54, 0x24, 0x47, 0x39, 0x73, 0x24, 0x05, 0x00, 0x11, 0x24,
+0x01, 0x00, 0x12, 0x24, 0xF0, 0x00, 0x10, 0x24, 0x34, 0x54, 0x00, 0x08,
+0x28, 0x00, 0xBF, 0xAF, 0x01, 0x00, 0x31, 0x26, 0x20, 0x00, 0x22, 0x2A,
+0x0E, 0x00, 0x40, 0x10, 0x21, 0x10, 0x20, 0x02, 0x21, 0x10, 0x14, 0x02,
+0xE6, 0x1D, 0x43, 0x90, 0x21, 0x20, 0x13, 0x02, 0x21, 0x28, 0xA0, 0x02,
+0x06, 0x00, 0x06, 0x24, 0xF6, 0xFF, 0x72, 0x14, 0x30, 0x00, 0x10, 0x26,
+0x1D, 0x55, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x31, 0x26, 0xFF, 0xFF, 0x31, 0x26, 0x21, 0x10, 0x20, 0x02,
+0x28, 0x00, 0xBF, 0x8F, 0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x30, 0x00, 0xBD, 0x27,
+0xD0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x28, 0x00, 0xB6, 0xAF, 0x24, 0x00, 0xB5, 0xAF, 0x20, 0x00, 0xB4, 0xAF,
+0x1C, 0x00, 0xB3, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x21, 0x98, 0x80, 0x00, 0x60, 0x1B, 0x56, 0x24, 0x47, 0x39, 0x75, 0x24,
+0x21, 0x88, 0x00, 0x00, 0x01, 0x00, 0x14, 0x24, 0x21, 0x80, 0x00, 0x00,
+0x2C, 0x00, 0xBF, 0xAF, 0x60, 0x54, 0x00, 0x08, 0x18, 0x00, 0xB2, 0xAF,
+0x01, 0x00, 0x31, 0x26, 0x20, 0x00, 0x22, 0x2A, 0x1E, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x90, 0x16, 0x02, 0xE6, 0x1D, 0x42, 0x92,
+0x21, 0x20, 0x15, 0x02, 0x21, 0x28, 0x60, 0x02, 0x06, 0x00, 0x06, 0x24,
+0xF6, 0xFF, 0x54, 0x14, 0x30, 0x00, 0x10, 0x26, 0x1D, 0x55, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0x40, 0x14, 0x01, 0x00, 0x31, 0x26,
+0xFF, 0xFF, 0x31, 0x26, 0x02, 0x80, 0x06, 0x3C, 0x02, 0x80, 0x07, 0x3C,
+0xFF, 0x00, 0x24, 0x32, 0xE6, 0x1D, 0x40, 0xA2, 0x2C, 0x00, 0xBF, 0x8F,
+0x28, 0x00, 0xB6, 0x8F, 0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F,
+0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x88, 0xDE, 0xC6, 0x24, 0x78, 0xDE, 0xE7, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x6F, 0x20, 0x00, 0x08, 0x30, 0x00, 0xBD, 0x27,
+0x2C, 0x00, 0xBF, 0x8F, 0x28, 0x00, 0xB6, 0x8F, 0x24, 0x00, 0xB5, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x30, 0x00, 0xBD, 0x27, 0xC8, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x18, 0x00, 0xB2, 0xAF, 0x60, 0x1B, 0x52, 0x24, 0x30, 0x00, 0xBE, 0xAF,
+0x2C, 0x00, 0xB7, 0xAF, 0x28, 0x00, 0xB6, 0xAF, 0x24, 0x00, 0xB5, 0xAF,
+0x20, 0x00, 0xB4, 0xAF, 0x1C, 0x00, 0xB3, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x34, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x00, 0x00,
+0x02, 0x80, 0x1E, 0x3C, 0x02, 0x80, 0x17, 0x3C, 0x02, 0x80, 0x16, 0x3C,
+0x01, 0x00, 0x13, 0x24, 0xFF, 0xF7, 0x15, 0x24, 0xFF, 0xEF, 0x14, 0x24,
+0x21, 0x88, 0x40, 0x02, 0xE6, 0x1D, 0x22, 0x92, 0xC0, 0x48, 0x10, 0x00,
+0xD2, 0x5C, 0xC7, 0x93, 0x41, 0x00, 0x53, 0x10, 0x21, 0x30, 0x32, 0x01,
+0xD4, 0x23, 0xC2, 0x8C, 0xBF, 0xFF, 0x03, 0x24, 0x24, 0x28, 0x43, 0x00,
+0x80, 0x07, 0xA3, 0x34, 0x24, 0x10, 0x75, 0x00, 0x31, 0x00, 0xF3, 0x10,
+0x24, 0x10, 0x54, 0x00, 0xD4, 0x23, 0xC2, 0xAC, 0x21, 0x48, 0x32, 0x01,
+0xD4, 0x23, 0x23, 0x8D, 0xFD, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x18, 0x62, 0x00, 0xFB, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x18, 0x62, 0x00, 0xE7, 0xFF, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0x24, 0x18, 0x62, 0x00, 0xFF, 0xFD, 0x02, 0x3C, 0xFF, 0xFF, 0x42, 0x34,
+0xD8, 0x23, 0x28, 0x8D, 0x24, 0x18, 0x62, 0x00, 0xFF, 0xFB, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x18, 0x62, 0x00, 0xFF, 0xE7, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x1F, 0x00, 0x06, 0x3C, 0x00, 0x80, 0x08, 0x35,
+0x24, 0x18, 0x62, 0x00, 0x25, 0x40, 0x06, 0x01, 0xFF, 0x00, 0x04, 0x32,
+0x21, 0x28, 0x00, 0x00, 0x01, 0x00, 0x10, 0x26, 0x88, 0xDE, 0xE6, 0x26,
+0x78, 0xDE, 0xC7, 0x26, 0xD8, 0x23, 0x28, 0xAD, 0x6F, 0x20, 0x00, 0x0C,
+0xD4, 0x23, 0x23, 0xAD, 0x20, 0x00, 0x02, 0x2A, 0xD1, 0xFF, 0x40, 0x14,
+0x30, 0x00, 0x31, 0x26, 0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xBE, 0x8F,
+0x2C, 0x00, 0xB7, 0x8F, 0x28, 0x00, 0xB6, 0x8F, 0x24, 0x00, 0xB5, 0x8F,
+0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x38, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0xD3, 0x5C, 0x44, 0x90,
+0x24, 0x18, 0x75, 0x00, 0x80, 0x0F, 0xA2, 0x34, 0x00, 0x10, 0x63, 0x34,
+0xCA, 0xFF, 0x87, 0x14, 0x24, 0x10, 0x54, 0x00, 0xA9, 0x54, 0x00, 0x08,
+0xD4, 0x23, 0xC3, 0xAC, 0xA1, 0x54, 0x00, 0x08, 0xE6, 0x1D, 0x20, 0xA2,
+0xE8, 0x54, 0x00, 0x08, 0xFF, 0x00, 0xA5, 0x30, 0x00, 0x00, 0x85, 0xA0,
+0xFF, 0xFF, 0xC6, 0x24, 0x01, 0x00, 0x84, 0x24, 0xFC, 0xFF, 0xC0, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x05, 0x00, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0xAC,
+0xFF, 0xFF, 0xC6, 0x24, 0xFD, 0xFF, 0xC0, 0x14, 0x04, 0x00, 0x84, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x21, 0x38, 0x80, 0x00,
+0x08, 0x00, 0xC0, 0x10, 0xFF, 0xFF, 0xC3, 0x24, 0xFF, 0xFF, 0x06, 0x24,
+0x00, 0x00, 0xA2, 0x90, 0xFF, 0xFF, 0x63, 0x24, 0x01, 0x00, 0xA5, 0x24,
+0x00, 0x00, 0xE2, 0xA0, 0xFB, 0xFF, 0x66, 0x14, 0x01, 0x00, 0xE7, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x80, 0x00, 0x2B, 0x10, 0xA4, 0x00,
+0x0D, 0x00, 0x40, 0x14, 0xFF, 0xFF, 0x02, 0x24, 0xFF, 0xFF, 0xC6, 0x24,
+0x08, 0x00, 0xC2, 0x10, 0x21, 0x18, 0x80, 0x00, 0xFF, 0xFF, 0x07, 0x24,
+0x00, 0x00, 0xA2, 0x90, 0xFF, 0xFF, 0xC6, 0x24, 0x01, 0x00, 0xA5, 0x24,
+0x00, 0x00, 0x62, 0xA0, 0xFB, 0xFF, 0xC7, 0x14, 0x01, 0x00, 0x63, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x80, 0x00, 0x21, 0x28, 0xA6, 0x00,
+0x21, 0x18, 0x86, 0x00, 0xFF, 0xFF, 0xC6, 0x24, 0xFA, 0xFF, 0xC2, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x07, 0x24, 0xFF, 0xFF, 0xA5, 0x24,
+0x00, 0x00, 0xA2, 0x90, 0xFF, 0xFF, 0x63, 0x24, 0xFF, 0xFF, 0xC6, 0x24,
+0xFB, 0xFF, 0xC7, 0x14, 0x00, 0x00, 0x62, 0xA0, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x80, 0x00, 0x0C, 0x00, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0xA3, 0x90, 0x01, 0x00, 0x84, 0x24,
+0x23, 0x10, 0x43, 0x00, 0x00, 0x16, 0x02, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x04, 0x00, 0x40, 0x14, 0x01, 0x00, 0xA5, 0x24, 0xFF, 0xFF, 0xC6, 0x24,
+0xF6, 0xFF, 0xC0, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0xC0, 0x00, 0x33, 0x55, 0x00, 0x08, 0x21, 0x18, 0x86, 0x00,
+0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x45, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x84, 0x24, 0xFA, 0xFF, 0x83, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x80, 0x00,
+0x09, 0x00, 0xC0, 0x10, 0xFF, 0xFF, 0xC3, 0x24, 0xFF, 0x00, 0xA5, 0x30,
+0xFF, 0xFF, 0x06, 0x24, 0x00, 0x00, 0x82, 0x90, 0xFF, 0xFF, 0x63, 0x24,
+0x05, 0x00, 0x45, 0x10, 0x01, 0x00, 0x84, 0x24, 0xFB, 0xFF, 0x66, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0xFF, 0xFF, 0x82, 0x24, 0x21, 0x38, 0x00, 0x00,
+0x1F, 0x00, 0xC0, 0x10, 0x21, 0x18, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x40, 0xF4, 0x4B, 0x24, 0x00, 0x00, 0x87, 0x90, 0x00, 0x00, 0xA3, 0x90,
+0xFF, 0xFF, 0xC6, 0x24, 0x01, 0x00, 0x84, 0x24, 0x21, 0x10, 0xEB, 0x00,
+0x16, 0x00, 0xE0, 0x10, 0x01, 0x00, 0xA5, 0x24, 0x14, 0x00, 0x60, 0x10,
+0x21, 0x48, 0x6B, 0x00, 0x10, 0x00, 0xE3, 0x10, 0x20, 0x00, 0xE8, 0x24,
+0x00, 0x00, 0x42, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x02, 0x00, 0x40, 0x10, 0x20, 0x00, 0x6A, 0x24, 0xFF, 0x00, 0x07, 0x31,
+0x00, 0x00, 0x22, 0x91, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x02, 0x00, 0x40, 0x10, 0xFF, 0x00, 0xE7, 0x30, 0xFF, 0x00, 0x43, 0x31,
+0xFF, 0x00, 0x63, 0x30, 0x03, 0x00, 0xE3, 0x14, 0x00, 0x00, 0x00, 0x00,
+0xE5, 0xFF, 0xC0, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x23, 0x10, 0xE3, 0x00, 0x21, 0x18, 0x80, 0x00, 0x00, 0x00, 0xA2, 0x90,
+0x01, 0x00, 0xA5, 0x24, 0x00, 0x00, 0x82, 0xA0, 0xFC, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x84, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x21, 0x38, 0x80, 0x00, 0xFF, 0xFF, 0x03, 0x24, 0xFF, 0xFF, 0xC6, 0x24,
+0x06, 0x00, 0xC3, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x90,
+0x01, 0x00, 0xA5, 0x24, 0x00, 0x00, 0x82, 0xA0, 0xF9, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x84, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xE0, 0x00,
+0x00, 0x00, 0x82, 0x80, 0x82, 0x55, 0x00, 0x08, 0x21, 0x18, 0x80, 0x00,
+0x01, 0x00, 0x84, 0x24, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00,
+0xFC, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x90,
+0x01, 0x00, 0xA5, 0x24, 0x00, 0x00, 0x82, 0xA0, 0xFC, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x84, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x12, 0x00, 0xC0, 0x10, 0x21, 0x18, 0x80, 0x00, 0x00, 0x00, 0x82, 0x80,
+0x93, 0x55, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x84, 0x24,
+0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x90, 0x01, 0x00, 0xA5, 0x24,
+0x00, 0x00, 0x82, 0xA0, 0x05, 0x00, 0x40, 0x10, 0x01, 0x00, 0x84, 0x24,
+0xFF, 0xFF, 0xC6, 0x24, 0xF9, 0xFF, 0xC0, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x80, 0xA0, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x00, 0x00, 0x83, 0x90, 0x00, 0x00, 0xA2, 0x90, 0x01, 0x00, 0x84, 0x24,
+0x23, 0x10, 0x62, 0x00, 0x00, 0x16, 0x02, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x03, 0x00, 0x40, 0x14, 0x01, 0x00, 0xA5, 0x24, 0xF7, 0xFF, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0x00, 0x00, 0x0B, 0x00, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xA2, 0x90, 0x00, 0x00, 0x83, 0x90, 0xFF, 0xFF, 0xC6, 0x24,
+0x23, 0x10, 0x62, 0x00, 0x00, 0x16, 0x02, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x03, 0x00, 0x40, 0x14, 0x01, 0x00, 0xA5, 0x24, 0xF5, 0xFF, 0x60, 0x14,
+0x01, 0x00, 0x84, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x83, 0x80, 0x00, 0x2E, 0x05, 0x00, 0x21, 0x10, 0x80, 0x00,
+0xC4, 0x55, 0x00, 0x08, 0x03, 0x2E, 0x05, 0x00, 0x07, 0x00, 0x60, 0x10,
+0x01, 0x00, 0x42, 0x24, 0x00, 0x00, 0x43, 0x80, 0x00, 0x00, 0x00, 0x00,
+0xFB, 0xFF, 0x65, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0x00, 0x00, 0x82, 0x80, 0xD0, 0x55, 0x00, 0x08, 0x21, 0x18, 0x80, 0x00,
+0x01, 0x00, 0x63, 0x24, 0x00, 0x00, 0x62, 0x80, 0x00, 0x00, 0x00, 0x00,
+0xFC, 0xFF, 0x40, 0x14, 0x23, 0x10, 0x64, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x21, 0x80, 0xA0, 0x00, 0x14, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xBF, 0xAF,
+0x21, 0x88, 0x80, 0x00, 0xCA, 0x55, 0x00, 0x0C, 0x00, 0x86, 0x10, 0x00,
+0x21, 0x18, 0x51, 0x00, 0x03, 0x86, 0x10, 0x00, 0x00, 0x00, 0x62, 0x80,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x50, 0x10, 0x21, 0x10, 0x60, 0x00,
+0xFF, 0xFF, 0x63, 0x24, 0x2B, 0x10, 0x71, 0x00, 0xF9, 0xFF, 0x40, 0x10,
+0x21, 0x10, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x21, 0x30, 0x80, 0x00,
+0x0D, 0x00, 0xA0, 0x10, 0xFF, 0xFF, 0xA3, 0x24, 0x00, 0x00, 0x82, 0x80,
+0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xFF, 0x05, 0x24, 0xFF, 0xFF, 0x63, 0x24, 0x05, 0x00, 0x65, 0x10,
+0x01, 0x00, 0xC6, 0x24, 0x00, 0x00, 0xC2, 0x80, 0x00, 0x00, 0x00, 0x00,
+0xFA, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x23, 0x10, 0xC4, 0x00, 0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x19, 0x00, 0x40, 0x10, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0xA9, 0x80,
+0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x20, 0x11, 0x21, 0x30, 0xA0, 0x00,
+0x00, 0x3E, 0x02, 0x00, 0x03, 0x3E, 0x07, 0x00, 0x21, 0x18, 0x20, 0x01,
+0x15, 0x00, 0xE3, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xC6, 0x24,
+0x00, 0x00, 0xC2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x02, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0xF8, 0xFF, 0x60, 0x14, 0x00, 0x16, 0x02, 0x00,
+0x03, 0x16, 0x02, 0x00, 0x06, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x84, 0x24, 0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xEB, 0xFF, 0x40, 0x14, 0x01, 0x00, 0x08, 0x25, 0x08, 0x00, 0xE0, 0x03,
+0x21, 0x10, 0x00, 0x01, 0x00, 0x00, 0xA2, 0x90, 0x15, 0x56, 0x00, 0x08,
+0x00, 0x16, 0x02, 0x00, 0x00, 0x00, 0xC2, 0x90, 0x15, 0x56, 0x00, 0x08,
+0x00, 0x16, 0x02, 0x00, 0x00, 0x00, 0x87, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x00, 0xE0, 0x10, 0x21, 0x10, 0x80, 0x00, 0x00, 0x00, 0xA4, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x04, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x09, 0x00, 0x60, 0x10, 0x21, 0x30, 0xA0, 0x00, 0x00, 0x3E, 0x07, 0x00,
+0x03, 0x3E, 0x07, 0x00, 0x0B, 0x00, 0xE3, 0x10, 0x01, 0x00, 0xC6, 0x24,
+0x00, 0x00, 0xC3, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFB, 0xFF, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0x00, 0x00, 0x47, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xE0, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x18, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x1D, 0x00, 0x80, 0x10,
+0x21, 0x88, 0xA0, 0x00, 0x01, 0x56, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02,
+0x21, 0x80, 0x02, 0x02, 0x00, 0x00, 0x02, 0x82, 0x21, 0x28, 0x20, 0x02,
+0x21, 0x20, 0x00, 0x02, 0x22, 0x00, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x25, 0x56, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x40, 0x10,
+0x21, 0x18, 0x40, 0x00, 0x00, 0x00, 0x42, 0x80, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x58, 0xF5, 0x43, 0xAC, 0x21, 0x18, 0x00, 0x02, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x60, 0xA0,
+0x56, 0x56, 0x00, 0x08, 0x01, 0x00, 0x63, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x58, 0xF5, 0x50, 0x8C, 0x00, 0x00, 0x00, 0x00, 0xF3, 0xFF, 0x00, 0x12,
+0x21, 0x18, 0x00, 0x00, 0x01, 0x56, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x02,
+0x21, 0x80, 0x02, 0x02, 0x00, 0x00, 0x02, 0x82, 0x21, 0x28, 0x20, 0x02,
+0x21, 0x20, 0x00, 0x02, 0xE0, 0xFF, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00,
+0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x02, 0x80, 0x02, 0x3C, 0x58, 0xF5, 0x40, 0xAC, 0x20, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x00, 0x00, 0x90, 0x8C, 0x21, 0x90, 0x80, 0x00,
+0x21, 0x88, 0xA0, 0x00, 0x21, 0x18, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x12,
+0x21, 0x20, 0x00, 0x02, 0x01, 0x56, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x80, 0x02, 0x02, 0x00, 0x00, 0x02, 0x82, 0x21, 0x28, 0x20, 0x02,
+0x21, 0x20, 0x00, 0x02, 0x07, 0x00, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x25, 0x56, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x18, 0x40, 0x00,
+0x09, 0x00, 0x40, 0x14, 0x00, 0x00, 0x42, 0xAE, 0x21, 0x18, 0x00, 0x02,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x42, 0x80, 0x00, 0x00, 0x00, 0x00,
+0xF5, 0xFF, 0x40, 0x10, 0x01, 0x00, 0x64, 0x24, 0x00, 0x00, 0x60, 0xA0,
+0x8F, 0x56, 0x00, 0x08, 0x00, 0x00, 0x44, 0xAE, 0xD8, 0xFF, 0xBD, 0x27,
+0x14, 0x00, 0xB1, 0xAF, 0x21, 0x88, 0x80, 0x00, 0x21, 0x20, 0xA0, 0x00,
+0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x00, 0xB2, 0xAF, 0x20, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0xCA, 0x55, 0x00, 0x0C, 0x21, 0x98, 0xA0, 0x00,
+0x21, 0x90, 0x40, 0x00, 0x08, 0x00, 0x40, 0x16, 0x21, 0x10, 0x20, 0x02,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xCA, 0x55, 0x00, 0x0C, 0x21, 0x20, 0x20, 0x02,
+0x21, 0x80, 0x40, 0x00, 0x2A, 0x10, 0x52, 0x00, 0x0A, 0x00, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x20, 0x02, 0x21, 0x28, 0x60, 0x02,
+0x21, 0x30, 0x40, 0x02, 0x1D, 0x55, 0x00, 0x0C, 0xFF, 0xFF, 0x10, 0x26,
+0x0B, 0x00, 0x40, 0x10, 0x2A, 0x18, 0x12, 0x02, 0xF8, 0xFF, 0x60, 0x10,
+0x01, 0x00, 0x31, 0x26, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0xAB, 0x56, 0x00, 0x08, 0x21, 0x10, 0x20, 0x02, 0x00, 0x00, 0x87, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0xE0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xA6, 0x90, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0xC0, 0x10,
+0xDF, 0xFF, 0x02, 0x24, 0x24, 0x18, 0xC2, 0x00, 0x24, 0x10, 0xE2, 0x00,
+0x00, 0x16, 0x02, 0x00, 0x00, 0x1E, 0x03, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0x0A, 0x00, 0x43, 0x10, 0x00, 0x00, 0x00, 0x00,
+0xDF, 0xFF, 0x02, 0x24, 0x24, 0x18, 0xC2, 0x00, 0x24, 0x10, 0xE2, 0x00,
+0x00, 0x16, 0x02, 0x00, 0x00, 0x1E, 0x03, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x03, 0x16, 0x02, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x23, 0x10, 0x43, 0x00,
+0xEE, 0x56, 0x00, 0x08, 0xDF, 0xFF, 0x08, 0x24, 0x00, 0x00, 0xA6, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x06, 0x01, 0x00, 0x16, 0x02, 0x00,
+0xF0, 0xFF, 0xC0, 0x10, 0x03, 0x16, 0x02, 0x00, 0xEF, 0xFF, 0x62, 0x14,
+0xDF, 0xFF, 0x02, 0x24, 0x01, 0x00, 0x84, 0x24, 0x00, 0x00, 0x87, 0x90,
+0x01, 0x00, 0xA5, 0x24, 0x24, 0x10, 0x07, 0x01, 0x00, 0x1E, 0x02, 0x00,
+0xF2, 0xFF, 0xE0, 0x14, 0x03, 0x1E, 0x03, 0x00, 0x00, 0x00, 0xA6, 0x90,
+0xDF, 0xFF, 0x02, 0x24, 0x24, 0x18, 0xC2, 0x00, 0x24, 0x10, 0xE2, 0x00,
+0x00, 0x16, 0x02, 0x00, 0x00, 0x1E, 0x03, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x03, 0x16, 0x02, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x23, 0x10, 0x43, 0x00,
+0xA8, 0xFF, 0xBD, 0x27, 0x44, 0x00, 0xB5, 0xAF, 0x40, 0x00, 0xB4, 0xAF,
+0x38, 0x00, 0xB2, 0xAF, 0x34, 0x00, 0xB1, 0xAF, 0x54, 0x00, 0xBF, 0xAF,
+0x50, 0x00, 0xBE, 0xAF, 0x4C, 0x00, 0xB7, 0xAF, 0x48, 0x00, 0xB6, 0xAF,
+0x3C, 0x00, 0xB3, 0xAF, 0x30, 0x00, 0xB0, 0xAF, 0x21, 0x90, 0xA0, 0x00,
+0x00, 0x00, 0xA5, 0x90, 0x21, 0xA0, 0x80, 0x00, 0x21, 0xA8, 0xC0, 0x00,
+0x00, 0x26, 0x05, 0x00, 0x03, 0x26, 0x04, 0x00, 0x11, 0x00, 0x80, 0x10,
+0x21, 0x88, 0x80, 0x02, 0x25, 0x00, 0x02, 0x24, 0x29, 0x00, 0x82, 0x10,
+0x0A, 0x00, 0x02, 0x24, 0x1B, 0x00, 0x82, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x1E, 0x00, 0x80, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xA2,
+0x01, 0x00, 0x31, 0x26, 0x01, 0x00, 0x52, 0x26, 0x00, 0x00, 0x45, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x05, 0x00, 0x03, 0x26, 0x04, 0x00,
+0xF2, 0xFF, 0x80, 0x14, 0x25, 0x00, 0x02, 0x24, 0x02, 0x00, 0x80, 0x12,
+0x23, 0x10, 0x34, 0x02, 0x00, 0x00, 0x20, 0xA2, 0x54, 0x00, 0xBF, 0x8F,
+0x50, 0x00, 0xBE, 0x8F, 0x4C, 0x00, 0xB7, 0x8F, 0x48, 0x00, 0xB6, 0x8F,
+0x44, 0x00, 0xB5, 0x8F, 0x40, 0x00, 0xB4, 0x8F, 0x3C, 0x00, 0xB3, 0x8F,
+0x38, 0x00, 0xB2, 0x8F, 0x34, 0x00, 0xB1, 0x8F, 0x30, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x58, 0x00, 0xBD, 0x27, 0xE7, 0xFF, 0x80, 0x16,
+0x00, 0x00, 0x00, 0x00, 0x57, 0x58, 0x00, 0x0C, 0x0D, 0x00, 0x04, 0x24,
+0x0A, 0x00, 0x04, 0x24, 0x57, 0x58, 0x00, 0x0C, 0x01, 0x00, 0x52, 0x26,
+0x00, 0x00, 0x45, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x05, 0x00,
+0x20, 0x57, 0x00, 0x08, 0x03, 0x26, 0x04, 0x00, 0x01, 0x00, 0x52, 0x26,
+0x00, 0x00, 0x45, 0x92, 0x73, 0x00, 0x02, 0x24, 0x00, 0x1E, 0x05, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0x2C, 0x00, 0x62, 0x10, 0x10, 0x00, 0xB3, 0x27,
+0x23, 0x00, 0x02, 0x24, 0x21, 0xF0, 0x60, 0x02, 0x21, 0x38, 0x00, 0x00,
+0x34, 0x00, 0x62, 0x10, 0x1C, 0x00, 0x04, 0x24, 0x00, 0x16, 0x05, 0x00,
+0x03, 0x16, 0x02, 0x00, 0x68, 0x00, 0x03, 0x24, 0x36, 0x00, 0x43, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x05, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x39, 0x00, 0x43, 0x10, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xA2, 0x34,
+0x00, 0x16, 0x02, 0x00, 0x03, 0x16, 0x02, 0x00, 0x78, 0x00, 0x03, 0x24,
+0x3C, 0x00, 0x43, 0x10, 0x20, 0x00, 0xA6, 0x30, 0x00, 0x1E, 0x05, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0x64, 0x00, 0x02, 0x24, 0x49, 0x00, 0x62, 0x10,
+0x40, 0x00, 0x02, 0x24, 0x81, 0x00, 0x62, 0x10, 0x21, 0x00, 0x02, 0x24,
+0x92, 0x00, 0x62, 0x10, 0x63, 0x00, 0x02, 0x24, 0xA2, 0x00, 0x62, 0x10,
+0x11, 0x00, 0xB3, 0x27, 0x10, 0x00, 0xA5, 0xA3, 0x21, 0x80, 0xC0, 0x03,
+0x2B, 0x10, 0x13, 0x02, 0xB4, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x6C, 0x00, 0x80, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92,
+0x01, 0x00, 0x10, 0x26, 0x00, 0x00, 0x22, 0xA2, 0x65, 0x57, 0x00, 0x08,
+0x01, 0x00, 0x31, 0x26, 0x00, 0x00, 0xA2, 0x8E, 0x04, 0x00, 0xB5, 0x26,
+0x21, 0x80, 0x40, 0x00, 0x00, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xA6, 0xFF, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x80, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xA2, 0x01, 0x00, 0x10, 0x26,
+0x72, 0x57, 0x00, 0x08, 0x01, 0x00, 0x31, 0x26, 0x01, 0x00, 0x52, 0x26,
+0x00, 0x00, 0x45, 0x92, 0x68, 0x00, 0x03, 0x24, 0x00, 0x16, 0x05, 0x00,
+0x03, 0x16, 0x02, 0x00, 0xCC, 0xFF, 0x43, 0x14, 0x01, 0x00, 0x07, 0x24,
+0x01, 0x00, 0x52, 0x26, 0x00, 0x00, 0x45, 0x92, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x16, 0x05, 0x00, 0x03, 0x16, 0x02, 0x00, 0xC9, 0xFF, 0x43, 0x14,
+0x0C, 0x00, 0x04, 0x24, 0x01, 0x00, 0x52, 0x26, 0x00, 0x00, 0x45, 0x92,
+0x78, 0x00, 0x03, 0x24, 0x20, 0x00, 0xA2, 0x34, 0x00, 0x16, 0x02, 0x00,
+0x03, 0x16, 0x02, 0x00, 0xC7, 0xFF, 0x43, 0x14, 0x04, 0x00, 0x04, 0x24,
+0x20, 0x00, 0xA6, 0x30, 0x00, 0x00, 0xA5, 0x8E, 0x35, 0x00, 0xE0, 0x14,
+0x04, 0x00, 0xB5, 0x26, 0xCD, 0xFF, 0x80, 0x04, 0x02, 0x80, 0x02, 0x3C,
+0x0C, 0xEF, 0x42, 0x24, 0x00, 0x00, 0x47, 0x8C, 0x07, 0x10, 0x85, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0x21, 0x10, 0x47, 0x00, 0x00, 0x00, 0x43, 0x90,
+0xFC, 0xFF, 0x84, 0x24, 0x25, 0x18, 0xC3, 0x00, 0x00, 0x00, 0x63, 0xA2,
+0xF8, 0xFF, 0x81, 0x04, 0x01, 0x00, 0x73, 0x26, 0x65, 0x57, 0x00, 0x08,
+0x21, 0x80, 0xC0, 0x03, 0x00, 0x00, 0xA2, 0x8E, 0x04, 0x00, 0xB5, 0x26,
+0x28, 0x00, 0x40, 0x04, 0x21, 0x28, 0x40, 0x00, 0x21, 0x80, 0x60, 0x02,
+0x02, 0x80, 0x02, 0x3C, 0x10, 0xEF, 0x42, 0x24, 0x00, 0x00, 0x46, 0x8C,
+0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xA6, 0x00, 0xC3, 0x27, 0x05, 0x00,
+0x10, 0x10, 0x00, 0x00, 0x83, 0x10, 0x02, 0x00, 0x23, 0x10, 0x44, 0x00,
+0x80, 0x18, 0x02, 0x00, 0x21, 0x18, 0x62, 0x00, 0x40, 0x18, 0x03, 0x00,
+0x23, 0x18, 0xA3, 0x00, 0x30, 0x00, 0x63, 0x24, 0x00, 0x00, 0x63, 0xA2,
+0x21, 0x28, 0x40, 0x00, 0xF3, 0xFF, 0x40, 0x14, 0x01, 0x00, 0x73, 0x26,
+0xC5, 0x57, 0x00, 0x08, 0xFF, 0xFF, 0x63, 0x26, 0x00, 0x00, 0x65, 0x80,
+0x00, 0x00, 0x02, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0xA0,
+0x00, 0x00, 0x05, 0xA2, 0xFF, 0xFF, 0x63, 0x24, 0x01, 0x00, 0x10, 0x26,
+0x2B, 0x10, 0x03, 0x02, 0xF7, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x65, 0x57, 0x00, 0x08, 0x21, 0x80, 0xC0, 0x03, 0x58, 0x00, 0xC3, 0x34,
+0x30, 0x00, 0x02, 0x24, 0x12, 0x00, 0xB3, 0x27, 0x10, 0x00, 0xA2, 0xA3,
+0x96, 0x57, 0x00, 0x08, 0x11, 0x00, 0xA3, 0xA3, 0x2D, 0x00, 0x02, 0x24,
+0x23, 0x28, 0x05, 0x00, 0x11, 0x00, 0xB3, 0x27, 0xA9, 0x57, 0x00, 0x08,
+0x10, 0x00, 0xA2, 0xA3, 0x00, 0x00, 0x04, 0x82, 0x57, 0x58, 0x00, 0x0C,
+0x01, 0x00, 0x10, 0x26, 0x66, 0x57, 0x00, 0x08, 0x2B, 0x10, 0x13, 0x02,
+0x00, 0x00, 0x04, 0x82, 0x57, 0x58, 0x00, 0x0C, 0x01, 0x00, 0x10, 0x26,
+0x72, 0x57, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x8E,
+0x28, 0x00, 0xB0, 0x27, 0x2C, 0x00, 0xA4, 0x27, 0x2B, 0x10, 0x04, 0x02,
+0x28, 0x00, 0xA3, 0xAF, 0x0B, 0x00, 0x40, 0x10, 0x04, 0x00, 0xB5, 0x26,
+0x21, 0xB8, 0x80, 0x00, 0x02, 0x80, 0x16, 0x3C, 0x00, 0x00, 0x06, 0x92,
+0x21, 0x20, 0x60, 0x02, 0x01, 0x00, 0x10, 0x26, 0x08, 0x58, 0x00, 0x0C,
+0x00, 0xEF, 0xC5, 0x26, 0x2B, 0x18, 0x17, 0x02, 0xF9, 0xFF, 0x60, 0x14,
+0x21, 0x98, 0x62, 0x02, 0x64, 0x57, 0x00, 0x08, 0xFF, 0xFF, 0x73, 0x26,
+0x00, 0x00, 0xA2, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x56, 0x24,
+0x21, 0x80, 0x40, 0x00, 0x2B, 0x10, 0x56, 0x00, 0xF8, 0xFF, 0x40, 0x10,
+0x04, 0x00, 0xB5, 0x26, 0x02, 0x80, 0x17, 0x3C, 0x00, 0x00, 0x06, 0x82,
+0x21, 0x20, 0x60, 0x02, 0x01, 0x00, 0x10, 0x26, 0x08, 0x58, 0x00, 0x0C,
+0x04, 0xEF, 0xE5, 0x26, 0x2B, 0x18, 0x16, 0x02, 0xF9, 0xFF, 0x60, 0x14,
+0x21, 0x98, 0x62, 0x02, 0x64, 0x57, 0x00, 0x08, 0xFF, 0xFF, 0x73, 0x26,
+0x00, 0x00, 0xA2, 0x8E, 0x04, 0x00, 0xB5, 0x26, 0x64, 0x57, 0x00, 0x08,
+0x10, 0x00, 0xA2, 0xA3, 0xE8, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xA6, 0xAF,
+0x20, 0x00, 0xA6, 0x27, 0x10, 0x00, 0xBF, 0xAF, 0x24, 0x00, 0xA7, 0xAF,
+0xFF, 0x56, 0x00, 0x0C, 0x1C, 0x00, 0xA5, 0xAF, 0x10, 0x00, 0xBF, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xA4, 0xAF, 0x10, 0x00, 0xA4, 0x27,
+0x1C, 0x00, 0xBF, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xA5, 0xAF,
+0x28, 0x00, 0xA6, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x2C, 0x00, 0xA7, 0xAF,
+0x53, 0x21, 0x00, 0x0C, 0xA0, 0x00, 0x04, 0x24, 0x1F, 0x00, 0x40, 0x10,
+0x21, 0x80, 0x40, 0x00, 0x08, 0x00, 0x44, 0x94, 0x20, 0x00, 0xA5, 0x8F,
+0x02, 0x80, 0x02, 0x3C, 0x25, 0x20, 0x82, 0x00, 0x20, 0x00, 0x84, 0x24,
+0xFF, 0x56, 0x00, 0x0C, 0x24, 0x00, 0xA6, 0x27, 0x01, 0x00, 0x42, 0x24,
+0x13, 0x00, 0x03, 0x24, 0x81, 0x00, 0x44, 0x2C, 0x14, 0x00, 0x03, 0xAE,
+0x0A, 0x00, 0x80, 0x14, 0x0C, 0x00, 0x02, 0xAE, 0x9B, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x88, 0x88, 0x63, 0x34, 0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x34, 0x58, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x17, 0x0A, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x02, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x99, 0x99, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C, 0x99, 0x99, 0x63, 0x34,
+0x18, 0x03, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC, 0x3A, 0x58, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x02, 0x80, 0x06, 0x3C, 0x5C, 0xF5, 0xC5, 0x8C, 0x02, 0x80, 0x02, 0x3C,
+0x40, 0xF5, 0x42, 0x24, 0x03, 0x00, 0xA3, 0x30, 0x21, 0x18, 0x62, 0x00,
+0x00, 0x00, 0x64, 0x80, 0x01, 0x00, 0xA5, 0x24, 0x57, 0x58, 0x00, 0x0C,
+0x5C, 0xF5, 0xC5, 0xAC, 0x10, 0x00, 0xBF, 0x8F, 0x08, 0x00, 0x04, 0x24,
+0x57, 0x58, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0x00, 0x26, 0x04, 0x00,
+0x03, 0x26, 0x04, 0x00, 0x00, 0x00, 0x84, 0x48, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x04, 0x00, 0x03, 0x26, 0x04, 0x00,
+0xF7, 0xFF, 0x82, 0x24, 0x05, 0x00, 0x42, 0x2C, 0x06, 0x00, 0x40, 0x14,
+0x21, 0x18, 0x00, 0x00, 0x20, 0x00, 0x02, 0x24, 0x03, 0x00, 0x82, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x01, 0x00, 0x03, 0x24, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x60, 0x00,
+0x00, 0x00, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x26, 0x10, 0x44, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x42, 0x2C, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xBF, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x10, 0x00, 0xA4, 0x27,
+0x02, 0x80, 0x02, 0x3C, 0xCC, 0x5D, 0x50, 0xAC, 0x90, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0x25, 0xB0, 0x05, 0x3C,
+0x01, 0x00, 0x06, 0x24, 0x01, 0x80, 0x02, 0x3C, 0x04, 0x30, 0x86, 0x00,
+0xF1, 0x02, 0xA7, 0x34, 0xED, 0x02, 0xA4, 0x34, 0xF8, 0x61, 0x42, 0x24,
+0x18, 0x03, 0xA5, 0x34, 0x08, 0x00, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xAC,
+0x00, 0x00, 0xE3, 0xA0, 0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0x86, 0xA0,
+0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0x86, 0xA0, 0x00, 0x00, 0x80, 0xA0,
+0x00, 0x00, 0x86, 0xA0, 0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0x86, 0xA0,
+0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0xE0, 0xA0, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF,
+0xFF, 0xFF, 0x90, 0x30, 0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C,
+0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x63, 0x24,
+0x6A, 0x37, 0x62, 0x94, 0x10, 0x00, 0xA4, 0x27, 0x25, 0x80, 0x02, 0x02,
+0x25, 0xB0, 0x02, 0x3C, 0x1E, 0x03, 0x42, 0x34, 0x00, 0x00, 0x50, 0xA4,
+0x90, 0x40, 0x00, 0x0C, 0x6A, 0x37, 0x70, 0xA4, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF, 0xFF, 0xFF, 0x90, 0x30,
+0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24, 0x6A, 0x37, 0xA2, 0x94,
+0x78, 0x37, 0xA3, 0x94, 0x27, 0x80, 0x10, 0x00, 0x10, 0x00, 0xA4, 0x27,
+0x24, 0x18, 0x03, 0x02, 0x24, 0x80, 0x02, 0x02, 0x25, 0xB0, 0x02, 0x3C,
+0x1E, 0x03, 0x42, 0x34, 0x78, 0x37, 0xA3, 0xA4, 0x00, 0x00, 0x50, 0xA4,
+0x90, 0x40, 0x00, 0x0C, 0x6A, 0x37, 0xB0, 0xA4, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xC8, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x03, 0x3C, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x34, 0x00, 0xBF, 0xAF, 0x30, 0x00, 0xBE, 0xAF, 0x2C, 0x00, 0xB7, 0xAF,
+0x28, 0x00, 0xB6, 0xAF, 0x24, 0x00, 0xB5, 0xAF, 0x20, 0x00, 0xB4, 0xAF,
+0x0A, 0x00, 0x67, 0x34, 0x00, 0x00, 0xE2, 0x90, 0xFF, 0xFF, 0xB2, 0x30,
+0x21, 0x98, 0xC0, 0x00, 0xFF, 0x00, 0x91, 0x30, 0x20, 0x00, 0x40, 0x12,
+0xFF, 0x00, 0x50, 0x30, 0x21, 0xA0, 0xE0, 0x00, 0x0C, 0x00, 0x77, 0x34,
+0x0B, 0x00, 0x76, 0x34, 0x21, 0xF0, 0xE0, 0x00, 0xC0, 0xFF, 0x15, 0x24,
+0x25, 0x10, 0x15, 0x02, 0xFF, 0x00, 0x50, 0x30, 0x00, 0x00, 0xD1, 0xA2,
+0x00, 0x00, 0x90, 0xA2, 0x00, 0x00, 0x82, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x50, 0x30, 0xC0, 0x00, 0x03, 0x32, 0x07, 0x00, 0x60, 0x10,
+0x21, 0x20, 0xC0, 0x03, 0x00, 0x00, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0x50, 0x30, 0xC0, 0x00, 0x03, 0x32, 0xFB, 0xFF, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE2, 0x8E, 0x04, 0x00, 0x23, 0x26,
+0x64, 0x00, 0x04, 0x24, 0x00, 0x00, 0x62, 0xAE, 0x2C, 0x1F, 0x00, 0x0C,
+0xFF, 0x00, 0x71, 0x30, 0xFC, 0xFF, 0x42, 0x26, 0xFF, 0xFF, 0x52, 0x30,
+0xE7, 0xFF, 0x40, 0x16, 0x04, 0x00, 0x73, 0x26, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xBE, 0x8F, 0x2C, 0x00, 0xB7, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x38, 0x00, 0xBD, 0x27, 0x25, 0xB0, 0x06, 0x3C,
+0x31, 0x00, 0xC2, 0x34, 0xFF, 0xFF, 0x84, 0x30, 0x00, 0x00, 0x44, 0xA0,
+0x32, 0x00, 0xC7, 0x34, 0x00, 0x00, 0xE3, 0x90, 0xFC, 0xFF, 0x02, 0x24,
+0x02, 0x22, 0x04, 0x00, 0x24, 0x18, 0x62, 0x00, 0x03, 0x00, 0x84, 0x30,
+0x25, 0x20, 0x83, 0x00, 0x33, 0x00, 0xC6, 0x34, 0x72, 0x00, 0x02, 0x24,
+0x00, 0x00, 0xE4, 0xA0, 0x00, 0x00, 0xC2, 0xA0, 0x00, 0x00, 0xC3, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x03, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x05, 0x00, 0x61, 0x04, 0x21, 0x10, 0x00, 0x00, 0x23, 0x59, 0x00, 0x08,
+0x25, 0xB0, 0x02, 0x3C, 0x11, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC3, 0x90, 0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x00, 0x1E, 0x03, 0x00, 0x03, 0x1E, 0x03, 0x00, 0xF8, 0xFF, 0x61, 0x04,
+0x64, 0x00, 0x44, 0x2C, 0x64, 0x00, 0x44, 0x2C, 0x07, 0x00, 0x80, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x30, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x43, 0x90, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0xA3, 0xA0, 0xFF, 0xFF, 0x02, 0x24, 0x00, 0x00, 0xA2, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x25, 0xB0, 0x06, 0x3C,
+0x31, 0x00, 0xC2, 0x34, 0xFF, 0xFF, 0x84, 0x30, 0x00, 0x00, 0x44, 0xA0,
+0x32, 0x00, 0xC3, 0x34, 0x00, 0x00, 0x62, 0x90, 0x02, 0x22, 0x04, 0x00,
+0x03, 0x00, 0x84, 0x30, 0x25, 0x20, 0x82, 0x00, 0x00, 0x00, 0x64, 0xA0,
+0x33, 0x00, 0xC7, 0x34, 0xFF, 0x00, 0xA5, 0x30, 0x30, 0x00, 0xC6, 0x34,
+0xF2, 0xFF, 0x03, 0x24, 0x00, 0x00, 0xC5, 0xA0, 0x00, 0x00, 0xE3, 0xA0,
+0x00, 0x00, 0xE2, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x02, 0x00,
+0x03, 0x16, 0x02, 0x00, 0x03, 0x00, 0x40, 0x04, 0x21, 0x20, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x01, 0x00, 0x02, 0x24, 0x48, 0x59, 0x00, 0x08,
+0x21, 0x30, 0xE0, 0x00, 0x0B, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC3, 0x90, 0x01, 0x00, 0x82, 0x24, 0xFF, 0x00, 0x44, 0x30,
+0x00, 0x1E, 0x03, 0x00, 0x03, 0x1E, 0x03, 0x00, 0xF8, 0xFF, 0x60, 0x04,
+0x64, 0x00, 0x82, 0x2C, 0x64, 0x00, 0x82, 0x2C, 0xF1, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x25, 0xB0, 0x02, 0x3C, 0x18, 0x00, 0xB0, 0xAF,
+0xF8, 0x02, 0x45, 0x34, 0x25, 0xB0, 0x10, 0x3C, 0xFF, 0x00, 0x83, 0x30,
+0x01, 0x00, 0x02, 0x24, 0x1C, 0x00, 0xBF, 0xAF, 0x03, 0x00, 0x06, 0x36,
+0x0A, 0x00, 0x62, 0x10, 0x0A, 0x00, 0x04, 0x24, 0x00, 0x00, 0xA2, 0x90,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0xFE, 0xFF, 0x03, 0x24,
+0x24, 0x10, 0x43, 0x00, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0xA2, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x42, 0x30, 0x20, 0x00, 0x43, 0x34,
+0x20, 0x00, 0x42, 0x30, 0x02, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC3, 0xA0, 0x2C, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x04, 0x36, 0x00, 0x00, 0x82, 0x90, 0xFE, 0xFF, 0x03, 0x24,
+0xF8, 0x02, 0x06, 0x36, 0x24, 0x10, 0x43, 0x00, 0x00, 0x00, 0x82, 0xA0,
+0x00, 0x00, 0xC3, 0x90, 0x10, 0x00, 0xA5, 0x27, 0x21, 0x20, 0x00, 0x00,
+0x03, 0x00, 0x63, 0x34, 0x00, 0x00, 0xC3, 0xA0, 0xFF, 0x58, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xFF, 0x00, 0x84, 0x30,
+0x21, 0x38, 0x00, 0x00, 0x21, 0x28, 0x00, 0x00, 0x01, 0x00, 0xA3, 0x24,
+0x07, 0x10, 0xA4, 0x00, 0x01, 0x00, 0x42, 0x30, 0xFF, 0x00, 0x65, 0x30,
+0x01, 0x00, 0xE6, 0x24, 0x02, 0x00, 0x40, 0x14, 0x04, 0x00, 0xA3, 0x2C,
+0xFF, 0x00, 0xC7, 0x30, 0xF7, 0xFF, 0x60, 0x14, 0x21, 0x10, 0xE0, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x8C, 0x30,
+0x21, 0x48, 0x00, 0x00, 0x21, 0x38, 0x00, 0x00, 0x40, 0x10, 0x07, 0x00,
+0xFF, 0x00, 0x42, 0x30, 0x21, 0x50, 0x46, 0x00, 0x01, 0x00, 0xE3, 0x24,
+0x07, 0x10, 0xEC, 0x00, 0x01, 0x00, 0x42, 0x30, 0xFF, 0x00, 0x67, 0x30,
+0x21, 0x58, 0x25, 0x01, 0x01, 0x00, 0x24, 0x25, 0x09, 0x00, 0x40, 0x14,
+0x04, 0x00, 0xE8, 0x2C, 0x00, 0x00, 0x63, 0x91, 0xFF, 0x00, 0x89, 0x30,
+0x21, 0x20, 0x25, 0x01, 0x00, 0x00, 0x43, 0xA1, 0x00, 0x00, 0x83, 0x90,
+0x01, 0x00, 0x22, 0x25, 0xFF, 0x00, 0x49, 0x30, 0x01, 0x00, 0x43, 0xA1,
+0xED, 0xFF, 0x00, 0x15, 0x40, 0x10, 0x07, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xD8, 0xFF, 0xBD, 0x27, 0x20, 0x00, 0xB2, 0xAF,
+0x1C, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xBF, 0xAF,
+0x01, 0x00, 0x12, 0x24, 0x21, 0x80, 0x00, 0x00, 0xC5, 0x59, 0x00, 0x08,
+0xFF, 0x00, 0x11, 0x24, 0xFF, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x00, 0x40, 0x10, 0x00, 0x02, 0x03, 0x2E, 0x0F, 0x00, 0x60, 0x10,
+0x21, 0x10, 0x00, 0x02, 0x10, 0x00, 0xA2, 0x93, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x51, 0x10, 0x0F, 0x00, 0x44, 0x30, 0x83, 0x59, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x02, 0x00, 0x21, 0x10, 0x50, 0x00,
+0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x50, 0x30, 0x21, 0x20, 0x00, 0x02,
+0xEE, 0xFF, 0x40, 0x16, 0x10, 0x00, 0xA5, 0x27, 0x21, 0x10, 0x00, 0x02,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0xB8, 0xFF, 0xBD, 0x27, 0x3C, 0x00, 0xB7, 0xAF, 0x38, 0x00, 0xB6, 0xAF,
+0x34, 0x00, 0xB5, 0xAF, 0x30, 0x00, 0xB4, 0xAF, 0x2C, 0x00, 0xB3, 0xAF,
+0x24, 0x00, 0xB1, 0xAF, 0x20, 0x00, 0xB0, 0xAF, 0x44, 0x00, 0xBF, 0xAF,
+0x40, 0x00, 0xBE, 0xAF, 0x28, 0x00, 0xB2, 0xAF, 0x21, 0x98, 0xA0, 0x00,
+0xFF, 0x00, 0x96, 0x30, 0x01, 0x00, 0x10, 0x24, 0x01, 0x00, 0x17, 0x24,
+0x21, 0xA0, 0x00, 0x00, 0x21, 0x88, 0x00, 0x00, 0x21, 0xA8, 0x00, 0x00,
+0x04, 0x00, 0xA0, 0x10, 0x21, 0x18, 0x00, 0x00, 0x10, 0x00, 0xC2, 0x2E,
+0x0E, 0x00, 0x40, 0x14, 0x21, 0x20, 0xA0, 0x00, 0x44, 0x00, 0xBF, 0x8F,
+0x40, 0x00, 0xBE, 0x8F, 0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F,
+0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F,
+0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F,
+0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0x06, 0x24, 0xE3, 0x54, 0x00, 0x0C, 0xFF, 0x00, 0x05, 0x24,
+0x18, 0x00, 0xA4, 0x27, 0xFF, 0x00, 0x05, 0x24, 0xE3, 0x54, 0x00, 0x0C,
+0x08, 0x00, 0x06, 0x24, 0x54, 0x59, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x04, 0x5A, 0x00, 0x08, 0x10, 0x00, 0xBE, 0x27, 0x1C, 0x00, 0x40, 0x14,
+0x21, 0x20, 0xA0, 0x02, 0x37, 0x00, 0xE0, 0x12, 0x00, 0x02, 0x22, 0x2E,
+0x35, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x32,
+0xF8, 0xFF, 0x40, 0x10, 0x20, 0x00, 0x02, 0x32, 0x21, 0x20, 0x20, 0x02,
+0xFF, 0x58, 0x00, 0x0C, 0x10, 0x00, 0xA5, 0x27, 0x2D, 0x00, 0x40, 0x10,
+0xFF, 0x00, 0x02, 0x24, 0x10, 0x00, 0xB0, 0x93, 0x00, 0x00, 0x00, 0x00,
+0x29, 0x00, 0x02, 0x12, 0x0F, 0x00, 0x15, 0x32, 0x83, 0x59, 0x00, 0x0C,
+0x21, 0x20, 0xA0, 0x02, 0x02, 0x81, 0x10, 0x00, 0x10, 0x00, 0x16, 0x12,
+0x21, 0xA0, 0x40, 0x00, 0x40, 0x10, 0x14, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x51, 0x30, 0x00, 0x5A, 0x00, 0x08,
+0x01, 0x00, 0x10, 0x24, 0x18, 0x00, 0xA5, 0x27, 0x92, 0x59, 0x00, 0x0C,
+0x21, 0x30, 0x60, 0x02, 0x40, 0x10, 0x14, 0x00, 0x21, 0x10, 0x51, 0x00,
+0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x51, 0x30, 0x00, 0x5A, 0x00, 0x08,
+0x01, 0x00, 0x10, 0x24, 0x40, 0x90, 0x02, 0x00, 0x10, 0x00, 0x40, 0x1A,
+0x21, 0x80, 0x00, 0x00, 0x21, 0x20, 0x30, 0x02, 0x01, 0x00, 0x84, 0x24,
+0xFF, 0xFF, 0x84, 0x30, 0xFF, 0x58, 0x00, 0x0C, 0x10, 0x00, 0xA5, 0x27,
+0x01, 0x00, 0x03, 0x26, 0x21, 0x20, 0xD0, 0x03, 0xFF, 0x00, 0x70, 0x30,
+0x04, 0x00, 0x40, 0x10, 0x2A, 0x18, 0x12, 0x02, 0x10, 0x00, 0xA2, 0x93,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x82, 0xA0, 0xF3, 0xFF, 0x60, 0x14,
+0x21, 0x20, 0x30, 0x02, 0x00, 0x5A, 0x00, 0x08, 0x20, 0x00, 0x10, 0x24,
+0x54, 0x59, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x63, 0x92,
+0xFF, 0x00, 0x02, 0x24, 0x0F, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x03, 0x24, 0x44, 0x00, 0xBF, 0x8F, 0x40, 0x00, 0xBE, 0x8F,
+0x3C, 0x00, 0xB7, 0x8F, 0x38, 0x00, 0xB6, 0x8F, 0x34, 0x00, 0xB5, 0x8F,
+0x30, 0x00, 0xB4, 0x8F, 0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F,
+0x24, 0x00, 0xB1, 0x8F, 0x20, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x48, 0x00, 0xBD, 0x27, 0x01, 0x00, 0x62, 0x92,
+0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0x43, 0x14, 0x01, 0x00, 0x03, 0x24,
+0x02, 0x00, 0x63, 0x92, 0x00, 0x00, 0x00, 0x00, 0xEB, 0xFF, 0x62, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x62, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xE8, 0xFF, 0x43, 0x14, 0x01, 0x00, 0x03, 0x24, 0x04, 0x00, 0x63, 0x92,
+0x00, 0x00, 0x00, 0x00, 0xE3, 0xFF, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x05, 0x00, 0x62, 0x92, 0x00, 0x00, 0x00, 0x00, 0xDF, 0xFF, 0x43, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x67, 0x92, 0x00, 0x00, 0x00, 0x00,
+0xDC, 0xFF, 0xE2, 0x14, 0x01, 0x00, 0x03, 0x24, 0x07, 0x00, 0x62, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x47, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x3F, 0x5A, 0x00, 0x08, 0x01, 0x00, 0x03, 0x24, 0xC0, 0xFF, 0xBD, 0x27,
+0x38, 0x00, 0xBE, 0xAF, 0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF,
+0x21, 0xF0, 0xC0, 0x00, 0xFF, 0x00, 0xB6, 0x30, 0xFF, 0xFF, 0x95, 0x30,
+0xFF, 0x00, 0x05, 0x24, 0x10, 0x00, 0xA4, 0x27, 0x08, 0x00, 0x06, 0x24,
+0x34, 0x00, 0xB7, 0xAF, 0x24, 0x00, 0xB3, 0xAF, 0x3C, 0x00, 0xBF, 0xAF,
+0x28, 0x00, 0xB4, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0xE3, 0x54, 0x00, 0x0C, 0x0F, 0x00, 0x17, 0x24,
+0x21, 0x98, 0x00, 0x00, 0x40, 0x10, 0x13, 0x00, 0xFF, 0x00, 0x52, 0x30,
+0x07, 0x10, 0x76, 0x02, 0x01, 0x00, 0x42, 0x30, 0x21, 0xA0, 0x5E, 0x02,
+0x21, 0x88, 0xA0, 0x02, 0x21, 0x20, 0xA0, 0x02, 0x13, 0x00, 0x40, 0x10,
+0x01, 0x00, 0xA3, 0x26, 0x01, 0x00, 0x62, 0x26, 0xFF, 0x00, 0x53, 0x30,
+0x04, 0x00, 0x63, 0x2E, 0xF4, 0xFF, 0x60, 0x14, 0x40, 0x10, 0x13, 0x00,
+0x21, 0x10, 0xE0, 0x02, 0x3C, 0x00, 0xBF, 0x8F, 0x38, 0x00, 0xBE, 0x8F,
+0x34, 0x00, 0xB7, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x40, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x85, 0x92, 0xFF, 0xFF, 0x75, 0x30,
+0x2C, 0x59, 0x00, 0x0C, 0x21, 0x80, 0xA0, 0x02, 0x01, 0x00, 0x85, 0x92,
+0x21, 0x20, 0xA0, 0x02, 0x01, 0x00, 0xA2, 0x26, 0x2C, 0x59, 0x00, 0x0C,
+0xFF, 0xFF, 0x55, 0x30, 0x10, 0x00, 0xA3, 0x27, 0x21, 0x90, 0x72, 0x00,
+0x21, 0x20, 0x20, 0x02, 0xFF, 0x58, 0x00, 0x0C, 0x21, 0x28, 0x40, 0x02,
+0x21, 0x20, 0x00, 0x02, 0xFF, 0x58, 0x00, 0x0C, 0x01, 0x00, 0x45, 0x26,
+0x00, 0x00, 0x84, 0x92, 0x00, 0x00, 0x42, 0x92, 0x01, 0x00, 0x03, 0x24,
+0x04, 0x18, 0x63, 0x02, 0x03, 0x00, 0x82, 0x10, 0x27, 0x30, 0x03, 0x00,
+0x87, 0x5A, 0x00, 0x08, 0x24, 0xB8, 0xD7, 0x00, 0x01, 0x00, 0x83, 0x92,
+0x01, 0x00, 0x42, 0x92, 0x00, 0x00, 0x00, 0x00, 0xD2, 0xFF, 0x62, 0x10,
+0x01, 0x00, 0x62, 0x26, 0x88, 0x5A, 0x00, 0x08, 0x24, 0xB8, 0xD7, 0x00,
+0x98, 0xFF, 0xBD, 0x27, 0x50, 0x00, 0xB4, 0xAF, 0xFF, 0x00, 0x94, 0x30,
+0x01, 0x00, 0x04, 0x24, 0x64, 0x00, 0xBF, 0xAF, 0x60, 0x00, 0xBE, 0xAF,
+0x5C, 0x00, 0xB7, 0xAF, 0x58, 0x00, 0xB6, 0xAF, 0x4C, 0x00, 0xB3, 0xAF,
+0x48, 0x00, 0xB2, 0xAF, 0x44, 0x00, 0xB1, 0xAF, 0x21, 0x98, 0xC0, 0x00,
+0xFF, 0x00, 0xB1, 0x30, 0x54, 0x00, 0xB5, 0xAF, 0x54, 0x59, 0x00, 0x0C,
+0x40, 0x00, 0xB0, 0xAF, 0xAC, 0x59, 0x00, 0x0C, 0x01, 0x00, 0x16, 0x24,
+0x21, 0x18, 0x40, 0x00, 0xFF, 0x01, 0x42, 0x2C, 0x01, 0x00, 0x17, 0x24,
+0x01, 0x00, 0x1E, 0x24, 0x21, 0x90, 0x00, 0x00, 0x0E, 0x00, 0x40, 0x14,
+0x21, 0x20, 0x00, 0x00, 0x64, 0x00, 0xBF, 0x8F, 0x60, 0x00, 0xBE, 0x8F,
+0x5C, 0x00, 0xB7, 0x8F, 0x58, 0x00, 0xB6, 0x8F, 0x54, 0x00, 0xB5, 0x8F,
+0x50, 0x00, 0xB4, 0x8F, 0x4C, 0x00, 0xB3, 0x8F, 0x48, 0x00, 0xB2, 0x8F,
+0x44, 0x00, 0xB1, 0x8F, 0x40, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x80, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x68, 0x00, 0xBD, 0x27, 0xFF, 0x01, 0x02, 0x24,
+0x23, 0x10, 0x43, 0x00, 0x1A, 0x00, 0xA4, 0x27, 0xFF, 0x00, 0x05, 0x24,
+0x08, 0x00, 0x06, 0x24, 0xFF, 0xFF, 0x50, 0x30, 0x18, 0x00, 0xB4, 0xA3,
+0xE3, 0x54, 0x00, 0x0C, 0x19, 0x00, 0xB1, 0xA3, 0x21, 0x20, 0x20, 0x02,
+0x21, 0x28, 0x60, 0x02, 0x92, 0x59, 0x00, 0x0C, 0x1A, 0x00, 0xA6, 0x27,
+0x19, 0x00, 0xA4, 0x93, 0x83, 0x59, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x21, 0xA8, 0x40, 0x00, 0xFF, 0xFF, 0x42, 0x30, 0x2B, 0x10, 0x02, 0x02,
+0xDF, 0xFF, 0x40, 0x14, 0x21, 0x20, 0x00, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x09, 0x00, 0xC2, 0x12, 0x20, 0x00, 0x02, 0x24, 0x22, 0x00, 0xC2, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x3B, 0x00, 0xE0, 0x12, 0x00, 0x02, 0x42, 0x2E,
+0x39, 0x00, 0x40, 0x10, 0x01, 0x00, 0x02, 0x24, 0xF9, 0xFF, 0xC2, 0x16,
+0x20, 0x00, 0x02, 0x24, 0x21, 0x20, 0x40, 0x02, 0x10, 0x00, 0xA5, 0x27,
+0xFF, 0x58, 0x00, 0x0C, 0x01, 0x00, 0x13, 0x24, 0x41, 0x00, 0x40, 0x10,
+0xFF, 0x00, 0x02, 0x24, 0x10, 0x00, 0xA5, 0x93, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0xA4, 0x30, 0x3C, 0x00, 0x82, 0x10, 0x0F, 0x00, 0xA3, 0x30,
+0x02, 0x11, 0x04, 0x00, 0x21, 0x20, 0x60, 0x00, 0x29, 0x00, 0xA3, 0xA3,
+0x28, 0x00, 0xA2, 0xA3, 0x83, 0x59, 0x00, 0x0C, 0x11, 0x00, 0xA5, 0xA3,
+0x21, 0x80, 0x40, 0x00, 0x28, 0x00, 0xA3, 0x93, 0x18, 0x00, 0xA2, 0x93,
+0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x62, 0x10, 0x40, 0x10, 0x10, 0x00,
+0x21, 0x10, 0x52, 0x00, 0x01, 0x00, 0x42, 0x24, 0xF9, 0x5A, 0x00, 0x08,
+0xFF, 0xFF, 0x52, 0x30, 0x19, 0x00, 0xA5, 0x93, 0x01, 0x00, 0x44, 0x26,
+0xFF, 0xFF, 0x84, 0x30, 0x6A, 0x5A, 0x00, 0x0C, 0x1A, 0x00, 0xA6, 0x27,
+0x21, 0x28, 0x40, 0x00, 0x0F, 0x00, 0x43, 0x30, 0x0F, 0x00, 0x02, 0x24,
+0x12, 0x00, 0x62, 0x10, 0x40, 0x10, 0x15, 0x00, 0x21, 0x10, 0x52, 0x00,
+0x01, 0x00, 0x42, 0x24, 0x21, 0x20, 0xA0, 0x00, 0xFF, 0xFF, 0x52, 0x30,
+0x18, 0x00, 0xB4, 0xA3, 0x83, 0x59, 0x00, 0x0C, 0x19, 0x00, 0xA5, 0xA3,
+0x21, 0xA8, 0x40, 0x00, 0x02, 0x80, 0x03, 0x3C, 0xCC, 0xDF, 0x62, 0x8C,
+0x02, 0x80, 0x04, 0x3C, 0x01, 0x00, 0x16, 0x24, 0x01, 0x00, 0x42, 0x24,
+0x04, 0x00, 0x43, 0x28, 0xC6, 0xFF, 0x60, 0x14, 0xCC, 0xDF, 0x82, 0xAC,
+0x21, 0xF0, 0x00, 0x00, 0x54, 0x59, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00,
+0x21, 0x20, 0xC0, 0x03, 0x64, 0x00, 0xBF, 0x8F, 0x60, 0x00, 0xBE, 0x8F,
+0x5C, 0x00, 0xB7, 0x8F, 0x58, 0x00, 0xB6, 0x8F, 0x54, 0x00, 0xB5, 0x8F,
+0x50, 0x00, 0xB4, 0x8F, 0x4C, 0x00, 0xB3, 0x8F, 0x48, 0x00, 0xB2, 0x8F,
+0x44, 0x00, 0xB1, 0x8F, 0x40, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x80, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x68, 0x00, 0xBD, 0x27, 0xAC, 0x59, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x03, 0x24, 0x23, 0x18, 0x62, 0x00,
+0xFF, 0xFF, 0x70, 0x30, 0xFF, 0xFF, 0xA2, 0x32, 0x2B, 0x10, 0x02, 0x02,
+0xE7, 0xFF, 0x40, 0x14, 0x21, 0x20, 0x40, 0x02, 0x18, 0x00, 0xB0, 0x93,
+0x19, 0x00, 0xA2, 0x93, 0x00, 0x81, 0x10, 0x00, 0x25, 0x80, 0x02, 0x02,
+0xFF, 0x00, 0x10, 0x32, 0x2C, 0x59, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x02,
+0x21, 0x20, 0x40, 0x02, 0xFF, 0x58, 0x00, 0x0C, 0x11, 0x00, 0xA5, 0x27,
+0x11, 0x00, 0xA3, 0x93, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x64, 0x30,
+0x9D, 0xFF, 0x90, 0x10, 0x20, 0x00, 0x16, 0x24, 0xFF, 0x00, 0x02, 0x24,
+0xCD, 0xFF, 0x82, 0x10, 0x0F, 0x00, 0x63, 0x30, 0x02, 0x11, 0x04, 0x00,
+0x21, 0x20, 0x60, 0x00, 0x29, 0x00, 0xA3, 0xA3, 0x83, 0x59, 0x00, 0x0C,
+0x28, 0x00, 0xA2, 0xA3, 0x38, 0x00, 0xA4, 0x27, 0xFF, 0x00, 0x05, 0x24,
+0x08, 0x00, 0x06, 0x24, 0xE3, 0x54, 0x00, 0x0C, 0x21, 0x80, 0x40, 0x00,
+0x28, 0x00, 0xA4, 0x93, 0xCF, 0x59, 0x00, 0x0C, 0x38, 0x00, 0xA5, 0x27,
+0x1F, 0x00, 0x40, 0x14, 0x01, 0x00, 0x44, 0x26, 0x40, 0x10, 0x10, 0x00,
+0x21, 0x10, 0x52, 0x00, 0x01, 0x00, 0x42, 0x24, 0x2C, 0x5B, 0x00, 0x08,
+0xFF, 0xFF, 0x52, 0x30, 0x40, 0x88, 0x10, 0x00, 0x27, 0x00, 0x20, 0x1A,
+0x21, 0x80, 0x00, 0x00, 0xFF, 0x00, 0x16, 0x24, 0x21, 0x20, 0x50, 0x02,
+0x01, 0x00, 0x84, 0x24, 0xFF, 0xFF, 0x84, 0x30, 0xFF, 0x58, 0x00, 0x0C,
+0x10, 0x00, 0xA5, 0x27, 0x01, 0x00, 0x03, 0x26, 0xFF, 0x00, 0x70, 0x30,
+0x05, 0x00, 0x40, 0x10, 0x2A, 0x18, 0x11, 0x02, 0x10, 0x00, 0xA2, 0x93,
+0x00, 0x00, 0x00, 0x00, 0x26, 0x10, 0x56, 0x00, 0x0B, 0x98, 0x02, 0x00,
+0xF3, 0xFF, 0x60, 0x14, 0x21, 0x20, 0x50, 0x02, 0x15, 0x00, 0x60, 0x16,
+0x21, 0x10, 0x32, 0x02, 0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x52, 0x30,
+0xF9, 0x5A, 0x00, 0x08, 0x01, 0x00, 0x16, 0x24, 0x29, 0x00, 0xA5, 0x93,
+0xFF, 0xFF, 0x84, 0x30, 0x6A, 0x5A, 0x00, 0x0C, 0x38, 0x00, 0xA6, 0x27,
+0x21, 0x28, 0x40, 0x00, 0x0F, 0x00, 0x43, 0x30, 0x0F, 0x00, 0x02, 0x24,
+0xDB, 0xFF, 0x62, 0x10, 0x40, 0x10, 0x10, 0x00, 0x28, 0x00, 0xA4, 0x93,
+0xB9, 0x5A, 0x00, 0x0C, 0x38, 0x00, 0xA6, 0x27, 0xAC, 0x59, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x2C, 0x5B, 0x00, 0x08, 0x21, 0x90, 0x40, 0x00,
+0x19, 0x00, 0xA3, 0x93, 0x29, 0x00, 0xA6, 0x93, 0x0F, 0x00, 0x13, 0x24,
+0x0E, 0x00, 0x10, 0x24, 0x25, 0x18, 0x66, 0x00, 0x01, 0x00, 0x62, 0x30,
+0x0A, 0x98, 0x02, 0x02, 0x02, 0x00, 0x64, 0x30, 0xFD, 0x00, 0x62, 0x32,
+0x0A, 0x98, 0x44, 0x00, 0x04, 0x00, 0x65, 0x30, 0xFB, 0x00, 0x62, 0x32,
+0x0A, 0x98, 0x45, 0x00, 0x08, 0x00, 0x63, 0x30, 0xF7, 0x00, 0x62, 0x32,
+0x0A, 0x98, 0x43, 0x00, 0x0F, 0x00, 0x64, 0x32, 0x0F, 0x00, 0x16, 0x24,
+0x25, 0x00, 0x96, 0x10, 0x21, 0x28, 0xC0, 0x00, 0x01, 0x00, 0x44, 0x26,
+0xFF, 0xFF, 0x84, 0x30, 0x6A, 0x5A, 0x00, 0x0C, 0x1A, 0x00, 0xA6, 0x27,
+0x21, 0x28, 0x40, 0x00, 0x0F, 0x00, 0x42, 0x30, 0x03, 0x00, 0x56, 0x10,
+0x21, 0x20, 0x80, 0x02, 0xB9, 0x5A, 0x00, 0x0C, 0x38, 0x00, 0xA6, 0x27,
+0x19, 0x00, 0xA5, 0x93, 0x00, 0x00, 0x00, 0x00, 0x26, 0x10, 0x65, 0x02,
+0x01, 0x00, 0x42, 0x30, 0x0A, 0x80, 0xC2, 0x02, 0x26, 0x18, 0x65, 0x02,
+0x02, 0x00, 0x63, 0x30, 0xFD, 0x00, 0x04, 0x32, 0x0B, 0x80, 0x83, 0x00,
+0x26, 0x10, 0x65, 0x02, 0x04, 0x00, 0x42, 0x30, 0xFB, 0x00, 0x03, 0x32,
+0x0B, 0x80, 0x62, 0x00, 0x26, 0x28, 0x65, 0x02, 0x08, 0x00, 0xA5, 0x30,
+0xF7, 0x00, 0x02, 0x32, 0x0B, 0x80, 0x45, 0x00, 0x0F, 0x00, 0x03, 0x32,
+0x0D, 0x00, 0x76, 0x10, 0x00, 0x00, 0x00, 0x00, 0xAC, 0x59, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x90, 0x40, 0x00, 0x19, 0x00, 0xB0, 0xA3,
+0x2C, 0x5B, 0x00, 0x08, 0x18, 0x00, 0xB4, 0xA3, 0x21, 0x10, 0x32, 0x02,
+0x01, 0x00, 0x42, 0x24, 0xFF, 0xFF, 0x52, 0x30, 0x01, 0x00, 0x16, 0x24,
+0xF9, 0x5A, 0x00, 0x08, 0x18, 0x00, 0xB4, 0xA3, 0x2C, 0x5B, 0x00, 0x08,
+0x21, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x85, 0xAC, 0x21, 0x10, 0x00, 0x00,
+0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30, 0x06, 0x00, 0x43, 0x2C,
+0xFC, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xA5, 0x30, 0x00, 0x00, 0x85, 0xA4,
+0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x43, 0x2C, 0xFC, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xA5, 0x30,
+0x00, 0x00, 0x85, 0xA0, 0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24,
+0xFF, 0x00, 0x42, 0x30, 0x06, 0x00, 0x43, 0x2C, 0xFC, 0xFF, 0x60, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x82, 0x8C, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x82, 0x94, 0x08, 0x00, 0xE0, 0x03, 0xFF, 0xFF, 0x42, 0x30,
+0x00, 0x00, 0x82, 0x90, 0x08, 0x00, 0xE0, 0x03, 0xFF, 0x00, 0x42, 0x30,
+0x25, 0xB0, 0x02, 0x3C, 0x21, 0x20, 0x82, 0x00, 0x00, 0x00, 0x85, 0xAC,
+0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x43, 0x2C, 0xFC, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x21, 0x20, 0x82, 0x00, 0xFF, 0xFF, 0xA5, 0x30, 0x00, 0x00, 0x85, 0xA4,
+0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x43, 0x2C, 0xFC, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x21, 0x20, 0x82, 0x00, 0xFF, 0x00, 0xA5, 0x30, 0x00, 0x00, 0x85, 0xA0,
+0x21, 0x10, 0x00, 0x00, 0x01, 0x00, 0x42, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x06, 0x00, 0x43, 0x2C, 0xFC, 0xFF, 0x60, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C,
+0x21, 0x20, 0x82, 0x00, 0x00, 0x00, 0x82, 0x8C, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0x21, 0x20, 0x82, 0x00,
+0x00, 0x00, 0x82, 0x94, 0x08, 0x00, 0xE0, 0x03, 0xFF, 0xFF, 0x42, 0x30,
+0x25, 0xB0, 0x02, 0x3C, 0x21, 0x20, 0x82, 0x00, 0x00, 0x00, 0x82, 0x90,
+0x08, 0x00, 0xE0, 0x03, 0xFF, 0x00, 0x42, 0x30, 0x01, 0x80, 0x02, 0x3C,
+0x25, 0xB0, 0x03, 0x3C, 0xD4, 0x70, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34,
+0x00, 0x00, 0x62, 0xAC, 0x00, 0x00, 0x83, 0x90, 0x30, 0x00, 0x02, 0x24,
+0x05, 0x00, 0x62, 0x10, 0x21, 0x20, 0x00, 0x00, 0x31, 0x00, 0x02, 0x24,
+0x02, 0x00, 0x62, 0x10, 0x01, 0x00, 0x04, 0x24, 0x07, 0x00, 0x04, 0x24,
+0x7E, 0x58, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x02, 0x3C,
+0x25, 0xB0, 0x03, 0x3C, 0x10, 0x71, 0x42, 0x24, 0x18, 0x03, 0x63, 0x34,
+0x02, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x62, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xFC, 0x5C, 0x80, 0xAC, 0x42, 0xB0, 0x02, 0x3C, 0x03, 0x00, 0x47, 0x34,
+0x00, 0x00, 0xE3, 0x90, 0xFF, 0x00, 0x84, 0x30, 0x04, 0x00, 0x84, 0x24,
+0xFF, 0x00, 0x65, 0x30, 0x01, 0x00, 0x02, 0x24, 0x04, 0x30, 0x82, 0x00,
+0x07, 0x18, 0x85, 0x00, 0x25, 0xB0, 0x02, 0x3C, 0xE8, 0x03, 0x42, 0x34,
+0x01, 0x00, 0x63, 0x30, 0x21, 0x20, 0xC0, 0x00, 0x00, 0x00, 0x45, 0xA0,
+0x02, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x24, 0x10, 0x85, 0x00, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x1C, 0x00, 0xBF, 0xAF,
+0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0xD0, 0xDF, 0x42, 0x24, 0x04, 0x00, 0x43, 0x8C, 0x00, 0x00, 0x02, 0xAE,
+0x04, 0x00, 0x50, 0xAC, 0x00, 0x00, 0x70, 0xAC, 0x04, 0x00, 0x03, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB0, 0xAF, 0x21, 0x80, 0x80, 0x00,
+0x1C, 0x00, 0xBF, 0xAF, 0x8A, 0x40, 0x00, 0x0C, 0x10, 0x00, 0xA4, 0x27,
+0x04, 0x00, 0x03, 0x8E, 0x00, 0x00, 0x02, 0x8E, 0x10, 0x00, 0xA4, 0x27,
+0x00, 0x00, 0x62, 0xAC, 0x04, 0x00, 0x43, 0xAC, 0x00, 0x00, 0x10, 0xAE,
+0x90, 0x40, 0x00, 0x0C, 0x04, 0x00, 0x10, 0xAE, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x1F, 0xF7, 0x00, 0x6A, 0x82, 0x34, 0x4C, 0xEC, 0x82, 0x34, 0x8C, 0x32,
+0x89, 0xE2, 0x48, 0x32, 0x89, 0xE2, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0x48, 0x32, 0x69, 0xE2, 0x04, 0xF5,
+0x68, 0x9A, 0x01, 0xF6, 0x01, 0x6C, 0x8B, 0xEC, 0x8C, 0xEB, 0x04, 0xF5,
+0x68, 0xDA, 0x20, 0xE8, 0x00, 0x65, 0x00, 0x00, 0x1F, 0xF7, 0x00, 0x6A,
+0x82, 0x34, 0x4C, 0xEC, 0x82, 0x34, 0x8C, 0x32, 0x89, 0xE2, 0x48, 0x32,
+0x89, 0xE2, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0x48, 0x32, 0x69, 0xE2, 0x04, 0xF5, 0x68, 0x9A, 0x01, 0xF6,
+0x01, 0x6C, 0x8B, 0xEC, 0x8C, 0xEB, 0x00, 0xF2, 0x00, 0x6C, 0x8D, 0xEB,
+0x04, 0xF5, 0x68, 0xDA, 0x20, 0xE8, 0x00, 0x65, 0xFF, 0x6B, 0x6C, 0xED,
+0x04, 0x5D, 0x6C, 0xEC, 0x69, 0x60, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0xCB, 0xF4, 0x46, 0xA2, 0xEF, 0x4A, 0x6C, 0xEA, 0x02, 0x5A,
+0x0C, 0x60, 0x02, 0x74, 0x38, 0x60, 0x03, 0x54, 0x1D, 0x61, 0x03, 0x74,
+0x2C, 0x60, 0x04, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x40, 0x32, 0x20, 0xE8,
+0xFF, 0x4A, 0x02, 0x74, 0x3D, 0x60, 0x03, 0x54, 0x18, 0x61, 0x03, 0x74,
+0xF4, 0x61, 0x01, 0x75, 0x43, 0x60, 0x02, 0x55, 0x31, 0x61, 0x02, 0x75,
+0x42, 0x60, 0x03, 0x75, 0xEC, 0x61, 0x02, 0xF0, 0x00, 0x6A, 0x40, 0x32,
+0x1E, 0xF0, 0x00, 0x4A, 0x20, 0xE8, 0x00, 0x65, 0x01, 0x74, 0xE3, 0x61,
+0x02, 0xF0, 0x0F, 0x6A, 0x40, 0x32, 0x20, 0xE8, 0x40, 0x32, 0x01, 0x74,
+0xDC, 0x61, 0x03, 0xF7, 0x10, 0x6A, 0x40, 0x32, 0x40, 0x32, 0x10, 0xF0,
+0x00, 0x4A, 0x20, 0xE8, 0x00, 0x65, 0x01, 0x75, 0x1B, 0x60, 0x02, 0x55,
+0x08, 0x61, 0x02, 0x75, 0x29, 0x60, 0x03, 0x75, 0xCC, 0x61, 0x02, 0xF0,
+0x10, 0x6A, 0x40, 0x32, 0xDE, 0x17, 0xC7, 0x2D, 0x02, 0xF0, 0x10, 0x6A,
+0x40, 0x32, 0x40, 0x32, 0x1E, 0xF0, 0x15, 0x4A, 0x20, 0xE8, 0x00, 0x65,
+0xBE, 0x2D, 0x02, 0xF0, 0x00, 0x6A, 0xF7, 0x17, 0x03, 0xF7, 0x10, 0x6A,
+0x40, 0x32, 0xCD, 0x17, 0x02, 0xF0, 0x10, 0x6A, 0x40, 0x32, 0x40, 0x32,
+0x1E, 0xF0, 0x10, 0x4A, 0x20, 0xE8, 0x00, 0x65, 0x02, 0xF0, 0x00, 0x6A,
+0xF8, 0x17, 0x02, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x1E, 0xF0, 0x05, 0x4A,
+0x20, 0xE8, 0x00, 0x65, 0x02, 0xF0, 0x10, 0x6A, 0x40, 0x32, 0xF7, 0x17,
+0xFC, 0x63, 0x06, 0xD0, 0x8C, 0x30, 0x81, 0xE0, 0x08, 0x30, 0x81, 0xE0,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A,
+0x08, 0x30, 0x41, 0xE0, 0xC9, 0xF7, 0x1B, 0x6D, 0x04, 0xF0, 0x00, 0x6A,
+0x40, 0x32, 0xAB, 0xED, 0x40, 0x32, 0xA0, 0x35, 0xA0, 0x35, 0xFF, 0x4A,
+0x04, 0xF5, 0x40, 0xD8, 0x07, 0x62, 0x80, 0xF1, 0x44, 0x45, 0x40, 0x9A,
+0x08, 0x6B, 0x6B, 0xEB, 0x04, 0xF5, 0x44, 0xD8, 0x04, 0xF5, 0x48, 0x98,
+0xC4, 0x67, 0x6C, 0xEA, 0xFF, 0x6B, 0x02, 0x4B, 0x6B, 0xEB, 0x6C, 0xEA,
+0x02, 0xF0, 0x01, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA, 0x04, 0xF5, 0x48, 0xD8,
+0x04, 0xD5, 0x00, 0x18, 0xA5, 0x21, 0x05, 0xD6, 0x04, 0x95, 0x05, 0x96,
+0x04, 0xF5, 0x4A, 0xA0, 0x60, 0xF1, 0x00, 0x4D, 0xB9, 0xE6, 0x40, 0xC6,
+0x00, 0x6A, 0xC4, 0xF4, 0x58, 0xD8, 0xC4, 0xF4, 0x5C, 0xD8, 0xE4, 0xF4,
+0x40, 0xD8, 0xE4, 0xF4, 0x44, 0xD8, 0xE4, 0xF4, 0x48, 0xD8, 0xE4, 0xF4,
+0x4C, 0xD8, 0xE4, 0xF4, 0x50, 0xD8, 0xE4, 0xF4, 0x54, 0xD8, 0x07, 0x97,
+0x06, 0x90, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x00, 0xFF, 0x63, 0x00, 0xD0,
+0x04, 0x67, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0xFF, 0x6F,
+0x80, 0x34, 0xA0, 0xF1, 0x4F, 0x44, 0xEC, 0xEE, 0x01, 0xD1, 0x59, 0xE6,
+0x40, 0xA6, 0xEC, 0xED, 0xC7, 0x67, 0x4C, 0xEE, 0xAC, 0x32, 0xA9, 0xE2,
+0x48, 0x32, 0xA9, 0xE2, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x63, 0xF3, 0x00, 0x4B, 0x48, 0x32, 0x69, 0xE2, 0x04, 0xF5, 0x48, 0x9A,
+0x07, 0x6B, 0x80, 0xF1, 0x04, 0x4C, 0x6C, 0xEA, 0xEC, 0xEA, 0x48, 0x32,
+0xEC, 0xE8, 0x89, 0xE2, 0x00, 0x6D, 0x80, 0x9A, 0x0D, 0x65, 0x70, 0x67,
+0x2E, 0x26, 0x32, 0x24, 0x65, 0x67, 0x01, 0x69, 0x51, 0x67, 0x44, 0xEB,
+0x8C, 0xEA, 0x36, 0x2A, 0x01, 0x4B, 0xEC, 0xEB, 0x1D, 0x5B, 0xF8, 0x61,
+0x6F, 0x40, 0xFF, 0x6A, 0x4C, 0xEB, 0xE8, 0x67, 0xE3, 0xEB, 0x10, 0x61,
+0x01, 0x69, 0xE2, 0x67, 0x51, 0x67, 0x44, 0xEB, 0x8C, 0xEA, 0x05, 0x22,
+0xCA, 0xED, 0x26, 0x60, 0x01, 0x4D, 0xEC, 0xED, 0x03, 0x67, 0xFF, 0x4B,
+0xEC, 0xEB, 0x48, 0x67, 0x43, 0xEB, 0xF2, 0x60, 0xC3, 0xED, 0x70, 0x67,
+0x0A, 0x60, 0x68, 0x67, 0xAB, 0xE6, 0x42, 0xEB, 0x00, 0x6B, 0x05, 0x61,
+0xE8, 0x67, 0xCB, 0xE7, 0xAD, 0xE2, 0xFF, 0x6A, 0x4C, 0xEB, 0x01, 0x91,
+0x00, 0x90, 0x43, 0x67, 0x20, 0xE8, 0x01, 0x63, 0xC3, 0xE8, 0x65, 0x67,
+0xF8, 0x61, 0xCF, 0xE0, 0x01, 0x91, 0x00, 0x90, 0xEC, 0xEB, 0x43, 0x67,
+0x20, 0xE8, 0x01, 0x63, 0x0B, 0x65, 0xCC, 0x17, 0x70, 0x67, 0xED, 0x17,
+0xC9, 0xF7, 0x1B, 0x6E, 0xCB, 0xEE, 0xC0, 0x36, 0xFF, 0x6F, 0xC0, 0x36,
+0xEC, 0xEC, 0xFF, 0x63, 0x60, 0xF1, 0x40, 0x46, 0x01, 0xD1, 0x00, 0xD0,
+0x49, 0xE4, 0x40, 0xA2, 0x07, 0x67, 0xEC, 0xED, 0x4C, 0xE8, 0xA0, 0xF1,
+0x4F, 0x46, 0x55, 0xE5, 0x40, 0xA5, 0x27, 0x67, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x4C, 0xE9, 0x8C, 0x32, 0x89, 0xE2, 0x48, 0x32,
+0x89, 0xE2, 0x63, 0xF3, 0x00, 0x4B, 0x48, 0x32, 0x69, 0xE2, 0x04, 0xF5,
+0x48, 0x9A, 0x07, 0x6B, 0x80, 0xF1, 0x04, 0x4E, 0x6C, 0xEA, 0xEC, 0xEA,
+0x48, 0x32, 0xC9, 0xE2, 0x00, 0x6D, 0x80, 0x9A, 0x2D, 0x65, 0x70, 0x67,
+0x30, 0x21, 0x34, 0x24, 0x01, 0x6A, 0x65, 0x67, 0x0A, 0x65, 0xC7, 0x67,
+0x48, 0x67, 0x44, 0xEB, 0x8C, 0xEA, 0x36, 0x2A, 0x01, 0x4B, 0xCC, 0xEB,
+0x1D, 0x5B, 0xF8, 0x61, 0x6F, 0x40, 0xFF, 0x6A, 0x4C, 0xEB, 0xC9, 0x67,
+0xC3, 0xEB, 0x10, 0x61, 0x01, 0x6F, 0xC2, 0x67, 0x47, 0x67, 0x44, 0xEB,
+0x8C, 0xEA, 0x05, 0x22, 0x2A, 0xED, 0x26, 0x60, 0x01, 0x4D, 0xCC, 0xED,
+0x03, 0x67, 0xFF, 0x4B, 0xCC, 0xEB, 0x49, 0x67, 0x43, 0xEB, 0xF2, 0x60,
+0x23, 0xED, 0x70, 0x67, 0x0A, 0x60, 0x69, 0x67, 0xAB, 0xE1, 0x42, 0xEB,
+0x00, 0x6B, 0x05, 0x61, 0xC9, 0x67, 0x2B, 0xE6, 0xAD, 0xE2, 0xFF, 0x6A,
+0x4C, 0xEB, 0x01, 0x91, 0x00, 0x90, 0x43, 0x67, 0x20, 0xE8, 0x01, 0x63,
+0x23, 0xE8, 0x65, 0x67, 0xF8, 0x61, 0x2F, 0xE0, 0x01, 0x91, 0x00, 0x90,
+0xEC, 0xEB, 0x43, 0x67, 0x20, 0xE8, 0x01, 0x63, 0x2B, 0x65, 0xCC, 0x17,
+0x70, 0x67, 0xED, 0x17, 0x10, 0xF0, 0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36,
+0xFB, 0x63, 0x00, 0x6D, 0x63, 0xF3, 0x00, 0x4E, 0x07, 0xD1, 0x06, 0xD0,
+0x08, 0x62, 0x05, 0x67, 0x26, 0x67, 0x85, 0x67, 0x04, 0xD5, 0x00, 0x18,
+0xDB, 0x5C, 0x05, 0xD6, 0x04, 0xF5, 0x4A, 0xA1, 0xFF, 0x6B, 0x05, 0x96,
+0x6C, 0xEA, 0x48, 0x32, 0xC9, 0xE2, 0xC0, 0xF5, 0x74, 0x9A, 0x60, 0xF5,
+0x40, 0x9A, 0x4D, 0xE3, 0x66, 0x33, 0xC4, 0xF4, 0x74, 0xD9, 0x04, 0x95,
+0x00, 0x6B, 0x69, 0xE1, 0x01, 0x4B, 0x1D, 0x53, 0x04, 0xF5, 0x0C, 0xC2,
+0x24, 0xF5, 0x09, 0xC2, 0x44, 0xF5, 0x06, 0xC2, 0xF6, 0x61, 0x00, 0x6A,
+0x01, 0x4D, 0x64, 0xF5, 0x44, 0xD9, 0x20, 0x55, 0x7F, 0x49, 0x15, 0x49,
+0xD8, 0x61, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x00, 0xEF, 0x05, 0x63,
+0xF8, 0x63, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x07, 0xD2,
+0x0E, 0x62, 0x0D, 0xD1, 0x0C, 0xD0, 0x63, 0xF3, 0x00, 0x4A, 0x27, 0xF1,
+0x44, 0x9A, 0xFF, 0x6B, 0x6C, 0xEC, 0x6C, 0x65, 0xFF, 0xF7, 0x1F, 0x72,
+0x00, 0x6C, 0x05, 0xD4, 0x01, 0x61, 0x05, 0xD3, 0x07, 0x93, 0xFF, 0xF7,
+0x1F, 0x6A, 0x8B, 0x67, 0x63, 0xF3, 0x00, 0x4B, 0x27, 0xF1, 0x44, 0xDB,
+0x00, 0x6A, 0x04, 0xD2, 0x00, 0xF1, 0x18, 0x24, 0x10, 0xF0, 0x02, 0x6D,
+0x00, 0xF4, 0xA0, 0x35, 0x22, 0x67, 0xBC, 0xF3, 0x0C, 0x4D, 0xFF, 0x6E,
+0x00, 0xF5, 0x84, 0x43, 0x05, 0x10, 0x01, 0x49, 0x1D, 0x51, 0x60, 0xC4,
+0x01, 0x4C, 0x0B, 0x60, 0xA9, 0xE1, 0x60, 0xA2, 0x46, 0x67, 0x6C, 0xEA,
+0xF6, 0x22, 0x01, 0x49, 0x4D, 0x43, 0x1D, 0x51, 0x40, 0xC4, 0x01, 0x4C,
+0xF5, 0x61, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4,
+0x80, 0x34, 0x00, 0x69, 0x63, 0xF3, 0x00, 0x4A, 0x5C, 0xF1, 0x04, 0x4B,
+0xDC, 0xF0, 0x0C, 0x4C, 0x0A, 0x65, 0x4B, 0x65, 0x2C, 0x65, 0x11, 0x67,
+0x48, 0x67, 0x6A, 0x67, 0x00, 0x6D, 0x5D, 0xE0, 0x79, 0xE0, 0xAD, 0xE6,
+0x40, 0xA3, 0xB1, 0xE7, 0x01, 0x4D, 0xA0, 0xF3, 0x48, 0xC4, 0x80, 0xF0,
+0x51, 0xA3, 0x05, 0x55, 0x20, 0xF4, 0x59, 0xC4, 0xF4, 0x61, 0x48, 0x67,
+0x51, 0xE1, 0x49, 0x67, 0x4D, 0xE1, 0x40, 0xA3, 0x01, 0x49, 0x1D, 0x51,
+0xC0, 0xF4, 0x4A, 0xC4, 0x5D, 0xA3, 0x05, 0x48, 0xE0, 0xF4, 0x47, 0xC4,
+0xE1, 0x61, 0x6B, 0x67, 0x00, 0xF1, 0x0A, 0x23, 0x10, 0xF0, 0x02, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x10, 0xF0, 0x02, 0x6F, 0x00, 0xF4, 0xE0, 0x37,
+0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0x00, 0x69, 0x63, 0xF3,
+0x00, 0x4E, 0x5C, 0xF4, 0x00, 0x4F, 0xDC, 0xF3, 0x0C, 0x4D, 0x28, 0x32,
+0xED, 0xE2, 0x60, 0x9B, 0xD1, 0xE2, 0xA9, 0xE2, 0xC0, 0xF5, 0x74, 0xDC,
+0x40, 0x9A, 0x01, 0x49, 0x04, 0x51, 0x60, 0xF5, 0x40, 0xDC, 0xF3, 0x61,
+0x10, 0xF0, 0x02, 0x6F, 0x00, 0xF4, 0xE0, 0x37, 0x10, 0xF0, 0x02, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x04, 0x69, 0x63, 0xF3, 0x00, 0x4F, 0x5C, 0xF4, 0x00, 0x4E, 0xDC, 0xF3,
+0x0C, 0x4D, 0x28, 0x33, 0xC9, 0xE3, 0x40, 0x9A, 0xF1, 0xE3, 0xAD, 0xE3,
+0x4A, 0x32, 0xC0, 0xF5, 0x54, 0xDC, 0x40, 0x9B, 0x01, 0x49, 0x1D, 0x51,
+0x4A, 0x32, 0x60, 0xF5, 0x40, 0xDC, 0xF1, 0x61, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x63, 0xF3, 0x00, 0x4C, 0x00, 0x69, 0x04, 0x67,
+0xD1, 0x67, 0xC4, 0xF4, 0x14, 0x48, 0x06, 0xD4, 0x08, 0xD1, 0x09, 0x10,
+0x08, 0x94, 0x01, 0x49, 0x7F, 0x48, 0x7F, 0x4C, 0x15, 0x4C, 0x20, 0x51,
+0x15, 0x48, 0x08, 0xD4, 0x5E, 0x60, 0x8D, 0x98, 0x01, 0x6B, 0x82, 0x32,
+0x52, 0x32, 0x6C, 0xEA, 0xFF, 0x6B, 0x6C, 0xEA, 0xEF, 0x22, 0x07, 0x6A,
+0x4C, 0xEC, 0x6C, 0xEC, 0x88, 0x32, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC,
+0x80, 0x34, 0x80, 0x34, 0x80, 0xF1, 0x04, 0x4C, 0x89, 0xE2, 0x6B, 0x98,
+0x40, 0x9A, 0x91, 0x67, 0x6C, 0xEA, 0x4C, 0xD8, 0x00, 0x18, 0xA5, 0x21,
+0x0A, 0xD6, 0x20, 0xF0, 0x96, 0xA0, 0xFF, 0x6A, 0xA2, 0x67, 0x4C, 0xEC,
+0x00, 0x18, 0x93, 0x21, 0x2C, 0xED, 0x20, 0xF0, 0x56, 0xA0, 0x04, 0x94,
+0xFF, 0x6B, 0x6C, 0xEA, 0x43, 0xEC, 0x0A, 0x96, 0x01, 0x60, 0x04, 0xD2,
+0xC1, 0xD8, 0xC2, 0xD8, 0xC3, 0xD8, 0xC4, 0xD8, 0xC5, 0xD8, 0xC6, 0xD8,
+0xC7, 0xD8, 0xC8, 0xD8, 0x06, 0x93, 0x48, 0x32, 0xA6, 0x67, 0x69, 0xE2,
+0xC0, 0xF5, 0x74, 0x9A, 0x60, 0xF5, 0x40, 0x9A, 0x4D, 0xE3, 0x66, 0x33,
+0x60, 0xD8, 0x08, 0x92, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33,
+0x63, 0xF3, 0x00, 0x4B, 0x71, 0xE2, 0x66, 0x67, 0xA9, 0xE4, 0x01, 0x4D,
+0x1D, 0x55, 0x04, 0xF5, 0x6C, 0xC2, 0x24, 0xF5, 0x69, 0xC2, 0x44, 0xF5,
+0x66, 0xC2, 0xF6, 0x61, 0x64, 0xF5, 0xC4, 0xDC, 0x08, 0x94, 0x01, 0x49,
+0x7F, 0x48, 0x7F, 0x4C, 0x15, 0x4C, 0x20, 0x51, 0x15, 0x48, 0x08, 0xD4,
+0xA2, 0x61, 0x05, 0x92, 0x06, 0x2A, 0x07, 0x93, 0x63, 0xF3, 0x00, 0x4B,
+0x07, 0xD3, 0x27, 0xF1, 0x44, 0xDB, 0x0E, 0x97, 0x0D, 0x91, 0x0C, 0x90,
+0x00, 0xEF, 0x08, 0x63, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x22, 0x67, 0xBC, 0xF3, 0x0C, 0x4C, 0x00, 0xF5, 0x04, 0x4B, 0x89, 0xE1,
+0x40, 0xA2, 0x01, 0x49, 0x1D, 0x51, 0x40, 0xC3, 0x01, 0x4B, 0xF9, 0x61,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x00, 0x69, 0x63, 0xF3, 0x00, 0x4B, 0x7C, 0xF2, 0x08, 0x4C, 0x1C, 0xF1,
+0x08, 0x4A, 0x0B, 0x65, 0x4C, 0x65, 0x2A, 0x65, 0x11, 0x67, 0x68, 0x67,
+0x8A, 0x67, 0x00, 0x6D, 0x7D, 0xE0, 0x99, 0xE0, 0xAD, 0xE6, 0x40, 0xA3,
+0xB1, 0xE7, 0x01, 0x4D, 0xA0, 0xF3, 0x48, 0xC4, 0x80, 0xF0, 0x51, 0xA3,
+0x05, 0x55, 0x20, 0xF4, 0x59, 0xC4, 0xF4, 0x61, 0x48, 0x67, 0x51, 0xE1,
+0x49, 0x67, 0x4D, 0xE1, 0x40, 0xA3, 0x01, 0x49, 0x1D, 0x51, 0xC0, 0xF4,
+0x4A, 0xC4, 0x5D, 0xA3, 0x05, 0x48, 0xE0, 0xF4, 0x47, 0xC4, 0xE1, 0x61,
+0x10, 0xF0, 0x02, 0x6F, 0x00, 0xF4, 0xE0, 0x37, 0x10, 0xF0, 0x02, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x2B, 0x67, 0x63, 0xF3, 0x00, 0x4F, 0x5C, 0xF4, 0x00, 0x4E, 0xDC, 0xF3,
+0x0C, 0x4D, 0x28, 0x32, 0xCD, 0xE2, 0x60, 0x9B, 0xF1, 0xE2, 0xA9, 0xE2,
+0xC0, 0xF5, 0x74, 0xDC, 0x40, 0x9A, 0x01, 0x49, 0x1D, 0x51, 0x60, 0xF5,
+0x40, 0xDC, 0xF3, 0x61, 0x17, 0x17, 0x00, 0x00, 0xFF, 0xF7, 0x1F, 0x6F,
+0x8C, 0xEF, 0xE0, 0xF1, 0x10, 0x6E, 0xEC, 0xEE, 0xFB, 0x63, 0xD2, 0x36,
+0x06, 0xD0, 0xCC, 0x30, 0xC1, 0xE0, 0x08, 0x30, 0xC1, 0xE0, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x08, 0x30,
+0x41, 0xE0, 0x08, 0x62, 0x07, 0xD1, 0x25, 0x67, 0x04, 0xF5, 0xA8, 0x98,
+0x02, 0xF0, 0x00, 0x6A, 0xFF, 0x6B, 0x4D, 0xED, 0x00, 0xF2, 0x00, 0x6A,
+0xEC, 0xEA, 0x43, 0x32, 0x02, 0x4B, 0x6B, 0xEB, 0x47, 0x32, 0x6C, 0xED,
+0x40, 0x32, 0x4D, 0xED, 0x04, 0xF5, 0x20, 0xD8, 0x04, 0xF5, 0xA8, 0xD8,
+0x87, 0x67, 0x04, 0xD5, 0x00, 0x18, 0x2C, 0x22, 0x05, 0xD6, 0x04, 0x95,
+0x08, 0x6B, 0x07, 0x6C, 0x6B, 0xEB, 0x8C, 0xEA, 0xAC, 0xEB, 0x4D, 0xEB,
+0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x04, 0xF5, 0x68, 0xD8,
+0x40, 0x32, 0x8C, 0xEB, 0x80, 0xF1, 0x04, 0x4A, 0x68, 0x33, 0x4D, 0xE3,
+0x40, 0x9B, 0x2C, 0xEA, 0x04, 0xF5, 0x44, 0xD8, 0x05, 0x96, 0x00, 0x18,
+0xA5, 0x21, 0x86, 0x67, 0x05, 0x96, 0x04, 0xF5, 0x8A, 0xA0, 0x00, 0x18,
+0x93, 0x21, 0xA6, 0x67, 0x08, 0x97, 0x07, 0x91, 0x06, 0x90, 0x00, 0xEF,
+0x05, 0x63, 0x00, 0x00, 0xFF, 0x6A, 0xFD, 0x63, 0x04, 0x62, 0x00, 0x18,
+0xDB, 0x5C, 0x4C, 0xEC, 0x04, 0x97, 0x00, 0xEF, 0x03, 0x63, 0x00, 0x00,
+0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x02, 0xF0, 0x00, 0x6D,
+0x63, 0xF3, 0x00, 0x4C, 0x1F, 0x6B, 0x04, 0xF5, 0x48, 0x9C, 0xFF, 0x4B,
+0x00, 0x53, 0xAD, 0xEA, 0x04, 0xF5, 0x48, 0xDC, 0x7F, 0x4C, 0x15, 0x4C,
+0xF6, 0x60, 0x20, 0xE8, 0x00, 0x65, 0x00, 0x65, 0x00, 0x1C, 0xA1, 0x5E,
+0x00, 0x65, 0x00, 0x65, 0x83, 0xED, 0xAB, 0xE4, 0x01, 0x61, 0x8B, 0xE5,
+0x20, 0xE8, 0x00, 0x65, 0xC9, 0xF7, 0x1B, 0x6A, 0xF9, 0x63, 0x4B, 0xEA,
+0x0A, 0xD0, 0x40, 0x30, 0x00, 0x30, 0x01, 0xF5, 0x83, 0x40, 0x0C, 0x62,
+0x00, 0x1C, 0x00, 0x5C, 0x0B, 0xD1, 0x05, 0xD2, 0x05, 0x93, 0x70, 0x6A,
+0x6C, 0xEA, 0x3A, 0x2A, 0x67, 0x40, 0x3B, 0x4B, 0x01, 0x6A, 0x4B, 0xEA,
+0x40, 0xC3, 0x05, 0x93, 0x70, 0x6A, 0x4C, 0xEB, 0x08, 0xD3, 0x3C, 0x2B,
+0x9D, 0x67, 0x00, 0x1C, 0x8A, 0x40, 0x10, 0x4C, 0x02, 0xF0, 0x00, 0x6A,
+0x40, 0x31, 0xAF, 0x41, 0x00, 0x1C, 0xAC, 0x45, 0x18, 0x6C, 0x9D, 0x67,
+0x10, 0x4C, 0x00, 0x1C, 0x90, 0x40, 0x02, 0x67, 0x00, 0x1C, 0x5B, 0x1F,
+0x64, 0x6C, 0x10, 0xF0, 0x00, 0x6A, 0xD0, 0x67, 0x4D, 0xEE, 0x18, 0x6C,
+0x00, 0x1C, 0x83, 0x45, 0xAF, 0x41, 0x00, 0x1C, 0x2C, 0x1F, 0x03, 0x6C,
+0x08, 0x92, 0x6A, 0x2A, 0xC9, 0xF7, 0x1B, 0x6A, 0x7D, 0x67, 0x4B, 0xEA,
+0x40, 0x32, 0x20, 0xF0, 0x60, 0xA3, 0x0C, 0x97, 0x0B, 0x91, 0x0A, 0x90,
+0x40, 0x32, 0x42, 0x4A, 0x07, 0x63, 0x60, 0xC2, 0x00, 0xEF, 0x00, 0x65,
+0x8F, 0x6A, 0xA3, 0x67, 0x01, 0xF5, 0x83, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0x4C, 0xED, 0x05, 0x93, 0x70, 0x6A, 0x4C, 0xEB, 0x08, 0xD3, 0xC4, 0x23,
+0x9D, 0x67, 0x00, 0x1C, 0x8A, 0x40, 0x10, 0x4C, 0x02, 0xF0, 0x00, 0x6D,
+0xA0, 0x31, 0xAF, 0x41, 0x00, 0x1C, 0xAC, 0x45, 0x00, 0x6C, 0x9D, 0x67,
+0x10, 0x4C, 0x00, 0x1C, 0x90, 0x40, 0x06, 0xD2, 0x00, 0x1C, 0x5B, 0x1F,
+0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42, 0x01, 0x6C, 0x9D, 0x67, 0x00, 0x1C,
+0x8A, 0x40, 0x10, 0x4C, 0xAF, 0x41, 0x00, 0x1C, 0xAC, 0x45, 0x00, 0x6C,
+0x9D, 0x67, 0x10, 0x4C, 0x00, 0x1C, 0x90, 0x40, 0x07, 0xD2, 0x00, 0x1C,
+0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42, 0x00, 0x6C, 0x01, 0xF1,
+0x00, 0x68, 0x06, 0x96, 0x00, 0x30, 0x01, 0x6A, 0xFF, 0x48, 0x40, 0x32,
+0x40, 0x32, 0x0C, 0xEE, 0x4D, 0xEE, 0xAF, 0x41, 0x00, 0x1C, 0x83, 0x45,
+0x00, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42,
+0x01, 0x6C, 0x07, 0x93, 0x01, 0x6E, 0xC0, 0x36, 0x6C, 0xE8, 0xC0, 0x36,
+0xAF, 0x41, 0x0D, 0xEE, 0x00, 0x1C, 0x83, 0x45, 0x00, 0x6C, 0x00, 0x1C,
+0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C, 0xF0, 0x42, 0x00, 0x6C, 0x76, 0x17,
+0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x01, 0xF5,
+0x03, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x05, 0x95, 0x06, 0x96, 0xAF, 0x41,
+0x00, 0x1C, 0x83, 0x45, 0x00, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x00, 0x1C, 0xF0, 0x42, 0x01, 0x6C, 0x07, 0x96, 0xAF, 0x41, 0x00, 0x1C,
+0x83, 0x45, 0x00, 0x6C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C, 0x00, 0x1C,
+0xF0, 0x42, 0x00, 0x6C, 0x0C, 0x97, 0x0B, 0x91, 0x0A, 0x90, 0x00, 0xEF,
+0x07, 0x63, 0x00, 0x00, 0xF8, 0x63, 0x0D, 0xD1, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0x0E, 0x62, 0x0C, 0xD0, 0x63, 0xF3, 0x00, 0x49,
+0x03, 0x99, 0x01, 0x6A, 0x80, 0xF7, 0x02, 0x30, 0x4C, 0xE8, 0x08, 0x28,
+0x42, 0x99, 0x03, 0x6B, 0x40, 0xF7, 0x42, 0x32, 0x6C, 0xEA, 0x01, 0x72,
+0x00, 0xF2, 0x07, 0x60, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x63, 0xF3, 0x00, 0x4D, 0x43, 0x9D, 0x01, 0x6B, 0x80, 0xF7, 0x42, 0x32,
+0x6C, 0xEA, 0xE0, 0xF1, 0x14, 0x22, 0x42, 0x9D, 0x03, 0x6B, 0x40, 0xF7,
+0x42, 0x32, 0x6C, 0xEA, 0x01, 0x72, 0xE0, 0xF1, 0x0C, 0x61, 0x44, 0x9D,
+0x80, 0xF7, 0x42, 0x32, 0x01, 0x72, 0xA0, 0xF2, 0x00, 0x60, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0xC0, 0xF2, 0xA7, 0xA5, 0x80, 0x34, 0x80, 0x34,
+0x61, 0xF4, 0x02, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x06, 0xD5, 0x10, 0xF0,
+0x02, 0x69, 0x00, 0xF4, 0x20, 0x31, 0x63, 0xF3, 0x00, 0x49, 0xC0, 0xF2,
+0x46, 0xA1, 0x07, 0x2A, 0xBD, 0x67, 0xAC, 0xAD, 0x01, 0x6A, 0xC0, 0xF2,
+0x46, 0xC1, 0xC0, 0xF2, 0xA4, 0xC9, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA,
+0x40, 0x30, 0x00, 0x30, 0x01, 0xF5, 0x83, 0x40, 0x00, 0x1C, 0x00, 0x5C,
+0x00, 0x65, 0x70, 0x6B, 0x4C, 0xEB, 0x80, 0xF2, 0x16, 0x2B, 0xC0, 0xF2,
+0x44, 0xA9, 0x06, 0x93, 0x53, 0xE3, 0x63, 0xEA, 0x07, 0xD4, 0x02, 0x61,
+0x6B, 0xE2, 0x07, 0xD2, 0x07, 0x95, 0x03, 0x5D, 0x80, 0xF2, 0x0D, 0x60,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0xC9, 0xF7, 0x1B, 0x6C,
+0x63, 0xF3, 0x00, 0x4A, 0x8B, 0xEC, 0x80, 0x34, 0xC0, 0xF2, 0xA4, 0xA2,
+0x80, 0x34, 0x61, 0xF4, 0x03, 0x4C, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0x63, 0xF3, 0x00, 0x4D,
+0x9D, 0x67, 0x62, 0x9D, 0x98, 0xA4, 0x3F, 0x6E, 0x24, 0x6A, 0xC0, 0xF2,
+0x82, 0xC5, 0x83, 0x67, 0x62, 0x33, 0xCC, 0xEC, 0x62, 0x33, 0xCC, 0xEB,
+0x93, 0xE2, 0x20, 0x6A, 0x7B, 0xE2, 0xC0, 0xF2, 0x43, 0xA5, 0x06, 0x95,
+0x4F, 0xE5, 0x43, 0xED, 0x07, 0xD3, 0x02, 0x60, 0xAB, 0xE2, 0x07, 0xD2,
+0x07, 0x95, 0x60, 0xF1, 0x1C, 0x25, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B, 0xC0, 0xF2, 0x43, 0xA3, 0x06, 0x95,
+0x43, 0xED, 0x16, 0x60, 0x07, 0x92, 0x24, 0x68, 0x83, 0xEA, 0x40, 0xF2,
+0x18, 0x61, 0x07, 0x94, 0x20, 0x6D, 0x08, 0xD5, 0xC3, 0xEC, 0x24, 0x60,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A,
+0x45, 0xAA, 0x3F, 0x6B, 0x6C, 0xEA, 0x89, 0xE2, 0x08, 0xD2, 0x18, 0x10,
+0x42, 0x9B, 0x3F, 0x6B, 0x6C, 0xEA, 0x07, 0x93, 0x43, 0xEB, 0x63, 0xE2,
+0x01, 0x61, 0x00, 0x68, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0x45, 0xAA, 0x07, 0x94, 0x3F, 0x6B, 0x6C, 0xEA,
+0x43, 0xEC, 0x8B, 0xE2, 0x08, 0xD2, 0x02, 0x61, 0x00, 0x6D, 0x08, 0xD5,
+0x06, 0x6A, 0x03, 0xEA, 0x80, 0xF2, 0x06, 0x60, 0x10, 0xF0, 0x02, 0x6B,
+0x00, 0xF4, 0x60, 0x33, 0x08, 0x32, 0x63, 0xF3, 0x00, 0x4B, 0x69, 0xE2,
+0xA6, 0x9A, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3,
+0x00, 0x4B, 0xC3, 0x9B, 0xE0, 0xF3, 0x1F, 0x6F, 0x80, 0xF5, 0xA2, 0x35,
+0x86, 0x67, 0xEC, 0xEC, 0x40, 0xF2, 0x17, 0x24, 0x00, 0xF2, 0x00, 0x68,
+0x44, 0x67, 0x0C, 0xEA, 0x04, 0x22, 0x00, 0xF4, 0x00, 0x6A, 0x4B, 0xEA,
+0x4D, 0xEC, 0xB8, 0xEC, 0xC2, 0x33, 0x6A, 0x33, 0xEC, 0xEB, 0x12, 0xEA,
+0x42, 0x34, 0x43, 0x67, 0x0C, 0xEA, 0xEC, 0xEC, 0x04, 0x22, 0x00, 0xF4,
+0x00, 0x6A, 0x4B, 0xEA, 0x4D, 0xEB, 0xB8, 0xEB, 0xC9, 0xF7, 0x1B, 0x68,
+0x0B, 0xE8, 0x80, 0xF5, 0xA0, 0x35, 0x00, 0x30, 0x00, 0x30, 0x12, 0xEA,
+0x42, 0x31, 0xEC, 0xE9, 0x3F, 0x6A, 0x2C, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x4D, 0xED, 0x8D, 0xED, 0x81, 0xF4, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x04, 0xD5, 0x91, 0xF4, 0x84, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x02, 0xF0, 0x00, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0xFF, 0x4D, 0x4C, 0xED,
+0xC0, 0xF3, 0x00, 0x6A, 0x4C, 0xE9, 0x80, 0xF5, 0x20, 0x32, 0x4D, 0xED,
+0x04, 0xD5, 0x91, 0xF4, 0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0x42, 0x9B, 0xC0, 0xF7, 0x42, 0x32, 0xC0, 0xF1, 0x0A, 0x2A, 0x08, 0x94,
+0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8, 0x8C, 0x32, 0x65, 0xE2, 0xA0, 0xF0,
+0xAC, 0xA1, 0x00, 0x30, 0x00, 0x30, 0x21, 0xF2, 0x82, 0x40, 0x00, 0x1C,
+0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF0, 0xAD, 0xA1, 0x21, 0xF2, 0x83, 0x40,
+0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF0, 0xAE, 0xA1, 0x21, 0xF2,
+0x84, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF0, 0xAF, 0xA1,
+0x21, 0xF2, 0x85, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF0,
+0xB0, 0xA1, 0x21, 0xF2, 0x86, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65,
+0xA0, 0xF0, 0xB1, 0xA1, 0x21, 0xF2, 0x87, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0x00, 0x65, 0xA0, 0xF0, 0xB2, 0xA1, 0x21, 0xF2, 0x88, 0x40, 0x00, 0x1C,
+0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF0, 0xB3, 0xA1, 0x21, 0xF2, 0x89, 0x40,
+0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0xCB, 0xF4, 0x46, 0xA2, 0x22, 0x72, 0x03, 0x60, 0x92, 0x72,
+0x80, 0xF0, 0x0D, 0x61, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0x42, 0x9A, 0x3F, 0x6B, 0x42, 0x32, 0x6C, 0xEA,
+0x24, 0x6B, 0x53, 0xE3, 0x07, 0x92, 0x01, 0x6B, 0x6E, 0xEA, 0x6C, 0xEA,
+0x00, 0xF2, 0x0F, 0x22, 0x07, 0x95, 0xA6, 0x33, 0x64, 0x32, 0x69, 0xE2,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x07, 0xD2, 0x63, 0xF3,
+0x00, 0x4B, 0xC0, 0xF2, 0x43, 0xA3, 0x06, 0x95, 0x43, 0xED, 0xA0, 0xF1,
+0x19, 0x60, 0x07, 0x92, 0x24, 0x68, 0x83, 0xEA, 0x06, 0x60, 0x42, 0x9B,
+0x3F, 0x6B, 0x42, 0x32, 0x6C, 0xEA, 0x07, 0x93, 0x61, 0xE2, 0x06, 0x6D,
+0x03, 0xED, 0xA0, 0xF1, 0x16, 0x60, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x08, 0x32, 0x63, 0xF3, 0x00, 0x4B, 0x69, 0xE2, 0xA6, 0x9A,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x63, 0xF3, 0x00, 0x4B,
+0xC4, 0x9B, 0xE0, 0xF3, 0x1F, 0x6F, 0x80, 0xF5, 0xA2, 0x35, 0xC2, 0x34,
+0x8A, 0x34, 0xEC, 0xEC, 0xA0, 0xF1, 0x1E, 0x24, 0x00, 0xF2, 0x00, 0x68,
+0x44, 0x67, 0x0C, 0xEA, 0x04, 0x22, 0x00, 0xF4, 0x00, 0x6A, 0x4B, 0xEA,
+0x4D, 0xEC, 0xB8, 0xEC, 0x00, 0xF5, 0xC2, 0x33, 0xEC, 0xEB, 0x12, 0xEA,
+0x42, 0x34, 0x43, 0x67, 0x0C, 0xEA, 0xEC, 0xEC, 0x04, 0x22, 0x00, 0xF4,
+0x00, 0x6A, 0x4B, 0xEA, 0x4D, 0xEB, 0xB8, 0xEB, 0xC9, 0xF7, 0x1B, 0x68,
+0x0B, 0xE8, 0x80, 0xF5, 0xA0, 0x35, 0x00, 0x30, 0x00, 0x30, 0x12, 0xEA,
+0x42, 0x31, 0xEC, 0xE9, 0x3F, 0x6A, 0x2C, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0x4D, 0xED, 0x8D, 0xED, 0x81, 0xF4, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x04, 0xD5, 0x91, 0xF4, 0x8C, 0x40, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x02, 0xF0, 0x00, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0xFF, 0x4D, 0x4C, 0xED,
+0xC0, 0xF3, 0x00, 0x6A, 0x4C, 0xE9, 0x80, 0xF5, 0x20, 0x32, 0x4D, 0xED,
+0x91, 0xF4, 0x8C, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x04, 0xD5, 0x0E, 0x97,
+0x0D, 0x91, 0x0C, 0x90, 0x00, 0x6A, 0x00, 0xEF, 0x08, 0x63, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x81, 0xF4, 0x00, 0x4C,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x08, 0xF0, 0x00, 0x6B, 0x6B, 0xEB,
+0x60, 0x33, 0xA2, 0x67, 0x6C, 0xED, 0xD1, 0x67, 0x03, 0x10, 0x01, 0x48,
+0x25, 0x58, 0x0E, 0x60, 0x08, 0x32, 0xC9, 0xE2, 0x46, 0x9A, 0x6C, 0xEA,
+0xAE, 0xEA, 0xF7, 0x2A, 0x62, 0x9E, 0x40, 0x6C, 0x3F, 0x6A, 0x8B, 0xEC,
+0x0C, 0xEA, 0x8C, 0xEB, 0x4D, 0xEB, 0x62, 0xDE, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0xCB, 0xF4, 0x46, 0xA2, 0x22, 0x72, 0x02, 0x60,
+0x92, 0x72, 0x2A, 0x61, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34,
+0x80, 0x34, 0x81, 0xF4, 0x08, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x68,
+0x08, 0xF0, 0x00, 0x6B, 0x6B, 0xEB, 0x60, 0x33, 0xA2, 0x67, 0x10, 0xF0,
+0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x6C, 0xED, 0x63, 0xF3, 0x00, 0x4E,
+0x03, 0x10, 0x01, 0x48, 0x25, 0x58, 0x10, 0x60, 0x08, 0x32, 0xC9, 0xE2,
+0x46, 0x9A, 0x6C, 0xEA, 0xAE, 0xEA, 0xF7, 0x2A, 0x62, 0x9E, 0x3F, 0x6A,
+0x07, 0xF7, 0x01, 0x6C, 0x0C, 0xEA, 0x8B, 0xEC, 0x40, 0x32, 0x8C, 0xEB,
+0x4D, 0xEB, 0x62, 0xDE, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34,
+0x80, 0x34, 0x21, 0xF2, 0x04, 0x4C, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x68,
+0x27, 0xF7, 0x1F, 0x6B, 0x60, 0x33, 0x60, 0x33, 0x27, 0xF7, 0x1F, 0x4B,
+0x4C, 0xEB, 0x04, 0xD3, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x03, 0xF4, 0x0E, 0x4A,
+0x03, 0xF5, 0x16, 0x4B, 0x09, 0xD2, 0x0A, 0xD3, 0x0C, 0x10, 0x0A, 0x93,
+0x9D, 0x67, 0x10, 0x4C, 0x75, 0xE1, 0x00, 0x1C, 0x1D, 0x55, 0x04, 0x6E,
+0xC0, 0xF0, 0x1B, 0x22, 0x01, 0x48, 0x21, 0x58, 0x22, 0x60, 0x09, 0x92,
+0x0C, 0x31, 0x9D, 0x67, 0x10, 0x4C, 0x55, 0xE1, 0x00, 0x1C, 0x1D, 0x55,
+0x04, 0x6E, 0xEB, 0x2A, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35,
+0x63, 0xF3, 0x00, 0x4D, 0x07, 0xF7, 0x00, 0x6A, 0x62, 0x9D, 0x4B, 0xEA,
+0x40, 0x32, 0xFF, 0x4A, 0x3F, 0x6C, 0x4C, 0xEB, 0x0C, 0xEC, 0x10, 0xF0,
+0x00, 0x6A, 0x80, 0x34, 0x40, 0x32, 0x80, 0x34, 0x40, 0x32, 0x8D, 0xEB,
+0xFF, 0x4A, 0x4C, 0xEB, 0x62, 0xDD, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4,
+0x80, 0x34, 0x63, 0xF3, 0x00, 0x4C, 0x63, 0x9C, 0x08, 0xF0, 0x00, 0x6A,
+0x40, 0x32, 0x40, 0x32, 0x4D, 0xEB, 0x63, 0xDC, 0x45, 0x15, 0x02, 0xF0,
+0x00, 0x68, 0x00, 0x30, 0x60, 0x6E, 0xAF, 0x40, 0x00, 0x1C, 0x83, 0x45,
+0x24, 0x6C, 0xE0, 0xF3, 0x08, 0x6C, 0x00, 0x1C, 0x2C, 0x1F, 0x00, 0x65,
+0x9D, 0x67, 0x00, 0x1C, 0x8A, 0x40, 0x14, 0x4C, 0xAF, 0x40, 0x00, 0x1C,
+0xAC, 0x45, 0x24, 0x6C, 0x1F, 0x6C, 0x4C, 0xEC, 0x06, 0xD4, 0x9D, 0x67,
+0x00, 0x1C, 0x90, 0x40, 0x14, 0x4C, 0x00, 0x1C, 0x5B, 0x1F, 0x64, 0x6C,
+0x4C, 0x15, 0x61, 0xF4, 0x83, 0x40, 0xCC, 0x6D, 0x82, 0x15, 0x00, 0x18,
+0xA4, 0x5E, 0x00, 0x65, 0x7D, 0x67, 0x6C, 0xAB, 0x10, 0xF0, 0x02, 0x6A,
+0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0xC0, 0xF2, 0x64, 0xCA,
+0x65, 0x15, 0x42, 0x9B, 0x3F, 0x6B, 0x6C, 0xEA, 0x07, 0x93, 0x61, 0xE2,
+0xA2, 0x15, 0x08, 0x95, 0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8, 0xAC, 0x32,
+0x65, 0xE2, 0xA0, 0xF1, 0xB4, 0xA1, 0x00, 0x30, 0x00, 0x30, 0x21, 0xF2,
+0x82, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF1, 0xB5, 0xA1,
+0x21, 0xF2, 0x83, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF1,
+0xB6, 0xA1, 0x21, 0xF2, 0x84, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65,
+0xA0, 0xF1, 0xB7, 0xA1, 0x21, 0xF2, 0x85, 0x40, 0x00, 0x1C, 0xF0, 0x5B,
+0x00, 0x65, 0xA0, 0xF1, 0xB8, 0xA1, 0x21, 0xF2, 0x86, 0x40, 0x00, 0x1C,
+0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF1, 0xB9, 0xA1, 0x21, 0xF2, 0x87, 0x40,
+0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF1, 0xBA, 0xA1, 0x21, 0xF2,
+0x88, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x00, 0x65, 0xA0, 0xF1, 0xBB, 0xA1,
+0x21, 0xF2, 0x89, 0x40, 0x35, 0x16, 0x6A, 0x60, 0x08, 0x32, 0xC9, 0xF7,
+0x1B, 0x6C, 0x69, 0xE2, 0x8B, 0xEC, 0x80, 0x34, 0xA6, 0x9A, 0x80, 0x34,
+0x81, 0xF4, 0x00, 0x4C, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x81, 0xF4, 0x14, 0x4C,
+0x00, 0x6D, 0xD3, 0x15, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0xAC, 0x9A, 0x7B, 0x15, 0x42, 0x9B, 0x07, 0x94,
+0x3F, 0x6B, 0x42, 0x32, 0x6C, 0xEA, 0x43, 0xEC, 0x83, 0xE2, 0x5F, 0xF6,
+0x08, 0x61, 0x00, 0x68, 0x18, 0x65, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0xAC, 0x9A, 0x4B, 0x16, 0x10, 0xF0,
+0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0x63, 0xF3, 0x00, 0x4D, 0x07, 0xF7,
+0x00, 0x6A, 0x62, 0x9D, 0x4B, 0xEA, 0x3F, 0x6C, 0x40, 0x32, 0xFF, 0x4A,
+0x0C, 0xEC, 0x4C, 0xEB, 0x80, 0x34, 0x10, 0xF0, 0x00, 0x6A, 0x4B, 0xEA,
+0x80, 0x34, 0x40, 0x32, 0x8D, 0xEB, 0x40, 0x32, 0x4D, 0xEB, 0x30, 0x17,
+0x28, 0x60, 0x08, 0x32, 0xC9, 0xF7, 0x1B, 0x6C, 0x69, 0xE2, 0x8B, 0xEC,
+0x80, 0x34, 0xA6, 0x9A, 0x80, 0x34, 0x81, 0xF4, 0x08, 0x4C, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34,
+0x80, 0x34, 0x81, 0xF4, 0x1C, 0x4C, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x6D,
+0x6C, 0x16, 0x07, 0x93, 0xFF, 0x4B, 0x66, 0x33, 0x64, 0x32, 0x69, 0xE2,
+0x01, 0x4A, 0xEE, 0x15, 0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34,
+0xAC, 0x9B, 0x80, 0x34, 0x81, 0xF4, 0x00, 0x4C, 0x97, 0x17, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0xAC, 0x9B, 0x80, 0x34, 0x81, 0xF4,
+0x08, 0x4C, 0xD9, 0x17, 0x82, 0x34, 0x1F, 0xF7, 0x00, 0x6A, 0x4C, 0xEC,
+0x82, 0x35, 0x20, 0x5D, 0x1B, 0x60, 0xAC, 0x32, 0xA9, 0xE2, 0x48, 0x32,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xA9, 0xE2, 0x63, 0xF3,
+0x00, 0x4B, 0x48, 0x32, 0x69, 0xE2, 0xE4, 0xF4, 0x58, 0x9A, 0xC9, 0xF7,
+0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x52, 0x32, 0x7F, 0x6B,
+0x60, 0xF3, 0x14, 0x4C, 0x6C, 0xEA, 0x40, 0xDC, 0x20, 0xE8, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0xCA, 0xF2, 0x4C, 0x9A,
+0xC9, 0xF7, 0x1B, 0x6C, 0x8B, 0xEC, 0x80, 0x34, 0x80, 0x34, 0x52, 0x32,
+0x7F, 0x6B, 0x60, 0xF3, 0x14, 0x4C, 0x6C, 0xEA, 0x40, 0xDC, 0x20, 0xE8,
+0x00, 0x65, 0x00, 0x00, 0xFC, 0x63, 0x04, 0xD0, 0xC9, 0xF7, 0x1B, 0x68,
+0x0B, 0xE8, 0x00, 0x30, 0x00, 0x30, 0x01, 0xF5, 0x83, 0x40, 0x06, 0x62,
+0x00, 0x1C, 0x00, 0x5C, 0x05, 0xD1, 0x08, 0x6D, 0x4D, 0xED, 0xFF, 0x69,
+0x01, 0xF5, 0x83, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x2C, 0xED, 0x01, 0xF5,
+0x83, 0x40, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65, 0xA2, 0x67, 0xF7, 0x6B,
+0x01, 0xF5, 0x83, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x6C, 0xED, 0x21, 0xF2,
+0x8D, 0x40, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65, 0xA2, 0x67, 0x3F, 0x6B,
+0x21, 0xF2, 0x8D, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x6C, 0xED, 0x21, 0xF2,
+0x8D, 0x40, 0x00, 0x1C, 0x00, 0x5C, 0x00, 0x65, 0x80, 0x6D, 0xAB, 0xED,
+0x4D, 0xED, 0x21, 0xF2, 0x8D, 0x40, 0x00, 0x1C, 0xF0, 0x5B, 0x2C, 0xED,
+0x06, 0x97, 0x05, 0x91, 0x04, 0x90, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x65,
+0x00, 0x1C, 0x2A, 0x61, 0x00, 0x65, 0x00, 0x65, 0x00, 0x1C, 0x2C, 0x61,
+0x00, 0x65, 0x00, 0x65, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x30, 0xF2, 0x63, 0x42, 0x90, 0x34, 0x80, 0xC3, 0x20, 0xF2,
+0x10, 0x4A, 0x40, 0x9A, 0x02, 0xF0, 0x00, 0x6B, 0x60, 0x33, 0xFF, 0x4B,
+0x20, 0xE8, 0x6C, 0xEA, 0xC9, 0xF7, 0x1B, 0x6A, 0x4B, 0xEA, 0xFF, 0x6D,
+0x40, 0x32, 0x8C, 0xED, 0x40, 0x32, 0x30, 0xF2, 0x83, 0x42, 0xB0, 0x33,
+0x60, 0xC4, 0x20, 0xF2, 0x10, 0x4A, 0x60, 0x9A, 0x02, 0xF0, 0x00, 0x6A,
+0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0x83, 0x67, 0x05, 0x23, 0x01, 0x6C,
+0x84, 0xED, 0xFF, 0xF7, 0x1F, 0x6A, 0x4C, 0xEC, 0x20, 0xE8, 0x44, 0x67,
+0xC9, 0xF7, 0x1B, 0x6A, 0xFB, 0x63, 0x4B, 0xEA, 0x07, 0xD1, 0x40, 0x31,
+0x08, 0x62, 0x06, 0xD0, 0x20, 0x31, 0x40, 0xF0, 0x4C, 0xA1, 0xFF, 0x6C,
+0x8C, 0xEA, 0x02, 0x72, 0x14, 0x61, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x04, 0xD2, 0x66, 0xF7, 0x56, 0xAA,
+0x01, 0x72, 0x09, 0x61, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0xEB, 0xF5, 0x4C, 0xA2, 0x04, 0x67, 0x4C, 0xE8, 0x05, 0x20, 0x08, 0x97,
+0x07, 0x91, 0x06, 0x90, 0x00, 0xEF, 0x05, 0x63, 0x00, 0x18, 0x2C, 0x61,
+0x04, 0x6C, 0x04, 0x94, 0x08, 0xF0, 0x64, 0x9C, 0x4D, 0xE3, 0x08, 0xF0,
+0x64, 0xDC, 0x00, 0x18, 0x2C, 0x61, 0x06, 0x6C, 0x04, 0x94, 0x08, 0xF0,
+0x68, 0x9C, 0x4D, 0xE3, 0x08, 0xF0, 0x68, 0xDC, 0x00, 0x18, 0x2C, 0x61,
+0x07, 0x6C, 0x04, 0x94, 0x08, 0xF0, 0x6C, 0x9C, 0x4D, 0xE3, 0x08, 0xF0,
+0x6C, 0xDC, 0x00, 0x18, 0x2C, 0x61, 0x05, 0x6C, 0x04, 0x94, 0x08, 0xF0,
+0x70, 0x9C, 0x4D, 0xE3, 0x08, 0xF0, 0x70, 0xDC, 0x00, 0x18, 0x35, 0x61,
+0x90, 0x67, 0x04, 0x6C, 0x00, 0x18, 0x35, 0x61, 0x02, 0x67, 0x4D, 0xE8,
+0xFF, 0xF7, 0x1F, 0x6A, 0x4C, 0xE8, 0x30, 0xF2, 0x63, 0x41, 0x08, 0x6A,
+0x40, 0xC3, 0xC7, 0x28, 0x40, 0xF0, 0x40, 0xA9, 0xFF, 0xF7, 0x1F, 0x6B,
+0x6C, 0xEA, 0xFB, 0xF7, 0x1F, 0x6B, 0x6C, 0xEA, 0x04, 0xF0, 0x00, 0x6B,
+0x40, 0xF0, 0x40, 0xC9, 0x6D, 0xEA, 0x40, 0xF0, 0x40, 0xC9, 0x04, 0x94,
+0xFF, 0xF7, 0x1F, 0x6A, 0x66, 0xF7, 0xB4, 0xAC, 0x01, 0x4D, 0x66, 0xF7,
+0xB4, 0xCC, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x7E, 0xF2,
+0x08, 0x4C, 0x00, 0x1C, 0x13, 0x58, 0x4C, 0xED, 0xA6, 0x17, 0x00, 0x65,
+0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF, 0x85, 0x2B, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xBF, 0x8F, 0x02, 0x80, 0x02, 0x3C,
+0xE8, 0x03, 0x03, 0x24, 0x2C, 0x5E, 0x43, 0xAC, 0x18, 0x00, 0xBD, 0x27,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x0B, 0x5E, 0x40, 0xA0, 0xFF, 0x00, 0x85, 0x30,
+0xF2, 0x5D, 0x60, 0xA0, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x05, 0x5E, 0x40, 0xA0, 0x08, 0x00, 0xA4, 0x2C, 0x07, 0x5E, 0x60, 0xA0,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x0F, 0x5E, 0x40, 0xA0,
+0xEC, 0x5D, 0x65, 0xA0, 0x2C, 0x00, 0x80, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x80, 0x10, 0x05, 0x00, 0x78, 0xF2, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x44, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24,
+0xD0, 0x1B, 0xA4, 0x8C, 0x00, 0x70, 0x02, 0x3C, 0x02, 0x00, 0x42, 0x34,
+0x25, 0x20, 0x82, 0x00, 0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x64, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0xD0, 0x1B, 0xA4, 0xAC, 0x02, 0x80, 0x05, 0x3C,
+0x60, 0x1B, 0xA5, 0x24, 0xD0, 0x1B, 0xA4, 0x8C, 0x00, 0x70, 0x02, 0x3C,
+0x02, 0x00, 0x42, 0x34, 0x27, 0x10, 0x02, 0x00, 0x24, 0x20, 0x82, 0x00,
+0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x64, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xD0, 0x1B, 0xA4, 0xAC, 0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24,
+0xD0, 0x1B, 0xA4, 0x8C, 0x00, 0x70, 0x02, 0x3C, 0x27, 0x10, 0x02, 0x00,
+0x24, 0x20, 0x82, 0x00, 0x02, 0x80, 0x07, 0x3C, 0x41, 0xB0, 0x02, 0x3C,
+0x01, 0x00, 0x03, 0x24, 0x00, 0x00, 0x44, 0xAC, 0x09, 0x5E, 0xE3, 0xA0,
+0x09, 0x5E, 0xE6, 0x90, 0x02, 0x80, 0x02, 0x3C, 0xD0, 0x1B, 0xA4, 0xAC,
+0x0A, 0x5E, 0x46, 0xA0, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x05, 0x3C, 0x60, 0x1B, 0xA5, 0x24, 0xD0, 0x1B, 0xA4, 0x8C,
+0x00, 0x70, 0x02, 0x3C, 0x27, 0x10, 0x02, 0x00, 0x24, 0x20, 0x82, 0x00,
+0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x64, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0xD0, 0x1B, 0xA4, 0xAC, 0xE0, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x10, 0x3C, 0xEC, 0x5D, 0x02, 0x92, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF, 0x21, 0x90, 0x80, 0x00,
+0x1C, 0x00, 0x40, 0x10, 0xFF, 0x00, 0xB1, 0x30, 0x02, 0x80, 0x03, 0x3C,
+0xC6, 0x5C, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x42, 0x30,
+0x1C, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x24,
+0x00, 0x02, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0xEE, 0x5D, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x0F, 0x00, 0x42, 0x30, 0x0C, 0x00, 0x42, 0x28, 0x06, 0x00, 0x40, 0x10,
+0x08, 0x00, 0x02, 0x24, 0x00, 0x00, 0x44, 0x96, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0x83, 0x30, 0x1B, 0x00, 0x62, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0xEC, 0x5D, 0x02, 0x92, 0x05, 0x00, 0x03, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x0B, 0x00, 0x43, 0x10, 0x02, 0x80, 0x03, 0x3C, 0x1C, 0x00, 0xBF, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27, 0xA8, 0x2D, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0xF1, 0x61, 0x00, 0x08, 0x00, 0x08, 0x04, 0x24,
+0x08, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x24, 0x10, 0x22, 0x02,
+0xF2, 0xFF, 0x40, 0x10, 0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x62, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x42, 0x34, 0x07, 0x5E, 0x62, 0xA0,
+0x05, 0x62, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5E, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x60, 0x14, 0x00, 0x10, 0x82, 0x34,
+0x00, 0x62, 0x00, 0x08, 0x00, 0x00, 0x42, 0xA6, 0x0C, 0x00, 0x04, 0x24,
+0x4B, 0x2E, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x00, 0x62, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x02, 0x80, 0x03, 0x3C, 0x0B, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x00, 0x40, 0x10, 0x02, 0x80, 0x04, 0x3C, 0x0B, 0x5E, 0x60, 0xA0,
+0x02, 0x80, 0x04, 0x3C, 0x07, 0x5E, 0x83, 0x90, 0xFD, 0xFF, 0x02, 0x24,
+0x24, 0x18, 0x62, 0x00, 0x07, 0x5E, 0x83, 0xA0, 0x07, 0x5E, 0x82, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x42, 0x30, 0x49, 0x00, 0x40, 0x10,
+0x02, 0x80, 0x02, 0x3C, 0x10, 0x00, 0xBF, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0xF2, 0x5D, 0x82, 0x90,
+0x02, 0x80, 0x05, 0x3C, 0x01, 0x00, 0x42, 0x24, 0xF2, 0x5D, 0x82, 0xA0,
+0x07, 0x5E, 0xA3, 0x90, 0xEF, 0xFF, 0x02, 0x24, 0x24, 0x18, 0x62, 0x00,
+0x07, 0x5E, 0xA3, 0xA0, 0xF2, 0x5D, 0x82, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x42, 0x2C, 0x13, 0x00, 0x40, 0x14, 0x25, 0xB0, 0x06, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x10, 0x37, 0x62, 0x94, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x42, 0x30, 0x3A, 0x00, 0x40, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x0E, 0x5E, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00,
+0xE5, 0xFF, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x5E, 0x62, 0x90,
+0x10, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xBD, 0x27, 0x01, 0x00, 0x42, 0x24,
+0x0E, 0x5E, 0x62, 0xA0, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x84, 0x00, 0xC4, 0x34, 0x80, 0x00, 0xC6, 0x34, 0x00, 0x00, 0x82, 0x8C,
+0x00, 0x00, 0xC4, 0x8C, 0x02, 0x80, 0x08, 0x3C, 0x21, 0x10, 0x00, 0x00,
+0x14, 0x5E, 0x06, 0x8D, 0x42, 0xB0, 0x0A, 0x3C, 0x25, 0x10, 0x44, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x18, 0x5E, 0x88, 0x8C, 0x1C, 0x5E, 0x89, 0x8C,
+0x00, 0x00, 0x45, 0x91, 0x21, 0x10, 0x46, 0x00, 0xFB, 0xFF, 0x04, 0x24,
+0x24, 0x28, 0xA4, 0x00, 0x23, 0x40, 0x02, 0x01, 0x00, 0x00, 0x45, 0xA1,
+0x04, 0x00, 0x00, 0x11, 0x01, 0x00, 0x06, 0x24, 0x80, 0x10, 0x08, 0x00,
+0x21, 0x10, 0x48, 0x00, 0x80, 0x30, 0x02, 0x00, 0x01, 0x00, 0x04, 0x24,
+0xB9, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x42, 0xB0, 0x02, 0x3C,
+0x22, 0x00, 0x04, 0x24, 0x03, 0x00, 0x42, 0x34, 0x00, 0x00, 0x44, 0xA0,
+0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90, 0x10, 0x00, 0xBF, 0x8F,
+0x01, 0x00, 0x05, 0x24, 0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08,
+0x18, 0x00, 0xBD, 0x27, 0x05, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C,
+0xED, 0x5D, 0x64, 0x90, 0x10, 0x00, 0xBF, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0x10, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xBD, 0x27, 0x0E, 0x5E, 0x40, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27,
+0xFF, 0x00, 0xA5, 0x30, 0x10, 0x00, 0xB0, 0xAF, 0x14, 0x00, 0xBF, 0xAF,
+0x18, 0x00, 0xA0, 0x14, 0xFF, 0x00, 0x90, 0x30, 0x35, 0x00, 0x00, 0x12,
+0x01, 0x00, 0x05, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x01, 0x00, 0x05, 0x24,
+0x05, 0x5E, 0x45, 0xA0, 0x02, 0x80, 0x07, 0x3C, 0x07, 0x5E, 0xE3, 0x90,
+0x02, 0x00, 0x04, 0x24, 0x21, 0x28, 0x00, 0x00, 0x02, 0x00, 0x63, 0x34,
+0x00, 0xF0, 0x06, 0x34, 0x07, 0x5E, 0xE3, 0xA0, 0xB9, 0x20, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x42, 0xB0, 0x02, 0x3C, 0x44, 0x00, 0x03, 0x24, 0x03, 0x00, 0x42, 0x34,
+0x18, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x43, 0xA0, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x05, 0x5E, 0x44, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0x08, 0x5E, 0x65, 0x90,
+0x0F, 0x00, 0x02, 0x24, 0x02, 0x80, 0x06, 0x3C, 0x0F, 0x00, 0xA5, 0x30,
+0x0D, 0x00, 0xA2, 0x10, 0x01, 0x00, 0x04, 0x24, 0x07, 0x5E, 0xC2, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x34, 0x07, 0x5E, 0xC2, 0xA0,
+0xE1, 0x51, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xDB, 0xFF, 0x00, 0x16,
+0x02, 0x80, 0x02, 0x3C, 0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x18, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C,
+0x04, 0x5E, 0x43, 0x90, 0x01, 0x00, 0x04, 0x24, 0xF6, 0xFF, 0x60, 0x10,
+0x01, 0x00, 0x05, 0x24, 0xC8, 0x51, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xB9, 0x62, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x05, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xFF, 0x00, 0x84, 0x30,
+0x4B, 0x2E, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27,
+0xFF, 0x00, 0xA5, 0x30, 0x14, 0x00, 0xB1, 0xAF, 0x18, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x03, 0x00, 0xA0, 0x14, 0xFF, 0x00, 0x91, 0x30,
+0x3A, 0x00, 0x20, 0x12, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x10, 0x3C,
+0x07, 0x5E, 0x02, 0x92, 0xFB, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x07, 0x5E, 0x02, 0xA2, 0x10, 0x00, 0xA0, 0x14, 0x02, 0x80, 0x03, 0x3C,
+0x07, 0x5E, 0x02, 0x92, 0xFE, 0xFF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00,
+0x07, 0x5E, 0x02, 0xA2, 0x19, 0x00, 0x20, 0x16, 0x02, 0x80, 0x02, 0x3C,
+0x07, 0x5E, 0x02, 0x92, 0xFD, 0xFF, 0x03, 0x24, 0x18, 0x00, 0xBF, 0x8F,
+0x24, 0x10, 0x43, 0x00, 0x07, 0x5E, 0x02, 0xA2, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x01, 0x00, 0x04, 0x24, 0x05, 0x5E, 0x64, 0xA0, 0x07, 0x5E, 0x02, 0x92,
+0x02, 0x80, 0x03, 0x3C, 0x01, 0x00, 0x42, 0x34, 0x07, 0x5E, 0x02, 0xA2,
+0x06, 0x5E, 0x62, 0x90, 0x02, 0x00, 0x03, 0x24, 0xFF, 0x00, 0x42, 0x30,
+0x23, 0x00, 0x43, 0x10, 0x00, 0x00, 0x00, 0x00, 0xE1, 0x51, 0x00, 0x0C,
+0x01, 0x00, 0x04, 0x24, 0xE9, 0xFF, 0x20, 0x12, 0x02, 0x80, 0x02, 0x3C,
+0x01, 0x00, 0x04, 0x24, 0x05, 0x5E, 0x44, 0xA0, 0x07, 0x5E, 0x03, 0x92,
+0x02, 0x00, 0x04, 0x24, 0x21, 0x28, 0x00, 0x00, 0x02, 0x00, 0x63, 0x34,
+0x00, 0xF0, 0x06, 0x34, 0x07, 0x5E, 0x03, 0xA2, 0xB9, 0x20, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x42, 0xB0, 0x02, 0x3C, 0x44, 0x00, 0x03, 0x24,
+0x03, 0x00, 0x42, 0x34, 0x20, 0x00, 0xBD, 0x27, 0x00, 0x00, 0x43, 0xA0,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0x5E, 0x40, 0xA0,
+0x02, 0x80, 0x03, 0x3C, 0xED, 0x5D, 0x64, 0x90, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x05, 0x24,
+0xFF, 0x00, 0x84, 0x30, 0x4B, 0x2E, 0x00, 0x08, 0x20, 0x00, 0xBD, 0x27,
+0xE2, 0x2C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x24,
+0x4B, 0x2E, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0xE5, 0x62, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB2, 0xAF,
+0x0C, 0x00, 0xB1, 0xAF, 0x08, 0x00, 0xB0, 0xAF, 0x21, 0x40, 0xE0, 0x00,
+0x21, 0x90, 0xA0, 0x03, 0x21, 0x60, 0xC0, 0x00, 0x21, 0x78, 0x80, 0x00,
+0x45, 0x00, 0xE0, 0x14, 0x21, 0x50, 0xA0, 0x00, 0x2B, 0x10, 0xA6, 0x00,
+0x78, 0x00, 0x40, 0x10, 0xFF, 0xFF, 0x02, 0x34, 0x2B, 0x10, 0x46, 0x00,
+0x8F, 0x01, 0x40, 0x10, 0x21, 0x28, 0xC0, 0x00, 0xFF, 0x00, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x10, 0x00, 0x03, 0x24, 0x2B, 0x10, 0x46, 0x00,
+0x18, 0x00, 0x04, 0x24, 0x21, 0x30, 0x60, 0x00, 0x0B, 0x30, 0x82, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x06, 0x10, 0xC5, 0x00, 0x98, 0xF2, 0x63, 0x24,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x90, 0x20, 0x00, 0x02, 0x24,
+0x21, 0x20, 0x86, 0x00, 0x23, 0x30, 0x44, 0x00, 0x08, 0x00, 0xC0, 0x10,
+0x02, 0x4C, 0x0C, 0x00, 0x23, 0x10, 0x46, 0x00, 0x06, 0x10, 0x4F, 0x00,
+0x04, 0x18, 0xCA, 0x00, 0x25, 0x50, 0x62, 0x00, 0x04, 0x60, 0xCC, 0x00,
+0x04, 0x78, 0xCF, 0x00, 0x02, 0x4C, 0x0C, 0x00, 0x1B, 0x00, 0x49, 0x01,
+0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00,
+0xFF, 0xFF, 0x87, 0x31, 0x02, 0x24, 0x0F, 0x00, 0x12, 0x18, 0x00, 0x00,
+0x10, 0x28, 0x00, 0x00, 0x00, 0x14, 0x05, 0x00, 0x25, 0x28, 0x44, 0x00,
+0x18, 0x00, 0x67, 0x00, 0x12, 0x58, 0x00, 0x00, 0x2B, 0x18, 0xAB, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x49, 0x01, 0x02, 0x00, 0x20, 0x15,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x08, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x28, 0xAC, 0x00, 0x2B, 0x10, 0xAC, 0x00,
+0x04, 0x00, 0x40, 0x14, 0x2B, 0x10, 0xAB, 0x00, 0x00, 0x00, 0x42, 0x38,
+0x21, 0x18, 0xAC, 0x00, 0x0B, 0x28, 0x62, 0x00, 0x23, 0x28, 0xAB, 0x00,
+0x1B, 0x00, 0xA9, 0x00, 0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0xE4, 0x31, 0x12, 0x18, 0x00, 0x00,
+0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x63, 0x00, 0x08,
+0x18, 0x00, 0x67, 0x00, 0x2B, 0x10, 0xA7, 0x00, 0x0A, 0x00, 0x40, 0x10,
+0xFF, 0xFF, 0x02, 0x34, 0x10, 0x00, 0xB2, 0x8F, 0x0C, 0x00, 0xB1, 0x8F,
+0x08, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x80, 0x00, 0x21, 0x18, 0xA0, 0x00,
+0x00, 0x00, 0xA4, 0xAF, 0x04, 0x00, 0xA5, 0xAF, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x2B, 0x10, 0x47, 0x00, 0xD2, 0x00, 0x40, 0x10,
+0x00, 0x01, 0xE3, 0x2C, 0xFF, 0x00, 0x02, 0x3C, 0x10, 0x00, 0x03, 0x24,
+0xFF, 0xFF, 0x42, 0x34, 0x2B, 0x10, 0x47, 0x00, 0x18, 0x00, 0x04, 0x24,
+0x21, 0x28, 0x60, 0x00, 0x0B, 0x28, 0x82, 0x00, 0x06, 0x10, 0xA8, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x98, 0xF2, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x44, 0x90, 0x20, 0x00, 0x02, 0x24, 0x21, 0x20, 0x85, 0x00,
+0x23, 0x30, 0x44, 0x00, 0xCE, 0x00, 0xC0, 0x14, 0x23, 0x38, 0x46, 0x00,
+0x2B, 0x10, 0x0A, 0x01, 0x04, 0x00, 0x40, 0x14, 0x23, 0x20, 0xEC, 0x01,
+0x2B, 0x10, 0xEC, 0x01, 0x05, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0xE4, 0x01, 0x23, 0x18, 0x48, 0x01, 0x23, 0x50, 0x62, 0x00,
+0x21, 0x78, 0x80, 0x00, 0x04, 0x00, 0x40, 0x12, 0x21, 0xC0, 0xE0, 0x01,
+0x21, 0xC8, 0x40, 0x01, 0x00, 0x00, 0x58, 0xAE, 0x04, 0x00, 0x59, 0xAE,
+0x00, 0x00, 0xA2, 0x8F, 0x04, 0x00, 0xA3, 0x8F, 0x10, 0x00, 0xB2, 0x8F,
+0x0C, 0x00, 0xB1, 0x8F, 0x08, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x53, 0x00, 0xC0, 0x10, 0x01, 0x00, 0x02, 0x24,
+0xFF, 0xFF, 0x02, 0x34, 0x2B, 0x10, 0x4C, 0x00, 0x59, 0x00, 0x40, 0x14,
+0xFF, 0x00, 0x02, 0x3C, 0x00, 0x01, 0x83, 0x2D, 0x08, 0x00, 0x02, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x0A, 0x28, 0x43, 0x00, 0x06, 0x10, 0xAC, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x98, 0xF2, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x44, 0x90, 0x20, 0x00, 0x02, 0x24, 0x21, 0x20, 0x85, 0x00,
+0x23, 0x30, 0x44, 0x00, 0x5B, 0x00, 0xC0, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x23, 0x50, 0x4C, 0x01, 0x02, 0x4C, 0x0C, 0x00, 0xFF, 0xFF, 0x8D, 0x31,
+0x1B, 0x00, 0x49, 0x01, 0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0x02, 0x24, 0x0F, 0x00, 0x12, 0x18, 0x00, 0x00,
+0x10, 0x28, 0x00, 0x00, 0x00, 0x14, 0x05, 0x00, 0x25, 0x28, 0x44, 0x00,
+0x18, 0x00, 0x6D, 0x00, 0x12, 0x58, 0x00, 0x00, 0x2B, 0x18, 0xAB, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x49, 0x01, 0x02, 0x00, 0x20, 0x15,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00, 0x08, 0x00, 0x60, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x28, 0xAC, 0x00, 0x2B, 0x10, 0xAC, 0x00,
+0x04, 0x00, 0x40, 0x14, 0x2B, 0x10, 0xAB, 0x00, 0x00, 0x00, 0x42, 0x38,
+0x21, 0x18, 0xAC, 0x00, 0x0B, 0x28, 0x62, 0x00, 0x23, 0x28, 0xAB, 0x00,
+0x1B, 0x00, 0xA9, 0x00, 0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0xE4, 0x31, 0x12, 0x18, 0x00, 0x00,
+0x10, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x00, 0x6D, 0x00, 0x00, 0x14, 0x08, 0x00, 0x12, 0x58, 0x00, 0x00,
+0x25, 0x40, 0x44, 0x00, 0x2B, 0x18, 0x0B, 0x01, 0x1B, 0x00, 0xA9, 0x00,
+0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00,
+0x08, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x21, 0x40, 0x0C, 0x01,
+0x2B, 0x10, 0x0C, 0x01, 0x04, 0x00, 0x40, 0x14, 0x2B, 0x10, 0x0B, 0x01,
+0x21, 0x18, 0x0C, 0x01, 0x00, 0x00, 0x42, 0x38, 0x0B, 0x40, 0x62, 0x00,
+0xAB, 0xFF, 0x40, 0x12, 0x23, 0x78, 0x0B, 0x01, 0x06, 0xC0, 0xCF, 0x00,
+0x21, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x58, 0xAE, 0xA1, 0x63, 0x00, 0x08,
+0x04, 0x00, 0x59, 0xAE, 0x1B, 0x00, 0x47, 0x00, 0x02, 0x00, 0xE0, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0x02, 0x34,
+0x12, 0x60, 0x00, 0x00, 0x2B, 0x10, 0x4C, 0x00, 0xAB, 0xFF, 0x40, 0x10,
+0x00, 0x01, 0x83, 0x2D, 0xFF, 0x00, 0x02, 0x3C, 0x10, 0x00, 0x03, 0x24,
+0xFF, 0xFF, 0x42, 0x34, 0x2B, 0x10, 0x4C, 0x00, 0x18, 0x00, 0x04, 0x24,
+0x21, 0x28, 0x60, 0x00, 0x0B, 0x28, 0x82, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x06, 0x10, 0xAC, 0x00, 0x98, 0xF2, 0x63, 0x24, 0x21, 0x10, 0x43, 0x00,
+0x00, 0x00, 0x44, 0x90, 0x20, 0x00, 0x02, 0x24, 0x21, 0x20, 0x85, 0x00,
+0x23, 0x30, 0x44, 0x00, 0xA7, 0xFF, 0xC0, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x23, 0x38, 0x46, 0x00, 0x04, 0x60, 0xCC, 0x00, 0x06, 0x58, 0xEA, 0x00,
+0x02, 0x4C, 0x0C, 0x00, 0x1B, 0x00, 0x69, 0x01, 0x02, 0x00, 0x20, 0x15,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0x8D, 0x31,
+0x06, 0x18, 0xEF, 0x00, 0x04, 0x10, 0xCA, 0x00, 0x25, 0x50, 0x43, 0x00,
+0x02, 0x24, 0x0A, 0x00, 0x12, 0x28, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00,
+0x00, 0x14, 0x08, 0x00, 0x25, 0x40, 0x44, 0x00, 0x18, 0x00, 0xAD, 0x00,
+0x12, 0x28, 0x00, 0x00, 0x2B, 0x18, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,
+0x1B, 0x00, 0x69, 0x01, 0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0x05, 0x00, 0x60, 0x10, 0x04, 0x78, 0xCF, 0x00,
+0x21, 0x40, 0x0C, 0x01, 0x2B, 0x10, 0x0C, 0x01, 0x93, 0x00, 0x40, 0x10,
+0x2B, 0x10, 0x05, 0x01, 0x23, 0x40, 0x05, 0x01, 0x1B, 0x00, 0x09, 0x01,
+0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00,
+0xFF, 0xFF, 0x44, 0x31, 0x12, 0x18, 0x00, 0x00, 0x10, 0x58, 0x00, 0x00,
+0x00, 0x14, 0x0B, 0x00, 0x25, 0x58, 0x44, 0x00, 0x18, 0x00, 0x6D, 0x00,
+0x12, 0x28, 0x00, 0x00, 0x2B, 0x18, 0x65, 0x01, 0x00, 0x00, 0x00, 0x00,
+0x1B, 0x00, 0x09, 0x01, 0x02, 0x00, 0x20, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0x77, 0xFF, 0x60, 0x10, 0x23, 0x50, 0x65, 0x01,
+0x21, 0x58, 0x6C, 0x01, 0x2B, 0x10, 0x6C, 0x01, 0x04, 0x00, 0x40, 0x14,
+0x2B, 0x10, 0x65, 0x01, 0x00, 0x00, 0x42, 0x38, 0x21, 0x18, 0x6C, 0x01,
+0x0B, 0x58, 0x62, 0x00, 0xBF, 0x63, 0x00, 0x08, 0x23, 0x50, 0x65, 0x01,
+0x08, 0x00, 0x02, 0x24, 0x21, 0x28, 0x00, 0x00, 0x0A, 0x28, 0x43, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x06, 0x10, 0xA8, 0x00, 0x98, 0xF2, 0x63, 0x24,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x90, 0x20, 0x00, 0x02, 0x24,
+0x21, 0x20, 0x85, 0x00, 0x23, 0x30, 0x44, 0x00, 0x34, 0xFF, 0xC0, 0x10,
+0x23, 0x38, 0x46, 0x00, 0x06, 0x10, 0xEC, 0x00, 0x04, 0x18, 0xC8, 0x00,
+0x25, 0x40, 0x62, 0x00, 0x06, 0x58, 0xEA, 0x00, 0x02, 0x6C, 0x08, 0x00,
+0x1B, 0x00, 0x6D, 0x01, 0x02, 0x00, 0xA0, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0x11, 0x31, 0x06, 0x10, 0xEF, 0x00,
+0x04, 0x18, 0xCA, 0x00, 0x25, 0x50, 0x62, 0x00, 0x02, 0x24, 0x0A, 0x00,
+0x04, 0x60, 0xCC, 0x00, 0x12, 0x80, 0x00, 0x00, 0x10, 0x48, 0x00, 0x00,
+0x00, 0x14, 0x09, 0x00, 0x25, 0x48, 0x44, 0x00, 0x12, 0x28, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x11, 0x02,
+0x12, 0x70, 0x00, 0x00, 0x2B, 0x18, 0x2E, 0x01, 0x00, 0x00, 0x00, 0x00,
+0x1B, 0x00, 0x6D, 0x01, 0x02, 0x00, 0xA0, 0x15, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x07, 0x00, 0x0A, 0x00, 0x60, 0x10, 0x04, 0x78, 0xCF, 0x00,
+0x21, 0x48, 0x28, 0x01, 0x2B, 0x10, 0x28, 0x01, 0x06, 0x00, 0x40, 0x14,
+0xFF, 0xFF, 0xB0, 0x24, 0x2B, 0x10, 0x2E, 0x01, 0x03, 0x00, 0x40, 0x10,
+0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x10, 0x26, 0x21, 0x48, 0x28, 0x01,
+0x23, 0x48, 0x2E, 0x01, 0x1B, 0x00, 0x2D, 0x01, 0x02, 0x00, 0xA0, 0x15,
+0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00, 0xFF, 0xFF, 0x44, 0x31,
+0x12, 0x28, 0x00, 0x00, 0x10, 0x58, 0x00, 0x00, 0x00, 0x14, 0x0B, 0x00,
+0x25, 0x58, 0x44, 0x00, 0x18, 0x00, 0xB1, 0x00, 0x12, 0x70, 0x00, 0x00,
+0x2B, 0x18, 0x6E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x2D, 0x01,
+0x02, 0x00, 0xA0, 0x15, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x07, 0x00,
+0x0B, 0x00, 0x60, 0x10, 0x00, 0x14, 0x10, 0x00, 0x21, 0x58, 0x68, 0x01,
+0x2B, 0x10, 0x68, 0x01, 0x06, 0x00, 0x40, 0x14, 0xFF, 0xFF, 0xA5, 0x24,
+0x2B, 0x10, 0x6E, 0x01, 0x04, 0x00, 0x40, 0x10, 0x00, 0x14, 0x10, 0x00,
+0xFF, 0xFF, 0xA5, 0x24, 0x21, 0x58, 0x68, 0x01, 0x00, 0x14, 0x10, 0x00,
+0x25, 0x10, 0x45, 0x00, 0x23, 0x58, 0x6E, 0x01, 0x19, 0x00, 0x4C, 0x00,
+0x10, 0x28, 0x00, 0x00, 0x2B, 0x18, 0x65, 0x01, 0x12, 0x48, 0x00, 0x00,
+0x05, 0x00, 0x60, 0x14, 0x23, 0x20, 0x2C, 0x01, 0x07, 0x00, 0xAB, 0x14,
+0x2B, 0x10, 0xE9, 0x01, 0x05, 0x00, 0x40, 0x10, 0x00, 0x00, 0x00, 0x00,
+0x2B, 0x10, 0x24, 0x01, 0x23, 0x18, 0xA8, 0x00, 0x23, 0x28, 0x62, 0x00,
+0x21, 0x48, 0x80, 0x00, 0xEA, 0xFE, 0x40, 0x12, 0x23, 0x18, 0xE9, 0x01,
+0x23, 0x20, 0x65, 0x01, 0x2B, 0x10, 0xE3, 0x01, 0x23, 0x50, 0x82, 0x00,
+0x04, 0x28, 0xEA, 0x00, 0x06, 0x18, 0xC3, 0x00, 0x25, 0xC0, 0xA3, 0x00,
+0x06, 0xC8, 0xCA, 0x00, 0x00, 0x00, 0x58, 0xAE, 0xA1, 0x63, 0x00, 0x08,
+0x04, 0x00, 0x59, 0xAE, 0x00, 0x01, 0xC3, 0x2C, 0x08, 0x00, 0x02, 0x24,
+0x21, 0x30, 0x00, 0x00, 0x3B, 0x63, 0x00, 0x08, 0x0A, 0x30, 0x43, 0x00,
+0x00, 0x00, 0x42, 0x38, 0x21, 0x18, 0x0C, 0x01, 0x35, 0x64, 0x00, 0x08,
+0x0B, 0x40, 0x62, 0x00, 0x25, 0xB0, 0x03, 0x3C, 0x4D, 0x00, 0x64, 0x34,
+0xF1, 0x02, 0x65, 0x34, 0x08, 0x00, 0x02, 0x24, 0x00, 0x00, 0x80, 0xA0,
+0xEC, 0x02, 0x66, 0x34, 0x00, 0x00, 0xA2, 0xA0, 0xF0, 0x02, 0x63, 0x34,
+0xFF, 0x00, 0x02, 0x3C, 0x00, 0x00, 0x60, 0xA0, 0x00, 0x00, 0xC2, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x60, 0x93, 0x63, 0x24, 0x18, 0x03, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x7F, 0x00, 0x02, 0x3C, 0x0D, 0xB8, 0x44, 0x34, 0x80, 0x04, 0x03, 0x3C,
+0x25, 0x20, 0x83, 0x00, 0x00, 0x08, 0x02, 0x3C, 0x25, 0x20, 0x82, 0x00,
+0x00, 0x30, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0x25, 0x20, 0x83, 0x00, 0x41, 0xB0, 0x03, 0x3C, 0x00, 0x00, 0x64, 0xAC,
+0xD8, 0x1B, 0x44, 0xAC, 0xD0, 0x1B, 0x44, 0xAC, 0x08, 0x00, 0x63, 0x34,
+0x86, 0x00, 0x04, 0x24, 0x00, 0x00, 0x64, 0xA4, 0xDC, 0x1B, 0x44, 0xA4,
+0xD4, 0x1B, 0x40, 0xAC, 0xDE, 0x1B, 0x40, 0xA4, 0x08, 0x00, 0xE0, 0x03,
+0xE0, 0x1B, 0x44, 0xA4, 0xF5, 0x64, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x42, 0xB0, 0x03, 0x3C, 0x01, 0x00, 0x63, 0x34, 0x02, 0x00, 0x02, 0x24,
+0xE8, 0xFF, 0xBD, 0x27, 0x00, 0x00, 0x62, 0xA0, 0x10, 0x00, 0xBF, 0xAF,
+0x85, 0x2B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x21, 0x20, 0x00, 0x00,
+0x01, 0x00, 0x05, 0x24, 0xB9, 0x20, 0x00, 0x0C, 0x00, 0x50, 0x06, 0x24,
+0x1F, 0x00, 0x06, 0x3C, 0x10, 0x00, 0xBF, 0x8F, 0x00, 0x40, 0xC6, 0x34,
+0x03, 0x00, 0x04, 0x24, 0x01, 0x00, 0x05, 0x24, 0xB9, 0x20, 0x00, 0x08,
+0x18, 0x00, 0xBD, 0x27, 0x25, 0xB0, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xC8, 0xFF, 0xBD, 0x27, 0x18, 0x03, 0x64, 0x34, 0x28, 0x94, 0x42, 0x24,
+0x00, 0x00, 0x82, 0xAC, 0x30, 0x00, 0xBE, 0xAF, 0x2C, 0x00, 0xB7, 0xAF,
+0x28, 0x00, 0xB6, 0xAF, 0x24, 0x00, 0xB5, 0xAF, 0x20, 0x00, 0xB4, 0xAF,
+0x1C, 0x00, 0xB3, 0xAF, 0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF,
+0x34, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF, 0xB6, 0x00, 0x63, 0x34,
+0x00, 0x00, 0x64, 0x90, 0x02, 0x80, 0x03, 0x3C, 0x60, 0x1B, 0x62, 0x24,
+0x48, 0x01, 0x03, 0x24, 0x70, 0x37, 0x43, 0xAC, 0x6C, 0x37, 0x43, 0xAC,
+0xAB, 0x1B, 0x44, 0xA0, 0xC6, 0x3D, 0x40, 0xA0, 0x66, 0x37, 0x40, 0xA0,
+0x84, 0x6C, 0x00, 0x0C, 0x21, 0x98, 0x40, 0x00, 0xFD, 0xFF, 0x02, 0x3C,
+0xFB, 0xFF, 0x03, 0x3C, 0x21, 0xA0, 0x60, 0x02, 0xFF, 0xFF, 0x55, 0x34,
+0xFF, 0xFF, 0x76, 0x34, 0x21, 0x88, 0x00, 0x00, 0x02, 0x80, 0x1E, 0x3C,
+0x02, 0x80, 0x17, 0x3C, 0x21, 0x90, 0x60, 0x02, 0x40, 0x10, 0x11, 0x00,
+0x21, 0x10, 0x51, 0x00, 0x00, 0x11, 0x02, 0x00, 0x21, 0x10, 0x53, 0x00,
+0xD4, 0x1D, 0x42, 0x24, 0x07, 0x00, 0x03, 0x24, 0xFF, 0xFF, 0x63, 0x24,
+0x00, 0x00, 0x40, 0xA4, 0xFD, 0xFF, 0x61, 0x04, 0x02, 0x00, 0x42, 0x24,
+0xC0, 0x80, 0x11, 0x00, 0x34, 0x3F, 0xC4, 0x27, 0x21, 0x20, 0x04, 0x02,
+0x21, 0x28, 0x00, 0x00, 0x02, 0x00, 0x06, 0x24, 0xE4, 0x1D, 0x40, 0xA6,
+0xEC, 0x54, 0x00, 0x0C, 0xE6, 0x1D, 0x40, 0xA2, 0x21, 0x20, 0x13, 0x02,
+0xD4, 0x23, 0x83, 0x8C, 0xD2, 0x5C, 0xE7, 0x92, 0xBF, 0xFF, 0x02, 0x24,
+0x24, 0x28, 0x62, 0x00, 0x01, 0x00, 0x02, 0x24, 0x63, 0x00, 0xE2, 0x10,
+0x80, 0x07, 0xA6, 0x34, 0xFF, 0xF7, 0x03, 0x24, 0x24, 0x10, 0xC3, 0x00,
+0xFF, 0xEF, 0x03, 0x24, 0x24, 0x10, 0x43, 0x00, 0xD4, 0x23, 0x82, 0xAC,
+0x21, 0x30, 0x14, 0x02, 0xD4, 0x23, 0xC4, 0x8C, 0xE7, 0xFF, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x24, 0x20, 0x95, 0x00, 0x24, 0x20, 0x96, 0x00,
+0xFF, 0xFD, 0x03, 0x3C, 0x24, 0x20, 0x82, 0x00, 0xFF, 0xFF, 0x63, 0x34,
+0xFF, 0xFB, 0x02, 0x3C, 0x24, 0x20, 0x83, 0x00, 0xD8, 0x23, 0xC5, 0x8C,
+0xFF, 0xFF, 0x42, 0x34, 0xFF, 0xE7, 0x03, 0x3C, 0x24, 0x20, 0x82, 0x00,
+0xFF, 0xFF, 0x63, 0x34, 0xFF, 0xFF, 0x02, 0x3C, 0x24, 0x20, 0x83, 0x00,
+0xFF, 0x7F, 0x42, 0x34, 0xC0, 0xFF, 0x03, 0x24, 0x24, 0x28, 0xA2, 0x00,
+0x24, 0x20, 0x83, 0x00, 0x1F, 0x00, 0x02, 0x3C, 0x01, 0x00, 0x31, 0x26,
+0x25, 0x28, 0xA2, 0x00, 0x08, 0x00, 0x84, 0x34, 0x20, 0x00, 0x22, 0x2A,
+0xD4, 0x23, 0xC4, 0xAC, 0xD8, 0x23, 0xC5, 0xAC, 0xC3, 0xFF, 0x40, 0x14,
+0x30, 0x00, 0x52, 0x26, 0x25, 0xB0, 0x02, 0x3C, 0x10, 0x00, 0x03, 0x24,
+0xB0, 0x03, 0x42, 0x34, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x43, 0xAC,
+0x88, 0x1E, 0x84, 0x24, 0x21, 0x28, 0x00, 0x00, 0xEC, 0x54, 0x00, 0x0C,
+0x20, 0x00, 0x06, 0x24, 0x02, 0x80, 0x02, 0x3C, 0xD1, 0x5C, 0x43, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x3A, 0x00, 0x60, 0x10, 0x02, 0x80, 0x03, 0x3C,
+0x60, 0x1B, 0x62, 0x24, 0x25, 0x03, 0x40, 0xA0, 0xC2, 0x6F, 0x00, 0x74,
+0x24, 0x03, 0x40, 0xA0, 0xD8, 0x70, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x47, 0x6C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0xBF, 0x8F,
+0x30, 0x00, 0xBE, 0x8F, 0x2C, 0x00, 0xB7, 0x8F, 0x28, 0x00, 0xB6, 0x8F,
+0x24, 0x00, 0xB5, 0x8F, 0x20, 0x00, 0xB4, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x02, 0x80, 0x09, 0x3C, 0x02, 0x80, 0x0A, 0x3C, 0x02, 0x80, 0x0B, 0x3C,
+0x02, 0x80, 0x0C, 0x3C, 0x02, 0x80, 0x0D, 0x3C, 0x02, 0x80, 0x0E, 0x3C,
+0x02, 0x80, 0x0F, 0x3C, 0x88, 0x54, 0x22, 0x25, 0x90, 0x54, 0x43, 0x25,
+0x98, 0x54, 0x64, 0x25, 0xA0, 0x54, 0x85, 0x25, 0xA8, 0x54, 0xA6, 0x25,
+0xB0, 0x54, 0xC7, 0x25, 0xB8, 0x54, 0xE8, 0x25, 0x38, 0x00, 0xBD, 0x27,
+0x04, 0x00, 0x42, 0xAC, 0x88, 0x54, 0x22, 0xAD, 0x04, 0x00, 0x63, 0xAC,
+0x90, 0x54, 0x43, 0xAD, 0x04, 0x00, 0x84, 0xAC, 0x98, 0x54, 0x64, 0xAD,
+0x04, 0x00, 0xA5, 0xAC, 0xA0, 0x54, 0x85, 0xAD, 0x04, 0x00, 0xC6, 0xAC,
+0xA8, 0x54, 0xA6, 0xAD, 0x04, 0x00, 0xE7, 0xAC, 0xB0, 0x54, 0xC7, 0xAD,
+0xB8, 0x54, 0xE8, 0xAD, 0x08, 0x00, 0xE0, 0x03, 0x04, 0x00, 0x08, 0xAD,
+0x02, 0x80, 0x02, 0x3C, 0xD3, 0x5C, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x9C, 0xFF, 0x67, 0x14, 0x80, 0x0F, 0xA2, 0x34, 0xFF, 0xF7, 0x03, 0x24,
+0x24, 0x10, 0xC3, 0x00, 0x4D, 0x65, 0x00, 0x08, 0x00, 0x10, 0x42, 0x34,
+0x7A, 0x6D, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0xAD, 0x6F, 0x00, 0x74,
+0x24, 0x39, 0x80, 0xAE, 0x26, 0x70, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0xC6, 0x5C, 0x64, 0x90, 0x92, 0x00, 0x02, 0x24,
+0x03, 0x00, 0x82, 0x10, 0x00, 0x00, 0x00, 0x00, 0x60, 0x70, 0x00, 0x74,
+0x00, 0x00, 0x00, 0x00, 0xC1, 0x70, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00,
+0x7B, 0x65, 0x00, 0x08, 0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0xC8, 0xFF, 0xBD, 0x27, 0x14, 0x97, 0x63, 0x24,
+0x18, 0x03, 0x42, 0x34, 0x18, 0x00, 0xB0, 0xAF, 0x34, 0x00, 0xBF, 0xAF,
+0x30, 0x00, 0xB6, 0xAF, 0x2C, 0x00, 0xB5, 0xAF, 0x28, 0x00, 0xB4, 0xAF,
+0x24, 0x00, 0xB3, 0xAF, 0x20, 0x00, 0xB2, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x00, 0x00, 0x43, 0xAC, 0x21, 0x80, 0x00, 0x00, 0x01, 0x00, 0x02, 0x26,
+0xFF, 0xFF, 0x50, 0x30, 0x64, 0x00, 0x03, 0x2E, 0xFD, 0xFF, 0x60, 0x14,
+0x01, 0x00, 0x02, 0x26, 0x64, 0x40, 0x00, 0x0C, 0x02, 0x80, 0x14, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xC3, 0x5C, 0x68, 0x90, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xC0, 0x5C, 0x4B, 0x94, 0xDB, 0x5C, 0x6A, 0x90,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0xE2, 0x5C, 0x67, 0x90,
+0xD0, 0x5C, 0x49, 0x90, 0xC2, 0x5C, 0x83, 0x92, 0x02, 0x80, 0x0C, 0x3C,
+0x02, 0x80, 0x02, 0x3C, 0xDD, 0x5C, 0x46, 0x90, 0xE0, 0x5C, 0x85, 0x91,
+0x25, 0xB0, 0x04, 0x3C, 0xB0, 0x03, 0x82, 0x34, 0x00, 0x00, 0x4B, 0xAC,
+0x00, 0x00, 0x48, 0xAC, 0x00, 0x00, 0x49, 0xAC, 0x00, 0x00, 0x43, 0xAC,
+0x02, 0x80, 0x03, 0x3C, 0x00, 0x00, 0x4A, 0xAC, 0x0A, 0x00, 0x88, 0x34,
+0x00, 0x00, 0x46, 0xAC, 0x00, 0x00, 0x45, 0xAC, 0x00, 0x00, 0x47, 0xAC,
+0x0C, 0x5D, 0x60, 0xA4, 0x00, 0x00, 0x06, 0x91, 0x02, 0x80, 0x02, 0x3C,
+0x0B, 0x00, 0x04, 0x24, 0x02, 0x80, 0x13, 0x3C, 0xCD, 0x5C, 0x44, 0xA0,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x65, 0x26, 0x00, 0x70, 0x03, 0x24,
+0xF0, 0x5C, 0x40, 0xA0, 0xF0, 0xFF, 0x02, 0x24, 0x01, 0x00, 0x07, 0x24,
+0x02, 0x80, 0x16, 0x3C, 0xAC, 0x1B, 0xA3, 0xA4, 0xAA, 0x1B, 0xA2, 0xA0,
+0xFF, 0x07, 0x03, 0x24, 0xFF, 0xFF, 0x02, 0x24, 0x20, 0x00, 0xC6, 0x30,
+0xE0, 0x5C, 0x87, 0xA1, 0xA8, 0x1B, 0xA7, 0xA0, 0xAE, 0x1B, 0xA3, 0xA4,
+0x48, 0xF5, 0xC2, 0xA2, 0x9A, 0x00, 0xC0, 0x10, 0xB0, 0x1B, 0xA0, 0xA4,
+0x00, 0x00, 0x02, 0x91, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x42, 0x30,
+0x0B, 0x01, 0x40, 0x14, 0x02, 0x80, 0x15, 0x3C, 0x21, 0x80, 0x00, 0x00,
+0x21, 0x88, 0x00, 0x00, 0x98, 0xF3, 0xB2, 0x26, 0xFF, 0x00, 0x24, 0x32,
+0xCF, 0x59, 0x00, 0x0C, 0x21, 0x28, 0x12, 0x02, 0x08, 0x00, 0x03, 0x26,
+0xFF, 0xFF, 0x70, 0x30, 0x01, 0x00, 0x22, 0x26, 0x80, 0x00, 0x03, 0x2E,
+0xF8, 0xFF, 0x60, 0x14, 0xFF, 0xFF, 0x51, 0x30, 0xC2, 0x5C, 0x83, 0x92,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x62, 0x30, 0xCA, 0x00, 0x40, 0x14,
+0x04, 0x00, 0x62, 0x30, 0x83, 0x00, 0x40, 0x10, 0x25, 0xB0, 0x03, 0x3C,
+0x25, 0xB0, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0x50, 0x00, 0x84, 0x34,
+0xE7, 0xF3, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24,
+0x98, 0xF3, 0xA3, 0x26, 0x7B, 0x00, 0x67, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0xE2, 0x2C, 0x04, 0x00, 0x40, 0x14, 0x02, 0x00, 0x0B, 0x24,
+0x79, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x4B, 0x30,
+0x04, 0x00, 0xE2, 0x2C, 0xEC, 0x00, 0x40, 0x10, 0x98, 0xF3, 0xA2, 0x26,
+0x60, 0x1B, 0x62, 0x8E, 0xBF, 0xFF, 0x03, 0x24, 0x02, 0x80, 0x12, 0x3C,
+0x24, 0x10, 0x43, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x4A, 0xF5, 0x60, 0xA0,
+0x60, 0x1B, 0x62, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0xCF, 0x5C, 0x43, 0x90,
+0x01, 0x00, 0x02, 0x24, 0x02, 0x00, 0x62, 0x10, 0xFC, 0xFF, 0x08, 0x24,
+0x21, 0x40, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x98, 0xF3, 0x4A, 0x24, 0x60, 0x1B, 0x69, 0x24, 0x21, 0x60, 0x00, 0x00,
+0x21, 0x80, 0x00, 0x00, 0x01, 0x00, 0x02, 0x26, 0x21, 0x30, 0x30, 0x01,
+0x03, 0x00, 0x03, 0x2E, 0x08, 0x00, 0x04, 0x2E, 0xFF, 0xFF, 0x50, 0x30,
+0x0E, 0x00, 0x07, 0x2E, 0x04, 0x00, 0x60, 0x14, 0x21, 0x88, 0x00, 0x00,
+0x01, 0x00, 0x11, 0x24, 0x02, 0x00, 0x02, 0x24, 0x0A, 0x88, 0x44, 0x00,
+0x21, 0x10, 0x51, 0x01, 0x61, 0x00, 0x43, 0x90, 0x55, 0x00, 0x44, 0x90,
+0x5B, 0x00, 0x45, 0x90, 0x21, 0x18, 0x03, 0x01, 0x21, 0x20, 0x04, 0x01,
+0x21, 0x28, 0x05, 0x01, 0x9C, 0x1D, 0xC3, 0xA0, 0x64, 0x1D, 0xC4, 0xA0,
+0xEB, 0xFF, 0xE0, 0x14, 0x80, 0x1D, 0xC5, 0xA0, 0x01, 0x00, 0x8C, 0x25,
+0x02, 0x00, 0x82, 0x2D, 0x0E, 0x00, 0x29, 0x25, 0xE5, 0xFF, 0x40, 0x14,
+0x03, 0x00, 0x4A, 0x25, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x60, 0x1B, 0x47, 0x24, 0x98, 0xF3, 0x66, 0x24, 0x21, 0x80, 0x00, 0x00,
+0x03, 0x00, 0x02, 0x2E, 0x21, 0x20, 0x07, 0x02, 0xD1, 0x00, 0x40, 0x10,
+0x08, 0x00, 0x03, 0x2E, 0x71, 0x00, 0xC3, 0x90, 0x6E, 0x00, 0xC2, 0x90,
+0x00, 0x00, 0x00, 0x00, 0xC6, 0x1D, 0x82, 0xA0, 0xB8, 0x1D, 0x83, 0xA0,
+0x01, 0x00, 0x02, 0x26, 0xFF, 0xFF, 0x50, 0x30, 0x0E, 0x00, 0x03, 0x2E,
+0xF4, 0xFF, 0x60, 0x14, 0x03, 0x00, 0x02, 0x2E, 0x03, 0x00, 0x02, 0x24,
+0x51, 0x00, 0x62, 0x15, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x98, 0xF3, 0x4E, 0x24, 0xC0, 0xD9, 0x6F, 0x24, 0x21, 0x60, 0x00, 0x00,
+0x21, 0x68, 0x00, 0x00, 0x21, 0x10, 0xAE, 0x01, 0x74, 0x00, 0x43, 0x90,
+0x21, 0x80, 0x00, 0x00, 0x0F, 0x00, 0x6A, 0x30, 0x02, 0x49, 0x03, 0x00,
+0x21, 0x10, 0xB0, 0x01, 0x00, 0x11, 0x02, 0x00, 0x21, 0x58, 0x4F, 0x00,
+0x21, 0x38, 0x00, 0x00, 0x21, 0x40, 0x67, 0x01, 0x00, 0x00, 0x03, 0x91,
+0x00, 0x31, 0x09, 0x00, 0x01, 0x00, 0xE7, 0x24, 0x02, 0x11, 0x03, 0x00,
+0x00, 0x21, 0x02, 0x00, 0x0F, 0x00, 0x63, 0x30, 0x2B, 0x10, 0x49, 0x00,
+0x0A, 0x20, 0xC2, 0x00, 0x2B, 0x28, 0x6A, 0x00, 0x00, 0x00, 0xA5, 0x38,
+0x25, 0x18, 0x83, 0x00, 0xFF, 0xFF, 0xE7, 0x30, 0x25, 0x20, 0x8A, 0x00,
+0x0A, 0x18, 0x85, 0x00, 0x10, 0x00, 0xE2, 0x2C, 0xEF, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x03, 0xA1, 0x01, 0x00, 0x02, 0x26, 0xFF, 0xFF, 0x50, 0x30,
+0x03, 0x00, 0x03, 0x2E, 0xE7, 0xFF, 0x60, 0x14, 0x21, 0x10, 0xB0, 0x01,
+0x01, 0x00, 0x8C, 0x25, 0x02, 0x00, 0x82, 0x2D, 0xDD, 0xFF, 0x40, 0x14,
+0x03, 0x00, 0xAD, 0x25, 0xCC, 0x66, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x03, 0x3C, 0x4C, 0x87, 0x02, 0x3C, 0x54, 0x00, 0x65, 0x34,
+0x00, 0xE0, 0x42, 0x34, 0x50, 0x00, 0x63, 0x34, 0x00, 0x00, 0x62, 0xAC,
+0x12, 0x01, 0x04, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x00, 0x00, 0xA4, 0xAC,
+0x60, 0x1B, 0x46, 0x24, 0x21, 0x60, 0x00, 0x00, 0x10, 0x00, 0x05, 0x24,
+0x21, 0x80, 0x00, 0x00, 0x01, 0x00, 0x02, 0x26, 0x21, 0x18, 0xD0, 0x00,
+0xFF, 0xFF, 0x50, 0x30, 0x0E, 0x00, 0x04, 0x2E, 0x80, 0x1D, 0x65, 0xA0,
+0x64, 0x1D, 0x65, 0xA0, 0xF9, 0xFF, 0x80, 0x14, 0x9C, 0x1D, 0x65, 0xA0,
+0x01, 0x00, 0x8C, 0x25, 0x02, 0x00, 0x82, 0x2D, 0xF4, 0xFF, 0x40, 0x14,
+0x0E, 0x00, 0xC6, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x46, 0x24,
+0x21, 0x80, 0x00, 0x00, 0x04, 0x00, 0x05, 0x24, 0x01, 0x00, 0x02, 0x26,
+0x21, 0x18, 0x06, 0x02, 0xFF, 0xFF, 0x50, 0x30, 0x0E, 0x00, 0x04, 0x2E,
+0xC6, 0x1D, 0x60, 0xA0, 0xFA, 0xFF, 0x80, 0x14, 0xB8, 0x1D, 0x65, 0xA0,
+0x02, 0x80, 0x12, 0x3C, 0xC6, 0x5C, 0x43, 0x92, 0x01, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x54, 0x59, 0x00, 0x0C, 0x4B, 0xF5, 0x43, 0xA0,
+0x48, 0xF5, 0xC5, 0x26, 0xFF, 0x58, 0x00, 0x0C, 0xFA, 0x01, 0x04, 0x24,
+0x54, 0x59, 0x00, 0x0C, 0x21, 0x20, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x25, 0xB0, 0x05, 0x3C, 0x48, 0x37, 0x84, 0x24, 0x50, 0x00, 0xA5, 0x34,
+0xF4, 0x54, 0x00, 0x0C, 0x06, 0x00, 0x06, 0x24, 0x60, 0x1B, 0x65, 0x26,
+0x01, 0x00, 0x02, 0x24, 0x06, 0x00, 0x03, 0x24, 0x05, 0x00, 0x04, 0x24,
+0x33, 0x1C, 0xA2, 0xA0, 0x6F, 0x58, 0x00, 0x0C, 0xC4, 0x3D, 0xA3, 0xA0,
+0x34, 0x00, 0xBF, 0x8F, 0x30, 0x00, 0xB6, 0x8F, 0x2C, 0x00, 0xB5, 0x8F,
+0x28, 0x00, 0xB4, 0x8F, 0x24, 0x00, 0xB3, 0x8F, 0x20, 0x00, 0xB2, 0x8F,
+0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x38, 0x00, 0xBD, 0x27, 0x25, 0xB0, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x50, 0x00, 0x84, 0x34, 0xAA, 0xF3, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C,
+0x06, 0x00, 0x06, 0x24, 0x98, 0xF3, 0xA2, 0x92, 0x98, 0xF3, 0xA5, 0x26,
+0x01, 0x00, 0xA4, 0x90, 0x21, 0x18, 0x40, 0x00, 0x10, 0x00, 0xA2, 0xA3,
+0x29, 0x00, 0x02, 0x24, 0x11, 0x00, 0xA4, 0xA3, 0x50, 0x00, 0xA7, 0x90,
+0x4F, 0x00, 0x62, 0x10, 0x02, 0x80, 0x12, 0x3C, 0x98, 0xF3, 0xA6, 0x26,
+0x68, 0x00, 0xC2, 0x90, 0x02, 0x80, 0x03, 0x3C, 0x04, 0x00, 0xE4, 0x2C,
+0x1F, 0x00, 0x42, 0x30, 0x34, 0x00, 0x80, 0x14, 0x49, 0xF5, 0x62, 0xA0,
+0x7A, 0x00, 0xC4, 0x90, 0x60, 0x1B, 0x65, 0x8E, 0x79, 0x00, 0xC6, 0x90,
+0x01, 0x00, 0x83, 0x30, 0xBF, 0xFF, 0x02, 0x24, 0x24, 0x28, 0xA2, 0x00,
+0x80, 0x19, 0x03, 0x00, 0x04, 0x00, 0x84, 0x30, 0x25, 0x28, 0xA3, 0x00,
+0x83, 0x20, 0x04, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x03, 0x00, 0xCB, 0x30,
+0x4A, 0xF5, 0x44, 0xA0, 0x60, 0x1B, 0x65, 0xAE, 0x06, 0x00, 0xE2, 0x2C,
+0x2C, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x98, 0xF3, 0xA3, 0x26,
+0x69, 0x00, 0x62, 0x90, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x30,
+0x26, 0xFF, 0x40, 0x14, 0x02, 0x80, 0x02, 0x3C, 0x45, 0x66, 0x00, 0x08,
+0x21, 0x40, 0x00, 0x00, 0x21, 0x20, 0x00, 0x00, 0x80, 0x00, 0x05, 0x24,
+0xC1, 0x58, 0x00, 0x0C, 0x98, 0xF3, 0xA6, 0x26, 0x1F, 0x66, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x7A, 0x00, 0x43, 0x90, 0x69, 0x00, 0x46, 0x90,
+0x7D, 0x00, 0x44, 0x90, 0x60, 0x1B, 0x65, 0x8E, 0xBF, 0xFF, 0x02, 0x24,
+0x01, 0x00, 0x63, 0x30, 0x24, 0x28, 0xA2, 0x00, 0x01, 0x00, 0xC6, 0x30,
+0x04, 0x00, 0x84, 0x30, 0x80, 0x19, 0x03, 0x00, 0x25, 0x28, 0xA3, 0x00,
+0x83, 0x20, 0x04, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x01, 0x00, 0xC6, 0x2C,
+0x4A, 0xF5, 0x44, 0xA0, 0x60, 0x1B, 0x65, 0xAE, 0x0B, 0xFF, 0xC0, 0x10,
+0x02, 0x80, 0x12, 0x3C, 0x45, 0x66, 0x00, 0x08, 0x21, 0x40, 0x00, 0x00,
+0x60, 0x1B, 0x62, 0x8E, 0xBF, 0xFF, 0x03, 0x24, 0x02, 0x80, 0x04, 0x3C,
+0x24, 0x10, 0x43, 0x00, 0x02, 0x00, 0x0B, 0x24, 0x4A, 0xF5, 0x80, 0xA0,
+0x12, 0x67, 0x00, 0x08, 0x60, 0x1B, 0x62, 0xAE, 0x21, 0x28, 0x07, 0x02,
+0x06, 0x00, 0x60, 0x10, 0x21, 0x20, 0xA0, 0x00, 0x67, 0x00, 0xC3, 0x90,
+0x6F, 0x00, 0xC2, 0x90, 0xB8, 0x1D, 0xA3, 0xA0, 0x74, 0x66, 0x00, 0x08,
+0xC6, 0x1D, 0xA2, 0xA0, 0x72, 0x00, 0xC3, 0x90, 0x70, 0x00, 0xC2, 0x90,
+0x73, 0x66, 0x00, 0x08, 0xC6, 0x1D, 0x82, 0xA0, 0xFF, 0x00, 0x83, 0x30,
+0x81, 0x00, 0x02, 0x24, 0xB0, 0xFF, 0x62, 0x14, 0x98, 0xF3, 0xA6, 0x26,
+0x54, 0x00, 0xA3, 0x90, 0x01, 0x00, 0x02, 0x24, 0x09, 0x00, 0x62, 0x10,
+0x02, 0x00, 0x02, 0x24, 0x04, 0x00, 0x62, 0x10, 0x11, 0x00, 0x02, 0x24,
+0x02, 0x80, 0x12, 0x3C, 0xFE, 0x66, 0x00, 0x08, 0xC6, 0x5C, 0x42, 0xA2,
+0x22, 0x00, 0x02, 0x24, 0xFD, 0x66, 0x00, 0x08, 0xC6, 0x5C, 0x42, 0xA2,
+0x02, 0x80, 0x12, 0x3C, 0x12, 0x00, 0x02, 0x24, 0xFD, 0x66, 0x00, 0x08,
+0xC6, 0x5C, 0x42, 0xA2, 0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB1, 0xAF,
+0x02, 0x80, 0x02, 0x3C, 0x25, 0xB0, 0x11, 0x3C, 0x18, 0x03, 0x23, 0x36,
+0x7C, 0x9D, 0x42, 0x24, 0x20, 0x00, 0xB2, 0xAF, 0x02, 0x80, 0x12, 0x3C,
+0x00, 0x00, 0x62, 0xAC, 0x18, 0x00, 0xB0, 0xAF, 0x24, 0x00, 0xBF, 0xAF,
+0xC5, 0x65, 0x00, 0x0C, 0x60, 0x1B, 0x50, 0x26, 0x08, 0x68, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xA3, 0x6A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x87, 0x6B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xEA, 0x6D, 0x00, 0x74,
+0x00, 0x00, 0x00, 0x00, 0xEF, 0x6A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xC4, 0x3D, 0x04, 0x92, 0x38, 0x0D, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0xC4, 0x3D, 0x04, 0x92, 0x75, 0x0D, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0xCB, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x82, 0x40, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x23, 0x36, 0x00, 0x00, 0x62, 0x94,
+0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x42, 0x34, 0x00, 0x00, 0x62, 0xA4,
+0x0A, 0x65, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x64, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0xF7, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x53, 0x6B, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x10, 0x6B, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x3C, 0x68, 0x61, 0x84, 0x24,
+0x70, 0x6B, 0x00, 0x0C, 0x01, 0x00, 0x05, 0x24, 0x00, 0x80, 0x04, 0x3C,
+0xD0, 0x67, 0x84, 0x24, 0x70, 0x6B, 0x00, 0x0C, 0x02, 0x00, 0x05, 0x24,
+0x00, 0x80, 0x04, 0x3C, 0x39, 0x6F, 0x84, 0x24, 0x70, 0x6B, 0x00, 0x0C,
+0x04, 0x00, 0x05, 0x24, 0x44, 0x5C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x01, 0x80, 0x04, 0x3C, 0x6C, 0x83, 0x84, 0x24, 0x70, 0x6B, 0x00, 0x0C,
+0x03, 0x00, 0x05, 0x24, 0x02, 0x80, 0x03, 0x3C, 0xD0, 0x5C, 0x63, 0x90,
+0x00, 0x00, 0x00, 0x00, 0x5F, 0x00, 0x60, 0x10, 0x43, 0x00, 0x22, 0x36,
+0x07, 0x00, 0x02, 0x24, 0x0C, 0x00, 0x62, 0x10, 0x03, 0x00, 0x02, 0x24,
+0x25, 0xB0, 0x04, 0x3C, 0x43, 0x00, 0x85, 0x34, 0x10, 0x02, 0x86, 0x34,
+0x10, 0x00, 0x03, 0x24, 0x00, 0x00, 0xA2, 0xA0, 0xD8, 0x00, 0x84, 0x34,
+0x00, 0x00, 0xC3, 0xA0, 0x00, 0x00, 0x82, 0x90, 0x80, 0xFF, 0x03, 0x24,
+0x25, 0x10, 0x43, 0x00, 0x00, 0x00, 0x82, 0xA0, 0xDF, 0x64, 0x00, 0x0C,
+0x25, 0xB0, 0x10, 0x3C, 0x44, 0x00, 0x03, 0x36, 0x00, 0x00, 0x62, 0x94,
+0x02, 0x80, 0x04, 0x3C, 0x18, 0xE5, 0x84, 0x24, 0xC0, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x62, 0xA4, 0x13, 0x58, 0x00, 0x0C, 0xF2, 0x00, 0x05, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0xC3, 0x5C, 0x45, 0x90, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0x5C, 0xE5, 0x84, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xC2, 0x5C, 0x45, 0x90, 0xC7, 0x5C, 0x66, 0x90,
+0x02, 0x80, 0x04, 0x3C, 0x13, 0x58, 0x00, 0x0C, 0x6C, 0xE5, 0x84, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0xC6, 0x5C, 0x45, 0x90,
+0x48, 0xF5, 0x66, 0x90, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0xCF, 0x5C, 0x47, 0x90, 0x4A, 0xF5, 0x62, 0x90, 0x02, 0x80, 0x04, 0x3C,
+0x80, 0xE5, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C, 0x10, 0x00, 0xA2, 0xAF,
+0xFA, 0x5B, 0x00, 0x0C, 0x80, 0x0C, 0x04, 0x36, 0x02, 0x80, 0x03, 0x3C,
+0x02, 0x80, 0x04, 0x3C, 0xD1, 0x5C, 0x65, 0x90, 0xCE, 0x5C, 0x86, 0x90,
+0x02, 0x80, 0x04, 0x3C, 0x21, 0x38, 0x40, 0x00, 0x13, 0x58, 0x00, 0x0C,
+0x9C, 0xE5, 0x84, 0x24, 0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xD3, 0x5C, 0x66, 0x90, 0xD2, 0x5C, 0x45, 0x90, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xB8, 0xE5, 0x84, 0x24, 0x60, 0x1B, 0x42, 0x26,
+0x54, 0x41, 0x46, 0x8C, 0x58, 0x41, 0x45, 0x8C, 0x02, 0x80, 0x04, 0x3C,
+0x13, 0x58, 0x00, 0x0C, 0xCC, 0xE5, 0x84, 0x24, 0x60, 0x1B, 0x46, 0x8E,
+0x02, 0x80, 0x02, 0x3C, 0x49, 0xF5, 0x45, 0x90, 0x82, 0x31, 0x06, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0xEC, 0xE5, 0x84, 0x24, 0x13, 0x58, 0x00, 0x0C,
+0x01, 0x00, 0xC6, 0x30, 0x02, 0x80, 0x04, 0x3C, 0x08, 0x00, 0x84, 0x24,
+0x21, 0x28, 0x00, 0x00, 0x21, 0x30, 0x00, 0x00, 0x76, 0x39, 0x00, 0x0C,
+0x21, 0x38, 0x00, 0x00, 0xF5, 0x64, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x24, 0x00, 0xBF, 0x8F, 0x20, 0x00, 0xB2, 0x8F, 0x1C, 0x00, 0xB1, 0x8F,
+0x18, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0xD8, 0x00, 0x24, 0x36, 0x00, 0x00, 0x40, 0xA0,
+0xB0, 0x67, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0xB8, 0xFF, 0xBD, 0x27,
+0x24, 0x00, 0xB1, 0xAF, 0x44, 0x00, 0xBF, 0xAF, 0x40, 0x00, 0xBE, 0xAF,
+0x3C, 0x00, 0xB7, 0xAF, 0x38, 0x00, 0xB6, 0xAF, 0x34, 0x00, 0xB5, 0xAF,
+0x30, 0x00, 0xB4, 0xAF, 0x2C, 0x00, 0xB3, 0xAF, 0x28, 0x00, 0xB2, 0xAF,
+0x20, 0x00, 0xB0, 0xAF, 0x02, 0x80, 0x02, 0x3C, 0xC2, 0x5C, 0x42, 0x90,
+0x25, 0xB0, 0x11, 0x3C, 0x58, 0x00, 0x25, 0x36, 0x10, 0x00, 0xA2, 0xAF,
+0x4C, 0x81, 0x02, 0x3C, 0x00, 0xE0, 0x42, 0x34, 0x00, 0x00, 0xA2, 0xAC,
+0xFF, 0xFF, 0x04, 0x24, 0x96, 0x01, 0x03, 0x24, 0x28, 0x28, 0x02, 0x24,
+0x5C, 0x00, 0x26, 0x36, 0x60, 0x00, 0x27, 0x36, 0x64, 0x00, 0x28, 0x36,
+0x8A, 0x00, 0x29, 0x36, 0x00, 0x00, 0xC3, 0xAC, 0x00, 0x00, 0xE4, 0xAC,
+0x00, 0x00, 0x04, 0xAD, 0x00, 0x00, 0x22, 0xA5, 0x0E, 0x0E, 0x02, 0x3C,
+0x09, 0x00, 0x03, 0x24, 0x0A, 0x0A, 0x42, 0x34, 0x89, 0x00, 0x2A, 0x36,
+0x8C, 0x00, 0x2B, 0x36, 0x00, 0x00, 0x43, 0xA1, 0x90, 0x00, 0x2C, 0x36,
+0x00, 0x00, 0x62, 0xAD, 0x13, 0x00, 0x03, 0x24, 0x40, 0x00, 0x02, 0x24,
+0x91, 0x00, 0x2D, 0x36, 0x00, 0x00, 0x83, 0xA1, 0x92, 0x00, 0x2E, 0x36,
+0x00, 0x00, 0xA2, 0xA1, 0x3A, 0x01, 0x03, 0x24, 0x21, 0x00, 0x02, 0x24,
+0xB5, 0x00, 0x2F, 0x36, 0x00, 0x00, 0xC3, 0xA5, 0x00, 0x00, 0xE2, 0xA1,
+0x10, 0x00, 0xA2, 0x8F, 0x12, 0x00, 0x03, 0x24, 0x87, 0x01, 0x43, 0x10,
+0x07, 0x07, 0x02, 0x3C, 0x07, 0x07, 0x42, 0x34, 0xA0, 0x00, 0x24, 0x36,
+0x00, 0x00, 0x82, 0xAC, 0xA4, 0x00, 0x25, 0x36, 0x00, 0x07, 0x03, 0x24,
+0x00, 0xC0, 0x02, 0x3C, 0xA8, 0x00, 0x26, 0x36, 0x00, 0x00, 0xA3, 0xAC,
+0x00, 0xC4, 0x42, 0x34, 0x02, 0x80, 0x03, 0x3C, 0x00, 0x00, 0xC2, 0xAC,
+0x60, 0x1B, 0x62, 0x24, 0xAC, 0x1B, 0x45, 0x94, 0xAE, 0x1B, 0x46, 0x94,
+0xAA, 0x1B, 0x42, 0x90, 0x02, 0x80, 0x03, 0x3C, 0x21, 0xB0, 0x07, 0x3C,
+0x14, 0x00, 0xA2, 0xA3, 0xD1, 0x5C, 0x63, 0x90, 0x20, 0xB0, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x18, 0x00, 0xA3, 0xAF, 0x23, 0xB0, 0x03, 0x3C,
+0xFF, 0xFF, 0x63, 0x34, 0x24, 0xB0, 0x08, 0x3C, 0xFF, 0x1F, 0x04, 0x3C,
+0x25, 0xB0, 0x1E, 0x3C, 0xFF, 0xFF, 0x84, 0x34, 0x21, 0x38, 0xA7, 0x00,
+0x21, 0x40, 0xC8, 0x00, 0x21, 0x28, 0xA2, 0x00, 0x21, 0x30, 0xC3, 0x00,
+0x24, 0x40, 0x04, 0x01, 0x24, 0x28, 0xA4, 0x00, 0x24, 0x38, 0xE4, 0x00,
+0x24, 0x30, 0xC4, 0x00, 0x35, 0x00, 0x02, 0x24, 0x20, 0x00, 0xC4, 0x37,
+0x00, 0x00, 0x82, 0xA0, 0x22, 0x00, 0x03, 0x24, 0x09, 0x00, 0x02, 0x24,
+0x03, 0x05, 0xC9, 0x37, 0x60, 0x05, 0xCA, 0x37, 0xAC, 0x00, 0xCB, 0x37,
+0xF8, 0x00, 0xCC, 0x37, 0xB0, 0x00, 0xCD, 0x37, 0x08, 0x01, 0xCE, 0x37,
+0xD8, 0x00, 0xCF, 0x37, 0x00, 0x00, 0x23, 0xA1, 0x00, 0x00, 0x42, 0xA1,
+0x00, 0x00, 0x65, 0xAD, 0x00, 0x00, 0x87, 0xAD, 0x00, 0x00, 0xA6, 0xAD,
+0x00, 0x00, 0xC8, 0xAD, 0x00, 0x00, 0xE0, 0xA1, 0x14, 0x00, 0xA3, 0x93,
+0x25, 0xB0, 0x02, 0x3C, 0xB4, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0xA0,
+0xB6, 0x00, 0xD1, 0x37, 0x04, 0x00, 0x02, 0x24, 0x25, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0x22, 0xA2, 0xB9, 0x00, 0x63, 0x34, 0xFF, 0xFF, 0x02, 0x24,
+0x00, 0x00, 0x62, 0xA0, 0x25, 0xB0, 0x03, 0x3C, 0x0F, 0x00, 0x02, 0x24,
+0xBA, 0x00, 0x63, 0x34, 0x00, 0x00, 0x62, 0xA4, 0xDC, 0x00, 0xD4, 0x37,
+0xFF, 0xCF, 0x03, 0x24, 0x3F, 0x3F, 0x02, 0x24, 0x16, 0x01, 0xD5, 0x37,
+0x00, 0x00, 0x83, 0xAE, 0x00, 0x00, 0xA2, 0xA6, 0x2F, 0x00, 0x02, 0x3C,
+0x00, 0x10, 0x03, 0x24, 0x17, 0x32, 0x42, 0x34, 0x18, 0x01, 0xD6, 0x37,
+0x1A, 0x01, 0xD7, 0x37, 0xD0, 0x01, 0xD8, 0x37, 0x00, 0x00, 0xC0, 0xA6,
+0x00, 0x00, 0xE3, 0xA6, 0x00, 0x00, 0x02, 0xAF, 0x5E, 0x00, 0x03, 0x3C,
+0x25, 0xB0, 0x02, 0x3C, 0x17, 0x43, 0x63, 0x34, 0xD4, 0x01, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xAC, 0x10, 0x00, 0x02, 0x3C, 0x20, 0x53, 0x42, 0x34,
+0xD8, 0x01, 0xDF, 0x37, 0x00, 0x00, 0xE2, 0xAF, 0x25, 0xB0, 0x02, 0x3C,
+0x44, 0xA4, 0x03, 0x34, 0xDC, 0x01, 0x42, 0x34, 0x00, 0x00, 0x43, 0xAC,
+0x25, 0xB0, 0x03, 0x3C, 0x1A, 0x06, 0x02, 0x24, 0xE0, 0x01, 0x63, 0x34,
+0x00, 0x00, 0x62, 0xA4, 0xC2, 0x00, 0x02, 0x3C, 0x30, 0x30, 0x03, 0x24,
+0x51, 0x10, 0x42, 0x34, 0xF4, 0x01, 0xD0, 0x37, 0xF8, 0x01, 0xD3, 0x37,
+0x00, 0x00, 0x03, 0xA6, 0x00, 0x02, 0xD2, 0x37, 0x00, 0x00, 0x62, 0xAE,
+0x26, 0x00, 0x03, 0x24, 0x03, 0x02, 0xD9, 0x37, 0x04, 0x00, 0x02, 0x24,
+0x00, 0x00, 0x43, 0xA6, 0x00, 0x00, 0x22, 0xA3, 0x18, 0x00, 0xA3, 0x8F,
+0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x60, 0x14, 0x36, 0x02, 0xC2, 0x37,
+0x04, 0x00, 0x03, 0x24, 0x00, 0x00, 0x43, 0xA0, 0x02, 0x80, 0x0B, 0x3C,
+0xC6, 0x5C, 0x66, 0x91, 0x25, 0xB0, 0x09, 0x3C, 0x34, 0x02, 0x23, 0x35,
+0x80, 0x00, 0x02, 0x24, 0x00, 0x00, 0x62, 0xA4, 0x38, 0x02, 0x24, 0x35,
+0x37, 0x02, 0x25, 0x35, 0x07, 0x00, 0x02, 0x24, 0x22, 0x00, 0x03, 0x24,
+0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0xA2, 0xA0, 0xE1, 0x00, 0xC3, 0x10,
+0x1B, 0x1B, 0x02, 0x3C, 0x13, 0x13, 0x02, 0x3C, 0x13, 0x13, 0x42, 0x34,
+0x60, 0x01, 0x23, 0x35, 0x64, 0x01, 0x24, 0x35, 0x68, 0x01, 0x25, 0x35,
+0x7C, 0x01, 0x2A, 0x35, 0x6C, 0x01, 0x26, 0x35, 0x70, 0x01, 0x27, 0x35,
+0x74, 0x01, 0x28, 0x35, 0x78, 0x01, 0x29, 0x35, 0x00, 0x00, 0x62, 0xAC,
+0x00, 0x00, 0x82, 0xAC, 0x00, 0x00, 0xA2, 0xAC, 0x00, 0x00, 0xC2, 0xAC,
+0x00, 0x00, 0xE2, 0xAC, 0x00, 0x00, 0x02, 0xAD, 0x00, 0x00, 0x22, 0xAD,
+0x00, 0x00, 0x42, 0xAD, 0xC6, 0x5C, 0x65, 0x91, 0x25, 0xB0, 0x0C, 0x3C,
+0x01, 0x00, 0x03, 0x3C, 0x80, 0x01, 0x82, 0x35, 0x08, 0x5F, 0x63, 0x34,
+0x22, 0x00, 0x04, 0x24, 0x00, 0x00, 0x43, 0xAC, 0xE0, 0x00, 0xA4, 0x10,
+0x0F, 0x1F, 0x02, 0x3C, 0x92, 0x00, 0x02, 0x24, 0xDD, 0x00, 0xA2, 0x10,
+0x0F, 0x1F, 0x02, 0x3C, 0x0F, 0x10, 0x02, 0x3C, 0x00, 0xF0, 0x4F, 0x34,
+0xF7, 0x01, 0x91, 0x35, 0x15, 0xF0, 0x4D, 0x34, 0x77, 0x00, 0x0E, 0x24,
+0x84, 0x01, 0x87, 0x35, 0x88, 0x01, 0x88, 0x35, 0x10, 0xF0, 0x44, 0x34,
+0x8C, 0x01, 0x85, 0x35, 0x05, 0xF0, 0x42, 0x34, 0x00, 0x00, 0xED, 0xAC,
+0x90, 0x01, 0x83, 0x35, 0x00, 0x00, 0x04, 0xAD, 0x94, 0x01, 0x86, 0x35,
+0x00, 0x00, 0xA2, 0xAC, 0xF5, 0x0F, 0x02, 0x24, 0x00, 0x00, 0x6F, 0xAC,
+0x98, 0x01, 0x89, 0x35, 0x00, 0x00, 0xC2, 0xAC, 0x9C, 0x01, 0x8A, 0x35,
+0xA0, 0x01, 0x8B, 0x35, 0xF0, 0x0F, 0x03, 0x24, 0xF6, 0x01, 0x8C, 0x35,
+0x0D, 0x00, 0x02, 0x24, 0x00, 0x00, 0x23, 0xAD, 0x00, 0x00, 0x42, 0xAD,
+0x00, 0x00, 0x6D, 0xAD, 0x02, 0x80, 0x02, 0x3C, 0x00, 0x00, 0x8E, 0xA1,
+0x00, 0x00, 0x2E, 0xA2, 0xE3, 0x5C, 0x42, 0x90, 0x25, 0xB0, 0x1F, 0x3C,
+0xA7, 0x01, 0xE7, 0x37, 0x1C, 0x00, 0xA2, 0xAF, 0xFF, 0xFF, 0x02, 0x24,
+0x00, 0x00, 0xE2, 0xA0, 0x05, 0x06, 0x03, 0x3C, 0x25, 0xB0, 0x02, 0x3C,
+0x03, 0x04, 0x63, 0x34, 0x0C, 0x00, 0x04, 0x24, 0xFF, 0xFF, 0x05, 0x24,
+0x01, 0x02, 0x06, 0x3C, 0xC2, 0x01, 0x42, 0x34, 0xA8, 0x01, 0xE8, 0x37,
+0xAC, 0x01, 0xE9, 0x37, 0xB0, 0x01, 0xEA, 0x37, 0xB4, 0x01, 0xEB, 0x37,
+0xB8, 0x01, 0xEC, 0x37, 0xBC, 0x01, 0xED, 0x37, 0xC0, 0x01, 0xEE, 0x37,
+0xC1, 0x01, 0xEF, 0x37, 0x00, 0x00, 0x05, 0xAD, 0x00, 0x00, 0x25, 0xAD,
+0x00, 0x00, 0x46, 0xAD, 0x00, 0x00, 0x63, 0xAD, 0x00, 0x00, 0x86, 0xAD,
+0x00, 0x00, 0xA3, 0xAD, 0x00, 0x00, 0xC4, 0xA1, 0x25, 0xB0, 0x03, 0x3C,
+0x00, 0x00, 0xE4, 0xA1, 0x00, 0x00, 0x44, 0xA0, 0x25, 0xB0, 0x02, 0x3C,
+0x0D, 0x00, 0x17, 0x24, 0x0E, 0x00, 0x18, 0x24, 0xC4, 0x01, 0x63, 0x34,
+0xC5, 0x01, 0x42, 0x34, 0xC3, 0x01, 0xF1, 0x37, 0x00, 0x00, 0x37, 0xA2,
+0xC6, 0x01, 0xF4, 0x37, 0x00, 0x00, 0x77, 0xA0, 0xC7, 0x01, 0xF5, 0x37,
+0x00, 0x00, 0x58, 0xA0, 0x0F, 0x00, 0x02, 0x24, 0x00, 0x00, 0x98, 0xA2,
+0x00, 0x00, 0xA2, 0xA2, 0x53, 0x01, 0x02, 0x3C, 0x46, 0x00, 0xF6, 0x37,
+0x48, 0x00, 0xFE, 0x37, 0x0E, 0xF0, 0x42, 0x34, 0x00, 0x00, 0xC0, 0xA6,
+0x00, 0x00, 0xC2, 0xAF, 0x1C, 0x00, 0xA3, 0x8F, 0x00, 0x00, 0x00, 0x00,
+0x09, 0x00, 0x60, 0x10, 0x44, 0x00, 0xF7, 0x37, 0x00, 0x00, 0xE2, 0x8E,
+0x00, 0x02, 0x03, 0x3C, 0x25, 0x10, 0x43, 0x00, 0x00, 0x00, 0xE2, 0xAE,
+0x00, 0x00, 0xC3, 0x8F, 0x00, 0x04, 0x02, 0x3C, 0x25, 0x18, 0x62, 0x00,
+0x00, 0x00, 0xC3, 0xAF, 0x4C, 0x00, 0xE2, 0x37, 0x00, 0x00, 0x40, 0xA0,
+0x40, 0x00, 0xE4, 0x37, 0xBC, 0x00, 0x03, 0x24, 0xFC, 0x37, 0x02, 0x24,
+0x00, 0x00, 0x83, 0xA4, 0x00, 0x00, 0x82, 0xA4, 0x02, 0x80, 0x02, 0x3C,
+0xD8, 0x00, 0xE9, 0x37, 0x60, 0x1B, 0x43, 0x24, 0x00, 0x00, 0x26, 0x91,
+0xAA, 0x1B, 0x64, 0x90, 0x2A, 0xB0, 0x05, 0x3C, 0xA0, 0xFF, 0x02, 0x24,
+0x26, 0xB0, 0x07, 0x3C, 0x25, 0x30, 0xC2, 0x00, 0x30, 0x00, 0xAD, 0x34,
+0x34, 0x00, 0xA8, 0x34, 0x01, 0x00, 0x83, 0x24, 0x38, 0x00, 0xA5, 0x34,
+0x20, 0x20, 0x02, 0x24, 0x00, 0x00, 0x26, 0xA1, 0x79, 0x00, 0xEA, 0x34,
+0x00, 0x00, 0x03, 0xA1, 0x00, 0x00, 0xA2, 0xA4, 0x40, 0x00, 0x03, 0x24,
+0x16, 0x00, 0x02, 0x24, 0x00, 0x00, 0xA3, 0xA1, 0x94, 0x00, 0xEB, 0x37,
+0x00, 0x00, 0x42, 0xA1, 0x98, 0x00, 0xEC, 0x37, 0x64, 0x00, 0x03, 0x24,
+0x22, 0x00, 0x02, 0x24, 0x00, 0x00, 0x63, 0xA5, 0x7C, 0x00, 0xF4, 0x34,
+0x00, 0x00, 0x82, 0xA5, 0x7A, 0x00, 0xE7, 0x34, 0x04, 0x00, 0x03, 0x24,
+0x20, 0x0C, 0x02, 0x24, 0x00, 0x00, 0xE3, 0xA0, 0x9C, 0x00, 0xEE, 0x37,
+0x00, 0x00, 0x82, 0xA6, 0x9A, 0x00, 0xEF, 0x37, 0x0A, 0x00, 0x03, 0x24,
+0xFF, 0x03, 0x02, 0x24, 0x00, 0x00, 0xC3, 0xA1, 0x00, 0x00, 0xE2, 0xA5,
+0x25, 0xB0, 0x02, 0x3C, 0x02, 0x00, 0x03, 0x24, 0x96, 0x00, 0x42, 0x34,
+0x00, 0x00, 0x43, 0xA4, 0x89, 0x00, 0xF5, 0x37, 0xB7, 0x00, 0xF1, 0x37,
+0x20, 0x00, 0x02, 0x24, 0x09, 0x00, 0x03, 0x24, 0x00, 0x00, 0x22, 0xA2,
+0x00, 0x00, 0xA3, 0xA2, 0x00, 0x00, 0xE2, 0x96, 0xFF, 0xFD, 0x03, 0x24,
+0x04, 0x02, 0x05, 0x24, 0x24, 0x10, 0x43, 0x00, 0x00, 0x00, 0xE2, 0xA6,
+0x00, 0x00, 0xE3, 0x96, 0x29, 0xB0, 0x02, 0x3C, 0x40, 0x00, 0x42, 0x34,
+0x00, 0x02, 0x63, 0x34, 0x00, 0x00, 0xE3, 0xA6, 0xFF, 0x00, 0x84, 0x30,
+0x00, 0x00, 0x45, 0xA4, 0x7A, 0x1F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x44, 0x00, 0xBF, 0x8F, 0x40, 0x00, 0xBE, 0x8F, 0x3C, 0x00, 0xB7, 0x8F,
+0x38, 0x00, 0xB6, 0x8F, 0x34, 0x00, 0xB5, 0x8F, 0x30, 0x00, 0xB4, 0x8F,
+0x2C, 0x00, 0xB3, 0x8F, 0x28, 0x00, 0xB2, 0x8F, 0x24, 0x00, 0xB1, 0x8F,
+0x20, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x02, 0x24, 0x08, 0x00, 0xE0, 0x03,
+0x48, 0x00, 0xBD, 0x27, 0xFF, 0xFF, 0x03, 0x24, 0x00, 0x00, 0x43, 0xA0,
+0x02, 0x80, 0x0B, 0x3C, 0xC6, 0x5C, 0x66, 0x91, 0x25, 0xB0, 0x09, 0x3C,
+0x34, 0x02, 0x23, 0x35, 0x80, 0x00, 0x02, 0x24, 0x00, 0x00, 0x62, 0xA4,
+0x38, 0x02, 0x24, 0x35, 0x37, 0x02, 0x25, 0x35, 0x07, 0x00, 0x02, 0x24,
+0x22, 0x00, 0x03, 0x24, 0x00, 0x00, 0x80, 0xA0, 0x00, 0x00, 0xA2, 0xA0,
+0x23, 0xFF, 0xC3, 0x14, 0x13, 0x13, 0x02, 0x3C, 0x1B, 0x1B, 0x02, 0x3C,
+0x1B, 0x1B, 0x42, 0x34, 0x60, 0x01, 0x23, 0x35, 0x64, 0x01, 0x24, 0x35,
+0x68, 0x01, 0x25, 0x35, 0x7C, 0x01, 0x2A, 0x35, 0x6C, 0x01, 0x26, 0x35,
+0x70, 0x01, 0x27, 0x35, 0x74, 0x01, 0x28, 0x35, 0x78, 0x01, 0x29, 0x35,
+0x00, 0x00, 0x62, 0xAC, 0x00, 0x00, 0x82, 0xAC, 0x00, 0x00, 0xA2, 0xAC,
+0x00, 0x00, 0xC2, 0xAC, 0x00, 0x00, 0xE2, 0xAC, 0x00, 0x00, 0x02, 0xAD,
+0x00, 0x00, 0x22, 0xAD, 0x00, 0x00, 0x42, 0xAD, 0xC6, 0x5C, 0x65, 0x91,
+0x25, 0xB0, 0x0C, 0x3C, 0x01, 0x00, 0x03, 0x3C, 0x80, 0x01, 0x82, 0x35,
+0x08, 0x5F, 0x63, 0x34, 0x22, 0x00, 0x04, 0x24, 0x00, 0x00, 0x43, 0xAC,
+0x22, 0xFF, 0xA4, 0x14, 0x0F, 0x1F, 0x02, 0x3C, 0x00, 0xF0, 0x4F, 0x34,
+0xF7, 0x01, 0x91, 0x35, 0x15, 0xF0, 0x4D, 0x34, 0xE7, 0x68, 0x00, 0x08,
+0xFF, 0xFF, 0x0E, 0x24, 0x02, 0x80, 0x02, 0x3C, 0xC7, 0x5C, 0x44, 0x90,
+0x06, 0x00, 0x03, 0x24, 0x0C, 0x00, 0x83, 0x10, 0xA0, 0x00, 0x24, 0x36,
+0x00, 0x15, 0x02, 0x3C, 0x00, 0x07, 0x42, 0x34, 0x00, 0x00, 0x82, 0xAC,
+0x04, 0xE0, 0x02, 0x3C, 0xA4, 0x00, 0x25, 0x36, 0x00, 0x22, 0x03, 0x24,
+0xA8, 0x00, 0x26, 0x36, 0x00, 0xAE, 0x42, 0x34, 0x00, 0x00, 0xA3, 0xAC,
+0x47, 0x68, 0x00, 0x08, 0x02, 0x80, 0x03, 0x3C, 0x00, 0x15, 0x02, 0x3C,
+0x00, 0x07, 0x42, 0x34, 0x00, 0x00, 0x82, 0xAC, 0x04, 0xC0, 0x02, 0x3C,
+0xA4, 0x00, 0x25, 0x36, 0x00, 0x22, 0x03, 0x24, 0xA8, 0x00, 0x26, 0x36,
+0x00, 0xB0, 0x42, 0x34, 0x00, 0x00, 0xA3, 0xAC, 0x47, 0x68, 0x00, 0x08,
+0x02, 0x80, 0x03, 0x3C, 0xE8, 0xFF, 0xBD, 0x27, 0x01, 0x00, 0x06, 0x24,
+0xE8, 0x0E, 0x04, 0x24, 0x10, 0x00, 0xBF, 0xAF, 0xC1, 0x43, 0x00, 0x0C,
+0x00, 0x10, 0x05, 0x3C, 0x60, 0x08, 0x04, 0x24, 0xE3, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0x20, 0x04, 0x06, 0x3C, 0x20, 0x04, 0xC6, 0x34,
+0x25, 0x30, 0x46, 0x00, 0x60, 0x08, 0x04, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0x70, 0x08, 0x04, 0x24, 0x00, 0x04, 0x05, 0x24,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x00, 0x20, 0x06, 0x3C,
+0x80, 0x00, 0xC6, 0x34, 0x80, 0x0C, 0x04, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0xFF, 0xFF, 0x05, 0x24, 0x00, 0x40, 0x06, 0x3C, 0x10, 0x00, 0xBF, 0x8F,
+0x00, 0x01, 0xC6, 0x34, 0x88, 0x0C, 0x04, 0x24, 0xFF, 0xFF, 0x05, 0x24,
+0xC1, 0x43, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF,
+0x10, 0x00, 0xB0, 0xAF, 0x21, 0x90, 0xA0, 0x00, 0x0A, 0x00, 0xA0, 0x10,
+0x21, 0x88, 0x00, 0x00, 0x21, 0x80, 0x80, 0x00, 0x00, 0x00, 0x04, 0x8E,
+0x04, 0x00, 0x05, 0x8E, 0x02, 0x00, 0x31, 0x26, 0x03, 0x5C, 0x00, 0x0C,
+0x08, 0x00, 0x10, 0x26, 0x2B, 0x10, 0x32, 0x02, 0xF9, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0xE0, 0xFF, 0xBD, 0x27, 0x18, 0x00, 0xB2, 0xAF,
+0x14, 0x00, 0xB1, 0xAF, 0x1C, 0x00, 0xBF, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x21, 0x90, 0xA0, 0x00, 0x0B, 0x00, 0xA0, 0x10, 0x21, 0x88, 0x00, 0x00,
+0x21, 0x80, 0x80, 0x00, 0x00, 0x00, 0x04, 0x8E, 0x04, 0x00, 0x05, 0x8E,
+0x08, 0x00, 0x06, 0x8E, 0x03, 0x00, 0x31, 0x26, 0xC1, 0x43, 0x00, 0x0C,
+0x0C, 0x00, 0x10, 0x26, 0x2B, 0x10, 0x32, 0x02, 0xF8, 0xFF, 0x40, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x21, 0x40, 0x80, 0x00, 0x21, 0x48, 0x00, 0x00,
+0x1E, 0x00, 0xA0, 0x10, 0x21, 0x38, 0x00, 0x00, 0x80, 0x30, 0x07, 0x00,
+0x21, 0x10, 0xC8, 0x00, 0x00, 0x00, 0x43, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x00, 0xF2, 0x63, 0x24, 0x1D, 0x00, 0x62, 0x2C, 0x12, 0x00, 0x40, 0x10,
+0x80, 0x10, 0x03, 0x00, 0x02, 0x80, 0x03, 0x3C, 0x14, 0xE6, 0x63, 0x24,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xC8, 0x00,
+0xC0, 0x18, 0x09, 0x00, 0x23, 0x18, 0x69, 0x00, 0x08, 0x00, 0x44, 0x8C,
+0x02, 0x80, 0x02, 0x3C, 0x80, 0x18, 0x03, 0x00, 0x60, 0x1B, 0x42, 0x24,
+0x21, 0x18, 0x62, 0x00, 0x04, 0x1D, 0x64, 0xAC, 0x01, 0x00, 0x29, 0x25,
+0x03, 0x00, 0xE7, 0x24, 0x2B, 0x10, 0xE5, 0x00, 0xE5, 0xFF, 0x40, 0x14,
+0x80, 0x30, 0x07, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0xC8, 0x00, 0xC0, 0x18, 0x09, 0x00, 0x08, 0x00, 0x44, 0x8C,
+0x23, 0x18, 0x69, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0x80, 0x18, 0x03, 0x00, 0x03, 0x00, 0xE7, 0x24, 0x21, 0x18, 0x62, 0x00,
+0x2B, 0x10, 0xE5, 0x00, 0xD6, 0xFF, 0x40, 0x14, 0x00, 0x1D, 0x64, 0xAC,
+0x4D, 0x6A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xC8, 0x00,
+0xC0, 0x18, 0x09, 0x00, 0x08, 0x00, 0x44, 0x8C, 0x23, 0x18, 0x69, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x80, 0x18, 0x03, 0x00,
+0x03, 0x00, 0xE7, 0x24, 0x21, 0x18, 0x62, 0x00, 0x2B, 0x10, 0xE5, 0x00,
+0xC8, 0xFF, 0x40, 0x14, 0xFC, 0x1C, 0x64, 0xAC, 0x4D, 0x6A, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xC8, 0x00, 0xC0, 0x18, 0x09, 0x00,
+0x08, 0x00, 0x44, 0x8C, 0x23, 0x18, 0x69, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x42, 0x24, 0x80, 0x18, 0x03, 0x00, 0x03, 0x00, 0xE7, 0x24,
+0x21, 0x18, 0x62, 0x00, 0x2B, 0x10, 0xE5, 0x00, 0xBA, 0xFF, 0x40, 0x14,
+0xF8, 0x1C, 0x64, 0xAC, 0x4D, 0x6A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x21, 0x10, 0xC8, 0x00, 0xC0, 0x18, 0x09, 0x00, 0x08, 0x00, 0x44, 0x8C,
+0x23, 0x18, 0x69, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24,
+0x80, 0x18, 0x03, 0x00, 0x03, 0x00, 0xE7, 0x24, 0x21, 0x18, 0x62, 0x00,
+0x2B, 0x10, 0xE5, 0x00, 0xAC, 0xFF, 0x40, 0x14, 0x08, 0x1D, 0x64, 0xAC,
+0x4D, 0x6A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xC8, 0x00,
+0xC0, 0x18, 0x09, 0x00, 0x08, 0x00, 0x44, 0x8C, 0x23, 0x18, 0x69, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x80, 0x18, 0x03, 0x00,
+0x03, 0x00, 0xE7, 0x24, 0x21, 0x18, 0x62, 0x00, 0x2B, 0x10, 0xE5, 0x00,
+0x9E, 0xFF, 0x40, 0x14, 0xF4, 0x1C, 0x64, 0xAC, 0x4D, 0x6A, 0x00, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x21, 0x10, 0xC8, 0x00, 0xC0, 0x18, 0x09, 0x00,
+0x08, 0x00, 0x44, 0x8C, 0x23, 0x18, 0x69, 0x00, 0x02, 0x80, 0x02, 0x3C,
+0x60, 0x1B, 0x42, 0x24, 0x80, 0x18, 0x03, 0x00, 0x03, 0x00, 0xE7, 0x24,
+0x21, 0x18, 0x62, 0x00, 0x2B, 0x10, 0xE5, 0x00, 0x90, 0xFF, 0x40, 0x14,
+0xF0, 0x1C, 0x64, 0xAC, 0x4D, 0x6A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x25, 0xB0, 0x02, 0x3C, 0xFC, 0x37, 0x03, 0x24, 0x40, 0x00, 0x42, 0x34,
+0x02, 0x80, 0x04, 0x3C, 0x00, 0x00, 0x43, 0xA4, 0xE8, 0xFF, 0xBD, 0x27,
+0x5C, 0xD1, 0x84, 0x24, 0x10, 0x00, 0xBF, 0xAF, 0xFD, 0x69, 0x00, 0x0C,
+0x74, 0x01, 0x05, 0x24, 0x02, 0x80, 0x02, 0x3C, 0xC6, 0x5C, 0x44, 0x90,
+0x12, 0x00, 0x03, 0x24, 0x34, 0x00, 0x83, 0x10, 0x13, 0x00, 0x82, 0x28,
+0x17, 0x00, 0x40, 0x14, 0x11, 0x00, 0x02, 0x24, 0x22, 0x00, 0x02, 0x24,
+0x36, 0x00, 0x82, 0x10, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x04, 0x3C,
+0xE4, 0xCD, 0x84, 0x24, 0x2C, 0x6A, 0x00, 0x0C, 0x54, 0x00, 0x05, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0x4A, 0xF5, 0x44, 0x90, 0x01, 0x00, 0x03, 0x24,
+0x1A, 0x00, 0x83, 0x10, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0xE4, 0xC8, 0x84, 0x24, 0xFD, 0x69, 0x00, 0x0C, 0x40, 0x01, 0x05, 0x24,
+0x10, 0x00, 0xBF, 0x8F, 0x84, 0x08, 0x04, 0x24, 0xFF, 0x00, 0x05, 0x24,
+0x58, 0x00, 0x06, 0x24, 0x35, 0x45, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0xED, 0xFF, 0x82, 0x14, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x04, 0x3C,
+0x9C, 0xD0, 0x84, 0x24, 0x14, 0x6A, 0x00, 0x0C, 0x30, 0x00, 0x05, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0xE4, 0xCD, 0x84, 0x24, 0x2C, 0x6A, 0x00, 0x0C,
+0x54, 0x00, 0x05, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x4A, 0xF5, 0x44, 0x90,
+0x01, 0x00, 0x03, 0x24, 0xE8, 0xFF, 0x83, 0x14, 0x00, 0x00, 0x00, 0x00,
+0xDE, 0x69, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0xE4, 0xC8, 0x84, 0x24, 0xFD, 0x69, 0x00, 0x0C, 0x40, 0x01, 0x05, 0x24,
+0x10, 0x00, 0xBF, 0x8F, 0x84, 0x08, 0x04, 0x24, 0xFF, 0x00, 0x05, 0x24,
+0x58, 0x00, 0x06, 0x24, 0x35, 0x45, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0x02, 0x80, 0x04, 0x3C, 0xE8, 0xCF, 0x84, 0x24, 0x2D, 0x00, 0x05, 0x24,
+0x14, 0x6A, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xD1, 0x6A, 0x00, 0x08,
+0x02, 0x80, 0x04, 0x3C, 0x34, 0xCF, 0x84, 0x24, 0xE8, 0x6A, 0x00, 0x08,
+0x2D, 0x00, 0x05, 0x24, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xB0, 0xAF,
+0x50, 0x0C, 0x04, 0x24, 0xFF, 0x00, 0x05, 0x24, 0x02, 0x80, 0x10, 0x3C,
+0x14, 0x00, 0xBF, 0xAF, 0x24, 0x45, 0x00, 0x0C, 0x60, 0x1B, 0x10, 0x26,
+0x60, 0x1D, 0x02, 0xA2, 0x58, 0x0C, 0x04, 0x24, 0x24, 0x45, 0x00, 0x0C,
+0xFF, 0x00, 0x05, 0x24, 0x61, 0x1D, 0x02, 0xA2, 0x60, 0x0C, 0x04, 0x24,
+0x24, 0x45, 0x00, 0x0C, 0xFF, 0x00, 0x05, 0x24, 0x62, 0x1D, 0x02, 0xA2,
+0x68, 0x0C, 0x04, 0x24, 0x24, 0x45, 0x00, 0x0C, 0xFF, 0x00, 0x05, 0x24,
+0x63, 0x1D, 0x02, 0xA2, 0x38, 0x0C, 0x04, 0x24, 0x24, 0x45, 0x00, 0x0C,
+0xFF, 0x00, 0x05, 0x24, 0xE8, 0x1C, 0x02, 0xA2, 0x34, 0x0C, 0x04, 0x24,
+0x24, 0x45, 0x00, 0x0C, 0xFF, 0xFF, 0x05, 0x24, 0xEC, 0x1C, 0x02, 0xAE,
+0x14, 0x00, 0xBF, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x38, 0xAD, 0x42, 0x24, 0xB0, 0x5D, 0x60, 0xAC,
+0x10, 0x5D, 0xA2, 0xAC, 0x02, 0x80, 0x03, 0x3C, 0x00, 0x80, 0x02, 0x3C,
+0xB4, 0x5D, 0x60, 0xA4, 0x10, 0x5D, 0xA4, 0x24, 0x64, 0x11, 0x42, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0xB6, 0x5D, 0x60, 0xA4, 0x08, 0x00, 0x82, 0xAC,
+0x00, 0x80, 0x03, 0x3C, 0x00, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x06, 0x3C,
+0x4C, 0x14, 0x42, 0x24, 0x80, 0x11, 0x63, 0x24, 0xB8, 0x5D, 0xC7, 0x24,
+0x14, 0x00, 0x82, 0xAC, 0x10, 0x00, 0x83, 0xAC, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xB8, 0x5D, 0xC0, 0xAC, 0x04, 0x00, 0xE0, 0xAC,
+0xC0, 0x5D, 0x40, 0xA0, 0xC4, 0x5D, 0x60, 0xAC, 0x01, 0x80, 0x02, 0x3C,
+0xB4, 0xC5, 0x42, 0x24, 0x7C, 0x00, 0x82, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x68, 0x14, 0x63, 0x24, 0x08, 0x17, 0x42, 0x24,
+0x20, 0x00, 0x83, 0xAC, 0x24, 0x00, 0x82, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0xB0, 0x19, 0x63, 0x24, 0x54, 0x1C, 0x42, 0x24,
+0x28, 0x00, 0x83, 0xAC, 0x2C, 0x00, 0x82, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x01, 0x80, 0x02, 0x3C, 0x80, 0x2F, 0x63, 0x24, 0x10, 0x02, 0x42, 0x24,
+0x30, 0x00, 0x83, 0xAC, 0x54, 0x00, 0x82, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x58, 0x1F, 0x63, 0x24, 0x38, 0x21, 0x42, 0x24,
+0x0C, 0x00, 0x83, 0xAC, 0x3C, 0x00, 0x82, 0xAC, 0x00, 0x80, 0x03, 0x3C,
+0x00, 0x80, 0x02, 0x3C, 0x00, 0x03, 0x63, 0x24, 0xF8, 0x1E, 0x42, 0x24,
+0x50, 0x00, 0x83, 0xAC, 0x08, 0x00, 0xE0, 0x03, 0x40, 0x00, 0x82, 0xAC,
+0x25, 0xB0, 0x02, 0x3C, 0x08, 0x00, 0x42, 0x34, 0x00, 0x00, 0x43, 0x8C,
+0x08, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x0E, 0x3C,
+0x02, 0x80, 0x08, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0xF8, 0x03, 0x4D, 0x24, 0x00, 0x18, 0x6C, 0x24, 0x01, 0x00, 0x07, 0x24,
+0x00, 0x00, 0xCB, 0x25, 0xFF, 0xFF, 0x0A, 0x24, 0x00, 0x04, 0x09, 0x25,
+0x80, 0x1A, 0x07, 0x00, 0x21, 0x10, 0x6B, 0x00, 0x00, 0x00, 0x42, 0xAC,
+0x90, 0x00, 0x4A, 0xAC, 0x00, 0x04, 0x04, 0x8D, 0x01, 0x00, 0xE7, 0x24,
+0x08, 0x00, 0x45, 0x24, 0x21, 0x18, 0x6D, 0x00, 0x06, 0x00, 0xE6, 0x28,
+0x04, 0x00, 0x82, 0xAC, 0x00, 0x00, 0x44, 0xAC, 0x04, 0x00, 0x49, 0xAC,
+0x00, 0x04, 0x02, 0xAD, 0x8C, 0x00, 0x40, 0xAC, 0x6C, 0x00, 0xA3, 0xAC,
+0xF0, 0xFF, 0xC0, 0x14, 0x68, 0x00, 0xAC, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0xC9, 0xAD, 0x06, 0x00, 0xA2, 0x2C, 0x13, 0x00, 0x40, 0x10,
+0xFF, 0xFF, 0x07, 0x24, 0x02, 0x80, 0x02, 0x3C, 0x80, 0x1A, 0x05, 0x00,
+0x00, 0x00, 0x42, 0x24, 0x0E, 0x00, 0xA0, 0x10, 0x21, 0x30, 0x62, 0x00,
+0x90, 0x00, 0xC3, 0x8C, 0xFF, 0xFF, 0x02, 0x24, 0x0A, 0x00, 0x62, 0x14,
+0x00, 0x00, 0x00, 0x00, 0x8C, 0x00, 0xC2, 0x8C, 0x00, 0x00, 0x00, 0x00,
+0x06, 0x00, 0x40, 0x14, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x24,
+0x88, 0x00, 0xC4, 0xAC, 0x8C, 0x00, 0xC2, 0xAC, 0x90, 0x00, 0xC5, 0xAC,
+0x21, 0x38, 0xA0, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0xE0, 0x00,
+0xE0, 0xFF, 0xBD, 0x27, 0x02, 0x80, 0x02, 0x3C, 0x1C, 0x00, 0xBF, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0xC3, 0x5C, 0x46, 0x90, 0x25, 0xB0, 0x07, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xDB, 0xFF, 0x03, 0x24, 0x18, 0x03, 0xE4, 0x34, 0x27, 0x00, 0xE5, 0x34,
+0x1C, 0xAE, 0x42, 0x24, 0x00, 0x00, 0x82, 0xAC, 0x00, 0x00, 0xA3, 0xA0,
+0x02, 0x00, 0xC0, 0x10, 0x1B, 0x00, 0xE3, 0x34, 0x1F, 0x00, 0xE3, 0x34,
+0x07, 0x00, 0x02, 0x24, 0x00, 0x00, 0x62, 0xA0, 0xF0, 0x42, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x00, 0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x50, 0x24,
+0x34, 0x1C, 0x04, 0x8E, 0xE3, 0x43, 0x00, 0x0C, 0x10, 0x00, 0x05, 0x24,
+0x40, 0x1C, 0x04, 0x8E, 0x10, 0x00, 0x05, 0x3C, 0x01, 0x00, 0x06, 0x24,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x90, 0x40, 0x00, 0x3C, 0x1C, 0x04, 0x8E,
+0x10, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24,
+0x58, 0x1C, 0x04, 0x8E, 0x00, 0x04, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x58, 0x1C, 0x04, 0x8E, 0x00, 0x08, 0x05, 0x24,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x02, 0x80, 0x05, 0x3C,
+0x78, 0xDA, 0xA5, 0x24, 0x21, 0x20, 0x00, 0x00, 0xC1, 0x45, 0x00, 0x0C,
+0xCA, 0x00, 0x06, 0x24, 0x31, 0x00, 0x40, 0x10, 0x21, 0x18, 0x00, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xCF, 0x5C, 0x43, 0x90, 0x01, 0x00, 0x11, 0x24,
+0x53, 0x00, 0x71, 0x10, 0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0x4A, 0xF5, 0x43, 0x90, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x71, 0x10,
+0x02, 0x80, 0x05, 0x3C, 0x34, 0x1C, 0x04, 0x8E, 0x21, 0x30, 0x40, 0x02,
+0x10, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C, 0x02, 0x80, 0x11, 0x3C,
+0xC6, 0x5C, 0x23, 0x92, 0x11, 0x00, 0x02, 0x24, 0x2A, 0x00, 0x62, 0x10,
+0x00, 0x08, 0x04, 0x24, 0xF0, 0x42, 0x00, 0x0C, 0x01, 0x00, 0x04, 0x24,
+0x34, 0x1C, 0x04, 0x8E, 0xE3, 0x43, 0x00, 0x0C, 0x10, 0x00, 0x05, 0x3C,
+0x40, 0x1C, 0x04, 0x8E, 0x10, 0x00, 0x05, 0x3C, 0x01, 0x00, 0x06, 0x24,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x90, 0x40, 0x00, 0x3C, 0x1C, 0x04, 0x8E,
+0x10, 0x00, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24,
+0x58, 0x1C, 0x04, 0x8E, 0x00, 0x04, 0x05, 0x24, 0xC1, 0x43, 0x00, 0x0C,
+0x21, 0x30, 0x00, 0x00, 0x58, 0x1C, 0x04, 0x8E, 0x00, 0x08, 0x05, 0x24,
+0xC1, 0x43, 0x00, 0x0C, 0x21, 0x30, 0x00, 0x00, 0x02, 0x80, 0x05, 0x3C,
+0x20, 0xDA, 0xA5, 0x24, 0x01, 0x00, 0x04, 0x24, 0xC1, 0x45, 0x00, 0x0C,
+0x16, 0x00, 0x06, 0x24, 0x08, 0x00, 0x40, 0x14, 0x21, 0x18, 0x00, 0x00,
+0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F,
+0x10, 0x00, 0xB0, 0x8F, 0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x34, 0x1C, 0x04, 0x8E, 0x21, 0x30, 0x40, 0x02,
+0xC1, 0x43, 0x00, 0x0C, 0x10, 0x00, 0x05, 0x3C, 0x00, 0x08, 0x04, 0x24,
+0x00, 0x01, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C, 0x01, 0x00, 0x06, 0x24,
+0x00, 0x08, 0x04, 0x24, 0x00, 0x02, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C,
+0x01, 0x00, 0x06, 0x24, 0xC6, 0x5C, 0x23, 0x92, 0x11, 0x00, 0x02, 0x24,
+0x1D, 0x00, 0x62, 0x10, 0x00, 0x08, 0x04, 0x24, 0xF0, 0x42, 0x00, 0x0C,
+0x21, 0x20, 0x00, 0x00, 0x0F, 0x00, 0x05, 0x3C, 0x0C, 0x00, 0x06, 0x3C,
+0xFF, 0xFF, 0xA5, 0x34, 0x00, 0xB4, 0xC6, 0x34, 0x83, 0x45, 0x00, 0x0C,
+0x08, 0x00, 0x04, 0x24, 0x1C, 0x00, 0xBF, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x01, 0x00, 0x03, 0x24,
+0x21, 0x10, 0x60, 0x00, 0x08, 0x00, 0xE0, 0x03, 0x20, 0x00, 0xBD, 0x27,
+0x10, 0xD9, 0xA5, 0x24, 0x21, 0x20, 0x00, 0x00, 0xC1, 0x45, 0x00, 0x0C,
+0x16, 0x00, 0x06, 0x24, 0xC0, 0x6B, 0x00, 0x08, 0x02, 0x80, 0x02, 0x3C,
+0x68, 0xD9, 0xA5, 0x24, 0x21, 0x20, 0x00, 0x00, 0xC1, 0x45, 0x00, 0x0C,
+0x16, 0x00, 0x06, 0x24, 0xC4, 0x6B, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x00, 0xFF, 0x05, 0x3C, 0xC1, 0x43, 0x00, 0x0C, 0x03, 0x00, 0x06, 0x24,
+0x01, 0x6C, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x02, 0x80, 0x02, 0x3C, 0x25, 0x59, 0x47, 0x90, 0x02, 0x80, 0x04, 0x3C,
+0x02, 0x80, 0x05, 0x3C, 0x03, 0x00, 0x03, 0x24, 0x4E, 0x37, 0x84, 0x24,
+0xB4, 0xDF, 0xA5, 0x24, 0x0F, 0x00, 0xE3, 0x10, 0x0D, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0x4E, 0x37, 0x84, 0x24,
+0x64, 0xDF, 0xA5, 0x24, 0xF4, 0x54, 0x00, 0x0C, 0x0D, 0x00, 0x06, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C, 0x10, 0x00, 0xBF, 0x8F,
+0x5B, 0x37, 0x84, 0x24, 0x74, 0xDF, 0xA5, 0x24, 0x0D, 0x00, 0x06, 0x24,
+0xF4, 0x54, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27, 0xF4, 0x54, 0x00, 0x0C,
+0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x02, 0x80, 0x05, 0x3C,
+0x10, 0x00, 0xBF, 0x8F, 0x5B, 0x37, 0x84, 0x24, 0xA4, 0xDF, 0xA5, 0x24,
+0x0D, 0x00, 0x06, 0x24, 0xF4, 0x54, 0x00, 0x08, 0x18, 0x00, 0xBD, 0x27,
+0xE0, 0xFF, 0xBD, 0x27, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x02, 0x80, 0x05, 0x3C, 0x02, 0x80, 0x10, 0x3C, 0x02, 0x80, 0x11, 0x3C,
+0x60, 0x1B, 0x31, 0x26, 0x2C, 0x59, 0x04, 0x26, 0xA0, 0xDD, 0xA5, 0x24,
+0x34, 0x00, 0x06, 0x24, 0x18, 0x00, 0xBF, 0xAF, 0xF4, 0x54, 0x00, 0x0C,
+0x2C, 0x59, 0x10, 0x26, 0x24, 0x6C, 0x00, 0x0C, 0x00, 0x3E, 0x30, 0xAE,
+0x02, 0x00, 0x10, 0x24, 0x02, 0x80, 0x04, 0x3C, 0x00, 0x80, 0x06, 0x3C,
+0x9C, 0x39, 0x30, 0xA2, 0xE8, 0x54, 0x84, 0x24, 0x98, 0x5B, 0xC6, 0x24,
+0xCF, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x01, 0x80, 0x06, 0x3C, 0xB8, 0x39, 0x30, 0xA2, 0x04, 0x55, 0x84, 0x24,
+0x90, 0x3B, 0xC6, 0x24, 0xCF, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0x02, 0x80, 0x04, 0x3C, 0x01, 0x80, 0x06, 0x3C, 0xD4, 0x39, 0x30, 0xA2,
+0x20, 0x55, 0x84, 0x24, 0x08, 0x39, 0xC6, 0x24, 0xCF, 0x20, 0x00, 0x0C,
+0x21, 0x28, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C, 0x01, 0x80, 0x06, 0x3C,
+0xF0, 0x39, 0x30, 0xA2, 0x3C, 0x55, 0x84, 0x24, 0x74, 0x44, 0xC6, 0x24,
+0xCF, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00, 0x02, 0x80, 0x04, 0x3C,
+0x00, 0x80, 0x06, 0x3C, 0x0C, 0x3A, 0x30, 0xA2, 0x58, 0x55, 0x84, 0x24,
+0xFC, 0x5A, 0xC6, 0x24, 0xCF, 0x20, 0x00, 0x0C, 0x21, 0x28, 0x00, 0x00,
+0x09, 0x00, 0x02, 0x24, 0xB8, 0x40, 0x22, 0xA2, 0xC7, 0x3D, 0x20, 0xA2,
+0x3A, 0x41, 0x20, 0xA2, 0xC8, 0x3D, 0x20, 0xA6, 0x18, 0x00, 0xBF, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x20, 0x00, 0xBD, 0x27, 0x03, 0x80, 0x05, 0x3C, 0x00, 0x80, 0xA5, 0x24,
+0xD8, 0xFF, 0xBD, 0x27, 0x40, 0x10, 0x0D, 0x3C, 0xFF, 0xFF, 0xA5, 0x30,
+0x02, 0x80, 0x02, 0x3C, 0x60, 0x1B, 0x42, 0x24, 0x20, 0x00, 0xBE, 0xAF,
+0x25, 0xF0, 0xAD, 0x00, 0x2C, 0x38, 0x5E, 0xAC, 0x00, 0x01, 0xDE, 0x27,
+0x38, 0x38, 0x5E, 0xAC, 0x00, 0x01, 0xDE, 0x27, 0x1C, 0x00, 0xB7, 0xAF,
+0x18, 0x00, 0xB6, 0xAF, 0x14, 0x00, 0xB5, 0xAF, 0x10, 0x00, 0xB4, 0xAF,
+0x0C, 0x00, 0xB3, 0xAF, 0x08, 0x00, 0xB2, 0xAF, 0x04, 0x00, 0xB1, 0xAF,
+0x00, 0x00, 0xB0, 0xAF, 0x44, 0x38, 0x5E, 0xAC, 0x00, 0x01, 0xDE, 0x27,
+0x50, 0x38, 0x5E, 0xAC, 0xAA, 0x1B, 0x44, 0x90, 0x00, 0x01, 0xDE, 0x27,
+0x5C, 0x38, 0x5E, 0xAC, 0x00, 0x01, 0xDE, 0x27, 0x68, 0x38, 0x5E, 0xAC,
+0x20, 0xB0, 0x06, 0x3C, 0x38, 0x38, 0x48, 0x8C, 0x44, 0x38, 0x49, 0x8C,
+0x50, 0x38, 0x4A, 0x8C, 0x5C, 0x38, 0x4B, 0x8C, 0x68, 0x38, 0x4C, 0x8C,
+0x00, 0x22, 0x04, 0x00, 0x00, 0x01, 0xC7, 0x34, 0xFF, 0x1F, 0x03, 0x3C,
+0x00, 0x01, 0xDE, 0x27, 0xFF, 0xFF, 0x63, 0x34, 0x21, 0x38, 0x87, 0x00,
+0x21, 0x20, 0x86, 0x00, 0x24, 0x38, 0xE3, 0x00, 0x20, 0x10, 0x06, 0x3C,
+0x24, 0x20, 0x83, 0x00, 0x74, 0x38, 0x5E, 0xAC, 0x21, 0x70, 0xC0, 0x03,
+0x25, 0x28, 0xAD, 0x00, 0x25, 0xB0, 0x0F, 0x3C, 0x00, 0x01, 0xDE, 0x27,
+0x28, 0x38, 0x45, 0xAC, 0x34, 0x38, 0x48, 0xAC, 0x40, 0x38, 0x49, 0xAC,
+0x4C, 0x38, 0x4A, 0xAC, 0xEC, 0x37, 0x44, 0xAC, 0x58, 0x38, 0x4B, 0xAC,
+0xF8, 0x37, 0x47, 0xAC, 0x64, 0x38, 0x4C, 0xAC, 0xAC, 0x00, 0xE3, 0x35,
+0xC0, 0x37, 0x46, 0xAC, 0xBC, 0x37, 0x46, 0xAC, 0xCC, 0x37, 0x46, 0xAC,
+0xC8, 0x37, 0x46, 0xAC, 0x80, 0x38, 0x5E, 0xAC, 0xF0, 0x37, 0x44, 0xAC,
+0xFC, 0x37, 0x47, 0xAC, 0x70, 0x38, 0x4E, 0xAC, 0xD8, 0x37, 0x46, 0xAC,
+0xD4, 0x37, 0x46, 0xAC, 0xE4, 0x37, 0x46, 0xAC, 0xE0, 0x37, 0x46, 0xAC,
+0x08, 0x38, 0x46, 0xAC, 0x04, 0x38, 0x46, 0xAC, 0xAC, 0x1B, 0x47, 0x94,
+0x00, 0x02, 0xDE, 0x27, 0x00, 0x00, 0x69, 0x8C, 0x21, 0x10, 0x05, 0x3C,
+0x98, 0x38, 0x5E, 0xAC, 0xB0, 0x00, 0xE3, 0x35, 0x00, 0x00, 0x79, 0x8C,
+0x80, 0x38, 0x54, 0x8C, 0x00, 0x80, 0xA4, 0x34, 0x23, 0x10, 0x0D, 0x3C,
+0x22, 0x10, 0x10, 0x3C, 0x02, 0x80, 0x16, 0x3C, 0x02, 0x80, 0x17, 0x3C,
+0x02, 0x80, 0x18, 0x3C, 0x02, 0x80, 0x13, 0x3C, 0x23, 0x20, 0x87, 0x00,
+0x02, 0x80, 0x03, 0x3C, 0x24, 0x10, 0x07, 0x3C, 0xC0, 0x54, 0x68, 0x24,
+0xCC, 0x38, 0x44, 0xAC, 0x21, 0xA8, 0xC0, 0x03, 0xC8, 0x54, 0xCE, 0x26,
+0x00, 0x04, 0xDE, 0x27, 0xD0, 0x54, 0xEA, 0x26, 0xD8, 0x54, 0x0B, 0x27,
+0xE0, 0x54, 0x6C, 0x26, 0x00, 0x04, 0xB1, 0x35, 0x01, 0x00, 0x29, 0x25,
+0x00, 0x40, 0x12, 0x36, 0x00, 0x01, 0xEF, 0x35, 0x01, 0x00, 0x03, 0x24,
+0x02, 0x80, 0x04, 0x3C, 0x7C, 0x38, 0x54, 0xAC, 0x85, 0x38, 0x43, 0xA0,
+0x94, 0x38, 0x55, 0xAC, 0xFC, 0x38, 0x51, 0xAC, 0xC0, 0x38, 0x49, 0xAC,
+0xF0, 0x38, 0x52, 0xAC, 0xE4, 0x38, 0x59, 0xAC, 0x00, 0x00, 0xE7, 0xAD,
+0xE0, 0x38, 0x47, 0xAC, 0x00, 0x39, 0x46, 0xAC, 0x14, 0x38, 0x46, 0xAC,
+0x10, 0x38, 0x46, 0xAC, 0x9E, 0x38, 0x40, 0xA4, 0x9D, 0x38, 0x40, 0xA0,
+0x9C, 0x38, 0x40, 0xA0, 0xF4, 0x38, 0x4D, 0xAC, 0xF8, 0x38, 0x4D, 0xAC,
+0xB8, 0x38, 0x45, 0xAC, 0xBC, 0x38, 0x45, 0xAC, 0xC4, 0x38, 0x45, 0xAC,
+0xC8, 0x38, 0x45, 0xAC, 0xE8, 0x38, 0x50, 0xAC, 0xEC, 0x38, 0x50, 0xAC,
+0xDC, 0x38, 0x47, 0xAC, 0x04, 0x39, 0x46, 0xAC, 0x10, 0x39, 0x5E, 0xAC,
+0x0C, 0x39, 0x5E, 0xAC, 0x04, 0x00, 0x4A, 0xAD, 0xC8, 0x54, 0xCE, 0xAE,
+0x04, 0x00, 0x6B, 0xAD, 0xD0, 0x54, 0xEA, 0xAE, 0x04, 0x00, 0x8C, 0xAD,
+0xD8, 0x54, 0x0B, 0xAF, 0x04, 0x00, 0x08, 0xAD, 0xE0, 0x54, 0x6C, 0xAE,
+0xC0, 0x54, 0x88, 0xAC, 0x04, 0x00, 0xCE, 0xAD, 0x02, 0x80, 0x04, 0x3C,
+0x18, 0x18, 0x83, 0x24, 0x02, 0x80, 0x05, 0x3C, 0x00, 0x18, 0xA2, 0x24,
+0x18, 0x18, 0x83, 0xAC, 0x02, 0x80, 0x04, 0x3C, 0x04, 0x00, 0x02, 0xAD,
+0x00, 0x18, 0xA8, 0xAC, 0xC0, 0x54, 0x82, 0xAC, 0x21, 0x48, 0x60, 0x00,
+0x08, 0x00, 0x5E, 0xAC, 0x01, 0x00, 0x07, 0x24, 0x04, 0x00, 0x63, 0xAC,
+0x00, 0x01, 0xDE, 0x27, 0x04, 0x00, 0x48, 0xAC, 0x10, 0x00, 0x40, 0xAC,
+0x21, 0x40, 0x40, 0x00, 0x21, 0x18, 0xC0, 0x01, 0x21, 0x28, 0x00, 0x00,
+0x0F, 0x00, 0x06, 0x24, 0x21, 0x20, 0xA9, 0x00, 0x21, 0x10, 0xA8, 0x00,
+0xFF, 0xFF, 0xC6, 0x24, 0x20, 0x00, 0x5E, 0xAC, 0x28, 0x00, 0x47, 0xAC,
+0x18, 0x00, 0xA5, 0x24, 0x00, 0x00, 0x8E, 0xAC, 0x04, 0x00, 0x83, 0xAC,
+0x00, 0x00, 0x64, 0xAC, 0x00, 0x01, 0xDE, 0x27, 0xF5, 0xFF, 0xC1, 0x04,
+0x21, 0x18, 0x80, 0x00, 0x02, 0x80, 0x02, 0x3C, 0xD0, 0x54, 0x48, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0x04, 0x00, 0x07, 0x8D,
+0x98, 0x19, 0x4B, 0x24, 0x04, 0x00, 0xC4, 0xAD, 0x00, 0x18, 0x6A, 0x24,
+0x02, 0x00, 0x09, 0x24, 0x21, 0x28, 0x00, 0x00, 0x0F, 0x00, 0x06, 0x24,
+0x21, 0x20, 0xAB, 0x00, 0x21, 0x10, 0xAA, 0x00, 0xFF, 0xFF, 0xC6, 0x24,
+0xA0, 0x01, 0x5E, 0xAC, 0xA8, 0x01, 0x49, 0xAC, 0x18, 0x00, 0xA5, 0x24,
+0x00, 0x00, 0x88, 0xAC, 0x04, 0x00, 0x87, 0xAC, 0x00, 0x00, 0xE4, 0xAC,
+0x00, 0x02, 0xDE, 0x27, 0xF5, 0xFF, 0xC1, 0x04, 0x21, 0x38, 0x80, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xD8, 0x54, 0x49, 0x24, 0x02, 0x80, 0x03, 0x3C,
+0x02, 0x80, 0x02, 0x3C, 0x04, 0x00, 0x25, 0x8D, 0x18, 0x1B, 0x4B, 0x24,
+0x04, 0x00, 0x04, 0xAD, 0x00, 0x18, 0x6A, 0x24, 0x03, 0x00, 0x07, 0x24,
+0x21, 0x20, 0x00, 0x00, 0x01, 0x00, 0x06, 0x24, 0x21, 0x40, 0x8B, 0x00,
+0x21, 0x10, 0x8A, 0x00, 0xFF, 0xFF, 0xC6, 0x24, 0x20, 0x03, 0x5E, 0xAC,
+0x28, 0x03, 0x47, 0xAC, 0x18, 0x00, 0x84, 0x24, 0x00, 0x00, 0x09, 0xAD,
+0x04, 0x00, 0x05, 0xAD, 0x00, 0x00, 0xA8, 0xAC, 0x00, 0x08, 0xDE, 0x27,
+0xF5, 0xFF, 0xC1, 0x04, 0x21, 0x28, 0x00, 0x01, 0x02, 0x80, 0x05, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0xE0, 0x54, 0xA5, 0x24, 0x00, 0x18, 0x63, 0x24,
+0x04, 0x00, 0xA6, 0x8C, 0x1C, 0x00, 0xB7, 0x8F, 0x50, 0x03, 0x7E, 0xAC,
+0x18, 0x00, 0xB6, 0x8F, 0x20, 0x00, 0xBE, 0x8F, 0x14, 0x00, 0xB5, 0x8F,
+0x10, 0x00, 0xB4, 0x8F, 0x0C, 0x00, 0xB3, 0x8F, 0x08, 0x00, 0xB2, 0x8F,
+0x04, 0x00, 0xB1, 0x8F, 0x00, 0x00, 0xB0, 0x8F, 0x02, 0x80, 0x07, 0x3C,
+0x48, 0x1B, 0xE4, 0x24, 0x04, 0x00, 0x02, 0x24, 0x28, 0x00, 0xBD, 0x27,
+0x04, 0x00, 0x28, 0xAD, 0x04, 0x00, 0xA4, 0xAC, 0x58, 0x03, 0x62, 0xAC,
+0x48, 0x1B, 0xE5, 0xAC, 0x04, 0x00, 0x86, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0xC4, 0xAC, 0xFA, 0x63, 0x00, 0x6A, 0x09, 0xD1, 0x0A, 0x62,
+0x08, 0xD0, 0x06, 0xD2, 0x7D, 0x67, 0x18, 0xA3, 0x10, 0xF0, 0x02, 0x69,
+0x00, 0xF4, 0x20, 0x31, 0x63, 0xF3, 0x00, 0x49, 0x00, 0x18, 0xDB, 0x5C,
+0x06, 0x94, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0x5C, 0xF4, 0x00, 0x4A, 0xDC, 0xF3,
+0x0C, 0x4B, 0x7B, 0x9B, 0x5B, 0x9A, 0x00, 0x6D, 0x69, 0xE2, 0x46, 0x32,
+0xC4, 0xF4, 0x54, 0xD9, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0xBC, 0xF3, 0x0C, 0x4A, 0x5B, 0xA2, 0x01, 0xF6, 0x01, 0x6B, 0x6B, 0xEB,
+0x50, 0x32, 0xE4, 0xF4, 0x5C, 0xD9, 0xE4, 0xF4, 0x58, 0xD9, 0x04, 0xF5,
+0x48, 0x99, 0x6C, 0xEA, 0x00, 0xF2, 0x00, 0x6B, 0x6D, 0xEA, 0x04, 0xF5,
+0x48, 0xD9, 0xA9, 0xE1, 0x01, 0x4D, 0x1D, 0x55, 0x04, 0xF5, 0x0C, 0xC2,
+0x44, 0xF5, 0x06, 0xC2, 0x24, 0xF5, 0x09, 0xC2, 0xF6, 0x61, 0x00, 0x6A,
+0x64, 0xF5, 0x44, 0xD9, 0x06, 0x94, 0x7F, 0x49, 0x15, 0x49, 0x01, 0x4C,
+0x20, 0x54, 0x06, 0xD4, 0xBF, 0x61, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4,
+0xA0, 0x35, 0x10, 0xF0, 0x02, 0x69, 0x00, 0xF4, 0x20, 0x31, 0x10, 0xF0,
+0x02, 0x68, 0x00, 0xF4, 0x00, 0x30, 0x10, 0xF0, 0x02, 0x6F, 0x00, 0xF4,
+0xE0, 0x37, 0x10, 0xF0, 0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x06, 0xD2,
+0x63, 0xF3, 0x00, 0x4D, 0x5C, 0xF4, 0x00, 0x49, 0xDC, 0xF3, 0x0C, 0x48,
+0xBC, 0xF3, 0x0C, 0x4F, 0x9C, 0xF3, 0x0C, 0x4E, 0x06, 0x93, 0x68, 0x32,
+0x2D, 0xE2, 0x60, 0x9B, 0xB1, 0xE2, 0x09, 0xE2, 0xC0, 0xF5, 0x74, 0xDC,
+0x40, 0x9A, 0x60, 0xF5, 0x40, 0xDC, 0x06, 0x94, 0xE9, 0xE4, 0x40, 0xA2,
+0xAD, 0xE4, 0x00, 0xF5, 0x44, 0xC3, 0xC9, 0xE4, 0x40, 0xA2, 0x01, 0x4C,
+0x1D, 0x54, 0x20, 0xF5, 0x5E, 0xC3, 0x06, 0xD4, 0xE7, 0x61, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4,
+0x60, 0x33, 0x00, 0x6D, 0x10, 0xF0, 0x02, 0x69, 0x00, 0xF4, 0x20, 0x31,
+0x7C, 0xF2, 0x08, 0x4A, 0x1C, 0xF1, 0x08, 0x4B, 0x06, 0xD5, 0x63, 0xF3,
+0x00, 0x49, 0x2A, 0x65, 0x0B, 0x65, 0x05, 0x67, 0x89, 0x67, 0x00, 0x6D,
+0x3D, 0xE0, 0x99, 0xE0, 0xAD, 0xE6, 0x40, 0xA3, 0xB1, 0xE7, 0x01, 0x4D,
+0xA0, 0xF3, 0x48, 0xC4, 0x80, 0xF0, 0x51, 0xA3, 0x05, 0x55, 0x20, 0xF4,
+0x59, 0xC4, 0xF4, 0x61, 0x06, 0x95, 0x48, 0x67, 0x05, 0x48, 0x4D, 0xE5,
+0x40, 0xA3, 0x31, 0xE5, 0x01, 0x4D, 0xC0, 0xF4, 0x4A, 0xC4, 0x5D, 0xA3,
+0x1D, 0x55, 0xE0, 0xF4, 0x47, 0xC4, 0x06, 0xD5, 0xE1, 0x61, 0x9D, 0x67,
+0x52, 0x6A, 0x50, 0xC4, 0x41, 0x6A, 0x51, 0xC4, 0x00, 0x6B, 0x4D, 0x6A,
+0x52, 0xC4, 0x73, 0xC4, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x7E, 0xF5, 0x00, 0x4C, 0xE0, 0xF3, 0x08, 0x6A, 0x43, 0xDC, 0xBD, 0x67,
+0x01, 0x6A, 0x10, 0xF0, 0x01, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x54, 0xC4,
+0x30, 0xF7, 0x01, 0x4E, 0x00, 0x1C, 0xCF, 0x20, 0x10, 0x4D, 0x0A, 0x97,
+0x09, 0x91, 0x08, 0x90, 0x00, 0xEF, 0x06, 0x63, 0xC9, 0xF7, 0x1B, 0x6C,
+0xF1, 0x63, 0x8B, 0xEC, 0x1B, 0xD1, 0x80, 0x31, 0x20, 0x31, 0xE1, 0xF6,
+0x80, 0x41, 0x1C, 0x62, 0x00, 0x1C, 0xFA, 0x5B, 0x1A, 0xD0, 0xD1, 0xF6,
+0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x07, 0xD2, 0x71, 0xF6, 0x80, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x08, 0xD2, 0x71, 0xF6, 0x84, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x09, 0xD2, 0x71, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x0A, 0xD2, 0x71, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x0B, 0xD2,
+0x81, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x0C, 0xD2, 0x81, 0xF6,
+0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x0D, 0xD2, 0x81, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x0E, 0xD2, 0x81, 0xF6, 0x8C, 0x41, 0xE7, 0xF7,
+0x0E, 0x68, 0x00, 0x1C, 0xFA, 0x5B, 0x0F, 0xD2, 0xD1, 0xF6, 0x80, 0x41,
+0x10, 0xD2, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x30, 0xD1, 0xF6, 0x84, 0x41,
+0x00, 0x30, 0x00, 0x1C, 0xFA, 0x5B, 0x11, 0xD2, 0xD1, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x12, 0xD2, 0xB0, 0x67, 0xE1, 0xF6, 0x80, 0x41,
+0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x13, 0xD2, 0xB0, 0x67,
+0xD1, 0xF6, 0x8C, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xB0, 0x67, 0x71, 0xF6, 0x80, 0x41, 0xF2, 0xF2, 0x1B, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67, 0x71, 0xF6, 0x84, 0x41,
+0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67,
+0x71, 0xF6, 0x88, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xB0, 0x67, 0x71, 0xF6, 0x8C, 0x41, 0xF2, 0xF2, 0x1B, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67, 0x81, 0xF6, 0x80, 0x41,
+0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67,
+0x81, 0xF6, 0x84, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xB0, 0x67, 0x81, 0xF6, 0x88, 0x41, 0xF2, 0xF2, 0x1B, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67, 0x81, 0xF6, 0x8C, 0x41,
+0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67,
+0xD1, 0xF6, 0x80, 0x41, 0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xB0, 0x67, 0xD1, 0xF6, 0x84, 0x41, 0xF2, 0xF2, 0x1B, 0x4D,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0xB0, 0x67, 0xD1, 0xF6, 0x88, 0x41,
+0xF2, 0xF2, 0x1B, 0x4D, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0x6A,
+0x04, 0xD2, 0xFF, 0x6A, 0x01, 0x4A, 0x40, 0x30, 0x00, 0xF5, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x15, 0xD2, 0x01, 0xF0, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0x00, 0x30, 0x16, 0xD2, 0x21, 0xF0,
+0x80, 0x41, 0x00, 0xF1, 0xA0, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65,
+0x21, 0xF0, 0x88, 0x41, 0x00, 0xF1, 0xA0, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0xA0, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x2A, 0xF4, 0x10, 0x4D,
+0x01, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0x1C,
+0x5B, 0x1F, 0x05, 0x6C, 0x01, 0xF0, 0x00, 0x6D, 0xA0, 0x35, 0x7F, 0x4D,
+0x01, 0xF4, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x65, 0x4D, 0x00, 0x1C,
+0x5B, 0x1F, 0x05, 0x6C, 0x8F, 0xF7, 0x00, 0x6D, 0xAB, 0xED, 0xA0, 0x35,
+0x21, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0xA0, 0x35, 0x00, 0x1C,
+0x5B, 0x1F, 0x05, 0x6C, 0x00, 0xF2, 0x14, 0x6D, 0xA0, 0x35, 0xA0, 0x35,
+0x00, 0xF1, 0x02, 0x4D, 0x41, 0xF6, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x0D, 0xF0, 0x16, 0x6D,
+0xA0, 0x35, 0xA0, 0x35, 0xC0, 0xF4, 0x02, 0x4D, 0x41, 0xF6, 0x84, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C,
+0xC5, 0xF0, 0x11, 0x6D, 0x41, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x00, 0xF2, 0x14, 0x6D,
+0xA0, 0x35, 0xA0, 0x35, 0x00, 0xF1, 0x02, 0x4D, 0x61, 0xF6, 0x80, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C,
+0x05, 0xF0, 0x16, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0x01, 0xF5, 0x05, 0x4D,
+0x61, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x65, 0x00, 0x1C,
+0x5B, 0x1F, 0x05, 0x6C, 0x41, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x15, 0x95, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x41, 0xF6, 0x88, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0x16, 0x95, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C,
+0x00, 0x1C, 0x2C, 0x1F, 0x02, 0x6C, 0x00, 0xF2, 0x00, 0x6D, 0xA0, 0x35,
+0xA0, 0x35, 0xC5, 0xF0, 0x11, 0x4D, 0x61, 0xF6, 0x8C, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x41, 0xF6,
+0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x15, 0x95, 0x00, 0x1C, 0x5B, 0x1F,
+0x05, 0x6C, 0x41, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x16, 0x95,
+0x00, 0x1C, 0x2C, 0x1F, 0x02, 0x6C, 0xA0, 0x6D, 0xA0, 0x35, 0xA0, 0x35,
+0x2A, 0xF4, 0x13, 0x4D, 0x01, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x00, 0x65, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x01, 0xF4, 0x88, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0xE4, 0x6D, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C,
+0x21, 0xF6, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x00, 0x6D, 0x21, 0xF0,
+0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0xB0, 0x67, 0x21, 0xF0, 0x88, 0x41,
+0x00, 0x1C, 0xDD, 0x5B, 0xB0, 0x67, 0xA1, 0xF6, 0x8C, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x05, 0xF0, 0x00, 0x6B, 0x6B, 0xEB, 0x60, 0x33,
+0x60, 0x33, 0x4C, 0xEB, 0x51, 0x23, 0x04, 0x95, 0x01, 0x4D, 0x0A, 0x5D,
+0x04, 0xD5, 0x3F, 0xF7, 0x04, 0x61, 0xC9, 0xF7, 0x1B, 0x68, 0x0B, 0xE8,
+0x00, 0x30, 0x00, 0x30, 0xE1, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x07, 0x95, 0xD1, 0xF6, 0x8C, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x08, 0x95,
+0x71, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x09, 0x95, 0x71, 0xF6,
+0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x0A, 0x95, 0x71, 0xF6, 0x88, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x0B, 0x95, 0x71, 0xF6, 0x8C, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x0C, 0x95, 0x81, 0xF6, 0x80, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x0D, 0x95, 0x81, 0xF6, 0x84, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x0E, 0x95,
+0x81, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x0F, 0x95, 0x81, 0xF6,
+0x8C, 0x40, 0x00, 0x1C, 0xDD, 0x5B, 0x10, 0x95, 0xD1, 0xF6, 0x80, 0x40,
+0x00, 0x1C, 0xDD, 0x5B, 0x11, 0x95, 0xD1, 0xF6, 0x84, 0x40, 0x00, 0x1C,
+0xDD, 0x5B, 0x12, 0x95, 0x81, 0xF6, 0x88, 0x40, 0x00, 0x1C, 0xDD, 0x5B,
+0x13, 0x95, 0x1C, 0x97, 0x1B, 0x91, 0x1A, 0x90, 0x00, 0xEF, 0x0F, 0x63,
+0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3,
+0x1F, 0x6B, 0x4C, 0xEB, 0x91, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x14, 0xD3, 0xE0, 0xF3, 0x1F, 0x6C, 0x80, 0x34, 0x80, 0x34, 0x8C, 0xEA,
+0x42, 0x33, 0x14, 0x92, 0x62, 0x33, 0x10, 0xF0, 0x02, 0x6D, 0x00, 0xF4,
+0xA0, 0x35, 0x58, 0xEB, 0x63, 0xF3, 0x00, 0x4D, 0x17, 0xD5, 0xE0, 0xF3,
+0x1F, 0x6D, 0x07, 0xF7, 0x00, 0x68, 0x12, 0xEC, 0x82, 0x33, 0x17, 0x94,
+0xAC, 0xEB, 0x00, 0xF4, 0x00, 0x6D, 0x43, 0x9C, 0xAB, 0xED, 0xAC, 0xEA,
+0x6D, 0xEA, 0x43, 0xDC, 0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x00, 0x30, 0x17, 0x94, 0x00, 0xF4, 0x00, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA,
+0x63, 0x9C, 0xE0, 0xF3, 0x1F, 0x6D, 0x81, 0xF4, 0x80, 0x41, 0xAC, 0xEB,
+0xA2, 0x67, 0x00, 0x1C, 0xDD, 0x5B, 0x6D, 0xED, 0x00, 0x1C, 0x5B, 0x1F,
+0x05, 0x6C, 0x91, 0xF6, 0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0xE0, 0xF3, 0x1F, 0x6B, 0x60, 0x33, 0x60, 0x33, 0x6C, 0xEA, 0x14, 0x93,
+0x42, 0x32, 0x42, 0x32, 0x78, 0xEA, 0xE0, 0xF3, 0x1F, 0x6C, 0x80, 0x33,
+0x17, 0x94, 0x06, 0xD2, 0x43, 0x9C, 0x12, 0xED, 0xAC, 0xEB, 0x10, 0x6D,
+0xAB, 0xED, 0xA0, 0x35, 0xA0, 0x35, 0xE0, 0xF3, 0x1F, 0x4D, 0x68, 0x33,
+0xAC, 0xEA, 0x6D, 0xEA, 0x43, 0xDC, 0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x3F, 0x6B, 0x6B, 0xEB, 0x17, 0x94, 0x60, 0x33,
+0x60, 0x33, 0xFF, 0x4B, 0x6C, 0xEA, 0x63, 0x9C, 0xE0, 0xF3, 0x1F, 0x6D,
+0x3F, 0x6C, 0x62, 0x33, 0x6A, 0x33, 0xAC, 0xEB, 0x8C, 0xEB, 0x60, 0x33,
+0x60, 0x33, 0xA2, 0x67, 0x81, 0xF4, 0x80, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x6D, 0xED, 0x91, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x02, 0xF0, 0x00, 0x6D, 0x06, 0x93, 0xA0, 0x35, 0xA0, 0x35, 0xFF, 0x4D,
+0xC0, 0xF3, 0x00, 0x6C, 0xAC, 0xEA, 0x8C, 0xEB, 0xA2, 0x67, 0x06, 0xD3,
+0x80, 0xF5, 0x60, 0x33, 0x91, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x6D, 0xED, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x11, 0xF4, 0x84, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xA1, 0xF6, 0x84, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x05, 0xD2, 0xE0, 0xF3, 0x1F, 0x6D, 0xA0, 0x35, 0xA0, 0x35,
+0xAC, 0xEA, 0x42, 0x33, 0x05, 0x92, 0x00, 0xF4, 0x00, 0x6C, 0x8B, 0xEC,
+0x62, 0x33, 0x8C, 0xEA, 0x6D, 0xEA, 0x11, 0xF4, 0x84, 0x41, 0xA2, 0x67,
+0x00, 0x1C, 0xDD, 0x5B, 0x05, 0xD2, 0xA1, 0xF6, 0x8C, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0x01, 0x6B, 0x6B, 0xEB, 0x05, 0x95, 0x60, 0x33,
+0x60, 0x33, 0xE0, 0xF3, 0x1F, 0x4B, 0x0C, 0xEA, 0x6C, 0xED, 0x5A, 0x32,
+0x05, 0xD5, 0x11, 0xF4, 0x84, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x4D, 0xED,
+0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3, 0x1F, 0x6C, 0x4C, 0xEC, 0x14, 0xD4,
+0xB1, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3,
+0x1F, 0x6D, 0xA0, 0x35, 0xA0, 0x35, 0xAC, 0xEA, 0x42, 0x33, 0x62, 0x33,
+0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x18, 0xD3, 0x18, 0x93,
+0x14, 0x94, 0x98, 0xEB, 0xE0, 0xF3, 0x1F, 0x6B, 0x12, 0xED, 0xA2, 0x34,
+0x17, 0x95, 0x6C, 0xEC, 0x63, 0x9D, 0x00, 0xF4, 0x00, 0x6D, 0xAB, 0xED,
+0xAC, 0xEB, 0x8D, 0xEB, 0x17, 0x94, 0xAC, 0xEA, 0xE0, 0xF3, 0x1F, 0x6D,
+0x63, 0xDC, 0xAC, 0xEB, 0xA2, 0x67, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C,
+0xDD, 0x5B, 0x6D, 0xED, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0xB1, 0xF6,
+0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0xE0, 0xF3, 0x1F, 0x6B,
+0x60, 0x33, 0x60, 0x33, 0x6C, 0xEA, 0x14, 0x93, 0x42, 0x32, 0x42, 0x32,
+0x78, 0xEA, 0xE0, 0xF3, 0x1F, 0x6C, 0x80, 0x33, 0x17, 0x94, 0x06, 0xD2,
+0x43, 0x9C, 0x12, 0xED, 0xAC, 0xEB, 0x10, 0x6D, 0xAB, 0xED, 0xA0, 0x35,
+0xA0, 0x35, 0xE0, 0xF3, 0x1F, 0x4D, 0x68, 0x33, 0xAC, 0xEA, 0x6D, 0xEA,
+0x43, 0xDC, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65,
+0x10, 0xF0, 0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xBD, 0xF7, 0x18, 0x4B,
+0x17, 0x94, 0xA0, 0x9B, 0xE0, 0xF3, 0x1F, 0x6B, 0x4C, 0xED, 0x43, 0x9C,
+0x3F, 0x6C, 0x42, 0x32, 0x4A, 0x32, 0x6C, 0xEA, 0x8C, 0xEA, 0x40, 0x32,
+0x40, 0x32, 0x81, 0xF4, 0x88, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x4D, 0xED,
+0x91, 0xF4, 0x8C, 0x41, 0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x10, 0xF0,
+0x02, 0x6B, 0x00, 0xF4, 0x60, 0x33, 0xBD, 0xF7, 0x1C, 0x4B, 0xA0, 0x9B,
+0x06, 0x94, 0x4C, 0xED, 0xC0, 0xF3, 0x00, 0x6A, 0x4C, 0xEC, 0x80, 0xF5,
+0x80, 0x32, 0x91, 0xF4, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B, 0x4D, 0xED,
+0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x11, 0xF4, 0x8C, 0x41, 0x00, 0x1C,
+0xFA, 0x5B, 0x00, 0x65, 0xC1, 0xF6, 0x84, 0x41, 0x00, 0x1C, 0xFA, 0x5B,
+0x05, 0xD2, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0xDD, 0xF7,
+0x00, 0x4C, 0x60, 0x9C, 0x05, 0x95, 0x11, 0xF4, 0x8C, 0x41, 0x4C, 0xEB,
+0x00, 0xF4, 0x00, 0x6A, 0x4B, 0xEA, 0x62, 0x33, 0x62, 0x33, 0x4C, 0xED,
+0x6D, 0xED, 0x00, 0x1C, 0xDD, 0x5B, 0x05, 0xD5, 0xC1, 0xF6, 0x8C, 0x41,
+0x00, 0x1C, 0xFA, 0x5B, 0x00, 0x65, 0x01, 0x6C, 0x8B, 0xEC, 0x05, 0x93,
+0x80, 0x34, 0x80, 0x34, 0xE0, 0xF3, 0x1F, 0x4C, 0x8C, 0xEB, 0x4C, 0xE8,
+0xA3, 0x67, 0x1A, 0x30, 0x11, 0xF4, 0x8C, 0x41, 0x00, 0x1C, 0xDD, 0x5B,
+0x0D, 0xED, 0x00, 0x1C, 0x5B, 0x1F, 0x05, 0x6C, 0x1E, 0x16, 0x00, 0x00,
+0xFC, 0x63, 0x00, 0x6B, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x9D, 0x67, 0x26, 0xF7, 0x61, 0xC2, 0x42, 0x6A, 0x50, 0xC4, 0x43, 0x6A,
+0x51, 0xC4, 0x4E, 0x6A, 0x52, 0xC4, 0x73, 0xC4, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x9E, 0xF5, 0x18, 0x4C, 0xC0, 0xF7, 0x10, 0x6A,
+0x43, 0xDC, 0xBD, 0x67, 0x01, 0x6A, 0x10, 0xF0, 0x01, 0x6E, 0x00, 0xF4,
+0xC0, 0x36, 0x54, 0xC4, 0x13, 0xF6, 0x11, 0x4E, 0x06, 0x62, 0x00, 0x1C,
+0xCF, 0x20, 0x10, 0x4D, 0x06, 0x97, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x00,
+0xE0, 0x63, 0x3E, 0x62, 0x3C, 0xD0, 0x3D, 0xD1, 0x10, 0xF0, 0x02, 0x6D,
+0x00, 0xF4, 0xA0, 0x35, 0xC7, 0x63, 0x04, 0x04, 0xDD, 0xF7, 0x04, 0x4D,
+0x00, 0x1C, 0xF4, 0x54, 0x94, 0x6E, 0x9D, 0x67, 0x7F, 0x4C, 0x10, 0xF0,
+0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0xFF, 0x6E, 0x29, 0x4C, 0x5E, 0xF0,
+0x18, 0x4D, 0x00, 0x1C, 0xF4, 0x54, 0x09, 0x4E, 0x9D, 0x67, 0x10, 0xF0,
+0x02, 0x6D, 0x00, 0xF4, 0xA0, 0x35, 0xFF, 0x6E, 0xA0, 0xF1, 0x10, 0x4C,
+0x7E, 0xF1, 0x00, 0x4D, 0x00, 0x1C, 0xF4, 0x54, 0x09, 0x4E, 0x10, 0xF0,
+0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x00, 0x6B,
+0x63, 0xC2, 0x00, 0x68, 0xA2, 0x67, 0xFF, 0x6C, 0x08, 0x32, 0x04, 0x06,
+0xAD, 0xE2, 0xC9, 0xE2, 0x40, 0x9A, 0x01, 0x48, 0x8C, 0xE8, 0x25, 0x58,
+0x46, 0xDB, 0xF6, 0x61, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32,
+0x63, 0xF3, 0x00, 0x4A, 0x00, 0x68, 0x0A, 0x65, 0xFF, 0x69, 0x0C, 0x32,
+0x68, 0x67, 0x04, 0x04, 0x00, 0x6D, 0x7D, 0xE2, 0x99, 0xE2, 0xAD, 0xE6,
+0x80, 0xF0, 0x58, 0xA3, 0xB1, 0xE7, 0x01, 0x4D, 0xA0, 0xF0, 0x4C, 0xC4,
+0xA0, 0xF1, 0x40, 0xA3, 0x2C, 0xED, 0x08, 0x5D, 0xA0, 0xF1, 0x54, 0xC4,
+0xF2, 0x61, 0x01, 0x48, 0x2C, 0xE8, 0x21, 0x58, 0xE8, 0x61, 0xC8, 0x67,
+0x1F, 0x6A, 0xA0, 0xF2, 0x5E, 0xC6, 0x00, 0x6F, 0x01, 0x6A, 0x62, 0x9E,
+0xA0, 0xF2, 0xFF, 0xC6, 0xC0, 0xF2, 0x40, 0xC6, 0x10, 0xF0, 0x00, 0x6E,
+0xC0, 0x36, 0xC0, 0x36, 0xFF, 0x4E, 0x40, 0x6A, 0xCC, 0xEB, 0x4B, 0xEA,
+0x4C, 0xEB, 0x0C, 0x6A, 0x4D, 0xEB, 0x07, 0xF7, 0x01, 0x6A, 0x4B, 0xEA,
+0x4C, 0xEB, 0x03, 0xF0, 0x00, 0x6A, 0x4D, 0xEB, 0x07, 0xF7, 0x00, 0x6A,
+0x4B, 0xEA, 0x08, 0xF0, 0x00, 0x6C, 0x40, 0x32, 0x8B, 0xEC, 0xFF, 0x4A,
+0x80, 0x34, 0x4C, 0xEB, 0x4F, 0x44, 0x4C, 0xEB, 0x10, 0xF0, 0x00, 0x6A,
+0x4B, 0xEA, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB, 0x40, 0x6A, 0x4D, 0xEB,
+0x08, 0xF0, 0x00, 0x6D, 0x81, 0x6A, 0xAD, 0xEB, 0x4B, 0xEA, 0x4C, 0xEB,
+0xFF, 0x6A, 0x01, 0x4A, 0x4B, 0xEA, 0x40, 0x32, 0xEF, 0xF7, 0x1F, 0x4A,
+0x4C, 0xEB, 0x0C, 0xF0, 0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32,
+0xFF, 0x4A, 0x4C, 0xEB, 0x48, 0x67, 0x62, 0xDA, 0xA0, 0x35, 0x63, 0x9A,
+0x44, 0x9A, 0x80, 0x34, 0xA0, 0x35, 0xFF, 0x4C, 0xFF, 0x4D, 0xAC, 0xEA,
+0x8C, 0xEB, 0x88, 0x67, 0x44, 0xDC, 0x01, 0x6A, 0x4B, 0xEA, 0xC0, 0xF2,
+0x42, 0xC4, 0xFF, 0x6A, 0xCC, 0xEB, 0xC0, 0xF2, 0x44, 0xCC, 0x12, 0x6A,
+0xC0, 0xF2, 0xE6, 0xC4, 0x63, 0xDC, 0xC0, 0xF2, 0x47, 0xC4, 0x00, 0x1C,
+0xF6, 0x48, 0x00, 0x65, 0x39, 0x63, 0x3E, 0x97, 0x3D, 0x91, 0x3C, 0x90,
+0x00, 0xEF, 0x20, 0x63, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34,
+0x63, 0xF3, 0x00, 0x4C, 0xFF, 0xF7, 0x1F, 0x6A, 0x66, 0xF7, 0x4C, 0xDC,
+0x01, 0x6A, 0x4B, 0xEA, 0xFC, 0x63, 0x45, 0xC4, 0x1C, 0x6A, 0x06, 0x62,
+0xC0, 0xF2, 0x4F, 0xC4, 0xC0, 0xF2, 0x51, 0xC4, 0x0A, 0x6A, 0x3E, 0x6B,
+0xC0, 0xF2, 0x52, 0xC4, 0x40, 0x9C, 0xC0, 0xF2, 0x6E, 0xC4, 0xC0, 0xF2,
+0x70, 0xC4, 0x02, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA, 0x21, 0x6B, 0x6B, 0xEB,
+0x6C, 0xEA, 0x00, 0x6D, 0x40, 0xDC, 0x06, 0xF0, 0x00, 0x6A, 0xE0, 0xF2,
+0xA6, 0xC4, 0x4B, 0xEA, 0xE0, 0xF2, 0x64, 0x9C, 0x40, 0x32, 0x40, 0x32,
+0xFF, 0x4A, 0x4C, 0xEB, 0x20, 0x6A, 0xC0, 0xF2, 0x57, 0xC4, 0x08, 0xF0,
+0x00, 0x6A, 0x4B, 0xEA, 0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB,
+0x10, 0xF0, 0x00, 0x6A, 0x40, 0x32, 0x40, 0x32, 0xFF, 0x4A, 0x4C, 0xEB,
+0x20, 0x6A, 0xC0, 0xF2, 0x48, 0xCC, 0xFF, 0x6A, 0x01, 0x4A, 0xE0, 0xF2,
+0x64, 0xDC, 0xC0, 0xF2, 0x4A, 0xCC, 0x01, 0x6B, 0x00, 0xF2, 0x00, 0x6A,
+0xC0, 0xF2, 0xB6, 0xC4, 0xC0, 0xF2, 0xB4, 0xC4, 0xC0, 0xF2, 0xB5, 0xC4,
+0xC0, 0xF2, 0x4C, 0xCC, 0x61, 0xC4, 0x44, 0x6A, 0x9D, 0x67, 0x50, 0xC4,
+0x49, 0x6A, 0x51, 0xC4, 0x47, 0x6A, 0x52, 0xC4, 0xB3, 0xC4, 0x10, 0xF0,
+0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x7E, 0xF5, 0x1C, 0x4C, 0xC0, 0xF7,
+0x10, 0x6A, 0xBD, 0x67, 0x10, 0xF0, 0x01, 0x6E, 0x00, 0xF4, 0xC0, 0x36,
+0x43, 0xDC, 0x74, 0xC4, 0x93, 0xF6, 0x19, 0x4E, 0x00, 0x1C, 0xCF, 0x20,
+0x10, 0x4D, 0x06, 0x97, 0x00, 0xEF, 0x04, 0x63, 0xFA, 0x63, 0x08, 0xD0,
+0x10, 0xF0, 0x02, 0x68, 0x00, 0xF4, 0x00, 0x30, 0x63, 0xF3, 0x00, 0x48,
+0x40, 0x98, 0x11, 0x6B, 0x6B, 0xEB, 0x6C, 0xEA, 0x09, 0x6B, 0x6B, 0xEB,
+0x6C, 0xEA, 0x40, 0xD8, 0x7D, 0x67, 0x44, 0x6A, 0x50, 0xC3, 0x49, 0x6A,
+0x09, 0xD1, 0x51, 0xC3, 0x00, 0x69, 0x47, 0x6A, 0x10, 0xF0, 0x02, 0x6C,
+0x00, 0xF4, 0x80, 0x34, 0x1E, 0xF6, 0x08, 0x4C, 0x52, 0xC3, 0x33, 0xC3,
+0x14, 0x6A, 0x01, 0x6B, 0xBD, 0x67, 0x10, 0xF0, 0x01, 0x6E, 0x00, 0xF4,
+0xC0, 0x36, 0x43, 0xDC, 0x74, 0xC4, 0x10, 0x4D, 0x95, 0xF0, 0x05, 0x4E,
+0x0A, 0x62, 0x00, 0x1C, 0xCF, 0x20, 0x23, 0xC8, 0x5D, 0x67, 0x47, 0x6B,
+0x78, 0xC2, 0x7D, 0x67, 0x3B, 0x6A, 0x59, 0xC3, 0x43, 0x6A, 0x5A, 0xC3,
+0x01, 0x6A, 0x4B, 0xEA, 0x00, 0xF3, 0x44, 0xC0, 0xFF, 0x6A, 0x01, 0x4A,
+0x3B, 0xC3, 0x4B, 0xEA, 0x00, 0xF3, 0x64, 0x98, 0x40, 0x32, 0x40, 0x32,
+0xE0, 0xF0, 0x1F, 0x4A, 0x4C, 0xEB, 0x00, 0xF2, 0x00, 0x6A, 0x40, 0x32,
+0xF3, 0xF0, 0x14, 0x4A, 0x00, 0xF3, 0x4C, 0xD8, 0xFF, 0x6A, 0x01, 0x4A,
+0x40, 0x32, 0x46, 0xF0, 0x16, 0x4A, 0x00, 0xF3, 0x64, 0xD8, 0x00, 0xF3,
+0x50, 0xD8, 0x60, 0x98, 0x02, 0x6A, 0x00, 0xF3, 0x47, 0xC0, 0x05, 0x6A,
+0x4B, 0xEA, 0x00, 0x6C, 0x4C, 0xEB, 0x81, 0x6A, 0x00, 0xF3, 0x88, 0xD8,
+0x00, 0xF3, 0x94, 0xD8, 0x00, 0xF3, 0x98, 0xD8, 0x4B, 0xEA, 0x10, 0xF0,
+0x02, 0x6C, 0x00, 0xF4, 0x80, 0x34, 0x4C, 0xEB, 0xBE, 0xF5, 0x14, 0x4C,
+0xC0, 0xF7, 0x10, 0x6A, 0x60, 0xD8, 0xBD, 0x67, 0x43, 0xDC, 0x10, 0xF0,
+0x01, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0x01, 0x6A, 0x54, 0xC4, 0x55, 0xF1,
+0x09, 0x4E, 0x00, 0x1C, 0xCF, 0x20, 0x18, 0x4D, 0x4A, 0x6A, 0x00, 0xF3,
+0x5C, 0xC0, 0x45, 0x6A, 0x00, 0xF3, 0x5D, 0xC0, 0x46, 0x6A, 0x00, 0xF3,
+0x5E, 0xC0, 0x40, 0x6A, 0x00, 0xF3, 0x5F, 0xC0, 0x23, 0x6A, 0x20, 0xF3,
+0x40, 0xC0, 0x1E, 0x6A, 0x20, 0xF3, 0x41, 0xC0, 0x0A, 0x97, 0x09, 0x91,
+0x08, 0x90, 0x00, 0xEF, 0x06, 0x63, 0x00, 0x00, 0xFC, 0x63, 0x7D, 0x67,
+0x3B, 0x6A, 0x50, 0xC3, 0x43, 0x6A, 0x51, 0xC3, 0x36, 0x6A, 0x52, 0xC3,
+0x00, 0x6B, 0x5D, 0x67, 0x73, 0xC2, 0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4,
+0x40, 0x32, 0x63, 0xF3, 0x00, 0x4A, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4,
+0x80, 0x34, 0xDE, 0xF5, 0x10, 0x4C, 0xC0, 0xF2, 0x73, 0xC2, 0xC0, 0xF7,
+0x10, 0x6A, 0x43, 0xDC, 0xBD, 0x67, 0x01, 0x6A, 0x10, 0xF0, 0x01, 0x6E,
+0x00, 0xF4, 0xC0, 0x36, 0x54, 0xC4, 0x95, 0xF4, 0x05, 0x4E, 0x06, 0x62,
+0x00, 0x1C, 0xCF, 0x20, 0x10, 0x4D, 0x06, 0x97, 0x00, 0xEF, 0x04, 0x63,
+0x10, 0xF0, 0x02, 0x6A, 0x00, 0xF4, 0x40, 0x32, 0xFC, 0x63, 0x63, 0xF3,
+0x00, 0x4A, 0x01, 0x6D, 0x00, 0x6B, 0x9D, 0x67, 0x66, 0xF7, 0xB6, 0xCA,
+0x66, 0xF7, 0x74, 0xCA, 0x52, 0x6A, 0x50, 0xC4, 0x53, 0x6A, 0x51, 0xC4,
+0x54, 0x6A, 0x52, 0xC4, 0x73, 0xC4, 0x10, 0xF0, 0x02, 0x6C, 0x00, 0xF4,
+0x80, 0x34, 0x3E, 0xF6, 0x04, 0x4C, 0xE0, 0xF1, 0x14, 0x6A, 0xB4, 0xC4,
+0x10, 0xF0, 0x02, 0x6E, 0x00, 0xF4, 0xC0, 0x36, 0xBD, 0x67, 0x43, 0xDC,
+0x10, 0xF5, 0x0D, 0x4E, 0x06, 0x62, 0x00, 0x1C, 0xCF, 0x20, 0x10, 0x4D,
+0x06, 0x97, 0x00, 0xEF, 0x04, 0x63, 0x00, 0x65, 0xD8, 0xFF, 0xBD, 0x27,
+0x02, 0x80, 0x03, 0x3C, 0x20, 0x00, 0xBF, 0xAF, 0x1C, 0x00, 0xB1, 0xAF,
+0x18, 0x00, 0xB0, 0xAF, 0x74, 0xF2, 0x62, 0x24, 0x02, 0x00, 0x48, 0x90,
+0x74, 0xF2, 0x67, 0x94, 0x02, 0x80, 0x02, 0x3C, 0xD0, 0x5D, 0x42, 0x24,
+0x02, 0x00, 0x10, 0x24, 0x01, 0x80, 0x06, 0x3C, 0x21, 0x20, 0x40, 0x00,
+0x14, 0x00, 0x50, 0xA0, 0x10, 0x00, 0xA5, 0x27, 0xFC, 0xC1, 0xC6, 0x24,
+0x02, 0x80, 0x11, 0x3C, 0x20, 0x5E, 0x31, 0x26, 0x10, 0x00, 0xA7, 0xA7,
+0x12, 0x00, 0xA8, 0xA3, 0xCF, 0x20, 0x00, 0x0C, 0x13, 0x00, 0xA0, 0xA3,
+0x02, 0x80, 0x06, 0x3C, 0x21, 0x20, 0x20, 0x02, 0x10, 0x00, 0xA5, 0x27,
+0x14, 0x00, 0x30, 0xA2, 0xCF, 0x20, 0x00, 0x0C, 0x08, 0x86, 0xC6, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0xEC, 0x5D, 0x40, 0xA0, 0x0C, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0xED, 0x5D, 0x64, 0xA0,
+0xEE, 0x5D, 0x44, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0x04, 0x5E, 0x60, 0xA0, 0x06, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C,
+0x02, 0x80, 0x02, 0x3C, 0x0C, 0x5E, 0x60, 0xA0, 0x01, 0x00, 0x06, 0x24,
+0x0D, 0x5E, 0x40, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C,
+0xF0, 0x5D, 0x66, 0xA0, 0x12, 0x00, 0x04, 0x24, 0x0E, 0x5E, 0x40, 0xA0,
+0x02, 0x80, 0x03, 0x3C, 0x02, 0x80, 0x02, 0x3C, 0xEF, 0x5D, 0x66, 0xA0,
+0xF1, 0x5D, 0x44, 0xA0, 0x02, 0x80, 0x03, 0x3C, 0x0C, 0x00, 0x04, 0x24,
+0x02, 0x80, 0x02, 0x3C, 0xF2, 0x5D, 0x60, 0xA0, 0x02, 0x80, 0x05, 0x3C,
+0xFC, 0x5D, 0x44, 0xA4, 0x64, 0x00, 0x03, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0xF4, 0x5D, 0xA3, 0xA4, 0xC6, 0x5C, 0x43, 0x90, 0xF4, 0x5D, 0xA4, 0x94,
+0x02, 0x00, 0x05, 0x24, 0x02, 0x00, 0x63, 0x30, 0x01, 0x00, 0x63, 0x2C,
+0xFF, 0xFF, 0x84, 0x30, 0x23, 0x28, 0xA3, 0x00, 0x80, 0x22, 0x04, 0x00,
+0x02, 0x80, 0x02, 0x3C, 0xE8, 0x03, 0x03, 0x24, 0xF8, 0x5D, 0x44, 0xAC,
+0x0C, 0x00, 0x23, 0xAE, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x00, 0x5E, 0x40, 0xAC, 0x05, 0x5E, 0x60, 0xA0, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x07, 0x5E, 0x40, 0xA0, 0x0F, 0x5E, 0x60, 0xA0,
+0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C, 0x3C, 0x5E, 0x45, 0xA0,
+0x20, 0x00, 0xBF, 0x8F, 0x08, 0x5E, 0x60, 0xA0, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x1C, 0x00, 0xB1, 0x8F, 0x18, 0x00, 0xB0, 0x8F,
+0x09, 0x5E, 0x46, 0xA0, 0x0A, 0x5E, 0x66, 0xA0, 0x02, 0x80, 0x02, 0x3C,
+0x02, 0x80, 0x03, 0x3C, 0x0B, 0x5E, 0x40, 0xA0, 0x21, 0x20, 0x00, 0x00,
+0x10, 0x5E, 0x60, 0xAC, 0x02, 0x80, 0x02, 0x3C, 0x02, 0x80, 0x03, 0x3C,
+0x21, 0x28, 0x00, 0x00, 0x28, 0x00, 0xBD, 0x27, 0x14, 0x5E, 0x40, 0xAC,
+0x18, 0x5E, 0x64, 0xAC, 0x1C, 0x5E, 0x65, 0xAC, 0x08, 0x00, 0xE0, 0x03,
+0x00, 0x00, 0x00, 0x00, 0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x21, 0x98, 0xA0, 0x00,
+0x21, 0x88, 0xC0, 0x00, 0x21, 0x90, 0x00, 0x00, 0x00, 0x00, 0x04, 0x82,
+0x5C, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x10, 0x26, 0xFF, 0xFF, 0x10, 0x26, 0x00, 0x00, 0x04, 0x92,
+0x2B, 0x00, 0x02, 0x24, 0x00, 0x1E, 0x04, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x41, 0x00, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x24,
+0x30, 0x00, 0x22, 0x12, 0x00, 0x1E, 0x04, 0x00, 0x07, 0x00, 0x20, 0x16,
+0x21, 0x18, 0x80, 0x00, 0x00, 0x1E, 0x04, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x30, 0x00, 0x02, 0x24, 0x3B, 0x00, 0x62, 0x10, 0x0A, 0x00, 0x11, 0x24,
+0x21, 0x18, 0x80, 0x00, 0x00, 0x16, 0x03, 0x00, 0x03, 0x16, 0x02, 0x00,
+0x1A, 0x00, 0x40, 0x10, 0xFF, 0x00, 0x64, 0x30, 0xA9, 0xFF, 0x82, 0x24,
+0x61, 0x00, 0x83, 0x2C, 0xFF, 0x00, 0x45, 0x30, 0x09, 0x00, 0x60, 0x10,
+0x41, 0x00, 0x86, 0x2C, 0xC9, 0xFF, 0x82, 0x24, 0xFF, 0x00, 0x45, 0x30,
+0x05, 0x00, 0xC0, 0x10, 0x3A, 0x00, 0x87, 0x2C, 0xD0, 0xFF, 0x82, 0x24,
+0x02, 0x00, 0xE0, 0x10, 0xFF, 0x00, 0x05, 0x24, 0xFF, 0x00, 0x45, 0x30,
+0x2A, 0x10, 0xB1, 0x00, 0x0A, 0x00, 0x40, 0x10, 0x18, 0x00, 0x51, 0x02,
+0x01, 0x00, 0x10, 0x26, 0x12, 0x10, 0x00, 0x00, 0x2B, 0x18, 0x52, 0x00,
+0x23, 0x00, 0x60, 0x14, 0x21, 0x90, 0xA2, 0x00, 0x00, 0x00, 0x03, 0x92,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0xFF, 0x60, 0x14, 0xFF, 0x00, 0x64, 0x30,
+0x02, 0x00, 0x60, 0x12, 0x21, 0x10, 0x40, 0x02, 0x00, 0x00, 0x70, 0xAE,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0x08, 0x00, 0xE0, 0x03,
+0x28, 0x00, 0xBD, 0x27, 0x03, 0x1E, 0x03, 0x00, 0x30, 0x00, 0x02, 0x24,
+0xCE, 0xFF, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x82,
+0x78, 0x00, 0x02, 0x24, 0x03, 0x00, 0x62, 0x10, 0x58, 0x00, 0x02, 0x24,
+0xD0, 0xFF, 0x62, 0x14, 0x21, 0x18, 0x80, 0x00, 0x02, 0x00, 0x10, 0x26,
+0x00, 0x00, 0x04, 0x92, 0x63, 0x71, 0x00, 0x08, 0x10, 0x00, 0x11, 0x24,
+0x01, 0x00, 0x10, 0x26, 0x00, 0x00, 0x04, 0x92, 0x5A, 0x71, 0x00, 0x08,
+0x10, 0x00, 0x02, 0x24, 0x8F, 0x71, 0x00, 0x08, 0x08, 0x00, 0x11, 0x24,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xFF, 0xFF, 0x02, 0x24,
+0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27, 0x21, 0x48, 0x80, 0x00,
+0x31, 0x00, 0xC0, 0x14, 0x21, 0x50, 0x00, 0x00, 0x00, 0x00, 0x87, 0x90,
+0x30, 0x00, 0x02, 0x24, 0x00, 0x1E, 0x07, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x2E, 0x00, 0x62, 0x10, 0x0A, 0x00, 0x06, 0x24, 0x02, 0x80, 0x02, 0x3C,
+0x40, 0xF4, 0x4B, 0x24, 0xFF, 0x00, 0xE8, 0x30, 0x21, 0x10, 0x0B, 0x01,
+0x00, 0x00, 0x44, 0x90, 0x00, 0x1E, 0x07, 0x00, 0x03, 0x1E, 0x03, 0x00,
+0x44, 0x00, 0x82, 0x30, 0x02, 0x00, 0x87, 0x30, 0xD0, 0xFF, 0x63, 0x24,
+0x1A, 0x00, 0x40, 0x10, 0x04, 0x00, 0x84, 0x30, 0x07, 0x00, 0x80, 0x14,
+0x2B, 0x10, 0x66, 0x00, 0x21, 0x10, 0x00, 0x01, 0x02, 0x00, 0xE0, 0x10,
+0xE0, 0xFF, 0x03, 0x25, 0xFF, 0x00, 0x62, 0x30, 0xC9, 0xFF, 0x43, 0x24,
+0x2B, 0x10, 0x66, 0x00, 0x10, 0x00, 0x40, 0x10, 0x18, 0x00, 0x46, 0x01,
+0x01, 0x00, 0x29, 0x25, 0x00, 0x00, 0x27, 0x91, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0x00, 0xE8, 0x30, 0x12, 0x10, 0x00, 0x00, 0x21, 0x50, 0x43, 0x00,
+0x21, 0x10, 0x0B, 0x01, 0x00, 0x00, 0x44, 0x90, 0x00, 0x1E, 0x07, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0x44, 0x00, 0x82, 0x30, 0x02, 0x00, 0x87, 0x30,
+0xD0, 0xFF, 0x63, 0x24, 0xE8, 0xFF, 0x40, 0x14, 0x04, 0x00, 0x84, 0x30,
+0x02, 0x00, 0xA0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA9, 0xAC,
+0x08, 0x00, 0xE0, 0x03, 0x21, 0x10, 0x40, 0x01, 0x00, 0x00, 0x87, 0x90,
+0xB1, 0x71, 0x00, 0x08, 0x02, 0x80, 0x02, 0x3C, 0x01, 0x00, 0x89, 0x24,
+0x00, 0x00, 0x27, 0x91, 0x78, 0x00, 0x02, 0x24, 0x00, 0x1E, 0x07, 0x00,
+0x03, 0x1E, 0x03, 0x00, 0xCD, 0xFF, 0x62, 0x14, 0x08, 0x00, 0x06, 0x24,
+0x01, 0x00, 0x22, 0x91, 0x02, 0x80, 0x03, 0x3C, 0x40, 0xF4, 0x63, 0x24,
+0x21, 0x10, 0x43, 0x00, 0x00, 0x00, 0x44, 0x90, 0x00, 0x00, 0x00, 0x00,
+0x44, 0x00, 0x84, 0x30, 0xC5, 0xFF, 0x80, 0x10, 0x02, 0x80, 0x02, 0x3C,
+0x01, 0x00, 0x29, 0x25, 0x00, 0x00, 0x27, 0x91, 0xB1, 0x71, 0x00, 0x08,
+0x10, 0x00, 0x06, 0x24, 0xE8, 0xFF, 0xBD, 0x27, 0x10, 0x00, 0xBF, 0xAF,
+0x00, 0x00, 0x83, 0x80, 0x2D, 0x00, 0x02, 0x24, 0x04, 0x00, 0x62, 0x10,
+0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0xBF, 0x8F, 0xA7, 0x71, 0x00, 0x08,
+0x18, 0x00, 0xBD, 0x27, 0xA7, 0x71, 0x00, 0x0C, 0x01, 0x00, 0x84, 0x24,
+0x10, 0x00, 0xBF, 0x8F, 0x23, 0x10, 0x02, 0x00, 0x08, 0x00, 0xE0, 0x03,
+0x18, 0x00, 0xBD, 0x27, 0xD8, 0xFF, 0xBD, 0x27, 0x1C, 0x00, 0xB3, 0xAF,
+0x18, 0x00, 0xB2, 0xAF, 0x14, 0x00, 0xB1, 0xAF, 0x10, 0x00, 0xB0, 0xAF,
+0x20, 0x00, 0xBF, 0xAF, 0x21, 0x80, 0x80, 0x00, 0x21, 0x90, 0xA0, 0x00,
+0x21, 0x98, 0xC0, 0x00, 0x21, 0x88, 0x00, 0x00, 0x00, 0x00, 0x04, 0x82,
+0x5C, 0x58, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x40, 0x14,
+0x01, 0x00, 0x10, 0x26, 0xFF, 0xFF, 0x10, 0x26, 0x00, 0x00, 0x03, 0x82,
+0x2D, 0x00, 0x02, 0x24, 0x0F, 0x00, 0x62, 0x10, 0x21, 0x20, 0x00, 0x02,
+0x21, 0x28, 0x40, 0x02, 0x43, 0x71, 0x00, 0x0C, 0x21, 0x30, 0x60, 0x02,
+0x12, 0x00, 0x40, 0x04, 0x21, 0x18, 0x40, 0x00, 0x23, 0x10, 0x02, 0x00,
+0x0A, 0x10, 0x71, 0x00, 0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F,
+0x18, 0x00, 0xB2, 0x8F, 0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F,
+0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27, 0x01, 0x00, 0x10, 0x26,
+0x21, 0x20, 0x00, 0x02, 0x21, 0x28, 0x40, 0x02, 0x43, 0x71, 0x00, 0x0C,
+0x21, 0x30, 0x60, 0x02, 0xFF, 0xFF, 0x11, 0x24, 0xF0, 0xFF, 0x41, 0x04,
+0x21, 0x18, 0x40, 0x00, 0xF0, 0xFF, 0x20, 0x16, 0x00, 0x80, 0x02, 0x3C,
+0x20, 0x00, 0xBF, 0x8F, 0x1C, 0x00, 0xB3, 0x8F, 0x18, 0x00, 0xB2, 0x8F,
+0x14, 0x00, 0xB1, 0x8F, 0x10, 0x00, 0xB0, 0x8F, 0xFF, 0x7F, 0x02, 0x3C,
+0xFF, 0xFF, 0x42, 0x34, 0x08, 0x00, 0xE0, 0x03, 0x28, 0x00, 0xBD, 0x27,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x00, 0x7F,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x01, 0x7F, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x02, 0x7E, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x03, 0x7D,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x04, 0x7C, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x05, 0x7B, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x06, 0x7A,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x07, 0x79, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x08, 0x78, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x09, 0x77,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x0A, 0x76, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x0B, 0x75, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x0C, 0x74,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x0D, 0x73, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x0E, 0x72, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x0F, 0x71,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x10, 0x70, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x11, 0x6F, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x12, 0x6F,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x13, 0x6E, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x14, 0x6D, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x15, 0x6D,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x16, 0x6C, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x17, 0x6B, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x18, 0x6A,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x19, 0x6A, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x1A, 0x69, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x1B, 0x68,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x1C, 0x67, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x1D, 0x66, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x1E, 0x65,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x1F, 0x64, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x20, 0x63, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x21, 0x4C,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x22, 0x4B, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x23, 0x4A, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x24, 0x49,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x25, 0x48, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x26, 0x47, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x27, 0x46,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x28, 0x45, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x29, 0x44, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x2A, 0x2C,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x2B, 0x2B, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x2C, 0x2A, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x2D, 0x29,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x2E, 0x28, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x2F, 0x27, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x30, 0x26,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x31, 0x25, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x32, 0x24, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x33, 0x23,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x34, 0x22, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x35, 0x09, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x36, 0x08,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x37, 0x07, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x38, 0x06, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x39, 0x05,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x3A, 0x04, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x3B, 0x03, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x3C, 0x02,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x3D, 0x01, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x3E, 0x00, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x3F, 0x00,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x40, 0x7F, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x41, 0x7F, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x42, 0x7E,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x43, 0x7D, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x44, 0x7C, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x45, 0x7B,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x46, 0x7A, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x47, 0x79, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x48, 0x78,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x49, 0x77, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x4A, 0x76, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x4B, 0x75,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x4C, 0x74, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x4D, 0x73, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x4E, 0x72,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x4F, 0x71, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x50, 0x70, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x51, 0x6F,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x52, 0x6F, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x53, 0x6E, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x54, 0x6D,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x55, 0x6D, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x56, 0x6C, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x57, 0x6B,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x58, 0x6A, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x59, 0x6A, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x5A, 0x69,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x5B, 0x68, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x5C, 0x67, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x5D, 0x66,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x5E, 0x65, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x5F, 0x64, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x60, 0x63,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x61, 0x4C, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x62, 0x4B, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x63, 0x4A,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x64, 0x49, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x65, 0x48, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x66, 0x47,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x67, 0x46, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x68, 0x45, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x69, 0x44,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x6A, 0x2C, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x6B, 0x2B, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x6C, 0x2A,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x6D, 0x29, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x6E, 0x28, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x6F, 0x27,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x70, 0x26, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x71, 0x25, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x72, 0x24,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x73, 0x23, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x74, 0x22, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x75, 0x09,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x76, 0x08, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x77, 0x07, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x78, 0x06,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x79, 0x05, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x7A, 0x04, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x7B, 0x03,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x7C, 0x02, 0x78, 0x0C, 0x00, 0x00,
+0x01, 0x00, 0x7D, 0x01, 0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x7E, 0x00,
+0x78, 0x0C, 0x00, 0x00, 0x01, 0x00, 0x7F, 0x00, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x00, 0x30, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x01, 0x30,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x02, 0x30, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x03, 0x30, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x04, 0x30,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x05, 0x34, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x06, 0x38, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x07, 0x3E,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x08, 0x3E, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x09, 0x44, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x0A, 0x46,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x0B, 0x48, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x0C, 0x48, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x0D, 0x4E,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x0E, 0x56, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x0F, 0x5A, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x10, 0x5E,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x11, 0x62, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x12, 0x6C, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x13, 0x72,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x14, 0x72, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x15, 0x72, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x16, 0x72,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x17, 0x72, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x18, 0x72, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x19, 0x72,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x1A, 0x72, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x1B, 0x72, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x1C, 0x72,
+0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x1D, 0x72, 0x78, 0x0C, 0x00, 0x00,
+0x1E, 0x00, 0x1E, 0x72, 0x78, 0x0C, 0x00, 0x00, 0x1E, 0x00, 0x1F, 0x72,
+0x00, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x06, 0x06, 0x04,
+0x04, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x02, 0x02, 0x00,
+0x08, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x08, 0x08, 0x04,
+0x14, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x02, 0x02, 0x00,
+0x18, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x0A, 0x08, 0x08, 0x04,
+0x1C, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0x02, 0x02, 0x00,
+0x00, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x0E, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x14, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x18, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x1C, 0x0E, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
+0x04, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+0x24, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x04, 0x00, 0x30, 0x00,
+0x2C, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x04, 0x00, 0x30, 0x00,
+0x70, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
+0x64, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+0x78, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x02, 0x00, 0x02, 0x00,
+0x74, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00,
+0x78, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00,
+0x7C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00,
+0x80, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x06, 0x00, 0x00, 0x00,
+0x0C, 0x09, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+0x04, 0x0C, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+0x04, 0x0D, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+0xF4, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
+0x34, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x13, 0x00, 0x00, 0x00,
+0x04, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+0x24, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x04, 0x00, 0x30, 0x00,
+0x2C, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x02, 0x00, 0x30, 0x00,
+0x70, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
+0x64, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x78, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x02, 0x00, 0x00, 0x00,
+0x74, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x78, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x7C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x80, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x0C, 0x09, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
+0x04, 0x0C, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+0x04, 0x0D, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+0xF4, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x77, 0x77, 0x00, 0x00,
+0x34, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0A, 0x00, 0x00, 0x00,
+0x44, 0x08, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00,
+0x04, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+0x24, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x04, 0x00, 0x30, 0x00,
+0x2C, 0x08, 0x00, 0x00, 0x0F, 0x00, 0xF0, 0x00, 0x02, 0x00, 0x10, 0x00,
+0x70, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00,
+0x64, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x78, 0x08, 0x00, 0x00, 0x0F, 0x00, 0x0F, 0x00, 0x02, 0x00, 0x00, 0x00,
+0x74, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x78, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x7C, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x80, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x02, 0x00, 0x00, 0x00,
+0x0C, 0x09, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
+0x04, 0x0C, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
+0x04, 0x0D, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+0xF4, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x77, 0x77, 0x00, 0x00,
+0x34, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x0A, 0x00, 0x00, 0x00,
+0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00,
+0x00, 0x00, 0x04, 0x00, 0x04, 0x08, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00,
+0x08, 0x08, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x0C, 0x08, 0x00, 0x00,
+0x0A, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x88, 0x50, 0x00, 0x10,
+0x14, 0x08, 0x00, 0x00, 0x10, 0x3D, 0x0C, 0x02, 0x18, 0x08, 0x00, 0x00,
+0x85, 0x01, 0x20, 0x00, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x20, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x24, 0x08, 0x00, 0x00,
+0x04, 0x00, 0x39, 0x00, 0x28, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+0x2C, 0x08, 0x00, 0x00, 0x04, 0x00, 0x39, 0x00, 0x30, 0x08, 0x00, 0x00,
+0x04, 0x00, 0x00, 0x00, 0x34, 0x08, 0x00, 0x00, 0x00, 0x02, 0x69, 0x00,
+0x38, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3C, 0x08, 0x00, 0x00,
+0x00, 0x02, 0x69, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+0x44, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x48, 0x08, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x4C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x50, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x08, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x58, 0x08, 0x00, 0x00, 0x48, 0x48, 0x48, 0x48,
+0x5C, 0x08, 0x00, 0x00, 0xA9, 0x65, 0xA9, 0x65, 0x60, 0x08, 0x00, 0x00,
+0x30, 0x01, 0x7F, 0x0F, 0x64, 0x08, 0x00, 0x00, 0x30, 0x01, 0x7F, 0x0F,
+0x68, 0x08, 0x00, 0x00, 0x30, 0x01, 0x7F, 0x0F, 0x6C, 0x08, 0x00, 0x00,
+0x30, 0x01, 0x7F, 0x0F, 0x70, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x03,
+0x74, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x78, 0x08, 0x00, 0x00,
+0x02, 0x00, 0x02, 0x00, 0x7C, 0x08, 0x00, 0x00, 0x01, 0x02, 0x4F, 0x00,
+0x80, 0x08, 0x00, 0x00, 0xC1, 0x0A, 0x30, 0xA8, 0x84, 0x08, 0x00, 0x00,
+0x58, 0x00, 0x00, 0x00, 0x88, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+0x8C, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x90, 0x08, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x94, 0x08, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF,
+0x98, 0x08, 0x00, 0x00, 0x10, 0x20, 0x30, 0x40, 0x9C, 0x08, 0x00, 0x00,
+0x50, 0x60, 0x70, 0x00, 0xB0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xE0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x08, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x33, 0x33, 0x33, 0x30,
+0x04, 0x0E, 0x00, 0x00, 0x2F, 0x2E, 0x2D, 0x2A, 0x08, 0x0E, 0x00, 0x00,
+0x32, 0x32, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, 0x33, 0x33, 0x33, 0x30,
+0x14, 0x0E, 0x00, 0x00, 0x2F, 0x2E, 0x2D, 0x2A, 0x18, 0x0E, 0x00, 0x00,
+0x33, 0x33, 0x33, 0x30, 0x1C, 0x0E, 0x00, 0x00, 0x2F, 0x2E, 0x2D, 0x2A,
+0x30, 0x0E, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x01, 0x34, 0x0E, 0x00, 0x00,
+0x00, 0x48, 0x00, 0x01, 0x38, 0x0E, 0x00, 0x00, 0x1F, 0xDC, 0x00, 0x10,
+0x3C, 0x0E, 0x00, 0x00, 0x1F, 0x8C, 0x00, 0x10, 0x40, 0x0E, 0x00, 0x00,
+0xA0, 0x00, 0x14, 0x02, 0x44, 0x0E, 0x00, 0x00, 0xA0, 0x00, 0x16, 0x28,
+0x48, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0xF8, 0x4C, 0x0E, 0x00, 0x00,
+0x10, 0x29, 0x00, 0x00, 0x50, 0x0E, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x01,
+0x54, 0x0E, 0x00, 0x00, 0x00, 0x48, 0x00, 0x01, 0x58, 0x0E, 0x00, 0x00,
+0x1F, 0xDC, 0x00, 0x10, 0x5C, 0x0E, 0x00, 0x00, 0x1F, 0x8C, 0x00, 0x10,
+0x60, 0x0E, 0x00, 0x00, 0xA0, 0x00, 0x14, 0x02, 0x64, 0x0E, 0x00, 0x00,
+0xA0, 0x00, 0x16, 0x28, 0x6C, 0x0E, 0x00, 0x00, 0x10, 0x29, 0x00, 0x00,
+0x70, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0xED, 0x31, 0x74, 0x0E, 0x00, 0x00,
+0xFB, 0x36, 0x15, 0x36, 0x78, 0x0E, 0x00, 0x00, 0xFB, 0x36, 0x15, 0x36,
+0x7C, 0x0E, 0x00, 0x00, 0xFB, 0x36, 0x15, 0x36, 0x80, 0x0E, 0x00, 0x00,
+0xFB, 0x36, 0x15, 0x36, 0x84, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0x0D, 0x00,
+0x88, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0x0D, 0x00, 0x8C, 0x0E, 0x00, 0x00,
+0xFB, 0x92, 0xED, 0x31, 0xD0, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0xED, 0x31,
+0xD4, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0xED, 0x31, 0xD8, 0x0E, 0x00, 0x00,
+0xFB, 0x92, 0x0D, 0x00, 0xDC, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0x0D, 0x00,
+0xE0, 0x0E, 0x00, 0x00, 0xFB, 0x92, 0x0D, 0x00, 0xE4, 0x0E, 0x00, 0x00,
+0x48, 0x54, 0x5E, 0x01, 0xE8, 0x0E, 0x00, 0x00, 0x48, 0x54, 0x55, 0x21,
+0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x09, 0x00, 0x00,
+0x23, 0x00, 0x00, 0x00, 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x0C, 0x09, 0x00, 0x00, 0x13, 0x13, 0x12, 0x01, 0x00, 0x0A, 0x00, 0x00,
+0xC8, 0x47, 0xD0, 0x00, 0x04, 0x0A, 0x00, 0x00, 0x08, 0x00, 0xFF, 0x80,
+0x08, 0x0A, 0x00, 0x00, 0x00, 0x83, 0xCD, 0x88, 0x0C, 0x0A, 0x00, 0x00,
+0x0F, 0x12, 0x62, 0x2E, 0x10, 0x0A, 0x00, 0x00, 0x78, 0xBB, 0x00, 0x95,
+0x14, 0x0A, 0x00, 0x00, 0x28, 0x40, 0x14, 0x11, 0x18, 0x0A, 0x00, 0x00,
+0x17, 0x11, 0x88, 0x00, 0x1C, 0x0A, 0x00, 0x00, 0x00, 0x0F, 0x14, 0x89,
+0x20, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x1A, 0x24, 0x0A, 0x00, 0x00,
+0x17, 0x13, 0x0E, 0x09, 0x28, 0x0A, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00,
+0x2C, 0x0A, 0x00, 0x00, 0x00, 0x00, 0xD3, 0x10, 0x00, 0x0C, 0x00, 0x00,
+0x40, 0x1D, 0x07, 0x40, 0x04, 0x0C, 0x00, 0x00, 0x33, 0x56, 0xA0, 0x00,
+0x08, 0x0C, 0x00, 0x00, 0xE4, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00,
+0x6C, 0x6C, 0x6C, 0x6C, 0x10, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08,
+0x14, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x18, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x08, 0x1C, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40,
+0x20, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x24, 0x0C, 0x00, 0x00,
+0x00, 0x01, 0x00, 0x40, 0x28, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+0x2C, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x30, 0x0C, 0x00, 0x00,
+0x44, 0xAC, 0xE9, 0x6D, 0x34, 0x0C, 0x00, 0x00, 0xCF, 0x52, 0x96, 0x46,
+0x38, 0x0C, 0x00, 0x00, 0x94, 0x59, 0x79, 0x49, 0x3C, 0x0C, 0x00, 0x00,
+0x64, 0x97, 0x97, 0x0A, 0x40, 0x0C, 0x00, 0x00, 0x3F, 0x40, 0x7C, 0x1F,
+0x44, 0x0C, 0x00, 0x00, 0xB7, 0x00, 0x01, 0x00, 0x48, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x02, 0xEC, 0x4C, 0x0C, 0x00, 0x00, 0x7F, 0x03, 0x7F, 0x00,
+0x50, 0x0C, 0x00, 0x00, 0x20, 0x34, 0x54, 0x69, 0x54, 0x0C, 0x00, 0x00,
+0x94, 0x00, 0x3C, 0x43, 0x58, 0x0C, 0x00, 0x00, 0x20, 0x34, 0x54, 0x69,
+0x5C, 0x0C, 0x00, 0x00, 0x94, 0x00, 0x3C, 0x43, 0x60, 0x0C, 0x00, 0x00,
+0x20, 0x34, 0x54, 0x69, 0x64, 0x0C, 0x00, 0x00, 0x94, 0x00, 0x3C, 0x43,
+0x68, 0x0C, 0x00, 0x00, 0x20, 0x34, 0x54, 0x69, 0x6C, 0x0C, 0x00, 0x00,
+0x94, 0x00, 0x3C, 0x43, 0x70, 0x0C, 0x00, 0x00, 0x0D, 0x00, 0x7F, 0x2C,
+0x74, 0x0C, 0x00, 0x00, 0x5B, 0x17, 0x86, 0x01, 0x78, 0x0C, 0x00, 0x00,
+0x1F, 0x00, 0x00, 0x00, 0x7C, 0x0C, 0x00, 0x00, 0x12, 0x16, 0xB9, 0x00,
+0x80, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x84, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0xF6, 0x20, 0x88, 0x0C, 0x00, 0x00, 0x80, 0x00, 0x00, 0x20,
+0x8C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x90, 0x0C, 0x00, 0x00,
+0x00, 0x01, 0x00, 0x40, 0x94, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x98, 0x0C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x40, 0x9C, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xA0, 0x0C, 0x00, 0x00, 0x92, 0x24, 0x49, 0x00,
+0xA4, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xAC, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xB0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB4, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xB8, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xBC, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xC0, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xC4, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xC8, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xD0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xD4, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x0C, 0x00, 0x00,
+0x27, 0x24, 0xB2, 0x64, 0xDC, 0x0C, 0x00, 0x00, 0x32, 0x69, 0x76, 0x00,
+0xE0, 0x0C, 0x00, 0x00, 0x22, 0x22, 0x22, 0x00, 0xE4, 0x0C, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xE8, 0x0C, 0x00, 0x00, 0x02, 0x43, 0x64, 0x37,
+0xEC, 0x0C, 0x00, 0x00, 0x0C, 0xD4, 0x97, 0x2F, 0x00, 0x0D, 0x00, 0x00,
+0x50, 0x07, 0x00, 0x00, 0x04, 0x0D, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00,
+0x08, 0x0D, 0x00, 0x00, 0x7F, 0x90, 0x00, 0x00, 0x0C, 0x0D, 0x00, 0x00,
+0x01, 0x00, 0x00, 0x00, 0x10, 0x0D, 0x00, 0x00, 0x33, 0x33, 0x63, 0xA0,
+0x14, 0x0D, 0x00, 0x00, 0x63, 0x3C, 0x33, 0x33, 0x18, 0x0D, 0x00, 0x00,
+0x6B, 0x5B, 0x8F, 0x6A, 0x1C, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x20, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x0D, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x28, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x2C, 0x0D, 0x00, 0x00, 0x75, 0x99, 0x97, 0xCC, 0x30, 0x0D, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x34, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x38, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x0D, 0x00, 0x00,
+0x93, 0x72, 0x02, 0x00, 0x40, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x44, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x0D, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x50, 0x0D, 0x00, 0x00, 0x0A, 0x14, 0x37, 0x64,
+0x54, 0x0D, 0x00, 0x00, 0x02, 0xBD, 0x4D, 0x02, 0x58, 0x0D, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x5C, 0x0D, 0x00, 0x00, 0x64, 0x20, 0x03, 0x30,
+0x60, 0x0D, 0x00, 0x00, 0x68, 0xDE, 0x53, 0x46, 0x64, 0x0D, 0x00, 0x00,
+0x3C, 0x8A, 0x51, 0x00, 0x68, 0x0D, 0x00, 0x00, 0x01, 0x21, 0x00, 0x00,
+0x14, 0x0F, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x4C, 0x0F, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
+0x10, 0x00, 0x00, 0x00, 0x84, 0x02, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00,
+0xB4, 0x02, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x01, 0x80,
+0x10, 0x00, 0x00, 0x00, 0xC8, 0x08, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00,
+0xD0, 0x08, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0xD8, 0x08, 0x01, 0x80,
+0x10, 0x00, 0x00, 0x00, 0xB0, 0x08, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00,
+0xB8, 0x08, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0x10, 0x09, 0x01, 0x80,
+0x10, 0x00, 0x00, 0x00, 0x18, 0x09, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00,
+0x58, 0x04, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0x50, 0x04, 0x01, 0x80,
+0x10, 0x00, 0x00, 0x00, 0x20, 0x09, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00,
+0x28, 0x09, 0x01, 0x80, 0x74, 0x03, 0x00, 0x00, 0xF0, 0x28, 0x00, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x88, 0x06, 0x01, 0x80, 0x74, 0x03, 0x00, 0x00,
+0xF0, 0x28, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0xAC, 0x2B, 0x00, 0x80,
+0x30, 0x00, 0x00, 0x00, 0x58, 0x2C, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00,
+0x1C, 0x2F, 0x00, 0x80, 0x13, 0x00, 0x00, 0x00, 0x7C, 0x07, 0x01, 0x80,
+0x17, 0x00, 0x00, 0x00, 0xD0, 0x07, 0x01, 0x80, 0x06, 0x00, 0x00, 0x00,
+0x58, 0x08, 0x01, 0x80, 0x06, 0x00, 0x00, 0x00, 0x60, 0x08, 0x01, 0x80,
+0x08, 0x00, 0x00, 0x00, 0x68, 0x08, 0x01, 0x80, 0x0C, 0x00, 0x00, 0x00,
+0x70, 0x08, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0x78, 0x08, 0x01, 0x80,
+0x0E, 0x00, 0x00, 0x00, 0x80, 0x08, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00,
+0x88, 0x08, 0x01, 0x80, 0x38, 0x00, 0x00, 0x00, 0x90, 0x08, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x98, 0x08, 0x01, 0x80, 0x02, 0x00, 0x00, 0x00,
+0xA0, 0x08, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0xA8, 0x08, 0x01, 0x80,
+0x01, 0x00, 0x00, 0x00, 0xE8, 0x08, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00,
+0xF0, 0x08, 0x01, 0x80, 0x0C, 0x00, 0x00, 0x00, 0x60, 0x04, 0x01, 0x80,
+0x0E, 0x00, 0x00, 0x00, 0x68, 0x04, 0x01, 0x80, 0x0C, 0x00, 0x00, 0x00,
+0x80, 0x06, 0x01, 0x80, 0x34, 0x00, 0x00, 0x00, 0xF8, 0x08, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00,
+0x30, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0x38, 0x09, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x40, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00,
+0x08, 0x09, 0x01, 0x80, 0x08, 0x00, 0x00, 0x00, 0xB8, 0x03, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x48, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00,
+0xC0, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0xCC, 0x09, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0xD4, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00,
+0xDC, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0xE4, 0x09, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0xEC, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00,
+0xF4, 0x09, 0x01, 0x80, 0x04, 0x00, 0x00, 0x00, 0xFC, 0x09, 0x01, 0x80,
+0x04, 0x00, 0x00, 0x00, 0x04, 0x0A, 0x01, 0x80, 0x74, 0x03, 0x00, 0x00,
+0x0C, 0x0A, 0x01, 0x80, 0x01, 0x00, 0x00, 0x00, 0x30, 0x0B, 0x01, 0x80,
+0x10, 0x00, 0x00, 0x00, 0x0C, 0x33, 0x00, 0x80, 0x06, 0x00, 0x00, 0x00,
+0x6C, 0x0B, 0x01, 0x80, 0x13, 0x00, 0x00, 0x00, 0xF8, 0x9E, 0x02, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xC8, 0x5E, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xF8, 0x0E, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00, 0xC8, 0xCE, 0x01, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xD4, 0x8E, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xA4, 0x4E, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00, 0xD0, 0x0E, 0x01, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xA0, 0xCE, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xD0, 0x86, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xA0, 0x46, 0x00, 0x00,
+0x13, 0x00, 0x00, 0x00, 0x70, 0x06, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xA4, 0x9E, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00, 0x74, 0x5E, 0x02, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xA4, 0x0E, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xD0, 0xCE, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00, 0x40, 0x9F, 0x01, 0x00,
+0x13, 0x00, 0x00, 0x00, 0x70, 0x4E, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00,
+0xA0, 0x06, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00, 0x70, 0xC6, 0x00, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xA0, 0x82, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+0x70, 0x42, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
+0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44,
+0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00,
+0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44,
+0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00,
+0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44,
+0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00,
+0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44,
+0x44, 0x22, 0x22, 0x00, 0xAA, 0x88, 0x88, 0x44, 0x44, 0x22, 0x22, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x59, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
+0x41, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00,
+0x05, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00,
+0x03, 0xC8, 0x0F, 0x00, 0x13, 0x00, 0x00, 0x00, 0xB0, 0x7C, 0x01, 0x00,
+0x13, 0x00, 0x00, 0x00, 0xC0, 0x1C, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00,
+0x60, 0xDC, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x60, 0x8C, 0x00, 0x00,
+0x13, 0x00, 0x00, 0x00, 0x50, 0x44, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x01, 0x03, 0x00,
+0x01, 0x00, 0x00, 0x00, 0x50, 0x02, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x08, 0x00,
+0x11, 0x00, 0x00, 0x00, 0xFC, 0x31, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00,
+0x0F, 0x00, 0x0C, 0x00, 0x11, 0x00, 0x00, 0x00, 0xF8, 0xF9, 0x03, 0x00,
+0x10, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00,
+0x01, 0x01, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x3E, 0x09, 0x01, 0x00,
+0x14, 0x00, 0x00, 0x00, 0x3E, 0x09, 0x09, 0x00, 0x15, 0x00, 0x00, 0x00,
+0xF4, 0x98, 0x01, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x65, 0x0F, 0x00,
+0x1A, 0x00, 0x00, 0x00, 0x56, 0x30, 0x01, 0x00, 0x1B, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x06, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+0x1E, 0x00, 0x00, 0x00, 0x59, 0x10, 0x03, 0x00, 0x21, 0x00, 0x00, 0x00,
+0x00, 0x40, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00, 0x3C, 0x08, 0x00, 0x00,
+0x23, 0x00, 0x00, 0x00, 0x58, 0x15, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+0x60, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x83, 0x25, 0x02, 0x00,
+0x26, 0x00, 0x00, 0x00, 0x00, 0xF2, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
+0xF1, 0xAC, 0x0E, 0x00, 0x28, 0x00, 0x00, 0x00, 0x54, 0xBD, 0x09, 0x00,
+0x29, 0x00, 0x00, 0x00, 0x82, 0x45, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x34, 0x13, 0x02, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x0A, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x33, 0x33, 0x05, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x08, 0x08, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x33, 0xB3, 0x05, 0x00,
+0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x03, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x33, 0x33, 0x06, 0x00, 0x2C, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x33, 0xB3, 0x06, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x09, 0x07, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x33, 0x33, 0x05, 0x00,
+0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x06, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x09, 0x07, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x33, 0xB3, 0x05, 0x00, 0x2C, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x09, 0x07, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x33, 0x33, 0x06, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x09, 0x07, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x33, 0xB3, 0x06, 0x00,
+0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x09, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0A, 0x06, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x33, 0x33, 0x05, 0x00, 0x2C, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x0A, 0x06, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x33, 0xB3, 0x05, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x0A, 0x06, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x33, 0x33, 0x06, 0x00,
+0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x0C, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x0A, 0x06, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x33, 0xB3, 0x06, 0x00, 0x2C, 0x00, 0x00, 0x00,
+0x0D, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
+0x2B, 0x00, 0x00, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x33, 0x33, 0x05, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00,
+0x2A, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00,
+0x0B, 0x05, 0x00, 0x00, 0x2B, 0x00, 0x00, 0x00, 0x23, 0x66, 0x06, 0x00,
+0x2C, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00,
+0x00, 0x40, 0x0E, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+0x31, 0x00, 0x00, 0x00, 0x31, 0x96, 0x0B, 0x00, 0x32, 0x00, 0x00, 0x00,
+0x0D, 0x13, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x87, 0x01, 0x00, 0x00,
+0x13, 0x00, 0x00, 0x00, 0x6C, 0x9E, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00,
+0x94, 0x5E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x01, 0x01, 0x00,
+0x18, 0x00, 0x00, 0x00, 0x01, 0xF4, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x5B, 0x10, 0x03, 0x00,
+0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x59, 0x01, 0x03, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x04, 0x00,
+0x11, 0x00, 0x00, 0x00, 0xF9, 0x03, 0x02, 0x00, 0x6C, 0x09, 0x00, 0x00,
+0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
+0x0D, 0x00, 0x00, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
+0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
+0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x17, 0x05, 0x03,
+0x22, 0x43, 0x5E, 0x00, 0x4F, 0xA4, 0x00, 0x00, 0x4F, 0xA4, 0x00, 0x00,
+0x22, 0x43, 0x5E, 0x00, 0x4F, 0xA4, 0x00, 0x00, 0x22, 0x43, 0x5E, 0x00,
+0x4F, 0xA4, 0x3E, 0x00, 0x30, 0xA6, 0x00, 0x00, 0x4F, 0xA4, 0x3E, 0x00,
+0x2B, 0xA4, 0x5E, 0x00, 0x2B, 0xA4, 0x00, 0x00, 0x2B, 0xA4, 0x5E, 0x00,
+0x22, 0xA4, 0x5E, 0x00, 0x4F, 0xA4, 0x00, 0x00, 0x4F, 0xA4, 0x00, 0x00,
+0x4F, 0xA4, 0x5E, 0x00, 0x4F, 0xA4, 0x5E, 0x00, 0x4F, 0xA4, 0x5E, 0x00,
+0x1C, 0x42, 0x2F, 0x00, 0x4F, 0x64, 0x5E, 0x00, 0x4F, 0xA4, 0x5E, 0x00,
+0x4F, 0xA4, 0x5E, 0x00, 0x4F, 0xA4, 0x00, 0x00, 0x4F, 0xA4, 0x5E, 0x00,
+0x00, 0xE0, 0x4C, 0x02, 0x01, 0x20, 0x00, 0x00, 0x00, 0xE0, 0x4C, 0x00,
+0x00, 0x0C, 0x43, 0x00, 0x00, 0x50, 0x43, 0x00, 0x00, 0x40, 0x96, 0x00,
+0x00, 0x05, 0xB5, 0x00, 0x00, 0x0A, 0xF7, 0x00, 0x00, 0x10, 0x18, 0x00,
+0x00, 0x21, 0x91, 0x00, 0x00, 0x1C, 0xF0, 0x00, 0x00, 0x13, 0x74, 0x00,
+0x00, 0x03, 0x7F, 0x00, 0x00, 0x50, 0xF2, 0x02, 0x01, 0x01, 0x00, 0x00,
+0x00, 0x50, 0xF2, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
+0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0xE7, 0x01, 0x80,
+0xE0, 0x25, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0xBC, 0xE7, 0x01, 0x80,
+0xE8, 0x25, 0x01, 0x80, 0x20, 0x00, 0x00, 0x00, 0xC8, 0xE7, 0x01, 0x80,
+0xE0, 0x25, 0x01, 0x80, 0x30, 0x00, 0x00, 0x00, 0xD8, 0xE7, 0x01, 0x80,
+0xE8, 0x25, 0x01, 0x80, 0x40, 0x00, 0x00, 0x00, 0xE8, 0xE7, 0x01, 0x80,
+0x44, 0x43, 0x00, 0x80, 0x50, 0x00, 0x00, 0x00, 0xF4, 0xE7, 0x01, 0x80,
+0xD4, 0x49, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x01, 0x80,
+0x34, 0x53, 0x00, 0x80, 0x90, 0x00, 0x00, 0x00, 0x0C, 0xE8, 0x01, 0x80,
+0x64, 0x30, 0x01, 0x80, 0xA0, 0x00, 0x00, 0x00, 0x14, 0xE8, 0x01, 0x80,
+0x6C, 0x30, 0x01, 0x80, 0xB0, 0x00, 0x00, 0x00, 0x20, 0xE8, 0x01, 0x80,
+0x9C, 0x39, 0x01, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x28, 0xE8, 0x01, 0x80,
+0x8C, 0x30, 0x01, 0x80, 0xD0, 0x00, 0x00, 0x00, 0x34, 0xE8, 0x01, 0x80,
+0xFC, 0x4E, 0x00, 0x80, 0xC8, 0x00, 0x00, 0x00, 0x40, 0xE8, 0x01, 0x80,
+0x54, 0x4A, 0x00, 0x80, 0x0D, 0x00, 0x00, 0x00, 0x4C, 0xE8, 0x01, 0x80,
+0xAC, 0x30, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,
+0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xFF, 0xFF, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0xFF, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
+0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xFF, 0x00, 0x00, 0x00,
+0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0xFF, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x08, 0xFF, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
+0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x01, 0x03, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xD0, 0xDF, 0x01, 0x80, 0xD0, 0xDF, 0x01, 0x80,
+0x31, 0x10, 0x10, 0x00, 0x00, 0x30, 0x00, 0x00, 0x31, 0x20, 0x10, 0x00,
+0x00, 0x30, 0x00, 0x00, 0x31, 0x28, 0x10, 0x00, 0x00, 0x30, 0x00, 0x00,
+0x31, 0x2C, 0x10, 0x10, 0x00, 0x30, 0x00, 0x00, 0x31, 0x2F, 0x10, 0x10,
+0x00, 0x30, 0x00, 0x00, 0x31, 0x30, 0x18, 0x00, 0x00, 0x30, 0x00, 0x00,
+0x31, 0x30, 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x22, 0x20, 0x18, 0x08,
+0x00, 0x20, 0x00, 0x00, 0x22, 0x21, 0x14, 0x08, 0x00, 0x20, 0x00, 0x00,
+0x22, 0x21, 0x1C, 0x08, 0x00, 0x20, 0x00, 0x00, 0x22, 0x21, 0x20, 0x08,
+0x00, 0x20, 0x00, 0x00, 0x22, 0x21, 0x20, 0x10, 0x00, 0x20, 0x00, 0x00,
+0x22, 0x21, 0x20, 0x18, 0x00, 0x20, 0x00, 0x00, 0x1A, 0x19, 0x18, 0x10,
+0x00, 0x18, 0x00, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x10, 0x00, 0x00,
+0x0A, 0x09, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x02,
+0x00, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x08, 0x00, 0x00,
+0x0A, 0x09, 0x08, 0x06, 0x00, 0x08, 0x00, 0x00, 0x08, 0x07, 0x06, 0x04,
+0x00, 0x06, 0x00, 0x00, 0x06, 0x05, 0x04, 0x02, 0x00, 0x04, 0x00, 0x00,
+0x06, 0x05, 0x04, 0x03, 0x00, 0x04, 0x00, 0x00, 0x05, 0x04, 0x03, 0x02,
+0x00, 0x03, 0x00, 0x00, 0x09, 0x08, 0x07, 0x06, 0x07, 0x06, 0x06, 0x05,
+0x05, 0x04, 0x04, 0x03, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03,
+0x05, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x02, 0x00, 0x09, 0x08, 0x07,
+0x06, 0x07, 0x06, 0x06, 0x05, 0x05, 0x04, 0x04, 0x03, 0x05, 0x04, 0x04,
+0x03, 0x03, 0x02, 0x02, 0x02, 0x04, 0x03, 0x03, 0x02, 0x02, 0x01, 0x01,
+0x01, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x10, 0x10, 0x20, 0x08, 0x08, 0x08, 0x08, 0x20, 0x20, 0x20, 0x20,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x20, 0x20, 0x20, 0x30, 0x08, 0x08, 0x08,
+0x08, 0x18, 0x18, 0x18, 0x18, 0x18, 0x20, 0x30, 0x30, 0x10, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x30, 0x30, 0x08, 0x10, 0x20, 0x30, 0x30, 0x30, 0x30,
+0x30, 0x30, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x10, 0x10, 0x20, 0x08, 0x08, 0x08, 0x08, 0x08, 0x20, 0x20, 0x20,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x20, 0x20, 0x20, 0x20, 0x08, 0x08, 0x08,
+0x08, 0x18, 0x18, 0x18, 0x18, 0x18, 0x20, 0x30, 0x30, 0x10, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x30, 0x30, 0x08, 0x10, 0x20, 0x30, 0x30, 0x30, 0x30,
+0x30, 0x30, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08,
+0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00,
+0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09,
+0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00,
+0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x22,
+0x21, 0x20, 0x18, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08,
+0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00,
+0x22, 0x21, 0x20, 0x18, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00, 0x22, 0x21,
+0x1C, 0x08, 0x00, 0x22, 0x20, 0x18, 0x08, 0x00, 0x0A, 0x09, 0x08, 0x02,
+0x00, 0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A,
+0x09, 0x08, 0x02, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x22, 0x21, 0x20,
+0x10, 0x00, 0x22, 0x21, 0x20, 0x08, 0x00, 0x22, 0x21, 0x1C, 0x08, 0x00,
+0x31, 0x30, 0x18, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09,
+0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x04,
+0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x1A,
+0x19, 0x18, 0x10, 0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x1A, 0x19, 0x18,
+0x10, 0x00, 0x22, 0x21, 0x20, 0x08, 0x00, 0x31, 0x2C, 0x10, 0x10, 0x00,
+0x31, 0x28, 0x10, 0x00, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x22, 0x21,
+0x20, 0x18, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00, 0x22, 0x21, 0x20, 0x08,
+0x00, 0x22, 0x21, 0x14, 0x08, 0x00, 0x22, 0x20, 0x18, 0x08, 0x00, 0x31,
+0x30, 0x20, 0x10, 0x00, 0x31, 0x2C, 0x10, 0x10, 0x00, 0x0A, 0x09, 0x08,
+0x00, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00,
+0x22, 0x21, 0x20, 0x18, 0x00, 0x31, 0x30, 0x20, 0x10, 0x00, 0x31, 0x2F,
+0x10, 0x10, 0x00, 0x31, 0x2F, 0x10, 0x10, 0x00, 0x31, 0x10, 0x10, 0x00,
+0x00, 0x31, 0x2C, 0x10, 0x10, 0x00, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x04,
+0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A,
+0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08,
+0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00,
+0x0A, 0x09, 0x08, 0x00, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x12, 0x11,
+0x10, 0x08, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00, 0x0A, 0x09, 0x08, 0x04,
+0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A,
+0x09, 0x08, 0x00, 0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x22, 0x21, 0x20,
+0x18, 0x00, 0x22, 0x21, 0x1C, 0x08, 0x00, 0x22, 0x21, 0x14, 0x08, 0x00,
+0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A, 0x09,
+0x08, 0x02, 0x00, 0x0A, 0x09, 0x08, 0x02, 0x00, 0x0A, 0x09, 0x08, 0x00,
+0x00, 0x22, 0x21, 0x20, 0x10, 0x00, 0x22, 0x21, 0x20, 0x08, 0x00, 0x22,
+0x21, 0x14, 0x08, 0x00, 0x22, 0x21, 0x14, 0x08, 0x00, 0x0A, 0x09, 0x08,
+0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00, 0x0A, 0x09, 0x08, 0x04, 0x00,
+0x0A, 0x09, 0x08, 0x04, 0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x1A, 0x19,
+0x18, 0x10, 0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x1A, 0x19, 0x18, 0x10,
+0x00, 0x1A, 0x19, 0x18, 0x10, 0x00, 0x22, 0x21, 0x20, 0x08, 0x00, 0x31,
+0x2C, 0x10, 0x10, 0x00, 0x31, 0x28, 0x10, 0x00, 0x00, 0x12, 0x11, 0x10,
+0x08, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00,
+0x22, 0x21, 0x20, 0x08, 0x00, 0x22, 0x21, 0x14, 0x08, 0x00, 0x22, 0x20,
+0x18, 0x08, 0x00, 0x31, 0x30, 0x20, 0x10, 0x00, 0x31, 0x2C, 0x10, 0x10,
+0x00, 0x0A, 0x09, 0x08, 0x00, 0x00, 0x12, 0x11, 0x10, 0x08, 0x00, 0x22,
+0x21, 0x20, 0x18, 0x00, 0x22, 0x21, 0x20, 0x18, 0x00, 0x31, 0x30, 0x20,
+0x10, 0x00, 0x31, 0x2F, 0x10, 0x10, 0x00, 0x31, 0x2F, 0x10, 0x10, 0x00,
+0x31, 0x10, 0x10, 0x00, 0x00, 0x31, 0x2C, 0x10, 0x10, 0x00, 0x00, 0x00,
+0x01, 0x02, 0x04, 0x08, 0x02, 0x04, 0x08, 0x0C, 0x10, 0x18, 0x20, 0x30,
+0x02, 0x04, 0x08, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x06, 0x0C, 0x10, 0x18,
+0x24, 0x30, 0x3C, 0x48, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x27, 0x2C, 0x19, 0x1B, 0x1E, 0x20,
+0x23, 0x29, 0x2A, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x25, 0x29, 0x2B, 0x2E,
+0x2E, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+0x24, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
+0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
+0xD8, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+0xA0, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00,
+0x90, 0x01, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00, 0x30, 0x02, 0x00, 0x00,
+0x2C, 0x01, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x00,
+0xD0, 0x02, 0x00, 0x00, 0x80, 0x0C, 0x00, 0x00, 0x80, 0x0C, 0x00, 0x00,
+0x80, 0x0C, 0x00, 0x00, 0xA0, 0x0F, 0x00, 0x00, 0xA0, 0x0F, 0x00, 0x00,
+0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+0x08, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
+0x18, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+0x48, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
+0x28, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+0x64, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x00,
+0xF0, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+0xA0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x68, 0x01, 0x00, 0x00,
+0x40, 0x06, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00, 0x40, 0x06, 0x00, 0x00,
+0xD0, 0x07, 0x00, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x54, 0x86, 0x01, 0x80,
+0x4C, 0xC4, 0x00, 0x80, 0x4C, 0xC4, 0x00, 0x80, 0x4C, 0xC4, 0x00, 0x80,
+0x4C, 0xC4, 0x00, 0x80, 0x9C, 0xC2, 0x00, 0x80, 0x5C, 0x86, 0x01, 0x80,
+0x54, 0x86, 0x01, 0x80, 0x54, 0x86, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x44, 0x8B, 0x01, 0x80, 0x44, 0x8B, 0x01, 0x80,
+0x44, 0x8B, 0x01, 0x80, 0x44, 0x8B, 0x01, 0x80, 0x34, 0x86, 0x01, 0x80,
+0x30, 0x8A, 0x01, 0x80, 0x3C, 0x86, 0x01, 0x80, 0x44, 0x86, 0x01, 0x80,
+0x4C, 0x86, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x08, 0x04, 0x04, 0x08, 0x02, 0x02, 0x01, 0x01, 0x80, 0x00, 0x00, 0x00,
+0x52, 0x54, 0x4C, 0x38, 0x37, 0x31, 0x32, 0x20, 0x46, 0x57, 0x20, 0x76,
+0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x30, 0x2E, 0x30, 0x2E, 0x31,
+0x23, 0x20, 0xE4, 0xB8, 0x80, 0x20, 0x35, 0xE6, 0x9C, 0x88, 0x20, 0x33,
+0x31, 0x20, 0x31, 0x35, 0x3A, 0x32, 0x35, 0x3A, 0x33, 0x39, 0x20, 0x43,
+0x53, 0x54, 0x20, 0x32, 0x30, 0x31, 0x30, 0x20, 0x20, 0x53, 0x56, 0x4E,
+0x3A, 0x20, 0x25, 0x64, 0x00, 0x00, 0x00, 0x00, 0x43, 0x68, 0x69, 0x70,
+0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x25, 0x78, 0x00,
+0x48, 0x43, 0x49, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3A, 0x20, 0x25, 0x78,
+0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x00, 0x72, 0x66, 0x5F, 0x63,
+0x6F, 0x66, 0x69, 0x67, 0x3A, 0x20, 0x25, 0x78, 0x28, 0x25, 0x78, 0x2C,
+0x20, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x00,
+0x6D, 0x70, 0x5F, 0x6D, 0x6F, 0x64, 0x65, 0x3A, 0x20, 0x25, 0x78, 0x28,
+0x25, 0x78, 0x29, 0x2C, 0x20, 0x49, 0x51, 0x4B, 0x3A, 0x20, 0x25, 0x78,
+0x0A, 0x00, 0x00, 0x00, 0x76, 0x63, 0x73, 0x20, 0x74, 0x79, 0x70, 0x65,
+0x3A, 0x20, 0x25, 0x78, 0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x00,
+0x33, 0x32, 0x6B, 0x20, 0x63, 0x61, 0x6C, 0x69, 0x62, 0x72, 0x61, 0x3A,
+0x20, 0x25, 0x64, 0x2C, 0x20, 0x33, 0x32, 0x4B, 0x20, 0x54, 0x53, 0x46,
+0x3A, 0x20, 0x25, 0x78, 0x00, 0x00, 0x00, 0x00, 0x74, 0x61, 0x72, 0x67,
+0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x72, 0x6D, 0x61, 0x6C, 0x3A, 0x20,
+0x25, 0x78, 0x2C, 0x20, 0x20, 0x62, 0x74, 0x5F, 0x63, 0x6F, 0x65, 0x78,
+0x69, 0x73, 0x74, 0x3A, 0x20, 0x25, 0x78, 0x0A, 0x00, 0x00, 0x00, 0x00,
+0x54, 0xAA, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x1C, 0xAA, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0xE4, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0xAC, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x74, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x3C, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80, 0x24, 0xA9, 0x01, 0x80,
+0x24, 0xA9, 0x01, 0x80, 0xFC, 0xA8, 0x01, 0x80, 0x64, 0x05, 0x00, 0x80,
+0x58, 0x05, 0x00, 0x80, 0x4C, 0x05, 0x00, 0x80, 0x40, 0x05, 0x00, 0x80,
+0x34, 0x05, 0x00, 0x80, 0x28, 0x05, 0x00, 0x80, 0x1C, 0x05, 0x00, 0x80,
+0x10, 0x05, 0x00, 0x80, 0x04, 0x05, 0x00, 0x80, 0xF8, 0x04, 0x00, 0x80,
+0xB0, 0x04, 0x00, 0x80, 0x60, 0x1B, 0x02, 0x80, 0xB0, 0x03, 0x25, 0xB0,
+0x60, 0x1B, 0x02, 0x80, 0x60, 0x1B, 0x02, 0x80, 0x60, 0x1B, 0x02, 0x80,
+0x60, 0x1B, 0x02, 0x80, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64,
+0x20, 0x65, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x49, 0x44, 0x3A,
+0x20, 0x25, 0x78, 0x2C, 0x20, 0x63, 0x6D, 0x64, 0x20, 0x73, 0x65, 0x71,
+0x3D, 0x25, 0x78, 0x2C, 0x20, 0x68, 0x32, 0x64, 0x73, 0x65, 0x71, 0x3D,
+0x25, 0x78, 0x0A, 0x00, 0x6A, 0x6F, 0x69, 0x6E, 0x62, 0x73, 0x73, 0x5F,
+0x68, 0x64, 0x6C, 0x00, 0x67, 0x65, 0x74, 0x20, 0x6A, 0x6F, 0x69, 0x6E,
+0x20, 0x63, 0x6D, 0x64, 0x0A, 0x00, 0x00, 0x00, 0x4E, 0x6F, 0x20, 0x69,
+0x72, 0x70, 0x20, 0x25, 0x73, 0x0A, 0x00, 0x00, 0x73, 0x65, 0x74, 0x20,
+0x6F, 0x70, 0x6D, 0x6F, 0x64, 0x65, 0x3A, 0x20, 0x25, 0x78, 0x0A, 0x00,
+0x67, 0x65, 0x74, 0x20, 0x73, 0x75, 0x72, 0x76, 0x65, 0x79, 0x20, 0x63,
+0x6D, 0x64, 0x0A, 0x00, 0x53, 0x53, 0x49, 0x44, 0x3A, 0x20, 0x25, 0x73,
+0x0A, 0x00, 0x00, 0x00, 0x73, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x3A,
+0x20, 0x25, 0x78, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x72, 0x63, 0x76, 0x20,
+0x73, 0x65, 0x74, 0x5F, 0x73, 0x74, 0x61, 0x6B, 0x65, 0x79, 0x0A, 0x00,
+0x54, 0x78, 0x5F, 0x42, 0x65, 0x61, 0x63, 0x6F, 0x6E, 0x5F, 0x68, 0x64,
+0x6C, 0x00, 0x00, 0x00, 0x74, 0x78, 0x20, 0x62, 0x65, 0x61, 0x63, 0x6F,
+0x6E, 0x20, 0x63, 0x6D, 0x64, 0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00,
+0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x4D, 0x61, 0x63, 0x41, 0x64,
+0x64, 0x72, 0x0A, 0x00, 0x00, 0x0E, 0x04, 0x0E, 0x10, 0x0E, 0x14, 0x0E,
+0x18, 0x0E, 0x1C, 0x0E, 0x4F, 0x6E, 0x41, 0x73, 0x73, 0x6F, 0x63, 0x52,
+0x65, 0x71, 0x00, 0x00, 0x4F, 0x6E, 0x41, 0x73, 0x73, 0x6F, 0x63, 0x52,
+0x73, 0x70, 0x00, 0x00, 0x4F, 0x6E, 0x52, 0x65, 0x41, 0x73, 0x73, 0x6F,
+0x63, 0x52, 0x65, 0x71, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6E, 0x52, 0x65,
+0x41, 0x73, 0x73, 0x6F, 0x63, 0x52, 0x73, 0x70, 0x00, 0x00, 0x00, 0x00,
+0x4F, 0x6E, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x52, 0x65, 0x71, 0x00, 0x00,
+0x4F, 0x6E, 0x50, 0x72, 0x6F, 0x62, 0x65, 0x52, 0x73, 0x70, 0x00, 0x00,
+0x4F, 0x6E, 0x42, 0x65, 0x61, 0x63, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00,
+0x4F, 0x6E, 0x41, 0x54, 0x49, 0x4D, 0x00, 0x00, 0x4F, 0x6E, 0x44, 0x69,
+0x73, 0x61, 0x73, 0x73, 0x6F, 0x63, 0x00, 0x00, 0x4F, 0x6E, 0x41, 0x75,
+0x74, 0x68, 0x00, 0x00, 0x4F, 0x6E, 0x44, 0x65, 0x41, 0x75, 0x74, 0x68,
+0x00, 0x00, 0x00, 0x00, 0x4F, 0x6E, 0x41, 0x63, 0x74, 0x69, 0x6F, 0x6E,
+0x00, 0x00, 0x00, 0x00, 0x4F, 0x6E, 0x51, 0x6F, 0x73, 0x4E, 0x75, 0x6C,
+0x6C, 0x00, 0x00, 0x00, 0x4F, 0x6E, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74,
+0x69, 0x6F, 0x6E, 0x00, 0x41, 0x54, 0x49, 0x4D, 0x3A, 0x20, 0x25, 0x78,
+0x0A, 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x07, 0x07, 0x0D, 0x0D, 0x0D,
+0x02, 0x07, 0x07, 0x0D, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00,
+0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x10, 0x72, 0x65, 0x70, 0x6F,
+0x72, 0x74, 0x5F, 0x73, 0x75, 0x72, 0x76, 0x65, 0x79, 0x5F, 0x64, 0x6F,
+0x6E, 0x65, 0x00, 0x00, 0x73, 0x75, 0x72, 0x76, 0x65, 0x79, 0x20, 0x64,
+0x6F, 0x6E, 0x65, 0x28, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x29, 0x0A,
+0x00, 0x00, 0x00, 0x00, 0x4E, 0x6F, 0x20, 0x69, 0x72, 0x70, 0x20, 0x25,
+0x73, 0x0A, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6F, 0x72, 0x74, 0x5F, 0x6A,
+0x6F, 0x69, 0x6E, 0x5F, 0x72, 0x65, 0x73, 0x00, 0x4E, 0x6F, 0x20, 0x69,
+0x72, 0x70, 0x28, 0x25, 0x78, 0x29, 0x20, 0x25, 0x73, 0x0A, 0x00, 0x00,
+0x6A, 0x6F, 0x69, 0x6E, 0x20, 0x72, 0x65, 0x73, 0x28, 0x25, 0x78, 0x2C,
+0x20, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6F,
+0x72, 0x74, 0x5F, 0x64, 0x65, 0x6C, 0x5F, 0x73, 0x74, 0x61, 0x5F, 0x65,
+0x76, 0x65, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x00, 0x64, 0x65, 0x6C, 0x20,
+0x73, 0x74, 0x61, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6F,
+0x72, 0x74, 0x5F, 0x61, 0x64, 0x64, 0x5F, 0x73, 0x74, 0x61, 0x5F, 0x65,
+0x76, 0x65, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x00, 0x61, 0x64, 0x64, 0x20,
+0x73, 0x74, 0x61, 0x3A, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x0A, 0x00,
+0x72, 0x63, 0x76, 0x20, 0x64, 0x69, 0x73, 0x63, 0x6F, 0x6E, 0x6E, 0x65,
+0x63, 0x74, 0x0A, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x70, 0x72,
+0x6F, 0x62, 0x65, 0x72, 0x65, 0x71, 0x00, 0x00, 0x4E, 0x6F, 0x20, 0x69,
+0x72, 0x70, 0x20, 0x40, 0x25, 0x73, 0x0A, 0x00, 0x57, 0x4D, 0x4D, 0x28,
+0x25, 0x78, 0x29, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x0A,
+0x00, 0x00, 0x00, 0x00, 0x61, 0x73, 0x73, 0x6F, 0x63, 0x20, 0x72, 0x65,
+0x6A, 0x65, 0x63, 0x74, 0x2C, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
+0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x63, 0x20,
+0x69, 0x64, 0x20, 0x23, 0x35, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25,
+0x78, 0x2C, 0x20, 0x25, 0x78, 0x0A, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75,
+0x65, 0x5F, 0x70, 0x72, 0x6F, 0x62, 0x65, 0x72, 0x73, 0x70, 0x00, 0x00,
+0x72, 0x65, 0x70, 0x6F, 0x72, 0x74, 0x5F, 0x42, 0x53, 0x53, 0x49, 0x44,
+0x5F, 0x69, 0x6E, 0x66, 0x6F, 0x00, 0x00, 0x00, 0x70, 0x61, 0x63, 0x6B,
+0x65, 0x74, 0x20, 0x74, 0x6F, 0x6F, 0x20, 0x6C, 0x61, 0x72, 0x67, 0x65,
+0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x50, 0xF2, 0x01,
+0x69, 0x6E, 0x76, 0x61, 0x6C, 0x69, 0x64, 0x20, 0x63, 0x61, 0x70, 0x3A,
+0x25, 0x78, 0x0A, 0x00, 0x49, 0x42, 0x53, 0x53, 0x20, 0x6D, 0x6F, 0x64,
+0x65, 0x2C, 0x20, 0x63, 0x75, 0x72, 0x20, 0x63, 0x68, 0x61, 0x6E, 0x6E,
+0x65, 0x6C, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x62, 0x63, 0x6E, 0x20,
+0x69, 0x6E, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6C, 0x3A, 0x20, 0x25, 0x78,
+0x0A, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x63, 0x20, 0x69, 0x64, 0x20, 0x23,
+0x34, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x0A, 0x00, 0x00,
+0x63, 0x75, 0x72, 0x20, 0x63, 0x68, 0x61, 0x6E, 0x6E, 0x65, 0x6C, 0x3A,
+0x20, 0x25, 0x78, 0x2C, 0x20, 0x62, 0x63, 0x6E, 0x20, 0x69, 0x6E, 0x74,
+0x65, 0x72, 0x76, 0x61, 0x6C, 0x3A, 0x20, 0x25, 0x78, 0x0A, 0x00, 0x00,
+0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x61, 0x73, 0x73, 0x6F, 0x63, 0x72,
+0x65, 0x71, 0x00, 0x00, 0x00, 0x50, 0xF2, 0x04, 0x69, 0x73, 0x73, 0x75,
+0x65, 0x20, 0x61, 0x73, 0x73, 0x6F, 0x63, 0x72, 0x65, 0x71, 0x28, 0x25,
+0x78, 0x29, 0x0A, 0x00, 0x5B, 0x57, 0x41, 0x50, 0x49, 0x5D, 0x20, 0x67,
+0x65, 0x74, 0x20, 0x77, 0x61, 0x70, 0x69, 0x20, 0x49, 0x45, 0x0A, 0x00,
+0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x61, 0x63, 0x74, 0x69, 0x6F, 0x6E,
+0x00, 0x00, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x20, 0x61, 0x63,
+0x74, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78,
+0x2C, 0x20, 0x25, 0x78, 0x20, 0x0A, 0x00, 0x00, 0x44, 0x45, 0x4C, 0x42,
+0x41, 0x3A, 0x20, 0x25, 0x78, 0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00,
+0x41, 0x44, 0x44, 0x42, 0x41, 0x20, 0x52, 0x53, 0x50, 0x3A, 0x20, 0x25,
+0x78, 0x0A, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x61, 0x75,
+0x74, 0x68, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x20, 0x61, 0x75,
+0x74, 0x68, 0x0A, 0x00, 0x63, 0x6C, 0x6E, 0x74, 0x20, 0x61, 0x75, 0x74,
+0x68, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x65, 0x64, 0x20, 0x64, 0x75, 0x65,
+0x20, 0x74, 0x6F, 0x20, 0x69, 0x6C, 0x6C, 0x65, 0x67, 0x61, 0x6C, 0x20,
+0x73, 0x65, 0x71, 0x3D, 0x25, 0x78, 0x0A, 0x00, 0x63, 0x6C, 0x6E, 0x74,
+0x20, 0x61, 0x75, 0x74, 0x68, 0x20, 0x66, 0x61, 0x69, 0x6C, 0x2C, 0x20,
+0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00,
+0x6E, 0x6F, 0x20, 0x63, 0x68, 0x61, 0x6C, 0x6C, 0x65, 0x6E, 0x67, 0x65,
+0x20, 0x74, 0x65, 0x78, 0x74, 0x3F, 0x0A, 0x00, 0x6C, 0x69, 0x6E, 0x6B,
+0x20, 0x74, 0x6F, 0x20, 0x75, 0x6E, 0x6B, 0x6E, 0x6F, 0x77, 0x6E, 0x20,
+0x41, 0x50, 0x0A, 0x00, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20,
+0x41, 0x74, 0x68, 0x65, 0x72, 0x6F, 0x73, 0x20, 0x41, 0x50, 0x28, 0x4D,
+0x41, 0x43, 0x29, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x63, 0x20,
+0x69, 0x64, 0x20, 0x23, 0x25, 0x78, 0x3A, 0x20, 0x25, 0x78, 0x2C, 0x20,
+0x25, 0x78, 0x0A, 0x00, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20,
+0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x6F, 0x6D, 0x20, 0x41, 0x50, 0x0A,
+0x00, 0x00, 0x00, 0x00, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20,
+0x41, 0x74, 0x68, 0x65, 0x72, 0x6F, 0x73, 0x20, 0x41, 0x50, 0x0A, 0x00,
+0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20, 0x4D, 0x61, 0x72, 0x76,
+0x65, 0x6C, 0x6C, 0x20, 0x41, 0x50, 0x0A, 0x00, 0x6C, 0x69, 0x6E, 0x6B,
+0x20, 0x74, 0x6F, 0x20, 0x52, 0x65, 0x61, 0x6C, 0x74, 0x65, 0x6B, 0x20,
+0x39, 0x36, 0x42, 0x20, 0x41, 0x50, 0x0A, 0x00, 0x6C, 0x69, 0x6E, 0x6B,
+0x20, 0x74, 0x6F, 0x20, 0x43, 0x69, 0x73, 0x63, 0x6F, 0x20, 0x41, 0x50,
+0x0A, 0x00, 0x00, 0x00, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20,
+0x52, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x41, 0x50, 0x0A, 0x00, 0x00,
+0x6C, 0x69, 0x6E, 0x6B, 0x20, 0x74, 0x6F, 0x20, 0x52, 0x65, 0x61, 0x6C,
+0x74, 0x65, 0x6B, 0x20, 0x39, 0x36, 0x42, 0x20, 0x41, 0x50, 0x20, 0x77,
+0x69, 0x74, 0x68, 0x20, 0x76, 0x69, 0x64, 0x65, 0x6F, 0x20, 0x6D, 0x6F,
+0x64, 0x65, 0x0A, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x64, 0x65,
+0x61, 0x75, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75,
+0x65, 0x5F, 0x64, 0x65, 0x61, 0x75, 0x74, 0x68, 0x0A, 0x00, 0x00, 0x00,
+0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x64, 0x69, 0x73, 0x61, 0x73, 0x73,
+0x6F, 0x63, 0x00, 0x00, 0x69, 0x73, 0x73, 0x75, 0x65, 0x5F, 0x64, 0x69,
+0x73, 0x61, 0x73, 0x73, 0x6F, 0x63, 0x0A, 0x00, 0x69, 0x73, 0x73, 0x75,
+0x65, 0x5F, 0x66, 0x72, 0x61, 0x6D, 0x65, 0x5F, 0x6C, 0x65, 0x6E, 0x00,
+0x64, 0x69, 0x73, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x20, 0x74,
+0x69, 0x6D, 0x65, 0x72, 0x3A, 0x20, 0x6E, 0x6F, 0x20, 0x62, 0x65, 0x61,
+0x63, 0x6F, 0x6E, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x64, 0x69, 0x73, 0x63,
+0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x28, 0x6E, 0x6F, 0x20, 0x64, 0x61,
+0x74, 0x61, 0x20, 0x72, 0x63, 0x76, 0x64, 0x29, 0x0A, 0x00, 0x00, 0x00,
+0x69, 0x73, 0x73, 0x75, 0x65, 0x20, 0x51, 0x6F, 0x73, 0x4E, 0x75, 0x6C,
+0x6C, 0x28, 0x25, 0x64, 0x29, 0x00, 0x00, 0x00, 0x60, 0x1B, 0x02, 0x80,
+0xB0, 0x03, 0x25, 0xB0, 0x18, 0x03, 0x25, 0xB0, 0x44, 0x44, 0x33, 0x33,
+0x06, 0x00, 0x2A, 0xB0, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB4, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0x38, 0x4A, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0x2C, 0x4A, 0x01, 0x80, 0x20, 0x4A, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0x14, 0x4A, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0x08, 0x4A, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xFC, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xF0, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xE4, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xD8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xCC, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80, 0xB8, 0x49, 0x01, 0x80,
+0xB8, 0x49, 0x01, 0x80, 0xC0, 0x49, 0x01, 0x80, 0xF8, 0x4A, 0x01, 0x80,
+0xEC, 0x4A, 0x01, 0x80, 0xE0, 0x4A, 0x01, 0x80, 0xD4, 0x4A, 0x01, 0x80,
+0xC8, 0x4A, 0x01, 0x80, 0xBC, 0x4A, 0x01, 0x80, 0xB0, 0x4A, 0x01, 0x80,
+0xA4, 0x4A, 0x01, 0x80, 0x98, 0x4A, 0x01, 0x80, 0x8C, 0x4A, 0x01, 0x80,
+0x80, 0x4A, 0x01, 0x80, 0x74, 0x4A, 0x01, 0x80, 0x00, 0x50, 0xF2, 0x01,
+0x00, 0x50, 0xF2, 0x02, 0x00, 0x0F, 0xAC, 0x02, 0x30, 0x31, 0x32, 0x33,
+0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
+0x00, 0x00, 0x00, 0x00, 0x25, 0x64, 0x2E, 0x00, 0x25, 0x68, 0x68, 0x58,
+0x3A, 0x00, 0x00, 0x00, 0xEC, 0xEE, 0x01, 0x80, 0x67, 0x66, 0x66, 0x66,
+0x87, 0x7C, 0x00, 0x80, 0x5D, 0x7C, 0x00, 0x80, 0x37, 0x7C, 0x00, 0x80,
+0x11, 0x7C, 0x00, 0x80, 0xC1, 0x7B, 0x00, 0x80, 0x9B, 0x7B, 0x00, 0x80,
+0xEB, 0x7B, 0x00, 0x80, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x20, 0x63,
+0x61, 0x6D, 0x20, 0x65, 0x6E, 0x74, 0x72, 0x79, 0x20, 0x28, 0x25, 0x78,
+0x2C, 0x20, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00, 0x2D, 0x3E, 0x28, 0x25,
+0x78, 0x2C, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25, 0x78, 0x2C, 0x20, 0x25,
+0x78, 0x29, 0x0A, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x09, 0x00, 0x00,
+0xDF, 0x88, 0x00, 0x80, 0xE5, 0x88, 0x00, 0x80, 0xEB, 0x88, 0x00, 0x80,
+0xF1, 0x88, 0x00, 0x80, 0xDF, 0x88, 0x00, 0x80, 0xDF, 0x88, 0x00, 0x80,
+0xDF, 0x88, 0x00, 0x80, 0xDF, 0x88, 0x00, 0x80, 0xF7, 0x88, 0x00, 0x80,
+0xFD, 0x88, 0x00, 0x80, 0x03, 0x89, 0x00, 0x80, 0x09, 0x89, 0x00, 0x80,
+0x60, 0x1B, 0x02, 0x80, 0x55, 0x6E, 0x69, 0x20, 0x4F, 0x6B, 0x3A, 0x20,
+0x41, 0x50, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xFF, 0xC0, 0xFF,
+0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xFF, 0x03, 0xFE, 0x01, 0x80, 0x7F,
+0xE2, 0x01, 0x80, 0x78, 0xC7, 0x01, 0xC0, 0x71, 0xAE, 0x01, 0x80, 0x6B,
+0x95, 0x01, 0x40, 0x65, 0x7F, 0x01, 0xC0, 0x5F, 0x69, 0x01, 0x40, 0x5A,
+0x55, 0x01, 0x40, 0x55, 0x42, 0x01, 0x80, 0x50, 0x30, 0x01, 0x00, 0x4C,
+0x1F, 0x01, 0xC0, 0x47, 0x0F, 0x01, 0xC0, 0x43, 0x00, 0x01, 0x00, 0x40,
+0xF2, 0x00, 0x80, 0x3C, 0xE4, 0x00, 0x00, 0x39, 0xD7, 0x00, 0xC0, 0x35,
+0xCB, 0x00, 0xC0, 0x32, 0xC0, 0x00, 0x00, 0x30, 0xB5, 0x00, 0x40, 0x2D,
+0xAB, 0x00, 0xC0, 0x2A, 0xA2, 0x00, 0x80, 0x28, 0x98, 0x00, 0x00, 0x26,
+0x90, 0x00, 0x00, 0x24, 0x88, 0x00, 0x00, 0x22, 0x80, 0x00, 0x00, 0x20,
+0x79, 0x00, 0x40, 0x1E, 0x72, 0x00, 0x80, 0x1C, 0x6C, 0x00, 0x00, 0x1B,
+0x66, 0x00, 0x80, 0x19, 0x60, 0x00, 0x00, 0x18, 0x5B, 0x00, 0xC0, 0x16,
+0x56, 0x00, 0x80, 0x15, 0x51, 0x00, 0x40, 0x14, 0x4C, 0x00, 0x00, 0x13,
+0x48, 0x00, 0x00, 0x12, 0x44, 0x00, 0x00, 0x11, 0x40, 0x00, 0x00, 0x10,
+0x36, 0x35, 0x2E, 0x25, 0x1C, 0x12, 0x09, 0x04, 0x33, 0x32, 0x2B, 0x23,
+0x1A, 0x11, 0x08, 0x04, 0x30, 0x2F, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03,
+0x2D, 0x2D, 0x27, 0x1F, 0x18, 0x0F, 0x08, 0x03, 0x2B, 0x2A, 0x25, 0x1E,
+0x16, 0x0E, 0x07, 0x03, 0x28, 0x28, 0x22, 0x1C, 0x15, 0x0D, 0x07, 0x03,
+0x26, 0x25, 0x21, 0x1B, 0x14, 0x0D, 0x06, 0x03, 0x24, 0x23, 0x1F, 0x19,
+0x13, 0x0C, 0x06, 0x03, 0x22, 0x21, 0x1D, 0x18, 0x11, 0x0B, 0x06, 0x02,
+0x20, 0x20, 0x1B, 0x16, 0x11, 0x08, 0x05, 0x02, 0x1F, 0x1E, 0x1A, 0x15,
+0x10, 0x0A, 0x05, 0x02, 0x1D, 0x1C, 0x18, 0x14, 0x0F, 0x0A, 0x05, 0x02,
+0x1B, 0x1A, 0x17, 0x13, 0x0E, 0x09, 0x04, 0x02, 0x1A, 0x19, 0x16, 0x12,
+0x0D, 0x09, 0x04, 0x02, 0x18, 0x17, 0x15, 0x11, 0x0C, 0x08, 0x04, 0x02,
+0x17, 0x16, 0x13, 0x10, 0x0C, 0x08, 0x04, 0x02, 0x16, 0x15, 0x12, 0x0F,
+0x0B, 0x07, 0x04, 0x01, 0x14, 0x14, 0x11, 0x0E, 0x0B, 0x07, 0x03, 0x02,
+0x13, 0x13, 0x10, 0x0D, 0x0A, 0x06, 0x03, 0x01, 0x12, 0x12, 0x0F, 0x0C,
+0x09, 0x06, 0x03, 0x01, 0x11, 0x11, 0x0F, 0x0C, 0x09, 0x06, 0x03, 0x01,
+0x10, 0x10, 0x0E, 0x0B, 0x08, 0x05, 0x03, 0x01, 0x0F, 0x0F, 0x0D, 0x0B,
+0x08, 0x05, 0x03, 0x01, 0x0E, 0x0E, 0x0C, 0x0A, 0x08, 0x05, 0x02, 0x01,
+0x0D, 0x0D, 0x0C, 0x0A, 0x07, 0x05, 0x02, 0x01, 0x0D, 0x0C, 0x0B, 0x09,
+0x07, 0x04, 0x02, 0x01, 0x0C, 0x0C, 0x0A, 0x09, 0x06, 0x04, 0x02, 0x01,
+0x0B, 0x0B, 0x0A, 0x08, 0x06, 0x04, 0x02, 0x01, 0x0B, 0x0A, 0x09, 0x08,
+0x06, 0x04, 0x02, 0x01, 0x0A, 0x0A, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01,
+0x0A, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01, 0x09, 0x09, 0x08, 0x06,
+0x05, 0x03, 0x01, 0x01, 0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01,
+0x36, 0x35, 0x2E, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x33, 0x32, 0x2B, 0x19,
+0x00, 0x00, 0x00, 0x00, 0x30, 0x2F, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00,
+0x2D, 0x2D, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00, 0x2B, 0x2A, 0x25, 0x15,
+0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00,
+0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00, 0x24, 0x23, 0x1F, 0x12,
+0x00, 0x00, 0x00, 0x00, 0x22, 0x21, 0x1D, 0x11, 0x00, 0x00, 0x00, 0x00,
+0x20, 0x20, 0x1B, 0x10, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1E, 0x1A, 0x0F,
+0x00, 0x00, 0x00, 0x00, 0x1D, 0x1C, 0x18, 0x0E, 0x00, 0x00, 0x00, 0x00,
+0x1B, 0x1A, 0x17, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x19, 0x16, 0x0D,
+0x00, 0x00, 0x00, 0x00, 0x18, 0x17, 0x15, 0x0C, 0x00, 0x00, 0x00, 0x00,
+0x17, 0x16, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x16, 0x15, 0x12, 0x0B,
+0x00, 0x00, 0x00, 0x00, 0x14, 0x14, 0x11, 0x0A, 0x00, 0x00, 0x00, 0x00,
+0x13, 0x13, 0x10, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x0F, 0x09,
+0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x0F, 0x09, 0x00, 0x00, 0x00, 0x00,
+0x10, 0x10, 0x0E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0D, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x0C, 0x07, 0x00, 0x00, 0x00, 0x00,
+0x0D, 0x0D, 0x0C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x0C, 0x0B, 0x06,
+0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00,
+0x0B, 0x0B, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x0A, 0x09, 0x05,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0x0A, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00,
+0x0A, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09, 0x08, 0x05,
+0x00, 0x00, 0x00, 0x00, 0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00,
+0x72, 0x65, 0x73, 0x65, 0x74, 0x28, 0x25, 0x78, 0x29, 0x0A, 0x00, 0x00,
+0x50, 0x53, 0x00, 0x00, 0xE8, 0x86, 0x01, 0x80, 0x58, 0x87, 0x01, 0x80,
+0x14, 0x87, 0x01, 0x80, 0x58, 0x87, 0x01, 0x80, 0x58, 0x87, 0x01, 0x80,
+0x58, 0x87, 0x01, 0x80, 0x58, 0x87, 0x01, 0x80, 0xC0, 0x86, 0x01, 0x80,
+0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
+0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06,
+0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x28, 0x28, 0x28, 0x28, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
+0xA0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+0x10, 0x10, 0x10, 0x10, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+0x04, 0x04, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x41, 0x41, 0x41,
+0x41, 0x41, 0x41, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x10,
+0x10, 0x10, 0x10, 0x10, 0x10, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x02,
+0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10, 0x10, 0x10, 0x10, 0x08,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x10, 0x10, 0x10,
+0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+0x10, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+0x01, 0x01, 0x01, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
+0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x10,
+0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x2D, 0x5C, 0x7C, 0x2F,
+0x00, 0x00, 0x00, 0x00, 0x0A, 0xD6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0xF0, 0xF4, 0x5E, 0x00, 0xF0, 0xF4, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xE5, 0x5E, 0x00,
+0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0xB8, 0xA0, 0xFC, 0x08, 0xFF, 0xFF, 0xFF, 0xFF,
+};
diff --git a/drivers/staging/rtl8712/generic.h b/drivers/staging/rtl8712/generic.h
new file mode 100644
index 000000000000..742424bdf16b
--- /dev/null
+++ b/drivers/staging/rtl8712/generic.h
@@ -0,0 +1,153 @@
+#ifndef _LINUX_BYTEORDER_GENERIC_H
+#define _LINUX_BYTEORDER_GENERIC_H
+
+/*
+ * linux/byteorder_generic.h
+ * Generic Byte-reordering support
+ *
+ * Francois-Rene Rideau <fare@tunes.org> 19970707
+ * gathered all the good ideas from all asm-foo/byteorder.h into one file,
+ * cleaned them up.
+ * I hope it is compliant with non-GCC compilers.
+ * I decided to put __BYTEORDER_HAS_U64__ in byteorder.h,
+ * because I wasn't sure it would be ok to put it in types.h
+ * Upgraded it to 2.1.43
+ * Francois-Rene Rideau <fare@tunes.org> 19971012
+ * Upgraded it to 2.1.57
+ * to please Linus T., replaced huge #ifdef's between little/big endian
+ * by nestedly #include'd files.
+ * Francois-Rene Rideau <fare@tunes.org> 19971205
+ * Made it to 2.1.71; now a facelift:
+ * Put files under include/linux/byteorder/
+ * Split swab from generic support.
+ *
+ * TODO:
+ * = Regular kernel maintainers could also replace all these manual
+ * byteswap macros that remain, disseminated among drivers,
+ * after some grep or the sources...
+ * = Linus might want to rename all these macros and files to fit his taste,
+ * to fit his personal naming scheme.
+ * = it seems that a few drivers would also appreciate
+ * nybble swapping support...
+ * = every architecture could add their byteswap macro in asm/byteorder.h
+ * see how some architectures already do (i386, alpha, ppc, etc)
+ * = cpu_to_beXX and beXX_to_cpu might some day need to be well
+ * distinguished throughout the kernel. This is not the case currently,
+ * since little endian, big endian, and pdp endian machines needn't it.
+ * But this might be the case for, say, a port of Linux to 20/21 bit
+ * architectures (and F21 Linux addict around?).
+ */
+
+/*
+ * The following macros are to be defined by <asm/byteorder.h>:
+ *
+ * Conversion of long and short int between network and host format
+ * ntohl(__u32 x)
+ * ntohs(__u16 x)
+ * htonl(__u32 x)
+ * htons(__u16 x)
+ * It seems that some programs (which? where? or perhaps a standard? POSIX?)
+ * might like the above to be functions, not macros (why?).
+ * if that's true, then detect them, and take measures.
+ * Anyway, the measure is: define only ___ntohl as a macro instead,
+ * and in a separate file, have
+ * unsigned long inline ntohl(x){return ___ntohl(x);}
+ *
+ * The same for constant arguments
+ * __constant_ntohl(__u32 x)
+ * __constant_ntohs(__u16 x)
+ * __constant_htonl(__u32 x)
+ * __constant_htons(__u16 x)
+ *
+ * Conversion of XX-bit integers (16- 32- or 64-)
+ * between native CPU format and little/big endian format
+ * 64-bit stuff only defined for proper architectures
+ * cpu_to_[bl]eXX(__uXX x)
+ * [bl]eXX_to_cpu(__uXX x)
+ *
+ * The same, but takes a pointer to the value to convert
+ * cpu_to_[bl]eXXp(__uXX x)
+ * [bl]eXX_to_cpup(__uXX x)
+ *
+ * The same, but change in situ
+ * cpu_to_[bl]eXXs(__uXX x)
+ * [bl]eXX_to_cpus(__uXX x)
+ *
+ * See asm-foo/byteorder.h for examples of how to provide
+ * architecture-optimized versions
+ *
+ */
+
+
+/*
+ * inside the kernel, we can use nicknames;
+ * outside of it, we must avoid POSIX namespace pollution...
+ */
+#define cpu_to_le64 __cpu_to_le64
+#define le64_to_cpu __le64_to_cpu
+#define cpu_to_le32 __cpu_to_le32
+#define le32_to_cpu __le32_to_cpu
+#define cpu_to_le16 __cpu_to_le16
+#define le16_to_cpu __le16_to_cpu
+#define cpu_to_be64 __cpu_to_be64
+#define be64_to_cpu __be64_to_cpu
+#define cpu_to_be32 __cpu_to_be32
+#define be32_to_cpu __be32_to_cpu
+#define cpu_to_be16 __cpu_to_be16
+#define be16_to_cpu __be16_to_cpu
+#define cpu_to_le64p __cpu_to_le64p
+#define le64_to_cpup __le64_to_cpup
+#define cpu_to_le32p __cpu_to_le32p
+#define le32_to_cpup __le32_to_cpup
+#define cpu_to_le16p __cpu_to_le16p
+#define le16_to_cpup __le16_to_cpup
+#define cpu_to_be64p __cpu_to_be64p
+#define be64_to_cpup __be64_to_cpup
+#define cpu_to_be32p __cpu_to_be32p
+#define be32_to_cpup __be32_to_cpup
+#define cpu_to_be16p __cpu_to_be16p
+#define be16_to_cpup __be16_to_cpup
+#define cpu_to_le64s __cpu_to_le64s
+#define le64_to_cpus __le64_to_cpus
+#define cpu_to_le32s __cpu_to_le32s
+#define le32_to_cpus __le32_to_cpus
+#define cpu_to_le16s __cpu_to_le16s
+#define le16_to_cpus __le16_to_cpus
+#define cpu_to_be64s __cpu_to_be64s
+#define be64_to_cpus __be64_to_cpus
+#define cpu_to_be32s __cpu_to_be32s
+#define be32_to_cpus __be32_to_cpus
+#define cpu_to_be16s __cpu_to_be16s
+#define be16_to_cpus __be16_to_cpus
+
+
+/*
+ * Handle ntohl and suches. These have various compatibility
+ * issues - like we want to give the prototype even though we
+ * also have a macro for them in case some strange program
+ * wants to take the address of the thing or something..
+ *
+ * Note that these used to return a "long" in libc5, even though
+ * long is often 64-bit these days.. Thus the casts.
+ *
+ * They have to be macros in order to do the constant folding
+ * correctly - if the argument passed into a inline function
+ * it is no longer constant according to gcc..
+ */
+
+#undef ntohl
+#undef ntohs
+#undef htonl
+#undef htons
+
+/*
+ * Do the prototypes. Somebody might want to take the
+ * address or some such sick thing..
+ */
+extern __u32 ntohl(__u32);
+extern __u32 htonl(__u32);
+extern unsigned short int ntohs(unsigned short int);
+extern unsigned short int htons(unsigned short int);
+
+#endif /* _LINUX_BYTEORDER_GENERIC_H */
+
diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
new file mode 100644
index 000000000000..32088a641eba
--- /dev/null
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -0,0 +1,358 @@
+/******************************************************************************
+ * hal_init.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _HAL_INIT_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_byteorder.h"
+#include "farray.h"
+#include "usb_osintf.h"
+
+#define FWBUFF_ALIGN_SZ 512
+#define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/
+
+static u32 rtl871x_open_fw(struct _adapter *padapter, void **pphfwfile_hdl,
+ const u8 **ppmappedfw)
+{
+ u32 len;
+
+ *ppmappedfw = f_array;
+ len = sizeof(f_array);
+ return len;
+}
+
+static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv)
+{
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+ struct registry_priv *pregpriv = &padapter->registrypriv;
+
+ memset(pfwpriv, 0, sizeof(struct fw_priv));
+ /* todo: check if needs endian conversion */
+ pfwpriv->hci_sel = RTL8712_HCI_TYPE_72USB;
+ pfwpriv->usb_ep_num = (u8)pdvobj->nr_endpoint;
+ pfwpriv->bw_40MHz_en = pregpriv->cbw40_enable;
+ switch (pregpriv->rf_config) {
+ case RTL8712_RF_1T1R:
+ pfwpriv->rf_config = RTL8712_RFC_1T1R;
+ break;
+ case RTL8712_RF_2T2R:
+ pfwpriv->rf_config = RTL8712_RFC_2T2R;
+ break;
+ case RTL8712_RF_1T2R:
+ default:
+ pfwpriv->rf_config = RTL8712_RFC_1T2R;
+ }
+ pfwpriv->mp_mode = (pregpriv->mp_mode == 1) ? 1 : 0;
+ pfwpriv->vcsType = pregpriv->vrtl_carrier_sense; /* 0:off 1:on 2:auto */
+ pfwpriv->vcsMode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */
+ /* default enable turboMode */
+ pfwpriv->turboMode = ((pregpriv->wifi_test == 1) ? 0 : 1);
+ pfwpriv->lowPowerMode = pregpriv->low_power;
+}
+
+static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw)
+{
+ pfwhdr->signature = le16_to_cpu(*(u16 *)pmappedfw);
+ pfwhdr->version = le16_to_cpu(*(u16 *)(pmappedfw+2));
+ /* define the size of boot loader */
+ pfwhdr->dmem_size = le32_to_cpu(*(uint *)(pmappedfw+4));
+ /* define the size of FW in IMEM */
+ pfwhdr->img_IMEM_size = le32_to_cpu(*(uint *)(pmappedfw+8));
+ /* define the size of FW in SRAM */
+ pfwhdr->img_SRAM_size = le32_to_cpu(*(uint *)(pmappedfw+12));
+ /* define the size of DMEM variable */
+ pfwhdr->fw_priv_sz = le32_to_cpu(*(uint *)(pmappedfw+16));
+}
+
+static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
+{
+ u32 fwhdrsz, fw_sz;
+ u8 intf, rfconf;
+
+ /* check signature */
+ if ((pfwhdr->signature != 0x8712) && (pfwhdr->signature != 0x8192))
+ return _FAIL;
+ /* check interface */
+ intf = (u8)((pfwhdr->version&0x3000) >> 12);
+ /* check rf_conf */
+ rfconf = (u8)((pfwhdr->version&0xC000) >> 14);
+ /* check fw_priv_sze & sizeof(struct fw_priv) */
+ if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv))
+ return _FAIL;
+ /* check fw_sz & image_fw_sz */
+ fwhdrsz = FIELD_OFFSET(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz;
+ fw_sz = fwhdrsz + pfwhdr->img_IMEM_size + pfwhdr->img_SRAM_size +
+ pfwhdr->dmem_size;
+ if (fw_sz != ulfilelength)
+ return _FAIL;
+ return _SUCCESS;
+}
+
+static u8 rtl8712_dl_fw(struct _adapter *padapter)
+{
+ sint i;
+ u8 tmp8, tmp8_a;
+ u16 tmp16;
+ u32 maxlen = 0, tmp32; /* for compare usage */
+ uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */
+ struct fw_hdr fwhdr;
+ u32 ulfilelength; /* FW file size */
+ void *phfwfile_hdl = NULL;
+ const u8 *pmappedfw = NULL;
+ u8 *ptmpchar = NULL, *ppayload, *ptr;
+ struct tx_desc *ptx_desc;
+ u32 txdscp_sz = sizeof(struct tx_desc);
+
+ ulfilelength = rtl871x_open_fw(padapter, &phfwfile_hdl, &pmappedfw);
+ if (pmappedfw && (ulfilelength > 0)) {
+ update_fwhdr(&fwhdr, pmappedfw);
+ if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL)
+ goto exit_fail;
+ fill_fwpriv(padapter, &fwhdr.fwpriv);
+ /* firmware check ok */
+ maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ?
+ fwhdr.img_IMEM_size : fwhdr.img_SRAM_size;
+ maxlen += txdscp_sz;
+ ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ);
+ if (ptmpchar == NULL)
+ return _FAIL;
+
+ ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ -
+ ((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1)));
+ ppayload = (u8 *)(ptx_desc) + txdscp_sz;
+ ptr = (u8 *)pmappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) +
+ fwhdr.fw_priv_sz;
+ /* Download FirmWare */
+ /* 1. determine IMEM code size and Load IMEM Code Section */
+ imem_sz = fwhdr.img_IMEM_size;
+ do {
+ memset(ptx_desc, 0, TXDESC_SIZE);
+ if (imem_sz > MAX_DUMP_FWSZ/*49152*/)
+ dump_imem_sz = MAX_DUMP_FWSZ;
+ else {
+ dump_imem_sz = imem_sz;
+ ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
+ }
+ ptx_desc->txdw0 |= cpu_to_le32(dump_imem_sz &
+ 0x0000ffff);
+ memcpy(ppayload, ptr, dump_imem_sz);
+ r8712_write_mem(padapter, RTL8712_DMA_VOQ,
+ dump_imem_sz + TXDESC_SIZE,
+ (u8 *)ptx_desc);
+ ptr += dump_imem_sz;
+ imem_sz -= dump_imem_sz;
+ } while (imem_sz > 0);
+ i = 10;
+ tmp16 = r8712_read16(padapter, TCR);
+ while (((tmp16 & _IMEM_CODE_DONE) == 0) && (i > 0)) {
+ udelay(10);
+ tmp16 = r8712_read16(padapter, TCR);
+ i--;
+ }
+ if (i == 0 || (tmp16 & _IMEM_CHK_RPT) == 0)
+ goto exit_fail;
+
+ /* 2.Download EMEM code size and Load EMEM Code Section */
+ emem_sz = fwhdr.img_SRAM_size;
+ do {
+ memset(ptx_desc, 0, TXDESC_SIZE);
+ if (emem_sz > MAX_DUMP_FWSZ) /* max=48k */
+ dump_emem_sz = MAX_DUMP_FWSZ;
+ else {
+ dump_emem_sz = emem_sz;
+ ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
+ }
+ ptx_desc->txdw0 |= cpu_to_le32(dump_emem_sz &
+ 0x0000ffff);
+ memcpy(ppayload, ptr, dump_emem_sz);
+ r8712_write_mem(padapter, RTL8712_DMA_VOQ,
+ dump_emem_sz+TXDESC_SIZE, (u8 *)ptx_desc);
+ ptr += dump_emem_sz;
+ emem_sz -= dump_emem_sz;
+ } while (emem_sz > 0);
+ i = 5;
+ tmp16 = r8712_read16(padapter, TCR);
+ while (((tmp16 & _EMEM_CODE_DONE) == 0) && (i > 0)) {
+ udelay(10);
+ tmp16 = r8712_read16(padapter, TCR);
+ i--;
+ }
+ if (i == 0 || (tmp16 & _EMEM_CHK_RPT) == 0)
+ goto exit_fail;
+
+ /* 3.Enable CPU */
+ tmp8 = r8712_read8(padapter, SYS_CLKR);
+ r8712_write8(padapter, SYS_CLKR, tmp8|BIT(2));
+ tmp8_a = r8712_read8(padapter, SYS_CLKR);
+ if (tmp8_a != (tmp8|BIT(2)))
+ goto exit_fail;
+
+ tmp8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN+1, tmp8|BIT(2));
+ tmp8_a = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ if (tmp8_a != (tmp8|BIT(2)))
+ goto exit_fail;
+
+ tmp32 = r8712_read32(padapter, TCR);
+
+ /* 4.polling IMEM Ready */
+ i = 100;
+ tmp16 = r8712_read16(padapter, TCR);
+ while (((tmp16 & _IMEM_RDY) == 0) && (i > 0)) {
+ msleep(20);
+ tmp16 = r8712_read16(padapter, TCR);
+ i--;
+ }
+ if (i == 0) {
+ r8712_write16(padapter, 0x10250348, 0xc000);
+ r8712_write16(padapter, 0x10250348, 0xc001);
+ r8712_write16(padapter, 0x10250348, 0x2000);
+ r8712_write16(padapter, 0x10250348, 0x2001);
+ r8712_write16(padapter, 0x10250348, 0x2002);
+ r8712_write16(padapter, 0x10250348, 0x2003);
+ goto exit_fail;
+ }
+ /* 5.Download DMEM code size and Load EMEM Code Section */
+ memset(ptx_desc, 0, TXDESC_SIZE);
+ ptx_desc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz&0x0000ffff);
+ ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
+ memcpy(ppayload, &fwhdr.fwpriv, fwhdr.fw_priv_sz);
+ r8712_write_mem(padapter, RTL8712_DMA_VOQ,
+ fwhdr.fw_priv_sz + TXDESC_SIZE, (u8 *)ptx_desc);
+
+ /* polling dmem code done */
+ i = 100;
+ tmp16 = r8712_read16(padapter, TCR);
+ while (((tmp16 & _DMEM_CODE_DONE) == 0) && (i > 0)) {
+ msleep(20);
+ tmp16 = r8712_read16(padapter, TCR);
+ i--;
+ }
+ if (i == 0)
+ goto exit_fail;
+
+ tmp8 = r8712_read8(padapter, 0x1025000A);
+ if (tmp8 & BIT(4)) /* When boot from EEPROM,
+ & FW need more time to read EEPROM */
+ i = 60;
+ else /* boot from EFUSE */
+ i = 30;
+ tmp16 = r8712_read16(padapter, TCR);
+ while (((tmp16 & _FWRDY) == 0) && (i > 0)) {
+ msleep(100);
+ tmp16 = r8712_read16(padapter, TCR);
+ i--;
+ }
+ if (i == 0)
+ goto exit_fail;
+ } else
+ goto exit_fail;
+ return _SUCCESS;
+
+exit_fail:
+ kfree(ptmpchar);
+ return _FAIL;
+}
+
+uint rtl8712_hal_init(struct _adapter *padapter)
+{
+ u32 val32;
+ int i;
+
+ /* r8712 firmware download */
+ if (rtl8712_dl_fw(padapter) != _SUCCESS)
+ return _FAIL;
+
+ printk(KERN_INFO "r8712u: 1 RCR=0x%x\n", r8712_read32(padapter, RCR));
+ val32 = r8712_read32(padapter, RCR);
+ r8712_write32(padapter, RCR, (val32 | BIT(26))); /* Enable RX TCP
+ Checksum offload */
+ printk(KERN_INFO "r8712u: 2 RCR=0x%x\n", r8712_read32(padapter, RCR));
+ val32 = r8712_read32(padapter, RCR);
+ r8712_write32(padapter, RCR, (val32|BIT(25))); /* Append PHY status */
+ val32 = 0;
+ val32 = r8712_read32(padapter, 0x10250040);
+ r8712_write32(padapter, 0x10250040, (val32&0x00FFFFFF));
+ /* for usb rx aggregation */
+ r8712_write8(padapter, 0x102500B5, r8712_read8(padapter, 0x102500B5) |
+ BIT(0)); /* page = 128bytes */
+ r8712_write8(padapter, 0x102500BD, r8712_read8(padapter, 0x102500BD) |
+ BIT(7)); /* enable usb rx aggregation */
+ r8712_write8(padapter, 0x102500D9, 1); /* TH=1 => means that invalidate
+ * usb rx aggregation */
+ r8712_write8(padapter, 0x1025FE5B, 0x04); /* 1.7ms/4 */
+ /* Fix the RX FIFO issue(USB error) */
+ r8712_write8(padapter, 0x1025fe5C, r8712_read8(padapter, 0x1025fe5C)
+ | BIT(7));
+ for (i = 0; i < 6; i++)
+ padapter->eeprompriv.mac_addr[i] = r8712_read8(padapter,
+ MACID + i);
+ return _SUCCESS;
+}
+
+uint rtl8712_hal_deinit(struct _adapter *padapter)
+{
+ r8712_write8(padapter, RF_CTRL, 0x00);
+ /* Turn off BB */
+ msleep(20);
+ /* Turn off MAC */
+ r8712_write8(padapter, SYS_CLKR+1, 0x38); /* Switch Control Path */
+ r8712_write8(padapter, SYS_FUNC_EN+1, 0x70);
+ r8712_write8(padapter, PMC_FSM, 0x06); /* Enable Loader Data Keep */
+ r8712_write8(padapter, SYS_ISO_CTRL, 0xF9); /* Isolation signals from
+ * CORE, PLL */
+ r8712_write8(padapter, SYS_ISO_CTRL+1, 0xe8); /* Enable EFUSE 1.2V */
+ r8712_write8(padapter, AFE_PLL_CTRL, 0x00); /* Disable AFE PLL. */
+ r8712_write8(padapter, LDOA15_CTRL, 0x54); /* Disable A15V */
+ r8712_write8(padapter, SYS_FUNC_EN+1, 0x50); /* Disable E-Fuse 1.2V */
+ r8712_write8(padapter, LDOV12D_CTRL, 0x24); /* Disable LDO12(for CE) */
+ r8712_write8(padapter, AFE_MISC, 0x30); /* Disable AFE BG&MB */
+ /* Option for Disable 1.6V LDO. */
+ r8712_write8(padapter, SPS0_CTRL, 0x56); /* Disable 1.6V LDO */
+ r8712_write8(padapter, SPS0_CTRL+1, 0x43); /* Set SW PFM */
+ return _SUCCESS;
+}
+
+uint rtl871x_hal_init(struct _adapter *padapter)
+{
+ padapter->hw_init_completed = false;
+ if (padapter->halpriv.hal_bus_init == NULL)
+ return _FAIL;
+ else {
+ if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
+ return _FAIL;
+ }
+ if (rtl8712_hal_init(padapter) == _SUCCESS)
+ padapter->hw_init_completed = true;
+ else {
+ padapter->hw_init_completed = false;
+ return _FAIL;
+ }
+ return _SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
new file mode 100644
index 000000000000..f06addcf063e
--- /dev/null
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -0,0 +1,454 @@
+/******************************************************************************
+ * ieee80211.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _IEEE80211_C
+
+#include "drv_types.h"
+#include "ieee80211.h"
+#include "wifi.h"
+#include "osdep_service.h"
+#include "wlan_bssdef.h"
+
+static const u8 WPA_OUI_TYPE[] = {0x00, 0x50, 0xf2, 1};
+static const u8 WPA_CIPHER_SUITE_NONE[] = {0x00, 0x50, 0xf2, 0};
+static const u8 WPA_CIPHER_SUITE_WEP40[] = {0x00, 0x50, 0xf2, 1};
+static const u8 WPA_CIPHER_SUITE_TKIP[] = {0x00, 0x50, 0xf2, 2};
+static const u8 WPA_CIPHER_SUITE_CCMP[] = {0x00, 0x50, 0xf2, 4};
+static const u8 WPA_CIPHER_SUITE_WEP104[] = {0x00, 0x50, 0xf2, 5};
+
+static const u8 RSN_CIPHER_SUITE_NONE[] = {0x00, 0x0f, 0xac, 0};
+static const u8 RSN_CIPHER_SUITE_WEP40[] = {0x00, 0x0f, 0xac, 1};
+static const u8 RSN_CIPHER_SUITE_TKIP[] = {0x00, 0x0f, 0xac, 2};
+static const u8 RSN_CIPHER_SUITE_CCMP[] = {0x00, 0x0f, 0xac, 4};
+static const u8 RSN_CIPHER_SUITE_WEP104[] = {0x00, 0x0f, 0xac, 5};
+
+/*-----------------------------------------------------------
+ * for adhoc-master to generate ie and provide supported-rate to fw
+ *-----------------------------------------------------------
+ */
+
+static u8 WIFI_CCKRATES[] = {
+ (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
+ (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK),
+ (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK),
+ (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)
+};
+
+static u8 WIFI_OFDMRATES[] = {
+ (IEEE80211_OFDM_RATE_6MB),
+ (IEEE80211_OFDM_RATE_9MB),
+ (IEEE80211_OFDM_RATE_12MB),
+ (IEEE80211_OFDM_RATE_18MB),
+ (IEEE80211_OFDM_RATE_24MB),
+ (IEEE80211_OFDM_RATE_36MB),
+ (IEEE80211_OFDM_RATE_48MB),
+ (IEEE80211_OFDM_RATE_54MB)
+};
+
+uint r8712_is_cckrates_included(u8 *rate)
+{
+ u32 i = 0;
+
+ while (rate[i] != 0) {
+ if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
+ (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
+ return true;
+ i++;
+ }
+ return false;
+}
+
+uint r8712_is_cckratesonly_included(u8 *rate)
+{
+ u32 i = 0;
+
+ while (rate[i] != 0) {
+ if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
+ (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
+ return false;
+ i++;
+ }
+ return true;
+}
+
+/* r8712_set_ie will update frame length */
+u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen)
+{
+ *pbuf = (u8)index;
+ *(pbuf + 1) = (u8)len;
+ if (len > 0)
+ memcpy((void *)(pbuf + 2), (void *)source, len);
+ *frlen = *frlen + (len + 2);
+ return pbuf + len + 2;
+}
+
+/*----------------------------------------------------------------------------
+index: the information element id index, limit is the limit for search
+-----------------------------------------------------------------------------*/
+u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
+{
+ sint tmp, i;
+ u8 *p;
+
+ if (limit < 1)
+ return NULL;
+ p = pbuf;
+ i = 0;
+ *len = 0;
+ while (1) {
+ if (*p == index) {
+ *len = *(p + 1);
+ return p;
+ } else {
+ tmp = *(p + 1);
+ p += (tmp + 2);
+ i += (tmp + 2);
+ }
+ if (i >= limit)
+ break;
+ }
+ return NULL;
+}
+
+static void set_supported_rate(u8 *SupportedRates, uint mode)
+{
+ memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
+ switch (mode) {
+ case WIRELESS_11B:
+ memcpy(SupportedRates, WIFI_CCKRATES,
+ IEEE80211_CCK_RATE_LEN);
+ break;
+ case WIRELESS_11G:
+ case WIRELESS_11A:
+ memcpy(SupportedRates, WIFI_OFDMRATES,
+ IEEE80211_NUM_OFDM_RATESLEN);
+ break;
+ case WIRELESS_11BG:
+ memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
+ memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES,
+ IEEE80211_NUM_OFDM_RATESLEN);
+ break;
+ }
+}
+
+static uint r8712_get_rateset_len(u8 *rateset)
+{
+ uint i = 0;
+
+ while (1) {
+ if ((rateset[i]) == 0)
+ break;
+ if (i > 12)
+ break;
+ i++;
+ }
+ return i;
+}
+
+int r8712_generate_ie(struct registry_priv *pregistrypriv,
+ struct _adapter *padapter)
+{
+ int sz = 0, rateLen;
+ struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
+ u8 *ie = pdev_network->IEs;
+ struct ieee80211_ht_cap ht_capie;
+ struct ieee80211_ht_addt_info ht_addt_info;
+ unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+
+ /*timestamp will be inserted by hardware*/
+ sz += 8;
+ ie += sz;
+ /*beacon interval : 2bytes*/
+ *(u16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
+ sz += 2;
+ ie += 2;
+ /*capability info*/
+ *(u16 *)ie = 0;
+ *(u16 *)ie |= cpu_to_le16(cap_IBSS);
+ if (pregistrypriv->preamble == PREAMBLE_SHORT)
+ *(u16 *)ie |= cpu_to_le16(cap_ShortPremble);
+ if (pdev_network->Privacy)
+ *(u16 *)ie |= cpu_to_le16(cap_Privacy);
+ sz += 2;
+ ie += 2;
+ /*SSID*/
+ ie = r8712_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength,
+ pdev_network->Ssid.Ssid, &sz);
+ /*supported rates*/
+ set_supported_rate(pdev_network->SupportedRates,
+ pregistrypriv->wireless_mode);
+ rateLen = r8712_get_rateset_len(pdev_network->SupportedRates);
+ if (rateLen > 8) {
+ ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, 8,
+ pdev_network->SupportedRates, &sz);
+ ie = r8712_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8),
+ (pdev_network->SupportedRates + 8), &sz);
+ } else
+ ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_,
+ rateLen, pdev_network->SupportedRates, &sz);
+ /*DS parameter set*/
+ ie = r8712_set_ie(ie, _DSSET_IE_, 1,
+ (u8 *)&(pdev_network->Configuration.DSConfig), &sz);
+ /*IBSS Parameter Set*/
+ ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2,
+ (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz);
+ if (pregistrypriv->ht_enable == 1) {
+ if (pqospriv->qos_option == 0) {
+ ie = r8712_set_ie(ie, _VENDOR_SPECIFIC_IE_,
+ _WMM_IE_Length_, WMM_IE, &sz);
+ pqospriv->qos_option = 1;
+ }
+ memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
+ ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH |
+ IEEE80211_HT_CAP_SGI_20 |
+ IEEE80211_HT_CAP_SGI_40 |
+ IEEE80211_HT_CAP_TX_STBC |
+ IEEE80211_HT_CAP_MAX_AMSDU |
+ IEEE80211_HT_CAP_DSSSCCK40;
+ ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR &
+ 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
+ ie = r8712_set_ie(ie, _HT_CAPABILITY_IE_,
+ sizeof(struct ieee80211_ht_cap),
+ (unsigned char *)&ht_capie, &sz);
+ /*add HT info ie*/
+ memset(&ht_addt_info, 0,
+ sizeof(struct ieee80211_ht_addt_info));
+ /*need to add the HT additional IEs*/
+ ht_addt_info.control_chan = pregistrypriv->channel;
+ ie = r8712_set_ie(ie, _HT_ADD_INFO_IE_,
+ sizeof(struct ieee80211_ht_addt_info),
+ (unsigned char *)&ht_addt_info, &sz);
+ }
+ return sz;
+}
+
+unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
+{
+ int len;
+ u16 val16;
+ unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
+ u8 *pbuf = pie;
+
+ while (1) {
+ pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit);
+ if (pbuf) {
+ /*check if oui matches...*/
+ if (memcmp((pbuf + 2), wpa_oui_type,
+ sizeof(wpa_oui_type)))
+ goto check_next_ie;
+ /*check version...*/
+ memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
+ val16 = le16_to_cpu(val16);
+ if (val16 != 0x0001)
+ goto check_next_ie;
+ *wpa_ie_len = *(pbuf + 1);
+ return pbuf;
+ } else {
+ *wpa_ie_len = 0;
+ return NULL;
+ }
+check_next_ie:
+ limit = limit - (pbuf - pie) - 2 - len;
+ if (limit <= 0)
+ break;
+ pbuf += (2 + len);
+ }
+ *wpa_ie_len = 0;
+ return NULL;
+}
+
+unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
+{
+ return r8712_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
+}
+
+static int r8712_get_wpa_cipher_suite(u8 *s)
+{
+ if (!memcmp(s, (void *)WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN))
+ return WPA_CIPHER_NONE;
+ if (!memcmp(s, (void *)WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN))
+ return WPA_CIPHER_WEP40;
+ if (!memcmp(s, (void *)WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN))
+ return WPA_CIPHER_TKIP;
+ if (!memcmp(s, (void *)WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN))
+ return WPA_CIPHER_CCMP;
+ if (!memcmp(s, (void *)WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN))
+ return WPA_CIPHER_WEP104;
+ return 0;
+}
+
+static int r8712_get_wpa2_cipher_suite(u8 *s)
+{
+ if (!memcmp(s, (void *)RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN))
+ return WPA_CIPHER_NONE;
+ if (!memcmp(s, (void *)RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN))
+ return WPA_CIPHER_WEP40;
+ if (!memcmp(s, (void *)RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN))
+ return WPA_CIPHER_TKIP;
+ if (!memcmp(s, (void *)RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN))
+ return WPA_CIPHER_CCMP;
+ if (!memcmp(s, (void *)RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN))
+ return WPA_CIPHER_WEP104;
+ return 0;
+}
+
+int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
+ int *pairwise_cipher)
+{
+ int i, ret = _SUCCESS;
+ int left, count;
+ u8 *pos;
+
+ if (wpa_ie_len <= 0) {
+ /* No WPA IE - fail silently */
+ return _FAIL;
+ }
+ if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2))
+ || (memcmp(wpa_ie + 2, (void *)WPA_OUI_TYPE, WPA_SELECTOR_LEN)))
+ return _FAIL;
+ pos = wpa_ie;
+ pos += 8;
+ left = wpa_ie_len - 8;
+ /*group_cipher*/
+ if (left >= WPA_SELECTOR_LEN) {
+ *group_cipher = r8712_get_wpa_cipher_suite(pos);
+ pos += WPA_SELECTOR_LEN;
+ left -= WPA_SELECTOR_LEN;
+ } else if (left > 0)
+ return _FAIL;
+ /*pairwise_cipher*/
+ if (left >= 2) {
+ count = le16_to_cpu(*(u16 *)pos);
+ pos += 2;
+ left -= 2;
+ if (count == 0 || left < count * WPA_SELECTOR_LEN)
+ return _FAIL;
+ for (i = 0; i < count; i++) {
+ *pairwise_cipher |= r8712_get_wpa_cipher_suite(pos);
+ pos += WPA_SELECTOR_LEN;
+ left -= WPA_SELECTOR_LEN;
+ }
+ } else if (left == 1)
+ return _FAIL;
+ return ret;
+}
+
+int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
+ int *pairwise_cipher)
+{
+ int i, ret = _SUCCESS;
+ int left, count;
+ u8 *pos;
+
+ if (rsn_ie_len <= 0) {
+ /* No RSN IE - fail silently */
+ return _FAIL;
+ }
+ if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2)))
+ return _FAIL;
+ pos = rsn_ie;
+ pos += 4;
+ left = rsn_ie_len - 4;
+ /*group_cipher*/
+ if (left >= RSN_SELECTOR_LEN) {
+ *group_cipher = r8712_get_wpa2_cipher_suite(pos);
+ pos += RSN_SELECTOR_LEN;
+ left -= RSN_SELECTOR_LEN;
+ } else if (left > 0)
+ return _FAIL;
+ /*pairwise_cipher*/
+ if (left >= 2) {
+ count = le16_to_cpu(*(u16 *)pos);
+ pos += 2;
+ left -= 2;
+ if (count == 0 || left < count * RSN_SELECTOR_LEN)
+ return _FAIL;
+ for (i = 0; i < count; i++) {
+ *pairwise_cipher |= r8712_get_wpa2_cipher_suite(pos);
+ pos += RSN_SELECTOR_LEN;
+ left -= RSN_SELECTOR_LEN;
+ }
+ } else if (left == 1)
+ return _FAIL;
+ return ret;
+}
+
+int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
+ u8 *wpa_ie, u16 *wpa_len)
+{
+ u8 authmode, sec_idx;
+ u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
+ uint cnt;
+
+ /*Search required WPA or WPA2 IE and copy to sec_ie[ ]*/
+ cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
+ sec_idx = 0;
+ while (cnt < in_len) {
+ authmode = in_ie[cnt];
+ if ((authmode == _WPA_IE_ID_) &&
+ (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) {
+ memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
+ *wpa_len = in_ie[cnt+1]+2;
+ cnt += in_ie[cnt + 1] + 2; /*get next */
+ } else {
+ if (authmode == _WPA2_IE_ID_) {
+ memcpy(rsn_ie, &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
+ *rsn_len = in_ie[cnt+1] + 2;
+ cnt += in_ie[cnt+1] + 2; /*get next*/
+ } else
+ cnt += in_ie[cnt+1] + 2; /*get next*/
+ }
+ }
+ return *rsn_len + *wpa_len;
+}
+
+int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
+{
+ int match;
+ uint cnt;
+ u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
+
+ cnt = 12;
+ match = false;
+ while (cnt < in_len) {
+ eid = in_ie[cnt];
+ if ((eid == _WPA_IE_ID_) &&
+ (!memcmp(&in_ie[cnt+2], wps_oui, 4))) {
+ memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2);
+ *wps_ielen = in_ie[cnt+1]+2;
+ cnt += in_ie[cnt+1]+2;
+ match = true;
+ break;
+ } else
+ cnt += in_ie[cnt+1]+2; /* goto next */
+ }
+ return match;
+}
diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h
new file mode 100644
index 000000000000..432cf8a7605f
--- /dev/null
+++ b/drivers/staging/rtl8712/ieee80211.h
@@ -0,0 +1,770 @@
+#ifndef __IEEE80211_H
+#define __IEEE80211_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wifi.h"
+#include <linux/wireless.h>
+
+#define MGMT_QUEUE_NUM 5
+#define ETH_ALEN 6
+#define IEEE_CMD_SET_WPA_PARAM 1
+#define IEEE_CMD_SET_WPA_IE 2
+#define IEEE_CMD_SET_ENCRYPTION 3
+#define IEEE_CMD_MLME 4
+
+#define IEEE_PARAM_WPA_ENABLED 1
+#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
+#define IEEE_PARAM_DROP_UNENCRYPTED 3
+#define IEEE_PARAM_PRIVACY_INVOKED 4
+#define IEEE_PARAM_AUTH_ALGS 5
+#define IEEE_PARAM_IEEE_802_1X 6
+#define IEEE_PARAM_WPAX_SELECT 7
+
+#define AUTH_ALG_OPEN_SYSTEM 0x1
+#define AUTH_ALG_SHARED_KEY 0x2
+#define AUTH_ALG_LEAP 0x00000004
+
+#define IEEE_MLME_STA_DEAUTH 1
+#define IEEE_MLME_STA_DISASSOC 2
+
+#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
+#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
+#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
+#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
+#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
+#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
+
+
+#define IEEE_CRYPT_ALG_NAME_LEN 16
+
+#define WPA_CIPHER_NONE BIT(0)
+#define WPA_CIPHER_WEP40 BIT(1)
+#define WPA_CIPHER_WEP104 BIT(2)
+#define WPA_CIPHER_TKIP BIT(3)
+#define WPA_CIPHER_CCMP BIT(4)
+
+
+
+#define WPA_SELECTOR_LEN 4
+#define RSN_HEADER_LEN 4
+
+#define RSN_SELECTOR_LEN 4
+
+enum NETWORK_TYPE {
+ WIRELESS_INVALID = 0,
+ WIRELESS_11B = 1,
+ WIRELESS_11G = 2,
+ WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
+ WIRELESS_11A = 4,
+ WIRELESS_11N = 8,
+ WIRELESS_11GN = (WIRELESS_11G | WIRELESS_11N),
+ WIRELESS_11BGN = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
+};
+
+
+struct ieee_param {
+ u32 cmd;
+ u8 sta_addr[ETH_ALEN];
+ union {
+ struct {
+ u8 name;
+ u32 value;
+ } wpa_param;
+ struct {
+ u32 len;
+ u8 reserved[32];
+ u8 data[0];
+ } wpa_ie;
+ struct{
+ int command;
+ int reason_code;
+ } mlme;
+ struct {
+ u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
+ u8 set_tx;
+ u32 err;
+ u8 idx;
+ u8 seq[8]; /* sequence counter (set: RX, get: TX) */
+ u16 key_len;
+ u8 key[0];
+ } crypt;
+ } u;
+};
+
+#define IEEE80211_DATA_LEN 2304
+/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
+ 6.2.1.1.2.
+
+ The figure in section 7.1.2 suggests a body size of up to 2312
+ bytes is allowed, which is a bit confusing, I suspect this
+ represents the 2304 bytes of real data, plus a possible 8 bytes of
+ WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
+
+#define IEEE80211_HLEN 30
+#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
+
+/* this is stolen from ipw2200 driver */
+#define IEEE_IBSS_MAC_HASH_SIZE 31
+
+struct ieee_ibss_seq {
+ u8 mac[ETH_ALEN];
+ u16 seq_num;
+ u16 frag_num;
+ unsigned int packet_time;
+ struct list_head list;
+};
+
+struct ieee80211_hdr {
+ u16 frame_ctl;
+ u16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ u16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addr {
+ u16 frame_ctl;
+ u16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ u16 seq_ctl;
+} __attribute__ ((packed));
+
+
+struct ieee80211_hdr_qos {
+ u16 frame_ctl;
+ u16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ u16 seq_ctl;
+ u8 addr4[ETH_ALEN];
+ u16 qc;
+} __attribute__ ((packed));
+
+struct ieee80211_hdr_3addr_qos {
+ u16 frame_ctl;
+ u16 duration_id;
+ u8 addr1[ETH_ALEN];
+ u8 addr2[ETH_ALEN];
+ u8 addr3[ETH_ALEN];
+ u16 seq_ctl;
+ u16 qc;
+} __attribute__ ((packed));
+
+struct eapol {
+ u8 snap[6];
+ u16 ethertype;
+ u8 version;
+ u8 type;
+ u16 length;
+} __attribute__ ((packed));
+
+
+enum eap_type {
+ EAP_PACKET = 0,
+ EAPOL_START,
+ EAPOL_LOGOFF,
+ EAPOL_KEY,
+ EAPOL_ENCAP_ASF_ALERT
+};
+
+#define IEEE80211_3ADDR_LEN 24
+#define IEEE80211_4ADDR_LEN 30
+#define IEEE80211_FCS_LEN 4
+
+#define MIN_FRAG_THRESHOLD 256U
+#define MAX_FRAG_THRESHOLD 2346U
+
+/* Frame control field constants */
+#define IEEE80211_FCTL_VERS 0x0002
+#define IEEE80211_FCTL_FTYPE 0x000c
+#define IEEE80211_FCTL_STYPE 0x00f0
+#define IEEE80211_FCTL_TODS 0x0100
+#define IEEE80211_FCTL_FROMDS 0x0200
+#define IEEE80211_FCTL_MOREFRAGS 0x0400
+#define IEEE80211_FCTL_RETRY 0x0800
+#define IEEE80211_FCTL_PM 0x1000
+#define IEEE80211_FCTL_MOREDATA 0x2000
+#define IEEE80211_FCTL_WEP 0x4000
+#define IEEE80211_FCTL_ORDER 0x8000
+
+#define IEEE80211_FTYPE_MGMT 0x0000
+#define IEEE80211_FTYPE_CTL 0x0004
+#define IEEE80211_FTYPE_DATA 0x0008
+
+/* management */
+#define IEEE80211_STYPE_ASSOC_REQ 0x0000
+#define IEEE80211_STYPE_ASSOC_RESP 0x0010
+#define IEEE80211_STYPE_REASSOC_REQ 0x0020
+#define IEEE80211_STYPE_REASSOC_RESP 0x0030
+#define IEEE80211_STYPE_PROBE_REQ 0x0040
+#define IEEE80211_STYPE_PROBE_RESP 0x0050
+#define IEEE80211_STYPE_BEACON 0x0080
+#define IEEE80211_STYPE_ATIM 0x0090
+#define IEEE80211_STYPE_DISASSOC 0x00A0
+#define IEEE80211_STYPE_AUTH 0x00B0
+#define IEEE80211_STYPE_DEAUTH 0x00C0
+
+/* control */
+#define IEEE80211_STYPE_PSPOLL 0x00A0
+#define IEEE80211_STYPE_RTS 0x00B0
+#define IEEE80211_STYPE_CTS 0x00C0
+#define IEEE80211_STYPE_ACK 0x00D0
+#define IEEE80211_STYPE_CFEND 0x00E0
+#define IEEE80211_STYPE_CFENDACK 0x00F0
+
+/* data */
+#define IEEE80211_STYPE_DATA 0x0000
+#define IEEE80211_STYPE_DATA_CFACK 0x0010
+#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
+#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
+#define IEEE80211_STYPE_NULLFUNC 0x0040
+#define IEEE80211_STYPE_CFACK 0x0050
+#define IEEE80211_STYPE_CFPOLL 0x0060
+#define IEEE80211_STYPE_CFACKPOLL 0x0070
+#define IEEE80211_QOS_DATAGRP 0x0080
+#define IEEE80211_QoS_DATAGRP IEEE80211_QOS_DATAGRP
+
+#define IEEE80211_SCTL_FRAG 0x000F
+#define IEEE80211_SCTL_SEQ 0xFFF0
+
+/* QoS,QOS */
+#define NORMAL_ACK 0
+#define NO_ACK 1
+#define NON_EXPLICIT_ACK 2
+#define BLOCK_ACK 3
+
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#endif /* ETH_P_PAE */
+
+#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
+
+#define ETH_P_ECONET 0x0018
+
+#ifndef ETH_P_80211_RAW
+#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
+#endif
+
+/* IEEE 802.11 defines */
+
+#define P80211_OUI_LEN 3
+
+struct ieee80211_snap_hdr {
+ u8 dsap; /* always 0xAA */
+ u8 ssap; /* always 0xAA */
+ u8 ctrl; /* always 0x03 */
+ u8 oui[P80211_OUI_LEN]; /* organizational universal id */
+} __attribute__ ((packed));
+
+#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
+
+#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
+#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
+
+#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
+
+#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
+#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
+
+/* Authentication algorithms */
+#define WLAN_AUTH_OPEN 0
+#define WLAN_AUTH_SHARED_KEY 1
+
+#define WLAN_AUTH_CHALLENGE_LEN 128
+
+#define WLAN_CAPABILITY_BSS (1<<0)
+#define WLAN_CAPABILITY_IBSS (1<<1)
+#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
+#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
+#define WLAN_CAPABILITY_PRIVACY (1<<4)
+#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
+#define WLAN_CAPABILITY_PBCC (1<<6)
+#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
+#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
+
+/* Status codes */
+#define WLAN_STATUS_SUCCESS 0
+#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
+#define WLAN_STATUS_CAPS_UNSUPPORTED 10
+#define WLAN_STATUS_REASSOC_NO_ASSOC 11
+#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
+#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
+#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
+#define WLAN_STATUS_CHALLENGE_FAIL 15
+#define WLAN_STATUS_AUTH_TIMEOUT 16
+#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
+#define WLAN_STATUS_ASSOC_DENIED_RATES 18
+/* 802.11b */
+#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
+#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
+#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
+
+/* Reason codes */
+#define WLAN_REASON_UNSPECIFIED 1
+#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
+#define WLAN_REASON_DEAUTH_LEAVING 3
+#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
+#define WLAN_REASON_DISASSOC_AP_BUSY 5
+#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
+#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
+#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
+#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
+
+
+/* Information Element IDs */
+#define WLAN_EID_SSID 0
+#define WLAN_EID_SUPP_RATES 1
+#define WLAN_EID_FH_PARAMS 2
+#define WLAN_EID_DS_PARAMS 3
+#define WLAN_EID_CF_PARAMS 4
+#define WLAN_EID_TIM 5
+#define WLAN_EID_IBSS_PARAMS 6
+#define WLAN_EID_CHALLENGE 16
+#define WLAN_EID_RSN 48
+#define WLAN_EID_GENERIC 221
+
+#define IEEE80211_MGMT_HDR_LEN 24
+#define IEEE80211_DATA_HDR3_LEN 24
+#define IEEE80211_DATA_HDR4_LEN 30
+
+
+#define IEEE80211_STATMASK_SIGNAL (1<<0)
+#define IEEE80211_STATMASK_RSSI (1<<1)
+#define IEEE80211_STATMASK_NOISE (1<<2)
+#define IEEE80211_STATMASK_RATE (1<<3)
+#define IEEE80211_STATMASK_WEMASK 0x7
+
+
+#define IEEE80211_CCK_MODULATION (1<<0)
+#define IEEE80211_OFDM_MODULATION (1<<1)
+
+#define IEEE80211_24GHZ_BAND (1<<0)
+#define IEEE80211_52GHZ_BAND (1<<1)
+
+#define IEEE80211_CCK_RATE_LEN 4
+#define IEEE80211_NUM_OFDM_RATESLEN 8
+
+
+#define IEEE80211_CCK_RATE_1MB 0x02
+#define IEEE80211_CCK_RATE_2MB 0x04
+#define IEEE80211_CCK_RATE_5MB 0x0B
+#define IEEE80211_CCK_RATE_11MB 0x16
+#define IEEE80211_OFDM_RATE_LEN 8
+#define IEEE80211_OFDM_RATE_6MB 0x0C
+#define IEEE80211_OFDM_RATE_9MB 0x12
+#define IEEE80211_OFDM_RATE_12MB 0x18
+#define IEEE80211_OFDM_RATE_18MB 0x24
+#define IEEE80211_OFDM_RATE_24MB 0x30
+#define IEEE80211_OFDM_RATE_36MB 0x48
+#define IEEE80211_OFDM_RATE_48MB 0x60
+#define IEEE80211_OFDM_RATE_54MB 0x6C
+#define IEEE80211_BASIC_RATE_MASK 0x80
+
+#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
+#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
+#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
+#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
+#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
+#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
+#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
+#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
+#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
+#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
+#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
+#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
+
+#define IEEE80211_CCK_RATES_MASK 0x0000000F
+#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
+ IEEE80211_CCK_RATE_2MB_MASK)
+#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
+ IEEE80211_CCK_RATE_5MB_MASK | \
+ IEEE80211_CCK_RATE_11MB_MASK)
+
+#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
+#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
+ IEEE80211_OFDM_RATE_12MB_MASK | \
+ IEEE80211_OFDM_RATE_24MB_MASK)
+#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
+ IEEE80211_OFDM_RATE_9MB_MASK | \
+ IEEE80211_OFDM_RATE_18MB_MASK | \
+ IEEE80211_OFDM_RATE_36MB_MASK | \
+ IEEE80211_OFDM_RATE_48MB_MASK | \
+ IEEE80211_OFDM_RATE_54MB_MASK)
+#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
+ IEEE80211_CCK_DEFAULT_RATES_MASK)
+
+#define IEEE80211_NUM_OFDM_RATES 8
+#define IEEE80211_NUM_CCK_RATES 4
+#define IEEE80211_OFDM_SHIFT_MASK_A 4
+
+
+
+
+/* NOTE: This data is for statistical purposes; not all hardware provides this
+ * information for frames received. Not setting these will not cause
+ * any adverse affects. */
+struct ieee80211_rx_stats {
+ s8 rssi;
+ u8 signal;
+ u8 noise;
+ u8 received_channel;
+ u16 rate; /* in 100 kbps */
+ u8 mask;
+ u8 freq;
+ u16 len;
+};
+
+/* IEEE 802.11 requires that STA supports concurrent reception of at least
+ * three fragmented frames. This define can be increased to support more
+ * concurrent frames, but it should be noted that each entry can consume about
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+#define IEEE80211_FRAG_CACHE_LEN 4
+
+struct ieee80211_frag_entry {
+ u32 first_frag_time;
+ uint seq;
+ uint last_frag;
+ uint qos; /*jackson*/
+ uint tid; /*jackson*/
+ struct sk_buff *skb;
+ u8 src_addr[ETH_ALEN];
+ u8 dst_addr[ETH_ALEN];
+};
+
+struct ieee80211_stats {
+ uint tx_unicast_frames;
+ uint tx_multicast_frames;
+ uint tx_fragments;
+ uint tx_unicast_octets;
+ uint tx_multicast_octets;
+ uint tx_deferred_transmissions;
+ uint tx_single_retry_frames;
+ uint tx_multiple_retry_frames;
+ uint tx_retry_limit_exceeded;
+ uint tx_discards;
+ uint rx_unicast_frames;
+ uint rx_multicast_frames;
+ uint rx_fragments;
+ uint rx_unicast_octets;
+ uint rx_multicast_octets;
+ uint rx_fcs_errors;
+ uint rx_discards_no_buffer;
+ uint tx_discards_wrong_sa;
+ uint rx_discards_undecryptable;
+ uint rx_message_in_msg_fragments;
+ uint rx_message_in_bad_msg_fragments;
+};
+
+struct ieee80211_softmac_stats{
+ uint rx_ass_ok;
+ uint rx_ass_err;
+ uint rx_probe_rq;
+ uint tx_probe_rs;
+ uint tx_beacons;
+ uint rx_auth_rq;
+ uint rx_auth_rs_ok;
+ uint rx_auth_rs_err;
+ uint tx_auth_rq;
+ uint no_auth_rs;
+ uint no_ass_rs;
+ uint tx_ass_rq;
+ uint rx_ass_rq;
+ uint tx_probe_rq;
+ uint reassoc;
+ uint swtxstop;
+ uint swtxawake;
+};
+
+#define SEC_KEY_1 (1<<0)
+#define SEC_KEY_2 (1<<1)
+#define SEC_KEY_3 (1<<2)
+#define SEC_KEY_4 (1<<3)
+#define SEC_ACTIVE_KEY (1<<4)
+#define SEC_AUTH_MODE (1<<5)
+#define SEC_UNICAST_GROUP (1<<6)
+#define SEC_LEVEL (1<<7)
+#define SEC_ENABLED (1<<8)
+
+#define SEC_LEVEL_0 0 /* None */
+#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
+#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
+#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
+#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
+
+#define WEP_KEYS 4
+#define WEP_KEY_LEN 13
+
+struct ieee80211_security {
+ u16 active_key:2,
+ enabled:1,
+ auth_mode:2,
+ auth_algo:4,
+ unicast_uses_group:1;
+ u8 key_sizes[WEP_KEYS];
+ u8 keys[WEP_KEYS][WEP_KEY_LEN];
+ u8 level;
+ u16 flags;
+} __attribute__ ((packed));
+
+/*
+
+ 802.11 data frame from AP
+
+ ,-------------------------------------------------------------------.
+Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
+ |------|------|---------|---------|---------|------|---------|------|
+Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
+ | | tion | (BSSID) | | | ence | data | |
+ `-------------------------------------------------------------------'
+
+Total: 28-2340 bytes
+
+*/
+
+struct ieee80211_header_data {
+ u16 frame_ctl;
+ u16 duration_id;
+ u8 addr1[6];
+ u8 addr2[6];
+ u8 addr3[6];
+ u16 seq_ctrl;
+};
+
+#define BEACON_PROBE_SSID_ID_POSITION 12
+
+/* Management Frame Information Element Types */
+#define MFIE_TYPE_SSID 0
+#define MFIE_TYPE_RATES 1
+#define MFIE_TYPE_FH_SET 2
+#define MFIE_TYPE_DS_SET 3
+#define MFIE_TYPE_CF_SET 4
+#define MFIE_TYPE_TIM 5
+#define MFIE_TYPE_IBSS_SET 6
+#define MFIE_TYPE_CHALLENGE 16
+#define MFIE_TYPE_ERP 42
+#define MFIE_TYPE_RSN 48
+#define MFIE_TYPE_RATES_EX 50
+#define MFIE_TYPE_GENERIC 221
+
+struct ieee80211_info_element_hdr {
+ u8 id;
+ u8 len;
+} __attribute__ ((packed));
+
+struct ieee80211_info_element {
+ u8 id;
+ u8 len;
+ u8 data[0];
+} __attribute__ ((packed));
+
+/*
+ * These are the data types that can make up management packets
+ *
+ u16 auth_algorithm;
+ u16 auth_sequence;
+ u16 beacon_interval;
+ u16 capability;
+ u8 current_ap[ETH_ALEN];
+ u16 listen_interval;
+ struct {
+ u16 association_id:14, reserved:2;
+ } __attribute__ ((packed));
+ u32 time_stamp[2];
+ u16 reason;
+ u16 status;
+*/
+
+#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
+#define IEEE80211_DEFAULT_BASIC_RATE 10
+
+struct ieee80211_authentication {
+ struct ieee80211_header_data header;
+ u16 algorithm;
+ u16 transaction;
+ u16 status;
+} __attribute__ ((packed));
+
+struct ieee80211_probe_response {
+ struct ieee80211_header_data header;
+ u32 time_stamp[2];
+ u16 beacon_interval;
+ u16 capability;
+ struct ieee80211_info_element info_element;
+} __attribute__ ((packed));
+
+struct ieee80211_probe_request {
+ struct ieee80211_header_data header;
+} __attribute__ ((packed));
+
+struct ieee80211_assoc_request_frame {
+ struct ieee80211_hdr_3addr header;
+ u16 capability;
+ u16 listen_interval;
+ struct ieee80211_info_element_hdr info_element;
+} __attribute__ ((packed));
+
+struct ieee80211_assoc_response_frame {
+ struct ieee80211_hdr_3addr header;
+ u16 capability;
+ u16 status;
+ u16 aid;
+} __attribute__ ((packed));
+
+struct ieee80211_txb {
+ u8 nr_frags;
+ u8 encrypted;
+ u16 reserved;
+ u16 frag_size;
+ u16 payload_size;
+ struct sk_buff *fragments[0];
+};
+
+/* SWEEP TABLE ENTRIES NUMBER*/
+#define MAX_SWEEP_TAB_ENTRIES 42
+#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
+/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
+ * only use 8, and then use extended rates for the remaining supported
+ * rates. Other APs, however, stick all of their supported rates on the
+ * main rates information element... */
+#define MAX_RATES_LENGTH ((u8)12)
+#define MAX_RATES_EX_LENGTH ((u8)16)
+#define MAX_NETWORK_COUNT 128
+#define MAX_CHANNEL_NUMBER 161
+#define IEEE80211_SOFTMAC_SCAN_TIME 400
+/*(HZ / 2)*/
+#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
+
+#define CRC_LENGTH 4U
+
+#define MAX_WPA_IE_LEN 128
+#define MAX_WPS_IE_LEN 512
+
+#define NETWORK_EMPTY_ESSID (1<<0)
+#define NETWORK_HAS_OFDM (1<<1)
+#define NETWORK_HAS_CCK (1<<2)
+
+#define IEEE80211_DTIM_MBCAST 4
+#define IEEE80211_DTIM_UCAST 2
+#define IEEE80211_DTIM_VALID 1
+#define IEEE80211_DTIM_INVALID 0
+
+#define IEEE80211_PS_DISABLED 0
+#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
+#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
+#define IW_ESSID_MAX_SIZE 32
+/*
+ * join_res:
+ * -1: authentication fail
+ * -2: association fail
+ * > 0: TID
+ */
+
+enum ieee80211_state {
+ /* the card is not linked at all */
+ IEEE80211_NOLINK = 0,
+ /* IEEE80211_ASSOCIATING* are for BSS client mode
+ * the driver shall not perform RX filtering unless
+ * the state is LINKED.
+ * The driver shall just check for the state LINKED and
+ * defaults to NOLINK for ALL the other states (including
+ * LINKED_SCANNING)
+ */
+ /* the association procedure will start (wq scheduling)*/
+ IEEE80211_ASSOCIATING,
+ IEEE80211_ASSOCIATING_RETRY,
+ /* the association procedure is sending AUTH request*/
+ IEEE80211_ASSOCIATING_AUTHENTICATING,
+ /* the association procedure has successfully authentcated
+ * and is sending association request
+ */
+ IEEE80211_ASSOCIATING_AUTHENTICATED,
+ /* the link is ok. the card associated to a BSS or linked
+ * to a ibss cell or acting as an AP and creating the bss
+ */
+ IEEE80211_LINKED,
+ /* same as LINKED, but the driver shall apply RX filter
+ * rules as we are in NO_LINK mode. As the card is still
+ * logically linked, but it is doing a syncro site survey
+ * then it will be back to LINKED state.
+ */
+ IEEE80211_LINKED_SCANNING,
+};
+
+#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
+#define DEFAULT_FTS 2346
+
+#define CFG_IEEE80211_RESERVE_FCS (1<<0)
+#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
+
+#define MAXTID 16
+
+#define IEEE_A (1<<0)
+#define IEEE_B (1<<1)
+#define IEEE_G (1<<2)
+#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
+
+extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+{
+ /* Single white space is for Linksys APs */
+ if (essid_len == 1 && essid[0] == ' ')
+ return 1;
+ /* Otherwise, if the entire essid is 0, we assume it is hidden */
+ while (essid_len) {
+ essid_len--;
+ if (essid[essid_len] != '\0')
+ return 0;
+ }
+ return 1;
+}
+
+extern inline int ieee80211_get_hdrlen(u16 fc)
+{
+ int hdrlen = 24;
+
+ switch (WLAN_FC_GET_TYPE(fc)) {
+ case IEEE80211_FTYPE_DATA:
+ if (fc & IEEE80211_QOS_DATAGRP)
+ hdrlen += 2;
+ if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
+ hdrlen += 6; /* Addr4 */
+ break;
+ case IEEE80211_FTYPE_CTL:
+ switch (WLAN_FC_GET_STYPE(fc)) {
+ case IEEE80211_STYPE_CTS:
+ case IEEE80211_STYPE_ACK:
+ hdrlen = 10;
+ break;
+ default:
+ hdrlen = 16;
+ break;
+ }
+ break;
+ }
+ return hdrlen;
+}
+
+struct registry_priv;
+
+u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
+u8 *r8712_get_ie(u8*pbuf, sint index, sint *len, sint limit);
+unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
+unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
+int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
+ int *pairwise_cipher);
+int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
+ int *pairwise_cipher);
+int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie,
+ u16 *wpa_len);
+int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
+int r8712_generate_ie(struct registry_priv *pregistrypriv, struct _adapter *padapter);
+uint r8712_is_cckrates_included(u8 *rate);
+uint r8712_is_cckratesonly_included(u8 *rate);
+
+#endif /* IEEE80211_H */
+
diff --git a/drivers/staging/rtl8712/if_ether.h b/drivers/staging/rtl8712/if_ether.h
new file mode 100644
index 000000000000..36a2ba5c86f1
--- /dev/null
+++ b/drivers/staging/rtl8712/if_ether.h
@@ -0,0 +1,116 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Global definitions for the Ethernet IEEE 802.3 interface.
+ *
+ * Version: @(#)if_ether.h 1.0.1a 02/08/94
+ *
+ * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ * Donald Becker, <becker@super.org>
+ * Alan Cox, <alan@redhat.com>
+ * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _LINUX_IF_ETHER_H
+#define _LINUX_IF_ETHER_H
+
+/*
+ * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
+ * and FCS/CRC (frame check sequence).
+ */
+
+#define ETH_ALEN 6 /* Octets in one ethernet addr */
+#define ETH_HLEN 14 /* Total octets in header. */
+#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
+#define ETH_DATA_LEN 1500 /* Max. octets in payload */
+#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
+
+/*
+ * These are the defined Ethernet Protocol ID's.
+ */
+
+#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
+#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
+#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
+#define ETH_P_IP 0x0800 /* Internet Protocol packet */
+#define ETH_P_X25 0x0805 /* CCITT X.25 */
+#define ETH_P_ARP 0x0806 /* Address Resolution packet */
+#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet
+ * [ NOT AN OFFICIAL ID ] */
+#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
+#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr
+ * Trans packet */
+#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
+#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
+#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
+#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
+#define ETH_P_LAT 0x6004 /* DEC LAT */
+#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
+#define ETH_P_CUST 0x6006 /* DEC Customer use */
+#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
+#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
+#define ETH_P_ATALK 0x809B /* Appletalk DDP */
+#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
+#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
+#define ETH_P_IPX 0x8137 /* IPX over DIX */
+#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
+#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
+#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
+#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
+#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
+ * over Ethernet
+ */
+
+/*
+ * Non DIX types. Won't clash for 1500 types.
+ */
+
+#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
+#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
+#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
+#define ETH_P_802_2 0x0004 /* 802.2 frames */
+#define ETH_P_SNAP 0x0005 /* Internal only */
+#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
+#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
+#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
+#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
+#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
+#define ETH_P_TR_802_2 0x0011i /* 802.2 frames */
+#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
+#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
+#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
+#define ETH_P_ECONET 0x0018 /* Acorn Econet */
+
+/*
+ * This is an Ethernet frame header.
+ */
+
+struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ unsigned short h_proto; /* packet type ID field */
+};
+
+struct _vlan {
+ unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID*/
+ unsigned short h_vlan_encapsulated_proto;
+};
+
+
+
+#define get_vlan_id(pvlan) ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff)
+#define get_vlan_priority(pvlan) ((ntohs((unsigned short)\
+ pvlan->h_vlan_TCI)) >> 13)
+#define get_vlan_encap_proto(pvlan) (ntohs((unsigned short)\
+ pvlan->h_vlan_encapsulated_proto))
+
+
+#endif /* _LINUX_IF_ETHER_H */
+
diff --git a/drivers/staging/rtl8712/ip.h b/drivers/staging/rtl8712/ip.h
new file mode 100644
index 000000000000..4785a591486c
--- /dev/null
+++ b/drivers/staging/rtl8712/ip.h
@@ -0,0 +1,137 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Definitions for the IP protocol.
+ *
+ * Version: @(#)ip.h 1.0.2 04/28/93
+ *
+ * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#ifndef _LINUX_IP_H
+#define _LINUX_IP_H
+
+#include "rtl871x_byteorder.h"
+
+/* SOL_IP socket options */
+
+#define IPTOS_TOS_MASK 0x1E
+#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_MINCOST 0x02
+
+#define IPTOS_PREC_MASK 0xE0
+#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+/* IP options */
+#define IPOPT_COPY 0x80
+#define IPOPT_CLASS_MASK 0x60
+#define IPOPT_NUMBER_MASK 0x1f
+
+#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
+#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
+#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_MEASUREMENT 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_END (0 | IPOPT_CONTROL)
+#define IPOPT_NOOP (1 | IPOPT_CONTROL)
+#define IPOPT_SEC (2 | IPOPT_CONTROL|IPOPT_COPY)
+#define IPOPT_LSRR (3 | IPOPT_CONTROL|IPOPT_COPY)
+#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT)
+#define IPOPT_RR (7 | IPOPT_CONTROL)
+#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY)
+#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY)
+#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY)
+
+#define IPVERSION 4
+#define MAXTTL 255
+#define IPDEFTTL 64
+
+/* struct timestamp, struct route and MAX_ROUTES are removed.
+ *
+ * REASONS: it is clear that nobody used them because:
+ * - MAX_ROUTES value was wrong.
+ * - "struct route" was wrong.
+ * - "struct timestamp" had fatally misaligned bitfields and was completely
+ * unusable.
+ */
+
+#define IPOPT_OPTVAL 0
+#define IPOPT_OLEN 1
+#define IPOPT_OFFSET 2
+#define IPOPT_MINOFF 4
+#define MAX_IPOPTLEN 40
+#define IPOPT_NOP IPOPT_NOOP
+#define IPOPT_EOL IPOPT_END
+#define IPOPT_TS IPOPT_TIMESTAMP
+
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+struct ip_options {
+ __u32 faddr; /* Saved first hop address */
+ unsigned char optlen;
+ unsigned char srr;
+ unsigned char rr;
+ unsigned char ts;
+ unsigned char is_setbyuser:1, /* Set by setsockopt? */
+ is_data:1, /* Options in __data, rather than skb */
+ is_strictroute:1, /* Strict source route */
+ srr_is_hit:1, /* Packet destination addr was our one */
+ is_changed:1, /* IP checksum more not valid */
+ rr_needaddr:1, /* Need to record addr of outgoing dev */
+ ts_needtime:1, /* Need to record timestamp */
+ ts_needaddr:1; /* Need to record addr of outgoing dev */
+ unsigned char router_alert;
+ unsigned char __pad1;
+ unsigned char __pad2;
+ unsigned char __data[0];
+};
+
+#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
+
+struct iphdr {
+#if defined(__LITTLE_ENDIAN_BITFIELD)
+ __u8 ihl:4,
+ version:4;
+#elif defined(__BIG_ENDIAN_BITFIELD)
+ __u8 version:4,
+ ihl:4;
+#else
+#error "Please fix <asm/byteorder.h>"
+#endif
+ __u8 tos;
+ __u16 tot_len;
+ __u16 id;
+ __u16 frag_off;
+ __u8 ttl;
+ __u8 protocol;
+ __u16 check;
+ __u32 saddr;
+ __u32 daddr;
+ /*The options start here. */
+};
+
+#endif /* _LINUX_IP_H */
+
diff --git a/drivers/staging/rtl8712/little_endian.h b/drivers/staging/rtl8712/little_endian.h
new file mode 100644
index 000000000000..0248c143c6df
--- /dev/null
+++ b/drivers/staging/rtl8712/little_endian.h
@@ -0,0 +1,69 @@
+#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
+#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
+
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+#ifndef __LITTLE_ENDIAN_BITFIELD
+#define __LITTLE_ENDIAN_BITFIELD
+#endif
+
+#include "swab.h"
+
+#define __constant_htonl(x) ___constant_swab32((x))
+#define __constant_ntohl(x) ___constant_swab32((x))
+#define __constant_htons(x) ___constant_swab16((x))
+#define __constant_ntohs(x) ___constant_swab16((x))
+#define __constant_cpu_to_le64(x) ((__u64)(x))
+#define __constant_le64_to_cpu(x) ((__u64)(x))
+#define __constant_cpu_to_le32(x) ((__u32)(x))
+#define __constant_le32_to_cpu(x) ((__u32)(x))
+#define __constant_cpu_to_le16(x) ((__u16)(x))
+#define __constant_le16_to_cpu(x) ((__u16)(x))
+#define __constant_cpu_to_be64(x) ___constant_swab64((x))
+#define __constant_be64_to_cpu(x) ___constant_swab64((x))
+#define __constant_cpu_to_be32(x) ___constant_swab32((x))
+#define __constant_be32_to_cpu(x) ___constant_swab32((x))
+#define __constant_cpu_to_be16(x) ___constant_swab16((x))
+#define __constant_be16_to_cpu(x) ___constant_swab16((x))
+#define __cpu_to_le64(x) ((__u64)(x))
+#define __le64_to_cpu(x) ((__u64)(x))
+#define __cpu_to_le32(x) ((__u32)(x))
+#define __le32_to_cpu(x) ((__u32)(x))
+#define __cpu_to_le16(x) ((__u16)(x))
+#define __le16_to_cpu(x) ((__u16)(x))
+#define __cpu_to_be64(x) __swab64((x))
+#define __be64_to_cpu(x) __swab64((x))
+#define __cpu_to_be32(x) __swab32((x))
+#define __be32_to_cpu(x) __swab32((x))
+#define __cpu_to_be16(x) __swab16((x))
+#define __be16_to_cpu(x) __swab16((x))
+#define __cpu_to_le64p(x) (*(__u64 *)(x))
+#define __le64_to_cpup(x) (*(__u64 *)(x))
+#define __cpu_to_le32p(x) (*(__u32 *)(x))
+#define __le32_to_cpup(x) (*(__u32 *)(x))
+#define __cpu_to_le16p(x) (*(__u16 *)(x))
+#define __le16_to_cpup(x) (*(__u16 *)(x))
+#define __cpu_to_be64p(x) __swab64p((x))
+#define __be64_to_cpup(x) __swab64p((x))
+#define __cpu_to_be32p(x) __swab32p((x))
+#define __be32_to_cpup(x) __swab32p((x))
+#define __cpu_to_be16p(x) __swab16p((x))
+#define __be16_to_cpup(x) __swab16p((x))
+#define __cpu_to_le64s(x) do {} while (0)
+#define __le64_to_cpus(x) do {} while (0)
+#define __cpu_to_le32s(x) do {} while (0)
+#define __le32_to_cpus(x) do {} while (0)
+#define __cpu_to_le16s(x) do {} while (0)
+#define __le16_to_cpus(x) do {} while (0)
+#define __cpu_to_be64s(x) __swab64s((x))
+#define __be64_to_cpus(x) __swab64s((x))
+#define __cpu_to_be32s(x) __swab32s((x))
+#define __be32_to_cpus(x) __swab32s((x))
+#define __cpu_to_be16s(x) __swab16s((x))
+#define __be16_to_cpus(x) __swab16s((x))
+
+#include "generic.h"
+
+#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
+
diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c
new file mode 100644
index 000000000000..abf96c14df93
--- /dev/null
+++ b/drivers/staging/rtl8712/mlme_linux.c
@@ -0,0 +1,170 @@
+/******************************************************************************
+ * mlme_linux.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _MLME_OSDEP_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "mlme_osdep.h"
+
+static void sitesurvey_ctrl_handler(void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+
+ _r8712_sitesurvey_ctrl_handler(adapter);
+ _set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
+ 3000);
+}
+
+static void join_timeout_handler (void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+ _r8712_join_timeout_handler(adapter);
+}
+
+static void _scan_timeout_handler (void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+ r8712_scan_timeout_handler(adapter);
+}
+
+static void dhcp_timeout_handler (void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+ _r8712_dhcp_timeout_handler(adapter);
+}
+
+static void wdg_timeout_handler (void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+
+ _r8712_wdg_timeout_handler(adapter);
+
+ _set_timer(&adapter->mlmepriv.wdg_timer, 2000);
+}
+
+void r8712_init_mlme_timer(struct _adapter *padapter)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
+ join_timeout_handler, (pmlmepriv->nic_hdl));
+ _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
+ padapter->pnetdev, sitesurvey_ctrl_handler,
+ (u8 *)(pmlmepriv->nic_hdl));
+ _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
+ _scan_timeout_handler, (pmlmepriv->nic_hdl));
+ _init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
+ dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
+ _init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
+ wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
+}
+
+void r8712_os_indicate_connect(struct _adapter *adapter)
+{
+ r8712_indicate_wx_assoc_event(adapter);
+ netif_carrier_on(adapter->pnetdev);
+}
+
+static struct RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
+void r8712_os_indicate_disconnect(struct _adapter *adapter)
+{
+ u8 backupPMKIDIndex = 0;
+ u8 backupTKIPCountermeasure = 0x00;
+
+ r8712_indicate_wx_disassoc_event(adapter);
+ netif_carrier_off(adapter->pnetdev);
+ if (adapter->securitypriv.AuthAlgrthm == 2) { /*/802.1x*/
+ /* We have to backup the PMK information for WiFi PMK Caching
+ * test item. Backup the btkip_countermeasure information.
+ * When the countermeasure is trigger, the driver have to
+ * disconnect with AP for 60 seconds.
+ */
+
+ memset(&backupPMKIDList[0], 0x00, sizeof(
+ struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ memcpy(&backupPMKIDList[0], &adapter->securitypriv.
+ PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
+ NUM_PMKID_CACHE);
+ backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
+ backupTKIPCountermeasure = adapter->securitypriv.
+ btkip_countermeasure;
+ memset((unsigned char *)&adapter->securitypriv, 0,
+ sizeof(struct security_priv));
+ _init_timer(&(adapter->securitypriv.tkip_timer),
+ adapter->pnetdev, r8712_use_tkipkey_handler,
+ adapter);
+ /* Restore the PMK information to securitypriv structure
+ * for the following connection. */
+ memcpy(&adapter->securitypriv.PMKIDList[0],
+ &backupPMKIDList[0],
+ sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
+ adapter->securitypriv.btkip_countermeasure =
+ backupTKIPCountermeasure;
+ } else { /*reset values in securitypriv*/
+ struct security_priv *psec_priv = &adapter->securitypriv;
+
+ psec_priv->AuthAlgrthm = 0; /*open system*/
+ psec_priv->PrivacyAlgrthm = _NO_PRIVACY_;
+ psec_priv->PrivacyKeyIndex = 0;
+ psec_priv->XGrpPrivacy = _NO_PRIVACY_;
+ psec_priv->XGrpKeyid = 1;
+ psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
+ psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
+ psec_priv->wps_phase = false;
+ }
+}
+
+void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie)
+{
+ uint len;
+ u8 *buff, *p, i;
+ union iwreq_data wrqu;
+
+ buff = NULL;
+ if (authmode == _WPA_IE_ID_) {
+ buff = _malloc(IW_CUSTOM_MAX);
+ if (buff == NULL)
+ return;
+ memset(buff, 0, IW_CUSTOM_MAX);
+ p = buff;
+ p += sprintf(p, "ASSOCINFO(ReqIEs=");
+ len = sec_ie[1] + 2;
+ len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
+ for (i = 0; i < len; i++)
+ p += sprintf(p, "%02x", sec_ie[i]);
+ p += sprintf(p, ")");
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = p-buff;
+ wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
+ wrqu.data.length : IW_CUSTOM_MAX;
+ wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
+ kfree(buff);
+ }
+}
diff --git a/drivers/staging/rtl8712/mlme_osdep.h b/drivers/staging/rtl8712/mlme_osdep.h
new file mode 100644
index 000000000000..7013a4980802
--- /dev/null
+++ b/drivers/staging/rtl8712/mlme_osdep.h
@@ -0,0 +1,18 @@
+#ifndef __MLME_OSDEP_H_
+#define __MLME_OSDEP_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+void r8712_init_mlme_timer(struct _adapter *padapter);
+void r8712_os_indicate_disconnect(struct _adapter *adapter);
+void r8712_os_indicate_connect(struct _adapter *adapter);
+void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie);
+int r8712_recv_indicatepkts_in_order(struct _adapter *adapter,
+ struct recv_reorder_ctrl *precvreorder_ctrl,
+ int bforced);
+void r8712_indicate_wx_assoc_event(struct _adapter *padapter);
+void r8712_indicate_wx_disassoc_event(struct _adapter *padapter);
+
+#endif /*_MLME_OSDEP_H_*/
+
diff --git a/drivers/staging/rtl8712/mp_custom_oid.h b/drivers/staging/rtl8712/mp_custom_oid.h
new file mode 100644
index 000000000000..a9e0b3483e3c
--- /dev/null
+++ b/drivers/staging/rtl8712/mp_custom_oid.h
@@ -0,0 +1,274 @@
+#ifndef __CUSTOM_OID_H
+#define __CUSTOM_OID_H
+
+/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit
+ * 0xFF818500 - 0xFF81850F RTL8185 Setup Utility
+ * 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility
+ *
+ * by Owen for Production Kit
+ * For Production Kit with Agilent Equipments
+ * in order to make our custom oids hopefully somewhat unique
+ * we will use 0xFF (indicating implementation specific OID)
+ * 81(first byte of non zero Realtek unique identifier)
+ * 80 (second byte of non zero Realtek unique identifier)
+ * XX (the custom OID number - providing 255 possible custom oids)
+ */
+#define OID_RT_PRO_RESET_DUT 0xFF818000
+#define OID_RT_PRO_SET_DATA_RATE 0xFF818001
+#define OID_RT_PRO_START_TEST 0xFF818002
+#define OID_RT_PRO_STOP_TEST 0xFF818003
+#define OID_RT_PRO_SET_PREAMBLE 0xFF818004
+#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005
+#define OID_RT_PRO_SET_FILTER_BB 0xFF818006
+#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007
+#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008
+#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009
+#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A
+
+#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D
+#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E
+#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F
+#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010
+#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011
+#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012
+#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013
+#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014
+#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015
+#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016
+#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017
+#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018
+#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019
+#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A
+#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B
+#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C
+#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D
+#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E
+#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F
+#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020
+#define OID_RT_PRO_WRITE_EEPROM 0xFF818021
+#define OID_RT_PRO_READ_EEPROM 0xFF818022
+#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023
+#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024
+#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025
+#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026
+#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027
+#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028
+#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029
+#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A
+#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C
+#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D
+#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E
+#define OID_RT_PRO_SET_MODULATION 0xFF81802F
+#define OID_RT_DRIVER_OPTION 0xFF818080
+#define OID_RT_RF_OFF 0xFF818081
+#define OID_RT_AUTH_STATUS 0xFF818082
+#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B
+#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C
+#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B
+#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043
+#define OID_RT_UTILITY_FALSE_ALARM_COUNTERS 0xFF818580
+#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581
+#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582
+#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583
+#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584
+#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS \
+ 0xFF818585
+#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586
+#define OID_RT_WIRELESS_MODE 0xFF818500
+#define OID_RT_SUPPORTED_RATES 0xFF818501
+#define OID_RT_DESIRED_RATES 0xFF818502
+#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503
+#define OID_RT_GET_CONNECT_STATE 0xFF030001
+#define OID_RT_RESCAN 0xFF030002
+#define OID_RT_SET_KEY_LENGTH 0xFF030003
+#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004
+#define OID_RT_SET_CHANNEL 0xFF010182
+#define OID_RT_SET_SNIFFER_MODE 0xFF010183
+#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184
+#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185
+#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186
+#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187
+#define OID_RT_GET_TX_RETRY 0xFF010188
+#define OID_RT_GET_RX_RETRY 0xFF010189
+#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A
+#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B
+#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190
+#define OID_RT_GET_TX_BEACON_OK 0xFF010191
+#define OID_RT_GET_TX_BEACON_ERR 0xFF010192
+#define OID_RT_GET_RX_ICV_ERR 0xFF010193
+#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194
+#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195
+#define OID_RT_GET_PREAMBLE_MODE 0xFF010196
+#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197
+#define OID_RT_GET_AP_IP 0xFF010198
+#define OID_RT_GET_CHANNELPLAN 0xFF010199
+#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A
+#define OID_RT_SET_BCN_INTVL 0xFF01019B
+#define OID_RT_GET_RF_VENDER 0xFF01019C
+#define OID_RT_DEDICATE_PROBE 0xFF01019D
+#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E
+#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F
+#define OID_RT_GET_CCA_ERR 0xFF0101A0
+#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1
+#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2
+#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3
+#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4
+#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5
+#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5
+#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6
+#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7
+#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8
+#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9
+#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA
+#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB
+#define OID_RT_GET_CHANNEL 0xFF0101AC
+#define OID_RT_SET_CHANNELPLAN 0xFF0101AD
+#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE
+#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF
+#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0
+#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1
+#define OID_RT_GET_IS_ROAMING 0xFF0101B2
+#define OID_RT_GET_IS_PRIVACY 0xFF0101B3
+#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4
+#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5
+#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6
+#define OID_RT_RESET_LOG 0xFF0101B7
+#define OID_RT_GET_LOG 0xFF0101B8
+#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9
+#define OID_RT_GET_HEADER_FAIL 0xFF0101BA
+#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB
+#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC
+#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD
+#define OID_RT_GET_TX_INFO 0xFF0101BE
+#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF
+#define OID_RT_RF_READ_WRITE 0xFF0101C0
+#define OID_RT_FORCED_DATA_RATE 0xFF0101C1
+#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2
+#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3
+#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4
+#define OID_RT_PRO_RX_FILTER 0xFF0111C0
+#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1
+#define OID_CE_USB_READ_REGISTRY 0xFF0111C2
+#define OID_RT_PRO_SET_INITIAL_GAIN 0xFF0111C3
+#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4
+#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5
+#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6
+#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7
+#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8
+#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9
+#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA
+#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300
+#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301
+#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302
+#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303
+#define OID_RT_AP_SUPPORTED 0xFF010304
+#define OID_RT_AP_SET_PASSPHRASE 0xFF010305
+#define OID_RT_PRO8187_WI_POLL 0xFF818780
+#define OID_RT_PRO_WRITE_BB_REG 0xFF818781
+#define OID_RT_PRO_READ_BB_REG 0xFF818782
+#define OID_RT_PRO_WRITE_RF_REG 0xFF818783
+#define OID_RT_PRO_READ_RF_REG 0xFF818784
+#define OID_RT_MH_VENDER_ID 0xFFEDC100
+#define OID_RT_PRO8711_JOIN_BSS 0xFF871100
+#define OID_RT_PRO_READ_REGISTER 0xFF871101
+#define OID_RT_PRO_WRITE_REGISTER 0xFF871102
+#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103
+#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104
+#define OID_RT_PRO_WRITE_TXCMD 0xFF871105
+#define OID_RT_PRO_READ16_EEPROM 0xFF871106
+#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107
+#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108
+#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109
+#define OID_RT_PRO8711_WI_POLL 0xFF87110A
+#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B
+#define OID_RT_RD_ATTRIB_MEM 0xFF87110C
+#define OID_RT_WR_ATTRIB_MEM 0xFF87110D
+/*Method 2 for H2C/C2H*/
+#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110
+#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111
+#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112
+#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113
+#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114
+#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115
+#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116
+#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117
+#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118
+#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119
+#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A
+#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B
+#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C
+#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D
+#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E
+#define OID_RT_POLL_RX_STATUS 0xFF87111F
+#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120
+#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121
+#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122
+#define OID_RT_PRO_READ_TSSI 0xFF871123
+#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124
+#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150
+#define OID_RT_PRO_SET_PWRSTATE 0xFF871151
+/*Method 2 , using workitem */
+#define OID_RT_SET_READ_REG 0xFF871181
+#define OID_RT_SET_WRITE_REG 0xFF871182
+#define OID_RT_SET_BURST_READ_REG 0xFF871183
+#define OID_RT_SET_BURST_WRITE_REG 0xFF871184
+#define OID_RT_SET_WRITE_TXCMD 0xFF871185
+#define OID_RT_SET_READ16_EEPROM 0xFF871186
+#define OID_RT_SET_WRITE16_EEPROM 0xFF871187
+#define OID_RT_QRY_POLL_WKITEM 0xFF871188
+
+/*For SDIO INTERFACE only*/
+#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0
+#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1
+
+/*For USB INTERFACE only*/
+#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0
+#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1
+#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2
+#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3
+#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4
+
+#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB
+#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC
+#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE
+
+#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200
+#define OID_RT_PRO_ADD_STA_INFO 0xFF871201
+#define OID_RT_PRO_DELE_STA_INFO 0xFF871202
+#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203
+
+#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204
+
+#define OID_RT_PRO_READ_EFUSE 0xFF871205
+#define OID_RT_PRO_WRITE_EFUSE 0xFF871206
+#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207
+#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208
+
+#define OID_RT_SET_BANDWIDTH 0xFF871209
+#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A
+
+#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B
+
+#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C
+
+#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D
+
+#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E
+
+#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F
+
+#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210
+
+#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211
+#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212
+#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213
+
+#define OID_RT_SET_POWER_DOWN 0xFF871214
+
+#define OID_RT_GET_POWER_MODE 0xFF871215
+
+#define OID_RT_PRO_EFUSE 0xFF871216
+#define OID_RT_PRO_EFUSE_MAP 0xFF871217
+
+#endif /*#ifndef __CUSTOM_OID_H */
+
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
new file mode 100644
index 000000000000..3f38e8eca3f1
--- /dev/null
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -0,0 +1,464 @@
+/******************************************************************************
+ * os_intfs.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _OS_INTFS_C_
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kthread.h>
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "xmit_osdep.h"
+#include "recv_osdep.h"
+#include "rtl871x_ioctl.h"
+#include "usb_osintf.h"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("rtl871x wireless lan driver");
+MODULE_AUTHOR("Larry Finger");
+
+static char ifname[IFNAMSIZ] = "wlan%d";
+
+/* module param defaults */
+static int chip_version = RTL8712_2ndCUT;
+static int rfintfs = HWPI;
+static int lbkmode = RTL8712_AIR_TRX;
+static int hci = RTL8712_USB;
+static int ampdu_enable = 1;/*for enable tx_ampdu*/
+
+/* The video_mode variable is for vedio mode.*/
+/* It may be specify when inserting module with video_mode=1 parameter.*/
+static int video_mode = 1; /* enable video mode*/
+
+/*Ndis802_11Infrastructure; infra, ad-hoc, auto*/
+static int network_mode = Ndis802_11IBSS;
+static int channel = 1;/*ad-hoc support requirement*/
+static int wireless_mode = WIRELESS_11BG;
+static int vrtl_carrier_sense = AUTO_VCS;
+static int vcs_type = RTS_CTS;
+static int frag_thresh = 2346;
+static int preamble = PREAMBLE_LONG;/*long, short, auto*/
+static int scan_mode = 1;/*active, passive*/
+static int adhoc_tx_pwr = 1;
+static int soft_ap;
+static int smart_ps = 1;
+static int power_mgnt = PS_MODE_ACTIVE;
+static int radio_enable = 1;
+static int long_retry_lmt = 7;
+static int short_retry_lmt = 7;
+static int busy_thresh = 40;
+static int ack_policy = NORMAL_ACK;
+static int mp_mode;
+static int software_encrypt;
+static int software_decrypt;
+
+static int wmm_enable;/* default is set to disable the wmm.*/
+static int uapsd_enable;
+static int uapsd_max_sp = NO_LIMIT;
+static int uapsd_acbk_en;
+static int uapsd_acbe_en;
+static int uapsd_acvi_en;
+static int uapsd_acvo_en;
+
+static int ht_enable = 1;
+static int cbw40_enable = 1;
+static int rf_config = RTL8712_RF_1T2R; /* 1T2R*/
+static int low_power;
+/* mac address to use instead of the one stored in Efuse */
+char *r8712_initmac;
+static char *initmac;
+/* if wifi_test = 1, driver will disable the turbo mode and pass it to
+ * firmware private.
+ */
+static int wifi_test = 0;
+
+module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR);
+module_param(wifi_test, int, 0644);
+module_param(initmac, charp, 0644);
+module_param(video_mode, int, 0644);
+module_param(chip_version, int, 0644);
+module_param(rfintfs, int, 0644);
+module_param(lbkmode, int, 0644);
+module_param(hci, int, 0644);
+module_param(network_mode, int, 0644);
+module_param(channel, int, 0644);
+module_param(mp_mode, int, 0644);
+module_param(wmm_enable, int, 0644);
+module_param(vrtl_carrier_sense, int, 0644);
+module_param(vcs_type, int, 0644);
+module_param(busy_thresh, int, 0644);
+module_param(ht_enable, int, 0644);
+module_param(cbw40_enable, int, 0644);
+module_param(ampdu_enable, int, 0644);
+module_param(rf_config, int, 0644);
+module_param(power_mgnt, int, 0644);
+module_param(low_power, int, 0644);
+
+MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default");
+MODULE_PARM_DESC(initmac, "MAC-Address, default: use FUSE");
+
+static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev);
+static int netdev_open(struct net_device *pnetdev);
+static int netdev_close(struct net_device *pnetdev);
+
+static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev)
+{
+ uint status = _SUCCESS;
+ struct registry_priv *registry_par = &padapter->registrypriv;
+
+ registry_par->chip_version = (u8)chip_version;
+ registry_par->rfintfs = (u8)rfintfs;
+ registry_par->lbkmode = (u8)lbkmode;
+ registry_par->hci = (u8)hci;
+ registry_par->network_mode = (u8)network_mode;
+ memcpy(registry_par->ssid.Ssid, "ANY", 3);
+ registry_par->ssid.SsidLength = 3;
+ registry_par->channel = (u8)channel;
+ registry_par->wireless_mode = (u8)wireless_mode;
+ registry_par->vrtl_carrier_sense = (u8)vrtl_carrier_sense ;
+ registry_par->vcs_type = (u8)vcs_type;
+ registry_par->frag_thresh = (u16)frag_thresh;
+ registry_par->preamble = (u8)preamble;
+ registry_par->scan_mode = (u8)scan_mode;
+ registry_par->adhoc_tx_pwr = (u8)adhoc_tx_pwr;
+ registry_par->soft_ap = (u8)soft_ap;
+ registry_par->smart_ps = (u8)smart_ps;
+ registry_par->power_mgnt = (u8)power_mgnt;
+ registry_par->radio_enable = (u8)radio_enable;
+ registry_par->long_retry_lmt = (u8)long_retry_lmt;
+ registry_par->short_retry_lmt = (u8)short_retry_lmt;
+ registry_par->busy_thresh = (u16)busy_thresh;
+ registry_par->ack_policy = (u8)ack_policy;
+ registry_par->mp_mode = (u8)mp_mode;
+ registry_par->software_encrypt = (u8)software_encrypt;
+ registry_par->software_decrypt = (u8)software_decrypt;
+ /*UAPSD*/
+ registry_par->wmm_enable = (u8)wmm_enable;
+ registry_par->uapsd_enable = (u8)uapsd_enable;
+ registry_par->uapsd_max_sp = (u8)uapsd_max_sp;
+ registry_par->uapsd_acbk_en = (u8)uapsd_acbk_en;
+ registry_par->uapsd_acbe_en = (u8)uapsd_acbe_en;
+ registry_par->uapsd_acvi_en = (u8)uapsd_acvi_en;
+ registry_par->uapsd_acvo_en = (u8)uapsd_acvo_en;
+ registry_par->ht_enable = (u8)ht_enable;
+ registry_par->cbw40_enable = (u8)cbw40_enable;
+ registry_par->ampdu_enable = (u8)ampdu_enable;
+ registry_par->rf_config = (u8)rf_config;
+ registry_par->low_power = (u8)low_power;
+ registry_par->wifi_test = (u8) wifi_test;
+ r8712_initmac = initmac;
+ return status;
+}
+
+static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev);
+ struct sockaddr *addr = p;
+
+ if (padapter->bup == false)
+ memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
+ return 0;
+}
+
+static struct net_device_stats *r871x_net_get_stats(struct net_device *pnetdev)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev);
+ struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
+ struct recv_priv *precvpriv = &(padapter->recvpriv);
+
+ padapter->stats.tx_packets = pxmitpriv->tx_pkts;
+ padapter->stats.rx_packets = precvpriv->rx_pkts;
+ padapter->stats.tx_dropped = pxmitpriv->tx_drop;
+ padapter->stats.rx_dropped = precvpriv->rx_drop;
+ padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
+ padapter->stats.rx_bytes = precvpriv->rx_bytes;
+ return &padapter->stats;
+}
+
+static const struct net_device_ops rtl8712_netdev_ops = {
+ .ndo_open = netdev_open,
+ .ndo_stop = netdev_close,
+ .ndo_start_xmit = r8712_xmit_entry,
+ .ndo_set_mac_address = r871x_net_set_mac_address,
+ .ndo_get_stats = r871x_net_get_stats,
+ .ndo_do_ioctl = r871x_ioctl,
+};
+
+struct net_device *r8712_init_netdev(void)
+{
+ struct _adapter *padapter;
+ struct net_device *pnetdev;
+
+ pnetdev = alloc_etherdev(sizeof(struct _adapter));
+ if (!pnetdev)
+ return NULL;
+ if (dev_alloc_name(pnetdev, ifname) < 0) {
+ strcpy(ifname, "wlan%d");
+ dev_alloc_name(pnetdev, ifname);
+ }
+ padapter = (struct _adapter *) _netdev_priv(pnetdev);
+ padapter->pnetdev = pnetdev;
+ printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to"
+ " netdev_ops\n");
+ pnetdev->netdev_ops = &rtl8712_netdev_ops;
+ pnetdev->watchdog_timeo = HZ; /* 1 second timeout */
+ pnetdev->wireless_handlers = (struct iw_handler_def *)
+ &r871x_handlers_def;
+ /*step 2.*/
+ loadparam(padapter, pnetdev);
+ netif_carrier_off(pnetdev);
+ padapter->pid = 0; /* Initial the PID value used for HW PBC.*/
+ return pnetdev;
+}
+
+static u32 start_drv_threads(struct _adapter *padapter)
+{
+ padapter->cmdThread = kthread_run(r8712_cmd_thread, padapter,
+ padapter->pnetdev->name);
+ if (IS_ERR(padapter->cmdThread) < 0)
+ return _FAIL;
+ return _SUCCESS;
+}
+
+void r8712_stop_drv_threads(struct _adapter *padapter)
+{
+ /*Below is to termindate r8712_cmd_thread & event_thread...*/
+ up(&padapter->cmdpriv.cmd_queue_sema);
+ if (padapter->cmdThread)
+ _down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ padapter->cmdpriv.cmd_seq = 1;
+}
+
+static void start_drv_timers(struct _adapter *padapter)
+{
+ _set_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
+ 5000);
+ _set_timer(&padapter->mlmepriv.wdg_timer, 2000);
+}
+
+static void stop_drv_timers(struct _adapter *padapter)
+{
+ _cancel_timer_ex(&padapter->mlmepriv.assoc_timer);
+ _cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl.
+ sitesurvey_ctrl_timer);
+ _cancel_timer_ex(&padapter->securitypriv.tkip_timer);
+ _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer);
+ _cancel_timer_ex(&padapter->mlmepriv.dhcp_timer);
+ _cancel_timer_ex(&padapter->mlmepriv.wdg_timer);
+}
+
+static u8 init_default_value(struct _adapter *padapter)
+{
+ u8 ret = _SUCCESS;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ /*xmit_priv*/
+ pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
+ pxmitpriv->vcs = pregistrypriv->vcs_type;
+ pxmitpriv->vcs_type = pregistrypriv->vcs_type;
+ pxmitpriv->rts_thresh = pregistrypriv->rts_thresh;
+ pxmitpriv->frag_len = pregistrypriv->frag_thresh;
+ /*ht_priv*/
+ {
+ int i;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+
+ phtpriv->ampdu_enable = false;/*set to disabled*/
+ for (i = 0; i < 16; i++)
+ phtpriv->baddbareq_issued[i] = false;
+ }
+ /*security_priv*/
+ psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
+ psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
+ psecuritypriv->binstallGrpkey = _FAIL;
+ /*pwrctrl_priv*/
+ /*registry_priv*/
+ r8712_init_registrypriv_dev_network(padapter);
+ r8712_update_registrypriv_dev_network(padapter);
+ /*misc.*/
+ return ret;
+}
+
+u8 r8712_init_drv_sw(struct _adapter *padapter)
+{
+ if ((r8712_init_cmd_priv(&padapter->cmdpriv)) == _FAIL)
+ return _FAIL;
+ padapter->cmdpriv.padapter = padapter;
+ if ((r8712_init_evt_priv(&padapter->evtpriv)) == _FAIL)
+ return _FAIL;
+ if (r8712_init_mlme_priv(padapter) == _FAIL)
+ return _FAIL;
+ _r8712_init_xmit_priv(&padapter->xmitpriv, padapter);
+ _r8712_init_recv_priv(&padapter->recvpriv, padapter);
+ memset((unsigned char *)&padapter->securitypriv, 0,
+ sizeof(struct security_priv));
+ _init_timer(&(padapter->securitypriv.tkip_timer), padapter->pnetdev,
+ r8712_use_tkipkey_handler, padapter);
+ _r8712_init_sta_priv(&padapter->stapriv);
+ padapter->stapriv.padapter = padapter;
+ r8712_init_bcmc_stainfo(padapter);
+ r8712_init_pwrctrl_priv(padapter);
+ sema_init(&(padapter->pwrctrlpriv.pnp_pwr_mgnt_sema), 0);
+ mp871xinit(padapter);
+ if (init_default_value(padapter) != _SUCCESS)
+ return _FAIL;
+ r8712_InitSwLeds(padapter);
+ return _SUCCESS;
+}
+
+u8 r8712_free_drv_sw(struct _adapter *padapter)
+{
+ struct net_device *pnetdev = (struct net_device *)padapter->pnetdev;
+
+ r8712_free_cmd_priv(&padapter->cmdpriv);
+ r8712_free_evt_priv(&padapter->evtpriv);
+ r8712_DeInitSwLeds(padapter);
+ r8712_free_mlme_priv(&padapter->mlmepriv);
+ r8712_free_io_queue(padapter);
+ _free_xmit_priv(&padapter->xmitpriv);
+ _r8712_free_sta_priv(&padapter->stapriv);
+ _r8712_free_recv_priv(&padapter->recvpriv);
+ mp871xdeinit(padapter);
+ if (pnetdev)
+ os_free_netdev(pnetdev);
+ return _SUCCESS;
+}
+
+
+static void enable_video_mode(struct _adapter *padapter, int cbw40_value)
+{
+ /* bit 8:
+ * 1 -> enable video mode to 96B AP
+ * 0 -> disable video mode to 96B AP
+ * bit 9:
+ * 1 -> enable 40MHz mode
+ * 0 -> disable 40MHz mode
+ * bit 10:
+ * 1 -> enable STBC
+ * 0 -> disable STBC
+ */
+ u32 intcmd = 0xf4000500; /* enable bit8, bit10*/
+
+ if (cbw40_value) {
+ /* if the driver supports the 40M bandwidth,
+ * we can enable the bit 9.*/
+ intcmd |= 0x200;
+ }
+ r8712_fw_cmd(padapter, intcmd);
+}
+
+static int netdev_open(struct net_device *pnetdev)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev);
+
+ if (padapter->bup == false) {
+ padapter->bDriverStopped = false;
+ padapter->bSurpriseRemoved = false;
+ padapter->bup = true;
+ if (rtl871x_hal_init(padapter) != _SUCCESS)
+ goto netdev_open_error;
+ if (r8712_initmac == NULL)
+ /* Use the mac address stored in the Efuse */
+ memcpy(pnetdev->dev_addr,
+ padapter->eeprompriv.mac_addr, ETH_ALEN);
+ else {
+ /* We have to inform f/w to use user-supplied MAC
+ * address.
+ */
+ msleep(200);
+ r8712_setMacAddr_cmd(padapter, (u8 *)pnetdev->dev_addr);
+ /*
+ * The "myid" function will get the wifi mac address
+ * from eeprompriv structure instead of netdev
+ * structure. So, we have to overwrite the mac_addr
+ * stored in the eeprompriv structure. In this case,
+ * the real mac address won't be used anymore. So that,
+ * the eeprompriv.mac_addr should store the mac which
+ * users specify.
+ */
+ memcpy(padapter->eeprompriv.mac_addr,
+ pnetdev->dev_addr, ETH_ALEN);
+ }
+ if (start_drv_threads(padapter) != _SUCCESS)
+ goto netdev_open_error;
+ if (padapter->dvobjpriv.inirp_init == NULL)
+ goto netdev_open_error;
+ else
+ padapter->dvobjpriv.inirp_init(padapter);
+ r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt,
+ padapter->registrypriv.smart_ps);
+ }
+ if (!netif_queue_stopped(pnetdev))
+ netif_start_queue(pnetdev);
+ else
+ netif_wake_queue(pnetdev);
+
+ if (video_mode)
+ enable_video_mode(padapter, cbw40_enable);
+ /* start driver mlme relation timer */
+ start_drv_timers(padapter);
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK);
+ return 0;
+netdev_open_error:
+ padapter->bup = false;
+ netif_carrier_off(pnetdev);
+ netif_stop_queue(pnetdev);
+ return -1;
+}
+
+static int netdev_close(struct net_device *pnetdev)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev);
+
+ /* Close LED*/
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_POWER_OFF);
+ msleep(200);
+
+ /*s1.*/
+ if (pnetdev) {
+ if (!netif_queue_stopped(pnetdev))
+ netif_stop_queue(pnetdev);
+ }
+ /*s2.*/
+ /*s2-1. issue disassoc_cmd to fw*/
+ r8712_disassoc_cmd(padapter);
+ /*s2-2. indicate disconnect to os*/
+ r8712_ind_disconnect(padapter);
+ /*s2-3.*/
+ r8712_free_assoc_resources(padapter);
+ /*s2-4.*/
+ r8712_free_network_queue(padapter);
+ /*Stop driver mlme relation timer*/
+ stop_drv_timers(padapter);
+ return 0;
+}
+
+#include "mlme_osdep.h"
diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h
new file mode 100644
index 000000000000..3bc20257b034
--- /dev/null
+++ b/drivers/staging/rtl8712/osdep_intf.h
@@ -0,0 +1,19 @@
+#ifndef __OSDEP_INTF_H_
+#define __OSDEP_INTF_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2)
+
+struct intf_priv {
+ u8 *intf_dev;
+ /* when in USB, IO is through interrupt in/out endpoints */
+ struct usb_device *udev;
+ struct urb *piorw_urb;
+ struct semaphore io_retevt;
+};
+
+int r871x_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+
+#endif /*_OSDEP_INTF_H_*/
diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h
new file mode 100644
index 000000000000..73509dad2107
--- /dev/null
+++ b/drivers/staging/rtl8712/osdep_service.h
@@ -0,0 +1,260 @@
+#ifndef __OSDEP_SERVICE_H_
+#define __OSDEP_SERVICE_H_
+
+#define _SUCCESS 1
+#define _FAIL 0
+
+#include "basic_types.h"
+#include <linux/version.h>
+#include <linux/spinlock.h>
+
+#include <linux/semaphore.h>
+#include <linux/sem.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <net/iw_handler.h>
+#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
+#include <linux/compiler.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/kref.h>
+#include <linux/smp_lock.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/usb.h>
+#include <linux/usb/ch9.h>
+#include <linux/io.h>
+#include <linux/circ_buf.h>
+#include <linux/uaccess.h>
+#include <asm/byteorder.h>
+#include <asm/atomic.h>
+#include <linux/wireless.h>
+#include <linux/rtnetlink.h>
+#include "ethernet.h"
+#include <linux/if_arp.h>
+#include <linux/firmware.h>
+#define _usb_alloc_urb(x, y) usb_alloc_urb(x, y)
+#define _usb_submit_urb(x, y) usb_submit_urb(x, y)
+
+struct __queue {
+ struct list_head queue;
+ spinlock_t lock;
+};
+
+#define _pkt struct sk_buff
+#define _buffer unsigned char
+#define thread_exit() complete_and_exit(NULL, 0)
+#define _workitem struct work_struct
+#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
+
+#define _init_queue(pqueue) \
+ do { \
+ _init_listhead(&((pqueue)->queue)); \
+ spin_lock_init(&((pqueue)->lock)); \
+ } while (0)
+
+static inline void *_netdev_priv(struct net_device *dev)
+{
+ return netdev_priv(dev);
+}
+
+static inline void os_free_netdev(struct net_device *dev)
+{
+ free_netdev(dev);
+}
+
+static inline struct list_head *get_next(struct list_head *list)
+{
+ return list->next;
+}
+
+static inline struct list_head *get_list_head(struct __queue *queue)
+{
+ return &(queue->queue);
+}
+
+#define LIST_CONTAINOR(ptr, type, member) \
+ ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
+
+static inline void _enter_hwio_critical(struct semaphore *prwlock,
+ unsigned long *pirqL)
+{
+ down(prwlock);
+}
+
+static inline void _exit_hwio_critical(struct semaphore *prwlock,
+ unsigned long *pirqL)
+{
+ up(prwlock);
+}
+
+static inline void list_delete(struct list_head *plist)
+{
+ list_del_init(plist);
+}
+
+static inline void _init_timer(struct timer_list *ptimer,
+ struct net_device *padapter,
+ void *pfunc, void *cntx)
+{
+ ptimer->function = pfunc;
+ ptimer->data = (addr_t)cntx;
+ init_timer(ptimer);
+}
+
+static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
+{
+ mod_timer(ptimer, (jiffies+(delay_time*HZ/1000)));
+}
+
+static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
+{
+ del_timer(ptimer);
+ *bcancelled = true; /*true ==1; false==0*/
+}
+
+static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
+{
+ INIT_WORK(pwork, pfunc);
+}
+
+static inline void _set_workitem(_workitem *pwork)
+{
+ schedule_work(pwork);
+}
+
+#include "rtl871x_byteorder.h"
+
+#ifndef BIT
+ #define BIT(x) (1 << (x))
+#endif
+
+/*
+For the following list_xxx operations,
+caller must guarantee the atomic context.
+Otherwise, there will be racing condition.
+*/
+static inline u32 is_list_empty(struct list_head *phead)
+{
+ if (list_empty(phead))
+ return true;
+ else
+ return false;
+}
+
+static inline void list_insert_tail(struct list_head *plist, struct list_head *phead)
+{
+ list_add_tail(plist, phead);
+}
+
+static inline u32 _down_sema(struct semaphore *sema)
+{
+ if (down_interruptible(sema))
+ return _FAIL;
+ else
+ return _SUCCESS;
+}
+
+static inline void _rtl_rwlock_init(struct semaphore *prwlock)
+{
+ init_MUTEX(prwlock);
+}
+
+static inline void _init_listhead(struct list_head *list)
+{
+ INIT_LIST_HEAD(list);
+}
+
+static inline u32 _queue_empty(struct __queue *pqueue)
+{
+ return is_list_empty(&(pqueue->queue));
+}
+
+static inline u32 end_of_queue_search(struct list_head *head, struct list_head *plist)
+{
+ if (head == plist)
+ return true;
+ else
+ return false;
+}
+
+static inline void sleep_schedulable(int ms)
+{
+ u32 delta;
+
+ delta = (ms * HZ) / 1000;/*(ms)*/
+ if (delta == 0)
+ delta = 1;/* 1 ms */
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (schedule_timeout(delta) != 0)
+ return ;
+}
+
+static inline u8 *_malloc(u32 sz)
+{
+ u8 *pbuf;
+
+ pbuf = kmalloc(sz, GFP_ATOMIC);
+ return pbuf;
+}
+
+static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
+{
+ return del_timer(ptimer);
+}
+
+static inline void thread_enter(void *context)
+{
+ daemonize("%s", "RTKTHREAD");
+ allow_signal(SIGTERM);
+}
+
+static inline void flush_signals_thread(void)
+{
+ if (signal_pending(current))
+ flush_signals(current);
+}
+
+static inline u32 _RND8(u32 sz)
+{
+ u32 val;
+
+ val = ((sz >> 3) + ((sz & 7) ? 1 : 0)) << 3;
+ return val;
+}
+
+static inline u32 _RND128(u32 sz)
+{
+ u32 val;
+
+ val = ((sz >> 7) + ((sz & 127) ? 1 : 0)) << 7;
+ return val;
+}
+
+static inline u32 _RND256(u32 sz)
+{
+ u32 val;
+
+ val = ((sz >> 8) + ((sz & 255) ? 1 : 0)) << 8;
+ return val;
+}
+
+static inline u32 _RND512(u32 sz)
+{
+ u32 val;
+
+ val = ((sz >> 9) + ((sz & 511) ? 1 : 0)) << 9;
+ return val;
+}
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+#define STRUCT_PACKED __attribute__ ((packed))
+
+#endif
+
diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c
new file mode 100644
index 000000000000..1f0949ed7ee0
--- /dev/null
+++ b/drivers/staging/rtl8712/recv_linux.c
@@ -0,0 +1,169 @@
+/******************************************************************************
+ * recv_linux.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RECV_OSDEP_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wifi.h"
+#include "recv_osdep.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+/*init os related resource in struct recv_priv*/
+/*alloc os related resource in union recv_frame*/
+int r8712_os_recv_resource_alloc(struct _adapter *padapter,
+ union recv_frame *precvframe)
+{
+ precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL;
+ return _SUCCESS;
+}
+
+/*alloc os related resource in struct recv_buf*/
+int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
+ struct recv_buf *precvbuf)
+{
+ int res = _SUCCESS;
+
+ precvbuf->irp_pending = false;
+ precvbuf->purb = _usb_alloc_urb(0, GFP_KERNEL);
+ if (precvbuf->purb == NULL)
+ res = _FAIL;
+ precvbuf->pskb = NULL;
+ precvbuf->reuse = false;
+ precvbuf->pallocated_buf = NULL;
+ precvbuf->pbuf = NULL;
+ precvbuf->pdata = NULL;
+ precvbuf->phead = NULL;
+ precvbuf->ptail = NULL;
+ precvbuf->pend = NULL;
+ precvbuf->transfer_len = 0;
+ precvbuf->len = 0;
+ return res;
+}
+
+/*free os related resource in struct recv_buf*/
+int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
+ struct recv_buf *precvbuf)
+{
+ if (precvbuf->pskb)
+ dev_kfree_skb_any(precvbuf->pskb);
+ if (precvbuf->purb) {
+ usb_kill_urb(precvbuf->purb);
+ usb_free_urb(precvbuf->purb);
+ }
+ return _SUCCESS;
+}
+
+void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
+{
+ union iwreq_data wrqu;
+ struct iw_michaelmicfailure ev;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ memset(&ev, 0x00, sizeof(ev));
+ if (bgroup)
+ ev.flags |= IW_MICFAILURE_GROUP;
+ else
+ ev.flags |= IW_MICFAILURE_PAIRWISE;
+ ev.src_addr.sa_family = ARPHRD_ETHER;
+ memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
+ memset(&wrqu, 0x00, sizeof(wrqu));
+ wrqu.data.length = sizeof(ev);
+ wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
+ (char *)&ev);
+}
+
+void r8712_recv_indicatepkt(struct _adapter *padapter,
+ union recv_frame *precv_frame)
+{
+ struct recv_priv *precvpriv;
+ struct __queue *pfree_recv_queue;
+ _pkt *skb;
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+
+ precvpriv = &(padapter->recvpriv);
+ pfree_recv_queue = &(precvpriv->free_recv_queue);
+ skb = precv_frame->u.hdr.pkt;
+ if (skb == NULL)
+ goto _recv_indicatepkt_drop;
+ skb->data = precv_frame->u.hdr.rx_data;
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+ skb->tail = (sk_buff_data_t)(precv_frame->u.hdr.rx_tail -
+ precv_frame->u.hdr.rx_head);
+#else
+ skb->tail = (sk_buff_data_t)precv_frame->u.hdr.rx_tail;
+#endif
+ skb->len = precv_frame->u.hdr.len;
+ if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ else
+ skb->ip_summed = CHECKSUM_NONE;
+ skb->dev = padapter->pnetdev;
+ skb->protocol = eth_type_trans(skb, padapter->pnetdev);
+ netif_rx(skb);
+ precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
+ * r8712_free_recvframe() */
+ r8712_free_recvframe(precv_frame, pfree_recv_queue);
+ return;
+_recv_indicatepkt_drop:
+ /*enqueue back to free_recv_queue*/
+ if (precv_frame)
+ r8712_free_recvframe(precv_frame, pfree_recv_queue);
+ precvpriv->rx_drop++;
+}
+
+void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf)
+{
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+
+ precvbuf->ref_cnt--;
+ /*free skb in recv_buf*/
+ dev_kfree_skb_any(precvbuf->pskb);
+ precvbuf->pskb = NULL;
+ precvbuf->reuse = false;
+ if (precvbuf->irp_pending == false)
+ r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
+ (unsigned char *)precvbuf);
+}
+
+static void _r8712_reordering_ctrl_timeout_handler (void *FunctionContext)
+{
+ struct recv_reorder_ctrl *preorder_ctrl =
+ (struct recv_reorder_ctrl *)FunctionContext;
+
+ r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
+}
+
+void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
+{
+ struct _adapter *padapter = preorder_ctrl->padapter;
+
+ _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev,
+ _r8712_reordering_ctrl_timeout_handler, preorder_ctrl);
+}
diff --git a/drivers/staging/rtl8712/recv_osdep.h b/drivers/staging/rtl8712/recv_osdep.h
new file mode 100644
index 000000000000..b23dd6b159f4
--- /dev/null
+++ b/drivers/staging/rtl8712/recv_osdep.h
@@ -0,0 +1,27 @@
+#ifndef __RECV_OSDEP_H_
+#define __RECV_OSDEP_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include <linux/skbuff.h>
+
+sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
+ struct _adapter *padapter);
+void _r8712_free_recv_priv(struct recv_priv *precvpriv);
+s32 r8712_recv_entry(union recv_frame *precv_frame);
+void r8712_recv_indicatepkt(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup);
+int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter);
+void r8712_free_recv_priv(struct recv_priv *precvpriv);
+int r8712_os_recv_resource_alloc(struct _adapter *padapter,
+ union recv_frame *precvframe);
+int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
+ struct recv_buf *precvbuf);
+int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
+ struct recv_buf *precvbuf);
+void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf);
+void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl8712_bitdef.h b/drivers/staging/rtl8712/rtl8712_bitdef.h
new file mode 100644
index 000000000000..356184fa0606
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_bitdef.h
@@ -0,0 +1,19 @@
+#ifndef __RTL8712_BITDEF_H__
+#define __RTL8712_BITDEF_H__
+
+#include "rtl8712_cmdctrl_bitdef.h"
+#include "rtl8712_syscfg_bitdef.h"
+#include "rtl8712_macsetting_bitdef.h"
+#include "rtl8712_timectrl_bitdef.h"
+#include "rtl8712_fifoctrl_bitdef.h"
+#include "rtl8712_ratectrl_bitdef.h"
+#include "rtl8712_edcasetting_bitdef.h"
+#include "rtl8712_wmac_bitdef.h"
+#include "rtl8712_security_bitdef.h"
+#include "rtl8712_powersave_bitdef.h"
+#include "rtl8712_gp_bitdef.h"
+#include "rtl8712_interrupt_bitdef.h"
+#include "rtl8712_debugctrl_bitdef.h"
+
+#endif /* __RTL8712_BITDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c
new file mode 100644
index 000000000000..26c605e8cd6f
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -0,0 +1,465 @@
+/******************************************************************************
+ * rtl8712_cmd.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL8712_CMD_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "mlme_osdep.h"
+#include "rtl871x_byteorder.h"
+#include "rtl871x_ioctl_set.h"
+
+static void check_hw_pbc(struct _adapter *padapter)
+{
+ u8 tmp1byte;
+
+ r8712_write8(padapter, MAC_PINMUX_CTRL, (GPIOMUX_EN | GPIOSEL_GPIO));
+ tmp1byte = r8712_read8(padapter, GPIO_IO_SEL);
+ tmp1byte &= ~(HAL_8192S_HW_GPIO_WPS_BIT);
+ r8712_write8(padapter, GPIO_IO_SEL, tmp1byte);
+ tmp1byte = r8712_read8(padapter, GPIO_CTRL);
+ if (tmp1byte == 0xff)
+ return ;
+ if (tmp1byte&HAL_8192S_HW_GPIO_WPS_BIT) {
+ /* Here we only set bPbcPressed to true
+ * After trigger PBC, the variable will be set to false */
+ DBG_8712("CheckPbcGPIO - PBC is pressed !!!!\n");
+ /* 0 is the default value and it means the application monitors
+ * the HW PBC doesn't privde its pid to driver. */
+ if (padapter->pid == 0)
+ return;
+ kill_pid(find_vpid(padapter->pid), SIGUSR1, 1);
+ }
+}
+
+/* query rx phy status from fw.
+ * Adhoc mode: beacon.
+ * Infrastructure mode: beacon , data. */
+static void query_fw_rx_phy_status(struct _adapter *padapter)
+{
+ u32 val32 = 0;
+ int pollingcnts = 50;
+
+ if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) {
+ r8712_write32(padapter, IOCMD_CTRL_REG, 0xf4000001);
+ msleep(100);
+ /* Wait FW complete IO Cmd */
+ while ((r8712_read32(padapter, IOCMD_CTRL_REG)) &&
+ (pollingcnts > 0)) {
+ pollingcnts--;
+ msleep(20);
+ }
+ if (pollingcnts != 0)
+ val32 = r8712_read32(padapter, IOCMD_DATA_REG);
+ else /* time out */
+ val32 = 0;
+ val32 = val32 >> 4;
+ padapter->recvpriv.fw_rssi =
+ (u8)r8712_signal_scale_mapping(val32);
+ }
+}
+
+/* check mlme, hw, phy, or dynamic algorithm status. */
+static void StatusWatchdogCallback(struct _adapter *padapter)
+{
+ check_hw_pbc(padapter);
+ query_fw_rx_phy_status(padapter);
+}
+
+static void r871x_internal_cmd_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ struct drvint_cmd_parm *pdrvcmd;
+
+ if (!pbuf)
+ return;
+ pdrvcmd = (struct drvint_cmd_parm *)pbuf;
+ switch (pdrvcmd->i_cid) {
+ case WDG_WK_CID:
+ StatusWatchdogCallback(padapter);
+ break;
+ default:
+ break;
+ }
+ kfree(pdrvcmd->pbuf);
+}
+
+static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ /* invoke cmd->callback function */
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ /* invoke cmd->callback function */
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ u32 val;
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct readBB_parm *prdbbparm;
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ prdbbparm = (struct readBB_parm *)pcmd->parmbuf;
+ if (pcmd->rsp && pcmd->rspsz > 0)
+ memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 write_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct writeBB_parm *pwritebbparm;
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ pwritebbparm = (struct writeBB_parm *)pcmd->parmbuf;
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ u32 val;
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct readRF_parm *prdrfparm;
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ prdrfparm = (struct readRF_parm *)pcmd->parmbuf;
+ if (pcmd->rsp && pcmd->rspsz > 0)
+ memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct writeRF_parm *pwriterfparm;
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+
+ pwriterfparm = (struct writeRF_parm *)pcmd->parmbuf;
+ pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
+ if (pcmd_callback == NULL)
+ r8712_free_cmd_obj(pcmd);
+ else
+ pcmd_callback(padapter, pcmd);
+ return H2C_SUCCESS;
+}
+
+static u8 sys_suspend_hdl(struct _adapter *padapter, u8 *pbuf)
+{
+ struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
+ struct usb_suspend_parm *psetusbsuspend;
+
+ psetusbsuspend = (struct usb_suspend_parm *)pcmd->parmbuf;
+ r8712_free_cmd_obj(pcmd);
+ return H2C_SUCCESS;
+}
+
+static struct cmd_obj *cmd_hdl_filter(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ struct cmd_obj *pcmd_r;
+
+ if (pcmd == NULL)
+ return pcmd;
+ pcmd_r = NULL;
+
+ switch (pcmd->cmdcode) {
+ case GEN_CMD_CODE(_Read_MACREG):
+ read_macreg_hdl(padapter, (u8 *)pcmd);
+ pcmd_r = pcmd;
+ break;
+ case GEN_CMD_CODE(_Write_MACREG):
+ write_macreg_hdl(padapter, (u8 *)pcmd);
+ pcmd_r = pcmd;
+ break;
+ case GEN_CMD_CODE(_Read_BBREG):
+ read_bbreg_hdl(padapter, (u8 *)pcmd);
+ break;
+ case GEN_CMD_CODE(_Write_BBREG):
+ write_bbreg_hdl(padapter, (u8 *)pcmd);
+ break;
+ case GEN_CMD_CODE(_Read_RFREG):
+ read_rfreg_hdl(padapter, (u8 *)pcmd);
+ break;
+ case GEN_CMD_CODE(_Write_RFREG):
+ write_rfreg_hdl(padapter, (u8 *)pcmd);
+ break;
+ case GEN_CMD_CODE(_SetUsbSuspend):
+ sys_suspend_hdl(padapter, (u8 *)pcmd);
+ break;
+ case GEN_CMD_CODE(_JoinBss):
+ r8712_joinbss_reset(padapter);
+ /* Before set JoinBss_CMD to FW, driver must ensure FW is in
+ * PS_MODE_ACTIVE. Directly write rpwm to radio on and assign
+ * new pwr_mode to Driver, instead of use workitem to change
+ * state. */
+ if (padapter->pwrctrlpriv.pwr_mode > PS_MODE_ACTIVE) {
+ padapter->pwrctrlpriv.pwr_mode = PS_MODE_ACTIVE;
+ _enter_pwrlock(&(padapter->pwrctrlpriv.lock));
+ r8712_set_rpwm(padapter, PS_STATE_S4);
+ up(&(padapter->pwrctrlpriv.lock));
+ }
+ pcmd_r = pcmd;
+ break;
+ case _DRV_INT_CMD_:
+ r871x_internal_cmd_hdl(padapter, pcmd->parmbuf);
+ r8712_free_cmd_obj(pcmd);
+ pcmd_r = NULL;
+ break;
+ default:
+ pcmd_r = pcmd;
+ break;
+ }
+ return pcmd_r; /* if returning pcmd_r == NULL, pcmd must be free. */
+}
+
+static u8 check_cmd_fifo(struct _adapter *padapter, uint sz)
+{
+ u8 res = _SUCCESS;
+ return res;
+}
+
+u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd)
+{
+ int pollingcnts = 50;
+
+ r8712_write32(pAdapter, IOCMD_CTRL_REG, cmd);
+ msleep(100);
+ while ((0 != r8712_read32(pAdapter, IOCMD_CTRL_REG)) &&
+ (pollingcnts > 0)) {
+ pollingcnts--;
+ msleep(20);
+ }
+ if (pollingcnts == 0)
+ return false;
+ return true;
+}
+
+void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag)
+{
+ if (flag == 0) /* set */
+ r8712_write32(pAdapter, IOCMD_DATA_REG, *value);
+ else /* query */
+ *value = r8712_read32(pAdapter, IOCMD_DATA_REG);
+}
+
+int r8712_cmd_thread(void *context)
+{
+ struct cmd_obj *pcmd;
+ unsigned int cmdsz, wr_sz, *pcmdbuf, *prspbuf;
+ struct tx_desc *pdesc;
+ void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
+ struct _adapter *padapter = (struct _adapter *)context;
+ struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
+
+ thread_enter(padapter);
+ while (1) {
+ if ((_down_sema(&(pcmdpriv->cmd_queue_sema))) == _FAIL)
+ break;
+ if ((padapter->bDriverStopped == true) ||
+ (padapter->bSurpriseRemoved == true))
+ break;
+ if (r8712_register_cmd_alive(padapter) != _SUCCESS)
+ continue;
+_next:
+ pcmd = r8712_dequeue_cmd(&(pcmdpriv->cmd_queue));
+ if (!(pcmd)) {
+ r8712_unregister_cmd_alive(padapter);
+ continue;
+ }
+ pcmdbuf = (unsigned int *)pcmdpriv->cmd_buf;
+ prspbuf = (unsigned int *)pcmdpriv->rsp_buf;
+ pdesc = (struct tx_desc *)pcmdbuf;
+ memset(pdesc, 0, TXDESC_SIZE);
+ pcmd = cmd_hdl_filter(padapter, pcmd);
+ if (pcmd) { /* if pcmd != NULL, cmd will be handled by f/w */
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)
+ &padapter->dvobjpriv;
+ u8 blnPending = 0;
+ pcmdpriv->cmd_issued_cnt++;
+ cmdsz = _RND8((pcmd->cmdsz)); /* _RND8 */
+ wr_sz = TXDESC_SIZE + 8 + cmdsz;
+ pdesc->txdw0 |= cpu_to_le32((wr_sz-TXDESC_SIZE) &
+ 0x0000ffff);
+ if (pdvobj->ishighspeed) {
+ if ((wr_sz % 512) == 0)
+ blnPending = 1;
+ } else {
+ if ((wr_sz % 64) == 0)
+ blnPending = 1;
+ }
+ if (blnPending) /* 32 bytes for TX Desc - 8 offset */
+ pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
+ OFFSET_SZ + 8) << OFFSET_SHT) &
+ 0x00ff0000);
+ else {
+ pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
+ OFFSET_SZ) <<
+ OFFSET_SHT) &
+ 0x00ff0000);
+ }
+ pdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
+ pdesc->txdw1 |= cpu_to_le32((0x13 << QSEL_SHT) &
+ 0x00001f00);
+ pcmdbuf += (TXDESC_SIZE >> 2);
+ *pcmdbuf = cpu_to_le32((cmdsz & 0x0000ffff) |
+ (pcmd->cmdcode << 16) |
+ (pcmdpriv->cmd_seq << 24));
+ pcmdbuf += 2 ; /* 8 bytes aligment */
+ memcpy((u8 *)pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
+ while (check_cmd_fifo(padapter, wr_sz) == _FAIL) {
+ if ((padapter->bDriverStopped == true) ||
+ (padapter->bSurpriseRemoved == true))
+ break;
+ msleep(100);
+ continue;
+ }
+ if (blnPending)
+ wr_sz += 8; /* Append 8 bytes */
+ r8712_write_mem(padapter, RTL8712_DMA_H2CCMD, wr_sz,
+ (u8 *)pdesc);
+ pcmdpriv->cmd_seq++;
+ if (pcmd->cmdcode == GEN_CMD_CODE(_CreateBss)) {
+ pcmd->res = H2C_SUCCESS;
+ pcmd_callback = cmd_callback[pcmd->
+ cmdcode].callback;
+ if (pcmd_callback)
+ pcmd_callback(padapter, pcmd);
+ continue;
+ }
+ if (pcmd->cmdcode == GEN_CMD_CODE(_SetPwrMode)) {
+ if (padapter->pwrctrlpriv.bSleep) {
+ _enter_pwrlock(&(padapter->
+ pwrctrlpriv.lock));
+ r8712_set_rpwm(padapter, PS_STATE_S2);
+ up(&padapter->pwrctrlpriv.lock);
+ }
+ }
+ r8712_free_cmd_obj(pcmd);
+ if (_queue_empty(&(pcmdpriv->cmd_queue))) {
+ r8712_unregister_cmd_alive(padapter);
+ continue;
+ } else
+ goto _next;
+ } else
+ goto _next;
+ flush_signals_thread();
+ }
+ /* free all cmd_obj resources */
+ do {
+ pcmd = r8712_dequeue_cmd(&(pcmdpriv->cmd_queue));
+ if (pcmd == NULL)
+ break;
+ r8712_free_cmd_obj(pcmd);
+ } while (1);
+ up(&pcmdpriv->terminate_cmdthread_sema);
+ thread_exit();
+}
+
+void r8712_event_handle(struct _adapter *padapter, uint *peventbuf)
+{
+ u8 evt_code, evt_seq;
+ u16 evt_sz;
+ void (*event_callback)(struct _adapter *dev, u8 *pbuf);
+ struct evt_priv *pevt_priv = &(padapter->evtpriv);
+
+ if (peventbuf == NULL)
+ goto _abort_event_;
+ evt_sz = (u16)(le32_to_cpu(*peventbuf) & 0xffff);
+ evt_seq = (u8)((le32_to_cpu(*peventbuf) >> 24) & 0x7f);
+ evt_code = (u8)((le32_to_cpu(*peventbuf) >> 16) & 0xff);
+ /* checking event sequence... */
+ if ((evt_seq & 0x7f) != pevt_priv->event_seq) {
+ pevt_priv->event_seq = ((evt_seq + 1) & 0x7f);
+ goto _abort_event_;
+ }
+ /* checking if event code is valid */
+ if (evt_code >= MAX_C2HEVT) {
+ pevt_priv->event_seq = ((evt_seq+1) & 0x7f);
+ goto _abort_event_;
+ } else if ((evt_code == GEN_EVT_CODE(_Survey)) &&
+ (evt_sz > sizeof(struct wlan_bssid_ex))) {
+ pevt_priv->event_seq = ((evt_seq+1)&0x7f);
+ goto _abort_event_;
+ }
+ /* checking if event size match the event parm size */
+ if ((wlanevents[evt_code].parmsize) &&
+ (wlanevents[evt_code].parmsize != evt_sz)) {
+ pevt_priv->event_seq = ((evt_seq+1)&0x7f);
+ goto _abort_event_;
+ } else if ((evt_sz == 0) && (evt_code != GEN_EVT_CODE(_WPS_PBC))) {
+ pevt_priv->event_seq = ((evt_seq+1)&0x7f);
+ goto _abort_event_;
+ }
+ pevt_priv->event_seq++; /* update evt_seq */
+ if (pevt_priv->event_seq > 127)
+ pevt_priv->event_seq = 0;
+ peventbuf = peventbuf + 2; /* move to event content, 8 bytes aligment */
+ if (peventbuf) {
+ event_callback = wlanevents[evt_code].event_callback;
+ if (event_callback)
+ event_callback(padapter, (u8 *)peventbuf);
+ }
+ pevt_priv->evt_done_cnt++;
+_abort_event_:
+ return;
+}
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h
new file mode 100644
index 000000000000..13ef0626b280
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_cmd.h
@@ -0,0 +1,157 @@
+#ifndef __RTL8712_CMD_H_
+#define __RTL8712_CMD_H_
+
+u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd);
+void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag);
+
+
+enum rtl8712_h2c_cmd {
+ GEN_CMD_CODE(_Read_MACREG), /*0*/
+ GEN_CMD_CODE(_Write_MACREG),
+ GEN_CMD_CODE(_Read_BBREG),
+ GEN_CMD_CODE(_Write_BBREG),
+ GEN_CMD_CODE(_Read_RFREG),
+ GEN_CMD_CODE(_Write_RFREG), /*5*/
+ GEN_CMD_CODE(_Read_EEPROM),
+ GEN_CMD_CODE(_Write_EEPROM),
+ GEN_CMD_CODE(_Read_EFUSE),
+ GEN_CMD_CODE(_Write_EFUSE),
+
+ GEN_CMD_CODE(_Read_CAM), /*10*/
+ GEN_CMD_CODE(_Write_CAM),
+ GEN_CMD_CODE(_setBCNITV),
+ GEN_CMD_CODE(_setMBIDCFG),
+ GEN_CMD_CODE(_JoinBss), /*14*/
+ GEN_CMD_CODE(_DisConnect), /*15*/
+ GEN_CMD_CODE(_CreateBss),
+ GEN_CMD_CODE(_SetOpMode),
+ GEN_CMD_CODE(_SiteSurvey), /*18*/
+ GEN_CMD_CODE(_SetAuth),
+
+ GEN_CMD_CODE(_SetKey), /*20*/
+ GEN_CMD_CODE(_SetStaKey),
+ GEN_CMD_CODE(_SetAssocSta),
+ GEN_CMD_CODE(_DelAssocSta),
+ GEN_CMD_CODE(_SetStaPwrState),
+ GEN_CMD_CODE(_SetBasicRate), /*25*/
+ GEN_CMD_CODE(_GetBasicRate),
+ GEN_CMD_CODE(_SetDataRate),
+ GEN_CMD_CODE(_GetDataRate),
+ GEN_CMD_CODE(_SetPhyInfo),
+
+ GEN_CMD_CODE(_GetPhyInfo), /*30*/
+ GEN_CMD_CODE(_SetPhy),
+ GEN_CMD_CODE(_GetPhy),
+ GEN_CMD_CODE(_readRssi),
+ GEN_CMD_CODE(_readGain),
+ GEN_CMD_CODE(_SetAtim), /*35*/
+ GEN_CMD_CODE(_SetPwrMode),
+ GEN_CMD_CODE(_JoinbssRpt),
+ GEN_CMD_CODE(_SetRaTable),
+ GEN_CMD_CODE(_GetRaTable),
+
+ GEN_CMD_CODE(_GetCCXReport), /*40*/
+ GEN_CMD_CODE(_GetDTMReport),
+ GEN_CMD_CODE(_GetTXRateStatistics),
+ GEN_CMD_CODE(_SetUsbSuspend),
+ GEN_CMD_CODE(_SetH2cLbk),
+ GEN_CMD_CODE(_AddBAReq), /*45*/
+
+ GEN_CMD_CODE(_SetChannel), /*46*/
+/* MP_OFFLOAD Start (47~54)*/
+ GEN_CMD_CODE(_SetTxPower),
+ GEN_CMD_CODE(_SwitchAntenna),
+ GEN_CMD_CODE(_SetCrystalCap),
+ GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
+ GEN_CMD_CODE(_SetSingleToneTx),
+ GEN_CMD_CODE(_SetCarrierSuppressionTx),
+ GEN_CMD_CODE(_SetContinuousTx),
+ GEN_CMD_CODE(_SwitchBandwidth), /*54*/
+/* MP_OFFLOAD End*/
+ GEN_CMD_CODE(_TX_Beacon), /*55*/
+ GEN_CMD_CODE(_SetPowerTracking),
+ GEN_CMD_CODE(_AMSDU_TO_AMPDU), /*57*/
+ GEN_CMD_CODE(_SetMacAddress), /*58*/
+ MAX_H2CCMD
+};
+
+
+#define _GetBBReg_CMD_ _Read_BBREG_CMD_
+#define _SetBBReg_CMD_ _Write_BBREG_CMD_
+#define _GetRFReg_CMD_ _Read_RFREG_CMD_
+#define _SetRFReg_CMD_ _Write_RFREG_CMD_
+#define _DRV_INT_CMD_ (MAX_H2CCMD+1)
+#define _SetRFIntFs_CMD_ (MAX_H2CCMD+2)
+
+#ifdef _RTL8712_CMD_C_
+static struct _cmd_callback cmd_callback[] = {
+ {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
+ {GEN_CMD_CODE(_Write_MACREG), NULL},
+ {GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback},
+ {GEN_CMD_CODE(_Write_BBREG), NULL},
+ {GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback},
+ {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
+ {GEN_CMD_CODE(_Read_EEPROM), NULL},
+ {GEN_CMD_CODE(_Write_EEPROM), NULL},
+ {GEN_CMD_CODE(_Read_EFUSE), NULL},
+ {GEN_CMD_CODE(_Write_EFUSE), NULL},
+
+ {GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/
+ {GEN_CMD_CODE(_Write_CAM), NULL},
+ {GEN_CMD_CODE(_setBCNITV), NULL},
+ {GEN_CMD_CODE(_setMBIDCFG), NULL},
+ {GEN_CMD_CODE(_JoinBss), &r8712_joinbss_cmd_callback}, /*14*/
+ {GEN_CMD_CODE(_DisConnect), &r8712_disassoc_cmd_callback}, /*15*/
+ {GEN_CMD_CODE(_CreateBss), &r8712_createbss_cmd_callback},
+ {GEN_CMD_CODE(_SetOpMode), NULL},
+ {GEN_CMD_CODE(_SiteSurvey), &r8712_survey_cmd_callback}, /*18*/
+ {GEN_CMD_CODE(_SetAuth), NULL},
+
+ {GEN_CMD_CODE(_SetKey), NULL}, /*20*/
+ {GEN_CMD_CODE(_SetStaKey), &r8712_setstaKey_cmdrsp_callback},
+ {GEN_CMD_CODE(_SetAssocSta), &r8712_setassocsta_cmdrsp_callback},
+ {GEN_CMD_CODE(_DelAssocSta), NULL},
+ {GEN_CMD_CODE(_SetStaPwrState), NULL},
+ {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
+ {GEN_CMD_CODE(_GetBasicRate), NULL},
+ {GEN_CMD_CODE(_SetDataRate), NULL},
+ {GEN_CMD_CODE(_GetDataRate), NULL},
+ {GEN_CMD_CODE(_SetPhyInfo), NULL},
+
+ {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
+ {GEN_CMD_CODE(_SetPhy), NULL},
+ {GEN_CMD_CODE(_GetPhy), NULL},
+ {GEN_CMD_CODE(_readRssi), NULL},
+ {GEN_CMD_CODE(_readGain), NULL},
+ {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
+ {GEN_CMD_CODE(_SetPwrMode), NULL},
+ {GEN_CMD_CODE(_JoinbssRpt), NULL},
+ {GEN_CMD_CODE(_SetRaTable), NULL},
+ {GEN_CMD_CODE(_GetRaTable), NULL},
+
+ {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
+ {GEN_CMD_CODE(_GetDTMReport), NULL},
+ {GEN_CMD_CODE(_GetTXRateStatistics), NULL},
+ {GEN_CMD_CODE(_SetUsbSuspend), NULL},
+ {GEN_CMD_CODE(_SetH2cLbk), NULL},
+ {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
+
+ {GEN_CMD_CODE(_SetChannel), NULL}, /*46*/
+/* MP_OFFLOAD Start (47~54)*/
+ {GEN_CMD_CODE(_SetTxPower), NULL},
+ {GEN_CMD_CODE(_SwitchAntenna), NULL},
+ {GEN_CMD_CODE(_SetCrystalCap), NULL},
+ {GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/
+ {GEN_CMD_CODE(_SetSingleToneTx), NULL},
+ {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
+ {GEN_CMD_CODE(_SetContinuousTx), NULL},
+ {GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/
+/* MP_OFFLOAD End*/
+ {GEN_CMD_CODE(_TX_Beacon), NULL}, /*55*/
+ {GEN_CMD_CODE(_SetPowerTracking), NULL},
+ {GEN_CMD_CODE(_AMSDU_TO_AMPDU), NULL}, /*57*/
+ {GEN_CMD_CODE(_SetMacAddress), NULL}, /*58*/
+};
+#endif
+
+#endif
diff --git a/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h
new file mode 100644
index 000000000000..6c49903a42f2
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h
@@ -0,0 +1,89 @@
+#ifndef __RTL8712_CMDCTRL_BITDEF_H__
+#define __RTL8712_CMDCTRL_BITDEF_H__
+
+/*
+ * 2. Command Control Registers (Offset: 0x0040 - 0x004F)*/
+/*--------------------------------------------------------------------------*/
+/* 8192S (CMD) command register bits (Offset 0x40, 16 bits)*/
+/*--------------------------------------------------------------------------*/
+#define _APSDOFF_STATUS BIT(15)
+#define _APSDOFF BIT(14)
+#define _BBRSTn BIT(13) /*Enable OFDM/CCK*/
+#define _BB_GLB_RSTn BIT(12) /*Enable BB*/
+#define _SCHEDULE_EN BIT(10) /*Enable MAC scheduler*/
+#define _MACRXEN BIT(9)
+#define _MACTXEN BIT(8)
+#define _DDMA_EN BIT(7) /*FW off load function enable*/
+#define _FW2HW_EN BIT(6) /*MAC every module reset */
+#define _RXDMA_EN BIT(5)
+#define _TXDMA_EN BIT(4)
+#define _HCI_RXDMA_EN BIT(3)
+#define _HCI_TXDMA_EN BIT(2)
+
+/*TXPAUSE*/
+#define _STOPHCCA BIT(6)
+#define _STOPHIGH BIT(5)
+#define _STOPMGT BIT(4)
+#define _STOPVO BIT(3)
+#define _STOPVI BIT(2)
+#define _STOPBE BIT(1)
+#define _STOPBK BIT(0)
+
+/*TCR*/
+#define _DISCW BIT(20)
+#define _ICV BIT(19)
+#define _CFEND_FMT BIT(17)
+#define _CRC BIT(16)
+#define _FWRDY BIT(7)
+#define _BASECHG BIT(6)
+#define _IMEM_RDY BIT(5)
+#define _DMEM_CODE_DONE BIT(4)
+#define _EMEM_CHK_RPT BIT(3)
+#define _EMEM_CODE_DONE BIT(2)
+#define _IMEM_CHK_RPT BIT(1)
+#define _IMEM_CODE_DONE BIT(0)
+
+#define _TXDMA_INIT_VALUE (_IMEM_CHK_RPT|_EMEM_CHK_RPT)
+
+/*RCR*/
+#define _ENMBID BIT(27)
+#define _APP_PHYST_RXFF BIT(25)
+#define _APP_PHYST_STAFF BIT(24)
+#define _CBSSID BIT(23)
+#define _APWRMGT BIT(22)
+#define _ADD3 BIT(21)
+#define _AMF BIT(20)
+#define _ACF BIT(19)
+#define _ADF BIT(18)
+#define _APP_MIC BIT(17)
+#define _APP_ICV BIT(16)
+#define _RXFTH_MSK 0x0000E000
+#define _RXFTH_SHT 13
+#define _AICV BIT(12)
+#define _RXPKTLMT_MSK 0x00000FC0
+#define _RXPKTLMT_SHT 6
+#define _ACRC32 BIT(5)
+#define _AB BIT(3)
+#define _AM BIT(2)
+#define _APM BIT(1)
+#define _AAP BIT(0)
+
+/*MSR*/
+#define _NETTYPE_MSK 0x03
+#define _NETTYPE_SHT 0
+
+/*BT*/
+#define _BTMODE_MSK 0x06
+#define _BTMODE_SHT 1
+#define _ENBT BIT(0)
+
+/*MBIDCTRL*/
+#define _ENMBID_MODE BIT(15)
+#define _BCNNO_MSK 0x7000
+#define _BCNNO_SHT 12
+#define _BCNSPACE_MSK 0x0FFF
+#define _BCNSPACE_SHT 0
+
+
+#endif /* __RTL8712_CMDCTRL_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h
new file mode 100644
index 000000000000..5d9a3f20ea6e
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h
@@ -0,0 +1,15 @@
+#ifndef __RTL8712_CMDCTRL_REGDEF_H__
+#define __RTL8712_CMDCTRL_REGDEF_H__
+
+
+#define CR (RTL8712_CMDCTRL_ + 0x0000)
+#define TXPAUSE (RTL8712_CMDCTRL_ + 0x0002)
+#define TCR (RTL8712_CMDCTRL_ + 0x0004)
+#define RCR (RTL8712_CMDCTRL_ + 0x0008)
+#define MSR (RTL8712_CMDCTRL_ + 0x000C)
+#define SYSF_CFG (RTL8712_CMDCTRL_ + 0x000D)
+#define MBIDCTRL (RTL8712_CMDCTRL_ + 0x000E)
+
+
+#endif /* __RTL8712_CMDCTRL_REGDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h
new file mode 100644
index 000000000000..7b34d4025e3e
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h
@@ -0,0 +1,36 @@
+#ifndef __RTL8712_DEBUGCTRL_BITDEF_H__
+#define __RTL8712_DEBUGCTRL_BITDEF_H__
+
+/*BIST*/
+#define _BIST_RST BIT(0)
+
+/*LMS*/
+#define _LMS_MSK 0x03
+
+/*WDG_CTRL*/
+#define _OVSEL_MSK 0x0600
+#define _OVSEL_SHT 9
+#define _WDGCLR BIT(8)
+#define _WDGEN_MSK 0x00FF
+#define _WDGEN_SHT 0
+
+/*INTM*/
+#define _TXTIMER_MSK 0xF000
+#define _TXTIMER_SHT 12
+#define _TXNUM_MSK 0x0F00
+#define _TXNUM_SHT 8
+#define _RXTIMER_MSK 0x00F0
+#define _RXTIMER_SHT 4
+#define _RXNUM_MSK 0x000F
+#define _RXNUM_SHT 0
+
+/*FDLOCKTURN0*/
+/*FDLOCKTURN1*/
+#define _TURN1 BIT(0)
+
+/*FDLOCKFLAG0*/
+/*FDLOCKFLAG1*/
+#define _LOCKFLAG1_MSK 0x03
+
+
+#endif /* __RTL8712_DEBUGCTRL_BITDEF_H__ */
diff --git a/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h
new file mode 100644
index 000000000000..27cad716868c
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h
@@ -0,0 +1,28 @@
+#ifndef __RTL8712_DEBUGCTRL_REGDEF_H__
+#define __RTL8712_DEBUGCTRL_REGDEF_H__
+
+#define BIST (RTL8712_DEBUGCTRL_ + 0x00)
+#define DBS (RTL8712_DEBUGCTRL_ + 0x04)
+#define LMS (RTL8712_DEBUGCTRL_ + 0x05)
+#define CPUINST (RTL8712_DEBUGCTRL_ + 0x08)
+#define CPUCAUSE (RTL8712_DEBUGCTRL_ + 0x0C)
+#define LBUS_ERR_ADDR (RTL8712_DEBUGCTRL_ + 0x10)
+#define LBUS_ERR_CMD (RTL8712_DEBUGCTRL_ + 0x14)
+#define LBUS_ERR_DATA_L (RTL8712_DEBUGCTRL_ + 0x18)
+#define LBUS_ERR_DATA_H (RTL8712_DEBUGCTRL_ + 0x1C)
+#define LBUS_EXCEPTION_ADDR (RTL8712_DEBUGCTRL_ + 0x20)
+#define WDG_CTRL (RTL8712_DEBUGCTRL_ + 0x24)
+#define INTMTU (RTL8712_DEBUGCTRL_ + 0x28)
+#define INTM (RTL8712_DEBUGCTRL_ + 0x2A)
+#define FDLOCKTURN0 (RTL8712_DEBUGCTRL_ + 0x2C)
+#define FDLOCKTURN1 (RTL8712_DEBUGCTRL_ + 0x2D)
+#define FDLOCKFLAG0 (RTL8712_DEBUGCTRL_ + 0x2E)
+#define FDLOCKFLAG1 (RTL8712_DEBUGCTRL_ + 0x2F)
+#define TRXPKTBUF_DBG_DATA (RTL8712_DEBUGCTRL_ + 0x30)
+#define TRXPKTBUF_DBG_CTRL (RTL8712_DEBUGCTRL_ + 0x38)
+#define DPLL_MON (RTL8712_DEBUGCTRL_ + 0x3A)
+
+
+
+#endif /* __RTL8712_DEBUGCTRL_REGDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h
new file mode 100644
index 000000000000..c69b1b72c28c
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h
@@ -0,0 +1,52 @@
+#ifndef __RTL8712_EDCASETTING_BITDEF_H__
+#define __RTL8712_EDCASETTING_BITDEF_H__
+
+/*EDCAPARAM*/
+#define _TXOPLIMIT_MSK 0xFFFF0000
+#define _TXOPLIMIT_SHT 16
+#define _ECWIN_MSK 0x0000FF00
+#define _ECWIN_SHT 8
+#define _AIFS_MSK 0x000000FF
+#define _AIFS_SHT 0
+
+/*BCNTCFG*/
+#define _BCNECW_MSK 0xFF00
+#define _BCNECW_SHT 8
+#define _BCNIFS_MSK 0x00FF
+#define _BCNIFS_SHT 0
+
+/*CWRR*/
+#define _CWRR_MSK 0x03FF
+
+/*ACMAVG*/
+#define _AVG_TIME_UP BIT(3)
+#define _AVGPERIOD_MSK 0x03
+
+/*ACMHWCTRL*/
+#define _VOQ_ACM_STATUS BIT(6)
+#define _VIQ_ACM_STATUS BIT(5)
+#define _BEQ_ACM_STATUS BIT(4)
+#define _VOQ_ACM_EN BIT(3)
+#define _VIQ_ACM_EN BIT(2)
+#define _BEQ_ACM_EN BIT(1)
+#define _ACMHWEN BIT(0)
+
+/*VO_ADMTIME*/
+#define _VO_ACM_RUT BIT(18)
+#define _VO_ADMTIME_MSK 0x0003FFF
+
+/*VI_ADMTIME*/
+#define _VI_ACM_RUT BIT(18)
+#define _VI_ADMTIME_MSK 0x0003FFF
+
+/*BE_ADMTIME*/
+#define _BE_ACM_RUT BIT(18)
+#define _BE_ADMTIME_MSK 0x0003FFF
+
+/*Retry limit reg*/
+#define _SRL_MSK 0xFF00
+#define _SRL_SHT 8
+#define _LRL_MSK 0x00FF
+#define _LRL_SHT 0
+
+#endif /* __RTL8712_EDCASETTING_BITDEF_H__*/
diff --git a/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h b/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h
new file mode 100644
index 000000000000..de3d3e23ba95
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h
@@ -0,0 +1,18 @@
+#ifndef __RTL8712_EDCASETTING_REGDEF_H__
+#define __RTL8712_EDCASETTING_REGDEF_H__
+
+#define EDCA_VO_PARAM (RTL8712_EDCASETTING_ + 0x00)
+#define EDCA_VI_PARAM (RTL8712_EDCASETTING_ + 0x04)
+#define EDCA_BE_PARAM (RTL8712_EDCASETTING_ + 0x08)
+#define EDCA_BK_PARAM (RTL8712_EDCASETTING_ + 0x0C)
+#define BCNTCFG (RTL8712_EDCASETTING_ + 0x10)
+#define CWRR (RTL8712_EDCASETTING_ + 0x12)
+#define ACMAVG (RTL8712_EDCASETTING_ + 0x16)
+#define ACMHWCTRL (RTL8712_EDCASETTING_ + 0x17)
+#define VO_ADMTIME (RTL8712_EDCASETTING_ + 0x18)
+#define VI_ADMTIME (RTL8712_EDCASETTING_ + 0x1C)
+#define BE_ADMTIME (RTL8712_EDCASETTING_ + 0x20)
+#define RL (RTL8712_EDCASETTING_ + 0x24)
+
+#endif /* __RTL8712_EDCASETTING_REGDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c
new file mode 100644
index 000000000000..9730ae1c58d5
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_efuse.c
@@ -0,0 +1,568 @@
+/*
+ * rtl8712_efuse.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL8712_EFUSE_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl8712_efuse.h"
+
+/* reserve 3 bytes for HW stop read */
+static int efuse_available_max_size = EFUSE_MAX_SIZE - 3 /*0x1FD*/;
+
+static void efuse_reg_ctrl(struct _adapter *padapter, u8 bPowerOn)
+{
+ u8 tmpu8 = 0;
+
+ if (true == bPowerOn) {
+ /* -----------------e-fuse pwr & clk reg ctrl ---------------
+ * Enable LDOE25 Macro Block
+ */
+ tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3);
+ tmpu8 |= 0x80;
+ r8712_write8(padapter, EFUSE_TEST + 3, tmpu8);
+ msleep(20); /* for some platform , need some delay time */
+ /* Change Efuse Clock for write action to 40MHZ */
+ r8712_write8(padapter, EFUSE_CLK_CTRL, 0x03);
+ msleep(20); /* for some platform , need some delay time */
+ } else {
+ /* -----------------e-fuse pwr & clk reg ctrl -----------------
+ * Disable LDOE25 Macro Block
+ */
+ tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3);
+ tmpu8 &= 0x7F;
+ r8712_write8(padapter, EFUSE_TEST + 3, tmpu8);
+ /* Change Efuse Clock for write action to 500K */
+ r8712_write8(padapter, EFUSE_CLK_CTRL, 0x02);
+ }
+}
+
+/*
+ * Before write E-Fuse, this function must be called.
+ */
+u8 r8712_efuse_reg_init(struct _adapter *padapter)
+{
+ return true;
+}
+
+void r8712_efuse_reg_uninit(struct _adapter *padapter)
+{
+ efuse_reg_ctrl(padapter, false);
+}
+
+static u8 efuse_one_byte_read(struct _adapter *padapter, u16 addr, u8 *data)
+{
+ u8 tmpidx = 0, bResult;
+
+ /* -----------------e-fuse reg ctrl --------------------------------- */
+ r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
+ r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) |
+ (r8712_read8(padapter, EFUSE_CTRL+2)&0xFC));
+ r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */
+ /* wait for complete */
+ while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100))
+ tmpidx++;
+ if (tmpidx < 100) {
+ *data = r8712_read8(padapter, EFUSE_CTRL);
+ bResult = true;
+ } else {
+ *data = 0xff;
+ bResult = false;
+ }
+ return bResult;
+}
+
+static u8 efuse_one_byte_write(struct _adapter *padapter, u16 addr, u8 data)
+{
+ u8 tmpidx = 0, bResult;
+
+ /* -----------------e-fuse reg ctrl -------------------------------- */
+ r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
+ r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) |
+ (r8712_read8(padapter, EFUSE_CTRL+2)&0xFC));
+ r8712_write8(padapter, EFUSE_CTRL, data); /* data */
+ r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */
+ /* wait for complete */
+ while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100))
+ tmpidx++;
+ if (tmpidx < 100)
+ bResult = true;
+ else
+ bResult = false;
+ return bResult;
+}
+
+static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr,
+ u8 *data)
+{
+ u8 tmpidx = 0, tmpv8 = 0, bResult;
+
+ /* -----------------e-fuse reg ctrl --------------------------------- */
+ r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
+ tmpv8 = ((u8)((addr >> 8) & 0x03)) |
+ (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC);
+ r8712_write8(padapter, EFUSE_CTRL+2, tmpv8);
+ if (true == bRead) {
+ r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */
+ while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) &&
+ (tmpidx < 100))
+ tmpidx++;
+ if (tmpidx < 100) {
+ *data = r8712_read8(padapter, EFUSE_CTRL);
+ bResult = true;
+ } else {
+ *data = 0;
+ bResult = false;
+ }
+ } else {
+ r8712_write8(padapter, EFUSE_CTRL, *data); /* data */
+ r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */
+ while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) &&
+ (tmpidx < 100))
+ tmpidx++;
+ if (tmpidx < 100)
+ bResult = true;
+ else
+ bResult = false;
+ }
+ return bResult;
+}
+
+static u8 efuse_is_empty(struct _adapter *padapter, u8 *empty)
+{
+ u8 value, ret = true;
+
+ /* read one byte to check if E-Fuse is empty */
+ if (efuse_one_byte_rw(padapter, true, 0, &value) == true) {
+ if (0xFF == value)
+ *empty = true;
+ else
+ *empty = false;
+ } else
+ ret = false;
+ return ret;
+}
+
+void r8712_efuse_change_max_size(struct _adapter *padapter)
+{
+ u16 pre_pg_data_saddr = 0x1FB;
+ u16 i;
+ u16 pre_pg_data_size = 5;
+ u8 pre_pg_data[5];
+
+ for (i = 0; i < pre_pg_data_size; i++)
+ efuse_one_byte_read(padapter, pre_pg_data_saddr + i,
+ &pre_pg_data[i]);
+ if ((pre_pg_data[0] == 0x03) && (pre_pg_data[1] == 0x00) &&
+ (pre_pg_data[2] == 0x00) && (pre_pg_data[3] == 0x00) &&
+ (pre_pg_data[4] == 0x0C))
+ efuse_available_max_size -= pre_pg_data_size;
+}
+
+int r8712_efuse_get_max_size(struct _adapter *padapter)
+{
+ return efuse_available_max_size;
+}
+
+static u8 calculate_word_cnts(const u8 word_en)
+{
+ u8 word_cnts = 0;
+ u8 word_idx;
+
+ for (word_idx = 0; word_idx < PGPKG_MAX_WORDS; word_idx++)
+ if (!(word_en & BIT(word_idx)))
+ word_cnts++; /* 0 : write enable */
+ return word_cnts;
+}
+
+static void pgpacket_copy_data(const u8 word_en, const u8 *sourdata,
+ u8 *targetdata)
+{
+ u8 tmpindex = 0;
+ u8 word_idx, byte_idx;
+
+ for (word_idx = 0; word_idx < PGPKG_MAX_WORDS; word_idx++) {
+ if (!(word_en&BIT(word_idx))) {
+ byte_idx = word_idx * 2;
+ targetdata[byte_idx] = sourdata[tmpindex++];
+ targetdata[byte_idx + 1] = sourdata[tmpindex++];
+ }
+ }
+}
+
+u16 r8712_efuse_get_current_size(struct _adapter *padapter)
+{
+ int bContinual = true;
+ u16 efuse_addr = 0;
+ u8 hoffset = 0, hworden = 0;
+ u8 efuse_data, word_cnts = 0;
+
+ while (bContinual && efuse_one_byte_read(padapter, efuse_addr,
+ &efuse_data) && (efuse_addr < efuse_available_max_size)) {
+ if (efuse_data != 0xFF) {
+ hoffset = (efuse_data >> 4) & 0x0F;
+ hworden = efuse_data & 0x0F;
+ word_cnts = calculate_word_cnts(hworden);
+ /* read next header */
+ efuse_addr = efuse_addr + (word_cnts * 2) + 1;
+ } else
+ bContinual = false ;
+ }
+ return efuse_addr;
+}
+
+u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data)
+{
+ u8 hoffset = 0, hworden = 0, word_cnts = 0;
+ u16 efuse_addr = 0;
+ u8 efuse_data;
+ u8 tmpidx = 0;
+ u8 tmpdata[PGPKT_DATA_SIZE];
+ u8 ret = true;
+
+ if (data == NULL)
+ return false;
+ if (offset > 0x0f)
+ return false;
+ memset(data, 0xFF, sizeof(u8)*PGPKT_DATA_SIZE);
+ while (efuse_addr < efuse_available_max_size) {
+ if (efuse_one_byte_read(padapter, efuse_addr, &efuse_data) ==
+ true) {
+ if (efuse_data == 0xFF)
+ break;
+ hoffset = (efuse_data >> 4) & 0x0F;
+ hworden = efuse_data & 0x0F;
+ word_cnts = calculate_word_cnts(hworden);
+ if (hoffset == offset) {
+ memset(tmpdata, 0xFF, PGPKT_DATA_SIZE);
+ for (tmpidx = 0; tmpidx < word_cnts * 2;
+ tmpidx++) {
+ if (efuse_one_byte_read(padapter,
+ efuse_addr+1+tmpidx, &efuse_data) ==
+ true) {
+ tmpdata[tmpidx] = efuse_data;
+ } else
+ ret = false;
+ }
+ pgpacket_copy_data(hworden, tmpdata, data);
+ }
+ efuse_addr += 1 + (word_cnts*2);
+ } else {
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr)
+{
+ struct PGPKT_STRUCT pkt;
+ u8 offset, word_en, value;
+ u16 addr;
+ int i;
+ u8 ret = true;
+
+ pkt.offset = GET_EFUSE_OFFSET(header);
+ pkt.word_en = GET_EFUSE_WORD_EN(header);
+ addr = header_addr + 1 + calculate_word_cnts(pkt.word_en) * 2;
+ if (addr > efuse_available_max_size)
+ return false;
+ /* retrieve original data */
+ addr = 0;
+ while (addr < header_addr) {
+ if (efuse_one_byte_read(padapter, addr++, &value) == false) {
+ ret = false;
+ break;
+ }
+ offset = GET_EFUSE_OFFSET(value);
+ word_en = GET_EFUSE_WORD_EN(value);
+ if (pkt.offset != offset) {
+ addr += calculate_word_cnts(word_en)*2;
+ continue;
+ }
+ for (i = 0; i < PGPKG_MAX_WORDS; i++) {
+ if (BIT(i) & word_en)
+ continue;
+ if (!(BIT(i) & pkt.word_en)) {
+ if (efuse_one_byte_read(padapter, addr,
+ &value) == true)
+ pkt.data[i*2] = value;
+ else
+ return false;
+ if (efuse_one_byte_read(padapter, addr + 1,
+ &value) == true)
+ pkt.data[i*2 + 1] = value;
+ else
+ return false;
+ }
+ addr += 2;
+ }
+ }
+ if (addr != header_addr)
+ return false;
+ addr++;
+ /* fill original data */
+ for (i = 0; i < PGPKG_MAX_WORDS; i++) {
+ if (BIT(i) & pkt.word_en)
+ continue;
+ efuse_one_byte_write(padapter, addr, pkt.data[i*2]);
+ efuse_one_byte_write(padapter, addr+1, pkt.data[i*2 + 1]);
+ /* additional check */
+ if (efuse_one_byte_read(padapter, addr, &value) == false)
+ ret = false;
+ else if (pkt.data[i*2] != value) {
+ ret = false;
+ if (0xFF == value) /* write again */
+ efuse_one_byte_write(padapter, addr,
+ pkt.data[i * 2]);
+ }
+ if (efuse_one_byte_read(padapter, addr+1, &value) == false)
+ ret = false;
+ else if (pkt.data[i*2 + 1] != value) {
+ ret = false;
+ if (0xFF == value) /* write again */
+ efuse_one_byte_write(padapter, addr+1,
+ pkt.data[i*2 + 1]);
+ }
+ addr += 2;
+ }
+ return ret;
+}
+
+u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset,
+ const u8 word_en, const u8 *data)
+{
+ u8 pg_header = 0;
+ u16 efuse_addr = 0, curr_size = 0;
+ u8 efuse_data, target_word_cnts = 0;
+ static int repeat_times;
+ int sub_repeat;
+ u8 bResult = true;
+
+ /* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */
+ efuse_data = r8712_read8(padapter, EFUSE_CLK_CTRL);
+ if (efuse_data != 0x03)
+ return false;
+ pg_header = MAKE_EFUSE_HEADER(offset, word_en);
+ target_word_cnts = calculate_word_cnts(word_en);
+ repeat_times = 0;
+ efuse_addr = 0;
+ while (efuse_addr < efuse_available_max_size) {
+ curr_size = r8712_efuse_get_current_size(padapter);
+ if ((curr_size + 1 + target_word_cnts * 2) >
+ efuse_available_max_size)
+ return false; /*target_word_cnts + pg header(1 byte)*/
+ efuse_addr = curr_size; /* current size is also the last addr*/
+ efuse_one_byte_write(padapter, efuse_addr, pg_header); /*hdr*/
+ sub_repeat = 0;
+ /* check if what we read is what we write */
+ while (efuse_one_byte_read(padapter, efuse_addr,
+ &efuse_data) == false) {
+ if (++sub_repeat > _REPEAT_THRESHOLD_) {
+ bResult = false; /* continue to blind write */
+ break; /* continue to blind write */
+ }
+ }
+ if ((sub_repeat > _REPEAT_THRESHOLD_) ||
+ (pg_header == efuse_data)) {
+ /* write header ok OR can't check header(creep) */
+ u8 i;
+
+ /* go to next address */
+ efuse_addr++;
+ for (i = 0; i < target_word_cnts*2; i++) {
+ efuse_one_byte_write(padapter,
+ efuse_addr + i,
+ *(data + i));
+ if (efuse_one_byte_read(padapter,
+ efuse_addr + i, &efuse_data) == false)
+ bResult = false;
+ else if (*(data+i) != efuse_data) /* fail */
+ bResult = false;
+ }
+ break;
+ } else { /* write header fail */
+ bResult = false;
+ if (0xFF == efuse_data)
+ return bResult; /* not thing damaged. */
+ /* call rescue procedure */
+ if (fix_header(padapter, efuse_data, efuse_addr) ==
+ false)
+ return false; /* rescue fail */
+
+ if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */
+ break;
+ /* otherwise, take another risk... */
+ }
+ }
+ return bResult;
+}
+
+u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr,
+ u16 cnts, u8 *data)
+{
+ int i;
+ u8 res = true;;
+
+ if (start_addr > EFUSE_MAX_SIZE)
+ return false;
+ if ((bRead == false) && ((start_addr + cnts) >
+ efuse_available_max_size))
+ return false;
+ if ((false == bRead) && (r8712_efuse_reg_init(padapter) == false))
+ return false;
+ /* -----------------e-fuse one byte read / write ---------------------*/
+ for (i = 0; i < cnts; i++) {
+ if ((start_addr + i) > EFUSE_MAX_SIZE) {
+ res = false;
+ break;
+ }
+ res = efuse_one_byte_rw(padapter, bRead, start_addr + i,
+ data + i);
+ if ((false == bRead) && (false == res))
+ break;
+ }
+ if (false == bRead)
+ r8712_efuse_reg_uninit(padapter);
+ return res;
+}
+
+u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data)
+{
+ u8 offset, ret = true;
+ u8 pktdata[PGPKT_DATA_SIZE];
+ int i, idx;
+
+ if ((addr + cnts) > EFUSE_MAP_MAX_SIZE)
+ return false;
+ if ((efuse_is_empty(padapter, &offset) == true) && (offset ==
+ true)) {
+ for (i = 0; i < cnts; i++)
+ data[i] = 0xFF;
+ return ret;
+ }
+ offset = (addr >> 3) & 0xF;
+ ret = r8712_efuse_pg_packet_read(padapter, offset, pktdata);
+ i = addr & 0x7; /* pktdata index */
+ idx = 0; /* data index */
+
+ do {
+ for (; i < PGPKT_DATA_SIZE; i++) {
+ data[idx++] = pktdata[i];
+ if (idx == cnts)
+ return ret;
+ }
+ offset++;
+ if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata))
+ ret = false;
+ i = 0;
+ } while (1);
+ return ret;
+}
+
+u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts,
+ u8 *data)
+{
+ u8 offset, word_en, empty;
+ u8 pktdata[PGPKT_DATA_SIZE], newdata[PGPKT_DATA_SIZE];
+ int i, j, idx;
+
+ if ((addr + cnts) > EFUSE_MAP_MAX_SIZE)
+ return false;
+ /* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */
+ empty = r8712_read8(padapter, EFUSE_CLK_CTRL);
+ if (empty != 0x03)
+ return false;
+ if (efuse_is_empty(padapter, &empty) == true) {
+ if (true == empty)
+ memset(pktdata, 0xFF, PGPKT_DATA_SIZE);
+ } else
+ return false;
+ offset = (addr >> 3) & 0xF;
+ if (empty == false)
+ if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata))
+ return false;
+ word_en = 0xF;
+ memset(newdata, 0xFF, PGPKT_DATA_SIZE);
+ i = addr & 0x7; /* pktdata index */
+ j = 0; /* newdata index */
+ idx = 0; /* data index */
+
+ if (i & 0x1) {
+ /* odd start */
+ if (data[idx] != pktdata[i]) {
+ word_en &= ~BIT(i >> 1);
+ newdata[j++] = pktdata[i - 1];
+ newdata[j++] = data[idx];
+ }
+ i++;
+ idx++;
+ }
+ do {
+ for (; i < PGPKT_DATA_SIZE; i += 2) {
+ if ((cnts - idx) == 1) {
+ if (data[idx] != pktdata[i]) {
+ word_en &= ~BIT(i >> 1);
+ newdata[j++] = data[idx];
+ newdata[j++] = pktdata[1 + 1];
+ }
+ idx++;
+ break;
+ } else {
+ if ((data[idx] != pktdata[i]) || (data[idx+1] !=
+ pktdata[i+1])) {
+ word_en &= ~BIT(i >> 1);
+ newdata[j++] = data[idx];
+ newdata[j++] = data[idx + 1];
+ }
+ idx += 2;
+ }
+ if (idx == cnts)
+ break;
+ }
+
+ if (word_en != 0xF)
+ if (r8712_efuse_pg_packet_write(padapter, offset,
+ word_en, newdata) == false)
+ return false;
+ if (idx == cnts)
+ break;
+ offset++;
+ if (empty == false)
+ if (!r8712_efuse_pg_packet_read(padapter, offset,
+ pktdata))
+ return false;
+ i = 0;
+ j = 0;
+ word_en = 0xF;
+ memset(newdata, 0xFF, PGPKT_DATA_SIZE);
+ } while (1);
+
+ return true;
+}
diff --git a/drivers/staging/rtl8712/rtl8712_efuse.h b/drivers/staging/rtl8712/rtl8712_efuse.h
new file mode 100644
index 000000000000..6a64f91ad75f
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_efuse.h
@@ -0,0 +1,43 @@
+#ifndef __RTL8712_EFUSE_H__
+#define __RTL8712_EFUSE_H__
+
+#include "osdep_service.h"
+
+
+#define _REPEAT_THRESHOLD_ 3
+
+#define EFUSE_MAX_SIZE 512
+#define EFUSE_MAP_MAX_SIZE 128
+
+#define PGPKG_MAX_WORDS 4
+#define PGPKT_DATA_SIZE 8 /* PGPKG_MAX_WORDS*2; BYTES sizeof(u8)*8*/
+#define MAX_PGPKT_SIZE 9 /* 1 + PGPKT_DATA_SIZE; header + 2 * 4 words (BYTES)*/
+
+#define GET_EFUSE_OFFSET(header) ((header & 0xF0) >> 4)
+#define GET_EFUSE_WORD_EN(header) (header & 0x0F)
+#define MAKE_EFUSE_HEADER(offset, word_en) (((offset & 0x0F) << 4) | \
+ (word_en & 0x0F))
+/*--------------------------------------------------------------------------*/
+struct PGPKT_STRUCT {
+ u8 offset;
+ u8 word_en;
+ u8 data[PGPKT_DATA_SIZE];
+};
+/*--------------------------------------------------------------------------*/
+u8 r8712_efuse_reg_init(struct _adapter *padapter);
+void r8712_efuse_reg_uninit(struct _adapter *padapter);
+u16 r8712_efuse_get_current_size(struct _adapter *padapter);
+int r8712_efuse_get_max_size(struct _adapter *padapter);
+void r8712_efuse_change_max_size(struct _adapter *padapter);
+u8 r8712_efuse_pg_packet_read(struct _adapter *padapter,
+ u8 offset, u8 *data);
+u8 r8712_efuse_pg_packet_write(struct _adapter *padapter,
+ const u8 offset, const u8 word_en,
+ const u8 *data);
+u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead,
+ u16 start_addr, u16 cnts, u8 *data);
+u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr,
+ u16 cnts, u8 *data);
+u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr,
+ u16 cnts, u8 *data);
+#endif
diff --git a/drivers/staging/rtl8712/rtl8712_event.h b/drivers/staging/rtl8712/rtl8712_event.h
new file mode 100644
index 000000000000..48408f72546c
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_event.h
@@ -0,0 +1,73 @@
+#ifndef _RTL8712_EVENT_H_
+#define _RTL8712_EVENT_H_
+
+void r8712_event_handle(struct _adapter *padapter, uint *peventbuf);
+void r8712_got_addbareq_event_callback(struct _adapter *adapter , u8 *pbuf);
+
+enum rtl8712_c2h_event {
+ GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
+ GEN_EVT_CODE(_Read_BBREG),
+ GEN_EVT_CODE(_Read_RFREG),
+ GEN_EVT_CODE(_Read_EEPROM),
+ GEN_EVT_CODE(_Read_EFUSE),
+ GEN_EVT_CODE(_Read_CAM), /*5*/
+ GEN_EVT_CODE(_Get_BasicRate),
+ GEN_EVT_CODE(_Get_DataRate),
+ GEN_EVT_CODE(_Survey), /*8*/
+ GEN_EVT_CODE(_SurveyDone), /*9*/
+
+ GEN_EVT_CODE(_JoinBss) , /*10*/
+ GEN_EVT_CODE(_AddSTA),
+ GEN_EVT_CODE(_DelSTA),
+ GEN_EVT_CODE(_AtimDone) ,
+ GEN_EVT_CODE(_TX_Report),
+ GEN_EVT_CODE(_CCX_Report), /*15*/
+ GEN_EVT_CODE(_DTM_Report),
+ GEN_EVT_CODE(_TX_Rate_Statistics),
+ GEN_EVT_CODE(_C2HLBK),
+ GEN_EVT_CODE(_FWDBG),
+ GEN_EVT_CODE(_C2HFEEDBACK), /*20*/
+ GEN_EVT_CODE(_ADDBA),
+ GEN_EVT_CODE(_C2HBCN),
+ GEN_EVT_CODE(_ReportPwrState), /*filen: only for PCIE, USB*/
+ GEN_EVT_CODE(_WPS_PBC), /*24*/
+ GEN_EVT_CODE(_ADDBAReq_Report), /*25*/
+ MAX_C2HEVT
+};
+
+
+#ifdef _RTL8712_CMD_C_
+
+static struct fwevent wlanevents[] = {
+ {0, NULL}, /*0*/
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, &r8712_survey_event_callback}, /*8*/
+ {sizeof(struct surveydone_event), &r8712_surveydone_event_callback},/*9*/
+
+ {0, &r8712_joinbss_event_callback}, /*10*/
+ {sizeof(struct stassoc_event), &r8712_stassoc_event_callback},
+ {sizeof(struct stadel_event), &r8712_stadel_event_callback},
+ {0, &r8712_atimdone_event_callback},
+ {0, NULL},
+ {0, NULL}, /*15*/
+ {0, NULL},
+ {0, NULL},
+ {0, NULL},
+ {0, NULL}, /*fwdbg_event_callback},*/
+ {0, NULL}, /*20*/
+ {0, NULL},
+ {0, NULL},
+ {0, &r8712_cpwm_event_callback},
+ {0, &r8712_wpspbc_event_callback},
+ {0, &r8712_got_addbareq_event_callback},
+};
+
+#endif/*_RTL8712_CMD_C_*/
+
+#endif
diff --git a/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h
new file mode 100644
index 000000000000..e5df19f4b02b
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h
@@ -0,0 +1,126 @@
+#ifndef __RTL8712_FIFOCTRL_BITDEF_H__
+#define __RTL8712_FIFOCTRL_BITDEF_H__
+
+/*PBP*/
+#define _PSTX_MSK 0xF0
+#define _PSTX_SHT 4
+#define _PSRX_MSK 0x0F
+#define _PSRX_SHT 0
+
+/*TXFF_STATUS*/
+#define _TXSTATUS_OVF BIT(15)
+
+/*RXFF_STATUS*/
+#define _STATUSFF1_OVF BIT(7)
+#define _STATUSFF1_EMPTY BIT(6)
+#define _STATUSFF0_OVF BIT(5)
+#define _STATUSFF0_EMPTY BIT(4)
+#define _RXFF1_OVF BIT(3)
+#define _RXFF1_EMPTY BIT(2)
+#define _RXFF0_OVF BIT(1)
+#define _RXFF0_EMPTY BIT(0)
+
+/*TXFF_EMPTY_TH*/
+#define _BKQ_EMPTY_TH_MSK 0x0F0000
+#define _BKQ_EMPTY_TH_SHT 16
+#define _BEQ_EMPTY_TH_MSK 0x00F000
+#define _BEQ_EMPTY_TH_SHT 12
+#define _VIQ_EMPTY_TH_MSK 0x000F00
+#define _VIQ_EMPTY_TH_SHT 8
+#define _VOQ_EMPTY_TH_MSK 0x0000F0
+#define _VOQ_EMPTY_TH_SHT 4
+#define _BMCQ_EMPTY_TH_MSK 0x00000F
+#define _BMCQ_EMPTY_TH_SHT 0
+
+/*SDIO_RX_BLKSZ*/
+#define _SDIO_RX_BLKSZ_MSK 0x07
+
+/*RXDMA_CTRL*/
+#define _C2HFF_POLL BIT(4)
+#define _RXPKT_POLL BIT(0)
+
+/*RXPKT_NUM*/
+#define _RXCMD_NUM_MSK 0xFF00
+#define _RXCMD_NUM_SHT 8
+#define _RXFF0_NUM_MSK 0x00FF
+#define _RXFF0_NUM_SHT 0
+
+/*FIFOPAGE2*/
+#define _PUB_AVAL_PG_MSK 0xFFFF0000
+#define _PUB_AVAL_PG_SHT 16
+#define _BCN_AVAL_PG_MSK 0x0000FFFF
+#define _BCN_AVAL_PG_SHT 0
+
+/*RX0PKTNUM*/
+#define _RXFF0_DEC_POLL BIT(15)
+#define _RXFF0_PKT_DEC_NUM_MSK 0x3F00
+#define _RXFF0_PKT_DEC_NUM_SHT 8
+#define _RXFF0_PKTNUM_RPT_MSK 0x00FF
+#define _RXFF0_PKTNUM_RPT_SHT 0
+
+/*RX1PKTNUM*/
+#define _RXFF1_DEC_POLL BIT(15)
+#define _RXFF1_PKT_DEC_NUM_MSK 0x3F00
+#define _RXFF1_PKT_DEC_NUM_SHT 8
+#define _RXFF1_PKTNUM_RPT_MSK 0x00FF
+#define _RXFF1_PKTNUM_RPT_SHT 0
+
+/*RXFLTMAP0*/
+#define _MGTFLT13EN BIT(13)
+#define _MGTFLT12EN BIT(12)
+#define _MGTFLT11EN BIT(11)
+#define _MGTFLT10EN BIT(10)
+#define _MGTFLT9EN BIT(9)
+#define _MGTFLT8EN BIT(8)
+#define _MGTFLT5EN BIT(5)
+#define _MGTFLT4EN BIT(4)
+#define _MGTFLT3EN BIT(3)
+#define _MGTFLT2EN BIT(2)
+#define _MGTFLT1EN BIT(1)
+#define _MGTFLT0EN BIT(0)
+
+/*RXFLTMAP1*/
+#define _CTRLFLT15EN BIT(15)
+#define _CTRLFLT14EN BIT(14)
+#define _CTRLFLT13EN BIT(13)
+#define _CTRLFLT12EN BIT(12)
+#define _CTRLFLT11EN BIT(11)
+#define _CTRLFLT10EN BIT(10)
+#define _CTRLFLT9EN BIT(9)
+#define _CTRLFLT8EN BIT(8)
+#define _CTRLFLT7EN BIT(7)
+#define _CTRLFLT6EN BIT(6)
+
+/*RXFLTMAP2*/
+#define _DATAFLT15EN BIT(15)
+#define _DATAFLT14EN BIT(14)
+#define _DATAFLT13EN BIT(13)
+#define _DATAFLT12EN BIT(12)
+#define _DATAFLT11EN BIT(11)
+#define _DATAFLT10EN BIT(10)
+#define _DATAFLT9EN BIT(9)
+#define _DATAFLT8EN BIT(8)
+#define _DATAFLT7EN BIT(7)
+#define _DATAFLT6EN BIT(6)
+#define _DATAFLT5EN BIT(5)
+#define _DATAFLT4EN BIT(4)
+#define _DATAFLT3EN BIT(3)
+#define _DATAFLT2EN BIT(2)
+#define _DATAFLT1EN BIT(1)
+#define _DATAFLT0EN BIT(0)
+
+/*RXFLTMAP3*/
+#define _MESHAFLT1EN BIT(1)
+#define _MESHAFLT0EN BIT(0)
+
+/*TXPKT_NUM_CTRL*/
+#define _TXPKTNUM_DEC BIT(8)
+#define _TXPKTNUM_MSK 0x00FF
+#define _TXPKTNUM_SHT 0
+
+/*TXFF_PG_NUM*/
+#define _TXFF_PG_NUM_MSK 0x0FFF
+
+
+#endif /* __RTL8712_FIFOCTRL_BITDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h b/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h
new file mode 100644
index 000000000000..c2e3af2c79f6
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h
@@ -0,0 +1,57 @@
+#ifndef __RTL8712_FIFOCTRL_REGDEF_H__
+#define __RTL8712_FIFOCTRL_REGDEF_H__
+
+#define RQPN (RTL8712_FIFOCTRL_ + 0x00)
+#define RXFF_BNDY (RTL8712_FIFOCTRL_ + 0x0C)
+#define RXRPT_BNDY (RTL8712_FIFOCTRL_ + 0x10)
+#define TXPKTBUF_PGBNDY (RTL8712_FIFOCTRL_ + 0x14)
+#define PBP (RTL8712_FIFOCTRL_ + 0x15)
+#define RX_DRVINFO_SZ (RTL8712_FIFOCTRL_ + 0x16)
+#define TXFF_STATUS (RTL8712_FIFOCTRL_ + 0x17)
+#define RXFF_STATUS (RTL8712_FIFOCTRL_ + 0x18)
+#define TXFF_EMPTY_TH (RTL8712_FIFOCTRL_ + 0x19)
+#define SDIO_RX_BLKSZ (RTL8712_FIFOCTRL_ + 0x1C)
+#define RXDMA_RXCTRL (RTL8712_FIFOCTRL_ + 0x1D)
+#define RXPKT_NUM (RTL8712_FIFOCTRL_ + 0x1E)
+#define RXPKT_NUM_C2H (RTL8712_FIFOCTRL_ + 0x1F)
+#define C2HCMD_UDT_SIZE (RTL8712_FIFOCTRL_ + 0x20)
+#define C2HCMD_UDT_ADDR (RTL8712_FIFOCTRL_ + 0x22)
+#define FIFOPAGE2 (RTL8712_FIFOCTRL_ + 0x24)
+#define FIFOPAGE1 (RTL8712_FIFOCTRL_ + 0x28)
+#define FW_RSVD_PG_CTRL (RTL8712_FIFOCTRL_ + 0x30)
+#define TXRPTFF_RDPTR (RTL8712_FIFOCTRL_ + 0x40)
+#define TXRPTFF_WTPTR (RTL8712_FIFOCTRL_ + 0x44)
+#define C2HFF_RDPTR (RTL8712_FIFOCTRL_ + 0x48)
+#define C2HFF_WTPTR (RTL8712_FIFOCTRL_ + 0x4C)
+#define RXFF0_RDPTR (RTL8712_FIFOCTRL_ + 0x50)
+#define RXFF0_WTPTR (RTL8712_FIFOCTRL_ + 0x54)
+#define RXFF1_RDPTR (RTL8712_FIFOCTRL_ + 0x58)
+#define RXFF1_WTPTR (RTL8712_FIFOCTRL_ + 0x5C)
+#define RXRPT0FF_RDPTR (RTL8712_FIFOCTRL_ + 0x60)
+#define RXRPT0FF_WTPTR (RTL8712_FIFOCTRL_ + 0x64)
+#define RXRPT1FF_RDPTR (RTL8712_FIFOCTRL_ + 0x68)
+#define RXRPT1FF_WTPTR (RTL8712_FIFOCTRL_ + 0x6C)
+#define RX0PKTNUM (RTL8712_FIFOCTRL_ + 0x72)
+#define RX1PKTNUM (RTL8712_FIFOCTRL_ + 0x74)
+#define RXFLTMAP0 (RTL8712_FIFOCTRL_ + 0x76)
+#define RXFLTMAP1 (RTL8712_FIFOCTRL_ + 0x78)
+#define RXFLTMAP2 (RTL8712_FIFOCTRL_ + 0x7A)
+#define RXFLTMAP3 (RTL8712_FIFOCTRL_ + 0x7c)
+#define TBDA (RTL8712_FIFOCTRL_ + 0x84)
+#define THPDA (RTL8712_FIFOCTRL_ + 0x88)
+#define TCDA (RTL8712_FIFOCTRL_ + 0x8C)
+#define TMDA (RTL8712_FIFOCTRL_ + 0x90)
+#define HDA (RTL8712_FIFOCTRL_ + 0x94)
+#define TVODA (RTL8712_FIFOCTRL_ + 0x98)
+#define TVIDA (RTL8712_FIFOCTRL_ + 0x9C)
+#define TBEDA (RTL8712_FIFOCTRL_ + 0xA0)
+#define TBKDA (RTL8712_FIFOCTRL_ + 0xA4)
+#define RCDA (RTL8712_FIFOCTRL_ + 0xA8)
+#define RDSA (RTL8712_FIFOCTRL_ + 0xAC)
+#define TXPKT_NUM_CTRL (RTL8712_FIFOCTRL_ + 0xB0)
+#define TXQ_PGADD (RTL8712_FIFOCTRL_ + 0xB3)
+#define TXFF_PG_NUM (RTL8712_FIFOCTRL_ + 0xB4)
+
+
+
+#endif /* __RTL8712_FIFOCTRL_REGDEF_H__ */
diff --git a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h
new file mode 100644
index 000000000000..35ca809e1799
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h
@@ -0,0 +1,54 @@
+#ifndef __RTL8712_GP_BITDEF_H__
+#define __RTL8712_GP_BITDEF_H__
+
+/*GPIO_CTRL*/
+#define _GPIO_MOD_MSK 0xFF000000
+#define _GPIO_MOD_SHT 24
+#define _GPIO_IO_SEL_MSK 0x00FF0000
+#define _GPIO_IO_SEL_SHT 16
+#define _GPIO_OUT_MSK 0x0000FF00
+#define _GPIO_OUT_SHT 8
+#define _GPIO_IN_MSK 0x000000FF
+#define _GPIO_IN_SHT 0
+
+/*SYS_PINMUX_CFG*/
+#define _GPIOSEL_MSK 0x0003
+#define _GPIOSEL_SHT 0
+
+/*LED_CFG*/
+#define _LED1SV BIT(7)
+#define _LED1CM_MSK 0x0070
+#define _LED1CM_SHT 4
+#define _LED0SV BIT(3)
+#define _LED0CM_MSK 0x0007
+#define _LED0CM_SHT 0
+
+/*PHY_REG*/
+#define _HST_RDRDY_SHT 0
+#define _HST_RDRDY_MSK 0xFF
+#define _HST_RDRDY BIT(_HST_RDRDY_SHT)
+#define _CPU_WTBUSY_SHT 1
+#define _CPU_WTBUSY_MSK 0xFF
+#define _CPU_WTBUSY BIT(_CPU_WTBUSY_SHT)
+
+/* 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)*/
+
+/* 8192S GPIO Config Setting (offset 0x2F1, 1 byte)*/
+
+/*----------------------------------------------------------------------------*/
+
+#define GPIOMUX_EN BIT(3) /* When this bit is set to "1",
+ * GPIO PINs will switch to MAC
+ * GPIO Function*/
+#define GPIOSEL_GPIO 0 /* UART or JTAG or pure GPIO*/
+#define GPIOSEL_PHYDBG 1 /* PHYDBG*/
+#define GPIOSEL_BT 2 /* BT_coex*/
+#define GPIOSEL_WLANDBG 3 /* WLANDBG*/
+#define GPIOSEL_GPIO_MASK (~(BIT(0)|BIT(1)))
+/* HW Readio OFF switch (GPIO BIT) */
+#define HAL_8192S_HW_GPIO_OFF_BIT BIT(3)
+#define HAL_8192S_HW_GPIO_OFF_MASK 0xF7
+#define HAL_8192S_HW_GPIO_WPS_BIT BIT(4)
+
+#endif /*__RTL8712_GP_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_gp_regdef.h b/drivers/staging/rtl8712/rtl8712_gp_regdef.h
new file mode 100644
index 000000000000..17e72bda617e
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_gp_regdef.h
@@ -0,0 +1,17 @@
+#ifndef __RTL8712_GP_REGDEF_H__
+#define __RTL8712_GP_REGDEF_H__
+
+#define PSTIMER (RTL8712_GP_ + 0x00)
+#define TIMER1 (RTL8712_GP_ + 0x04)
+#define TIMER2 (RTL8712_GP_ + 0x08)
+#define GPIO_CTRL (RTL8712_GP_ + 0x0C)
+#define GPIO_IO_SEL (RTL8712_GP_ + 0x0E)
+#define GPIO_INTCTRL (RTL8712_GP_ + 0x10)
+#define MAC_PINMUX_CTRL (RTL8712_GP_ + 0x11)
+#define LEDCFG (RTL8712_GP_ + 0x12)
+#define PHY_REG_RPT (RTL8712_GP_ + 0x13)
+#define PHY_REG_DATA (RTL8712_GP_ + 0x14)
+
+
+#endif /*__RTL8712_GP_REGDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h
new file mode 100644
index 000000000000..13df2001e9ad
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_hal.h
@@ -0,0 +1,124 @@
+#ifndef __RTL8712_HAL_H__
+#define __RTL8712_HAL_H__
+
+enum _HW_VERSION {
+ RTL8712_FPGA,
+ RTL8712_1stCUT, /*A Cut (RTL8712_ASIC)*/
+ RTL8712_2ndCUT, /*B Cut*/
+ RTL8712_3rdCUT, /*C Cut*/
+};
+
+enum _LOOPBACK_TYPE {
+ RTL8712_AIR_TRX = 0,
+ RTL8712_MAC_LBK,
+ RTL8712_BB_LBK,
+ RTL8712_MAC_FW_LBK = 4,
+ RTL8712_BB_FW_LBK = 8,
+};
+
+enum RTL871X_HCI_TYPE {
+ RTL8712_SDIO,
+ RTL8712_USB,
+};
+
+enum RTL8712_RF_CONFIG{
+ RTL8712_RF_1T1R,
+ RTL8712_RF_1T2R,
+ RTL8712_RF_2T2R
+};
+
+enum _RTL8712_HCI_TYPE_{
+ RTL8712_HCI_TYPE_PCIE = 0x01,
+ RTL8712_HCI_TYPE_AP_PCIE = 0x81,
+ RTL8712_HCI_TYPE_USB = 0x02,
+ RTL8712_HCI_TYPE_92USB = 0x02,
+ RTL8712_HCI_TYPE_AP_USB = 0x82,
+ RTL8712_HCI_TYPE_72USB = 0x12,
+ RTL8712_HCI_TYPE_SDIO = 0x04,
+ RTL8712_HCI_TYPE_72SDIO = 0x14
+};
+
+struct fw_priv { /*8-bytes alignment required*/
+ /*--- long word 0 ----*/
+ unsigned char signature_0; /*0x12: CE product, 0x92: IT product*/
+ unsigned char signature_1; /*0x87: CE product, 0x81: IT product*/
+ unsigned char hci_sel; /*0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP,
+ * 0x12: 72S-U, 03:SDIO*/
+ unsigned char chip_version; /*the same value as register value*/
+ unsigned char customer_ID_0; /*customer ID low byte*/
+ unsigned char customer_ID_1; /*customer ID high byte*/
+ unsigned char rf_config; /*0x11: 1T1R, 0x12: 1T2R, 0x92: 1T2R turbo,
+ * 0x22: 2T2R*/
+ unsigned char usb_ep_num; /* 4: 4EP, 6: 6EP, 11: 11EP*/
+ /*--- long word 1 ----*/
+ unsigned char regulatory_class_0; /*regulatory class bit map 0*/
+ unsigned char regulatory_class_1; /*regulatory class bit map 1*/
+ unsigned char regulatory_class_2; /*regulatory class bit map 2*/
+ unsigned char regulatory_class_3; /*regulatory class bit map 3*/
+ unsigned char rfintfs; /* 0:SWSI, 1:HWSI, 2:HWPI*/
+ unsigned char def_nettype;
+ unsigned char turboMode;
+ unsigned char lowPowerMode;/* 0: noral mode, 1: low power mode*/
+ /*--- long word 2 ----*/
+ unsigned char lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/
+ unsigned char mp_mode; /* 1: for MP use, 0: for normal driver */
+ unsigned char vcsType; /* 0:off 1:on 2:auto */
+ unsigned char vcsMode; /* 1:RTS/CTS 2:CTS to self */
+ unsigned char rsvd022;
+ unsigned char rsvd023;
+ unsigned char rsvd024;
+ unsigned char rsvd025;
+ /*--- long word 3 ----*/
+ unsigned char qos_en; /*1: QoS enable*/
+ unsigned char bw_40MHz_en; /*1: 40MHz BW enable*/
+ unsigned char AMSDU2AMPDU_en; /*1: 4181 convert AMSDU to AMPDU,
+ * 0: disable*/
+ unsigned char AMPDU_en; /*1: 11n AMPDU enable*/
+ unsigned char rate_control_offload; /*1: FW offloads, 0: driver handles*/
+ unsigned char aggregation_offload; /*1: FW offloads, 0: driver handles*/
+ unsigned char rsvd030;
+ unsigned char rsvd031;
+ /*--- long word 4 ----*/
+ unsigned char beacon_offload; /* 1. FW offloads, 0: driver handles*/
+ unsigned char MLME_offload; /* 2. FW offloads, 0: driver handles*/
+ unsigned char hwpc_offload; /* 3. FW offloads, 0: driver handles*/
+ unsigned char tcp_checksum_offload; /* 4. FW offloads, 0: driver handles*/
+ unsigned char tcp_offload; /* 5. FW offloads, 0: driver handles*/
+ unsigned char ps_control_offload; /* 6. FW offloads, 0: driver handles*/
+ unsigned char WWLAN_offload; /* 7. FW offloads, 0: driver handles*/
+ unsigned char rsvd040;
+ /*--- long word 5 ----*/
+ unsigned char tcp_tx_frame_len_L; /*tcp tx packet length low byte*/
+ unsigned char tcp_tx_frame_len_H; /*tcp tx packet length high byte*/
+ unsigned char tcp_rx_frame_len_L; /*tcp rx packet length low byte*/
+ unsigned char tcp_rx_frame_len_H; /*tcp rx packet length high byte*/
+ unsigned char rsvd050;
+ unsigned char rsvd051;
+ unsigned char rsvd052;
+ unsigned char rsvd053;
+};
+
+struct fw_hdr {/*8-byte alinment required*/
+ unsigned short signature;
+ unsigned short version; /*0x8000 ~ 0x8FFF for FPGA version,
+ *0x0000 ~ 0x7FFF for ASIC version,*/
+ unsigned int dmem_size; /*define the size of boot loader*/
+ unsigned int img_IMEM_size; /*define the size of FW in IMEM*/
+ unsigned int img_SRAM_size; /*define the size of FW in SRAM*/
+ unsigned int fw_priv_sz; /*define the size of DMEM variable*/
+ unsigned short efuse_addr;
+ unsigned short h2ccnd_resp_addr;
+ unsigned int SVNRevision;
+ unsigned int release_time; /*Mon:Day:Hr:Min*/
+ struct fw_priv fwpriv;
+};
+
+struct hal_priv{
+ /*Endpoint handles*/
+ struct net_device *pipehdls_r8712[10];
+ u8 (*hal_bus_init)(struct _adapter *adapter);
+};
+
+uint rtl8712_hal_init(struct _adapter *padapter);
+
+#endif
diff --git a/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h b/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h
new file mode 100644
index 000000000000..02f24809814d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h
@@ -0,0 +1,39 @@
+#ifndef __RTL8712_INTERRUPT_BITDEF_H__
+#define __RTL8712_INTERRUPT_BITDEF_H__
+
+/*HIMR*/
+/*HISR*/
+#define _CPUERR BIT(29)
+#define _ATIMEND BIT(28)
+#define _TXBCNOK BIT(27)
+#define _TXBCNERR BIT(26)
+#define _BCNDMAINT4 BIT(25)
+#define _BCNDMAINT3 BIT(24)
+#define _BCNDMAINT2 BIT(23)
+#define _BCNDMAINT1 BIT(22)
+#define _BCNDOK4 BIT(21)
+#define _BCNDOK3 BIT(20)
+#define _BCNDOK2 BIT(19)
+#define _BCNDOK1 BIT(18)
+#define _TIMEOUT2 BIT(17)
+#define _TIMEOUT1 BIT(16)
+#define _TXFOVW BIT(15)
+#define _PSTIMEOUT BIT(14)
+#define _BCNDMAINT0 BIT(13)
+#define _FOVW BIT(12)
+#define _RDU BIT(11)
+#define _RXCMDOK BIT(10)
+#define _BCNDOK0 BIT(9)
+#define _HIGHDOK BIT(8)
+#define _COMDOK BIT(7)
+#define _MGTDOK BIT(6)
+#define _HCCADOK BIT(5)
+#define _BKDOK BIT(4)
+#define _BEDOK BIT(3)
+#define _VIDOK BIT(2)
+#define _VODOK BIT(1)
+#define _RXOK BIT(0)
+
+
+#endif /*__RTL8712_INTERRUPT_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_io.c b/drivers/staging/rtl8712/rtl8712_io.c
new file mode 100644
index 000000000000..c7346008def0
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_io.c
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * rtl8712_io.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>.
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL8712_IO_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_io.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+u8 r8712_read8(struct _adapter *adapter, u32 addr)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+ u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
+ u8 r_val;
+
+ _read8 = pintfhdl->io_ops._read8;
+ r_val = _read8(pintfhdl, addr);
+ return r_val;
+}
+
+u16 r8712_read16(struct _adapter *adapter, u32 addr)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+ u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
+ u16 r_val;
+
+ _read16 = pintfhdl->io_ops._read16;
+ r_val = _read16(pintfhdl, addr);
+ return r_val;
+}
+
+u32 r8712_read32(struct _adapter *adapter, u32 addr)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+ u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
+ u32 r_val;
+
+ _read32 = pintfhdl->io_ops._read32;
+ r_val = _read32(pintfhdl, addr);
+ return r_val;
+}
+
+void r8712_write8(struct _adapter *adapter, u32 addr, u8 val)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+ void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
+
+ _write8 = pintfhdl->io_ops._write8;
+ _write8(pintfhdl, addr, val);
+}
+
+void r8712_write16(struct _adapter *adapter, u32 addr, u16 val)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+
+ void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
+ _write16 = pintfhdl->io_ops._write16;
+ _write16(pintfhdl, addr, val);
+}
+
+void r8712_write32(struct _adapter *adapter, u32 addr, u32 val)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_queue->intf));
+
+ void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
+ _write32 = pintfhdl->io_ops._write32;
+ _write32(pintfhdl, addr, val);
+}
+
+void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+
+ void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ if ((adapter->bDriverStopped == true) ||
+ (adapter->bSurpriseRemoved == true))
+ return;
+ _read_mem = pintfhdl->io_ops._read_mem;
+ _read_mem(pintfhdl, addr, cnt, pmem);
+}
+
+void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+ void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+
+ _write_mem = pintfhdl->io_ops._write_mem;
+ _write_mem(pintfhdl, addr, cnt, pmem);
+}
+
+void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+
+ u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ if ((adapter->bDriverStopped == true) ||
+ (adapter->bSurpriseRemoved == true))
+ return;
+ _read_port = pintfhdl->io_ops._read_port;
+ _read_port(pintfhdl, addr, cnt, pmem);
+}
+
+void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
+{
+ struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
+ struct intf_hdl *pintfhdl = &(pio_queue->intf);
+
+ u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ _write_port = pintfhdl->io_ops._write_port;
+ _write_port(pintfhdl, addr, cnt, pmem);
+}
diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c
new file mode 100644
index 000000000000..5024ee42b04b
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_led.c
@@ -0,0 +1,1815 @@
+/******************************************************************************
+ * rtl8712_led.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#include "drv_types.h"
+
+/*===========================================================================
+ * Constant.
+ *===========================================================================
+
+ *
+ * Default LED behavior.
+ */
+#define LED_BLINK_NORMAL_INTERVAL 100
+#define LED_BLINK_SLOWLY_INTERVAL 200
+#define LED_BLINK_LONG_INTERVAL 400
+
+#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000
+#define LED_BLINK_LINK_INTERVAL_ALPHA 500
+#define LED_BLINK_SCAN_INTERVAL_ALPHA 180
+#define LED_BLINK_FASTER_INTERVAL_ALPHA 50
+#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000
+
+/*===========================================================================
+ * LED object.
+ *===========================================================================
+ */
+enum _LED_STATE_871x{
+ LED_UNKNOWN = 0,
+ LED_ON = 1,
+ LED_OFF = 2,
+ LED_BLINK_NORMAL = 3,
+ LED_BLINK_SLOWLY = 4,
+ LED_POWER_ON_BLINK = 5,
+ LED_SCAN_BLINK = 6, /* LED is blinking during scanning period,
+ * the # of times to blink is depend on time
+ * for scanning. */
+ LED_NO_LINK_BLINK = 7, /* LED is blinking during no link state. */
+ LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer
+ * Server case */
+ LED_BLINK_WPS = 9, /* LED is blinkg during WPS communication */
+ LED_TXRX_BLINK = 10,
+ LED_BLINK_WPS_STOP = 11, /*for ALPHA */
+ LED_BLINK_WPS_STOP_OVERLAP = 12, /*for BELKIN */
+};
+
+/*===========================================================================
+ * Prototype of protected function.
+ *===========================================================================
+ */
+static void BlinkTimerCallback(unsigned long data);
+
+static void BlinkWorkItemCallback(struct work_struct *work);
+/*===========================================================================
+ * LED_819xUsb routines.
+ *===========================================================================
+ *
+ *
+ *
+ * Description:
+ * Initialize an LED_871x object.
+ */
+static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed,
+ enum LED_PIN_871x LedPin)
+{
+ struct net_device *nic;
+
+ nic = padapter->pnetdev;
+ pLed->padapter = padapter;
+ pLed->LedPin = LedPin;
+ pLed->CurrLedState = LED_OFF;
+ pLed->bLedOn = false;
+ pLed->bLedBlinkInProgress = false;
+ pLed->BlinkTimes = 0;
+ pLed->BlinkingLedState = LED_UNKNOWN;
+ _init_timer(&(pLed->BlinkTimer), nic, BlinkTimerCallback, pLed);
+ _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed);
+}
+
+/*
+ * Description:
+ * DeInitialize an LED_871x object.
+ */
+static void DeInitLed871x(struct LED_871x *pLed)
+{
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ /* We should reset bLedBlinkInProgress if we cancel
+ * the LedControlTimer, */
+ pLed->bLedBlinkInProgress = false;
+}
+
+/*
+ * Description:
+ * Turn on LED according to LedPin specified.
+ */
+static void SwLedOn(struct _adapter *padapter, struct LED_871x *pLed)
+{
+ u8 LedCfg;
+
+ if ((padapter->bSurpriseRemoved == true) ||
+ (padapter->bDriverStopped == true))
+ return;
+ LedCfg = r8712_read8(padapter, LEDCFG);
+ switch (pLed->LedPin) {
+ case LED_PIN_GPIO0:
+ break;
+ case LED_PIN_LED0:
+ /* SW control led0 on.*/
+ r8712_write8(padapter, LEDCFG, LedCfg&0xf0);
+ break;
+ case LED_PIN_LED1:
+ /* SW control led1 on.*/
+ r8712_write8(padapter, LEDCFG, LedCfg&0x0f);
+ break;
+ default:
+ break;
+ }
+ pLed->bLedOn = true;
+}
+
+/*
+ * Description:
+ * Turn off LED according to LedPin specified.
+ */
+static void SwLedOff(struct _adapter *padapter, struct LED_871x *pLed)
+{
+ u8 LedCfg;
+
+ if ((padapter->bSurpriseRemoved == true) ||
+ (padapter->bDriverStopped == true))
+ return;
+ LedCfg = r8712_read8(padapter, LEDCFG);
+ switch (pLed->LedPin) {
+ case LED_PIN_GPIO0:
+ break;
+ case LED_PIN_LED0:
+ LedCfg &= 0xf0; /* Set to software control.*/
+ r8712_write8(padapter, LEDCFG, (LedCfg|BIT(3)));
+ break;
+ case LED_PIN_LED1:
+ LedCfg &= 0x0f; /* Set to software control.*/
+ r8712_write8(padapter, LEDCFG, (LedCfg|BIT(7)));
+ break;
+ default:
+ break;
+ }
+ pLed->bLedOn = false;
+}
+
+/*===========================================================================
+ * Interface to manipulate LED objects.
+ *===========================================================================
+ *
+ * Description:
+ * Initialize all LED_871x objects.
+ */
+void r8712_InitSwLeds(struct _adapter *padapter)
+{
+ struct led_priv *pledpriv = &(padapter->ledpriv);
+
+ pledpriv->LedControlHandler = LedControl871x;
+ InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0);
+ InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1);
+}
+
+/* Description:
+ * DeInitialize all LED_819xUsb objects.
+ */
+void r8712_DeInitSwLeds(struct _adapter *padapter)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+
+ DeInitLed871x(&(ledpriv->SwLed0));
+ DeInitLed871x(&(ledpriv->SwLed1));
+}
+
+/* Description:
+ * Implementation of LED blinking behavior.
+ * It toggle off LED and schedule corresponding timer if necessary.
+ */
+static void SwLedBlink(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ /* Determine if we shall change LED state again. */
+ pLed->BlinkTimes--;
+ switch (pLed->CurrLedState) {
+ case LED_BLINK_NORMAL:
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ break;
+ case LED_BLINK_StartToBlink:
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) &&
+ (pmlmepriv->fw_state & WIFI_STATION_STATE))
+ bStopBlinking = true;
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) &&
+ ((pmlmepriv->fw_state & WIFI_ADHOC_STATE) ||
+ (pmlmepriv->fw_state & WIFI_ADHOC_MASTER_STATE)))
+ bStopBlinking = true;
+ else if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ break;
+ default:
+ bStopBlinking = true;
+ break;
+ }
+ if (bStopBlinking) {
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) &&
+ (pLed->bLedOn == false))
+ SwLedOn(padapter, pLed);
+ else if ((check_fwstate(pmlmepriv, _FW_LINKED) ==
+ true) && pLed->bLedOn == true)
+ SwLedOff(padapter, pLed);
+ pLed->BlinkTimes = 0;
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ /* Assign LED state to toggle. */
+ if (pLed->BlinkingLedState == LED_ON)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+
+ /* Schedule a timer to toggle LED state. */
+ switch (pLed->CurrLedState) {
+ case LED_BLINK_NORMAL:
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ break;
+ case LED_BLINK_SLOWLY:
+ case LED_BLINK_StartToBlink:
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->BlinkingLedState == LED_ON)
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LONG_INTERVAL);
+ else
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LONG_INTERVAL);
+ break;
+ default:
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ break;
+ }
+ }
+}
+
+static void SwLedBlink1(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct eeprom_priv *peeprompriv = &(padapter->eeprompriv);
+ struct LED_871x *pLed1 = &(ledpriv->SwLed1);
+ u8 bStopBlinking = false;
+
+ if (peeprompriv->CustomerID == RT_CID_819x_CAMEO)
+ pLed = &(ledpriv->SwLed1);
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ if (peeprompriv->CustomerID == RT_CID_DEFAULT) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ if (!pLed1->bSWLedCtrl) {
+ SwLedOn(padapter, pLed1);
+ pLed1->bSWLedCtrl = true;
+ } else if (!pLed1->bLedOn)
+ SwLedOn(padapter, pLed1);
+ } else {
+ if (!pLed1->bSWLedCtrl) {
+ SwLedOff(padapter, pLed1);
+ pLed1->bSWLedCtrl = true;
+ } else if (pLed1->bLedOn)
+ SwLedOff(padapter, pLed1);
+ }
+ }
+ switch (pLed->CurrLedState) {
+ case LED_BLINK_SLOWLY:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ break;
+ case LED_BLINK_NORMAL:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ break;
+ case LED_SCAN_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->bLedLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_NORMAL;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ }
+ pLed->bLedScanBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->bLedLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_NORMAL;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ }
+ pLed->BlinkTimes = 0;
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ break;
+ case LED_BLINK_WPS_STOP: /* WPS success */
+ if (pLed->BlinkingLedState == LED_ON) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+ bStopBlinking = false;
+ } else
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->bLedLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_NORMAL;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ }
+ pLed->bLedWPSBlinkInProgress = false;
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedBlink2(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ switch (pLed->CurrLedState) {
+ case LED_SCAN_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ SwLedOn(padapter, pLed);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ SwLedOff(padapter, pLed);
+ }
+ pLed->bLedScanBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ SwLedOn(padapter, pLed);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ SwLedOff(padapter, pLed);
+ }
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedBlink3(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ if (pLed->CurrLedState != LED_BLINK_WPS_STOP)
+ SwLedOff(padapter, pLed);
+ switch (pLed->CurrLedState) {
+ case LED_SCAN_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (!pLed->bLedOn)
+ SwLedOn(padapter, pLed);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedOn)
+ SwLedOff(padapter, pLed);
+ }
+ pLed->bLedScanBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (!pLed->bLedOn)
+ SwLedOn(padapter, pLed);
+ } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedOn)
+ SwLedOff(padapter, pLed);
+ }
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ break;
+ case LED_BLINK_WPS_STOP: /*WPS success*/
+ if (pLed->BlinkingLedState == LED_ON) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+ bStopBlinking = false;
+ } else
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ SwLedOn(padapter, pLed);
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedBlink4(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct LED_871x *pLed1 = &(ledpriv->SwLed1);
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ if (!pLed1->bLedWPSBlinkInProgress &&
+ pLed1->BlinkingLedState == LED_UNKNOWN) {
+ pLed1->BlinkingLedState = LED_OFF;
+ pLed1->CurrLedState = LED_OFF;
+ SwLedOff(padapter, pLed1);
+ }
+ switch (pLed->CurrLedState) {
+ case LED_BLINK_SLOWLY:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ break;
+ case LED_BLINK_StartToBlink:
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ }
+ break;
+ case LED_SCAN_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ pLed->bLedScanBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ }
+ break;
+ case LED_BLINK_WPS_STOP: /*WPS authentication fail*/
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+ break;
+ case LED_BLINK_WPS_STOP_OVERLAP: /*WPS session overlap */
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0) {
+ if (pLed->bLedOn)
+ pLed->BlinkTimes = 1;
+ else
+ bStopBlinking = true;
+ }
+ if (bStopBlinking) {
+ pLed->BlinkTimes = 10;
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedBlink5(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ switch (pLed->CurrLedState) {
+ case LED_SCAN_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (!pLed->bLedOn)
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ pLed->bLedScanBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (!pLed->bLedOn)
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedBlink6(struct LED_871x *pLed)
+{
+ struct _adapter *padapter = pLed->padapter;
+ u8 bStopBlinking = false;
+
+ /* Change LED according to BlinkingLedState specified. */
+ if (pLed->BlinkingLedState == LED_ON)
+ SwLedOn(padapter, pLed);
+ else
+ SwLedOff(padapter, pLed);
+ switch (pLed->CurrLedState) {
+ case LED_TXRX_BLINK:
+ pLed->BlinkTimes--;
+ if (pLed->BlinkTimes == 0)
+ bStopBlinking = true;
+ if (bStopBlinking) {
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (!pLed->bLedOn)
+ SwLedOn(padapter, pLed);
+ pLed->bLedBlinkInProgress = false;
+ } else {
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_BLINK_WPS:
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Description:
+ * Callback function of LED BlinkTimer,
+ * it just schedules to corresponding BlinkWorkItem.
+ */
+static void BlinkTimerCallback(unsigned long data)
+{
+ struct LED_871x *pLed = (struct LED_871x *)data;
+
+ /* This fixed the crash problem on Fedora 12 when trying to do thei
+ * insmod;ifconfig up;rmmod commands. */
+ if ((pLed->padapter->bSurpriseRemoved == true) ||
+ (pLed->padapter->bDriverStopped == true))
+ return;
+ _set_workitem(&(pLed->BlinkWorkItem));
+}
+
+/* Description:
+ * Callback function of LED BlinkWorkItem.
+ * We dispatch acture LED blink action according to LedStrategy.
+ */
+static void BlinkWorkItemCallback(struct work_struct *work)
+{
+ struct LED_871x *pLed = container_of(work, struct LED_871x,
+ BlinkWorkItem);
+ struct led_priv *ledpriv = &(pLed->padapter->ledpriv);
+
+ switch (ledpriv->LedStrategy) {
+ case SW_LED_MODE0:
+ SwLedBlink(pLed);
+ break;
+ case SW_LED_MODE1:
+ SwLedBlink1(pLed);
+ break;
+ case SW_LED_MODE2:
+ SwLedBlink2(pLed);
+ break;
+ case SW_LED_MODE3:
+ SwLedBlink3(pLed);
+ break;
+ case SW_LED_MODE4:
+ SwLedBlink4(pLed);
+ break;
+ case SW_LED_MODE5:
+ SwLedBlink5(pLed);
+ break;
+ case SW_LED_MODE6:
+ SwLedBlink6(pLed);
+ break;
+ default:
+ SwLedBlink(pLed);
+ break;
+ }
+}
+
+/*============================================================================
+ * Default LED behavior.
+ *============================================================================
+ *
+ * Description:
+ * Implement each led action for SW_LED_MODE0.
+ * This is default strategy.
+ */
+
+static void SwLedControlMode1(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct sitesurvey_ctrl *psitesurveyctrl = &(pmlmepriv->sitesurveyctrl);
+
+ if (padapter->eeprompriv.CustomerID == RT_CID_819x_CAMEO)
+ pLed = &(ledpriv->SwLed1);
+ switch (LedAction) {
+ case LED_CTL_START_TO_LINK:
+ case LED_CTL_NO_LINK:
+ if (pLed->bLedNoLinkBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_LINK:
+ if (pLed->bLedLinkBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_NORMAL;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_LINK_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_SITE_SURVEY:
+ if ((psitesurveyctrl->traffic_busy) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true))
+ ; /* dummy branch */
+ else if (pLed->bLedScanBlinkInProgress == false) {
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedScanBlinkInProgress = true;
+ pLed->CurrLedState = LED_SCAN_BLINK;
+ pLed->BlinkTimes = 24;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if (pLed->bLedBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+
+ case LED_CTL_START_WPS: /*wait until xinpin finish */
+ case LED_CTL_START_WPS_BOTTON:
+ if (pLed->bLedWPSBlinkInProgress == false) {
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_STOP_WPS:
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress)
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ else
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS_STOP;
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ break;
+ case LED_CTL_STOP_WPS_FAIL:
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedNoLinkBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedControlMode2(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+
+ switch (LedAction) {
+ case LED_CTL_SITE_SURVEY:
+ if (pmlmepriv->sitesurveyctrl.traffic_busy)
+ ; /* dummy branch */
+ else if (pLed->bLedScanBlinkInProgress == false) {
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedScanBlinkInProgress = true;
+ pLed->CurrLedState = LED_SCAN_BLINK;
+ pLed->BlinkTimes = 24;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if ((pLed->bLedBlinkInProgress == false) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+
+ case LED_CTL_LINK:
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+
+ case LED_CTL_START_WPS: /*wait until xinpin finish*/
+ case LED_CTL_START_WPS_BOTTON:
+ if (pLed->bLedWPSBlinkInProgress == false) {
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ break;
+
+ case LED_CTL_STOP_WPS:
+ pLed->bLedWPSBlinkInProgress = false;
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+
+ case LED_CTL_STOP_WPS_FAIL:
+ pLed->bLedWPSBlinkInProgress = false;
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+
+ case LED_CTL_START_TO_LINK:
+ case LED_CTL_NO_LINK:
+ if (!IS_LED_BLINKING(pLed)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedControlMode3(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+
+ switch (LedAction) {
+ case LED_CTL_SITE_SURVEY:
+ if (pmlmepriv->sitesurveyctrl.traffic_busy)
+ ; /* dummy branch */
+ else if (pLed->bLedScanBlinkInProgress == false) {
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedScanBlinkInProgress = true;
+ pLed->CurrLedState = LED_SCAN_BLINK;
+ pLed->BlinkTimes = 24;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if ((pLed->bLedBlinkInProgress == false) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_LINK:
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ case LED_CTL_START_WPS: /* wait until xinpin finish */
+ case LED_CTL_START_WPS_BOTTON:
+ if (pLed->bLedWPSBlinkInProgress == false) {
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_STOP_WPS:
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ } else
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS_STOP;
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ break;
+ case LED_CTL_STOP_WPS_FAIL:
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ case LED_CTL_START_TO_LINK:
+ case LED_CTL_NO_LINK:
+ if (!IS_LED_BLINKING(pLed)) {
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedControlMode4(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+ struct LED_871x *pLed1 = &(ledpriv->SwLed1);
+
+ switch (LedAction) {
+ case LED_CTL_START_TO_LINK:
+ if (pLed1->bLedWPSBlinkInProgress) {
+ pLed1->bLedWPSBlinkInProgress = false;
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ pLed1->BlinkingLedState = LED_OFF;
+ pLed1->CurrLedState = LED_OFF;
+ if (pLed1->bLedOn)
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ if (pLed->bLedStartToLinkBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ pLed->bLedStartToLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_StartToBlink;
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ }
+ }
+ break;
+ case LED_CTL_LINK:
+ case LED_CTL_NO_LINK:
+ /*LED1 settings*/
+ if (LedAction == LED_CTL_LINK) {
+ if (pLed1->bLedWPSBlinkInProgress) {
+ pLed1->bLedWPSBlinkInProgress = false;
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ pLed1->BlinkingLedState = LED_OFF;
+ pLed1->CurrLedState = LED_OFF;
+ if (pLed1->bLedOn)
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ }
+ if (pLed->bLedNoLinkBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_SITE_SURVEY:
+ if ((pmlmepriv->sitesurveyctrl.traffic_busy) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true))
+ ;
+ else if (pLed->bLedScanBlinkInProgress == false) {
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedScanBlinkInProgress = true;
+ pLed->CurrLedState = LED_SCAN_BLINK;
+ pLed->BlinkTimes = 24;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if (pLed->bLedBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK ||
+ IS_LED_WPS_BLINKING(pLed))
+ return;
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_START_WPS: /*wait until xinpin finish*/
+ case LED_CTL_START_WPS_BOTTON:
+ if (pLed1->bLedWPSBlinkInProgress) {
+ pLed1->bLedWPSBlinkInProgress = false;
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ pLed1->BlinkingLedState = LED_OFF;
+ pLed1->CurrLedState = LED_OFF;
+ if (pLed1->bLedOn)
+ _set_timer(&(pLed->BlinkTimer), 0);
+ }
+ if (pLed->bLedWPSBlinkInProgress == false) {
+ if (pLed->bLedNoLinkBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS;
+ if (pLed->bLedOn) {
+ pLed->BlinkingLedState = LED_OFF;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SLOWLY_INTERVAL);
+ } else {
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NORMAL_INTERVAL);
+ }
+ }
+ break;
+ case LED_CTL_STOP_WPS: /*WPS connect success*/
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ break;
+ case LED_CTL_STOP_WPS_FAIL: /*WPS authentication fail*/
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ /*LED1 settings*/
+ if (pLed1->bLedWPSBlinkInProgress)
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ else
+ pLed1->bLedWPSBlinkInProgress = true;
+ pLed1->CurrLedState = LED_BLINK_WPS_STOP;
+ if (pLed1->bLedOn)
+ pLed1->BlinkingLedState = LED_OFF;
+ else
+ pLed1->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+ break;
+ case LED_CTL_STOP_WPS_FAIL_OVERLAP: /*WPS session overlap*/
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->bLedNoLinkBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_SLOWLY;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+ /*LED1 settings*/
+ if (pLed1->bLedWPSBlinkInProgress)
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ else
+ pLed1->bLedWPSBlinkInProgress = true;
+ pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP;
+ pLed1->BlinkTimes = 10;
+ if (pLed1->bLedOn)
+ pLed1->BlinkingLedState = LED_OFF;
+ else
+ pLed1->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedNoLinkBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedNoLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedLinkBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedLinkBlinkInProgress = false;
+ }
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ if (pLed->bLedScanBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedScanBlinkInProgress = false;
+ }
+ if (pLed->bLedStartToLinkBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedStartToLinkBlinkInProgress = false;
+ }
+ if (pLed1->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed1->BlinkTimer));
+ pLed1->bLedWPSBlinkInProgress = false;
+ }
+ pLed1->BlinkingLedState = LED_UNKNOWN;
+ SwLedOff(padapter, pLed);
+ SwLedOff(padapter, pLed1);
+ break;
+ default:
+ break;
+ }
+}
+
+static void SwLedControlMode5(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+
+ if (padapter->eeprompriv.CustomerID == RT_CID_819x_CAMEO)
+ pLed = &(ledpriv->SwLed1);
+
+ switch (LedAction) {
+ case LED_CTL_POWER_ON:
+ case LED_CTL_NO_LINK:
+ case LED_CTL_LINK: /* solid blue */
+ if (pLed->CurrLedState == LED_SCAN_BLINK)
+ return;
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ pLed->bLedBlinkInProgress = false;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ case LED_CTL_SITE_SURVEY:
+ if ((pmlmepriv->sitesurveyctrl.traffic_busy) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true))
+ ; /* dummy branch */
+ else if (pLed->bLedScanBlinkInProgress == false) {
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedScanBlinkInProgress = true;
+ pLed->CurrLedState = LED_SCAN_BLINK;
+ pLed->BlinkTimes = 24;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if (pLed->bLedBlinkInProgress == false) {
+ if (pLed->CurrLedState == LED_SCAN_BLINK)
+ return;
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ SwLedOff(padapter, pLed);
+ break;
+ default:
+ break;
+ }
+}
+
+
+static void SwLedControlMode6(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct LED_871x *pLed = &(ledpriv->SwLed0);
+
+ switch (LedAction) {
+ case LED_CTL_POWER_ON:
+ case LED_CTL_NO_LINK:
+ case LED_CTL_LINK: /*solid blue*/
+ case LED_CTL_SITE_SURVEY:
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ pLed->bLedBlinkInProgress = false;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ case LED_CTL_TX:
+ case LED_CTL_RX:
+ if (pLed->bLedBlinkInProgress == false &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
+ if (IS_LED_WPS_BLINKING(pLed))
+ return;
+ pLed->bLedBlinkInProgress = true;
+ pLed->CurrLedState = LED_TXRX_BLINK;
+ pLed->BlinkTimes = 2;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_FASTER_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_START_WPS: /*wait until xinpin finish*/
+ case LED_CTL_START_WPS_BOTTON:
+ if (pLed->bLedWPSBlinkInProgress == false) {
+ if (pLed->bLedBlinkInProgress == true) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ pLed->bLedWPSBlinkInProgress = true;
+ pLed->CurrLedState = LED_BLINK_WPS;
+ if (pLed->bLedOn)
+ pLed->BlinkingLedState = LED_OFF;
+ else
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer),
+ LED_BLINK_SCAN_INTERVAL_ALPHA);
+ }
+ break;
+ case LED_CTL_STOP_WPS_FAIL:
+ case LED_CTL_STOP_WPS:
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ pLed->CurrLedState = LED_ON;
+ pLed->BlinkingLedState = LED_ON;
+ _set_timer(&(pLed->BlinkTimer), 0);
+ break;
+ case LED_CTL_POWER_OFF:
+ pLed->CurrLedState = LED_OFF;
+ pLed->BlinkingLedState = LED_OFF;
+ if (pLed->bLedBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedBlinkInProgress = false;
+ }
+ if (pLed->bLedWPSBlinkInProgress) {
+ _cancel_timer_ex(&(pLed->BlinkTimer));
+ pLed->bLedWPSBlinkInProgress = false;
+ }
+ SwLedOff(padapter, pLed);
+ break;
+ default:
+ break;
+ }
+}
+
+/* Description:
+ * Dispatch LED action according to pHalData->LedStrategy.
+ */
+void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction)
+{
+ struct led_priv *ledpriv = &(padapter->ledpriv);
+
+ if (ledpriv == NULL || ledpriv->bRegUseLed == false)
+ return;
+ switch (ledpriv->LedStrategy) {
+ case SW_LED_MODE0:
+ break;
+ case SW_LED_MODE1:
+ SwLedControlMode1(padapter, LedAction);
+ break;
+ case SW_LED_MODE2:
+ SwLedControlMode2(padapter, LedAction);
+ break;
+ case SW_LED_MODE3:
+ SwLedControlMode3(padapter, LedAction);
+ break;
+ case SW_LED_MODE4:
+ SwLedControlMode4(padapter, LedAction);
+ break;
+ case SW_LED_MODE5:
+ SwLedControlMode5(padapter, LedAction);
+ break;
+ case SW_LED_MODE6:
+ SwLedControlMode6(padapter, LedAction);
+ break;
+ default:
+ break;
+ }
+}
diff --git a/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h b/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h
new file mode 100644
index 000000000000..74800cd2340d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h
@@ -0,0 +1,28 @@
+#ifndef __RTL8712_MACSETTING_BITDEF_H__
+#define __RTL8712_MACSETTING_BITDEF_H__
+
+
+/*MACID*/
+/*BSSID*/
+
+/*HWVID*/
+#define _HWVID_MSK 0x0F
+
+/*MAR*/
+/*MBIDCANCONTENT*/
+
+/*MBIDCANCFG*/
+#define _POOLING BIT(31)
+#define _WRITE_EN BIT(16)
+#define _CAM_ADDR_MSK 0x001F
+#define _CAM_ADDR_SHT 0
+
+/*BUILDTIME*/
+#define _BUILDTIME_MSK 0x3FFFFFFF
+
+/*BUILDUSER*/
+
+
+
+#endif /* __RTL8712_MACSETTING_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h b/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h
new file mode 100644
index 000000000000..00b003bd6900
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_macsetting_regdef.h
@@ -0,0 +1,16 @@
+#ifndef __RTL8712_MACSETTING_REGDEF_H__
+#define __RTL8712_MACSETTING_REGDEF_H__
+
+#define MACID (RTL8712_MACIDSETTING_ + 0x0000)
+#define BSSIDR (RTL8712_MACIDSETTING_ + 0x0008)
+#define HWVID (RTL8712_MACIDSETTING_ + 0x000E)
+#define MAR (RTL8712_MACIDSETTING_ + 0x0010)
+#define MBIDCANCONTENT (RTL8712_MACIDSETTING_ + 0x0018)
+#define MBIDCANCFG (RTL8712_MACIDSETTING_ + 0x0020)
+#define BUILDTIME (RTL8712_MACIDSETTING_ + 0x0024)
+#define BUILDUSER (RTL8712_MACIDSETTING_ + 0x0028)
+
+
+
+#endif /*__RTL8712_MACSETTING_REGDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h b/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h
new file mode 100644
index 000000000000..0922a8dc1322
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_powersave_bitdef.h
@@ -0,0 +1,33 @@
+#ifndef __RTL8712_POWERSAVE_BITDEF_H__
+#define __RTL8712_POWERSAVE_BITDEF_H__
+
+/*WOWCTRL*/
+#define _UWF BIT(3)
+#define _MAGIC BIT(2)
+#define _WOW_EN BIT(1)
+#define _PMEN BIT(0)
+
+/*PSSTATUS*/
+#define _PSSTATUS_SEL_MSK 0x0F
+
+/*PSSWITCH*/
+#define _PSSWITCH_ACT BIT(7)
+#define _PSSWITCH_SEL_MSK 0x0F
+#define _PSSWITCH_SEL_SHT 0
+
+/*LPNAV_CTRL*/
+#define _LPNAV_EN BIT(31)
+#define _LPNAV_EARLY_MSK 0x7FFF0000
+#define _LPNAV_EARLY_SHT 16
+#define _LPNAV_TH_MSK 0x0000FFFF
+#define _LPNAV_TH_SHT 0
+
+/*RPWM*/
+/*CPWM*/
+#define _TOGGLING BIT(7)
+#define _WWLAN BIT(3)
+#define _RPS_ST BIT(2)
+#define _WLAN_TRX BIT(1)
+#define _SYS_CLK BIT(0)
+
+#endif /* __RTL8712_POWERSAVE_BITDEF_H__*/
diff --git a/drivers/staging/rtl8712/rtl8712_powersave_regdef.h b/drivers/staging/rtl8712/rtl8712_powersave_regdef.h
new file mode 100644
index 000000000000..72927df3db24
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_powersave_regdef.h
@@ -0,0 +1,20 @@
+#ifndef __RTL8712_POWERSAVE_REGDEF_H__
+#define __RTL8712_POWERSAVE_REGDEF_H__
+
+#define WOWCTRL (RTL8712_POWERSAVE_ + 0x00)
+#define PSSTATUS (RTL8712_POWERSAVE_ + 0x01)
+#define PSSWITCH (RTL8712_POWERSAVE_ + 0x02)
+#define MIMOPS_WAITPERIOD (RTL8712_POWERSAVE_ + 0x03)
+#define LPNAV_CTRL (RTL8712_POWERSAVE_ + 0x04)
+#define WFM0 (RTL8712_POWERSAVE_ + 0x10)
+#define WFM1 (RTL8712_POWERSAVE_ + 0x20)
+#define WFM2 (RTL8712_POWERSAVE_ + 0x30)
+#define WFM3 (RTL8712_POWERSAVE_ + 0x40)
+#define WFM4 (RTL8712_POWERSAVE_ + 0x50)
+#define WFM5 (RTL8712_POWERSAVE_ + 0x60)
+#define WFCRC (RTL8712_POWERSAVE_ + 0x70)
+#define RPWM (RTL8712_POWERSAVE_ + 0x7C)
+#define CPWM (RTL8712_POWERSAVE_ + 0x7D)
+
+#endif /* __RTL8712_POWERSAVE_REGDEF_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h
new file mode 100644
index 000000000000..87048b3fe04f
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h
@@ -0,0 +1,30 @@
+#ifndef __RTL8712_RATECTRL_BITDEF_H__
+#define __RTL8712_RATECTRL_BITDEF_H__
+
+/*INIRTSMCS_SEL*/
+#define _INIRTSMCS_SEL_MSK 0x3F
+
+/* RRSR*/
+#define _RRSR_SHORT BIT(23)
+#define _RRSR_RSC_MSK 0x600000
+#define _RRSR_RSC_SHT 21
+#define _RRSR_BITMAP_MSK 0x0FFFFF
+#define _RRSR_BITMAP_SHT 0
+
+/* AGGLEN_LMT_H*/
+#define _AGGLMT_MCS32_MSK 0xF0
+#define _AGGLMT_MCS32_SHT 4
+#define _AGGLMT_MCS15_SGI_MSK 0x0F
+#define _AGGLMT_MCS15_SGI_SHT 0
+
+/* DARFRC*/
+/* RARFRC*/
+/* MCS_TXAGC*/
+/* CCK_TXAGC*/
+#define _CCK_MSK 0xFF00
+#define _CCK_SHT 8
+#define _BARKER_MSK 0x00FF
+#define _BARKER_SHT 0
+
+#endif /* __RTL8712_RATECTRL_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h
new file mode 100644
index 000000000000..31c8363e5bc6
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h
@@ -0,0 +1,31 @@
+#ifndef __RTL8712_RATECTRL_REGDEF_H__
+#define __RTL8712_RATECTRL_REGDEF_H__
+
+#define INIMCS_SEL (RTL8712_RATECTRL_ + 0x00)
+#define INIRTSMCS_SEL (RTL8712_RATECTRL_ + 0x20)
+#define RRSR (RTL8712_RATECTRL_ + 0x21)
+#define ARFR0 (RTL8712_RATECTRL_ + 0x24)
+#define ARFR1 (RTL8712_RATECTRL_ + 0x28)
+#define ARFR2 (RTL8712_RATECTRL_ + 0x2C)
+#define ARFR3 (RTL8712_RATECTRL_ + 0x30)
+#define ARFR4 (RTL8712_RATECTRL_ + 0x34)
+#define ARFR5 (RTL8712_RATECTRL_ + 0x38)
+#define ARFR6 (RTL8712_RATECTRL_ + 0x3C)
+#define ARFR7 (RTL8712_RATECTRL_ + 0x40)
+#define AGGLEN_LMT_H (RTL8712_RATECTRL_ + 0x47)
+#define AGGLEN_LMT_L (RTL8712_RATECTRL_ + 0x48)
+#define DARFRC (RTL8712_RATECTRL_ + 0x50)
+#define RARFRC (RTL8712_RATECTRL_ + 0x58)
+#define MCS_TXAGC0 (RTL8712_RATECTRL_ + 0x60)
+#define MCS_TXAGC1 (RTL8712_RATECTRL_ + 0x61)
+#define MCS_TXAGC2 (RTL8712_RATECTRL_ + 0x62)
+#define MCS_TXAGC3 (RTL8712_RATECTRL_ + 0x63)
+#define MCS_TXAGC4 (RTL8712_RATECTRL_ + 0x64)
+#define MCS_TXAGC5 (RTL8712_RATECTRL_ + 0x65)
+#define MCS_TXAGC6 (RTL8712_RATECTRL_ + 0x66)
+#define MCS_TXAGC7 (RTL8712_RATECTRL_ + 0x67)
+#define CCK_TXAGC (RTL8712_RATECTRL_ + 0x68)
+
+
+#endif /*__RTL8712_RATECTRL_REGDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
new file mode 100644
index 000000000000..569e14b599b4
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -0,0 +1,1131 @@
+/******************************************************************************
+ * rtl8712_recv.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL8712_RECV_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "mlme_osdep.h"
+#include "ip.h"
+#include "if_ether.h"
+#include "ethernet.h"
+#include "usb_ops.h"
+#include "wifi.h"
+
+/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
+static u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
+
+/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+static u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
+
+static void recv_tasklet(void *priv);
+
+int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter)
+{
+ int i;
+ struct recv_buf *precvbuf;
+ int res = _SUCCESS;
+ addr_t tmpaddr = 0;
+ int alignment = 0;
+ struct sk_buff *pskb = NULL;
+
+ sema_init(&precvpriv->recv_sema, 0);
+ sema_init(&precvpriv->terminate_recvthread_sema, 0);
+ /*init recv_buf*/
+ _init_queue(&precvpriv->free_recv_buf_queue);
+ precvpriv->pallocated_recv_buf = _malloc(NR_RECVBUFF *
+ sizeof(struct recv_buf) + 4);
+ if (precvpriv->pallocated_recv_buf == NULL)
+ return _FAIL;
+ memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF *
+ sizeof(struct recv_buf) + 4);
+ precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 -
+ ((addr_t) (precvpriv->pallocated_recv_buf) & 3);
+ precvbuf = (struct recv_buf *)precvpriv->precv_buf;
+ for (i = 0; i < NR_RECVBUFF; i++) {
+ _init_listhead(&precvbuf->list);
+ spin_lock_init(&precvbuf->recvbuf_lock);
+ res = r8712_os_recvbuf_resource_alloc(padapter, precvbuf);
+ if (res == _FAIL)
+ break;
+ precvbuf->ref_cnt = 0;
+ precvbuf->adapter = padapter;
+ list_insert_tail(&precvbuf->list,
+ &(precvpriv->free_recv_buf_queue.queue));
+ precvbuf++;
+ }
+ precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF;
+ tasklet_init(&precvpriv->recv_tasklet,
+ (void(*)(unsigned long))recv_tasklet,
+ (unsigned long)padapter);
+ skb_queue_head_init(&precvpriv->rx_skb_queue);
+
+ skb_queue_head_init(&precvpriv->free_recv_skb_queue);
+ for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) {
+ pskb = netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ +
+ RECVBUFF_ALIGN_SZ);
+ if (pskb) {
+ pskb->dev = padapter->pnetdev;
+ tmpaddr = (addr_t)pskb->data;
+ alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
+ skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
+ skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
+ }
+ pskb = NULL;
+ }
+ return res;
+}
+
+void r8712_free_recv_priv(struct recv_priv *precvpriv)
+{
+ int i;
+ struct recv_buf *precvbuf;
+ struct _adapter *padapter = precvpriv->adapter;
+
+ precvbuf = (struct recv_buf *)precvpriv->precv_buf;
+ for (i = 0; i < NR_RECVBUFF ; i++) {
+ r8712_os_recvbuf_resource_free(padapter, precvbuf);
+ precvbuf++;
+ }
+ kfree(precvpriv->pallocated_recv_buf);
+ skb_queue_purge(&precvpriv->rx_skb_queue);
+ if (skb_queue_len(&precvpriv->rx_skb_queue))
+ printk(KERN_WARNING "r8712u: rx_skb_queue not empty\n");
+ skb_queue_purge(&precvpriv->free_recv_skb_queue);
+ if (skb_queue_len(&precvpriv->free_recv_skb_queue))
+ printk(KERN_WARNING "r8712u: free_recv_skb_queue not empty "
+ "%d\n", skb_queue_len(&precvpriv->free_recv_skb_queue));
+}
+
+int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf)
+{
+ int res = _SUCCESS;
+
+ precvbuf->transfer_len = 0;
+ precvbuf->len = 0;
+ precvbuf->ref_cnt = 0;
+ if (precvbuf->pbuf) {
+ precvbuf->pdata = precvbuf->pbuf;
+ precvbuf->phead = precvbuf->pbuf;
+ precvbuf->ptail = precvbuf->pbuf;
+ precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ;
+ }
+ return res;
+}
+
+int r8712_free_recvframe(union recv_frame *precvframe,
+ struct __queue *pfree_recv_queue)
+{
+ unsigned long irqL;
+ struct _adapter *padapter = precvframe->u.hdr.adapter;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+
+ if (precvframe->u.hdr.pkt) {
+ dev_kfree_skb_any(precvframe->u.hdr.pkt);/*free skb by driver*/
+ precvframe->u.hdr.pkt = NULL;
+ }
+ spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
+ list_delete(&(precvframe->u.hdr.list));
+ list_insert_tail(&(precvframe->u.hdr.list),
+ get_list_head(pfree_recv_queue));
+ if (padapter != NULL) {
+ if (pfree_recv_queue == &precvpriv->free_recv_queue)
+ precvpriv->free_recvframe_cnt++;
+ }
+ spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
+ return _SUCCESS;
+}
+
+static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
+ struct recv_stat *prxstat)
+{
+ u32 *pphy_info;
+ struct phy_stat *pphy_stat;
+ u16 drvinfo_sz = 0;
+
+ drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16;
+ drvinfo_sz = drvinfo_sz<<3;
+ /*TODO:
+ * Offset 0 */
+ pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27)
+ ? 0 : 1;
+ pattrib->crc_err = ((le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14);
+ /*Offset 4*/
+ /*Offset 8*/
+ /*Offset 12*/
+ if (le32_to_cpu(prxstat->rxdw3) & BIT(13)) {
+ pattrib->tcpchk_valid = 1; /* valid */
+ if (le32_to_cpu(prxstat->rxdw3) & BIT(11))
+ pattrib->tcp_chkrpt = 1; /* correct */
+ else
+ pattrib->tcp_chkrpt = 0; /* incorrect */
+ if (le32_to_cpu(prxstat->rxdw3) & BIT(12))
+ pattrib->ip_chkrpt = 1; /* correct */
+ else
+ pattrib->ip_chkrpt = 0; /* incorrect */
+ } else
+ pattrib->tcpchk_valid = 0; /* invalid */
+ pattrib->mcs_rate = (u8)((le32_to_cpu(prxstat->rxdw3)) & 0x3f);
+ pattrib->htc = (u8)((le32_to_cpu(prxstat->rxdw3) >> 6) & 0x1);
+ /*Offset 16*/
+ /*Offset 20*/
+ /*phy_info*/
+ if (drvinfo_sz) {
+ pphy_stat = (struct phy_stat *)(prxstat+1);
+ pphy_info = (u32 *)prxstat+1;
+ }
+}
+
+/*perform defrag*/
+static union recv_frame *recvframe_defrag(struct _adapter *adapter,
+ struct __queue *defrag_q)
+{
+ struct list_head *plist, *phead;
+ u8 wlanhdr_offset;
+ u8 curfragnum;
+ struct recv_frame_hdr *pfhdr, *pnfhdr;
+ union recv_frame *prframe, *pnextrframe;
+ struct __queue *pfree_recv_queue;
+
+ pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
+ phead = get_list_head(defrag_q);
+ plist = get_next(phead);
+ prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ list_delete(&prframe->u.list);
+ pfhdr = &prframe->u.hdr;
+ curfragnum = 0;
+ if (curfragnum != pfhdr->attrib.frag_num) {
+ /*the first fragment number must be 0
+ *free the whole queue*/
+ r8712_free_recvframe(prframe, pfree_recv_queue);
+ prframe = NULL;
+ goto exit;
+ }
+ plist = get_next(phead);
+ while (end_of_queue_search(phead, plist) == false) {
+ pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ /*check the fragment sequence (2nd ~n fragment frame) */
+ pnfhdr = &pnextrframe->u.hdr;
+ curfragnum++;
+ if (curfragnum != pnfhdr->attrib.frag_num) {
+ /* the fragment number must increase (after decache)
+ * release the defrag_q & prframe */
+ r8712_free_recvframe(prframe, pfree_recv_queue);
+ prframe = NULL;
+ goto exit;
+ }
+ /* copy the 2nd~n fragment frame's payload to the first fragment
+ * get the 2nd~last fragment frame's payload */
+ wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len;
+ recvframe_pull(pnextrframe, wlanhdr_offset);
+ /* append to first fragment frame's tail (if privacy frame,
+ * pull the ICV) */
+ recvframe_pull_tail(prframe, pfhdr->attrib.icv_len);
+ memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len);
+ recvframe_put(prframe, pnfhdr->len);
+ pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len;
+ plist = get_next(plist);
+ };
+exit:
+ /* free the defrag_q queue and return the prframe */
+ r8712_free_recvframe_queue(defrag_q, pfree_recv_queue);
+ return prframe;
+}
+
+/* check if need to defrag, if needed queue the frame to defrag_q */
+union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *padapter,
+ union recv_frame *precv_frame)
+{
+ u8 ismfrag;
+ u8 fragnum;
+ u8 *psta_addr;
+ struct recv_frame_hdr *pfhdr;
+ struct sta_info *psta;
+ struct sta_priv *pstapriv ;
+ struct list_head *phead;
+ union recv_frame *prtnframe = NULL;
+ struct __queue *pfree_recv_queue, *pdefrag_q;
+
+ pstapriv = &padapter->stapriv;
+ pfhdr = &precv_frame->u.hdr;
+ pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
+ /* need to define struct of wlan header frame ctrl */
+ ismfrag = pfhdr->attrib.mfrag;
+ fragnum = pfhdr->attrib.frag_num;
+ psta_addr = pfhdr->attrib.ta;
+ psta = r8712_get_stainfo(pstapriv, psta_addr);
+ if (psta == NULL)
+ pdefrag_q = NULL;
+ else
+ pdefrag_q = &psta->sta_recvpriv.defrag_q;
+
+ if ((ismfrag == 0) && (fragnum == 0))
+ prtnframe = precv_frame;/*isn't a fragment frame*/
+ if (ismfrag == 1) {
+ /* 0~(n-1) fragment frame
+ * enqueue to defraf_g */
+ if (pdefrag_q != NULL) {
+ if (fragnum == 0) {
+ /*the first fragment*/
+ if (_queue_empty(pdefrag_q) == false) {
+ /*free current defrag_q */
+ r8712_free_recvframe_queue(pdefrag_q,
+ pfree_recv_queue);
+ }
+ }
+ /* Then enqueue the 0~(n-1) fragment to the defrag_q */
+ phead = get_list_head(pdefrag_q);
+ list_insert_tail(&pfhdr->list, phead);
+ prtnframe = NULL;
+ } else {
+ /* can't find this ta's defrag_queue, so free this
+ * recv_frame */
+ r8712_free_recvframe(precv_frame, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+
+ }
+ if ((ismfrag == 0) && (fragnum != 0)) {
+ /* the last fragment frame
+ * enqueue the last fragment */
+ if (pdefrag_q != NULL) {
+ phead = get_list_head(pdefrag_q);
+ list_insert_tail(&pfhdr->list, phead);
+ /*call recvframe_defrag to defrag*/
+ precv_frame = recvframe_defrag(padapter, pdefrag_q);
+ prtnframe = precv_frame;
+ } else {
+ /* can't find this ta's defrag_queue, so free this
+ * recv_frame */
+ r8712_free_recvframe(precv_frame, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+ }
+ if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) {
+ /* after defrag we must check tkip mic code */
+ if (r8712_recvframe_chkmic(padapter, prtnframe) == _FAIL) {
+ r8712_free_recvframe(prtnframe, pfree_recv_queue);
+ prtnframe = NULL;
+ }
+ }
+ return prtnframe;
+}
+
+static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe)
+{
+ int a_len, padding_len;
+ u16 eth_type, nSubframe_Length;
+ u8 nr_subframes, i;
+ unsigned char *data_ptr, *pdata;
+ struct rx_pkt_attrib *pattrib;
+ _pkt *sub_skb, *subframes[MAX_SUBFRAME_COUNT];
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+ struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue);
+ int ret = _SUCCESS;
+
+ nr_subframes = 0;
+ pattrib = &prframe->u.hdr.attrib;
+ recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen);
+ if (prframe->u.hdr.attrib.iv_len > 0)
+ recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len);
+ a_len = prframe->u.hdr.len;
+ pdata = prframe->u.hdr.rx_data;
+ while (a_len > ETH_HLEN) {
+ /* Offset 12 denote 2 mac address */
+ nSubframe_Length = *((u16 *)(pdata + 12));
+ /*==m==>change the length order*/
+ nSubframe_Length = (nSubframe_Length >> 8) +
+ (nSubframe_Length << 8);
+ if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
+ printk(KERN_WARNING "r8712u: nRemain_Length is %d and"
+ " nSubframe_Length is: %d\n",
+ a_len, nSubframe_Length);
+ goto exit;
+ }
+ /* move the data point to data content */
+ pdata += ETH_HLEN;
+ a_len -= ETH_HLEN;
+ /* Allocate new skb for releasing to upper layer */
+ sub_skb = dev_alloc_skb(nSubframe_Length + 12);
+ skb_reserve(sub_skb, 12);
+ data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
+ memcpy(data_ptr, pdata, nSubframe_Length);
+ subframes[nr_subframes++] = sub_skb;
+ if (nr_subframes >= MAX_SUBFRAME_COUNT) {
+ printk(KERN_WARNING "r8712u: ParseSubframe(): Too"
+ " many Subframes! Packets dropped!\n");
+ break;
+ }
+ pdata += nSubframe_Length;
+ a_len -= nSubframe_Length;
+ if (a_len != 0) {
+ padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & 3);
+ if (padding_len == 4)
+ padding_len = 0;
+ if (a_len < padding_len)
+ goto exit;
+ pdata += padding_len;
+ a_len -= padding_len;
+ }
+ }
+ for (i = 0; i < nr_subframes; i++) {
+ sub_skb = subframes[i];
+ /* convert hdr + possible LLC headers into Ethernet header */
+ eth_type = (sub_skb->data[6] << 8) | sub_skb->data[7];
+ if (sub_skb->len >= 8 &&
+ ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) &&
+ eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) ||
+ !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) {
+ /* remove RFC1042 or Bridge-Tunnel encapsulation and
+ * replace EtherType */
+ skb_pull(sub_skb, SNAP_SIZE);
+ memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src,
+ ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst,
+ ETH_ALEN);
+ } else {
+ u16 len;
+ /* Leave Ethernet header part of hdr and full payload */
+ len = htons(sub_skb->len);
+ memcpy(skb_push(sub_skb, 2), &len, 2);
+ memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src,
+ ETH_ALEN);
+ memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst,
+ ETH_ALEN);
+ }
+ /* Indicate the packets to upper layer */
+ if (sub_skb) {
+ sub_skb->protocol =
+ eth_type_trans(sub_skb, padapter->pnetdev);
+ sub_skb->dev = padapter->pnetdev;
+ if ((pattrib->tcpchk_valid == 1) &&
+ (pattrib->tcp_chkrpt == 1)) {
+ sub_skb->ip_summed = CHECKSUM_UNNECESSARY;
+ } else
+ sub_skb->ip_summed = CHECKSUM_NONE;
+ netif_rx(sub_skb);
+ }
+ }
+exit:
+ prframe->u.hdr.len = 0;
+ r8712_free_recvframe(prframe, pfree_recv_queue);
+ return ret;
+}
+
+void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
+{
+ uint voffset;
+ u8 *poffset;
+ u16 pkt_len, cmd_len, drvinfo_sz;
+ u8 eid, cmd_seq;
+ struct recv_stat *prxstat;
+
+ poffset = (u8 *)prxcmdbuf;
+ voffset = *(uint *)poffset;
+ pkt_len = le32_to_cpu(voffset) & 0x00003fff;
+ prxstat = (struct recv_stat *)prxcmdbuf;
+ drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16);
+ drvinfo_sz = drvinfo_sz << 3;
+ poffset += RXDESC_SIZE + drvinfo_sz;
+ do {
+ voffset = *(uint *)poffset;
+ cmd_len = (u16)(le32_to_cpu(voffset) & 0xffff);
+ cmd_seq = (u8)((le32_to_cpu(voffset) >> 24) & 0x7f);
+ eid = (u8)((le32_to_cpu(voffset) >> 16) & 0xff);
+ r8712_event_handle(padapter, (uint *)poffset);
+ poffset += (cmd_len + 8);/*8 bytes aligment*/
+ } while (le32_to_cpu(voffset) & BIT(31));
+
+}
+
+static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl,
+ u16 seq_num)
+{
+ u8 wsize = preorder_ctrl->wsize_b;
+ u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) % 4096;
+
+ /* Rx Reorder initialize condition.*/
+ if (preorder_ctrl->indicate_seq == 0xffff)
+ preorder_ctrl->indicate_seq = seq_num;
+ /* Drop out the packet which SeqNum is smaller than WinStart */
+ if (SN_LESS(seq_num, preorder_ctrl->indicate_seq))
+ return false;
+ /*
+ * Sliding window manipulation. Conditions includes:
+ * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
+ * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
+ */
+ if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq))
+ preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq +
+ 1) % 4096;
+ else if (SN_LESS(wend, seq_num)) {
+ if (seq_num >= (wsize - 1))
+ preorder_ctrl->indicate_seq = seq_num + 1 - wsize;
+ else
+ preorder_ctrl->indicate_seq = 4095 - (wsize -
+ (seq_num + 1)) + 1;
+ }
+ return true;
+}
+
+static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
+ union recv_frame *prframe)
+{
+ struct list_head *phead, *plist;
+ union recv_frame *pnextrframe;
+ struct rx_pkt_attrib *pnextattrib;
+ struct __queue *ppending_recvframe_queue =
+ &preorder_ctrl->pending_recvframe_queue;
+ struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
+
+ phead = get_list_head(ppending_recvframe_queue);
+ plist = get_next(phead);
+ while (end_of_queue_search(phead, plist) == false) {
+ pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ pnextattrib = &pnextrframe->u.hdr.attrib;
+ if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
+ plist = get_next(plist);
+ else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num))
+ return false;
+ else
+ break;
+ }
+ list_delete(&(prframe->u.hdr.list));
+ list_insert_tail(&(prframe->u.hdr.list), plist);
+ return true;
+}
+
+int r8712_recv_indicatepkts_in_order(struct _adapter *padapter,
+ struct recv_reorder_ctrl *preorder_ctrl,
+ int bforced)
+{
+ struct list_head *phead, *plist;
+ union recv_frame *prframe;
+ struct rx_pkt_attrib *pattrib;
+ int bPktInBuf = false;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+ struct __queue *ppending_recvframe_queue =
+ &preorder_ctrl->pending_recvframe_queue;
+
+ phead = get_list_head(ppending_recvframe_queue);
+ plist = get_next(phead);
+ /* Handling some condition for forced indicate case.*/
+ if (bforced == true) {
+ if (is_list_empty(phead))
+ return true;
+ else {
+ prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ pattrib = &prframe->u.hdr.attrib;
+ preorder_ctrl->indicate_seq = pattrib->seq_num;
+ }
+ }
+ /* Prepare indication list and indication.
+ * Check if there is any packet need indicate. */
+ while (!is_list_empty(phead)) {
+ prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ pattrib = &prframe->u.hdr.attrib;
+ if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
+ plist = get_next(plist);
+ list_delete(&(prframe->u.hdr.list));
+ if (SN_EQUAL(preorder_ctrl->indicate_seq,
+ pattrib->seq_num))
+ preorder_ctrl->indicate_seq =
+ (preorder_ctrl->indicate_seq + 1) % 4096;
+ /*indicate this recv_frame*/
+ if (!pattrib->amsdu) {
+ if ((padapter->bDriverStopped == false) &&
+ (padapter->bSurpriseRemoved == false)) {
+ /* indicate this recv_frame */
+ r8712_recv_indicatepkt(padapter,
+ prframe);
+ }
+ } else if (pattrib->amsdu == 1) {
+ if (amsdu_to_msdu(padapter, prframe) !=
+ _SUCCESS)
+ r8712_free_recvframe(prframe,
+ &precvpriv->free_recv_queue);
+ }
+ /* Update local variables. */
+ bPktInBuf = false;
+ } else {
+ bPktInBuf = true;
+ break;
+ }
+ }
+ return bPktInBuf;
+}
+
+static int recv_indicatepkt_reorder(struct _adapter *padapter,
+ union recv_frame *prframe)
+{
+ unsigned long irql;
+ struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
+ struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl;
+ struct __queue *ppending_recvframe_queue =
+ &preorder_ctrl->pending_recvframe_queue;
+
+ if (!pattrib->amsdu) {
+ /* s1. */
+ r8712_wlanhdr_to_ethhdr(prframe);
+ if (pattrib->qos != 1) {
+ if ((padapter->bDriverStopped == false) &&
+ (padapter->bSurpriseRemoved == false)) {
+ r8712_recv_indicatepkt(padapter, prframe);
+ return _SUCCESS;
+ } else
+ return _FAIL;
+ }
+ }
+ spin_lock_irqsave(&ppending_recvframe_queue->lock, irql);
+ /*s2. check if winstart_b(indicate_seq) needs to been updated*/
+ if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num))
+ goto _err_exit;
+ /*s3. Insert all packet into Reorder Queue to maintain its ordering.*/
+ if (!enqueue_reorder_recvframe(preorder_ctrl, prframe))
+ goto _err_exit;
+ /*s4.
+ * Indication process.
+ * After Packet dropping and Sliding Window shifting as above, we can
+ * now just indicate the packets with the SeqNum smaller than latest
+ * WinStart and buffer other packets.
+ *
+ * For Rx Reorder condition:
+ * 1. All packets with SeqNum smaller than WinStart => Indicate
+ * 2. All packets with SeqNum larger than or equal to
+ * WinStart => Buffer it.
+ */
+ if (r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, false) ==
+ true) {
+ _set_timer(&preorder_ctrl->reordering_ctrl_timer,
+ REORDER_WAIT_TIME);
+ spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
+ } else {
+ spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
+ _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
+ }
+ return _SUCCESS;
+_err_exit:
+ spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
+ return _FAIL;
+}
+
+void r8712_reordering_ctrl_timeout_handler(void *pcontext)
+{
+ unsigned long irql;
+ struct recv_reorder_ctrl *preorder_ctrl =
+ (struct recv_reorder_ctrl *)pcontext;
+ struct _adapter *padapter = preorder_ctrl->padapter;
+ struct __queue *ppending_recvframe_queue =
+ &preorder_ctrl->pending_recvframe_queue;
+
+ if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
+ return;
+ spin_lock_irqsave(&ppending_recvframe_queue->lock, irql);
+ r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, true);
+ spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
+}
+
+static int r8712_process_recv_indicatepkts(struct _adapter *padapter,
+ union recv_frame *prframe)
+{
+ int retval = _SUCCESS;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+
+ if (phtpriv->ht_option == 1) { /*B/G/N Mode*/
+ if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) {
+ /* including perform A-MPDU Rx Ordering Buffer Control*/
+ if ((padapter->bDriverStopped == false) &&
+ (padapter->bSurpriseRemoved == false))
+ return _FAIL;
+ }
+ } else { /*B/G mode*/
+ retval = r8712_wlanhdr_to_ethhdr(prframe);
+ if (retval != _SUCCESS)
+ return retval;
+ if ((padapter->bDriverStopped == false) &&
+ (padapter->bSurpriseRemoved == false)) {
+ /* indicate this recv_frame */
+ r8712_recv_indicatepkt(padapter, prframe);
+ } else
+ return _FAIL;
+ }
+ return retval;
+}
+
+static u8 query_rx_pwr_percentage(s8 antpower)
+{
+ if ((antpower <= -100) || (antpower >= 20))
+ return 0;
+ else if (antpower >= 0)
+ return 100;
+ else
+ return 100 + antpower;
+}
+
+static u8 evm_db2percentage(s8 value)
+{
+ /*
+ * -33dB~0dB to 0%~99%
+ */
+ s8 ret_val;
+
+ ret_val = value;
+ if (ret_val >= 0)
+ ret_val = 0;
+ if (ret_val <= -33)
+ ret_val = -33;
+ ret_val = -ret_val;
+ ret_val *= 3;
+ if (ret_val == 99)
+ ret_val = 100;
+ return ret_val;
+}
+
+s32 r8712_signal_scale_mapping(s32 cur_sig)
+{
+ s32 ret_sig;
+
+ if (cur_sig >= 51 && cur_sig <= 100)
+ ret_sig = 100;
+ else if (cur_sig >= 41 && cur_sig <= 50)
+ ret_sig = 80 + ((cur_sig - 40) * 2);
+ else if (cur_sig >= 31 && cur_sig <= 40)
+ ret_sig = 66 + (cur_sig - 30);
+ else if (cur_sig >= 21 && cur_sig <= 30)
+ ret_sig = 54 + (cur_sig - 20);
+ else if (cur_sig >= 10 && cur_sig <= 20)
+ ret_sig = 42 + (((cur_sig - 10) * 2) / 3);
+ else if (cur_sig >= 5 && cur_sig <= 9)
+ ret_sig = 22 + (((cur_sig - 5) * 3) / 2);
+ else if (cur_sig >= 1 && cur_sig <= 4)
+ ret_sig = 6 + (((cur_sig - 1) * 3) / 2);
+ else
+ ret_sig = cur_sig;
+ return ret_sig;
+}
+
+static s32 translate2dbm(struct _adapter *padapter, u8 signal_strength_idx)
+{
+ s32 signal_power; /* in dBm.*/
+ /* Translate to dBm (x=0.5y-95).*/
+ signal_power = (s32)((signal_strength_idx + 1) >> 1);
+ signal_power -= 95;
+ return signal_power;
+}
+
+static void query_rx_phy_status(struct _adapter *padapter,
+ union recv_frame *prframe)
+{
+ u8 i, max_spatial_stream, evm;
+ struct recv_stat *prxstat = (struct recv_stat *)prframe->u.hdr.rx_head;
+ struct phy_stat *pphy_stat = (struct phy_stat *)(prxstat + 1);
+ u8 *pphy_head = (u8 *)(prxstat + 1);
+ s8 rx_pwr[4], rx_pwr_all;
+ u8 pwdb_all;
+ u32 rssi, total_rssi = 0;
+ u8 bcck_rate = 0, rf_rx_num = 0, cck_highpwr = 0;
+ struct phy_cck_rx_status *pcck_buf;
+ u8 sq;
+
+ /* Record it for next packet processing*/
+ bcck_rate = (prframe->u.hdr.attrib.mcs_rate <= 3 ? 1 : 0);
+ if (bcck_rate) {
+ u8 report;
+
+ /* CCK Driver info Structure is not the same as OFDM packet.*/
+ pcck_buf = (struct phy_cck_rx_status *)pphy_stat;
+ /* (1)Hardware does not provide RSSI for CCK
+ * (2)PWDB, Average PWDB cacluated by hardware
+ * (for rate adaptive)
+ */
+ if (!cck_highpwr) {
+ report = pcck_buf->cck_agc_rpt & 0xc0;
+ report = report >> 6;
+ switch (report) {
+ /* Modify the RF RNA gain value to -40, -20,
+ * -2, 14 by Jenyu's suggestion
+ * Note: different RF with the different
+ * RNA gain. */
+ case 0x3:
+ rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
+ 0x3e);
+ break;
+ case 0x2:
+ rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
+ 0x3e);
+ break;
+ case 0x1:
+ rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
+ 0x3e);
+ break;
+ case 0x0:
+ rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
+ 0x3e);
+ break;
+ }
+ } else {
+ report = ((u8)(le32_to_cpu(pphy_stat->phydw1) >> 8)) &
+ 0x60;
+ report = report >> 5;
+ switch (report) {
+ case 0x3:
+ rx_pwr_all = -40 - ((pcck_buf->cck_agc_rpt &
+ 0x1f) << 1);
+ break;
+ case 0x2:
+ rx_pwr_all = -20 - ((pcck_buf->cck_agc_rpt &
+ 0x1f) << 1);
+ break;
+ case 0x1:
+ rx_pwr_all = -2 - ((pcck_buf->cck_agc_rpt &
+ 0x1f) << 1);
+ break;
+ case 0x0:
+ rx_pwr_all = 14 - ((pcck_buf->cck_agc_rpt &
+ 0x1f) << 1);
+ break;
+ }
+ }
+ pwdb_all = query_rx_pwr_percentage(rx_pwr_all);
+ /* CCK gain is smaller than OFDM/MCS gain,*/
+ /* so we add gain diff by experiences, the val is 6 */
+ pwdb_all += 6;
+ if (pwdb_all > 100)
+ pwdb_all = 100;
+ /* modify the offset to make the same gain index with OFDM.*/
+ if (pwdb_all > 34 && pwdb_all <= 42)
+ pwdb_all -= 2;
+ else if (pwdb_all > 26 && pwdb_all <= 34)
+ pwdb_all -= 6;
+ else if (pwdb_all > 14 && pwdb_all <= 26)
+ pwdb_all -= 8;
+ else if (pwdb_all > 4 && pwdb_all <= 14)
+ pwdb_all -= 4;
+ /*
+ * (3) Get Signal Quality (EVM)
+ */
+ if (pwdb_all > 40)
+ sq = 100;
+ else {
+ sq = pcck_buf->sq_rpt;
+ if (pcck_buf->sq_rpt > 64)
+ sq = 0;
+ else if (pcck_buf->sq_rpt < 20)
+ sq = 100;
+ else
+ sq = ((64-sq) * 100) / 44;
+ }
+ prframe->u.hdr.attrib.signal_qual = sq;
+ prframe->u.hdr.attrib.rx_mimo_signal_qual[0] = sq;
+ prframe->u.hdr.attrib.rx_mimo_signal_qual[1] = -1;
+ } else {
+ /* (1)Get RSSI for HT rate */
+ for (i = 0; i < ((padapter->registrypriv.rf_config) &
+ 0x0f) ; i++) {
+ rf_rx_num++;
+ rx_pwr[i] = ((pphy_head[PHY_STAT_GAIN_TRSW_SHT + i]
+ & 0x3F) * 2) - 110;
+ /* Translate DBM to percentage. */
+ rssi = query_rx_pwr_percentage(rx_pwr[i]);
+ total_rssi += rssi;
+ }
+ /* (2)PWDB, Average PWDB cacluated by hardware (for
+ * rate adaptive) */
+ rx_pwr_all = (((pphy_head[PHY_STAT_PWDB_ALL_SHT]) >> 1) & 0x7f)
+ - 106;
+ pwdb_all = query_rx_pwr_percentage(rx_pwr_all);
+
+ {
+ /* (3)EVM of HT rate */
+ if (prframe->u.hdr.attrib.htc &&
+ prframe->u.hdr.attrib.mcs_rate >= 20 &&
+ prframe->u.hdr.attrib.mcs_rate <= 27) {
+ /* both spatial stream make sense */
+ max_spatial_stream = 2;
+ } else {
+ /* only spatial stream 1 makes sense */
+ max_spatial_stream = 1;
+ }
+ for (i = 0; i < max_spatial_stream; i++) {
+ evm = evm_db2percentage((pphy_head
+ [PHY_STAT_RXEVM_SHT + i]));/*dbm*/
+ prframe->u.hdr.attrib.signal_qual =
+ (u8)(evm & 0xff);
+ prframe->u.hdr.attrib.rx_mimo_signal_qual[i] =
+ (u8)(evm & 0xff);
+ }
+ }
+ }
+ /* UI BSS List signal strength(in percentage), make it good looking,
+ * from 0~100. It is assigned to the BSS List in
+ * GetValueFromBeaconOrProbeRsp(). */
+ if (bcck_rate)
+ prframe->u.hdr.attrib.signal_strength =
+ (u8)r8712_signal_scale_mapping(pwdb_all);
+ else {
+ if (rf_rx_num != 0)
+ prframe->u.hdr.attrib.signal_strength =
+ (u8)(r8712_signal_scale_mapping(total_rssi /=
+ rf_rx_num));
+ }
+}
+
+static void process_link_qual(struct _adapter *padapter,
+ union recv_frame *prframe)
+{
+ u32 last_evm = 0, tmpVal;
+ struct rx_pkt_attrib *pattrib;
+
+ if (prframe == NULL || padapter == NULL)
+ return;
+ pattrib = &prframe->u.hdr.attrib;
+ if (pattrib->signal_qual != 0) {
+ /*
+ * 1. Record the general EVM to the sliding window.
+ */
+ if (padapter->recvpriv.signal_qual_data.total_num++ >=
+ PHY_LINKQUALITY_SLID_WIN_MAX) {
+ padapter->recvpriv.signal_qual_data.total_num =
+ PHY_LINKQUALITY_SLID_WIN_MAX;
+ last_evm = padapter->recvpriv.signal_qual_data.elements
+ [padapter->recvpriv.signal_qual_data.index];
+ padapter->recvpriv.signal_qual_data.total_val -=
+ last_evm;
+ }
+ padapter->recvpriv.signal_qual_data.total_val +=
+ pattrib->signal_qual;
+ padapter->recvpriv.signal_qual_data.elements[padapter->
+ recvpriv.signal_qual_data.index++] =
+ pattrib->signal_qual;
+ if (padapter->recvpriv.signal_qual_data.index >=
+ PHY_LINKQUALITY_SLID_WIN_MAX)
+ padapter->recvpriv.signal_qual_data.index = 0;
+
+ /* <1> Showed on UI for user, in percentage. */
+ tmpVal = padapter->recvpriv.signal_qual_data.total_val /
+ padapter->recvpriv.signal_qual_data.total_num;
+ padapter->recvpriv.signal = (u8)tmpVal;
+ }
+}
+
+static void process_rssi(struct _adapter *padapter, union recv_frame *prframe)
+{
+ u32 last_rssi, tmp_val;
+ struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib;
+
+ if (padapter->recvpriv.signal_strength_data.total_num++ >=
+ PHY_RSSI_SLID_WIN_MAX) {
+ padapter->recvpriv.signal_strength_data.total_num =
+ PHY_RSSI_SLID_WIN_MAX;
+ last_rssi = padapter->recvpriv.signal_strength_data.elements
+ [padapter->recvpriv.signal_strength_data.index];
+ padapter->recvpriv.signal_strength_data.total_val -= last_rssi;
+ }
+ padapter->recvpriv.signal_strength_data.total_val +=
+ pattrib->signal_strength;
+ padapter->recvpriv.signal_strength_data.elements[padapter->recvpriv.
+ signal_strength_data.index++] =
+ pattrib->signal_strength;
+ if (padapter->recvpriv.signal_strength_data.index >=
+ PHY_RSSI_SLID_WIN_MAX)
+ padapter->recvpriv.signal_strength_data.index = 0;
+ tmp_val = padapter->recvpriv.signal_strength_data.total_val /
+ padapter->recvpriv.signal_strength_data.total_num;
+ padapter->recvpriv.rssi = (s8)translate2dbm(padapter, (u8)tmp_val);
+}
+
+static void process_phy_info(struct _adapter *padapter,
+ union recv_frame *prframe)
+{
+ query_rx_phy_status(padapter, prframe);
+ process_rssi(padapter, prframe);
+ process_link_qual(padapter, prframe);
+}
+
+int recv_func(struct _adapter *padapter, void *pcontext)
+{
+ struct rx_pkt_attrib *pattrib;
+ union recv_frame *prframe, *orig_prframe;
+ int retval = _SUCCESS;
+ struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ prframe = (union recv_frame *)pcontext;
+ orig_prframe = prframe;
+ pattrib = &prframe->u.hdr.attrib;
+ if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
+ if (pattrib->crc_err == 1)
+ padapter->mppriv.rx_crcerrpktcount++;
+ else
+ padapter->mppriv.rx_pktcount++;
+ if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) {
+ /* free this recv_frame */
+ r8712_free_recvframe(orig_prframe, pfree_recv_queue);
+ goto _exit_recv_func;
+ }
+ }
+ /* check the frame crtl field and decache */
+ retval = r8712_validate_recv_frame(padapter, prframe);
+ if (retval != _SUCCESS) {
+ /* free this recv_frame */
+ r8712_free_recvframe(orig_prframe, pfree_recv_queue);
+ goto _exit_recv_func;
+ }
+ process_phy_info(padapter, prframe);
+ prframe = r8712_decryptor(padapter, prframe);
+ if (prframe == NULL) {
+ retval = _FAIL;
+ goto _exit_recv_func;
+ }
+ prframe = r8712_recvframe_chk_defrag(padapter, prframe);
+ if (prframe == NULL)
+ goto _exit_recv_func;
+ prframe = r8712_portctrl(padapter, prframe);
+ if (prframe == NULL) {
+ retval = _FAIL;
+ goto _exit_recv_func;
+ }
+ retval = r8712_process_recv_indicatepkts(padapter, prframe);
+ if (retval != _SUCCESS) {
+ r8712_free_recvframe(orig_prframe, pfree_recv_queue);
+ goto _exit_recv_func;
+ }
+_exit_recv_func:
+ return retval;
+}
+
+static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb)
+{
+ u8 *pbuf, shift_sz = 0;
+ u8 frag, mf;
+ uint pkt_len;
+ u32 transfer_len;
+ struct recv_stat *prxstat;
+ u16 pkt_cnt, drvinfo_sz, pkt_offset, tmp_len, alloc_sz;
+ struct __queue *pfree_recv_queue;
+ _pkt *pkt_copy = NULL;
+ union recv_frame *precvframe = NULL;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+
+ pfree_recv_queue = &(precvpriv->free_recv_queue);
+ pbuf = pskb->data;
+ prxstat = (struct recv_stat *)pbuf;
+ pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16)&0xff;
+ pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff;
+ transfer_len = pskb->len;
+ /* Test throughput with Netgear 3700 (No security) with Chariot 3T3R
+ * pairs. The packet count will be a big number so that the containing
+ * packet will effect the Rx reordering. */
+ if (transfer_len < pkt_len) {
+ /* In this case, it means the MAX_RECVBUF_SZ is too small to
+ * get the data from 8712u. */
+ return _FAIL;
+ }
+ do {
+ prxstat = (struct recv_stat *)pbuf;
+ pkt_len = le32_to_cpu(prxstat->rxdw0)&0x00003fff;
+ /* more fragment bit */
+ mf = (le32_to_cpu(prxstat->rxdw1) >> 27) & 0x1;
+ /* ragmentation number */
+ frag = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
+ /* uint 2^3 = 8 bytes */
+ drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16;
+ drvinfo_sz = drvinfo_sz<<3;
+ if (pkt_len <= 0)
+ goto _exit_recvbuf2recvframe;
+ /* Qos data, wireless lan header length is 26 */
+ if ((le32_to_cpu(prxstat->rxdw0) >> 23) & 0x01)
+ shift_sz = 2;
+ precvframe = r8712_alloc_recvframe(pfree_recv_queue);
+ if (precvframe == NULL)
+ goto _exit_recvbuf2recvframe;
+ _init_listhead(&precvframe->u.hdr.list);
+ precvframe->u.hdr.precvbuf = NULL; /*can't access the precvbuf*/
+ precvframe->u.hdr.len = 0;
+ tmp_len = pkt_len + drvinfo_sz + RXDESC_SIZE;
+ pkt_offset = (u16)_RND128(tmp_len);
+ /* for first fragment packet, driver need allocate 1536 +
+ * drvinfo_sz + RXDESC_SIZE to defrag packet. */
+ if ((mf == 1) && (frag == 0))
+ alloc_sz = 1658;
+ else
+ alloc_sz = tmp_len;
+ /* 2 is for IP header 4 bytes alignment in QoS packet case.
+ * 4 is for skb->data 4 bytes alignment. */
+ alloc_sz += 6;
+ pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz);
+ if (pkt_copy) {
+ pkt_copy->dev = padapter->pnetdev;
+ precvframe->u.hdr.pkt = pkt_copy;
+ skb_reserve(pkt_copy, 4 - ((addr_t)(pkt_copy->data)
+ % 4));
+ skb_reserve(pkt_copy, shift_sz);
+ memcpy(pkt_copy->data, pbuf, tmp_len);
+ precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data =
+ precvframe->u.hdr.rx_tail = pkt_copy->data;
+ precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz;
+ } else {
+ precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC);
+ precvframe->u.hdr.rx_head = pbuf;
+ precvframe->u.hdr.rx_data = pbuf;
+ precvframe->u.hdr.rx_tail = pbuf;
+ precvframe->u.hdr.rx_end = pbuf + alloc_sz;
+ }
+ recvframe_put(precvframe, tmp_len);
+ recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE);
+ /* because the endian issue, driver avoid reference to the
+ * rxstat after calling update_recvframe_attrib_from_recvstat();
+ */
+ update_recvframe_attrib_from_recvstat(&precvframe->u.hdr.attrib,
+ prxstat);
+ r8712_recv_entry(precvframe);
+ transfer_len -= pkt_offset;
+ pbuf += pkt_offset;
+ pkt_cnt--;
+ precvframe = NULL;
+ pkt_copy = NULL;
+ } while ((transfer_len > 0) && pkt_cnt > 0);
+_exit_recvbuf2recvframe:
+ return _SUCCESS;
+}
+
+static void recv_tasklet(void *priv)
+{
+ struct sk_buff *pskb;
+ struct _adapter *padapter = (struct _adapter *)priv;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+
+ while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
+ recvbuf2recvframe(padapter, pskb);
+ skb_reset_tail_pointer(pskb);
+ pskb->len = 0;
+ skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
+ }
+}
diff --git a/drivers/staging/rtl8712/rtl8712_recv.h b/drivers/staging/rtl8712/rtl8712_recv.h
new file mode 100644
index 000000000000..4ba52b9c1697
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_recv.h
@@ -0,0 +1,128 @@
+#ifndef _RTL8712_RECV_H_
+#define _RTL8712_RECV_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+#define NR_RECVBUFF (8)
+#define NR_PREALLOC_RECV_SKB (8)
+#define RXDESC_SIZE 24
+#define RXDESC_OFFSET RXDESC_SIZE
+#define RECV_BLK_SZ 512
+#define RECV_BLK_CNT 16
+#define RECV_BLK_TH RECV_BLK_CNT
+#define MAX_RECVBUF_SZ (30720) /* 30K */
+#define RECVBUFF_ALIGN_SZ 512
+#define RSVD_ROOM_SZ (0)
+/*These definition is used for Rx packet reordering.*/
+#define SN_LESS(a, b) (((a-b) & 0x800) != 0)
+#define SN_EQUAL(a, b) (a == b)
+#define REORDER_WAIT_TIME 30 /* (ms)*/
+
+struct recv_stat {
+ unsigned int rxdw0;
+ unsigned int rxdw1;
+ unsigned int rxdw2;
+ unsigned int rxdw3;
+ unsigned int rxdw4;
+ unsigned int rxdw5;
+};
+
+struct phy_cck_rx_status {
+ /* For CCK rate descriptor. This is a unsigned 8:1 variable.
+ * LSB bit present 0.5. And MSB 7 bts present a signed value.
+ * Range from -64~+63.5. */
+ u8 adc_pwdb_X[4];
+ u8 sq_rpt;
+ u8 cck_agc_rpt;
+};
+
+struct phy_stat {
+ unsigned int phydw0;
+ unsigned int phydw1;
+ unsigned int phydw2;
+ unsigned int phydw3;
+ unsigned int phydw4;
+ unsigned int phydw5;
+ unsigned int phydw6;
+ unsigned int phydw7;
+};
+#define PHY_STAT_GAIN_TRSW_SHT 0
+#define PHY_STAT_PWDB_ALL_SHT 4
+#define PHY_STAT_CFOSHO_SHT 5
+#define PHY_STAT_CCK_AGC_RPT_SHT 5
+#define PHY_STAT_CFOTAIL_SHT 9
+#define PHY_STAT_RXEVM_SHT 13
+#define PHY_STAT_RXSNR_SHT 15
+#define PHY_STAT_PDSNR_SHT 19
+#define PHY_STAT_CSI_CURRENT_SHT 21
+#define PHY_STAT_CSI_TARGET_SHT 23
+#define PHY_STAT_SIGEVM_SHT 25
+#define PHY_STAT_MAX_EX_PWR_SHT 26
+
+union recvstat {
+ struct recv_stat recv_stat;
+ unsigned int value[RXDESC_SIZE>>2];
+};
+
+
+struct recv_buf {
+ struct list_head list;
+ spinlock_t recvbuf_lock;
+ u32 ref_cnt;
+ struct _adapter *adapter;
+ struct urb *purb;
+ _pkt *pskb;
+ u8 reuse;
+ u8 irp_pending;
+ u32 transfer_len;
+ uint len;
+ u8 *phead;
+ u8 *pdata;
+ u8 *ptail;
+ u8 *pend;
+ u8 *pbuf;
+ u8 *pallocated_buf;
+};
+
+/*
+ head ----->
+ data ----->
+ payload
+ tail ----->
+ end ----->
+ len = (unsigned int )(tail - data);
+*/
+struct recv_frame_hdr{
+ struct list_head list;
+ _pkt *pkt;
+ _pkt *pkt_newalloc;
+ struct _adapter *adapter;
+ u8 fragcnt;
+ struct rx_pkt_attrib attrib;
+ uint len;
+ u8 *rx_head;
+ u8 *rx_data;
+ u8 *rx_tail;
+ u8 *rx_end;
+ void *precvbuf;
+ struct sta_info *psta;
+ /*for A-MPDU Rx reordering buffer control*/
+ struct recv_reorder_ctrl *preorder_ctrl;
+};
+
+union recv_frame {
+ union {
+ struct list_head list;
+ struct recv_frame_hdr hdr;
+ addr_t mem[RECVFRAME_HDR_ALIGN>>2];
+ } u;
+};
+
+int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf);
+void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf);
+s32 r8712_signal_scale_mapping(s32 cur_sig);
+void r8712_reordering_ctrl_timeout_handler(void *pcontext);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl8712_regdef.h b/drivers/staging/rtl8712/rtl8712_regdef.h
new file mode 100644
index 000000000000..5b0de2ab6b61
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_regdef.h
@@ -0,0 +1,19 @@
+#ifndef __RTL8712_REGDEF_H__
+#define __RTL8712_REGDEF_H__
+
+#include "rtl8712_syscfg_regdef.h"
+#include "rtl8712_cmdctrl_regdef.h"
+#include "rtl8712_macsetting_regdef.h"
+#include "rtl8712_timectrl_regdef.h"
+#include "rtl8712_fifoctrl_regdef.h"
+#include "rtl8712_ratectrl_regdef.h"
+#include "rtl8712_edcasetting_regdef.h"
+#include "rtl8712_wmac_regdef.h"
+#include "rtl8712_powersave_regdef.h"
+#include "rtl8712_gp_regdef.h"
+#include "rtl8712_debugctrl_regdef.h"
+
+#define HIMR (RTL8712_INTERRUPT_ + 0x08)
+
+#endif /* __RTL8712_REGDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_security_bitdef.h b/drivers/staging/rtl8712/rtl8712_security_bitdef.h
new file mode 100644
index 000000000000..8df4bf4a0699
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_security_bitdef.h
@@ -0,0 +1,29 @@
+#ifndef __RTL8712_SECURITY_BITDEF_H__
+#define __RTL8712_SECURITY_BITDEF_H__
+
+/*CAMCMD*/
+#define _SECCAM_POLLING BIT(31)
+#define _SECCAM_CLR BIT(30)
+#define _SECCAM_WE BIT(16)
+#define _SECCAM_ADR_MSK 0x000000FF
+#define _SECCAM_ADR_SHT 0
+
+/*CAMDBG*/
+#define _SECCAM_INFO BIT(31)
+#define _SEC_KEYFOUND BIT(30)
+#define _SEC_CONFIG_MSK 0x3F000000
+#define _SEC_CONFIG_SHT 24
+#define _SEC_KEYCONTENT_MSK 0x00FFFFFF
+#define _SEC_KEYCONTENT_SHT 0
+
+/*SECCFG*/
+#define _NOSKMC BIT(5)
+#define _SKBYA2 BIT(4)
+#define _RXDEC BIT(3)
+#define _TXENC BIT(2)
+#define _RXUSEDK BIT(1)
+#define _TXUSEDK BIT(0)
+
+
+#endif /*__RTL8712_SECURITY_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_spec.h b/drivers/staging/rtl8712/rtl8712_spec.h
new file mode 100644
index 000000000000..3f181eed4ee9
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_spec.h
@@ -0,0 +1,110 @@
+#ifndef __RTL8712_SPEC_H__
+#define __RTL8712_SPEC_H__
+
+#define RTL8712_IOBASE_TXPKT 0x10200000 /*IOBASE_TXPKT*/
+#define RTL8712_IOBASE_RXPKT 0x10210000 /*IOBASE_RXPKT*/
+#define RTL8712_IOBASE_RXCMD 0x10220000 /*IOBASE_RXCMD*/
+#define RTL8712_IOBASE_TXSTATUS 0x10230000 /*IOBASE_TXSTATUS*/
+#define RTL8712_IOBASE_RXSTATUS 0x10240000 /*IOBASE_RXSTATUS*/
+#define RTL8712_IOBASE_IOREG 0x10250000 /*IOBASE_IOREG ADDR*/
+#define RTL8712_IOBASE_SCHEDULER 0x10260000 /*IOBASE_SCHEDULE*/
+
+#define RTL8712_IOBASE_TRXDMA 0x10270000 /*IOBASE_TRXDMA*/
+#define RTL8712_IOBASE_TXLLT 0x10280000 /*IOBASE_TXLLT*/
+#define RTL8712_IOBASE_WMAC 0x10290000 /*IOBASE_WMAC*/
+#define RTL8712_IOBASE_FW2HW 0x102A0000 /*IOBASE_FW2HW*/
+#define RTL8712_IOBASE_ACCESS_PHYREG 0x102B0000 /*IOBASE_ACCESS_PHYREG*/
+
+#define RTL8712_IOBASE_FF 0x10300000 /*IOBASE_FIFO 0x1031000~0x103AFFFF*/
+
+
+/*IOREG Offset for 8712*/
+#define RTL8712_SYSCFG_ RTL8712_IOBASE_IOREG
+#define RTL8712_CMDCTRL_ (RTL8712_IOBASE_IOREG + 0x40)
+#define RTL8712_MACIDSETTING_ (RTL8712_IOBASE_IOREG + 0x50)
+#define RTL8712_TIMECTRL_ (RTL8712_IOBASE_IOREG + 0x80)
+#define RTL8712_FIFOCTRL_ (RTL8712_IOBASE_IOREG + 0xA0)
+#define RTL8712_RATECTRL_ (RTL8712_IOBASE_IOREG + 0x160)
+#define RTL8712_EDCASETTING_ (RTL8712_IOBASE_IOREG + 0x1D0)
+#define RTL8712_WMAC_ (RTL8712_IOBASE_IOREG + 0x200)
+#define RTL8712_SECURITY_ (RTL8712_IOBASE_IOREG + 0x240)
+#define RTL8712_POWERSAVE_ (RTL8712_IOBASE_IOREG + 0x260)
+#define RTL8712_GP_ (RTL8712_IOBASE_IOREG + 0x2E0)
+#define RTL8712_INTERRUPT_ (RTL8712_IOBASE_IOREG + 0x300)
+#define RTL8712_DEBUGCTRL_ (RTL8712_IOBASE_IOREG + 0x310)
+#define RTL8712_OFFLOAD_ (RTL8712_IOBASE_IOREG + 0x2D0)
+
+
+/*FIFO for 8712*/
+#define RTL8712_DMA_BCNQ (RTL8712_IOBASE_FF + 0x10000)
+#define RTL8712_DMA_MGTQ (RTL8712_IOBASE_FF + 0x20000)
+#define RTL8712_DMA_BMCQ (RTL8712_IOBASE_FF + 0x30000)
+#define RTL8712_DMA_VOQ (RTL8712_IOBASE_FF + 0x40000)
+#define RTL8712_DMA_VIQ (RTL8712_IOBASE_FF + 0x50000)
+#define RTL8712_DMA_BEQ (RTL8712_IOBASE_FF + 0x60000)
+#define RTL8712_DMA_BKQ (RTL8712_IOBASE_FF + 0x70000)
+#define RTL8712_DMA_RX0FF (RTL8712_IOBASE_FF + 0x80000)
+#define RTL8712_DMA_H2CCMD (RTL8712_IOBASE_FF + 0x90000)
+#define RTL8712_DMA_C2HCMD (RTL8712_IOBASE_FF + 0xA0000)
+
+
+/*------------------------------*/
+
+/*BIT 16 15*/
+#define DID_SDIO_LOCAL 0 /* 0 0*/
+#define DID_WLAN_IOREG 1 /* 0 1*/
+#define DID_WLAN_FIFO 3 /* 1 1*/
+#define DID_UNDEFINE (-1)
+
+#define CMD_ADDR_MAPPING_SHIFT 2 /*SDIO CMD ADDR MAPPING,
+ *shift 2 bit for match
+ * offset[14:2]*/
+
+/*Offset for SDIO LOCAL*/
+#define OFFSET_SDIO_LOCAL 0x0FFF
+
+/*Offset for WLAN IOREG*/
+#define OFFSET_WLAN_IOREG 0x0FFF
+
+/*Offset for WLAN FIFO*/
+#define OFFSET_TX_BCNQ 0x0300
+#define OFFSET_TX_HIQ 0x0310
+#define OFFSET_TX_CMDQ 0x0320
+#define OFFSET_TX_MGTQ 0x0330
+#define OFFSET_TX_HCCAQ 0x0340
+#define OFFSET_TX_VOQ 0x0350
+#define OFFSET_TX_VIQ 0x0360
+#define OFFSET_TX_BEQ 0x0370
+#define OFFSET_TX_BKQ 0x0380
+#define OFFSET_RX_RX0FFQ 0x0390
+#define OFFSET_RX_C2HFFQ 0x03A0
+
+#define BK_QID_01 1
+#define BK_QID_02 2
+#define BE_QID_01 0
+#define BE_QID_02 3
+#define VI_QID_01 4
+#define VI_QID_02 5
+#define VO_QID_01 6
+#define VO_QID_02 7
+#define HCCA_QID_01 8
+#define HCCA_QID_02 9
+#define HCCA_QID_03 10
+#define HCCA_QID_04 11
+#define HCCA_QID_05 12
+#define HCCA_QID_06 13
+#define HCCA_QID_07 14
+#define HCCA_QID_08 15
+#define HI_QID 17
+#define CMD_QID 19
+#define MGT_QID 18
+#define BCN_QID 16
+
+#include "rtl8712_regdef.h"
+
+#include "rtl8712_bitdef.h"
+
+#include "basic_types.h"
+
+#endif /* __RTL8712_SPEC_H__ */
+
diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h
new file mode 100644
index 000000000000..dce15c2ff503
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h
@@ -0,0 +1,145 @@
+#ifndef __RTL8712_SYSCFG_BITDEF_H__
+#define __RTL8712_SYSCFG_BITDEF_H__
+
+/*SYS_PWR_CTRL*/
+/*SRCTRL0*/
+/*SRCTRL1*/
+/*SYS_CLKR*/
+
+/*SYS_IOS_CTRL*/
+#define iso_LDR2RP_SHT 8 /* EE Loader to Retention Path*/
+#define iso_LDR2RP BIT(iso_LDR2RP_SHT) /* 1:isolation, 0:attach*/
+
+/*SYS_CTRL*/
+#define FEN_DIO_SDIO_SHT 0
+#define FEN_DIO_SDIO BIT(FEN_DIO_SDIO_SHT)
+#define FEN_SDIO_SHT 1
+#define FEN_SDIO BIT(FEN_SDIO_SHT)
+#define FEN_USBA_SHT 2
+#define FEN_USBA BIT(FEN_USBA_SHT)
+#define FEN_UPLL_SHT 3
+#define FEN_UPLL BIT(FEN_UPLL_SHT)
+#define FEN_USBD_SHT 4
+#define FEN_USBD BIT(FEN_USBD_SHT)
+#define FEN_DIO_PCIE_SHT 5
+#define FEN_DIO_PCIE BIT(FEN_DIO_PCIE_SHT)
+#define FEN_PCIEA_SHT 6
+#define FEN_PCIEA BIT(FEN_PCIEA_SHT)
+#define FEN_PPLL_SHT 7
+#define FEN_PPLL BIT(FEN_PPLL_SHT)
+#define FEN_PCIED_SHT 8
+#define FEN_PCIED BIT(FEN_PCIED_SHT)
+#define FEN_CPUEN_SHT 10
+#define FEN_CPUEN BIT(FEN_CPUEN_SHT)
+#define FEN_DCORE_SHT 11
+#define FEN_DCORE BIT(FEN_DCORE_SHT)
+#define FEN_ELDR_SHT 12
+#define FEN_ELDR BIT(FEN_ELDR_SHT)
+#define PWC_DV2LDR_SHT 13
+#define PWC_DV2LDR BIT(PWC_DV2LDR_SHT) /* Loader Power Enable*/
+
+/*=== SYS_CLKR ===*/
+#define SYS_CLKSEL_SHT 0
+#define SYS_CLKSEL BIT(SYS_CLKSEL_SHT) /* System Clock 80MHz*/
+#define PS_CLKSEL_SHT 1
+#define PS_CLKSEL BIT(PS_CLKSEL_SHT) /*System power save
+ * clock select.*/
+#define CPU_CLKSEL_SHT 2
+#define CPU_CLKSEL BIT(CPU_CLKSEL_SHT) /* System Clock select,
+ * 1: AFE source,
+ * 0: System clock(L-Bus)*/
+#define INT32K_EN_SHT 3
+#define INT32K_EN BIT(INT32K_EN_SHT)
+#define MACSLP_SHT 4
+#define MACSLP BIT(MACSLP_SHT)
+#define MAC_CLK_EN_SHT 11
+#define MAC_CLK_EN BIT(MAC_CLK_EN_SHT) /* MAC Clock Enable.*/
+#define SYS_CLK_EN_SHT 12
+#define SYS_CLK_EN BIT(SYS_CLK_EN_SHT)
+#define RING_CLK_EN_SHT 13
+#define RING_CLK_EN BIT(RING_CLK_EN_SHT)
+#define SWHW_SEL_SHT 14
+#define SWHW_SEL BIT(SWHW_SEL_SHT) /* Load done,
+ * control path switch.*/
+#define FWHW_SEL_SHT 15
+#define FWHW_SEL BIT(FWHW_SEL_SHT) /* Sleep exit,
+ * control path switch.*/
+
+/*9346CR*/
+#define _VPDIDX_MSK 0xFF00
+#define _VPDIDX_SHT 8
+#define _EEM_MSK 0x00C0
+#define _EEM_SHT 6
+#define _EEM0 BIT(6)
+#define _EEM1 BIT(7)
+#define _EEPROM_EN BIT(5)
+#define _9356SEL BIT(4)
+#define _EECS BIT(3)
+#define _EESK BIT(2)
+#define _EEDI BIT(1)
+#define _EEDO BIT(0)
+
+/*AFE_MISC*/
+#define AFE_MISC_USB_MBEN_SHT 7
+#define AFE_MISC_USB_MBEN BIT(AFE_MISC_USB_MBEN_SHT)
+#define AFE_MISC_USB_BGEN_SHT 6
+#define AFE_MISC_USB_BGEN BIT(AFE_MISC_USB_BGEN_SHT)
+#define AFE_MISC_LD12_VDAJ_SHT 4
+#define AFE_MISC_LD12_VDAJ_MSK 0X0030
+#define AFE_MISC_LD12_VDAJ BIT(AFE_MISC_LD12_VDAJ_SHT)
+#define AFE_MISC_I32_EN_SHT 3
+#define AFE_MISC_I32_EN BIT(AFE_MISC_I32_EN_SHT)
+#define AFE_MISC_E32_EN_SHT 2
+#define AFE_MISC_E32_EN BIT(AFE_MISC_E32_EN_SHT)
+#define AFE_MISC_MBEN_SHT 1
+#define AFE_MISC_MBEN BIT(AFE_MISC_MBEN_SHT)/* Enable AFE Macro
+ * Block's Mbias.*/
+#define AFE_MISC_BGEN_SHT 0
+#define AFE_MISC_BGEN BIT(AFE_MISC_BGEN_SHT)/* Enable AFE Macro
+ * Block's Bandgap.*/
+
+
+/*--------------------------------------------------------------------------*/
+/* SPS1_CTRL bits (Offset 0x18-1E, 56bits)*/
+/*--------------------------------------------------------------------------*/
+#define SPS1_SWEN BIT(1) /* Enable vsps18 SW Macro Block.*/
+#define SPS1_LDEN BIT(0) /* Enable VSPS12 LDO Macro block.*/
+
+
+/*----------------------------------------------------------------------------*/
+/* LDOA15_CTRL bits (Offset 0x20, 8bits)*/
+/*----------------------------------------------------------------------------*/
+#define LDA15_EN BIT(0) /* Enable LDOA15 Macro Block*/
+
+
+/*----------------------------------------------------------------------------*/
+/* 8192S LDOV12D_CTRL bit (Offset 0x21, 8bits)*/
+/*----------------------------------------------------------------------------*/
+#define LDV12_EN BIT(0) /* Enable LDOVD12 Macro Block*/
+#define LDV12_SDBY BIT(1) /* LDOVD12 standby mode*/
+
+/*CLK_PS_CTRL*/
+#define _CLK_GATE_EN BIT(0)
+
+
+/* EFUSE_CTRL*/
+#define EF_FLAG BIT(31) /* Access Flag, Write:1;
+ * Read:0*/
+#define EF_PGPD 0x70000000 /* E-fuse Program time*/
+#define EF_RDT 0x0F000000 /* E-fuse read time: in the
+ * unit of cycle time*/
+#define EF_PDN_EN BIT(19) /* EFuse Power down enable*/
+#define ALD_EN BIT(18) /* Autoload Enable*/
+#define EF_ADDR 0x0003FF00 /* Access Address*/
+#define EF_DATA 0x000000FF /* Access Data*/
+
+/* EFUSE_TEST*/
+#define LDOE25_EN BIT(31) /* Enable LDOE25 Macro Block*/
+
+/* EFUSE_CLK_CTRL*/
+#define EFUSE_CLK_EN BIT(1) /* E-Fuse Clock Enable*/
+#define EFUSE_CLK_SEL BIT(0) /* E-Fuse Clock Select,
+ * 0:500K, 1:40M*/
+
+#endif /*__RTL8712_SYSCFG_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h
new file mode 100644
index 000000000000..687e1b7a03f5
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_syscfg_regdef.h
@@ -0,0 +1,31 @@
+#ifndef __RTL8712_SYSCFG_REGDEF_H__
+#define __RTL8712_SYSCFG_REGDEF_H__
+
+
+#define SYS_ISO_CTRL (RTL8712_SYSCFG_ + 0x0000)
+#define SYS_FUNC_EN (RTL8712_SYSCFG_ + 0x0002)
+#define PMC_FSM (RTL8712_SYSCFG_ + 0x0004)
+#define SYS_CLKR (RTL8712_SYSCFG_ + 0x0008)
+#define EE_9346CR (RTL8712_SYSCFG_ + 0x000A)
+#define EE_VPD (RTL8712_SYSCFG_ + 0x000C)
+#define AFE_MISC (RTL8712_SYSCFG_ + 0x0010)
+#define SPS0_CTRL (RTL8712_SYSCFG_ + 0x0011)
+#define SPS1_CTRL (RTL8712_SYSCFG_ + 0x0018)
+#define RF_CTRL (RTL8712_SYSCFG_ + 0x001F)
+#define LDOA15_CTRL (RTL8712_SYSCFG_ + 0x0020)
+#define LDOV12D_CTRL (RTL8712_SYSCFG_ + 0x0021)
+#define LDOHCI12_CTRL (RTL8712_SYSCFG_ + 0x0022)
+#define LDO_USB_CTRL (RTL8712_SYSCFG_ + 0x0023)
+#define LPLDO_CTRL (RTL8712_SYSCFG_ + 0x0024)
+#define AFE_XTAL_CTRL (RTL8712_SYSCFG_ + 0x0026)
+#define AFE_PLL_CTRL (RTL8712_SYSCFG_ + 0x0028)
+#define EFUSE_CTRL (RTL8712_SYSCFG_ + 0x0030)
+#define EFUSE_TEST (RTL8712_SYSCFG_ + 0x0034)
+#define PWR_DATA (RTL8712_SYSCFG_ + 0x0038)
+#define DPS_TIMER (RTL8712_SYSCFG_ + 0x003C)
+#define RCLK_MON (RTL8712_SYSCFG_ + 0x003E)
+#define EFUSE_CLK_CTRL (RTL8712_SYSCFG_ + 0x02F8)
+
+
+#endif /*__RTL8712_SYSCFG_REGDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h b/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h
new file mode 100644
index 000000000000..32ce9fab5dbe
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h
@@ -0,0 +1,44 @@
+#ifndef __RTL8712_TIMECTRL_BITDEF_H__
+#define __RTL8712_TIMECTRL_BITDEF_H__
+
+/*TSFTR*/
+/*SLOT*/
+/*USTIME*/
+
+/*TUBASE*/
+#define _TUBASE_MSK 0x07FF
+
+/*SIFS_CCK*/
+#define _SIFS_CCK_TRX_MSK 0xFF00
+#define _SIFS_CCK_TRX_SHT 0x8
+#define _SIFS_CCK_CTX_MSK 0x00FF
+#define _SIFS_CCK_CTX_SHT 0
+
+/*SIFS_OFDM*/
+#define _SIFS_OFDM_TRX_MSK 0xFF00
+#define _SIFS_OFDM_TRX_SHT 0x8
+#define _SIFS_OFDM_CTX_MSK 0x00FF
+#define _SIFS_OFDM_CTX_SHT 0
+
+/*PIFS*/
+/*ACKTO*/
+/*EIFS*/
+/*BCNITV*/
+/*ATIMWND*/
+
+/*DRVERLYINT*/
+#define _ENSWBCN BIT(15)
+#define _DRVERLY_TU_MSK 0x0FF0
+#define _DRVERLY_TU_SHT 4
+#define _DRVERLY_US_MSK 0x000F
+#define _DRVERLY_US_SHT 0
+
+/*BCNDMATIM*/
+#define _BCNDMATIM_MSK 0x03FF
+
+/*BCNERRTH*/
+/*MLT*/
+
+
+#endif /* __RTL8712_TIMECTRL_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h b/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h
new file mode 100644
index 000000000000..8a3dd562ba89
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_timectrl_regdef.h
@@ -0,0 +1,20 @@
+#ifndef __RTL8712_TIMECTRL_REGDEF_H__
+#define __RTL8712_TIMECTRL_REGDEF_H__
+
+#define TSFTR (RTL8712_TIMECTRL_ + 0x00)
+#define USTIME (RTL8712_TIMECTRL_ + 0x08)
+#define SLOT (RTL8712_TIMECTRL_ + 0x09)
+#define TUBASE (RTL8712_TIMECTRL_ + 0x0A)
+#define SIFS_CCK (RTL8712_TIMECTRL_ + 0x0C)
+#define SIFS_OFDM (RTL8712_TIMECTRL_ + 0x0E)
+#define PIFS (RTL8712_TIMECTRL_ + 0x10)
+#define ACKTO (RTL8712_TIMECTRL_ + 0x11)
+#define EIFS (RTL8712_TIMECTRL_ + 0x12)
+#define BCNITV (RTL8712_TIMECTRL_ + 0x14)
+#define ATIMWND (RTL8712_TIMECTRL_ + 0x16)
+#define DRVERLYINT (RTL8712_TIMECTRL_ + 0x18)
+#define BCNDMATIM (RTL8712_TIMECTRL_ + 0x1A)
+#define BCNERRTH (RTL8712_TIMECTRL_ + 0x1C)
+#define MLT (RTL8712_TIMECTRL_ + 0x1D)
+
+#endif /* __RTL8712_TIMECTRL_REGDEF_H__ */
diff --git a/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h
new file mode 100644
index 000000000000..6d3be2a24226
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_wmac_bitdef.h
@@ -0,0 +1,37 @@
+#ifndef __RTL8712_WMAC_BITDEF_H__
+#define __RTL8712_WMAC_BITDEF_H__
+
+/*NAVCTRL*/
+#define _NAV_UPPER_EN BIT(18)
+#define _NAV_MTO_EN BIT(17)
+#define _NAV_UPPER BIT(16)
+#define _NAV_MTO_MSK 0xFF00
+#define _NAV_MTO_SHT 8
+#define _RTSRST_MSK 0x00FF
+#define _RTSRST_SHT 0
+
+/*BWOPMODE*/
+#define _20MHZBW BIT(2)
+
+/*BACAMCMD*/
+#define _BACAM_POLL BIT(31)
+#define _BACAM_RST BIT(17)
+#define _BACAM_RW BIT(16)
+#define _BACAM_ADDR_MSK 0x0000007F
+#define _BACAM_ADDR_SHT 0
+
+/*LBDLY*/
+#define _LBDLY_MSK 0x1F
+
+/*FWDLY*/
+#define _FWDLY_MSK 0x0F
+
+/*RXERR_RPT*/
+#define _RXERR_RPT_SEL_MSK 0xF0000000
+#define _RXERR_RPT_SEL_SHT 28
+#define _RPT_CNT_MSK 0x000FFFFF
+#define _RPT_CNT_SHT 0
+
+
+#endif /*__RTL8712_WMAC_BITDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_wmac_regdef.h b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h
new file mode 100644
index 000000000000..ac80dfb317cb
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_wmac_regdef.h
@@ -0,0 +1,24 @@
+#ifndef __RTL8712_WMAC_REGDEF_H__
+#define __RTL8712_WMAC_REGDEF_H__
+
+#define NAVCTRL (RTL8712_WMAC_ + 0x00)
+#define BWOPMODE (RTL8712_WMAC_ + 0x03)
+#define BACAMCMD (RTL8712_WMAC_ + 0x04)
+#define BACAMCONTENT (RTL8712_WMAC_ + 0x08)
+#define LBDLY (RTL8712_WMAC_ + 0x10)
+#define FWDLY (RTL8712_WMAC_ + 0x11)
+#define HWPC_RX_CTRL (RTL8712_WMAC_ + 0x18)
+#define MQ (RTL8712_WMAC_ + 0x20)
+#define MA (RTL8712_WMAC_ + 0x22)
+#define MS (RTL8712_WMAC_ + 0x24)
+#define CLM_RESULT (RTL8712_WMAC_ + 0x27)
+#define NHM_RPI_CNT (RTL8712_WMAC_ + 0x28)
+#define RXERR_RPT (RTL8712_WMAC_ + 0x30)
+#define NAV_PROT_LEN (RTL8712_WMAC_ + 0x34)
+#define CFEND_TH (RTL8712_WMAC_ + 0x36)
+#define AMPDU_MIN_SPACE (RTL8712_WMAC_ + 0x37)
+#define TXOP_STALL_CTRL (RTL8712_WMAC_ + 0x38)
+
+
+#endif /*__RTL8712_WMAC_REGDEF_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c
new file mode 100644
index 000000000000..8edc518536f9
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_xmit.c
@@ -0,0 +1,509 @@
+/******************************************************************************
+ * rtl8712_xmit.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL8712_XMIT_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_byteorder.h"
+#include "wifi.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+static void dump_xframe(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe);
+
+sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag)
+{
+ phw_txqueue->ac_tag = ac_tag;
+ switch (ac_tag) {
+ case BE_QUEUE_INX:
+ phw_txqueue->ff_hwaddr = RTL8712_DMA_BEQ;
+ break;
+ case BK_QUEUE_INX:
+ phw_txqueue->ff_hwaddr = RTL8712_DMA_BKQ;
+ break;
+ case VI_QUEUE_INX:
+ phw_txqueue->ff_hwaddr = RTL8712_DMA_VIQ;
+ break;
+ case VO_QUEUE_INX:
+ phw_txqueue->ff_hwaddr = RTL8712_DMA_VOQ;
+ break;
+ case BMC_QUEUE_INX:
+ phw_txqueue->ff_hwaddr = RTL8712_DMA_BEQ;
+ break;
+ }
+ return _SUCCESS;
+}
+
+int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
+ struct pkt_attrib *pattrib)
+{
+ struct sta_info *psta;
+ struct tx_servq *ptxservq;
+ int priority = pattrib->priority;
+
+ psta = pattrib->psta;
+ switch (priority) {
+ case 1:
+ case 2:
+ ptxservq = &(psta->sta_xmitpriv.bk_q);
+ break;
+ case 4:
+ case 5:
+ ptxservq = &(psta->sta_xmitpriv.vi_q);
+ break;
+ case 6:
+ case 7:
+ ptxservq = &(psta->sta_xmitpriv.vo_q);
+ break;
+ case 0:
+ case 3:
+ default:
+ ptxservq = &(psta->sta_xmitpriv.be_q);
+ break;
+ }
+ return ptxservq->qcnt;
+}
+
+static u32 get_ff_hwaddr(struct xmit_frame *pxmitframe)
+{
+ u32 addr = 0;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ struct _adapter *padapter = pxmitframe->padapter;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+
+ if (pxmitframe->frame_tag == TXAGG_FRAMETAG)
+ addr = RTL8712_DMA_H2CCMD;
+ else if (pxmitframe->frame_tag == MGNT_FRAMETAG)
+ addr = RTL8712_DMA_MGTQ;
+ else if (pdvobj->nr_endpoint == 6) {
+ switch (pattrib->priority) {
+ case 0:
+ case 3:
+ addr = RTL8712_DMA_BEQ;
+ break;
+ case 1:
+ case 2:
+ addr = RTL8712_DMA_BKQ;
+ break;
+ case 4:
+ case 5:
+ addr = RTL8712_DMA_VIQ;
+ break;
+ case 6:
+ case 7:
+ addr = RTL8712_DMA_VOQ;
+ break;
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ addr = RTL8712_DMA_H2CCMD;
+ break;
+ default:
+ addr = RTL8712_DMA_BEQ;
+ break;
+ }
+ } else if (pdvobj->nr_endpoint == 4) {
+ switch (pattrib->qsel) {
+ case 0:
+ case 3:
+ case 1:
+ case 2:
+ addr = RTL8712_DMA_BEQ;/*RTL8712_EP_LO;*/
+ break;
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ addr = RTL8712_DMA_VOQ;/*RTL8712_EP_HI;*/
+ break;
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ addr = RTL8712_DMA_H2CCMD;;
+ break;
+ default:
+ addr = RTL8712_DMA_BEQ;/*RTL8712_EP_LO;*/
+ break;
+ }
+ }
+ return addr;
+}
+
+static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv,
+ struct hw_xmit *phwxmit,
+ struct tx_servq *ptxservq,
+ struct __queue *pframe_queue)
+{
+ struct list_head *xmitframe_plist, *xmitframe_phead;
+ struct xmit_frame *pxmitframe = NULL;
+
+ xmitframe_phead = get_list_head(pframe_queue);
+ xmitframe_plist = get_next(xmitframe_phead);
+ if ((end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) {
+ pxmitframe = LIST_CONTAINOR(xmitframe_plist,
+ struct xmit_frame, list);
+ list_delete(&pxmitframe->list);
+ ptxservq->qcnt--;
+ phwxmit->txcmdcnt++;
+ }
+ return pxmitframe;
+}
+
+static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv,
+ struct hw_xmit *phwxmit_i, sint entry)
+{
+ unsigned long irqL0;
+ struct list_head *sta_plist, *sta_phead;
+ struct hw_xmit *phwxmit;
+ struct tx_servq *ptxservq = NULL;
+ struct __queue *pframe_queue = NULL;
+ struct xmit_frame *pxmitframe = NULL;
+ int i, inx[4];
+ int j, tmp, acirp_cnt[4];
+
+ /*entry indx: 0->vo, 1->vi, 2->be, 3->bk.*/
+ inx[0] = 0; acirp_cnt[0] = pxmitpriv->voq_cnt;
+ inx[1] = 1; acirp_cnt[1] = pxmitpriv->viq_cnt;
+ inx[2] = 2; acirp_cnt[2] = pxmitpriv->beq_cnt;
+ inx[3] = 3; acirp_cnt[3] = pxmitpriv->bkq_cnt;
+ for (i = 0; i < 4; i++) {
+ for (j = i + 1; j < 4; j++) {
+ if (acirp_cnt[j] < acirp_cnt[i]) {
+ tmp = acirp_cnt[i];
+ acirp_cnt[i] = acirp_cnt[j];
+ acirp_cnt[j] = tmp;
+ tmp = inx[i];
+ inx[i] = inx[j];
+ inx[j] = tmp;
+ }
+ }
+ }
+ spin_lock_irqsave(&pxmitpriv->lock, irqL0);
+ for (i = 0; i < entry; i++) {
+ phwxmit = phwxmit_i + inx[i];
+ sta_phead = get_list_head(phwxmit->sta_queue);
+ sta_plist = get_next(sta_phead);
+ while ((end_of_queue_search(sta_phead, sta_plist)) == false) {
+ ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq,
+ tx_pending);
+ pframe_queue = &ptxservq->sta_pending;
+ pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit,
+ ptxservq, pframe_queue);
+ if (pxmitframe) {
+ phwxmit->accnt--;
+ goto exit_dequeue_xframe_ex;
+ }
+ sta_plist = get_next(sta_plist);
+ /*Remove sta node when there are no pending packets.*/
+ if (_queue_empty(pframe_queue)) {
+ /*must be done after get_next and before break*/
+ list_delete(&ptxservq->tx_pending);
+ }
+ }
+ }
+exit_dequeue_xframe_ex:
+ spin_unlock_irqrestore(&pxmitpriv->lock, irqL0);
+ return pxmitframe;
+}
+
+void r8712_do_queue_select(struct _adapter *padapter,
+ struct pkt_attrib *pattrib)
+{
+ u8 qsel = 0;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+
+ if (pdvobj->nr_endpoint == 6)
+ qsel = pattrib->priority;
+ else if (pdvobj->nr_endpoint == 4)
+ qsel = pattrib->priority;
+ pattrib->qsel = qsel;
+}
+
+static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz)
+{
+ uint qsel;
+ struct _adapter *padapter = pxmitframe->padapter;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ struct tx_desc *ptxdesc = (struct tx_desc *)pmem;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+ u8 blnSetTxDescOffset;
+ sint bmcst = IS_MCAST(pattrib->ra);
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+ struct tx_desc txdesc_mp;
+
+ memcpy(&txdesc_mp, ptxdesc, sizeof(struct tx_desc));
+ memset(ptxdesc, 0, sizeof(struct tx_desc));
+ /* offset 0 */
+ ptxdesc->txdw0 |= cpu_to_le32(sz&0x0000ffff);
+ if (pdvobj->ishighspeed) {
+ if (((sz + TXDESC_SIZE) % 512) == 0)
+ blnSetTxDescOffset = 1;
+ else
+ blnSetTxDescOffset = 0;
+ } else {
+ if (((sz + TXDESC_SIZE) % 64) == 0)
+ blnSetTxDescOffset = 1;
+ else
+ blnSetTxDescOffset = 0;
+ }
+ if (blnSetTxDescOffset) {
+ /* 32 bytes for TX Desc + 8 bytes pending */
+ ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ + 8) <<
+ OFFSET_SHT) & 0x00ff0000);
+ } else {
+ /* default = 32 bytes for TX Desc */
+ ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ) <<
+ OFFSET_SHT) & 0x00ff0000);
+ }
+ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
+ if (pxmitframe->frame_tag == DATA_FRAMETAG) {
+ /* offset 4 */
+ ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id)&0x1f);
+ qsel = (uint)(pattrib->qsel & 0x0000001f);
+ ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
+ if (!pqospriv->qos_option)
+ ptxdesc->txdw1 |= cpu_to_le32(BIT(16));/*Non-QoS*/
+ if ((pattrib->encrypt > 0) && !pattrib->bswenc) {
+ switch (pattrib->encrypt) { /*SEC_TYPE*/
+ case _WEP40_:
+ case _WEP104_:
+ ptxdesc->txdw1 |= cpu_to_le32((0x01 << 22) &
+ 0x00c00000);
+ /*KEY_ID when WEP is used;*/
+ ptxdesc->txdw1 |= cpu_to_le32((psecuritypriv->
+ PrivacyKeyIndex << 17) &
+ 0x00060000);
+ break;
+ case _TKIP_:
+ case _TKIP_WTMIC_:
+ ptxdesc->txdw1 |= cpu_to_le32((0x02 << 22) &
+ 0x00c00000);
+ break;
+ case _AES_:
+ ptxdesc->txdw1 |= cpu_to_le32((0x03 << 22) &
+ 0x00c00000);
+ break;
+ case _NO_PRIVACY_:
+ default:
+ break;
+ }
+ }
+ /*offset 8*/
+ if (bmcst)
+ ptxdesc->txdw2 |= cpu_to_le32(BMC);
+
+ /*offset 12*/
+ /* f/w will increase the seqnum by itself, driver pass the
+ * correct priority to fw
+ * fw will check the correct priority for increasing the
+ * seqnum per tid. about usb using 4-endpoint, qsel points out
+ * the correct mapping between AC&Endpoint,
+ * the purpose is that correct mapping lets the MAC release
+ * the AC Queue list correctly. */
+ ptxdesc->txdw3 = cpu_to_le32((pattrib->priority << SEQ_SHT) &
+ 0x0fff0000);
+ if ((pattrib->ether_type != 0x888e) &&
+ (pattrib->ether_type != 0x0806) &&
+ (pattrib->dhcp_pkt != 1)) {
+ /*Not EAP & ARP type data packet*/
+ if (phtpriv->ht_option == 1) { /*B/G/N Mode*/
+ if (phtpriv->ampdu_enable != true)
+ ptxdesc->txdw2 |= cpu_to_le32(BK);
+ }
+ } else {
+ /* EAP data packet and ARP packet.
+ * Use the 1M data rate to send the EAP/ARP packet.
+ * This will maybe make the handshake smooth.
+ */
+ /*driver uses data rate*/
+ ptxdesc->txdw4 = cpu_to_le32(0x80000000);
+ ptxdesc->txdw5 = cpu_to_le32(0x001f8000);/*1M*/
+ }
+ if (pattrib->pctrl == 1) { /* mp tx packets */
+ struct tx_desc *ptxdesc_mp;
+ ptxdesc_mp = &txdesc_mp;
+ /* offset 8 */
+ ptxdesc->txdw2 = cpu_to_le32(ptxdesc_mp->txdw2);
+ if (bmcst)
+ ptxdesc->txdw2 |= cpu_to_le32(BMC);
+ ptxdesc->txdw2 |= cpu_to_le32(BK);
+ /* offset 16 */
+ ptxdesc->txdw4 = cpu_to_le32(ptxdesc_mp->txdw4);
+ /* offset 20 */
+ ptxdesc->txdw5 = cpu_to_le32(ptxdesc_mp->txdw5);
+ pattrib->pctrl = 0;/* reset to zero; */
+ }
+ } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) {
+ /* offset 4 */
+ ptxdesc->txdw1 |= (0x05) & 0x1f;/*CAM_ID(MAC_ID), default=5;*/
+ qsel = (uint)(pattrib->qsel & 0x0000001f);
+ ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
+ ptxdesc->txdw1 |= cpu_to_le32(BIT(16));/* Non-QoS */
+ /* offset 8 */
+ if (bmcst)
+ ptxdesc->txdw2 |= cpu_to_le32(BMC);
+ /* offset 12 */
+ /* f/w will increase the seqnum by itself, driver pass the
+ * correct priority to fw
+ * fw will check the correct priority for increasing the seqnum
+ * per tid. about usb using 4-endpoint, qsel points out the
+ * correct mapping between AC&Endpoint,
+ * the purpose is that correct mapping let the MAC releases
+ * the AC Queue list correctly. */
+ ptxdesc->txdw3 = cpu_to_le32((pattrib->priority << SEQ_SHT) &
+ 0x0fff0000);
+ /* offset 16 */
+ ptxdesc->txdw4 = cpu_to_le32(0x80002040);/*gtest*/
+ /* offset 20 */
+ ptxdesc->txdw5 = cpu_to_le32(0x001f8000);/* gtest 1M */
+ } else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) {
+ /* offset 4 */
+ qsel = 0x13;
+ ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
+ } else {
+ /* offset 4 */
+ qsel = (uint)(pattrib->priority&0x0000001f);
+ ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
+ /*offset 8*/
+ /*offset 12*/
+ ptxdesc->txdw3 = cpu_to_le32((pattrib->seqnum << SEQ_SHT) &
+ 0x0fff0000);
+ /*offset 16*/
+ ptxdesc->txdw4 = cpu_to_le32(0x80002040);/*gtest*/
+ /*offset 20*/
+ ptxdesc->txdw5 = cpu_to_le32(0x001f9600);/*gtest*/
+ }
+}
+
+int r8712_xmitframe_complete(struct _adapter *padapter,
+ struct xmit_priv *pxmitpriv,
+ struct xmit_buf *pxmitbuf)
+{
+ struct hw_xmit *phwxmits;
+ sint hwentry;
+ struct xmit_frame *pxmitframe = NULL;
+ int res = _SUCCESS, xcnt = 0;
+
+ phwxmits = pxmitpriv->hwxmits;
+ hwentry = pxmitpriv->hwxmit_entry;
+ if (pxmitbuf == NULL) {
+ pxmitbuf = r8712_alloc_xmitbuf(pxmitpriv);
+ if (!pxmitbuf)
+ return false;
+ }
+ do {
+ pxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, hwentry);
+ if (pxmitframe) {
+ pxmitframe->pxmitbuf = pxmitbuf;
+ pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0];
+ pxmitframe->buf_addr = pxmitbuf->pbuf;
+ if (pxmitframe->frame_tag == DATA_FRAMETAG) {
+ if (pxmitframe->attrib.priority <= 15)
+ res = r8712_xmitframe_coalesce(padapter,
+ pxmitframe->pkt, pxmitframe);
+ /* always return ndis_packet after
+ * r8712_xmitframe_coalesce */
+ r8712_xmit_complete(padapter, pxmitframe);
+ }
+ if (res == _SUCCESS)
+ dump_xframe(padapter, pxmitframe);
+ else
+ r8712_free_xmitframe_ex(pxmitpriv, pxmitframe);
+ xcnt++;
+ } else {
+ r8712_free_xmitbuf(pxmitpriv, pxmitbuf);
+ return false;
+ }
+ break;
+ } while (0);
+ return true;
+}
+
+static void dump_xframe(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe)
+{
+ int t, sz, w_sz;
+ u8 *mem_addr;
+ u32 ff_hwaddr;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ if (pxmitframe->attrib.ether_type != 0x0806) {
+ if (pxmitframe->attrib.ether_type != 0x888e)
+ r8712_issue_addbareq_cmd(padapter, pattrib->priority);
+ }
+ mem_addr = pxmitframe->buf_addr;
+ for (t = 0; t < pattrib->nr_frags; t++) {
+ if (t != (pattrib->nr_frags - 1)) {
+ sz = pxmitpriv->frag_len;
+ sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 :
+ pattrib->icv_len);
+ pxmitframe->last[t] = 0;
+ } else {
+ sz = pattrib->last_txcmdsz;
+ pxmitframe->last[t] = 1;
+ }
+ update_txdesc(pxmitframe, (uint *)mem_addr, sz);
+ w_sz = sz + TXDESC_SIZE;
+ pxmitframe->mem_addr = mem_addr;
+ pxmitframe->bpending[t] = false;
+ ff_hwaddr = get_ff_hwaddr(pxmitframe);
+ r8712_write_port(padapter, ff_hwaddr, w_sz,
+ (unsigned char *)pxmitframe);
+ mem_addr += w_sz;
+ mem_addr = (u8 *)RND4(((addr_t)(mem_addr)));
+ }
+}
+
+int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe)
+{
+ int res = _SUCCESS;
+
+ res = r8712_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe);
+ pxmitframe->pkt = NULL;
+ if (res == _SUCCESS)
+ dump_xframe(padapter, pxmitframe);
+ return res;
+}
+
+int r8712_xmit_enqueue(struct _adapter *padapter, struct xmit_frame *pxmitframe)
+{
+ if (r8712_xmit_classifier(padapter, pxmitframe) == _FAIL) {
+ pxmitframe->pkt = NULL;
+ return _FAIL;
+ }
+ return _SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.h b/drivers/staging/rtl8712/rtl8712_xmit.h
new file mode 100644
index 000000000000..5d77c5107242
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl8712_xmit.h
@@ -0,0 +1,95 @@
+#ifndef _RTL8712_XMIT_H_
+#define _RTL8712_XMIT_H_
+
+#define HWXMIT_ENTRY 4
+
+#define VO_QUEUE_INX 0
+#define VI_QUEUE_INX 1
+#define BE_QUEUE_INX 2
+#define BK_QUEUE_INX 3
+#define TS_QUEUE_INX 4
+#define MGT_QUEUE_INX 5
+#define BMC_QUEUE_INX 6
+#define BCN_QUEUE_INX 7
+
+#define HW_QUEUE_ENTRY 8
+
+#define TXDESC_SIZE 32
+#define TXDESC_OFFSET TXDESC_SIZE
+
+#define NR_AMSDU_XMITFRAME 8
+#define NR_TXAGG_XMITFRAME 8
+
+#define MAX_AMSDU_XMITBUF_SZ 8704
+#define MAX_TXAGG_XMITBUF_SZ 16384 /*16k*/
+
+
+#define tx_cmd tx_desc
+
+
+/*
+ *defined for TX DESC Operation
+ */
+
+#define MAX_TID (15)
+
+/*OFFSET 0*/
+#define OFFSET_SZ (0)
+#define OFFSET_SHT (16)
+#define OWN BIT(31)
+#define FSG BIT(27)
+#define LSG BIT(26)
+
+/*OFFSET 4*/
+#define PKT_OFFSET_SZ (0)
+#define QSEL_SHT (8)
+#define HWPC BIT(31)
+
+/*OFFSET 8*/
+#define BMC BIT(7)
+#define BK BIT(30)
+#define AGG_EN BIT(29)
+
+/*OFFSET 12*/
+#define SEQ_SHT (16)
+
+/*OFFSET 16*/
+#define TXBW BIT(18)
+
+/*OFFSET 20*/
+#define DISFB BIT(15)
+
+struct tx_desc{
+
+ /*DWORD 0*/
+ unsigned int txdw0;
+
+ unsigned int txdw1;
+
+ unsigned int txdw2;
+
+ unsigned int txdw3;
+
+ unsigned int txdw4;
+
+ unsigned int txdw5;
+
+ unsigned int txdw6;
+
+ unsigned int txdw7;
+
+};
+
+
+union txdesc {
+ struct tx_desc txdesc;
+ unsigned int value[TXDESC_SIZE>>2];
+};
+
+int r8712_xmitframe_complete(struct _adapter *padapter,
+ struct xmit_priv *pxmitpriv,
+ struct xmit_buf *pxmitbuf);
+void r8712_do_queue_select(struct _adapter *padapter,
+ struct pkt_attrib *pattrib);
+
+#endif
diff --git a/drivers/staging/rtl8712/rtl871x_byteorder.h b/drivers/staging/rtl8712/rtl871x_byteorder.h
new file mode 100644
index 000000000000..07707e23dbed
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_byteorder.h
@@ -0,0 +1,13 @@
+#ifndef _RTL871X_BYTEORDER_H_
+#define _RTL871X_BYTEORDER_H_
+
+#if defined(__LITTLE_ENDIAN)
+# include "little_endian.h"
+#elif defined(__BIG_ENDIAN)
+# include "big_endian.h"
+#else
+# error "Must be LITTLE/BIG Endian Host"
+#endif
+
+#endif /* _RTL871X_BYTEORDER_H_ */
+
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
new file mode 100644
index 000000000000..fbb2e4eaae51
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -0,0 +1,926 @@
+/******************************************************************************
+ * rtl871x_cmd.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_CMD_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "mlme_osdep.h"
+#include "rtl871x_byteorder.h"
+
+/*
+Caller and the r8712_cmd_thread can protect cmd_q by spin_lock.
+No irqsave is necessary.
+*/
+
+static sint _init_cmd_priv(struct cmd_priv *pcmdpriv)
+{
+ sema_init(&(pcmdpriv->cmd_queue_sema), 0);
+ sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
+
+ _init_queue(&(pcmdpriv->cmd_queue));
+
+ /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
+ pcmdpriv->cmd_seq = 1;
+ pcmdpriv->cmd_allocated_buf = _malloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ);
+ if (pcmdpriv->cmd_allocated_buf == NULL)
+ return _FAIL;
+ pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ -
+ ((addr_t)(pcmdpriv->cmd_allocated_buf) &
+ (CMDBUFF_ALIGN_SZ-1));
+ pcmdpriv->rsp_allocated_buf = _malloc(MAX_RSPSZ + 4);
+ if (pcmdpriv->rsp_allocated_buf == NULL)
+ return _FAIL;
+ pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 -
+ ((addr_t)(pcmdpriv->rsp_allocated_buf) & 3);
+ pcmdpriv->cmd_issued_cnt = 0;
+ pcmdpriv->cmd_done_cnt = 0;
+ pcmdpriv->rsp_cnt = 0;
+ return _SUCCESS;
+}
+
+static sint _init_evt_priv(struct evt_priv *pevtpriv)
+{
+ /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
+ pevtpriv->event_seq = 0;
+ pevtpriv->evt_allocated_buf = _malloc(MAX_EVTSZ + 4);
+
+ if (pevtpriv->evt_allocated_buf == NULL)
+ return _FAIL;
+ pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 -
+ ((addr_t)(pevtpriv->evt_allocated_buf) & 3);
+ pevtpriv->evt_done_cnt = 0;
+ return _SUCCESS;
+}
+
+static void _free_evt_priv(struct evt_priv *pevtpriv)
+{
+ kfree(pevtpriv->evt_allocated_buf);
+}
+
+static void _free_cmd_priv(struct cmd_priv *pcmdpriv)
+{
+ if (pcmdpriv) {
+ kfree(pcmdpriv->cmd_allocated_buf);
+ kfree(pcmdpriv->rsp_allocated_buf);
+ }
+}
+
+/*
+Calling Context:
+
+_enqueue_cmd can only be called between kernel thread,
+since only spin_lock is used.
+
+ISR/Call-Back functions can't call this sub-function.
+
+*/
+
+static sint _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
+{
+ unsigned long irqL;
+
+ if (obj == NULL)
+ return _SUCCESS;
+ spin_lock_irqsave(&queue->lock, irqL);
+ list_insert_tail(&obj->list, &queue->queue);
+ spin_unlock_irqrestore(&queue->lock, irqL);
+ return _SUCCESS;
+}
+
+static struct cmd_obj *_dequeue_cmd(struct __queue *queue)
+{
+ unsigned long irqL;
+ struct cmd_obj *obj;
+
+ spin_lock_irqsave(&(queue->lock), irqL);
+ if (is_list_empty(&(queue->queue)))
+ obj = NULL;
+ else {
+ obj = LIST_CONTAINOR(get_next(&(queue->queue)),
+ struct cmd_obj, list);
+ list_delete(&obj->list);
+ }
+ spin_unlock_irqrestore(&(queue->lock), irqL);
+ return obj;
+}
+
+u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv)
+{
+ return _init_cmd_priv(pcmdpriv);
+}
+
+u32 r8712_init_evt_priv(struct evt_priv *pevtpriv)
+{
+ return _init_evt_priv(pevtpriv);
+}
+
+void r8712_free_evt_priv(struct evt_priv *pevtpriv)
+{
+ _free_evt_priv(pevtpriv);
+}
+
+void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv)
+{
+ _free_cmd_priv(pcmdpriv);
+}
+
+u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj)
+{
+ int res;
+
+ if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true)
+ return _FAIL;
+ res = _enqueue_cmd(&pcmdpriv->cmd_queue, obj);
+ up(&pcmdpriv->cmd_queue_sema);
+ return res;
+}
+
+u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj)
+{
+ unsigned long irqL;
+ struct __queue *queue;
+
+ if (obj == NULL)
+ return _SUCCESS;
+ if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true)
+ return _FAIL;
+ queue = &pcmdpriv->cmd_queue;
+ spin_lock_irqsave(&queue->lock, irqL);
+ list_insert_tail(&obj->list, &queue->queue);
+ spin_unlock_irqrestore(&queue->lock, irqL);
+ up(&pcmdpriv->cmd_queue_sema);
+ return _SUCCESS;
+}
+
+struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue)
+{
+ return _dequeue_cmd(queue);
+}
+
+void r8712_free_cmd_obj(struct cmd_obj *pcmd)
+{
+ if ((pcmd->cmdcode != _JoinBss_CMD_) &&
+ (pcmd->cmdcode != _CreateBss_CMD_))
+ kfree((unsigned char *)pcmd->parmbuf);
+ if (pcmd->rsp != NULL) {
+ if (pcmd->rspsz != 0)
+ kfree((unsigned char *)pcmd->rsp);
+ }
+ kfree((unsigned char *)pcmd);
+}
+
+/*
+r8712_sitesurvey_cmd(~)
+ ### NOTE:#### (!!!!)
+ MUST TAKE CARE THAT BEFORE CALLING THIS FUNC,
+ YOU SHOULD HAVE LOCKED pmlmepriv->lock
+*/
+u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
+ struct ndis_802_11_ssid *pssid)
+{
+ struct cmd_obj *ph2c;
+ struct sitesurvey_parm *psurveyPara;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psurveyPara = (struct sitesurvey_parm *)_malloc(
+ sizeof(struct sitesurvey_parm));
+ if (psurveyPara == NULL) {
+ kfree((unsigned char *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara,
+ GEN_CMD_CODE(_SiteSurvey));
+ psurveyPara->bsslimit = cpu_to_le32(48);
+ psurveyPara->passive_mode = cpu_to_le32(1);
+ psurveyPara->ss_ssidlen = 0;
+ memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1);
+ if ((pssid != NULL) && (pssid->SsidLength)) {
+ memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength);
+ psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength);
+ }
+ set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY);
+ return _SUCCESS;
+}
+
+u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset)
+{
+ struct cmd_obj *ph2c;
+ struct setdatarate_parm *pbsetdataratepara;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ pbsetdataratepara = (struct setdatarate_parm *)_malloc(
+ sizeof(struct setdatarate_parm));
+ if (pbsetdataratepara == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara,
+ GEN_CMD_CODE(_SetDataRate));
+ pbsetdataratepara->mac_id = 5;
+ memcpy(pbsetdataratepara->datarates, rateset, NumRates);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset)
+{
+ struct cmd_obj *ph2c;
+ struct setbasicrate_parm *pssetbasicratepara;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ pssetbasicratepara = (struct setbasicrate_parm *)_malloc(
+ sizeof(struct setbasicrate_parm));
+ if (pssetbasicratepara == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara,
+ _SetBasicRate_CMD_);
+ memcpy(pssetbasicratepara->basicrates, rateset, NumRates);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+/* power tracking mechanism setting */
+u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type)
+{
+ struct cmd_obj *ph2c;
+ struct PT_param *pptparm;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ pptparm = (struct PT_param *)_malloc(sizeof(struct PT_param));
+ if (pptparm == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, pptparm,
+ GEN_CMD_CODE(_SetPowerTracking));
+ pptparm->PT_En = type;
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val)
+{
+ struct cmd_obj *ph2c;
+ struct writeRF_parm *pwriterfparm;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ pwriterfparm = (struct writeRF_parm *)_malloc(
+ sizeof(struct writeRF_parm));
+ if (pwriterfparm == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg));
+ pwriterfparm->offset = offset;
+ pwriterfparm->value = val;
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval)
+{
+ struct cmd_obj *ph2c;
+ struct readRF_parm *prdrfparm;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ prdrfparm = (struct readRF_parm *)_malloc(sizeof(struct readRF_parm));
+ if (prdrfparm == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ _init_listhead(&ph2c->list);
+ ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg);
+ ph2c->parmbuf = (unsigned char *)prdrfparm;
+ ph2c->cmdsz = sizeof(struct readRF_parm);
+ ph2c->rsp = pval;
+ ph2c->rspsz = sizeof(struct readRF_rsp);
+ prdrfparm->offset = offset;
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ kfree((unsigned char *) pcmd->parmbuf);
+ kfree((unsigned char *) pcmd);
+ padapter->mppriv.workparam.bcompleted = true;
+}
+
+u8 r8712_createbss_cmd(struct _adapter *padapter)
+{
+ struct cmd_obj *pcmd;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct wlan_bssid_ex *pdev_network =
+ &padapter->registrypriv.dev_network;
+
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
+ pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pcmd == NULL)
+ return _FAIL;
+ _init_listhead(&pcmd->list);
+ pcmd->cmdcode = _CreateBss_CMD_;
+ pcmd->parmbuf = (unsigned char *)pdev_network;
+ pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz((
+ struct ndis_wlan_bssid_ex *)
+ pdev_network);
+ pcmd->rsp = NULL;
+ pcmd->rspsz = 0;
+ /* notes: translate IELength & Length after assign to cmdsz; */
+ pdev_network->Length = cpu_to_le32(pcmd->cmdsz);
+ pdev_network->IELength = cpu_to_le32(pdev_network->IELength);
+ pdev_network->Ssid.SsidLength = cpu_to_le32(
+ pdev_network->Ssid.SsidLength);
+ r8712_enqueue_cmd(pcmdpriv, pcmd);
+ return _SUCCESS;
+}
+
+u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork)
+{
+ u8 *auth;
+ uint t_len = 0;
+ struct ndis_wlan_bssid_ex *psecnetwork;
+ struct cmd_obj *pcmd;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->
+ network.InfrastructureMode;
+
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
+ pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pcmd == NULL)
+ return _FAIL;
+ t_len = sizeof(u32) + 6 * sizeof(unsigned char) + 2 +
+ sizeof(struct ndis_802_11_ssid) + sizeof(u32) +
+ sizeof(s32) +
+ sizeof(enum NDIS_802_11_NETWORK_TYPE) +
+ sizeof(struct NDIS_802_11_CONFIGURATION) +
+ sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) +
+ sizeof(NDIS_802_11_RATES_EX) +
+ sizeof(u32) + MAX_IE_SZ;
+
+ /* for hidden ap to set fw_state here */
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) !=
+ true) {
+ switch (ndis_network_mode) {
+ case Ndis802_11IBSS:
+ pmlmepriv->fw_state |= WIFI_ADHOC_STATE;
+ break;
+ case Ndis802_11Infrastructure:
+ pmlmepriv->fw_state |= WIFI_STATION_STATE;
+ break;
+ case Ndis802_11APMode:
+ case Ndis802_11AutoUnknown:
+ case Ndis802_11InfrastructureMax:
+ break;
+ }
+ }
+ psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss;
+ if (psecnetwork == NULL) {
+ if (pcmd != NULL)
+ kfree((unsigned char *)pcmd);
+ return _FAIL;
+ }
+ memset(psecnetwork, 0, t_len);
+ memcpy(psecnetwork, &pnetwork->network, t_len);
+ auth = &psecuritypriv->authenticator_ie[0];
+ psecuritypriv->authenticator_ie[0] = (unsigned char)
+ psecnetwork->IELength;
+ if ((psecnetwork->IELength-12) < (256 - 1))
+ memcpy(&psecuritypriv->authenticator_ie[1],
+ &psecnetwork->IEs[12], psecnetwork->IELength-12);
+ else
+ memcpy(&psecuritypriv->authenticator_ie[1],
+ &psecnetwork->IEs[12], (256-1));
+ psecnetwork->IELength = 0;
+ /* If the the driver wants to use the bssid to create the connection.
+ * If not, we copy the connecting AP's MAC address to it so that
+ * the driver just has the bssid information for PMKIDList searching.
+ */
+ if (pmlmepriv->assoc_by_bssid == false)
+ memcpy(&pmlmepriv->assoc_bssid[0],
+ &pnetwork->network.MacAddress[0], ETH_ALEN);
+ psecnetwork->IELength = r8712_restruct_sec_ie(padapter,
+ &pnetwork->network.IEs[0],
+ &psecnetwork->IEs[0],
+ pnetwork->network.IELength);
+ pqospriv->qos_option = 0;
+ if (pregistrypriv->wmm_enable) {
+ u32 tmp_len;
+
+ tmp_len = r8712_restruct_wmm_ie(padapter,
+ &pnetwork->network.IEs[0],
+ &psecnetwork->IEs[0],
+ pnetwork->network.IELength,
+ psecnetwork->IELength);
+ if (psecnetwork->IELength != tmp_len) {
+ psecnetwork->IELength = tmp_len;
+ pqospriv->qos_option = 1; /* WMM IE in beacon */
+ } else
+ pqospriv->qos_option = 0; /* no WMM IE in beacon */
+ }
+ if (pregistrypriv->ht_enable) {
+ /* For WEP mode, we will use the bg mode to do the connection
+ * to avoid some IOT issues, especially for Realtek 8192u
+ * SoftAP.
+ */
+ if ((padapter->securitypriv.PrivacyAlgrthm != _WEP40_ ) &&
+ (padapter->securitypriv.PrivacyAlgrthm != _WEP104_ )) {
+ /* restructure_ht_ie */
+ r8712_restructure_ht_ie(padapter,
+ &pnetwork->network.IEs[0],
+ &psecnetwork->IEs[0],
+ pnetwork->network.IELength,
+ &psecnetwork->IELength);
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
+ r8712_add_ht_addt_info(padapter,
+ &pnetwork->network.IEs[0],
+ &psecnetwork->IEs[0],
+ pnetwork->network.IELength,
+ &psecnetwork->IELength);
+ }
+ }
+ psecuritypriv->supplicant_ie[0] = (u8)psecnetwork->IELength;
+ if (psecnetwork->IELength < 255)
+ memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0],
+ psecnetwork->IELength);
+ else
+ memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0],
+ 255);
+ /* get cmdsz before endian conversion */
+ pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(psecnetwork);
+#ifdef __BIG_ENDIAN
+ /* wlan_network endian conversion */
+ psecnetwork->Length = cpu_to_le32(psecnetwork->Length);
+ psecnetwork->Ssid.SsidLength = cpu_to_le32(
+ psecnetwork->Ssid.SsidLength);
+ psecnetwork->Privacy = cpu_to_le32(psecnetwork->Privacy);
+ psecnetwork->Rssi = cpu_to_le32(psecnetwork->Rssi);
+ psecnetwork->NetworkTypeInUse = cpu_to_le32(
+ psecnetwork->NetworkTypeInUse);
+ psecnetwork->Configuration.ATIMWindow = cpu_to_le32(
+ psecnetwork->Configuration.ATIMWindow);
+ psecnetwork->Configuration.BeaconPeriod = cpu_to_le32(
+ psecnetwork->Configuration.BeaconPeriod);
+ psecnetwork->Configuration.DSConfig = cpu_to_le32(
+ psecnetwork->Configuration.DSConfig);
+ psecnetwork->Configuration.FHConfig.DwellTime = cpu_to_le32(
+ psecnetwork->Configuration.FHConfig.DwellTime);
+ psecnetwork->Configuration.FHConfig.HopPattern = cpu_to_le32(
+ psecnetwork->Configuration.FHConfig.HopPattern);
+ psecnetwork->Configuration.FHConfig.HopSet = cpu_to_le32(
+ psecnetwork->Configuration.FHConfig.HopSet);
+ psecnetwork->Configuration.FHConfig.Length = cpu_to_le32(
+ psecnetwork->Configuration.FHConfig.Length);
+ psecnetwork->Configuration.Length = cpu_to_le32(
+ psecnetwork->Configuration.Length);
+ psecnetwork->InfrastructureMode = cpu_to_le32(
+ psecnetwork->InfrastructureMode);
+ psecnetwork->IELength = cpu_to_le32(psecnetwork->IELength);
+#endif
+ _init_listhead(&pcmd->list);
+ pcmd->cmdcode = _JoinBss_CMD_;
+ pcmd->parmbuf = (unsigned char *)psecnetwork;
+ pcmd->rsp = NULL;
+ pcmd->rspsz = 0;
+ r8712_enqueue_cmd(pcmdpriv, pcmd);
+ return _SUCCESS;
+}
+
+u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */
+{
+ struct cmd_obj *pdisconnect_cmd;
+ struct disconnect_parm *pdisconnect;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ pdisconnect_cmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pdisconnect_cmd == NULL)
+ return _FAIL;
+ pdisconnect = (struct disconnect_parm *)_malloc(
+ sizeof(struct disconnect_parm));
+ if (pdisconnect == NULL) {
+ kfree((u8 *)pdisconnect_cmd);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect,
+ _DisConnect_CMD_);
+ r8712_enqueue_cmd(pcmdpriv, pdisconnect_cmd);
+ return _SUCCESS;
+}
+
+u8 r8712_setopmode_cmd(struct _adapter *padapter,
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
+{
+ struct cmd_obj *ph2c;
+ struct setopmode_parm *psetop;
+
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetop = (struct setopmode_parm *)_malloc(
+ sizeof(struct setopmode_parm));
+ if (psetop == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
+ psetop->mode = (u8)networktype;
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key)
+{
+ struct cmd_obj *ph2c;
+ struct set_stakey_parm *psetstakey_para;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct set_stakey_rsp *psetstakey_rsp = NULL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct sta_info *sta = (struct sta_info *)psta;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetstakey_para = (struct set_stakey_parm *)_malloc(
+ sizeof(struct set_stakey_parm));
+ if (psetstakey_para == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ psetstakey_rsp = (struct set_stakey_rsp *)_malloc(
+ sizeof(struct set_stakey_rsp));
+ if (psetstakey_rsp == NULL) {
+ kfree((u8 *) ph2c);
+ kfree((u8 *) psetstakey_para);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
+ ph2c->rsp = (u8 *) psetstakey_rsp;
+ ph2c->rspsz = sizeof(struct set_stakey_rsp);
+ memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
+ psetstakey_para->algorithm = (unsigned char)
+ psecuritypriv->PrivacyAlgrthm;
+ else
+ GET_ENCRY_ALGO(psecuritypriv, sta,
+ psetstakey_para->algorithm, false);
+ if (unicast_key == true)
+ memcpy(&psetstakey_para->key, &sta->x_UncstKey, 16);
+ else
+ memcpy(&psetstakey_para->key,
+ &psecuritypriv->XGrpKey[
+ psecuritypriv->XGrpKeyid - 1]. skey, 16);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode)
+{
+ struct cmd_obj *ph2c;
+ struct setrfintfs_parm *psetrfintfsparm;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetrfintfsparm = (struct setrfintfs_parm *)_malloc(
+ sizeof(struct setrfintfs_parm));
+ if (psetrfintfsparm == NULL) {
+ kfree((unsigned char *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm,
+ GEN_CMD_CODE(_SetRFIntFs));
+ psetrfintfsparm->rfintfs = mode;
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setrttbl_cmd(struct _adapter *padapter,
+ struct setratable_parm *prate_table)
+{
+ struct cmd_obj *ph2c;
+ struct setratable_parm *psetrttblparm;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetrttblparm = (struct setratable_parm *)_malloc(
+ sizeof(struct setratable_parm));
+ if (psetrttblparm == NULL) {
+ kfree((unsigned char *)ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm,
+ GEN_CMD_CODE(_SetRaTable));
+ memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm));
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr)
+{
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct cmd_obj *ph2c;
+ struct SetMacAddr_param *psetMacAddr_para;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetMacAddr_para = (struct SetMacAddr_param *)_malloc(
+ sizeof(struct SetMacAddr_param));
+ if (psetMacAddr_para == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para,
+ _SetMacAddress_CMD_);
+ memcpy(psetMacAddr_para->MacAddr, mac_addr, ETH_ALEN);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr)
+{
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct cmd_obj *ph2c;
+ struct set_assocsta_parm *psetassocsta_para;
+ struct set_stakey_rsp *psetassocsta_rsp = NULL;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ psetassocsta_para = (struct set_assocsta_parm *)
+ _malloc(sizeof(struct set_assocsta_parm));
+ if (psetassocsta_para == NULL) {
+ kfree((u8 *) ph2c);
+ return _FAIL;
+ }
+ psetassocsta_rsp = (struct set_stakey_rsp *)_malloc(
+ sizeof(struct set_assocsta_rsp));
+ if (psetassocsta_rsp == NULL) {
+ kfree((u8 *)ph2c);
+ kfree((u8 *)psetassocsta_para);
+ return _FAIL;
+ }
+ init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_);
+ ph2c->rsp = (u8 *) psetassocsta_rsp;
+ ph2c->rspsz = sizeof(struct set_assocsta_rsp);
+ memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN);
+ r8712_enqueue_cmd(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid)
+{
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+ struct cmd_obj *ph2c;
+ struct addBaReq_parm *paddbareq_parm;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ paddbareq_parm = (struct addBaReq_parm *)_malloc(
+ sizeof(struct addBaReq_parm));
+ if (paddbareq_parm == NULL) {
+ kfree((unsigned char *)ph2c);
+ return _FAIL;
+ }
+ paddbareq_parm->tid = tid;
+ init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm,
+ GEN_CMD_CODE(_AddBAReq));
+ r8712_enqueue_cmd_ex(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+u8 r8712_wdg_wk_cmd(struct _adapter *padapter)
+{
+ struct cmd_obj *ph2c;
+ struct drvint_cmd_parm *pdrvintcmd_param;
+ struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
+
+ ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (ph2c == NULL)
+ return _FAIL;
+ pdrvintcmd_param = (struct drvint_cmd_parm *)_malloc(
+ sizeof(struct drvint_cmd_parm));
+ if (pdrvintcmd_param == NULL) {
+ kfree((unsigned char *)ph2c);
+ return _FAIL;
+ }
+ pdrvintcmd_param->i_cid = WDG_WK_CID;
+ pdrvintcmd_param->sz = 0;
+ pdrvintcmd_param->pbuf = NULL;
+ init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvintcmd_param, _DRV_INT_CMD_);
+ r8712_enqueue_cmd_ex(pcmdpriv, ph2c);
+ return _SUCCESS;
+}
+
+void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ if (pcmd->res != H2C_SUCCESS)
+ clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
+ r8712_free_cmd_obj(pcmd);
+}
+
+void r8712_disassoc_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ if (pcmd->res != H2C_SUCCESS) {
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ set_fwstate(pmlmepriv, _FW_LINKED);
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return;
+ }
+ r8712_free_cmd_obj(pcmd);
+}
+
+void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ if ((pcmd->res != H2C_SUCCESS))
+ _set_timer(&pmlmepriv->assoc_timer, 1);
+ r8712_free_cmd_obj(pcmd);
+}
+
+void r8712_createbss_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ unsigned long irqL;
+ u8 timer_cancelled;
+ struct sta_info *psta = NULL;
+ struct wlan_network *pwlan = NULL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ndis_wlan_bssid_ex *pnetwork = (struct ndis_wlan_bssid_ex *)
+ pcmd->parmbuf;
+ struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
+
+ if ((pcmd->res != H2C_SUCCESS))
+ _set_timer(&pmlmepriv->assoc_timer, 1);
+ _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
+#ifdef __BIG_ENDIAN
+ /* endian_convert */
+ pnetwork->Length = le32_to_cpu(pnetwork->Length);
+ pnetwork->Ssid.SsidLength = le32_to_cpu(pnetwork->Ssid.SsidLength);
+ pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
+ pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
+ pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
+ pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork->
+ Configuration.ATIMWindow);
+ pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork->
+ Configuration.DSConfig);
+ pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->
+ Configuration.FHConfig.DwellTime);
+ pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->
+ Configuration.FHConfig.HopPattern);
+ pnetwork->Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork->
+ Configuration.FHConfig.HopSet);
+ pnetwork->Configuration.FHConfig.Length = le32_to_cpu(pnetwork->
+ Configuration.FHConfig.Length);
+ pnetwork->Configuration.Length = le32_to_cpu(pnetwork->
+ Configuration.Length);
+ pnetwork->InfrastructureMode = le32_to_cpu(pnetwork->
+ InfrastructureMode);
+ pnetwork->IELength = le32_to_cpu(pnetwork->IELength);
+#endif
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((pmlmepriv->fw_state) & WIFI_AP_STATE) {
+ psta = r8712_get_stainfo(&padapter->stapriv,
+ pnetwork->MacAddress);
+ if (!psta) {
+ psta = r8712_alloc_stainfo(&padapter->stapriv,
+ pnetwork->MacAddress);
+ if (psta == NULL)
+ goto createbss_cmd_fail ;
+ }
+ r8712_indicate_connect(padapter);
+ } else {
+ pwlan = _r8712_alloc_network(pmlmepriv);
+ if (pwlan == NULL) {
+ pwlan = r8712_get_oldest_wlan_network(
+ &pmlmepriv->scanned_queue);
+ if (pwlan == NULL)
+ goto createbss_cmd_fail;
+ pwlan->last_scanned = jiffies;
+ } else
+ list_insert_tail(&(pwlan->list),
+ &pmlmepriv->scanned_queue.queue);
+ pnetwork->Length = r8712_get_ndis_wlan_bssid_ex_sz(pnetwork);
+ memcpy(&(pwlan->network), pnetwork, pnetwork->Length);
+ pwlan->fixed = true;
+ memcpy(&tgt_network->network, pnetwork,
+ (r8712_get_ndis_wlan_bssid_ex_sz(pnetwork)));
+ if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
+ pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
+ /* we will set _FW_LINKED when there is one more sat to
+ * join us (stassoc_event_callback) */
+ }
+createbss_cmd_fail:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ r8712_free_cmd_obj(pcmd);
+}
+
+void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)
+ (pcmd->rsp);
+ struct sta_info *psta = r8712_get_stainfo(pstapriv,
+ psetstakey_rsp->addr);
+
+ if (psta == NULL)
+ goto exit;
+ psta->aid = psta->mac_id = psetstakey_rsp->keyid; /*CAM_ID(CAM_ENTRY)*/
+exit:
+ r8712_free_cmd_obj(pcmd);
+}
+
+void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd)
+{
+ unsigned long irqL;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct set_assocsta_parm *passocsta_parm =
+ (struct set_assocsta_parm *)(pcmd->parmbuf);
+ struct set_assocsta_rsp *passocsta_rsp =
+ (struct set_assocsta_rsp *) (pcmd->rsp);
+ struct sta_info *psta = r8712_get_stainfo(pstapriv,
+ passocsta_parm->addr);
+
+ if (psta == NULL)
+ return;
+ psta->aid = psta->mac_id = passocsta_rsp->cam_id;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((check_fwstate(pmlmepriv, WIFI_MP_STATE)) &&
+ (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)))
+ pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
+ set_fwstate(pmlmepriv, _FW_LINKED);
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ r8712_free_cmd_obj(pcmd);
+}
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
new file mode 100644
index 000000000000..3a945b5f0e01
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -0,0 +1,719 @@
+#ifndef __RTL871X_CMD_H_
+#define __RTL871X_CMD_H_
+
+#include "wlan_bssdef.h"
+#include "rtl871x_rf.h"
+#define C2H_MEM_SZ (16*1024)
+
+#include "osdep_service.h"
+#include "ieee80211.h"
+
+#define FREE_CMDOBJ_SZ 128
+#define MAX_CMDSZ 512
+#define MAX_RSPSZ 512
+#define MAX_EVTSZ 1024
+#define CMDBUFF_ALIGN_SZ 512
+
+struct cmd_obj {
+ u16 cmdcode;
+ u8 res;
+ u8 *parmbuf;
+ u32 cmdsz;
+ u8 *rsp;
+ u32 rspsz;
+ struct list_head list;
+};
+
+struct cmd_priv {
+ struct semaphore cmd_queue_sema;
+ struct semaphore terminate_cmdthread_sema;
+ struct __queue cmd_queue;
+ u8 cmd_seq;
+ u8 *cmd_buf; /*shall be non-paged, and 4 bytes aligned*/
+ u8 *cmd_allocated_buf;
+ u8 *rsp_buf; /*shall be non-paged, and 4 bytes aligned*/
+ u8 *rsp_allocated_buf;
+ u32 cmd_issued_cnt;
+ u32 cmd_done_cnt;
+ u32 rsp_cnt;
+ struct _adapter *padapter;
+};
+
+struct evt_obj {
+ u16 evtcode;
+ u8 res;
+ u8 *parmbuf;
+ u32 evtsz;
+ struct list_head list;
+};
+
+struct evt_priv {
+ struct __queue evt_queue;
+ u8 event_seq;
+ u8 *evt_buf; /*shall be non-paged, and 4 bytes aligned*/
+ u8 *evt_allocated_buf;
+ u32 evt_done_cnt;
+ struct tasklet_struct event_tasklet;
+};
+
+#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
+do {\
+ _init_listhead(&pcmd->list);\
+ pcmd->cmdcode = code;\
+ pcmd->parmbuf = (u8 *)(pparm);\
+ pcmd->cmdsz = sizeof(*pparm);\
+ pcmd->rsp = NULL;\
+ pcmd->rspsz = 0;\
+} while (0)
+
+u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
+u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
+struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue);
+void r8712_free_cmd_obj(struct cmd_obj *pcmd);
+int r8712_cmd_thread(void *context);
+u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv);
+void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv);
+u32 r8712_init_evt_priv(struct evt_priv *pevtpriv);
+void r8712_free_evt_priv(struct evt_priv *pevtpriv);
+
+enum rtl871x_drvint_cid {
+ NONE_WK_CID,
+ WDG_WK_CID,
+ MAX_WK_CID
+};
+
+enum RFINTFS {
+ SWSI,
+ HWSI,
+ HWPI,
+};
+
+/*
+ * Caller Mode: Infra, Ad-HoC(C)
+ * Notes: To enter USB suspend mode
+ * Command Mode
+ */
+struct usb_suspend_parm {
+ u32 action; /* 1: sleep, 0:resume */
+};
+
+/*
+ * Caller Mode: Infra, Ad-Hoc
+ * Notes: To join the specified bss
+ * Command Event Mode
+ */
+struct joinbss_parm {
+ struct ndis_wlan_bssid_ex network;
+};
+
+/*
+ * Caller Mode: Infra, Ad-HoC(C)
+ * Notes: To disconnect the current associated BSS
+ * Command Mode
+ */
+struct disconnect_parm {
+ u32 rsvd;
+};
+
+/*
+ * Caller Mode: AP, Ad-HoC(M)
+ * Notes: To create a BSS
+ * Command Mode
+ */
+struct createbss_parm {
+ struct ndis_wlan_bssid_ex network;
+};
+
+/*
+ * Caller Mode: AP, Ad-HoC, Infra
+ * Notes: To set the NIC mode of RTL8711
+ * Command Mode
+ * The definition of mode:
+ *
+ * #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
+ * #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
+ * #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
+ * #define IW_MODE_MASTER 3 // Synchronisation master or AP
+ * #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
+ * #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
+ * #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
+*/
+struct setopmode_parm {
+ u8 mode;
+ u8 rsvd[3];
+};
+
+/*
+ * Caller Mode: AP, Ad-HoC, Infra
+ * Notes: To ask RTL8711 performing site-survey
+ * Command-Event Mode
+ */
+struct sitesurvey_parm {
+ sint passive_mode; /*active: 1, passive: 0 */
+ sint bsslimit; /* 1 ~ 48 */
+ sint ss_ssidlen;
+ u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
+};
+
+/*
+ * Caller Mode: Any
+ * Notes: To set the auth type of RTL8711. open/shared/802.1x
+ * Command Mode
+ */
+struct setauth_parm {
+ u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
+ u8 _1x; /*0: PSK, 1: TLS*/
+ u8 rsvd[2];
+};
+
+/*
+ * Caller Mode: Infra
+ * a. algorithm: wep40, wep104, tkip & aes
+ * b. keytype: grp key/unicast key
+ * c. key contents
+ *
+ * when shared key ==> keyid is the camid
+ * when 802.1x ==> keyid [0:1] ==> grp key
+ * when 802.1x ==> keyid > 2 ==> unicast key
+ */
+struct setkey_parm {
+ u8 algorithm; /* encryption algorithm, could be none, wep40,
+ * TKIP, CCMP, wep104 */
+ u8 keyid;
+ u8 grpkey; /* 1: this is the grpkey for 802.1x.
+ * 0: this is the unicast key for 802.1x */
+ u8 key[16]; /* this could be 40 or 104 */
+};
+
+/*
+ * When in AP or Ad-Hoc mode, this is used to
+ * allocate an sw/hw entry for a newly associated sta.
+ * Command
+ * when shared key ==> algorithm/keyid
+ */
+struct set_stakey_parm {
+ u8 addr[ETH_ALEN];
+ u8 algorithm;
+ u8 key[16];
+};
+
+struct set_stakey_rsp {
+ u8 addr[ETH_ALEN];
+ u8 keyid;
+ u8 rsvd;
+};
+
+struct SetMacAddr_param {
+ u8 MacAddr[ETH_ALEN];
+};
+
+/*
+Caller Ad-Hoc/AP
+
+Command -Rsp(AID == CAMID) mode
+
+This is to force fw to add an sta_data entry per driver's request.
+
+FW will write an cam entry associated with it.
+
+*/
+struct set_assocsta_parm {
+ u8 addr[ETH_ALEN];
+};
+
+struct set_assocsta_rsp {
+ u8 cam_id;
+ u8 rsvd[3];
+};
+
+/*
+ Caller Ad-Hoc/AP
+
+ Command mode
+
+ This is to force fw to del an sta_data entry per driver's request
+
+ FW will invalidate the cam entry associated with it.
+
+*/
+struct del_assocsta_parm {
+ u8 addr[ETH_ALEN];
+};
+
+/*
+Caller Mode: AP/Ad-HoC(M)
+
+Notes: To notify fw that given staid has changed its power state
+
+Command Mode
+
+*/
+struct setstapwrstate_parm {
+ u8 staid;
+ u8 status;
+ u8 hwaddr[6];
+};
+
+/*
+Caller Mode: Any
+
+Notes: To setup the basic rate of RTL8711
+
+Command Mode
+
+*/
+struct setbasicrate_parm {
+ u8 basicrates[NumRates];
+};
+
+/*
+Caller Mode: Any
+
+Notes: To read the current basic rate
+
+Command-Rsp Mode
+
+*/
+struct getbasicrate_parm {
+ u32 rsvd;
+};
+
+struct getbasicrate_rsp {
+ u8 basicrates[NumRates];
+};
+
+/*
+Caller Mode: Any
+
+Notes: To setup the data rate of RTL8711
+
+Command Mode
+
+*/
+struct setdatarate_parm {
+ u8 mac_id;
+ u8 datarates[NumRates];
+};
+
+/*
+Caller Mode: Any
+
+Notes: To read the current data rate
+
+Command-Rsp Mode
+
+*/
+struct getdatarate_parm {
+ u32 rsvd;
+
+};
+struct getdatarate_rsp {
+ u8 datarates[NumRates];
+};
+
+
+/*
+Caller Mode: Any
+AP: AP can use the info for the contents of beacon frame
+Infra: STA can use the info when sitesurveying
+Ad-HoC(M): Like AP
+Ad-HoC(C): Like STA
+
+
+Notes: To set the phy capability of the NIC
+
+Command Mode
+
+*/
+
+/*
+Caller Mode: Any
+
+Notes: To set the channel/modem/band
+This command will be used when channel/modem/band is changed.
+
+Command Mode
+
+*/
+/*
+Caller Mode: Any
+
+Notes: To get the current setting of channel/modem/band
+
+Command-Rsp Mode
+
+*/
+struct getphy_rsp {
+ u8 rfchannel;
+ u8 modem;
+};
+
+struct readBB_parm {
+ u8 offset;
+};
+struct readBB_rsp {
+ u8 value;
+};
+
+struct readTSSI_parm {
+ u8 offset;
+};
+struct readTSSI_rsp {
+ u8 value;
+};
+
+struct writeBB_parm {
+ u8 offset;
+ u8 value;
+};
+
+struct readRF_parm {
+ u8 offset;
+};
+struct readRF_rsp {
+ u32 value;
+};
+
+struct writeRF_parm {
+ u32 offset;
+ u32 value;
+};
+
+struct setrfintfs_parm {
+ u8 rfintfs;
+};
+
+struct getrfintfs_parm {
+ u8 rfintfs;
+};
+
+/*
+ Notes: This command is used for H2C/C2H loopback testing
+
+ mac[0] == 0
+ ==> CMD mode, return H2C_SUCCESS.
+ The following condition must be ture under CMD mode
+ mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
+ s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
+ s2 == (b1 << 8 | b0);
+
+ mac[0] == 1
+ ==> CMD_RSP mode, return H2C_SUCCESS_RSP
+
+ The rsp layout shall be:
+ rsp: parm:
+ mac[0] = mac[5];
+ mac[1] = mac[4];
+ mac[2] = mac[3];
+ mac[3] = mac[2];
+ mac[4] = mac[1];
+ mac[5] = mac[0];
+ s0 = s1;
+ s1 = swap16(s0);
+ w0 = swap32(w1);
+ b0 = b1
+ s2 = s0 + s1
+ b1 = b0
+ w1 = w0
+
+ mac[0] == 2
+ ==> CMD_EVENT mode, return H2C_SUCCESS
+ The event layout shall be:
+ event: parm:
+ mac[0] = mac[5];
+ mac[1] = mac[4];
+ mac[2] = event's sequence number, starting from 1 to parm's marc[3]
+ mac[3] = mac[2];
+ mac[4] = mac[1];
+ mac[5] = mac[0];
+ s0 = swap16(s0) - event.mac[2];
+ s1 = s1 + event.mac[2];
+ w0 = swap32(w0);
+ b0 = b1
+ s2 = s0 + event.mac[2]
+ b1 = b0
+ w1 = swap32(w1) - event.mac[2];
+
+ parm->mac[3] is the total event counts that host requested.
+
+
+ event will be the same with the cmd's param.
+
+*/
+
+/* CMD param Formart for DRV INTERNAL CMD HDL*/
+struct drvint_cmd_parm {
+ int i_cid; /*internal cmd id*/
+ int sz; /* buf sz*/
+ unsigned char *pbuf;
+};
+
+/*------------------- Below are used for RF/BB tunning ---------------------*/
+
+struct setantenna_parm {
+ u8 tx_antset;
+ u8 rx_antset;
+ u8 tx_antenna;
+ u8 rx_antenna;
+};
+
+struct enrateadaptive_parm {
+ u32 en;
+};
+
+struct settxagctbl_parm {
+ u32 txagc[MAX_RATES_LENGTH];
+};
+
+struct gettxagctbl_parm {
+ u32 rsvd;
+};
+struct gettxagctbl_rsp {
+ u32 txagc[MAX_RATES_LENGTH];
+};
+
+struct setagcctrl_parm {
+ u32 agcctrl; /* 0: pure hw, 1: fw */
+};
+
+struct setssup_parm {
+ u32 ss_ForceUp[MAX_RATES_LENGTH];
+};
+
+struct getssup_parm {
+ u32 rsvd;
+};
+struct getssup_rsp {
+ u8 ss_ForceUp[MAX_RATES_LENGTH];
+};
+
+struct setssdlevel_parm {
+ u8 ss_DLevel[MAX_RATES_LENGTH];
+};
+
+struct getssdlevel_parm {
+ u32 rsvd;
+};
+struct getssdlevel_rsp {
+ u8 ss_DLevel[MAX_RATES_LENGTH];
+};
+
+struct setssulevel_parm {
+ u8 ss_ULevel[MAX_RATES_LENGTH];
+};
+
+struct getssulevel_parm {
+ u32 rsvd;
+};
+struct getssulevel_rsp {
+ u8 ss_ULevel[MAX_RATES_LENGTH];
+};
+
+struct setcountjudge_parm {
+ u8 count_judge[MAX_RATES_LENGTH];
+};
+
+struct getcountjudge_parm {
+ u32 rsvd;
+};
+
+struct getcountjudge_rsp {
+ u8 count_judge[MAX_RATES_LENGTH];
+};
+
+struct setpwrmode_parm {
+ u8 mode;
+ u8 flag_low_traffic_en;
+ u8 flag_lpnav_en;
+ u8 flag_rf_low_snr_en;
+ u8 flag_dps_en; /* 1: dps, 0: 32k */
+ u8 bcn_rx_en;
+ u8 bcn_pass_cnt; /* fw report one beacon information to
+ * driver when it receives bcn_pass_cnt
+ * beacons. */
+ u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
+ u16 bcn_itv;
+ u8 app_itv; /* only for VOIP mode. */
+ u8 awake_bcn_itv;
+ u8 smart_ps;
+ u8 bcn_pass_time; /* unit: 100ms */
+};
+
+struct setatim_parm {
+ u8 op; /*0: add, 1:del*/
+ u8 txid; /* id of dest station.*/
+};
+
+struct setratable_parm {
+ u8 ss_ForceUp[NumRates];
+ u8 ss_ULevel[NumRates];
+ u8 ss_DLevel[NumRates];
+ u8 count_judge[NumRates];
+};
+
+struct getratable_parm {
+ uint rsvd;
+};
+struct getratable_rsp {
+ u8 ss_ForceUp[NumRates];
+ u8 ss_ULevel[NumRates];
+ u8 ss_DLevel[NumRates];
+ u8 count_judge[NumRates];
+};
+
+/*to get TX,RX retry count*/
+struct gettxretrycnt_parm{
+ unsigned int rsvd;
+};
+
+struct gettxretrycnt_rsp{
+ unsigned long tx_retrycnt;
+};
+
+struct getrxretrycnt_parm{
+ unsigned int rsvd;
+};
+
+struct getrxretrycnt_rsp{
+ unsigned long rx_retrycnt;
+};
+
+/*to get BCNOK,BCNERR count*/
+struct getbcnokcnt_parm{
+ unsigned int rsvd;
+};
+
+struct getbcnokcnt_rsp{
+ unsigned long bcnokcnt;
+};
+
+struct getbcnerrcnt_parm{
+ unsigned int rsvd;
+};
+struct getbcnerrcnt_rsp{
+ unsigned long bcnerrcnt;
+};
+
+/* to get current TX power level*/
+struct getcurtxpwrlevel_parm{
+ unsigned int rsvd;
+};
+
+struct getcurtxpwrlevel_rsp{
+ unsigned short tx_power;
+};
+
+/*dynamic on/off DIG*/
+struct setdig_parm{
+ unsigned char dig_on; /* 1:on , 0:off */
+};
+
+/*dynamic on/off RA*/
+struct setra_parm{
+ unsigned char ra_on; /* 1:on , 0:off */
+};
+
+struct setprobereqextraie_parm {
+ unsigned char e_id;
+ unsigned char ie_len;
+ unsigned char ie[0];
+};
+
+struct setassocreqextraie_parm {
+ unsigned char e_id;
+ unsigned char ie_len;
+ unsigned char ie[0];
+};
+
+struct setproberspextraie_parm {
+ unsigned char e_id;
+ unsigned char ie_len;
+ unsigned char ie[0];
+};
+
+struct setassocrspextraie_parm {
+ unsigned char e_id;
+ unsigned char ie_len;
+ unsigned char ie[0];
+};
+
+struct addBaReq_parm {
+ unsigned int tid;
+};
+
+/*H2C Handler index: 46 */
+struct SetChannel_parm {
+ u32 curr_ch;
+};
+
+/*H2C Handler index: 56 */
+struct PT_param {
+ u8 PT_En;
+};
+
+#define GEN_CMD_CODE(cmd) cmd ## _CMD_
+
+/*
+ * Result:
+ * 0x00: success
+ * 0x01: sucess, and check Response.
+ * 0x02: cmd ignored due to duplicated sequcne number
+ * 0x03: cmd dropped due to invalid cmd code
+ * 0x04: reserved.
+ */
+
+#define H2C_RSP_OFFSET 512
+#define H2C_SUCCESS 0x00
+#define H2C_SUCCESS_RSP 0x01
+#define H2C_DUPLICATED 0x02
+#define H2C_DROPPED 0x03
+#define H2C_PARAMETERS_ERROR 0x04
+#define H2C_REJECTED 0x05
+#define H2C_CMD_OVERFLOW 0x06
+#define H2C_RESERVED 0x07
+
+u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr);
+u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr);
+u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
+ struct ndis_802_11_ssid *pssid);
+u8 r8712_createbss_cmd(struct _adapter *padapter);
+u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
+u8 r8712_joinbss_cmd(struct _adapter *padapter,
+ struct wlan_network *pnetwork);
+u8 r8712_disassoc_cmd(struct _adapter *padapter);
+u8 r8712_setopmode_cmd(struct _adapter *padapter,
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
+u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
+u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset);
+u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval);
+u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode);
+u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val);
+u8 r8712_setrttbl_cmd(struct _adapter *padapter,
+ struct setratable_parm *prate_table);
+u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type);
+u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid);
+u8 r8712_wdg_wk_cmd(struct _adapter *padapter);
+void r8712_survey_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_disassoc_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_joinbss_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_createbss_cmd_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
+ struct cmd_obj *pcmd);
+
+struct _cmd_callback {
+ u32 cmd_code;
+ void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
+};
+
+#include "rtl8712_cmd.h"
+
+#endif /* _CMD_H_ */
+
diff --git a/drivers/staging/rtl8712/rtl871x_debug.h b/drivers/staging/rtl8712/rtl871x_debug.h
new file mode 100644
index 000000000000..c392fd958e43
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_debug.h
@@ -0,0 +1,142 @@
+#ifndef __RTL871X_DEBUG_H__
+#define __RTL871X_DEBUG_H__
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+
+#define _drv_emerg_ 1
+#define _drv_alert_ 2
+#define _drv_crit_ 3
+#define _drv_err_ 4
+#define _drv_warning_ 5
+#define _drv_notice_ 6
+#define _drv_info_ 7
+#define _drv_dump_ 8
+#define _drv_debug_ 9
+
+
+#define _module_rtl871x_xmit_c_ BIT(0)
+#define _module_xmit_osdep_c_ BIT(1)
+#define _module_rtl871x_recv_c_ BIT(2)
+#define _module_recv_osdep_c_ BIT(3)
+#define _module_rtl871x_mlme_c_ BIT(4)
+#define _module_mlme_osdep_c_ BIT(5)
+#define _module_rtl871x_sta_mgt_c_ BIT(6)
+#define _module_rtl871x_cmd_c_ BIT(7)
+#define _module_cmd_osdep_c_ BIT(8)
+#define _module_rtl871x_io_c_ BIT(9)
+#define _module_io_osdep_c_ BIT(10)
+#define _module_os_intfs_c_ BIT(11)
+#define _module_rtl871x_security_c_ BIT(12)
+#define _module_rtl871x_eeprom_c_ BIT(13)
+#define _module_hal_init_c_ BIT(14)
+#define _module_hci_hal_init_c_ BIT(15)
+#define _module_rtl871x_ioctl_c_ BIT(16)
+#define _module_rtl871x_ioctl_set_c_ BIT(17)
+#define _module_rtl871x_pwrctrl_c_ BIT(19)
+#define _module_hci_intfs_c_ BIT(20)
+#define _module_hci_ops_c_ BIT(21)
+#define _module_osdep_service_c_ BIT(22)
+#define _module_rtl871x_mp_ioctl_c_ BIT(23)
+#define _module_hci_ops_os_c_ BIT(24)
+#define _module_rtl871x_ioctl_os_c BIT(25)
+#define _module_rtl8712_cmd_c_ BIT(26)
+#define _module_rtl871x_mp_c_ BIT(27)
+#define _module_rtl8712_xmit_c_ BIT(28)
+#define _module_rtl8712_efuse_c_ BIT(29)
+#define _module_rtl8712_recv_c_ BIT(30)
+#define _module_rtl8712_led_c_ BIT(31)
+
+#undef _MODULE_DEFINE_
+
+#if defined _RTL871X_XMIT_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_xmit_c_
+#elif defined _XMIT_OSDEP_C_
+ #define _MODULE_DEFINE_ _module_xmit_osdep_c_
+#elif defined _RTL871X_RECV_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_recv_c_
+#elif defined _RECV_OSDEP_C_
+ #define _MODULE_DEFINE_ _module_recv_osdep_c_
+#elif defined _RTL871X_MLME_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_mlme_c_
+#elif defined _MLME_OSDEP_C_
+ #define _MODULE_DEFINE_ _module_mlme_osdep_c_
+#elif defined _RTL871X_STA_MGT_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_sta_mgt_c_
+#elif defined _RTL871X_CMD_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_cmd_c_
+#elif defined _CMD_OSDEP_C_
+ #define _MODULE_DEFINE_ _module_cmd_osdep_c_
+#elif defined _RTL871X_IO_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_io_c_
+#elif defined _IO_OSDEP_C_
+ #define _MODULE_DEFINE_ _module_io_osdep_c_
+#elif defined _OS_INTFS_C_
+ #define _MODULE_DEFINE_ _module_os_intfs_c_
+#elif defined _RTL871X_SECURITY_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_security_c_
+#elif defined _RTL871X_EEPROM_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_eeprom_c_
+#elif defined _HAL_INIT_C_
+ #define _MODULE_DEFINE_ _module_hal_init_c_
+#elif defined _HCI_HAL_INIT_C_
+ #define _MODULE_DEFINE_ _module_hci_hal_init_c_
+#elif defined _RTL871X_IOCTL_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_ioctl_c_
+#elif defined _RTL871X_IOCTL_SET_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_ioctl_set_c_
+#elif defined _RTL871X_PWRCTRL_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_pwrctrl_c_
+#elif defined _HCI_INTF_C_
+ #define _MODULE_DEFINE_ _module_hci_intfs_c_
+#elif defined _HCI_OPS_C_
+ #define _MODULE_DEFINE_ _module_hci_ops_c_
+#elif defined _OSDEP_HCI_INTF_C_
+ #define _MODULE_DEFINE_ _module_hci_intfs_c_
+#elif defined _OSDEP_SERVICE_C_
+ #define _MODULE_DEFINE_ _module_osdep_service_c_
+#elif defined _RTL871X_MP_IOCTL_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_mp_ioctl_c_
+#elif defined _HCI_OPS_OS_C_
+ #define _MODULE_DEFINE_ _module_hci_ops_os_c_
+#elif defined _RTL871X_IOCTL_LINUX_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_ioctl_os_c
+#elif defined _RTL871X_MP_C_
+ #define _MODULE_DEFINE_ _module_rtl871x_mp_c_
+#elif defined _RTL8712_CMD_C_
+ #define _MODULE_DEFINE_ _module_rtl8712_cmd_c_
+#elif defined _RTL8712_XMIT_C_
+ #define _MODULE_DEFINE_ _module_rtl8712_xmit_c_
+#elif defined _RTL8712_EFUSE_C_
+ #define _MODULE_DEFINE_ _module_rtl8712_efuse_c_
+#elif defined _RTL8712_RECV_C_
+ #define _MODULE_DEFINE_ _module_rtl8712_recv_c_
+#else
+ #undef _MODULE_DEFINE_
+#endif
+
+#define _dbgdump printk
+
+#define MSG_8712(x, ...) {}
+
+#define DBG_8712(x, ...) {}
+
+#define WRN_8712(x, ...) {}
+
+#define ERR_8712(x, ...) {}
+
+#undef MSG_8712
+#define MSG_8712 _dbgdump
+
+#undef DBG_8712
+#define DBG_8712 _dbgdump
+
+#undef WRN_8712
+#define WRN_8712 _dbgdump
+
+#undef ERR_8712
+#define ERR_8712 _dbgdump
+
+#endif /*__RTL871X_DEBUG_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl871x_eeprom.c b/drivers/staging/rtl8712/rtl871x_eeprom.c
new file mode 100644
index 000000000000..2f145d63fcec
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_eeprom.c
@@ -0,0 +1,233 @@
+/******************************************************************************
+ * rtl871x_eeprom.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_EEPROM_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+static void up_clk(struct _adapter *padapter, u16 *x)
+{
+ *x = *x | _EESK;
+ r8712_write8(padapter, EE_9346CR, (u8)*x);
+ udelay(CLOCK_RATE);
+}
+
+static void down_clk(struct _adapter *padapter, u16 *x)
+{
+ *x = *x & ~_EESK;
+ r8712_write8(padapter, EE_9346CR, (u8)*x);
+ udelay(CLOCK_RATE);
+}
+
+static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count)
+{
+ u16 x, mask;
+
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ mask = 0x01 << (count - 1);
+ x = r8712_read8(padapter, EE_9346CR);
+ x &= ~(_EEDO | _EEDI);
+ do {
+ x &= ~_EEDI;
+ if (data & mask)
+ x |= _EEDI;
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ r8712_write8(padapter, EE_9346CR, (u8)x);
+ udelay(CLOCK_RATE);
+ up_clk(padapter, &x);
+ down_clk(padapter, &x);
+ mask = mask >> 1;
+ } while (mask);
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ x &= ~_EEDI;
+ r8712_write8(padapter, EE_9346CR, (u8)x);
+out:;
+}
+
+static u16 shift_in_bits(struct _adapter *padapter)
+{
+ u16 x, d = 0, i;
+
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ x = r8712_read8(padapter, EE_9346CR);
+ x &= ~(_EEDO | _EEDI);
+ d = 0;
+ for (i = 0; i < 16; i++) {
+ d = d << 1;
+ up_clk(padapter, &x);
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ x = r8712_read8(padapter, EE_9346CR);
+ x &= ~(_EEDI);
+ if (x & _EEDO)
+ d |= 1;
+ down_clk(padapter, &x);
+ }
+out:
+ return d;
+}
+
+static void standby(struct _adapter *padapter)
+{
+ u8 x;
+
+ x = r8712_read8(padapter, EE_9346CR);
+ x &= ~(_EECS | _EESK);
+ r8712_write8(padapter, EE_9346CR, x);
+ udelay(CLOCK_RATE);
+ x |= _EECS;
+ r8712_write8(padapter, EE_9346CR, x);
+ udelay(CLOCK_RATE);
+}
+
+static u16 wait_eeprom_cmd_done(struct _adapter *padapter)
+{
+ u8 x;
+ u16 i;
+
+ standby(padapter);
+ for (i = 0; i < 200; i++) {
+ x = r8712_read8(padapter, EE_9346CR);
+ if (x & _EEDO)
+ return true;
+ udelay(CLOCK_RATE);
+ }
+ return false;
+}
+
+static void eeprom_clean(struct _adapter *padapter)
+{
+ u16 x;
+
+ if (padapter->bSurpriseRemoved == true)
+ return;
+ x = r8712_read8(padapter, EE_9346CR);
+ if (padapter->bSurpriseRemoved == true)
+ return;
+ x &= ~(_EECS | _EEDI);
+ r8712_write8(padapter, EE_9346CR, (u8)x);
+ if (padapter->bSurpriseRemoved == true)
+ return;
+ up_clk(padapter, &x);
+ if (padapter->bSurpriseRemoved == true)
+ return;
+ down_clk(padapter, &x);
+}
+
+void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data)
+{
+ u8 x;
+ u8 tmp8_ori, tmp8_new, tmp8_clk_ori, tmp8_clk_new;
+
+ tmp8_ori = r8712_read8(padapter, 0x102502f1);
+ tmp8_new = tmp8_ori & 0xf7;
+ if (tmp8_ori != tmp8_new)
+ r8712_write8(padapter, 0x102502f1, tmp8_new);
+ tmp8_clk_ori = r8712_read8(padapter, 0x10250003);
+ tmp8_clk_new = tmp8_clk_ori | 0x20;
+ if (tmp8_clk_new != tmp8_clk_ori)
+ r8712_write8(padapter, 0x10250003, tmp8_clk_new);
+ x = r8712_read8(padapter, EE_9346CR);
+ x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
+ x |= _EEM1 | _EECS;
+ r8712_write8(padapter, EE_9346CR, x);
+ shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5);
+ if (padapter->EepromAddressSize == 8) /*CF+ and SDIO*/
+ shift_out_bits(padapter, 0, 6);
+ else /* USB */
+ shift_out_bits(padapter, 0, 4);
+ standby(padapter);
+ /* Erase this particular word. Write the erase opcode and register
+ * number in that order. The opcode is 3bits in length; reg is 6
+ * bits long.
+ */
+ standby(padapter);
+ /* write the new word to the EEPROM
+ * send the write opcode the EEPORM
+ */
+ shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3);
+ /* select which word in the EEPROM that we are writing to. */
+ shift_out_bits(padapter, reg, padapter->EepromAddressSize);
+ /* write the data to the selected EEPROM word. */
+ shift_out_bits(padapter, data, 16);
+ if (wait_eeprom_cmd_done(padapter)) {
+ standby(padapter);
+ shift_out_bits(padapter, EEPROM_EWDS_OPCODE, 5);
+ shift_out_bits(padapter, reg, 4);
+ eeprom_clean(padapter);
+ }
+ if (tmp8_clk_new != tmp8_clk_ori)
+ r8712_write8(padapter, 0x10250003, tmp8_clk_ori);
+ if (tmp8_new != tmp8_ori)
+ r8712_write8(padapter, 0x102502f1, tmp8_ori);
+}
+
+u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg) /*ReadEEprom*/
+{
+ u16 x;
+ u16 data = 0;
+ u8 tmp8_ori, tmp8_new, tmp8_clk_ori, tmp8_clk_new;
+
+ tmp8_ori = r8712_read8(padapter, 0x102502f1);
+ tmp8_new = tmp8_ori & 0xf7;
+ if (tmp8_ori != tmp8_new)
+ r8712_write8(padapter, 0x102502f1, tmp8_new);
+ tmp8_clk_ori = r8712_read8(padapter, 0x10250003);
+ tmp8_clk_new = tmp8_clk_ori | 0x20;
+ if (tmp8_clk_new != tmp8_clk_ori)
+ r8712_write8(padapter, 0x10250003, tmp8_clk_new);
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ /* select EEPROM, reset bits, set _EECS */
+ x = r8712_read8(padapter, EE_9346CR);
+ if (padapter->bSurpriseRemoved == true)
+ goto out;
+ x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
+ x |= _EEM1 | _EECS;
+ r8712_write8(padapter, EE_9346CR, (unsigned char)x);
+ /* write the read opcode and register number in that order
+ * The opcode is 3bits in length, reg is 6 bits long
+ */
+ shift_out_bits(padapter, EEPROM_READ_OPCODE, 3);
+ shift_out_bits(padapter, reg, padapter->EepromAddressSize);
+ /* Now read the data (16 bits) in from the selected EEPROM word */
+ data = shift_in_bits(padapter);
+ eeprom_clean(padapter);
+out:
+ if (tmp8_clk_new != tmp8_clk_ori)
+ r8712_write8(padapter, 0x10250003, tmp8_clk_ori);
+ if (tmp8_new != tmp8_ori)
+ r8712_write8(padapter, 0x102502f1, tmp8_ori);
+ return data;
+}
+
diff --git a/drivers/staging/rtl8712/rtl871x_eeprom.h b/drivers/staging/rtl8712/rtl871x_eeprom.h
new file mode 100644
index 000000000000..fb15f5bde426
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_eeprom.h
@@ -0,0 +1,82 @@
+#ifndef __RTL871X_EEPROM_H__
+#define __RTL871X_EEPROM_H__
+
+#include "osdep_service.h"
+
+#define RTL8712_EEPROM_ID 0x8712
+#define EEPROM_MAX_SIZE 256
+#define CLOCK_RATE 50 /*100us*/
+
+/*- EEPROM opcodes*/
+#define EEPROM_READ_OPCODE 06
+#define EEPROM_WRITE_OPCODE 05
+#define EEPROM_ERASE_OPCODE 07
+#define EEPROM_EWEN_OPCODE 19 /* Erase/write enable*/
+#define EEPROM_EWDS_OPCODE 16 /* Erase/write disable*/
+
+#define EEPROM_CID_DEFAULT 0x0
+#define EEPROM_CID_ALPHA 0x1
+#define EEPROM_CID_Senao 0x3
+#define EEPROM_CID_NetCore 0x5
+#define EEPROM_CID_CAMEO 0X8
+#define EEPROM_CID_SITECOM 0x9
+#define EEPROM_CID_COREGA 0xB
+#define EEPROM_CID_EDIMAX_BELKIN 0xC
+#define EEPROM_CID_SERCOMM_BELKIN 0xE
+#define EEPROM_CID_CAMEO1 0xF
+#define EEPROM_CID_WNC_COREGA 0x12
+#define EEPROM_CID_CLEVO 0x13
+#define EEPROM_CID_WHQL 0xFE
+
+enum RT_CUSTOMER_ID {
+ RT_CID_DEFAULT = 0,
+ RT_CID_8187_ALPHA0 = 1,
+ RT_CID_8187_SERCOMM_PS = 2,
+ RT_CID_8187_HW_LED = 3,
+ RT_CID_8187_NETGEAR = 4,
+ RT_CID_WHQL = 5,
+ RT_CID_819x_CAMEO = 6,
+ RT_CID_819x_RUNTOP = 7,
+ RT_CID_819x_Senao = 8,
+ RT_CID_TOSHIBA = 9,
+ RT_CID_819x_Netcore = 10,
+ RT_CID_Nettronix = 11,
+ RT_CID_DLINK = 12,
+ RT_CID_PRONET = 13,
+ RT_CID_COREGA = 14,
+ RT_CID_819x_ALPHA = 15,
+ RT_CID_819x_Sitecom = 16,
+ RT_CID_CCX = 17,
+ RT_CID_819x_Lenovo = 18,
+ RT_CID_819x_QMI = 19,
+ RT_CID_819x_Edimax_Belkin = 20,
+ RT_CID_819x_Sercomm_Belkin = 21,
+ RT_CID_819x_CAMEO1 = 22,
+ RT_CID_819x_MSI = 23,
+ RT_CID_819x_Acer = 24,
+ RT_CID_819x_AzWave_ASUS = 25,
+ RT_CID_819x_AzWave = 26,
+ RT_CID_819x_WNC_COREGA = 27,
+ RT_CID_819x_CLEVO = 28,
+};
+
+struct eeprom_priv {
+ u8 bautoload_fail_flag;
+ u8 bempty;
+ u8 sys_config;
+ u8 mac_addr[6];
+ u8 config0;
+ u16 channel_plan;
+ u8 country_string[3];
+ u8 tx_power_b[15];
+ u8 tx_power_g[15];
+ u8 tx_power_a[201];
+ u8 efuse_eeprom_data[EEPROM_MAX_SIZE];
+ enum RT_CUSTOMER_ID CustomerID;
+};
+
+void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data);
+u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg);
+
+#endif /*__RTL871X_EEPROM_H__*/
+
diff --git a/drivers/staging/rtl8712/rtl871x_event.h b/drivers/staging/rtl8712/rtl871x_event.h
new file mode 100644
index 000000000000..d45229356bf6
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_event.h
@@ -0,0 +1,95 @@
+#ifndef _RTL871x_EVENT_H_
+#define _RTL871x_EVENT_H_
+
+#include "osdep_service.h"
+
+#include "wlan_bssdef.h"
+#include <linux/semaphore.h>
+#include <linux/sem.h>
+
+/*
+ * Used to report a bss has been scanned
+*/
+struct survey_event {
+ struct ndis_wlan_bssid_ex bss;
+};
+
+/*
+ * Used to report that the requested site survey has been done.
+ * bss_cnt indicates the number of bss that has been reported.
+*/
+struct surveydone_event {
+ unsigned int bss_cnt;
+
+};
+
+/*
+ * Used to report the link result of joinning the given bss
+ * join_res:
+ * -1: authentication fail
+ * -2: association fail
+ * > 0: TID
+*/
+struct joinbss_event {
+ struct wlan_network network;
+};
+
+/*
+ * Used to report a given STA has joinned the created BSS.
+ * It is used in AP/Ad-HoC(M) mode.
+*/
+struct stassoc_event {
+ unsigned char macaddr[6];
+ unsigned char rsvd[2];
+ int cam_id;
+};
+
+struct stadel_event {
+ unsigned char macaddr[6];
+ unsigned char rsvd[2];
+};
+
+struct addba_event {
+ unsigned int tid;
+};
+
+#define GEN_EVT_CODE(event) event ## _EVT_
+
+struct fwevent {
+ u32 parmsize;
+ void (*event_callback)(struct _adapter *dev, u8 *pbuf);
+};
+
+#define C2HEVENT_SZ 32
+struct event_node{
+ unsigned char *node;
+ unsigned char evt_code;
+ unsigned short evt_sz;
+ /*volatile*/ int *caller_ff_tail;
+ int caller_ff_sz;
+};
+
+struct c2hevent_queue {
+ /*volatile*/ int head;
+ /*volatile*/ int tail;
+ struct event_node nodes[C2HEVENT_SZ];
+ unsigned char seq;
+};
+
+#define NETWORK_QUEUE_SZ 4
+
+struct network_queue {
+ /*volatile*/ int head;
+ /*volatile*/ int tail;
+ struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ];
+};
+
+struct ADDBA_Req_Report_parm {
+ unsigned char MacAddress[ETH_ALEN];
+ unsigned short StartSeqNum;
+ unsigned char tid;
+};
+#include "rtl8712_event.h"
+
+#endif /* _WLANEVENT_H_ */
+
diff --git a/drivers/staging/rtl8712/rtl871x_ht.h b/drivers/staging/rtl8712/rtl871x_ht.h
new file mode 100644
index 000000000000..612203deea73
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ht.h
@@ -0,0 +1,19 @@
+#ifndef _RTL871X_HT_H_
+#define _RTL871X_HT_H_
+
+#include "osdep_service.h"
+#include "wifi.h"
+
+struct ht_priv {
+ unsigned int ht_option;
+ unsigned int ampdu_enable;/*for enable Tx A-MPDU*/
+ unsigned char baddbareq_issued[16];
+ unsigned int tx_amsdu_enable;/*for enable Tx A-MSDU */
+ unsigned int tx_amdsu_maxlen; /* 1: 8k, 0:4k ; default:8k, for tx */
+ unsigned int rx_ampdu_maxlen; /* for rx reordering ctrl win_sz,
+ * updated when join_callback. */
+ struct ieee80211_ht_cap ht_cap;
+};
+
+#endif /*_RTL871X_HT_H_ */
+
diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c
new file mode 100644
index 000000000000..e6e3c3752a97
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_io.c
@@ -0,0 +1,163 @@
+/******************************************************************************
+ * rtl871x_io.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+/*
+ *
+ * The purpose of rtl871x_io.c
+ *
+ * a. provides the API
+ * b. provides the protocol engine
+ * c. provides the software interface between caller and the hardware interface
+ *
+ * For r8712u, both sync/async operations are provided.
+ *
+ * Only sync read/write_mem operations are provided.
+ *
+ */
+
+#define _RTL871X_IO_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_io.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+static uint _init_intf_hdl(struct _adapter *padapter,
+ struct intf_hdl *pintf_hdl)
+{
+ struct intf_priv *pintf_priv;
+ void (*set_intf_option)(u32 *poption) = NULL;
+ void (*set_intf_funs)(struct intf_hdl *pintf_hdl);
+ void (*set_intf_ops)(struct _io_ops *pops);
+ uint (*init_intf_priv)(struct intf_priv *pintfpriv);
+
+ set_intf_option = &(r8712_usb_set_intf_option);
+ set_intf_funs = &(r8712_usb_set_intf_funs);
+ set_intf_ops = &r8712_usb_set_intf_ops;
+ init_intf_priv = &r8712_usb_init_intf_priv;
+ pintf_priv = pintf_hdl->pintfpriv = (struct intf_priv *)
+ _malloc(sizeof(struct intf_priv));
+ if (pintf_priv == NULL)
+ goto _init_intf_hdl_fail;
+ pintf_hdl->adapter = (u8 *)padapter;
+ set_intf_option(&pintf_hdl->intf_option);
+ set_intf_funs(pintf_hdl);
+ set_intf_ops(&pintf_hdl->io_ops);
+ pintf_priv->intf_dev = (u8 *)&(padapter->dvobjpriv);
+ if (init_intf_priv(pintf_priv) == _FAIL)
+ goto _init_intf_hdl_fail;
+ return _SUCCESS;
+_init_intf_hdl_fail:
+ if (pintf_priv)
+ kfree((u8 *)pintf_priv);
+ return _FAIL;
+}
+
+static void _unload_intf_hdl(struct intf_priv *pintfpriv)
+{
+ void (*unload_intf_priv)(struct intf_priv *pintfpriv);
+
+ unload_intf_priv = &r8712_usb_unload_intf_priv;
+ unload_intf_priv(pintfpriv);
+ if (pintfpriv)
+ kfree((u8 *)pintfpriv);
+}
+
+static uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl)
+{
+ struct _adapter *adapter = (struct _adapter *)dev;
+
+ pintfhdl->intf_option = 0;
+ pintfhdl->adapter = dev;
+ pintfhdl->intf_dev = (u8 *)&(adapter->dvobjpriv);
+ if (_init_intf_hdl(adapter, pintfhdl) == false)
+ goto register_intf_hdl_fail;
+ return _SUCCESS;
+register_intf_hdl_fail:
+ return false;
+}
+
+static void unregister_intf_hdl(struct intf_hdl *pintfhdl)
+{
+ _unload_intf_hdl(pintfhdl->pintfpriv);
+ memset((u8 *)pintfhdl, 0, sizeof(struct intf_hdl));
+}
+
+uint r8712_alloc_io_queue(struct _adapter *adapter)
+{
+ u32 i;
+ struct io_queue *pio_queue;
+ struct io_req *pio_req;
+
+ pio_queue = (struct io_queue *)_malloc(sizeof(struct io_queue));
+ if (pio_queue == NULL)
+ goto alloc_io_queue_fail;
+ _init_listhead(&pio_queue->free_ioreqs);
+ _init_listhead(&pio_queue->processing);
+ _init_listhead(&pio_queue->pending);
+ spin_lock_init(&pio_queue->lock);
+ pio_queue->pallocated_free_ioreqs_buf = (u8 *)_malloc(NUM_IOREQ *
+ (sizeof(struct io_req)) + 4);
+ if ((pio_queue->pallocated_free_ioreqs_buf) == NULL)
+ goto alloc_io_queue_fail;
+ memset(pio_queue->pallocated_free_ioreqs_buf, 0,
+ (NUM_IOREQ * (sizeof(struct io_req)) + 4));
+ pio_queue->free_ioreqs_buf = pio_queue->pallocated_free_ioreqs_buf + 4
+ - ((addr_t)(pio_queue->pallocated_free_ioreqs_buf)
+ & 3);
+ pio_req = (struct io_req *)(pio_queue->free_ioreqs_buf);
+ for (i = 0; i < NUM_IOREQ; i++) {
+ _init_listhead(&pio_req->list);
+ sema_init(&pio_req->sema, 0);
+ list_insert_tail(&pio_req->list, &pio_queue->free_ioreqs);
+ pio_req++;
+ }
+ if ((register_intf_hdl((u8 *)adapter, &(pio_queue->intf))) == _FAIL)
+ goto alloc_io_queue_fail;
+ adapter->pio_queue = pio_queue;
+ return _SUCCESS;
+alloc_io_queue_fail:
+ if (pio_queue) {
+ kfree(pio_queue->pallocated_free_ioreqs_buf);
+ kfree((u8 *)pio_queue);
+ }
+ adapter->pio_queue = NULL;
+ return _FAIL;
+}
+
+void r8712_free_io_queue(struct _adapter *adapter)
+{
+ struct io_queue *pio_queue = (struct io_queue *)(adapter->pio_queue);
+
+ if (pio_queue) {
+ kfree(pio_queue->pallocated_free_ioreqs_buf);
+ adapter->pio_queue = NULL;
+ unregister_intf_hdl(&pio_queue->intf);
+ kfree((u8 *)pio_queue);
+ }
+}
diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
new file mode 100644
index 000000000000..b70cb2b6296c
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_io.h
@@ -0,0 +1,233 @@
+#ifndef _IO_H_
+#define _IO_H_
+
+#include "osdep_service.h"
+#include "osdep_intf.h"
+
+#define NUM_IOREQ 8
+
+#define MAX_PROT_SZ (64-16)
+
+#define _IOREADY 0
+#define _IO_WAIT_COMPLETE 1
+#define _IO_WAIT_RSP 2
+
+/* IO COMMAND TYPE */
+#define _IOSZ_MASK_ (0x7F)
+#define _IO_WRITE_ BIT(7)
+#define _IO_FIXED_ BIT(8)
+#define _IO_BURST_ BIT(9)
+#define _IO_BYTE_ BIT(10)
+#define _IO_HW_ BIT(11)
+#define _IO_WORD_ BIT(12)
+#define _IO_SYNC_ BIT(13)
+#define _IO_CMDMASK_ (0x1F80)
+
+/*
+ For prompt mode accessing, caller shall free io_req
+ Otherwise, io_handler will free io_req
+*/
+/* IO STATUS TYPE */
+#define _IO_ERR_ BIT(2)
+#define _IO_SUCCESS_ BIT(1)
+#define _IO_DONE_ BIT(0)
+#define IO_RD32 (_IO_SYNC_ | _IO_WORD_)
+#define IO_RD16 (_IO_SYNC_ | _IO_HW_)
+#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_)
+#define IO_RD32_ASYNC (_IO_WORD_)
+#define IO_RD16_ASYNC (_IO_HW_)
+#define IO_RD8_ASYNC (_IO_BYTE_)
+#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_)
+#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_)
+#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_)
+#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_)
+#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_)
+#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_)
+/*
+ Only Sync. burst accessing is provided.
+*/
+#define IO_WR_BURST(x) (IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | \
+ ((x) & _IOSZ_MASK_))
+#define IO_RD_BURST(x) (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_))
+/*below is for the intf_option bit defition...*/
+#define _INTF_ASYNC_ BIT(0) /*support async io*/
+struct intf_priv;
+struct intf_hdl;
+struct io_queue;
+struct _io_ops {
+ uint (*_sdbus_read_bytes_to_membuf)(struct intf_priv *pintfpriv,
+ u32 addr, u32 cnt, u8 *pbuf);
+ uint (*_sdbus_read_blocks_to_membuf)(struct intf_priv *pintfpriv,
+ u32 addr, u32 cnt, u8 *pbuf);
+ u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
+ u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
+ u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
+ uint (*_sdbus_write_blocks_from_membuf)(struct intf_priv *pintfpriv,
+ u32 addr, u32 cnt, u8 *pbuf,
+ u8 async);
+ uint (*_sdbus_write_bytes_from_membuf)(struct intf_priv *pintfpriv,
+ u32 addr, u32 cnt, u8 *pbuf);
+ u8 (*_cmd52r)(struct intf_priv *pintfpriv, u32 addr);
+ void (*_cmd52w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
+ u8 (*_cmdfunc152r)(struct intf_priv *pintfpriv, u32 addr);
+ void (*_cmdfunc152w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
+ void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
+ void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
+ void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
+ void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
+ u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+ u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
+ u8 *pmem);
+};
+
+struct io_req {
+ struct list_head list;
+ u32 addr;
+ /*volatile*/ u32 val;
+ u32 command;
+ u32 status;
+ u8 *pbuf;
+ struct semaphore sema;
+ void (*_async_io_callback)(struct _adapter *padater,
+ struct io_req *pio_req, u8 *cnxt);
+ u8 *cnxt;
+};
+
+struct intf_hdl {
+ u32 intf_option;
+ u8 *adapter;
+ u8 *intf_dev;
+ struct intf_priv *pintfpriv;
+ void (*intf_hdl_init)(u8 *priv);
+ void (*intf_hdl_unload)(u8 *priv);
+ void (*intf_hdl_open)(u8 *priv);
+ void (*intf_hdl_close)(u8 *priv);
+ struct _io_ops io_ops;
+};
+
+struct reg_protocol_rd {
+
+#ifdef __LITTLE_ENDIAN
+ /* DW1 */
+ u32 NumOfTrans:4;
+ u32 Reserved1:4;
+ u32 Reserved2:24;
+ /* DW2 */
+ u32 ByteCount:7;
+ u32 WriteEnable:1; /*0:read, 1:write*/
+ u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
+ u32 BurstMode:1;
+ u32 Byte1Access:1;
+ u32 Byte2Access:1;
+ u32 Byte4Access:1;
+ u32 Reserved3:3;
+ u32 Reserved4:16;
+ /*DW3*/
+ u32 BusAddress;
+ /*DW4*/
+#else
+/*DW1*/
+ u32 Reserved1:4;
+ u32 NumOfTrans:4;
+ u32 Reserved2:24;
+ /*DW2*/
+ u32 WriteEnable:1;
+ u32 ByteCount:7;
+ u32 Reserved3:3;
+ u32 Byte4Access:1;
+ u32 Byte2Access:1;
+ u32 Byte1Access:1;
+ u32 BurstMode:1 ;
+ u32 FixOrContinuous:1;
+ u32 Reserved4:16;
+ /*DW3*/
+ u32 BusAddress;
+ /*DW4*/
+#endif
+};
+
+struct reg_protocol_wt {
+#ifdef __LITTLE_ENDIAN
+ /*DW1*/
+ u32 NumOfTrans:4;
+ u32 Reserved1:4;
+ u32 Reserved2:24;
+ /*DW2*/
+ u32 ByteCount:7;
+ u32 WriteEnable:1; /*0:read, 1:write*/
+ u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
+ u32 BurstMode:1;
+ u32 Byte1Access:1;
+ u32 Byte2Access:1;
+ u32 Byte4Access:1;
+ u32 Reserved3:3;
+ u32 Reserved4:16;
+ /*DW3*/
+ u32 BusAddress;
+ /*DW4*/
+ u32 Value;
+#else
+ /*DW1*/
+ u32 Reserved1:4;
+ u32 NumOfTrans:4;
+ u32 Reserved2:24;
+ /*DW2*/
+ u32 WriteEnable:1;
+ u32 ByteCount:7;
+ u32 Reserved3:3;
+ u32 Byte4Access:1;
+ u32 Byte2Access:1;
+ u32 Byte1Access:1;
+ u32 BurstMode:1;
+ u32 FixOrContinuous:1;
+ u32 Reserved4:16;
+ /*DW3*/
+ u32 BusAddress;
+ /*DW4*/
+ u32 Value;
+#endif
+};
+
+/*
+Below is the data structure used by _io_handler
+*/
+
+struct io_queue {
+ spinlock_t lock;
+ struct list_head free_ioreqs;
+ /*The io_req list that will be served in the single protocol r/w.*/
+ struct list_head pending;
+ struct list_head processing;
+ u8 *free_ioreqs_buf; /* 4-byte aligned */
+ u8 *pallocated_free_ioreqs_buf;
+ struct intf_hdl intf;
+};
+
+static inline u32 _RND4(u32 sz)
+{
+ u32 val;
+ val = ((sz >> 2) + ((sz & 3) ? 1 : 0)) << 2;
+ return val;
+}
+
+u8 r8712_read8(struct _adapter *adapter, u32 addr);
+u16 r8712_read16(struct _adapter *adapter, u32 addr);
+u32 r8712_read32(struct _adapter *adapter, u32 addr);
+void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
+void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
+void r8712_write8(struct _adapter *adapter, u32 addr, u8 val);
+void r8712_write16(struct _adapter *adapter, u32 addr, u16 val);
+void r8712_write32(struct _adapter *adapter, u32 addr, u32 val);
+void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
+void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
+/*ioreq */
+uint r8712_alloc_io_queue(struct _adapter *adapter);
+void r8712_free_io_queue(struct _adapter *adapter);
+
+#endif /*_RTL8711_IO_H_*/
+
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl.h b/drivers/staging/rtl8712/rtl871x_ioctl.h
new file mode 100644
index 000000000000..20168028d39d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl.h
@@ -0,0 +1,97 @@
+#ifndef __IOCTL_H
+#define __IOCTL_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+#ifndef OID_802_11_CAPABILITY
+ #define OID_802_11_CAPABILITY 0x0d010122
+#endif
+
+#ifndef OID_802_11_PMKID
+ #define OID_802_11_PMKID 0x0d010123
+#endif
+
+
+/* For DDK-defined OIDs*/
+#define OID_NDIS_SEG1 0x00010100
+#define OID_NDIS_SEG2 0x00010200
+#define OID_NDIS_SEG3 0x00020100
+#define OID_NDIS_SEG4 0x01010100
+#define OID_NDIS_SEG5 0x01020100
+#define OID_NDIS_SEG6 0x01020200
+#define OID_NDIS_SEG7 0xFD010100
+#define OID_NDIS_SEG8 0x0D010100
+#define OID_NDIS_SEG9 0x0D010200
+#define OID_NDIS_SEG10 0x0D020200
+#define SZ_OID_NDIS_SEG1 23
+#define SZ_OID_NDIS_SEG2 3
+#define SZ_OID_NDIS_SEG3 6
+#define SZ_OID_NDIS_SEG4 6
+#define SZ_OID_NDIS_SEG5 4
+#define SZ_OID_NDIS_SEG6 8
+#define SZ_OID_NDIS_SEG7 7
+#define SZ_OID_NDIS_SEG8 36
+#define SZ_OID_NDIS_SEG9 24
+#define SZ_OID_NDIS_SEG10 19
+
+/* For Realtek-defined OIDs*/
+#define OID_MP_SEG1 0xFF871100
+#define OID_MP_SEG2 0xFF818000
+#define OID_MP_SEG3 0xFF818700
+#define OID_MP_SEG4 0xFF011100
+
+enum oid_type {
+ QUERY_OID,
+ SET_OID
+};
+
+struct oid_funs_node {
+ unsigned int oid_start; /*the starting number for OID*/
+ unsigned int oid_end; /*the ending number for OID*/
+ struct oid_obj_priv *node_array;
+ unsigned int array_sz; /*the size of node_array*/
+ int query_counter; /*count the number of query hits for this segment*/
+ int set_counter; /*count the number of set hits for this segment*/
+};
+
+struct oid_par_priv {
+ void *adapter_context;
+ uint oid;
+ void *information_buf;
+ unsigned long information_buf_len;
+ unsigned long *bytes_rw;
+ unsigned long *bytes_needed;
+ enum oid_type type_of_oid;
+ unsigned int dbg;
+};
+
+struct oid_obj_priv {
+ unsigned char dbg; /* 0: without OID debug message
+ * 1: with OID debug message */
+ uint(*oidfuns)(struct oid_par_priv *poid_par_priv);
+};
+
+uint oid_null_function(struct oid_par_priv *poid_par_priv);
+
+extern struct iw_handler_def r871x_handlers_def;
+
+extern uint drv_query_info(
+ struct net_device *MiniportAdapterContext,
+ uint Oid,
+ void *InformationBuffer,
+ u32 InformationBufferLength,
+ u32 *BytesWritten,
+ u32 *BytesNeeded
+);
+
+extern uint drv_set_info(
+ struct net_device *MiniportAdapterContext,
+ uint Oid,
+ void *InformationBuffer,
+ u32 InformationBufferLength,
+ u32 *BytesRead,
+ u32 *BytesNeeded
+);
+
+#endif
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
new file mode 100644
index 000000000000..1529239bac68
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -0,0 +1,2258 @@
+/******************************************************************************
+ * rtl871x_ioctl_linux.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_IOCTL_LINUX_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wlan_bssdef.h"
+#include "rtl871x_debug.h"
+#include "wifi.h"
+#include "rtl871x_mlme.h"
+#include "rtl871x_ioctl.h"
+#include "rtl871x_ioctl_set.h"
+#include "rtl871x_mp_ioctl.h"
+#include "mlme_osdep.h"
+
+#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30)
+
+#define SCAN_ITEM_SIZE 768
+#define MAX_CUSTOM_LEN 64
+#define RATE_COUNT 4
+
+
+static const u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000,
+ 6000000, 9000000, 12000000, 18000000,
+ 24000000, 36000000, 48000000, 54000000};
+
+static const long ieee80211_wlan_frequencies[] = {
+ 2412, 2417, 2422, 2427,
+ 2432, 2437, 2442, 2447,
+ 2452, 2457, 2462, 2467,
+ 2472, 2484
+};
+
+static const char * const iw_operation_mode[] = {
+ "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary",
+ "Monitor"
+};
+
+static int hex2num_i(char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ return -1;
+}
+
+/**
+ * hwaddr_aton - Convert ASCII string to MAC address
+ * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
+ * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
+ * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
+ */
+static int hwaddr_aton_i(const char *txt, u8 *addr)
+{
+ int i;
+
+ for (i = 0; i < 6; i++) {
+ int a, b;
+
+ a = hex2num_i(*txt++);
+ if (a < 0)
+ return -1;
+ b = hex2num_i(*txt++);
+ if (b < 0)
+ return -1;
+ *addr++ = (a << 4) | b;
+ if (i < 5 && *txt++ != ':')
+ return -1;
+ }
+ return 0;
+}
+
+void r8712_indicate_wx_assoc_event(struct _adapter *padapter)
+{
+ union iwreq_data wrqu;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress,
+ ETH_ALEN);
+ wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
+}
+
+void r8712_indicate_wx_disassoc_event(struct _adapter *padapter)
+{
+ union iwreq_data wrqu;
+
+ wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+ memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+ wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
+}
+
+static inline void handle_pairwise_key(struct sta_info *psta,
+ struct ieee_param *param,
+ struct _adapter *padapter)
+{
+ /* pairwise key */
+ memcpy(psta->x_UncstKey.skey, param->u.crypt.key,
+ (param->u.crypt. key_len > 16 ? 16 : param->u.crypt.key_len));
+ if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */
+ memcpy(psta->tkiptxmickey. skey, &(param->u.crypt.
+ key[16]), 8);
+ memcpy(psta->tkiprxmickey. skey, &(param->u.crypt.
+ key[24]), 8);
+ padapter->securitypriv. busetkipkey = false;
+ _set_timer(&padapter->securitypriv.tkip_timer, 50);
+ }
+ r8712_setstakey_cmd(padapter, (unsigned char *)psta, true);
+}
+
+static inline void handle_group_key(struct ieee_param *param,
+ struct _adapter *padapter)
+{
+ if (0 < param->u.crypt.idx &&
+ param->u.crypt.idx < 3) {
+ /* group key idx is 1 or 2 */
+ memcpy(padapter->securitypriv.XGrpKey[param->u.crypt.
+ idx-1].skey, param->u.crypt.key, (param->u.crypt.key_len
+ > 16 ? 16 : param->u.crypt.key_len));
+ memcpy(padapter->securitypriv.XGrptxmickey[param->
+ u.crypt.idx-1].skey, &(param->u.crypt.key[16]), 8);
+ memcpy(padapter->securitypriv. XGrprxmickey[param->
+ u.crypt.idx-1].skey, &(param->u.crypt.key[24]), 8);
+ padapter->securitypriv.binstallGrpkey = true;
+ r8712_set_key(padapter, &padapter->securitypriv,
+ param->u.crypt.idx);
+ if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE) {
+ if (padapter->registrypriv.power_mgnt != padapter->
+ pwrctrlpriv.pwr_mode)
+ _set_timer(&(padapter->mlmepriv.dhcp_timer),
+ 60000);
+ }
+ }
+}
+
+static inline char *translate_scan(struct _adapter *padapter,
+ struct iw_request_info *info,
+ struct wlan_network *pnetwork,
+ char *start, char *stop)
+{
+ struct iw_event iwe;
+ struct ieee80211_ht_cap *pht_capie;
+ char *current_val;
+ u8 *buf = (u8 *)_malloc(pnetwork->network.IELength * 2);
+ u8 *wpa_ie = (u8 *)_malloc(255);
+ u8 *rsn_ie = (u8 *)_malloc(255);
+ u8 *wps_ie = (u8 *)_malloc(MAX_WPS_IE_LEN);
+ s8 *p;
+ u32 i = 0, ht_ielen = 0;
+ u16 cap, ht_cap = false, mcs_rate;
+ u8 rssi, bw_40MHz = 0, short_GI = 0;
+
+ if ((pnetwork->network.Configuration.DSConfig < 1) ||
+ (pnetwork->network.Configuration.DSConfig > 14)) {
+ if (pnetwork->network.Configuration.DSConfig < 1)
+ pnetwork->network.Configuration.DSConfig = 1;
+ else
+ pnetwork->network.Configuration.DSConfig = 14;
+ }
+ /* AP MAC address */
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN);
+ start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
+ /* Add the ESSID */
+ iwe.cmd = SIOCGIWESSID;
+ iwe.u.data.flags = 1;
+ iwe.u.data.length = (u16)min((u16)pnetwork->network.Ssid.SsidLength,
+ (u16)32);
+ start = iwe_stream_add_point(info, start, stop, &iwe,
+ pnetwork->network.Ssid.Ssid);
+ /* parsing HT_CAP_IE */
+ p = r8712_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_,
+ &ht_ielen, pnetwork->network.IELength - 12);
+ if (p && ht_ielen > 0) {
+ ht_cap = true;
+ pht_capie = (struct ieee80211_ht_cap *)(p + 2);
+ memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2);
+ bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH)
+ ? 1 : 0;
+ short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20 |
+ IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
+ }
+ /* Add the protocol name */
+ iwe.cmd = SIOCGIWNAME;
+ if ((r8712_is_cckratesonly_included((u8 *)&pnetwork->network.
+ SupportedRates)) == true) {
+ if (ht_cap == true)
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
+ else
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
+ } else if ((r8712_is_cckrates_included((u8 *)&pnetwork->network.
+ SupportedRates)) == true) {
+ if (ht_cap == true)
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
+ else
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
+ } else {
+ if (ht_cap == true)
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
+ else
+ snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
+ }
+ start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
+ /* Add mode */
+ iwe.cmd = SIOCGIWMODE;
+ memcpy((u8 *)&cap, r8712_get_capability_from_ie(pnetwork->network.IEs),
+ 2);
+ cap = le16_to_cpu(cap);
+ if (cap & (WLAN_CAPABILITY_IBSS|WLAN_CAPABILITY_BSS)) {
+ if (cap & WLAN_CAPABILITY_BSS)
+ iwe.u.mode = (u32)IW_MODE_MASTER;
+ else
+ iwe.u.mode = (u32)IW_MODE_ADHOC;
+ start = iwe_stream_add_event(info, start, stop, &iwe,
+ IW_EV_UINT_LEN);
+ }
+ /* Add frequency/channel */
+ iwe.cmd = SIOCGIWFREQ;
+ {
+ /* check legel index */
+ u8 dsconfig = pnetwork->network.Configuration.DSConfig;
+ if (dsconfig >= 1 && dsconfig <= sizeof(
+ ieee80211_wlan_frequencies) / sizeof(long))
+ iwe.u.freq.m = (s32)(ieee80211_wlan_frequencies[
+ pnetwork->network.Configuration.
+ DSConfig - 1] * 100000);
+ else
+ iwe.u.freq.m = 0;
+ }
+ iwe.u.freq.e = (s16)1;
+ iwe.u.freq.i = (u8)pnetwork->network.Configuration.DSConfig;
+ start = iwe_stream_add_event(info, start, stop, &iwe,
+ IW_EV_FREQ_LEN);
+ /* Add encryption capability */
+ iwe.cmd = SIOCGIWENCODE;
+ if (cap & WLAN_CAPABILITY_PRIVACY)
+ iwe.u.data.flags = (u16)(IW_ENCODE_ENABLED |
+ IW_ENCODE_NOKEY);
+ else
+ iwe.u.data.flags = (u16)(IW_ENCODE_DISABLED);
+ iwe.u.data.length = (u16)0;
+ start = iwe_stream_add_point(info, start, stop, &iwe,
+ pnetwork->network.Ssid.Ssid);
+ /*Add basic and extended rates */
+ current_val = start + iwe_stream_lcp_len(info);
+ iwe.cmd = SIOCGIWRATE;
+ iwe.u.bitrate.fixed = 0;
+ iwe.u.bitrate.disabled = 0;
+ iwe.u.bitrate.value = 0;
+ i = 0;
+ while (pnetwork->network.SupportedRates[i] != 0) {
+ /* Bit rate given in 500 kb/s units */
+ iwe.u.bitrate.value = (pnetwork->network.SupportedRates[i++] &
+ 0x7F) * 500000;
+ current_val = iwe_stream_add_value(info, start, current_val,
+ stop, &iwe, IW_EV_PARAM_LEN);
+ }
+ /* Check if we added any event */
+ if ((current_val - start) > iwe_stream_lcp_len(info))
+ start = current_val;
+ /* parsing WPA/WPA2 IE */
+ {
+ u16 wpa_len = 0, rsn_len = 0;
+ u8 *p;
+ sint out_len = 0;
+ out_len = r8712_get_sec_ie(pnetwork->network.IEs,
+ pnetwork->network.
+ IELength, rsn_ie, &rsn_len,
+ wpa_ie, &wpa_len);
+ if (wpa_len > 0) {
+ p = buf;
+ memset(buf, 0, MAX_WPA_IE_LEN);
+ p += snprintf(p, 7, "wpa_ie=");
+ for (i = 0; i < wpa_len; i++)
+ p += snprintf(p, 2, "%02x", wpa_ie[i]);
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ iwe.u.data.length = (u16)strlen(buf);
+ start = iwe_stream_add_point(info, start, stop,
+ &iwe, buf);
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = (u16)wpa_len;
+ start = iwe_stream_add_point(info, start, stop,
+ &iwe, wpa_ie);
+ }
+ if (rsn_len > 0) {
+ p = buf;
+ memset(buf, 0, MAX_WPA_IE_LEN);
+ p += snprintf(p, 7, "rsn_ie=");
+ for (i = 0; i < rsn_len; i++)
+ p += snprintf(p, 2, "%02x", rsn_ie[i]);
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ iwe.u.data.length = strlen(buf);
+ start = iwe_stream_add_point(info, start, stop,
+ &iwe, buf);
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = rsn_len;
+ start = iwe_stream_add_point(info, start, stop, &iwe,
+ rsn_ie);
+ }
+ }
+
+ { /* parsing WPS IE */
+ uint wps_ielen;
+
+ if (r8712_get_wps_ie(pnetwork->network.IEs,
+ pnetwork->network.IELength,
+ wps_ie, &wps_ielen) == true) {
+ if (wps_ielen > 2) {
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = (u16)wps_ielen;
+ start = iwe_stream_add_point(info, start, stop,
+ &iwe, wps_ie);
+ }
+ }
+ }
+ /* Add quality statistics */
+ iwe.cmd = IWEVQUAL;
+ rssi = r8712_signal_scale_mapping(pnetwork->network.Rssi);
+ /* we only update signal_level (signal strength) that is rssi. */
+ iwe.u.qual.updated = (u8)(IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_UPDATED |
+ IW_QUAL_NOISE_INVALID);
+ iwe.u.qual.level = rssi; /* signal strength */
+ iwe.u.qual.qual = 0; /* signal quality */
+ iwe.u.qual.noise = 0; /* noise level */
+ start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
+ /* how to translate rssi to ?% */
+ kfree(buf);
+ kfree(wpa_ie);
+ kfree(rsn_ie);
+ kfree(wps_ie);
+ return start;
+}
+
+static int wpa_set_auth_algs(struct net_device *dev, u32 value)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ int ret = 0;
+
+ if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeAutoSwitch;
+ padapter->securitypriv.AuthAlgrthm = 3;
+ } else if (value & AUTH_ALG_SHARED_KEY) {
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared;
+ padapter->securitypriv.AuthAlgrthm = 1;
+ } else if (value & AUTH_ALG_OPEN_SYSTEM) {
+ if (padapter->securitypriv.ndisauthtype <
+ Ndis802_11AuthModeWPAPSK) {
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeOpen;
+ padapter->securitypriv.AuthAlgrthm = 0;
+ }
+ } else
+ ret = -EINVAL;
+ return ret;
+}
+
+static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
+ u32 param_len)
+{
+ int ret = 0;
+ u32 wep_key_idx, wep_key_len = 0;
+ struct NDIS_802_11_WEP *pwep = NULL;
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ param->u.crypt.err = 0;
+ param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
+ if (param_len != (u32)((u8 *) param->u.crypt.key - (u8 *)param) +
+ param->u.crypt.key_len)
+ return -EINVAL;
+ if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
+ param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
+ param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+ if (param->u.crypt.idx >= WEP_KEYS) {
+ /* for large key indices, set the default (0) */
+ param->u.crypt.idx = 0;
+ }
+ } else
+ return -EINVAL;
+ if (strcmp(param->u.crypt.alg, "WEP") == 0) {
+ printk(KERN_INFO "r8712u: wpa_set_encryption, crypt.alg ="
+ " WEP\n");
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.PrivacyAlgrthm = _WEP40_;
+ padapter->securitypriv.XGrpPrivacy = _WEP40_;
+ wep_key_idx = param->u.crypt.idx;
+ wep_key_len = param->u.crypt.key_len;
+ if (wep_key_idx >= WEP_KEYS)
+ wep_key_idx = 0;
+ if (wep_key_len > 0) {
+ wep_key_len = wep_key_len <= 5 ? 5 : 13;
+ pwep = (struct NDIS_802_11_WEP *)_malloc((u32)
+ (wep_key_len +
+ FIELD_OFFSET(struct NDIS_802_11_WEP,
+ KeyMaterial)));
+ if (pwep == NULL)
+ return -ENOMEM;
+ memset(pwep, 0, sizeof(struct NDIS_802_11_WEP));
+ pwep->KeyLength = wep_key_len;
+ pwep->Length = wep_key_len +
+ FIELD_OFFSET(struct NDIS_802_11_WEP,
+ KeyMaterial);
+ if (wep_key_len == 13) {
+ padapter->securitypriv.PrivacyAlgrthm =
+ _WEP104_;
+ padapter->securitypriv.XGrpPrivacy =
+ _WEP104_;
+ }
+ } else
+ return -EINVAL;
+ pwep->KeyIndex = wep_key_idx;
+ pwep->KeyIndex |= 0x80000000;
+ memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
+ if (param->u.crypt.set_tx) {
+ if (r8712_set_802_11_add_wep(padapter, pwep) ==
+ (u8)_FAIL)
+ ret = -EOPNOTSUPP;
+ } else {
+ /* don't update "psecuritypriv->PrivacyAlgrthm" and
+ * "psecuritypriv->PrivacyKeyIndex=keyid", but can
+ * r8712_set_key to fw/cam
+ */
+ if (wep_key_idx >= WEP_KEYS) {
+ ret = -EOPNOTSUPP;
+ goto exit;
+ }
+ memcpy(&(psecuritypriv->DefKey[wep_key_idx].
+ skey[0]), pwep->KeyMaterial,
+ pwep->KeyLength);
+ psecuritypriv->DefKeylen[wep_key_idx] =
+ pwep->KeyLength;
+ r8712_set_key(padapter, psecuritypriv, wep_key_idx);
+ }
+ goto exit;
+ }
+ if (padapter->securitypriv.AuthAlgrthm == 2) { /* 802_1x */
+ struct sta_info *psta, *pbcmc_sta;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE |
+ WIFI_MP_STATE) == true) { /* sta mode */
+ psta = r8712_get_stainfo(pstapriv,
+ get_bssid(pmlmepriv));
+ if (psta) {
+ psta->ieee8021x_blocked = false;
+ if ((padapter->securitypriv.ndisencryptstatus ==
+ Ndis802_11Encryption2Enabled) ||
+ (padapter->securitypriv.ndisencryptstatus ==
+ Ndis802_11Encryption3Enabled))
+ psta->XPrivacy = padapter->
+ securitypriv.PrivacyAlgrthm;
+ if (param->u.crypt.set_tx == 1)
+ handle_pairwise_key(psta, param,
+ padapter);
+ else /* group key */
+ handle_group_key(param, padapter);
+ }
+ pbcmc_sta = r8712_get_bcmc_stainfo(padapter);
+ if (pbcmc_sta) {
+ pbcmc_sta->ieee8021x_blocked = false;
+ if ((padapter->securitypriv.ndisencryptstatus ==
+ Ndis802_11Encryption2Enabled) ||
+ (padapter->securitypriv.ndisencryptstatus ==
+ Ndis802_11Encryption3Enabled))
+ pbcmc_sta->XPrivacy =
+ padapter->securitypriv.
+ PrivacyAlgrthm;
+ }
+ }
+ }
+exit:
+ kfree((u8 *)pwep);
+ return ret;
+}
+
+static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
+ unsigned short ielen)
+{
+ u8 *buf = NULL, *pos = NULL;
+ int group_cipher = 0, pairwise_cipher = 0;
+ int ret = 0;
+
+ if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL))
+ return -EINVAL;
+ if (ielen) {
+ buf = _malloc(ielen);
+ if (buf == NULL)
+ return -ENOMEM;
+ memcpy(buf, pie , ielen);
+ pos = buf;
+ if (ielen < RSN_HEADER_LEN) {
+ ret = -1;
+ goto exit;
+ }
+ if (r8712_parse_wpa_ie(buf, ielen, &group_cipher,
+ &pairwise_cipher) == _SUCCESS) {
+ padapter->securitypriv.AuthAlgrthm = 2;
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeWPAPSK;
+ }
+ if (r8712_parse_wpa2_ie(buf, ielen, &group_cipher,
+ &pairwise_cipher) == _SUCCESS) {
+ padapter->securitypriv.AuthAlgrthm = 2;
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeWPA2PSK;
+ }
+ switch (group_cipher) {
+ case WPA_CIPHER_NONE:
+ padapter->securitypriv.XGrpPrivacy =
+ _NO_PRIVACY_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11EncryptionDisabled;
+ break;
+ case WPA_CIPHER_WEP40:
+ padapter->securitypriv.XGrpPrivacy = _WEP40_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ break;
+ case WPA_CIPHER_TKIP:
+ padapter->securitypriv.XGrpPrivacy = _TKIP_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption2Enabled;
+ break;
+ case WPA_CIPHER_CCMP:
+ padapter->securitypriv.XGrpPrivacy = _AES_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption3Enabled;
+ break;
+ case WPA_CIPHER_WEP104:
+ padapter->securitypriv.XGrpPrivacy = _WEP104_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ break;
+ }
+ switch (pairwise_cipher) {
+ case WPA_CIPHER_NONE:
+ padapter->securitypriv.PrivacyAlgrthm =
+ _NO_PRIVACY_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11EncryptionDisabled;
+ break;
+ case WPA_CIPHER_WEP40:
+ padapter->securitypriv.PrivacyAlgrthm = _WEP40_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ break;
+ case WPA_CIPHER_TKIP:
+ padapter->securitypriv.PrivacyAlgrthm = _TKIP_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption2Enabled;
+ break;
+ case WPA_CIPHER_CCMP:
+ padapter->securitypriv.PrivacyAlgrthm = _AES_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption3Enabled;
+ break;
+ case WPA_CIPHER_WEP104:
+ padapter->securitypriv.PrivacyAlgrthm = _WEP104_;
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ break;
+ }
+ padapter->securitypriv.wps_phase = false;
+ {/* set wps_ie */
+ u16 cnt = 0;
+ u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
+
+ while (cnt < ielen) {
+ eid = buf[cnt];
+
+ if ((eid == _VENDOR_SPECIFIC_IE_) &&
+ (!memcmp(&buf[cnt+2], wps_oui, 4))) {
+ printk(KERN_INFO "r8712u: "
+ "SET WPS_IE\n");
+ padapter->securitypriv.wps_ie_len =
+ ((buf[cnt+1] + 2) <
+ (MAX_WPA_IE_LEN << 2)) ?
+ (buf[cnt + 1] + 2) :
+ (MAX_WPA_IE_LEN << 2);
+ memcpy(padapter->securitypriv.wps_ie,
+ &buf[cnt],
+ padapter->securitypriv.wps_ie_len);
+ padapter->securitypriv.wps_phase =
+ true;
+ printk(KERN_INFO "r8712u: SET WPS_IE,"
+ " wps_phase==true\n");
+ cnt += buf[cnt+1]+2;
+ break;
+ } else
+ cnt += buf[cnt + 1] + 2;
+ }
+ }
+ }
+exit:
+ kfree(buf);
+ return ret;
+}
+
+static int r8711_wx_get_name(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ u32 ht_ielen = 0;
+ char *p;
+ u8 ht_cap = false;
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+ NDIS_802_11_RATES_EX *prates = NULL;
+
+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) ==
+ true) {
+ /* parsing HT_CAP_IE */
+ p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_,
+ &ht_ielen, pcur_bss->IELength - 12);
+ if (p && ht_ielen > 0)
+ ht_cap = true;
+ prates = &pcur_bss->SupportedRates;
+ if (r8712_is_cckratesonly_included((u8 *)prates) == true) {
+ if (ht_cap == true)
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11bn");
+ else
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11b");
+ } else if ((r8712_is_cckrates_included((u8 *)prates)) == true) {
+ if (ht_cap == true)
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11bgn");
+ else
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11bg");
+ } else {
+ if (ht_cap == true)
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11gn");
+ else
+ snprintf(wrqu->name, IFNAMSIZ,
+ "IEEE 802.11g");
+ }
+ } else
+ snprintf(wrqu->name, IFNAMSIZ, "unassociated");
+ return 0;
+}
+
+static const long frequency_list[] = {
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462,
+ 2467, 2472, 2484, 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
+ 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210,
+ 5220, 5230, 5240, 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560,
+ 5580, 5600, 5620, 5640, 5660, 5680, 5700, 5745, 5765, 5785, 5805,
+ 5825
+};
+
+static int r8711_wx_set_freq(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct iw_freq *fwrq = &wrqu->freq;
+ int rc = 0;
+
+/* If setting by frequency, convert to a channel */
+ if ((fwrq->e == 1) &&
+ (fwrq->m >= (int) 2.412e8) &&
+ (fwrq->m <= (int) 2.487e8)) {
+ int f = fwrq->m / 100000;
+ int c = 0;
+ while ((c < 14) && (f != frequency_list[c]))
+ c++;
+ fwrq->e = 0;
+ fwrq->m = c + 1;
+ }
+ /* Setting by channel number */
+ if ((fwrq->m > 14) || (fwrq->e > 0))
+ rc = -EOPNOTSUPP;
+ else {
+ int channel = fwrq->m;
+ if ((channel < 1) || (channel > 14))
+ rc = -EINVAL;
+ else {
+ /* Yes ! We can set it !!! */
+ padapter->registrypriv.channel = channel;
+ }
+ }
+ return rc;
+}
+
+static int r8711_wx_get_freq(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ wrqu->freq.m = ieee80211_wlan_frequencies[
+ pcur_bss->Configuration.DSConfig-1] * 100000;
+ wrqu->freq.e = 1;
+ wrqu->freq.i = pcur_bss->Configuration.DSConfig;
+ } else
+ return -1;
+ return 0;
+}
+
+static int r8711_wx_set_mode(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
+
+ switch (wrqu->mode) {
+ case IW_MODE_AUTO:
+ networkType = Ndis802_11AutoUnknown;
+ break;
+ case IW_MODE_ADHOC:
+ networkType = Ndis802_11IBSS;
+ break;
+ case IW_MODE_MASTER:
+ networkType = Ndis802_11APMode;
+ break;
+ case IW_MODE_INFRA:
+ networkType = Ndis802_11Infrastructure;
+ break;
+ default:
+ return -EINVAL;
+ }
+ if (Ndis802_11APMode == networkType)
+ r8712_setopmode_cmd(padapter, networkType);
+ else
+ r8712_setopmode_cmd(padapter, Ndis802_11AutoUnknown);
+ if (!r8712_set_802_11_infrastructure_mode(padapter, networkType))
+ return -1;
+ return 0;
+}
+
+static int r8711_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
+ wrqu->mode = IW_MODE_INFRA;
+ else if (check_fwstate(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) == true)
+ wrqu->mode = IW_MODE_ADHOC;
+ else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
+ wrqu->mode = IW_MODE_MASTER;
+ else
+ wrqu->mode = IW_MODE_AUTO;
+ return 0;
+}
+
+static int r871x_wx_set_pmkid(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct iw_pmksa *pPMK = (struct iw_pmksa *) extra;
+ u8 strZeroMacAddress[ETH_ALEN] = {0x00};
+ u8 strIssueBssid[ETH_ALEN] = {0x00};
+ u8 j, blInserted = false;
+ int intReturn = false;
+
+/*
+ There are the BSSID information in the bssid.sa_data array.
+ If cmd is IW_PMKSA_FLUSH, it means the wpa_suppplicant wants to clear
+ all the PMKID information. If cmd is IW_PMKSA_ADD, it means the
+ wpa_supplicant wants to add a PMKID/BSSID to driver.
+ If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to
+ remove a PMKID/BSSID from driver.
+*/
+ if (pPMK == NULL)
+ return -EINVAL;
+ memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
+ switch (pPMK->cmd) {
+ case IW_PMKSA_ADD:
+ if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN))
+ return intReturn;
+ else
+ intReturn = true;
+ blInserted = false;
+ /* overwrite PMKID */
+ for (j = 0 ; j < NUM_PMKID_CACHE; j++) {
+ if (!memcmp(psecuritypriv->PMKIDList[j].Bssid,
+ strIssueBssid, ETH_ALEN)) {
+ /* BSSID is matched, the same AP => rewrite
+ * with new PMKID. */
+ printk(KERN_INFO "r8712u: r871x_wx_set_pmkid:"
+ " BSSID exists in the PMKList.\n");
+ memcpy(psecuritypriv->PMKIDList[j].PMKID,
+ pPMK->pmkid, IW_PMKID_LEN);
+ psecuritypriv->PMKIDList[j].bUsed = true;
+ psecuritypriv->PMKIDIndex = j + 1;
+ blInserted = true;
+ break;
+ }
+ }
+ if (!blInserted) {
+ /* Find a new entry */
+ printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: Use the"
+ " new entry index = %d for this PMKID.\n",
+ psecuritypriv->PMKIDIndex);
+ memcpy(psecuritypriv->PMKIDList[psecuritypriv->
+ PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN);
+ memcpy(psecuritypriv->PMKIDList[psecuritypriv->
+ PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN);
+ psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].
+ bUsed = true;
+ psecuritypriv->PMKIDIndex++ ;
+ if (psecuritypriv->PMKIDIndex == NUM_PMKID_CACHE)
+ psecuritypriv->PMKIDIndex = 0;
+ }
+ break;
+ case IW_PMKSA_REMOVE:
+ intReturn = true;
+ for (j = 0; j < NUM_PMKID_CACHE; j++) {
+ if (!memcmp(psecuritypriv->PMKIDList[j].Bssid,
+ strIssueBssid, ETH_ALEN)) {
+ /* BSSID is matched, the same AP => Remove
+ * this PMKID information and reset it. */
+ memset(psecuritypriv->PMKIDList[j].Bssid,
+ 0x00, ETH_ALEN);
+ psecuritypriv->PMKIDList[j].bUsed = false;
+ break;
+ }
+ }
+ break;
+ case IW_PMKSA_FLUSH:
+ memset(psecuritypriv->PMKIDList, 0,
+ sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
+ psecuritypriv->PMKIDIndex = 0;
+ intReturn = true;
+ break;
+ default:
+ printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: "
+ "unknown Command\n");
+ intReturn = false;
+ break;
+ }
+ return intReturn;
+}
+
+static int r8711_wx_get_sens(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ wrqu->sens.value = 0;
+ wrqu->sens.fixed = 0; /* no auto select */
+ wrqu->sens.disabled = 1;
+ return 0;
+}
+
+static int r8711_wx_get_range(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_range *range = (struct iw_range *)extra;
+ u16 val;
+ int i;
+
+ wrqu->data.length = sizeof(*range);
+ memset(range, 0, sizeof(*range));
+ /* Let's try to keep this struct in the same order as in
+ * linux/include/wireless.h
+ */
+
+ /* TODO: See what values we can set, and remove the ones we can't
+ * set, or fill them with some default data.
+ */
+ /* ~5 Mb/s real (802.11b) */
+ range->throughput = 5 * 1000 * 1000;
+ /* TODO: 8711 sensitivity ? */
+ /* signal level threshold range */
+ /* percent values between 0 and 100. */
+ range->max_qual.qual = 100;
+ range->max_qual.level = 100;
+ range->max_qual.noise = 100;
+ range->max_qual.updated = 7; /* Updated all three */
+ range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
+ /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+ range->avg_qual.level = 20 + -98;
+ range->avg_qual.noise = 0;
+ range->avg_qual.updated = 7; /* Updated all three */
+ range->num_bitrates = RATE_COUNT;
+ for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++)
+ range->bitrate[i] = rtl8180_rates[i];
+ range->min_frag = MIN_FRAG_THRESHOLD;
+ range->max_frag = MAX_FRAG_THRESHOLD;
+ range->pm_capa = 0;
+ range->we_version_compiled = WIRELESS_EXT;
+ range->we_version_source = 16;
+ range->num_channels = 14;
+ for (i = 0, val = 0; i < 14; i++) {
+ /* Include only legal frequencies for some countries */
+ range->freq[val].i = i + 1;
+ range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
+ range->freq[val].e = 1;
+ val++;
+ if (val == IW_MAX_FREQUENCIES)
+ break;
+ }
+ range->num_frequency = val;
+ range->enc_capa = IW_ENC_CAPA_WPA |
+ IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP |
+ IW_ENC_CAPA_CIPHER_CCMP;
+ return 0;
+}
+
+static int r871x_wx_set_priv(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra)
+{
+ int ret = 0, len = 0;
+ char *ext;
+ struct iw_point *dwrq = (struct iw_point *)awrq;
+
+ len = dwrq->length;
+ ext = _malloc(len);
+ if (!_malloc(len))
+ return -ENOMEM;
+ if (copy_from_user(ext, dwrq->pointer, len)) {
+ kfree(ext);
+ return -EFAULT;
+ }
+ kfree(ext);
+ return ret;
+}
+
+/* set bssid flow
+ * s1. set_802_11_infrastructure_mode()
+ * s2. set_802_11_authentication_mode()
+ * s3. set_802_11_encryption_mode()
+ * s4. set_802_11_bssid()
+ */
+static int r8711_wx_set_wap(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *awrq,
+ char *extra)
+{
+ int ret = -EINPROGRESS;
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+ struct sockaddr *temp = (struct sockaddr *)awrq;
+ unsigned long irqL;
+ struct list_head *phead;
+ u8 *dst_bssid;
+ struct wlan_network *pnetwork = NULL;
+ enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+
+ if (padapter->bup == false)
+ return -1;
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
+ return -1;
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
+ return ret;
+ if (temp->sa_family != ARPHRD_ETHER)
+ return -EINVAL;
+ authmode = padapter->securitypriv.ndisauthtype;
+ spin_lock_irqsave(&queue->lock, irqL);
+ phead = get_list_head(queue);
+ pmlmepriv->pscanned = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, pmlmepriv->pscanned) == true)
+ break;
+ pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
+ struct wlan_network, list);
+ pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
+ dst_bssid = pnetwork->network.MacAddress;
+ if (!memcmp(dst_bssid, temp->sa_data, ETH_ALEN)) {
+ if (r8712_set_802_11_infrastructure_mode(padapter,
+ pnetwork->network.InfrastructureMode) == false)
+ ret = -1;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&queue->lock, irqL);
+ if (!ret) {
+ if (!r8712_set_802_11_authentication_mode(padapter, authmode))
+ ret = -1;
+ else {
+ if (!r8712_set_802_11_bssid(padapter, temp->sa_data))
+ ret = -1;
+ }
+ }
+ return ret;
+}
+
+static int r8711_wx_get_wap(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+
+ wrqu->ap_addr.sa_family = ARPHRD_ETHER;
+ memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+ if (check_fwstate(pmlmepriv, _FW_LINKED |
+ WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
+ memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
+ }
+ return 0;
+}
+
+static int r871x_wx_set_mlme(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int ret = 0;
+ u16 reason;
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct iw_mlme *mlme = (struct iw_mlme *) extra;
+
+ if (mlme == NULL)
+ return -1;
+ reason = cpu_to_le16(mlme->reason_code);
+ switch (mlme->cmd) {
+ case IW_MLME_DEAUTH:
+ if (!r8712_set_802_11_disassociate(padapter))
+ ret = -1;
+ break;
+ case IW_MLME_DISASSOC:
+ if (!r8712_set_802_11_disassociate(padapter))
+ ret = -1;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ return ret;
+}
+
+static int r8711_wx_set_scan(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ u8 status = true;
+
+ if (padapter->bDriverStopped == true) {
+ printk(KERN_WARNING "r8712u: in r8711_wx_set_scan: "
+ "bDriverStopped=%d\n", padapter->bDriverStopped);
+ return -1;
+ }
+ if (padapter->bup == false)
+ return -1;
+ if (padapter->hw_init_completed == false)
+ return -1;
+ if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
+ (pmlmepriv->sitesurveyctrl.traffic_busy == true))
+ return 0;
+ if (wrqu->data.length == sizeof(struct iw_scan_req)) {
+ struct iw_scan_req *req = (struct iw_scan_req *)extra;
+ if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
+ struct ndis_802_11_ssid ssid;
+ unsigned long irqL;
+ u32 len = (u32) min((u8)req->essid_len,
+ (u8)IW_ESSID_MAX_SIZE);
+ memset((unsigned char *)&ssid, 0,
+ sizeof(struct ndis_802_11_ssid));
+ memcpy(ssid.Ssid, req->essid, len);
+ ssid.SsidLength = len;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
+ _FW_UNDER_LINKING)) ||
+ (pmlmepriv->sitesurveyctrl.traffic_busy == true)) {
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
+ status = false;
+ } else
+ status = r8712_sitesurvey_cmd(padapter, &ssid);
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ }
+ } else
+ status = r8712_set_802_11_bssid_list_scan(padapter);
+ if (status == false)
+ return -1;
+ return 0;
+}
+
+static int r8711_wx_get_scan(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+ struct wlan_network *pnetwork = NULL;
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ char *ev = extra;
+ char *stop = ev + wrqu->data.length;
+ u32 ret = 0, cnt = 0;
+
+ if (padapter->bDriverStopped)
+ return -EINVAL;
+ while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
+ msleep(30);
+ cnt++;
+ if (cnt > 1000)
+ break;
+ }
+ spin_lock_irqsave(&queue->lock, irqL);
+ phead = get_list_head(queue);
+ plist = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, plist) == true)
+ break;
+ if ((stop - ev) < SCAN_ITEM_SIZE) {
+ ret = -E2BIG;
+ break;
+ }
+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+ ev = translate_scan(padapter, a, pnetwork, ev, stop);
+ plist = get_next(plist);
+ }
+ spin_unlock_irqrestore(&queue->lock, irqL);
+ wrqu->data.length = ev - extra;
+ wrqu->data.flags = 0;
+ return ret;
+}
+
+/* set ssid flow
+ * s1. set_802_11_infrastructure_mode()
+ * s2. set_802_11_authenticaion_mode()
+ * s3. set_802_11_encryption_mode()
+ * s4. set_802_11_ssid()
+ */
+static int r8711_wx_set_essid(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+ struct wlan_network *pnetwork = NULL;
+ enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ struct ndis_802_11_ssid ndis_ssid;
+ u8 *dst_ssid, *src_ssid;
+ struct list_head *phead;
+ u32 len;
+
+ if (padapter->bup == false)
+ return -1;
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
+ return -1;
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
+ return 0;
+ if (wrqu->essid.length > IW_ESSID_MAX_SIZE)
+ return -E2BIG;
+ authmode = padapter->securitypriv.ndisauthtype;
+ if (wrqu->essid.flags && wrqu->essid.length) {
+ len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ?
+ wrqu->essid.length : IW_ESSID_MAX_SIZE;
+ memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid));
+ ndis_ssid.SsidLength = len;
+ memcpy(ndis_ssid.Ssid, extra, len);
+ src_ssid = ndis_ssid.Ssid;
+ phead = get_list_head(queue);
+ pmlmepriv->pscanned = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, pmlmepriv->pscanned))
+ break;
+ pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
+ struct wlan_network, list);
+ pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
+ dst_ssid = pnetwork->network.Ssid.Ssid;
+ if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength))
+ && (pnetwork->network.Ssid.SsidLength ==
+ ndis_ssid.SsidLength)) {
+ if (!r8712_set_802_11_infrastructure_mode(
+ padapter,
+ pnetwork->network.InfrastructureMode))
+ return -1;
+ break;
+ }
+ }
+ r8712_set_802_11_authentication_mode(padapter, authmode);
+ r8712_set_802_11_ssid(padapter, &ndis_ssid);
+ }
+ return -EINPROGRESS;
+}
+
+static int r8711_wx_get_essid(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+ u32 len, ret = 0;
+
+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+ len = pcur_bss->Ssid.SsidLength;
+ wrqu->essid.length = len;
+ memcpy(extra, pcur_bss->Ssid.Ssid, len);
+ wrqu->essid.flags = 1;
+ } else
+ ret = -1;
+ return ret;
+}
+
+static int r8711_wx_set_rate(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ u32 target_rate = wrqu->bitrate.value;
+ u32 fixed = wrqu->bitrate.fixed;
+ u32 ratevalue = 0;
+ u8 datarates[NumRates];
+ u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
+ int i, ret = 0;
+
+ if (target_rate == -1) {
+ ratevalue = 11;
+ goto set_rate;
+ }
+ target_rate = target_rate / 100000;
+ switch (target_rate) {
+ case 10:
+ ratevalue = 0;
+ break;
+ case 20:
+ ratevalue = 1;
+ break;
+ case 55:
+ ratevalue = 2;
+ break;
+ case 60:
+ ratevalue = 3;
+ break;
+ case 90:
+ ratevalue = 4;
+ break;
+ case 110:
+ ratevalue = 5;
+ break;
+ case 120:
+ ratevalue = 6;
+ break;
+ case 180:
+ ratevalue = 7;
+ break;
+ case 240:
+ ratevalue = 8;
+ break;
+ case 360:
+ ratevalue = 9;
+ break;
+ case 480:
+ ratevalue = 10;
+ break;
+ case 540:
+ ratevalue = 11;
+ break;
+ default:
+ ratevalue = 11;
+ break;
+ }
+set_rate:
+ for (i = 0; i < NumRates; i++) {
+ if (ratevalue == mpdatarate[i]) {
+ datarates[i] = mpdatarate[i];
+ if (fixed == 0)
+ break;
+ } else
+ datarates[i] = 0xff;
+ }
+ if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS)
+ ret = -1;
+ return ret;
+}
+
+static int r8711_wx_get_rate(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+ struct ieee80211_ht_cap *pht_capie;
+ int i;
+ u8 *p;
+ u16 rate, max_rate = 0, ht_cap = false;
+ u32 ht_ielen = 0;
+ u8 bw_40MHz = 0, short_GI = 0;
+ u16 mcs_rate = 0;
+
+ i = 0;
+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+ p = r8712_get_ie(&pcur_bss->IEs[12],
+ _HT_CAPABILITY_IE_, &ht_ielen,
+ pcur_bss->IELength - 12);
+ if (p && ht_ielen > 0) {
+ ht_cap = true;
+ pht_capie = (struct ieee80211_ht_cap *)(p + 2);
+ memcpy(&mcs_rate , pht_capie->supp_mcs_set, 2);
+ bw_40MHz = (pht_capie->cap_info &
+ IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0;
+ short_GI = (pht_capie->cap_info &
+ (IEEE80211_HT_CAP_SGI_20 |
+ IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
+ }
+ while ((pcur_bss->SupportedRates[i] != 0) &&
+ (pcur_bss->SupportedRates[i] != 0xFF)) {
+ rate = pcur_bss->SupportedRates[i] & 0x7F;
+ if (rate > max_rate)
+ max_rate = rate;
+ wrqu->bitrate.fixed = 0; /* no auto select */
+ wrqu->bitrate.value = rate*500000;
+ i++;
+ }
+ if (ht_cap == true) {
+ if (mcs_rate & 0x8000) /* MCS15 */
+ max_rate = (bw_40MHz) ? ((short_GI) ? 300 :
+ 270) : ((short_GI) ? 144 : 130);
+ else if (mcs_rate & 0x0080) /* MCS7 */
+ max_rate = (bw_40MHz) ? ((short_GI) ? 150 :
+ 135) : ((short_GI) ? 72 : 65);
+ else /* default MCS7 */
+ max_rate = (bw_40MHz) ? ((short_GI) ? 150 :
+ 135) : ((short_GI) ? 72 : 65);
+ max_rate *= 2; /* Mbps/2 */
+ wrqu->bitrate.value = max_rate * 500000;
+ } else {
+ wrqu->bitrate.value = max_rate * 500000;
+ }
+ } else
+ return -1;
+ return 0;
+}
+
+static int r8711_wx_get_rts(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+
+ wrqu->rts.value = padapter->registrypriv.rts_thresh;
+ wrqu->rts.fixed = 0; /* no auto select */
+ return 0;
+}
+
+static int r8711_wx_set_frag(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+
+ if (wrqu->frag.disabled)
+ padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
+ else {
+ if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
+ wrqu->frag.value > MAX_FRAG_THRESHOLD)
+ return -EINVAL;
+ padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1;
+ }
+ return 0;
+}
+
+static int r8711_wx_get_frag(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+
+ wrqu->frag.value = padapter->xmitpriv.frag_len;
+ wrqu->frag.fixed = 0; /* no auto select */
+ return 0;
+}
+
+static int r8711_wx_get_retry(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ wrqu->retry.value = 7;
+ wrqu->retry.fixed = 0; /* no auto select */
+ wrqu->retry.disabled = 1;
+ return 0;
+}
+
+static int r8711_wx_set_enc(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ u32 key;
+ u32 keyindex_provided;
+ struct NDIS_802_11_WEP wep;
+ enum NDIS_802_11_AUTHENTICATION_MODE authmode;
+ struct iw_point *erq = &(wrqu->encoding);
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+
+ key = erq->flags & IW_ENCODE_INDEX;
+ memset(&wep, 0, sizeof(struct NDIS_802_11_WEP));
+ if (erq->flags & IW_ENCODE_DISABLED) {
+ printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
+ "EncryptionDisabled\n");
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11EncryptionDisabled;
+ padapter->securitypriv.PrivacyAlgrthm = _NO_PRIVACY_;
+ padapter->securitypriv.XGrpPrivacy = _NO_PRIVACY_;
+ padapter->securitypriv.AuthAlgrthm = 0; /* open system */
+ authmode = Ndis802_11AuthModeOpen;
+ padapter->securitypriv.ndisauthtype = authmode;
+ return 0;
+ }
+ if (key) {
+ if (key > WEP_KEYS)
+ return -EINVAL;
+ key--;
+ keyindex_provided = 1;
+ } else {
+ keyindex_provided = 0;
+ key = padapter->securitypriv.PrivacyKeyIndex;
+ }
+ /* set authentication mode */
+ if (erq->flags & IW_ENCODE_OPEN) {
+ printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
+ "IW_ENCODE_OPEN\n");
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.AuthAlgrthm = 0; /* open system */
+ padapter->securitypriv.PrivacyAlgrthm = _NO_PRIVACY_;
+ padapter->securitypriv.XGrpPrivacy = _NO_PRIVACY_;
+ authmode = Ndis802_11AuthModeOpen;
+ padapter->securitypriv.ndisauthtype = authmode;
+ } else if (erq->flags & IW_ENCODE_RESTRICTED) {
+ printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
+ "IW_ENCODE_RESTRICTED\n");
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.AuthAlgrthm = 1; /* shared system */
+ padapter->securitypriv.PrivacyAlgrthm = _WEP40_;
+ padapter->securitypriv.XGrpPrivacy = _WEP40_;
+ authmode = Ndis802_11AuthModeShared;
+ padapter->securitypriv.ndisauthtype = authmode;
+ } else {
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption1Enabled;
+ padapter->securitypriv.AuthAlgrthm = 0; /* open system */
+ padapter->securitypriv.PrivacyAlgrthm = _NO_PRIVACY_;
+ padapter->securitypriv.XGrpPrivacy = _NO_PRIVACY_;
+ authmode = Ndis802_11AuthModeOpen;
+ padapter->securitypriv.ndisauthtype = authmode;
+ }
+ wep.KeyIndex = key;
+ if (erq->length > 0) {
+ wep.KeyLength = erq->length <= 5 ? 5 : 13;
+ wep.Length = wep.KeyLength +
+ FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial);
+ } else {
+ wep.KeyLength = 0 ;
+ if (keyindex_provided == 1) { /* set key_id only, no given
+ * KeyMaterial(erq->length==0).*/
+ padapter->securitypriv.PrivacyKeyIndex = key;
+ switch (padapter->securitypriv.DefKeylen[key]) {
+ case 5:
+ padapter->securitypriv.PrivacyAlgrthm =
+ _WEP40_;
+ break;
+ case 13:
+ padapter->securitypriv.PrivacyAlgrthm =
+ _WEP104_;
+ break;
+ default:
+ padapter->securitypriv.PrivacyAlgrthm =
+ _NO_PRIVACY_;
+ break;
+ }
+ return 0;
+ }
+ }
+ wep.KeyIndex |= 0x80000000; /* transmit key */
+ memcpy(wep.KeyMaterial, keybuf, wep.KeyLength);
+ if (r8712_set_802_11_add_wep(padapter, &wep) == _FAIL)
+ return -EOPNOTSUPP;
+ return 0;
+}
+
+static int r8711_wx_get_enc(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ uint key, ret = 0;
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ struct iw_point *erq = &(wrqu->encoding);
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
+ if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ return 0;
+ }
+ }
+ key = erq->flags & IW_ENCODE_INDEX;
+ if (key) {
+ if (key > WEP_KEYS)
+ return -EINVAL;
+ key--;
+ } else {
+ key = padapter->securitypriv.PrivacyKeyIndex;
+ }
+ erq->flags = key + 1;
+ switch (padapter->securitypriv.ndisencryptstatus) {
+ case Ndis802_11EncryptionNotSupported:
+ case Ndis802_11EncryptionDisabled:
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ break;
+ case Ndis802_11Encryption1Enabled:
+ erq->length = padapter->securitypriv.DefKeylen[key];
+ if (erq->length) {
+ memcpy(keybuf, padapter->securitypriv.DefKey[
+ key].skey, padapter->securitypriv.
+ DefKeylen[key]);
+ erq->flags |= IW_ENCODE_ENABLED;
+ if (padapter->securitypriv.ndisauthtype ==
+ Ndis802_11AuthModeOpen)
+ erq->flags |= IW_ENCODE_OPEN;
+ else if (padapter->securitypriv.ndisauthtype ==
+ Ndis802_11AuthModeShared)
+ erq->flags |= IW_ENCODE_RESTRICTED;
+ } else {
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ }
+ break;
+ case Ndis802_11Encryption2Enabled:
+ case Ndis802_11Encryption3Enabled:
+ erq->length = 16;
+ erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN |
+ IW_ENCODE_NOKEY);
+ break;
+ default:
+ erq->length = 0;
+ erq->flags |= IW_ENCODE_DISABLED;
+ break;
+ }
+ return ret;
+}
+
+static int r8711_wx_get_power(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ wrqu->power.value = 0;
+ wrqu->power.fixed = 0; /* no auto select */
+ wrqu->power.disabled = 1;
+ return 0;
+}
+
+static int r871x_wx_set_gen_ie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+
+ return r871x_set_wpa_ie(padapter, extra, wrqu->data.length);
+}
+
+static int r871x_wx_set_auth(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct iw_param *param = (struct iw_param *)&(wrqu->param);
+ int paramid;
+ int paramval;
+ int ret = 0;
+
+ paramid = param->flags & IW_AUTH_INDEX;
+ paramval = param->value;
+ switch (paramid) {
+ case IW_AUTH_WPA_VERSION:
+ break;
+ case IW_AUTH_CIPHER_PAIRWISE:
+ break;
+ case IW_AUTH_CIPHER_GROUP:
+ break;
+ case IW_AUTH_KEY_MGMT:
+ /*
+ * ??? does not use these parameters
+ */
+ break;
+ case IW_AUTH_TKIP_COUNTERMEASURES:
+ if (paramval) {
+ /* wpa_supplicant is enabling tkip countermeasure. */
+ padapter->securitypriv.btkip_countermeasure = true;
+ } else {
+ /* wpa_supplicant is disabling tkip countermeasure. */
+ padapter->securitypriv.btkip_countermeasure = false;
+ }
+ break;
+ case IW_AUTH_DROP_UNENCRYPTED:
+ /* HACK:
+ *
+ * wpa_supplicant calls set_wpa_enabled when the driver
+ * is loaded and unloaded, regardless of if WPA is being
+ * used. No other calls are made which can be used to
+ * determine if encryption will be used or not prior to
+ * association being expected. If encryption is not being
+ * used, drop_unencrypted is set to false, else true -- we
+ * can use this to determine if the CAP_PRIVACY_ON bit should
+ * be set.
+ */
+ if (padapter->securitypriv.ndisencryptstatus ==
+ Ndis802_11Encryption1Enabled) {
+ /* it means init value, or using wep,
+ * ndisencryptstatus =
+ * Ndis802_11Encryption1Enabled,
+ * then it needn't reset it;
+ */
+ break;
+ }
+
+ if (paramval) {
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11EncryptionDisabled;
+ padapter->securitypriv.PrivacyAlgrthm =
+ _NO_PRIVACY_;
+ padapter->securitypriv.XGrpPrivacy =
+ _NO_PRIVACY_;
+ padapter->securitypriv.AuthAlgrthm = 0;
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeOpen;
+ }
+ break;
+ case IW_AUTH_80211_AUTH_ALG:
+ ret = wpa_set_auth_algs(dev, (u32)paramval);
+ break;
+ case IW_AUTH_WPA_ENABLED:
+ break;
+ case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+ break;
+ case IW_AUTH_PRIVACY_INVOKED:
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+
+ return ret;
+}
+
+static int r871x_wx_set_enc_ext(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_point *pencoding = &wrqu->encoding;
+ struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
+ struct ieee_param *param = NULL;
+ char *alg_name;
+ u32 param_len;
+ int ret = 0;
+
+ param_len = sizeof(struct ieee_param) + pext->key_len;
+ param = (struct ieee_param *)_malloc(param_len);
+ if (param == NULL)
+ return -1;
+ memset(param, 0, param_len);
+ param->cmd = IEEE_CMD_SET_ENCRYPTION;
+ memset(param->sta_addr, 0xff, ETH_ALEN);
+ switch (pext->alg) {
+ case IW_ENCODE_ALG_NONE:
+ alg_name = "none";
+ break;
+ case IW_ENCODE_ALG_WEP:
+ alg_name = "WEP";
+ break;
+ case IW_ENCODE_ALG_TKIP:
+ alg_name = "TKIP";
+ break;
+ case IW_ENCODE_ALG_CCMP:
+ alg_name = "CCMP";
+ break;
+ default:
+ return -1;
+ }
+ strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
+ if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
+ param->u.crypt.set_tx = 0;
+ if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
+ param->u.crypt.set_tx = 1;
+ param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1;
+ if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
+ memcpy(param->u.crypt.seq, pext->rx_seq, 8);
+ if (pext->key_len) {
+ param->u.crypt.key_len = pext->key_len;
+ memcpy(param + 1, pext + 1, pext->key_len);
+ }
+ ret = wpa_set_encryption(dev, param, param_len);
+ if (param)
+ kfree((u8 *)param);
+ return ret;
+}
+
+static int r871x_wx_get_nick(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ if (extra) {
+ wrqu->data.length = 8;
+ wrqu->data.flags = 1;
+ memcpy(extra, "rtl_wifi", 8);
+ }
+ return 0;
+}
+
+static int r8711_wx_read32(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ u32 addr;
+ u32 data32;
+
+ get_user(addr, (u32 __user *)wrqu->data.pointer);
+ data32 = r8712_read32(padapter, addr);
+ put_user(data32, (u32 __user *)wrqu->data.pointer);
+ wrqu->data.length = (data32 & 0xffff0000) >> 16;
+ wrqu->data.flags = data32 & 0xffff;
+ get_user(addr, (u32 __user *)wrqu->data.pointer);
+ return 0;
+}
+
+static int r8711_wx_write32(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *keybuf)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ u32 addr;
+ u32 data32;
+
+ get_user(addr, (u32 __user *)wrqu->data.pointer);
+ data32 = ((u32)wrqu->data.length<<16) | (u32)wrqu->data.flags ;
+ r8712_write32(padapter, addr, data32);
+ return 0;
+}
+
+static int dummy(struct net_device *dev,
+ struct iw_request_info *a,
+ union iwreq_data *wrqu, char *b)
+{
+ return -1;
+}
+
+static int r8711_drvext_hdl(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ return 0;
+}
+
+static int r871x_mp_ioctl_hdl(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct iw_point *p = &wrqu->data;
+ struct oid_par_priv oid_par;
+ struct mp_ioctl_handler *phandler;
+ struct mp_ioctl_param *poidparam;
+ unsigned long BytesRead, BytesWritten, BytesNeeded;
+ u8 *pparmbuf = NULL, bset;
+ u16 len;
+ uint status;
+ int ret = 0;
+
+ if ((!p->length) || (!p->pointer)) {
+ ret = -EINVAL;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ bset = (u8)(p->flags & 0xFFFF);
+ len = p->length;
+ pparmbuf = NULL;
+ pparmbuf = (u8 *)_malloc(len);
+ if (pparmbuf == NULL) {
+ ret = -ENOMEM;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ if (copy_from_user(pparmbuf, p->pointer, len)) {
+ ret = -EFAULT;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ poidparam = (struct mp_ioctl_param *)pparmbuf;
+ if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) {
+ ret = -EINVAL;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ phandler = mp_ioctl_hdl + poidparam->subcode;
+ if ((phandler->paramsize != 0) &&
+ (poidparam->len < phandler->paramsize)) {
+ ret = -EINVAL;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ if (phandler->oid == 0 && phandler->handler)
+ status = phandler->handler(&oid_par);
+ else if (phandler->handler) {
+ oid_par.adapter_context = padapter;
+ oid_par.oid = phandler->oid;
+ oid_par.information_buf = poidparam->data;
+ oid_par.information_buf_len = poidparam->len;
+ oid_par.dbg = 0;
+ BytesWritten = 0;
+ BytesNeeded = 0;
+ if (bset) {
+ oid_par.bytes_rw = &BytesRead;
+ oid_par.bytes_needed = &BytesNeeded;
+ oid_par.type_of_oid = SET_OID;
+ } else {
+ oid_par.bytes_rw = &BytesWritten;
+ oid_par.bytes_needed = &BytesNeeded;
+ oid_par.type_of_oid = QUERY_OID;
+ }
+ status = phandler->handler(&oid_par);
+ /* todo:check status, BytesNeeded, etc. */
+ } else {
+ printk(KERN_INFO "r8712u: r871x_mp_ioctl_hdl(): err!,"
+ " subcode=%d, oid=%d, handler=%p\n",
+ poidparam->subcode, phandler->oid, phandler->handler);
+ ret = -EFAULT;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+ if (bset == 0x00) { /* query info */
+ if (copy_to_user(p->pointer, pparmbuf, len))
+ ret = -EFAULT;
+ }
+ if (status) {
+ ret = -EFAULT;
+ goto _r871x_mp_ioctl_hdl_exit;
+ }
+_r871x_mp_ioctl_hdl_exit:
+ if (pparmbuf != NULL)
+ kfree(pparmbuf);
+ return ret;
+}
+
+static int r871x_get_ap_info(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+ struct iw_point *pdata = &wrqu->data;
+ struct wlan_network *pnetwork = NULL;
+ u32 cnt = 0, wpa_ielen;
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ unsigned char *pbuf;
+ u8 bssid[ETH_ALEN];
+ char data[32];
+
+ if (padapter->bDriverStopped || (pdata == NULL))
+ return -EINVAL;
+ while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
+ msleep(30);
+ cnt++;
+ if (cnt > 100)
+ break;
+ }
+ pdata->flags = 0;
+ if (pdata->length >= 32) {
+ if (copy_from_user(data, pdata->pointer, 32))
+ return -EINVAL;
+ } else
+ return -EINVAL;
+ spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
+ phead = get_list_head(queue);
+ plist = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, plist) == true)
+ break;
+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+ if (hwaddr_aton_i(data, bssid)) {
+ printk(KERN_INFO "r8712u: Invalid BSSID '%s'.\n",
+ (u8 *)data);
+ spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock),
+ irqL);
+ return -EINVAL;
+ }
+ printk(KERN_INFO "r8712u: BSSID:" MACSTR "\n",
+ MAC2STR(bssid));
+ if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) {
+ /* BSSID match, then check if supporting wpa/wpa2 */
+ pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12],
+ &wpa_ielen, pnetwork->network.IELength-12);
+ if (pbuf && (wpa_ielen > 0)) {
+ pdata->flags = 1;
+ break;
+ }
+ pbuf = r8712_get_wpa2_ie(&pnetwork->network.IEs[12],
+ &wpa_ielen, pnetwork->network.IELength-12);
+ if (pbuf && (wpa_ielen > 0)) {
+ pdata->flags = 2;
+ break;
+ }
+ }
+ plist = get_next(plist);
+ }
+ spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock), irqL);
+ if (pdata->length >= 34) {
+ if (copy_to_user((u8 __user *)pdata->pointer + 32,
+ (u8 *)&pdata->flags, 1))
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int r871x_set_pid(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ struct iw_point *pdata = &wrqu->data;
+
+ if ((padapter->bDriverStopped) || (pdata == NULL))
+ return -EINVAL;
+ if (copy_from_user(&padapter->pid, pdata->pointer, sizeof(int)))
+ return -EINVAL;
+ return 0;
+}
+
+static int r871x_wps_start(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(dev);
+ struct iw_point *pdata = &wrqu->data;
+ u32 u32wps_start = 0;
+ unsigned int uintRet = 0;
+
+ uintRet = copy_from_user((void *)&u32wps_start, pdata->pointer, 4);
+ if ((padapter->bDriverStopped) || (pdata == NULL))
+ return -EINVAL;
+ if (u32wps_start == 0)
+ u32wps_start = *extra;
+ if (u32wps_start == 1) /* WPS Start */
+ padapter->ledpriv.LedControlHandler(padapter,
+ LED_CTL_START_WPS);
+ else if (u32wps_start == 2) /* WPS Stop because of wps success */
+ padapter->ledpriv.LedControlHandler(padapter,
+ LED_CTL_STOP_WPS);
+ else if (u32wps_start == 3) /* WPS Stop because of wps fail */
+ padapter->ledpriv.LedControlHandler(padapter,
+ LED_CTL_STOP_WPS_FAIL);
+ return 0;
+}
+
+static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+
+ switch (name) {
+ case IEEE_PARAM_WPA_ENABLED:
+ padapter->securitypriv.AuthAlgrthm = 2; /* 802.1x */
+ switch ((value)&0xff) {
+ case 1: /* WPA */
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeWPAPSK; /* WPA_PSK */
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption2Enabled;
+ break;
+ case 2: /* WPA2 */
+ padapter->securitypriv.ndisauthtype =
+ Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */
+ padapter->securitypriv.ndisencryptstatus =
+ Ndis802_11Encryption3Enabled;
+ break;
+ }
+ break;
+ case IEEE_PARAM_TKIP_COUNTERMEASURES:
+ break;
+ case IEEE_PARAM_DROP_UNENCRYPTED:
+ /* HACK:
+ *
+ * wpa_supplicant calls set_wpa_enabled when the driver
+ * is loaded and unloaded, regardless of if WPA is being
+ * used. No other calls are made which can be used to
+ * determine if encryption will be used or not prior to
+ * association being expected. If encryption is not being
+ * used, drop_unencrypted is set to false, else true -- we
+ * can use this to determine if the CAP_PRIVACY_ON bit should
+ * be set.
+ */
+ break;
+ case IEEE_PARAM_PRIVACY_INVOKED:
+ break;
+ case IEEE_PARAM_AUTH_ALGS:
+ return wpa_set_auth_algs(dev, value);
+ break;
+ case IEEE_PARAM_IEEE_802_1X:
+ break;
+ case IEEE_PARAM_WPAX_SELECT:
+ /* added for WPA2 mixed mode */
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ return 0;
+}
+
+static int wpa_mlme(struct net_device *dev, u32 command, u32 reason)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+
+ switch (command) {
+ case IEEE_MLME_STA_DEAUTH:
+ if (!r8712_set_802_11_disassociate(padapter))
+ return -1;
+ break;
+ case IEEE_MLME_STA_DISASSOC:
+ if (!r8712_set_802_11_disassociate(padapter))
+ return -1;
+ break;
+ default:
+ return -EOPNOTSUPP;
+ }
+ return 0;
+}
+
+static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
+{
+ struct ieee_param *param;
+ int ret = 0;
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+
+ if (p->length < sizeof(struct ieee_param) || !p->pointer)
+ return -EINVAL;
+ param = (struct ieee_param *)_malloc(p->length);
+ if (param == NULL)
+ return -ENOMEM;
+ if (copy_from_user(param, p->pointer, p->length))
+ kfree((u8 *)param);
+ return -EFAULT;
+ switch (param->cmd) {
+ case IEEE_CMD_SET_WPA_PARAM:
+ ret = wpa_set_param(dev, param->u.wpa_param.name,
+ param->u.wpa_param.value);
+ break;
+ case IEEE_CMD_SET_WPA_IE:
+ ret = r871x_set_wpa_ie(padapter, (char *)param->u.wpa_ie.data,
+ (u16)param->u.wpa_ie.len);
+ break;
+ case IEEE_CMD_SET_ENCRYPTION:
+ ret = wpa_set_encryption(dev, param, p->length);
+ break;
+ case IEEE_CMD_MLME:
+ ret = wpa_mlme(dev, param->u.mlme.command,
+ param->u.mlme.reason_code);
+ break;
+ default:
+ ret = -EOPNOTSUPP;
+ break;
+ }
+ if (ret == 0 && copy_to_user(p->pointer, param, p->length))
+ ret = -EFAULT;
+ kfree((u8 *)param);
+ return ret;
+}
+
+/* based on "driver_ipw" and for hostapd */
+int r871x_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ struct iwreq *wrq = (struct iwreq *)rq;
+
+ switch (cmd) {
+ case RTL_IOCTL_WPA_SUPPLICANT:
+ return wpa_supplicant_ioctl(dev, &wrq->u.data);
+ default:
+ return -EOPNOTSUPP;
+ }
+ return 0;
+}
+
+static iw_handler r8711_handlers[] = {
+ NULL, /* SIOCSIWCOMMIT */
+ r8711_wx_get_name, /* SIOCGIWNAME */
+ dummy, /* SIOCSIWNWID */
+ dummy, /* SIOCGIWNWID */
+ r8711_wx_set_freq, /* SIOCSIWFREQ */
+ r8711_wx_get_freq, /* SIOCGIWFREQ */
+ r8711_wx_set_mode, /* SIOCSIWMODE */
+ r8711_wx_get_mode, /* SIOCGIWMODE */
+ dummy, /* SIOCSIWSENS */
+ r8711_wx_get_sens, /* SIOCGIWSENS */
+ NULL, /* SIOCSIWRANGE */
+ r8711_wx_get_range, /* SIOCGIWRANGE */
+ r871x_wx_set_priv, /* SIOCSIWPRIV */
+ NULL, /* SIOCGIWPRIV */
+ NULL, /* SIOCSIWSTATS */
+ NULL, /* SIOCGIWSTATS */
+ dummy, /* SIOCSIWSPY */
+ dummy, /* SIOCGIWSPY */
+ NULL, /* SIOCGIWTHRSPY */
+ NULL, /* SIOCWIWTHRSPY */
+ r8711_wx_set_wap, /* SIOCSIWAP */
+ r8711_wx_get_wap, /* SIOCGIWAP */
+ r871x_wx_set_mlme, /* request MLME operation;
+ * uses struct iw_mlme */
+ dummy, /* SIOCGIWAPLIST -- deprecated */
+ r8711_wx_set_scan, /* SIOCSIWSCAN */
+ r8711_wx_get_scan, /* SIOCGIWSCAN */
+ r8711_wx_set_essid, /* SIOCSIWESSID */
+ r8711_wx_get_essid, /* SIOCGIWESSID */
+ dummy, /* SIOCSIWNICKN */
+ r871x_wx_get_nick, /* SIOCGIWNICKN */
+ NULL, /* -- hole -- */
+ NULL, /* -- hole -- */
+ r8711_wx_set_rate, /* SIOCSIWRATE */
+ r8711_wx_get_rate, /* SIOCGIWRATE */
+ dummy, /* SIOCSIWRTS */
+ r8711_wx_get_rts, /* SIOCGIWRTS */
+ r8711_wx_set_frag, /* SIOCSIWFRAG */
+ r8711_wx_get_frag, /* SIOCGIWFRAG */
+ dummy, /* SIOCSIWTXPOW */
+ dummy, /* SIOCGIWTXPOW */
+ dummy, /* SIOCSIWRETRY */
+ r8711_wx_get_retry, /* SIOCGIWRETRY */
+ r8711_wx_set_enc, /* SIOCSIWENCODE */
+ r8711_wx_get_enc, /* SIOCGIWENCODE */
+ dummy, /* SIOCSIWPOWER */
+ r8711_wx_get_power, /* SIOCGIWPOWER */
+ NULL, /*---hole---*/
+ NULL, /*---hole---*/
+ r871x_wx_set_gen_ie, /* SIOCSIWGENIE */
+ NULL, /* SIOCGIWGENIE */
+ r871x_wx_set_auth, /* SIOCSIWAUTH */
+ NULL, /* SIOCGIWAUTH */
+ r871x_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
+ NULL, /* SIOCGIWENCODEEXT */
+ r871x_wx_set_pmkid, /* SIOCSIWPMKSA */
+ NULL, /*---hole---*/
+};
+
+static const struct iw_priv_args r8711_private_args[] = {
+ {
+ SIOCIWFIRSTPRIV + 0x0,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "read32"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x1,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "write32"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x4,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x5,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "setpid"
+ },
+ {
+ SIOCIWFIRSTPRIV + 0x6,
+ IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start"
+ }
+};
+
+static iw_handler r8711_private_handler[] = {
+ r8711_wx_read32,
+ r8711_wx_write32,
+ r8711_drvext_hdl,
+ r871x_mp_ioctl_hdl,
+ r871x_get_ap_info, /*for MM DTV platform*/
+ r871x_set_pid,
+ r871x_wps_start,
+};
+
+static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev)
+{
+ struct _adapter *padapter = (struct _adapter *) _netdev_priv(dev);
+ struct iw_statistics *piwstats = &padapter->iwstats;
+ int tmp_level = 0;
+ int tmp_qual = 0;
+ int tmp_noise = 0;
+
+ if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) {
+ piwstats->qual.qual = 0;
+ piwstats->qual.level = 0;
+ piwstats->qual.noise = 0;
+ } else {
+ /* show percentage, we need transfer dbm to orignal value. */
+ tmp_level = padapter->recvpriv.fw_rssi;
+ tmp_qual = padapter->recvpriv.signal;
+ tmp_noise = padapter->recvpriv.noise;
+ piwstats->qual.level = tmp_level;
+ piwstats->qual.qual = tmp_qual;
+ piwstats->qual.noise = tmp_noise;
+ }
+ piwstats->qual.updated = IW_QUAL_ALL_UPDATED;
+ return &padapter->iwstats;
+}
+
+struct iw_handler_def r871x_handlers_def = {
+ .standard = r8711_handlers,
+ .num_standard = sizeof(r8711_handlers) / sizeof(iw_handler),
+ .private = r8711_private_handler,
+ .private_args = (struct iw_priv_args *)r8711_private_args,
+ .num_private = sizeof(r8711_private_handler) / sizeof(iw_handler),
+ .num_private_args = sizeof(r8711_private_args) /
+ sizeof(struct iw_priv_args),
+ .get_wireless_stats = r871x_get_wireless_stats,
+};
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
new file mode 100644
index 000000000000..7adbe82cd085
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
@@ -0,0 +1,535 @@
+/******************************************************************************
+ * rtl871x_ioctl_rtl.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_IOCTL_RTL_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wlan_bssdef.h"
+#include "wifi.h"
+#include "rtl871x_ioctl.h"
+#include "rtl871x_ioctl_set.h"
+#include "rtl871x_ioctl_rtl.h"
+#include "mp_custom_oid.h"
+#include "rtl871x_mp.h"
+#include "rtl871x_mp_ioctl.h"
+
+uint oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_smallpacket_crcerr;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_middlepacket_crcerr;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_largepacket_crcerr;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_pkts +
+ padapter->recvpriv.rx_drop;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(uint *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_icv_err;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH ;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 preamblemode = 0 ;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ if (padapter->registrypriv.preamble == PREAMBLE_LONG)
+ preamblemode = 0;
+ else if (padapter->registrypriv.preamble == PREAMBLE_AUTO)
+ preamblemode = 1;
+ else if (padapter->registrypriv.preamble == PREAMBLE_SHORT)
+ preamblemode = 2;
+ *(u32 *)poid_par_priv->information_buf = preamblemode;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ *(u16 *)poid_par_priv->information_buf = peeprompriv->channel_plan;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_set_channelplan_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ peeprompriv->channel_plan = *(u16 *)poid_par_priv->information_buf;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 preamblemode = 0;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ preamblemode = *(u32 *)poid_par_priv->information_buf;
+ if (preamblemode == 0)
+ padapter->registrypriv.preamble = PREAMBLE_LONG;
+ else if (preamblemode == 1)
+ padapter->registrypriv.preamble = PREAMBLE_AUTO;
+ else if (preamblemode == 2)
+ padapter->registrypriv.preamble = PREAMBLE_SHORT;
+ *(u32 *)poid_par_priv->information_buf = preamblemode;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_dedicate_probe_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->xmitpriv.tx_bytes;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ padapter->recvpriv.rx_bytes;
+ *poid_par_priv->bytes_rw = poid_par_priv->
+ information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_current_tx_power_level_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct NDIS_802_11_CONFIGURATION *pnic_Config;
+ u32 channelnum;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
+ (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
+ pnic_Config = &pmlmepriv->cur_network.network.Configuration;
+ else
+ pnic_Config = &padapter->registrypriv.dev_network.
+ Configuration;
+ channelnum = pnic_Config->DSConfig;
+ *(u32 *)poid_par_priv->information_buf = channelnum;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ u32 ulInfo = 0;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len >= sizeof(u32)) {
+ ulInfo |= 0x0100; /* WIRELESS_MODE_B */
+ ulInfo |= 0x0200; /* WIRELESS_MODE_G */
+ ulInfo |= 0x0400; /* WIRELESS_MODE_A */
+ *(u32 *) poid_par_priv->information_buf = ulInfo;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ return NDIS_STATUS_INVALID_LENGTH;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+
+uint oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv*
+ poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv*
+ poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len ==
+ (sizeof(unsigned long) * 3)) {
+ if (!r8712_setrfreg_cmd(Adapter,
+ *(unsigned char *)poid_par_priv->information_buf,
+ (unsigned long)(*((unsigned long *)
+ poid_par_priv->information_buf + 2))))
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) {
+ if (Adapter->mppriv.act_in_progress == true)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ else {
+ /* init workparam */
+ Adapter->mppriv.act_in_progress = true;
+ Adapter->mppriv.workparam.bcompleted = false;
+ Adapter->mppriv.workparam.act_type = MPT_READ_RF;
+ Adapter->mppriv.workparam.io_offset = *(unsigned long *)
+ poid_par_priv->information_buf;
+ Adapter->mppriv.workparam.io_value = 0xcccccccc;
+
+ /* RegOffsetValue - The offset of RF register to read.
+ * RegDataWidth - The data width of RF register to read.
+ * RegDataValue - The value to read.
+ * RegOffsetValue = *((unsigned long *)InformationBuffer);
+ * RegDataWidth = *((unsigned long *)InformationBuffer+1);
+ * RegDataValue = *((unsigned long *)InformationBuffer+2);
+ */
+ if (!r8712_getrfreg_cmd(Adapter,
+ *(unsigned char *)poid_par_priv->information_buf,
+ (unsigned char *)&Adapter->mppriv.workparam.
+ io_value))
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ }
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+enum _CONNECT_STATE_{
+ CHECKINGSTATUS,
+ ASSOCIATED,
+ ADHOCMODE,
+ NOTASSOCIATED
+};
+
+uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *padapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ u32 ulInfo;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ /* nStatus==0 CheckingStatus
+ * nStatus==1 Associated
+ * nStatus==2 AdHocMode
+ * nStatus==3 NotAssociated
+ */
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
+ ulInfo = CHECKINGSTATUS;
+ else if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
+ ulInfo = ASSOCIATED;
+ else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
+ ulInfo = ADHOCMODE;
+ else
+ ulInfo = NOTASSOCIATED ;
+ *(u32 *)poid_par_priv->information_buf = ulInfo;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h
new file mode 100644
index 000000000000..4f1aa876d75d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.h
@@ -0,0 +1,96 @@
+#ifndef _RTL871X_IOCTL_RTL_H
+#define _RTL871X_IOCTL_RTL_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+/*************** oid_rtl_seg_01_01 **************/
+uint oid_rt_get_signal_quality_hdl(
+ struct oid_par_priv *poid_par_priv);/*84*/
+uint oid_rt_get_small_packet_crc_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_middle_packet_crc_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_large_packet_crc_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_tx_retry_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_rx_retry_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_rx_total_packet_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_tx_beacon_ok_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_tx_beacon_err_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_rx_icv_err_hdl(
+ struct oid_par_priv *poid_par_priv);/*93*/
+uint oid_rt_set_encryption_algorithm_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_preamble_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_ap_ip_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_channelplan_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_channelplan_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_preamble_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_bcn_intvl_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_dedicate_probe_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_total_tx_bytes_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_total_rx_bytes_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_current_tx_power_level_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_enc_key_mismatch_count_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_enc_key_match_count_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_channel_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_hardware_radio_off_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_key_mismatch_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_supported_wireless_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_channel_list_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_scan_in_progress_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_forced_data_rate_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_wireless_mode_for_scan_list_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_bss_wireless_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_scan_with_magic_packet_hdl(
+ struct oid_par_priv *poid_par_priv);
+
+/************** oid_rtl_seg_01_03 section start **************/
+uint oid_rt_ap_get_associated_station_list_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_ap_switch_into_ap_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_ap_supported_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_ap_set_passphrase_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_01_11 */
+uint oid_rt_pro_rf_write_registry_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_rf_read_registry_hdl(
+ struct oid_par_priv *poid_par_priv);
+/*************** oid_rtl_seg_03_00 section start **************/
+uint oid_rt_get_connect_state_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_default_key_id_hdl(
+ struct oid_par_priv *poid_par_priv);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
new file mode 100644
index 000000000000..8b1451d03069
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -0,0 +1,379 @@
+/******************************************************************************
+ * rtl871x_ioctl_set.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_IOCTL_SET_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_ioctl_set.h"
+#include "usb_osintf.h"
+#include "usb_ops.h"
+
+#define IS_MAC_ADDRESS_BROADCAST(addr) \
+( \
+ ((addr[0] == 0xff) && (addr[1] == 0xff) && \
+ (addr[2] == 0xff) && (addr[3] == 0xff) && \
+ (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \
+)
+
+static u8 validate_ssid(struct ndis_802_11_ssid *ssid)
+{
+ u8 i;
+
+ if (ssid->SsidLength > 32)
+ return false;
+ for (i = 0; i < ssid->SsidLength; i++) {
+ /* wifi, printable ascii code must be supported */
+ if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e)))
+ return false;
+ }
+ return true;
+}
+
+static u8 do_join(struct _adapter *padapter)
+{
+ struct list_head *plist, *phead;
+ u8 *pibss = NULL;
+ struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
+ struct __queue *queue = &(pmlmepriv->scanned_queue);
+
+ phead = get_list_head(queue);
+ plist = get_next(phead);
+ pmlmepriv->cur_network.join_res = -2;
+ pmlmepriv->fw_state |= _FW_UNDER_LINKING;
+ pmlmepriv->pscanned = plist;
+ pmlmepriv->to_join = true;
+ if (_queue_empty(queue) == true) {
+ if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
+ pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
+ /* when set_ssid/set_bssid for do_join(), but scanning queue
+ * is empty we try to issue sitesurvey firstly
+ */
+ if (pmlmepriv->sitesurveyctrl.traffic_busy == false)
+ r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
+ return true;
+ } else {
+ int ret;
+
+ ret = r8712_select_and_join_from_scan(pmlmepriv);
+ if (ret == _SUCCESS)
+ _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
+ else {
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+ /* submit r8712_createbss_cmd to change to an
+ * ADHOC_MASTER pmlmepriv->lock has been
+ * acquired by caller...
+ */
+ struct wlan_bssid_ex *pdev_network =
+ &(padapter->registrypriv.dev_network);
+ pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
+ pibss = padapter->registrypriv.dev_network.
+ MacAddress;
+ memset(&pdev_network->Ssid, 0,
+ sizeof(struct ndis_802_11_ssid));
+ memcpy(&pdev_network->Ssid,
+ &pmlmepriv->assoc_ssid,
+ sizeof(struct ndis_802_11_ssid));
+ r8712_update_registrypriv_dev_network(padapter);
+ r8712_generate_random_ibss(pibss);
+ if (r8712_createbss_cmd(padapter) != _SUCCESS)
+ return false;
+ pmlmepriv->to_join = false;
+ } else {
+ /* can't associate ; reset under-linking */
+ if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
+ pmlmepriv->fw_state ^=
+ _FW_UNDER_LINKING;
+ /* when set_ssid/set_bssid for do_join(), but
+ * there are no desired bss in scanning queue
+ * we try to issue sitesurvey first
+ */
+ if (!pmlmepriv->sitesurveyctrl.traffic_busy)
+ r8712_sitesurvey_cmd(padapter,
+ &pmlmepriv->assoc_ssid);
+ }
+ }
+ }
+ return true;
+}
+
+u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
+{
+ unsigned long irqL;
+ u8 status = true;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
+ bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
+ (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
+ bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
+ status = false;
+ return status;
+ }
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
+ _FW_UNDER_LINKING) == true) {
+ status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+ goto _Abort_Set_BSSID;
+ }
+ if (check_fwstate(pmlmepriv,
+ _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
+ if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid,
+ ETH_ALEN)) {
+ if (check_fwstate(pmlmepriv,
+ WIFI_STATION_STATE) == false)
+ goto _Abort_Set_BSSID; /* driver is in
+ * WIFI_ADHOC_MASTER_STATE */
+ } else {
+ r8712_disassoc_cmd(padapter);
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
+ r8712_ind_disconnect(padapter);
+ r8712_free_assoc_resources(padapter);
+ if ((check_fwstate(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE))) {
+ _clr_fwstate_(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE);
+ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+ }
+ }
+ }
+ memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
+ pmlmepriv->assoc_by_bssid = true;
+ status = do_join(padapter);
+ goto done;
+_Abort_Set_BSSID:
+done:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return status;
+}
+
+void r8712_set_802_11_ssid(struct _adapter *padapter,
+ struct ndis_802_11_ssid *ssid)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct wlan_network *pnetwork = &pmlmepriv->cur_network;
+
+ if (padapter->hw_init_completed == false)
+ return;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
+ check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+ goto _Abort_Set_SSID;
+ }
+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+ if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
+ (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid,
+ ssid->SsidLength))) {
+ if ((check_fwstate(pmlmepriv,
+ WIFI_STATION_STATE) == false)) {
+ if (r8712_is_same_ibss(padapter,
+ pnetwork) == false) {
+ /* if in WIFI_ADHOC_MASTER_STATE or
+ * WIFI_ADHOC_STATE, create bss or
+ * rejoin again
+ */
+ r8712_disassoc_cmd(padapter);
+ if (check_fwstate(pmlmepriv,
+ _FW_LINKED) == true)
+ r8712_ind_disconnect(padapter);
+ r8712_free_assoc_resources(padapter);
+ if (check_fwstate(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE)) {
+ _clr_fwstate_(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE);
+ set_fwstate(pmlmepriv,
+ WIFI_ADHOC_STATE);
+ }
+ } else
+ goto _Abort_Set_SSID; /* driver is in
+ * WIFI_ADHOC_MASTER_STATE */
+ }
+ } else {
+ r8712_disassoc_cmd(padapter);
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
+ r8712_ind_disconnect(padapter);
+ r8712_free_assoc_resources(padapter);
+ if (check_fwstate(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE) == true) {
+ _clr_fwstate_(pmlmepriv,
+ WIFI_ADHOC_MASTER_STATE);
+ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+ }
+ }
+ }
+ if (padapter->securitypriv.btkip_countermeasure == true)
+ goto _Abort_Set_SSID;
+ if (validate_ssid(ssid) == false)
+ goto _Abort_Set_SSID;
+ memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
+ pmlmepriv->assoc_by_bssid = false;
+ do_join(padapter);
+ goto done;
+_Abort_Set_SSID:
+done:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct wlan_network *cur_network = &pmlmepriv->cur_network;
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state =
+ &(cur_network->network.InfrastructureMode);
+
+ if (*pold_state != networktype) {
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
+ (*pold_state == Ndis802_11IBSS))
+ r8712_disassoc_cmd(padapter);
+ if (check_fwstate(pmlmepriv,
+ _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true)
+ r8712_free_assoc_resources(padapter);
+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
+ (*pold_state == Ndis802_11Infrastructure) ||
+ (*pold_state == Ndis802_11IBSS)) {
+ /* will clr Linked_state before this function,
+ * we must have chked whether issue dis-assoc_cmd or
+ * not */
+ r8712_ind_disconnect(padapter);
+ }
+ *pold_state = networktype;
+ /* clear WIFI_STATION_STATE; WIFI_AP_STATE; WIFI_ADHOC_STATE;
+ * WIFI_ADHOC_MASTER_STATE */
+ _clr_fwstate_(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE |
+ WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE |
+ WIFI_AP_STATE);
+ switch (networktype) {
+ case Ndis802_11IBSS:
+ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
+ break;
+ case Ndis802_11Infrastructure:
+ set_fwstate(pmlmepriv, WIFI_STATION_STATE);
+ break;
+ case Ndis802_11APMode:
+ set_fwstate(pmlmepriv, WIFI_AP_STATE);
+ break;
+ case Ndis802_11AutoUnknown:
+ case Ndis802_11InfrastructureMax:
+ break;
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ }
+ return true;
+}
+
+u8 r8712_set_802_11_disassociate(struct _adapter *padapter)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ r8712_disassoc_cmd(padapter);
+ r8712_ind_disconnect(padapter);
+ r8712_free_assoc_resources(padapter);
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return true;
+}
+
+u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter)
+{
+ struct mlme_priv *pmlmepriv = NULL;
+ unsigned long irqL;
+ u8 ret = true;
+
+ if (padapter == NULL)
+ return false;
+ pmlmepriv = &padapter->mlmepriv;
+ if (padapter->hw_init_completed == false)
+ return false;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
+ (pmlmepriv->sitesurveyctrl.traffic_busy == true)) {
+ /* Scan or linking is in progress, do nothing. */
+ ret = (u8)check_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
+ } else {
+ r8712_free_network_queue(padapter);
+ ret = r8712_sitesurvey_cmd(padapter, NULL);
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return ret;
+}
+
+u8 r8712_set_802_11_authentication_mode(struct _adapter *padapter,
+ enum NDIS_802_11_AUTHENTICATION_MODE authmode)
+{
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ u8 ret;
+
+ psecuritypriv->ndisauthtype = authmode;
+ if (psecuritypriv->ndisauthtype > 3)
+ psecuritypriv->AuthAlgrthm = 2; /* 802.1x */
+ if (r8712_set_auth(padapter, psecuritypriv) == _SUCCESS)
+ ret = true;
+ else
+ ret = false;
+ return ret;
+}
+
+u8 r8712_set_802_11_add_wep(struct _adapter *padapter,
+ struct NDIS_802_11_WEP *wep)
+{
+ u8 bdefaultkey;
+ u8 btransmitkey;
+ sint keyid;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true;
+ btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false;
+ keyid = wep->KeyIndex & 0x3fffffff;
+ if (keyid >= WEP_KEYS)
+ return false;
+ switch (wep->KeyLength) {
+ case 5:
+ psecuritypriv->PrivacyAlgrthm = _WEP40_;
+ break;
+ case 13:
+ psecuritypriv->PrivacyAlgrthm = _WEP104_;
+ break;
+ default:
+ psecuritypriv->PrivacyAlgrthm = _NO_PRIVACY_;
+ break;
+ }
+ memcpy(psecuritypriv->DefKey[keyid].skey, &wep->KeyMaterial,
+ wep->KeyLength);
+ psecuritypriv->DefKeylen[keyid] = wep->KeyLength;
+ psecuritypriv->PrivacyKeyIndex = keyid;
+ if (r8712_set_key(padapter, psecuritypriv, keyid) == _FAIL)
+ return false;
+ return _SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.h b/drivers/staging/rtl8712/rtl871x_ioctl_set.h
new file mode 100644
index 000000000000..283afbfc1d02
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.h
@@ -0,0 +1,24 @@
+#ifndef __IOCTL_SET_H
+#define __IOCTL_SET_H
+
+#include "drv_types.h"
+
+typedef u8 NDIS_802_11_PMKID_VALUE[16];
+
+struct BSSIDInfo {
+ unsigned char BSSID[6];
+ NDIS_802_11_PMKID_VALUE PMKID;
+};
+
+u8 r8712_set_802_11_authentication_mode(struct _adapter *pdapter,
+ enum NDIS_802_11_AUTHENTICATION_MODE authmode);
+u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid);
+u8 r8712_set_802_11_add_wep(struct _adapter *padapter, struct NDIS_802_11_WEP *wep);
+u8 r8712_set_802_11_disassociate(struct _adapter *padapter);
+u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter);
+u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
+void r8712_set_802_11_ssid(struct _adapter *padapter, struct ndis_802_11_ssid *ssid);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_led.h b/drivers/staging/rtl8712/rtl871x_led.h
new file mode 100644
index 000000000000..994ef82141ab
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_led.h
@@ -0,0 +1,99 @@
+#ifndef __RTL8712_LED_H
+#define __RTL8712_LED_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+/*===========================================================================
+ * LED customization.
+ *===========================================================================
+ */
+enum LED_CTL_MODE {
+ LED_CTL_POWER_ON = 1,
+ LED_CTL_LINK = 2,
+ LED_CTL_NO_LINK = 3,
+ LED_CTL_TX = 4,
+ LED_CTL_RX = 5,
+ LED_CTL_SITE_SURVEY = 6,
+ LED_CTL_POWER_OFF = 7,
+ LED_CTL_START_TO_LINK = 8,
+ LED_CTL_START_WPS = 9,
+ LED_CTL_STOP_WPS = 10,
+ LED_CTL_START_WPS_BOTTON = 11,
+ LED_CTL_STOP_WPS_FAIL = 12,
+ LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
+};
+
+#define IS_LED_WPS_BLINKING(_LED_871x) \
+ (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS \
+ || ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP \
+ || ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
+
+#define IS_LED_BLINKING(_LED_871x) \
+ (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress \
+ || ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
+
+enum LED_PIN_871x {
+ LED_PIN_GPIO0,
+ LED_PIN_LED0,
+ LED_PIN_LED1
+};
+
+/*===========================================================================
+ * LED customization.
+ *===========================================================================
+ */
+enum LED_STRATEGY_871x {
+ SW_LED_MODE0, /* SW control 1 LED via GPIO0. It is default option. */
+ SW_LED_MODE1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */
+ SW_LED_MODE2, /* SW control 1 LED via GPIO0,
+ * custom for AzWave 8187 minicard. */
+ SW_LED_MODE3, /* SW control 1 LED via GPIO0,
+ * customized for Sercomm Printer Server case.*/
+ SW_LED_MODE4, /*for Edimax / Belkin*/
+ SW_LED_MODE5, /*for Sercomm / Belkin*/
+ SW_LED_MODE6, /*for WNC / Corega*/
+ HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different
+ * control modes, see MAC.CONFIG1 for details.)*/
+};
+
+struct LED_871x {
+ struct _adapter *padapter;
+ enum LED_PIN_871x LedPin; /* Implementation for this SW led. */
+ u32 CurrLedState; /* Current LED state. */
+ u8 bLedOn; /* true if LED is ON */
+ u8 bSWLedCtrl;
+ u8 bLedBlinkInProgress; /*true if blinking */
+ u8 bLedNoLinkBlinkInProgress;
+ u8 bLedLinkBlinkInProgress;
+ u8 bLedStartToLinkBlinkInProgress;
+ u8 bLedScanBlinkInProgress;
+ u8 bLedWPSBlinkInProgress;
+ u32 BlinkTimes; /* No. times to toggle for blink.*/
+ u32 BlinkingLedState; /* Next state for blinking,
+ * either LED_ON or OFF.*/
+
+ struct timer_list BlinkTimer; /* Timer object for led blinking.*/
+ _workitem BlinkWorkItem; /* Workitem used by BlinkTimer */
+};
+
+struct led_priv {
+ /* add for led controll */
+ struct LED_871x SwLed0;
+ struct LED_871x SwLed1;
+ enum LED_STRATEGY_871x LedStrategy;
+ u8 bRegUseLed;
+ void (*LedControlHandler)(struct _adapter *padapter,
+ enum LED_CTL_MODE LedAction);
+ /* add for led controll */
+};
+
+/*===========================================================================
+ * Interface to manipulate LED objects.
+ *===========================================================================*/
+void r8712_InitSwLeds(struct _adapter *padapter);
+void r8712_DeInitSwLeds(struct _adapter *padapter);
+void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
new file mode 100644
index 000000000000..98ba7602e250
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -0,0 +1,1840 @@
+/******************************************************************************
+ * rtl871x_mlme.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_MLME_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "xmit_osdep.h"
+#include "mlme_osdep.h"
+#include "sta_info.h"
+#include "wifi.h"
+#include "wlan_bssdef.h"
+
+static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len);
+
+static sint _init_mlme_priv(struct _adapter *padapter)
+{
+ sint i;
+ u8 *pbuf;
+ struct wlan_network *pnetwork;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv));
+ pmlmepriv->nic_hdl = (u8 *)padapter;
+ pmlmepriv->pscanned = NULL;
+ pmlmepriv->fw_state = 0;
+ pmlmepriv->cur_network.network.InfrastructureMode =
+ Ndis802_11AutoUnknown;
+ spin_lock_init(&(pmlmepriv->lock));
+ spin_lock_init(&(pmlmepriv->lock2));
+ _init_queue(&(pmlmepriv->free_bss_pool));
+ _init_queue(&(pmlmepriv->scanned_queue));
+ set_scanned_network_val(pmlmepriv, 0);
+ memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
+ pbuf = _malloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
+ if (pbuf == NULL)
+ return _FAIL;
+ pmlmepriv->free_bss_buf = pbuf;
+ pnetwork = (struct wlan_network *)pbuf;
+ for (i = 0; i < MAX_BSS_CNT; i++) {
+ _init_listhead(&(pnetwork->list));
+ list_insert_tail(&(pnetwork->list),
+ &(pmlmepriv->free_bss_pool.queue));
+ pnetwork++;
+ }
+ pmlmepriv->sitesurveyctrl.last_rx_pkts = 0;
+ pmlmepriv->sitesurveyctrl.last_tx_pkts = 0;
+ pmlmepriv->sitesurveyctrl.traffic_busy = false;
+ /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
+ r8712_init_mlme_timer(padapter);
+ return _SUCCESS;
+}
+
+struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv)
+{
+ unsigned long irqL;
+ struct wlan_network *pnetwork;
+ struct __queue *free_queue = &pmlmepriv->free_bss_pool;
+ struct list_head *plist = NULL;
+
+ if (_queue_empty(free_queue) == true)
+ return NULL;
+ spin_lock_irqsave(&free_queue->lock, irqL);
+ plist = get_next(&(free_queue->queue));
+ pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list);
+ list_delete(&pnetwork->list);
+ pnetwork->last_scanned = jiffies;
+ pmlmepriv->num_of_scanned++;
+ spin_unlock_irqrestore(&free_queue->lock, irqL);
+ return pnetwork;
+}
+
+static void _free_network(struct mlme_priv *pmlmepriv,
+ struct wlan_network *pnetwork)
+{
+ u32 curr_time, delta_time;
+ unsigned long irqL;
+ struct __queue *free_queue = &(pmlmepriv->free_bss_pool);
+
+ if (pnetwork == NULL)
+ return;
+ if (pnetwork->fixed == true)
+ return;
+ curr_time = jiffies;
+ delta_time = (curr_time - (u32)pnetwork->last_scanned) / HZ;
+ if (delta_time < SCANQUEUE_LIFETIME)
+ return;
+ spin_lock_irqsave(&free_queue->lock, irqL);
+ list_delete(&pnetwork->list);
+ list_insert_tail(&pnetwork->list, &free_queue->queue);
+ pmlmepriv->num_of_scanned--;
+ spin_unlock_irqrestore(&free_queue->lock, irqL);
+}
+
+static void _free_network_nolock(struct mlme_priv *pmlmepriv,
+ struct wlan_network *pnetwork)
+{
+ struct __queue *free_queue = &pmlmepriv->free_bss_pool;
+
+ if (pnetwork == NULL)
+ return;
+ if (pnetwork->fixed == true)
+ return;
+ list_delete(&pnetwork->list);
+ list_insert_tail(&pnetwork->list, get_list_head(free_queue));
+ pmlmepriv->num_of_scanned--;
+}
+
+
+/*
+ return the wlan_network with the matching addr
+ Shall be calle under atomic context...
+ to avoid possible racing condition...
+*/
+static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,
+ u8 *addr)
+{
+ unsigned long irqL;
+ struct list_head *phead, *plist;
+ struct wlan_network *pnetwork = NULL;
+ u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
+
+ if (!memcmp(zero_addr, addr, ETH_ALEN))
+ return NULL;
+ spin_lock_irqsave(&scanned_queue->lock, irqL);
+ phead = get_list_head(scanned_queue);
+ plist = get_next(phead);
+ while (plist != phead) {
+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+ plist = get_next(plist);
+ if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
+ break;
+ }
+ spin_unlock_irqrestore(&scanned_queue->lock, irqL);
+ return pnetwork;
+}
+
+static void _free_network_queue(struct _adapter *padapter)
+{
+ unsigned long irqL;
+ struct list_head *phead, *plist;
+ struct wlan_network *pnetwork;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct __queue *scanned_queue = &pmlmepriv->scanned_queue;
+
+ spin_lock_irqsave(&scanned_queue->lock, irqL);
+ phead = get_list_head(scanned_queue);
+ plist = get_next(phead);
+ while (end_of_queue_search(phead, plist) == false) {
+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+ plist = get_next(plist);
+ _free_network(pmlmepriv, pnetwork);
+ }
+ spin_unlock_irqrestore(&scanned_queue->lock, irqL);
+}
+
+sint r8712_if_up(struct _adapter *padapter)
+{
+ sint res;
+
+ if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
+ (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) {
+ res = false;
+ } else
+ res = true;
+ return res;
+}
+
+void r8712_generate_random_ibss(u8 *pibss)
+{
+ u32 curtime = jiffies;
+
+ pibss[0] = 0x02; /*in ad-hoc mode bit1 must set to 1 */
+ pibss[1] = 0x11;
+ pibss[2] = 0x87;
+ pibss[3] = (u8)(curtime & 0xff);
+ pibss[4] = (u8)((curtime>>8) & 0xff);
+ pibss[5] = (u8)((curtime>>16) & 0xff);
+}
+
+uint r8712_get_ndis_wlan_bssid_ex_sz(struct ndis_wlan_bssid_ex *bss)
+{
+ uint t_len;
+
+ t_len = sizeof(u32) + 6 * sizeof(unsigned long) + 2 +
+ sizeof(struct ndis_802_11_ssid) + sizeof(u32) +
+ sizeof(s32) +
+ sizeof(enum NDIS_802_11_NETWORK_TYPE) +
+ sizeof(struct NDIS_802_11_CONFIGURATION) +
+ sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) +
+ sizeof(NDIS_802_11_RATES_EX) +
+ sizeof(u32) + bss->IELength;
+ return t_len;
+}
+
+u8 *r8712_get_capability_from_ie(u8 *ie)
+{
+ return ie + 8 + 2;
+}
+
+int r8712_init_mlme_priv(struct _adapter *padapter)
+{
+ return _init_mlme_priv(padapter);
+}
+
+void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv)
+{
+ kfree(pmlmepriv->free_bss_buf);
+}
+
+static struct wlan_network *alloc_network(struct mlme_priv *pmlmepriv)
+{
+ return _r8712_alloc_network(pmlmepriv);
+}
+
+static void free_network_nolock(struct mlme_priv *pmlmepriv,
+ struct wlan_network *pnetwork)
+{
+ _free_network_nolock(pmlmepriv, pnetwork);
+}
+
+void r8712_free_network_queue(struct _adapter *dev)
+{
+ _free_network_queue(dev);
+}
+
+/*
+ return the wlan_network with the matching addr
+
+ Shall be calle under atomic context...
+ to avoid possible racing condition...
+*/
+static struct wlan_network *r8712_find_network(struct __queue *scanned_queue,
+ u8 *addr)
+{
+ struct wlan_network *pnetwork = _r8712_find_network(scanned_queue,
+ addr);
+
+ return pnetwork;
+}
+
+int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork)
+{
+ int ret = true;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+
+ if ((psecuritypriv->PrivacyAlgrthm != _NO_PRIVACY_) &&
+ (pnetwork->network.Privacy == 0))
+ ret = false;
+ else if ((psecuritypriv->PrivacyAlgrthm == _NO_PRIVACY_) &&
+ (pnetwork->network.Privacy == 1))
+ ret = false;
+ else
+ ret = true;
+ return ret;
+
+}
+
+static int is_same_network(struct ndis_wlan_bssid_ex *src,
+ struct ndis_wlan_bssid_ex *dst)
+{
+ u16 s_cap, d_cap;
+
+ memcpy((u8 *)&s_cap, r8712_get_capability_from_ie(src->IEs), 2);
+ memcpy((u8 *)&d_cap, r8712_get_capability_from_ie(dst->IEs), 2);
+ return (src->Ssid.SsidLength == dst->Ssid.SsidLength) &&
+ (src->Configuration.DSConfig ==
+ dst->Configuration.DSConfig) &&
+ ((!memcmp(src->MacAddress, dst->MacAddress,
+ ETH_ALEN))) &&
+ ((!memcmp(src->Ssid.Ssid,
+ dst->Ssid.Ssid,
+ src->Ssid.SsidLength))) &&
+ ((s_cap & WLAN_CAPABILITY_IBSS) ==
+ (d_cap & WLAN_CAPABILITY_IBSS)) &&
+ ((s_cap & WLAN_CAPABILITY_BSS) ==
+ (d_cap & WLAN_CAPABILITY_BSS));
+
+}
+
+struct wlan_network *r8712_get_oldest_wlan_network(
+ struct __queue *scanned_queue)
+{
+ struct list_head *plist, *phead;
+ struct wlan_network *pwlan = NULL;
+ struct wlan_network *oldest = NULL;
+
+ phead = get_list_head(scanned_queue);
+ plist = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, plist) == true)
+ break;
+ pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
+ if (pwlan->fixed != true) {
+ if (oldest == NULL ||
+ time_after((unsigned long)oldest->last_scanned,
+ (unsigned long)pwlan->last_scanned))
+ oldest = pwlan;
+ }
+ plist = get_next(plist);
+ }
+ return oldest;
+}
+
+static void update_network(struct ndis_wlan_bssid_ex *dst,
+ struct ndis_wlan_bssid_ex *src,
+ struct _adapter *padapter)
+{
+ u32 last_evm = 0, tmpVal;
+
+ if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) &&
+ is_same_network(&(padapter->mlmepriv.cur_network.network), src)) {
+ if (padapter->recvpriv.signal_qual_data.total_num++ >=
+ PHY_LINKQUALITY_SLID_WIN_MAX) {
+ padapter->recvpriv.signal_qual_data.total_num =
+ PHY_LINKQUALITY_SLID_WIN_MAX;
+ last_evm = padapter->recvpriv.signal_qual_data.
+ elements[padapter->recvpriv.
+ signal_qual_data.index];
+ padapter->recvpriv.signal_qual_data.total_val -=
+ last_evm;
+ }
+ padapter->recvpriv.signal_qual_data.total_val += src->Rssi;
+
+ padapter->recvpriv.signal_qual_data.
+ elements[padapter->recvpriv.signal_qual_data.
+ index++] = src->Rssi;
+ if (padapter->recvpriv.signal_qual_data.index >=
+ PHY_LINKQUALITY_SLID_WIN_MAX)
+ padapter->recvpriv.signal_qual_data.index = 0;
+ /* <1> Showed on UI for user, in percentage. */
+ tmpVal = padapter->recvpriv.signal_qual_data.total_val /
+ padapter->recvpriv.signal_qual_data.total_num;
+ padapter->recvpriv.signal = (u8)tmpVal;
+
+ src->Rssi = padapter->recvpriv.signal;
+ } else
+ src->Rssi = (src->Rssi + dst->Rssi) / 2;
+ memcpy((u8 *)dst, (u8 *)src, r8712_get_ndis_wlan_bssid_ex_sz(src));
+}
+
+static void update_current_network(struct _adapter *adapter,
+ struct ndis_wlan_bssid_ex *pnetwork)
+{
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ if (is_same_network(&(pmlmepriv->cur_network.network), pnetwork)) {
+ update_network(&(pmlmepriv->cur_network.network),
+ pnetwork, adapter);
+ r8712_update_protection(adapter,
+ (pmlmepriv->cur_network.network.IEs) +
+ sizeof(struct NDIS_802_11_FIXED_IEs),
+ pmlmepriv->cur_network.network.IELength);
+ }
+}
+
+/*
+Caller must hold pmlmepriv->lock first.
+*/
+static void update_scanned_network(struct _adapter *adapter,
+ struct ndis_wlan_bssid_ex *target)
+{
+ struct list_head *plist, *phead;
+
+ u32 bssid_ex_sz;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+ struct wlan_network *pnetwork = NULL;
+ struct wlan_network *oldest = NULL;
+
+ phead = get_list_head(queue);
+ plist = get_next(phead);
+
+ while (1) {
+ if (end_of_queue_search(phead, plist) == true)
+ break;
+
+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+ if (is_same_network(&pnetwork->network, target))
+ break;
+ if ((oldest == ((struct wlan_network *)0)) ||
+ time_after((unsigned long)oldest->last_scanned,
+ (unsigned long)pnetwork->last_scanned))
+ oldest = pnetwork;
+
+ plist = get_next(plist);
+ }
+
+
+ /* If we didn't find a match, then get a new network slot to initialize
+ * with this beacon's information */
+ if (end_of_queue_search(phead, plist) == true) {
+ if (_queue_empty(&pmlmepriv->free_bss_pool) == true) {
+ /* If there are no more slots, expire the oldest */
+ pnetwork = oldest;
+ target->Rssi = (pnetwork->network.Rssi +
+ target->Rssi) / 2;
+ memcpy(&pnetwork->network, target,
+ r8712_get_ndis_wlan_bssid_ex_sz(target));
+ pnetwork->last_scanned = jiffies;
+ } else {
+ /* Otherwise just pull from the free list */
+ /* update scan_time */
+ pnetwork = alloc_network(pmlmepriv);
+ if (pnetwork == NULL)
+ return;
+ bssid_ex_sz = r8712_get_ndis_wlan_bssid_ex_sz(target);
+ target->Length = bssid_ex_sz;
+ memcpy(&pnetwork->network, target, bssid_ex_sz);
+ list_insert_tail(&pnetwork->list, &queue->queue);
+ }
+ } else {
+ /* we have an entry and we are going to update it. But
+ * this entry may be already expired. In this case we
+ * do the same as we found a new net and call the new_net
+ * handler
+ */
+ update_network(&pnetwork->network, target, adapter);
+ pnetwork->last_scanned = jiffies;
+ }
+}
+
+static void rtl8711_add_network(struct _adapter *adapter,
+ struct ndis_wlan_bssid_ex *pnetwork)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &(((struct _adapter *)adapter)->mlmepriv);
+ struct __queue *queue = &pmlmepriv->scanned_queue;
+
+ spin_lock_irqsave(&queue->lock, irqL);
+ update_current_network(adapter, pnetwork);
+ update_scanned_network(adapter, pnetwork);
+ spin_unlock_irqrestore(&queue->lock, irqL);
+}
+
+/*select the desired network based on the capability of the (i)bss.
+ * check items: (1) security
+ * (2) network_type
+ * (3) WMM
+ * (4) HT
+ * (5) others
+ */
+static int is_desired_network(struct _adapter *adapter,
+ struct wlan_network *pnetwork)
+{
+ u8 wps_ie[512];
+ uint wps_ielen;
+ int bselected = true;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+
+ if (psecuritypriv->wps_phase == true) {
+ if (r8712_get_wps_ie(pnetwork->network.IEs,
+ pnetwork->network.IELength, wps_ie,
+ &wps_ielen) == true)
+ return true;
+ else
+ return false;
+ }
+ if ((psecuritypriv->PrivacyAlgrthm != _NO_PRIVACY_) &&
+ (pnetwork->network.Privacy == 0))
+ bselected = false;
+ return bselected;
+}
+
+/* TODO: Perry : For Power Management */
+void r8712_atimdone_event_callback(struct _adapter *adapter , u8 *pbuf)
+{
+}
+
+void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ unsigned long flags;
+ u32 len;
+ struct ndis_wlan_bssid_ex *pnetwork;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ pnetwork = (struct ndis_wlan_bssid_ex *)pbuf;
+#ifdef __BIG_ENDIAN
+ /* endian_convert */
+ pnetwork->Length = le32_to_cpu(pnetwork->Length);
+ pnetwork->Ssid.SsidLength = le32_to_cpu(pnetwork->Ssid.SsidLength);
+ pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
+ pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
+ pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
+ pnetwork->Configuration.ATIMWindow =
+ le32_to_cpu(pnetwork->Configuration.ATIMWindow);
+ pnetwork->Configuration.BeaconPeriod =
+ le32_to_cpu(pnetwork->Configuration.BeaconPeriod);
+ pnetwork->Configuration.DSConfig =
+ le32_to_cpu(pnetwork->Configuration.DSConfig);
+ pnetwork->Configuration.FHConfig.DwellTime =
+ le32_to_cpu(pnetwork->Configuration.FHConfig.DwellTime);
+ pnetwork->Configuration.FHConfig.HopPattern =
+ le32_to_cpu(pnetwork->Configuration.FHConfig.HopPattern);
+ pnetwork->Configuration.FHConfig.HopSet =
+ le32_to_cpu(pnetwork->Configuration.FHConfig.HopSet);
+ pnetwork->Configuration.FHConfig.Length =
+ le32_to_cpu(pnetwork->Configuration.FHConfig.Length);
+ pnetwork->Configuration.Length =
+ le32_to_cpu(pnetwork->Configuration.Length);
+ pnetwork->InfrastructureMode =
+ le32_to_cpu(pnetwork->InfrastructureMode);
+ pnetwork->IELength = le32_to_cpu(pnetwork->IELength);
+#endif
+ len = r8712_get_ndis_wlan_bssid_ex_sz(pnetwork);
+ if (len > sizeof(struct wlan_bssid_ex))
+ return;
+ spin_lock_irqsave(&pmlmepriv->lock2, flags);
+ /* update IBSS_network 's timestamp */
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) {
+ if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress),
+ pnetwork->MacAddress, ETH_ALEN)) {
+ struct wlan_network *ibss_wlan = NULL;
+
+ memcpy(pmlmepriv->cur_network.network.IEs,
+ pnetwork->IEs, 8);
+ ibss_wlan = r8712_find_network(
+ &pmlmepriv->scanned_queue,
+ pnetwork->MacAddress);
+ if (!ibss_wlan) {
+ memcpy(ibss_wlan->network.IEs,
+ pnetwork->IEs, 8);
+ goto exit;
+ }
+ }
+ }
+ /* lock pmlmepriv->lock when you accessing network_q */
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) {
+ if (pnetwork->Ssid.Ssid[0] != 0)
+ rtl8711_add_network(adapter, pnetwork);
+ else {
+ pnetwork->Ssid.SsidLength = 8;
+ memcpy(pnetwork->Ssid.Ssid, "<hidden>", 8);
+ rtl8711_add_network(adapter, pnetwork);
+ }
+ }
+exit:
+ spin_unlock_irqrestore(&pmlmepriv->lock2, flags);
+}
+
+void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+
+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
+ u8 timer_cancelled;
+
+ _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
+
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
+ }
+
+ if (pmlmepriv->to_join == true) {
+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
+ set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+
+ if (r8712_select_and_join_from_scan(pmlmepriv)
+ == _SUCCESS)
+ _set_timer(&pmlmepriv->assoc_timer,
+ MAX_JOIN_TIMEOUT);
+ else {
+ struct wlan_bssid_ex *pdev_network =
+ &(adapter->registrypriv.dev_network);
+ u8 *pibss =
+ adapter->registrypriv.
+ dev_network.MacAddress;
+ pmlmepriv->fw_state ^= _FW_UNDER_SURVEY;
+ memset(&pdev_network->Ssid, 0,
+ sizeof(struct
+ ndis_802_11_ssid));
+ memcpy(&pdev_network->Ssid,
+ &pmlmepriv->assoc_ssid,
+ sizeof(struct
+ ndis_802_11_ssid));
+ r8712_update_registrypriv_dev_network
+ (adapter);
+ r8712_generate_random_ibss(pibss);
+ pmlmepriv->fw_state =
+ WIFI_ADHOC_MASTER_STATE;
+ pmlmepriv->to_join = false;
+ }
+ }
+ } else {
+ pmlmepriv->to_join = false;
+ set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+ if (r8712_select_and_join_from_scan(pmlmepriv) ==
+ _SUCCESS)
+ _set_timer(&pmlmepriv->assoc_timer,
+ MAX_JOIN_TIMEOUT);
+ else
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
+ }
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+/*
+ *r8712_free_assoc_resources: the caller has to lock pmlmepriv->lock
+ */
+void r8712_free_assoc_resources(struct _adapter *adapter)
+{
+ unsigned long irqL;
+ struct wlan_network *pwlan = NULL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+
+ pwlan = r8712_find_network(&pmlmepriv->scanned_queue,
+ tgt_network->network.MacAddress);
+
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) {
+ struct sta_info *psta;
+
+ psta = r8712_get_stainfo(&adapter->stapriv,
+ tgt_network->network.MacAddress);
+
+ spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
+ r8712_free_stainfo(adapter, psta);
+ spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
+ }
+
+ if (check_fwstate(pmlmepriv,
+ WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE))
+ r8712_free_all_stainfo(adapter);
+ if (pwlan)
+ pwlan->fixed = false;
+
+ if (((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) &&
+ (adapter->stapriv.asoc_sta_count == 1)))
+ free_network_nolock(pmlmepriv, pwlan);
+}
+
+/*
+*r8712_indicate_connect: the caller has to lock pmlmepriv->lock
+*/
+void r8712_indicate_connect(struct _adapter *padapter)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ pmlmepriv->to_join = false;
+ set_fwstate(pmlmepriv, _FW_LINKED);
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_LINK);
+ r8712_os_indicate_connect(padapter);
+ if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE)
+ _set_timer(&pmlmepriv->dhcp_timer, 60000);
+}
+
+
+/*
+*r8712_ind_disconnect: the caller has to lock pmlmepriv->lock
+*/
+void r8712_ind_disconnect(struct _adapter *padapter)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+
+ _clr_fwstate_(pmlmepriv, _FW_LINKED);
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK);
+ r8712_os_indicate_disconnect(padapter);
+ if (padapter->pwrctrlpriv.pwr_mode !=
+ padapter->registrypriv.power_mgnt) {
+ _cancel_timer_ex(&pmlmepriv->dhcp_timer);
+ r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt,
+ padapter->registrypriv.smart_ps);
+ }
+}
+
+/*Notes:
+ *pnetwork : returns from r8712_joinbss_event_callback
+ *ptarget_wlan: found from scanned_queue
+ *if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if
+ * "ptarget_sta" & "ptarget_wlan" exist.
+ *if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check
+ * if "ptarget_wlan" exist.
+ *if join_res > 0, update "cur_network->network" from
+ * "pnetwork->network" if (ptarget_wlan !=NULL).
+ */
+void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ unsigned long irqL = 0, irqL2;
+ u8 timer_cancelled;
+ struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct wlan_network *cur_network = &pmlmepriv->cur_network;
+ struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL;
+ unsigned int the_same_macaddr = false;
+ struct wlan_network *pnetwork;
+
+ if (sizeof(struct list_head) == 4 * sizeof(u32)) {
+ pnetwork = (struct wlan_network *)
+ _malloc(sizeof(struct wlan_network));
+ memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8,
+ sizeof(struct wlan_network) - 16);
+ } else
+ pnetwork = (struct wlan_network *)pbuf;
+
+#ifdef __BIG_ENDIAN
+ /* endian_convert */
+ pnetwork->join_res = le32_to_cpu(pnetwork->join_res);
+ pnetwork->network_type = le32_to_cpu(pnetwork->network_type);
+ pnetwork->network.Length = le32_to_cpu(pnetwork->network.Length);
+ pnetwork->network.Ssid.SsidLength =
+ le32_to_cpu(pnetwork->network.Ssid.SsidLength);
+ pnetwork->network.Privacy = le32_to_cpu(pnetwork->network.Privacy);
+ pnetwork->network.Rssi = le32_to_cpu(pnetwork->network.Rssi);
+ pnetwork->network.NetworkTypeInUse =
+ le32_to_cpu(pnetwork->network.NetworkTypeInUse);
+ pnetwork->network.Configuration.ATIMWindow =
+ le32_to_cpu(pnetwork->network.Configuration.ATIMWindow);
+ pnetwork->network.Configuration.BeaconPeriod =
+ le32_to_cpu(pnetwork->network.Configuration.BeaconPeriod);
+ pnetwork->network.Configuration.DSConfig =
+ le32_to_cpu(pnetwork->network.Configuration.DSConfig);
+ pnetwork->network.Configuration.FHConfig.DwellTime =
+ le32_to_cpu(pnetwork->network.Configuration.FHConfig.
+ DwellTime);
+ pnetwork->network.Configuration.FHConfig.HopPattern =
+ le32_to_cpu(pnetwork->network.Configuration.
+ FHConfig.HopPattern);
+ pnetwork->network.Configuration.FHConfig.HopSet =
+ le32_to_cpu(pnetwork->network.Configuration.FHConfig.HopSet);
+ pnetwork->network.Configuration.FHConfig.Length =
+ le32_to_cpu(pnetwork->network.Configuration.FHConfig.Length);
+ pnetwork->network.Configuration.Length =
+ le32_to_cpu(pnetwork->network.Configuration.Length);
+ pnetwork->network.InfrastructureMode =
+ le32_to_cpu(pnetwork->network.InfrastructureMode);
+ pnetwork->network.IELength = le32_to_cpu(pnetwork->network.IELength);
+#endif
+
+ the_same_macaddr = !memcmp(pnetwork->network.MacAddress,
+ cur_network->network.MacAddress, ETH_ALEN);
+ pnetwork->network.Length =
+ r8712_get_ndis_wlan_bssid_ex_sz(&pnetwork->network);
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex))
+ goto ignore_joinbss_callback;
+ if (pnetwork->join_res > 0) {
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
+ /*s1. find ptarget_wlan*/
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ if (the_same_macaddr == true)
+ ptarget_wlan =
+ r8712_find_network(&pmlmepriv->
+ scanned_queue,
+ cur_network->network.MacAddress);
+ else {
+ pcur_wlan =
+ r8712_find_network(&pmlmepriv->
+ scanned_queue,
+ cur_network->network.MacAddress);
+ pcur_wlan->fixed = false;
+
+ pcur_sta = r8712_get_stainfo(pstapriv,
+ cur_network->network.MacAddress);
+ spin_lock_irqsave(&pstapriv->
+ sta_hash_lock, irqL2);
+ r8712_free_stainfo(adapter, pcur_sta);
+ spin_unlock_irqrestore(&(pstapriv->
+ sta_hash_lock), irqL2);
+
+ ptarget_wlan =
+ r8712_find_network(&pmlmepriv->
+ scanned_queue,
+ pnetwork->network.
+ MacAddress);
+ if (ptarget_wlan)
+ ptarget_wlan->fixed = true;
+ }
+ } else {
+ ptarget_wlan = r8712_find_network(&pmlmepriv->
+ scanned_queue,
+ pnetwork->network.MacAddress);
+ if (ptarget_wlan)
+ ptarget_wlan->fixed = true;
+ }
+
+ if (ptarget_wlan == NULL) {
+ if (check_fwstate(pmlmepriv,
+ _FW_UNDER_LINKING))
+ pmlmepriv->fw_state ^=
+ _FW_UNDER_LINKING;
+ goto ignore_joinbss_callback;
+ }
+
+ /*s2. find ptarget_sta & update ptarget_sta*/
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+ if (the_same_macaddr == true) {
+ ptarget_sta =
+ r8712_get_stainfo(pstapriv,
+ pnetwork->network.MacAddress);
+ if (ptarget_sta == NULL)
+ ptarget_sta =
+ r8712_alloc_stainfo(pstapriv,
+ pnetwork->network.MacAddress);
+ } else
+ ptarget_sta =
+ r8712_alloc_stainfo(pstapriv,
+ pnetwork->network.MacAddress);
+ if (ptarget_sta) /*update ptarget_sta*/ {
+ ptarget_sta->aid = pnetwork->join_res;
+ ptarget_sta->qos_option = 1;
+ ptarget_sta->mac_id = 5;
+ if (adapter->securitypriv.
+ AuthAlgrthm == 2) {
+ adapter->securitypriv.
+ binstallGrpkey =
+ false;
+ adapter->securitypriv.
+ busetkipkey =
+ false;
+ adapter->securitypriv.
+ bgrpkey_handshake =
+ false;
+ ptarget_sta->ieee8021x_blocked
+ = true;
+ ptarget_sta->XPrivacy =
+ adapter->securitypriv.
+ PrivacyAlgrthm;
+ memset((u8 *)&ptarget_sta->
+ x_UncstKey,
+ 0,
+ sizeof(union Keytype));
+ memset((u8 *)&ptarget_sta->
+ tkiprxmickey,
+ 0,
+ sizeof(union Keytype));
+ memset((u8 *)&ptarget_sta->
+ tkiptxmickey,
+ 0,
+ sizeof(union Keytype));
+ memset((u8 *)&ptarget_sta->
+ txpn, 0,
+ sizeof(union pn48));
+ memset((u8 *)&ptarget_sta->
+ rxpn, 0,
+ sizeof(union pn48));
+ }
+ } else {
+ if (check_fwstate(pmlmepriv,
+ _FW_UNDER_LINKING))
+ pmlmepriv->fw_state ^=
+ _FW_UNDER_LINKING;
+ goto ignore_joinbss_callback;
+ }
+ }
+
+ /*s3. update cur_network & indicate connect*/
+ memcpy(&cur_network->network, &pnetwork->network,
+ pnetwork->network.Length);
+ cur_network->aid = pnetwork->join_res;
+ /*update fw_state will clr _FW_UNDER_LINKING*/
+ switch (pnetwork->network.InfrastructureMode) {
+ case Ndis802_11Infrastructure:
+ pmlmepriv->fw_state = WIFI_STATION_STATE;
+ break;
+ case Ndis802_11IBSS:
+ pmlmepriv->fw_state = WIFI_ADHOC_STATE;
+ break;
+ default:
+ pmlmepriv->fw_state = WIFI_NULL_STATE;
+ break;
+ }
+ r8712_update_protection(adapter,
+ (cur_network->network.IEs) +
+ sizeof(struct NDIS_802_11_FIXED_IEs),
+ (cur_network->network.IELength));
+ /*TODO: update HT_Capability*/
+ update_ht_cap(adapter, cur_network->network.IEs,
+ cur_network->network.IELength);
+ /*indicate connect*/
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
+ == true)
+ r8712_indicate_connect(adapter);
+ _cancel_timer(&pmlmepriv->assoc_timer,
+ &timer_cancelled);
+ } else
+ goto ignore_joinbss_callback;
+ } else {
+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
+ _set_timer(&pmlmepriv->assoc_timer, 1);
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
+ }
+ }
+ignore_joinbss_callback:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ if (sizeof(struct list_head) == 4 * sizeof(u32))
+ kfree((u8 *)pnetwork);
+}
+
+void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ unsigned long irqL;
+ struct sta_info *psta;
+ struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
+ struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf;
+
+ /* to do: */
+ if (r8712_access_ctrl(&adapter->acl_list, pstassoc->macaddr) == false)
+ return;
+ psta = r8712_get_stainfo(&adapter->stapriv, pstassoc->macaddr);
+ if (psta != NULL) {
+ /*the sta have been in sta_info_queue => do nothing
+ *(between drv has received this event before and
+ * fw have not yet to set key to CAM_ENTRY) */
+ return;
+ }
+
+ psta = r8712_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr);
+ if (psta == NULL)
+ return;
+ /* to do : init sta_info variable */
+ psta->qos_option = 0;
+ psta->mac_id = le32_to_cpu((uint)pstassoc->cam_id);
+ /* psta->aid = (uint)pstassoc->cam_id; */
+
+ if (adapter->securitypriv.AuthAlgrthm == 2)
+ psta->XPrivacy = adapter->securitypriv.PrivacyAlgrthm;
+ psta->ieee8021x_blocked = false;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
+ (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) {
+ if (adapter->stapriv.asoc_sta_count == 2) {
+ /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
+ r8712_indicate_connect(adapter);
+ }
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ unsigned long irqL, irqL2;
+ struct sta_info *psta;
+ struct wlan_network *pwlan = NULL;
+ struct wlan_bssid_ex *pdev_network = NULL;
+ u8 *pibss = NULL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct stadel_event *pstadel = (struct stadel_event *)pbuf;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL2);
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
+ r8712_ind_disconnect(adapter);
+ r8712_free_assoc_resources(adapter);
+ }
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE |
+ WIFI_ADHOC_STATE)) {
+ psta = r8712_get_stainfo(&adapter->stapriv, pstadel->macaddr);
+ spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
+ r8712_free_stainfo(adapter, psta);
+ spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
+ if (adapter->stapriv.asoc_sta_count == 1) {
+ /*a sta + bc/mc_stainfo (not Ibss_stainfo) */
+ pwlan = r8712_find_network(&pmlmepriv->scanned_queue,
+ tgt_network->network.MacAddress);
+ if (pwlan) {
+ pwlan->fixed = false;
+ free_network_nolock(pmlmepriv, pwlan);
+ }
+ /*re-create ibss*/
+ pdev_network = &(adapter->registrypriv.dev_network);
+ pibss = adapter->registrypriv.dev_network.MacAddress;
+ memcpy(pdev_network, &tgt_network->network,
+ r8712_get_ndis_wlan_bssid_ex_sz(&tgt_network->
+ network));
+ memset(&pdev_network->Ssid, 0,
+ sizeof(struct ndis_802_11_ssid));
+ memcpy(&pdev_network->Ssid,
+ &pmlmepriv->assoc_ssid,
+ sizeof(struct ndis_802_11_ssid));
+ r8712_update_registrypriv_dev_network(adapter);
+ r8712_generate_random_ibss(pibss);
+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
+ _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
+ set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
+ }
+ }
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL2);
+}
+
+void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ struct reportpwrstate_parm *preportpwrstate =
+ (struct reportpwrstate_parm *)pbuf;
+
+ preportpwrstate->state |= (u8)(adapter->pwrctrlpriv.cpwm_tog + 0x80);
+ r8712_cpwm_int_hdl(adapter, preportpwrstate);
+}
+
+/* When the Netgear 3500 AP is with WPA2PSK-AES mode, it will send
+ * the ADDBA req frame with start seq control = 0 to wifi client after
+ * the WPA handshake and the seqence number of following data packet
+ * will be 0. In this case, the Rx reorder sequence is not longer than 0
+ * and the WiFi client will drop the data with seq number 0.
+ * So, the 8712 firmware has to inform driver with receiving the
+ * ADDBA-Req frame so that the driver can reset the
+ * sequence value of Rx reorder contorl.
+ */
+void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ struct ADDBA_Req_Report_parm *pAddbareq_pram =
+ (struct ADDBA_Req_Report_parm *)pbuf;
+ struct sta_info *psta;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct recv_reorder_ctrl *precvreorder_ctrl = NULL;
+
+ printk(KERN_INFO "r8712u: [%s] mac = %pM, seq = %d, tid = %d\n",
+ __func__, pAddbareq_pram->MacAddress,
+ pAddbareq_pram->StartSeqNum, pAddbareq_pram->tid);
+ psta = r8712_get_stainfo(pstapriv, pAddbareq_pram->MacAddress);
+ if (psta) {
+ precvreorder_ctrl =
+ &psta->recvreorder_ctrl[pAddbareq_pram->tid];
+ /* set the indicate_seq to 0xffff so that the rx reorder
+ * can store any following data packet.
+ */
+ precvreorder_ctrl->indicate_seq = 0xffff;
+ }
+}
+
+void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf)
+{
+ if (adapter->securitypriv.wps_hw_pbc_pressed == false)
+ adapter->securitypriv.wps_hw_pbc_pressed = true;
+}
+
+void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter)
+{
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct sitesurvey_ctrl *psitesurveyctrl = &pmlmepriv->sitesurveyctrl;
+ struct registry_priv *pregistrypriv = &adapter->registrypriv;
+ u64 current_tx_pkts;
+ uint current_rx_pkts;
+
+ current_tx_pkts = (adapter->xmitpriv.tx_pkts) -
+ (psitesurveyctrl->last_tx_pkts);
+ current_rx_pkts = (adapter->recvpriv.rx_pkts) -
+ (psitesurveyctrl->last_rx_pkts);
+ psitesurveyctrl->last_tx_pkts = adapter->xmitpriv.tx_pkts;
+ psitesurveyctrl->last_rx_pkts = adapter->recvpriv.rx_pkts;
+ if ((current_tx_pkts > pregistrypriv->busy_thresh) ||
+ (current_rx_pkts > pregistrypriv->busy_thresh))
+ psitesurveyctrl->traffic_busy = true;
+ else
+ psitesurveyctrl->traffic_busy = false;
+}
+
+void _r8712_join_timeout_handler(struct _adapter *adapter)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
+ return;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
+ pmlmepriv->to_join = false;
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+ r8712_os_indicate_disconnect(adapter);
+ _clr_fwstate_(pmlmepriv, _FW_LINKED);
+ }
+ if (adapter->pwrctrlpriv.pwr_mode != adapter->registrypriv.power_mgnt) {
+ r8712_set_ps_mode(adapter, adapter->registrypriv.power_mgnt,
+ adapter->registrypriv.smart_ps);
+ }
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+void r8712_scan_timeout_handler (struct _adapter *adapter)
+{
+ unsigned long irqL;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
+ pmlmepriv->to_join = false; /* scan fail, so clear to_join flag */
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+void _r8712_dhcp_timeout_handler (struct _adapter *adapter)
+{
+ if (adapter->bDriverStopped || adapter->bSurpriseRemoved)
+ return;
+ if (adapter->pwrctrlpriv.pwr_mode != adapter->registrypriv.power_mgnt)
+ r8712_set_ps_mode(adapter, adapter->registrypriv.power_mgnt,
+ adapter->registrypriv.smart_ps);
+}
+
+void _r8712_wdg_timeout_handler(struct _adapter *adapter)
+{
+ r8712_wdg_wk_cmd(adapter);
+}
+
+int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv)
+{
+ struct list_head *phead;
+ unsigned char *dst_ssid, *src_ssid;
+ struct _adapter *adapter;
+ struct __queue *queue = NULL;
+ struct wlan_network *pnetwork = NULL;
+ struct wlan_network *pnetwork_max_rssi = NULL;
+
+ adapter = (struct _adapter *)pmlmepriv->nic_hdl;
+ queue = &pmlmepriv->scanned_queue;
+ phead = get_list_head(queue);
+ pmlmepriv->pscanned = get_next(phead);
+ while (1) {
+ if (end_of_queue_search(phead, pmlmepriv->pscanned) == true) {
+ if ((pmlmepriv->assoc_by_rssi == true) &&
+ (pnetwork_max_rssi != NULL)) {
+ pnetwork = pnetwork_max_rssi;
+ goto ask_for_joinbss;
+ }
+ return _FAIL;
+ }
+ pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
+ struct wlan_network, list);
+ if (pnetwork == NULL)
+ return _FAIL;
+ pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
+ if (pmlmepriv->assoc_by_bssid == true) {
+ dst_ssid = pnetwork->network.MacAddress;
+ src_ssid = pmlmepriv->assoc_bssid;
+ if (!memcmp(dst_ssid, src_ssid, ETH_ALEN)) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+ if (is_same_network(&pmlmepriv->
+ cur_network.network,
+ &pnetwork->network)) {
+ _clr_fwstate_(pmlmepriv,
+ _FW_UNDER_LINKING);
+ /*r8712_indicate_connect again*/
+ r8712_indicate_connect(adapter);
+ return 2;
+ }
+ r8712_disassoc_cmd(adapter);
+ r8712_ind_disconnect(adapter);
+ r8712_free_assoc_resources(adapter);
+ }
+ goto ask_for_joinbss;
+ }
+ } else if (pmlmepriv->assoc_ssid.SsidLength == 0)
+ goto ask_for_joinbss;
+ dst_ssid = pnetwork->network.Ssid.Ssid;
+ src_ssid = pmlmepriv->assoc_ssid.Ssid;
+ if ((pnetwork->network.Ssid.SsidLength ==
+ pmlmepriv->assoc_ssid.SsidLength) &&
+ (!memcmp(dst_ssid, src_ssid,
+ pmlmepriv->assoc_ssid.SsidLength))) {
+ if (pmlmepriv->assoc_by_rssi == true) {
+ /* if the ssid is the same, select the bss
+ * which has the max rssi*/
+ if (pnetwork_max_rssi) {
+ if (pnetwork->network.Rssi >
+ pnetwork_max_rssi->network.Rssi)
+ pnetwork_max_rssi = pnetwork;
+ } else
+ pnetwork_max_rssi = pnetwork;
+ } else if (is_desired_network(adapter, pnetwork)) {
+ if (check_fwstate(pmlmepriv, _FW_LINKED)) {
+ r8712_disassoc_cmd(adapter);
+ r8712_free_assoc_resources(adapter);
+ }
+ goto ask_for_joinbss;
+ }
+ }
+ }
+ return _FAIL;
+ask_for_joinbss:
+ return r8712_joinbss_cmd(adapter, pnetwork);
+}
+
+sint r8712_set_auth(struct _adapter *adapter,
+ struct security_priv *psecuritypriv)
+{
+ struct cmd_priv *pcmdpriv = &adapter->cmdpriv;
+ struct cmd_obj *pcmd;
+ struct setauth_parm *psetauthparm;
+ sint ret = _SUCCESS;
+
+ pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pcmd == NULL)
+ return _FAIL;
+
+ psetauthparm = (struct setauth_parm *)_malloc(
+ sizeof(struct setauth_parm));
+ if (psetauthparm == NULL) {
+ kfree((unsigned char *)pcmd);
+ return _FAIL;
+ }
+ memset(psetauthparm, 0, sizeof(struct setauth_parm));
+ psetauthparm->mode = (u8)psecuritypriv->AuthAlgrthm;
+ pcmd->cmdcode = _SetAuth_CMD_;
+ pcmd->parmbuf = (unsigned char *)psetauthparm;
+ pcmd->cmdsz = sizeof(struct setauth_parm);
+ pcmd->rsp = NULL;
+ pcmd->rspsz = 0;
+ _init_listhead(&pcmd->list);
+ r8712_enqueue_cmd(pcmdpriv, pcmd);
+ return ret;
+}
+
+sint r8712_set_key(struct _adapter *adapter,
+ struct security_priv *psecuritypriv,
+ sint keyid)
+{
+ struct cmd_priv *pcmdpriv = &adapter->cmdpriv;
+ struct cmd_obj *pcmd;
+ struct setkey_parm *psetkeyparm;
+ u8 keylen;
+
+ pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pcmd == NULL)
+ return _FAIL;
+ psetkeyparm = (struct setkey_parm *)_malloc(sizeof(struct setkey_parm));
+ if (psetkeyparm == NULL) {
+ kfree((unsigned char *)pcmd);
+ return _FAIL;
+ }
+ memset(psetkeyparm, 0, sizeof(struct setkey_parm));
+ if (psecuritypriv->AuthAlgrthm == 2) { /* 802.1X */
+ psetkeyparm->algorithm =
+ (u8)psecuritypriv->XGrpPrivacy;
+ } else { /* WEP */
+ psetkeyparm->algorithm =
+ (u8)psecuritypriv->PrivacyAlgrthm;
+ }
+ psetkeyparm->keyid = (u8)keyid;
+
+ switch (psetkeyparm->algorithm) {
+ case _WEP40_:
+ keylen = 5;
+ memcpy(psetkeyparm->key,
+ psecuritypriv->DefKey[keyid].skey, keylen);
+ break;
+ case _WEP104_:
+ keylen = 13;
+ memcpy(psetkeyparm->key,
+ psecuritypriv->DefKey[keyid].skey, keylen);
+ break;
+ case _TKIP_:
+ keylen = 16;
+ memcpy(psetkeyparm->key,
+ &psecuritypriv->XGrpKey[keyid - 1], keylen);
+ psetkeyparm->grpkey = 1;
+ break;
+ case _AES_:
+ keylen = 16;
+ memcpy(psetkeyparm->key,
+ &psecuritypriv->XGrpKey[keyid - 1], keylen);
+ psetkeyparm->grpkey = 1;
+ break;
+ default:
+ return _FAIL;
+ }
+ pcmd->cmdcode = _SetKey_CMD_;
+ pcmd->parmbuf = (u8 *)psetkeyparm;
+ pcmd->cmdsz = (sizeof(struct setkey_parm));
+ pcmd->rsp = NULL;
+ pcmd->rspsz = 0;
+ _init_listhead(&pcmd->list);
+ r8712_enqueue_cmd(pcmdpriv, pcmd);
+ return _SUCCESS;
+}
+
+/* adjust IEs for r8712_joinbss_cmd in WMM */
+int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie, u8 *out_ie,
+ uint in_len, uint initial_out_len)
+{
+ unsigned int ielength = 0;
+ unsigned int i, j;
+
+ i = 12; /* after the fixed IE */
+ while (i < in_len) {
+ ielength = initial_out_len;
+ if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 &&
+ in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 &&
+ in_ie[i + 5] == 0x02 && i + 5 < in_len) {
+ /*WMM element ID and OUI*/
+ for (j = i; j < i + 9; j++) {
+ out_ie[ielength] = in_ie[j];
+ ielength++;
+ }
+ out_ie[initial_out_len + 1] = 0x07;
+ out_ie[initial_out_len + 6] = 0x00;
+ out_ie[initial_out_len + 8] = 0x00;
+ break;
+ }
+ i += (in_ie[i + 1] + 2); /* to the next IE element */
+ }
+ return ielength;
+}
+
+/*
+ * Ported from 8185: IsInPreAuthKeyList().
+ *
+ * Search by BSSID,
+ * Return Value:
+ * -1 :if there is no pre-auth key in the table
+ * >=0 :if there is pre-auth key, and return the entry id
+ */
+static int SecIsInPMKIDList(struct _adapter *Adapter, u8 *bssid)
+{
+ struct security_priv *psecuritypriv = &Adapter->securitypriv;
+ int i = 0;
+
+ do {
+ if (psecuritypriv->PMKIDList[i].bUsed &&
+ (!memcmp(psecuritypriv->PMKIDList[i].Bssid,
+ bssid, ETH_ALEN)))
+ break;
+ else
+ i++;
+ } while (i < NUM_PMKID_CACHE);
+
+ if (i == NUM_PMKID_CACHE) {
+ i = -1; /* Could not find. */
+ } else {
+ ; /* There is one Pre-Authentication Key for the
+ * specific BSSID. */
+ }
+ return i;
+}
+
+sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
+ u8 *out_ie, uint in_len)
+{
+ u8 authmode = 0, securitytype, match;
+ u8 sec_ie[255], uncst_oui[4], bkup_ie[255];
+ u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
+ uint ielength, cnt, remove_cnt;
+ int iEntry;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+ uint ndisauthmode = psecuritypriv->ndisauthtype;
+ uint ndissecuritytype = psecuritypriv->ndisencryptstatus;
+
+ if ((ndisauthmode == Ndis802_11AuthModeWPA) ||
+ (ndisauthmode == Ndis802_11AuthModeWPAPSK)) {
+ authmode = _WPA_IE_ID_;
+ uncst_oui[0] = 0x0;
+ uncst_oui[1] = 0x50;
+ uncst_oui[2] = 0xf2;
+ }
+ if ((ndisauthmode == Ndis802_11AuthModeWPA2) ||
+ (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) {
+ authmode = _WPA2_IE_ID_;
+ uncst_oui[0] = 0x0;
+ uncst_oui[1] = 0x0f;
+ uncst_oui[2] = 0xac;
+ }
+ switch (ndissecuritytype) {
+ case Ndis802_11Encryption1Enabled:
+ case Ndis802_11Encryption1KeyAbsent:
+ securitytype = _WEP40_;
+ uncst_oui[3] = 0x1;
+ break;
+ case Ndis802_11Encryption2Enabled:
+ case Ndis802_11Encryption2KeyAbsent:
+ securitytype = _TKIP_;
+ uncst_oui[3] = 0x2;
+ break;
+ case Ndis802_11Encryption3Enabled:
+ case Ndis802_11Encryption3KeyAbsent:
+ securitytype = _AES_;
+ uncst_oui[3] = 0x4;
+ break;
+ default:
+ securitytype = _NO_PRIVACY_;
+ break;
+ }
+ /*Search required WPA or WPA2 IE and copy to sec_ie[] */
+ cnt = 12;
+ match = false;
+ while (cnt < in_len) {
+ if (in_ie[cnt] == authmode) {
+ if ((authmode == _WPA_IE_ID_) &&
+ (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) {
+ memcpy(&sec_ie[0], &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
+ match = true;
+ break;
+ }
+ if (authmode == _WPA2_IE_ID_) {
+ memcpy(&sec_ie[0], &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
+ match = true;
+ break;
+ }
+ if (((authmode == _WPA_IE_ID_) &&
+ (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) ||
+ (authmode == _WPA2_IE_ID_))
+ memcpy(&bkup_ie[0], &in_ie[cnt],
+ in_ie[cnt + 1] + 2);
+ }
+ cnt += in_ie[cnt+1] + 2; /*get next*/
+ }
+ /*restruct WPA IE or WPA2 IE in sec_ie[] */
+ if (match == true) {
+ if (sec_ie[0] == _WPA_IE_ID_) {
+ /* parsing SSN IE to select required encryption
+ * algorithm, and set the bc/mc encryption algorithm */
+ while (true) {
+ /*check wpa_oui tag*/
+ if (memcmp(&sec_ie[2], &wpa_oui[0], 4)) {
+ match = false;
+ break;
+ }
+ if ((sec_ie[6] != 0x01) || (sec_ie[7] != 0x0)) {
+ /*IE Ver error*/
+ match = false;
+ break;
+ }
+ if (!memcmp(&sec_ie[8], &wpa_oui[0], 3)) {
+ /* get bc/mc encryption type (group
+ * key type)*/
+ switch (sec_ie[11]) {
+ case 0x0: /*none*/
+ psecuritypriv->XGrpPrivacy =
+ _NO_PRIVACY_;
+ break;
+ case 0x1: /*WEP_40*/
+ psecuritypriv->XGrpPrivacy =
+ _WEP40_;
+ break;
+ case 0x2: /*TKIP*/
+ psecuritypriv->XGrpPrivacy =
+ _TKIP_;
+ break;
+ case 0x3: /*AESCCMP*/
+ case 0x4:
+ psecuritypriv->XGrpPrivacy =
+ _AES_;
+ break;
+ case 0x5: /*WEP_104*/
+ psecuritypriv->XGrpPrivacy =
+ _WEP104_;
+ break;
+ }
+ } else {
+ match = false;
+ break;
+ }
+ if (sec_ie[12] == 0x01) {
+ /*check the unicast encryption type*/
+ if (memcmp(&sec_ie[14],
+ &uncst_oui[0], 4)) {
+ match = false;
+ break;
+
+ } /*else the uncst_oui is match*/
+ } else { /*mixed mode, unicast_enc_type > 1*/
+ /*select the uncst_oui and remove
+ * the other uncst_oui*/
+ cnt = sec_ie[12];
+ remove_cnt = (cnt-1) * 4;
+ sec_ie[12] = 0x01;
+ memcpy(&sec_ie[14], &uncst_oui[0], 4);
+ /*remove the other unicast suit*/
+ memcpy(&sec_ie[18],
+ &sec_ie[18 + remove_cnt],
+ sec_ie[1] - 18 + 2 -
+ remove_cnt);
+ sec_ie[1] = sec_ie[1] - remove_cnt;
+ }
+ break;
+ }
+ }
+ if (authmode == _WPA2_IE_ID_) {
+ /* parsing RSN IE to select required encryption
+ * algorithm, and set the bc/mc encryption algorithm */
+ while (true) {
+ if ((sec_ie[2] != 0x01) || (sec_ie[3] != 0x0)) {
+ /*IE Ver error*/
+ match = false;
+ break;
+ }
+ if (!memcmp(&sec_ie[4], &uncst_oui[0], 3)) {
+ /*get bc/mc encryption type*/
+ switch (sec_ie[7]) {
+ case 0x1: /*WEP_40*/
+ psecuritypriv->XGrpPrivacy =
+ _WEP40_;
+ break;
+ case 0x2: /*TKIP*/
+ psecuritypriv->XGrpPrivacy =
+ _TKIP_;
+ break;
+ case 0x4: /*AESWRAP*/
+ psecuritypriv->XGrpPrivacy =
+ _AES_;
+ break;
+ case 0x5: /*WEP_104*/
+ psecuritypriv->XGrpPrivacy =
+ _WEP104_;
+ break;
+ default: /*one*/
+ psecuritypriv->XGrpPrivacy =
+ _NO_PRIVACY_;
+ break;
+ }
+ } else {
+ match = false;
+ break;
+ }
+ if (sec_ie[8] == 0x01) {
+ /*check the unicast encryption type*/
+ if (memcmp(&sec_ie[10],
+ &uncst_oui[0], 4)) {
+ match = false;
+ break;
+ } /*else the uncst_oui is match*/
+ } else { /*mixed mode, unicast_enc_type > 1*/
+ /*select the uncst_oui and remove the
+ * other uncst_oui*/
+ cnt = sec_ie[8];
+ remove_cnt = (cnt-1)*4;
+ sec_ie[8] = 0x01;
+ memcpy(&sec_ie[10], &uncst_oui[0], 4);
+ /*remove the other unicast suit*/
+ memcpy(&sec_ie[14],
+ &sec_ie[14 + remove_cnt],
+ (sec_ie[1] - 14 + 2 -
+ remove_cnt));
+ sec_ie[1] = sec_ie[1]-remove_cnt;
+ }
+ break;
+ }
+ }
+ }
+ if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) {
+ /*copy fixed ie*/
+ memcpy(out_ie, in_ie, 12);
+ ielength = 12;
+ /*copy RSN or SSN*/
+ if (match == true) {
+ memcpy(&out_ie[ielength], &sec_ie[0], sec_ie[1]+2);
+ ielength += sec_ie[1] + 2;
+ if (authmode == _WPA2_IE_ID_) {
+ /*the Pre-Authentication bit should be zero*/
+ out_ie[ielength - 1] = 0;
+ out_ie[ielength - 2] = 0;
+ }
+ r8712_report_sec_ie(adapter, authmode, sec_ie);
+ }
+ } else {
+ /*copy fixed ie only*/
+ memcpy(out_ie, in_ie, 12);
+ ielength = 12;
+ if (psecuritypriv->wps_phase == true) {
+ memcpy(out_ie+ielength, psecuritypriv->wps_ie,
+ psecuritypriv->wps_ie_len);
+ ielength += psecuritypriv->wps_ie_len;
+ }
+ }
+ iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid);
+ if (iEntry < 0)
+ return ielength;
+ else {
+ if (authmode == _WPA2_IE_ID_) {
+ out_ie[ielength] = 1;
+ ielength++;
+ out_ie[ielength] = 0; /*PMKID count = 0x0100*/
+ ielength++;
+ memcpy(&out_ie[ielength],
+ &psecuritypriv->PMKIDList[iEntry].PMKID, 16);
+ ielength += 16;
+ out_ie[13] += 18;/*PMKID length = 2+16*/
+ }
+ }
+ return ielength;
+}
+
+void r8712_init_registrypriv_dev_network(struct _adapter *adapter)
+{
+ struct registry_priv *pregistrypriv = &adapter->registrypriv;
+ struct eeprom_priv *peepriv = &adapter->eeprompriv;
+ struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
+ u8 *myhwaddr = myid(peepriv);
+
+ memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN);
+ memcpy(&pdev_network->Ssid, &pregistrypriv->ssid,
+ sizeof(struct ndis_802_11_ssid));
+ pdev_network->Configuration.Length =
+ sizeof(struct NDIS_802_11_CONFIGURATION);
+ pdev_network->Configuration.BeaconPeriod = 100;
+ pdev_network->Configuration.FHConfig.Length = 0;
+ pdev_network->Configuration.FHConfig.HopPattern = 0;
+ pdev_network->Configuration.FHConfig.HopSet = 0;
+ pdev_network->Configuration.FHConfig.DwellTime = 0;
+}
+
+void r8712_update_registrypriv_dev_network(struct _adapter *adapter)
+{
+ int sz = 0;
+ struct registry_priv *pregistrypriv = &adapter->registrypriv;
+ struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+ struct wlan_network *cur_network = &adapter->mlmepriv.cur_network;
+
+ pdev_network->Privacy = cpu_to_le32(psecuritypriv->PrivacyAlgrthm
+ > 0 ? 1 : 0) ; /* adhoc no 802.1x */
+ pdev_network->Rssi = 0;
+ switch (pregistrypriv->wireless_mode) {
+ case WIRELESS_11B:
+ pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11DS);
+ break;
+ case WIRELESS_11G:
+ case WIRELESS_11BG:
+ pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11OFDM24);
+ break;
+ case WIRELESS_11A:
+ pdev_network->NetworkTypeInUse = cpu_to_le32(Ndis802_11OFDM5);
+ break;
+ default:
+ /* TODO */
+ break;
+ }
+ pdev_network->Configuration.DSConfig = cpu_to_le32(
+ pregistrypriv->channel);
+ if (cur_network->network.InfrastructureMode == Ndis802_11IBSS)
+ pdev_network->Configuration.ATIMWindow = cpu_to_le32(3);
+ pdev_network->InfrastructureMode = cpu_to_le32(
+ cur_network->network.InfrastructureMode);
+ /* 1. Supported rates
+ * 2. IE
+ */
+ sz = r8712_generate_ie(pregistrypriv, adapter);
+ pdev_network->IELength = sz;
+ pdev_network->Length = r8712_get_ndis_wlan_bssid_ex_sz(
+ (struct ndis_wlan_bssid_ex *)pdev_network);
+}
+
+/*the fucntion is at passive_level*/
+void r8712_joinbss_reset(struct _adapter *padapter)
+{
+ int i;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+
+ /* todo: if you want to do something io/reg/hw setting before join_bss,
+ * please add code here */
+ phtpriv->ampdu_enable = false;/*reset to disabled*/
+ for (i = 0; i < 16; i++)
+ phtpriv->baddbareq_issued[i] = false;/*reset it*/
+ if (phtpriv->ht_option) {
+ /* validate usb rx aggregation */
+ r8712_write8(padapter, 0x102500D9, 48);/*TH = 48 pages, 6k*/
+ } else {
+ /* invalidate usb rx aggregation */
+ /* TH=1 => means that invalidate usb rx aggregation */
+ r8712_write8(padapter, 0x102500D9, 1);
+ }
+}
+
+/*the function is >= passive_level*/
+unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
+ u8 *out_ie, uint in_len, uint *pout_len)
+{
+ u32 ielen, out_len;
+ unsigned char *p, *pframe;
+ struct ieee80211_ht_cap ht_capie;
+ unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+
+ phtpriv->ht_option = 0;
+ p = r8712_get_ie(in_ie+12, _HT_CAPABILITY_IE_, &ielen, in_len-12);
+ if (p && (ielen > 0)) {
+ if (pqospriv->qos_option == 0) {
+ out_len = *pout_len;
+ pframe = r8712_set_ie(out_ie+out_len,
+ _VENDOR_SPECIFIC_IE_,
+ _WMM_IE_Length_,
+ WMM_IE, pout_len);
+ pqospriv->qos_option = 1;
+ }
+ out_len = *pout_len;
+ memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
+ ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH |
+ IEEE80211_HT_CAP_SGI_20 |
+ IEEE80211_HT_CAP_SGI_40 |
+ IEEE80211_HT_CAP_TX_STBC |
+ IEEE80211_HT_CAP_MAX_AMSDU |
+ IEEE80211_HT_CAP_DSSSCCK40;
+ ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR &
+ 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
+ pframe = r8712_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_,
+ sizeof(struct ieee80211_ht_cap),
+ (unsigned char *)&ht_capie, pout_len);
+ phtpriv->ht_option = 1;
+ }
+ return phtpriv->ht_option;
+}
+
+/* the fucntion is > passive_level (in critical_section) */
+static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
+{
+ u8 *p, max_ampdu_sz;
+ int i, len;
+ struct sta_info *bmc_sta, *psta;
+ struct ieee80211_ht_cap *pht_capie;
+ struct ieee80211_ht_addt_info *pht_addtinfo;
+ struct recv_reorder_ctrl *preorder_ctrl;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+ struct wlan_network *pcur_network = &(pmlmepriv->cur_network);
+
+ if (!phtpriv->ht_option)
+ return;
+ /* maybe needs check if ap supports rx ampdu. */
+ if ((phtpriv->ampdu_enable == false) &&
+ (pregistrypriv->ampdu_enable == 1))
+ phtpriv->ampdu_enable = true;
+ /*check Max Rx A-MPDU Size*/
+ len = 0;
+ p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs),
+ _HT_CAPABILITY_IE_,
+ &len, ie_len -
+ sizeof(struct NDIS_802_11_FIXED_IEs));
+ if (p && len > 0) {
+ pht_capie = (struct ieee80211_ht_cap *)(p+2);
+ max_ampdu_sz = (pht_capie->ampdu_params_info &
+ IEEE80211_HT_CAP_AMPDU_FACTOR);
+ /* max_ampdu_sz (kbytes); */
+ max_ampdu_sz = 1 << (max_ampdu_sz+3);
+ phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
+ }
+ /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info
+ * if A-MPDU Rx is enabled, reseting rx_ordering_ctrl
+ * wstart_b(indicate_seq) to default value=0xffff
+ * todo: check if AP can send A-MPDU packets
+ */
+ bmc_sta = r8712_get_bcmc_stainfo(padapter);
+ if (bmc_sta) {
+ for (i = 0; i < 16; i++) {
+ preorder_ctrl = &bmc_sta->recvreorder_ctrl[i];
+ preorder_ctrl->indicate_seq = 0xffff;
+ preorder_ctrl->wend_b = 0xffff;
+ }
+ }
+ psta = r8712_get_stainfo(&padapter->stapriv,
+ pcur_network->network.MacAddress);
+ if (psta) {
+ for (i = 0; i < 16 ; i++) {
+ preorder_ctrl = &psta->recvreorder_ctrl[i];
+ preorder_ctrl->indicate_seq = 0xffff;
+ preorder_ctrl->wend_b = 0xffff;
+ }
+ }
+ len = 0;
+ p = r8712_get_ie(pie + sizeof(struct NDIS_802_11_FIXED_IEs),
+ _HT_ADD_INFO_IE_, &len,
+ ie_len-sizeof(struct NDIS_802_11_FIXED_IEs));
+ if (p && len > 0)
+ pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2);
+}
+
+void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority)
+{
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+
+ if ((phtpriv->ht_option == 1) && (phtpriv->ampdu_enable == true)) {
+ if (phtpriv->baddbareq_issued[priority] == false) {
+ r8712_addbareq_cmd(padapter, (u8)priority);
+ phtpriv->baddbareq_issued[priority] = true;
+ }
+ }
+}
+
+/*the fucntion is >= passive_level*/
+unsigned int r8712_add_ht_addt_info(struct _adapter *padapter,
+ u8 *in_ie, u8 *out_ie,
+ uint in_len, uint *pout_len)
+{
+ u32 ielen, out_len = 0;
+ unsigned char *p, *pframe;
+ struct ieee80211_ht_addt_info ht_addt_info;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct ht_priv *phtpriv = &pmlmepriv->htpriv;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+ out_len = *pout_len;
+
+ if (pregistrypriv->ht_enable == 1) {
+ p = r8712_get_ie(in_ie+12, _HT_ADD_INFO_IE_,
+ &ielen, in_len - 12);
+ if (p && (ielen > 0)) {
+ ; /* dummy branch */
+ } else {
+ if (p == NULL) {
+ int sz = sizeof(struct ieee80211_ht_addt_info);
+ memset(&ht_addt_info, 0, sz);
+ /*need to add the HT additional IEs*/
+ ht_addt_info.control_chan =
+ pregistrypriv->channel;
+ pframe = r8712_set_ie(out_ie + out_len,
+ _HT_ADD_INFO_IE_,
+ sz,
+ (unsigned char *)&ht_addt_info,
+ pout_len);
+ }
+ }
+ }
+ return phtpriv->ht_option;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h
new file mode 100644
index 000000000000..2b35b740ab89
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mlme.h
@@ -0,0 +1,208 @@
+#ifndef __RTL871X_MLME_H_
+#define __RTL871X_MLME_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wlan_bssdef.h"
+
+#define MAX_BSS_CNT 64
+#define MAX_JOIN_TIMEOUT 6000
+
+#define SCANNING_TIMEOUT 4500
+
+#define SCANQUEUE_LIFETIME 20 /* unit:sec */
+
+#define WIFI_NULL_STATE 0x00000000
+#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state...*/
+#define WIFI_REASOC_STATE 0x00000002
+#define WIFI_SLEEP_STATE 0x00000004
+#define WIFI_STATION_STATE 0x00000008
+#define WIFI_AP_STATE 0x00000010
+#define WIFI_ADHOC_STATE 0x00000020
+#define WIFI_ADHOC_MASTER_STATE 0x00000040
+#define WIFI_UNDER_LINKING 0x00000080
+#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station
+ * is under site surveying*/
+#define WIFI_MP_STATE 0x00010000
+#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in cont. tx background*/
+#define WIFI_MP_CTX_ST 0x00040000 /* in cont. tx with
+ * single-tone*/
+#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in cont, tx
+ * background due to out of skb*/
+#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx*/
+#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in cont, tx with carrier
+ * suppression*/
+#define WIFI_MP_LPBK_STATE 0x00400000
+
+#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
+#define _FW_LINKED WIFI_ASOC_STATE
+#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
+
+/*
+there are several "locks" in mlme_priv,
+since mlme_priv is a shared resource between many threads,
+like ISR/Call-Back functions, the OID handlers, and even timer functions.
+Each _queue has its own locks, already.
+Other items are protected by mlme_priv.lock.
+To avoid possible dead lock, any thread trying to modifiying mlme_priv
+SHALL not lock up more than one locks at a time!
+*/
+
+#define traffic_threshold 10
+#define traffic_scan_period 500
+
+struct sitesurvey_ctrl {
+ u64 last_tx_pkts;
+ uint last_rx_pkts;
+ sint traffic_busy;
+ struct timer_list sitesurvey_ctrl_timer;
+};
+
+struct mlme_priv {
+
+ spinlock_t lock;
+ spinlock_t lock2;
+ sint fw_state; /*shall we protect this variable? */
+ u8 to_join; /*flag*/
+ u8 *nic_hdl;
+ struct list_head *pscanned;
+ struct __queue free_bss_pool;
+ struct __queue scanned_queue;
+ u8 *free_bss_buf;
+ unsigned long num_of_scanned;
+ struct ndis_802_11_ssid assoc_ssid;
+ u8 assoc_bssid[6];
+ struct wlan_network cur_network;
+ struct sitesurvey_ctrl sitesurveyctrl;
+ struct timer_list assoc_timer;
+ uint assoc_by_bssid;
+ uint assoc_by_rssi;
+ struct timer_list scan_to_timer; /* driver handles scan_timeout.*/
+ struct timer_list dhcp_timer; /* set dhcp to if driver in ps mode.*/
+ struct qos_priv qospriv;
+ struct ht_priv htpriv;
+ struct timer_list wdg_timer; /*watchdog periodic timer*/
+};
+
+static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
+{
+ return pmlmepriv->cur_network.network.MacAddress;
+}
+
+static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
+{
+ if (pmlmepriv->fw_state & state)
+ return true;
+ return false;
+}
+
+static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
+{
+ return pmlmepriv->fw_state;
+}
+
+/*
+ * No Limit on the calling context,
+ * therefore set it to be the critical section...
+ *
+ * ### NOTE:#### (!!!!)
+ * TAKE CARE THAT BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
+ */
+static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
+{
+ pmlmepriv->fw_state |= state;
+}
+
+static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
+{
+ pmlmepriv->fw_state &= ~state;
+}
+
+/*
+ * No Limit on the calling context,
+ * therefore set it to be the critical section...
+ */
+static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
+{
+ unsigned long irqL;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, state) == true)
+ pmlmepriv->fw_state ^= state;
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
+{
+ unsigned long irqL;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ pmlmepriv->num_of_scanned++;
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
+{
+ unsigned long irqL;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ pmlmepriv->num_of_scanned--;
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
+ sint val)
+{
+ unsigned long irqL;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ pmlmepriv->num_of_scanned = val;
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+}
+
+void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
+void r8712_free_network_queue(struct _adapter *adapter);
+int r8712_init_mlme_priv(struct _adapter *adapter);
+void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
+sint r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
+sint r8712_set_key(struct _adapter *adapter,
+ struct security_priv *psecuritypriv, sint keyid);
+sint r8712_set_auth(struct _adapter *adapter,
+ struct security_priv *psecuritypriv);
+uint r8712_get_ndis_wlan_bssid_ex_sz(struct ndis_wlan_bssid_ex *bss);
+void r8712_generate_random_ibss(u8 *pibss);
+u8 *r8712_get_capability_from_ie(u8 *ie);
+struct wlan_network *r8712_get_oldest_wlan_network(
+ struct __queue *scanned_queue);
+void r8712_free_assoc_resources(struct _adapter *adapter);
+void r8712_ind_disconnect(struct _adapter *adapter);
+void r8712_indicate_connect(struct _adapter *adapter);
+int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
+ u8 *out_ie, uint in_len);
+int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
+ u8 *out_ie, uint in_len, uint initial_out_len);
+void r8712_init_registrypriv_dev_network(struct _adapter *adapter);
+void r8712_update_registrypriv_dev_network(struct _adapter *adapter);
+void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter);
+void _r8712_join_timeout_handler(struct _adapter *adapter);
+void r8712_scan_timeout_handler(struct _adapter *adapter);
+void _r8712_dhcp_timeout_handler(struct _adapter *adapter);
+void _r8712_wdg_timeout_handler(struct _adapter *adapter);
+struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
+sint r8712_if_up(struct _adapter *padapter);
+void r8712_joinbss_reset(struct _adapter *padapter);
+unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
+ u8 *out_ie, uint in_len, uint *pout_len);
+void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
+unsigned int r8712_add_ht_addt_info(struct _adapter *padapter, u8 *in_ie,
+ u8 *out_ie, uint in_len, uint *pout_len);
+int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
+
+#endif /*__RTL871X_MLME_H_*/
diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c
new file mode 100644
index 000000000000..427467cb10bd
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mp.c
@@ -0,0 +1,736 @@
+/******************************************************************************
+ * rtl871x_mp.c
+ *
+ * Description :
+ *
+ * Author :
+ *
+ * History :
+ *
+ * Copyright 2007, Realtek Corp.
+ *
+ * The contents of this file is the sole property of Realtek Corp. It can not be
+ * be used, copied or modified without written permission from Realtek Corp.
+ *
+*******************************************************************************/
+#define _RTL871X_MP_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_mp_phy_regdef.h"
+#include "rtl8712_cmd.h"
+
+static void _init_mp_priv_(struct mp_priv *pmp_priv)
+{
+ pmp_priv->mode = _LOOPBOOK_MODE_;
+ pmp_priv->curr_ch = 1;
+ pmp_priv->curr_modem = MIXED_PHY;
+ pmp_priv->curr_rateidx = 0;
+ pmp_priv->curr_txpoweridx = 0x14;
+ pmp_priv->antenna_tx = ANTENNA_A;
+ pmp_priv->antenna_rx = ANTENNA_AB;
+ pmp_priv->check_mp_pkt = 0;
+ pmp_priv->tx_pktcount = 0;
+ pmp_priv->rx_pktcount = 0;
+ pmp_priv->rx_crcerrpktcount = 0;
+}
+
+static int init_mp_priv(struct mp_priv *pmp_priv)
+{
+ int i, res;
+ struct mp_xmit_frame *pmp_xmitframe;
+
+ _init_mp_priv_(pmp_priv);
+ _init_queue(&pmp_priv->free_mp_xmitqueue);
+ pmp_priv->pallocated_mp_xmitframe_buf = NULL;
+ pmp_priv->pallocated_mp_xmitframe_buf = _malloc(NR_MP_XMITFRAME *
+ sizeof(struct mp_xmit_frame) + 4);
+ if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) {
+ res = _FAIL;
+ goto _exit_init_mp_priv;
+ }
+ pmp_priv->pmp_xmtframe_buf = pmp_priv->pallocated_mp_xmitframe_buf +
+ 4 -
+ ((addr_t)(pmp_priv->pallocated_mp_xmitframe_buf) & 3);
+ pmp_xmitframe = (struct mp_xmit_frame *)pmp_priv->pmp_xmtframe_buf;
+ for (i = 0; i < NR_MP_XMITFRAME; i++) {
+ _init_listhead(&(pmp_xmitframe->list));
+ list_insert_tail(&(pmp_xmitframe->list),
+ &(pmp_priv->free_mp_xmitqueue.queue));
+ pmp_xmitframe->pkt = NULL;
+ pmp_xmitframe->frame_tag = MP_FRAMETAG;
+ pmp_xmitframe->padapter = pmp_priv->papdater;
+ pmp_xmitframe++;
+ }
+ pmp_priv->free_mp_xmitframe_cnt = NR_MP_XMITFRAME;
+ res = _SUCCESS;
+_exit_init_mp_priv:
+ return res;
+}
+
+static int free_mp_priv(struct mp_priv *pmp_priv)
+{
+ int res = 0;
+ kfree(pmp_priv->pallocated_mp_xmitframe_buf);
+ return res;
+}
+
+void mp871xinit(struct _adapter *padapter)
+{
+ struct mp_priv *pmppriv = &padapter->mppriv;
+
+ pmppriv->papdater = padapter;
+ init_mp_priv(pmppriv);
+}
+
+void mp871xdeinit(struct _adapter *padapter)
+{
+ struct mp_priv *pmppriv = &padapter->mppriv;
+
+ free_mp_priv(pmppriv);
+}
+
+/*
+ * Special for bb and rf reg read/write
+ */
+static u32 fw_iocmd_read(struct _adapter *pAdapter, struct IOCMD_STRUCT iocmd)
+{
+ u32 cmd32 = 0, val32 = 0;
+ u8 iocmd_class = iocmd.cmdclass;
+ u16 iocmd_value = iocmd.value;
+ u8 iocmd_idx = iocmd.index;
+
+ cmd32 = (iocmd_class << 24) | (iocmd_value << 8) | iocmd_idx ;
+ if (r8712_fw_cmd(pAdapter, cmd32))
+ r8712_fw_cmd_data(pAdapter, &val32, 1);
+ else
+ val32 = 0;
+ return val32;
+}
+
+static u8 fw_iocmd_write(struct _adapter *pAdapter,
+ struct IOCMD_STRUCT iocmd, u32 value)
+{
+ u32 cmd32 = 0;
+ u8 iocmd_class = iocmd.cmdclass;
+ u32 iocmd_value = iocmd.value;
+ u8 iocmd_idx = iocmd.index;
+
+ r8712_fw_cmd_data(pAdapter, &value, 0);
+ msleep(100);
+ cmd32 = (iocmd_class << 24) | (iocmd_value << 8) | iocmd_idx ;
+ return r8712_fw_cmd(pAdapter, cmd32);
+}
+
+/* offset : 0X800~0XFFF */
+u32 r8712_bb_reg_read(struct _adapter *pAdapter, u16 offset)
+{
+ u8 shift = offset & 0x0003; /* 4 byte access */
+ u16 bb_addr = offset & 0x0FFC; /* 4 byte access */
+ u32 bb_val = 0;
+ struct IOCMD_STRUCT iocmd;
+
+ iocmd.cmdclass = IOCMD_CLASS_BB_RF;
+ iocmd.value = bb_addr;
+ iocmd.index = IOCMD_BB_READ_IDX;
+ bb_val = fw_iocmd_read(pAdapter, iocmd);
+ if (shift != 0) {
+ u32 bb_val2 = 0;
+ bb_val >>= (shift * 8);
+ iocmd.value += 4;
+ bb_val2 = fw_iocmd_read(pAdapter, iocmd);
+ bb_val2 <<= ((4 - shift) * 8);
+ bb_val |= bb_val2;
+ }
+ return bb_val;
+}
+
+/* offset : 0X800~0XFFF */
+u8 r8712_bb_reg_write(struct _adapter *pAdapter, u16 offset, u32 value)
+{
+ u8 shift = offset & 0x0003; /* 4 byte access */
+ u16 bb_addr = offset & 0x0FFC; /* 4 byte access */
+ struct IOCMD_STRUCT iocmd;
+
+ iocmd.cmdclass = IOCMD_CLASS_BB_RF;
+ iocmd.value = bb_addr;
+ iocmd.index = IOCMD_BB_WRITE_IDX;
+ if (shift != 0) {
+ u32 oldValue = 0;
+ u32 newValue = value;
+
+ oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
+ oldValue &= (0xFFFFFFFF >> ((4 - shift) * 8));
+ value = oldValue | (newValue << (shift * 8));
+ if (fw_iocmd_write(pAdapter, iocmd, value) == false)
+ return false;
+ iocmd.value += 4;
+ oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
+ oldValue &= (0xFFFFFFFF << (shift * 8));
+ value = oldValue | (newValue >> ((4 - shift) * 8));
+ }
+ return fw_iocmd_write(pAdapter, iocmd, value);
+}
+
+/* offset : 0x00 ~ 0xFF */
+u32 r8712_rf_reg_read(struct _adapter *pAdapter, u8 path, u8 offset)
+{
+ u16 rf_addr = (path << 8) | offset;
+ u32 rf_data;
+ struct IOCMD_STRUCT iocmd;
+
+ iocmd.cmdclass = IOCMD_CLASS_BB_RF ;
+ iocmd.value = rf_addr ;
+ iocmd.index = IOCMD_RF_READ_IDX;
+ rf_data = fw_iocmd_read(pAdapter, iocmd);
+ return rf_data;
+}
+
+u8 r8712_rf_reg_write(struct _adapter *pAdapter, u8 path, u8 offset, u32 value)
+{
+ u16 rf_addr = (path << 8) | offset;
+ struct IOCMD_STRUCT iocmd;
+
+ iocmd.cmdclass = IOCMD_CLASS_BB_RF;
+ iocmd.value = rf_addr;
+ iocmd.index = IOCMD_RF_WRIT_IDX;
+ return fw_iocmd_write(pAdapter, iocmd, value);
+}
+
+static u32 bitshift(u32 bitmask)
+{
+ u32 i;
+
+ for (i = 0; i <= 31; i++)
+ if (((bitmask>>i) & 0x1) == 1)
+ break;
+ return i;
+}
+
+static u32 get_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask)
+{
+ u32 org_value, bit_shift, new_value;
+
+ org_value = r8712_bb_reg_read(pAdapter, offset);
+ bit_shift = bitshift(bitmask);
+ new_value = (org_value & bitmask) >> bit_shift;
+ return new_value;
+}
+
+static u8 set_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask, u32 value)
+{
+ u32 org_value, bit_shift, new_value;
+
+ if (bitmask != bMaskDWord) {
+ org_value = r8712_bb_reg_read(pAdapter, offset);
+ bit_shift = bitshift(bitmask);
+ new_value = ((org_value & (~bitmask)) | (value << bit_shift));
+ } else
+ new_value = value;
+ return r8712_bb_reg_write(pAdapter, offset, new_value);
+}
+
+static u32 get_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset,
+ u32 bitmask)
+{
+ u32 org_value, bit_shift, new_value;
+
+ org_value = r8712_rf_reg_read(pAdapter, path, offset);
+ bit_shift = bitshift(bitmask);
+ new_value = (org_value & bitmask) >> bit_shift;
+ return new_value;
+}
+
+static u8 set_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset, u32 bitmask,
+ u32 value)
+{
+ u32 org_value, bit_shift, new_value;
+
+ if (bitmask != bMaskDWord) {
+ org_value = r8712_rf_reg_read(pAdapter, path, offset);
+ bit_shift = bitshift(bitmask);
+ new_value = ((org_value & (~bitmask)) | (value << bit_shift));
+ } else
+ new_value = value;
+ return r8712_rf_reg_write(pAdapter, path, offset, new_value);
+}
+
+/*
+ * SetChannel
+ * Description
+ * Use H2C command to change channel,
+ * not only modify rf register, but also other setting need to be done.
+ */
+void r8712_SetChannel(struct _adapter *pAdapter)
+{
+ struct cmd_priv *pcmdpriv = &pAdapter->cmdpriv;
+ struct cmd_obj *pcmd = NULL;
+ struct SetChannel_parm *pparm = NULL;
+ u16 code = GEN_CMD_CODE(_SetChannel);
+
+ pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
+ if (pcmd == NULL)
+ return;
+ pparm = (struct SetChannel_parm *)_malloc(sizeof(struct
+ SetChannel_parm));
+ if (pparm == NULL) {
+ if (pcmd != NULL)
+ kfree((u8 *)pcmd);
+ return;
+ }
+ pparm->curr_ch = pAdapter->mppriv.curr_ch;
+ init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code);
+ r8712_enqueue_cmd(pcmdpriv, pcmd);
+}
+
+static void SetCCKTxPower(struct _adapter *pAdapter, u8 TxPower)
+{
+ u16 TxAGC = 0;
+
+ TxAGC = TxPower;
+ set_bb_reg(pAdapter, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
+}
+
+static void SetOFDMTxPower(struct _adapter *pAdapter, u8 TxPower)
+{
+ u32 TxAGC = 0;
+
+ TxAGC |= ((TxPower<<24)|(TxPower<<16)|(TxPower<<8)|TxPower);
+ set_bb_reg(pAdapter, rTxAGC_Rate18_06, bTxAGCRate18_06, TxAGC);
+ set_bb_reg(pAdapter, rTxAGC_Rate54_24, bTxAGCRate54_24, TxAGC);
+ set_bb_reg(pAdapter, rTxAGC_Mcs03_Mcs00, bTxAGCRateMCS3_MCS0, TxAGC);
+ set_bb_reg(pAdapter, rTxAGC_Mcs07_Mcs04, bTxAGCRateMCS7_MCS4, TxAGC);
+ set_bb_reg(pAdapter, rTxAGC_Mcs11_Mcs08, bTxAGCRateMCS11_MCS8, TxAGC);
+ set_bb_reg(pAdapter, rTxAGC_Mcs15_Mcs12, bTxAGCRateMCS15_MCS12, TxAGC);
+}
+
+void r8712_SetTxPower(struct _adapter *pAdapter)
+{
+ u8 TxPower = pAdapter->mppriv.curr_txpoweridx;
+ SetCCKTxPower(pAdapter, TxPower);
+ SetOFDMTxPower(pAdapter, TxPower);
+}
+
+void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset)
+{
+ u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D, tmpAGC;
+
+ TxAGCOffset_B = (ulTxAGCOffset&0x000000ff);
+ TxAGCOffset_C = ((ulTxAGCOffset&0x0000ff00)>>8);
+ TxAGCOffset_D = ((ulTxAGCOffset&0x00ff0000)>>16);
+ tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B);
+ set_bb_reg(pAdapter, rFPGA0_TxGainStage,
+ (bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC);
+}
+
+void r8712_SetDataRate(struct _adapter *pAdapter)
+{
+ u8 path = RF_PATH_A;
+ u8 offset = RF_SYN_G2;
+ u32 value;
+
+ value = (pAdapter->mppriv.curr_rateidx < 4) ? 0x4440 : 0xF200;
+ r8712_rf_reg_write(pAdapter, path, offset, value);
+}
+
+void r8712_SwitchBandwidth(struct _adapter *pAdapter)
+{
+ /* 3 1.Set MAC register : BWOPMODE bit2:1 20MhzBW */
+ u8 regBwOpMode = 0;
+ u8 Bandwidth = pAdapter->mppriv.curr_bandwidth;
+
+ regBwOpMode = r8712_read8(pAdapter, 0x10250203);
+ if (Bandwidth == HT_CHANNEL_WIDTH_20)
+ regBwOpMode |= BIT(2);
+ else
+ regBwOpMode &= ~(BIT(2));
+ r8712_write8(pAdapter, 0x10250203, regBwOpMode);
+ /* 3 2.Set PHY related register */
+ switch (Bandwidth) {
+ /* 20 MHz channel*/
+ case HT_CHANNEL_WIDTH_20:
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bRFMOD, 0x0);
+ set_bb_reg(pAdapter, rFPGA1_RFMOD, bRFMOD, 0x0);
+ /* Use PHY_REG.txt default value. Do not need to change.
+ * Correct the tx power for CCK rate in 40M.
+ * It is set in Tx descriptor for 8192x series
+ */
+ set_bb_reg(pAdapter, rFPGA0_AnalogParameter2, bMaskDWord, 0x58);
+ break;
+ /* 40 MHz channel*/
+ case HT_CHANNEL_WIDTH_40:
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bRFMOD, 0x1);
+ set_bb_reg(pAdapter, rFPGA1_RFMOD, bRFMOD, 0x1);
+ /* Use PHY_REG.txt default value. Do not need to change.
+ * Correct the tx power for CCK rate in 40M.
+ * Set Control channel to upper or lower. These settings are
+ * required only for 40MHz */
+ set_bb_reg(pAdapter, rCCK0_System, bCCKSideBand,
+ (HAL_PRIME_CHNL_OFFSET_DONT_CARE>>1));
+ set_bb_reg(pAdapter, rOFDM1_LSTF, 0xC00,
+ HAL_PRIME_CHNL_OFFSET_DONT_CARE);
+ set_bb_reg(pAdapter, rFPGA0_AnalogParameter2, bMaskDWord, 0x18);
+ break;
+ default:
+ break;
+ }
+
+ /* 3 3.Set RF related register */
+ switch (Bandwidth) {
+ case HT_CHANNEL_WIDTH_20:
+ set_rf_reg(pAdapter, RF_PATH_A, RF_CHNLBW,
+ BIT(10) | BIT(11), 0x01);
+ break;
+ case HT_CHANNEL_WIDTH_40:
+ set_rf_reg(pAdapter, RF_PATH_A, RF_CHNLBW,
+ BIT(10) | BIT(11), 0x00);
+ break;
+ default:
+ break;
+ }
+}
+/*------------------------------Define structure----------------------------*/
+struct R_ANTENNA_SELECT_OFDM {
+ u32 r_tx_antenna:4;
+ u32 r_ant_l:4;
+ u32 r_ant_non_ht:4;
+ u32 r_ant_ht1:4;
+ u32 r_ant_ht2:4;
+ u32 r_ant_ht_s1:4;
+ u32 r_ant_non_ht_s1:4;
+ u32 OFDM_TXSC:2;
+ u32 Reserved:2;
+};
+
+struct R_ANTENNA_SELECT_CCK {
+ u8 r_cckrx_enable_2:2;
+ u8 r_cckrx_enable:2;
+ u8 r_ccktx_enable:4;
+};
+
+void r8712_SwitchAntenna(struct _adapter *pAdapter)
+{
+ u32 ofdm_tx_en_val = 0, ofdm_tx_ant_sel_val = 0;
+ u8 ofdm_rx_ant_sel_val = 0;
+ u8 cck_ant_select_val = 0;
+ u32 cck_ant_sel_val = 0;
+ struct R_ANTENNA_SELECT_CCK *p_cck_txrx;
+
+ p_cck_txrx = (struct R_ANTENNA_SELECT_CCK *)&cck_ant_select_val;
+
+ switch (pAdapter->mppriv.antenna_tx) {
+ case ANTENNA_A:
+ /* From SD3 Willis suggestion !!! Set RF A=TX and B as standby*/
+ set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2);
+ set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 1);
+ ofdm_tx_en_val = 0x3;
+ ofdm_tx_ant_sel_val = 0x11111111;/* Power save */
+ p_cck_txrx->r_ccktx_enable = 0x8;
+ break;
+ case ANTENNA_B:
+ set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 1);
+ set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2);
+ ofdm_tx_en_val = 0x3;
+ ofdm_tx_ant_sel_val = 0x22222222;/* Power save */
+ p_cck_txrx->r_ccktx_enable = 0x4;
+ break;
+ case ANTENNA_AB: /* For 8192S */
+ set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2);
+ set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2);
+ ofdm_tx_en_val = 0x3;
+ ofdm_tx_ant_sel_val = 0x3321333; /* Disable Power save */
+ p_cck_txrx->r_ccktx_enable = 0xC;
+ break;
+ default:
+ break;
+ }
+ /*OFDM Tx*/
+ set_bb_reg(pAdapter, rFPGA1_TxInfo, 0xffffffff, ofdm_tx_ant_sel_val);
+ /*OFDM Tx*/
+ set_bb_reg(pAdapter, rFPGA0_TxInfo, 0x0000000f, ofdm_tx_en_val);
+ switch (pAdapter->mppriv.antenna_rx) {
+ case ANTENNA_A:
+ ofdm_rx_ant_sel_val = 0x1; /* A */
+ p_cck_txrx->r_cckrx_enable = 0x0; /* default: A */
+ p_cck_txrx->r_cckrx_enable_2 = 0x0; /* option: A */
+ break;
+ case ANTENNA_B:
+ ofdm_rx_ant_sel_val = 0x2; /* B */
+ p_cck_txrx->r_cckrx_enable = 0x1; /* default: B */
+ p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option: B */
+ break;
+ case ANTENNA_AB:
+ ofdm_rx_ant_sel_val = 0x3; /* AB */
+ p_cck_txrx->r_cckrx_enable = 0x0; /* default:A */
+ p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option:B */
+ break;
+ default:
+ break;
+ }
+ /*OFDM Rx*/
+ set_bb_reg(pAdapter, rOFDM0_TRxPathEnable, 0x0000000f,
+ ofdm_rx_ant_sel_val);
+ /*OFDM Rx*/
+ set_bb_reg(pAdapter, rOFDM1_TRxPathEnable, 0x0000000f,
+ ofdm_rx_ant_sel_val);
+
+ cck_ant_sel_val = cck_ant_select_val;
+ /*CCK TxRx*/
+ set_bb_reg(pAdapter, rCCK0_AFESetting, bMaskByte3, cck_ant_sel_val);
+}
+
+void r8712_SetCrystalCap(struct _adapter *pAdapter)
+{
+ set_bb_reg(pAdapter, rFPGA0_AnalogParameter1, bXtalCap,
+ pAdapter->mppriv.curr_crystalcap);
+}
+
+static void TriggerRFThermalMeter(struct _adapter *pAdapter)
+{
+ /* 0x24: RF Reg[6:5] */
+ set_rf_reg(pAdapter, RF_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60);
+}
+
+static u32 ReadRFThermalMeter(struct _adapter *pAdapter)
+{
+ u32 ThermalValue = 0;
+
+ /* 0x24: RF Reg[4:0] */
+ ThermalValue = get_rf_reg(pAdapter, RF_PATH_A, RF_T_METER, 0x1F);
+ return ThermalValue;
+}
+
+void r8712_GetThermalMeter(struct _adapter *pAdapter, u32 *value)
+{
+ TriggerRFThermalMeter(pAdapter);
+ msleep(1000);
+ *value = ReadRFThermalMeter(pAdapter);
+}
+
+void r8712_SetSingleCarrierTx(struct _adapter *pAdapter, u8 bStart)
+{
+ if (bStart) { /* Start Single Carrier. */
+ /* 1. if OFDM block on? */
+ if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn))
+ /*set OFDM block on*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
+ /* 2. set CCK test mode off, set to CCK normal mode */
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
+ /* 3. turn on scramble setting */
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
+ /* 4. Turn On Single Carrier Tx and off the other test modes. */
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bEnable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
+ } else { /* Stop Single Carrier.*/
+ /* Turn off all test modes.*/
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
+ bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
+ msleep(20);
+ /*BB Reset*/
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
+ }
+}
+
+void r8712_SetSingleToneTx(struct _adapter *pAdapter, u8 bStart)
+{
+ u8 rfPath = pAdapter->mppriv.curr_rfpath;
+ switch (pAdapter->mppriv.antenna_tx) {
+ case ANTENNA_B:
+ rfPath = RF_PATH_B;
+ break;
+ case ANTENNA_A:
+ default:
+ rfPath = RF_PATH_A;
+ break;
+ }
+ if (bStart) { /* Start Single Tone.*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bDisable);
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bDisable);
+ set_rf_reg(pAdapter, rfPath, RF_TX_G2, bRFRegOffsetMask,
+ 0xd4000);
+ msleep(100);
+ /* PAD all on.*/
+ set_rf_reg(pAdapter, rfPath, RF_AC, bRFRegOffsetMask, 0x2001f);
+ msleep(100);
+ } else { /* Stop Single Tone.*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
+ set_rf_reg(pAdapter, rfPath, RF_TX_G2, bRFRegOffsetMask,
+ 0x54000);
+ msleep(100);
+ /* PAD all on.*/
+ set_rf_reg(pAdapter, rfPath, RF_AC, bRFRegOffsetMask, 0x30000);
+ msleep(100);
+ }
+}
+
+void r8712_SetCarrierSuppressionTx(struct _adapter *pAdapter, u8 bStart)
+{
+ if (bStart) { /* Start Carrier Suppression.*/
+ if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M) {
+ /* 1. if CCK block on? */
+ if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn)) {
+ /*set CCK block on*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn,
+ bEnable);
+ }
+ /* Turn Off All Test Mode */
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx,
+ bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
+ bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone,
+ bDisable);
+ /*transmit mode*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x2);
+ /*turn off scramble setting*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble,
+ bDisable);
+ /*Set CCK Tx Test Rate*/
+ /*Set FTxRate to 1Mbps*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKTxRate, 0x0);
+ }
+ } else { /* Stop Carrier Suppression. */
+ if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M) {
+ /*normal mode*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x0);
+ /*turn on scramble setting*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble,
+ bEnable);
+ /*BB Reset*/
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
+ }
+ }
+}
+
+static void SetCCKContinuousTx(struct _adapter *pAdapter, u8 bStart)
+{
+ u32 cckrate;
+
+ if (bStart) {
+ /* 1. if CCK block on? */
+ if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn)) {
+ /*set CCK block on*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);
+ }
+ /* Turn Off All Test Mode */
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
+ /*Set CCK Tx Test Rate*/
+ cckrate = pAdapter->mppriv.curr_rateidx;
+ set_bb_reg(pAdapter, rCCK0_System, bCCKTxRate, cckrate);
+ /*transmit mode*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x2);
+ /*turn on scramble setting*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
+ } else {
+ /*normal mode*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x0);
+ /*turn on scramble setting*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
+ /*BB Reset*/
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
+ }
+} /* mpt_StartCckContTx */
+
+static void SetOFDMContinuousTx(struct _adapter *pAdapter, u8 bStart)
+{
+ if (bStart) {
+ /* 1. if OFDM block on? */
+ if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) {
+ /*set OFDM block on*/
+ set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
+ }
+ /* 2. set CCK test mode off, set to CCK normal mode*/
+ set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
+ /* 3. turn on scramble setting */
+ set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
+ /* 4. Turn On Continue Tx and turn off the other test modes.*/
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bEnable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
+ } else {
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
+ bDisable);
+ set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
+ msleep(20);
+ /*BB Reset*/
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
+ set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
+ }
+} /* mpt_StartOfdmContTx */
+
+void r8712_SetContinuousTx(struct _adapter *pAdapter, u8 bStart)
+{
+ /* ADC turn off [bit24-21] adc port0 ~ port1 */
+ if (bStart) {
+ r8712_bb_reg_write(pAdapter, rRx_Wait_CCCA,
+ r8712_bb_reg_read(pAdapter,
+ rRx_Wait_CCCA) & 0xFE1FFFFF);
+ msleep(100);
+ }
+ if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M)
+ SetCCKContinuousTx(pAdapter, bStart);
+ else if ((pAdapter->mppriv.curr_rateidx >= MPT_RATE_6M) &&
+ (pAdapter->mppriv.curr_rateidx <= MPT_RATE_MCS15))
+ SetOFDMContinuousTx(pAdapter, bStart);
+ /* ADC turn on [bit24-21] adc port0 ~ port1 */
+ if (!bStart)
+ r8712_bb_reg_write(pAdapter, rRx_Wait_CCCA,
+ r8712_bb_reg_read(pAdapter,
+ rRx_Wait_CCCA) | 0x01E00000);
+}
+
+void r8712_ResetPhyRxPktCount(struct _adapter *pAdapter)
+{
+ u32 i, phyrx_set = 0;
+
+ for (i = OFDM_PPDU_BIT; i <= HT_MPDU_FAIL_BIT; i++) {
+ phyrx_set = 0;
+ phyrx_set |= (i << 28); /*select*/
+ phyrx_set |= 0x08000000; /* set counter to zero*/
+ r8712_write32(pAdapter, RXERR_RPT, phyrx_set);
+ }
+}
+
+static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit)
+{
+ /*selection*/
+ u32 phyrx_set = 0, count = 0;
+ u32 SelectBit;
+
+ SelectBit = selbit << 28;
+ phyrx_set |= (SelectBit & 0xF0000000);
+ r8712_write32(pAdapter, RXERR_RPT, phyrx_set);
+ /*Read packet count*/
+ count = r8712_read32(pAdapter, RXERR_RPT) & RPTMaxCount;
+ return count;
+}
+
+u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
+{
+ u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+
+ OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
+ CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
+ HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT);
+ return OFDM_cnt + CCK_cnt + HT_cnt;
+}
+
+u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
+{
+ u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+
+ OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
+ CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
+ HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT);
+ return OFDM_cnt + CCK_cnt + HT_cnt;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_mp.h b/drivers/staging/rtl8712/rtl871x_mp.h
new file mode 100644
index 000000000000..805aba07159e
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mp.h
@@ -0,0 +1,318 @@
+#ifndef __RTL871X_MP_H_
+#define __RTL871X_MP_H_
+
+/* 00 - Success */
+/* 11 - Error */
+#define STATUS_SUCCESS (0x00000000L)
+#define STATUS_PENDING (0x00000103L)
+#define STATUS_UNSUCCESSFUL (0xC0000001L)
+#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
+#define STATUS_NOT_SUPPORTED (0xC00000BBL)
+#define NDIS_STATUS_SUCCESS ((uint)STATUS_SUCCESS)
+#define NDIS_STATUS_PENDING ((uint) STATUS_PENDING)
+#define NDIS_STATUS_NOT_RECOGNIZED ((uint)0x00010001L)
+#define NDIS_STATUS_NOT_COPIED ((uint)0x00010002L)
+#define NDIS_STATUS_NOT_ACCEPTED ((uint)0x00010003L)
+#define NDIS_STATUS_CALL_ACTIVE ((uint)0x00010007L)
+#define NDIS_STATUS_FAILURE ((uint) STATUS_UNSUCCESSFUL)
+#define NDIS_STATUS_RESOURCES ((uint)\
+ STATUS_INSUFFICIENT_RESOURCES)
+#define NDIS_STATUS_CLOSING ((uint)0xC0010002L)
+#define NDIS_STATUS_BAD_VERSION ((uint)0xC0010004L)
+#define NDIS_STATUS_BAD_CHARACTERISTICS ((uint)0xC0010005L)
+#define NDIS_STATUS_ADAPTER_NOT_FOUND ((uint)0xC0010006L)
+#define NDIS_STATUS_OPEN_FAILED ((uint)0xC0010007L)
+#define NDIS_STATUS_DEVICE_FAILED ((uint)0xC0010008L)
+#define NDIS_STATUS_MULTICAST_FULL ((uint)0xC0010009L)
+#define NDIS_STATUS_MULTICAST_EXISTS ((uint)0xC001000AL)
+#define NDIS_STATUS_MULTICAST_NOT_FOUND ((uint)0xC001000BL)
+#define NDIS_STATUS_REQUEST_ABORTED ((uint)0xC001000CL)
+#define NDIS_STATUS_RESET_IN_PROGRESS ((uint)0xC001000DL)
+#define NDIS_STATUS_CLOSING_INDICATING ((uint)0xC001000EL)
+#define NDIS_STATUS_NOT_SUPPORTED ((uint)STATUS_NOT_SUPPORTED)
+#define NDIS_STATUS_INVALID_PACKET ((uint)0xC001000FL)
+#define NDIS_STATUS_OPEN_LIST_FULL ((uint)0xC0010010L)
+#define NDIS_STATUS_ADAPTER_NOT_READY ((uint)0xC0010011L)
+#define NDIS_STATUS_ADAPTER_NOT_OPEN ((uint)0xC0010012L)
+#define NDIS_STATUS_NOT_INDICATING ((uint)0xC0010013L)
+#define NDIS_STATUS_INVALID_LENGTH ((uint)0xC0010014L)
+#define NDIS_STATUS_INVALID_DATA ((uint)0xC0010015L)
+#define NDIS_STATUS_BUFFER_TOO_SHORT ((uint)0xC0010016L)
+#define NDIS_STATUS_INVALID_OID ((uint)0xC0010017L)
+#define NDIS_STATUS_ADAPTER_REMOVED ((uint)0xC0010018L)
+#define NDIS_STATUS_UNSUPPORTED_MEDIA ((uint)0xC0010019L)
+#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((uint)0xC001001AL)
+#define NDIS_STATUS_FILE_NOT_FOUND ((uint)0xC001001BL)
+#define NDIS_STATUS_ERROR_READING_FILE ((uint)0xC001001CL)
+#define NDIS_STATUS_ALREADY_MAPPED ((uint)0xC001001DL)
+#define NDIS_STATUS_RESOURCE_CONFLICT ((uint)0xC001001EL)
+#define NDIS_STATUS_NO_CABLE ((uint)0xC001001FL)
+#define NDIS_STATUS_INVALID_SAP ((uint)0xC0010020L)
+#define NDIS_STATUS_SAP_IN_USE ((uint)0xC0010021L)
+#define NDIS_STATUS_INVALID_ADDRESS ((uint)0xC0010022L)
+#define NDIS_STATUS_VC_NOT_ACTIVATED ((uint)0xC0010023L)
+#define NDIS_STATUS_DEST_OUT_OF_ORDER ((uint)0xC0010024L) /* cause 27*/
+#define NDIS_STATUS_VC_NOT_AVAILABLE ((uint)0xC0010025L) /* 35,45*/
+#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((uint)0xC0010026L) /* 37*/
+#define NDIS_STATUS_INCOMPATABLE_QOS ((uint)0xC0010027L) /* 49*/
+#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((uint)0xC0010028L) /* 93*/
+#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((uint)0xC0010029L) /* 3*/
+#define MPT_NOOP 0
+#define MPT_READ_MAC_1BYTE 1
+#define MPT_READ_MAC_2BYTE 2
+#define MPT_READ_MAC_4BYTE 3
+#define MPT_WRITE_MAC_1BYTE 4
+#define MPT_WRITE_MAC_2BYTE 5
+#define MPT_WRITE_MAC_4BYTE 6
+#define MPT_READ_BB_CCK 7
+#define MPT_WRITE_BB_CCK 8
+#define MPT_READ_BB_OFDM 9
+#define MPT_WRITE_BB_OFDM 10
+#define MPT_READ_RF 11
+#define MPT_WRITE_RF 12
+#define MPT_READ_EEPROM_1BYTE 13
+#define MPT_WRITE_EEPROM_1BYTE 14
+#define MPT_READ_EEPROM_2BYTE 15
+#define MPT_WRITE_EEPROM_2BYTE 16
+#define MPT_SET_CSTHRESHOLD 21
+#define MPT_SET_INITGAIN 22
+#define MPT_SWITCH_BAND 23
+#define MPT_SWITCH_CHANNEL 24
+#define MPT_SET_DATARATE 25
+#define MPT_SWITCH_ANTENNA 26
+#define MPT_SET_TX_POWER 27
+#define MPT_SET_CONT_TX 28
+#define MPT_SET_SINGLE_CARRIER 29
+#define MPT_SET_CARRIER_SUPPRESSION 30
+#define MPT_GET_RATE_TABLE 31
+#define MPT_READ_TSSI 32
+#define MPT_GET_THERMAL_METER 33
+#define MAX_MP_XMITBUF_SZ 2048
+#define NR_MP_XMITFRAME 8
+
+struct mp_xmit_frame {
+ struct list_head list;
+ struct pkt_attrib attrib;
+ _pkt *pkt;
+ int frame_tag;
+ struct _adapter *padapter;
+ u8 *mem_addr;
+ u16 sz[8];
+ struct urb *pxmit_urb[8];
+ u8 bpending[8];
+ u8 last[8];
+ uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
+};
+
+struct mp_wiparam {
+ u32 bcompleted;
+ u32 act_type;
+ u32 io_offset;
+ u32 io_value;
+};
+
+struct mp_priv {
+ struct _adapter *papdater;
+ /*OID cmd handler*/
+ struct mp_wiparam workparam;
+ u8 act_in_progress;
+ /*Tx Section*/
+ u8 TID;
+ u32 tx_pktcount;
+ /*Rx Section*/
+ u32 rx_pktcount;
+ u32 rx_crcerrpktcount;
+ u32 rx_pktloss;
+ struct recv_stat rxstat;
+ /*RF/BB relative*/
+ u32 curr_ch;
+ u32 curr_rateidx;
+ u8 curr_bandwidth;
+ u8 curr_modem;
+ u8 curr_txpoweridx;
+ u32 curr_crystalcap;
+ u16 antenna_tx;
+ u16 antenna_rx;
+ u8 curr_rfpath;
+ u8 check_mp_pkt;
+ uint ForcedDataRate;
+ struct wlan_network mp_network;
+ unsigned char network_macaddr[6];
+ /*Testing Flag*/
+ u32 mode;/*0 for normal type packet,
+ * 1 for loopback packet (16bytes TXCMD)*/
+ sint prev_fw_state;
+ u8 *pallocated_mp_xmitframe_buf;
+ u8 *pmp_xmtframe_buf;
+ struct __queue free_mp_xmitqueue;
+ u32 free_mp_xmitframe_cnt;
+};
+
+struct IOCMD_STRUCT {
+ u8 cmdclass;
+ u16 value;
+ u8 index;
+};
+
+struct rf_reg_param {
+ u32 path;
+ u32 offset;
+ u32 value;
+};
+
+struct bb_reg_param {
+ u32 offset;
+ u32 value;
+};
+/* ======================================================================= */
+
+#define LOWER true
+#define RAISE false
+#define IOCMD_CTRL_REG 0x10250370
+#define IOCMD_DATA_REG 0x10250374
+#define IOCMD_GET_THERMAL_METER 0xFD000028
+#define IOCMD_CLASS_BB_RF 0xF0
+#define IOCMD_BB_READ_IDX 0x00
+#define IOCMD_BB_WRITE_IDX 0x01
+#define IOCMD_RF_READ_IDX 0x02
+#define IOCMD_RF_WRIT_IDX 0x03
+#define BB_REG_BASE_ADDR 0x800
+#define RF_PATH_A 0
+#define RF_PATH_B 1
+#define RF_PATH_C 2
+#define RF_PATH_D 3
+#define MAX_RF_PATH_NUMS 2
+#define _2MAC_MODE_ 0
+#define _LOOPBOOK_MODE_ 1
+
+/* MP set force data rate base on the definition. */
+enum {
+ /* CCK rate. */
+ MPT_RATE_1M, /* 0 */
+ MPT_RATE_2M,
+ MPT_RATE_55M,
+ MPT_RATE_11M, /* 3 */
+
+ /* OFDM rate. */
+ MPT_RATE_6M, /* 4 */
+ MPT_RATE_9M,
+ MPT_RATE_12M,
+ MPT_RATE_18M,
+ MPT_RATE_24M,
+ MPT_RATE_36M,
+ MPT_RATE_48M,
+ MPT_RATE_54M, /* 11 */
+
+ /* HT rate. */
+ MPT_RATE_MCS0, /* 12 */
+ MPT_RATE_MCS1,
+ MPT_RATE_MCS2,
+ MPT_RATE_MCS3,
+ MPT_RATE_MCS4,
+ MPT_RATE_MCS5,
+ MPT_RATE_MCS6,
+ MPT_RATE_MCS7, /* 19 */
+ MPT_RATE_MCS8,
+ MPT_RATE_MCS9,
+ MPT_RATE_MCS10,
+ MPT_RATE_MCS11,
+ MPT_RATE_MCS12,
+ MPT_RATE_MCS13,
+ MPT_RATE_MCS14,
+ MPT_RATE_MCS15, /* 27 */
+ MPT_RATE_LAST
+};
+
+/* Represent Channel Width in HT Capabilities */
+enum HT_CHANNEL_WIDTH {
+ HT_CHANNEL_WIDTH_20 = 0,
+ HT_CHANNEL_WIDTH_40 = 1,
+};
+
+#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
+
+enum POWER_MODE {
+ POWER_LOW = 0,
+ POWER_NORMAL
+};
+
+#define RX_PKT_BROADCAST 1
+#define RX_PKT_DEST_ADDR 2
+#define RX_PKT_PHY_MATCH 3
+
+#define RPTMaxCount 0x000FFFFF;
+
+/* parameter 1 : BitMask
+ * bit 0 : OFDM PPDU
+ * bit 1 : OFDM False Alarm
+ * bit 2 : OFDM MPDU OK
+ * bit 3 : OFDM MPDU Fail
+ * bit 4 : CCK PPDU
+ * bit 5 : CCK False Alarm
+ * bit 6 : CCK MPDU ok
+ * bit 7 : CCK MPDU fail
+ * bit 8 : HT PPDU counter
+ * bit 9 : HT false alarm
+ * bit 10 : HT MPDU total
+ * bit 11 : HT MPDU OK
+ * bit 12 : HT MPDU fail
+ * bit 15 : RX full drop
+ */
+enum RXPHY_BITMASK {
+ OFDM_PPDU_BIT = 0,
+ OFDM_MPDU_OK_BIT,
+ OFDM_MPDU_FAIL_BIT,
+ CCK_PPDU_BIT,
+ CCK_MPDU_OK_BIT,
+ CCK_MPDU_FAIL_BIT,
+ HT_PPDU_BIT,
+ HT_MPDU_BIT,
+ HT_MPDU_OK_BIT,
+ HT_MPDU_FAIL_BIT,
+};
+
+enum ENCRY_CTRL_STATE {
+ HW_CONTROL, /*hw encryption& decryption*/
+ SW_CONTROL, /*sw encryption& decryption*/
+ HW_ENCRY_SW_DECRY, /*hw encryption & sw decryption*/
+ SW_ENCRY_HW_DECRY /*sw encryption & hw decryption*/
+};
+
+/* Bandwidth Offset */
+#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
+#define HAL_PRIME_CHNL_OFFSET_LOWER 1
+#define HAL_PRIME_CHNL_OFFSET_UPPER 2
+/*=======================================================================*/
+void mp871xinit(struct _adapter *padapter);
+void mp871xdeinit(struct _adapter *padapter);
+u32 r8712_bb_reg_read(struct _adapter *Adapter, u16 offset);
+u8 r8712_bb_reg_write(struct _adapter *Adapter, u16 offset, u32 value);
+u32 r8712_rf_reg_read(struct _adapter *Adapter, u8 path, u8 offset);
+u8 r8712_rf_reg_write(struct _adapter *Adapter, u8 path,
+ u8 offset, u32 value);
+u32 r8712_get_bb_reg(struct _adapter *Adapter, u16 offset, u32 bitmask);
+u8 r8712_set_bb_reg(struct _adapter *Adapter, u16 offset,
+ u32 bitmask, u32 value);
+u32 r8712_get_rf_reg(struct _adapter *Adapter, u8 path, u8 offset,
+ u32 bitmask);
+u8 r8712_set_rf_reg(struct _adapter *Adapter, u8 path, u8 offset,
+ u32 bitmask, u32 value);
+
+void r8712_SetChannel(struct _adapter *pAdapter);
+void r8712_SetTxPower(struct _adapter *pAdapte);
+void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset);
+void r8712_SetDataRate(struct _adapter *pAdapter);
+void r8712_SwitchBandwidth(struct _adapter *pAdapter);
+void r8712_SwitchAntenna(struct _adapter *pAdapter);
+void r8712_SetCrystalCap(struct _adapter *pAdapter);
+void r8712_GetThermalMeter(struct _adapter *pAdapter, u32 *value);
+void r8712_SetContinuousTx(struct _adapter *pAdapter, u8 bStart);
+void r8712_SetSingleCarrierTx(struct _adapter *pAdapter, u8 bStart);
+void r8712_SetSingleToneTx(struct _adapter *pAdapter, u8 bStart);
+void r8712_SetCarrierSuppressionTx(struct _adapter *pAdapter, u8 bStart);
+void r8712_ResetPhyRxPktCount(struct _adapter *pAdapter);
+u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter);
+u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter);
+
+#endif /*__RTL871X_MP_H_*/
+
diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
new file mode 100644
index 000000000000..d60aaa9c4872
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c
@@ -0,0 +1,1475 @@
+/******************************************************************************
+ * rtl871x_mp_ioctl.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_MP_IOCTL_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "mlme_osdep.h"
+#include "rtl871x_mp.h"
+#include "rtl871x_mp_ioctl.h"
+
+uint oid_null_function(struct oid_par_priv *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid == SET_OID) {
+ if (poid_par_priv->information_buf_len >= sizeof(u8))
+ Adapter->registrypriv.wireless_mode =
+ *(u8 *)poid_par_priv->information_buf;
+ else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ } else if (poid_par_priv->type_of_oid == QUERY_OID) {
+ if (poid_par_priv->information_buf_len >= sizeof(u8)) {
+ *(u8 *)poid_par_priv->information_buf =
+ Adapter->registrypriv.wireless_mode;
+ *poid_par_priv->bytes_rw =
+ poid_par_priv->information_buf_len;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ } else {
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ }
+ return status;
+}
+
+uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct bb_reg_param *pbbreg;
+ u16 offset;
+ u32 value;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
+ return NDIS_STATUS_INVALID_LENGTH;
+ pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
+ offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
+ if (offset < BB_REG_BASE_ADDR)
+ offset |= BB_REG_BASE_ADDR;
+ value = pbbreg->value;
+ r8712_bb_reg_write(Adapter, offset, value);
+ return status;
+}
+
+uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct bb_reg_param *pbbreg;
+ u16 offset;
+ u32 value;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
+ return NDIS_STATUS_INVALID_LENGTH;
+ pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
+ offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
+ if (offset < BB_REG_BASE_ADDR)
+ offset |= BB_REG_BASE_ADDR;
+ value = r8712_bb_reg_read(Adapter, offset);
+ pbbreg->value = value;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct rf_reg_param *pbbreg;
+ u8 path;
+ u8 offset;
+ u32 value;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
+ return NDIS_STATUS_INVALID_LENGTH;
+ pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
+ path = (u8)pbbreg->path;
+ if (path > RF_PATH_B)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ offset = (u8)pbbreg->offset;
+ value = pbbreg->value;
+ r8712_rf_reg_write(Adapter, path, offset, value);
+ return status;
+}
+
+uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct rf_reg_param *pbbreg;
+ u8 path;
+ u8 offset;
+ u32 value;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
+ return NDIS_STATUS_INVALID_LENGTH;
+ pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
+ path = (u8)pbbreg->path;
+ if (path > RF_PATH_B) /* 1T2R path_a /path_b */
+ return NDIS_STATUS_NOT_ACCEPTED;
+ offset = (u8)pbbreg->offset;
+ value = r8712_rf_reg_read(Adapter, path, offset);
+ pbbreg->value = value;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+/*This function initializes the DUT to the MP test mode*/
+static int mp_start_test(struct _adapter *padapter)
+{
+ struct mp_priv *pmppriv = &padapter->mppriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+ struct ndis_wlan_bssid_ex bssid;
+ struct sta_info *psta;
+ unsigned long length;
+ unsigned long irqL;
+ int res = _SUCCESS;
+
+ /* 3 1. initialize a new struct ndis_wlan_bssid_ex */
+ memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN);
+ bssid.Ssid.SsidLength = 16;
+ memcpy(bssid.Ssid.Ssid, (unsigned char *)"mp_pseudo_adhoc",
+ bssid.Ssid.SsidLength);
+ bssid.InfrastructureMode = Ndis802_11IBSS;
+ bssid.NetworkTypeInUse = Ndis802_11DS;
+ bssid.IELength = 0;
+ length = r8712_get_ndis_wlan_bssid_ex_sz(&bssid);
+ if (length % 4) {
+ /*round up to multiple of 4 bytes.*/
+ bssid.Length = ((length >> 2) + 1) << 2;
+ } else
+ bssid.Length = length;
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
+ goto end_of_mp_start_test;
+ /*init mp_start_test status*/
+ pmppriv->prev_fw_state = get_fwstate(pmlmepriv);
+ pmlmepriv->fw_state = WIFI_MP_STATE;
+ if (pmppriv->mode == _LOOPBOOK_MODE_)
+ set_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE); /*append txdesc*/
+ set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+ /* 3 2. create a new psta for mp driver */
+ /* clear psta in the cur_network, if any */
+ psta = r8712_get_stainfo(&padapter->stapriv,
+ tgt_network->network.MacAddress);
+ if (psta)
+ r8712_free_stainfo(padapter, psta);
+ psta = r8712_alloc_stainfo(&padapter->stapriv, bssid.MacAddress);
+ if (psta == NULL) {
+ res = _FAIL;
+ goto end_of_mp_start_test;
+ }
+ /* 3 3. join psudo AdHoc */
+ tgt_network->join_res = 1;
+ tgt_network->aid = psta->aid = 1;
+ memcpy(&tgt_network->network, &bssid, length);
+ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
+ r8712_os_indicate_connect(padapter);
+ /* Set to LINKED STATE for MP TRX Testing */
+ set_fwstate(pmlmepriv, _FW_LINKED);
+end_of_mp_start_test:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return res;
+}
+
+/*This function change the DUT from the MP test mode into normal mode */
+static int mp_stop_test(struct _adapter *padapter)
+{
+ struct mp_priv *pmppriv = &padapter->mppriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct wlan_network *tgt_network = &pmlmepriv->cur_network;
+ struct sta_info *psta;
+ unsigned long irqL;
+
+ spin_lock_irqsave(&pmlmepriv->lock, irqL);
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)
+ goto end_of_mp_stop_test;
+ /* 3 1. disconnect psudo AdHoc */
+ r8712_os_indicate_disconnect(padapter);
+ /* 3 2. clear psta used in mp test mode. */
+ psta = r8712_get_stainfo(&padapter->stapriv,
+ tgt_network->network.MacAddress);
+ if (psta)
+ r8712_free_stainfo(padapter, psta);
+ /* 3 3. return to normal state (default:station mode) */
+ pmlmepriv->fw_state = pmppriv->prev_fw_state; /* WIFI_STATION_STATE;*/
+ /*flush the cur_network*/
+ memset(tgt_network, 0, sizeof(struct wlan_network));
+end_of_mp_stop_test:
+ spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
+ return _SUCCESS;
+}
+
+int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid)
+{
+ struct mp_priv *pmppriv = &padapter->mppriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ unsigned char res = _SUCCESS;
+
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)
+ return _FAIL;
+ if (check_fwstate(pmlmepriv, _FW_LINKED) == false)
+ return _FAIL;
+ _clr_fwstate_(pmlmepriv, _FW_LINKED);
+ res = r8712_setassocsta_cmd(padapter, pmppriv->network_macaddr);
+ set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
+ return res;
+}
+
+uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 ratevalue;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ ratevalue = *((u32 *)poid_par_priv->information_buf);
+ if (ratevalue >= MPT_RATE_LAST)
+ return NDIS_STATUS_INVALID_DATA;
+ Adapter->mppriv.curr_rateidx = ratevalue;
+ r8712_SetDataRate(Adapter);
+ return status;
+}
+
+uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 mode;
+ u8 val8;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ mode = *((u32 *)poid_par_priv->information_buf);
+ Adapter->mppriv.mode = mode;/* 1 for loopback*/
+ if (mp_start_test(Adapter) == _FAIL)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */
+ r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */
+ /* RCR disable Check BSSID, 0x1025004a */
+ r8712_write8(Adapter, RCR+2, 0x57);
+ /* disable RX filter map , mgt frames will put in RX FIFO 0 */
+ r8712_write16(Adapter, RXFLTMAP0, 0x0);
+ val8 = r8712_read8(Adapter, EE_9346CR);
+ if (!(val8 & _9356SEL)) { /*boot from EFUSE*/
+ r8712_efuse_reg_init(Adapter);
+ r8712_efuse_change_max_size(Adapter);
+ r8712_efuse_reg_uninit(Adapter);
+ }
+ return status;
+}
+
+uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (mp_stop_test(Adapter) == _FAIL)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+
+uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 Channel;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ Channel = *((u32 *)poid_par_priv->information_buf);
+ if (Channel > 14)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ Adapter->mppriv.curr_ch = Channel;
+ r8712_SetChannel(Adapter);
+ return status;
+}
+
+uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 antenna;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ antenna = *((u32 *)poid_par_priv->information_buf);
+ Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16);
+ Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF);
+ r8712_SwitchAntenna(Adapter);
+ return status;
+}
+
+uint oid_rt_pro_set_tx_power_control_hdl(
+ struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 tx_pwr_idx;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ tx_pwr_idx = *((u32 *)poid_par_priv->information_buf);
+ if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ Adapter->mppriv.curr_txpoweridx = (u8)tx_pwr_idx;
+ r8712_SetTxPower(Adapter);
+ return status;
+}
+
+uint oid_rt_pro_query_tx_packet_sent_hdl(
+ struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID) {
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+ }
+ if (poid_par_priv->information_buf_len == sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ Adapter->mppriv.tx_pktcount;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+uint oid_rt_pro_query_rx_packet_received_hdl(
+ struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID) {
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+ }
+ if (poid_par_priv->information_buf_len == sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ Adapter->mppriv.rx_pktcount;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
+ struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID) {
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+ }
+ if (poid_par_priv->information_buf_len == sizeof(u32)) {
+ *(u32 *)poid_par_priv->information_buf =
+ Adapter->mppriv.rx_crcerrpktcount;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ Adapter->mppriv.tx_pktcount = 0;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len == sizeof(u32)) {
+ Adapter->mppriv.rx_pktcount = 0;
+ Adapter->mppriv.rx_crcerrpktcount = 0;
+ } else
+ status = NDIS_STATUS_INVALID_LENGTH;
+ return status;
+}
+
+uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ r8712_ResetPhyRxPktCount(Adapter);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ *(u32 *)poid_par_priv->information_buf =
+ r8712_GetPhyRxPktReceived(Adapter);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len != sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ *(u32 *)poid_par_priv->information_buf =
+ r8712_GetPhyRxPktCRC32Error(Adapter);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ Adapter->mppriv.curr_modem = *((u8 *)poid_par_priv->information_buf);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 bStartTest;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ bStartTest = *((u32 *)poid_par_priv->information_buf);
+ r8712_SetContinuousTx(Adapter, (u8)bStartTest);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 bStartTest;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ bStartTest = *((u32 *)poid_par_priv->information_buf);
+ r8712_SetSingleCarrierTx(Adapter, (u8)bStartTest);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 bStartTest;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ bStartTest = *((u32 *)poid_par_priv->information_buf);
+ r8712_SetCarrierSuppressionTx(Adapter, (u8)bStartTest);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 bStartTest;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ bStartTest = *((u32 *)poid_par_priv->information_buf);
+ r8712_SetSingleToneTx(Adapter, (u8)bStartTest);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct ndis_802_11_ssid *pssid;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_needed = (u32)sizeof(struct ndis_802_11_ssid);
+ *poid_par_priv->bytes_rw = 0;
+ if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
+ return NDIS_STATUS_INVALID_LENGTH;
+ pssid = (struct ndis_802_11_ssid *)poid_par_priv->information_buf;
+ if (mp_start_joinbss(Adapter, pssid) == _FAIL)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_rw = sizeof(struct ndis_802_11_ssid);
+ return status;
+}
+
+uint oid_rt_pro_read_register_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct mp_rw_reg *RegRWStruct;
+ u16 offset;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
+ if ((RegRWStruct->offset >= 0x10250800) &&
+ (RegRWStruct->offset <= 0x10250FFF)) {
+ /*baseband register*/
+ /*0ffset :0x800~0xfff*/
+ offset = (u16)(RegRWStruct->offset) & 0xFFF;
+ RegRWStruct->value = r8712_bb_reg_read(Adapter, offset);
+ } else {
+ switch (RegRWStruct->width) {
+ case 1:
+ RegRWStruct->value = r8712_read8(Adapter,
+ RegRWStruct->offset);
+ break;
+ case 2:
+ RegRWStruct->value = r8712_read16(Adapter,
+ RegRWStruct->offset);
+ break;
+ case 4:
+ RegRWStruct->value = r8712_read32(Adapter,
+ RegRWStruct->offset);
+ break;
+ default:
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ break;
+ }
+ }
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct mp_rw_reg *RegRWStruct;
+ u16 offset;
+ u32 value;
+ u32 oldValue = 0;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
+ if ((RegRWStruct->offset >= 0x10250800) &&
+ (RegRWStruct->offset <= 0x10250FFF)) {
+ /*baseband register*/
+ offset = (u16)(RegRWStruct->offset) & 0xFFF;
+ value = RegRWStruct->value;
+ switch (RegRWStruct->width) {
+ case 1:
+ oldValue = r8712_bb_reg_read(Adapter, offset);
+ oldValue &= 0xFFFFFF00;
+ value &= 0x000000FF;
+ value |= oldValue;
+ break;
+ case 2:
+ oldValue = r8712_bb_reg_read(Adapter, offset);
+ oldValue &= 0xFFFF0000;
+ value &= 0x0000FFFF;
+ value |= oldValue;
+ break;
+ }
+ r8712_bb_reg_write(Adapter, offset, value);
+ } else {
+ switch (RegRWStruct->width) {
+ case 1:
+ r8712_write8(Adapter, RegRWStruct->offset,
+ (unsigned char)RegRWStruct->value);
+ break;
+ case 2:
+ r8712_write16(Adapter, RegRWStruct->offset,
+ (unsigned short)RegRWStruct->value);
+ break;
+ case 4:
+ r8712_write32(Adapter, RegRWStruct->offset,
+ (unsigned int)RegRWStruct->value);
+ break;
+ default:
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ break;
+ }
+
+ if ((status == NDIS_STATUS_SUCCESS) &&
+ (RegRWStruct->offset == HIMR) &&
+ (RegRWStruct->width == 4))
+ Adapter->ImrContent = RegRWStruct->value;
+ }
+ return status;
+}
+
+uint oid_rt_pro_burst_read_register_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct burst_rw_reg *pBstRwReg;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf;
+ r8712_read_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len,
+ pBstRwReg->Data);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct burst_rw_reg *pBstRwReg;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf;
+ r8712_write_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len,
+ pBstRwReg->Data);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct eeprom_rw_param *pEEPROM;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf;
+ pEEPROM->value = r8712_eeprom_read16(Adapter,
+ (u16)(pEEPROM->offset >> 1));
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct eeprom_rw_param *pEEPROM;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf;
+ r8712_eeprom_write16(Adapter, (u16)(pEEPROM->offset >> 1),
+ pEEPROM->value);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct mp_wiparam *pwi_param;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(struct mp_wiparam))
+ return NDIS_STATUS_INVALID_LENGTH;
+ if (Adapter->mppriv.workparam.bcompleted == false)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ pwi_param = (struct mp_wiparam *)poid_par_priv->information_buf;
+ memcpy(pwi_param, &Adapter->mppriv.workparam,
+ sizeof(struct mp_wiparam));
+ Adapter->mppriv.act_in_progress = false;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(uint) * 2)
+ return NDIS_STATUS_INVALID_LENGTH;
+ if (*(uint *)poid_par_priv->information_buf == 1)
+ Adapter->mppriv.rx_pktloss = 0;
+ *((uint *)poid_par_priv->information_buf+1) =
+ Adapter->mppriv.rx_pktloss;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (r8712_setrfintfs_cmd(Adapter, *(unsigned char *)
+ poid_par_priv->information_buf) == _FAIL)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+
+uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ memcpy(poid_par_priv->information_buf,
+ (unsigned char *)&Adapter->mppriv.rxstat,
+ sizeof(struct recv_stat));
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+uint oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (r8712_setdatarate_cmd(Adapter,
+ poid_par_priv->information_buf) != _SUCCESS)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+
+uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ if (Adapter->mppriv.act_in_progress == true)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ if (poid_par_priv->information_buf_len < sizeof(u8))
+ return NDIS_STATUS_INVALID_LENGTH;
+ /*init workparam*/
+ Adapter->mppriv.act_in_progress = true;
+ Adapter->mppriv.workparam.bcompleted = false;
+ Adapter->mppriv.workparam.act_type = MPT_GET_THERMAL_METER;
+ Adapter->mppriv.workparam.io_offset = 0;
+ Adapter->mppriv.workparam.io_value = 0xFFFFFFFF;
+ r8712_GetThermalMeter(Adapter, &Adapter->mppriv.workparam.io_value);
+ Adapter->mppriv.workparam.bcompleted = true;
+ Adapter->mppriv.act_in_progress = false;
+ *(u32 *)poid_par_priv->information_buf =
+ Adapter->mppriv.workparam.io_value;
+ *poid_par_priv->bytes_rw = sizeof(u32);
+ return status;
+}
+
+uint oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u8))
+ return NDIS_STATUS_INVALID_LENGTH;
+ if (!r8712_setptm_cmd(Adapter, *((u8 *)poid_par_priv->information_buf)))
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+
+uint oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 ratevalue;
+ u8 datarates[NumRates];
+ int i;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ ratevalue = *((u32 *)poid_par_priv->information_buf);
+ for (i = 0; i < NumRates; i++) {
+ if (ratevalue == mpdatarate[i])
+ datarates[i] = mpdatarate[i];
+ else
+ datarates[i] = 0xff;
+ }
+ if (r8712_setbasicrate_cmd(Adapter, datarates) != _SUCCESS)
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+
+uint oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < 8)
+ return NDIS_STATUS_INVALID_LENGTH;
+ *poid_par_priv->bytes_rw = 8;
+ memcpy(poid_par_priv->information_buf,
+ &(Adapter->pwrctrlpriv.pwr_mode), 8);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint pwr_mode, smart_ps;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_rw = 0;
+ *poid_par_priv->bytes_needed = 8;
+ if (poid_par_priv->information_buf_len < 8)
+ return NDIS_STATUS_INVALID_LENGTH;
+ pwr_mode = *(uint *)(poid_par_priv->information_buf);
+ smart_ps = *(uint *)((addr_t)poid_par_priv->information_buf + 4);
+ if (pwr_mode != Adapter->pwrctrlpriv.pwr_mode || smart_ps !=
+ Adapter->pwrctrlpriv.smart_ps)
+ r8712_set_ps_mode(Adapter, pwr_mode, smart_ps);
+ *poid_par_priv->bytes_rw = 8;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct setratable_parm *prate_table;
+ u8 res;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_needed = sizeof(struct setratable_parm);
+ if (poid_par_priv->information_buf_len <
+ sizeof(struct setratable_parm))
+ return NDIS_STATUS_INVALID_LENGTH;
+ prate_table = (struct setratable_parm *)poid_par_priv->information_buf;
+ res = r8712_setrttbl_cmd(Adapter, prate_table);
+ if (res == _FAIL)
+ status = NDIS_STATUS_FAILURE;
+ return status;
+}
+
+uint oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ struct security_priv *psecuritypriv = &Adapter->securitypriv;
+ enum ENCRY_CTRL_STATE encry_mode = 0;
+
+ *poid_par_priv->bytes_needed = sizeof(u8);
+ if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
+ return NDIS_STATUS_INVALID_LENGTH;
+
+ if (poid_par_priv->type_of_oid == SET_OID) {
+ encry_mode = *((u8 *)poid_par_priv->information_buf);
+ switch (encry_mode) {
+ case HW_CONTROL:
+ psecuritypriv->sw_decrypt = false;
+ psecuritypriv->sw_encrypt = false;
+ break;
+ case SW_CONTROL:
+ psecuritypriv->sw_decrypt = true;
+ psecuritypriv->sw_encrypt = true;
+ break;
+ case HW_ENCRY_SW_DECRY:
+ psecuritypriv->sw_decrypt = true;
+ psecuritypriv->sw_encrypt = false;
+ break;
+ case SW_ENCRY_HW_DECRY:
+ psecuritypriv->sw_decrypt = false;
+ psecuritypriv->sw_encrypt = true;
+ break;
+ }
+ } else {
+ if ((psecuritypriv->sw_encrypt == false) &&
+ (psecuritypriv->sw_decrypt == false))
+ encry_mode = HW_CONTROL;
+ else if ((psecuritypriv->sw_encrypt == false) &&
+ (psecuritypriv->sw_decrypt == true))
+ encry_mode = HW_ENCRY_SW_DECRY;
+ else if ((psecuritypriv->sw_encrypt == true) &&
+ (psecuritypriv->sw_decrypt == false))
+ encry_mode = SW_ENCRY_HW_DECRY;
+ else if ((psecuritypriv->sw_encrypt == true) &&
+ (psecuritypriv->sw_decrypt == true))
+ encry_mode = SW_CONTROL;
+ *(u8 *)poid_par_priv->information_buf = encry_mode;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ }
+ return NDIS_STATUS_SUCCESS;
+}
+/*----------------------------------------------------------------------*/
+uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ uint status = NDIS_STATUS_SUCCESS;
+
+ struct sta_info *psta = NULL;
+ u8 *macaddr;
+
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ *poid_par_priv->bytes_needed = ETH_ALEN;
+ if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
+ return NDIS_STATUS_INVALID_LENGTH;
+ macaddr = (u8 *) poid_par_priv->information_buf;
+ psta = r8712_get_stainfo(&Adapter->stapriv, macaddr);
+ if (psta == NULL) { /* the sta in sta_info_queue => do nothing*/
+ psta = r8712_alloc_stainfo(&Adapter->stapriv, macaddr);
+ if (psta == NULL)
+ status = NDIS_STATUS_FAILURE;
+ }
+ return status;
+}
+/*-------------------------------------------------------------------------*/
+uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ unsigned long irqL;
+ uint status = NDIS_STATUS_SUCCESS;
+
+ struct sta_info *psta = NULL;
+ u8 *macaddr;
+
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ *poid_par_priv->bytes_needed = ETH_ALEN;
+ if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
+ return NDIS_STATUS_INVALID_LENGTH;
+
+ macaddr = (u8 *)poid_par_priv->information_buf;
+
+ psta = r8712_get_stainfo(&Adapter->stapriv, macaddr);
+ if (psta != NULL) {
+ spin_lock_irqsave(&(Adapter->stapriv.sta_hash_lock), irqL);
+ r8712_free_stainfo(Adapter, psta);
+ spin_unlock_irqrestore(&(Adapter->stapriv.sta_hash_lock), irqL);
+ }
+
+ return status;
+}
+/*--------------------------------------------------------------------------*/
+static u32 mp_query_drv_var(struct _adapter *padapter, u8 offset, u32 var)
+{
+ return var;
+}
+
+uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ uint status = NDIS_STATUS_SUCCESS;
+
+ struct DR_VARIABLE_STRUCT *pdrv_var;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ *poid_par_priv->bytes_needed = sizeof(struct DR_VARIABLE_STRUCT);
+ if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
+ return NDIS_STATUS_INVALID_LENGTH;
+ pdrv_var = (struct DR_VARIABLE_STRUCT *)poid_par_priv->information_buf;
+ pdrv_var->variable = mp_query_drv_var(Adapter, pdrv_var->offset,
+ pdrv_var->variable);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+/*--------------------------------------------------------------------------*/
+uint oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv)
+{
+ return NDIS_STATUS_SUCCESS;
+}
+/*------------------------------------------------------------------------*/
+uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ uint status = NDIS_STATUS_SUCCESS;
+
+ struct EFUSE_ACCESS_STRUCT *pefuse;
+ u8 *data;
+ u16 addr = 0, cnts = 0;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len <
+ sizeof(struct EFUSE_ACCESS_STRUCT))
+ return NDIS_STATUS_INVALID_LENGTH;
+ pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
+ addr = pefuse->start_addr;
+ cnts = pefuse->cnts;
+ data = pefuse->data;
+ memset(data, 0xFF, cnts);
+ if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) >
+ EFUSE_MAX_SIZE)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (r8712_efuse_access(Adapter, true, addr, cnts, data) == false)
+ status = NDIS_STATUS_FAILURE;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+/*------------------------------------------------------------------------*/
+uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ uint status = NDIS_STATUS_SUCCESS;
+
+ struct EFUSE_ACCESS_STRUCT *pefuse;
+ u8 *data;
+ u16 addr = 0, cnts = 0;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
+ addr = pefuse->start_addr;
+ cnts = pefuse->cnts;
+ data = pefuse->data;
+
+ if ((addr > 511) || (cnts < 1) || (cnts > 512) ||
+ (addr + cnts) > r8712_efuse_get_max_size(Adapter))
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (r8712_efuse_access(Adapter, false, addr, cnts, data) == false)
+ status = NDIS_STATUS_FAILURE;
+ return status;
+}
+/*----------------------------------------------------------------------*/
+uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct PGPKT_STRUCT *ppgpkt;
+
+ *poid_par_priv->bytes_rw = 0;
+ if (poid_par_priv->information_buf_len < sizeof(struct PGPKT_STRUCT))
+ return NDIS_STATUS_INVALID_LENGTH;
+ ppgpkt = (struct PGPKT_STRUCT *)poid_par_priv->information_buf;
+ if (poid_par_priv->type_of_oid == QUERY_OID) {
+ if (r8712_efuse_pg_packet_read(Adapter, ppgpkt->offset,
+ ppgpkt->data) == true)
+ *poid_par_priv->bytes_rw =
+ poid_par_priv->information_buf_len;
+ else
+ status = NDIS_STATUS_FAILURE;
+ } else {
+ if (r8712_efuse_reg_init(Adapter) == true) {
+ if (r8712_efuse_pg_packet_write(Adapter, ppgpkt->offset,
+ ppgpkt->word_en, ppgpkt->data) == true)
+ *poid_par_priv->bytes_rw =
+ poid_par_priv->information_buf_len;
+ else
+ status = NDIS_STATUS_FAILURE;
+ r8712_efuse_reg_uninit(Adapter);
+ } else
+ status = NDIS_STATUS_FAILURE;
+ }
+ return status;
+}
+
+uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(int))
+ return NDIS_STATUS_INVALID_LENGTH;
+ r8712_efuse_reg_init(Adapter);
+ *(int *)poid_par_priv->information_buf =
+ r8712_efuse_get_current_size(Adapter);
+ r8712_efuse_reg_uninit(Adapter);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ *(int *)poid_par_priv->information_buf =
+ r8712_efuse_get_max_size(Adapter);
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return status;
+}
+
+uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv)
+{
+ uint status = NDIS_STATUS_SUCCESS;
+
+ if (poid_par_priv->type_of_oid == QUERY_OID)
+ status = oid_rt_pro_read_efuse_hdl(poid_par_priv);
+ else
+ status = oid_rt_pro_write_efuse_hdl(poid_par_priv);
+ return status;
+}
+
+uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u8 *data;
+
+ *poid_par_priv->bytes_rw = 0;
+ if (poid_par_priv->information_buf_len < EFUSE_MAP_MAX_SIZE)
+ return NDIS_STATUS_INVALID_LENGTH;
+ data = (u8 *)poid_par_priv->information_buf;
+ if (poid_par_priv->type_of_oid == QUERY_OID) {
+ if (r8712_efuse_map_read(Adapter, 0, EFUSE_MAP_MAX_SIZE, data))
+ *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
+ else
+ status = NDIS_STATUS_FAILURE;
+ } else {
+ /* SET_OID */
+ if (r8712_efuse_reg_init(Adapter) == true) {
+ if (r8712_efuse_map_write(Adapter, 0,
+ EFUSE_MAP_MAX_SIZE, data))
+ *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
+ else
+ status = NDIS_STATUS_FAILURE;
+ r8712_efuse_reg_uninit(Adapter);
+ } else {
+ status = NDIS_STATUS_FAILURE;
+ }
+ }
+ return status;
+}
+
+uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 bandwidth;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ bandwidth = *((u32 *)poid_par_priv->information_buf);/*4*/
+ if (bandwidth != HT_CHANNEL_WIDTH_20)
+ bandwidth = HT_CHANNEL_WIDTH_40;
+ Adapter->mppriv.curr_bandwidth = (u8)bandwidth;
+ r8712_SwitchBandwidth(Adapter);
+ return status;
+}
+
+uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ u32 crystal_cap = 0;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ crystal_cap = *((u32 *)poid_par_priv->information_buf);/*4*/
+ if (crystal_cap > 0xf)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ Adapter->mppriv.curr_crystalcap = crystal_cap;
+ r8712_SetCrystalCap(Adapter);
+ return status;
+}
+
+uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u8 rx_pkt_type;
+ u32 rcr_val32;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u8))
+ return NDIS_STATUS_INVALID_LENGTH;
+ rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/*4*/
+ rcr_val32 = r8712_read32(Adapter, RCR);/*RCR = 0x10250048*/
+ rcr_val32 &= ~(RCR_CBSSID | RCR_AB | RCR_AM | RCR_APM | RCR_AAP);
+ switch (rx_pkt_type) {
+ case RX_PKT_BROADCAST:
+ rcr_val32 |= (RCR_AB | RCR_AM | RCR_APM | RCR_AAP | RCR_ACRC32);
+ break;
+ case RX_PKT_DEST_ADDR:
+ rcr_val32 |= (RCR_AB | RCR_AM | RCR_APM | RCR_AAP | RCR_ACRC32);
+ break;
+ case RX_PKT_PHY_MATCH:
+ rcr_val32 |= (RCR_APM|RCR_ACRC32);
+ break;
+ default:
+ rcr_val32 &= ~(RCR_AAP |
+ RCR_APM |
+ RCR_AM |
+ RCR_AB |
+ RCR_ACRC32);
+ break;
+ }
+ if (rx_pkt_type == RX_PKT_DEST_ADDR)
+ Adapter->mppriv.check_mp_pkt = 1;
+ else
+ Adapter->mppriv.check_mp_pkt = 0;
+ r8712_write32(Adapter, RCR, rcr_val32);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ u32 txagc;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ txagc = *(u32 *)poid_par_priv->information_buf;
+ r8712_SetTxAGCOffset(Adapter, txagc);
+ return NDIS_STATUS_SUCCESS;
+}
+
+uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv
+ *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+ uint status = NDIS_STATUS_SUCCESS;
+ struct mlme_priv *pmlmepriv = &Adapter->mlmepriv;
+ struct mp_priv *pmppriv = &Adapter->mppriv;
+ u32 type;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+
+ type = *(u32 *)poid_par_priv->information_buf;
+
+ if (_LOOPBOOK_MODE_ == type) {
+ pmppriv->mode = type;
+ set_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE); /*append txdesc*/
+ } else if (_2MAC_MODE_ == type) {
+ pmppriv->mode = type;
+ _clr_fwstate_(pmlmepriv, WIFI_MP_LPBK_STATE);
+ } else
+ status = NDIS_STATUS_NOT_ACCEPTED;
+ return status;
+}
+/*--------------------------------------------------------------------------*/
+/*Linux*/
+unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv)
+{
+ return _SUCCESS;
+}
+/*-------------------------------------------------------------------------*/
+uint oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv)
+{
+ u8 bpwrup;
+
+ if (poid_par_priv->type_of_oid != SET_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ bpwrup = *(u8 *)poid_par_priv->information_buf;
+ /*CALL the power_down function*/
+ return NDIS_STATUS_SUCCESS;
+}
+
+/*-------------------------------------------------------------------------- */
+uint oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv)
+{
+ struct _adapter *Adapter = (struct _adapter *)
+ (poid_par_priv->adapter_context);
+
+ if (poid_par_priv->type_of_oid != QUERY_OID)
+ return NDIS_STATUS_NOT_ACCEPTED;
+ if (poid_par_priv->information_buf_len < sizeof(u32))
+ return NDIS_STATUS_INVALID_LENGTH;
+ *(int *)poid_par_priv->information_buf =
+ Adapter->registrypriv.low_power ? POWER_LOW : POWER_NORMAL;
+ *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
+ return NDIS_STATUS_SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h
new file mode 100644
index 000000000000..2225bd15466b
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h
@@ -0,0 +1,457 @@
+#ifndef _RTL871X_MP_IOCTL_H
+#define _RTL871X_MP_IOCTL_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "mp_custom_oid.h"
+#include "rtl871x_ioctl.h"
+#include "rtl871x_ioctl_rtl.h"
+#include "rtl8712_efuse.h"
+
+#define TESTFWCMDNUMBER 1000000
+#define TEST_H2CINT_WAIT_TIME 500
+#define TEST_C2HINT_WAIT_TIME 500
+#define HCI_TEST_SYSCFG_HWMASK 1
+#define _BUSCLK_40M (4 << 2)
+
+struct CFG_DBG_MSG_STRUCT {
+ u32 DebugLevel;
+ u32 DebugComponent_H32;
+ u32 DebugComponent_L32;
+};
+
+struct mp_rw_reg {
+ uint offset;
+ uint width;
+ u32 value;
+};
+
+/* for OID_RT_PRO_READ16_EEPROM & OID_RT_PRO_WRITE16_EEPROM */
+struct eeprom_rw_param {
+ uint offset;
+ u16 value;
+};
+
+struct EFUSE_ACCESS_STRUCT {
+ u16 start_addr;
+ u16 cnts;
+ u8 data[0];
+};
+
+struct burst_rw_reg {
+ uint offset;
+ uint len;
+ u8 Data[256];
+};
+
+struct usb_vendor_req {
+ u8 bRequest;
+ u16 wValue;
+ u16 wIndex;
+ u16 wLength;
+ u8 u8Dir;/*0:OUT, 1:IN */
+ u8 u8InData;
+};
+
+struct DR_VARIABLE_STRUCT {
+ u8 offset;
+ u32 variable;
+};
+
+int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid);
+
+/* oid_rtl_seg_87_11_00 */
+uint oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_burst_read_register_hdl(struct oid_par_priv*
+ poid_par_priv);
+uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv*
+ poid_par_priv);
+uint oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_87_11_20 */
+uint oid_rt_pro_cfg_debug_message_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_data_rate_ex_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_basic_rate_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_power_tracking_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_87_11_50 */
+uint oid_rt_pro_qry_pwrstate_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_pwrstate_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_87_11_F0 */
+uint oid_rt_pro_h2c_set_rate_table_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_h2c_get_rate_table_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_81_80_00 */
+uint oid_rt_pro_set_data_rate_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_channel_direct_call_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_antenna_bb_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_tx_power_control_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_81_80_20 */
+uint oid_rt_pro_query_tx_packet_sent_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_query_rx_packet_received_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_reset_tx_packet_sent_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_reset_rx_packet_received_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_continuous_tx_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_single_carrier_tx_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_carrier_suppression_tx_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_single_tone_tx_hdl(
+ struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_81_87 */
+uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_81_85 */
+uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv);
+/* oid_rtl_seg_87_12_00 */
+uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_query_dr_variable_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_efuse_current_size_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_tx_agc_offset_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_pro_set_pkt_test_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_thermal_meter_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_reset_phy_rx_packet_count_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_phy_rx_packet_received_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_phy_rx_packet_crc32_error_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_set_power_down_hdl(
+ struct oid_par_priv *poid_par_priv);
+uint oid_rt_get_power_mode_hdl(
+ struct oid_par_priv *poid_par_priv);
+#ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
+/* This ifdef _MUST_ be left in!! */
+static const struct oid_obj_priv oid_rtl_seg_81_80_00[] = {
+ {1, &oid_null_function}, /*0x00 OID_RT_PRO_RESET_DUT */
+ {1, &oid_rt_pro_set_data_rate_hdl}, /*0x01*/
+ {1, &oid_rt_pro_start_test_hdl},/*0x02*/
+ {1, &oid_rt_pro_stop_test_hdl}, /*0x03*/
+ {1, &oid_null_function}, /*0x04 OID_RT_PRO_SET_PREAMBLE*/
+ {1, &oid_null_function}, /*0x05 OID_RT_PRO_SET_SCRAMBLER*/
+ {1, &oid_null_function}, /*0x06 OID_RT_PRO_SET_FILTER_BB*/
+ {1, &oid_null_function}, /*0x07
+ * OID_RT_PRO_SET_MANUAL_DIVERS_BB*/
+ {1, &oid_rt_pro_set_channel_direct_call_hdl}, /*0x08*/
+ {1, &oid_null_function}, /*0x09
+ * OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL*/
+ {1, &oid_null_function}, /*0x0A
+ * OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL*/
+ {1, &oid_rt_pro_set_continuous_tx_hdl}, /*0x0B
+ * OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL*/
+ {1, &oid_rt_pro_set_single_carrier_tx_hdl}, /*0x0C
+ * OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS*/
+ {1, &oid_null_function}, /*0x0D
+ * OID_RT_PRO_SET_TX_ANTENNA_BB*/
+ {1, &oid_rt_pro_set_antenna_bb_hdl}, /*0x0E*/
+ {1, &oid_null_function}, /*0x0F OID_RT_PRO_SET_CR_SCRAMBLER*/
+ {1, &oid_null_function}, /*0x10 OID_RT_PRO_SET_CR_NEW_FILTER*/
+ {1, &oid_rt_pro_set_tx_power_control_hdl}, /*0x11
+ * OID_RT_PRO_SET_TX_POWER_CONTROL*/
+ {1, &oid_null_function}, /*0x12 OID_RT_PRO_SET_CR_TX_CONFIG*/
+ {1, &oid_null_function}, /*0x13
+ * OID_RT_PRO_GET_TX_POWER_CONTROL*/
+ {1, &oid_null_function}, /*0x14
+ * OID_RT_PRO_GET_CR_SIGNAL_QUALITY*/
+ {1, &oid_null_function}, /*0x15 OID_RT_PRO_SET_CR_SETPOINT*/
+ {1, &oid_null_function}, /*0x16 OID_RT_PRO_SET_INTEGRATOR*/
+ {1, &oid_null_function}, /*0x17 OID_RT_PRO_SET_SIGNAL_QUALITY*/
+ {1, &oid_null_function}, /*0x18 OID_RT_PRO_GET_INTEGRATOR*/
+ {1, &oid_null_function}, /*0x19 OID_RT_PRO_GET_SIGNAL_QUALITY*/
+ {1, &oid_null_function}, /*0x1A OID_RT_PRO_QUERY_EEPROM_TYPE*/
+ {1, &oid_null_function}, /*0x1B OID_RT_PRO_WRITE_MAC_ADDRESS*/
+ {1, &oid_null_function}, /*0x1C OID_RT_PRO_READ_MAC_ADDRESS*/
+ {1, &oid_null_function}, /*0x1D OID_RT_PRO_WRITE_CIS_DATA*/
+ {1, &oid_null_function}, /*0x1E OID_RT_PRO_READ_CIS_DATA*/
+ {1, &oid_null_function} /*0x1F OID_RT_PRO_WRITE_POWER_CONTROL*/
+};
+
+static const struct oid_obj_priv oid_rtl_seg_81_80_20[] = {
+ {1, &oid_null_function}, /*0x20 OID_RT_PRO_READ_POWER_CONTROL*/
+ {1, &oid_null_function}, /*0x21 OID_RT_PRO_WRITE_EEPROM*/
+ {1, &oid_null_function}, /*0x22 OID_RT_PRO_READ_EEPROM*/
+ {1, &oid_rt_pro_reset_tx_packet_sent_hdl}, /*0x23*/
+ {1, &oid_rt_pro_query_tx_packet_sent_hdl}, /*0x24*/
+ {1, &oid_rt_pro_reset_rx_packet_received_hdl}, /*0x25*/
+ {1, &oid_rt_pro_query_rx_packet_received_hdl}, /*0x26*/
+ {1, &oid_rt_pro_query_rx_packet_crc32_error_hdl},/*0x27*/
+ {1, &oid_null_function}, /*0x28
+ *OID_RT_PRO_QUERY_CURRENT_ADDRESS*/
+ {1, &oid_null_function}, /*0x29
+ *OID_RT_PRO_QUERY_PERMANENT_ADDRESS*/
+ {1, &oid_null_function}, /*0x2A
+ *OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS*/
+ {1, &oid_rt_pro_set_carrier_suppression_tx_hdl},/*0x2B
+ *OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX*/
+ {1, &oid_null_function}, /*0x2C OID_RT_PRO_RECEIVE_PACKET*/
+ {1, &oid_null_function}, /*0x2D OID_RT_PRO_WRITE_EEPROM_BYTE*/
+ {1, &oid_null_function}, /*0x2E OID_RT_PRO_READ_EEPROM_BYTE*/
+ {1, &oid_rt_pro_set_modulation_hdl} /*0x2F*/
+};
+
+static const struct oid_obj_priv oid_rtl_seg_81_80_40[] = {
+ {1, &oid_null_function}, /*0x40*/
+ {1, &oid_null_function}, /*0x41*/
+ {1, &oid_null_function}, /*0x42*/
+ {1, &oid_rt_pro_set_single_tone_tx_hdl}, /*0x43*/
+ {1, &oid_null_function}, /*0x44*/
+ {1, &oid_null_function} /*0x45*/
+};
+
+static const struct oid_obj_priv oid_rtl_seg_81_80_80[] = {
+ {1, &oid_null_function}, /*0x80 OID_RT_DRIVER_OPTION*/
+ {1, &oid_null_function}, /*0x81 OID_RT_RF_OFF*/
+ {1, &oid_null_function} /*0x82 OID_RT_AUTH_STATUS*/
+
+};
+
+static const struct oid_obj_priv oid_rtl_seg_81_85[] = {
+ {1, &oid_rt_wireless_mode_hdl} /*0x00 OID_RT_WIRELESS_MODE*/
+};
+
+#else /* _RTL871X_MP_IOCTL_C_ */
+extern struct oid_obj_priv oid_rtl_seg_81_80_00[32];
+extern struct oid_obj_priv oid_rtl_seg_81_80_20[16];
+extern struct oid_obj_priv oid_rtl_seg_81_80_40[6];
+extern struct oid_obj_priv oid_rtl_seg_81_80_80[3];
+extern struct oid_obj_priv oid_rtl_seg_81_85[1];
+extern struct oid_obj_priv oid_rtl_seg_81_87[5];
+extern struct oid_obj_priv oid_rtl_seg_87_11_00[32];
+extern struct oid_obj_priv oid_rtl_seg_87_11_20[5];
+extern struct oid_obj_priv oid_rtl_seg_87_11_50[2];
+extern struct oid_obj_priv oid_rtl_seg_87_11_80[1];
+extern struct oid_obj_priv oid_rtl_seg_87_11_B0[1];
+extern struct oid_obj_priv oid_rtl_seg_87_11_F0[16];
+extern struct oid_obj_priv oid_rtl_seg_87_12_00[32];
+
+#endif /* _RTL871X_MP_IOCTL_C_ */
+
+
+enum MP_MODE {
+ MP_START_MODE,
+ MP_STOP_MODE,
+ MP_ERR_MODE
+};
+
+struct rwreg_param{
+ unsigned int offset;
+ unsigned int width;
+ unsigned int value;
+};
+
+struct bbreg_param{
+ unsigned int offset;
+ unsigned int phymask;
+ unsigned int value;
+};
+
+struct txpower_param{
+ unsigned int pwr_index;
+};
+
+struct datarate_param{
+ unsigned int rate_index;
+};
+
+struct rfintfs_parm {
+ unsigned int rfintfs;
+};
+
+struct mp_xmit_packet {
+ unsigned int len;
+ unsigned int mem[MAX_MP_XMITBUF_SZ >> 2];
+};
+
+struct psmode_param {
+ unsigned int ps_mode;
+ unsigned int smart_ps;
+};
+
+struct mp_ioctl_handler {
+ unsigned int paramsize;
+ unsigned int (*handler)(struct oid_par_priv *poid_par_priv);
+ unsigned int oid;
+};
+
+struct mp_ioctl_param{
+ unsigned int subcode;
+ unsigned int len;
+ unsigned char data[0];
+};
+
+#define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_
+
+enum RTL871X_MP_IOCTL_SUBCODE {
+ GEN_MP_IOCTL_SUBCODE(MP_START), /*0*/
+ GEN_MP_IOCTL_SUBCODE(MP_STOP), /*1*/
+ GEN_MP_IOCTL_SUBCODE(READ_REG), /*2*/
+ GEN_MP_IOCTL_SUBCODE(WRITE_REG),
+ GEN_MP_IOCTL_SUBCODE(SET_CHANNEL), /*4*/
+ GEN_MP_IOCTL_SUBCODE(SET_TXPOWER), /*5*/
+ GEN_MP_IOCTL_SUBCODE(SET_DATARATE), /*6*/
+ GEN_MP_IOCTL_SUBCODE(READ_BB_REG), /*7*/
+ GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG),
+ GEN_MP_IOCTL_SUBCODE(READ_RF_REG), /*9*/
+ GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG),
+ GEN_MP_IOCTL_SUBCODE(SET_RF_INTFS),
+ GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET), /*12*/
+ GEN_MP_IOCTL_SUBCODE(PS_STATE), /*13*/
+ GEN_MP_IOCTL_SUBCODE(READ16_EEPROM), /*14*/
+ GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM), /*15*/
+ GEN_MP_IOCTL_SUBCODE(SET_PTM), /*16*/
+ GEN_MP_IOCTL_SUBCODE(READ_TSSI), /*17*/
+ GEN_MP_IOCTL_SUBCODE(CNTU_TX), /*18*/
+ GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH), /*19*/
+ GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE), /*20*/
+ GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT), /*21*/
+ GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV), /*22*/
+ GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR), /*23*/
+ GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN), /*24*/
+ GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER), /*25*/
+ GEN_MP_IOCTL_SUBCODE(GET_POWER_MODE), /*26*/
+ GEN_MP_IOCTL_SUBCODE(EFUSE), /*27*/
+ GEN_MP_IOCTL_SUBCODE(EFUSE_MAP), /*28*/
+ GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE), /*29*/
+ GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE), /*30*/
+ GEN_MP_IOCTL_SUBCODE(SC_TX), /*31*/
+ GEN_MP_IOCTL_SUBCODE(CS_TX), /*32*/
+ GEN_MP_IOCTL_SUBCODE(ST_TX), /*33*/
+ GEN_MP_IOCTL_SUBCODE(SET_ANTENNA), /*34*/
+ MAX_MP_IOCTL_SUBCODE,
+};
+
+unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv);
+
+#ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
+/* This ifdef _MUST_ be left in!! */
+
+struct mp_ioctl_handler mp_ioctl_hdl[] = {
+ {sizeof(u32), oid_rt_pro_start_test_hdl,
+ OID_RT_PRO_START_TEST},/*0*/
+ {sizeof(u32), oid_rt_pro_stop_test_hdl,
+ OID_RT_PRO_STOP_TEST},/*1*/
+ {sizeof(struct rwreg_param),
+ oid_rt_pro_read_register_hdl,
+ OID_RT_PRO_READ_REGISTER},/*2*/
+ {sizeof(struct rwreg_param),
+ oid_rt_pro_write_register_hdl,
+ OID_RT_PRO_WRITE_REGISTER},
+ {sizeof(u32),
+ oid_rt_pro_set_channel_direct_call_hdl,
+ OID_RT_PRO_SET_CHANNEL_DIRECT_CALL},
+ {sizeof(struct txpower_param),
+ oid_rt_pro_set_tx_power_control_hdl,
+ OID_RT_PRO_SET_TX_POWER_CONTROL},
+ {sizeof(u32),
+ oid_rt_pro_set_data_rate_hdl,
+ OID_RT_PRO_SET_DATA_RATE},
+ {sizeof(struct bb_reg_param),
+ oid_rt_pro_read_bb_reg_hdl,
+ OID_RT_PRO_READ_BB_REG},/*7*/
+ {sizeof(struct bb_reg_param),
+ oid_rt_pro_write_bb_reg_hdl,
+ OID_RT_PRO_WRITE_BB_REG},
+ {sizeof(struct rwreg_param),
+ oid_rt_pro_read_rf_reg_hdl,
+ OID_RT_PRO_RF_READ_REGISTRY},/*9*/
+ {sizeof(struct rwreg_param),
+ oid_rt_pro_write_rf_reg_hdl,
+ OID_RT_PRO_RF_WRITE_REGISTRY},
+ {sizeof(struct rfintfs_parm), NULL, 0},
+ {0, &mp_ioctl_xmit_packet_hdl, 0},/*12*/
+ {sizeof(struct psmode_param), NULL, 0},/*13*/
+ {sizeof(struct eeprom_rw_param), NULL, 0},/*14*/
+ {sizeof(struct eeprom_rw_param), NULL, 0},/*15*/
+ {sizeof(u8), oid_rt_pro_set_power_tracking_hdl,
+ OID_RT_PRO_SET_POWER_TRACKING},/*16*/
+ {sizeof(u32), NULL, 0},/*17*/
+ {sizeof(u32), oid_rt_pro_set_continuous_tx_hdl,
+ OID_RT_PRO_SET_CONTINUOUS_TX},/*18*/
+ {sizeof(u32), oid_rt_set_bandwidth_hdl,
+ OID_RT_SET_BANDWIDTH},/*19*/
+ {sizeof(u32), oid_rt_set_rx_packet_type_hdl,
+ OID_RT_SET_RX_PACKET_TYPE},/*20*/
+ {0, oid_rt_reset_phy_rx_packet_count_hdl,
+ OID_RT_RESET_PHY_RX_PACKET_COUNT},/*21*/
+ {sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl,
+ OID_RT_GET_PHY_RX_PACKET_RECEIVED},/*22*/
+ {sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl,
+ OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR},/*23*/
+ {sizeof(unsigned char), oid_rt_set_power_down_hdl,
+ OID_RT_SET_POWER_DOWN},/*24*/
+ {sizeof(u32), oid_rt_get_thermal_meter_hdl,
+ OID_RT_PRO_GET_THERMAL_METER},/*25*/
+ {sizeof(u32), oid_rt_get_power_mode_hdl,
+ OID_RT_GET_POWER_MODE},/*26*/
+ {sizeof(struct EFUSE_ACCESS_STRUCT),
+ oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE},/*27*/
+ {EFUSE_MAP_MAX_SIZE, oid_rt_pro_efuse_map_hdl,
+ OID_RT_PRO_EFUSE_MAP},/*28*/
+ {sizeof(u32), oid_rt_get_efuse_max_size_hdl,
+ OID_RT_GET_EFUSE_MAX_SIZE},/*29*/
+ {sizeof(u32), oid_rt_get_efuse_current_size_hdl,
+ OID_RT_GET_EFUSE_CURRENT_SIZE},/*30*/
+ {sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl,
+ OID_RT_PRO_SET_SINGLE_CARRIER_TX},/*31*/
+ {sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl,
+ OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX},/*32*/
+ {sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl,
+ OID_RT_PRO_SET_SINGLE_TONE_TX},/*33*/
+ {sizeof(u32), oid_rt_pro_set_antenna_bb_hdl,
+ OID_RT_PRO_SET_ANTENNA_BB},/*34*/
+};
+
+#else /* _RTL871X_MP_IOCTL_C_ */
+extern struct mp_ioctl_handler mp_ioctl_hdl[];
+#endif /* _RTL871X_MP_IOCTL_C_ */
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
new file mode 100644
index 000000000000..e386fb0aac3e
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
@@ -0,0 +1,1025 @@
+/*****************************************************************************
+ * Copyright(c) 2008, RealTEK Technology Inc. All Right Reserved.
+ *
+ * Module: __INC_HAL8192SPHYREG_H
+ *
+ *
+ * Note: 1. Define PMAC/BB register map
+ * 2. Define RF register map
+ * 3. PMAC/BB register bit mask.
+ * 4. RF reg bit mask.
+ * 5. Other BB/RF relative definition.
+ *
+ *
+ * Export: Constants, macro, functions(API), global variables(None).
+ *
+ * Abbrev:
+ *
+ * History:
+ * Data Who Remark
+ * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h.
+ * 2. Reorganize code architecture.
+ * 09/25/2008 MH 1. Add RL6052 register definition
+ *
+ *****************************************************************************/
+#ifndef __RTL871X_MP_PHY_REGDEF_H
+#define __RTL871X_MP_PHY_REGDEF_H
+
+
+/*--------------------------Define Parameters-------------------------------*/
+
+/*============================================================
+ * 8192S Regsiter offset definition
+ *============================================================
+ *
+ *
+ * BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF
+ * 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
+ * 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00
+ * 3. RF register 0x00-2E
+ * 4. Bit Mask for BB/RF register
+ * 5. Other defintion for BB/RF R/W
+ *
+ * 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
+ * 1. Page1(0x100)
+ */
+#define rPMAC_Reset 0x100
+#define rPMAC_TxStart 0x104
+#define rPMAC_TxLegacySIG 0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum 0x118
+#define rPMAC_TxIdle 0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType 0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble 0x140
+#define rPMAC_CCKPLCPHeader 0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK 0x170
+#define rPMAC_OFDMRxCRC32Er 0x174
+#define rPMAC_OFDMRxParityEr 0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+/*
+ * 2. Page2(0x200)
+ *
+ * The following two definition are only used for USB interface.
+ *#define RF_BB_CMD_ADDR 0x02c0 // RF/BB read/write command address.
+ *#define RF_BB_CMD_DATA 0x02c4 // RF/BB read/write command data.
+ *
+ *
+ * 3. Page8(0x800)
+ */
+#define rFPGA0_RFMOD 0x800 /*RF mode & CCK TxSC RF
+ * BW Setting?? */
+#define rFPGA0_TxInfo 0x804 /* Status report?? */
+#define rFPGA0_PSDFunction 0x808
+#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */
+#define rFPGA0_RFTiming1 0x810 /* Useless now */
+#define rFPGA0_RFTiming2 0x814
+#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */
+#define rFPGA0_XA_HSSIParameter2 0x824
+#define rFPGA0_XB_HSSIParameter1 0x828
+#define rFPGA0_XB_HSSIParameter2 0x82c
+#define rFPGA0_XC_HSSIParameter1 0x830
+#define rFPGA0_XC_HSSIParameter2 0x834
+#define rFPGA0_XD_HSSIParameter1 0x838
+#define rFPGA0_XD_HSSIParameter2 0x83c
+#define rFPGA0_XA_LSSIParameter 0x840
+#define rFPGA0_XB_LSSIParameter 0x844
+#define rFPGA0_XC_LSSIParameter 0x848
+#define rFPGA0_XD_LSSIParameter 0x84c
+
+#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */
+#define rFPGA0_RFSleepUpParameter 0x854
+
+#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */
+#define rFPGA0_XCD_SwitchControl 0x85c
+
+#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */
+#define rFPGA0_XB_RFInterfaceOE 0x864
+#define rFPGA0_XC_RFInterfaceOE 0x868
+#define rFPGA0_XD_RFInterfaceOE 0x86c
+#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Interface Software Ctrl */
+#define rFPGA0_XCD_RFInterfaceSW 0x874
+
+#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */
+#define rFPGA0_XCD_RFParameter 0x87c
+
+#define rFPGA0_AnalogParameter1 0x880 /* Crystal cap setting
+ * RF-R/W protection
+ * for parameter4?? */
+#define rFPGA0_AnalogParameter2 0x884
+#define rFPGA0_AnalogParameter3 0x888 /* Useless now */
+#define rFPGA0_AnalogParameter4 0x88c
+
+#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */
+#define rFPGA0_XB_LSSIReadBack 0x8a4
+#define rFPGA0_XC_LSSIReadBack 0x8a8
+#define rFPGA0_XD_LSSIReadBack 0x8ac
+
+#define rFPGA0_PSDReport 0x8b4 /* Useless now */
+#define rFPGA0_XAB_RFInterfaceRB 0x8e0 /* Useless now */
+#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */
+
+/*
+ * 4. Page9(0x900)
+ */
+#define rFPGA1_RFMOD 0x900 /* RF mode & OFDM TxSC */
+
+#define rFPGA1_TxBlock 0x904 /* Useless now */
+#define rFPGA1_DebugSelect 0x908 /* Useless now */
+#define rFPGA1_TxInfo 0x90c /* Useless now */
+
+/*
+ * 5. PageA(0xA00)
+ *
+ * Set Control channel to upper or lower.
+ * These settings are required only for 40MHz */
+#define rCCK0_System 0xa00
+
+#define rCCK0_AFESetting 0xa04 /* Disable init gain now */
+#define rCCK0_CCA 0xa08 /* Disable init gain now */
+
+#define rCCK0_RxAGC1 0xa0c
+/* AGC default value, saturation level
+ * Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now.
+ * Not the same as 90 series */
+#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */
+
+#define rCCK0_RxHP 0xa14
+
+#define rCCK0_DSPParameter1 0xa18 /* Timing recovery & Channel
+ * estimation threshold */
+#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */
+
+#define rCCK0_TxFilter1 0xa20
+#define rCCK0_TxFilter2 0xa24
+#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */
+#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now 0xa30-a4f
+ * channel report */
+#define rCCK0_TRSSIReport 0xa50
+#define rCCK0_RxReport 0xa54 /* 0xa57 */
+#define rCCK0_FACounterLower 0xa5c /* 0xa5b */
+#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */
+
+/*
+ * 6. PageC(0xC00)
+ */
+#define rOFDM0_LSTF 0xc00
+#define rOFDM0_TRxPathEnable 0xc04
+#define rOFDM0_TRMuxPar 0xc08
+#define rOFDM0_TRSWIsolation 0xc0c
+
+/*RxIQ DC offset, Rx digital filter, DC notch filter */
+#define rOFDM0_XARxAFE 0xc10
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */
+#define rOFDM0_XBRxAFE 0xc18
+#define rOFDM0_XBRxIQImbalance 0xc1c
+#define rOFDM0_XCRxAFE 0xc20
+#define rOFDM0_XCRxIQImbalance 0xc24
+#define rOFDM0_XDRxAFE 0xc28
+#define rOFDM0_XDRxIQImbalance 0xc2c
+
+#define rOFDM0_RxDetector1 0xc30 /* PD,BW & SBD DM tune
+ * init gain */
+#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */
+#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */
+#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync &
+ * Short-GI */
+
+#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */
+#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */
+#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */
+#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */
+
+#define rOFDM0_XAAGCCore1 0xc50 /* DIG */
+#define rOFDM0_XAAGCCore2 0xc54
+#define rOFDM0_XBAGCCore1 0xc58
+#define rOFDM0_XBAGCCore2 0xc5c
+#define rOFDM0_XCAGCCore1 0xc60
+#define rOFDM0_XCAGCCore2 0xc64
+#define rOFDM0_XDAGCCore1 0xc68
+#define rOFDM0_XDAGCCore2 0xc6c
+#define rOFDM0_AGCParameter1 0xc70
+#define rOFDM0_AGCParameter2 0xc74
+#define rOFDM0_AGCRSSITable 0xc78
+#define rOFDM0_HTSTFAGC 0xc7c
+
+#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */
+#define rOFDM0_XATxAFE 0xc84
+#define rOFDM0_XBTxIQImbalance 0xc88
+#define rOFDM0_XBTxAFE 0xc8c
+#define rOFDM0_XCTxIQImbalance 0xc90
+#define rOFDM0_XCTxAFE 0xc94
+#define rOFDM0_XDTxIQImbalance 0xc98
+#define rOFDM0_XDTxAFE 0xc9c
+
+#define rOFDM0_RxHPParameter 0xce0
+#define rOFDM0_TxPseudoNoiseWgt 0xce4
+#define rOFDM0_FrameSync 0xcf0
+#define rOFDM0_DFSReport 0xcf4
+#define rOFDM0_TxCoeff1 0xca4
+#define rOFDM0_TxCoeff2 0xca8
+#define rOFDM0_TxCoeff3 0xcac
+#define rOFDM0_TxCoeff4 0xcb0
+#define rOFDM0_TxCoeff5 0xcb4
+#define rOFDM0_TxCoeff6 0xcb8
+
+/*
+ * 7. PageD(0xD00)
+ */
+#define rOFDM1_LSTF 0xd00
+#define rOFDM1_TRxPathEnable 0xd04
+
+#define rOFDM1_CFO 0xd08 /* No setting now */
+#define rOFDM1_CSI1 0xd10
+#define rOFDM1_SBD 0xd14
+#define rOFDM1_CSI2 0xd18
+#define rOFDM1_CFOTracking 0xd2c
+#define rOFDM1_TRxMesaure1 0xd34
+#define rOFDM1_IntfDet 0xd3c
+#define rOFDM1_PseudoNoiseStateAB 0xd50
+#define rOFDM1_PseudoNoiseStateCD 0xd54
+#define rOFDM1_RxPseudoNoiseWgt 0xd58
+
+#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */
+#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */
+#define rOFDM_PHYCounter3 0xda8 /* MCS not support */
+#define rOFDM_ShortCFOAB 0xdac /* No setting now */
+#define rOFDM_ShortCFOCD 0xdb0
+#define rOFDM_LongCFOAB 0xdb4
+#define rOFDM_LongCFOCD 0xdb8
+#define rOFDM_TailCFOAB 0xdbc
+#define rOFDM_TailCFOCD 0xdc0
+#define rOFDM_PWMeasure1 0xdc4
+#define rOFDM_PWMeasure2 0xdc8
+#define rOFDM_BWReport 0xdcc
+#define rOFDM_AGCReport 0xdd0
+#define rOFDM_RxSNR 0xdd4
+#define rOFDM_RxEVMCSI 0xdd8
+#define rOFDM_SIGReport 0xddc
+
+/*
+ * 8. PageE(0xE00)
+ */
+#define rTxAGC_Rate18_06 0xe00
+#define rTxAGC_Rate54_24 0xe04
+#define rTxAGC_CCK_Mcs32 0xe08
+#define rTxAGC_Mcs03_Mcs00 0xe10
+#define rTxAGC_Mcs07_Mcs04 0xe14
+#define rTxAGC_Mcs11_Mcs08 0xe18
+#define rTxAGC_Mcs15_Mcs12 0xe1c
+
+/* Analog- control in RX_WAIT_CCA : REG: EE0
+ * [Analog- Power & Control Register] */
+#define rRx_Wait_CCCA 0xe70
+#define rAnapar_Ctrl_BB 0xee0
+
+/*
+ * 7. RF Register 0x00-0x2E (RF 8256)
+ * RF-0222D 0x00-3F
+ *
+ * Zebra1
+ */
+#define rZebra1_HSSIEnable 0x0 /* Useless now */
+#define rZebra1_TRxEnable1 0x1
+#define rZebra1_TRxEnable2 0x2
+#define rZebra1_AGC 0x4
+#define rZebra1_ChargePump 0x5
+#define rZebra1_Channel 0x7 /* RF channel switch */
+#define rZebra1_TxGain 0x8 /* Useless now */
+#define rZebra1_TxLPF 0x9
+#define rZebra1_RxLPF 0xb
+#define rZebra1_RxHPFCorner 0xc
+
+/* Zebra4 */
+#define rGlobalCtrl 0 /* Useless now */
+#define rRTL8256_TxLPF 19
+#define rRTL8256_RxLPF 11
+
+/* RTL8258 */
+#define rRTL8258_TxLPF 0x11 /* Useless now */
+#define rRTL8258_RxLPF 0x13
+#define rRTL8258_RSSILPF 0xa
+
+/* RL6052 Register definition */
+#define RF_AC 0x00
+#define RF_IQADJ_G1 0x01
+#define RF_IQADJ_G2 0x02
+#define RF_POW_TRSW 0x05
+
+#define RF_GAIN_RX 0x06
+#define RF_GAIN_TX 0x07
+
+#define RF_TXM_IDAC 0x08
+#define RF_BS_IQGEN 0x0F
+
+#define RF_MODE1 0x10
+#define RF_MODE2 0x11
+
+#define RF_RX_AGC_HP 0x12
+#define RF_TX_AGC 0x13
+#define RF_BIAS 0x14
+#define RF_IPA 0x15
+#define RF_POW_ABILITY 0x17
+#define RF_MODE_AG 0x18
+#define rRfChannel 0x18 /* RF channel and BW switch */
+#define RF_CHNLBW 0x18 /* RF channel and BW switch */
+#define RF_TOP 0x19
+#define RF_RX_G1 0x1A
+#define RF_RX_G2 0x1B
+#define RF_RX_BB2 0x1C
+#define RF_RX_BB1 0x1D
+
+#define RF_RCK1 0x1E
+#define RF_RCK2 0x1F
+
+#define RF_TX_G1 0x20
+#define RF_TX_G2 0x21
+#define RF_TX_G3 0x22
+
+#define RF_TX_BB1 0x23
+#define RF_T_METER 0x24
+
+#define RF_SYN_G1 0x25 /* RF TX Power control */
+#define RF_SYN_G2 0x26 /* RF TX Power control */
+#define RF_SYN_G3 0x27 /* RF TX Power control */
+#define RF_SYN_G4 0x28 /* RF TX Power control */
+#define RF_SYN_G5 0x29 /* RF TX Power control */
+#define RF_SYN_G6 0x2A /* RF TX Power control */
+#define RF_SYN_G7 0x2B /* RF TX Power control */
+#define RF_SYN_G8 0x2C /* RF TX Power control */
+
+#define RF_RCK_OS 0x30 /* RF TX PA control */
+
+#define RF_TXPA_G1 0x31 /* RF TX PA control */
+#define RF_TXPA_G2 0x32 /* RF TX PA control */
+#define RF_TXPA_G3 0x33 /* RF TX PA control */
+
+/*
+ * Bit Mask
+ *
+ * 1. Page1(0x100) */
+#define bBBResetB 0x100 /* Useless now? */
+#define bGlobalResetB 0x200
+#define bOFDMTxStart 0x4
+#define bCCKTxStart 0x8
+#define bCRC32Debug 0x100
+#define bPMACLoopback 0x10
+#define bTxLSIG 0xffffff
+#define bOFDMTxRate 0xf
+#define bOFDMTxReserved 0x10
+#define bOFDMTxLength 0x1ffe0
+#define bOFDMTxParity 0x20000
+#define bTxHTSIG1 0xffffff
+#define bTxHTMCSRate 0x7f
+#define bTxHTBW 0x80
+#define bTxHTLength 0xffff00
+#define bTxHTSIG2 0xffffff
+#define bTxHTSmoothing 0x1
+#define bTxHTSounding 0x2
+#define bTxHTReserved 0x4
+#define bTxHTAggreation 0x8
+#define bTxHTSTBC 0x30
+#define bTxHTAdvanceCoding 0x40
+#define bTxHTShortGI 0x80
+#define bTxHTNumberHT_LTF 0x300
+#define bTxHTCRC8 0x3fc00
+#define bCounterReset 0x10000
+#define bNumOfOFDMTx 0xffff
+#define bNumOfCCKTx 0xffff0000
+#define bTxIdleInterval 0xffff
+#define bOFDMService 0xffff0000
+#define bTxMACHeader 0xffffffff
+#define bTxDataInit 0xff
+#define bTxHTMode 0x100
+#define bTxDataType 0x30000
+#define bTxRandomSeed 0xffffffff
+#define bCCKTxPreamble 0x1
+#define bCCKTxSFD 0xffff0000
+#define bCCKTxSIG 0xff
+#define bCCKTxService 0xff00
+#define bCCKLengthExt 0x8000
+#define bCCKTxLength 0xffff0000
+#define bCCKTxCRC16 0xffff
+#define bCCKTxStatus 0x1
+#define bOFDMTxStatus 0x2
+#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && \
+ (_Offset <= 0xfff))
+
+/* 2. Page8(0x800) */
+#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */
+#define bJapanMode 0x2
+#define bCCKTxSC 0x30
+#define bCCKEn 0x1000000
+#define bOFDMEn 0x2000000
+
+#define bOFDMRxADCPhase 0x10000 /* Useless now */
+#define bOFDMTxDACPhase 0x40000
+#define bXATxAGC 0x3f
+#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */
+#define bXCTxAGC 0xf000
+#define bXDTxAGC 0xf0000
+
+#define bPAStart 0xf0000000 /* Useless now */
+#define bTRStart 0x00f00000
+#define bRFStart 0x0000f000
+#define bBBStart 0x000000f0
+#define bBBCCKStart 0x0000000f
+#define bPAEnd 0xf /* Reg0x814 */
+#define bTREnd 0x0f000000
+#define bRFEnd 0x000f0000
+#define bCCAMask 0x000000f0 /* T2R */
+#define bR2RCCAMask 0x00000f00
+#define bHSSI_R2TDelay 0xf8000000
+#define bHSSI_T2RDelay 0xf80000
+#define bContTxHSSI 0x400 /* change gain at continue Tx */
+#define bIGFromCCK 0x200
+#define bAGCAddress 0x3f
+#define bRxHPTx 0x7000
+#define bRxHPT2R 0x38000
+#define bRxHPCCKIni 0xc0000
+#define bAGCTxCode 0xc00000
+#define bAGCRxCode 0x300000
+#define b3WireDataLength 0x800 /* Reg 0x820~84f rFPGA0_XA_HSSIParm1 */
+#define b3WireAddressLength 0x400
+#define b3WireRFPowerDown 0x1 /* Useless now */
+#define b5GPAPEPolarity 0x40000000
+#define b2GPAPEPolarity 0x80000000
+#define bRFSW_TxDefaultAnt 0x3
+#define bRFSW_TxOptionAnt 0x30
+#define bRFSW_RxDefaultAnt 0x300
+#define bRFSW_RxOptionAnt 0x3000
+#define bRFSI_3WireData 0x1
+#define bRFSI_3WireClock 0x2
+#define bRFSI_3WireLoad 0x4
+#define bRFSI_3WireRW 0x8
+#define bRFSI_3Wire 0xf
+#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */
+#define bRFSI_TRSW 0x20 /* Useless now */
+#define bRFSI_TRSWB 0x40
+#define bRFSI_ANTSW 0x100
+#define bRFSI_ANTSWB 0x200
+#define bRFSI_PAPE 0x400
+#define bRFSI_PAPE5G 0x800
+#define bBandSelect 0x1
+#define bHTSIG2_GI 0x80
+#define bHTSIG2_Smoothing 0x01
+#define bHTSIG2_Sounding 0x02
+#define bHTSIG2_Aggreaton 0x08
+#define bHTSIG2_STBC 0x30
+#define bHTSIG2_AdvCoding 0x40
+#define bHTSIG2_NumOfHTLTF 0x300
+#define bHTSIG2_CRC8 0x3fc
+#define bHTSIG1_MCS 0x7f
+#define bHTSIG1_BandWidth 0x80
+#define bHTSIG1_HTLength 0xffff
+#define bLSIG_Rate 0xf
+#define bLSIG_Reserved 0x10
+#define bLSIG_Length 0x1fffe
+#define bLSIG_Parity 0x20
+#define bCCKRxPhase 0x4
+#define bLSSIReadAddress 0x7f800000 /* T65 RF */
+#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */
+#define bLSSIReadBackData 0xfffff /* T65 RF */
+#define bLSSIReadOKFlag 0x1000 /* Useless now */
+#define bCCKSampleRate 0x8 /*0: 44MHz, 1:88MHz*/
+#define bRegulator0Standby 0x1
+#define bRegulatorPLLStandby 0x2
+#define bRegulator1Standby 0x4
+#define bPLLPowerUp 0x8
+#define bDPLLPowerUp 0x10
+#define bDA10PowerUp 0x20
+#define bAD7PowerUp 0x200
+#define bDA6PowerUp 0x2000
+#define bXtalPowerUp 0x4000
+#define b40MDClkPowerUP 0x8000
+#define bDA6DebugMode 0x20000
+#define bDA6Swing 0x380000
+
+/* Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */
+#define bADClkPhase 0x4000000
+
+#define b80MClkDelay 0x18000000 /* Useless */
+#define bAFEWatchDogEnable 0x20000000
+
+/* Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap */
+#define bXtalCap01 0xc0000000
+#define bXtalCap23 0x3
+#define bXtalCap92x 0x0f000000
+#define bXtalCap 0x0f000000
+#define bIntDifClkEnable 0x400 /* Useless */
+#define bExtSigClkEnable 0x800
+#define bBandgapMbiasPowerUp 0x10000
+#define bAD11SHGain 0xc0000
+#define bAD11InputRange 0x700000
+#define bAD11OPCurrent 0x3800000
+#define bIPathLoopback 0x4000000
+#define bQPathLoopback 0x8000000
+#define bAFELoopback 0x10000000
+#define bDA10Swing 0x7e0
+#define bDA10Reverse 0x800
+#define bDAClkSource 0x1000
+#define bAD7InputRange 0x6000
+#define bAD7Gain 0x38000
+#define bAD7OutputCMMode 0x40000
+#define bAD7InputCMMode 0x380000
+#define bAD7Current 0xc00000
+#define bRegulatorAdjust 0x7000000
+#define bAD11PowerUpAtTx 0x1
+#define bDA10PSAtTx 0x10
+#define bAD11PowerUpAtRx 0x100
+#define bDA10PSAtRx 0x1000
+#define bCCKRxAGCFormat 0x200
+#define bPSDFFTSamplepPoint 0xc000
+#define bPSDAverageNum 0x3000
+#define bIQPathControl 0xc00
+#define bPSDFreq 0x3ff
+#define bPSDAntennaPath 0x30
+#define bPSDIQSwitch 0x40
+#define bPSDRxTrigger 0x400000
+#define bPSDTxTrigger 0x80000000
+#define bPSDSineToneScale 0x7f000000
+#define bPSDReport 0xffff
+
+/* 3. Page9(0x900) */
+#define bOFDMTxSC 0x30000000 /* Useless */
+#define bCCKTxOn 0x1
+#define bOFDMTxOn 0x2
+#define bDebugPage 0xfff /* reset debug page and HWord, LWord */
+#define bDebugItem 0xff /* reset debug page and LWord */
+#define bAntL 0x10
+#define bAntNonHT 0x100
+#define bAntHT1 0x1000
+#define bAntHT2 0x10000
+#define bAntHT1S1 0x100000
+#define bAntNonHTS1 0x1000000
+
+/* 4. PageA(0xA00) */
+#define bCCKBBMode 0x3 /* Useless */
+#define bCCKTxPowerSaving 0x80
+#define bCCKRxPowerSaving 0x40
+
+#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0_System 20/40 switch*/
+#define bCCKScramble 0x8 /* Useless */
+#define bCCKAntDiversity 0x8000
+#define bCCKCarrierRecovery 0x4000
+#define bCCKTxRate 0x3000
+#define bCCKDCCancel 0x0800
+#define bCCKISICancel 0x0400
+#define bCCKMatchFilter 0x0200
+#define bCCKEqualizer 0x0100
+#define bCCKPreambleDetect 0x800000
+#define bCCKFastFalseCCA 0x400000
+#define bCCKChEstStart 0x300000
+#define bCCKCCACount 0x080000
+#define bCCKcs_lim 0x070000
+#define bCCKBistMode 0x80000000
+#define bCCKCCAMask 0x40000000
+#define bCCKTxDACPhase 0x4
+#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */
+#define bCCKr_cp_mode0 0x0100
+#define bCCKTxDCOffset 0xf0
+#define bCCKRxDCOffset 0xf
+#define bCCKCCAMode 0xc000
+#define bCCKFalseCS_lim 0x3f00
+#define bCCKCS_ratio 0xc00000
+#define bCCKCorgBit_sel 0x300000
+#define bCCKPD_lim 0x0f0000
+#define bCCKNewCCA 0x80000000
+#define bCCKRxHPofIG 0x8000
+#define bCCKRxIG 0x7f00
+#define bCCKLNAPolarity 0x800000
+#define bCCKRx1stGain 0x7f0000
+#define bCCKRFExtend 0x20000000 /* CCK Rx Iinital gain polarity */
+#define bCCKRxAGCSatLevel 0x1f000000
+#define bCCKRxAGCSatCount 0xe0
+#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */
+#define bCCKFixedRxAGC 0x8000
+#define bCCKAntennaPolarity 0x2000
+#define bCCKTxFilterType 0x0c00
+#define bCCKRxAGCReportType 0x0300
+#define bCCKRxDAGCEn 0x80000000
+#define bCCKRxDAGCPeriod 0x20000000
+#define bCCKRxDAGCSatLevel 0x1f000000
+#define bCCKTimingRecovery 0x800000
+#define bCCKTxC0 0x3f0000
+#define bCCKTxC1 0x3f000000
+#define bCCKTxC2 0x3f
+#define bCCKTxC3 0x3f00
+#define bCCKTxC4 0x3f0000
+#define bCCKTxC5 0x3f000000
+#define bCCKTxC6 0x3f
+#define bCCKTxC7 0x3f00
+#define bCCKDebugPort 0xff0000
+#define bCCKDACDebug 0x0f000000
+#define bCCKFalseAlarmEnable 0x8000
+#define bCCKFalseAlarmRead 0x4000
+#define bCCKTRSSI 0x7f
+#define bCCKRxAGCReport 0xfe
+#define bCCKRxReport_AntSel 0x80000000
+#define bCCKRxReport_MFOff 0x40000000
+#define bCCKRxRxReport_SQLoss 0x20000000
+#define bCCKRxReport_Pktloss 0x10000000
+#define bCCKRxReport_Lockedbit 0x08000000
+#define bCCKRxReport_RateError 0x04000000
+#define bCCKRxReport_RxRate 0x03000000
+#define bCCKRxFACounterLower 0xff
+#define bCCKRxFACounterUpper 0xff000000
+#define bCCKRxHPAGCStart 0xe000
+#define bCCKRxHPAGCFinal 0x1c00
+#define bCCKRxFalseAlarmEnable 0x8000
+#define bCCKFACounterFreeze 0x4000
+#define bCCKTxPathSel 0x10000000
+#define bCCKDefaultRxPath 0xc000000
+#define bCCKOptionRxPath 0x3000000
+
+/* 5. PageC(0xC00) */
+#define bNumOfSTF 0x3 /* Useless */
+#define bShift_L 0xc0
+#define bGI_TH 0xc
+#define bRxPathA 0x1
+#define bRxPathB 0x2
+#define bRxPathC 0x4
+#define bRxPathD 0x8
+#define bTxPathA 0x1
+#define bTxPathB 0x2
+#define bTxPathC 0x4
+#define bTxPathD 0x8
+#define bTRSSIFreq 0x200
+#define bADCBackoff 0x3000
+#define bDFIRBackoff 0xc000
+#define bTRSSILatchPhase 0x10000
+#define bRxIDCOffset 0xff
+#define bRxQDCOffset 0xff00
+#define bRxDFIRMode 0x1800000
+#define bRxDCNFType 0xe000000
+#define bRXIQImb_A 0x3ff
+#define bRXIQImb_B 0xfc00
+#define bRXIQImb_C 0x3f0000
+#define bRXIQImb_D 0xffc00000
+#define bDC_dc_Notch 0x60000
+#define bRxNBINotch 0x1f000000
+#define bPD_TH 0xf
+#define bPD_TH_Opt2 0xc000
+#define bPWED_TH 0x700
+#define bIfMF_Win_L 0x800
+#define bPD_Option 0x1000
+#define bMF_Win_L 0xe000
+#define bBW_Search_L 0x30000
+#define bwin_enh_L 0xc0000
+#define bBW_TH 0x700000
+#define bED_TH2 0x3800000
+#define bBW_option 0x4000000
+#define bRatio_TH 0x18000000
+#define bWindow_L 0xe0000000
+#define bSBD_Option 0x1
+#define bFrame_TH 0x1c
+#define bFS_Option 0x60
+#define bDC_Slope_check 0x80
+#define bFGuard_Counter_DC_L 0xe00
+#define bFrame_Weight_Short 0x7000
+#define bSub_Tune 0xe00000
+#define bFrame_DC_Length 0xe000000
+#define bSBD_start_offset 0x30000000
+#define bFrame_TH_2 0x7
+#define bFrame_GI2_TH 0x38
+#define bGI2_Sync_en 0x40
+#define bSarch_Short_Early 0x300
+#define bSarch_Short_Late 0xc00
+#define bSarch_GI2_Late 0x70000
+#define bCFOAntSum 0x1
+#define bCFOAcc 0x2
+#define bCFOStartOffset 0xc
+#define bCFOLookBack 0x70
+#define bCFOSumWeight 0x80
+#define bDAGCEnable 0x10000
+#define bTXIQImb_A 0x3ff
+#define bTXIQImb_B 0xfc00
+#define bTXIQImb_C 0x3f0000
+#define bTXIQImb_D 0xffc00000
+#define bTxIDCOffset 0xff
+#define bTxQDCOffset 0xff00
+#define bTxDFIRMode 0x10000
+#define bTxPesudoNoiseOn 0x4000000
+#define bTxPesudoNoise_A 0xff
+#define bTxPesudoNoise_B 0xff00
+#define bTxPesudoNoise_C 0xff0000
+#define bTxPesudoNoise_D 0xff000000
+#define bCCADropOption 0x20000
+#define bCCADropThres 0xfff00000
+#define bEDCCA_H 0xf
+#define bEDCCA_L 0xf0
+#define bLambda_ED 0x300
+#define bRxInitialGain 0x7f
+#define bRxAntDivEn 0x80
+#define bRxAGCAddressForLNA 0x7f00
+#define bRxHighPowerFlow 0x8000
+#define bRxAGCFreezeThres 0xc0000
+#define bRxFreezeStep_AGC1 0x300000
+#define bRxFreezeStep_AGC2 0xc00000
+#define bRxFreezeStep_AGC3 0x3000000
+#define bRxFreezeStep_AGC0 0xc000000
+#define bRxRssi_Cmp_En 0x10000000
+#define bRxQuickAGCEn 0x20000000
+#define bRxAGCFreezeThresMode 0x40000000
+#define bRxOverFlowCheckType 0x80000000
+#define bRxAGCShift 0x7f
+#define bTRSW_Tri_Only 0x80
+#define bPowerThres 0x300
+#define bRxAGCEn 0x1
+#define bRxAGCTogetherEn 0x2
+#define bRxAGCMin 0x4
+#define bRxHP_Ini 0x7
+#define bRxHP_TRLNA 0x70
+#define bRxHP_RSSI 0x700
+#define bRxHP_BBP1 0x7000
+#define bRxHP_BBP2 0x70000
+#define bRxHP_BBP3 0x700000
+#define bRSSI_H 0x7f0000 /* the threshold for high power */
+#define bRSSI_Gen 0x7f000000 /* the threshold for ant divers */
+#define bRxSettle_TRSW 0x7
+#define bRxSettle_LNA 0x38
+#define bRxSettle_RSSI 0x1c0
+#define bRxSettle_BBP 0xe00
+#define bRxSettle_RxHP 0x7000
+#define bRxSettle_AntSW_RSSI 0x38000
+#define bRxSettle_AntSW 0xc0000
+#define bRxProcessTime_DAGC 0x300000
+#define bRxSettle_HSSI 0x400000
+#define bRxProcessTime_BBPPW 0x800000
+#define bRxAntennaPowerShift 0x3000000
+#define bRSSITableSelect 0xc000000
+#define bRxHP_Final 0x7000000
+#define bRxHTSettle_BBP 0x7
+#define bRxHTSettle_HSSI 0x8
+#define bRxHTSettle_RxHP 0x70
+#define bRxHTSettle_BBPPW 0x80
+#define bRxHTSettle_Idle 0x300
+#define bRxHTSettle_Reserved 0x1c00
+#define bRxHTRxHPEn 0x8000
+#define bRxHTAGCFreezeThres 0x30000
+#define bRxHTAGCTogetherEn 0x40000
+#define bRxHTAGCMin 0x80000
+#define bRxHTAGCEn 0x100000
+#define bRxHTDAGCEn 0x200000
+#define bRxHTRxHP_BBP 0x1c00000
+#define bRxHTRxHP_Final 0xe0000000
+#define bRxPWRatioTH 0x3
+#define bRxPWRatioEn 0x4
+#define bRxMFHold 0x3800
+#define bRxPD_Delay_TH1 0x38
+#define bRxPD_Delay_TH2 0x1c0
+#define bRxPD_DC_COUNT_MAX 0x600
+#define bRxPD_Delay_TH 0x8000
+#define bRxProcess_Delay 0xf0000
+#define bRxSearchrange_GI2_Early 0x700000
+#define bRxFrame_Guard_Counter_L 0x3800000
+#define bRxSGI_Guard_L 0xc000000
+#define bRxSGI_Search_L 0x30000000
+#define bRxSGI_TH 0xc0000000
+#define bDFSCnt0 0xff
+#define bDFSCnt1 0xff00
+#define bDFSFlag 0xf0000
+#define bMFWeightSum 0x300000
+#define bMinIdxTH 0x7f000000
+#define bDAFormat 0x40000
+#define bTxChEmuEnable 0x01000000
+#define bTRSWIsolation_A 0x7f
+#define bTRSWIsolation_B 0x7f00
+#define bTRSWIsolation_C 0x7f0000
+#define bTRSWIsolation_D 0x7f000000
+#define bExtLNAGain 0x7c00
+
+/* 6. PageE(0xE00) */
+#define bSTBCEn 0x4 /* Useless */
+#define bAntennaMapping 0x10
+#define bNss 0x20
+#define bCFOAntSumD 0x200
+#define bPHYCounterReset 0x8000000
+#define bCFOReportGet 0x4000000
+#define bOFDMContinueTx 0x10000000
+#define bOFDMSingleCarrier 0x20000000
+#define bOFDMSingleTone 0x40000000
+#define bHTDetect 0x100
+#define bCFOEn 0x10000
+#define bCFOValue 0xfff00000
+#define bSigTone_Re 0x3f
+#define bSigTone_Im 0x7f00
+#define bCounter_CCA 0xffff
+#define bCounter_ParityFail 0xffff0000
+#define bCounter_RateIllegal 0xffff
+#define bCounter_CRC8Fail 0xffff0000
+#define bCounter_MCSNoSupport 0xffff
+#define bCounter_FastSync 0xffff
+#define bShortCFO 0xfff
+#define bShortCFOTLength 12 /* total */
+#define bShortCFOFLength 11 /* fraction */
+#define bLongCFO 0x7ff
+#define bLongCFOTLength 11
+#define bLongCFOFLength 11
+#define bTailCFO 0x1fff
+#define bTailCFOTLength 13
+#define bTailCFOFLength 12
+#define bmax_en_pwdB 0xffff
+#define bCC_power_dB 0xffff0000
+#define bnoise_pwdB 0xffff
+#define bPowerMeasTLength 10
+#define bPowerMeasFLength 3
+#define bRx_HT_BW 0x1
+#define bRxSC 0x6
+#define bRx_HT 0x8
+#define bNB_intf_det_on 0x1
+#define bIntf_win_len_cfg 0x30
+#define bNB_Intf_TH_cfg 0x1c0
+#define bRFGain 0x3f
+#define bTableSel 0x40
+#define bTRSW 0x80
+#define bRxSNR_A 0xff
+#define bRxSNR_B 0xff00
+#define bRxSNR_C 0xff0000
+#define bRxSNR_D 0xff000000
+#define bSNREVMTLength 8
+#define bSNREVMFLength 1
+#define bCSI1st 0xff
+#define bCSI2nd 0xff00
+#define bRxEVM1st 0xff0000
+#define bRxEVM2nd 0xff000000
+#define bSIGEVM 0xff
+#define bPWDB 0xff00
+#define bSGIEN 0x10000
+
+#define bSFactorQAM1 0xf /* Useless */
+#define bSFactorQAM2 0xf0
+#define bSFactorQAM3 0xf00
+#define bSFactorQAM4 0xf000
+#define bSFactorQAM5 0xf0000
+#define bSFactorQAM6 0xf0000
+#define bSFactorQAM7 0xf00000
+#define bSFactorQAM8 0xf000000
+#define bSFactorQAM9 0xf0000000
+#define bCSIScheme 0x100000
+
+#define bNoiseLvlTopSet 0x3 /* Useless */
+#define bChSmooth 0x4
+#define bChSmoothCfg1 0x38
+#define bChSmoothCfg2 0x1c0
+#define bChSmoothCfg3 0xe00
+#define bChSmoothCfg4 0x7000
+#define bMRCMode 0x800000
+#define bTHEVMCfg 0x7000000
+
+#define bLoopFitType 0x1 /* Useless */
+#define bUpdCFO 0x40
+#define bUpdCFOOffData 0x80
+#define bAdvUpdCFO 0x100
+#define bAdvTimeCtrl 0x800
+#define bUpdClko 0x1000
+#define bFC 0x6000
+#define bTrackingMode 0x8000
+#define bPhCmpEnable 0x10000
+#define bUpdClkoLTF 0x20000
+#define bComChCFO 0x40000
+#define bCSIEstiMode 0x80000
+#define bAdvUpdEqz 0x100000
+#define bUChCfg 0x7000000
+#define bUpdEqz 0x8000000
+
+#define bTxAGCRate18_06 0x7f7f7f7f /* Useless */
+#define bTxAGCRate54_24 0x7f7f7f7f
+#define bTxAGCRateMCS32 0x7f
+#define bTxAGCRateCCK 0x7f00
+#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
+#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
+#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
+#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
+
+/* Rx Pseduo noise */
+#define bRxPesudoNoiseOn 0x20000000 /* Useless */
+#define bRxPesudoNoise_A 0xff
+#define bRxPesudoNoise_B 0xff00
+#define bRxPesudoNoise_C 0xff0000
+#define bRxPesudoNoise_D 0xff000000
+#define bPesudoNoiseState_A 0xffff
+#define bPesudoNoiseState_B 0xffff0000
+#define bPesudoNoiseState_C 0xffff
+#define bPesudoNoiseState_D 0xffff0000
+
+/* 7. RF Register
+ * Zebra1 */
+#define bZebra1_HSSIEnable 0x8 /* Useless */
+#define bZebra1_TRxControl 0xc00
+#define bZebra1_TRxGainSetting 0x07f
+#define bZebra1_RxCorner 0xc00
+#define bZebra1_TxChargePump 0x38
+#define bZebra1_RxChargePump 0x7
+#define bZebra1_ChannelNum 0xf80
+#define bZebra1_TxLPFBW 0x400
+#define bZebra1_RxLPFBW 0x600
+
+/*Zebra4 */
+#define bRTL8256RegModeCtrl1 0x100 /* Useless */
+#define bRTL8256RegModeCtrl0 0x40
+#define bRTL8256_TxLPFBW 0x18
+#define bRTL8256_RxLPFBW 0x600
+
+/* RTL8258 */
+#define bRTL8258_TxLPFBW 0xc /* Useless */
+#define bRTL8258_RxLPFBW 0xc00
+#define bRTL8258_RSSILPFBW 0xc0
+
+/*
+ * Other Definition
+ */
+
+/* byte endable for sb_write */
+#define bByte0 0x1 /* Useless */
+#define bByte1 0x2
+#define bByte2 0x4
+#define bByte3 0x8
+#define bWord0 0x3
+#define bWord1 0xc
+#define bDWord 0xf
+
+/* for PutRegsetting & GetRegSetting BitMask */
+#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+/* for PutRFRegsetting & GetRFRegSetting BitMask */
+#define bRFRegOffsetMask 0xfffff
+#define bEnable 0x1 /* Useless */
+#define bDisable 0x0
+
+#define LeftAntenna 0x0 /* Useless */
+#define RightAntenna 0x1
+
+#define tCheckTxStatus 500 /* 500ms Useless */
+#define tUpdateRxCounter 100 /* 100ms */
+
+#define rateCCK 0 /* Useless */
+#define rateOFDM 1
+#define rateHT 2
+
+/* define Register-End */
+#define bPMAC_End 0x1ff /* Useless */
+#define bFPGAPHY0_End 0x8ff
+#define bFPGAPHY1_End 0x9ff
+#define bCCKPHY0_End 0xaff
+#define bOFDMPHY0_End 0xcff
+#define bOFDMPHY1_End 0xdff
+
+#define bPMACControl 0x0 /* Useless */
+#define bWMACControl 0x1
+#define bWNICControl 0x2
+
+#define ANTENNA_A 0x1 /* Useless */
+#define ANTENNA_B 0x2
+#define ANTENNA_AB 0x3 /* ANTENNA_A |ANTENNA_B */
+
+#define ANTENNA_C 0x4
+#define ANTENNA_D 0x8
+
+
+/* accept all physical address */
+#define RCR_AAP BIT(0)
+#define RCR_APM BIT(1) /* accept physical match */
+#define RCR_AM BIT(2) /* accept multicast */
+#define RCR_AB BIT(3) /* accept broadcast */
+#define RCR_ACRC32 BIT(5) /* accept error packet */
+#define RCR_9356SEL BIT(6)
+#define RCR_AICV BIT(12) /* Accept ICV error packet */
+#define RCR_RXFTH0 (BIT(13)|BIT(14)|BIT(15)) /* Rx FIFO threshold */
+#define RCR_ADF BIT(18) /* Accept Data(frame type) frame */
+#define RCR_ACF BIT(19) /* Accept control frame */
+#define RCR_AMF BIT(20) /* Accept management frame */
+#define RCR_ADD3 BIT(21)
+#define RCR_APWRMGT BIT(22) /* Accept power management packet */
+#define RCR_CBSSID BIT(23) /* Accept BSSID match packet */
+#define RCR_ENMARP BIT(28) /* enable mac auto reset phy */
+#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */
+#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */
+/* Rx Early mode is performed for packet size greater than 1536 */
+#define RCR_OnlyErlPkt BIT(31)
+
+/*--------------------------Define Parameters-------------------------------*/
+
+
+#endif /*__INC_HAL8192SPHYREG_H */
+
diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.c b/drivers/staging/rtl8712/rtl871x_pwrctrl.c
new file mode 100644
index 000000000000..9244c8a6d943
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.c
@@ -0,0 +1,250 @@
+/******************************************************************************
+ * rtl871x_pwrctrl.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_PWRCTRL_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "osdep_intf.h"
+
+#define RTL8712_SDIO_LOCAL_BASE 0X10100000
+#define SDIO_HCPWM (RTL8712_SDIO_LOCAL_BASE + 0x0081)
+
+void r8712_set_rpwm(struct _adapter *padapter, u8 val8)
+{
+ u8 rpwm;
+ struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
+
+ if (pwrpriv->rpwm == val8) {
+ if (pwrpriv->rpwm_retry == 0)
+ return;
+ }
+ if ((padapter->bDriverStopped == true) ||
+ (padapter->bSurpriseRemoved == true))
+ return;
+ rpwm = val8 | pwrpriv->tog;
+ switch (val8) {
+ case PS_STATE_S1:
+ pwrpriv->cpwm = val8;
+ break;
+ case PS_STATE_S2:/* only for USB normal powersave mode use,
+ * temp mark some code. */
+ case PS_STATE_S3:
+ case PS_STATE_S4:
+ pwrpriv->cpwm = val8;
+ break;
+ default:
+ break;
+ }
+ pwrpriv->rpwm_retry = 0;
+ pwrpriv->rpwm = val8;
+ r8712_write8(padapter, 0x1025FE58, rpwm);
+ pwrpriv->tog += 0x80;
+}
+
+void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode, uint smart_ps)
+{
+ struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
+
+ if (ps_mode > PM_Card_Disable)
+ return;
+ /* if driver is in active state, we dont need set smart_ps.*/
+ if (ps_mode == PS_MODE_ACTIVE)
+ smart_ps = 0;
+ if ((pwrpriv->pwr_mode != ps_mode) || (pwrpriv->smart_ps != smart_ps)) {
+ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
+ pwrpriv->bSleep = true;
+ else
+ pwrpriv->bSleep = false;
+ pwrpriv->pwr_mode = ps_mode;
+ pwrpriv->smart_ps = smart_ps;
+ _set_workitem(&(pwrpriv->SetPSModeWorkItem));
+ }
+}
+
+/*
+ * Caller:ISR handler...
+ *
+ * This will be called when CPWM interrupt is up.
+ *
+ * using to update cpwn of drv; and drv willl make a decision to up or
+ * down pwr level
+ */
+void r8712_cpwm_int_hdl(struct _adapter *padapter,
+ struct reportpwrstate_parm *preportpwrstate)
+{
+ struct pwrctrl_priv *pwrpriv = &(padapter->pwrctrlpriv);
+ struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
+ struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
+
+ if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80))
+ return;
+ _cancel_timer_ex(&padapter->pwrctrlpriv. rpwm_check_timer);
+ _enter_pwrlock(&pwrpriv->lock);
+ pwrpriv->cpwm = (preportpwrstate->state) & 0xf;
+ if (pwrpriv->cpwm >= PS_STATE_S2) {
+ if (pwrpriv->alives & CMD_ALIVE)
+ up(&(pcmdpriv->cmd_queue_sema));
+ if (pwrpriv->alives & XMIT_ALIVE)
+ up(&(pxmitpriv->xmit_sema));
+ }
+ pwrpriv->cpwm_tog = (preportpwrstate->state) & 0x80;
+ up(&pwrpriv->lock);
+}
+
+static inline void register_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
+{
+ pwrctrl->alives |= tag;
+}
+
+static inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
+{
+ if (pwrctrl->alives & tag)
+ pwrctrl->alives ^= tag;
+}
+
+static void _rpwm_check_handler (struct _adapter *padapter)
+{
+ struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
+
+ if (padapter->bDriverStopped == true ||
+ padapter->bSurpriseRemoved == true)
+ return;
+ if (pwrpriv->cpwm != pwrpriv->rpwm)
+ _set_workitem(&(pwrpriv->rpwm_workitem));
+}
+
+static void SetPSModeWorkItemCallback(struct work_struct *work)
+{
+ struct pwrctrl_priv *pwrpriv = container_of(work,
+ struct pwrctrl_priv, SetPSModeWorkItem);
+ struct _adapter *padapter = container_of(pwrpriv,
+ struct _adapter, pwrctrlpriv);
+ _enter_pwrlock(&pwrpriv->lock);
+ if (!pwrpriv->bSleep) {
+ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
+ r8712_set_rpwm(padapter, PS_STATE_S4);
+ }
+ up(&pwrpriv->lock);
+}
+
+static void rpwm_workitem_callback(struct work_struct *work)
+{
+ struct pwrctrl_priv *pwrpriv = container_of(work,
+ struct pwrctrl_priv, rpwm_workitem);
+ struct _adapter *padapter = container_of(pwrpriv,
+ struct _adapter, pwrctrlpriv);
+ u8 cpwm = pwrpriv->cpwm;
+ _enter_pwrlock(&pwrpriv->lock);
+ if (pwrpriv->cpwm != pwrpriv->rpwm) {
+ cpwm = r8712_read8(padapter, SDIO_HCPWM);
+ pwrpriv->rpwm_retry = 1;
+ r8712_set_rpwm(padapter, pwrpriv->rpwm);
+ }
+ up(&pwrpriv->lock);
+}
+
+static void rpwm_check_handler (void *FunctionContext)
+{
+ struct _adapter *adapter = (struct _adapter *)FunctionContext;
+ _rpwm_check_handler(adapter);
+}
+
+void r8712_init_pwrctrl_priv(struct _adapter *padapter)
+{
+ struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
+
+ memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv));
+ sema_init(&pwrctrlpriv->lock, 1);
+ pwrctrlpriv->cpwm = PS_STATE_S4;
+ pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
+ pwrctrlpriv->smart_ps = 0;
+ pwrctrlpriv->tog = 0x80;
+/* clear RPWM to ensure driver and fw back to initial state. */
+ r8712_write8(padapter, 0x1025FE58, 0);
+ _init_workitem(&(pwrctrlpriv->SetPSModeWorkItem),
+ SetPSModeWorkItemCallback, padapter);
+ _init_workitem(&(pwrctrlpriv->rpwm_workitem),
+ rpwm_workitem_callback, padapter);
+ _init_timer(&(pwrctrlpriv->rpwm_check_timer),
+ padapter->pnetdev, rpwm_check_handler, (u8 *)padapter);
+}
+
+/*
+Caller: r8712_cmd_thread
+
+Check if the fw_pwrstate is okay for issuing cmd.
+If not (cpwm should be is less than P2 state), then the sub-routine
+will raise the cpwm to be greater than or equal to P2.
+
+Calling Context: Passive
+
+Return Value:
+
+_SUCCESS: r8712_cmd_thread can issue cmds to firmware afterwards.
+_FAIL: r8712_cmd_thread can not do anything.
+*/
+sint r8712_register_cmd_alive(struct _adapter *padapter)
+{
+ uint res = _SUCCESS;
+ struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
+
+ _enter_pwrlock(&pwrctrl->lock);
+ register_task_alive(pwrctrl, CMD_ALIVE);
+ if (pwrctrl->cpwm < PS_STATE_S2) {
+ r8712_set_rpwm(padapter, PS_STATE_S3);
+ res = _FAIL;
+ }
+ up(&pwrctrl->lock);
+ return res;
+}
+
+/*
+Caller: ISR
+
+If ISR's txdone,
+No more pkts for TX,
+Then driver shall call this fun. to power down firmware again.
+*/
+
+void r8712_unregister_cmd_alive(struct _adapter *padapter)
+{
+ struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
+
+ _enter_pwrlock(&pwrctrl->lock);
+ unregister_task_alive(pwrctrl, CMD_ALIVE);
+ if ((pwrctrl->cpwm > PS_STATE_S2) &&
+ (pwrctrl->pwr_mode > PS_MODE_ACTIVE)) {
+ if ((pwrctrl->alives == 0) &&
+ (check_fwstate(&padapter->mlmepriv,
+ _FW_UNDER_LINKING) != true)) {
+ r8712_set_rpwm(padapter, PS_STATE_S0);
+ }
+ }
+ up(&pwrctrl->lock);
+}
diff --git a/drivers/staging/rtl8712/rtl871x_pwrctrl.h b/drivers/staging/rtl8712/rtl871x_pwrctrl.h
new file mode 100644
index 000000000000..34f074aebd69
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_pwrctrl.h
@@ -0,0 +1,127 @@
+#ifndef __RTL871X_PWRCTRL_H_
+#define __RTL871X_PWRCTRL_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+
+#define FW_PWR0 0
+#define FW_PWR1 1
+#define FW_PWR2 2
+#define FW_PWR3 3
+
+
+#define HW_PWR0 7
+#define HW_PWR1 6
+#define HW_PWR2 2
+#define HW_PWR3 0
+#define HW_PWR4 8
+
+#define FW_PWRMSK 0x7
+
+
+#define XMIT_ALIVE BIT(0)
+#define RECV_ALIVE BIT(1)
+#define CMD_ALIVE BIT(2)
+#define EVT_ALIVE BIT(3)
+
+
+enum Power_Mgnt {
+ PS_MODE_ACTIVE = 0 ,
+ PS_MODE_MIN ,
+ PS_MODE_MAX ,
+ PS_MODE_DTIM ,
+ PS_MODE_VOIP ,
+ PS_MODE_UAPSD_WMM ,
+ PS_MODE_UAPSD ,
+ PS_MODE_IBSS ,
+ PS_MODE_WWLAN ,
+ PM_Radio_Off ,
+ PM_Card_Disable ,
+ PS_MODE_NUM
+};
+
+
+/*
+ BIT[2:0] = HW state
+ BIT[3] = Protocol PS state, 0: register active state,
+ 1: register sleep state
+ BIT[4] = sub-state
+*/
+
+#define PS_DPS BIT(0)
+#define PS_LCLK (PS_DPS)
+#define PS_RF_OFF BIT(1)
+#define PS_ALL_ON BIT(2)
+#define PS_ST_ACTIVE BIT(3)
+#define PS_LP BIT(4) /* low performance */
+
+#define PS_STATE_MASK (0x0F)
+#define PS_STATE_HW_MASK (0x07)
+#define PS_SEQ_MASK (0xc0)
+
+#define PS_STATE(x) (PS_STATE_MASK & (x))
+#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x))
+#define PS_SEQ(x) (PS_SEQ_MASK & (x))
+
+#define PS_STATE_S0 (PS_DPS)
+#define PS_STATE_S1 (PS_LCLK)
+#define PS_STATE_S2 (PS_RF_OFF)
+#define PS_STATE_S3 (PS_ALL_ON)
+#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
+
+
+#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
+#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
+#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
+
+
+struct reportpwrstate_parm {
+ unsigned char mode;
+ unsigned char state; /* the CPWM value */
+ unsigned short rsvd;
+};
+
+static inline void _enter_pwrlock(struct semaphore *plock)
+{
+ _down_sema(plock);
+}
+
+struct pwrctrl_priv {
+ struct semaphore lock;
+ /*volatile*/ u8 rpwm; /* requested power state for fw */
+ /* fw current power state. updated when 1. read from HCPWM or
+ * 2. driver lowers power level */
+ /*volatile*/ u8 cpwm;
+ /*volatile*/ u8 tog; /* toggling */
+ /*volatile*/ u8 cpwm_tog; /* toggling */
+ /*volatile*/ u8 tgt_rpwm; /* wanted power state */
+ uint pwr_mode;
+ uint smart_ps;
+ uint alives;
+ uint ImrContent; /* used to store original imr. */
+ uint bSleep; /* sleep -> active is different from active -> sleep. */
+
+ _workitem SetPSModeWorkItem;
+ _workitem rpwm_workitem;
+ struct timer_list rpwm_check_timer;
+ u8 rpwm_retry;
+ uint bSetPSModeWorkItemInProgress;
+
+ struct semaphore pnp_pwr_mgnt_sema;
+ spinlock_t pnp_pwr_mgnt_lock;
+ s32 pnp_current_pwr_state;
+ u8 pnp_bstop_trx;
+ u8 pnp_wwirp_pending;
+};
+
+void r8712_init_pwrctrl_priv(struct _adapter *adapter);
+sint r8712_register_cmd_alive(struct _adapter *padapter);
+void r8712_unregister_cmd_alive(struct _adapter *padapter);
+void r8712_cpwm_int_hdl(struct _adapter *padapter,
+ struct reportpwrstate_parm *preportpwrstate);
+void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode,
+ uint smart_ps);
+void r8712_set_rpwm(struct _adapter *padapter, u8 val8);
+
+#endif /* __RTL871X_PWRCTRL_H_ */
diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
new file mode 100644
index 000000000000..a3165e67f857
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -0,0 +1,693 @@
+/******************************************************************************
+ * rtl871x_recv.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_RECV_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "mlme_osdep.h"
+#include "ip.h"
+#include "if_ether.h"
+#include "ethernet.h"
+#include "usb_ops.h"
+#include "wifi.h"
+
+static const u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
+
+/* Datagram Delivery Protocol */
+static const u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
+
+/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
+static const u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
+
+/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+static const u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
+
+void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
+{
+ memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv));
+ spin_lock_init(&psta_recvpriv->lock);
+ _init_queue(&psta_recvpriv->defrag_q);
+}
+
+sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
+ struct _adapter *padapter)
+{
+ sint i;
+ union recv_frame *precvframe;
+
+ memset((unsigned char *)precvpriv, 0, sizeof(struct recv_priv));
+ spin_lock_init(&precvpriv->lock);
+ _init_queue(&precvpriv->free_recv_queue);
+ _init_queue(&precvpriv->recv_pending_queue);
+ precvpriv->adapter = padapter;
+ precvpriv->free_recvframe_cnt = NR_RECVFRAME;
+ precvpriv->pallocated_frame_buf = _malloc(NR_RECVFRAME *
+ sizeof(union recv_frame) +
+ RXFRAME_ALIGN_SZ);
+ if (precvpriv->pallocated_frame_buf == NULL)
+ return _FAIL;
+ memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME *
+ sizeof(union recv_frame) + RXFRAME_ALIGN_SZ);
+ precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf +
+ RXFRAME_ALIGN_SZ -
+ ((addr_t)(precvpriv->pallocated_frame_buf) &
+ (RXFRAME_ALIGN_SZ-1));
+ precvframe = (union recv_frame *)precvpriv->precv_frame_buf;
+ for (i = 0; i < NR_RECVFRAME; i++) {
+ _init_listhead(&(precvframe->u.list));
+ list_insert_tail(&(precvframe->u.list),
+ &(precvpriv->free_recv_queue.queue));
+ r8712_os_recv_resource_alloc(padapter, precvframe);
+ precvframe->u.hdr.adapter = padapter;
+ precvframe++;
+ }
+ precvpriv->rx_pending_cnt = 1;
+ sema_init(&precvpriv->allrxreturnevt, 0);
+ return r8712_init_recv_priv(precvpriv, padapter);
+}
+
+void _r8712_free_recv_priv(struct recv_priv *precvpriv)
+{
+ kfree(precvpriv->pallocated_frame_buf);
+ r8712_free_recv_priv(precvpriv);
+}
+
+union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue)
+{
+ unsigned long irqL;
+ union recv_frame *precvframe;
+ struct list_head *plist, *phead;
+ struct _adapter *padapter;
+ struct recv_priv *precvpriv;
+
+ spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
+ if (_queue_empty(pfree_recv_queue) == true)
+ precvframe = NULL;
+ else {
+ phead = get_list_head(pfree_recv_queue);
+ plist = get_next(phead);
+ precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ list_delete(&precvframe->u.hdr.list);
+ padapter = precvframe->u.hdr.adapter;
+ if (padapter != NULL) {
+ precvpriv = &padapter->recvpriv;
+ if (pfree_recv_queue == &precvpriv->free_recv_queue)
+ precvpriv->free_recvframe_cnt--;
+ }
+ }
+ spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
+ return precvframe;
+}
+
+/*
+caller : defrag; recvframe_chk_defrag in recv_thread (passive)
+pframequeue: defrag_queue : will be accessed in recv_thread (passive)
+
+using spin_lock to protect
+
+*/
+
+void r8712_free_recvframe_queue(struct __queue *pframequeue,
+ struct __queue *pfree_recv_queue)
+{
+ union recv_frame *precvframe;
+ struct list_head *plist, *phead;
+
+ spin_lock(&pframequeue->lock);
+ phead = get_list_head(pframequeue);
+ plist = get_next(phead);
+ while (end_of_queue_search(phead, plist) == false) {
+ precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ plist = get_next(plist);
+ r8712_free_recvframe(precvframe, pfree_recv_queue);
+ }
+ spin_unlock(&pframequeue->lock);
+}
+
+sint r8712_recvframe_chkmic(struct _adapter *adapter,
+ union recv_frame *precvframe)
+{
+ sint i, res = _SUCCESS;
+ u32 datalen;
+ u8 miccode[8];
+ u8 bmic_err = false;
+ u8 *pframe, *payload, *pframemic;
+ u8 *mickey, idx, *iv;
+ struct sta_info *stainfo;
+ struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+
+ stainfo = r8712_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
+ if (prxattrib->encrypt == _TKIP_) {
+ /* calculate mic code */
+ if (stainfo != NULL) {
+ if (IS_MCAST(prxattrib->ra)) {
+ iv = precvframe->u.hdr.rx_data +
+ prxattrib->hdrlen;
+ idx = iv[3];
+ mickey = &psecuritypriv->XGrprxmickey[(((idx >>
+ 6) & 0x3)) - 1].skey[0];
+ if (psecuritypriv->binstallGrpkey == false)
+ return _FAIL;
+ } else
+ mickey = &stainfo->tkiprxmickey.skey[0];
+ /*icv_len included the mic code*/
+ datalen = precvframe->u.hdr.len - prxattrib->hdrlen -
+ prxattrib->iv_len - prxattrib->icv_len - 8;
+ pframe = precvframe->u.hdr.rx_data;
+ payload = pframe + prxattrib->hdrlen +
+ prxattrib->iv_len;
+ seccalctkipmic(mickey, pframe, payload, datalen,
+ &miccode[0],
+ (unsigned char)prxattrib->priority);
+ pframemic = payload + datalen;
+ bmic_err = false;
+ for (i = 0; i < 8; i++) {
+ if (miccode[i] != *(pframemic + i))
+ bmic_err = true;
+ }
+ if (bmic_err == true) {
+ if (prxattrib->bdecrypted == true)
+ r8712_handle_tkip_mic_err(adapter,
+ (u8)IS_MCAST(prxattrib->ra));
+ res = _FAIL;
+ } else {
+ /* mic checked ok */
+ if ((psecuritypriv->bcheck_grpkey ==
+ false) && (IS_MCAST(prxattrib->ra) ==
+ true))
+ psecuritypriv->bcheck_grpkey = true;
+ }
+ recvframe_pull_tail(precvframe, 8);
+ }
+ }
+ return res;
+}
+
+/* decrypt and set the ivlen,icvlen of the recv_frame */
+union recv_frame *r8712_decryptor(struct _adapter *padapter,
+ union recv_frame *precv_frame)
+{
+ struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ union recv_frame *return_packet = precv_frame;
+
+ if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) ||
+ (psecuritypriv->sw_decrypt == true))) {
+ psecuritypriv->hw_decrypted = false;
+ switch (prxattrib->encrypt) {
+ case _WEP40_:
+ case _WEP104_:
+ r8712_wep_decrypt(padapter, (u8 *)precv_frame);
+ break;
+ case _TKIP_:
+ r8712_tkip_decrypt(padapter, (u8 *)precv_frame);
+ break;
+ case _AES_:
+ r8712_aes_decrypt(padapter, (u8 *)precv_frame);
+ break;
+ default:
+ break;
+ }
+ } else if (prxattrib->bdecrypted == 1)
+ psecuritypriv->hw_decrypted = true;
+ return return_packet;
+}
+/*###set the security information in the recv_frame */
+union recv_frame *r8712_portctrl(struct _adapter *adapter,
+ union recv_frame *precv_frame)
+{
+ u8 *psta_addr, *ptr;
+ uint auth_alg;
+ struct recv_frame_hdr *pfhdr;
+ struct sta_info *psta;
+ struct sta_priv *pstapriv;
+ union recv_frame *prtnframe;
+ u16 ether_type = 0;
+
+ pstapriv = &adapter->stapriv;
+ ptr = get_recvframe_data(precv_frame);
+ pfhdr = &precv_frame->u.hdr;
+ psta_addr = pfhdr->attrib.ta;
+ psta = r8712_get_stainfo(pstapriv, psta_addr);
+ auth_alg = adapter->securitypriv.AuthAlgrthm;
+ if (auth_alg == 2) {
+ if ((psta != NULL) && (psta->ieee8021x_blocked)) {
+ /* blocked
+ * only accept EAPOL frame */
+ prtnframe = precv_frame;
+ /*get ether_type */
+ ptr = ptr + pfhdr->attrib.hdrlen +
+ pfhdr->attrib.iv_len + LLC_HEADER_SIZE;
+ memcpy(&ether_type, ptr, 2);
+ ether_type = ntohs((unsigned short)ether_type);
+ if (ether_type == 0x888e)
+ prtnframe = precv_frame;
+ else {
+ /*free this frame*/
+ r8712_free_recvframe(precv_frame,
+ &adapter->recvpriv.free_recv_queue);
+ prtnframe = NULL;
+ }
+ } else {
+ /* allowed
+ * check decryption status, and decrypt the
+ * frame if needed */
+ prtnframe = precv_frame;
+ /* check is the EAPOL frame or not (Rekey) */
+ if (ether_type == 0x888e) {
+ /* check Rekey */
+ prtnframe = precv_frame;
+ }
+ }
+ } else
+ prtnframe = precv_frame;
+ return prtnframe;
+}
+
+static sint recv_decache(union recv_frame *precv_frame, u8 bretry,
+ struct stainfo_rxcache *prxcache)
+{
+ sint tid = precv_frame->u.hdr.attrib.priority;
+ u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) |
+ (precv_frame->u.hdr.attrib.frag_num & 0xf);
+
+ if (tid > 15)
+ return _FAIL;
+ if (seq_ctrl == prxcache->tid_rxseq[tid])
+ return _FAIL;
+ prxcache->tid_rxseq[tid] = seq_ctrl;
+ return _SUCCESS;
+}
+
+static sint sta2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
+ struct sta_info **psta
+)
+{
+ u8 *ptr = precv_frame->u.hdr.rx_data;
+ sint ret = _SUCCESS;
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ u8 *mybssid = get_bssid(pmlmepriv);
+ u8 *myhwaddr = myid(&adapter->eeprompriv);
+ u8 *sta_addr = NULL;
+ sint bmcast = IS_MCAST(pattrib->dst);
+
+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
+ (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
+ /* filter packets that SA is myself or multicast or broadcast */
+ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
+ return _FAIL;
+ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
+ return _FAIL;
+ if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
+ !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
+ (memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
+ return _FAIL;
+ sta_addr = pattrib->src;
+ } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
+ /* For Station mode, sa and bssid should always be BSSID,
+ * and DA is my mac-address */
+ if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN))
+ return _FAIL;
+ sta_addr = pattrib->bssid;
+ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
+ if (bmcast) {
+ /* For AP mode, if DA == MCAST, then BSSID should
+ * be also MCAST */
+ if (!IS_MCAST(pattrib->bssid))
+ return _FAIL;
+ } else { /* not mc-frame */
+ /* For AP mode, if DA is non-MCAST, then it must be
+ * BSSID, and bssid == BSSID */
+ if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN))
+ return _FAIL;
+ sta_addr = pattrib->src;
+ }
+ } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
+ memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
+ memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+ sta_addr = mybssid;
+ } else
+ ret = _FAIL;
+ if (bmcast)
+ *psta = r8712_get_bcmc_stainfo(adapter);
+ else
+ *psta = r8712_get_stainfo(pstapriv, sta_addr); /* get ap_info */
+ if (*psta == NULL) {
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
+ adapter->mppriv.rx_pktloss++;
+ return _FAIL;
+ }
+ return ret;
+}
+
+static sint ap2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
+ struct sta_info **psta)
+{
+ u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ u8 *mybssid = get_bssid(pmlmepriv);
+ u8 *myhwaddr = myid(&adapter->eeprompriv);
+ sint bmcast = IS_MCAST(pattrib->dst);
+
+ if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
+ && (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
+ /* if NULL-frame, drop packet */
+ if ((GetFrameSubType(ptr)) == WIFI_DATA_NULL)
+ return _FAIL;
+ /* drop QoS-SubType Data, including QoS NULL,
+ * excluding QoS-Data */
+ if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) ==
+ WIFI_QOS_DATA_TYPE) {
+ if (GetFrameSubType(ptr) & (BIT(4) | BIT(5) | BIT(6)))
+ return _FAIL;
+ }
+
+ /* filter packets that SA is myself or multicast or broadcast */
+ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
+ return _FAIL;
+
+ /* da should be for me */
+ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
+ return _FAIL;
+ /* check BSSID */
+ if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
+ !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
+ (memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
+ return _FAIL;
+ if (bmcast)
+ *psta = r8712_get_bcmc_stainfo(adapter);
+ else
+ *psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
+ if (*psta == NULL)
+ return _FAIL;
+ } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) &&
+ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
+ memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
+ memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+ memcpy(pattrib->bssid, mybssid, ETH_ALEN);
+ *psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
+ if (*psta == NULL)
+ return _FAIL;
+ } else
+ return _FAIL;
+ return _SUCCESS;
+}
+
+static sint sta2ap_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
+ struct sta_info **psta)
+{
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+ struct sta_priv *pstapriv = &adapter->stapriv;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+ unsigned char *mybssid = get_bssid(pmlmepriv);
+
+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
+ /* For AP mode, if DA is non-MCAST, then it must be BSSID,
+ * and bssid == BSSID
+ * For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
+ if (memcmp(pattrib->bssid, mybssid, ETH_ALEN))
+ return _FAIL;
+ *psta = r8712_get_stainfo(pstapriv, pattrib->src);
+ if (*psta == NULL)
+ return _FAIL;
+ }
+ return _SUCCESS;
+}
+
+static sint validate_recv_ctrl_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame)
+{
+ return _FAIL;
+}
+
+static sint validate_recv_mgnt_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame)
+{
+ return _FAIL;
+}
+
+
+static sint validate_recv_data_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame)
+{
+ int res;
+ u8 bretry;
+ u8 *psa, *pda, *pbssid;
+ struct sta_info *psta = NULL;
+ u8 *ptr = precv_frame->u.hdr.rx_data;
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+ struct security_priv *psecuritypriv = &adapter->securitypriv;
+
+ bretry = GetRetry(ptr);
+ pda = get_da(ptr);
+ psa = get_sa(ptr);
+ pbssid = get_hdr_bssid(ptr);
+ if (pbssid == NULL)
+ return _FAIL;
+ memcpy(pattrib->dst, pda, ETH_ALEN);
+ memcpy(pattrib->src, psa, ETH_ALEN);
+ memcpy(pattrib->bssid, pbssid, ETH_ALEN);
+ switch (pattrib->to_fr_ds) {
+ case 0:
+ memcpy(pattrib->ra, pda, ETH_ALEN);
+ memcpy(pattrib->ta, psa, ETH_ALEN);
+ res = sta2sta_data_frame(adapter, precv_frame, &psta);
+ break;
+ case 1:
+ memcpy(pattrib->ra, pda, ETH_ALEN);
+ memcpy(pattrib->ta, pbssid, ETH_ALEN);
+ res = ap2sta_data_frame(adapter, precv_frame, &psta);
+ break;
+ case 2:
+ memcpy(pattrib->ra, pbssid, ETH_ALEN);
+ memcpy(pattrib->ta, psa, ETH_ALEN);
+ res = sta2ap_data_frame(adapter, precv_frame, &psta);
+ break;
+ case 3:
+ memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
+ memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
+ return _FAIL;
+ default:
+ return _FAIL;
+ }
+ if (res == _FAIL)
+ return _FAIL;
+ if (psta == NULL)
+ return _FAIL;
+ else
+ precv_frame->u.hdr.psta = psta;
+ pattrib->amsdu = 0;
+ /* parsing QC field */
+ if (pattrib->qos == 1) {
+ pattrib->priority = GetPriority((ptr + 24));
+ pattrib->ack_policy = GetAckpolicy((ptr + 24));
+ pattrib->amsdu = GetAMsdu((ptr + 24));
+ pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26;
+ } else {
+ pattrib->priority = 0;
+ pattrib->hdrlen = (pattrib->to_fr_ds == 3) ? 30 : 24;
+ }
+
+ if (pattrib->order)/*HT-CTRL 11n*/
+ pattrib->hdrlen += 4;
+ precv_frame->u.hdr.preorder_ctrl =
+ &psta->recvreorder_ctrl[pattrib->priority];
+
+ /* decache, drop duplicate recv packets */
+ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) ==
+ _FAIL)
+ return _FAIL;
+
+ if (pattrib->privacy) {
+ GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt,
+ IS_MCAST(pattrib->ra));
+ SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len,
+ pattrib->encrypt);
+ } else {
+ pattrib->encrypt = 0;
+ pattrib->iv_len = pattrib->icv_len = 0;
+ }
+ return _SUCCESS;
+}
+
+sint r8712_validate_recv_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame)
+{
+ /*shall check frame subtype, to / from ds, da, bssid */
+ /*then call check if rx seq/frag. duplicated.*/
+
+ u8 type;
+ u8 subtype;
+ sint retval = _SUCCESS;
+ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
+
+ u8 *ptr = precv_frame->u.hdr.rx_data;
+ u8 ver = (unsigned char)(*ptr) & 0x3;
+
+ /*add version chk*/
+ if (ver != 0)
+ return _FAIL;
+ type = GetFrameType(ptr);
+ subtype = GetFrameSubType(ptr); /*bit(7)~bit(2)*/
+ pattrib->to_fr_ds = get_tofr_ds(ptr);
+ pattrib->frag_num = GetFragNum(ptr);
+ pattrib->seq_num = GetSequence(ptr);
+ pattrib->pw_save = GetPwrMgt(ptr);
+ pattrib->mfrag = GetMFrag(ptr);
+ pattrib->mdata = GetMData(ptr);
+ pattrib->privacy = GetPrivacy(ptr);
+ pattrib->order = GetOrder(ptr);
+ switch (type) {
+ case WIFI_MGT_TYPE: /*mgnt*/
+ retval = validate_recv_mgnt_frame(adapter, precv_frame);
+ break;
+ case WIFI_CTRL_TYPE:/*ctrl*/
+ retval = validate_recv_ctrl_frame(adapter, precv_frame);
+ break;
+ case WIFI_DATA_TYPE: /*data*/
+ pattrib->qos = (subtype & BIT(7)) ? 1 : 0;
+ retval = validate_recv_data_frame(adapter, precv_frame);
+ break;
+ default:
+ return _FAIL;
+ }
+ return retval;
+}
+
+sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
+{
+ /*remove the wlanhdr and add the eth_hdr*/
+ sint rmv_len;
+ u16 eth_type, len;
+ u8 bsnaphdr;
+ u8 *psnap_type;
+ struct ieee80211_snap_hdr *psnap;
+
+ sint ret = _SUCCESS;
+ struct _adapter *adapter = precvframe->u.hdr.adapter;
+ struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+
+ u8 *ptr = get_recvframe_data(precvframe); /*point to frame_ctrl field*/
+ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;
+
+ if (pattrib->encrypt)
+ recvframe_pull_tail(precvframe, pattrib->icv_len);
+ psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen +
+ pattrib->iv_len);
+ psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE;
+ /* convert hdr + possible LLC headers into Ethernet header */
+ if ((!memcmp(psnap, (void *)rfc1042_header, SNAP_SIZE) &&
+ (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_IPX, 2)) &&
+ (memcmp(psnap_type, (void *)SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
+ !memcmp(psnap, (void *)bridge_tunnel_header, SNAP_SIZE)) {
+ /* remove RFC1042 or Bridge-Tunnel encapsulation and
+ * replace EtherType */
+ bsnaphdr = true;
+ } else {
+ /* Leave Ethernet header part of hdr and full payload */
+ bsnaphdr = false;
+ }
+ rmv_len = pattrib->hdrlen + pattrib->iv_len +
+ (bsnaphdr ? SNAP_SIZE : 0);
+ len = precvframe->u.hdr.len - rmv_len;
+ if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
+ ptr += rmv_len;
+ *ptr = 0x87;
+ *(ptr+1) = 0x12;
+ eth_type = 0x8712;
+ /* append rx status for mp test packets */
+ ptr = recvframe_pull(precvframe, (rmv_len -
+ sizeof(struct ethhdr) + 2) - 24);
+ memcpy(ptr, get_rxmem(precvframe), 24);
+ ptr += 24;
+ } else
+ ptr = recvframe_pull(precvframe, (rmv_len -
+ sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
+
+ memcpy(ptr, pattrib->dst, ETH_ALEN);
+ memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN);
+ if (!bsnaphdr) {
+ len = htons(len);
+ memcpy(ptr + 12, &len, 2);
+ }
+ return ret;
+}
+
+s32 r8712_recv_entry(union recv_frame *precvframe)
+{
+ struct _adapter *padapter;
+ struct recv_priv *precvpriv;
+ struct mlme_priv *pmlmepriv;
+ struct recv_stat *prxstat;
+ struct dvobj_priv *pdev;
+ u8 *phead, *pdata, *ptail, *pend;
+
+ struct __queue *pfree_recv_queue, *ppending_recv_queue;
+ s32 ret = _SUCCESS;
+ struct intf_hdl *pintfhdl;
+
+ padapter = precvframe->u.hdr.adapter;
+ pintfhdl = &padapter->pio_queue->intf;
+ pmlmepriv = &padapter->mlmepriv;
+ precvpriv = &(padapter->recvpriv);
+ pdev = &padapter->dvobjpriv;
+ pfree_recv_queue = &(precvpriv->free_recv_queue);
+ ppending_recv_queue = &(precvpriv->recv_pending_queue);
+ phead = precvframe->u.hdr.rx_head;
+ pdata = precvframe->u.hdr.rx_data;
+ ptail = precvframe->u.hdr.rx_tail;
+ pend = precvframe->u.hdr.rx_end;
+ prxstat = (struct recv_stat *)phead;
+
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX);
+
+ ret = recv_func(padapter, precvframe);
+ if (ret == _FAIL)
+ goto _recv_entry_drop;
+ precvpriv->rx_pkts++;
+ precvpriv->rx_bytes += (uint)(precvframe->u.hdr.rx_tail -
+ precvframe->u.hdr.rx_data);
+ return ret;
+_recv_entry_drop:
+ precvpriv->rx_drop++;
+ padapter->mppriv.rx_pktloss = precvpriv->rx_drop;
+ return ret;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_recv.h b/drivers/staging/rtl8712/rtl871x_recv.h
new file mode 100644
index 000000000000..bf8115dbcb61
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_recv.h
@@ -0,0 +1,330 @@
+#ifndef _RTL871X_RECV_H_
+#define _RTL871X_RECV_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+#define NR_RECVFRAME 256
+
+#define RXFRAME_ALIGN 8
+#define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN)
+
+#define MAX_RXFRAME_CNT 512
+#define MAX_RX_NUMBLKS (32)
+#define RECVFRAME_HDR_ALIGN 128
+#define MAX_SUBFRAME_COUNT 64
+
+#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
+
+/* for Rx reordering buffer control */
+struct recv_reorder_ctrl {
+ struct _adapter *padapter;
+ u16 indicate_seq;/* =wstart_b, init_value=0xffff */
+ u16 wend_b;
+ u8 wsize_b;
+ struct __queue pending_recvframe_queue;
+ struct timer_list reordering_ctrl_timer;
+};
+
+struct stainfo_rxcache {
+ u16 tid_rxseq[16];
+};
+
+#define PHY_RSSI_SLID_WIN_MAX 100
+#define PHY_LINKQUALITY_SLID_WIN_MAX 20
+
+
+struct smooth_rssi_data {
+ u32 elements[100]; /* array to store values */
+ u32 index; /* index to current array to store */
+ u32 total_num; /* num of valid elements */
+ u32 total_val; /* sum of valid elements */
+};
+
+struct rx_pkt_attrib {
+
+ u8 amsdu;
+ u8 order;
+ u8 qos;
+ u8 to_fr_ds;
+ u8 frag_num;
+ u16 seq_num;
+ u8 pw_save;
+ u8 mfrag;
+ u8 mdata;
+ u8 privacy; /* in frame_ctrl field */
+ u8 bdecrypted;
+ int hdrlen; /* the WLAN Header Len */
+ int encrypt; /* 0 no encrypt. != 0 encrypt algorith */
+ int iv_len;
+ int icv_len;
+ int priority;
+ int ack_policy;
+ u8 crc_err;
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+ u8 ta[ETH_ALEN];
+ u8 ra[ETH_ALEN];
+ u8 bssid[ETH_ALEN];
+ u8 tcpchk_valid; /* 0: invalid, 1: valid */
+ u8 ip_chkrpt; /* 0: incorrect, 1: correct */
+ u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
+ u8 signal_qual;
+ s8 rx_mimo_signal_qual[2];
+ u8 mcs_rate;
+ u8 htc;
+ u8 signal_strength;
+};
+
+/*
+accesser of recv_priv: recv_entry(dispatch / passive level);
+recv_thread(passive) ; returnpkt(dispatch)
+; halt(passive) ;
+
+using enter_critical section to protect
+*/
+struct recv_priv {
+ spinlock_t lock;
+ struct semaphore recv_sema;
+ struct semaphore terminate_recvthread_sema;
+ struct __queue free_recv_queue;
+ struct __queue recv_pending_queue;
+ u8 *pallocated_frame_buf;
+ u8 *precv_frame_buf;
+ uint free_recvframe_cnt;
+ struct _adapter *adapter;
+ uint rx_bytes;
+ uint rx_pkts;
+ uint rx_drop;
+ uint rx_icv_err;
+ uint rx_largepacket_crcerr;
+ uint rx_smallpacket_crcerr;
+ uint rx_middlepacket_crcerr;
+ struct semaphore allrxreturnevt;
+ u8 rx_pending_cnt;
+ uint ff_hwaddr;
+ struct tasklet_struct recv_tasklet;
+ struct sk_buff_head free_recv_skb_queue;
+ struct sk_buff_head rx_skb_queue;
+ u8 *pallocated_recv_buf;
+ u8 *precv_buf; /* 4 alignment */
+ struct __queue free_recv_buf_queue;
+ u32 free_recv_buf_queue_cnt;
+ /* For the phy informatiom */
+ s8 rssi;
+ u8 signal;
+ u8 noise;
+ u8 fw_rssi;
+ struct smooth_rssi_data signal_qual_data;
+ struct smooth_rssi_data signal_strength_data;
+};
+
+struct sta_recv_priv {
+ spinlock_t lock;
+ sint option;
+ struct __queue defrag_q; /* keeping the fragment frame until defrag */
+ struct stainfo_rxcache rxcache;
+ uint sta_rx_bytes;
+ uint sta_rx_pkts;
+ uint sta_rx_fail;
+};
+
+#include "rtl8712_recv.h"
+
+/* get a free recv_frame from pfree_recv_queue */
+union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue);
+union recv_frame *r8712_dequeue_recvframe(struct __queue *queue);
+int r8712_enqueue_recvframe(union recv_frame *precvframe,
+ struct __queue *queue);
+int r8712_free_recvframe(union recv_frame *precvframe,
+ struct __queue *pfree_recv_queue);
+void r8712_free_recvframe_queue(struct __queue *pframequeue,
+ struct __queue *pfree_recv_queue);
+void r8712_init_recvframe(union recv_frame *precvframe,
+ struct recv_priv *precvpriv);
+int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe);
+int recv_func(struct _adapter *padapter, void *pcontext);
+
+static inline u8 *get_rxmem(union recv_frame *precvframe)
+{
+ /* always return rx_head... */
+ if (precvframe == NULL)
+ return NULL;
+ return precvframe->u.hdr.rx_head;
+}
+
+static inline u8 *get_rx_status(union recv_frame *precvframe)
+{
+ return get_rxmem(precvframe);
+}
+
+static inline u8 *get_recvframe_data(union recv_frame *precvframe)
+{
+ /* always return rx_data */
+ if (precvframe == NULL)
+ return NULL;
+ return precvframe->u.hdr.rx_data;
+}
+
+static inline u8 *recvframe_push(union recv_frame *precvframe, sint sz)
+{
+ /* append data before rx_data */
+
+ /* add data to the start of recv_frame
+ *
+ * This function extends the used data area of the recv_frame at the
+ * buffer start. rx_data must be still larger than rx_head, after
+ * pushing.
+ */
+
+ if (precvframe == NULL)
+ return NULL;
+ precvframe->u.hdr.rx_data -= sz ;
+ if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) {
+ precvframe->u.hdr.rx_data += sz ;
+ return NULL;
+ }
+ precvframe->u.hdr.len += sz;
+ return precvframe->u.hdr.rx_data;
+}
+
+static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
+{
+ /* used for extract sz bytes from rx_data, update rx_data and return
+ * the updated rx_data to the caller */
+ if (precvframe == NULL)
+ return NULL;
+ precvframe->u.hdr.rx_data += sz;
+ if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
+ precvframe->u.hdr.rx_data -= sz;
+ return NULL;
+ }
+ precvframe->u.hdr.len -= sz;
+ return precvframe->u.hdr.rx_data;
+}
+
+static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
+{
+ /* used for append sz bytes from ptr to rx_tail, update rx_tail and
+ * return the updated rx_tail to the caller
+ * after putting, rx_tail must be still larger than rx_end. */
+ unsigned char *prev_rx_tail;
+
+ if (precvframe == NULL)
+ return NULL;
+ prev_rx_tail = precvframe->u.hdr.rx_tail;
+ precvframe->u.hdr.rx_tail += sz;
+ if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
+ precvframe->u.hdr.rx_tail -= sz;
+ return NULL;
+ }
+ precvframe->u.hdr.len += sz;
+ return precvframe->u.hdr.rx_tail;
+}
+
+static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
+{
+ /* rmv data from rx_tail (by yitsen)
+ * used for extract sz bytes from rx_end, update rx_end and return the
+ * updated rx_end to the caller
+ * after pulling, rx_end must be still larger than rx_data. */
+ if (precvframe == NULL)
+ return NULL;
+ precvframe->u.hdr.rx_tail -= sz;
+ if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
+ precvframe->u.hdr.rx_tail += sz;
+ return NULL;
+ }
+ precvframe->u.hdr.len -= sz;
+ return precvframe->u.hdr.rx_tail;
+}
+
+static inline _buffer *get_rxbuf_desc(union recv_frame *precvframe)
+{
+ _buffer *buf_desc;
+ if (precvframe == NULL)
+ return NULL;
+ return buf_desc;
+}
+
+static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem)
+{
+ /* due to the design of 2048 bytes alignment of recv_frame, we can
+ * reference the union recv_frame from any given member of recv_frame.
+ * rxmem indicates the any member/address in recv_frame */
+ return (union recv_frame *)(((addr_t)rxmem >> RXFRAME_ALIGN) <<
+ RXFRAME_ALIGN);
+}
+
+static inline union recv_frame *pkt_to_recvframe(_pkt *pkt)
+{
+ u8 *buf_star;
+ union recv_frame *precv_frame;
+
+ precv_frame = rxmem_to_recvframe((unsigned char *)buf_star);
+ return precv_frame;
+}
+
+static inline u8 *pkt_to_recvmem(_pkt *pkt)
+{
+ /* return the rx_head */
+ union recv_frame *precv_frame = pkt_to_recvframe(pkt);
+
+ return precv_frame->u.hdr.rx_head;
+}
+
+static inline u8 *pkt_to_recvdata(_pkt *pkt)
+{
+ /* return the rx_data */
+ union recv_frame *precv_frame = pkt_to_recvframe(pkt);
+
+ return precv_frame->u.hdr.rx_data;
+}
+
+static inline sint get_recvframe_len(union recv_frame *precvframe)
+{
+ return precvframe->u.hdr.len;
+}
+
+struct sta_info;
+
+void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
+sint r8712_recvframe_chkmic(struct _adapter *adapter,
+ union recv_frame *precvframe);
+union recv_frame *r8712_decryptor(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+union recv_frame *r8712_recvframe_defrag(struct _adapter *adapter,
+ struct __queue *defrag_q);
+union recv_frame *r8712_recvframe_chk_defrag_new(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+union recv_frame *r8712_recvframe_defrag_new(struct _adapter *adapter,
+ struct __queue *defrag_q,
+ union recv_frame *precv_frame);
+int r8712_recv_decache(union recv_frame *precv_frame, u8 bretry,
+ struct stainfo_rxcache *prxcache);
+int r8712_sta2sta_data_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame,
+ struct sta_info **psta);
+int r8712_ap2sta_data_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame,
+ struct sta_info **psta);
+int r8712_sta2ap_data_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame,
+ struct sta_info **psta);
+int r8712_validate_recv_ctrl_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+int r8712_validate_recv_mgnt_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+int r8712_validate_recv_data_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+int r8712_validate_recv_frame(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+union recv_frame *r8712_portctrl(struct _adapter *adapter,
+ union recv_frame *precv_frame);
+void r8712_mgt_dispatcher(struct _adapter *padapter, u8 *pframe, uint len);
+int r8712_amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_rf.h b/drivers/staging/rtl8712/rtl871x_rf.h
new file mode 100644
index 000000000000..c709d8cadf0c
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_rf.h
@@ -0,0 +1,43 @@
+#ifndef __RTL871X_RF_H_
+#define __RTL871X_RF_H_
+
+#include "rtl871x_cmd.h"
+#include "rtl871x_mp_phy_regdef.h"
+
+#define OFDM_PHY 1
+#define MIXED_PHY 2
+#define CCK_PHY 3
+#define NumRates (13)
+#define RTL8711_RF_MAX_SENS 6
+#define RTL8711_RF_DEF_SENS 4
+#define NUM_CHANNELS 15
+
+struct regulatory_class {
+ u32 starting_freq; /*MHz, */
+ u8 channel_set[NUM_CHANNELS];
+ u8 channel_cck_power[NUM_CHANNELS]; /*dbm*/
+ u8 channel_ofdm_power[NUM_CHANNELS];/*dbm*/
+ u8 txpower_limit; /*dbm*/
+ u8 channel_spacing; /*MHz*/
+ u8 modem;
+};
+
+enum _REG_PREAMBLE_MODE{
+ PREAMBLE_LONG = 1,
+ PREAMBLE_AUTO = 2,
+ PREAMBLE_SHORT = 3,
+};
+
+enum {
+ RTL8712_RFC_1T = 0x10,
+ RTL8712_RFC_2T = 0x20,
+ RTL8712_RFC_1R = 0x01,
+ RTL8712_RFC_2R = 0x02,
+ RTL8712_RFC_1T1R = 0x11,
+ RTL8712_RFC_1T2R = 0x12,
+ RTL8712_RFC_TURBO = 0x92,
+ RTL8712_RFC_2T2R = 0x22
+};
+
+#endif /*_RTL8711_RF_H_*/
+
diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c
new file mode 100644
index 000000000000..65321bed4d5d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -0,0 +1,1389 @@
+/******************************************************************************
+ * rtl871x_security.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_SECURITY_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wifi.h"
+#include "osdep_intf.h"
+
+/* =====WEP related===== */
+
+#define CRC32_POLY 0x04c11db7
+
+struct arc4context {
+ u32 x;
+ u32 y;
+ u8 state[256];
+};
+
+static void arcfour_init(struct arc4context *parc4ctx, u8 * key, u32 key_len)
+{
+ u32 t, u;
+ u32 keyindex;
+ u32 stateindex;
+ u8 *state;
+ u32 counter;
+
+ state = parc4ctx->state;
+ parc4ctx->x = 0;
+ parc4ctx->y = 0;
+ for (counter = 0; counter < 256; counter++)
+ state[counter] = (u8)counter;
+ keyindex = 0;
+ stateindex = 0;
+ for (counter = 0; counter < 256; counter++) {
+ t = state[counter];
+ stateindex = (stateindex + key[keyindex] + t) & 0xff;
+ u = state[stateindex];
+ state[stateindex] = (u8)t;
+ state[counter] = (u8)u;
+ if (++keyindex >= key_len)
+ keyindex = 0;
+ }
+}
+
+static u32 arcfour_byte(struct arc4context *parc4ctx)
+{
+ u32 x;
+ u32 y;
+ u32 sx, sy;
+ u8 *state;
+
+ state = parc4ctx->state;
+ x = (parc4ctx->x + 1) & 0xff;
+ sx = state[x];
+ y = (sx + parc4ctx->y) & 0xff;
+ sy = state[y];
+ parc4ctx->x = x;
+ parc4ctx->y = y;
+ state[y] = (u8)sx;
+ state[x] = (u8)sy;
+ return state[(sx + sy) & 0xff];
+}
+
+static void arcfour_encrypt(struct arc4context *parc4ctx,
+ u8 *dest, u8 *src, u32 len)
+{
+ u32 i;
+
+ for (i = 0; i < len; i++)
+ dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
+}
+
+static sint bcrc32initialized;
+static u32 crc32_table[256];
+
+static u8 crc32_reverseBit(u8 data)
+{
+ return ((u8)(data << 7) & 0x80) | ((data << 5) & 0x40) | ((data << 3)
+ & 0x20) | ((data << 1) & 0x10) | ((data >> 1) & 0x08) |
+ ((data >> 3) & 0x04) | ((data >> 5) & 0x02) | ((data >> 7) &
+ 0x01);
+}
+
+static void crc32_init(void)
+{
+ if (bcrc32initialized == 1)
+ return;
+ else {
+ sint i, j;
+ u32 c;
+ u8 *p = (u8 *)&c, *p1;
+ u8 k;
+
+ c = 0x12340000;
+ for (i = 0; i < 256; ++i) {
+ k = crc32_reverseBit((u8)i);
+ for (c = ((u32)k) << 24, j = 8; j > 0; --j)
+ c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY :
+ (c << 1);
+ p1 = (u8 *)&crc32_table[i];
+ p1[0] = crc32_reverseBit(p[3]);
+ p1[1] = crc32_reverseBit(p[2]);
+ p1[2] = crc32_reverseBit(p[1]);
+ p1[3] = crc32_reverseBit(p[0]);
+ }
+ bcrc32initialized = 1;
+ }
+}
+
+static u32 getcrc32(u8 *buf, u32 len)
+{
+ u8 *p;
+ u32 crc;
+
+ if (bcrc32initialized == 0)
+ crc32_init();
+ crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
+ for (p = buf; len > 0; ++p, --len)
+ crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
+ return ~crc; /* transmit complement, per CRC-32 spec */
+}
+
+/*
+ Need to consider the fragment situation
+*/
+void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
+{ /* exclude ICV */
+ unsigned char crc[4];
+ struct arc4context mycontext;
+ u32 curfragnum, length, keylength;
+ u8 *pframe, *payload, *iv; /*,*wepkey*/
+ u8 wepkey[16];
+ struct pkt_attrib *pattrib = &((struct xmit_frame *)
+ pxmitframe)->attrib;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+
+ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
+ return;
+ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr+TXDESC_OFFSET;
+ /*start to encrypt each fragment*/
+ if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
+ keylength = psecuritypriv->DefKeylen[psecuritypriv->
+ PrivacyKeyIndex];
+ for (curfragnum = 0; curfragnum < pattrib->nr_frags;
+ curfragnum++) {
+ iv = pframe+pattrib->hdrlen;
+ memcpy(&wepkey[0], iv, 3);
+ memcpy(&wepkey[3], &psecuritypriv->DefKey[
+ psecuritypriv->PrivacyKeyIndex].skey[0],
+ keylength);
+ payload = pframe+pattrib->iv_len+pattrib->hdrlen;
+ if ((curfragnum + 1) == pattrib->nr_frags) {
+ length = pattrib->last_txcmdsz-pattrib->
+ hdrlen-pattrib->iv_len -
+ pattrib->icv_len;
+ *((u32 *)crc) = cpu_to_le32(getcrc32(
+ payload, length));
+ arcfour_init(&mycontext, wepkey, 3 + keylength);
+ arcfour_encrypt(&mycontext, payload, payload,
+ length);
+ arcfour_encrypt(&mycontext, payload + length,
+ crc, 4);
+ } else {
+ length = pxmitpriv->frag_len-pattrib->hdrlen -
+ pattrib->iv_len-pattrib->icv_len;
+ *((u32 *)crc) = cpu_to_le32(getcrc32(
+ payload, length));
+ arcfour_init(&mycontext, wepkey, 3 + keylength);
+ arcfour_encrypt(&mycontext, payload, payload,
+ length);
+ arcfour_encrypt(&mycontext, payload+length,
+ crc, 4);
+ pframe += pxmitpriv->frag_len;
+ pframe = (u8 *)RND4((addr_t)(pframe));
+ }
+ }
+ }
+}
+
+void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe)
+{
+ /* exclude ICV */
+ u8 crc[4];
+ struct arc4context mycontext;
+ u32 length, keylength;
+ u8 *pframe, *payload, *iv, wepkey[16];
+ u8 keyindex;
+ struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)
+ precvframe)->u.hdr.attrib);
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ pframe = (unsigned char *)((union recv_frame *)precvframe)->
+ u.hdr.rx_data;
+ /* start to decrypt recvframe */
+ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt ==
+ _WEP104_)) {
+ iv = pframe + prxattrib->hdrlen;
+ keyindex = (iv[3] & 0x3);
+ keylength = psecuritypriv->DefKeylen[keyindex];
+ memcpy(&wepkey[0], iv, 3);
+ memcpy(&wepkey[3], &psecuritypriv->DefKey[
+ psecuritypriv->PrivacyKeyIndex].skey[0],
+ keylength);
+ length = ((union recv_frame *)precvframe)->
+ u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len;
+ payload = pframe+prxattrib->iv_len+prxattrib->hdrlen;
+ /* decrypt payload include icv */
+ arcfour_init(&mycontext, wepkey, 3 + keylength);
+ arcfour_encrypt(&mycontext, payload, payload, length);
+ /* calculate icv and compare the icv */
+ *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length - 4));
+ }
+ return;
+}
+
+/* 3 =====TKIP related===== */
+
+static u32 secmicgetuint32(u8 *p)
+/* Convert from Byte[] to Us4Byte32 in a portable way */
+{
+ s32 i;
+ u32 res = 0;
+
+ for (i = 0; i < 4; i++)
+ res |= ((u32)(*p++)) << (8 * i);
+ return res;
+}
+
+static void secmicputuint32(u8 *p, u32 val)
+/* Convert from Us4Byte32 to Byte[] in a portable way */
+{
+ long i;
+ for (i = 0; i < 4; i++) {
+ *p++ = (u8) (val & 0xff);
+ val >>= 8;
+ }
+}
+
+static void secmicclear(struct mic_data *pmicdata)
+{
+/* Reset the state to the empty message. */
+ pmicdata->L = pmicdata->K0;
+ pmicdata->R = pmicdata->K1;
+ pmicdata->nBytesInM = 0;
+ pmicdata->M = 0;
+}
+
+void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key)
+{
+ /* Set the key */
+ pmicdata->K0 = secmicgetuint32(key);
+ pmicdata->K1 = secmicgetuint32(key + 4);
+ /* and reset the message */
+ secmicclear(pmicdata);
+}
+
+static void secmicappendbyte(struct mic_data *pmicdata, u8 b)
+{
+ /* Append the byte to our word-sized buffer */
+ pmicdata->M |= ((u32)b) << (8 * pmicdata->nBytesInM);
+ pmicdata->nBytesInM++;
+ /* Process the word if it is full. */
+ if (pmicdata->nBytesInM >= 4) {
+ pmicdata->L ^= pmicdata->M;
+ pmicdata->R ^= ROL32(pmicdata->L, 17);
+ pmicdata->L += pmicdata->R;
+ pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) |
+ ((pmicdata->L & 0x00ff00ff) << 8);
+ pmicdata->L += pmicdata->R;
+ pmicdata->R ^= ROL32(pmicdata->L, 3);
+ pmicdata->L += pmicdata->R;
+ pmicdata->R ^= ROR32(pmicdata->L, 2);
+ pmicdata->L += pmicdata->R;
+ /* Clear the buffer */
+ pmicdata->M = 0;
+ pmicdata->nBytesInM = 0;
+ }
+}
+
+void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nbytes)
+{
+ /* This is simple */
+ while (nbytes > 0) {
+ secmicappendbyte(pmicdata, *src++);
+ nbytes--;
+ }
+}
+
+void r8712_secgetmic(struct mic_data *pmicdata, u8 *dst)
+{
+ /* Append the minimum padding */
+ secmicappendbyte(pmicdata, 0x5a);
+ secmicappendbyte(pmicdata, 0);
+ secmicappendbyte(pmicdata, 0);
+ secmicappendbyte(pmicdata, 0);
+ secmicappendbyte(pmicdata, 0);
+ /* and then zeroes until the length is a multiple of 4 */
+ while (pmicdata->nBytesInM != 0)
+ secmicappendbyte(pmicdata, 0);
+ /* The appendByte function has already computed the result. */
+ secmicputuint32(dst, pmicdata->L);
+ secmicputuint32(dst + 4, pmicdata->R);
+ /* Reset to the empty message. */
+ secmicclear(pmicdata);
+}
+
+void seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code,
+ u8 pri)
+{
+
+ struct mic_data micdata;
+ u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
+
+ r8712_secmicsetkey(&micdata, key);
+ priority[0] = pri;
+ /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
+ if (header[1] & 1) { /* ToDS==1 */
+ r8712_secmicappend(&micdata, &header[16], 6); /* DA */
+ if (header[1] & 2) /* From Ds==1 */
+ r8712_secmicappend(&micdata, &header[24], 6);
+ else
+ r8712_secmicappend(&micdata, &header[10], 6);
+ } else { /* ToDS==0 */
+ r8712_secmicappend(&micdata, &header[4], 6); /* DA */
+ if (header[1] & 2) /* From Ds==1 */
+ r8712_secmicappend(&micdata, &header[16], 6);
+ else
+ r8712_secmicappend(&micdata, &header[10], 6);
+ }
+ r8712_secmicappend(&micdata, &priority[0], 4);
+ r8712_secmicappend(&micdata, data, data_len);
+ r8712_secgetmic(&micdata, mic_code);
+}
+
+/* macros for extraction/creation of unsigned char/unsigned short values */
+#define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15))
+#define Lo8(v16) ((u8)((v16) & 0x00FF))
+#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF))
+#define Lo16(v32) ((u16)((v32) & 0xFFFF))
+#define Hi16(v32) ((u16)(((v32) >> 16) & 0xFFFF))
+#define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8))
+
+/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */
+#define TK16(N) Mk16(tk[2 * (N) + 1], tk[2 * (N)])
+
+/* S-box lookup: 16 bits --> 16 bits */
+#define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)])
+
+/* fixed algorithm "parameters" */
+#define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */
+#define TA_SIZE 6 /* 48-bit transmitter address */
+#define TK_SIZE 16 /* 128-bit temporal key */
+#define P1K_SIZE 10 /* 80-bit Phase1 key */
+#define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */
+
+
+/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */
+static const unsigned short Sbox1[2][256] = {/* Sbox for hash (can be in ROM) */
+ {
+ 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
+ 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
+ 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
+ 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
+ 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
+ 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
+ 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
+ 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
+ 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
+ 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
+ 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
+ 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
+ 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
+ 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
+ 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
+ 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
+ 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
+ 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
+ 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
+ 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
+ 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
+ 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
+ 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
+ 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
+ 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
+ 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
+ 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
+ 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
+ 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
+ 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
+ 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
+ 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
+ },
+ { /* second half is unsigned char-reversed version of first! */
+ 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491,
+ 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
+ 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB,
+ 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B,
+ 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83,
+ 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A,
+ 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F,
+ 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA,
+ 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B,
+ 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713,
+ 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6,
+ 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85,
+ 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411,
+ 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B,
+ 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1,
+ 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF,
+ 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E,
+ 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6,
+ 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B,
+ 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD,
+ 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8,
+ 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2,
+ 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049,
+ 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810,
+ 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197,
+ 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F,
+ 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C,
+ 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927,
+ 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733,
+ 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5,
+ 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0,
+ 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C,
+ }
+};
+
+/*
+**********************************************************************
+* Routine: Phase 1 -- generate P1K, given TA, TK, IV32
+*
+* Inputs:
+* tk[] = temporal key [128 bits]
+* ta[] = transmitter's MAC address [ 48 bits]
+* iv32 = upper 32 bits of IV [ 32 bits]
+* Output:
+* p1k[] = Phase 1 key [ 80 bits]
+*
+* Note:
+* This function only needs to be called every 2**16 packets,
+* although in theory it could be called every packet.
+*
+**********************************************************************
+*/
+static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
+{
+ sint i;
+
+ /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */
+ p1k[0] = Lo16(iv32);
+ p1k[1] = Hi16(iv32);
+ p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */
+ p1k[3] = Mk16(ta[3], ta[2]);
+ p1k[4] = Mk16(ta[5], ta[4]);
+ /* Now compute an unbalanced Feistel cipher with 80-bit block */
+ /* size on the 80-bit block P1K[], using the 128-bit key TK[] */
+ for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add is mod 2**16 */
+ p1k[0] += _S_(p1k[4] ^ TK16((i&1) + 0));
+ p1k[1] += _S_(p1k[0] ^ TK16((i&1) + 2));
+ p1k[2] += _S_(p1k[1] ^ TK16((i&1) + 4));
+ p1k[3] += _S_(p1k[2] ^ TK16((i&1) + 6));
+ p1k[4] += _S_(p1k[3] ^ TK16((i&1) + 0));
+ p1k[4] += (unsigned short)i; /* avoid "slide attacks" */
+ }
+}
+
+/*
+**********************************************************************
+* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16
+*
+* Inputs:
+* tk[] = Temporal key [128 bits]
+* p1k[] = Phase 1 output key [ 80 bits]
+* iv16 = low 16 bits of IV counter [ 16 bits]
+* Output:
+* rc4key[] = the key used to encrypt the packet [128 bits]
+*
+* Note:
+* The value {TA,IV32,IV16} for Phase1/Phase2 must be unique
+* across all packets using the same key TK value. Then, for a
+* given value of TK[], this TKIP48 construction guarantees that
+* the final RC4KEY value is unique across all packets.
+*
+* Suggested implementation optimization: if PPK[] is "overlaid"
+* appropriately on RC4KEY[], there is no need for the final
+* for loop below that copies the PPK[] result into RC4KEY[].
+*
+**********************************************************************
+*/
+static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
+{
+ sint i;
+ u16 PPK[6]; /* temporary key for mixing */
+
+ /* Note: all adds in the PPK[] equations below are mod 2**16 */
+ for (i = 0; i < 5; i++)
+ PPK[i] = p1k[i]; /* first, copy P1K to PPK */
+ PPK[5] = p1k[4] + iv16; /* next, add in IV16 */
+ /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */
+ PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */
+ PPK[1] += _S_(PPK[0] ^ TK16(1));
+ PPK[2] += _S_(PPK[1] ^ TK16(2));
+ PPK[3] += _S_(PPK[2] ^ TK16(3));
+ PPK[4] += _S_(PPK[3] ^ TK16(4));
+ PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */
+ /* Final sweep: bijective, "linear". Rotates kill LSB correlations */
+ PPK[0] += RotR1(PPK[5] ^ TK16(6));
+ PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */
+ PPK[2] += RotR1(PPK[1]);
+ PPK[3] += RotR1(PPK[2]);
+ PPK[4] += RotR1(PPK[3]);
+ PPK[5] += RotR1(PPK[4]);
+ /* Note: At this point, for a given key TK[0..15], the 96-bit output */
+ /* value PPK[0..5] is guaranteed to be unique, as a function */
+ /* of the 96-bit "input" value {TA,IV32,IV16}. That is, P1K */
+ /* is now a keyed permutation of {TA,IV32,IV16}. */
+ /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */
+ rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */
+ rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */
+ rc4key[2] = Lo8(iv16);
+ rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1);
+ /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */
+ for (i = 0; i < 6; i++) {
+ rc4key[4 + 2 * i] = Lo8(PPK[i]);
+ rc4key[5 + 2 * i] = Hi8(PPK[i]);
+ }
+}
+
+/*The hlen isn't include the IV*/
+u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
+{ /* exclude ICV */
+ u16 pnl;
+ u32 pnh;
+ u8 rc4key[16];
+ u8 ttkey[16];
+ u8 crc[4];
+ struct arc4context mycontext;
+ u32 curfragnum, length, prwskeylen;
+
+ u8 *pframe, *payload, *iv, *prwskey;
+ union pn48 txpn;
+ struct sta_info *stainfo;
+ struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ u32 res = _SUCCESS;
+
+ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
+ return _FAIL;
+
+ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr+TXDESC_OFFSET;
+ /* 4 start to encrypt each fragment */
+ if (pattrib->encrypt == _TKIP_) {
+ if (pattrib->psta)
+ stainfo = pattrib->psta;
+ else
+ stainfo = r8712_get_stainfo(&padapter->stapriv,
+ &pattrib->ra[0]);
+ if (stainfo != NULL) {
+ prwskey = &stainfo->x_UncstKey.skey[0];
+ prwskeylen = 16;
+ for (curfragnum = 0; curfragnum < pattrib->nr_frags;
+ curfragnum++) {
+ iv = pframe + pattrib->hdrlen;
+ payload = pframe+pattrib->iv_len +
+ pattrib->hdrlen;
+ GET_TKIP_PN(iv, txpn);
+ pnl = (u16)(txpn.val);
+ pnh = (u32)(txpn.val >> 16);
+ phase1((u16 *)&ttkey[0], prwskey, &pattrib->
+ ta[0], pnh);
+ phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0],
+ pnl);
+ if ((curfragnum + 1) == pattrib->nr_frags) {
+ /* 4 the last fragment */
+ length = pattrib->last_txcmdsz -
+ pattrib->hdrlen-pattrib->iv_len -
+ pattrib->icv_len;
+ *((u32 *)crc) = cpu_to_le32(
+ getcrc32(payload, length));
+ arcfour_init(&mycontext, rc4key, 16);
+ arcfour_encrypt(&mycontext, payload,
+ payload, length);
+ arcfour_encrypt(&mycontext, payload +
+ length, crc, 4);
+ } else {
+ length = pxmitpriv->frag_len-pattrib->
+ hdrlen-pattrib->
+ iv_len-pattrib->icv_len;
+ *((u32 *)crc) = cpu_to_le32(getcrc32(
+ payload, length));
+ arcfour_init(&mycontext, rc4key, 16);
+ arcfour_encrypt(&mycontext, payload,
+ payload, length);
+ arcfour_encrypt(&mycontext,
+ payload+length, crc, 4);
+ pframe += pxmitpriv->frag_len;
+ pframe = (u8 *)RND4((addr_t)(pframe));
+ }
+ }
+ } else
+ res = _FAIL;
+ }
+ return res;
+}
+
+/* The hlen doesn't include the IV */
+u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe)
+{ /* exclude ICV */
+ u16 pnl;
+ u32 pnh;
+ u8 rc4key[16];
+ u8 ttkey[16];
+ u8 crc[4];
+ struct arc4context mycontext;
+ u32 length, prwskeylen;
+ u8 *pframe, *payload, *iv, *prwskey, idx = 0;
+ union pn48 txpn;
+ struct sta_info *stainfo;
+ struct rx_pkt_attrib *prxattrib = &((union recv_frame *)
+ precvframe)->u.hdr.attrib;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ pframe = (unsigned char *)((union recv_frame *)
+ precvframe)->u.hdr.rx_data;
+ /* 4 start to decrypt recvframe */
+ if (prxattrib->encrypt == _TKIP_) {
+ stainfo = r8712_get_stainfo(&padapter->stapriv,
+ &prxattrib->ta[0]);
+ if (stainfo != NULL) {
+ iv = pframe+prxattrib->hdrlen;
+ payload = pframe+prxattrib->iv_len + prxattrib->hdrlen;
+ length = ((union recv_frame *)precvframe)->
+ u.hdr.len - prxattrib->hdrlen -
+ prxattrib->iv_len;
+ if (IS_MCAST(prxattrib->ra)) {
+ idx = iv[3];
+ prwskey = &psecuritypriv->XGrpKey[
+ ((idx >> 6) & 0x3) - 1].skey[0];
+ if (psecuritypriv->binstallGrpkey == false)
+ return _FAIL;
+ } else
+ prwskey = &stainfo->x_UncstKey.skey[0];
+ prwskeylen = 16;
+ GET_TKIP_PN(iv, txpn);
+ pnl = (u16)(txpn.val);
+ pnh = (u32)(txpn.val >> 16);
+ phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0],
+ pnh);
+ phase2(&rc4key[0], prwskey, (unsigned short *)
+ &ttkey[0], pnl);
+ /* 4 decrypt payload include icv */
+ arcfour_init(&mycontext, rc4key, 16);
+ arcfour_encrypt(&mycontext, payload, payload, length);
+ *((u32 *)crc) = cpu_to_le32(getcrc32(payload,
+ length - 4));
+ if (crc[3] != payload[length - 1] ||
+ crc[2] != payload[length - 2] ||
+ crc[1] != payload[length - 3] ||
+ crc[0] != payload[length - 4])
+ return _FAIL;
+ } else
+ return _FAIL;
+ }
+ return _SUCCESS;
+}
+
+/* 3 =====AES related===== */
+
+#define MAX_MSG_SIZE 2048
+/*****************************/
+/******** SBOX Table *********/
+/*****************************/
+
+static const u8 sbox_table[256] = {
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5,
+ 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
+ 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc,
+ 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a,
+ 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
+ 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b,
+ 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85,
+ 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
+ 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17,
+ 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88,
+ 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
+ 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9,
+ 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6,
+ 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
+ 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94,
+ 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68,
+ 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
+};
+
+/****************************************/
+/* aes128k128d() */
+/* Performs a 128 bit AES encrypt with */
+/* 128 bit data. */
+/****************************************/
+static void xor_128(u8 *a, u8 *b, u8 *out)
+{
+ sint i;
+
+ for (i = 0; i < 16; i++)
+ out[i] = a[i] ^ b[i];
+}
+
+static void xor_32(u8 *a, u8 *b, u8 *out)
+{
+ sint i;
+ for (i = 0; i < 4; i++)
+ out[i] = a[i] ^ b[i];
+}
+
+static u8 sbox(u8 a)
+{
+ return sbox_table[(sint)a];
+}
+
+static void next_key(u8 *key, sint round)
+{
+ u8 rcon;
+ u8 sbox_key[4];
+ u8 rcon_table[12] = {
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
+ 0x1b, 0x36, 0x36, 0x36
+ };
+
+ sbox_key[0] = sbox(key[13]);
+ sbox_key[1] = sbox(key[14]);
+ sbox_key[2] = sbox(key[15]);
+ sbox_key[3] = sbox(key[12]);
+ rcon = rcon_table[round];
+ xor_32(&key[0], sbox_key, &key[0]);
+ key[0] = key[0] ^ rcon;
+ xor_32(&key[4], &key[0], &key[4]);
+ xor_32(&key[8], &key[4], &key[8]);
+ xor_32(&key[12], &key[8], &key[12]);
+}
+
+static void byte_sub(u8 *in, u8 *out)
+{
+ sint i;
+ for (i = 0; i < 16; i++)
+ out[i] = sbox(in[i]);
+}
+
+static void shift_row(u8 *in, u8 *out)
+{
+ out[0] = in[0];
+ out[1] = in[5];
+ out[2] = in[10];
+ out[3] = in[15];
+ out[4] = in[4];
+ out[5] = in[9];
+ out[6] = in[14];
+ out[7] = in[3];
+ out[8] = in[8];
+ out[9] = in[13];
+ out[10] = in[2];
+ out[11] = in[7];
+ out[12] = in[12];
+ out[13] = in[1];
+ out[14] = in[6];
+ out[15] = in[11];
+}
+
+static void mix_column(u8 *in, u8 *out)
+{
+ sint i;
+ u8 add1b[4];
+ u8 add1bf7[4];
+ u8 rotl[4];
+ u8 swap_halfs[4];
+ u8 andf7[4];
+ u8 rotr[4];
+ u8 temp[4];
+ u8 tempb[4];
+
+ for (i = 0 ; i < 4; i++) {
+ if ((in[i] & 0x80) == 0x80)
+ add1b[i] = 0x1b;
+ else
+ add1b[i] = 0x00;
+ }
+ swap_halfs[0] = in[2]; /* Swap halves */
+ swap_halfs[1] = in[3];
+ swap_halfs[2] = in[0];
+ swap_halfs[3] = in[1];
+ rotl[0] = in[3]; /* Rotate left 8 bits */
+ rotl[1] = in[0];
+ rotl[2] = in[1];
+ rotl[3] = in[2];
+ andf7[0] = in[0] & 0x7f;
+ andf7[1] = in[1] & 0x7f;
+ andf7[2] = in[2] & 0x7f;
+ andf7[3] = in[3] & 0x7f;
+ for (i = 3; i > 0; i--) { /* logical shift left 1 bit */
+ andf7[i] = andf7[i] << 1;
+ if ((andf7[i-1] & 0x80) == 0x80)
+ andf7[i] = (andf7[i] | 0x01);
+ }
+ andf7[0] = andf7[0] << 1;
+ andf7[0] = andf7[0] & 0xfe;
+ xor_32(add1b, andf7, add1bf7);
+ xor_32(in, add1bf7, rotr);
+ temp[0] = rotr[0]; /* Rotate right 8 bits */
+ rotr[0] = rotr[1];
+ rotr[1] = rotr[2];
+ rotr[2] = rotr[3];
+ rotr[3] = temp[0];
+ xor_32(add1bf7, rotr, temp);
+ xor_32(swap_halfs, rotl, tempb);
+ xor_32(temp, tempb, out);
+}
+
+static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
+{
+ sint round;
+ sint i;
+ u8 intermediatea[16];
+ u8 intermediateb[16];
+ u8 round_key[16];
+
+ for (i = 0; i < 16; i++)
+ round_key[i] = key[i];
+ for (round = 0; round < 11; round++) {
+ if (round == 0) {
+ xor_128(round_key, data, ciphertext);
+ next_key(round_key, round);
+ } else if (round == 10) {
+ byte_sub(ciphertext, intermediatea);
+ shift_row(intermediatea, intermediateb);
+ xor_128(intermediateb, round_key, ciphertext);
+ } else { /* 1 - 9 */
+ byte_sub(ciphertext, intermediatea);
+ shift_row(intermediatea, intermediateb);
+ mix_column(&intermediateb[0], &intermediatea[0]);
+ mix_column(&intermediateb[4], &intermediatea[4]);
+ mix_column(&intermediateb[8], &intermediatea[8]);
+ mix_column(&intermediateb[12], &intermediatea[12]);
+ xor_128(intermediatea, round_key, ciphertext);
+ next_key(round_key, round);
+ }
+ }
+}
+
+/************************************************/
+/* construct_mic_iv() */
+/* Builds the MIC IV from header fields and PN */
+/************************************************/
+static void construct_mic_iv(u8 *mic_iv, sint qc_exists, sint a4_exists,
+ u8 *mpdu, uint payload_length, u8 *pn_vector)
+{
+ sint i;
+
+ mic_iv[0] = 0x59;
+ if (qc_exists && a4_exists)
+ mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */
+ if (qc_exists && !a4_exists)
+ mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */
+ if (!qc_exists)
+ mic_iv[1] = 0x00;
+ for (i = 2; i < 8; i++)
+ mic_iv[i] = mpdu[i + 8];
+ for (i = 8; i < 14; i++)
+ mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */
+ mic_iv[14] = (unsigned char) (payload_length / 256);
+ mic_iv[15] = (unsigned char) (payload_length % 256);
+}
+
+/************************************************/
+/* construct_mic_header1() */
+/* Builds the first MIC header block from */
+/* header fields. */
+/************************************************/
+static void construct_mic_header1(u8 *mic_header1, sint header_length, u8 *mpdu)
+{
+ mic_header1[0] = (u8)((header_length - 2) / 256);
+ mic_header1[1] = (u8)((header_length - 2) % 256);
+ mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */
+ /* Mute retry, more data and pwr mgt bits */
+ mic_header1[3] = mpdu[1] & 0xc7;
+ mic_header1[4] = mpdu[4]; /* A1 */
+ mic_header1[5] = mpdu[5];
+ mic_header1[6] = mpdu[6];
+ mic_header1[7] = mpdu[7];
+ mic_header1[8] = mpdu[8];
+ mic_header1[9] = mpdu[9];
+ mic_header1[10] = mpdu[10]; /* A2 */
+ mic_header1[11] = mpdu[11];
+ mic_header1[12] = mpdu[12];
+ mic_header1[13] = mpdu[13];
+ mic_header1[14] = mpdu[14];
+ mic_header1[15] = mpdu[15];
+}
+
+/************************************************/
+/* construct_mic_header2() */
+/* Builds the last MIC header block from */
+/* header fields. */
+/************************************************/
+static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, sint a4_exists,
+ sint qc_exists)
+{
+ sint i;
+
+ for (i = 0; i < 16; i++)
+ mic_header2[i] = 0x00;
+ mic_header2[0] = mpdu[16]; /* A3 */
+ mic_header2[1] = mpdu[17];
+ mic_header2[2] = mpdu[18];
+ mic_header2[3] = mpdu[19];
+ mic_header2[4] = mpdu[20];
+ mic_header2[5] = mpdu[21];
+ mic_header2[6] = 0x00;
+ mic_header2[7] = 0x00; /* mpdu[23]; */
+ if (!qc_exists && a4_exists)
+ for (i = 0; i < 6; i++)
+ mic_header2[8 + i] = mpdu[24 + i]; /* A4 */
+ if (qc_exists && !a4_exists) {
+ mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */
+ mic_header2[9] = mpdu[25] & 0x00;
+ }
+ if (qc_exists && a4_exists) {
+ for (i = 0; i < 6; i++)
+ mic_header2[8 + i] = mpdu[24 + i]; /* A4 */
+ mic_header2[14] = mpdu[30] & 0x0f;
+ mic_header2[15] = mpdu[31] & 0x00;
+ }
+}
+
+/************************************************/
+/* construct_mic_header2() */
+/* Builds the last MIC header block from */
+/* header fields. */
+/************************************************/
+static void construct_ctr_preload(u8 *ctr_preload, sint a4_exists, sint qc_exists,
+ u8 *mpdu, u8 *pn_vector, sint c)
+{
+ sint i;
+
+ for (i = 0; i < 16; i++)
+ ctr_preload[i] = 0x00;
+ i = 0;
+ ctr_preload[0] = 0x01; /* flag */
+ if (qc_exists && a4_exists)
+ ctr_preload[1] = mpdu[30] & 0x0f;
+ if (qc_exists && !a4_exists)
+ ctr_preload[1] = mpdu[24] & 0x0f;
+ for (i = 2; i < 8; i++)
+ ctr_preload[i] = mpdu[i + 8];
+ for (i = 8; i < 14; i++)
+ ctr_preload[i] = pn_vector[13 - i];
+ ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */
+ ctr_preload[15] = (unsigned char) (c % 256);
+}
+
+/************************************/
+/* bitwise_xor() */
+/* A 128 bit, bitwise exclusive or */
+/************************************/
+static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
+{
+ sint i;
+
+ for (i = 0; i < 16; i++)
+ out[i] = ina[i] ^ inb[i];
+}
+
+static sint aes_cipher(u8 *key, uint hdrlen,
+ u8 *pframe, uint plen)
+{
+ uint qc_exists, a4_exists, i, j, payload_remainder;
+ uint num_blocks, payload_index;
+
+ u8 pn_vector[6];
+ u8 mic_iv[16];
+ u8 mic_header1[16];
+ u8 mic_header2[16];
+ u8 ctr_preload[16];
+
+ /* Intermediate Buffers */
+ u8 chain_buffer[16];
+ u8 aes_out[16];
+ u8 padded_buffer[16];
+ u8 mic[8];
+ uint frtype = GetFrameType(pframe);
+ uint frsubtype = GetFrameSubType(pframe);
+
+ frsubtype = frsubtype >> 4;
+ memset((void *)mic_iv, 0, 16);
+ memset((void *)mic_header1, 0, 16);
+ memset((void *)mic_header2, 0, 16);
+ memset((void *)ctr_preload, 0, 16);
+ memset((void *)chain_buffer, 0, 16);
+ memset((void *)aes_out, 0, 16);
+ memset((void *)padded_buffer, 0, 16);
+
+ if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN))
+ a4_exists = 0;
+ else
+ a4_exists = 1;
+
+ if ((frtype == WIFI_DATA_CFACK) ||
+ (frtype == WIFI_DATA_CFPOLL) ||
+ (frtype == WIFI_DATA_CFACKPOLL)) {
+ qc_exists = 1;
+ if (hdrlen != WLAN_HDR_A3_QOS_LEN)
+ hdrlen += 2;
+ } else if ((frsubtype == 0x08) ||
+ (frsubtype == 0x09) ||
+ (frsubtype == 0x0a) ||
+ (frsubtype == 0x0b)) {
+ if (hdrlen != WLAN_HDR_A3_QOS_LEN)
+ hdrlen += 2;
+ qc_exists = 1;
+ } else
+ qc_exists = 0;
+ pn_vector[0] = pframe[hdrlen];
+ pn_vector[1] = pframe[hdrlen+1];
+ pn_vector[2] = pframe[hdrlen+4];
+ pn_vector[3] = pframe[hdrlen+5];
+ pn_vector[4] = pframe[hdrlen+6];
+ pn_vector[5] = pframe[hdrlen+7];
+ construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector);
+ construct_mic_header1(mic_header1, hdrlen, pframe);
+ construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists);
+ payload_remainder = plen % 16;
+ num_blocks = plen / 16;
+ /* Find start of payload */
+ payload_index = (hdrlen + 8);
+ /* Calculate MIC */
+ aes128k128d(key, mic_iv, aes_out);
+ bitwise_xor(aes_out, mic_header1, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ bitwise_xor(aes_out, mic_header2, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ for (i = 0; i < num_blocks; i++) {
+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
+ payload_index += 16;
+ aes128k128d(key, chain_buffer, aes_out);
+ }
+ /* Add on the final payload block if it needs padding */
+ if (payload_remainder > 0) {
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < payload_remainder; j++)
+ padded_buffer[j] = pframe[payload_index++];
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ }
+ for (j = 0; j < 8; j++)
+ mic[j] = aes_out[j];
+ /* Insert MIC into payload */
+ for (j = 0; j < 8; j++)
+ pframe[payload_index+j] = mic[j];
+ payload_index = hdrlen + 8;
+ for (i = 0; i < num_blocks; i++) {
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ pframe, pn_vector, i + 1);
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
+ for (j = 0; j < 16; j++)
+ pframe[payload_index++] = chain_buffer[j];
+ }
+ if (payload_remainder > 0) { /* If short final block, then pad it,*/
+ /* encrypt and copy unpadded part back */
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ pframe, pn_vector, num_blocks+1);
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < payload_remainder; j++)
+ padded_buffer[j] = pframe[payload_index+j];
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ for (j = 0; j < payload_remainder; j++)
+ pframe[payload_index++] = chain_buffer[j];
+ }
+ /* Encrypt the MIC */
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ pframe, pn_vector, 0);
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < 8; j++)
+ padded_buffer[j] = pframe[j+hdrlen+8+plen];
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ for (j = 0; j < 8; j++)
+ pframe[payload_index++] = chain_buffer[j];
+ return _SUCCESS;
+}
+
+u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe)
+{ /* exclude ICV */
+ /* Intermediate Buffers */
+ sint curfragnum, length;
+ u32 prwskeylen;
+ u8 *pframe, *prwskey;
+ struct sta_info *stainfo;
+ struct pkt_attrib *pattrib = &((struct xmit_frame *)
+ pxmitframe)->attrib;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ u32 res = _SUCCESS;
+
+ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
+ return _FAIL;
+ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
+ /* 4 start to encrypt each fragment */
+ if ((pattrib->encrypt == _AES_)) {
+ if (pattrib->psta)
+ stainfo = pattrib->psta;
+ else
+ stainfo = r8712_get_stainfo(&padapter->stapriv,
+ &pattrib->ra[0]);
+ if (stainfo != NULL) {
+ prwskey = &stainfo->x_UncstKey.skey[0];
+ prwskeylen = 16;
+ for (curfragnum = 0; curfragnum < pattrib->nr_frags;
+ curfragnum++) {
+ if ((curfragnum + 1) == pattrib->nr_frags) {\
+ length = pattrib->last_txcmdsz -
+ pattrib->hdrlen -
+ pattrib->iv_len -
+ pattrib->icv_len;
+ aes_cipher(prwskey, pattrib->
+ hdrlen, pframe, length);
+ } else {
+ length = pxmitpriv->frag_len -
+ pattrib->hdrlen -
+ pattrib->iv_len -
+ pattrib->icv_len ;
+ aes_cipher(prwskey, pattrib->
+ hdrlen, pframe, length);
+ pframe += pxmitpriv->frag_len;
+ pframe = (u8 *)RND4((addr_t)(pframe));
+ }
+ }
+ } else
+ res = _FAIL;
+ }
+ return res;
+}
+
+static sint aes_decipher(u8 *key, uint hdrlen,
+ u8 *pframe, uint plen)
+{
+ static u8 message[MAX_MSG_SIZE];
+ uint qc_exists, a4_exists, i, j, payload_remainder;
+ uint num_blocks, payload_index;
+ u8 pn_vector[6];
+ u8 mic_iv[16];
+ u8 mic_header1[16];
+ u8 mic_header2[16];
+ u8 ctr_preload[16];
+ /* Intermediate Buffers */
+ u8 chain_buffer[16];
+ u8 aes_out[16];
+ u8 padded_buffer[16];
+ u8 mic[8];
+ uint frtype = GetFrameType(pframe);
+ uint frsubtype = GetFrameSubType(pframe);
+
+ frsubtype = frsubtype >> 4;
+ memset((void *)mic_iv, 0, 16);
+ memset((void *)mic_header1, 0, 16);
+ memset((void *)mic_header2, 0, 16);
+ memset((void *)ctr_preload, 0, 16);
+ memset((void *)chain_buffer, 0, 16);
+ memset((void *)aes_out, 0, 16);
+ memset((void *)padded_buffer, 0, 16);
+ /* start to decrypt the payload */
+ /*(plen including llc, payload and mic) */
+ num_blocks = (plen - 8) / 16;
+ payload_remainder = (plen-8) % 16;
+ pn_vector[0] = pframe[hdrlen];
+ pn_vector[1] = pframe[hdrlen+1];
+ pn_vector[2] = pframe[hdrlen+4];
+ pn_vector[3] = pframe[hdrlen+5];
+ pn_vector[4] = pframe[hdrlen+6];
+ pn_vector[5] = pframe[hdrlen+7];
+ if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN))
+ a4_exists = 0;
+ else
+ a4_exists = 1;
+ if ((frtype == WIFI_DATA_CFACK) ||
+ (frtype == WIFI_DATA_CFPOLL) ||
+ (frtype == WIFI_DATA_CFACKPOLL)) {
+ qc_exists = 1;
+ if (hdrlen != WLAN_HDR_A3_QOS_LEN)
+ hdrlen += 2;
+ } else if ((frsubtype == 0x08) ||
+ (frsubtype == 0x09) ||
+ (frsubtype == 0x0a) ||
+ (frsubtype == 0x0b)) {
+ if (hdrlen != WLAN_HDR_A3_QOS_LEN)
+ hdrlen += 2;
+ qc_exists = 1;
+ } else
+ qc_exists = 0;
+ /* now, decrypt pframe with hdrlen offset and plen long */
+ payload_index = hdrlen + 8; /* 8 is for extiv */
+ for (i = 0; i < num_blocks; i++) {
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ pframe, pn_vector, i + 1);
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
+ for (j = 0; j < 16; j++)
+ pframe[payload_index++] = chain_buffer[j];
+ }
+ if (payload_remainder > 0) { /* If short final block, pad it,*/
+ /* encrypt it and copy the unpadded part back */
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ pframe, pn_vector, num_blocks+1);
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < payload_remainder; j++)
+ padded_buffer[j] = pframe[payload_index + j];
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ for (j = 0; j < payload_remainder; j++)
+ pframe[payload_index++] = chain_buffer[j];
+ }
+ /* start to calculate the mic */
+ memcpy((void *)message, pframe, (hdrlen + plen + 8));
+ pn_vector[0] = pframe[hdrlen];
+ pn_vector[1] = pframe[hdrlen+1];
+ pn_vector[2] = pframe[hdrlen+4];
+ pn_vector[3] = pframe[hdrlen+5];
+ pn_vector[4] = pframe[hdrlen+6];
+ pn_vector[5] = pframe[hdrlen+7];
+ construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8,
+ pn_vector);
+ construct_mic_header1(mic_header1, hdrlen, message);
+ construct_mic_header2(mic_header2, message, a4_exists, qc_exists);
+ payload_remainder = (plen - 8) % 16;
+ num_blocks = (plen - 8) / 16;
+ /* Find start of payload */
+ payload_index = (hdrlen + 8);
+ /* Calculate MIC */
+ aes128k128d(key, mic_iv, aes_out);
+ bitwise_xor(aes_out, mic_header1, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ bitwise_xor(aes_out, mic_header2, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ for (i = 0; i < num_blocks; i++) {
+ bitwise_xor(aes_out, &message[payload_index], chain_buffer);
+ payload_index += 16;
+ aes128k128d(key, chain_buffer, aes_out);
+ }
+ /* Add on the final payload block if it needs padding */
+ if (payload_remainder > 0) {
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < payload_remainder; j++)
+ padded_buffer[j] = message[payload_index++];
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ aes128k128d(key, chain_buffer, aes_out);
+ }
+ for (j = 0 ; j < 8; j++)
+ mic[j] = aes_out[j];
+ /* Insert MIC into payload */
+ for (j = 0; j < 8; j++)
+ message[payload_index+j] = mic[j];
+ payload_index = hdrlen + 8;
+ for (i = 0; i < num_blocks; i++) {
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ message, pn_vector, i + 1);
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, &message[payload_index], chain_buffer);
+ for (j = 0; j < 16; j++)
+ message[payload_index++] = chain_buffer[j];
+ }
+ if (payload_remainder > 0) { /* If short final block, pad it,*/
+ /* encrypt and copy unpadded part back */
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
+ message, pn_vector, num_blocks+1);
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < payload_remainder; j++)
+ padded_buffer[j] = message[payload_index + j];
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ for (j = 0; j < payload_remainder; j++)
+ message[payload_index++] = chain_buffer[j];
+ }
+ /* Encrypt the MIC */
+ construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message,
+ pn_vector, 0);
+ for (j = 0; j < 16; j++)
+ padded_buffer[j] = 0x00;
+ for (j = 0; j < 8; j++)
+ padded_buffer[j] = message[j + hdrlen + plen];
+ aes128k128d(key, ctr_preload, aes_out);
+ bitwise_xor(aes_out, padded_buffer, chain_buffer);
+ for (j = 0; j < 8; j++)
+ message[payload_index++] = chain_buffer[j];
+ /* compare the mic */
+ return _SUCCESS;
+}
+
+u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
+{ /* exclude ICV */
+ /* Intermediate Buffers */
+ sint length;
+ u32 prwskeylen;
+ u8 *pframe, *prwskey, *iv, idx;
+ struct sta_info *stainfo;
+ struct rx_pkt_attrib *prxattrib = &((union recv_frame *)
+ precvframe)->u.hdr.attrib;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+
+ pframe = (unsigned char *)((union recv_frame*)precvframe)->
+ u.hdr.rx_data;
+ /* 4 start to encrypt each fragment */
+ if ((prxattrib->encrypt == _AES_)) {
+ stainfo = r8712_get_stainfo(&padapter->stapriv,
+ &prxattrib->ta[0]);
+ if (stainfo != NULL) {
+ if (IS_MCAST(prxattrib->ra)) {
+ iv = pframe+prxattrib->hdrlen;
+ idx = iv[3];
+ prwskey = &psecuritypriv->XGrpKey[
+ ((idx >> 6) & 0x3) - 1].skey[0];
+ if (psecuritypriv->binstallGrpkey == false)
+ return _FAIL;
+
+ } else
+ prwskey = &stainfo->x_UncstKey.skey[0];
+ prwskeylen = 16;
+ length = ((union recv_frame *)precvframe)->
+ u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len;
+ aes_decipher(prwskey, prxattrib->hdrlen, pframe,
+ length);
+ } else
+ return _FAIL;
+ }
+ return _SUCCESS;
+}
+
+void r8712_use_tkipkey_handler(void *FunctionContext)
+{
+ struct _adapter *padapter = (struct _adapter *)FunctionContext;
+
+ padapter->securitypriv.busetkipkey = true;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_security.h b/drivers/staging/rtl8712/rtl871x_security.h
new file mode 100644
index 000000000000..782b70a352fb
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_security.h
@@ -0,0 +1,196 @@
+#ifndef __RTL871X_SECURITY_H_
+#define __RTL871X_SECURITY_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+#define _NO_PRIVACY_ 0x0
+#define _WEP40_ 0x1
+#define _TKIP_ 0x2
+#define _TKIP_WTMIC_ 0x3
+#define _AES_ 0x4
+#define _WEP104_ 0x5
+
+#define _WPA_IE_ID_ 0xdd
+#define _WPA2_IE_ID_ 0x30
+
+#ifndef Ndis802_11AuthModeWPA2
+#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
+#endif
+
+#ifndef Ndis802_11AuthModeWPA2PSK
+#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
+#endif
+union pn48 {
+ u64 val;
+#if defined(__BIG_ENDIAN)
+struct {
+ u8 TSC7;
+ u8 TSC6;
+ u8 TSC5;
+ u8 TSC4;
+ u8 TSC3;
+ u8 TSC2;
+ u8 TSC1;
+ u8 TSC0;
+} _byte_;
+#else
+struct {
+ u8 TSC0;
+ u8 TSC1;
+ u8 TSC2;
+ u8 TSC3;
+ u8 TSC4;
+ u8 TSC5;
+ u8 TSC6;
+ u8 TSC7;
+} _byte_;
+#endif
+};
+
+union Keytype {
+ u8 skey[16];
+ u32 lkey[4];
+};
+
+struct RT_PMKID_LIST {
+ u8 bUsed;
+ u8 Bssid[6];
+ u8 PMKID[16];
+ u8 SsidBuf[33];
+ u8 *ssid_octet;
+ u16 ssid_length;
+};
+
+struct security_priv {
+ u32 AuthAlgrthm; /* 802.11 auth, could be open, shared,
+ * 8021x and authswitch */
+ u32 PrivacyAlgrthm; /* This specify the privacy for shared
+ * auth. algorithm. */
+ u32 PrivacyKeyIndex; /* this is only valid for legendary
+ * wep, 0~3 for key id. */
+ union Keytype DefKey[4]; /* this is only valid for def. key */
+ u32 DefKeylen[4];
+ u32 XGrpPrivacy; /* This specify the privacy algthm.
+ * used for Grp key */
+ u32 XGrpKeyid; /* key id used for Grp Key */
+ union Keytype XGrpKey[2]; /* 802.1x Group Key, for
+ * inx0 and inx1 */
+ union Keytype XGrptxmickey[2];
+ union Keytype XGrprxmickey[2];
+ union pn48 Grptxpn; /* PN48 used for Grp Key xmit. */
+ union pn48 Grprxpn; /* PN48 used for Grp Key recv. */
+ u8 wps_hw_pbc_pressed;/*for hw pbc pressed*/
+ u8 wps_phase;/*for wps*/
+ u8 wps_ie[MAX_WPA_IE_LEN<<2];
+ int wps_ie_len;
+ u8 binstallGrpkey;
+ u8 busetkipkey;
+ struct timer_list tkip_timer;
+ u8 bcheck_grpkey;
+ u8 bgrpkey_handshake;
+ s32 sw_encrypt; /* from registry_priv */
+ s32 sw_decrypt; /* from registry_priv */
+ s32 hw_decrypted; /* if the rx packets is hw_decrypted==false,
+ * it means the hw has not been ready. */
+ u32 ndisauthtype; /* keeps the auth_type & enc_status from upper
+ * layer ioctl(wpa_supplicant or wzc) */
+ u32 ndisencryptstatus;
+ struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
+ struct NDIS_802_11_WEP ndiswep;
+ u8 assoc_info[600];
+ u8 szofcapability[256]; /* for wpa2 usage */
+ u8 oidassociation[512]; /* for wpa/wpa2 usage */
+ u8 authenticator_ie[256]; /* store ap security information element */
+ u8 supplicant_ie[256]; /* store sta security information element */
+ /* for tkip countermeasure */
+ u32 last_mic_err_time;
+ u8 btkip_countermeasure;
+ u8 btkip_wait_report;
+ u32 btkip_countermeasure_time;
+ /*-------------------------------------------------------------------
+ * For WPA2 Pre-Authentication.
+ *------------------------------------------------------------------ */
+ struct RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
+ u8 PMKIDIndex;
+};
+
+#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \
+do { \
+ switch (psecuritypriv->AuthAlgrthm) { \
+ case 0: \
+ case 1: \
+ case 3: \
+ encry_algo = (u8)psecuritypriv->PrivacyAlgrthm; \
+ break; \
+ case 2: \
+ if (bmcst) \
+ encry_algo = (u8)psecuritypriv->XGrpPrivacy; \
+ else \
+ encry_algo = (u8)psta->XPrivacy; \
+ break; \
+ } \
+} while (0)
+#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)\
+do {\
+ switch (encrypt) { \
+ case _WEP40_: \
+ case _WEP104_: \
+ iv_len = 4; \
+ icv_len = 4; \
+ break; \
+ case _TKIP_: \
+ iv_len = 8; \
+ icv_len = 4; \
+ break; \
+ case _AES_: \
+ iv_len = 8; \
+ icv_len = 8; \
+ break; \
+ default: \
+ iv_len = 0; \
+ icv_len = 0; \
+ break; \
+ } \
+} while (0)
+#define GET_TKIP_PN(iv, txpn) \
+do {\
+ txpn._byte_.TSC0 = iv[2];\
+ txpn._byte_.TSC1 = iv[0];\
+ txpn._byte_.TSC2 = iv[4];\
+ txpn._byte_.TSC3 = iv[5];\
+ txpn._byte_.TSC4 = iv[6];\
+ txpn._byte_.TSC5 = iv[7];\
+} while (0)
+
+#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
+#define ROR32(A, n) ROL32((A), 32 - (n))
+
+struct mic_data {
+ u32 K0, K1; /* Key */
+ u32 L, R; /* Current state */
+ u32 M; /* Message accumulator (single word) */
+ u32 nBytesInM; /* # bytes in M */
+};
+
+void seccalctkipmic(
+ u8 *key,
+ u8 *header,
+ u8 *data,
+ u32 data_len,
+ u8 *Miccode,
+ u8 priority);
+
+void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
+void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes);
+void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst);
+u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe);
+u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe);
+void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe);
+u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe);
+u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe);
+void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe);
+void r8712_use_tkipkey_handler(void *FunctionContext);
+
+#endif /*__RTL871X_SECURITY_H_ */
+
diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c
new file mode 100644
index 000000000000..64f569618839
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c
@@ -0,0 +1,299 @@
+/******************************************************************************
+ * rtl871x_sta_mgt.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_STA_MGT_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "xmit_osdep.h"
+#include "sta_info.h"
+
+static void _init_stainfo(struct sta_info *psta)
+{
+ memset((u8 *)psta, 0, sizeof(struct sta_info));
+ spin_lock_init(&psta->lock);
+ _init_listhead(&psta->list);
+ _init_listhead(&psta->hash_list);
+ _r8712_init_sta_xmit_priv(&psta->sta_xmitpriv);
+ _r8712_init_sta_recv_priv(&psta->sta_recvpriv);
+#ifdef CONFIG_R8712_AP
+ _init_listhead(&psta->auth_list);
+#endif
+}
+
+u32 _r8712_init_sta_priv(struct sta_priv *pstapriv)
+{
+ struct sta_info *psta;
+ s32 i;
+
+ pstapriv->pallocated_stainfo_buf = _malloc(sizeof(struct sta_info) *
+ NUM_STA + 4);
+ if (pstapriv->pallocated_stainfo_buf == NULL)
+ return _FAIL;
+ pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
+ ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
+ _init_queue(&pstapriv->free_sta_queue);
+ spin_lock_init(&pstapriv->sta_hash_lock);
+ pstapriv->asoc_sta_count = 0;
+ _init_queue(&pstapriv->sleep_q);
+ _init_queue(&pstapriv->wakeup_q);
+ psta = (struct sta_info *)(pstapriv->pstainfo_buf);
+ for (i = 0; i < NUM_STA; i++) {
+ _init_stainfo(psta);
+ _init_listhead(&(pstapriv->sta_hash[i]));
+ list_insert_tail(&psta->list,
+ get_list_head(&pstapriv->free_sta_queue));
+ psta++;
+ }
+#ifdef CONFIG_R8712_AP
+ _init_listhead(&pstapriv->asoc_list);
+ _init_listhead(&pstapriv->auth_list);
+#endif
+ return _SUCCESS;
+}
+
+/* this function is used to free the memory of lock || sema for all stainfos */
+static void mfree_all_stainfo(struct sta_priv *pstapriv)
+{
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ struct sta_info *psta = NULL;
+
+ spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
+ phead = get_list_head(&pstapriv->free_sta_queue);
+ plist = get_next(phead);
+ while ((end_of_queue_search(phead, plist)) == false) {
+ psta = LIST_CONTAINOR(plist, struct sta_info, list);
+ plist = get_next(plist);
+ }
+
+ spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
+}
+
+
+static void mfree_sta_priv_lock(struct sta_priv *pstapriv)
+{
+ mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */
+}
+
+u32 _r8712_free_sta_priv(struct sta_priv *pstapriv)
+{
+ if (pstapriv) {
+ mfree_sta_priv_lock(pstapriv);
+ kfree(pstapriv->pallocated_stainfo_buf);
+ }
+ return _SUCCESS;
+}
+
+struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
+{
+ uint tmp_aid;
+ s32 index;
+ struct list_head *phash_list;
+ struct sta_info *psta;
+ struct __queue *pfree_sta_queue;
+ struct recv_reorder_ctrl *preorder_ctrl;
+ int i = 0;
+ u16 wRxSeqInitialValue = 0xffff;
+ unsigned long flags;
+
+ pfree_sta_queue = &pstapriv->free_sta_queue;
+ spin_lock_irqsave(&(pfree_sta_queue->lock), flags);
+ if (_queue_empty(pfree_sta_queue) == true)
+ psta = NULL;
+ else {
+ psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue),
+ struct sta_info, list);
+ list_delete(&(psta->list));
+ tmp_aid = psta->aid;
+ _init_stainfo(psta);
+ memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
+ index = wifi_mac_hash(hwaddr);
+ if (index >= NUM_STA) {
+ psta = NULL;
+ goto exit;
+ }
+ phash_list = &(pstapriv->sta_hash[index]);
+ list_insert_tail(&psta->hash_list, phash_list);
+ pstapriv->asoc_sta_count++ ;
+
+/* For the SMC router, the sequence number of first packet of WPS handshake
+ * will be 0. In this case, this packet will be dropped by recv_decache function
+ * if we use the 0x00 as the default value for tid_rxseq variable. So, we
+ * initialize the tid_rxseq variable as the 0xffff.
+ */
+ for (i = 0; i < 16; i++)
+ memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i],
+ &wRxSeqInitialValue, 2);
+ /* for A-MPDU Rx reordering buffer control */
+ for (i = 0; i < 16 ; i++) {
+ preorder_ctrl = &psta->recvreorder_ctrl[i];
+ preorder_ctrl->padapter = pstapriv->padapter;
+ preorder_ctrl->indicate_seq = 0xffff;
+ preorder_ctrl->wend_b = 0xffff;
+ preorder_ctrl->wsize_b = 64;
+ _init_queue(&preorder_ctrl->pending_recvframe_queue);
+ r8712_init_recv_timer(preorder_ctrl);
+ }
+ }
+exit:
+ spin_unlock_irqrestore(&(pfree_sta_queue->lock), flags);
+ return psta;
+}
+
+/* using pstapriv->sta_hash_lock to protect */
+void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta)
+{
+ int i;
+ unsigned long irqL0;
+ struct __queue *pfree_sta_queue;
+ struct recv_reorder_ctrl *preorder_ctrl;
+ struct sta_xmit_priv *pstaxmitpriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+
+ if (psta == NULL)
+ return;
+ pfree_sta_queue = &pstapriv->free_sta_queue;
+ pstaxmitpriv = &psta->sta_xmitpriv;
+ spin_lock_irqsave(&(pxmitpriv->vo_pending.lock), irqL0);
+ r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);
+ list_delete(&(pstaxmitpriv->vo_q.tx_pending));
+ spin_unlock_irqrestore(&(pxmitpriv->vo_pending.lock), irqL0);
+ spin_lock_irqsave(&(pxmitpriv->vi_pending.lock), irqL0);
+ r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);
+ list_delete(&(pstaxmitpriv->vi_q.tx_pending));
+ spin_unlock_irqrestore(&(pxmitpriv->vi_pending.lock), irqL0);
+ spin_lock_irqsave(&(pxmitpriv->bk_pending.lock), irqL0);
+ r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);
+ list_delete(&(pstaxmitpriv->bk_q.tx_pending));
+ spin_unlock_irqrestore(&(pxmitpriv->bk_pending.lock), irqL0);
+ spin_lock_irqsave(&(pxmitpriv->be_pending.lock), irqL0);
+ r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending);
+ list_delete(&(pstaxmitpriv->be_q.tx_pending));
+ spin_unlock_irqrestore(&(pxmitpriv->be_pending.lock), irqL0);
+ list_delete(&psta->hash_list);
+ pstapriv->asoc_sta_count--;
+ /* re-init sta_info; 20061114 */
+ _r8712_init_sta_xmit_priv(&psta->sta_xmitpriv);
+ _r8712_init_sta_recv_priv(&psta->sta_recvpriv);
+ /* for A-MPDU Rx reordering buffer control,
+ * cancel reordering_ctrl_timer */
+ for (i = 0; i < 16; i++) {
+ preorder_ctrl = &psta->recvreorder_ctrl[i];
+ _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
+ }
+ spin_lock(&(pfree_sta_queue->lock));
+ /* insert into free_sta_queue; 20061114 */
+ list_insert_tail(&psta->list, get_list_head(pfree_sta_queue));
+ spin_unlock(&(pfree_sta_queue->lock));
+}
+
+/* free all stainfo which in sta_hash[all] */
+void r8712_free_all_stainfo(struct _adapter *padapter)
+{
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ s32 index;
+ struct sta_info *psta = NULL;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ struct sta_info *pbcmc_stainfo = r8712_get_bcmc_stainfo(padapter);
+
+ if (pstapriv->asoc_sta_count == 1)
+ return;
+ spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
+ for (index = 0; index < NUM_STA; index++) {
+ phead = &(pstapriv->sta_hash[index]);
+ plist = get_next(phead);
+ while ((end_of_queue_search(phead, plist)) == false) {
+ psta = LIST_CONTAINOR(plist,
+ struct sta_info, hash_list);
+ plist = get_next(plist);
+ if (pbcmc_stainfo != psta)
+ r8712_free_stainfo(padapter , psta);
+ }
+ }
+ spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
+}
+
+/* any station allocated can be searched by hash list */
+struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
+{
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ struct sta_info *psta = NULL;
+ u32 index;
+
+ if (hwaddr == NULL)
+ return NULL;
+ index = wifi_mac_hash(hwaddr);
+ spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
+ phead = &(pstapriv->sta_hash[index]);
+ plist = get_next(phead);
+ while ((end_of_queue_search(phead, plist)) == false) {
+ psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
+ if ((!memcmp(psta->hwaddr, hwaddr, ETH_ALEN))) {
+ /* if found the matched address */
+ break;
+ }
+ psta = NULL;
+ plist = get_next(plist);
+ }
+ spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
+ return psta;
+}
+
+void r8712_init_bcmc_stainfo(struct _adapter *padapter)
+{
+ struct sta_info *psta;
+ struct tx_servq *ptxservq;
+ unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ struct sta_priv *pstapriv = &padapter->stapriv;
+
+ psta = r8712_alloc_stainfo(pstapriv, bcast_addr);
+ if (psta == NULL)
+ return;
+ ptxservq = &(psta->sta_xmitpriv.be_q);
+}
+
+struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter)
+{
+ struct sta_info *psta;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+ psta = r8712_get_stainfo(pstapriv, bc_addr);
+ return psta;
+}
+
+
+u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr)
+{
+ return true;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_wlan_sme.h b/drivers/staging/rtl8712/rtl871x_wlan_sme.h
new file mode 100644
index 000000000000..d9733ac6a43a
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_wlan_sme.h
@@ -0,0 +1,22 @@
+#ifndef _RTL871X_WLAN_SME_H_
+#define _RTL871X_WLAN_SME_H_
+
+#define MSR_APMODE 0x0C
+#define MSR_STAMODE 0x08
+#define MSR_ADHOCMODE 0x04
+#define MSR_NOLINKMODE 0x00
+#define _1M_RATE_ 0
+#define _2M_RATE_ 1
+#define _5M_RATE_ 2
+#define _11M_RATE_ 3
+#define _6M_RATE_ 4
+#define _9M_RATE_ 5
+#define _12M_RATE_ 6
+#define _18M_RATE_ 7
+#define _24M_RATE_ 8
+#define _36M_RATE_ 9
+#define _48M_RATE_ 10
+#define _54M_RATE_ 11
+
+#endif
+
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c
new file mode 100644
index 000000000000..b8195e3a72d4
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -0,0 +1,1052 @@
+/******************************************************************************
+ * rtl871x_xmit.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _RTL871X_XMIT_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "rtl871x_byteorder.h"
+#include "wifi.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+
+static const u8 P802_1H_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0xf8};
+static const u8 RFC1042_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0x00};
+static void init_hwxmits(struct hw_xmit *phwxmit, sint entry);
+static void alloc_hwxmits(struct _adapter *padapter);
+static void free_hwxmits(struct _adapter *padapter);
+
+static void _init_txservq(struct tx_servq *ptxservq)
+{
+ _init_listhead(&ptxservq->tx_pending);
+ _init_queue(&ptxservq->sta_pending);
+ ptxservq->qcnt = 0;
+}
+
+void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv)
+{
+ memset((unsigned char *)psta_xmitpriv, 0,
+ sizeof(struct sta_xmit_priv));
+ spin_lock_init(&psta_xmitpriv->lock);
+ _init_txservq(&psta_xmitpriv->be_q);
+ _init_txservq(&psta_xmitpriv->bk_q);
+ _init_txservq(&psta_xmitpriv->vi_q);
+ _init_txservq(&psta_xmitpriv->vo_q);
+ _init_listhead(&psta_xmitpriv->legacy_dz);
+ _init_listhead(&psta_xmitpriv->apsd);
+}
+
+sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
+ struct _adapter *padapter)
+{
+ sint i;
+ struct xmit_buf *pxmitbuf;
+ struct xmit_frame *pxframe;
+
+ memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv));
+ spin_lock_init(&pxmitpriv->lock);
+ sema_init(&pxmitpriv->xmit_sema, 0);
+ sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
+ /*
+ Please insert all the queue initializaiton using _init_queue below
+ */
+ pxmitpriv->adapter = padapter;
+ _init_queue(&pxmitpriv->be_pending);
+ _init_queue(&pxmitpriv->bk_pending);
+ _init_queue(&pxmitpriv->vi_pending);
+ _init_queue(&pxmitpriv->vo_pending);
+ _init_queue(&pxmitpriv->bm_pending);
+ _init_queue(&pxmitpriv->legacy_dz_queue);
+ _init_queue(&pxmitpriv->apsd_queue);
+ _init_queue(&pxmitpriv->free_xmit_queue);
+ /*
+ Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
+ and initialize free_xmit_frame below.
+ Please also apply free_txobj to link_up all the xmit_frames...
+ */
+ pxmitpriv->pallocated_frame_buf = _malloc(NR_XMITFRAME *
+ sizeof(struct xmit_frame) + 4);
+ if (pxmitpriv->pallocated_frame_buf == NULL) {
+ pxmitpriv->pxmit_frame_buf = NULL;
+ return _FAIL;
+ }
+ pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 -
+ ((addr_t) (pxmitpriv->pallocated_frame_buf) & 3);
+ pxframe = (struct xmit_frame *) pxmitpriv->pxmit_frame_buf;
+ for (i = 0; i < NR_XMITFRAME; i++) {
+ _init_listhead(&(pxframe->list));
+ pxframe->padapter = padapter;
+ pxframe->frame_tag = DATA_FRAMETAG;
+ pxframe->pkt = NULL;
+ pxframe->buf_addr = NULL;
+ pxframe->pxmitbuf = NULL;
+ list_insert_tail(&(pxframe->list),
+ &(pxmitpriv->free_xmit_queue.queue));
+ pxframe++;
+ }
+ pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME;
+ /*
+ init xmit hw_txqueue
+ */
+ _r8712_init_hw_txqueue(&pxmitpriv->be_txqueue, BE_QUEUE_INX);
+ _r8712_init_hw_txqueue(&pxmitpriv->bk_txqueue, BK_QUEUE_INX);
+ _r8712_init_hw_txqueue(&pxmitpriv->vi_txqueue, VI_QUEUE_INX);
+ _r8712_init_hw_txqueue(&pxmitpriv->vo_txqueue, VO_QUEUE_INX);
+ _r8712_init_hw_txqueue(&pxmitpriv->bmc_txqueue, BMC_QUEUE_INX);
+ pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
+ pxmitpriv->txirp_cnt = 1;
+ sema_init(&(pxmitpriv->tx_retevt), 0);
+ /*per AC pending irp*/
+ pxmitpriv->beq_cnt = 0;
+ pxmitpriv->bkq_cnt = 0;
+ pxmitpriv->viq_cnt = 0;
+ pxmitpriv->voq_cnt = 0;
+ /*init xmit_buf*/
+ _init_queue(&pxmitpriv->free_xmitbuf_queue);
+ _init_queue(&pxmitpriv->pending_xmitbuf_queue);
+ pxmitpriv->pallocated_xmitbuf = _malloc(NR_XMITBUFF *
+ sizeof(struct xmit_buf) + 4);
+ if (pxmitpriv->pallocated_xmitbuf == NULL)
+ return _FAIL;
+ pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 -
+ ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3);
+ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
+ for (i = 0; i < NR_XMITBUFF; i++) {
+ _init_listhead(&pxmitbuf->list);
+ pxmitbuf->pallocated_buf = _malloc(MAX_XMITBUF_SZ +
+ XMITBUF_ALIGN_SZ);
+ if (pxmitbuf->pallocated_buf == NULL)
+ return _FAIL;
+ pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ -
+ ((addr_t) (pxmitbuf->pallocated_buf) &
+ (XMITBUF_ALIGN_SZ - 1));
+ r8712_xmit_resource_alloc(padapter, pxmitbuf);
+ list_insert_tail(&pxmitbuf->list,
+ &(pxmitpriv->free_xmitbuf_queue.queue));
+ pxmitbuf++;
+ }
+ pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF;
+ alloc_hwxmits(padapter);
+ init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
+ tasklet_init(&pxmitpriv->xmit_tasklet,
+ (void(*)(addr_t))r8712_xmit_bh,
+ (addr_t)padapter);
+ return _SUCCESS;
+}
+
+void _free_xmit_priv(struct xmit_priv *pxmitpriv)
+{
+ int i;
+ struct _adapter *padapter = pxmitpriv->adapter;
+ struct xmit_frame *pxmitframe = (struct xmit_frame *)
+ pxmitpriv->pxmit_frame_buf;
+ struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
+
+ if (pxmitpriv->pxmit_frame_buf == NULL)
+ return;
+ for (i = 0; i < NR_XMITFRAME; i++) {
+ r8712_xmit_complete(padapter, pxmitframe);
+ pxmitframe++;
+ }
+ for (i = 0; i < NR_XMITBUFF; i++) {
+ r8712_xmit_resource_free(padapter, pxmitbuf);
+ kfree(pxmitbuf->pallocated_buf);
+ pxmitbuf++;
+ }
+ kfree(pxmitpriv->pallocated_frame_buf);
+ kfree(pxmitpriv->pallocated_xmitbuf);
+ free_hwxmits(padapter);
+}
+
+sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
+ struct pkt_attrib *pattrib)
+{
+ uint i;
+ struct pkt_file pktfile;
+ struct sta_info *psta = NULL;
+ struct ethhdr etherhdr;
+
+ struct tx_cmd txdesc;
+
+ sint bmcast;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+
+ _r8712_open_pktfile(pkt, &pktfile);
+
+ i = _r8712_pktfile_read(&pktfile, (unsigned char *)&etherhdr, ETH_HLEN);
+
+ pattrib->ether_type = ntohs(etherhdr.h_proto);
+
+{
+ u8 bool;
+ /*If driver xmit ARP packet, driver can set ps mode to initial
+ * setting. It stands for getting DHCP or fix IP.*/
+ if (pattrib->ether_type == 0x0806) {
+ if (padapter->pwrctrlpriv.pwr_mode !=
+ padapter->registrypriv.power_mgnt) {
+ _cancel_timer(&(pmlmepriv->dhcp_timer), &bool);
+ r8712_set_ps_mode(padapter, padapter->registrypriv.
+ power_mgnt, padapter->registrypriv.smart_ps);
+ }
+ }
+}
+ memcpy(pattrib->dst, &etherhdr.h_dest, ETH_ALEN);
+ memcpy(pattrib->src, &etherhdr.h_source, ETH_ALEN);
+ pattrib->pctrl = 0;
+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
+ (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
+ memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
+ memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+ } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
+ memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
+ memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
+ memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
+ memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN);
+ } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
+ /*firstly, filter packet not belongs to mp*/
+ if (pattrib->ether_type != 0x8712)
+ return _FAIL;
+ /* for mp storing the txcmd per packet,
+ * according to the info of txcmd to update pattrib */
+ /*get MP_TXDESC_SIZE bytes txcmd per packet*/
+ i = _r8712_pktfile_read(&pktfile, (u8 *)&txdesc, TXDESC_SIZE);
+ memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
+ memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
+ pattrib->pctrl = 1;
+ }
+ /* r8712_xmitframe_coalesce() overwrite this!*/
+ pattrib->pktlen = pktfile.pkt_len;
+ if (ETH_P_IP == pattrib->ether_type) {
+ /* The following is for DHCP and ARP packet, we use cck1M to
+ * tx these packets and let LPS awake some time
+ * to prevent DHCP protocol fail */
+ u8 tmp[24];
+ _r8712_pktfile_read(&pktfile, &tmp[0], 24);
+ pattrib->dhcp_pkt = 0;
+ if (pktfile.pkt_len > 282) {/*MINIMUM_DHCP_PACKET_SIZE)*/
+ if (ETH_P_IP == pattrib->ether_type) {/* IP header*/
+ if (((tmp[21] == 68) && (tmp[23] == 67)) ||
+ ((tmp[21] == 67) && (tmp[23] == 68))) {
+ /* 68 : UDP BOOTP client
+ * 67 : UDP BOOTP server
+ * Use low rate to send DHCP packet.*/
+ pattrib->dhcp_pkt = 1;
+ }
+ }
+ }
+ }
+ bmcast = IS_MCAST(pattrib->ra);
+ /* get sta_info*/
+ if (bmcast) {
+ psta = r8712_get_bcmc_stainfo(padapter);
+ pattrib->mac_id = 4;
+ } else {
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
+ psta = r8712_get_stainfo(pstapriv,
+ get_bssid(pmlmepriv));
+ pattrib->mac_id = 5;
+ } else {
+ psta = r8712_get_stainfo(pstapriv, pattrib->ra);
+ if (psta == NULL) /* drop the pkt */
+ return _FAIL;
+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
+ pattrib->mac_id = 5;
+ else
+ pattrib->mac_id = psta->mac_id;
+ }
+ }
+
+ if (psta) {
+ pattrib->psta = psta;
+ } else {
+ /* if we cannot get psta => drrp the pkt */
+ return _FAIL;
+ }
+
+ pattrib->ack_policy = 0;
+ /* get ether_hdr_len */
+ pattrib->pkt_hdrlen = ETH_HLEN;
+
+ if (pqospriv->qos_option)
+ r8712_set_qos(&pktfile, pattrib);
+ else {
+ pattrib->hdrlen = WLAN_HDR_A3_LEN;
+ pattrib->subtype = WIFI_DATA_TYPE;
+ pattrib->priority = 0;
+ }
+ if (psta->ieee8021x_blocked == true) {
+ pattrib->encrypt = 0;
+ if ((pattrib->ether_type != 0x888e) &&
+ (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false))
+ return _FAIL;
+ } else
+ GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
+ switch (pattrib->encrypt) {
+ case _WEP40_:
+ case _WEP104_:
+ pattrib->iv_len = 4;
+ pattrib->icv_len = 4;
+ break;
+ case _TKIP_:
+ pattrib->iv_len = 8;
+ pattrib->icv_len = 4;
+ if (padapter->securitypriv.busetkipkey == _FAIL)
+ return _FAIL;
+ break;
+ case _AES_:
+ pattrib->iv_len = 8;
+ pattrib->icv_len = 8;
+ break;
+ default:
+ pattrib->iv_len = 0;
+ pattrib->icv_len = 0;
+ break;
+ }
+
+ if (pattrib->encrypt &&
+ ((padapter->securitypriv.sw_encrypt == true) ||
+ (psecuritypriv->hw_decrypted == false)))
+ pattrib->bswenc = true;
+ else
+ pattrib->bswenc = false;
+ /* if in MP_STATE, update pkt_attrib from mp_txcmd, and overwrite
+ * some settings above.*/
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
+ pattrib->priority = (txdesc.txdw1 >> QSEL_SHT) & 0x1f;
+ return _SUCCESS;
+}
+
+static sint xmitframe_addmic(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe)
+{
+ u32 curfragnum, length, datalen;
+ u8 *pframe, *payload, mic[8];
+ struct mic_data micdata;
+ struct sta_info *stainfo;
+ struct qos_priv *pqospriv = &(padapter->mlmepriv.qospriv);
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
+ sint bmcst = IS_MCAST(pattrib->ra);
+
+ if (pattrib->psta)
+ stainfo = pattrib->psta;
+ else
+ stainfo = r8712_get_stainfo(&padapter->stapriv,
+ &pattrib->ra[0]);
+ if (pattrib->encrypt == _TKIP_) {
+ /*encode mic code*/
+ if (stainfo != NULL) {
+ u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0};
+ datalen = pattrib->pktlen - pattrib->hdrlen;
+ pframe = pxmitframe->buf_addr + TXDESC_OFFSET;;
+ if (bmcst) {
+ if (!memcmp(psecuritypriv->XGrptxmickey
+ [psecuritypriv->XGrpKeyid].skey,
+ null_key, 16))
+ return _FAIL;
+ /*start to calculate the mic code*/
+ r8712_secmicsetkey(&micdata,
+ psecuritypriv->
+ XGrptxmickey[psecuritypriv->
+ XGrpKeyid].skey);
+ } else {
+ if (!memcmp(&stainfo->tkiptxmickey.skey[0],
+ null_key, 16))
+ return _FAIL;
+ /* start to calculate the mic code */
+ r8712_secmicsetkey(&micdata,
+ &stainfo->tkiptxmickey.skey[0]);
+ }
+ if (pframe[1] & 1) { /* ToDS==1 */
+ r8712_secmicappend(&micdata,
+ &pframe[16], 6); /*DA*/
+ if (pframe[1]&2) /* From Ds==1 */
+ r8712_secmicappend(&micdata,
+ &pframe[24], 6);
+ else
+ r8712_secmicappend(&micdata,
+ &pframe[10], 6);
+ } else { /* ToDS==0 */
+ r8712_secmicappend(&micdata,
+ &pframe[4], 6); /* DA */
+ if (pframe[1]&2) /* From Ds==1 */
+ r8712_secmicappend(&micdata,
+ &pframe[16], 6);
+ else
+ r8712_secmicappend(&micdata,
+ &pframe[10], 6);
+ }
+ if (pqospriv->qos_option == 1)
+ priority[0] = (u8)pxmitframe->
+ attrib.priority;
+ r8712_secmicappend(&micdata, &priority[0], 4);
+ payload = pframe;
+ for (curfragnum = 0; curfragnum < pattrib->nr_frags;
+ curfragnum++) {
+ payload = (u8 *)RND4((addr_t)(payload));
+ payload = payload+pattrib->
+ hdrlen+pattrib->iv_len;
+ if ((curfragnum + 1) == pattrib->nr_frags) {
+ length = pattrib->last_txcmdsz -
+ pattrib->hdrlen -
+ pattrib->iv_len -
+ ((psecuritypriv->sw_encrypt)
+ ? pattrib->icv_len : 0);
+ r8712_secmicappend(&micdata, payload,
+ length);
+ payload = payload+length;
+ } else{
+ length = pxmitpriv->frag_len -
+ pattrib->hdrlen-pattrib->iv_len -
+ ((psecuritypriv->sw_encrypt) ?
+ pattrib->icv_len : 0);
+ r8712_secmicappend(&micdata, payload,
+ length);
+ payload = payload + length +
+ pattrib->icv_len;
+ }
+ }
+ r8712_secgetmic(&micdata, &(mic[0]));
+ /* add mic code and add the mic code length in
+ * last_txcmdsz */
+ memcpy(payload, &(mic[0]), 8);
+ pattrib->last_txcmdsz += 8;
+ payload = payload-pattrib->last_txcmdsz + 8;
+ }
+ }
+ return _SUCCESS;
+}
+
+static sint xmitframe_swencrypt(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe)
+{
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+
+ if (pattrib->bswenc) {
+ switch (pattrib->encrypt) {
+ case _WEP40_:
+ case _WEP104_:
+ r8712_wep_encrypt(padapter, (u8 *)pxmitframe);
+ break;
+ case _TKIP_:
+ r8712_tkip_encrypt(padapter, (u8 *)pxmitframe);
+ break;
+ case _AES_:
+ r8712_aes_encrypt(padapter, (u8 *)pxmitframe);
+ break;
+ default:
+ break;
+ }
+ }
+ return _SUCCESS;
+}
+
+static sint make_wlanhdr(struct _adapter *padapter , u8 *hdr,
+ struct pkt_attrib *pattrib)
+{
+ u16 *qc;
+
+ struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct qos_priv *pqospriv = &pmlmepriv->qospriv;
+ u16 *fctrl = &pwlanhdr->frame_ctl;
+ memset(hdr, 0, WLANHDR_OFFSET);
+ SetFrameSubType(fctrl, pattrib->subtype);
+ if (pattrib->subtype & WIFI_DATA_TYPE) {
+ if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) {
+ /* to_ds = 1, fr_ds = 0; */
+ SetToDs(fctrl);
+ memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv),
+ ETH_ALEN);
+ memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
+ memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN);
+ } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) {
+ /* to_ds = 0, fr_ds = 1; */
+ SetFrDs(fctrl);
+ memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
+ memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv),
+ ETH_ALEN);
+ memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
+ } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
+ || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)
+ == true)) {
+ memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
+ memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
+ memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv),
+ ETH_ALEN);
+ } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
+ memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
+ memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
+ memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv),
+ ETH_ALEN);
+ } else
+ return _FAIL;
+
+ if (pattrib->encrypt)
+ SetPrivacy(fctrl);
+ if (pqospriv->qos_option) {
+ qc = (unsigned short *)(hdr + pattrib->hdrlen - 2);
+ if (pattrib->priority)
+ SetPriority(qc, pattrib->priority);
+ SetAckpolicy(qc, pattrib->ack_policy);
+ }
+ /* TODO: fill HT Control Field */
+ /* Update Seq Num will be handled by f/w */
+ {
+ struct sta_info *psta;
+
+ sint bmcst = IS_MCAST(pattrib->ra);
+ if (pattrib->psta)
+ psta = pattrib->psta;
+ else {
+ if (bmcst)
+ psta = r8712_get_bcmc_stainfo(padapter);
+ else
+ psta =
+ r8712_get_stainfo(&padapter->stapriv,
+ pattrib->ra);
+ }
+ if (psta) {
+ psta->sta_xmitpriv.txseq_tid
+ [pattrib->priority]++;
+ psta->sta_xmitpriv.txseq_tid[pattrib->priority]
+ &= 0xFFF;
+ pattrib->seqnum = psta->sta_xmitpriv.
+ txseq_tid[pattrib->priority];
+ SetSeqNum(hdr, pattrib->seqnum);
+ }
+ }
+ }
+ return _SUCCESS;
+}
+
+static sint r8712_put_snap(u8 *data, u16 h_proto)
+{
+ struct ieee80211_snap_hdr *snap;
+ const u8 *oui;
+
+ snap = (struct ieee80211_snap_hdr *)data;
+ snap->dsap = 0xaa;
+ snap->ssap = 0xaa;
+ snap->ctrl = 0x03;
+ if (h_proto == 0x8137 || h_proto == 0x80f3)
+ oui = P802_1H_OUI;
+ else
+ oui = RFC1042_OUI;
+ snap->oui[0] = oui[0];
+ snap->oui[1] = oui[1];
+ snap->oui[2] = oui[2];
+ *(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+ return SNAP_SIZE + sizeof(u16);
+}
+
+/*
+ * This sub-routine will perform all the following:
+ * 1. remove 802.3 header.
+ * 2. create wlan_header, based on the info in pxmitframe
+ * 3. append sta's iv/ext-iv
+ * 4. append LLC
+ * 5. move frag chunk from pframe to pxmitframe->mem
+ * 6. apply sw-encrypt, if necessary.
+ */
+sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
+ struct xmit_frame *pxmitframe)
+{
+ struct pkt_file pktfile;
+
+ sint frg_len, mpdu_len, llc_sz;
+ u32 mem_sz;
+ u8 frg_inx;
+ addr_t addr;
+ u8 *pframe, *mem_start, *ptxdesc;
+ struct sta_info *psta;
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ u8 *pbuf_start;
+ sint bmcst = IS_MCAST(pattrib->ra);
+
+ if (pattrib->psta == NULL)
+ return _FAIL;
+ psta = pattrib->psta;
+ if (pxmitframe->buf_addr == NULL)
+ return _FAIL;
+ pbuf_start = pxmitframe->buf_addr;
+ ptxdesc = pbuf_start;
+ mem_start = pbuf_start + TXDESC_OFFSET;
+ if (make_wlanhdr(padapter, mem_start, pattrib) == _FAIL)
+ return _FAIL;
+ _r8712_open_pktfile(pkt, &pktfile);
+ _r8712_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
+ /* truncate TXDESC_SIZE bytes txcmd if at mp mode for 871x */
+ if (pattrib->ether_type == 0x8712) {
+ /* take care - update_txdesc overwrite this */
+ _r8712_pktfile_read(&pktfile, ptxdesc, TXDESC_SIZE);
+ }
+ }
+ pattrib->pktlen = pktfile.pkt_len;
+ frg_inx = 0;
+ frg_len = pxmitpriv->frag_len - 4;
+ while (1) {
+ llc_sz = 0;
+ mpdu_len = frg_len;
+ pframe = mem_start;
+ SetMFrag(mem_start);
+ pframe += pattrib->hdrlen;
+ mpdu_len -= pattrib->hdrlen;
+ /* adding icv, if necessary...*/
+ if (pattrib->iv_len) {
+ if (psta != NULL) {
+ switch (pattrib->encrypt) {
+ case _WEP40_:
+ case _WEP104_:
+ WEP_IV(pattrib->iv, psta->txpn,
+ (u8)psecuritypriv->
+ PrivacyKeyIndex);
+ break;
+ case _TKIP_:
+ if (bmcst)
+ TKIP_IV(pattrib->iv,
+ psta->txpn,
+ (u8)psecuritypriv->
+ XGrpKeyid);
+ else
+ TKIP_IV(pattrib->iv, psta->txpn,
+ 0);
+ break;
+ case _AES_:
+ if (bmcst)
+ AES_IV(pattrib->iv, psta->txpn,
+ (u8)psecuritypriv->
+ XGrpKeyid);
+ else
+ AES_IV(pattrib->iv, psta->txpn,
+ 0);
+ break;
+ }
+ }
+ memcpy(pframe, pattrib->iv, pattrib->iv_len);
+ pframe += pattrib->iv_len;
+ mpdu_len -= pattrib->iv_len;
+ }
+ if (frg_inx == 0) {
+ llc_sz = r8712_put_snap(pframe, pattrib->ether_type);
+ pframe += llc_sz;
+ mpdu_len -= llc_sz;
+ }
+ if ((pattrib->icv_len > 0) && (pattrib->bswenc))
+ mpdu_len -= pattrib->icv_len;
+ if (bmcst)
+ mem_sz = _r8712_pktfile_read(&pktfile, pframe,
+ pattrib->pktlen);
+ else
+ mem_sz = _r8712_pktfile_read(&pktfile, pframe,
+ mpdu_len);
+ pframe += mem_sz;
+ if ((pattrib->icv_len > 0) && (pattrib->bswenc)) {
+ memcpy(pframe, pattrib->icv, pattrib->icv_len);
+ pframe += pattrib->icv_len;
+ }
+ frg_inx++;
+ if (bmcst || (r8712_endofpktfile(&pktfile) == true)) {
+ pattrib->nr_frags = frg_inx;
+ pattrib->last_txcmdsz = pattrib->hdrlen +
+ pattrib->iv_len +
+ ((pattrib->nr_frags == 1) ?
+ llc_sz : 0) +
+ ((pattrib->bswenc) ?
+ pattrib->icv_len : 0) + mem_sz;
+ ClearMFrag(mem_start);
+ break;
+ }
+ addr = (addr_t)(pframe);
+ mem_start = (unsigned char *)RND4(addr) + TXDESC_OFFSET;
+ memcpy(mem_start, pbuf_start + TXDESC_OFFSET, pattrib->hdrlen);
+ }
+
+ if (xmitframe_addmic(padapter, pxmitframe) == _FAIL)
+ return _FAIL;
+ xmitframe_swencrypt(padapter, pxmitframe);
+ return _SUCCESS;
+}
+
+void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len)
+{
+ uint protection;
+ u8 *perp;
+ sint erp_len;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+
+ switch (pxmitpriv->vcs_setting) {
+ case DISABLE_VCS:
+ pxmitpriv->vcs = NONE_VCS;
+ break;
+ case ENABLE_VCS:
+ break;
+ case AUTO_VCS:
+ default:
+ perp = r8712_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len);
+ if (perp == NULL)
+ pxmitpriv->vcs = NONE_VCS;
+ else {
+ protection = (*(perp + 2)) & BIT(1);
+ if (protection) {
+ if (pregistrypriv->vcs_type == RTS_CTS)
+ pxmitpriv->vcs = RTS_CTS;
+ else
+ pxmitpriv->vcs = CTS_TO_SELF;
+ } else
+ pxmitpriv->vcs = NONE_VCS;
+ }
+ break;
+ }
+}
+
+struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
+{
+ unsigned long irqL;
+ struct xmit_buf *pxmitbuf = NULL;
+ struct list_head *plist, *phead;
+ struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
+
+ spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL);
+ if (_queue_empty(pfree_xmitbuf_queue) == true)
+ pxmitbuf = NULL;
+ else {
+ phead = get_list_head(pfree_xmitbuf_queue);
+ plist = get_next(phead);
+ pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
+ list_delete(&(pxmitbuf->list));
+ }
+ if (pxmitbuf != NULL)
+ pxmitpriv->free_xmitbuf_cnt--;
+ spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
+ return pxmitbuf;
+}
+
+int r8712_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
+{
+ unsigned long irqL;
+ struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
+
+ if (pxmitbuf == NULL)
+ return _FAIL;
+ spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL);
+ list_delete(&pxmitbuf->list);
+ list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue));
+ pxmitpriv->free_xmitbuf_cnt++;
+ spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
+ return _SUCCESS;
+}
+
+/*
+Calling context:
+1. OS_TXENTRY
+2. RXENTRY (rx_thread or RX_ISR/RX_CallBack)
+
+If we turn on USE_RXTHREAD, then, no need for critical section.
+Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
+
+Must be very very cautious...
+
+*/
+
+struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv)
+{
+ /*
+ Please remember to use all the osdep_service api,
+ and lock/unlock or _enter/_exit critical to protect
+ pfree_xmit_queue
+ */
+ unsigned long irqL;
+ struct xmit_frame *pxframe = NULL;
+ struct list_head *plist, *phead;
+ struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
+
+ spin_lock_irqsave(&pfree_xmit_queue->lock, irqL);
+ if (_queue_empty(pfree_xmit_queue) == true)
+ pxframe = NULL;
+ else {
+ phead = get_list_head(pfree_xmit_queue);
+ plist = get_next(phead);
+ pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
+ list_delete(&(pxframe->list));
+ }
+ if (pxframe != NULL) {
+ pxmitpriv->free_xmitframe_cnt--;
+ pxframe->buf_addr = NULL;
+ pxframe->pxmitbuf = NULL;
+ pxframe->attrib.psta = NULL;
+ pxframe->pkt = NULL;
+ }
+ spin_unlock_irqrestore(&pfree_xmit_queue->lock, irqL);
+ return pxframe;
+}
+
+void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
+ struct xmit_frame *pxmitframe)
+{
+ unsigned long irqL;
+ struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
+ struct _adapter *padapter = pxmitpriv->adapter;
+
+ if (pxmitframe == NULL)
+ return;
+ if (pxmitframe->pkt)
+ r8712_xmit_complete(padapter, pxmitframe);
+ spin_lock_irqsave(&pfree_xmit_queue->lock, irqL);
+ list_delete(&pxmitframe->list);
+ list_insert_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue));
+ pxmitpriv->free_xmitframe_cnt++;
+ spin_unlock_irqrestore(&pfree_xmit_queue->lock, irqL);
+ if (netif_queue_stopped(padapter->pnetdev))
+ netif_wake_queue(padapter->pnetdev);
+}
+
+void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
+ struct xmit_frame *pxmitframe)
+{
+ if (pxmitframe == NULL)
+ return;
+ if (pxmitframe->frame_tag == DATA_FRAMETAG)
+ r8712_free_xmitframe(pxmitpriv, pxmitframe);
+}
+
+void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
+ struct __queue *pframequeue)
+{
+ unsigned long irqL;
+ struct list_head *plist, *phead;
+ struct xmit_frame *pxmitframe;
+
+ spin_lock_irqsave(&(pframequeue->lock), irqL);
+ phead = get_list_head(pframequeue);
+ plist = get_next(phead);
+ while (end_of_queue_search(phead, plist) == false) {
+ pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
+ plist = get_next(plist);
+ r8712_free_xmitframe(pxmitpriv, pxmitframe);
+ }
+ spin_unlock_irqrestore(&(pframequeue->lock), irqL);
+}
+
+static inline struct tx_servq *get_sta_pending(struct _adapter *padapter,
+ struct __queue **ppstapending,
+ struct sta_info *psta, sint up)
+{
+
+ struct tx_servq *ptxservq;
+ struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits;
+
+ switch (up) {
+ case 1:
+ case 2:
+ ptxservq = &(psta->sta_xmitpriv.bk_q);
+ *ppstapending = &padapter->xmitpriv.bk_pending;
+ (phwxmits+3)->accnt++;
+ break;
+ case 4:
+ case 5:
+ ptxservq = &(psta->sta_xmitpriv.vi_q);
+ *ppstapending = &padapter->xmitpriv.vi_pending;
+ (phwxmits+1)->accnt++;
+ break;
+ case 6:
+ case 7:
+ ptxservq = &(psta->sta_xmitpriv.vo_q);
+ *ppstapending = &padapter->xmitpriv.vo_pending;
+ (phwxmits+0)->accnt++;
+ break;
+ case 0:
+ case 3:
+ default:
+ ptxservq = &(psta->sta_xmitpriv.be_q);
+ *ppstapending = &padapter->xmitpriv.be_pending;
+ (phwxmits + 2)->accnt++;
+ break;
+ }
+ return ptxservq;
+}
+
+/*
+ * Will enqueue pxmitframe to the proper queue, and indicate it
+ * to xx_pending list.....
+ */
+sint r8712_xmit_classifier(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe)
+{
+ unsigned long irqL0;
+ struct __queue *pstapending;
+ struct sta_info *psta;
+ struct tx_servq *ptxservq;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+ struct sta_priv *pstapriv = &padapter->stapriv;
+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
+ sint bmcst = IS_MCAST(pattrib->ra);
+
+ if (pattrib->psta)
+ psta = pattrib->psta;
+ else {
+ if (bmcst)
+ psta = r8712_get_bcmc_stainfo(padapter);
+ else {
+ if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
+ psta = r8712_get_stainfo(pstapriv,
+ get_bssid(pmlmepriv));
+ else
+ psta = r8712_get_stainfo(pstapriv, pattrib->ra);
+ }
+ }
+ if (psta == NULL)
+ return _FAIL;
+ ptxservq = get_sta_pending(padapter, &pstapending,
+ psta, pattrib->priority);
+ spin_lock_irqsave(&pstapending->lock, irqL0);
+ if (is_list_empty(&ptxservq->tx_pending))
+ list_insert_tail(&ptxservq->tx_pending,
+ get_list_head(pstapending));
+ list_insert_tail(&pxmitframe->list,
+ get_list_head(&ptxservq->sta_pending));
+ ptxservq->qcnt++;
+ spin_unlock_irqrestore(&pstapending->lock, irqL0);
+ return _SUCCESS;
+}
+
+static void alloc_hwxmits(struct _adapter *padapter)
+{
+ struct hw_xmit *hwxmits;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+
+ pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
+ pxmitpriv->hwxmits = (struct hw_xmit *)_malloc(sizeof(struct hw_xmit) *
+ pxmitpriv->hwxmit_entry);
+ if (pxmitpriv->hwxmits == NULL)
+ return;
+ hwxmits = pxmitpriv->hwxmits;
+ if (pxmitpriv->hwxmit_entry == 5) {
+ pxmitpriv->bmc_txqueue.head = 0;
+ hwxmits[0] .phwtxqueue = &pxmitpriv->bmc_txqueue;
+ hwxmits[0] .sta_queue = &pxmitpriv->bm_pending;
+ pxmitpriv->vo_txqueue.head = 0;
+ hwxmits[1] .phwtxqueue = &pxmitpriv->vo_txqueue;
+ hwxmits[1] .sta_queue = &pxmitpriv->vo_pending;
+ pxmitpriv->vi_txqueue.head = 0;
+ hwxmits[2] .phwtxqueue = &pxmitpriv->vi_txqueue;
+ hwxmits[2] .sta_queue = &pxmitpriv->vi_pending;
+ pxmitpriv->bk_txqueue.head = 0;
+ hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue;
+ hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
+ pxmitpriv->be_txqueue.head = 0;
+ hwxmits[4] .phwtxqueue = &pxmitpriv->be_txqueue;
+ hwxmits[4] .sta_queue = &pxmitpriv->be_pending;
+ } else if (pxmitpriv->hwxmit_entry == 4) {
+ pxmitpriv->vo_txqueue.head = 0;
+ hwxmits[0] .phwtxqueue = &pxmitpriv->vo_txqueue;
+ hwxmits[0] .sta_queue = &pxmitpriv->vo_pending;
+ pxmitpriv->vi_txqueue.head = 0;
+ hwxmits[1] .phwtxqueue = &pxmitpriv->vi_txqueue;
+ hwxmits[1] .sta_queue = &pxmitpriv->vi_pending;
+ pxmitpriv->be_txqueue.head = 0;
+ hwxmits[2] .phwtxqueue = &pxmitpriv->be_txqueue;
+ hwxmits[2] .sta_queue = &pxmitpriv->be_pending;
+ pxmitpriv->bk_txqueue.head = 0;
+ hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue;
+ hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
+ }
+}
+
+static void free_hwxmits(struct _adapter *padapter)
+{
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+
+ if (pxmitpriv->hwxmits)
+ kfree((u8 *)pxmitpriv->hwxmits);
+}
+
+static void init_hwxmits(struct hw_xmit *phwxmit, sint entry)
+{
+ sint i;
+
+ for (i = 0; i < entry; i++, phwxmit++) {
+ spin_lock_init(&phwxmit->xmit_lock);
+ _init_listhead(&phwxmit->pending);
+ phwxmit->txcmdcnt = 0;
+ phwxmit->accnt = 0;
+ }
+}
+
+/*
+ * tx_action == 0 == no frames to transmit
+ * tx_action > 0 ==> we have frames to transmit
+ * tx_action < 0 ==> we have frames to transmit, but TXFF is not even enough
+ * to transmit 1 frame.
+ */
+
+int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe)
+{
+ unsigned long irqL;
+ int ret;
+ struct xmit_buf *pxmitbuf = NULL;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+
+ r8712_do_queue_select(padapter, pattrib);
+ spin_lock_irqsave(&pxmitpriv->lock, irqL);
+ if (r8712_txframes_sta_ac_pending(padapter, pattrib) > 0) {
+ ret = false;
+ r8712_xmit_enqueue(padapter, pxmitframe);
+ spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
+ return ret;
+ }
+ pxmitbuf = r8712_alloc_xmitbuf(pxmitpriv);
+ if (pxmitbuf == NULL) { /*enqueue packet*/
+ ret = false;
+ r8712_xmit_enqueue(padapter, pxmitframe);
+ spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
+ } else { /*dump packet directly*/
+ spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
+ ret = true;
+ pxmitframe->pxmitbuf = pxmitbuf;
+ pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0];
+ pxmitframe->buf_addr = pxmitbuf->pbuf;
+ r8712_xmit_direct(padapter, pxmitframe);
+ }
+ return ret;
+}
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h
new file mode 100644
index 000000000000..d518ce85585d
--- /dev/null
+++ b/drivers/staging/rtl8712/rtl871x_xmit.h
@@ -0,0 +1,260 @@
+#ifndef _RTL871X_XMIT_H_
+#define _RTL871X_XMIT_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "xmit_osdep.h"
+
+#define MAX_XMITBUF_SZ (2048)
+#define NR_XMITBUFF (4)
+#define XMITBUF_ALIGN_SZ 512
+#define TX_GUARD_BAND 5
+#define MAX_NUMBLKS (1)
+
+/* Fixed the Big Endian bug when using the software driver encryption.*/
+#define WEP_IV(pattrib_iv, txpn, keyidx)\
+do { \
+ pattrib_iv[0] = txpn._byte_.TSC0;\
+ pattrib_iv[1] = txpn._byte_.TSC1;\
+ pattrib_iv[2] = txpn._byte_.TSC2;\
+ pattrib_iv[3] = ((keyidx & 0x3)<<6);\
+ txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val+1);\
+} while (0)
+
+/* Fixed the Big Endian bug when doing the Tx.
+ * The Linksys WRH54G will check this.*/
+#define TKIP_IV(pattrib_iv, txpn, keyidx)\
+do { \
+ pattrib_iv[0] = txpn._byte_.TSC1;\
+ pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
+ pattrib_iv[2] = txpn._byte_.TSC0;\
+ pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
+ pattrib_iv[4] = txpn._byte_.TSC2;\
+ pattrib_iv[5] = txpn._byte_.TSC3;\
+ pattrib_iv[6] = txpn._byte_.TSC4;\
+ pattrib_iv[7] = txpn._byte_.TSC5;\
+ txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
+ (txpn.val+1);\
+} while (0)
+
+#define AES_IV(pattrib_iv, txpn, keyidx)\
+do { \
+ pattrib_iv[0] = txpn._byte_.TSC0;\
+ pattrib_iv[1] = txpn._byte_.TSC1;\
+ pattrib_iv[2] = 0;\
+ pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
+ pattrib_iv[4] = txpn._byte_.TSC2;\
+ pattrib_iv[5] = txpn._byte_.TSC3;\
+ pattrib_iv[6] = txpn._byte_.TSC4;\
+ pattrib_iv[7] = txpn._byte_.TSC5;\
+ txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
+ (txpn.val+1);\
+} while (0)
+
+struct hw_xmit {
+ spinlock_t xmit_lock;
+ struct list_head pending;
+ struct __queue *sta_queue;
+ struct hw_txqueue *phwtxqueue;
+ sint txcmdcnt;
+ int accnt;
+};
+
+struct pkt_attrib {
+ u8 type;
+ u8 subtype;
+ u8 bswenc;
+ u8 dhcp_pkt;
+
+ u16 seqnum;
+ u16 ether_type;
+ u32 pktlen; /* the original 802.3 pkt raw_data len
+ * (not include ether_hdr data) */
+ u32 last_txcmdsz;
+
+ u8 pkt_hdrlen; /*the original 802.3 pkt header len*/
+ u8 hdrlen; /*the WLAN Header Len*/
+ u8 nr_frags;
+ u8 ack_policy;
+ u8 mac_id;
+ u8 vcs_mode; /*virtual carrier sense method*/
+ u8 pctrl;/*per packet txdesc control enable*/
+ u8 qsel;
+
+ u8 priority;
+ u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
+ * indicate the encrypt algorith*/
+ u8 iv_len;
+ u8 icv_len;
+ unsigned char iv[8];
+ unsigned char icv[8];
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+ u8 ta[ETH_ALEN];
+ u8 ra[ETH_ALEN];
+ struct sta_info *psta;
+};
+
+#define WLANHDR_OFFSET 64
+#define DATA_FRAMETAG 0x01
+#define L2_FRAMETAG 0x02
+#define MGNT_FRAMETAG 0x03
+#define AMSDU_FRAMETAG 0x04
+#define EII_FRAMETAG 0x05
+#define IEEE8023_FRAMETAG 0x06
+#define MP_FRAMETAG 0x07
+#define TXAGG_FRAMETAG 0x08
+
+struct xmit_buf {
+ struct list_head list;
+
+ u8 *pallocated_buf;
+ u8 *pbuf;
+ struct urb *pxmit_urb[8];
+};
+
+struct xmit_frame {
+ struct list_head list;
+ struct pkt_attrib attrib;
+ _pkt *pkt;
+ int frame_tag;
+ struct _adapter *padapter;
+ u8 *buf_addr;
+ struct xmit_buf *pxmitbuf;
+ u8 *mem_addr;
+ u16 sz[8];
+ struct urb *pxmit_urb[8];
+ u8 bpending[8];
+ u8 last[8];
+};
+
+struct tx_servq {
+ struct list_head tx_pending;
+ struct __queue sta_pending;
+ int qcnt;
+};
+
+struct sta_xmit_priv {
+ spinlock_t lock;
+ sint option;
+ sint apsd_setting; /* When bit mask is on, the associated edca
+ * queue supports APSD.*/
+ struct tx_servq be_q; /* priority == 0,3 */
+ struct tx_servq bk_q; /* priority == 1,2*/
+ struct tx_servq vi_q; /*priority == 4,5*/
+ struct tx_servq vo_q; /*priority == 6,7*/
+ struct list_head legacy_dz;
+ struct list_head apsd;
+ u16 txseq_tid[16];
+ uint sta_tx_bytes;
+ u64 sta_tx_pkts;
+ uint sta_tx_fail;
+};
+
+struct hw_txqueue {
+ /*volatile*/ sint head;
+ /*volatile*/ sint tail;
+ /*volatile*/ sint free_sz; /*in units of 64 bytes*/
+ /*volatile*/ sint free_cmdsz;
+ /*volatile*/ sint txsz[8];
+ uint ff_hwaddr;
+ uint cmd_hwaddr;
+ sint ac_tag;
+};
+
+struct xmit_priv {
+ spinlock_t lock;
+ struct semaphore xmit_sema;
+ struct semaphore terminate_xmitthread_sema;
+ struct __queue be_pending;
+ struct __queue bk_pending;
+ struct __queue vi_pending;
+ struct __queue vo_pending;
+ struct __queue bm_pending;
+ struct __queue legacy_dz_queue;
+ struct __queue apsd_queue;
+ u8 *pallocated_frame_buf;
+ u8 *pxmit_frame_buf;
+ uint free_xmitframe_cnt;
+ uint mapping_addr;
+ uint pkt_sz;
+ struct __queue free_xmit_queue;
+ struct hw_txqueue be_txqueue;
+ struct hw_txqueue bk_txqueue;
+ struct hw_txqueue vi_txqueue;
+ struct hw_txqueue vo_txqueue;
+ struct hw_txqueue bmc_txqueue;
+ uint frag_len;
+ struct _adapter *adapter;
+ u8 vcs_setting;
+ u8 vcs;
+ u8 vcs_type;
+ u16 rts_thresh;
+ uint tx_bytes;
+ u64 tx_pkts;
+ uint tx_drop;
+ struct hw_xmit *hwxmits;
+ u8 hwxmit_entry;
+ struct semaphore tx_retevt;/*all tx return event;*/
+ u8 txirp_cnt;
+ struct tasklet_struct xmit_tasklet;
+ /*per AC pending irp*/
+ int beq_cnt;
+ int bkq_cnt;
+ int viq_cnt;
+ int voq_cnt;
+ struct __queue free_amsdu_xmit_queue;
+ u8 *pallocated_amsdu_frame_buf;
+ u8 *pxmit_amsdu_frame_buf;
+ uint free_amsdu_xmitframe_cnt;
+ struct __queue free_txagg_xmit_queue;
+ u8 *pallocated_txagg_frame_buf;
+ u8 *pxmit_txagg_frame_buf;
+ uint free_txagg_xmitframe_cnt;
+ int cmdseq;
+ struct __queue free_xmitbuf_queue;
+ struct __queue pending_xmitbuf_queue;
+ u8 *pallocated_xmitbuf;
+ u8 *pxmitbuf;
+ uint free_xmitbuf_cnt;
+};
+
+static inline struct __queue *get_free_xmit_queue(
+ struct xmit_priv *pxmitpriv)
+{
+ return &(pxmitpriv->free_xmit_queue);
+}
+
+int r8712_free_xmitbuf(struct xmit_priv *pxmitpriv,
+ struct xmit_buf *pxmitbuf);
+struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
+void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len);
+struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv);
+void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
+ struct xmit_frame *pxmitframe);
+void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
+ struct __queue *pframequeue);
+sint r8712_xmit_classifier(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe);
+sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
+ struct xmit_frame *pxmitframe);
+sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
+void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
+sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
+ struct pkt_attrib *pattrib);
+int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
+ struct pkt_attrib *pattrib);
+sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, struct _adapter *padapter);
+void _free_xmit_priv(struct xmit_priv *pxmitpriv);
+void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
+ struct xmit_frame *pxmitframe);
+int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe);
+int r8712_xmit_enqueue(struct _adapter *padapter,
+ struct xmit_frame *pxmitframe);
+int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe);
+void r8712_xmit_bh(void *priv);
+
+#include "rtl8712_xmit.h"
+
+#endif /*_RTL871X_XMIT_H_*/
+
diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h
new file mode 100644
index 000000000000..79ad1593214f
--- /dev/null
+++ b/drivers/staging/rtl8712/sta_info.h
@@ -0,0 +1,125 @@
+#ifndef __STA_INFO_H_
+#define __STA_INFO_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "wifi.h"
+
+#define NUM_STA 32
+#define NUM_ACL 64
+
+
+/* if mode ==0, then the sta is allowed once the addr is hit.
+ * if mode ==1, then the sta is rejected once the addr is non-hit.
+ */
+struct wlan_acl_node {
+ struct list_head list;
+ u8 addr[ETH_ALEN];
+ u8 mode;
+};
+
+struct wlan_acl_pool {
+ struct wlan_acl_node aclnode[NUM_ACL];
+};
+
+struct stainfo_stats {
+
+ uint rx_pkts;
+ uint rx_bytes;
+ u64 tx_pkts;
+ uint tx_bytes;
+};
+
+struct sta_info {
+ spinlock_t lock;
+ struct list_head list; /*free_sta_queue*/
+ struct list_head hash_list; /*sta_hash*/
+ struct sta_xmit_priv sta_xmitpriv;
+ struct sta_recv_priv sta_recvpriv;
+ uint state;
+ uint aid;
+ u8 mac_id;
+ u8 qos_option;
+ u8 hwaddr[ETH_ALEN];
+ uint ieee8021x_blocked; /*0: allowed, 1:blocked */
+ uint XPrivacy; /*aes, tkip...*/
+ union Keytype tkiptxmickey;
+ union Keytype tkiprxmickey;
+ union Keytype x_UncstKey;
+ union pn48 txpn; /* PN48 used for Unicast xmit.*/
+ union pn48 rxpn; /* PN48 used for Unicast recv.*/
+ u8 bssrateset[16];
+ uint bssratelen;
+ s32 rssi;
+ s32 signal_quality;
+ struct stainfo_stats sta_stats;
+ /*for A-MPDU Rx reordering buffer control */
+ struct recv_reorder_ctrl recvreorder_ctrl[16];
+ struct ht_priv htpriv;
+ /* Notes:
+ * STA_Mode:
+ * curr_network(mlme_priv/security_priv/qos/ht)
+ * + sta_info: (STA & AP) CAP/INFO
+ * scan_q: AP CAP/INFO
+ * AP_Mode:
+ * curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
+ * sta_info: (AP & STA) CAP/INFO
+ */
+#ifdef CONFIG_R8712_AP
+ struct list_head asoc_list;
+ struct list_head auth_list;
+ unsigned int expire_to;
+ unsigned int auth_seq;
+ unsigned int authalg;
+ unsigned char chg_txt[128];
+ unsigned int tx_ra_bitmap;
+#endif
+};
+
+struct sta_priv {
+ u8 *pallocated_stainfo_buf;
+ u8 *pstainfo_buf;
+ struct __queue free_sta_queue;
+ spinlock_t sta_hash_lock;
+ struct list_head sta_hash[NUM_STA];
+ int asoc_sta_count;
+ struct __queue sleep_q;
+ struct __queue wakeup_q;
+ struct _adapter *padapter;
+#ifdef CONFIG_R8712_AP
+ struct list_head asoc_list;
+ struct list_head auth_list;
+ unsigned int auth_to; /* sec, time to expire in authenticating. */
+ unsigned int assoc_to; /* sec, time to expire before associating. */
+ unsigned int expire_to; /* sec , time to expire after associated. */
+#endif
+};
+
+static inline u32 wifi_mac_hash(u8 *mac)
+{
+ u32 x;
+
+ x = mac[0];
+ x = (x << 2) ^ mac[1];
+ x = (x << 2) ^ mac[2];
+ x = (x << 2) ^ mac[3];
+ x = (x << 2) ^ mac[4];
+ x = (x << 2) ^ mac[5];
+ x ^= x >> 8;
+ x = x & (NUM_STA - 1);
+ return x;
+}
+
+u32 _r8712_init_sta_priv(struct sta_priv *pstapriv);
+u32 _r8712_free_sta_priv(struct sta_priv *pstapriv);
+struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv,
+ u8 *hwaddr);
+void r8712_free_stainfo(struct _adapter *padapter , struct sta_info *psta);
+void r8712_free_all_stainfo(struct _adapter *padapter);
+struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
+void r8712_init_bcmc_stainfo(struct _adapter *padapter);
+struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
+u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 * mac_addr);
+
+#endif /* _STA_INFO_H_ */
+
diff --git a/drivers/staging/rtl8712/swab.h b/drivers/staging/rtl8712/swab.h
new file mode 100644
index 000000000000..44709a91bafc
--- /dev/null
+++ b/drivers/staging/rtl8712/swab.h
@@ -0,0 +1,106 @@
+#ifndef _LINUX_BYTEORDER_SWAB_H
+#define _LINUX_BYTEORDER_SWAB_H
+
+#ifndef __u16
+ #define __u16 unsigned short
+#endif
+
+#ifndef __u32
+ #define __u32 unsigned int
+#endif
+
+#ifndef __u8
+ #define __u8 unsigned char
+#endif
+
+#ifndef __u64
+ #define __u64 unsigned long long
+#endif
+
+
+static inline __u16 ___swab16(__u16 x)
+{
+ __u16 __x = x;
+ return (__u16)(
+ (((__u16)(__x) & (__u16)0x00ffU) << 8) |
+ (((__u16)(__x) & (__u16)0xff00U) >> 8));
+
+}
+
+static inline __u32 ___swab32(__u32 x)
+{
+ __u32 __x = (x);
+ return (__u32)(
+ (((__u32)(__x) & (__u32)0x000000ffUL) << 24) |
+ (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) |
+ (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) |
+ (((__u32)(__x) & (__u32)0xff000000UL) >> 24));
+}
+
+static inline __u64 ___swab64(__u64 x)
+{
+ __u64 __x = (x);
+
+ return (__u64)( \
+ (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
+ (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
+ (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
+ (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \
+ (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \
+ (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
+ (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
+ (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56));
+}
+
+#ifndef __arch__swab16
+static inline __u16 __arch__swab16(__u16 x)
+{
+ return ___swab16(x);
+}
+
+#endif
+
+#ifndef __arch__swab32
+static inline __u32 __arch__swab32(__u32 x)
+{
+ __u32 __tmp = (x) ;
+ return ___swab32(__tmp);
+}
+#endif
+
+#ifndef __arch__swab64
+
+static inline __u64 __arch__swab64(__u64 x)
+{
+ __u64 __tmp = (x) ;
+ return ___swab64(__tmp);
+}
+
+
+#endif
+
+#define __swab16(x) __fswab16(x)
+#define __swab32(x) __fswab32(x)
+#define __swab64(x) __fswab64(x)
+
+static inline const __u16 __fswab16(__u16 x)
+{
+ return __arch__swab16(x);
+}
+static inline const __u32 __fswab32(__u32 x)
+{
+ return __arch__swab32(x);
+}
+
+#define swab16 __swab16
+#define swab32 __swab32
+#define swab64 __swab64
+#define swab16p __swab16p
+#define swab32p __swab32p
+#define swab64p __swab64p
+#define swab16s __swab16s
+#define swab32s __swab32s
+#define swab64s __swab64s
+
+#endif /* _LINUX_BYTEORDER_SWAB_H */
+
diff --git a/drivers/staging/rtl8712/usb_halinit.c b/drivers/staging/rtl8712/usb_halinit.c
new file mode 100644
index 000000000000..f6569dce3012
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_halinit.c
@@ -0,0 +1,317 @@
+/******************************************************************************
+ * usb_halinit.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _HCI_HAL_INIT_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "usb_ops.h"
+#include "usb_osintf.h"
+
+u8 r8712_usb_hal_bus_init(struct _adapter *padapter)
+{
+ u8 val8 = 0;
+ u8 ret = _SUCCESS;
+ u8 PollingCnt = 20;
+ struct registry_priv *pregistrypriv = &padapter->registrypriv;
+
+ if (pregistrypriv->chip_version == RTL8712_FPGA) {
+ val8 = 0x01;
+ /* switch to 80M clock */
+ r8712_write8(padapter, SYS_CLKR, val8);
+ val8 = r8712_read8(padapter, SPS1_CTRL);
+ val8 = val8 | 0x01;
+ /* enable VSPS12 LDO Macro block */
+ r8712_write8(padapter, SPS1_CTRL, val8);
+ val8 = r8712_read8(padapter, AFE_MISC);
+ val8 = val8 | 0x01;
+ /* Enable AFE Macro Block's Bandgap */
+ r8712_write8(padapter, AFE_MISC, val8);
+ val8 = r8712_read8(padapter, LDOA15_CTRL);
+ val8 = val8 | 0x01;
+ /* enable LDOA15 block */
+ r8712_write8(padapter, LDOA15_CTRL, val8);
+ val8 = r8712_read8(padapter, SPS1_CTRL);
+ val8 = val8 | 0x02;
+ /* Enable VSPS12_SW Macro Block */
+ r8712_write8(padapter, SPS1_CTRL, val8);
+ val8 = r8712_read8(padapter, AFE_MISC);
+ val8 = val8 | 0x02;
+ /* Enable AFE Macro Block's Mbias */
+ r8712_write8(padapter, AFE_MISC, val8);
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ val8 = val8 | 0x08;
+ /* isolate PCIe Analog 1.2V to PCIe 3.3V and PCIE Digital */
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, val8);
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ val8 = val8 & 0xEF;
+ /* attatch AFE PLL to MACTOP/BB/PCIe Digital */
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, val8);
+ val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1);
+ val8 = val8 & 0xFB;
+ /* enable AFE clock */
+ r8712_write8(padapter, AFE_XTAL_CTRL + 1, val8);
+ val8 = r8712_read8(padapter, AFE_PLL_CTRL);
+ val8 = val8 | 0x01;
+ /* Enable AFE PLL Macro Block */
+ r8712_write8(padapter, AFE_PLL_CTRL, val8);
+ val8 = 0xEE;
+ /* release isolation AFE PLL & MD */
+ r8712_write8(padapter, SYS_ISO_CTRL, val8);
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ val8 = val8 | 0x08;
+ /* enable MAC clock */
+ r8712_write8(padapter, SYS_CLKR + 1, val8);
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ val8 = val8 | 0x08;
+ /* enable Core digital and enable IOREG R/W */
+ r8712_write8(padapter, SYS_FUNC_EN + 1, val8);
+ val8 = val8 | 0x80;
+ /* enable REG_EN */
+ r8712_write8(padapter, SYS_FUNC_EN + 1, val8);
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ val8 = (val8 | 0x80) & 0xBF;
+ /* switch the control path */
+ r8712_write8(padapter, SYS_CLKR + 1, val8);
+ val8 = 0xFC;
+ r8712_write8(padapter, CR, val8);
+ val8 = 0x37;
+ r8712_write8(padapter, CR + 1, val8);
+ /* reduce EndPoint & init it */
+ r8712_write8(padapter, 0x102500ab, r8712_read8(padapter,
+ 0x102500ab) | BIT(6) | BIT(7));
+ /* consideration of power consumption - init */
+ r8712_write8(padapter, 0x10250008, r8712_read8(padapter,
+ 0x10250008) & 0xfffffffb);
+ } else if (pregistrypriv->chip_version == RTL8712_1stCUT) {
+ /* Initialization for power on sequence, */
+ r8712_write8(padapter, SPS0_CTRL + 1, 0x53);
+ r8712_write8(padapter, SPS0_CTRL, 0x57);
+ /* Enable AFE Macro Block's Bandgap adn Enable AFE Macro
+ * Block's Mbias
+ */
+ val8 = r8712_read8(padapter, AFE_MISC);
+ r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN |
+ AFE_MISC_MBEN));
+ /* Enable LDOA15 block */
+ val8 = r8712_read8(padapter, LDOA15_CTRL);
+ r8712_write8(padapter, LDOA15_CTRL, (val8 | LDA15_EN));
+ val8 = r8712_read8(padapter, SPS1_CTRL);
+ r8712_write8(padapter, SPS1_CTRL, (val8 | SPS1_LDEN));
+ msleep(20);
+ /* Enable Switch Regulator Block */
+ val8 = r8712_read8(padapter, SPS1_CTRL);
+ r8712_write8(padapter, SPS1_CTRL, (val8 | SPS1_SWEN));
+ r8712_write32(padapter, SPS1_CTRL, 0x00a7b267);
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 | 0x08));
+ /* Engineer Packet CP test Enable */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x20));
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 & 0x6F));
+ /* Enable AFE clock */
+ val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1);
+ r8712_write8(padapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb));
+ /* Enable AFE PLL Macro Block */
+ val8 = r8712_read8(padapter, AFE_PLL_CTRL);
+ r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11));
+ /* Attatch AFE PLL to MACTOP/BB/PCIe Digital */
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL);
+ r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE));
+ /* Switch to 40M clock */
+ val8 = r8712_read8(padapter, SYS_CLKR);
+ r8712_write8(padapter, SYS_CLKR, val8 & (~SYS_CLKSEL));
+ /* SSC Disable */
+ val8 = r8712_read8(padapter, SYS_CLKR);
+ /* Enable MAC clock */
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x18));
+ /* Revised POS, */
+ r8712_write8(padapter, PMC_FSM, 0x02);
+ /* Enable Core digital and enable IOREG R/W */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x08));
+ /* Enable REG_EN */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x80));
+ /* Switch the control path to FW */
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF);
+ r8712_write8(padapter, CR, 0xFC);
+ r8712_write8(padapter, CR + 1, 0x37);
+ /* Fix the RX FIFO issue(usb error), */
+ val8 = r8712_read8(padapter, 0x1025FE5c);
+ r8712_write8(padapter, 0x1025FE5c, (val8|BIT(7)));
+ val8 = r8712_read8(padapter, 0x102500ab);
+ r8712_write8(padapter, 0x102500ab, (val8|BIT(6)|BIT(7)));
+ /* For power save, used this in the bit file after 970621 */
+ val8 = r8712_read8(padapter, SYS_CLKR);
+ r8712_write8(padapter, SYS_CLKR, val8&(~CPU_CLKSEL));
+ } else if (pregistrypriv->chip_version == RTL8712_2ndCUT ||
+ pregistrypriv->chip_version == RTL8712_3rdCUT) {
+ /* Initialization for power on sequence,
+ * E-Fuse leakage prevention sequence
+ */
+ r8712_write8(padapter, 0x37, 0xb0);
+ msleep(20);
+ r8712_write8(padapter, 0x37, 0x30);
+ /* Set control path switch to HW control and reset Digital Core,
+ * CPU Core and MAC I/O to solve FW download fail when system
+ * from resume sate.
+ */
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ if (val8 & 0x80) {
+ val8 &= 0x3f;
+ r8712_write8(padapter, SYS_CLKR + 1, val8);
+ }
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ val8 &= 0x73;
+ r8712_write8(padapter, SYS_FUNC_EN + 1, val8);
+ msleep(20);
+ /* Revised POS, */
+ /* Enable AFE Macro Block's Bandgap and Enable AFE Macro
+ * Block's Mbias */
+ r8712_write8(padapter, SPS0_CTRL + 1, 0x53);
+ r8712_write8(padapter, SPS0_CTRL, 0x57);
+ val8 = r8712_read8(padapter, AFE_MISC);
+ /*Bandgap*/
+ r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN));
+ r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN |
+ AFE_MISC_MBEN | AFE_MISC_I32_EN));
+ /* Enable PLL Power (LDOA15V) */
+ val8 = r8712_read8(padapter, LDOA15_CTRL);
+ r8712_write8(padapter, LDOA15_CTRL, (val8 | LDA15_EN));
+ /* Enable LDOV12D block */
+ val8 = r8712_read8(padapter, LDOV12D_CTRL);
+ r8712_write8(padapter, LDOV12D_CTRL, (val8 | LDV12_EN));
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 | 0x08));
+ /* Engineer Packet CP test Enable */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x20));
+ /* Support 64k IMEM */
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1);
+ r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 & 0x68));
+ /* Enable AFE clock */
+ val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1);
+ r8712_write8(padapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb));
+ /* Enable AFE PLL Macro Block */
+ val8 = r8712_read8(padapter, AFE_PLL_CTRL);
+ r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11));
+ /* Some sample will download fw failure. The clock will be
+ * stable with 500 us delay after reset the PLL
+ * TODO: When usleep is added to kernel, change next 3
+ * udelay(500) to usleep(500)
+ */
+ udelay(500);
+ r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x51));
+ udelay(500);
+ r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11));
+ udelay(500);
+ /* Attatch AFE PLL to MACTOP/BB/PCIe Digital */
+ val8 = r8712_read8(padapter, SYS_ISO_CTRL);
+ r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE));
+ /* Switch to 40M clock */
+ r8712_write8(padapter, SYS_CLKR, 0x00);
+ /* CPU Clock and 80M Clock SSC Disable to overcome FW download
+ * fail timing issue.
+ */
+ val8 = r8712_read8(padapter, SYS_CLKR);
+ r8712_write8(padapter, SYS_CLKR, (val8 | 0xa0));
+ /* Enable MAC clock */
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x18));
+ /* Revised POS, */
+ r8712_write8(padapter, PMC_FSM, 0x02);
+ /* Enable Core digital and enable IOREG R/W */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x08));
+ /* Enable REG_EN */
+ val8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
+ r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x80));
+ /* Switch the control path to FW */
+ val8 = r8712_read8(padapter, SYS_CLKR + 1);
+ r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF);
+ r8712_write8(padapter, CR, 0xFC);
+ r8712_write8(padapter, CR + 1, 0x37);
+ /* Fix the RX FIFO issue(usb error), 970410 */
+ val8 = r8712_read8(padapter, 0x1025FE5c);
+ r8712_write8(padapter, 0x1025FE5c, (val8 | BIT(7)));
+ /* For power save, used this in the bit file after 970621 */
+ val8 = r8712_read8(padapter, SYS_CLKR);
+ r8712_write8(padapter, SYS_CLKR, val8 & (~CPU_CLKSEL));
+ /* Revised for 8051 ROM code wrong operation. */
+ r8712_write8(padapter, 0x1025fe1c, 0x80);
+ /* To make sure that TxDMA can ready to download FW.
+ * We should reset TxDMA if IMEM RPT was not ready.
+ */
+ do {
+ val8 = r8712_read8(padapter, TCR);
+ if ((val8 & _TXDMA_INIT_VALUE) == _TXDMA_INIT_VALUE)
+ break;
+ udelay(5); /* PlatformStallExecution(5); */
+ } while (PollingCnt--); /* Delay 1ms */
+
+ if (PollingCnt <= 0) {
+ val8 = r8712_read8(padapter, CR);
+ r8712_write8(padapter, CR, val8&(~_TXDMA_EN));
+ udelay(2); /* PlatformStallExecution(2); */
+ /* Reset TxDMA */
+ r8712_write8(padapter, CR, val8|_TXDMA_EN);
+ }
+ } else
+ ret = _FAIL;
+ return ret;
+}
+
+unsigned int r8712_usb_inirp_init(struct _adapter *padapter)
+{
+ u8 i;
+ struct recv_buf *precvbuf;
+ struct intf_hdl *pintfhdl = &padapter->pio_queue->intf;
+ struct recv_priv *precvpriv = &(padapter->recvpriv);
+
+ precvpriv->ff_hwaddr = RTL8712_DMA_RX0FF; /* mapping rx fifo address */
+ /* issue Rx irp to receive data */
+ precvbuf = (struct recv_buf *)precvpriv->precv_buf;
+ for (i = 0; i < NR_RECVBUFF; i++) {
+ if (r8712_usb_read_port(pintfhdl, precvpriv->ff_hwaddr, 0,
+ (unsigned char *)precvbuf) == false)
+ return _FAIL;
+ precvbuf++;
+ precvpriv->free_recv_buf_queue_cnt--;
+ }
+ return _SUCCESS;
+}
+
+unsigned int r8712_usb_inirp_deinit(struct _adapter *padapter)
+{
+ r8712_usb_read_port_cancel(padapter);
+ return _SUCCESS;
+}
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
new file mode 100644
index 000000000000..f1f0c63e5bbc
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -0,0 +1,571 @@
+/******************************************************************************
+ * usb_intf.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _HCI_INTF_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "recv_osdep.h"
+#include "xmit_osdep.h"
+#include "rtl8712_efuse.h"
+#include "usb_vendor_req.h"
+#include "usb_ops.h"
+#include "usb_osintf.h"
+
+#define DRVER "v7_0.20100831"
+
+static struct usb_interface *pintf;
+
+static int r871xu_drv_init(struct usb_interface *pusb_intf,
+ const struct usb_device_id *pdid);
+
+static void r871xu_dev_remove(struct usb_interface *pusb_intf);
+
+static struct usb_device_id rtl871x_usb_id_tbl[] = {
+ /*92SU
+ * Realtek */
+ {USB_DEVICE(0x0bda, 0x8171)},
+ {USB_DEVICE(0x0bda, 0x8172)},
+ {USB_DEVICE(0x0bda, 0x8173)},
+ {USB_DEVICE(0x0bda, 0x8174)},
+ {USB_DEVICE(0x0bda, 0x8712)},
+ {USB_DEVICE(0x0bda, 0x8713)},
+ {USB_DEVICE(0x0bda, 0xC512)},
+ /* Abocom */
+ {USB_DEVICE(0x07B8, 0x8188)},
+ /* Corega */
+ {USB_DEVICE(0x07aa, 0x0047)},
+ /* Dlink */
+ {USB_DEVICE(0x07d1, 0x3303)},
+ {USB_DEVICE(0x07d1, 0x3302)},
+ {USB_DEVICE(0x07d1, 0x3300)},
+ /* Dlink for Skyworth */
+ {USB_DEVICE(0x14b2, 0x3300)},
+ {USB_DEVICE(0x14b2, 0x3301)},
+ {USB_DEVICE(0x14b2, 0x3302)},
+ /* EnGenius */
+ {USB_DEVICE(0x1740, 0x9603)},
+ {USB_DEVICE(0x1740, 0x9605)},
+ /* Belkin */
+ {USB_DEVICE(0x050d, 0x815F)},
+ {USB_DEVICE(0x050d, 0x945A)},
+ {USB_DEVICE(0x050d, 0x845A)},
+ /* Guillemot */
+ {USB_DEVICE(0x06f8, 0xe031)},
+ /* Edimax */
+ {USB_DEVICE(0x7392, 0x7611)},
+ {USB_DEVICE(0x7392, 0x7612)},
+ {USB_DEVICE(0x7392, 0x7622)},
+ /* Sitecom */
+ {USB_DEVICE(0x0DF6, 0x0045)},
+ /* Hawking */
+ {USB_DEVICE(0x0E66, 0x0015)},
+ {USB_DEVICE(0x0E66, 0x0016)},
+ {USB_DEVICE(0x0b05, 0x1786)},
+ {USB_DEVICE(0x0b05, 0x1791)}, /* 11n mode disable */
+
+ {USB_DEVICE(0x13D3, 0x3306)},
+ {USB_DEVICE(0x13D3, 0x3309)},
+ {USB_DEVICE(0x13D3, 0x3310)},
+ {USB_DEVICE(0x13D3, 0x3311)}, /* 11n mode disable */
+ {USB_DEVICE(0x13D3, 0x3325)},
+ {USB_DEVICE(0x083A, 0xC512)},
+ {}
+};
+
+MODULE_DEVICE_TABLE(usb, rtl871x_usb_id_tbl);
+
+static struct specific_device_id specific_device_id_tbl[] = {
+ {.idVendor = 0x0b05, .idProduct = 0x1791,
+ .flags = SPEC_DEV_ID_DISABLE_HT},
+ {.idVendor = 0x13D3, .idProduct = 0x3311,
+ .flags = SPEC_DEV_ID_DISABLE_HT},
+ {}
+};
+
+struct drv_priv {
+ struct usb_driver r871xu_drv;
+ int drv_registered;
+};
+
+#ifdef CONFIG_PM
+static int r871x_suspend(struct usb_interface *pusb_intf, pm_message_t state)
+{
+ struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
+
+ printk(KERN_INFO "r8712: suspending...\n");
+ if (!pnetdev || !netif_running(pnetdev)) {
+ printk(KERN_INFO "r8712: unable to suspend\n");
+ return 0;
+ }
+ if (pnetdev->netdev_ops->ndo_stop)
+ pnetdev->netdev_ops->ndo_stop(pnetdev);
+ mdelay(10);
+ netif_device_detach(pnetdev);
+ return 0;
+}
+
+static int r871x_resume(struct usb_interface *pusb_intf)
+{
+ struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
+
+ printk(KERN_INFO "r8712: resuming...\n");
+ if (!pnetdev || !netif_running(pnetdev)) {
+ printk(KERN_INFO "r8712: unable to resume\n");
+ return 0;
+ }
+ netif_device_attach(pnetdev);
+ if (pnetdev->netdev_ops->ndo_open)
+ pnetdev->netdev_ops->ndo_open(pnetdev);
+ return 0;
+}
+
+static int r871x_reset_resume(struct usb_interface *pusb_intf)
+{
+ /* dummy routine */
+ return 0;
+}
+
+#endif
+
+static struct drv_priv drvpriv = {
+ .r871xu_drv.name = "r8712u",
+ .r871xu_drv.id_table = rtl871x_usb_id_tbl,
+ .r871xu_drv.probe = r871xu_drv_init,
+ .r871xu_drv.disconnect = r871xu_dev_remove,
+#ifdef CONFIG_PM
+ .r871xu_drv.suspend = r871x_suspend,
+ .r871xu_drv.resume = r871x_resume,
+ .r871xu_drv.reset_resume = r871x_reset_resume,
+#endif
+};
+
+static uint r8712_usb_dvobj_init(struct _adapter *padapter)
+{
+ uint status = _SUCCESS;
+ struct usb_device_descriptor *pdev_desc;
+ struct usb_host_config *phost_conf;
+ struct usb_config_descriptor *pconf_desc;
+ struct usb_host_interface *phost_iface;
+ struct usb_interface_descriptor *piface_desc;
+ struct dvobj_priv *pdvobjpriv = &padapter->dvobjpriv;
+ struct usb_device *pusbd = pdvobjpriv->pusbdev;
+
+ pdvobjpriv->padapter = padapter;
+ padapter->EepromAddressSize = 6;
+ pdev_desc = &pusbd->descriptor;
+ phost_conf = pusbd->actconfig;
+ pconf_desc = &phost_conf->desc;
+ phost_iface = &pintf->altsetting[0];
+ piface_desc = &phost_iface->desc;
+ pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
+ if (pusbd->speed == USB_SPEED_HIGH) {
+ pdvobjpriv->ishighspeed = true;
+ printk(KERN_INFO "r8712u: USB_SPEED_HIGH with %d endpoints\n",
+ pdvobjpriv->nr_endpoint);
+ } else {
+ pdvobjpriv->ishighspeed = false;
+ printk(KERN_INFO "r8712u: USB_SPEED_LOW with %d endpoints\n",
+ pdvobjpriv->nr_endpoint);
+ }
+ if ((r8712_alloc_io_queue(padapter)) == _FAIL)
+ status = _FAIL;
+ sema_init(&(padapter->dvobjpriv.usb_suspend_sema), 0);
+ return status;
+}
+
+static void r8712_usb_dvobj_deinit(struct _adapter *padapter)
+{
+}
+
+void rtl871x_intf_stop(struct _adapter *padapter)
+{
+ /*disable_hw_interrupt*/
+ if (padapter->bSurpriseRemoved == false) {
+ /*device still exists, so driver can do i/o operation
+ * TODO: */
+ }
+
+ /* cancel in irp */
+ if (padapter->dvobjpriv.inirp_deinit != NULL)
+ padapter->dvobjpriv.inirp_deinit(padapter);
+ /* cancel out irp */
+ r8712_usb_write_port_cancel(padapter);
+ /* TODO:cancel other irps */
+}
+
+void r871x_dev_unload(struct _adapter *padapter)
+{
+ if (padapter->bup == true) {
+ /*s1.*/
+ padapter->bDriverStopped = true;
+
+ /*s3.*/
+ rtl871x_intf_stop(padapter);
+
+ /*s4.*/
+ r8712_stop_drv_threads(padapter);
+
+ /*s5.*/
+ if (padapter->bSurpriseRemoved == false) {
+ padapter->hw_init_completed = false;
+ rtl8712_hal_deinit(padapter);
+ }
+
+ /*s6.*/
+ if (padapter->dvobj_deinit)
+ padapter->dvobj_deinit(padapter);
+ padapter->bup = false;
+ }
+}
+
+static void disable_ht_for_spec_devid(const struct usb_device_id *pdid,
+ struct _adapter *padapter)
+{
+ u16 vid, pid;
+ u32 flags;
+ int i;
+ int num = sizeof(specific_device_id_tbl) /
+ sizeof(struct specific_device_id);
+
+ for (i = 0; i < num; i++) {
+ vid = specific_device_id_tbl[i].idVendor;
+ pid = specific_device_id_tbl[i].idProduct;
+ flags = specific_device_id_tbl[i].flags;
+
+ if ((pdid->idVendor == vid) && (pdid->idProduct == pid) &&
+ (flags&SPEC_DEV_ID_DISABLE_HT)) {
+ padapter->registrypriv.ht_enable = 0;
+ padapter->registrypriv.cbw40_enable = 0;
+ padapter->registrypriv.ampdu_enable = 0;
+ }
+ }
+}
+
+static u8 key_2char2num(u8 hch, u8 lch)
+{
+ return (hex_to_bin(hch) << 4) | hex_to_bin(lch);
+}
+
+/*
+ * drv_init() - a device potentially for us
+ *
+ * notes: drv_init() is called when the bus driver has located a card for us
+ * to support. We accept the new device by returning 0.
+*/
+static int r871xu_drv_init(struct usb_interface *pusb_intf,
+ const struct usb_device_id *pdid)
+{
+ uint status;
+ struct _adapter *padapter = NULL;
+ struct dvobj_priv *pdvobjpriv;
+ struct net_device *pnetdev;
+
+ printk(KERN_INFO "r8712u: DriverVersion: %s\n", DRVER);
+ /* In this probe function, O.S. will provide the usb interface pointer
+ * to driver. We have to increase the reference count of the usb device
+ * structure by using the usb_get_dev function.
+ */
+ usb_get_dev(interface_to_usbdev(pusb_intf));
+ pintf = pusb_intf;
+ /* step 1. */
+ pnetdev = r8712_init_netdev();
+ if (!pnetdev)
+ goto error;
+ padapter = (struct _adapter *)_netdev_priv(pnetdev);
+ disable_ht_for_spec_devid(pdid, padapter);
+ pdvobjpriv = &padapter->dvobjpriv;
+ pdvobjpriv->padapter = padapter;
+ padapter->dvobjpriv.pusbdev = interface_to_usbdev(pusb_intf);
+ usb_set_intfdata(pusb_intf, pnetdev);
+ SET_NETDEV_DEV(pnetdev, &pusb_intf->dev);
+ /* step 2. */
+ padapter->dvobj_init = &r8712_usb_dvobj_init;
+ padapter->dvobj_deinit = &r8712_usb_dvobj_deinit;
+ padapter->halpriv.hal_bus_init = &r8712_usb_hal_bus_init;
+ padapter->dvobjpriv.inirp_init = &r8712_usb_inirp_init;
+ padapter->dvobjpriv.inirp_deinit = &r8712_usb_inirp_deinit;
+ /* step 3.
+ * initialize the dvobj_priv
+ */
+ if (padapter->dvobj_init == NULL)
+ goto error;
+ else {
+ status = padapter->dvobj_init(padapter);
+ if (status != _SUCCESS)
+ goto error;
+ }
+ /* step 4. */
+ status = r8712_init_drv_sw(padapter);
+ if (status == _FAIL)
+ goto error;
+ /* step 5. read efuse/eeprom data and get mac_addr */
+ {
+ int i, offset;
+ u8 mac[6];
+ u8 tmpU1b, AutoloadFail, eeprom_CustomerID;
+ u8 *pdata = padapter->eeprompriv.efuse_eeprom_data;
+
+ tmpU1b = r8712_read8(padapter, EE_9346CR);/*CR9346*/
+
+ /* To check system boot selection.*/
+ printk(KERN_INFO "r8712u: Boot from %s: Autoload %s\n",
+ (tmpU1b & _9356SEL) ? "EEPROM" : "EFUSE",
+ (tmpU1b & _EEPROM_EN) ? "OK" : "Failed");
+
+ /* To check autoload success or not.*/
+ if (tmpU1b & _EEPROM_EN) {
+ AutoloadFail = true;
+ /* The following operations prevent Efuse leakage by
+ * turning on 2.5V.
+ */
+ tmpU1b = r8712_read8(padapter, EFUSE_TEST+3);
+ r8712_write8(padapter, EFUSE_TEST + 3, tmpU1b | 0x80);
+ msleep(20);
+ r8712_write8(padapter, EFUSE_TEST + 3,
+ (tmpU1b & (~BIT(7))));
+
+ /* Retrieve Chip version.
+ * Recognize IC version by Reg0x4 BIT15.
+ */
+ tmpU1b = (u8)((r8712_read32(padapter, PMC_FSM) >> 15) &
+ 0x1F);
+ if (tmpU1b == 0x3)
+ padapter->registrypriv.chip_version =
+ RTL8712_3rdCUT;
+ else
+ padapter->registrypriv.chip_version =
+ (tmpU1b >> 1) + 1;
+ switch (padapter->registrypriv.chip_version) {
+ case RTL8712_1stCUT:
+ case RTL8712_2ndCUT:
+ case RTL8712_3rdCUT:
+ break;
+ default:
+ padapter->registrypriv.chip_version =
+ RTL8712_2ndCUT;
+ break;
+ }
+
+ for (i = 0, offset = 0; i < 128; i += 8, offset++)
+ r8712_efuse_pg_packet_read(padapter, offset,
+ &pdata[i]);
+
+ if (r8712_initmac) {
+ /* Users specify the mac address */
+ int jj, kk;
+
+ for (jj = 0, kk = 0; jj < ETH_ALEN;
+ jj++, kk += 3)
+ mac[jj] =
+ key_2char2num(r8712_initmac[kk],
+ r8712_initmac[kk + 1]);
+ } else {
+ /* Use the mac address stored in the Efuse
+ * offset = 0x12 for usb in efuse
+ */
+ memcpy(mac, &pdata[0x12], ETH_ALEN);
+ }
+ eeprom_CustomerID = pdata[0x52];
+ switch (eeprom_CustomerID) {
+ case EEPROM_CID_ALPHA:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_ALPHA;
+ break;
+ case EEPROM_CID_CAMEO:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_CAMEO;
+ break;
+ case EEPROM_CID_SITECOM:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_Sitecom;
+ break;
+ case EEPROM_CID_COREGA:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_COREGA;
+ break;
+ case EEPROM_CID_Senao:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_Senao;
+ break;
+ case EEPROM_CID_EDIMAX_BELKIN:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_Edimax_Belkin;
+ break;
+ case EEPROM_CID_SERCOMM_BELKIN:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_Sercomm_Belkin;
+ break;
+ case EEPROM_CID_WNC_COREGA:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_WNC_COREGA;
+ break;
+ case EEPROM_CID_WHQL:
+ break;
+ case EEPROM_CID_NetCore:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_Netcore;
+ break;
+ case EEPROM_CID_CAMEO1:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_CAMEO1;
+ break;
+ case EEPROM_CID_CLEVO:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_819x_CLEVO;
+ break;
+ default:
+ padapter->eeprompriv.CustomerID =
+ RT_CID_DEFAULT;
+ break;
+ }
+ printk(KERN_INFO "r8712u: CustomerID = 0x%.4x\n",
+ padapter->eeprompriv.CustomerID);
+ /* Led mode */
+ switch (padapter->eeprompriv.CustomerID) {
+ case RT_CID_DEFAULT:
+ case RT_CID_819x_ALPHA:
+ case RT_CID_819x_CAMEO:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE1;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ case RT_CID_819x_Sitecom:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE2;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ case RT_CID_COREGA:
+ case RT_CID_819x_Senao:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE3;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ case RT_CID_819x_Edimax_Belkin:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE4;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ case RT_CID_819x_Sercomm_Belkin:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE5;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ case RT_CID_819x_WNC_COREGA:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE6;
+ padapter->ledpriv.bRegUseLed = true;
+ break;
+ default:
+ padapter->ledpriv.LedStrategy = SW_LED_MODE0;
+ padapter->ledpriv.bRegUseLed = false;
+ break;
+ }
+ } else
+ AutoloadFail = false;
+ if (((mac[0] == 0xff) && (mac[1] == 0xff) &&
+ (mac[2] == 0xff) && (mac[3] == 0xff) &&
+ (mac[4] == 0xff) && (mac[5] == 0xff)) ||
+ ((mac[0] == 0x00) && (mac[1] == 0x00) &&
+ (mac[2] == 0x00) && (mac[3] == 0x00) &&
+ (mac[4] == 0x00) && (mac[5] == 0x00)) ||
+ (AutoloadFail == false)) {
+ mac[0] = 0x00;
+ mac[1] = 0xe0;
+ mac[2] = 0x4c;
+ mac[3] = 0x87;
+ mac[4] = 0x00;
+ mac[5] = 0x00;
+ }
+ if (r8712_initmac) {
+ /* Make sure the user did not select a multicast
+ * address by setting bit 1 of first octet.
+ */
+ mac[0] &= 0xFE;
+ printk(KERN_INFO "r8712u: MAC Address from user = "
+ "%pM\n", mac);
+ } else
+ printk(KERN_INFO "r8712u: MAC Address from efuse = "
+ "%pM\n", mac);
+ memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
+ }
+ /* step 6. Tell the network stack we exist */
+ if (register_netdev(pnetdev) != 0)
+ goto error;
+ return 0;
+error:
+ usb_put_dev(interface_to_usbdev(pusb_intf));
+ usb_set_intfdata(pusb_intf, NULL);
+ if (padapter->dvobj_deinit != NULL)
+ padapter->dvobj_deinit(padapter);
+ if (pnetdev)
+ os_free_netdev(pnetdev);
+ return -ENODEV;
+}
+
+/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove()
+ * => how to recognize both */
+static void r871xu_dev_remove(struct usb_interface *pusb_intf)
+{
+ struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
+ struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev);
+ struct usb_device *udev = interface_to_usbdev(pusb_intf);
+
+ if (padapter) {
+ if (drvpriv.drv_registered == true)
+ padapter->bSurpriseRemoved = true;
+ if (pnetdev != NULL) {
+ /* will call netdev_close() */
+ unregister_netdev(pnetdev);
+ }
+ flush_scheduled_work();
+ udelay(1);
+ r871x_dev_unload(padapter);
+ r8712_free_drv_sw(padapter);
+ }
+ usb_set_intfdata(pusb_intf, NULL);
+ /* decrease the reference count of the usb device structure
+ * when disconnect */
+ usb_put_dev(udev);
+ /* If we didn't unplug usb dongle and remove/insert modlue, driver
+ * fails on sitesurvey for the first time when device is up.
+ * Reset usb port for sitesurvey fail issue. */
+ if (udev->state != USB_STATE_NOTATTACHED)
+ usb_reset_device(udev);
+ return;
+}
+
+static int __init r8712u_drv_entry(void)
+{
+ drvpriv.drv_registered = true;
+ return usb_register(&drvpriv.r871xu_drv);
+}
+
+static void __exit r8712u_drv_halt(void)
+{
+ drvpriv.drv_registered = false;
+ usb_deregister(&drvpriv.r871xu_drv);
+ printk(KERN_INFO "r8712u: Driver unloaded\n");
+}
+
+module_init(r8712u_drv_entry);
+module_exit(r8712u_drv_halt);
diff --git a/drivers/staging/rtl8712/usb_ops.c b/drivers/staging/rtl8712/usb_ops.c
new file mode 100644
index 000000000000..5a8b0ebd0b79
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_ops.c
@@ -0,0 +1,201 @@
+/******************************************************************************
+ * usb_ops.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _HCI_OPS_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+#include "recv_osdep.h"
+#include "rtl871x_byteorder.h"
+
+static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x01; /* read_in */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 1;
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+ return (u8)(le32_to_cpu(data)&0x0ff);
+}
+
+static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x01; /* read_in */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 2;
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+ return (u16)(le32_to_cpu(data)&0xffff);
+}
+
+static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x01; /* read_in */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 4;
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+ return le32_to_cpu(data);
+}
+
+static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x00; /* write_out */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 1;
+ data = val;
+ data = cpu_to_le32(data&0x000000ff);
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+}
+
+static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x00; /* write_out */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 2;
+ data = val;
+ data = cpu_to_le32(data&0x0000ffff);
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+}
+
+static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
+{
+ u8 request;
+ u8 requesttype;
+ u16 wvalue;
+ u16 index;
+ u16 len;
+ u32 data;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+
+ request = 0x05;
+ requesttype = 0x00; /* write_out */
+ index = 0;
+ wvalue = (u16)(addr&0x0000ffff);
+ len = 4;
+ data = cpu_to_le32(val);
+ r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
+ requesttype);
+}
+
+void r8712_usb_set_intf_option(u32 *poption)
+{
+ *poption = ((*poption) | _INTF_ASYNC_);
+}
+
+static void usb_intf_hdl_init(u8 *priv)
+{
+}
+
+static void usb_intf_hdl_unload(u8 *priv)
+{
+}
+
+static void usb_intf_hdl_open(u8 *priv)
+{
+}
+
+static void usb_intf_hdl_close(u8 *priv)
+{
+}
+
+void r8712_usb_set_intf_funs(struct intf_hdl *pintf_hdl)
+{
+ pintf_hdl->intf_hdl_init = &usb_intf_hdl_init;
+ pintf_hdl->intf_hdl_unload = &usb_intf_hdl_unload;
+ pintf_hdl->intf_hdl_open = &usb_intf_hdl_open;
+ pintf_hdl->intf_hdl_close = &usb_intf_hdl_close;
+}
+
+void r8712_usb_set_intf_ops(struct _io_ops *pops)
+{
+ memset((u8 *)pops, 0, sizeof(struct _io_ops));
+ pops->_read8 = &usb_read8;
+ pops->_read16 = &usb_read16;
+ pops->_read32 = &usb_read32;
+ pops->_read_port = &r8712_usb_read_port;
+ pops->_write8 = &usb_write8;
+ pops->_write16 = &usb_write16;
+ pops->_write32 = &usb_write32;
+ pops->_write_mem = &r8712_usb_write_mem;
+ pops->_write_port = &r8712_usb_write_port;
+}
diff --git a/drivers/staging/rtl8712/usb_ops.h b/drivers/staging/rtl8712/usb_ops.h
new file mode 100644
index 000000000000..dc0611a2a0df
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_ops.h
@@ -0,0 +1,25 @@
+#ifndef __USB_OPS_H_
+#define __USB_OPS_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "osdep_intf.h"
+
+void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr,
+ u32 cnt, u8 *wmem);
+u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr,
+ u32 cnt, u8 *wmem);
+u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr,
+ u32 cnt, u8 *rmem);
+void r8712_usb_set_intf_option(u32 *poption);
+void r8712_usb_set_intf_funs(struct intf_hdl *pintf_hdl);
+uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv);
+void r8712_usb_unload_intf_priv(struct intf_priv *pintfpriv);
+void r8712_usb_set_intf_ops(struct _io_ops *pops);
+void r8712_usb_read_port_cancel(struct _adapter *padapter);
+void r8712_usb_write_port_cancel(struct _adapter *padapter);
+int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
+ u16 index, void *pdata, u16 len, u8 requesttype);
+
+#endif
+
diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c
new file mode 100644
index 000000000000..7933ea4f632b
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -0,0 +1,529 @@
+/******************************************************************************
+ * usb_ops_linux.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _HCI_OPS_OS_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "osdep_intf.h"
+#include "usb_ops.h"
+
+#define RTL871X_VENQT_READ 0xc0
+#define RTL871X_VENQT_WRITE 0x40
+
+struct zero_bulkout_context {
+ void *pbuf;
+ void *purb;
+ void *pirp;
+ void *padapter;
+};
+
+#define usb_write_cmd r8712_usb_write_mem
+#define usb_write_cmd_complete usb_write_mem_complete
+
+uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv)
+{
+ pintfpriv->piorw_urb = _usb_alloc_urb(0, GFP_ATOMIC);
+ if (!pintfpriv->piorw_urb)
+ return _FAIL;
+ sema_init(&(pintfpriv->io_retevt), 0);
+ return _SUCCESS;
+}
+
+void r8712_usb_unload_intf_priv(struct intf_priv *pintfpriv)
+{
+ if (pintfpriv->piorw_urb) {
+ usb_kill_urb(pintfpriv->piorw_urb);
+ usb_free_urb(pintfpriv->piorw_urb);
+ }
+}
+
+static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
+{
+ unsigned int pipe = 0;
+ struct usb_device *pusbd = pdvobj->pusbdev;
+
+ if (pdvobj->nr_endpoint == 11) {
+ switch (addr) {
+ case RTL8712_DMA_BKQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x07);
+ break;
+ case RTL8712_DMA_BEQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x06);
+ break;
+ case RTL8712_DMA_VIQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x05);
+ break;
+ case RTL8712_DMA_VOQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x04);
+ break;
+ case RTL8712_DMA_BCNQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x0a);
+ break;
+ case RTL8712_DMA_BMCQ: /* HI Queue */
+ pipe = usb_sndbulkpipe(pusbd, 0x0b);
+ break;
+ case RTL8712_DMA_MGTQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x0c);
+ break;
+ case RTL8712_DMA_RX0FF:
+ pipe = usb_rcvbulkpipe(pusbd, 0x03); /* in */
+ break;
+ case RTL8712_DMA_C2HCMD:
+ pipe = usb_rcvbulkpipe(pusbd, 0x09); /* in */
+ break;
+ case RTL8712_DMA_H2CCMD:
+ pipe = usb_sndbulkpipe(pusbd, 0x0d);
+ break;
+ }
+ } else if (pdvobj->nr_endpoint == 6) {
+ switch (addr) {
+ case RTL8712_DMA_BKQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x07);
+ break;
+ case RTL8712_DMA_BEQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x06);
+ break;
+ case RTL8712_DMA_VIQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x05);
+ break;
+ case RTL8712_DMA_VOQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x04);
+ break;
+ case RTL8712_DMA_RX0FF:
+ case RTL8712_DMA_C2HCMD:
+ pipe = usb_rcvbulkpipe(pusbd, 0x03); /* in */
+ break;
+ case RTL8712_DMA_H2CCMD:
+ case RTL8712_DMA_BCNQ:
+ case RTL8712_DMA_BMCQ:
+ case RTL8712_DMA_MGTQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x0d);
+ break;
+ }
+ } else if (pdvobj->nr_endpoint == 4) {
+ switch (addr) {
+ case RTL8712_DMA_BEQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x06);
+ break;
+ case RTL8712_DMA_VOQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x04);
+ break;
+ case RTL8712_DMA_RX0FF:
+ case RTL8712_DMA_C2HCMD:
+ pipe = usb_rcvbulkpipe(pusbd, 0x03); /* in */
+ break;
+ case RTL8712_DMA_H2CCMD:
+ case RTL8712_DMA_BCNQ:
+ case RTL8712_DMA_BMCQ:
+ case RTL8712_DMA_MGTQ:
+ pipe = usb_sndbulkpipe(pusbd, 0x0d);
+ break;
+ }
+ } else
+ pipe = 0;
+ return pipe;
+}
+
+static void usb_write_mem_complete(struct urb *purb)
+{
+ struct io_queue *pio_q = (struct io_queue *)purb->context;
+ struct intf_hdl *pintf = &(pio_q->intf);
+ struct intf_priv *pintfpriv = pintf->pintfpriv;
+ struct _adapter *padapter = (struct _adapter *)pintf->adapter;
+
+ if (purb->status != 0) {
+ if (purb->status == (-ESHUTDOWN))
+ padapter->bDriverStopped = true;
+ else
+ padapter->bSurpriseRemoved = true;
+ }
+ up(&pintfpriv->io_retevt);
+}
+
+void r8712_usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
+{
+ unsigned int pipe;
+ int status;
+ struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+ struct io_queue *pio_queue = (struct io_queue *)padapter->pio_queue;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)pintfpriv->intf_dev;
+ struct usb_device *pusbd = pdvobj->pusbdev;
+ struct urb *piorw_urb = pintfpriv->piorw_urb;
+
+ if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ||
+ (padapter->pwrctrlpriv.pnp_bstop_trx))
+ return;
+ /* translate DMA FIFO addr to pipehandle */
+ pipe = ffaddr2pipehdl(pdvobj, addr);
+ if (pipe == 0)
+ return;
+ usb_fill_bulk_urb(piorw_urb, pusbd, pipe,
+ wmem, cnt, usb_write_mem_complete,
+ pio_queue);
+ status = _usb_submit_urb(piorw_urb, GFP_ATOMIC);
+ _down_sema(&pintfpriv->io_retevt);
+}
+
+static void r8712_usb_read_port_complete(struct urb *purb)
+{
+ uint isevt, *pbuf;
+ struct recv_buf *precvbuf = (struct recv_buf *)purb->context;
+ struct _adapter *padapter = (struct _adapter *)precvbuf->adapter;
+ struct recv_priv *precvpriv = &padapter->recvpriv;
+
+ if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
+ return;
+ if (purb->status == 0) { /* SUCCESS */
+ if ((purb->actual_length > (MAX_RECVBUF_SZ)) ||
+ (purb->actual_length < RXDESC_SIZE)) {
+ precvbuf->reuse = true;
+ r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
+ (unsigned char *)precvbuf);
+ } else {
+ precvbuf->transfer_len = purb->actual_length;
+ pbuf = (uint *)precvbuf->pbuf;
+ isevt = le32_to_cpu(*(pbuf + 1)) & 0x1ff;
+ if ((isevt & 0x1ff) == 0x1ff) {
+ r8712_rxcmd_event_hdl(padapter, pbuf);
+ precvbuf->reuse = true;
+ r8712_read_port(padapter, precvpriv->ff_hwaddr,
+ 0, (unsigned char *)precvbuf);
+ } else {
+ _pkt *pskb = precvbuf->pskb;
+ skb_put(pskb, purb->actual_length);
+ skb_queue_tail(&precvpriv->rx_skb_queue, pskb);
+ tasklet_hi_schedule(&precvpriv->recv_tasklet);
+ precvbuf->pskb = NULL;
+ precvbuf->reuse = false;
+ r8712_read_port(padapter, precvpriv->ff_hwaddr,
+ 0, (unsigned char *)precvbuf);
+ }
+ }
+ } else {
+ switch (purb->status) {
+ case -EINVAL:
+ case -EPIPE:
+ case -ENODEV:
+ case -ESHUTDOWN:
+ case -ENOENT:
+ padapter->bDriverStopped = true;
+ break;
+ case -EPROTO:
+ precvbuf->reuse = true;
+ r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
+ (unsigned char *)precvbuf);
+ break;
+ case -EINPROGRESS:
+ printk(KERN_ERR "r8712u: ERROR: URB IS IN"
+ " PROGRESS!/n");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+u32 r8712_usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
+{
+ unsigned int pipe;
+ int err;
+ u32 tmpaddr = 0;
+ int alignment = 0;
+ u32 ret = _SUCCESS;
+ struct urb *purb = NULL;
+ struct recv_buf *precvbuf = (struct recv_buf *)rmem;
+ struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)pintfpriv->intf_dev;
+ struct _adapter *adapter = (struct _adapter *)pdvobj->padapter;
+ struct recv_priv *precvpriv = &adapter->recvpriv;
+ struct usb_device *pusbd = pdvobj->pusbdev;
+
+ if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
+ adapter->pwrctrlpriv.pnp_bstop_trx)
+ return _FAIL;
+ if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) {
+ precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue);
+ if (NULL != precvbuf->pskb)
+ precvbuf->reuse = true;
+ }
+ if (precvbuf != NULL) {
+ r8712_init_recvbuf(adapter, precvbuf);
+ /* re-assign for linux based on skb */
+ if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) {
+ precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev,
+ MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
+ if (precvbuf->pskb == NULL)
+ return _FAIL;
+ tmpaddr = (addr_t)precvbuf->pskb->data;
+ alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1);
+ skb_reserve(precvbuf->pskb,
+ (RECVBUFF_ALIGN_SZ - alignment));
+ precvbuf->phead = precvbuf->pskb->head;
+ precvbuf->pdata = precvbuf->pskb->data;
+ precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
+ precvbuf->pend = skb_end_pointer(precvbuf->pskb);
+ precvbuf->pbuf = precvbuf->pskb->data;
+ } else { /* reuse skb */
+ precvbuf->phead = precvbuf->pskb->head;
+ precvbuf->pdata = precvbuf->pskb->data;
+ precvbuf->ptail = skb_tail_pointer(precvbuf->pskb);
+ precvbuf->pend = skb_end_pointer(precvbuf->pskb);
+ precvbuf->pbuf = precvbuf->pskb->data;
+ precvbuf->reuse = false;
+ }
+ purb = precvbuf->purb;
+ /* translate DMA FIFO addr to pipehandle */
+ pipe = ffaddr2pipehdl(pdvobj, addr);
+ usb_fill_bulk_urb(purb, pusbd, pipe,
+ precvbuf->pbuf, MAX_RECVBUF_SZ,
+ r8712_usb_read_port_complete,
+ precvbuf);
+ err = _usb_submit_urb(purb, GFP_ATOMIC);
+ if ((err) && (err != (-EPERM)))
+ ret = _FAIL;
+ } else
+ ret = _FAIL;
+ return ret;
+}
+
+void r8712_usb_read_port_cancel(struct _adapter *padapter)
+{
+ int i;
+ struct recv_buf *precvbuf;
+
+ precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
+ for (i = 0; i < NR_RECVBUFF; i++) {
+ if (precvbuf->purb)
+ usb_kill_urb(precvbuf->purb);
+ precvbuf++;
+ }
+}
+
+void r8712_xmit_bh(void *priv)
+{
+ int ret = false;
+ struct _adapter *padapter = (struct _adapter *)priv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+
+ while (1) {
+ if ((padapter->bDriverStopped == true) ||
+ (padapter->bSurpriseRemoved == true)) {
+ printk(KERN_ERR "r8712u: xmit_bh => bDriverStopped"
+ " or bSurpriseRemoved\n");
+ break;
+ }
+ ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL);
+ if (ret == false)
+ break;
+ }
+}
+
+static void usb_write_port_complete(struct urb *purb)
+{
+ int i;
+ struct xmit_frame *pxmitframe = (struct xmit_frame *)purb->context;
+ struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf;
+ struct _adapter *padapter = pxmitframe->padapter;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+
+ switch (pattrib->priority) {
+ case 1:
+ case 2:
+ pxmitpriv->bkq_cnt--;
+ break;
+ case 4:
+ case 5:
+ pxmitpriv->viq_cnt--;
+ break;
+ case 6:
+ case 7:
+ pxmitpriv->voq_cnt--;
+ break;
+ case 0:
+ case 3:
+ default:
+ pxmitpriv->beq_cnt--;
+ break;
+ }
+ pxmitpriv->txirp_cnt--;
+ for (i = 0; i < 8; i++) {
+ if (purb == pxmitframe->pxmit_urb[i]) {
+ pxmitframe->bpending[i] = false;
+ break;
+ }
+ }
+ if (padapter->bSurpriseRemoved)
+ return;
+ switch (purb->status) {
+ case 0:
+ break;
+ default:
+ printk(KERN_WARNING "r8712u: pipe error: (%d)\n", purb->status);
+ break;
+ }
+ /* not to consider tx fragment */
+ r8712_free_xmitframe_ex(pxmitpriv, pxmitframe);
+ r8712_free_xmitbuf(pxmitpriv, pxmitbuf);
+ tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
+}
+
+u32 r8712_usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
+{
+ unsigned long irqL;
+ int i, status;
+ unsigned int pipe;
+ u32 ret, bwritezero;
+ struct urb *purb = NULL;
+ struct _adapter *padapter = (struct _adapter *)pintfhdl->adapter;
+ struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+ struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+ struct xmit_frame *pxmitframe = (struct xmit_frame *)wmem;
+ struct usb_device *pusbd = pdvobj->pusbdev;
+ struct pkt_attrib *pattrib = &pxmitframe->attrib;
+
+ if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ||
+ (padapter->pwrctrlpriv.pnp_bstop_trx))
+ return _FAIL;
+ for (i = 0; i < 8; i++) {
+ if (pxmitframe->bpending[i] == false) {
+ spin_lock_irqsave(&pxmitpriv->lock, irqL);
+ pxmitpriv->txirp_cnt++;
+ pxmitframe->bpending[i] = true;
+ switch (pattrib->priority) {
+ case 1:
+ case 2:
+ pxmitpriv->bkq_cnt++;
+ break;
+ case 4:
+ case 5:
+ pxmitpriv->viq_cnt++;
+ break;
+ case 6:
+ case 7:
+ pxmitpriv->voq_cnt++;
+ break;
+ case 0:
+ case 3:
+ default:
+ pxmitpriv->beq_cnt++;
+ break;
+ }
+ spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
+ pxmitframe->sz[i] = (u16)cnt;
+ purb = pxmitframe->pxmit_urb[i];
+ break;
+ }
+ }
+ bwritezero = false;
+ if (pdvobj->ishighspeed) {
+ if (cnt > 0 && cnt % 512 == 0)
+ bwritezero = true;
+ } else {
+ if (cnt > 0 && cnt % 64 == 0)
+ bwritezero = true;
+ }
+ /* translate DMA FIFO addr to pipehandle */
+ pipe = ffaddr2pipehdl(pdvobj, addr);
+ if (pxmitpriv->free_xmitbuf_cnt%NR_XMITBUFF == 0)
+ purb->transfer_flags &= (~URB_NO_INTERRUPT);
+ else
+ purb->transfer_flags |= URB_NO_INTERRUPT;
+ if (bwritezero)
+ cnt += 8;
+ usb_fill_bulk_urb(purb, pusbd, pipe,
+ pxmitframe->mem_addr,
+ cnt, usb_write_port_complete,
+ pxmitframe); /* context is xmit_frame */
+ status = _usb_submit_urb(purb, GFP_ATOMIC);
+ if (!status)
+ ret = _SUCCESS;
+ else
+ ret = _FAIL;
+ return ret;
+}
+
+void r8712_usb_write_port_cancel(struct _adapter *padapter)
+{
+ int i, j;
+ struct xmit_buf *pxmitbuf = (struct xmit_buf *)
+ padapter->xmitpriv.pxmitbuf;
+
+ for (i = 0; i < NR_XMITBUFF; i++) {
+ for (j = 0; j < 8; j++) {
+ if (pxmitbuf->pxmit_urb[j])
+ usb_kill_urb(pxmitbuf->pxmit_urb[j]);
+ }
+ pxmitbuf++;
+ }
+}
+
+int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
+ u16 index, void *pdata, u16 len, u8 requesttype)
+{
+ unsigned int pipe;
+ int status;
+ u8 reqtype;
+ struct dvobj_priv *pdvobjpriv = (struct dvobj_priv *)
+ pintfpriv->intf_dev;
+ struct usb_device *udev = pdvobjpriv->pusbdev;
+ /* For mstar platform, mstar suggests the address for USB IO
+ * should be 16 bytes alignment. Trying to fix it here.
+ */
+ u8 *palloc_buf, *pIo_buf;
+
+ palloc_buf = _malloc((u32) len + 16);
+ if (palloc_buf == NULL) {
+ printk(KERN_ERR "r8712u: [%s] Can't alloc memory for vendor"
+ " request\n", __func__);
+ return -1;
+ }
+ pIo_buf = palloc_buf + 16 - ((addr_t)(palloc_buf) & 0x0f);
+ if (requesttype == 0x01) {
+ pipe = usb_rcvctrlpipe(udev, 0); /* read_in */
+ reqtype = RTL871X_VENQT_READ;
+ } else {
+ pipe = usb_sndctrlpipe(udev, 0); /* write_out */
+ reqtype = RTL871X_VENQT_WRITE;
+ memcpy(pIo_buf, pdata, len);
+ }
+ status = usb_control_msg(udev, pipe, request, reqtype, value, index,
+ pIo_buf, len, HZ / 2);
+ if (status > 0) { /* Success this control transfer. */
+ if (requesttype == 0x01) {
+ /* For Control read transfer, we have to copy the read
+ * data from pIo_buf to pdata.
+ */
+ memcpy(pdata, pIo_buf, status);
+ }
+ }
+ kfree(palloc_buf);
+ return status;
+}
diff --git a/drivers/staging/rtl8712/usb_osintf.h b/drivers/staging/rtl8712/usb_osintf.h
new file mode 100644
index 000000000000..0da6c1db048e
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_osintf.h
@@ -0,0 +1,24 @@
+#ifndef __USB_OSINTF_H
+#define __USB_OSINTF_H
+
+#include "osdep_service.h"
+#include "drv_types.h"
+#include "usb_vendor_req.h"
+
+#define USBD_HALTED(Status) ((u32)(Status) >> 30 == 3)
+
+extern char *r8712_initmac;
+
+unsigned int r8712_usb_inirp_init(struct _adapter *padapter);
+unsigned int r8712_usb_inirp_deinit(struct _adapter *padapter);
+uint rtl871x_hal_init(struct _adapter *padapter);
+uint rtl8712_hal_deinit(struct _adapter *padapter);
+
+void rtl871x_intf_stop(struct _adapter *padapter);
+void r871x_dev_unload(struct _adapter *padapter);
+void r8712_stop_drv_threads(struct _adapter *padapter);
+u8 r8712_init_drv_sw(struct _adapter *padapter);
+u8 r8712_free_drv_sw(struct _adapter *padapter);
+struct net_device *r8712_init_netdev(void);
+
+#endif
diff --git a/drivers/staging/rtl8712/usb_vendor_req.h b/drivers/staging/rtl8712/usb_vendor_req.h
new file mode 100644
index 000000000000..d35c538c47a1
--- /dev/null
+++ b/drivers/staging/rtl8712/usb_vendor_req.h
@@ -0,0 +1,33 @@
+#ifndef _USB_VENDOR_REQUEST_H_
+#define _USB_VENDOR_REQUEST_H_
+
+/*4 Set/Get Register related wIndex/Data */
+#define RT_USB_RESET_MASK_OFF 0
+#define RT_USB_RESET_MASK_ON 1
+#define RT_USB_SLEEP_MASK_OFF 0
+#define RT_USB_SLEEP_MASK_ON 1
+#define RT_USB_LDO_ON 1
+#define RT_USB_LDO_OFF 0
+
+/*4 Set/Get SYSCLK related wValue or Data */
+#define RT_USB_SYSCLK_32KHZ 0
+#define RT_USB_SYSCLK_40MHZ 1
+#define RT_USB_SYSCLK_60MHZ 2
+
+enum RT_USB_BREQUEST {
+ RT_USB_SET_REGISTER = 1,
+ RT_USB_SET_SYSCLK = 2,
+ RT_USB_GET_SYSCLK = 3,
+ RT_USB_GET_REGISTER = 4
+};
+
+enum RT_USB_WVALUE {
+ RT_USB_RESET_MASK = 1,
+ RT_USB_SLEEP_MASK = 2,
+ RT_USB_USB_HRCPWM = 3,
+ RT_USB_LDO = 4,
+ RT_USB_BOOT_TYPE = 5
+};
+
+#endif
+
diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h
new file mode 100644
index 000000000000..86d4b98e2439
--- /dev/null
+++ b/drivers/staging/rtl8712/wifi.h
@@ -0,0 +1,622 @@
+#ifndef _WIFI_H_
+#define _WIFI_H_
+
+#include "rtl871x_byteorder.h"
+
+#ifdef BIT
+#undef BIT
+#endif
+#define BIT(x) (1 << (x))
+
+#define WLAN_ETHHDR_LEN 14
+#define WLAN_ETHADDR_LEN 6
+#define WLAN_IEEE_OUI_LEN 3
+#define WLAN_ADDR_LEN 6
+#define WLAN_CRC_LEN 4
+#define WLAN_BSSID_LEN 6
+#define WLAN_BSS_TS_LEN 8
+#define WLAN_HDR_A3_LEN 24
+#define WLAN_HDR_A4_LEN 30
+#define WLAN_HDR_A3_QOS_LEN 26
+#define WLAN_HDR_A4_QOS_LEN 32
+#define WLAN_SSID_MAXLEN 32
+#define WLAN_DATA_MAXLEN 2312
+
+#define WLAN_A3_PN_OFFSET 24
+#define WLAN_A4_PN_OFFSET 30
+
+#define WLAN_MIN_ETHFRM_LEN 60
+#define WLAN_MAX_ETHFRM_LEN 1514
+#define WLAN_ETHHDR_LEN 14
+
+#define P80211CAPTURE_VERSION 0x80211001
+
+enum WIFI_FRAME_TYPE {
+ WIFI_MGT_TYPE = (0),
+ WIFI_CTRL_TYPE = (BIT(2)),
+ WIFI_DATA_TYPE = (BIT(3)),
+ WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /*!< QoS Data */
+};
+
+enum WIFI_FRAME_SUBTYPE {
+
+ /* below is for mgt frame */
+ WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE),
+ WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE),
+ WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE),
+ WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
+ WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE),
+ WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
+ WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE),
+ WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
+ WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
+ WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
+ WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
+ WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
+
+ /* below is for control frame */
+ WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
+ WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
+ WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
+ WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
+ WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
+ WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
+
+ /* below is for data frame */
+ WIFI_DATA = (0 | WIFI_DATA_TYPE),
+ WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE),
+ WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE),
+ WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
+ WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE),
+ WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
+ WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
+ WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
+};
+
+enum WIFI_REASON_CODE {
+ _RSON_RESERVED_ = 0,
+ _RSON_UNSPECIFIED_ = 1,
+ _RSON_AUTH_NO_LONGER_VALID_ = 2,
+ _RSON_DEAUTH_STA_LEAVING_ = 3,
+ _RSON_INACTIVITY_ = 4,
+ _RSON_UNABLE_HANDLE_ = 5,
+ _RSON_CLS2_ = 6,
+ _RSON_CLS3_ = 7,
+ _RSON_DISAOC_STA_LEAVING_ = 8,
+ _RSON_ASOC_NOT_AUTH_ = 9,
+
+ /* WPA reason */
+ _RSON_INVALID_IE_ = 13,
+ _RSON_MIC_FAILURE_ = 14,
+ _RSON_4WAY_HNDSHK_TIMEOUT_ = 15,
+ _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
+ _RSON_DIFF_IE_ = 17,
+ _RSON_MLTCST_CIPHER_NOT_VALID_ = 18,
+ _RSON_UNICST_CIPHER_NOT_VALID_ = 19,
+ _RSON_AKMP_NOT_VALID_ = 20,
+ _RSON_UNSUPPORT_RSNE_VER_ = 21,
+ _RSON_INVALID_RSNE_CAP_ = 22,
+ _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23,
+
+ /* below are Realtek definitions */
+ _RSON_PMK_NOT_AVAILABLE_ = 24,
+};
+
+enum WIFI_STATUS_CODE {
+ _STATS_SUCCESSFUL_ = 0,
+ _STATS_FAILURE_ = 1,
+ _STATS_CAP_FAIL_ = 10,
+ _STATS_NO_ASOC_ = 11,
+ _STATS_OTHER_ = 12,
+ _STATS_NO_SUPP_ALG_ = 13,
+ _STATS_OUT_OF_AUTH_SEQ_ = 14,
+ _STATS_CHALLENGE_FAIL_ = 15,
+ _STATS_AUTH_TIMEOUT_ = 16,
+ _STATS_UNABLE_HANDLE_STA_ = 17,
+ _STATS_RATE_FAIL_ = 18,
+};
+
+enum WIFI_REG_DOMAIN {
+ DOMAIN_FCC = 1,
+ DOMAIN_IC = 2,
+ DOMAIN_ETSI = 3,
+ DOMAIN_SPAIN = 4,
+ DOMAIN_FRANCE = 5,
+ DOMAIN_MKK = 6,
+ DOMAIN_ISRAEL = 7,
+ DOMAIN_MKK1 = 8,
+ DOMAIN_MKK2 = 9,
+ DOMAIN_MKK3 = 10,
+ DOMAIN_MAX
+};
+
+#define _TO_DS_ BIT(8)
+#define _FROM_DS_ BIT(9)
+#define _MORE_FRAG_ BIT(10)
+#define _RETRY_ BIT(11)
+#define _PWRMGT_ BIT(12)
+#define _MORE_DATA_ BIT(13)
+#define _PRIVACY_ BIT(14)
+#define _ORDER_ BIT(15)
+
+#define SetToDs(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \
+ } while (0)
+
+#define GetToDs(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_TO_DS_)) != 0)
+
+#define ClearToDs(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
+ } while (0)
+
+#define SetFrDs(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
+ } while (0)
+
+#define GetFrDs(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_FROM_DS_)) != 0)
+
+#define ClearFrDs(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
+ } while (0)
+
+#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe))
+
+
+#define SetMFrag(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
+ } while (0)
+
+#define GetMFrag(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_MORE_FRAG_)) != 0)
+
+#define ClearMFrag(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
+ } while (0)
+
+#define SetRetry(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \
+ } while (0)
+
+#define GetRetry(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_RETRY_)) != 0)
+
+#define ClearRetry(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
+ } while (0)
+
+#define SetPwrMgt(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
+ } while (0)
+
+#define GetPwrMgt(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_PWRMGT_)) != 0)
+
+#define ClearPwrMgt(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
+ } while (0)
+
+#define SetMData(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
+ } while (0)
+
+#define GetMData(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_MORE_DATA_)) != 0)
+
+#define ClearMData(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
+ } while (0)
+
+#define SetPrivacy(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
+ } while (0)
+
+#define GetPrivacy(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_PRIVACY_)) != 0)
+
+#define ClearPrivacy(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
+ } while (0)
+
+
+#define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_ORDER_)) != 0)
+
+#define GetFrameType(pbuf) (le16_to_cpu(*(unsigned short *)(pbuf)) & \
+ (BIT(3) | BIT(2)))
+
+#define SetFrameType(pbuf, type) \
+ do { \
+ *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | \
+ BIT(2))); \
+ *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
+ } while (0)
+
+#define GetFrameSubType(pbuf) (cpu_to_le16(*(unsigned short *)(pbuf)) & \
+ (BIT(7) | BIT(6) | BIT(5) | BIT(4) | BIT(3) | \
+ BIT(2)))
+
+#define SetFrameSubType(pbuf, type) \
+ do { \
+ *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \
+ BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
+ } while (0)
+
+#define GetSequence(pbuf) (cpu_to_le16(*(unsigned short *)\
+ ((addr_t)(pbuf) + 22)) >> 4)
+
+#define GetFragNum(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)\
+ (pbuf) + 22)) & 0x0f)
+
+#define GetTupleCache(pbuf) (cpu_to_le16(*(unsigned short *)\
+ ((addr_t)(pbuf) + 22)))
+
+#define SetFragNum(pbuf, num) \
+ do { \
+ *(unsigned short *)((addr_t)(pbuf) + 22) = \
+ ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
+ le16_to_cpu(~(0x000f))) | \
+ cpu_to_le16(0x0f & (num)); \
+ } while (0)
+
+#define SetSeqNum(pbuf, num) \
+ do { \
+ *(unsigned short *)((addr_t)(pbuf) + 22) = \
+ ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
+ le16_to_cpu((unsigned short)0x000f)) | \
+ le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
+ } while (0)
+
+#define SetDuration(pbuf, dur) \
+ do { \
+ *(unsigned short *)((addr_t)(pbuf) + 2) |= \
+ cpu_to_le16(0xffff & (dur)); \
+ } while (0)
+
+#define SetPriority(pbuf, tid) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \
+ } while (0)
+
+#define GetPriority(pbuf) ((le16_to_cpu(*(unsigned short *)(pbuf))) & 0xf)
+
+#define SetAckpolicy(pbuf, ack) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
+ } while (0)
+
+#define GetAckpolicy(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 5) & 0x3)
+
+#define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1)
+
+#define SetAMsdu(pbuf, amsdu) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \
+ } while (0)
+
+#define GetAid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + 2)) \
+ & 0x3fff)
+
+#define GetTid(pbuf) (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + \
+ (((GetToDs(pbuf) << 1)|GetFrDs(pbuf)) == 3 ? \
+ 30 : 24))) & 0x000f)
+
+#define GetAddr1Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 4))
+
+#define GetAddr2Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 10))
+
+#define GetAddr3Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 16))
+
+#define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24))
+
+
+
+static inline int IS_MCAST(unsigned char *da)
+{
+ if ((*da) & 0x01)
+ return true;
+ else
+ return false;
+}
+
+
+static inline unsigned char *get_da(unsigned char *pframe)
+{
+ unsigned char *da;
+ unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
+
+ switch (to_fr_ds) {
+ case 0x00: /* ToDs=0, FromDs=0 */
+ da = GetAddr1Ptr(pframe);
+ break;
+ case 0x01: /* ToDs=0, FromDs=1 */
+ da = GetAddr1Ptr(pframe);
+ break;
+ case 0x02: /* ToDs=1, FromDs=0 */
+ da = GetAddr3Ptr(pframe);
+ break;
+ default: /* ToDs=1, FromDs=1 */
+ da = GetAddr3Ptr(pframe);
+ break;
+ }
+ return da;
+}
+
+
+static inline unsigned char *get_sa(unsigned char *pframe)
+{
+ unsigned char *sa;
+ unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
+
+ switch (to_fr_ds) {
+ case 0x00: /* ToDs=0, FromDs=0 */
+ sa = GetAddr2Ptr(pframe);
+ break;
+ case 0x01: /* ToDs=0, FromDs=1 */
+ sa = GetAddr3Ptr(pframe);
+ break;
+ case 0x02: /* ToDs=1, FromDs=0 */
+ sa = GetAddr2Ptr(pframe);
+ break;
+ default: /* ToDs=1, FromDs=1 */
+ sa = GetAddr4Ptr(pframe);
+ break;
+ }
+
+ return sa;
+}
+
+static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
+{
+ unsigned char *sa;
+ unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
+
+ switch (to_fr_ds) {
+ case 0x00: /* ToDs=0, FromDs=0 */
+ sa = GetAddr3Ptr(pframe);
+ break;
+ case 0x01: /* ToDs=0, FromDs=1 */
+ sa = GetAddr2Ptr(pframe);
+ break;
+ case 0x02: /* ToDs=1, FromDs=0 */
+ sa = GetAddr1Ptr(pframe);
+ break;
+ default: /* ToDs=1, FromDs=1 */
+ sa = NULL;
+ break;
+ }
+ return sa;
+}
+
+
+
+/*-----------------------------------------------------------------------------
+ Below is for the security related definition
+------------------------------------------------------------------------------*/
+#define _RESERVED_FRAME_TYPE_ 0
+#define _SKB_FRAME_TYPE_ 2
+#define _PRE_ALLOCMEM_ 1
+#define _PRE_ALLOCHDR_ 3
+#define _PRE_ALLOCLLCHDR_ 4
+#define _PRE_ALLOCICVHDR_ 5
+#define _PRE_ALLOCMICHDR_ 6
+
+#define _SIFSTIME_ ((priv->pmib->BssType.net_work_type & \
+ WIRELESS_11A) ? 16 : 10)
+#define _ACKCTSLNG_ 14 /*14 bytes long, including crclng */
+#define _CRCLNG_ 4
+
+#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */
+#define _ASOCRSP_IE_OFFSET_ 6
+#define _REASOCREQ_IE_OFFSET_ 10
+#define _REASOCRSP_IE_OFFSET_ 6
+#define _PROBEREQ_IE_OFFSET_ 0
+#define _PROBERSP_IE_OFFSET_ 12
+#define _AUTH_IE_OFFSET_ 6
+#define _DEAUTH_IE_OFFSET_ 0
+#define _BEACON_IE_OFFSET_ 12
+
+#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_
+
+#define _SSID_IE_ 0
+#define _SUPPORTEDRATES_IE_ 1
+#define _DSSET_IE_ 3
+#define _TIM_IE_ 5
+#define _IBSS_PARA_IE_ 6
+#define _CHLGETXT_IE_ 16
+#define _RSN_IE_2_ 48`
+#define _SSN_IE_1_ 221
+#define _ERPINFO_IE_ 42
+#define _EXT_SUPPORTEDRATES_IE_ 50
+
+#define _HT_CAPABILITY_IE_ 45
+#define _HT_EXTRA_INFO_IE_ 61
+#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */
+
+#define _VENDOR_SPECIFIC_IE_ 221
+
+#define _RESERVED47_ 47
+
+
+/* ---------------------------------------------------------------------------
+ Below is the fixed elements...
+-----------------------------------------------------------------------------*/
+#define _AUTH_ALGM_NUM_ 2
+#define _AUTH_SEQ_NUM_ 2
+#define _BEACON_ITERVAL_ 2
+#define _CAPABILITY_ 2
+#define _CURRENT_APADDR_ 6
+#define _LISTEN_INTERVAL_ 2
+#define _RSON_CODE_ 2
+#define _ASOC_ID_ 2
+#define _STATUS_CODE_ 2
+#define _TIMESTAMP_ 8
+
+#define AUTH_ODD_TO 0
+#define AUTH_EVEN_TO 1
+
+#define WLAN_ETHCONV_ENCAP 1
+#define WLAN_ETHCONV_RFC1042 2
+#define WLAN_ETHCONV_8021h 3
+
+#define cap_ESS BIT(0)
+#define cap_IBSS BIT(1)
+#define cap_CFPollable BIT(2)
+#define cap_CFRequest BIT(3)
+#define cap_Privacy BIT(4)
+#define cap_ShortPremble BIT(5)
+
+/*-----------------------------------------------------------------------------
+ Below is the definition for 802.11i / 802.1x
+------------------------------------------------------------------------------*/
+#define _IEEE8021X_MGT_ 1 /*WPA */
+#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */
+
+/*-----------------------------------------------------------------------------
+ Below is the definition for WMM
+------------------------------------------------------------------------------*/
+#define _WMM_IE_Length_ 7 /* for WMM STA */
+#define _WMM_Para_Element_Length_ 24
+
+
+/*-----------------------------------------------------------------------------
+ Below is the definition for 802.11n
+------------------------------------------------------------------------------*/
+
+/* block-ack parameters */
+#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
+#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
+#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
+#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
+#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
+
+#define SetOrderBit(pbuf) \
+ do { \
+ *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \
+ } while (0)
+
+#define GetOrderBit(pbuf) (((*(unsigned short *)(pbuf)) & \
+ le16_to_cpu(_ORDER_)) != 0)
+
+
+/**
+ * struct ieee80211_bar - HT Block Ack Request
+ *
+ * This structure refers to "HT BlockAckReq" as
+ * described in 802.11n draft section 7.2.1.7.1
+ */
+struct ieee80211_bar {
+ unsigned short frame_control;
+ unsigned short duration;
+ unsigned char ra[6];
+ unsigned char ta[6];
+ unsigned short control;
+ unsigned short start_seq_num;
+} __attribute__((packed));
+
+/* 802.11 BAR control masks */
+#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000
+#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004
+
+
+ /**
+ * struct ieee80211_ht_cap - HT capabilities
+ *
+ * This structure refers to "HT capabilities element" as
+ * described in 802.11n draft section 7.3.2.52
+ */
+
+struct ieee80211_ht_cap {
+ unsigned short cap_info;
+ unsigned char ampdu_params_info;
+ unsigned char supp_mcs_set[16];
+ unsigned short extended_ht_cap_info;
+ unsigned int tx_BF_cap_info;
+ unsigned char antenna_selection_info;
+} __attribute__ ((packed));
+
+/**
+ * struct ieee80211_ht_cap - HT additional information
+ *
+ * This structure refers to "HT information element" as
+ * described in 802.11n draft section 7.3.2.53
+ */
+struct ieee80211_ht_addt_info {
+ unsigned char control_chan;
+ unsigned char ht_param;
+ unsigned short operation_mode;
+ unsigned short stbc_param;
+ unsigned char basic_set[16];
+} __attribute__ ((packed));
+
+/* 802.11n HT capabilities masks */
+#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
+#define IEEE80211_HT_CAP_SM_PS 0x000C
+#define IEEE80211_HT_CAP_GRN_FLD 0x0010
+#define IEEE80211_HT_CAP_SGI_20 0x0020
+#define IEEE80211_HT_CAP_SGI_40 0x0040
+#define IEEE80211_HT_CAP_TX_STBC 0x0080
+#define IEEE80211_HT_CAP_DELAY_BA 0x0400
+#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
+#define IEEE80211_HT_CAP_DSSSCCK40 0x1000
+/* 802.11n HT capability AMPDU settings */
+#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
+#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
+/* 802.11n HT capability MSC set */
+#define IEEE80211_SUPP_MCS_SET_UEQM 4
+#define IEEE80211_HT_CAP_MAX_STREAMS 4
+#define IEEE80211_SUPP_MCS_SET_LEN 10
+/* maximum streams the spec allows */
+#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01
+#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02
+#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C
+#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10
+/* 802.11n HT IE masks */
+#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
+#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00
+#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01
+#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03
+#define IEEE80211_HT_IE_CHA_WIDTH 0x04
+#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
+#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
+#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
+
+/* block-ack parameters */
+#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
+#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
+#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFA0
+#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
+#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
+
+/*
+ * A-PMDU buffer sizes
+ * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
+ */
+#define IEEE80211_MIN_AMPDU_BUF 0x8
+#define IEEE80211_MAX_AMPDU_BUF 0x40
+
+
+/* Spatial Multiplexing Power Save Modes */
+#define WLAN_HT_CAP_SM_PS_STATIC 0
+#define WLAN_HT_CAP_SM_PS_DYNAMIC 1
+#define WLAN_HT_CAP_SM_PS_INVALID 2
+#define WLAN_HT_CAP_SM_PS_DISABLED 3
+
+#endif /* _WIFI_H_ */
+
diff --git a/drivers/staging/rtl8712/wlan_bssdef.h b/drivers/staging/rtl8712/wlan_bssdef.h
new file mode 100644
index 000000000000..6d9295270f83
--- /dev/null
+++ b/drivers/staging/rtl8712/wlan_bssdef.h
@@ -0,0 +1,242 @@
+#ifndef __WLAN_BSSDEF_H__
+#define __WLAN_BSSDEF_H__
+
+#define MAX_IE_SZ 768
+
+#define NDIS_802_11_LENGTH_SSID 32
+#define NDIS_802_11_LENGTH_RATES 8
+#define NDIS_802_11_LENGTH_RATES_EX 16
+
+/* Set of 8 data rates*/
+typedef unsigned char NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];
+/* Set of 16 data rates */
+typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];
+
+struct ndis_802_11_ssid {
+ u32 SsidLength;
+ u8 Ssid[32];
+};
+
+enum NDIS_802_11_NETWORK_TYPE {
+ Ndis802_11FH,
+ Ndis802_11DS,
+ Ndis802_11OFDM5,
+ Ndis802_11OFDM24,
+ Ndis802_11NetworkTypeMax /* not a real type, defined as an upper bound */
+};
+
+struct NDIS_802_11_CONFIGURATION_FH {
+ u32 Length; /* Length of structure */
+ u32 HopPattern; /* As defined by 802.11, MSB set */
+ u32 HopSet; /* to one if non-802.11 */
+ u32 DwellTime; /* units are Kusec */
+};
+
+/*
+ FW will only save the channel number in DSConfig.
+ ODI Handler will convert the channel number to freq. number.
+*/
+struct NDIS_802_11_CONFIGURATION {
+ u32 Length; /* Length of structure */
+ u32 BeaconPeriod; /* units are Kusec */
+ u32 ATIMWindow; /* units are Kusec */
+ u32 DSConfig; /* Frequency, units are kHz */
+ struct NDIS_802_11_CONFIGURATION_FH FHConfig;
+};
+
+enum NDIS_802_11_NETWORK_INFRASTRUCTURE {
+ Ndis802_11IBSS,
+ Ndis802_11Infrastructure,
+ Ndis802_11AutoUnknown,
+ Ndis802_11InfrastructureMax, /* Not a real value, defined as upper bound */
+ Ndis802_11APMode
+};
+
+struct NDIS_802_11_FIXED_IEs {
+ u8 Timestamp[8];
+ u16 BeaconInterval;
+ u16 Capabilities;
+};
+
+/*
+ * Length is the 4 bytes multiples of the sume of
+ * 6 * sizeof (unsigned char) + 2 + sizeof (ndis_802_11_ssid) + sizeof (u32)
+ * + sizeof (s32) + sizeof (NDIS_802_11_NETWORK_TYPE)
+ * + sizeof (struct NDIS_802_11_CONFIGURATION)
+ * + sizeof (NDIS_802_11_RATES_EX) + IELength
+
+ * Except the IELength, all other fields are fixed length. Therefore, we can
+ * define a macro to present the partial sum.
+ */
+
+struct ndis_wlan_bssid_ex {
+ u32 Length;
+ unsigned char MacAddress[6];
+ u8 Reserved[2];
+ struct ndis_802_11_ssid Ssid;
+ u32 Privacy;
+ s32 Rssi;
+ enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
+ struct NDIS_802_11_CONFIGURATION Configuration;
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
+ NDIS_802_11_RATES_EX SupportedRates;
+ u32 IELength;
+/*(timestamp, beacon interval, and capability information) */
+ u8 IEs[MAX_IE_SZ];
+};
+
+enum NDIS_802_11_AUTHENTICATION_MODE {
+ Ndis802_11AuthModeOpen,
+ Ndis802_11AuthModeShared,
+ Ndis802_11AuthModeAutoSwitch,
+ Ndis802_11AuthModeWPA,
+ Ndis802_11AuthModeWPAPSK,
+ Ndis802_11AuthModeWPANone,
+ Ndis802_11AuthModeMax /* Not a real mode, defined as upper bound */
+};
+
+enum {
+ Ndis802_11WEPEnabled,
+ Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
+ Ndis802_11WEPDisabled,
+ Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
+ Ndis802_11WEPKeyAbsent,
+ Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
+ Ndis802_11WEPNotSupported,
+ Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
+ Ndis802_11Encryption2Enabled,
+ Ndis802_11Encryption2KeyAbsent,
+ Ndis802_11Encryption3Enabled,
+ Ndis802_11Encryption3KeyAbsent
+};
+
+#define NDIS_802_11_AI_REQFI_CAPABILITIES 1
+#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2
+#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4
+
+#define NDIS_802_11_AI_RESFI_CAPABILITIES 1
+#define NDIS_802_11_AI_RESFI_STATUSCODE 2
+#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4
+
+struct NDIS_802_11_AI_REQFI {
+ u16 Capabilities;
+ u16 ListenInterval;
+ unsigned char CurrentAPAddress[6];
+};
+
+struct NDIS_802_11_AI_RESFI {
+ u16 Capabilities;
+ u16 StatusCode;
+ u16 AssociationId;
+};
+
+struct NDIS_802_11_ASSOCIATION_INFORMATION {
+ u32 Length;
+ u16 AvailableRequestFixedIEs;
+ struct NDIS_802_11_AI_REQFI RequestFixedIEs;
+ u32 RequestIELength;
+ u32 OffsetRequestIEs;
+ u16 AvailableResponseFixedIEs;
+ struct NDIS_802_11_AI_RESFI ResponseFixedIEs;
+ u32 ResponseIELength;
+ u32 OffsetResponseIEs;
+};
+
+/* Key mapping keys require a BSSID*/
+struct NDIS_802_11_KEY {
+ u32 Length; /* Length of this structure */
+ u32 KeyIndex;
+ u32 KeyLength; /* length of key in bytes */
+ unsigned char BSSID[6];
+ unsigned long long KeyRSC;
+ u8 KeyMaterial[32]; /* variable length */
+};
+
+struct NDIS_802_11_REMOVE_KEY {
+ u32 Length; /* Length of this structure */
+ u32 KeyIndex;
+ unsigned char BSSID[6];
+};
+
+struct NDIS_802_11_WEP {
+ u32 Length; /* Length of this structure */
+ u32 KeyIndex; /* 0 is the per-client key,
+ * 1-N are the global keys */
+ u32 KeyLength; /* length of key in bytes */
+ u8 KeyMaterial[16];/* variable length depending on above field */
+};
+
+/* mask for authentication/integrity fields */
+#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f
+#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01
+#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02
+#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
+#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E
+
+/* MIC check time, 60 seconds. */
+#define MIC_CHECK_TIME 60000000
+
+#ifndef Ndis802_11APMode
+#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1)
+#endif
+
+struct wlan_network {
+ struct list_head list;
+ int network_type; /*refer to ieee80211.h for WIRELESS_11A/B/G */
+ int fixed; /* set to fixed when not to be removed asi
+ * site-surveying */
+ unsigned int last_scanned; /*timestamp for the network */
+ int aid; /*will only be valid when a BSS is joined. */
+ int join_res;
+ struct ndis_wlan_bssid_ex network; /*must be the last item */
+};
+
+enum VRTL_CARRIER_SENSE {
+ DISABLE_VCS,
+ ENABLE_VCS,
+ AUTO_VCS
+};
+
+enum VCS_TYPE {
+ NONE_VCS,
+ RTS_CTS,
+ CTS_TO_SELF
+};
+
+#define PWR_CAM 0
+#define PWR_MINPS 1
+#define PWR_MAXPS 2
+#define PWR_UAPSD 3
+#define PWR_VOIP 4
+
+enum UAPSD_MAX_SP {
+ NO_LIMIT,
+ TWO_MSDU,
+ FOUR_MSDU,
+ SIX_MSDU
+};
+
+#define NUM_PRE_AUTH_KEY 16
+#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY
+
+/*
+ * WPA2
+ */
+struct wlan_bssid_ex {
+ u32 Length;
+ unsigned char MacAddress[6];
+ u8 Reserved[2];
+ struct ndis_802_11_ssid Ssid;
+ u32 Privacy;
+ s32 Rssi;
+ enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse;
+ struct NDIS_802_11_CONFIGURATION Configuration;
+ enum NDIS_802_11_NETWORK_INFRASTRUCTURE InfrastructureMode;
+ NDIS_802_11_RATES_EX SupportedRates;
+ u32 IELength;
+ u8 IEs[MAX_IE_SZ]; /* (timestamp, beacon interval, and capability
+ * information) */
+};
+
+#endif /* #ifndef WLAN_BSSDEF_H_ */
+
diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c
new file mode 100644
index 000000000000..7dea8b5b7e75
--- /dev/null
+++ b/drivers/staging/rtl8712/xmit_linux.c
@@ -0,0 +1,182 @@
+/******************************************************************************
+ * xmit_linux.c
+ *
+ * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
+ * Linux device driver for RTL8192SU
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ *
+ * Modifications for inclusion into the Linux staging tree are
+ * Copyright(c) 2010 Larry Finger. All rights reserved.
+ *
+ * Contact information:
+ * WLAN FAE <wlanfae@realtek.com>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ *
+ ******************************************************************************/
+
+#define _XMIT_OSDEP_C_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+
+#include "if_ether.h"
+#include "ip.h"
+#include "rtl871x_byteorder.h"
+#include "wifi.h"
+#include "mlme_osdep.h"
+#include "xmit_osdep.h"
+#include "osdep_intf.h"
+
+static uint remainder_len(struct pkt_file *pfile)
+{
+ /* Kovich: Need to extend the buf_len to 64 bit ?(unsigned long long) */
+ return (uint)(pfile->buf_len - ((addr_t)(pfile->cur_addr) -
+ (addr_t)(pfile->buf_start)));
+}
+
+void _r8712_open_pktfile(_pkt *pktptr, struct pkt_file *pfile)
+{
+ pfile->pkt = pktptr;
+ pfile->cur_addr = pfile->buf_start = pktptr->data;
+ pfile->pkt_len = pfile->buf_len = pktptr->len;
+ pfile->cur_buffer = pfile->buf_start ;
+}
+
+uint _r8712_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen)
+{
+ uint len;
+
+ len = remainder_len(pfile);
+ len = (rlen > len) ? len : rlen;
+ if (rmem)
+ skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len,
+ rmem, len);
+ pfile->cur_addr += len;
+ pfile->pkt_len -= len;
+ return len;
+}
+
+sint r8712_endofpktfile(struct pkt_file *pfile)
+{
+ if (pfile->pkt_len == 0)
+ return true;
+ else
+ return false;
+}
+
+
+void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
+{
+ int i;
+ struct ethhdr etherhdr;
+ struct iphdr ip_hdr;
+ u16 UserPriority = 0;
+
+ _r8712_open_pktfile(ppktfile->pkt, ppktfile);
+ _r8712_pktfile_read(ppktfile, (unsigned char *)&etherhdr, ETH_HLEN);
+
+ /* get UserPriority from IP hdr*/
+ if (pattrib->ether_type == 0x0800) {
+ i = _r8712_pktfile_read(ppktfile, (u8 *)&ip_hdr,
+ sizeof(ip_hdr));
+ /*UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3 ;*/
+ UserPriority = ip_hdr.tos >> 5;
+ } else {
+ /* "When priority processing of data frames is supported,
+ * a STA's SME should send EAPOL-Key frames at the highest
+ * priority." */
+
+ if (pattrib->ether_type == 0x888e)
+ UserPriority = 7;
+ }
+ pattrib->priority = UserPriority;
+ pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN;
+ pattrib->subtype = WIFI_QOS_DATA_TYPE;
+}
+
+int r8712_xmit_resource_alloc(struct _adapter *padapter,
+ struct xmit_buf *pxmitbuf)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ pxmitbuf->pxmit_urb[i] = _usb_alloc_urb(0, GFP_KERNEL);
+ if (pxmitbuf->pxmit_urb[i] == NULL) {
+ printk(KERN_ERR "r8712u: pxmitbuf->pxmit_urb[i]"
+ " == NULL");
+ return _FAIL;
+ }
+ }
+ return _SUCCESS;
+}
+
+void r8712_xmit_resource_free(struct _adapter *padapter,
+ struct xmit_buf *pxmitbuf)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ if (pxmitbuf->pxmit_urb[i]) {
+ usb_kill_urb(pxmitbuf->pxmit_urb[i]);
+ usb_free_urb(pxmitbuf->pxmit_urb[i]);
+ }
+ }
+}
+
+void r8712_xmit_complete(struct _adapter *padapter, struct xmit_frame *pxframe)
+{
+ if (pxframe->pkt)
+ dev_kfree_skb_any(pxframe->pkt);
+ pxframe->pkt = NULL;
+}
+
+int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev)
+{
+ struct xmit_frame *pxmitframe = NULL;
+ struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev);
+ struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
+ int ret = 0;
+
+ if (r8712_if_up(padapter) == false) {
+ ret = 0;
+ goto _xmit_entry_drop;
+ }
+ pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
+ if (pxmitframe == NULL) {
+ ret = 0;
+ goto _xmit_entry_drop;
+ }
+ if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) {
+ ret = 0;
+ goto _xmit_entry_drop;
+ }
+ padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
+ pxmitframe->pkt = pkt;
+ if (r8712_pre_xmit(padapter, pxmitframe) == true) {
+ /*dump xmitframe directly or drop xframe*/
+ dev_kfree_skb_any(pkt);
+ pxmitframe->pkt = NULL;
+ }
+ pxmitpriv->tx_pkts++;
+ pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz;
+ return ret;
+_xmit_entry_drop:
+ if (pxmitframe)
+ r8712_free_xmitframe(pxmitpriv, pxmitframe);
+ pxmitpriv->tx_drop++;
+ dev_kfree_skb_any(pkt);
+ return ret;
+}
diff --git a/drivers/staging/rtl8712/xmit_osdep.h b/drivers/staging/rtl8712/xmit_osdep.h
new file mode 100644
index 000000000000..ca439378953d
--- /dev/null
+++ b/drivers/staging/rtl8712/xmit_osdep.h
@@ -0,0 +1,38 @@
+#ifndef __XMIT_OSDEP_H_
+#define __XMIT_OSDEP_H_
+
+#include "osdep_service.h"
+#include "drv_types.h"
+
+struct pkt_file {
+ _pkt *pkt;
+ u32 pkt_len; /*the remainder length of the open_file*/
+ _buffer *cur_buffer;
+ u8 *buf_start;
+ u8 *cur_addr;
+ u32 buf_len;
+};
+
+#define NR_XMITFRAME 256
+
+struct xmit_priv;
+struct pkt_attrib;
+struct sta_xmit_priv;
+struct xmit_frame;
+struct xmit_buf;
+
+int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev);
+int r8712_xmit_resource_alloc(struct _adapter *padapter,
+ struct xmit_buf *pxmitbuf);
+void r8712_xmit_resource_free(struct _adapter *padapter,
+ struct xmit_buf *pxmitbuf);
+
+void r8712_set_qos(struct pkt_file *ppktfile,
+ struct pkt_attrib *pattrib);
+void _r8712_open_pktfile(_pkt *pktptr, struct pkt_file *pfile);
+uint _r8712_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen);
+sint r8712_endofpktfile(struct pkt_file *pfile);
+void r8712_xmit_complete(struct _adapter *padapter,
+ struct xmit_frame *pxframe);
+
+#endif
diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h b/drivers/staging/sbe-2t3e3/2t3e3.h
new file mode 100644
index 000000000000..fe9f086b6e7a
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/2t3e3.h
@@ -0,0 +1,894 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#ifndef T3E3_H
+#define T3E3_H
+
+#include <linux/hdlc.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/io.h>
+#include "ctrl.h"
+
+/**************************************************************
+ * 21143
+ **************************************************************/
+
+/* CSR */
+#define SBE_2T3E3_21143_REG_BUS_MODE 0
+#define SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND 1
+#define SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND 2
+#define SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS 3
+#define SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS 4
+#define SBE_2T3E3_21143_REG_STATUS 5
+#define SBE_2T3E3_21143_REG_OPERATION_MODE 6
+#define SBE_2T3E3_21143_REG_INTERRUPT_ENABLE 7
+#define SBE_2T3E3_21143_REG_MISSED_FRAMES_AND_OVERFLOW_COUNTER 8
+#define SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT 9
+#define SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS 10
+#define SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL 11
+#define SBE_2T3E3_21143_REG_SIA_STATUS 12
+#define SBE_2T3E3_21143_REG_SIA_CONNECTIVITY 13
+#define SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE 14
+#define SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT 15
+#define SBE_2T3E3_21143_REG_MAX 16
+
+/* CSR0 - BUS_MODE */
+#define SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE 0x01000000
+#define SBE_2T3E3_21143_VAL_READ_LINE_ENABLE 0x00800000
+#define SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE 0x00200000
+#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us 0x00020000
+#define SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_DISABLED 0x00000000
+#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32 0x0000c000
+#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16 0x00008000
+#define SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8 0x00004000
+#define SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR 0x00000002
+#define SBE_2T3E3_21143_VAL_SOFTWARE_RESET 0x00000001
+
+/* CSR5 - STATUS */
+#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_INTERRUPT 0x04000000
+#define SBE_2T3E3_21143_VAL_ERROR_BITS 0x03800000
+#define SBE_2T3E3_21143_VAL_PARITY_ERROR 0x00000000
+#define SBE_2T3E3_21143_VAL_MASTER_ABORT 0x00800000
+#define SBE_2T3E3_21143_VAL_TARGET_ABORT 0x01000000
+#define SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE 0x00700000
+#define SBE_2T3E3_21143_VAL_TX_STOPPED 0x00000000
+#define SBE_2T3E3_21143_VAL_TX_SUSPENDED 0x00600000
+#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE 0x000e0000
+#define SBE_2T3E3_21143_VAL_RX_STOPPED 0x00000000
+#define SBE_2T3E3_21143_VAL_RX_SUSPENDED 0x000a0000
+#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY 0x00010000
+#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY 0x00008000
+#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT 0x00004000
+#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR 0x00002000
+#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_EXPIRED 0x00000800
+#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT 0x00000400
+#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT 0x00000200
+#define SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED 0x00000100
+#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE 0x00000080
+#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT 0x00000040
+#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW 0x00000020
+#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT 0x00000008
+#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE 0x00000004
+#define SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED 0x00000002
+#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT 0x00000001
+
+/* CSR6 - OPERATION_MODE */
+#define SBE_2T3E3_21143_VAL_SPECIAL_CAPTURE_EFFECT_ENABLE 0x80000000
+#define SBE_2T3E3_21143_VAL_RECEIVE_ALL 0x40000000
+#define SBE_2T3E3_21143_VAL_MUST_BE_ONE 0x02000000
+#define SBE_2T3E3_21143_VAL_SCRAMBLER_MODE 0x01000000
+#define SBE_2T3E3_21143_VAL_PCS_FUNCTION 0x00800000
+#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_10Mbs 0x00400000
+#define SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs 0x00000000
+#define SBE_2T3E3_21143_VAL_STORE_AND_FORWARD 0x00200000
+#define SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE 0x00080000
+#define SBE_2T3E3_21143_VAL_PORT_SELECT 0x00040000
+#define SBE_2T3E3_21143_VAL_CAPTURE_EFFECT_ENABLE 0x00020000
+#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS 0x0000c000
+#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1 0x00000000
+#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2 0x00004000
+#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3 0x00008000
+#define SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4 0x0000c000
+#define SBE_2T3E3_21143_VAL_TRANSMISSION_START 0x00002000
+#define SBE_2T3E3_21143_VAL_OPERATING_MODE 0x00000c00
+#define SBE_2T3E3_21143_VAL_LOOPBACK_OFF 0x00000000
+#define SBE_2T3E3_21143_VAL_LOOPBACK_EXTERNAL 0x00000800
+#define SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL 0x00000400
+#define SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE 0x00000200
+#define SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST 0x00000080
+#define SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE 0x00000040
+#define SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES 0x00000008
+#define SBE_2T3E3_21143_VAL_RECEIVE_START 0x00000002
+
+/* CSR7 - INTERRUPT_ENABLE */
+#define SBE_2T3E3_21143_VAL_LINK_CHANGED_ENABLE 0x08000000
+#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_PORT_ENABLE 0x04000000
+#define SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE 0x00010000
+#define SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE 0x00008000
+#define SBE_2T3E3_21143_VAL_EARLY_RECEIVE_INTERRUPT_ENABLE 0x00004000
+#define SBE_2T3E3_21143_VAL_FATAL_BUS_ERROR_ENABLE 0x00002000
+#define SBE_2T3E3_21143_VAL_LINK_FAIL_ENABLE 0x00001000
+#define SBE_2T3E3_21143_VAL_GENERAL_PURPOSE_TIMER_ENABLE 0x00000800
+#define SBE_2T3E3_21143_VAL_EARLY_TRANSMIT_INTERRUPT_ENABLE 0x00000400
+#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_TIMEOUT_ENABLE 0x00000200
+#define SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE 0x00000100
+#define SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE 0x00000080
+#define SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE 0x00000040
+#define SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE 0x00000020
+#define SBE_2T3E3_21143_VAL_TRANSMIT_JABBER_TIMEOUT_ENABLE 0x00000008
+#define SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE 0x00000004
+#define SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE 0x00000002
+#define SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE 0x00000001
+
+/* CSR8 - MISSED_FRAMES_AND_OVERFLOW_COUNTER */
+#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER_OVERFLOW 0x10000000
+#define SBE_2T3E3_21143_VAL_OVERFLOW_COUNTER 0x0ffe0000
+#define SBE_2T3E3_21143_VAL_MISSED_FRAME_OVERFLOW 0x00010000
+#define SBE_2T3E3_21143_VAL_MISSED_FRAMES_COUNTER 0x0000ffff
+
+/* CSR9 - BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT */
+#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_IN 0x00080000
+#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_READ_MODE 0x00040000
+#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_DATA_OUT 0x00020000
+#define SBE_2T3E3_21143_VAL_MII_MANAGEMENT_CLOCK 0x00010000
+#define SBE_2T3E3_21143_VAL_READ_OPERATION 0x00004000
+#define SBE_2T3E3_21143_VAL_WRITE_OPERATION 0x00002000
+#define SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT 0x00001000
+#define SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT 0x00000800
+#define SBE_2T3E3_21143_VAL_BOOT_ROM_DATA 0x000000ff
+#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT 0x00000008
+#define SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_IN 0x00000004
+#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK 0x00000002
+#define SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT 0x00000001
+
+/* CSR11 - GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL */
+#define SBE_2T3E3_21143_VAL_CYCLE_SIZE 0x80000000
+#define SBE_2T3E3_21143_VAL_TRANSMIT_TIMER 0x78000000
+#define SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS 0x07000000
+#define SBE_2T3E3_21143_VAL_RECEIVE_TIMER 0x00f00000
+#define SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS 0x000e0000
+#define SBE_2T3E3_21143_VAL_CONTINUOUS_MODE 0x00010000
+#define SBE_2T3E3_21143_VAL_TIMER_VALUE 0x0000ffff
+
+/* CSR12 - SIA_STATUS */
+#define SBE_2T3E3_21143_VAL_10BASE_T_RECEIVE_PORT_ACTIVITY 0x00000200
+#define SBE_2T3E3_21143_VAL_AUI_RECEIVE_PORT_ACTIVITY 0x00000100
+#define SBE_2T3E3_21143_VAL_10Mbs_LINK_STATUS 0x00000004
+#define SBE_2T3E3_21143_VAL_100Mbs_LINK_STATUS 0x00000002
+#define SBE_2T3E3_21143_VAL_MII_RECEIVE_PORT_ACTIVITY 0x00000001
+
+/* CSR13 - SIA_CONNECTIVITY */
+#define SBE_2T3E3_21143_VAL_10BASE_T_OR_AUI 0x00000008
+#define SBE_2T3E3_21143_VAL_SIA_RESET 0x00000001
+
+/* CSR14 - SIA_TRANSMIT_AND_RECEIVE */
+#define SBE_2T3E3_21143_VAL_100BASE_TX_FULL_DUPLEX 0x00020000
+#define SBE_2T3E3_21143_VAL_COLLISION_DETECT_ENABLE 0x00000400
+#define SBE_2T3E3_21143_VAL_COLLISION_SQUELCH_ENABLE 0x00000200
+#define SBE_2T3E3_21143_VAL_RECEIVE_SQUELCH_ENABLE 0x00000100
+#define SBE_2T3E3_21143_VAL_LINK_PULSE_SEND_ENABLE 0x00000004
+#define SBE_2T3E3_21143_VAL_ENCODER_ENABLE 0x00000001
+
+/* CSR15 - SIA_AND_GENERAL_PURPOSE_PORT */
+#define SBE_2T3E3_21143_VAL_RECEIVE_WATCHDOG_DISABLE 0x00000010
+#define SBE_2T3E3_21143_VAL_AUI_BNC_MODE 0x00000008
+#define SBE_2T3E3_21143_VAL_HOST_UNJAB 0x00000002
+#define SBE_2T3E3_21143_VAL_JABBER_DISABLE 0x00000001
+
+/**************************************************************
+ * CPLD
+ **************************************************************/
+
+/* reg_map indexes */
+#define SBE_2T3E3_CPLD_REG_PCRA 0
+#define SBE_2T3E3_CPLD_REG_PCRB 1
+#define SBE_2T3E3_CPLD_REG_PLCR 2
+#define SBE_2T3E3_CPLD_REG_PLTR 3
+#define SBE_2T3E3_CPLD_REG_PPFR 4
+#define SBE_2T3E3_CPLD_REG_BOARD_ID 5
+#define SBE_2T3E3_CPLD_REG_FPGA_VERSION 6
+#define SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS 7
+#define SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT 8
+#define SBE_2T3E3_CPLD_REG_STATIC_RESET 9
+#define SBE_2T3E3_CPLD_REG_PULSE_RESET 10
+#define SBE_2T3E3_CPLD_REG_FPGA_RECONFIGURATION 11
+#define SBE_2T3E3_CPLD_REG_LEDR 12
+#define SBE_2T3E3_CPLD_REG_PICSR 13
+#define SBE_2T3E3_CPLD_REG_PIER 14
+#define SBE_2T3E3_CPLD_REG_PCRC 15
+#define SBE_2T3E3_CPLD_REG_PBWF 16
+#define SBE_2T3E3_CPLD_REG_PBWL 17
+
+#define SBE_2T3E3_CPLD_REG_MAX 18
+
+/**********/
+
+/* val_map indexes */
+#define SBE_2T3E3_CPLD_VAL_LIU_SELECT 0
+#define SBE_2T3E3_CPLD_VAL_DAC_SELECT 1
+#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE 2
+#define SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET 3
+
+/* PCRA */
+#define SBE_2T3E3_CPLD_VAL_CRC32 0x40
+#define SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE 0x20
+#define SBE_2T3E3_CPLD_VAL_REAR_PANEL 0x10
+#define SBE_2T3E3_CPLD_VAL_RAW_MODE 0x08
+#define SBE_2T3E3_CPLD_VAL_ALT 0x04
+#define SBE_2T3E3_CPLD_VAL_LOOP_TIMING 0x02
+#define SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3 0x01
+
+/* PCRB */
+#define SBE_2T3E3_CPLD_VAL_PAD_COUNT 0x30
+#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_1 0x00
+#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_2 0x10
+#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_3 0x20
+#define SBE_2T3E3_CPLD_VAL_PAD_COUNT_4 0x30
+#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE 0x02
+#define SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE 0x01
+
+/* PCRC */
+#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE 0x00
+#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0 0x01
+#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1 0x11
+#define SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2 0x21
+
+/* PLTR */
+#define SBE_2T3E3_CPLD_VAL_LCV_COUNTER 0xff
+
+/* SCSR */
+#define SBE_2T3E3_CPLD_VAL_EEPROM_SELECT 0x10
+
+/* PICSR */
+#define SBE_2T3E3_CPLD_VAL_LOSS_OF_SIGNAL_THRESHOLD_LEVEL_1 0x80
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE 0x40
+#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED 0x20
+#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED 0x10
+#define SBE_2T3E3_CPLD_VAL_LCV_LIMIT_EXCEEDED 0x08
+#define SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED 0x04
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED 0x02
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED 0x01
+
+/* PIER */
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOS_CHANGE_ENABLE 0x40
+#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE 0x20
+#define SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE 0x10
+#define SBE_2T3E3_CPLD_VAL_LCV_INTERRUPT_ENABLE 0x08
+#define SBE_2T3E3_CPLD_VAL_DMO_ENABLE 0x04
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_ENABLE 0x02
+#define SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_ENABLE 0x01
+
+/**************************************************************
+ * Framer
+ **************************************************************/
+
+/* reg_map indexes */
+/* common */
+#define SBE_2T3E3_FRAMER_REG_OPERATING_MODE 0
+#define SBE_2T3E3_FRAMER_REG_IO_CONTROL 1
+#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE 2
+#define SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS 3
+#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB 28
+#define SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_LSB 29
+#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB 30
+#define SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB 31
+#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB 32
+#define SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_LSB 33
+#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB 34
+#define SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_LSB 35
+#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB 36
+#define SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_LSB 37
+#define SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER 38
+#define SBE_2T3E3_FRAMER_REG_ONE_SECOND_ERROR_STATUS 39
+#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_MSB 40
+#define SBE_2T3E3_FRAMER_REG_LCV_ONE_SECOND_ACCUMULATOR_LSB 41
+#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB 42
+#define SBE_2T3E3_FRAMER_REG_FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB 43
+#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB 44
+#define SBE_2T3E3_FRAMER_REG_FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB 45
+#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_DRIVE 46
+#define SBE_2T3E3_FRAMER_REG_LINE_INTERFACE_SCAN 47
+
+/* T3 */
+#define SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS 4
+#define SBE_2T3E3_FRAMER_REG_T3_RX_STATUS 5
+#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE 6
+#define SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS 7
+#define SBE_2T3E3_FRAMER_REG_T3_RX_SYNC_DETECT_ENABLE 8
+#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC 10
+#define SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS 11
+#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL 12
+#define SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_STATUS 13
+#define SBE_2T3E3_FRAMER_REG_T3_TX_CONFIGURATION 16
+#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS 17
+#define SBE_2T3E3_FRAMER_REG_T3_TX_FEAC 18
+#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_CONFIGURATION 19
+#define SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS 20
+#define SBE_2T3E3_FRAMER_REG_T3_TX_MBIT_MASK 21
+#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK 22
+#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_2 23
+#define SBE_2T3E3_FRAMER_REG_T3_TX_FBIT_MASK_3 24
+
+/* E3 */
+#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_1 4
+#define SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2 5
+#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1 6
+#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2 7
+#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1 8
+#define SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2 9
+#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL 12
+#define SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_STATUS 13
+#define SBE_2T3E3_FRAMER_REG_E3_RX_NR_BYTE 14
+#define SBE_2T3E3_FRAMER_REG_E3_RX_SERVICE_BITS 14
+#define SBE_2T3E3_FRAMER_REG_E3_RX_GC_BYTE 15
+#define SBE_2T3E3_FRAMER_REG_E3_TX_CONFIGURATION 16
+#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_CONFIGURATION 19
+#define SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS 19
+#define SBE_2T3E3_FRAMER_REG_E3_TX_GC_BYTE 21
+#define SBE_2T3E3_FRAMER_REG_E3_TX_SERVICE_BITS 21
+#define SBE_2T3E3_FRAMER_REG_E3_TX_MA_BYTE 22
+#define SBE_2T3E3_FRAMER_REG_E3_TX_NR_BYTE 23
+#define SBE_2T3E3_FRAMER_REG_E3_TX_FA1_ERROR_MASK 25
+#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_UPPER 25
+#define SBE_2T3E3_FRAMER_REG_E3_TX_FA2_ERROR_MASK 26
+#define SBE_2T3E3_FRAMER_REG_E3_TX_FAS_ERROR_MASK_LOWER 26
+#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP8_MASK 27
+#define SBE_2T3E3_FRAMER_REG_E3_TX_BIP4_MASK 27
+
+#define SBE_2T3E3_FRAMER_REG_MAX 48
+
+/**********/
+
+/* OPERATING_MODE */
+#define SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE 0x80
+#define SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT 0x40
+#define SBE_2T3E3_FRAMER_VAL_INTERNAL_LOS_ENABLE 0x20
+#define SBE_2T3E3_FRAMER_VAL_RESET 0x10
+#define SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET 0x08
+#define SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT 0x04
+#define SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK 0x03
+#define SBE_2T3E3_FRAMER_VAL_E3_G751 0x00
+#define SBE_2T3E3_FRAMER_VAL_E3_G832 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_CBIT 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_M13 0x44
+#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON 0x80
+#define SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF 0x00
+
+/* IO_CONTROL */
+#define SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK 0x80
+#define SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS 0x40
+#define SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK 0x20
+#define SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE 0x10
+#define SBE_2T3E3_FRAMER_VAL_UNIPOLAR 0x08
+#define SBE_2T3E3_FRAMER_VAL_TX_LINE_CLOCK_INVERT 0x04
+#define SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT 0x02
+#define SBE_2T3E3_FRAMER_VAL_REFRAME 0x01
+
+/* BLOCK_INTERRUPT_ENABLE */
+#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE 0x80
+#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_ENABLE 0x01
+
+/* BLOCK_INTERRUPT_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS 0x80
+#define SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS 0x02
+#define SBE_2T3E3_FRAMER_VAL_ONE_SECOND_INTERRUPT_STATUS 0x01
+
+/**********/
+
+/* T3_RX_CONFIGURATION_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS 0x80
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE 0x20
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FRAMING_ON_PARITY 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_F_SYNC_ALGO 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_M_SYNC_ALGO 0x01
+
+/* T3_RX_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE 0x07
+
+/* T3_RX_INTERRUPT_ENABLE */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE 0x80
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE 0x20
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE 0x01
+
+/* T3_RX_INTERRUPT_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_STATUS 0x80
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_STATUS 0x20
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_STATUS 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_STATUS 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_STATUS 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_STATUS 0x01
+
+/* T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_STATUS 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_STATUS 0x01
+
+/* T3_RX_LAPD_CONTROL */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_INTERRUPT_STATUS 0x01
+
+/* T3_RX_LAPD_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_ABORT 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_LAPD_TYPE 0x30
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_CR_TYPE 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FCS_ERROR 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_END_OF_MESSAGE 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_RX_FLAG_PRESENT 0x01
+
+/* T3_TX_CONFIGURATION */
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_YELLOW_ALARM 0x80
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_X_BIT 0x40
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_IDLE 0x20
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_AIS 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_LOS 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_LOS 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_OOF 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FERF_ON_AIS 0x01
+
+/* T3_TX_FEAC_CONFIGURATION_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_ENABLE 0x10
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_INTERRUPT_STATUS 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_GO 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_FEAC_BUSY 0x01
+
+/* T3_TX_LAPD_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_START 0x08
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_DL_BUSY 0x04
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_T3_TX_LAPD_INTERRUPT_STATUS 0x01
+
+/**********/
+
+/* E3_RX_CONFIGURATION_STATUS_1 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_TYPE 0xe0
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_ALGO 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK_ALGO 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_EXPECTED 0x07
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4 0x01
+
+/* E3_RX_CONFIGURATION_STATUS_2 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_ALGO 0x80
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF 0x40
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF 0x20
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_UNSTABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_T_MARK 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF 0x01
+
+/* E3_RX_INTERRUPT_ENABLE_1 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE 0x01
+
+/* E3_RX_INTERRUPT_ENABLE_2 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_ENABLE 0x40
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_ENABLE 0x01
+
+/* E3_RX_INTERRUPT_STATUS_1 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_STATUS 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_STATUS 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_STATUS 0x01
+
+/* E3_RX_INTERRUPT_STATUS_2 */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_TTB_CHANGE_INTERRUPT_STATUS 0x40
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_STATUS 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_STATUS 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP8_ERROR_INTERRUPT_STATUS 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_BIP4_ERROR_INTERRUPT_STATUS 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_STATUS 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_PAYLOAD_MISMATCH_INTERRUPT_STATUS 0x01
+
+/* E3_RX_LAPD_CONTROL */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_DL_FROM_NR 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_INTERRUPT_STATUS 0x01
+
+/* E3_RX_LAPD_STATUS */
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_ABORT 0x40
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_LAPD_TYPE 0x30
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_CR_TYPE 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FCS_ERROR 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_END_OF_MESSAGE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_RX_FLAG_PRESENT 0x01
+
+/* E3_TX_CONFIGURATION */
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_BIP4_ENABLE 0x80
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_A_SOURCE_SELECT 0x60
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_IN_NR 0x10
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_N_SOURCE_SELECT 0x18
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_AIS_ENABLE 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_LOS_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_MA_RX 0x01
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_FAS_SOURCE_SELECT 0x01
+
+/* E3_TX_LAPD_CONFIGURATION */
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_AUTO_RETRANSMIT 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_MESSAGE_LENGTH 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_ENABLE 0x01
+
+/* E3_TX_LAPD_STATUS_INTERRUPT */
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_START 0x08
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_DL_BUSY 0x04
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_ENABLE 0x02
+#define SBE_2T3E3_FRAMER_VAL_E3_TX_LAPD_INTERRUPT_STATUS 0x01
+
+
+
+
+
+
+/**************************************************************
+ * LIU
+ **************************************************************/
+
+/* reg_map indexes */
+#define SBE_2T3E3_LIU_REG_REG0 0
+#define SBE_2T3E3_LIU_REG_REG1 1
+#define SBE_2T3E3_LIU_REG_REG2 2
+#define SBE_2T3E3_LIU_REG_REG3 3
+#define SBE_2T3E3_LIU_REG_REG4 4
+
+#define SBE_2T3E3_LIU_REG_MAX 5
+
+/**********/
+
+/* REG0 */
+#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_LOCK_STATUS 0x10
+#define SBE_2T3E3_LIU_VAL_RECEIVE_LOSS_OF_SIGNAL_STATUS 0x08
+#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_STATUS 0x04
+#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_STATUS 0x02
+#define SBE_2T3E3_LIU_VAL_DMO_STATUS 0x01
+
+/* REG1 */
+#define SBE_2T3E3_LIU_VAL_TRANSMITTER_OFF 0x10
+#define SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES 0x08
+#define SBE_2T3E3_LIU_VAL_TRANSMIT_CLOCK_INVERT 0x04
+#define SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT 0x02
+#define SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA 0x01
+
+/* REG2 */
+#define SBE_2T3E3_LIU_VAL_DECODER_DISABLE 0x10
+#define SBE_2T3E3_LIU_VAL_ENCODER_DISABLE 0x08
+#define SBE_2T3E3_LIU_VAL_ANALOG_LOSS_OF_SIGNAL_DISABLE 0x04
+#define SBE_2T3E3_LIU_VAL_DIGITAL_LOSS_OF_SIGNAL_DISABLE 0x02
+#define SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE 0x01
+
+/* REG3 */
+#define SBE_2T3E3_LIU_VAL_RECEIVE_BINARY_DATA 0x10
+#define SBE_2T3E3_LIU_VAL_RECOVERED_DATA_MUTING 0x08
+#define SBE_2T3E3_LIU_VAL_RECEIVE_CLOCK_OUTPUT_2 0x04
+#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_2 0x02
+#define SBE_2T3E3_LIU_VAL_INVERT_RECEIVE_CLOCK_1 0x01
+
+/* REG4 */
+#define SBE_2T3E3_LIU_VAL_T3_MODE_SELECT 0x00
+#define SBE_2T3E3_LIU_VAL_E3_MODE_SELECT 0x04
+#define SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK 0x02
+#define SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK 0x01
+#define SBE_2T3E3_LIU_VAL_LOOPBACK_OFF 0x00
+#define SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE 0x01
+#define SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG 0x02
+#define SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL 0x03
+
+/**********************************************************************
+ *
+ * descriptor list and data buffer
+ *
+ **********************************************************************/
+typedef struct {
+ u32 rdes0;
+ u32 rdes1;
+ u32 rdes2;
+ u32 rdes3;
+} t3e3_rx_desc_t;
+
+#define SBE_2T3E3_RX_DESC_RING_SIZE 64
+
+/* RDES0 */
+#define SBE_2T3E3_RX_DESC_21143_OWN 0X80000000
+#define SBE_2T3E3_RX_DESC_FRAME_LENGTH 0x3fff0000
+#define SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT 16
+#define SBE_2T3E3_RX_DESC_ERROR_SUMMARY 0x00008000
+#define SBE_2T3E3_RX_DESC_DESC_ERROR 0x00004000
+#define SBE_2T3E3_RX_DESC_DATA_TYPE 0x00003000
+#define SBE_2T3E3_RX_DESC_RUNT_FRAME 0x00000800
+#define SBE_2T3E3_RX_DESC_FIRST_DESC 0x00000200
+#define SBE_2T3E3_RX_DESC_LAST_DESC 0x00000100
+#define SBE_2T3E3_RX_DESC_FRAME_TOO_LONG 0x00000080
+#define SBE_2T3E3_RX_DESC_COLLISION_SEEN 0x00000040
+#define SBE_2T3E3_RX_DESC_FRAME_TYPE 0x00000020
+#define SBE_2T3E3_RX_DESC_RECEIVE_WATCHDOG 0x00000010
+#define SBE_2T3E3_RX_DESC_MII_ERROR 0x00000008
+#define SBE_2T3E3_RX_DESC_DRIBBLING_BIT 0x00000004
+#define SBE_2T3E3_RX_DESC_CRC_ERROR 0x00000002
+
+/* RDES1 */
+#define SBE_2T3E3_RX_DESC_END_OF_RING 0x02000000
+#define SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED 0x01000000
+#define SBE_2T3E3_RX_DESC_BUFFER_2_SIZE 0x003ff800
+#define SBE_2T3E3_RX_DESC_BUFFER_1_SIZE 0x000007ff
+
+/*********************/
+
+typedef struct {
+ u32 tdes0;
+ u32 tdes1;
+ u32 tdes2;
+ u32 tdes3;
+} t3e3_tx_desc_t;
+
+#define SBE_2T3E3_TX_DESC_RING_SIZE 256
+
+/* TDES0 */
+#define SBE_2T3E3_TX_DESC_21143_OWN 0x80000000
+#define SBE_2T3E3_TX_DESC_ERROR_SUMMARY 0x00008000
+#define SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT 0x00004000
+#define SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER 0x00000800
+#define SBE_2T3E3_TX_DESC_NO_CARRIER 0x00000400
+#define SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT 0x00000004
+#define SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR 0x00000002
+#define SBE_2T3E3_TX_DESC_DEFFERED 0x00000001
+
+/* TDES1 */
+#define SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION 0x80000000
+#define SBE_2T3E3_TX_DESC_LAST_SEGMENT 0x40000000
+#define SBE_2T3E3_TX_DESC_FIRST_SEGMENT 0x20000000
+#define SBE_2T3E3_TX_DESC_CRC_DISABLE 0x04000000
+#define SBE_2T3E3_TX_DESC_END_OF_RING 0x02000000
+#define SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED 0x01000000
+#define SBE_2T3E3_TX_DESC_DISABLE_PADDING 0x00800000
+#define SBE_2T3E3_TX_DESC_BUFFER_2_SIZE 0x003ff800
+#define SBE_2T3E3_TX_DESC_BUFFER_1_SIZE 0x000007ff
+
+
+#define SBE_2T3E3_MTU 1600
+#define SBE_2T3E3_CRC16_LENGTH 2
+#define SBE_2T3E3_CRC32_LENGTH 4
+
+#define MCLBYTES (SBE_2T3E3_MTU + 128)
+
+struct channel {
+ struct pci_dev *pdev;
+ struct net_device *dev;
+ struct card *card;
+ unsigned long addr; /* DECchip */
+
+ int leds;
+
+ /* pci specific */
+ struct {
+ u32 slot; /* should be 0 or 1 */
+ u32 command;
+ u8 cache_size;
+ } h;
+
+ /* statistics */
+ t3e3_stats_t s;
+
+ /* running */
+ struct {
+ u32 flags;
+ } r;
+
+ /* parameters */
+ t3e3_param_t p;
+
+ u32 liu_regs[SBE_2T3E3_LIU_REG_MAX]; /* LIU registers */
+ u32 framer_regs[SBE_2T3E3_FRAMER_REG_MAX]; /* Framer registers */
+
+ /* Ethernet Controller */
+ struct {
+ u_int16_t card_serial_number[3];
+
+ u32 reg[SBE_2T3E3_21143_REG_MAX]; /* registers i.e. CSR */
+
+ u32 interrupt_enable_mask;
+
+ /* receive chain/ring */
+ t3e3_rx_desc_t *rx_ring;
+ struct sk_buff *rx_data[SBE_2T3E3_RX_DESC_RING_SIZE];
+ u32 rx_ring_current_read;
+
+ /* transmit chain/ring */
+ t3e3_tx_desc_t *tx_ring;
+ struct sk_buff *tx_data[SBE_2T3E3_TX_DESC_RING_SIZE];
+ u32 tx_ring_current_read;
+ u32 tx_ring_current_write;
+ int tx_full;
+ int tx_free_cnt;
+ spinlock_t tx_lock;
+ } ether;
+
+ int32_t interrupt_active;
+ int32_t rcv_count;
+};
+
+struct card {
+ spinlock_t bootrom_lock;
+ unsigned long bootrom_addr;
+ struct timer_list timer; /* for updating LEDs */
+ struct channel channels[0];
+};
+
+#define SBE_2T3E3_FLAG_NETWORK_UP 0x00000001
+#define SBE_2T3E3_FLAG_NO_ERROR_MESSAGES 0x00000002
+
+extern const u32 cpld_reg_map[][2];
+extern const u32 cpld_val_map[][2];
+extern const u32 t3e3_framer_reg_map[];
+extern const u32 t3e3_liu_reg_map[];
+
+void t3e3_init(struct channel *);
+void t3e3_if_up(struct channel *);
+void t3e3_if_down(struct channel *);
+int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev);
+void t3e3_if_config(struct channel *, u32, char *,
+ t3e3_resp_t *, int *);
+void t3e3_set_frame_type(struct channel *, u32);
+u32 t3e3_eeprom_read_word(struct channel *, u32);
+void t3e3_read_card_serial_number(struct channel *);
+
+/* interrupt handlers */
+irqreturn_t t3e3_intr(int irq, void *dev_instance);
+void dc_intr(struct channel *);
+void dc_intr_rx(struct channel *);
+void dc_intr_tx(struct channel *);
+void dc_intr_tx_underflow(struct channel *);
+void exar7250_intr(struct channel *);
+void exar7250_E3_intr(struct channel *, u32);
+void exar7250_T3_intr(struct channel *, u32);
+
+/* Ethernet controller */
+u32 bootrom_read(struct channel *, u32);
+void bootrom_write(struct channel *, u32, u32);
+void dc_init(struct channel *);
+void dc_start(struct channel *);
+void dc_stop(struct channel *);
+void dc_start_intr(struct channel *);
+void dc_stop_intr(struct channel *);
+void dc_reset(struct channel *);
+void dc_restart(struct channel *);
+void dc_receiver_onoff(struct channel *, u32);
+void dc_transmitter_onoff(struct channel *, u32);
+void dc_set_loopback(struct channel *, u32);
+u32 dc_init_descriptor_list(struct channel *);
+void dc_clear_descriptor_list(struct channel *);
+void dc_drop_descriptor_list(struct channel *);
+void dc_set_output_port(struct channel *);
+void t3e3_sc_init(struct channel *);
+
+/* CPLD */
+void cpld_init(struct channel *sc);
+u32 cpld_read(struct channel *sc, u32 reg);
+void cpld_set_crc(struct channel *, u32);
+void cpld_start_intr(struct channel *);
+void cpld_stop_intr(struct channel *);
+#if 0
+void cpld_led_onoff(struct channel *, u32, u32, u32, u32);
+#endif
+void cpld_set_clock(struct channel *sc, u32 mode);
+void cpld_set_scrambler(struct channel *, u32);
+void cpld_select_panel(struct channel *, u32);
+void cpld_set_frame_mode(struct channel *, u32);
+void cpld_set_frame_type(struct channel *, u32);
+void cpld_set_pad_count(struct channel *, u32);
+void cpld_set_fractional_mode(struct channel *, u32, u32, u32);
+void cpld_LOS_update(struct channel *);
+
+/* Framer */
+extern u32 exar7250_read(struct channel *, u32);
+extern void exar7250_write(struct channel *, u32, u32);
+void exar7250_init(struct channel *);
+void exar7250_start_intr(struct channel *, u32);
+void exar7250_stop_intr(struct channel *, u32);
+void exar7250_set_frame_type(struct channel *, u32);
+void exar7250_set_loopback(struct channel *, u32);
+void exar7250_unipolar_onoff(struct channel *, u32);
+
+/* LIU */
+u32 exar7300_read(struct channel *, u32);
+void exar7300_write(struct channel *, u32, u32);
+void exar7300_init(struct channel *);
+void exar7300_line_build_out_onoff(struct channel *, u32);
+void exar7300_set_frame_type(struct channel *, u32);
+void exar7300_set_loopback(struct channel *, u32);
+void exar7300_transmit_all_ones_onoff(struct channel *, u32);
+void exar7300_receive_equalization_onoff(struct channel *, u32);
+void exar7300_unipolar_onoff(struct channel *, u32);
+
+void update_led(struct channel *, int);
+int setup_device(struct net_device *dev, struct channel *sc);
+
+static inline int has_two_ports(struct pci_dev *pdev)
+{
+ return pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P0;
+}
+
+#define dev_to_priv(dev) (*(struct channel **) ((hdlc_device*)(dev) + 1))
+
+static inline u32 dc_read(unsigned long addr, u32 reg)
+{
+ return inl(addr + (reg << 3));
+}
+
+static inline void dc_write(unsigned long addr, u32 reg, u32 val)
+{
+ outl(val, addr + (reg << 3));
+}
+
+static inline void dc_set_bits(unsigned long addr, u32 reg, u32 bits)
+{
+ dc_write(addr, reg, dc_read(addr, reg) | bits);
+}
+
+static inline void dc_clear_bits(unsigned long addr, u32 reg, u32 bits)
+{
+ dc_write(addr, reg, dc_read(addr, reg) & ~bits);
+}
+
+#define CPLD_MAP_REG(reg, sc) (cpld_reg_map[(reg)][(sc)->h.slot])
+
+static inline void cpld_write(struct channel *channel, unsigned reg, u32 val)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+ bootrom_write(channel, CPLD_MAP_REG(reg, channel), val);
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+}
+
+#define exar7250_set_bit(sc, reg, bit) \
+ exar7250_write((sc), (reg), \
+ exar7250_read(sc, reg) | (bit))
+
+#define exar7250_clear_bit(sc, reg, bit) \
+ exar7250_write((sc), (reg), \
+ exar7250_read(sc, reg) & ~(bit))
+
+#define exar7300_set_bit(sc, reg, bit) \
+ exar7300_write((sc), (reg), \
+ exar7300_read(sc, reg) | (bit))
+
+#define exar7300_clear_bit(sc, reg, bit) \
+ exar7300_write((sc), (reg), \
+ exar7300_read(sc, reg) & ~(bit))
+
+
+#endif /* T3E3_H */
diff --git a/drivers/staging/sbe-2t3e3/Kconfig b/drivers/staging/sbe-2t3e3/Kconfig
new file mode 100644
index 000000000000..8ec86cfc6bf8
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/Kconfig
@@ -0,0 +1,13 @@
+config SBE_2T3E3
+ tristate "SBE wanPMC-2T3E3 support"
+ depends on HDLC && PCI
+ help
+ Driver for wanPMC-2T3E3 cards by SBE Inc.
+
+ If you have such a card, say Y here and see
+ <http://www.kernel.org/pub/linux/utils/net/hdlc/>.
+
+ To compile this as a module, choose M here: the
+ module will be called sbe-2t3e3.
+
+ If unsure, say N.
diff --git a/drivers/staging/sbe-2t3e3/Makefile b/drivers/staging/sbe-2t3e3/Makefile
new file mode 100644
index 000000000000..2c7b0978b478
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_SBE_2T3E3) += sbe-2t3e3.o
+
+sbe-2t3e3-objs := module.o netdev.o maps.o \
+ main.o cpld.o intr.o ctrl.o io.o dc.o exar7250.o exar7300.o
diff --git a/drivers/staging/sbe-2t3e3/TODO b/drivers/staging/sbe-2t3e3/TODO
new file mode 100644
index 000000000000..624b20f70cf8
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/TODO
@@ -0,0 +1,6 @@
+TODO:
+ - additional cleaning and tests
+ - wait for the new configuration interface in generic HDLC layer and
+ when available, convert the driver to it
+
+Please send patches to Krzysztof Halasa <khc@pm.waw.pl>. \ No newline at end of file
diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c
new file mode 100644
index 000000000000..b0fc2ddad329
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/cpld.c
@@ -0,0 +1,366 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/delay.h>
+#include "2t3e3.h"
+#include "ctrl.h"
+
+#define bootrom_set_bit(sc, reg, bit) \
+ bootrom_write((sc), (reg), \
+ bootrom_read((sc), (reg)) | (bit))
+
+#define bootrom_clear_bit(sc, reg, bit) \
+ bootrom_write((sc), (reg), \
+ bootrom_read((sc), (reg)) & ~(bit))
+
+static inline void cpld_set_bit(struct channel *channel, unsigned reg, u32 bit)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+ bootrom_set_bit(channel, CPLD_MAP_REG(reg, channel), bit);
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+}
+
+static inline void cpld_clear_bit(struct channel *channel, unsigned reg, u32 bit)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+ bootrom_clear_bit(channel, CPLD_MAP_REG(reg, channel), bit);
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+}
+
+void cpld_init(struct channel *sc)
+{
+ u32 val;
+#if 0
+ /* reset LIU and Framer */
+ val = cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET][sc->h.slot];
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
+ udelay(10000); /* TODO - how long? */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
+#endif
+
+ /* PCRA */
+ val = SBE_2T3E3_CPLD_VAL_CRC32 |
+ cpld_val_map[SBE_2T3E3_CPLD_VAL_LOOP_TIMING_SOURCE][sc->h.slot];
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRA, val);
+
+ /* PCRB */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRB, val);
+
+ /* PCRC */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC, val);
+
+ /* PBWF */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, val);
+
+ /* PBWL */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, val);
+
+ /* PLTR */
+ val = SBE_2T3E3_CPLD_VAL_LCV_COUNTER;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PLTR, val);
+ udelay(1000);
+
+ /* PLCR */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PLCR, val);
+ udelay(1000);
+
+ /* PPFR */
+ val = 0x55;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PPFR, val);
+ /* TODO: this doesn't work!!! */
+
+ /* SERIAL_CHIP_SELECT */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, val);
+
+ /* PICSR */
+ val = SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED |
+ SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED |
+ SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR, val);
+
+ cpld_start_intr(sc);
+
+ udelay(1000);
+}
+
+void cpld_start_intr(struct channel *sc)
+{
+ u32 val;
+
+ /* PIER */
+ val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE |
+ SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
+#if 0
+ /*
+ do you want to hang up your computer?
+ ENABLE REST OF INTERRUPTS !!!
+ you have been warned :).
+ */
+#endif
+}
+
+void cpld_stop_intr(struct channel *sc)
+{
+ u32 val;
+
+ /* PIER */
+ val = 0;
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
+}
+
+void cpld_set_frame_mode(struct channel *sc, u32 mode)
+{
+ if (sc->p.frame_mode == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_FRAME_MODE_HDLC:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE |
+ SBE_2T3E3_CPLD_VAL_RAW_MODE);
+ exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF);
+ exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF);
+ break;
+ case SBE_2T3E3_FRAME_MODE_TRANSPARENT:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_RAW_MODE);
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_TRANSPARENT_MODE);
+ exar7250_unipolar_onoff(sc, SBE_2T3E3_OFF);
+ exar7300_unipolar_onoff(sc, SBE_2T3E3_OFF);
+ break;
+ case SBE_2T3E3_FRAME_MODE_RAW:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_RAW_MODE);
+ exar7250_unipolar_onoff(sc, SBE_2T3E3_ON);
+ exar7300_unipolar_onoff(sc, SBE_2T3E3_ON);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.frame_mode = mode;
+}
+
+/* set rate of the local clock */
+void cpld_set_frame_type(struct channel *sc, u32 type)
+{
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3);
+ break;
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_LOCAL_CLOCK_E3);
+ break;
+ default:
+ return;
+ }
+}
+
+void cpld_set_scrambler(struct channel *sc, u32 mode)
+{
+ if (sc->p.scrambler == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_SCRAMBLER_OFF:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
+ break;
+ case SBE_2T3E3_SCRAMBLER_LARSCOM:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE);
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
+ break;
+ case SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_SCRAMBLER_TYPE);
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_SCRAMBLER_ENABLE);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.scrambler = mode;
+}
+
+
+void cpld_set_crc(struct channel *sc, u32 crc)
+{
+ if (sc->p.crc == crc)
+ return;
+
+ switch (crc) {
+ case SBE_2T3E3_CRC_16:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_CRC32);
+ break;
+ case SBE_2T3E3_CRC_32:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_CRC32);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.crc = crc;
+}
+
+
+void cpld_select_panel(struct channel *sc, u32 panel)
+{
+ if (sc->p.panel == panel)
+ return;
+ switch (panel) {
+ case SBE_2T3E3_PANEL_FRONT:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_REAR_PANEL);
+ break;
+ case SBE_2T3E3_PANEL_REAR:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_REAR_PANEL);
+ break;
+ default:
+ return;
+ }
+
+ udelay(100);
+
+ sc->p.panel = panel;
+}
+
+
+extern void cpld_set_clock(struct channel *sc, u32 mode)
+{
+ if (sc->p.clock_source == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_TIMING_LOCAL:
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_ALT);
+ break;
+ case SBE_2T3E3_TIMING_LOOP:
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRA,
+ SBE_2T3E3_CPLD_VAL_ALT);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.clock_source = mode;
+}
+
+void cpld_set_pad_count(struct channel *sc, u32 count)
+{
+ u32 val;
+
+ if (sc->p.pad_count == count)
+ return;
+
+ switch (count) {
+ case SBE_2T3E3_PAD_COUNT_1:
+ val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_1;
+ break;
+ case SBE_2T3E3_PAD_COUNT_2:
+ val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_2;
+ break;
+ case SBE_2T3E3_PAD_COUNT_3:
+ val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_3;
+ break;
+ case SBE_2T3E3_PAD_COUNT_4:
+ val = SBE_2T3E3_CPLD_VAL_PAD_COUNT_4;
+ break;
+ default:
+ return;
+ }
+
+ cpld_clear_bit(sc, SBE_2T3E3_CPLD_REG_PCRB,
+ SBE_2T3E3_CPLD_VAL_PAD_COUNT);
+ cpld_set_bit(sc, SBE_2T3E3_CPLD_REG_PCRB, val);
+ sc->p.pad_count = count;
+}
+
+void cpld_LOS_update(struct channel *sc)
+{
+ u_int8_t los;
+
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PICSR,
+ SBE_2T3E3_CPLD_VAL_DMO_SIGNAL_DETECTED |
+ SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_LOCK_DETECTED |
+ SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED);
+ los = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR) &
+ SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_DETECTED;
+
+ if (los != sc->s.LOS)
+ dev_info(&sc->pdev->dev, "SBE 2T3E3: LOS status: %s\n",
+ los ? "Loss of signal" : "Signal OK");
+ sc->s.LOS = los;
+}
+
+void cpld_set_fractional_mode(struct channel *sc, u32 mode,
+ u32 start, u32 stop)
+{
+ if (mode == SBE_2T3E3_FRACTIONAL_MODE_NONE) {
+ start = 0;
+ stop = 0;
+ }
+
+ if (sc->p.fractional_mode == mode && sc->p.bandwidth_start == start &&
+ sc->p.bandwidth_stop == stop)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_FRACTIONAL_MODE_NONE:
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
+ SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_NONE);
+ break;
+ case SBE_2T3E3_FRACTIONAL_MODE_0:
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
+ SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_0);
+ break;
+ case SBE_2T3E3_FRACTIONAL_MODE_1:
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
+ SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_1);
+ break;
+ case SBE_2T3E3_FRACTIONAL_MODE_2:
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PCRC,
+ SBE_2T3E3_CPLD_VAL_FRACTIONAL_MODE_2);
+ break;
+ default:
+ printk(KERN_ERR "wrong mode in set_fractional_mode\n");
+ return;
+ }
+
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWF, start);
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_PBWL, stop);
+
+ sc->p.fractional_mode = mode;
+ sc->p.bandwidth_start = start;
+ sc->p.bandwidth_stop = stop;
+}
diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c
new file mode 100644
index 000000000000..d9dd216e9ae0
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/ctrl.c
@@ -0,0 +1,362 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/types.h>
+#include "2t3e3.h"
+#include "ctrl.h"
+
+void t3e3_set_frame_type(struct channel *sc, u32 mode)
+{
+ if (sc->p.frame_type == mode)
+ return;
+
+ if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: changing frame type during active connection\n");
+ return;
+ }
+
+ exar7300_set_frame_type(sc, mode);
+ exar7250_set_frame_type(sc, mode);
+ cpld_set_frame_type(sc, mode);
+
+ sc->p.frame_type = mode;
+}
+
+void t3e3_set_loopback(struct channel *sc, u32 mode)
+{
+ u32 tx, rx;
+
+ if (sc->p.loopback == mode)
+ return;
+
+ tx = sc->p.transmitter_on;
+ rx = sc->p.receiver_on;
+ if (tx == SBE_2T3E3_ON)
+ dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
+ if (rx == SBE_2T3E3_ON)
+ dc_receiver_onoff(sc, SBE_2T3E3_OFF);
+
+ /* stop current loopback if any exists */
+ switch (sc->p.loopback) {
+ case SBE_2T3E3_LOOPBACK_NONE:
+ break;
+ case SBE_2T3E3_LOOPBACK_ETHERNET:
+ dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_OFF);
+ break;
+ case SBE_2T3E3_LOOPBACK_FRAMER:
+ exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF);
+ break;
+ case SBE_2T3E3_LOOPBACK_LIU_DIGITAL:
+ case SBE_2T3E3_LOOPBACK_LIU_ANALOG:
+ case SBE_2T3E3_LOOPBACK_LIU_REMOTE:
+ exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_OFF);
+ break;
+ default:
+ return;
+ }
+
+ switch (mode) {
+ case SBE_2T3E3_LOOPBACK_NONE:
+ break;
+ case SBE_2T3E3_LOOPBACK_ETHERNET:
+ dc_set_loopback(sc, SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL);
+ break;
+ case SBE_2T3E3_LOOPBACK_FRAMER:
+ exar7250_set_loopback(sc, SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON);
+ break;
+ case SBE_2T3E3_LOOPBACK_LIU_DIGITAL:
+ exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL);
+ break;
+ case SBE_2T3E3_LOOPBACK_LIU_ANALOG:
+ exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG);
+ break;
+ case SBE_2T3E3_LOOPBACK_LIU_REMOTE:
+ exar7300_set_loopback(sc, SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.loopback = mode;
+
+ if (tx == SBE_2T3E3_ON)
+ dc_transmitter_onoff(sc, SBE_2T3E3_ON);
+ if (rx == SBE_2T3E3_ON)
+ dc_receiver_onoff(sc, SBE_2T3E3_ON);
+}
+
+
+void t3e3_reg_read(struct channel *sc, u32 *reg, u32 *val)
+{
+ u32 i;
+
+ *val = 0;
+
+ switch (reg[0]) {
+ case SBE_2T3E3_CHIP_21143:
+ if (!(reg[1] & 7))
+ *val = dc_read(sc->addr, reg[1] / 8);
+ break;
+ case SBE_2T3E3_CHIP_CPLD:
+ for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++)
+ if (cpld_reg_map[i][sc->h.slot] == reg[1]) {
+ *val = cpld_read(sc, i);
+ break;
+ }
+ break;
+ case SBE_2T3E3_CHIP_FRAMER:
+ for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++)
+ if (t3e3_framer_reg_map[i] == reg[1]) {
+ *val = exar7250_read(sc, i);
+ break;
+ }
+ break;
+ case SBE_2T3E3_CHIP_LIU:
+ for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++)
+ if (t3e3_liu_reg_map[i] == reg[1]) {
+ *val = exar7300_read(sc, i);
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void t3e3_reg_write(struct channel *sc, u32 *reg)
+{
+ u32 i;
+
+ switch (reg[0]) {
+ case SBE_2T3E3_CHIP_21143:
+ dc_write(sc->addr, reg[1], reg[2]);
+ break;
+ case SBE_2T3E3_CHIP_CPLD:
+ for (i = 0; i < SBE_2T3E3_CPLD_REG_MAX; i++)
+ if (cpld_reg_map[i][sc->h.slot] == reg[1]) {
+ cpld_write(sc, i, reg[2]);
+ break;
+ }
+ break;
+ case SBE_2T3E3_CHIP_FRAMER:
+ for (i = 0; i < SBE_2T3E3_FRAMER_REG_MAX; i++)
+ if (t3e3_framer_reg_map[i] == reg[1]) {
+ exar7250_write(sc, i, reg[2]);
+ break;
+ }
+ break;
+ case SBE_2T3E3_CHIP_LIU:
+ for (i = 0; i < SBE_2T3E3_LIU_REG_MAX; i++)
+ if (t3e3_liu_reg_map[i] == reg[1]) {
+ exar7300_write(sc, i, reg[2]);
+ break;
+ }
+ break;
+ }
+}
+
+void t3e3_port_get(struct channel *sc, t3e3_param_t *param)
+{
+ memcpy(param, &(sc->p), sizeof(t3e3_param_t));
+}
+
+void t3e3_port_set(struct channel *sc, t3e3_param_t *param)
+{
+ if (param->frame_mode != 0xff)
+ cpld_set_frame_mode(sc, param->frame_mode);
+
+ if (param->fractional_mode != 0xff)
+ cpld_set_fractional_mode(sc, param->fractional_mode,
+ param->bandwidth_start,
+ param->bandwidth_stop);
+
+ if (param->pad_count != 0xff)
+ cpld_set_pad_count(sc, param->pad_count);
+
+ if (param->crc != 0xff)
+ cpld_set_crc(sc, param->crc);
+
+ if (param->receiver_on != 0xff)
+ dc_receiver_onoff(sc, param->receiver_on);
+
+ if (param->transmitter_on != 0xff)
+ dc_transmitter_onoff(sc, param->transmitter_on);
+
+ if (param->frame_type != 0xff)
+ t3e3_set_frame_type(sc, param->frame_type);
+
+ if (param->panel != 0xff)
+ cpld_select_panel(sc, param->panel);
+
+ if (param->line_build_out != 0xff)
+ exar7300_line_build_out_onoff(sc, param->line_build_out);
+
+ if (param->receive_equalization != 0xff)
+ exar7300_receive_equalization_onoff(sc, param->receive_equalization);
+
+ if (param->transmit_all_ones != 0xff)
+ exar7300_transmit_all_ones_onoff(sc, param->transmit_all_ones);
+
+ if (param->loopback != 0xff)
+ t3e3_set_loopback(sc, param->loopback);
+
+ if (param->clock_source != 0xff)
+ cpld_set_clock(sc, param->clock_source);
+
+ if (param->scrambler != 0xff)
+ cpld_set_scrambler(sc, param->scrambler);
+}
+
+void t3e3_port_get_stats(struct channel *sc,
+ t3e3_stats_t *stats)
+{
+ u32 result;
+
+ sc->s.LOC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL)
+ & SBE_2T3E3_FRAMER_VAL_LOSS_OF_CLOCK_STATUS ? 1 : 0;
+
+ switch (sc->p.frame_type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
+ sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0;
+ sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
+#if 0
+ sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
+#else
+ cpld_LOS_update(sc);
+#endif
+ sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0;
+ sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0;
+ break;
+
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
+ sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0;
+#if 0
+ sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
+#else
+ cpld_LOS_update(sc);
+#endif
+ sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0;
+ sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_STATUS);
+ sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FERF ? 1 : 0;
+ sc->s.AIC = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIC ? 1 : 0;
+ sc->s.FEBE_code = result & SBE_2T3E3_FRAMER_VAL_T3_RX_FEBE;
+
+ sc->s.FEAC = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC);
+ break;
+
+ default:
+ break;
+ }
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_LCV_EVENT_COUNT_MSB) << 8;
+ result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
+ sc->s.LCV += result;
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB) << 8;
+ result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
+ sc->s.FRAMING_BIT += result;
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_PARITY_ERROR_EVENT_COUNT_MSB) << 8;
+ result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
+ sc->s.PARITY_ERROR += result;
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_FEBE_EVENT_COUNT_MSB) << 8;
+ result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
+ sc->s.FEBE_count += result;
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_CP_BIT_ERROR_EVENT_COUNT_MSB) << 8;
+ result += exar7250_read(sc, SBE_2T3E3_FRAMER_REG_PMON_HOLDING_REGISTER);
+ sc->s.CP_BIT += result;
+
+ memcpy(stats, &(sc->s), sizeof(t3e3_stats_t));
+}
+
+void t3e3_port_del_stats(struct channel *sc)
+{
+ memset(&(sc->s), 0, sizeof(t3e3_stats_t));
+}
+
+void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
+ t3e3_resp_t *ret, int *rlen)
+{
+ t3e3_param_t *param = (t3e3_param_t *)set;
+ u32 *data = (u32 *)set;
+
+ /* turn off all interrupt */
+ /* cpld_stop_intr(sc); */
+
+ switch (cmd) {
+ case SBE_2T3E3_PORT_GET:
+ t3e3_port_get(sc, &(ret->u.param));
+ *rlen = sizeof(ret->u.param);
+ break;
+ case SBE_2T3E3_PORT_SET:
+ t3e3_port_set(sc, param);
+ *rlen = 0;
+ break;
+ case SBE_2T3E3_PORT_GET_STATS:
+ t3e3_port_get_stats(sc, &(ret->u.stats));
+ *rlen = sizeof(ret->u.stats);
+ break;
+ case SBE_2T3E3_PORT_DEL_STATS:
+ t3e3_port_del_stats(sc);
+ *rlen = 0;
+ break;
+ case SBE_2T3E3_PORT_READ_REGS:
+ t3e3_reg_read(sc, data, &(ret->u.data));
+ *rlen = sizeof(ret->u.data);
+ break;
+ case SBE_2T3E3_PORT_WRITE_REGS:
+#if 0
+ printk(KERN_DEBUG "SBE_2T3E3_PORT_WRITE_REGS, 0x%x, 0x%x, 0x%x\n",
+ ((int*)data)[0], ((int*)data)[1], ((int*)data)[2]);
+#endif
+ t3e3_reg_write(sc, data);
+ *rlen = 0;
+ break;
+ case SBE_2T3E3_LOG_LEVEL:
+ *rlen = 0;
+ break;
+ default:
+ *rlen = 0;
+ break;
+ }
+
+ /* turn on interrupt */
+ /* cpld_start_intr(sc); */
+}
+
+void t3e3_sc_init(struct channel *sc)
+{
+ memset(sc, 0, sizeof(*sc));
+
+ sc->p.frame_mode = SBE_2T3E3_FRAME_MODE_HDLC;
+ sc->p.fractional_mode = SBE_2T3E3_FRACTIONAL_MODE_NONE;
+ sc->p.crc = SBE_2T3E3_CRC_32;
+ sc->p.receiver_on = SBE_2T3E3_OFF;
+ sc->p.transmitter_on = SBE_2T3E3_OFF;
+ sc->p.frame_type = SBE_2T3E3_FRAME_TYPE_T3_CBIT;
+ sc->p.panel = SBE_2T3E3_PANEL_FRONT;
+ sc->p.line_build_out = SBE_2T3E3_OFF;
+ sc->p.receive_equalization = SBE_2T3E3_OFF;
+ sc->p.transmit_all_ones = SBE_2T3E3_OFF;
+ sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
+ sc->p.clock_source = SBE_2T3E3_TIMING_LOCAL;
+ sc->p.scrambler = SBE_2T3E3_SCRAMBLER_OFF;
+ sc->p.pad_count = SBE_2T3E3_PAD_COUNT_1;
+}
diff --git a/drivers/staging/sbe-2t3e3/ctrl.h b/drivers/staging/sbe-2t3e3/ctrl.h
new file mode 100644
index 000000000000..c11a58871845
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/ctrl.h
@@ -0,0 +1,131 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#ifndef CTRL_H
+#define CTRL_H
+
+#define SBE_2T3E3_OFF 0
+#define SBE_2T3E3_ON 1
+
+#define SBE_2T3E3_LED_NONE 0
+#define SBE_2T3E3_LED_GREEN 1
+#define SBE_2T3E3_LED_YELLOW 2
+
+#define SBE_2T3E3_CABLE_LENGTH_LESS_THAN_255_FEET 0
+#define SBE_2T3E3_CABLE_LENGTH_GREATER_THAN_255_FEET 1
+
+#define SBE_2T3E3_CRC_16 0
+#define SBE_2T3E3_CRC_32 1
+
+#define SBE_2T3E3_PANEL_FRONT 0
+#define SBE_2T3E3_PANEL_REAR 1
+
+#define SBE_2T3E3_FRAME_MODE_HDLC 0
+#define SBE_2T3E3_FRAME_MODE_TRANSPARENT 1
+#define SBE_2T3E3_FRAME_MODE_RAW 2
+
+#define SBE_2T3E3_FRAME_TYPE_E3_G751 0
+#define SBE_2T3E3_FRAME_TYPE_E3_G832 1
+#define SBE_2T3E3_FRAME_TYPE_T3_CBIT 2
+#define SBE_2T3E3_FRAME_TYPE_T3_M13 3
+
+#define SBE_2T3E3_FRACTIONAL_MODE_NONE 0
+#define SBE_2T3E3_FRACTIONAL_MODE_0 1
+#define SBE_2T3E3_FRACTIONAL_MODE_1 2
+#define SBE_2T3E3_FRACTIONAL_MODE_2 3
+
+#define SBE_2T3E3_SCRAMBLER_OFF 0
+#define SBE_2T3E3_SCRAMBLER_LARSCOM 1
+#define SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL 2
+
+#define SBE_2T3E3_TIMING_LOCAL 0
+#define SBE_2T3E3_TIMING_LOOP 1
+
+#define SBE_2T3E3_LOOPBACK_NONE 0
+#define SBE_2T3E3_LOOPBACK_ETHERNET 1
+#define SBE_2T3E3_LOOPBACK_FRAMER 2
+#define SBE_2T3E3_LOOPBACK_LIU_DIGITAL 3
+#define SBE_2T3E3_LOOPBACK_LIU_ANALOG 4
+#define SBE_2T3E3_LOOPBACK_LIU_REMOTE 5
+
+#define SBE_2T3E3_PAD_COUNT_1 1
+#define SBE_2T3E3_PAD_COUNT_2 2
+#define SBE_2T3E3_PAD_COUNT_3 3
+#define SBE_2T3E3_PAD_COUNT_4 4
+
+#define SBE_2T3E3_CHIP_21143 0
+#define SBE_2T3E3_CHIP_CPLD 1
+#define SBE_2T3E3_CHIP_FRAMER 2
+#define SBE_2T3E3_CHIP_LIU 3
+
+#define SBE_2T3E3_LOG_LEVEL_NONE 0
+#define SBE_2T3E3_LOG_LEVEL_ERROR 1
+#define SBE_2T3E3_LOG_LEVEL_WARNING 2
+#define SBE_2T3E3_LOG_LEVEL_INFO 3
+
+/* commands */
+#define SBE_2T3E3_PORT_GET 0
+#define SBE_2T3E3_PORT_SET 1
+#define SBE_2T3E3_PORT_GET_STATS 2
+#define SBE_2T3E3_PORT_DEL_STATS 3
+#define SBE_2T3E3_PORT_READ_REGS 4
+#define SBE_2T3E3_LOG_LEVEL 5
+#define SBE_2T3E3_PORT_WRITE_REGS 6
+
+#define NG_SBE_2T3E3_NODE_TYPE "sbe2T3E3"
+#define NG_SBE_2T3E3_COOKIE 0x03800891
+
+typedef struct t3e3_param {
+ u_int8_t frame_mode; /* FRAME_MODE_* */
+ u_int8_t crc; /* CRC_* */
+ u_int8_t receiver_on; /* ON/OFF */
+ u_int8_t transmitter_on; /* ON/OFF */
+ u_int8_t frame_type; /* FRAME_TYPE_* */
+ u_int8_t panel; /* PANEL_* */
+ u_int8_t line_build_out; /* ON/OFF */
+ u_int8_t receive_equalization; /* ON/OFF */
+ u_int8_t transmit_all_ones; /* ON/OFF */
+ u_int8_t loopback; /* LOOPBACK_* */
+ u_int8_t clock_source; /* TIMING_* */
+ u_int8_t scrambler; /* SCRAMBLER_* */
+ u_int8_t pad_count; /* PAD_COUNT_* */
+ u_int8_t log_level; /* LOG_LEVEL_* - unused */
+ u_int8_t fractional_mode; /* FRACTIONAL_MODE_* */
+ u_int8_t bandwidth_start; /* 0-255 */
+ u_int8_t bandwidth_stop; /* 0-255 */
+} t3e3_param_t;
+
+typedef struct t3e3_stats {
+ u_int64_t in_bytes;
+ u32 in_packets, in_dropped;
+ u32 in_errors, in_error_desc, in_error_coll, in_error_drib,
+ in_error_crc, in_error_mii;
+ u_int64_t out_bytes;
+ u32 out_packets, out_dropped;
+ u32 out_errors, out_error_jab, out_error_lost_carr,
+ out_error_no_carr, out_error_link_fail, out_error_underflow,
+ out_error_dereferred;
+ u_int8_t LOC, LOF, OOF, LOS, AIS, FERF, IDLE, AIC, FEAC;
+ u_int16_t FEBE_code;
+ u32 LCV, FRAMING_BIT, PARITY_ERROR, FEBE_count, CP_BIT;
+} t3e3_stats_t;
+
+
+typedef struct t3e3_resp {
+ union {
+ t3e3_param_t param;
+ t3e3_stats_t stats;
+ u32 data;
+ } u;
+} t3e3_resp_t;
+
+#endif /* CTRL_H */
diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c
new file mode 100644
index 000000000000..126a9720c6b8
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/dc.c
@@ -0,0 +1,502 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/netdevice.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+#include "2t3e3.h"
+#include "ctrl.h"
+
+void dc_init(struct channel *sc)
+{
+ u32 val;
+
+ dc_stop(sc);
+ /*dc_reset(sc);*/ /* do not want to reset here */
+
+ /*
+ * BUS_MODE (CSR0)
+ */
+ val = SBE_2T3E3_21143_VAL_READ_LINE_ENABLE |
+ SBE_2T3E3_21143_VAL_READ_MULTIPLE_ENABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_AUTOMATIC_POLLING_200us |
+ SBE_2T3E3_21143_VAL_BUS_ARBITRATION_RR;
+
+ if (sc->h.command & 16)
+ val |= SBE_2T3E3_21143_VAL_WRITE_AND_INVALIDATE_ENABLE;
+
+ switch (sc->h.cache_size) {
+ case 32:
+ val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_32;
+ break;
+ case 16:
+ val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_16;
+ break;
+ case 8:
+ val |= SBE_2T3E3_21143_VAL_CACHE_ALIGNMENT_8;
+ break;
+ default:
+ break;
+ }
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, val);
+
+ /* OPERATION_MODE (CSR6) */
+ val = SBE_2T3E3_21143_VAL_RECEIVE_ALL |
+ SBE_2T3E3_21143_VAL_MUST_BE_ONE |
+ SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1 |
+ SBE_2T3E3_21143_VAL_LOOPBACK_OFF |
+ SBE_2T3E3_21143_VAL_PASS_ALL_MULTICAST |
+ SBE_2T3E3_21143_VAL_PROMISCUOUS_MODE |
+ SBE_2T3E3_21143_VAL_PASS_BAD_FRAMES;
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val);
+ if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET)
+ sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
+
+#if 0 /* No need to clear this register - and it may be in use */
+ /*
+ * BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT (CSR9)
+ */
+ val = 0;
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, val);
+#endif
+
+ /*
+ * GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL (CSR11)
+ */
+ val = SBE_2T3E3_21143_VAL_CYCLE_SIZE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_TIMER |
+ SBE_2T3E3_21143_VAL_NUMBER_OF_TRANSMIT_PACKETS |
+ SBE_2T3E3_21143_VAL_RECEIVE_TIMER |
+ SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS;
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL, val);
+
+ /* prepare descriptors and data for receive and transmit procecsses */
+ if (dc_init_descriptor_list(sc) != 0)
+ return;
+
+ /* clear ethernet interrupts status */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
+
+ /* SIA mode registers */
+ dc_set_output_port(sc);
+}
+
+void dc_start(struct channel *sc)
+{
+ u32 val;
+
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP))
+ return;
+
+ dc_init(sc);
+
+ /* get actual LOS and OOF status */
+ switch (sc->p.frame_type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
+ dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val);
+ sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
+ break;
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
+ dev_dbg(&sc->pdev->dev, "Start Framer Rx Status = %02X\n", val);
+ sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
+ break;
+ default:
+ break;
+ }
+ cpld_LOS_update(sc);
+
+ /* start receive and transmit processes */
+ dc_transmitter_onoff(sc, SBE_2T3E3_ON);
+ dc_receiver_onoff(sc, SBE_2T3E3_ON);
+
+ /* start interrupts */
+ dc_start_intr(sc);
+}
+
+#define MAX_INT_WAIT_CNT 12000
+void dc_stop(struct channel *sc)
+{
+ int wcnt;
+
+ /* stop receive and transmit processes */
+ dc_receiver_onoff(sc, SBE_2T3E3_OFF);
+ dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
+
+ /* turn off ethernet interrupts */
+ dc_stop_intr(sc);
+
+ /* wait to ensure the interrupts have been completed */
+ for (wcnt = 0; wcnt < MAX_INT_WAIT_CNT; wcnt++) {
+ udelay(5);
+ if (!sc->interrupt_active)
+ break;
+ }
+ if (wcnt >= MAX_INT_WAIT_CNT)
+ dev_warn(&sc->pdev->dev, "SBE 2T3E3: Interrupt active too long\n");
+
+ /* clear all receive/transmit data */
+ dc_drop_descriptor_list(sc);
+}
+
+void dc_start_intr(struct channel *sc)
+{
+ if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE && sc->s.OOF)
+ return;
+
+ if (sc->p.receiver_on || sc->p.transmitter_on) {
+ if (!sc->ether.interrupt_enable_mask)
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
+
+ sc->ether.interrupt_enable_mask =
+ SBE_2T3E3_21143_VAL_NORMAL_INTERRUPT_SUMMARY_ENABLE |
+ SBE_2T3E3_21143_VAL_ABNORMAL_INTERRUPT_SUMMARY_ENABLE |
+ SBE_2T3E3_21143_VAL_RECEIVE_STOPPED_ENABLE |
+ SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE_ENABLE |
+ SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT_ENABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW_INTERRUPT_ENABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE_ENABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_STOPPED_ENABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT_ENABLE;
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE,
+ sc->ether.interrupt_enable_mask);
+ }
+}
+
+void dc_stop_intr(struct channel *sc)
+{
+ sc->ether.interrupt_enable_mask = 0;
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
+}
+
+void dc_reset(struct channel *sc)
+{
+ /* turn off ethernet interrupts */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, 0xFFFFFFFF);
+
+ /* software reset */
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE,
+ SBE_2T3E3_21143_VAL_SOFTWARE_RESET);
+ udelay(4); /* 50 PCI cycles < 2us */
+
+ /* clear hardware configuration */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_BUS_MODE, 0);
+
+ /* clear software configuration */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, 0);
+
+ /* turn off SIA reset */
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
+ SBE_2T3E3_21143_VAL_SIA_RESET);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0);
+}
+
+
+void dc_receiver_onoff(struct channel *sc, u32 mode)
+{
+ u32 i, state = 0;
+
+ if (sc->p.receiver_on == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
+ SBE_2T3E3_21143_VAL_RECEIVE_START) {
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_RECEIVE_START);
+
+ for (i = 0; i < 16; i++) {
+ state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) &
+ SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STATE;
+ if (state == SBE_2T3E3_21143_VAL_RX_STOPPED)
+ break;
+ udelay(5);
+ }
+ if (state != SBE_2T3E3_21143_VAL_RX_STOPPED)
+ dev_warn(&sc->pdev->dev, "SBE 2T3E3: Rx failed to stop\n");
+ else
+ dev_info(&sc->pdev->dev, "SBE 2T3E3: Rx off\n");
+ }
+ break;
+ case SBE_2T3E3_ON:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_RECEIVE_START);
+ udelay(100);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.receiver_on = mode;
+}
+
+void dc_transmitter_onoff(struct channel *sc, u32 mode)
+{
+ u32 i, state = 0;
+
+ if (sc->p.transmitter_on == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ if (dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
+ SBE_2T3E3_21143_VAL_TRANSMISSION_START) {
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_TRANSMISSION_START);
+
+ for (i = 0; i < 16; i++) {
+ state = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS) &
+ SBE_2T3E3_21143_VAL_TRANSMISSION_PROCESS_STATE;
+ if (state == SBE_2T3E3_21143_VAL_TX_STOPPED)
+ break;
+ udelay(5);
+ }
+ if (state != SBE_2T3E3_21143_VAL_TX_STOPPED)
+ dev_warn(&sc->pdev->dev, "SBE 2T3E3: Tx failed to stop\n");
+ }
+ break;
+ case SBE_2T3E3_ON:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_TRANSMISSION_START);
+ udelay(100);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND, 0xFFFFFFFF);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.transmitter_on = mode;
+}
+
+
+
+void dc_set_loopback(struct channel *sc, u32 mode)
+{
+ u32 val;
+
+ switch (mode) {
+ case SBE_2T3E3_21143_VAL_LOOPBACK_OFF:
+ case SBE_2T3E3_21143_VAL_LOOPBACK_INTERNAL:
+ break;
+ default:
+ return;
+ }
+
+#if 0
+ /* restart SIA */
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
+ SBE_2T3E3_21143_VAL_SIA_RESET);
+ udelay(1000);
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
+ SBE_2T3E3_21143_VAL_SIA_RESET);
+#endif
+
+ /* select loopback mode */
+ val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
+ ~SBE_2T3E3_21143_VAL_OPERATING_MODE;
+ val |= mode;
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE, val);
+
+ if (mode == SBE_2T3E3_21143_VAL_LOOPBACK_OFF)
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
+ else
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
+}
+
+u32 dc_init_descriptor_list(struct channel *sc)
+{
+ u32 i, j;
+ struct sk_buff *m;
+
+ if (sc->ether.rx_ring == NULL)
+ sc->ether.rx_ring = kzalloc(SBE_2T3E3_RX_DESC_RING_SIZE *
+ sizeof(t3e3_rx_desc_t), GFP_KERNEL);
+ if (sc->ether.rx_ring == NULL) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n");
+ return ENOMEM;
+ }
+
+ if (sc->ether.tx_ring == NULL)
+ sc->ether.tx_ring = kzalloc(SBE_2T3E3_TX_DESC_RING_SIZE *
+ sizeof(t3e3_tx_desc_t), GFP_KERNEL);
+ if (sc->ether.tx_ring == NULL) {
+#ifdef T3E3_USE_CONTIGMALLOC
+ t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
+ sizeof(t3e3_rx_desc_t);
+#endif
+ kfree(sc->ether.rx_ring);
+ sc->ether.rx_ring = NULL;
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: no buffer space for RX ring\n");
+ return ENOMEM;
+ }
+
+
+ /*
+ * Receive ring
+ */
+ for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) {
+ sc->ether.rx_ring[i].rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
+ sc->ether.rx_ring[i].rdes1 =
+ SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED | SBE_2T3E3_MTU;
+
+ if (sc->ether.rx_data[i] == NULL) {
+ if (!(m = dev_alloc_skb(MCLBYTES))) {
+ for (j = 0; j < i; j++) {
+ dev_kfree_skb_any(sc->ether.rx_data[j]);
+ sc->ether.rx_data[j] = NULL;
+ }
+#ifdef T3E3_USE_CONTIGMALLOC
+ t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
+ sizeof(t3e3_rx_desc_t);
+#endif
+ kfree(sc->ether.rx_ring);
+ sc->ether.rx_ring = NULL;
+#ifdef T3E3_USE_CONTIGMALLOC
+ t3e3_contigmemory_size = SBE_2T3E3_TX_DESC_RING_SIZE *
+ sizeof(t3e3_tx_desc_t);
+#endif
+ kfree(sc->ether.tx_ring);
+ sc->ether.tx_ring = NULL;
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: token_alloc err:"
+ " no buffer space for RX ring\n");
+ return ENOBUFS;
+ }
+ sc->ether.rx_data[i] = m;
+ }
+ sc->ether.rx_ring[i].rdes2 = virt_to_phys(sc->ether.rx_data[i]->data);
+
+ sc->ether.rx_ring[i].rdes3 = virt_to_phys(
+ &sc->ether.rx_ring[(i + 1) % SBE_2T3E3_RX_DESC_RING_SIZE]);
+ }
+ sc->ether.rx_ring[SBE_2T3E3_RX_DESC_RING_SIZE - 1].rdes1 |=
+ SBE_2T3E3_RX_DESC_END_OF_RING;
+ sc->ether.rx_ring_current_read = 0;
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS,
+ virt_to_phys(&sc->ether.rx_ring[0]));
+
+ /*
+ * Transmit ring
+ */
+ for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) {
+ sc->ether.tx_ring[i].tdes0 = 0;
+ sc->ether.tx_ring[i].tdes1 = SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED |
+ SBE_2T3E3_TX_DESC_DISABLE_PADDING;
+
+ sc->ether.tx_ring[i].tdes2 = 0;
+ sc->ether.tx_data[i] = NULL;
+
+ sc->ether.tx_ring[i].tdes3 = virt_to_phys(
+ &sc->ether.tx_ring[(i + 1) % SBE_2T3E3_TX_DESC_RING_SIZE]);
+ }
+ sc->ether.tx_ring[SBE_2T3E3_TX_DESC_RING_SIZE - 1].tdes1 |=
+ SBE_2T3E3_TX_DESC_END_OF_RING;
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS,
+ virt_to_phys(&sc->ether.tx_ring[0]));
+ sc->ether.tx_ring_current_read = 0;
+ sc->ether.tx_ring_current_write = 0;
+ sc->ether.tx_free_cnt = SBE_2T3E3_TX_DESC_RING_SIZE;
+ spin_lock_init(&sc->ether.tx_lock);
+
+ return 0;
+}
+
+void dc_clear_descriptor_list(struct channel *sc)
+{
+ u32 i;
+
+ /* clear CSR3 and CSR4 */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_LIST_BASE_ADDRESS, 0);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_LIST_BASE_ADDRESS, 0);
+
+ /* free all data buffers on TX ring */
+ for (i = 0; i < SBE_2T3E3_TX_DESC_RING_SIZE; i++) {
+ if (sc->ether.tx_data[i] != NULL) {
+ dev_kfree_skb_any(sc->ether.tx_data[i]);
+ sc->ether.tx_data[i] = NULL;
+ }
+ }
+}
+
+void dc_drop_descriptor_list(struct channel *sc)
+{
+ u32 i;
+
+ dc_clear_descriptor_list(sc);
+
+ /* free all data buffers on RX ring */
+ for (i = 0; i < SBE_2T3E3_RX_DESC_RING_SIZE; i++) {
+ if (sc->ether.rx_data[i] != NULL) {
+ dev_kfree_skb_any(sc->ether.rx_data[i]);
+ sc->ether.rx_data[i] = NULL;
+ }
+ }
+
+ if (sc->ether.rx_ring != NULL) {
+#ifdef T3E3_USE_CONTIGMALLOC
+ t3e3_contigmemory_size = SBE_2T3E3_RX_DESC_RING_SIZE *
+ sizeof(t3e3_rx_desc_t);
+#endif
+ kfree(sc->ether.rx_ring);
+ sc->ether.rx_ring = NULL;
+ }
+
+ if (sc->ether.tx_ring != NULL) {
+#ifdef T3E3_USE_CONTIGMALLOC
+ t3e3_contigmemory_size = SBE_2T3E3_TX_DESC_RING_SIZE *
+ sizeof(t3e3_tx_desc_t);
+#endif
+ kfree(sc->ether.tx_ring);
+ sc->ether.tx_ring = NULL;
+ }
+}
+
+
+void dc_set_output_port(struct channel *sc)
+{
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_PORT_SELECT);
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_STATUS, 0x00000301);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY, 0);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_TRANSMIT_AND_RECEIVE, 0);
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_SIA_AND_GENERAL_PURPOSE_PORT, 0x08000011);
+
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_TRANSMIT_THRESHOLD_MODE_100Mbs |
+ SBE_2T3E3_21143_VAL_HEARTBEAT_DISABLE |
+ SBE_2T3E3_21143_VAL_PORT_SELECT |
+ SBE_2T3E3_21143_VAL_FULL_DUPLEX_MODE);
+}
+
+void dc_restart(struct channel *sc)
+{
+ dev_warn(&sc->pdev->dev, "SBE 2T3E3: 21143 restart\n");
+
+ dc_stop(sc);
+ dc_reset(sc);
+ dc_init(sc); /* stop + reset + init */
+ dc_start(sc);
+}
diff --git a/drivers/staging/sbe-2t3e3/exar7250.c b/drivers/staging/sbe-2t3e3/exar7250.c
new file mode 100644
index 000000000000..809f446bdc3a
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/exar7250.c
@@ -0,0 +1,217 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include "2t3e3.h"
+#include "ctrl.h"
+
+void exar7250_init(struct channel *sc)
+{
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
+ SBE_2T3E3_FRAMER_VAL_T3_CBIT |
+ SBE_2T3E3_FRAMER_VAL_INTERRUPT_ENABLE_RESET |
+ SBE_2T3E3_FRAMER_VAL_TIMING_ASYNCH_TXINCLK);
+
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
+ SBE_2T3E3_FRAMER_VAL_DISABLE_TX_LOSS_OF_CLOCK |
+ SBE_2T3E3_FRAMER_VAL_DISABLE_RX_LOSS_OF_CLOCK |
+ SBE_2T3E3_FRAMER_VAL_AMI_LINE_CODE |
+ SBE_2T3E3_FRAMER_VAL_RX_LINE_CLOCK_INVERT);
+
+ exar7250_set_frame_type(sc, SBE_2T3E3_FRAME_TYPE_T3_CBIT);
+}
+
+void exar7250_set_frame_type(struct channel *sc, u32 type)
+{
+ u32 val;
+
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ break;
+ default:
+ return;
+ }
+
+ exar7250_stop_intr(sc, type);
+
+ val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE);
+ val &= ~(SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE |
+ SBE_2T3E3_FRAMER_VAL_T3_E3_SELECT |
+ SBE_2T3E3_FRAMER_VAL_FRAME_FORMAT_SELECT);
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ val |= SBE_2T3E3_FRAMER_VAL_E3_G751;
+ break;
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ val |= SBE_2T3E3_FRAMER_VAL_E3_G832;
+ break;
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ val |= SBE_2T3E3_FRAMER_VAL_T3_CBIT;
+ break;
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ val |= SBE_2T3E3_FRAMER_VAL_T3_M13;
+ break;
+ default:
+ return;
+ }
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE, val);
+ exar7250_start_intr(sc, type);
+}
+
+
+void exar7250_start_intr(struct channel *sc, u32 type)
+{
+ u32 val;
+
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
+#if 0
+ sc->s.LOS = val & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
+#else
+ cpld_LOS_update(sc);
+#endif
+ sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
+ SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE);
+#if 0
+ /*SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE);*/
+#endif
+
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
+#if 0
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2,
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE);
+#endif
+ break;
+
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
+#if 0
+ sc->s.LOS = val & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
+#else
+ cpld_LOS_update(sc);
+#endif
+ sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
+
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
+ SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
+#if 0
+ /* SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE);*/
+#endif
+
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
+#if 0
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS,
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE);
+#endif
+
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
+ break;
+
+ default:
+ return;
+ }
+
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
+ SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE);
+}
+
+
+void exar7250_stop_intr(struct channel *sc, u32 type)
+{
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
+
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_LAPD_CONTROL);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
+ break;
+
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS, 0);
+ exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
+ break;
+ }
+}
+
+
+
+
+void exar7250_unipolar_onoff(struct channel *sc, u32 mode)
+{
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
+ SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
+ break;
+ case SBE_2T3E3_ON:
+ exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_IO_CONTROL,
+ SBE_2T3E3_FRAMER_VAL_UNIPOLAR);
+ break;
+ }
+}
+
+void exar7250_set_loopback(struct channel *sc, u32 mode)
+{
+ switch (mode) {
+ case SBE_2T3E3_FRAMER_VAL_LOOPBACK_OFF:
+ exar7300_clear_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
+ SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
+ break;
+ case SBE_2T3E3_FRAMER_VAL_LOOPBACK_ON:
+ exar7300_set_bit(sc, SBE_2T3E3_FRAMER_REG_OPERATING_MODE,
+ SBE_2T3E3_FRAMER_VAL_LOCAL_LOOPBACK_MODE);
+ break;
+ }
+}
diff --git a/drivers/staging/sbe-2t3e3/exar7300.c b/drivers/staging/sbe-2t3e3/exar7300.c
new file mode 100644
index 000000000000..d10d696cf6fb
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/exar7300.c
@@ -0,0 +1,182 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include "2t3e3.h"
+#include "ctrl.h"
+
+void exar7300_init(struct channel *sc)
+{
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG1, 0);
+
+ /* enable line decodeer and encoder */
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG2, 0);
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG3, 0);
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4,
+ SBE_2T3E3_LIU_VAL_T3_MODE_SELECT |
+ SBE_2T3E3_LIU_VAL_LOOPBACK_OFF);
+}
+
+void exar7300_set_loopback(struct channel *sc, u32 mode)
+{
+ u32 val;
+
+ switch (mode) {
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_OFF:
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE:
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG:
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL:
+ break;
+ default:
+ return;
+ }
+
+ val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4);
+ val &= ~(SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK | SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK);
+ val |= mode;
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val);
+
+#if 0
+ /* TODO - is it necessary? idea from 2T3E3_HW_Test_code */
+ switch (mode) {
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_OFF:
+ break;
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE:
+ exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
+ break;
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG:
+ exar7300_receive_equalization_onoff(sc, SBE_2T3E3_OFF);
+ break;
+ case SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL:
+ exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
+ break;
+ }
+#endif
+}
+
+void exar7300_set_frame_type(struct channel *sc, u32 type)
+{
+ u32 val;
+
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ break;
+ default:
+ return;
+ }
+
+ val = exar7300_read(sc, SBE_2T3E3_LIU_REG_REG4);
+ val &= ~(SBE_2T3E3_LIU_VAL_T3_MODE_SELECT |
+ SBE_2T3E3_LIU_VAL_E3_MODE_SELECT);
+
+ switch (type) {
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ val |= SBE_2T3E3_LIU_VAL_T3_MODE_SELECT;
+ break;
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ val |= SBE_2T3E3_LIU_VAL_E3_MODE_SELECT;
+ break;
+ default:
+ return;
+ }
+
+ exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val);
+}
+
+
+void exar7300_transmit_all_ones_onoff(struct channel *sc, u32 mode)
+{
+ if (sc->p.transmit_all_ones == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_ON:
+ exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES);
+ break;
+ case SBE_2T3E3_OFF:
+ exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_ALL_ONES);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.transmit_all_ones = mode;
+}
+
+void exar7300_receive_equalization_onoff(struct channel *sc, u32 mode)
+{
+ if (sc->p.receive_equalization == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG2,
+ SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE);
+ break;
+ case SBE_2T3E3_ON:
+ exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG2,
+ SBE_2T3E3_LIU_VAL_RECEIVE_EQUALIZATION_DISABLE);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.receive_equalization = mode;
+}
+
+void exar7300_line_build_out_onoff(struct channel *sc, u32 mode)
+{
+ if (sc->p.line_build_out == mode)
+ return;
+
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT);
+ exar7300_receive_equalization_onoff(sc, SBE_2T3E3_OFF);
+ break;
+ case SBE_2T3E3_ON:
+ exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_LEVEL_SELECT);
+ exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
+ break;
+ default:
+ return;
+ }
+
+ sc->p.line_build_out = mode;
+}
+
+/* TODO - what about encoder in raw mode??? disable it too? */
+void exar7300_unipolar_onoff(struct channel *sc, u32 mode)
+{
+ switch (mode) {
+ case SBE_2T3E3_OFF:
+ exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG3,
+ SBE_2T3E3_LIU_VAL_DECODER_DISABLE);
+ exar7300_clear_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA);
+ break;
+ case SBE_2T3E3_ON:
+ exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG3,
+ SBE_2T3E3_LIU_VAL_DECODER_DISABLE);
+ exar7300_set_bit(sc, SBE_2T3E3_LIU_REG_REG1,
+ SBE_2T3E3_LIU_VAL_TRANSMIT_BINARY_DATA);
+ break;
+ }
+}
diff --git a/drivers/staging/sbe-2t3e3/intr.c b/drivers/staging/sbe-2t3e3/intr.c
new file mode 100644
index 000000000000..7ad1a8382037
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/intr.c
@@ -0,0 +1,635 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/hdlc.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include "2t3e3.h"
+
+irqreturn_t t3e3_intr(int irq, void *dev_instance)
+{
+ struct channel *sc = dev_to_priv(dev_instance);
+ u32 val;
+ irqreturn_t ret = IRQ_NONE;
+
+ sc->interrupt_active = 1;
+
+ val = cpld_read(sc, SBE_2T3E3_CPLD_REG_PICSR);
+
+ if (val & SBE_2T3E3_CPLD_VAL_RECEIVE_LOSS_OF_SIGNAL_CHANGE) {
+ dev_dbg(&sc->pdev->dev,
+ "Rx LOS Chng Int r=%02x (LOS|OOF=%02x)\n",
+ val, (sc->s.LOS << 4) | sc->s.OOF);
+ cpld_LOS_update(sc);
+ ret = IRQ_HANDLED;
+ }
+
+ if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ASSERTED) {
+ dc_intr(sc);
+ ret = IRQ_HANDLED;
+ }
+
+ if (val & SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ASSERTED) {
+ exar7250_intr(sc);
+ ret = IRQ_HANDLED;
+ }
+
+ /*
+ we don't care about other interrupt sources (DMO, LOS, LCV) because
+ they are handled by Framer too
+ */
+
+ sc->interrupt_active = 0;
+ return ret;
+}
+
+void dc_intr(struct channel *sc)
+{
+ u32 val;
+
+ /* disable ethernet interrupts */
+ /* grrr this clears interrupt summary bits !!! */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE, 0);
+
+ while ((val = dc_read(sc->addr, SBE_2T3E3_21143_REG_STATUS)) &
+ (SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED |
+ SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
+ SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
+ SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW |
+ SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED |
+ SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)) {
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_STATUS, val);
+
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Ethernet controller interrupt! (CSR5 = %08X)\n",
+ val);
+
+ if (val & (SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT |
+ SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE |
+ SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)) {
+ if (val & SBE_2T3E3_21143_VAL_RECEIVE_INTERRUPT)
+ dev_dbg(&sc->pdev->dev,
+ "Receive interrupt (LOS=%d, OOF=%d)\n",
+ sc->s.LOS, sc->s.OOF);
+ if (val & SBE_2T3E3_21143_VAL_RECEIVE_BUFFER_UNAVAILABLE)
+ dev_dbg(&sc->pdev->dev,
+ "Receive buffer unavailable\n");
+ if (val & SBE_2T3E3_21143_VAL_RECEIVE_PROCESS_STOPPED)
+ dev_dbg(&sc->pdev->dev,
+ "Receive process stopped\n");
+ dc_intr_rx(sc);
+ }
+
+ if (val & SBE_2T3E3_21143_VAL_TRANSMIT_UNDERFLOW) {
+ dev_dbg(&sc->pdev->dev, "Transmit underflow\n");
+ dc_intr_tx_underflow(sc);
+ }
+
+ if (val & (SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE |
+ SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT |
+ SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)) {
+ if (val & SBE_2T3E3_21143_VAL_TRANSMIT_INTERRUPT)
+ dev_dbg(&sc->pdev->dev, "Transmit interrupt\n");
+ if (val & SBE_2T3E3_21143_VAL_TRANSMIT_BUFFER_UNAVAILABLE)
+ dev_dbg(&sc->pdev->dev,
+ "Transmit buffer unavailable\n");
+ if (val & SBE_2T3E3_21143_VAL_TRANSMIT_PROCESS_STOPPED)
+ dev_dbg(&sc->pdev->dev,
+ "Transmit process stopped\n");
+ dc_intr_tx(sc);
+ }
+ }
+
+ /* enable ethernet interrupts */
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_INTERRUPT_ENABLE,
+ sc->ether.interrupt_enable_mask);
+}
+
+void dc_intr_rx(struct channel *sc)
+{
+ u32 current_read;
+ u32 error_mask, error;
+ t3e3_rx_desc_t *current_desc;
+ struct sk_buff *m, *m2;
+ unsigned rcv_len;
+
+ sc->rcv_count++; /* for the activity LED */
+
+ current_read = sc->ether.rx_ring_current_read;
+ dev_dbg(&sc->pdev->dev, "intr_rx current_read = %d\n", current_read);
+
+ /* when ethernet loopback is set, ignore framer signals */
+ if ((sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) && sc->s.OOF) {
+ while (!(sc->ether.rx_ring[current_read].rdes0 &
+ SBE_2T3E3_RX_DESC_21143_OWN)) {
+ current_desc = &sc->ether.rx_ring[current_read];
+ current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
+ SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
+ current_desc->rdes1 |= SBE_2T3E3_MTU;
+ current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
+ current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
+ }
+ sc->ether.rx_ring_current_read = current_read;
+ return;
+ }
+
+ while (!(sc->ether.rx_ring[current_read].rdes0 &
+ SBE_2T3E3_RX_DESC_21143_OWN)) {
+ current_desc = &sc->ether.rx_ring[current_read];
+
+ dev_dbg(&sc->pdev->dev, "rdes0: %08X rdes1: %08X\n",
+ current_desc->rdes0, current_desc->rdes1);
+
+ m = sc->ether.rx_data[current_read];
+ rcv_len = (current_desc->rdes0 & SBE_2T3E3_RX_DESC_FRAME_LENGTH) >>
+ SBE_2T3E3_RX_DESC_FRAME_LENGTH_SHIFT;
+
+ dev_dbg(&sc->pdev->dev, "mbuf was received (mbuf len = %d)\n",
+ rcv_len);
+
+ switch (sc->p.crc) {
+ case SBE_2T3E3_CRC_16:
+ rcv_len -= SBE_2T3E3_CRC16_LENGTH;
+ break;
+ case SBE_2T3E3_CRC_32:
+ rcv_len -= SBE_2T3E3_CRC32_LENGTH;
+ break;
+ default:
+ break;
+ }
+
+ if (current_desc->rdes0 & SBE_2T3E3_RX_DESC_LAST_DESC) {
+
+ /* TODO: is collision possible? */
+ error_mask = SBE_2T3E3_RX_DESC_DESC_ERROR |
+ SBE_2T3E3_RX_DESC_COLLISION_SEEN |
+ SBE_2T3E3_RX_DESC_DRIBBLING_BIT;
+
+ switch (sc->p.frame_mode) {
+ case SBE_2T3E3_FRAME_MODE_HDLC:
+ error_mask |= SBE_2T3E3_RX_DESC_MII_ERROR;
+ if (sc->p.crc == SBE_2T3E3_CRC_32)
+ error_mask |= SBE_2T3E3_RX_DESC_CRC_ERROR;
+ break;
+ case SBE_2T3E3_FRAME_MODE_TRANSPARENT:
+ case SBE_2T3E3_FRAME_MODE_RAW:
+ break;
+ default:
+ error_mask = 0;
+ }
+
+ if (sc->s.LOS) {
+ error_mask &= ~(SBE_2T3E3_RX_DESC_DRIBBLING_BIT ||
+ SBE_2T3E3_RX_DESC_MII_ERROR);
+ }
+
+ error = current_desc->rdes0 & error_mask;
+ if (error) {
+ sc->s.in_errors++;
+ dev_dbg(&sc->pdev->dev,
+ "error interrupt: NO_ERROR_MESSAGE = %d\n",
+ sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES ? 1 : 0);
+
+ current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
+ SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
+ current_desc->rdes1 |= SBE_2T3E3_MTU;
+ current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
+
+ if (error & SBE_2T3E3_RX_DESC_DESC_ERROR) {
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev,
+ "SBE 2T3E3: descriptor error\n");
+ sc->s.in_error_desc++;
+ }
+
+ if (error & SBE_2T3E3_RX_DESC_COLLISION_SEEN) {
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev,
+ "SBE 2T3E3: collision seen\n");
+ sc->s.in_error_coll++;
+ } else {
+ if (error & SBE_2T3E3_RX_DESC_DRIBBLING_BIT) {
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev,
+ "SBE 2T3E3: dribbling bits error\n");
+ sc->s.in_error_drib++;
+ }
+
+ if (error & SBE_2T3E3_RX_DESC_CRC_ERROR) {
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev,
+ "SBE 2T3E3: crc error\n");
+ sc->s.in_error_crc++;
+ }
+ }
+
+ if (error & SBE_2T3E3_RX_DESC_MII_ERROR) {
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: mii error\n");
+ sc->s.in_error_mii++;
+ }
+
+ current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
+ sc->r.flags |= SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
+ continue;
+ }
+ }
+
+ current_desc->rdes1 &= SBE_2T3E3_RX_DESC_END_OF_RING |
+ SBE_2T3E3_RX_DESC_SECOND_ADDRESS_CHAINED;
+ current_desc->rdes1 |= SBE_2T3E3_MTU;
+
+ if (rcv_len > 1600) {
+ sc->s.in_errors++;
+ sc->s.in_dropped++;
+ if (!(sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES))
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: oversized rx: rdes0 = %08X\n",
+ current_desc->rdes0);
+ } else {
+ m2 = dev_alloc_skb(MCLBYTES);
+ if (m2 != NULL) {
+ current_desc->rdes2 = virt_to_phys(m2->data);
+ sc->ether.rx_data[current_read] = m2;
+ sc->s.in_packets++;
+ sc->s.in_bytes += rcv_len;
+ m->dev = sc->dev;
+ skb_put(m, rcv_len);
+ skb_reset_mac_header(m);
+ m->protocol = hdlc_type_trans(m, m->dev);
+ netif_rx(m);
+
+ /* good packet was received so we will show error messages again... */
+ if (sc->r.flags & SBE_2T3E3_FLAG_NO_ERROR_MESSAGES) {
+ dev_dbg(&sc->pdev->dev,
+ "setting ERROR_MESSAGES->0\n");
+ sc->r.flags &= ~SBE_2T3E3_FLAG_NO_ERROR_MESSAGES;
+ }
+
+ } else {
+ sc->s.in_errors++;
+ sc->s.in_dropped++;
+ }
+ }
+ current_desc->rdes0 = SBE_2T3E3_RX_DESC_21143_OWN;
+ current_read = (current_read + 1) % SBE_2T3E3_RX_DESC_RING_SIZE;
+ }
+
+ sc->ether.rx_ring_current_read = current_read;
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_RECEIVE_POLL_DEMAND, 0xFFFFFFFF);
+}
+
+void dc_intr_tx(struct channel *sc)
+{
+ u32 current_read, current_write;
+ u32 last_segment, error;
+ t3e3_tx_desc_t *current_desc;
+
+ spin_lock(&sc->ether.tx_lock);
+
+ current_read = sc->ether.tx_ring_current_read;
+ current_write = sc->ether.tx_ring_current_write;
+
+ while (current_read != current_write) {
+ current_desc = &sc->ether.tx_ring[current_read];
+
+ if (current_desc->tdes0 & SBE_2T3E3_RX_DESC_21143_OWN)
+ break;
+
+ dev_dbg(&sc->pdev->dev,
+ "txeof: tdes0 = %08X tdes1 = %08X\n",
+ current_desc->tdes0, current_desc->tdes1);
+
+ error = current_desc->tdes0 & (SBE_2T3E3_TX_DESC_ERROR_SUMMARY |
+ SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT |
+ SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER |
+ SBE_2T3E3_TX_DESC_NO_CARRIER |
+ SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT |
+ SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR |
+ SBE_2T3E3_TX_DESC_DEFFERED);
+
+ last_segment = current_desc->tdes1 & SBE_2T3E3_TX_DESC_LAST_SEGMENT;
+
+ current_desc->tdes0 = 0;
+ current_desc->tdes1 &= SBE_2T3E3_TX_DESC_END_OF_RING |
+ SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED;
+ current_desc->tdes2 = 0;
+ sc->ether.tx_free_cnt++;
+
+ if (last_segment != SBE_2T3E3_TX_DESC_LAST_SEGMENT) {
+ current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
+ continue;
+ }
+
+
+ if (sc->ether.tx_data[current_read]) {
+ sc->s.out_packets++;
+ sc->s.out_bytes += sc->ether.tx_data[current_read]->len;
+ dev_kfree_skb_any(sc->ether.tx_data[current_read]);
+ sc->ether.tx_data[current_read] = NULL;
+ }
+
+ if (error > 0) {
+ sc->s.out_errors++;
+
+ if (error & SBE_2T3E3_TX_DESC_TRANSMIT_JABBER_TIMEOUT) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: transmit jabber timeout\n");
+ sc->s.out_error_jab++;
+ }
+
+ if (sc->p.loopback != SBE_2T3E3_LOOPBACK_ETHERNET) {
+ if (error & SBE_2T3E3_TX_DESC_LOSS_OF_CARRIER) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: loss of carrier\n");
+ sc->s.out_error_lost_carr++;
+ }
+
+ if (error & SBE_2T3E3_TX_DESC_NO_CARRIER) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: no carrier\n");
+ sc->s.out_error_no_carr++;
+ }
+ }
+
+ if (error & SBE_2T3E3_TX_DESC_LINK_FAIL_REPORT) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: link fail report\n");
+ sc->s.out_error_link_fail++;
+ }
+
+ if (error & SBE_2T3E3_TX_DESC_UNDERFLOW_ERROR) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3:"
+ " transmission underflow error\n");
+ sc->s.out_error_underflow++;
+ spin_unlock(&sc->ether.tx_lock);
+
+ dc_restart(sc);
+ return;
+ }
+
+ if (error & SBE_2T3E3_TX_DESC_DEFFERED) {
+ dev_err(&sc->pdev->dev, "SBE 2T3E3: transmission deferred\n");
+ sc->s.out_error_dereferred++;
+ }
+ }
+
+ current_read = (current_read + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
+ }
+
+ sc->ether.tx_ring_current_read = current_read;
+
+ /* Relieve flow control when the TX queue is drained at least half way */
+ if (sc->ether.tx_full &&
+ (sc->ether.tx_free_cnt >= (SBE_2T3E3_TX_DESC_RING_SIZE / 2))) {
+ sc->ether.tx_full = 0;
+ netif_wake_queue(sc->dev);
+ }
+ spin_unlock(&sc->ether.tx_lock);
+}
+
+
+void dc_intr_tx_underflow(struct channel *sc)
+{
+ u32 val;
+
+ dc_transmitter_onoff(sc, SBE_2T3E3_OFF);
+
+ val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE);
+ dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS);
+
+ switch (val & SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS) {
+ case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_1:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2);
+ break;
+ case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_2:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3);
+ break;
+ case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_3:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4);
+ break;
+ case SBE_2T3E3_21143_VAL_THRESHOLD_CONTROL_BITS_4:
+ default:
+ dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE,
+ SBE_2T3E3_21143_VAL_STORE_AND_FORWARD);
+ break;
+ }
+
+ dc_transmitter_onoff(sc, SBE_2T3E3_ON);
+}
+
+
+
+
+void exar7250_intr(struct channel *sc)
+{
+ u32 status, old_OOF;
+
+#if 0
+ /* disable interrupts */
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
+#endif
+
+ old_OOF = sc->s.OOF;
+
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt! (REG[0x05] = %02X)\n", status);
+
+ switch (sc->p.frame_type) {
+ case SBE_2T3E3_FRAME_TYPE_E3_G751:
+ case SBE_2T3E3_FRAME_TYPE_E3_G832:
+ exar7250_E3_intr(sc, status);
+ break;
+
+ case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
+ case SBE_2T3E3_FRAME_TYPE_T3_M13:
+ exar7250_T3_intr(sc, status);
+ break;
+
+ default:
+ break;
+ }
+
+ if (sc->s.OOF != old_OOF) {
+ if (sc->s.OOF) {
+ if (sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) {
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Disabling eth interrupts\n");
+ /* turn off ethernet interrupts */
+ dc_stop_intr(sc);
+ }
+ } else if (sc->r.flags & SBE_2T3E3_FLAG_NETWORK_UP) {
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Enabling eth interrupts\n");
+ /* start interrupts */
+ sc->s.OOF = 1;
+ dc_intr_rx(sc);
+ sc->s.OOF = 0;
+ if (sc->p.receiver_on) {
+ dc_receiver_onoff(sc, SBE_2T3E3_OFF);
+ dc_receiver_onoff(sc, SBE_2T3E3_ON);
+ }
+ dc_start_intr(sc);
+ }
+ }
+#if 0
+ /* reenable interrupts */
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
+ SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE
+ );
+#endif
+}
+
+
+void exar7250_T3_intr(struct channel *sc, u32 block_status)
+{
+ u32 status, result;
+
+ if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
+
+ if (status) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt T3 RX (REG[0x13] = %02X)\n",
+ status);
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
+
+#if 0
+ if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt T3: LOS\n");
+ sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
+
+ }
+#else
+ cpld_LOS_update(sc);
+#endif
+ if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS) {
+ sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt T3: OOF (%d)\n",
+ sc->s.OOF);
+ }
+
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
+ SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
+#if 0
+ SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE
+#endif
+ }
+
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
+ if (status) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt T3 RX (REG[0x17] = %02X)\n",
+ status);
+#if 0
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS,
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE
+ );
+#endif
+ }
+
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
+ if (status)
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt T3 RX (REG[0x18] = %02X)\n",
+ status);
+ }
+
+
+ if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_FEAC_CONFIGURATION_STATUS);
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x31] = %02X)\n",
+ status);
+
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_TX_LAPD_STATUS);
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt T3 TX (REG[0x34] = %02X)\n",
+ status);
+ }
+}
+
+
+void exar7250_E3_intr(struct channel *sc, u32 block_status)
+{
+ u32 status, result;
+
+ if (block_status & SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_STATUS) {
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
+
+ if (status) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt E3 RX (REG[0x14] = %02X)\n",
+ status);
+
+ result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
+
+#if 0
+ if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt E3: LOS\n");
+ sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
+ }
+#else
+ cpld_LOS_update(sc);
+#endif
+ if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS) {
+ sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt E3: OOF (%d)\n",
+ sc->s.OOF);
+ }
+
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
+ SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE
+ );
+#if 0
+ SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE
+#endif
+ }
+
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
+ if (status) {
+ dev_dbg(&sc->pdev->dev,
+ "Framer interrupt E3 RX (REG[0x15] = %02X)\n",
+ status);
+
+#if 0
+ exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2,
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE |
+ SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE);
+#endif
+ }
+
+ }
+
+ if (block_status & SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_STATUS) {
+ status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_TX_LAPD_STATUS);
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: Framer interrupt E3 TX (REG[0x34] = %02X)\n",
+ status);
+ }
+}
diff --git a/drivers/staging/sbe-2t3e3/io.c b/drivers/staging/sbe-2t3e3/io.c
new file mode 100644
index 000000000000..b458ff034067
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/io.c
@@ -0,0 +1,352 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/ip.h>
+#include <asm/system.h>
+#include "2t3e3.h"
+#include "ctrl.h"
+
+/* All access to registers done via the 21143 on port 0 must be
+ * protected via the card->bootrom_lock. */
+
+/* priviate define to be used here only - must be protected by card->bootrom_lock */
+#define cpld_write_nolock(channel, reg, val) \
+ bootrom_write((channel), CPLD_MAP_REG(reg, channel), val)
+
+u32 cpld_read(struct channel *channel, u32 reg)
+{
+ unsigned long flags;
+ u32 val;
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+ val = bootrom_read((channel), CPLD_MAP_REG(reg, channel));
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+ return val;
+}
+
+/****************************************
+ * Access via BootROM port
+ ****************************************/
+
+u32 bootrom_read(struct channel *channel, u32 reg)
+{
+ unsigned long addr = channel->card->bootrom_addr;
+ u32 result;
+
+ /* select BootROM address */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF);
+
+ /* select reading from BootROM */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT);
+
+ udelay(2); /* 20 PCI cycles */
+
+ /* read from BootROM */
+ result = dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) & 0xff;
+
+ /* reset CSR9 */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
+
+ return result;
+}
+
+void bootrom_write(struct channel *channel, u32 reg, u32 val)
+{
+ unsigned long addr = channel->card->bootrom_addr;
+
+ /* select BootROM address */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_PROGRAMMING_ADDRESS, reg & 0x3FFFF);
+
+ /* select writting to BootROM */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_BOOT_ROM_SELECT |
+ (val & 0xff));
+
+ udelay(2); /* 20 PCI cycles */
+
+ /* reset CSR9 */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
+}
+
+
+/****************************************
+ * Access via Serial I/O port
+ ****************************************/
+
+static u32 serialrom_read_bit(struct channel *channel)
+{
+ unsigned long addr = channel->card->bootrom_addr;
+ u32 bit;
+
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock high */
+
+ bit = (dc_read(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT) &
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_DATA_OUT) > 0 ? 1 : 0;
+
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+
+ return bit;
+}
+
+static void serialrom_write_bit(struct channel *channel, u32 bit)
+{
+ unsigned long addr = channel->card->bootrom_addr;
+ u32 lastbit = -1;
+
+ bit &= 1;
+
+ if (bit != lastbit) {
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
+ (bit << 2)); /* clock low */
+
+ lastbit = bit;
+ }
+
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CLOCK |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
+ (bit << 2)); /* clock high */
+
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT |
+ (bit << 2)); /* clock low */
+}
+
+/****************************************
+ * Access to SerialROM (eeprom)
+ ****************************************/
+
+u32 t3e3_eeprom_read_word(struct channel *channel, u32 address)
+{
+ unsigned long addr = channel->card->bootrom_addr;
+ u32 i, val;
+ unsigned long flags;
+
+ address &= 0x3f;
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+
+ /* select correct Serial Chip */
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
+ SBE_2T3E3_CPLD_VAL_EEPROM_SELECT);
+
+ /* select reading from Serial I/O Bus */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+
+ /* select read operation */
+ serialrom_write_bit(channel, 0);
+ serialrom_write_bit(channel, 1);
+ serialrom_write_bit(channel, 1);
+ serialrom_write_bit(channel, 0);
+
+ for (i = 0x20; i; i >>= 1)
+ serialrom_write_bit(channel, address & i ? 1 : 0);
+
+ val = 0;
+ for (i = 0x8000; i; i >>= 1)
+ val |= (serialrom_read_bit(channel) ? i : 0);
+
+ /* Reset 21143's CSR9 */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
+
+ /* Unselect Serial Chip */
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
+
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+
+ return ntohs(val);
+}
+
+
+/****************************************
+ * Access to Framer
+ ****************************************/
+
+u32 exar7250_read(struct channel *channel, u32 reg)
+{
+ u32 result;
+ unsigned long flags;
+
+#if 0
+ switch (reg) {
+ case SBE_2T3E3_FRAMER_REG_OPERATING_MODE:
+ return channel->framer_regs[reg];
+ break;
+ default:
+ }
+#endif
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+
+ result = bootrom_read(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS]
+ [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2));
+
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+
+ return result;
+}
+
+void exar7250_write(struct channel *channel, u32 reg, u32 val)
+{
+ unsigned long flags;
+
+ val &= 0xff;
+ channel->framer_regs[reg] = val;
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+
+ bootrom_write(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS]
+ [channel->h.slot] + (t3e3_framer_reg_map[reg] << 2), val);
+
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+}
+
+
+/****************************************
+ * Access to LIU
+ ****************************************/
+
+u32 exar7300_read(struct channel *channel, u32 reg)
+{
+ unsigned long addr = channel->card->bootrom_addr, flags;
+ u32 i, val;
+
+#if 0
+ switch (reg) {
+ case SBE_2T3E3_LIU_REG_REG1:
+ case SBE_2T3E3_LIU_REG_REG2:
+ case SBE_2T3E3_LIU_REG_REG3:
+ case SBE_2T3E3_LIU_REG_REG4:
+ return channel->liu_regs[reg];
+ break;
+ default:
+ }
+#endif
+
+ /* select correct Serial Chip */
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
+ cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]);
+
+ /* select reading from Serial I/O Bus */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+
+ /* select read operation */
+ serialrom_write_bit(channel, 1);
+
+ /* Exar7300 register address is 4 bit long */
+ reg = t3e3_liu_reg_map[reg];
+ for (i = 0; i < 4; i++, reg >>= 1) /* 4 bits of SerialROM address */
+ serialrom_write_bit(channel, reg & 1);
+ for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */
+ serialrom_write_bit(channel, 0);
+
+ val = 0; /* Exar7300 register value is 5 bit long */
+ for (i = 0; i < 8; i++) /* 8 bits of SerialROM value */
+ val += (serialrom_read_bit(channel) << i);
+
+ /* Reset 21143's CSR9 */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_READ_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
+
+ /* Unselect Serial Chip */
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
+
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+
+ return val;
+}
+
+void exar7300_write(struct channel *channel, u32 reg, u32 val)
+{
+ unsigned long addr = channel->card->bootrom_addr, flags;
+ u32 i;
+
+ channel->liu_regs[reg] = val;
+
+ /* select correct Serial Chip */
+
+ spin_lock_irqsave(&channel->card->bootrom_lock, flags);
+
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT,
+ cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_SELECT][channel->h.slot]);
+
+ /* select writting to Serial I/O Bus */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+
+ /* select write operation */
+ serialrom_write_bit(channel, 0);
+
+ /* Exar7300 register address is 4 bit long */
+ reg = t3e3_liu_reg_map[reg];
+ for (i = 0; i < 4; i++) { /* 4 bits */
+ serialrom_write_bit(channel, reg & 1);
+ reg >>= 1;
+ }
+ for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM address */
+ serialrom_write_bit(channel, 0);
+
+ /* Exar7300 register value is 5 bit long */
+ for (i = 0; i < 5; i++) {
+ serialrom_write_bit(channel, val & 1);
+ val >>= 1;
+ }
+ for (i = 0; i < 3; i++) /* remaining 3 bits of SerialROM value */
+ serialrom_write_bit(channel, 0);
+
+ /* Reset 21143_CSR9 */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT,
+ SBE_2T3E3_21143_VAL_WRITE_OPERATION |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_SELECT |
+ SBE_2T3E3_21143_VAL_SERIAL_ROM_CHIP_SELECT); /* clock low */
+ dc_write(addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, 0);
+
+ /* Unselect Serial Chip */
+ cpld_write_nolock(channel, SBE_2T3E3_CPLD_REG_SERIAL_CHIP_SELECT, 0);
+
+ spin_unlock_irqrestore(&channel->card->bootrom_lock, flags);
+}
diff --git a/drivers/staging/sbe-2t3e3/main.c b/drivers/staging/sbe-2t3e3/main.c
new file mode 100644
index 000000000000..f3dbef6b0eef
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/main.c
@@ -0,0 +1,171 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include "2t3e3.h"
+
+void t3e3_init(struct channel *sc)
+{
+ cpld_init(sc);
+ dc_reset(sc);
+ dc_init(sc);
+ exar7250_init(sc);
+ exar7300_init(sc);
+}
+
+int t3e3_if_start_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct channel *sc = dev_to_priv(dev);
+ u32 current_write, last_write;
+ unsigned long flags;
+ struct sk_buff *skb2;
+
+ if (skb == NULL) {
+ sc->s.out_errors++;
+ return 0;
+ }
+
+ if (sc->p.transmitter_on != SBE_2T3E3_ON) {
+ sc->s.out_errors++;
+ sc->s.out_dropped++;
+ dev_kfree_skb_any(skb);
+ return 0;
+ }
+
+ if (sc->s.OOF && sc->p.loopback == SBE_2T3E3_LOOPBACK_NONE) {
+ sc->s.out_dropped++;
+ dev_kfree_skb_any(skb);
+ return 0;
+ }
+
+ spin_lock_irqsave(&sc->ether.tx_lock, flags);
+
+ current_write = sc->ether.tx_ring_current_write;
+ for (skb2 = skb; skb2 != NULL; skb2 = NULL) {
+ if (skb2->len) {
+ if ((sc->ether.tx_ring[current_write].tdes1 &
+ SBE_2T3E3_TX_DESC_BUFFER_1_SIZE) > 0)
+ break;
+ current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
+ /*
+ * Leave at least 1 tx desc free so that dc_intr_tx() can
+ * identify empty list
+ */
+ if (current_write == sc->ether.tx_ring_current_read)
+ break;
+ }
+ }
+ if (skb2 != NULL) {
+ netif_stop_queue(sc->dev);
+ sc->ether.tx_full = 1;
+ dev_dbg(&sc->pdev->dev, "SBE 2T3E3: out of descriptors\n");
+ spin_unlock_irqrestore(&sc->ether.tx_lock, flags);
+ return NETDEV_TX_BUSY;
+ }
+
+ current_write = last_write = sc->ether.tx_ring_current_write;
+ dev_dbg(&sc->pdev->dev, "sending mbuf (current_write = %d)\n",
+ current_write);
+
+ for (skb2 = skb; skb2 != NULL; skb2 = NULL) {
+ if (skb2->len) {
+ dev_dbg(&sc->pdev->dev,
+ "sending mbuf (len = %d, next = %p)\n",
+ skb2->len, NULL);
+
+ sc->ether.tx_free_cnt--;
+ sc->ether.tx_ring[current_write].tdes0 = 0;
+ sc->ether.tx_ring[current_write].tdes1 &=
+ SBE_2T3E3_TX_DESC_END_OF_RING |
+ SBE_2T3E3_TX_DESC_SECOND_ADDRESS_CHAINED;
+/* DISABLE_PADDING sometimes gets lost somehow, hands off... */
+ sc->ether.tx_ring[current_write].tdes1 |=
+ SBE_2T3E3_TX_DESC_DISABLE_PADDING | skb2->len;
+
+ if (current_write == sc->ether.tx_ring_current_write) {
+ sc->ether.tx_ring[current_write].tdes1 |=
+ SBE_2T3E3_TX_DESC_FIRST_SEGMENT;
+ } else {
+ sc->ether.tx_ring[current_write].tdes0 =
+ SBE_2T3E3_TX_DESC_21143_OWN;
+ }
+
+ sc->ether.tx_ring[current_write].tdes2 = virt_to_phys(skb2->data);
+ sc->ether.tx_data[current_write] = NULL;
+
+ last_write = current_write;
+ current_write = (current_write + 1) % SBE_2T3E3_TX_DESC_RING_SIZE;
+ }
+ }
+
+ sc->ether.tx_data[last_write] = skb;
+ sc->ether.tx_ring[last_write].tdes1 |=
+ SBE_2T3E3_TX_DESC_LAST_SEGMENT |
+ SBE_2T3E3_TX_DESC_INTERRUPT_ON_COMPLETION;
+ sc->ether.tx_ring[sc->ether.tx_ring_current_write].tdes0 |=
+ SBE_2T3E3_TX_DESC_21143_OWN;
+ sc->ether.tx_ring_current_write = current_write;
+
+ dev_dbg(&sc->pdev->dev, "txput: tdes0 = %08X tdes1 = %08X\n",
+ sc->ether.tx_ring[last_write].tdes0,
+ sc->ether.tx_ring[last_write].tdes1);
+
+ dc_write(sc->addr, SBE_2T3E3_21143_REG_TRANSMIT_POLL_DEMAND,
+ 0xffffffff);
+
+ spin_unlock_irqrestore(&sc->ether.tx_lock, flags);
+ return 0;
+}
+
+
+void t3e3_read_card_serial_number(struct channel *sc)
+{
+ u32 i;
+
+ for (i = 0; i < 3; i++)
+ sc->ether.card_serial_number[i] = t3e3_eeprom_read_word(sc, 10 + i);
+
+ printk(KERN_INFO "SBE wanPMC-2T3E3 serial number: %04X%04X%04X\n",
+ sc->ether.card_serial_number[0], sc->ether.card_serial_number[1],
+ sc->ether.card_serial_number[2]);
+}
+
+/*
+ bit 0 led1 (green)
+ bit 1 led1 (yellow)
+
+ bit 2 led2 (green)
+ bit 3 led2 (yellow)
+
+ bit 4 led3 (green)
+ bit 5 led3 (yellow)
+
+ bit 6 led4 (green)
+ bit 7 led4 (yellow)
+*/
+
+void update_led(struct channel *sc, int blinker)
+{
+ int leds;
+ if (sc->s.LOS)
+ leds = 0; /* led1 = off */
+ else if (sc->s.OOF)
+ leds = 2; /* led1 = yellow */
+ else if ((blinker & 1) && sc->rcv_count) {
+ leds = 0; /* led1 = off */
+ sc->rcv_count = 0;
+ } else
+ leds = 1; /* led1 = green */
+ cpld_write(sc, SBE_2T3E3_CPLD_REG_LEDR, leds);
+ sc->leds = leds;
+}
diff --git a/drivers/staging/sbe-2t3e3/maps.c b/drivers/staging/sbe-2t3e3/maps.c
new file mode 100644
index 000000000000..7084fbe7b794
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/maps.c
@@ -0,0 +1,104 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/kernel.h>
+#include "2t3e3.h"
+
+const u32 cpld_reg_map[][2] =
+{
+ { 0x0000, 0x0080 }, /* 0 - Port Control Register A (PCRA) */
+ { 0x0004, 0x0084 }, /* 1 - Port Control Register B (PCRB) */
+ { 0x0008, 0x0088 }, /* 2 - LCV Count Register (PLCR) */
+ { 0x000c, 0x008c }, /* 3 - LCV Threshold register (PLTR) */
+ { 0x0010, 0x0090 }, /* 4 - Payload Fill Register (PPFR) */
+ { 0x0200, 0x0200 }, /* 5 - Board ID / FPGA Programming Status Register */
+ { 0x0204, 0x0204 }, /* 6 - FPGA Version Register */
+ { 0x0800, 0x1000 }, /* 7 - Framer Registers Base Address */
+ { 0x2000, 0x2000 }, /* 8 - Serial Chip Select Register */
+ { 0x2004, 0x2004 }, /* 9 - Static Reset Register */
+ { 0x2008, 0x2008 }, /* 10 - Pulse Reset Register */
+ { 0x200c, 0x200c }, /* 11 - FPGA Reconfiguration Register */
+ { 0x2010, 0x2014 }, /* 12 - LED Register (LEDR) */
+ { 0x2018, 0x201c }, /* 13 - LIU Control and Status Register (PISCR) */
+ { 0x2020, 0x2024 }, /* 14 - Interrupt Enable Register (PIER) */
+ { 0x0068, 0x00e8 }, /* 15 - Port Control Register C (PCRC) */
+ { 0x006c, 0x00ec }, /* 16 - Port Bandwidth Start (PBWF) */
+ { 0x0070, 0x00f0 }, /* 17 - Port Bandwidth Stop (PBWL) */
+};
+
+const u32 cpld_val_map[][2] =
+{
+ { 0x01, 0x02 }, /* LIU1 / LIU2 select for Serial Chip Select */
+ { 0x04, 0x08 }, /* DAC1 / DAC2 select for Serial Chip Select */
+ { 0x00, 0x04 }, /* LOOP1 / LOOP2 - select of loop timing source */
+ { 0x01, 0x02 } /* PORT1 / PORT2 - select LIU and Framer for reset */
+};
+
+const u32 t3e3_framer_reg_map[] = {
+ 0x00, /* 0 - OPERATING_MODE */
+ 0x01, /* 1 - IO_CONTROL */
+ 0x04, /* 2 - BLOCK_INTERRUPT_ENABLE */
+ 0x05, /* 3 - BLOCK_INTERRUPT_STATUS */
+ 0x10, /* 4 - T3_RX_CONFIGURATION_STATUS, E3_RX_CONFIGURATION_STATUS_1 */
+ 0x11, /* 5 - T3_RX_STATUS, E3_RX_CONFIGURATION_STATUS_2 */
+ 0x12, /* 6 - T3_RX_INTERRUPT_ENABLE, E3_RX_INTERRUPT_ENABLE_1 */
+ 0x13, /* 7 - T3_RX_INTERRUPT_STATUS, E3_RX_INTERRUPT_ENABLE_2 */
+ 0x14, /* 8 - T3_RX_SYNC_DETECT_ENABLE, E3_RX_INTERRUPT_STATUS_1 */
+ 0x15, /* 9 - E3_RX_INTERRUPT_STATUS_2 */
+ 0x16, /* 10 - T3_RX_FEAC */
+ 0x17, /* 11 - T3_RX_FEAC_INTERRUPT_ENABLE_STATUS */
+ 0x18, /* 12 - T3_RX_LAPD_CONTROL, E3_RX_LAPD_CONTROL */
+ 0x19, /* 13 - T3_RX_LAPD_STATUS, E3_RX_LAPD_STATUS */
+ 0x1a, /* 14 - E3_RX_NR_BYTE, E3_RX_SERVICE_BITS */
+ 0x1b, /* 15 - E3_RX_GC_BYTE */
+ 0x30, /* 16 - T3_TX_CONFIGURATION, E3_TX_CONFIGURATION */
+ 0x31, /* 17 - T3_TX_FEAC_CONFIGURATION_STATUS */
+ 0x32, /* 18 - T3_TX_FEAC */
+ 0x33, /* 19 - T3_TX_LAPD_CONFIGURATION, E3_TX_LAPD_CONFIGURATION */
+ 0x34, /* 20 - T3_TX_LAPD_STATUS, E3_TX_LAPD_STATUS_INTERRUPT */
+ 0x35, /* 21 - T3_TX_MBIT_MASK, E3_TX_GC_BYTE, E3_TX_SERVICE_BITS */
+ 0x36, /* 22 - T3_TX_FBIT_MASK, E3_TX_MA_BYTE */
+ 0x37, /* 23 - T3_TX_FBIT_MASK_2, E3_TX_NR_BYTE */
+ 0x38, /* 24 - T3_TX_FBIT_MASK_3 */
+ 0x48, /* 25 - E3_TX_FA1_ERROR_MASK, E3_TX_FAS_ERROR_MASK_UPPER */
+ 0x49, /* 26 - E3_TX_FA2_ERROR_MASK, E3_TX_FAS_ERROR_MASK_LOWER */
+ 0x4a, /* 27 - E3_TX_BIP8_MASK, E3_TX_BIP4_MASK */
+ 0x50, /* 28 - PMON_LCV_EVENT_COUNT_MSB */
+ 0x51, /* 29 - PMON_LCV_EVENT_COUNT_LSB */
+ 0x52, /* 30 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_MSB */
+ 0x53, /* 31 - PMON_FRAMING_BIT_ERROR_EVENT_COUNT_LSB */
+ 0x54, /* 32 - PMON_PARITY_ERROR_EVENT_COUNT_MSB */
+ 0x55, /* 33 - PMON_PARITY_ERROR_EVENT_COUNT_LSB */
+ 0x56, /* 34 - PMON_FEBE_EVENT_COUNT_MSB */
+ 0x57, /* 35 - PMON_FEBE_EVENT_COUNT_LSB */
+ 0x58, /* 36 - PMON_CP_BIT_ERROR_EVENT_COUNT_MSB */
+ 0x59, /* 37 - PMON_CP_BIT_ERROR_EVENT_COUNT_LSB */
+ 0x6c, /* 38 - PMON_HOLDING_REGISTER */
+ 0x6d, /* 39 - ONE_SECOND_ERROR_STATUS */
+ 0x6e, /* 40 - LCV_ONE_SECOND_ACCUMULATOR_MSB */
+ 0x6f, /* 41 - LCV_ONE_SECOND_ACCUMULATOR_LSB */
+ 0x70, /* 42 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_MSB */
+ 0x71, /* 43 - FRAME_PARITY_ERROR_ONE_SECOND_ACCUMULATOR_LSB */
+ 0x72, /* 44 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_MSB */
+ 0x73, /* 45 - FRAME_CP_BIT_ERROR_ONE_SECOND_ACCUMULATOR_LSB */
+ 0x80, /* 46 - LINE_INTERFACE_DRIVE */
+ 0x81 /* 47 - LINE_INTERFACE_SCAN */
+};
+
+const u32 t3e3_liu_reg_map[] =
+{
+ 0x00, /* REG0 */
+ 0x01, /* REG1 */
+ 0x02, /* REG2 */
+ 0x03, /* REG3 */
+ 0x04 /* REG4 */
+};
diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c
new file mode 100644
index 000000000000..e87fe81f6bb3
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/module.c
@@ -0,0 +1,210 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/hdlc.h>
+#include <linux/if_arp.h>
+#include <linux/interrupt.h>
+#include "2t3e3.h"
+
+static void check_leds(unsigned long arg)
+{
+ struct card *card = (struct card *)arg;
+ struct channel *channel0 = &card->channels[0];
+ static int blinker;
+
+ update_led(channel0, ++blinker);
+ if (has_two_ports(channel0->pdev))
+ update_led(&card->channels[1], blinker);
+
+ card->timer.expires = jiffies + HZ / 10;
+ add_timer(&card->timer);
+}
+
+static void t3e3_remove_channel(struct channel *channel)
+{
+ struct pci_dev *pdev = channel->pdev;
+ struct net_device *dev = channel->dev;
+
+ /* system hangs if board asserts irq while module is unloaded */
+ cpld_stop_intr(channel);
+ free_irq(dev->irq, dev);
+ dc_drop_descriptor_list(channel);
+ unregister_hdlc_device(dev);
+ free_netdev(dev);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+}
+
+static int __devinit t3e3_init_channel(struct channel *channel, struct pci_dev *pdev, struct card *card)
+{
+ struct net_device *dev;
+ unsigned int val;
+ int err;
+
+ err = pci_enable_device(pdev);
+ if (err)
+ return err;
+
+ err = pci_request_regions(pdev, "SBE 2T3E3");
+ if (err)
+ goto disable;
+
+ dev = alloc_hdlcdev(channel);
+ if (!dev) {
+ printk(KERN_ERR "SBE 2T3E3" ": Out of memory\n");
+ goto free_regions;
+ }
+
+ t3e3_sc_init(channel);
+ dev_to_priv(dev) = channel;
+
+ channel->pdev = pdev;
+ channel->dev = dev;
+ channel->card = card;
+ channel->addr = pci_resource_start(pdev, 0);
+ if (pdev->subsystem_device == PCI_SUBDEVICE_ID_SBE_2T3E3_P1)
+ channel->h.slot = 1;
+ else
+ channel->h.slot = 0;
+
+ if (setup_device(dev, channel))
+ goto free_regions;
+
+ pci_read_config_dword(channel->pdev, 0x40, &val); /* mask sleep mode */
+ pci_write_config_dword(channel->pdev, 0x40, val & 0x3FFFFFFF);
+
+ pci_read_config_byte(channel->pdev, PCI_CACHE_LINE_SIZE, &channel->h.cache_size);
+ pci_read_config_dword(channel->pdev, PCI_COMMAND, &channel->h.command);
+ t3e3_init(channel);
+
+ if (request_irq(dev->irq, &t3e3_intr, IRQF_SHARED, dev->name, dev)) {
+ printk(KERN_WARNING "%s: could not get irq: %d\n", dev->name, dev->irq);
+ goto free_regions;
+ }
+
+ pci_set_drvdata(pdev, channel);
+ return 0;
+
+free_regions:
+ pci_release_regions(pdev);
+disable:
+ pci_disable_device(pdev);
+ return err;
+}
+
+static void __devexit t3e3_remove_card(struct pci_dev *pdev)
+{
+ struct channel *channel0 = pci_get_drvdata(pdev);
+ struct card *card = channel0->card;
+
+ del_timer(&card->timer);
+ if (has_two_ports(channel0->pdev)) {
+ t3e3_remove_channel(&card->channels[1]);
+ pci_dev_put(card->channels[1].pdev);
+ }
+ t3e3_remove_channel(channel0);
+ kfree(card);
+}
+
+static int __devinit t3e3_init_card(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ /* pdev points to channel #0 */
+ struct pci_dev *pdev1 = NULL;
+ struct card *card;
+ int channels = 1, err;
+
+ if (has_two_ports(pdev)) {
+ while ((pdev1 = pci_get_subsys(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
+ PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P1,
+ pdev1)))
+ if (pdev1->bus == pdev->bus &&
+ pdev1->devfn == pdev->devfn + 8 /* next device on the same bus */)
+ break; /* found the second channel */
+
+ if (!pdev1) {
+ printk(KERN_ERR "SBE 2T3E3" ": Can't find the second channel\n");
+ return -EFAULT;
+ }
+ channels = 2;
+ /* holds the reference for pdev1 */
+ }
+
+ card = kzalloc(sizeof(struct card) + channels * sizeof(struct channel), GFP_KERNEL);
+ if (!card) {
+ printk(KERN_ERR "SBE 2T3E3" ": Out of memory\n");
+ return -ENOBUFS;
+ }
+
+ spin_lock_init(&card->bootrom_lock);
+ card->bootrom_addr = pci_resource_start(pdev, 0);
+
+ err = t3e3_init_channel(&card->channels[0], pdev, card);
+ if (err)
+ goto free_card;
+
+ if (channels == 2) {
+ err = t3e3_init_channel(&card->channels[1], pdev1, card);
+ if (err) {
+ t3e3_remove_channel(&card->channels[0]);
+ goto free_card;
+ }
+ }
+
+ /* start LED timer */
+ init_timer(&card->timer);
+ card->timer.function = check_leds;
+ card->timer.expires = jiffies + HZ / 10;
+ card->timer.data = (unsigned long)card;
+ add_timer(&card->timer);
+ return 0;
+
+free_card:
+ kfree(card);
+ return err;
+}
+
+static struct pci_device_id t3e3_pci_tbl[] __devinitdata = {
+ { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
+ PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_T3E3, 0, 0, 0 },
+ { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
+ PCI_VENDOR_ID_SBE, PCI_SUBDEVICE_ID_SBE_2T3E3_P0, 0, 0, 0 },
+ /* channel 1 will be initialized after channel 0 */
+ { 0, }
+};
+
+static struct pci_driver t3e3_pci_driver = {
+ .name = "SBE T3E3",
+ .id_table = t3e3_pci_tbl,
+ .probe = t3e3_init_card,
+ .remove = t3e3_remove_card,
+};
+
+static int __init t3e3_init_module(void)
+{
+ return pci_register_driver(&t3e3_pci_driver);
+}
+
+static void __exit t3e3_cleanup_module(void)
+{
+ pci_unregister_driver(&t3e3_pci_driver);
+}
+
+module_init(t3e3_init_module);
+module_exit(t3e3_cleanup_module);
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, t3e3_pci_tbl);
diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
new file mode 100644
index 000000000000..c7b5e8bb04ff
--- /dev/null
+++ b/drivers/staging/sbe-2t3e3/netdev.c
@@ -0,0 +1,142 @@
+/*
+ * SBE 2T3E3 synchronous serial card driver for Linux
+ *
+ * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * This code is based on a driver written by SBE Inc.
+ */
+
+#include <linux/capability.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/pci.h>
+#include <linux/hdlc.h>
+#include <linux/if_arp.h>
+#include <linux/interrupt.h>
+#include "2t3e3.h"
+
+int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ struct channel *sc = dev_to_priv(dev);
+ int cmd_2t3e3, len, rlen;
+ t3e3_param_t param;
+ t3e3_resp_t resp;
+ void *data = ifr->ifr_data + sizeof(cmd_2t3e3) + sizeof(len);
+
+ if (cmd == SIOCWANDEV)
+ return hdlc_ioctl(dev, ifr, cmd);
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ if (cmd != SIOCDEVPRIVATE + 15)
+ return -EINVAL;
+
+ if (copy_from_user(&cmd_2t3e3, ifr->ifr_data, sizeof(cmd_2t3e3)))
+ return -EFAULT;
+ if (copy_from_user(&len, ifr->ifr_data + sizeof(cmd_2t3e3), sizeof(len)))
+ return -EFAULT;
+
+ if (len > sizeof(param))
+ return -EFAULT;
+
+ if (len)
+ if (copy_from_user(&param, data, len))
+ return -EFAULT;
+
+ t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
+
+ if (rlen)
+ if (copy_to_user(data, &resp, rlen))
+ return -EFAULT;
+
+ return 0;
+}
+
+static struct net_device_stats* t3e3_get_stats(struct net_device *dev)
+{
+ struct net_device_stats *nstats = &dev->stats;
+ struct channel *sc = dev_to_priv(dev);
+ t3e3_stats_t *stats = &sc->s;
+
+ memset(nstats, 0, sizeof(struct net_device_stats));
+ nstats->rx_packets = stats->in_packets;
+ nstats->tx_packets = stats->out_packets;
+ nstats->rx_bytes = stats->in_bytes;
+ nstats->tx_bytes = stats->out_bytes;
+
+ nstats->rx_errors = stats->in_errors;
+ nstats->tx_errors = stats->out_errors;
+ nstats->rx_crc_errors = stats->in_error_crc;
+
+
+ nstats->rx_dropped = stats->in_dropped;
+ nstats->tx_dropped = stats->out_dropped;
+ nstats->tx_carrier_errors = stats->out_error_lost_carr +
+ stats->out_error_no_carr;
+
+ return nstats;
+}
+
+int t3e3_open(struct net_device *dev)
+{
+ struct channel *sc = dev_to_priv(dev);
+ int ret = hdlc_open(dev);
+
+ if (ret)
+ return ret;
+
+ sc->r.flags |= SBE_2T3E3_FLAG_NETWORK_UP;
+ dc_start(dev_to_priv(dev));
+ netif_start_queue(dev);
+ try_module_get(THIS_MODULE);
+ return 0;
+}
+
+int t3e3_close(struct net_device *dev)
+{
+ struct channel *sc = dev_to_priv(dev);
+ hdlc_close(dev);
+ netif_stop_queue(dev);
+ dc_stop(sc);
+ sc->r.flags &= ~SBE_2T3E3_FLAG_NETWORK_UP;
+ module_put(THIS_MODULE);
+ return 0;
+}
+
+static int t3e3_attach(struct net_device *dev, unsigned short foo1,
+ unsigned short foo2)
+{
+ return 0;
+}
+
+static const struct net_device_ops t3e3_ops = {
+ .ndo_open = t3e3_open,
+ .ndo_stop = t3e3_close,
+ .ndo_change_mtu = hdlc_change_mtu,
+ .ndo_start_xmit = hdlc_start_xmit,
+ .ndo_do_ioctl = t3e3_ioctl,
+ .ndo_get_stats = t3e3_get_stats,
+};
+
+int setup_device(struct net_device *dev, struct channel *sc)
+{
+ hdlc_device *hdlc = dev_to_hdlc(dev);
+ int retval;
+
+ dev->base_addr = pci_resource_start(sc->pdev, 0);
+ dev->irq = sc->pdev->irq;
+ dev->netdev_ops = &t3e3_ops;
+ dev->tx_queue_len = 100;
+ hdlc->xmit = t3e3_if_start_xmit;
+ hdlc->attach = t3e3_attach;
+ if ((retval = register_hdlc_device(dev))) {
+ dev_err(&sc->pdev->dev, "error registering HDLC device\n");
+ return retval;
+ }
+ return 0;
+}
diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index beab400805af..ebdcc6f91fdc 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -515,14 +515,16 @@ struct adapter {
(largestat) += ((newstat) - (oldstat)); \
}
-#if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
+#if BITS_PER_LONG == 64
#define SLIC_GET_ADDR_LOW(_addr) (u32)((u64)(_addr) & \
0x00000000FFFFFFFF)
#define SLIC_GET_ADDR_HIGH(_addr) (u32)(((u64)(_addr) >> 32) & \
0x00000000FFFFFFFF)
-#else
-#define SLIC_GET_ADDR_LOW(_addr) (u32)_addr
+#elif BITS_PER_LONG == 32
+#define SLIC_GET_ADDR_LOW(_addr) (u32)(_addr)
#define SLIC_GET_ADDR_HIGH(_addr) (u32)0
+#else
+#error BITS_PER_LONG must be 32 or 64
#endif
#define FLUSH true
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index f8c4b127e83a..58ff1233270c 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1099,19 +1099,17 @@ static void slic_link_upr_complete(struct adapter *adapter, u32 isr)
struct slic_shmem *pshmem;
pshmem = (struct slic_shmem *)adapter->phys_shmem;
-#if defined(CONFIG_X86_64)
+#if BITS_PER_LONG == 64
slic_upr_queue_request(adapter,
SLIC_UPR_RLSR,
SLIC_GET_ADDR_LOW(&pshmem->linkstatus),
SLIC_GET_ADDR_HIGH(&pshmem->linkstatus),
0, 0);
-#elif defined(CONFIG_X86)
+#else
slic_upr_queue_request(adapter,
SLIC_UPR_RLSR,
(u32) &pshmem->linkstatus,
SLIC_GET_ADDR_HIGH(pshmem), 0, 0);
-#else
- Stop Compilation;
#endif
return;
}
@@ -1327,7 +1325,7 @@ static ushort slic_eeprom_cksum(char *m, int len)
s_util.s = 0;
w = (u16 *)m;
-#ifdef CONFIG_X86_64
+#if BITS_PER_LONG == 64
w_int = (u32) ((ulong) w & 0x00000000FFFFFFFF);
#else
w_int = (u32) (w);
@@ -1439,12 +1437,16 @@ static int slic_rspqueue_init(struct adapter *adapter)
slic_rspqueue_free(adapter);
return -ENOMEM;
}
+ /* FIXME:
+ * do we really need this assertions (4K PAGE_SIZE aligned addr)? */
+#if 0
#ifndef CONFIG_X86_64
ASSERT(((u32) rspq->vaddr[i] & 0xFFFFF000) ==
(u32) rspq->vaddr[i]);
ASSERT(((u32) rspq->paddr[i] & 0xFFFFF000) ==
(u32) rspq->paddr[i]);
#endif
+#endif
memset(rspq->vaddr[i], 0, PAGE_SIZE);
if (paddrh == 0) {
@@ -1473,13 +1475,13 @@ static struct slic_rspbuf *slic_rspqueue_getnext(struct adapter *adapter)
return NULL;
buf = rspq->rspbuf;
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT((buf->status & 0xFFFFFFE0) == 0);
#endif
ASSERT(buf->hosthandle);
if (++rspq->offset < SLIC_RSPQ_BUFSINPAGE) {
rspq->rspbuf++;
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT(((u32) rspq->rspbuf & 0xFFFFFFE0) ==
(u32) rspq->rspbuf);
#endif
@@ -1492,12 +1494,12 @@ static struct slic_rspbuf *slic_rspqueue_getnext(struct adapter *adapter)
rspq->offset = 0;
rspq->rspbuf = (struct slic_rspbuf *)
rspq->vaddr[rspq->pageindex];
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT(((u32) rspq->rspbuf & 0xFFFFF000) ==
(u32) rspq->rspbuf);
#endif
}
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT(((u32) buf & 0xFFFFFFE0) == (u32) buf);
#endif
return buf;
@@ -1538,7 +1540,7 @@ static u32 *slic_cmdqmem_addpage(struct adapter *adapter)
&cmdqmem->dma_pages[cmdqmem->pagecnt]);
if (!pageaddr)
return NULL;
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT(((u32) pageaddr & 0xFFFFF000) == (u32) pageaddr);
#endif
cmdqmem->pages[cmdqmem->pagecnt] = pageaddr;
@@ -1650,7 +1652,7 @@ static int slic_cmdq_init(struct adapter *adapter)
adapter->slic_handle_ix = 1;
for (i = 0; i < SLIC_CMDQ_INITPAGES; i++) {
pageaddr = slic_cmdqmem_addpage(adapter);
-#ifndef CONFIG_X86_64
+#if BITS_PER_LONG == 32
ASSERT(((u32) pageaddr & 0xFFFFF000) == (u32) pageaddr);
#endif
if (!pageaddr) {
@@ -2447,18 +2449,16 @@ static void slic_link_event_handler(struct adapter *adapter)
pshmem = (struct slic_shmem *)adapter->phys_shmem;
-#if defined(CONFIG_X86_64)
+#if BITS_PER_LONG == 64
status = slic_upr_request(adapter,
SLIC_UPR_RLSR,
SLIC_GET_ADDR_LOW(&pshmem->linkstatus),
SLIC_GET_ADDR_HIGH(&pshmem->linkstatus),
0, 0);
-#elif defined(CONFIG_X86)
+#else
status = slic_upr_request(adapter, SLIC_UPR_RLSR,
(u32) &pshmem->linkstatus, /* no 4GB wrap guaranteed */
0, 0, 0);
-#else
- Stop compilation;
#endif
ASSERT(status == 0);
}
@@ -2575,14 +2575,12 @@ static void slic_xmit_build_request(struct adapter *adapter,
ihcmd->u.slic_buffers.bufs[0].paddrl = SLIC_GET_ADDR_LOW(phys_addr);
ihcmd->u.slic_buffers.bufs[0].paddrh = SLIC_GET_ADDR_HIGH(phys_addr);
ihcmd->u.slic_buffers.bufs[0].length = skb->len;
-#if defined(CONFIG_X86_64)
+#if BITS_PER_LONG == 64
hcmd->cmdsize = (u32) ((((u64)&ihcmd->u.slic_buffers.bufs[1] -
(u64) hcmd) + 31) >> 5);
-#elif defined(CONFIG_X86)
+#else
hcmd->cmdsize = ((((u32) &ihcmd->u.slic_buffers.bufs[1] -
(u32) hcmd) + 31) >> 5);
-#else
- Stop Compilation;
#endif
}
@@ -3078,16 +3076,14 @@ static int slic_if_init(struct adapter *adapter)
spin_lock_irqsave(&adapter->bit64reglock.lock,
adapter->bit64reglock.flags);
-#if defined(CONFIG_X86_64)
+#if BITS_PER_LONG == 64
slic_reg32_write(&slic_regs->slic_addr_upper,
SLIC_GET_ADDR_HIGH(&pshmem->isr), DONT_FLUSH);
slic_reg32_write(&slic_regs->slic_isp,
SLIC_GET_ADDR_LOW(&pshmem->isr), FLUSH);
-#elif defined(CONFIG_X86)
+#else
slic_reg32_write(&slic_regs->slic_addr_upper, 0, DONT_FLUSH);
slic_reg32_write(&slic_regs->slic_isp, (u32)&pshmem->isr, FLUSH);
-#else
- Stop Compilations
#endif
spin_unlock_irqrestore(&adapter->bit64reglock.lock,
adapter->bit64reglock.flags);
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index f6b401c0ccc9..24f47d6388f4 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -848,7 +848,6 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
"Silicon Motion display driver " SMTC_LINUX_FB_VERSION "\n");
err = pci_enable_device(pdev); /* enable SMTC chip */
-
if (err)
return err;
err = -ENOMEM;
@@ -859,7 +858,7 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
sfb = smtc_alloc_fb_info(pdev, name);
if (!sfb)
- goto failed;
+ goto failed_free;
/* Jason (08/13/2009)
* Store fb_info to be further used when suspending and resuming
*/
@@ -917,7 +916,8 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
printk(KERN_INFO
"%s: unable to map memory mapped IO\n",
sfb->fb.fix.id);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto failed_fb;
}
/* set MCLK = 14.31818 * (0x16 / 0x2) */
@@ -951,8 +951,7 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
printk(KERN_INFO
"No valid Silicon Motion display chip was detected!\n");
- smtc_free_fb_info(sfb);
- return err;
+ goto failed_fb;
}
/* can support 32 bpp */
@@ -986,8 +985,12 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
smtc_unmap_smem(sfb);
smtc_unmap_mmio(sfb);
+failed_fb:
smtc_free_fb_info(sfb);
+failed_free:
+ pci_disable_device(pdev);
+
return err;
}
diff --git a/drivers/staging/solo6x10/solo6010-core.c b/drivers/staging/solo6x10/solo6010-core.c
index 98c6739fc196..4a051cde55da 100644
--- a/drivers/staging/solo6x10/solo6010-core.c
+++ b/drivers/staging/solo6x10/solo6010-core.c
@@ -136,23 +136,26 @@ static int __devinit solo6010_pci_probe(struct pci_dev *pdev,
int ret;
int sdram;
u8 chip_id;
-
- if ((solo_dev = kzalloc(sizeof(*solo_dev), GFP_KERNEL)) == NULL)
+ solo_dev = kzalloc(sizeof(*solo_dev), GFP_KERNEL);
+ if (solo_dev == NULL)
return -ENOMEM;
solo_dev->pdev = pdev;
spin_lock_init(&solo_dev->reg_io_lock);
pci_set_drvdata(pdev, solo_dev);
- if ((ret = pci_enable_device(pdev)))
+ ret = pci_enable_device(pdev);
+ if (ret)
goto fail_probe;
pci_set_master(pdev);
- if ((ret = pci_request_regions(pdev, SOLO6010_NAME)))
+ ret = pci_request_regions(pdev, SOLO6010_NAME);
+ if (ret)
goto fail_probe;
- if ((solo_dev->reg_base = pci_ioremap_bar(pdev, 0)) == NULL) {
+ solo_dev->reg_base = pci_ioremap_bar(pdev, 0);
+ if (solo_dev->reg_base == NULL) {
ret = -ENOMEM;
goto fail_probe;
}
@@ -198,7 +201,8 @@ static int __devinit solo6010_pci_probe(struct pci_dev *pdev,
/* Handle this from the start */
solo6010_irq_on(solo_dev, SOLO_IRQ_PCI_ERR);
- if ((ret = solo_i2c_init(solo_dev)))
+ ret = solo_i2c_init(solo_dev);
+ if (ret)
goto fail_probe;
/* Setup the DMA engine */
@@ -210,28 +214,36 @@ static int __devinit solo6010_pci_probe(struct pci_dev *pdev,
SOLO_DMA_CTRL_READ_CLK_SELECT |
SOLO_DMA_CTRL_LATENCY(1));
- if ((ret = solo_p2m_init(solo_dev)))
+ ret = solo_p2m_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_disp_init(solo_dev)))
+ ret = solo_disp_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_gpio_init(solo_dev)))
+ ret = solo_gpio_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_tw28_init(solo_dev)))
+ ret = solo_tw28_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_v4l2_init(solo_dev)))
+ ret = solo_v4l2_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_enc_init(solo_dev)))
+ ret = solo_enc_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_enc_v4l2_init(solo_dev)))
+ ret = solo_enc_v4l2_init(solo_dev);
+ if (ret)
goto fail_probe;
- if ((ret = solo_g723_init(solo_dev)))
+ ret = solo_g723_init(solo_dev);
+ if (ret)
goto fail_probe;
return 0;
diff --git a/drivers/staging/solo6x10/solo6010-g723.c b/drivers/staging/solo6x10/solo6010-g723.c
index e82846c1d6c6..82fbcb845878 100644
--- a/drivers/staging/solo6x10/solo6010-g723.c
+++ b/drivers/staging/solo6x10/solo6010-g723.c
@@ -233,7 +233,7 @@ static int snd_solo_pcm_copy(struct snd_pcm_substream *ss, int channel,
solo_pcm->g723_buf, G723_PERIOD_BYTES);
if (err)
- return err;
+ return -EFAULT;
}
return 0;
diff --git a/drivers/staging/spectra/lld_nand.c b/drivers/staging/spectra/lld_nand.c
index 13c3ad2db394..0d647a8fd2b6 100644
--- a/drivers/staging/spectra/lld_nand.c
+++ b/drivers/staging/spectra/lld_nand.c
@@ -2411,13 +2411,15 @@ static int nand_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
csr_base = pci_resource_start(dev, 0);
if (!csr_base) {
printk(KERN_ERR "Spectra: pci_resource_start failed!\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto failed_req_csr;
}
csr_len = pci_resource_len(dev, 0);
if (!csr_len) {
printk(KERN_ERR "Spectra: pci_resource_len failed!\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto failed_req_csr;
}
ret = pci_request_regions(dev, SPECTRA_NAND_NAME);
@@ -2464,6 +2466,7 @@ static int nand_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
failed_remap_csr:
pci_release_regions(dev);
failed_req_csr:
+ pci_disable_device(dev);
return ret;
}
diff --git a/drivers/staging/ti-st/st.h b/drivers/staging/ti-st/st.h
index 9952579425b9..1b3060eb2921 100644
--- a/drivers/staging/ti-st/st.h
+++ b/drivers/staging/ti-st/st.h
@@ -80,5 +80,4 @@ struct st_proto_s {
extern long st_register(struct st_proto_s *);
extern long st_unregister(enum proto_type);
-extern struct platform_device *st_get_plat_device(void);
#endif /* ST_H */
diff --git a/drivers/staging/ti-st/st_core.c b/drivers/staging/ti-st/st_core.c
index 063c9b1db1ab..fad97d7f0421 100644
--- a/drivers/staging/ti-st/st_core.c
+++ b/drivers/staging/ti-st/st_core.c
@@ -38,7 +38,6 @@
#include "st_ll.h"
#include "st.h"
-#define VERBOSE
/* strings to be used for rfkill entries and by
* ST Core to be used for sysfs debug entry
*/
@@ -581,7 +580,7 @@ long st_register(struct st_proto_s *new_proto)
long err = 0;
unsigned long flags = 0;
- st_kim_ref(&st_gdata);
+ st_kim_ref(&st_gdata, 0);
pr_info("%s(%d) ", __func__, new_proto->type);
if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL
|| new_proto->reg_complete_cb == NULL) {
@@ -686,9 +685,8 @@ long st_register(struct st_proto_s *new_proto)
default:
pr_err("%d protocol not supported",
new_proto->type);
- err = -EPROTONOSUPPORT;
- /* something wrong */
- break;
+ spin_unlock_irqrestore(&st_gdata->lock, flags);
+ return -EPROTONOSUPPORT;
}
st_gdata->list[new_proto->type] = new_proto;
st_gdata->protos_registered++;
@@ -713,7 +711,7 @@ long st_unregister(enum proto_type type)
pr_debug("%s: %d ", __func__, type);
- st_kim_ref(&st_gdata);
+ st_kim_ref(&st_gdata, 0);
if (type < ST_BT || type >= ST_MAX) {
pr_err(" protocol %d not supported", type);
return -EPROTONOSUPPORT;
@@ -767,7 +765,7 @@ long st_write(struct sk_buff *skb)
#endif
long len;
- st_kim_ref(&st_gdata);
+ st_kim_ref(&st_gdata, 0);
if (unlikely(skb == NULL || st_gdata == NULL
|| st_gdata->tty == NULL)) {
pr_err("data/tty unavailable to perform write");
@@ -818,7 +816,7 @@ static int st_tty_open(struct tty_struct *tty)
struct st_data_s *st_gdata;
pr_info("%s ", __func__);
- st_kim_ref(&st_gdata);
+ st_kim_ref(&st_gdata, 0);
st_gdata->tty = tty;
tty->disc_data = st_gdata;
diff --git a/drivers/staging/ti-st/st_core.h b/drivers/staging/ti-st/st_core.h
index e0c32d149f5f..8601320a679e 100644
--- a/drivers/staging/ti-st/st_core.h
+++ b/drivers/staging/ti-st/st_core.h
@@ -117,7 +117,7 @@ int st_core_init(struct st_data_s **);
void st_core_exit(struct st_data_s *);
/* ask for reference from KIM */
-void st_kim_ref(struct st_data_s **);
+void st_kim_ref(struct st_data_s **, int);
#define GPS_STUB_TEST
#ifdef GPS_STUB_TEST
diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c
index b4a6c7fdc4e6..9e99463f76e8 100644
--- a/drivers/staging/ti-st/st_kim.c
+++ b/drivers/staging/ti-st/st_kim.c
@@ -72,11 +72,26 @@ const unsigned char *protocol_names[] = {
PROTO_ENTRY(ST_GPS, "GPS"),
};
+#define MAX_ST_DEVICES 3 /* Imagine 1 on each UART for now */
+struct platform_device *st_kim_devices[MAX_ST_DEVICES];
/**********************************************************************/
/* internal functions */
/**
+ * st_get_plat_device -
+ * function which returns the reference to the platform device
+ * requested by id. As of now only 1 such device exists (id=0)
+ * the context requesting for reference can get the id to be
+ * requested by a. The protocol driver which is registering or
+ * b. the tty device which is opened.
+ */
+static struct platform_device *st_get_plat_device(int id)
+{
+ return st_kim_devices[id];
+}
+
+/**
* validate_firmware_response -
* function to return whether the firmware response was proper
* in case of error don't complete so that waiting for proper
@@ -353,7 +368,7 @@ void st_kim_chip_toggle(enum proto_type type, enum kim_gpio_state state)
struct kim_data_s *kim_gdata;
pr_info(" %s ", __func__);
- kim_pdev = st_get_plat_device();
+ kim_pdev = st_get_plat_device(0);
kim_gdata = dev_get_drvdata(&kim_pdev->dev);
if (kim_gdata->gpios[type] == -1) {
@@ -574,12 +589,12 @@ static int kim_toggle_radio(void *data, bool blocked)
* This would enable multiple such platform devices to exist
* on a given platform
*/
-void st_kim_ref(struct st_data_s **core_data)
+void st_kim_ref(struct st_data_s **core_data, int id)
{
struct platform_device *pdev;
struct kim_data_s *kim_gdata;
/* get kim_gdata reference from platform device */
- pdev = st_get_plat_device();
+ pdev = st_get_plat_device(id);
kim_gdata = dev_get_drvdata(&pdev->dev);
*core_data = kim_gdata->core_data;
}
@@ -623,6 +638,7 @@ static int kim_probe(struct platform_device *pdev)
long *gpios = pdev->dev.platform_data;
struct kim_data_s *kim_gdata;
+ st_kim_devices[pdev->id] = pdev;
kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC);
if (!kim_gdata) {
pr_err("no mem to allocate");
diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile
index 65671724e6f9..8082d5c7be48 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,11 +1,9 @@
obj-$(CONFIG_TIDSPBRIDGE) += bridgedriver.o
libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
-libservices = services/sync.o services/cfg.o \
- services/ntfy.o services/services.o
libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o \
- core/ue_deh.o core/wdt.o core/dsp-clock.o
+ core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/dspapi.o \
pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c b/drivers/staging/tidspbridge/core/chnl_sm.c
index bee2b23a09a1..662a5b5a58e3 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -54,7 +54,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/sync.h>
/* ----------------------------------- Bridge Driver */
diff --git a/drivers/staging/tidspbridge/core/dsp-clock.c b/drivers/staging/tidspbridge/core/dsp-clock.c
index 5b1a0c5bb143..46d17c777b88 100644
--- a/drivers/staging/tidspbridge/core/dsp-clock.c
+++ b/drivers/staging/tidspbridge/core/dsp-clock.c
@@ -25,7 +25,6 @@
/* ----------------------------------- DSP/BIOS Bridge */
#include <dspbridge/dbdefs.h>
-#include <dspbridge/cfg.h>
#include <dspbridge/drv.h>
#include <dspbridge/dev.h>
#include "_tiomap.h"
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index 02c660dbcf68..571864555ddd 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -36,7 +36,6 @@
#include <dspbridge/dbc.h>
/* Services Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/ntfy.h>
#include <dspbridge/sync.h>
diff --git a/drivers/staging/tidspbridge/services/sync.c b/drivers/staging/tidspbridge/core/sync.c
index 9010b37bf5b1..995986a9d03b 100644
--- a/drivers/staging/tidspbridge/services/sync.c
+++ b/drivers/staging/tidspbridge/core/sync.c
@@ -21,6 +21,7 @@
/* ----------------------------------- This */
#include <dspbridge/sync.h>
+#include <dspbridge/ntfy.h>
DEFINE_SPINLOCK(sync_lock);
@@ -102,3 +103,19 @@ func_end:
return status;
}
+/**
+ * dsp_notifier_event() - callback function to nofity events
+ * @this: pointer to itself struct notifier_block
+ * @event: event to be notified.
+ * @data: Currently not used.
+ *
+ */
+int dsp_notifier_event(struct notifier_block *this, unsigned long event,
+ void *data)
+{
+ struct ntfy_event *ne = container_of(this, struct ntfy_event,
+ noti_block);
+ if (ne->event & event)
+ sync_set_event(&ne->sync_obj);
+ return NOTIFY_OK;
+}
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index f914829c70f5..f1e59e84ea38 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -30,7 +30,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/drv.h>
#include <dspbridge/sync.h>
diff --git a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
index b789f8fdd89b..b9d07535ef71 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
@@ -16,9 +16,11 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/* ----------------------------------- Host OS */
+#include <dspbridge/host_os.h>
+
/* ----------------------------------- DSP/BIOS Bridge */
#include <dspbridge/dbdefs.h>
-#include <dspbridge/cfg.h>
#include <dspbridge/drv.h>
#include <dspbridge/io_sm.h>
diff --git a/drivers/staging/tidspbridge/core/tiomap_io.c b/drivers/staging/tidspbridge/core/tiomap_io.c
index 190c028afe9b..e78a7cd31526 100644
--- a/drivers/staging/tidspbridge/core/tiomap_io.c
+++ b/drivers/staging/tidspbridge/core/tiomap_io.c
@@ -27,7 +27,6 @@
#include <dspbridge/drv.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/wdt.h>
/* ----------------------------------- specific to this file */
diff --git a/drivers/staging/tidspbridge/gen/gb.c b/drivers/staging/tidspbridge/gen/gb.c
index 06eb3d361225..9f590230473b 100644
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ b/drivers/staging/tidspbridge/gen/gb.c
@@ -15,7 +15,6 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#include <linux/types.h>
/* ----------------------------------- DSP/BIOS Bridge */
#include <linux/types.h>
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cfg.h b/drivers/staging/tidspbridge/include/dspbridge/cfg.h
deleted file mode 100644
index 05a8999070f8..000000000000
--- a/drivers/staging/tidspbridge/include/dspbridge/cfg.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * cfg.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * PM Configuration module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CFG_
-#define CFG_
-#include <dspbridge/host_os.h>
-#include <dspbridge/cfgdefs.h>
-
-/*
- * ======== cfg_exit ========
- * Purpose:
- * Discontinue usage of the CFG module.
- * Parameters:
- * Returns:
- * Requires:
- * cfg_init(void) was previously called.
- * Ensures:
- * Resources acquired in cfg_init(void) are freed.
- */
-extern void cfg_exit(void);
-
-/*
- * ======== cfg_get_auto_start ========
- * Purpose:
- * Retreive the autostart mask, if any, for this board.
- * Parameters:
- * dev_node_obj: Handle to the dev_node who's driver we are querying.
- * auto_start: Ptr to location for 32 bit autostart mask.
- * Returns:
- * 0: Success.
- * -EFAULT: dev_node_obj is invalid.
- * -ENODATA: Unable to retreive resource.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: *auto_start contains autostart mask for this devnode.
- */
-extern int cfg_get_auto_start(struct cfg_devnode *dev_node_obj,
- u32 *auto_start);
-
-/*
- * ======== cfg_get_cd_version ========
- * Purpose:
- * Retrieves the version of the PM Class Driver.
- * Parameters:
- * version: Ptr to u32 to contain version number upon return.
- * Returns:
- * 0: Success. version contains Class Driver version in
- * the form: 0xAABBCCDD where AABB is Major version and
- * CCDD is Minor.
- * -EPERM: Failure.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: Success.
- * else: *version is NULL.
- */
-extern int cfg_get_cd_version(u32 *version);
-
-/*
- * ======== cfg_get_dev_object ========
- * Purpose:
- * Retrieve the Device Object handle for a given devnode.
- * Parameters:
- * dev_node_obj: Platform's dev_node handle from which to retrieve
- * value.
- * value: Ptr to location to store the value.
- * Returns:
- * 0: Success.
- * -EFAULT: dev_node_obj is invalid or device_obj is invalid.
- * -ENODATA: The resource is not available.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: *value is set to the retrieved u32.
- * else: *value is set to 0L.
- */
-extern int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
- u32 *value);
-
-/*
- * ======== cfg_get_exec_file ========
- * Purpose:
- * Retreive the default executable, if any, for this board.
- * Parameters:
- * dev_node_obj: Handle to the dev_node who's driver we are querying.
- * buf_size: Size of buffer.
- * str_exec_file: Ptr to character buf to hold ExecFile.
- * Returns:
- * 0: Success.
- * -EFAULT: dev_node_obj is invalid or str_exec_file is invalid.
- * -ENODATA: The resource is not available.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: Not more than buf_size bytes were copied into str_exec_file,
- * and *str_exec_file contains default executable for this
- * devnode.
- */
-extern int cfg_get_exec_file(struct cfg_devnode *dev_node_obj,
- u32 buf_size, char *str_exec_file);
-
-/*
- * ======== cfg_get_object ========
- * Purpose:
- * Retrieve the Driver Object handle From the Registry
- * Parameters:
- * value: Ptr to location to store the value.
- * dw_type Type of Object to Get
- * Returns:
- * 0: Success.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: *value is set to the retrieved u32(non-Zero).
- * else: *value is set to 0L.
- */
-extern int cfg_get_object(u32 *value, u8 dw_type);
-
-/*
- * ======== cfg_get_perf_value ========
- * Purpose:
- * Retrieve a flag indicating whether PERF should log statistics for the
- * PM class driver.
- * Parameters:
- * enable_perf: Location to store flag. 0 indicates the key was
- * not found, or had a zero value. A nonzero value
- * means the key was found and had a nonzero value.
- * Returns:
- * Requires:
- * enable_perf != NULL;
- * Ensures:
- */
-extern void cfg_get_perf_value(bool *enable_perf);
-
-/*
- * ======== cfg_get_zl_file ========
- * Purpose:
- * Retreive the ZLFile, if any, for this board.
- * Parameters:
- * dev_node_obj: Handle to the dev_node who's driver we are querying.
- * buf_size: Size of buffer.
- * str_zl_file_name: Ptr to character buf to hold ZLFileName.
- * Returns:
- * 0: Success.
- * -EFAULT: str_zl_file_name is invalid or dev_node_obj is invalid.
- * -ENODATA: couldn't find the ZLFileName.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: Not more than buf_size bytes were copied into
- * str_zl_file_name, and *str_zl_file_name contains ZLFileName
- * for this devnode.
- */
-extern int cfg_get_zl_file(struct cfg_devnode *dev_node_obj,
- u32 buf_size, char *str_zl_file_name);
-
-/*
- * ======== cfg_init ========
- * Purpose:
- * Initialize the CFG module's private state.
- * Parameters:
- * Returns:
- * TRUE if initialized; FALSE if error occured.
- * Requires:
- * Ensures:
- * A requirement for each of the other public CFG functions.
- */
-extern bool cfg_init(void);
-
-/*
- * ======== cfg_set_dev_object ========
- * Purpose:
- * Store the Device Object handle for a given devnode.
- * Parameters:
- * dev_node_obj: Platform's dev_node handle we are storing value with.
- * value: Arbitrary value to store.
- * Returns:
- * 0: Success.
- * -EFAULT: dev_node_obj is invalid.
- * -EPERM: Internal Error.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: The Private u32 was successfully set.
- */
-extern int cfg_set_dev_object(struct cfg_devnode *dev_node_obj,
- u32 value);
-
-/*
- * ======== CFG_SetDrvObject ========
- * Purpose:
- * Store the Driver Object handle.
- * Parameters:
- * value: Arbitrary value to store.
- * dw_type Type of Object to Store
- * Returns:
- * 0: Success.
- * -EPERM: Internal Error.
- * Requires:
- * CFG initialized.
- * Ensures:
- * 0: The Private u32 was successfully set.
- */
-extern int cfg_set_object(u32 value, u8 dw_type);
-
-#endif /* CFG_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/services.h b/drivers/staging/tidspbridge/include/dspbridge/services.h
deleted file mode 100644
index eb26c867c931..000000000000
--- a/drivers/staging/tidspbridge/include/dspbridge/services.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * services.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Provide loading and unloading of SERVICES modules.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef SERVICES_
-#define SERVICES_
-
-#include <dspbridge/host_os.h>
-/*
- * ======== services_exit ========
- * Purpose:
- * Discontinue usage of module; free resources when reference count
- * reaches 0.
- * Parameters:
- * Returns:
- * Requires:
- * SERVICES initialized.
- * Ensures:
- * Resources used by module are freed when cRef reaches zero.
- */
-extern void services_exit(void);
-
-/*
- * ======== services_init ========
- * Purpose:
- * Initializes SERVICES modules.
- * Parameters:
- * Returns:
- * TRUE if all modules initialized; otherwise FALSE.
- * Requires:
- * Ensures:
- * SERVICES modules initialized.
- */
-extern bool services_init(void);
-
-#endif /* SERVICES_ */
diff --git a/drivers/staging/tidspbridge/pmgr/chnl.c b/drivers/staging/tidspbridge/pmgr/chnl.c
index 90317b58f8eb..78b0d0f303d7 100644
--- a/drivers/staging/tidspbridge/pmgr/chnl.c
+++ b/drivers/staging/tidspbridge/pmgr/chnl.c
@@ -28,7 +28,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/sync.h>
/* ----------------------------------- Platform Manager */
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c b/drivers/staging/tidspbridge/pmgr/cmm.c
index ce3dc8822afa..e3f77bd453f7 100644
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ b/drivers/staging/tidspbridge/pmgr/cmm.c
@@ -38,7 +38,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/list.h>
#include <dspbridge/sync.h>
#include <dspbridge/utildefs.h>
diff --git a/drivers/staging/tidspbridge/pmgr/dev.c b/drivers/staging/tidspbridge/pmgr/dev.c
index 4ddf03d3b1ab..132e960967b9 100644
--- a/drivers/staging/tidspbridge/pmgr/dev.c
+++ b/drivers/staging/tidspbridge/pmgr/dev.c
@@ -27,7 +27,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/ldr.h>
#include <dspbridge/list.h>
@@ -85,6 +84,11 @@ struct dev_object {
struct node_mgr *hnode_mgr;
};
+struct drv_ext {
+ struct list_head link;
+ char sz_string[MAXREGPATHLENGTH];
+};
+
/* ----------------------------------- Globals */
static u32 refs; /* Module reference count */
@@ -143,6 +147,7 @@ int dev_create_device(struct dev_object **device_obj,
struct io_attrs io_mgr_attrs;
u32 num_windows;
struct drv_object *hdrv_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
int status = 0;
DBC_REQUIRE(refs > 0);
DBC_REQUIRE(device_obj != NULL);
@@ -158,10 +163,15 @@ int dev_create_device(struct dev_object **device_obj,
/* Get the Bridge driver interface functions */
bridge_drv_entry(&drv_fxns, driver_file_name);
- if (cfg_get_object((u32 *) &hdrv_obj, REG_DRV_OBJECT)) {
- /* don't propogate CFG errors from this PROC function */
+
+ /* Retrieve the Object handle from the driver data */
+ if (drv_datap && drv_datap->drv_object) {
+ hdrv_obj = drv_datap->drv_object;
+ } else {
status = -EPERM;
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
}
+
/* Create the device object, and pass a handle to the Bridge driver for
* storage. */
if (!status) {
@@ -812,18 +822,31 @@ int dev_remove_device(struct cfg_devnode *dev_node_obj)
{
struct dev_object *hdev_obj; /* handle to device object */
int status = 0;
- struct dev_object *dev_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
+
+ if (!drv_datap)
+ status = -ENODATA;
+
+ if (!dev_node_obj)
+ status = -EFAULT;
/* Retrieve the device object handle originaly stored with
* the dev_node: */
- status = cfg_get_dev_object(dev_node_obj, (u32 *) &hdev_obj);
if (!status) {
- /* Remove the Processor List */
- dev_obj = (struct dev_object *)hdev_obj;
- /* Destroy the device object. */
- status = dev_destroy_device(hdev_obj);
+ /* check the device string and then store dev object */
+ if (!strcmp((char *)((struct drv_ext *)dev_node_obj)->sz_string,
+ "TIOMAP1510")) {
+ hdev_obj = drv_datap->dev_object;
+ /* Destroy the device object. */
+ status = dev_destroy_device(hdev_obj);
+ } else {
+ status = -EPERM;
+ }
}
+ if (status)
+ pr_err("%s: Failed, status 0x%x\n", __func__, status);
+
return status;
}
@@ -874,6 +897,7 @@ int dev_start_device(struct cfg_devnode *dev_node_obj)
char bridge_file_name[CFG_MAXSEARCHPATHLEN] = "UMA";
int status;
struct mgr_object *hmgr_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(refs > 0);
@@ -882,24 +906,27 @@ int dev_start_device(struct cfg_devnode *dev_node_obj)
dev_node_obj);
if (!status) {
/* Store away the hdev_obj with the DEVNODE */
- status = cfg_set_dev_object(dev_node_obj, (u32) hdev_obj);
+ if (!drv_datap || !dev_node_obj) {
+ status = -EFAULT;
+ pr_err("%s: Failed, status 0x%x\n", __func__, status);
+ } else if (!(strcmp((char *)dev_node_obj, "TIOMAP1510"))) {
+ drv_datap->dev_object = (void *) hdev_obj;
+ }
+ if (!status) {
+ /* Create the Manager Object */
+ status = mgr_create(&hmgr_obj, dev_node_obj);
+ if (status && !(strcmp((char *)dev_node_obj,
+ "TIOMAP1510"))) {
+ /* Ensure the device extension is NULL */
+ drv_datap->dev_object = NULL;
+ }
+ }
if (status) {
/* Clean up */
dev_destroy_device(hdev_obj);
hdev_obj = NULL;
}
}
- if (!status) {
- /* Create the Manager Object */
- status = mgr_create(&hmgr_obj, dev_node_obj);
- }
- if (status) {
- if (hdev_obj)
- dev_destroy_device(hdev_obj);
-
- /* Ensure the device extension is NULL */
- cfg_set_dev_object(dev_node_obj, 0L);
- }
return status;
}
diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c
index 7b42f72a97b2..b23591b0f414 100644
--- a/drivers/staging/tidspbridge/pmgr/dspapi.c
+++ b/drivers/staging/tidspbridge/pmgr/dspapi.c
@@ -28,9 +28,7 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/ntfy.h>
-#include <dspbridge/services.h>
/* ----------------------------------- Platform Manager */
#include <dspbridge/chnl.h>
@@ -381,8 +379,8 @@ int api_init_complete2(void)
int status = 0;
struct cfg_devnode *dev_node;
struct dev_object *hdev_obj;
+ struct drv_data *drv_datap;
u8 dev_type;
- u32 tmp;
DBC_REQUIRE(api_c_refs > 0);
@@ -397,10 +395,12 @@ int api_init_complete2(void)
if (dev_get_dev_type(hdev_obj, &dev_type))
continue;
- if ((dev_type == DSP_UNIT) || (dev_type == IVA_UNIT))
- if (cfg_get_auto_start(dev_node, &tmp) == 0
- && tmp)
+ if ((dev_type == DSP_UNIT) || (dev_type == IVA_UNIT)) {
+ drv_datap = dev_get_drvdata(bridge);
+
+ if (drv_datap && drv_datap->base_img)
proc_auto_start(dev_node, hdev_obj);
+ }
}
return status;
diff --git a/drivers/staging/tidspbridge/pmgr/io.c b/drivers/staging/tidspbridge/pmgr/io.c
index 7970fe55648e..20cbb9fe40c2 100644
--- a/drivers/staging/tidspbridge/pmgr/io.c
+++ b/drivers/staging/tidspbridge/pmgr/io.c
@@ -26,9 +26,6 @@
/* ----------------------------------- Trace & Debug */
#include <dspbridge/dbc.h>
-/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
-
/* ----------------------------------- Platform Manager */
#include <dspbridge/dev.h>
diff --git a/drivers/staging/tidspbridge/rmgr/drv.c b/drivers/staging/tidspbridge/rmgr/drv.c
index 8a8dea6efeda..81b1b9013550 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -27,7 +27,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/list.h>
/* ----------------------------------- This */
@@ -309,6 +308,7 @@ int drv_create(struct drv_object **drv_obj)
{
int status = 0;
struct drv_object *pdrv_object = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(drv_obj != NULL);
DBC_REQUIRE(refs > 0);
@@ -335,9 +335,16 @@ int drv_create(struct drv_object **drv_obj)
} else {
status = -ENOMEM;
}
- /* Store the DRV Object in the Registry */
- if (!status)
- status = cfg_set_object((u32) pdrv_object, REG_DRV_OBJECT);
+ /* Store the DRV Object in the driver data */
+ if (!status) {
+ if (drv_datap) {
+ drv_datap->drv_object = (void *)pdrv_object;
+ } else {
+ status = -EPERM;
+ pr_err("%s: Failed to store DRV object\n", __func__);
+ }
+ }
+
if (!status) {
*drv_obj = pdrv_object;
} else {
@@ -374,6 +381,7 @@ int drv_destroy(struct drv_object *driver_obj)
{
int status = 0;
struct drv_object *pdrv_object = (struct drv_object *)driver_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(refs > 0);
DBC_REQUIRE(pdrv_object);
@@ -386,8 +394,13 @@ int drv_destroy(struct drv_object *driver_obj)
kfree(pdrv_object->dev_list);
kfree(pdrv_object->dev_node_string);
kfree(pdrv_object);
- /* Update the DRV Object in Registry to be 0 */
- (void)cfg_set_object(0, REG_DRV_OBJECT);
+ /* Update the DRV Object in the driver data */
+ if (drv_datap) {
+ drv_datap->drv_object = NULL;
+ } else {
+ status = -EPERM;
+ pr_err("%s: Failed to store DRV object\n", __func__);
+ }
return status;
}
@@ -438,11 +451,15 @@ u32 drv_get_first_dev_object(void)
{
u32 dw_dev_object = 0;
struct drv_object *pdrv_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
- if (!cfg_get_object((u32 *) &pdrv_obj, REG_DRV_OBJECT)) {
+ if (drv_datap && drv_datap->drv_object) {
+ pdrv_obj = drv_datap->drv_object;
if ((pdrv_obj->dev_list != NULL) &&
!LST_IS_EMPTY(pdrv_obj->dev_list))
dw_dev_object = (u32) lst_first(pdrv_obj->dev_list);
+ } else {
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
}
return dw_dev_object;
@@ -458,14 +475,17 @@ u32 drv_get_first_dev_extension(void)
{
u32 dw_dev_extension = 0;
struct drv_object *pdrv_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
- if (!cfg_get_object((u32 *) &pdrv_obj, REG_DRV_OBJECT)) {
-
+ if (drv_datap && drv_datap->drv_object) {
+ pdrv_obj = drv_datap->drv_object;
if ((pdrv_obj->dev_node_string != NULL) &&
!LST_IS_EMPTY(pdrv_obj->dev_node_string)) {
dw_dev_extension =
(u32) lst_first(pdrv_obj->dev_node_string);
}
+ } else {
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
}
return dw_dev_extension;
@@ -482,18 +502,22 @@ u32 drv_get_next_dev_object(u32 hdev_obj)
{
u32 dw_next_dev_object = 0;
struct drv_object *pdrv_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(hdev_obj != 0);
- if (!cfg_get_object((u32 *) &pdrv_obj, REG_DRV_OBJECT)) {
-
+ if (drv_datap && drv_datap->drv_object) {
+ pdrv_obj = drv_datap->drv_object;
if ((pdrv_obj->dev_list != NULL) &&
!LST_IS_EMPTY(pdrv_obj->dev_list)) {
dw_next_dev_object = (u32) lst_next(pdrv_obj->dev_list,
(struct list_head *)
hdev_obj);
}
+ } else {
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
}
+
return dw_next_dev_object;
}
@@ -509,16 +533,20 @@ u32 drv_get_next_dev_extension(u32 dev_extension)
{
u32 dw_dev_extension = 0;
struct drv_object *pdrv_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(dev_extension != 0);
- if (!cfg_get_object((u32 *) &pdrv_obj, REG_DRV_OBJECT)) {
+ if (drv_datap && drv_datap->drv_object) {
+ pdrv_obj = drv_datap->drv_object;
if ((pdrv_obj->dev_node_string != NULL) &&
!LST_IS_EMPTY(pdrv_obj->dev_node_string)) {
dw_dev_extension =
(u32) lst_next(pdrv_obj->dev_node_string,
(struct list_head *)dev_extension);
}
+ } else {
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
}
return dw_dev_extension;
@@ -616,6 +644,7 @@ int drv_request_resources(u32 dw_context, u32 *dev_node_strg)
int status = 0;
struct drv_object *pdrv_object;
struct drv_ext *pszdev_node;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(dw_context != 0);
DBC_REQUIRE(dev_node_strg != NULL);
@@ -626,7 +655,11 @@ int drv_request_resources(u32 dw_context, u32 *dev_node_strg)
* list.
*/
- status = cfg_get_object((u32 *) &pdrv_object, REG_DRV_OBJECT);
+ if (!drv_datap || !drv_datap->drv_object)
+ status = -ENODATA;
+ else
+ pdrv_object = drv_datap->drv_object;
+
if (!status) {
pszdev_node = kzalloc(sizeof(struct drv_ext), GFP_KERNEL);
if (pszdev_node) {
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 7ee89492a755..4c0b9ee07488 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -39,7 +39,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/services.h>
#include <dspbridge/clk.h>
#include <dspbridge/sync.h>
@@ -54,7 +53,6 @@
/* ----------------------------------- This */
#include <drv_interface.h>
-#include <dspbridge/cfg.h>
#include <dspbridge/resourcecleanup.h>
#include <dspbridge/chnl.h>
#include <dspbridge/proc.h>
@@ -271,7 +269,6 @@ static int omap3_bridge_startup(struct platform_device *pdev)
#endif
dsp_clk_init();
- services_init();
drv_datap = kzalloc(sizeof(struct drv_data), GFP_KERNEL);
if (!drv_datap) {
@@ -328,7 +325,6 @@ err1:
CPUFREQ_TRANSITION_NOTIFIER);
#endif
dsp_clk_exit();
- services_exit();
return err;
}
@@ -394,11 +390,14 @@ static int __devexit omap34_xx_bridge_remove(struct platform_device *pdev)
dev_t devno;
bool ret;
int status = 0;
- void *hdrv_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
- status = cfg_get_object((u32 *) &hdrv_obj, REG_DRV_OBJECT);
- if (status)
+ /* Retrieve the Object handle from the driver data */
+ if (!drv_datap || !drv_datap->drv_object) {
+ status = -ENODATA;
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
goto func_cont;
+ }
#ifdef CONFIG_TIDSPBRIDGE_DVFS
if (cpufreq_unregister_notifier(&iva_clk_notifier,
@@ -418,7 +417,6 @@ func_cont:
mem_ext_phys_pool_release();
dsp_clk_exit();
- services_exit();
devno = MKDEV(driver_major, 0);
cdev_del(&bridge_cdev);
diff --git a/drivers/staging/tidspbridge/rmgr/dspdrv.c b/drivers/staging/tidspbridge/rmgr/dspdrv.c
index 714f348f526a..7a6fc737872c 100644
--- a/drivers/staging/tidspbridge/rmgr/dspdrv.c
+++ b/drivers/staging/tidspbridge/rmgr/dspdrv.c
@@ -26,9 +26,6 @@
/* ----------------------------------- Trace & Debug */
#include <dspbridge/dbc.h>
-/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
-
/* ----------------------------------- Platform Manager */
#include <dspbridge/drv.h>
#include <dspbridge/dev.h>
@@ -121,6 +118,7 @@ bool dsp_deinit(u32 device_context)
bool ret = true;
u32 device_node;
struct mgr_object *mgr_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
while ((device_node = drv_get_first_dev_extension()) != 0) {
(void)dev_remove_device((struct cfg_devnode *)device_node);
@@ -131,10 +129,14 @@ bool dsp_deinit(u32 device_context)
(void)drv_destroy((struct drv_object *)device_context);
- /* Get the Manager Object from Registry
+ /* Get the Manager Object from driver data
* MGR Destroy will unload the DCD dll */
- if (!cfg_get_object((u32 *) &mgr_obj, REG_MGR_OBJECT))
+ if (drv_datap && drv_datap->mgr_object) {
+ mgr_obj = drv_datap->mgr_object;
(void)mgr_destroy(mgr_obj);
+ } else {
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
+ }
api_exit();
diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c b/drivers/staging/tidspbridge/rmgr/mgr.c
index 57a39b9c274b..0ea89a1bb77c 100644
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ b/drivers/staging/tidspbridge/rmgr/mgr.c
@@ -20,6 +20,9 @@
#include <linux/types.h>
+/* ----------------------------------- Host OS */
+#include <dspbridge/host_os.h>
+
/* ----------------------------------- DSP/BIOS Bridge */
#include <dspbridge/dbdefs.h>
@@ -27,7 +30,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/sync.h>
/* ----------------------------------- Others */
@@ -58,6 +60,7 @@ int mgr_create(struct mgr_object **mgr_obj,
{
int status = 0;
struct mgr_object *pmgr_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(mgr_obj != NULL);
DBC_REQUIRE(refs > 0);
@@ -67,7 +70,14 @@ int mgr_create(struct mgr_object **mgr_obj,
status = dcd_create_manager(ZLDLLNAME, &pmgr_obj->hdcd_mgr);
if (!status) {
/* If succeeded store the handle in the MGR Object */
- status = cfg_set_object((u32) pmgr_obj, REG_MGR_OBJECT);
+ if (drv_datap) {
+ drv_datap->mgr_object = (void *)pmgr_obj;
+ } else {
+ status = -EPERM;
+ pr_err("%s: Failed to store MGR object\n",
+ __func__);
+ }
+
if (!status) {
*mgr_obj = pmgr_obj;
} else {
@@ -94,6 +104,7 @@ int mgr_destroy(struct mgr_object *hmgr_obj)
{
int status = 0;
struct mgr_object *pmgr_obj = (struct mgr_object *)hmgr_obj;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(refs > 0);
DBC_REQUIRE(hmgr_obj);
@@ -103,8 +114,13 @@ int mgr_destroy(struct mgr_object *hmgr_obj)
dcd_destroy_manager(hmgr_obj->hdcd_mgr);
kfree(pmgr_obj);
- /* Update the Registry with NULL for MGR Object */
- (void)cfg_set_object(0, REG_MGR_OBJECT);
+ /* Update the driver data with NULL for MGR Object */
+ if (drv_datap) {
+ drv_datap->mgr_object = NULL;
+ } else {
+ status = -EPERM;
+ pr_err("%s: Failed to store MGR object\n", __func__);
+ }
return status;
}
@@ -123,6 +139,7 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
u32 node_index = 0;
struct dcd_genericobj gen_obj;
struct mgr_object *pmgr_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(pndb_props != NULL);
DBC_REQUIRE(pu_num_nodes != NULL);
@@ -130,10 +147,14 @@ int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
DBC_REQUIRE(refs > 0);
*pu_num_nodes = 0;
- /* Get The Manager Object from the Registry */
- status = cfg_get_object((u32 *) &pmgr_obj, REG_MGR_OBJECT);
- if (status)
+ /* Get the Manager Object from the driver data */
+ if (!drv_datap || !drv_datap->mgr_object) {
+ status = -ENODATA;
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
goto func_cont;
+ } else {
+ pmgr_obj = drv_datap->mgr_object;
+ }
DBC_ASSERT(pmgr_obj);
/* Forever loop till we hit failed or no more items in the
@@ -195,6 +216,7 @@ int mgr_enum_processor_info(u32 processor_id,
struct drv_object *hdrv_obj;
u8 dev_type;
struct cfg_devnode *dev_node;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
bool proc_detect = false;
DBC_REQUIRE(processor_info != NULL);
@@ -203,7 +225,15 @@ int mgr_enum_processor_info(u32 processor_id,
DBC_REQUIRE(refs > 0);
*pu_num_procs = 0;
- status = cfg_get_object((u32 *) &hdrv_obj, REG_DRV_OBJECT);
+
+ /* Retrieve the Object handle from the driver data */
+ if (!drv_datap || !drv_datap->drv_object) {
+ status = -ENODATA;
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
+ } else {
+ hdrv_obj = drv_datap->drv_object;
+ }
+
if (!status) {
status = drv_get_dev_object(processor_id, hdrv_obj, &hdev_obj);
if (!status) {
@@ -219,8 +249,10 @@ int mgr_enum_processor_info(u32 processor_id,
if (status)
goto func_end;
- /* Get The Manager Object from the Registry */
- if (cfg_get_object((u32 *) &pmgr_obj, REG_MGR_OBJECT)) {
+ /* Get The Manager Object from the driver data */
+ if (drv_datap && drv_datap->mgr_object) {
+ pmgr_obj = drv_datap->mgr_object;
+ } else {
dev_dbg(bridge, "%s: Failed to get MGR Object\n", __func__);
goto func_end;
}
diff --git a/drivers/staging/tidspbridge/rmgr/node.c b/drivers/staging/tidspbridge/rmgr/node.c
index 6e9441e21265..84882dc29a50 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -27,7 +27,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/list.h>
#include <dspbridge/memdefs.h>
#include <dspbridge/proc.h>
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index 44c26e11fc4a..b47d7aa747b1 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -29,7 +29,6 @@
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
#include <dspbridge/list.h>
#include <dspbridge/ntfy.h>
#include <dspbridge/sync.h>
@@ -280,6 +279,7 @@ proc_attach(u32 processor_id,
struct proc_object *p_proc_object = NULL;
struct mgr_object *hmgr_obj = NULL;
struct drv_object *hdrv_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
u8 dev_type;
DBC_REQUIRE(refs > 0);
@@ -291,9 +291,13 @@ proc_attach(u32 processor_id,
}
/* Get the Driver and Manager Object Handles */
- status = cfg_get_object((u32 *) &hdrv_obj, REG_DRV_OBJECT);
- if (!status)
- status = cfg_get_object((u32 *) &hmgr_obj, REG_MGR_OBJECT);
+ if (!drv_datap || !drv_datap->drv_object || !drv_datap->mgr_object) {
+ status = -ENODATA;
+ pr_err("%s: Failed to get object handles\n", __func__);
+ } else {
+ hdrv_obj = drv_datap->drv_object;
+ hmgr_obj = drv_datap->mgr_object;
+ }
if (!status) {
/* Get the Device Object */
@@ -393,18 +397,29 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj,
{
u8 dev_type;
s32 len;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
+
+ if (!exec_file)
+ return -EFAULT;
+
if (dev_type == DSP_UNIT) {
- return cfg_get_exec_file(dev_node_obj, size, exec_file);
- } else if (dev_type == IVA_UNIT) {
- if (iva_img) {
- len = strlen(iva_img);
- strncpy(exec_file, iva_img, len + 1);
- return 0;
- }
+ if (!drv_datap || !drv_datap->base_img)
+ return -EFAULT;
+
+ if (strlen(drv_datap->base_img) > size)
+ return -EINVAL;
+
+ strcpy(exec_file, drv_datap->base_img);
+ } else if (dev_type == IVA_UNIT && iva_img) {
+ len = strlen(iva_img);
+ strncpy(exec_file, iva_img, len + 1);
+ } else {
+ return -ENOENT;
}
- return -ENOENT;
+
+ return 0;
}
/*
@@ -429,6 +444,7 @@ int proc_auto_start(struct cfg_devnode *dev_node_obj,
char sz_exec_file[MAXCMDLINELEN];
char *argv[2];
struct mgr_object *hmgr_obj = NULL;
+ struct drv_data *drv_datap = dev_get_drvdata(bridge);
u8 dev_type;
DBC_REQUIRE(refs > 0);
@@ -436,9 +452,13 @@ int proc_auto_start(struct cfg_devnode *dev_node_obj,
DBC_REQUIRE(hdev_obj != NULL);
/* Create a Dummy PROC Object */
- status = cfg_get_object((u32 *) &hmgr_obj, REG_MGR_OBJECT);
- if (status)
+ if (!drv_datap || !drv_datap->mgr_object) {
+ status = -ENODATA;
+ pr_err("%s: Failed to retrieve the object handle\n", __func__);
goto func_end;
+ } else {
+ hmgr_obj = drv_datap->mgr_object;
+ }
p_proc_object = kzalloc(sizeof(struct proc_object), GFP_KERNEL);
if (p_proc_object == NULL) {
diff --git a/drivers/staging/tidspbridge/rmgr/strm.c b/drivers/staging/tidspbridge/rmgr/strm.c
index ef2ec9497b1c..f4986b7cc9e5 100644
--- a/drivers/staging/tidspbridge/rmgr/strm.c
+++ b/drivers/staging/tidspbridge/rmgr/strm.c
@@ -42,7 +42,6 @@
/* ----------------------------------- This */
#include <dspbridge/strm.h>
-#include <dspbridge/cfg.h>
#include <dspbridge/resourcecleanup.h>
/* ----------------------------------- Defines, Data Structures, Typedefs */
diff --git a/drivers/staging/tidspbridge/services/cfg.c b/drivers/staging/tidspbridge/services/cfg.c
deleted file mode 100644
index a7af74f482dd..000000000000
--- a/drivers/staging/tidspbridge/services/cfg.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * cfg.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implementation of platform specific config services.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-/* ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/* ----------------------------------- Trace & Debug */
-#include <dspbridge/dbc.h>
-
-/* ----------------------------------- OS Adaptation Layer */
-
-/* ----------------------------------- This */
-#include <dspbridge/cfg.h>
-#include <dspbridge/drv.h>
-
-struct drv_ext {
- struct list_head link;
- char sz_string[MAXREGPATHLENGTH];
-};
-
-/*
- * ======== cfg_exit ========
- * Purpose:
- * Discontinue usage of the CFG module.
- */
-void cfg_exit(void)
-{
- /* Do nothing */
-}
-
-/*
- * ======== cfg_get_auto_start ========
- * Purpose:
- * Retreive the autostart mask, if any, for this board.
- */
-int cfg_get_auto_start(struct cfg_devnode *dev_node_obj,
- u32 *auto_start)
-{
- int status = 0;
- u32 dw_buf_size;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- dw_buf_size = sizeof(*auto_start);
- if (!dev_node_obj)
- status = -EFAULT;
- if (!auto_start || !drv_datap)
- status = -EFAULT;
- if (!status)
- *auto_start = (drv_datap->base_img) ? 1 : 0;
-
- DBC_ENSURE((status == 0 &&
- (*auto_start == 0 || *auto_start == 1))
- || status != 0);
- return status;
-}
-
-/*
- * ======== cfg_get_dev_object ========
- * Purpose:
- * Retrieve the Device Object handle for a given devnode.
- */
-int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
- u32 *value)
-{
- int status = 0;
- u32 dw_buf_size;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- if (!drv_datap)
- status = -EPERM;
-
- if (!dev_node_obj)
- status = -EFAULT;
-
- if (!value)
- status = -EFAULT;
-
- dw_buf_size = sizeof(value);
- if (!status) {
-
- /* check the device string and then store dev object */
- if (!
- (strcmp
- ((char *)((struct drv_ext *)dev_node_obj)->sz_string,
- "TIOMAP1510")))
- *value = (u32)drv_datap->dev_object;
- }
- if (status)
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
- return status;
-}
-
-/*
- * ======== cfg_get_exec_file ========
- * Purpose:
- * Retreive the default executable, if any, for this board.
- */
-int cfg_get_exec_file(struct cfg_devnode *dev_node_obj, u32 buf_size,
- char *str_exec_file)
-{
- int status = 0;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- if (!dev_node_obj)
- status = -EFAULT;
-
- else if (!str_exec_file || !drv_datap)
- status = -EFAULT;
-
- if (strlen(drv_datap->base_img) > buf_size)
- status = -EINVAL;
-
- if (!status && drv_datap->base_img)
- strcpy(str_exec_file, drv_datap->base_img);
-
- if (status)
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
- DBC_ENSURE(((status == 0) &&
- (strlen(str_exec_file) <= buf_size))
- || (status != 0));
- return status;
-}
-
-/*
- * ======== cfg_get_object ========
- * Purpose:
- * Retrieve the Object handle from the Registry
- */
-int cfg_get_object(u32 *value, u8 dw_type)
-{
- int status = -EINVAL;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- DBC_REQUIRE(value != NULL);
-
- if (!drv_datap)
- return -EPERM;
-
- switch (dw_type) {
- case (REG_DRV_OBJECT):
- if (drv_datap->drv_object) {
- *value = (u32)drv_datap->drv_object;
- status = 0;
- } else {
- status = -ENODATA;
- }
- break;
- case (REG_MGR_OBJECT):
- if (drv_datap->mgr_object) {
- *value = (u32)drv_datap->mgr_object;
- status = 0;
- } else {
- status = -ENODATA;
- }
- break;
-
- default:
- break;
- }
- if (status) {
- *value = 0;
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
- }
- DBC_ENSURE((!status && *value != 0) || (status && *value == 0));
- return status;
-}
-
-/*
- * ======== cfg_init ========
- * Purpose:
- * Initialize the CFG module's private state.
- */
-bool cfg_init(void)
-{
- return true;
-}
-
-/*
- * ======== cfg_set_dev_object ========
- * Purpose:
- * Store the Device Object handle and dev_node pointer for a given devnode.
- */
-int cfg_set_dev_object(struct cfg_devnode *dev_node_obj, u32 value)
-{
- int status = 0;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- if (!drv_datap) {
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
- return -EPERM;
- }
-
- if (!dev_node_obj)
- status = -EFAULT;
-
- if (!status) {
- /* Store the Bridge device object in the Registry */
-
- if (!(strcmp((char *)dev_node_obj, "TIOMAP1510")))
- drv_datap->dev_object = (void *) value;
- }
- if (status)
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
-
- return status;
-}
-
-/*
- * ======== cfg_set_object ========
- * Purpose:
- * Store the Driver Object handle
- */
-int cfg_set_object(u32 value, u8 dw_type)
-{
- int status = -EINVAL;
- struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
- if (!drv_datap)
- return -EPERM;
-
- switch (dw_type) {
- case (REG_DRV_OBJECT):
- drv_datap->drv_object = (void *)value;
- status = 0;
- break;
- case (REG_MGR_OBJECT):
- drv_datap->mgr_object = (void *)value;
- status = 0;
- break;
- default:
- break;
- }
- if (status)
- pr_err("%s: Failed, status 0x%x\n", __func__, status);
- return status;
-}
diff --git a/drivers/staging/tidspbridge/services/ntfy.c b/drivers/staging/tidspbridge/services/ntfy.c
deleted file mode 100644
index a2ea698be24e..000000000000
--- a/drivers/staging/tidspbridge/services/ntfy.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ntfy.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Manage lists of notification events.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* ----------------------------------- This */
-#include <dspbridge/ntfy.h>
-
-int dsp_notifier_event(struct notifier_block *this, unsigned long event,
- void *data)
-{
- struct ntfy_event *ne = container_of(this, struct ntfy_event,
- noti_block);
- if (ne->event & event)
- sync_set_event(&ne->sync_obj);
- return NOTIFY_OK;
-}
-
diff --git a/drivers/staging/tidspbridge/services/services.c b/drivers/staging/tidspbridge/services/services.c
deleted file mode 100644
index 6a7dd6f3ecba..000000000000
--- a/drivers/staging/tidspbridge/services/services.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * services.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Provide SERVICES loading.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-#include <dspbridge/host_os.h>
-
-/* ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/* ----------------------------------- Trace & Debug */
-#include <dspbridge/dbc.h>
-
-/* ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/cfg.h>
-#include <dspbridge/ntfy.h>
-#include <dspbridge/sync.h>
-#include <dspbridge/clk.h>
-
-/* ----------------------------------- This */
-#include <dspbridge/services.h>
-
-/*
- * ======== services_exit ========
- * Purpose:
- * Discontinue usage of module; free resources when reference count
- * reaches 0.
- */
-void services_exit(void)
-{
- cfg_exit();
-}
-
-/*
- * ======== services_init ========
- * Purpose:
- * Initializes SERVICES modules.
- */
-bool services_init(void)
-{
- bool ret = true;
- bool fcfg;
-
- /* Perform required initialization of SERVICES modules. */
- fcfg = cfg_init();
-
- ret = fcfg;
-
- if (!ret) {
- if (fcfg)
- cfg_exit();
- }
-
- return ret;
-}
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 087137d9164d..6c09ef3c71ea 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -403,7 +403,7 @@ int tm6000_audio_init(struct tm6000_core *dev)
rc = snd_pcm_new(card, "TM6000 Audio", 0, 0, 1, &pcm);
if (rc < 0)
- goto error;
+ goto error_chip;
pcm->info_flags = 0;
pcm->private_data = chip;
@@ -413,12 +413,15 @@ int tm6000_audio_init(struct tm6000_core *dev)
rc = snd_card_register(card);
if (rc < 0)
- goto error;
+ goto error_chip;
dprintk(1,"Registered audio driver for %s\n", card->longname);
return 0;
+error_chip:
+ kfree(chip);
+ dev->adev = NULL;
error:
snd_card_free(card);
return rc;
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index cded411d8bba..80f2bf084505 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -702,10 +702,8 @@ void tm6000_unregister_extension(struct tm6000_ops *ops)
struct tm6000_core *dev = NULL;
mutex_lock(&tm6000_devlist_mutex);
- list_for_each_entry(dev, &tm6000_devlist, devlist) {
- if (dev)
- ops->fini(dev);
- }
+ list_for_each_entry(dev, &tm6000_devlist, devlist)
+ ops->fini(dev);
mutex_lock(&tm6000_extension_devlist_lock);
printk(KERN_INFO "tm6000: Remove (%s) extension\n", ops->name);
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index b6b753a49346..b186b5fed2b9 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -427,11 +427,11 @@ static int stub_probe(struct usb_interface *interface,
if (busid_priv->status == STUB_BUSID_ALLOC) {
- busid_priv->interf_count++;
sdev = busid_priv->sdev;
if (!sdev)
return -ENODEV;
+ busid_priv->interf_count++;
dev_info(&interface->dev,
"USB/IP Stub: register a new interface "
"(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum,
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 4d6b66a4fd9d..f5028d9d7d9b 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -955,12 +955,13 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
pDevice->dev = dev;
pDevice->next_module = root_device_dev;
root_device_dev = dev;
- dev->irq = pcid->irq;
if (pci_enable_device(pcid)) {
device_free_info(pDevice);
return -ENODEV;
}
+ dev->irq = pcid->irq;
+
#ifdef DEBUG
printk("Before get pci_info memaddr is %x\n",pDevice->memaddr);
#endif
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
index 43227617aabe..4009c0b5bb27 100644
--- a/drivers/staging/vt6655/iwctl.c
+++ b/drivers/staging/vt6655/iwctl.c
@@ -1900,7 +1900,7 @@ int iwctl_siwgenie(struct net_device *dev,
}
out://not completely ...not necessary in wpa_supplicant 0.5.8
- return 0;
+ return ret;
}
int iwctl_giwgenie(struct net_device *dev,
diff --git a/drivers/staging/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h
index 3d57f793986d..515b9c1d4d10 100644
--- a/drivers/staging/vt6656/80211mgr.h
+++ b/drivers/staging/vt6656/80211mgr.h
@@ -66,9 +66,9 @@
#define WLAN_EID_RSN_WPA 221
#ifdef Cisco_ccx
-#define WLAN_EID_CCX 133 //DavidWang
-#define WLAN_EID_CCX_IP 149 //DavidWang
-#define WLAN_EID_CCX_Ver 221 //DavidWang
+#define WLAN_EID_CCX 133
+#define WLAN_EID_CCX_IP 149
+#define WLAN_EID_CCX_Ver 221
#endif
#define WLAN_EID_ERP_NONERP_PRESENT 0x01
@@ -348,7 +348,7 @@ typedef struct tagWLAN_IE_RSN {
BYTE abyRSN[WLAN_MIN_ARRAY];
} WLAN_IE_RSN, *PWLAN_IE_RSN;
-//DavidWang
+
// CCX Identity DavidWang
#pragma pack(1)
typedef struct tagWLAN_IE_CCX {
@@ -371,7 +371,7 @@ BYTE len;
BYTE abyCCXVer[5];
} WLAN_IE_CCX_Ver, *PWLAN_IE_CCX_Ver;
-//DavidWang
+
// ERP
#pragma pack(1)
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index 29902492975c..e5add2046375 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -1010,11 +1010,9 @@ BOOL BBbVT3184Init(PSDevice pDevice)
}
- //20080215-01,<Add> by Mike Liu
// if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
// return FALSE;
-//20080804-01,<Add> by Mike Liu
//zonetype initial
pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index a9f68bd5afa6..2bdd0a2028d2 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -148,7 +148,6 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
for (ii = 0; ii <MAX_BSS_NUM; ii++) {
pCurrBSS = &(pMgmt->sBSSList[ii]);
- //2008-0718-01<Add>by MikeLiu
pCurrBSS->bSelected = FALSE;
if ((pCurrBSS->bActive) &&
@@ -188,7 +187,6 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
// if ((pCurrBSS->bActive) &&
// (pCurrBSS->bSelected == FALSE)) {
- //2007-0721-01<Add>by MikeLiu
pCurrBSS->bSelected = FALSE;
if (pCurrBSS->bActive) {
@@ -238,12 +236,12 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
}
}
*/
-//DavidWang
+
pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList pSelect1[%02X %02X %02X-%02X %02X %02X]\n",*pCurrBSS->abyBSSID,*(pCurrBSS->abyBSSID+1),*(pCurrBSS->abyBSSID+2),*(pCurrBSS->abyBSSID+3),*(pCurrBSS->abyBSSID+4),*(pCurrBSS->abyBSSID+5));
jj++;
-//DavidWang
+
if (pSelect == NULL) {
pSelect = pCurrBSS;
} else {
@@ -254,9 +252,9 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
}
}
}
-//DavidWang
+
pDevice->bSameBSSMaxNum = jj;
-//DavidWang
+
if (pSelect != NULL) {
pSelect->bSelected = TRUE;
if (pDevice->bRoaming == FALSE) {
@@ -956,7 +954,7 @@ void BSSvSecondCallBack(void *hDeviceContext)
unsigned int uSleepySTACnt = 0;
unsigned int uNonShortSlotSTACnt = 0;
unsigned int uLongPreambleSTACnt = 0;
- viawget_wpa_header *wpahdr; //DavidWang
+ viawget_wpa_header *wpahdr;
spin_lock_irq(&pDevice->lock);
@@ -1180,7 +1178,7 @@ if((pMgmt->eCurrState!=WMAC_STATE_ASSOC) &&
pDevice->bIsRoaming = FALSE;
DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
- //let wpa supplicant know AP may disconnect.//20080717-01,<Add> by James Li
+ /* let wpa supplicant know AP may disconnect */
if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
wpahdr = (viawget_wpa_header *)pDevice->skb->data;
wpahdr->type = VIAWGET_DISASSOC_MSG;
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index b9852aa22c06..e8d0b4203cad 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -258,8 +258,6 @@ typedef enum _VIA_PKT_TYPE
//++ NDIS related
-#define NDIS_STATUS int
-
typedef enum __DEVICE_NDIS_STATUS {
STATUS_SUCCESS = 0,
STATUS_FAILURE,
@@ -267,7 +265,6 @@ typedef enum __DEVICE_NDIS_STATUS {
STATUS_PENDING,
} DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS;
-
#define MAX_BSSIDINFO_4_PMKID 16
#define MAX_PMKIDLIST 5
//Flags for PMKID Candidate list structure
@@ -713,11 +710,11 @@ typedef struct __device_info {
BOOL bCmdClear;
BOOL bNeedRadioOFF;
- BOOL bEnableRoaming; //DavidWang
- BOOL bIsRoaming; //DavidWang
- BOOL bFastRoaming; //DavidWang
- BYTE bSameBSSMaxNum; //Davidwang
- BYTE bSameBSSCurNum; //DavidWang
+ BOOL bEnableRoaming;
+ BOOL bIsRoaming;
+ BOOL bFastRoaming;
+ BYTE bSameBSSMaxNum;
+ BYTE bSameBSSCurNum;
BOOL bRoaming;
BOOL b11hEable;
unsigned long ulTxPower;
@@ -726,7 +723,6 @@ typedef struct __device_info {
NDIS_802_11_WEP_STATUS eEncryptionStatus;
BOOL bTransmitKey;
-//2007-0925-01<Add>by MikeLiu
//mike add :save old Encryption
NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
@@ -891,11 +887,8 @@ typedef struct __device_info {
#define fMP_CONTROL_READS 0x00000400
#define fMP_CONTROL_WRITES 0x00000800
-
-
#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
-#define MP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
#define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
#define MP_IS_READY(_M) (((_M)->Flags & \
@@ -909,5 +902,3 @@ typedef struct __device_info {
BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
#endif
-
-
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index 5e88349d3b95..1f9d29636803 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -200,10 +200,9 @@ s_vProcessRxMACHeader (
} else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
cbHeaderSize += 6;
pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
- if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) {
- }
- else {
- cbHeaderSize -= 8;
+ if ((*pwType == cpu_to_le16(ETH_P_IPX)) ||
+ (*pwType == cpu_to_le16(0xF380))) {
+ cbHeaderSize -= 8;
pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
if (bIsWEP) {
if (bExtIV) {
@@ -377,9 +376,9 @@ RXbBulkInProcessData (
return FALSE;
}
- if ((BytesToIndicate > 2372)||(BytesToIndicate <= 40)) {
+ if ((BytesToIndicate > 2372) || (BytesToIndicate <= 40)) {
// Frame Size error drop this packet.
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 2 \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---------- WRONG Length 2\n");
return FALSE;
}
@@ -865,7 +864,6 @@ RXbBulkInProcessData (
pDevice->dev->name);
}
}
- //2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
//send event to wpa_supplicant
//if(pDevice->bWPASuppWextEnabled == TRUE)
@@ -1524,7 +1522,8 @@ void RXvWorkItem(void *Context)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n");
spin_lock_irq(&pDevice->lock);
- while ( MP_TEST_FLAG(pDevice, fMP_POST_READS) &&
+
+ while ((pDevice->Flags & fMP_POST_READS) &&
MP_IS_READY(pDevice) &&
(pDevice->NumRecvFreeList != 0) ) {
pRCB = pDevice->FirstRecvFreeList;
@@ -1569,7 +1568,7 @@ RXvFreeRCB(
pDevice->NumRecvFreeList++;
- if (MP_TEST_FLAG(pDevice, fMP_POST_READS) && MP_IS_READY(pDevice) &&
+ if ((pDevice->Flags & fMP_POST_READS) && MP_IS_READY(pDevice) &&
(pDevice->bIsRxWorkItemQueued == FALSE) ) {
pDevice->bIsRxWorkItemQueued = TRUE;
diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index ebb9c99df70c..ad06fd1398e6 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -773,7 +773,7 @@ FIRMWAREbDownload(
PSDevice pDevice
)
{
- NDIS_STATUS NdisStatus;
+ int NdisStatus;
PBYTE pBuffer = NULL;
WORD wLength;
int ii;
@@ -823,7 +823,7 @@ FIRMWAREbBrach2Sram(
PSDevice pDevice
)
{
- NDIS_STATUS NdisStatus;
+ int NdisStatus;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n");
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c
index d532618639bc..2fe071ca42fa 100644
--- a/drivers/staging/vt6656/ioctl.c
+++ b/drivers/staging/vt6656/ioctl.c
@@ -670,7 +670,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) {
pMgmt->Cisco_cckm =1;
else
pMgmt->Cisco_cckm =0;
-//DavidWang
+
if(wpa_Result.authenticated==TRUE) {
{
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
index 016b8e7766f3..0004be8e3957 100644
--- a/drivers/staging/vt6656/iwctl.c
+++ b/drivers/staging/vt6656/iwctl.c
@@ -49,7 +49,6 @@
/*--------------------- Static Definitions -------------------------*/
-//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
#define SUPPORTED_WIRELESS_EXT 18
#else
@@ -155,7 +154,6 @@ int iwctl_siwscan(struct net_device *dev,
BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
PWLAN_IE_SSID pItemSSID=NULL;
-//2008-0920-01<Add>by MikeLiu
if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
return -EINVAL;
@@ -285,7 +283,6 @@ int iwctl_giwscan(struct net_device *dev,
iwe.u.freq.e = 0;
iwe.u.freq.i = 0;
current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
- //2008-0409-04, <Add> by Einsn Liu
{
int f = (int)pBSS->uChannel - 1;
if(f < 0)f = 0;
@@ -299,7 +296,7 @@ int iwctl_giwscan(struct net_device *dev,
RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
iwe.u.qual.level = ldBm;
iwe.u.qual.noise = 0;
-//2008-0409-01, <Add> by Einsn Liu
+
if(-ldBm<50){
iwe.u.qual.qual = 100;
}else if(-ldBm > 90) {
@@ -803,7 +800,6 @@ int iwctl_siwessid(struct net_device *dev,
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
PWLAN_IE_SSID pItemSSID;
-//2008-0920-01<Add>by MikeLiu
if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
return -EINVAL;
@@ -931,11 +927,10 @@ int iwctl_giwessid(struct net_device *dev,
//pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
extra[pItemSSID->len] = '\0';
- //2008-0409-03, <Add> by Einsn Liu
+
wrq->length = pItemSSID->len;
wrq->flags = 1; // active
-
return 0;
}
@@ -1392,8 +1387,6 @@ int iwctl_giwencode(struct net_device *dev,
}
*/
-//2008-0409-06, <Add> by Einsn Liu
-
int iwctl_giwencode(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *wrq,
@@ -1561,7 +1554,6 @@ int iwctl_giwsens(struct net_device *dev,
return 0;
}
-//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
int iwctl_siwauth(struct net_device *dev,
@@ -1598,7 +1590,8 @@ int iwctl_siwauth(struct net_device *dev,
pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
}else if(pairwise == IW_AUTH_CIPHER_TKIP){
pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
- }else if(pairwise == IW_AUTH_CIPHER_WEP40||pairwise == IW_AUTH_CIPHER_WEP104){
+ } else if (pairwise == IW_AUTH_CIPHER_WEP40 ||
+ pairwise == IW_AUTH_CIPHER_WEP104) {
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
}else if(pairwise == IW_AUTH_CIPHER_NONE){
//do nothing,einsn liu
@@ -1726,7 +1719,7 @@ int iwctl_siwgenie(struct net_device *dev,
}
out://not completely ...not necessary in wpa_supplicant 0.5.8
- return 0;
+ return ret;
}
int iwctl_giwgenie(struct net_device *dev,
@@ -1933,9 +1926,6 @@ int iwctl_siwmlme(struct net_device *dev,
}
#endif
-//End Add --//2008-0409-07, <Add> by Einsn Liu
-
-
/*------------------------------------------------------------------*/
/*
diff --git a/drivers/staging/vt6656/iwctl.h b/drivers/staging/vt6656/iwctl.h
index d601e9220219..cc48954783fc 100644
--- a/drivers/staging/vt6656/iwctl.h
+++ b/drivers/staging/vt6656/iwctl.h
@@ -178,7 +178,6 @@ int iwctl_siwscan(struct net_device *dev,
struct iw_param *wrq,
char *extra);
-//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
int iwctl_siwauth(struct net_device *dev,
struct iw_request_info *info,
@@ -215,8 +214,6 @@ int iwctl_siwmlme(struct net_device *dev,
struct iw_point *wrq,
char *extra);
#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
-
extern const struct iw_handler_def iwctl_handler_def;
extern const struct iw_priv_args iwctl_private_args;
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index d181a2f66266..27bb523c8a97 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -559,7 +559,7 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
int i, ii;
*pKey = NULL;
- for (i=0;i<MAX_KEY_TABLE;i++) {
+ for (i = 0; i < MAX_KEY_TABLE; i++) {
if ((pTable->KeyTable[i].bInUse == TRUE) &&
!compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index c528ef0f8ed4..e992d5d9e15b 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -282,7 +282,6 @@ static int Config_FileGetParameter(unsigned char *string,
unsigned char *dest,
unsigned char *source);
-//2008-0714<Add>by Mike Liu
static BOOL device_release_WPADEV(PSDevice pDevice);
static void usb_device_reset(PSDevice pDevice);
@@ -771,10 +770,9 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
udev = usb_get_dev(udev);
netdev = alloc_etherdev(sizeof(DEVICE_INFO));
-
if (!netdev) {
printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n");
- kfree(pDevice);
+ rc = -ENOMEM;
goto err_nomem;
}
@@ -800,9 +798,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
rc = register_netdev(netdev);
if (rc) {
printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
- free_netdev(netdev);
- kfree(pDevice);
- return -ENODEV;
+ goto err_netdev;
}
usb_device_reset(pDevice);
@@ -820,10 +816,12 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
return 0;
+err_netdev:
+ free_netdev(netdev);
err_nomem:
usb_put_dev(udev);
- return -ENOMEM;
+ return rc;
}
static void device_free_tx_bufs(PSDevice pDevice)
@@ -869,7 +867,6 @@ static void device_free_rx_bufs(PSDevice pDevice)
return;
}
-//2007-1107-02<Add>by MikeLiu
static void usb_device_reset(PSDevice pDevice)
{
int status;
@@ -1091,8 +1088,8 @@ static int device_open(struct net_device *dev) {
memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
pDevice->bStopTx0Pkt = FALSE;
pDevice->bStopDataPkt = FALSE;
- pDevice->bRoaming = FALSE; //DavidWang
- pDevice->bIsRoaming = FALSE;//DavidWang
+ pDevice->bRoaming = FALSE;
+ pDevice->bIsRoaming = FALSE;
pDevice->bEnableRoaming = FALSE;
if (pDevice->bDiversityRegCtlON) {
device_init_diversity_timer(pDevice);
@@ -1195,14 +1192,11 @@ static int device_close(struct net_device *dev) {
wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
}
-//2007-1121-02<Add>by EinsnLiu
if (pDevice->bLinkPass) {
bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
mdelay(30);
}
-//End Add
-//2008-0714-01<Add>by MikeLiu
device_release_WPADEV(pDevice);
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
@@ -1236,8 +1230,8 @@ device_release_WPADEV(pDevice);
tasklet_kill(&pDevice->ReadWorkItem);
tasklet_kill(&pDevice->EventWorkItem);
- pDevice->bRoaming = FALSE; //DavidWang
- pDevice->bIsRoaming = FALSE;//DavidWang
+ pDevice->bRoaming = FALSE;
+ pDevice->bIsRoaming = FALSE;
pDevice->bEnableRoaming = FALSE;
pDevice->bCmdRunning = FALSE;
pDevice->bLinkPass = FALSE;
@@ -1914,11 +1908,9 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
*/
break;
-
-//2008-0409-07, <Add> by Einsn Liu
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
case SIOCSIWAUTH:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH\n");
rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);
break;
@@ -1970,7 +1962,6 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
break;
#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
case IOCTL_CMD_TEST:
diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c
index 4d7d4e014d00..0c12fd36d0f9 100644
--- a/drivers/staging/vt6656/power.c
+++ b/drivers/staging/vt6656/power.c
@@ -77,12 +77,12 @@ void PSvEnablePowerSaving(void *hDeviceContext,
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
- // set period of power up before TBTT
+ /* set period of power up before TBTT */
MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT);
if (pDevice->eOPMode != OP_MODE_ADHOC) {
- // set AID
- MACvWriteWord(pDevice, MAC_REG_AIDATIM, wAID);
+ /* set AID */
+ MACvWriteWord(pDevice, MAC_REG_AIDATIM, wAID);
} else {
// set ATIM Window
//MACvWriteATIMW(pDevice->PortOffset, pMgmt->wCurrATIMWindow);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index deca2137d921..bbdc127a987d 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -841,8 +841,8 @@ s_uFillDataHead (
}
if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
- if((uDMAIdx==TYPE_ATIMDMA)||(uDMAIdx==TYPE_BEACONDMA)) {
- PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead;
+ if ((uDMAIdx == TYPE_ATIMDMA) || (uDMAIdx == TYPE_BEACONDMA)) {
+ PSTxDataHead_ab pBuf = (PSTxDataHead_ab) pTxDataHead;
//Get SignalField,ServiceField,Length
BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType,
(PWORD)&(pBuf->wTransmitLength), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField)
@@ -1701,10 +1701,11 @@ s_bPacketToWirelessUsb(
// 802.1H
if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) {
- if (pDevice->dwDiagRefCount == 0) {
- if ( (psEthHeader->wType == TYPE_PKT_IPX) ||
- (psEthHeader->wType == cpu_to_le16(0xF380))) {
- memcpy((PBYTE) (pbyPayloadHead), &abySNAP_Bridgetunnel[0], 6);
+ if (pDevice->dwDiagRefCount == 0) {
+ if ((psEthHeader->wType == cpu_to_le16(ETH_P_IPX)) ||
+ (psEthHeader->wType == cpu_to_le16(0xF380))) {
+ memcpy((PBYTE) (pbyPayloadHead),
+ abySNAP_Bridgetunnel, 6);
} else {
memcpy((PBYTE) (pbyPayloadHead), &abySNAP_RFC1042[0], 6);
}
@@ -2840,9 +2841,10 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
Packet_Type = skb->data[ETH_HLEN+1];
Descriptor_type = skb->data[ETH_HLEN+1+1+2];
Key_info = (skb->data[ETH_HLEN+1+1+2+1] << 8)|(skb->data[ETH_HLEN+1+1+2+2]);
- if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
- if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
- (Packet_Type==3)) { //802.1x OR eapol-key challenge frame transfer
+ if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) {
+ /* 802.1x OR eapol-key challenge frame transfer */
+ if (((Protocol_Version == 1) || (Protocol_Version == 2)) &&
+ (Packet_Type == 3)) {
bTxeapol_key = TRUE;
if(!(Key_info & BIT3) && //WPA or RSN group-key challenge
(Key_info & BIT8) && (Key_info & BIT9)) { //send 2/2 key
@@ -2988,7 +2990,7 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
}
}
- if (pDevice->sTxEthHeader.wType == TYPE_PKT_802_1x) {
+ if (pDevice->sTxEthHeader.wType == cpu_to_le16(ETH_P_PAE)) {
if (pDevice->byBBType != BB_TYPE_11A) {
pDevice->wCurrentRate = RATE_1M;
pDevice->byACKRate = RATE_1M;
@@ -3016,8 +3018,8 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
if (bNeedEncryption == TRUE) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ntohs Pkt Type=%04x\n", ntohs(pDevice->sTxEthHeader.wType));
- if ((pDevice->sTxEthHeader.wType) == TYPE_PKT_802_1x) {
- bNeedEncryption = FALSE;
+ if ((pDevice->sTxEthHeader.wType) == cpu_to_le16(ETH_P_PAE)) {
+ bNeedEncryption = FALSE;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Pkt Type=%04x\n", (pDevice->sTxEthHeader.wType));
if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
if (pTransmitKey == NULL) {
diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h
index be87020d5323..4ec05237469b 100644
--- a/drivers/staging/vt6656/tether.h
+++ b/drivers/staging/vt6656/tether.h
@@ -42,22 +42,8 @@
#ifdef __BIG_ENDIAN
-#define TYPE_PKT_IP 0x0800 //
-#define TYPE_PKT_ARP 0x0806 //
-#define TYPE_PKT_RARP 0x8035 //
-#define TYPE_PKT_IPX 0x8137 //
-#define TYPE_PKT_802_1x 0x888e
-#define TYPE_PKT_PreAuth 0x88C7
-
-#define TYPE_PKT_PING_M_REQ 0x8011 // master reguest
-#define TYPE_PKT_PING_S_GNT 0x8022 // slave grant
-#define TYPE_PKT_PING_M 0x8077 // pingpong master packet
-#define TYPE_PKT_PING_S 0x8088 // pingpong slave packet
-#define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request
-#define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant
#define TYPE_MGMT_PROBE_RSP 0x5000
-#define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt
-#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
+
//
// wFrameCtl field in the S802_11Header
//
@@ -94,23 +80,9 @@
//
// NOTE....
// in network byte order, high byte is going first
-#define TYPE_PKT_IP 0x0008 //
-#define TYPE_PKT_ARP 0x0608 //
-#define TYPE_PKT_RARP 0x3580 //
-#define TYPE_PKT_IPX 0x3781 //
-
-#define TYPE_PKT_802_1x 0x8e88
-#define TYPE_PKT_PreAuth 0xC788
-
-#define TYPE_PKT_PING_M_REQ 0x1180 // master reguest
-#define TYPE_PKT_PING_S_GNT 0x2280 // slave grant
-#define TYPE_PKT_PING_M 0x7780 // pingpong master packet
-#define TYPE_PKT_PING_S 0x8880 // pingpong slave packet
-#define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request
-#define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant
+
#define TYPE_MGMT_PROBE_RSP 0x0050
-#define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt
-#define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt
+
//
// wFrameCtl field in the S802_11Header
//
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index a32785cb9d18..c612ab58f389 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -118,13 +118,11 @@ int PIPEnsControlOutAsyn(
{
int ntStatus;
- if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;
-
- if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES)) {
+ if (pDevice->Flags & fMP_CONTROL_WRITES)
return STATUS_FAILURE;
- }
if (in_interrupt()) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
@@ -164,12 +162,11 @@ int PIPEnsControlOut(
int ntStatus = 0;
int ii;
- if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;
- if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES)) {
+ if (pDevice->Flags & fMP_CONTROL_WRITES)
return STATUS_FAILURE;
- }
pDevice->sUsbCtlRequest.bRequestType = 0x40;
pDevice->sUsbCtlRequest.bRequest = byRequest;
@@ -193,12 +190,15 @@ int PIPEnsControlOut(
}
spin_unlock_irq(&pDevice->lock);
for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
- if (MP_TEST_FLAG(pDevice, fMP_CONTROL_WRITES))
- mdelay(1);
+
+ if (pDevice->Flags & fMP_CONTROL_WRITES)
+ mdelay(1);
else
- break;
+ break;
+
if (ii >= USB_CTL_WAIT) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission timeout \n");
+ DBG_PRT(MSG_LEVEL_DEBUG,
+ KERN_INFO "control send request submission timeout\n");
spin_lock_irq(&pDevice->lock);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
return STATUS_FAILURE;
@@ -221,12 +221,12 @@ int PIPEnsControlIn(
int ntStatus = 0;
int ii;
- if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;
- if (MP_TEST_FLAG(pDevice, fMP_CONTROL_READS)) {
- return STATUS_FAILURE;
- }
+ if (pDevice->Flags & fMP_CONTROL_READS)
+ return STATUS_FAILURE;
+
pDevice->sUsbCtlRequest.bRequestType = 0xC0;
pDevice->sUsbCtlRequest.bRequest = byRequest;
pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
@@ -247,13 +247,15 @@ int PIPEnsControlIn(
spin_unlock_irq(&pDevice->lock);
for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
- if (MP_TEST_FLAG(pDevice, fMP_CONTROL_READS))
- mdelay(1);
- else {
- break;
- }
- if (ii >= USB_CTL_WAIT) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control rcv request submission timeout \n");
+
+ if (pDevice->Flags & fMP_CONTROL_READS)
+ mdelay(1);
+ else
+ break;
+
+ if (ii >= USB_CTL_WAIT) {
+ DBG_PRT(MSG_LEVEL_DEBUG,
+ KERN_INFO "control rcv request submission timeout\n");
spin_lock_irq(&pDevice->lock);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
return STATUS_FAILURE;
@@ -492,7 +494,7 @@ int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
- if (MP_TEST_FLAG(pDevice, fMP_DISCONNECTED))
+ if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE;
pDevice->ulBulkInPosted++;
@@ -618,7 +620,7 @@ s_nsBulkInUsbIoCompleteRead(
* Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
*
*/
-NDIS_STATUS
+int
PIPEnsSendBulkOut(
PSDevice pDevice,
PUSB_SEND_CONTEXT pContext
@@ -643,7 +645,7 @@ PIPEnsSendBulkOut(
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
- if(MP_IS_READY(pDevice) && MP_TEST_FLAG(pDevice, fMP_POST_WRITES)) {
+ if (MP_IS_READY(pDevice) && (pDevice->Flags & fMP_POST_WRITES)) {
pUrb = pContext->pUrb;
pDevice->ulBulkOutPosted++;
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index 686747a09294..b83b660b1f0f 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -500,7 +500,7 @@ void vRunCommand(void *hDeviceContext)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Scanning, set back to channel: [%d]\n", pMgmt->uCurrChannel);
pMgmt->eScanState = WMAC_NO_SCANNING;
pDevice->bStopDataPkt = FALSE;
-//2008-0409-07, <Add> by Einsn Liu
+
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
if(pMgmt->eScanType == WMAC_SCAN_PASSIVE)
{
@@ -876,7 +876,7 @@ void vRunCommand(void *hDeviceContext)
// CARDbRadioPowerOn(pDevice);
// else
// CARDbRadioPowerOff(pDevice);
- //2008-09-09<Add> BY Mike:Hot Key for Radio On/Off
+
{
int ntStatus = STATUS_SUCCESS;
BYTE byTmp;
diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c
index e4eca9b060b1..2ec200d8b736 100644
--- a/drivers/staging/vt6656/wmgr.c
+++ b/drivers/staging/vt6656/wmgr.c
@@ -92,7 +92,7 @@ static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Functions --------------------------*/
-//2008-0730-01<Add>by MikeLiu
+
static BOOL ChannelExceedZoneType(
PSDevice pDevice,
BYTE byCurrChannel
@@ -997,7 +997,7 @@ s_vMgrRxAssocResponse(
netif_rx(pDevice->skb);
pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
}
-//2008-0409-07, <Add> by Einsn Liu
+
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
//if(pDevice->bWPASuppWextEnabled == TRUE)
{
@@ -1038,7 +1038,7 @@ s_vMgrRxAssocResponse(
}
#endif //#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-//End Add -- //2008-0409-07, <Add> by Einsn Liu
+
}
else {
if (bReAssocType) {
@@ -1745,7 +1745,6 @@ s_vMgrRxDeauthentication(
return;
}
-//2008-0730-01<Add>by MikeLiu
/*+
*
* Routine Description:
@@ -1868,7 +1867,6 @@ s_vMgrRxBeacon(
}
}
-//2008-0730-01<Add>by MikeLiu
if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
return;
@@ -2638,8 +2636,9 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus)
if (WLAN_GET_CAP_INFO_ESS(cpu_to_le16(pCurr->wCapInfo))){
- if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA)||(pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
-/*
+ if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
+ (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
+ /*
if (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled) {
if (WPA_SearchRSN(0, WPA_TKIP, pCurr) == FALSE) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No match RSN info. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
@@ -4239,7 +4238,6 @@ s_vMgrRxProbeResponse(
}
//RobertYu:20050201
-//2008-0730-01<Add>by MikeLiu
if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
return;
@@ -4767,8 +4765,9 @@ s_bCipherMatch (
if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) &&
(pBSSNode->bWPA2Valid == TRUE) &&
- //20080123-01,<Add> by Einsn Liu
- ((EncStatus == Ndis802_11Encryption3Enabled)||(EncStatus == Ndis802_11Encryption2Enabled))) {
+
+ ((EncStatus == Ndis802_11Encryption3Enabled) ||
+ (EncStatus == Ndis802_11Encryption2Enabled))) {
//WPA2
// check Group Key Cipher
if ((pBSSNode->byCSSGK == WLAN_11i_CSS_WEP40) ||
diff --git a/drivers/staging/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h
index 683840c0ac45..594f3a89d8a7 100644
--- a/drivers/staging/vt6656/wmgr.h
+++ b/drivers/staging/vt6656/wmgr.h
@@ -355,7 +355,7 @@ typedef struct tagSMgmtObject
// link list of known bss's (scan results)
KnownBSS sBSSList[MAX_BSS_NUM];
- //link list of same bss's //DavidWang
+ /* link list of same bss's */
KnownBSS pSameBSS[6] ;
BOOL Cisco_cckm ;
BYTE Roam_dbm;
diff --git a/drivers/staging/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c
index f492778ee8b6..7dde3d6941ab 100644
--- a/drivers/staging/vt6656/wpa.c
+++ b/drivers/staging/vt6656/wpa.c
@@ -69,7 +69,7 @@ const BYTE abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 };
-*/
void
-WPA_ClearRSN (
+WPA_ClearRSN(
PKnownBSS pBSSList
)
{
@@ -105,7 +105,7 @@ WPA_ClearRSN (
*
-*/
void
-WPA_ParseRSN (
+WPA_ParseRSN(
PKnownBSS pBSSList,
PWLAN_IE_RSN_EXT pRSN
)
@@ -240,7 +240,7 @@ WPA_ParseRSN (
*
-*/
BOOL
-WPA_SearchRSN (
+WPA_SearchRSN(
BYTE byCmd,
BYTE byEncrypt,
PKnownBSS pBSSList
@@ -300,7 +300,7 @@ WPA_SearchRSN (
*
-*/
BOOL
-WPAb_Is_RSN (
+WPAb_Is_RSN(
PWLAN_IE_RSN_EXT pRSN
)
{
diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c
index b407ae536bf5..7fd300f2e7c3 100644
--- a/drivers/staging/vt6656/wpactl.c
+++ b/drivers/staging/vt6656/wpactl.c
@@ -515,7 +515,6 @@ static int wpa_set_scan(PSDevice pDevice,
{
int ret = 0;
-//2007-0919-01<Add>by MikeLiu
/**set ap_scan=1&&scan_ssid=1 under hidden ssid mode**/
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
PWLAN_IE_SSID pItemSSID;
@@ -695,7 +694,7 @@ static int wpa_get_scan(PSDevice pDevice,
scan_buf->ssid_len = pItemSSID->len;
scan_buf->freq = frequency_list[pBSS->uChannel-1];
scan_buf->caps = pBSS->wCapInfo; //DavidWang for sharemode
-//20080717-05,<Add> by James Li
+
RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
if(-ldBm<50){
scan_buf->qual = 100;
@@ -710,7 +709,7 @@ static int wpa_get_scan(PSDevice pDevice,
//scan_buf->qual =
scan_buf->noise = 0;
scan_buf->level = ldBm;
- //20080717-05,<Add> by James Li--End
+
//scan_buf->maxrate =
if (pBSS->wWPALen != 0) {
scan_buf->wpa_ie_len = pBSS->wWPALen;
@@ -873,7 +872,6 @@ static int wpa_set_associate(PSDevice pDevice,
pMgmt->eCurrState = WMAC_STATE_IDLE;
netif_stop_queue(pDevice->dev);
-//20080701-02,<Add> by Mike Liu
/*******search if ap_scan=2 ,which is associating request in hidden ssid mode ****/
{
PKnownBSS pCurr = NULL;
diff --git a/drivers/staging/westbridge/Kconfig b/drivers/staging/westbridge/Kconfig
new file mode 100644
index 000000000000..57468125b391
--- /dev/null
+++ b/drivers/staging/westbridge/Kconfig
@@ -0,0 +1,34 @@
+#
+# West Bridge configuration
+#
+
+menuconfig WESTBRIDGE
+ tristate "West Bridge support"
+ depends on HAS_IOMEM && BROKEN
+ help
+ This selects West Bridge Peripheral controller support.
+
+ If you want West Bridge support, you should say Y here.
+
+menuconfig WESTBRIDGE_ASTORIA
+ bool "West Bridge Astoria support"
+ depends on WESTBRIDGE != n
+ help
+ This option enables support for West Bridge Astoria
+
+if WESTBRIDGE_ASTORIA
+source "drivers/staging/westbridge/astoria/Kconfig"
+endif #WESTBRIDGE_ASTORIA
+
+menuconfig MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+ bool "WESTBRIDGE OMAP3430 Astoria PNAND HAL"
+ depends on ARCH_OMAP3 && WESTBRIDGE_ASTORIA
+ help
+ Include the OMAP3430 Linux Based HAL
+
+config WESTBRIDGE_DEBUG
+ bool "West Bridge debugging"
+ depends on WESTBRIDGE != n
+ help
+ This is an option for use by developers; most people should
+ say N here. This enables WESTBRIDGE core and driver debugging.
diff --git a/drivers/staging/westbridge/TODO b/drivers/staging/westbridge/TODO
new file mode 100644
index 000000000000..6ca80581bbe2
--- /dev/null
+++ b/drivers/staging/westbridge/TODO
@@ -0,0 +1,7 @@
+TODO:
+- checkpatch.pl fixes
+- determine where to put the hal and common api code
+- modify the driver directory structure in an intuitive way
+
+Please send any patches to Greg Kroah-Hartman <gregkh@suse.de>
+and David Cross <david.cross@cypress.com>.
diff --git a/drivers/staging/westbridge/astoria/Kconfig b/drivers/staging/westbridge/astoria/Kconfig
new file mode 100644
index 000000000000..1ce388acbfeb
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/Kconfig
@@ -0,0 +1,9 @@
+#
+# West Bridge configuration
+#
+source "drivers/staging/westbridge/astoria/device/Kconfig"
+
+source "drivers/staging/westbridge/astoria/block/Kconfig"
+
+source "drivers/staging/westbridge/astoria/gadget/Kconfig"
+
diff --git a/drivers/staging/westbridge/astoria/Makefile b/drivers/staging/westbridge/astoria/Makefile
new file mode 100644
index 000000000000..907bdb25804b
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for the kernel westbridge device drivers.
+#
+
+ifneq ($(CONFIG_WESTBRIDGE_DEBUG),y)
+ EXTRA_CFLAGS += -WESTBRIDGE_NDEBUG
+endif
+
+obj-$(CONFIG_WESTBRIDGE) += device/
+obj-$(CONFIG_WESTBRIDGE) += block/
+obj-$(CONFIG_WESTBRIDGE) += gadget/ \ No newline at end of file
diff --git a/drivers/staging/westbridge/astoria/api/Makefile b/drivers/staging/westbridge/astoria/api/Makefile
new file mode 100644
index 000000000000..1c94bc7bb310
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/Makefile
@@ -0,0 +1,14 @@
+#
+# Makefile for the kernel westbridge core.
+#
+
+ifeq ($(CONFIG_WESTBRIDGE_DEBUG),n)
+ EXTRA_CFLAGS += -NDEBUG
+endif
+
+obj-$(CONFIG_WESTBRIDGE_DEVICE_DRIVER) += cyasapi.o
+cyasapi-y := src/cyasdma.o src/cyasintr.o src/cyaslep2pep.o \
+ src/cyaslowlevel.o src/cyasmisc.o src/cyasmtp.o \
+ src/cyasstorage.o src/cyasusb.o
+
+
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasdma.c b/drivers/staging/westbridge/astoria/api/src/cyasdma.c
new file mode 100644
index 000000000000..152591d93ec2
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasdma.c
@@ -0,0 +1,1107 @@
+/* Cypress West Bridge API source file (cyasdma.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+
+/*
+ * Add the DMA queue entry to the free list to be re-used later
+ */
+static void
+cy_as_dma_add_request_to_free_queue(cy_as_device *dev_p,
+ cy_as_dma_queue_entry *req_p)
+{
+ uint32_t imask ;
+ imask = cy_as_hal_disable_interrupts() ;
+
+ req_p->next_p = dev_p->dma_freelist_p ;
+ dev_p->dma_freelist_p = req_p ;
+
+ cy_as_hal_enable_interrupts(imask) ;
+}
+
+/*
+ * Get a DMA queue entry from the free list.
+ */
+static cy_as_dma_queue_entry *
+cy_as_dma_get_dma_queue_entry(cy_as_device *dev_p)
+{
+ cy_as_dma_queue_entry *req_p ;
+ uint32_t imask ;
+
+ cy_as_hal_assert(dev_p->dma_freelist_p != 0) ;
+
+ imask = cy_as_hal_disable_interrupts() ;
+ req_p = dev_p->dma_freelist_p ;
+ dev_p->dma_freelist_p = req_p->next_p ;
+ cy_as_hal_enable_interrupts(imask) ;
+
+ return req_p ;
+}
+
+/*
+ * Set the maximum size that the West Bridge hardware
+ * can handle in a single DMA operation. This size
+ * may change for the P <-> U endpoints as a function
+ * of the endpoint type and whether we are running
+ * at full speed or high speed.
+ */
+cy_as_return_status_t
+cy_as_dma_set_max_dma_size(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, uint32_t size)
+{
+ /* In MTP mode, EP2 is allowed to have all max sizes. */
+ if ((!dev_p->is_mtp_firmware) || (ep != 0x02)) {
+ if (size < 64 || size > 1024)
+ return CY_AS_ERROR_INVALID_SIZE ;
+ }
+
+ CY_AS_NUM_EP(dev_p, ep)->maxhwdata = (uint16_t)size ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+ * The callback for requests sent to West Bridge
+ * to relay endpoint data. Endpoint data for EP0
+ * and EP1 are sent using mailbox requests. This
+ * is the callback that is called when a response
+ * to a mailbox request to send data is received.
+ */
+static void
+cy_as_dma_request_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *resp_p,
+ cy_as_return_status_t ret)
+{
+ uint16_t v ;
+ uint16_t datacnt ;
+ cy_as_end_point_number_t ep ;
+
+ (void)context ;
+
+ cy_as_log_debug_message(5, "cy_as_dma_request_callback called") ;
+
+ /*
+ * extract the return code from the firmware
+ */
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp_p) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(resp_p, 0) ;
+ }
+
+ /*
+ * extract the endpoint number and the transferred byte count
+ * from the request.
+ */
+ v = cy_as_ll_request_response__get_word(req_p, 0) ;
+ ep = (cy_as_end_point_number_t)((v >> 13) & 0x01) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ /*
+ * if the firmware returns success,
+ * all of the data requested was
+ * transferred. there are no partial
+ * transfers.
+ */
+ datacnt = v & 0x3FF ;
+ } else {
+ /*
+ * if the firmware returned an error, no data was transferred.
+ */
+ datacnt = 0 ;
+ }
+
+ /*
+ * queue the request and response data structures for use with the
+ * next EP0 or EP1 request.
+ */
+ if (ep == 0) {
+ dev_p->usb_ep0_dma_req = req_p ;
+ dev_p->usb_ep0_dma_resp = resp_p ;
+ } else {
+ dev_p->usb_ep1_dma_req = req_p ;
+ dev_p->usb_ep1_dma_resp = resp_p ;
+ }
+
+ /*
+ * call the DMA complete function so we can
+ * signal that this portion of the transfer
+ * has completed. if the low level request
+ * was canceled, we do not need to signal
+ * the completed function as the only way a
+ * cancel can happen is via the DMA cancel
+ * function.
+ */
+ if (ret != CY_AS_ERROR_CANCELED)
+ cy_as_dma_completed_callback(dev_p->tag, ep, datacnt, ret) ;
+}
+
+/*
+ * Set the DRQ mask register for the given endpoint number. If state is
+ * CyTrue, the DRQ interrupt for the given endpoint is enabled, otherwise
+ * it is disabled.
+ */
+static void
+cy_as_dma_set_drq(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, cy_bool state)
+{
+ uint16_t mask ;
+ uint16_t v ;
+ uint32_t intval ;
+
+ /*
+ * there are not DRQ register bits for EP0 and EP1
+ */
+ if (ep == 0 || ep == 1)
+ return ;
+
+ /*
+ * disable interrupts while we do this to be sure the state of the
+ * DRQ mask register is always well defined.
+ */
+ intval = cy_as_hal_disable_interrupts() ;
+
+ /*
+ * set the DRQ bit to the given state for the ep given
+ */
+ mask = (1 << ep) ;
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_DRQ_MASK) ;
+
+ if (state)
+ v |= mask ;
+ else
+ v &= ~mask ;
+
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_P0_DRQ_MASK, v) ;
+ cy_as_hal_enable_interrupts(intval) ;
+}
+
+/*
+* Send the next DMA request for the endpoint given
+*/
+static void
+cy_as_dma_send_next_dma_request(cy_as_device *dev_p, cy_as_dma_end_point *ep_p)
+{
+ uint32_t datacnt ;
+ void *buf_p ;
+ cy_as_dma_queue_entry *dma_p ;
+
+ cy_as_log_debug_message(6, "cy_as_dma_send_next_dma_request called") ;
+
+ /* If the queue is empty, nothing to do */
+ dma_p = ep_p->queue_p ;
+ if (dma_p == 0) {
+ /*
+ * there are no pending DMA requests
+ * for this endpoint. disable the DRQ
+ * mask bits to insure no interrupts
+ * will be triggered by this endpoint
+ * until someone is interested in the data.
+ */
+ cy_as_dma_set_drq(dev_p, ep_p->ep, cy_false) ;
+ return ;
+ }
+
+ cy_as_dma_end_point_set_running(ep_p) ;
+
+ /*
+ * get the number of words that still
+ * need to be xferred in this request.
+ */
+ datacnt = dma_p->size - dma_p->offset ;
+ cy_as_hal_assert(datacnt >= 0) ;
+
+ /*
+ * the HAL layer should never limit the size
+ * of the transfer to something less than the
+ * maxhwdata otherwise, the data will be sent
+ * in packets that are not correct in size.
+ */
+ cy_as_hal_assert(ep_p->maxhaldata == CY_AS_DMA_MAX_SIZE_HW_SIZE
+ || ep_p->maxhaldata >= ep_p->maxhwdata) ;
+
+ /*
+ * update the number of words that need to be xferred yet
+ * based on the limits of the HAL layer.
+ */
+ if (ep_p->maxhaldata == CY_AS_DMA_MAX_SIZE_HW_SIZE) {
+ if (datacnt > ep_p->maxhwdata)
+ datacnt = ep_p->maxhwdata ;
+ } else {
+ if (datacnt > ep_p->maxhaldata)
+ datacnt = ep_p->maxhaldata ;
+ }
+
+ /*
+ * find a pointer to the data that needs to be transferred
+ */
+ buf_p = (((char *)dma_p->buf_p) + dma_p->offset);
+
+ /*
+ * mark a request in transit
+ */
+ cy_as_dma_end_point_set_in_transit(ep_p) ;
+
+ if (ep_p->ep == 0 || ep_p->ep == 1) {
+ /*
+ * if this is a WRITE request on EP0 and EP1
+ * we write the data via an EP_DATA request
+ * to west bridge via the mailbox registers.
+ * if this is a READ request, we do nothing
+ * and the data will arrive via an EP_DATA
+ * request from west bridge. in the request
+ * handler for the USB context we will pass
+ * the data back into the DMA module.
+ */
+ if (dma_p->readreq == cy_false) {
+ uint16_t v ;
+ uint16_t len ;
+ cy_as_ll_request_response *resp_p ;
+ cy_as_ll_request_response *req_p ;
+ cy_as_return_status_t ret ;
+
+ len = (uint16_t)(datacnt / 2) ;
+ if (datacnt % 2)
+ len++ ;
+
+ len++ ;
+
+ if (ep_p->ep == 0) {
+ req_p = dev_p->usb_ep0_dma_req ;
+ resp_p = dev_p->usb_ep0_dma_resp ;
+ dev_p->usb_ep0_dma_req = 0 ;
+ dev_p->usb_ep0_dma_resp = 0 ;
+ } else {
+ req_p = dev_p->usb_ep1_dma_req ;
+ resp_p = dev_p->usb_ep1_dma_resp ;
+ dev_p->usb_ep1_dma_req = 0 ;
+ dev_p->usb_ep1_dma_resp = 0 ;
+ }
+
+ cy_as_hal_assert(req_p != 0) ;
+ cy_as_hal_assert(resp_p != 0) ;
+ cy_as_hal_assert(len <= 64) ;
+
+ cy_as_ll_init_request(req_p, CY_RQT_USB_EP_DATA,
+ CY_RQT_USB_RQT_CONTEXT, len) ;
+
+ v = (uint16_t)(datacnt | (ep_p->ep << 13) | (1 << 14)) ;
+ if (dma_p->offset == 0)
+ v |= (1 << 12) ;/* Set the first packet bit */
+ if (dma_p->offset + datacnt == dma_p->size)
+ v |= (1 << 11) ;/* Set the last packet bit */
+
+ cy_as_ll_request_response__set_word(req_p, 0, v) ;
+ cy_as_ll_request_response__pack(req_p,
+ 1, datacnt, buf_p) ;
+
+ cy_as_ll_init_response(resp_p, 1) ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p, resp_p,
+ cy_false, cy_as_dma_request_callback) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ cy_as_log_debug_message(5,
+ "+++ send EP 0/1 data via mailbox registers") ;
+ else
+ cy_as_log_debug_message(5,
+ "+++ error sending EP 0/1 data via mailbox "
+ "registers - CY_AS_ERROR_TIMEOUT") ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_dma_completed_callback(dev_p->tag,
+ ep_p->ep, 0, ret) ;
+ }
+ } else {
+ /*
+ * this is a DMA request on an endpoint that is accessible
+ * via the P port. ask the HAL DMA capabilities to
+ * perform this. the amount of data sent is limited by the
+ * HAL max size as well as what we need to send. if the
+ * ep_p->maxhaldata is set to a value larger than the
+ * endpoint buffer size, then we will pass more than a
+ * single buffer worth of data to the HAL layer and expect
+ * the HAL layer to divide the data into packets. the last
+ * parameter here (ep_p->maxhwdata) gives the packet size for
+ * the data so the HAL layer knows what the packet size should
+ * be.
+ */
+ if (cy_as_dma_end_point_is_direction_in(ep_p))
+ cy_as_hal_dma_setup_write(dev_p->tag,
+ ep_p->ep, buf_p, datacnt, ep_p->maxhwdata) ;
+ else
+ cy_as_hal_dma_setup_read(dev_p->tag,
+ ep_p->ep, buf_p, datacnt, ep_p->maxhwdata) ;
+
+ /*
+ * the DRQ interrupt for this endpoint should be enabled
+ * so that the data transfer progresses at interrupt time.
+ */
+ cy_as_dma_set_drq(dev_p, ep_p->ep, cy_true) ;
+ }
+}
+
+/*
+ * This function is called when the HAL layer has
+ * completed the last requested DMA operation.
+ * This function sends/receives the next batch of
+ * data associated with the current DMA request,
+ * or it is is complete, moves to the next DMA request.
+ */
+void
+cy_as_dma_completed_callback(cy_as_hal_device_tag tag,
+ cy_as_end_point_number_t ep, uint32_t cnt, cy_as_return_status_t status)
+{
+ uint32_t mask ;
+ cy_as_dma_queue_entry *req_p ;
+ cy_as_dma_end_point *ep_p ;
+ cy_as_device *dev_p = cy_as_device_find_from_tag(tag) ;
+
+ /* Make sure the HAL layer gave us good parameters */
+ cy_as_hal_assert(dev_p != 0) ;
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+ cy_as_hal_assert(ep < 16) ;
+
+
+ /* Get the endpoint ptr */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+ cy_as_hal_assert(ep_p->queue_p != 0) ;
+
+ /* Get a pointer to the current entry in the queue */
+ mask = cy_as_hal_disable_interrupts() ;
+ req_p = ep_p->queue_p ;
+
+ /* Update the offset to reflect the data actually received or sent */
+ req_p->offset += cnt ;
+
+ /*
+ * if we are still sending/receiving the current packet,
+ * send/receive the next chunk basically we keep going
+ * if we have not sent/received enough data, and we are
+ * not doing a packet operation, and the last packet
+ * sent or received was a full sized packet. in other
+ * words, when we are NOT doing a packet operation, a
+ * less than full size packet (a short packet) will
+ * terminate the operation.
+ *
+ * note: if this is EP1 request and the request has
+ * timed out, it means the buffer is not free.
+ * we have to resend the data.
+ *
+ * note: for the MTP data transfers, the DMA transfer
+ * for the next packet can only be started asynchronously,
+ * after a firmware event notifies that the device is ready.
+ */
+ if (((req_p->offset != req_p->size) && (req_p->packet == cy_false) &&
+ ((cnt == ep_p->maxhaldata) || ((cnt == ep_p->maxhwdata) &&
+ ((ep != CY_AS_MTP_READ_ENDPOINT) ||
+ (cnt == dev_p->usb_max_tx_size)))))
+ || ((ep == 1) && (status == CY_AS_ERROR_TIMEOUT))) {
+ cy_as_hal_enable_interrupts(mask) ;
+
+ /*
+ * and send the request again to send the next block of
+ * data. special handling for MTP transfers on E_ps 2
+ * and 6. the send_next_request will be processed based
+ * on the event sent by the firmware.
+ */
+ if ((ep == CY_AS_MTP_WRITE_ENDPOINT) || (
+ (ep == CY_AS_MTP_READ_ENDPOINT) &&
+ (!cy_as_dma_end_point_is_direction_in(ep_p))))
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+ else
+ cy_as_dma_send_next_dma_request(dev_p, ep_p) ;
+ } else {
+ /*
+ * we get here if ...
+ * we have sent or received all of the data
+ * or
+ * we are doing a packet operation
+ * or
+ * we receive a short packet
+ */
+
+ /*
+ * remove this entry from the DMA queue for this endpoint.
+ */
+ cy_as_dma_end_point_clear_in_transit(ep_p) ;
+ ep_p->queue_p = req_p->next_p ;
+ if (ep_p->last_p == req_p) {
+ /*
+ * we have removed the last packet from the DMA queue,
+ * disable the interrupt associated with this interrupt.
+ */
+ ep_p->last_p = 0 ;
+ cy_as_hal_enable_interrupts(mask) ;
+ cy_as_dma_set_drq(dev_p, ep, cy_false) ;
+ } else
+ cy_as_hal_enable_interrupts(mask) ;
+
+ if (req_p->cb) {
+ /*
+ * if the request has a callback associated with it,
+ * call the callback to tell the interested party that
+ * this DMA request has completed.
+ *
+ * note, we set the in_callback bit to insure that we
+ * cannot recursively call an API function that is
+ * synchronous only from a callback.
+ */
+ cy_as_device_set_in_callback(dev_p) ;
+ (*req_p->cb)(dev_p, ep, req_p->buf_p,
+ req_p->offset, status) ;
+ cy_as_device_clear_in_callback(dev_p) ;
+ }
+
+ /*
+ * we are done with this request, put it on the freelist to be
+ * reused at a later time.
+ */
+ cy_as_dma_add_request_to_free_queue(dev_p, req_p) ;
+
+ if (ep_p->queue_p == 0) {
+ /*
+ * if the endpoint is out of DMA entries, set the
+ * endpoint as stopped.
+ */
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+
+ /*
+ * the DMA queue is empty, wake any task waiting on
+ * the QUEUE to drain.
+ */
+ if (cy_as_dma_end_point_is_sleeping(ep_p)) {
+ cy_as_dma_end_point_set_wake_state(ep_p) ;
+ cy_as_hal_wake(&ep_p->channel) ;
+ }
+ } else {
+ /*
+ * if the queued operation is a MTP transfer,
+ * wait until firmware event before sending
+ * down the next DMA request.
+ */
+ if ((ep == CY_AS_MTP_WRITE_ENDPOINT) ||
+ ((ep == CY_AS_MTP_READ_ENDPOINT) &&
+ (!cy_as_dma_end_point_is_direction_in(ep_p))) ||
+ ((ep == dev_p->storage_read_endpoint) &&
+ (!cy_as_device_is_p2s_dma_start_recvd(dev_p)))
+ || ((ep == dev_p->storage_write_endpoint) &&
+ (!cy_as_device_is_p2s_dma_start_recvd(dev_p))))
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+ else
+ cy_as_dma_send_next_dma_request(dev_p, ep_p) ;
+ }
+ }
+}
+
+/*
+* This function is used to kick start DMA on a given
+* channel. If DMA is already running on the given
+* endpoint, nothing happens. If DMA is not running,
+* the first entry is pulled from the DMA queue and
+* sent/recevied to/from the West Bridge device.
+*/
+cy_as_return_status_t
+cy_as_dma_kick_start(cy_as_device *dev_p, cy_as_end_point_number_t ep)
+{
+ cy_as_dma_end_point *ep_p ;
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ /* We are already running */
+ if (cy_as_dma_end_point_is_running(ep_p))
+ return CY_AS_ERROR_SUCCESS ;
+
+ cy_as_dma_send_next_dma_request(dev_p, ep_p);
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+ * This function stops the given endpoint. Stopping and endpoint cancels
+ * any pending DMA operations and frees all resources associated with the
+ * given endpoint.
+ */
+static cy_as_return_status_t
+cy_as_dma_stop_end_point(cy_as_device *dev_p, cy_as_end_point_number_t ep)
+{
+ cy_as_return_status_t ret ;
+ cy_as_dma_end_point *ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ /*
+ * cancel any pending DMA requests associated with this endpoint. this
+ * cancels any DMA requests at the HAL layer as well as dequeues any
+ * request that is currently pending.
+ */
+ ret = cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * destroy the sleep channel
+ */
+ if (!cy_as_hal_destroy_sleep_channel(&ep_p->channel)
+ && ret == CY_AS_ERROR_SUCCESS)
+ ret = CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED ;
+
+ /*
+ * free the memory associated with this endpoint
+ */
+ cy_as_hal_free(ep_p) ;
+
+ /*
+ * set the data structure ptr to something sane since the
+ * previous pointer is now free.
+ */
+ dev_p->endp[ep] = 0 ;
+
+ return ret ;
+}
+
+/*
+ * This method stops the USB stack. This is an internal function that does
+ * all of the work of destroying the USB stack without the protections that
+ * we provide to the API (i.e. stopping at stack that is not running).
+ */
+static cy_as_return_status_t
+cy_as_dma_stop_internal(cy_as_device *dev_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_return_status_t lret ;
+ cy_as_end_point_number_t i ;
+
+ /*
+ * stop all of the endpoints. this cancels all DMA requests, and
+ * frees all resources associated with each endpoint.
+ */
+ for (i = 0 ; i < sizeof(dev_p->endp)/(sizeof(dev_p->endp[0])) ; i++) {
+ lret = cy_as_dma_stop_end_point(dev_p, i) ;
+ if (lret != CY_AS_ERROR_SUCCESS && ret == CY_AS_ERROR_SUCCESS)
+ ret = lret ;
+ }
+
+ /*
+ * now, free the list of DMA requests structures that we use to manage
+ * DMA requests.
+ */
+ while (dev_p->dma_freelist_p) {
+ cy_as_dma_queue_entry *req_p ;
+ uint32_t imask = cy_as_hal_disable_interrupts() ;
+
+ req_p = dev_p->dma_freelist_p ;
+ dev_p->dma_freelist_p = req_p->next_p ;
+
+ cy_as_hal_enable_interrupts(imask) ;
+
+ cy_as_hal_free(req_p) ;
+ }
+
+ cy_as_ll_destroy_request(dev_p, dev_p->usb_ep0_dma_req) ;
+ cy_as_ll_destroy_request(dev_p, dev_p->usb_ep1_dma_req) ;
+ cy_as_ll_destroy_response(dev_p, dev_p->usb_ep0_dma_resp) ;
+ cy_as_ll_destroy_response(dev_p, dev_p->usb_ep1_dma_resp) ;
+
+ return ret ;
+}
+
+
+/*
+ * CyAsDmaStop()
+ *
+ * This function shuts down the DMA module. All resources
+ * associated with the DMA module will be freed. This
+ * routine is the API stop function. It insures that we
+ * are stopping a stack that is actually running and then
+ * calls the internal function to do the work.
+ */
+cy_as_return_status_t
+cy_as_dma_stop(cy_as_device *dev_p)
+{
+ cy_as_return_status_t ret ;
+
+ ret = cy_as_dma_stop_internal(dev_p) ;
+ cy_as_device_set_dma_stopped(dev_p) ;
+
+ return ret ;
+}
+
+/*
+ * CyAsDmaStart()
+ *
+ * This function intializes the DMA module to insure it is up and running.
+ */
+cy_as_return_status_t
+cy_as_dma_start(cy_as_device *dev_p)
+{
+ cy_as_end_point_number_t i ;
+ uint16_t cnt ;
+
+ if (cy_as_device_is_dma_running(dev_p))
+ return CY_AS_ERROR_ALREADY_RUNNING ;
+
+ /*
+ * pre-allocate DMA queue structures to be used in the interrupt context
+ */
+ for (cnt = 0 ; cnt < 32 ; cnt++) {
+ cy_as_dma_queue_entry *entry_p = (cy_as_dma_queue_entry *)
+ cy_as_hal_alloc(sizeof(cy_as_dma_queue_entry)) ;
+ if (entry_p == 0) {
+ cy_as_dma_stop_internal(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ cy_as_dma_add_request_to_free_queue(dev_p, entry_p) ;
+ }
+
+ /*
+ * pre-allocate the DMA requests for sending EP0
+ * and EP1 data to west bridge
+ */
+ dev_p->usb_ep0_dma_req = cy_as_ll_create_request(dev_p,
+ CY_RQT_USB_EP_DATA, CY_RQT_USB_RQT_CONTEXT, 64) ;
+ dev_p->usb_ep1_dma_req = cy_as_ll_create_request(dev_p,
+ CY_RQT_USB_EP_DATA, CY_RQT_USB_RQT_CONTEXT, 64) ;
+
+ if (dev_p->usb_ep0_dma_req == 0 || dev_p->usb_ep1_dma_req == 0) {
+ cy_as_dma_stop_internal(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ dev_p->usb_ep0_dma_req_save = dev_p->usb_ep0_dma_req ;
+
+ dev_p->usb_ep0_dma_resp = cy_as_ll_create_response(dev_p, 1) ;
+ dev_p->usb_ep1_dma_resp = cy_as_ll_create_response(dev_p, 1) ;
+ if (dev_p->usb_ep0_dma_resp == 0 || dev_p->usb_ep1_dma_resp == 0) {
+ cy_as_dma_stop_internal(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ dev_p->usb_ep0_dma_resp_save = dev_p->usb_ep0_dma_resp ;
+
+ /*
+ * set the dev_p->endp to all zeros to insure cleanup is possible if
+ * an error occurs during initialization.
+ */
+ cy_as_hal_mem_set(dev_p->endp, 0, sizeof(dev_p->endp)) ;
+
+ /*
+ * now, iterate through each of the endpoints and initialize each
+ * one.
+ */
+ for (i = 0 ; i < sizeof(dev_p->endp)/sizeof(dev_p->endp[0]) ; i++) {
+ dev_p->endp[i] = (cy_as_dma_end_point *)
+ cy_as_hal_alloc(sizeof(cy_as_dma_end_point)) ;
+ if (dev_p->endp[i] == 0) {
+ cy_as_dma_stop_internal(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ cy_as_hal_mem_set(dev_p->endp[i], 0,
+ sizeof(cy_as_dma_end_point)) ;
+
+ dev_p->endp[i]->ep = i ;
+ dev_p->endp[i]->queue_p = 0 ;
+ dev_p->endp[i]->last_p = 0 ;
+
+ cy_as_dma_set_drq(dev_p, i, cy_false) ;
+
+ if (!cy_as_hal_create_sleep_channel(&dev_p->endp[i]->channel))
+ return CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED ;
+ }
+
+ /*
+ * tell the HAL layer who to call when the
+ * HAL layer completes a DMA request
+ */
+ cy_as_hal_dma_register_callback(dev_p->tag,
+ cy_as_dma_completed_callback) ;
+
+ /*
+ * mark DMA as up and running on this device
+ */
+ cy_as_device_set_dma_running(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* Wait for all entries in the DMA queue associated
+* the given endpoint to be drained. This function
+* will not return until all the DMA data has been
+* transferred.
+*/
+cy_as_return_status_t
+cy_as_dma_drain_queue(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, cy_bool kickstart)
+{
+ cy_as_dma_end_point *ep_p ;
+ int loopcount = 1000 ;
+ uint32_t mask ;
+
+ /*
+ * make sure the endpoint is valid
+ */
+ if (ep >= sizeof(dev_p->endp)/sizeof(dev_p->endp[0]))
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ /*
+ * if the endpoint is empty of traffic, we return
+ * with success immediately
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+ if (ep_p->queue_p == 0) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_SUCCESS ;
+ } else {
+ /*
+ * add 10 seconds to the time out value for each 64 KB segment
+ * of data to be transferred.
+ */
+ if (ep_p->queue_p->size > 0x10000)
+ loopcount += ((ep_p->queue_p->size / 0x10000) * 1000) ;
+ }
+ cy_as_hal_enable_interrupts(mask) ;
+
+ /* If we are already sleeping on this endpoint, it is an error */
+ if (cy_as_dma_end_point_is_sleeping(ep_p))
+ return CY_AS_ERROR_NESTED_SLEEP ;
+
+ /*
+ * we disable the endpoint while the queue drains to
+ * prevent any additional requests from being queued while we are waiting
+ */
+ cy_as_dma_enable_end_point(dev_p, ep,
+ cy_false, cy_as_direction_dont_change) ;
+
+ if (kickstart) {
+ /*
+ * now, kick start the DMA if necessary
+ */
+ cy_as_dma_kick_start(dev_p, ep) ;
+ }
+
+ /*
+ * check one last time before we begin sleeping to see if the
+ * queue is drained.
+ */
+ if (ep_p->queue_p == 0) {
+ cy_as_dma_enable_end_point(dev_p, ep, cy_true,
+ cy_as_direction_dont_change) ;
+ return CY_AS_ERROR_SUCCESS ;
+ }
+
+ while (loopcount-- > 0) {
+ /*
+ * sleep for 10 ms maximum (per loop) while
+ * waiting for the transfer to complete.
+ */
+ cy_as_dma_end_point_set_sleep_state(ep_p) ;
+ cy_as_hal_sleep_on(&ep_p->channel, 10) ;
+
+ /* If we timed out, the sleep bit will still be set */
+ cy_as_dma_end_point_set_wake_state(ep_p) ;
+
+ /* Check the queue to see if is drained */
+ if (ep_p->queue_p == 0) {
+ /*
+ * clear the endpoint running and in transit flags
+ * for the endpoint, now that its DMA queue is empty.
+ */
+ cy_as_dma_end_point_clear_in_transit(ep_p) ;
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+
+ cy_as_dma_enable_end_point(dev_p, ep,
+ cy_true, cy_as_direction_dont_change) ;
+ return CY_AS_ERROR_SUCCESS ;
+ }
+ }
+
+ /*
+ * the DMA operation that has timed out can be cancelled, so that later
+ * operations on this queue can proceed.
+ */
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_TIMEOUT) ;
+ cy_as_dma_enable_end_point(dev_p, ep,
+ cy_true, cy_as_direction_dont_change) ;
+ return CY_AS_ERROR_TIMEOUT ;
+}
+
+/*
+* This function queues a write request in the DMA queue
+* for a given endpoint. The direction of the
+* entry will be inferred from the endpoint direction.
+*/
+cy_as_return_status_t
+cy_as_dma_queue_request(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *mem_p,
+ uint32_t size, cy_bool pkt, cy_bool readreq, cy_as_dma_callback cb)
+{
+ uint32_t mask ;
+ cy_as_dma_queue_entry *entry_p ;
+ cy_as_dma_end_point *ep_p ;
+
+ /*
+ * make sure the endpoint is valid
+ */
+ if (ep >= sizeof(dev_p->endp)/sizeof(dev_p->endp[0]))
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ if (!cy_as_dma_end_point_is_enabled(ep_p))
+ return CY_AS_ERROR_ENDPOINT_DISABLED ;
+
+ entry_p = cy_as_dma_get_dma_queue_entry(dev_p) ;
+
+ entry_p->buf_p = mem_p ;
+ entry_p->cb = cb ;
+ entry_p->size = size ;
+ entry_p->offset = 0 ;
+ entry_p->packet = pkt ;
+ entry_p->readreq = readreq ;
+
+ mask = cy_as_hal_disable_interrupts() ;
+ entry_p->next_p = 0 ;
+ if (ep_p->last_p)
+ ep_p->last_p->next_p = entry_p ;
+ ep_p->last_p = entry_p ;
+ if (ep_p->queue_p == 0)
+ ep_p->queue_p = entry_p ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* This function enables or disables and endpoint for DMA
+* queueing. If an endpoint is disabled, any queue requests
+* continue to be processed, but no new requests can be queued.
+*/
+cy_as_return_status_t
+cy_as_dma_enable_end_point(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, cy_bool enable, cy_as_dma_direction dir)
+{
+ cy_as_dma_end_point *ep_p ;
+
+ /*
+ * make sure the endpoint is valid
+ */
+ if (ep >= sizeof(dev_p->endp)/sizeof(dev_p->endp[0]))
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ if (dir == cy_as_direction_out)
+ cy_as_dma_end_point_set_direction_out(ep_p) ;
+ else if (dir == cy_as_direction_in)
+ cy_as_dma_end_point_set_direction_in(ep_p) ;
+
+ /*
+ * get the maximum size of data buffer the HAL
+ * layer can accept. this is used when the DMA
+ * module is sending DMA requests to the HAL.
+ * the DMA module will never send down a request
+ * that is greater than this value.
+ *
+ * for EP0 and EP1, we can send no more than 64
+ * bytes of data at one time as this is the maximum
+ * size of a packet that can be sent via these
+ * endpoints.
+ */
+ if (ep == 0 || ep == 1)
+ ep_p->maxhaldata = 64 ;
+ else
+ ep_p->maxhaldata = cy_as_hal_dma_max_request_size(
+ dev_p->tag, ep) ;
+
+ if (enable)
+ cy_as_dma_end_point_enable(ep_p) ;
+ else
+ cy_as_dma_end_point_disable(ep_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+ * This function cancels any DMA operations pending with the HAL layer as well
+ * as any DMA operation queued on the endpoint.
+ */
+cy_as_return_status_t
+cy_as_dma_cancel(
+ cy_as_device *dev_p,
+ cy_as_end_point_number_t ep,
+ cy_as_return_status_t err)
+{
+ uint32_t mask ;
+ cy_as_dma_end_point *ep_p ;
+ cy_as_dma_queue_entry *entry_p ;
+ cy_bool epstate ;
+
+ /*
+ * make sure the endpoint is valid
+ */
+ if (ep >= sizeof(dev_p->endp)/sizeof(dev_p->endp[0]))
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ if (ep_p) {
+ /* Remember the state of the endpoint */
+ epstate = cy_as_dma_end_point_is_enabled(ep_p) ;
+
+ /*
+ * disable the endpoint so no more DMA packets can be
+ * queued.
+ */
+ cy_as_dma_enable_end_point(dev_p, ep,
+ cy_false, cy_as_direction_dont_change) ;
+
+ /*
+ * don't allow any interrupts from this endpoint
+ * while we get the most current request off of
+ * the queue.
+ */
+ cy_as_dma_set_drq(dev_p, ep, cy_false) ;
+
+ /*
+ * cancel any pending request queued in the HAL layer
+ */
+ if (cy_as_dma_end_point_in_transit(ep_p))
+ cy_as_hal_dma_cancel_request(dev_p->tag, ep_p->ep) ;
+
+ /*
+ * shutdown the DMA for this endpoint so no
+ * more data is transferred
+ */
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+
+ /*
+ * mark the endpoint as not in transit, because we are
+ * going to consume any queued requests
+ */
+ cy_as_dma_end_point_clear_in_transit(ep_p) ;
+
+ /*
+ * now, remove each entry in the queue and call the
+ * associated callback stating that the request was
+ * canceled.
+ */
+ ep_p->last_p = 0 ;
+ while (ep_p->queue_p != 0) {
+ /* Disable interrupts to manipulate the queue */
+ mask = cy_as_hal_disable_interrupts() ;
+
+ /* Remove an entry from the queue */
+ entry_p = ep_p->queue_p ;
+ ep_p->queue_p = entry_p->next_p ;
+
+ /* Ok, the queue has been updated, we can
+ * turn interrupts back on */
+ cy_as_hal_enable_interrupts(mask) ;
+
+ /* Call the callback indicating we have
+ * canceled the DMA */
+ if (entry_p->cb)
+ entry_p->cb(dev_p, ep,
+ entry_p->buf_p, entry_p->size, err) ;
+
+ cy_as_dma_add_request_to_free_queue(dev_p, entry_p) ;
+ }
+
+ if (ep == 0 || ep == 1) {
+ /*
+ * if this endpoint is zero or one, we need to
+ * clear the queue of any pending CY_RQT_USB_EP_DATA
+ * requests as these are pending requests to send
+ * data to the west bridge device.
+ */
+ cy_as_ll_remove_ep_data_requests(dev_p, ep) ;
+ }
+
+ if (epstate) {
+ /*
+ * the endpoint started out enabled, so we
+ * re-enable the endpoint here.
+ */
+ cy_as_dma_enable_end_point(dev_p, ep,
+ cy_true, cy_as_direction_dont_change) ;
+ }
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_dma_received_data(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, uint32_t dsize, void *data)
+{
+ cy_as_dma_queue_entry *dma_p ;
+ uint8_t *src_p, *dest_p ;
+ cy_as_dma_end_point *ep_p ;
+ uint32_t xfersize ;
+
+ /*
+ * make sure the endpoint is valid
+ */
+ if (ep != 0 && ep != 1)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+ dma_p = ep_p->queue_p ;
+ if (dma_p == 0)
+ return CY_AS_ERROR_SUCCESS ;
+
+ /*
+ * if the data received exceeds the size of the DMA buffer,
+ * clip the data to the size of the buffer. this can lead
+ * to loosing some data, but is not different than doing
+ * non-packet reads on the other endpoints.
+ */
+ if (dsize > dma_p->size - dma_p->offset)
+ dsize = dma_p->size - dma_p->offset ;
+
+ /*
+ * copy the data from the request packet to the DMA buffer
+ * for the endpoint
+ */
+ src_p = (uint8_t *)data ;
+ dest_p = ((uint8_t *)(dma_p->buf_p)) + dma_p->offset ;
+ xfersize = dsize ;
+ while (xfersize-- > 0)
+ *dest_p++ = *src_p++ ;
+
+ /* Signal the DMA module that we have
+ * received data for this EP request */
+ cy_as_dma_completed_callback(dev_p->tag,
+ ep, dsize, CY_AS_ERROR_SUCCESS) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasintr.c b/drivers/staging/westbridge/astoria/api/src/cyasintr.c
new file mode 100644
index 000000000000..aea6c3ebf067
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasintr.c
@@ -0,0 +1,143 @@
+/* Cypress West Bridge API source file (cyasintr.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasdevice.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+
+extern void cy_as_mail_box_interrupt_handler(cy_as_device *) ;
+
+void
+cy_as_mcu_interrupt_handler(cy_as_device *dev_p)
+{
+ /* Read and clear the interrupt. */
+ uint16_t v ;
+
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_MCU_STAT) ;
+ v = v ;
+}
+
+void
+cy_as_power_management_interrupt_handler(cy_as_device *dev_p)
+{
+ uint16_t v ;
+
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_PWR_MAGT_STAT) ;
+ v = v ;
+}
+
+void
+cy_as_pll_lock_loss_interrupt_handler(cy_as_device *dev_p)
+{
+ uint16_t v ;
+
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_PLL_LOCK_LOSS_STAT) ;
+ v = v ;
+}
+
+uint32_t cy_as_intr_start(cy_as_device *dev_p, cy_bool dmaintr)
+{
+ uint16_t v ;
+
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ if (cy_as_device_is_intr_running(dev_p) != 0)
+ return CY_AS_ERROR_ALREADY_RUNNING ;
+
+ v = CY_AS_MEM_P0_INT_MASK_REG_MMCUINT |
+ CY_AS_MEM_P0_INT_MASK_REG_MMBINT |
+ CY_AS_MEM_P0_INT_MASK_REG_MPMINT ;
+
+ if (dmaintr)
+ v |= CY_AS_MEM_P0_INT_MASK_REG_MDRQINT ;
+
+ /* Enable the interrupts of interest */
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_P0_INT_MASK_REG, v) ;
+
+ /* Mark the interrupt module as initialized */
+ cy_as_device_set_intr_running(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+uint32_t cy_as_intr_stop(cy_as_device *dev_p)
+{
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ if (cy_as_device_is_intr_running(dev_p) == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_P0_INT_MASK_REG, 0) ;
+ cy_as_device_set_intr_stopped(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+void cy_as_intr_service_interrupt(cy_as_hal_device_tag tag)
+{
+ uint16_t v ;
+ cy_as_device *dev_p ;
+
+ dev_p = cy_as_device_find_from_tag(tag) ;
+
+ /*
+ * only power management interrupts can occur before the
+ * antioch API setup is complete. if this is a PM interrupt
+ * handle it here; otherwise output a warning message.
+ */
+ if (dev_p == 0) {
+ v = cy_as_hal_read_register(tag, CY_AS_MEM_P0_INTR_REG) ;
+ if (v == CY_AS_MEM_P0_INTR_REG_PMINT) {
+ /* Read the PWR_MAGT_STAT register
+ * to clear this interrupt. */
+ v = cy_as_hal_read_register(tag,
+ CY_AS_MEM_PWR_MAGT_STAT) ;
+ } else
+ cy_as_hal_print_message("stray antioch "
+ "interrupt detected"
+ ", tag not associated "
+ "with any created device.") ;
+ return ;
+ }
+
+ /* Make sure we got a valid object from CyAsDeviceFindFromTag */
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_INTR_REG) ;
+
+ if (v & CY_AS_MEM_P0_INTR_REG_MCUINT)
+ cy_as_mcu_interrupt_handler(dev_p) ;
+
+ if (v & CY_AS_MEM_P0_INTR_REG_PMINT)
+ cy_as_power_management_interrupt_handler(dev_p) ;
+
+ if (v & CY_AS_MEM_P0_INTR_REG_PLLLOCKINT)
+ cy_as_pll_lock_loss_interrupt_handler(dev_p) ;
+
+ /* If the interrupt module is not running, no mailbox
+ * interrupts are expected from the west bridge. */
+ if (cy_as_device_is_intr_running(dev_p) == 0)
+ return ;
+
+ if (v & CY_AS_MEM_P0_INTR_REG_MBINT)
+ cy_as_mail_box_interrupt_handler(dev_p) ;
+}
diff --git a/drivers/staging/westbridge/astoria/api/src/cyaslep2pep.c b/drivers/staging/westbridge/astoria/api/src/cyaslep2pep.c
new file mode 100644
index 000000000000..b28e33a1ce9d
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyaslep2pep.c
@@ -0,0 +1,358 @@
+/* Cypress West Bridge API source file (cyaslep2pep.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasusb.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+
+typedef enum cy_as_physical_endpoint_state {
+ cy_as_e_p_free,
+ cy_as_e_p_in,
+ cy_as_e_p_out,
+ cy_as_e_p_iso_in,
+ cy_as_e_p_iso_out
+} cy_as_physical_endpoint_state;
+
+
+/*
+* This map is used to map an index between 1 and 10
+* to a logical endpoint number. This is used to map
+* LEP register indexes into actual EP numbers.
+*/
+static cy_as_end_point_number_t end_point_map[] = {
+ 3, 5, 7, 9, 10, 11, 12, 13, 14, 15 } ;
+
+#define CY_AS_EPCFG_1024 (1 << 3)
+#define CY_AS_EPCFG_DBL (0x02)
+#define CY_AS_EPCFG_TRIPLE (0x03)
+#define CY_AS_EPCFG_QUAD (0x00)
+
+/*
+ * NB: This table contains the register values for PEP1
+ * and PEP3. PEP2 and PEP4 only have a bit to change the
+ * direction of the PEP and therefre are not represented
+ * in this table.
+ */
+static uint8_t pep_register_values[12][4] = {
+ /* Bit 1:0 buffering, 0 = quad, 2 = double, 3 = triple */
+ /* Bit 3 size, 0 = 512, 1 = 1024 */
+ {
+ CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_DBL,
+ },/* Config 1 - PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (2 * 512), PEP4 (2 * 512) */
+ {
+ CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_QUAD,
+ }, /* Config 2 - PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (4 * 512), PEP4 (N/A) */
+ {
+ CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_DBL | CY_AS_EPCFG_1024,
+ },/* Config 3 - PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (2 * 1024), PEP4(N/A) */
+ {
+ CY_AS_EPCFG_QUAD,
+ CY_AS_EPCFG_DBL,
+ },/* Config 4 - PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (2 * 512), PEP4 (2 * 512) */
+ {
+ CY_AS_EPCFG_QUAD,
+ CY_AS_EPCFG_QUAD,
+ },/* Config 5 - PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (4 * 512), PEP4 (N/A) */
+ {
+ CY_AS_EPCFG_QUAD,
+ CY_AS_EPCFG_1024 | CY_AS_EPCFG_DBL,
+ },/* Config 6 - PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (2 * 1024), PEP4 (N/A) */
+ {
+ CY_AS_EPCFG_1024 | CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_DBL,
+ },/* Config 7 - PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (2 * 512), PEP4 (2 * 512) */
+ {
+ CY_AS_EPCFG_1024 | CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_QUAD,
+ },/* Config 8 - PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (4 * 512), PEP4 (N/A) */
+ {
+ CY_AS_EPCFG_1024 | CY_AS_EPCFG_DBL,
+ CY_AS_EPCFG_1024 | CY_AS_EPCFG_DBL,
+ },/* Config 9 - PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (2 * 1024), PEP4 (N/A)*/
+ {
+ CY_AS_EPCFG_TRIPLE,
+ CY_AS_EPCFG_TRIPLE,
+ },/* Config 10 - PEP1 (3 * 512), PEP2 (N/A),
+ * PEP3 (3 * 512), PEP4 (2 * 512)*/
+ {
+ CY_AS_EPCFG_TRIPLE | CY_AS_EPCFG_1024,
+ CY_AS_EPCFG_DBL,
+ },/* Config 11 - PEP1 (3 * 1024), PEP2 (N/A),
+ * PEP3 (N/A), PEP4 (2 * 512) */
+ {
+ CY_AS_EPCFG_QUAD | CY_AS_EPCFG_1024,
+ CY_AS_EPCFG_DBL,
+ },/* Config 12 - PEP1 (4 * 1024), PEP2 (N/A),
+ * PEP3 (N/A), PEP4 (N/A) */
+} ;
+
+static cy_as_return_status_t
+find_endpoint_directions(cy_as_device *dev_p,
+ cy_as_physical_endpoint_state epstate[4])
+{
+ int i ;
+ cy_as_physical_endpoint_state desired ;
+
+ /*
+ * note, there is no error checking here becuase
+ * ISO error checking happens when the API is called.
+ */
+ for (i = 0 ; i < 10 ; i++) {
+ int epno = end_point_map[i] ;
+ if (dev_p->usb_config[epno].enabled) {
+ int pep = dev_p->usb_config[epno].physical ;
+ if (dev_p->usb_config[epno].type == cy_as_usb_iso) {
+ /*
+ * marking this as an ISO endpoint, removes the
+ * physical EP from consideration when
+ * mapping the remaining E_ps.
+ */
+ if (dev_p->usb_config[epno].dir == cy_as_usb_in)
+ desired = cy_as_e_p_iso_in ;
+ else
+ desired = cy_as_e_p_iso_out ;
+ } else {
+ if (dev_p->usb_config[epno].dir == cy_as_usb_in)
+ desired = cy_as_e_p_in ;
+ else
+ desired = cy_as_e_p_out ;
+ }
+
+ /*
+ * NB: Note the API calls insure that an ISO endpoint
+ * has a physical and logical EP number that are the
+ * same, therefore this condition is not enforced here.
+ */
+ if (epstate[pep - 1] !=
+ cy_as_e_p_free && epstate[pep - 1] != desired)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ epstate[pep - 1] = desired ;
+ }
+ }
+
+ /*
+ * create the EP1 config values directly.
+ * both EP1OUT and EP1IN are invalid by default.
+ */
+ dev_p->usb_ep1cfg[0] = 0 ;
+ dev_p->usb_ep1cfg[1] = 0 ;
+ if (dev_p->usb_config[1].enabled) {
+ if ((dev_p->usb_config[1].dir == cy_as_usb_out) ||
+ (dev_p->usb_config[1].dir == cy_as_usb_in_out)) {
+ /* Set the valid bit and type field. */
+ dev_p->usb_ep1cfg[0] = (1 << 7) ;
+ if (dev_p->usb_config[1].type == cy_as_usb_bulk)
+ dev_p->usb_ep1cfg[0] |= (2 << 4) ;
+ else
+ dev_p->usb_ep1cfg[0] |= (3 << 4) ;
+ }
+
+ if ((dev_p->usb_config[1].dir == cy_as_usb_in) ||
+ (dev_p->usb_config[1].dir == cy_as_usb_in_out)) {
+ /* Set the valid bit and type field. */
+ dev_p->usb_ep1cfg[1] = (1 << 7) ;
+ if (dev_p->usb_config[1].type == cy_as_usb_bulk)
+ dev_p->usb_ep1cfg[1] |= (2 << 4) ;
+ else
+ dev_p->usb_ep1cfg[1] |= (3 << 4) ;
+ }
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+create_register_settings(cy_as_device *dev_p,
+ cy_as_physical_endpoint_state epstate[4])
+{
+ int i ;
+ uint8_t v ;
+
+ for (i = 0 ; i < 4 ; i++) {
+ if (i == 0) {
+ /* Start with the values that specify size */
+ dev_p->usb_pepcfg[i] =
+ pep_register_values
+ [dev_p->usb_phy_config - 1][0] ;
+ } else if (i == 2) {
+ /* Start with the values that specify size */
+ dev_p->usb_pepcfg[i] =
+ pep_register_values
+ [dev_p->usb_phy_config - 1][1] ;
+ } else
+ dev_p->usb_pepcfg[i] = 0 ;
+
+ /* Adjust direction if it is in */
+ if (epstate[i] == cy_as_e_p_iso_in ||
+ epstate[i] == cy_as_e_p_in)
+ dev_p->usb_pepcfg[i] |= (1 << 6) ;
+ }
+
+ /* Configure the logical EP registers */
+ for (i = 0 ; i < 10 ; i++) {
+ int val ;
+ int epnum = end_point_map[i] ;
+
+ v = 0x10 ; /* PEP 1, Bulk Endpoint, EP not valid */
+ if (dev_p->usb_config[epnum].enabled) {
+ v |= (1 << 7) ; /* Enabled */
+
+ val = dev_p->usb_config[epnum].physical - 1 ;
+ cy_as_hal_assert(val >= 0 && val <= 3) ;
+ v |= (val << 5) ;
+
+ switch (dev_p->usb_config[epnum].type) {
+ case cy_as_usb_bulk:
+ val = 2 ;
+ break ;
+ case cy_as_usb_int:
+ val = 3 ;
+ break ;
+ case cy_as_usb_iso:
+ val = 1 ;
+ break ;
+ default:
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+ v |= (val << 3) ;
+ }
+
+ dev_p->usb_lepcfg[i] = v ;
+ }
+}
+
+
+cy_as_return_status_t
+cy_as_usb_map_logical2_physical(cy_as_device *dev_p)
+{
+ cy_as_return_status_t ret ;
+
+ /* Physical EPs 3 5 7 9 respectively in the array */
+ cy_as_physical_endpoint_state epstate[4] = {
+ cy_as_e_p_free, cy_as_e_p_free,
+ cy_as_e_p_free, cy_as_e_p_free } ;
+
+ /* Find the direction for the endpoints */
+ ret = find_endpoint_directions(dev_p, epstate) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * now create the register settings based on the given
+ * assigned of logical E_ps to physical endpoints.
+ */
+ create_register_settings(dev_p, epstate) ;
+
+ return ret ;
+}
+
+static uint16_t
+get_max_dma_size(cy_as_device *dev_p, cy_as_end_point_number_t ep)
+{
+ uint16_t size = dev_p->usb_config[ep].size ;
+
+ if (size == 0) {
+ switch (dev_p->usb_config[ep].type) {
+ case cy_as_usb_control:
+ size = 64 ;
+ break ;
+
+ case cy_as_usb_bulk:
+ size = cy_as_device_is_usb_high_speed(dev_p) ?
+ 512 : 64 ;
+ break ;
+
+ case cy_as_usb_int:
+ size = cy_as_device_is_usb_high_speed(dev_p) ?
+ 1024 : 64 ;
+ break ;
+
+ case cy_as_usb_iso:
+ size = cy_as_device_is_usb_high_speed(dev_p) ?
+ 1024 : 1023 ;
+ break ;
+ }
+ }
+
+ return size ;
+}
+
+cy_as_return_status_t
+cy_as_usb_set_dma_sizes(cy_as_device *dev_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint32_t i ;
+
+ for (i = 0 ; i < 10 ; i++) {
+ cy_as_usb_end_point_config *config_p =
+ &dev_p->usb_config[end_point_map[i]] ;
+ if (config_p->enabled) {
+ ret = cy_as_dma_set_max_dma_size(dev_p,
+ end_point_map[i],
+ get_max_dma_size(dev_p, end_point_map[i])) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ break ;
+ }
+ }
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_setup_dma(cy_as_device *dev_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint32_t i ;
+
+ for (i = 0 ; i < 10 ; i++) {
+ cy_as_usb_end_point_config *config_p =
+ &dev_p->usb_config[end_point_map[i]] ;
+ if (config_p->enabled) {
+ /* Map the endpoint direction to the DMA direction */
+ cy_as_dma_direction dir = cy_as_direction_out ;
+ if (config_p->dir == cy_as_usb_in)
+ dir = cy_as_direction_in ;
+
+ ret = cy_as_dma_enable_end_point(dev_p,
+ end_point_map[i], cy_true, dir) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ break ;
+ }
+ }
+
+ return ret ;
+}
diff --git a/drivers/staging/westbridge/astoria/api/src/cyaslowlevel.c b/drivers/staging/westbridge/astoria/api/src/cyaslowlevel.c
new file mode 100644
index 000000000000..70d56e9b060c
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyaslowlevel.c
@@ -0,0 +1,1264 @@
+/* Cypress West Bridge API source file (cyaslowlevel.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyascast.h"
+#include "../../include/linux/westbridge/cyasdevice.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyasintr.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+
+static const uint32_t cy_as_low_level_timeout_count = 65536 * 4 ;
+
+/* Forward declaration */
+static cy_as_return_status_t cy_as_send_one(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p) ;
+
+/*
+* This array holds the size of the largest request we will ever recevie from
+* the West Bridge device per context. The size is in 16 bit words. Note a
+* size of 0xffff indicates that there will be no requests on this context
+* from West Bridge.
+*/
+static uint16_t max_request_length[CY_RQT_CONTEXT_COUNT] = {
+ 8, /* CY_RQT_GENERAL_RQT_CONTEXT - CY_RQT_INITIALIZATION_COMPLETE */
+ 8, /* CY_RQT_RESOURCE_RQT_CONTEXT - none */
+ 8, /* CY_RQT_STORAGE_RQT_CONTEXT - CY_RQT_MEDIA_CHANGED */
+ 128, /* CY_RQT_USB_RQT_CONTEXT - CY_RQT_USB_EVENT */
+ 8 /* CY_RQT_TUR_RQT_CONTEXT - CY_RQT_TURBO_CMD_FROM_HOST */
+} ;
+
+/*
+* For the given context, this function removes the request node at the head
+* of the queue from the context. This is called after all processing has
+* occurred on the given request and response and we are ready to remove this
+* entry from the queue.
+*/
+static void
+cy_as_ll_remove_request_queue_head(cy_as_device *dev_p, cy_as_context *ctxt_p)
+{
+ uint32_t mask, state ;
+ cy_as_ll_request_list_node *node_p ;
+
+ (void)dev_p ;
+ cy_as_hal_assert(ctxt_p->request_queue_p != 0) ;
+
+ mask = cy_as_hal_disable_interrupts() ;
+ node_p = ctxt_p->request_queue_p ;
+ ctxt_p->request_queue_p = node_p->next ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+ node_p->callback = 0 ;
+ node_p->rqt = 0 ;
+ node_p->resp = 0 ;
+
+ /*
+ * note that the caller allocates and destroys the request and
+ * response. generally the destroy happens in the callback for
+ * async requests and after the wait returns for sync. the
+ * request and response may not actually be destroyed but may be
+ * managed in other ways as well. it is the responsibilty of
+ * the caller to deal with these in any case. the caller can do
+ * this in the request/response callback function.
+ */
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+/*
+* For the context given, this function sends the next request to
+* West Bridge via the mailbox register, if the next request is
+* ready to be sent and has not already been sent.
+*/
+static void
+cy_as_ll_send_next_request(cy_as_device *dev_p, cy_as_context *ctxt_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ /*
+ * ret == ret is equivalent to while (1) but eliminates compiler
+ * warnings for some compilers.
+ */
+ while (ret == ret) {
+ cy_as_ll_request_list_node *node_p = ctxt_p->request_queue_p ;
+ if (node_p == 0)
+ break ;
+
+ if (cy_as_request_get_node_state(node_p) !=
+ CY_AS_REQUEST_LIST_STATE_QUEUED)
+ break ;
+
+ cy_as_request_set_node_state(node_p,
+ CY_AS_REQUEST_LIST_STATE_WAITING) ;
+ ret = cy_as_send_one(dev_p, node_p->rqt) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ break ;
+
+ /*
+ * if an error occurs in sending the request, tell the requester
+ * about the error and remove the request from the queue.
+ */
+ cy_as_request_set_node_state(node_p,
+ CY_AS_REQUEST_LIST_STATE_RECEIVED) ;
+ node_p->callback(dev_p, ctxt_p->number,
+ node_p->rqt, node_p->resp, ret) ;
+ cy_as_ll_remove_request_queue_head(dev_p, ctxt_p) ;
+
+ /*
+ * this falls through to the while loop to send the next request
+ * since the previous request did not get sent.
+ */
+ }
+}
+
+/*
+* This method removes an entry from the request queue of a given context.
+* The entry is removed only if it is not in transit.
+*/
+cy_as_remove_request_result_t
+cy_as_ll_remove_request(cy_as_device *dev_p, cy_as_context *ctxt_p,
+ cy_as_ll_request_response *req_p, cy_bool force)
+{
+ uint32_t imask ;
+ cy_as_ll_request_list_node *node_p ;
+ cy_as_ll_request_list_node *tmp_p ;
+ uint32_t state ;
+
+ imask = cy_as_hal_disable_interrupts() ;
+ if (ctxt_p->request_queue_p != 0 &&
+ ctxt_p->request_queue_p->rqt == req_p) {
+ node_p = ctxt_p->request_queue_p ;
+ if ((cy_as_request_get_node_state(node_p) ==
+ CY_AS_REQUEST_LIST_STATE_WAITING) && (!force)) {
+ cy_as_hal_enable_interrupts(imask) ;
+ return cy_as_remove_request_in_transit ;
+ }
+
+ ctxt_p->request_queue_p = node_p->next ;
+ } else {
+ tmp_p = ctxt_p->request_queue_p ;
+ while (tmp_p != 0 && tmp_p->next != 0 &&
+ tmp_p->next->rqt != req_p)
+ tmp_p = tmp_p->next ;
+
+ if (tmp_p == 0 || tmp_p->next == 0) {
+ cy_as_hal_enable_interrupts(imask) ;
+ return cy_as_remove_request_not_found ;
+ }
+
+ node_p = tmp_p->next ;
+ tmp_p->next = node_p->next ;
+ }
+
+ if (node_p->callback)
+ node_p->callback(dev_p, ctxt_p->number, node_p->rqt,
+ node_p->resp, CY_AS_ERROR_CANCELED) ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+
+ cy_as_hal_enable_interrupts(imask) ;
+ return cy_as_remove_request_sucessful ;
+}
+
+void
+cy_as_ll_remove_all_requests(cy_as_device *dev_p, cy_as_context *ctxt_p)
+{
+ cy_as_ll_request_list_node *node = ctxt_p->request_queue_p ;
+
+ while (node) {
+ if (cy_as_request_get_node_state(ctxt_p->request_queue_p) !=
+ CY_AS_REQUEST_LIST_STATE_RECEIVED)
+ cy_as_ll_remove_request(dev_p, ctxt_p,
+ node->rqt, cy_true) ;
+ node = node->next ;
+ }
+}
+
+static cy_bool
+cy_as_ll_is_in_queue(cy_as_context *ctxt_p, cy_as_ll_request_response *req_p)
+{
+ uint32_t mask ;
+ cy_as_ll_request_list_node *node_p ;
+
+ mask = cy_as_hal_disable_interrupts() ;
+ node_p = ctxt_p->request_queue_p ;
+ while (node_p) {
+ if (node_p->rqt == req_p) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return cy_true ;
+ }
+ node_p = node_p->next ;
+ }
+ cy_as_hal_enable_interrupts(mask) ;
+ return cy_false ;
+}
+
+/*
+* This is the handler for mailbox data when we are trying to send data
+* to the West Bridge firmware. The firmware may be trying to send us
+* data and we need to queue this data to allow the firmware to move
+* forward and be in a state to receive our request. Here we just queue
+* the data and it is processed at a later time by the mailbox interrupt
+* handler.
+*/
+void
+cy_as_ll_queue_mailbox_data(cy_as_device *dev_p)
+{
+ cy_as_context *ctxt_p ;
+ uint8_t context ;
+ uint16_t data[4] ;
+ int32_t i ;
+
+ /* Read the data from mailbox 0 to determine what to do with the data */
+ for (i = 3 ; i >= 0 ; i--)
+ data[i] = cy_as_hal_read_register(dev_p->tag,
+ cy_cast_int2U_int16(CY_AS_MEM_P0_MAILBOX0 + i)) ;
+
+ context = cy_as_mbox_get_context(data[0]) ;
+ if (context >= CY_RQT_CONTEXT_COUNT) {
+ cy_as_hal_print_message("mailbox request/response received "
+ "with invalid context value (%d)\n", context) ;
+ return ;
+ }
+
+ ctxt_p = dev_p->context[context] ;
+
+ /*
+ * if we have queued too much data, drop future data.
+ */
+ cy_as_hal_assert(ctxt_p->queue_index * sizeof(uint16_t) +
+ sizeof(data) <= sizeof(ctxt_p->data_queue)) ;
+
+ for (i = 0 ; i < 4 ; i++)
+ ctxt_p->data_queue[ctxt_p->queue_index++] = data[i] ;
+
+ cy_as_hal_assert((ctxt_p->queue_index % 4) == 0) ;
+ dev_p->ll_queued_data = cy_true ;
+}
+
+void
+cy_as_mail_box_process_data(cy_as_device *dev_p, uint16_t *data)
+{
+ cy_as_context *ctxt_p ;
+ uint8_t context ;
+ uint16_t *len_p ;
+ cy_as_ll_request_response *rec_p ;
+ uint8_t st ;
+ uint16_t src, dest ;
+
+ context = cy_as_mbox_get_context(data[0]) ;
+ if (context >= CY_RQT_CONTEXT_COUNT) {
+ cy_as_hal_print_message("mailbox request/response received "
+ "with invalid context value (%d)\n", context) ;
+ return ;
+ }
+
+ ctxt_p = dev_p->context[context] ;
+
+ if (cy_as_mbox_is_request(data[0])) {
+ cy_as_hal_assert(ctxt_p->req_p != 0) ;
+ rec_p = ctxt_p->req_p ;
+ len_p = &ctxt_p->request_length ;
+
+ } else {
+ if (ctxt_p->request_queue_p == 0 ||
+ cy_as_request_get_node_state(ctxt_p->request_queue_p)
+ != CY_AS_REQUEST_LIST_STATE_WAITING) {
+ cy_as_hal_print_message("mailbox response received on "
+ "context that was not expecting a response\n") ;
+ cy_as_hal_print_message(" context: %d\n", context);
+ cy_as_hal_print_message(" contents: 0x%04x 0x%04x "
+ "0x%04x 0x%04x\n",
+ data[0], data[1], data[2], data[3]) ;
+ if (ctxt_p->request_queue_p != 0)
+ cy_as_hal_print_message(" state: 0x%02x\n",
+ ctxt_p->request_queue_p->state) ;
+ return ;
+ }
+
+ /* Make sure the request has an associated response */
+ cy_as_hal_assert(ctxt_p->request_queue_p->resp != 0) ;
+
+ rec_p = ctxt_p->request_queue_p->resp ;
+ len_p = &ctxt_p->request_queue_p->length ;
+ }
+
+ if (rec_p->stored == 0) {
+ /*
+ * this is the first cycle of the response
+ */
+ cy_as_ll_request_response__set_code(rec_p,
+ cy_as_mbox_get_code(data[0])) ;
+ cy_as_ll_request_response__set_context(rec_p, context) ;
+
+ if (cy_as_mbox_is_last(data[0])) {
+ /* This is a single cycle response */
+ *len_p = rec_p->length ;
+ st = 1 ;
+ } else {
+ /* Ensure that enough memory has been
+ * reserved for the response. */
+ cy_as_hal_assert(rec_p->length >= data[1]) ;
+ *len_p = (data[1] < rec_p->length) ?
+ data[1] : rec_p->length ;
+ st = 2 ;
+ }
+ } else
+ st = 1 ;
+
+ /* Trasnfer the data from the mailboxes to the response */
+ while (rec_p->stored < *len_p && st < 4)
+ rec_p->data[rec_p->stored++] = data[st++] ;
+
+ if (cy_as_mbox_is_last(data[0])) {
+ /* NB: The call-back that is made below can cause the
+ * addition of more data in this queue, thus causing
+ * a recursive overflow of the queue. this is prevented
+ * by removing the request entry that is currently
+ * being passed up from the data queue. if this is done,
+ * the queue only needs to be as long as two request
+ * entries from west bridge.
+ */
+ if ((ctxt_p->rqt_index > 0) &&
+ (ctxt_p->rqt_index <= ctxt_p->queue_index)) {
+ dest = 0 ;
+ src = ctxt_p->rqt_index ;
+
+ while (src < ctxt_p->queue_index)
+ ctxt_p->data_queue[dest++] =
+ ctxt_p->data_queue[src++] ;
+
+ ctxt_p->rqt_index = 0 ;
+ ctxt_p->queue_index = dest ;
+ cy_as_hal_assert((ctxt_p->queue_index % 4) == 0) ;
+ }
+
+ if (ctxt_p->request_queue_p != 0 && rec_p ==
+ ctxt_p->request_queue_p->resp) {
+ /*
+ * if this is the last cycle of the response, call the
+ * callback and reset for the next response.
+ */
+ cy_as_ll_request_response *resp_p =
+ ctxt_p->request_queue_p->resp ;
+ resp_p->length = ctxt_p->request_queue_p->length ;
+ cy_as_request_set_node_state(ctxt_p->request_queue_p,
+ CY_AS_REQUEST_LIST_STATE_RECEIVED) ;
+
+ cy_as_device_set_in_callback(dev_p) ;
+ ctxt_p->request_queue_p->callback(dev_p, context,
+ ctxt_p->request_queue_p->rqt,
+ resp_p, CY_AS_ERROR_SUCCESS) ;
+
+ cy_as_device_clear_in_callback(dev_p) ;
+
+ cy_as_ll_remove_request_queue_head(dev_p, ctxt_p) ;
+ cy_as_ll_send_next_request(dev_p, ctxt_p) ;
+ } else {
+ /* Send the request to the appropriate
+ * module to handle */
+ cy_as_ll_request_response *request_p = ctxt_p->req_p ;
+ ctxt_p->req_p = 0 ;
+ if (ctxt_p->request_callback) {
+ cy_as_device_set_in_callback(dev_p) ;
+ ctxt_p->request_callback(dev_p, context,
+ request_p, 0, CY_AS_ERROR_SUCCESS) ;
+ cy_as_device_clear_in_callback(dev_p) ;
+ }
+ cy_as_ll_init_request(request_p, 0,
+ context, request_p->length) ;
+ ctxt_p->req_p = request_p ;
+ }
+ }
+}
+
+/*
+* This is the handler for processing queued mailbox data
+*/
+void
+cy_as_mail_box_queued_data_handler(cy_as_device *dev_p)
+{
+ uint16_t i ;
+
+ /*
+ * if more data gets queued in between our entering this call
+ * and the end of the iteration on all contexts; we should
+ * continue processing the queued data.
+ */
+ while (dev_p->ll_queued_data) {
+ dev_p->ll_queued_data = cy_false ;
+ for (i = 0 ; i < CY_RQT_CONTEXT_COUNT ; i++) {
+ uint16_t offset ;
+ cy_as_context *ctxt_p = dev_p->context[i] ;
+ cy_as_hal_assert((ctxt_p->queue_index % 4) == 0) ;
+
+ offset = 0 ;
+ while (offset < ctxt_p->queue_index) {
+ ctxt_p->rqt_index = offset + 4 ;
+ cy_as_mail_box_process_data(dev_p,
+ ctxt_p->data_queue + offset) ;
+ offset = ctxt_p->rqt_index ;
+ }
+ ctxt_p->queue_index = 0 ;
+ }
+ }
+}
+
+/*
+* This is the handler for the mailbox interrupt. This function reads
+* data from the mailbox registers until a complete request or response
+* is received. When a complete request is received, the callback
+* associated with requests on that context is called. When a complete
+* response is recevied, the callback associated with the request that
+* generated the reponse is called.
+*/
+void
+cy_as_mail_box_interrupt_handler(cy_as_device *dev_p)
+{
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ /*
+ * queue the mailbox data to preserve
+ * order for later processing.
+ */
+ cy_as_ll_queue_mailbox_data(dev_p) ;
+
+ /*
+ * process what was queued and anything that may be pending
+ */
+ cy_as_mail_box_queued_data_handler(dev_p) ;
+}
+
+cy_as_return_status_t
+cy_as_ll_start(cy_as_device *dev_p)
+{
+ uint16_t i ;
+
+ if (cy_as_device_is_low_level_running(dev_p))
+ return CY_AS_ERROR_ALREADY_RUNNING ;
+
+ dev_p->ll_sending_rqt = cy_false ;
+ dev_p->ll_abort_curr_rqt = cy_false ;
+
+ for (i = 0 ; i < CY_RQT_CONTEXT_COUNT ; i++) {
+ dev_p->context[i] = (cy_as_context *)
+ cy_as_hal_alloc(sizeof(cy_as_context)) ;
+ if (dev_p->context[i] == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ dev_p->context[i]->number = (uint8_t)i ;
+ dev_p->context[i]->request_callback = 0 ;
+ dev_p->context[i]->request_queue_p = 0 ;
+ dev_p->context[i]->last_node_p = 0 ;
+ dev_p->context[i]->req_p = cy_as_ll_create_request(dev_p,
+ 0, (uint8_t)i, max_request_length[i]) ;
+ dev_p->context[i]->queue_index = 0 ;
+
+ if (!cy_as_hal_create_sleep_channel
+ (&dev_p->context[i]->channel))
+ return CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED ;
+ }
+
+ cy_as_device_set_low_level_running(dev_p) ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* Shutdown the low level communications module. This operation will
+* also cancel any queued low level requests.
+*/
+cy_as_return_status_t
+cy_as_ll_stop(cy_as_device *dev_p)
+{
+ uint8_t i ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_context *ctxt_p ;
+ uint32_t mask ;
+
+ for (i = 0 ; i < CY_RQT_CONTEXT_COUNT ; i++) {
+ ctxt_p = dev_p->context[i] ;
+ if (!cy_as_hal_destroy_sleep_channel(&ctxt_p->channel))
+ return CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED ;
+
+ /*
+ * now, free any queued requests and assocaited responses
+ */
+ while (ctxt_p->request_queue_p) {
+ uint32_t state ;
+ cy_as_ll_request_list_node *node_p =
+ ctxt_p->request_queue_p ;
+
+ /* Mark this pair as in a cancel operation */
+ cy_as_request_set_node_state(node_p,
+ CY_AS_REQUEST_LIST_STATE_CANCELING) ;
+
+ /* Tell the caller that we are canceling this request */
+ /* NB: The callback is responsible for destroying the
+ * request and the response. we cannot count on the
+ * contents of these two after calling the callback.
+ */
+ node_p->callback(dev_p, i, node_p->rqt,
+ node_p->resp, CY_AS_ERROR_CANCELED) ;
+
+ /* Remove the pair from the queue */
+ mask = cy_as_hal_disable_interrupts() ;
+ ctxt_p->request_queue_p = node_p->next ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+ /* Free the list node */
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+ }
+
+ cy_as_ll_destroy_request(dev_p, dev_p->context[i]->req_p) ;
+ cy_as_hal_free(dev_p->context[i]) ;
+ dev_p->context[i] = 0 ;
+
+ }
+ cy_as_device_set_low_level_stopped(dev_p) ;
+
+ return ret ;
+}
+
+void
+cy_as_ll_init_request(cy_as_ll_request_response *req_p,
+ uint16_t code, uint16_t context, uint16_t length)
+{
+ uint16_t totallen = sizeof(cy_as_ll_request_response) +
+ (length - 1) * sizeof(uint16_t) ;
+
+ cy_as_hal_mem_set(req_p, 0, totallen) ;
+ req_p->length = length ;
+ cy_as_ll_request_response__set_code(req_p, code) ;
+ cy_as_ll_request_response__set_context(req_p, context) ;
+ cy_as_ll_request_response__set_request(req_p) ;
+}
+
+/*
+* Create a new request.
+*/
+cy_as_ll_request_response *
+cy_as_ll_create_request(cy_as_device *dev_p, uint16_t code,
+ uint8_t context, uint16_t length)
+{
+ cy_as_ll_request_response *req_p ;
+ uint32_t state ;
+ uint16_t totallen = sizeof(cy_as_ll_request_response) +
+ (length - 1) * sizeof(uint16_t) ;
+
+ (void)dev_p ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ req_p = cy_as_hal_c_b_alloc(totallen) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (req_p)
+ cy_as_ll_init_request(req_p, code, context, length) ;
+
+ return req_p ;
+}
+
+/*
+* Destroy a request.
+*/
+void
+cy_as_ll_destroy_request(cy_as_device *dev_p, cy_as_ll_request_response *req_p)
+{
+ uint32_t state ;
+ (void)dev_p ;
+ (void)req_p ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(req_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+
+}
+
+void
+cy_as_ll_init_response(cy_as_ll_request_response *req_p, uint16_t length)
+{
+ uint16_t totallen = sizeof(cy_as_ll_request_response) +
+ (length - 1) * sizeof(uint16_t) ;
+
+ cy_as_hal_mem_set(req_p, 0, totallen) ;
+ req_p->length = length ;
+ cy_as_ll_request_response__set_response(req_p) ;
+}
+
+/*
+* Create a new response
+*/
+cy_as_ll_request_response *
+cy_as_ll_create_response(cy_as_device *dev_p, uint16_t length)
+{
+ cy_as_ll_request_response *req_p ;
+ uint32_t state ;
+ uint16_t totallen = sizeof(cy_as_ll_request_response) +
+ (length - 1) * sizeof(uint16_t) ;
+
+ (void)dev_p ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ req_p = cy_as_hal_c_b_alloc(totallen) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (req_p)
+ cy_as_ll_init_response(req_p, length) ;
+
+ return req_p ;
+}
+
+/*
+* Destroy the new response
+*/
+void
+cy_as_ll_destroy_response(cy_as_device *dev_p, cy_as_ll_request_response *req_p)
+{
+ uint32_t state ;
+ (void)dev_p ;
+ (void)req_p ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(req_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+static uint16_t
+cy_as_read_intr_status(
+ cy_as_device *dev_p)
+{
+ uint32_t mask ;
+ cy_bool bloop = cy_true ;
+ uint16_t v = 0, last = 0xffff;
+
+ /*
+ * before determining if the mailboxes are ready for more data,
+ * we first check the mailbox interrupt to see if we need to
+ * receive data. this prevents a dead-lock condition that can
+ * occur when both sides are trying to receive data.
+ */
+ while (last == last) {
+ /*
+ * disable interrupts to be sure we don't process the mailbox
+ * here and have the interrupt routine try to read this data
+ * as well.
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+
+ /*
+ * see if there is data to be read.
+ */
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_INTR_REG) ;
+ if ((v & CY_AS_MEM_P0_INTR_REG_MBINT) == 0) {
+ cy_as_hal_enable_interrupts(mask) ;
+ break ;
+ }
+
+ /*
+ * queue the mailbox data for later processing.
+ * this allows the firmware to move forward and
+ * service the requst from the P port.
+ */
+ cy_as_ll_queue_mailbox_data(dev_p) ;
+
+ /*
+ * enable interrupts again to service mailbox
+ * interrupts appropriately
+ */
+ cy_as_hal_enable_interrupts(mask) ;
+ }
+
+ /*
+ * now, all data is received
+ */
+ last = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MB_STAT) & CY_AS_MEM_P0_MCU_MBNOTRD ;
+ while (bloop) {
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MB_STAT) & CY_AS_MEM_P0_MCU_MBNOTRD ;
+ if (v == last)
+ break ;
+
+ last = v ;
+ }
+
+ return v ;
+}
+
+/*
+* Send a single request or response using the mail box register.
+* This function does not deal with the internal queues at all,
+* but only sends the request or response across to the firmware
+*/
+static cy_as_return_status_t
+cy_as_send_one(
+ cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ int i ;
+ uint16_t mb0, v ;
+ int32_t loopcount ;
+ uint32_t int_stat ;
+
+#ifdef _DEBUG
+ if (cy_as_ll_request_response__is_request(req_p)) {
+ switch (cy_as_ll_request_response__get_context(req_p)) {
+ case CY_RQT_GENERAL_RQT_CONTEXT:
+ cy_as_hal_assert(req_p->length * 2 + 2 <
+ CY_CTX_GEN_MAX_DATA_SIZE) ;
+ break ;
+
+ case CY_RQT_RESOURCE_RQT_CONTEXT:
+ cy_as_hal_assert(req_p->length * 2 + 2 <
+ CY_CTX_RES_MAX_DATA_SIZE) ;
+ break ;
+
+ case CY_RQT_STORAGE_RQT_CONTEXT:
+ cy_as_hal_assert(req_p->length * 2 + 2 <
+ CY_CTX_STR_MAX_DATA_SIZE) ;
+ break ;
+
+ case CY_RQT_USB_RQT_CONTEXT:
+ cy_as_hal_assert(req_p->length * 2 + 2 <
+ CY_CTX_USB_MAX_DATA_SIZE) ;
+ break ;
+ }
+ }
+#endif
+
+ /* Write the request to the mail box registers */
+ if (req_p->length > 3) {
+ uint16_t length = req_p->length ;
+ int which = 0 ;
+ int st = 1 ;
+
+ dev_p->ll_sending_rqt = cy_true ;
+ while (which < length) {
+ loopcount = cy_as_low_level_timeout_count ;
+ do {
+ v = cy_as_read_intr_status(dev_p) ;
+
+ } while (v && loopcount-- > 0) ;
+
+ if (v) {
+ cy_as_hal_print_message(
+ ">>>>>> LOW LEVEL TIMEOUT "
+ "%x %x %x %x\n",
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX0),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX1),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX2),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX3)) ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+
+ if (dev_p->ll_abort_curr_rqt) {
+ dev_p->ll_sending_rqt = cy_false ;
+ dev_p->ll_abort_curr_rqt = cy_false ;
+ return CY_AS_ERROR_CANCELED ;
+ }
+
+ int_stat = cy_as_hal_disable_interrupts() ;
+
+ /*
+ * check again whether the mailbox is free.
+ * it is possible that an ISR came in and
+ * wrote into the mailboxes since we last
+ * checked the status.
+ */
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MB_STAT) &
+ CY_AS_MEM_P0_MCU_MBNOTRD ;
+ if (v) {
+ /* Go back to the original check since
+ * the mailbox is not free. */
+ cy_as_hal_enable_interrupts(int_stat) ;
+ continue ;
+ }
+
+ if (which == 0) {
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX1, length) ;
+ st = 2 ;
+ } else {
+ st = 1;
+ }
+
+ while ((which < length) && (st < 4)) {
+ cy_as_hal_write_register(dev_p->tag,
+ cy_cast_int2U_int16
+ (CY_AS_MEM_MCU_MAILBOX0 + st),
+ req_p->data[which++]) ;
+ st++ ;
+ }
+
+ mb0 = req_p->box0 ;
+ if (which == length) {
+ dev_p->ll_sending_rqt = cy_false ;
+ mb0 |= CY_AS_REQUEST_RESPONSE_LAST_MASK ;
+ }
+
+ if (dev_p->ll_abort_curr_rqt) {
+ dev_p->ll_sending_rqt = cy_false ;
+ dev_p->ll_abort_curr_rqt = cy_false ;
+ cy_as_hal_enable_interrupts(int_stat) ;
+ return CY_AS_ERROR_CANCELED ;
+ }
+
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX0, mb0) ;
+
+ /* Wait for the MBOX interrupt to be high */
+ cy_as_hal_sleep150() ;
+ cy_as_hal_enable_interrupts(int_stat) ;
+ }
+ } else {
+check_mailbox_availability:
+ /*
+ * wait for the mailbox registers to become available. this
+ * should be a very quick wait as the firmware is designed
+ * to accept requests at interrupt time and queue them for
+ * future processing.
+ */
+ loopcount = cy_as_low_level_timeout_count ;
+ do {
+ v = cy_as_read_intr_status(dev_p) ;
+
+ } while (v && loopcount-- > 0) ;
+
+ if (v) {
+ cy_as_hal_print_message(
+ ">>>>>> LOW LEVEL TIMEOUT %x %x %x %x\n",
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX0),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX1),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX2),
+ cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_MCU_MAILBOX3)) ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+
+ int_stat = cy_as_hal_disable_interrupts();
+
+ /*
+ * check again whether the mailbox is free. it is
+ * possible that an ISR came in and wrote into the
+ * mailboxes since we last checked the status.
+ */
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_MCU_MB_STAT) &
+ CY_AS_MEM_P0_MCU_MBNOTRD ;
+ if (v) {
+ /* Go back to the original check
+ * since the mailbox is not free. */
+ cy_as_hal_enable_interrupts(int_stat) ;
+ goto check_mailbox_availability ;
+ }
+
+ /* Write the data associated with the request
+ * into the mbox registers 1 - 3 */
+ v = 0 ;
+ for (i = req_p->length - 1 ; i >= 0 ; i--)
+ cy_as_hal_write_register(dev_p->tag,
+ cy_cast_int2U_int16(CY_AS_MEM_MCU_MAILBOX1 + i),
+ req_p->data[i]) ;
+
+ /* Write the mbox register 0 to trigger the interrupt */
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_MCU_MAILBOX0,
+ req_p->box0 | CY_AS_REQUEST_RESPONSE_LAST_MASK) ;
+
+ cy_as_hal_sleep150() ;
+ cy_as_hal_enable_interrupts(int_stat);
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* This function queues a single request to be sent to the firmware.
+*/
+extern cy_as_return_status_t
+cy_as_ll_send_request(
+ cy_as_device *dev_p,
+ /* The request to send */
+ cy_as_ll_request_response *req,
+ /* Storage for a reply, must be sure
+ * it is of sufficient size */
+ cy_as_ll_request_response *resp,
+ /* If true, this is a synchronous request */
+ cy_bool sync,
+ /* Callback to call when reply is received */
+ cy_as_response_callback cb
+)
+{
+ cy_as_context *ctxt_p ;
+ uint16_t box0 = req->box0 ;
+ uint8_t context ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_list_node *node_p ;
+ uint32_t mask, state ;
+
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE);
+
+ context = cy_as_mbox_get_context(box0) ;
+ cy_as_hal_assert(context < CY_RQT_CONTEXT_COUNT) ;
+ ctxt_p = dev_p->context[context] ;
+
+ /* Allocate the list node */
+ state = cy_as_hal_disable_interrupts() ;
+ node_p = cy_as_hal_c_b_alloc(sizeof(cy_as_ll_request_list_node)) ;
+ cy_as_hal_enable_interrupts(state) ;
+
+ if (node_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Initialize the list node */
+ node_p->callback = cb ;
+ node_p->length = 0 ;
+ node_p->next = 0 ;
+ node_p->resp = resp ;
+ node_p->rqt = req ;
+ node_p->state = CY_AS_REQUEST_LIST_STATE_QUEUED ;
+ if (sync)
+ cy_as_request_node_set_sync(node_p) ;
+
+ /* Put the request into the queue */
+ mask = cy_as_hal_disable_interrupts() ;
+ if (ctxt_p->request_queue_p == 0) {
+ /* Empty queue */
+ ctxt_p->request_queue_p = node_p ;
+ ctxt_p->last_node_p = node_p ;
+ } else {
+ ctxt_p->last_node_p->next = node_p ;
+ ctxt_p->last_node_p = node_p ;
+ }
+ cy_as_hal_enable_interrupts(mask) ;
+ cy_as_ll_send_next_request(dev_p, ctxt_p) ;
+
+ if (!cy_as_device_is_in_callback(dev_p)) {
+ mask = cy_as_hal_disable_interrupts() ;
+ cy_as_mail_box_queued_data_handler(dev_p) ;
+ cy_as_hal_enable_interrupts(mask) ;
+ }
+
+ return ret ;
+}
+
+static void
+cy_as_ll_send_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ (void)rqt ;
+ (void)resp ;
+ (void)ret ;
+
+
+ cy_as_hal_assert(dev_p->sig == CY_AS_DEVICE_HANDLE_SIGNATURE) ;
+
+ /*
+ * storage the state to return to the caller
+ */
+ dev_p->ll_error = ret ;
+
+ /*
+ * now wake the caller
+ */
+ cy_as_hal_wake(&dev_p->context[context]->channel) ;
+}
+
+cy_as_return_status_t
+cy_as_ll_send_request_wait_reply(
+ cy_as_device *dev_p,
+ /* The request to send */
+ cy_as_ll_request_response *req,
+ /* Storage for a reply, must be
+ * sure it is of sufficient size */
+ cy_as_ll_request_response *resp
+ )
+{
+ cy_as_return_status_t ret ;
+ uint8_t context ;
+ /* Larger 8 sec time-out to handle the init
+ * delay for slower storage devices in USB FS. */
+ uint32_t loopcount = 800 ;
+ cy_as_context *ctxt_p ;
+
+ /* Get the context for the request */
+ context = cy_as_ll_request_response__get_context(req) ;
+ cy_as_hal_assert(context < CY_RQT_CONTEXT_COUNT) ;
+ ctxt_p = dev_p->context[context] ;
+
+ ret = cy_as_ll_send_request(dev_p, req, resp,
+ cy_true, cy_as_ll_send_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ while (loopcount-- > 0) {
+ /*
+ * sleep while we wait on the response. receiving the reply will
+ * wake this thread. we will wait, at most 2 seconds (10 ms*200
+ * tries) before we timeout. note if the reply arrives, we will
+ * not sleep the entire 10 ms, just til the reply arrives.
+ */
+ cy_as_hal_sleep_on(&ctxt_p->channel, 10) ;
+
+ /*
+ * if the request has left the queue, it means the request has
+ * been sent and the reply has been received. this means we can
+ * return to the caller and be sure the reply has been received.
+ */
+ if (!cy_as_ll_is_in_queue(ctxt_p, req))
+ return dev_p->ll_error ;
+ }
+
+ /* Remove the QueueListNode for this request. */
+ cy_as_ll_remove_request(dev_p, ctxt_p, req, cy_true) ;
+
+ return CY_AS_ERROR_TIMEOUT ;
+}
+
+cy_as_return_status_t
+cy_as_ll_register_request_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_response_callback cb)
+{
+ cy_as_context *ctxt_p ;
+ cy_as_hal_assert(context < CY_RQT_CONTEXT_COUNT) ;
+ ctxt_p = dev_p->context[context] ;
+
+ ctxt_p->request_callback = cb ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+void
+cy_as_ll_request_response__pack(
+ cy_as_ll_request_response *req_p,
+ uint32_t offset,
+ uint32_t length,
+ void *data_p)
+{
+ uint16_t dt ;
+ uint8_t *dp = (uint8_t *)data_p ;
+
+ while (length > 1) {
+ dt = ((*dp++) << 8) ;
+ dt |= (*dp++) ;
+ cy_as_ll_request_response__set_word(req_p, offset, dt) ;
+ offset++ ;
+ length -= 2 ;
+ }
+
+ if (length == 1) {
+ dt = (*dp << 8) ;
+ cy_as_ll_request_response__set_word(req_p, offset, dt) ;
+ }
+}
+
+void
+cy_as_ll_request_response__unpack(
+ cy_as_ll_request_response *req_p,
+ uint32_t offset,
+ uint32_t length,
+ void *data_p)
+{
+ uint8_t *dp = (uint8_t *)data_p ;
+
+ while (length-- > 0) {
+ uint16_t val = cy_as_ll_request_response__get_word
+ (req_p, offset++) ;
+ *dp++ = (uint8_t)((val >> 8) & 0xff) ;
+
+ if (length) {
+ length-- ;
+ *dp++ = (uint8_t)(val & 0xff) ;
+ }
+ }
+}
+
+extern cy_as_return_status_t
+cy_as_ll_send_status_response(
+ cy_as_device *dev_p,
+ uint8_t context,
+ uint16_t code,
+ uint8_t clear_storage)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response resp ;
+ cy_as_ll_request_response *resp_p = &resp ;
+
+ cy_as_hal_mem_set(resp_p, 0, sizeof(resp)) ;
+ resp_p->length = 1 ;
+ cy_as_ll_request_response__set_response(resp_p) ;
+ cy_as_ll_request_response__set_context(resp_p, context) ;
+
+ if (clear_storage)
+ cy_as_ll_request_response__set_clear_storage_flag(resp_p) ;
+
+ cy_as_ll_request_response__set_code(resp_p, CY_RESP_SUCCESS_FAILURE) ;
+ cy_as_ll_request_response__set_word(resp_p, 0, code) ;
+
+ ret = cy_as_send_one(dev_p, resp_p) ;
+
+ return ret ;
+}
+
+extern cy_as_return_status_t
+cy_as_ll_send_data_response(
+ cy_as_device *dev_p,
+ uint8_t context,
+ uint16_t code,
+ uint16_t length,
+ void *data)
+{
+ cy_as_ll_request_response *resp_p ;
+ uint16_t wlen ;
+ uint8_t respbuf[256] ;
+
+ if (length > 192)
+ return CY_AS_ERROR_INVALID_SIZE ;
+
+ /* Word length for bytes */
+ wlen = length / 2 ;
+
+ /* If byte length odd, add one more */
+ if (length % 2)
+ wlen++ ;
+
+ /* One for the length of field */
+ wlen++ ;
+
+ resp_p = (cy_as_ll_request_response *)respbuf ;
+ cy_as_hal_mem_set(resp_p, 0, sizeof(respbuf)) ;
+ resp_p->length = wlen ;
+ cy_as_ll_request_response__set_context(resp_p, context) ;
+ cy_as_ll_request_response__set_code(resp_p, code) ;
+
+ cy_as_ll_request_response__set_word(resp_p, 0, length) ;
+ cy_as_ll_request_response__pack(resp_p, 1, length, data) ;
+
+ return cy_as_send_one(dev_p, resp_p) ;
+}
+
+static cy_bool
+cy_as_ll_is_e_p_transfer_related_request(cy_as_ll_request_response *rqt_p,
+ cy_as_end_point_number_t ep)
+{
+ uint16_t v ;
+ uint8_t type = cy_as_ll_request_response__get_code(rqt_p) ;
+
+ if (cy_as_ll_request_response__get_context(rqt_p) !=
+ CY_RQT_USB_RQT_CONTEXT)
+ return cy_false ;
+
+ /*
+ * when cancelling outstanding EP0 data transfers, any pending
+ * setup ACK requests also need to be cancelled.
+ */
+ if ((ep == 0) && (type == CY_RQT_ACK_SETUP_PACKET))
+ return cy_true ;
+
+ if (type != CY_RQT_USB_EP_DATA)
+ return cy_false ;
+
+ v = cy_as_ll_request_response__get_word(rqt_p, 0) ;
+ if ((cy_as_end_point_number_t)((v >> 13) & 1) != ep)
+ return cy_false ;
+
+ return cy_true ;
+}
+
+cy_as_return_status_t
+cy_as_ll_remove_ep_data_requests(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep)
+{
+ cy_as_context *ctxt_p ;
+ cy_as_ll_request_list_node *node_p ;
+ uint32_t imask ;
+
+ /*
+ * first, remove any queued requests
+ */
+ ctxt_p = dev_p->context[CY_RQT_USB_RQT_CONTEXT] ;
+ if (ctxt_p) {
+ for (node_p = ctxt_p->request_queue_p; node_p;
+ node_p = node_p->next) {
+ if (cy_as_ll_is_e_p_transfer_related_request
+ (node_p->rqt, ep)) {
+ cy_as_ll_remove_request(dev_p, ctxt_p,
+ node_p->rqt, cy_false) ;
+ break ;
+ }
+ }
+
+ /*
+ * now, deal with any request that may be in transit
+ */
+ imask = cy_as_hal_disable_interrupts() ;
+
+ if (ctxt_p->request_queue_p != 0 &&
+ cy_as_ll_is_e_p_transfer_related_request
+ (ctxt_p->request_queue_p->rqt, ep) &&
+ cy_as_request_get_node_state(ctxt_p->request_queue_p) ==
+ CY_AS_REQUEST_LIST_STATE_WAITING) {
+ cy_as_hal_print_message("need to remove an in-transit "
+ "request to antioch\n") ;
+
+ /*
+ * if the request has not been fully sent to west bridge
+ * yet, abort sending. otherwise, terminate the request
+ * with a CANCELED status. firmware will already have
+ * terminated this transfer.
+ */
+ if (dev_p->ll_sending_rqt)
+ dev_p->ll_abort_curr_rqt = cy_true ;
+ else {
+ uint32_t state ;
+
+ node_p = ctxt_p->request_queue_p ;
+ if (node_p->callback)
+ node_p->callback(dev_p, ctxt_p->number,
+ node_p->rqt, node_p->resp,
+ CY_AS_ERROR_CANCELED) ;
+
+ ctxt_p->request_queue_p = node_p->next ;
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+ }
+ }
+
+ cy_as_hal_enable_interrupts(imask) ;
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasmisc.c b/drivers/staging/westbridge/astoria/api/src/cyasmisc.c
new file mode 100644
index 000000000000..7c1c945873d5
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasmisc.c
@@ -0,0 +1,3474 @@
+/* Cypress West Bridge API source file (cyasmisc.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasmisc.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+#include "../../include/linux/westbridge/cyasintr.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyasprotocol.h"
+
+/*
+* The device list, the only global in the API
+*/
+static cy_as_device *g_device_list;
+
+/*
+ * The current debug level
+ */
+static uint8_t debug_level;
+
+/*
+ * This function sets the debug level for the API
+ *
+ */
+void
+cy_as_misc_set_log_level(uint8_t level)
+{
+ debug_level = level ;
+}
+
+#ifdef CY_AS_LOG_SUPPORT
+
+/*
+ * This function is a low level logger for the API.
+ */
+void
+cy_as_log_debug_message(int level, const char *str)
+{
+ if (level <= debug_level)
+ cy_as_hal_print_message("log %d: %s\n", level, str) ;
+}
+
+#endif
+
+#define cy_as_check_device_ready(dev_p) \
+{\
+ if (!(dev_p) || ((dev_p)->sig != \
+ CY_AS_DEVICE_HANDLE_SIGNATURE)) \
+ return CY_AS_ERROR_INVALID_HANDLE ; \
+\
+ if (!cy_as_device_is_configured(dev_p)) \
+ return CY_AS_ERROR_NOT_CONFIGURED ; \
+\
+ if (!cy_as_device_is_firmware_loaded(dev_p))\
+ return CY_AS_ERROR_NO_FIRMWARE ; \
+}
+
+/* Find an West Bridge device based on a TAG */
+cy_as_device *
+cy_as_device_find_from_tag(cy_as_hal_device_tag tag)
+{
+ cy_as_device *dev_p ;
+
+ for (dev_p = g_device_list; dev_p != 0; dev_p = dev_p->next_p) {
+ if (dev_p->tag == tag)
+ return dev_p ;
+ }
+
+ return 0 ;
+}
+
+/* Map a pre-V1.2 media type to the V1.2+ bus number */
+static void
+cy_as_bus_from_media_type(cy_as_media_type type,
+ cy_as_bus_number_t *bus)
+{
+ if (type == cy_as_media_nand)
+ *bus = 0 ;
+ else
+ *bus = 1 ;
+}
+
+static cy_as_return_status_t
+my_handle_response_no_data(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+* Create a new West Bridge device
+*/
+cy_as_return_status_t
+cy_as_misc_create_device(cy_as_device_handle *handle_p,
+ cy_as_hal_device_tag tag)
+{
+ cy_as_device *dev_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_create_device called") ;
+
+ dev_p = (cy_as_device *)cy_as_hal_alloc(sizeof(cy_as_device)) ;
+ if (dev_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ cy_as_hal_mem_set(dev_p, 0, sizeof(cy_as_device)) ;
+
+ /*
+ * dynamically allocating this buffer to ensure that it is
+ * word aligned.
+ */
+ dev_p->usb_ep_data = (uint8_t *)cy_as_hal_alloc(64 * sizeof(uint8_t)) ;
+ if (dev_p->usb_ep_data == 0) {
+ cy_as_hal_free(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ dev_p->sig = CY_AS_DEVICE_HANDLE_SIGNATURE ;
+ dev_p->tag = tag ;
+ dev_p->usb_max_tx_size = 0x40 ;
+
+ dev_p->storage_write_endpoint = CY_AS_P2S_WRITE_ENDPOINT ;
+ dev_p->storage_read_endpoint = CY_AS_P2S_READ_ENDPOINT ;
+
+ dev_p->func_cbs_misc = cy_as_create_c_b_queue(CYAS_FUNC_CB) ;
+ if (dev_p->func_cbs_misc == 0)
+ goto destroy ;
+
+ dev_p->func_cbs_res = cy_as_create_c_b_queue(CYAS_FUNC_CB) ;
+ if (dev_p->func_cbs_res == 0)
+ goto destroy ;
+
+ dev_p->func_cbs_stor = cy_as_create_c_b_queue(CYAS_FUNC_CB) ;
+ if (dev_p->func_cbs_stor == 0)
+ goto destroy ;
+
+ dev_p->func_cbs_usb = cy_as_create_c_b_queue(CYAS_FUNC_CB) ;
+ if (dev_p->func_cbs_usb == 0)
+ goto destroy ;
+
+ dev_p->func_cbs_mtp = cy_as_create_c_b_queue(CYAS_FUNC_CB) ;
+ if (dev_p->func_cbs_mtp == 0)
+ goto destroy ;
+
+ /*
+ * allocate memory for the DMA module here. it is then marked idle, and
+ * will be activated when cy_as_misc_configure_device is called.
+ */
+ ret = cy_as_dma_start(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ cy_as_device_set_dma_stopped(dev_p) ;
+
+ /*
+ * allocate memory for the low level module here. this module is also
+ * activated only when cy_as_misc_configure_device is called.
+ */
+ ret = cy_as_ll_start(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ cy_as_device_set_low_level_stopped(dev_p) ;
+
+ dev_p->next_p = g_device_list ;
+ g_device_list = dev_p ;
+
+ *handle_p = dev_p ;
+ cy_as_hal_init_dev_registers(tag, cy_false) ;
+ return CY_AS_ERROR_SUCCESS ;
+
+destroy:
+ /* Free any queues that were successfully allocated. */
+ if (dev_p->func_cbs_misc)
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_misc) ;
+
+ if (dev_p->func_cbs_res)
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_res) ;
+
+ if (dev_p->func_cbs_stor)
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_stor) ;
+
+ if (dev_p->func_cbs_usb)
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_usb) ;
+
+ if (dev_p->func_cbs_mtp)
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_mtp) ;
+
+ cy_as_hal_free(dev_p->usb_ep_data) ;
+ cy_as_hal_free(dev_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ else
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+}
+
+/*
+* Destroy an existing West Bridge device
+*/
+cy_as_return_status_t
+cy_as_misc_destroy_device(cy_as_device_handle handle)
+{
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_destroy_device called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * if the USB stack is still running,
+ * it must be stopped first
+ */
+ if (dev_p->usb_count > 0)
+ return CY_AS_ERROR_STILL_RUNNING ;
+
+ /*
+ * if the STORAGE stack is still running,
+ * it must be stopped first
+ */
+ if (dev_p->storage_count > 0)
+ return CY_AS_ERROR_STILL_RUNNING ;
+
+ if (cy_as_device_is_intr_running(dev_p))
+ ret = cy_as_intr_stop(dev_p) ;
+
+ ret = cy_as_ll_stop(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_intr_start(dev_p, dev_p->use_int_drq) ;
+ return ret ;
+ }
+
+ ret = cy_as_dma_stop(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_intr_start(dev_p, dev_p->use_int_drq) ;
+ return ret ;
+ }
+
+ /* Reset the West Bridge device. */
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_RST_CTRL_REG,
+ CY_AS_MEM_RST_CTRL_REG_HARD) ;
+
+ /*
+ * remove the device from the device list
+ */
+ if (g_device_list == dev_p) {
+ g_device_list = dev_p->next_p ;
+ } else {
+ cy_as_device *tmp_p = g_device_list ;
+ while (tmp_p && tmp_p->next_p != dev_p)
+ tmp_p = tmp_p->next_p ;
+
+ cy_as_hal_assert(tmp_p != 0) ;
+ tmp_p->next_p = dev_p->next_p ;
+ }
+
+ /*
+ * reset the signature so this will not be detected
+ * as a valid handle
+ */
+ dev_p->sig = 0 ;
+
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_misc) ;
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_res) ;
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_stor) ;
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_usb) ;
+ cy_as_destroy_c_b_queue(dev_p->func_cbs_mtp) ;
+
+ /*
+ * free the memory associated with the device
+ */
+ cy_as_hal_free(dev_p->usb_ep_data) ;
+ cy_as_hal_free(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* Determine the endian mode for the processor we are
+* running on, then set the endian mode register
+*/
+static void
+cy_as_setup_endian_mode(cy_as_device *dev_p)
+{
+ /*
+ * In general, we always set west bridge intothe little
+ * endian mode. this causes the data on bit 0 internally
+ * to come out on data line 0 externally and it is generally
+ * what we want regardless of the endian mode of the
+ * processor. this capability in west bridge should be
+ * labeled as a "SWAP" capability and can be used to swap the
+ * bytes of data in and out of west bridge. this is
+ * useful if there is DMA hardware that requires this for some
+ * reason I cannot imagine at this time. basically if the
+ * wires are connected correctly, we should never need to
+ * change the endian-ness of west bridge.
+ */
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_P0_ENDIAN,
+ CY_AS_LITTLE_ENDIAN) ;
+}
+
+/*
+* Query the West Bridge device and determine if we are an standby mode
+*/
+cy_as_return_status_t
+cy_as_misc_in_standby(cy_as_device_handle handle, cy_bool *standby)
+{
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_in_standby called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (cy_as_device_is_pin_standby(dev_p) ||
+ cy_as_device_is_register_standby(dev_p)) {
+ *standby = cy_true ;
+ } else
+ *standby = cy_false ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+cy_as_misc_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret) ;
+
+
+static void
+my_misc_callback(cy_as_device *dev_p, uint8_t context,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *resp_p,
+ cy_as_return_status_t ret)
+{
+ (void)resp_p ;
+ (void)context ;
+ (void)ret ;
+
+ switch (cy_as_ll_request_response__get_code(req_p)) {
+ case CY_RQT_INITIALIZATION_COMPLETE:
+ {
+ uint16_t v ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_GENERAL_RQT_CONTEXT,
+ CY_AS_ERROR_SUCCESS, 0) ;
+ cy_as_device_set_firmware_loaded(dev_p) ;
+
+ if (cy_as_device_is_waking(dev_p)) {
+ /*
+ * this is a callback from a
+ * cy_as_misc_leave_standby()
+ * request. in this case we call
+ * the standby callback and clear
+ * the waking state.
+ */
+ if (dev_p->misc_event_cb)
+ dev_p->misc_event_cb(
+ (cy_as_device_handle)dev_p,
+ cy_as_event_misc_awake, 0) ;
+ cy_as_device_clear_waking(dev_p) ;
+ } else {
+ v = cy_as_ll_request_response__get_word
+ (req_p, 3) ;
+
+ /*
+ * store the media supported on
+ * each of the device buses.
+ */
+ dev_p->media_supported[0] =
+ (uint8_t)(v & 0xFF) ;
+ dev_p->media_supported[1] =
+ (uint8_t)((v >> 8) & 0xFF) ;
+
+ v = cy_as_ll_request_response__get_word
+ (req_p, 4) ;
+
+ dev_p->is_mtp_firmware =
+ (cy_bool)((v >> 8) & 0xFF) ;
+
+ if (dev_p->misc_event_cb)
+ dev_p->misc_event_cb(
+ (cy_as_device_handle)dev_p,
+ cy_as_event_misc_initialized, 0) ;
+ }
+
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_P0_VM_SET) ;
+
+ if (v & CY_AS_MEM_P0_VM_SET_CFGMODE)
+ cy_as_hal_print_message(
+ "initialization message "
+ "recieved, but config bit "
+ "still set\n") ;
+
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG) ;
+ if ((v & CY_AS_MEM_RST_RSTCMPT) == 0)
+ cy_as_hal_print_message(
+ "initialization message "
+ "recieved, but reset complete "
+ "bit still not set\n") ;
+ }
+ break ;
+
+ case CY_RQT_OUT_OF_SUSPEND:
+ cy_as_ll_send_status_response(dev_p, CY_RQT_GENERAL_RQT_CONTEXT,
+ CY_AS_ERROR_SUCCESS, 0) ;
+ cy_as_device_clear_suspend_mode(dev_p) ;
+
+ /*
+ * if the wakeup was caused by an async cy_as_misc_leave_suspend
+ * call, we have to call the corresponding callback.
+ */
+ if (dev_p->func_cbs_misc->count > 0) {
+ cy_as_func_c_b_node *node = (cy_as_func_c_b_node *)
+ dev_p->func_cbs_misc->head_p ;
+ cy_as_hal_assert(node) ;
+
+ if (cy_as_funct_c_b_type_get_type(node->data_type) ==
+ CY_FUNCT_CB_MISC_LEAVESUSPEND) {
+ cy_as_hal_assert(node->cb_p != 0) ;
+
+ node->cb_p((cy_as_device_handle)dev_p,
+ CY_AS_ERROR_SUCCESS, node->client_data,
+ CY_FUNCT_CB_MISC_LEAVESUSPEND, 0) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_misc) ;
+ }
+ }
+
+ if (dev_p->misc_event_cb)
+ dev_p->misc_event_cb((cy_as_device_handle)dev_p,
+ cy_as_event_misc_wakeup, 0) ;
+ break ;
+
+ case CY_RQT_DEBUG_MESSAGE:
+ if ((req_p->data[0] == 0) && (req_p->data[1] == 0) &&
+ (req_p->data[2] == 0)) {
+ if (dev_p->misc_event_cb)
+ dev_p->misc_event_cb((cy_as_device_handle)dev_p,
+ cy_as_event_misc_heart_beat, 0) ;
+ } else {
+ cy_as_hal_print_message(
+ "**** debug message: %02x "
+ "%02x %02x %02x %02x %02x\n",
+ req_p->data[0] & 0xff,
+ (req_p->data[0] >> 8) & 0xff,
+ req_p->data[1] & 0xff,
+ (req_p->data[1] >> 8) & 0xff,
+ req_p->data[2] & 0xff,
+ (req_p->data[2] >> 8) & 0xff) ;
+ }
+ break ;
+
+ case CY_RQT_WB_DEVICE_MISMATCH:
+ {
+ if (dev_p->misc_event_cb)
+ dev_p->misc_event_cb((cy_as_device_handle)dev_p,
+ cy_as_event_misc_device_mismatch, 0) ;
+ }
+ break ;
+
+ case CY_RQT_BOOTLOAD_NO_FIRMWARE:
+ {
+ /* TODO Handle case when firmware is
+ * not found during bootloading. */
+ cy_as_hal_print_message("no firmware image found "
+ "during bootload. device not started\n") ;
+ }
+ break ;
+
+ default:
+ cy_as_hal_assert(0) ;
+ }
+}
+
+static cy_bool
+is_valid_silicon_id(uint16_t v)
+{
+ cy_bool idok = cy_false ;
+
+ /*
+ * remove the revision number from the ID value
+ */
+ v = v & CY_AS_MEM_CM_WB_CFG_ID_HDID_MASK ;
+
+ /*
+ * if this is west bridge, then we are OK.
+ */
+ if (v == CY_AS_MEM_CM_WB_CFG_ID_HDID_ANTIOCH_VALUE ||
+ v == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_FPGA_VALUE ||
+ v == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_VALUE)
+ idok = cy_true ;
+
+ return idok ;
+}
+
+/*
+* Configure the West Bridge device hardware
+*/
+cy_as_return_status_t
+cy_as_misc_configure_device(cy_as_device_handle handle,
+ cy_as_device_config *config_p)
+{
+ cy_as_return_status_t ret ;
+ cy_bool standby ;
+ cy_as_device *dev_p ;
+ uint16_t v ;
+ uint16_t fw_present;
+ cy_as_log_debug_message(6, "cy_as_misc_configure_device called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /* Setup big endian vs little endian */
+ cy_as_setup_endian_mode(dev_p) ;
+
+ /* Now, confirm that we can talk to the West Bridge device */
+ dev_p->silicon_id = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+ fw_present = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG) ;
+ if (!(fw_present & CY_AS_MEM_RST_RSTCMPT)) {
+ if (!is_valid_silicon_id(dev_p->silicon_id))
+ return CY_AS_ERROR_NO_ANTIOCH ;
+ }
+ /* Check for standby mode */
+ ret = cy_as_misc_in_standby(handle, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ if (ret)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ /* Setup P-port interface mode (CRAM / SRAM). */
+ if (cy_as_device_is_astoria_dev(dev_p)) {
+ if (config_p->srammode)
+ v = CY_AS_MEM_P0_VM_SET_VMTYPE_SRAM ;
+ else
+ v = CY_AS_MEM_P0_VM_SET_VMTYPE_RAM ;
+ } else
+ v = CY_AS_MEM_P0_VM_SET_VMTYPE_RAM ;
+
+ /* Setup synchronous versus asynchronous mode */
+ if (config_p->sync)
+ v |= CY_AS_MEM_P0_VM_SET_IFMODE ;
+ if (config_p->dackmode == cy_as_device_dack_ack)
+ v |= CY_AS_MEM_P0_VM_SET_DACKEOB ;
+ if (config_p->drqpol)
+ v |= CY_AS_MEM_P0_VM_SET_DRQPOL ;
+ if (config_p->dackpol)
+ v |= CY_AS_MEM_P0_VM_SET_DACKPOL ;
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_P0_VM_SET, v) ;
+
+ if (config_p->crystal)
+ cy_as_device_set_crystal(dev_p) ;
+ else
+ cy_as_device_set_external_clock(dev_p) ;
+
+ /* Register a callback to handle MISC requests from the firmware */
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_GENERAL_RQT_CONTEXT, my_misc_callback) ;
+
+ /* Now mark the DMA and low level modules as active. */
+ cy_as_device_set_dma_running(dev_p) ;
+ cy_as_device_set_low_level_running(dev_p) ;
+
+ /* Now, initialize the interrupt module */
+ dev_p->use_int_drq = config_p->dmaintr ;
+ ret = cy_as_intr_start(dev_p, config_p->dmaintr) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Mark the interface as initialized */
+ cy_as_device_set_configured(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+my_dma_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep,
+ void *mem_p,
+ uint32_t size,
+ cy_as_return_status_t ret
+ )
+{
+ cy_as_dma_end_point *ep_p ;
+
+ (void)size ;
+
+ /* Get the endpoint pointer based on the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, ep) ;
+
+ /* Check the queue to see if is drained */
+ if (ep_p->queue_p == 0) {
+ cy_as_func_c_b_node *node =
+ (cy_as_func_c_b_node *)dev_p->func_cbs_misc->head_p ;
+
+ cy_as_hal_assert(node) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ /*
+ * disable endpoint 2. the storage module
+ * will enable this EP if necessary.
+ */
+ cy_as_dma_enable_end_point(dev_p,
+ CY_AS_FIRMWARE_ENDPOINT,
+ cy_false, cy_as_direction_in) ;
+
+ /*
+ * clear the reset register. this releases the
+ * antioch micro-controller from reset and begins
+ * running the code at address zero.
+ */
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG, 0x00) ;
+ }
+
+ /* Call the user Callback */
+ node->cb_p((cy_as_device_handle)dev_p, ret, node->client_data,
+ node->data_type, node->data) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_misc) ;
+ } else {
+ /* This is the header data that was allocated in the
+ * download firmware function, and can be safely freed
+ * here. */
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(mem_p) ;
+ cy_as_hal_enable_interrupts(state) ;
+ }
+}
+
+cy_as_return_status_t
+cy_as_misc_download_firmware(cy_as_device_handle handle,
+ const void *mem_p,
+ uint16_t size,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ uint8_t *header ;
+ cy_as_return_status_t ret ;
+ cy_bool standby ;
+ cy_as_device *dev_p ;
+ cy_as_dma_callback dmacb = 0 ;
+ uint32_t state ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_download_firmware called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * if the device has not been initialized, we cannot download firmware
+ * to the device.
+ */
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ /*
+ * make sure west bridge is not in standby
+ */
+ ret = cy_as_misc_in_standby(dev_p, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (standby)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /*
+ * make sure we are in configuration mode
+ */
+ if ((cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_VM_SET) &
+ CY_AS_MEM_P0_VM_SET_CFGMODE) == 0)
+ return CY_AS_ERROR_NOT_IN_CONFIG_MODE ;
+
+ /* Maximum firmware size is 24k */
+ if (size > CY_AS_MAXIMUM_FIRMWARE_SIZE)
+ return CY_AS_ERROR_INVALID_SIZE ;
+
+ /* Make sure the size is an even number of bytes as well */
+ if (size & 0x01)
+ return CY_AS_ERROR_ALIGNMENT_ERROR ;
+
+ /*
+ * write the two word header that gives the base address and
+ * size of the firmware image to download
+ */
+ state = cy_as_hal_disable_interrupts() ;
+ header = (uint8_t *)cy_as_hal_c_b_alloc(4) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (header == NULL)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ header[0] = 0x00 ;
+ header[1] = 0x00 ;
+ header[2] = (uint8_t)(size & 0xff) ;
+ header[3] = (uint8_t)((size >> 8) & 0xff) ;
+
+ /* Enable the firmware endpoint */
+ ret = cy_as_dma_enable_end_point(dev_p, CY_AS_FIRMWARE_ENDPOINT,
+ cy_true, cy_as_direction_in) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * setup DMA for 64 byte packets. this is the requirement for downloading
+ * firmware to west bridge.
+ */
+ cy_as_dma_set_max_dma_size(dev_p, CY_AS_FIRMWARE_ENDPOINT, 64) ;
+
+ if (cb)
+ dmacb = my_dma_callback ;
+
+ ret = cy_as_dma_queue_request(dev_p, CY_AS_FIRMWARE_ENDPOINT, header,
+ 4, cy_false, cy_false, dmacb) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * write the firmware image to the west bridge device
+ */
+ ret = cy_as_dma_queue_request(dev_p, CY_AS_FIRMWARE_ENDPOINT,
+ (void *)mem_p, size, cy_false, cy_false, dmacb) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cb) {
+ cy_as_func_c_b_node *cbnode = cy_as_create_func_c_b_node_data(
+ cb, client, CY_FUNCT_CB_MISC_DOWNLOADFIRMWARE, 0) ;
+
+ if (cbnode == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ else
+ cy_as_insert_c_b_node(dev_p->func_cbs_misc, cbnode) ;
+
+ ret = cy_as_dma_kick_start(dev_p, CY_AS_FIRMWARE_ENDPOINT) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ } else {
+ ret = cy_as_dma_drain_queue(dev_p,
+ CY_AS_FIRMWARE_ENDPOINT, cy_true) ;
+
+ /* Free the header memory that was allocated earlier. */
+ cy_as_hal_c_b_free(header) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * disable EP 2. the storage module will
+ * enable this EP if necessary.
+ */
+ cy_as_dma_enable_end_point(dev_p, CY_AS_FIRMWARE_ENDPOINT,
+ cy_false, cy_as_direction_in) ;
+
+ /*
+ * clear the reset register. this releases the west bridge
+ * micro-controller from reset and begins running the code at
+ * address zero.
+ */
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG, 0x00) ;
+ }
+
+ /*
+ * the firmware is not marked as loaded until the firmware
+ * initializes west bridge and a request is sent from west bridge
+ * to the P port processor indicating that west bridge is ready.
+ */
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+
+static cy_as_return_status_t
+my_handle_response_get_firmware_version(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_get_firmware_version_data *data_p)
+{
+
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t val ;
+
+ if (cy_as_ll_request_response__get_code(reply_p)
+ != CY_RESP_FIRMWARE_VERSION) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ data_p->major = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ data_p->minor = cy_as_ll_request_response__get_word(reply_p, 1) ;
+ data_p->build = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ val = cy_as_ll_request_response__get_word(reply_p, 3) ;
+ data_p->media_type = (uint8_t)(((val >> 8) & 0xFF) | (val & 0xFF)) ;
+ val = cy_as_ll_request_response__get_word(reply_p, 4) ;
+ data_p->is_debug_mode = (cy_bool)(val & 0xFF) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_get_firmware_version(cy_as_device_handle handle,
+ cy_as_get_firmware_version_data *data,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_bool standby ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ cy_as_device *dev_p ;
+
+ (void)client ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_get_firmware_version called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /*
+ * make sure antioch is not in standby
+ */
+ ret = cy_as_misc_in_standby(dev_p, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ if (standby)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ /* Make sure the Antioch is not in suspend mode. */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_GET_FIRMWARE_VERSION,
+ CY_RQT_GENERAL_RQT_CONTEXT, 0) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*
+ * Reserve space for the reply, the reply data
+ * will not exceed three words
+ */
+ reply_p = cy_as_ll_create_response(dev_p, 5) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* Request and response are freed in
+ * MyHandleResponseGetFirmwareVersion. */
+ ret = my_handle_response_get_firmware_version(dev_p,
+ req_p, reply_p, data) ;
+ return ret ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_GETFIRMWAREVERSION, data,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+static cy_as_return_status_t
+my_handle_response_read_m_c_u_register(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ uint8_t *data_p)
+{
+
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p)
+ != CY_RESP_MCU_REGISTER_DATA) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ *data_p = (uint8_t)
+ (cy_as_ll_request_response__get_word(reply_p, 0)) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_get_gpio_value(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ uint8_t *data_p)
+{
+
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p)
+ != CY_RESP_GPIO_STATE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ } else
+ *data_p = (uint8_t)
+ (cy_as_ll_request_response__get_word(reply_p, 0)) ;
+
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+
+cy_as_return_status_t cy_as_misc_set_sd_power_polarity(
+ cy_as_device_handle handle,
+ cy_as_misc_signal_polarity polarity,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SDPOLARITY,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)polarity) ;
+
+ /*
+ * Reserve space for the reply, the reply data will
+ * not exceed one word
+ */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return (my_handle_response_no_data(dev_p, req_p, reply_p)) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_SETSDPOLARITY, 0, dev_p->func_cbs_misc,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the FuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_misc_read_m_c_u_register(cy_as_device_handle handle,
+ uint16_t address,
+ uint8_t *value,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_read_m_c_u_register called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /* Check whether the firmware supports this command. */
+ if (cy_as_device_is_nand_storage_supported(dev_p))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ /* Make sure the Antioch is not in suspend mode. */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_READ_MCU_REGISTER,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, (uint16_t)address) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_MCU_REGISTER_DATA) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ *value = (uint8_t)(cy_as_ll_request_response__get_word
+ (reply_p, 0)) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_READMCUREGISTER, value,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_misc_write_m_c_u_register(cy_as_device_handle handle,
+ uint16_t address,
+ uint8_t mask,
+ uint8_t value,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_write_m_c_u_register called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /* Check whether the firmware supports this command. */
+ if (cy_as_device_is_nand_storage_supported(dev_p))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ /* Make sure the Antioch is not in suspend mode. */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_WRITE_MCU_REGISTER,
+ CY_RQT_GENERAL_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, (uint16_t)address) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((mask << 8) | value)) ;
+
+ /*
+ * Reserve space for the reply, the reply data
+ * will not exceed one word
+ */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_WRITEMCUREGISTER, 0,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /*
+ * The request and response are freed as part of the
+ * MiscFuncCallback
+ */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+my_handle_response_reset(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_reset_type type)
+{
+ uint16_t v ;
+
+ (void)req_p ;
+ (void)reply_p ;
+
+ /*
+ * if the device is in suspend mode, it needs to be woken up
+ * so that the write to the reset control register succeeds.
+ * we need not however wait for the wake up procedure to be
+ * complete.
+ */
+ if (cy_as_device_is_in_suspend_mode(dev_p)) {
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+ cy_as_hal_sleep(1) ;
+ }
+
+ if (type == cy_as_reset_hard) {
+ cy_as_misc_cancel_ex_requests(dev_p) ;
+ cy_as_hal_write_register(dev_p->tag, CY_AS_MEM_RST_CTRL_REG,
+ CY_AS_MEM_RST_CTRL_REG_HARD) ;
+ cy_as_device_set_unconfigured(dev_p) ;
+ cy_as_device_set_firmware_not_loaded(dev_p) ;
+ cy_as_device_set_dma_stopped(dev_p) ;
+ cy_as_device_set_low_level_stopped(dev_p) ;
+ cy_as_device_set_intr_stopped(dev_p) ;
+ cy_as_device_clear_suspend_mode(dev_p) ;
+ cy_as_usb_cleanup(dev_p) ;
+ cy_as_storage_cleanup(dev_p) ;
+
+ /*
+ * wait for a small amount of time to
+ * allow reset to be complete.
+ */
+ cy_as_hal_sleep(100) ;
+ }
+
+ cy_as_device_clear_reset_pending(dev_p) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_misc_reset(cy_as_device_handle handle,
+ cy_as_reset_type type,
+ cy_bool flush,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ cy_as_end_point_number_t i ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ (void)client ;
+ (void)cb ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_reset_e_x called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /*
+ * soft reset is not supported until we close on the issues
+ * in the firmware with what needs to happen.
+ */
+ if (type == cy_as_reset_soft)
+ return CY_AS_ERROR_NOT_YET_SUPPORTED ;
+
+ cy_as_device_set_reset_pending(dev_p) ;
+
+ if (flush) {
+ /* Unable to DrainQueues in polling mode */
+ if ((dev_p->storage_cb || dev_p->storage_cb_ms) &&
+ cy_as_hal_is_polling())
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ /*
+ * shutdown the endpoints so no more traffic can be queued
+ */
+ for (i = 0; i < 15; i++)
+ cy_as_dma_enable_end_point(dev_p, i, cy_false,
+ cy_as_direction_dont_change) ;
+
+ /*
+ * if we are in normal mode, drain all traffic across all
+ * endpoints to be sure all traffic is flushed. if the
+ * device is suspended, data will not be coming in on any
+ * endpoint and all outstanding DMA operations can be
+ * cancelled.
+ */
+ if (cy_as_device_is_in_suspend_mode(dev_p)) {
+ for (i = 0; i < 15; i++)
+ cy_as_dma_cancel(dev_p, i,
+ CY_AS_ERROR_CANCELED) ;
+ } else {
+ for (i = 0; i < 15; i++) {
+ if ((i == CY_AS_P2S_WRITE_ENDPOINT) ||
+ (i == CY_AS_P2S_READ_ENDPOINT))
+ cy_as_dma_drain_queue(dev_p, i,
+ cy_false) ;
+ else
+ cy_as_dma_drain_queue(dev_p, i,
+ cy_true) ;
+ }
+ }
+ } else {
+ /* No flush was requested, so cancel any outstanding DMAs
+ * so the user callbacks are called as needed
+ */
+ if (cy_as_device_is_storage_async_pending(dev_p)) {
+ for (i = 0; i < 15; i++)
+ cy_as_dma_cancel(dev_p, i,
+ CY_AS_ERROR_CANCELED) ;
+ }
+ }
+
+ ret = my_handle_response_reset(dev_p, 0, 0, type) ;
+
+ if (cb)
+ /* Even though no mailbox communication was needed,
+ * issue the callback so the user does not need to
+ * special case their code. */
+ cb((cy_as_device_handle)dev_p, ret, client,
+ CY_FUNCT_CB_MISC_RESET, 0) ;
+
+ /*
+ * initialize any registers that may have been
+ * changed when the device was reset.
+ */
+ cy_as_hal_init_dev_registers(dev_p->tag, cy_false) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+get_unallocated_resource(cy_as_device *dev_p, cy_as_resource_type resource)
+{
+ uint8_t shift = 0 ;
+ uint16_t v ;
+ cy_as_return_status_t ret = CY_AS_ERROR_NOT_ACQUIRED ;
+
+ switch (resource) {
+ case cy_as_bus_u_s_b:
+ shift = 4 ;
+ break ;
+ case cy_as_bus_1:
+ shift = 0 ;
+ break ;
+ case cy_as_bus_0:
+ shift = 2 ;
+ break ;
+ default:
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /* Get the semaphore value for this resource */
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_RSE_ALLOCATE) ;
+ v = (v >> shift) & 0x03 ;
+
+ if (v == 0x03) {
+ ret = CY_AS_ERROR_RESOURCE_ALREADY_OWNED ;
+ } else if ((v & 0x01) == 0) {
+ /* The resource is not owned by anyone, we can try to get it */
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_MASK, (0x03 << shift)) ;
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_RSE_MASK) ;
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_ALLOCATE, (0x01 << shift)) ;
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_P0_RSE_MASK) ;
+
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_ALLOCATE) ;
+ v = (v >> shift) & 0x03 ;
+ if (v == 0x03)
+ ret = CY_AS_ERROR_SUCCESS ;
+ }
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_acquire_resource(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_resource_type *resource)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ ret = get_unallocated_resource(dev_p, *resource) ;
+ if (ret != CY_AS_ERROR_NOT_ACQUIRED)
+ ret = CY_AS_ERROR_SUCCESS ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_acquire_resource(cy_as_device_handle handle,
+ cy_as_resource_type *resource,
+ cy_bool force,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret ;
+
+ cy_as_device *dev_p ;
+
+ (void)client ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_acquire_resource called") ;
+
+ if (*resource != cy_as_bus_u_s_b && *resource !=
+ cy_as_bus_0 && *resource != cy_as_bus_1)
+ return CY_AS_ERROR_INVALID_RESOURCE ;
+
+
+ /* Make sure the device is ready to accept the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+
+ ret = get_unallocated_resource(dev_p, *resource) ;
+
+ /*
+ * make sure that the callback is called if the resource is
+ * successfully acquired at this point.
+ */
+ if ((ret == CY_AS_ERROR_SUCCESS) && (cb != 0))
+ cb(handle, ret, client,
+ CY_FUNCT_CB_MISC_ACQUIRERESOURCE, resource) ;
+
+ if (ret != CY_AS_ERROR_NOT_ACQUIRED)
+ return ret ;
+
+ if (!force)
+ return CY_AS_ERROR_NOT_ACQUIRED ;
+
+ /* Create the request to acquire the resource */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_ACQUIRE_RESOURCE,
+ CY_RQT_RESOURCE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, (uint16_t)(*resource)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_ACQUIRERESOURCE, resource,
+ dev_p->func_cbs_res, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ ret = get_unallocated_resource(dev_p, *resource) ;
+ if (ret != CY_AS_ERROR_NOT_ACQUIRED)
+ ret = CY_AS_ERROR_SUCCESS ;
+ }
+
+ return ret ;
+}
+cy_as_return_status_t
+cy_as_misc_release_resource(cy_as_device_handle handle,
+ cy_as_resource_type resource)
+{
+ uint8_t shift = 0 ;
+ uint16_t v ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_release_resource called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (resource != cy_as_bus_u_s_b && resource !=
+ cy_as_bus_0 && resource != cy_as_bus_1)
+ return CY_AS_ERROR_INVALID_RESOURCE ;
+
+ switch (resource) {
+ case cy_as_bus_u_s_b:
+ shift = 4 ;
+ break ;
+ case cy_as_bus_1:
+ shift = 0 ;
+ break ;
+ case cy_as_bus_0:
+ shift = 2 ;
+ break ;
+ default:
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /* Get the semaphore value for this resource */
+ v = (cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_ALLOCATE) >> shift) & 0x03 ;
+ if (v == 0 || v == 1 || v == 2)
+ return CY_AS_ERROR_RESOURCE_NOT_OWNED ;
+
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_MASK, (0x03 << shift)) ;
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_ALLOCATE, (0x02 << shift)) ;
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_P0_RSE_MASK, 0) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_misc_set_trace_level(cy_as_device_handle handle,
+ uint8_t level,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint32_t unit,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_set_trace_level called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (unit > 255)
+ return CY_AS_ERROR_NO_SUCH_UNIT ;
+
+ if (level >= CYAS_FW_TRACE_MAX_LEVEL)
+ return CY_AS_ERROR_INVALID_TRACE_LEVEL ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SET_TRACE_LEVEL,
+ CY_RQT_GENERAL_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)level) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((bus << 12) | (device << 8) | (unit))) ;
+
+ /*
+ * Reserve space for the reply, the reply data will not
+ * exceed three words
+ */
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_NOT_SUPPORTED ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_SETTRACELEVEL, 0, dev_p->func_cbs_misc,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_heart_beat_control(cy_as_device_handle handle,
+ cy_bool enable,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_heart_beat_control called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_CONTROL_ANTIOCH_HEARTBEAT,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, (uint16_t)enable) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_HEARTBEATCONTROL, 0,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_set_sd_clock_freq(
+ cy_as_device *dev_p,
+ uint8_t card_type,
+ uint8_t setting,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ if (cy_as_device_is_in_callback(dev_p) && (cb == 0))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SET_SD_CLOCK_FREQ,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((card_type << 8) | setting)) ;
+
+ /* Reserve space for the reply, which will not exceed one word. */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_SETSDFREQ, 0, dev_p->func_cbs_misc,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_set_low_speed_sd_freq(
+ cy_as_device_handle handle,
+ cy_as_low_speed_sd_freq setting,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_set_low_speed_sd_freq called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if ((setting != CY_AS_SD_DEFAULT_FREQ) &&
+ (setting != CY_AS_SD_RATED_FREQ))
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ return my_set_sd_clock_freq(dev_p, 0, (uint8_t)setting, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_misc_set_high_speed_sd_freq(
+ cy_as_device_handle handle,
+ cy_as_high_speed_sd_freq setting,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_set_high_speed_sd_freq called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if ((setting != CY_AS_HS_SD_FREQ_24) &&
+ (setting != CY_AS_HS_SD_FREQ_48))
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ return my_set_sd_clock_freq(dev_p, 1, (uint8_t)setting, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_misc_get_gpio_value(cy_as_device_handle handle,
+ cy_as_misc_gpio pin,
+ uint8_t *value,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_device *dev_p ;
+ uint16_t v ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_get_gpio_value called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /* If the pin specified is UVALID, there is no need
+ * for firmware to be loaded. */
+ if (pin == cy_as_misc_gpio_U_valid) {
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_PMU_UPDATE) ;
+ *value = (uint8_t)(v & CY_AS_MEM_PMU_UPDATE_UVALID) ;
+
+ if (cb != 0)
+ cb(dev_p, ret, client,
+ CY_FUNCT_CB_MISC_GETGPIOVALUE, value) ;
+
+ return ret ;
+ }
+
+ /* Check whether the firmware supports this command. */
+ if (cy_as_device_is_nand_storage_supported(dev_p))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Make sure the pin selected is valid */
+ if ((pin != cy_as_misc_gpio_1) && (pin != cy_as_misc_gpio_0))
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_GET_GPIO_STATE,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, ((uint8_t)pin << 8)) ;
+
+ /* Reserve space for the reply, which will not exceed one word. */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_GPIO_STATE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ *value = (uint8_t)
+ cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_GETGPIOVALUE, value,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_misc_set_gpio_value(cy_as_device_handle handle,
+ cy_as_misc_gpio pin,
+ uint8_t value,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_device *dev_p ;
+ uint16_t v ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_set_gpio_value called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /* If the pin specified is UVALID, there is
+ * no need for firmware to be loaded. */
+ if (pin == cy_as_misc_gpio_U_valid) {
+ v = cy_as_hal_read_register(dev_p->tag, CY_AS_MEM_PMU_UPDATE) ;
+ if (value)
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_PMU_UPDATE,
+ (v | CY_AS_MEM_PMU_UPDATE_UVALID)) ;
+ else
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_PMU_UPDATE,
+ (v & ~CY_AS_MEM_PMU_UPDATE_UVALID)) ;
+
+ if (cb != 0)
+ cb(dev_p, ret, client,
+ CY_FUNCT_CB_MISC_SETGPIOVALUE, 0) ;
+ return ret ;
+ }
+
+ /* Check whether the firmware supports this command. */
+ if (cy_as_device_is_nand_storage_supported(dev_p))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Make sure the pin selected is valid */
+ if ((pin < cy_as_misc_gpio_0) || (pin > cy_as_misc_gpio_U_valid))
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ /* Create and initialize the low level request to the firmware. */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SET_GPIO_STATE,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ v = (uint16_t)(((uint8_t)pin << 8) | (value > 0)) ;
+ cy_as_ll_request_response__set_word(req_p, 0, v) ;
+
+ /* Reserve space for the reply, which will not exceed one word. */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_SETGPIOVALUE, 0,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_enter_standby(cy_as_device *dev_p, cy_bool pin)
+{
+ cy_as_misc_cancel_ex_requests(dev_p) ;
+
+ /* Save the current values in the critical P-port
+ * registers, where necessary. */
+ cy_as_hal_read_regs_before_standby(dev_p->tag) ;
+
+ if (pin) {
+ if (cy_as_hal_set_wakeup_pin(dev_p->tag, cy_false))
+ cy_as_device_set_pin_standby(dev_p) ;
+ else
+ return CY_AS_ERROR_SETTING_WAKEUP_PIN ;
+ } else {
+ /*
+ * put antioch in the standby mode
+ */
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_PWR_MAGT_STAT, 0x02) ;
+ cy_as_device_set_register_standby(dev_p) ;
+ }
+
+ /*
+ * when the antioch comes out of standby, we have to wait until
+ * the firmware initialization completes before sending other
+ * requests down.
+ */
+ cy_as_device_set_firmware_not_loaded(dev_p) ;
+
+ /*
+ * keep west bridge interrupt disabled until the device is being woken
+ * up from standby.
+ */
+ dev_p->stby_int_mask = cy_as_hal_disable_interrupts();
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static cy_as_return_status_t
+my_handle_response_enter_standby(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_bool pin)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ ret = my_enter_standby(dev_p, pin) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_enter_standby(cy_as_device_handle handle,
+ cy_bool pin,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_bool standby ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_enter_standby called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * if we already are in standby, do not do it again and let the
+ * user know via the error return.
+ */
+ ret = cy_as_misc_in_standby(handle, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (standby == cy_true)
+ return CY_AS_ERROR_ALREADY_STANDBY ;
+
+ /*
+ * if the user wants to transition from suspend mode to standby mode,
+ * the device needs to be woken up so that it can complete all pending
+ * operations.
+ */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ cy_as_misc_leave_suspend(dev_p, 0, 0) ;
+
+ if (dev_p->usb_count) {
+ /*
+ * we do not allow west bridge to go into standby mode when the
+ * USB stack is initialized. you must stop the USB stack in
+ * order to enter standby mode.
+ */
+ return CY_AS_ERROR_USB_RUNNING ;
+ }
+
+ /*
+ * if the storage stack is not running, the device can directly be
+ * put into sleep mode. otherwise, the firmware needs to be signaled
+ * to prepare for going into sleep mode.
+ */
+ if (dev_p->storage_count) {
+ /*
+ * if there are async storage operations pending,
+ * make one attempt to complete them.
+ */
+ if (cy_as_device_is_storage_async_pending(dev_p)) {
+ /* DrainQueue will not work in polling mode */
+ if (cy_as_hal_is_polling())
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ cy_as_dma_drain_queue(dev_p,
+ CY_AS_P2S_READ_ENDPOINT, cy_false) ;
+ cy_as_dma_drain_queue(dev_p,
+ CY_AS_P2S_WRITE_ENDPOINT, cy_false) ;
+
+ /*
+ * if more storage operations were queued
+ * at this stage, return an error.
+ */
+ if (cy_as_device_is_storage_async_pending(dev_p))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_PREPARE_FOR_STANDBY,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (!cb) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * in the HandleResponse */
+ return my_handle_response_enter_standby(dev_p,
+ req_p, reply_p, pin) ;
+
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_ENTERSTANDBY, (void *)pin,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else {
+ ret = my_enter_standby(dev_p, pin) ;
+ if (cb)
+ /* Even though no mailbox communication was
+ * needed, issue the callback so the user
+ * does not need to special case their code. */
+ cb((cy_as_device_handle)dev_p, ret, client,
+ CY_FUNCT_CB_MISC_ENTERSTANDBY, 0) ;
+ }
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_enter_standby_e_x_u(cy_as_device_handle handle,
+ cy_bool pin,
+ cy_bool uvalid_special,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (uvalid_special)
+ cy_as_hal_write_register(dev_p->tag, 0xc5, 0x4) ;
+
+ return cy_as_misc_enter_standby(handle, pin, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_misc_leave_standby(cy_as_device_handle handle,
+ cy_as_resource_type resource)
+{
+ cy_as_device *dev_p ;
+ uint16_t v ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint32_t count = 8 ;
+ uint8_t retry = 1 ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_leave_standby called") ;
+ (void)resource ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (cy_as_device_is_register_standby(dev_p)) {
+ /*
+ * set a flag to indicate that the west bridge is waking
+ * up from standby.
+ */
+ cy_as_device_set_waking(dev_p) ;
+
+ /*
+ * the initial read will not succeed, but will just wake
+ * the west bridge device from standby. successive reads
+ * should succeed and in that way we know west bridge is awake.
+ */
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+
+ do {
+ /*
+ * we have initiated the operation to leave standby, now
+ * we need to wait at least N ms before trying to access
+ * the west bridge device to insure the PLLs have locked
+ * and we can talk to the device.
+ */
+ if (cy_as_device_is_crystal(dev_p))
+ cy_as_hal_sleep(
+ CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL) ;
+ else
+ cy_as_hal_sleep(
+ CY_AS_LEAVE_STANDBY_DELAY_CLOCK) ;
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+
+ /*
+ * if the P-SPI interface mode is in use, there may be a
+ * need to re-synchronise the serial clock used for
+ * astoria access.
+ */
+ if (!is_valid_silicon_id(v)) {
+ if (cy_as_hal_sync_device_clocks(dev_p->tag) !=
+ cy_true) {
+ cy_as_hal_enable_interrupts(
+ dev_p->stby_int_mask) ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+ }
+ } while (!is_valid_silicon_id(v) && count-- > 0) ;
+
+ /*
+ * if we tried to read the register and could not,
+ * return a timeout
+ */
+ if (count == 0) {
+ cy_as_hal_enable_interrupts(
+ dev_p->stby_int_mask) ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+
+ /*
+ * the standby flag is cleared here, after the action to
+ * exit standby has been taken. the wait for firmware
+ * initialization, is ensured by marking the firmware as
+ * not loaded until the init event is received.
+ */
+ cy_as_device_clear_register_standby(dev_p) ;
+
+ /*
+ * initialize any registers that may have been changed
+ * while the device was in standby mode.
+ */
+ cy_as_hal_init_dev_registers(dev_p->tag, cy_true) ;
+ } else if (cy_as_device_is_pin_standby(dev_p)) {
+ /*
+ * set a flag to indicate that the west bridge is waking
+ * up from standby.
+ */
+ cy_as_device_set_waking(dev_p) ;
+
+try_wakeup_again:
+ /*
+ * try to set the wakeup pin, if this fails in the HAL
+ * layer, return this failure to the user.
+ */
+ if (!cy_as_hal_set_wakeup_pin(dev_p->tag, cy_true)) {
+ cy_as_hal_enable_interrupts(dev_p->stby_int_mask) ;
+ return CY_AS_ERROR_SETTING_WAKEUP_PIN ;
+ }
+
+ /*
+ * we have initiated the operation to leave standby, now
+ * we need to wait at least N ms before trying to access
+ * the west bridge device to insure the PL_ls have locked
+ * and we can talk to the device.
+ */
+ if (cy_as_device_is_crystal(dev_p))
+ cy_as_hal_sleep(CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL) ;
+ else
+ cy_as_hal_sleep(CY_AS_LEAVE_STANDBY_DELAY_CLOCK) ;
+
+ /*
+ * initialize any registers that may have been changed
+ * while the device was in standby mode.
+ */
+ cy_as_hal_init_dev_registers(dev_p->tag, cy_true) ;
+
+ /*
+ * the standby flag is cleared here, after the action to
+ * exit standby has been taken. the wait for firmware
+ * initialization, is ensured by marking the firmware as
+ * not loaded until the init event is received.
+ */
+ cy_as_device_clear_pin_standby(dev_p) ;
+ } else {
+ return CY_AS_ERROR_NOT_IN_STANDBY ;
+ }
+
+ /*
+ * the west bridge interrupt can be enabled now.
+ */
+ cy_as_hal_enable_interrupts(dev_p->stby_int_mask) ;
+
+ /*
+ * release the west bridge micro-_controller from reset,
+ * so that firmware initialization can complete. the attempt
+ * to release antioch reset is made upto 8 times.
+ */
+ v = 0x03 ;
+ count = 0x08 ;
+ while ((v & 0x03) && (count)) {
+ cy_as_hal_write_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG, 0x00) ;
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_RST_CTRL_REG) ;
+ count-- ;
+ }
+
+ if (v & 0x03) {
+ cy_as_hal_print_message("failed to clear antioch reset\n") ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+
+ /*
+ * if the wake-up pin is being used, wait here to make
+ * sure that the wake-up event is received within a
+ * reasonable delay. otherwise, toggle the wake-up pin
+ * again in an attempt to start the firmware properly.
+ */
+ if (retry) {
+ count = 10 ;
+ while (count) {
+ /* If the wake-up event has been received,
+ * we can return. */
+ if (cy_as_device_is_firmware_loaded(dev_p))
+ break ;
+ /* If we are in polling mode, the interrupt may
+ * not have been serviced as yet. read the
+ * interrupt status register. if a pending mailbox
+ * interrupt is seen, we can assume that the
+ * wake-up event will be received soon. */
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_P0_INTR_REG) ;
+ if (v & CY_AS_MEM_P0_INTR_REG_MBINT)
+ break ;
+
+ cy_as_hal_sleep(10) ;
+ count-- ;
+ }
+
+ if (!count) {
+ retry = 0 ;
+ dev_p->stby_int_mask = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_set_wakeup_pin(dev_p->tag, cy_false) ;
+ cy_as_hal_sleep(10) ;
+ goto try_wakeup_again ;
+ }
+ }
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_register_callback(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The function to call */
+ cy_as_misc_event_callback callback
+ )
+{
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_register_callback called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ dev_p->misc_event_cb = callback ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_misc_storage_changed(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_bool standby ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_storage_changed called") ;
+
+ /* Make sure the device is ready for the command. */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /*
+ * make sure antioch is not in standby
+ */
+ ret = cy_as_misc_in_standby(dev_p, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (standby)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ /*
+ * make sure westbridge is not in suspend mode.
+ */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_STORAGE_MEDIA_CHANGED,
+ CY_RQT_GENERAL_RQT_CONTEXT, 0) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_STORAGECHANGED, 0,
+ dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_misc_enter_suspend(
+ cy_as_device_handle handle,
+ cy_bool usb_wakeup_en,
+ cy_bool gpio_wakeup_en,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_bool standby ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ uint16_t value ;
+ uint32_t int_state ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_enter_suspend called") ;
+
+ /*
+ * basic sanity checks to ensure that the device is initialised.
+ */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /*
+ * make sure west bridge is not already in standby
+ */
+ cy_as_misc_in_standby(dev_p, &standby) ;
+ if (standby)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ /*
+ * make sure that the device is not already in suspend mode.
+ */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /*
+ * make sure there is no active USB connection.
+ */
+ if ((cy_as_device_is_usb_connected(dev_p)) && (dev_p->usb_last_event
+ != cy_as_event_usb_suspend))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ /*
+ * make sure that there are no async requests at this point in time.
+ */
+ int_state = cy_as_hal_disable_interrupts() ;
+ if ((dev_p->func_cbs_misc->count) || (dev_p->func_cbs_res->count) ||
+ (dev_p->func_cbs_stor->count) || (dev_p->func_cbs_usb->count)) {
+ cy_as_hal_enable_interrupts(int_state) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+ cy_as_hal_enable_interrupts(int_state) ;
+
+ /* Create the request to send to the Antioch device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_ENTER_SUSPEND_MODE,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply data will not
+ * exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Wakeup control flags. */
+ value = 0x0001 ;
+ if (usb_wakeup_en)
+ value |= 0x04 ;
+ if (gpio_wakeup_en)
+ value |= 0x02 ;
+ cy_as_ll_request_response__set_word(req_p, 0, value) ;
+
+ if (cb != 0) {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_ENTERSUSPEND,
+ 0, dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p,
+ cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return CY_AS_ERROR_SUCCESS ;
+ } else {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ }
+
+destroy:
+ if (ret == CY_AS_ERROR_SUCCESS)
+ cy_as_device_set_suspend_mode(dev_p) ;
+
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_leave_suspend(
+ cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ uint16_t v, count ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_leave_suspend called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /* Make sure we are in suspend mode. */
+ if (cy_as_device_is_in_suspend_mode(dev_p)) {
+ if (cb) {
+ cy_as_func_c_b_node *cbnode =
+ cy_as_create_func_c_b_node_data(cb, client,
+ CY_FUNCT_CB_MISC_LEAVESUSPEND, 0) ;
+ if (cbnode == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_insert_c_b_node(dev_p->func_cbs_misc, cbnode) ;
+ }
+
+ /*
+ * do a read from the ID register so that the CE assertion
+ * will wake west bridge. the read is repeated until the
+ * read comes back with valid data.
+ */
+ count = 8 ;
+
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+
+ while (!is_valid_silicon_id(v) && count-- > 0) {
+ cy_as_hal_sleep(CY_AS_LEAVE_STANDBY_DELAY_CLOCK) ;
+ v = cy_as_hal_read_register(dev_p->tag,
+ CY_AS_MEM_CM_WB_CFG_ID) ;
+ }
+
+ /*
+ * if we tried to read the register and could not,
+ * return a timeout
+ */
+ if (count == 0)
+ return CY_AS_ERROR_TIMEOUT ;
+ } else
+ return CY_AS_ERROR_NOT_IN_SUSPEND ;
+
+ if (cb == 0) {
+ /*
+ * wait until the in suspend mode flag is cleared.
+ */
+ count = 20 ;
+ while ((cy_as_device_is_in_suspend_mode(dev_p))
+ && (count--)) {
+ cy_as_hal_sleep(CY_AS_LEAVE_STANDBY_DELAY_CLOCK) ;
+ }
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ ret = CY_AS_ERROR_TIMEOUT ;
+ }
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_misc_reserve_l_n_a_boot_area(cy_as_device_handle handle,
+ uint8_t numzones,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_bool standby ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ cy_as_device *dev_p ;
+
+ (void)client ;
+
+ cy_as_log_debug_message(6, "cy_as_misc_switch_pnand_mode called") ;
+
+ /* Make sure we have a valid device */
+ dev_p = (cy_as_device *)handle ;
+ cy_as_check_device_ready(dev_p) ;
+
+ /*
+ * make sure antioch is not in standby
+ */
+ ret = cy_as_misc_in_standby(dev_p, &standby) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ if (standby)
+ return CY_AS_ERROR_IN_STANDBY ;
+
+ /* Make sure the Antioch is not in suspend mode. */
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_RESERVE_LNA_BOOT_AREA,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ cy_as_ll_request_response__set_word(req_p,
+ 0, (uint16_t)numzones) ;
+
+ /* Reserve space for the reply, the reply data will not
+ * exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MISC_RESERVELNABOOTAREA,
+ 0, dev_p->func_cbs_misc, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_misc_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_func_c_b_node*
+cy_as_create_func_c_b_node_data(cy_as_function_callback cb,
+ uint32_t client,
+ cy_as_funct_c_b_type type,
+ void *data)
+{
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_func_c_b_node *node = cy_as_hal_c_b_alloc(
+ sizeof(cy_as_func_c_b_node)) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (node != 0) {
+ node->node_type = CYAS_FUNC_CB ;
+ node->cb_p = cb ;
+ node->client_data = client ;
+ node->data_type = type ;
+ if (data != 0)
+ node->data_type |= CY_FUNCT_CB_DATA ;
+ else
+ node->data_type |= CY_FUNCT_CB_NODATA ;
+ node->data = data ;
+ node->next_p = 0 ;
+ }
+ return node ;
+}
+
+cy_as_func_c_b_node*
+cy_as_create_func_c_b_node(cy_as_function_callback cb,
+ uint32_t client)
+{
+ return cy_as_create_func_c_b_node_data(cb, client,
+ CY_FUNCT_CB_NODATA, 0) ;
+}
+
+void
+cy_as_destroy_func_c_b_node(cy_as_func_c_b_node *node)
+{
+ uint32_t state ;
+
+ node->node_type = CYAS_INVALID ;
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+cy_as_usb_func_c_b_node*
+cy_as_create_usb_func_c_b_node(
+ cy_as_usb_function_callback cb, uint32_t client)
+{
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_usb_func_c_b_node *node = cy_as_hal_c_b_alloc(
+ sizeof(cy_as_usb_func_c_b_node)) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (node != 0) {
+ node->type = CYAS_USB_FUNC_CB ;
+ node->cb_p = cb ;
+ node->client_data = client ;
+ node->next_p = 0 ;
+ }
+ return node ;
+}
+
+void
+cy_as_destroy_usb_func_c_b_node(cy_as_usb_func_c_b_node *node)
+{
+ uint32_t state ;
+
+ node->type = CYAS_INVALID ;
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+cy_as_usb_io_c_b_node*
+cy_as_create_usb_io_c_b_node(cy_as_usb_io_callback cb)
+{
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_usb_io_c_b_node *node = cy_as_hal_c_b_alloc(
+ sizeof(cy_as_usb_io_c_b_node)) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (node != 0) {
+ node->type = CYAS_USB_IO_CB ;
+ node->cb_p = cb ;
+ node->next_p = 0 ;
+ }
+ return node ;
+}
+
+void
+cy_as_destroy_usb_io_c_b_node(cy_as_usb_io_c_b_node *node)
+{
+ uint32_t state ;
+
+ node->type = CYAS_INVALID ;
+
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+cy_as_storage_io_c_b_node*
+cy_as_create_storage_io_c_b_node(cy_as_storage_callback cb,
+ cy_as_media_type media, uint32_t device_index,
+ uint32_t unit, uint32_t block_addr, cy_as_oper_type oper,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_storage_io_c_b_node *node = cy_as_hal_c_b_alloc(
+ sizeof(cy_as_storage_io_c_b_node)) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (node != 0) {
+ node->type = CYAS_STORAGE_IO_CB ;
+ node->cb_p = cb ;
+ node->media = media ;
+ node->device_index = device_index ;
+ node->unit = unit ;
+ node->block_addr = block_addr ;
+ node->oper = oper ;
+ node->req_p = req_p ;
+ node->reply_p = reply_p ;
+ node->next_p = 0 ;
+ }
+ return node ;
+}
+
+void
+cy_as_destroy_storage_io_c_b_node(cy_as_storage_io_c_b_node *node)
+{
+ uint32_t state ;
+ node->type = CYAS_INVALID ;
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(node) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+cy_as_c_b_queue *
+cy_as_create_c_b_queue(cy_as_c_b_node_type type)
+{
+ uint32_t state = cy_as_hal_disable_interrupts() ;
+ cy_as_c_b_queue *queue = cy_as_hal_c_b_alloc(
+ sizeof(cy_as_c_b_queue)) ;
+ cy_as_hal_enable_interrupts(state) ;
+ if (queue) {
+ queue->type = type ;
+ queue->head_p = 0 ;
+ queue->tail_p = 0 ;
+ queue->count = 0 ;
+ }
+
+ return queue ;
+}
+
+void
+cy_as_destroy_c_b_queue(cy_as_c_b_queue *queue)
+{
+ uint32_t state ;
+ queue->type = CYAS_INVALID ;
+ queue->head_p = 0 ;
+ queue->tail_p = 0 ;
+ queue->count = 0 ;
+ state = cy_as_hal_disable_interrupts() ;
+ cy_as_hal_c_b_free(queue) ;
+ cy_as_hal_enable_interrupts(state) ;
+}
+
+/* Inserts a CyAsCBNode into the queue, the
+ * node type must match the queue type*/
+void
+cy_as_insert_c_b_node(cy_as_c_b_queue *queue_p, void*cbnode)
+{
+ uint32_t int_state ;
+
+ int_state = cy_as_hal_disable_interrupts() ;
+
+ cy_as_hal_assert(queue_p != 0) ;
+
+ switch (queue_p->type) {
+ case CYAS_USB_FUNC_CB:
+ {
+ cy_as_usb_func_c_b_node *node =
+ (cy_as_usb_func_c_b_node *)cbnode ;
+ cy_as_usb_func_c_b_node *tail =
+ (cy_as_usb_func_c_b_node *)queue_p->tail_p ;
+
+ cy_as_hal_assert(node->type == CYAS_USB_FUNC_CB) ;
+ cy_as_hal_assert(tail == 0 ||
+ tail->type == CYAS_USB_FUNC_CB) ;
+ if (queue_p->head_p == 0)
+ queue_p->head_p = node ;
+ else
+ tail->next_p = node ;
+
+ queue_p->tail_p = node ;
+ }
+ break ;
+
+ case CYAS_USB_IO_CB:
+ {
+ cy_as_usb_io_c_b_node *node =
+ (cy_as_usb_io_c_b_node *)cbnode ;
+ cy_as_usb_io_c_b_node *tail =
+ (cy_as_usb_io_c_b_node *)queue_p->tail_p ;
+
+ cy_as_hal_assert(node->type == CYAS_USB_IO_CB) ;
+ cy_as_hal_assert(tail == 0 ||
+ tail->type == CYAS_USB_IO_CB) ;
+ if (queue_p->head_p == 0)
+ queue_p->head_p = node ;
+ else
+ tail->next_p = node ;
+
+ queue_p->tail_p = node ;
+ }
+ break ;
+
+ case CYAS_STORAGE_IO_CB:
+ {
+ cy_as_storage_io_c_b_node *node =
+ (cy_as_storage_io_c_b_node *)cbnode ;
+ cy_as_storage_io_c_b_node *tail =
+ (cy_as_storage_io_c_b_node *)queue_p->tail_p ;
+
+ cy_as_hal_assert(node->type == CYAS_STORAGE_IO_CB) ;
+ cy_as_hal_assert(tail == 0 ||
+ tail->type == CYAS_STORAGE_IO_CB) ;
+ if (queue_p->head_p == 0)
+ queue_p->head_p = node ;
+ else
+ tail->next_p = node ;
+
+ queue_p->tail_p = node ;
+ }
+ break ;
+
+ case CYAS_FUNC_CB:
+ {
+ cy_as_func_c_b_node *node =
+ (cy_as_func_c_b_node *)cbnode ;
+ cy_as_func_c_b_node *tail =
+ (cy_as_func_c_b_node *)queue_p->tail_p ;
+
+ cy_as_hal_assert(node->node_type == CYAS_FUNC_CB) ;
+ cy_as_hal_assert(tail == 0 ||
+ tail->node_type == CYAS_FUNC_CB) ;
+ if (queue_p->head_p == 0)
+ queue_p->head_p = node ;
+ else
+ tail->next_p = node ;
+
+ queue_p->tail_p = node ;
+ }
+ break ;
+
+ default:
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ queue_p->count++ ;
+
+ cy_as_hal_enable_interrupts(int_state) ;
+}
+
+/* Removes the tail node from the queue and frees it */
+void
+cy_as_remove_c_b_tail_node(cy_as_c_b_queue *queue_p)
+{
+ uint32_t int_state ;
+
+ int_state = cy_as_hal_disable_interrupts() ;
+
+ if (queue_p->count > 0) {
+ /*
+ * the worst case length of the queue should be
+ * under 10 elements, and the average case should
+ * be just 1 element. so, we just employ a linear
+ * search to find the node to be freed.
+ */
+ switch (queue_p->type) {
+ case CYAS_FUNC_CB:
+ {
+ cy_as_func_c_b_node *node =
+ (cy_as_func_c_b_node *)
+ queue_p->head_p ;
+ cy_as_func_c_b_node *tail =
+ (cy_as_func_c_b_node *)
+ queue_p->tail_p ;
+ if (node != tail) {
+ while (node->next_p != tail)
+ node = node->next_p ;
+ node->next_p = 0 ;
+ queue_p->tail_p = node ;
+ }
+ cy_as_destroy_func_c_b_node(tail) ;
+ }
+ break ;
+
+ case CYAS_USB_FUNC_CB:
+ {
+ cy_as_usb_func_c_b_node *node =
+ (cy_as_usb_func_c_b_node *)
+ queue_p->head_p ;
+ cy_as_usb_func_c_b_node *tail =
+ (cy_as_usb_func_c_b_node *)
+ queue_p->tail_p ;
+ if (node != tail) {
+ while (node->next_p != tail)
+ node = node->next_p ;
+ node->next_p = 0 ;
+ queue_p->tail_p = node ;
+ }
+
+ cy_as_destroy_usb_func_c_b_node(tail) ;
+ }
+ break ;
+
+ case CYAS_USB_IO_CB:
+ {
+ cy_as_usb_io_c_b_node *node =
+ (cy_as_usb_io_c_b_node *)
+ queue_p->head_p ;
+ cy_as_usb_io_c_b_node *tail =
+ (cy_as_usb_io_c_b_node *)
+ queue_p->tail_p ;
+ if (node != tail) {
+ while (node->next_p != tail)
+ node = node->next_p ;
+ node->next_p = 0 ;
+ queue_p->tail_p = node ;
+ }
+ cy_as_destroy_usb_io_c_b_node(tail) ;
+ }
+ break ;
+
+ case CYAS_STORAGE_IO_CB:
+ {
+ cy_as_storage_io_c_b_node *node =
+ (cy_as_storage_io_c_b_node *)
+ queue_p->head_p ;
+ cy_as_storage_io_c_b_node *tail =
+ (cy_as_storage_io_c_b_node *)
+ queue_p->tail_p ;
+ if (node != tail) {
+ while (node->next_p != tail)
+ node = node->next_p ;
+ node->next_p = 0 ;
+ queue_p->tail_p = node ;
+ }
+ cy_as_destroy_storage_io_c_b_node(tail) ;
+ }
+ break ;
+
+ default:
+ cy_as_hal_assert(cy_false) ;
+ }
+
+ queue_p->count-- ;
+ if (queue_p->count == 0) {
+ queue_p->head_p = 0 ;
+ queue_p->tail_p = 0 ;
+ }
+ }
+
+ cy_as_hal_enable_interrupts(int_state) ;
+}
+
+/* Removes the first CyAsCBNode from the queue and frees it */
+void
+cy_as_remove_c_b_node(cy_as_c_b_queue *queue_p)
+{
+ uint32_t int_state ;
+
+ int_state = cy_as_hal_disable_interrupts() ;
+
+ cy_as_hal_assert(queue_p->count >= 0) ;
+ if (queue_p->count > 0) {
+ if (queue_p->type == CYAS_USB_FUNC_CB) {
+ cy_as_usb_func_c_b_node *node =
+ (cy_as_usb_func_c_b_node *)
+ queue_p->head_p ;
+ queue_p->head_p = node->next_p ;
+ cy_as_destroy_usb_func_c_b_node(node) ;
+ } else if (queue_p->type == CYAS_USB_IO_CB) {
+ cy_as_usb_io_c_b_node *node =
+ (cy_as_usb_io_c_b_node *)
+ queue_p->head_p ;
+ queue_p->head_p = node->next_p ;
+ cy_as_destroy_usb_io_c_b_node(node) ;
+ } else if (queue_p->type == CYAS_STORAGE_IO_CB) {
+ cy_as_storage_io_c_b_node *node =
+ (cy_as_storage_io_c_b_node *)
+ queue_p->head_p ;
+ queue_p->head_p = node->next_p ;
+ cy_as_destroy_storage_io_c_b_node(node) ;
+ } else if (queue_p->type == CYAS_FUNC_CB) {
+ cy_as_func_c_b_node *node =
+ (cy_as_func_c_b_node *)
+ queue_p->head_p ;
+ queue_p->head_p = node->next_p ;
+ cy_as_destroy_func_c_b_node(node) ;
+ } else {
+ cy_as_hal_assert(cy_false) ;
+ }
+
+ queue_p->count-- ;
+ if (queue_p->count == 0) {
+ queue_p->head_p = 0 ;
+ queue_p->tail_p = 0 ;
+ }
+ }
+
+ cy_as_hal_enable_interrupts(int_state) ;
+}
+
+void my_print_func_c_b_node(cy_as_func_c_b_node *node)
+{
+ cy_as_funct_c_b_type type =
+ cy_as_funct_c_b_type_get_type(node->data_type) ;
+ cy_as_hal_print_message("[cd:%2u dt:%2u cb:0x%08x "
+ "d:0x%08x nt:%1i]", node->client_data, type,
+ (uint32_t)node->cb_p, (uint32_t)node->data,
+ node->node_type) ;
+}
+
+void my_print_c_b_queue(cy_as_c_b_queue *queue_p)
+{
+ uint32_t i = 0 ;
+
+ cy_as_hal_print_message("| count: %u type: ", queue_p->count) ;
+
+ if (queue_p->type == CYAS_USB_FUNC_CB) {
+ cy_as_hal_print_message("USB_FUNC_CB\n") ;
+ } else if (queue_p->type == CYAS_USB_IO_CB) {
+ cy_as_hal_print_message("USB_IO_CB\n") ;
+ } else if (queue_p->type == CYAS_STORAGE_IO_CB) {
+ cy_as_hal_print_message("STORAGE_IO_CB\n") ;
+ } else if (queue_p->type == CYAS_FUNC_CB) {
+ cy_as_func_c_b_node *node = queue_p->head_p ;
+ cy_as_hal_print_message("FUNC_CB\n") ;
+ if (queue_p->count > 0) {
+ cy_as_hal_print_message("| head->") ;
+
+ for (i = 0; i < queue_p->count; i++) {
+ if (node) {
+ cy_as_hal_print_message("->") ;
+ my_print_func_c_b_node(node) ;
+ node = node->next_p ;
+ } else
+ cy_as_hal_print_message("->[NULL]\n") ;
+ }
+
+ cy_as_hal_print_message("\n| tail->") ;
+ my_print_func_c_b_node(queue_p->tail_p) ;
+ cy_as_hal_print_message("\n") ;
+ }
+ } else {
+ cy_as_hal_print_message("INVALID\n") ;
+ }
+
+ cy_as_hal_print_message("|----------\n") ;
+}
+
+
+/* Removes and frees all pending callbacks */
+void
+cy_as_clear_c_b_queue(cy_as_c_b_queue *queue_p)
+{
+ uint32_t int_state = cy_as_hal_disable_interrupts() ;
+
+ while (queue_p->count != 0)
+ cy_as_remove_c_b_node(queue_p) ;
+
+ cy_as_hal_enable_interrupts(int_state) ;
+}
+
+cy_as_return_status_t
+cy_as_misc_send_request(cy_as_device *dev_p,
+ cy_as_function_callback cb,
+ uint32_t client,
+ cy_as_funct_c_b_type type,
+ void *data,
+ cy_as_c_b_queue *queue,
+ uint16_t req_type,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_response_callback rcb)
+{
+
+ cy_as_func_c_b_node *cbnode = cy_as_create_func_c_b_node_data(cb,
+ client, type, data) ;
+ cy_as_return_status_t ret ;
+
+ if (cbnode == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ else
+ cy_as_insert_c_b_node(queue, cbnode) ;
+
+ req_p->flags |= req_type ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p, cy_false, rcb) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_remove_c_b_tail_node(queue) ;
+
+ return ret ;
+}
+
+void
+cy_as_misc_cancel_ex_requests(cy_as_device *dev_p)
+{
+ int i ;
+ for (i = 0; i < CY_RQT_CONTEXT_COUNT; i++)
+ cy_as_ll_remove_all_requests(dev_p, dev_p->context[i]) ;
+}
+
+
+static void
+cy_as_misc_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ cy_as_func_c_b_node *node = NULL ;
+ cy_as_return_status_t ret ;
+
+ cy_bool ex_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_EX)
+ == CY_AS_REQUEST_RESPONSE_EX ;
+ cy_bool ms_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_MS)
+ == CY_AS_REQUEST_RESPONSE_MS ;
+ uint8_t code ;
+ uint32_t type ;
+ uint8_t cntxt ;
+
+ cy_as_hal_assert(ex_request || ms_request) ;
+ (void) ex_request;
+ (void) ms_request;
+ (void)context ;
+
+ cntxt = cy_as_ll_request_response__get_context(rqt) ;
+ code = cy_as_ll_request_response__get_code(rqt) ;
+
+ switch (cntxt) {
+ case CY_RQT_GENERAL_RQT_CONTEXT:
+ cy_as_hal_assert(dev_p->func_cbs_misc->count != 0) ;
+ cy_as_hal_assert(dev_p->func_cbs_misc->type == CYAS_FUNC_CB) ;
+ node = (cy_as_func_c_b_node *)dev_p->func_cbs_misc->head_p ;
+ type = cy_as_funct_c_b_type_get_type(node->data_type) ;
+
+ switch (code) {
+ case CY_RQT_GET_FIRMWARE_VERSION:
+ cy_as_hal_assert(node->data != 0) ;
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_GETFIRMWAREVERSION) ;
+ ret = my_handle_response_get_firmware_version(dev_p,
+ rqt, resp,
+ (cy_as_get_firmware_version_data *)node->data);
+ break ;
+ case CY_RQT_READ_MCU_REGISTER:
+ cy_as_hal_assert(node->data != 0) ;
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_READMCUREGISTER) ;
+ ret = my_handle_response_read_m_c_u_register(dev_p, rqt,
+ resp, (uint8_t *)node->data) ;
+ break ;
+ case CY_RQT_GET_GPIO_STATE:
+ cy_as_hal_assert(node->data != 0) ;
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_GETGPIOVALUE) ;
+ ret = my_handle_response_get_gpio_value(dev_p, rqt,
+ resp, (uint8_t *)node->data) ;
+ break ;
+ case CY_RQT_SET_SD_CLOCK_FREQ:
+ cy_as_hal_assert(type == CY_FUNCT_CB_MISC_SETSDFREQ) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_CONTROL_ANTIOCH_HEARTBEAT:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_HEARTBEATCONTROL) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_WRITE_MCU_REGISTER:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_WRITEMCUREGISTER) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_STORAGE_MEDIA_CHANGED:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_STORAGECHANGED) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_SET_GPIO_STATE:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_SETGPIOVALUE) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_SET_TRACE_LEVEL:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_SETTRACELEVEL) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ if (ret == CY_AS_ERROR_INVALID_RESPONSE)
+ ret = CY_AS_ERROR_NOT_SUPPORTED ;
+ break ;
+ case CY_RQT_PREPARE_FOR_STANDBY:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_ENTERSTANDBY) ;
+ ret = my_handle_response_enter_standby(dev_p, rqt, resp,
+ (cy_bool)node->data) ;
+ break ;
+ case CY_RQT_ENTER_SUSPEND_MODE:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_ENTERSUSPEND) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ cy_as_device_set_suspend_mode(dev_p) ;
+
+ break ;
+ case CY_RQT_RESERVE_LNA_BOOT_AREA:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_RESERVELNABOOTAREA) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_SDPOLARITY:
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_SETSDPOLARITY) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+ break ;
+
+ case CY_RQT_RESOURCE_RQT_CONTEXT:
+ cy_as_hal_assert(dev_p->func_cbs_res->count != 0) ;
+ cy_as_hal_assert(dev_p->func_cbs_res->type == CYAS_FUNC_CB) ;
+ node = (cy_as_func_c_b_node *)dev_p->func_cbs_res->head_p ;
+ type = cy_as_funct_c_b_type_get_type(node->data_type) ;
+
+ switch (code) {
+ case CY_RQT_ACQUIRE_RESOURCE:
+ /* The node->data field is actually an enum value
+ * which could be 0, thus no assert is done */
+ cy_as_hal_assert(type ==
+ CY_FUNCT_CB_MISC_ACQUIRERESOURCE) ;
+ ret = my_handle_response_acquire_resource(dev_p, rqt,
+ resp, (cy_as_resource_type *)node->data) ;
+ break ;
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+ break ;
+
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /*
+ * if the low level layer returns a direct error, use the
+ * corresponding error code. if not, use the error code
+ * based on the response from firmware.
+ */
+ if (stat == CY_AS_ERROR_SUCCESS)
+ stat = ret ;
+
+ /* Call the user Callback */
+ node->cb_p((cy_as_device_handle)dev_p, stat, node->client_data,
+ node->data_type, node->data) ;
+ if (cntxt == CY_RQT_GENERAL_RQT_CONTEXT)
+ cy_as_remove_c_b_node(dev_p->func_cbs_misc) ;
+ else
+ cy_as_remove_c_b_node(dev_p->func_cbs_res) ;
+
+}
+
+
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasmtp.c b/drivers/staging/westbridge/astoria/api/src/cyasmtp.c
new file mode 100644
index 000000000000..3725800aa7be
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasmtp.c
@@ -0,0 +1,1128 @@
+/* Cypress West Bridge API header file (cyasmtp.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasmtp.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+
+static void
+cy_as_mtp_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat) ;
+
+static cy_as_return_status_t
+is_mtp_active(cy_as_device *dev_p)
+{
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->mtp_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+my_mtp_request_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *resp_p,
+ cy_as_return_status_t ret)
+{
+ uint16_t val, ev, status ;
+ uint16_t mtp_datalen = 0 ;
+ uint32_t bytecount_l, bytecount_h ;
+ cy_as_mtp_send_object_complete_data send_obj_data ;
+ cy_as_mtp_get_object_complete_data get_obj_data ;
+ cy_as_dma_end_point *ep_p ;
+
+ uint8_t code = cy_as_ll_request_response__get_code(req_p) ;
+
+ (void)resp_p ;
+ (void)context ;
+ (void)ret ;
+
+ switch (code) {
+ case CY_RQT_MTP_EVENT:
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ /* MSB indicates status of read/write */
+ status = (val >> 8) & 0xFF ;
+ /* event type */
+ ev = val & 0xFF ;
+ switch (ev) {
+ case 0: /* SendObject Complete */
+ {
+ bytecount_l =
+ cy_as_ll_request_response__get_word
+ (req_p, 1) ;
+ bytecount_h =
+ cy_as_ll_request_response__get_word
+ (req_p, 2) ;
+ send_obj_data.byte_count =
+ (bytecount_h << 16) | bytecount_l ;
+
+ send_obj_data.status = status ;
+
+ /* use the byte count again */
+ bytecount_l =
+ cy_as_ll_request_response__get_word
+ (req_p, 3) ;
+ bytecount_h =
+ cy_as_ll_request_response__get_word
+ (req_p, 4) ;
+ send_obj_data.transaction_id =
+ (bytecount_h << 16) | bytecount_l ;
+
+ dev_p->mtp_turbo_active = cy_false ;
+
+ if (dev_p->mtp_event_cb)
+ dev_p->mtp_event_cb(
+ (cy_as_device_handle) dev_p,
+ cy_as_mtp_send_object_complete,
+ &send_obj_data) ;
+ }
+ break ;
+
+ case 1: /* GetObject Complete */
+ {
+ bytecount_l =
+ cy_as_ll_request_response__get_word
+ (req_p, 1) ;
+ bytecount_h =
+ cy_as_ll_request_response__get_word
+ (req_p, 2) ;
+
+ get_obj_data.byte_count =
+ (bytecount_h << 16) | bytecount_l ;
+
+ get_obj_data.status = status ;
+
+ dev_p->mtp_turbo_active = cy_false ;
+
+ if (dev_p->mtp_event_cb)
+ dev_p->mtp_event_cb(
+ (cy_as_device_handle) dev_p,
+ cy_as_mtp_get_object_complete,
+ &get_obj_data);
+ }
+ break ;
+
+ case 2: /* BlockTable Needed */
+ {
+ if (dev_p->mtp_event_cb)
+ dev_p->mtp_event_cb(
+ (cy_as_device_handle) dev_p,
+ cy_as_mtp_block_table_needed, 0);
+ }
+ break ;
+ default:
+ cy_as_hal_print_message("invalid event type\n") ;
+ cy_as_ll_send_data_response(dev_p,
+ CY_RQT_TUR_RQT_CONTEXT,
+ CY_RESP_MTP_INVALID_EVENT,
+ sizeof(ev), &ev) ;
+ break ;
+ }
+ break ;
+
+ case CY_RQT_TURBO_CMD_FROM_HOST:
+ {
+ mtp_datalen =
+ cy_as_ll_request_response__get_word(req_p, 1) ;
+
+ /* Get the endpoint pointer based on
+ * the endpoint number */
+ ep_p = CY_AS_NUM_EP(dev_p, CY_AS_MTP_READ_ENDPOINT) ;
+
+ /* The event should arrive only after the DMA operation
+ * has been queued. */
+ cy_as_hal_assert(ep_p->queue_p != 0) ;
+
+ /* Put the len in ep data information in
+ * dmaqueue and kick start the queue */
+ cy_as_hal_assert(ep_p->queue_p->size >= mtp_datalen) ;
+
+ if (mtp_datalen == 0) {
+ cy_as_dma_completed_callback(dev_p->tag,
+ CY_AS_MTP_READ_ENDPOINT, 0,
+ CY_AS_ERROR_SUCCESS) ;
+ } else {
+ ep_p->maxhwdata = mtp_datalen ;
+
+ /*
+ * make sure that the DMA status for this
+ * EP is not running, so that the call to
+ * cy_as_dma_kick_start gets this transfer
+ * going. note: in MTP mode, we never leave
+ * a DMA transfer of greater than one packet
+ * running. so, it is okay to override the
+ * status here and start the next packet
+ * transfer.
+ */
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+
+ /* Kick start the queue if it is not running */
+ cy_as_dma_kick_start(dev_p,
+ CY_AS_MTP_READ_ENDPOINT);
+ }
+ }
+ break ;
+
+ case CY_RQT_TURBO_START_WRITE_DMA:
+ {
+ /*
+ * now that the firmware is ready to receive the
+ * next packet of data, start the corresponding
+ * DMA transfer. first, ensure that a DMA
+ * operation is still pending in the queue for the
+ * write endpoint.
+ */
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_TUR_RQT_CONTEXT,
+ CY_AS_ERROR_SUCCESS, 0) ;
+
+ ep_p = CY_AS_NUM_EP(dev_p, CY_AS_MTP_WRITE_ENDPOINT) ;
+ cy_as_hal_assert(ep_p->queue_p != 0) ;
+
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+ cy_as_dma_kick_start(dev_p, CY_AS_MTP_WRITE_ENDPOINT) ;
+ }
+ break ;
+
+ default:
+ cy_as_hal_print_message("invalid request received "
+ "on TUR context\n") ;
+ val = req_p->box0 ;
+ cy_as_ll_send_data_response(dev_p, CY_RQT_TUR_RQT_CONTEXT,
+ CY_RESP_INVALID_REQUEST, sizeof(val), &val) ;
+ break ;
+ }
+}
+
+static cy_as_return_status_t
+my_handle_response_no_data(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_mtp_start(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ dev_p->mtp_count++ ;
+
+ cy_as_dma_enable_end_point(dev_p, CY_AS_MTP_READ_ENDPOINT,
+ cy_true, cy_as_direction_out) ;
+ dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].enabled = cy_true ;
+ dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].dir = cy_as_usb_out ;
+ dev_p->usb_config[CY_AS_MTP_READ_ENDPOINT].type = cy_as_usb_bulk ;
+
+ cy_as_dma_enable_end_point(dev_p, CY_AS_MTP_WRITE_ENDPOINT,
+ cy_true, cy_as_direction_in) ;
+ dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].enabled = cy_true ;
+ dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].dir = cy_as_usb_in ;
+ dev_p->usb_config[CY_AS_MTP_WRITE_ENDPOINT].type = cy_as_usb_bulk ;
+
+ /* Packet size is 512 bytes */
+ cy_as_dma_set_max_dma_size(dev_p, 0x02, 0x0200) ;
+ /* Packet size is 64 bytes until a switch to high speed happens.*/
+ cy_as_dma_set_max_dma_size(dev_p, 0x06, 0x40) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_TUR_RQT_CONTEXT, 0) ;
+
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_mtp_start(cy_as_device_handle handle,
+ cy_as_mtp_event_callback event_c_b,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (cy_as_device_is_m_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ if (dev_p->storage_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (dev_p->usb_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (dev_p->is_mtp_firmware == 0)
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ cy_as_device_set_m_s_s_pending(dev_p) ;
+
+ if (dev_p->mtp_count == 0) {
+
+ dev_p->mtp_event_cb = event_c_b ;
+ /*
+ * we register here becuase the start request may cause
+ * events to occur before the response to the start request.
+ */
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_TUR_RQT_CONTEXT, my_mtp_request_callback) ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_START_MTP, CY_RQT_TUR_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_mtp_start(dev_p, req_p,
+ reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_START, 0, dev_p->func_cbs_mtp,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else {
+ dev_p->mtp_count++ ;
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_MTP_START, 0) ;
+ }
+
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_mtp_stop(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /*
+ * we sucessfully shutdown the stack, so decrement
+ * to make the count zero.
+ */
+ dev_p->mtp_count-- ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_TUR_RQT_CONTEXT, 0) ;
+
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_stop(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p = 0, *reply_p = 0 ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_mtp_stop called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_mtp_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (cy_as_device_is_m_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ cy_as_device_set_m_s_s_pending(dev_p) ;
+
+ if (dev_p->mtp_count == 1) {
+ /* Create the request to send to the West
+ * Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_STOP_MTP,
+ CY_RQT_TUR_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_mtp_stop(dev_p, req_p,
+ reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_STOP, 0, dev_p->func_cbs_mtp,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else if (dev_p->mtp_count > 1) {
+
+ dev_p->mtp_count-- ;
+
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_MTP_STOP, 0) ;
+ }
+
+ cy_as_device_clear_m_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+static void
+mtp_write_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ cy_as_hal_assert(context == CY_RQT_TUR_RQT_CONTEXT) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ /* Firmware failed the request. Cancel the DMA transfer. */
+ cy_as_dma_cancel(dev_p, 0x04, CY_AS_ERROR_CANCELED) ;
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ }
+
+ cy_as_ll_destroy_response(dev_p, resp) ;
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+}
+
+static void
+async_write_request_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p, uint32_t size,
+ cy_as_return_status_t err)
+{
+ cy_as_device_handle h ;
+ cy_as_function_callback cb ;
+
+ (void)size ;
+ (void)buf_p ;
+ (void)ep ;
+
+
+ cy_as_log_debug_message(6, "async_write_request_callback called") ;
+
+ h = (cy_as_device_handle)dev_p ;
+
+ cb = dev_p->mtp_cb ;
+ dev_p->mtp_cb = 0 ;
+
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+
+ if (cb)
+ cb(h, err, dev_p->mtp_client, dev_p->mtp_op, 0) ;
+
+}
+
+static void
+sync_mtp_callback(cy_as_device *dev_p, cy_as_end_point_number_t ep,
+ void *buf_p, uint32_t size, cy_as_return_status_t err)
+{
+ (void)ep ;
+ (void)buf_p ;
+ (void)size ;
+
+ dev_p->mtp_error = err ;
+}
+
+static cy_as_return_status_t
+cy_as_mtp_operation(cy_as_device *dev_p,
+ cy_as_mtp_block_table *blk_table,
+ uint32_t num_bytes,
+ uint32_t transaction_id,
+ cy_as_function_callback cb,
+ uint32_t client,
+ uint8_t rqttype
+ )
+{
+ cy_as_ll_request_response *req_p = 0, *reply_p = 0 ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint32_t mask = 0 ;
+ cy_as_funct_c_b_type mtp_cb_op = 0 ;
+ uint16_t size = 2 ;
+
+ if (dev_p->mtp_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (rqttype == CY_RQT_INIT_SEND_OBJECT) {
+ mtp_cb_op = CY_FUNCT_CB_MTP_INIT_SEND_OBJECT ;
+ dev_p->mtp_turbo_active = cy_true ;
+ } else if (rqttype == CY_RQT_INIT_GET_OBJECT) {
+ mtp_cb_op = CY_FUNCT_CB_MTP_INIT_GET_OBJECT ;
+ dev_p->mtp_turbo_active = cy_true ;
+ } else
+ mtp_cb_op = CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE ;
+
+ ret = is_mtp_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (CY_RQT_INIT_GET_OBJECT == rqttype)
+ size = 4 ;
+
+ /* Create the request to send to the West
+ * Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, rqttype,
+ CY_RQT_TUR_RQT_CONTEXT, size) ;
+ if (req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)(num_bytes & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((num_bytes >> 16) & 0xFFFF)) ;
+
+ /* If it is GET_OBJECT, send transaction id as well*/
+ if (CY_RQT_INIT_GET_OBJECT == rqttype) {
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(transaction_id & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 3,
+ (uint16_t)((transaction_id >> 16) & 0xFFFF)) ;
+ }
+
+ if (cb == 0) {
+ /* Queue the DMA request for block table write */
+ ret = cy_as_dma_queue_request(dev_p, 4, blk_table,
+ sizeof(cy_as_mtp_block_table), cy_false,
+ cy_false, sync_mtp_callback) ;
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, 4, CY_AS_ERROR_CANCELED) ;
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+
+ goto destroy ;
+ }
+
+ ret = cy_as_dma_drain_queue(dev_p, 4, cy_true) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = dev_p->mtp_error ;
+ goto destroy ;
+ } else {
+#if 0
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,
+ 0, dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+#endif
+
+ /* Protection from interrupt driven code */
+ /* since we are using storage EP4 check if any
+ * storage activity is pending */
+ mask = cy_as_hal_disable_interrupts() ;
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait)) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+ cy_as_device_set_storage_async_pending(dev_p) ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+ dev_p->mtp_cb = cb ;
+ dev_p->mtp_client = client ;
+ dev_p->mtp_op = mtp_cb_op ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_false, mtp_write_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = cy_as_dma_queue_request(dev_p, 4, blk_table,
+ sizeof(cy_as_mtp_block_table), cy_false, cy_false,
+ async_write_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Kick start the queue if it is not running */
+ cy_as_dma_kick_start(dev_p, 4) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_init_send_object(cy_as_device_handle handle,
+ cy_as_mtp_block_table *blk_table,
+ uint32_t num_bytes,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_device *dev_p ;
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ return cy_as_mtp_operation(dev_p, blk_table, num_bytes, 0, cb,
+ client, CY_RQT_INIT_SEND_OBJECT) ;
+
+}
+
+cy_as_return_status_t
+cy_as_mtp_init_get_object(cy_as_device_handle handle,
+ cy_as_mtp_block_table *blk_table,
+ uint32_t num_bytes,
+ uint32_t transaction_id,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_device *dev_p ;
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ return cy_as_mtp_operation(dev_p, blk_table, num_bytes,
+ transaction_id, cb, client, CY_RQT_INIT_GET_OBJECT) ;
+
+}
+
+static cy_as_return_status_t
+my_handle_response_cancel_send_object(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_cancel_send_object(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p = 0, *reply_p = 0 ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (dev_p->mtp_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_CANCEL_SEND_OBJECT, CY_RQT_TUR_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_cancel_send_object(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT, 0,
+ dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_cancel_get_object(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_cancel_get_object(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p = 0, *reply_p = 0 ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (dev_p->mtp_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_CANCEL_GET_OBJECT,
+ CY_RQT_TUR_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_cancel_get_object(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT, 0,
+ dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_send_block_table(cy_as_device_handle handle,
+ cy_as_mtp_block_table *blk_table,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p ;
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ return cy_as_mtp_operation(dev_p, blk_table, 0, 0, cb,
+ client, CY_RQT_SEND_BLOCK_TABLE) ;
+}
+
+static void
+cy_as_mtp_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ cy_as_func_c_b_node* node = (cy_as_func_c_b_node *)
+ dev_p->func_cbs_mtp->head_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code ;
+ cy_bool delay_callback = cy_false ;
+
+ cy_as_hal_assert(dev_p->func_cbs_mtp->count != 0) ;
+ cy_as_hal_assert(dev_p->func_cbs_mtp->type == CYAS_FUNC_CB) ;
+
+ (void)context ;
+
+ /* The Handlers are responsible for Deleting the
+ * rqt and resp when they are finished
+ */
+ code = cy_as_ll_request_response__get_code(rqt) ;
+ switch (code) {
+ case CY_RQT_START_MTP:
+ ret = my_handle_response_mtp_start(dev_p, rqt,
+ resp, stat) ;
+ break ;
+ case CY_RQT_STOP_MTP:
+ ret = my_handle_response_mtp_stop(dev_p, rqt,
+ resp, stat) ;
+ break ;
+#if 0
+ case CY_RQT_INIT_SEND_OBJECT:
+ ret = my_handle_response_init_send_object(dev_p,
+ rqt, resp, stat, cy_true) ;
+ delay_callback = cy_true ;
+ break ;
+#endif
+ case CY_RQT_CANCEL_SEND_OBJECT:
+ ret = my_handle_response_cancel_send_object(dev_p,
+ rqt, resp, stat) ;
+ break ;
+#if 0
+ case CY_RQT_INIT_GET_OBJECT:
+ ret = my_handle_response_init_get_object(dev_p,
+ rqt, resp, stat, cy_true) ;
+ delay_callback = cy_true ;
+ break ;
+#endif
+ case CY_RQT_CANCEL_GET_OBJECT:
+ ret = my_handle_response_cancel_get_object(dev_p,
+ rqt, resp, stat) ;
+ break ;
+#if 0
+ case CY_RQT_SEND_BLOCK_TABLE:
+ ret = my_handle_response_send_block_table(dev_p, rqt,
+ resp, stat, cy_true) ;
+ delay_callback = cy_true ;
+ break ;
+#endif
+ case CY_RQT_ENABLE_USB_PATH:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ dev_p->is_storage_only_mode = cy_false ;
+ break ;
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /*
+ * if the low level layer returns a direct error, use the
+ * corresponding error code. if not, use the error code
+ * based on the response from firmware.
+ */
+ if (stat == CY_AS_ERROR_SUCCESS)
+ stat = ret ;
+
+ if (!delay_callback) {
+ node->cb_p((cy_as_device_handle)dev_p, stat, node->client_data,
+ node->data_type, node->data) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_mtp) ;
+ }
+}
+
+cy_as_return_status_t
+cy_as_mtp_storage_only_start(cy_as_device_handle handle)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->storage_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ dev_p->is_storage_only_mode = cy_true ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_mtp_storage_only_stop(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->storage_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (dev_p->is_storage_only_mode == cy_false)
+ return CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_ENABLE_USB_PATH, CY_RQT_TUR_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = my_handle_response_no_data(dev_p, req_p,
+ reply_p) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ dev_p->is_storage_only_mode = cy_false ;
+ return ret ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY, 0,
+ dev_p->func_cbs_mtp, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_mtp_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasstorage.c b/drivers/staging/westbridge/astoria/api/src/cyasstorage.c
new file mode 100644
index 000000000000..c7c3cda261db
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasstorage.c
@@ -0,0 +1,4104 @@
+/* Cypress West Bridge API source file (cyasstorage.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+* Storage Design
+*
+* The storage module is fairly straight forward once the
+* DMA and LOWLEVEL modules have been designed. The
+* storage module simple takes requests from the user, queues
+* the associated DMA requests for action, and then sends
+* the low level requests to the West Bridge firmware.
+*
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasstorage.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasdevice.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+
+/* Map a pre-V1.2 media type to the V1.2+ bus number */
+cy_as_return_status_t
+cy_an_map_bus_from_media_type(cy_as_device *dev_p,
+ cy_as_media_type type, cy_as_bus_number_t *bus)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code = (uint8_t)(1 << type) ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+
+ if (dev_p->media_supported[0] & code) {
+ if (dev_p->media_supported[1] & code) {
+ /*
+ * this media type could be supported on multiple
+ * buses. so, report an address resolution error.
+ */
+ ret = CY_AS_ERROR_ADDRESS_RESOLUTION_ERROR ;
+ } else
+ *bus = 0 ;
+ } else {
+ if (dev_p->media_supported[1] & code)
+ *bus = 1 ;
+ else
+ ret = CY_AS_ERROR_NO_SUCH_MEDIA ;
+ }
+
+ return ret ;
+}
+
+static uint16_t
+create_address(cy_as_bus_number_t bus, uint32_t device, uint8_t unit)
+{
+ cy_as_hal_assert(bus >= 0 && bus < CY_AS_MAX_BUSES) ;
+ cy_as_hal_assert(device < 16) ;
+
+ return (uint16_t)(((uint8_t)bus << 12) | (device << 8) | unit) ;
+}
+
+cy_as_media_type
+cy_as_storage_get_media_from_address(uint16_t v)
+{
+ cy_as_media_type media = cy_as_media_max_media_value ;
+
+ switch (v & 0xFF) {
+ case 0x00:
+ break;
+ case 0x01:
+ media = cy_as_media_nand ;
+ break ;
+ case 0x02:
+ media = cy_as_media_sd_flash ;
+ break ;
+ case 0x04:
+ media = cy_as_media_mmc_flash ;
+ break ;
+ case 0x08:
+ media = cy_as_media_ce_ata ;
+ break ;
+ case 0x10:
+ media = cy_as_media_sdio ;
+ break ;
+ default:
+ cy_as_hal_assert(0) ;
+ break ;
+ }
+
+ return media ;
+}
+
+cy_as_bus_number_t
+cy_as_storage_get_bus_from_address(uint16_t v)
+{
+ cy_as_bus_number_t bus = (cy_as_bus_number_t)((v >> 12) & 0x0f) ;
+ cy_as_hal_assert(bus >= 0 && bus < CY_AS_MAX_BUSES) ;
+ return bus ;
+}
+
+uint32_t
+cy_as_storage_get_device_from_address(uint16_t v)
+{
+ return (uint32_t)((v >> 8) & 0x0f) ;
+}
+
+static uint8_t
+get_unit_from_address(uint16_t v)
+{
+ return (uint8_t)(v & 0xff) ;
+}
+
+static cy_as_return_status_t
+cy_as_map_bad_addr(uint16_t val)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_INVALID_RESPONSE ;
+
+ switch (val) {
+ case 0:
+ ret = CY_AS_ERROR_NO_SUCH_BUS ;
+ break ;
+ case 1:
+ ret = CY_AS_ERROR_NO_SUCH_DEVICE ;
+ break ;
+ case 2:
+ ret = CY_AS_ERROR_NO_SUCH_UNIT ;
+ break ;
+ case 3:
+ ret = CY_AS_ERROR_INVALID_BLOCK ;
+ break ;
+ }
+
+ return ret ;
+}
+
+static void
+my_storage_request_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *resp_p,
+ cy_as_return_status_t ret)
+{
+ uint16_t val ;
+ uint16_t addr ;
+ cy_as_bus_number_t bus;
+ uint32_t device;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+ cy_as_dma_end_point *ep_p = NULL ;
+
+ (void)resp_p ;
+ (void)context ;
+ (void)ret ;
+
+ switch (cy_as_ll_request_response__get_code(req_p)) {
+ case CY_RQT_MEDIA_CHANGED:
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+
+ /* Media has either been inserted or removed */
+ addr = cy_as_ll_request_response__get_word(req_p, 0) ;
+
+ bus = cy_as_storage_get_bus_from_address(addr);
+ device = cy_as_storage_get_device_from_address(addr);
+
+ /* Clear the entry for this device to force re-query later */
+ cy_as_hal_mem_set(&(dev_p->storage_device_info[bus][device]), 0,
+ sizeof(dev_p->storage_device_info[bus][device])) ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ if (dev_p->storage_event_cb_ms) {
+ if (val == 1)
+ dev_p->storage_event_cb_ms(h, bus,
+ device, cy_as_storage_removed, 0) ;
+ else
+ dev_p->storage_event_cb_ms(h, bus,
+ device, cy_as_storage_inserted, 0) ;
+ } else if (dev_p->storage_event_cb) {
+ if (val == 1)
+ dev_p->storage_event_cb(h, bus,
+ cy_as_storage_removed, 0) ;
+ else
+ dev_p->storage_event_cb(h, bus,
+ cy_as_storage_inserted, 0) ;
+ }
+
+ break ;
+
+ case CY_RQT_ANTIOCH_CLAIM:
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ if (dev_p->storage_event_cb || dev_p->storage_event_cb_ms) {
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ if (dev_p->storage_event_cb_ms) {
+ if (val & 0x0100)
+ dev_p->storage_event_cb_ms(h, 0, 0,
+ cy_as_storage_antioch, 0) ;
+ if (val & 0x0200)
+ dev_p->storage_event_cb_ms(h, 1, 0,
+ cy_as_storage_antioch, 0) ;
+ } else {
+ if (val & 0x01)
+ dev_p->storage_event_cb(h,
+ cy_as_media_nand,
+ cy_as_storage_antioch, 0) ;
+ if (val & 0x02)
+ dev_p->storage_event_cb(h,
+ cy_as_media_sd_flash,
+ cy_as_storage_antioch, 0) ;
+ if (val & 0x04)
+ dev_p->storage_event_cb(h,
+ cy_as_media_mmc_flash,
+ cy_as_storage_antioch, 0) ;
+ if (val & 0x08)
+ dev_p->storage_event_cb(h,
+ cy_as_media_ce_ata,
+ cy_as_storage_antioch, 0) ;
+ }
+ }
+ break ;
+
+ case CY_RQT_ANTIOCH_RELEASE:
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ if (dev_p->storage_event_cb_ms) {
+ if (val & 0x0100)
+ dev_p->storage_event_cb_ms(h, 0, 0,
+ cy_as_storage_processor, 0) ;
+ if (val & 0x0200)
+ dev_p->storage_event_cb_ms(h, 1, 0,
+ cy_as_storage_processor, 0) ;
+ } else if (dev_p->storage_event_cb) {
+ if (val & 0x01)
+ dev_p->storage_event_cb(h,
+ cy_as_media_nand,
+ cy_as_storage_processor, 0) ;
+ if (val & 0x02)
+ dev_p->storage_event_cb(h,
+ cy_as_media_sd_flash,
+ cy_as_storage_processor, 0) ;
+ if (val & 0x04)
+ dev_p->storage_event_cb(h,
+ cy_as_media_mmc_flash,
+ cy_as_storage_processor, 0) ;
+ if (val & 0x08)
+ dev_p->storage_event_cb(h,
+ cy_as_media_ce_ata,
+ cy_as_storage_processor, 0) ;
+ }
+ break ;
+
+
+ case CY_RQT_SDIO_INTR:
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ if (dev_p->storage_event_cb_ms) {
+ if (val & 0x0100)
+ dev_p->storage_event_cb_ms(h, 1, 0,
+ cy_as_sdio_interrupt, 0) ;
+ else
+ dev_p->storage_event_cb_ms(h, 0, 0,
+ cy_as_sdio_interrupt, 0) ;
+
+ } else if (dev_p->storage_event_cb) {
+ dev_p->storage_event_cb(h,
+ cy_as_media_sdio, cy_as_sdio_interrupt, 0) ;
+ }
+ break;
+
+ case CY_RQT_P2S_DMA_START:
+ /* Do the DMA setup for the waiting operation. */
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ cy_as_device_set_p2s_dma_start_recvd(dev_p) ;
+ if (dev_p->storage_oper == cy_as_op_read) {
+ ep_p = CY_AS_NUM_EP(dev_p, CY_AS_P2S_READ_ENDPOINT) ;
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+ cy_as_dma_kick_start(dev_p, CY_AS_P2S_READ_ENDPOINT) ;
+ } else {
+ ep_p = CY_AS_NUM_EP(dev_p, CY_AS_P2S_WRITE_ENDPOINT) ;
+ cy_as_dma_end_point_set_stopped(ep_p) ;
+ cy_as_dma_kick_start(dev_p, CY_AS_P2S_WRITE_ENDPOINT) ;
+ }
+ break ;
+
+ default:
+ cy_as_hal_print_message("invalid request received "
+ "on storage context\n") ;
+ val = req_p->box0 ;
+ cy_as_ll_send_data_response(dev_p, CY_RQT_STORAGE_RQT_CONTEXT,
+ CY_RESP_INVALID_REQUEST, sizeof(val), &val) ;
+ break ;
+ }
+}
+
+static cy_as_return_status_t
+is_storage_active(cy_as_device *dev_p)
+{
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->storage_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+cy_as_storage_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret) ;
+
+static cy_as_return_status_t
+my_handle_response_no_data(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_storage_start(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (dev_p->storage_count > 0 && ret ==
+ CY_AS_ERROR_ALREADY_RUNNING)
+ ret = CY_AS_ERROR_SUCCESS ;
+
+ ret = cy_as_dma_enable_end_point(dev_p,
+ CY_AS_P2S_WRITE_ENDPOINT, cy_true, cy_as_direction_in) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = cy_as_dma_set_max_dma_size(dev_p,
+ CY_AS_P2S_WRITE_ENDPOINT, CY_AS_STORAGE_EP_SIZE) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = cy_as_dma_enable_end_point(dev_p,
+ CY_AS_P2S_READ_ENDPOINT, cy_true, cy_as_direction_out) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = cy_as_dma_set_max_dma_size(dev_p,
+ CY_AS_P2S_READ_ENDPOINT, CY_AS_STORAGE_EP_SIZE) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_STORAGE_RQT_CONTEXT, my_storage_request_callback) ;
+
+ /* Create the request/response used for storage reads and writes. */
+ dev_p->storage_rw_req_p = cy_as_ll_create_request(dev_p,
+ 0, CY_RQT_STORAGE_RQT_CONTEXT, 5) ;
+ if (dev_p->storage_rw_req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY;
+ goto destroy;
+ }
+
+ dev_p->storage_rw_resp_p = cy_as_ll_create_response(dev_p, 5) ;
+ if (dev_p->storage_rw_resp_p == 0) {
+ cy_as_ll_destroy_request(dev_p, dev_p->storage_rw_req_p) ;
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ /* Increment the storage count only if
+ * the above functionality succeeds.*/
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (dev_p->storage_count == 0) {
+ cy_as_hal_mem_set(dev_p->storage_device_info,
+ 0, sizeof(dev_p->storage_device_info)) ;
+ dev_p->is_storage_only_mode = cy_false ;
+ }
+
+ dev_p->storage_count++ ;
+ }
+
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_start(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (cy_as_device_is_s_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ cy_as_device_set_s_s_s_pending(dev_p) ;
+
+ if (dev_p->storage_count == 0) {
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_START_STORAGE, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0) {
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_storage_start(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_START, 0, dev_p->func_cbs_stor,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as
+ * part of the FuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else {
+ dev_p->storage_count++ ;
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_STOR_START, 0) ;
+ }
+
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+
+static cy_as_return_status_t
+my_handle_response_storage_stop(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ cy_as_ll_destroy_request(dev_p, dev_p->storage_rw_req_p) ;
+ cy_as_ll_destroy_response(dev_p, dev_p->storage_rw_resp_p) ;
+ dev_p->storage_count-- ;
+ }
+
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+cy_as_return_status_t
+cy_as_storage_stop(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_storage_async_pending(dev_p))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ if (cy_as_device_is_s_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ cy_as_device_set_s_s_s_pending(dev_p) ;
+
+ if (dev_p->storage_count == 1) {
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_STOP_STORAGE, CY_RQT_STORAGE_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_storage_stop(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_STOP, 0, dev_p->func_cbs_stor,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else if (dev_p->storage_count > 1) {
+ dev_p->storage_count-- ;
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_STOR_STOP, 0) ;
+ }
+
+ cy_as_device_clear_s_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_register_callback(cy_as_device_handle handle,
+ cy_as_storage_event_callback callback)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->storage_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ dev_p->storage_event_cb = NULL ;
+ dev_p->storage_event_cb_ms = callback ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+
+
+static cy_as_return_status_t
+my_handle_response_storage_claim(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_NO_SUCH_ADDRESS) {
+ ret = cy_as_map_bad_addr(
+ cy_as_ll_request_response__get_word(reply_p, 3)) ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_MEDIA_CLAIMED_RELEASED) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* The response must be about the address I am
+ * trying to claim or the firmware is broken */
+ if ((cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(req_p, 0)) !=
+ cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 0))) ||
+ (cy_as_storage_get_device_from_address(
+ cy_as_ll_request_response__get_word(req_p, 0)) !=
+ cy_as_storage_get_device_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 0)))) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_word(reply_p, 1) != 1)
+ ret = CY_AS_ERROR_NOT_ACQUIRED ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_storage_claim(cy_as_device *dev_p,
+ void *data,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint16_t req_flags,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (dev_p->mtp_count > 0)
+ return CY_AS_ERROR_NOT_VALID_IN_MTP ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_CLAIM_STORAGE, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, create_address(bus, device, 0)) ;
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 4) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_storage_claim(dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_CLAIM, data, dev_p->func_cbs_stor,
+ req_flags, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of
+ * the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_claim(cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ return my_storage_claim(dev_p, NULL, bus, device,
+ CY_AS_REQUEST_RESPONSE_MS, cb, client) ;
+}
+
+static cy_as_return_status_t
+my_handle_response_storage_release(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_NO_SUCH_ADDRESS) {
+ ret = cy_as_map_bad_addr(
+ cy_as_ll_request_response__get_word(reply_p, 3)) ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_MEDIA_CLAIMED_RELEASED) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* The response must be about the address I am
+ * trying to release or the firmware is broken */
+ if ((cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(req_p, 0)) !=
+ cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 0))) ||
+ (cy_as_storage_get_device_from_address(
+ cy_as_ll_request_response__get_word(req_p, 0)) !=
+ cy_as_storage_get_device_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 0)))) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+
+ if (cy_as_ll_request_response__get_word(reply_p, 1) != 0)
+ ret = CY_AS_ERROR_NOT_RELEASED ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_storage_release(cy_as_device *dev_p,
+ void *data,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint16_t req_flags,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (dev_p->mtp_count > 0)
+ return CY_AS_ERROR_NOT_VALID_IN_MTP ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_RELEASE_STORAGE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(
+ req_p, 0, create_address(bus, device, 0)) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 4) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_storage_release(
+ dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_RELEASE, data, dev_p->func_cbs_stor,
+ req_flags, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as
+ * part of the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_release(cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ return my_storage_release(dev_p, NULL, bus, device,
+ CY_AS_REQUEST_RESPONSE_MS, cb, client) ;
+}
+
+static cy_as_return_status_t
+my_handle_response_storage_query_bus(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ uint32_t *count)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code = cy_as_ll_request_response__get_code(reply_p) ;
+ uint16_t v ;
+
+ if (code == CY_RESP_NO_SUCH_ADDRESS) {
+ ret = CY_AS_ERROR_NO_SUCH_BUS ;
+ goto destroy ;
+ }
+
+ if (code != CY_RESP_BUS_DESCRIPTOR) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /*
+ * verify that the response corresponds to the bus that was queried.
+ */
+ if (cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(req_p, 0)) !=
+ cy_as_storage_get_bus_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 0))) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ v = cy_as_ll_request_response__get_word(reply_p, 1) ;
+ if (req_p->flags & CY_AS_REQUEST_RESPONSE_MS) {
+ /*
+ * this request is only for the count of devices
+ * on the bus. there is no need to check the media type.
+ */
+ if (v)
+ *count = 1 ;
+ else
+ *count = 0 ;
+ } else {
+ /*
+ * this request is for the count of devices of a
+ * particular type. we need to check whether the media
+ * type found matches the queried type.
+ */
+ cy_as_media_type queried = (cy_as_media_type)
+ cy_as_ll_request_response__get_word(req_p, 1) ;
+ cy_as_media_type found =
+ cy_as_storage_get_media_from_address(v);
+
+ if (queried == found)
+ *count = 1 ;
+ else
+ *count = 0 ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+my_storage_query_bus(cy_as_device *dev_p,
+ cy_as_bus_number_t bus,
+ cy_as_media_type type,
+ uint16_t req_flags,
+ uint32_t *count,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_funct_c_b_type cb_type = CY_FUNCT_CB_STOR_QUERYBUS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Create the request to send to the Antioch device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_QUERY_BUS, CY_RQT_STORAGE_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, create_address(bus, 0, 0)) ;
+ cy_as_ll_request_response__set_word(req_p, 1, (uint16_t)type) ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed two words. */
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ req_p->flags |= req_flags;
+ return my_handle_response_storage_query_bus(dev_p,
+ req_p, reply_p, count) ;
+ } else {
+ if (req_flags == CY_AS_REQUEST_RESPONSE_EX)
+ cb_type = CY_FUNCT_CB_STOR_QUERYMEDIA ;
+
+ ret = cy_as_misc_send_request(dev_p, cb, client, cb_type,
+ count, dev_p->func_cbs_stor, req_flags,
+ req_p, reply_p, cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of
+ * the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_query_bus(cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t *count,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ return my_storage_query_bus(dev_p, bus, cy_as_media_max_media_value,
+ CY_AS_REQUEST_RESPONSE_MS, count, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_storage_query_media(cy_as_device_handle handle,
+ cy_as_media_type type,
+ uint32_t *count,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_bus_number_t bus ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ ret = cy_an_map_bus_from_media_type(dev_p, type, &bus) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ return my_storage_query_bus(dev_p, bus, type, CY_AS_REQUEST_RESPONSE_EX,
+ count, cb, client) ;
+}
+
+static cy_as_return_status_t
+my_handle_response_storage_query_device(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ void *data_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t v ;
+ cy_as_bus_number_t bus ;
+ cy_as_media_type type ;
+ uint32_t device ;
+ cy_bool removable ;
+ cy_bool writeable ;
+ cy_bool locked ;
+ uint16_t block_size ;
+ uint32_t number_units ;
+ uint32_t number_eus ;
+
+ if (cy_as_ll_request_response__get_code(reply_p)
+ == CY_RESP_NO_SUCH_ADDRESS) {
+ ret = cy_as_map_bad_addr(
+ cy_as_ll_request_response__get_word(reply_p, 3)) ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_DEVICE_DESCRIPTOR) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* Unpack the response */
+ v = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ type = cy_as_storage_get_media_from_address(v) ;
+ bus = cy_as_storage_get_bus_from_address(v) ;
+ device = cy_as_storage_get_device_from_address(v) ;
+
+ block_size = cy_as_ll_request_response__get_word(reply_p, 1) ;
+
+ v = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ removable = (v & 0x8000) ? cy_true : cy_false ;
+ writeable = (v & 0x0100) ? cy_true : cy_false ;
+ locked = (v & 0x0200) ? cy_true : cy_false ;
+ number_units = (v & 0xff) ;
+
+ number_eus = (cy_as_ll_request_response__get_word(reply_p, 3) << 16)
+ | cy_as_ll_request_response__get_word(reply_p, 4) ;
+
+ /* Store the results based on the version of originating function */
+ if (req_p->flags & CY_AS_REQUEST_RESPONSE_MS) {
+ cy_as_storage_query_device_data *store_p =
+ (cy_as_storage_query_device_data *)data_p ;
+
+ /* Make sure the response is about the address we asked
+ * about - if not, firmware error */
+ if ((bus != store_p->bus) || (device != store_p->device)) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ store_p->desc_p.type = type ;
+ store_p->desc_p.removable = removable ;
+ store_p->desc_p.writeable = writeable ;
+ store_p->desc_p.block_size = block_size ;
+ store_p->desc_p.number_units = number_units ;
+ store_p->desc_p.locked = locked ;
+ store_p->desc_p.erase_unit_size = number_eus ;
+ dev_p->storage_device_info[bus][device] = store_p->desc_p ;
+ } else {
+ cy_as_storage_query_device_data_dep *store_p =
+ (cy_as_storage_query_device_data_dep *)data_p ;
+
+ /* Make sure the response is about the address we asked
+ * about - if not, firmware error */
+ if ((type != store_p->type) || (device != store_p->device)) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ store_p->desc_p.type = type ;
+ store_p->desc_p.removable = removable ;
+ store_p->desc_p.writeable = writeable ;
+ store_p->desc_p.block_size = block_size ;
+ store_p->desc_p.number_units = number_units ;
+ store_p->desc_p.locked = locked ;
+ store_p->desc_p.erase_unit_size = number_eus ;
+ dev_p->storage_device_info[bus][device] = store_p->desc_p ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_storage_query_device(cy_as_device *dev_p,
+ void *data_p,
+ uint16_t req_flags,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Create the request to send to the Antioch device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_QUERY_DEVICE, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, device, 0)) ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed five words. */
+ reply_p = cy_as_ll_create_response(dev_p, 5) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ req_p->flags |= req_flags;
+ return my_handle_response_storage_query_device(dev_p,
+ req_p, reply_p, data_p) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_QUERYDEVICE, data_p,
+ dev_p->func_cbs_stor, req_flags, req_p,
+ reply_p, cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_query_device(cy_as_device_handle handle,
+ cy_as_storage_query_device_data *data_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ return my_storage_query_device(dev_p, data_p,
+ CY_AS_REQUEST_RESPONSE_MS, data_p->bus,
+ data_p->device, cb, client) ;
+}
+
+static cy_as_return_status_t
+my_handle_response_storage_query_unit(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ void *data_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_bus_number_t bus ;
+ uint32_t device ;
+ uint32_t unit ;
+ cy_as_media_type type ;
+ uint16_t block_size ;
+ uint32_t start_block ;
+ uint32_t unit_size ;
+ uint16_t v ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_NO_SUCH_ADDRESS) {
+ ret = cy_as_map_bad_addr(
+ cy_as_ll_request_response__get_word(reply_p, 3)) ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_UNIT_DESCRIPTOR) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* Unpack the response */
+ v = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ bus = cy_as_storage_get_bus_from_address(v) ;
+ device = cy_as_storage_get_device_from_address(v) ;
+ unit = get_unit_from_address(v) ;
+
+ type = cy_as_storage_get_media_from_address(
+ cy_as_ll_request_response__get_word(reply_p, 1));
+
+ block_size = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ start_block = cy_as_ll_request_response__get_word(reply_p, 3)
+ | (cy_as_ll_request_response__get_word(reply_p, 4) << 16) ;
+ unit_size = cy_as_ll_request_response__get_word(reply_p, 5)
+ | (cy_as_ll_request_response__get_word(reply_p, 6) << 16) ;
+
+ /* Store the results based on the version of
+ * originating function */
+ if (req_p->flags & CY_AS_REQUEST_RESPONSE_MS) {
+ cy_as_storage_query_unit_data *store_p =
+ (cy_as_storage_query_unit_data *)data_p ;
+
+ /* Make sure the response is about the address we
+ * asked about - if not, firmware error */
+ if (bus != store_p->bus || device != store_p->device ||
+ unit != store_p->unit) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ store_p->desc_p.type = type ;
+ store_p->desc_p.block_size = block_size ;
+ store_p->desc_p.start_block = start_block ;
+ store_p->desc_p.unit_size = unit_size ;
+ } else {
+ cy_as_storage_query_unit_data_dep *store_p =
+ (cy_as_storage_query_unit_data_dep *)data_p ;
+
+ /* Make sure the response is about the media type we asked
+ * about - if not, firmware error */
+ if ((type != store_p->type) || (device != store_p->device) ||
+ (unit != store_p->unit)) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ store_p->desc_p.type = type ;
+ store_p->desc_p.block_size = block_size ;
+ store_p->desc_p.start_block = start_block ;
+ store_p->desc_p.unit_size = unit_size ;
+ }
+
+ dev_p->storage_device_info[bus][device].type = type ;
+ dev_p->storage_device_info[bus][device].block_size = block_size ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_storage_query_unit(cy_as_device *dev_p,
+ void *data_p,
+ uint16_t req_flags,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint32_t unit,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_QUERY_UNIT, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ if (device > 255)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (unit > 255)
+ return CY_AS_ERROR_NO_SUCH_UNIT ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, device, (uint8_t)unit)) ;
+
+ /* Reserve space for the reply, the reply data
+ * will be of seven words. */
+ reply_p = cy_as_ll_create_response(dev_p, 7) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ req_p->flags |= req_flags ;
+ return my_handle_response_storage_query_unit(dev_p,
+ req_p, reply_p, data_p) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_QUERYUNIT, data_p,
+ dev_p->func_cbs_stor, req_flags, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_query_unit(cy_as_device_handle handle,
+ cy_as_storage_query_unit_data *data_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ return my_storage_query_unit(dev_p, data_p, CY_AS_REQUEST_RESPONSE_MS,
+ data_p->bus, data_p->device, data_p->unit, cb, client) ;
+}
+
+
+static cy_as_return_status_t
+cy_as_get_block_size(cy_as_device *dev_p,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_function_callback cb)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_QUERY_DEVICE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, device, 0)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 4) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p)
+ == CY_RESP_NO_SUCH_ADDRESS) {
+ ret = CY_AS_ERROR_NO_SUCH_BUS ;
+ goto destroy ;
+ }
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_DEVICE_DESCRIPTOR) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* Make sure the response is about the media type we asked
+ * about - if not, firmware error */
+ if ((cy_as_storage_get_bus_from_address
+ (cy_as_ll_request_response__get_word(reply_p, 0))
+ != bus) || (cy_as_storage_get_device_from_address
+ (cy_as_ll_request_response__get_word(reply_p, 0))
+ != device)) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+
+ dev_p->storage_device_info[bus][device].block_size =
+ cy_as_ll_request_response__get_word(reply_p, 1) ;
+ } else
+ ret = CY_AS_ERROR_INVALID_REQUEST ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+my_storage_device_control(
+ cy_as_device *dev_p,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_bool card_detect_en,
+ cy_bool write_prot_en,
+ cy_as_storage_card_detect config_detect,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret ;
+ cy_bool use_gpio = cy_false ;
+
+ (void)device ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ /* If SD is not supported on the specified bus,
+ * then return ERROR */
+ if ((dev_p->media_supported[bus] == 0) ||
+ (dev_p->media_supported[bus] & (1<<cy_as_media_nand)))
+ return CY_AS_ERROR_NOT_SUPPORTED;
+
+ if (config_detect == cy_as_storage_detect_GPIO)
+ use_gpio = cy_true ;
+ else if (config_detect == cy_as_storage_detect_SDAT_3)
+ use_gpio = cy_false ;
+ else
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SD_INTERFACE_CONTROL, CY_RQT_STORAGE_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, create_address(bus, device, 0)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 1, (((uint16_t)card_detect_en << 8) |
+ ((uint16_t)use_gpio << 1) | (uint16_t)write_prot_en)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ } else {
+
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_DEVICECONTROL,
+ 0, dev_p->func_cbs_stor, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_device_control(cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_bool card_detect_en,
+ cy_bool write_prot_en,
+ cy_as_storage_card_detect config_detect,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ return my_storage_device_control(dev_p, bus, device, card_detect_en,
+ write_prot_en, config_detect, cb, client);
+}
+
+static void
+cy_as_async_storage_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p, uint32_t size,
+ cy_as_return_status_t ret)
+{
+ cy_as_storage_callback_dep cb ;
+ cy_as_storage_callback cb_ms ;
+
+ (void)size ;
+ (void)buf_p ;
+ (void)ep ;
+
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+
+ /*
+ * if the LL request callback has already been called,
+ * the user callback has to be called from here.
+ */
+ if (!dev_p->storage_wait) {
+ cy_as_hal_assert(dev_p->storage_cb != NULL ||
+ dev_p->storage_cb_ms != NULL) ;
+ cb = dev_p->storage_cb ;
+ cb_ms = dev_p->storage_cb_ms ;
+
+ dev_p->storage_cb = 0 ;
+ dev_p->storage_cb_ms = 0 ;
+
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = dev_p->storage_error ;
+
+ if (cb_ms) {
+ cb_ms((cy_as_device_handle)dev_p,
+ dev_p->storage_bus_index,
+ dev_p->storage_device_index,
+ dev_p->storage_unit,
+ dev_p->storage_block_addr,
+ dev_p->storage_oper, ret) ;
+ } else {
+ cb((cy_as_device_handle)dev_p,
+ dev_p->storage_device_info
+ [dev_p->storage_bus_index]
+ [dev_p->storage_device_index].type,
+ dev_p->storage_device_index,
+ dev_p->storage_unit,
+ dev_p->storage_block_addr,
+ dev_p->storage_oper, ret) ;
+ }
+ } else
+ dev_p->storage_error = ret ;
+}
+
+static void
+cy_as_async_storage_reply_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ cy_as_storage_callback_dep cb ;
+ cy_as_storage_callback cb_ms ;
+ uint8_t reqtype ;
+ (void)rqt ;
+ (void)context ;
+
+ reqtype = cy_as_ll_request_response__get_code(rqt) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_ANTIOCH_DEFERRED_ERROR) {
+ ret = cy_as_ll_request_response__get_word
+ (resp, 0) & 0x00FF ;
+ } else if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (reqtype == CY_RQT_READ_BLOCK)
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_read_endpoint, ret) ;
+ else
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_write_endpoint, ret) ;
+ }
+
+ dev_p->storage_wait = cy_false ;
+
+ /*
+ * if the DMA callback has already been called, the
+ * user callback has to be called from here.
+ */
+ if (!cy_as_device_is_storage_async_pending(dev_p)) {
+ cy_as_hal_assert(dev_p->storage_cb != NULL ||
+ dev_p->storage_cb_ms != NULL) ;
+ cb = dev_p->storage_cb ;
+ cb_ms = dev_p->storage_cb_ms ;
+
+ dev_p->storage_cb = 0 ;
+ dev_p->storage_cb_ms = 0 ;
+
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = dev_p->storage_error ;
+
+ if (cb_ms) {
+ cb_ms((cy_as_device_handle)dev_p,
+ dev_p->storage_bus_index,
+ dev_p->storage_device_index,
+ dev_p->storage_unit,
+ dev_p->storage_block_addr,
+ dev_p->storage_oper, ret) ;
+ } else {
+ cb((cy_as_device_handle)dev_p,
+ dev_p->storage_device_info
+ [dev_p->storage_bus_index]
+ [dev_p->storage_device_index].type,
+ dev_p->storage_device_index,
+ dev_p->storage_unit,
+ dev_p->storage_block_addr,
+ dev_p->storage_oper, ret) ;
+ }
+ } else
+ dev_p->storage_error = ret ;
+}
+
+static cy_as_return_status_t
+cy_as_storage_async_oper(cy_as_device *dev_p, cy_as_end_point_number_t ep,
+ uint8_t reqtype, uint16_t req_flags, cy_as_bus_number_t bus,
+ uint32_t device, uint32_t unit, uint32_t block, void *data_p,
+ uint16_t num_blocks, cy_as_storage_callback_dep callback,
+ cy_as_storage_callback callback_ms)
+{
+ uint32_t mask ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (unit > 255)
+ return CY_AS_ERROR_NO_SUCH_UNIT ;
+
+ /* We are supposed to return sucess if the number of
+ * blocks is zero
+ */
+ if (num_blocks == 0) {
+ if (callback_ms)
+ callback_ms((cy_as_device_handle)dev_p,
+ bus, device, unit, block,
+ ((reqtype == CY_RQT_WRITE_BLOCK)
+ ? cy_as_op_write : cy_as_op_read),
+ CY_AS_ERROR_SUCCESS) ;
+ else
+ callback((cy_as_device_handle)dev_p,
+ dev_p->storage_device_info[bus][device].type,
+ device, unit, block,
+ ((reqtype == CY_RQT_WRITE_BLOCK) ?
+ cy_as_op_write : cy_as_op_read),
+ CY_AS_ERROR_SUCCESS) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+ }
+
+ if (dev_p->storage_device_info[bus][device].block_size == 0)
+ return CY_AS_ERROR_QUERY_DEVICE_NEEDED ;
+
+ /*
+ * since async operations can be triggered by interrupt
+ * code, we must insure that we do not get multiple
+ * async operations going at one time and protect this
+ * test and set operation from interrupts. also need to
+ * check for pending async MTP writes
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait) ||
+ (cy_as_device_is_usb_async_pending(dev_p, 6))) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+
+ cy_as_device_set_storage_async_pending(dev_p) ;
+ cy_as_device_clear_p2s_dma_start_recvd(dev_p) ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+ /*
+ * storage information about the currently outstanding request
+ */
+ dev_p->storage_cb = callback ;
+ dev_p->storage_cb_ms = callback_ms ;
+ dev_p->storage_bus_index = bus ;
+ dev_p->storage_device_index = device ;
+ dev_p->storage_unit = unit ;
+ dev_p->storage_block_addr = block ;
+
+ /* Initialise the request to send to the West Bridge. */
+ req_p = dev_p->storage_rw_req_p ;
+ cy_as_ll_init_request(req_p, reqtype, CY_RQT_STORAGE_RQT_CONTEXT, 5) ;
+
+ /* Initialise the space for reply from the West Bridge. */
+ reply_p = dev_p->storage_rw_resp_p ;
+ cy_as_ll_init_response(reply_p, 5) ;
+
+ /* Remember which version of the API originated the request */
+ req_p->flags |= req_flags ;
+
+ /* Setup the DMA request and adjust the storage
+ * operation if we are reading */
+ if (reqtype == CY_RQT_READ_BLOCK) {
+ ret = cy_as_dma_queue_request(dev_p, ep, data_p,
+ dev_p->storage_device_info[bus][device].block_size
+ * num_blocks, cy_false, cy_true,
+ cy_as_async_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_read ;
+ } else if (reqtype == CY_RQT_WRITE_BLOCK) {
+ ret = cy_as_dma_queue_request(dev_p, ep, data_p,
+ dev_p->storage_device_info[bus][device].block_size *
+ num_blocks, cy_false, cy_false,
+ cy_as_async_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_write ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ return ret ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, create_address(bus, (uint8_t)device, (uint8_t)unit)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 1, (uint16_t)((block >> 16) & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 2, (uint16_t)(block & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 3, (uint16_t)((num_blocks >> 8) & 0x00ff)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 4, (uint16_t)((num_blocks << 8) & 0xff00)) ;
+
+ /* Set the burst mode flag. */
+ if (dev_p->is_storage_only_mode)
+ req_p->data[4] |= 0x0001;
+
+ /* Send the request and wait for completion
+ * of storage request */
+ dev_p->storage_wait = cy_true ;
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_true, cy_as_async_storage_reply_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ }
+
+ return ret ;
+}
+
+static void
+cy_as_sync_storage_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p,
+ uint32_t size, cy_as_return_status_t err)
+{
+ (void)ep ;
+ (void)buf_p ;
+ (void)size ;
+
+ dev_p->storage_error = err ;
+}
+
+static void
+cy_as_sync_storage_reply_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ uint8_t reqtype ;
+ (void)rqt ;
+
+ reqtype = cy_as_ll_request_response__get_code(rqt) ;
+
+ if (cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_ANTIOCH_DEFERRED_ERROR) {
+ ret = cy_as_ll_request_response__get_word(resp, 0) & 0x00FF ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (reqtype == CY_RQT_READ_BLOCK)
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_read_endpoint, ret) ;
+ else
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_write_endpoint, ret) ;
+ }
+ } else if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+
+ dev_p->storage_wait = cy_false ;
+ dev_p->storage_error = ret ;
+
+ /* Wake any threads/processes that are waiting on
+ * the read/write completion. */
+ cy_as_hal_wake(&dev_p->context[context]->channel) ;
+}
+
+static cy_as_return_status_t
+cy_as_storage_sync_oper(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, uint8_t reqtype,
+ cy_as_bus_number_t bus, uint32_t device,
+ uint32_t unit, uint32_t block, void *data_p,
+ uint16_t num_blocks)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_context *ctxt_p ;
+ uint32_t loopcount = 200 ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (unit > 255)
+ return CY_AS_ERROR_NO_SUCH_UNIT ;
+
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ /* Also need to check for pending Async MTP writes */
+ if (cy_as_device_is_usb_async_pending(dev_p, 6))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ /* We are supposed to return sucess if the number of
+ * blocks is zero
+ */
+ if (num_blocks == 0)
+ return CY_AS_ERROR_SUCCESS ;
+
+ if (dev_p->storage_device_info[bus][device].block_size == 0) {
+ /*
+ * normally, a given device has been queried via
+ * the query device call before a read request is issued.
+ * therefore, this normally will not be run.
+ */
+ ret = cy_as_get_block_size(dev_p, bus, device, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ /* Initialise the request to send to the West Bridge. */
+ req_p = dev_p->storage_rw_req_p ;
+ cy_as_ll_init_request(req_p, reqtype,
+ CY_RQT_STORAGE_RQT_CONTEXT, 5) ;
+
+ /* Initialise the space for reply from
+ * the West Bridge. */
+ reply_p = dev_p->storage_rw_resp_p ;
+ cy_as_ll_init_response(reply_p, 5) ;
+ cy_as_device_clear_p2s_dma_start_recvd(dev_p) ;
+
+ /* Setup the DMA request */
+ if (reqtype == CY_RQT_READ_BLOCK) {
+ ret = cy_as_dma_queue_request(dev_p, ep, data_p,
+ dev_p->storage_device_info[bus][device].block_size *
+ num_blocks, cy_false,
+ cy_true, cy_as_sync_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_read ;
+ } else if (reqtype == CY_RQT_WRITE_BLOCK) {
+ ret = cy_as_dma_queue_request(dev_p, ep, data_p,
+ dev_p->storage_device_info[bus][device].block_size *
+ num_blocks, cy_false, cy_false,
+ cy_as_sync_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_write ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, (uint8_t)unit)) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((block >> 16) & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(block & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p, 3,
+ (uint16_t)((num_blocks >> 8) & 0x00ff)) ;
+ cy_as_ll_request_response__set_word(req_p, 4,
+ (uint16_t)((num_blocks << 8) & 0xff00)) ;
+
+ /* Set the burst mode flag. */
+ if (dev_p->is_storage_only_mode)
+ req_p->data[4] |= 0x0001;
+
+ /* Send the request and wait for
+ * completion of storage request */
+ dev_p->storage_wait = cy_true ;
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p, cy_true,
+ cy_as_sync_storage_reply_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ } else {
+ /* Setup the DMA request */
+ ctxt_p = dev_p->context[CY_RQT_STORAGE_RQT_CONTEXT] ;
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_false) ;
+
+ while (loopcount-- > 0) {
+ if (dev_p->storage_wait == cy_false)
+ break ;
+ cy_as_hal_sleep_on(&ctxt_p->channel, 10) ;
+ }
+
+ if (dev_p->storage_wait == cy_true) {
+ dev_p->storage_wait = cy_false ;
+ cy_as_ll_remove_request(dev_p, ctxt_p, req_p, cy_true) ;
+ ret = CY_AS_ERROR_TIMEOUT ;
+ }
+
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = dev_p->storage_error ;
+ }
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_read(cy_as_device_handle handle,
+ cy_as_bus_number_t bus, uint32_t device,
+ uint32_t unit, uint32_t block,
+ void *data_p, uint16_t num_blocks)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ return cy_as_storage_sync_oper(dev_p, dev_p->storage_read_endpoint,
+ CY_RQT_READ_BLOCK, bus, device,
+ unit, block, data_p, num_blocks) ;
+}
+
+cy_as_return_status_t
+cy_as_storage_write(cy_as_device_handle handle,
+ cy_as_bus_number_t bus, uint32_t device,
+ uint32_t unit, uint32_t block, void *data_p,
+ uint16_t num_blocks)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (dev_p->mtp_turbo_active)
+ return CY_AS_ERROR_NOT_VALID_DURING_MTP ;
+
+ return cy_as_storage_sync_oper(dev_p,
+ dev_p->storage_write_endpoint,
+ CY_RQT_WRITE_BLOCK, bus, device,
+ unit, block, data_p, num_blocks) ;
+}
+
+
+cy_as_return_status_t
+cy_as_storage_read_async(cy_as_device_handle handle,
+ cy_as_bus_number_t bus, uint32_t device, uint32_t unit,
+ uint32_t block, void *data_p, uint16_t num_blocks,
+ cy_as_storage_callback callback)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (callback == 0)
+ return CY_AS_ERROR_NULL_CALLBACK ;
+
+ return cy_as_storage_async_oper(dev_p,
+ dev_p->storage_read_endpoint, CY_RQT_READ_BLOCK,
+ CY_AS_REQUEST_RESPONSE_MS, bus, device, unit,
+ block, data_p, num_blocks, NULL, callback);
+}
+
+cy_as_return_status_t
+cy_as_storage_write_async(cy_as_device_handle handle,
+ cy_as_bus_number_t bus, uint32_t device, uint32_t unit,
+ uint32_t block, void *data_p, uint16_t num_blocks,
+ cy_as_storage_callback callback)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (callback == 0)
+ return CY_AS_ERROR_NULL_CALLBACK ;
+
+ if (dev_p->mtp_turbo_active)
+ return CY_AS_ERROR_NOT_VALID_DURING_MTP ;
+
+ return cy_as_storage_async_oper(dev_p,
+ dev_p->storage_write_endpoint, CY_RQT_WRITE_BLOCK,
+ CY_AS_REQUEST_RESPONSE_MS, bus, device, unit, block,
+ data_p, num_blocks, NULL, callback);
+}
+
+
+static void
+my_storage_cancel_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ (void)context ;
+ (void)stat ;
+
+ /* Nothing to do here, except free up the
+ * request and response structures. */
+ cy_as_ll_destroy_response(dev_p, resp) ;
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+}
+
+
+cy_as_return_status_t
+cy_as_storage_cancel_async(cy_as_device_handle handle)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (!cy_as_device_is_storage_async_pending(dev_p))
+ return CY_AS_ERROR_ASYNC_NOT_PENDING ;
+
+ /*
+ * create and send a mailbox request to firmware
+ * asking it to abort processing of the current
+ * P2S operation. the rest of the cancel processing will be
+ * driven through the callbacks for the read/write call.
+ */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_ABORT_P2S_XFER,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ ret = cy_as_ll_send_request(dev_p, req_p,
+ reply_p, cy_false, my_storage_cancel_callback) ;
+ if (ret) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+ * This function does all the API side clean-up associated with
+ * CyAsStorageStop, without any communication with the firmware.
+ */
+void cy_as_storage_cleanup(cy_as_device *dev_p)
+{
+ if (dev_p->storage_count) {
+ cy_as_ll_destroy_request(dev_p, dev_p->storage_rw_req_p) ;
+ cy_as_ll_destroy_response(dev_p, dev_p->storage_rw_resp_p) ;
+ dev_p->storage_count = 0 ;
+ cy_as_device_clear_scsi_messages(dev_p) ;
+ cy_as_hal_mem_set(dev_p->storage_device_info,
+ 0, sizeof(dev_p->storage_device_info)) ;
+
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ dev_p->storage_cb = 0 ;
+ dev_p->storage_cb_ms = 0 ;
+ dev_p->storage_wait = cy_false ;
+ }
+}
+
+static cy_as_return_status_t
+my_handle_response_sd_reg_read(
+ cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_storage_sd_reg_read_data *info)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t resp_type, i ;
+ uint16_t resp_len ;
+ uint8_t length = info->length ;
+ uint8_t *data_p = info->buf_p ;
+
+ resp_type = cy_as_ll_request_response__get_code(reply_p) ;
+ if (resp_type == CY_RESP_SD_REGISTER_DATA) {
+ uint16_t *resp_p = reply_p->data + 1 ;
+ uint16_t temp ;
+
+ resp_len = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ cy_as_hal_assert(resp_len >= length) ;
+
+ /*
+ * copy the values into the output buffer after doing the
+ * necessary bit shifting. the bit shifting is required because
+ * the data comes out of the west bridge with a 6 bit offset.
+ */
+ i = 0 ;
+ while (length) {
+ temp = ((resp_p[i] << 6) | (resp_p[i + 1] >> 10)) ;
+ i++ ;
+
+ *data_p++ = (uint8_t)(temp >> 8) ;
+ length-- ;
+
+ if (length) {
+ *data_p++ = (uint8_t)(temp & 0xFF) ;
+ length-- ;
+ }
+ }
+ } else {
+ if (resp_type == CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_sd_register_read(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint8_t device,
+ cy_as_sd_card_reg_type reg_type,
+ cy_as_storage_sd_reg_read_data *data_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t length ;
+
+ /*
+ * sanity checks required before sending the request to the
+ * firmware.
+ */
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (reg_type > cy_as_sd_reg_CSD)
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ /* If SD/MMC media is not supported on the
+ * addressed bus, return error. */
+ if ((dev_p->media_supported[bus] & (1 << cy_as_media_sd_flash)) == 0)
+ return CY_AS_ERROR_INVALID_PARAMETER ;
+
+ /*
+ * find the amount of data to be returned. this will be the minimum of
+ * the actual data length, and the length requested.
+ */
+ switch (reg_type) {
+ case cy_as_sd_reg_OCR:
+ length = CY_AS_SD_REG_OCR_LENGTH ;
+ break ;
+ case cy_as_sd_reg_CID:
+ length = CY_AS_SD_REG_CID_LENGTH ;
+ break ;
+ case cy_as_sd_reg_CSD:
+ length = CY_AS_SD_REG_CSD_LENGTH ;
+ break ;
+
+ default:
+ length = 0 ;
+ cy_as_hal_assert(0) ;
+ }
+
+ if (length < data_p->length)
+ data_p->length = length ;
+ length = data_p->length ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SD_REGISTER_READ,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (create_address(bus, device, 0) | (uint16_t)reg_type)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p,
+ CY_AS_SD_REG_MAX_RESP_LENGTH) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_sd_reg_read(dev_p,
+ req_p, reply_p, data_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_SDREGISTERREAD, data_p,
+ dev_p->func_cbs_stor, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * MiscFuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_create_p_partition(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ /* of P-port only partition in blocks */
+ uint32_t size,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Partitions cannot be created or deleted while
+ * the USB stack is active. */
+ if (dev_p->usb_count)
+ return CY_AS_ERROR_USB_RUNNING ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_PARTITION_STORAGE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 3) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, 0x00));
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((size >> 16) & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(size & 0xffff)) ;
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_no_data(dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_PARTITION, 0, dev_p->func_cbs_stor,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * FuncCallback */
+ return ret ;
+
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_remove_p_partition(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Partitions cannot be created or deleted while
+ * the USB stack is active. */
+ if (dev_p->usb_count)
+ return CY_AS_ERROR_USB_RUNNING ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_PARTITION_ERASE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, create_address(bus, (uint8_t)device, 0x00));
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_no_data(dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_NODATA, 0, dev_p->func_cbs_stor,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the FuncCallback */
+ return ret ;
+
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_get_transfer_amount(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_m_s_c_progress_data *data)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code = cy_as_ll_request_response__get_code(reply_p) ;
+ uint16_t v1, v2 ;
+
+ if (code != CY_RESP_TRANSFER_COUNT) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ v1 = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ v2 = cy_as_ll_request_response__get_word(reply_p, 1) ;
+ data->wr_count = (uint32_t)((v1 << 16) | v2) ;
+
+ v1 = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ v2 = cy_as_ll_request_response__get_word(reply_p, 3) ;
+ data->rd_count = (uint32_t)((v1 << 16) | v2) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_storage_get_transfer_amount(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_m_s_c_progress_data *data_p,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* Check if the firmware image supports this feature. */
+ if ((dev_p->media_supported[0]) && (dev_p->media_supported[0]
+ == (1 << cy_as_media_nand)))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_GET_TRANSFER_AMOUNT,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed four words. */
+ reply_p = cy_as_ll_create_response(dev_p, 4) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, 0x00));
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_get_transfer_amount(dev_p,
+ req_p, reply_p, data_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_GETTRANSFERAMOUNT, (void *)data_p,
+ dev_p->func_cbs_stor, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed as part of the
+ * FuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+
+}
+
+cy_as_return_status_t
+cy_as_storage_erase(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint32_t erase_unit,
+ uint16_t num_erase_units,
+ cy_as_function_callback cb,
+ uint32_t client
+ )
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_storage_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (dev_p->storage_device_info[bus][device].block_size == 0)
+ return CY_AS_ERROR_QUERY_DEVICE_NEEDED ;
+
+ /* If SD is not supported on the specified bus, then return ERROR */
+ if (dev_p->storage_device_info[bus][device].type !=
+ cy_as_media_sd_flash)
+ return CY_AS_ERROR_NOT_SUPPORTED;
+
+ if (num_erase_units == 0)
+ return CY_AS_ERROR_SUCCESS ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_ERASE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 5) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed four words. */
+ reply_p = cy_as_ll_create_response(dev_p, 4) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, 0x00));
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((erase_unit >> 16) & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(erase_unit & 0xffff)) ;
+ cy_as_ll_request_response__set_word(req_p, 3,
+ (uint16_t)((num_erase_units >> 8) & 0x00ff)) ;
+ cy_as_ll_request_response__set_word(req_p, 4,
+ (uint16_t)((num_erase_units << 8) & 0xff00)) ;
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = my_handle_response_no_data(dev_p, req_p, reply_p) ;
+
+ /* If error = "invalid response", this (very likely) means
+ * that we are not using the SD-only firmware module which
+ * is the only one supporting storage_erase. in this case
+ * force a "non supported" error code */
+ if (ret == CY_AS_ERROR_INVALID_RESPONSE)
+ ret = CY_AS_ERROR_NOT_SUPPORTED;
+
+ return ret ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_STOR_ERASE, 0, dev_p->func_cbs_stor,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_storage_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* The request and response are freed
+ * as part of the FuncCallback */
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static void
+cy_as_storage_func_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ cy_as_func_c_b_node *node = (cy_as_func_c_b_node *)
+ dev_p->func_cbs_stor->head_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_bool ex_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_EX)
+ == CY_AS_REQUEST_RESPONSE_EX ;
+ cy_bool ms_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_MS)
+ == CY_AS_REQUEST_RESPONSE_MS ;
+ uint8_t code ;
+ uint8_t cntxt ;
+
+ cy_as_hal_assert(ex_request || ms_request) ;
+ cy_as_hal_assert(dev_p->func_cbs_stor->count != 0) ;
+ cy_as_hal_assert(dev_p->func_cbs_stor->type == CYAS_FUNC_CB) ;
+ (void) ex_request;
+ (void) ms_request;
+
+ (void)context ;
+
+ cntxt = cy_as_ll_request_response__get_context(rqt) ;
+ cy_as_hal_assert(cntxt == CY_RQT_STORAGE_RQT_CONTEXT) ;
+
+ code = cy_as_ll_request_response__get_code(rqt) ;
+ switch (code) {
+ case CY_RQT_START_STORAGE:
+ ret = my_handle_response_storage_start(dev_p, rqt, resp, stat) ;
+ break ;
+ case CY_RQT_STOP_STORAGE:
+ ret = my_handle_response_storage_stop(dev_p, rqt, resp, stat) ;
+ break ;
+ case CY_RQT_CLAIM_STORAGE:
+ ret = my_handle_response_storage_claim(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_RELEASE_STORAGE:
+ ret = my_handle_response_storage_release(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_QUERY_MEDIA:
+ cy_as_hal_assert(cy_false) ;/* Not used any more. */
+ break ;
+ case CY_RQT_QUERY_BUS:
+ cy_as_hal_assert(node->data != 0) ;
+ ret = my_handle_response_storage_query_bus(dev_p,
+ rqt, resp, (uint32_t *)node->data) ;
+ break ;
+ case CY_RQT_QUERY_DEVICE:
+ cy_as_hal_assert(node->data != 0) ;
+ ret = my_handle_response_storage_query_device(dev_p,
+ rqt, resp, node->data) ;
+ break ;
+ case CY_RQT_QUERY_UNIT:
+ cy_as_hal_assert(node->data != 0) ;
+ ret = my_handle_response_storage_query_unit(dev_p,
+ rqt, resp, node->data) ;
+ break ;
+ case CY_RQT_SD_INTERFACE_CONTROL:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_SD_REGISTER_READ:
+ cy_as_hal_assert(node->data != 0) ;
+ ret = my_handle_response_sd_reg_read(dev_p, rqt, resp,
+ (cy_as_storage_sd_reg_read_data *)node->data) ;
+ break ;
+ case CY_RQT_PARTITION_STORAGE:
+ ret = my_handle_response_no_data(dev_p, rqt, resp);
+ break ;
+ case CY_RQT_PARTITION_ERASE:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_GET_TRANSFER_AMOUNT:
+ cy_as_hal_assert(node->data != 0) ;
+ ret = my_handle_response_get_transfer_amount(dev_p,
+ rqt, resp, (cy_as_m_s_c_progress_data *)node->data) ;
+ break ;
+ case CY_RQT_ERASE:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+
+ /* If error = "invalid response", this (very likely)
+ * means that we are not using the SD-only firmware
+ * module which is the only one supporting storage_erase.
+ * in this case force a "non supported" error code */
+ if (ret == CY_AS_ERROR_INVALID_RESPONSE)
+ ret = CY_AS_ERROR_NOT_SUPPORTED;
+
+ break ;
+
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /*
+ * if the low level layer returns a direct error, use the
+ * corresponding error code. if not, use the error code
+ * based on the response from firmware.
+ */
+ if (stat == CY_AS_ERROR_SUCCESS)
+ stat = ret ;
+
+ /* Call the user callback, if there is one */
+ if (node->cb_p)
+ node->cb_p((cy_as_device_handle)dev_p, stat,
+ node->client_data, node->data_type, node->data) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_stor) ;
+}
+
+
+static void
+cy_as_sdio_sync_reply_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ (void)rqt ;
+
+ if ((cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_SDIO_GET_TUPLE) ||
+ (cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_SDIO_EXT)) {
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ if ((ret & 0x00FF) != CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(rqt) ==
+ CY_RQT_SDIO_READ_EXTENDED)
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_read_endpoint, ret) ;
+ else
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_write_endpoint, ret) ;
+ }
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+
+ dev_p->storage_rw_resp_p = resp;
+ dev_p->storage_wait = cy_false ;
+ if (((ret & 0x00FF) == CY_AS_ERROR_IO_ABORTED) || ((ret & 0x00FF)
+ == CY_AS_ERROR_IO_SUSPENDED))
+ dev_p->storage_error = (ret & 0x00FF);
+ else
+ dev_p->storage_error = (ret & 0x00FF) ?
+ CY_AS_ERROR_INVALID_RESPONSE : CY_AS_ERROR_SUCCESS ;
+
+ /* Wake any threads/processes that are waiting on
+ * the read/write completion. */
+ cy_as_hal_wake(&dev_p->context[context]->channel);
+}
+
+cy_as_return_status_t
+cy_as_sdio_device_check(
+ cy_as_device *dev_p,
+ cy_as_bus_number_t bus,
+ uint32_t device)
+{
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (bus < 0 || bus >= CY_AS_MAX_BUSES)
+ return CY_AS_ERROR_NO_SUCH_BUS ;
+
+ if (device >= CY_AS_MAX_STORAGE_DEVICES)
+ return CY_AS_ERROR_NO_SUCH_DEVICE ;
+
+ if (!cy_as_device_is_astoria_dev(dev_p))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ return (is_storage_active(dev_p)) ;
+}
+
+cy_as_return_status_t
+cy_as_sdio_direct_io(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t is_write,
+ uint8_t *data_p)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t resp_data;
+
+ /*
+ * sanity checks required before sending the request to the
+ * firmware.
+ */
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+
+ if (!(cy_as_sdio_check_function_initialized(handle,
+ bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (cy_as_sdio_check_function_suspended(handle, bus, n_function_no))
+ return CY_AS_ERROR_FUNCTION_SUSPENDED;
+
+ req_p = cy_as_ll_create_request(dev_p, (is_write == cy_true) ?
+ CY_RQT_SDIO_WRITE_DIRECT : CY_RQT_SDIO_READ_DIRECT,
+ CY_RQT_STORAGE_RQT_CONTEXT, 3) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*Setting up request*/
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+ /* D1 */
+ if (is_write == cy_true) {
+ cy_as_ll_request_response__set_word(req_p, 1,
+ ((argument<<8) | 0x0080 | (n_function_no<<4) |
+ ((misc_buf&CY_SDIO_RAW)<<3) |
+ ((misc_buf&CY_SDIO_REARM_INT)>>5) |
+ (uint16_t)(address>>15)));
+ } else {
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (n_function_no<<4) | ((misc_buf&CY_SDIO_REARM_INT)>>5) |
+ (uint16_t)(address>>15));
+ }
+ /* D2 */
+ cy_as_ll_request_response__set_word(req_p, 2,
+ ((uint16_t)((address&0x00007fff)<<1))) ;
+
+ /*Create response*/
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /*Sending the request*/
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /*Check reply type*/
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SDIO_DIRECT) {
+ resp_data = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (resp_data >> 8)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else if (data_p != 0)
+ *(uint8_t *)(data_p) = (uint8_t)(resp_data&0x00ff);
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+
+destroy:
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_sdio_direct_read(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint8_t *data_p)
+{
+ return cy_as_sdio_direct_io(handle, bus, device, n_function_no,
+ address, misc_buf, 0x00, cy_false, data_p);
+}
+
+cy_as_return_status_t
+cy_as_sdio_direct_write(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t *data_p)
+{
+ return cy_as_sdio_direct_io(handle, bus, device, n_function_no,
+ address, misc_buf, argument, cy_true, data_p);
+}
+
+/*Cmd53 IO*/
+cy_as_return_status_t
+cy_as_sdio_extended_i_o(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t is_write,
+ uint8_t *data_p ,
+ uint8_t is_resume)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t resp_type;
+ uint8_t reqtype;
+ uint16_t resp_data;
+ cy_as_context *ctxt_p ;
+ uint32_t dmasize, loopcount = 200;
+ cy_as_end_point_number_t ep;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle,
+ bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (cy_as_sdio_check_function_suspended(handle, bus, n_function_no))
+ return CY_AS_ERROR_FUNCTION_SUSPENDED;
+
+
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+ /* Request for 0 bytes of blocks is returned as a success*/
+ if (argument == 0)
+ return CY_AS_ERROR_SUCCESS;
+
+ /* Initialise the request to send to the West Bridge device. */
+ if (is_write == cy_true) {
+ reqtype = CY_RQT_SDIO_WRITE_EXTENDED;
+ ep = dev_p->storage_write_endpoint;
+ } else {
+ reqtype = CY_RQT_SDIO_READ_EXTENDED;
+ ep = dev_p->storage_read_endpoint;
+ }
+
+ req_p = dev_p->storage_rw_req_p ;
+ cy_as_ll_init_request(req_p, reqtype, CY_RQT_STORAGE_RQT_CONTEXT, 3) ;
+
+ /* Initialise the space for reply from the Antioch. */
+ reply_p = dev_p->storage_rw_resp_p ;
+ cy_as_ll_init_response(reply_p, 2) ;
+
+ /* Setup the DMA request */
+ if (!(misc_buf&CY_SDIO_BLOCKMODE)) {
+ if (argument >
+ dev_p->sdiocard[bus].
+ function[n_function_no-1].blocksize)
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+
+ } else {
+ if (argument > 511)
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+ }
+
+ if (argument == 512)
+ argument = 0;
+
+ dmasize = ((misc_buf&CY_SDIO_BLOCKMODE) != 0) ?
+ dev_p->sdiocard[bus].function[n_function_no-1].blocksize
+ * argument : argument;
+
+ ret = cy_as_dma_queue_request(dev_p, ep, (void *)(data_p),
+ dmasize, cy_false, (is_write & cy_true) ? cy_false :
+ cy_true, cy_as_sync_storage_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device,
+ n_function_no | ((is_resume) ? 0x80 : 0x00))) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ ((uint16_t)n_function_no)<<12|
+ ((uint16_t)(misc_buf & (CY_SDIO_BLOCKMODE|CY_SDIO_OP_INCR)))
+ << 9 | (uint16_t)(address >> 7) |
+ ((is_write == cy_true) ? 0x8000 : 0x0000)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ ((uint16_t)(address&0x0000ffff) << 9) | argument) ;
+
+
+ /* Send the request and wait for completion of storage request */
+ dev_p->storage_wait = cy_true ;
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_true, cy_as_sdio_sync_reply_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ } else {
+ /* Setup the DMA request */
+ ctxt_p = dev_p->context[CY_RQT_STORAGE_RQT_CONTEXT] ;
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_true) ;
+
+ while (loopcount-- > 0) {
+ if (dev_p->storage_wait == cy_false)
+ break;
+ cy_as_hal_sleep_on(&ctxt_p->channel, 10) ;
+ }
+ if (dev_p->storage_wait == cy_true) {
+ dev_p->storage_wait = cy_false ;
+ cy_as_ll_remove_request(dev_p, ctxt_p, req_p, cy_true) ;
+ dev_p->storage_error = CY_AS_ERROR_TIMEOUT ;
+ }
+
+ ret = dev_p->storage_error;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ resp_type = cy_as_ll_request_response__get_code(
+ dev_p->storage_rw_resp_p) ;
+ if (resp_type == CY_RESP_SDIO_EXT) {
+ resp_data = cy_as_ll_request_response__get_word
+ (reply_p, 0)&0x00ff ;
+ if (resp_data)
+ ret = CY_AS_ERROR_INVALID_REQUEST ;
+
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+ }
+ return ret;
+
+}
+
+static void
+cy_as_sdio_async_reply_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ cy_as_storage_callback cb_ms ;
+ uint8_t reqtype ;
+ uint32_t pendingblocks;
+ (void)rqt ;
+ (void)context ;
+
+ pendingblocks = 0;
+ reqtype = cy_as_ll_request_response__get_code(rqt) ;
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if ((cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_SUCCESS_FAILURE) ||
+ (cy_as_ll_request_response__get_code(resp) ==
+ CY_RESP_SDIO_EXT)) {
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ ret &= 0x00FF ;
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (reqtype == CY_RQT_SDIO_READ_EXTENDED)
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_read_endpoint, ret) ;
+ else
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_write_endpoint, ret) ;
+
+ dev_p->storage_error = ret;
+ }
+
+ dev_p->storage_wait = cy_false ;
+
+ /*
+ * if the DMA callback has already been called,
+ * the user callback has to be called from here.
+ */
+ if (!cy_as_device_is_storage_async_pending(dev_p)) {
+ cy_as_hal_assert(dev_p->storage_cb_ms != NULL) ;
+ cb_ms = dev_p->storage_cb_ms ;
+
+ dev_p->storage_cb = 0 ;
+ dev_p->storage_cb_ms = 0 ;
+
+ if ((ret == CY_AS_ERROR_SUCCESS) ||
+ (ret == CY_AS_ERROR_IO_ABORTED) ||
+ (ret == CY_AS_ERROR_IO_SUSPENDED)) {
+ ret = dev_p->storage_error ;
+ pendingblocks = ((uint32_t)
+ cy_as_ll_request_response__get_word
+ (resp, 1)) << 16;
+ } else
+ ret = CY_AS_ERROR_INVALID_RESPONSE;
+
+ cb_ms((cy_as_device_handle)dev_p, dev_p->storage_bus_index,
+ dev_p->storage_device_index,
+ (dev_p->storage_unit | pendingblocks),
+ dev_p->storage_block_addr, dev_p->storage_oper, ret) ;
+ } else
+ dev_p->storage_error = ret ;
+}
+
+
+cy_as_return_status_t
+cy_as_sdio_extended_i_o_async(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t is_write,
+ uint8_t *data_p,
+ cy_as_storage_callback callback)
+{
+
+ uint32_t mask ;
+ uint32_t dmasize;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ uint8_t reqtype;
+ cy_as_end_point_number_t ep;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle,
+ bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (cy_as_sdio_check_function_suspended(handle, bus, n_function_no))
+ return CY_AS_ERROR_FUNCTION_SUSPENDED;
+
+ if (callback == 0)
+ return CY_AS_ERROR_NULL_CALLBACK ;
+
+ /* We are supposed to return sucess if the number of
+ * blocks is zero
+ */
+ if (((misc_buf&CY_SDIO_BLOCKMODE) != 0) && (argument == 0)) {
+ callback(handle, bus, device, n_function_no, address,
+ ((is_write) ? cy_as_op_write : cy_as_op_read),
+ CY_AS_ERROR_SUCCESS) ;
+ return CY_AS_ERROR_SUCCESS ;
+ }
+
+
+ /*
+ * since async operations can be triggered by interrupt
+ * code, we must insure that we do not get multiple async
+ * operations going at one time and protect this test and
+ * set operation from interrupts.
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait)) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+ cy_as_device_set_storage_async_pending(dev_p) ;
+ cy_as_hal_enable_interrupts(mask) ;
+
+
+ /*
+ * storage information about the currently
+ * outstanding request
+ */
+ dev_p->storage_cb_ms = callback ;
+ dev_p->storage_bus_index = bus ;
+ dev_p->storage_device_index = device ;
+ dev_p->storage_unit = n_function_no ;
+ dev_p->storage_block_addr = address ;
+
+ if (is_write == cy_true) {
+ reqtype = CY_RQT_SDIO_WRITE_EXTENDED;
+ ep = dev_p->storage_write_endpoint;
+ } else {
+ reqtype = CY_RQT_SDIO_READ_EXTENDED;
+ ep = dev_p->storage_read_endpoint;
+ }
+
+ /* Initialise the request to send to the West Bridge. */
+ req_p = dev_p->storage_rw_req_p ;
+ cy_as_ll_init_request(req_p, reqtype,
+ CY_RQT_STORAGE_RQT_CONTEXT, 3) ;
+
+ /* Initialise the space for reply from the West Bridge. */
+ reply_p = dev_p->storage_rw_resp_p ;
+ cy_as_ll_init_response(reply_p, 2) ;
+
+ if (!(misc_buf&CY_SDIO_BLOCKMODE)) {
+ if (argument >
+ dev_p->sdiocard[bus].function[n_function_no-1].blocksize)
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+
+ } else {
+ if (argument > 511)
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+ }
+
+ if (argument == 512)
+ argument = 0;
+ dmasize = ((misc_buf&CY_SDIO_BLOCKMODE) != 0) ?
+ dev_p->sdiocard[bus].function[n_function_no-1].blocksize *
+ argument : argument;
+
+ /* Setup the DMA request and adjust the storage
+ * operation if we are reading */
+ if (reqtype == CY_RQT_SDIO_READ_EXTENDED) {
+ ret = cy_as_dma_queue_request(dev_p, ep,
+ (void *)data_p, dmasize , cy_false, cy_true,
+ cy_as_async_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_read ;
+ } else if (reqtype == CY_RQT_SDIO_WRITE_EXTENDED) {
+ ret = cy_as_dma_queue_request(dev_p, ep, (void *)data_p,
+ dmasize, cy_false, cy_false, cy_as_async_storage_callback) ;
+ dev_p->storage_oper = cy_as_op_write ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ return ret ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ ((uint16_t)n_function_no) << 12 |
+ ((uint16_t)(misc_buf & (CY_SDIO_BLOCKMODE | CY_SDIO_OP_INCR)))
+ << 9 | (uint16_t)(address>>7) |
+ ((is_write == cy_true) ? 0x8000 : 0x0000)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ ((uint16_t)(address&0x0000ffff) << 9) | argument) ;
+
+
+ /* Send the request and wait for completion of storage request */
+ dev_p->storage_wait = cy_true ;
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p, cy_true,
+ cy_as_sdio_async_reply_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ cy_as_device_clear_storage_async_pending(dev_p) ;
+ } else {
+ cy_as_dma_kick_start(dev_p, ep) ;
+ }
+
+ return ret ;
+}
+
+/* CMD53 Extended Read*/
+cy_as_return_status_t
+cy_as_sdio_extended_read(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t *data_p,
+ cy_as_sdio_callback callback)
+{
+ if (callback == 0)
+ return cy_as_sdio_extended_i_o(handle, bus, device,
+ n_function_no, address, misc_buf, argument,
+ cy_false, data_p, 0);
+
+ return cy_as_sdio_extended_i_o_async(handle, bus, device,
+ n_function_no, address, misc_buf, argument, cy_false,
+ data_p, callback);
+}
+
+/* CMD53 Extended Write*/
+cy_as_return_status_t
+cy_as_sdio_extended_write(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint32_t address,
+ uint8_t misc_buf,
+ uint16_t argument,
+ uint8_t *data_p,
+ cy_as_sdio_callback callback)
+{
+ if (callback == 0)
+ return cy_as_sdio_extended_i_o(handle, bus, device,
+ n_function_no, address, misc_buf, argument, cy_true,
+ data_p, 0);
+
+ return cy_as_sdio_extended_i_o_async(handle, bus, device,
+ n_function_no, address, misc_buf, argument, cy_true,
+ data_p, callback);
+}
+
+
+/* Read the CIS info tuples for the given function and Tuple ID*/
+cy_as_return_status_t
+cy_as_sdio_get_c_i_s_info(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint16_t tuple_id,
+ uint8_t *data_p)
+{
+
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t resp_data;
+ cy_as_context *ctxt_p ;
+ uint32_t loopcount = 200;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle, bus, 0)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait))
+ return CY_AS_ERROR_ASYNC_PENDING ;
+
+
+ /* Initialise the request to send to the Antioch. */
+ req_p = dev_p->storage_rw_req_p ;
+ cy_as_ll_init_request(req_p, CY_RQT_SDIO_GET_TUPLE,
+ CY_RQT_STORAGE_RQT_CONTEXT, 2) ;
+
+ /* Initialise the space for reply from the Antioch. */
+ reply_p = dev_p->storage_rw_resp_p ;
+ cy_as_ll_init_response(reply_p, 3) ;
+
+ /* Setup the DMA request */
+ ret = cy_as_dma_queue_request(dev_p, dev_p->storage_read_endpoint,
+ data_p+1, 255, cy_false, cy_true, cy_as_sync_storage_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+
+ /* Set tuple id to fetch. */
+ cy_as_ll_request_response__set_word(req_p, 1, tuple_id<<8) ;
+
+ /* Send the request and wait for completion of storage request */
+ dev_p->storage_wait = cy_true ;
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p, cy_true,
+ cy_as_sdio_sync_reply_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p,
+ dev_p->storage_read_endpoint, CY_AS_ERROR_CANCELED) ;
+ } else {
+ /* Setup the DMA request */
+ ctxt_p = dev_p->context[CY_RQT_STORAGE_RQT_CONTEXT] ;
+ ret = cy_as_dma_drain_queue(dev_p,
+ dev_p->storage_read_endpoint, cy_true) ;
+
+ while (loopcount-- > 0) {
+ if (dev_p->storage_wait == cy_false)
+ break;
+ cy_as_hal_sleep_on(&ctxt_p->channel, 10) ;
+ }
+
+ if (dev_p->storage_wait == cy_true) {
+ dev_p->storage_wait = cy_false ;
+ cy_as_ll_remove_request(dev_p, ctxt_p, req_p, cy_true) ;
+ return CY_AS_ERROR_TIMEOUT ;
+ }
+ ret = dev_p->storage_error ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_ll_request_response__get_code
+ (dev_p->storage_rw_resp_p) == CY_RESP_SDIO_GET_TUPLE) {
+ resp_data = cy_as_ll_request_response__get_word
+ (reply_p, 0) ;
+ if (resp_data) {
+ ret = CY_AS_ERROR_INVALID_REQUEST ;
+ } else if (data_p != 0)
+ *(uint8_t *)data_p = (uint8_t)
+ (cy_as_ll_request_response__get_word
+ (reply_p, 0)&0x00ff);
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+ }
+ return ret;
+}
+
+/*Query Device*/
+cy_as_return_status_t
+cy_as_sdio_query_card(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_sdio_card *data_p)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ uint8_t resp_type;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ /* Allocating memory to the SDIO device structure in dev_p */
+
+ cy_as_hal_mem_set(&dev_p->sdiocard[bus], 0, sizeof(cy_as_sdio_device));
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SDIO_QUERY_CARD,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, 0)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 5) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ resp_type = cy_as_ll_request_response__get_code(reply_p);
+ if (resp_type == CY_RESP_SDIO_QUERY_CARD) {
+ dev_p->sdiocard[bus].card.num_functions =
+ (uint8_t)((reply_p->data[0]&0xff00)>>8);
+ dev_p->sdiocard[bus].card.memory_present =
+ (uint8_t)reply_p->data[0]&0x0001;
+ dev_p->sdiocard[bus].card.manufacturer__id =
+ reply_p->data[1];
+ dev_p->sdiocard[bus].card.manufacturer_info =
+ reply_p->data[2];
+ dev_p->sdiocard[bus].card.blocksize =
+ reply_p->data[3];
+ dev_p->sdiocard[bus].card.maxblocksize =
+ reply_p->data[3];
+ dev_p->sdiocard[bus].card.card_capability =
+ (uint8_t)((reply_p->data[4]&0xff00)>>8);
+ dev_p->sdiocard[bus].card.sdio_version =
+ (uint8_t)(reply_p->data[4]&0x00ff);
+ dev_p->sdiocard[bus].function_init_map = 0x01;
+ data_p->num_functions =
+ dev_p->sdiocard[bus].card.num_functions;
+ data_p->memory_present =
+ dev_p->sdiocard[bus].card.memory_present;
+ data_p->manufacturer__id =
+ dev_p->sdiocard[bus].card.manufacturer__id;
+ data_p->manufacturer_info =
+ dev_p->sdiocard[bus].card.manufacturer_info;
+ data_p->blocksize = dev_p->sdiocard[bus].card.blocksize;
+ data_p->maxblocksize =
+ dev_p->sdiocard[bus].card.maxblocksize;
+ data_p->card_capability =
+ dev_p->sdiocard[bus].card.card_capability;
+ data_p->sdio_version =
+ dev_p->sdiocard[bus].card.sdio_version;
+ } else {
+ if (resp_type == CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+destroy:
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+/*Reset SDIO card. */
+cy_as_return_status_t
+cy_as_sdio_reset_card(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device)
+{
+
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t resp_type;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (dev_p->sdiocard != 0) {
+ dev_p->sdiocard[bus].function_init_map = 0;
+ dev_p->sdiocard[bus].function_suspended_map = 0;
+ }
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SDIO_RESET_DEV,
+ CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*Setup mailbox */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, 0)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ resp_type = cy_as_ll_request_response__get_code(reply_p) ;
+
+ if (resp_type == CY_RESP_SUCCESS_FAILURE) {
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = cy_as_sdio_query_card(handle, bus, device, 0);
+ } else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+
+destroy:
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+/* Initialise an IO function*/
+cy_as_return_status_t
+cy_as_sdio_init_function(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint8_t misc_buf)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t resp_type;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized
+ (handle, bus, 0)))
+ return CY_AS_ERROR_NOT_RUNNING;
+
+ if ((cy_as_sdio_check_function_initialized
+ (handle, bus, n_function_no))) {
+ if (misc_buf&CY_SDIO_FORCE_INIT)
+ dev_p->sdiocard[bus].function_init_map &=
+ (~(1 << n_function_no));
+ else
+ return CY_AS_ERROR_ALREADY_RUNNING;
+ }
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SDIO_INIT_FUNCTION, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 5) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ resp_type = cy_as_ll_request_response__get_code(reply_p) ;
+
+ if (resp_type == CY_RESP_SDIO_INIT_FUNCTION) {
+ dev_p->sdiocard[bus].function[n_function_no-1].function_code =
+ (uint8_t)((reply_p->data[0]&0xff00)>>8);
+ dev_p->sdiocard[bus].function[n_function_no-1].
+ extended_func_code = (uint8_t)reply_p->data[0]&0x00ff;
+ dev_p->sdiocard[bus].function[n_function_no-1].blocksize =
+ reply_p->data[1];
+ dev_p->sdiocard[bus].function[n_function_no-1].
+ maxblocksize = reply_p->data[1];
+ dev_p->sdiocard[bus].function[n_function_no-1].card_psn =
+ (uint32_t)(reply_p->data[2])<<16;
+ dev_p->sdiocard[bus].function[n_function_no-1].card_psn |=
+ (uint32_t)(reply_p->data[3]);
+ dev_p->sdiocard[bus].function[n_function_no-1].csa_bits =
+ (uint8_t)((reply_p->data[4]&0xff00)>>8);
+ dev_p->sdiocard[bus].function[n_function_no-1].wakeup_support =
+ (uint8_t)(reply_p->data[4]&0x0001);
+ dev_p->sdiocard[bus].function_init_map |= (1 << n_function_no);
+ cy_as_sdio_clear_function_suspended(handle, bus, n_function_no);
+
+ } else {
+ if (resp_type == CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_FUNCTION ;
+ }
+
+destroy:
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+/*Query individual functions. */
+cy_as_return_status_t
+cy_as_sdio_query_function(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ cy_as_sdio_func *data_p)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ cy_as_return_status_t ret;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle,
+ bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ data_p->blocksize =
+ dev_p->sdiocard[bus].function[n_function_no-1].blocksize;
+ data_p->card_psn =
+ dev_p->sdiocard[bus].function[n_function_no-1].card_psn;
+ data_p->csa_bits =
+ dev_p->sdiocard[bus].function[n_function_no-1].csa_bits;
+ data_p->extended_func_code =
+ dev_p->sdiocard[bus].function[n_function_no-1].
+ extended_func_code;
+ data_p->function_code =
+ dev_p->sdiocard[bus].function[n_function_no-1].function_code;
+ data_p->maxblocksize =
+ dev_p->sdiocard[bus].function[n_function_no-1].maxblocksize;
+ data_p->wakeup_support =
+ dev_p->sdiocard[bus].function[n_function_no-1].wakeup_support;
+
+ return CY_AS_ERROR_SUCCESS;
+}
+
+/* Abort the Current Extended IO Operation*/
+cy_as_return_status_t
+cy_as_sdio_abort_function(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t resp_type;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle,
+ bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ if ((cy_as_device_is_storage_async_pending(dev_p)) ||
+ (dev_p->storage_wait)) {
+ if (!(cy_as_sdio_get_card_capability(handle, bus) &
+ CY_SDIO_SDC))
+ return CY_AS_ERROR_INVALID_COMMAND;
+ }
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SDIO_ABORT_IO,
+ CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*Setup mailbox */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ resp_type = cy_as_ll_request_response__get_code(reply_p) ;
+
+ if (resp_type == CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+
+
+destroy:
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+}
+
+/* Suspend IO to current function*/
+cy_as_return_status_t
+cy_as_sdio_suspend(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized(handle, bus,
+ n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (!(cy_as_sdio_check_support_bus_suspend(handle, bus)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (!(cy_as_sdio_get_card_capability(handle, bus) & CY_SDIO_SDC))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (cy_as_sdio_check_function_suspended(handle, bus, n_function_no))
+ return CY_AS_ERROR_FUNCTION_SUSPENDED;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SDIO_SUSPEND, CY_RQT_GENERAL_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*Setup mailbox */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ ret = cy_as_ll_request_response__get_code(reply_p) ;
+ cy_as_sdio_set_function_suspended(handle, bus, n_function_no);
+ }
+
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*Resume suspended function*/
+cy_as_return_status_t
+cy_as_sdio_resume(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ cy_as_oper_type op,
+ uint8_t misc_buf,
+ uint16_t pendingblockcount,
+ uint8_t *data_p
+ )
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t resp_data, ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized
+ (handle, bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ /* If suspend resume is not supported return */
+ if (!(cy_as_sdio_check_support_bus_suspend(handle, bus)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ /* if the function is not suspended return. */
+ if (!(cy_as_sdio_check_function_suspended
+ (handle, bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SDIO_RESUME, CY_RQT_STORAGE_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /*Setup mailbox */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ create_address(bus, (uint8_t)device, n_function_no)) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 2) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SDIO_RESUME) {
+ resp_data = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (resp_data & 0x00ff) {
+ /* Send extended read request to resume the read. */
+ if (op == cy_as_op_read) {
+ ret = cy_as_sdio_extended_i_o(handle, bus,
+ device, n_function_no, 0, misc_buf,
+ pendingblockcount, cy_false, data_p, 1);
+ } else {
+ ret = cy_as_sdio_extended_i_o(handle, bus,
+ device, n_function_no, 0, misc_buf,
+ pendingblockcount, cy_true, data_p, 1);
+ }
+ } else {
+ ret = CY_AS_ERROR_SUCCESS;
+ }
+ } else {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ }
+
+destroy:
+ cy_as_sdio_clear_function_suspended(handle, bus, n_function_no);
+ if (req_p != 0)
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ if (reply_p != 0)
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+
+}
+
+/*Set function blocksize. Size cannot exceed max
+ * block size for the function*/
+cy_as_return_status_t
+cy_as_sdio_set_blocksize(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no,
+ uint16_t blocksize)
+{
+ cy_as_return_status_t ret;
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ ret = cy_as_sdio_device_check(dev_p, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized
+ (handle, bus, n_function_no)))
+ return CY_AS_ERROR_INVALID_FUNCTION;
+ if (n_function_no == 0) {
+ if (blocksize > cy_as_sdio_get_card_max_blocksize(handle, bus))
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+ else if (blocksize == cy_as_sdio_get_card_blocksize
+ (handle, bus))
+ return CY_AS_ERROR_SUCCESS;
+ } else {
+ if (blocksize >
+ cy_as_sdio_get_function_max_blocksize(handle,
+ bus, n_function_no))
+ return CY_AS_ERROR_INVALID_BLOCKSIZE;
+ else if (blocksize ==
+ cy_as_sdio_get_function_blocksize(handle,
+ bus, n_function_no))
+ return CY_AS_ERROR_SUCCESS;
+ }
+
+ ret = cy_as_sdio_direct_write(handle, bus, device, 0,
+ (uint16_t)(n_function_no << 8) |
+ 0x10, 0, blocksize & 0x00ff, 0);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ ret = cy_as_sdio_direct_write(handle, bus, device, 0,
+ (uint16_t)(n_function_no << 8) |
+ 0x11, 0, (blocksize & 0xff00) >> 8, 0);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (n_function_no == 0)
+ cy_as_sdio_set_card_block_size(handle, bus, blocksize);
+ else
+ cy_as_sdio_set_function_block_size(handle,
+ bus, n_function_no, blocksize);
+ return ret;
+}
+
+/* Deinitialize an SDIO function*/
+cy_as_return_status_t
+cy_as_sdio_de_init_function(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ uint8_t n_function_no)
+{
+ cy_as_return_status_t ret;
+ uint8_t temp;
+
+ if (n_function_no == 0)
+ return CY_AS_ERROR_INVALID_FUNCTION;
+
+ ret = cy_as_sdio_device_check((cy_as_device *)handle, bus, device);
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret;
+
+ if (!(cy_as_sdio_check_function_initialized
+ (handle, bus, n_function_no)))
+ return CY_AS_ERROR_SUCCESS;
+
+ temp = (uint8_t)(((cy_as_device *)handle)->sdiocard[bus].
+ function_init_map & (~(1 << n_function_no)));
+
+ cy_as_sdio_direct_write(handle, bus, device, 0, 0x02, 0, temp, 0);
+
+ ((cy_as_device *)handle)->sdiocard[bus].function_init_map &=
+ (~(1 << n_function_no));
+
+ return CY_AS_ERROR_SUCCESS;
+}
+
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/api/src/cyasusb.c b/drivers/staging/westbridge/astoria/api/src/cyasusb.c
new file mode 100644
index 000000000000..d0ffc2cfe77a
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/api/src/cyasusb.c
@@ -0,0 +1,3718 @@
+/* Cypress West Bridge API source file (cyasusb.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include "../../include/linux/westbridge/cyashal.h"
+#include "../../include/linux/westbridge/cyasusb.h"
+#include "../../include/linux/westbridge/cyaserr.h"
+#include "../../include/linux/westbridge/cyasdma.h"
+#include "../../include/linux/westbridge/cyaslowlevel.h"
+#include "../../include/linux/westbridge/cyaslep2pep.h"
+#include "../../include/linux/westbridge/cyasregs.h"
+#include "../../include/linux/westbridge/cyasstorage.h"
+
+static cy_as_return_status_t
+cy_as_usb_ack_setup_packet(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+static void
+cy_as_usb_func_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret) ;
+/*
+* Reset the USB EP0 state
+*/
+static void
+cy_as_usb_reset_e_p0_state(cy_as_device *dev_p)
+{
+ cy_as_log_debug_message(6, "cy_as_usb_reset_e_p0_state called") ;
+
+ cy_as_device_clear_ack_delayed(dev_p) ;
+ cy_as_device_clear_setup_packet(dev_p) ;
+ if (cy_as_device_is_usb_async_pending(dev_p, 0))
+ cy_as_usb_cancel_async((cy_as_device_handle)dev_p, 0) ;
+
+ dev_p->usb_pending_buffer = 0 ;
+}
+
+/*
+* External function to map logical endpoints to physical endpoints
+*/
+static cy_as_return_status_t
+is_usb_active(cy_as_device *dev_p)
+{
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (dev_p->usb_count == 0)
+ return CY_AS_ERROR_NOT_RUNNING ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+usb_ack_callback(cy_as_device_handle h,
+ cy_as_return_status_t status,
+ uint32_t client,
+ cy_as_funct_c_b_type type,
+ void *data)
+{
+ cy_as_device *dev_p = (cy_as_device *)h ;
+
+ (void)client ;
+ (void)status ;
+ (void)data ;
+
+ cy_as_hal_assert(type == CY_FUNCT_CB_NODATA) ;
+
+ if (dev_p->usb_pending_buffer) {
+ cy_as_usb_io_callback cb ;
+
+ cb = dev_p->usb_cb[0] ;
+ dev_p->usb_cb[0] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p, 0) ;
+ if (cb)
+ cb(h, 0, dev_p->usb_pending_size,
+ dev_p->usb_pending_buffer, dev_p->usb_error) ;
+
+ dev_p->usb_pending_buffer = 0 ;
+ }
+
+ cy_as_device_clear_setup_packet(dev_p) ;
+}
+
+static void
+my_usb_request_callback_usb_event(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ uint16_t ev ;
+ uint16_t val ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+
+ ev = cy_as_ll_request_response__get_word(req_p, 0) ;
+ switch (ev) {
+ case 0: /* Reserved */
+ cy_as_ll_send_status_response(dev_p, CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_INVALID_REQUEST, 0) ;
+ break ;
+
+ case 1: /* Reserved */
+ cy_as_ll_send_status_response(dev_p, CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_INVALID_REQUEST, 0) ;
+ break ;
+
+ case 2: /* USB Suspend */
+ dev_p->usb_last_event = cy_as_event_usb_suspend ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h, cy_as_event_usb_suspend, 0) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h, cy_as_event_usb_suspend, 0) ;
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ break;
+
+ case 3: /* USB Resume */
+ dev_p->usb_last_event = cy_as_event_usb_resume ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h, cy_as_event_usb_resume, 0) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h, cy_as_event_usb_resume, 0) ;
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ break ;
+
+ case 4: /* USB Reset */
+ /*
+ * if we get a USB reset, the USB host did not understand
+ * our response or we timed out for some reason. reset
+ * our internal state to be ready for another set of
+ * enumeration based requests.
+ */
+ if (cy_as_device_is_ack_delayed(dev_p))
+ cy_as_usb_reset_e_p0_state(dev_p) ;
+
+ dev_p->usb_last_event = cy_as_event_usb_reset ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h, cy_as_event_usb_reset, 0) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h, cy_as_event_usb_reset, 0) ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ cy_as_device_clear_usb_high_speed(dev_p) ;
+ cy_as_usb_set_dma_sizes(dev_p) ;
+ dev_p->usb_max_tx_size = 0x40 ;
+ cy_as_dma_set_max_dma_size(dev_p, 0x06, 0x40) ;
+ break ;
+
+ case 5: /* USB Set Configuration */
+ /* The configuration to set */
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ dev_p->usb_last_event = cy_as_event_usb_set_config ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_set_config, &val) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_set_config, &val) ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ break ;
+
+ case 6: /* USB Speed change */
+ /* Connect speed */
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ dev_p->usb_last_event = cy_as_event_usb_speed_change ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_speed_change, &val) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_speed_change, &val) ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ cy_as_device_set_usb_high_speed(dev_p) ;
+ cy_as_usb_set_dma_sizes(dev_p) ;
+ dev_p->usb_max_tx_size = 0x200 ;
+ cy_as_dma_set_max_dma_size(dev_p, 0x06, 0x200) ;
+ break ;
+
+ case 7: /* USB Clear Feature */
+ /* EP Number */
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_clear_feature, &val) ;
+ if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_clear_feature, &val) ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ break ;
+
+ default:
+ cy_as_hal_print_message("invalid event type\n") ;
+ cy_as_ll_send_data_response(dev_p, CY_RQT_USB_RQT_CONTEXT,
+ CY_RESP_USB_INVALID_EVENT, sizeof(ev), &ev) ;
+ break ;
+ }
+}
+
+static void
+my_usb_request_callback_usb_data(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ cy_as_end_point_number_t ep ;
+ uint8_t type ;
+ uint16_t len ;
+ uint16_t val ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ ep = (cy_as_end_point_number_t)((val >> 13) & 0x01) ;
+ len = (val & 0x1ff) ;
+
+ cy_as_hal_assert(len <= 64) ;
+ cy_as_ll_request_response__unpack(req_p,
+ 1, len, dev_p->usb_ep_data) ;
+
+ type = (uint8_t)((val >> 14) & 0x03) ;
+ if (type == 0) {
+ if (cy_as_device_is_ack_delayed(dev_p)) {
+ /*
+ * A setup packet has arrived while we are
+ * processing a previous setup packet. reset
+ * our state with respect to EP0 to be ready
+ * to process the new packet.
+ */
+ cy_as_usb_reset_e_p0_state(dev_p) ;
+ }
+
+ if (len != 8)
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_INVALID_REQUEST, 0) ;
+ else {
+ cy_as_device_clear_ep0_stalled(dev_p) ;
+ cy_as_device_set_setup_packet(dev_p) ;
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_SUCCESS, 0) ;
+
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_setup_packet,
+ dev_p->usb_ep_data) ;
+ else
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_setup_packet,
+ dev_p->usb_ep_data) ;
+
+ if ((!cy_as_device_is_ack_delayed(dev_p)) &&
+ (!cy_as_device_is_ep0_stalled(dev_p)))
+ cy_as_usb_ack_setup_packet(h,
+ usb_ack_callback, 0) ;
+ }
+ } else if (type == 2) {
+ if (len != 0)
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_INVALID_REQUEST, 0) ;
+ else {
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_status_packet, 0) ;
+ else
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_status_packet, 0) ;
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT,
+ CY_AS_ERROR_SUCCESS, 0) ;
+ }
+ } else if (type == 1) {
+ /*
+ * we need to hand the data associated with these
+ * endpoints to the DMA module.
+ */
+ cy_as_dma_received_data(dev_p, ep, len, dev_p->usb_ep_data) ;
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+ }
+}
+
+static void
+my_usb_request_callback_inquiry(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ cy_as_usb_inquiry_data_dep cbdata ;
+ cy_as_usb_inquiry_data cbdata_ms ;
+ void *data ;
+ uint16_t val ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+ uint8_t def_inq_data[64] ;
+ uint8_t evpd ;
+ uint8_t codepage ;
+ cy_bool updated ;
+ uint16_t length ;
+
+ cy_as_bus_number_t bus ;
+ uint32_t device ;
+ cy_as_media_type media ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ bus = cy_as_storage_get_bus_from_address(val) ;
+ device = cy_as_storage_get_device_from_address(val) ;
+ media = cy_as_storage_get_media_from_address(val) ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ evpd = (uint8_t)((val >> 8) & 0x01) ;
+ codepage = (uint8_t)(val & 0xff) ;
+
+ length = cy_as_ll_request_response__get_word(req_p, 2) ;
+ data = (void *)def_inq_data ;
+
+ updated = cy_false ;
+
+ if (dev_p->usb_event_cb_ms) {
+ cbdata_ms.bus = bus ;
+ cbdata_ms.device = device ;
+ cbdata_ms.updated = updated ;
+ cbdata_ms.evpd = evpd ;
+ cbdata_ms.codepage = codepage ;
+ cbdata_ms.length = length ;
+ cbdata_ms.data = data ;
+
+ cy_as_hal_assert(cbdata_ms.length <= sizeof(def_inq_data)) ;
+ cy_as_ll_request_response__unpack(req_p,
+ 3, cbdata_ms.length, cbdata_ms.data) ;
+
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_inquiry_before, &cbdata_ms) ;
+
+ updated = cbdata_ms.updated;
+ data = cbdata_ms.data ;
+ length = cbdata_ms.length ;
+ } else if (dev_p->usb_event_cb) {
+ cbdata.media = media ;
+ cbdata.updated = updated ;
+ cbdata.evpd = evpd ;
+ cbdata.codepage = codepage ;
+ cbdata.length = length ;
+ cbdata.data = data ;
+
+ cy_as_hal_assert(cbdata.length <=
+ sizeof(def_inq_data)) ;
+ cy_as_ll_request_response__unpack(req_p, 3,
+ cbdata.length, cbdata.data) ;
+
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_inquiry_before, &cbdata) ;
+
+ updated = cbdata.updated ;
+ data = cbdata.data ;
+ length = cbdata.length ;
+ }
+
+ if (updated && length > 192)
+ cy_as_hal_print_message("an inquiry result from a "
+ "cy_as_event_usb_inquiry_before event "
+ "was greater than 192 bytes.") ;
+
+ /* Now send the reply with the data back
+ * to the West Bridge device */
+ if (updated && length <= 192) {
+ /*
+ * the callback function modified the inquiry
+ * data, ship the data back to the west bridge firmware.
+ */
+ cy_as_ll_send_data_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT,
+ CY_RESP_INQUIRY_DATA, length, data) ;
+ } else {
+ /*
+ * the callback did not modify the data, just acknowledge
+ * that we processed the request
+ */
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 1) ;
+ }
+
+ if (dev_p->usb_event_cb_ms)
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_inquiry_after, &cbdata_ms) ;
+ else if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_inquiry_after, &cbdata) ;
+}
+
+static void
+my_usb_request_callback_start_stop(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ cy_as_bus_number_t bus ;
+ cy_as_media_type media ;
+ uint32_t device ;
+ uint16_t val ;
+
+ if (dev_p->usb_event_cb_ms || dev_p->usb_event_cb) {
+ cy_bool loej ;
+ cy_bool start ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ bus = cy_as_storage_get_bus_from_address(val) ;
+ device = cy_as_storage_get_device_from_address(val) ;
+ media = cy_as_storage_get_media_from_address(val) ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 1) ;
+ loej = (val & 0x02) ? cy_true : cy_false ;
+ start = (val & 0x01) ? cy_true : cy_false ;
+
+ if (dev_p->usb_event_cb_ms) {
+ cy_as_usb_start_stop_data cbdata_ms ;
+
+ cbdata_ms.bus = bus ;
+ cbdata_ms.device = device ;
+ cbdata_ms.loej = loej ;
+ cbdata_ms.start = start ;
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_start_stop, &cbdata_ms) ;
+
+ } else if (dev_p->usb_event_cb) {
+ cy_as_usb_start_stop_data_dep cbdata ;
+
+ cbdata.media = media ;
+ cbdata.loej = loej ;
+ cbdata.start = start ;
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_start_stop, &cbdata) ;
+ }
+ }
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 1) ;
+}
+
+static void
+my_usb_request_callback_uknown_c_b_w(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ uint16_t val ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+ uint8_t buf[16] ;
+
+ uint8_t response[4] ;
+ uint16_t reqlen ;
+ void *request ;
+ uint8_t status ;
+ uint8_t key ;
+ uint8_t asc ;
+ uint8_t ascq ;
+
+ val = cy_as_ll_request_response__get_word(req_p, 0) ;
+ /* Failed by default */
+ status = 1 ;
+ /* Invalid command */
+ key = 0x05 ;
+ /* Invalid command */
+ asc = 0x20 ;
+ /* Invalid command */
+ ascq = 0x00 ;
+ reqlen = cy_as_ll_request_response__get_word(req_p, 1) ;
+ request = buf ;
+
+ cy_as_hal_assert(reqlen <= sizeof(buf)) ;
+ cy_as_ll_request_response__unpack(req_p, 2, reqlen, request) ;
+
+ if (dev_p->usb_event_cb_ms) {
+ cy_as_usb_unknown_command_data cbdata_ms ;
+ cbdata_ms.bus = cy_as_storage_get_bus_from_address(val) ;
+ cbdata_ms.device =
+ cy_as_storage_get_device_from_address(val) ;
+ cbdata_ms.reqlen = reqlen ;
+ cbdata_ms.request = request ;
+ cbdata_ms.status = status ;
+ cbdata_ms.key = key ;
+ cbdata_ms.asc = asc ;
+ cbdata_ms.ascq = ascq ;
+
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_unknown_storage, &cbdata_ms) ;
+ status = cbdata_ms.status ;
+ key = cbdata_ms.key ;
+ asc = cbdata_ms.asc ;
+ ascq = cbdata_ms.ascq ;
+ } else if (dev_p->usb_event_cb) {
+ cy_as_usb_unknown_command_data_dep cbdata ;
+ cbdata.media =
+ cy_as_storage_get_media_from_address(val) ;
+ cbdata.reqlen = reqlen ;
+ cbdata.request = request ;
+ cbdata.status = status ;
+ cbdata.key = key ;
+ cbdata.asc = asc ;
+ cbdata.ascq = ascq ;
+
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_unknown_storage, &cbdata) ;
+ status = cbdata.status ;
+ key = cbdata.key ;
+ asc = cbdata.asc ;
+ ascq = cbdata.ascq ;
+ }
+
+ response[0] = status ;
+ response[1] = key ;
+ response[2] = asc ;
+ response[3] = ascq ;
+ cy_as_ll_send_data_response(dev_p, CY_RQT_USB_RQT_CONTEXT,
+ CY_RESP_UNKNOWN_SCSI_COMMAND, sizeof(response), response) ;
+}
+
+static void
+my_usb_request_callback_m_s_c_progress(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p)
+{
+ uint16_t val1, val2 ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+
+ if ((dev_p->usb_event_cb) || (dev_p->usb_event_cb_ms)) {
+ cy_as_m_s_c_progress_data cbdata ;
+
+ val1 = cy_as_ll_request_response__get_word(req_p, 0) ;
+ val2 = cy_as_ll_request_response__get_word(req_p, 1) ;
+ cbdata.wr_count = (uint32_t)((val1 << 16) | val2) ;
+
+ val1 = cy_as_ll_request_response__get_word(req_p, 2) ;
+ val2 = cy_as_ll_request_response__get_word(req_p, 3) ;
+ cbdata.rd_count = (uint32_t)((val1 << 16) | val2) ;
+
+ if (dev_p->usb_event_cb)
+ dev_p->usb_event_cb(h,
+ cy_as_event_usb_m_s_c_progress, &cbdata) ;
+ else
+ dev_p->usb_event_cb_ms(h,
+ cy_as_event_usb_m_s_c_progress, &cbdata) ;
+ }
+
+ cy_as_ll_send_status_response(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, CY_AS_ERROR_SUCCESS, 0) ;
+}
+
+/*
+* This function processes the requests delivered from the
+* firmware within the West Bridge device that are delivered
+* in the USB context. These requests generally are EP0 and
+* EP1 related requests or USB events.
+*/
+static void
+my_usb_request_callback(cy_as_device *dev_p, uint8_t context,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *resp_p,
+ cy_as_return_status_t ret)
+{
+ uint16_t val ;
+ uint8_t code = cy_as_ll_request_response__get_code(req_p) ;
+
+ (void)resp_p ;
+ (void)context ;
+ (void)ret ;
+
+ switch (code) {
+ case CY_RQT_USB_EVENT:
+ my_usb_request_callback_usb_event(dev_p, req_p) ;
+ break ;
+
+ case CY_RQT_USB_EP_DATA:
+ dev_p->usb_last_event = cy_as_event_usb_setup_packet ;
+ my_usb_request_callback_usb_data(dev_p, req_p) ;
+ break ;
+
+ case CY_RQT_SCSI_INQUIRY_COMMAND:
+ dev_p->usb_last_event = cy_as_event_usb_inquiry_after ;
+ my_usb_request_callback_inquiry(dev_p, req_p) ;
+ break ;
+
+ case CY_RQT_SCSI_START_STOP_COMMAND:
+ dev_p->usb_last_event = cy_as_event_usb_start_stop ;
+ my_usb_request_callback_start_stop(dev_p, req_p) ;
+ break ;
+
+ case CY_RQT_SCSI_UNKNOWN_COMMAND:
+ dev_p->usb_last_event = cy_as_event_usb_unknown_storage ;
+ my_usb_request_callback_uknown_c_b_w(dev_p, req_p) ;
+ break ;
+
+ case CY_RQT_USB_ACTIVITY_UPDATE:
+ dev_p->usb_last_event = cy_as_event_usb_m_s_c_progress ;
+ my_usb_request_callback_m_s_c_progress(dev_p, req_p) ;
+ break ;
+
+ default:
+ cy_as_hal_print_message("invalid request "
+ "received on USB context\n") ;
+ val = req_p->box0 ;
+ cy_as_ll_send_data_response(dev_p, CY_RQT_USB_RQT_CONTEXT,
+ CY_RESP_INVALID_REQUEST, sizeof(val), &val) ;
+ break ;
+ }
+}
+
+static cy_as_return_status_t
+my_handle_response_usb_start(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /*
+ * mark EP 0 and EP1 as 64 byte endpoints
+ */
+ cy_as_dma_set_max_dma_size(dev_p, 0, 64) ;
+ cy_as_dma_set_max_dma_size(dev_p, 1, 64) ;
+
+ dev_p->usb_count++ ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_destroy_c_b_queue(dev_p->usb_func_cbs) ;
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, 0) ;
+ }
+
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+
+ return ret ;
+
+}
+
+/*
+* This function starts the USB stack. The stack is reference
+* counted so if the stack is already started, this function
+* just increments the count. If the stack has not been started,
+* a start request is sent to the West Bridge device.
+*
+* Note: Starting the USB stack does not cause the USB signals
+* to be connected to the USB pins. To do this and therefore
+* initiate enumeration, CyAsUsbConnect() must be called.
+*/
+cy_as_return_status_t
+cy_as_usb_start(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p, *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_start called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (cy_as_device_is_u_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ cy_as_device_set_u_s_s_pending(dev_p) ;
+
+ if (dev_p->usb_count == 0) {
+ /*
+ * since we are just starting the stack,
+ * mark USB as not connected to the remote host
+ */
+ cy_as_device_clear_usb_connected(dev_p) ;
+ dev_p->usb_phy_config = 0 ;
+
+ /* Queue for 1.0 Async Requests, kept for
+ * backwards compatibility */
+ dev_p->usb_func_cbs = cy_as_create_c_b_queue(CYAS_USB_FUNC_CB) ;
+ if (dev_p->usb_func_cbs == 0) {
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Reset the EP0 state */
+ cy_as_usb_reset_e_p0_state(dev_p) ;
+
+ /*
+ * we register here becuase the start request may cause
+ * events to occur before the response to the start request.
+ */
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, my_usb_request_callback) ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_START_USB, CY_RQT_USB_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ cy_as_destroy_c_b_queue(dev_p->usb_func_cbs) ;
+ dev_p->usb_func_cbs = 0 ;
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_destroy_c_b_queue(dev_p->usb_func_cbs) ;
+ dev_p->usb_func_cbs = 0 ;
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_usb_start(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb,
+ client, CY_FUNCT_CB_USB_START, 0,
+ dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else {
+ dev_p->usb_count++ ;
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_USB_START, 0) ;
+ }
+
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+void
+cy_as_usb_reset(cy_as_device *dev_p)
+{
+ int i ;
+
+ cy_as_device_clear_usb_connected(dev_p) ;
+
+ for (i = 0 ; i < sizeof(dev_p->usb_config) /
+ sizeof(dev_p->usb_config[0]) ; i++) {
+ /*
+ * cancel all pending USB read/write operations, as it is
+ * possible that the USB stack comes up in a different
+ * configuration with a different set of endpoints.
+ */
+ if (cy_as_device_is_usb_async_pending(dev_p, i))
+ cy_as_usb_cancel_async(dev_p,
+ (cy_as_end_point_number_t)i) ;
+
+ dev_p->usb_cb[i] = 0 ;
+ dev_p->usb_config[i].enabled = cy_false ;
+ }
+
+ dev_p->usb_phy_config = 0 ;
+}
+
+/*
+ * This function does all the API side clean-up associated
+ * with CyAsUsbStop, without any communication with firmware.
+ * This needs to be done when the device is being reset while
+ * the USB stack is active.
+ */
+void
+cy_as_usb_cleanup(cy_as_device *dev_p)
+{
+ if (dev_p->usb_count) {
+ cy_as_usb_reset_e_p0_state(dev_p) ;
+ cy_as_usb_reset(dev_p) ;
+ cy_as_hal_mem_set(dev_p->usb_config, 0,
+ sizeof(dev_p->usb_config)) ;
+ cy_as_destroy_c_b_queue(dev_p->usb_func_cbs) ;
+
+ dev_p->usb_count = 0 ;
+ }
+}
+
+static cy_as_return_status_t
+my_handle_response_usb_stop(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /*
+ * we sucessfully shutdown the stack, so
+ * decrement to make the count zero.
+ */
+ cy_as_usb_cleanup(dev_p) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_ll_register_request_callback(dev_p,
+ CY_RQT_USB_RQT_CONTEXT, 0) ;
+
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+/*
+* This function stops the USB stack. The USB stack is reference
+* counted so first is reference count is decremented. If the
+* reference count is then zero, a request is sent to the West
+* Bridge device to stop the USB stack on the West Bridge device.
+*/
+cy_as_return_status_t
+cy_as_usb_stop(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p = 0, *reply_p = 0 ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_stop called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (cy_as_device_is_u_s_s_pending(dev_p))
+ return CY_AS_ERROR_STARTSTOP_PENDING ;
+
+ cy_as_device_set_u_s_s_pending(dev_p) ;
+
+ if (dev_p->usb_count == 1) {
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_STOP_USB,
+ CY_RQT_USB_RQT_CONTEXT, 0) ;
+ if (req_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ /* Reserve space for the reply, the reply data will not
+ * exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_usb_stop(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_STOP, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ } else if (dev_p->usb_count > 1) {
+ /*
+ * reset all LE_ps to inactive state, after cleaning
+ * up any pending async read/write calls.
+ */
+ cy_as_usb_reset(dev_p) ;
+ dev_p->usb_count-- ;
+
+ if (cb)
+ cb(handle, ret, client, CY_FUNCT_CB_USB_STOP, 0) ;
+ }
+
+ cy_as_device_clear_u_s_s_pending(dev_p) ;
+
+ return ret ;
+}
+
+/*
+* This function registers a callback to be called when
+* USB events are processed
+*/
+cy_as_return_status_t
+cy_as_usb_register_callback(cy_as_device_handle handle,
+ cy_as_usb_event_callback callback)
+{
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_register_callback called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (!cy_as_device_is_configured(dev_p))
+ return CY_AS_ERROR_NOT_CONFIGURED ;
+
+ if (!cy_as_device_is_firmware_loaded(dev_p))
+ return CY_AS_ERROR_NO_FIRMWARE ;
+
+ dev_p->usb_event_cb = NULL ;
+ dev_p->usb_event_cb_ms = callback ;
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+
+static cy_as_return_status_t
+my_handle_response_no_data(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_connect(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ cy_as_device_set_usb_connected(dev_p) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+
+/*
+* This method asks the West Bridge device to connect the
+* internal USB D+ and D- signals to the USB pins, thus
+* starting the enumeration processes if the external pins
+* are connnected to a USB host. If the external pins are
+* not connect to a USB host, enumeration will begin as soon
+* as the USB pins are connected to a host.
+*/
+cy_as_return_status_t
+cy_as_usb_connect(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_connect called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SET_CONNECT_STATE, CY_RQT_USB_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* 1 = Connect request */
+ cy_as_ll_request_response__set_word(req_p, 0, 1) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_connect(dev_p, req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_CONNECT, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_disconnect(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_return_status_t ret)
+{
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ cy_as_device_clear_usb_connected(dev_p) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+/*
+* This method forces a disconnect of the D+ and D- pins
+* external to the West Bridge device from the D+ and D-
+* signals internally, effectively disconnecting the West
+* Bridge device from any connected USB host.
+*/
+cy_as_return_status_t
+cy_as_usb_disconnect(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_disconnect called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (!cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_NOT_CONNECTED ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SET_CONNECT_STATE, CY_RQT_USB_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0, 0) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed two bytes */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_disconnect(dev_p,
+ req_p, reply_p, ret) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_DISCONNECT, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_set_enum_config(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ /*
+ * we configured the west bridge device and
+ * enumeration is going to happen on the P port
+ * processor. now we must enable endpoint zero
+ */
+ cy_as_usb_end_point_config config ;
+
+ config.dir = cy_as_usb_in_out ;
+ config.type = cy_as_usb_control ;
+ config.enabled = cy_true ;
+
+ ret = cy_as_usb_set_end_point_config((cy_as_device_handle *)
+ dev_p, 0, &config) ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+* This method sets how the USB is enumerated and should
+* be called before the CyAsUsbConnect() is called.
+*/
+static cy_as_return_status_t
+my_usb_set_enum_config(cy_as_device *dev_p,
+ uint8_t bus_mask,
+ uint8_t media_mask,
+ cy_bool use_antioch_enumeration,
+ uint8_t mass_storage_interface,
+ uint8_t mtp_interface,
+ cy_bool mass_storage_callbacks,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_set_enum_config called") ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* if we are using MTP firmware: */
+ if (dev_p->is_mtp_firmware == 1) {
+ /* we cannot enumerate MSC */
+ if (mass_storage_interface != 0)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (bus_mask == 0) {
+ if (mtp_interface != 0)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+ } else if (bus_mask == 2) {
+ /* enable EP 1 as it will be used */
+ cy_as_dma_enable_end_point(dev_p, 1, cy_true,
+ cy_as_direction_in) ;
+ dev_p->usb_config[1].enabled = cy_true ;
+ dev_p->usb_config[1].dir = cy_as_usb_in ;
+ dev_p->usb_config[1].type = cy_as_usb_int ;
+ } else {
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+ }
+ /* if we are not using MTP firmware, we cannot enumerate MTP */
+ } else if (mtp_interface != 0)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ /*
+ * if we are not enumerating mass storage, we should
+ * not be providing an interface number.
+ */
+ if (bus_mask == 0 && mass_storage_interface != 0)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ /*
+ * if we are going to use mtp_interface, bus mask must be 2.
+ */
+ if (mtp_interface != 0 && bus_mask != 2)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SET_USB_CONFIG, CY_RQT_USB_RQT_CONTEXT, 4) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Marshal the structure */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((media_mask << 8) | bus_mask)) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)use_antioch_enumeration) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ dev_p->is_mtp_firmware ? mtp_interface :
+ mass_storage_interface) ;
+ cy_as_ll_request_response__set_word(req_p, 3,
+ (uint16_t)mass_storage_callbacks) ;
+
+ /* Reserve space for the reply, the reply
+ * data will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_set_enum_config(dev_p,
+ req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_SETENUMCONFIG, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+ * This method sets how the USB is enumerated and should
+ * be called before the CyAsUsbConnect() is called.
+ */
+cy_as_return_status_t
+cy_as_usb_set_enum_config(cy_as_device_handle handle,
+ cy_as_usb_enum_control *config_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ uint8_t bus_mask, media_mask ;
+ uint32_t bus, device ;
+ cy_as_return_status_t ret ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if ((cy_as_device_is_in_callback(dev_p)) && (cb != 0))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Since we are mapping the media types to bus with NAND to 0
+ * and the rest to 1, and we are only allowing for enumerating
+ * all the devices on a bus we just scan the array for any
+ * positions where there a device is enabled and mark the bus
+ * to be enumerated.
+ */
+ bus_mask = 0 ;
+ media_mask = 0 ;
+ media_mask = 0 ;
+ for (bus = 0; bus < CY_AS_MAX_BUSES; bus++) {
+ for (device = 0; device < CY_AS_MAX_STORAGE_DEVICES; device++) {
+ if (config_p->devices_to_enumerate[bus][device] ==
+ cy_true) {
+ bus_mask |= (0x01 << bus) ;
+ media_mask |= dev_p->media_supported[bus] ;
+ media_mask |= dev_p->media_supported[bus] ;
+ }
+ }
+ }
+
+ return my_usb_set_enum_config(dev_p, bus_mask, media_mask,
+ config_p->antioch_enumeration,
+ config_p->mass_storage_interface,
+ config_p->mtp_interface,
+ config_p->mass_storage_callbacks,
+ cb,
+ client
+ ) ;
+}
+
+
+static cy_as_return_status_t
+my_handle_response_get_enum_config(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ void *config_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t val ;
+ uint8_t bus_mask ;
+ uint32_t bus ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_USB_CONFIG) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ /* Marshal the reply */
+ if (req_p->flags & CY_AS_REQUEST_RESPONSE_MS) {
+ uint32_t device ;
+ cy_bool state;
+ cy_as_usb_enum_control *ms_config_p =
+ (cy_as_usb_enum_control *)config_p;
+
+ bus_mask = (uint8_t)
+ (cy_as_ll_request_response__get_word
+ (reply_p, 0) & 0xFF) ;
+ for (bus = 0; bus < CY_AS_MAX_BUSES; bus++) {
+ if (bus_mask & (1 << bus))
+ state = cy_true ;
+ else
+ state = cy_false ;
+
+ for (device = 0; device < CY_AS_MAX_STORAGE_DEVICES;
+ device++)
+ ms_config_p->devices_to_enumerate[bus][device]
+ = state ;
+ }
+
+ ms_config_p->antioch_enumeration =
+ (cy_bool)cy_as_ll_request_response__get_word
+ (reply_p, 1) ;
+
+ val = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ if (dev_p->is_mtp_firmware) {
+ ms_config_p->mass_storage_interface = 0 ;
+ ms_config_p->mtp_interface = (uint8_t)(val & 0xFF) ;
+ } else {
+ ms_config_p->mass_storage_interface =
+ (uint8_t)(val & 0xFF) ;
+ ms_config_p->mtp_interface = 0 ;
+ }
+ ms_config_p->mass_storage_callbacks = (cy_bool)(val >> 8) ;
+
+ /*
+ * firmware returns an invalid interface number for mass storage,
+ * if mass storage is not enabled. this needs to be converted to
+ * zero to match the input configuration.
+ */
+ if (bus_mask == 0) {
+ if (dev_p->is_mtp_firmware)
+ ms_config_p->mtp_interface = 0 ;
+ else
+ ms_config_p->mass_storage_interface = 0 ;
+ }
+ } else {
+ cy_as_usb_enum_control_dep *ex_config_p =
+ (cy_as_usb_enum_control_dep *)config_p;
+
+ ex_config_p->enum_mass_storage = (uint8_t)
+ ((cy_as_ll_request_response__get_word
+ (reply_p, 0) >> 8) & 0xFF) ;
+ ex_config_p->antioch_enumeration = (cy_bool)
+ cy_as_ll_request_response__get_word(reply_p, 1) ;
+
+ val = cy_as_ll_request_response__get_word(reply_p, 2) ;
+ ex_config_p->mass_storage_interface = (uint8_t)(val & 0xFF) ;
+ ex_config_p->mass_storage_callbacks = (cy_bool)(val >> 8) ;
+
+ /*
+ * firmware returns an invalid interface number for mass
+ * storage, if mass storage is not enabled. this needs to
+ * be converted to zero to match the input configuration.
+ */
+ if (ex_config_p->enum_mass_storage == 0)
+ ex_config_p->mass_storage_interface = 0 ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+* This sets up the request for the enumerateion configuration
+* information, based on if the request is from the old pre-1.2
+* functions.
+*/
+static cy_as_return_status_t
+my_usb_get_enum_config(cy_as_device_handle handle,
+ uint16_t req_flags,
+ void *config_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_get_enum_config called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_GET_USB_CONFIG, CY_RQT_USB_RQT_CONTEXT, 0) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed two bytes */
+ reply_p = cy_as_ll_create_response(dev_p, 3) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ /* we need to know the type of request to
+ * know how to manage the data */
+ req_p->flags |= req_flags;
+ return my_handle_response_get_enum_config(dev_p,
+ req_p, reply_p, config_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_GETENUMCONFIG, config_p,
+ dev_p->func_cbs_usb, req_flags, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+ * This method returns the enumerateion configuration information
+ * from the West Bridge device. Generally this is not used by
+ * client software but is provided mostly for debug information.
+ * We want a method to read all state information from the device.
+ */
+cy_as_return_status_t
+cy_as_usb_get_enum_config(cy_as_device_handle handle,
+ cy_as_usb_enum_control *config_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ return my_usb_get_enum_config(handle,
+ CY_AS_REQUEST_RESPONSE_MS, config_p, cb, client);
+}
+
+
+/*
+* This method sets the USB descriptor for a given entity.
+*/
+cy_as_return_status_t
+cy_as_usb_set_descriptor(cy_as_device_handle handle,
+ cy_as_usb_desc_type type,
+ uint8_t index,
+ void *desc_p,
+ uint16_t length,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint16_t pktlen ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_set_descriptor called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (length > CY_AS_MAX_USB_DESCRIPTOR_SIZE)
+ return CY_AS_ERROR_INVALID_DESCRIPTOR ;
+
+ pktlen = (uint16_t)length / 2 ;
+ if (length % 2)
+ pktlen++ ;
+ pktlen += 2 ; /* 1 for type, 1 for length */
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_SET_DESCRIPTOR,
+ CY_RQT_USB_RQT_CONTEXT, (uint16_t)pktlen) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((uint8_t)type | (index << 8))) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)length) ;
+ cy_as_ll_request_response__pack(req_p, 2, length, desc_p) ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_no_data(dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_SETDESCRIPTOR, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+ * This method clears all descriptors that were previously
+ * stored on the West Bridge through CyAsUsbSetDescriptor calls.
+ */
+cy_as_return_status_t
+cy_as_usb_clear_descriptors(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_clear_descriptors called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if ((cy_as_device_is_in_callback(dev_p)) && (cb == 0))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_CLEAR_DESCRIPTORS, CY_RQT_USB_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_no_data(dev_p, req_p, reply_p) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_CLEARDESCRIPTORS, 0,
+ dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_get_descriptor(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_get_descriptor_data *data)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint32_t retlen ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ goto destroy ;
+ } else if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_USB_DESCRIPTOR) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ retlen = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ if (retlen > data->length) {
+ ret = CY_AS_ERROR_INVALID_SIZE ;
+ goto destroy ;
+ }
+
+ ret = CY_AS_ERROR_SUCCESS ;
+ cy_as_ll_request_response__unpack(reply_p, 1,
+ retlen, data->desc_p) ;
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+/*
+* This method retreives the USB descriptor for a given type.
+*/
+cy_as_return_status_t
+cy_as_usb_get_descriptor(cy_as_device_handle handle,
+ cy_as_usb_desc_type type,
+ uint8_t index,
+ cy_as_get_descriptor_data *data,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_get_descriptor called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_GET_DESCRIPTOR, CY_RQT_USB_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((uint8_t)type | (index << 8))) ;
+
+ /* Add one for the length field */
+ reply_p = cy_as_ll_create_response(dev_p,
+ CY_AS_MAX_USB_DESCRIPTOR_SIZE + 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(
+ dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return my_handle_response_get_descriptor(dev_p,
+ req_p, reply_p, data) ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_GETDESCRIPTOR, data,
+ dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p,
+ reply_p, cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_set_physical_configuration(cy_as_device_handle handle,
+ uint8_t config)
+{
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6,
+ "cy_as_usb_set_physical_configuration called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ if (config < 1 || config > 12)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ dev_p->usb_phy_config = config ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static cy_bool
+is_physical_valid(uint8_t config, cy_as_end_point_number_t ep)
+{
+ static uint8_t validmask[12] = {
+ 0x0f, /* Config 1 - 1, 2, 3, 4 */
+ 0x07, /* Config 2 - 1, 2, 3 */
+ 0x07, /* Config 3 - 1, 2, 3 */
+ 0x0d, /* Config 4 - 1, 3, 4 */
+ 0x05, /* Config 5 - 1, 3 */
+ 0x05, /* Config 6 - 1, 3 */
+ 0x0d, /* Config 7 - 1, 3, 4 */
+ 0x05, /* Config 8 - 1, 3 */
+ 0x05, /* Config 9 - 1, 3 */
+ 0x0d, /* Config 10 - 1, 3, 4 */
+ 0x09, /* Config 11 - 1, 4 */
+ 0x01 /* Config 12 - 1 */
+ } ;
+
+ return (validmask[config - 1] & (1 << (ep - 1))) ? cy_true : cy_false ;
+}
+
+/*
+* This method sets the configuration for an endpoint
+*/
+cy_as_return_status_t
+cy_as_usb_set_end_point_config(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, cy_as_usb_end_point_config *config_p)
+{
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_set_end_point_config called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ if (ep >= 16 || ep == 2 || ep == 4 || ep == 6 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ if (ep == 0) {
+ /* Endpoint 0 must be 64 byte, dir IN/OUT,
+ * and control type */
+ if (config_p->dir != cy_as_usb_in_out ||
+ config_p->type != cy_as_usb_control)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+ } else if (ep == 1) {
+ if ((dev_p->is_mtp_firmware == 1) &&
+ (dev_p->usb_config[1].enabled == cy_true)) {
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+ }
+
+ /*
+ * EP1 can only be used either as an OUT ep, or as an IN ep.
+ */
+ if ((config_p->type == cy_as_usb_control) ||
+ (config_p->type == cy_as_usb_iso) ||
+ (config_p->dir == cy_as_usb_in_out))
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+ } else {
+ if (config_p->dir == cy_as_usb_in_out ||
+ config_p->type == cy_as_usb_control)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (!is_physical_valid(dev_p->usb_phy_config,
+ config_p->physical))
+ return CY_AS_ERROR_INVALID_PHYSICAL_ENDPOINT ;
+
+ /*
+ * ISO endpoints must be on E_ps 3, 5, 7 or 9 as
+ * they need to align directly with the underlying
+ * physical endpoint.
+ */
+ if (config_p->type == cy_as_usb_iso) {
+ if (ep != 3 && ep != 5 && ep != 7 && ep != 9)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (ep == 3 && config_p->physical != 1)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (ep == 5 && config_p->physical != 2)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (ep == 7 && config_p->physical != 3)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+
+ if (ep == 9 && config_p->physical != 4)
+ return CY_AS_ERROR_INVALID_CONFIGURATION ;
+ }
+ }
+
+ /* Store the configuration information until a
+ * CyAsUsbCommitConfig is done */
+ dev_p->usb_config[ep] = *config_p ;
+
+ /* If the endpoint is enabled, enable DMA associated
+ * with the endpoint */
+ /*
+ * we make some assumptions that we check here. we assume
+ * that the direction fields for the DMA module are the same
+ * values as the direction values for the USB module.
+ */
+ cy_as_hal_assert((int)cy_as_usb_in == (int)cy_as_direction_in);
+ cy_as_hal_assert((int)cy_as_usb_out == (int)cy_as_direction_out);
+ cy_as_hal_assert((int)cy_as_usb_in_out == (int)cy_as_direction_in_out) ;
+
+ return cy_as_dma_enable_end_point(dev_p, ep,
+ config_p->enabled, (cy_as_dma_direction)config_p->dir) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_get_end_point_config(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, cy_as_usb_end_point_config *config_p)
+{
+ cy_as_return_status_t ret ;
+
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_get_end_point_config called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (ep >= 16 || ep == 2 || ep == 4 || ep == 6 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ *config_p = dev_p->usb_config[ep] ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+/*
+* Commit the configuration of the various endpoints to the hardware.
+*/
+cy_as_return_status_t
+cy_as_usb_commit_config(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ uint32_t i ;
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ cy_as_device *dev_p ;
+ uint16_t data ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_commit_config called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_usb_connected(dev_p))
+ return CY_AS_ERROR_USB_CONNECTED ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /*
+ * this performs the mapping based on informatation that was
+ * previously stored on the device about the various endpoints
+ * and how they are configured. the output of this mapping is
+ * setting the the 14 register values contained in usb_lepcfg
+ * and usb_pepcfg
+ */
+ ret = cy_as_usb_map_logical2_physical(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /*
+ * now, package the information about the various logical and
+ * physical endpoint configuration registers and send it
+ * across to the west bridge device.
+ */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_SET_USB_CONFIG_REGISTERS, CY_RQT_USB_RQT_CONTEXT, 8) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_hal_print_message("USB configuration: %d\n",
+ dev_p->usb_phy_config) ;
+ cy_as_hal_print_message("EP1OUT: 0x%02x EP1IN: 0x%02x\n",
+ dev_p->usb_ep1cfg[0], dev_p->usb_ep1cfg[1]) ;
+ cy_as_hal_print_message("PEP registers: 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ dev_p->usb_pepcfg[0], dev_p->usb_pepcfg[1],
+ dev_p->usb_pepcfg[2], dev_p->usb_pepcfg[3]) ;
+
+ cy_as_hal_print_message("LEP registers: 0x%02x 0x%02x 0x%02x "
+ "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
+ dev_p->usb_lepcfg[0], dev_p->usb_lepcfg[1],
+ dev_p->usb_lepcfg[2], dev_p->usb_lepcfg[3],
+ dev_p->usb_lepcfg[4], dev_p->usb_lepcfg[5],
+ dev_p->usb_lepcfg[6], dev_p->usb_lepcfg[7],
+ dev_p->usb_lepcfg[8], dev_p->usb_lepcfg[9]) ;
+
+ /* Write the EP1OUTCFG and EP1INCFG data in the first word. */
+ data = (uint16_t)((dev_p->usb_ep1cfg[0] << 8) |
+ dev_p->usb_ep1cfg[1]) ;
+ cy_as_ll_request_response__set_word(req_p, 0, data) ;
+
+ /* Write the PEP CFG data in the next 2 words */
+ for (i = 0 ; i < 4 ; i += 2) {
+ data = (uint16_t)((dev_p->usb_pepcfg[i] << 8) |
+ dev_p->usb_pepcfg[i + 1]) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 1 + i / 2, data) ;
+ }
+
+ /* Write the LEP CFG data in the next 5 words */
+ for (i = 0 ; i < 10 ; i += 2) {
+ data = (uint16_t)((dev_p->usb_lepcfg[i] << 8) |
+ dev_p->usb_lepcfg[i + 1]) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 3 + i / 2, data) ;
+ }
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ ret = my_handle_response_no_data(dev_p,
+ req_p, reply_p) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = cy_as_usb_setup_dma(dev_p) ;
+
+ return ret ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_COMMITCONFIG, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static void
+sync_request_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p,
+ uint32_t size, cy_as_return_status_t err)
+{
+ (void)ep ;
+ (void)buf_p ;
+
+ dev_p->usb_error = err ;
+ dev_p->usb_actual_cnt = size ;
+}
+
+static void
+async_read_request_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p,
+ uint32_t size, cy_as_return_status_t err)
+{
+ cy_as_device_handle h ;
+
+ cy_as_log_debug_message(6,
+ "async_read_request_callback called") ;
+
+ h = (cy_as_device_handle)dev_p ;
+
+ if (ep == 0 && cy_as_device_is_ack_delayed(dev_p)) {
+ dev_p->usb_pending_buffer = buf_p ;
+ dev_p->usb_pending_size = size ;
+ dev_p->usb_error = err ;
+ cy_as_usb_ack_setup_packet(h, usb_ack_callback, 0) ;
+ } else {
+ cy_as_usb_io_callback cb ;
+
+ cb = dev_p->usb_cb[ep] ;
+ dev_p->usb_cb[ep] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p, ep) ;
+ if (cb)
+ cb(h, ep, size, buf_p, err) ;
+ }
+}
+
+static void
+async_write_request_callback(cy_as_device *dev_p,
+ cy_as_end_point_number_t ep, void *buf_p,
+ uint32_t size, cy_as_return_status_t err)
+{
+ cy_as_device_handle h ;
+
+ cy_as_log_debug_message(6,
+ "async_write_request_callback called") ;
+
+ h = (cy_as_device_handle)dev_p ;
+
+ if (ep == 0 && cy_as_device_is_ack_delayed(dev_p)) {
+ dev_p->usb_pending_buffer = buf_p ;
+ dev_p->usb_pending_size = size ;
+ dev_p->usb_error = err ;
+
+ /* The west bridge protocol generates ZLPs as required. */
+ cy_as_usb_ack_setup_packet(h, usb_ack_callback, 0) ;
+ } else {
+ cy_as_usb_io_callback cb ;
+
+ cb = dev_p->usb_cb[ep] ;
+ dev_p->usb_cb[ep] = 0 ;
+
+ cy_as_device_clear_usb_async_pending(dev_p, ep) ;
+ if (cb)
+ cb(h, ep, size, buf_p, err) ;
+ }
+}
+
+static void
+my_turbo_rqt_callback(cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ uint8_t code ;
+
+ (void)context ;
+ (void)stat ;
+
+ /* The Handlers are responsible for Deleting the rqt and resp when
+ * they are finished
+ */
+ code = cy_as_ll_request_response__get_code(rqt) ;
+ switch (code) {
+ case CY_RQT_TURBO_SWITCH_ENDPOINT:
+ cy_as_hal_assert(stat == CY_AS_ERROR_SUCCESS) ;
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+ cy_as_ll_destroy_response(dev_p, resp) ;
+ break;
+ default:
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+}
+
+/* Send a mailbox request to prepare the endpoint for switching */
+static cy_as_return_status_t
+my_send_turbo_switch(cy_as_device *dev_p, uint32_t size, cy_bool pktread)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+
+ /* Create the request to send to the West Bridge device */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_TURBO_SWITCH_ENDPOINT, CY_RQT_TUR_RQT_CONTEXT, 3) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Reserve space for the reply, the reply data will
+ * not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)pktread) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((size >> 16) & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(size & 0xFFFF)) ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p,
+ reply_p, cy_false, my_turbo_rqt_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_request(dev_p, reply_p) ;
+ return ret ;
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+cy_as_return_status_t
+cy_as_usb_read_data(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, cy_bool pktread,
+ uint32_t dsize, uint32_t *dataread, void *data)
+{
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_read_data called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (ep >= 16 || ep == 4 || ep == 6 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* EP2 is available for reading when MTP is active */
+ if (dev_p->mtp_count == 0 && ep == CY_AS_MTP_READ_ENDPOINT)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* If the endpoint is disabled, we cannot
+ * write data to the endpoint */
+ if (!dev_p->usb_config[ep].enabled)
+ return CY_AS_ERROR_ENDPOINT_DISABLED ;
+
+ if (dev_p->usb_config[ep].dir != cy_as_usb_out)
+ return CY_AS_ERROR_USB_BAD_DIRECTION ;
+
+ ret = cy_as_dma_queue_request(dev_p, ep, data, dsize,
+ pktread, cy_true, sync_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (ep == CY_AS_MTP_READ_ENDPOINT) {
+ ret = my_send_turbo_switch(dev_p, dsize, pktread) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, ret) ;
+ return ret ;
+ }
+
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_false) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ } else {
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_true) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ ret = dev_p->usb_error ;
+ *dataread = dev_p->usb_actual_cnt ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_read_data_async(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, cy_bool pktread,
+ uint32_t dsize, void *data, cy_as_usb_io_callback cb)
+{
+ cy_as_return_status_t ret ;
+ uint32_t mask ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_read_data_async called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (ep >= 16 || ep == 4 || ep == 6 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* EP2 is available for reading when MTP is active */
+ if (dev_p->mtp_count == 0 && ep == CY_AS_MTP_READ_ENDPOINT)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* If the endpoint is disabled, we cannot
+ * write data to the endpoint */
+ if (!dev_p->usb_config[ep].enabled)
+ return CY_AS_ERROR_ENDPOINT_DISABLED ;
+
+ if (dev_p->usb_config[ep].dir != cy_as_usb_out &&
+ dev_p->usb_config[ep].dir != cy_as_usb_in_out)
+ return CY_AS_ERROR_USB_BAD_DIRECTION ;
+
+ /*
+ * since async operations can be triggered by interrupt
+ * code, we must insure that we do not get multiple async
+ * operations going at one time and protect this test and
+ * set operation from interrupts.
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+ if (cy_as_device_is_usb_async_pending(dev_p, ep)) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+ cy_as_device_set_usb_async_pending(dev_p, ep) ;
+
+ /*
+ * if this is for EP0, we set this bit to delay the
+ * ACK response until after this read has completed.
+ */
+ if (ep == 0)
+ cy_as_device_set_ack_delayed(dev_p) ;
+
+ cy_as_hal_enable_interrupts(mask) ;
+
+ cy_as_hal_assert(dev_p->usb_cb[ep] == 0) ;
+ dev_p->usb_cb[ep] = cb ;
+
+ ret = cy_as_dma_queue_request(dev_p, ep, data, dsize,
+ pktread, cy_true, async_read_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (ep == CY_AS_MTP_READ_ENDPOINT) {
+ ret = my_send_turbo_switch(dev_p, dsize, pktread) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, ret) ;
+ return ret ;
+ }
+ } else {
+ /* Kick start the queue if it is not running */
+ cy_as_dma_kick_start(dev_p, ep) ;
+ }
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_write_data(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, uint32_t dsize, void *data)
+{
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_write_data called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (ep >= 16 || ep == 2 || ep == 4 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* EP6 is available for writing when MTP is active */
+ if (dev_p->mtp_count == 0 && ep == CY_AS_MTP_WRITE_ENDPOINT)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* If the endpoint is disabled, we cannot
+ * write data to the endpoint */
+ if (!dev_p->usb_config[ep].enabled)
+ return CY_AS_ERROR_ENDPOINT_DISABLED ;
+
+ if (dev_p->usb_config[ep].dir != cy_as_usb_in &&
+ dev_p->usb_config[ep].dir != cy_as_usb_in_out)
+ return CY_AS_ERROR_USB_BAD_DIRECTION ;
+
+ /* Write on Turbo endpoint */
+ if (ep == CY_AS_MTP_WRITE_ENDPOINT) {
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_TURBO_SEND_RESP_DATA_TO_HOST,
+ CY_RQT_TUR_RQT_CONTEXT, 3) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p,
+ 0, 0x0006) ; /* EP number to use. */
+ cy_as_ll_request_response__set_word(req_p,
+ 1, (uint16_t)((dsize >> 16) & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p,
+ 2, (uint16_t)(dsize & 0xFFFF)) ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (dsize) {
+ ret = cy_as_dma_queue_request(dev_p,
+ ep, data, dsize, cy_false,
+ cy_false, sync_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word
+ (reply_p, 0);
+ }
+
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (dsize)
+ cy_as_dma_cancel(dev_p, ep, ret) ;
+ return ret ;
+ }
+
+ /* If this is a zero-byte write, firmware will
+ * handle it. there is no need to do any work here.
+ */
+ if (!dsize)
+ return CY_AS_ERROR_SUCCESS ;
+ } else {
+ ret = cy_as_dma_queue_request(dev_p, ep, data, dsize,
+ cy_false, cy_false, sync_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ if (ep != CY_AS_MTP_WRITE_ENDPOINT)
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_true) ;
+ else
+ ret = cy_as_dma_drain_queue(dev_p, ep, cy_false) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ ret = dev_p->usb_error ;
+ return ret ;
+}
+
+static void
+mtp_write_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ cy_as_usb_io_callback cb ;
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+
+ cy_as_hal_assert(context == CY_RQT_TUR_RQT_CONTEXT) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ }
+
+ /* If this was a zero byte transfer request, we can
+ * call the callback from here. */
+ if ((cy_as_ll_request_response__get_word(rqt, 1) == 0) &&
+ (cy_as_ll_request_response__get_word(rqt, 2) == 0)) {
+ cb = dev_p->usb_cb[CY_AS_MTP_WRITE_ENDPOINT] ;
+ dev_p->usb_cb[CY_AS_MTP_WRITE_ENDPOINT] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p,
+ CY_AS_MTP_WRITE_ENDPOINT) ;
+ if (cb)
+ cb(h, CY_AS_MTP_WRITE_ENDPOINT, 0, 0, ret) ;
+
+ goto destroy ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ /* Firmware failed the request. Cancel the DMA transfer. */
+ cy_as_dma_cancel(dev_p, 0x06, CY_AS_ERROR_CANCELED) ;
+ dev_p->usb_cb[0x06] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p, 0x06) ;
+ }
+
+destroy:
+ cy_as_ll_destroy_response(dev_p, resp) ;
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_write_data_async(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep, uint32_t dsize, void *data,
+ cy_bool spacket, cy_as_usb_io_callback cb)
+{
+ uint32_t mask ;
+ cy_as_return_status_t ret ;
+ cy_as_device *dev_p ;
+
+ cy_as_log_debug_message(6, "cy_as_usb_write_data_async called") ;
+
+ dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (ep >= 16 || ep == 2 || ep == 4 || ep == 8)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* EP6 is available for writing when MTP is active */
+ if (dev_p->mtp_count == 0 && ep == CY_AS_MTP_WRITE_ENDPOINT)
+ return CY_AS_ERROR_INVALID_ENDPOINT ;
+
+ /* If the endpoint is disabled, we cannot
+ * write data to the endpoint */
+ if (!dev_p->usb_config[ep].enabled)
+ return CY_AS_ERROR_ENDPOINT_DISABLED ;
+
+ if (dev_p->usb_config[ep].dir != cy_as_usb_in &&
+ dev_p->usb_config[ep].dir != cy_as_usb_in_out)
+ return CY_AS_ERROR_USB_BAD_DIRECTION ;
+
+ /*
+ * since async operations can be triggered by interrupt
+ * code, we must insure that we do not get multiple
+ * async operations going at one time and
+ * protect this test and set operation from interrupts.
+ */
+ mask = cy_as_hal_disable_interrupts() ;
+ if (cy_as_device_is_usb_async_pending(dev_p, ep)) {
+ cy_as_hal_enable_interrupts(mask) ;
+ return CY_AS_ERROR_ASYNC_PENDING ;
+ }
+
+ cy_as_device_set_usb_async_pending(dev_p, ep) ;
+
+ if (ep == 0)
+ cy_as_device_set_ack_delayed(dev_p) ;
+
+ cy_as_hal_enable_interrupts(mask) ;
+
+ cy_as_hal_assert(dev_p->usb_cb[ep] == 0) ;
+ dev_p->usb_cb[ep] = cb ;
+ dev_p->usb_spacket[ep] = spacket ;
+
+ /* Write on Turbo endpoint */
+ if (ep == CY_AS_MTP_WRITE_ENDPOINT) {
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_TURBO_SEND_RESP_DATA_TO_HOST,
+ CY_RQT_TUR_RQT_CONTEXT, 3) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ 0x0006) ; /* EP number to use. */
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)((dsize >> 16) & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)(dsize & 0xFFFF)) ;
+
+ /* Reserve space for the reply, the reply data
+ * will not exceed one word */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (dsize) {
+ ret = cy_as_dma_queue_request(dev_p, ep, data,
+ dsize, cy_false, cy_false,
+ async_write_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_false, mtp_write_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (dsize)
+ cy_as_dma_cancel(dev_p, ep, ret) ;
+ return ret ;
+ }
+
+ /* Firmware will handle a zero byte transfer
+ * without any DMA transfers. */
+ if (!dsize)
+ return CY_AS_ERROR_SUCCESS ;
+ } else {
+ ret = cy_as_dma_queue_request(dev_p, ep, data, dsize,
+ cy_false, cy_false, async_write_request_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+ }
+
+ /* Kick start the queue if it is not running */
+ if (ep != CY_AS_MTP_WRITE_ENDPOINT)
+ cy_as_dma_kick_start(dev_p, ep) ;
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+my_usb_cancel_async_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ uint8_t ep ;
+ (void)context ;
+
+ ep = (uint8_t)cy_as_ll_request_response__get_word(rqt, 0) ;
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ }
+
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+ cy_as_ll_destroy_response(dev_p, resp) ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ dev_p->usb_cb[ep] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p, ep) ;
+ }
+}
+
+cy_as_return_status_t
+cy_as_usb_cancel_async(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p, *reply_p ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ep &= 0x7F; /* Remove the direction bit. */
+ if (!cy_as_device_is_usb_async_pending(dev_p, ep))
+ return CY_AS_ERROR_ASYNC_NOT_PENDING;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_suspend_mode(dev_p))
+ return CY_AS_ERROR_IN_SUSPEND ;
+
+ if ((ep == CY_AS_MTP_WRITE_ENDPOINT) ||
+ (ep == CY_AS_MTP_READ_ENDPOINT)) {
+ /* Need firmware support for the cancel operation. */
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_CANCEL_ASYNC_TRANSFER,
+ CY_RQT_TUR_RQT_CONTEXT, 1) ;
+
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)ep) ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_false, my_usb_cancel_async_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ return ret ;
+ }
+ } else {
+ ret = cy_as_dma_cancel(dev_p, ep, CY_AS_ERROR_CANCELED) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ dev_p->usb_cb[ep] = 0 ;
+ cy_as_device_clear_usb_async_pending(dev_p, ep) ;
+ }
+
+ return CY_AS_ERROR_SUCCESS ;
+}
+
+static void
+cy_as_usb_ack_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t ret)
+{
+ cy_as_func_c_b_node *node = (cy_as_func_c_b_node *)
+ dev_p->func_cbs_usb->head_p ;
+
+ (void)context ;
+
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ if (cy_as_ll_request_response__get_code(resp) !=
+ CY_RESP_SUCCESS_FAILURE)
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ else
+ ret = cy_as_ll_request_response__get_word(resp, 0) ;
+ }
+
+ node->cb_p((cy_as_device_handle)dev_p, ret,
+ node->client_data, node->data_type, node->data) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_usb) ;
+
+ cy_as_ll_destroy_request(dev_p, rqt) ;
+ cy_as_ll_destroy_response(dev_p, resp) ;
+ cy_as_device_clear_ack_delayed(dev_p) ;
+}
+
+static cy_as_return_status_t
+cy_as_usb_ack_setup_packet(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p ;
+ cy_as_ll_request_response *reply_p ;
+ cy_as_func_c_b_node *cbnode ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p) && cb == 0)
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ cy_as_hal_assert(cb != 0) ;
+
+ cbnode = cy_as_create_func_c_b_node(cb, client);
+ if (cbnode == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ req_p = cy_as_ll_create_request(dev_p, 0,
+ CY_RQT_USB_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ cy_as_ll_init_request(req_p, CY_RQT_ACK_SETUP_PACKET,
+ CY_RQT_USB_RQT_CONTEXT, 1) ;
+ cy_as_ll_init_response(reply_p, 1) ;
+
+ req_p->flags |= CY_AS_REQUEST_RESPONSE_EX ;
+
+ cy_as_insert_c_b_node(dev_p->func_cbs_usb, cbnode) ;
+
+ ret = cy_as_ll_send_request(dev_p, req_p, reply_p,
+ cy_false, cy_as_usb_ack_callback) ;
+
+ return ret ;
+}
+
+/*
+ * Flush all data in logical EP that is being NAK-ed or
+ * Stall-ed, so that this does not continue to block data
+ * on other LEPs that use the same physical EP.
+ */
+static void
+cy_as_usb_flush_logical_e_p(
+ cy_as_device *dev_p,
+ uint16_t ep)
+{
+ uint16_t addr, val, count ;
+
+ addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+ val = cy_as_hal_read_register(dev_p->tag, addr) ;
+
+ while (val) {
+ count = ((val & 0xFFF) + 1) / 2 ;
+ while (count--)
+ val = cy_as_hal_read_register(dev_p->tag, ep) ;
+
+ cy_as_hal_write_register(dev_p->tag, addr, 0) ;
+ val = cy_as_hal_read_register(dev_p->tag, addr) ;
+ }
+}
+
+static cy_as_return_status_t
+cy_as_usb_nak_stall_request(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ uint16_t request,
+ cy_bool state,
+ cy_as_usb_function_callback cb,
+ cy_as_function_callback fcb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ uint16_t data ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ if (cb)
+ cy_as_hal_assert(fcb == 0) ;
+ if (fcb)
+ cy_as_hal_assert(cb == 0) ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p) && cb == 0 && fcb == 0)
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ request, CY_RQT_USB_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Set the endpoint */
+ data = (uint8_t)ep ;
+ cy_as_ll_request_response__set_word(req_p, 0, data) ;
+
+ /* Set stall state to stalled */
+ cy_as_ll_request_response__set_word(req_p, 1, (uint8_t)state) ;
+
+ if (cb || fcb) {
+ void *cbnode ;
+ cy_as_c_b_queue *queue ;
+ if (cb) {
+ cbnode = cy_as_create_usb_func_c_b_node(cb, client) ;
+ queue = dev_p->usb_func_cbs ;
+ } else {
+ cbnode = cy_as_create_func_c_b_node(fcb, client) ;
+ queue = dev_p->func_cbs_usb ;
+ req_p->flags |= CY_AS_REQUEST_RESPONSE_EX ;
+ }
+
+ if (cbnode == 0) {
+ ret = CY_AS_ERROR_OUT_OF_MEMORY ;
+ goto destroy ;
+ } else
+ cy_as_insert_c_b_node(queue, cbnode) ;
+
+
+ if (cy_as_device_is_setup_packet(dev_p)) {
+ /* No Ack is needed on a stall request on EP0 */
+ if ((state == cy_true) && (ep == 0)) {
+ cy_as_device_set_ep0_stalled(dev_p) ;
+ } else {
+ cy_as_device_set_ack_delayed(dev_p) ;
+ req_p->flags |=
+ CY_AS_REQUEST_RESPONSE_DELAY_ACK ;
+ }
+ }
+
+ ret = cy_as_ll_send_request(dev_p, req_p,
+ reply_p, cy_false, cy_as_usb_func_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ if (req_p->flags & CY_AS_REQUEST_RESPONSE_DELAY_ACK)
+ cy_as_device_rem_ack_delayed(dev_p) ;
+ cy_as_remove_c_b_tail_node(queue) ;
+
+ goto destroy ;
+ }
+ } else {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) !=
+ CY_RESP_SUCCESS_FAILURE) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+
+ if ((ret == CY_AS_ERROR_SUCCESS) &&
+ (request == CY_RQT_STALL_ENDPOINT)) {
+ if ((ep > 1) && (state != 0) &&
+ (dev_p->usb_config[ep].dir == cy_as_usb_out))
+ cy_as_usb_flush_logical_e_p(dev_p, ep) ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+ }
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_get_stall(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_bool *state_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code = cy_as_ll_request_response__get_code(reply_p) ;
+
+ if (code == CY_RESP_SUCCESS_FAILURE) {
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ goto destroy ;
+ } else if (code != CY_RESP_ENDPOINT_STALL) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ *state_p = (cy_bool)cy_as_ll_request_response__get_word(reply_p, 0) ;
+ ret = CY_AS_ERROR_SUCCESS ;
+
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+my_handle_response_get_nak(cy_as_device *dev_p,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_bool *state_p)
+{
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+ uint8_t code = cy_as_ll_request_response__get_code(reply_p) ;
+
+ if (code == CY_RESP_SUCCESS_FAILURE) {
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ goto destroy ;
+ } else if (code != CY_RESP_ENDPOINT_NAK) {
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ goto destroy ;
+ }
+
+ *state_p = (cy_bool)cy_as_ll_request_response__get_word(reply_p, 0) ;
+ ret = CY_AS_ERROR_SUCCESS ;
+
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static cy_as_return_status_t
+cy_as_usb_get_nak_stall(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ uint16_t request,
+ uint16_t response,
+ cy_bool *state_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ uint16_t data ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+
+ (void)response ;
+
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p) && !cb)
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ req_p = cy_as_ll_create_request(dev_p, request,
+ CY_RQT_USB_RQT_CONTEXT, 1) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* Set the endpoint */
+ data = (uint8_t)ep ;
+ cy_as_ll_request_response__set_word(req_p, 0, (uint16_t)ep) ;
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p,
+ req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (request == CY_RQT_GET_STALL)
+ return my_handle_response_get_stall(dev_p,
+ req_p, reply_p, state_p) ;
+ else
+ return my_handle_response_get_nak(dev_p,
+ req_p, reply_p, state_p) ;
+
+ } else {
+ cy_as_funct_c_b_type type ;
+
+ if (request == CY_RQT_GET_STALL)
+ type = CY_FUNCT_CB_USB_GETSTALL ;
+ else
+ type = CY_FUNCT_CB_USB_GETNAK ;
+
+ ret = cy_as_misc_send_request(dev_p, cb, client, type,
+ state_p, dev_p->func_cbs_usb, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_set_nak(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate direction
+ * bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_count > 0)
+ return CY_AS_ERROR_NOT_VALID_IN_MTP ;
+
+ return cy_as_usb_nak_stall_request(handle, ep,
+ CY_RQT_ENDPOINT_SET_NAK, cy_true, 0, cb, client) ;
+}
+
+
+cy_as_return_status_t
+cy_as_usb_clear_nak(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate
+ * direction bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_count > 0)
+ return CY_AS_ERROR_NOT_VALID_IN_MTP ;
+
+ return cy_as_usb_nak_stall_request(handle, ep,
+ CY_RQT_ENDPOINT_SET_NAK, cy_false, 0, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_get_nak(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_bool *nak_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate
+ * direction bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_count > 0)
+ return CY_AS_ERROR_NOT_VALID_IN_MTP ;
+
+ return cy_as_usb_get_nak_stall(handle, ep,
+ CY_RQT_GET_ENDPOINT_NAK, CY_RESP_ENDPOINT_NAK,
+ nak_p, cb, client) ;
+}
+
+
+cy_as_return_status_t
+cy_as_usb_set_stall(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate
+ * direction bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_turbo_active)
+ return CY_AS_ERROR_NOT_VALID_DURING_MTP ;
+
+ return cy_as_usb_nak_stall_request(handle, ep,
+ CY_RQT_STALL_ENDPOINT, cy_true, 0, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_clear_stall(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate
+ * direction bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_turbo_active)
+ return CY_AS_ERROR_NOT_VALID_DURING_MTP ;
+
+ return cy_as_usb_nak_stall_request(handle, ep,
+ CY_RQT_STALL_ENDPOINT, cy_false, 0, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_get_stall(cy_as_device_handle handle,
+ cy_as_end_point_number_t ep,
+ cy_bool *stall_p,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ /*
+ * we send the firmware the EP# with the appropriate
+ * direction bit, regardless of what the user gave us.
+ */
+ ep &= 0x0f ;
+ if (dev_p->usb_config[ep].dir == cy_as_usb_in)
+ ep |= 0x80 ;
+
+ if (dev_p->mtp_turbo_active)
+ return CY_AS_ERROR_NOT_VALID_DURING_MTP ;
+
+ return cy_as_usb_get_nak_stall(handle, ep,
+ CY_RQT_GET_STALL, CY_RESP_ENDPOINT_STALL, stall_p, cb, client) ;
+}
+
+cy_as_return_status_t
+cy_as_usb_signal_remote_wakeup(cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if (cy_as_device_is_in_callback(dev_p))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ if (dev_p->usb_last_event != cy_as_event_usb_suspend)
+ return CY_AS_ERROR_NOT_IN_SUSPEND ;
+
+ req_p = cy_as_ll_create_request(dev_p,
+ CY_RQT_USB_REMOTE_WAKEUP, CY_RQT_USB_RQT_CONTEXT, 0) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_SIGNALREMOTEWAKEUP, 0,
+ dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p,
+ reply_p, cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_set_m_s_report_threshold(cy_as_device_handle handle,
+ uint32_t wr_sectors,
+ uint32_t rd_sectors,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ if ((cb == 0) && (cy_as_device_is_in_callback(dev_p)))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ /* Check if the firmware version supports this feature. */
+ if ((dev_p->media_supported[0]) && (dev_p->media_supported[0] ==
+ (1 << cy_as_media_nand)))
+ return CY_AS_ERROR_NOT_SUPPORTED ;
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_USB_STORAGE_MONITOR,
+ CY_RQT_USB_RQT_CONTEXT, 4) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Set the read and write count parameters into
+ * the request structure. */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((wr_sectors >> 16) & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 1,
+ (uint16_t)(wr_sectors & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 2,
+ (uint16_t)((rd_sectors >> 16) & 0xFFFF)) ;
+ cy_as_ll_request_response__set_word(req_p, 3,
+ (uint16_t)(rd_sectors & 0xFFFF)) ;
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_USB_SET_MSREPORT_THRESHOLD, 0,
+ dev_p->func_cbs_usb, CY_AS_REQUEST_RESPONSE_EX,
+ req_p, reply_p, cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+cy_as_return_status_t
+cy_as_usb_select_m_s_partitions(
+ cy_as_device_handle handle,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_usb_m_s_type_t type,
+ cy_as_function_callback cb,
+ uint32_t client)
+{
+ cy_as_return_status_t ret ;
+ cy_as_ll_request_response *req_p , *reply_p ;
+ uint16_t val ;
+
+ cy_as_device *dev_p = (cy_as_device *)handle ;
+ if (!dev_p || (dev_p->sig != CY_AS_DEVICE_HANDLE_SIGNATURE))
+ return CY_AS_ERROR_INVALID_HANDLE ;
+
+ ret = is_usb_active(dev_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ return ret ;
+
+ /* This API has to be made before SetEnumConfig is called. */
+ if (dev_p->usb_config[0].enabled)
+ return CY_AS_ERROR_INVALID_CALL_SEQUENCE ;
+
+ if ((cb == 0) && (cy_as_device_is_in_callback(dev_p)))
+ return CY_AS_ERROR_INVALID_IN_CALLBACK ;
+
+ req_p = cy_as_ll_create_request(dev_p, CY_RQT_MS_PARTITION_SELECT,
+ CY_RQT_USB_RQT_CONTEXT, 2) ;
+ if (req_p == 0)
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+
+ /* A single status word response type */
+ reply_p = cy_as_ll_create_response(dev_p, 1) ;
+ if (reply_p == 0) {
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ return CY_AS_ERROR_OUT_OF_MEMORY ;
+ }
+
+ /* Set the read and write count parameters into
+ * the request structure. */
+ cy_as_ll_request_response__set_word(req_p, 0,
+ (uint16_t)((bus << 8) | device)) ;
+
+ val = 0 ;
+ if ((type == cy_as_usb_m_s_unit0) || (type == cy_as_usb_m_s_both))
+ val |= 1 ;
+ if ((type == cy_as_usb_m_s_unit1) || (type == cy_as_usb_m_s_both))
+ val |= (1 << 8) ;
+
+ cy_as_ll_request_response__set_word(req_p, 1, val) ;
+
+ if (cb == 0) {
+ ret = cy_as_ll_send_request_wait_reply(dev_p, req_p, reply_p) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+
+ if (cy_as_ll_request_response__get_code(reply_p) ==
+ CY_RESP_SUCCESS_FAILURE)
+ ret = cy_as_ll_request_response__get_word(reply_p, 0) ;
+ else
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ } else {
+ ret = cy_as_misc_send_request(dev_p, cb, client,
+ CY_FUNCT_CB_NODATA, 0, dev_p->func_cbs_usb,
+ CY_AS_REQUEST_RESPONSE_EX, req_p, reply_p,
+ cy_as_usb_func_callback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ goto destroy ;
+ return ret ;
+ }
+
+destroy:
+ cy_as_ll_destroy_request(dev_p, req_p) ;
+ cy_as_ll_destroy_response(dev_p, reply_p) ;
+
+ return ret ;
+}
+
+static void
+cy_as_usb_func_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_ll_request_response *rqt,
+ cy_as_ll_request_response *resp,
+ cy_as_return_status_t stat)
+{
+ cy_as_usb_func_c_b_node* node = (cy_as_usb_func_c_b_node *)
+ dev_p->usb_func_cbs->head_p ;
+ cy_as_func_c_b_node* fnode = (cy_as_func_c_b_node *)
+ dev_p->func_cbs_usb->head_p ;
+ cy_as_return_status_t ret = CY_AS_ERROR_SUCCESS ;
+
+ cy_as_device_handle h = (cy_as_device_handle)dev_p ;
+ cy_bool delayed_ack = (rqt->flags & CY_AS_REQUEST_RESPONSE_DELAY_ACK)
+ == CY_AS_REQUEST_RESPONSE_DELAY_ACK;
+ cy_bool ex_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_EX)
+ == CY_AS_REQUEST_RESPONSE_EX ;
+ cy_bool ms_request = (rqt->flags & CY_AS_REQUEST_RESPONSE_MS)
+ == CY_AS_REQUEST_RESPONSE_MS ;
+ uint8_t code ;
+ uint8_t ep, state ;
+
+ if (!ex_request && !ms_request) {
+ cy_as_hal_assert(dev_p->usb_func_cbs->count != 0) ;
+ cy_as_hal_assert(dev_p->usb_func_cbs->type ==
+ CYAS_USB_FUNC_CB) ;
+ } else {
+ cy_as_hal_assert(dev_p->func_cbs_usb->count != 0) ;
+ cy_as_hal_assert(dev_p->func_cbs_usb->type == CYAS_FUNC_CB) ;
+ }
+
+ (void)context ;
+
+ /* The Handlers are responsible for Deleting the rqt and resp when
+ * they are finished
+ */
+ code = cy_as_ll_request_response__get_code(rqt) ;
+ switch (code) {
+ case CY_RQT_START_USB:
+ ret = my_handle_response_usb_start(dev_p, rqt, resp, stat) ;
+ break ;
+ case CY_RQT_STOP_USB:
+ ret = my_handle_response_usb_stop(dev_p, rqt, resp, stat) ;
+ break ;
+ case CY_RQT_SET_CONNECT_STATE:
+ if (!cy_as_ll_request_response__get_word(rqt, 0))
+ ret = my_handle_response_disconnect(
+ dev_p, rqt, resp, stat) ;
+ else
+ ret = my_handle_response_connect(
+ dev_p, rqt, resp, stat) ;
+ break ;
+ case CY_RQT_GET_CONNECT_STATE:
+ break ;
+ case CY_RQT_SET_USB_CONFIG:
+ ret = my_handle_response_set_enum_config(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_GET_USB_CONFIG:
+ cy_as_hal_assert(fnode->data != 0) ;
+ ret = my_handle_response_get_enum_config(dev_p,
+ rqt, resp, fnode->data) ;
+ break ;
+ case CY_RQT_STALL_ENDPOINT:
+ ep = (uint8_t)cy_as_ll_request_response__get_word(rqt, 0) ;
+ state = (uint8_t)cy_as_ll_request_response__get_word(rqt, 1) ;
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ if ((ret == CY_AS_ERROR_SUCCESS) && (ep > 1) && (state != 0)
+ && (dev_p->usb_config[ep].dir == cy_as_usb_out))
+ cy_as_usb_flush_logical_e_p(dev_p, ep) ;
+ break ;
+ case CY_RQT_GET_STALL:
+ cy_as_hal_assert(fnode->data != 0) ;
+ ret = my_handle_response_get_stall(dev_p,
+ rqt, resp, (cy_bool *)fnode->data) ;
+ break ;
+ case CY_RQT_SET_DESCRIPTOR:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_GET_DESCRIPTOR:
+ cy_as_hal_assert(fnode->data != 0) ;
+ ret = my_handle_response_get_descriptor(dev_p,
+ rqt, resp, (cy_as_get_descriptor_data *)fnode->data) ;
+ break;
+ case CY_RQT_SET_USB_CONFIG_REGISTERS:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ if (ret == CY_AS_ERROR_SUCCESS)
+ ret = cy_as_usb_setup_dma(dev_p) ;
+ break ;
+ case CY_RQT_ENDPOINT_SET_NAK:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_GET_ENDPOINT_NAK:
+ cy_as_hal_assert(fnode->data != 0) ;
+ ret = my_handle_response_get_nak(dev_p,
+ rqt, resp, (cy_bool *)fnode->data) ;
+ break ;
+ case CY_RQT_ACK_SETUP_PACKET:
+ break ;
+ case CY_RQT_USB_REMOTE_WAKEUP:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_CLEAR_DESCRIPTORS:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_USB_STORAGE_MONITOR:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ case CY_RQT_MS_PARTITION_SELECT:
+ ret = my_handle_response_no_data(dev_p, rqt, resp) ;
+ break ;
+ default:
+ ret = CY_AS_ERROR_INVALID_RESPONSE ;
+ cy_as_hal_assert(cy_false) ;
+ break ;
+ }
+
+ /*
+ * if the low level layer returns a direct error, use
+ * the corresponding error code. if not, use the error
+ * code based on the response from firmware.
+ */
+ if (stat == CY_AS_ERROR_SUCCESS)
+ stat = ret ;
+
+ if (ex_request || ms_request) {
+ fnode->cb_p((cy_as_device_handle)dev_p, stat,
+ fnode->client_data, fnode->data_type, fnode->data) ;
+ cy_as_remove_c_b_node(dev_p->func_cbs_usb) ;
+ } else {
+ node->cb_p((cy_as_device_handle)dev_p, stat,
+ node->client_data) ;
+ cy_as_remove_c_b_node(dev_p->usb_func_cbs) ;
+ }
+
+ if (delayed_ack) {
+ cy_as_hal_assert(cy_as_device_is_ack_delayed(dev_p)) ;
+ cy_as_device_rem_ack_delayed(dev_p) ;
+
+ /*
+ * send the ACK if required.
+ */
+ if (!cy_as_device_is_ack_delayed(dev_p))
+ cy_as_usb_ack_setup_packet(h,
+ usb_ack_callback, 0) ;
+ }
+}
+
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c b/drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c
new file mode 100644
index 000000000000..a0759ee76249
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/arch/arm/mach-omap2/cyashalomap_kernel.c
@@ -0,0 +1,2450 @@
+/* Cypress WestBridge OMAP3430 Kernel Hal source file (cyashalomap_kernel.c)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor,
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+
+#include <linux/fs.h>
+#include <linux/ioport.h>
+#include <linux/timer.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/scatterlist.h>
+#include <linux/mm.h>
+#include <linux/irq.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+/* include seems broken moving for patch submission
+ * #include <mach/mux.h>
+ * #include <mach/gpmc.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h>
+ * #include <mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h>
+ * #include <linux/westbridge/cyaserr.h>
+ * #include <linux/westbridge/cyasregs.h>
+ * #include <linux/westbridge/cyasdma.h>
+ * #include <linux/westbridge/cyasintr.h>
+ */
+#include <linux/../../arch/arm/plat-omap/include/plat/mux.h>
+#include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h"
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h"
+#include "../plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h"
+#include "../../../include/linux/westbridge/cyaserr.h"
+#include "../../../include/linux/westbridge/cyasregs.h"
+#include "../../../include/linux/westbridge/cyasdma.h"
+#include "../../../include/linux/westbridge/cyasintr.h"
+
+#define HAL_REV "1.1.0"
+
+/*
+ * uncomment to enable 16bit pnand interface
+ */
+#define PNAND_16BIT_MODE
+
+/*
+ * selects one of 3 versions of pnand_lbd_read()
+ * PNAND_LBD_READ_NO_PFE - original 8/16 bit code
+ * reads through the gpmc CONTROLLER REGISTERS
+ * ENABLE_GPMC_PF_ENGINE - USES GPMC PFE FIFO reads, in 8 bit mode,
+ * same speed as the above
+ * PFE_LBD_READ_V2 - slightly diffrenet, performance same as above
+ */
+#define PNAND_LBD_READ_NO_PFE
+/* #define ENABLE_GPMC_PF_ENGINE */
+/* #define PFE_LBD_READ_V2 */
+
+/*
+ * westbrige astoria ISR options to limit number of
+ * back to back DMA transfers per ISR interrupt
+ */
+#define MAX_DRQ_LOOPS_IN_ISR 4
+
+/*
+ * debug prints enabling
+ *#define DBGPRN_ENABLED
+ *#define DBGPRN_DMA_SETUP_RD
+ *#define DBGPRN_DMA_SETUP_WR
+ */
+
+
+/*
+ * For performance reasons, we handle storage endpoint transfers upto 4 KB
+ * within the HAL itself.
+ */
+ #define CYASSTORAGE_WRITE_EP_NUM (4)
+ #define CYASSTORAGE_READ_EP_NUM (8)
+
+/*
+ * size of DMA packet HAL can accept from Storage API
+ * HAL will fragment it into smaller chunks that the P port can accept
+ */
+#define CYASSTORAGE_MAX_XFER_SIZE (2*32768)
+
+/*
+ * P port MAX DMA packet size according to interface/ep configurartion
+ */
+#define HAL_DMA_PKT_SZ 512
+
+#define is_storage_e_p(ep) (((ep) == 2) || ((ep) == 4) || \
+ ((ep) == 6) || ((ep) == 8))
+
+/*
+ * persistant, stores current GPMC interface cfg mode
+ */
+static uint8_t pnand_16bit;
+
+/*
+ * keep processing new WB DRQ in ISR untill all handled (performance feature)
+ */
+#define PROCESS_MULTIPLE_DRQ_IN_ISR (1)
+
+
+/*
+ * ASTORIA PNAND IF COMMANDS, CASDO - READ, CASDI - WRITE
+ */
+#define CASDO 0x05
+#define CASDI 0x85
+#define RDPAGE_B1 0x00
+#define RDPAGE_B2 0x30
+#define PGMPAGE_B1 0x80
+#define PGMPAGE_B2 0x10
+
+/*
+ * The type of DMA operation, per endpoint
+ */
+typedef enum cy_as_hal_dma_type {
+ cy_as_hal_read,
+ cy_as_hal_write,
+ cy_as_hal_none
+} cy_as_hal_dma_type ;
+
+
+/*
+ * SG list halpers defined in scaterlist.h
+#define sg_is_chain(sg) ((sg)->page_link & 0x01)
+#define sg_is_last(sg) ((sg)->page_link & 0x02)
+#define sg_chain_ptr(sg) \
+ ((struct scatterlist *) ((sg)->page_link & ~0x03))
+*/
+typedef struct cy_as_hal_endpoint_dma {
+ cy_bool buffer_valid ;
+ uint8_t *data_p ;
+ uint32_t size ;
+ /*
+ * sg_list_enabled - if true use, r/w DMA transfers use sg list,
+ * FALSE use pointer to a buffer
+ * sg_p - pointer to the owner's sg list, of there is such
+ * (like blockdriver)
+ * dma_xfer_sz - size of the next dma xfer on P port
+ * seg_xfer_cnt - counts xfered bytes for in current sg_list
+ * memory segment
+ * req_xfer_cnt - total number of bytes transfered so far in
+ * current request
+ * req_length - total request length
+ */
+ bool sg_list_enabled;
+ struct scatterlist *sg_p ;
+ uint16_t dma_xfer_sz;
+ uint32_t seg_xfer_cnt;
+ uint16_t req_xfer_cnt;
+ uint16_t req_length;
+ cy_as_hal_dma_type type ;
+ cy_bool pending ;
+} cy_as_hal_endpoint_dma ;
+
+/*
+ * The list of OMAP devices (should be one)
+ */
+static cy_as_omap_dev_kernel *m_omap_list_p;
+
+/*
+ * The callback to call after DMA operations are complete
+ */
+static cy_as_hal_dma_complete_callback callback;
+
+/*
+ * Pending data size for the endpoints
+ */
+static cy_as_hal_endpoint_dma end_points[16] ;
+
+/*
+ * Forward declaration
+ */
+static void cy_handle_d_r_q_interrupt(cy_as_omap_dev_kernel *dev_p);
+
+static uint16_t intr_sequence_num;
+static uint8_t intr__enable;
+spinlock_t int_lock ;
+
+static u32 iomux_vma;
+static u32 csa_phy;
+
+/*
+ * gpmc I/O registers VMA
+ */
+static u32 gpmc_base ;
+
+/*
+ * gpmc data VMA associated with CS4 (ASTORIA CS on GPMC)
+ */
+static u32 gpmc_data_vma;
+static u32 ndata_reg_vma;
+static u32 ncmd_reg_vma;
+static u32 naddr_reg_vma;
+
+/*
+ * fwd declarations
+ */
+static void p_nand_lbd_read(u16 col_addr, u32 row_addr, u16 count, void *buff);
+static void p_nand_lbd_write(u16 col_addr, u32 row_addr, u16 count, void *buff);
+static inline u16 __attribute__((always_inline))
+ ast_p_nand_casdo_read(u8 reg_addr8);
+static inline void __attribute__((always_inline))
+ ast_p_nand_casdi_write(u8 reg_addr8, u16 data);
+
+/*
+ * prints given number of omap registers
+ */
+static void cy_as_hal_print_omap_regs(char *name_prefix,
+ u8 name_base, u32 virt_base, u16 count)
+{
+ u32 reg_val, reg_addr;
+ u16 i;
+ cy_as_hal_print_message(KERN_INFO "\n");
+ for (i = 0; i < count; i++) {
+
+ reg_addr = virt_base + (i*4);
+ /* use virtual addresses here*/
+ reg_val = __raw_readl(reg_addr);
+ cy_as_hal_print_message(KERN_INFO "%s_%d[%8.8x]=%8.8x\n",
+ name_prefix, name_base+i,
+ reg_addr, reg_val);
+ }
+}
+
+/*
+ * setMUX function for a pad + additional pad flags
+ */
+static u16 omap_cfg_reg_L(u32 pad_func_index)
+{
+ static u8 sanity_check = 1;
+
+ u32 reg_vma;
+ u16 cur_val, wr_val, rdback_val;
+
+ /*
+ * do sanity check on the omap_mux_pin_cfg[] table
+ */
+ cy_as_hal_print_message(KERN_INFO" OMAP pins user_pad cfg ");
+ if (sanity_check) {
+ if ((omap_mux_pin_cfg[END_OF_TABLE].name[0] == 'E') &&
+ (omap_mux_pin_cfg[END_OF_TABLE].name[1] == 'N') &&
+ (omap_mux_pin_cfg[END_OF_TABLE].name[2] == 'D')) {
+
+ cy_as_hal_print_message(KERN_INFO
+ "table is good.\n");
+ } else {
+ cy_as_hal_print_message(KERN_WARNING
+ "table is bad, fix it");
+ }
+ /*
+ * do it only once
+ */
+ sanity_check = 0;
+ }
+
+ /*
+ * get virtual address to the PADCNF_REG
+ */
+ reg_vma = (u32)iomux_vma + omap_mux_pin_cfg[pad_func_index].offset;
+
+ /*
+ * add additional USER PU/PD/EN flags
+ */
+ wr_val = omap_mux_pin_cfg[pad_func_index].mux_val;
+ cur_val = IORD16(reg_vma);
+
+ /*
+ * PADCFG regs 16 bit long, packed into 32 bit regs,
+ * can also be accessed as u16
+ */
+ IOWR16(reg_vma, wr_val);
+ rdback_val = IORD16(reg_vma);
+
+ /*
+ * in case if the caller wants to save the old value
+ */
+ return wr_val;
+}
+
+#define BLKSZ_4K 0x1000
+
+/*
+ * switch GPMC DATA bus mode
+ */
+void cy_as_hal_gpmc_enable_16bit_bus(bool dbus16_enabled)
+{
+ uint32_t tmp32;
+
+ /*
+ * disable gpmc CS4 operation 1st
+ */
+ tmp32 = gpmc_cs_read_reg(AST_GPMC_CS,
+ GPMC_CS_CONFIG7) & ~GPMC_CONFIG7_CSVALID;
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG7, tmp32);
+
+ /*
+ * GPMC NAND data bus can be 8 or 16 bit wide
+ */
+ if (dbus16_enabled) {
+ DBGPRN("enabling 16 bit bus\n");
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1,
+ (GPMC_CONFIG1_DEVICETYPE(2) |
+ GPMC_CONFIG1_WAIT_PIN_SEL(2) |
+ GPMC_CONFIG1_DEVICESIZE_16)
+ );
+ } else {
+ DBGPRN(KERN_INFO "enabling 8 bit bus\n");
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1,
+ (GPMC_CONFIG1_DEVICETYPE(2) |
+ GPMC_CONFIG1_WAIT_PIN_SEL(2))
+ );
+ }
+
+ /*
+ * re-enable astoria CS operation on GPMC
+ */
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG7,
+ (tmp32 | GPMC_CONFIG7_CSVALID));
+
+ /*
+ *remember the state
+ */
+ pnand_16bit = dbus16_enabled;
+}
+
+static int cy_as_hal_gpmc_init(void)
+{
+ u32 tmp32;
+ int err;
+ struct gpmc_timings timings;
+ /*
+ * get GPMC i/o registers base(already been i/o mapped
+ * in kernel, no need for separate i/o remap)
+ */
+ gpmc_base = phys_to_virt(OMAP34XX_GPMC_BASE);
+ DBGPRN(KERN_INFO "kernel has gpmc_base=%x , val@ the base=%x",
+ gpmc_base, __raw_readl(gpmc_base)
+ );
+
+ /*
+ * these are globals are full VMAs of the gpmc_base above
+ */
+ ncmd_reg_vma = GPMC_VMA(GPMC_NAND_CMD);
+ naddr_reg_vma = GPMC_VMA(GPMC_NAND_ADDR);
+ ndata_reg_vma = GPMC_VMA(GPMC_NAND_DATA);
+
+ /*
+ * request GPMC CS for ASTORIA request
+ */
+ if (gpmc_cs_request(AST_GPMC_CS, SZ_16M, (void *)&csa_phy) < 0) {
+ cy_as_hal_print_message(KERN_ERR "error failed to request"
+ "ncs4 for ASTORIA\n");
+ return -1;
+ } else {
+ DBGPRN(KERN_INFO "got phy_addr:%x for "
+ "GPMC CS%d GPMC_CFGREG7[CS4]\n",
+ csa_phy, AST_GPMC_CS);
+ }
+
+ /*
+ * request VM region for 4K addr space for chip select 4 phy address
+ * technically we don't need it for NAND devices, but do it anyway
+ * so that data read/write bus cycle can be triggered by reading
+ * or writing this mem region
+ */
+ if (!request_mem_region(csa_phy, BLKSZ_4K, "AST_OMAP_HAL")) {
+ err = -EBUSY;
+ cy_as_hal_print_message(KERN_ERR "error MEM region "
+ "request for phy_addr:%x failed\n",
+ csa_phy);
+ goto out_free_cs;
+ }
+
+ /*
+ * REMAP mem region associated with our CS
+ */
+ gpmc_data_vma = (u32)ioremap_nocache(csa_phy, BLKSZ_4K);
+ if (!gpmc_data_vma) {
+ err = -ENOMEM;
+ cy_as_hal_print_message(KERN_ERR "error- ioremap()"
+ "for phy_addr:%x failed", csa_phy);
+
+ goto out_release_mem_region;
+ }
+ cy_as_hal_print_message(KERN_INFO "ioremap(%x) returned vma=%x\n",
+ csa_phy, gpmc_data_vma);
+
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1,
+ (GPMC_CONFIG1_DEVICETYPE(2) |
+ GPMC_CONFIG1_WAIT_PIN_SEL(2)));
+
+ memset(&timings, 0, sizeof(timings));
+
+ /* cs timing */
+ timings.cs_on = WB_GPMC_CS_t_o_n;
+ timings.cs_wr_off = WB_GPMC_BUSCYC_t;
+ timings.cs_rd_off = WB_GPMC_BUSCYC_t;
+
+ /* adv timing */
+ timings.adv_on = WB_GPMC_ADV_t_o_n;
+ timings.adv_rd_off = WB_GPMC_BUSCYC_t;
+ timings.adv_wr_off = WB_GPMC_BUSCYC_t;
+
+ /* oe timing */
+ timings.oe_on = WB_GPMC_OE_t_o_n;
+ timings.oe_off = WB_GPMC_OE_t_o_f_f;
+ timings.access = WB_GPMC_RD_t_a_c_c;
+ timings.rd_cycle = WB_GPMC_BUSCYC_t;
+
+ /* we timing */
+ timings.we_on = WB_GPMC_WE_t_o_n;
+ timings.we_off = WB_GPMC_WE_t_o_f_f;
+ timings.wr_access = WB_GPMC_WR_t_a_c_c;
+ timings.wr_cycle = WB_GPMC_BUSCYC_t;
+
+ timings.page_burst_access = WB_GPMC_BUSCYC_t;
+ timings.wr_data_mux_bus = WB_GPMC_BUSCYC_t;
+ gpmc_cs_set_timings(AST_GPMC_CS, &timings);
+
+ cy_as_hal_print_omap_regs("GPMC_CONFIG", 1,
+ GPMC_VMA(GPMC_CFG_REG(1, AST_GPMC_CS)), 7);
+
+ /*
+ * DISABLE cs4, NOTE GPMC REG7 is already configured
+ * at this point by gpmc_cs_request
+ */
+ tmp32 = gpmc_cs_read_reg(AST_GPMC_CS, GPMC_CS_CONFIG7) &
+ ~GPMC_CONFIG7_CSVALID;
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG7, tmp32);
+
+ /*
+ * PROGRAM chip select Region, (see OMAP3430 TRM PAGE 1088)
+ */
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG7,
+ (AS_CS_MASK | AS_CS_BADDR));
+
+ /*
+ * by default configure GPMC into 8 bit mode
+ * (to match astoria default mode)
+ */
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG1,
+ (GPMC_CONFIG1_DEVICETYPE(2) |
+ GPMC_CONFIG1_WAIT_PIN_SEL(2)));
+
+ /*
+ * ENABLE astoria cs operation on GPMC
+ */
+ gpmc_cs_write_reg(AST_GPMC_CS, GPMC_CS_CONFIG7,
+ (tmp32 | GPMC_CONFIG7_CSVALID));
+
+ /*
+ * No method currently exists to write this register through GPMC APIs
+ * need to change WAIT2 polarity
+ */
+ tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG));
+ tmp32 = tmp32 | NAND_FORCE_POSTED_WRITE_B | 0x40;
+ IOWR32(GPMC_VMA(GPMC_CONFIG_REG), tmp32);
+
+ tmp32 = IORD32(GPMC_VMA(GPMC_CONFIG_REG));
+ cy_as_hal_print_message("GPMC_CONFIG_REG=0x%x\n", tmp32);
+
+ return 0;
+
+out_release_mem_region:
+ release_mem_region(csa_phy, BLKSZ_4K);
+
+out_free_cs:
+ gpmc_cs_free(AST_GPMC_CS);
+
+ return err;
+}
+
+/*
+ * west bridge astoria ISR (Interrupt handler)
+ */
+static irqreturn_t cy_astoria_int_handler(int irq,
+ void *dev_id, struct pt_regs *regs)
+{
+ cy_as_omap_dev_kernel *dev_p;
+ uint16_t read_val = 0 ;
+ uint16_t mask_val = 0 ;
+
+ /*
+ * debug stuff, counts number of loops per one intr trigger
+ */
+ uint16_t drq_loop_cnt = 0;
+ uint8_t irq_pin;
+ /*
+ * flags to watch
+ */
+ const uint16_t sentinel = (CY_AS_MEM_P0_INTR_REG_MCUINT |
+ CY_AS_MEM_P0_INTR_REG_MBINT |
+ CY_AS_MEM_P0_INTR_REG_PMINT |
+ CY_AS_MEM_P0_INTR_REG_PLLLOCKINT);
+
+ /*
+ * sample IRQ pin level (just for statistics)
+ */
+ irq_pin = __gpio_get_value(AST_INT);
+
+ /*
+ * this one just for debugging
+ */
+ intr_sequence_num++ ;
+
+ /*
+ * astoria device handle
+ */
+ dev_p = dev_id;
+
+ /*
+ * read Astoria intr register
+ */
+ read_val = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INTR_REG) ;
+
+ /*
+ * save current mask value
+ */
+ mask_val = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INT_MASK_REG) ;
+
+ DBGPRN("<1>HAL__intr__enter:_seq:%d, P0_INTR_REG:%x\n",
+ intr_sequence_num, read_val);
+
+ /*
+ * Disable WB interrupt signal generation while we are in ISR
+ */
+ cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INT_MASK_REG, 0x0000) ;
+
+ /*
+ * this is a DRQ Interrupt
+ */
+ if (read_val & CY_AS_MEM_P0_INTR_REG_DRQINT) {
+
+ do {
+ /*
+ * handle DRQ interrupt
+ */
+ drq_loop_cnt++;
+
+ cy_handle_d_r_q_interrupt(dev_p) ;
+
+ /*
+ * spending to much time in ISR may impact
+ * average system performance
+ */
+ if (drq_loop_cnt >= MAX_DRQ_LOOPS_IN_ISR)
+ break;
+
+ /*
+ * Keep processing if there is another DRQ int flag
+ */
+ } while (cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INTR_REG) &
+ CY_AS_MEM_P0_INTR_REG_DRQINT);
+ }
+
+ if (read_val & sentinel)
+ cy_as_intr_service_interrupt((cy_as_hal_device_tag)dev_p) ;
+
+ DBGPRN("<1>_hal:_intr__exit seq:%d, mask=%4.4x,"
+ "int_pin:%d DRQ_jobs:%d\n",
+ intr_sequence_num,
+ mask_val,
+ irq_pin,
+ drq_loop_cnt);
+
+ /*
+ * re-enable WB hw interrupts
+ */
+ cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INT_MASK_REG, mask_val) ;
+
+ return IRQ_HANDLED ;
+}
+
+static int cy_as_hal_configure_interrupts(void *dev_p)
+{
+ int result;
+ int irq_pin = AST_INT;
+
+ set_irq_type(OMAP_GPIO_IRQ(irq_pin), IRQ_TYPE_LEVEL_LOW);
+
+ /*
+ * for shared IRQS must provide non NULL device ptr
+ * othervise the int won't register
+ * */
+ result = request_irq(OMAP_GPIO_IRQ(irq_pin),
+ (irq_handler_t)cy_astoria_int_handler,
+ IRQF_SHARED, "AST_INT#", dev_p);
+
+ if (result == 0) {
+ /*
+ * OMAP_GPIO_IRQ(irq_pin) - omap logical IRQ number
+ * assigned to this interrupt
+ * OMAP_GPIO_BIT(AST_INT, GPIO_IRQENABLE1) - print status
+ * of AST_INT GPIO IRQ_ENABLE FLAG
+ */
+ cy_as_hal_print_message(KERN_INFO"AST_INT omap_pin:"
+ "%d assigned IRQ #%d IRQEN1=%d\n",
+ irq_pin,
+ OMAP_GPIO_IRQ(irq_pin),
+ OMAP_GPIO_BIT(AST_INT, GPIO_IRQENABLE1)
+ );
+ } else {
+ cy_as_hal_print_message("cyasomaphal: interrupt "
+ "failed to register\n");
+ gpio_free(irq_pin);
+ cy_as_hal_print_message(KERN_WARNING
+ "ASTORIA: can't get assigned IRQ"
+ "%i for INT#\n", OMAP_GPIO_IRQ(irq_pin));
+ }
+
+ return result;
+}
+
+/*
+ * initialize OMAP pads/pins to user defined functions
+ */
+static void cy_as_hal_init_user_pads(user_pad_cfg_t *pad_cfg_tab)
+{
+ /*
+ * browse through the table an dinitiaze the pins
+ */
+ u32 in_level = 0;
+ u16 tmp16, mux_val;
+
+ while (pad_cfg_tab->name != NULL) {
+
+ if (gpio_request(pad_cfg_tab->pin_num, NULL) == 0) {
+
+ pad_cfg_tab->valid = 1;
+ mux_val = omap_cfg_reg_L(pad_cfg_tab->mux_func);
+
+ /*
+ * always set drv level before changing out direction
+ */
+ __gpio_set_value(pad_cfg_tab->pin_num,
+ pad_cfg_tab->drv);
+
+ /*
+ * "0" - OUT, "1", input omap_set_gpio_direction
+ * (pad_cfg_tab->pin_num, pad_cfg_tab->dir);
+ */
+ if (pad_cfg_tab->dir)
+ gpio_direction_input(pad_cfg_tab->pin_num);
+ else
+ gpio_direction_output(pad_cfg_tab->pin_num,
+ pad_cfg_tab->drv);
+
+ /* sample the pin */
+ in_level = __gpio_get_value(pad_cfg_tab->pin_num);
+
+ cy_as_hal_print_message(KERN_INFO "configured %s to "
+ "OMAP pad_%d, DIR=%d "
+ "DOUT=%d, DIN=%d\n",
+ pad_cfg_tab->name,
+ pad_cfg_tab->pin_num,
+ pad_cfg_tab->dir,
+ pad_cfg_tab->drv,
+ in_level
+ );
+ } else {
+ /*
+ * get the pad_mux value to check on the pin_function
+ */
+ cy_as_hal_print_message(KERN_INFO "couldn't cfg pin %d"
+ "for signal %s, its already taken\n",
+ pad_cfg_tab->pin_num,
+ pad_cfg_tab->name);
+ }
+
+ tmp16 = *(u16 *)PADCFG_VMA
+ (omap_mux_pin_cfg[pad_cfg_tab->mux_func].offset);
+
+ cy_as_hal_print_message(KERN_INFO "GPIO_%d(PAD_CFG=%x,OE=%d"
+ "DOUT=%d, DIN=%d IRQEN=%d)\n\n",
+ pad_cfg_tab->pin_num, tmp16,
+ OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_OE),
+ OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_DATA_OUT),
+ OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_DATA_IN),
+ OMAP_GPIO_BIT(pad_cfg_tab->pin_num, GPIO_IRQENABLE1)
+ );
+
+ /*
+ * next pad_cfg deriptor
+ */
+ pad_cfg_tab++;
+ }
+
+ cy_as_hal_print_message(KERN_INFO"pads configured\n");
+}
+
+
+/*
+ * release gpios taken by the module
+ */
+static void cy_as_hal_release_user_pads(user_pad_cfg_t *pad_cfg_tab)
+{
+ while (pad_cfg_tab->name != NULL) {
+
+ if (pad_cfg_tab->valid) {
+ gpio_free(pad_cfg_tab->pin_num);
+ pad_cfg_tab->valid = 0;
+ cy_as_hal_print_message(KERN_INFO "GPIO_%d "
+ "released from %s\n",
+ pad_cfg_tab->pin_num,
+ pad_cfg_tab->name);
+ } else {
+ cy_as_hal_print_message(KERN_INFO "no release "
+ "for %s, GPIO_%d, wasn't acquired\n",
+ pad_cfg_tab->name,
+ pad_cfg_tab->pin_num);
+ }
+ pad_cfg_tab++;
+ }
+}
+
+void cy_as_hal_config_c_s_mux(void)
+{
+ /*
+ * FORCE the GPMC CS4 pin (it is in use by the zoom system)
+ */
+ omap_cfg_reg_L(T8_OMAP3430_GPMC_n_c_s4);
+}
+EXPORT_SYMBOL(cy_as_hal_config_c_s_mux);
+
+/*
+ * inits all omap h/w
+ */
+uint32_t cy_as_hal_processor_hw_init(void)
+{
+ int i, err;
+
+ cy_as_hal_print_message(KERN_INFO "init OMAP3430 hw...\n");
+
+ iomux_vma = (u32)ioremap_nocache(
+ (u32)CTLPADCONF_BASE_ADDR, CTLPADCONF_SIZE);
+ cy_as_hal_print_message(KERN_INFO "PADCONF_VMA=%x val=%x\n",
+ iomux_vma, IORD32(iomux_vma));
+
+ /*
+ * remap gpio banks
+ */
+ for (i = 0; i < 6; i++) {
+ gpio_vma_tab[i].virt_addr = (u32)ioremap_nocache(
+ gpio_vma_tab[i].phy_addr,
+ gpio_vma_tab[i].size);
+
+ cy_as_hal_print_message(KERN_INFO "%s virt_addr=%x\n",
+ gpio_vma_tab[i].name,
+ (u32)gpio_vma_tab[i].virt_addr);
+ };
+
+ /*
+ * force OMAP_GPIO_126 to rleased state,
+ * will be configured to drive reset
+ */
+ gpio_free(AST_RESET);
+
+ /*
+ *same thing with AStoria CS pin
+ */
+ gpio_free(AST_CS);
+
+ /*
+ * initialize all the OMAP pads connected to astoria
+ */
+ cy_as_hal_init_user_pads(user_pad_cfg);
+
+ err = cy_as_hal_gpmc_init();
+ if (err < 0)
+ cy_as_hal_print_message(KERN_INFO"gpmc init failed:%d", err);
+
+ cy_as_hal_config_c_s_mux();
+
+ return gpmc_data_vma;
+}
+EXPORT_SYMBOL(cy_as_hal_processor_hw_init);
+
+void cy_as_hal_omap_hardware_deinit(cy_as_omap_dev_kernel *dev_p)
+{
+ /*
+ * free omap hw resources
+ */
+ if (gpmc_data_vma != 0)
+ iounmap((void *)gpmc_data_vma);
+
+ if (csa_phy != 0)
+ release_mem_region(csa_phy, BLKSZ_4K);
+
+ gpmc_cs_free(AST_GPMC_CS);
+
+ free_irq(OMAP_GPIO_IRQ(AST_INT), dev_p);
+
+ cy_as_hal_release_user_pads(user_pad_cfg);
+}
+
+/*
+ * These are the functions that are not part of the
+ * HAL layer, but are required to be called for this HAL
+ */
+
+/*
+ * Called On AstDevice LKM exit
+ */
+int stop_o_m_a_p_kernel(const char *pgm, cy_as_hal_device_tag tag)
+{
+ cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+
+ /*
+ * TODO: Need to disable WB interrupt handlere 1st
+ */
+ if (0 == dev_p)
+ return 1 ;
+
+ cy_as_hal_print_message("<1>_stopping OMAP34xx HAL layer object\n");
+ if (dev_p->m_sig != CY_AS_OMAP_KERNEL_HAL_SIG) {
+ cy_as_hal_print_message("<1>%s: %s: bad HAL tag\n",
+ pgm, __func__) ;
+ return 1 ;
+ }
+
+ /*
+ * disable interrupt
+ */
+ cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INT_MASK_REG, 0x0000) ;
+
+#if 0
+ if (dev_p->thread_flag == 0) {
+ dev_p->thread_flag = 1 ;
+ wait_for_completion(&dev_p->thread_complete) ;
+ cy_as_hal_print_message("cyasomaphal:"
+ "done cleaning thread\n");
+ cy_as_hal_destroy_sleep_channel(&dev_p->thread_sc) ;
+ }
+#endif
+
+ cy_as_hal_omap_hardware_deinit(dev_p);
+
+ /*
+ * Rearrange the list
+ */
+ if (m_omap_list_p == dev_p)
+ m_omap_list_p = dev_p->m_next_p ;
+
+ cy_as_hal_free(dev_p) ;
+
+ cy_as_hal_print_message(KERN_INFO"OMAP_kernel_hal stopped\n");
+ return 0;
+}
+
+int omap_start_intr(cy_as_hal_device_tag tag)
+{
+ cy_as_omap_dev_kernel *dev_p = (cy_as_omap_dev_kernel *)tag ;
+ int ret = 0 ;
+ const uint16_t mask = CY_AS_MEM_P0_INTR_REG_DRQINT |
+ CY_AS_MEM_P0_INTR_REG_MBINT ;
+
+ /*
+ * register for interrupts
+ */
+ ret = cy_as_hal_configure_interrupts(dev_p) ;
+
+ /*
+ * enable only MBox & DRQ interrupts for now
+ */
+ cy_as_hal_write_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_INT_MASK_REG, mask) ;
+
+ return 1 ;
+}
+
+/*
+ * Below are the functions that communicate with the WestBridge device.
+ * These are system dependent and must be defined by the HAL layer
+ * for a given system.
+ */
+
+/*
+ * GPMC NAND command+addr write phase
+ */
+static inline void nand_cmd_n_addr(u8 cmdb1, u16 col_addr, u32 row_addr)
+{
+ /*
+ * byte order on the bus <cmd> <CA0,CA1,RA0,RA1, RA2>
+ */
+ u32 tmpa32 = ((row_addr << 16) | col_addr);
+ u8 RA2 = (u8)(row_addr >> 16);
+
+ if (!pnand_16bit) {
+ /*
+ * GPMC PNAND 8bit BUS
+ */
+ /*
+ * CMD1
+ */
+ IOWR8(ncmd_reg_vma, cmdb1);
+
+ /*
+ *pnand bus: <CA0,CA1,RA0,RA1>
+ */
+ IOWR32(naddr_reg_vma, tmpa32);
+
+ /*
+ * <RA2> , always zero
+ */
+ IOWR8(naddr_reg_vma, RA2);
+
+ } else {
+ /*
+ * GPMC PNAND 16bit BUS , in 16 bit mode CMD
+ * and ADDR sent on [d7..d0]
+ */
+ uint8_t CA0, CA1, RA0, RA1;
+ CA0 = tmpa32 & 0x000000ff;
+ CA1 = (tmpa32 >> 8) & 0x000000ff;
+ RA0 = (tmpa32 >> 16) & 0x000000ff;
+ RA1 = (tmpa32 >> 24) & 0x000000ff;
+
+ /*
+ * can't use 32 bit writes here omap will not serialize
+ * them to lower half in16 bit mode
+ */
+
+ /*
+ *pnand bus: <CMD1, CA0,CA1,RA0,RA1, RA2 (always zero)>
+ */
+ IOWR8(ncmd_reg_vma, cmdb1);
+ IOWR8(naddr_reg_vma, CA0);
+ IOWR8(naddr_reg_vma, CA1);
+ IOWR8(naddr_reg_vma, RA0);
+ IOWR8(naddr_reg_vma, RA1);
+ IOWR8(naddr_reg_vma, RA2);
+ }
+}
+
+/*
+ * spin until r/b goes high
+ */
+inline int wait_rn_b_high(void)
+{
+ u32 w_spins = 0;
+
+ /*
+ * TODO: note R/b may go low here, need to spin until high
+ * while (omap_get_gpio_datain(AST_RnB) == 0) {
+ * w_spins++;
+ * }
+ * if (OMAP_GPIO_BIT(AST_RnB, GPIO_DATA_IN) == 0) {
+ *
+ * while (OMAP_GPIO_BIT(AST_RnB, GPIO_DATA_IN) == 0) {
+ * w_spins++;
+ * }
+ * printk("<1>RnB=0!:%d\n",w_spins);
+ * }
+ */
+ return w_spins;
+}
+
+#ifdef ENABLE_GPMC_PF_ENGINE
+/* #define PFE_READ_DEBUG
+ * PNAND block read with OMAP PFE enabled
+ * status: Not tested, NW, broken , etc
+ */
+static void p_nand_lbd_read(u16 col_addr, u32 row_addr, u16 count, void *buff)
+{
+ uint16_t w32cnt;
+ uint32_t *ptr32;
+ uint8_t *ptr8;
+ uint8_t bytes_in_fifo;
+
+ /* debug vars*/
+#ifdef PFE_READ_DEBUG
+ uint32_t loop_limit;
+ uint16_t bytes_read = 0;
+#endif
+
+ /*
+ * configure the prefetch engine
+ */
+ uint32_t tmp32;
+ uint32_t pfe_status;
+
+ /*
+ * DISABLE GPMC CS4 operation 1st, this is
+ * in case engine is be already disabled
+ */
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONTROL), 0x0);
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONFIG1), GPMC_PREFETCH_CONFIG1_VAL);
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONFIG2), count);
+
+#ifdef PFE_READ_DEBUG
+ tmp32 = IORD32(GPMC_VMA(GPMC_PREFETCH_CONFIG1));
+ if (tmp32 != GPMC_PREFETCH_CONFIG1_VAL) {
+ printk(KERN_INFO "<1> prefetch is CONFIG1 read val:%8.8x, != VAL written:%8.8x\n",
+ tmp32, GPMC_PREFETCH_CONFIG1_VAL);
+ tmp32 = IORD32(GPMC_VMA(GPMC_PREFETCH_STATUS));
+ printk(KERN_INFO "<1> GPMC_PREFETCH_STATUS : %8.8x\n", tmp32);
+ }
+
+ /*
+ *sanity check 2
+ */
+ tmp32 = IORD32(GPMC_VMA(GPMC_PREFETCH_CONFIG2));
+ if (tmp32 != (count))
+ printk(KERN_INFO "<1> GPMC_PREFETCH_CONFIG2 read val:%d, "
+ "!= VAL written:%d\n", tmp32, count);
+#endif
+
+ /*
+ * ISSUE PNAND CMD+ADDR, note gpmc puts 32b words
+ * on the bus least sig. byte 1st
+ */
+ nand_cmd_n_addr(RDPAGE_B1, col_addr, row_addr);
+
+ IOWR8(ncmd_reg_vma, RDPAGE_B2);
+
+ /*
+ * start the prefetch engine
+ */
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONTROL), 0x1);
+
+ ptr32 = buff;
+
+ while (1) {
+ /*
+ * GPMC PFE service loop
+ */
+ do {
+ /*
+ * spin until PFE fetched some
+ * PNAND bus words in the FIFO
+ */
+ pfe_status = IORD32(GPMC_VMA(GPMC_PREFETCH_STATUS));
+ bytes_in_fifo = (pfe_status >> 24) & 0x7f;
+ } while (bytes_in_fifo == 0);
+
+ /* whole 32 bit words in fifo */
+ w32cnt = bytes_in_fifo >> 2;
+
+#if 0
+ /*
+ *NOTE: FIFO_PTR indicates number of NAND bus words bytes
+ * already received in the FIFO and available to be read
+ * by DMA or MPU whether COUNTVAL indicates number of BUS
+ * words yet to be read from PNAND bus words
+ */
+ printk(KERN_ERR "<1> got PF_STATUS:%8.8x FIFO_PTR:%d, COUNTVAL:%d, w32cnt:%d\n",
+ pfe_status, bytes_in_fifo,
+ (pfe_status & 0x3fff), w32cnt);
+#endif
+
+ while (w32cnt--)
+ *ptr32++ = IORD32(gpmc_data_vma);
+
+ if ((pfe_status & 0x3fff) == 0) {
+ /*
+ * PFE acc angine done, there still may be data leftover
+ * in the FIFO re-read FIFO BYTE counter (check for
+ * leftovers from 32 bit read accesses above)
+ */
+ bytes_in_fifo = (IORD32(
+ GPMC_VMA(GPMC_PREFETCH_STATUS)) >> 24) & 0x7f;
+
+ /*
+ * NOTE we may still have one word left in the fifo
+ * read it out
+ */
+ ptr8 = ptr32;
+ switch (bytes_in_fifo) {
+
+ case 0:
+ /*
+ * nothing to do we already read the
+ * FIFO out with 32 bit accesses
+ */
+ break;
+ case 1:
+ /*
+ * this only possible
+ * for 8 bit pNAND only
+ */
+ *ptr8 = IORD8(gpmc_data_vma);
+ break;
+
+ case 2:
+ /*
+ * this one can occur in either modes
+ */
+ *(uint16_t *)ptr8 = IORD16(gpmc_data_vma);
+ break;
+
+ case 3:
+ /*
+ * this only possible for 8 bit pNAND only
+ */
+ *(uint16_t *)ptr8 = IORD16(gpmc_data_vma);
+ ptr8 += 2;
+ *ptr8 = IORD8(gpmc_data_vma);
+ break;
+
+ case 4:
+ /*
+ * shouldn't happen, but has been seen
+ * in 8 bit mode
+ */
+ *ptr32 = IORD32(gpmc_data_vma);
+ break;
+
+ default:
+ printk(KERN_ERR"<1>_error: PFE FIFO bytes leftover is not read:%d\n",
+ bytes_in_fifo);
+ break;
+ }
+ /*
+ * read is completed, get out of the while(1) loop
+ */
+ break;
+ }
+ }
+}
+#endif
+
+#ifdef PFE_LBD_READ_V2
+/*
+ * PFE engine assisted reads with the 64 byte blocks
+ */
+static void p_nand_lbd_read(u16 col_addr, u32 row_addr, u16 count, void *buff)
+{
+ uint8_t rd_cnt;
+ uint32_t *ptr32;
+ uint8_t *ptr8;
+ uint16_t reminder;
+ uint32_t pfe_status;
+
+ /*
+ * ISSUE PNAND CMD+ADDR
+ * note gpmc puts 32b words on the bus least sig. byte 1st
+ */
+ nand_cmd_n_addr(RDPAGE_B1, col_addr, row_addr);
+ IOWR8(ncmd_reg_vma, RDPAGE_B2);
+
+ /*
+ * setup PFE block
+ * count - OMAP number of bytes to access on pnand bus
+ */
+
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONFIG1), GPMC_PREFETCH_CONFIG1_VAL);
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONFIG2), count);
+ IOWR32(GPMC_VMA(GPMC_PREFETCH_CONTROL), 0x1);
+
+ ptr32 = buff;
+
+ do {
+ pfe_status = IORD32(GPMC_VMA(GPMC_PREFETCH_STATUS)) ;
+ rd_cnt = pfe_status >> (24+2);
+
+ while (rd_cnt--)
+ *ptr32++ = IORD32(gpmc_data_vma);
+
+ } while (pfe_status & 0x3fff);
+
+ /*
+ * read out the leftover
+ */
+ ptr8 = ptr32;
+ rd_cnt = (IORD32(GPMC_VMA(GPMC_PREFETCH_STATUS)) >> 24) & 0x7f;
+
+ while (rd_cnt--)
+ *ptr8++ = IORD8(gpmc_data_vma);
+}
+#endif
+
+#ifdef PNAND_LBD_READ_NO_PFE
+/*
+ * Endpoint buffer read w/o OMAP GPMC Prefetch Engine
+ * the original working code, works at max speed for 8 bit xfers
+ * for 16 bit the bus diagram has gaps
+ */
+static void p_nand_lbd_read(u16 col_addr, u32 row_addr, u16 count, void *buff)
+{
+ uint16_t w32cnt;
+ uint32_t *ptr32;
+ uint16_t *ptr16;
+ uint16_t remainder;
+
+ DBGPRN("<1> %s(): NO_PFE\n", __func__);
+
+ ptr32 = buff;
+ /* number of whole 32 bit words in the transfer */
+ w32cnt = count >> 2;
+
+ /* remainder, in bytes(0..3) */
+ remainder = count & 03;
+
+ /*
+ * note gpmc puts 32b words on the bus least sig. byte 1st
+ */
+ nand_cmd_n_addr(RDPAGE_B1, col_addr, row_addr);
+ IOWR8(ncmd_reg_vma, RDPAGE_B2);
+
+ /*
+ * read data by 32 bit chunks
+ */
+ while (w32cnt--)
+ *ptr32++ = IORD32(ndata_reg_vma);
+
+ /*
+ * now do the remainder(it can be 0, 1, 2 or 3)
+ * same code for both 8 & 16 bit bus
+ * do 1 or 2 MORE words
+ */
+ ptr16 = (uint16_t *)ptr32;
+
+ switch (remainder) {
+ case 1:
+ /* read one 16 bit word
+ * IN 8 BIT WE NEED TO READ even number of bytes
+ */
+ case 2:
+ *ptr16 = IORD16(ndata_reg_vma);
+ break;
+ case 3:
+ /*
+ * for 3 bytes read 2 16 bit words
+ */
+ *ptr16++ = IORD16(ndata_reg_vma);
+ *ptr16 = IORD16(ndata_reg_vma);
+ break;
+ default:
+ /*
+ * remainder is 0
+ */
+ break;
+ }
+}
+#endif
+
+/*
+ * uses LBD mode to write N bytes into astoria
+ * Status: Working, however there are 150ns idle
+ * timeafter every 2 (16 bit or 4(8 bit) bus cycles
+ */
+static void p_nand_lbd_write(u16 col_addr, u32 row_addr, u16 count, void *buff)
+{
+ uint16_t w32cnt;
+ uint16_t remainder;
+ uint8_t *ptr8;
+ uint16_t *ptr16;
+ uint32_t *ptr32;
+
+ remainder = count & 03;
+ w32cnt = count >> 2;
+ ptr32 = buff;
+ ptr8 = buff;
+
+ /*
+ * send: CMDB1, CA0,CA1,RA0,RA1,RA2
+ */
+ nand_cmd_n_addr(PGMPAGE_B1, col_addr, row_addr);
+
+ /*
+ * blast the data out in 32bit chunks
+ */
+ while (w32cnt--)
+ IOWR32(ndata_reg_vma, *ptr32++);
+
+ /*
+ * do the reminder if there is one
+ * same handling for both 8 & 16 bit pnand: mode
+ */
+ ptr16 = (uint16_t *)ptr32; /* do 1 or 2 words */
+
+ switch (remainder) {
+ case 1:
+ /*
+ * read one 16 bit word
+ */
+ case 2:
+ IOWR16(ndata_reg_vma, *ptr16);
+ break;
+
+ case 3:
+ /*
+ * for 3 bytes read 2 16 bit words
+ */
+ IOWR16(ndata_reg_vma, *ptr16++);
+ IOWR16(ndata_reg_vma, *ptr16);
+ break;
+ default:
+ /*
+ * reminder is 0
+ */
+ break;
+ }
+ /*
+ * finally issue a PGM cmd
+ */
+ IOWR8(ncmd_reg_vma, PGMPAGE_B2);
+}
+
+/*
+ * write Astoria register
+ */
+static inline void ast_p_nand_casdi_write(u8 reg_addr8, u16 data)
+{
+ unsigned long flags;
+ u16 addr16;
+ /*
+ * throw an error if called from multiple threads
+ */
+ static atomic_t rdreg_usage_cnt = { 0 };
+
+ /*
+ * disable interrupts
+ */
+ local_irq_save(flags);
+
+ if (atomic_read(&rdreg_usage_cnt) != 0) {
+ cy_as_hal_print_message(KERN_ERR "cy_as_omap_hal:"
+ "* cy_as_hal_write_register usage:%d\n",
+ atomic_read(&rdreg_usage_cnt));
+ }
+
+ atomic_inc(&rdreg_usage_cnt);
+
+ /*
+ * 2 flavors of GPMC -> PNAND access
+ */
+ if (pnand_16bit) {
+ /*
+ * 16 BIT gpmc NAND mode
+ */
+
+ /*
+ * CMD1, CA1, CA2,
+ */
+ IOWR8(ncmd_reg_vma, 0x85);
+ IOWR8(naddr_reg_vma, reg_addr8);
+ IOWR8(naddr_reg_vma, 0x0c);
+
+ /*
+ * this should be sent on the 16 bit bus
+ */
+ IOWR16(ndata_reg_vma, data);
+ } else {
+ /*
+ * 8 bit nand mode GPMC will automatically
+ * seriallize 16bit or 32 bit writes into
+ * 8 bit onesto the lower 8 bit in LE order
+ */
+ addr16 = 0x0c00 | reg_addr8;
+
+ /*
+ * CMD1, CA1, CA2,
+ */
+ IOWR8(ncmd_reg_vma, 0x85);
+ IOWR16(naddr_reg_vma, addr16);
+ IOWR16(ndata_reg_vma, data);
+ }
+
+ /*
+ * re-enable interrupts
+ */
+ atomic_dec(&rdreg_usage_cnt);
+ local_irq_restore(flags);
+}
+
+
+/*
+ * read astoria register via pNAND interface
+ */
+static inline u16 ast_p_nand_casdo_read(u8 reg_addr8)
+{
+ u16 data;
+ u16 addr16;
+ unsigned long flags;
+ /*
+ * throw an error if called from multiple threads
+ */
+ static atomic_t wrreg_usage_cnt = { 0 };
+
+ /*
+ * disable interrupts
+ */
+ local_irq_save(flags);
+
+ if (atomic_read(&wrreg_usage_cnt) != 0) {
+ /*
+ * if it gets here ( from other threads), this function needs
+ * need spin_lock_irq save() protection
+ */
+ cy_as_hal_print_message(KERN_ERR"cy_as_omap_hal: "
+ "cy_as_hal_write_register usage:%d\n",
+ atomic_read(&wrreg_usage_cnt));
+ }
+ atomic_inc(&wrreg_usage_cnt);
+
+ /*
+ * 2 flavors of GPMC -> PNAND access
+ */
+ if (pnand_16bit) {
+ /*
+ * 16 BIT gpmc NAND mode
+ * CMD1, CA1, CA2,
+ */
+
+ IOWR8(ncmd_reg_vma, 0x05);
+ IOWR8(naddr_reg_vma, reg_addr8);
+ IOWR8(naddr_reg_vma, 0x0c);
+ IOWR8(ncmd_reg_vma, 0x00E0);
+
+ udelay(1);
+
+ /*
+ * much faster through the gPMC Register space
+ */
+ data = IORD16(ndata_reg_vma);
+ } else {
+ /*
+ * 8 BIT gpmc NAND mode
+ * CMD1, CA1, CA2, CMD2
+ */
+ addr16 = 0x0c00 | reg_addr8;
+ IOWR8(ncmd_reg_vma, 0x05);
+ IOWR16(naddr_reg_vma, addr16);
+ IOWR8(ncmd_reg_vma, 0xE0);
+ udelay(1);
+ data = IORD16(ndata_reg_vma);
+ }
+
+ /*
+ * re-enable interrupts
+ */
+ atomic_dec(&wrreg_usage_cnt);
+ local_irq_restore(flags);
+
+ return data;
+}
+
+
+/*
+ * This function must be defined to write a register within the WestBridge
+ * device. The addr value is the address of the register to write with
+ * respect to the base address of the WestBridge device.
+ */
+void cy_as_hal_write_register(
+ cy_as_hal_device_tag tag,
+ uint16_t addr, uint16_t data)
+{
+ ast_p_nand_casdi_write((u8)addr, data);
+}
+
+/*
+ * This function must be defined to read a register from the WestBridge
+ * device. The addr value is the address of the register to read with
+ * respect to the base address of the WestBridge device.
+ */
+uint16_t cy_as_hal_read_register(cy_as_hal_device_tag tag, uint16_t addr)
+{
+ uint16_t data = 0 ;
+
+ /*
+ * READ ASTORIA REGISTER USING CASDO
+ */
+ data = ast_p_nand_casdo_read((u8)addr);
+
+ return data ;
+}
+
+/*
+ * preps Ep pointers & data counters for next packet
+ * (fragment of the request) xfer returns true if
+ * there is a next transfer, and false if all bytes in
+ * current request have been xfered
+ */
+static inline bool prep_for_next_xfer(cy_as_hal_device_tag tag, uint8_t ep)
+{
+
+ if (!end_points[ep].sg_list_enabled) {
+ /*
+ * no further transfers for non storage EPs
+ * (like EP2 during firmware download, done
+ * in 64 byte chunks)
+ */
+ if (end_points[ep].req_xfer_cnt >= end_points[ep].req_length) {
+ DBGPRN("<1> %s():RQ sz:%d non-_sg EP:%d completed\n",
+ __func__, end_points[ep].req_length, ep);
+
+ /*
+ * no more transfers, we are done with the request
+ */
+ return false;
+ }
+
+ /*
+ * calculate size of the next DMA xfer, corner
+ * case for non-storage EPs where transfer size
+ * is not egual N * HAL_DMA_PKT_SZ xfers
+ */
+ if ((end_points[ep].req_length - end_points[ep].req_xfer_cnt)
+ >= HAL_DMA_PKT_SZ) {
+ end_points[ep].dma_xfer_sz = HAL_DMA_PKT_SZ;
+ } else {
+ /*
+ * that would be the last chunk less
+ * than P-port max size
+ */
+ end_points[ep].dma_xfer_sz = end_points[ep].req_length -
+ end_points[ep].req_xfer_cnt;
+ }
+
+ return true;
+ }
+
+ /*
+ * for SG_list assisted dma xfers
+ * are we done with current SG ?
+ */
+ if (end_points[ep].seg_xfer_cnt == end_points[ep].sg_p->length) {
+ /*
+ * was it the Last SG segment on the list ?
+ */
+ if (sg_is_last(end_points[ep].sg_p)) {
+ DBGPRN("<1> %s: EP:%d completed,"
+ "%d bytes xfered\n",
+ __func__,
+ ep,
+ end_points[ep].req_xfer_cnt
+ );
+
+ return false;
+ } else {
+ /*
+ * There are more SG segments in current
+ * request's sg list setup new segment
+ */
+
+ end_points[ep].seg_xfer_cnt = 0;
+ end_points[ep].sg_p = sg_next(end_points[ep].sg_p);
+ /* set data pointer for next DMA sg transfer*/
+ end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+ DBGPRN("<1> %s new SG:_va:%p\n\n",
+ __func__, end_points[ep].data_p);
+ }
+
+ }
+
+ /*
+ * for sg list xfers it will always be 512 or 1024
+ */
+ end_points[ep].dma_xfer_sz = HAL_DMA_PKT_SZ;
+
+ /*
+ * next transfer is required
+ */
+
+ return true;
+}
+
+/*
+ * Astoria DMA read request, APP_CPU reads from WB ep buffer
+ */
+static void cy_service_e_p_dma_read_request(
+ cy_as_omap_dev_kernel *dev_p, uint8_t ep)
+{
+ cy_as_hal_device_tag tag = (cy_as_hal_device_tag)dev_p ;
+ uint16_t v, size;
+ void *dptr;
+ uint16_t col_addr = 0x0000;
+ uint32_t row_addr = CYAS_DEV_CALC_EP_ADDR(ep);
+ uint16_t ep_dma_reg = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2;
+
+ /*
+ * get the XFER size frtom WB eP DMA REGISTER
+ */
+ v = cy_as_hal_read_register(tag, ep_dma_reg);
+
+ /*
+ * amount of data in EP buff in bytes
+ */
+ size = v & CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK;
+
+ /*
+ * memory pointer for this DMA packet xfer (sub_segment)
+ */
+ dptr = end_points[ep].data_p;
+
+ DBGPRN("<1>HAL:_svc_dma_read on EP_%d sz:%d, intr_seq:%d, dptr:%p\n",
+ ep,
+ size,
+ intr_sequence_num,
+ dptr
+ );
+
+ cy_as_hal_assert(size != 0);
+
+ if (size) {
+ /*
+ * the actual WB-->OMAP memory "soft" DMA xfer
+ */
+ p_nand_lbd_read(col_addr, row_addr, size, dptr);
+ }
+
+ /*
+ * clear DMAVALID bit indicating that the data has been read
+ */
+ cy_as_hal_write_register(tag, ep_dma_reg, 0) ;
+
+ end_points[ep].seg_xfer_cnt += size;
+ end_points[ep].req_xfer_cnt += size;
+
+ /*
+ * pre-advance data pointer (if it's outside sg
+ * list it will be reset anyway
+ */
+ end_points[ep].data_p += size;
+
+ if (prep_for_next_xfer(tag, ep)) {
+ /*
+ * we have more data to read in this request,
+ * setup next dma packet due tell WB how much
+ * data we are going to xfer next
+ */
+ v = end_points[ep].dma_xfer_sz/*HAL_DMA_PKT_SZ*/ |
+ CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+ cy_as_hal_write_register(tag, ep_dma_reg, v);
+ } else {
+ end_points[ep].pending = cy_false ;
+ end_points[ep].type = cy_as_hal_none ;
+ end_points[ep].buffer_valid = cy_false ;
+
+ /*
+ * notify the API that we are done with rq on this EP
+ */
+ if (callback) {
+ DBGPRN("<1>trigg rd_dma completion cb: xfer_sz:%d\n",
+ end_points[ep].req_xfer_cnt);
+ callback(tag, ep,
+ end_points[ep].req_xfer_cnt,
+ CY_AS_ERROR_SUCCESS);
+ }
+ }
+}
+
+/*
+ * omap_cpu needs to transfer data to ASTORIA EP buffer
+ */
+static void cy_service_e_p_dma_write_request(
+ cy_as_omap_dev_kernel *dev_p, uint8_t ep)
+{
+ uint16_t addr;
+ uint16_t v = 0;
+ uint32_t size;
+ uint16_t col_addr = 0x0000;
+ uint32_t row_addr = CYAS_DEV_CALC_EP_ADDR(ep);
+ void *dptr;
+
+ cy_as_hal_device_tag tag = (cy_as_hal_device_tag)dev_p ;
+ /*
+ * note: size here its the size of the dma transfer could be
+ * anything > 0 && < P_PORT packet size
+ */
+ size = end_points[ep].dma_xfer_sz ;
+ dptr = end_points[ep].data_p ;
+
+ /*
+ * perform the soft DMA transfer, soft in this case
+ */
+ if (size)
+ p_nand_lbd_write(col_addr, row_addr, size, dptr);
+
+ end_points[ep].seg_xfer_cnt += size;
+ end_points[ep].req_xfer_cnt += size;
+ /*
+ * pre-advance data pointer
+ * (if it's outside sg list it will be reset anyway)
+ */
+ end_points[ep].data_p += size;
+
+ /*
+ * now clear DMAVAL bit to indicate we are done
+ * transferring data and that the data can now be
+ * sent via USB to the USB host, sent to storage,
+ * or used internally.
+ */
+
+ addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+ cy_as_hal_write_register(tag, addr, size) ;
+
+ /*
+ * finally, tell the USB subsystem that the
+ * data is gone and we can accept the
+ * next request if one exists.
+ */
+ if (prep_for_next_xfer(tag, ep)) {
+ /*
+ * There is more data to go. Re-init the WestBridge DMA side
+ */
+ v = end_points[ep].dma_xfer_sz |
+ CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+ cy_as_hal_write_register(tag, addr, v) ;
+ } else {
+
+ end_points[ep].pending = cy_false ;
+ end_points[ep].type = cy_as_hal_none ;
+ end_points[ep].buffer_valid = cy_false ;
+
+ /*
+ * notify the API that we are done with rq on this EP
+ */
+ if (callback) {
+ /*
+ * this callback will wake up the process that might be
+ * sleeping on the EP which data is being transferred
+ */
+ callback(tag, ep,
+ end_points[ep].req_xfer_cnt,
+ CY_AS_ERROR_SUCCESS);
+ }
+ }
+}
+
+/*
+ * HANDLE DRQINT from Astoria (called in AS_Intr context
+ */
+static void cy_handle_d_r_q_interrupt(cy_as_omap_dev_kernel *dev_p)
+{
+ uint16_t v ;
+ static uint8_t service_ep = 2 ;
+
+ /*
+ * We've got DRQ INT, read DRQ STATUS Register */
+ v = cy_as_hal_read_register((cy_as_hal_device_tag)dev_p,
+ CY_AS_MEM_P0_DRQ) ;
+
+ if (v == 0) {
+#ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("stray DRQ interrupt detected\n") ;
+#endif
+ return;
+ }
+
+ /*
+ * Now, pick a given DMA request to handle, for now, we just
+ * go round robin. Each bit position in the service_mask
+ * represents an endpoint from EP2 to EP15. We rotate through
+ * each of the endpoints to find one that needs to be serviced.
+ */
+ while ((v & (1 << service_ep)) == 0) {
+
+ if (service_ep == 15)
+ service_ep = 2 ;
+ else
+ service_ep++ ;
+ }
+
+ if (end_points[service_ep].type == cy_as_hal_write) {
+ /*
+ * handle DMA WRITE REQUEST: app_cpu will
+ * write data into astoria EP buffer
+ */
+ cy_service_e_p_dma_write_request(dev_p, service_ep) ;
+ } else if (end_points[service_ep].type == cy_as_hal_read) {
+ /*
+ * handle DMA READ REQUEST: cpu will
+ * read EP buffer from Astoria
+ */
+ cy_service_e_p_dma_read_request(dev_p, service_ep) ;
+ }
+#ifndef WESTBRIDGE_NDEBUG
+ else
+ cy_as_hal_print_message("cyashalomap:interrupt,"
+ " w/o pending DMA job,"
+ "-check DRQ_MASK logic\n") ;
+#endif
+
+ /*
+ * Now bump the EP ahead, so other endpoints get
+ * a shot before the one we just serviced
+ */
+ if (end_points[service_ep].type == cy_as_hal_none) {
+ if (service_ep == 15)
+ service_ep = 2 ;
+ else
+ service_ep++ ;
+ }
+
+}
+
+void cy_as_hal_dma_cancel_request(cy_as_hal_device_tag tag, uint8_t ep)
+{
+ DBGPRN("cy_as_hal_dma_cancel_request on ep:%d", ep);
+ if (end_points[ep].pending)
+ cy_as_hal_write_register(tag,
+ CY_AS_MEM_P0_EP2_DMA_REG + ep - 2, 0);
+
+ end_points[ep].buffer_valid = cy_false ;
+ end_points[ep].type = cy_as_hal_none;
+}
+
+/*
+ * enables/disables SG list assisted DMA xfers for the given EP
+ * sg_list assisted XFERS can use physical addresses of mem pages in case if the
+ * xfer is performed by a h/w DMA controller rather then the CPU on P port
+ */
+void cy_as_hal_set_ep_dma_mode(uint8_t ep, bool sg_xfer_enabled)
+{
+ end_points[ep].sg_list_enabled = sg_xfer_enabled;
+ DBGPRN("<1> EP:%d sg_list assisted DMA mode set to = %d\n",
+ ep, end_points[ep].sg_list_enabled);
+}
+EXPORT_SYMBOL(cy_as_hal_set_ep_dma_mode);
+
+/*
+ * This function must be defined to transfer a block of data to
+ * the WestBridge device. This function can use the burst write
+ * (DMA) capabilities of WestBridge to do this, or it can just copy
+ * the data using writes.
+ */
+void cy_as_hal_dma_setup_write(cy_as_hal_device_tag tag,
+ uint8_t ep, void *buf,
+ uint32_t size, uint16_t maxsize)
+{
+ uint32_t addr = 0 ;
+ uint16_t v = 0;
+
+ /*
+ * Note: "size" is the actual request size
+ * "maxsize" - is the P port fragment size
+ * No EP0 or EP1 traffic should get here
+ */
+ cy_as_hal_assert(ep != 0 && ep != 1) ;
+
+ /*
+ * If this asserts, we have an ordering problem. Another DMA request
+ * is coming down before the previous one has completed.
+ */
+ cy_as_hal_assert(end_points[ep].buffer_valid == cy_false) ;
+ end_points[ep].buffer_valid = cy_true ;
+ end_points[ep].type = cy_as_hal_write ;
+ end_points[ep].pending = cy_true;
+
+ /*
+ * total length of the request
+ */
+ end_points[ep].req_length = size;
+
+ if (size >= maxsize) {
+ /*
+ * set xfer size for very 1st DMA xfer operation
+ * port max packet size ( typically 512 or 1024)
+ */
+ end_points[ep].dma_xfer_sz = maxsize;
+ } else {
+ /*
+ * smaller xfers for non-storage EPs
+ */
+ end_points[ep].dma_xfer_sz = size;
+ }
+
+ /*
+ * check the EP transfer mode uses sg_list rather then a memory buffer
+ * block devices pass it to the HAL, so the hAL could get to the real
+ * physical address for each segment and set up a DMA controller
+ * hardware ( if there is one)
+ */
+ if (end_points[ep].sg_list_enabled) {
+ /*
+ * buf - pointer to the SG list
+ * data_p - data pointer to the 1st DMA segment
+ * seg_xfer_cnt - keeps track of N of bytes sent in current
+ * sg_list segment
+ * req_xfer_cnt - keeps track of the total N of bytes
+ * transferred for the request
+ */
+ end_points[ep].sg_p = buf;
+ end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+ end_points[ep].seg_xfer_cnt = 0 ;
+ end_points[ep].req_xfer_cnt = 0;
+
+#ifdef DBGPRN_DMA_SETUP_WR
+ DBGPRN("cyasomaphal:%s: EP:%d, buf:%p, buf_va:%p,"
+ "req_sz:%d, maxsz:%d\n",
+ __func__,
+ ep,
+ buf,
+ end_points[ep].data_p,
+ size,
+ maxsize);
+#endif
+
+ } else {
+ /*
+ * setup XFER for non sg_list assisted EPs
+ */
+
+ #ifdef DBGPRN_DMA_SETUP_WR
+ DBGPRN("<1>%s non storage or sz < 512:"
+ "EP:%d, sz:%d\n", __func__, ep, size);
+ #endif
+
+ end_points[ep].sg_p = NULL;
+
+ /*
+ * must be a VMA of a membuf in kernel space
+ */
+ end_points[ep].data_p = buf;
+
+ /*
+ * will keep track No of bytes xferred for the request
+ */
+ end_points[ep].req_xfer_cnt = 0;
+ }
+
+ /*
+ * Tell WB we are ready to send data on the given endpoint
+ */
+ v = (end_points[ep].dma_xfer_sz & CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK)
+ | CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+
+ addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+
+ cy_as_hal_write_register(tag, addr, v) ;
+}
+
+/*
+ * This function must be defined to transfer a block of data from
+ * the WestBridge device. This function can use the burst read
+ * (DMA) capabilities of WestBridge to do this, or it can just
+ * copy the data using reads.
+ */
+void cy_as_hal_dma_setup_read(cy_as_hal_device_tag tag,
+ uint8_t ep, void *buf,
+ uint32_t size, uint16_t maxsize)
+{
+ uint32_t addr ;
+ uint16_t v ;
+
+ /*
+ * Note: "size" is the actual request size
+ * "maxsize" - is the P port fragment size
+ * No EP0 or EP1 traffic should get here
+ */
+ cy_as_hal_assert(ep != 0 && ep != 1) ;
+
+ /*
+ * If this asserts, we have an ordering problem.
+ * Another DMA request is coming down before the
+ * previous one has completed. we should not get
+ * new requests if current is still in process
+ */
+
+ cy_as_hal_assert(end_points[ep].buffer_valid == cy_false);
+
+ end_points[ep].buffer_valid = cy_true ;
+ end_points[ep].type = cy_as_hal_read ;
+ end_points[ep].pending = cy_true;
+ end_points[ep].req_xfer_cnt = 0;
+ end_points[ep].req_length = size;
+
+ if (size >= maxsize) {
+ /*
+ * set xfer size for very 1st DMA xfer operation
+ * port max packet size ( typically 512 or 1024)
+ */
+ end_points[ep].dma_xfer_sz = maxsize;
+ } else {
+ /*
+ * so that we could handle small xfers on in case
+ * of non-storage EPs
+ */
+ end_points[ep].dma_xfer_sz = size;
+ }
+
+ addr = CY_AS_MEM_P0_EP2_DMA_REG + ep - 2 ;
+
+ if (end_points[ep].sg_list_enabled) {
+ /*
+ * Handle sg-list assisted EPs
+ * seg_xfer_cnt - keeps track of N of sent packets
+ * buf - pointer to the SG list
+ * data_p - data pointer for the 1st DMA segment
+ */
+ end_points[ep].seg_xfer_cnt = 0 ;
+ end_points[ep].sg_p = buf;
+ end_points[ep].data_p = sg_virt(end_points[ep].sg_p);
+
+ #ifdef DBGPRN_DMA_SETUP_RD
+ DBGPRN("cyasomaphal:DMA_setup_read sg_list EP:%d, "
+ "buf:%p, buf_va:%p, req_sz:%d, maxsz:%d\n",
+ ep,
+ buf,
+ end_points[ep].data_p,
+ size,
+ maxsize);
+ #endif
+ v = (end_points[ep].dma_xfer_sz &
+ CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK) |
+ CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+ cy_as_hal_write_register(tag, addr, v);
+ } else {
+ /*
+ * Non sg list EP passed void *buf rather then scatterlist *sg
+ */
+ #ifdef DBGPRN_DMA_SETUP_RD
+ DBGPRN("%s:non-sg_list EP:%d,"
+ "RQ_sz:%d, maxsz:%d\n",
+ __func__, ep, size, maxsize);
+ #endif
+
+ end_points[ep].sg_p = NULL;
+
+ /*
+ * must be a VMA of a membuf in kernel space
+ */
+ end_points[ep].data_p = buf;
+
+ /*
+ * Program the EP DMA register for Storage endpoints only.
+ */
+ if (is_storage_e_p(ep)) {
+ v = (end_points[ep].dma_xfer_sz &
+ CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK) |
+ CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL ;
+ cy_as_hal_write_register(tag, addr, v);
+ }
+ }
+}
+
+/*
+ * This function must be defined to allow the WB API to
+ * register a callback function that is called when a
+ * DMA transfer is complete.
+ */
+void cy_as_hal_dma_register_callback(cy_as_hal_device_tag tag,
+ cy_as_hal_dma_complete_callback cb)
+{
+ DBGPRN("<1>\n%s: WB API has registered a dma_complete callback:%x\n",
+ __func__, (uint32_t)cb);
+ callback = cb ;
+}
+
+/*
+ * This function must be defined to return the maximum size of
+ * DMA request that can be handled on the given endpoint. The
+ * return value should be the maximum size in bytes that the DMA
+ * module can handle.
+ */
+uint32_t cy_as_hal_dma_max_request_size(cy_as_hal_device_tag tag,
+ cy_as_end_point_number_t ep)
+{
+ /*
+ * Storage reads and writes are always done in 512 byte blocks.
+ * So, we do the count handling within the HAL, and save on
+ * some of the data transfer delay.
+ */
+ if ((ep == CYASSTORAGE_READ_EP_NUM) ||
+ (ep == CYASSTORAGE_WRITE_EP_NUM)) {
+ /* max DMA request size HAL can handle by itself */
+ return CYASSTORAGE_MAX_XFER_SIZE;
+ } else {
+ /*
+ * For the USB - Processor endpoints, the maximum transfer
+ * size depends on the speed of USB operation. So, we use
+ * the following constant to indicate to the API that
+ * splitting of the data into chunks less that or equal to
+ * the max transfer size should be handled internally.
+ */
+
+ /* DEFINED AS 0xffffffff in cyasdma.h */
+ return CY_AS_DMA_MAX_SIZE_HW_SIZE;
+ }
+}
+
+/*
+ * This function must be defined to set the state of the WAKEUP pin
+ * on the WestBridge device. Generally this is done via a GPIO of
+ * some type.
+ */
+cy_bool cy_as_hal_set_wakeup_pin(cy_as_hal_device_tag tag, cy_bool state)
+{
+ /*
+ * Not supported as of now.
+ */
+ return cy_false ;
+}
+
+void cy_as_hal_pll_lock_loss_handler(cy_as_hal_device_tag tag)
+{
+ cy_as_hal_print_message("error: astoria PLL lock is lost\n") ;
+ cy_as_hal_print_message("please check the input voltage levels");
+ cy_as_hal_print_message("and clock, and restart the system\n") ;
+}
+
+/*
+ * Below are the functions that must be defined to provide the basic
+ * operating system services required by the API.
+ */
+
+/*
+ * This function is required by the API to allocate memory.
+ * This function is expected to work exactly like malloc().
+ */
+void *cy_as_hal_alloc(uint32_t cnt)
+{
+ void *ret_p ;
+
+ ret_p = kmalloc(cnt, GFP_ATOMIC) ;
+ return ret_p ;
+}
+
+/*
+ * This function is required by the API to free memory allocated
+ * with CyAsHalAlloc(). This function is'expected to work exacly
+ * like free().
+ */
+void cy_as_hal_free(void *mem_p)
+{
+ kfree(mem_p) ;
+}
+
+/*
+ * Allocator that can be used in interrupt context.
+ * We have to ensure that the kmalloc call does not
+ * sleep in this case.
+ */
+void *cy_as_hal_c_b_alloc(uint32_t cnt)
+{
+ void *ret_p ;
+
+ ret_p = kmalloc(cnt, GFP_ATOMIC) ;
+ return ret_p ;
+}
+
+/*
+ * This function is required to set a block of memory to a
+ * specific value. This function is expected to work exactly
+ * like memset()
+ */
+void cy_as_hal_mem_set(void *ptr, uint8_t value, uint32_t cnt)
+{
+ memset(ptr, value, cnt) ;
+}
+
+/*
+ * This function is expected to create a sleep channel.
+ * The data structure that represents the sleep channel object
+ * sleep channel (which is Linux "wait_queue_head_t wq" for this paticular HAL)
+ * passed as a pointer, and allpocated by the caller
+ * (typically as a local var on the stack) "Create" word should read as
+ * "SleepOn", this func doesn't actually create anything
+ */
+cy_bool cy_as_hal_create_sleep_channel(cy_as_hal_sleep_channel *channel)
+{
+ init_waitqueue_head(&channel->wq) ;
+ return cy_true ;
+}
+
+/*
+ * for this particular HAL it doesn't actually destroy anything
+ * since no actual sleep object is created in CreateSleepChannel()
+ * sleep channel is given by the pointer in the argument.
+ */
+cy_bool cy_as_hal_destroy_sleep_channel(cy_as_hal_sleep_channel *channel)
+{
+ return cy_true ;
+}
+
+/*
+ * platform specific wakeable Sleep implementation
+ */
+cy_bool cy_as_hal_sleep_on(cy_as_hal_sleep_channel *channel, uint32_t ms)
+{
+ wait_event_interruptible_timeout(channel->wq, 0, ((ms * HZ)/1000)) ;
+ return cy_true ;
+}
+
+/*
+ * wakes up the process waiting on the CHANNEL
+ */
+cy_bool cy_as_hal_wake(cy_as_hal_sleep_channel *channel)
+{
+ wake_up_interruptible_all(&channel->wq);
+ return cy_true ;
+}
+
+uint32_t cy_as_hal_disable_interrupts()
+{
+ if (0 == intr__enable)
+ ;
+
+ intr__enable++ ;
+ return 0 ;
+}
+
+void cy_as_hal_enable_interrupts(uint32_t val)
+{
+ intr__enable-- ;
+ if (0 == intr__enable)
+ ;
+}
+
+/*
+ * Sleep atleast 150ns, cpu dependent
+ */
+void cy_as_hal_sleep150(void)
+{
+ uint32_t i, j;
+
+ j = 0;
+ for (i = 0; i < 1000; i++)
+ j += (~i);
+}
+
+void cy_as_hal_sleep(uint32_t ms)
+{
+ cy_as_hal_sleep_channel channel;
+
+ cy_as_hal_create_sleep_channel(&channel) ;
+ cy_as_hal_sleep_on(&channel, ms) ;
+ cy_as_hal_destroy_sleep_channel(&channel) ;
+}
+
+cy_bool cy_as_hal_is_polling()
+{
+ return cy_false;
+}
+
+void cy_as_hal_c_b_free(void *ptr)
+{
+ cy_as_hal_free(ptr);
+}
+
+/*
+ * suppose to reinstate the astoria registers
+ * that may be clobbered in sleep mode
+ */
+void cy_as_hal_init_dev_registers(cy_as_hal_device_tag tag,
+ cy_bool is_standby_wakeup)
+{
+ /* specific to SPI, no implementation required */
+ (void) tag;
+ (void) is_standby_wakeup;
+}
+
+void cy_as_hal_read_regs_before_standby(cy_as_hal_device_tag tag)
+{
+ /* specific to SPI, no implementation required */
+ (void) tag;
+}
+
+cy_bool cy_as_hal_sync_device_clocks(cy_as_hal_device_tag tag)
+{
+ /*
+ * we are in asynchronous mode. so no need to handle this
+ */
+ return true;
+}
+
+/*
+ * init OMAP h/w resources
+ */
+int start_o_m_a_p_kernel(const char *pgm,
+ cy_as_hal_device_tag *tag, cy_bool debug)
+{
+ cy_as_omap_dev_kernel *dev_p ;
+ int i;
+ u16 data16[4];
+ u8 pncfg_reg;
+
+ /*
+ * No debug mode support through argument as of now
+ */
+ (void)debug;
+
+ DBGPRN(KERN_INFO"starting OMAP34xx HAL...\n");
+
+ /*
+ * Initialize the HAL level endpoint DMA data.
+ */
+ for (i = 0 ; i < sizeof(end_points)/sizeof(end_points[0]) ; i++) {
+ end_points[i].data_p = 0 ;
+ end_points[i].pending = cy_false ;
+ end_points[i].size = 0 ;
+ end_points[i].type = cy_as_hal_none ;
+ end_points[i].sg_list_enabled = cy_false;
+
+ /*
+ * by default the DMA transfers to/from the E_ps don't
+ * use sg_list that implies that the upper devices like
+ * blockdevice have to enable it for the E_ps in their
+ * initialization code
+ */
+ }
+
+ /*
+ * allocate memory for OMAP HAL
+ */
+ dev_p = (cy_as_omap_dev_kernel *)cy_as_hal_alloc(
+ sizeof(cy_as_omap_dev_kernel)) ;
+ if (dev_p == 0) {
+ cy_as_hal_print_message("out of memory allocating OMAP"
+ "device structure\n") ;
+ return 0 ;
+ }
+
+ dev_p->m_sig = CY_AS_OMAP_KERNEL_HAL_SIG;
+
+ /*
+ * initialize OMAP hardware and StartOMAPKernelall gpio pins
+ */
+ dev_p->m_addr_base = (void *)cy_as_hal_processor_hw_init();
+
+ /*
+ * Now perform a hard reset of the device to have
+ * the new settings take effect
+ */
+ __gpio_set_value(AST_WAKEUP, 1);
+
+ /*
+ * do Astoria h/w reset
+ */
+ DBGPRN(KERN_INFO"-_-_pulse -> westbridge RST pin\n");
+
+ /*
+ * NEGATIVE PULSE on RST pin
+ */
+ __gpio_set_value(AST_RESET, 0);
+ mdelay(1);
+ __gpio_set_value(AST_RESET, 1);
+ mdelay(50);
+
+ /*
+ * note AFTER reset PNAND interface is 8 bit mode
+ * so if gpmc Is configured in 8 bit mode upper half will be FF
+ */
+ pncfg_reg = ast_p_nand_casdo_read(CY_AS_MEM_PNAND_CFG);
+
+#ifdef PNAND_16BIT_MODE
+
+ /*
+ * switch to 16 bit mode, force NON-LNA LBD mode, 3 RA addr bytes
+ */
+ ast_p_nand_casdi_write(CY_AS_MEM_PNAND_CFG, 0x0001);
+
+ /*
+ * now in order to continue to talk to astoria
+ * sw OMAP GPMC into 16 bit mode as well
+ */
+ cy_as_hal_gpmc_enable_16bit_bus(cy_true);
+#else
+ /* Astoria and GPMC are already in 8 bit mode, jsut initialize PNAND_CFG */
+ ast_p_nand_casdi_write(CY_AS_MEM_PNAND_CFG, 0x0000);
+#endif
+
+ /*
+ * NOTE: if you want to capture bus activity on the LA,
+ * don't use printks in between the activities you want to capture.
+ * prinks may take milliseconds, and the data of interest
+ * will fall outside the LA capture window/buffer
+ */
+ data16[0] = ast_p_nand_casdo_read(CY_AS_MEM_CM_WB_CFG_ID);
+ data16[1] = ast_p_nand_casdo_read(CY_AS_MEM_PNAND_CFG);
+
+ if (data16[0] != 0xA200) {
+ /*
+ * astoria device is not found
+ */
+ printk(KERN_ERR "ERROR: astoria device is not found, CY_AS_MEM_CM_WB_CFG_ID ");
+ printk(KERN_ERR "read returned:%4.4X: CY_AS_MEM_PNAND_CFG:%4.4x !\n",
+ data16[0], data16[0]);
+ goto bus_acc_error;
+ }
+
+ cy_as_hal_print_message(KERN_INFO" register access CASDO test:"
+ "\n CY_AS_MEM_CM_WB_CFG_ID:%4.4x\n"
+ "PNAND_CFG after RST:%4.4x\n "
+ "CY_AS_MEM_PNAND_CFG"
+ "after cfg_wr:%4.4x\n\n",
+ data16[0], pncfg_reg, data16[1]);
+
+ dev_p->thread_flag = 1 ;
+ spin_lock_init(&int_lock) ;
+ dev_p->m_next_p = m_omap_list_p ;
+
+ m_omap_list_p = dev_p ;
+ *tag = dev_p;
+
+ cy_as_hal_configure_interrupts((void *)dev_p);
+
+ cy_as_hal_print_message(KERN_INFO"OMAP3430__hal started tag:%p"
+ ", kernel HZ:%d\n", dev_p, HZ);
+
+ /*
+ *make processor to storage endpoints SG assisted by default
+ */
+ cy_as_hal_set_ep_dma_mode(4, true);
+ cy_as_hal_set_ep_dma_mode(8, true);
+
+ return 1 ;
+
+ /*
+ * there's been a NAND bus access error or
+ * astoria device is not connected
+ */
+bus_acc_error:
+ /*
+ * at this point hal tag hasn't been set yet
+ * so the device will not call omap_stop
+ */
+ cy_as_hal_omap_hardware_deinit(dev_p);
+ cy_as_hal_free(dev_p) ;
+ return 0;
+}
+
+#else
+/*
+ * Some compilers do not like empty C files, so if the OMAP hal is not being
+ * compiled, we compile this single function. We do this so that for a
+ * given target HAL there are not multiple sources for the HAL functions.
+ */
+void my_o_m_a_p_kernel_hal_dummy_function(void)
+{
+}
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/cyashaldef.h b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/cyashaldef.h
new file mode 100644
index 000000000000..6ce78ae6c3bb
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/cyashaldef.h
@@ -0,0 +1,55 @@
+/* Cypress West Bridge API header file (cyashaldef.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASHALDEF_H_
+#define _INCLUDED_CYASHALDEF_H_
+
+/* Summary
+ * If set to TRUE, the basic numeric types are defined by the
+ * West Bridge API code
+ *
+ * Description
+ * The West Bridge API relies on some basic integral types to be
+ * defined. These types include uint8_t, int8_t, uint16_t,
+ * int16_t, uint32_t, and int32_t. If this macro is defined the
+ * West Bridge API will define these types based on some basic
+ * assumptions. If this value is set and the West Bridge API is
+ * used to set these types, the definition of these types must be
+ * examined to insure that they are appropriate for the given
+ * target architecture and compiler.
+ *
+ * Notes
+ * It is preferred that if the basic platform development
+ * environment defines these types that the CY_DEFINE_BASIC_TYPES
+ * macro be undefined and the appropriate target system header file
+ * be added to the file cyashaldef.h.
+ */
+
+#include <linux/types.h>
+
+
+#if !defined(__doxygen__)
+typedef int cy_bool ;
+#define cy_true (1)
+#define cy_false (0)
+#endif
+
+#endif /* _INCLUDED_CYASHALDEF_H_ */
diff --git a/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h
new file mode 100644
index 000000000000..c40279b29109
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h
@@ -0,0 +1,319 @@
+/* Cypress Antioch HAL for OMAP KERNEL header file (cyashalomapkernel.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * This file contains the defintion of the hardware abstraction
+ * layer on OMAP3430 talking to the West Bridge Astoria device
+ */
+
+
+#ifndef _INCLUDED_CYASHALOMAP_KERNEL_H_
+#define _INCLUDED_CYASHALOMAP_KERNEL_H_
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/wait.h>
+#include <linux/string.h>
+/* include does not seem to work
+ * moving for patch submission
+#include <mach/gpmc.h>
+*/
+#include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
+typedef struct cy_as_hal_sleep_channel_t {
+ wait_queue_head_t wq ;
+} cy_as_hal_sleep_channel ;
+
+/* moved to staging location, eventual location
+ * considered is here
+#include <mach/westbridge/cyashaldef.h>
+#include <linux/westbridge/cyastypes.h>
+#include <linux/westbridge/cyas_cplus_start.h>
+*/
+#include "../cyashaldef.h"
+#include "../../../../../../../include/linux/westbridge/cyastypes.h"
+#include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h"
+#include "cyasomapdev_kernel.h"
+
+/*
+ * Below are the data structures that must be defined by the HAL layer
+ */
+
+/*
+ * The HAL layer must define a TAG for identifying a specific Astoria
+ * device in the system. In this case the tag is a void * which is
+ * really an OMAP device pointer
+ */
+typedef void *cy_as_hal_device_tag ;
+
+
+/* This must be included after the CyAsHalDeviceTag type is defined */
+
+/* moved to staging location, eventual location
+ * considered is here
+ * #include <linux/westbridge/cyashalcb.h>
+*/
+#include "../../../../../../../include/linux/westbridge/cyashalcb.h"
+/*
+ * Below are the functions that communicate with the West Bridge
+ * device. These are system dependent and must be defined by
+ * the HAL layer for a given system.
+ */
+
+/*
+ * This function must be defined to write a register within the Antioch
+ * device. The addr value is the address of the register to write with
+ * respect to the base address of the Antioch device.
+ */
+void
+cy_as_hal_write_register(cy_as_hal_device_tag tag,
+ uint16_t addr, uint16_t data) ;
+
+/*
+ * This function must be defined to read a register from
+ * the west bridge device. The addr value is the address of
+ * the register to read with respect to the base address
+ * of the west bridge device.
+ */
+uint16_t
+cy_as_hal_read_register(cy_as_hal_device_tag tag, uint16_t addr) ;
+
+/*
+ * This function must be defined to transfer a block of data
+ * to the west bridge device. This function can use the burst write
+ * (DMA) capabilities of Antioch to do this, or it can just copy
+ * the data using writes.
+ */
+void
+cy_as_hal_dma_setup_write(cy_as_hal_device_tag tag,
+ uint8_t ep, void *buf, uint32_t size, uint16_t maxsize) ;
+
+/*
+ * This function must be defined to transfer a block of data
+ * from the Antioch device. This function can use the burst
+ * read (DMA) capabilities of Antioch to do this, or it can
+ * just copy the data using reads.
+ */
+void
+cy_as_hal_dma_setup_read(cy_as_hal_device_tag tag, uint8_t ep,
+ void *buf, uint32_t size, uint16_t maxsize) ;
+
+/*
+ * This function must be defined to cancel any pending DMA request.
+ */
+void
+cy_as_hal_dma_cancel_request(cy_as_hal_device_tag tag, uint8_t ep) ;
+
+/*
+ * This function must be defined to allow the Antioch API to
+ * register a callback function that is called when a DMA transfer
+ * is complete.
+ */
+void
+cy_as_hal_dma_register_callback(cy_as_hal_device_tag tag,
+ cy_as_hal_dma_complete_callback cb) ;
+
+/*
+ * This function must be defined to return the maximum size of DMA
+ * request that can be handled on the given endpoint. The return
+ * value should be the maximum size in bytes that the DMA module can
+ * handle.
+ */
+uint32_t
+cy_as_hal_dma_max_request_size(cy_as_hal_device_tag tag,
+ cy_as_end_point_number_t ep) ;
+
+/*
+ * This function must be defined to set the state of the WAKEUP pin
+ * on the Antioch device. Generally this is done via a GPIO of some
+ * type.
+ */
+cy_bool
+cy_as_hal_set_wakeup_pin(cy_as_hal_device_tag tag, cy_bool state) ;
+
+/*
+ * This function is called when the Antioch PLL loses lock, because
+ * of a problem in the supply voltage or the input clock.
+ */
+void
+cy_as_hal_pll_lock_loss_handler(cy_as_hal_device_tag tag) ;
+
+
+/**********************************************************************
+ *
+ * Below are the functions that must be defined to provide the basic
+ * operating system services required by the API.
+ *
+***********************************************************************/
+
+/*
+ * This function is required by the API to allocate memory. This function
+ * is expected to work exactly like malloc().
+ */
+void *
+cy_as_hal_alloc(uint32_t cnt) ;
+
+/*
+ * This function is required by the API to free memory allocated with
+ * CyAsHalAlloc(). This function is expected to work exacly like free().
+ */
+void
+cy_as_hal_free(void *mem_p) ;
+
+/*
+ * This function is required by the API to allocate memory during a
+ * callback. This function must be able to provide storage at inturupt
+ * time.
+ */
+void *
+cy_as_hal_c_b_alloc(uint32_t cnt) ;
+
+/*
+ * This function is required by the API to free memory allocated with
+ * CyAsCBHalAlloc().
+ */
+void
+cy_as_hal_c_b_free(void *ptr) ;
+
+/*
+ * This function is required to set a block of memory to a specific
+ * value. This function is expected to work exactly like memset()
+ */
+void
+cy_as_hal_mem_set(void *ptr, uint8_t value, uint32_t cnt) ;
+
+/*
+ * This function is expected to create a sleep channel. The data
+ * structure that represents the sleep channel is given by the
+ * pointer in the argument.
+ */
+cy_bool
+cy_as_hal_create_sleep_channel(cy_as_hal_sleep_channel *channel) ;
+
+/*
+ * This function is expected to destroy a sleep channel. The data
+ * structure that represents the sleep channel is given by
+ * the pointer in the argument.
+ */
+
+
+cy_bool
+cy_as_hal_destroy_sleep_channel(cy_as_hal_sleep_channel *channel) ;
+
+cy_bool
+cy_as_hal_sleep_on(cy_as_hal_sleep_channel *channel, uint32_t ms) ;
+
+cy_bool
+cy_as_hal_wake(cy_as_hal_sleep_channel *channel) ;
+
+uint32_t
+cy_as_hal_disable_interrupts(void) ;
+
+void
+cy_as_hal_enable_interrupts(uint32_t);
+
+void
+cy_as_hal_sleep150(void);
+
+void
+cy_as_hal_sleep(uint32_t ms);
+
+cy_bool
+cy_as_hal_is_polling(void);
+
+void cy_as_hal_init_dev_registers(cy_as_hal_device_tag tag,
+ cy_bool is_standby_wakeup);
+
+/*
+ * required only in spi mode
+ */
+cy_bool cy_as_hal_sync_device_clocks(cy_as_hal_device_tag tag);
+
+void cy_as_hal_read_regs_before_standby(cy_as_hal_device_tag tag);
+
+
+#ifndef NDEBUG
+#define cy_as_hal_assert(cond) if (!(cond))\
+ printk(KERN_WARNING"assertion failed at %s:%d\n", __FILE__, __LINE__);
+#else
+#define cy_as_hal_assert(cond)
+#endif
+
+#define cy_as_hal_print_message printk
+
+/* removable debug printks */
+#ifndef WESTBRIDGE_NDEBUG
+#define DBG_PRINT_ENABLED
+#endif
+
+/*#define MBOX_ACCESS_DBG_PRINT_ENABLED*/
+
+
+#ifdef DBG_PRINT_ENABLED
+ /* Debug printing enabled */
+
+ #define DBGPRN(...) printk(__VA_ARGS__)
+ #define DBGPRN_FUNC_NAME printk("<1> %x:_func: %s\n", \
+ current->pid, __func__)
+
+#else
+ /** NO DEBUG PRINTING **/
+ #define DBGPRN(...)
+ #define DBGPRN_FUNC_NAME
+
+#endif
+
+/*
+CyAsMiscSetLogLevel(uint8_t level)
+{
+ debug_level = level ;
+}
+
+#ifdef CY_AS_LOG_SUPPORT
+
+void
+cy_as_log_debug_message(int level, const char *str)
+{
+ if (level <= debug_level)
+ cy_as_hal_print_message("log %d: %s\n", level, str) ;
+}
+*/
+
+
+/*
+ * print buffer helper
+ */
+void cyashal_prn_buf(void *buf, uint16_t offset, int len);
+
+/*
+ * These are the functions that are not part of the HAL layer,
+ * but are required to be called for this HAL.
+ */
+int start_o_m_a_p_kernel(const char *pgm,
+ cy_as_hal_device_tag *tag, cy_bool debug) ;
+int stop_o_m_a_p_kernel(const char *pgm, cy_as_hal_device_tag tag) ;
+int omap_start_intr(cy_as_hal_device_tag tag) ;
+void cy_as_hal_set_ep_dma_mode(uint8_t ep, bool sg_xfer_enabled);
+
+/* moved to staging location
+#include <linux/westbridge/cyas_cplus_end.h>
+*/
+#include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h"
+#endif
diff --git a/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h
new file mode 100644
index 000000000000..4377a34717b8
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasmemmap.h
@@ -0,0 +1,555 @@
+/*
+ OMAP3430 ZOOM MDK astoria interface defs(cyasmemmap.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+/* include does not seem to work
+ * moving for patch submission
+#include <mach/gpmc.h>
+#include <mach/mux.h>
+*/
+#include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
+#include <linux/../../arch/arm/plat-omap/include/plat/mux.h>
+
+#ifndef _INCLUDED_CYASMEMMAP_H_
+#define _INCLUDED_CYASMEMMAP_H_
+
+/* defines copied from OMAP kernel branch */
+#define OMAP34XX_MUX_MODE0 0
+#define OMAP34XX_MUX_MODE4 4
+#define OMAP3_INPUT_EN (1 << 8)
+#define OMAP34XX_PIN_INPUT_PULLUP (OMAP2_PULL_ENA | OMAP3_INPUT_EN \
+ | OMAP2_PULL_UP)
+
+/*
+ * for OMAP3430 <-> astoria : ADmux mode, 8 bit data path
+ * WB Signal- OMAP3430 signal COMMENTS
+ * --------------------------- --------------------
+ * CS_L -GPMC_nCS4_GPIO_53 ZOOM I SOM board
+ * signal: up_nCS_A_EXT
+ * AD[7:0]-upD[7:0] buffered on the
+ * transposer board
+ * GPMC_ADDR
+ * [A8:A1]->upD[7:0]
+ * INT# -GPMC_nWP_GPIO_62
+ * DACK -N/C not conected
+ * WAKEUP-GPIO_167
+ * RESET-GPIO_126
+ * R/B -GPMC_WAIT2_GPIO_64
+ * -------------------------------------------
+ * The address range for nCS1B is 0x06000000 - 0x07FF FFFF.
+*/
+
+/*
+ *OMAP_ZOOM LEDS
+ */
+#define LED_0 156
+#define LED_1 128
+#define LED_2 64
+#define LED_3 60
+
+#define HIGH 1
+#define LOW 1
+
+/*
+ *omap GPIO number
+ */
+#define AST_WAKEUP 167
+#define AST_RESET 126
+#define AST__rn_b 64
+
+/*
+ * NOTE THIS PIN IS USED AS WP for OMAP NAND
+ */
+#define AST_INT 62
+
+/*
+ * as an I/O, it is actually controlled by GPMC
+ */
+#define AST_CS 55
+
+
+/*
+ *GPMC prefetch engine
+ */
+
+/* register and its bit fields */
+#define GPMC_PREFETCH_CONFIG1 0x01E0
+
+ /*32 bytes for 16 bit pnand mode*/
+ #define PFE_THRESHOLD 31
+
+ /*
+ * bit fields
+ * PF_ACCESSMODE - 0 - read mode, 1 - write mode
+ * PF_DMAMODE - 0 - default only intr line signal will be generated
+ * PF_SYNCHROMODE - default 0 - engin will start access as soon as
+ * ctrl re STARTENGINE is set
+ * PF_WAITPINSEL - FOR synchro mode selects WAIT pin whch edge
+ * will be monitored
+ * PF_EN_ENGINE - 1- ENABLES ENGINE, but it needs to be started after
+ * that C ctrl reg bit 0
+ * PF_FIFO_THRESHOLD - FIFO threshhold in number of BUS(8 or 16) words
+ * PF_WEIGHTED_PRIO - NUM of cycles granted to PFE if RND_ROBIN
+ * prioritization is enabled
+ * PF_ROUND_ROBIN - if enabled, gives priority to other CS, but
+ * reserves NUM of cycles for PFE's turn
+ * PF_ENGIN_CS_SEL - GPMC CS assotiated with PFE function
+ */
+ #define PF_ACCESSMODE (0 << 0)
+ #define PF_DMAMODE (0 << 2)
+ #define PF_SYNCHROMODE (0 << 3)
+ #define PF_WAITPINSEL (0x0 << 4)
+ #define PF_EN_ENGINE (1 << 7)
+ #define PF_FIFO_THRESHOLD (PFE_THRESHOLD << 8)
+ #define PF_WEIGHTED_PRIO (0x0 << 16)
+ #define PF_ROUND_ROBIN (0 << 23)
+ #define PF_ENGIN_CS_SEL (AST_GPMC_CS << 24)
+ #define PF_EN_OPTIM_ACC (0 << 27)
+ #define PF_CYCLEOPTIM (0x0 << 28)
+
+#define GPMC_PREFETCH_CONFIG1_VAL (PF_ACCESSMODE | \
+ PF_DMAMODE | PF_SYNCHROMODE | \
+ PF_WAITPINSEL | PF_EN_ENGINE | \
+ PF_FIFO_THRESHOLD | PF_FIFO_THRESHOLD | \
+ PF_WEIGHTED_PRIO | PF_ROUND_ROBIN | \
+ PF_ENGIN_CS_SEL | PF_EN_OPTIM_ACC | \
+ PF_CYCLEOPTIM)
+
+/* register and its bit fields */
+#define GPMC_PREFETCH_CONFIG2 0x01E4
+ /*
+ * bit fields
+ * 14 bit field NOTE this counts is also
+ * is in number of BUS(8 or 16) words
+ */
+ #define PF_TRANSFERCOUNT (0x000)
+
+
+/* register and its bit fields */
+#define GPMC_PREFETCH_CONTROL 0x01EC
+ /*
+ * bit fields , ONLY BIT 0 is implemented
+ * PFWE engin must be programmed with this bit = 0
+ */
+ #define PFPW_STARTENGINE (1 << 0)
+
+/* register and its bit fields */
+#define GPMC_PREFETCH_STATUS 0x01F0
+
+ /* */
+ #define PFE_FIFO_THRESHOLD (1 << 16)
+
+/*
+ * GPMC posted write/prefetch engine end
+ */
+
+
+/*
+ * chip select number on GPMC ( 0..7 )
+ */
+#define AST_GPMC_CS 4
+
+/*
+ * not connected
+ */
+#define AST_DACK 00
+
+
+/*
+ * Physical address above the NAND flash
+ * we use CS For mapping in OMAP3430 RAM space use 0x0600 0000
+ */
+#define CYAS_DEV_BASE_ADDR (0x20000000)
+
+#define CYAS_DEV_MAX_ADDR (0xFF)
+#define CYAS_DEV_ADDR_RANGE (CYAS_DEV_MAX_ADDR << 1)
+
+#ifdef p_s_r_a_m_INTERFACE
+ /* in CRAM or PSRAM mode OMAP A1..An wires-> Astoria, there is no A0 line */
+ #define CYAS_DEV_CALC_ADDR(cyas_addr) (cyas_addr << 1)
+ #define CYAS_DEV_CALC_EP_ADDR(ep) (ep << 1)
+#else
+ /*
+ * For pNAND interface it depends on NAND emulation mode
+ * SBD/LBD etc we use NON-LNA_LBD mode, so it goes like this:
+ * forlbd <CMD><CA0,CA1,RA0,RA1,RA2> <CMD>,
+ * where CA1 address must have bits 2,3 = "11"
+ * ep is mapped into RA1 bits {4:0}
+ */
+ #define CYAS_DEV_CALC_ADDR(cyas_addr) (cyas_addr | 0x0c00)
+ #define CYAS_DEV_CALC_EP_ADDR(ep) ep
+#endif
+
+/*
+ *OMAP3430 i/o access macros
+ */
+#define IORD32(addr) (*(volatile u32 *)(addr))
+#define IOWR32(addr, val) (*(volatile u32 *)(addr) = val)
+
+#define IORD16(addr) (*(volatile u16 *)(addr))
+#define IOWR16(addr, val) (*(volatile u16 *)(addr) = val)
+
+#define IORD8(addr) (*(volatile u8 *)(addr))
+#define IOWR8(addr, val) (*(volatile u8 *)(addr) = val)
+
+/*
+ * local defines for accessing to OMAP GPIO ***
+ */
+#define CTLPADCONF_BASE_ADDR 0x48002000
+#define CTLPADCONF_SIZE 0x1000
+
+#define GPIO1_BASE_ADDR 0x48310000
+#define GPIO2_BASE_ADDR 0x49050000
+#define GPIO3_BASE_ADDR 0x49052000
+#define GPIO4_BASE_ADDR 0x49054000
+#define GPIO5_BASE_ADDR 0x49056000
+#define GPIO6_BASE_ADDR 0x49058000
+#define GPIO_SPACE_SIZE 0x1000
+
+
+/*
+ * OMAP3430 GPMC timing for pNAND interface
+ */
+#define GPMC_BASE 0x6E000000
+#define GPMC_REGION_SIZE 0x1000
+#define GPMC_CONFIG_REG (0x50)
+
+/*
+ * bit 0 in the GPMC_CONFIG_REG
+ */
+#define NAND_FORCE_POSTED_WRITE_B 1
+
+/*
+ * WAIT2STATUS, must be (1 << 10)
+ */
+#define AS_WAIT_PIN_MASK (1 << 10)
+
+
+/*
+ * GPMC_CONFIG(reg number [1..7] [for chip sel CS[0..7])
+ */
+#define GPMC_CFG_REG(N, CS) ((0x60 + (4*(N-1))) + (0x30*CS))
+
+/*
+ *gpmc nand registers for CS4
+ */
+#define GPMC_NAND_CMD (0x7c + (0x30*AST_GPMC_CS))
+#define GPMC_NAND_ADDR (0x80 + (0x30*AST_GPMC_CS))
+#define GPMC_NAND_DATA (0x84 + (0x30*AST_GPMC_CS))
+
+#define GPMC_STAT_REG (0x54)
+#define GPMC_ERR_TYPE (0x48)
+
+/*
+ * we get "gpmc_base" from kernel
+ */
+#define GPMC_VMA(offset) (gpmc_base + offset)
+
+/*
+ * GPMC CS space VMA start address
+ */
+#define GPMC_CS_VMA(offset) (gpmc_data_vma + offset)
+
+/*
+ * PAD_CFG mux space VMA
+ */
+#define PADCFG_VMA(offset) (iomux_vma + offset)
+
+/*
+ * CONFIG1: by default, sngle access, async r/w RD_MULTIPLE[30]
+ * WR_MULTIPLE[28]; GPMC_FCL_DIV[1:0]
+ */
+#define GPMC_FCLK_DIV ((0) << 0)
+
+/*
+ * ADDITIONAL DIVIDER FOR ALL TIMING PARAMS
+ */
+#define TIME_GRAN_SCALE ((0) << 4)
+
+/*
+ * for use by gpmc_set_timings api, measured in ns, not clocks
+ */
+#define WB_GPMC_BUSCYC_t (7 * 6)
+#define WB_GPMC_CS_t_o_n (0)
+#define WB_GPMC_ADV_t_o_n (0)
+#define WB_GPMC_OE_t_o_n (0)
+#define WB_GPMC_OE_t_o_f_f (5 * 6)
+#define WB_GPMC_WE_t_o_n (1 * 6)
+#define WB_GPMC_WE_t_o_f_f (5 * 6)
+#define WB_GPMC_RDS_ADJ (2 * 6)
+#define WB_GPMC_RD_t_a_c_c (WB_GPMC_OE_t_o_f_f + WB_GPMC_RDS_ADJ)
+#define WB_GPMC_WR_t_a_c_c (WB_GPMC_BUSCYC_t)
+
+#define DIR_OUT 0
+#define DIR_INP 1
+#define DRV_HI 1
+#define DRV_LO 0
+
+/*
+ * GPMC_CONFIG7[cs] register bit fields
+ * AS_CS_MASK - 3 bit mask for A26,A25,A24,
+ * AS_CS_BADDR - 6 BIT VALUE A29 ...A24
+ * CSVALID_B - CSVALID bit on GPMC_CONFIG7[cs] register
+ */
+#define AS_CS_MASK (0X7 << 8)
+#define AS_CS_BADDR 0x02
+#define CSVALID_B (1 << 6)
+
+/*
+ * DEFINE OMAP34XX GPIO OFFSETS (should have been defined in kernel /arch
+ * these are offsets from the BASE_ADDRESS of the GPIO BLOCK
+ */
+#define GPIO_REVISION 0x000
+#define GPIO_SYSCONFIG 0x010
+#define GPIO_SYSSTATUS1 0x014
+#define GPIO_IRQSTATUS1 0x018
+#define GPIO_IRQENABLE1 0x01C
+#define GPIO_IRQSTATUS2 0x028
+#define GPIO_CTRL 0x030
+#define GPIO_OE 0x034
+#define GPIO_DATA_IN 0x038
+#define GPIO_DATA_OUT 0x03C
+#define GPIO_LEVELDETECT0 0x040
+#define GPIO_LEVELDETECT1 0x044
+#define GPIO_RISINGDETECT 0x048
+#define GPIO_FALLINGDETECT 0x04c
+#define GPIO_CLEAR_DATAOUT 0x090
+#define GPIO_SET_DATAOUT 0x094
+
+typedef struct {
+ char *name;
+ u32 phy_addr;
+ u32 virt_addr;
+ u32 size;
+} io2vma_tab_t;
+
+/*
+ * GPIO phy to translation VMA table
+ */
+static io2vma_tab_t gpio_vma_tab[6] = {
+ {"GPIO1_BASE_ADDR", GPIO1_BASE_ADDR , 0 , GPIO_SPACE_SIZE},
+ {"GPIO2_BASE_ADDR", GPIO2_BASE_ADDR , 0 , GPIO_SPACE_SIZE},
+ {"GPIO3_BASE_ADDR", GPIO3_BASE_ADDR , 0 , GPIO_SPACE_SIZE},
+ {"GPIO4_BASE_ADDR", GPIO4_BASE_ADDR , 0 , GPIO_SPACE_SIZE},
+ {"GPIO5_BASE_ADDR", GPIO5_BASE_ADDR , 0 , GPIO_SPACE_SIZE},
+ {"GPIO6_BASE_ADDR", GPIO6_BASE_ADDR , 0 , GPIO_SPACE_SIZE}
+};
+/*
+ * name - USER signal name assigned to the pin ( for printks)
+ * mux_func - enum index NAME for the pad_cfg function
+ * pin_num - pin_number if mux_func is GPIO, if not a GPIO it is -1
+ * mux_ptr - pointer to the corresponding pad_cfg_reg
+ * (used for pad release )
+ * mux_save - preserve here original PAD_CNF value for this
+ * pin (used for pad release)
+ * dir - if GPIO: 0 - OUT , 1 - IN
+ * dir_save - save original pin direction
+ * drv - initial drive level "0" or "1"
+ * drv_save - save original pin drive level
+ * valid - 1 if successfuly configured
+*/
+typedef struct {
+ char *name;
+ u32 mux_func;
+ int pin_num;
+ u16 *mux_ptr;
+ u16 mux_save;
+ u8 dir;
+ u8 dir_save;
+ u8 drv;
+ u8 drv_save;
+ u8 valid;
+} user_pad_cfg_t;
+
+/*
+ * need to ensure that enums are in sync with the
+ * omap_mux_pin_cfg table, these enums designate
+ * functions that OMAP pads can be configured to
+ */
+enum {
+ B23_OMAP3430_GPIO_167,
+ D23_OMAP3430_GPIO_126,
+ H1_OMAP3430_GPIO_62,
+ H1_OMAP3430_GPMC_n_w_p,
+ T8_OMAP3430_GPMC_n_c_s4,
+ T8_OMAP3430_GPIO_55,
+ R25_OMAP3430_GPIO_156,
+ R27_OMAP3430_GPIO_128,
+ K8_OMAP3430_GPIO_64,
+ K8_GPMC_WAIT2,
+ G3_OMAP3430_GPIO_60,
+ G3_OMAP3430_n_b_e0_CLE,
+ C6_GPMC_WAIT3,
+ J1_OMAP3430_GPIO_61,
+ C6_OMAP3430_GPIO_65,
+
+ END_OF_TABLE
+};
+
+/*
+ * number of GPIOS we plan to grab
+ */
+#define GPIO_SLOTS 8
+
+/*
+ * user_pads_init() reads(and saves) from/to this table
+ * used in conjunction with omap_3430_mux_t table in .h file
+ * because the way it's done in the kernel code
+ * TODO: implement restore of the the original cfg and i/o regs
+ */
+
+static user_pad_cfg_t user_pad_cfg[] = {
+ /*
+ * name,pad_func,pin_num, mux_ptr, mux_sav, dir,
+ * dir_sav, drv, drv_save, valid
+ */
+ {"AST_WAKEUP", B23_OMAP3430_GPIO_167, 167, NULL, 0,
+ DIR_OUT, 0, DRV_HI, 0, 0},
+ {"AST_RESET", D23_OMAP3430_GPIO_126, 126, NULL, 0,
+ DIR_OUT, 0, DRV_HI, 0, 0},
+ {"AST__rn_b", K8_GPMC_WAIT2, 64, NULL, 0,
+ DIR_INP, 0, 0, 0, 0},
+ {"AST_INTR", H1_OMAP3430_GPIO_62, 62, NULL, 0,
+ DIR_INP, 0, DRV_HI, 0, 0},
+ {"AST_CS", T8_OMAP3430_GPMC_n_c_s4, 55, NULL, 0,
+ DIR_OUT, 0, DRV_HI, 0, 0},
+ {"LED_0", R25_OMAP3430_GPIO_156, 156, NULL, 0,
+ DIR_OUT, 0, DRV_LO, 0, 0},
+ {"LED_1", R27_OMAP3430_GPIO_128, 128, NULL, 0,
+ DIR_OUT, 0, DRV_LO, 0, 0},
+ {"AST_CLE", G3_OMAP3430_n_b_e0_CLE , 60, NULL, 0,
+ DIR_OUT, 0, DRV_LO, 0, 0},
+ /*
+ * Z terminator, must always be present
+ * for sanity check, don't remove
+ */
+ {NULL}
+};
+
+#define GPIO_BANK(pin) (pin >> 5)
+#define REG_WIDTH 32
+#define GPIO_REG_VMA(pin_num, offset) \
+ (gpio_vma_tab[GPIO_BANK(pin_num)].virt_addr + offset)
+
+/*
+ * OMAP GPIO_REG 32 BIT MASK for a bit or
+ * flag in gpio_No[0..191] apply it to a 32 bit
+ * location to set clear or check on a corresponding
+ * gpio bit or flag
+ */
+#define GPIO_REG_MASK(pin_num) (1 << \
+ (pin_num - (GPIO_BANK(pin_num) * REG_WIDTH)))
+
+/*
+ * OMAP GPIO registers bitwise access macros
+ */
+
+#define OMAP_GPIO_BIT(pin_num, reg) \
+ ((*((u32 *)GPIO_REG_VMA(pin_num, reg)) \
+ & GPIO_REG_MASK(pin_num)) ? 1 : 0)
+
+#define RD_OMAP_GPIO_BIT(pin_num, v) OMAP_GPIO_BIT(pin_num, reg)
+
+/*
+ *these are superfast set/clr bitbang macro, 48ns cyc tyme
+ */
+#define OMAP_SET_GPIO(pin_num) \
+ (*(u32 *)GPIO_REG_VMA(pin_num, GPIO_SET_DATAOUT) \
+ = GPIO_REG_MASK(pin_num))
+#define OMAP_CLR_GPIO(pin_num) \
+ (*(u32 *)GPIO_REG_VMA(pin_num, GPIO_CLEAR_DATAOUT) \
+ = GPIO_REG_MASK(pin_num))
+
+#define WR_OMAP_GPIO_BIT(pin_num, v) \
+ (v ? (*(u32 *)GPIO_REG_VMA(pin_num, \
+ GPIO_SET_DATAOUT) = GPIO_REG_MASK(pin_num)) \
+ : (*(u32 *)GPIO_REG_VMA(pin_num, \
+ GPIO_CLEAR_DATAOUT) = GPIO_REG_MASK(pin_num)))
+
+/*
+ * Note this pin cfg mimicks similar implementation
+ * in linux kernel, which unfortunately doesn't allow
+ * us to dynamically insert new custom GPIO mux
+ * configurations all REG definitions used in this
+ * applications. to add a new pad_cfg function, insert
+ * a new ENUM and new pin_cfg entry in omap_mux_pin_cfg[]
+ * table below
+ *
+ * offset - note this is a word offset since the
+ * SCM regs are 16 bit packed in one 32 bit word
+ * mux_val - just enough to describe pins used
+ */
+typedef struct {
+ char *name;
+ u16 offset;
+ u16 mux_val;
+} omap_3430_mux_t;
+
+/*
+ * "OUTIN" is configuration when DATA reg drives the
+ * pin but the level at the pin can be sensed
+ */
+#define PAD_AS_OUTIN (OMAP34XX_MUX_MODE4 | \
+ OMAP34XX_PIN_OUTPUT | OMAP34XX_PIN_INPUT)
+
+omap_3430_mux_t omap_mux_pin_cfg[] = {
+ /*
+ * B23_OMAP3430_GPIO_167 - GPIO func to PAD 167 WB wakeup
+ * D23_OMAP3430_GPIO_126 - drive GPIO_126 ( AST RESET)
+ * H1_OMAP3430_GPIO_62 - need a pullup on this pin
+ * H1_OMAP3430_GPMC_n_w_p - GPMC NAND CTRL n_w_p out
+ * T8_OMAP3430_GPMC_n_c_s4" - T8 is controlled b_y GPMC NAND ctrl
+ * R25_OMAP3430_GPIO_156 - OMAPZOOM drive LED_0
+ * R27_OMAP3430_GPIO_128 - OMAPZOOM drive LED_1
+ * K8_OMAP3430_GPIO_64 - OMAPZOOM drive LED_2
+ * K8_GPMC_WAIT2 - GPMC WAIT2 function on PAD K8
+ * G3_OMAP3430_GPIO_60 - OMAPZOOM drive LED_3
+ * G3_OMAP3430_n_b_e0_CLE -GPMC NAND ctrl CLE signal
+ */
+
+ {"B23_OMAP3430_GPIO_167", 0x0130, (OMAP34XX_MUX_MODE4)},
+ {"D23_OMAP3430_GPIO_126", 0x0132, (OMAP34XX_MUX_MODE4)},
+ {"H1_OMAP3430_GPIO_62", 0x00CA, (OMAP34XX_MUX_MODE4 |
+ OMAP3_INPUT_EN | OMAP34XX_PIN_INPUT_PULLUP) },
+ {"H1_OMAP3430_GPMC_n_w_p", 0x00CA, (OMAP34XX_MUX_MODE0)},
+ {"T8_OMAP3430_GPMC_n_c_s4", 0x00B6, (OMAP34XX_MUX_MODE0) },
+ {"T8_OMAP3430_GPIO_55", 0x00B6, (OMAP34XX_MUX_MODE4) },
+ {"R25_OMAP3430_GPIO_156", 0x018C, (OMAP34XX_MUX_MODE4) },
+ {"R27_OMAP3430_GPIO_128", 0x0154, (OMAP34XX_MUX_MODE4) },
+ {"K8_OMAP3430_GPIO_64", 0x00d0, (OMAP34XX_MUX_MODE4) },
+ {"K8_GPMC_WAIT2", 0x00d0, (OMAP34XX_MUX_MODE0) },
+ {"G3_OMAP3430_GPIO_60", 0x00C6, (OMAP34XX_MUX_MODE4 |
+ OMAP3_INPUT_EN)},
+ {"G3_OMAP3430_n_b_e0_CLE", 0x00C6, (OMAP34XX_MUX_MODE0)},
+ {"C6_GPMC_WAIT3", 0x00d2, (OMAP34XX_MUX_MODE0)},
+ {"C6_OMAP3430_GPIO_65", 0x00d2, (OMAP34XX_MUX_MODE4 |
+ OMAP3_INPUT_EN)},
+ {"J1_OMAP3430_GPIO_61", 0x00C8, (OMAP34XX_MUX_MODE4 |
+ OMAP3_INPUT_EN | OMAP34XX_PIN_INPUT_PULLUP)},
+ /*
+ * don't remove, used for sanity check.
+ */
+ {"END_OF_TABLE"}
+};
+
+
+#endif /* _INCLUDED_CYASMEMMAP_H_ */
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h
new file mode 100644
index 000000000000..896e23281dba
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyasomapdev_kernel.h
@@ -0,0 +1,72 @@
+/* Cypress Antioch OMAP KERNEL file (cyanomapdev_kernel.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor,
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef __CY_AS_OMAP_DEV_KERNEL_H__
+#define __CY_AS_OMAP_DEV_KERNEL_H__
+
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/completion.h>
+
+/* include does not seem to work
+ * moving for patch submission
+#include <mach/gpmc.h>
+*/
+#include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h>
+
+/*
+ * Constants
+ */
+#define CY_AS_OMAP_KERNEL_HAL_SIG (0x1441)
+
+
+/*
+ * Data structures
+ */
+typedef struct cy_as_omap_dev_kernel {
+ /* This is the signature for this data structure */
+ unsigned int m_sig ;
+
+ /* Address base of Antioch Device */
+ void *m_addr_base;
+
+ /* This is a pointer to the next Antioch device in the system */
+ struct cy_as_omap_dev_kernel *m_next_p;
+
+ /* This is for thread sync */
+ struct completion thread_complete;
+
+ /* This is for thread to wait for interrupts */
+ cy_as_hal_sleep_channel thread_sc;
+
+ /* This is for thread to exit upon StopOmapKernel */
+ int thread_flag; /* set 1 to exit */
+
+ int dma_ch;
+
+ /* This is for dma sync */
+ struct completion dma_complete;
+} cy_as_omap_dev_kernel;
+
+#endif
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/block/Kconfig b/drivers/staging/westbridge/astoria/block/Kconfig
new file mode 100644
index 000000000000..851bf96a7b87
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/block/Kconfig
@@ -0,0 +1,9 @@
+#
+# West Bridge block driver configuration
+#
+
+config WESTBRIDGE_BLOCK_DRIVER
+ tristate "West Bridge Block Driver"
+ help
+ Include the West Bridge based block driver
+
diff --git a/drivers/staging/westbridge/astoria/block/Makefile b/drivers/staging/westbridge/astoria/block/Makefile
new file mode 100644
index 000000000000..4a45dd0861e7
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/block/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for the kernel westbridge block driver
+#
+
+ifneq ($(CONFIG_WESTBRIDGE_DEBUG),y)
+ EXTRA_CFLAGS += -DWESTBRIDGE_NDEBUG
+endif
+
+obj-$(CONFIG_WESTBRIDGE_BLOCK_DRIVER) += cyasblkdev.o
+cyasblkdev-y := cyasblkdev_block.o cyasblkdev_queue.o
+
diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
new file mode 100644
index 000000000000..58b89b167870
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
@@ -0,0 +1,1628 @@
+/* cyanblkdev_block.c - West Bridge Linux Block Driver source file
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * Linux block driver implementation for Cypress West Bridge.
+ * Based on the mmc block driver implementation by Andrew Christian
+ * for the linux 2.6.26 kernel.
+ * mmc_block.c, 5/28/2002
+ */
+
+/*
+ * Block driver for media (i.e., flash cards)
+ *
+ * Copyright 2002 Hewlett-Packard Company
+ *
+ * Use consistent with the GNU GPL is permitted,
+ * provided that this copyright notice is
+ * preserved in its entirety in all copies and derived works.
+ *
+ * HEWLETT-PACKARD COMPANY MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
+ * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
+ * FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ * Many thanks to Alessandro Rubini and Jonathan Corbet!
+ *
+ * Author: Andrew Christian
+ * 28 May 2002
+ */
+
+#include <linux/moduleparam.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/hdreg.h>
+#include <linux/kdev_t.h>
+#include <linux/blkdev.h>
+
+#include <asm/system.h>
+#include <linux/uaccess.h>
+
+#include <linux/scatterlist.h>
+#include <linux/time.h>
+#include <linux/signal.h>
+#include <linux/delay.h>
+
+#include "cyasblkdev_queue.h"
+
+#define CYASBLKDEV_SHIFT 0 /* Only a single partition. */
+#define CYASBLKDEV_MAX_REQ_LEN (256)
+#define CYASBLKDEV_NUM_MINORS (256 >> CYASBLKDEV_SHIFT)
+#define CY_AS_TEST_NUM_BLOCKS (64)
+#define CYASBLKDEV_MINOR_0 1
+#define CYASBLKDEV_MINOR_1 2
+#define CYASBLKDEV_MINOR_2 3
+
+static int major;
+module_param(major, int, 0444);
+MODULE_PARM_DESC(major,
+ "specify the major device number for cyasblkdev block driver");
+
+/* parameters passed from the user space */
+static int vfat_search;
+module_param(vfat_search, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(vfat_search,
+ "dynamically find the location of the first sector");
+
+static int private_partition_bus = -1;
+module_param(private_partition_bus, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(private_partition_bus,
+ "bus number for private partition");
+
+static int private_partition_size = -1;
+module_param(private_partition_size, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(private_partition_size,
+ "size of the private partition");
+
+/*
+ * There is one cyasblkdev_blk_data per slot.
+ */
+struct cyasblkdev_blk_data {
+ spinlock_t lock;
+ int media_count[2];
+ const struct block_device_operations *blkops;
+ unsigned int usage;
+ unsigned int suspended;
+
+ /* handle to the west bridge device this handle, typdefed as *void */
+ cy_as_device_handle dev_handle;
+
+ /* our custom structure, in addition to request queue,
+ * adds lock & semaphore items*/
+ struct cyasblkdev_queue queue;
+
+ /* 16 entries is enough given max request size
+ * 16 * 4K (64 K per request)*/
+ struct scatterlist sg[16];
+
+ /* non-zero enables printk of executed reqests */
+ unsigned int dbgprn_flags;
+
+ /*gen_disk for private, system disk */
+ struct gendisk *system_disk;
+ cy_as_media_type system_disk_type;
+ cy_bool system_disk_read_only;
+ cy_bool system_disk_bus_num;
+
+ /* sector size for the medium */
+ unsigned int system_disk_blk_size;
+ unsigned int system_disk_first_sector;
+ unsigned int system_disk_unit_no;
+
+ /*gen_disk for bus 0 */
+ struct gendisk *user_disk_0;
+ cy_as_media_type user_disk_0_type;
+ cy_bool user_disk_0_read_only;
+ cy_bool user_disk_0_bus_num;
+
+ /* sector size for the medium */
+ unsigned int user_disk_0_blk_size;
+ unsigned int user_disk_0_first_sector;
+ unsigned int user_disk_0_unit_no;
+
+ /*gen_disk for bus 1 */
+ struct gendisk *user_disk_1;
+ cy_as_media_type user_disk_1_type;
+ cy_bool user_disk_1_read_only;
+ cy_bool user_disk_1_bus_num;
+
+ /* sector size for the medium */
+ unsigned int user_disk_1_blk_size;
+ unsigned int user_disk_1_first_sector;
+ unsigned int user_disk_1_unit_no;
+};
+
+/* pointer to west bridge block data device superstructure */
+static struct cyasblkdev_blk_data *gl_bd ;
+
+static DECLARE_MUTEX(open_lock);
+
+/* local forwardd declarationss */
+static cy_as_device_handle *cyas_dev_handle;
+static void cyasblkdev_blk_deinit(struct cyasblkdev_blk_data *bd);
+
+/*change debug print options */
+ #define DBGPRN_RD_RQ (1 < 0)
+ #define DBGPRN_WR_RQ (1 < 1)
+ #define DBGPRN_RQ_END (1 < 2)
+
+int blkdev_ctl_dbgprn(
+ int prn_flags
+ )
+{
+ int cur_options = gl_bd->dbgprn_flags;
+
+ DBGPRN_FUNC_NAME;
+
+ /* set new debug print options */
+ gl_bd->dbgprn_flags = prn_flags;
+
+ /* return previous */
+ return cur_options;
+}
+EXPORT_SYMBOL(blkdev_ctl_dbgprn);
+
+static struct cyasblkdev_blk_data *cyasblkdev_blk_get(
+ struct gendisk *disk
+ )
+{
+ struct cyasblkdev_blk_data *bd;
+
+ DBGPRN_FUNC_NAME;
+
+ down(&open_lock);
+
+ bd = disk->private_data;
+
+ if (bd && (bd->usage == 0))
+ bd = NULL;
+
+ if (bd) {
+ bd->usage++;
+ #ifndef NBDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev_blk_get: usage = %d\n", bd->usage) ;
+ #endif
+ }
+ up(&open_lock);
+
+ return bd;
+}
+
+static void cyasblkdev_blk_put(
+ struct cyasblkdev_blk_data *bd
+ )
+{
+ DBGPRN_FUNC_NAME;
+
+ down(&open_lock);
+
+ if (bd) {
+ bd->usage--;
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ " cyasblkdev_blk_put , bd->usage= %d\n", bd->usage);
+ #endif
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev: blk_put(bd) on bd = NULL!: usage = %d\n",
+ bd->usage);
+ #endif
+ up(&open_lock);
+ return ;
+ }
+
+ if (bd->usage == 0) {
+ put_disk(bd->user_disk_0);
+ put_disk(bd->user_disk_1);
+ put_disk(bd->system_disk);
+ cyasblkdev_cleanup_queue(&bd->queue);
+
+ if (CY_AS_ERROR_SUCCESS !=
+ cy_as_storage_release(bd->dev_handle, 0, 0, 0, 0)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev: cannot release bus 0\n") ;
+ #endif
+ }
+
+ if (CY_AS_ERROR_SUCCESS !=
+ cy_as_storage_release(bd->dev_handle, 1, 0, 0, 0)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev: cannot release bus 1\n") ;
+ #endif
+ }
+
+ if (CY_AS_ERROR_SUCCESS !=
+ cy_as_storage_stop(bd->dev_handle, 0, 0)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev: cannot stop storage stack\n") ;
+ #endif
+ }
+
+ #ifdef __CY_ASTORIA_SCM_KERNEL_HAL__
+ /* If the SCM Kernel HAL is being used, disable the use
+ * of scatter/gather lists at the end of block driver usage.
+ */
+ cy_as_hal_disable_scatter_list(cyasdevice_gethaltag()) ;
+ #endif
+
+ /*ptr to global struct cyasblkdev_blk_data */
+ gl_bd = NULL ;
+ kfree(bd);
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev (blk_put): usage = %d\n",
+ bd->usage) ;
+ #endif
+ up(&open_lock);
+}
+
+static int cyasblkdev_blk_open(
+ struct block_device *bdev,
+ fmode_t mode
+ )
+{
+ struct cyasblkdev_blk_data *bd = cyasblkdev_blk_get(bdev->bd_disk);
+ int ret = -ENXIO;
+
+ DBGPRN_FUNC_NAME;
+
+ if (bd) {
+ if (bd->usage == 2)
+ check_disk_change(bdev);
+
+ ret = 0;
+
+ if (bdev->bd_disk == bd->user_disk_0) {
+ if ((mode & FMODE_WRITE) && bd->user_disk_0_read_only) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "device marked as readonly "
+ "and write requested\n");
+ #endif
+
+ cyasblkdev_blk_put(bd);
+ ret = -EROFS;
+ }
+ } else if (bdev->bd_disk == bd->user_disk_1) {
+ if ((mode & FMODE_WRITE) && bd->user_disk_1_read_only) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "device marked as readonly "
+ "and write requested\n");
+ #endif
+
+ cyasblkdev_blk_put(bd);
+ ret = -EROFS;
+ }
+ } else if (bdev->bd_disk == bd->system_disk) {
+ if ((mode & FMODE_WRITE) && bd->system_disk_read_only) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "device marked as readonly "
+ "and write requested\n");
+ #endif
+
+ cyasblkdev_blk_put(bd);
+ ret = -EROFS;
+ }
+ }
+ }
+
+ return ret;
+}
+
+static int cyasblkdev_blk_release(
+ struct gendisk *disk,
+ fmode_t mode
+ )
+{
+ struct cyasblkdev_blk_data *bd = disk->private_data;
+
+ DBGPRN_FUNC_NAME;
+
+ cyasblkdev_blk_put(bd);
+ return 0;
+}
+
+static int cyasblkdev_blk_ioctl(
+ struct block_device *bdev,
+ fmode_t mode,
+ unsigned int cmd,
+ unsigned long arg
+ )
+{
+ DBGPRN_FUNC_NAME;
+
+ if (cmd == HDIO_GETGEO) {
+ /*for now we only process geometry IOCTL*/
+ struct hd_geometry geo;
+
+ memset(&geo, 0, sizeof(struct hd_geometry));
+
+ geo.cylinders = get_capacity(bdev->bd_disk) / (4 * 16);
+ geo.heads = 4;
+ geo.sectors = 16;
+ geo.start = get_start_sect(bdev);
+
+ /* copy to user space */
+ return copy_to_user((void __user *)arg, &geo, sizeof(geo))
+ ? -EFAULT : 0;
+ }
+
+ return -ENOTTY;
+}
+
+/* Media_changed block_device opp
+ * this one is called by kernel to confirm if the media really changed
+ * as we indicated by issuing check_disk_change() call */
+int cyasblkdev_media_changed(struct gendisk *gd)
+{
+ struct cyasblkdev_blk_data *bd;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("cyasblkdev_media_changed() is called\n");
+ #endif
+
+ if (gd)
+ bd = gd->private_data;
+ else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "cyasblkdev_media_changed() is called, "
+ "but gd is null\n");
+ #endif
+ }
+
+ /* return media change state "1" yes, 0 no */
+ return 1;
+}
+
+/* this one called by kernel to give us a chence
+ * to prep the new media before it starts to rescaning
+ * of the newlly inserted SD media */
+int cyasblkdev_revalidate_disk(struct gendisk *gd)
+{
+ /*int (*revalidate_disk) (struct gendisk *); */
+
+ #ifndef WESTBRIDGE_NDEBUG
+ if (gd)
+ cy_as_hal_print_message(
+ "cyasblkdev_revalidate_disk() is called, "
+ "(gl_bd->usage:%d)\n", gl_bd->usage);
+ #endif
+
+ /* 0 means ok, kern can go ahead with partition rescan */
+ return 0;
+}
+
+
+/*standard block device driver interface */
+static struct block_device_operations cyasblkdev_bdops = {
+ .open = cyasblkdev_blk_open,
+ .release = cyasblkdev_blk_release,
+ .ioctl = cyasblkdev_blk_ioctl,
+ /* .getgeo = cyasblkdev_blk_getgeo, */
+ /* added to support media removal( real and simulated) media */
+ .media_changed = cyasblkdev_media_changed,
+ /* added to support media removal( real and simulated) media */
+ .revalidate_disk = cyasblkdev_revalidate_disk,
+ .owner = THIS_MODULE,
+};
+
+/* west bridge block device prep request function */
+static int cyasblkdev_blk_prep_rq(
+ struct cyasblkdev_queue *bq,
+ struct request *req
+ )
+{
+ struct cyasblkdev_blk_data *bd = bq->data;
+ int stat = BLKPREP_OK;
+
+ DBGPRN_FUNC_NAME;
+
+ /* If we have no device, we haven't finished initialising. */
+ if (!bd || !bd->dev_handle) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(KERN_ERR
+ "cyasblkdev %s: killing request - no device/host\n",
+ req->rq_disk->disk_name);
+ #endif
+ stat = BLKPREP_KILL;
+ }
+
+ if (bd->suspended) {
+ blk_plug_device(bd->queue.queue);
+ stat = BLKPREP_DEFER;
+ }
+
+ /* Check for excessive requests.*/
+ if (blk_rq_pos(req) + blk_rq_sectors(req) > get_capacity(req->rq_disk)) {
+ cy_as_hal_print_message("cyasblkdev: bad request address\n");
+ stat = BLKPREP_KILL;
+ }
+
+ return stat;
+}
+
+/*west bridge storage async api on_completed callback */
+static void cyasblkdev_issuecallback(
+ /* Handle to the device completing the storage operation */
+ cy_as_device_handle handle,
+ /* The media type completing the operation */
+ cy_as_media_type type,
+ /* The device completing the operation */
+ uint32_t device,
+ /* The unit completing the operation */
+ uint32_t unit,
+ /* The block number of the completed operation */
+ uint32_t block_number,
+ /* The type of operation */
+ cy_as_oper_type op,
+ /* The error status */
+ cy_as_return_status_t status
+ )
+{
+ int retry_cnt = 0;
+ DBGPRN_FUNC_NAME;
+
+ if (status != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: async r/w: op:%d failed with error %d at address %d\n",
+ __func__, op, status, block_number) ;
+ #endif
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s calling blk_end_request from issue_callback "
+ "req=0x%x, status=0x%x, nr_sectors=0x%x\n",
+ __func__, (unsigned int) gl_bd->queue.req, status,
+ (unsigned int) blk_rq_sectors(gl_bd->queue.req)) ;
+ #endif
+
+ /* note: blk_end_request w/o __ prefix should
+ * not require spinlocks on the queue*/
+ while (blk_end_request(gl_bd->queue.req,
+ status, blk_rq_sectors(gl_bd->queue.req)*512)) {
+ retry_cnt++;
+ };
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s blkdev_callback: ended rq on %d sectors, "
+ "with err:%d, n:%d times\n", __func__,
+ (int)blk_rq_sectors(gl_bd->queue.req), status,
+ retry_cnt
+ );
+ #endif
+
+ spin_lock_irq(&gl_bd->lock);
+
+ /*elevate next request, if there is one*/
+ if (!blk_queue_plugged(gl_bd->queue.queue)) {
+ /* queue is not plugged */
+ gl_bd->queue.req = blk_fetch_request(gl_bd->queue.queue);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s blkdev_callback: "
+ "blk_fetch_request():%p\n",
+ __func__, gl_bd->queue.req);
+ #endif
+ }
+
+ if (gl_bd->queue.req) {
+ spin_unlock_irq(&gl_bd->lock);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s blkdev_callback: about to "
+ "call issue_fn:%p\n", __func__, gl_bd->queue.req);
+ #endif
+
+ gl_bd->queue.issue_fn(&gl_bd->queue, gl_bd->queue.req);
+ } else {
+ spin_unlock_irq(&gl_bd->lock);
+ }
+}
+
+/* issue astoria blkdev request (issue_fn) */
+static int cyasblkdev_blk_issue_rq(
+ struct cyasblkdev_queue *bq,
+ struct request *req
+ )
+{
+ struct cyasblkdev_blk_data *bd = bq->data;
+ int index = 0 ;
+ int ret = CY_AS_ERROR_SUCCESS;
+ uint32_t req_sector = 0;
+ uint32_t req_nr_sectors = 0;
+ int bus_num = 0;
+ int lcl_unit_no = 0;
+
+ DBGPRN_FUNC_NAME;
+
+ /*
+ * will construct a scatterlist for the given request;
+ * the return value is the number of actually used
+ * entries in the resulting list. Then, this scatterlist
+ * can be used for the actual DMA prep operation.
+ */
+ spin_lock_irq(&bd->lock);
+ index = blk_rq_map_sg(bq->queue, req, bd->sg);
+
+ if (req->rq_disk == bd->user_disk_0) {
+ bus_num = bd->user_disk_0_bus_num;
+ req_sector = blk_rq_pos(req) + gl_bd->user_disk_0_first_sector;
+ req_nr_sectors = blk_rq_sectors(req);
+ lcl_unit_no = gl_bd->user_disk_0_unit_no;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: request made to disk 0 "
+ "for sector=%d, num_sectors=%d, unit_no=%d\n",
+ __func__, req_sector, (int) blk_rq_sectors(req),
+ lcl_unit_no);
+ #endif
+ } else if (req->rq_disk == bd->user_disk_1) {
+ bus_num = bd->user_disk_1_bus_num;
+ req_sector = blk_rq_pos(req) + gl_bd->user_disk_1_first_sector;
+ /*SECT_NUM_TRANSLATE(blk_rq_sectors(req));*/
+ req_nr_sectors = blk_rq_sectors(req);
+ lcl_unit_no = gl_bd->user_disk_1_unit_no;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: request made to disk 1 for "
+ "sector=%d, num_sectors=%d, unit_no=%d\n", __func__,
+ req_sector, (int) blk_rq_sectors(req), lcl_unit_no);
+ #endif
+ } else if (req->rq_disk == bd->system_disk) {
+ bus_num = bd->system_disk_bus_num;
+ req_sector = blk_rq_pos(req) + gl_bd->system_disk_first_sector;
+ req_nr_sectors = blk_rq_sectors(req);
+ lcl_unit_no = gl_bd->system_disk_unit_no;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: request made to system disk "
+ "for sector=%d, num_sectors=%d, unit_no=%d\n", __func__,
+ req_sector, (int) blk_rq_sectors(req), lcl_unit_no);
+ #endif
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message(
+ "%s: invalid disk used for request\n", __func__);
+ }
+ #endif
+
+ spin_unlock_irq(&bd->lock);
+
+ if (rq_data_dir(req) == READ) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: calling readasync() "
+ "req_sector=0x%x, req_nr_sectors=0x%x, bd->sg:%x\n\n",
+ __func__, req_sector, req_nr_sectors, (uint32_t)bd->sg);
+ #endif
+
+ ret = cy_as_storage_read_async(bd->dev_handle, bus_num, 0,
+ lcl_unit_no, req_sector, bd->sg, req_nr_sectors,
+ (cy_as_storage_callback)cyasblkdev_issuecallback);
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s:readasync() error %d at "
+ "address %ld, unit no %d\n", __func__, ret,
+ blk_rq_pos(req), lcl_unit_no);
+ cy_as_hal_print_message("%s:ending i/o request "
+ "on reg:%x\n", __func__, (uint32_t)req);
+ #endif
+
+ while (blk_end_request(req,
+ (ret == CY_AS_ERROR_SUCCESS),
+ req_nr_sectors*512))
+ ;
+
+ bq->req = NULL ;
+ }
+ } else {
+ ret = cy_as_storage_write_async(bd->dev_handle, bus_num, 0,
+ lcl_unit_no, req_sector, bd->sg, req_nr_sectors,
+ (cy_as_storage_callback)cyasblkdev_issuecallback);
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: write failed with "
+ "error %d at address %ld, unit no %d\n",
+ __func__, ret, blk_rq_pos(req), lcl_unit_no);
+ #endif
+
+ /*end IO op on this request(does both
+ * end_that_request_... _first & _last) */
+ while (blk_end_request(req,
+ (ret == CY_AS_ERROR_SUCCESS),
+ req_nr_sectors*512))
+ ;
+
+ bq->req = NULL ;
+ }
+ }
+
+ return ret;
+}
+
+static unsigned long
+dev_use[CYASBLKDEV_NUM_MINORS / (8 * sizeof(unsigned long))];
+
+
+/* storage event callback (note: called in astoria isr context) */
+static void cyasblkdev_storage_callback(
+ cy_as_device_handle dev_h,
+ cy_as_bus_number_t bus,
+ uint32_t device,
+ cy_as_storage_event evtype,
+ void *evdata
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: bus:%d, device:%d, evtype:%d, "
+ "evdata:%p\n ", __func__, bus, device, evtype, evdata);
+ #endif
+
+ switch (evtype) {
+ case cy_as_storage_processor:
+ break;
+
+ case cy_as_storage_removed:
+ break;
+
+ case cy_as_storage_inserted:
+ break;
+
+ default:
+ break;
+ }
+}
+
+#define SECTORS_TO_SCAN 4096
+
+uint32_t cyasblkdev_get_vfat_offset(int bus_num, int unit_no)
+{
+ /*
+ * for sd media, vfat partition boot record is not always
+ * located at sector it greatly depends on the system and
+ * software that was used to format the sd however, linux
+ * fs layer always expects it at sector 0, this function
+ * finds the offset and then uses it in all media r/w
+ * operations
+ */
+ int sect_no, stat;
+ uint8_t *sect_buf;
+ bool br_found = false;
+
+ DBGPRN_FUNC_NAME;
+
+ sect_buf = kmalloc(1024, GFP_KERNEL);
+
+ /* since HAL layer always uses sg lists instead of the
+ * buffer (for hw dmas) we need to initialize the sg list
+ * for local buffer*/
+ sg_init_one(gl_bd->sg, sect_buf, 512);
+
+ /*
+ * Check MPR partition table 1st, then try to scan through
+ * 1st 384 sectors until BR signature(intel JMP istruction
+ * code and ,0x55AA) is found
+ */
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s scanning media for vfat partition...\n", __func__) ;
+ #endif
+
+ for (sect_no = 0; sect_no < SECTORS_TO_SCAN; sect_no++) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s before cyasstorageread "
+ "gl_bd->sg addr=0x%x\n", __func__,
+ (unsigned int) gl_bd->sg);
+ #endif
+
+ stat = cy_as_storage_read(
+ /* Handle to the device of interest */
+ gl_bd->dev_handle,
+ /* The bus to access */
+ bus_num,
+ /* The device to access */
+ 0,
+ /* The unit to access */
+ unit_no,
+ /* absolute sector number */
+ sect_no,
+ /* sg structure */
+ gl_bd->sg,
+ /* The number of blocks to be read */
+ 1
+ );
+
+ /* try only sectors with boot signature */
+ if ((sect_buf[510] == 0x55) && (sect_buf[511] == 0xaa)) {
+ /* vfat boot record may also be located at
+ * sector 0, check it first */
+ if (sect_buf[0] == 0xEB) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s vfat partition found "
+ "at sector:%d\n",
+ __func__, sect_no);
+ #endif
+
+ br_found = true;
+ break;
+ }
+ }
+
+ if (stat != 0) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s sector scan error\n",
+ __func__);
+ #endif
+ break;
+ }
+ }
+
+ kfree(sect_buf);
+
+ if (br_found) {
+ return sect_no;
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s vfat partition is not found, using 0 offset\n",
+ __func__);
+ #endif
+ return 0;
+ }
+}
+
+cy_as_storage_query_device_data dev_data = {0} ;
+
+static int cyasblkdev_add_disks(int bus_num,
+ struct cyasblkdev_blk_data *bd,
+ int total_media_count,
+ int devidx)
+{
+ int ret = 0;
+ uint64_t disk_cap;
+ int lcl_unit_no;
+ cy_as_storage_query_unit_data unit_data = {0} ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s:query device: "
+ "type:%d, removable:%d, writable:%d, "
+ "blksize %d, units:%d, locked:%d, "
+ "erase_sz:%d\n",
+ __func__,
+ dev_data.desc_p.type,
+ dev_data.desc_p.removable,
+ dev_data.desc_p.writeable,
+ dev_data.desc_p.block_size,
+ dev_data.desc_p.number_units,
+ dev_data.desc_p.locked,
+ dev_data.desc_p.erase_unit_size
+ );
+ #endif
+
+ /* make sure that device is not locked */
+ if (dev_data.desc_p.locked) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: device is locked\n", __func__);
+ #endif
+ ret = cy_as_storage_release(
+ bd->dev_handle, bus_num, 0, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s cannot release"
+ " storage\n", __func__) ;
+ #endif
+ goto out;
+ }
+ goto out;
+ }
+
+ unit_data.device = 0 ;
+ unit_data.unit = 0 ;
+ unit_data.bus = bus_num;
+ ret = cy_as_storage_query_unit(bd->dev_handle,
+ &unit_data, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot query "
+ "%d device unit - reason code %d\n",
+ __func__, bus_num, ret) ;
+ #endif
+ goto out ;
+ }
+
+ if (private_partition_bus == bus_num) {
+ if (private_partition_size > 0) {
+ ret = cy_as_storage_create_p_partition(
+ bd->dev_handle, bus_num, 0,
+ private_partition_size, 0, 0);
+ if ((ret != CY_AS_ERROR_SUCCESS) &&
+ (ret != CY_AS_ERROR_ALREADY_PARTITIONED)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_storage_"
+ "create_p_partition after size > 0 check "
+ "failed with error code %d\n",
+ __func__, ret);
+ #endif
+
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no = 0;
+
+ } else if (ret == CY_AS_ERROR_ALREADY_PARTITIONED) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cy_as_storage_create_p_partition "
+ "indicates memory already partitioned\n",
+ __func__);
+ #endif
+
+ /*check to see that partition
+ * matches size */
+ if (unit_data.desc_p.unit_size !=
+ private_partition_size) {
+ ret = cy_as_storage_remove_p_partition(
+ bd->dev_handle,
+ bus_num, 0, 0, 0);
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ ret = cy_as_storage_create_p_partition(
+ bd->dev_handle, bus_num, 0,
+ private_partition_size, 0, 0);
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ unit_data.bus = bus_num ;
+ unit_data.device = 0 ;
+ unit_data.unit = 1 ;
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cy_as_storage_create_p_partition "
+ "after removal unexpectedly failed "
+ "with error %d\n", __func__, ret) ;
+ #endif
+
+ /* need to requery bus
+ * seeing as delete
+ * successful and create
+ * failed we have changed
+ * the disk properties */
+ unit_data.bus = bus_num ;
+ unit_data.device = 0 ;
+ unit_data.unit = 0 ;
+ }
+
+ ret = cy_as_storage_query_unit(
+ bd->dev_handle,
+ &unit_data, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cannot query %d "
+ "device unit - reason code %d\n",
+ __func__, bus_num, ret) ;
+ #endif
+ goto out ;
+ } else {
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no =
+ unit_data.unit;
+ }
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cy_as_storage_remove_p_partition "
+ "failed with error %d\n",
+ __func__, ret);
+ #endif
+
+ unit_data.bus = bus_num ;
+ unit_data.device = 0 ;
+ unit_data.unit = 1 ;
+
+ ret = cy_as_storage_query_unit(
+ bd->dev_handle, &unit_data, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cannot query %d "
+ "device unit - reason "
+ "code %d\n", __func__,
+ bus_num, ret) ;
+ #endif
+ goto out ;
+ }
+
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no =
+ unit_data.unit ;
+ }
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: partition "
+ "exists and sizes equal\n",
+ __func__);
+ #endif
+
+ /*partition already existed,
+ * need to query second unit*/
+ unit_data.bus = bus_num ;
+ unit_data.device = 0 ;
+ unit_data.unit = 1 ;
+
+ ret = cy_as_storage_query_unit(
+ bd->dev_handle, &unit_data, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cannot query %d "
+ "device unit "
+ "- reason code %d\n",
+ __func__, bus_num, ret) ;
+ #endif
+ goto out ;
+ } else {
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no = unit_data.unit ;
+ }
+ }
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cy_as_storage_create_p_partition "
+ "created successfully\n", __func__);
+ #endif
+
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size -
+ private_partition_size);
+
+ lcl_unit_no = 1;
+ }
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message(
+ "%s: invalid partition_size%d\n", __func__,
+ private_partition_size);
+
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no = 0;
+ }
+ #endif
+ } else {
+ disk_cap = (uint64_t)
+ (unit_data.desc_p.unit_size);
+ lcl_unit_no = 0;
+ }
+
+ if ((bus_num == 0) ||
+ (total_media_count == 1)) {
+ sprintf(bd->user_disk_0->disk_name,
+ "cyasblkdevblk%d", devidx);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: disk unit_sz:%lu blk_sz:%d, "
+ "start_blk:%lu, capacity:%llu\n",
+ __func__, (unsigned long)
+ unit_data.desc_p.unit_size,
+ unit_data.desc_p.block_size,
+ (unsigned long)
+ unit_data.desc_p.start_block,
+ (uint64_t)disk_cap
+ );
+ #endif
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: setting gendisk disk "
+ "capacity to %d\n", __func__, (int) disk_cap);
+ #endif
+
+ /* initializing bd->queue */
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: init bd->queue\n",
+ __func__);
+ #endif
+
+ /* this will create a
+ * queue kernel thread */
+ cyasblkdev_init_queue(
+ &bd->queue, &bd->lock) ;
+
+ bd->queue.prep_fn = cyasblkdev_blk_prep_rq;
+ bd->queue.issue_fn = cyasblkdev_blk_issue_rq;
+ bd->queue.data = bd;
+
+ /*blk_size should always
+ * be a multiple of 512,
+ * set to the max to ensure
+ * that all accesses aligned
+ * to the greatest multiple,
+ * can adjust request to
+ * smaller block sizes
+ * dynamically*/
+
+ bd->user_disk_0_read_only = !dev_data.desc_p.writeable;
+ bd->user_disk_0_blk_size = dev_data.desc_p.block_size;
+ bd->user_disk_0_type = dev_data.desc_p.type;
+ bd->user_disk_0_bus_num = bus_num;
+ bd->user_disk_0->major = major;
+ bd->user_disk_0->first_minor = devidx << CYASBLKDEV_SHIFT;
+ bd->user_disk_0->minors = 8;
+ bd->user_disk_0->fops = &cyasblkdev_bdops;
+ bd->user_disk_0->private_data = bd;
+ bd->user_disk_0->queue = bd->queue.queue;
+ bd->dbgprn_flags = DBGPRN_RD_RQ;
+ bd->user_disk_0_unit_no = lcl_unit_no;
+
+ blk_queue_logical_block_size(bd->queue.queue,
+ bd->user_disk_0_blk_size);
+
+ set_capacity(bd->user_disk_0,
+ disk_cap);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: returned from set_capacity %d\n",
+ __func__, (int) disk_cap);
+ #endif
+
+ /* need to start search from
+ * public partition beginning */
+ if (vfat_search) {
+ bd->user_disk_0_first_sector =
+ cyasblkdev_get_vfat_offset(0,
+ bd->user_disk_0_unit_no);
+ } else {
+ bd->user_disk_0_first_sector = 0;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: set user_disk_0_first "
+ "sector to %d\n", __func__,
+ bd->user_disk_0_first_sector);
+ cy_as_hal_print_message(
+ "%s: add_disk: disk->major=0x%x\n",
+ __func__,
+ bd->user_disk_0->major);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->first_minor=0x%x\n", __func__,
+ bd->user_disk_0->first_minor);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->minors=0x%x\n", __func__,
+ bd->user_disk_0->minors);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->disk_name=%s\n",
+ __func__,
+ bd->user_disk_0->disk_name);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->part_tbl=0x%x\n", __func__,
+ (unsigned int)
+ bd->user_disk_0->part_tbl);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->queue=0x%x\n", __func__,
+ (unsigned int)
+ bd->user_disk_0->queue);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->flags=0x%x\n",
+ __func__, (unsigned int)
+ bd->user_disk_0->flags);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->driverfs_dev=0x%x\n",
+ __func__, (unsigned int)
+ bd->user_disk_0->driverfs_dev);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->slave_dir=0x%x\n",
+ __func__, (unsigned int)
+ bd->user_disk_0->slave_dir);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->random=0x%x\n",
+ __func__, (unsigned int)
+ bd->user_disk_0->random);
+ cy_as_hal_print_message(
+ "%s: add_disk: "
+ "disk->node_id=0x%x\n",
+ __func__, (unsigned int)
+ bd->user_disk_0->node_id);
+
+ #endif
+
+ add_disk(bd->user_disk_0);
+
+ } else if ((bus_num == 1) &&
+ (total_media_count == 2)) {
+ bd->user_disk_1_read_only = !dev_data.desc_p.writeable;
+ bd->user_disk_1_blk_size = dev_data.desc_p.block_size;
+ bd->user_disk_1_type = dev_data.desc_p.type;
+ bd->user_disk_1_bus_num = bus_num;
+ bd->user_disk_1->major = major;
+ bd->user_disk_1->first_minor = (devidx + 1) << CYASBLKDEV_SHIFT;
+ bd->user_disk_1->minors = 8;
+ bd->user_disk_1->fops = &cyasblkdev_bdops;
+ bd->user_disk_1->private_data = bd;
+ bd->user_disk_1->queue = bd->queue.queue;
+ bd->dbgprn_flags = DBGPRN_RD_RQ;
+ bd->user_disk_1_unit_no = lcl_unit_no;
+
+ sprintf(bd->user_disk_1->disk_name,
+ "cyasblkdevblk%d", (devidx + 1));
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: disk unit_sz:%lu "
+ "blk_sz:%d, "
+ "start_blk:%lu, "
+ "capacity:%llu\n",
+ __func__,
+ (unsigned long)
+ unit_data.desc_p.unit_size,
+ unit_data.desc_p.block_size,
+ (unsigned long)
+ unit_data.desc_p.start_block,
+ (uint64_t)disk_cap
+ );
+ #endif
+
+ /*blk_size should always be a
+ * multiple of 512, set to the max
+ * to ensure that all accesses
+ * aligned to the greatest multiple,
+ * can adjust request to smaller
+ * block sizes dynamically*/
+ if (bd->user_disk_0_blk_size >
+ bd->user_disk_1_blk_size) {
+ blk_queue_logical_block_size(bd->queue.queue,
+ bd->user_disk_0_blk_size);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: set hard sect_sz:%d\n",
+ __func__,
+ bd->user_disk_0_blk_size);
+ #endif
+ } else {
+ blk_queue_logical_block_size(bd->queue.queue,
+ bd->user_disk_1_blk_size);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: set hard sect_sz:%d\n",
+ __func__,
+ bd->user_disk_1_blk_size);
+ #endif
+ }
+
+ set_capacity(bd->user_disk_1, disk_cap);
+ if (vfat_search) {
+ bd->user_disk_1_first_sector =
+ cyasblkdev_get_vfat_offset(
+ 1, bd->user_disk_1_unit_no);
+ } else {
+ bd->user_disk_1_first_sector
+ = 0;
+ }
+
+ add_disk(bd->user_disk_1);
+ }
+
+ if (lcl_unit_no > 0) {
+ if (bd->system_disk == NULL) {
+ bd->system_disk =
+ alloc_disk(CYASBLKDEV_MINOR_2
+ << CYASBLKDEV_SHIFT);
+ if (bd->system_disk == NULL) {
+ kfree(bd);
+ bd = ERR_PTR(-ENOMEM);
+ return bd ;
+ }
+ disk_cap = (uint64_t)
+ (private_partition_size);
+
+ /* set properties of
+ * system disk */
+ bd->system_disk_read_only = !dev_data.desc_p.writeable;
+ bd->system_disk_blk_size = dev_data.desc_p.block_size;
+ bd->system_disk_bus_num = bus_num;
+ bd->system_disk->major = major;
+ bd->system_disk->first_minor =
+ (devidx + 2) << CYASBLKDEV_SHIFT;
+ bd->system_disk->minors = 8;
+ bd->system_disk->fops = &cyasblkdev_bdops;
+ bd->system_disk->private_data = bd;
+ bd->system_disk->queue = bd->queue.queue;
+ /* don't search for vfat
+ * with system disk */
+ bd->system_disk_first_sector = 0;
+ sprintf(
+ bd->system_disk->disk_name,
+ "cyasblkdevblk%d", (devidx + 2));
+
+ set_capacity(bd->system_disk,
+ disk_cap);
+
+ add_disk(bd->system_disk);
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message(
+ "%s: system disk already allocated %d\n",
+ __func__, bus_num) ;
+ }
+ #endif
+ }
+out:
+ return ret;
+}
+
+static struct cyasblkdev_blk_data *cyasblkdev_blk_alloc(void)
+{
+ struct cyasblkdev_blk_data *bd;
+ int ret = 0 ;
+ cy_as_return_status_t stat = -1 ;
+ int bus_num = 0;
+ int total_media_count = 0;
+ int devidx = 0;
+ DBGPRN_FUNC_NAME;
+
+ total_media_count = 0;
+ devidx = find_first_zero_bit(dev_use, CYASBLKDEV_NUM_MINORS);
+ if (devidx >= CYASBLKDEV_NUM_MINORS)
+ return ERR_PTR(-ENOSPC);
+
+ __set_bit(devidx, dev_use);
+ __set_bit(devidx + 1, dev_use);
+
+ bd = kzalloc(sizeof(struct cyasblkdev_blk_data), GFP_KERNEL);
+ if (bd) {
+ gl_bd = bd ;
+
+ spin_lock_init(&bd->lock);
+ bd->usage = 1;
+
+ /* setup the block_dev_ops pointer*/
+ bd->blkops = &cyasblkdev_bdops;
+
+ /* Get the device handle */
+ bd->dev_handle = cyasdevice_getdevhandle() ;
+ if (0 == bd->dev_handle) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: get device failed\n", __func__) ;
+ #endif
+ ret = ENODEV ;
+ goto out ;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s west bridge device handle:%x\n",
+ __func__, (uint32_t)bd->dev_handle);
+ #endif
+
+ /* start the storage api and get a handle to the
+ * device we are interested in. */
+
+ /* Error code to use if the conditions are not satisfied. */
+ ret = ENOMEDIUM ;
+
+ stat = cy_as_misc_release_resource(bd->dev_handle, cy_as_bus_0);
+ if ((stat != CY_AS_ERROR_SUCCESS) &&
+ (stat != CY_AS_ERROR_RESOURCE_NOT_OWNED)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot release "
+ "resource bus 0 - reason code %d\n",
+ __func__, stat) ;
+ #endif
+ }
+
+ stat = cy_as_misc_release_resource(bd->dev_handle, cy_as_bus_1);
+ if ((stat != CY_AS_ERROR_SUCCESS) &&
+ (stat != CY_AS_ERROR_RESOURCE_NOT_OWNED)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot release "
+ "resource bus 0 - reason code %d\n",
+ __func__, stat) ;
+ #endif
+ }
+
+ /* start storage stack*/
+ stat = cy_as_storage_start(bd->dev_handle, 0, 0x101) ;
+ if (stat != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot start storage "
+ "stack - reason code %d\n", __func__, stat) ;
+ #endif
+ goto out;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: storage started:%d ok\n",
+ __func__, stat);
+ #endif
+
+ stat = cy_as_storage_register_callback(bd->dev_handle,
+ cyasblkdev_storage_callback);
+ if (stat != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot register callback "
+ "- reason code %d\n", __func__, stat) ;
+ #endif
+ goto out;
+ }
+
+ for (bus_num = 0; bus_num < 2; bus_num++) {
+ stat = cy_as_storage_query_bus(bd->dev_handle,
+ bus_num, &bd->media_count[bus_num], 0, 0) ;
+ if (stat == CY_AS_ERROR_SUCCESS) {
+ total_media_count = total_media_count +
+ bd->media_count[bus_num];
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cannot query %d, "
+ "reason code: %d\n",
+ __func__, bus_num, stat) ;
+ #endif
+ goto out;
+ }
+ }
+
+ if (total_media_count == 0) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: no storage media was found\n", __func__) ;
+ #endif
+ goto out ;
+ } else if (total_media_count >= 1) {
+ if (bd->user_disk_0 == NULL) {
+
+ bd->user_disk_0 =
+ alloc_disk(CYASBLKDEV_MINOR_0
+ << CYASBLKDEV_SHIFT);
+ if (bd->user_disk_0 == NULL) {
+ kfree(bd);
+ bd = ERR_PTR(-ENOMEM);
+ return bd ;
+ }
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message("%s: no available "
+ "gen_disk for disk 0, "
+ "physically inconsistent\n", __func__);
+ }
+ #endif
+ }
+
+ if (total_media_count == 2) {
+ if (bd->user_disk_1 == NULL) {
+ bd->user_disk_1 =
+ alloc_disk(CYASBLKDEV_MINOR_1
+ << CYASBLKDEV_SHIFT);
+ if (bd->user_disk_1 == NULL) {
+ kfree(bd);
+ bd = ERR_PTR(-ENOMEM);
+ return bd ;
+ }
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message("%s: no available "
+ "gen_disk for media, "
+ "physically inconsistent\n", __func__);
+ }
+ #endif
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else if (total_media_count > 2) {
+ cy_as_hal_print_message("%s: count corrupted = 0x%d\n",
+ __func__, total_media_count);
+ }
+ #endif
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: %d device(s) found\n",
+ __func__, total_media_count) ;
+ #endif
+
+ for (bus_num = 0; bus_num <= 1; bus_num++) {
+ /*claim storage for cpu */
+ stat = cy_as_storage_claim(bd->dev_handle,
+ bus_num, 0, 0, 0) ;
+ if (stat != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("%s: cannot claim "
+ "%d bus - reason code %d\n",
+ __func__, bus_num, stat) ;
+ goto out;
+ }
+
+ dev_data.bus = bus_num ;
+ dev_data.device = 0 ;
+
+ stat = cy_as_storage_query_device(bd->dev_handle,
+ &dev_data, 0, 0) ;
+ if (stat == CY_AS_ERROR_SUCCESS) {
+ cyasblkdev_add_disks(bus_num, bd,
+ total_media_count, devidx);
+ } else if (stat == CY_AS_ERROR_NO_SUCH_DEVICE) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: no device on bus %d\n",
+ __func__, bus_num) ;
+ #endif
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cannot query %d device "
+ "- reason code %d\n",
+ __func__, bus_num, stat) ;
+ #endif
+ goto out ;
+ }
+ } /* end for (bus_num = 0; bus_num <= 1; bus_num++)*/
+
+ return bd ;
+ }
+out:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: bd failed to initialize\n", __func__);
+ #endif
+
+ kfree(bd);
+ bd = ERR_PTR(-ret);
+ return bd;
+}
+
+
+/*init west bridge block device */
+static int cyasblkdev_blk_initialize(void)
+{
+ struct cyasblkdev_blk_data *bd;
+ int res;
+
+ DBGPRN_FUNC_NAME;
+
+ res = register_blkdev(major, "cyasblkdev");
+
+ if (res < 0) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(KERN_WARNING
+ "%s unable to get major %d for cyasblkdev media: %d\n",
+ __func__, major, res);
+ #endif
+ return res;
+ }
+
+ if (major == 0)
+ major = res;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s cyasblkdev registered with major number: %d\n",
+ __func__, major) ;
+ #endif
+
+ bd = cyasblkdev_blk_alloc();
+ if (IS_ERR(bd))
+ return PTR_ERR(bd);
+
+ return 0;
+}
+
+/* start block device */
+static int __init cyasblkdev_blk_init(void)
+{
+ int res = -ENOMEM;
+
+ DBGPRN_FUNC_NAME;
+
+ /* get the cyasdev handle for future use*/
+ cyas_dev_handle = cyasdevice_getdevhandle();
+
+ if (cyasblkdev_blk_initialize() == 0)
+ return 0;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("cyasblkdev init error:%d\n", res);
+ #endif
+ return res;
+}
+
+
+static void cyasblkdev_blk_deinit(struct cyasblkdev_blk_data *bd)
+{
+ DBGPRN_FUNC_NAME;
+
+ if (bd) {
+ int devidx;
+
+ if (bd->user_disk_0 != NULL) {
+ del_gendisk(bd->user_disk_0);
+ devidx = bd->user_disk_0->first_minor
+ >> CYASBLKDEV_SHIFT;
+ __clear_bit(devidx, dev_use);
+ }
+
+ if (bd->user_disk_1 != NULL) {
+ del_gendisk(bd->user_disk_1);
+ devidx = bd->user_disk_1->first_minor
+ >> CYASBLKDEV_SHIFT;
+ __clear_bit(devidx, dev_use);
+ }
+
+ if (bd->system_disk != NULL) {
+ del_gendisk(bd->system_disk);
+ devidx = bd->system_disk->first_minor
+ >> CYASBLKDEV_SHIFT;
+ __clear_bit(devidx, dev_use);
+ }
+
+ cyasblkdev_blk_put(bd);
+ }
+}
+
+/* block device exit */
+static void __exit cyasblkdev_blk_exit(void)
+{
+ DBGPRN_FUNC_NAME;
+
+ cyasblkdev_blk_deinit(gl_bd);
+ unregister_blkdev(major, "cyasblkdev");
+
+}
+
+module_init(cyasblkdev_blk_init);
+module_exit(cyasblkdev_blk_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("antioch (cyasblkdev) block device driver");
+MODULE_AUTHOR("cypress semiconductor");
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c b/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c
new file mode 100644
index 000000000000..8dc29bd2891d
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.c
@@ -0,0 +1,417 @@
+/* cyanblkdev_queue.h - Antioch Linux Block Driver queue source file
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor,
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * Request queue handling for Antioch block device driver.
+ * Based on the mmc queue handling code by Russell King in the
+ * linux 2.6.10 kernel.
+ */
+
+/*
+ * linux/drivers/mmc/mmc_queue.c
+ *
+ * Copyright (C) 2003 Russell King, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/blkdev.h>
+
+#include "cyasblkdev_queue.h"
+
+#define CYASBLKDEV_QUEUE_EXIT (1 << 0)
+#define CYASBLKDEV_QUEUE_SUSPENDED (1 << 1)
+#define CY_AS_USE_ASYNC_API
+
+
+
+/* print flags by name */
+const char *rq_flag_bit_names[] = {
+ "REQ_RW", /* not set, read. set, write */
+ "REQ_FAILFAST", /* no low level driver retries */
+ "REQ_SORTED", /* elevator knows about this request */
+ "REQ_SOFTBARRIER", /* may not be passed by ioscheduler */
+ "REQ_HARDBARRIER", /* may not be passed by drive either */
+ "REQ_FUA", /* forced unit access */
+ "REQ_NOMERGE", /* don't touch this for merging */
+ "REQ_STARTED", /* drive already may have started this one */
+ "REQ_DONTPREP", /* don't call prep for this one */
+ "REQ_QUEUED", /* uses queueing */
+ "REQ_ELVPRIV", /* elevator private data attached */
+ "REQ_FAILED", /* set if the request failed */
+ "REQ_QUIET", /* don't worry about errors */
+ "REQ_PREEMPT", /* set for "ide_preempt" requests */
+ "REQ_ORDERED_COLOR",/* is before or after barrier */
+ "REQ_RW_SYNC", /* request is sync (O_DIRECT) */
+ "REQ_ALLOCED", /* request came from our alloc pool */
+ "REQ_RW_META", /* metadata io request */
+ "REQ_COPY_USER", /* contains copies of user pages */
+ "REQ_NR_BITS", /* stops here */
+};
+
+void verbose_rq_flags(int flags)
+{
+ int i;
+ uint32_t j;
+ j = 1;
+ for (i = 0; i < 32; i++) {
+ if (flags & j)
+ DBGPRN("<1>%s", rq_flag_bit_names[i]);
+ j = j << 1;
+ }
+}
+
+
+/*
+ * Prepare a -BLK_DEV request. Essentially, this means passing the
+ * preparation off to the media driver. The media driver will
+ * create request to CyAsDev.
+ */
+static int cyasblkdev_prep_request(
+ struct request_queue *q, struct request *req)
+{
+ DBGPRN_FUNC_NAME;
+
+ /* we only like normal block requests.*/
+ if (!blk_fs_request(req)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s:%x bad request received\n",
+ __func__, current->pid) ;
+ #endif
+
+ blk_dump_rq_flags(req, "cyasblkdev bad request");
+ return BLKPREP_KILL;
+ }
+
+ req->cmd_flags |= REQ_DONTPREP;
+
+ return BLKPREP_OK;
+}
+
+/* queue worker thread */
+static int cyasblkdev_queue_thread(void *d)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ struct cyasblkdev_queue *bq = d;
+ struct request_queue *q = bq->queue;
+ u32 qth_pid;
+
+ DBGPRN_FUNC_NAME;
+
+ /*
+ * set iothread to ensure that we aren't put to sleep by
+ * the process freezing. we handle suspension ourselves.
+ */
+ daemonize("cyasblkdev_queue_thread");
+
+ /* signal to queue_init() so it could contnue */
+ complete(&bq->thread_complete);
+
+ down(&bq->thread_sem);
+ add_wait_queue(&bq->thread_wq, &wait);
+
+ qth_pid = current->pid;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s:%x started, bq:%p, q:%p\n", __func__, qth_pid, bq, q) ;
+ #endif
+
+ do {
+ struct request *req = NULL;
+
+ /* the thread wants to be woken up by signals as well */
+ set_current_state(TASK_INTERRUPTIBLE);
+
+ spin_lock_irq(q->queue_lock);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: for bq->queue is null\n", __func__);
+ #endif
+
+ if (!bq->req) {
+ /* chk if queue is plugged */
+ if (!blk_queue_plugged(q)) {
+ bq->req = req = blk_fetch_request(q);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: blk_fetch_request:%x\n",
+ __func__, (uint32_t)req);
+ #endif
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: queue plugged, "
+ "skip blk_fetch()\n", __func__);
+ #endif
+ }
+ }
+ spin_unlock_irq(q->queue_lock);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: checking if request queue is null\n", __func__);
+ #endif
+
+ if (!req) {
+ if (bq->flags & CYASBLKDEV_QUEUE_EXIT) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s:got QUEUE_EXIT flag\n", __func__);
+ #endif
+
+ break;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: request queue is null, goto sleep, "
+ "thread_sem->count=%d\n",
+ __func__, bq->thread_sem.count);
+ if (spin_is_locked(q->queue_lock)) {
+ cy_as_hal_print_message("%s: queue_lock "
+ "is locked, need to release\n", __func__);
+ spin_unlock(q->queue_lock);
+
+ if (spin_is_locked(q->queue_lock))
+ cy_as_hal_print_message(
+ "%s: unlock did not work\n",
+ __func__);
+ } else {
+ cy_as_hal_print_message(
+ "%s: checked lock, is not locked\n",
+ __func__);
+ }
+ #endif
+
+ up(&bq->thread_sem);
+
+ /* yields to the next rdytorun proc,
+ * then goes back to sleep*/
+ schedule();
+ down(&bq->thread_sem);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: wake_up,continue\n",
+ __func__);
+ #endif
+ continue;
+ }
+
+ /* new req recieved, issue it to the driver */
+ set_current_state(TASK_RUNNING);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: issued a RQ:%x\n",
+ __func__, (uint32_t)req);
+ #endif
+
+ bq->issue_fn(bq, req);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: bq->issue_fn() returned\n",
+ __func__);
+ #endif
+
+
+ } while (1);
+
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&bq->thread_wq, &wait);
+ up(&bq->thread_sem);
+
+ complete_and_exit(&bq->thread_complete, 0);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: is finished\n", __func__) ;
+ #endif
+
+ return 0;
+}
+
+/*
+ * Generic request handler. it is called for any queue on a
+ * particular host. When the host is not busy, we look for a request
+ * on any queue on this host, and attempt to issue it. This may
+ * not be the queue we were asked to process.
+ */
+static void cyasblkdev_request(struct request_queue *q)
+{
+ struct cyasblkdev_queue *bq = q->queuedata;
+ DBGPRN_FUNC_NAME;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s new request on cyasblkdev_queue_t bq:=%x\n",
+ __func__, (uint32_t)bq);
+ #endif
+
+ if (!bq->req) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s wake_up(&bq->thread_wq)\n",
+ __func__);
+ #endif
+
+ /* wake up cyasblkdev_queue worker thread*/
+ wake_up(&bq->thread_wq);
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: don't wake Q_thr, bq->req:%x\n",
+ __func__, (uint32_t)bq->req);
+ #endif
+ }
+}
+
+/*
+ * cyasblkdev_init_queue - initialise a queue structure.
+ * @bq: cyasblkdev queue
+ * @dev: CyAsDeviceHandle to attach this queue
+ * @lock: queue lock
+ *
+ * Initialise a cyasblkdev_request queue.
+ */
+
+/* MAX NUMBER OF SECTORS PER REQUEST **/
+#define Q_MAX_SECTORS 128
+
+/* MAX NUMBER OF PHYS SEGMENTS (entries in the SG list)*/
+#define Q_MAX_SGS 16
+
+int cyasblkdev_init_queue(struct cyasblkdev_queue *bq, spinlock_t *lock)
+{
+ int ret;
+
+ DBGPRN_FUNC_NAME;
+
+ /* 1st param is a function that wakes up the queue thread */
+ bq->queue = blk_init_queue(cyasblkdev_request, lock);
+ if (!bq->queue)
+ return -ENOMEM;
+
+ blk_queue_prep_rq(bq->queue, cyasblkdev_prep_request);
+
+ blk_queue_bounce_limit(bq->queue, BLK_BOUNCE_ANY);
+ blk_queue_max_hw_sectors(bq->queue, Q_MAX_SECTORS);
+
+ /* As of now, we have the HAL/driver support to
+ * merge scattered segments and handle them simultaneously.
+ * so, setting the max_phys_segments to 8. */
+ /*blk_queue_max_phys_segments(bq->queue, Q_MAX_SGS);
+ blk_queue_max_hw_segments(bq->queue, Q_MAX_SGS);*/
+ blk_queue_max_segments(bq->queue, Q_MAX_SGS);
+
+ /* should be < then HAL can handle */
+ blk_queue_max_segment_size(bq->queue, 512*Q_MAX_SECTORS);
+
+ bq->queue->queuedata = bq;
+ bq->req = NULL;
+
+ init_completion(&bq->thread_complete);
+ init_waitqueue_head(&bq->thread_wq);
+ init_MUTEX(&bq->thread_sem);
+
+ ret = kernel_thread(cyasblkdev_queue_thread, bq, CLONE_KERNEL);
+ if (ret >= 0) {
+ /* wait until the thread is spawned */
+ wait_for_completion(&bq->thread_complete);
+
+ /* reinitialize the completion */
+ init_completion(&bq->thread_complete);
+ ret = 0;
+ goto out;
+ }
+
+out:
+ return ret;
+}
+EXPORT_SYMBOL(cyasblkdev_init_queue);
+
+/*called from blk_put() */
+void cyasblkdev_cleanup_queue(struct cyasblkdev_queue *bq)
+{
+ DBGPRN_FUNC_NAME;
+
+ bq->flags |= CYASBLKDEV_QUEUE_EXIT;
+ wake_up(&bq->thread_wq);
+ wait_for_completion(&bq->thread_complete);
+
+ blk_cleanup_queue(bq->queue);
+}
+EXPORT_SYMBOL(cyasblkdev_cleanup_queue);
+
+
+/**
+ * cyasblkdev_queue_suspend - suspend a CyAsBlkDev request queue
+ * @bq: CyAsBlkDev queue to suspend
+ *
+ * Stop the block request queue, and wait for our thread to
+ * complete any outstanding requests. This ensures that we
+ * won't suspend while a request is being processed.
+ */
+void cyasblkdev_queue_suspend(struct cyasblkdev_queue *bq)
+{
+ struct request_queue *q = bq->queue;
+ unsigned long flags;
+
+ DBGPRN_FUNC_NAME;
+
+ if (!(bq->flags & CYASBLKDEV_QUEUE_SUSPENDED)) {
+ bq->flags |= CYASBLKDEV_QUEUE_SUSPENDED;
+
+ spin_lock_irqsave(q->queue_lock, flags);
+ blk_stop_queue(q);
+ spin_unlock_irqrestore(q->queue_lock, flags);
+
+ down(&bq->thread_sem);
+ }
+}
+EXPORT_SYMBOL(cyasblkdev_queue_suspend);
+
+/*cyasblkdev_queue_resume - resume a previously suspended
+ * CyAsBlkDev request queue @bq: CyAsBlkDev queue to resume */
+void cyasblkdev_queue_resume(struct cyasblkdev_queue *bq)
+{
+ struct request_queue *q = bq->queue;
+ unsigned long flags;
+
+ DBGPRN_FUNC_NAME;
+
+ if (bq->flags & CYASBLKDEV_QUEUE_SUSPENDED) {
+ bq->flags &= ~CYASBLKDEV_QUEUE_SUSPENDED;
+
+ up(&bq->thread_sem);
+
+ spin_lock_irqsave(q->queue_lock, flags);
+ blk_start_queue(q);
+ spin_unlock_irqrestore(q->queue_lock, flags);
+ }
+}
+EXPORT_SYMBOL(cyasblkdev_queue_resume);
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h b/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h
new file mode 100644
index 000000000000..26f9f596506d
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/block/cyasblkdev_queue.h
@@ -0,0 +1,64 @@
+/* cyanblkdev_queue.h - Antioch Linux Block Driver queue header file
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANBLKDEV_QUEUE_H_
+#define _INCLUDED_CYANBLKDEV_QUEUE_H_
+
+/*
+ * may contain various useful MACRO and debug printks
+ */
+
+/* moved to staging location, eventual implementation
+ * considered is here
+ * #include <linux/westbridge/cyashal.h>
+ * #include <linux/westbridge/cyastoria.h>
+ * */
+
+#include "../include/linux/westbridge/cyashal.h"
+#include "../include/linux/westbridge/cyastoria.h"
+
+struct request;
+struct task_struct;
+
+struct cyasblkdev_queue {
+ struct completion thread_complete;
+ wait_queue_head_t thread_wq;
+ struct semaphore thread_sem;
+ unsigned int flags;
+ struct request *req;
+ int (*prep_fn)(struct cyasblkdev_queue *, struct request *);
+ int (*issue_fn)(struct cyasblkdev_queue *, struct request *);
+ void *data;
+ struct request_queue *queue;
+};
+
+extern int cyasblkdev_init_queue(struct cyasblkdev_queue *, spinlock_t *);
+extern void cyasblkdev_cleanup_queue(struct cyasblkdev_queue *);
+extern void cyasblkdev_queue_suspend(struct cyasblkdev_queue *);
+extern void cyasblkdev_queue_resume(struct cyasblkdev_queue *);
+
+extern cy_as_device_handle cyasdevice_getdevhandle(void) ;
+#define MOD_LOGS 1
+void verbose_rq_flags(int flags);
+
+#endif /* _INCLUDED_CYANBLKDEV_QUEUE_H_ */
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/device/Kconfig b/drivers/staging/westbridge/astoria/device/Kconfig
new file mode 100644
index 000000000000..cc99658cf3a4
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/device/Kconfig
@@ -0,0 +1,9 @@
+#
+# West Bridge block driver configuration
+#
+
+config WESTBRIDGE_DEVICE_DRIVER
+ tristate "West Bridge Device Driver"
+ help
+ Include the West Bridge based device driver
+
diff --git a/drivers/staging/westbridge/astoria/device/Makefile b/drivers/staging/westbridge/astoria/device/Makefile
new file mode 100644
index 000000000000..7af8b5b0a8f5
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/device/Makefile
@@ -0,0 +1,23 @@
+#
+# Makefile for the kernel westbridge device driver
+#
+
+ifneq ($(CONFIG_WESTBRIDGE_DEBUG),y)
+ EXTRA_CFLAGS += -DWESTBRIDGE_NDEBUG
+endif
+
+obj-$(CONFIG_WESTBRIDGE_DEVICE_DRIVER) += cyasdev.o
+
+
+ifeq ($(CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL),y)
+#moved for staging compatbility
+#cyasdev-y := ../../../arch/arm/mach-omap2/cyashalomap_kernel.o cyasdevice.o
+cyasdev-y := ../arch/arm/mach-omap2/cyashalomap_kernel.o cyasdevice.o \
+ ../api/src/cyasdma.o ../api/src/cyasintr.o ../api/src/cyaslep2pep.o \
+ ../api/src/cyaslowlevel.o ../api/src/cyasmisc.o ../api/src/cyasmtp.o \
+ ../api/src/cyasstorage.o ../api/src/cyasusb.o
+
+else
+# should not get here, need to be built with some hal
+cyasdev-y := cyasdevice.o
+endif
diff --git a/drivers/staging/westbridge/astoria/device/cyandevice_export.h b/drivers/staging/westbridge/astoria/device/cyandevice_export.h
new file mode 100644
index 000000000000..fc9dee994f01
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/device/cyandevice_export.h
@@ -0,0 +1,132 @@
+/*
+## cyandevice_export.h - Linux Antioch device driver file
+##
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * Export Misc APIs that can be used from the other driver modules.
+ * The APIs to create a device handle and download firmware are not exported
+ * because they are expected to be used only by this kernel module.
+ */
+EXPORT_SYMBOL(cy_as_misc_get_firmware_version) ;
+EXPORT_SYMBOL(cy_as_misc_read_m_c_u_register) ;
+EXPORT_SYMBOL(cy_as_misc_reset) ;
+EXPORT_SYMBOL(cy_as_misc_acquire_resource) ;
+EXPORT_SYMBOL(cy_as_misc_release_resource) ;
+EXPORT_SYMBOL(cy_as_misc_enter_standby) ;
+EXPORT_SYMBOL(cy_as_misc_leave_standby) ;
+EXPORT_SYMBOL(cy_as_misc_enter_suspend) ;
+EXPORT_SYMBOL(cy_as_misc_leave_suspend) ;
+EXPORT_SYMBOL(cy_as_misc_storage_changed) ;
+EXPORT_SYMBOL(cy_as_misc_heart_beat_control) ;
+EXPORT_SYMBOL(cy_as_misc_get_gpio_value) ;
+EXPORT_SYMBOL(cy_as_misc_set_gpio_value) ;
+EXPORT_SYMBOL(cy_as_misc_set_low_speed_sd_freq) ;
+EXPORT_SYMBOL(cy_as_misc_set_high_speed_sd_freq) ;
+
+/*
+ * Export the USB APIs that can be used by the dependent kernel modules.
+ */
+EXPORT_SYMBOL(cy_as_usb_set_end_point_config) ;
+EXPORT_SYMBOL(cy_as_usb_read_data_async) ;
+EXPORT_SYMBOL(cy_as_usb_write_data_async) ;
+EXPORT_SYMBOL(cy_as_usb_cancel_async) ;
+EXPORT_SYMBOL(cy_as_usb_set_stall) ;
+EXPORT_SYMBOL(cy_as_usb_clear_stall) ;
+EXPORT_SYMBOL(cy_as_usb_connect) ;
+EXPORT_SYMBOL(cy_as_usb_disconnect) ;
+EXPORT_SYMBOL(cy_as_usb_start) ;
+EXPORT_SYMBOL(cy_as_usb_stop) ;
+EXPORT_SYMBOL(cy_as_usb_set_enum_config) ;
+EXPORT_SYMBOL(cy_as_usb_get_enum_config) ;
+EXPORT_SYMBOL(cy_as_usb_set_physical_configuration) ;
+EXPORT_SYMBOL(cy_as_usb_register_callback) ;
+EXPORT_SYMBOL(cy_as_usb_commit_config) ;
+EXPORT_SYMBOL(cy_as_usb_set_descriptor) ;
+EXPORT_SYMBOL(cy_as_usb_clear_descriptors) ;
+EXPORT_SYMBOL(cy_as_usb_get_descriptor) ;
+EXPORT_SYMBOL(cy_as_usb_get_end_point_config) ;
+EXPORT_SYMBOL(cy_as_usb_read_data) ;
+EXPORT_SYMBOL(cy_as_usb_write_data) ;
+EXPORT_SYMBOL(cy_as_usb_get_stall) ;
+EXPORT_SYMBOL(cy_as_usb_set_nak) ;
+EXPORT_SYMBOL(cy_as_usb_clear_nak) ;
+EXPORT_SYMBOL(cy_as_usb_get_nak) ;
+EXPORT_SYMBOL(cy_as_usb_signal_remote_wakeup) ;
+EXPORT_SYMBOL(cy_as_usb_set_m_s_report_threshold) ;
+EXPORT_SYMBOL(cy_as_usb_select_m_s_partitions) ;
+
+/*
+ * Export all Storage APIs that can be used by dependent kernel modules.
+ */
+EXPORT_SYMBOL(cy_as_storage_start) ;
+EXPORT_SYMBOL(cy_as_storage_stop) ;
+EXPORT_SYMBOL(cy_as_storage_register_callback) ;
+EXPORT_SYMBOL(cy_as_storage_query_bus) ;
+EXPORT_SYMBOL(cy_as_storage_query_media) ;
+EXPORT_SYMBOL(cy_as_storage_query_device) ;
+EXPORT_SYMBOL(cy_as_storage_query_unit) ;
+EXPORT_SYMBOL(cy_as_storage_device_control) ;
+EXPORT_SYMBOL(cy_as_storage_claim) ;
+EXPORT_SYMBOL(cy_as_storage_release) ;
+EXPORT_SYMBOL(cy_as_storage_read) ;
+EXPORT_SYMBOL(cy_as_storage_write) ;
+EXPORT_SYMBOL(cy_as_storage_read_async) ;
+EXPORT_SYMBOL(cy_as_storage_write_async) ;
+EXPORT_SYMBOL(cy_as_storage_cancel_async) ;
+EXPORT_SYMBOL(cy_as_storage_sd_register_read) ;
+EXPORT_SYMBOL(cy_as_storage_create_p_partition) ;
+EXPORT_SYMBOL(cy_as_storage_remove_p_partition) ;
+EXPORT_SYMBOL(cy_as_storage_get_transfer_amount) ;
+EXPORT_SYMBOL(cy_as_storage_erase) ;
+
+EXPORT_SYMBOL(cy_as_sdio_query_card);
+EXPORT_SYMBOL(cy_as_sdio_init_function);
+EXPORT_SYMBOL(cy_as_sdio_set_blocksize);
+EXPORT_SYMBOL(cy_as_sdio_direct_read);
+EXPORT_SYMBOL(cy_as_sdio_direct_write);
+EXPORT_SYMBOL(cy_as_sdio_extended_read);
+EXPORT_SYMBOL(cy_as_sdio_extended_write);
+
+EXPORT_SYMBOL(cy_as_hal_alloc) ;
+EXPORT_SYMBOL(cy_as_hal_free) ;
+EXPORT_SYMBOL(cy_as_hal_sleep) ;
+EXPORT_SYMBOL(cy_as_hal_create_sleep_channel) ;
+EXPORT_SYMBOL(cy_as_hal_destroy_sleep_channel) ;
+EXPORT_SYMBOL(cy_as_hal_sleep_on) ;
+EXPORT_SYMBOL(cy_as_hal_wake) ;
+EXPORT_SYMBOL(cy_as_hal_mem_set);
+
+EXPORT_SYMBOL(cy_as_mtp_storage_only_start);
+EXPORT_SYMBOL(cy_as_mtp_storage_only_stop);
+EXPORT_SYMBOL(cy_as_mtp_start);
+EXPORT_SYMBOL(cy_as_mtp_init_send_object);
+EXPORT_SYMBOL(cy_as_mtp_init_get_object);
+EXPORT_SYMBOL(cy_as_mtp_cancel_send_object);
+EXPORT_SYMBOL(cy_as_mtp_cancel_get_object);
+
+#ifdef __CY_ASTORIA_SCM_KERNEL_HAL__
+/* Functions in the SCM kernel HAL implementation only. */
+EXPORT_SYMBOL(cy_as_hal_enable_scatter_list) ;
+EXPORT_SYMBOL(cy_as_hal_disable_scatter_list) ;
+#endif
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/device/cyasdevice.c b/drivers/staging/westbridge/astoria/device/cyasdevice.c
new file mode 100644
index 000000000000..cd0f7cbc9b18
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/device/cyasdevice.c
@@ -0,0 +1,394 @@
+/*
+## cyandevice.c - Linux Antioch device driver file
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/sched.h>
+#include <linux/scatterlist.h>
+#include <linux/err.h>
+#include <linux/firmware.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+/* moved for staging location
+ * update/patch submission
+#include <linux/westbridge/cyastoria.h>
+#include <linux/westbridge/cyashal.h>
+#include <linux/westbridge/cyasregs.h>
+*/
+
+#include "../include/linux/westbridge/cyastoria.h"
+#include "../include/linux/westbridge/cyashal.h"
+#include "../include/linux/westbridge/cyasregs.h"
+
+/* API exports include file */
+#include "cyandevice_export.h"
+
+typedef struct cyasdevice {
+ /* Handle to the Antioch device */
+ cy_as_device_handle dev_handle;
+ /* Handle to the HAL */
+ cy_as_hal_device_tag hal_tag;
+} cyasdevice ;
+
+/* global ptr to astoria device */
+static cyasdevice *cy_as_device_controller ;
+int cy_as_device_init_done;
+const char *dev_handle_name = "cy_astoria_dev_handle" ;
+
+#ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+extern void cy_as_hal_config_c_s_mux(void);
+#endif
+
+static void cyasdevice_deinit(cyasdevice *cy_as_dev)
+{
+ cy_as_hal_print_message("<1>_cy_as_device deinitialize called\n") ;
+ if (!cy_as_dev) {
+ cy_as_hal_print_message("<1>_cy_as_device_deinit: "
+ "device handle %x is invalid\n", (uint32_t)cy_as_dev) ;
+ return ;
+ }
+
+ /* stop west_brige */
+ if (cy_as_dev->dev_handle) {
+ cy_as_hal_print_message("<1>_cy_as_device: "
+ "cy_as_misc_destroy_device called\n") ;
+ if (cy_as_misc_destroy_device(cy_as_dev->dev_handle) !=
+ CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message(
+ "<1>_cy_as_device: destroying failed\n");
+ }
+ }
+
+ if (cy_as_dev->hal_tag) {
+
+ #ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+ if (stop_o_m_a_p_kernel(dev_handle_name,
+ cy_as_dev->hal_tag) != 0)
+ cy_as_hal_print_message("<1>_cy_as_device: stopping "
+ "OMAP kernel HAL failed\n");
+
+ #endif
+ }
+ cy_as_hal_print_message("<1>_cy_as_device:HAL layer stopped\n") ;
+
+ kfree(cy_as_dev) ;
+ cy_as_device_controller = NULL ;
+ cy_as_hal_print_message("<1>_cy_as_device: deinitialized\n") ;
+}
+
+/*called from src/cyasmisc.c:MyMiscCallback() as a func
+ * pointer [dev_p->misc_event_cb] which was previously
+ * registered by CyAsLLRegisterRequestCallback(...,
+ * MyMiscCallback) ; called from CyAsMiscConfigureDevice()
+ * which is in turn called from cyasdevice_initialize() in
+ * this src
+ */
+static void cy_misc_callback(cy_as_device_handle h,
+ cy_as_misc_event_type evtype, void *evdata)
+{
+ (void)h ;
+ (void)evdata ;
+
+ switch (evtype) {
+ case cy_as_event_misc_initialized:
+ cy_as_hal_print_message("<1>_cy_as_device: "
+ "initialization done callback triggered\n") ;
+ cy_as_device_init_done = 1 ;
+ break ;
+
+ case cy_as_event_misc_awake:
+ cy_as_hal_print_message("<1>_cy_as_device: "
+ "cy_as_event_misc_awake event callback triggered\n") ;
+ cy_as_device_init_done = 1 ;
+ break ;
+ default:
+ break ;
+ }
+}
+
+/* reset astoria and reinit all regs */
+ #define PNAND_REG_CFG_INIT_VAL 0x0000
+void hal_reset(cy_as_hal_device_tag tag)
+{
+ cy_as_hal_print_message("<1> send soft hard rst: "
+ "MEM_RST_CTRL_REG_HARD...\n");
+ cy_as_hal_write_register(tag, CY_AS_MEM_RST_CTRL_REG,
+ CY_AS_MEM_RST_CTRL_REG_HARD) ;
+ mdelay(60);
+
+ cy_as_hal_print_message("<1> after RST: si_rev_REG:%x, "
+ "PNANDCFG_reg:%x\n",
+ cy_as_hal_read_register(tag, CY_AS_MEM_CM_WB_CFG_ID),
+ cy_as_hal_read_register(tag, CY_AS_MEM_PNAND_CFG)
+ );
+
+ /* set it to LBD */
+ cy_as_hal_write_register(tag, CY_AS_MEM_PNAND_CFG,
+ PNAND_REG_CFG_INIT_VAL) ;
+}
+EXPORT_SYMBOL(hal_reset);
+
+
+/* below structures and functions primarily
+ * implemented for firmware loading */
+static struct platform_device *westbridge_pd;
+
+static int __devinit wb_probe(struct platform_device *devptr)
+{
+ cy_as_hal_print_message("%s called\n", __func__);
+ return 0;
+}
+
+static int __devexit wb_remove(struct platform_device *devptr)
+{
+ cy_as_hal_print_message("%s called\n", __func__);
+ return 0;
+}
+
+static struct platform_driver west_bridge_driver = {
+ .probe = wb_probe,
+ .remove = __devexit_p(wb_remove),
+ .driver = {
+ .name = "west_bridge_dev"},
+};
+
+/* west bridge device driver main init */
+static int cyasdevice_initialize(void)
+{
+ cyasdevice *cy_as_dev = 0 ;
+ int ret = 0 ;
+ int retval = 0 ;
+ cy_as_device_config config ;
+ cy_as_hal_sleep_channel channel ;
+ cy_as_get_firmware_version_data ver_data = {0};
+ const char *str = "" ;
+ int spin_lim;
+ const struct firmware *fw_entry;
+
+ cy_as_device_init_done = 0;
+
+ cy_as_misc_set_log_level(8);
+
+ cy_as_hal_print_message("<1>_cy_as_device initialize called\n") ;
+
+ if (cy_as_device_controller != 0) {
+ cy_as_hal_print_message("<1>_cy_as_device: the device "
+ "has already been initilaized. ignoring\n") ;
+ return -EBUSY ;
+ }
+
+ /* cy_as_dev = CyAsHalAlloc (sizeof(cyasdevice), SLAB_KERNEL); */
+ cy_as_dev = cy_as_hal_alloc(sizeof(cyasdevice));
+ if (cy_as_dev == NULL) {
+ cy_as_hal_print_message("<1>_cy_as_device: "
+ "memmory allocation failed\n") ;
+ return -ENOMEM;
+ }
+ memset(cy_as_dev, 0, sizeof(cyasdevice));
+
+
+ /* Init the HAL & CyAsDeviceHandle */
+
+ #ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+ /* start OMAP HAL init instsnce */
+
+ if (!start_o_m_a_p_kernel(dev_handle_name,
+ &(cy_as_dev->hal_tag), cy_false)) {
+
+ cy_as_hal_print_message(
+ "<1>_cy_as_device: start OMAP34xx HAL failed\n") ;
+ goto done;
+ }
+ #endif
+
+ /* Now create the device */
+ if (cy_as_misc_create_device(&(cy_as_dev->dev_handle),
+ cy_as_dev->hal_tag) != CY_AS_ERROR_SUCCESS) {
+
+ cy_as_hal_print_message(
+ "<1>_cy_as_device: create device failed\n") ;
+ goto done ;
+ }
+
+ memset(&config, 0, sizeof(config));
+ config.dmaintr = cy_true;
+
+ ret = cy_as_misc_configure_device(cy_as_dev->dev_handle, &config) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+
+ cy_as_hal_print_message(
+ "<1>_cy_as_device: configure device "
+ "failed. reason code: %d\n", ret) ;
+ goto done;
+ }
+
+ ret = cy_as_misc_register_callback(cy_as_dev->dev_handle,
+ cy_misc_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("<1>_cy_as_device: "
+ "cy_as_misc_register_callback failed. "
+ "reason code: %d\n", ret) ;
+ goto done;
+ }
+
+ ret = platform_driver_register(&west_bridge_driver);
+ if (unlikely(ret < 0))
+ return ret;
+ westbridge_pd = platform_device_register_simple(
+ "west_bridge_dev", -1, NULL, 0);
+
+ if (IS_ERR(westbridge_pd)) {
+ platform_driver_unregister(&west_bridge_driver);
+ return PTR_ERR(westbridge_pd);
+ }
+ /* Load the firmware */
+ ret = request_firmware(&fw_entry,
+ "west bridge fw", &westbridge_pd->dev);
+ if (ret) {
+ cy_as_hal_print_message("cy_as_device: "
+ "request_firmware failed return val = %d\n", ret);
+ } else {
+ cy_as_hal_print_message("cy_as_device: "
+ "got the firmware %d size=0x%x\n", ret, fw_entry->size);
+
+ ret = cy_as_misc_download_firmware(
+ cy_as_dev->dev_handle,
+ fw_entry->data,
+ fw_entry->size ,
+ 0, 0) ;
+ }
+
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("<1>_cy_as_device: cannot download "
+ "firmware. reason code: %d\n", ret) ;
+ goto done;
+ }
+
+ /* spin until the device init is completed */
+ /* 50 -MAX wait time for the FW load & init
+ * to complete is 5sec*/
+ spin_lim = 50;
+
+ cy_as_hal_create_sleep_channel(&channel) ;
+ while (!cy_as_device_init_done) {
+
+ cy_as_hal_sleep_on(&channel, 100) ;
+
+ if (spin_lim-- <= 0) {
+ cy_as_hal_print_message(
+ "<1>\n_e_r_r_o_r!: "
+ "wait for FW init has timed out !!!");
+ break;
+ }
+ }
+ cy_as_hal_destroy_sleep_channel(&channel) ;
+
+ if (spin_lim > 0)
+ cy_as_hal_print_message(
+ "cy_as_device: astoria firmware is loaded\n") ;
+
+ ret = cy_as_misc_get_firmware_version(cy_as_dev->dev_handle,
+ &ver_data, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("<1>_cy_as_device: cannot get firmware "
+ "version. reason code: %d\n", ret) ;
+ goto done;
+ }
+
+ if ((ver_data.media_type & 0x01) && (ver_data.media_type & 0x06))
+ str = "nand and SD/MMC." ;
+ else if ((ver_data.media_type & 0x01) && (ver_data.media_type & 0x08))
+ str = "nand and CEATA." ;
+ else if (ver_data.media_type & 0x01)
+ str = "nand." ;
+ else if (ver_data.media_type & 0x08)
+ str = "CEATA." ;
+ else
+ str = "SD/MMC." ;
+
+ cy_as_hal_print_message("<1> cy_as_device:_firmware version: %s "
+ "major=%d minor=%d build=%d,\n_media types supported:%s\n",
+ ((ver_data.is_debug_mode) ? "debug" : "release"),
+ ver_data.major, ver_data.minor, ver_data.build, str) ;
+
+ /* done now */
+ cy_as_device_controller = cy_as_dev ;
+
+ return 0 ;
+
+done:
+ if (cy_as_dev)
+ cyasdevice_deinit(cy_as_dev) ;
+
+ return -EINVAL ;
+}
+
+cy_as_device_handle cyasdevice_getdevhandle(void)
+{
+ if (cy_as_device_controller) {
+ #ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+ cy_as_hal_config_c_s_mux();
+ #endif
+
+ return cy_as_device_controller->dev_handle ;
+ }
+ return NULL;
+}
+EXPORT_SYMBOL(cyasdevice_getdevhandle) ;
+
+cy_as_hal_device_tag cyasdevice_gethaltag(void)
+{
+ if (cy_as_device_controller)
+ return (cy_as_hal_device_tag)
+ cy_as_device_controller->hal_tag ;
+
+ return NULL;
+}
+EXPORT_SYMBOL(cyasdevice_gethaltag) ;
+
+
+/*init Westbridge device driver **/
+static int __init cyasdevice_init(void)
+{
+ if (cyasdevice_initialize() != 0)
+ return ENODEV;
+
+ return 0 ;
+}
+
+
+static void __exit cyasdevice_cleanup(void)
+{
+
+ cyasdevice_deinit(cy_as_device_controller) ;
+}
+
+
+MODULE_DESCRIPTION("west bridge device driver");
+MODULE_AUTHOR("cypress semiconductor");
+MODULE_LICENSE("GPL");
+
+module_init(cyasdevice_init);
+module_exit(cyasdevice_cleanup);
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/gadget/Kconfig b/drivers/staging/westbridge/astoria/gadget/Kconfig
new file mode 100644
index 000000000000..6fbdf2277b03
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/gadget/Kconfig
@@ -0,0 +1,9 @@
+#
+# West Bridge gadget driver configuration
+#
+
+config WESTBRIDGE_GADGET_DRIVER
+ tristate "West Bridge Gadget Driver"
+ help
+ Include the West Bridge based gadget peripheral controller driver
+
diff --git a/drivers/staging/westbridge/astoria/gadget/Makefile b/drivers/staging/westbridge/astoria/gadget/Makefile
new file mode 100644
index 000000000000..a5eef7ee60a4
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/gadget/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for the kernel westbridge hal
+#
+
+ifneq ($(CONFIG_WESTBRIDGE_DEBUG),y)
+ EXTRA_CFLAGS += -DWESTBRIDGE_NDEBUG
+endif
+
+obj-$(CONFIG_WESTBRIDGE_GADGET_DRIVER) += cyasgadgetctrl.o
+cyasgadgetctrl-y := cyasgadget.o
+
diff --git a/drivers/staging/westbridge/astoria/gadget/cyasgadget.c b/drivers/staging/westbridge/astoria/gadget/cyasgadget.c
new file mode 100644
index 000000000000..ced239dc3678
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/gadget/cyasgadget.c
@@ -0,0 +1,2211 @@
+/* cyangadget.c - Linux USB Gadget driver file for the Cypress West Bridge
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * Cypress West Bridge high/full speed usb device controller code
+ * Based on the Netchip 2280 device controller by David Brownell
+ * in the linux 2.6.10 kernel
+ *
+ * linux/drivers/usb/gadget/net2280.c
+ */
+
+/*
+ * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
+ * Copyright (C) 2003 David Brownell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330
+ * Boston, MA 02111-1307 USA
+ */
+
+#include "cyasgadget.h"
+
+#define CY_AS_DRIVER_DESC "cypress west bridge usb gadget"
+#define CY_AS_DRIVER_VERSION "REV B"
+#define DMA_ADDR_INVALID (~(dma_addr_t)0)
+
+static const char cy_as_driver_name[] = "cy_astoria_gadget";
+static const char cy_as_driver_desc[] = CY_AS_DRIVER_DESC;
+
+static const char cy_as_ep0name[] = "EP0";
+static const char *cy_as_ep_names[] = {
+ cy_as_ep0name, "EP1",
+ "EP2", "EP3", "EP4", "EP5", "EP6", "EP7", "EP8",
+ "EP9", "EP10", "EP11", "EP12", "EP13", "EP14", "EP15"
+};
+
+/* forward declarations */
+static void
+cyas_ep_reset(
+ struct cyasgadget_ep *an_ep) ;
+
+static int
+cyasgadget_fifo_status(
+ struct usb_ep *_ep) ;
+
+static void
+cyasgadget_stallcallback(
+ cy_as_device_handle h,
+ cy_as_return_status_t status,
+ uint32_t tag,
+ cy_as_funct_c_b_type cbtype,
+ void *cbdata);
+
+/* variables */
+static cyasgadget *cy_as_gadget_controller;
+
+static int append_mtp;
+module_param(append_mtp, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(append_mtp,
+ "west bridge to append descriptors for mtp 0=no 1=yes");
+
+static int msc_enum_bus_0;
+module_param(msc_enum_bus_0, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(msc_enum_bus_0,
+ "west bridge to enumerate bus 0 as msc 0=no 1=yes");
+
+static int msc_enum_bus_1;
+module_param(msc_enum_bus_1, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(msc_enum_bus_1,
+ "west bridge to enumerate bus 1 as msc 0=no 1=yes");
+
+/* all Callbacks are placed in this subsection*/
+static void cy_as_gadget_usb_event_callback(
+ cy_as_device_handle h,
+ cy_as_usb_event ev,
+ void *evdata
+ )
+{
+ cyasgadget *cy_as_dev ;
+ #ifndef WESTBRIDGE_NDEBUG
+ struct usb_ctrlrequest *ctrlreq;
+ #endif
+
+ /* cy_as_dev = container_of(h, cyasgadget, dev_handle); */
+ cy_as_dev = cy_as_gadget_controller ;
+ switch (ev) {
+ case cy_as_event_usb_suspend:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_suspend received\n") ;
+ #endif
+ cy_as_dev->driver->suspend(&cy_as_dev->gadget) ;
+ break;
+
+ case cy_as_event_usb_resume:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_resume received\n") ;
+ #endif
+ cy_as_dev->driver->resume(&cy_as_dev->gadget) ;
+ break;
+
+ case cy_as_event_usb_reset:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_reset received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_speed_change:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_speed_change received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_set_config:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_set_config received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_setup_packet:
+ #ifndef WESTBRIDGE_NDEBUG
+ ctrlreq = (struct usb_ctrlrequest *)evdata;
+
+ cy_as_hal_print_message("<1>_cy_as_event_usb_setup_packet "
+ "received"
+ "bRequestType=0x%x,"
+ "bRequest=0x%x,"
+ "wValue=x%x,"
+ "wIndex=0x%x,"
+ "wLength=0x%x,",
+ ctrlreq->bRequestType,
+ ctrlreq->bRequest,
+ ctrlreq->wValue,
+ ctrlreq->wIndex,
+ ctrlreq->wLength
+ ) ;
+ #endif
+ cy_as_dev->outsetupreq = 0;
+ if ((((uint8_t *)evdata)[0] & USB_DIR_IN) == USB_DIR_OUT)
+ cy_as_dev->outsetupreq = 1;
+ cy_as_dev->driver->setup(&cy_as_dev->gadget,
+ (struct usb_ctrlrequest *)evdata) ;
+ break;
+
+ case cy_as_event_usb_status_packet:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_status_packet received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_inquiry_before:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_inquiry_before received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_inquiry_after:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_inquiry_after received\n") ;
+ #endif
+ break;
+
+ case cy_as_event_usb_start_stop:
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<1>_cy_as_event_usb_start_stop received\n") ;
+ #endif
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void cy_as_gadget_mtp_event_callback(
+ cy_as_device_handle handle,
+ cy_as_mtp_event evtype,
+ void *evdata
+ )
+{
+
+ cyasgadget *dev = cy_as_gadget_controller ;
+ (void) handle;
+
+ switch (evtype) {
+ case cy_as_mtp_send_object_complete:
+ {
+ cy_as_mtp_send_object_complete_data *send_obj_data =
+ (cy_as_mtp_send_object_complete_data *) evdata ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<6>MTP EVENT: send_object_complete\n");
+ cy_as_hal_print_message(
+ "<6>_bytes sent = %d\n_send status = %d",
+ send_obj_data->byte_count,
+ send_obj_data->status);
+ #endif
+
+ dev->tmtp_send_complete_data.byte_count =
+ send_obj_data->byte_count;
+ dev->tmtp_send_complete_data.status =
+ send_obj_data->status;
+ dev->tmtp_send_complete_data.transaction_id =
+ send_obj_data->transaction_id ;
+ dev->tmtp_send_complete = cy_true ;
+ break;
+ }
+ case cy_as_mtp_get_object_complete:
+ {
+ cy_as_mtp_get_object_complete_data *get_obj_data =
+ (cy_as_mtp_get_object_complete_data *) evdata ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<6>MTP EVENT: get_object_complete\n");
+ cy_as_hal_print_message(
+ "<6>_bytes got = %d\n_get status = %d",
+ get_obj_data->byte_count, get_obj_data->status);
+ #endif
+
+ dev->tmtp_get_complete_data.byte_count =
+ get_obj_data->byte_count;
+ dev->tmtp_get_complete_data.status =
+ get_obj_data->status ;
+ dev->tmtp_get_complete = cy_true ;
+ break;
+ }
+ case cy_as_mtp_block_table_needed:
+ {
+ dev->tmtp_need_new_blk_tbl = cy_true ;
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<6>MTP EVENT: cy_as_mtp_block_table_needed\n");
+ #endif
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+static void
+cyasgadget_setupreadcallback(
+ cy_as_device_handle h,
+ cy_as_end_point_number_t ep,
+ uint32_t count,
+ void *buf,
+ cy_as_return_status_t status)
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget_req *an_req;
+ cyasgadget *cy_as_dev ;
+ unsigned stopped ;
+ unsigned long flags;
+ (void)buf ;
+
+ cy_as_dev = cy_as_gadget_controller ;
+ if (cy_as_dev->driver == NULL)
+ return;
+
+ an_ep = &cy_as_dev->an_gadget_ep[ep] ;
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+ stopped = an_ep->stopped ;
+
+#ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: ep=%d, count=%d, "
+ "status=%d\n", __func__, ep, count, status) ;
+#endif
+
+ an_req = list_entry(an_ep->queue.next,
+ cyasgadget_req, queue) ;
+ list_del_init(&an_req->queue) ;
+
+ if (status == CY_AS_ERROR_SUCCESS)
+ an_req->req.status = 0;
+ else
+ an_req->req.status = -status;
+ an_req->req.actual = count ;
+ an_ep->stopped = 1;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ an_req->req.complete(&an_ep->usb_ep_inst, &an_req->req);
+
+ an_ep->stopped = stopped;
+
+}
+/*called when the write of a setup packet has been completed*/
+static void cyasgadget_setupwritecallback(
+ cy_as_device_handle h,
+ cy_as_end_point_number_t ep,
+ uint32_t count,
+ void *buf,
+ cy_as_return_status_t status
+ )
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget_req *an_req;
+ cyasgadget *cy_as_dev ;
+ unsigned stopped ;
+ unsigned long flags;
+
+ (void)buf ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called status=0x%x\n",
+ __func__, status);
+ #endif
+
+ cy_as_dev = cy_as_gadget_controller ;
+
+ if (cy_as_dev->driver == NULL)
+ return;
+
+ an_ep = &cy_as_dev->an_gadget_ep[ep] ;
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+
+ stopped = an_ep->stopped ;
+
+#ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("setup_write_callback: ep=%d, "
+ "count=%d, status=%d\n", ep, count, status) ;
+#endif
+
+ an_req = list_entry(an_ep->queue.next, cyasgadget_req, queue) ;
+ list_del_init(&an_req->queue) ;
+
+ an_req->req.actual = count ;
+ an_req->req.status = 0 ;
+ an_ep->stopped = 1;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ an_req->req.complete(&an_ep->usb_ep_inst, &an_req->req);
+
+ an_ep->stopped = stopped;
+
+}
+
+/* called when a read operation has completed.*/
+static void cyasgadget_readcallback(
+ cy_as_device_handle h,
+ cy_as_end_point_number_t ep,
+ uint32_t count,
+ void *buf,
+ cy_as_return_status_t status
+ )
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget_req *an_req;
+ cyasgadget *cy_as_dev ;
+ unsigned stopped ;
+ cy_as_return_status_t ret ;
+ unsigned long flags;
+
+ (void)h ;
+ (void)buf ;
+
+ cy_as_dev = cy_as_gadget_controller ;
+
+ if (cy_as_dev->driver == NULL)
+ return;
+
+ an_ep = &cy_as_dev->an_gadget_ep[ep] ;
+ stopped = an_ep->stopped ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: ep=%d, count=%d, status=%d\n",
+ __func__, ep, count, status) ;
+ #endif
+
+ if (status == CY_AS_ERROR_CANCELED)
+ return ;
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+
+ an_req = list_entry(an_ep->queue.next, cyasgadget_req, queue) ;
+ list_del_init(&an_req->queue) ;
+
+ if (status == CY_AS_ERROR_SUCCESS)
+ an_req->req.status = 0 ;
+ else
+ an_req->req.status = -status ;
+
+ an_req->complete = 1;
+ an_req->req.actual = count ;
+ an_ep->stopped = 1;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+ an_req->req.complete(&an_ep->usb_ep_inst, &an_req->req);
+
+ an_ep->stopped = stopped;
+
+ /* We need to call ReadAsync on this end-point
+ * again, so as to not miss any data packets. */
+ if (!an_ep->stopped) {
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+ an_req = 0 ;
+ if (!list_empty(&an_ep->queue))
+ an_req = list_entry(an_ep->queue.next,
+ cyasgadget_req, queue) ;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ if ((an_req) && (an_req->req.status == -EINPROGRESS)) {
+ ret = cy_as_usb_read_data_async(cy_as_dev->dev_handle,
+ an_ep->num, cy_false, an_req->req.length,
+ an_req->req.buf, cyasgadget_readcallback);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_read_data_async failed "
+ "with error code %d\n", ret) ;
+ else
+ an_req->req.status = -EALREADY ;
+ }
+ }
+}
+
+/* function is called when a usb write operation has completed*/
+static void cyasgadget_writecallback(
+ cy_as_device_handle h,
+ cy_as_end_point_number_t ep,
+ uint32_t count,
+ void *buf,
+ cy_as_return_status_t status
+ )
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget_req *an_req;
+ cyasgadget *cy_as_dev ;
+ unsigned stopped = 0;
+ cy_as_return_status_t ret ;
+ unsigned long flags;
+
+ (void)h ;
+ (void)buf ;
+
+ cy_as_dev = cy_as_gadget_controller ;
+ if (cy_as_dev->driver == NULL)
+ return;
+
+ an_ep = &cy_as_dev->an_gadget_ep[ep] ;
+
+ if (status == CY_AS_ERROR_CANCELED)
+ return ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: ep=%d, count=%d, status=%d\n",
+ __func__, ep, count, status) ;
+ #endif
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+
+ an_req = list_entry(an_ep->queue.next, cyasgadget_req, queue) ;
+ list_del_init(&an_req->queue) ;
+ an_req->req.actual = count ;
+
+ /* Verify the status value before setting req.status to zero */
+ if (status == CY_AS_ERROR_SUCCESS)
+ an_req->req.status = 0 ;
+ else
+ an_req->req.status = -status ;
+
+ an_ep->stopped = 1;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ an_req->req.complete(&an_ep->usb_ep_inst, &an_req->req);
+ an_ep->stopped = stopped;
+
+ /* We need to call WriteAsync on this end-point again, so as to not
+ miss any data packets. */
+ if (!an_ep->stopped) {
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+ an_req = 0 ;
+ if (!list_empty(&an_ep->queue))
+ an_req = list_entry(an_ep->queue.next,
+ cyasgadget_req, queue) ;
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ if ((an_req) && (an_req->req.status == -EINPROGRESS)) {
+ ret = cy_as_usb_write_data_async(cy_as_dev->dev_handle,
+ an_ep->num, an_req->req.length, an_req->req.buf,
+ cy_false, cyasgadget_writecallback);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async "
+ "failed with error code %d\n", ret) ;
+ else
+ an_req->req.status = -EALREADY ;
+ }
+ }
+}
+
+static void cyasgadget_stallcallback(
+ cy_as_device_handle h,
+ cy_as_return_status_t status,
+ uint32_t tag,
+ cy_as_funct_c_b_type cbtype,
+ void *cbdata
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ if (status != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_set/_clear stall "
+ "failed with status %d\n", status) ;
+ #endif
+}
+
+
+/*******************************************************************/
+/* All usb_ep_ops (cyasgadget_ep_ops) are placed in this subsection*/
+/*******************************************************************/
+static int cyasgadget_enable(
+ struct usb_ep *_ep,
+ const struct usb_endpoint_descriptor *desc
+ )
+{
+ cyasgadget *an_dev;
+ cyasgadget_ep *an_ep;
+ u32 max, tmp;
+ unsigned long flags;
+
+ an_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+ if (!_ep || !desc || an_ep->desc || _ep->name == cy_as_ep0name
+ || desc->bDescriptorType != USB_DT_ENDPOINT)
+ return -EINVAL;
+
+ an_dev = an_ep->dev;
+ if (!an_dev->driver || an_dev->gadget.speed == USB_SPEED_UNKNOWN)
+ return -ESHUTDOWN;
+
+ max = le16_to_cpu(desc->wMaxPacketSize) & 0x1fff;
+
+ spin_lock_irqsave(&an_dev->lock, flags);
+ _ep->maxpacket = max & 0x7ff;
+ an_ep->desc = desc;
+
+ /* ep_reset() has already been called */
+ an_ep->stopped = 0;
+ an_ep->out_overflow = 0;
+
+ if (an_ep->cyepconfig.enabled != cy_true) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on enabled\n", an_ep->usb_ep_inst.name) ;
+ #endif
+ return -EINVAL;
+ }
+
+ tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
+ an_ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
+
+ spin_unlock_irqrestore(&an_dev->lock, flags);
+
+ switch (tmp) {
+ case USB_ENDPOINT_XFER_ISOC:
+ if (an_ep->cyepconfig.type != cy_as_usb_iso) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on type %d %d\n", an_ep->usb_ep_inst.name,
+ an_ep->cyepconfig.type, cy_as_usb_iso) ;
+ #endif
+ return -EINVAL;
+ }
+ break;
+ case USB_ENDPOINT_XFER_INT:
+ if (an_ep->cyepconfig.type != cy_as_usb_int) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on type %d %d\n", an_ep->usb_ep_inst.name,
+ an_ep->cyepconfig.type, cy_as_usb_int) ;
+ #endif
+ return -EINVAL;
+ }
+ break;
+ default:
+ if (an_ep->cyepconfig.type != cy_as_usb_bulk) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on type %d %d\n", an_ep->usb_ep_inst.name,
+ an_ep->cyepconfig.type, cy_as_usb_bulk) ;
+ #endif
+ return -EINVAL;
+ }
+ break;
+ }
+
+ tmp = desc->bEndpointAddress;
+ an_ep->is_in = (tmp & USB_DIR_IN) != 0;
+
+ if ((an_ep->cyepconfig.dir == cy_as_usb_in) &&
+ (!an_ep->is_in)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on dir %d %d\n", an_ep->usb_ep_inst.name,
+ an_ep->cyepconfig.dir, cy_as_usb_in) ;
+ #endif
+ return -EINVAL;
+ } else if ((an_ep->cyepconfig.dir == cy_as_usb_out) &&
+ (an_ep->is_in)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_end_point_config EP %s mismatch "
+ "on dir %d %d\n", an_ep->usb_ep_inst.name,
+ an_ep->cyepconfig.dir, cy_as_usb_out) ;
+ #endif
+ return -EINVAL;
+ }
+
+ cy_as_usb_clear_stall(an_dev->dev_handle, an_ep->num,
+ cyasgadget_stallcallback, 0);
+
+ cy_as_hal_print_message("%s enabled %s (ep%d-%d) max %04x\n",
+ __func__, _ep->name, an_ep->num, tmp, max);
+
+ return 0;
+}
+
+static int cyasgadget_disable(
+ struct usb_ep *_ep
+ )
+{
+ cyasgadget_ep *an_ep;
+ unsigned long flags;
+
+ an_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+ if (!_ep || !an_ep->desc || _ep->name == cy_as_ep0name)
+ return -EINVAL;
+
+ spin_lock_irqsave(&an_ep->dev->lock, flags);
+ cyas_ep_reset(an_ep);
+
+ spin_unlock_irqrestore(&an_ep->dev->lock, flags);
+ return 0;
+}
+
+static struct usb_request *cyasgadget_alloc_request(
+ struct usb_ep *_ep, gfp_t gfp_flags
+ )
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget_req *an_req;
+
+ if (!_ep)
+ return NULL;
+
+ an_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+
+ an_req = kzalloc(sizeof(cyasgadget_req), gfp_flags);
+ if (!an_req)
+ return NULL;
+
+ an_req->req.dma = DMA_ADDR_INVALID;
+ INIT_LIST_HEAD(&an_req->queue);
+
+ return &an_req->req;
+}
+
+static void cyasgadget_free_request(
+ struct usb_ep *_ep,
+ struct usb_request *_req
+ )
+{
+ cyasgadget_req *an_req ;
+
+ if (!_ep || !_req)
+ return ;
+
+ an_req = container_of(_req, cyasgadget_req, req) ;
+
+ kfree(an_req);
+}
+
+/* Load a packet into the fifo we use for usb IN transfers.
+ * works for all endpoints. */
+static int cyasgadget_queue(
+ struct usb_ep *_ep,
+ struct usb_request *_req,
+ gfp_t gfp_flags
+ )
+{
+ cyasgadget_req *as_req;
+ cyasgadget_ep *as_ep;
+ cyasgadget *cy_as_dev;
+ unsigned long flags;
+ cy_as_return_status_t ret = 0;
+
+ as_req = container_of(_req, cyasgadget_req, req);
+ if (!_req || !_req->complete || !_req->buf
+ || !list_empty(&as_req->queue))
+ return -EINVAL;
+
+ as_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+
+ if (!_ep || (!as_ep->desc && (as_ep->num != 0)))
+ return -EINVAL;
+
+ cy_as_dev = as_ep->dev;
+ if (!cy_as_dev->driver ||
+ cy_as_dev->gadget.speed == USB_SPEED_UNKNOWN)
+ return -ESHUTDOWN;
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+
+ _req->status = -EINPROGRESS;
+ _req->actual = 0;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ /* Call Async functions */
+ if (as_ep->is_in) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async being called "
+ "on ep %d\n", as_ep->num) ;
+ #endif
+
+ ret = cy_as_usb_write_data_async(cy_as_dev->dev_handle,
+ as_ep->num, _req->length, _req->buf,
+ cy_false, cyasgadget_writecallback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async failed with "
+ "error code %d\n", ret) ;
+ else
+ _req->status = -EALREADY ;
+ } else if (as_ep->num == 0) {
+ /*
+ ret = cy_as_usb_write_data_async(cy_as_dev->dev_handle,
+ as_ep->num, _req->length, _req->buf, cy_false,
+ cyasgadget_setupwritecallback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async failed with error "
+ "code %d\n", ret) ;
+ */
+ if ((cy_as_dev->outsetupreq) && (_req->length)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_read_data_async "
+ "being called on ep %d\n",
+ as_ep->num) ;
+ #endif
+
+ ret = cy_as_usb_read_data_async (
+ cy_as_dev->dev_handle, as_ep->num,
+ cy_true, _req->length, _req->buf,
+ cyasgadget_setupreadcallback);
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_read_data_async failed with "
+ "error code %d\n", ret) ;
+
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async "
+ "being called on ep %d\n",
+ as_ep->num) ;
+ #endif
+
+ ret = cy_as_usb_write_data_async(cy_as_dev->dev_handle,
+ as_ep->num, _req->length, _req->buf, cy_false,
+ cyasgadget_setupwritecallback) ;
+
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_write_data_async failed with "
+ "error code %d\n", ret) ;
+ }
+
+ } else if (list_empty(&as_ep->queue)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_read_data_async being called since "
+ "ep queue empty%d\n", ret) ;
+ #endif
+
+ ret = cy_as_usb_read_data_async(cy_as_dev->dev_handle,
+ as_ep->num, cy_false, _req->length, _req->buf,
+ cyasgadget_readcallback) ;
+ if (ret != CY_AS_ERROR_SUCCESS)
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_read_data_async failed with error "
+ "code %d\n", ret) ;
+ else
+ _req->status = -EALREADY ;
+ }
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+
+ if (as_req)
+ list_add_tail(&as_req->queue, &as_ep->queue);
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ return 0;
+}
+
+/* dequeue request */
+static int cyasgadget_dequeue(
+ struct usb_ep *_ep,
+ struct usb_request *_req
+ )
+{
+ cyasgadget_ep *an_ep;
+ cyasgadget *dev;
+ an_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+ dev = an_ep->dev ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ cy_as_usb_cancel_async(dev->dev_handle, an_ep->num);
+
+ return 0;
+}
+
+static int cyasgadget_set_halt(
+ struct usb_ep *_ep,
+ int value
+ )
+{
+ cyasgadget_ep *an_ep;
+ int retval = 0;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ an_ep = container_of(_ep, cyasgadget_ep, usb_ep_inst);
+ if (!_ep || (!an_ep->desc && an_ep->num != 0))
+ return -EINVAL;
+
+ if (!an_ep->dev->driver || an_ep->dev->gadget.speed ==
+ USB_SPEED_UNKNOWN)
+ return -ESHUTDOWN;
+
+ if (an_ep->desc /* not ep0 */ &&
+ (an_ep->desc->bmAttributes & 0x03) == USB_ENDPOINT_XFER_ISOC)
+ return -EINVAL;
+
+ if (!list_empty(&an_ep->queue))
+ retval = -EAGAIN;
+ else if (an_ep->is_in && value &&
+ cyasgadget_fifo_status(_ep) != 0)
+ retval = -EAGAIN;
+ else {
+ if (value) {
+ cy_as_usb_set_stall(an_ep->dev->dev_handle,
+ an_ep->num, cyasgadget_stallcallback, 0) ;
+ } else {
+ cy_as_usb_clear_stall(an_ep->dev->dev_handle,
+ an_ep->num, cyasgadget_stallcallback, 0) ;
+ }
+ }
+
+ return retval;
+}
+
+static int cyasgadget_fifo_status(
+ struct usb_ep *_ep
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ return 0 ;
+}
+
+static void cyasgadget_fifo_flush(
+ struct usb_ep *_ep
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+}
+
+static struct usb_ep_ops cyasgadget_ep_ops = {
+ .enable = cyasgadget_enable,
+ .disable = cyasgadget_disable,
+ .alloc_request = cyasgadget_alloc_request,
+ .free_request = cyasgadget_free_request,
+ .queue = cyasgadget_queue,
+ .dequeue = cyasgadget_dequeue,
+ .set_halt = cyasgadget_set_halt,
+ .fifo_status = cyasgadget_fifo_status,
+ .fifo_flush = cyasgadget_fifo_flush,
+};
+
+/*************************************************************/
+/*This subsection contains all usb_gadget_ops cyasgadget_ops */
+/*************************************************************/
+static int cyasgadget_get_frame(
+ struct usb_gadget *_gadget
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+ return 0 ;
+}
+
+static int cyasgadget_wakeup(
+ struct usb_gadget *_gadget
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+ return 0;
+}
+
+static int cyasgadget_set_selfpowered(
+ struct usb_gadget *_gadget,
+ int value
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+ return 0;
+}
+
+static int cyasgadget_pullup(
+ struct usb_gadget *_gadget,
+ int is_on
+ )
+{
+ struct cyasgadget *cy_as_dev ;
+ unsigned long flags;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ if (!_gadget)
+ return -ENODEV;
+
+ cy_as_dev = container_of(_gadget, cyasgadget, gadget);
+
+ spin_lock_irqsave(&cy_as_dev->lock, flags);
+ cy_as_dev->softconnect = (is_on != 0);
+ if (is_on)
+ cy_as_usb_connect(cy_as_dev->dev_handle, 0, 0) ;
+ else
+ cy_as_usb_disconnect(cy_as_dev->dev_handle, 0, 0) ;
+
+ spin_unlock_irqrestore(&cy_as_dev->lock, flags);
+
+ return 0;
+}
+
+static int cyasgadget_ioctl(
+ struct usb_gadget *_gadget,
+ unsigned code,
+ unsigned long param
+ )
+{
+ int err = 0;
+ int retval = 0;
+ int ret_stat = 0;
+ cyasgadget *dev = cy_as_gadget_controller ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called, code=%d, param=%ld\n",
+ __func__, code, param);
+ #endif
+ /*
+ * extract the type and number bitfields, and don't decode
+ * wrong cmds: return ENOTTY (inappropriate ioctl) before access_ok()
+ */
+ if (_IOC_TYPE(code) != CYASGADGET_IOC_MAGIC) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s, bad magic number = 0x%x\n",
+ __func__, _IOC_TYPE(code));
+ #endif
+ return -ENOTTY;
+ }
+
+ if (_IOC_NR(code) > CYASGADGET_IOC_MAXNR) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s, bad ioctl code = 0x%x\n",
+ __func__, _IOC_NR(code));
+ #endif
+ return -ENOTTY;
+ }
+
+ /*
+ * the direction is a bitmask, and VERIFY_WRITE catches R/W
+ * transfers. `Type' is user-oriented, while
+ * access_ok is kernel-oriented, so the concept of "read" and
+ * "write" is reversed
+ */
+ if (_IOC_DIR(code) & _IOC_READ)
+ err = !access_ok(VERIFY_WRITE,
+ (void __user *)param, _IOC_SIZE(code));
+ else if (_IOC_DIR(code) & _IOC_WRITE)
+ err = !access_ok(VERIFY_READ,
+ (void __user *)param, _IOC_SIZE(code));
+
+ if (err) {
+ cy_as_hal_print_message("%s, bad ioctl dir = 0x%x\n",
+ __func__, _IOC_DIR(code));
+ return -EFAULT;
+ }
+
+ switch (code) {
+ case CYASGADGET_GETMTPSTATUS:
+ {
+ cy_as_gadget_ioctl_tmtp_status *usr_d =
+ (cy_as_gadget_ioctl_tmtp_status *)param ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: got CYASGADGET_GETMTPSTATUS\n",
+ __func__);
+ #endif
+
+ retval = __put_user(dev->tmtp_send_complete,
+ (uint32_t __user *)(&(usr_d->tmtp_send_complete)));
+ retval = __put_user(dev->tmtp_get_complete,
+ (uint32_t __user *)(&(usr_d->tmtp_get_complete)));
+ retval = __put_user(dev->tmtp_need_new_blk_tbl,
+ (uint32_t __user *)(&(usr_d->tmtp_need_new_blk_tbl)));
+
+ if (copy_to_user((&(usr_d->tmtp_send_complete_data)),
+ (&(dev->tmtp_send_complete_data)),
+ sizeof(cy_as_gadget_ioctl_send_object)))
+ return -EFAULT;
+
+ if (copy_to_user((&(usr_d->tmtp_get_complete_data)),
+ (&(dev->tmtp_get_complete_data)),
+ sizeof(cy_as_gadget_ioctl_get_object)))
+ return -EFAULT;
+ break;
+ }
+ case CYASGADGET_CLEARTMTPSTATUS:
+ {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s got CYASGADGET_CLEARTMTPSTATUS\n",
+ __func__);
+ #endif
+
+ dev->tmtp_send_complete = 0 ;
+ dev->tmtp_get_complete = 0 ;
+ dev->tmtp_need_new_blk_tbl = 0 ;
+
+ break;
+ }
+ case CYASGADGET_INITSOJ:
+ {
+ cy_as_gadget_ioctl_i_s_o_j_d k_d ;
+ cy_as_gadget_ioctl_i_s_o_j_d *usr_d =
+ (cy_as_gadget_ioctl_i_s_o_j_d *)param ;
+ cy_as_mtp_block_table blk_table ;
+ struct scatterlist sg ;
+ char *alloc_filename;
+ struct file *file_to_allocate;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s got CYASGADGET_INITSOJ\n",
+ __func__);
+ #endif
+
+ memset(&blk_table, 0, sizeof(blk_table));
+
+ /* Get user argument structure */
+ if (copy_from_user(&k_d, usr_d,
+ sizeof(cy_as_gadget_ioctl_i_s_o_j_d)))
+ return -EFAULT;
+
+ /* better use fixed size buff*/
+ alloc_filename = kmalloc(k_d.name_length + 1, GFP_KERNEL);
+
+ /* get the filename */
+ if (copy_from_user(alloc_filename, k_d.file_name,
+ k_d.name_length + 1)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: CYASGADGET_INITSOJ, "
+ "copy file name from user space failed\n",
+ __func__);
+ #endif
+ return -EFAULT;
+ }
+
+ file_to_allocate = filp_open(alloc_filename, O_RDWR, 0);
+
+ if ((int)file_to_allocate != 0xfffffffe) {
+
+ struct address_space *mapping =
+ file_to_allocate->f_mapping;
+ const struct address_space_operations *a_ops =
+ mapping->a_ops;
+ struct inode *inode = mapping->host;
+ struct inode *alloc_inode =
+ file_to_allocate->f_path.dentry->d_inode;
+ int cluster = 0;
+ uint32_t num_clusters = 0;
+ struct buffer_head bh;
+ struct kstat stat;
+ struct iattr alloc_iattr;
+ int nr_pages = 0;
+ int ret_stat = 0;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: fhandle is OK, "
+ "calling vfs_getattr\n", __func__);
+ #endif
+
+ ret_stat = vfs_getattr(file_to_allocate->f_path.mnt,
+ file_to_allocate->f_path.dentry, &stat);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: returned from "
+ "vfs_getattr() stat->blksize=0x%lx\n",
+ __func__, stat.blksize);
+ #endif
+
+ /* TODO: get this from disk properties
+ * (from blockdevice)*/
+ #define SECTOR_SIZE 512
+ if (stat.blksize != 0) {
+ num_clusters = (k_d.num_bytes) / SECTOR_SIZE;
+
+ if (((k_d.num_bytes) % SECTOR_SIZE) != 0)
+ num_clusters++;
+ } else {
+ goto initsoj_safe_exit;
+ }
+
+ bh.b_state = 0;
+ bh.b_blocknr = 0;
+ /* block size is arbitrary , we'll use sector size*/
+ bh.b_size = SECTOR_SIZE ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: getting fat blocks %d "
+ "size of %d\n", __func__,
+ num_clusters, bh.b_size);
+ #endif
+ for (cluster = 0; cluster < num_clusters; cluster++) {
+ ret_stat = fat_get_block(inode,
+ cluster, &bh, 1);
+ if (ret_stat) {
+ cy_as_hal_print_message(
+ "%s: unable to get fat block, "
+ "ret_stat=0x%d\n",
+ __func__, ret_stat);
+ goto initsoj_safe_exit;
+ }
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: allocated clusters "
+ "successfully (fat_get_block), check bmap..."
+ "\n", __func__);
+ #endif
+
+ alloc_iattr.ia_valid = ATTR_SIZE;
+ alloc_iattr.ia_size = k_d.num_bytes;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: calling fat_notify_change "
+ "(ia_valid:%d, ia_size:%d)\n", __func__,
+ alloc_iattr.ia_valid,
+ (int)alloc_iattr.ia_size);
+ #endif
+
+ /* adjust the filesize */
+ ret_stat = alloc_inode->i_op->setattr(
+ file_to_allocate->f_path.dentry, &alloc_iattr);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: fat_setattr() "
+ "returned 0x%x\n",
+ __func__, ret_stat);
+ #endif
+
+ /* clear dirty pages in page cache
+ * (if were any allocated) */
+ nr_pages = (k_d.num_bytes) / (PAGE_CACHE_SIZE);
+
+ if (((k_d.num_bytes) % (PAGE_CACHE_SIZE)) != 0)
+ nr_pages++;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ /*check out how many pages where actually allocated */
+ if (mapping->nrpages != nr_pages)
+ cy_as_hal_print_message("%s mpage_cleardirty "
+ "mapping->nrpages %d != num_pages %d\n",
+ __func__, (int) mapping->nrpages,
+ nr_pages);
+
+ cy_as_hal_print_message("%s: calling "
+ "mpage_cleardirty() "
+ "for %d pages\n", __func__, nr_pages);
+ #endif
+
+ ret_stat = mpage_cleardirty(mapping, nr_pages);
+
+ /*fill up the the block table from the addr mapping */
+ if (a_ops->bmap) {
+ int8_t blk_table_idx = -1;
+ uint32_t file_block_idx = 0;
+ uint32_t last_blk_addr_map = 0,
+ curr_blk_addr_map = 0;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ if (alloc_inode->i_bytes == 0)
+ cy_as_hal_print_message(
+ "%s: alloc_inode->ibytes =0\n",
+ __func__);
+ #endif
+
+ /* iterate through the list of
+ * blocks (not clusters)*/
+ for (file_block_idx = 0;
+ file_block_idx < num_clusters
+ /*inode->i_bytes*/; file_block_idx++) {
+
+ /* returns starting sector number */
+ curr_blk_addr_map =
+ a_ops->bmap(mapping,
+ file_block_idx);
+
+ /*no valid mapping*/
+ if (curr_blk_addr_map == 0) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s:hit invalid "
+ "mapping\n", __func__);
+ #endif
+ break;
+ } else if (curr_blk_addr_map !=
+ (last_blk_addr_map + 1) ||
+ (blk_table.num_blocks
+ [blk_table_idx] == 65535)) {
+
+ /* next table entry */
+ blk_table_idx++;
+ /* starting sector of a
+ * scattered cluster*/
+ blk_table.start_blocks
+ [blk_table_idx] =
+ curr_blk_addr_map;
+ /* ++ num of blocks in cur
+ * table entry*/
+ blk_table.
+ num_blocks[blk_table_idx]++;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ if (file_block_idx != 0)
+ cy_as_hal_print_message(
+ "<*> next table "
+ "entry:%d required\n",
+ blk_table_idx);
+ #endif
+ } else {
+ /*add contiguous block*/
+ blk_table.num_blocks
+ [blk_table_idx]++;
+ } /*if (curr_blk_addr_map == 0)*/
+
+ last_blk_addr_map = curr_blk_addr_map;
+ } /* end for (file_block_idx = 0; file_block_idx
+ < inode->i_bytes;) */
+
+ #ifndef WESTBRIDGE_NDEBUG
+ /*print result for verification*/
+ {
+ int i;
+ cy_as_hal_print_message(
+ "%s: print block table "
+ "mapping:\n",
+ __func__);
+ for (i = 0; i <= blk_table_idx; i++) {
+ cy_as_hal_print_message(
+ "<1> %d 0x%x 0x%x\n", i,
+ blk_table.start_blocks[i],
+ blk_table.num_blocks[i]);
+ }
+ }
+ #endif
+
+ /* copy the block table to user
+ * space (for debug purposes) */
+ retval = __put_user(
+ blk_table.start_blocks[blk_table_idx],
+ (uint32_t __user *)
+ (&(usr_d->blk_addr_p)));
+
+ retval = __put_user(
+ blk_table.num_blocks[blk_table_idx],
+ (uint32_t __user *)
+ (&(usr_d->blk_count_p)));
+
+ blk_table_idx++;
+ retval = __put_user(blk_table_idx,
+ (uint32_t __user *)
+ (&(usr_d->item_count)));
+
+ } /*end if (a_ops->bmap)*/
+
+ filp_close(file_to_allocate, NULL);
+
+ dev->tmtp_send_complete = 0 ;
+ dev->tmtp_need_new_blk_tbl = 0 ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: calling cy_as_mtp_init_send_object()\n",
+ __func__);
+ #endif
+ sg_init_one(&sg, &blk_table, sizeof(blk_table));
+ ret_stat = cy_as_mtp_init_send_object(dev->dev_handle,
+ (cy_as_mtp_block_table *)&sg,
+ k_d.num_bytes, 0, 0);
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: returned from "
+ "cy_as_mtp_init_send_object()\n", __func__);
+ #endif
+
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message(
+ "%s: failed to allocate the file %s\n",
+ __func__, alloc_filename);
+ } /* end if (file_to_allocate)*/
+ #endif
+initsoj_safe_exit:
+ ret_stat = 0;
+ retval = __put_user(ret_stat,
+ (uint32_t __user *)(&(usr_d->ret_val)));
+
+ break;
+ }
+ case CYASGADGET_INITGOJ:
+ {
+ cy_as_gadget_ioctl_i_g_o_j_d k_d ;
+ cy_as_gadget_ioctl_i_g_o_j_d *usr_d =
+ (cy_as_gadget_ioctl_i_g_o_j_d *)param ;
+ cy_as_mtp_block_table blk_table ;
+ struct scatterlist sg ;
+ char *map_filename;
+ struct file *file_to_map;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: got CYASGADGET_INITGOJ\n",
+ __func__);
+ #endif
+
+ memset(&blk_table, 0, sizeof(blk_table));
+
+ /* Get user argument sturcutre */
+ if (copy_from_user(&k_d, usr_d,
+ sizeof(cy_as_gadget_ioctl_i_g_o_j_d)))
+ return -EFAULT;
+
+ map_filename = kmalloc(k_d.name_length + 1, GFP_KERNEL);
+ if (copy_from_user(map_filename, k_d.file_name,
+ k_d.name_length + 1)) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: copy file name from "
+ "user space failed\n", __func__);
+ #endif
+ return -EFAULT;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<*>%s: opening %s for kernel "
+ "mode access map\n", __func__, map_filename);
+ #endif
+ file_to_map = filp_open(map_filename, O_RDWR, 0);
+ if (file_to_map) {
+ struct address_space *mapping = file_to_map->f_mapping;
+ const struct address_space_operations
+ *a_ops = mapping->a_ops;
+ struct inode *inode = mapping->host;
+
+ int8_t blk_table_idx = -1;
+ uint32_t file_block_idx = 0;
+ uint32_t last_blk_addr_map = 0, curr_blk_addr_map = 0;
+
+ /*verify operation exists*/
+ if (a_ops->bmap) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<*>%s: bmap found, i_bytes=0x%x, "
+ "i_size=0x%x, i_blocks=0x%x\n",
+ __func__, inode->i_bytes,
+ (unsigned int) inode->i_size,
+ (unsigned int) inode->i_blocks);
+ #endif
+
+ k_d.num_bytes = inode->i_size;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "<*>%s: k_d.num_bytes=0x%x\n",
+ __func__, k_d.num_bytes);
+ #endif
+
+ for (file_block_idx = 0;
+ file_block_idx < inode->i_size;
+ file_block_idx++) {
+ curr_blk_addr_map =
+ a_ops->bmap(mapping,
+ file_block_idx);
+
+ if (curr_blk_addr_map == 0) {
+ /*no valid mapping*/
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: no valid "
+ "mapping\n", __func__);
+ #endif
+ break;
+ } else if (curr_blk_addr_map !=
+ (last_blk_addr_map + 1)) {
+ /*non-contiguous break*/
+ blk_table_idx++;
+ blk_table.start_blocks
+ [blk_table_idx] =
+ curr_blk_addr_map;
+ blk_table.num_blocks
+ [blk_table_idx]++;
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: found non-"
+ "contiguous break",
+ __func__);
+ #endif
+ } else {
+ /*add contiguous block*/
+ blk_table.num_blocks
+ [blk_table_idx]++;
+ }
+ last_blk_addr_map = curr_blk_addr_map;
+ }
+
+ /*print result for verification*/
+ #ifndef WESTBRIDGE_NDEBUG
+ {
+ int i = 0;
+
+ for (i = 0 ; i <= blk_table_idx; i++) {
+ cy_as_hal_print_message(
+ "%s %d 0x%x 0x%x\n",
+ __func__, i,
+ blk_table.start_blocks[i],
+ blk_table.num_blocks[i]);
+ }
+ }
+ #endif
+ } else {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: could not find "
+ "a_ops->bmap\n", __func__);
+ #endif
+ return -EFAULT;
+ }
+
+ filp_close(file_to_map, NULL);
+
+ dev->tmtp_get_complete = 0 ;
+ dev->tmtp_need_new_blk_tbl = 0 ;
+
+ ret_stat = __put_user(
+ blk_table.start_blocks[blk_table_idx],
+ (uint32_t __user *)(&(usr_d->blk_addr_p)));
+
+ ret_stat = __put_user(
+ blk_table.num_blocks[blk_table_idx],
+ (uint32_t __user *)(&(usr_d->blk_count_p)));
+
+ sg_init_one(&sg, &blk_table, sizeof(blk_table));
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: calling cy_as_mtp_init_get_object() "
+ "start=0x%x, num =0x%x, tid=0x%x, "
+ "num_bytes=0x%x\n",
+ __func__,
+ blk_table.start_blocks[0],
+ blk_table.num_blocks[0],
+ k_d.tid,
+ k_d.num_bytes);
+ #endif
+
+ ret_stat = cy_as_mtp_init_get_object(
+ dev->dev_handle,
+ (cy_as_mtp_block_table *)&sg,
+ k_d.num_bytes, k_d.tid, 0, 0);
+ if (ret_stat != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: cy_as_mtp_init_get_object "
+ "failed ret_stat=0x%x\n",
+ __func__, ret_stat);
+ #endif
+ }
+ }
+ #ifndef WESTBRIDGE_NDEBUG
+ else {
+ cy_as_hal_print_message(
+ "%s: failed to open file %s\n",
+ __func__, map_filename);
+ }
+ #endif
+
+ ret_stat = 0;
+ retval = __put_user(ret_stat, (uint32_t __user *)
+ (&(usr_d->ret_val)));
+ break;
+ }
+ case CYASGADGET_CANCELSOJ:
+ {
+ cy_as_gadget_ioctl_cancel *usr_d =
+ (cy_as_gadget_ioctl_cancel *)param ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message(
+ "%s: got CYASGADGET_CANCELSOJ\n",
+ __func__);
+ #endif
+
+ ret_stat = cy_as_mtp_cancel_send_object(dev->dev_handle, 0, 0);
+
+ retval = __put_user(ret_stat, (uint32_t __user *)
+ (&(usr_d->ret_val)));
+ break;
+ }
+ case CYASGADGET_CANCELGOJ:
+ {
+ cy_as_gadget_ioctl_cancel *usr_d =
+ (cy_as_gadget_ioctl_cancel *)param ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: got CYASGADGET_CANCELGOJ\n",
+ __func__);
+ #endif
+
+ ret_stat = cy_as_mtp_cancel_get_object(dev->dev_handle, 0, 0);
+
+ retval = __put_user(ret_stat,
+ (uint32_t __user *)(&(usr_d->ret_val)));
+ break;
+ }
+ default:
+ {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: unknown ioctl received: %d\n",
+ __func__, code);
+
+ cy_as_hal_print_message("%s: known codes:\n"
+ "CYASGADGET_GETMTPSTATUS=%d\n"
+ "CYASGADGET_CLEARTMTPSTATUS=%d\n"
+ "CYASGADGET_INITSOJ=%d\n"
+ "CYASGADGET_INITGOJ=%d\n"
+ "CYASGADGET_CANCELSOJ=%d\n"
+ "CYASGADGET_CANCELGOJ=%d\n",
+ __func__,
+ CYASGADGET_GETMTPSTATUS,
+ CYASGADGET_CLEARTMTPSTATUS,
+ CYASGADGET_INITSOJ,
+ CYASGADGET_INITGOJ,
+ CYASGADGET_CANCELSOJ,
+ CYASGADGET_CANCELGOJ);
+ #endif
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static const struct usb_gadget_ops cyasgadget_ops = {
+ .get_frame = cyasgadget_get_frame,
+ .wakeup = cyasgadget_wakeup,
+ .set_selfpowered = cyasgadget_set_selfpowered,
+ .pullup = cyasgadget_pullup,
+ .ioctl = cyasgadget_ioctl,
+};
+
+
+/* keeping it simple:
+ * - one bus driver, initted first;
+ * - one function driver, initted second
+ *
+ * most of the work to support multiple controllers would
+ * be to associate this gadget driver with all of them, or
+ * perhaps to bind specific drivers to specific devices.
+ */
+
+static void cyas_ep_reset(
+ cyasgadget_ep *an_ep
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ an_ep->desc = NULL;
+ INIT_LIST_HEAD(&an_ep->queue);
+
+ an_ep->stopped = 0 ;
+ an_ep->is_in = 0 ;
+ an_ep->is_iso = 0 ;
+ an_ep->usb_ep_inst.maxpacket = ~0;
+ an_ep->usb_ep_inst.ops = &cyasgadget_ep_ops;
+}
+
+static void cyas_usb_reset(
+ cyasgadget *cy_as_dev
+ )
+{
+ cy_as_return_status_t ret;
+ cy_as_usb_enum_control config ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_device *dev_p = (cy_as_device *)cy_as_dev->dev_handle ;
+
+ cy_as_hal_print_message("<1>%s called mtp_firmware=0x%x\n",
+ __func__, dev_p->is_mtp_firmware);
+ #endif
+
+ ret = cy_as_misc_release_resource(cy_as_dev->dev_handle,
+ cy_as_bus_u_s_b) ;
+ if (ret != CY_AS_ERROR_SUCCESS && ret !=
+ CY_AS_ERROR_RESOURCE_NOT_OWNED) {
+ cy_as_hal_print_message("<1>_cy_as_gadget: cannot "
+ "release usb resource: failed with error code %d\n",
+ ret) ;
+ return ;
+ }
+
+ cy_as_dev->gadget.speed = USB_SPEED_HIGH ;
+
+ ret = cy_as_usb_start(cy_as_dev->dev_handle, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_start failed with error code %d\n",
+ ret) ;
+ return ;
+ }
+ /* P port will do enumeration, not West Bridge */
+ config.antioch_enumeration = cy_false ;
+ /* 1 2 : 1-BUS_NUM , 2:Storage_device number, SD - is bus 1*/
+
+ /* TODO: add module param to enumerate mass storage */
+ config.mass_storage_interface = 0 ;
+
+ if (append_mtp) {
+ ret = cy_as_mtp_start(cy_as_dev->dev_handle,
+ cy_as_gadget_mtp_event_callback, 0, 0);
+ if (ret == CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("MTP start passed, enumerating "
+ "MTP interface\n");
+ config.mtp_interface = append_mtp ;
+ /*Do not enumerate NAND storage*/
+ config.devices_to_enumerate[0][0] = cy_false;
+
+ /*enumerate SD storage as MTP*/
+ config.devices_to_enumerate[1][0] = cy_true;
+ }
+ } else {
+ cy_as_hal_print_message("MTP start not attempted, not "
+ "enumerating MTP interface\n");
+ config.mtp_interface = 0 ;
+ /* enumerate mass storage based on module parameters */
+ config.devices_to_enumerate[0][0] = msc_enum_bus_0;
+ config.devices_to_enumerate[1][0] = msc_enum_bus_1;
+ }
+
+ ret = cy_as_usb_set_enum_config(cy_as_dev->dev_handle,
+ &config, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("<1>_cy_as_gadget: "
+ "cy_as_usb_set_enum_config failed with error "
+ "code %d\n", ret) ;
+ return ;
+ }
+
+ cy_as_usb_set_physical_configuration(cy_as_dev->dev_handle, 1);
+
+}
+
+static void cyas_usb_reinit(
+ cyasgadget *cy_as_dev
+ )
+{
+ int index = 0;
+ cyasgadget_ep *an_ep_p;
+ cy_as_return_status_t ret;
+ cy_as_device *dev_p = (cy_as_device *)cy_as_dev->dev_handle ;
+
+ INIT_LIST_HEAD(&cy_as_dev->gadget.ep_list);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called, is_mtp_firmware = "
+ "0x%x\n", __func__, dev_p->is_mtp_firmware);
+ #endif
+
+ /* Init the end points */
+ for (index = 1; index <= 15; index++) {
+ an_ep_p = &cy_as_dev->an_gadget_ep[index] ;
+ cyas_ep_reset(an_ep_p) ;
+ an_ep_p->usb_ep_inst.name = cy_as_ep_names[index] ;
+ an_ep_p->dev = cy_as_dev ;
+ an_ep_p->num = index ;
+ memset(&an_ep_p->cyepconfig, 0, sizeof(an_ep_p->cyepconfig));
+
+ /* EP0, EPs 2,4,6,8 need not be added */
+ if ((index <= 8) && (index % 2 == 0) &&
+ (!dev_p->is_mtp_firmware)) {
+ /* EP0 is 64 and EPs 2,4,6,8 not allowed */
+ cy_as_dev->an_gadget_ep[index].fifo_size = 0 ;
+ } else {
+ if (index == 1)
+ an_ep_p->fifo_size = 64;
+ else
+ an_ep_p->fifo_size = 512 ;
+ list_add_tail(&an_ep_p->usb_ep_inst.ep_list,
+ &cy_as_dev->gadget.ep_list);
+ }
+ }
+ /* need to setendpointconfig before usb connect, this is not
+ * quite compatible with gadget methodology (ep_enable called
+ * by gadget after connect), therefore need to set config in
+ * initialization and verify compatibility in ep_enable,
+ * kick up error otherwise*/
+ an_ep_p = &cy_as_dev->an_gadget_ep[3] ;
+ an_ep_p->cyepconfig.enabled = cy_true ;
+ an_ep_p->cyepconfig.dir = cy_as_usb_out ;
+ an_ep_p->cyepconfig.type = cy_as_usb_bulk ;
+ an_ep_p->cyepconfig.size = 0 ;
+ an_ep_p->cyepconfig.physical = 1 ;
+ ret = cy_as_usb_set_end_point_config(an_ep_p->dev->dev_handle,
+ 3, &an_ep_p->cyepconfig) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("cy_as_usb_set_end_point_config "
+ "failed with error code %d\n", ret) ;
+ }
+
+ cy_as_usb_set_stall(an_ep_p->dev->dev_handle, 3, 0, 0);
+
+ an_ep_p = &cy_as_dev->an_gadget_ep[5] ;
+ an_ep_p->cyepconfig.enabled = cy_true ;
+ an_ep_p->cyepconfig.dir = cy_as_usb_in ;
+ an_ep_p->cyepconfig.type = cy_as_usb_bulk ;
+ an_ep_p->cyepconfig.size = 0 ;
+ an_ep_p->cyepconfig.physical = 2 ;
+ ret = cy_as_usb_set_end_point_config(an_ep_p->dev->dev_handle,
+ 5, &an_ep_p->cyepconfig) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("cy_as_usb_set_end_point_config "
+ "failed with error code %d\n", ret) ;
+ }
+
+ cy_as_usb_set_stall(an_ep_p->dev->dev_handle, 5, 0, 0);
+
+ an_ep_p = &cy_as_dev->an_gadget_ep[9] ;
+ an_ep_p->cyepconfig.enabled = cy_true ;
+ an_ep_p->cyepconfig.dir = cy_as_usb_in ;
+ an_ep_p->cyepconfig.type = cy_as_usb_bulk ;
+ an_ep_p->cyepconfig.size = 0 ;
+ an_ep_p->cyepconfig.physical = 4 ;
+ ret = cy_as_usb_set_end_point_config(an_ep_p->dev->dev_handle,
+ 9, &an_ep_p->cyepconfig) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ cy_as_hal_print_message("cy_as_usb_set_end_point_config "
+ "failed with error code %d\n", ret) ;
+ }
+
+ cy_as_usb_set_stall(an_ep_p->dev->dev_handle, 9, 0, 0);
+
+ if (dev_p->mtp_count != 0) {
+ /* these need to be set for compatibility with
+ * the gadget_enable logic */
+ an_ep_p = &cy_as_dev->an_gadget_ep[2] ;
+ an_ep_p->cyepconfig.enabled = cy_true ;
+ an_ep_p->cyepconfig.dir = cy_as_usb_out ;
+ an_ep_p->cyepconfig.type = cy_as_usb_bulk ;
+ an_ep_p->cyepconfig.size = 0 ;
+ an_ep_p->cyepconfig.physical = 0 ;
+ cy_as_usb_set_stall(an_ep_p->dev->dev_handle, 2, 0, 0);
+
+ an_ep_p = &cy_as_dev->an_gadget_ep[6] ;
+ an_ep_p->cyepconfig.enabled = cy_true ;
+ an_ep_p->cyepconfig.dir = cy_as_usb_in ;
+ an_ep_p->cyepconfig.type = cy_as_usb_bulk ;
+ an_ep_p->cyepconfig.size = 0 ;
+ an_ep_p->cyepconfig.physical = 0 ;
+ cy_as_usb_set_stall(an_ep_p->dev->dev_handle, 6, 0, 0);
+ }
+
+ cyas_ep_reset(&cy_as_dev->an_gadget_ep[0]) ;
+ cy_as_dev->an_gadget_ep[0].usb_ep_inst.name = cy_as_ep_names[0] ;
+ cy_as_dev->an_gadget_ep[0].dev = cy_as_dev ;
+ cy_as_dev->an_gadget_ep[0].num = 0 ;
+ cy_as_dev->an_gadget_ep[0].fifo_size = 64 ;
+
+ cy_as_dev->an_gadget_ep[0].usb_ep_inst.maxpacket = 64;
+ cy_as_dev->gadget.ep0 = &cy_as_dev->an_gadget_ep[0].usb_ep_inst;
+ cy_as_dev->an_gadget_ep[0].stopped = 0;
+ INIT_LIST_HEAD(&cy_as_dev->gadget.ep0->ep_list);
+}
+
+static void cyas_ep0_start(
+ cyasgadget *dev
+ )
+{
+ cy_as_return_status_t ret ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ ret = cy_as_usb_register_callback(dev->dev_handle,
+ cy_as_gadget_usb_event_callback) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_usb_register_callback "
+ "failed with error code %d\n", __func__, ret) ;
+ #endif
+ return ;
+ }
+
+ ret = cy_as_usb_commit_config(dev->dev_handle, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_usb_commit_config "
+ "failed with error code %d\n", __func__, ret) ;
+ #endif
+ return ;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_usb_commit_config "
+ "message sent\n", __func__) ;
+ #endif
+
+ ret = cy_as_usb_connect(dev->dev_handle, 0, 0) ;
+ if (ret != CY_AS_ERROR_SUCCESS) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_usb_connect failed "
+ "with error code %d\n", __func__, ret) ;
+ #endif
+ return ;
+ }
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s: cy_as_usb_connect message "
+ "sent\n", __func__) ;
+ #endif
+}
+
+/*
+ * When a driver is successfully registered, it will receive
+ * control requests including set_configuration(), which enables
+ * non-control requests. then usb traffic follows until a
+ * disconnect is reported. then a host may connect again, or
+ * the driver might get unbound.
+ */
+int usb_gadget_register_driver(
+ struct usb_gadget_driver *driver
+ )
+{
+ cyasgadget *dev = cy_as_gadget_controller ;
+ int retval;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called driver=0x%x\n",
+ __func__, (unsigned int) driver);
+ #endif
+
+ /* insist on high speed support from the driver, since
+ * "must not be used in normal operation"
+ */
+ if (!driver
+ || !driver->bind
+ || !driver->unbind
+ || !driver->setup)
+ return -EINVAL;
+
+ if (!dev)
+ return -ENODEV;
+
+ if (dev->driver)
+ return -EBUSY;
+
+ /* hook up the driver ... */
+ dev->softconnect = 1;
+ driver->driver.bus = NULL;
+ dev->driver = driver;
+ dev->gadget.dev.driver = &driver->driver;
+
+ /* Do the needful */
+ cyas_usb_reset(dev) ; /* External usb */
+ cyas_usb_reinit(dev) ; /* Internal */
+
+ retval = driver->bind(&dev->gadget);
+ if (retval) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("%s bind to driver %s --> %d\n",
+ __func__, driver->driver.name, retval);
+ #endif
+
+ dev->driver = NULL;
+ dev->gadget.dev.driver = NULL;
+ return retval;
+ }
+
+ /* ... then enable host detection and ep0; and we're ready
+ * for set_configuration as well as eventual disconnect.
+ */
+ cyas_ep0_start(dev);
+
+ return 0;
+}
+EXPORT_SYMBOL(usb_gadget_register_driver);
+
+static void cyasgadget_nuke(
+ cyasgadget_ep *an_ep
+ )
+{
+ cyasgadget *dev = cy_as_gadget_controller ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ cy_as_usb_cancel_async(dev->dev_handle, an_ep->num);
+ an_ep->stopped = 1 ;
+
+ while (!list_empty(&an_ep->queue)) {
+ cyasgadget_req *an_req = list_entry
+ (an_ep->queue.next, cyasgadget_req, queue) ;
+ list_del_init(&an_req->queue) ;
+ an_req->req.status = -ESHUTDOWN ;
+ an_req->req.complete(&an_ep->usb_ep_inst, &an_req->req) ;
+ }
+}
+
+static void cyasgadget_stop_activity(
+ cyasgadget *dev,
+ struct usb_gadget_driver *driver
+ )
+{
+ int index ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ /* don't disconnect if it's not connected */
+ if (dev->gadget.speed == USB_SPEED_UNKNOWN)
+ driver = NULL;
+
+ if (spin_is_locked(&dev->lock))
+ spin_unlock(&dev->lock);
+
+ /* Stop hardware; prevent new request submissions;
+ * and kill any outstanding requests.
+ */
+ cy_as_usb_disconnect(dev->dev_handle, 0, 0) ;
+
+ for (index = 3; index <= 7; index += 2) {
+ cyasgadget_ep *an_ep_p = &dev->an_gadget_ep[index] ;
+ cyasgadget_nuke(an_ep_p) ;
+ }
+
+ for (index = 9; index <= 15; index++) {
+ cyasgadget_ep *an_ep_p = &dev->an_gadget_ep[index] ;
+ cyasgadget_nuke(an_ep_p) ;
+ }
+
+ /* report disconnect; the driver is already quiesced */
+ if (driver)
+ driver->disconnect(&dev->gadget);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("cy_as_usb_disconnect returned success");
+ #endif
+
+ /* Stop Usb */
+ cy_as_usb_stop(dev->dev_handle, 0, 0) ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("cy_as_usb_stop returned success");
+ #endif
+}
+
+int usb_gadget_unregister_driver(
+ struct usb_gadget_driver *driver
+ )
+{
+ cyasgadget *dev = cy_as_gadget_controller ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ if (!dev)
+ return -ENODEV;
+
+ if (!driver || driver != dev->driver)
+ return -EINVAL;
+
+ cyasgadget_stop_activity(dev, driver);
+
+ driver->unbind(&dev->gadget);
+ dev->gadget.dev.driver = NULL;
+ dev->driver = NULL;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("unregistered driver '%s'\n",
+ driver->driver.name) ;
+ #endif
+
+ return 0;
+}
+EXPORT_SYMBOL(usb_gadget_unregister_driver);
+
+static void cyas_gadget_release(
+ struct device *_dev
+ )
+{
+ cyasgadget *dev = dev_get_drvdata(_dev);
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>%s called\n", __func__);
+ #endif
+
+ kfree(dev);
+}
+
+/* DeInitialize gadget driver */
+static void cyasgadget_deinit(
+ cyasgadget *cy_as_dev
+ )
+{
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget deinitialize called\n") ;
+ #endif
+
+ if (!cy_as_dev) {
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget_deinit: "
+ "invalid cyasgadget device\n") ;
+ #endif
+ return ;
+ }
+
+ if (cy_as_dev->driver) {
+ /* should have been done already by driver model core */
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1> cy_as_gadget: '%s' "
+ "is still registered\n",
+ cy_as_dev->driver->driver.name);
+ #endif
+ usb_gadget_unregister_driver(cy_as_dev->driver);
+ }
+
+ kfree(cy_as_dev) ;
+ cy_as_gadget_controller = NULL ;
+}
+
+/* Initialize gadget driver */
+static int cyasgadget_initialize(void)
+{
+ cyasgadget *cy_as_dev = 0 ;
+ int retval = 0 ;
+
+ #ifndef WESTBRIDGE_NDEBUG
+ cy_as_hal_print_message("<1>_cy_as_gadget [V1.1] initialize called\n") ;
+ #endif
+
+ if (cy_as_gadget_controller != 0) {
+ cy_as_hal_print_message("<1> cy_as_gadget: the device has "
+ "already been initilaized. ignoring\n") ;
+ return -EBUSY ;
+ }
+
+ cy_as_dev = kzalloc(sizeof(cyasgadget), GFP_ATOMIC);
+ if (cy_as_dev == NULL) {
+ cy_as_hal_print_message("<1> cy_as_gadget: memory "
+ "allocation failed\n") ;
+ return -ENOMEM;
+ }
+
+ spin_lock_init(&cy_as_dev->lock);
+ cy_as_dev->gadget.ops = &cyasgadget_ops;
+ cy_as_dev->gadget.is_dualspeed = 1;
+
+ /* the "gadget" abstracts/virtualizes the controller */
+ /*strcpy(cy_as_dev->gadget.dev.bus_id, "cyasgadget");*/
+ cy_as_dev->gadget.dev.release = cyas_gadget_release;
+ cy_as_dev->gadget.name = cy_as_driver_name;
+
+ /* Get the device handle */
+ cy_as_dev->dev_handle = cyasdevice_getdevhandle() ;
+ if (0 == cy_as_dev->dev_handle) {
+ #ifndef NDEBUG
+ cy_as_hal_print_message("<1> cy_as_gadget: "
+ "no west bridge device\n") ;
+ #endif
+ retval = -EFAULT ;
+ goto done ;
+ }
+
+ /* We are done now */
+ cy_as_gadget_controller = cy_as_dev ;
+ return 0 ;
+
+/*
+ * in case of an error
+ */
+done:
+ if (cy_as_dev)
+ cyasgadget_deinit(cy_as_dev) ;
+
+ return retval ;
+}
+
+static int __init cyas_init(void)
+{
+ int init_res = 0;
+
+ init_res = cyasgadget_initialize();
+
+ if (init_res != 0) {
+ printk(KERN_WARNING "<1> gadget ctl instance "
+ "init error:%d\n", init_res);
+ if (init_res > 0) {
+ /* force -E/0 linux convention */
+ init_res = init_res * -1;
+ }
+ }
+
+ return init_res;
+}
+module_init(cyas_init);
+
+static void __exit cyas_cleanup(void)
+{
+ if (cy_as_gadget_controller != NULL)
+ cyasgadget_deinit(cy_as_gadget_controller);
+}
+module_exit(cyas_cleanup);
+
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION(CY_AS_DRIVER_DESC);
+MODULE_AUTHOR("cypress semiconductor");
+
+/*[]*/
diff --git a/drivers/staging/westbridge/astoria/gadget/cyasgadget.h b/drivers/staging/westbridge/astoria/gadget/cyasgadget.h
new file mode 100644
index 000000000000..d7b72d2720be
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/gadget/cyasgadget.h
@@ -0,0 +1,193 @@
+/* cyangadget.h - Linux USB Gadget driver file for the Cypress West Bridge
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * Cypress West Bridge high/full speed USB device controller code
+ * Based on the Netchip 2280 device controller by David Brownell
+ * in the linux 2.6.10 kernel
+ *
+ * linux/drivers/usb/gadget/net2280.h
+ */
+
+/*
+ * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
+ * Copyright (C) 2003 David Brownell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _INCLUDED_CYANGADGET_H_
+#define _INCLUDED_CYANGADGET_H_
+
+#include <linux/device.h>
+#include <linux/moduleparam.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/sched.h>
+
+#include "../include/linux/westbridge/cyastoria.h"
+#include "../include/linux/westbridge/cyashal.h"
+#include "../include/linux/westbridge/cyasdevice.h"
+#include "cyasgadget_ioctl.h"
+
+#include <linux/module.h>
+#include <linux/init.h>
+
+/*char driver defines, revisit*/
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/fs.h> /* everything... */
+#include <linux/errno.h> /* error codes */
+#include <linux/types.h> /* size_t */
+#include <linux/proc_fs.h>
+#include <linux/fcntl.h> /* O_ACCMODE */
+#include <linux/seq_file.h>
+#include <linux/cdev.h>
+#include <linux/scatterlist.h>
+#include <linux/pagemap.h>
+#include <linux/vmalloc.h> /* vmalloc(), vfree */
+#include <linux/msdos_fs.h> /*fat_alloc_cluster*/
+#include <linux/buffer_head.h>
+#include <asm/system.h> /* cli(), *_flags */
+#include <linux/uaccess.h> /* copy_*_user */
+
+extern int mpage_cleardirty(struct address_space *mapping, int num_pages);
+extern int fat_get_block(struct inode *, sector_t , struct buffer_head *, int);
+extern cy_as_device_handle *cyasdevice_getdevhandle(void) ;
+
+/* Driver data structures and utilities */
+typedef struct cyasgadget_ep {
+ struct usb_ep usb_ep_inst;
+ struct cyasgadget *dev;
+
+ /* analogous to a host-side qh */
+ struct list_head queue;
+ const struct usb_endpoint_descriptor *desc;
+ unsigned num:8,
+ fifo_size:12,
+ in_fifo_validate:1,
+ out_overflow:1,
+ stopped:1,
+ is_in:1,
+ is_iso:1;
+ cy_as_usb_end_point_config cyepconfig;
+} cyasgadget_ep ;
+
+typedef struct cyasgadget_req {
+ struct usb_request req;
+ struct list_head queue;
+ int ep_num;
+ unsigned mapped:1,
+ valid:1,
+ complete:1,
+ ep_stopped:1;
+} cyasgadget_req ;
+
+typedef struct cyasgadget {
+ /* each device provides one gadget, several endpoints */
+ struct usb_gadget gadget;
+ spinlock_t lock;
+ struct cyasgadget_ep an_gadget_ep[16];
+ struct usb_gadget_driver *driver;
+ /* Handle to the West Bridge device */
+ cy_as_device_handle dev_handle;
+ unsigned enabled:1,
+ protocol_stall:1,
+ softconnect:1,
+ outsetupreq:1;
+ struct completion thread_complete;
+ wait_queue_head_t thread_wq;
+ struct semaphore thread_sem;
+ struct list_head thread_queue;
+
+ cy_bool tmtp_send_complete;
+ cy_bool tmtp_get_complete;
+ cy_bool tmtp_need_new_blk_tbl;
+ /* Data member used to store the SendObjectComplete event data */
+ cy_as_mtp_send_object_complete_data tmtp_send_complete_data;
+ /* Data member used to store the GetObjectComplete event data */
+ cy_as_mtp_get_object_complete_data tmtp_get_complete_data;
+
+} cyasgadget ;
+
+static inline void set_halt(cyasgadget_ep *ep)
+{
+ return ;
+}
+
+static inline void clear_halt(cyasgadget_ep *ep)
+{
+ return ;
+}
+
+#define xprintk(dev, level, fmt, args...) \
+ printk(level "%s %s: " fmt, driver_name, \
+ pci_name(dev->pdev), ## args)
+
+#ifdef DEBUG
+#undef DEBUG
+#define DEBUG(dev, fmt, args...) \
+ xprintk(dev, KERN_DEBUG, fmt, ## args)
+#else
+#define DEBUG(dev, fmt, args...) \
+ do { } while (0)
+#endif /* DEBUG */
+
+#ifdef VERBOSE
+#define VDEBUG DEBUG
+#else
+#define VDEBUG(dev, fmt, args...) \
+ do { } while (0)
+#endif /* VERBOSE */
+
+#define ERROR(dev, fmt, args...) \
+ xprintk(dev, KERN_ERR, fmt, ## args)
+#define GADG_WARN(dev, fmt, args...) \
+ xprintk(dev, KERN_WARNING, fmt, ## args)
+#define INFO(dev, fmt, args...) \
+ xprintk(dev, KERN_INFO, fmt, ## args)
+
+/*-------------------------------------------------------------------------*/
+
+static inline void start_out_naking(struct cyasgadget_ep *ep)
+{
+ return ;
+}
+
+static inline void stop_out_naking(struct cyasgadget_ep *ep)
+{
+ return ;
+}
+
+#endif /* _INCLUDED_CYANGADGET_H_ */
diff --git a/drivers/staging/westbridge/astoria/gadget/cyasgadget_ioctl.h b/drivers/staging/westbridge/astoria/gadget/cyasgadget_ioctl.h
new file mode 100644
index 000000000000..e67bfd36f62a
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/gadget/cyasgadget_ioctl.h
@@ -0,0 +1,99 @@
+/* cyasgadget_ioctl.h - Linux USB Gadget driver ioctl file for
+ * Cypress West Bridge
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef CYASGADGET_IOCTL_H
+#define CYASGADGET_IOCTL_H
+
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+typedef struct cy_as_gadget_ioctl_send_object {
+ uint32_t status;
+ uint32_t byte_count ;
+ uint32_t transaction_id ;
+} cy_as_gadget_ioctl_send_object ;
+
+typedef struct cy_as_gadget_ioctl_get_object {
+ uint32_t status;
+ uint32_t byte_count ;
+} cy_as_gadget_ioctl_get_object ;
+
+
+typedef struct cy_as_gadget_ioctl_tmtp_status {
+ cy_bool tmtp_send_complete;
+ cy_bool tmtp_get_complete;
+ cy_bool tmtp_need_new_blk_tbl;
+ cy_as_gadget_ioctl_send_object tmtp_send_complete_data;
+ cy_as_gadget_ioctl_get_object tmtp_get_complete_data;
+ uint32_t t_usec;
+} cy_as_gadget_ioctl_tmtp_status ;
+
+/*Init send object data*/
+typedef struct cy_as_gadget_ioctl_i_s_o_j_d {
+ uint32_t *blk_addr_p; /* starting sector */
+ uint16_t *blk_count_p; /* num of sectors in the block */
+ /* number of entries in the blk table */
+ uint32_t item_count;
+ uint32_t num_bytes;
+ /* in case if more prcise timestamping is done in kernel mode */
+ uint32_t t_usec;
+ uint32_t ret_val ;
+ char *file_name;
+ uint32_t name_length;
+
+} cy_as_gadget_ioctl_i_s_o_j_d;
+
+
+/*Init get object data*/
+typedef struct cy_as_gadget_ioctl_i_g_o_j_d {
+ uint32_t *blk_addr_p;
+ uint16_t *blk_count_p;
+ uint32_t item_count;
+ uint32_t num_bytes;
+ uint32_t tid ;
+ uint32_t ret_val ;
+ char *file_name;
+ uint32_t name_length;
+
+} cy_as_gadget_ioctl_i_g_o_j_d ;
+
+typedef struct cy_as_gadget_ioctl_cancel {
+ uint32_t ret_val;
+} cy_as_gadget_ioctl_cancel;
+
+#define CYASGADGET_IOC_MAGIC 0xEF
+#define CYASGADGET_GETMTPSTATUS \
+ _IOW(CYASGADGET_IOC_MAGIC, 0, cy_as_gadget_ioctl_tmtp_status)
+#define CYASGADGET_CLEARTMTPSTATUS \
+ _IO(CYASGADGET_IOC_MAGIC, 1)
+#define CYASGADGET_INITSOJ \
+ _IOW(CYASGADGET_IOC_MAGIC, 2, cy_as_gadget_ioctl_i_s_o_j_d)
+#define CYASGADGET_INITGOJ \
+ _IOW(CYASGADGET_IOC_MAGIC, 3, cy_as_gadget_ioctl_i_g_o_j_d)
+#define CYASGADGET_CANCELSOJ \
+ _IOW(CYASGADGET_IOC_MAGIC, 4, cy_as_gadget_ioctl_cancel)
+#define CYASGADGET_CANCELGOJ \
+ _IOW(CYASGADGET_IOC_MAGIC, 5, cy_as_gadget_ioctl_cancel)
+#define CYASGADGET_IOC_MAXNR 6
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanerr.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanerr.h
new file mode 100644
index 000000000000..c7d4ebb020c9
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanerr.h
@@ -0,0 +1,418 @@
+/* Cypress West Bridge API header file (cyanerr.h)
+ ## Symbols for backward compatibility with previous releases of Antioch SDK.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANERR_H_
+#define _INCLUDED_CYANERR_H_
+
+#include "cyaserr.h"
+
+#ifndef __doxygen__
+
+/*
+ * Function completed successfully.
+ */
+#define CY_AN_ERROR_SUCCESS (CY_AS_ERROR_SUCCESS)
+
+/*
+ * A function trying to acquire a resource was unable to do so.
+ */
+#define CY_AN_ERROR_NOT_ACQUIRED (CY_AS_ERROR_NOT_ACQUIRED)
+
+/*
+ * A function trying to acquire a resource was unable to do so.
+ */
+#define CY_AN_ERROR_NOT_RELEASED (CY_AS_ERROR_NOT_RELEASED)
+
+/*
+ * The West Bridge firmware is not loaded.
+ */
+#define CY_AN_ERROR_NO_FIRMWARE (CY_AS_ERROR_NO_FIRMWARE)
+
+/*
+ * A timeout occurred waiting on a response from the West Bridge device
+ */
+#define CY_AN_ERROR_TIMEOUT (CY_AS_ERROR_TIMEOUT)
+
+/*
+ * A request to download firmware was made while not in the CONFIG mode
+ */
+#define CY_AN_ERROR_NOT_IN_CONFIG_MODE (CY_AS_ERROR_NOT_IN_CONFIG_MODE)
+
+/*
+ * This error is returned if the firmware size specified is too invalid.
+ */
+#define CY_AN_ERROR_INVALID_SIZE (CY_AS_ERROR_INVALID_SIZE)
+
+/*
+ * This error is returned if a request is made to acquire a resource that has
+ * already been acquired.
+ */
+#define CY_AN_ERROR_RESOURCE_ALREADY_OWNED (CY_AS_ERROR_RESOURCE_ALREADY_OWNED)
+
+/*
+ * This error is returned if a request is made to release a resource that has
+ * not previously been acquired.
+ */
+#define CY_AN_ERROR_RESOURCE_NOT_OWNED (CY_AS_ERROR_RESOURCE_NOT_OWNED)
+
+/*
+ * This error is returned when a request is made for a media that does not
+ * exist
+ */
+#define CY_AN_ERROR_NO_SUCH_MEDIA (CY_AS_ERROR_NO_SUCH_MEDIA)
+
+/*
+ * This error is returned when a request is made for a device that does
+ * not exist
+ */
+#define CY_AN_ERROR_NO_SUCH_DEVICE (CY_AS_ERROR_NO_SUCH_DEVICE)
+
+/*
+ * This error is returned when a request is made for a unit that does
+ * not exist
+ */
+#define CY_AN_ERROR_NO_SUCH_UNIT (CY_AS_ERROR_NO_SUCH_UNIT)
+
+/*
+ * This error is returned when a request is made for a block that does
+ * not exist
+ */
+#define CY_AN_ERROR_INVALID_BLOCK (CY_AS_ERROR_INVALID_BLOCK)
+
+/*
+ * This error is returned when an invalid trace level is set.
+ */
+#define CY_AN_ERROR_INVALID_TRACE_LEVEL (CY_AS_ERROR_INVALID_TRACE_LEVEL)
+
+/*
+ * This error is returned when West Bridge is already in the standby state
+ * and an attempt is made to put West Bridge into this state again.
+ */
+#define CY_AN_ERROR_ALREADY_STANDBY (CY_AS_ERROR_ALREADY_STANDBY)
+
+/*
+ * This error is returned when the API needs to set a pin on the
+ * West Bridge device, but this is not supported by the underlying HAL
+ * layer.
+ */
+#define CY_AN_ERROR_SETTING_WAKEUP_PIN (CY_AS_ERROR_SETTING_WAKEUP_PIN)
+
+/*
+ * This error is returned when a module is being started that has
+ * already been started.
+ */
+#define CY_AN_ERROR_ALREADY_RUNNING (CY_AS_ERROR_ALREADY_RUNNING)
+
+/*
+ * This error is returned when a module is being stopped that has
+ * already been stopped.
+ */
+#define CY_AN_ERROR_NOT_RUNNING (CY_AS_ERROR_NOT_RUNNING)
+
+/*
+ * This error is returned when the caller tries to claim a media that has
+ * already been claimed.
+ */
+#define CY_AN_ERROR_MEDIA_ALREADY_CLAIMED (CY_AS_ERROR_MEDIA_ALREADY_CLAIMED)
+
+/*
+ * This error is returned when the caller tries to release a media that
+ * has already been released.
+ */
+#define CY_AN_ERROR_MEDIA_NOT_CLAIMED (CY_AS_ERROR_MEDIA_NOT_CLAIMED)
+
+/*
+ * This error is returned when canceling trying to cancel an asynchronous
+ * operation when an async operation is not pending.
+ */
+#define CY_AN_ERROR_NO_OPERATION_PENDING (CY_AS_ERROR_NO_OPERATION_PENDING)
+
+/*
+ * This error is returned when an invalid endpoint number is provided
+ * to an API call.
+ */
+#define CY_AN_ERROR_INVALID_ENDPOINT (CY_AS_ERROR_INVALID_ENDPOINT)
+
+/*
+ * This error is returned when an invalid descriptor type
+ * is specified in an API call.
+ */
+#define CY_AN_ERROR_INVALID_DESCRIPTOR (CY_AS_ERROR_INVALID_DESCRIPTOR)
+
+/*
+ * This error is returned when an invalid descriptor index
+ * is specified in an API call.
+ */
+#define CY_AN_ERROR_BAD_INDEX (CY_AS_ERROR_BAD_INDEX)
+
+/*
+ * This error is returned if trying to set a USB descriptor
+ * when in the P port enumeration mode.
+ */
+#define CY_AN_ERROR_BAD_ENUMERATION_MODE (CY_AS_ERROR_BAD_ENUMERATION_MODE)
+
+/*
+ * This error is returned when the endpoint configuration specified
+ * is not valid.
+ */
+#define CY_AN_ERROR_INVALID_CONFIGURATION (CY_AS_ERROR_INVALID_CONFIGURATION)
+
+/*
+ * This error is returned when the API cannot verify it is connected
+ * to an West Bridge device.
+ */
+#define CY_AN_ERROR_NO_ANTIOCH (CY_AS_ERROR_NO_ANTIOCH)
+
+/*
+ * This error is returned when an API function is called and
+ * CyAnMiscConfigureDevice has not been called to configure West
+ * Bridge for the current environment.
+ */
+#define CY_AN_ERROR_NOT_CONFIGURED (CY_AS_ERROR_NOT_CONFIGURED)
+
+/*
+ * This error is returned when West Bridge cannot allocate memory required for
+ * internal API operations.
+ */
+#define CY_AN_ERROR_OUT_OF_MEMORY (CY_AS_ERROR_OUT_OF_MEMORY)
+
+/*
+ * This error is returned when a module is being started that has
+ * already been started.
+ */
+#define CY_AN_ERROR_NESTED_SLEEP (CY_AS_ERROR_NESTED_SLEEP)
+
+/*
+ * This error is returned when an operation is attempted on an endpoint that has
+ * been disabled.
+ */
+#define CY_AN_ERROR_ENDPOINT_DISABLED (CY_AS_ERROR_ENDPOINT_DISABLED)
+
+/*
+ * This error is returned when a call is made to an API function when the device
+ * is in standby.
+ */
+#define CY_AN_ERROR_IN_STANDBY (CY_AS_ERROR_IN_STANDBY)
+
+/*
+ * This error is returned when an API call is made with an invalid handle value.
+ */
+#define CY_AN_ERROR_INVALID_HANDLE (CY_AS_ERROR_INVALID_HANDLE)
+
+/*
+ * This error is returned when an invalid response is returned from the West
+ * Bridge device.
+ */
+#define CY_AN_ERROR_INVALID_RESPONSE (CY_AS_ERROR_INVALID_RESPONSE)
+
+/*
+ * This error is returned from the callback function for any asynchronous
+ * read or write request that is canceled.
+ */
+#define CY_AN_ERROR_CANCELED (CY_AS_ERROR_CANCELED)
+
+/*
+ * This error is returned when the call to create sleep channel fails
+ * in the HAL layer.
+ */
+#define CY_AN_ERROR_CREATE_SLEEP_CHANNEL_FAILED \
+ (CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED)
+
+/*
+ * This error is returned when the call to CyAnMiscLeaveStandby
+ * is made and the device is not in standby.
+ */
+#define CY_AN_ERROR_NOT_IN_STANDBY (CY_AS_ERROR_NOT_IN_STANDBY)
+
+/*
+ * This error is returned when the call to destroy sleep channel fails
+ * in the HAL layer.
+ */
+#define CY_AN_ERROR_DESTROY_SLEEP_CHANNEL_FAILED \
+ (CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED)
+
+/*
+ * This error is returned when an invalid resource is specified to a call
+ * to CyAnMiscAcquireResource() or CyAnMiscReleaseResource()
+ */
+#define CY_AN_ERROR_INVALID_RESOURCE (CY_AS_ERROR_INVALID_RESOURCE)
+
+/*
+ * This error occurs when an operation is requested on an endpoint that has
+ * a currently pending async operation.
+ */
+#define CY_AN_ERROR_ASYNC_PENDING (CY_AS_ERROR_ASYNC_PENDING)
+
+/*
+ * This error is returned when a call to CyAnStorageCancelAsync() or
+ * CyAnUsbCancelAsync() is made when no asynchronous request is pending.
+ */
+#define CY_AN_ERROR_ASYNC_NOT_PENDING (CY_AS_ERROR_ASYNC_NOT_PENDING)
+
+/*
+ * This error is returned when a request is made to put the West Bridge device
+ * into standby mode while the USB stack is still active.
+ */
+#define CY_AN_ERROR_USB_RUNNING (CY_AS_ERROR_USB_RUNNING)
+
+/*
+ * A request for in the wrong direction was issued on an endpoint.
+ */
+#define CY_AN_ERROR_USB_BAD_DIRECTION (CY_AS_ERROR_USB_BAD_DIRECTION)
+
+/*
+ * An invalid request was received
+ */
+#define CY_AN_ERROR_INVALID_REQUEST (CY_AS_ERROR_INVALID_REQUEST)
+
+/*
+ * An ACK request was requested while no setup packet was pending.
+ */
+#define CY_AN_ERROR_NO_SETUP_PACKET_PENDING \
+ (CY_AS_ERROR_NO_SETUP_PACKET_PENDING)
+
+/*
+ * A call was made to a API function that cannot be called from a callback.
+ */
+#define CY_AN_ERROR_INVALID_IN_CALLBACK (CY_AS_ERROR_INVALID_IN_CALLBACK)
+
+/*
+ * A call was made to CyAnUsbSetEndPointConfig() before
+ * CyAnUsbSetPhysicalConfiguration() was called.
+ */
+#define CY_AN_ERROR_ENDPOINT_CONFIG_NOT_SET \
+ (CY_AS_ERROR_ENDPOINT_CONFIG_NOT_SET)
+
+/*
+ * The physical endpoint referenced is not valid in the current
+ * physical configuration
+ */
+#define CY_AN_ERROR_INVALID_PHYSICAL_ENDPOINT \
+ (CY_AS_ERROR_INVALID_PHYSICAL_ENDPOINT)
+
+/*
+ * The data supplied to the CyAnMiscDownloadFirmware() call is not aligned on a
+ * WORD (16 bit) boundary.
+ */
+#define CY_AN_ERROR_ALIGNMENT_ERROR (CY_AS_ERROR_ALIGNMENT_ERROR)
+
+/*
+ * A call was made to destroy the West Bridge device, but the USB stack or the
+ * storage stack was will running.
+ */
+#define CY_AN_ERROR_STILL_RUNNING (CY_AS_ERROR_STILL_RUNNING)
+
+/*
+ * A call was made to the API for a function that is not yet supported.
+ */
+#define CY_AN_ERROR_NOT_YET_SUPPORTED (CY_AS_ERROR_NOT_YET_SUPPORTED)
+
+/*
+ * A NULL callback was provided where a non-NULL callback was required
+ */
+#define CY_AN_ERROR_NULL_CALLBACK (CY_AS_ERROR_NULL_CALLBACK)
+
+/*
+ * This error is returned when a request is made to put the West Bridge device
+ * into standby mode while the storage stack is still active.
+ */
+#define CY_AN_ERROR_STORAGE_RUNNING (CY_AS_ERROR_STORAGE_RUNNING)
+
+/*
+ * This error is returned when an operation is attempted that cannot be
+ * completed while the USB stack is connected to a USB host.
+ */
+#define CY_AN_ERROR_USB_CONNECTED (CY_AS_ERROR_USB_CONNECTED)
+
+/*
+ * This error is returned when a USB disconnect is attempted and the
+ * West Bridge device is not connected.
+ */
+#define CY_AN_ERROR_USB_NOT_CONNECTED (CY_AS_ERROR_USB_NOT_CONNECTED)
+
+/*
+ * This error is returned when an P2S storage operation attempted and
+ * data could not be read or written to the storage media.
+ */
+#define CY_AN_ERROR_MEDIA_ACCESS_FAILURE (CY_AS_ERROR_MEDIA_ACCESS_FAILURE)
+
+/*
+ * This error is returned when an P2S storage operation attempted and
+ * the media is write protected.
+ */
+#define CY_AN_ERROR_MEDIA_WRITE_PROTECTED (CY_AS_ERROR_MEDIA_WRITE_PROTECTED)
+
+/*
+ * This error is returned when an attempt is made to cancel a request
+ * that has already been sent to the West Bridge.
+ */
+#define CY_AN_ERROR_OPERATION_IN_TRANSIT (CY_AS_ERROR_OPERATION_IN_TRANSIT)
+
+/*
+ * This error is returned when an invalid parameter is passed to one of
+ * the APIs.
+ */
+#define CY_AN_ERROR_INVALID_PARAMETER (CY_AS_ERROR_INVALID_PARAMETER)
+
+/*
+ * This error is returned if an API is not supported by the current
+ * West Bridge device or the active firmware version.
+ */
+#define CY_AN_ERROR_NOT_SUPPORTED (CY_AS_ERROR_NOT_SUPPORTED)
+
+/*
+ * This error is returned when a call is made to one of the Storage or
+ * USB APIs while the device is in suspend mode.
+ */
+#define CY_AN_ERROR_IN_SUSPEND (CY_AS_ERROR_IN_SUSPEND)
+
+/*
+ * This error is returned when the call to CyAnMiscLeaveSuspend
+ * is made and the device is not in suspend mode.
+ */
+#define CY_AN_ERROR_NOT_IN_SUSPEND (CY_AS_ERROR_NOT_IN_SUSPEND)
+
+/*
+ * This error is returned when a command that is disabled by USB is called.
+ */
+#define CY_AN_ERROR_FEATURE_NOT_ENABLED (CY_AS_ERROR_FEATURE_NOT_ENABLED)
+
+/*
+ * This error is returned when an Async storage read or write is called before a
+ * query device call is issued.
+ */
+#define CY_AN_ERROR_QUERY_DEVICE_NEEDED (CY_AS_ERROR_QUERY_DEVICE_NEEDED)
+
+/*
+ * This error is returned when a call is made to USB or STORAGE Start or
+ * Stop before a prior Start or Stop has finished.
+ */
+#define CY_AN_ERROR_STARTSTOP_PENDING (CY_AS_ERROR_STARTSTOP_PENDING)
+
+/*
+ * This error is returned when a request is made for a bus that does not exist
+ */
+#define CY_AN_ERROR_NO_SUCH_BUS (CY_AS_ERROR_NO_SUCH_BUS)
+
+#endif /* __doxygen__ */
+
+#endif /* _INCLUDED_CYANERR_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmedia.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmedia.h
new file mode 100644
index 000000000000..be074887f5a3
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmedia.h
@@ -0,0 +1,59 @@
+/* Cypress West Bridge API header file (cyanmedia.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANMEDIA_H_
+#define _INCLUDED_CYANMEDIA_H_
+
+#include "cyas_cplus_start.h"
+
+/* Summary
+ Specifies a specific type of media supported by West Bridge
+
+ Description
+ The West Bridge device supports five specific types
+ of media as storage/IO devices attached to it's S-Port. This
+ type is used to indicate the type of media being referenced in
+ any API call.
+*/
+#include "cyasmedia.h"
+
+/* Flash NAND memory (may be SLC or MLC) */
+#define cy_an_media_nand cy_as_media_nand
+
+/* An SD flash memory device */
+#define cy_an_media_sd_flash cy_as_media_sd_flash
+
+/* An MMC flash memory device */
+#define cy_an_media_mmc_flash cy_as_media_mmc_flash
+
+/* A CE-ATA disk drive */
+#define cy_an_media_ce_ata cy_as_media_ce_ata
+
+ /* SDIO device. */
+#define cy_an_media_sdio cy_as_media_sdio
+#define cy_an_media_max_media_value \
+ cy_as_media_max_media_value
+
+typedef cy_as_media_type cy_an_media_type;
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYANMEDIA_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmisc.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmisc.h
new file mode 100644
index 000000000000..34584b798709
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanmisc.h
@@ -0,0 +1,614 @@
+/* Cypress West Bridge API header file (cyanmisc.h)
+ ## Version for backward compatibility with previous Antioch SDK releases.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANMISC_H_
+#define _INCLUDED_CYANMISC_H_
+
+#include "cyantypes.h"
+#include <cyasmisc.h>
+#include "cyanmedia.h"
+#include "cyas_cplus_start.h"
+
+#define CY_AN_LEAVE_STANDBY_DELAY_CLOCK \
+ (CY_AS_LEAVE_STANDBY_DELAY_CLOCK)
+#define CY_AN_RESET_DELAY_CLOCK \
+ (CY_AS_RESET_DELAY_CLOCK)
+
+#define CY_AN_LEAVE_STANDBY_DELAY_CRYSTAL \
+ (CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL)
+
+#define CY_AN_RESET_DELAY_CRYSTAL \
+ (CY_AS_RESET_DELAY_CRYSTAL)
+
+/* Defines to convert the old CyAn names to the new
+ * CyAs names
+ */
+typedef cy_as_device_handle cy_an_device_handle;
+
+#define cy_an_device_dack_ack cy_as_device_dack_ack
+#define cy_an_device_dack_eob cy_as_device_dack_eob
+typedef cy_as_device_dack_mode cy_an_device_dack_mode;
+
+typedef cy_as_device_config cy_an_device_config;
+
+#define cy_an_resource_u_s_b cy_as_bus_u_sB
+#define cy_an_resource_sdio_MMC cy_as_bus_1
+#define cy_an_resource_nand cy_as_bus_0
+typedef cy_as_resource_type cy_an_resource_type;
+
+#define cy_an_reset_soft cy_as_reset_soft
+#define cy_an_reset_hard cy_as_reset_hard
+typedef cy_as_reset_type cy_an_reset_type;
+typedef cy_as_funct_c_b_type cy_an_funct_c_b_type;
+typedef cy_as_function_callback cy_an_function_callback;
+
+#define cy_an_event_misc_initialized \
+ cy_as_event_misc_initialized
+#define cy_an_event_misc_awake \
+ cy_as_event_misc_awake
+#define cy_an_event_misc_heart_beat \
+ cy_as_event_misc_heart_beat
+#define cy_an_event_misc_wakeup \
+ cy_as_event_misc_wakeup
+#define cy_an_event_misc_device_mismatch \
+ cy_as_event_misc_device_mismatch
+typedef cy_as_misc_event_type \
+ cy_an_misc_event_type;
+typedef cy_as_misc_event_callback \
+ cy_an_misc_event_callback;
+
+#define cy_an_misc_gpio_0 cy_as_misc_gpio_0
+#define cy_an_misc_gpio_1 cy_as_misc_gpio_1
+#define cy_an_misc_gpio__nand_CE \
+ cy_as_misc_gpio__nand_CE
+#define cy_an_misc_gpio__nand_CE2 \
+ cy_as_misc_gpio__nand_CE2
+#define cy_an_misc_gpio__nand_WP \
+ cy_as_misc_gpio__nand_WP
+#define cy_an_misc_gpio__nand_CLE \
+ cy_as_misc_gpio__nand_CLE
+#define cy_an_misc_gpio__nand_ALE \
+ cy_as_misc_gpio__nand_ALE
+#define cy_an_misc_gpio_U_valid \
+ cy_as_misc_gpio_U_valid
+#define cy_an_misc_gpio_SD_POW \
+ cy_as_misc_gpio_SD_POW
+typedef cy_as_misc_gpio cy_an_misc_gpio;
+
+#define CY_AN_SD_DEFAULT_FREQ CY_AS_SD_DEFAULT_FREQ
+#define CY_AN_SD_RATED_FREQ CY_AS_SD_RATED_FREQ
+typedef cy_as_low_speed_sd_freq cy_an_low_speed_sd_freq;
+
+#define CY_AN_HS_SD_FREQ_48 CY_AS_HS_SD_FREQ_48
+#define CY_AN_HS_SD_FREQ_24 CY_AS_HS_SD_FREQ_24
+typedef cy_as_high_speed_sd_freq \
+ cy_an_high_speed_sd_freq;
+
+#define cy_an_misc_active_high cy_as_misc_active_high
+#define cy_an_misc_active_low cy_as_misc_active_low
+typedef cy_as_misc_signal_polarity cy_an_misc_signal_polarity;
+
+typedef cy_as_get_firmware_version_data \
+ cy_an_get_firmware_version_data;
+
+enum {
+ CYAN_FW_TRACE_LOG_NONE = 0,
+ CYAN_FW_TRACE_LOG_STATE,
+ CYAN_FW_TRACE_LOG_CALLS,
+ CYAN_FW_TRACE_LOG_STACK_TRACE,
+ CYAN_FW_TRACE_MAX_LEVEL
+};
+
+
+/***********************************/
+/***********************************/
+/* FUNCTIONS */
+/***********************************/
+/***********************************/
+
+
+EXTERN cy_an_return_status_t
+cy_an_misc_create_device(
+ cy_an_device_handle *handle_p,
+ cy_an_hal_device_tag tag
+ ) ;
+#define cy_an_misc_create_device(h, tag) \
+ cy_as_misc_create_device((cy_as_device_handle *)(h), \
+ (cy_as_hal_device_tag)(tag))
+
+EXTERN cy_an_return_status_t
+cy_an_misc_destroy_device(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_misc_destroy_device(h) \
+ cy_as_misc_destroy_device((cy_as_device_handle)(h))
+
+EXTERN cy_an_return_status_t
+cy_an_misc_configure_device(
+ cy_an_device_handle handle,
+ cy_an_device_config *config_p
+ ) ;
+#define cy_an_misc_configure_device(h, cfg) \
+ cy_as_misc_configure_device((cy_as_device_handle)(h), \
+ (cy_as_device_config *)(cfg))
+
+EXTERN cy_an_return_status_t
+cy_an_misc_in_standby(
+ cy_an_device_handle handle,
+ cy_bool *standby
+ ) ;
+#define cy_an_misc_in_standby(h, standby) \
+ cy_as_misc_in_standby((cy_as_device_handle)(h), (standby))
+
+/* Sync version of Download Firmware */
+EXTERN cy_an_return_status_t
+cy_an_misc_download_firmware(
+ cy_an_device_handle handle,
+ const void *fw_p,
+ uint16_t size
+ ) ;
+
+#define cy_an_misc_download_firmware(handle, fw_p, size) \
+ cy_as_misc_download_firmware((cy_as_device_handle)\
+ (handle), (fw_p), (size), 0, 0)
+
+/* Async version of Download Firmware */
+EXTERN cy_an_return_status_t
+cy_an_misc_download_firmware_e_x(
+ cy_an_device_handle handle,
+ const void *fw_p,
+ uint16_t size,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+
+#define cy_an_misc_download_firmware_e_x(h, fw_p, size, cb, client) \
+ cy_as_misc_download_firmware((cy_as_device_handle)(h), \
+ (fw_p), (size), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Get Firmware Version */
+EXTERN cy_an_return_status_t
+cy_as_misc_get_firmware_version_dep(
+ cy_as_device_handle handle,
+ uint16_t *major,
+ uint16_t *minor,
+ uint16_t *build,
+ uint8_t *media_type,
+ cy_bool *is_debug_mode);
+
+#define cy_an_misc_get_firmware_version\
+ (h, major, minor, bld, type, mode) \
+ cy_as_misc_get_firmware_version_dep((cy_as_device_handle)(h), \
+ (major), (minor), (bld), (type), (mode))
+
+/* Async version of Get Firmware Version*/
+EXTERN cy_an_return_status_t
+cy_an_misc_get_firmware_version_e_x(
+ cy_an_device_handle handle,
+ cy_an_get_firmware_version_data *data,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_get_firmware_version_e_x\
+ (h, data, cb, client) \
+ cy_as_misc_get_firmware_version((cy_as_device_handle)(h), \
+ (data), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Read MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_read_m_c_u_register(
+ cy_an_device_handle handle,
+ uint16_t address,
+ uint8_t *value
+ ) ;
+
+#define cy_an_misc_read_m_c_u_register(handle, address, value) \
+ cy_as_misc_read_m_c_u_register((cy_as_device_handle)(handle), \
+ (address), (value), 0, 0)
+
+/* Async version of Read MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_read_m_c_u_register_e_x(
+ cy_an_device_handle handle,
+ uint16_t address,
+ uint8_t *value,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+
+#define cy_an_misc_read_m_c_u_register_e_x\
+ (h, addr, val, cb, client) \
+ cy_as_misc_read_m_c_u_register((cy_as_device_handle)(h), \
+ (addr), (val), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Write MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_write_m_c_u_register(
+ cy_an_device_handle handle,
+ uint16_t address,
+ uint8_t mask,
+ uint8_t value
+ ) ;
+#define cy_an_misc_write_m_c_u_register\
+ (handle, address, mask, value) \
+ cy_as_misc_write_m_c_u_register((cy_as_device_handle)(handle), \
+ (address), (mask), (value), 0, 0)
+
+/* Async version of Write MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_write_m_c_u_register_e_x(
+ cy_an_device_handle handle,
+ uint16_t address,
+ uint8_t mask,
+ uint8_t value,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_write_m_c_u_register_e_x\
+ (h, addr, mask, val, cb, client) \
+ cy_as_misc_write_m_c_u_register((cy_as_device_handle)(h), \
+ (addr), (mask), (val), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Write MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_reset(
+ cy_an_device_handle handle,
+ cy_an_reset_type type,
+ cy_bool flush
+ ) ;
+#define cy_an_misc_reset(handle, type, flush) \
+ cy_as_misc_reset((cy_as_device_handle)(handle), \
+ (type), (flush), 0, 0)
+
+/* Async version of Write MCU Register*/
+EXTERN cy_an_return_status_t
+cy_an_misc_reset_e_x(
+ cy_an_device_handle handle,
+ cy_an_reset_type type,
+ cy_bool flush,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_reset_e_x(h, type, flush, cb, client) \
+ cy_as_misc_reset((cy_as_device_handle)(h), \
+ (cy_as_reset_type)(type), (flush), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Synchronous version of CyAnMiscAcquireResource. */
+EXTERN cy_an_return_status_t
+cy_an_misc_acquire_resource(
+ cy_an_device_handle handle,
+ cy_an_resource_type type,
+ cy_bool force
+ ) ;
+#define cy_an_misc_acquire_resource(h, type, force) \
+ cy_as_misc_acquire_resource_dep((cy_as_device_handle)(h), \
+ (cy_as_resource_type)(type), (force))
+
+/* Asynchronous version of CyAnMiscAcquireResource. */
+EXTERN cy_an_return_status_t
+cy_an_misc_acquire_resource_e_x(
+ cy_an_device_handle handle,
+ cy_an_resource_type *type,
+ cy_bool force,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_acquire_resource_e_x\
+ (h, type_p, force, cb, client) \
+ cy_as_misc_acquire_resource((cy_as_device_handle)(h), \
+ (cy_as_resource_type *)(type_p), \
+ (force), (cy_as_function_callback)(cb), (client))
+
+/* The one and only version of Release resource */
+EXTERN cy_an_return_status_t
+cy_an_misc_release_resource(
+ cy_an_device_handle handle,
+ cy_an_resource_type type
+ ) ;
+#define cy_an_misc_release_resource(h, type)\
+ cy_as_misc_release_resource((cy_as_device_handle)(h), \
+ (cy_as_resource_type)(type))
+
+/* Synchronous version of CyAnMiscSetTraceLevel. */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_trace_level(
+ cy_an_device_handle handle,
+ uint8_t level,
+ cy_an_media_type media,
+ uint32_t device,
+ uint32_t unit
+ ) ;
+
+#define cy_an_misc_set_trace_level\
+ (handle, level, media, device, unit) \
+ cy_as_misc_set_trace_level_dep((cy_as_device_handle)(handle), \
+ (level), (cy_as_media_type)(media), (device), (unit), 0, 0)
+
+/* Asynchronous version of CyAnMiscSetTraceLevel. */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_trace_level_e_x(
+ cy_an_device_handle handle,
+ uint8_t level,
+ cy_an_media_type media,
+ uint32_t device,
+ uint32_t unit,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_set_trace_level_e_x\
+ (h, level, media, device, unit, cb, client) \
+ cy_as_misc_set_trace_level_dep((cy_as_device_handle)(h), \
+ (level), (cy_as_media_type)(media), (device), (unit), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Synchronous version of CyAnMiscEnterStandby. */
+EXTERN cy_an_return_status_t
+cy_an_misc_enter_standby(
+ cy_an_device_handle handle,
+ cy_bool pin
+ ) ;
+#define cy_an_misc_enter_standby(handle, pin) \
+ cy_as_misc_enter_standby(\
+ (cy_as_device_handle)(handle), (pin), 0, 0)
+
+/* Synchronous version of CyAnMiscEnterStandby. */
+EXTERN cy_an_return_status_t
+cy_an_misc_enter_standby_e_x(
+ cy_an_device_handle handle,
+ cy_bool pin,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_enter_standby_e_x(h, pin, cb, client) \
+ cy_as_misc_enter_standby((cy_as_device_handle)(h), \
+ (pin), (cy_as_function_callback)(cb), (client))
+
+/* Only one version of CyAnMiscLeaveStandby. */
+EXTERN cy_an_return_status_t
+cy_an_misc_leave_standby(
+ cy_an_device_handle handle,
+ cy_an_resource_type type
+ ) ;
+#define cy_an_misc_leave_standby(h, type) \
+ cy_as_misc_leave_standby((cy_as_device_handle)(h), \
+ (cy_as_resource_type)(type))
+
+/* The one version of Misc Register Callback */
+EXTERN cy_an_return_status_t
+cy_an_misc_register_callback(
+ cy_an_device_handle handle,
+ cy_an_misc_event_callback callback
+ ) ;
+#define cy_an_misc_register_callback(h, cb) \
+ cy_as_misc_register_callback((cy_as_device_handle)(h), \
+ (cy_as_misc_event_callback)(cb))
+
+/* The only version of SetLogLevel */
+EXTERN void
+cy_an_misc_set_log_level(
+ uint8_t level
+ ) ;
+#define cy_an_misc_set_log_level(level) \
+ cy_as_misc_set_log_level(level)
+
+/* Sync version of Misc Storage Changed */
+EXTERN cy_an_return_status_t
+cy_an_misc_storage_changed(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_misc_storage_changed(handle) \
+ cy_as_misc_storage_changed((cy_as_device_handle)(handle), 0, 0)
+
+/* Async version of Misc Storage Changed */
+EXTERN cy_an_return_status_t
+cy_an_misc_storage_changed_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_storage_changed_e_x(h, cb, client) \
+ cy_as_misc_storage_changed((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Heartbeat control */
+EXTERN cy_an_return_status_t
+cy_an_misc_heart_beat_control(
+ cy_an_device_handle handle,
+ cy_bool enable
+ ) ;
+#define cy_an_misc_heart_beat_control(handle, enable) \
+ cy_as_misc_heart_beat_control((cy_as_device_handle)\
+ (handle), (enable), 0, 0)
+
+/* Async version of Heartbeat control */
+EXTERN cy_an_return_status_t
+cy_an_misc_heart_beat_control_e_x(
+ cy_an_device_handle handle,
+ cy_bool enable,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_heart_beat_control_e_x(h, enable, cb, client) \
+ cy_as_misc_heart_beat_control((cy_as_device_handle)(h), \
+ (enable), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Get Gpio */
+EXTERN cy_an_return_status_t
+cy_an_misc_get_gpio_value(
+ cy_an_device_handle handle,
+ cy_an_misc_gpio pin,
+ uint8_t *value
+ ) ;
+#define cy_an_misc_get_gpio_value(handle, pin, value) \
+ cy_as_misc_get_gpio_value((cy_as_device_handle)(handle), \
+ (cy_as_misc_gpio)(pin), (value), 0, 0)
+
+/* Async version of Get Gpio */
+EXTERN cy_an_return_status_t
+cy_an_misc_get_gpio_value_e_x(
+ cy_an_device_handle handle,
+ cy_an_misc_gpio pin,
+ uint8_t *value,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_get_gpio_value_e_x(h, pin, value, cb, client) \
+ cy_as_misc_get_gpio_value((cy_as_device_handle)(h), \
+ (cy_as_misc_gpio)(pin), (value), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Set Gpio */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_gpio_value(
+ cy_an_device_handle handle,
+ cy_an_misc_gpio pin,
+ uint8_t value
+ ) ;
+#define cy_an_misc_set_gpio_value(handle, pin, value) \
+ cy_as_misc_set_gpio_value((cy_as_device_handle)(handle), \
+ (cy_as_misc_gpio)(pin), (value), 0, 0)
+
+/* Async version of Set Gpio */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_gpio_value_e_x(
+ cy_an_device_handle handle,
+ cy_an_misc_gpio pin,
+ uint8_t value,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_set_gpio_value_e_x\
+ (h, pin, value, cb, client) \
+ cy_as_misc_set_gpio_value((cy_as_device_handle)(h), \
+ (cy_as_misc_gpio)(pin), (value), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Enter suspend */
+EXTERN cy_an_return_status_t
+cy_an_misc_enter_suspend(
+ cy_an_device_handle handle,
+ cy_bool usb_wakeup_en,
+ cy_bool gpio_wakeup_en
+ ) ;
+#define cy_an_misc_enter_suspend(handle, usb_wakeup_en, \
+ gpio_wakeup_en) \
+ cy_as_misc_enter_suspend((cy_as_device_handle)(handle), \
+ (usb_wakeup_en), (gpio_wakeup_en), 0, 0)
+
+/* Async version of Enter suspend */
+EXTERN cy_an_return_status_t
+cy_an_misc_enter_suspend_e_x(
+ cy_an_device_handle handle,
+ cy_bool usb_wakeup_en,
+ cy_bool gpio_wakeup_en,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_enter_suspend_e_x(h, usb_en, gpio_en, cb, client)\
+ cy_as_misc_enter_suspend((cy_as_device_handle)(h), (usb_en), \
+ (gpio_en), (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Enter suspend */
+EXTERN cy_an_return_status_t
+cy_an_misc_leave_suspend(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_misc_leave_suspend(handle) \
+ cy_as_misc_leave_suspend((cy_as_device_handle)(handle), 0, 0)
+
+/* Async version of Enter suspend */
+EXTERN cy_an_return_status_t
+cy_an_misc_leave_suspend_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+
+#define cy_an_misc_leave_suspend_e_x(h, cb, client) \
+ cy_as_misc_leave_suspend((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of SetLowSpeedSDFreq */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_low_speed_sd_freq(
+ cy_an_device_handle handle,
+ cy_an_low_speed_sd_freq setting
+ ) ;
+#define cy_an_misc_set_low_speed_sd_freq(h, setting) \
+ cy_as_misc_set_low_speed_sd_freq((cy_as_device_handle)(h), \
+ (cy_as_low_speed_sd_freq)(setting), 0, 0)
+
+/* Async version of SetLowSpeedSDFreq */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_low_speed_sd_freq_e_x(
+ cy_an_device_handle handle,
+ cy_an_low_speed_sd_freq setting,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_set_low_speed_sd_freq_e_x\
+(h, setting, cb, client) \
+ cy_as_misc_set_low_speed_sd_freq((cy_as_device_handle)(h), \
+ (cy_as_low_speed_sd_freq)(setting), \
+ (cy_as_function_callback)(cb), (client))
+
+/* SetHighSpeedSDFreq */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_high_speed_sd_freq(
+ cy_an_device_handle handle,
+ cy_an_high_speed_sd_freq setting,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_misc_set_high_speed_sd_freq(h, setting, cb, client) \
+ cy_as_misc_set_high_speed_sd_freq((cy_as_device_handle)(h), \
+ (cy_as_high_speed_sd_freq)(setting), \
+ (cy_as_function_callback)(cb), (client))
+
+/* ReserveLNABootArea */
+EXTERN cy_an_return_status_t
+cy_an_misc_reserve_l_n_a_boot_area(
+ cy_an_device_handle handle,
+ uint8_t numzones,
+ cy_an_function_callback cb,
+ uint32_t client);
+#define cy_an_misc_reserve_l_n_a_boot_area(h, num, cb, client) \
+ cy_as_misc_reserve_l_n_a_boot_area((cy_as_device_handle)(h), \
+ num, (cy_as_function_callback)(cb), (client))
+
+/* SetSDPowerPolarity */
+EXTERN cy_an_return_status_t
+cy_an_misc_set_sd_power_polarity(
+ cy_an_device_handle handle,
+ cy_an_misc_signal_polarity polarity,
+ cy_an_function_callback cb,
+ uint32_t client);
+#define cy_an_misc_set_sd_power_polarity(h, pol, cb, client) \
+ cy_as_misc_set_sd_power_polarity((cy_as_device_handle)(h), \
+ (cy_as_misc_signal_polarity)(pol), \
+ (cy_as_function_callback)(cb), (client))
+
+#include "cyas_cplus_end.h"
+
+#endif
+
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanregs.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanregs.h
new file mode 100644
index 000000000000..d670291bd24d
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanregs.h
@@ -0,0 +1,180 @@
+/* Cypress West Bridge API header file (cyanregs.h)
+ ## Register and field definitions for the Antioch device.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANREG_H_
+#define _INCLUDED_CYANREG_H_
+
+#if !defined(__doxygen__)
+
+#define CY_AN_MEM_CM_WB_CFG_ID (0x80)
+#define CY_AN_MEM_CM_WB_CFG_ID_VER_MASK (0x000F)
+#define CY_AN_MEM_CM_WB_CFG_ID_HDID_MASK (0xFFF0)
+#define CY_AN_MEM_CM_WB_CFG_ID_HDID_ANTIOCH_VALUE (0xA100)
+#define CY_AN_MEM_CM_WB_CFG_ID_HDID_ASTORIA_FPGA_VALUE (0x6800)
+#define CY_AN_MEM_CM_WB_CFG_ID_HDID_ASTORIA_VALUE (0xA200)
+
+
+#define CY_AN_MEM_RST_CTRL_REG (0x81)
+#define CY_AN_MEM_RST_CTRL_REG_HARD (0x0003)
+#define CY_AN_MEM_RST_CTRL_REG_SOFT (0x0001)
+#define CY_AN_MEM_RST_RSTCMPT (0x0004)
+
+#define CY_AN_MEM_P0_ENDIAN (0x82)
+#define CY_AN_LITTLE_ENDIAN (0x0000)
+#define CY_AN_BIG_ENDIAN (0x0101)
+
+#define CY_AN_MEM_P0_VM_SET (0x83)
+#define CY_AN_MEM_P0_VM_SET_VMTYPE_MASK (0x0007)
+#define CY_AN_MEM_P0_VM_SET_VMTYPE_RAM (0x0005)
+#define CY_AN_MEM_P0_VM_SET_VMTYPE_VMWIDTH (0x0008)
+#define CY_AN_MEM_P0_VM_SET_VMTYPE_FLOWCTRL (0x0010)
+#define CY_AN_MEM_P0_VM_SET_IFMODE (0x0020)
+#define CY_AN_MEM_P0_VM_SET_CFGMODE (0x0040)
+#define CY_AN_MEM_P0_VM_SET_DACKEOB (0x0080)
+#define CY_AN_MEM_P0_VM_SET_OVERRIDE (0x0100)
+#define CY_AN_MEM_P0_VM_SET_INTOVERD (0x0200)
+#define CY_AN_MEM_P0_VM_SET_DRQOVERD (0x0400)
+#define CY_AN_MEM_P0_VM_SET_DRQPOL (0x0800)
+#define CY_AN_MEM_P0_VM_SET_DACKPOL (0x1000)
+
+
+#define CY_AN_MEM_P0_NV_SET (0x84)
+#define CY_AN_MEM_P0_NV_SET_WPSWEN (0x0001)
+#define CY_AN_MEM_P0_NV_SET_WPPOLAR (0x0002)
+
+#define CY_AN_MEM_PMU_UPDATE (0x85)
+#define CY_AN_MEM_PMU_UPDATE_UVALID (0x0001)
+#define CY_AN_MEM_PMU_UPDATE_USBUPDATE (0x0002)
+#define CY_AN_MEM_PMU_UPDATE_SDIOUPDATE (0x0004)
+
+#define CY_AN_MEM_P0_INTR_REG (0x90)
+#define CY_AN_MEM_P0_INTR_REG_MCUINT (0x0020)
+#define CY_AN_MEM_P0_INTR_REG_DRQINT (0x0800)
+#define CY_AN_MEM_P0_INTR_REG_MBINT (0x1000)
+#define CY_AN_MEM_P0_INTR_REG_PMINT (0x2000)
+#define CY_AN_MEM_P0_INTR_REG_PLLLOCKINT (0x4000)
+
+#define CY_AN_MEM_P0_INT_MASK_REG (0x91)
+#define CY_AN_MEM_P0_INT_MASK_REG_MMCUINT (0x0020)
+#define CY_AN_MEM_P0_INT_MASK_REG_MDRQINT (0x0800)
+#define CY_AN_MEM_P0_INT_MASK_REG_MMBINT (0x1000)
+#define CY_AN_MEM_P0_INT_MASK_REG_MPMINT (0x2000)
+#define CY_AN_MEM_P0_INT_MASK_REG_MPLLLOCKINT (0x4000)
+
+#define CY_AN_MEM_MCU_MB_STAT (0x92)
+#define CY_AN_MEM_P0_MCU_MBNOTRD (0x0001)
+
+#define CY_AN_MEM_P0_MCU_STAT (0x94)
+#define CY_AN_MEM_P0_MCU_STAT_CARDINS (0x0001)
+#define CY_AN_MEM_P0_MCU_STAT_CARDREM (0x0002)
+
+#define CY_AN_MEM_PWR_MAGT_STAT (0x95)
+#define CY_AN_MEM_PWR_MAGT_STAT_WAKEUP (0x0001)
+
+#define CY_AN_MEM_P0_RSE_ALLOCATE (0x98)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_SDIOAVI (0x0001)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_SDIOALLO (0x0002)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_NANDAVI (0x0004)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_NANDALLO (0x0008)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_USBAVI (0x0010)
+#define CY_AN_MEM_P0_RSE_ALLOCATE_USBALLO (0x0020)
+
+#define CY_AN_MEM_P0_RSE_MASK (0x9A)
+#define CY_AN_MEM_P0_RSE_MASK_MSDIOBUS_RW (0x0003)
+#define CY_AN_MEM_P0_RSE_MASK_MNANDBUS_RW (0x00C0)
+#define CY_AN_MEM_P0_RSE_MASK_MUSBBUS_RW (0x0030)
+
+#define CY_AN_MEM_P0_DRQ (0xA0)
+#define CY_AN_MEM_P0_DRQ_EP2DRQ (0x0004)
+#define CY_AN_MEM_P0_DRQ_EP3DRQ (0x0008)
+#define CY_AN_MEM_P0_DRQ_EP4DRQ (0x0010)
+#define CY_AN_MEM_P0_DRQ_EP5DRQ (0x0020)
+#define CY_AN_MEM_P0_DRQ_EP6DRQ (0x0040)
+#define CY_AN_MEM_P0_DRQ_EP7DRQ (0x0080)
+#define CY_AN_MEM_P0_DRQ_EP8DRQ (0x0100)
+#define CY_AN_MEM_P0_DRQ_EP9DRQ (0x0200)
+#define CY_AN_MEM_P0_DRQ_EP10DRQ (0x0400)
+#define CY_AN_MEM_P0_DRQ_EP11DRQ (0x0800)
+#define CY_AN_MEM_P0_DRQ_EP12DRQ (0x1000)
+#define CY_AN_MEM_P0_DRQ_EP13DRQ (0x2000)
+#define CY_AN_MEM_P0_DRQ_EP14DRQ (0x4000)
+#define CY_AN_MEM_P0_DRQ_EP15DRQ (0x8000)
+
+#define CY_AN_MEM_P0_DRQ_MASK (0xA1)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP2DRQ (0x0004)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP3DRQ (0x0008)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP4DRQ (0x0010)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP5DRQ (0x0020)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP6DRQ (0x0040)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP7DRQ (0x0080)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP8DRQ (0x0100)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP9DRQ (0x0200)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP10DRQ (0x0400)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP11DRQ (0x0800)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP12DRQ (0x1000)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP13DRQ (0x2000)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP14DRQ (0x4000)
+#define CY_AN_MEM_P0_DRQ_MASK_MEP15DRQ (0x8000)
+
+#define CY_AN_MEM_P0_EP2_DMA_REG (0xA2)
+#define CY_AN_MEM_P0_E_pn_DMA_REG_COUNT_MASK (0x7FF)
+#define CY_AN_MEM_P0_E_pn_DMA_REG_DMAVAL (1 << 12)
+#define CY_AN_MEM_P0_EP3_DMA_REG (0xA3)
+#define CY_AN_MEM_P0_EP4_DMA_REG (0xA4)
+#define CY_AN_MEM_P0_EP5_DMA_REG (0xA5)
+#define CY_AN_MEM_P0_EP6_DMA_REG (0xA6)
+#define CY_AN_MEM_P0_EP7_DMA_REG (0xA7)
+#define CY_AN_MEM_P0_EP8_DMA_REG (0xA8)
+#define CY_AN_MEM_P0_EP9_DMA_REG (0xA9)
+#define CY_AN_MEM_P0_EP10_DMA_REG (0xAA)
+#define CY_AN_MEM_P0_EP11_DMA_REG (0xAB)
+#define CY_AN_MEM_P0_EP12_DMA_REG (0xAC)
+#define CY_AN_MEM_P0_EP13_DMA_REG (0xAD)
+#define CY_AN_MEM_P0_EP14_DMA_REG (0xAE)
+#define CY_AN_MEM_P0_EP15_DMA_REG (0xAF)
+
+#define CY_AN_MEM_IROS_IO_CFG (0xC1)
+#define CY_AN_MEM_IROS_IO_CFG_GPIODRVST_MASK (0x0003)
+#define CY_AN_MEM_IROS_IO_CFG_GPIOSLEW_MASK (0x0004)
+#define CY_AN_MEM_IROS_IO_CFG_PPIODRVST_MASK (0x0018)
+#define CY_AN_MEM_IROS_IO_CFG_PPIOSLEW_MASK (0x0020)
+#define CY_AN_MEM_IROS_IO_CFG_SSIODRVST_MASK (0x0300)
+#define CY_AN_MEM_IROS_IO_CFG_SSIOSLEW_MASK (0x0400)
+#define CY_AN_MEM_IROS_IO_CFG_SNIODRVST_MASK (0x1800)
+#define CY_AN_MEM_IROS_IO_CFG_SNIOSLEW_MASK (0x2000)
+
+#define CY_AN_MEM_PLL_LOCK_LOSS_STAT (0xC4)
+#define CY_AN_MEM_PLL_LOCK_LOSS_STAT_PLLSTAT (0x0800)
+
+#define CY_AN_MEM_P0_MAILBOX0 (0xF0)
+#define CY_AN_MEM_P0_MAILBOX1 (0xF1)
+#define CY_AN_MEM_P0_MAILBOX2 (0xF2)
+#define CY_AN_MEM_P0_MAILBOX3 (0xF3)
+
+#define CY_AN_MEM_MCU_MAILBOX0 (0xF8)
+#define CY_AN_MEM_MCU_MAILBOX1 (0xF9)
+#define CY_AN_MEM_MCU_MAILBOX2 (0xFA)
+#define CY_AN_MEM_MCU_MAILBOX3 (0xFB)
+
+#endif /* !defined(__doxygen__) */
+
+#endif /* _INCLUDED_CYANREG_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyansdkversion.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyansdkversion.h
new file mode 100644
index 000000000000..ac26b9556dda
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyansdkversion.h
@@ -0,0 +1,30 @@
+/* Cypress Antioch Sdk Version file (cyansdkversion.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANSDK_VERSION_H_
+#define _INCLUDED_CYANSDK_VERSION_H_
+
+/* Antioch SDK version 1.3.2 */
+#define CYAN_MAJOR_VERSION (1)
+#define CYAN_MINOR_VERSION (3)
+#define CYAN_BUILD_NUMBER (473)
+
+#endif /*_INCLUDED_CYANSDK_VERSION_H_*/
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanstorage.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanstorage.h
new file mode 100644
index 000000000000..766f94a9c92b
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanstorage.h
@@ -0,0 +1,419 @@
+/* Cypress West Bridge API header file (cyanstorage.h)
+ ## Header for backward compatibility with previous releases of Antioch SDK.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANSTORAGE_H_
+#define _INCLUDED_CYANSTORAGE_H_
+#ifndef __doxygen__
+
+#include "cyanmedia.h"
+#include "cyanmisc.h"
+#include "cyasstorage.h"
+#include "cyas_cplus_start.h"
+
+#define CY_AN_LUN_PHYSICAL_DEVICE (CY_AS_LUN_PHYSICAL_DEVICE)
+#define CY_AN_STORAGE_EP_SIZE (CY_AS_STORAGE_EP_SIZE)
+
+#define cy_an_storage_antioch cy_as_storage_antioch
+#define cy_an_storage_processor cy_as_storage_processor
+#define cy_an_storage_removed cy_as_storage_removed
+#define cy_an_storage_inserted cy_as_storage_inserted
+#define cy_an_sdio_interrupt cy_as_sdio_interrupt
+typedef cy_as_storage_event cy_an_storage_event;
+
+#define cy_an_op_read cy_as_op_read
+#define cy_an_op_write cy_as_op_write
+typedef cy_as_oper_type cy_an_oper_type;
+
+typedef cy_as_device_desc cy_an_device_desc;
+
+typedef cy_as_unit_desc cy_an_unit_desc;
+
+typedef cy_as_storage_callback_dep \
+ cy_an_storage_callback;
+
+typedef cy_as_storage_event_callback_dep \
+ cy_an_storage_event_callback;
+
+#define cy_an_sd_reg_OCR cy_as_sd_reg_OCR
+#define cy_an_sd_reg_CID cy_as_sd_reg_CID
+#define cy_an_sd_reg_CSD cy_as_sd_reg_CSD
+typedef cy_as_sd_card_reg_type \
+ cy_an_sd_card_reg_type;
+
+typedef cy_as_storage_query_device_data_dep \
+ cy_an_storage_query_device_data ;
+
+typedef cy_as_storage_query_unit_data_dep \
+ cy_an_storage_query_unit_data ;
+
+typedef cy_as_storage_sd_reg_read_data \
+ cy_an_storage_sd_reg_read_data;
+
+#define CY_AN_SD_REG_OCR_LENGTH (CY_AS_SD_REG_OCR_LENGTH)
+#define CY_AN_SD_REG_CID_LENGTH (CY_AS_SD_REG_CID_LENGTH)
+#define CY_AN_SD_REG_CSD_LENGTH (CY_AS_SD_REG_CSD_LENGTH)
+#define CY_AN_SD_REG_MAX_RESP_LENGTH \
+ (CY_AS_SD_REG_MAX_RESP_LENGTH)
+
+/**** API Functions ******/
+
+/* Sync version of Storage Start */
+EXTERN cy_an_return_status_t
+cy_an_storage_start(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_storage_start(handle) \
+ cy_as_storage_start((cy_as_device_handle)(handle), 0, 0)
+
+/* Async version of Storage Start */
+EXTERN cy_an_return_status_t
+cy_an_storage_start_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_start_e_x(h, cb, client) \
+ cy_as_storage_start((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Storage Stop */
+EXTERN cy_an_return_status_t
+cy_an_storage_stop(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_storage_stop(handle) \
+ cy_as_storage_stop((cy_as_device_handle)(handle), 0, 0)
+
+/* Async version of Storage Stop */
+EXTERN cy_an_return_status_t
+cy_an_storage_stop_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_stop_e_x(h, cb, client) \
+ cy_as_storage_stop((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Register Call back api */
+EXTERN cy_an_return_status_t
+cy_an_storage_register_callback(
+ cy_an_device_handle handle,
+ cy_an_storage_event_callback callback
+ ) ;
+#define cy_an_storage_register_callback(h, cb) \
+ cy_as_storage_register_callback_dep((cy_as_device_handle)(h), \
+ (cy_as_storage_event_callback_dep)(cb))
+
+/* Sync version of Storage Claim */
+EXTERN cy_an_return_status_t
+cy_an_storage_claim(
+ cy_an_device_handle handle,
+ cy_an_media_type type
+ ) ;
+#define cy_an_storage_claim(h, type) \
+ cy_as_storage_claim_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type))
+
+/* Async version of Storage Claim */
+EXTERN cy_an_return_status_t
+cy_an_storage_claim_e_x(
+ cy_an_device_handle handle,
+ cy_an_media_type *type,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_claim_e_x(h, type_p, cb, client) \
+ cy_as_storage_claim_dep_EX((cy_as_device_handle)(h), \
+ (cy_as_media_type *)(type_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync Version of Storage Release */
+EXTERN cy_an_return_status_t
+cy_an_storage_release(
+ cy_an_device_handle handle,
+ cy_an_media_type type
+ ) ;
+#define cy_an_storage_release(h, type) \
+ cy_as_storage_release_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type))
+
+/* Async Version of Storage Release */
+EXTERN cy_an_return_status_t
+cy_an_storage_release_e_x(
+ cy_an_device_handle handle,
+ cy_an_media_type *type,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_release_e_x(h, type_p, cb, client) \
+ cy_as_storage_release_dep_EX((cy_as_device_handle)(h), \
+ (cy_as_media_type *)(type_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Query Media */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_media(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t *count
+ ) ;
+#define cy_an_storage_query_media(handle, type, count) \
+ cy_as_storage_query_media((cy_as_device_handle)(handle), \
+ (cy_as_media_type)(type), (count), 0, 0)
+
+/* Async version of Query Media */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_media_e_x(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t *count,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_query_media_e_x(h, type, count, cb, client) \
+ cy_as_storage_query_media((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (count), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Query device */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_device(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ cy_an_device_desc *desc_p
+ ) ;
+#define cy_an_storage_query_device(h, type, device, desc_p) \
+ cy_as_storage_query_device_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), (cy_as_device_desc *)(desc_p))
+
+/* Async version of Query device */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_device_e_x(
+ cy_an_device_handle handle,
+ cy_an_storage_query_device_data *data,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_query_device_e_x(h, data, cb, client) \
+ cy_as_storage_query_device_dep_EX((cy_as_device_handle)(h), \
+ (cy_as_storage_query_device_data_dep *)(data), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Query Unit */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_unit(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ uint32_t unit,
+ cy_an_unit_desc *desc_p
+ ) ;
+#define cy_an_storage_query_unit(h, type, device, unit, desc_p) \
+ cy_as_storage_query_unit_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), \
+ (unit), (cy_as_unit_desc *)(desc_p))
+
+/* Async version of Query Unit */
+EXTERN cy_an_return_status_t
+cy_an_storage_query_unit_e_x(
+ cy_an_device_handle handle,
+ cy_an_storage_query_unit_data *data_p,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_query_unit_e_x(h, data_p, cb, client) \
+ cy_as_storage_query_unit_dep_EX((cy_as_device_handle)(h), \
+ (cy_as_storage_query_unit_data_dep *)(data_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of device control */
+EXTERN cy_an_return_status_t
+cy_an_storage_device_control(
+ cy_an_device_handle handle,
+ cy_bool card_detect_en,
+ cy_bool write_prot_en
+ ) ;
+#define cy_an_storage_device_control(handle, \
+ card_detect_en, write_prot_en) \
+ cy_as_storage_device_control_dep((cy_as_device_handle)(handle), \
+ (card_detect_en), (write_prot_en), 0, 0)
+
+/* Async version of device control */
+EXTERN cy_an_return_status_t
+cy_an_storage_device_control_e_x(
+ cy_an_device_handle handle,
+ cy_bool card_detect_en,
+ cy_bool write_prot_en,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_device_control_e_x(h, det_en, prot_en, cb, client) \
+ cy_as_storage_device_control_dep((cy_as_device_handle)(h), (det_en), \
+ (prot_en), (cy_as_function_callback)(cb), (client))
+
+/* Sync Read */
+EXTERN cy_an_return_status_t
+cy_an_storage_read(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ uint32_t unit,
+ uint32_t block,
+ void *data_p,
+ uint16_t num_blocks
+ ) ;
+#define cy_an_storage_read(h, type, device, unit, block, data_p, nblks) \
+ cy_as_storage_read_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), (unit), \
+ (block), (data_p), (nblks))
+
+/* Async Read */
+EXTERN cy_an_return_status_t
+cy_an_storage_read_async(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ uint32_t unit,
+ uint32_t block,
+ void *data_p,
+ uint16_t num_blocks,
+ cy_an_storage_callback callback
+ ) ;
+#define cy_an_storage_read_async(h, type, device, unit, \
+ block, data_p, nblks, cb) \
+ cy_as_storage_read_async_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), (unit), (block), \
+ (data_p), (nblks), (cy_as_storage_callback_dep)(cb))
+
+/* Sync Write */
+EXTERN cy_an_return_status_t
+cy_an_storage_write(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ uint32_t unit,
+ uint32_t block,
+ void *data_p,
+ uint16_t num_blocks
+ ) ;
+#define cy_an_storage_write(h, type, device, unit, \
+ block, data_p, nblks) \
+ cy_as_storage_write_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), (unit), \
+ (block), (data_p), (nblks))
+
+/* Async Write */
+EXTERN cy_an_return_status_t
+cy_an_storage_write_async(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint32_t device,
+ uint32_t unit,
+ uint32_t block,
+ void *data_p,
+ uint16_t num_blocks,
+ cy_an_storage_callback callback
+ ) ;
+#define cy_an_storage_write_async(h, type, device, unit, \
+ block, data_p, nblks, cb) \
+ cy_as_storage_write_async_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), (unit), (block), \
+ (data_p), (nblks), (cy_as_storage_callback_dep)(cb))
+
+/* Cancel Async */
+EXTERN cy_an_return_status_t
+cy_an_storage_cancel_async(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_storage_cancel_async(h) \
+ cy_as_storage_cancel_async((cy_as_device_handle)(h))
+
+/* Sync SD Register Read*/
+EXTERN cy_an_return_status_t
+cy_an_storage_sd_register_read(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint8_t device,
+ cy_an_sd_card_reg_type reg_type,
+ uint8_t read_len,
+ uint8_t *data_p
+ ) ;
+#define cy_an_storage_sd_register_read(h, type, device, \
+ reg_type, len, data_p) \
+ cy_as_storage_sd_register_read_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), \
+ (cy_as_sd_card_reg_type)(reg_type), (len), (data_p))
+
+/*Async SD Register Read*/
+EXTERN cy_an_return_status_t
+cy_an_storage_sd_register_read_e_x(
+ cy_an_device_handle handle,
+ cy_an_media_type type,
+ uint8_t device,
+ cy_an_sd_card_reg_type reg_type,
+ cy_an_storage_sd_reg_read_data *data_p,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_storage_sd_register_read_e_x(h, type, device, \
+ reg_type, data_p, cb, client) \
+ cy_as_storage_sd_register_read_dep_EX((cy_as_device_handle)(h), \
+ (cy_as_media_type)(type), (device), \
+ (cy_as_sd_card_reg_type)(reg_type), \
+ (cy_as_storage_sd_reg_read_data *)(data_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Create partition on storage device */
+EXTERN cy_an_return_status_t
+cy_an_storage_create_p_partition(
+ cy_an_device_handle handle,
+ cy_an_media_type media,
+ uint32_t device,
+ uint32_t size,
+ cy_an_function_callback cb,
+ uint32_t client) ;
+#define cy_an_storage_create_p_partition(h, media, dev, \
+ size, cb, client) \
+ cy_as_storage_create_p_partition_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(media), (dev), \
+ (size), (cy_as_function_callback)(cb), (client))
+
+/* Remove partition on storage device */
+EXTERN cy_an_return_status_t
+cy_an_storage_remove_p_partition(
+ cy_an_device_handle handle,
+ cy_an_media_type media,
+ uint32_t device,
+ cy_an_function_callback cb,
+ uint32_t client) ;
+#define cy_an_storage_remove_p_partition\
+(h, media, dev, cb, client) \
+ cy_as_storage_remove_p_partition_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(media), (dev), \
+ (cy_as_function_callback)(cb), (client))
+
+#include "cyas_cplus_end.h"
+#endif /*__doxygen__ */
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantioch.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantioch.h
new file mode 100644
index 000000000000..d65b35a14ae1
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantioch.h
@@ -0,0 +1,35 @@
+/* Cypress West Bridge API header file (cyastioch.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANTIOCH_H_
+#define _INCLUDED_CYANTIOCH_H_
+
+#if !defined(__doxygen__)
+
+#include "cyanerr.h"
+#include "cyanmisc.h"
+#include "cyanstorage.h"
+#include "cyanusb.h"
+#include "cyanch9.h"
+
+#endif
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantypes.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantypes.h
new file mode 100644
index 000000000000..d6028d64d247
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyantypes.h
@@ -0,0 +1,31 @@
+/* Cypress West Bridge API header file (cyantypes.h)
+## Type definitions for backward compatibility with previous
+## Antioch SDK releases.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANTYPES_H_
+#define _INCLUDED_CYANTYPES_H_
+
+#include "cyastypes.h"
+typedef cy_as_end_point_number_t cy_an_end_point_number_t ;
+typedef cy_as_return_status_t cy_an_return_status_t ;
+typedef cy_as_bus_number_t cy_an_bus_number_t ;
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanusb.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanusb.h
new file mode 100644
index 000000000000..0777fd457d49
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyanusb.h
@@ -0,0 +1,619 @@
+/* Cypress West Bridge API header file (cyanusb.h)
+ ## Header for backward compatibility with previous Antioch SDK releases.
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYANUSB_H_
+#define _INCLUDED_CYANUSB_H_
+
+#if !defined(__doxygen__)
+
+#include "cyanmisc.h"
+#include "cyasusb.h"
+#include "cyas_cplus_start.h"
+
+#define CY_AN_MAX_USB_DESCRIPTOR_SIZE (CY_AS_MAX_USB_DESCRIPTOR_SIZE)
+
+typedef cy_as_usb_inquiry_data_dep cy_an_usb_inquiry_data;
+typedef cy_as_usb_unknown_command_data_dep \
+ cy_an_usb_unknown_command_data ;
+typedef cy_as_usb_start_stop_data_dep cy_an_usb_start_stop_data ;
+typedef cy_as_m_s_c_progress_data cy_an_m_s_c_progress_data ;
+
+#define cy_an_usb_nand_enum cy_as_usb_nand_enum
+#define cy_an_usb_sd_enum cy_as_usb_sd_enum
+#define cy_an_usb_mmc_enum cy_as_usb_mmc_enum
+#define cy_an_usb_ce_ata_enum cy_as_usb_ce_ata_enum
+typedef cy_as_usb_mass_storage_enum cy_an_usb_mass_storage_enum;
+
+#define cy_an_usb_desc_device cy_as_usb_desc_device
+#define cy_an_usb_desc_device_qual cy_as_usb_desc_device_qual
+#define cy_an_usb_desc_f_s_configuration \
+ cy_as_usb_desc_f_s_configuration
+#define cy_an_usb_desc_h_s_configuration \
+ cy_as_usb_desc_h_s_configuration
+#define cy_an_usb_desc_string cy_as_usb_desc_string
+typedef cy_as_usb_desc_type cy_an_usb_desc_type ;
+
+#define cy_an_usb_in cy_as_usb_in
+#define cy_an_usb_out cy_as_usb_out
+#define cy_an_usb_in_out cy_as_usb_in_out
+typedef cy_as_usb_end_point_dir cy_an_usb_end_point_dir ;
+
+
+#define cy_an_usb_control cy_as_usb_control
+#define cy_an_usb_iso cy_as_usb_iso
+#define cy_an_usb_bulk cy_as_usb_bulk
+#define cy_an_usb_int cy_as_usb_int
+typedef cy_as_usb_end_point_type cy_an_usb_end_point_type ;
+
+
+typedef cy_as_usb_enum_control_dep cy_an_usb_enum_control ;
+typedef cy_as_usb_end_point_config cy_an_usb_end_point_config ;
+
+#define cy_an_usb_m_s_unit0 cy_as_usb_m_s_unit0
+#define cy_an_usb_m_s_unit1 cy_as_usb_m_s_unit1
+#define cy_an_usb_m_s_both cy_as_usb_m_s_both
+typedef cy_as_usb_m_s_type_t cy_an_usb_m_s_type_t ;
+
+#define cy_an_event_usb_suspend cy_as_event_usb_suspend
+#define cy_an_event_usb_resume cy_as_event_usb_resume
+#define cy_an_event_usb_reset cy_as_event_usb_reset
+#define cy_an_event_usb_set_config cy_as_event_usb_set_config
+#define cy_an_event_usb_speed_change cy_as_event_usb_speed_change
+#define cy_an_event_usb_setup_packet cy_as_event_usb_setup_packet
+#define cy_an_event_usb_status_packet cy_as_event_usb_status_packet
+#define cy_an_event_usb_inquiry_before cy_as_event_usb_inquiry_before
+#define cy_an_event_usb_inquiry_after cy_as_event_usb_inquiry_after
+#define cy_an_event_usb_start_stop cy_as_event_usb_start_stop
+#define cy_an_event_usb_unknown_storage cy_as_event_usb_unknown_storage
+#define cy_an_event_usb_m_s_c_progress cy_as_event_usb_m_s_c_progress
+typedef cy_as_usb_event cy_an_usb_event;
+
+typedef cy_as_usb_event_callback_dep cy_an_usb_event_callback ;
+
+typedef cy_as_usb_io_callback cy_an_usb_io_callback;
+typedef cy_as_usb_function_callback cy_an_usb_function_callback;
+
+/******* USB Functions ********************/
+
+/* Sync Usb Start */
+extern cy_an_return_status_t
+cy_an_usb_start(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_start(handle) \
+ cy_as_usb_start((cy_as_device_handle)(handle), 0, 0)
+
+/*Async Usb Start */
+extern cy_an_return_status_t
+cy_an_usb_start_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_start_e_x(h, cb, client) \
+ cy_as_usb_start((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync Usb Stop */
+extern cy_an_return_status_t
+cy_an_usb_stop(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_stop(handle) \
+ cy_as_usb_stop((cy_as_device_handle)(handle), 0, 0)
+
+/*Async Usb Stop */
+extern cy_an_return_status_t
+cy_an_usb_stop_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_stop_e_x(h, cb, client) \
+ cy_as_usb_stop((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Register USB event callback */
+EXTERN cy_an_return_status_t
+cy_an_usb_register_callback(
+ cy_an_device_handle handle,
+ cy_an_usb_event_callback callback
+ ) ;
+#define cy_an_usb_register_callback(h, cb) \
+ cy_as_usb_register_callback_dep((cy_as_device_handle)(h), \
+ (cy_as_usb_event_callback_dep)(cb))
+
+/*Sync Usb connect */
+EXTERN cy_an_return_status_t
+cy_an_usb_connect(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_connect(handle) \
+ cy_as_usb_connect((cy_as_device_handle)(handle), 0, 0)
+
+/*Async Usb connect */
+extern cy_an_return_status_t
+cy_an_usb_connect_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_connect_e_x(h, cb, client) \
+ cy_as_usb_connect((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/*Sync Usb disconnect */
+EXTERN cy_an_return_status_t
+cy_an_usb_disconnect(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_disconnect(handle) \
+ cy_as_usb_disconnect((cy_as_device_handle)(handle), 0, 0)
+
+/*Async Usb disconnect */
+extern cy_an_return_status_t
+cy_an_usb_disconnect_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_disconnect_e_x(h, cb, client) \
+ cy_as_usb_disconnect((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of set enum config */
+EXTERN cy_an_return_status_t
+cy_an_usb_set_enum_config(
+ cy_an_device_handle handle,
+ cy_an_usb_enum_control *config_p
+ ) ;
+#define cy_an_usb_set_enum_config(handle, config_p) \
+ cy_as_usb_set_enum_config_dep((cy_as_device_handle)(handle), \
+ (cy_as_usb_enum_control_dep *)(config_p), 0, 0)
+
+/* Async version of set enum config */
+extern cy_an_return_status_t
+cy_an_usb_set_enum_config_e_x(
+ cy_an_device_handle handle,
+ cy_an_usb_enum_control *config_p,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_set_enum_config_e_x(h, config_p, cb, client) \
+ cy_as_usb_set_enum_config_dep((cy_as_device_handle)(h), \
+ (cy_as_usb_enum_control_dep *)(config_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of get enum config */
+EXTERN cy_an_return_status_t
+cy_an_usb_get_enum_config(
+ cy_an_device_handle handle,
+ cy_an_usb_enum_control *config_p
+ ) ;
+#define cy_an_usb_get_enum_config(handle, config_p) \
+ cy_as_usb_get_enum_config_dep((cy_as_device_handle)(handle), \
+ (cy_as_usb_enum_control_dep *)(config_p), 0, 0)
+
+/* Async version of get enum config */
+extern cy_an_return_status_t
+cy_an_usb_get_enum_config_e_x(
+ cy_an_device_handle handle,
+ cy_an_usb_enum_control *config_p,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_get_enum_config_e_x(h, config_p, cb, client) \
+ cy_as_usb_get_enum_config_dep((cy_as_device_handle)(h), \
+ (cy_as_usb_enum_control_dep *)(config_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync Version of Set descriptor */
+EXTERN cy_an_return_status_t
+cy_an_usb_set_descriptor(
+ cy_an_device_handle handle,
+ cy_an_usb_desc_type type,
+ uint8_t index,
+ void *desc_p,
+ uint16_t length
+ ) ;
+#define cy_an_usb_set_descriptor(handle, type, index, desc_p, length) \
+ cy_as_usb_set_descriptor((cy_as_device_handle)(handle), \
+ (cy_as_usb_desc_type)(type), (index), (desc_p), (length), 0, 0)
+
+/* Async Version of Set descriptor */
+extern cy_an_return_status_t
+cy_an_usb_set_descriptor_e_x(
+ cy_an_device_handle handle,
+ cy_an_usb_desc_type type,
+ uint8_t index,
+ void *desc_p,
+ uint16_t length,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_set_descriptor_e_x\
+ (h, type, index, desc_p, length, cb, client) \
+ cy_as_usb_set_descriptor((cy_as_device_handle)(h), \
+ (cy_as_usb_desc_type)(type), (index), (desc_p), (length), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Only version of clear descriptors */
+EXTERN cy_an_return_status_t
+cy_an_usb_clear_descriptors(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_clear_descriptors(h, cb, client) \
+ cy_as_usb_clear_descriptors((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of get descriptor*/
+EXTERN cy_an_return_status_t
+cy_an_usb_get_descriptor(
+ cy_an_device_handle handle,
+ cy_an_usb_desc_type type,
+ uint8_t index,
+ void *desc_p,
+ uint32_t *length_p
+ ) ;
+#define cy_an_usb_get_descriptor(h, type, index, desc_p, length_p) \
+ cy_as_usb_get_descriptor_dep((cy_as_device_handle)(h), \
+ (cy_as_usb_desc_type)(type), (index), (desc_p), (length_p))
+
+typedef cy_as_get_descriptor_data cy_an_get_descriptor_data ;
+
+/* Async version of get descriptor */
+extern cy_an_return_status_t
+cy_an_usb_get_descriptor_e_x(
+ cy_an_device_handle handle,
+ cy_an_usb_desc_type type,
+ uint8_t index,
+ cy_an_get_descriptor_data *data,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_get_descriptor_e_x\
+ (h, type, index, data, cb, client) \
+ cy_as_usb_get_descriptor((cy_as_device_handle)(h), \
+ (cy_as_usb_desc_type)(type), (index), \
+ (cy_as_get_descriptor_data *)(data), \
+ (cy_as_function_callback)(cb), (client))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_set_physical_configuration(
+ cy_an_device_handle handle,
+ uint8_t config
+ ) ;
+#define cy_an_usb_set_physical_configuration(h, config) \
+ cy_as_usb_set_physical_configuration\
+ ((cy_as_device_handle)(h), (config))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_set_end_point_config(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_end_point_config *config_p
+ ) ;
+#define cy_an_usb_set_end_point_config(h, ep, config_p) \
+ cy_as_usb_set_end_point_config((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_end_point_config *)(config_p))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_get_end_point_config(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_end_point_config *config_p
+ ) ;
+#define cy_an_usb_get_end_point_config(h, ep, config_p) \
+ cy_as_usb_get_end_point_config((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_end_point_config *)(config_p))
+
+/* Sync version of commit */
+EXTERN cy_an_return_status_t
+cy_an_usb_commit_config(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_commit_config(handle) \
+ cy_as_usb_commit_config((cy_as_device_handle)(handle), 0, 0)
+
+/* Async version of commit */
+extern cy_an_return_status_t
+cy_an_usb_commit_config_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_commit_config_e_x(h, cb, client) \
+ cy_as_usb_commit_config((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_read_data(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool pktread,
+ uint32_t dsize,
+ uint32_t *dataread,
+ void *data
+ ) ;
+#define cy_an_usb_read_data(h, ep, pkt, dsize, dataread, data_p) \
+ cy_as_usb_read_data((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (pkt), (dsize), \
+ (dataread), (data_p))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_read_data_async(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool pktread,
+ uint32_t dsize,
+ void *data,
+ cy_an_usb_io_callback callback
+ ) ;
+#define cy_an_usb_read_data_async(h, ep, pkt, dsize, data_p, cb) \
+ cy_as_usb_read_data_async((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (pkt), (dsize), (data_p), \
+ (cy_as_usb_io_callback)(cb))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_write_data(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ uint32_t dsize,
+ void *data
+ ) ;
+#define cy_an_usb_write_data(h, ep, dsize, data_p) \
+ cy_as_usb_write_data((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (dsize), (data_p))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_write_data_async(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ uint32_t dsize,
+ void *data,
+ cy_bool spacket,
+ cy_an_usb_io_callback callback
+ ) ;
+#define cy_an_usb_write_data_async(h, ep, dsize, data_p, spacket, cb) \
+ cy_as_usb_write_data_async((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (dsize), (data_p), (spacket), \
+ (cy_as_usb_io_callback)(cb))
+
+EXTERN cy_an_return_status_t
+cy_an_usb_cancel_async(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep
+ ) ;
+#define cy_an_usb_cancel_async(h, ep) \
+ cy_as_usb_cancel_async((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep))
+
+/* Sync version of set stall */
+EXTERN cy_an_return_status_t
+cy_an_usb_set_stall(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_function_callback cb,
+ uint32_t client
+) ;
+#define cy_an_usb_set_stall(h, ep, cb, client) \
+ cy_as_usb_set_stall_dep((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_function_callback)(cb), (client))
+
+/* Async version of set stall */
+extern cy_an_return_status_t
+cy_an_usb_set_stall_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_function_callback cb,
+ uint32_t client
+) ;
+#define cy_an_usb_set_stall_e_x(h, ep, cb, client) \
+ cy_as_usb_set_stall((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_function_callback)(cb), (client))
+
+/*Sync version of clear stall */
+EXTERN cy_an_return_status_t
+cy_an_usb_clear_stall(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_clear_stall(h, ep, cb, client) \
+ cy_as_usb_clear_stall_dep((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_function_callback)(cb), (client))
+
+/*Sync version of clear stall */
+extern cy_an_return_status_t
+cy_an_usb_clear_stall_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_clear_stall_e_x(h, ep, cb, client) \
+ cy_as_usb_clear_stall((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync get stall */
+EXTERN cy_an_return_status_t
+cy_an_usb_get_stall(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool *stall_p
+ ) ;
+#define cy_an_usb_get_stall(handle, ep, stall_p) \
+ cy_as_usb_get_stall((cy_as_device_handle)(handle), \
+ (cy_as_end_point_number_t)(ep), (stall_p), 0, 0)
+
+/* Async get stall */
+extern cy_an_return_status_t
+cy_an_usb_get_stall_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool *stall_p,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_get_stall_e_x(h, ep, stall_p, cb, client) \
+ cy_as_usb_get_stall((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (stall_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of Set Nak */
+EXTERN cy_an_return_status_t
+cy_an_usb_set_nak(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_function_callback cb,
+ uint32_t client
+) ;
+
+#define cy_an_usb_set_nak(h, ep, cb, client) \
+ cy_as_usb_set_nak_dep((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_function_callback)(cb), (client))
+
+/* Async version of Set Nak */
+extern cy_an_return_status_t
+cy_an_usb_set_nak_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_function_callback cb,
+ uint32_t client
+) ;
+#define cy_an_usb_set_nak_e_x(h, ep, cb, client) \
+ cy_as_usb_set_nak((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync version of clear nak */
+EXTERN cy_an_return_status_t
+cy_an_usb_clear_nak(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_usb_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_clear_nak(h, ep, cb, client) \
+ cy_as_usb_clear_nak_dep((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_usb_function_callback)(cb), (client))
+
+/* Sync version of clear nak */
+extern cy_an_return_status_t
+cy_an_usb_clear_nak_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_clear_nak_e_x(h, ep, cb, client) \
+ cy_as_usb_clear_nak((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync Get NAK */
+EXTERN cy_an_return_status_t
+cy_an_usb_get_nak(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool *nak_p
+) ;
+#define cy_an_usb_get_nak(handle, ep, nak_p) \
+ cy_as_usb_get_nak((cy_as_device_handle)(handle), \
+ (cy_as_end_point_number_t)(ep), (nak_p), 0, 0)
+
+/* Async Get NAK */
+EXTERN cy_an_return_status_t
+cy_an_usb_get_nak_e_x(
+ cy_an_device_handle handle,
+ cy_an_end_point_number_t ep,
+ cy_bool *nak_p,
+ cy_an_function_callback cb,
+ uint32_t client
+) ;
+#define cy_an_usb_get_nak_e_x(h, ep, nak_p, cb, client) \
+ cy_as_usb_get_nak((cy_as_device_handle)(h), \
+ (cy_as_end_point_number_t)(ep), (nak_p), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Sync remote wakup */
+EXTERN cy_an_return_status_t
+cy_an_usb_signal_remote_wakeup(
+ cy_an_device_handle handle
+ ) ;
+#define cy_an_usb_signal_remote_wakeup(handle) \
+ cy_as_usb_signal_remote_wakeup((cy_as_device_handle)(handle), 0, 0)
+
+/* Async remote wakup */
+EXTERN cy_an_return_status_t
+cy_an_usb_signal_remote_wakeup_e_x(
+ cy_an_device_handle handle,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_signal_remote_wakeup_e_x(h, cb, client) \
+ cy_as_usb_signal_remote_wakeup((cy_as_device_handle)(h), \
+ (cy_as_function_callback)(cb), (client))
+
+/* Only version of SetMSReportThreshold */
+EXTERN cy_an_return_status_t
+cy_an_usb_set_m_s_report_threshold(
+ cy_an_device_handle handle,
+ uint32_t wr_sectors,
+ uint32_t rd_sectors,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_set_m_s_report_threshold\
+ (h, wr_cnt, rd_cnt, cb, client) \
+ cy_as_usb_set_m_s_report_threshold((cy_as_device_handle)(h), \
+ wr_cnt, rd_cnt, (cy_as_function_callback)(cb), (client))
+
+/* Select storage partitions to be enumerated. */
+EXTERN cy_an_return_status_t
+cy_an_usb_select_m_s_partitions(
+ cy_an_device_handle handle,
+ cy_an_media_type media,
+ uint32_t device,
+ cy_an_usb_m_s_type_t type,
+ cy_an_function_callback cb,
+ uint32_t client
+ ) ;
+#define cy_an_usb_select_m_s_partitions(h, media, dev, type, cb, client) \
+ cy_as_usb_select_m_s_partitions_dep((cy_as_device_handle)(h), \
+ (cy_as_media_type)(media), (dev), \
+ (cy_as_usb_m_s_type_t)(type), (cy_as_function_callback)(cb), (client))
+
+#include "cyas_cplus_end.h"
+#endif /*__doxygen__*/
+#endif /*_INCLUDED_CYANUSB_H_*/
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_end.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_end.h
new file mode 100644
index 000000000000..ece44ca34f3b
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_end.h
@@ -0,0 +1,11 @@
+/*
+ * This file is included at the end of other include files.
+ * It basically turns off the C++ specific code words that
+ * insure this code is seen as C code even within
+ * a C++ compiler.
+ *
+ */
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_start.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_start.h
new file mode 100644
index 000000000000..b879cefa9d6b
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyas_cplus_start.h
@@ -0,0 +1,11 @@
+/*
+ * This file is included after all other headers files, but before any other
+ * definitions in the file. It basically insures that the definitions within
+ * the file are seen as C defintions even when compiled by a C++ compiler.
+ */
+
+#ifdef __cplusplus
+
+extern "C" {
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyascast.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyascast.h
new file mode 100644
index 000000000000..5f8c852fbb41
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyascast.h
@@ -0,0 +1,35 @@
+/* Cypress West Bridge API header file (cyascast.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASCAST_H_
+#define _INCLUDED_CYASCAST_H_
+
+#ifndef __doxygen__
+
+#ifdef _DEBUG
+#define cy_cast_int2U_int16(v) \
+ (cy_as_hal_assert(v < 65536), (uint16_t)(v))
+#else /* _DEBUG */
+#define cy_cast_int2U_int16(v) ((uint16_t)(v))
+#endif /* _DEBUG */
+
+#endif /* __doxygen__ */
+#endif /* _INCLUDED_CYASCAST_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdevice.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdevice.h
new file mode 100644
index 000000000000..b17c985ed0ae
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdevice.h
@@ -0,0 +1,1057 @@
+/* Cypress West Bridge API header file (cyasdevice.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+##Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef __INCLUDED_CYASDEVICE_H__
+#define __INCLUDED_CYASDEVICE_H__
+
+#include "cyashal.h"
+#include "cyasprotocol.h"
+#include "cyasusb.h"
+#include "cyasstorage.h"
+#include "cyasmtp.h"
+#include "cyas_cplus_start.h"
+
+/***********************************
+ * West Bridge Constants
+ ***********************************/
+
+/* The endpoints used by West Bridge for the P port to S port path */
+#define CY_AS_P2S_WRITE_ENDPOINT (0x04)
+#define CY_AS_P2S_READ_ENDPOINT (0x08)
+
+/* The endpoint to use for firmware download */
+#define CY_AS_FIRMWARE_ENDPOINT (0x02)
+
+/* The maximum size of the firmware image West Bridge can accept */
+#define CY_AS_MAXIMUM_FIRMWARE_SIZE (24 * 1024)
+
+/* The maximum size of a write for EP0 and EP1 */
+#define CY_AS_EP0_MAX_WRITE_SIZE (128)
+#define CY_AS_EP1_MAX_WRITE_SIZE (64)
+
+/* The bitfields for the device state value */
+
+/* The device is in StandBy mode */
+#define CY_AS_DEVICE_STATE_PIN_STANDBY (0x00000001)
+/* The device has been configured */
+#define CY_AS_DEVICE_STATE_CONFIGURED (0x00000002)
+/* The firmware has been loaded into the device */
+#define CY_AS_DEVICE_STATE_FIRMWARE_LOADED (0x00000004)
+/* The interrupt module has been initialized */
+#define CY_AS_DEVICE_STATE_LOWLEVEL_MODULE (0x00000008)
+/* The DMA module has been initialized */
+#define CY_AS_DEVICE_STATE_DMA_MODULE (0x00000010)
+/* The interrupt module has been initialized */
+#define CY_AS_DEVICE_STATE_INTR_MODULE (0x00000020)
+/* The storage module has been initialized */
+#define CY_AS_DEVICE_STATE_STORAGE_MODULE (0x00000040)
+/* The USB module has been initialized */
+#define CY_AS_DEVICE_STATE_USB_MODULE (0x00000080)
+/* If set, the API wants SCSI messages */
+#define CY_AS_DEVICE_STATE_STORAGE_SCSIMSG (0x00000100)
+/* If set, an ASYNC storage operation is pending */
+#define CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING (0x00000200)
+/* If set, the USB port is connected */
+#define CY_AS_DEVICE_STATE_USB_CONNECTED (0x00000400)
+/* If set and USB is connected, it is high speed */
+#define CY_AS_DEVICE_STATE_USB_HIGHSPEED (0x00000800)
+/* If set, we are in a callback */
+#define CY_AS_DEVICE_STATE_IN_CALLBACK (0x00001000)
+/* If set, we are processing a setup packet */
+#define CY_AS_DEVICE_STATE_IN_SETUP_PACKET (0x00004000)
+/* The device was placed in standby via register */
+#define CY_AS_DEVICE_STATE_REGISTER_STANDBY (0x00008000)
+/* If set, the device is using a crystal */
+#define CY_AS_DEVICE_STATE_CRYSTAL (0x00010000)
+/* If set, wakeup has been called */
+#define CY_AS_DEVICE_STATE_WAKING (0x00020000)
+/* If set, EP0 has been stalled. */
+#define CY_AS_DEVICE_STATE_EP0_STALLED (0x00040000)
+/* If set, device is in suspend mode. */
+#define CY_AS_DEVICE_STATE_SUSPEND (0x00080000)
+/* If set, device is a reset is pending. */
+#define CY_AS_DEVICE_STATE_RESETP (0x00100000)
+/* If set, device is a standby is pending. */
+#define CY_AS_DEVICE_STATE_STANDP (0x00200000)
+/* If set, device has a storage start or stop pending. */
+#define CY_AS_DEVICE_STATE_SSSP (0x00400000)
+/* If set, device has a usb start or stop pending. */
+#define CY_AS_DEVICE_STATE_USSP (0x00800000)
+/* If set, device has a mtp start or stop pending. */
+#define CY_AS_DEVICE_STATE_MSSP (0x01000000)
+/* If set, P2S DMA transfer can be started. */
+#define CY_AS_DEVICE_STATE_P2SDMA_START (0x02000000)
+
+/* The bitfields for the endpoint state value */
+/* DMA requests are accepted into the queue */
+#define CY_AS_DMA_ENDPOINT_STATE_ENABLED (0x0001)
+/* The endpoint has a sleeping client, waiting on a queue drain */
+#define CY_AS_DMA_ENDPOINT_STATE_SLEEPING (0x0002)
+/* The DMA backend to hardware is running */
+#define CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING (0x0004)
+/* There is an outstanding DMA entry deployed to the HAL */
+#define CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT (0x0008)
+/* 0 = OUT (West Bridge -> P Port), 1 = IN (P Port -> West Bridge) */
+#define CY_AS_DMA_ENDPOINT_STATE_DIRECTION (0x0010)
+
+/* The state values for the request list */
+/* Mask for getting the state information */
+#define CY_AS_REQUEST_LIST_STATE_MASK (0x0f)
+/* The request is queued, nothing further */
+#define CY_AS_REQUEST_LIST_STATE_QUEUED (0x00)
+/* The request is sent, waiting for response */
+#define CY_AS_REQUEST_LIST_STATE_WAITING (0x01)
+/* The response has been received, processing reponse */
+#define CY_AS_REQUEST_LIST_STATE_RECEIVED (0x02)
+/* The request/response is being canceled */
+#define CY_AS_REQUEST_LIST_STATE_CANCELING (0x03)
+/* The request is synchronous */
+#define CY_AS_REQUEST_LIST_STATE_SYNC (0x80)
+
+/* The flag values for a LL RequestResponse */
+/* This request requires an ACK to be sent after it is completed */
+#define CY_AS_REQUEST_RESPONSE_DELAY_ACK (0x01)
+/* This request originated from a version V1.1 function call */
+#define CY_AS_REQUEST_RESPONSE_EX (0x02)
+/* This request originated from a version V1.2 function call */
+#define CY_AS_REQUEST_RESPONSE_MS (0x04)
+
+
+#define CY_AS_DEVICE_HANDLE_SIGNATURE (0x01211219)
+
+/*
+ * This macro returns the endpoint pointer given the
+ * device pointer and an endpoint number
+ */
+#define CY_AS_NUM_EP(dev_p, num) ((dev_p)->endp[(num)])
+
+/****************************************
+ * West Bridge Data Structures
+ ****************************************/
+
+typedef struct cy_as_device cy_as_device ;
+
+/* Summary
+ This type defines a callback function that will be called
+ on completion of a DMA operation.
+
+ Description
+ This function definition is for a function that is called when
+ the DMA operation is complete. This function is called with the
+ endpoint number, operation type, buffer pointer and size.
+
+ See Also
+ * CyAsDmaOper
+ * CyAsDmaQueueWrite
+ */
+typedef void (*cy_as_dma_callback)(
+ /* The device that completed DMA */
+ cy_as_device *dev_p,
+ /* The endpoint that completed DMA */
+ cy_as_end_point_number_t ep,
+ /* The pointer to the buffer that completed DMA */
+ void *mem_p,
+ /* The amount of data transferred */
+ uint32_t size,
+ /* The error code for this DMA xfer */
+ cy_as_return_status_t error
+ ) ;
+
+/* Summary
+ This structure defines a DMA request that is queued
+
+ Description
+ This structure contains the information about a DMA
+ request that is queued and is to be sent when possible.
+*/
+typedef struct cy_as_dma_queue_entry {
+ /* Pointer to memory buffer for this request */
+ void *buf_p ;
+ /* Size of the memory buffer for DMA operation */
+ uint32_t size ;
+ /* Offset into memory buffer for next DMA operation */
+ uint32_t offset ;
+ /* If TRUE and IN request */
+ cy_bool packet ;
+ /* If TRUE, this is a read request */
+ cy_bool readreq ;
+ /* Callback function for when DMA is complete */
+ cy_as_dma_callback cb ;
+ /* Pointer to next entry in queue */
+ struct cy_as_dma_queue_entry *next_p ;
+} cy_as_dma_queue_entry ;
+
+/* Summary
+ This structure defines the endpoint data for a given
+
+ Description
+ This structure defines all of the information required
+ to manage DMA for a given endpoint.
+*/
+typedef struct cy_as_dma_end_point {
+ /* The endpoint number */
+ cy_as_end_point_number_t ep ;
+ /* The state of this endpoint */
+ uint8_t state ;
+ /* The maximum amount of data accepted in a packet by the hw */
+ uint16_t maxhwdata ;
+ /* The maximum amount of data accepted by the HAL layer */
+ uint32_t maxhaldata ;
+ /* The queue for DMA operations */
+ cy_as_dma_queue_entry *queue_p ;
+ /* The last entry in the DMA queue */
+ cy_as_dma_queue_entry *last_p ;
+ /* This sleep channel is used to wait while the DMA queue
+ * drains for a given endpoint */
+ cy_as_hal_sleep_channel channel ;
+} cy_as_dma_end_point ;
+
+#define cy_as_end_point_number_is_usb(n) \
+ ((n) != 2 && (n) != 4 && (n) != 6 && (n) != 8)
+#define cy_as_end_point_number_is_storage(n) \
+ ((n) == 2 || (n) == 4 || (n) == 6 || (n) == 8)
+
+#define cy_as_dma_end_point_is_enabled(ep) \
+ ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_ENABLED)
+#define cy_as_dma_end_point_enable(ep) \
+ ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_ENABLED)
+#define cy_as_dma_end_point_disable(ep) \
+ ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_ENABLED)
+
+#define cy_as_dma_end_point_is_sleeping(ep) \
+ ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
+#define cy_as_dma_end_point_set_sleep_state(ep) \
+ ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
+#define cy_as_dma_end_point_set_wake_state(ep) \
+ ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
+
+#define cy_as_dma_end_point_is_running(ep) \
+ ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
+#define cy_as_dma_end_point_set_running(ep) \
+ ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
+#define cy_as_dma_end_point_set_stopped(ep) \
+ ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
+
+#define cy_as_dma_end_point_in_transit(ep) \
+ ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
+#define cy_as_dma_end_point_set_in_transit(ep) \
+ ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
+#define cy_as_dma_end_point_clear_in_transit(ep) \
+ ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
+
+#define cy_as_dma_end_point_is_direction_in(ep) \
+ (((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DIRECTION) == \
+ CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
+#define cy_as_dma_end_point_is_direction_out(ep) \
+ (((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DIRECTION) == 0)
+#define cy_as_dma_end_point_set_direction_in(ep) \
+ ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
+#define cy_as_dma_end_point_set_direction_out(ep) \
+ ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
+
+#define cy_as_dma_end_point_is_usb(p) \
+ cy_as_end_point_number_is_usb((p)->ep)
+#define cy_as_dma_end_point_is_storage(p) \
+ cy_as_end_point_number_is_storage((p)->ep)
+
+typedef struct cy_as_ll_request_response {
+ /* The mbox[0] contents - see low level comm section of API doc */
+ uint16_t box0 ;
+ /* The amount of data stored in this request/response in bytes */
+ uint16_t stored ;
+ /* Length of this request in words */
+ uint16_t length ;
+ /* Additional status information about the request */
+ uint16_t flags ;
+ /* Note: This is over indexed and contains the request/response data */
+ uint16_t data[1] ;
+} cy_as_ll_request_response ;
+
+/*
+ * The callback function for responses
+ */
+typedef void (*cy_as_response_callback)(
+ /* The device that had the response */
+ cy_as_device *dev_p,
+ /* The context receiving a response */
+ uint8_t context,
+ /* The request data */
+ cy_as_ll_request_response *rqt,
+ /* The response data */
+ cy_as_ll_request_response *resp,
+ /* The status of the request */
+ cy_as_return_status_t status
+ ) ;
+
+typedef struct cy_as_ll_request_list_node {
+ /* The request to send */
+ cy_as_ll_request_response *rqt ;
+ /* The associated response for the request */
+ cy_as_ll_request_response *resp ;
+ /* Length of the response */
+ uint16_t length ;
+ /* The callback to call when done */
+ cy_as_response_callback callback ;
+ /* The state of the request */
+ uint8_t state ;
+ /* The next request in the list */
+ struct cy_as_ll_request_list_node *next ;
+} cy_as_ll_request_list_node ;
+
+#define cy_as_request_get_node_state(node_p) \
+ ((node_p)->state & CY_AS_REQUEST_LIST_STATE_MASK)
+#define cy_as_request_set_node_state(node_p, st) \
+ ((node_p)->state = \
+ ((node_p)->state & ~CY_AS_REQUEST_LIST_STATE_MASK) | (st))
+
+#define cy_as_request_node_is_sync(node_p) \
+ ((node_p)->state & CY_AS_REQUEST_LIST_STATE_SYNC)
+#define cy_as_request_node_set_sync(node_p) \
+ ((node_p)->state |= CY_AS_REQUEST_LIST_STATE_SYNC)
+#define cy_as_request_node_clear_sync(node_p) \
+ ((node_p)->state &= ~CY_AS_REQUEST_LIST_STATE_SYNC)
+
+#ifndef __doxygen__
+typedef enum cy_as_c_b_node_type {
+ CYAS_INVALID,
+ CYAS_USB_FUNC_CB,
+ CYAS_USB_IO_CB,
+ CYAS_STORAGE_IO_CB,
+ CYAS_FUNC_CB
+} cy_as_c_b_node_type ;
+
+typedef struct cy_as_func_c_b_node {
+ cy_as_c_b_node_type node_type ;
+ cy_as_function_callback cb_p ;
+ uint32_t client_data ;
+ cy_as_funct_c_b_type data_type ;
+ void *data ;
+ struct cy_as_func_c_b_node *next_p ;
+} cy_as_func_c_b_node;
+
+extern cy_as_func_c_b_node*
+cy_as_create_func_c_b_node_data(cy_as_function_callback
+ cb, uint32_t client, cy_as_funct_c_b_type type, void *data) ;
+
+extern cy_as_func_c_b_node*
+cy_as_create_func_c_b_node(cy_as_function_callback cb,
+ uint32_t client) ;
+
+extern void
+cy_as_destroy_func_c_b_node(cy_as_func_c_b_node *node) ;
+
+typedef struct cy_as_mtp_func_c_b_node {
+ cy_as_c_b_node_type type ;
+ cy_as_mtp_function_callback cb_p ;
+ uint32_t client_data;
+ struct cy_as_mtp_func_c_b_node *next_p ;
+} cy_as_mtp_func_c_b_node;
+
+extern cy_as_mtp_func_c_b_node*
+cy_as_create_mtp_func_c_b_node(cy_as_mtp_function_callback cb,
+ uint32_t client) ;
+
+extern void
+cy_as_destroy_mtp_func_c_b_node(cy_as_mtp_func_c_b_node *node) ;
+
+typedef struct cy_as_usb_func_c_b_node {
+ cy_as_c_b_node_type type ;
+ cy_as_usb_function_callback cb_p ;
+ uint32_t client_data;
+ struct cy_as_usb_func_c_b_node *next_p ;
+} cy_as_usb_func_c_b_node;
+
+extern cy_as_usb_func_c_b_node*
+cy_as_create_usb_func_c_b_node(cy_as_usb_function_callback cb,
+ uint32_t client) ;
+
+extern void
+cy_as_destroy_usb_func_c_b_node(cy_as_usb_func_c_b_node *node) ;
+
+typedef struct cy_as_usb_io_c_b_node {
+ cy_as_c_b_node_type type ;
+ cy_as_usb_io_callback cb_p ;
+ struct cy_as_usb_io_c_b_node *next_p ;
+} cy_as_usb_io_c_b_node;
+
+extern cy_as_usb_io_c_b_node*
+cy_as_create_usb_io_c_b_node(cy_as_usb_io_callback cb) ;
+
+extern void
+cy_as_destroy_usb_io_c_b_node(cy_as_usb_io_c_b_node *node) ;
+
+typedef struct cy_as_storage_io_c_b_node {
+ cy_as_c_b_node_type type ;
+ cy_as_storage_callback cb_p ;
+ /* The media for the currently outstanding async storage request */
+ cy_as_media_type media ;
+ /* The device index for the currently outstanding async storage
+ * request */
+ uint32_t device_index ;
+ /* The unit index for the currently outstanding async storage
+ * request */
+ uint32_t unit ;
+ /* The block address for the currently outstanding async storage
+ * request */
+ uint32_t block_addr ;
+ /* The operation for the currently outstanding async storage
+ * request */
+ cy_as_oper_type oper ;
+ cy_as_ll_request_response *req_p ;
+ cy_as_ll_request_response *reply_p ;
+ struct cy_as_storage_io_c_b_node *next_p ;
+} cy_as_storage_io_c_b_node;
+
+extern cy_as_storage_io_c_b_node*
+cy_as_create_storage_io_c_b_node(cy_as_storage_callback cb,
+ cy_as_media_type media, uint32_t device_index,
+ uint32_t unit, uint32_t block_addr, cy_as_oper_type oper,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p) ;
+
+extern void
+cy_as_destroy_storage_io_c_b_node(cy_as_storage_io_c_b_node *node) ;
+
+typedef struct cy_as_c_b_queue {
+ void *head_p;
+ void *tail_p;
+ uint32_t count ;
+ cy_as_c_b_node_type type ;
+} cy_as_c_b_queue ;
+
+extern cy_as_c_b_queue *
+cy_as_create_c_b_queue(cy_as_c_b_node_type type) ;
+
+extern void
+cy_as_destroy_c_b_queue(cy_as_c_b_queue *queue) ;
+
+/* Allocates a new CyAsCBNode */
+extern void
+cy_as_insert_c_b_node(cy_as_c_b_queue *queue_p, void *cbnode) ;
+
+/* Removes the first CyAsCBNode from the queue and frees it */
+extern void
+cy_as_remove_c_b_node(cy_as_c_b_queue *queue_p) ;
+
+/* Remove the last CyAsCBNode from the queue and frees it */
+extern void
+cy_as_remove_c_b_tail_node(cy_as_c_b_queue *queue_p) ;
+
+/* Removes and frees all pending callbacks */
+extern void
+cy_as_clear_c_b_queue(cy_as_c_b_queue *queue_p) ;
+
+extern cy_as_return_status_t
+cy_as_misc_send_request(cy_as_device *dev_p,
+ cy_as_function_callback cb,
+ uint32_t client,
+ cy_as_funct_c_b_type type,
+ void *data,
+ cy_as_c_b_queue *queue,
+ uint16_t req_type,
+ cy_as_ll_request_response *req_p,
+ cy_as_ll_request_response *reply_p,
+ cy_as_response_callback rcb) ;
+
+extern void
+cy_as_misc_cancel_ex_requests(cy_as_device *dev_p) ;
+
+/* Summary
+ Free all memory allocated by and zero all
+ structures initialized by CyAsUsbStart.
+ */
+extern void
+cy_as_usb_cleanup(
+ cy_as_device *dev_p) ;
+
+/* Summary
+ Free all memory allocated and zero all structures initialized
+ by CyAsStorageStart.
+ */
+extern void
+cy_as_storage_cleanup(
+ cy_as_device *dev_p) ;
+#endif
+
+/* Summary
+ This structure defines the data structure to support a
+ given command context
+
+ Description
+ All commands send to the West Bridge device via the mailbox
+ registers are sent via a context.Each context is independent
+ and there can be a parallel stream of requests and responses on
+ each context. This structure is used to manage a single context.
+*/
+typedef struct cy_as_context {
+ /* The context number for this context */
+ uint8_t number ;
+ /* This sleep channel is used to sleep while waiting on a
+ * response from the west bridge device for a request. */
+ cy_as_hal_sleep_channel channel ;
+ /* The buffer for received requests */
+ cy_as_ll_request_response *req_p ;
+ /* The length of the request being received */
+ uint16_t request_length ;
+ /* The callback for the next request received */
+ cy_as_response_callback request_callback ;
+ /* A list of low level requests to go to the firmware */
+ cy_as_ll_request_list_node *request_queue_p ;
+ /* The list node in the request queue */
+ cy_as_ll_request_list_node *last_node_p ;
+ /* Index upto which data is stored. */
+ uint16_t queue_index ;
+ /* Index to the next request in the queue. */
+ uint16_t rqt_index ;
+ /* Queue of data stored */
+ uint16_t data_queue[128] ;
+
+} cy_as_context ;
+
+#define cy_as_context_is_waiting(ctxt) \
+ ((ctxt)->state & CY_AS_CTXT_STATE_WAITING_RESPONSE)
+#define cy_as_context_set_waiting(ctxt) \
+ ((ctxt)->state |= CY_AS_CTXT_STATE_WAITING_RESPONSE)
+#define cy_as_context_clear_waiting(ctxt) \
+ ((ctxt)->state &= ~CY_AS_CTXT_STATE_WAITING_RESPONSE)
+
+
+
+/* Summary
+ This data structure stores SDIO function
+ parameters for a SDIO card
+
+ Description
+*/
+typedef struct cy_as_sdio_device {
+ /* Keeps track of IO functions initialized*/
+ uint8_t function_init_map;
+ uint8_t function_suspended_map;
+ /* Function 0 (Card Common) properties*/
+ cy_as_sdio_card card;
+ /* Function 1-7 (Mapped to array element 0-6) properties.*/
+ cy_as_sdio_func function[7];
+
+} cy_as_sdio_device;
+
+/* Summary
+Macros to access the SDIO card properties
+*/
+
+#define cy_as_sdio_get_function_code(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].function_code)
+
+#define cy_as_sdio_get_function_ext_code(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].\
+ function[i-1].extended_func_code)
+
+#define cy_as_sdio_get_function_p_s_n(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].card_psn)
+
+#define cy_as_sdio_get_function_blocksize(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].blocksize)
+
+#define cy_as_sdio_get_function_max_blocksize(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].maxblocksize)
+
+#define cy_as_sdio_get_function_csa_support(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].csa_bits)
+
+#define cy_as_sdio_get_function_wakeup_support(handle, bus, i) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1]. wakeup_support)
+
+#define cy_as_sdio_set_function_block_size(handle, bus, i, blocksize) \
+ (((cy_as_device *)handle)->sdiocard[bus].function[i-1].blocksize = \
+ blocksize)
+
+#define cy_as_sdio_get_card_num_functions(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.num_functions)
+
+#define cy_as_sdio_get_card_mem_present(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.memory_present)
+
+#define cy_as_sdio_get_card_manf_id(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.manufacturer__id)
+
+#define cy_as_sdio_get_card_manf_info(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.manufacturer_info)
+
+#define cy_as_sdio_get_card_blocksize(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.blocksize)
+
+#define cy_as_sdio_get_card_max_blocksize(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.maxblocksize)
+
+#define cy_as_sdio_get_card_sdio_version(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.sdio_version)
+
+#define cy_as_sdio_get_card_capability(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.card_capability)
+
+#define cy_as_sdio_get_function_init_map(handle, bus) \
+ (((cy_as_device *)handle)->sdiocard[bus].function_init_map)
+
+#define cy_as_sdio_check_function_initialized(handle, bus, i) \
+ (((cy_as_sdio_get_function_init_map(handle, bus)) & (0x01<<i)) ? 1 : 0)
+
+#define cy_as_sdio_set_card_block_size(handle, bus, blocksize) \
+ (((cy_as_device *)handle)->sdiocard[bus].card.blocksize = blocksize)
+
+#define cy_as_sdio_check_support_bus_suspend(handle, bus) \
+ ((cy_as_sdio_get_card_capability(handle, bus) & CY_SDIO_SBS) ? 1 : 0)
+
+#define cy_as_sdio_check_function_suspended(handle, bus, i) \
+ ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map & \
+ (0x01<<i)) ? 1 : 0)
+
+#define cy_as_sdio_set_function_suspended(handle, bus, i) \
+ ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map) \
+ |= (0x01<<i))
+
+#define cy_as_sdio_clear_function_suspended(handle, bus, i) \
+ ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map) \
+ &= (~(0x01<<i)))
+
+/* Summary
+ This data structure represents a single device.
+
+ Description
+*/
+struct cy_as_device {
+ /* General stuff */
+ /* A signature to insure we have a valid handle */
+ uint32_t sig ;
+ /* The ID of the silicon */
+ uint16_t silicon_id ;
+ /* Pointer to the next device */
+ struct cy_as_device *next_p ;
+ /* This is the client specific tag for this device */
+ cy_as_hal_device_tag tag ;
+ /* This contains various state information about the device */
+ uint32_t state ;
+ /* Flag indicating whether INT# pin is used for DRQ */
+ cy_bool use_int_drq ;
+
+ /* DMA related */
+ /* The endpoint pointers associated with this device */
+ cy_as_dma_end_point *endp[16] ;
+ /* List of queue entries that can be used for xfers */
+ cy_as_dma_queue_entry *dma_freelist_p ;
+
+ /* Low level comm related */
+ /* The contexts available in this device */
+ cy_as_context *context[CY_RQT_CONTEXT_COUNT] ;
+ /* The low level error returned from sending an async request */
+ cy_as_return_status_t ll_error ;
+ /* A request is currently being sent to West Bridge. */
+ cy_bool ll_sending_rqt ;
+ /* The current mailbox request should be aborted. */
+ cy_bool ll_abort_curr_rqt ;
+ /* Indicates that the LL layer has queued mailbox data. */
+ cy_bool ll_queued_data ;
+
+ /* MISC API related */
+ /* Misc callback */
+ cy_as_misc_event_callback misc_event_cb ;
+
+ /* Storage Related */
+ /* The reference count for the Storage API */
+ uint32_t storage_count ;
+ /* Callback for storage events */
+ cy_as_storage_event_callback_dep storage_event_cb ;
+ /* V1.2+ callback for storage events */
+ cy_as_storage_event_callback storage_event_cb_ms ;
+ /* The error for a sleeping storage operation */
+ cy_as_return_status_t storage_error ;
+ /* Flag indicating that the storage stack is waiting for an operation */
+ cy_bool storage_wait ;
+ /* Request used for storage read/writes. */
+ cy_as_ll_request_response *storage_rw_req_p ;
+ /* Response used for storage read/writes. */
+ cy_as_ll_request_response *storage_rw_resp_p ;
+ /* The storage callback */
+ cy_as_storage_callback_dep storage_cb ;
+ /* The V1.2+ storage callback */
+ cy_as_storage_callback storage_cb_ms ;
+ /* The bus index for the currently outstanding async storage request */
+ cy_as_bus_number_t storage_bus_index ;
+ /* The device index for the currently outstanding async storage
+ * request */
+ uint32_t storage_device_index ;
+ /* The unit index for the currently outstanding async storage request */
+ uint32_t storage_unit ;
+ /* The block address for the currently outstanding async storage
+ * request */
+ uint32_t storage_block_addr ;
+ /* The operation for the currently outstanding async storage request */
+ cy_as_oper_type storage_oper ;
+ /* The endpoint used to read Storage data */
+ cy_as_end_point_number_t storage_read_endpoint ;
+ /* The endpoint used to write endpoint data */
+ cy_as_end_point_number_t storage_write_endpoint ;
+ cy_as_device_desc storage_device_info
+ [CY_AS_MAX_BUSES][CY_AS_MAX_STORAGE_DEVICES] ;
+ /* The information on each device on each bus */
+
+ /* USB Related */
+ /* This conatins the endpoint async state */
+ uint16_t epasync ;
+ /* The reference count for the USB API */
+ uint32_t usb_count ;
+ /* The physical endpoint configuration */
+ uint8_t usb_phy_config ;
+ /* The callbacks for async func calls */
+ cy_as_c_b_queue *usb_func_cbs ;
+ /* Endpoint configuration information */
+ cy_as_usb_end_point_config usb_config[16] ;
+ /* The USB callback */
+ cy_as_usb_event_callback_dep usb_event_cb ;
+ /* The V1.2+ USB callback */
+ cy_as_usb_event_callback usb_event_cb_ms ;
+ /* The error for a sleeping usb operation */
+ cy_as_return_status_t usb_error ;
+ /* The USB callback for a pending storage operation */
+ cy_as_usb_io_callback usb_cb[16] ;
+ /* The buffer pending from a USB operation */
+ void *usb_pending_buffer ;
+ /* The size of the buffer pending from a USB operation */
+ uint32_t usb_pending_size ;
+ /* If true, send a short packet */
+ cy_bool usb_spacket[16] ;
+ /* The amount of data actually xferred */
+ uint32_t usb_actual_cnt ;
+ /* EP1OUT and EP1IN config register contents */
+ uint8_t usb_ep1cfg[2] ;
+ /* LEP config register contents */
+ uint16_t usb_lepcfg[10] ;
+ /* PEP config register contents */
+ uint16_t usb_pepcfg[4] ;
+ /* Buffer for EP0 and EP1 data sent via mailboxes */
+ uint8_t *usb_ep_data ;
+ /* Used to track how many ack requests are pending */
+ uint32_t usb_delay_ack_count ;
+ /* Maximum transfer size for USB endpoints. */
+ uint32_t usb_max_tx_size ;
+
+ /* Request for sending EP0 data to West Bridge */
+ cy_as_ll_request_response *usb_ep0_dma_req ;
+ /* Response for EP0 data sent to West Bridge */
+ cy_as_ll_request_response *usb_ep0_dma_resp ;
+ /* Request for sending EP1 data to West Bridge */
+ cy_as_ll_request_response *usb_ep1_dma_req ;
+ /* Response for EP1 data sent to West Bridge */
+ cy_as_ll_request_response *usb_ep1_dma_resp ;
+
+ cy_as_ll_request_response *usb_ep0_dma_req_save ;
+ cy_as_ll_request_response *usb_ep0_dma_resp_save ;
+
+ /* MTP Related */
+ /* The reference count for the MTP API */
+ uint32_t mtp_count ;
+ /* The MTP event callback supplied by the client */
+ cy_as_mtp_event_callback mtp_event_cb ;
+ /* The current block table to be transfered */
+ cy_as_mtp_block_table *tp_blk_tbl ;
+
+ cy_as_c_b_queue *func_cbs_mtp ;
+ cy_as_c_b_queue *func_cbs_usb ;
+ cy_as_c_b_queue *func_cbs_stor ;
+ cy_as_c_b_queue *func_cbs_misc ;
+ cy_as_c_b_queue *func_cbs_res ;
+
+ /* The last USB event that was received */
+ cy_as_usb_event usb_last_event ;
+ /* Types of storage media supported by the firmware */
+ uint8_t media_supported[CY_AS_MAX_BUSES] ;
+
+ /* SDIO card parameters*/
+ cy_as_sdio_device sdiocard[CY_AS_MAX_BUSES];
+ /* if true, MTP enabled Firmware. */
+ cy_bool is_mtp_firmware ;
+ /* if true, mailbox message has come already */
+ cy_bool is_mtp_data_pending ;
+ /* True between the time an Init was called and
+ * the complete event is generated */
+ cy_bool mtp_turbo_active ;
+ /* mbox reported EP 2 data len */
+ uint16_t mtp_data_len ;
+ /* The error for mtp EP4 write operation */
+ cy_as_return_status_t mtp_error ;
+ /* mtp send/get operation callback */
+ cy_as_function_callback mtp_cb ;
+ /* mtp send/get operation client id */
+ uint32_t mtp_client ;
+ /* mtp operation type. To be used in callback */
+ cy_as_funct_c_b_type mtp_op ;
+
+ /* Firmware is running in P2S only mode. */
+ cy_bool is_storage_only_mode ;
+ /* Interrupt mask value during device standby. */
+ uint32_t stby_int_mask ;
+} ;
+
+#define cy_as_device_is_configured(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_CONFIGURED)
+#define cy_as_device_set_configured(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_CONFIGURED)
+#define cy_as_device_set_unconfigured(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_CONFIGURED)
+
+#define cy_as_device_is_dma_running(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_DMA_MODULE)
+#define cy_as_device_set_dma_running(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_DMA_MODULE)
+#define cy_as_device_set_dma_stopped(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_DMA_MODULE)
+
+#define cy_as_device_is_low_level_running(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
+#define cy_as_device_set_low_level_running(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
+#define cy_as_device_set_low_level_stopped(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
+
+#define cy_as_device_is_intr_running(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_INTR_MODULE)
+#define cy_as_device_set_intr_running(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_INTR_MODULE)
+#define cy_as_device_set_intr_stopped(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_INTR_MODULE)
+
+#define cy_as_device_is_firmware_loaded(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
+#define cy_as_device_set_firmware_loaded(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
+#define cy_as_device_set_firmware_not_loaded(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
+
+#define cy_as_device_is_storage_running(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_STORAGE_MODULE)
+#define cy_as_device_set_storage_running(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_MODULE)
+#define cy_as_device_set_storage_stopped(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_MODULE)
+
+#define cy_as_device_is_usb_running(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_USB_MODULE)
+#define cy_as_device_set_usb_running(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_USB_MODULE)
+#define cy_as_device_set_usb_stopped(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_MODULE)
+
+#define cy_as_device_wants_scsi_messages(dp) \
+ (((dp)->state & CY_AS_DEVICE_STATE_STORAGE_SCSIMSG) \
+ ? cy_true : cy_false)
+#define cy_as_device_set_scsi_messages(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_SCSIMSG)
+#define cy_as_device_clear_scsi_messages(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_SCSIMSG)
+
+#define cy_as_device_is_storage_async_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
+#define cy_as_device_set_storage_async_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
+#define cy_as_device_clear_storage_async_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
+
+#define cy_as_device_is_usb_connected(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_USB_CONNECTED)
+#define cy_as_device_set_usb_connected(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_USB_CONNECTED)
+#define cy_as_device_clear_usb_connected(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_CONNECTED)
+
+#define cy_as_device_is_usb_high_speed(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_USB_HIGHSPEED)
+#define cy_as_device_set_usb_high_speed(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_USB_HIGHSPEED)
+#define cy_as_device_clear_usb_high_speed(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_HIGHSPEED)
+
+#define cy_as_device_is_in_callback(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_IN_CALLBACK)
+#define cy_as_device_set_in_callback(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_IN_CALLBACK)
+#define cy_as_device_clear_in_callback(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_IN_CALLBACK)
+
+#define cy_as_device_is_setup_i_o_performed(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
+#define cy_as_device_set_setup_i_o_performed(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
+#define cy_as_device_clear_setup_i_o_performed(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
+
+#define cy_as_device_is_ack_delayed(dp) \
+ ((dp)->usb_delay_ack_count > 0)
+#define cy_as_device_set_ack_delayed(dp) \
+ ((dp)->usb_delay_ack_count++)
+#define cy_as_device_rem_ack_delayed(dp) \
+ ((dp)->usb_delay_ack_count--)
+#define cy_as_device_clear_ack_delayed(dp) \
+ ((dp)->usb_delay_ack_count = 0)
+
+#define cy_as_device_is_setup_packet(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
+#define cy_as_device_set_setup_packet(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
+#define cy_as_device_clear_setup_packet(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
+
+#define cy_as_device_is_ep0_stalled(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_EP0_STALLED)
+#define cy_as_device_set_ep0_stalled(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_EP0_STALLED)
+#define cy_as_device_clear_ep0_stalled(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_EP0_STALLED)
+
+#define cy_as_device_is_register_standby(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_REGISTER_STANDBY)
+#define cy_as_device_set_register_standby(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_REGISTER_STANDBY)
+#define cy_as_device_clear_register_standby(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_REGISTER_STANDBY)
+
+#define cy_as_device_is_pin_standby(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_PIN_STANDBY)
+#define cy_as_device_set_pin_standby(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_PIN_STANDBY)
+#define cy_as_device_clear_pin_standby(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_PIN_STANDBY)
+
+#define cy_as_device_is_crystal(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_CRYSTAL)
+#define cy_as_device_is_external_clock(dp) \
+ (!((dp)->state & CY_AS_DEVICE_STATE_CRYSTAL))
+#define cy_as_device_set_crystal(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_CRYSTAL)
+#define cy_as_device_set_external_clock(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_CRYSTAL)
+
+#define cy_as_device_is_waking(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_WAKING)
+#define cy_as_device_set_waking(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_WAKING)
+#define cy_as_device_clear_waking(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_WAKING)
+
+#define cy_as_device_is_in_suspend_mode(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_SUSPEND)
+#define cy_as_device_set_suspend_mode(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_SUSPEND)
+#define cy_as_device_clear_suspend_mode(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_SUSPEND)
+
+#define cy_as_device_is_reset_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_RESETP)
+#define cy_as_device_set_reset_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_RESETP)
+#define cy_as_device_clear_reset_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_RESETP)
+
+#define cy_as_device_is_standby_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_STANDP)
+#define cy_as_device_set_standby_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_STANDP)
+#define cy_as_device_clear_standby_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_STANDP)
+
+#define cy_as_device_is_s_s_s_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_SSSP)
+#define cy_as_device_set_s_s_s_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_SSSP)
+#define cy_as_device_clear_s_s_s_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_SSSP)
+
+#define cy_as_device_is_u_s_s_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_USSP)
+#define cy_as_device_set_u_s_s_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_USSP)
+#define cy_as_device_clear_u_s_s_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_USSP)
+
+#define cy_as_device_is_m_s_s_pending(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_MSSP)
+#define cy_as_device_set_m_s_s_pending(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_MSSP)
+#define cy_as_device_clear_m_s_s_pending(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_MSSP)
+
+#define cy_as_device_is_p2s_dma_start_recvd(dp) \
+ ((dp)->state & CY_AS_DEVICE_STATE_P2SDMA_START)
+#define cy_as_device_set_p2s_dma_start_recvd(dp) \
+ ((dp)->state |= CY_AS_DEVICE_STATE_P2SDMA_START)
+#define cy_as_device_clear_p2s_dma_start_recvd(dp) \
+ ((dp)->state &= ~CY_AS_DEVICE_STATE_P2SDMA_START)
+
+#define cy_as_device_is_usb_async_pending(dp, ep) \
+ ((dp)->epasync & (1 << ep))
+#define cy_as_device_set_usb_async_pending(dp, ep) \
+ ((dp)->epasync |= (1 << ep))
+#define cy_as_device_clear_usb_async_pending(dp, ep) \
+ ((dp)->epasync &= ~(1 << ep))
+
+#define cy_as_device_is_nand_storage_supported(dp) \
+ ((dp)->media_supported[0] & 1)
+
+/* Macros to check the type of West Bridge device. */
+#define cy_as_device_is_astoria_dev(dp) \
+ (((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_VALUE) || \
+ ((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_FPGA_VALUE))
+#define cy_as_device_is_antioch_dev(dp) \
+ ((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ANTIOCH_VALUE)
+
+#ifdef CY_AS_LOG_SUPPORT
+extern void cy_as_log_debug_message(int value, const char *msg) ;
+#else
+#define cy_as_log_debug_message(value, msg)
+#endif
+
+/* Summary
+ This function finds the device object given the HAL tag
+
+ Description
+ The user associats a device TAG with each West Bridge device
+ created. This tag is passed from the API functions to and HAL
+ functions that need to ID a specific West Bridge device. This
+ tag is also passed in from the user back into the API via
+ interrupt functions. This function allows the API to find the
+ device structure associated with a given tag.
+
+ Notes
+ This function does a simple linear search for the device based
+ on the TAG. This function is called each time an West Bridge
+ interrupt handler is called. Therefore this works fine for a
+ small number of West Bridge devices (e.g. less than five).
+ Anything more than this and this methodology will need to be
+ updated.
+
+ Returns
+ Pointer to a CyAsDevice associated with the tag
+*/
+extern cy_as_device *
+cy_as_device_find_from_tag(
+ cy_as_hal_device_tag tag
+ ) ;
+
+#include "cyas_cplus_end.h"
+
+#endif /* __INCLUDED_CYASDEVICE_H__ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdma.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdma.h
new file mode 100644
index 000000000000..c97f9876fc4c
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasdma.h
@@ -0,0 +1,375 @@
+/* Cypress West Bridge API header file (cyasdma.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASDMA_H_
+#define _INCLUDED_CYASDMA_H_
+
+#include "cyashal.h"
+#include "cyasdevice.h"
+
+#include "cyas_cplus_start.h"
+
+
+/*@@DMA Overview
+ This module manages the DMA operations to/from the West Bridge
+ device. The DMA module maintains a DMA queue for each endpoint
+ so multiple DMA requests may be queued and they will complete
+ at some future time.
+
+ The DMA module must be started before it can be used. It is
+ started by calling CyAsDmaStart(). This function intializes
+ all of the endpoint data structures.
+
+ In order to perform DMA on a particular endpoint, the endpoint
+ must be enabled by calling CyAsDmaEnableEndPoint(). In addition
+ to enabling or disabling the endpoint, this function also sets
+ the direction for a given endpoint. Direction is given in USB
+ terms. For P port to West Bridge traffic, the endpoint is a
+ CyAsDirectionIn endpoint. For West Bridge to P port traffic,
+ the endpoint is a CyAsDirectionOut endpoint.
+
+ Once DMA is started and an endpoint is enabled, DMA requests
+ are issued by calling CyAsDmaQueueRequest(). This function
+ queue either a DMA read or DMA write request. The callback
+ associated with the request is called once the request has been
+ fulfilled.
+
+ See Also
+ * CyAsDmaStart
+ * CyAsDmaEnableEndPoint
+ * CyAsDmaDirection
+ * CyAsDmaQueueRequest
+ */
+
+/************************
+ * West Bridge Constants
+ ************************/
+#define CY_AS_DMA_MAX_SIZE_HW_SIZE (0xffffffff)
+
+/************************
+ * West Bridge Data Structures
+ ************************/
+
+/* Summary
+ This type specifies the direction of an endpoint to the
+ CyAsDmaEnableEndPoint function.
+
+ Description
+ When an endpoint is enabled, the direction of the endpoint
+ can also be set. This type is used to specify the endpoint
+ type. Note that the direction is specified in USB terms.
+ Therefore, if the DMA is from the P port to West Bridge,
+ the direction is IN.
+
+ See Also
+ * CyAsDmaEnableEndPoint
+*/
+typedef enum cy_as_dma_direction {
+ /* Set the endpoint to type IN (P -> West Bridge) */
+ cy_as_direction_in = 0,
+ /* Set the endpoint to type OUT (West Bridge -> P) */
+ cy_as_direction_out = 1,
+ /* Only valid for EP 0 */
+ cy_as_direction_in_out = 2,
+ /* Do no change the endpoint type */
+ cy_as_direction_dont_change = 3
+} cy_as_dma_direction ;
+
+/*********************************
+ * West Bridge Functions
+ *********************************/
+
+/* Summary
+ Initialize the DMA module and ready the module for receiving data
+
+ Description
+ This function initializes the DMA module by initializing all of
+ the endpoint data structures associated with the device given.
+ This function also register a DMA complete callback with the HAL
+ DMA code. This callback is called whenever the HAL DMA subsystem
+ completes a requested DMA operation.
+
+ Returns
+ CY_AS_ERROR_SUCCESS - the module initialized sucessfully
+ CY_AS_ERROR_OUT_OF_MEMORY - memory allocation failed during
+ initialization
+ CY_AS_ERROR_ALREADY_RUNNING - the DMA module was already running
+
+ See Also
+ * CyAsDmaStop
+*/
+extern cy_as_return_status_t
+cy_as_dma_start(
+ /* The device to start */
+ cy_as_device *dev_p
+ ) ;
+
+/* Summary
+ Shutdown the DMA module
+
+ Description
+ This function shuts down the DMA module for this device by
+ canceling any DMA requests associated with each endpoint and
+ then freeing the resources associated with each DMA endpoint.
+
+ Returns
+ CY_AS_ERROR_SUCCESS - the module shutdown sucessfully
+ CY_AS_ERROR_NOT_RUNNING - the DMA module was not running
+
+ See Also
+ * CyAsDmaStart
+ * CyAsDmaCancel
+*/
+extern cy_as_return_status_t
+cy_as_dma_stop(
+ /* The device to stop */
+ cy_as_device *dev_p
+ ) ;
+
+/* Summary
+ This function cancels all outstanding DMA requests on a given endpoint
+
+ Description
+ This function cancels any DMA requests outstanding on a given endpoint
+ by disabling the transfer of DMA requests from the queue to the HAL
+ layer and then removing any pending DMA requests from the queue. The
+ callback associated with any DMA requests that are being removed is
+ called with an error code of CY_AS_ERROR_CANCELED.
+
+ Notes
+ If a request has already been sent to the HAL layer it will be
+ completed and not canceled. Only requests that have not been sent to
+ the HAL layer will be cancelled.
+
+ Returns
+ CY_AS_ERROR_SUCCESS - the traffic on the endpoint is canceled
+ sucessfully
+
+ See Also
+*/
+extern cy_as_return_status_t
+cy_as_dma_cancel(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to cancel */
+ cy_as_end_point_number_t ep,
+ cy_as_return_status_t err
+ ) ;
+
+/* Summary
+ This function enables a single endpoint for DMA operations
+
+ Description
+ In order to enable the queuing of DMA requests on a given
+ endpoint, the endpoint must be enabled for DMA. This function
+ enables a given endpoint. In addition, this function sets the
+ direction of the DMA operation.
+
+ Returns
+ * CY_AS_ERROR_INVALID_ENDPOINT - invalid endpoint number
+ * CY_AS_ERROR_SUCCESS - endpoint was enabled or disabled
+ * successfully
+
+ See Also
+ * CyAsDmaQueueRequest
+*/
+extern cy_as_return_status_t
+cy_as_dma_enable_end_point(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to enable or disable */
+ cy_as_end_point_number_t ep,
+ /* CyTrue to enable, CyFalse to disable */
+ cy_bool enable,
+ /* The direction of the endpoint */
+ cy_as_dma_direction dir
+) ;
+
+/* Summary
+ This function queue a DMA request for a given endpoint
+
+ Description
+ When an West Bridge API module wishes to do a DMA operation,
+ this function is called on the associated endpoint to queue
+ a DMA request. When the DMA request has been fulfilled, the
+ callback associated with the DMA operation is called.
+
+ Notes
+ The buffer associated with the DMA request, must remain valid
+ until after the callback function is calld.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the DMA operation was queued successfully
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint number was invalid
+ * CY_AS_ERROR_ENDPOINT_DISABLED - the endpoint was disabled
+ * CY_AS_ERROR_OUT_OF_MEMORY - out of memory processing the request
+
+ See Also
+ * CyAsDmaEnableEndPoint
+ * CyAsDmaCancel
+*/
+extern cy_as_return_status_t
+cy_as_dma_queue_request(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to receive a new request */
+ cy_as_end_point_number_t ep,
+ /* The memory buffer for the DMA request -
+ * must be valid until after the callback has been called */
+ void *mem_p,
+ /* The size of the DMA request in bytes */
+ uint32_t size,
+ /* If true and a DMA read request, return the next packet
+ * regardless of size */
+ cy_bool packet,
+ /* If true, this is a read request,
+ * otherwise it is a write request */
+ cy_bool readreq,
+ /* The callback to call when the DMA request is complete,
+ * either successfully or via an error */
+ cy_as_dma_callback cb
+ ) ;
+
+/* Summary
+ This function waits until all DMA requests on a given endpoint
+ have been processed and then return
+
+ Description
+ There are times when a module in the West Bridge API needs to
+ wait until the DMA operations have been queued. This function
+ sleeps until all DMA requests have been fulfilled and only then
+ returns to the caller.
+
+ Notes
+ I don't think we will need a list of sleeping clients to support
+ multiple parallel client modules sleeping on a single endpoint,
+ but if we do instead of having a single sleep channel in the
+ endpoint, each client will have to supply a sleep channel and we
+ will have to maintain a list of sleep channels to wake.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the queue has drained sucessfully
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given is not valid
+ * CY_AS_ERROR_NESTED_SLEEP - CyAsDmaQueueRequest() was requested
+ * on an endpoint where CyAsDmaQueueRequest was already called
+*/
+extern cy_as_return_status_t
+cy_as_dma_drain_queue(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to drain */
+ cy_as_end_point_number_t ep,
+ /* If CyTrue, call kickstart to start the DMA process,
+ if cy_false, west bridge will start the DMA process */
+ cy_bool kickstart
+ ) ;
+
+/* Summary
+ Sets the maximum amount of data West Bridge can accept in a single
+ DMA Operation for the given endpoint
+
+ Description
+ Depending on the configuration of the West Bridge device endpoint,
+ the amount of data that can be accepted varies. This function
+ sets the maximum amount of data West Bridge can accept in a single
+ DMA operation. The value is stored with the endpoint and passed
+ to the HAL layer in the CyAsHalDmaSetupWrite() and
+ CyAsHalDmaSetupRead() functoins.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the value was set sucessfully
+ * CY_AS_ERROR_INVALID_SIZE - the size value was not valid
+*/
+extern cy_as_return_status_t
+cy_as_dma_set_max_dma_size(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to change */
+ cy_as_end_point_number_t ep,
+ /* The max size of this endpoint in bytes */
+ uint32_t size
+ ) ;
+
+/* Summary
+ This function starts the DMA process on a given channel.
+
+ Description
+ When transferring data from the P port processor to West
+ Bridge, the DMA operation must be initiated P Port software
+ for the first transfer. Subsequent transferrs will be
+ handled at the interrupt level.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+*/
+extern cy_as_return_status_t
+cy_as_dma_kick_start(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint to change */
+ cy_as_end_point_number_t ep
+ ) ;
+
+/* Summary
+ This function receives endpoint data from a request.
+
+ Description
+ For endpoint 0 and 1 the endpoint data is transferred from
+ the West Bridge device to the DMA via a lowlevel
+ requests (via the mailbox registers).
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+*/
+extern cy_as_return_status_t
+cy_as_dma_received_data(
+ /* The device of interest */
+ cy_as_device *dev_p,
+ /* The endpoint that received data */
+ cy_as_end_point_number_t ep,
+ /* The data size */
+ uint32_t dsize,
+ /* The data buffer */
+ void *data
+ );
+
+/* Summary
+ This function is called when the DMA operation on
+ an endpoint has been completed.
+
+ Returns
+ * void
+ */
+extern void
+cy_as_dma_completed_callback(
+ /* Tag to HAL completing the DMA operation. */
+ cy_as_hal_device_tag tag,
+ /* Endpoint on which DMA has been completed. */
+ cy_as_end_point_number_t ep,
+ /* Length of data received. */
+ uint32_t length,
+ /* Status of DMA operation. */
+ cy_as_return_status_t status
+ ) ;
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASDMA_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaserr.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaserr.h
new file mode 100644
index 000000000000..f78d60270d45
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaserr.h
@@ -0,0 +1,1094 @@
+/* Cypress West Bridge API header file (cyaserr.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASERR_H_
+#define _INCLUDED_CYASERR_H_
+
+/*@@West Bridge Errors
+ Summary
+ This section lists the error codes for West Bridge.
+
+*/
+
+/* Summary
+ The function completed sucessfully
+*/
+#define CY_AS_ERROR_SUCCESS (0)
+
+/* Summary
+ A function trying to acquire a resource was unable to do so.
+
+ Description
+ This code indicates that a resource that the API was trying to claim
+ could not be claimed.
+
+ See Also
+ * CyAsMiscAcquireResource
+ * CyAsStorageClaim
+*/
+#define CY_AS_ERROR_NOT_ACQUIRED (1)
+
+/* Summary
+ A function trying to acquire a resource was unable to do so.
+
+ Description
+ The West Bridge API provides the capability to assign the storage media to
+ either the West Bridge device or the USB port. This error indicates the
+ P port was trying to release a storage media and was not able to do
+ so. This generally means it was not owned by the P port processor.
+
+ See Also
+ * CyAsStorageRelease
+*/
+#define CY_AS_ERROR_NOT_RELEASED (2)
+
+/* Summary
+ The West Bridge firmware is not loaded.
+
+ Description
+ Most of the API functions that are part of the West Bridge API rely on
+ firmware running on the West Bridge device. This error code is
+ returned when one of these functions is called and the firmware has
+ not yet been loaded.
+
+ See Also
+ * CyAsMiscGetFirmwareVersion
+ * CyAsMiscReset
+ * CyAsMiscAcquireResource
+ * CyAsMiscReleaseResource
+ * CyAsMiscSetTraceLevel
+ * CyAsStorageStart
+ * CyAsStorageStop
+ * CyAsStorageRegisterCallback
+ * CyAsStorageClaim
+ * CyAsStorageRelease
+ * CyAsStorageQueryMedia
+ * CyAsStorageQueryDevice
+ * CyAsStorageQueryUnit
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_NO_FIRMWARE (3)
+
+/* Summary
+ A timeout occurred waiting on a response from the West Bridge device
+
+ Description
+ When requests are made of the West Bridge device, a response is expected
+ within a given timeframe. If a response is not recevied within the
+ given timeframe, a timeout error occurs.
+*/
+#define CY_AS_ERROR_TIMEOUT (4)
+
+/* Summary
+ A request to download firmware was made while not in the CONFIG mode
+
+ Description
+ Firmware is downloaded via the CyAsMiscDownloadFirmware() function. This
+ function can only be called while in the CONFIG mode. This error indicates
+ that the CyAsMiscDownloadFirmware() call was made while not in the CONFIG
+ mode.
+
+ See Also
+ * CyAsMiscDownloadFirmware
+*/
+#define CY_AS_ERROR_NOT_IN_CONFIG_MODE (5)
+
+/* Summary
+ This error is returned if the firmware size specified is too invalid.
+
+ Description
+ If the size of the firmware to be downloaded into West Bridge is
+ invalid, this error is issued. Invalid firmware sizes are those
+ greater than 24K or a size of zero.
+
+ See Also
+ * CyAsMiscDownloadFirmare
+*/
+#define CY_AS_ERROR_INVALID_SIZE (6)
+
+/* Summary
+ This error is returned if a request is made to acquire a resource that has
+ already been acquired.
+
+ Description
+ This error is returned if a request is made to acquire a resource that has
+ already been acquired.
+
+ See Also
+ * CyAsMiscAcquireResource
+ * CyAsMiscReleaseResource
+*/
+#define CY_AS_ERROR_RESOURCE_ALREADY_OWNED (7)
+
+/* Summary
+ This error is returned if a request is made to release a resource that has
+ not previously been acquired.
+
+ Description
+ This error is returned if a request is made to release a resource that has
+ not previously been acquired.
+
+ See Also
+ * CyAsMiscAcquireResource
+ * CyAsMiscReleaseResource
+*/
+#define CY_AS_ERROR_RESOURCE_NOT_OWNED (8)
+
+/* Summary
+ This error is returned when a request is made for a media that
+ does not exist
+
+ Description
+ This error is returned when a request is made that references
+ a storage media that does not exist. This error is returned
+ when the storage media is not present in the current system,
+ or if the media value given is not valid.
+
+ See Also
+ * CyAsMiscSetTraceLevel
+ * CyAsStorageClaim
+ * CyAsStorageRelease
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_NO_SUCH_MEDIA (9)
+
+/* Summary
+ This error is returned when a request is made for a device
+ that does not exist
+
+ Description
+ This error is returned when a request is made that references a
+ storage device that does not exist. This error is returned when
+ the device index is not present in the current system, or if the
+ device index exceeds 15.
+
+ See Also
+ * CyAsMiscSetTraceLevel
+ * CyAsStorageQueryDevice
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_NO_SUCH_DEVICE (10)
+
+/* Summary
+ This error is returned when a request is made for a unit that
+ does not exist
+
+ Description
+ This error is returned when a request is made that references
+ a storage unit that does not exist. This error is returned
+ when the unit index is not present in the current system, or
+ if the unit index exceeds 255.
+
+ See Also
+ * CyAsMiscSetTraceLevel
+ * CyAsStorageQueryDevice
+ * CyAsStorageQueryUnit
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_NO_SUCH_UNIT (11)
+
+/* Summary
+ This error is returned when a request is made for a block that
+ does not exist
+
+ Description
+ This error is returned when a request is made that references
+ a storage block that does not exist. This error is returned
+ when the block address reference an address beyond the end of
+ the unit selected.
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_INVALID_BLOCK (12)
+
+/* Summary
+ This error is returned when an invalid trace level is set.
+
+ Description
+ This error is returned when the trace level request is greater
+ than three.
+
+ See Also
+ * CyAsMiscSetTraceLevel
+*/
+#define CY_AS_ERROR_INVALID_TRACE_LEVEL (13)
+
+/* Summary
+ This error is returned when West Bridge is already in the standby state
+ and an attempt is made to put West Bridge into this state again.
+
+ Description
+ This error is returned when West Bridge is already in the standby state
+ and an attempt is made to put West Bridge into this state again.
+
+ See Also
+ * CyAsMiscEnterStandby
+*/
+#define CY_AS_ERROR_ALREADY_STANDBY (14)
+
+/* Summary
+ This error is returned when the API needs to set a pin on the
+ West Bridge device, but this is not supported by the underlying HAL
+ layer.
+
+ Description
+ This error is returned when the API needs to set a pin on the
+ West Bridge device, but this is not supported by the underlying HAL
+ layer.
+
+ See Also
+ * CyAsMiscEnterStandby
+ * CyAsMiscLeaveStandby
+*/
+#define CY_AS_ERROR_SETTING_WAKEUP_PIN (15)
+
+/* Summary
+ This error is returned when a module is being started that has
+ already been started.
+
+ Description
+ This error is returned when a module is being started and that module
+ has already been started. This error does not occur with the
+ CyAsStorageStart() or CyAsUsbStart() functions as the storage and
+ USB modules are reference counted.
+
+ Note
+ At the current time, this error is returned by module internal to
+ the API but not returned by any of the API functions.
+*/
+#define CY_AS_ERROR_ALREADY_RUNNING (16)
+
+/* Summary
+ This error is returned when a module is being stopped that has
+ already been stopped.
+
+ Description
+ This error is returned when a module is being stopped and that module
+ has already been stopped. This error does not occur with the
+ CyAsStorageStop() or CyAsUsbStop() functions as the storage and USB
+ modules are reference counted.
+
+ Note
+ At the current time, this error is returned by module internal to
+ the API but not returned by any of the API functions.
+*/
+
+#define CY_AS_ERROR_NOT_RUNNING (17)
+
+/* Summary
+ This error is returned when the caller tries to claim a media that
+ has already been claimed.
+
+ Description
+ This error is returned when the caller tries to claim a media that
+ has already been claimed.
+
+ See Also
+ * CyAsStorageClaim
+*/
+#define CY_AS_ERROR_MEDIA_ALREADY_CLAIMED (18)
+
+/* Summary
+ This error is returned when the caller tries to release a media that has
+ already been released.
+
+ Description
+ This error is returned when the caller tries to release a media that has
+ already been released.
+
+ See Also
+ * CyAsStorageRelease
+*/
+#define CY_AS_ERROR_MEDIA_NOT_CLAIMED (19)
+
+/* Summary
+ This error is returned when canceling trying to cancel an asynchronous
+ operation when an async operation is not pending.
+
+ Description
+ This error is returned when a call is made to a function to cancel an
+ asynchronous operation and there is no asynchronous operation pending.
+
+ See Also
+ * CyAsStorageCancelAsync
+ * CyAsUsbCancelAsync
+*/
+#define CY_AS_ERROR_NO_OPERATION_PENDING (20)
+
+/* Summary
+ This error is returned when an invalid endpoint number is provided to
+ an API call.
+
+ Description
+ This error is returned when an invalid endpoint number is specified in
+ an API call. The endpoint number may be invalid because it is greater
+ than 15, or because it was a reference to an endpoint that is invalid
+ for West Bridge (2, 4, 6, or 8).
+
+ See Also
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbGetEndPointConfig
+ * CyAsUsbReadData
+ * CyAsUsbWriteData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+ * CyAsUsbSetStall
+ * CyAsUsbGetStall
+*/
+#define CY_AS_ERROR_INVALID_ENDPOINT (21)
+
+/* Summary
+ This error is returned when an invalid descriptor type
+ is specified in an API call.
+
+ Description
+ This error is returned when an invalid descriptor type
+ is specified in an API call.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+*/
+#define CY_AS_ERROR_INVALID_DESCRIPTOR (22)
+
+/* Summary
+ This error is returned when an invalid descriptor index
+ is specified in an API call.
+
+ Description
+ This error is returned when an invalid descriptor index
+ is specified in an API call.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+*/
+#define CY_AS_ERROR_BAD_INDEX (23)
+
+/* Summary
+ This error is returned if trying to set a USB descriptor
+ when in the P port enumeration mode.
+
+ Description
+ This error is returned if trying to set a USB descriptor
+ when in the P port enumeration mode.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+*/
+#define CY_AS_ERROR_BAD_ENUMERATION_MODE (24)
+
+/* Summary
+ This error is returned when the endpoint configuration specified
+ is not valid.
+
+ Description
+ This error is returned when the endpoint configuration specified
+ is not valid.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+ * CyAsUsbCommitConfig
+*/
+#define CY_AS_ERROR_INVALID_CONFIGURATION (25)
+
+/* Summary
+ This error is returned when the API cannot verify it is connected
+ to an West Bridge device.
+
+ Description
+ When the API is initialized, the API tries to read the ID register from
+ the West Bridge device. The value from this ID register should match the
+ value expected before communications with West Bridge are established. This
+ error means that the contents of the ID register cannot be verified.
+
+ See Also
+ * CyAsMiscConfigureDevice
+*/
+#define CY_AS_ERROR_NO_ANTIOCH (26)
+
+/* Summary
+ This error is returned when an API function is called and
+ CyAsMiscConfigureDevice has not been called to configure West Bridge
+ for the current environment.
+
+ Description
+ This error is returned when an API function is called and
+ CyAsMiscConfigureDevice has not been called to configure West Bridge for
+ the current environment.
+
+ See Also
+ * Almost all API function
+*/
+#define CY_AS_ERROR_NOT_CONFIGURED (27)
+
+/* Summary
+ This error is returned when West Bridge cannot allocate memory required for
+ internal API operations.
+
+ Description
+ This error is returned when West Bridge cannot allocate memory required for
+ internal API operations.
+
+ See Also
+ * Almost all API functoins
+*/
+#define CY_AS_ERROR_OUT_OF_MEMORY (28)
+
+/* Summary
+ This error is returned when a module is being started that has
+ already been started.
+
+ Description
+ This error is returned when a module is being started and that module
+ has already been started. This error does not occur with the
+ CyAsStorageStart() or CyAsUsbStart() functions as the storage and
+ USB modules are reference counted.
+
+ Note
+ At the current time, this error is returned by module internal to the API but
+ not returned by any of the API functions.
+*/
+#define CY_AS_ERROR_NESTED_SLEEP (29)
+
+/* Summary
+ This error is returned when an operation is attempted on an endpoint that has
+ been disabled.
+
+ Description
+ This error is returned when an operation is attempted on an endpoint that has
+ been disabled.
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbWriteData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+*/
+#define CY_AS_ERROR_ENDPOINT_DISABLED (30)
+
+/* Summary
+ This error is returned when a call is made to an API function when
+ the device is in standby.
+
+ Description
+ When the West Bridge device is in standby, the only two API functions that
+ can be called are CyAsMiscInStandby() and CyAsMiscLeaveStandby().
+ Calling any other API function will result in this error.
+
+ See Also
+*/
+#define CY_AS_ERROR_IN_STANDBY (31)
+
+/* Summary
+ This error is returned when an API call is made with an invalid handle value.
+
+ Description
+ This error is returned when an API call is made with an invalid handle value.
+
+ See Also
+*/
+#define CY_AS_ERROR_INVALID_HANDLE (32)
+
+/* Summary
+ This error is returned when an invalid response is returned from
+ the West Bridge device.
+
+ Description
+ Many of the API calls result in requests made to the West Bridge
+ device. This error occurs when the response from West Bridge is
+ invalid and generally indicates that the West Bridge device
+ should be reset.
+
+ See Also
+*/
+#define CY_AS_ERROR_INVALID_RESPONSE (33)
+
+/* Summary
+ This error is returned from the callback function for any asynchronous
+ read or write request that is canceled.
+
+ Description
+ When asynchronous requests are canceled, this error is passed to the
+ callback function associated with the request to indicate that the
+ request has been canceled
+
+ See Also
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+ * CyAsStorageCancelAsync
+ * CyAsUsbCancelAsync
+*/
+#define CY_AS_ERROR_CANCELED (34)
+
+/* Summary
+ This error is returned when the call to create sleep channel fails
+ in the HAL layer.
+
+ Description
+ This error is returned when the call to create sleep channel fails
+ in the HAL layer.
+
+ See Also
+ * CyAsMiscConfigureDevice
+*/
+#define CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED (35)
+
+/* Summary
+ This error is returned when the call to CyAsMiscLeaveStandby
+ is made and the device is not in standby.
+
+ Description
+ This error is returned when the call to CyAsMiscLeaveStandby
+ is made and the device is not in standby.
+
+ See Also
+*/
+#define CY_AS_ERROR_NOT_IN_STANDBY (36)
+
+/* Summary
+ This error is returned when the call to destroy sleep channel fails
+ in the HAL layer.
+
+ Description
+ This error is returned when the call to destroy sleep channel fails
+ in the HAL layer.
+
+ See Also
+ * CyAsMiscDestroyDevice
+*/
+#define CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED (37)
+
+/* Summary
+ This error is returned when an invalid resource is specified to a call
+ to CyAsMiscAcquireResource() or CyAsMiscReleaseResource()
+
+ Description
+ This error is returned when an invalid resource is specified to a call
+ to CyAsMiscAcquireResource() or CyAsMiscReleaseResource()
+
+ See Also
+ * CyAsMiscAcquireResource
+ * CyAsMiscReleaseResource
+*/
+#define CY_AS_ERROR_INVALID_RESOURCE (38)
+
+/* Summary
+ This error occurs when an operation is requested on an endpoint that has
+ a currently pending async operation.
+
+ Description
+ There can only be a single asynchronous pending operation on a given
+ endpoint and while the operation is pending on other operation can occur
+ on the endpoint. In addition, the device cannot enter standby while
+ any asynchronous operations are pending.
+
+ See Also
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsUsbReadData
+ * CyAsUsbWriteData
+ * CyAsMiscEnterStandby
+*/
+#define CY_AS_ERROR_ASYNC_PENDING (39)
+
+/* Summary
+ This error is returned when a call to CyAsStorageCancelAsync() or
+ CyAsUsbCancelAsync() is made when no asynchronous request is pending.
+
+ Description
+ This error is returned when a call to CyAsStorageCancelAsync() or
+ CyAsUsbCancelAsync() is made when no asynchronous request is pending.
+
+ See Also
+ * CyAsStorageCancelAsync
+ * CyAsUsbCancelAsync
+*/
+#define CY_AS_ERROR_ASYNC_NOT_PENDING (40)
+
+/* Summary
+ This error is returned when a request is made to put the West Bridge device
+ into standby mode while the USB stack is still active.
+
+ Description
+ This error is returned when a request is made to put the West Bridge device
+ into standby mode while the USB stack is still active. You must call the
+ function CyAsUsbStop() in order to shut down the USB stack in order to go
+ into the standby mode.
+
+ See Also
+ * CyAsMiscEnterStandby
+*/
+#define CY_AS_ERROR_USB_RUNNING (41)
+
+/* Summary
+ A request for in the wrong direction was issued on an endpoint.
+
+ Description
+ This error is returned when a write is attempted on an OUT endpoint or
+ a read is attempted on an IN endpoint.
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbWriteData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+*/
+#define CY_AS_ERROR_USB_BAD_DIRECTION (42)
+
+/* Summary
+ An invalid request was received
+
+ Description
+ This error is isused if an invalid request is issued.
+*/
+#define CY_AS_ERROR_INVALID_REQUEST (43)
+
+/* Summary
+ An ACK request was requested while no setup packet was pending.
+
+ Description
+ This error is issued if CyAsUsbAckSetupPacket() is called when no
+ setup packet is pending.
+*/
+#define CY_AS_ERROR_NO_SETUP_PACKET_PENDING (44)
+
+/* Summary
+ A call was made to a API function that cannot be called from a callback.
+
+ Description
+ Only asynchronous functions can be called from within West Bridge callbacks.
+ This error results when an invalid function is called from a callback.
+*/
+#define CY_AS_ERROR_INVALID_IN_CALLBACK (45)
+
+/* Summary
+ A call was made to CyAsUsbSetEndPointConfig() before
+ CyAsUsbSetPhysicalConfiguration() was called.
+
+ Description
+ When logical endpoints are configured, you must define the physical
+ endpoint for the logical endpoint being configured. Therefore
+ CyAsUsbSetPhysicalConfiguration() must be called to define the
+ physical endpoints before calling CyAsUsbSetEndPointConfig().
+*/
+#define CY_AS_ERROR_ENDPOINT_CONFIG_NOT_SET (46)
+
+/* Summary
+ The physical endpoint referenced is not valid in the current physical
+ configuration
+
+ Description
+ When logical endpoints are configured, you must define the physical
+ endpoint for the logical endpoint being configured. Given the
+ current physical configuration, the physical endpoint referenced
+ is not valid.
+*/
+#define CY_AS_ERROR_INVALID_PHYSICAL_ENDPOINT (47)
+
+/* Summary
+ The data supplied to the CyAsMiscDownloadFirmware() call is not
+ aligned on a WORD (16 bit) boundary.
+
+ Description
+ Many systems have problems with the transfer of data a word at a
+ time when the data is not word aligned. For this reason, we
+ require that the firmware image be aligned on a word boundary and
+ be an even number of bytes. This error is returned if these
+ conditions are not met.
+*/
+#define CY_AS_ERROR_ALIGNMENT_ERROR (48)
+
+/* Summary
+ A call was made to destroy the West Bridge device, but the USB
+ stack or the storage stack was will running.
+
+ Description
+ Before calling CyAsMiscDestroyDevice to destroy an West Bridge
+ device created via a call to CyAsMiscCreateDevice, the USB and
+ STORAGE stacks much be stopped via calls to CyAsUsbStop and
+ CyAsStorageStop. This error indicates that one of these two
+ stacks have not been stopped.
+*/
+#define CY_AS_ERROR_STILL_RUNNING (49)
+
+/* Summary
+ A call was made to the API for a function that is not yet supported.
+
+ Description
+ There are calls that are not yet supported that may be called through
+ the API. This is done to maintain compatibility in the future with
+ the API. This error is returned if you are asking for a capability
+ that does not yet exist.
+*/
+#define CY_AS_ERROR_NOT_YET_SUPPORTED (50)
+
+/* Summary
+ A NULL callback was provided where a non-NULL callback was required
+
+ Description
+ When async IO function are called, a callback is required to indicate
+ that the IO has completed. This callback must be non-NULL.
+*/
+#define CY_AS_ERROR_NULL_CALLBACK (51)
+
+/* Summary
+ This error is returned when a request is made to put the West Bridge device
+ into standby mode while the storage stack is still active.
+
+ Description
+ This error is returned when a request is made to put the West Bridge device
+ into standby mode while the storage stack is still active. You must call the
+ function CyAsStorageStop() in order to shut down the storage stack in order
+ to go into the standby mode.
+
+ See Also
+ * CyAsMiscEnterStandby
+*/
+#define CY_AS_ERROR_STORAGE_RUNNING (52)
+
+/* Summary
+ This error is returned when an operation is attempted that cannot be
+ completed while the USB stack is connected to a USB host.
+
+ Description
+ This error is returned when an operation is attempted that cannot be
+ completed while the USB stack is connected to a USB host. In order
+ to sucessfully complete the desired operation, CyAsUsbDisconnect()
+ must be called to disconnect from the host.
+*/
+#define CY_AS_ERROR_USB_CONNECTED (53)
+
+/* Summary
+ This error is returned when a USB disconnect is attempted and the
+ West Bridge device is not connected.
+
+ Description
+ This error is returned when a USB disconnect is attempted and the
+ West Bridge device is not connected.
+*/
+#define CY_AS_ERROR_USB_NOT_CONNECTED (54)
+
+/* Summary
+ This error is returned when an P2S storage operation attempted
+ and data could not be read or written to the storage media.
+
+ Description
+ This error is returned when an P2S storage operation attempted
+ and data could not be read or written to the storage media. If
+ this error is recevied then a retry can be done.
+*/
+#define CY_AS_ERROR_MEDIA_ACCESS_FAILURE (55)
+
+/* Summary
+ This error is returned when an P2S storage operation attempted
+ and the media is write protected.
+
+ Description
+ This error is returned when an P2S storage operation attempted
+ and the media is write protected.
+*/
+#define CY_AS_ERROR_MEDIA_WRITE_PROTECTED (56)
+
+/* Summary
+ This error is returned when an attempt is made to cancel a request
+ that has already been sent to the West Bridge.
+
+ Description
+ It is not possible to cancel an asynchronous storage read/write
+ operation after the actual data transfer with the West Bridge
+ has started. This error is returned if CyAsStorageCancelAsync
+ is called to cancel such a request.
+ */
+#define CY_AS_ERROR_OPERATION_IN_TRANSIT (57)
+
+/* Summary
+ This error is returned when an invalid parameter is passed to
+ one of the APIs.
+
+ Description
+ Some of the West Bridge APIs are applicable to only specific
+ media types, devices etc. This error code is returned when a
+ API is called with an invalid parameter type.
+ */
+#define CY_AS_ERROR_INVALID_PARAMETER (58)
+
+/* Summary
+ This error is returned if an API is not supported in the current setup.
+
+ Description
+ Some of the West Bridge APIs work only with specific device types
+ or firmware images. This error is returned when such APIs are called
+ when the current device or firmware does not support the invoked API
+ function.
+ */
+#define CY_AS_ERROR_NOT_SUPPORTED (59)
+
+/* Summary
+ This error is returned when a call is made to one of the Storage or
+ USB APIs while the device is in suspend mode.
+
+ Description
+ This error is returned when a call is made to one of the storage or
+ USB APIs while the device is in suspend mode.
+ */
+#define CY_AS_ERROR_IN_SUSPEND (60)
+
+/* Summary
+ This error is returned when the call to CyAsMiscLeaveSuspend
+ is made and the device is not in suspend mode.
+
+ Description
+ This error is returned when the call to CyAsMiscLeaveSuspend
+ is made and the device is not in suspend mode.
+ */
+#define CY_AS_ERROR_NOT_IN_SUSPEND (61)
+
+/* Summary
+ This error is returned when a command that is disabled by USB is called.
+
+ Description
+ The remote wakeup capability should be exercised only if enabled by the
+ USB host. This error is returned when the CyAsUsbSignalRemoteWakeup API
+ is called when the feature has not been enabled by the USB host.
+ */
+#define CY_AS_ERROR_FEATURE_NOT_ENABLED (62)
+
+/* Summary
+ This error is returned when an Async storage read or write is called before a
+ query device call is issued.
+
+ Description
+ In order for the SDK to properly set up a DMA the block size of a given media
+ needs to be known. This is done by making a call to CyAsStorageQueryDevice.
+ This call only needs to be made once per device. If this call is not issued
+ before an Async read or write is issued this error code is returned.
+ */
+#define CY_AS_ERROR_QUERY_DEVICE_NEEDED (63)
+
+/* Summary
+ This error is returned when a call is made to USB or STORAGE Start or
+ Stop before a prior Start or Stop has finished.
+
+ Description
+ The USB and STORAGE start and stop functions can only be called if a
+ prior start or stop function call has fully completed. This means when
+ an async EX call is made you must wait until the callback for that call
+ has been completed before calling start or stop again.
+ */
+#define CY_AS_ERROR_STARTSTOP_PENDING (64)
+
+/* Summary
+ This error is returned when a request is made for a bus that does not exist
+
+ Description
+ This error is returned when a request is made that references a bus
+ number that does not exist. This error is returned when the bus number
+ is not present in the current system, or if the bus number given is not
+ valid.
+
+ See Also
+ * CyAsMiscSetTraceLevel
+ * CyAsStorageClaim
+ * CyAsStorageRelease
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_ERROR_NO_SUCH_BUS (65)
+
+/* Summary
+ This error is returned when the bus corresponding to a media type cannot
+ be resolved.
+
+ Description
+ In some S-Port configurations, the same media type may be supported on
+ multiple buses. In this case, it is not possible to resolve the target
+ address based on the media type. This error indicates that only
+ bus-based addressing is supported in a particular run-time
+ configuration.
+
+ See Also
+ * CyAsMediaType
+ * CyAsBusNumber_t
+ */
+#define CY_AS_ERROR_ADDRESS_RESOLUTION_ERROR (66)
+
+/* Summary
+ This error is returned when an invalid command is passed to the
+ CyAsStorageSDIOSync() function.
+
+ Description
+ This error indiactes an unknown Command type was passed to the SDIO
+ command handler function.
+ */
+
+#define CY_AS_ERROR_INVALID_COMMAND (67)
+
+
+/* Summary
+ This error is returned when an invalid function /uninitialized
+ function is passed to an SDIO function.
+
+ Description
+ This error indiactes an unknown/uninitialized function number was
+ passed to a SDIO function.
+ */
+#define CY_AS_ERROR_INVALID_FUNCTION (68)
+
+/* Summary
+ This error is returned when an invalid block size is passed to
+ CyAsSdioSetBlocksize().
+
+ Description
+ This error is returned when an invalid block size (greater than
+ maximum block size supported) is passed to CyAsSdioSetBlocksize().
+ */
+
+#define CY_AS_ERROR_INVALID_BLOCKSIZE (69)
+
+/* Summary
+ This error is returned when an tuple requested is not found.
+
+ Description
+ This error is returned when an tuple requested is not found.
+ */
+#define CY_AS_ERROR_TUPLE_NOT_FOUND (70)
+
+/* Summary
+ This error is returned when an extended IO operation to an SDIO function is
+ Aborted.
+ Description
+ This error is returned when an extended IO operation to an SDIO function is
+ Aborted. */
+#define CY_AS_ERROR_IO_ABORTED (71)
+
+/* Summary
+ This error is returned when an extended IO operation to an SDIO function is
+ Suspended.
+ Description
+ This error is returned when an extended IO operation to an SDIO function is
+ Suspended. */
+#define CY_AS_ERROR_IO_SUSPENDED (72)
+
+/* Summary
+ This error is returned when IO is attempted to a Suspended SDIO function.
+ Description
+ This error is returned when IO is attempted to a Suspended SDIO function. */
+#define CY_AS_ERROR_FUNCTION_SUSPENDED (73)
+
+/* Summary
+ This error is returned if an MTP function is called before MTPStart
+ has completed.
+ Description
+ This error is returned if an MTP function is called before MTPStart
+ has completed.
+*/
+#define CY_AS_ERROR_MTP_NOT_STARTED (74)
+
+/* Summary
+ This error is returned by API functions that are not valid in MTP
+ mode (CyAsStorageClaim for example)
+ Description
+ This error is returned by API functions that are not valid in MTP
+ mode (CyAsStorageClaim for example)
+*/
+#define CY_AS_ERROR_NOT_VALID_IN_MTP (75)
+
+/* Summary
+ This error is returned when an attempt is made to partition a
+ storage device that is already partitioned.
+
+ Description
+ This error is returned when an attempt is made to partition a
+ storage device that is already partitioned.
+*/
+#define CY_AS_ERROR_ALREADY_PARTITIONED (76)
+
+/* Summary
+ This error is returned when a call is made to
+ CyAsUsbSelectMSPartitions after CyAsUsbSetEnumConfig is called.
+
+ Description
+ This error is returned when a call is made to
+ CyAsUsbSelectMSPartitions after CyAsUsbSetEnumConfig is called.
+ */
+#define CY_AS_ERROR_INVALID_CALL_SEQUENCE (77)
+
+/* Summary
+ This error is returned when a StorageWrite opperation is attempted
+ during an ongoing MTP transfer.
+ Description
+ This error is returned when a StorageWrite opperation is attempted
+ during an ongoing MTP transfer. A MTP transfer is initiated by a
+ call to CyAsMTPInitSendObject or CyAsMTPInitGetObject and is not
+ finished until the CyAsMTPSendObjectComplete or
+ CyAsMTPGetObjectComplete event is generated.
+*/
+#define CY_AS_ERROR_NOT_VALID_DURING_MTP (78)
+
+/* Summary
+ This error is returned when a StorageRead or StorageWrite is
+ attempted while a UsbRead or UsbWrite on a Turbo endpoint (2 or 6) is
+ pending, or visa versa.
+ Description
+ When there is a pending usb read or write on a turbo endpoint (2 or 6)
+ a storage read or write call may not be performed. Similarly when there
+ is a pending storage read or write a usb read or write may not be
+ performed on a turbo endpoint (2 or 6).
+*/
+#define CY_AS_ERROR_STORAGE_EP_TURBO_EP_CONFLICT (79)
+
+/* Summary
+ This error is returned when processor requests to reserve greater
+ number of zones than available for proc booting via lna firmware.
+
+ Description
+ Astoria does not allocate any nand zones for the processor in this case.
+*/
+#define CY_AS_ERROR_EXCEEDED_NUM_ZONES_AVAIL (80)
+
+#endif /* _INCLUDED_CYASERR_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h
new file mode 100644
index 000000000000..b695ba1a9110
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashal.h
@@ -0,0 +1,108 @@
+/* Cypress West Bridge API header file (cyashal.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASHAL_H_
+#define _INCLUDED_CYASHAL_H_
+
+#if !defined(__doxygen__)
+
+/* The possible HAL layers defined and implemented by Cypress */
+
+#ifdef __CY_ASTORIA_FPGA_HAL__
+#ifdef CY_HAL_DEFINED
+#error only one HAL layer can be defined
+#endif
+
+#define CY_HAL_DEFINED
+
+#include "cyashalfpga.h"
+#endif
+
+/***** SCM User space HAL ****/
+#ifdef __CY_ASTORIA_SCM_HAL__
+#ifdef CY_HAL_DEFINED
+#error only one HAL layer can be defined
+#endif
+
+#define CY_HAL_DEFINEDŚŚ
+
+#include "cyanhalscm.h"
+#endif
+/***** SCM User space HAL ****/
+
+/***** SCM Kernel HAL ****/
+#ifdef __CY_ASTORIA_SCM_KERNEL_HAL__
+#ifdef CY_HAL_DEFINED
+#error only one HAL layer can be defined
+#endif
+
+#define CY_HAL_DEFINEDÅš
+
+#include "cyanhalscm_kernel.h"
+#endif
+/***** SCM Kernel HAL ****/
+
+/***** OMAP5912 Kernel HAL ****/
+#ifdef __CY_ASTORIA_OMAP_5912_KERNEL_HAL__
+ #ifdef CY_HAL_DEFINED
+ #error only one HAL layer can be defined
+ #endif
+
+ #define CY_HAL_DEFINED
+
+ #include "cyanhalomap_kernel.h"
+#endif
+/***** eof OMAP5912 Kernel HAL ****/
+
+
+
+/***** OMAP3430 Kernel HAL ****/
+#ifdef CONFIG_MACH_OMAP3_WESTBRIDGE_AST_PNAND_HAL
+
+ #ifdef CY_HAL_DEFINED
+ #error only one HAL layer can be defined
+ #endif
+
+ #define CY_HAL_DEFINED
+/* moved to staging location, eventual implementation
+ * considered is here
+ * #include mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h>
+*/
+ #include "../../../arch/arm/plat-omap/include/mach/westbridge/westbridge-omap3-pnand-hal/cyashalomap_kernel.h"
+
+#endif
+/*****************************/
+
+
+/******/
+#ifdef __CY_ASTORIA_CUSTOMER_HAL__
+#ifdef CY_HAL_DEFINED
+#error only one HAL layer can be defined
+#endif
+br
+#define CY_HAL_DEFINED
+#include "cyashal_customer.h"
+
+#endif
+
+#endif /* __doxygen__ */
+
+#endif /* _INCLUDED_CYASHAL_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashalcb.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashalcb.h
new file mode 100644
index 000000000000..d48a7f4b147f
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashalcb.h
@@ -0,0 +1,44 @@
+/* Cypress West Bridge API header file (cyashalcb.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASHALCB_H_
+#define _INCLUDED_CYASHALCB_H_
+
+/* Summary
+ This type defines a callback function type called when a
+ DMA operation has completed.
+
+ Description
+
+ See Also
+ * CyAsHalDmaRegisterCallback
+ * CyAsHalDmaSetupWrite
+ * CyAsHalDmaSetupRead
+*/
+typedef void (*cy_as_hal_dma_complete_callback)(
+ cy_as_hal_device_tag tag,
+ cy_as_end_point_number_t ep,
+ uint32_t cnt,
+ cy_as_return_status_t ret) ;
+
+typedef cy_as_hal_dma_complete_callback \
+ cy_an_hal_dma_complete_callback;
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashaldoc.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashaldoc.h
new file mode 100644
index 000000000000..2cfe4fb4cf68
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyashaldoc.h
@@ -0,0 +1,800 @@
+/* Cypress West Bridge API header file (cyashaldoc.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASHALDOC_H_
+#define _INCLUDED_CYASHALDOC_H_
+
+#include "cyashaldef.h"
+
+/*@@Hardware Abstraction Layer (HAL)
+ Summary
+ This software module is supplied by the user of the West Bridge
+ API. This module contains the software that is specific to the
+ hardware implementation or operating system of the client
+ system.
+
+ * Sleep Channels *
+ A sleep channel is a operating system object that provides that
+ capability for one thread or process to sleep while waiting on
+ the completion of some hardware event. The hardware event is
+ usually processed by a hardware interrupt and the interrupt
+ handler then wakes the thread or process that is sleeping.
+
+ A sleep channel provides the mechanism for this operation. A
+ sleep channel is created and initialized during the API
+ initialization. When the API needs to wait for the hardware,
+ the API performs a SleepOn() operation on the sleep channel.
+ When hardware event occurs, an interrupt handler processes the
+ event and then performs a Wake() operation on the sleep channel
+ to wake the sleeping process or thread.
+
+ * DMA Model *
+ When the West Bridge API needs to transfer USB or storage data
+ to/from the West Bridge device, this is done using a "DMA"
+ operation. In this context the term DMA is used loosely as the
+ West Bridge API does not really care if the data is transferred
+ using a burst read or write operation, or if the data is
+ transferred using programmed I/O operations. When a "DMA"
+ operation is needed, the West Bridge API calls either
+ CyAsHalDmaSetupRead() or CyAsHalDmaSetupWrite() depending on the
+ direction of the data flow. The West Bridge API expects the
+ "DMA" operation requested in the call to be completed and the
+ registered "DMA complete" callback to be called.
+
+ The West Bridge API looks at several factors to determine the
+ size of the "DMA" request to pass to the HAL layer. First the
+ West Bridge API calls CyAsHalDmaMaxRequestSize() to determine
+ the maximum amount of data the HAL layer can accept for a "DMA"
+ operation on the requested endpoint. The West Bridge API will
+ never exceed this value in a "DMA" request to the HAL layer.
+ The West Bridge API also sends the maximum amount of data the
+ West Bridge device can accept as part of the "DMA" request. If
+ the amount of data in the "DMA" request to the HAL layer
+ exceeds the amount of data the West Bridge device can accept,
+ it is expected that the HAL layer has the ability to break the
+ request into multiple operations.
+
+ If the HAL implementation requires the API to handle the size
+ of the "DMA" requests for one or more endpoints, the value
+ CY_AS_DMA_MAX_SIZE_HW_SIZE can be returned from the
+ CyAsHalDmaMaxRequestSize() call. In this case, the API assumes
+ that the maximum size of each "DMA" request should be limited
+ to the maximum that can be accepted by the endpoint in question.
+
+ Notes
+ See the <install>/api/hal/scm_kernel/cyashalscm_kernel.c file
+ for an example of how the DMA request size can be managed by
+ the HAL implementation.
+
+ * Interrupt Handling *
+ The HAL implementation is required to handle interrupts arriving
+ from the West Bridge device, and call the appropriate handlers.
+ If the interrupt arriving is one of PLLLOCKINT, PMINT, MBINT or
+ MCUINT, the CyAsIntrServiceInterrupt API should be called to
+ service the interrupt. If the interrupt arriving is DRQINT, the
+ HAL should identify the endpoint corresponding to which the DRQ
+ is being generated and perform the read/write transfer from the
+ West Bridge. See the <install>/api/hal/scm_kernel/
+ cyashalscm_kernel.c or <install>/api/hal/fpga/cyashalfpga.c
+ reference HAL implementations for examples.
+
+ The HAL implementation can choose to poll the West Bridge
+ interrupt status register instead of using interrupts. In this
+ case, the polling has to be performed from a different thread/
+ task than the one running the APIs. This is required because
+ there are API calls that block on the reception of data from the
+ West Bridge, which is delivered only through the interrupt
+ handlers.
+
+ * Required Functions *
+ This section defines the types and functions that must be
+ supplied in order to provide a complete HAL layer for the
+ West Bridge API.
+
+ Types that must be supplied:
+ * CyAsHalSleepChannel
+
+ Hardware functions that must be supplied:
+ * CyAsHalWriteRegister
+ * CyAsHalReadRegister
+ * CyAsHalDmaSetupWrite
+ * CyAsHalDmaSetupRead
+ * CyAsHalDmaCancelRequest
+ * CyAsHalDmaRegisterCallback
+ * CyAsHalDmaMaxRequestSize
+ * CyAsHalSetWakeupPin
+ * CyAsHalSyncDeviceClocks
+ * CyAsHalInitDevRegisters
+ * CyAsHalReadRegsBeforeStandby
+ * CyAsHalRestoreRegsAfterStandby
+
+ Operating system functions that must be supplied:
+ * CyAsHalAlloc
+ * CyAsHalFree
+ * CyAsHalCBAlloc
+ * CyAsHalCBFree
+ * CyAsHalMemSet
+ * CyAsHalCreateSleepChannel
+ * CyAsHalDestroySleepChannel
+ * CyAsHalSleepOn
+ * CyAsHalWake
+ * CyAsHalDisableInterrupts
+ * CyAsHalEnableInterrupts
+ * CyAsHalSleep150
+ * CyAsHalSleep
+ * CyAsHalAssert
+ * CyAsHalPrintMessage
+ * CyAsHalIsPolling
+*/
+
+/* Summary
+ This is the type that represents a sleep channel
+
+ Description
+ A sleep channel is an operating system object that, when a
+ thread of control waits on the sleep channel, the thread
+ sleeps until another thread signals the sleep object. This
+ object is generally used when a high level API is called
+ and must wait for a response that is supplied in an interrupt
+ handler. The thread calling the API is put into a sleep
+ state and when the reply arrives via the interrupt handler,
+ the interrupt handler wakes the sleeping thread to indicate
+ that the expect reply is available.
+*/
+typedef struct cy_as_hal_sleep_channel {
+ /* This structure is filled in with OS specific information
+ to implementat a sleep channel */
+ int m_channel ;
+} cy_as_hal_sleep_channel ;
+
+/* Summary
+ This function is called to write a register value
+
+ Description
+ This function is called to write a specific register to a
+ specific value. The tag identifies the device of interest.
+ The address is relative to the base address of the West
+ Bridge device.
+
+ Returns
+ Nothing
+
+ See Also
+ * CyAsHalDeviceTag
+ * CyAsHalReadRegister
+*/
+EXTERN void
+cy_as_hal_write_register(
+/* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The address we are writing to */
+ uint16_t addr,
+ /* The value to write to the register */
+ uint16_t value
+ ) ;
+
+/* Summary
+ This function is called to read a register value
+
+ Description
+ This function is called to read the contents of a specific
+ register. The tag identifies the device of interest. The
+ address is relative to the base address of the West Bridge
+ device.
+
+ Returns
+ Contents of the register
+
+ See Also
+ * CyAsHalDeviceTag
+ * CyAsHalWriteRegister
+*/
+EXTERN uint16_t
+cy_as_hal_read_register(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The address we are writing to */
+ uint16_t addr
+ ) ;
+
+/* Summary
+ This function initiates a DMA write operation to write
+ to West Bridge
+
+ Description
+ This function initiates a DMA write operation. The request
+ size will not exceed the value the HAL layer returned via
+ CyAsHalDmaMaxRequestSize(). This request size may exceed
+ the size of what the West Bridge device will accept as on
+ packet and the HAL layer may need to divide the request
+ into multiple hardware DMA operations.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalDmaSetupRead
+ * CyAsHalDmaMaxRequestSize
+*/
+EXTERN void
+cy_as_hal_dma_setup_write(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The endpoint we are writing to */
+ cy_as_end_point_number_t ep,
+ /* The data to write via DMA */
+ void *buf_p,
+ /* The size of the data at buf_p */
+ uint32_t size,
+ /* The maximum amount of data that the endpoint
+ * can accept as one packet */
+ uint16_t maxsize
+ ) ;
+
+/* Summary
+ This function initiates a DMA read operation from West Bridge
+
+ Description
+ This function initiates a DMA read operation. The request
+ size will not exceed the value the HAL layer returned via
+ CyAsHalDmaMaxRequestSize(). This request size may exceed
+ the size of what the Anitoch will accept as one packet and
+ the HAL layer may need to divide the request into multiple
+ hardware DMA operations.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalDmaSetupRead
+ * CyAsHalDmaMaxRequestSize
+*/
+EXTERN void
+cy_as_hal_dma_setup_read(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The endpoint we are reading from */
+ cy_as_end_point_number_t ep,
+ /* The buffer to read data into */
+ void *buf_p,
+ /* The amount of data to read */
+ uint32_t size,
+ /* The maximum amount of data that the endpoint
+ * can provide in one DMA operation */
+ uint16_t maxsize
+ ) ;
+
+/* Summary
+ This function cancels a pending DMA request
+
+ Description
+ This function cancels a pending DMA request that has been
+ passed down to the hardware. The HAL layer can elect to
+ physically cancel the request if possible, or just ignore
+ the results of the request if it is not possible.
+
+ Returns
+ None
+*/
+EXTERN void
+cy_as_hal_dma_cancel_request(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The endpoint we are reading from */
+ cy_as_end_point_number_t ep
+ ) ;
+
+/* Summary
+ This function registers a callback function to be called when
+ a DMA request is completed
+
+ Description
+ This function registers a callback that is called when a request
+ issued via CyAsHalDmaSetupWrite() or CyAsHalDmaSetupRead() has
+ completed.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalDmaSetupWrite
+ * CyAsHalDmaSetupRead
+*/
+EXTERN void
+cy_as_hal_dma_register_callback(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The callback to call when a request has completed */
+ cy_as_hal_dma_complete_callback cb
+ ) ;
+
+/* Summary
+ This function returns the maximum size of a DMA request that can
+ be handled by the HAL.
+
+ Description
+ When DMA requests are passed to the HAL layer for processing,
+ the HAL layer may have a limit on the size of the request that
+ can be handled. This function is called by the DMA manager for
+ an endpoint when DMA is enabled to get the maximum size of data
+ the HAL layer can handle. The DMA manager insures that a request
+ is never sent to the HAL layer that exceeds the size returned by
+ this function.
+
+ Returns
+ the maximum size of DMA request the HAL layer can handle
+*/
+EXTERN uint32_t
+cy_as_hal_dma_max_request_size(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep
+ ) ;
+
+/* Summary
+ This function sets the WAKEUP pin to a specific state on the
+ West Bridge device.
+
+ Description
+ In order to enter the standby mode, the WAKEUP pin must be
+ de-asserted. In order to resume from standby mode, the WAKEUP
+ pin must be asserted. This function provides the mechanism to
+ do this.
+
+ Returns
+ 1 if the pin was changed, 0 if the HAL layer does not support
+ changing this pin
+*/
+EXTERN uint32_t
+cy_as_hal_set_wakeup_pin(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* The desired state of the wakeup pin */
+ cy_bool state
+ ) ;
+
+/* Summary
+ Synchronise the West Bridge device clocks to re-establish device
+ connectivity.
+
+ Description
+ When the Astoria bridge device is working in SPI mode, a long
+ period of inactivity can cause a loss of serial synchronisation
+ between the processor and Astoria. This function is called by
+ the API when it detects such a condition, and is expected to take
+ the action required to re-establish clock synchronisation between
+ the devices.
+
+ Returns
+ CyTrue if the attempt to re-synchronise is successful,
+ CyFalse if not.
+ */
+EXTERN cy_bool
+cy_as_hal_sync_device_clocks(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ ) ;
+
+/* Summary
+ Initialize West Bridge device registers that may have been
+ modified while the device was in standby.
+
+ Description
+ The content of some West Bridge registers may be lost when
+ the device is placed in standby mode. This function restores
+ these register contents so that the device can continue to
+ function normally after it wakes up from standby mode.
+
+ This function is required to perform operations only when the
+ API is being used with the Astoria device in one of the PNAND
+ modes or in the PSPI mode. It can be a no-operation in all
+ other cases.
+
+ Returns
+ None
+ */
+EXTERN void
+cy_as_hal_init_dev_registers(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag,
+ /* Indicates whether this is a wake-up from standby. */
+ cy_bool is_standby_wakeup
+ ) ;
+
+/* Summary
+ This function reads a set of P-port accessible device registers and
+ stores their value for later use.
+
+ Description
+ The West Bridge Astoria device silicon has a known problem when
+ operating in SPI mode on the P-port, where some of the device
+ registers lose their value when the device goes in and out of
+ standby mode. The suggested work-around is to reset the Astoria
+ device as part of the wakeup procedure from standby.
+
+ This requires that the values of some of the P-port accessible
+ registers be restored to their pre-standby values after it has
+ been reset. This HAL function can be used to read and store
+ the values of these registers at the point where the device is
+ being placed in standby mode.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalRestoreRegsAfterStandby
+ */
+EXTERN void
+cy_as_hal_read_regs_before_standby(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag
+ ) ;
+
+/* Summary
+ This function restores the old values to a set of P-port
+ accessible device registers.
+
+ Description
+ This function is part of the work-around to a known West
+ Bridge Astoria device error when operating in SPI mode on
+ the P-port. This function is used to restore a set of
+ P-port accessible registers to the values they had before
+ the device was placed in standby mode.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalRestoreRegsAfterStandby
+ */
+EXTERN void
+cy_as_hal_restore_regs_after_standby(
+ /* The tag to ID a specific West Bridge device */
+ cy_as_hal_device_tag tag
+ ) ;
+
+/*
+ * The functions below this comment are part of the HAL layer,
+ * as the HAL layer consists of the abstraction to both the
+ * hardware platform and the operating system. However; the
+ * functions below this comment all relate to the operating
+ * environment and not specifically to the hardware platform
+ * or specific device.
+ */
+
+/* Summary
+ This function allocates a block of memory
+
+ Description
+ This is the HAL layer equivalent of the malloc() function.
+
+ Returns
+ a pointer to a block of memory
+
+ See Also
+ * CyAsHalFree
+*/
+EXTERN void *
+cy_as_hal_alloc(
+ /* The size of the memory block to allocate */
+ uint32_t size
+ ) ;
+
+/* Summary
+ This function frees a previously allocated block of memory
+
+ Description
+ This is the HAL layer equivalent of the free() function.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalAlloc
+*/
+EXTERN void
+cy_as_hal_free(
+ /* Pointer to a memory block to free */
+ void *ptr
+ ) ;
+
+/* Summary
+ This function is a malloc equivalent that can be used from an
+ interrupt context.
+
+ Description
+ This function is a malloc equivalent that will be called from the
+ API in callbacks. This function is required to be able to provide
+ memory in interrupt context.
+
+ Notes
+ For platforms where it is not possible to allocate memory in interrupt
+ context, we provide a reference allocator that takes memory during
+ initialization and implements malloc/free using this memory.
+ See the <install>/api/hal/fpga/cyashalblkalloc.[ch] files for the
+ implementation, and the <install>/api/hal/fpga/cyashalfpga.c file
+ for an example of the use of this allocator.
+
+ Returns
+ A pointer to the allocated block of memory
+
+ See Also
+ * CyAsHalCBFree
+ * CyAsHalAlloc
+*/
+EXTERN void *
+cy_as_hal_c_b_alloc(
+ /* The size of the memory block to allocate */
+ uint32_t size
+ ) ;
+
+/* Summary
+ This function frees the memory allocated through the CyAsHalCBAlloc
+ call.
+
+ Description
+ This function frees memory allocated through the CyAsHalCBAlloc
+ call, and is also required to support calls from interrupt
+ context.
+
+ Returns
+ None
+
+ See Also
+ * CyAsHalCBAlloc
+ * CyAsHalFree
+*/
+EXTERN void
+cy_as_hal_c_b_free(
+ /* Pointer to the memory block to be freed */
+ void *ptr
+ ) ;
+
+/* Summary
+ This function sets a block of memory to a specific value
+
+ Description
+ This function is the HAL layer equivalent of the memset() function.
+
+ Returns
+ None
+*/
+EXTERN void
+cy_as_mem_set(
+ /* A pointer to a block of memory to set */
+ void *ptr,
+ /* The value to set the memory to */
+ uint8_t value,
+ /* The number of bytes to set */
+ uint32_t cnt
+ ) ;
+
+/* Summary
+ This function creates or initializes a sleep channel
+
+ Description
+ This function creates or initializes a sleep channel. The
+ sleep channel defined using the HAL data structure
+ CyAsHalSleepChannel.
+
+ Returns
+ CyTrue is the initialization was sucessful, and CyFalse otherwise
+
+ See Also
+ * CyAsHalSleepChannel
+ * CyAsHalDestroySleepChannel
+ * CyAsHalSleepOn
+ * CyAsHalWake
+*/
+EXTERN cy_bool
+cy_as_hal_create_sleep_channel(
+ /* Pointer to the sleep channel to create/initialize */
+ cy_as_hal_sleep_channel *chan
+ ) ;
+
+/* Summary
+ This function destroys an existing sleep channel
+
+ Description
+ This function destroys an existing sleep channel. The sleep channel
+ is of type CyAsHalSleepChannel.
+
+ Returns
+ CyTrue if the channel was destroyed, and CyFalse otherwise
+
+ See Also
+ * CyAsHalSleepChannel
+ * CyAsHalCreateSleepChannel
+ * CyAsHalSleepOn
+ * CyAsHalWake
+*/
+EXTERN cy_bool
+cy_as_hal_destroy_sleep_channel(
+ /* The sleep channel to destroy */
+ cy_as_hal_sleep_channel chan
+ ) ;
+
+/* Summary
+ This function causes the calling process or thread to sleep until
+ CyAsHalWake() is called
+
+ Description
+ This function causes the calling process or threadvto sleep.
+ When CyAsHalWake() is called on the same sleep channel, this
+ processes or thread is then wakened and allowed to run
+
+ Returns
+ CyTrue if the thread or process is asleep, and CyFalse otherwise
+
+ See Also
+ * CyAsHalSleepChannel
+ * CyAsHalWake
+*/
+EXTERN cy_bool
+cy_as_hal_sleep_on(
+ /* The sleep channel to sleep on */
+ cy_as_hal_sleep_channel chan,
+ /* The maximum time to sleep in milli-seconds */
+ uint32_t ms
+ ) ;
+
+/* Summary
+ This function casues the process or thread sleeping on the given
+ sleep channel to wake
+
+ Description
+ This function causes the process or thread sleeping on the given
+ sleep channel to wake. The channel
+
+ Returns
+ CyTrue if the thread or process is awake, and CyFalse otherwise
+
+ See Also
+ * CyAsHalSleepChannel
+ * CyAsHalSleepOn
+*/
+EXTERN cy_bool
+cy_as_hal_wake(
+ /* The sleep channel to wake */
+ cy_as_hal_sleep_channel chan
+ ) ;
+
+/* Summary
+ This function disables interrupts, insuring that short bursts
+ of code can be run without danger of interrupt handlers running.
+
+ Description
+ There are cases within the API when lists must be manipulated by
+ both the API and the associated interrupt handlers. In these
+ cases, interrupts must be disabled to insure the integrity of the
+ list during the modification. This function is used to disable
+ interrupts during the short intervals where these lists are being
+ changed.
+
+ The HAL must have the ability to nest calls to
+ CyAsHalDisableInterrupts and CyAsHalEnableInterrupts.
+
+ Returns
+ Any interrupt related state value which will be passed back into
+ the subsequent CyAsHalEnableInterrupts call.
+
+ See Also
+ * CyAsHalEnableInterrupts
+*/
+EXTERN uint32_t
+cy_as_hal_disable_interrupts() ;
+
+/* Summary
+ This function re-enables interrupts after a critical section of
+ code in the API has been completed.
+
+ Description
+ There are cases within the API when lists must be manipulated by
+ both the API and the associated interrupt handlers. In these
+ cases, interrupts must be disabled to insure the integrity of the
+ list during the modification. This function is used to enable
+ interrupts after the short intervals where these lists are being
+ changed.
+
+ See Also
+ * CyAsHalDisableInterrupts
+*/
+EXTERN void
+cy_as_hal_enable_interrupts(
+ /* Value returned by the previous CyAsHalDisableInterrupts call. */
+ uint32_t value
+ ) ;
+
+/* Summary
+ This function sleeps for 150 ns.
+
+ Description
+ This function sleeps for 150 ns before allowing the calling function
+ to continue. This function is used for a specific purpose and the
+ sleep required is at least 150 ns.
+*/
+EXTERN void
+cy_as_hal_sleep150(
+ ) ;
+
+/* Summary
+ This function sleeps for the given number of milliseconds
+
+ Description
+ This function sleeps for at least the given number of milliseonds
+*/
+EXTERN void
+cy_as_hal_sleep(
+ uint32_t ms
+ ) ;
+
+/* Summary
+ This function asserts when the condition evaluates to zero
+
+ Description
+ Within the API there are conditions which are checked to insure
+ the integrity of the code. These conditions are checked only
+ within a DEBUG build. This function is used to check the condition
+ and if the result evaluates to zero, it should be considered a
+ fatal error that should be reported to Cypress.
+*/
+EXTERN void
+cy_as_hal_assert(
+ /* The condition to evaluate */
+ cy_bool cond
+ ) ;
+
+/* Summary
+ This function prints a message from the API to a human readable device
+
+ Description
+ There are places within the West Bridge API where printing a message
+ is useful to the debug process. This function provides the mechanism
+ to print a message.
+
+ Returns
+ NONE
+*/
+EXTERN void
+cy_as_hal_print_message(
+ /* The message to print */
+ const char *fmt_p,
+ ... /* Variable arguments */
+ ) ;
+
+/* Summary
+ This function reports whether the HAL implementation uses
+ polling to service data coming from the West Bridge.
+
+ Description
+ This function reports whether the HAL implementation uses
+ polling to service data coming from the West Bridge.
+
+ Returns
+ CyTrue if the HAL polls the West Bridge Interrupt Status registers
+ to complete operations, CyFalse if the HAL is interrupt driven.
+ */
+EXTERN cy_bool
+cy_as_hal_is_polling(
+ void) ;
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasintr.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasintr.h
new file mode 100644
index 000000000000..e77aa6ae82bb
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasintr.h
@@ -0,0 +1,104 @@
+/* Cypress West Bridge API header file (cyasintr.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASINTR_H_
+#define _INCLUDED_CYASINTR_H_
+
+#include "cyasdevice.h"
+
+#include "cyas_cplus_start.h"
+
+/* Summary
+ Initialize the interrupt manager module
+
+ Description
+ This function is called to initialize the interrupt module.
+ This module enables interrupts as well as servies West Bridge
+ related interrupts by determining the source of the interrupt
+ and calling the appropriate handler function.
+
+ Notes
+ If the dmaintr parameter is TRUE, the initialization code
+ initializes the interrupt mask to have the DMA related interrupt
+ enabled via the general purpose interrupt. However, the interrupt
+ service function assumes that the DMA interrupt is handled by the
+ HAL layer before the interrupt module handler function is called.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the interrupt module was initialized
+ * correctly
+ * CY_AS_ERROR_ALREADY_RUNNING - the interrupt module was already
+ * started
+
+ See Also
+ * CyAsIntrStop
+ * CyAsServiceInterrupt
+*/
+cy_as_return_status_t
+cy_as_intr_start(
+ /* Device being initialized */
+ cy_as_device *dev_p,
+ /* If true, enable the DMA interrupt through the INT signal */
+ cy_bool dmaintr
+ ) ;
+
+/* Summary
+ Stop the interrupt manager module
+
+ Description
+ This function stops the interrupt module and masks all interrupts
+ from the West Bridge device.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the interrupt module was stopped
+ * sucessfully
+ * CY_AS_ERROR_NOT_RUNNING - the interrupt module was not
+ * running
+
+ See Also
+ * CyAsIntrStart
+ * CyAsServiceInterrupt
+*/
+cy_as_return_status_t
+cy_as_intr_stop(
+ /* Device bein stopped */
+ cy_as_device *dev_p
+ ) ;
+
+
+/* Summary
+ The interrupt service routine for West Bridge
+
+ Description
+ When an interrupt is detected, this function is called to
+ service the West Bridge interrupt. It is safe and efficient
+ for this function to be called when no West Bridge interrupt
+ has occurred. This function will determine it is not an West
+ Bridge interrupt quickly and return.
+*/
+void cy_as_intr_service_interrupt(
+ /* The USER supplied tag for this device */
+ cy_as_hal_device_tag tag
+ ) ;
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASINTR_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslep2pep.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslep2pep.h
new file mode 100644
index 000000000000..40497655b7fb
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslep2pep.h
@@ -0,0 +1,36 @@
+/* Cypress West Bridge API header file (cyaslep2pep.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASLEP2PEP_H_
+#define _INCLUDED_CYASLEP2PEP_H_
+
+#include "cyasdevice.h"
+
+extern cy_as_return_status_t
+cy_as_usb_map_logical2_physical(cy_as_device *dev_p) ;
+
+extern cy_as_return_status_t
+cy_as_usb_setup_dma(cy_as_device *dev_p) ;
+
+extern cy_as_return_status_t
+cy_as_usb_set_dma_sizes(cy_as_device *dev_p) ;
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h
new file mode 100644
index 000000000000..6d40aa6eed6c
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyaslowlevel.h
@@ -0,0 +1,366 @@
+/* Cypress West Bridge API header file (cyaslowlevel.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASLOWLEVEL_H_
+#define _INCLUDED_CYASLOWLEVEL_H_
+
+/*@@Low Level Communications
+
+ Summary
+ The low level communications module is responsible for
+ communications between the West Bridge device and the P
+ port processor. Communications is organized as a series
+ of requests and subsequent responses. For each request
+ there is a one and only one response. Requests may go
+ from the West Bridge device to the P port processor, or
+ from the P Port processor to the West Bridge device.
+
+ Description
+ Requests are issued across what is called a context. A
+ context is a single channel of communications from one
+ processor to another processor. There can be only a single
+ request outstanding on a context at a given time. Contexts
+ are used to identify subsystems that can only process a
+ single request at a time, but are independent of other
+ contexts in the system. For instance, there is a context
+ for communicating storage commands from the P port processor
+ to the West Bridge device. There is also a context for
+ communicating USB commands from the P port processor to the
+ West Bridge device.
+
+ Requests and responses are identical with the exception of
+ the type bit in the request/response header. If the type
+ bit is one, the packet is a request. If this bit is zero,
+ the packet is a response. Also encoded within the header of
+ the request/response is the code. The code is a command
+ code for a request, or a response code for a response. For
+ a request, the code is a function of the context. The code
+ 0 has one meaning for the storage context and a different
+ meaning for the USB context. The code is treated differently
+ in the response. If the code in the response is less than 16,
+ then the meaning of the response is global across all
+ contexts. If the response is greater than or equal to 16,
+ then the response is specific to the associated context.
+
+ Requests and responses are transferred between processors
+ through the mailbox registers. It may take one or more cycles
+ to transmit a complete request or response. The context is
+ encoded into each cycle of the transfer to insure the
+ receiving processor can route the data to the appropriate
+ context for processing. In this way, the traffic from multiple
+ contexts can be multiplexed into a single data stream through
+ the mailbox registers by the sending processor, and
+ demultiplexed from the mailbox registers by the receiving
+ processor.
+
+ * Firmware Assumptions *
+ The firmware assumes that mailbox contents will be consumed
+ immediately. Therefore for multi-cycle packets, the data is
+ sent in a tight polling loop from the firmware. This implies
+ that the data must be read from the mailbox register on the P
+ port side and processed immediately or performance of the
+ firmware will suffer. In order to insure this is the case,
+ the data from the mailboxes is read and stored immediately
+ in a per context buffer. This occurs until the entire packet
+ is received at which time the request packet is processed.
+ Since the protocol is designed to allow for only one
+ outstanding packet at a time, the firmware can never be in a
+ position of waiting on the mailbox registers while the P port
+ is processing a request. Only after the response to the
+ previous request is sent will another request be sent.
+*/
+
+#include "cyashal.h"
+#include "cyasdevice.h"
+
+#include "cyas_cplus_start.h"
+
+/*
+ * Constants
+ */
+#define CY_AS_REQUEST_RESPONSE_CODE_MASK (0x00ff)
+#define CY_AS_REQUEST_RESPONSE_CONTEXT_MASK (0x0F00)
+#define CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT (8)
+#define CY_AS_REQUEST_RESPONSE_TYPE_MASK (0x4000)
+#define CY_AS_REQUEST_RESPONSE_LAST_MASK (0x8000)
+#define CY_AS_REQUEST_RESPONSE_CLEAR_STR_FLAG (0x1000)
+
+/*
+ * These macros extract the data from a 16 bit value
+ */
+#define cy_as_mbox_get_code(c) \
+ ((uint8_t)((c) & CY_AS_REQUEST_RESPONSE_CODE_MASK))
+#define cy_as_mbox_get_context(c) \
+ ((uint8_t)(((c) & CY_AS_REQUEST_RESPONSE_CONTEXT_MASK) \
+ >> CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT))
+#define cy_as_mbox_is_last(c) \
+ ((c) & CY_AS_REQUEST_RESPONSE_LAST_MASK)
+#define cy_as_mbox_is_request(c) \
+ (((c) & CY_AS_REQUEST_RESPONSE_TYPE_MASK) != 0)
+#define cy_as_mbox_is_response(c) \
+ (((c) & CY_AS_REQUEST_RESPONSE_TYPE_MASK) == 0)
+
+/*
+ * These macros (not yet written) pack data into or extract data
+ * from the m_box0 field of the request or response
+ */
+#define cy_as_ll_request_response__set_code(req, code) \
+ ((req)->box0 = \
+ ((req)->box0 & ~CY_AS_REQUEST_RESPONSE_CODE_MASK) | \
+ (code & CY_AS_REQUEST_RESPONSE_CODE_MASK))
+
+#define cy_as_ll_request_response__get_code(req) \
+ cy_as_mbox_get_code((req)->box0)
+
+#define cy_as_ll_request_response__set_context(req, context) \
+ ((req)->box0 |= ((context) << \
+ CY_AS_REQUEST_RESPONSE_CONTEXT_SHIFT))
+
+#define cy_as_ll_request_response__set_clear_storage_flag(req) \
+ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_CLEAR_STR_FLAG)
+
+#define cy_as_ll_request_response__get_context(req) \
+ cy_as_mbox_get_context((req)->box0)
+
+#define cy_as_ll_request_response__is_last(req) \
+ cy_as_mbox_is_last((req)->box0)
+
+#define CY_an_ll_request_response___set_last(req) \
+ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_LAST_MASK)
+
+#define cy_as_ll_request_response__is_request(req) \
+ cy_as_mbox_is_request((req)->box0)
+
+#define cy_as_ll_request_response__set_request(req) \
+ ((req)->box0 |= CY_AS_REQUEST_RESPONSE_TYPE_MASK)
+
+#define cy_as_ll_request_response__set_response(req) \
+ ((req)->box0 &= ~CY_AS_REQUEST_RESPONSE_TYPE_MASK)
+
+#define cy_as_ll_request_response__is_response(req) \
+ cy_as_mbox_is_response((req)->box0)
+
+#define cy_as_ll_request_response__get_word(req, offset) \
+ ((req)->data[(offset)])
+
+#define cy_as_ll_request_response__set_word(req, offset, \
+ value) ((req)->data[(offset)] = value)
+
+typedef enum cy_as_remove_request_result_t {
+ cy_as_remove_request_sucessful,
+ cy_as_remove_request_in_transit,
+ cy_as_remove_request_not_found
+} cy_as_remove_request_result_t ;
+
+/* Summary
+ Start the low level communications module
+
+ Description
+*/
+cy_as_return_status_t
+cy_as_ll_start(
+ cy_as_device *dev_p
+ ) ;
+
+cy_as_return_status_t
+cy_as_ll_stop(
+ cy_as_device *dev_p
+ ) ;
+
+
+cy_as_ll_request_response *
+cy_as_ll_create_request(
+ cy_as_device *dev_p,
+ uint16_t code,
+ uint8_t context,
+ /* Length of the request in 16 bit words */
+ uint16_t length
+ ) ;
+
+void
+cy_as_ll_init_request(
+ cy_as_ll_request_response *req_p,
+ uint16_t code,
+ uint16_t context,
+ uint16_t length) ;
+
+void
+cy_as_ll_init_response(
+ cy_as_ll_request_response *req_p,
+ uint16_t length) ;
+
+void
+cy_as_ll_destroy_request(
+ cy_as_device *dev_p,
+ cy_as_ll_request_response *) ;
+
+cy_as_ll_request_response *
+cy_as_ll_create_response(
+ cy_as_device *dev_p,
+ /* Length of the request in 16 bit words */
+ uint16_t length
+ ) ;
+
+cy_as_remove_request_result_t
+cy_as_ll_remove_request(
+ cy_as_device *dev_p,
+ cy_as_context *ctxt_p,
+ cy_as_ll_request_response *req_p,
+ cy_bool force
+ ) ;
+void
+cy_as_ll_remove_all_requests(cy_as_device *dev_p,
+ cy_as_context *ctxt_p) ;
+
+void
+cy_as_ll_destroy_response(
+ cy_as_device *dev_p,
+ cy_as_ll_request_response *) ;
+
+cy_as_return_status_t
+cy_as_ll_send_request(
+ /* The West Bridge device */
+ cy_as_device *dev_p,
+ /* The request to send */
+ cy_as_ll_request_response *req,
+ /* Storage for a reply, must be sure it is of sufficient size */
+ cy_as_ll_request_response *resp,
+ /* If true, this is a sync request */
+ cy_bool sync,
+ /* Callback to call when reply is received */
+ cy_as_response_callback cb
+) ;
+
+cy_as_return_status_t
+cy_as_ll_send_request_wait_reply(
+ /* The West Bridge device */
+ cy_as_device *dev_p,
+ /* The request to send */
+ cy_as_ll_request_response *req,
+ /* Storage for a reply, must be sure it is of sufficient size */
+ cy_as_ll_request_response *resp
+) ;
+
+/* Summary
+ This function registers a callback function to be called when a
+ request arrives on a given context.
+
+ Description
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+*/
+extern cy_as_return_status_t
+cy_as_ll_register_request_callback(
+ cy_as_device *dev_p,
+ uint8_t context,
+ cy_as_response_callback cb
+ ) ;
+
+/* Summary
+ This function packs a set of bytes given by the data_p pointer
+ into a request, reply structure.
+*/
+extern void
+cy_as_ll_request_response__pack(
+ /* The destintation request or response */
+ cy_as_ll_request_response *req,
+ /* The offset of where to pack the data */
+ uint32_t offset,
+ /* The length of the data to pack in bytes */
+ uint32_t length,
+ /* The data to pack */
+ void *data_p
+ ) ;
+
+/* Summary
+ This function unpacks a set of bytes from a request/reply
+ structure into a segment of memory given by the data_p pointer.
+*/
+extern void
+cy_as_ll_request_response__unpack(
+ /* The source of the data to unpack */
+ cy_as_ll_request_response *req,
+ /* The offset of the data to unpack */
+ uint32_t offset,
+ /* The length of the data to unpack in bytes */
+ uint32_t length,
+ /* The destination of the unpack operation */
+ void *data_p
+ ) ;
+
+/* Summary
+ This function sends a status response back to the West Bridge
+ device in response to a previously send request
+*/
+extern cy_as_return_status_t
+cy_as_ll_send_status_response(
+ /* The West Bridge device */
+ cy_as_device *dev_p,
+ /* The context to send the response on */
+ uint8_t context,
+ /* The success/failure code to send */
+ uint16_t code,
+ /* Flag to clear wait on storage context */
+ uint8_t clear_storage) ;
+
+/* Summary
+ This function sends a response back to the West Bridge device.
+
+ Description
+ This function sends a response back to the West Bridge device.
+ The response is sent on the context given by the 'context'
+ variable. The code for the response is given by the 'code'
+ argument. The data for the response is given by the data and
+ length arguments.
+*/
+extern cy_as_return_status_t
+cy_as_ll_send_data_response(
+ /* The West Bridge device */
+ cy_as_device *dev_p,
+ /* The context to send the response on */
+ uint8_t context,
+ /* The response code to use */
+ uint16_t code,
+ /* The length of the data for the response */
+ uint16_t length,
+ /* The data for the response */
+ void *data
+) ;
+
+/* Summary
+ This function removes any requests of the given type
+ from the given context.
+
+ Description
+ This function removes requests of a given type from the
+ context given via the context number.
+*/
+extern cy_as_return_status_t
+cy_as_ll_remove_ep_data_requests(
+ /* The West Bridge device */
+ cy_as_device *dev_p,
+ cy_as_end_point_number_t ep
+ ) ;
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASLOWLEVEL_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmedia.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmedia.h
new file mode 100644
index 000000000000..e444079cf87c
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmedia.h
@@ -0,0 +1,54 @@
+/* Cypress West Bridge API header file (cyasmedia.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASMEDIA_H_
+#define _INCLUDED_CYASMEDIA_H_
+
+#include "cyas_cplus_start.h"
+
+
+/* Summary
+ Specifies a specific type of media supported by West Bridge
+
+ Description
+ The West Bridge device supports five specific types of media
+ as storage/IO devices attached to it's S-Port. This type is
+ used to indicate the type of media being referenced in any
+ API call.
+*/
+typedef enum cy_as_media_type {
+ /* Flash NAND memory (may be SLC or MLC) */
+ cy_as_media_nand = 0x00,
+ /* An SD flash memory device */
+ cy_as_media_sd_flash = 0x01,
+ /* An MMC flash memory device */
+ cy_as_media_mmc_flash = 0x02,
+ /* A CE-ATA disk drive */
+ cy_as_media_ce_ata = 0x03,
+ /* SDIO device. */
+ cy_as_media_sdio = 0x04,
+ cy_as_media_max_media_value = 0x05
+
+} cy_as_media_type ;
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASMEDIA_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h
new file mode 100644
index 000000000000..33655bd125cc
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h
@@ -0,0 +1,1549 @@
+/* Cypress West Bridge API header file (cyasmisc.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASMISC_H_
+#define _INCLUDED_CYASMISC_H_
+
+#include "cyashal.h"
+#include "cyastypes.h"
+#include "cyasmedia.h"
+
+#include "cyas_cplus_start.h"
+
+#define CY_AS_LEAVE_STANDBY_DELAY_CLOCK (1)
+#define CY_AS_RESET_DELAY_CLOCK (1)
+
+#define CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL (5)
+#define CY_AS_RESET_DELAY_CRYSTAL (5)
+
+/* The maximum number of buses supported */
+#define CY_AS_MAX_BUSES (2)
+
+/* The maximum number of storage devices supported per bus */
+#define CY_AS_MAX_STORAGE_DEVICES (1)
+
+#define CY_AS_FUNCTCBTYPE_DATA_MASK (0x60000000U)
+#define CY_AS_FUNCTCBTYPE_TYPE_MASK (0x1FFFFFFFU)
+
+#define cy_as_funct_c_b_type_get_type(t) \
+ ((cy_as_funct_c_b_type)((t) & CY_AS_FUNCTCBTYPE_TYPE_MASK))
+#define cy_as_funct_c_b_type_contains_data(t) \
+ (((cy_as_funct_c_b_type)((t) & \
+ CY_AS_FUNCTCBTYPE_DATA_MASK)) == CY_FUNCT_CB_DATA)
+
+/**************************************
+ * West Bridge Types
+ **************************************/
+
+/* Summary
+ Specifies a handle to an West Bridge device
+
+ Description
+ This type represents an opaque handle to an West Bridge device.
+ This handle is created via the CyAsMiscCreateDevice() function
+ and is used in all subsequent calls that communicate to the West
+ Bridge device.
+
+ See Also
+ * CyAsMiscCreateDevice
+ * CyAsMiscDestroyDevice
+*/
+typedef void *cy_as_device_handle ;
+
+/* Summary
+ This data type gives the mode for the DACK# signal
+*/
+typedef enum cy_as_device_dack_mode {
+ cy_as_device_dack_ack, /* Operate in the ACK mode */
+ cy_as_device_dack_eob /* Operate in the EOB mode */
+} cy_as_device_dack_mode ;
+
+/* Summary
+ This data structure gives the options for all hardware features.
+
+ Description
+ This structure contains the information required to initialize the
+ West Bridge hardware. Any features of the device that can be
+ configured by the caller are specified here.
+
+ See Also
+ * CyAsMiscConfigure
+*/
+typedef struct cy_as_device_config {
+ /* If TRUE, the P port is running in SRAM mode. */
+ cy_bool srammode ;
+ /* If TRUE, the P port is synchronous, otherwise async */
+ cy_bool sync ;
+ /* If TRUE, DMA req will be delivered via the interrupt signal */
+ cy_bool dmaintr ;
+ /* Mode for the DACK# signal */
+ cy_as_device_dack_mode dackmode ;
+ /* If TRUE, the DRQ line is active high, otherwise active low */
+ cy_bool drqpol ;
+ /* If TRUE, the DACK line is active high, otherwise active low */
+ cy_bool dackpol ;
+ /* If TRUE, the clock is connected to a crystal, otherwise it is
+ connected to a clock */
+ cy_bool crystal ;
+} cy_as_device_config ;
+
+
+/* Summary
+ Specifies a resource that can be owned by either the West Bridge
+ device or by the processor.
+
+ Description
+ This enumerated type identifies a resource that can be owned
+ either by the West Bridge device, or by the processor attached to
+ the P port of the West Bridge device.
+
+ See Also
+ * CyAsMiscAcquireResource
+ * CyAsMiscReleaseResource
+*/
+typedef enum cy_as_resource_type {
+ cy_as_bus_u_s_b = 0, /* The USB D+ and D- pins */
+ cy_as_bus_1 = 1, /* The SDIO bus */
+ cy_as_bus_0 = 2 /* The NAND bus (not implemented) */
+} cy_as_resource_type;
+
+/* Summary
+ Specifies the reset type for a software reset operation.
+
+ Description
+ When the West Bridge device is reset, there are two types of
+ reset that arE possible. This type indicates the type of reset
+ requested.
+
+ Notes
+ Both of these reset types are software based resets; and are
+ distinct from a chip level HARD reset that is applied through
+ the reset pin on the West Bridge.
+
+ The CyAsResetSoft type resets only the on-chip micro-controller
+ in the West Bridge. In this case, the previously loaded firmware
+ will continue running. However, the Storage and USB stack
+ operations will need to be restarted, as any state relating to
+ these would have been lost.
+
+ The CyAsResetHard type resets the entire West Bridge chip, and will
+ need a fresh configuration and firmware download.
+
+ See Also
+ * <LINK CyAsMiscReset>
+ */
+
+typedef enum cy_as_reset_type {
+ /* Just resets the West Bridge micro-controller */
+ cy_as_reset_soft,
+ /* Resets entire device, firmware must be reloaded and
+ the west bridge device must be re-initialized */
+ cy_as_reset_hard
+} cy_as_reset_type;
+
+
+
+/* Summary
+ This type specifies the polarity of the SD power pin.
+
+ Description
+ Sets the SD power pin ( port C, bit 6) to active low or
+ active high.
+
+*/
+
+typedef enum cy_as_misc_signal_polarity {
+ cy_as_misc_active_high,
+ cy_as_misc_active_low
+
+} cy_as_misc_signal_polarity ;
+
+
+
+/* Summary
+ This type specifies the type of the data returned by a Function
+ Callback.
+
+ Description
+ CY_FUNCT_CB_NODATA - This callback does not return any additional
+ information in the data field.
+ CY_FUNCT_CB_DATA - The data field is used, and the CyAsFunctCBType
+ will also contain the type of this data.
+
+ See Also
+ CyAsFunctionCallback
+*/
+typedef enum cy_as_funct_c_b_type {
+ CY_FUNCT_CB_INVALID = 0x0U,
+ /* Data from a CyAsMiscGetFirmwareVersion call. */
+ CY_FUNCT_CB_MISC_GETFIRMWAREVERSION,
+ /* Data from a CyAsMiscHeartBeatControl call. */
+ CY_FUNCT_CB_MISC_HEARTBEATCONTROL,
+ /* Data from a CyAsMiscAcquireResource call. */
+ CY_FUNCT_CB_MISC_ACQUIRERESOURCE,
+ /* Data from a CyAsMiscReadMCURegister call. */
+ CY_FUNCT_CB_MISC_READMCUREGISTER,
+ /* Data from a CyAsMiscWriteMCURegister call. */
+ CY_FUNCT_CB_MISC_WRITEMCUREGISTER,
+ /* Data from a CyAsMiscSetTraceLevel call. */
+ CY_FUNCT_CB_MISC_SETTRACELEVEL,
+ /* Data from a CyAsMiscStorageChanged call. */
+ CY_FUNCT_CB_MISC_STORAGECHANGED,
+ /* Data from a CyAsMiscGetGpioValue call. */
+ CY_FUNCT_CB_MISC_GETGPIOVALUE,
+ /* Data from a CyAsMiscSetGpioValue call. */
+ CY_FUNCT_CB_MISC_SETGPIOVALUE,
+ /* Data from a CyAsMiscDownloadFirmware call. */
+ CY_FUNCT_CB_MISC_DOWNLOADFIRMWARE,
+ /* Data from a CyAsMiscEnterStandby call. */
+ CY_FUNCT_CB_MISC_ENTERSTANDBY,
+ /* Data from a CyAsMiscEnterSuspend call. */
+ CY_FUNCT_CB_MISC_ENTERSUSPEND,
+ /* Data from a CyAsMiscLeaveSuspend call. */
+ CY_FUNCT_CB_MISC_LEAVESUSPEND,
+ /* Data from a CyAsMiscReset call. */
+ CY_FUNCT_CB_MISC_RESET,
+ /* Data from a CyAsMiscSetLowSpeedSDFreq or
+ * CyAsMiscSetHighSpeedSDFreq call. */
+ CY_FUNCT_CB_MISC_SETSDFREQ,
+ /* Data from a CyAsMiscSwitchPnandMode call */
+ CY_FUNCT_CB_MISC_RESERVELNABOOTAREA,
+ /* Data from a CyAsMiscSetSDPowerPolarity call */
+ CY_FUNCT_CB_MISC_SETSDPOLARITY,
+
+ /* Data from a CyAsStorageStart call. */
+ CY_FUNCT_CB_STOR_START,
+ /* Data from a CyAsStorageStop call. */
+ CY_FUNCT_CB_STOR_STOP,
+ /* Data from a CyAsStorageClaim call. */
+ CY_FUNCT_CB_STOR_CLAIM,
+ /* Data from a CyAsStorageRelease call. */
+ CY_FUNCT_CB_STOR_RELEASE,
+ /* Data from a CyAsStorageQueryMedia call. */
+ CY_FUNCT_CB_STOR_QUERYMEDIA,
+ /* Data from a CyAsStorageQueryBus call. */
+ CY_FUNCT_CB_STOR_QUERYBUS,
+ /* Data from a CyAsStorageQueryDevice call. */
+ CY_FUNCT_CB_STOR_QUERYDEVICE,
+ /* Data from a CyAsStorageQueryUnit call. */
+ CY_FUNCT_CB_STOR_QUERYUNIT,
+ /* Data from a CyAsStorageDeviceControl call. */
+ CY_FUNCT_CB_STOR_DEVICECONTROL,
+ /* Data from a CyAsStorageSDRegisterRead call. */
+ CY_FUNCT_CB_STOR_SDREGISTERREAD,
+ /* Data from a CyAsStorageCreatePartition call. */
+ CY_FUNCT_CB_STOR_PARTITION,
+ /* Data from a CyAsStorageGetTransferAmount call. */
+ CY_FUNCT_CB_STOR_GETTRANSFERAMOUNT,
+ /* Data from a CyAsStorageErase call. */
+ CY_FUNCT_CB_STOR_ERASE,
+ /* Data from a CyAsStorageCancelAsync call. */
+ CY_FUNCT_CB_ABORT_P2S_XFER,
+ /* Data from a CyAsUsbStart call. */
+ CY_FUNCT_CB_USB_START,
+ /* Data from a CyAsUsbStop call. */
+ CY_FUNCT_CB_USB_STOP,
+ /* Data from a CyAsUsbConnect call. */
+ CY_FUNCT_CB_USB_CONNECT,
+ /* Data from a CyAsUsbDisconnect call. */
+ CY_FUNCT_CB_USB_DISCONNECT,
+ /* Data from a CyAsUsbSetEnumConfig call. */
+ CY_FUNCT_CB_USB_SETENUMCONFIG,
+ /* Data from a CyAsUsbGetEnumConfig call. */
+ CY_FUNCT_CB_USB_GETENUMCONFIG,
+ /* Data from a CyAsUsbSetDescriptor call. */
+ CY_FUNCT_CB_USB_SETDESCRIPTOR,
+ /* Data from a CyAsUsbGetDescriptor call. */
+ CY_FUNCT_CB_USB_GETDESCRIPTOR,
+ /* Data from a CyAsUsbCommitConfig call. */
+ CY_FUNCT_CB_USB_COMMITCONFIG,
+ /* Data from a CyAsUsbGetNak call. */
+ CY_FUNCT_CB_USB_GETNAK,
+ /* Data from a CyAsUsbGetStall call. */
+ CY_FUNCT_CB_USB_GETSTALL,
+ /* Data from a CyAsUsbSignalRemoteWakeup call. */
+ CY_FUNCT_CB_USB_SIGNALREMOTEWAKEUP,
+ /* Data from a CyAnUsbClearDescriptors call. */
+ CY_FUNCT_CB_USB_CLEARDESCRIPTORS,
+ /* Data from a CyAnUsbSetMSReportThreshold call. */
+ CY_FUNCT_CB_USB_SET_MSREPORT_THRESHOLD,
+ /* Data from a CyAsMTPStart call. */
+ CY_FUNCT_CB_MTP_START,
+ /* Data from a CyAsMTPStop call. */
+ CY_FUNCT_CB_MTP_STOP,
+ /* Data from a CyAsMTPInitSendObject call. */
+ CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,
+ /* Data from a CyAsMTPCancelSendObject call. */
+ CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT,
+ /* Data from a CyAsMTPInitGetObject call. */
+ CY_FUNCT_CB_MTP_INIT_GET_OBJECT,
+ /* Data from a CyAsMTPCancelGetObject call. */
+ CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT,
+ /* Data from a CyAsMTPSendBlockTable call. */
+ CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE,
+ /* Data from a CyAsMTPStopStorageOnly call. */
+ CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY,
+ CY_FUNCT_CB_NODATA = 0x40000000U,
+ CY_FUNCT_CB_DATA = 0x20000000U
+} cy_as_funct_c_b_type ;
+
+/* Summary
+ This type specifies the general West Bridge function callback.
+
+ Description
+ This callback is supplied as an argument to all asynchronous
+ functions in the API. It iS called after the asynchronous function
+ has completed.
+
+ See Also
+ CyAsFunctCBType
+*/
+typedef void (*cy_as_function_callback)(
+ cy_as_device_handle handle,
+ cy_as_return_status_t status,
+ uint32_t client,
+ cy_as_funct_c_b_type type,
+ void *data) ;
+
+/* Summary
+ This type specifies the general West Bridge event that has
+ occurred.
+
+ Description
+ This type is used in the West Bridge misc callback function to
+ indicate the type of callback.
+
+ See Also
+*/
+typedef enum cy_as_misc_event_type {
+ /* This event is sent when West Bridge has finished
+ initialization and is ready to respond to API calls. */
+ cy_as_event_misc_initialized = 0,
+
+ /* This event is sent when West Bridge has left the
+ standby state and is ready to respond to commands again. */
+ cy_as_event_misc_awake,
+
+ /* This event is sent periodically from the firmware
+ to the processor. */
+ cy_as_event_misc_heart_beat,
+
+ /* This event is sent when the West Bridge has left the
+ suspend mode and is ready to respond to commands
+ again. */
+ cy_as_event_misc_wakeup,
+
+ /* This event is sent when the firmware image downloaded
+ cannot run on the active west bridge device. */
+ cy_as_event_misc_device_mismatch
+} cy_as_misc_event_type ;
+
+/* Summary
+ This type is the type of a callback function that is called when a
+ West Bridge misc event occurs.
+
+ Description
+ At times West Bridge needs to inform the P port processor of events
+ that have occurred. These events are asynchronous to the thread of
+ control on the P port processor and as such are generally delivered
+ via a callback function that is called as part of an interrupt
+ handler. This type defines the type of function that must be provided
+ as a callback function for West Bridge misc events.
+
+ See Also
+ * CyAsMiscEventType
+*/
+typedef void (*cy_as_misc_event_callback)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The event type being reported */
+ cy_as_misc_event_type ev,
+ /* The data assocaited with the event being reported */
+ void *evdata
+) ;
+
+#ifndef __doxygen__
+/* Summary
+ This enum provides info of various firmware trace levels.
+
+ Description
+
+ See Also
+ * CyAsMiscSetTraceLevel
+*/
+enum {
+ CYAS_FW_TRACE_LOG_NONE = 0, /* Log nothing. */
+ CYAS_FW_TRACE_LOG_STATE, /* Log state information. */
+ CYAS_FW_TRACE_LOG_CALLS, /* Log function calls. */
+ CYAS_FW_TRACE_LOG_STACK_TRACE, /* Log function calls with args. */
+ CYAS_FW_TRACE_MAX_LEVEL /* Max trace level sentinel. */
+};
+#endif
+
+/* Summary
+ This enum lists the controllable GPIOs of the West Bridge device.
+
+ Description
+ The West Bridge device has GPIOs that can be used for user defined functions.
+ This enumeration lists the GPIOs that are available on the device.
+
+ Notes
+ All of the GPIOs except UVALID can only be accessed when using West Bridge
+ firmware images that support only SD/MMC/MMC+ storage devices. This
+ functionality is not supported in firmware images that support NAND
+ storage.
+
+ See Also
+ * CyAsMiscGetGpioValue
+ * CyAsMiscSetGpioValue
+ */
+typedef enum {
+ cy_as_misc_gpio_0 = 0, /* GPIO[0] pin */
+ cy_as_misc_gpio_1, /* GPIO[1] pin */
+ cy_as_misc_gpio__nand_CE, /* NAND_CE pin, output only */
+ cy_as_misc_gpio__nand_CE2, /* NAND_CE2 pin, output only */
+ cy_as_misc_gpio__nand_WP, /* NAND_WP pin, output only */
+ cy_as_misc_gpio__nand_CLE, /* NAND_CLE pin, output only */
+ cy_as_misc_gpio__nand_ALE, /* NAND_ALE pin, output only */
+ /* SD_POW pin, output only, do not drive low while storage is active */
+ cy_as_misc_gpio_SD_POW,
+ cy_as_misc_gpio_U_valid /* UVALID pin */
+} cy_as_misc_gpio;
+
+/* Summary
+ This enum lists the set of clock frequencies that are supported for
+ working with low speed SD media.
+
+ Description
+ West Bridge firmware uses a clock frequency less than the maximum
+ possible rate for low speed SD media. This can be changed to a
+ setting equal to the maximum frequency as desired by the user. This
+ enumeration lists the different frequency settings that are
+ supported.
+
+ See Also
+ * CyAsMiscSetLowSpeedSDFreq
+ */
+typedef enum cy_as_low_speed_sd_freq {
+ /* Approx. 21.82 MHz, default value */
+ CY_AS_SD_DEFAULT_FREQ = 0,
+ /* 24 MHz */
+ CY_AS_SD_RATED_FREQ
+} cy_as_low_speed_sd_freq ;
+
+/* Summary
+ This enum lists the set of clock frequencies that are supported
+ for working with high speed SD media.
+
+ Description
+ West Bridge firmware uses a 48 MHz clock by default to interface
+ with high speed SD/MMC media. This can be changed to 24 MHz if
+ so desired by the user. This enum lists the different frequencies
+ that are supported.
+
+ See Also
+ * CyAsMiscSetHighSpeedSDFreq
+ */
+typedef enum cy_as_high_speed_sd_freq {
+ CY_AS_HS_SD_FREQ_48, /* 48 MHz, default value */
+ CY_AS_HS_SD_FREQ_24 /* 24 MHz */
+} cy_as_high_speed_sd_freq ;
+
+/* Summary
+ Struct encapsulating all information returned by the
+ CyAsMiscGetFirmwareVersion call.
+
+ Description
+ This struct encapsulates all return values from the asynchronous
+ CyAsMiscGetFirmwareVersion call, so that a single data argument
+ can be passed to the user provided callback function.
+
+ See Also
+ * CyAsMiscGetFirmwareVersion
+ */
+typedef struct cy_as_get_firmware_version_data {
+ /* Return value for major version number for the firmware */
+ uint16_t major;
+ /* Return value for minor version number for the firmware */
+ uint16_t minor;
+ /* Return value for build version number for the firmware */
+ uint16_t build;
+ /* Return value for media types supported in the current firmware */
+ uint8_t media_type;
+ /* Return value to indicate the release or debug mode of firmware */
+ cy_bool is_debug_mode;
+} cy_as_get_firmware_version_data ;
+
+
+/*****************************
+ * West Bridge Functions
+ *****************************/
+
+/* Summary
+ This function creates a new West Bridge device and returns a
+ handle to the device.
+
+ Description
+ This function initializes the API object that represents the West
+ Bridge device and returns a handle to this device. This handle is
+ required for all West Bridge related functions to identify the
+ specific West Bridge device.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_OUT_OF_MEMORY
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_create_device(
+ /* Return value for handle to created device */
+ cy_as_device_handle *handle_p,
+ /* The HAL specific tag for this device */
+ cy_as_hal_device_tag tag
+ ) ;
+
+/* Summary
+ This functions destroys a previously created West Bridge device.
+
+ Description
+ When an West Bridge device is created, an opaque handle is returned
+ that represents the device. This function destroys that handle and
+ frees all resources associated with the handle.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_STILL_RUNNING - The USB or STORAGE stacks are still
+ * running, they must be stopped before the device can be destroyed
+ * CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED - the HAL layer failed to
+ * destroy a sleep channel
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_destroy_device(
+ /* Handle to the device to destroy */
+ cy_as_device_handle handle
+ ) ;
+
+/* Summary
+ This function initializes the hardware for basic communication with
+ West Bridge.
+
+ Description
+ This function intializes the hardware to establish basic
+ communication with the West Bridge device. This is always the first
+ function called to initialize communication with the West Bridge
+ device.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the basic initialization was completed
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_IN_STANDBY
+ * CY_AS_ERROR_ALREADY_RUNNING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_NO_ANTIOCH - cannot find the West Bridge device
+ * CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED -
+ * the HAL layer falied to create a sleep channel
+
+ See Also
+ * CyAsDeviceConfig
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_configure_device(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Configuration information */
+ cy_as_device_config *config_p
+ ) ;
+
+/* Summary
+ This function returns non-zero if West Bridge is in standby and
+ zero otherwise.
+
+ Description
+ West Bridge supports a standby mode. This function is used to
+ query West Bridge to determine if West Bridge is in a standby
+ mode.
+
+ * Valid In Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_in_standby(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Return value for standby state */
+ cy_bool *standby
+ ) ;
+
+/* Summary
+ This function downloads the firmware to West Bridge device.
+
+ Description
+ This function downloads firmware from a given location and with a
+ given size to the West Bridge device. After the firmware is
+ downloaded the West Bridge device is moved out of configuration
+ mode causing the firmware to be executed. It is an error to call
+ this function when the device is not in configuration mode. The
+ device is in configuration mode on power up and may be placed in
+ configuration mode after power up with a hard reset.
+
+ Notes
+ The firmware must be on a word align boundary.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the firmware was sucessfully downloaded
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * was not configured
+ * CY_AS_ERROR_NOT_IN_CONFIG_MODE
+ * CY_AS_ERROR_INVALID_SIZE - the size of the firmware
+ * exceeded 32768 bytes
+ * CY_AS_ERROR_ALIGNMENT_ERROR
+ * CY_AS_ERROR_IN_STANDBY - trying to download
+ * while in standby mode
+ * CY_AS_ERROR_TIMEOUT
+
+ See Also
+ * CyAsMiscReset
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_download_firmware(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Pointer to the firmware to be downloaded */
+ const void *fw_p,
+ /* The size of the firmware in bytes */
+ uint16_t size,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+
+/* Summary
+ This function returns the version number of the firmware running in
+ the West Bridge device.
+
+ Description
+ This function queries the West Bridge device and retreives the
+ firmware version number. If the firmware is not loaded an error is
+ returned indicated no firmware has been loaded.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the firmware version number was retreived
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been downloaded
+ * to the device
+ * CY_AS_ERROR_IN_STANDBY
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
+ * from the West Bridge firmware
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_get_firmware_version(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Return values indicating the firmware version. */
+ cy_as_get_firmware_version_data *data,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+#if !defined(__doxygen__)
+
+/* Summary
+ This function reads and returns the contents of an MCU accessible
+ register on the West Bridge.
+
+ Description
+ This function requests the firmware to read and return the contents
+ of an MCU accessible register through the mailboxes.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the register content was retrieved.
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
+ * from the West Bridge firmware
+ * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not
+ * support this command.
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_read_m_c_u_register(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Address of the register to read */
+ uint16_t address,
+ /* Return value for the MCU register content */
+ uint8_t *value,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function writes to an MCU accessible register on the West Bridge.
+
+ Description
+ This function requests the firmware to write a specified value to an
+ MCU accessible register through the mailboxes.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ This function is only for internal use by the West Bridge API layer.
+ Calling this function directly can cause device malfunction.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the register content was updated.
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
+ * from the West Bridge firmware
+ * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not support
+ * this command.
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_write_m_c_u_register(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Address of the register to write */
+ uint16_t address,
+ /* Mask to be applied on the register contents. */
+ uint8_t mask,
+ /* Data to be ORed with the register contents. */
+ uint8_t value,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+#endif
+
+/* Summary
+ This function will reset the West Bridge device and software API.
+
+ Description
+ This function will reset the West Bridge device and software API.
+ The reset operation can be a hard reset or a soft reset. A hard
+ reset will reset all aspects of the West Bridge device. The device
+ will enter the configuration state and the firmware will have to be
+ reloaded. The device will also have to be re-initialized. A soft
+ reset just resets the West Bridge micro-controller.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ When a hard reset is issued, the firmware that may have been
+ previously loaded will be lost and any configuration information set
+ via CyAsMiscConfigureDevice() will be lost. This will be reflected
+ in the API maintained state of the device. In order to re-establish
+ communications with the West Bridge device, CyAsMiscConfigureDevice()
+ and CyAsMiscDownloadFirmware() must be called again.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the device has been reset
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_NOT_YET_SUPPORTED - current soft reset is not supported
+ * CY_AS_ERROR_ASYNC_PENDING - Reset is unable to flush pending async
+ * reads/writes in polling mode.
+
+
+ See Also
+ * CyAsMiscReset
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_reset(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The type of reset to perform */
+ cy_as_reset_type type,
+ /* If true, flush all pending writes to mass storage
+ before performing the reset. */
+ cy_bool flush,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function acquires a given resource.
+
+ Description
+ There are resources in the system that are shared between the
+ West Bridge device and the processor attached to the P port of
+ the West Bridge device. This API provides a mechanism for the
+ P port processor to acquire ownership of a resource.
+
+ Notes
+ The ownership of the resources controlled by CyAsMiscAcquireResource()
+ and CyAsMiscReleaseResource() defaults to a known state at hardware
+ reset. After the firmware is loaded and begins execution the state of
+ these resources may change. At any point if the P Port processor needs
+ to acquire a resource it should do so explicitly to be sure of
+ ownership.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the p port sucessfully acquired the
+ * resource of interest
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_INVALID_RESOURCE
+ * CY_AS_ERROR_RESOURCE_ALREADY_OWNED - the p port already
+ * owns this resource
+ * CY_AS_ERROR_NOT_ACQUIRED - the resource cannot be acquired
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
+ * response from the West Bridge firmware
+
+ See Also
+ * CyAsResourceType
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_acquire_resource(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The resource to acquire */
+ cy_as_resource_type *resource,
+ /* If true, force West Bridge to release the resource */
+ cy_bool force,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function releases a given resource.
+
+ Description
+ There are resources in the system that are shared between the
+ West Bridge device and the processor attached to the P port of
+ the West Bridge device. This API provides a mechanism for the
+ P port processor to release a resource that has previously been
+ acquired via the CyAsMiscAcquireResource() call.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the p port sucessfully released
+ * the resource of interest
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_INVALID_RESOURCE
+ * CY_AS_ERROR_RESOURCE_NOT_OWNED - the p port does not own the
+ * resource of interest
+
+ See Also
+ * CyAsResourceType
+ * CyAsMiscAcquireResource
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_release_resource(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The resource to release */
+ cy_as_resource_type resource
+ ) ;
+
+#ifndef __doxygen__
+/* Summary
+ This function sets the trace level for the West Bridge firmware.
+
+ Description
+ The West Bridge firmware has the ability to store information
+ about the state and execution path of the firmware on a mass storage
+ device attached to the West Bridge device. This function configures
+ the specific mass storage device to be used and the type of information
+ to be stored. This state information is used for debugging purposes
+ and must be interpreted by a Cypress provided tool.
+
+ *Trace Level*
+ The trace level indicates the amount of information to output.
+ * 0 = no trace information is output
+ * 1 = state information is output
+ * 2 = function call information is output
+ * 3 = function call, arguments, and return value information is output
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ The media device and unit specified in this call will be overwritten
+ and any data currently stored on this device and unit will be lost.
+
+ * NOT IMPLEMENTED YET
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the trace configuration has been
+ * sucessfully changed
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified does not exist
+ * CY_AS_ERROR_INVALID_TRACE_LEVEL - the trace level requested
+ * does not exist
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
+ * response from the West Bridge firmware
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_set_trace_level(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The trace level */
+ uint8_t level,
+ /* The bus for the output */
+ cy_as_bus_number_t bus,
+ /* The device for the output */
+ uint32_t device,
+ /* The unit for the output */
+ uint32_t unit,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+#endif
+
+/* Summary
+ This function places West Bridge into the low power standby mode.
+
+ Description
+ This function places West Bridge into a low power (sleep) mode, and
+ cannot be called while the USB stack is active. This function first
+ instructs the West Bridge firmware that the device is about to be
+ placed into sleep mode. This allows West Bridge to complete any pending
+ storage operations. After the West Bridge device has responded that
+ pending operations are complete, the device is placed in standby mode.
+
+ There are two methods of placing the device in standby mode. If the
+ WAKEUP pin of the West Bridge is connected to a GPIO on the processor,
+ the pin is de-asserted (via the HAL layer) and West Bridge enters into
+ a sleep mode. If the WAKEUP pin is not accessible, the processor can
+ write into the power management control/status register on the West
+ Bridge to put the device into sleep mode.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
+ * is in sleep mode
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_ALREADY_STANDBY - the West Bridge device is already
+ * in sleep mode
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
+ * from the West Bridge firmware
+ * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support changing
+ * the WAKEUP pin
+ * CY_AS_ERROR_USB_RUNNING - The USB stack is still running when the
+ * EnterStandby call is made
+ * CY_AS_ERROR_ASYNC_PENDING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_SETTING_WAKEUP_PIN
+ * CY_AS_ERROR_ASYNC_PENDING - In polling mode EnterStandby can not
+ * be called until all pending storage read/write requests have
+ * finished.
+
+ See Also
+ * CyAsMiscLeaveStandby
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_enter_standby_e_x_u(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* If true, use the wakeup pin, otherwise use the register */
+ cy_bool pin,
+ /* Set true to enable specific usages of the
+ UVALID signal, please refer to AN xx or ERRATA xx */
+ cy_bool uvalid_special,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function is provided for backwards compatibility.
+
+ Description
+ Calling this function is the same as calling CyAsMiscEnterStandbyEx
+ with True for the lowpower parameter.
+
+ See Also
+ * CyAsMiscEnterStandbyEx
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_enter_standby(cy_as_device_handle handle,
+ cy_bool pin,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function brings West Bridge out of sleep mode.
+
+ Description
+ This function asserts the WAKEUP pin (via the HAL layer). This
+ brings the West Bridge out of the sleep state and allows the
+ West Bridge firmware to process the event causing the wakeup.
+ When all processing associated with the wakeup is complete, a
+ callback function is called to tell the P port software that
+ the firmware processing associated with wakeup is complete.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns:
+ * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
+ * is in sleep mode
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_SETTING_WAKEUP_PIN
+ * CY_AS_ERROR_NOT_IN_STANDBY - the West Bridge device is not in
+ * the sleep state
+ * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
+ * response from the West Bridge firmware
+ * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support
+ * changing the WAKEUP pin
+
+ See Also
+ * CyAsMiscEnterStandby
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_leave_standby(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The resource causing the wakeup */
+ cy_as_resource_type resource
+ ) ;
+
+/* Summary
+ This function registers a callback function to be called when an
+ asynchronous West Bridge MISC event occurs.
+
+ Description
+ When asynchronous misc events occur, a callback function can be
+ called to alert the calling program. This functions allows the
+ calling program to register a callback.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns:
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_register_callback(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The function to call */
+ cy_as_misc_event_callback callback
+ ) ;
+
+/* Summary
+ This function sets the logging level for log messages.
+
+ Description
+ The API can print messages via the CyAsHalPrintMessage capability.
+ This function sets the level of detail seen when printing messages
+ from the API.
+
+ * Valid In Asynchronous Callback:NO
+*/
+EXTERN void
+cy_as_misc_set_log_level(
+ /* Level to set, 0 is fewer messages, 255 is all */
+ uint8_t level
+ ) ;
+
+
+/* Summary
+ This function tells West Bridge that SD or MMC media has been
+ inserted or removed.
+
+ Description
+ In some hardware configurations, SD or MMC media detection is
+ handled outside of the West Bridge device. This function is called
+ when a change is detected to inform the West Bridge firmware to check
+ for storage media changes.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns:
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_IN_STANDBY
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsMiscStorageChanged
+
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_storage_changed(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function instructs the West Bridge firmware to start/stop
+ sending periodic heartbeat messages to the processor.
+
+ Description
+ The West Bridge firmware can send heartbeat messages through the
+ mailbox register once every 500 ms. This message can be an overhead
+ as it causes regular Mailbox interrupts to happen, and is turned
+ off by default. The message can be used to test and verify that the
+ West Bridge firmware is alive. This API can be used to enable or
+ disable the heartbeat message.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function completed successfully
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured yet
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
+ * the West Bridge device
+
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_heart_beat_control(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Message enable/disable selection */
+ cy_bool enable,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function gets the current state of a GPIO pin on the
+ West Bridge device.
+
+ Description
+ The West Bridge device has GPIO pins that can be used for user
+ defined functions. This function gets the current state of the
+ specified GPIO pin. Calling this function will configure the
+ corresponding pin as an input.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ Only GPIO[0], GPIO[1] and UVALID pins can be used as GP inputs.
+ Of these pins, only the UVALID pin is supported by firmware images
+ that include NAND storage support.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function completed successfully
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured yet
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
+ * to the West Bridge device
+ * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
+ * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
+ * by the firmware
+
+ See Also
+ * CyAsMiscGpio
+ * CyAsMiscSetGpioValue
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_get_gpio_value(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Id of the GPIO pin to query */
+ cy_as_misc_gpio pin,
+ /* Current value of the GPIO pin */
+ uint8_t *value,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function updates the state of a GPIO pin on the West
+ Bridge device.
+
+ Description
+ The West Bridge device has GPIO pins that can be used for
+ user defined functions. This function updates the output
+ value driven on a specified GPIO pin. Calling this function
+ will configure the corresponding pin as an output.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ All of the pins listed under CyAsMiscGpio can be used as GP
+ outputs. This feature is note supported by firmware images
+ that include NAND storage device support.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function completed successfully
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured yet
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
+ * to the West Bridge device
+ * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
+ * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
+ * by firmware.
+
+ See Also
+ * CyAsMiscGpio
+ * CyAsMiscGetGpioValue
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_set_gpio_value(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Id of the GPIO pin to set */
+ cy_as_misc_gpio pin,
+ /* Value to be set on the GPIO pin */
+ uint8_t value,
+ /* Callback to call when the operation is complete. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Set the West Bridge device in the low power suspend mode.
+
+ Description
+ The West Bridge device has a low power suspend mode where the USB
+ core and the internal microcontroller are powered down. This
+ function sets the West Bridge device into this low power mode.
+ This mode can only be entered when there is no active USB
+ connection; i.e., when USB has not been connected or is suspended;
+ and there are no pending USB or storage asynchronous calls. The
+ device will exit the suspend mode and resume handling USB and
+ processor requests when any activity is detected on the CE#, D+/D-
+ or GPIO[0] lines.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ The GPIO[0] pin needs to be configured as an input for the gpio
+ wakeup to work. This flag should not be enabled if the pin is
+ being used as a GP output.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the device was placed in suspend mode.
+ * CY_AS_ERROR_INVALID_HANDLE - the West Bridge handle passed
+ * in is invalid.
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * yet been configured.
+ * CY_AS_ERROR_NO_FIRMWARE - no firmware has been downloaded
+ * to the device.
+ * CY_AS_ERROR_IN_STANDBY - the device is already in sleep mode.
+ * CY_AS_ERROR_USB_CONNECTED - the USB connection is active.
+ * CY_AS_ERROR_ASYNC_PENDING - asynchronous storage/USB calls
+ * are pending.
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
+ * the operation.
+ * CY_AS_ERROR_INVALID_RESPONSE - command not recognised by
+ * firmware.
+
+ See Also
+ * CyAsMiscLeaveSuspend
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_enter_suspend(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Control the USB wakeup source */
+ cy_bool usb_wakeup_en,
+ /* Control the GPIO[0] wakeup source */
+ cy_bool gpio_wakeup_en,
+ /* Callback to call when suspend mode entry is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Wake up the West Bridge device from suspend mode.
+
+ Description
+ This call wakes up the West Bridge device from suspend mode,
+ and makes it ready for accepting other commands from the API.
+ A CyAsEventMiscWakeup event will be delivered to the callback
+ registered with CyAsMiscRegisterCallback to indicate that the
+ wake up is complete.
+
+ The CyAsEventMiscWakeup event will also be delivered if the
+ wakeup happens due to USB or GPIO activity.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the device was woken up from
+ * suspend mode.
+ * CY_AS_ERROR_INVALID_HANDLE - invalid device handle
+ * passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has
+ * not been configured.
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been
+ * downloaded to the device.
+ * CY_AS_ERROR_NOT_IN_SUSPEND - the device is not in
+ * suspend mode.
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory
+ * for the operation.
+ * CY_AS_ERROR_TIMEOUT - failed to wake up the device.
+
+ See Also
+ * CyAsMiscEnterSuspend
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_leave_suspend(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Callback to call when device has resumed operation. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Reserve first numzones zones of nand device for storing
+ processor boot image. LNA firmware works on the first
+ numzones zones of nand to enable the processor to boot.
+
+ Description
+ This function reserves first numzones zones of nand device
+ for storing processor boot image. This fonction MUST be
+ completed before starting the storage stack for the setting
+ to be taken into account.
+
+ * Valid In Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS- zones are reserved.
+
+*/
+EXTERN cy_as_return_status_t
+cy_as_misc_reserve_l_n_a_boot_area(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* number of nand zones to reserve */
+ uint8_t numzones,
+ /* Callback to call when device has resumed operation. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Select the clock frequency to be used when talking to low
+ speed (non-high speed) SD media.
+
+ Description
+ West Bridge firmware uses a clock frequency less than the
+ maximum possible rate for low speed SD media. This function
+ selects the frequency setting from between the default speed
+ and the maximum speed. This fonction MUST be completed before
+ starting the storage stack for the setting to be taken into
+ account.
+
+ * Valid in Asynchronous Callback: Yes (if cb is non-zero)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the operation completed successfully.
+ * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
+ * configured.
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
+ * to the device.
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
+ * the operation.
+ * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend
+ * mode.
+ * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
+ * desired.
+ * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
+ * the operation.
+ * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
+ * the operation.
+
+ See Also
+ * CyAsLowSpeedSDFreq
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_set_low_speed_sd_freq(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Frequency setting desired for low speed SD cards */
+ cy_as_low_speed_sd_freq setting,
+ /* Callback to call on completion */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Select the clock frequency to be used when talking to high speed
+ SD/MMC media.
+
+ Description
+ West Bridge firmware uses a 48 MHz clock to interface with high
+ speed SD/MMC media. This clock rate can be restricted to 24 MHz
+ if desired. This function selects the frequency setting to be
+ used. This fonction MUST be completed before starting the storage
+ stack for the setting to be taken into account.
+
+ * Valid in Asynchronous Callback: Yes (if cb is non-zero)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the operation completed successfully.
+ * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
+ * configured.
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
+ * the device.
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the
+ * operation.
+ * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
+ * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
+ * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the
+ * operation.
+ * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
+ * the operation.
+
+ See Also
+ * CyAsLowSpeedSDFreq
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_set_high_speed_sd_freq(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Frequency setting desired for high speed SD cards */
+ cy_as_high_speed_sd_freq setting,
+ /* Callback to call on completion */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+/* Summary
+ Select the polarity of the SD_POW output driven by West Bridge.
+
+ Description
+ The SD_POW signal driven by West Bridge can be used to control
+ the supply of Vcc to the SD/MMC media connected to the device.
+ This signal is driven as an active high signal by default. This
+ function can be used to change the polarity of this signal if
+ required. This fonction MUST be completed before starting the
+ storage stack for the setting to be taken into account.
+
+ * Valid in Asynchronous Callback: Yes (if cb is non-zero)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the operation completed successfully.
+ * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
+ * configured.
+ * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
+ * to the device.
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
+ * the operation.
+ * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power
+ * suspend mode.
+ * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
+ * desired.
+ * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
+ * the operation.
+ * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not
+ * support the operation.
+
+ See Also
+ * CyAsMiscSignalPolarity
+ */
+EXTERN cy_as_return_status_t
+cy_as_misc_set_sd_power_polarity(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Desired polarity setting to the SD_POW signal. */
+ cy_as_misc_signal_polarity polarity,
+ /* Callback to call on completion. */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback. */
+ uint32_t client
+ ) ;
+
+/* For supporting deprecated functions */
+#include "cyasmisc_dep.h"
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASMISC_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc_dep.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc_dep.h
new file mode 100644
index 000000000000..8b258efc0182
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc_dep.h
@@ -0,0 +1,53 @@
+/* Cypress West Bridge API header file (cyasmisc_dep.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/* This header will contain Antioch specific declaration
+ * of the APIs that are deprecated in Astoria SDK. This is
+ * for maintaining backward compatibility with prior releases
+ * of the Antioch SDK.
+ */
+#ifndef __INCLUDED_CYASMISC_DEP_H__
+#define __INCLUDED_CYASMISC_DEP_H__
+
+#ifndef __doxygen__
+
+EXTERN cy_as_return_status_t
+cy_as_misc_acquire_resource_dep(cy_as_device_handle handle,
+ cy_as_resource_type resource,
+ cy_bool force);
+EXTERN cy_as_return_status_t
+cy_as_misc_get_firmware_version_dep(cy_as_device_handle handle,
+ uint16_t *major,
+ uint16_t *minor,
+ uint16_t *build,
+ uint8_t *media_type,
+ cy_bool *is_debug_mode);
+EXTERN cy_as_return_status_t
+cy_as_misc_set_trace_level_dep(cy_as_device_handle handle,
+ uint8_t level,
+ cy_as_media_type media,
+ uint32_t device,
+ uint32_t unit,
+ cy_as_function_callback cb,
+ uint32_t client);
+#endif /*__doxygen*/
+
+#endif /*__INCLUDED_CYANSTORAGE_DEP_H__*/
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmtp.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmtp.h
new file mode 100644
index 000000000000..25af22e9a6b7
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmtp.h
@@ -0,0 +1,646 @@
+/* Cypress West Bridge API header file (cyasmtp.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASMTP_H_
+#define _INCLUDED_CYASMTP_H_
+
+#include "cyasmisc.h"
+
+#include "cyas_cplus_start.h"
+
+/*@@Media Transfer Protocol (MTP) Overview
+ Summary
+ The MTP API has been designed to allow MTP enabled West Bridge
+ devices to implement the MTP protocol while maintaining high
+ performance. West Bridge has the capability to enter into a
+ Turbo mode during a MTP SendObject or GetObject operation
+ enabling it to directly stream the data into or out of the
+ attached SD card with minimal involvement from the Processor.
+
+ Description
+ The MTP API is designed to act as a pass through implementation
+ of the MTP protocol for all operations. Each MTP transaction
+ received from the Host is passed through West Bridge and along
+ to the Processor. The Processor can then respond to the
+ transaction and pass data and/or responses back to the Host
+ through West Bridge.
+
+ The MTP API also allows for a high speed handling of MTP
+ SendObject and GetObject operations, referred to as Turbo MTP.
+ During a Turbo MTP operation West Bridge is responsible for
+ reading or writing the data for the MTP operation directly from
+ or to the SD card with minimal interaction from the Processor.
+ The is done by having the Processor transfer a Block Table
+ to West Bridge which contains the locations on the SD card that
+ need to be read or written. During the handling of a Turbo
+ Operation the Processor will then only periodically need to
+ send a new Block Table to West Bridge when the first is used up.
+ See the CyAsMTPInitSendObject and CyAsMTPInitGetObject functions
+ for more details.
+
+ In order to enable the MTP API you must first have a MTP enabled
+ West Bridge loaded with MTP firmware. You then must start the USB
+ and Storage APIs before starting the MTP API. See CyAsMTPStart
+ for more details.
+*/
+
+/*@@Endpoints
+ Summary
+ When using MTP firmware endpoints 2 and 6 are dedicated
+ to bulk MTP traffic and endpoint 1 is available for MTP
+ events.
+
+ Description
+ When using a MTP enabled West Brdige device endpoints 2 and
+ 6 are made available for use to implement the MTP protocol.
+ These endpoints have a few special restrictions noted below
+ but otherwise the existing USB APIs can be used normally with
+ these endpoints.
+
+ 1. CyAsUsbSetNak, CyAsUsbClearNak, and CyAsUsbGetNak are
+ disabled for these endpoints
+ 2. During a turbo operation CyAsUsbSetStall, CyAsUsbClearStall,
+ and CyAsUsbGetStall are disabled.
+
+*/
+
+
+/* Summary
+ This constants defines the maximum number of
+ entries in the Block Table used to describe
+ the locations for Send/GetObject operations.
+
+ See Also
+ * CyAsMtpSendObject
+ * CyAsMtpGetObject
+*/
+#define CY_AS_MAX_BLOCK_TABLE_ENTRIES 64
+
+/* Summary
+ Endpoint to be used for MTP reads from the USB host.
+ */
+#define CY_AS_MTP_READ_ENDPOINT (2)
+
+/* Summary
+ Endpoint to be used fro MTP writes to the USB host.
+ */
+#define CY_AS_MTP_WRITE_ENDPOINT (6)
+
+/******************************************
+ * MTP Types
+ ******************************************/
+
+/* Summary
+ The BlockTable used for turbo operations.
+
+ Description
+ This struct is used to specify the blocks
+ to be used for both read/write and send/getObject
+ operations.
+
+ The start block is a starting Logical Block Address
+ and num block is the number of blocks in that contiguous
+ region.
+
+ start_blocks[i]->[-------] <- start_blocks[i] + num_blocks[i]
+
+ If you need fewer than CY_AS_MAX_BLOCK_TABLE_ENTRIES
+ the remainder should be left empty. Empty is defined
+ as num_blocks equal to 0.
+
+ See Also
+ * CyAsMTPInitSendObject
+ * CyAsMTPInitGetObject
+
+*/
+typedef struct cy_as_mtp_block_table {
+ uint32_t start_blocks[CY_AS_MAX_BLOCK_TABLE_ENTRIES] ;
+ uint16_t num_blocks[CY_AS_MAX_BLOCK_TABLE_ENTRIES] ;
+} cy_as_mtp_block_table ;
+
+/* Summary
+ This type specifies the type of MTP event that has occurred.
+
+ Description
+ MTP events are used to communicate that West Bridge has
+ either finished the handling of the given operation, or
+ that it requires additional data to complete the operation.
+
+ In no case does West Bridge send any MTP protocol responses,
+ this always remain the responsibility of the client.
+
+ See Also
+ * CyAsMTPInitSendObject
+ * CyAsMTPInitGetObject
+ * CyAsMTPSendBlockTable
+
+*/
+typedef enum cy_as_mtp_event {
+ /* This event is sent when West Bridge
+ has finished writing the data from a
+ send_object. west bridge will -not- send
+ the MTP response. */
+ cy_as_mtp_send_object_complete,
+
+ /* This event is sent when West Bridge
+ has finished sending the data for a
+ get_object operation. west bridge will
+ -not- send the MTP response. */
+ cy_as_mtp_get_object_complete,
+
+ /* This event is called when West Bridge
+ needs a new block_table. this is only a
+ notification, to transfer a block_table
+ to west bridge the cy_as_mtp_send_block_table
+ use the function. while west bridge is waiting
+ for a block_table during a send_object it
+ may need to NAK the endpoint. it is important
+ that the cy_as_mtp_send_block_table call is made
+ in a timely manner as eventually a delay
+ will result in an USB reset. this event has
+ no data */
+ cy_as_mtp_block_table_needed
+} cy_as_mtp_event ;
+
+/* Summary
+ Data for the CyAsMTPSendObjectComplete event.
+
+ Description
+ Notification that a SendObject operation has been
+ completed. The status of the operation is given
+ (to distinguish between a cancelled and a success
+ for example) as well as the block count. The blocks
+ are used in order based on the current block table.
+ If more than one block table was used for a given
+ SendObject the count will include the total number
+ of blocks written.
+
+ This callback will be made only once per SendObject
+ operation and it will only be called after all of
+ the data has been committed to the SD card.
+
+ See Also
+ * CyAsMTPEvent
+
+ */
+typedef struct cy_as_mtp_send_object_complete_data {
+ cy_as_return_status_t status ;
+ uint32_t byte_count ;
+ uint32_t transaction_id ;
+} cy_as_mtp_send_object_complete_data ;
+
+/* Summary
+ Data for the CyAsMTPGetObjectComplete event.
+
+ Description
+ Notification that a GetObject has finished. This
+ event allows the P side to know when to send the MTP
+ response for the GetObject operation.
+
+ See Also
+ * CyAsMTPEvent
+
+*/
+typedef struct cy_as_mtp_get_object_complete_data {
+ cy_as_return_status_t status ;
+ uint32_t byte_count ;
+} cy_as_mtp_get_object_complete_data ;
+
+/* Summary
+ MTP Event callback.
+
+ Description
+ Callback used to communicate that a SendObject
+ operation has finished.
+
+ See Also
+ * CyAsMTPEvent
+*/
+typedef void (*cy_as_mtp_event_callback)(
+ cy_as_device_handle handle,
+ cy_as_mtp_event evtype,
+ void *evdata
+ ) ;
+
+/* Summary
+ This is the callback function called after asynchronous API
+ functions have completed.
+
+ Description
+ When calling API functions from callback routines (interrupt
+ handlers usually) the async version of these functions must
+ be used. This callback is called when an asynchronous API
+ function has completed.
+*/
+typedef void (*cy_as_mtp_function_callback)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The error status of the operation */
+ cy_as_return_status_t status,
+ /* A client supplied 32 bit tag */
+ uint32_t client
+) ;
+
+/**************************************
+ * MTP Functions
+ **************************************/
+
+/* Summary
+ This function starts the MTP stack.
+
+ Description
+ Initializes West Bridge for MTP activity and registers the MTP
+ event callback.
+
+ Before calling CyAsMTPStart, CyAsUsbStart and CyAsStorageStart must be
+ called (in either order).
+
+ MTPStart must be called before the device is enumerated. Please
+ see the documentation for CyAsUsbSetEnumConfig and CyAsUsbEnumControl
+ for details on enumerating a device for MTP.
+
+ Calling MTPStart will not affect any ongoing P<->S traffic.
+
+ This requires a MTP firmware image to be loaded on West Bridge.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_IN_SUSPEND
+ * CY_AS_ERROR_INVALID_IN_CALLBACK
+ * CY_AS_ERROR_STARTSTOP_PENDING
+ * CY_AS_ERROR_NOT_RUNNING - CyAsUsbStart or CyAsStorageStart
+ * have not been called
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+
+ See Also
+ * CyAsMTPStop
+ * CyAsUsbStart
+ * CyAsStorageStart
+ * CyAsUsbSetEnumConfig
+ * CyAsUsbEnumControl
+*/
+cy_as_return_status_t
+cy_as_mtp_start(
+ cy_as_device_handle handle,
+ cy_as_mtp_event_callback event_c_b,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+
+/* Summary
+ This function stops the MTP stack.
+
+ Description
+ Stops all MTP activity. Any ongoing transfers are
+ canceled.
+
+ This will not cause a UsbDisconnect but all
+ MTP activity (both pass through and turbo) will
+ stop.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_IN_SUSPEND
+ * CY_AS_ERROR_INVALID_IN_CALLBACK
+ * CY_AS_ERROR_STARTSTOP_PENDING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+
+ See Also
+ * CyAsMTPStart
+*/
+cy_as_return_status_t
+cy_as_mtp_stop(
+ cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets up a Turbo SendObject operation.
+
+ Description
+ Calling this function will setup West Bridge to
+ enable Tubo handling of the next SendObject
+ operation received. This will pass down the initial
+ block table to the firmware and setup a direct u->s
+ write for the SendObject operation.
+
+ If this function is not called before a SendObject
+ operation is seen the SendObject operation and data
+ will be passed along to the P port like any other MTP
+ command. It would then be the responsibility of the
+ client to perform a normal StorageWrite call to
+ store the data on the SD card. N.B. This will be
+ very slow compared with the Turbo handling.
+
+ The completion of this function only signals that
+ West Bridge has been set up to receive the next SendObject
+ operation. When the SendObject operation has been fully
+ handled and the data written to the SD card a separate
+ event will be triggered.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_IN_SUSPEND
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_ASYNC_PENDING
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+
+ See Also
+ * CyAsMTPCancelSendObject
+ * CyAsMTPInitGetObject
+ * CyAsMTPEvent
+ * CyAsMTPSendBlockTable
+*/
+cy_as_return_status_t
+cy_as_mtp_init_send_object(
+ cy_as_device_handle handle,
+ cy_as_mtp_block_table *blk_table,
+ uint32_t num_bytes,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function cancels an ongoing MTP operation.
+
+ Description
+ Causes West Bridge to cancel an ongoing SendObject
+ operation. Note this is only a cancel to West Bridge,
+ the MTP operation still needs to be canceled by
+ sending a response.
+
+ West Bridge will automatically set a Stall on the endpoint
+ when the cancel is received.
+
+ This function is only valid after CyAsMTPInitSendObject
+ has been called, but before the CyAsMTPSendObjectComplete
+ event has been sent.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+ * CY_AS_ERROR_NO_OPERATION_PENDING
+
+ See Also
+ * CyAsMTPInitSendObject
+*/
+cy_as_return_status_t
+cy_as_mtp_cancel_send_object(
+ cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets up a turbo GetObject operation.
+
+ Description
+ Called by the P in response to a GetObject
+ operation. This provides West Bridge with the block
+ addresses for the Object data that needs to be
+ transferred.
+
+ It is the responsibility of the Processor to send the MTP
+ operation before calling CyAsMTPInitGetObject. West Bridge
+ will then send the data phase of the transaction,
+ automatically creating the required container for Data.
+ Once all of the Data has been transferred a callback will
+ be issued to inform the Processor that the Data phase has
+ completed allowing it to send the required MTP response.
+
+ If an entire Block Table is used then after the
+ last block is transferred the CyAsMTPBtCallback
+ will be called to allow an additional Block Table(s)
+ to be specified.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_IN_SUSPEND
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_ASYNC_PENDING
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+
+ See Also
+ * CyAsMTPInitSendObject
+ * CyAsMTPCancelGetObject
+ * CyAsMTPEvent
+ * CyAsMTPSendBlockTable
+*/
+cy_as_return_status_t
+cy_as_mtp_init_get_object(
+ cy_as_device_handle handle,
+ cy_as_mtp_block_table *table_p,
+ uint32_t num_bytes,
+ uint32_t transaction_id,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function cancels an ongoing turbo GetObject
+ operation.
+
+ Description
+ Causes West Bridge to cancel an ongoing GetObject
+ operation. Note this is only a cancel to West Bridge,
+ the MTP operation still needs to be canceled by
+ sending a response.
+
+ This function is only valid after CyAsMTPGetSendObject
+ has been called, but before the CyAsMTPGetObjectComplete
+ event has been sent.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+ * CY_AS_ERROR_NO_OPERATION_PENDING
+
+ See Also
+ * CyAsMTPInitGetObject
+*/
+cy_as_return_status_t
+cy_as_mtp_cancel_get_object(
+ cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function is used to transfer a BlockTable as part of
+ an ongoing MTP operation.
+
+ Description
+ This function is called in response to the
+ CyAsMTPBlockTableNeeded event. This allows the client to
+ pass in a BlockTable structure to West Bridge.
+
+ The memory associated with the table will be copied and
+ can be safely disposed of when the function returns if
+ called synchronously, or when the callback is made if
+ called asynchronously.
+
+ This function is used for both SendObject and GetObject
+ as both can generate the CyAsMTPBlockTableNeeded event.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_NOT_CONFIGURED
+ * CY_AS_ERROR_NO_FIRMWARE
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_IN_SUSPEND
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_ASYNC_PENDING
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_SUPPORTED - West Bridge is not running
+ * firmware with MTP support
+
+ See Also
+ * CyAsMTPInitSendObject
+ * CyAsMTPInitGetObject
+*/
+cy_as_return_status_t
+cy_as_mtp_send_block_table(
+ cy_as_device_handle handle,
+ cy_as_mtp_block_table *table,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function is used to mark the start of a storage
+ read/write burst from the P port processor.
+
+ Description
+ This function is used to mark the start of a storage
+ read/write burst from the processor. All USB host access
+ into the mass storage / MTP endpoints will be blocked
+ while the read/write burst is ongoing, and will be allowed
+ to resume only after CyAsMTPStorageOnlyStop is called.
+ The burst mode is used to reduce the firmware overhead
+ due to configuring the internal data paths repeatedly,
+ and can help improve performance when a sequence of
+ read/writes is performed in a burst.
+
+ This function will not generate a special mailbox request,
+ it will only set a flag on the next Storage Read/Write
+ operation. Until such a call is made West Bridge will
+ continue to accept incoming packets from the Host.
+
+ * Valid in Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_INVALID_HANDLE - Invalid West Bridge device
+ * handle was passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not
+ * been configured.
+ * CY_AS_ERROR_NO_FIRMWARE - Firmware is not active on West
+ * Bridge device.
+ * CY_AS_ERROR_NOT_RUNNING - Storage stack is not running.
+ * CY_AS_ERROR_SUCCESS - Burst mode has been started.
+
+ See Also
+ * CyAsStorageReadWriteBurstStop
+ */
+cy_as_return_status_t
+cy_as_mtp_storage_only_start(
+ /* Handle to the West Bridge device. */
+ cy_as_device_handle handle
+ );
+
+/* Summary
+ This function is used to mark the end of a storage read/write
+ burst from the P port processor.
+
+ Description
+ This function is used to mark the end of a storage read/write
+ burst from the processor. At this point, USB access to the
+ mass storage / MTP endpoints on the West Bridge device will be
+ re-enabled.
+
+ * Valid in Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_INVALID_HANDLE - Invalid West Bridge device handle
+ * was passed in.
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
+ * configured.
+ * CY_AS_ERROR_NO_FIRMWARE - Firmware is not active on West Bridge
+ * device.
+ * CY_AS_ERROR_NOT_RUNNING - Storage stack is not running.
+ * CY_AS_ERROR_INVALID_IN_CALLBACK - This API cannot be called
+ * from a callback.
+ * CY_AS_ERROR_OUT_OF_MEMORY - Failed to allocate memory to
+ * process the request.
+ * CY_AS_ERROR_TIMEOUT - Failed to send request to firmware.
+ * CY_AS_ERROR_SUCCESS - Burst mode has been stopped.
+
+ See Also
+ * CyAsStorageReadWriteBurstStart
+ */
+cy_as_return_status_t
+cy_as_mtp_storage_only_stop(
+ /* Handle to the West Bridge device. */
+ cy_as_device_handle handle,
+ cy_as_function_callback cb,
+ uint32_t client
+ );
+
+#include "cyas_cplus_end.h"
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasprotocol.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasprotocol.h
new file mode 100644
index 000000000000..317805fc4ff4
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasprotocol.h
@@ -0,0 +1,3838 @@
+/* Cypress West Bridge API header file (cyasprotocol.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASPROTOCOL_H_
+#define _INCLUDED_CYASPROTOCOL_H_
+
+/*
+ * Constants defining the per context buffer sizes
+ */
+#ifndef __doxygen__
+#define CY_CTX_GEN_MAX_DATA_SIZE (8)
+#define CY_CTX_RES_MAX_DATA_SIZE (8)
+#define CY_CTX_STR_MAX_DATA_SIZE (64)
+#define CY_CTX_USB_MAX_DATA_SIZE (130 + 23)
+#define CY_CTX_TUR_MAX_DATA_SIZE (12)
+#endif
+
+/* Summary
+ This response indicates a command has been processed
+ and returned a status.
+
+ Direction
+ West Bridge -> P Port Processor
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = all
+ * Response Code = 0
+
+ D0
+ * 0 = success (CY_AS_ERROR_SUCCESS)
+ * non-zero = error code
+
+ Description
+ This response indicates that a request was processed
+ and no data was generated as a result of the request
+ beyond a single 16 bit status value. This response
+ contains the 16 bit data value.
+ */
+#define CY_RESP_SUCCESS_FAILURE (0)
+
+/* Summary
+ This response indicates an invalid request was sent
+
+ Direction
+ West Bridge -> P Port Processor
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = all
+ * Response Code = 1
+
+ D0
+ * Mailbox contents for invalid request
+
+ Description
+ This response is returned when a request is sent
+ that contains an invalid
+ context or request code.
+*/
+#define CY_RESP_INVALID_REQUEST (1)
+
+/* Summary
+ This response indicates a request of invalid length was sent
+
+ Direction
+ West Bridge -> P Port Processor
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = all
+ * Response Code = 2
+
+ D0
+ * Mailbox contenxt for invalid request
+ * Length for invalid request
+
+ Description
+ The software API and firmware sends requests across the
+ P Port to West Bridge interface on different contexts.
+ Each contexts has a maximum size of the request packet
+ that can be received. The size of a request can be
+ determined during the first cycle of a request transfer.
+ If the request is larger than can be handled by the
+ receiving context this response is returned. Note that
+ the complete request is received before this response is
+ sent, but that the request is dropped after this response
+ is sent.
+*/
+#define CY_RESP_INVALID_LENGTH (2)
+
+
+/* Summary
+ This response indicates a request was made to an
+ invalid storage address.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = all
+ * Response Code = 0
+
+ D0
+ Bits 15 - 12 : Media Type
+ * 0 = NAND
+ * 1 = SD Flash
+ * 2 = MMC Flash
+ * 3 = CE-ATA
+
+ Bits 11 - 8 : Zero based device index
+
+ Bits 7 - 0 : Zero based unit index
+
+ D1
+ Upper 16 bits of block address
+
+ D2
+ Lower 16 bits of block address
+
+ D3
+ Portion of address that is invalid
+ * 0 = Media Type
+ * 1 = Device Index
+ * 2 = Unit Index
+ * 3 = Block Address
+
+ Description
+ This response indicates a request to an invalid storage media
+ address
+ */
+#define CY_RESP_NO_SUCH_ADDRESS (3)
+
+
+/******************************************************/
+
+/*@@General requests
+ Summary
+ The general requests include:
+ * CY_RQT_GET_FIRMWARE_VERSION
+ * CY_RQT_SET_TRACE_LEVEL
+ * CY_RQT_INITIALIZATION_COMPLETE
+ * CY_RQT_READ_MCU_REGISTER
+ * CY_RQT_WRITE_MCU_REGISTER
+ * CY_RQT_STORAGE_MEDIA_CHANGED
+ * CY_RQT_CONTROL_ANTIOCH_HEARTBEAT
+ * CY_RQT_PREPARE_FOR_STANDBY
+ * CY_RQT_ENTER_SUSPEND_MODE
+ * CY_RQT_OUT_OF_SUSPEND
+ * CY_RQT_GET_GPIO_STATE
+ * CY_RQT_SET_GPIO_STATE
+ * CY_RQT_SET_SD_CLOCK_FREQ
+ * CY_RQT_WB_DEVICE_MISMATCH
+ * CY_RQT_BOOTLOAD_NO_FIRMWARE
+ * CY_RQT_RESERVE_LNA_BOOT_AREA
+ * CY_RQT_ABORT_P2S_XFER
+ */
+
+#ifndef __doxygen__
+#define CY_RQT_GENERAL_RQT_CONTEXT (0)
+#endif
+
+/* Summary
+ This command returns the firmware version number,
+ media types supported and debug/release mode information.
+
+ Direction
+ P Port Processor-> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request Code = 0
+
+ Description
+ The response contains the 16-bit major version, the
+ 16-bit minor version, the 16 bit build number, media
+ types supported and release/debug mode information.
+
+ Responses
+ * CY_RESP_FIRMWARE_VERSION
+ */
+#define CY_RQT_GET_FIRMWARE_VERSION (0)
+
+
+/* Summary
+ This command changes the trace level and trace information
+ destination within the West Bridge firmware.
+
+ Direction
+ P Port Processor-> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request Code = 1
+
+ D0
+ Trace Level
+ * 0 = no trace information
+ * 1 = state information
+ * 2 = function call
+ * 3 = function call with args/return value
+
+ D1
+ Bits 12 - 15 : MediaType
+ * 0 = NAND
+ * 1 = SDIO Flash
+ * 2 = MMC Flash
+ * 3 = CE-ATA
+
+ Bits 8 - 11 : Zero based device index
+
+ Bits 0 - 7 : Zero based unit index
+
+ Description
+ The West Bridge firmware contains debugging facilities that can
+ be used to trace the execution of the firmware. This request
+ sets the level of tracing information that is stored and the
+ location where it is stored.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_SET_TRACE_LEVEL (1)
+
+/* Summary
+ This command indicates that the firmware is up and ready
+ for communications with the P port processor.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 0
+ * Request Code = 3
+
+ D0
+ Major Version
+
+ D1
+ Minor Version
+
+ D2
+ Build Number
+
+ D3
+ Bits 15-8: Media types supported on Bus 1.
+ Bits 7-0: Media types supported on Bus 0.
+ Bits 8, 0: NAND support.
+ * 0: NAND is not supported.
+ * 1: NAND is supported.
+ Bits 9, 1: SD memory card support.
+ * 0: SD memory card is not supported.
+ * 1: SD memory card is supported.
+ Bits 10, 2: MMC card support.
+ * 0: MMC card is not supported.
+ * 1: MMC card is supported.
+ Bits 11, 3: CEATA drive support
+ * 0: CEATA drive is not supported.
+ * 1: CEATA drive is supported.
+ Bits 12, 4: SD IO card support.
+ * 0: SD IO card is not supported.
+ * 1: SD IO card is supported.
+
+ D4
+ Bits 15 - 8 : MTP information
+ * 0 : MTP not supported in firmware
+ * 1 : MTP supported in firmware
+ Bits 7 - 0 : Debug/Release mode information.
+ * 0 : Release mode
+ * 1 : Debug mode
+
+ Description
+ When the West Bridge firmware is loaded it being by performing
+ initialization. Initialization must be complete before West
+ Bridge is ready to accept requests from the P port processor.
+ This request is sent from West Bridge to the P port processor
+ to indicate that initialization is complete.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_INITIALIZATION_COMPLETE (3)
+
+/* Summary
+ This command requests the firmware to read and return the contents
+ of a MCU accessible
+ register.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 4
+
+ D0
+ Address of register to read
+
+ Description
+ This debug command allows the processor to read the contents of
+ a MCU accessible register.
+
+ Responses
+ * CY_RESP_MCU_REGISTER_DATA
+ */
+#define CY_RQT_READ_MCU_REGISTER (4)
+
+/* Summary
+ This command requests the firmware to write to an MCU
+ accessible register.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 5
+
+ D0
+ Address of register to be written
+
+ D1
+ Bits 15 - 8 : Mask to be applied to existing data.
+ Bits 7 - 0 : Data to be ORed with masked data.
+
+ Description
+ This debug command allows the processor to write to an MCU
+ accessible register.
+ Note: This has to be used with caution, and is supported by
+ the firmware only in special debug builds.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_WRITE_MCU_REGISTER (5)
+
+/* Summary
+ This command tells the West Bridge firmware that a change in
+ storage media has been detected.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 6
+
+ Description
+ If the insertion or removal of SD or MMC cards is detected by
+ hardware external to West Bridge, this command is used to tell
+ the West Bridge firmware to re-initialize the storage controlled
+ by the device.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+*/
+#define CY_RQT_STORAGE_MEDIA_CHANGED (6)
+
+/* Summary
+ This command enables/disables the periodic heartbeat message
+ from the West Bridge firmware to the processor.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 7
+
+ Description
+ This command enables/disables the periodic heartbeat message
+ from the West Bridge firmware to the processor. The heartbeat
+ message is left enabled by default, and can lead to a loss
+ in performance on the P port interface.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_CONTROL_ANTIOCH_HEARTBEAT (7)
+
+/* Summary
+ This command requests the West Bridge firmware to prepare for
+ the device going into standby
+ mode.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 8
+
+ Description
+ This command is sent by the processor to the West Bridge as
+ preparation for going into standby mode. The request allows the
+ firmware to complete any pending/cached storage operations before
+ going into the low power state.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_PREPARE_FOR_STANDBY (8)
+
+/* Summary
+ Requests the firmware to go into suspend mode.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 9
+
+ D0
+ Bits 7-0: Wakeup control information.
+
+ Description
+ This command is sent by the processor to the West Bridge to
+ request the device to be placed in suspend mode. The firmware
+ will complete any pending/cached storage operations before
+ going into the low power state.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_ENTER_SUSPEND_MODE (9)
+
+/* Summary
+ Indicates that the device has left suspend mode.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 10
+
+ Description
+ This message is sent by the West Bridge to the Processor
+ to indicate that the device has woken up from suspend mode,
+ and is ready to accept new requests.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_OUT_OF_SUSPEND (10)
+
+/* Summary
+ Request to get the current state of an West Bridge GPIO pin.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 11
+
+ D0
+ Bits 15 - 8 : GPIO pin identifier
+
+ Responses
+ * CY_RESP_GPIO_STATE
+
+ Description
+ Request from the processor to get the current state of
+ an West Bridge GPIO pin.
+ */
+#define CY_RQT_GET_GPIO_STATE (11)
+
+/* Summary
+ Request to update the output value on an West Bridge
+ GPIO pin.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 12
+
+ D0
+ Bits 15 - 8 : GPIO pin identifier
+ Bit 0 : Desired output state
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+
+ Description
+ Request from the processor to update the output value on
+ an West Bridge GPIO pin.
+ */
+#define CY_RQT_SET_GPIO_STATE (12)
+
+/* Summary
+ Set the clock frequency on the SD interface of the West
+ Bridge device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 13
+
+ D0
+ Bit 8: Type of SD/MMC media
+ 0 = low speed media
+ 1 = high speed media
+ Bit 0: Clock frequency selection
+ 0 = Default frequency
+ 1 = Alternate frequency (24 MHz in both cases)
+
+ Description
+ This request is sent by the processor to set the operating clock
+ frequency used on the SD interface of the device.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_SET_SD_CLOCK_FREQ (13)
+
+/* Summary
+ Indicates the firmware downloaded to West Bridge cannot
+ run on the active device.
+
+ Direction
+ West Bridge -> P Port processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 14
+
+ Description
+ Some versions of West Bridge firmware can only run on specific
+ types/versions of the West Bridge device. This error is
+ returned when a firmware image is downloaded onto a device that
+ does not support it.
+
+ Responses
+ * None
+ */
+#define CY_RQT_WB_DEVICE_MISMATCH (14)
+
+/* Summary
+ This command is indicates that no firmware was found in the
+ storage media.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 0
+ * Request code = 15
+
+ Description
+ The command is received only in case of silicon with bootloader
+ ROM. The device sends the request if there is no firmware image
+ found in the storage media or the image is corrupted. The
+ device is waiting for P port to download a valid firmware image.
+
+ Responses
+ * None
+ */
+#define CY_RQT_BOOTLOAD_NO_FIRMWARE (15)
+
+/* Summary
+ This command reserves first numzones zones of nand device for
+ storing processor boot image.
+
+ Direction
+ P Port Processor-> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request Code = 16
+
+ D0
+ Bits 7-0: numzones
+
+ Description
+ The first numzones zones in nand device will be used for storing
+ proc boot image. LNA firmware in Astoria will work on this nand
+ area and boots the processor which will then use the remaining
+ nand for usual purposes.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_RESERVE_LNA_BOOT_AREA (16)
+
+/* Summary
+ This command cancels the processing of a P2S operation in
+ firmware.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request Code = 17
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+*/
+#define CY_RQT_ABORT_P2S_XFER (17)
+
+/*
+ * Used for debugging, ignore for normal operations
+ */
+#ifndef __doxygen__
+#define CY_RQT_DEBUG_MESSAGE (127)
+#endif
+
+/******************************************************/
+
+/*@@General responses
+ Summary
+ The general responses include:
+ * CY_RESP_FIRMWARE_VERSION
+ * CY_RESP_MCU_REGISTER_DATA
+ * CY_RESP_GPIO_STATE
+ */
+
+
+/* Summary
+ This response indicates success and contains the firmware
+ version number, media types supported by the firmware and
+ release/debug mode information.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 0
+ * Response Code = 16
+
+ D0
+ Major Version
+
+ D1
+ Minor Version
+
+ D2
+ Build Number
+
+ D3
+ Bits 15-8: Media types supported on Bus 1.
+ Bits 7-0: Media types supported on Bus 0.
+ Bits 8, 0: NAND support.
+ * 0: NAND is not supported.
+ * 1: NAND is supported.
+ Bits 9, 1: SD memory card support.
+ * 0: SD memory card is not supported.
+ * 1: SD memory card is supported.
+ Bits 10, 2: MMC card support.
+ * 0: MMC card is not supported.
+ * 1: MMC card is supported.
+ Bits 11, 3: CEATA drive support
+ * 0: CEATA drive is not supported.
+ * 1: CEATA drive is supported.
+ Bits 12, 4: SD IO card support.
+ * 0: SD IO card is not supported.
+ * 1: SD IO card is supported.
+
+ D4
+ Bits 15 - 8 : MTP information
+ * 0 : MTP not supported in firmware
+ * 1 : MTP supported in firmware
+ Bits 7 - 0 : Debug/Release mode information.
+ * 0 : Release mode
+ * 1 : Debug mode
+
+ Description
+ This reponse is sent to return the firmware version
+ number to the requestor.
+ */
+#define CY_RESP_FIRMWARE_VERSION (16)
+
+/* Summary
+ This response returns the contents of a MCU accessible
+ register to the processor.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Response code = 17
+
+ D0
+ Bits 7 - 0 : MCU register contents
+
+ Description
+ This response is sent by the firmware in response to the
+ CY_RQT_READ_MCU_REGISTER
+ command.
+ */
+#define CY_RESP_MCU_REGISTER_DATA (17)
+
+/* Summary
+ Reports the current state of an West Bridge GPIO pin.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request code = 18
+
+ D0
+ Bit 0: Current state of the GP input pin
+
+ Description
+ This response is sent by the West Bridge to report the
+ current state observed on a general purpose input pin.
+ */
+#define CY_RESP_GPIO_STATE (18)
+
+
+/* Summary
+ This command notifies West Bridge the polarity of the
+ SD power pin
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 0
+ * Request Code = 19
+ D0: CyAnMiscActivehigh / CyAnMiscActivelow
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+
+ */
+
+#define CY_RQT_SDPOLARITY (19)
+
+/******************************/
+
+/*@@Resource requests
+ Summary
+
+ The resource requests include:
+ * CY_RQT_ACQUIRE_RESOURCE
+ * CY_RQT_RELEASE_RESOURCE
+ */
+
+
+
+
+
+#ifndef __doxygen__
+#define CY_RQT_RESOURCE_RQT_CONTEXT (1)
+#endif
+
+
+/* Summary
+ This command is a request from the P port processor
+ for ownership of a resource.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 1
+ * Request Code = 0
+
+ D0
+ Resource
+ * 0 = USB
+ * 1 = SDIO/MMC
+ * 2 = NAND
+
+ D1
+ Force Flag
+ * 0 = Normal
+ * 1 = Force
+
+ Description
+ The resource may be the USB pins, the SDIO/MMC bus,
+ or the NAND bus.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_NOT_RELEASED
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_RESOURCE
+ */
+#define CY_RQT_ACQUIRE_RESOURCE (0)
+
+
+/* Summary
+ This command is a request from the P port processor
+ to release ownership of a resource.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 1
+ * Request Code = 1
+
+ D0
+ Resource
+ * 0 = USB
+ * 1 = SDIO/MMC
+ * 2 = NAND
+
+ Description
+ The resource may be the USB pins, the SDIO/MMC bus, or
+ the NAND bus.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_NOT_OWNER
+ */
+#define CY_RQT_RELEASE_RESOURCE (1)
+
+
+/****************************/
+
+/*@@Storage requests
+ Summary
+ The storage commands include:
+ * CY_RQT_START_STORAGE
+ * CY_RQT_STOP_STORAGE
+ * CY_RQT_CLAIM_STORAGE
+ * CY_RQT_RELEASE_STORAGE
+ * CY_RQT_QUERY_MEDIA
+ * CY_RQT_QUERY_DEVICE
+ * CY_RQT_QUERY_UNIT
+ * CY_RQT_READ_BLOCK
+ * CY_RQT_WRITE_BLOCK
+ * CY_RQT_MEDIA_CHANGED
+ * CY_RQT_ANTIOCH_CLAIM
+ * CY_RQT_ANTIOCH_RELEASE
+ * CY_RQT_SD_INTERFACE_CONTROL
+ * CY_RQT_SD_REGISTER_READ
+ * CY_RQT_CHECK_CARD_LOCK
+ * CY_RQT_QUERY_BUS
+ * CY_RQT_PARTITION_STORAGE
+ * CY_RQT_PARTITION_ERASE
+ * CY_RQT_GET_TRANSFER_AMOUNT
+ * CY_RQT_ERASE
+ * CY_RQT_SDIO_READ_DIRECT
+ * CY_RQT_SDIO_WRITE_DIRECT
+ * CY_RQT_SDIO_READ_EXTENDED
+ * CY_RQT_SDIO_WRITE_EXTENDED
+ * CY_RQT_SDIO_INIT_FUNCTION
+ * CY_RQT_SDIO_QUERY_CARD
+ * CY_RQT_SDIO_GET_TUPLE
+ * CY_RQT_SDIO_ABORT_IO
+ * CY_RQT_SDIO_INTR
+ * CY_RQT_SDIO_SUSPEND
+ * CY_RQT_SDIO_RESUME
+ * CY_RQT_SDIO_RESET_DEV
+ * CY_RQT_P2S_DMA_START
+ */
+#ifndef __doxygen__
+#define CY_RQT_STORAGE_RQT_CONTEXT (2)
+#endif
+
+/* Summary
+ This command requests initialization of the storage stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 0
+
+ Description
+ This command is required before any other storage related command
+ can be send to the West Bridge firmware.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_ALREADY_RUNNING
+ */
+#define CY_RQT_START_STORAGE (0)
+
+
+/* Summary
+ This command requests shutdown of the storage stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 1
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_NOT_RUNNING
+ */
+#define CY_RQT_STOP_STORAGE (1)
+
+
+/* Summary
+ This command requests ownership of the given media
+ type by the P port processor.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 2
+
+ D0
+ Bits 12 - 15 : Bus Index
+ Bits 8 - 11 : Zero based device index
+
+ Responses
+ * CY_RESP_MEDIA_CLAIMED_RELEASED
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_CLAIM_STORAGE (2)
+
+
+/* Summary
+ This command releases ownership of a given media type
+ by the P port processor.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 3
+
+ D0
+ Bits 12 - 15 : Bus Index
+ Bits 8 - 11 : Zero based device index
+
+ Responses
+ * CY_RESP_MEDIA_CLAIMED_RELEASED
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_RELEASE_STORAGE (3)
+
+
+/* Summary
+ This command returns the total number of logical devices
+ of the given type of media.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 4
+
+ D0
+ Bits 12 - 15 : MediaType
+ * 0 = NAND
+ * 1 = SDIO Flash
+ * 2 = MMC Flash
+ * 3 = CE-ATA
+
+ Bits 8 - 11 : Not Used
+
+ Bits 0 - 7 : Not Used
+
+ Responses
+ * CY_RESP_MEDIA_DESCRIPTOR
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_QUERY_MEDIA (4)
+
+
+/* Summary
+ This command queries a given device to determine
+ information about the number of logical units on
+ the given device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 5
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Not Used
+
+ Responses
+ * CY_RESP_DEVICE_DESCRIPTOR
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_INVALID_PARTITION_TABLE
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_QUERY_DEVICE (5)
+
+
+/* Summary
+ This command queries a given device to determine
+ information about the size and location of a logical unit
+ located on a physical device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 6
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ Responses
+ * CY_RESP_UNIT_DESCRIPTOR
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_INVALID_PARTITION_TABLE
+ * CY_RESP_NO_SUCH_ADDRESS
+ */
+#define CY_RQT_QUERY_UNIT (6)
+
+
+/* Summary
+ This command initiates the read of a specific block
+ from the given media,
+ device and unit.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 2
+ * Request Code = 7
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ D1
+ Upper 16 bits of block address
+
+ D2
+ Lower 16 bits of block address
+
+ D3
+ BIT 8 - 15 : Upper 8 bits of Number of blocks
+
+ BIT 0 - 7 : Reserved
+
+ * D4 *
+ BITS 8 - 15 : Lower 8 bits of Number of blocks
+ BITS 1 - 7 : Not Used
+ BIT 0 : Indicates whether this command is a
+ part of a P2S only burst.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_ANTIOCH_DEFERRED_ERROR
+ */
+#define CY_RQT_READ_BLOCK (7)
+
+
+/* Summary
+ This command initiates the write of a specific block
+ from the given media, device and unit.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 2
+ * Request Code = 8
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ D1
+ Upper 16 bits of block address
+
+ D2
+ Lower 16 bits of block address
+
+ D3
+ BIT 8 - 15 : Upper 8 bits of Number of blocks
+
+ BIT 0 - 7 : Reserved
+
+ * D4 *
+ BITS 8 - 15 : Lower 8 bits of Number of blocks
+ BITS 1 - 7 : Not Used
+ BIT 0 : Indicates whether this command is a
+ part of a P2S only burst.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_ANTIOCH_DEFERRED_ERROR
+ */
+#define CY_RQT_WRITE_BLOCK (8)
+
+/* Summary
+ This request is sent when the West Bridge device detects
+ a change in the status of the media.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request Code = 9
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 0 - 7 : Media type
+
+ D1
+ Bit 0 : Action
+ * 0 = Inserted
+ * 1 = Removed
+
+ Description
+ When the media manager detects the insertion or removal
+ of a media from the West Bridge port, this request is sent
+ from the West Bridge device to the P Port processor to
+ inform the processor of the change in status of the media.
+ This request is sent for both an insert operation and a
+ removal operation.
+
+ Responses
+ * CY_RESPO_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_MEDIA_CHANGED (9)
+
+/* Summary
+ This request is sent when the USB module wishes to claim
+ storage media.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request Code = 10
+
+ D0
+ Bit 0:
+ * 0 = do not release NAND
+ * 1 = release NAND
+
+ Bit 1:
+ * 0 = do not release SD Flash
+ * 1 = release SD Flash
+
+ Bit 2:
+ * 0 = do not release MMC flash
+ * 1 = release MMC flash
+
+ Bit 3:
+ * 0 = do not release CE-ATA storage
+ * 1 = release CE-ATA storage
+
+ Bit 8:
+ * 0 = do not release storage on bus 0
+ * 1 = release storage on bus 0
+
+ Bit 9:
+ * 0 = do not release storage on bus 1
+ * 1 = release storage on bus 1
+
+ Description
+ When the USB cable is attached to the West Bridge device,
+ West Bridge will enumerate the storage devices per the USB
+ initialization of West Bridge. In order for West Bridge to
+ respond to requests received via USB for the mass storage
+ devices, the USB module must claim the storeage. This
+ request is a request to the P port processor to release the
+ storage medium. The medium will not be visible on the USB
+ host, until it has been released by the processor.
+*/
+#define CY_RQT_ANTIOCH_CLAIM (10)
+
+/* Summary
+ This request is sent when the P port has asked West Bridge to
+ release storage media, and the West Bridge device has
+ completed this.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request Code = 11
+
+ D0
+ Bit 0:
+ * 0 = No change in ownership of NAND storage
+ * 1 = NAND ownership has been given to processor
+
+ Bit 1:
+ * 0 = No change in ownership of SD storage
+ * 1 = SD ownership has been given to processor
+
+ Bit 2:
+ * 0 = No change in ownership of MMC storage
+ * 1 = MMC ownership has been given to processor
+
+ Bit 3:
+ * 0 = No change in ownership of CE-ATA storage
+ * 1 = CE-ATA ownership has been given to processor
+
+ Bit 4:
+ * 0 = No change in ownership of SD IO device
+ * 1 = SD IO device ownership has been given to processor
+
+ Bit 8:
+ * 0 = No change in ownership of storage on bus 0
+ * 1 = Bus 0 ownership has been given to processor
+
+ Bit 9:
+ * 0 = No change in ownership of storage on bus 1
+ * 1 = Bus 1 ownership has been given to processor
+
+ Description
+ When the P port asks for control of a particular media, West
+ Bridge may be able to release the media immediately. West
+ Bridge may also need to complete the flush of buffers before
+ releasing the media. In the later case, West Bridge will
+ indicated a release is not possible immediately and West Bridge
+ will send this request to the P port when the release has been
+ completed.
+*/
+#define CY_RQT_ANTIOCH_RELEASE (11)
+
+/* Summary
+ This request is sent by the Processor to enable/disable the
+ handling of SD card detection and SD card write protection
+ by the firmware.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 12
+
+ D0
+ Bit 8: Enable/disable handling of card detection.
+ Bit 1: SDAT_3 = 0, GIPO_0 = 1
+ Bit 0: Enable/disable handling of write protection.
+
+ Description
+ This request is sent by the Processor to enable/disable
+ the handling of SD card detection and SD card write
+ protection by the firmware.
+ */
+#define CY_RQT_SD_INTERFACE_CONTROL (12)
+
+/* Summary
+ Request from the processor to read a register on the SD
+ card, and return the contents.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 13
+
+ D0
+ Bits 12 - 15 : MediaType
+ * 0 = Reserved
+ * 1 = SDIO Flash
+ * 2 = MMC Flash
+ * 3 = Reserved
+
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Type of register to read
+
+ Description
+ This request is sent by the processor to instruct the
+ West Bridge to read a register on the SD/MMC card, and
+ send the contents back through the CY_RESP_SD_REGISTER_DATA
+ response.
+ */
+#define CY_RQT_SD_REGISTER_READ (13)
+
+/* Summary
+ Check if the SD/MMC card connected to West Bridge is
+ password locked.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 14
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+
+ Description
+ This request is sent by the processor to check if the
+ SD/MMC connected to the West Bridge is locked with a
+ password.
+ */
+#define CY_RQT_CHECK_CARD_LOCK (14)
+
+/* Summary
+ This command returns the total number of logical devices on the
+ given bus
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 15
+
+ D0
+ Bits 12 - 15 : Bus Number
+
+ Bits 0 - 11: Not Used
+
+ Responses
+ * CY_RESP_BUS_DESCRIPTOR
+ * CY_RESP_NO_SUCH_BUS
+ */
+#define CY_RQT_QUERY_BUS (15)
+
+/* Summary
+ Divide a storage device into two partitions.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request code = 16
+
+ D0
+ Bits 12 - 15 : Bus number
+ Bits 8 - 11 : Device number
+ Bits 0 - 7 : Not used
+
+ D1
+ Size of partition 0 (MS word)
+
+ D2
+ Size of partition 0 (LS word)
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_PARTITION_STORAGE (16)
+
+/* Summary
+ Remove the partition table and unify all partitions on
+ a storage device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request code = 17
+
+ D0
+ Bits 12 - 15 : Bus number
+ Bits 8 - 11 : Device number
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_PARTITION_ERASE (17)
+
+/* Summary
+ Requests the current transfer amount.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request code = 18
+
+ D0
+ Bits 12 - 15 : Bus number
+ Bits 8 - 11 : Device number
+
+ Responses
+ * CY_RESP_TRANSFER_COUNT
+ */
+#define CY_RQT_GET_TRANSFER_AMOUNT (18)
+
+/* Summary
+ Erases.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 2
+ * Request code = 19
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ D1
+ Upper 16 bits of erase unit
+
+ D2
+ Lower 16 bits of erase unit
+
+ D3
+ BIT 8 - 15 : Upper 8 bits of Number of erase units
+ BIT 0 - 7 : Reserved
+
+ * D4 *
+ BIT 8 - 15 : Lower 8 bits of Number of erase units
+ BIT 0 - 7 : Not Used
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ */
+#define CY_RQT_ERASE (19)
+
+/* Summary
+ This command reads 1 byte from an SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 23
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ D1
+ Bits 8 - 15 : 0
+ Bit 7 : 0 to indicate a read
+ Bits 4 - 6 : Function number
+ Bit 3 : 0
+ Bit 2 : 1 if SDIO interrupt needs to be re-enabled.
+ Bits 0 - 1 : Two Most significant bits of Read address
+
+ D2
+ Bits 1 - 15 : 15 Least significant bits of Read address
+ Bit 0 : 0
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ * CY_RESP_SDIO_DIRECT
+*/
+#define CY_RQT_SDIO_READ_DIRECT (23)
+
+/* Summary
+ This command writes 1 byte to an SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 24
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ D1
+ Bits 8 - 15 : Data to write
+ Bit 7 : 1 to indicate a write
+ Bits 4 - 6 : Function number
+ Bit 3 : 1 if Read after write is enabled
+ Bit 2 : 1 if SDIO interrupt needs to be re-enabled.
+ Bits 0 - 1 : Two Most significant bits of write address
+
+ D2
+ Bits 1 - 15 : 15 Least significant bits of write address
+ Bit 0 : 0
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SDIO_DIRECT
+*/
+#define CY_RQT_SDIO_WRITE_DIRECT (24)
+
+/* Summary
+ This command reads performs a multi block/byte read from
+ an SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 25
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ D1
+ Bit 15 : 0 to indicate a read
+ Bit 12 - 14 : Function Number
+ Bit 11 : Block Mode
+ Bit 10 : OpCode
+ Bits 0 - 9 : 10 Most significant bits of Read address
+
+ D2
+ Bits 9 - 15 : 7 Least significant bits of address
+ Bits 0 - 8 : Block/Byte Count
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SDIO_EXT
+*/
+#define CY_RQT_SDIO_READ_EXTENDED (25)
+
+/* Summary
+ This command reads performs a multi block/byte write
+ to an SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 26
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ D1
+ Bit 15 : 1 to indicate a write
+ Bit 12 - 14 : Function Number
+ Bit 11 : Block Mode
+ Bit 10 : OpCode
+ Bits 0 - 9 : 10 Most significant bits of Read address
+
+ D2
+ Bits 9 - 15 : 7 Least significant bits of address
+ Bits 0 - 8 : Block/Byte Count
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SDIO_EXT
+*/
+#define CY_RQT_SDIO_WRITE_EXTENDED (26)
+
+/* Summary
+ This command initialises an IO function on the SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 27
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SDIO_INIT_FUNCTION (27)
+
+/* Summary
+ This command gets properties of the SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 28
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_QUERY_CARD
+*/
+#define CY_RQT_SDIO_QUERY_CARD (28)
+
+/* Summary
+ This command reads a tuple from the CIS of an SDIO card.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 29
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ D1
+ Bits 8 - 15 : Tuple ID to read
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SDIO_GET_TUPLE
+*/
+#define CY_RQT_SDIO_GET_TUPLE (29)
+
+/* Summary
+ This command Aborts an IO operation.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 30
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SDIO_ABORT_IO (30)
+
+/* Summary
+ SDIO Interrupt request sent to the processor from the West Bridge device.
+
+ Direction
+ West Bridge ->P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 31
+
+ D0
+ Bits 0 - 7 : Bus Index
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SDIO_INTR (31)
+
+/* Summary
+ This command Suspends an IO operation.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 32
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SDIO_SUSPEND (32)
+
+/* Summary
+ This command resumes a suspended operation.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 33
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based function number
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SDIO_RESUME
+*/
+#define CY_RQT_SDIO_RESUME (33)
+
+/* Summary
+ This command resets an SDIO device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request Code = 34
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : 0
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SDIO_RESET_DEV (34)
+
+/* Summary
+ This command asks the API to start the DMA transfer
+ for a P2S operation.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Request code = 35
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_P2S_DMA_START (35)
+
+/******************************************************/
+
+/*@@Storage responses
+ Summary
+ The storage responses include:
+ * CY_RESP_MEDIA_CLAIMED_RELEASED
+ * CY_RESP_MEDIA_DESCRIPTOR
+ * CY_RESP_DEVICE_DESCRIPTOR
+ * CY_RESP_UNIT_DESCRIPTOR
+ * CY_RESP_ANTIOCH_DEFERRED_ERROR
+ * CY_RESP_SD_REGISTER_DATA
+ * CY_RESP_SD_LOCK_STATUS
+ * CY_RESP_BUS_DESCRIPTOR
+ * CY_RESP_TRANSFER_COUNT
+ * CY_RESP_SDIO_EXT
+ * CY_RESP_SDIO_INIT_FUNCTION
+ * CY_RESP_SDIO_QUERY_CARD
+ * CY_RESP_SDIO_GET_TUPLE
+ * CY_RESP_SDIO_DIRECT
+ * CY_RESP_SDIO_INVALID_FUNCTION
+ * CY_RESP_SDIO_RESUME
+ */
+
+/* Summary
+ Based on the request sent, the state of a given media was
+ changed as indicated by this response.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Response Code = 16
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+
+ D1
+ State of Media
+ * 0 = released
+ * 1 = claimed
+ */
+#define CY_RESP_MEDIA_CLAIMED_RELEASED (16)
+
+
+/* Summary
+ This response gives the number of physical devices
+ associated with a given media type.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Response Code = 17
+
+ D0
+ Media Type
+ Bits 12 - 15
+ * 0 = NAND
+ * 1 = SDIO Flash
+ * 2 = MMC Flash
+ * 3 = CE-ATA
+
+ D1
+ Number of devices
+ */
+#define CY_RESP_MEDIA_DESCRIPTOR (17)
+
+
+/* Summary
+ This response gives description of a physical device.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 2
+ * Response Code = 18
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Type of media present on bus
+
+ D1
+ Block Size in bytes
+
+ D2
+ Bit 15 : Is device removable
+ Bit 9 : Is device password locked
+ Bit 8 : Is device writeable
+ Bits 0 - 7 : Number Of Units
+
+ D3
+ ERASE_UNIT_SIZE high 16 bits
+
+ D4
+ ERASE_UNIT_SIZE low 16 bits
+
+ */
+#define CY_RESP_DEVICE_DESCRIPTOR (18)
+
+
+/* Summary
+ This response gives description of a unit on a
+ physical device.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 6
+
+ MailBox0
+ * Context = 2
+ * Response Code = 19
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ D1
+ Bits 0 - 7 : Media type
+ * 1 = NAND
+ * 2 = SD FLASH
+ * 4 = MMC FLASH
+ * 8 = CEATA
+ * 16 = SD IO
+
+ D2
+ Block Size in bytes
+
+ D3
+ Start Block Low 16 bits
+
+ D4
+ Start Block High 16 bits
+
+ D5
+ Unit Size Low 16 bits
+
+ D6
+ Unit Size High 16 bits
+ */
+#define CY_RESP_UNIT_DESCRIPTOR (19)
+
+
+/* Summary
+ This response is sent as error status for P2S
+ Storage operation.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 2
+ * Request Code = 20
+
+ D0
+ Bit 8 : Type of operation (Read / Write)
+ Bits 7 - 0 : Error code
+
+ D1
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Zero based unit index
+
+ *D2 - D3*
+ Address where the error occurred.
+
+ D4
+ Length of the operation in blocks.
+
+ Description
+ This error is returned by the West Bridge to the
+ processor if a storage operation fails due to a
+ medium error.
+*/
+#define CY_RESP_ANTIOCH_DEFERRED_ERROR (20)
+
+/* Summary
+ Contents of a register on the SD/MMC card connected to
+ West Bridge.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ Variable
+
+ Mailbox0
+ * Context = 2
+ * Request code = 21
+
+ D0
+ Length of data in bytes
+
+ D1 - Dn
+ The register contents
+
+ Description
+ This is the response to a CY_RQT_SD_REGISTER_READ
+ request.
+*/
+#define CY_RESP_SD_REGISTER_DATA (21)
+
+/* Summary
+ Status of whether the SD card is password locked.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 22
+
+ D0
+ Bit 0 : The card's lock status
+
+ Description
+ Status of whether the SD card is password locked.
+*/
+#define CY_RESP_SD_LOCK_STATUS (22)
+
+
+/* Summary
+ This response gives the types of physical devices
+ attached to a given bus.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 2
+ * Response Code = 23
+
+ D0
+ Bus Number
+ Bits 12 - 15
+
+ D1
+ Media present on addressed bus
+ */
+#define CY_RESP_BUS_DESCRIPTOR (23)
+
+/* Summary
+ Amount of data read/written through the USB mass
+ storage/MTP device.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 2
+ * Request code = 24
+
+ D0
+ MS 16 bits of number of sectors written
+
+ D1
+ LS 16 bits of number of sectors written
+
+ D2
+ MS 16 bits of number of sectors read
+
+ D3
+ LS 16 bits of number of sectors read
+
+ Description
+ This is the response to the CY_RQT_GET_TRANSFER_AMOUNT
+ request, and represents the number of sectors of data
+ that has been written to or read from the storage device
+ through the USB Mass storage or MTP interface.
+ */
+#define CY_RESP_TRANSFER_COUNT (24)
+
+/* Summary
+ Status of SDIO Extended read/write operation.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 34
+
+ D0
+ Bit 8 : 1 if Read response, 0 if write response
+ Bits 0-7: Error Status
+
+ Description
+ Status of SDIO Extended read write operation.
+*/
+
+#define CY_RESP_SDIO_EXT (34)
+
+/* Summary
+ Status of SDIO operation to Initialize a function
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 2
+ * Request code = 35
+
+
+ D0
+ Bits 8-15 : Function Interface Code
+ Bits 0-7: Extended Function Interface Code
+
+ D1
+ Bits 0-15 : Function Block Size
+
+ D2
+ Bits 0-15 : Most significant Word of Function PSN
+
+ D3
+ Bits 0-15 : Least significant Word of Function PSN
+
+ D4
+ Bit 15 : CSA Enabled Status
+ Bit 14 : CSA Support Status
+ Bit 9 : CSA No Format Status
+ Bit 8 : CSA Write Protect Status
+ Bit 0 : Function Wake Up Support status
+
+ Description
+ Status of SDIO Function Initialization operation.
+*/
+#define CY_RESP_SDIO_INIT_FUNCTION (35)
+
+/* Summary
+ Status of SDIO operation to query the Card
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 2
+ * Request code = 36
+
+
+ D0
+ Bits 8-15 : Number of IO functions present
+ Bit 0: 1 if memory is present
+
+ D1
+ Bits 0-15 : Card Manufacturer ID
+
+ D2
+ Bits 0-15 : Card Manufacturer Additional Information
+
+ D3
+ Bits 0-15 : Function 0 Block Size
+
+ D4
+ Bits 8-15 :SDIO Card Capability register
+ Bits 0-7: SDIO Version
+
+
+ Description
+ Status of SDIO Card Query operation.
+ */
+#define CY_RESP_SDIO_QUERY_CARD (36)
+/* Summary
+ Status of SDIO CIS read operation
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 37
+
+ D0
+ Bit 8 : 1
+ Bits 0-7: Error Status
+
+ D1
+ Bits 0 - 7 : Size of data read.
+
+ Description
+ Status of SDIO Get Tuple Read operation.
+ */
+#define CY_RESP_SDIO_GET_TUPLE (37)
+
+/* Summary
+ Status of SDIO Direct read/write operation.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 38
+
+ D0
+ Bit 8 : Error Status
+ Bits 0-7: Data Read(If any)
+
+ Description
+ Status of SDIO Direct read write operation.
+
+*/
+#define CY_RESP_SDIO_DIRECT (38)
+
+/* Summary
+ Indicates an un-initialized function has been used for IO
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 39
+
+ Description
+ Indicates an IO request on an uninitialized function.
+*/
+#define CY_RESP_SDIO_INVALID_FUNCTION (39)
+
+/* Summary
+ Response to a Resume request
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 2
+ * Request code = 40
+
+ D0
+ Bits 8-15 : Error Status
+ Bit 0: 1 if data is available. 0 otherwise.
+
+ Description
+ Response to a Resume request. Indicates if data is
+ available after resum or not.
+*/
+#define CY_RESP_SDIO_RESUME (40)
+
+/******************************************************/
+
+/*@@USB requests
+ Summary
+ The USB requests include:
+ * CY_RQT_START_USB
+ * CY_RQT_STOP_USB
+ * CY_RQT_SET_CONNECT_STATE
+ * CY_RQT_GET_CONNECT_STATE
+ * CY_RQT_SET_USB_CONFIG
+ * CY_RQT_GET_USB_CONFIG
+ * CY_RQT_STALL_ENDPOINT
+ * CY_RQT_GET_STALL
+ * CY_RQT_SET_DESCRIPTOR
+ * CY_RQT_GET_DESCRIPTOR
+ * CY_RQT_SET_USB_CONFIG_REGISTERS
+ * CY_RQT_USB_EVENT
+ * CY_RQT_USB_EP_DATA
+ * CY_RQT_ENDPOINT_SET_NAK
+ * CY_RQT_GET_ENDPOINT_NAK
+ * CY_RQT_ACK_SETUP_PACKET
+ * CY_RQT_SCSI_INQUIRY_COMMAND
+ * CY_RQT_SCSI_START_STOP_COMMAND
+ * CY_RQT_SCSI_UNKNOWN_COMMAND
+ * CY_RQT_USB_REMOTE_WAKEUP
+ * CY_RQT_CLEAR_DESCRIPTORS
+ * CY_RQT_USB_STORAGE_MONITOR
+ * CY_RQT_USB_ACTIVITY_UPDATE
+ * CY_RQT_MS_PARTITION_SELECT
+ */
+#ifndef __doxygen__
+#define CY_RQT_USB_RQT_CONTEXT (3)
+#endif
+
+/* Summary
+ This command requests initialization of the USB stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 0
+
+ Description
+ This command is required before any other USB related command can be
+ sent to the West Bridge firmware.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_ALREADY_RUNNING
+ */
+#define CY_RQT_START_USB (0)
+
+
+/* Summary
+ This command requests shutdown of the USB stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 1
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_STOP_USB (1)
+
+
+/* Summary
+ This command requests that the USB pins be connected
+ or disconnected to/from the West Bridge device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 2
+
+ D0
+ Desired Connect State
+ * 0 = DISCONNECTED
+ * 1 = CONNECTED
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_SET_CONNECT_STATE (2)
+
+
+/* Summary
+ This command requests the connection state of the
+ West Bridge USB pins.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 3
+
+ Responses
+ * CY_RESP_CONNECT_STATE
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_GET_CONNECT_STATE (3)
+
+
+/* Summary
+ This request configures the USB subsystem.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 3
+ * Request Code = 4
+
+ D0
+ Bits 8 - 15: Media to enumerate (bit mask)
+ Bits 0 - 7: Enumerate Mass Storage (bit mask)
+ * 1 = Enumerate device on bus 0
+ * 2 = Enumerate device on bus 1
+
+ D1
+ Enumeration Methodology
+ * 1 = West Bridge enumeration
+ * 0 = P Port enumeration
+
+ D2
+ Mass storage interface number - Interface number to
+ be used for the mass storage interface
+
+ D3
+ Mass storage callbacks
+ * 1 = relay to P port
+ * 0 = completely handle in firmware
+
+ Description
+ This indicates how enumeration should be handled.
+ Enumeration can be handled by the West Bridge device
+ or by the P port processor.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_INVALID_MASK
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_INVALID_STORAGE_MEDIA
+ */
+#define CY_RQT_SET_USB_CONFIG (4)
+
+
+/* Summary
+ This request retrieves the current USB configuration from
+ the West Bridge device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 5
+
+ Responses
+ * CY_RESP_USB_CONFIG
+ */
+#define CY_RQT_GET_USB_CONFIG (5)
+
+
+/* Summary
+ This request stalls the given endpoint.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 6
+
+ D0
+ Endpoint Number
+
+ D1
+ * 1 = Stall Endpoint
+ * 0 = Clear Stall
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_INVALID_ENDPOINT
+ */
+#define CY_RQT_STALL_ENDPOINT (6)
+
+
+/* Summary
+ This request retrieves the stall status of the
+ requested endpoint.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 7
+
+ D0
+ Endpoint number
+
+ Responses
+ * CY_RESP_ENDPOINT_STALL
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_INVALID_ENDPOINT
+ */
+#define CY_RQT_GET_STALL (7)
+
+
+/* Summary
+ This command sets the contents of a descriptor.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 8
+
+ D0
+ Bit 15 - Bit 8
+ Descriptor Index
+
+ Bit 7 - Bit 0
+ Descriptor Type
+ * Device = 1
+ * Device Qualifier = 2
+ * Full Speed Configuration = 3
+ * High Speed Configuration = 4
+
+ * D1 - DN *
+ Actual data for the descriptor
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_TYPE
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_INDEX
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_LENGTH
+ */
+#define CY_RQT_SET_DESCRIPTOR (8)
+
+/* Summary
+ This command gets the contents of a descriptor.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 9
+
+ D0
+ Bit 15 - Bit 8
+ Descriptor Index
+
+ Bit 7 - Bit 0
+ Descriptor Type
+ * Device = 1
+ * Device Qualifier = 2
+ * Full Speed Configuration = 3
+ * High Speed Configuration = 4
+
+ Responses
+ * CY_RESP_USB_DESCRIPTOR
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_TYPE
+ * CY_RESP_SUCCESS_FAILURE:CY_ERR_BAD_INDEX
+ */
+#define CY_RQT_GET_DESCRIPTOR (9)
+
+/* Summary
+ This request is sent from the P port processor to the
+ West Bridge device to physically configure the endpoints
+ in the device.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 3
+
+ MailBox0
+ * Context = 3
+ * Request Code = 10
+
+ D0
+ Bit 15 - Bit 8
+ EP1OUTCFG register value
+ Bit 7 - Bit 0
+ EP1INCFG register value
+
+ * D1 - D2 *
+ PEPxCFS register values where x = 3, 5, 7, 9
+
+ * D3 - D7 *
+ LEPxCFG register values where x = 3, 5, 7, 9, 10,
+ 11, 12, 13, 14, 15
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_SET_USB_CONFIG_REGISTERS (10)
+
+/* Summary
+ This request is sent to the P port processor when a
+ USB event occurs and needs to be relayed to the
+ P port.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Request Code = 11
+
+ D0
+ Event Type
+ * 0 = Reserved
+ * 1 = Reserved
+ * 2 = USB Suspend
+ * 3 = USB Resume
+ * 4 = USB Reset
+ * 5 = USB Set Configuration
+ * 6 = USB Speed change
+
+ D1
+ If EventTYpe is USB Speed change
+ * 0 = Full Speed
+ * 1 = High Speed
+
+ If EventType is USB Set Configuration
+ * The number of the configuration to use
+ * (may be zero to unconfigure)
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_USB_EVENT (11)
+
+/* Summary
+ This request is sent in both directions to transfer
+ endpoint data for endpoints 0 and 1.
+
+ Direction
+ West Bridge -> P Port Processor
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ Variable
+
+ Mailbox0
+ * Context = 3
+ * Request Code = 12
+
+ D0
+ Bit 15 - 14 Data Type
+ * 0 = Setup (payload should be the 8 byte setup packet)
+ * 1 = Data
+ * 2 = Status (payload should be empty)
+
+ Bit 13 Endpoint Number (only 0 and 1 supported)
+ Bit 12 First Packet (only supported for Host ->
+ West Bridge traffic)
+ Bit 11 Last Packet (only supported for Host ->
+ West Bridge traffic)
+
+ Bit 9 - 0 Data Length (real max data length is 64 bytes
+ for EP0 and EP1)
+
+ *D1-Dn*
+ Endpoint data
+*/
+#define CY_RQT_USB_EP_DATA (12)
+
+
+/* Summary
+ This request sets the NAK bit on an endpoint.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 13
+
+ D0
+ Endpoint Number
+
+ D1
+ * 1 = NAK Endpoint
+ * 0 = Clear NAK
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_INVALID_ENDPOINT
+ */
+#define CY_RQT_ENDPOINT_SET_NAK (13)
+
+
+/* Summary
+ This request retrieves the NAK config status of the
+ requested endpoint.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Request Code = 14
+
+ D0
+ Endpoint number
+
+ Responses
+ * CY_RESP_ENDPOINT_NAK
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_INVALID_ENDPOINT
+ */
+#define CY_RQT_GET_ENDPOINT_NAK (14)
+
+/* Summary
+ This request acknowledges a setup packet that does not
+ require any data transfer.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox
+ * Context = 3
+ * Request Code = 15
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_ACK_SETUP_PACKET (15)
+
+/* Summary
+ This request is sent when the USB storage driver within
+ West Bridge receives an Inquiry request.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ x - variable
+
+ Mailbox0
+ * Context = 3
+ * Request Code = 16
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Media type being addressed
+
+ D1
+ Bits 8 : EVPD bit from request
+ Bits 0 - 7 : Codepage from the inquiry request
+
+ D2
+ Length of the inquiry response in bytes
+
+ * D3 - Dn *
+ The inquiry response
+
+ Description
+ When the West Bridge firmware receives an SCSI Inquiry
+ request from the USB host, the response to this mass
+ storage command is created by West Bridge and forwarded to
+ the P port processor. The P port processor may change
+ this response before it is returned to the USB host. This
+ request is the method by which this may happen.
+*/
+#define CY_RQT_SCSI_INQUIRY_COMMAND (16)
+
+/* Summary
+ This request is sent when the USB storage driver within
+ West Bridge receives a Start/Stop request.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Request Code = 17
+
+ D0
+ Bits 12 - 15 : Bus index
+ Bits 8 - 11 : Zero based device index
+ Bits 0 - 7 : Media type being addressed
+
+ D1
+ Bit 1
+ * LoEj Bit (See SCSI-3 specification)
+
+ Bit 0
+ * Start Bit (See SCSI-3 specification)
+
+ Description
+ When the West Bridge firmware received a SCSI Start/Stop
+ request from the USB host, this request is relayed to the
+ P port processor. This request is used to relay the command.
+ The USB firmware will not response to the USB command until
+ the response to this request is recevied by the firmware.
+*/
+#define CY_RQT_SCSI_START_STOP_COMMAND (17)
+
+/* Summary
+ This request is sent when the USB storage driver
+ receives an unknown CBW on mass storage.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 4
+
+ Mailbox0
+ * Context = 3
+ * Request Code = 18
+
+ D0
+ Bits 12 - 15 : MediaType
+ * 0 = NAND
+ * 1 = SDIO Flash
+ * 2 = MMC Flash
+ * 3 = CE-ATA
+
+ D1
+ The length of the request in bytes
+
+ D2 - Dn
+ CBW command block from the SCSI host controller.
+
+ Description
+ When the firmware recevies a SCSI request that is not
+ understood, this request is relayed to the
+ P port processor.
+*/
+#define CY_RQT_SCSI_UNKNOWN_COMMAND (18)
+
+/* Summary
+ Request the West Bridge to signal remote wakeup
+ to the USB host.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Request code = 19
+
+ Description
+ Request from the processor to West Bridge, to signal
+ remote wakeup to the USB host.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_USB_REMOTE_WAKEUP (19)
+
+/* Summary
+ Request the West Bridge to clear all descriptors tha
+ were set previously
+ using the Set Descriptor calls.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Request code = 20
+
+ Description
+ Request from the processor to West Bridge, to clear
+ all descriptor information that was previously stored
+ on the West Bridge using CyAnUsbSetDescriptor calls.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_CLEAR_DESCRIPTORS (20)
+
+/* Summary
+ Request the West Bridge to monitor USB to storage activity
+ and send periodic updates.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 3
+ * Request code = 21
+
+ D0
+ Upper 16 bits of write threshold
+
+ D1
+ Lower 16 bits of write threshold
+
+ D2
+ Upper 16 bits of read threshold
+
+ D3
+ Lower 16 bits of read threshold
+
+ Description
+ Request from the processor to West Bridge, to start
+ monitoring the level of read/write activity on the
+ USB mass storage drive and to set the threshold
+ level at which progress reports are sent.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_USB_STORAGE_MONITOR (21)
+
+/* Summary
+ Event from the West Bridge showing that U2S activity
+ since the last event has crossed the threshold.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 3
+ * Request code = 22
+
+ D0
+ Upper 16 bits of sectors written since last event.
+
+ D1
+ Lower 16 bits of sectors written since last event.
+
+ D2
+ Upper 16 bits of sectors read since last event.
+
+ D3
+ Lower 16 bits of sectors read since last event.
+
+ Description
+ Event notification from the West Bridge indicating
+ that the number of read/writes on the USB mass
+ storage device have crossed a pre-defined threshold
+ level.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_USB_ACTIVITY_UPDATE (22)
+
+/* Summary
+ Request to select the partitions to be enumerated on a
+ storage device with partitions.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Request code = 23
+
+ D0
+ Bits 8-15 : Bus index
+ Bits 0- 7 : Device index
+
+ D1
+ Bits 8-15 : Control whether to enumerate partition 1.
+ Bits 0- 7 : Control whether to enumerate partition 0.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE
+ */
+#define CY_RQT_MS_PARTITION_SELECT (23)
+
+/************/
+
+/*@@USB responses
+ Summary
+ The USB responses include:
+ * CY_RESP_USB_CONFIG
+ * CY_RESP_ENDPOINT_CONFIG
+ * CY_RESP_ENDPOINT_STALL
+ * CY_RESP_CONNECT_STATE
+ * CY_RESP_USB_DESCRIPTOR
+ * CY_RESP_USB_INVALID_EVENT
+ * CY_RESP_ENDPOINT_NAK
+ * CY_RESP_INQUIRY_DATA
+ * CY_RESP_UNKNOWN_SCSI_COMMAND
+ */
+
+/* Summary
+ This response contains the enumeration configuration
+ information for the USB module.
+
+ Direction
+ 8051->P
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Response Code = 32
+
+ D0
+ Bits 8 - 15: Media to enumerate (bit mask)
+ Bits 0 - 7: Buses to enumerate (bit mask)
+ * 1 = Bus 0
+ * 2 = Bus 1
+
+ D1
+ Enumeration Methodology
+ * 0 = West Bridge enumeration
+ * 1 = P Port enumeration
+
+ D2
+ Bits 7 - 0 : Interface Count - the number of interfaces
+ Bits 15 - 8 : Mass storage callbacks
+
+ */
+#define CY_RESP_USB_CONFIG (32)
+
+
+/* Summary
+ This response contains the configuration information
+ for the specified endpoint.
+
+ Direction
+ 8051->P
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Response Code = 33
+
+ D0
+ Bits 15 - 12 : Endpoint Number (0 - 15)
+
+ Bits 11 - 10 : Endpoint Type
+ * 0 = Control
+ * 1 = Bulk
+ * 2 = Interrupt
+ * 3 = Isochronous
+
+ Bits 9 : Endpoint Size
+ * 0 = 512
+ * 1 = 1024
+
+ Bits 8 - 7 : Buffering
+ * 0 = Double
+ * 1 = Triple
+ * 2 = Quad
+
+ Bits 6 : Bit Direction
+ * 0 = Input
+ * 1 = Output
+ */
+#define CY_RESP_ENDPOINT_CONFIG (33)
+
+
+/* Summary
+ This response contains the stall status for
+ the specified endpoint.
+
+ Direction
+ 8051->P
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Response Code = 34
+
+ D0
+ Stall status
+ * 0 = Active
+ * 1 = Stalled
+ */
+#define CY_RESP_ENDPOINT_STALL (34)
+
+
+/* Summary
+ This response contains the connected/disconnected
+ state of the West Bridge USB pins.
+
+ Direction
+ 8051->P
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 3
+ * Response Code = 35
+
+ D0
+ Connect state
+ * 0 = Disconnected
+ * 1 = Connected
+ */
+#define CY_RESP_CONNECT_STATE (35)
+
+/* Summary
+ This response contains the information
+ about the USB configuration
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length
+ x bytes
+
+ Mailbox0
+ * Context = 3
+ * Response Code = 36
+
+ D0
+ Length in bytes of the descriptor
+
+ * D1 - DN *
+ Descriptor contents
+*/
+#define CY_RESP_USB_DESCRIPTOR (36)
+
+/* Summary
+ This response is sent in response to a bad USB event code
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length
+ 1 word (2 bytes)
+
+ Mailbox0
+ * Context = 3
+ * Response Code = 37
+
+ D0
+ The invalid event code in the request
+*/
+#define CY_RESP_USB_INVALID_EVENT (37)
+
+/* Summary
+ This response contains the current NAK status of
+ a USB endpoint.
+
+ Direction
+ West Bridge -> P port processor
+
+ Length
+ 1 transfer
+
+ Mailbox0
+ * Context = 3
+ * Response Code = 38
+
+ D0
+ The NAK status of the endpoint
+ 1 : NAK bit set
+ 0 : NAK bit clear
+*/
+#define CY_RESP_ENDPOINT_NAK (38)
+
+/* Summary
+ This response gives the contents of the inquiry
+ data back to West Bridge to returns to the USB host.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length
+ Variable
+
+ MailBox0
+ * Context = 3
+ * Response Code = 39
+
+ D0
+ Length of the inquiry response
+
+ *D1 - Dn*
+ Inquiry data
+*/
+#define CY_RESP_INQUIRY_DATA (39)
+
+/* Summary
+ This response gives the status of an unknown SCSI command.
+ This also gives three bytes of sense information.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 3
+ * Response Code = 40
+
+ D0
+ The length of the reply in bytes
+
+ D1
+ * Status of the command
+ * Sense Key
+
+ D2
+ * Additional Sense Code (ASC)
+ * Additional Sense Code Qualifier (ASCQ)
+*/
+#define CY_RESP_UNKNOWN_SCSI_COMMAND (40)
+/*******************************************************/
+
+/*@@Turbo requests
+ Summary
+ The Turbo requests include:
+ * CY_RQT_START_MTP
+ * CY_RQT_STOP_MTP
+ * CY_RQT_INIT_SEND_OBJECT
+ * CY_RQT_CANCEL_SEND_OBJECT
+ * CY_RQT_INIT_GET_OBJECT
+ * CY_RQT_CANCEL_GET_OBJECT
+ * CY_RQT_SEND_BLOCK_TABLE
+ * CY_RQT_MTP_EVENT
+ * CY_RQT_TURBO_CMD_FROM_HOST
+ * CY_RQT_TURBO_SEND_RESP_DATA_TO_HOST
+ * CY_RQT_TURBO_SWITCH_ENDPOINT
+ * CY_RQT_TURBO_START_WRITE_DMA
+ * CY_RQT_ENABLE_USB_PATH
+ * CY_RQT_CANCEL_ASYNC_TRANSFER
+ */
+#ifndef __doxygen__
+#define CY_RQT_TUR_RQT_CONTEXT (4)
+#endif
+
+/* Summary
+ This command requests initialization of the MTP stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 0
+
+ Description
+ This command is required before any other MTP related
+ command can be sent to the West Bridge firmware.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_ALREADY_RUNNING
+ */
+#define CY_RQT_START_MTP (0)
+
+/* Summary
+ This command requests shutdown of the MTP stack.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 1
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_STOP_MTP (1)
+
+/* Summary
+ This command sets up an MTP SendObject operation.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 2
+
+ D0
+ Total bytes for send object Low 16 bits
+
+ D1
+ Total bytes for send object High 16 bits
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_INIT_SEND_OBJECT (2)
+
+/* Summary
+ This command cancels West Bridges handling of
+ an ongoing MTP SendObject operation. This
+ does NOT send an MTP response.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 3
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_NO_OPERATION_PENDING
+ */
+#define CY_RQT_CANCEL_SEND_OBJECT (3)
+
+/* Summary
+ This command sets up an MTP GetObject operation.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 4
+ * Request Code = 4
+
+ D0
+ Total bytes for get object Low 16 bits
+
+ D1
+ Total bytes for get object High 16 bits
+
+ D2
+ Transaction Id for get object Low 16 bits
+
+ D3
+ Transaction Id for get object High 16 bits
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_INIT_GET_OBJECT (4)
+
+/* Summary
+ This command notifies West Bridge of a new
+ BlockTable transfer.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 5
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_SEND_BLOCK_TABLE (5)
+
+/* Summary
+ This request is sent to the P port processor when a MTP event occurs
+ and needs to be relayed to the P port.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 4
+ * Request Code = 6
+
+ D0
+ Bits 15 - 8 : Return Status for GetObject/SendObject
+ Bits 7 - 0 : Event Type
+ * 0 = MTP SendObject Complete
+ * 1 = MTP GetObject Complete
+ * 2 = BlockTable Needed
+
+ D1
+ Lower 16 bits of the length of the data that got transferred
+ in the Turbo Endpoint.(Applicable to "MTP SendObject Complete"
+ and "MTP GetObject Complete" events)
+
+ D2
+ Upper 16 bits of the length of the data that got transferred
+ in the Turbo Endpoint. (Applicable to "MTP SendObject Complete"
+ and "MTP GetObject Complete" events)
+
+ D3
+ Lower 16 bits of the Transaction Id of the MTP_SEND_OBJECT
+ command. (Applicable to "MTP SendObject Complete" event)
+
+ D4
+ Upper 16 bits of the Transaction Id of the MTP_SEND_OBJECT
+ command. (Applicable to "MTP SendObject Complete" event)
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_MTP_EVENT (6)
+
+/* Summary
+ This request is sent to the P port processor when a command
+ is received from Host in a Turbo Endpoint. Upon receiving
+ this event, P port should read the data from the endpoint as
+ soon as possible.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 4
+ * Request Code = 7
+
+ D0
+ This contains the EP number. (This will be always two now).
+
+ D1
+ Length of the data available in the Turbo Endpoint.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_TURBO_CMD_FROM_HOST (7)
+
+/* Summary
+ This request is sent to the West Bridge when the P port
+ needs to send data to the Host in a Turbo Endpoint.
+ Upon receiving this event, Firmware will make the end point
+ avilable for the P port. If the length is zero, then
+ firmware will send a zero length packet.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ Mailbox0
+ * Context = 4
+ * Request Code = 8
+
+ D0
+ This contains the EP number. (This will be always six now).
+
+ D1
+ Lower 16 bits of the length of the data that needs to be
+ sent in the Turbo Endpoint.
+
+ D2
+ Upper 16 bits of the length of the data that needs to be
+ sent in the Turbo Endpoint.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+*/
+#define CY_RQT_TURBO_SEND_RESP_DATA_TO_HOST (8)
+
+/* Summary
+ This command cancels West Bridges handling of
+ an ongoing MTP GetObject operation. This
+ does NOT send an MTP response.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 9
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_NO_OPERATION_PENDING
+ */
+#define CY_RQT_CANCEL_GET_OBJECT (9)
+
+/* Summary
+ This command switches a Turbo endpoint
+ from the U port to the P port. If no data
+ is in the endpoint the endpoint is
+ primed to switch as soon as data is placed
+ in the endpoint. The endpoint will continue
+ to switch until all data has been transferd.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 2
+
+ MailBox0
+ * Context = 4
+ * Request Code = 10
+
+ D0
+ Whether the read is a packet read.
+
+ D1
+ Lower 16 bits of the length of the data to switch
+ the Turbo Endpoint for.
+
+ D2
+ Upper 16 bits of the length of the data to switch
+ the Turbo Endpoint for.
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ * CY_RESP_SUCCESS_FAILURE:CY_RESP_NOT_RUNNING
+ */
+#define CY_RQT_TURBO_SWITCH_ENDPOINT (10)
+
+/* Summary
+ This command requests the API to start the DMA
+ transfer of a packet of MTP data to the Antioch.
+
+ Direction
+ West Bridge -> P Port Processor
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request Code = 11
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ */
+#define CY_RQT_TURBO_START_WRITE_DMA (11)
+
+/* Summary
+ This command requests the firmware to switch the
+ internal data paths to enable USB access to the
+ Mass storage / MTP endpoints.
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ MailBox0
+ * Context = 4
+ * Request code = 12
+
+ Responses
+ * CY_RESP_SUCCESS_FAILURE:CY_AS_ERROR_SUCCESS
+ */
+#define CY_RQT_ENABLE_USB_PATH (12)
+
+/* Summary
+ Request to cancel an asynchronous MTP write from
+ the processor side.
+
+ Direction
+ P Port processor -> West Bridge
+
+ Length (in transfers)
+ 1
+
+ Mailbox0
+ * Context = 4
+ * Request code = 13
+
+ D0
+ * EP number
+
+ Description
+ This is a request to the firmware to update internal
+ state so that a pending write on the MTP endpoint
+ can be cancelled.
+ */
+#define CY_RQT_CANCEL_ASYNC_TRANSFER (13)
+
+/******************************************************/
+
+/*@@Turbo responses
+ Summary
+ The Turbo responses include:
+ * CY_RESP_MTP_INVALID_EVENT
+ */
+
+/* Summary
+ This response is sent in response to a bad MTP event code
+
+ Direction
+ P Port Processor -> West Bridge
+
+ Length
+ 1 word (2 bytes)
+
+ Mailbox0
+ * Context = 4
+ * Response Code = 16
+
+ D0
+ The invalid event code in the request
+*/
+#define CY_RESP_MTP_INVALID_EVENT (16)
+
+#ifndef __doxygen__
+#define CY_RQT_CONTEXT_COUNT (5)
+#endif
+
+#endif /* _INCLUDED_CYASPROTOCOL_H_ */
+
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasregs.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasregs.h
new file mode 100644
index 000000000000..f049d7e32a4b
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasregs.h
@@ -0,0 +1,201 @@
+/* Cypress West Bridge API header file (cyasregs.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASREG_H_
+#define _INCLUDED_CYASREG_H_
+
+#if !defined(__doxygen__)
+
+#define CY_AS_MEM_CM_WB_CFG_ID (0x80)
+#define CY_AS_MEM_CM_WB_CFG_ID_VER_MASK (0x000F)
+#define CY_AS_MEM_CM_WB_CFG_ID_HDID_MASK (0xFFF0)
+#define CY_AS_MEM_CM_WB_CFG_ID_HDID_ANTIOCH_VALUE (0xA100)
+#define CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_FPGA_VALUE (0x6800)
+#define CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_VALUE (0xA200)
+
+
+#define CY_AS_MEM_RST_CTRL_REG (0x81)
+#define CY_AS_MEM_RST_CTRL_REG_HARD (0x0003)
+#define CY_AS_MEM_RST_CTRL_REG_SOFT (0x0001)
+#define CY_AS_MEM_RST_RSTCMPT (0x0004)
+
+#define CY_AS_MEM_P0_ENDIAN (0x82)
+#define CY_AS_LITTLE_ENDIAN (0x0000)
+#define CY_AS_BIG_ENDIAN (0x0101)
+
+#define CY_AS_MEM_P0_VM_SET (0x83)
+#define CY_AS_MEM_P0_VM_SET_VMTYPE_MASK (0x0007)
+#define CY_AS_MEM_P0_VM_SET_VMTYPE_RAM (0x0005)
+#define CY_AS_MEM_P0_VM_SET_VMTYPE_SRAM (0x0007)
+#define CY_AS_MEM_P0_VM_SET_VMTYPE_VMWIDTH (0x0008)
+#define CY_AS_MEM_P0_VM_SET_VMTYPE_FLOWCTRL (0x0010)
+#define CY_AS_MEM_P0_VM_SET_IFMODE (0x0020)
+#define CY_AS_MEM_P0_VM_SET_CFGMODE (0x0040)
+#define CY_AS_MEM_P0_VM_SET_DACKEOB (0x0080)
+#define CY_AS_MEM_P0_VM_SET_OVERRIDE (0x0100)
+#define CY_AS_MEM_P0_VM_SET_INTOVERD (0x0200)
+#define CY_AS_MEM_P0_VM_SET_DRQOVERD (0x0400)
+#define CY_AS_MEM_P0_VM_SET_DRQPOL (0x0800)
+#define CY_AS_MEM_P0_VM_SET_DACKPOL (0x1000)
+
+
+#define CY_AS_MEM_P0_NV_SET (0x84)
+#define CY_AS_MEM_P0_NV_SET_WPSWEN (0x0001)
+#define CY_AS_MEM_P0_NV_SET_WPPOLAR (0x0002)
+
+#define CY_AS_MEM_PMU_UPDATE (0x85)
+#define CY_AS_MEM_PMU_UPDATE_UVALID (0x0001)
+#define CY_AS_MEM_PMU_UPDATE_USBUPDATE (0x0002)
+#define CY_AS_MEM_PMU_UPDATE_SDIOUPDATE (0x0004)
+
+#define CY_AS_MEM_P0_INTR_REG (0x90)
+#define CY_AS_MEM_P0_INTR_REG_MCUINT (0x0020)
+#define CY_AS_MEM_P0_INTR_REG_DRQINT (0x0800)
+#define CY_AS_MEM_P0_INTR_REG_MBINT (0x1000)
+#define CY_AS_MEM_P0_INTR_REG_PMINT (0x2000)
+#define CY_AS_MEM_P0_INTR_REG_PLLLOCKINT (0x4000)
+
+#define CY_AS_MEM_P0_INT_MASK_REG (0x91)
+#define CY_AS_MEM_P0_INT_MASK_REG_MMCUINT (0x0020)
+#define CY_AS_MEM_P0_INT_MASK_REG_MDRQINT (0x0800)
+#define CY_AS_MEM_P0_INT_MASK_REG_MMBINT (0x1000)
+#define CY_AS_MEM_P0_INT_MASK_REG_MPMINT (0x2000)
+#define CY_AS_MEM_P0_INT_MASK_REG_MPLLLOCKINT (0x4000)
+
+#define CY_AS_MEM_MCU_MB_STAT (0x92)
+#define CY_AS_MEM_P0_MCU_MBNOTRD (0x0001)
+
+#define CY_AS_MEM_P0_MCU_STAT (0x94)
+#define CY_AS_MEM_P0_MCU_STAT_CARDINS (0x0001)
+#define CY_AS_MEM_P0_MCU_STAT_CARDREM (0x0002)
+
+#define CY_AS_MEM_PWR_MAGT_STAT (0x95)
+#define CY_AS_MEM_PWR_MAGT_STAT_WAKEUP (0x0001)
+
+#define CY_AS_MEM_P0_RSE_ALLOCATE (0x98)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_SDIOAVI (0x0001)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_SDIOALLO (0x0002)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_NANDAVI (0x0004)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_NANDALLO (0x0008)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_USBAVI (0x0010)
+#define CY_AS_MEM_P0_RSE_ALLOCATE_USBALLO (0x0020)
+
+#define CY_AS_MEM_P0_RSE_MASK (0x9A)
+#define CY_AS_MEM_P0_RSE_MASK_MSDIOBUS_RW (0x0003)
+#define CY_AS_MEM_P0_RSE_MASK_MNANDBUS_RW (0x00C0)
+#define CY_AS_MEM_P0_RSE_MASK_MUSBBUS_RW (0x0030)
+
+#define CY_AS_MEM_P0_DRQ (0xA0)
+#define CY_AS_MEM_P0_DRQ_EP2DRQ (0x0004)
+#define CY_AS_MEM_P0_DRQ_EP3DRQ (0x0008)
+#define CY_AS_MEM_P0_DRQ_EP4DRQ (0x0010)
+#define CY_AS_MEM_P0_DRQ_EP5DRQ (0x0020)
+#define CY_AS_MEM_P0_DRQ_EP6DRQ (0x0040)
+#define CY_AS_MEM_P0_DRQ_EP7DRQ (0x0080)
+#define CY_AS_MEM_P0_DRQ_EP8DRQ (0x0100)
+#define CY_AS_MEM_P0_DRQ_EP9DRQ (0x0200)
+#define CY_AS_MEM_P0_DRQ_EP10DRQ (0x0400)
+#define CY_AS_MEM_P0_DRQ_EP11DRQ (0x0800)
+#define CY_AS_MEM_P0_DRQ_EP12DRQ (0x1000)
+#define CY_AS_MEM_P0_DRQ_EP13DRQ (0x2000)
+#define CY_AS_MEM_P0_DRQ_EP14DRQ (0x4000)
+#define CY_AS_MEM_P0_DRQ_EP15DRQ (0x8000)
+
+#define CY_AS_MEM_P0_DRQ_MASK (0xA1)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP2DRQ (0x0004)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP3DRQ (0x0008)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP4DRQ (0x0010)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP5DRQ (0x0020)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP6DRQ (0x0040)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP7DRQ (0x0080)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP8DRQ (0x0100)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP9DRQ (0x0200)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP10DRQ (0x0400)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP11DRQ (0x0800)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP12DRQ (0x1000)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP13DRQ (0x2000)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP14DRQ (0x4000)
+#define CY_AS_MEM_P0_DRQ_MASK_MEP15DRQ (0x8000)
+
+#define CY_AS_MEM_P0_EP2_DMA_REG (0xA2)
+#define CY_AS_MEM_P0_E_pn_DMA_REG_COUNT_MASK (0x7FF)
+#define CY_AS_MEM_P0_E_pn_DMA_REG_DMAVAL (1 << 12)
+#define CY_AS_MEM_P0_EP3_DMA_REG (0xA3)
+#define CY_AS_MEM_P0_EP4_DMA_REG (0xA4)
+#define CY_AS_MEM_P0_EP5_DMA_REG (0xA5)
+#define CY_AS_MEM_P0_EP6_DMA_REG (0xA6)
+#define CY_AS_MEM_P0_EP7_DMA_REG (0xA7)
+#define CY_AS_MEM_P0_EP8_DMA_REG (0xA8)
+#define CY_AS_MEM_P0_EP9_DMA_REG (0xA9)
+#define CY_AS_MEM_P0_EP10_DMA_REG (0xAA)
+#define CY_AS_MEM_P0_EP11_DMA_REG (0xAB)
+#define CY_AS_MEM_P0_EP12_DMA_REG (0xAC)
+#define CY_AS_MEM_P0_EP13_DMA_REG (0xAD)
+#define CY_AS_MEM_P0_EP14_DMA_REG (0xAE)
+#define CY_AS_MEM_P0_EP15_DMA_REG (0xAF)
+
+#define CY_AS_MEM_IROS_SLB_DATARET (0xC0)
+
+#define CY_AS_MEM_IROS_IO_CFG (0xC1)
+#define CY_AS_MEM_IROS_IO_CFG_GPIODRVST_MASK (0x0003)
+#define CY_AS_MEM_IROS_IO_CFG_GPIOSLEW_MASK (0x0004)
+#define CY_AS_MEM_IROS_IO_CFG_PPIODRVST_MASK (0x0018)
+#define CY_AS_MEM_IROS_IO_CFG_PPIOSLEW_MASK (0x0020)
+#define CY_AS_MEM_IROS_IO_CFG_SSIODRVST_MASK (0x0300)
+#define CY_AS_MEM_IROS_IO_CFG_SSIOSLEW_MASK (0x0400)
+#define CY_AS_MEM_IROS_IO_CFG_SNIODRVST_MASK (0x1800)
+#define CY_AS_MEM_IROS_IO_CFG_SNIOSLEW_MASK (0x2000)
+
+#define CY_AS_MEM_IROS_PLL_CFG (0xC2)
+
+#define CY_AS_MEM_IROS_PXB_DATARET (0xC3)
+
+#define CY_AS_MEM_PLL_LOCK_LOSS_STAT (0xC4)
+#define CY_AS_MEM_PLL_LOCK_LOSS_STAT_PLLSTAT (0x0800)
+
+#define CY_AS_MEM_IROS_SLEEP_CFG (0xC5)
+
+#define CY_AS_MEM_PNAND_CFG (0xDA)
+#define CY_AS_MEM_PNAND_CFG_IOWIDTH_MASK (0x0001)
+#define CY_AS_MEM_PNAND_CFG_IOWIDTH_8BIT (0x0000)
+#define CY_AS_MEM_PNAND_CFG_IOWIDTH_16BIT (0x0001)
+#define CY_AS_MEM_PNAND_CFG_BLKTYPE_MASK (0x0002)
+#define CY_AS_MEM_PNAND_CFG_BLKTYPE_SMALL (0x0002)
+#define CY_AS_MEM_PNAND_CFG_BLKTYPE_LARGE (0x0000)
+#define CY_AS_MEM_PNAND_CFG_EPABYTE_POS (4)
+#define CY_AS_MEM_PNAND_CFG_EPABYTE_MASK (0x0030)
+#define CY_AS_MEM_PNAND_CFG_EPABIT_POS (6)
+#define CY_AS_MEM_PNAND_CFG_EPABIT_MASK (0x00C0)
+#define CY_AS_MEM_PNAND_CFG_LNAEN_MASK (0x0100)
+
+#define CY_AS_MEM_P0_MAILBOX0 (0xF0)
+#define CY_AS_MEM_P0_MAILBOX1 (0xF1)
+#define CY_AS_MEM_P0_MAILBOX2 (0xF2)
+#define CY_AS_MEM_P0_MAILBOX3 (0xF3)
+
+#define CY_AS_MEM_MCU_MAILBOX0 (0xF8)
+#define CY_AS_MEM_MCU_MAILBOX1 (0xF9)
+#define CY_AS_MEM_MCU_MAILBOX2 (0xFA)
+#define CY_AS_MEM_MCU_MAILBOX3 (0xFB)
+
+#endif /* !defined(__doxygen__) */
+
+#endif /* _INCLUDED_CYASREG_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage.h
new file mode 100644
index 000000000000..52d3d688a47c
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage.h
@@ -0,0 +1,2759 @@
+/* Cypress West Bridge API header file (cyasstorage.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASSTORAGE_H_
+#define _INCLUDED_CYASSTORAGE_H_
+
+#include "cyasmedia.h"
+#include "cyasmisc.h"
+#include "cyas_cplus_start.h"
+
+
+/*@@Storage APIs
+ Summary
+ This section documents the storage APIs supported by the
+ West Bridge API.
+
+ Description
+ The storage API is based on some specific concepts which
+ are referenced here.
+ * <LINK Storage API Overview>
+ * Addressing
+ * Ownership
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+
+/*@@Storage API Overview
+ Summary
+ Storage devices are identified by media type. Each media
+ type is considered a single logical device.
+
+ Description
+ Each media type has a consistent block size and consists
+ of a set of logical blocks numbered from 0 to N - 1 where
+ N is the size of the
+ media type in blocks. The mass storage APIs defined below
+ provide the
+ capability to query for devices that are present, and
+ read/write data to/from
+ these devices.
+*/
+
+/*@@Addressing
+ Summary
+ Blocks within a storage device are address by a hierarchal
+ block address. This
+ address consists of the bus number, physical device,
+ logical unit, and finally
+ block address.
+
+ Description
+ While currently only a single device of each media type
+ is supported, the address
+ space reserves space in the future for multiple devices
+ of each type. Therefore
+ the second element of the address is the specific device
+ being addressed within
+ a given device type. For this release of the software,
+ this value will always be
+ zero to address the first device.
+
+ The third element of the address is the logical unit.
+ A device being managed
+ by West Bridge can be partitioned into multiple logical
+ units. This partition
+ information is stored on each device itself. Currently,
+ one of the storage devices
+ managed by West Bridge can be partitioned into two
+ logical units.
+
+ Finally a logical block address is given within the
+ logical unit to address an
+ individual block.
+*/
+
+/*@@Ownership
+ Summary
+ While West Bridge supports concurrent block level
+ operations from both the USB port and
+ the processor port, this is not desirable in most
+ situations as the file system
+ contained on the storage media cannot be accessed
+ concurrently. To insure access
+ by only one of USB and the processor, the West Bridge
+ API provides for ownership of storage
+ devices based on media type.
+
+ Description
+ The processor requests ownership of a given media type
+ by calling CyAsStorageClaim().
+ The firmware in West Bridge releases control of the
+ media and signals the processor through
+ the event callback registered with
+ CyAsStorageRegisterCallback(). The specific event is
+ the CyAsStorageProcessor. The processor can later
+ release the media via a call to
+ CyAsStorageRelease(). This call is immediate and
+ no callback is required.
+
+ If the processor has claimed storage and the USB port
+ is connected, West Bridge will need to
+ claim the storage to manage the mass storage device.
+ West Bridge requests the storage through
+ the event callback registered with
+ CyAsStorageRegisterCallback(). The specific event is
+ CyAsStorageAntioch and is named as such to reflect
+ the USB view of storage. This callback
+ is a request for the processor to release storage.
+ The storage is not actually released
+ until the processor calls CyAsStorageRelease().
+
+ Note that the CyAsStorageAntioch is only sent when the
+ USB storage device is enumerated and
+ NOT at every USB operation. The ownership of a given
+ storage media type is assumed to belong
+ to the processor until the USB connection is established.
+ At that point, the storage ownership
+ is transferred to West Bridge. After the USB connection
+ is broken, ownership can be transferred
+ back to the processor.
+*/
+
+/*@@Asynchronous Versus Synchronous Operation
+ Summary
+ When read or write operations are performed to the
+ storage devices, these operations may be
+ synchronous or asynchronous. A synchronous operation
+ is an operation where the read or write
+ operation is requested and the function does not return
+ until the operation is complete. This
+ type of function is the easiest to use but does not
+ provide for optimal usage of the P port processor time.
+
+ Description
+ An asynchronous operation is one where the function returns
+ as soon as the request is started.
+ The specific read and write request will complete at some
+ time in the future and the P port
+ processor will be notified via a callback function. While
+ asynchronous functions provide for
+ much better usage of the CPU, these function have more
+ stringent requirements for use. First,
+ any buffer use for data transfer must be valid from the
+ function call to request the operation
+ through when the callback function is called. This basically
+ implies that stack based buffers
+ are not acceptable for asynchronous calls. Second, error
+ handling must be deferred until the
+ callback function is called indicating any kind of error
+ that may have occurred.
+*/
+
+/*@@Partitioning
+ Summary
+ West Bridge API and firmware support the creation of up to
+ two logical partitions on one
+ of the storage devices that are managed by West Bridge. The
+ partitions are managed through
+ the CyAsStorageCreatePPartition and CyAsStorageRemovePPartition
+ APIs.
+
+ Description
+ The CyAsStorageCreatePPartition API is used to divide the total
+ storage on a storage
+ device into two logical units or partitions. Since the partition
+ information is stored
+ on the storage device in a custom format, partitions should
+ only be created on fixed
+ storage devices (i.e., no removable SD/MMC cards). Any data
+ stored on the device
+ before the creation of the partition, is liable to be lost when
+ a partition is created.
+
+ The CyAsStorageRemovePPartition API is used to remove the
+ stored partition information,
+ so that all of the device's capacity is treated as a single
+ partition again.
+
+ When a storage device with two partitions (units) is being
+ enumerated as a mass storage
+ device through the West Bridge, it is possible to select the
+ partitions to be made
+ visible to the USB host. This is done through the
+ CyAsUsbSelectMSPartitions API.
+*/
+
+/*********************************
+ * West Bridge Constants
+ **********************************/
+
+/* Summary
+ This constants indicates a raw device access to the read/write
+ functions
+
+ Description
+ When performing reading and writing operations on the
+ storage devices attached
+ to West Bridge, there are cases where writes need to
+ happen to raw devices, versus
+ the units contained within a device. This is
+ specifically required to manage
+ the partitions within physical devices. This constant
+ is used in calls to
+ CyAsStorageRead(), CyAsStorageReadAsync(),
+ CyAsStorageWrite() and
+ CyAsStorageWriteAsync(), to indicate that the raw
+ physical device is being
+ accessed and not any specific unit on the device.
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageReadAsync
+ * CyAsStorageWrite
+ * CyAsStorageWriteAsync
+*/
+#define CY_AS_LUN_PHYSICAL_DEVICE (0xffffffff)
+
+/* Summary
+ This constant represents the maximum DMA burst length
+ supported on a storage endpoint
+
+ Description
+ West Bridge reserves separate endpoints for accessing
+ storage media through the
+ CyAsStorageRead() and CyAsStorageWrite() calls. The
+ maximum size of these
+ endpoints is always 512 bytes, regardless of status
+ and speed of the USB
+ connection.
+*/
+#define CY_AS_STORAGE_EP_SIZE (512)
+
+/********************************
+ * West Bridge Types
+ *******************************/
+
+/* Summary
+ This type indicates the type of event in an event
+ callback from West Bridge
+
+ Description
+ At times West Bridge needs to inform the P port
+ processor of events that have
+ occurred. These events are asynchronous to the
+ thread of control on the P
+ port processor and as such are generally delivered
+ via a callback function that
+ is called as part of an interrupt handler. This
+ type indicates the resonse for
+ the call to the callback function.
+
+ See Also
+ * CyAsStorageEventCallback
+ * CyAsStorageRegisterCallback
+*/
+typedef enum cy_as_storage_event {
+ /* This event occurs when the West Bridge device has
+ detected a USB connect and has enumerated the
+ storage controlled by west bridge to the USB port.
+ this event is the signal that the processor
+ needs to release the storage media. west bridge will
+ not have control of the storage media until the
+ processor calls cy_as_release_storage() to release
+ the specific media. */
+ cy_as_storage_antioch,
+
+ /* This event occurs when the processor has requested
+ ownership of a given media type and west bridge has
+ released the media. this event is an indicator
+ that the transfer of ownership is complete and the
+ processor now owns the given media type. */
+ cy_as_storage_processor,
+
+ /* This event occurs when a removable media type has
+ been removed. */
+ cy_as_storage_removed,
+
+ /* This event occurs when a removable media type has
+ been inserted. */
+ cy_as_storage_inserted,
+
+ /* This event occurs when the West Bridge device
+ * percieves an interrrupt from an SDIO card */
+ cy_as_sdio_interrupt
+
+} cy_as_storage_event ;
+
+/* Summary
+ This type gives the type of the operation in a storage
+ operation callback
+
+ Description
+ This type is used in the callback function for asynchronous
+ operation. This type indicates whether it is a
+ CyAsStorageRead() or CyAsStorageWrite() operation that
+ has completed.
+
+ See Also
+ * <LINK Asynchronous Versus Synchronous Operation>
+ * CyAsStorageRead
+ * CyAsStorageWrite
+*/
+typedef enum cy_as_oper_type {
+ /* A data read operation */
+ cy_as_op_read,
+ /* A data write operation */
+ cy_as_op_write
+} cy_as_oper_type ;
+
+/* Summary
+ This data structure describes a specific type of media
+
+ Description
+ This data structure is the return value from the
+ CyAsStorageQueryDevice function. This structure provides
+ information about the specific storage device being queried.
+
+ See Also
+ * CyAsStorageQueryDevice
+*/
+typedef struct cy_as_device_desc {
+ /* Type of device */
+ cy_as_media_type type ;
+ /* Is the device removable */
+ cy_bool removable ;
+ /* Is the device writeable */
+ cy_bool writeable ;
+ /* Basic block size for device */
+ uint16_t block_size ;
+ /* Number of LUNs on the device */
+ uint32_t number_units ;
+ /* Is the device password locked */
+ cy_bool locked ;
+ /* Size in bytes of an Erase Unit. Block erase operation
+ is only supported for SD storage, and the erase_unit_size
+ is invalid for all other kinds of storage. */
+ uint32_t erase_unit_size ;
+} cy_as_device_desc ;
+
+/* Summary
+ This data structure describes a specific unit on a
+ specific type of media
+
+ Description
+ This data structure is the return value from the
+ CyAsStorageQueryUnit function. This structure provides
+ information about the specific unit.
+
+ See Also
+ * CyAsStorageQueryUnit
+*/
+typedef struct cy_as_unit_desc {
+ /* Type of device */
+ cy_as_media_type type ;
+ /* Basic block size for device */
+ uint16_t block_size ;
+ /* Physical start block for LUN */
+ uint32_t start_block ;
+ /* Number of blocks in the LUN */
+ uint32_t unit_size ;
+} cy_as_unit_desc ;
+
+/* Summary
+ This function type defines a callback to be called after an
+ asynchronous operation
+
+ Description
+ This function type defines a callback function that is called
+ at the completion of any asynchronous read or write operation.
+
+ See Also
+ * CyAsStorageReadAsync()
+ * CyAsStorageWriteAsync()
+*/
+typedef void (*cy_as_storage_callback)(
+ /* Handle to the device completing the storage operation */
+ cy_as_device_handle handle,
+ /* The bus completing the operation */
+ cy_as_bus_number_t bus,
+ /* The device completing the operation */
+ uint32_t device,
+ /* The unit completing the operation */
+ uint32_t unit,
+ /* The block number of the completed operation */
+ uint32_t block_number,
+ /* The type of operation */
+ cy_as_oper_type op,
+ /* The error status */
+ cy_as_return_status_t status
+ ) ;
+
+/* Summary
+ This function type defines a callback to be called in the
+ event of a storage related event
+
+ Description
+ At times West Bridge needs to inform the P port processor
+ of events that have
+ occurred. These events are asynchronous to the thread of
+ control on the P
+ port processor and as such are generally delivered via a
+ callback function that
+ is called as part of an interrupt handler. This type
+ defines the type of function
+ that must be provided as a callback function.
+
+ See Also
+ * CyAsStorageEvent
+ * CyAsStorageRegisterCallback
+*/
+typedef void (*cy_as_storage_event_callback)(
+ /* Handle to the device sending the event notification */
+ cy_as_device_handle handle,
+ /* The bus where the event happened */
+ cy_as_bus_number_t bus,
+ /* The device where the event happened */
+ uint32_t device,
+ /* The event type */
+ cy_as_storage_event evtype,
+ /* Event related data */
+ void *evdata
+ ) ;
+
+/* Summary
+ This function type defines a callback to be called after
+ an asynchronous sdio operation
+
+ Description
+ The Callback function is called at the completion of an
+ asynchronous sdio read or write operation.
+
+ See Also
+ * CyAsSdioExtendedRead()
+ * CyAsSdioExtendedWrite()
+*/
+typedef void (*cy_as_sdio_callback)(
+ /* Handle to the device completing the storage operation */
+ cy_as_device_handle handle,
+ /* The bus completing the operation */
+ cy_as_bus_number_t bus,
+ /* The device completing the operation */
+ uint32_t device,
+ /* The function number of the completing the operation.
+ if the status of the operation is either CY_AS_ERROR_IO_ABORTED
+ or CY_AS_IO_SUSPENDED then the most significant word parameter will
+ contain the number of blocks still pending. */
+ uint32_t function,
+ /* The base address of the completed operation */
+ uint32_t address,
+ /* The type of operation */
+ cy_as_oper_type op,
+ /* The status of the operation */
+ cy_as_return_status_t status
+ ) ;
+
+/* Summary
+ Enumeration of SD/MMC card registers that can be read
+ through the API.
+
+ Description
+ Some of the registers on the SD/MMC card(s) attached to the
+ West Bridge can be read through the API layers. This type
+ enumerates the registers that can be read.
+
+ See Also
+ * CyAsStorageSDRegisterRead
+ */
+typedef enum cy_as_sd_card_reg_type {
+ cy_as_sd_reg_OCR = 0,
+ cy_as_sd_reg_CID,
+ cy_as_sd_reg_CSD
+} cy_as_sd_card_reg_type ;
+
+/* Summary
+ Struct encapsulating parameters and return values for a
+ CyAsStorageQueryDevice call.
+
+ Description
+ This struct holds the input parameters and the return values
+ for an asynchronous CyAsStorageQueryDevice call.
+
+ See Also
+ * CyAsStorageQueryDevice
+ */
+typedef struct cy_as_storage_query_device_data {
+ /* The bus with the device to query */
+ cy_as_bus_number_t bus ;
+ /* The logical device number to query */
+ uint32_t device ;
+ /* The return value for the device descriptor */
+ cy_as_device_desc desc_p ;
+} cy_as_storage_query_device_data ;
+
+
+/* Summary
+ Struct encapsulating parameters and return values
+ for a CyAsStorageQueryUnit call.
+
+ Description
+ This struct holds the input parameters and the return
+ values for an asynchronous CyAsStorageQueryUnit call.
+
+ See Also
+ * CyAsStorageQueryUnit
+ */
+typedef struct cy_as_storage_query_unit_data {
+ /* The bus with the device to query */
+ cy_as_bus_number_t bus ;
+ /* The logical device number to query */
+ uint32_t device ;
+ /* The unit to query on the device */
+ uint32_t unit ;
+ /* The return value for the unit descriptor */
+ cy_as_unit_desc desc_p ;
+} cy_as_storage_query_unit_data ;
+
+/* Summary
+ Struct encapsulating the input parameter and return
+ values for a CyAsStorageSDRegisterRead call.
+
+ Description
+ This struct holds the input parameter and return
+ values for an asynchronous CyAsStorageSDRegisterRead
+ call.
+
+ See Also
+ * CyAsStorageSDRegisterRead
+ */
+typedef struct cy_as_storage_sd_reg_read_data {
+ /* Pointer to the result buffer. */
+ uint8_t *buf_p;
+ /* Length of data to be copied in bytes. */
+ uint8_t length;
+} cy_as_storage_sd_reg_read_data ;
+
+/* Summary
+ Controls which pins are used for card detection
+
+ Description
+ When a StorageDeviceControl call is made to enable or
+ disable card detection this enum is passed in to
+ control which pin is used for the detection.
+
+ See Also
+ * CyAsStorageDeviceControl
+*/
+typedef enum cy_as_storage_card_detect {
+ cy_as_storage_detect_GPIO,
+ cy_as_storage_detect_SDAT_3
+} cy_as_storage_card_detect ;
+
+#ifndef __doxygen__
+#define cy_as_storage_detect_GPIO_0 cy_as_storage_detect_GPIO
+
+/* Length of OCR value in bytes. */
+#define CY_AS_SD_REG_OCR_LENGTH (4)
+/* Length of CID value in bytes. */
+#define CY_AS_SD_REG_CID_LENGTH (16)
+/* Length of CSD value in bytes. */
+#define CY_AS_SD_REG_CSD_LENGTH (16)
+/* Max. length of register response in words. */
+#define CY_AS_SD_REG_MAX_RESP_LENGTH (10)
+
+#endif
+
+/* Summary
+ This data structure is the data passed via the evdata
+ paramater on a usb event callback for the mass storage
+ device progress event.
+
+ Description
+ This data structure reports the number of sectors that have
+ been written and read on the USB mass storage device since
+ the last event report. The corresponding event is only sent
+ when either the number of writes, or the number of reads has
+ crossed a pre-set threshold.
+
+ See Also
+ * CyAsUsbEventCallback
+ * CyAsUsbRegisterCallback
+*/
+typedef struct cy_as_m_s_c_progress_data {
+ /* Number of sectors written since the last event. */
+ uint32_t wr_count;
+ /* Number of sectors read since the last event. */
+ uint32_t rd_count;
+} cy_as_m_s_c_progress_data ;
+
+/* Summary
+Flag to set Direct Write operation to read back from the
+address written to.
+
+
+ See Also
+ *CyAsSdioDirectWrite()
+*/
+#define CY_SDIO_RAW (0x01)
+
+
+/* Summary
+Flag to set Extended Read and Write to perform IO
+using a FIFO i.e. read or write from the specified
+address only.
+
+ See Also
+ *CyAsSdioExtendedRead()
+ *CyAsSdioExtendedWrite()
+*/
+#define CY_SDIO_OP_FIFO (0x00)
+
+/* Summary
+Flag to set Extended Read and Write to perform incremental
+IO using the address provided as the base address.
+
+
+ See Also
+ *CyAsSdioExtendedRead()
+ *CyAsSdioExtendedWrite()
+*/
+#define CY_SDIO_OP_INCR (0x02)
+
+/* Summary
+Flag to set Extended Read and Write to Block Mode operation
+
+ See Also
+ *CyAsSdioExtendedRead()
+ *CyAsSdioExtendedWrite()
+*/
+#define CY_SDIO_BLOCKMODE (0x04)
+
+/* Summary
+Flag to set Extended Read and Write to Byte Mode operation
+
+ See Also
+ *CyAsSdioExtendedRead()
+ *CyAsSdioExtendedWrite()
+*/
+#define CY_SDIO_BYTEMODE (0x00)
+
+/* Summary
+Flag to force re/initialization of a function.
+
+Description
+If not set a call to CyAsSdioInitFunction()
+will not initialize a function that has been previously
+initialized.
+ See Also
+ *CyAsSdioInitFunction()
+ */
+#define CY_SDIO_FORCE_INIT (0x40)
+
+/* Summary
+Flag to re-enable the SDIO interrupts.
+
+Description
+Used with a direct read or direct write
+after the Interrupt triggerred by SDIO has been serviced
+and cleared to reset the West Bridge Sdio Interrupt.
+ See Also
+ *CyAsSdioDirectRead()
+ *CyAsSdioDirectWrite()
+*/
+
+#define CY_SDIO_REARM_INT (0x80)
+
+
+/* Summary
+ Flag to check if 4 bit support is enabled on a
+ low speed card
+ See Also
+ <link CyAsSDIOCard::card_capability>*/
+#define CY_SDIO_4BLS (0x80)
+
+/* Summary
+ Flag to check if card is a low speed card
+ See Also
+ <link CyAsSDIOCard::card_capability> */
+#define CY_SDIO_LSC (0x40)
+
+/* Summary
+ Flag to check if interrupt during multiblock data
+ transfer is enabled
+ See Also
+ <link CyAsSDIOCard::card_capability>*/
+#define CY_SDIO_E4MI (0x20)
+
+/* Summary
+ Flag to check if interrupt during multiblock data
+ transfer is supported
+ See Also
+ <link CyAsSDIOCard::card_capability> */
+#define CY_SDIO_S4MI (0x10)
+
+/* Summary
+ Flag to check if card supports function suspending.
+ See Also
+ <link CyAsSDIOCard::card_capability> */
+#define CY_SDIO_SBS (0x08)
+
+/* Summary
+ Flag to check if card supports SDIO Read-Wait
+ See Also
+ <link CyAsSDIOCard::card_capability> */
+#define CY_SDIO_SRW (0x04)
+
+/* Summary
+ Flag to check if card supports multi-block transfers
+ See Also
+ <link CyAsSDIOCard::card_capability> */
+#define CY_SDIO_SMB (0x02)
+
+/* Summary
+ Flag to check if card supports Direct IO commands
+ during execution of an Extended
+ IO function
+ See Also
+ <link CyAsSDIOCard::card_capability>*/
+#define CY_SDIO_SDC (0x01)
+
+/* Summary
+ Flag to check if function has a CSA area.
+ See Also
+ <link CyAsSDIOFunc::csa_bits> */
+#define CY_SDIO_CSA_SUP (0x40)
+
+/* Summary
+ Flag to check if CSA access is enabled.
+ See Also
+ <link CyAsSDIOFunc::csa_bits> */
+#define CY_SDIO_CSA_EN (0x80)
+
+/* Summary
+ Flag to check if CSA is Write protected.
+ See Also
+ <link CyAsSDIOFunc::csa_bits> */
+#define CY_SDIO_CSA_WP (0x01)
+
+/* Summary
+ Flag to check if CSA formatting is prohibited.
+ See Also
+ <link CyAsSDIOFunc::csa_bits>*/
+#define CY_SDIO_CSA_NF (0x02)
+
+/* Summary
+ Flag to check if the function allows wake-up from low
+ power mode using some vendor specific method.
+ See Also
+ <link CyAsSDIOFunc::wakeup_support>*/
+#define CY_SDIO_FN_WUS (0x01)
+
+
+/* Summary
+ This data structure stores SDIO function 0
+ parameters for a SDIO card
+*/
+typedef struct cy_as_sdio_card {
+ /* Number of functions present on the card. */
+ uint8_t num_functions;
+ /* Memory present(Combo card) or not */
+ uint8_t memory_present;
+ /* 16 bit manufacturer ID */
+ uint16_t manufacturer__id;
+ /* Additional vendor specific info */
+ uint16_t manufacturer_info;
+ /* Max Block size for function 0 */
+ uint16_t maxblocksize;
+ /* Block size used for function 0 */
+ uint16_t blocksize;
+ /* SDIO version supported by the card */
+ uint8_t sdio_version;
+ /* Card capability flags */
+ uint8_t card_capability;
+} cy_as_sdio_card;
+
+/* Summary
+ This data structure stores SDIO function 1-7 parameters
+ for a SDIO card
+*/
+typedef struct cy_as_sdio_func {
+ /* SDIO function code. 0 if non standard function */
+ uint8_t function_code;
+ /* Extended function type code for non-standard function */
+ uint8_t extended_func_code;
+ /* Max IO Blocksize supported by the function */
+ uint16_t maxblocksize;
+ /* IO Blocksize used by the function */
+ uint16_t blocksize;
+ /* 32 bit product serial number for the function */
+ uint32_t card_psn;
+ /* Code storage area variables */
+ uint8_t csa_bits;
+ /* Function wake-up support */
+ uint8_t wakeup_support;
+} cy_as_sdio_func;
+
+/***********************************
+ * West Bridge Functions
+ ************************************/
+
+/* Summary
+ This function starts the West Bridge storage module.
+
+ Description
+ This function initializes the West Bridge storage software
+ stack and readies this module to service storage related
+ requests. If the stack is already running, the reference
+ count for the stack is incremented.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_SUCCESS - the module started sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsStorageStop
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_start(
+ /* Handle to the device */
+ cy_as_device_handle handle,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function stops the West Bridge storage module.
+
+ Description
+ This function decrements the reference count for the
+ storage stack and if this count is zero, the storage
+ stack is shut down. The shutdown frees all resources
+ associated with the storage stack.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ While all resources associated with the storage stack
+ will be freed is a shutdown occurs,
+ resources associated with underlying layers of the
+ software will not be freed if they
+ are shared by the USB stack and the USB stack is
+ active. Specifically the DMA manager,
+ the interrupt manager, and the West Bridge
+ communications module are all shared by both the
+ USB stack and the storage stack.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge
+ * device has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not
+ * been loaded into West Bridge
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - this module was shut
+ * down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING
+ * CY_AS_ERROR_ASYNC_PENDING
+ * CY_AS_ERROR_OUT_OF_MEMORY
+
+ See Also
+ * CyAsStorageStart
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_stop(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function is used to register a callback function
+ for the storage API.
+
+ Description
+ At times West Bridge needs to inform the P port processor
+ of events that have occurred. These events are asynchronous
+ to the thread of control on the P
+ port processor and as such are generally delivered via a
+ callback function that
+ is called as part of an interrupt handler. This function
+ registers the callback
+ function that is called when an event occurs. Each call
+ to this function
+ replaces any old callback function with a new callback
+ function supplied on
+ the most recent call. This function can also be called
+ with a callback function
+ of NULL in order to remove any existing callback function
+
+ * Valid In Asynchronous Callback:YES
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has
+ * not been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
+ * was passed in
+ * CY_AS_ERROR_SUCCESS - the function was registered
+ * sucessfully
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+
+ See Also
+ * CyAsStorageEventCallback
+ * CyAsStorageEvent
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_register_callback(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The callback function to call for async storage events */
+ cy_as_storage_event_callback callback
+ ) ;
+
+/* Summary
+ This function claims a given media type.
+
+ Description
+ This function communicates to West Bridge that the
+ processor wants control of the
+ given storage media type. Each media type can be
+ claimed or released by the
+ processor independently. As the processor is the
+ master for the storage,
+ West Bridge should release control of the requested
+ media as soon as possible and
+ signal the processor via the CyAsStorageProcessor event.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ This function just notifies West Bridge that the storage
+ is desired. The storage
+ has not actually been released by West Bridge until the
+ registered callback function
+ is called with the CyAsStorageProcessor event
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - this request was sucessfully
+ * transmitted to the West Bridge device
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_MEDIA
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_ACQUIRED
+
+ See Also:
+ * CyAsStorageClaim
+ * CyAsStorageRelease
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_claim(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to claim */
+ cy_as_bus_number_t bus,
+ /* The device to claim */
+ uint32_t device,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function releases a given media type.
+
+ Description
+ This function communicates to West Bridge that the
+ processor has released control of
+ the given storage media type. Each media type can
+ be claimed or released by the
+ processor independently. As the processor is the
+ master for the storage, West Bridge
+ can now assume ownership of the media type. No callback
+ or event is generated.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
+ * was passed in
+ * CY_AS_ERROR_SUCCESS - the media was sucessfully
+ * released
+ * CY_AS_ERROR_MEDIA_NOT_CLAIMED - the media was not
+ * claimed by the P port
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_MEDIA
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsStorageClaim
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_release(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to release */
+ cy_as_bus_number_t bus,
+ /* The device to release */
+ uint32_t device,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function information about the number of devices present
+ on a given bus
+
+ Description
+ This function retrieves information about how many devices on
+ on the given
+ West Bridge bus.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ While the current implementation of West Bridge only
+ supports one of logical device of
+ each media type, future versions WestBridge/Antioch may
+ support multiple devices.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsStorageQueryDevice
+ * CyAsStorageQueryUnit
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_query_bus(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to query */
+ cy_as_bus_number_t bus,
+ /* The return value containing the number of
+ devices present for this media type */
+ uint32_t *count,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function information about the number of devices
+ present for a given media type
+
+ Description
+ This function retrieves information about how many
+ devices of a given media type are attached to West Bridge.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ While the current implementation of West Bridge only
+ supports one of logical device of each media type, future
+ versions West Bridge may support multiple devices.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsStorageQueryMedia
+ * CyAsMediaType
+ * CyAsStorageQueryDevice
+ * CyAsStorageQueryUnit
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_query_media(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to query */
+ cy_as_media_type type,
+ /* The return value containing the number of
+ devices present for this media type */
+ uint32_t *count,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function returns information about a given device
+ of a specific media type
+
+ Description
+ This function retrieves information about a device of a
+ given type of media. The function is called with a given
+ media type and device and a pointer to a media descriptor
+ (CyAsDeviceDesc). This function fills in the data in the
+ media descriptor to provide information about the
+ attributes of the device of the given device.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ Currently this API only supports a single logical device
+ of each media type. Therefore the only acceptable value
+ for the parameter device is zero (0).
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_NO_SUCH_MEDIA
+ * CY_AS_ERROR_NO_SUCH_DEVICE
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsMediaType
+ * CyAsStorageQueryMedia
+ * CyAsStorageQueryUnit
+ * CyAsDeviceDesc
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_query_device(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Parameters and return value for the query call */
+ cy_as_storage_query_device_data *data,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function returns information about a given unit on a
+ specific device
+
+ Description
+ This function retrieves information about a device of a
+ given logical unit. The function is called with a given
+ media type, device address, unit address, and a pointer
+ to a unit descriptor (CyAsUnitDesc). This function fills
+ in the data in the unit descriptor to provide information
+ about the attributes of the device of the given logical
+ unit.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_NO_SUCH_DEVICE
+ * CY_AS_ERROR_NO_SUCH_UNIT
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+
+ See Also
+ * CyAsMediaType
+ * CyAsStorageQueryMedia
+ * CyAsStorageQueryDevice
+ * CyAsUnitDesc
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_query_unit(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Parameters and return value for the query call */
+ cy_as_storage_query_unit_data *data_p,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function enables/disables the handling of SD/MMC card
+ detection and SD/MMC write protection in West Bridge Firmware.
+
+ Description
+ If the detection of SD/MMC card insertion or removal is being
+ done by the Processor directly, the West Bridge firmware needs
+ to be instructed to disable the card detect feature. Also, if
+ the hardware design does not use the SD_WP GPIO of the West
+ Bridge to handle SD card's write protect notch, the handling
+ of write protection if firmware should be disabled. This API
+ is used to enable/disable the card detect and write protect
+ support in West Bridge firmware.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the feature controls were
+ * set successfully
+ * CY_AS_ERROR_NO_SUCH_BUS - the specified bus is invalid
+ * CY_AS_ERROR_NOT_SUPPORTED - function not supported on
+ * the device in the specified bus
+ * CY_AS_ERROR_IN_SUSPEND - the West Brdige device is in
+ * suspended mode
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_device_control(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The bus to control */
+ cy_as_bus_number_t bus,
+ /* The device to control */
+ uint32_t device,
+ /* Enable/disable control for card detection */
+ cy_bool card_detect_en,
+ /* Enable/disable control for write protect handling */
+ cy_bool write_prot_en,
+ /* Control which pin is used for card detection */
+ cy_as_storage_card_detect config_detect,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function reads one or more blocks of data from
+ the storage system.
+
+ Description
+ This function synchronously reads one or more blocks
+ of data from the given media
+ type/device and places the data into the data buffer
+ given. This function does not
+ return until the data is read and placed into the buffer.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ If the Samsung CEATA drive is the target for a
+ read/write operation, the maximum
+ number of sectors that can be accessed through a
+ single API call is limited to 2047.
+ Longer accesses addressed to a Samsung CEATA drive
+ can result in time-out errors.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
+ * was passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified
+ * does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified
+ * media/device pair does not exist
+ * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified
+ * does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation
+ * is pending
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was
+ * error in reading from the media
+ * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
+ * write protected
+ * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
+ * than 4095 logic blocks are not allowed
+
+ See Also
+ * CyAsStorageReadAsync
+ * CyAsStorageWrite
+ * CyAsStorageWriteAsync
+ * CyAsStorageCancelAsync
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_read(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to access */
+ cy_as_bus_number_t bus,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where data will be placed */
+ void *data_p,
+ /* The number of blocks to be read */
+ uint16_t num_blocks
+ ) ;
+
+/* Summary
+ This function asynchronously reads one or more blocks of data
+ from the storage system.
+
+ Description
+ This function asynchronously reads one or more blocks of
+ data from the given media
+ type/device and places the data into the data buffer given.
+ This function returns
+ as soon as the request is transmitted to the West Bridge
+ device but before the data is
+ available. When the read is complete, the callback function
+ is called to indicate the
+ data has been placed into the data buffer. Note that the
+ data buffer must remain
+ valid from when the read is requested until the callback
+ function is called.
+
+ * Valid In Asynchronous Callback: YES
+
+ Notes
+ If the Samsung CEATA drive is the target for a read/write
+ operation, the maximum
+ number of sectors that can be accessed through a single API
+ call is limited to 2047.
+ Longer accesses addressed to a Samsung CEATA drive can
+ result in time-out errors.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
+ * was passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation
+ * is pending
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
+ * in reading from the media
+ * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
+ * write protected
+ * CY_AS_ERROR_QUERY_DEVICE_NEEDED - Before an
+ * asynchronous read can be issue a call to
+ * CyAsStorageQueryDevice must be made
+ * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
+ * than 4095 logic blocks are not allowed
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageWriteAsync
+ * CyAsStorageCancelAsync
+ * CyAsStorageQueryDevice
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_read_async(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to access */
+ cy_as_bus_number_t bus,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where data will be placed */
+ void *data_p,
+ /* The number of blocks to be read */
+ uint16_t num_blocks,
+ /* The function to call when the read is complete
+ or an error occurs */
+ cy_as_storage_callback callback
+ ) ;
+
+/* Summary
+ This function writes one or more blocks of data
+ to the storage system.
+
+ Description
+ This function synchronously writes one or more blocks of
+ data to the given media/device.
+ This function does not return until the data is written
+ into the media.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ If the Samsung CEATA drive is the target for a read/write
+ operation, the maximum
+ number of sectors that can be accessed through a single
+ API call is limited to 2047.
+ Longer accesses addressed to a Samsung CEATA drive can
+ result in time-out errors.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does
+ * not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified
+ * media/device pair does not exist
+ * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified
+ * does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation
+ * is pending
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
+ * in reading from the media
+ * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
+ * write protected
+ * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
+ * than 4095 logic blocks are not allowed
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageReadAsync
+ * CyAsStorageWriteAsync
+ * CyAsStorageCancelAsync
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_write(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to access */
+ cy_as_bus_number_t bus,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer containing the data to be written */
+ void *data_p,
+ /* The number of blocks to be written */
+ uint16_t num_blocks
+ ) ;
+
+/* Summary
+ This function asynchronously writes one or more blocks
+ of data to the storage system
+
+ Description
+ This function asynchronously writes one or more blocks of
+ data to the given media type/device.
+ This function returns as soon as the request is transmitted
+ to the West Bridge device
+ but before the data is actually written. When the write is
+ complete, the callback
+ function is called to indicate the data has been physically
+ written into the media.
+
+ * Valid In Asynchronous Callback: YES
+
+ Notes
+ If the Samsung CEATA drive is the target for a read/write
+ operation, the maximum
+ number of sectors that can be accessed through a single API
+ call is limited to 2047.
+ Longer accesses addressed to a Samsung CEATA drive can
+ result in time-out errors.
+
+ Notes
+ The data buffer must remain valid from when the write is
+ requested until the callback function is called.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has
+ * not been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation is
+ * pending
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is write
+ * protected
+ * CY_AS_ERROR_QUERY_DEVICE_NEEDED - A query device call is
+ * required before async writes are allowed
+ * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
+ * than 4095 logic blocks are not allowed
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageWrite
+ * CyAsStorageReadAsync
+ * CyAsStorageCancelAsync
+ * CyAsStorageQueryDevice
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_write_async(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The bus to access */
+ cy_as_bus_number_t bus,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where the data to be written is stored */
+ void *data_p,
+ /* The number of blocks to be written */
+ uint16_t num_blocks,
+ /* The function to call when the write is complete
+ or an error occurs */
+ cy_as_storage_callback callback
+ ) ;
+
+/* Summary
+ This function aborts any outstanding asynchronous operation
+
+ Description
+ This function aborts any asynchronous block read or block
+ write operation. As only a single asynchronous block read
+ or write operation is possible at one time, this aborts
+ the single operation in progress.
+
+ * Valid In Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_OPERATION_PENDING - no asynchronous
+ * operation is pending
+
+ See Also
+ * CyAsStorageRead
+ * CyAsStorageReadAsync
+ * CyAsStorageWrite
+ * CyAsStorageWriteAsync
+ * <LINK Asynchronous Versus Synchronous Operation>
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_cancel_async(
+ /* Handle to the device with outstanding async request */
+ cy_as_device_handle handle
+ ) ;
+
+/* Summary
+ This function is used to read the content of SD registers
+
+ Description
+ This function is used to read the contents of CSD, CID and
+ CSD registers of the SD Card.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the read operation was successful
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair
+ * does not exist
+ * CY_AS_ERROR_INVALID_PARAMETER - The register type is invalid
+ * or the media is not supported on the bus
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to process
+ * request
+ * CY_AS_ERROR_INVALID_RESPONSE - communication failure with
+ * West Bridge firmware
+
+ See Also
+ * CyAsStorageSDRegReadData
+ */
+EXTERN cy_as_return_status_t
+cy_as_storage_sd_register_read(
+ /* Handle to the West Bridge device. */
+ cy_as_device_handle handle,
+ /* The bus to query */
+ cy_as_bus_number_t bus,
+ /* The device to query */
+ uint8_t device,
+ /* The type of register to read. */
+ cy_as_sd_card_reg_type reg_type,
+ /* Output data buffer and length. */
+ cy_as_storage_sd_reg_read_data *data_p,
+ /* Callback function to call when done. */
+ cy_as_function_callback cb,
+ /* Call context to send to the cb function. */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Creates a partition starting at the given block and using the
+ remaining blocks on the card.
+
+ Description
+ Storage devices attached to West Bridge can be partitioned
+ into two units.
+ The visibility of these units through the mass storage
+ interface can be
+ individually controlled. This API is used to partition
+ a device into two.
+
+ * Valid in Asynchronous Callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the partition was successfully created
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_USB_RUNNING - Partition cannot be created while
+ * USB stack is active
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to
+ * process request
+ * CY_AS_ERROR_INVALID_REQUEST - feature not supported by
+ * active device or firmware
+ * CY_AS_ERROR_INVALID_RESPONSE - communication failure with
+ * West Bridge firmware
+ * CY_AS_ERROR_ALREADY_PARTITIONED - the storage device already
+ * has been partitioned
+ * CY_AS_ERROR_INVALID_BLOCK - Size specified for the partition
+ * exceeds the actual device capacity
+
+ See Also
+ * <LINK Partitioning>
+ * CyAsStorageRemovePPartition
+ */
+EXTERN cy_as_return_status_t
+cy_as_storage_create_p_partition(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Bus on which the device to be partitioned is connected */
+ cy_as_bus_number_t bus,
+ /* Device number to be partitioned */
+ uint32_t device,
+ /* Size of partition number 0 in blocks */
+ uint32_t size,
+ /* Callback in case of async call */
+ cy_as_function_callback cb,
+ /* Client context to pass to the callback */
+ uint32_t client
+ );
+
+/* Summary
+ Removes the partition table on a storage device connected
+ to the West Bridge.
+
+ Description
+ Storage devices attached to West Bridge can be partitioned
+ into two units.This partition information is stored on the
+ device and is non-volatile. This API is used to remove the
+ stored partition information and make the entire device
+ visible as a single partition (unit).
+
+ * Valid in Asynchronous Callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the partition was successfully
+ * deleted
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_USB_RUNNING - Partition cannot be created
+ * while USB stack is active
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to
+ * process request
+ * CY_AS_ERROR_INVALID_REQUEST - operation not supported
+ * by active device/firmware
+ * CY_AS_ERROR_NO_SUCH_UNIT - the addressed device is
+ * not partitioned
+
+ See Also
+ * <LINK Partitioning>
+ * CyAsStorageCreatePPartition
+ */
+EXTERN cy_as_return_status_t
+cy_as_storage_remove_p_partition(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Bus on which device of interest is connected */
+ cy_as_bus_number_t bus,
+ /* Device number of interest */
+ uint32_t device,
+ /* Callback in case of async call */
+ cy_as_function_callback cb,
+ /* Client context to pass to the callback */
+ uint32_t client
+ );
+
+/* Summary
+ Returns the amount of data read/written to the given
+ device from the USB host.
+
+ Description
+
+ * Valid in Asynchronous Callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - API call completed successfully
+ * CY_AS_ERROR_INVALID_HANDLE - Invalid West Bridge device
+ * handle
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - No firmware image has been
+ * loaded on West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - Storage stack has not been
+ * started
+ * CY_AS_ERROR_NOT_SUPPORTED - This function is not
+ * supported by active firmware version
+ * CY_AS_ERROR_OUT_OF_MEMORY - Failed to get memory to
+ * process the request
+ * CY_AS_ERROR_TIMEOUT - West Bridge firmware did not
+ * respond to request
+ * CY_AS_ERROR_INVALID_RESPONSE - Unexpected reply from
+ * West Bridge firmware
+
+ See Also
+ * CyAsUsbSetMSReportThreshold
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_get_transfer_amount(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Bus on which device of interest is connected */
+ cy_as_bus_number_t bus,
+ /* Device number of interest */
+ uint32_t device,
+ /* Return value containing read/write sector counts. */
+ cy_as_m_s_c_progress_data *data_p,
+ /* Callback in case of async call */
+ cy_as_function_callback cb,
+ /* Client context to pass to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Performs a Sector Erase on an attached SD Card
+
+ Description
+ This allows you to erase an attached SD card. The area to erase
+ is specified in terms of a starting Erase Unit and a number of
+ Erase Units. The size of each Erase Unit is defined in the
+ DeviceDesc returned from a StorageQueryDevice call and it can
+ differ between SD cards.
+
+ A large erase can take a while to complete depending on the SD
+ card. In such a case it is reccomended that an async call is made.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - API call completed successfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation is pending
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is write protected
+ * CY_AS_ERROR_QUERY_DEVICE_NEEDED - A query device call is
+ * required before erase is allowed
+ * CY_AS_ERROR_NO_SUCH_BUS
+ * CY_AS_ERROR_NO_SUCH_DEVICE
+ * CY_AS_ERROR_NOT_SUPPORTED - Erase is currenly only supported
+ * on SD and using SD only firmware
+ * CY_AS_ERROR_OUT_OF_MEMORY
+
+ See Also
+ * CyAsStorageSDRegisterRead
+*/
+EXTERN cy_as_return_status_t
+cy_as_storage_erase(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Bus on which device of interest is connected */
+ cy_as_bus_number_t bus,
+ /* Device number of interest */
+ uint32_t device,
+ /* Erase Unit to start the erase */
+ uint32_t erase_unit,
+ /* Number of Erase Units to erase */
+ uint16_t num_erase_units,
+ /* Callback in case of async call */
+ cy_as_function_callback cb,
+ /* Client context to pass to the callback */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function is used to read a Tuple from the SDIO CIS area.
+
+ Description
+ This function is used to read a Tuple from the SDIO CIS area.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device
+ * is in suspend mode
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation is pending
+ * CY_AS_ERROR_INVALID_REQUEST - an invalid IO request
+ * type was made
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
+ * an invalid function
+ * CY_AS_ERROR_INVALID_ENDPOINT - A DMA request was made to
+ * an invalid endpoint
+ * CY_AS_ERROR_ENDPOINT_DISABLED - A DMA request was made to
+ * a disabled endpoint
+
+*/
+cy_as_return_status_t
+cy_as_sdio_get_c_i_s_info(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Id of tuple to be fetched */
+ uint16_t tuple_id,
+ /* Buffer to hold tuple read from card.
+ should be at least 256 bytes in size */
+ uint8_t *data_p
+ );
+
+
+/* Summary
+ This function is used to read properties of the SDIO card.
+
+ Description
+ This function is used to read properties of the SDIO card
+ into a CyAsSDIOCard structure.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_SUCCESS - the card information was returned
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+
+*/
+cy_as_return_status_t
+cy_as_sdio_query_card(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* Buffer to store card properties */
+ cy_as_sdio_card *data_p
+ );
+
+/* Summary
+ This function is used to reset a SDIO card.
+
+ Description
+ This function is used to reset a SDIO card by writing to
+ the reset bit in the CCCR and reinitializing the card. This
+ function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ */
+cy_as_return_status_t
+cy_as_sdio_reset_card(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device
+ );
+
+/* Summary
+ This function performs a Synchronous 1 byte read from the sdio
+ device function.
+
+ Description
+ This function is used to perform a synchronous 1 byte read
+ from an SDIO card function. This function is to be used only
+ for IO to an SDIO card as other media will not respond to the
+ SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
+ * in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair
+ * does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
+ * from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in reading
+ * from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to an
+ * invalid function
+ * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which read
+ * was attempted is in suspend
+*/
+cy_as_return_status_t
+cy_as_sdio_direct_read(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Address for IO */
+ uint32_t address,
+ /* Set to CY_SDIO_REARM_INT to reinitialize SDIO interrupt */
+ uint8_t misc_buf,
+ /* Buffer to hold byte read from card */
+ uint8_t *data_p
+ );
+
+/* Summary
+ This function performs a Synchronous 1 byte write to the
+ sdio device function.
+
+ Description
+ This function is used to perform a synchronous 1 byte write
+ to an SDIO card function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
+ * from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
+ * an invalid function
+ * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
+ * write was attempted is in suspend
+*/
+cy_as_return_status_t
+cy_as_sdio_direct_write(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Address for IO */
+ uint32_t address,
+ /* Set to CY_SDIO_REARM_INT to reinitialize SDIO interrupt,
+ set to CY_SDIO_RAW for read after write */
+ uint8_t misc_buf,
+ /* Byte to write */
+ uint16_t argument,
+ /* Buffer to hold byte read from card in Read after write mode */
+ uint8_t *data_p
+ );
+
+/* Summary
+ This function is used to set the blocksize of an SDIO function.
+
+ Description
+ This function is used to set the blocksize of an SDIO function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory
+ * available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+ * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize
+ * was passed to the function.
+ * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
+ * write was attempted is in suspend
+*/
+cy_as_return_status_t
+cy_as_sdio_set_blocksize(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Block size to set. */
+ uint16_t blocksize
+ );
+
+/* Summary
+ This function is used to read Multibyte/Block data from a
+ IO function.
+
+ Description
+ This function is used to read Multibyte/Block data from a
+ IO function. This function is to be used only for IO to an
+ SDIO card as other media will not respond to the SDIO
+ command set.
+
+ * Valid in Asynchronous Callback: YES
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation is pending
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
+ * from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
+ * an invalid function
+ * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize or
+ * block count was passed to the function.
+ * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
+ * write was attempted is in suspend
+ * CY_AS_ERROR_IO_ABORTED - The IO operation was aborted
+ * CY_AS_ERROR_IO_SUSPENDED - The IO operation was suspended
+ * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
+ * passed to the card.
+
+*/
+cy_as_return_status_t
+cy_as_sdio_extended_read(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Base Address for IO */
+ uint32_t address,
+ /* Set to CY_SDIO_BLOCKMODE for block IO,
+ CY_SDIO_BYTEMODE for multibyte IO,
+ CY_SDIO_OP_FIFO to read multiple bytes from the
+ same address, CY_SDIO_OP_INCR to read bytes from
+ the incrementing addresses */
+ uint8_t misc_buf,
+ /* Block/Byte count to read */
+ uint16_t argument,
+ /* Buffer to hold data read from card */
+ uint8_t *data_p,
+ /* Callback in case of Asyncronous call. 0 if Synchronous */
+ cy_as_sdio_callback callback
+ );
+
+/* Summary
+ This function is used to write Multibyte/Block data
+ to a IO function.
+
+ Description
+ This function is used to write Multibyte/Block data
+ to a IO function. This function is to be used only
+ for IO to an SDIO card as other media will not respond
+ to the SDIO command set.
+
+ * Valid in Asynchronous Callback: YES
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation is pending
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+ * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize or
+ * block count was passed to the function.
+ * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
+ * write was attempted is in suspend
+ * CY_AS_ERROR_IO_ABORTED - The IO operation was aborted
+ * CY_AS_ERROR_IO_SUSPENDED - The IO operation was suspended
+ * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
+ * passed to the card.
+*/
+cy_as_return_status_t
+cy_as_sdio_extended_write(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Base Address for IO */
+ uint32_t address,
+ /* Set to CY_SDIO_BLOCKMODE for block IO,
+ CY_SDIO_BYTEMODE for multibyte IO,
+ CY_SDIO_OP_FIFO to write multiple bytes to the same address,
+ CY_SDIO_OP_INCR to write multiple bytes to incrementing
+ addresses */
+ uint8_t misc_buf,
+ /* Block/Byte count to write
+ in case of byte mode the count should not exceed the block size
+ or 512, whichever is smaller.
+ in case of block mode, maximum number of blocks is 511. */
+ uint16_t argument,
+ /* Buffer to hold data to be written to card. */
+ uint8_t *data_p,
+ /* Callback in case of Asyncronous call. 0 if Synchronous */
+ cy_as_sdio_callback callback
+ );
+
+/* Summary
+ This function is used to initialize a SDIO card function.
+
+ Description
+ This function is used to initialize a SDIO card function
+ (1 - 7). This function is to be used only for IO to an
+ SDIO card as other media will not respond to the SDIO
+ command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
+ * in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
+ * reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+*/
+cy_as_return_status_t
+cy_as_sdio_init_function(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Set to CY_SDIO_FORCE_INIT to reinitialize function */
+ uint8_t misc_buf
+ );
+
+/* Summary
+ This function is used to get properties of a SDIO card function.
+
+ Description
+ This function is used to get properties of a SDIO card functio
+ (1 - 7) into a CyAsSDIOFunc structure. This function is to be
+ used only for IO to an SDIO card as other media will not respond
+ to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
+ * started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
+ * in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the media specified does
+ * not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair
+ * does not exist
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO request was made to
+ * an invalid function
+*/
+cy_as_return_status_t
+cy_as_sdio_query_function(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Buffer to store function properties */
+ cy_as_sdio_func *data_p
+ );
+
+/* Summary
+ This function is used to Abort the current IO function.
+
+ Description
+ This function is used to Abort the current IO function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified
+ * media/device pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory
+ * available
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+*/
+cy_as_return_status_t
+cy_as_sdio_abort_function(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no
+ );
+
+/* Summary
+ This function is used to Disable IO to an SDIO function.
+
+ Description
+ This function is used to Disable IO to an SDIO function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is
+ * in suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
+ * pair does not exist
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+*/
+cy_as_return_status_t
+cy_as_sdio_de_init_function(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no
+ );
+
+/* Summary
+ This function is used to Suspend the current IO function.
+
+ Description
+ This function is used to Suspend the current IO function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
+ * not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not
+ * exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified
+ * media/device pair does not exist
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory
+ * available
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
+ * to an invalid function
+*/
+cy_as_return_status_t
+cy_as_sdio_suspend(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no
+ );
+
+/* Summary
+ This function is used to resume a Suspended IO function.
+
+ Description
+ This function is used to resume a Suspended IO function.
+ This function is to be used only for IO to an SDIO card as
+ other media will not respond to the SDIO command set.
+
+ * Valid in Asynchronous Callback: NO
+ * Valid on Antioch device: NO
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
+ * has not been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
+ * loaded into West Bridge
+ * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
+ * been started
+ * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
+ * passed in
+ * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is
+ * in suspend mode
+ * CY_AS_ERROR_SUCCESS - the media information was
+ * returned
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred
+ * communicating with the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the stack is not running
+ * CY_AS_ERROR_NO_SUCH_BUS - the bus specified
+ * does not exist
+ * CY_AS_ERROR_NO_SUCH_DEVICE - the specified
+ * media/device pair does not exist
+ * CY_AS_ERROR_ASYNC_PENDING - an async operation
+ * is pending
+ * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory
+ * available
+ * CY_AS_ERROR_INVALID_RESPONSE - an error message was
+ * recieved from the firmware
+ * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
+ * in reading from the media
+ * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was
+ * made to an invalid function
+ * CY_AS_ERROR_IO_ABORTED - The IO operation was
+ * aborted
+ * CY_AS_ERROR_IO_SUSPENDED - The IO operation was
+ * suspended
+ * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
+ * passed to the card.
+
+*/
+cy_as_return_status_t
+cy_as_sdio_resume(
+ /* Handle to the Westbridge device */
+ cy_as_device_handle handle,
+ /* Bus to use */
+ cy_as_bus_number_t bus,
+ /* Device number */
+ uint32_t device,
+ /* IO function Number */
+ uint8_t n_function_no,
+ /* Operation to resume (Read or Write) */
+ cy_as_oper_type op,
+ /* Micellaneous buffer same as for Extended read and Write */
+ uint8_t misc_buf,
+ /* Number of pending blocks for IO. Should be less
+ than or equal to the maximum defined for extended
+ read and write */
+ uint16_t pendingblockcount,
+ /* Buffer to continue the Suspended IO operation */
+ uint8_t *data_p
+ );
+
+
+
+/* For supporting deprecated functions */
+#include "cyasstorage_dep.h"
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASSTORAGE_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage_dep.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage_dep.h
new file mode 100644
index 000000000000..172fa85731bb
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage_dep.h
@@ -0,0 +1,309 @@
+/* Cypress West Bridge API header file (cyanstorage_dep.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/* This header will contain Antioch specific declaration
+ * of the APIs that are deprecated in Astoria SDK. This is
+ * for maintaining backward compatibility
+ */
+#ifndef __INCLUDED_CYANSTORAGE_DEP_H__
+#define __INCLUDED_CYANSTORAGE_DEP_H__
+
+#ifndef __doxygen__
+
+typedef void (*cy_as_storage_callback_dep)(
+/* Handle to the device completing the storage operation */
+ cy_as_device_handle handle,
+ /* The media type completing the operation */
+ cy_as_media_type type,
+ /* The device completing the operation */
+ uint32_t device,
+ /* The unit completing the operation */
+ uint32_t unit,
+ /* The block number of the completed operation */
+ uint32_t block_number,
+ /* The type of operation */
+ cy_as_oper_type op,
+ /* The error status */
+ cy_as_return_status_t status
+ ) ;
+
+typedef void (*cy_as_storage_event_callback_dep)(
+ /* Handle to the device sending the event notification */
+ cy_as_device_handle handle,
+ /* The media type */
+ cy_as_media_type type,
+ /* The event type */
+ cy_as_storage_event evtype,
+ /* Event related data */
+ void *evdata
+ ) ;
+
+typedef struct cy_as_storage_query_device_data_dep {
+ /* The type of media to query */
+ cy_as_media_type type ;
+ /* The logical device number to query */
+ uint32_t device ;
+ /* The return value for the device descriptor */
+ cy_as_device_desc desc_p ;
+} cy_as_storage_query_device_data_dep ;
+
+typedef struct cy_as_storage_query_unit_data_dep {
+ /* The type of media to query */
+ cy_as_media_type type ;
+ /* The logical device number to query */
+ uint32_t device ;
+ /* The unit to query on the device */
+ uint32_t unit ;
+ /* The return value for the unit descriptor */
+ cy_as_unit_desc desc_p ;
+} cy_as_storage_query_unit_data_dep ;
+
+
+/************ FUNCTIONS *********************/
+
+EXTERN cy_as_return_status_t
+cy_as_storage_register_callback_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The callback function to call for async storage events */
+ cy_as_storage_event_callback_dep callback
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_claim_dep(cy_as_device_handle handle,
+ cy_as_media_type type
+ );
+
+EXTERN cy_as_return_status_t
+cy_as_storage_claim_dep_EX(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to claim */
+ cy_as_media_type *type,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_release_dep(cy_as_device_handle handle,
+ cy_as_media_type type
+ );
+
+EXTERN cy_as_return_status_t
+cy_as_storage_release_dep_EX(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Handle to the device of interest */
+ cy_as_media_type *type,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_query_device_dep(
+ cy_as_device_handle handle,
+ cy_as_media_type media,
+ uint32_t device,
+ cy_as_device_desc *desc_p
+ );
+
+EXTERN cy_as_return_status_t
+cy_as_storage_query_device_dep_EX(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Parameters and return value for the query call */
+ cy_as_storage_query_device_data_dep *data,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_query_unit_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to query */
+ cy_as_media_type type,
+ /* The logical device number to query */
+ uint32_t device,
+ /* The unit to query on the device */
+ uint32_t unit,
+ /* The return value for the unit descriptor */
+ cy_as_unit_desc *unit_p
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_query_unit_dep_EX(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* Parameters and return value for the query call */
+ cy_as_storage_query_unit_data_dep *data_p,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_device_control_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Enable/disable control for card detection */
+ cy_bool card_detect_en,
+ /* Enable/disable control for write protect handling */
+ cy_bool write_prot_en,
+ /* Callback to be called when the operation is complete */
+ cy_as_function_callback cb,
+ /* Client data to be passed to the callback */
+ uint32_t client
+ ) ;
+
+
+EXTERN cy_as_return_status_t
+cy_as_storage_read_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to access */
+ cy_as_media_type type,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where data will be placed */
+ void *data_p,
+ /* The number of blocks to be read */
+ uint16_t num_blocks
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_read_async_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to access */
+ cy_as_media_type type,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where data will be placed */
+ void *data_p,
+ /* The number of blocks to be read */
+ uint16_t num_blocks,
+ /* The function to call when the read is complete
+ or an error occurs */
+ cy_as_storage_callback_dep callback
+ ) ;
+EXTERN cy_as_return_status_t
+cy_as_storage_write_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to access */
+ cy_as_media_type type,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer containing the data to be written */
+ void *data_p,
+ /* The number of blocks to be written */
+ uint16_t num_blocks
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_write_async_dep(
+ /* Handle to the device of interest */
+ cy_as_device_handle handle,
+ /* The type of media to access */
+ cy_as_media_type type,
+ /* The device to access */
+ uint32_t device,
+ /* The unit to access */
+ uint32_t unit,
+ /* The first block to access */
+ uint32_t block,
+ /* The buffer where the data to be written is stored */
+ void *data_p,
+ /* The number of blocks to be written */
+ uint16_t num_blocks,
+ /* The function to call when the write is complete
+ or an error occurs */
+ cy_as_storage_callback_dep callback
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_sd_register_read_dep(
+ cy_as_device_handle handle,
+ cy_as_media_type type,
+ uint8_t device,
+ cy_as_sd_card_reg_type reg_type,
+ uint8_t read_len,
+ uint8_t *data_p
+ );
+
+EXTERN cy_as_return_status_t
+cy_as_storage_sd_register_read_dep_EX(
+ /* Handle to the West Bridge device. */
+ cy_as_device_handle handle,
+ /* The type of media to query */
+ cy_as_media_type type,
+ /* The device to query */
+ uint8_t device,
+ /* The type of register to read. */
+ cy_as_sd_card_reg_type reg_type,
+ /* Output data buffer and length. */
+ cy_as_storage_sd_reg_read_data *data_p,
+ /* Callback function to call when done. */
+ cy_as_function_callback cb,
+ /* Call context to send to the cb function. */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_create_p_partition_dep(
+ cy_as_device_handle handle,
+ cy_as_media_type media,
+ uint32_t device,
+ uint32_t size,
+ cy_as_function_callback cb,
+ uint32_t client) ;
+
+EXTERN cy_as_return_status_t
+cy_as_storage_remove_p_partition_dep(
+ cy_as_device_handle handle,
+ cy_as_media_type media,
+ uint32_t device,
+ cy_as_function_callback cb,
+ uint32_t client) ;
+
+#endif /*__doxygen*/
+
+#endif /*__INCLUDED_CYANSTORAGE_DEP_H__*/
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastoria.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastoria.h
new file mode 100644
index 000000000000..b1b18d0685e4
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastoria.h
@@ -0,0 +1,36 @@
+/* Cypress West Bridge API header file (cyastioch.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASTORIA_H_
+#define _INCLUDED_CYASTORIA_H_
+
+#if !defined(__doxygen__)
+
+#include "cyaserr.h"
+#include "cyasmisc.h"
+#include "cyasstorage.h"
+#include "cyasusb.h"
+#include "cyasmtp.h"
+
+#endif
+
+#endif
+
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastsdkversion.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastsdkversion.h
new file mode 100644
index 000000000000..a3c10aa559e2
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastsdkversion.h
@@ -0,0 +1,30 @@
+/* Cypress Astoria Sdk Version file (cyastsdkversion.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor
+## Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASTSDK_VERSION_H_
+#define _INCLUDED_CYASTSDK_VERSION_H_
+
+/* Astoria SDK version 1.2.1 */
+#define CYAS_MAJOR_VERSION (1)
+#define CYAS_MINOR_VERSION (2)
+#define CYAS_BUILD_NUMBER (197)
+
+#endif /*_INCLUDED_CYASTSDK_VERSION_H_*/
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastypes.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastypes.h
new file mode 100644
index 000000000000..2ccccf746a10
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyastypes.h
@@ -0,0 +1,71 @@
+/* Cypress West Bridge API header file (cyastypes.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASTYPES_H_
+#define _INCLUDED_CYASTYPES_H_
+/* moved to staging location, eventual implementation
+ * considered is here
+#include <mach/westbridge/cyashaldef.h>
+*/
+ #include "../../../arch/arm/plat-omap/include/mach/westbridge/cyashaldef.h"
+
+/* Types that are not available on specific platforms.
+ * These are used only in the reference HAL implementations and
+ * are not required for using the API.
+ */
+#ifdef __unix__
+typedef unsigned long DWORD;
+typedef void *LPVOID;
+#define WINAPI
+#define INFINITE (0xFFFFFFFF)
+#define ptr_to_uint(ptr) ((unsigned int)(ptr))
+#endif
+
+/* Basic types used by the entire API */
+
+/* Summary
+ This type represents an endpoint number
+*/
+typedef uint8_t cy_as_end_point_number_t ;
+
+/* Summary
+ This type is used to return status information from
+ an API call.
+*/
+typedef uint16_t cy_as_return_status_t ;
+
+/* Summary
+ This type represents a bus number
+*/
+typedef uint32_t cy_as_bus_number_t ;
+
+/* Summary
+ All APIs provided with this release are marked extern
+ through this definition. This definition can be changed
+ to meet the scope changes required in the user build
+ environment.
+
+ For example, this can be changed to __declspec(exportdll)
+ to enable exporting the API from a DLL.
+ */
+#define EXTERN extern
+
+#endif
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb.h
new file mode 100644
index 000000000000..f066848cb7a9
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb.h
@@ -0,0 +1,1862 @@
+/* Cypress West Bridge API header file (cyasusb.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+#ifndef _INCLUDED_CYASUSB_H_
+#define _INCLUDED_CYASUSB_H_
+
+#include "cyasmisc.h"
+
+#include "cyas_cplus_start.h"
+
+/*@@Enumeration Model
+ Summary
+ The USB enumeration process is the process of communicating
+ to the USB host information
+ about the capabilities of the connected device. This
+ process is completed by servicing
+ requests for various types of descriptors. In the software
+ APIs described below, this
+ process is controlled in one of two ways.
+
+ Description
+ There are advantages to either type of enumeration
+ and this is why both models are supported.
+ P Port processor based enumeraton gives the P port
+ processor maximum control and flexibility
+ for providing USB configuration information. However,
+ this does require (near) real time data
+ responses from the P port processor during the enumeration
+ process. West Bridge based enumeration
+ requires no real time information from the P port processor,
+ ensuring the fastest possible
+ enumeration times.
+
+ * P Port Based Enumeration *
+ The first method for handling USB enumeration is for the
+ processor client to handle all
+ endpoint zero requests for descriptors. This mode is
+ configured by indicating to the API
+ that the processor wants to handle all endpoint zero
+ requests. This is done by setting
+ bit 0 in the end_point_mask to a 1. The processor uses
+ CyAsUsbReadDataAsync() to read the request and
+ CyAsUsbWriteDataAsync() to write the response.
+
+ * West Bridge Based Enumeration *
+ The second method for handling USB enumeration is the
+ configuration information method.
+ Before enabling a connection from the West Bridge device
+ to the USB connector, the P Port
+ processor sends information about the USB configuration to
+ West Bridge through the configuration
+ APIs. This information is stored within the West Bridge
+ device. When a USB cable is attached,
+ the West Bridge device then handles all descriptor requests
+ based on the stored information.
+ Note that this method of enumeration only supports a single
+ USB configuration.
+
+ In either model of enumeration, the processor client is
+ responsible for ensuring that
+ the system meets USB Chapter 9 compliance requirements. This
+ can be done by providing spec
+ compliant descriptors, and handling any setup packets that
+ are sent to the client
+ appropriately.
+
+ Mass storage class compliance will be ensured by the West
+ Bridge firmware when the mass
+ storage functionality is enabled.
+*/
+
+/*@@Endpoint Configuration
+ Summary
+ The West Bridge device has one 64-byte control endpoint, one
+ 64-byte low bandwidth endpoint, four bulk
+ endpoints dedicated for mass storage usage, and up to ten
+ bulk/interrupt/isochronous
+ endpoints that can be used for USB-to-Processor communication.
+
+ Description
+ The four storage endpoints (Endpoints 2, 4, 6 and 8) are
+ reserved for accessing storage
+ devices attached to West Bridge and are not available for use
+ by the processor. These are
+ used implicitly when using the storage API to read/write to
+ the storage media.
+
+ Endpoint 0 is the standard USB control pipe used for all
+ enumeration activity. Though
+ the endpoint buffer is not directly accessible from the
+ processor, read/write activity
+ can be performed on this endpoint through the API layers.
+ This endpoint is always
+ configured as a bi-directional control endpoint.
+
+ Endpoint 1 is a 64-byte endpoint that can be used for low
+ bandwidth bulk/interrupt
+ activity. The physical buffer is not accessible from the
+ processor, but can be read/written
+ through the API. As the data coming to this endpoint is
+ being handled through the
+ software layers, there can be loss of data if a read call
+ is not waiting when an OUT
+ packet arrives.
+
+ Endpoints 3, 5, 7, 9, 10, 11, 12, 13, 14 and 15 are ten
+ configurable endpoints
+ mapped to parts of a total 4 KB FIFO buffer space on the
+ West Bridge device. This 4 KB
+ physical buffer space is divided into up to four endpoints
+ called PEP1, PEP2, PEP3 and PEP4
+ in this software document. There are multiple configurations
+ in which this buffer space
+ can be used, and the size and number of buffers available to
+ each physical endpoint
+ vary between these configurations. See the West Bridge PDD
+ for details on the buffer
+ orientation corresponding to each configuration.
+
+ * Note *
+ PEPs 1, 2, 3 and 4 are called Physical EP 3, 5, 7 and 9 in the
+ West Bridge PDD. The
+ sequential number scheme is used in the software to disambiguate
+ these from the logical
+ endpoint numbers, and also for convenience of array indexing.
+*/
+
+#if !defined(__doxygen__)
+
+
+#endif
+
+/* Summary
+ This constants defines the maximum size of a USB descriptor
+ when referenced via the CyAsUsbSetDescriptor or
+ CyAsUsbGetDescriptor functions.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+*/
+#define CY_AS_MAX_USB_DESCRIPTOR_SIZE (128)
+
+/***************************************
+ * West Bridge Types
+ ***************************************/
+
+
+/* Summary
+ This data structure is the data passed via the evdata paramater
+ on a usb event callback for the inquiry request.
+
+ Description
+ When a SCSI inquiry request arrives via the USB connection and
+ the P Port has asked
+ to receive inquiry requests, this request is forwarded to the
+ client via the USB
+ callback. This callback is called twice, once before the
+ inquiry data is forwarded
+ to the host (CyAsEventUsbInquiryBefore) and once after the
+ inquiry has been sent to the
+ USB host (CyAsEventUsbInquiryAfter). The evdata parameter
+ is a pointer to this data
+ structure.
+
+ *CyAsEventUsbInquiryBefore*
+ If the client just wishes to see the inquiry request and
+ associated data, then a simple
+ return from the callback will forward the inquiry response
+ to the USB host. If the
+ client wishes to change the data returned to the USB host,
+ the updated parameter must
+ be set to CyTrue and the memory area address by the data
+ parameter should be updated.
+ The data pointer can be changed to point to a new memory
+ area and the length field
+ changed to change the amount of data returned from the
+ inquiry request. Note that the
+ data area pointed to by the data parameter must remain
+ valid and the contents must
+ remain consistent until after the CyAsEventUsbInquiryAfter
+ event has occurred. THE LENGTH
+ MUST BE LESS THAN 192 BYTES OR THE CUSTOM INQUIRY RESPONSE
+ WILL NOT BE RETURNED. If the
+ length is too long, the default inquiry response will be
+ returned.
+
+ *CyAsEventUsbInquiryAfter*
+ If the client needs to free any data, this event signals that
+ the data associated with the inquiry is no longer needed.
+
+ See Also
+ * CyAsUsbEventCallback
+ * CyAsUsbRegisterCallback
+*/
+typedef struct cy_as_usb_inquiry_data {
+ /* The bus for the event */
+ cy_as_bus_number_t bus ;
+ /* The device the event */
+ uint32_t device ;
+ /* The EVPD bit from the SCSI INQUIRY request */
+ uint8_t evpd ;
+ /* The codepage in the inquiry request */
+ uint8_t codepage ;
+ /* This bool must be set to CyTrue indicate that the inquiry
+ data was changed */
+ cy_bool updated ;
+ /* The length of the data */
+ uint16_t length ;
+ /* The inquiry data */
+ void *data ;
+} cy_as_usb_inquiry_data ;
+
+
+/* Summary
+ This data structure is the data passed via the evdata
+ parameter on a usb event
+ callback for the unknown mass storage request.
+
+ Description
+ When a SCSI request is made that the mass storage
+ firmware in West Bridge does not
+ know how to process, this request is passed to the
+ processor for handling via
+ the usb callback. This data structure is used to
+ pass the request and the
+ associated response. The user may set the status
+ to indicate the status of the
+ request. The status value is the bCSWStatus value
+ from the USB mass storage
+ Command Status Wrapper (0 = command passed, 1 =
+ command failed). If the status
+ is set to command failed (1), the sense information
+ should be set as well. For
+ more information about sense information, see the
+ USB mass storage specification
+ as well as the SCSI specifications for block devices.
+ By default the status is
+ initialized to 1 (failure) with a sense information
+ of 05h/20h/00h which
+ indicates INVALID COMMAND.
+*/
+typedef struct cy_as_usb_unknown_command_data {
+ /* The bus for the event */
+ cy_as_bus_number_t bus ;
+ /* The device for the event */
+ uint32_t device ;
+
+ uint16_t reqlen ;
+ /* The request */
+ void *request ;
+
+ /* The returned status value for the command */
+ uint8_t status ;
+ /* If status is failed, the sense key */
+ uint8_t key ;
+ /* If status is failed, the additional sense code */
+ uint8_t asc ;
+ /* If status if failed, the additional sense code qualifier */
+ uint8_t ascq ;
+} cy_as_usb_unknown_command_data ;
+
+
+/* Summary
+ This data structure is the data passed via the evdata
+ paramater on a usb event callback for the start/stop request.
+
+ Description
+ When a SCSI start stop request arrives via the USB connection
+ and the P Port has asked
+
+ See Also
+ * CyAsUsbEventCallback
+ * CyAsUsbRegisterCallback
+*/
+typedef struct cy_as_usb_start_stop_data {
+ /* The bus for the event */
+ cy_as_bus_number_t bus ;
+ /* The device for the event */
+ uint32_t device ;
+ /* CyTrue means start request, CyFalse means stop request */
+ cy_bool start ;
+ /* CyTrue means LoEj bit set, otherwise false */
+ cy_bool loej ;
+} cy_as_usb_start_stop_data ;
+
+/* Summary
+ This data type is used to indicate which mass storage devices
+ are enumerated.
+
+ Description
+
+ See Also
+ * CyAsUsbEnumControl
+ * CyAsUsbSetEnumConfig
+*/
+typedef enum cy_as_usb_mass_storage_enum {
+ cy_as_usb_nand_enum = 0x01,
+ cy_as_usb_sd_enum = 0x02,
+ cy_as_usb_mmc_enum = 0x04,
+ cy_as_usb_ce_ata_enum = 0x08
+} cy_as_usb_mass_storage_enum ;
+
+/* Summary
+ This data type specifies the type of descriptor to transfer
+ to the West Bridge device
+
+ Description
+ During enumeration, if West Bridge is handling enumeration,
+ the West Bridge device needs to USB descriptors
+ to complete the enumeration. The function CyAsUsbSetDescriptor()
+ is used to transfer the descriptors
+ to the West Bridge device. This type is an argument to that
+ function and specifies which descriptor
+ is being transferred.
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * CyAsUsbGetDescriptor
+*/
+typedef enum cy_as_usb_desc_type {
+ /* A device descriptor - See USB 2.0 specification Chapter 9 */
+ cy_as_usb_desc_device = 1,
+ /* A device descriptor qualifier -
+ * See USB 2.0 specification Chapter 9 */
+ cy_as_usb_desc_device_qual = 2,
+ /* A configuration descriptor for FS operation -
+ * See USB 2.0 specification Chapter 9 */
+ cy_as_usb_desc_f_s_configuration = 3,
+ /* A configuration descriptor for HS operation -
+ * See USB 2.0 specification Chapter 9 */
+ cy_as_usb_desc_h_s_configuration = 4,
+ cy_as_usb_desc_string = 5
+} cy_as_usb_desc_type ;
+
+/* Summary
+ This type specifies the direction of an endpoint
+
+ Description
+ This type is used when configuring the endpoint hardware
+ to specify the direction
+ of the endpoint.
+
+ See Also
+ * CyAsUsbEndPointConfig
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbGetEndPointConfig
+*/
+typedef enum cy_as_usb_end_point_dir {
+ /* The endpoint direction is IN (West Bridge -> USB Host) */
+ cy_as_usb_in = 0,
+ /* The endpoint direction is OUT (USB Host -> West Bridge) */
+ cy_as_usb_out = 1,
+ /* The endpoint direction is IN/OUT (valid only for EP 0 & 1) */
+ cy_as_usb_in_out = 2
+} cy_as_usb_end_point_dir ;
+
+/* Summary
+ This type specifies the type of an endpoint
+
+ Description
+ This type is used when configuring the endpoint hardware
+ to specify the type of endpoint.
+
+ See Also
+ * CyAsUsbEndPointConfig
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbGetEndPointConfig
+*/
+typedef enum cy_as_usb_end_point_type {
+ cy_as_usb_control,
+ cy_as_usb_iso,
+ cy_as_usb_bulk,
+ cy_as_usb_int
+} cy_as_usb_end_point_type ;
+
+/* Summary
+ This type is a structure used to indicate the top level
+ configuration of the USB stack
+
+ Description
+ In order to configure the USB stack, the CyAsUsbSetEnumConfig()
+ function is called to indicate
+ how mass storage is to be handled, the specific number of
+ interfaces to be supported if
+ West Bridge is handling enumeration, and the end points of
+ specifi interest. This structure
+ contains this information.
+
+ See Also
+ * CyAsUsbSetConfig
+ * CyAsUsbGetConfig
+ * <LINK Enumeration Model>
+*/
+typedef struct cy_as_usb_enum_control {
+ /* Designate which devices on which buses to enumerate */
+ cy_bool devices_to_enumerate[CY_AS_MAX_BUSES]
+ [CY_AS_MAX_STORAGE_DEVICES];
+ /* If true, West Bridge will control enumeration. If this
+ * is false the P port controls enumeration. if the P port
+ * is controlling enumeration, traffic will be received via
+ * endpoint zero. */
+ cy_bool antioch_enumeration ;
+ /* This is the interface # to use for the mass storage
+ * interface, if mass storage is enumerated. if mass
+ * storage is not enumerated this value should be zero. */
+ uint8_t mass_storage_interface ;
+ /* This is the interface # to use for the MTP interface,
+ * if MTP is enumerated. if MTP is not enumerated
+ * this value should be zero. */
+ uint8_t mtp_interface ;
+ /* If true, Inquiry, START/STOP, and unknown mass storage
+ * requests cause a callback to occur for handling by the
+ * baseband processor. */
+ cy_bool mass_storage_callbacks ;
+} cy_as_usb_enum_control ;
+
+
+/* Summary
+ This structure is used to configure a single endpoint
+
+ Description
+ This data structure contains all of the information required
+ to configure the West Bridge hardware
+ associated with a given endpoint.
+
+ See Also
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbGetEndPointConfig
+*/
+typedef struct cy_as_usb_end_point_config {
+ /* If true, this endpoint is enabled */
+ cy_bool enabled ;
+ /* The direction of this endpoint */
+ cy_as_usb_end_point_dir dir ;
+ /* The type of endpoint */
+ cy_as_usb_end_point_type type ;
+ /* The physical endpoint #, 1, 2, 3, 4 */
+ cy_as_end_point_number_t physical ;
+ /* The size of the endpoint in bytes */
+ uint16_t size ;
+} cy_as_usb_end_point_config ;
+
+/* Summary
+ List of partition enumeration combinations that can
+ be selected on a partitioned storage device.
+
+ Description
+ West Bridge firmware supports creating upto two
+ partitions on mass storage devices connected to
+ West Bridge. When there are two partitions on a device,
+ the user can choose which of these partitions should be
+ made visible to a USB host through the mass storage
+ interface. This enumeration lists the various enumeration
+ selections that can be made.
+
+ See Also
+ * CyAsStorageCreatePPartition
+ * CyAsStorageRemovePPartition
+ * CyAsUsbSelectMSPartitions
+ */
+typedef enum cy_as_usb_m_s_type_t {
+ /* Enumerate only partition 0 as CD (autorun) device */
+ cy_as_usb_m_s_unit0 = 0,
+ /* Enumerate only partition 1 as MS device (default setting) */
+ cy_as_usb_m_s_unit1,
+ /* Enumerate both units */
+ cy_as_usb_m_s_both
+} cy_as_usb_m_s_type_t ;
+
+/* Summary
+ This type specifies the type of USB event that has occurred
+
+ Description
+ This type is used in the USB event callback function to
+ indicate the type of USB event that has occurred. The callback
+ function includes both this reasons for the callback and a data
+ parameter associated with the reason. The data parameter is used
+ in a reason specific way and is documented below with each reason.
+
+ See Also
+ * CyAsUsbIoCallback
+*/
+typedef enum cy_as_usb_event {
+ /* This event is sent when West Bridge is put into the suspend
+ state by the USB host. the data parameter is not used and
+ will be zero. */
+ cy_as_event_usb_suspend,
+ /* This event is sent when West Bridge is taken out of the
+ suspend state by the USB host. the data parameter is not
+ used and will be zero. */
+ cy_as_event_usb_resume,
+ /* This event is sent when a USB reset request is received
+ by the west bridge device. the data parameter is not used and
+ will be zero. */
+ cy_as_event_usb_reset,
+ /* This event is sent when a USB set configuration request is made.
+ the data parameter is a pointer to a uint16_t that contains the
+ configuration number. the configuration number may be zero to
+ indicate an unconfigure operation. */
+ cy_as_event_usb_set_config,
+ /* This event is sent when the USB connection changes speed. This is
+ generally a transition from full speed to high speed. the parameter
+ to this event is a pointer to uint16_t that gives the speed of the
+ USB connection. zero indicates full speed, one indicates high speed */
+ cy_as_event_usb_speed_change,
+ /* This event is sent when a setup packet is received.
+ * The data parameter is a pointer to the eight bytes of setup data. */
+ cy_as_event_usb_setup_packet,
+ /* This event is sent when a status packet is received. The data
+ parameter is not used. */
+ cy_as_event_usb_status_packet,
+ /* This event is sent when mass storage receives an inquiry
+ request and we have asked to see these requests. */
+ cy_as_event_usb_inquiry_before,
+ /* This event is sent when mass storage has finished processing an
+ inquiry request and any data associated with the request is no longer
+ required. */
+ cy_as_event_usb_inquiry_after,
+ /* This event is sent when mass storage receives a start/stop
+ * request and we have asked to see these requests */
+ cy_as_event_usb_start_stop,
+ /* This event is sent when a Clear Feature request is received.
+ * The data parameter is the endpoint number. */
+ cy_as_event_usb_clear_feature,
+ /* This event is sent when mass storage receives a request
+ * that is not known and we have asked to see these requests */
+ cy_as_event_usb_unknown_storage,
+ /* This event is sent when the read/write activity on the USB mass
+ storage has crossed a pre-set level */
+ cy_as_event_usb_m_s_c_progress
+} cy_as_usb_event;
+
+/* Summary
+ This type is the type of a callback function that is
+ called when a USB event occurs
+
+ Description
+ At times West Bridge needs to inform the P port processor
+ of events that have
+ occurred. These events are asynchronous to the thread of
+ control on the P
+ port processor and as such are generally delivered via a
+ callback function that
+ is called as part of an interrupt handler. This type
+ defines the type of function
+ that must be provided as a callback function for USB events.
+
+ See Also
+ * CyAsUsbEvent
+*/
+typedef void (*cy_as_usb_event_callback)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The event type being reported */
+ cy_as_usb_event ev,
+ /* The data assocaited with the event being reported */
+ void *evdata
+) ;
+
+
+/* Summary
+ This type is the callback function called after an
+ asynchronous USB read/write operation
+
+ Description
+ This function type defines a callback function that is
+ called at the completion of any
+ asynchronous read or write operation.
+
+ See Also
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+ * CY_AS_ERROR_CANCELED
+*/
+typedef void (*cy_as_usb_io_callback)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The endpoint that has completed an operation */
+ cy_as_end_point_number_t ep,
+ /* THe amount of data transferred to/from USB */
+ uint32_t count,
+ /* The data buffer for the operation */
+ void *buffer,
+ /* The error status of the operation */
+ cy_as_return_status_t status
+) ;
+
+/* Summary
+ This type is the callback function called after asynchronous
+ API functions have completed.
+
+ Description
+ When calling API functions from callback routines (interrupt
+ handlers usually) the async version of
+ these functions must be used. This callback is called when an
+ asynchronous API function has completed.
+*/
+typedef void (*cy_as_usb_function_callback)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The error status of the operation */
+ cy_as_return_status_t status,
+ /* A client supplied 32 bit tag */
+ uint32_t client
+) ;
+
+
+/********************************************
+ * West Bridge Functions
+ ********************************************/
+
+/* Summary
+ This function starts the USB stack
+
+ Description
+ This function initializes the West Bridge USB software
+ stack if it has not yet been stared.
+ This initializes any required data structures and powers
+ up any USB specific portions of
+ the West Bridge hardware. If the stack had already been
+ started, the USB stack reference count
+ is incremented.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ This function cannot be called from any type of West Bridge
+ callback.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_SUCCESS - the stack initialized and is ready
+ * for use
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
+ * with the West Bridge device
+
+ See Also
+ * CyAsUsbStop
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_start(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function stops the USB stack
+
+ Description
+ This function decrements the reference count for
+ the USB stack and if this count
+ is zero, the USB stack is shut down. The shutdown
+ frees all resources associated
+ with the USB stack.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ While all resources associated with the USB stack will
+ be freed is a shutdown occurs,
+ resources associated with underlying layers of the software
+ will not be freed if they
+ are shared by the storage stack and the storage stack is active.
+ Specifically the DMA manager,
+ the interrupt manager, and the West Bridge communications module
+ are all shared by both the
+ USB stack and the storage stack.
+
+ Returns
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+
+ See Also
+ * CyAsUsbStart
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_stop(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function registers a callback function to be called when an
+ asynchronous USB event occurs
+
+ Description
+ When asynchronous USB events occur, a callback function can be
+ called to alert the calling program. This
+ functions allows the calling program to register a callback.
+
+ * Valid In Asynchronous Callback: YES
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_register_callback(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The function to call */
+ cy_as_usb_event_callback callback
+ ) ;
+
+
+/* Summary
+ This function connects the West Bridge device D+ and D- signals
+ physically to the USB host.
+
+ Description
+ The West Bridge device has the ability to programmatically
+ disconnect the USB pins on the device
+ from the USB host. This feature allows for re-enumeration of
+ the West Bridge device as a different
+ device when necessary. This function connects the D+ and D-
+ signal physically to the USB host
+ if they have been previously disconnnected.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+
+ See Also
+ * CyAsUsbDisconnect
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_connect(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function disconnects the West Bridge device D+ and D-
+ signals physically from the USB host.
+
+ Description
+ The West Bridge device has the ability to programmatically
+ disconnect the USB pins on the device
+ from the USB host. This feature allows for re-enumeration
+ of the West Bridge device as a different
+ device when necessary. This function disconnects the D+
+ and D- signal physically from the USB host
+ if they have been previously connected.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+
+ See Also
+ * CyAsUsbConnect
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_disconnect(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function configures the USB stack
+
+ Description
+ This function is used to configure the USB stack. It is
+ used to indicate which endpoints are going to
+ be used, and how to deal with the mass storage USB device
+ within West Bridge.
+
+ * Valid In Asynchronous Callback: Yes (if cb supplied)
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+
+ See Also
+ * CyAsUsbGetEnumConfig
+ * CyAsUsbEnumControl
+ */
+EXTERN cy_as_return_status_t
+cy_as_usb_set_enum_config(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The USB configuration information */
+ cy_as_usb_enum_control *config_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function retreives the current configuration of
+ the USB stack
+
+ Description
+ This function sends a request to West Bridge to retreive
+ the current configuration
+
+ * Valid In Asynchronous Callback: Yes (if cb supplied)
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+
+ See Also
+ * CyAsUsbSetConfig
+ * CyAsUsbConfig
+ */
+EXTERN cy_as_return_status_t
+cy_as_usb_get_enum_config(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The return value for USB congifuration information */
+ cy_as_usb_enum_control *config_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets the USB descriptor
+
+ Description
+ This function is used to set the various descriptors
+ assocaited with the USB enumeration
+ process. This function should only be called when the
+ West Bridge enumeration model is selected.
+ Descriptors set using this function can be cleared by
+ stopping the USB stack, or by calling
+ the CyAsUsbClearDescriptors function.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ These descriptors are described in the USB 2.0 specification,
+ Chapter 9.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_DESCRIPTOR - the descriptor passed is
+ * not valid
+ * CY_AS_ERROR_BAD_INDEX - a bad index was given for the type
+ * of descriptor given
+ * CY_AS_ERROR_BAD_ENUMERATION_MODE - this function cannot be
+ * called if the P port processor doing enumeration
+
+ See Also
+ * CyAsUsbGetDescriptor
+ * CyAsUsbClearDescriptors
+ * <LINK Enumeration Model>
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_descriptor(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The type of descriptor */
+ cy_as_usb_desc_type type,
+ /* Only valid for string descriptors */
+ uint8_t index,
+ /* The descriptor to be transferred */
+ void *desc_p,
+ /* The length of the descriptor in bytes */
+ uint16_t length,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function clears all user descriptors stored
+ on the West Bridge.
+
+ Description
+ This function is used to clear all descriptors that
+ were previously
+ stored on the West Bridge through CyAsUsbSetDescriptor
+ calls, and go back
+ to the default descriptor setup in the firmware. This
+ function should
+ only be called when the Antioch enumeration model is
+ selected.
+
+ * Valid In Asynchronous Callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - all descriptors cleared successfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_BAD_ENUMERATION_MODE - this function cannot be
+ * called if the P port processor is doing enumeration
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * <LINK Enumeration Model>
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_clear_descriptors(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+/* Summary
+ This structure contains the descriptor buffer to be
+ filled by CyAsUsbGetDescriptor API.
+
+ Description
+ This data structure the buffer to hold the descriptor
+ data, and an in/out parameter ti indicate the
+ lenght of the buffer and descriptor data in bytes.
+
+ See Also
+ * CyAsUsbGetDescriptor
+*/
+typedef struct cy_as_get_descriptor_data {
+ /* The buffer to hold the returned descriptor */
+ void *desc_p;
+ /* This is an input and output parameter.
+ * Before the code this pointer points to a uint32_t
+ * that contains the length of the buffer. after
+ * the call, this value contains the amount of data
+ * actually returned. */
+ uint32_t length;
+
+} cy_as_get_descriptor_data ;
+
+/* Summary
+ This function retreives a given descriptor from the
+ West Bridge device
+
+ Description
+ This function retreives a USB descriptor from the West
+ Bridge device. This function should only be called when the
+ West Bridge enumeration model is selected.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Notes
+ These descriptors are described in the USB 2.0 specification,
+ Chapter 9.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_BAD_INDEX - a bad index was given for the type of
+ * descriptor given
+ * CY_AS_ERROR_BAD_ENUMERATION_MODE - this function cannot be
+ * called if the P port processor doing enumeration
+
+ See Also
+ * CyAsUsbSetDescriptor
+ * <LINK Enumeration Model>
+*/
+
+EXTERN cy_as_return_status_t
+cy_as_usb_get_descriptor(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The type of descriptor */
+ cy_as_usb_desc_type type,
+ /* Index for string descriptor */
+ uint8_t index,
+ /* Parameters and return value for the get descriptor call */
+ cy_as_get_descriptor_data *data,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets the configuration of the physical
+ endpoints into one of the twelve supported configuration
+
+ Description
+ USB endpoints are mapped onto one of four physical
+ endpoints in the device. Therefore
+ USB endpoints are known as logical endpoints and these
+ logical endpoints are mapped to
+ one of four physical endpoints. In support of these
+ four physical endpoints there is
+ four kilo-bytes of buffer spaces that can be used as
+ buffers for these physical endpoints.
+ This 4K of buffer space can be configured in one of
+ twelve ways. This function sets the
+ buffer configuration for the physical endpoints.
+
+ * Config 1: PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (2 * 512), PEP4 (2 * 512)
+ * Config 2: PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (4 * 512), PEP4 (N/A)
+ * Config 3: PEP1 (2 * 512), PEP2 (2 * 512),
+ * PEP3 (2 * 1024), PEP4(N/A)
+ * Config 4: PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (2 * 512), PEP4 (2 * 512)
+ * Config 5: PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (4 * 512), PEP4 (N/A)
+ * Config 6: PEP1 (4 * 512), PEP2 (N/A),
+ * PEP3 (2 * 1024), PEP4 (N/A)
+ * Config 7: PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (2 * 512), PEP4 (2 * 512)
+ * Config 8: PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (4 * 512), PEP4 (N/A)
+ * Config 9: PEP1 (2 * 1024), PEP2 (N/A),
+ * PEP3 (2 * 1024), PEP4 (N/A)
+ * Config 10: PEP1 (3 * 512), PEP2 (N/A),
+ * PEP3 (3 * 512), PEP4 (2 * 512)
+ * Config 11: PEP1 (3 * 1024), PEP2 (N/A),
+ * PEP3 (N/A), PEP4 (2 * 512)
+ * Config 12: PEP1 (4 * 1024), PEP2 (N/A),
+ * PEP3 (N/A), PEP4 (N/A)
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_CONFIGURATION - the configuration given
+ * is not between 1 and 12
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_physical_configuration(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The physical endpoint configuration number */
+ uint8_t config
+ ) ;
+
+/* Summary
+ This function sets the hardware configuration for a given endpoint
+
+ Description
+ This function sets the hardware configuration for a given endpoint.
+ This is the method to set the direction of the endpoint, the type
+ of endpoint, the size of the endpoint buffer, and the buffering
+ style for the endpoint.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ Add documentation about endpoint configuration limitations
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is invalid
+ * CY_AS_ERROR_INVALID_CONFIGURATION - the endpoint configuration
+ * given is not valid
+ * CY_AS_ERROR_ENDPOINT_CONFIG_NOT_SET - the physical endpoint
+ * configuration is not set
+
+ See Also
+ * CyAsUsbGetEndPointConfig
+ * CyAsUsbEndPointConfig
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_end_point_config(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The configuration information for the endpoint */
+ cy_as_usb_end_point_config *config_p
+ ) ;
+
+/* Summary
+ This function retreives the hardware configuration for
+ a given endpoint
+
+ Description
+ This function gets the hardware configuration for the given
+ endpoint. This include information about the direction of
+ the endpoint, the type of endpoint, the size of the endpoint
+ buffer, and the buffering style for the endpoint.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is
+ * invalid
+
+ See Also
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbEndPointConfig
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_get_end_point_config(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest*/
+ cy_as_end_point_number_t ep,
+ /* The return value containing the endpoint config
+ * information */
+ cy_as_usb_end_point_config *config_p
+ ) ;
+
+/* Summary
+ This function commits the configuration information that
+ has previously been set.
+
+ Description
+ The initialization process involves calling CyAsUsbSetEnumConfig()
+ and CyAsUsbSetEndPointConfig(). These
+ functions do not actually send the configuration information to
+ the West Bridge device. Instead, these
+ functions store away the configuration information and this
+ CyAsUsbCommitConfig() actually finds the
+ best hardware configuration based on the requested endpoint
+ configuration and sends thsi optimal
+ confiuration down to the West Bridge device.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - a configuration was found and sent
+ * to West Bridge
+ * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
+ * into West Bridge
+ * CY_AS_ERROR_INVALID_CONFIGURATION - the configuration requested
+ * is not possible
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+
+ See Also
+ * CyAsUsbSetEndPointConfig
+ * CyAsUsbSetEnumConfig
+*/
+
+EXTERN cy_as_return_status_t
+cy_as_usb_commit_config(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function reads data from a USB endpoint.
+
+ Description
+ This function reads data from an OUT. This function blocks
+ until the read is complete.
+ If this is a packet read, a single received USB packet will
+ complete the read. If this
+ is not a packet read, this function will block until all of
+ the data requested has been
+ recevied.
+
+ * Valid In Asynchronous Callback: NO
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is
+ * invalid
+
+ See Also
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteData
+ * CyAsUsbWriteDataAsync
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_read_data(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* If CyTrue, this is a packet read */
+ cy_bool pktread,
+ /* The amount of data to read */
+ uint32_t dsize,
+ /* The amount of data read */
+ uint32_t *dataread,
+ /* The buffer to hold the data read */
+ void *data
+ ) ;
+
+/* Summary
+ This function reads data from a USB endpoint
+
+ Description
+ This function reads data from an OUT endpoint. This
+ function will return immediately and the callback
+ provided will be called when the read is complete.
+ If this is a packet read, then the callback will be
+ called on the next received packet. If this is not a
+ packet read, the callback will be called when the
+ requested data is received.
+
+ * Valid In Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is
+ * invalid
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbWriteData
+ * CyAsUsbWriteDataAsync
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_read_data_async(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* If CyTrue, this is a packet read */
+ cy_bool pktread,
+ /* The amount of data to read */
+ uint32_t dsize,
+ /* The buffer for storing the data */
+ void *data,
+ /* The callback function to call when the data is read */
+ cy_as_usb_io_callback callback
+ ) ;
+
+/* Summary
+ This function writes data to a USB endpoint
+
+ Description
+ This function writes data to an IN endpoint data buffer.
+ Multiple USB packets may be sent until all data requeste
+ has been sent. This function blocks until all of the data
+ has been sent.
+
+ * Valid In Asynchronous Callback: NO
+
+ Notes
+ Calling this function with a dsize of zero will result in
+ a zero length packet transmitted to the USB host.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is
+ * invalid
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteDataAsync
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_write_data(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint to write data to */
+ cy_as_end_point_number_t ep,
+ /* The size of the data to write */
+ uint32_t dsize,
+ /* The data buffer */
+ void *data
+ ) ;
+
+/* Summary
+ This function writes data to a USB endpoint
+
+ Description
+ This function writes data to an IN endpoint data buffer.
+ This function returns immediately and when the write
+ completes, or if an error occurs, the callback function
+ is called to indicate completion of the write operation.
+
+ * Valid In Asynchronous Callback: YES
+
+ Notes
+ Calling this function with a dsize of zero will result
+ in a zero length packet transmitted to the USB host.
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down sucessfully
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint parameter is
+ * invalid
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteData
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_write_data_async(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint to write data to */
+ cy_as_end_point_number_t ep,
+ /* The size of the data */
+ uint32_t dsize,
+ /* The buffer containing the data */
+ void *data,
+ /* If true, send a short packet to terminate data */
+ cy_bool spacket,
+ /* The callback to call when the data is written */
+ cy_as_usb_io_callback callback
+ ) ;
+
+/* Summary
+ This function aborts an outstanding asynchronous
+ operation on a given endpoint
+
+ Description
+ This function aborts any outstanding operation that is
+ pending on the given endpoint.
+
+ * Valid In Asynchronous Callback: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - this module was shut down
+ * sucessfully
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not
+ * running
+ * CY_AS_ERROR_ASYNC_NOT_PENDING - no asynchronous USB
+ * operation was pending
+
+ See Also
+ * CyAsUsbReadData
+ * CyAsUsbReadDataAsync
+ * CyAsUsbWriteData
+ * CyAsUsbWriteDataAsync
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_cancel_async(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep
+ ) ;
+
+/* Summary
+ This function sets a stall condition on a given endpoint
+
+ Description
+ This function sets a stall condition on the given endpoint.
+ If the callback function is not zero, the function is
+ executed asynchronously and the callback is called when
+ the function is completed. If the callback function is
+ zero, this function executes synchronously and will not
+ return until the function has completed.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was invalid,
+ * or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK (only if no cb supplied)
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbGetStall
+ * CyAsUsbClearStall
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_stall(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+) ;
+
+/* Summary
+ This function clears a stall condition on a given endpoint
+
+ Description
+ This function clears a stall condition on the given endpoint.
+ If the callback function is not zero, the function is
+ executed asynchronously and the callback is called when the
+ function is completed. If the callback function is zero, this
+ function executes synchronously and will not return until the
+ function has completed.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was invalid,
+ * or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK (only if no cb supplied)
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbGetStall
+ * CyAsUsbSetStall
+*/
+
+EXTERN cy_as_return_status_t
+cy_as_usb_clear_stall(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+
+/* Summary
+ This function returns the stall status for a given endpoint
+
+ Description
+ This function returns the stall status for a given endpoint
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was invalid,
+ * or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbGetStall
+ * CyAsUsbSetStall
+ * CyAsUsbClearStall
+*/
+
+EXTERN cy_as_return_status_t
+cy_as_usb_get_stall(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The return value for the stall state */
+ cy_bool *stall_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets a NAK condition on a given endpoint
+
+ Description
+ This function sets a NAK condition on the given endpoint.
+ If the callback function is not zero, the function is
+ executed asynchronously and the callback is called when
+ the function is completed. If the callback function is
+ zero, this function executes synchronously and will not
+ return until the function has completed.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was
+ * invalid, or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK (only if no cb supplied)
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbGetNak
+ * CyAsUsbClearNak
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_nak(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+) ;
+
+/* Summary
+ This function clears a NAK condition on a given endpoint
+
+ Description
+ This function clears a NAK condition on the given endpoint.
+ If the callback function is not zero, the function is
+ executed asynchronously and the callback is called when the
+ function is completed. If the callback function is zero,
+ this function executes synchronously and will not return
+ until the function has completed.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was invalid,
+ * or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK (only if no cb supplied)
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbGetNak
+ * CyAsUsbSetNak
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_clear_nak(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function returns the NAK status for a given endpoint
+
+ Description
+ This function returns the NAK status for a given endpoint
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_INVALID_ENDPOINT - the endpoint given was invalid,
+ * or was not configured as an OUT endpoint
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+
+ See Also
+ * CyAsUsbSetNak
+ * CyAsUsbClearNak
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_get_nak(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The return value for the stall state */
+ cy_bool *nak_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+) ;
+
+/* Summary
+ This function triggers a USB remote wakeup from the Processor
+ API
+
+ Description
+ When there is a Suspend condition on the USB bus, this function
+ programmatically takes the USB bus out of thi suspend state.
+
+ * Valid In Asynchronous Callback: YES (if cb supplied)
+ * Nestable: YES
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE
+ * CY_AS_ERROR_INVALID_IN_CALLBACK
+ * CY_AS_ERROR_OUT_OF_MEMORY
+ * CY_AS_ERROR_INVALID_RESPONSE
+ * CY_AS_ERROR_NOT_IN_SUSPEND
+
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_signal_remote_wakeup(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ This function sets the threshold levels for mass storage progress
+ reports from the West Bridge.
+
+ Description
+ The West Bridge firmware can be configured to track the amount of
+ read/write activity on the mass storage device, and send progress
+ reports when the activity level has crossed a threshold level.
+ This function sets the threshold levels for the progress reports.
+ Set wr_sectors and rd_sectors to 0, if the progress reports are to
+ be turned off.
+
+ * Valid In Asynchronous Callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - the function succeeded
+ * CY_AS_ERROR_NOT_RUNNING - the USB stack is not running
+ * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
+ * the West Bridge device
+ * CY_AS_ERROR_INVALID_HANDLE - Bad handle
+ * CY_AS_ERROR_INVALID_IN_CALLBACK - Synchronous call made
+ * while in callback
+ * CY_AS_ERROR_OUT_OF_MEMORY - Failed allocating memory for
+ * request processing
+ * CY_AS_ERROR_NOT_SUPPORTED - Firmware version does not support
+ * mass storage progress tracking
+ * CY_AS_ERROR_INVALID_RESPONSE - Unexpected response from
+ * Firmware
+
+ See Also
+ * CyAsUsbMSCProgressData
+ * CyAsEventUsbMSCProgress
+*/
+EXTERN cy_as_return_status_t
+cy_as_usb_set_m_s_report_threshold(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Number of sectors written before report is sent */
+ uint32_t wr_sectors,
+ /* Number of sectors read before report is sent */
+ uint32_t rd_sectors,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+/* Summary
+ Specify which of the partitions on a partitioned mass storage
+ device should be made visible to USB.
+
+ Description
+ West Bridge firmware supports the creation of upto two
+ partitions on mass storage devices connected to the West Bridge
+ device. When there are two partitions on a device, the user can
+ choose which of these partitions should be made visible to the
+ USB host through the USB mass storage interface. This function
+ allows the user to configure the partitions that should be
+ enumerated. At least one partition should be selected through
+ this API. If neither partition needs to be enumerated, use
+ CyAsUsbSetEnumConfig to control this.
+
+ * Valid in Asynchronous callback: Yes (if cb supplied)
+ * Nestable: Yes
+
+ Returns
+ * CY_AS_ERROR_SUCCESS - operation completed successfully
+ * CY_AS_ERROR_INVALID_HANDLE - invalid handle to the West
+ * Bridge device
+ * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not
+ * been configured
+ * CY_AS_ERROR_NO_FIRMWARE - no firmware running on West
+ * Bridge device
+ * CY_AS_ERROR_NOT_RUNNING - USB stack has not been started
+ * CY_AS_ERROR_IN_SUSPEND - West Bridge device is in
+ * suspend mode
+ * CY_AS_ERROR_INVALID_CALL_SEQUENCE - this API has to be
+ * called before CyAsUsbSetEnumConfig
+ * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to
+ * process the request
+ * CY_AS_ERROR_NO_SUCH_UNIT - Storage device addressed has
+ * not been partitioned
+ * CY_AS_ERROR_NOT_SUPPORTED - operation is not supported by
+ * active device/firmware.
+
+ See Also
+ * CyAsStorageCreatePPartition
+ * CyAsStorageRemovePPartition
+ * CyAsUsbMsType_t
+ */
+EXTERN cy_as_return_status_t
+cy_as_usb_select_m_s_partitions(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* Bus index of the device being addressed */
+ cy_as_bus_number_t bus,
+ /* Device id of the device being addressed */
+ uint32_t device,
+ /* Selection of partitions to be enumerated */
+ cy_as_usb_m_s_type_t type,
+ /* The callback, if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ );
+
+extern cy_as_media_type
+cy_as_storage_get_media_from_address(uint16_t v) ;
+
+extern cy_as_bus_number_t
+cy_as_storage_get_bus_from_address(uint16_t v) ;
+
+extern uint32_t
+cy_as_storage_get_device_from_address(uint16_t v) ;
+
+/* For supporting deprecated functions */
+#include "cyasusb_dep.h"
+
+#include "cyas_cplus_end.h"
+
+#endif /* _INCLUDED_CYASUSB_H_ */
diff --git a/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb_dep.h b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb_dep.h
new file mode 100644
index 000000000000..0ee18e8ba1bd
--- /dev/null
+++ b/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasusb_dep.h
@@ -0,0 +1,224 @@
+/* Cypress West Bridge API header file (cyasusb_dep.h)
+## ===========================
+## Copyright (C) 2010 Cypress Semiconductor
+##
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; either version 2
+## of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin Street
+## Fifth Floor, Boston, MA 02110-1301, USA.
+## ===========================
+*/
+
+/*
+ * This header will contain Antioch specific declaration
+ * of the APIs that are deprecated in Astoria SDK. This is
+ * for maintaining backward compatibility.
+ */
+
+#ifndef __INCLUDED_CYASUSB_DEP_H__
+#define __INCLUDED_CYASUSB_DEP_H__
+
+#ifndef __doxygen__
+
+/*
+ This data structure is the data passed via the evdata
+ paramater on a usb event callback for the inquiry request.
+*/
+
+typedef struct cy_as_usb_inquiry_data_dep {
+ /* The media for the event */
+ cy_as_media_type media ;
+ /* The EVPD bit from the SCSI INQUIRY request */
+ uint8_t evpd ;
+ /* The codepage in the inquiry request */
+ uint8_t codepage ;
+ /* This bool must be set to CyTrue indicate
+ * that the inquiry data was changed */
+ cy_bool updated ;
+ /* The length of the data */
+ uint16_t length ;
+ /* The inquiry data */
+ void *data ;
+} cy_as_usb_inquiry_data_dep ;
+
+
+typedef struct cy_as_usb_unknown_command_data_dep {
+ /* The media for the event */
+ cy_as_media_type media ;
+ /* The length of the requst (should be 16 bytes) */
+ uint16_t reqlen ;
+ /* The request */
+ void *request ;
+ /* The returned status value for the command */
+ uint8_t status ;
+ /* If status is failed, the sense key */
+ uint8_t key ;
+ /* If status is failed, the additional sense code */
+ uint8_t asc ;
+ /* If status if failed, the additional sense code qualifier */
+ uint8_t ascq ;
+} cy_as_usb_unknown_command_data_dep ;
+
+
+typedef struct cy_as_usb_start_stop_data_dep {
+ /* The media type for the event */
+ cy_as_media_type media ;
+ /* CyTrue means start request, CyFalse means stop request */
+ cy_bool start ;
+ /* CyTrue means LoEj bit set, otherwise false */
+ cy_bool loej ;
+} cy_as_usb_start_stop_data_dep ;
+
+
+typedef struct cy_as_usb_enum_control_dep {
+ /* The bits in this member determine which mass storage devices
+ are enumerated. see cy_as_usb_mass_storage_enum for more details. */
+ uint8_t enum_mass_storage ;
+ /* If true, West Bridge will control enumeration. If this is false the
+ pport controls enumeration. if the P port is controlling
+ enumeration, traffic will be received via endpoint zero. */
+ cy_bool antioch_enumeration ;
+ /* This is the interface # to use for the mass storage interface,
+ if mass storage is enumerated. if mass storage is not enumerated
+ this value should be zero. */
+ uint8_t mass_storage_interface ;
+ /* If true, Inquiry, START/STOP, and unknown mass storage
+ requests cause a callback to occur for handling by the
+ baseband processor. */
+ cy_bool mass_storage_callbacks ;
+} cy_as_usb_enum_control_dep ;
+
+
+typedef void (*cy_as_usb_event_callback_dep)(
+ /* Handle to the device to configure */
+ cy_as_device_handle handle,
+ /* The event type being reported */
+ cy_as_usb_event ev,
+ /* The data assocaited with the event being reported */
+ void *evdata
+) ;
+
+
+
+/* Register Callback api */
+EXTERN cy_as_return_status_t
+cy_as_usb_register_callback_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The function to call */
+ cy_as_usb_event_callback_dep callback
+ ) ;
+
+
+extern cy_as_return_status_t
+cy_as_usb_set_enum_config_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The USB configuration information */
+ cy_as_usb_enum_control_dep *config_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+
+extern cy_as_return_status_t
+cy_as_usb_get_enum_config_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The return value for USB congifuration information */
+ cy_as_usb_enum_control_dep *config_p,
+ /* The callback if async call */
+ cy_as_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+extern cy_as_return_status_t
+cy_as_usb_get_descriptor_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The type of descriptor */
+ cy_as_usb_desc_type type,
+ /* Index for string descriptor */
+ uint8_t index,
+ /* The buffer to hold the returned descriptor */
+ void *desc_p,
+ /* This is an input and output parameter. Before the code this pointer
+ points to a uint32_t that contains the length of the buffer. after
+ the call, this value contains the amount of data actually returned. */
+ uint32_t *length_p
+ ) ;
+
+extern cy_as_return_status_t
+cy_as_usb_set_stall_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_usb_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+) ;
+
+EXTERN cy_as_return_status_t
+cy_as_usb_clear_stall_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_usb_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_usb_set_nak_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_usb_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+) ;
+
+EXTERN cy_as_return_status_t
+cy_as_usb_clear_nak_dep(
+ /* Handle to the West Bridge device */
+ cy_as_device_handle handle,
+ /* The endpoint of interest */
+ cy_as_end_point_number_t ep,
+ /* The callback if async call */
+ cy_as_usb_function_callback cb,
+ /* Client supplied data */
+ uint32_t client
+ ) ;
+
+EXTERN cy_as_return_status_t
+cy_as_usb_select_m_s_partitions_dep(
+ cy_as_device_handle handle,
+ cy_as_media_type media,
+ uint32_t device,
+ cy_as_usb_m_s_type_t type,
+ cy_as_function_callback cb,
+ uint32_t client
+ ) ;
+
+#endif /*__doxygen*/
+
+#endif /*__INCLUDED_CYANSTORAGE_DEP_H__*/
diff --git a/drivers/staging/xgifb/XGI_accel.h b/drivers/staging/xgifb/XGI_accel.h
index 28c057994b37..5a0395bef2f2 100644
--- a/drivers/staging/xgifb/XGI_accel.h
+++ b/drivers/staging/xgifb/XGI_accel.h
@@ -179,7 +179,7 @@
/* TW: BR(16)+2 = 0x8242 */
-int xgiCmdQueLen;
+static int xgiCmdQueLen;
#define XGI300Idle \
{ \
@@ -488,6 +488,7 @@ int xgiCmdQueLen;
int XGIfb_initaccel(void);
void XGIfb_syncaccel(void);
+int fbcon_XGI_sync(struct fb_info *info);
extern struct video_info xgi_video_info;
diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h
index fd1152eb2c92..72448e88fd8b 100644
--- a/drivers/staging/xgifb/XGI_main.h
+++ b/drivers/staging/xgifb/XGI_main.h
@@ -46,8 +46,7 @@
#define XGI_IOTYPE2 __iomem
#define XGIINITSTATIC static
-static struct pci_device_id __devinitdata xgifb_pci_table[] = {
-
+static DEFINE_PCI_DEVICE_TABLE(xgifb_pci_table) = {
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_27, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
{ PCI_VENDOR_ID_XG, PCI_DEVICE_ID_XG_40, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
@@ -351,20 +350,17 @@ static int enable_dstn = 0;
static int XGIfb_ypan = -1;
-int XGIfb_accel = 0;
-
-
static int XGIfb_hwcursor_size = 0;
static int XGIfb_CRT2_write_enable = 0;
-int XGIfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */
-int XGIfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */
+static int XGIfb_crt2type = -1; /* TW: CRT2 type (for overriding autodetection) */
+static int XGIfb_tvplug = -1; /* PR: Tv plug type (for overriding autodetection) */
-int XGIfb_queuemode = -1; /* TW: Use MMIO queue mode by default (310/325 series only) */
+static int XGIfb_queuemode = -1; /* TW: Use MMIO queue mode by default (310/325 series only) */
-unsigned char XGIfb_detectedpdc = 0;
+static unsigned char XGIfb_detectedpdc = 0;
-unsigned char XGIfb_detectedlcda = 0xff;
+static unsigned char XGIfb_detectedlcda = 0xff;
@@ -373,10 +369,10 @@ unsigned char XGIfb_detectedlcda = 0xff;
/* XGIfb_info XGIfbinfo; */
/* TW: Hardware extension; contains data on hardware */
-struct xgi_hw_device_info XGIhw_ext;
+static struct xgi_hw_device_info XGIhw_ext;
/* TW: XGI private structure */
-struct vb_device_info XGI_Pr;
+static struct vb_device_info XGI_Pr;
/* card parameters */
static unsigned long XGIfb_mmio_size = 0;
@@ -393,7 +389,7 @@ typedef enum _XGI_CMDTYPE {
/* mode table */
/* NOT const - will be patched for 1280x960 mode number chaos reasons */
-struct _XGIbios_mode {
+static struct _XGIbios_mode {
char name[15];
u8 mode_no;
u16 vesa_mode_no_1; /* "XGI defined" VESA mode number */
@@ -492,17 +488,17 @@ static int xgifb_mode_idx = 1;
#else
static int xgifb_mode_idx = -1; /* Use a default mode if we are inside the kernel */
#endif
-u8 XGIfb_mode_no = 0;
-u8 XGIfb_rate_idx = 0;
+static u8 XGIfb_mode_no = 0;
+static u8 XGIfb_rate_idx = 0;
/* TW: CR36 evaluation */
-const unsigned short XGI300paneltype[] =
+static const unsigned short XGI300paneltype[] =
{ LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768,
LCD_1024x768, LCD_1024x768, LCD_1024x768,
LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768 };
-const unsigned short XGI310paneltype[] =
+static const unsigned short XGI310paneltype[] =
{ LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960,
LCD_1152x768, LCD_1400x1050,LCD_1280x768, LCD_1600x1200,
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index 976c39bb2866..7cd3e959e9f3 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -44,6 +44,8 @@
#include "XGI_main.h"
#include "vb_util.h"
+int XGIfb_accel = 0;
+
#define Index_CR_GPIO_Reg1 0x48
#define Index_CR_GPIO_Reg2 0x49
@@ -161,8 +163,9 @@ struct video_info xgi_video_info;
/* --------------- Hardware Access Routines -------------------------- */
-int
-XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, struct xgi_hw_device_info *HwDeviceExtension,
+static int
+XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
+ struct xgi_hw_device_info *HwDeviceExtension,
unsigned char modeno, unsigned char rateindex)
{
unsigned short ModeNo = modeno;
@@ -196,8 +199,9 @@ XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, struct xgi_hw_device_in
return(Clock);
}
-int
-XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, struct xgi_hw_device_info *HwDeviceExtension,
+static int
+XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
+ struct xgi_hw_device_info *HwDeviceExtension,
unsigned char modeno, unsigned char rateindex,
u32 *left_margin, u32 *right_margin,
u32 *upper_margin, u32 *lower_margin,
@@ -377,7 +381,7 @@ XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, struct xgi_hw_device_inf
-void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
+static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
{
XGI_Pr->RelIO = BaseAddr;
XGI_Pr->P3c4 = BaseAddr + 0x14;
@@ -570,7 +574,7 @@ static void XGIfb_search_vesamode(unsigned int vesamode)
if(!j) printk(KERN_INFO "XGIfb: Invalid VESA mode 0x%x'\n", vesamode);
}
-int XGIfb_GetXG21LVDSData(void)
+static int XGIfb_GetXG21LVDSData(void)
{
u8 tmp;
unsigned char *pData;
@@ -2057,9 +2061,9 @@ static int XGIfb_heap_init(void)
int agp_enabled = 1;
u32 agp_size;
- unsigned long *cmdq_baseport = 0;
- unsigned long *read_port = 0;
- unsigned long *write_port = 0;
+ unsigned long *cmdq_baseport = NULL;
+ unsigned long *read_port = NULL;
+ unsigned long *write_port = NULL;
XGI_CMDTYPE cmd_type;
#ifndef AGPOFF
struct agp_kern_info *agp_info;
@@ -2827,7 +2831,7 @@ XGIINITSTATIC int __init XGIfb_setup(char *options)
static unsigned char VBIOS_BUF[65535];
-unsigned char *attempt_map_rom(struct pci_dev *dev, void *copy_address)
+static unsigned char *attempt_map_rom(struct pci_dev *dev, void *copy_address)
{
u32 rom_size = 0;
u32 rom_address = 0;
@@ -2872,7 +2876,8 @@ unsigned char *attempt_map_rom(struct pci_dev *dev, void *copy_address)
return copy_address;
}
-int __devinit xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+static int __devinit xgifb_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
{
u16 reg16;
u8 reg, reg1;
@@ -3641,7 +3646,7 @@ MODULE_PARM_DESC(nocrt2rate,
-int __init xgifb_init_module(void)
+static int __init xgifb_init_module(void)
{
printk("\nXGIfb_init_module");
if(mode)
diff --git a/drivers/staging/xgifb/vb_ext.c b/drivers/staging/xgifb/vb_ext.c
index 1ecf9e3e85fb..9774c41ba4c6 100644
--- a/drivers/staging/xgifb/vb_ext.c
+++ b/drivers/staging/xgifb/vb_ext.c
@@ -44,7 +44,7 @@ unsigned char XGI_Is301LV(struct vb_device_info *);
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
+static unsigned char XGINew_Is301B(struct vb_device_info *pVBInfo)
{
unsigned short flag ;
@@ -816,7 +816,8 @@ unsigned char XGINew_SenseHiTV(struct xgi_hw_device_info *HwDeviceExtension, str
; DX: PAnel V. resolution
;-----------------------------------------------------------------------------
*/
-void XGI_XG21Fun14Sub70(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
+static void XGI_XG21Fun14Sub70(struct vb_device_info *pVBInfo,
+ PX86_REGS pBiosArguments)
{
unsigned short ModeIdIndex;
@@ -859,7 +860,8 @@ void XGI_XG21Fun14Sub70(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments
;
;-----------------------------------------------------------------------------
*/
-void XGI_XG21Fun14Sub71(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
+static void XGI_XG21Fun14Sub71(struct vb_device_info *pVBInfo,
+ PX86_REGS pBiosArguments)
{
unsigned short EModeCount;
@@ -905,7 +907,8 @@ void XGI_XG21Fun14Sub71(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments
;
;-----------------------------------------------------------------------------
*/
-void XGI_XG21Fun14Sub72(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
+static void XGI_XG21Fun14Sub72(struct vb_device_info *pVBInfo,
+ PX86_REGS pBiosArguments)
{
unsigned short ModeIdIndex, resindex;
unsigned short ModeNo;
@@ -964,7 +967,8 @@ void XGI_XG21Fun14Sub72(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments
; BX[6]: *Value1 D[6] Panel H. Polarity
;-----------------------------------------------------------------------------
*/
-void XGI_XG21Fun14Sub73(struct vb_device_info *pVBInfo, PX86_REGS pBiosArguments)
+static void XGI_XG21Fun14Sub73(struct vb_device_info *pVBInfo,
+ PX86_REGS pBiosArguments)
{
unsigned char Select;
diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
index e02722d05f68..e0153d3cc859 100644
--- a/drivers/staging/xgifb/vb_init.c
+++ b/drivers/staging/xgifb/vb_init.c
@@ -18,7 +18,7 @@
-unsigned char XGINew_ChannelAB, XGINew_DataBusWidth;
+static unsigned char XGINew_ChannelAB, XGINew_DataBusWidth;
unsigned short XGINew_DRAMType[17][5] = {
{0x0C, 0x0A, 0x02, 0x40, 0x39}, {0x0D, 0x0A, 0x01, 0x40, 0x48},
@@ -31,7 +31,7 @@ unsigned short XGINew_DRAMType[17][5] = {
{0x0B, 0x08, 0x01, 0x04, 0x20}, {0x0A, 0x08, 0x01, 0x02, 0x10},
{0x09, 0x08, 0x01, 0x01, 0x00} };
-unsigned short XGINew_SDRDRAM_TYPE[13][5] = {
+static unsigned short XGINew_SDRDRAM_TYPE[13][5] = {
{ 2, 12, 9, 64, 0x35},
{ 1, 13, 9, 64, 0x44},
{ 2, 12, 8, 32, 0x31},
@@ -46,19 +46,19 @@ unsigned short XGINew_SDRDRAM_TYPE[13][5] = {
{ 1, 10, 8, 4, 0x10},
{ 1, 9, 8, 2, 0x00} };
-unsigned short XGINew_DDRDRAM_TYPE[4][5] = {
+static unsigned short XGINew_DDRDRAM_TYPE[4][5] = {
{ 2, 12, 9, 64, 0x35},
{ 2, 12, 8, 32, 0x31},
{ 2, 11, 8, 16, 0x21},
{ 2, 9, 8, 4, 0x01} };
-unsigned short XGINew_DDRDRAM_TYPE340[4][5] = {
+static unsigned short XGINew_DDRDRAM_TYPE340[4][5] = {
{ 2, 13, 9, 64, 0x45},
{ 2, 12, 9, 32, 0x35},
{ 2, 12, 8, 16, 0x31},
{ 2, 11, 8, 8, 0x21} };
-unsigned short XGINew_DDRDRAM_TYPE20[12][5] = {
+static unsigned short XGINew_DDRDRAM_TYPE20[12][5] = {
{ 2, 14, 11, 128, 0x5D},
{ 2, 14, 10, 64, 0x59},
{ 2, 13, 11, 64, 0x4D},
@@ -89,8 +89,10 @@ void XGINew_CheckBusWidth_310(struct vb_device_info *) ;
int XGINew_SDRSizing(struct vb_device_info *);
int XGINew_DDRSizing(struct vb_device_info *);
void XGINew_EnableRefresh(struct xgi_hw_device_info *, struct vb_device_info *);
-int XGINew_RAMType; /*int ModeIDOffset,StandTable,CRT1Table,ScreenOffset,REFIndex;*/
-unsigned long UNIROM; /* UNIROM */
+static int XGINew_RAMType; /*int ModeIDOffset,StandTable,CRT1Table,ScreenOffset,REFIndex;*/
+#if 0
+static unsigned long UNIROM;
+#endif
unsigned char ChkLFB(struct vb_device_info *);
void XGINew_Delay15us(unsigned long);
void SetPowerConsume(struct xgi_hw_device_info *HwDeviceExtension,
@@ -106,7 +108,7 @@ unsigned char GetXG21FPBits(struct vb_device_info *pVBInfo);
void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) ;
unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo);
-void DelayUS(unsigned long MicroSeconds)
+static void DelayUS(unsigned long MicroSeconds)
{
udelay(MicroSeconds);
}
@@ -148,7 +150,7 @@ unsigned char XGIInitNew(struct xgi_hw_device_info *HwDeviceExtension)
/* if ( pVBInfo->ROMAddr == 0 ) */
/* return( 0 ) ; */
- if (pVBInfo->FBAddr == 0) {
+ if (pVBInfo->FBAddr == NULL) {
printk("\n pVBInfo->FBAddr == 0 ");
return 0;
}
@@ -617,7 +619,7 @@ unsigned char XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtensio
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned char XGINew_Get310DRAMType(struct vb_device_info *pVBInfo)
+static unsigned char XGINew_Get310DRAMType(struct vb_device_info *pVBInfo)
{
unsigned char data ;
@@ -653,7 +655,7 @@ void XGINew_Delay15us(unsigned long ulMicrsoSec)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_SDR_MRS(struct vb_device_info *pVBInfo)
+static void XGINew_SDR_MRS(struct vb_device_info *pVBInfo)
{
unsigned short data ;
@@ -673,7 +675,7 @@ void XGINew_SDR_MRS(struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR1x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
+static void XGINew_DDR1x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
{
XGINew_SetReg1( P3c4 , 0x18 , 0x01 ) ;
XGINew_SetReg1( P3c4 , 0x19 , 0x20 ) ;
@@ -711,7 +713,8 @@ void XGINew_DDR1x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR2x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
+static void XGINew_DDR2x_MRS_340(unsigned long P3c4,
+ struct vb_device_info *pVBInfo)
{
XGINew_SetReg1( P3c4 , 0x18 , 0x00 ) ;
XGINew_SetReg1( P3c4 , 0x19 , 0x20 ) ;
@@ -740,8 +743,10 @@ void XGINew_DDR2x_MRS_340(unsigned long P3c4, struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDRII_Bootup_XG27(struct xgi_hw_device_info *HwDeviceExtension,
- unsigned long P3c4, struct vb_device_info *pVBInfo)
+static void XGINew_DDRII_Bootup_XG27(
+ struct xgi_hw_device_info *HwDeviceExtension,
+ unsigned long P3c4,
+ struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = P3c4 + 0x10 ;
XGINew_RAMType = ( int )XGINew_GetXG20DRAMType( HwDeviceExtension , pVBInfo ) ;
@@ -819,7 +824,7 @@ void XGINew_DDRII_Bootup_XG27(struct xgi_hw_device_info *HwDeviceExtension,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
+static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
unsigned long P3c4, struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = P3c4 + 0x10 ;
@@ -866,13 +871,14 @@ void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
DelayUS( 200 ) ;
}
+#if 0
/* --------------------------------------------------------------------- */
/* Function : XGINew_DDR2_MRS_XG20 */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR2_MRS_XG27(struct xgi_hw_device_info *HwDeviceExtension,
+static void XGINew_DDR2_MRS_XG27(struct xgi_hw_device_info *HwDeviceExtension,
unsigned long P3c4, struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = P3c4 + 0x10 ;
@@ -944,6 +950,7 @@ void XGINew_DDR2_MRS_XG27(struct xgi_hw_device_info *HwDeviceExtension,
XGINew_SetReg1( P3c4 , 0x1B , 0x03 ) ; /* SR1B */
}
+#endif
/* --------------------------------------------------------------------- */
/* Function : XGINew_DDR1x_DefaultRegister */
@@ -951,8 +958,10 @@ void XGINew_DDR2_MRS_XG27(struct xgi_hw_device_info *HwDeviceExtension,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR1x_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
- unsigned long Port, struct vb_device_info *pVBInfo)
+static void XGINew_DDR1x_DefaultRegister(
+ struct xgi_hw_device_info *HwDeviceExtension,
+ unsigned long Port,
+ struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = Port ,
P3c4 = Port - 0x10 ;
@@ -1005,15 +1014,17 @@ void XGINew_DDR1x_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
}
}
-
+#if 0
/* --------------------------------------------------------------------- */
/* Function : XGINew_DDR2x_DefaultRegister */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR2x_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
- unsigned long Port, struct vb_device_info *pVBInfo)
+static void XGINew_DDR2x_DefaultRegister(
+ struct xgi_hw_device_info *HwDeviceExtension,
+ unsigned long Port,
+ struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = Port ,
P3c4 = Port - 0x10 ;
@@ -1056,7 +1067,7 @@ void XGINew_DDR2x_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
XGINew_DDR2x_MRS_340( P3c4 , pVBInfo ) ;
}
-
+#endif
/* --------------------------------------------------------------------- */
/* Function : XGINew_DDR2_DefaultRegister */
@@ -1064,8 +1075,10 @@ void XGINew_DDR2x_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR2_DefaultRegister(struct xgi_hw_device_info *HwDeviceExtension,
- unsigned long Port, struct vb_device_info *pVBInfo)
+static void XGINew_DDR2_DefaultRegister(
+ struct xgi_hw_device_info *HwDeviceExtension,
+ unsigned long Port,
+ struct vb_device_info *pVBInfo)
{
unsigned long P3d4 = Port ,
P3c4 = Port - 0x10 ;
@@ -1247,7 +1260,7 @@ void XGINew_SetDRAMDefaultRegister340(struct xgi_hw_device_info *HwDeviceExtensi
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DDR_MRS(struct vb_device_info *pVBInfo)
+static void XGINew_DDR_MRS(struct vb_device_info *pVBInfo)
{
unsigned short data ;
@@ -1315,7 +1328,8 @@ void XGINew_DDR_MRS(struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_VerifyMclk(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+static void XGINew_VerifyMclk(struct xgi_hw_device_info *HwDeviceExtension,
+ struct vb_device_info *pVBInfo)
{
unsigned char *pVideoMemory = pVBInfo->FBAddr ;
unsigned char i, j ;
@@ -1561,7 +1575,7 @@ void XGINew_EnableRefresh(struct xgi_hw_device_info *HwDeviceExtension, struct v
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_DisableChannelInterleaving(int index,
+static void XGINew_DisableChannelInterleaving(int index,
unsigned short XGINew_DDRDRAM_TYPE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1597,7 +1611,7 @@ void XGINew_DisableChannelInterleaving(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_SetDRAMSizingType(int index,
+static void XGINew_SetDRAMSizingType(int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1750,7 +1764,7 @@ void XGINew_CheckBusWidth_310(struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_SetRank(int index,
+static int XGINew_SetRank(int index,
unsigned char RankNo,
unsigned char XGINew_ChannelAB,
unsigned short DRAMTYPE_TABLE[][5],
@@ -1791,7 +1805,7 @@ int XGINew_SetRank(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_SetDDRChannel(int index,
+static int XGINew_SetDDRChannel(int index,
unsigned char ChannelNo,
unsigned char XGINew_ChannelAB,
unsigned short DRAMTYPE_TABLE[][5],
@@ -1831,7 +1845,7 @@ int XGINew_SetDDRChannel(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckColumn(int index,
+static int XGINew_CheckColumn(int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1865,7 +1879,7 @@ int XGINew_CheckColumn(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckBanks(int index,
+static int XGINew_CheckBanks(int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1898,7 +1912,7 @@ int XGINew_CheckBanks(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckRank(int RankNo, int index,
+static int XGINew_CheckRank(int RankNo, int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1934,7 +1948,7 @@ int XGINew_CheckRank(int RankNo, int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckDDRRank(int RankNo, int index,
+static int XGINew_CheckDDRRank(int RankNo, int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -1978,7 +1992,7 @@ int XGINew_CheckDDRRank(int RankNo, int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckRanks(int RankNo, int index,
+static int XGINew_CheckRanks(int RankNo, int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -2006,7 +2020,7 @@ int XGINew_CheckRanks(int RankNo, int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_CheckDDRRanks(int RankNo, int index,
+static int XGINew_CheckDDRRanks(int RankNo, int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -2065,7 +2079,7 @@ int XGINew_SDRSizing(struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned short XGINew_SetDRAMSizeReg(int index,
+static unsigned short XGINew_SetDRAMSizeReg(int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -2116,7 +2130,7 @@ unsigned short XGINew_SetDRAMSizeReg(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned short XGINew_SetDRAMSize20Reg(int index,
+static unsigned short XGINew_SetDRAMSize20Reg(int index,
unsigned short DRAMTYPE_TABLE[][5],
struct vb_device_info *pVBInfo)
{
@@ -2168,8 +2182,9 @@ unsigned short XGINew_SetDRAMSize20Reg(int index,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-int XGINew_ReadWriteRest(unsigned short StopAddr, unsigned short StartAddr,
- struct vb_device_info *pVBInfo)
+static int XGINew_ReadWriteRest(unsigned short StopAddr,
+ unsigned short StartAddr,
+ struct vb_device_info *pVBInfo)
{
int i ;
unsigned long Position = 0 ;
@@ -2205,7 +2220,7 @@ int XGINew_ReadWriteRest(unsigned short StopAddr, unsigned short StartAddr,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
+static unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
{
unsigned char data ;
@@ -2228,7 +2243,8 @@ unsigned char XGINew_CheckFrequence(struct vb_device_info *pVBInfo)
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension,
+ struct vb_device_info *pVBInfo)
{
unsigned char data;
@@ -2672,8 +2688,9 @@ void SetPowerConsume(struct xgi_hw_device_info *HwDeviceExtension,
}
}
-
-void XGINew_InitVBIOSData(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo)
+#if 0
+static void XGINew_InitVBIOSData(struct xgi_hw_device_info *HwDeviceExtension,
+ struct vb_device_info *pVBInfo)
{
/* unsigned long ROMAddr = (unsigned long)HwDeviceExtension->pjVirtualRomBase; */
@@ -2715,6 +2732,7 @@ void XGINew_InitVBIOSData(struct xgi_hw_device_info *HwDeviceExtension, struct v
}
}
+#endif
/* --------------------------------------------------------------------- */
/* Function : ReadVBIOSTablData */
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index d90bf06bf62f..cf6874be90bf 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -124,6 +124,7 @@ void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, str
void XGI_GetLVDSResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo);
void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo);
+unsigned short XGI_GetLVDSOEMTableIndex(struct vb_device_info *pVBInfo);
void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex,
struct xgi_hw_device_info *HwDeviceExtension,
@@ -191,7 +192,7 @@ extern void ReadVBIOSTablData(unsigned char ChipType, struct vb_device_info *pVB
/* unsigned short XGINew_flag_clearbuffer; 0: no clear frame buffer 1:clear frame buffer */
-unsigned short XGINew_MDA_DAC[] = {
+static unsigned short XGINew_MDA_DAC[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
@@ -201,7 +202,7 @@ unsigned short XGINew_MDA_DAC[] = {
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
-unsigned short XGINew_CGA_DAC[] = {
+static unsigned short XGINew_CGA_DAC[] = {
0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
@@ -211,7 +212,7 @@ unsigned short XGINew_CGA_DAC[] = {
0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
-unsigned short XGINew_EGA_DAC[] = {
+static unsigned short XGINew_EGA_DAC[] = {
0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
@@ -221,7 +222,7 @@ unsigned short XGINew_EGA_DAC[] = {
0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
-unsigned short XGINew_VGA_DAC[] = {
+static unsigned short XGINew_VGA_DAC[] = {
0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
0x00, 0x05, 0x08, 0x0B, 0x0E, 0x11, 0x14, 0x18,
@@ -2947,7 +2948,7 @@ void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
LCDPtr = (struct XGI330_LCDDataDesStruct *)XGI_GetLcdPtr(tempbx, ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo);
}
- if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == 0 ) )
+ if ( ( pVBInfo->IF_DEF_OEMUtil == 0 ) || ( LCDPtr == NULL ) )
{
tempbx = 3 ;
if ( pVBInfo->LCDInfo & EnableScalingLCD )
@@ -4058,13 +4059,15 @@ unsigned char XGI_SearchModeID(unsigned short ModeNo,
/* win2000 MM adapter not support standard mode! */
+#if 0
/* --------------------------------------------------------------------- */
/* Function : */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtension,
+static unsigned char XGINew_CheckMemorySize(
+ struct xgi_hw_device_info *HwDeviceExtension,
unsigned short ModeNo,
unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
@@ -4141,7 +4144,7 @@ unsigned char XGINew_CheckMemorySize(struct xgi_hw_device_info *HwDeviceExtensio
else
return 1;
}
-
+#endif
/* --------------------------------------------------------------------- */
/* Function : XGINew_IsLowResolution */
@@ -4415,28 +4418,20 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
}
-
-
-
-
-
-
-
-
+#if 0
/* --------------------------------------------------------------------- */
/* Function : XGI_WaitDisplay */
/* Input : */
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
+static void XGI_WaitDisplay(struct vb_device_info *pVBInfo)
{
while( !( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ) ;
while( XGINew_GetReg2( pVBInfo->P3da ) & 0x01 ) ;
}
-
-
+#endif
/* --------------------------------------------------------------------- */
@@ -5139,7 +5134,7 @@ void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGI_SetCRT2Offset(unsigned short ModeNo,
+static void XGI_SetCRT2Offset(unsigned short ModeNo,
unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex,
struct xgi_hw_device_info *HwDeviceExtension,
@@ -5218,7 +5213,7 @@ unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex,
/* Output : */
/* Description : */
/* --------------------------------------------------------------------- */
-void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
+static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo)
{
XGINew_SetReg1( pVBInfo->Part1Port , 0x01 , 0x3B ) ; /* threshold high ,disable auto threshold */
XGINew_SetRegANDOR( pVBInfo->Part1Port , 0x02 , ~( 0x3F ) , 0x04 ) ; /* threshold low default 04h */
@@ -7143,7 +7138,7 @@ void *XGI_GetLcdPtr(unsigned short BX,
modeflag ,
table ;
- struct XGI330_LCDDataTablStruct *tempdi = 0 ;
+ struct XGI330_LCDDataTablStruct *tempdi = NULL;
tempbx = BX;
@@ -7224,14 +7219,14 @@ void *XGI_GetLcdPtr(unsigned short BX,
case 7:
case 8:
case 9:
- tempdi = 0 ;
+ tempdi = NULL;
break ;
default:
break ;
}
- if ( tempdi == 0x00 ) /* OEMUtil */
- return 0 ;
+ if ( tempdi == NULL ) /* OEMUtil */
+ return NULL;
table = tempbx ;
i = 0 ;
@@ -7625,7 +7620,7 @@ void *XGI_GetLcdPtr(unsigned short BX,
break ;
}
}
- return 0 ;
+ return NULL;
}
@@ -7641,7 +7636,7 @@ void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
struct vb_device_info *pVBInfo)
{
unsigned short i , tempdx , tempbx , tempal , modeflag , table ;
- struct XGI330_TVDataTablStruct *tempdi = 0 ;
+ struct XGI330_TVDataTablStruct *tempdi = NULL;
tempbx = BX ;
@@ -7662,14 +7657,14 @@ void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
switch( tempbx )
{
case 0:
- tempdi = 0 ; /*EPLCHTVCRT1Ptr_H;*/
+ tempdi = NULL; /*EPLCHTVCRT1Ptr_H;*/
if ( pVBInfo->IF_DEF_CH7007 == 1 )
{
tempdi = XGI_EPLCHTVCRT1Ptr;
}
break ;
case 1:
- tempdi = 0 ; /*EPLCHTVCRT1Ptr_V;*/
+ tempdi = NULL; /*EPLCHTVCRT1Ptr_V;*/
if ( pVBInfo->IF_DEF_CH7007 == 1 )
{
tempdi = XGI_EPLCHTVCRT1Ptr;
@@ -7679,13 +7674,13 @@ void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
tempdi = XGI_EPLCHTVDataPtr ;
break ;
case 3:
- tempdi = 0 ;
+ tempdi = NULL;
break ;
case 4:
tempdi = XGI_TVDataTable ;
break ;
case 5:
- tempdi = 0 ;
+ tempdi = NULL;
break ;
case 6:
tempdi = XGI_EPLCHTVRegPtr ;
@@ -7694,8 +7689,8 @@ void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
break ;
}
- if ( tempdi == 0x00 ) /* OEMUtil */
- return( 0 ) ;
+ if ( tempdi == NULL ) /* OEMUtil */
+ return NULL;
tempdx = pVBInfo->TVInfo ;
@@ -7793,7 +7788,7 @@ void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
else if( table == 0x06 )
{
}
- return( 0 ) ;
+ return NULL;
}
@@ -7913,7 +7908,7 @@ void XGI_SetPanelPower(unsigned short tempah, unsigned short tempbl, struct vb_d
XGINew_SetRegANDOR( pVBInfo->P3c4 , 0x11 , tempbl , tempah ) ;
}
-unsigned char XG21GPIODataTransfer(unsigned char ujDate)
+static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
{
unsigned char ujRet = 0;
unsigned char i = 0;
diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h
index 510ef7678685..78b1c796f01e 100644
--- a/drivers/staging/xgifb/vb_table.h
+++ b/drivers/staging/xgifb/vb_table.h
@@ -1,7 +1,7 @@
#define Tap4
-struct XGI_MCLKDataStruct XGI330New_MCLKData[] =
+static struct XGI_MCLKDataStruct XGI330New_MCLKData[] =
{
{ 0x5c,0x23,0x01,166},
{ 0x5c,0x23,0x01,166},
@@ -13,7 +13,7 @@ struct XGI_MCLKDataStruct XGI330New_MCLKData[] =
{ 0x29,0x01,0x81,300}
};
//yilin modify for xgi20
-struct XGI_MCLKDataStruct XGI340New_MCLKData[] =
+static struct XGI_MCLKDataStruct XGI340New_MCLKData[] =
{
{ 0x16,0x01,0x01,166},
{ 0x19,0x02,0x01,124},
@@ -25,7 +25,7 @@ struct XGI_MCLKDataStruct XGI340New_MCLKData[] =
{ 0x5c,0x23,0x01,166}
};
-struct XGI_MCLKDataStruct XGI27New_MCLKData[] =
+static struct XGI_MCLKDataStruct XGI27New_MCLKData[] =
{
{ 0x5c,0x23,0x01,166},
{ 0x19,0x02,0x01,124},
@@ -37,7 +37,7 @@ struct XGI_MCLKDataStruct XGI27New_MCLKData[] =
{ 0x5c,0x23,0x01,166}
};
-struct XGI_ECLKDataStruct XGI330_ECLKData[] =
+static struct XGI_ECLKDataStruct XGI330_ECLKData[] =
{
{ 0x7c,0x08,0x01,200},
{ 0x7c,0x08,0x01,200},
@@ -49,7 +49,7 @@ struct XGI_ECLKDataStruct XGI330_ECLKData[] =
{ 0x29,0x01,0x81,300}
};
//yilin modify for xgi20
-struct XGI_ECLKDataStruct XGI340_ECLKData[] =
+static struct XGI_ECLKDataStruct XGI340_ECLKData[] =
{
{ 0x5c,0x23,0x01,166},
{ 0x55,0x84,0x01,123},
@@ -63,14 +63,14 @@ struct XGI_ECLKDataStruct XGI340_ECLKData[] =
-unsigned char XGI340_SR13[4][8] = {
+static unsigned char XGI340_SR13[4][8] = {
{0x35,0x45,0xb1,0x00,0x00,0x00,0x00,0x00},/* SR13 */
{0x41,0x51,0x5c,0x00,0x00,0x00,0x00,0x00},/* SR14 */
{0x31,0x42,0x42,0x00,0x00,0x00,0x00,0x00},/* SR18 */
{0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00}/* SR1B */
};
-unsigned char XGI340_cr41[24][8] =
+static unsigned char XGI340_cr41[24][8] =
{{0x20,0x50,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
{0xc4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 2 CR8B */
@@ -98,7 +98,7 @@ unsigned char XGI340_cr41[24][8] =
};
-unsigned char XGI27_cr41[24][8] =
+static unsigned char XGI27_cr41[24][8] =
{
{0x20,0x40,0x60,0x00,0x00,0x00,0x00,0x00},/* 0 CR41 */
{0xC4,0x40,0x84,0x00,0x00,0x00,0x00,0x00},/* 1 CR8A */
@@ -126,7 +126,7 @@ unsigned char XGI27_cr41[24][8] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* 23 CRC5 */
};
-unsigned char XGI340_CR6B[8][4] = {
+static unsigned char XGI340_CR6B[8][4] = {
{0xaa,0xaa,0xaa,0xaa},
{0xaa,0xaa,0xaa,0xaa},
{0xaa,0xaa,0xaa,0xaa},
@@ -137,7 +137,7 @@ unsigned char XGI340_CR6B[8][4] = {
{0x00,0x00,0x00,0x00}
};
-unsigned char XGI340_CR6E[8][4] = {
+static unsigned char XGI340_CR6E[8][4] = {
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00},
@@ -148,7 +148,7 @@ unsigned char XGI340_CR6E[8][4] = {
{0x00,0x00,0x00,0x00}
};
-unsigned char XGI340_CR6F[8][32] = {
+static unsigned char XGI340_CR6F[8][32] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -159,7 +159,7 @@ unsigned char XGI340_CR6F[8][32] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
-unsigned char XGI340_CR89[8][2] = {
+static unsigned char XGI340_CR89[8][2] = {
{0x00,0x00},
{0x00,0x00},
{0x00,0x00},
@@ -170,12 +170,14 @@ unsigned char XGI340_CR89[8][2] = {
{0x00,0x00}
};
/* CR47,CR48,CR49,CR4A,CR4B,CR4C,CR70,CR71,CR74,CR75,CR76,CR77 */
-unsigned char XGI340_AGPReg[12] = {0x28, 0x23, 0x00, 0x20, 0x00, 0x20, 0x00,
+static unsigned char XGI340_AGPReg[12] = {
+ 0x28, 0x23, 0x00, 0x20, 0x00, 0x20, 0x00,
0x05, 0xd0, 0x10, 0x10, 0x00};
-unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83};
+static unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83};
-unsigned char XGI330_SR15_1[8][8] = {
+#if 0
+static unsigned char XGI330_SR15_1[8][8] = {
{0x0,0x0,0x00,0x00,0x20,0x20,0x00,0x00},
{0x5,0x15,0x15,0x15,0x15,0x15,0x00,0x00},
{0xba,0xba,0xba,0xba,0xBA,0xBA,0x00,0x00},
@@ -186,7 +188,7 @@ unsigned char XGI330_SR15_1[8][8] = {
{0x0,0xa5,0xfb,0xf6,0xF6,0xF6,0x00,0x00}
};
-unsigned char XGI330_cr40_1[15][8] = {
+static unsigned char XGI330_cr40_1[15][8] = {
{0x66,0x40,0x40,0x28,0x24,0x24,0x00,0x00},
{0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
@@ -203,15 +205,16 @@ unsigned char XGI330_cr40_1[15][8] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0xA2,0x00,0x00,0xA2,0xA2,0x00,0x00},
};
+#endif
-unsigned char XGI330_sr25[] = {0x00, 0x0};
-unsigned char XGI330_sr31 = 0xc0;
-unsigned char XGI330_sr32 = 0x11;
-unsigned char XGI330_SR33 = 0x00;
-unsigned char XG40_CRCF = 0x13;
-unsigned char XG40_DRAMTypeDefinition = 0xFF ;
+static unsigned char XGI330_sr25[] = {0x00, 0x0};
+static unsigned char XGI330_sr31 = 0xc0;
+static unsigned char XGI330_sr32 = 0x11;
+static unsigned char XGI330_SR33 = 0x00;
+static unsigned char XG40_CRCF = 0x13;
+static unsigned char XG40_DRAMTypeDefinition = 0xFF ;
-struct XGI_StStruct XGI330_SModeIDTable[] =
+static struct XGI_StStruct XGI330_SModeIDTable[] =
{
{0x01,0x9208,0x01,0x00,0x10,0x00,0x00,0x01,0x00},
{0x01,0x1210,0x14,0x01,0x00,0x01,0x00,0x01,0x00},
@@ -236,7 +239,7 @@ struct XGI_StStruct XGI330_SModeIDTable[] =
};
-struct XGI_ExtStruct XGI330_EModeIDTable[] =
+static struct XGI_ExtStruct XGI330_EModeIDTable[] =
{
{0x6a,0x2212,0x0407,0x3a81,0x0102,0x08,0x07,0x00,0x00,0x07,0x0e},
{0x2e,0x0a1b,0x0306,0x3a57,0x0101,0x08,0x06,0x00,0x00,0x05,0x06},
@@ -308,7 +311,7 @@ struct XGI_ExtStruct XGI330_EModeIDTable[] =
{0xff,0x0000,0x0000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00}
};
-struct XGI_StandTableStruct XGI330_StandTable[] =
+static struct XGI_StandTableStruct XGI330_StandTable[] =
{
/* MD_0_200 */
{
@@ -746,13 +749,13 @@ struct XGI_StandTableStruct XGI330_StandTable[] =
}
};
-struct XGI_TimingHStruct XGI_TimingH[] =
+static struct XGI_TimingHStruct XGI_TimingH[] =
{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
-struct XGI_TimingVStruct XGI_TimingV[] =
+static struct XGI_TimingVStruct XGI_TimingV[] =
{{{0x00,0x00,0x00,0x00,0x00,0x00,0x00}}};
-struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] =
+static struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] =
{
{0x01,0x27,0x91,0x8f,0xc0}, /* 00 */
{0x03,0x4f,0x83,0x8f,0xc0}, /* 01 */
@@ -773,7 +776,7 @@ struct XGI_XG21CRT1Struct XGI_UpdateCRT1Table[] =
{0x59,0x27,0x91,0x8f,0xc0} /* 16 */
};
-struct XGI_CRT1TableStruct XGI_CRT1Table[] =
+static struct XGI_CRT1TableStruct XGI_CRT1Table[] =
{
{{0x2d,0x28,0x90,0x2c,0x90,0x00,0x04,0x00,
0xbf,0x1f,0x9c,0x8e,0x96,0xb9,0x30}}, /* 0x0 */
@@ -921,7 +924,8 @@ struct XGI_CRT1TableStruct XGI_CRT1Table[] =
0x03,0xDE,0xC0,0x84,0xBF,0x04,0x90}} /* 0x47 */
};
-struct XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = {
+#if 0
+static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = {
/* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
{{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
{{ 0x4A,0x77,0xBB,0x94,0x84,0x48,0xFE,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
@@ -932,7 +936,7 @@ struct XGI330_CHTVRegDataStruct XGI_CHTVRegUNTSC[] = {
{{ 0xEE,0x77,0xBB,0x66,0x87,0x32,0x01,0x5A,0x04,0x00,0x80,0x1B,0xD4,0x2F,0x6F,0x00 }}/* 06 (1024x768) ;;5/6/02 */
};
-struct XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[] = {
+static struct XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[] = {
/* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
{{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
{{ 0x49,0x77,0xBB,0x7B,0x84,0x34,0x00,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
@@ -943,7 +947,7 @@ struct XGI330_CHTVRegDataStruct XGI_CHTVRegONTSC[] = {
{{ 0xED,0x77,0xBB,0x66,0x8C,0x21,0x02,0x5A,0x04,0x00,0x80,0x1F,0xA0,0x7E,0x73,0x00 }}/* 06 (1024x768) ;;5/6/02 */
};
-struct XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[] = {
+static struct XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[] = {
/* Index:000h,001h,002h,004h,003h,005h,006h,007h,008h,015h,01Fh,00Ch,00Dh,00Eh,00Fh,010h */
{{ 0x41,0x7F,0xB7,0x34,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 00 (640x200,640x400) */
{{ 0x41,0x7F,0xB7,0x80,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* ; 01 (640x350) */
@@ -954,7 +958,7 @@ struct XGI330_CHTVRegDataStruct XGI_CHTVRegUPAL[] = {
{{ 0xE5,0x7F,0xB7,0x1D,0xA7,0x3E,0x04,0x5A,0x05,0x00,0x80,0x20,0x3E,0xE4,0x22,0x00 }}/* ; 06 (1024x768) ;;1/12/02 */
};
-struct XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[] = {
+static struct XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[] = {
/* Index:000,0x01,0x02,0x04,0x03,0x05,0x06,0x07,0x08,0x15,0x1F,0x0C,0x0D,0x0E,0x0F,0x10h */
{{ 0x41,0x7F,0xB7,0x36,0xAD,0x50,0x34,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 00 (640x200,640x400) */
{{ 0x41,0x7F,0xB7,0x86,0x85,0x50,0x00,0x83,0x05,0x00,0x80,0x00,0x00,0x00,0x00,0x01 }},/* 01 (640x350) */
@@ -964,15 +968,18 @@ struct XGI330_CHTVRegDataStruct XGI_CHTVRegOPAL[] = {
{{ 0xC1,0x7F,0xB7,0x4D,0x8C,0x1E,0x31,0x5A,0x05,0x00,0x80,0x26,0x78,0x19,0x34,0x00 }},/* 05 (800x600) ;;1/12/02 */
{{ 0xE4,0x7F,0xB7,0x1E,0xAF,0x29,0x37,0x5A,0x05,0x00,0x80,0x25,0x8C,0xB2,0x2A,0x00 }}/* 06 (1024x768) ;;1/12/02 */
};
+#endif
-unsigned char XGI_CH7017LV1024x768[] = {0x60, 0x02, 0x00, 0x07, 0x40, 0xED, 0xA3,
+static unsigned char XGI_CH7017LV1024x768[] = {
+ 0x60, 0x02, 0x00, 0x07, 0x40, 0xED, 0xA3,
0xC8, 0xC7, 0xAC, 0xE0, 0x02};
-unsigned char XGI_CH7017LV1400x1050[] = {0x60, 0x03, 0x11, 0x00, 0x40, 0xE3, 0xAD,
+static unsigned char XGI_CH7017LV1400x1050[] = {
+ 0x60, 0x03, 0x11, 0x00, 0x40, 0xE3, 0xAD,
0xDB, 0xF6, 0xAC, 0xE0, 0x02};
/*add for new UNIVGABIOS*/
-struct XGI330_LCDDataStruct XGI_StLCD1024x768Data[] =
+static struct XGI330_LCDDataStruct XGI_StLCD1024x768Data[] =
{
{ 62, 25, 800, 546,1344, 806},
{ 32, 15, 930, 546,1344, 806},
@@ -983,7 +990,7 @@ struct XGI330_LCDDataStruct XGI_StLCD1024x768Data[] =
{ 1, 1,1344, 806,1344, 806}
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] =
{
{ 42, 25,1536, 419,1344, 806}, /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */
{ 48, 25,1536, 369,1344, 806}, /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */
@@ -1011,7 +1018,7 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] =
{ 1, 1,1344, 806,1344, 806}
};*/
-struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] =
+static struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] =
{
{ 1,1,1344,806,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 1,1,1344,806,1344,806 }, /* 01 (320x350,640x350) */
@@ -1022,7 +1029,7 @@ struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] =
{ 1,1,1344,806,1344,806 } /* 06 (1024x768x60Hz) */
};
-struct XGI330_LCDDataStruct XGI_StLCD1280x1024Data[] =
+static struct XGI330_LCDDataStruct XGI_StLCD1280x1024Data[] =
{
{ 22, 5, 800, 510,1650,1088},
{ 22, 5, 800, 510,1650,1088},
@@ -1034,7 +1041,7 @@ struct XGI330_LCDDataStruct XGI_StLCD1280x1024Data[] =
{ 1, 1,1688,1066,1688,1066}
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] =
{
{ 211, 60,1024, 501,1688,1066},
{ 211, 60,1024, 508,1688,1066},
@@ -1046,7 +1053,8 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] =
{ 1, 1,1688,1066,1688,1066}
};
-struct XGI330_LCDDataStruct XGI_St2LCD1280x1024Data[] =
+#if 0
+static struct XGI330_LCDDataStruct XGI_St2LCD1280x1024Data[] =
{
{ 22, 5, 800, 510,1650,1088},
{ 22, 5, 800, 510,1650,1088},
@@ -1057,8 +1065,9 @@ struct XGI330_LCDDataStruct XGI_St2LCD1280x1024Data[] =
{ 16, 9,1266, 804,1688,1072},
{ 1, 1,1688,1066,1688,1066}
};
+#endif
-struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] =
+static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] =
{
{ 1,1,1688,1066,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1,1,1688,1066,1688,1066 }, /* 01 (320x350,640x350) */
@@ -1071,7 +1080,7 @@ struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] =
{ 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataStruct XGI_StLCD1400x1050Data[] =
+static struct XGI330_LCDDataStruct XGI_StLCD1400x1050Data[] =
{
{ 211,100,2100,408,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 211,64,1536,358,1688,1066 }, /* 01 (320x350,640x350) */
@@ -1084,7 +1093,7 @@ struct XGI330_LCDDataStruct XGI_StLCD1400x1050Data[] =
{ 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1400x1050Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1400x1050Data[] =
{
{ 211,100,2100,408,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 211,64,1536,358,1688,1066 }, /* 01 (320x350,640x350) */
@@ -1097,7 +1106,7 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1400x1050Data[] =
{ 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[] =
{
{ 4,1,1620,420,2160,1250 }, /* { 3,1,2160,425,2160,1250 }, // 00 (320x200,320x400,640x200,640x400) // alan 10/14/2003 */
{ 27,7,1920,375,2160,1250 }, /* 01 (320x350,640x350) */
@@ -1111,7 +1120,7 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[] =
{ 1,1,2160,1250,2160,1250 } /* 09 (1600x1200x60Hz) ;302lv */
};
-struct XGI330_LCDDataStruct XGI_StLCD1600x1200Data[] =
+static struct XGI330_LCDDataStruct XGI_StLCD1600x1200Data[] =
{
{ 27,4,800,500,2160,1250 },/* 00 (320x200,320x400,640x200,640x400) */
{ 27,4,800,500,2160,1250 },/* 01 (320x350,640x350) */
@@ -1125,7 +1134,7 @@ struct XGI330_LCDDataStruct XGI_StLCD1600x1200Data[] =
{ 1,1,2160,1250,2160,1250 } /* 09 (1600x1200) */
};
-struct XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[] =
+static struct XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[] =
{
{ 1,1,1688,1066,1688,1066 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1,1,1688,1066,1688,1066 }, /* 01 (320x350,640x350) */
@@ -1138,7 +1147,7 @@ struct XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[] =
{ 1,1,1688,1066,1688,1066 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataStruct XGI_NoScalingData[] =
+static struct XGI330_LCDDataStruct XGI_NoScalingData[] =
{
{ 1, 1, 800, 449, 800, 449},
{ 1, 1, 800, 449, 800, 449},
@@ -1150,7 +1159,7 @@ struct XGI330_LCDDataStruct XGI_NoScalingData[] =
{ 1, 1,1688,1066,1688,1066}
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] =
{
{42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
@@ -1161,7 +1170,8 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] =
{1,1,1312,800,1312,800 } /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LCDDataStruct XGI_StLCD1024x768x75Data[] =
+#if 0
+static struct XGI330_LCDDataStruct XGI_StLCD1024x768x75Data[] =
{
{42,25,1536,419,1344,806 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{48,25,1536,369,1344,806 }, /* ; 01 (320x350,640x350) */
@@ -1171,8 +1181,9 @@ struct XGI330_LCDDataStruct XGI_StLCD1024x768x75Data[] =
{41,25,1024,625,1312,800 }, /* ; 05 (800x600x75Hz) */
{1,1,1312,800,1312,800 } /* ; 06 (1024x768x75Hz) */
};
+#endif
-struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] =
+static struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] =
{
{1,1,1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1,1,1312,800,1312,800}, /* ; 01 (320x350,640x350) */
@@ -1183,7 +1194,7 @@ struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] =
{1,1,1312,800,1312,800} /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024x75Data[] =
+static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024x75Data[] =
{
{211,60,1024,501,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{211,60,1024,508,1688,1066 }, /* ; 01 (320x350,640x350) */
@@ -1195,7 +1206,7 @@ struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024x75Data[] =
{1,1,1688,1066,1688,1066 } /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataStruct XGI_StLCD1280x1024x75Data[] =
+static struct XGI330_LCDDataStruct XGI_StLCD1280x1024x75Data[] =
{
{211,60,1024,501,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{211,60,1024,508,1688,1066 }, /* ; 01 (320x350,640x350) */
@@ -1207,7 +1218,7 @@ struct XGI330_LCDDataStruct XGI_StLCD1280x1024x75Data[] =
{1,1,1688,1066,1688,1066 } /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[] =
+static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[] =
{
{1,1,1688,1066,1688,1066}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1,1,1688,1066,1688,1066}, /* ; 01 (320x350,640x350) */
@@ -1219,7 +1230,7 @@ struct XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[] =
{1,1,1688,1066,1688,1066} /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataStruct XGI_NoScalingDatax75[] =
+static struct XGI330_LCDDataStruct XGI_NoScalingDatax75[] =
{
{1,1,800,449,800,449 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1,1,800,449,800,449 }, /* ; 01 (320x350,640x350) */
@@ -1234,7 +1245,7 @@ struct XGI330_LCDDataStruct XGI_NoScalingDatax75[] =
{1,1,1688,806,1688,806 } /* ; 0A (1280x768x75Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[] =
{
{ 9,1057,0, 771 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 9,1057,0, 771 }, /* ; 01 (320x350,640x350) */
@@ -1245,7 +1256,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[] =
{ 9,1057,805, 770 } /* ; 06 (1024x768x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[] =
{
{ 9,1057,737,703 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 9,1057,686,651 }, /* ; 01 (320x350,640x350) */
@@ -1256,7 +1267,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[] =
{ 9,1057,805,770 } /* ; 06 (1024x768x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[] =
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[] =
{
{ 1152,856,622,587 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 1152,856,597,562 }, /* ; 01 (320x350,640x350) */
@@ -1267,7 +1278,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[] =
{ 0,1048,805,770 } /* ; 06 (1024x768x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] =
{
{ 18,1346,981,940 },/* 00 (320x200,320x400,640x200,640x400) */
{ 18,1346,926,865 },/* 01 (320x350,640x350) */
@@ -1279,7 +1290,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] =
{ 18,1346,1065,1024 }/* 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] =
{
{ 18,1346,970,907 },/* 00 (320x200,320x400,640x200,640x400) */
{ 18,1346,917,854 },/* 01 (320x350,640x350) */
@@ -1291,7 +1302,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] =
{ 18,1346,1065,1024 }/* 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[] =
{
{ 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1368,1008,729,688 }, /* 01 (320x350,640x350) */
@@ -1303,7 +1314,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[] =
{ 18,1346,1065,1024 } /* 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[] =
{
{ 9,1337,981,940 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 9,1337,926,884 }, /* ; 01 (320x350,640x350) alan, 2003/09/30 */
@@ -1315,7 +1326,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[] =
{ 9,1337,1065,1024 } /* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[] =
{
{ 9,1337,970,907 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 9,1337,917,854 }, /* ; 01 (320x350,640x350) */
@@ -1327,7 +1338,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[] =
{ 9,1337,1065,1024 } /* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] =
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] =
{
{ 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1368,1008,729,688 }, /* 01 (320x350,640x350) */
@@ -1339,7 +1350,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] =
{ 9,1337,1065,1024 } /* 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[] =
{
{ 18,1464,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 18,1464,0,1051 }, /* 01 (320x350,640x350) */
@@ -1352,7 +1363,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1400x1050Data[] =
{ 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1400x1050Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1400x1050Data[] =
{
{ 18,1464,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 18,1464,0,1051 }, /* 01 (320x350,640x350) */
@@ -1365,7 +1376,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1400x1050Data[] =
{ 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1400x1050Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1400x1050Data[] =
{
{ 9,1455,0,1051 },/* 00 (320x200,320x400,640x200,640x400) */
{ 9,1455,0,1051 },/* 01 (320x350,640x350) */
@@ -1378,7 +1389,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1400x1050Data[] =
{ 9,1455,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1400x1050Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1400x1050Data[] =
{
{ 9,1455,0,1051 },/* 00 (320x200,320x400,640x200,640x400) */
{ 9,1455,0,1051 },/* 01 (320x350,640x350) */
@@ -1391,7 +1402,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1400x1050Data[] =
{ 9,1455,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[] =
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[] =
{
{ 1308,1068,781,766 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1308,1068,781,766 }, /* 01 (320x350,640x350) */
@@ -1404,7 +1415,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[] =
{ 18,1464,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[] =
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[] =
{
{ 0,1448,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0,1448,0,1051 }, /* 01 (320x350,640x350) */
@@ -1415,7 +1426,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[] =
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[] =
{
{ 18,1682,0,1201 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 18,1682,0,1201 }, /* 01 (320x350,640x350) */
@@ -1429,7 +1440,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[] =
{ 18,1682,0,1201 } /* 09 (1600x1200x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[] =
{
{ 18,1682,1150,1101 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 18,1682,1083,1034 }, /* 01 (320x350,640x350) */
@@ -1443,7 +1454,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[] =
{ 18,1682,0,1201 } /* 09 (1600x1200x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[] =
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[] =
{
{ 9,1673,0,1201 },/* 00 (320x200,320x400,640x200,640x400) */
{ 9,1673,0,1201 },/* 01 (320x350,640x350) */
@@ -1457,7 +1468,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[] =
{ 9,1673,0,1201 } /* 09 (1600x1200x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1600x1200Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1600x1200Data[] =
{
{ 9,1673,1150,1101 },/* 00 (320x200,320x400,640x200,640x400) */
{ 9,1673,1083,1034 },/* 01 (320x350,640x350) */
@@ -1471,7 +1482,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1600x1200Data[] =
{ 9,1673,0,1201 } /* 09 (1600x1200x60Hz) */
};
-struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] =
+static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] =
{
{ 9,657,448,405,96,2 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 9,657,448,355,96,2 }, /* 01 (320x350,640x350) */
@@ -1486,7 +1497,7 @@ struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] =
{ 9,1337,0,771,112,6 } /* 0A (1280x768x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768x75Data[] = /* ;;1024x768x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768x75Data[] = /* ;;1024x768x75Hz */
{
{9,1049,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9,1049,0,769}, /* ; 01 (320x350,640x350) */
@@ -1497,7 +1508,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768x75Data[] = /* ;;1024x768x
{9,1049,0,769} /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768x75Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768x75Data[] =
{
{9,1049,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9,1049,0,769}, /* ; 01 (320x350,640x350) */
@@ -1508,7 +1519,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768x75Data[] =
{9,1049,0,769} /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = /* ;;1024x768x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = /* ;;1024x768x75Hz */
{
{1152,856,622,587}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1152,856,597,562}, /* ; 01 (320x350,640x350) */
@@ -1519,7 +1530,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = /* ;;1024x768x7
{9,1049,0,769} /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024x75Data[] = /* ;;1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024x75Data[] = /* ;;1280x1024x75Hz */
{
{18,1314,0,1025 },/* ; 00 (320x200,320x400,640x200,640x400) */
{18,1314,0,1025 },/* ; 01 (320x350,640x350) */
@@ -1531,7 +1542,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024x75Data[] = /* ;
{18,1314,0,1025 }/* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024x75Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024x75Data[] =
{
{18,1314,0,1025 },/* ; 00 (320x200,320x400,640x200,640x400) */
{18,1314,0,1025 },/* ; 01 (320x350,640x350) */
@@ -1543,7 +1554,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024x75Data[] =
{18,1314,0,1025 }/* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = /* 1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = /* 1280x1024x75Hz */
{
{1368,1008,752,711}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368,1008,729,688}, /* ; 01 (320x350,640x350) */
@@ -1555,7 +1566,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = /* 1280x1024
{18,1314,0,1025} /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024x75Data[] = /* ;;1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024x75Data[] = /* ;;1280x1024x75Hz */
{
{9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
{9,1305,0,1025},/* ; 01 (320x350,640x350) */
@@ -1567,7 +1578,7 @@ struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024x75Data[] = /* ;;1
{9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024x75Data[] =
+static struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024x75Data[] =
{
{9,1305,0,1025},/* ; 00 (320x200,320x400,640x200,640x400) */
{9,1305,0,1025},/* ; 01 (320x350,640x350) */
@@ -1579,7 +1590,7 @@ struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024x75Data[] =
{9,1305,0,1025} /* ; 07 (1280x1024x60Hz) */
};
-struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024x75Data[] = /* 1280x1024x75Hz */
+static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024x75Data[] = /* 1280x1024x75Hz */
{
{1368,1008,752,711}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368,1008,729,688}, /* ; 01 (320x350,640x350) */
@@ -1591,7 +1602,7 @@ struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024x75Data[] = /* 1280x1024x7
{9,1305,0,1025} /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = /* Scaling LCD 75Hz */
+static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = /* Scaling LCD 75Hz */
{
{9,657,448,405,96,2}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9,657,448,355,96,2}, /* ; 01 (320x350,640x350) */
@@ -1606,7 +1617,7 @@ struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = /* Scaling LCD 75Hz
{9,1337,0,771,112,6} /* ; 0A (1280x768x60Hz) */
};
-struct XGI330_TVDataStruct XGI_StPALData[] =
+static struct XGI330_TVDataStruct XGI_StPALData[] =
{
{ 1, 1, 864, 525,1270, 400, 100, 0, 760},
{ 1, 1, 864, 525,1270, 350, 100, 0, 760},
@@ -1616,7 +1627,7 @@ struct XGI330_TVDataStruct XGI_StPALData[] =
{ 1, 1, 864, 525,1270, 600, 50, 0, 0}
};
-struct XGI330_TVDataStruct XGI_ExtPALData[] =
+static struct XGI330_TVDataStruct XGI_ExtPALData[] =
{
{ 2, 1,1080, 463,1270, 500, 50, 0, 50},
{ 15, 7,1152, 413,1270, 500, 50, 0, 50},
@@ -1628,7 +1639,7 @@ struct XGI330_TVDataStruct XGI_ExtPALData[] =
{ 3, 2,1080, 619,1270, 540, 438, 0, 438}
};
-struct XGI330_TVDataStruct XGI_StNTSCData[] =
+static struct XGI330_TVDataStruct XGI_StNTSCData[] =
{
{ 1, 1, 858, 525,1270, 400, 50, 0, 760},
{ 1, 1, 858, 525,1270, 350, 50, 0, 640},
@@ -1637,7 +1648,7 @@ struct XGI330_TVDataStruct XGI_StNTSCData[] =
{ 1, 1, 858, 525,1270, 480, 0, 0, 760}
};
-struct XGI330_TVDataStruct XGI_ExtNTSCData[] =
+static struct XGI330_TVDataStruct XGI_ExtNTSCData[] =
{
{ 9, 5, 1001, 453,1270, 420, 171, 0, 171},
{ 12, 5, 858, 403,1270, 420, 171, 0, 171},
@@ -1650,7 +1661,7 @@ struct XGI330_TVDataStruct XGI_ExtNTSCData[] =
{ 3, 2,1001, 533,1270, 420, 0, 0, 0}
};
-struct XGI330_TVDataStruct XGI_St1HiTVData[] =
+static struct XGI330_TVDataStruct XGI_St1HiTVData[] =
{
{ 1,1,892,563,690,800,0,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1,1,892,563,690,700,0,0,0 }, /* 01 (320x350,640x350) */
@@ -1660,7 +1671,7 @@ struct XGI330_TVDataStruct XGI_St1HiTVData[] =
{ 8,5,1050,683,1648,960,0x150,1,0 } /* 05 (400x300,800x600) */
};
-struct XGI330_TVDataStruct XGI_St2HiTVData[] =
+static struct XGI330_TVDataStruct XGI_St2HiTVData[] =
{
{ 3,1,840,483,1648,960,0x032,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1,1,892,563,690,700,0,0,0 }, /* 01 (320x350,640x350) */
@@ -1671,7 +1682,7 @@ struct XGI330_TVDataStruct XGI_St2HiTVData[] =
};
-struct XGI330_TVDataStruct XGI_ExtHiTVData[] =
+static struct XGI330_TVDataStruct XGI_ExtHiTVData[] =
{
{ 6,1,840,563,1632,960,0,0,0 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 3,1,960,563,1632,960,0,0,0 }, /* 01 (320x350,640x350) */
@@ -1687,7 +1698,7 @@ struct XGI330_TVDataStruct XGI_ExtHiTVData[] =
};
-struct XGI330_TVDataStruct XGI_ExtYPbPr525iData[] =
+static struct XGI330_TVDataStruct XGI_ExtYPbPr525iData[] =
{
{ 9, 5, 1001, 453,1270, 420, 171, 0, 171},
{ 12, 5, 858, 403,1270, 420, 171, 0, 171},
@@ -1700,7 +1711,7 @@ struct XGI330_TVDataStruct XGI_ExtYPbPr525iData[] =
{ 3, 2,1001, 533,1250, 420, 0, 0, 0}
};
-struct XGI330_TVDataStruct XGI_StYPbPr525iData[] =
+static struct XGI330_TVDataStruct XGI_StYPbPr525iData[] =
{
{ 1, 1, 858, 525,1270, 400, 50, 0, 760},
{ 1, 1, 858, 525,1270, 350, 50, 0, 640},
@@ -1709,7 +1720,7 @@ struct XGI330_TVDataStruct XGI_StYPbPr525iData[] =
{ 1, 1, 858, 525,1270, 480, 0, 0, 760},
};
-struct XGI330_TVDataStruct XGI_ExtYPbPr525pData[] =
+static struct XGI330_TVDataStruct XGI_ExtYPbPr525pData[] =
{
{ 9, 5, 1001, 453,1270, 420, 171, 0, 171},
{ 12, 5, 858, 403,1270, 420, 171, 0, 171},
@@ -1722,7 +1733,7 @@ struct XGI330_TVDataStruct XGI_ExtYPbPr525pData[] =
{ 3, 2,1001, 533,1270, 420, 0, 0, 0}
};
-struct XGI330_TVDataStruct XGI_StYPbPr525pData[] =
+static struct XGI330_TVDataStruct XGI_StYPbPr525pData[] =
{
{ 1, 1,1716, 525,1270, 400, 50, 0, 760},
{ 1, 1,1716, 525,1270, 350, 50, 0, 640},
@@ -1731,7 +1742,7 @@ struct XGI330_TVDataStruct XGI_StYPbPr525pData[] =
{ 1, 1,1716, 525,1270, 480, 0, 0, 760},
};
-struct XGI330_TVDataStruct XGI_ExtYPbPr750pData[] =
+static struct XGI330_TVDataStruct XGI_ExtYPbPr750pData[] =
{
{ 3, 1, 935, 470,1130, 680, 50, 0, 0}, /* 00 (320x200,320x400,640x200,640x400) */
{ 24, 7, 935, 420,1130, 680, 50, 0, 0}, /* 01 (320x350,640x350) */
@@ -1746,7 +1757,7 @@ struct XGI330_TVDataStruct XGI_ExtYPbPr750pData[] =
{ 10, 9,1320, 830,1130, 640, 50, 0, 0}
};
-struct XGI330_TVDataStruct XGI_StYPbPr750pData[] =
+static struct XGI330_TVDataStruct XGI_StYPbPr750pData[] =
{
{ 1, 1,1650, 750,1280, 400, 50, 0, 760},
{ 1, 1,1650, 750,1280, 350, 50, 0, 640},
@@ -1755,7 +1766,7 @@ struct XGI330_TVDataStruct XGI_StYPbPr750pData[] =
{ 1, 1,1650, 750,1280, 480, 0, 0, 760},
};
-unsigned char XGI330_NTSCTiming[] = {
+static unsigned char XGI330_NTSCTiming[] = {
0x17,0x1d,0x03,0x09,0x05,0x06,0x0c,0x0c,
0x94,0x49,0x01,0x0a,0x06,0x0d,0x04,0x0a,
0x06,0x14,0x0d,0x04,0x0a,0x00,0x85,0x1b,
@@ -1765,7 +1776,7 @@ unsigned char XGI330_NTSCTiming[] = {
0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x50,
0x00,0x40,0x44,0x00,0xdb,0x02,0x3b,0x00};
-unsigned char XGI330_PALTiming[] = {
+static unsigned char XGI330_PALTiming[] = {
0x21,0x5A,0x35,0x6e,0x04,0x38,0x3d,0x70,
0x94,0x49,0x01,0x12,0x06,0x3e,0x35,0x6d,
0x06,0x14,0x3e,0x35,0x6d,0x00,0x45,0x2b,
@@ -1775,7 +1786,7 @@ unsigned char XGI330_PALTiming[] = {
0x60,0x80,0x14,0x90,0x8c,0x60,0x14,0x63,
0x00,0x40,0x3e,0x00,0xe1,0x02,0x28,0x00};
-unsigned char XGI330_HiTVExtTiming[] =
+static unsigned char XGI330_HiTVExtTiming[] =
{
0x2D,0x60,0x2C,0x5F,0x08,0x31,0x3A,0x64,
0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
@@ -1789,7 +1800,7 @@ unsigned char XGI330_HiTVExtTiming[] =
};
-unsigned char XGI330_HiTVSt1Timing[] =
+static unsigned char XGI330_HiTVSt1Timing[] =
{
0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
@@ -1802,7 +1813,7 @@ unsigned char XGI330_HiTVSt1Timing[] =
0x0E,0x00,0xfc,0xff,0x2d,0x00
};
-unsigned char XGI330_HiTVSt2Timing[] =
+static unsigned char XGI330_HiTVSt2Timing[] =
{
0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x64,
0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
@@ -1815,7 +1826,7 @@ unsigned char XGI330_HiTVSt2Timing[] =
0x27,0x00,0xFC,0xff,0x6a,0x00
};
-unsigned char XGI330_HiTVTextTiming[] =
+static unsigned char XGI330_HiTVTextTiming[] =
{
0x32,0x65,0x2C,0x5F,0x08,0x31,0x3A,0x65,
0x28,0x02,0x01,0x3D,0x06,0x3E,0x35,0x6D,
@@ -1828,7 +1839,7 @@ unsigned char XGI330_HiTVTextTiming[] =
0x11,0x00,0xFC,0xFF,0x32,0x00
};
-unsigned char XGI330_YPbPr750pTiming[] =
+static unsigned char XGI330_YPbPr750pTiming[] =
{
0x30,0x1d,0xe8,0x09,0x09,0xed,0x0c,0x0c,
0x98,0x0a,0x01,0x0c,0x06,0x0d,0x04,0x0a,
@@ -1841,7 +1852,7 @@ unsigned char XGI330_YPbPr750pTiming[] =
0x11,0x00,0xfc,0xff,0x32,0x00
};
-unsigned char XGI330_YPbPr525pTiming[] =
+static unsigned char XGI330_YPbPr525pTiming[] =
{
0x3E,0x11,0x06,0x09,0x0b,0x0c,0x0c,0x0c,
0x98,0x0a,0x01,0x0d,0x06,0x0d,0x04,0x0a,
@@ -1854,7 +1865,7 @@ unsigned char XGI330_YPbPr525pTiming[] =
0x11,0x00,0xFC,0xFF,0x32,0x00
};
-unsigned char XGI330_YPbPr525iTiming[] =
+static unsigned char XGI330_YPbPr525iTiming[] =
{
0x1B,0x21,0x03,0x09,0x05,0x06,0x0C,0x0C,
0x94,0x49,0x01,0x0A,0x06,0x0D,0x04,0x0A,
@@ -1868,7 +1879,7 @@ unsigned char XGI330_YPbPr525iTiming[] =
};
-unsigned char XGI330_HiTVGroup3Data[] =
+static unsigned char XGI330_HiTVGroup3Data[] =
{
0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x5F,
0x05,0x21,0xB2,0xB2,0x55,0x77,0x2A,0xA6,
@@ -1880,7 +1891,7 @@ unsigned char XGI330_HiTVGroup3Data[] =
0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
};
-unsigned char XGI330_HiTVGroup3Simu[] =
+static unsigned char XGI330_HiTVGroup3Simu[] =
{
0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0x95,
0xDB,0x20,0xB8,0xB8,0x55,0x47,0x2A,0xA6,
@@ -1892,7 +1903,7 @@ unsigned char XGI330_HiTVGroup3Simu[] =
0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
};
-unsigned char XGI330_HiTVGroup3Text[] =
+static unsigned char XGI330_HiTVGroup3Text[] =
{
0x00,0x1A,0x22,0x63,0x62,0x22,0x08,0xA7,
0xF5,0x20,0xCE,0xCE,0x55,0x47,0x2A,0xA6,
@@ -1904,7 +1915,7 @@ unsigned char XGI330_HiTVGroup3Text[] =
0x18,0x05,0x18,0x05,0x4C,0xA8,0x01
};
-unsigned char XGI330_Ren525pGroup3[] =
+static unsigned char XGI330_Ren525pGroup3[] =
{
0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x13,
0xB1,0x41,0x62,0x62,0xFF,0xF4,0x45,0xa6,
@@ -1916,7 +1927,7 @@ unsigned char XGI330_Ren525pGroup3[] =
0x1a,0x1F,0x25,0x2a,0x4C,0xAA,0x01
};
-unsigned char XGI330_Ren750pGroup3[] =
+static unsigned char XGI330_Ren750pGroup3[] =
{
0x00,0x14,0x15,0x25,0x55,0x15,0x0b,0x7a,
0x54,0x41,0xE7,0xE7,0xFF,0xF4,0x45,0xa6,
@@ -1928,7 +1939,8 @@ unsigned char XGI330_Ren750pGroup3[] =
0x18,0x1D,0x23,0x28,0x4C,0xAA,0x01
};
-struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] =
+#if 0
+static struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] =
{
{{0x00,0x00}},
{{0x00,0x00}},
@@ -1948,7 +1960,7 @@ struct XGI_PanelDelayTblStruct XGI330_PanelDelayTbl[] =
{{0x00,0x00}}
};
-struct XGI330_LVDSDataStruct XGI330_LVDS320x480Data_1[] =
+static struct XGI330_LVDSDataStruct XGI330_LVDS320x480Data_1[] =
{
{848, 433,400,525},
{848, 389,400,525},
@@ -1961,7 +1973,7 @@ struct XGI330_LVDSDataStruct XGI330_LVDS320x480Data_1[] =
{800, 525,1000, 635}
};
-struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_1[] =
+static struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_1[] =
{
{848, 433,1060, 629},
{848, 389,1060, 629},
@@ -1974,7 +1986,7 @@ struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_1[] =
{800, 525,1000, 635}
};
-struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_2[] =
+static struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_2[] =
{
{1056, 628,1056, 628},
{1056, 628,1056, 628},
@@ -1986,8 +1998,9 @@ struct XGI330_LVDSDataStruct XGI330_LVDS800x600Data_2[] =
{800, 449,1000, 644},
{800, 525,1000, 635}
};
+#endif
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] =
{
{ 960 , 438 , 1344 , 806 } , /* 00 (320x200,320x400,640x200,640x400) */
{ 960 , 388 , 1344 , 806 } , /* 01 (320x350,640x350) */
@@ -1999,7 +2012,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] =
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[] =
{
{1344, 806,1344, 806},
{1344, 806,1344, 806},
@@ -2012,7 +2025,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[] =
{800, 525,1280, 813}
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[] =
{
{1048, 442,1688, 1066},
{1048, 392,1688, 1066},
@@ -2024,7 +2037,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[] =
{1688, 1066,1688, 1066}
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[] =
{
{1344, 806,1344, 806},
{1344, 806,1344, 806},
@@ -2115,7 +2128,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x768SData_2[] =
{1688,806,1688,806}
};
*/
-struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] =
{
{928,416,1688,1066},
{928,366,1688,1066},
@@ -2128,7 +2141,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] =
{1688,1066,1688,1066}
};
-struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[] =
{
{1688,1066,1688,1066},
{1688,1066,1688,1066},
@@ -2141,7 +2154,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[] =
{1688,1066,1688,1066}
};
-struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] =
{ /* ;;[ycchen] 12/05/02 LCDHTxLCDVT=2048x1320 */
{ 1088,520,2048,1320 },/* 00 (320x200,320x400,640x200,640x400) */
{ 1088,470,2048,1320 },/* 01 (320x350,640x350) */
@@ -2155,7 +2168,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] =
{ 2048,1320,2048,1320 } /* 09 (1600x1200) */
};
-struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] =
+static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] =
{
{ 800,449,800,449 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 800,449,800,449 }, /* 01 (320x350,640x350) */
@@ -2170,7 +2183,7 @@ struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] =
{ 1688,806,1688,806 } /* 0A (1280x768x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] =
{
{960,438,1312,800 }, /* 00 (320x200,320x400,640x200,640x400) */
{960,388,1312,800 }, /* 01 (320x350,640x350) */
@@ -2182,7 +2195,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] =
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] =
{
{1312,800,1312,800}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1312,800,1312,800}, /* ; 01 (320x350,640x350) */
@@ -2193,7 +2206,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] =
{1312,800,1312,800}, /* ; 06 (512x384,1024x768) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] =
{
{1048,442,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1048,392,1688,1066 }, /* ; 01 (320x350,640x350) */
@@ -2205,7 +2218,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] =
{1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] =
{
{1688,1066,1688,1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1688,1066,1688,1066 }, /* ; 01 (320x350,640x350) */
@@ -2217,7 +2230,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] =
{1688,1066,1688,1066 }, /* ; 06; 07 (640x512,1280x1024) */
};
-struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] =
{
{800,449,800,449 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{800,449,800,449 }, /* ; 01 (320x350,640x350) */
@@ -2232,7 +2245,7 @@ struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] =
{1688,806,1688,806 }, /* ; 0A (1280x768x75Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] =
{
{ 0,1048, 0, 771 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0,1048, 0, 771 }, /* 01 (320x350,640x350) */
@@ -2243,7 +2256,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] =
{ 0,1048, 805, 770 } /* 06 (1024x768x60Hz) */
} ;
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] =
{
{ 1142, 856, 622, 587 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1142, 856, 597, 562 }, /* 01 (320x350,640x350) */
@@ -2254,7 +2267,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] =
{ 0,1048, 805, 771 } /* 06 (1024x768x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] =
{
{ 320, 24, 622, 587 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 320, 24, 597, 562 }, /* 01 (320x350,640x350) */
@@ -2263,7 +2276,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] =
{ 320, 24, 722, 687 } /* 04 (640x480x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] =
{
{ 0,1328, 0, 1025 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0,1328, 0, 1025 }, /* 01 (320x350,640x350) */
@@ -2276,7 +2289,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] =
};
/* The Display setting for DE Mode Panel */
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] =
{
{ 1368,1008,752,711 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1368,1008,729,688 }, /* 01 (320x350,640x350) */
@@ -2288,7 +2301,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] =
{ 0000,1328,0,1025 } /* 07 (1280x1024x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] =
{
{ 0,1448,0,1051 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0,1448,0,1051 }, /* 01 (320x350,640x350) */
@@ -2301,7 +2314,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] =
{ 0,1448,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] =
{
{ 1308,1068, 781, 766 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 1308,1068, 781, 766 }, /* 01 (320x350,640x350) */
@@ -2314,7 +2327,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] =
{ 0,1448,0,1051 } /* 08 (1400x1050x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] =
{
{ 0,1664,0,1201 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0,1664,0,1201 }, /* 01 (320x350,640x350) */
@@ -2330,7 +2343,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] =
-struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[] =
+static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[] =
{
{ 0, 648, 448, 405, 96, 2 }, /* 00 (320x200,320x400,640x200,640x400) */
{ 0, 648, 448, 355, 96, 2 }, /* 01 (320x350,640x350) */
@@ -2345,7 +2358,7 @@ struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[] =
{ 0,1328,0,0771, 112, 6 } /* 0A (1280x768x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = /* ; 1024x768 Full-screen */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = /* ; 1024x768 Full-screen */
{
{0,1040,0,769}, /* ; 00 (320x200,320x400,640x200,640x400) */
{0,1040,0,769}, /* ; 01 (320x350,640x350) */
@@ -2356,7 +2369,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = /* ; 1024x768 Full-s
{0,1040,0,769} /* ; 06 (1024x768x75Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = /* ; 1024x768 center-screen (Enh. Mode) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = /* ; 1024x768 center-screen (Enh. Mode) */
{
{1142, 856,622,587 }, /* 00 (320x200,320x400,640x200,640x400) */
{1142, 856,597,562 }, /* 01 (320x350,640x350) */
@@ -2367,7 +2380,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = /* ; 1024x768 center-s
{ 0,1048,805,771 } /* 06 (1024x768x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = /* ; 1024x768 center-screen (St.Mode) */
+static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = /* ; 1024x768 center-screen (St.Mode) */
{
{320,24,622,587 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{320,24,597,562 }, /* ; 01 (320x350,640x350) */
@@ -2376,7 +2389,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = /* ; 1024x768 center-s
{320,24,722,687 } /* ; 04 (640x480x60Hz) */
};
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] =
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] =
{
{0,1296,0,1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
{0,1296,0,1025}, /* ; 01 (320x350,640x350) */
@@ -2389,7 +2402,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] =
};
/* The Display setting for DE Mode Panel */
-struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] = /* [ycchen] 02/18/03 Set DE as default */
+static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] = /* [ycchen] 02/18/03 Set DE as default */
{
{1368,976,752,711 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368,976,729,688 }, /* ; 01 (320x350,640x350) */
@@ -2401,7 +2414,7 @@ struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] = /* [ycchen] 02/18/0
{0,1296,0,1025 } /* ; 07 (1280x1024x75Hz) */
};
-struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = /* Scaling LCD 75Hz */
+static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = /* Scaling LCD 75Hz */
{
{ 0,648,448,405,96,2 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 0,648,448,355,96,2 }, /* ; 01 (320x350,640x350) */
@@ -2416,7 +2429,8 @@ struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = /* Scaling LCD
{ 0,1328,0,771,112,6 } /* ; 0A (1280x768x75Hz) */
};
-struct XGI330_LVDSDataStruct XGI330_LVDS640x480Data_1[] =
+#if 0
+static struct XGI330_LVDSDataStruct XGI330_LVDS640x480Data_1[] =
{
{800, 449, 800, 449},
{800, 449, 800, 449},
@@ -2428,8 +2442,9 @@ struct XGI330_LVDSDataStruct XGI330_LVDS640x480Data_1[] =
{1056, 628,1056, 628},
{1056, 628,1056, 628}
};
+#endif
-struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] =
+static struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] =
{
{840, 600, 840, 600},
{840, 600, 840, 600},
@@ -2439,7 +2454,7 @@ struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] =
{1064, 750,1064, 750}
};
-struct XGI330_CHTVDataStruct XGI_CHTVONTSCData[] =
+static struct XGI330_CHTVDataStruct XGI_CHTVONTSCData[] =
{
{840, 525, 840, 525},
{840, 525, 840, 525},
@@ -2449,7 +2464,7 @@ struct XGI330_CHTVDataStruct XGI_CHTVONTSCData[] =
{1040, 700,1040, 700}
};
-struct XGI330_CHTVDataStruct XGI_CHTVUPALData[] =
+static struct XGI330_CHTVDataStruct XGI_CHTVUPALData[] =
{
{1008, 625,1008, 625},
{1008, 625,1008, 625},
@@ -2459,7 +2474,7 @@ struct XGI330_CHTVDataStruct XGI_CHTVUPALData[] =
{936, 836, 936, 836}
};
-struct XGI330_CHTVDataStruct XGI_CHTVOPALData[] =
+static struct XGI330_CHTVDataStruct XGI_CHTVOPALData[] =
{
{1008, 625,1008, 625},
{1008, 625,1008, 625},
@@ -2469,7 +2484,7 @@ struct XGI330_CHTVDataStruct XGI_CHTVOPALData[] =
{960, 750, 960, 750}
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_H[] =
{
/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }}, /* 00 (320x) */
@@ -2482,7 +2497,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_H[] =
{{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_H[] =
{
/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }}, /* 00 (320x) */
@@ -2496,7 +2511,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_H[] =
{{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_H[] =
{
/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }}, /* 00 (320x) */
@@ -2509,7 +2524,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_H[] =
{{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* 07 (1024x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_H[] =
{
/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }}, /* 00 (320x) */
@@ -2523,7 +2538,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_H[] =
{{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* 08 (1280x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[] =
{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x47,0x27,0x8B,0x2C,0x1A,0x00,0x05,0x00 }}, /* 00 (320x) */
{{ 0x47,0x27,0x8B,0x30,0x1E,0x00,0x05,0x00 }}, /* 01 (360x) */
@@ -2537,7 +2552,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_1_H[] =
{{ 0xCE,0xAE,0x92,0xB3,0x01,0x00,0x03,0x00 }} /* 09 (1400x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[] =
{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 00 (320x) */
{{ 0x76,0x3F,0x83,0x45,0x8C,0x00,0x41,0x00 }}, /* 01 (360x) */
@@ -2551,7 +2566,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11400x1050_2_H[] =
{{ 0xCE,0xAE,0x92,0xBC,0x0A,0x00,0x03,0x00 }} /* 09 (1400x) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[] =
/* ;302lv channelA [ycchen] 12/05/02 LCDHT=2048 */
{ /* ; CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x5B,0x27,0x9F,0x32,0x0A,0x00,0x01,0x00 }},/* 00 (320x) */
@@ -2567,7 +2582,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11600x1200_1_H[] =
{{ 0xFB,0xC7,0x9F,0xC9,0x81,0x00,0x07,0x00 }} /* 0A (1600x) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
{{ 0x97,0x1F,0x60,0x87,0x5D,0x83,0x10 }}, /* 00 (x350) */
{{ 0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30 }}, /* 01 (x400) */
@@ -2576,7 +2591,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_V[] =
{{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* 04 (x768) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x24,0xBB,0x31,0x87,0x5D,0x25,0x30 }}, /* 00 (x350) */
{{ 0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30 }}, /* 01 (x400) */
@@ -2585,7 +2600,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_V[] =
{{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* 04 (x768) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x86,0x1F,0x5E,0x82,0x5D,0x87,0x00 }}, /* 00 (x350) */
{{ 0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30 }}, /* 01 (x400) */
@@ -2595,7 +2610,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_V[] =
{{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* 05 (x1024) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1 }}, /* 00 (x350) */
{{ 0x28,0xD2,0xC8,0x8C,0xC7,0xF2,0x81 }}, /* 01 (x400) */
@@ -2605,7 +2620,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_V[] =
{{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* 05 (x1024) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x6C,0x1F,0x60,0x84,0x5D,0x6D,0x10 }}, /* 00 (x350) */
{{ 0x9E,0x1F,0x93,0x86,0x8F,0x9F,0x30 }}, /* 01 (x400) */
@@ -2616,7 +2631,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_1_V[] =
{{ 0x28,0x10,0x1A,0x80,0x19,0x29,0x0F }} /* 06 (x1050) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x28,0x92,0xB6,0x83,0xB5,0xCF,0x81 }}, /* 00 (x350) */
{{ 0x28,0x92,0xD5,0x82,0xD4,0xEE,0x81 }}, /* 01 (x400) */
@@ -2627,7 +2642,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11400x1050_2_V[] =
{{ 0x28,0x10,0x1A,0x87,0x19,0x29,0x8F }} /* 06 (x1050) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[] =
{
/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
{{ 0xd4,0x1F,0x81,0x84,0x5D,0xd5,0x10 }}, /* 00 (x350) */
@@ -2640,7 +2655,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11600x1200_1_V[] =
{{ 0x26,0x11,0xd3,0x86,0xaF,0x27,0x3f }} /* 07 (x1200) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[] =
{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x4B,0x27,0x8F,0x32,0x1B,0x00,0x45,0x00 }},/* ; 00 (320x) */
{{ 0x4B,0x27,0x8F,0x2B,0x03,0x00,0x44,0x00 }},/* ; 01 (360x) */
@@ -2652,7 +2667,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_1_Hx75[] =
{{ 0x9F,0x7F,0x83,0x85,0x91,0x00,0x02,0x00 }} /* ; 07 (1024x) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A+CR09(5->7) */
{{ 0x97,0x1F,0x60,0x87,0x5D,0x83,0x10 }},/* ; 00 (x350) */
{{ 0xB4,0x1F,0x92,0x89,0x8F,0xB5,0x30 }},/* ; 01 (x400) */
@@ -2661,7 +2676,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_1_Vx75[] =
{{ 0x1E,0xF5,0x00,0x83,0xFF,0x1F,0x90 }} /* ; 04 (x768) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[] =
{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 00 (320x) */
{{ 0x63,0x27,0x87,0x3B,0x8C,0x00,0x01,0x00 }},/* ; 01 (360x) */
@@ -2673,7 +2688,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11024x768_2_Hx75[] =
{{ 0xA3,0x7F,0x87,0x86,0x97,0x00,0x02,0x00 }} /* ; 07 (1024x) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x24,0xBB,0x31,0x87,0x5D,0x25,0x30 }},/* ; 00 (x350) */
{{ 0x24,0xBB,0x4A,0x80,0x8F,0x25,0x30 }},/* ; 01 (x400) */
@@ -2682,7 +2697,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11024x768_2_Vx75[] =
{{ 0x24,0xF5,0x02,0x88,0xFF,0x25,0x90 }} /* ; 04 (x768) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[] =
{ /* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 00 (320x) */
{{ 0x56,0x27,0x9A,0x30,0x1E,0x00,0x05,0x00 }},/* ; 01 (360x) */
@@ -2695,7 +2710,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_1_Hx75[] =
{{ 0xCE,0x9F,0x92,0xA5,0x17,0x00,0x07,0x00 }} /* ; 08 (1280x) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[] =
{ /* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x86,0xD1,0xBC,0x80,0xBB,0xE5,0x00 }},/* ; 00 (x350) */
{{ 0xB8,0x1F,0x90,0x84,0x8F,0xB9,0x30 }},/* ; 01 (x400) */
@@ -2705,7 +2720,7 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_1_Vx75[] =
{{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* ; 05 (x1024) */
};
-struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[] =
+static struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[] =
{
/* CR00,CR02,CR03,CR04,CR05,SR0B,SR0C,SR0E */
{{ 0x7E,0x3B,0x9A,0x44,0x12,0x00,0x01,0x00 }},/* ; 00 (320x) */
@@ -2719,7 +2734,7 @@ struct XGI_LVDSCRT1HDataStruct XGI_LVDSCRT11280x1024_2_Hx75[] =
{{ 0xCE,0x9F,0x92,0xA8,0x16,0x00,0x07,0x00 }} /* ; 08 (1280x) */
};
-struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] =
+static struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] =
{
/* CR06,CR07,CR10,CR11,CR15,CR16,SR0A */
{{ 0x28,0xD2,0xAF,0x83,0xAE,0xD8,0xA1 }},/* ; 00 (x350) */
@@ -2730,7 +2745,8 @@ struct XGI_LVDSCRT1VDataStruct XGI_LVDSCRT11280x1024_2_Vx75[] =
{{ 0x28,0x5A,0x13,0x87,0xFF,0x29,0xA9 }} /* ; 05 (x1024) */
};
-struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UNTSC[] =
+#if 0
+static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UNTSC[] =
{
{{0x64,0x4f,0x88,0x56,0x9f,0x56,0x3e,
0xe8,0x84,0x8f,0x57,0x20,0x00,0x01,0x00 }},
@@ -2746,7 +2762,7 @@ struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UNTSC[] =
0x90,0x8c,0x57,0xed,0x20,0x00,0x06,0x01 }}
};
-struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1ONTSC[] =
+static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1ONTSC[] =
{
{{0x64,0x4f,0x88,0x5a,0x9f,0x0b,0x3e,
0xc0,0x84,0x8f,0x0c,0x20,0x00,0x01,0x00 }},
@@ -2762,7 +2778,7 @@ struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1ONTSC[] =
0x7f,0x86,0x57,0xbb,0x00,0x00,0x06,0x01 }}
};
-struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UPAL[] =
+static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UPAL[] =
{
{{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
0xf8,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
@@ -2778,7 +2794,7 @@ struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1UPAL[] =
0xc8,0x8c,0x57,0xe9,0x20,0x00,0x05,0x01 }}
};
-struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1OPAL[] =
+static struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1OPAL[] =
{
{{0x79,0x4f,0x9d,0x5a,0x90,0x6f,0x3e,
0xf0,0x83,0x8f,0x70,0x20,0x00,0x05,0x00 }},
@@ -2793,9 +2809,10 @@ struct XGI_LVDSCRT1DataStruct XGI_CHTVCRT1OPAL[] =
{{0x73,0x63,0x97,0x69,0x8e,0xec,0xf0,
0x90,0x8c,0x57,0xed,0x20,0x00,0x05,0x01 }}
};
+#endif
/*add for new UNIVGABIOS*/
-struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] =
+static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] =
{
{Panel1024x768,0x0019,0x0001,0}, /* XGI_ExtLCD1024x768Data */
{Panel1024x768,0x0019,0x0000,1}, /* XGI_StLCD1024x768Data */
@@ -2819,7 +2836,7 @@ struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] =
{0xFF,0x0000,0x0000,0} /* End of table */
};
-struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] =
+static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] =
{
{Panel1024x768,0x0019,0x0001,0}, /* XGI_ExtLCDDes1024x768Data */
{Panel1024x768,0x0019,0x0000,1}, /* XGI_StLCDDes1024x768Data */
@@ -2844,7 +2861,7 @@ struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] =
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] =
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] =
{
{Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_H */
{Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_H */
@@ -2860,7 +2877,7 @@ struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_H[] =
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] =
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] =
{
{Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDSCRT11024x768_1_V */
{Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDSCRT11024x768_2_V */
@@ -2876,7 +2893,7 @@ struct XGI330_LCDDataTablStruct XGI_EPLLCDCRT1Ptr_V[] =
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] =
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] =
{
{Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Data_1 */
{Panel1024x768,0x0018,0x0010,1}, /* XGI_LVDS1024x768Data_2 */
@@ -2894,7 +2911,7 @@ struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] =
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] =
+static struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] =
{
{Panel1024x768,0x0018,0x0000,0}, /* XGI_LVDS1024x768Des_1 */
{Panel1024x768,0x0618,0x0410,1}, /* XGI_LVDS1024x768Des_3 */
@@ -2914,14 +2931,14 @@ struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] =
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_LCDDataTablStruct XGI_EPLCHLCDRegPtr[] =
+static struct XGI330_LCDDataTablStruct XGI_EPLCHLCDRegPtr[] =
{
{Panel1024x768,0x0000,0x0000,0}, /* XGI_CH7017LV1024x768 */
{Panel1400x1050,0x0000,0x0000,1}, /* XGI_CH7017LV1400x1050 */
{0xFF,0x0000,0x0000,0}
};
-struct XGI330_TVDataTablStruct XGI_TVDataTable[] =
+static struct XGI330_TVDataTablStruct XGI_TVDataTable[] =
{
{0x09E1,0x0001,0}, /* XGI_ExtPALData */
{0x09E1,0x0000,1}, /* XGI_ExtNTSCData */
@@ -2939,7 +2956,8 @@ struct XGI330_TVDataTablStruct XGI_TVDataTable[] =
{0xffff,0x0000,12} /* END */
};
-unsigned short TVLenList[] =
+#if 0
+static unsigned short TVLenList[] =
{
LVDSCRT1Len_H,
LVDSCRT1Len_V,
@@ -2950,9 +2968,10 @@ unsigned short TVLenList[] =
0,
CHTVRegLen
} ;
+#endif
/* Chrontel 7017 TV CRT1 Timing List */
-struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] =
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] =
{
{0x0011,0x0000,0}, /* XGI_CHTVCRT1UNTSC */
{0x0011,0x0010,1}, /* XGI_CHTVCRT1ONTSC */
@@ -2962,7 +2981,7 @@ struct XGI330_TVDataTablStruct XGI_EPLCHTVCRT1Ptr[] =
};
/* ;;Chrontel 7017 TV Timing List */
-struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] =
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] =
{
{0x0011,0x0000,0}, /* XGI_CHTVUNTSCData */
{0x0011,0x0010,1}, /* XGI_CHTVONTSCData */
@@ -2972,7 +2991,7 @@ struct XGI330_TVDataTablStruct XGI_EPLCHTVDataPtr[] =
};
/* ;;Chrontel 7017 TV Reg. List */
-struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] =
+static struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] =
{
{0x0011,0x0000,0}, /* XGI_CHTVRegUNTSC */
{0x0011,0x0010,1}, /* XGI_CHTVRegONTSC */
@@ -2981,7 +3000,7 @@ struct XGI330_TVDataTablStruct XGI_EPLCHTVRegPtr[] =
{0xFFFF,0x0000,4}
};
-unsigned short LCDLenList[] =
+static unsigned short LCDLenList[] =
{
LVDSCRT1Len_H,
LVDSCRT1Len_V,
@@ -2995,7 +3014,8 @@ unsigned short LCDLenList[] =
0
} ;
-struct XGI330_LCDCapStruct XGI660_LCDDLCapList[] = /* 660, Dual link */
+#if 0
+static struct XGI330_LCDCapStruct XGI660_LCDDLCapList[] = /* 660, Dual link */
{
/* LCDCap1024x768 */
{Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
@@ -3026,8 +3046,9 @@ struct XGI330_LCDCapStruct XGI660_LCDDLCapList[] = /* 660, Dual link */
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
};
+#endif
-struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = /* Dual link only */
+static struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = /* Dual link only */
{
/* LCDCap1024x768 */
{Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
@@ -3059,7 +3080,8 @@ struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = /* Dual link only */
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
};
-struct XGI330_LCDCapStruct XGI660_LCDCapList[] =
+#if 0
+static struct XGI330_LCDCapStruct XGI660_LCDCapList[] =
{
/* LCDCap1024x768 */
{Panel1024x768, DefaultLCDCap, 0, 0x014, 0x88, 0x06, VCLK65,
@@ -3090,8 +3112,9 @@ struct XGI330_LCDCapStruct XGI660_LCDCapList[] =
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
};
+#endif
-struct XGI330_LCDCapStruct XGI_LCDCapList[] =
+static struct XGI330_LCDCapStruct XGI_LCDCapList[] =
{
/* LCDCap1024x768 */
{Panel1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65,
@@ -3152,7 +3175,7 @@ struct XGI21_LVDSCapStruct XGI21_LCDCapList[] =
};
-struct XGI_Ext2Struct XGI330_RefIndex[] =
+static struct XGI_Ext2Struct XGI330_RefIndex[] =
{
{Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175, 0x00,0x10,0x59, 320, 200},/* 00 */
{Support32Bpp + SupportAllCRT2 + SyncPN, RES320x200, VCLK25_175, 0x00,0x10,0x00, 320, 400},/* 01 */
@@ -3230,8 +3253,8 @@ struct XGI_Ext2Struct XGI330_RefIndex[] =
};
-
-struct XGI330_VCLKDataStruct XGI330_VCLKData[] =
+#if 0
+static struct XGI330_VCLKDataStruct XGI330_VCLKData[] =
{
{ 0x1b,0xe1, 25}, /* 0x0 */
{ 0x4e,0xe4, 28}, /* 0x1 */
@@ -3315,7 +3338,7 @@ struct XGI330_VCLKDataStruct XGI330_VCLKData[] =
{ 0x3b,0x61,108} /* 0x4f */
};
-struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] =
+static struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] =
{
{ 0x1b,0xe1, 25}, /* 0x0 */
{ 0x4e,0xe4, 28}, /* 0x1 */
@@ -3392,12 +3415,14 @@ struct XGI_VBVCLKDataStruct XGI330_VBVCLKData[] =
{ 0x5e,0x64,68}, /* 0x48 chiawen for fuj1280x768*/
{ 0x70,0x44,108}, /* 0x49 chiawen for 1400x1050*/
};
+#endif
-unsigned char XGI330_ScreenOffset[] = { 0x14, 0x19, 0x20, 0x28, 0x32, 0x40,
+static unsigned char XGI330_ScreenOffset[] = {
+ 0x14, 0x19, 0x20, 0x28, 0x32, 0x40,
0x50, 0x64, 0x78, 0x80, 0x2d, 0x35,
0x57, 0x48};
-struct XGI_StResInfoStruct XGI330_StResInfo[] =
+static struct XGI_StResInfoStruct XGI330_StResInfo[] =
{
{ 640,400},
{ 640,350},
@@ -3406,7 +3431,7 @@ struct XGI_StResInfoStruct XGI330_StResInfo[] =
{ 640,480}
};
-struct XGI_ModeResInfoStruct XGI330_ModeResInfo[] =
+static struct XGI_ModeResInfoStruct XGI330_ModeResInfo[] =
{
{ 320, 200, 8, 8},
{ 320, 240, 8, 8},
@@ -3433,10 +3458,12 @@ struct XGI_ModeResInfoStruct XGI330_ModeResInfo[] =
{ 1152, 864, 8,16}
};
-unsigned char XGI330_OutputSelect = 0x40;
-unsigned char XGI330_SoftSetting = 0x30;
-unsigned char XGI330_SR07 = 0x18;
-unsigned char XGI330New_SR15[8][8] = {
+static unsigned char XGI330_OutputSelect = 0x40;
+static unsigned char XGI330_SoftSetting = 0x30;
+static unsigned char XGI330_SR07 = 0x18;
+
+#if 0
+static unsigned char XGI330New_SR15[8][8] = {
{0x0,0x4,0x60,0x60},
{0xf,0xf,0xf,0xf},
{0xba,0xba,0xba,0xba},
@@ -3447,71 +3474,78 @@ unsigned char XGI330New_SR15[8][8] = {
{0x0,0xa5,0xfb,0xf6}
};
-unsigned char XGI330New_CR40[5][8] = {
+static unsigned char XGI330New_CR40[5][8] = {
{0x77,0x77,0x44,0x44},
{0x77,0x77,0x44,0x44},
{0x0,0x0,0x0,0x0},
{0x5b,0x5b,0xab,0xab},
{0x0,0x0,0xf0,0xf8}
};
-
-unsigned char XGI330_CR49[] = {0xaa, 0x88};
-unsigned char XGI330_SR1F = 0x0;
-unsigned char XGI330_SR21 = 0xa3;
-unsigned char XGI330_650_SR21 = 0xa7;
-unsigned char XGI330_SR22 = 0xfb;
-unsigned char XGI330_SR23 = 0xf6;
-unsigned char XGI330_SR24 = 0xd;
-
-unsigned char XGI660_SR21 = 0xa3;/* 2003.0312 */
-unsigned char XGI660_SR22 = 0xf3;/* 2003.0312 */
-
-unsigned char XGI330_LVDS_SR32 = 0x00; /* ynlai for 650 LVDS */
-unsigned char XGI330_LVDS_SR33 = 0x00; /* chiawen for 650 LVDS */
-unsigned char XGI330_650_SR31 = 0x40;
-unsigned char XGI330_650_SR33 = 0x04;
-unsigned char XGI330_CRT2Data_1_2 = 0x0;
-unsigned char XGI330_CRT2Data_4_D = 0x0;
-unsigned char XGI330_CRT2Data_4_E = 0x0;
-unsigned char XGI330_CRT2Data_4_10 = 0x80;
-unsigned short XGI330_RGBSenseData = 0xd1;
-unsigned short XGI330_VideoSenseData = 0xb9;
-unsigned short XGI330_YCSenseData = 0xb3;
-unsigned short XGI330_RGBSenseData2 = 0x0190; /*301b*/
-unsigned short XGI330_VideoSenseData2 = 0x0110;
-unsigned short XGI330_YCSenseData2 = 0x016B;
-unsigned char XGI330_NTSCPhase[] = {0x21, 0xed, 0x8a, 0x8};
-unsigned char XGI330_PALPhase[] = {0x2a, 0x5, 0xd3, 0x0};
-unsigned char XGI330_NTSCPhase2[] = {0x21, 0xF0, 0x7B, 0xD6};/*301b*/
-unsigned char XGI330_PALPhase2[] = {0x2a, 0x09, 0x86, 0xe9};
-unsigned char XGI330_PALMPhase[] = {0x21, 0xE4, 0x2E, 0x9B}; /*palmn*/
-unsigned char XGI330_PALNPhase[] = {0x21, 0xF4, 0x3E, 0xBA};
-unsigned char XG40_I2CDefinition = 0x00 ;
-unsigned char XG20_CR97 = 0x10 ;
-
-unsigned char XG21_DVOSetting = 0x00 ;
-unsigned char XG21_CR2E = 0x00 ;
-unsigned char XG21_CR2F = 0x00 ;
-unsigned char XG21_CR46 = 0x00 ;
-unsigned char XG21_CR47 = 0x00 ;
-
-unsigned char XG27_CR97 = 0xC1 ;
-unsigned char XG27_SR36 = 0x30 ;
-unsigned char XG27_CR8F = 0x0C ;
-unsigned char XG27_CRD0[] = {0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00};
-unsigned char XG27_CRDE[] = {0, 0};
-unsigned char XG27_SR40 = 0x04 ;
-unsigned char XG27_SR41 = 0x00 ;
-
-unsigned char XGI330_CHTVVCLKUNTSC[] = {0x00};
-
-unsigned char XGI330_CHTVVCLKONTSC[] = {0x00};
-
-unsigned char XGI330_CHTVVCLKUPAL[] = {0x00};
-
-unsigned char XGI330_CHTVVCLKOPAL[] = {0x00};
-
-unsigned char XGI7007_CHTVVCLKUNTSC[] = {CH7007TVVCLK30_2,
+#endif
+
+static unsigned char XGI330_CR49[] = {0xaa, 0x88};
+static unsigned char XGI330_SR1F = 0x0;
+static unsigned char XGI330_SR21 = 0xa3;
+#if 0
+static unsigned char XGI330_650_SR21 = 0xa7;
+#endif
+static unsigned char XGI330_SR22 = 0xfb;
+static unsigned char XGI330_SR23 = 0xf6;
+static unsigned char XGI330_SR24 = 0xd;
+
+#if 0
+static unsigned char XGI660_SR21 = 0xa3;/* 2003.0312 */
+static unsigned char XGI660_SR22 = 0xf3;/* 2003.0312 */
+
+static unsigned char XGI330_LVDS_SR32 = 0x00; /* ynlai for 650 LVDS */
+static unsigned char XGI330_LVDS_SR33 = 0x00; /* chiawen for 650 LVDS */
+static unsigned char XGI330_650_SR31 = 0x40;
+static unsigned char XGI330_650_SR33 = 0x04;
+#endif
+static unsigned char XGI330_CRT2Data_1_2 = 0x0;
+static unsigned char XGI330_CRT2Data_4_D = 0x0;
+static unsigned char XGI330_CRT2Data_4_E = 0x0;
+static unsigned char XGI330_CRT2Data_4_10 = 0x80;
+static unsigned short XGI330_RGBSenseData = 0xd1;
+static unsigned short XGI330_VideoSenseData = 0xb9;
+static unsigned short XGI330_YCSenseData = 0xb3;
+static unsigned short XGI330_RGBSenseData2 = 0x0190; /*301b*/
+static unsigned short XGI330_VideoSenseData2 = 0x0110;
+static unsigned short XGI330_YCSenseData2 = 0x016B;
+#if 0
+static unsigned char XGI330_NTSCPhase[] = {0x21, 0xed, 0x8a, 0x8};
+static unsigned char XGI330_PALPhase[] = {0x2a, 0x5, 0xd3, 0x0};
+static unsigned char XGI330_NTSCPhase2[] = {0x21, 0xF0, 0x7B, 0xD6};/*301b*/
+static unsigned char XGI330_PALPhase2[] = {0x2a, 0x09, 0x86, 0xe9};
+static unsigned char XGI330_PALMPhase[] = {0x21, 0xE4, 0x2E, 0x9B}; /*palmn*/
+static unsigned char XGI330_PALNPhase[] = {0x21, 0xF4, 0x3E, 0xBA};
+#endif
+static unsigned char XG40_I2CDefinition = 0x00 ;
+static unsigned char XG20_CR97 = 0x10 ;
+
+static unsigned char XG21_DVOSetting = 0x00 ;
+static unsigned char XG21_CR2E = 0x00 ;
+static unsigned char XG21_CR2F = 0x00 ;
+static unsigned char XG21_CR46 = 0x00 ;
+static unsigned char XG21_CR47 = 0x00 ;
+
+static unsigned char XG27_CR97 = 0xC1 ;
+static unsigned char XG27_SR36 = 0x30 ;
+static unsigned char XG27_CR8F = 0x0C ;
+static unsigned char XG27_CRD0[] = {0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00};
+static unsigned char XG27_CRDE[] = {0, 0};
+static unsigned char XG27_SR40 = 0x04 ;
+static unsigned char XG27_SR41 = 0x00 ;
+
+static unsigned char XGI330_CHTVVCLKUNTSC[] = {0x00};
+
+static unsigned char XGI330_CHTVVCLKONTSC[] = {0x00};
+
+static unsigned char XGI330_CHTVVCLKUPAL[] = {0x00};
+
+static unsigned char XGI330_CHTVVCLKOPAL[] = {0x00};
+
+static unsigned char XGI7007_CHTVVCLKUNTSC[] = {CH7007TVVCLK30_2,
CH7007TVVCLK30_2,
CH7007TVVCLK30_2,
CH7007TVVCLK30_2,
@@ -3519,7 +3553,7 @@ unsigned char XGI7007_CHTVVCLKUNTSC[] = {CH7007TVVCLK30_2,
CH7007TVVCLK47_8
};
-unsigned char XGI7007_CHTVVCLKONTSC[] = {CH7007TVVCLK26_4,
+static unsigned char XGI7007_CHTVVCLKONTSC[] = {CH7007TVVCLK26_4,
CH7007TVVCLK26_4,
CH7007TVVCLK26_4,
CH7007TVVCLK26_4,
@@ -3527,7 +3561,7 @@ unsigned char XGI7007_CHTVVCLKONTSC[] = {CH7007TVVCLK26_4,
CH7007TVVCLK43_6
};
-unsigned char XGI7007_CHTVVCLKUPAL[] = {CH7007TVVCLK31_5,
+static unsigned char XGI7007_CHTVVCLKUPAL[] = {CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
@@ -3535,7 +3569,7 @@ unsigned char XGI7007_CHTVVCLKUPAL[] = {CH7007TVVCLK31_5,
CH7007TVVCLK39
};
-unsigned char XGI7007_CHTVVCLKOPAL[] = {CH7007TVVCLK31_5,
+static unsigned char XGI7007_CHTVVCLKOPAL[] = {CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
CH7007TVVCLK31_5,
@@ -3543,7 +3577,7 @@ unsigned char XGI7007_CHTVVCLKOPAL[] = {CH7007TVVCLK31_5,
CH7007TVVCLK36
};
-struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] =
+static struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] =
{
{ 0x60,0x36,30}, /* 0 30.2 MHZ */
{ 0x40,0x4A,28}, /* 1 28.19 MHZ */
@@ -3558,7 +3592,7 @@ struct XGI330_VCLKDataStruct XGI_CH7007VCLKData[] =
{ 0xFF,0x00,0 } /* End mark */
};
-struct XGI330_VCLKDataStruct XGI_VCLKData[] =
+static struct XGI330_VCLKDataStruct XGI_VCLKData[] =
{
/* SR2B,SR2C,SR2D */
{ 0x1B,0xE1,25 },/* 00 (25.175MHz) */
@@ -3759,7 +3793,7 @@ struct XGI330_VCLKDataStruct XGI_VCLKData[] =
{ 0xFF,0x00,0 }/* End mark */
} ;
-struct XGI330_VCLKDataStruct XGI_VBVCLKData[] =
+static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] =
{
{ 0x1B,0xE1,25 },/* 00 (25.175MHz) */
@@ -3960,7 +3994,8 @@ struct XGI330_VCLKDataStruct XGI_VBVCLKData[] =
{ 0xFF,0x00,0 } /* End mark */
};
-unsigned char XGI660_TVDelayList[] =
+#if 0
+static unsigned char XGI660_TVDelayList[] =
{
0x44, /* ; 0 ExtNTSCDelay */
0x44, /* ; 1 StNTSCDelay */
@@ -3976,7 +4011,7 @@ unsigned char XGI660_TVDelayList[] =
0x44 /* ; B StYPbPrDealy(750p) */
};
-unsigned char XGI660_TVDelayList2[] =
+static unsigned char XGI660_TVDelayList2[] =
{
0x44, /* ; 0 ExtNTSCDelay */
0x44, /* ; 1 StNTSCDelay */
@@ -3991,8 +4026,9 @@ unsigned char XGI660_TVDelayList2[] =
0x44, /* ; A ExtYPbPrDelay(750p) */
0x44 /* ; B StYPbPrDealy(750p) */
};
+#endif
-unsigned char XGI301TVDelayList[] =
+static unsigned char XGI301TVDelayList[] =
{
0x22, /* ; 0 ExtNTSCDelay */
0x22, /* ; 1 StNTSCDelay */
@@ -4008,7 +4044,7 @@ unsigned char XGI301TVDelayList[] =
0x22 /* B StYPbPrDealy(750p) */
};
-unsigned char XGI301TVDelayList2[] =
+static unsigned char XGI301TVDelayList2[] =
{
0x22, /* ; 0 ExtNTSCDelay */
0x22, /* ; 1 StNTSCDelay */
@@ -4025,7 +4061,7 @@ unsigned char XGI301TVDelayList2[] =
};
-unsigned char TVAntiFlickList[] =
+static unsigned char TVAntiFlickList[] =
{/* NTSCAntiFlicker */
0x04, /* ; 0 Adaptive */
0x00, /* ; 1 new anti-flicker ? */
@@ -4038,7 +4074,7 @@ unsigned char TVAntiFlickList[] =
};
-unsigned char TVEdgeList[] =
+static unsigned char TVEdgeList[] =
{
0x00, /* ; 0 NTSC No Edge enhance */
0x04, /* ; 1 NTSC Adaptive Edge enhance */
@@ -4048,7 +4084,7 @@ unsigned char TVEdgeList[] =
0x00 /* ; 1 HiTV */
};
-unsigned long TVPhaseList[] =
+static unsigned long TVPhaseList[] =
{ 0x08BAED21, /* ; 0 NTSC phase */
0x00E3052A, /* ; 1 PAL phase */
0x9B2EE421, /* ; 2 PAL-M phase */
@@ -4065,7 +4101,7 @@ unsigned long TVPhaseList[] =
0xE00A831E /* ; D PAL-M 1024x768 */
};
-unsigned char NTSCYFilter1[] =
+static unsigned char NTSCYFilter1[] =
{
0x00,0xF4,0x10,0x38 ,/* 0 : 320x text mode */
0x00,0xF4,0x10,0x38 ,/* 1 : 360x text mode */
@@ -4076,7 +4112,7 @@ unsigned char NTSCYFilter1[] =
0xEB,0x15,0x25,0xF6 /* 6 : 800x gra. mode */
};
-unsigned char PALYFilter1[] =
+static unsigned char PALYFilter1[] =
{
0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
0x00,0xF4,0x10,0x38 ,/* 1 : 360x text mode */
@@ -4087,7 +4123,7 @@ unsigned char PALYFilter1[] =
0xFC,0xFB,0x14,0x2A /* 6 : 800x gra. mode */
};
-unsigned char PALMYFilter1[] =
+static unsigned char PALMYFilter1[] =
{
0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
@@ -4099,7 +4135,7 @@ unsigned char PALMYFilter1[] =
0xFF,0xFF,0xFF,0xFF /* End of Table */
};
-unsigned char PALNYFilter1[] =
+static unsigned char PALNYFilter1[] =
{
0x00,0xF4,0x10,0x38, /* 0 : 320x text mode */
0x00,0xF4,0x10,0x38, /* 1 : 360x text mode */
@@ -4111,7 +4147,7 @@ unsigned char PALNYFilter1[] =
0xFF,0xFF,0xFF,0xFF /* End of Table */
};
-unsigned char NTSCYFilter2[] =
+static unsigned char NTSCYFilter2[] =
{
0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
@@ -4123,7 +4159,7 @@ unsigned char NTSCYFilter2[] =
0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
};
-unsigned char PALYFilter2[] =
+static unsigned char PALYFilter2[] =
{
0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
@@ -4135,7 +4171,7 @@ unsigned char PALYFilter2[] =
0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
};
-unsigned char PALMYFilter2[] =
+static unsigned char PALMYFilter2[] =
{
0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
@@ -4147,7 +4183,7 @@ unsigned char PALMYFilter2[] =
0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
};
-unsigned char PALNYFilter2[] =
+static unsigned char PALNYFilter2[] =
{
0xFF,0x03,0x02,0xF6,0xFC,0x27,0x46, /* 0 : 320x text mode */
0x01,0x02,0xFE,0xF7,0x03,0x27,0x3C, /* 1 : 360x text mode */
@@ -4159,14 +4195,14 @@ unsigned char PALNYFilter2[] =
0xFF,0xFF,0xFC,0x00,0x0F,0x22,0x28 /* 7 : 1024xgra. mode */
};
-unsigned char XGI_NTSC1024AdjTime[] =
+static unsigned char XGI_NTSC1024AdjTime[] =
{
0xa7,0x07,0xf2,0x6e,0x17,0x8b,0x73,0x53,
0x13,0x40,0x34,0xF4,0x63,0xBB,0xCC,0x7A,
0x58,0xe4,0x73,0xd0,0x13
};
-struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] =
{
{0,{
0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
@@ -4181,7 +4217,7 @@ struct XGI301C_Tap4TimingStruct HiTVTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] =
{
{0,{
0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
@@ -4196,7 +4232,7 @@ struct XGI301C_Tap4TimingStruct EnlargeTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] =
{
{0,{
0x00,0x20,0x00,0x00,0x7F,0x20,0x02,0x7F, /* ; C0-C7 */
@@ -4211,7 +4247,7 @@ struct XGI301C_Tap4TimingStruct NoScaleTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct PALTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct PALTap4Timing[] =
{
{600, {
0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
@@ -4249,7 +4285,7 @@ struct XGI301C_Tap4TimingStruct PALTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] =
{
{480, {
0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
@@ -4287,7 +4323,7 @@ struct XGI301C_Tap4TimingStruct NTSCTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] =
{
{480, {
0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
@@ -4325,7 +4361,7 @@ struct XGI301C_Tap4TimingStruct YPbPr525pTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] =
{
{480, {
0x04,0x1A,0x04,0x7E,0x03,0x1A,0x06,0x7D, /* ; C0-C7 */
@@ -4363,7 +4399,7 @@ struct XGI301C_Tap4TimingStruct YPbPr525iTap4Timing[] =
}
};
-struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] =
+static struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] =
{ {0xFFFF,
{
0x05,0x19,0x05,0x7D,0x03,0x19,0x06,0x7E, /* ; C0-C7 */
diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c
index 2c40368ceee2..ae27f0ca093e 100644
--- a/drivers/staging/xgifb/vb_util.c
+++ b/drivers/staging/xgifb/vb_util.c
@@ -170,7 +170,7 @@ void XGINew_SetRegOR( unsigned long Port , unsigned short Index , unsigned short
XGINew_SetReg1( Port , Index , temp ) ;
}
-
+#if 0
/* --------------------------------------------------------------------- */
/* Function : NewDelaySecond */
/* Input : */
@@ -190,7 +190,6 @@ void NewDelaySeconds( int seconds )
}
}
-
/* --------------------------------------------------------------------- */
/* Function : Newdebugcode */
/* Input : */
@@ -203,6 +202,4 @@ void Newdebugcode(unsigned char code)
/* OutPortByte ( 0x300 , code ) ; */
/* NewDelaySeconds( 0x3 ) ; */
}
-
-
-
+#endif
diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig
index 4654ae2eb42e..da079f8d6e3d 100644
--- a/drivers/staging/zram/Kconfig
+++ b/drivers/staging/zram/Kconfig
@@ -15,15 +15,3 @@ config ZRAM
See zram.txt for more information.
Project home: http://compcache.googlecode.com/
-
-config ZRAM_STATS
- bool "Enable statistics for compressed RAM disks"
- depends on ZRAM
- default y
- help
- Enable statistics collection for compressed RAM devices. Statistics
- are exported through ioctl interface, so you have to use zramconfig
- program to get them. This adds only a minimal overhead.
-
- If unsure, say Y.
-
diff --git a/drivers/staging/zram/Makefile b/drivers/staging/zram/Makefile
index b2c087aa105e..c01160a98d10 100644
--- a/drivers/staging/zram/Makefile
+++ b/drivers/staging/zram/Makefile
@@ -1,3 +1,3 @@
-zram-objs := zram_drv.o xvmalloc.o
+zram-objs := zram_drv.o zram_sysfs.o xvmalloc.o
obj-$(CONFIG_ZRAM) += zram.o
diff --git a/drivers/staging/zram/zram.txt b/drivers/staging/zram/zram.txt
index 520edc1bea73..5f75d2987564 100644
--- a/drivers/staging/zram/zram.txt
+++ b/drivers/staging/zram/zram.txt
@@ -5,33 +5,35 @@ Project home: http://compcache.googlecode.com/
* Introduction
-The zram module creates RAM based block devices: /dev/ramX (X = 0, 1, ...).
-Pages written to these disks are compressed and stored in memory itself.
-These disks allow very fast I/O and compression provides good amounts of
-memory savings.
+The zram module creates RAM based block devices named /dev/zram<id>
+(<id> = 0, 1, ...). Pages written to these disks are compressed and stored
+in memory itself. These disks allow very fast I/O and compression provides
+good amounts of memory savings. Some of the usecases include /tmp storage,
+use as swap disks, various caches under /var and maybe many more :)
-See project home for use cases, performance numbers and a lot more.
-
-Individual zram devices are configured and initialized using zramconfig
-userspace utility as shown in examples below. See zramconfig man page for
-more details.
+Statistics for individual zram devices are exported through sysfs nodes at
+/sys/block/zram<id>/
* Usage
Following shows a typical sequence of steps for using zram.
-1) Load Modules:
+1) Load Module:
modprobe zram num_devices=4
- This creates 4 (uninitialized) devices: /dev/zram{0,1,2,3}
+ This creates 4 devices: /dev/zram{0,1,2,3}
(num_devices parameter is optional. Default: 1)
-2) Initialize:
- Use zramconfig utility to configure and initialize individual
- zram devices. For example:
- zramconfig /dev/zram0 --init # uses default value of disksize_kb
- zramconfig /dev/zram1 --disksize_kb=102400 # 100MB /dev/zram1
+2) Set Disksize (Optional):
+ Set disk size by writing the value to sysfs node 'disksize'
+ (in bytes). If disksize is not given, default value of 25%
+ of RAM is used.
+
+ # Initialize /dev/zram0 with 50MB disksize
+ echo $((50*1024*1024)) > /sys/block/zram0/disksize
- *See zramconfig man page for more details and examples*
+ NOTE: disksize cannot be changed if the disk contains any
+ data. So, for such a disk, you need to issue 'reset' (see below)
+ before you can change its disksize.
3) Activate:
mkswap /dev/zram0
@@ -41,17 +43,29 @@ Following shows a typical sequence of steps for using zram.
mount /dev/zram1 /tmp
4) Stats:
- zramconfig /dev/zram0 --stats
- zramconfig /dev/zram1 --stats
+ Per-device statistics are exported as various nodes under
+ /sys/block/zram<id>/
+ disksize
+ num_reads
+ num_writes
+ invalid_io
+ notify_free
+ discard
+ zero_pages
+ orig_data_size
+ compr_data_size
+ mem_used_total
5) Deactivate:
swapoff /dev/zram0
umount /dev/zram1
6) Reset:
- zramconfig /dev/zram0 --reset
- zramconfig /dev/zram1 --reset
- (This frees memory allocated for the given device).
+ Write any positive value to 'reset' sysfs node
+ echo 1 > /sys/block/zram0/reset
+ echo 1 > /sys/block/zram1/reset
+
+ (This frees all the memory allocated for the given device).
Please report any problems at:
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 722c840ac638..d0e9e0207539 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -33,10 +33,39 @@
/* Globals */
static int zram_major;
-static struct zram *devices;
+struct zram *devices;
/* Module params (documentation at end) */
-static unsigned int num_devices;
+unsigned int num_devices;
+
+static void zram_stat_inc(u32 *v)
+{
+ *v = *v + 1;
+}
+
+static void zram_stat_dec(u32 *v)
+{
+ *v = *v - 1;
+}
+
+static void zram_stat64_add(struct zram *zram, u64 *v, u64 inc)
+{
+ spin_lock(&zram->stat64_lock);
+ *v = *v + inc;
+ spin_unlock(&zram->stat64_lock);
+}
+
+static void zram_stat64_sub(struct zram *zram, u64 *v, u64 dec)
+{
+ spin_lock(&zram->stat64_lock);
+ *v = *v - dec;
+ spin_unlock(&zram->stat64_lock);
+}
+
+static void zram_stat64_inc(struct zram *zram, u64 *v)
+{
+ zram_stat64_add(zram, v, 1);
+}
static int zram_test_flag(struct zram *zram, u32 index,
enum zram_pageflags flag)
@@ -91,7 +120,7 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
"the disk when not in use so a huge zram is "
"wasteful.\n"
"\tMemory Size: %zu kB\n"
- "\tSize you selected: %zu kB\n"
+ "\tSize you selected: %llu kB\n"
"Continuing anyway ...\n",
totalram_bytes >> 10, zram->disksize
);
@@ -100,49 +129,6 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
zram->disksize &= PAGE_MASK;
}
-static void zram_ioctl_get_stats(struct zram *zram,
- struct zram_ioctl_stats *s)
-{
- s->disksize = zram->disksize;
-
-#if defined(CONFIG_ZRAM_STATS)
- {
- struct zram_stats *rs = &zram->stats;
- size_t succ_writes, mem_used;
- unsigned int good_compress_perc = 0, no_compress_perc = 0;
-
- mem_used = xv_get_total_size_bytes(zram->mem_pool)
- + (rs->pages_expand << PAGE_SHIFT);
- succ_writes = zram_stat64_read(zram, &rs->num_writes) -
- zram_stat64_read(zram, &rs->failed_writes);
-
- if (succ_writes && rs->pages_stored) {
- good_compress_perc = rs->good_compress * 100
- / rs->pages_stored;
- no_compress_perc = rs->pages_expand * 100
- / rs->pages_stored;
- }
-
- s->num_reads = zram_stat64_read(zram, &rs->num_reads);
- s->num_writes = zram_stat64_read(zram, &rs->num_writes);
- s->failed_reads = zram_stat64_read(zram, &rs->failed_reads);
- s->failed_writes = zram_stat64_read(zram, &rs->failed_writes);
- s->invalid_io = zram_stat64_read(zram, &rs->invalid_io);
- s->notify_free = zram_stat64_read(zram, &rs->notify_free);
- s->pages_zero = rs->pages_zero;
-
- s->good_compress_pct = good_compress_perc;
- s->pages_expand_pct = no_compress_perc;
-
- s->pages_stored = rs->pages_stored;
- s->pages_used = mem_used >> PAGE_SHIFT;
- s->orig_data_size = rs->pages_stored << PAGE_SHIFT;
- s->compr_data_size = rs->compr_size;
- s->mem_used_total = mem_used;
- }
-#endif /* CONFIG_ZRAM_STATS */
-}
-
static void zram_free_page(struct zram *zram, size_t index)
{
u32 clen;
@@ -180,7 +166,7 @@ static void zram_free_page(struct zram *zram, size_t index)
zram_stat_dec(&zram->stats.good_compress);
out:
- zram->stats.compr_size -= clen;
+ zram_stat64_sub(zram, &zram->stats.compr_size, clen);
zram_stat_dec(&zram->stats.pages_stored);
zram->table[index].page = NULL;
@@ -221,9 +207,15 @@ static int zram_read(struct zram *zram, struct bio *bio)
u32 index;
struct bio_vec *bvec;
- zram_stat64_inc(zram, &zram->stats.num_reads);
+ if (unlikely(!zram->init_done)) {
+ set_bit(BIO_UPTODATE, &bio->bi_flags);
+ bio_endio(bio, 0);
+ return 0;
+ }
+ zram_stat64_inc(zram, &zram->stats.num_reads);
index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT;
+
bio_for_each_segment(bvec, bio, i) {
int ret;
size_t clen;
@@ -289,16 +281,20 @@ out:
static int zram_write(struct zram *zram, struct bio *bio)
{
- int i;
+ int i, ret;
u32 index;
struct bio_vec *bvec;
- zram_stat64_inc(zram, &zram->stats.num_writes);
+ if (unlikely(!zram->init_done)) {
+ ret = zram_init_device(zram);
+ if (ret)
+ goto out;
+ }
+ zram_stat64_inc(zram, &zram->stats.num_writes);
index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT;
bio_for_each_segment(bvec, bio, i) {
- int ret;
u32 offset;
size_t clen;
struct zobj_header *zheader;
@@ -396,7 +392,7 @@ memstore:
kunmap_atomic(src, KM_USER0);
/* Update stats */
- zram->stats.compr_size += clen;
+ zram_stat64_add(zram, &zram->stats.compr_size, clen);
zram_stat_inc(&zram->stats.pages_stored);
if (clen <= PAGE_SIZE / 2)
zram_stat_inc(&zram->stats.good_compress);
@@ -439,11 +435,6 @@ static int zram_make_request(struct request_queue *queue, struct bio *bio)
int ret = 0;
struct zram *zram = queue->queuedata;
- if (unlikely(!zram->init_done)) {
- bio_io_error(bio);
- return 0;
- }
-
if (!valid_io_request(zram, bio)) {
zram_stat64_inc(zram, &zram->stats.invalid_io);
bio_io_error(bio);
@@ -463,11 +454,11 @@ static int zram_make_request(struct request_queue *queue, struct bio *bio)
return ret;
}
-static void reset_device(struct zram *zram)
+void zram_reset_device(struct zram *zram)
{
size_t index;
- /* Do not accept any new I/O request */
+ mutex_lock(&zram->init_lock);
zram->init_done = 0;
/* Free various per-device buffers */
@@ -504,16 +495,19 @@ static void reset_device(struct zram *zram)
memset(&zram->stats, 0, sizeof(zram->stats));
zram->disksize = 0;
+ mutex_unlock(&zram->init_lock);
}
-static int zram_ioctl_init_device(struct zram *zram)
+int zram_init_device(struct zram *zram)
{
int ret;
size_t num_pages;
+ mutex_lock(&zram->init_lock);
+
if (zram->init_done) {
- pr_info("Device already initialized!\n");
- return -EBUSY;
+ mutex_unlock(&zram->init_lock);
+ return 0;
}
zram_set_disksize(zram, totalram_pages << PAGE_SHIFT);
@@ -556,96 +550,19 @@ static int zram_ioctl_init_device(struct zram *zram)
}
zram->init_done = 1;
+ mutex_unlock(&zram->init_lock);
pr_debug("Initialization done!\n");
return 0;
fail:
- reset_device(zram);
+ mutex_unlock(&zram->init_lock);
+ zram_reset_device(zram);
pr_err("Initialization failed: err=%d\n", ret);
return ret;
}
-static int zram_ioctl_reset_device(struct zram *zram)
-{
- if (zram->init_done)
- reset_device(zram);
-
- return 0;
-}
-
-static int zram_ioctl(struct block_device *bdev, fmode_t mode,
- unsigned int cmd, unsigned long arg)
-{
- int ret = 0;
- size_t disksize_kb;
-
- struct zram *zram = bdev->bd_disk->private_data;
-
- switch (cmd) {
- case ZRAMIO_SET_DISKSIZE_KB:
- if (zram->init_done) {
- ret = -EBUSY;
- goto out;
- }
- if (copy_from_user(&disksize_kb, (void *)arg,
- _IOC_SIZE(cmd))) {
- ret = -EFAULT;
- goto out;
- }
- zram->disksize = disksize_kb << 10;
- pr_info("Disk size set to %zu kB\n", disksize_kb);
- break;
-
- case ZRAMIO_GET_STATS:
- {
- struct zram_ioctl_stats *stats;
- if (!zram->init_done) {
- ret = -ENOTTY;
- goto out;
- }
- stats = kzalloc(sizeof(*stats), GFP_KERNEL);
- if (!stats) {
- ret = -ENOMEM;
- goto out;
- }
- zram_ioctl_get_stats(zram, stats);
- if (copy_to_user((void *)arg, stats, sizeof(*stats))) {
- kfree(stats);
- ret = -EFAULT;
- goto out;
- }
- kfree(stats);
- break;
- }
- case ZRAMIO_INIT:
- ret = zram_ioctl_init_device(zram);
- break;
-
- case ZRAMIO_RESET:
- /* Do not reset an active device! */
- if (bdev->bd_holders) {
- ret = -EBUSY;
- goto out;
- }
-
- /* Make sure all pending I/O is finished */
- if (bdev)
- fsync_bdev(bdev);
-
- ret = zram_ioctl_reset_device(zram);
- break;
-
- default:
- pr_info("Invalid ioctl %u\n", cmd);
- ret = -ENOTTY;
- }
-
-out:
- return ret;
-}
-
void zram_slot_free_notify(struct block_device *bdev, unsigned long index)
{
struct zram *zram;
@@ -656,7 +573,6 @@ void zram_slot_free_notify(struct block_device *bdev, unsigned long index)
}
static const struct block_device_operations zram_devops = {
- .ioctl = zram_ioctl,
.swap_slot_free_notify = zram_slot_free_notify,
.owner = THIS_MODULE
};
@@ -666,6 +582,7 @@ static int create_device(struct zram *zram, int device_id)
int ret = 0;
mutex_init(&zram->lock);
+ mutex_init(&zram->init_lock);
spin_lock_init(&zram->stat64_lock);
zram->queue = blk_alloc_queue(GFP_KERNEL);
@@ -696,7 +613,7 @@ static int create_device(struct zram *zram, int device_id)
zram->disk->private_data = zram;
snprintf(zram->disk->disk_name, 16, "zram%d", device_id);
- /* Actual capacity set using ZRAMIO_SET_DISKSIZE_KB ioctl */
+ /* Actual capacity set using syfs (/sys/block/zram<id>/disksize */
set_capacity(zram->disk, 0);
/*
@@ -710,6 +627,15 @@ static int create_device(struct zram *zram, int device_id)
add_disk(zram->disk);
+#ifdef CONFIG_SYSFS
+ ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,
+ &zram_disk_attr_group);
+ if (ret < 0) {
+ pr_warning("Error creating sysfs group");
+ goto out;
+ }
+#endif
+
zram->init_done = 0;
out:
@@ -718,6 +644,11 @@ out:
static void destroy_device(struct zram *zram)
{
+#ifdef CONFIG_SYSFS
+ sysfs_remove_group(&disk_to_dev(zram->disk)->kobj,
+ &zram_disk_attr_group);
+#endif
+
if (zram->disk) {
del_gendisk(zram->disk);
put_disk(zram->disk);
@@ -786,7 +717,7 @@ static void __exit zram_exit(void)
destroy_device(zram);
if (zram->init_done)
- reset_device(zram);
+ zram_reset_device(zram);
}
unregister_blkdev(zram_major, "zram");
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index 945f9740442f..a48155112b1e 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -18,7 +18,6 @@
#include <linux/spinlock.h>
#include <linux/mutex.h>
-#include "zram_ioctl.h"
#include "xvmalloc.h"
/*
@@ -85,11 +84,7 @@ struct table {
} __attribute__((aligned(4)));
struct zram_stats {
- /* basic stats */
- size_t compr_size; /* compressed size of pages stored -
- * needed to enforce memlimit */
- /* more stats */
-#if defined(CONFIG_ZRAM_STATS)
+ u64 compr_size; /* compressed size of pages stored */
u64 num_reads; /* failed + successful */
u64 num_writes; /* --do-- */
u64 failed_reads; /* should NEVER! happen */
@@ -100,7 +95,6 @@ struct zram_stats {
u32 pages_stored; /* no. of pages currently stored */
u32 good_compress; /* % of pages with compression ratio<=50% */
u32 pages_expand; /* % of incompressible pages */
-#endif
};
struct zram {
@@ -114,51 +108,24 @@ struct zram {
struct request_queue *queue;
struct gendisk *disk;
int init_done;
+ /* Prevent concurrent execution of device init and reset */
+ struct mutex init_lock;
/*
* This is the limit on amount of *uncompressed* worth of data
* we can store in a disk.
*/
- size_t disksize; /* bytes */
+ u64 disksize; /* bytes */
struct zram_stats stats;
};
-/*-- */
-
-/* Debugging and Stats */
-#if defined(CONFIG_ZRAM_STATS)
-static void zram_stat_inc(u32 *v)
-{
- *v = *v + 1;
-}
-
-static void zram_stat_dec(u32 *v)
-{
- *v = *v - 1;
-}
-
-static void zram_stat64_inc(struct zram *zram, u64 *v)
-{
- spin_lock(&zram->stat64_lock);
- *v = *v + 1;
- spin_unlock(&zram->stat64_lock);
-}
-
-static u64 zram_stat64_read(struct zram *zram, u64 *v)
-{
- u64 val;
-
- spin_lock(&zram->stat64_lock);
- val = *v;
- spin_unlock(&zram->stat64_lock);
-
- return val;
-}
-#else
-#define zram_stat_inc(v)
-#define zram_stat_dec(v)
-#define zram_stat64_inc(r, v)
-#define zram_stat64_read(r, v)
-#endif /* CONFIG_ZRAM_STATS */
+extern struct zram *devices;
+extern unsigned int num_devices;
+#ifdef CONFIG_SYSFS
+extern struct attribute_group zram_disk_attr_group;
+#endif
+
+extern int zram_init_device(struct zram *zram);
+extern void zram_reset_device(struct zram *zram);
#endif
diff --git a/drivers/staging/zram/zram_ioctl.h b/drivers/staging/zram/zram_ioctl.h
deleted file mode 100644
index 5c415fa4f17b..000000000000
--- a/drivers/staging/zram/zram_ioctl.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Compressed RAM block device
- *
- * Copyright (C) 2008, 2009, 2010 Nitin Gupta
- *
- * This code is released using a dual license strategy: BSD/GPL
- * You can choose the licence that better fits your requirements.
- *
- * Released under the terms of 3-clause BSD License
- * Released under the terms of GNU General Public License Version 2.0
- *
- * Project home: http://compcache.googlecode.com
- */
-
-#ifndef _ZRAM_IOCTL_H_
-#define _ZRAM_IOCTL_H_
-
-struct zram_ioctl_stats {
- u64 disksize; /* disksize in bytes (user specifies in KB) */
- u64 num_reads; /* failed + successful */
- u64 num_writes; /* --do-- */
- u64 failed_reads; /* should NEVER! happen */
- u64 failed_writes; /* can happen when memory is too low */
- u64 invalid_io; /* non-page-aligned I/O requests */
- u64 notify_free; /* no. of swap slot free notifications */
- u32 pages_zero; /* no. of zero filled pages */
- u32 good_compress_pct; /* no. of pages with compression ratio<=50% */
- u32 pages_expand_pct; /* no. of incompressible pages */
- u32 pages_stored;
- u32 pages_used;
- u64 orig_data_size;
- u64 compr_data_size;
- u64 mem_used_total;
-} __attribute__ ((packed, aligned(4)));
-
-#define ZRAMIO_SET_DISKSIZE_KB _IOW('z', 0, size_t)
-#define ZRAMIO_GET_STATS _IOR('z', 1, struct zram_ioctl_stats)
-#define ZRAMIO_INIT _IO('z', 2)
-#define ZRAMIO_RESET _IO('z', 3)
-
-#endif
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
new file mode 100644
index 000000000000..6c574a994d11
--- /dev/null
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -0,0 +1,224 @@
+/*
+ * Compressed RAM block device
+ *
+ * Copyright (C) 2008, 2009, 2010 Nitin Gupta
+ *
+ * This code is released using a dual license strategy: BSD/GPL
+ * You can choose the licence that better fits your requirements.
+ *
+ * Released under the terms of 3-clause BSD License
+ * Released under the terms of GNU General Public License Version 2.0
+ *
+ * Project home: http://compcache.googlecode.com/
+ */
+
+#include <linux/device.h>
+#include <linux/genhd.h>
+
+#include "zram_drv.h"
+
+#ifdef CONFIG_SYSFS
+
+static u64 zram_stat64_read(struct zram *zram, u64 *v)
+{
+ u64 val;
+
+ spin_lock(&zram->stat64_lock);
+ val = *v;
+ spin_unlock(&zram->stat64_lock);
+
+ return val;
+}
+
+static struct zram *dev_to_zram(struct device *dev)
+{
+ int i;
+ struct zram *zram = NULL;
+
+ for (i = 0; i < num_devices; i++) {
+ zram = &devices[i];
+ if (disk_to_dev(zram->disk) == dev)
+ break;
+ }
+
+ return zram;
+}
+
+static ssize_t disksize_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n", zram->disksize);
+}
+
+static ssize_t disksize_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ int ret;
+ struct zram *zram = dev_to_zram(dev);
+
+ if (zram->init_done) {
+ pr_info("Cannot change disksize for initialized device\n");
+ return -EBUSY;
+ }
+
+ ret = strict_strtoull(buf, 10, &zram->disksize);
+ if (ret)
+ return ret;
+
+ zram->disksize &= PAGE_MASK;
+ set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
+
+ return len;
+}
+
+static ssize_t initstate_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%u\n", zram->init_done);
+}
+
+static ssize_t reset_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ int ret;
+ unsigned long do_reset;
+ struct zram *zram;
+ struct block_device *bdev;
+
+ zram = dev_to_zram(dev);
+ bdev = bdget_disk(zram->disk, 0);
+
+ /* Do not reset an active device! */
+ if (bdev->bd_holders)
+ return -EBUSY;
+
+ ret = strict_strtoul(buf, 10, &do_reset);
+ if (ret)
+ return ret;
+
+ if (!do_reset)
+ return -EINVAL;
+
+ /* Make sure all pending I/O is finished */
+ if (bdev)
+ fsync_bdev(bdev);
+
+ if (zram->init_done)
+ zram_reset_device(zram);
+
+ return len;
+}
+
+static ssize_t num_reads_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ zram_stat64_read(zram, &zram->stats.num_reads));
+}
+
+static ssize_t num_writes_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ zram_stat64_read(zram, &zram->stats.num_writes));
+}
+
+static ssize_t invalid_io_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ zram_stat64_read(zram, &zram->stats.invalid_io));
+}
+
+static ssize_t notify_free_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ zram_stat64_read(zram, &zram->stats.notify_free));
+}
+
+static ssize_t zero_pages_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%u\n", zram->stats.pages_zero);
+}
+
+static ssize_t orig_data_size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ (u64)(zram->stats.pages_stored) << PAGE_SHIFT);
+}
+
+static ssize_t compr_data_size_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct zram *zram = dev_to_zram(dev);
+
+ return sprintf(buf, "%llu\n",
+ zram_stat64_read(zram, &zram->stats.compr_size));
+}
+
+static ssize_t mem_used_total_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ u64 val = 0;
+ struct zram *zram = dev_to_zram(dev);
+
+ if (zram->init_done) {
+ val = xv_get_total_size_bytes(zram->mem_pool) +
+ ((u64)(zram->stats.pages_expand) << PAGE_SHIFT);
+ }
+
+ return sprintf(buf, "%llu\n", val);
+}
+
+static DEVICE_ATTR(disksize, S_IRUGO | S_IWUGO,
+ disksize_show, disksize_store);
+static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL);
+static DEVICE_ATTR(reset, S_IWUGO, NULL, reset_store);
+static DEVICE_ATTR(num_reads, S_IRUGO, num_reads_show, NULL);
+static DEVICE_ATTR(num_writes, S_IRUGO, num_writes_show, NULL);
+static DEVICE_ATTR(invalid_io, S_IRUGO, invalid_io_show, NULL);
+static DEVICE_ATTR(notify_free, S_IRUGO, notify_free_show, NULL);
+static DEVICE_ATTR(zero_pages, S_IRUGO, zero_pages_show, NULL);
+static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL);
+static DEVICE_ATTR(compr_data_size, S_IRUGO, compr_data_size_show, NULL);
+static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL);
+
+static struct attribute *zram_disk_attrs[] = {
+ &dev_attr_disksize.attr,
+ &dev_attr_initstate.attr,
+ &dev_attr_reset.attr,
+ &dev_attr_num_reads.attr,
+ &dev_attr_num_writes.attr,
+ &dev_attr_invalid_io.attr,
+ &dev_attr_notify_free.attr,
+ &dev_attr_zero_pages.attr,
+ &dev_attr_orig_data_size.attr,
+ &dev_attr_compr_data_size.attr,
+ &dev_attr_mem_used_total.attr,
+ NULL,
+};
+
+struct attribute_group zram_disk_attr_group = {
+ .attrs = zram_disk_attrs,
+};
+
+#endif /* CONFIG_SYSFS */