From 010390f8d0350491a86e9d273dc9e1534eb8b6b2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 20 Oct 2018 15:18:20 -0500 Subject: [PATCH] rtl8188eu: Remove some unused files and remove code for platforms other than Linux in os_dep/ Signed-off-by: Larry Finger --- include/drv_types.h | 11 - include/drv_types_gspi.h | 50 --- include/drv_types_sdio.h | 61 --- include/gspi_hal.h | 35 -- include/gspi_ops.h | 185 -------- include/gspi_ops_linux.h | 23 - include/gspi_osintf.h | 23 - include/hal_gspi.h | 31 -- include/pci_hal.h | 53 --- include/pci_ops.h | 96 ----- include/pci_osintf.h | 43 -- os_dep/linux/os_intfs.c | 21 +- os_dep/linux/recv_linux.c | 22 - os_dep/osdep_service.c | 877 +------------------------------------- 14 files changed, 9 insertions(+), 1522 deletions(-) delete mode 100644 include/drv_types_gspi.h delete mode 100644 include/drv_types_sdio.h delete mode 100644 include/gspi_hal.h delete mode 100644 include/gspi_ops.h delete mode 100644 include/gspi_ops_linux.h delete mode 100644 include/gspi_osintf.h delete mode 100644 include/hal_gspi.h delete mode 100644 include/pci_hal.h delete mode 100644 include/pci_ops.h delete mode 100644 include/pci_osintf.h diff --git a/include/drv_types.h b/include/drv_types.h index 79fc83e..1d4e306 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -442,17 +442,6 @@ typedef struct rtw_if_operations { size_t len, bool fixed); } RTW_IF_OPS, *PRTW_IF_OPS; -#ifdef CONFIG_SDIO_HCI - #include - #define INTF_DATA SDIO_DATA - #define INTF_OPS PRTW_IF_OPS -#elif defined(CONFIG_GSPI_HCI) - #include - #define INTF_DATA GSPI_DATA -#elif defined(CONFIG_PCI_HCI) - #include -#endif - #ifdef CONFIG_CONCURRENT_MODE #define is_primary_adapter(adapter) (adapter->adapter_type == PRIMARY_ADAPTER) #define is_vir_adapter(adapter) (adapter->adapter_type == VIRTUAL_ADAPTER) diff --git a/include/drv_types_gspi.h b/include/drv_types_gspi.h deleted file mode 100644 index 20c8ae1..0000000 --- a/include/drv_types_gspi.h +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __DRV_TYPES_GSPI_H__ -#define __DRV_TYPES_GSPI_H__ - -/* SPI Header Files */ - #include - #include - #include - /* #include */ - #include - #include - #include - #include - #include - #include - #include - - -typedef struct gspi_data { - u8 func_number; - - u8 tx_block_mode; - u8 rx_block_mode; - u32 block_transfer_len; - - struct spi_device *func; - - struct workqueue_struct *priv_wq; - struct delayed_work irq_work; -} GSPI_DATA, *PGSPI_DATA; - -#endif /* #ifndef __DRV_TYPES_GSPI_H__ */ diff --git a/include/drv_types_sdio.h b/include/drv_types_sdio.h deleted file mode 100644 index 451a839..0000000 --- a/include/drv_types_sdio.h +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __DRV_TYPES_SDIO_H__ -#define __DRV_TYPES_SDIO_H__ - -/* SDIO Header Files */ - #include - #include - - #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) || defined(CONFIG_PLATFORM_SPRD) - #include - #include - #endif - - #ifdef CONFIG_PLATFORM_SPRD - #include - #include - #endif /* CONFIG_PLATFORM_SPRD */ - -typedef struct sdio_data { - u8 func_number; - - u8 tx_block_mode; - u8 rx_block_mode; - u32 block_transfer_len; - - struct sdio_func *func; - _thread_hdl_ sys_sdio_irq_thd; - -} SDIO_DATA, *PSDIO_DATA; - -#define dvobj_to_sdio_func(d) ((d)->intf_data.func) - -#define RTW_SDIO_ADDR_CMD52_BIT (1<<17) -#define RTW_SDIO_ADDR_CMD52_GEN(a) (a | RTW_SDIO_ADDR_CMD52_BIT) -#define RTW_SDIO_ADDR_CMD52_CLR(a) (a&~RTW_SDIO_ADDR_CMD52_BIT) -#define RTW_SDIO_ADDR_CMD52_CHK(a) (a&RTW_SDIO_ADDR_CMD52_BIT ? 1 : 0) - -#define RTW_SDIO_ADDR_F0_BIT (1<<18) -#define RTW_SDIO_ADDR_F0_GEN(a) (a | RTW_SDIO_ADDR_F0_BIT) -#define RTW_SDIO_ADDR_F0_CLR(a) (a&~RTW_SDIO_ADDR_F0_BIT) -#define RTW_SDIO_ADDR_F0_CHK(a) (a&RTW_SDIO_ADDR_F0_BIT ? 1 : 0) - -#endif diff --git a/include/gspi_hal.h b/include/gspi_hal.h deleted file mode 100644 index 98fec09..0000000 --- a/include/gspi_hal.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __GSPI_HAL_H__ -#define __GSPI_HAL_H__ - - -void spi_int_dpc(PADAPTER padapter, u32 sdio_hisr); -u8 rtw_set_hal_ops(_adapter *padapter); - -#ifdef CONFIG_RTL8188E - void rtl8188es_set_hal_ops(PADAPTER padapter); -#endif - -#ifdef CONFIG_RTL8723B - void rtl8723bs_set_hal_ops(PADAPTER padapter); -#endif - -#endif /* __GSPI_HAL_H__ */ diff --git a/include/gspi_ops.h b/include/gspi_ops.h deleted file mode 100644 index 7a8cb63..0000000 --- a/include/gspi_ops.h +++ /dev/null @@ -1,185 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __GSPI_OPS_H__ -#define __GSPI_OPS_H__ - -/* follwing defination is based on - * GSPI spec of RTL8723, we temp - * suppose that it will be the same - * for diff chips of GSPI, if not - * we should move it to HAL folder */ -#define SPI_LOCAL_DOMAIN 0x0 -#define WLAN_IOREG_DOMAIN 0x8 -#define FW_FIFO_DOMAIN 0x4 -#define TX_HIQ_DOMAIN 0xc -#define TX_MIQ_DOMAIN 0xd -#define TX_LOQ_DOMAIN 0xe -#define RX_RXFIFO_DOMAIN 0x1f - -/* IO Bus domain address mapping */ -#define DEFUALT_OFFSET 0x0 -#define SPI_LOCAL_OFFSET 0x10250000 -#define WLAN_IOREG_OFFSET 0x10260000 -#define FW_FIFO_OFFSET 0x10270000 -#define TX_HIQ_OFFSET 0x10310000 -#define TX_MIQ_OFFSET 0x1032000 -#define TX_LOQ_OFFSET 0x10330000 -#define RX_RXOFF_OFFSET 0x10340000 - -/* SPI Local registers */ -#define SPI_REG_TX_CTRL 0x0000 /* SPI Tx Control */ -#define SPI_REG_STATUS_RECOVERY 0x0004 -#define SPI_REG_INT_TIMEOUT 0x0006 -#define SPI_REG_HIMR 0x0014 /* SPI Host Interrupt Mask */ -#define SPI_REG_HISR 0x0018 /* SPI Host Interrupt Service Routine */ -#define SPI_REG_RX0_REQ_LEN 0x001C /* RXDMA Request Length */ -#define SPI_REG_FREE_TXPG 0x0020 /* Free Tx Buffer Page */ -#define SPI_REG_HCPWM1 0x0024 /* HCI Current Power Mode 1 */ -#define SPI_REG_HCPWM2 0x0026 /* HCI Current Power Mode 2 */ -#define SPI_REG_HTSFR_INFO 0x0030 /* HTSF Informaion */ -#define SPI_REG_HRPWM1 0x0080 /* HCI Request Power Mode 1 */ -#define SPI_REG_HRPWM2 0x0082 /* HCI Request Power Mode 2 */ -#define SPI_REG_HPS_CLKR 0x0084 /* HCI Power Save Clock */ -#define SPI_REG_HSUS_CTRL 0x0086 /* SPI HCI Suspend Control */ -#define SPI_REG_HIMR_ON 0x0090 /* SPI Host Extension Interrupt Mask Always */ -#define SPI_REG_HISR_ON 0x0091 /* SPI Host Extension Interrupt Status Always */ -#define SPI_REG_CFG 0x00F0 /* SPI Configuration Register */ - -#define SPI_TX_CTRL (SPI_REG_TX_CTRL | SPI_LOCAL_OFFSET) -#define SPI_STATUS_RECOVERY (SPI_REG_STATUS_RECOVERY | SPI_LOCAL_OFFSET) -#define SPI_INT_TIMEOUT (SPI_REG_INT_TIMEOUT | SPI_LOCAL_OFFSET) -#define SPI_HIMR (SPI_REG_HIMR | SPI_LOCAL_OFFSET) -#define SPI_HISR (SPI_REG_HISR | SPI_LOCAL_OFFSET) -#define SPI_RX0_REQ_LEN_1_BYTE (SPI_REG_RX0_REQ_LEN | SPI_LOCAL_OFFSET) -#define SPI_FREE_TXPG (SPI_REG_FREE_TXPG | SPI_LOCAL_OFFSET) - -#define SPI_HIMR_DISABLED 0 - -/* SPI HIMR MASK diff with SDIO */ -#define SPI_HISR_RX_REQUEST BIT(0) -#define SPI_HISR_AVAL BIT(1) -#define SPI_HISR_TXERR BIT(2) -#define SPI_HISR_RXERR BIT(3) -#define SPI_HISR_TXFOVW BIT(4) -#define SPI_HISR_RXFOVW BIT(5) -#define SPI_HISR_TXBCNOK BIT(6) -#define SPI_HISR_TXBCNERR BIT(7) -#define SPI_HISR_BCNERLY_INT BIT(16) -#define SPI_HISR_ATIMEND BIT(17) -#define SPI_HISR_ATIMEND_E BIT(18) -#define SPI_HISR_CTWEND BIT(19) -#define SPI_HISR_C2HCMD BIT(20) -#define SPI_HISR_CPWM1 BIT(21) -#define SPI_HISR_CPWM2 BIT(22) -#define SPI_HISR_HSISR_IND BIT(23) -#define SPI_HISR_GTINT3_IND BIT(24) -#define SPI_HISR_GTINT4_IND BIT(25) -#define SPI_HISR_PSTIMEOUT BIT(26) -#define SPI_HISR_OCPINT BIT(27) -#define SPI_HISR_TSF_BIT32_TOGGLE BIT(29) - -#define MASK_SPI_HISR_CLEAR (SPI_HISR_TXERR |\ - SPI_HISR_RXERR |\ - SPI_HISR_TXFOVW |\ - SPI_HISR_RXFOVW |\ - SPI_HISR_TXBCNOK |\ - SPI_HISR_TXBCNERR |\ - SPI_HISR_C2HCMD |\ - SPI_HISR_CPWM1 |\ - SPI_HISR_CPWM2 |\ - SPI_HISR_HSISR_IND |\ - SPI_HISR_GTINT3_IND |\ - SPI_HISR_GTINT4_IND |\ - SPI_HISR_PSTIMEOUT |\ - SPI_HISR_OCPINT) - -#define REG_LEN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 0, 8, x)/* (x<<(unsigned int)24) */ -#define REG_ADDR_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 8, 16, x)/* (x<<(unsigned int)16) */ -#define REG_DOMAIN_ID_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 24, 5, x)/* (x<<(unsigned int)0) */ -#define REG_FUN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 29, 2, x)/* (x<<(unsigned int)5) */ -#define REG_RW_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 31, 1, x)/* (x<<(unsigned int)7) */ - -#define FIFO_LEN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 0, 16, x)/* (x<<(unsigned int)24) - * #define FIFO_ADDR_FORMAT(pcmd,x) SET_BITS_TO_LE_4BYTE(pcmd, 8, 16, x) */ /* (x<<(unsigned int)16) */ -#define FIFO_DOMAIN_ID_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 24, 5, x)/* (x<<(unsigned int)0) */ -#define FIFO_FUN_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 29, 2, x)/* (x<<(unsigned int)5) */ -#define FIFO_RW_FORMAT(pcmd, x) SET_BITS_TO_LE_4BYTE(pcmd, 31, 1, x)/* (x<<(unsigned int)7) */ - - -/* get status dword0 */ -#define GET_STATUS_PUB_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 24, 8) -#define GET_STATUS_HI_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 18, 6) -#define GET_STATUS_MID_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 12, 6) -#define GET_STATUS_LOW_PAGE_NUM(status) LE_BITS_TO_4BYTE(status, 6, 6) -#define GET_STATUS_HISR_HI6BIT(status) LE_BITS_TO_4BYTE(status, 0, 6) - -/* get status dword1 */ -#define GET_STATUS_HISR_MID8BIT(status) LE_BITS_TO_4BYTE(status + 4, 24, 8) -#define GET_STATUS_HISR_LOW8BIT(status) LE_BITS_TO_4BYTE(status + 4, 16, 8) -#define GET_STATUS_ERROR(status) LE_BITS_TO_4BYTE(status + 4, 17, 1) -#define GET_STATUS_INT(status) LE_BITS_TO_4BYTE(status + 4, 16, 1) -#define GET_STATUS_RX_LENGTH(status) LE_BITS_TO_4BYTE(status + 4, 0, 16) - - -#define RXDESC_SIZE 24 - - -struct spi_more_data { - unsigned long more_data; - unsigned long len; -}; - -#ifdef CONFIG_RTL8188E - void rtl8188es_set_hal_ops(PADAPTER padapter); - #define set_hal_ops rtl8188es_set_hal_ops -#endif -extern void spi_set_chip_endian(PADAPTER padapter); -extern unsigned int spi_write8_endian(ADAPTER *Adapter, unsigned int addr, unsigned int buf, u32 big); -extern void spi_set_intf_ops(_adapter *padapter, struct _io_ops *pops); -extern void spi_set_chip_endian(PADAPTER padapter); -extern void InitInterrupt8723ASdio(PADAPTER padapter); -extern void InitSysInterrupt8723ASdio(PADAPTER padapter); -extern void EnableInterrupt8723ASdio(PADAPTER padapter); -extern void DisableInterrupt8723ASdio(PADAPTER padapter); -extern void spi_int_hdl(PADAPTER padapter); -extern u8 HalQueryTxBufferStatus8723ASdio(PADAPTER padapter); -#ifdef CONFIG_RTL8723B - extern void InitInterrupt8723BSdio(PADAPTER padapter); - extern void InitSysInterrupt8723BSdio(PADAPTER padapter); - extern void EnableInterrupt8723BSdio(PADAPTER padapter); - extern void DisableInterrupt8723BSdio(PADAPTER padapter); - extern u8 HalQueryTxBufferStatus8723BSdio(PADAPTER padapter); -#endif - -#ifdef CONFIG_RTL8188E - extern void InitInterrupt8188EGspi(PADAPTER padapter); - extern void EnableInterrupt8188EGspi(PADAPTER padapter); - extern void DisableInterrupt8188EGspi(PADAPTER padapter); - extern void UpdateInterruptMask8188EGspi(PADAPTER padapter, u32 AddMSR, u32 RemoveMSR); - extern u8 HalQueryTxBufferStatus8189EGspi(PADAPTER padapter); - extern u8 HalQueryTxOQTBufferStatus8189EGspi(PADAPTER padapter); - extern void ClearInterrupt8188EGspi(PADAPTER padapter); - extern u8 CheckIPSStatus(PADAPTER padapter); -#endif /* CONFIG_RTL8188E */ -#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) - extern u8 RecvOnePkt(PADAPTER padapter); -#endif /* CONFIG_WOWLAN */ - -#endif /* __GSPI_OPS_H__ */ diff --git a/include/gspi_ops_linux.h b/include/gspi_ops_linux.h deleted file mode 100644 index 9bd18da..0000000 --- a/include/gspi_ops_linux.h +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __SDIO_OPS_LINUX_H__ -#define __SDIO_OPS_LINUX_H__ - -#endif diff --git a/include/gspi_osintf.h b/include/gspi_osintf.h deleted file mode 100644 index f2ecd44..0000000 --- a/include/gspi_osintf.h +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __SDIO_OSINTF_H__ -#define __SDIO_OSINTF_H__ - -#endif diff --git a/include/hal_gspi.h b/include/hal_gspi.h deleted file mode 100644 index 68119c5..0000000 --- a/include/hal_gspi.h +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __HAL_GSPI_H_ -#define __HAL_GSPI_H_ - -#define ffaddr2deviceId(pdvobj, addr) (pdvobj->Queue2Pipe[addr]) - -u8 rtw_hal_gspi_max_txoqt_free_space(_adapter *padapter); -u8 rtw_hal_gspi_query_tx_freepage(_adapter *padapter, u8 PageIdx, u8 RequiredPageNum); -void rtw_hal_gspi_update_tx_freepage(_adapter *padapter, u8 PageIdx, u8 RequiredPageNum); -void rtw_hal_set_gspi_tx_max_length(PADAPTER padapter, u8 numHQ, u8 numNQ, u8 numLQ, u8 numPubQ); -u32 rtw_hal_get_gspi_tx_max_length(PADAPTER padapter, u8 queue_idx); - -#endif diff --git a/include/pci_hal.h b/include/pci_hal.h deleted file mode 100644 index 8aa1a56..0000000 --- a/include/pci_hal.h +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __PCI_HAL_H__ -#define __PCI_HAL_H__ - -#ifdef CONFIG_RTL8188E - void rtl8188ee_set_hal_ops(_adapter *padapter); -#endif - -#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) - void rtl8812ae_set_hal_ops(_adapter *padapter); -#endif - -#if defined(CONFIG_RTL8192E) - void rtl8192ee_set_hal_ops(_adapter *padapter); -#endif - -#ifdef CONFIG_RTL8723B - void rtl8723be_set_hal_ops(_adapter *padapter); -#endif - -#ifdef CONFIG_RTL8723D - void rtl8723de_set_hal_ops(_adapter *padapter); -#endif - -#ifdef CONFIG_RTL8814A - void rtl8814ae_set_hal_ops(_adapter *padapter); -#endif - -#ifdef CONFIG_RTL8822B - void rtl8822be_set_hal_ops(PADAPTER padapter); -#endif - -u8 rtw_set_hal_ops(_adapter *padapter); - -#endif /* __PCIE_HAL_H__ */ diff --git a/include/pci_ops.h b/include/pci_ops.h deleted file mode 100644 index dda0f36..0000000 --- a/include/pci_ops.h +++ /dev/null @@ -1,96 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __PCI_OPS_H_ -#define __PCI_OPS_H_ - - -#ifdef CONFIG_RTL8188E - u32 rtl8188ee_init_desc_ring(_adapter *padapter); - u32 rtl8188ee_free_desc_ring(_adapter *padapter); - void rtl8188ee_reset_desc_ring(_adapter *padapter); - int rtl8188ee_interrupt(PADAPTER Adapter); - void rtl8188ee_xmit_tasklet(void *priv); - void rtl8188ee_recv_tasklet(void *priv); - void rtl8188ee_prepare_bcn_tasklet(void *priv); - void rtl8188ee_set_intf_ops(struct _io_ops *pops); -#endif - -#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) - u32 rtl8812ae_init_desc_ring(_adapter *padapter); - u32 rtl8812ae_free_desc_ring(_adapter *padapter); - void rtl8812ae_reset_desc_ring(_adapter *padapter); - int rtl8812ae_interrupt(PADAPTER Adapter); - void rtl8812ae_xmit_tasklet(void *priv); - void rtl8812ae_recv_tasklet(void *priv); - void rtl8812ae_prepare_bcn_tasklet(void *priv); - void rtl8812ae_set_intf_ops(struct _io_ops *pops); -#endif - -#ifdef CONFIG_RTL8192E - u32 rtl8192ee_init_desc_ring(_adapter *padapter); - u32 rtl8192ee_free_desc_ring(_adapter *padapter); - void rtl8192ee_reset_desc_ring(_adapter *padapter); - void rtl8192ee_recv_tasklet(void *priv); - void rtl8192ee_prepare_bcn_tasklet(void *priv); - int rtl8192ee_interrupt(PADAPTER Adapter); - void rtl8192ee_set_intf_ops(struct _io_ops *pops); -#endif - -#ifdef CONFIG_RTL8723B - u32 rtl8723be_init_desc_ring(_adapter *padapter); - u32 rtl8723be_free_desc_ring(_adapter *padapter); - void rtl8723be_reset_desc_ring(_adapter *padapter); - int rtl8723be_interrupt(PADAPTER Adapter); - void rtl8723be_recv_tasklet(void *priv); - void rtl8723be_prepare_bcn_tasklet(void *priv); - void rtl8723be_set_intf_ops(struct _io_ops *pops); -#endif - -#ifdef CONFIG_RTL8723D - u32 rtl8723de_init_desc_ring(_adapter *padapter); - u32 rtl8723de_free_desc_ring(_adapter *padapter); - void rtl8723de_reset_desc_ring(_adapter *padapter); - int rtl8723de_interrupt(PADAPTER Adapter); - void rtl8723de_recv_tasklet(void *priv); - void rtl8723de_prepare_bcn_tasklet(void *priv); - void rtl8723de_set_intf_ops(struct _io_ops *pops); - u8 check_tx_desc_resource(_adapter *padapter, int prio); -#endif - -#ifdef CONFIG_RTL8814A - u32 rtl8814ae_init_desc_ring(_adapter *padapter); - u32 rtl8814ae_free_desc_ring(_adapter *padapter); - void rtl8814ae_reset_desc_ring(_adapter *padapter); - int rtl8814ae_interrupt(PADAPTER Adapter); - void rtl8814ae_xmit_tasklet(void *priv); - void rtl8814ae_recv_tasklet(void *priv); - void rtl8814ae_prepare_bcn_tasklet(void *priv); - void rtl8814ae_set_intf_ops(struct _io_ops *pops); -#endif - -#ifdef CONFIG_RTL8822B - void rtl8822be_set_intf_ops(struct _io_ops *pops); -#endif - -#ifdef CONFIG_RTL8821C - void rtl8821ce_set_intf_ops(struct _io_ops *pops); -#endif - -#endif diff --git a/include/pci_osintf.h b/include/pci_osintf.h deleted file mode 100644 index 3339352..0000000 --- a/include/pci_osintf.h +++ /dev/null @@ -1,43 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __PCI_OSINTF_H -#define __PCI_OSINTF_H - -#ifdef RTK_129X_PLATFORM -#define PCIE_SLOT1_MEM_START 0x9804F000 -#define PCIE_SLOT1_MEM_LEN 0x1000 -#define PCIE_SLOT1_CTRL_START 0x9804EC00 - -#define PCIE_SLOT2_MEM_START 0x9803C000 -#define PCIE_SLOT2_MEM_LEN 0x1000 -#define PCIE_SLOT2_CTRL_START 0x9803BC00 - -#define PCIE_MASK_OFFSET 0x100 /* mask offset from CTRL_START */ -#define PCIE_TRANSLATE_OFFSET 0x104 /* translate offset from CTRL_START */ -#endif - -void rtw_pci_disable_aspm(_adapter *padapter); -void rtw_pci_enable_aspm(_adapter *padapter); -void PlatformClearPciPMEStatus(PADAPTER Adapter); -#ifdef CONFIG_64BIT_DMA - u8 PlatformEnableDMA64(PADAPTER Adapter); -#endif - -#endif diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 58f3067..29c7af2 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -22,13 +22,6 @@ #include #include -#if defined(PLATFORM_LINUX) && defined (PLATFORM_WINDOWS) - - #error "Shall be Linux or Windows, but not both!\n" - -#endif - - MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); @@ -38,8 +31,6 @@ MODULE_VERSION(DRIVERVERSION); int rtw_chip_version = 0x00; int rtw_rfintfs = HWPI; int rtw_lbkmode = 0;/* RTL8712_AIR_TRX; */ - - int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; */ /* infra, ad-hoc, auto */ /* NDIS_802_11_SSID ssid; */ int rtw_channel = 1;/* ad-hoc support requirement */ @@ -303,11 +294,7 @@ char *ifname = "wlan%d"; module_param(ifname, charp, 0644); MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); -#ifdef CONFIG_PLATFORM_ANDROID - char *if2name = "p2p%d"; -#else /* CONFIG_PLATFORM_ANDROID */ - char *if2name = "wlan%d"; -#endif /* CONFIG_PLATFORM_ANDROID */ +char *if2name = "wlan%d"; module_param(if2name, charp, 0644); MODULE_PARM_DESC(if2name, "The default name to allocate for second interface"); @@ -1818,9 +1805,6 @@ struct dvobj_priv *devobj_init(void) rtw_macid_ctl_init(&pdvobj->macid_ctl); spin_lock_init(&pdvobj->cam_ctl.lock); _rtw_mutex_init(&pdvobj->cam_ctl.sec_cam_access_mutex); -#if defined(RTK_129X_PLATFORM) && defined(CONFIG_PCI_HCI) - spin_lock_init(&pdvobj->io_reg_lock); -#endif #ifdef CONFIG_MBSSID_CAM rtw_mbid_cam_init(pdvobj); #endif @@ -1886,9 +1870,6 @@ void devobj_deinit(struct dvobj_priv *pdvobj) _rtw_spinlock_free(&pdvobj->cam_ctl.lock); _rtw_mutex_free(&pdvobj->cam_ctl.sec_cam_access_mutex); -#if defined(RTK_129X_PLATFORM) && defined(CONFIG_PCI_HCI) - _rtw_spinlock_free(&pdvobj->io_reg_lock); -#endif #ifdef CONFIG_MBSSID_CAM rtw_mbid_cam_deinit(pdvobj); #endif diff --git a/os_dep/linux/recv_linux.c b/os_dep/linux/recv_linux.c index 8f425af..e34b1ef 100644 --- a/os_dep/linux/recv_linux.c +++ b/os_dep/linux/recv_linux.c @@ -105,22 +105,6 @@ int rtw_os_alloc_recvframe(_adapter *padapter, union recv_frame *precvframe, u8 _rtw_memcpy(pkt_copy->data, pdata, skb_len); precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pkt_copy->data; } else { -#if 0 - { - rtw_free_recvframe(precvframe_if2, &precvpriv->free_recv_queue); - rtw_enqueue_recvbuf_to_head(precvbuf, &precvpriv->recv_buf_pending_queue); - - /* The case of can't allocate skb is serious and may never be recovered, - once bDriverStopped is enable, this task should be stopped.*/ - if (!rtw_is_drv_stopped(secondary_padapter)) -#ifdef PLATFORM_LINUX - tasklet_schedule(&precvpriv->recv_tasklet); -#endif - return ret; - } - -#endif - #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX RTW_INFO("%s:can not allocate memory for skb copy\n", __func__); @@ -655,12 +639,6 @@ static void rtw_os_ksocket_send(_adapter *padapter, union recv_frame *precv_fram RTW_INFO("eth, RC-end\n"); -#if 0 - /* send_sz = ksocket_send(padapter->ksock_send, &padapter->kaddr_send, (skb->data+ETH_HLEN+2), len); */ - rtw_recv_ksocket_send_cmd(padapter, (skb->data + ETH_HLEN + 2), len); - - /* RTW_INFO("ksocket_send size=%d\n", send_sz); */ -#endif } } diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 4a9b87c..7687a17 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -26,14 +26,10 @@ #define RT_TAG '1178' #ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX atomic_t _malloc_cnt = ATOMIC_INIT(0); atomic_t _malloc_size = ATOMIC_INIT(0); -#endif #endif /* DBG_MEMORY_LEAK */ - -#if defined(PLATFORM_LINUX) /* * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE * @return: one of RTW_STATUS_CODE @@ -50,16 +46,9 @@ inline int RTW_STATUS_CODE(int error_code) return _FAIL; } } -#else -inline int RTW_STATUS_CODE(int error_code) -{ - return error_code; -} -#endif u32 rtw_atoi(u8 *s) { - int num = 0, flag = 0; int i; for (i = 0; i <= strlen(s); i++) { @@ -81,24 +70,13 @@ u32 rtw_atoi(u8 *s) inline u8 *_rtw_vmalloc(u32 sz) { u8 *pbuf; -#ifdef PLATFORM_LINUX + pbuf = vmalloc(sz); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_NOWAIT); -#endif - -#ifdef PLATFORM_WINDOWS - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); -#endif - #ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX if (pbuf != NULL) { atomic_inc(&_malloc_cnt); atomic_add(sz, &_malloc_size); } -#endif #endif /* DBG_MEMORY_LEAK */ return pbuf; @@ -107,49 +85,25 @@ inline u8 *_rtw_vmalloc(u32 sz) inline u8 *_rtw_zvmalloc(u32 sz) { u8 *pbuf; -#ifdef PLATFORM_LINUX pbuf = _rtw_vmalloc(sz); if (pbuf != NULL) memset(pbuf, 0, sz); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_ZERO | M_NOWAIT); -#endif -#ifdef PLATFORM_WINDOWS - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); - if (pbuf != NULL) - NdisFillMemory(pbuf, sz, 0); -#endif - return pbuf; } inline void _rtw_vmfree(u8 *pbuf, u32 sz) { -#ifdef PLATFORM_LINUX vfree(pbuf); -#endif -#ifdef PLATFORM_FREEBSD - free(pbuf, M_DEVBUF); -#endif -#ifdef PLATFORM_WINDOWS - NdisFreeMemory(pbuf, sz, 0); -#endif - #ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX atomic_dec(&_malloc_cnt); atomic_sub(sz, &_malloc_size); -#endif #endif /* DBG_MEMORY_LEAK */ } u8 *_rtw_malloc(u32 sz) { - u8 *pbuf = NULL; -#ifdef PLATFORM_LINUX #ifdef RTK_DMP_PLATFORM if (sz > 0x4000) pbuf = (u8 *)dvr_malloc(sz); @@ -157,57 +111,28 @@ u8 *_rtw_malloc(u32 sz) #endif pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -#endif -#ifdef PLATFORM_FREEBSD - pbuf = malloc(sz, M_DEVBUF, M_NOWAIT); -#endif -#ifdef PLATFORM_WINDOWS - - NdisAllocateMemoryWithTag(&pbuf, sz, RT_TAG); - -#endif - #ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX if (pbuf != NULL) { atomic_inc(&_malloc_cnt); atomic_add(sz, &_malloc_size); } -#endif #endif /* DBG_MEMORY_LEAK */ return pbuf; - } u8 *_rtw_zmalloc(u32 sz) { -#ifdef PLATFORM_FREEBSD - return malloc(sz, M_DEVBUF, M_ZERO | M_NOWAIT); -#else /* PLATFORM_FREEBSD */ u8 *pbuf = _rtw_malloc(sz); - if (pbuf != NULL) { - -#ifdef PLATFORM_LINUX + if (pbuf != NULL) memset(pbuf, 0, sz); -#endif - -#ifdef PLATFORM_WINDOWS - NdisFillMemory(pbuf, sz, 0); -#endif - - } - return pbuf; -#endif /* PLATFORM_FREEBSD */ } void _rtw_mfree(u8 *pbuf, u32 sz) { - -#ifdef PLATFORM_LINUX #ifdef RTK_DMP_PLATFORM if (sz > 0x4000) dvr_free(pbuf); @@ -215,81 +140,15 @@ void _rtw_mfree(u8 *pbuf, u32 sz) #endif kfree(pbuf); -#endif -#ifdef PLATFORM_FREEBSD - free(pbuf, M_DEVBUF); -#endif -#ifdef PLATFORM_WINDOWS - - NdisFreeMemory(pbuf, sz, 0); - -#endif - #ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX atomic_dec(&_malloc_cnt); atomic_sub(sz, &_malloc_size); -#endif #endif /* DBG_MEMORY_LEAK */ - } -#ifdef PLATFORM_FREEBSD -/* review again */ -struct sk_buff *dev_alloc_skb(unsigned int size) -{ - struct sk_buff *skb = NULL; - u8 *data = NULL; - - /* skb = (struct sk_buff *)_rtw_zmalloc(sizeof(struct sk_buff)); */ /* for skb->len, etc. */ - skb = (struct sk_buff *)_rtw_malloc(sizeof(struct sk_buff)); - if (!skb) - goto out; - data = _rtw_malloc(size); - if (!data) - goto nodata; - - skb->head = (unsigned char *)data; - skb->data = (unsigned char *)data; - skb->tail = (unsigned char *)data; - skb->end = (unsigned char *)data + size; - skb->len = 0; - /* printf("%s()-%d: skb=%p, skb->head = %p\n", __FUNCTION__, __LINE__, skb, skb->head); */ - -out: - return skb; -nodata: - _rtw_mfree((u8 *)skb, sizeof(struct sk_buff)); - skb = NULL; - goto out; - -} - -void dev_kfree_skb_any(struct sk_buff *skb) -{ - /* printf("%s()-%d: skb->head = %p\n", __FUNCTION__, __LINE__, skb->head); */ - if (skb->head) - _rtw_mfree(skb->head, 0); - /* printf("%s()-%d: skb = %p\n", __FUNCTION__, __LINE__, skb); */ - if (skb) - _rtw_mfree((u8 *)skb, 0); -} -struct sk_buff *skb_clone(const struct sk_buff *skb) -{ - return NULL; -} - -#endif /* PLATFORM_FREEBSD */ - inline struct sk_buff *_rtw_skb_alloc(u32 sz) { -#ifdef PLATFORM_LINUX return __dev_alloc_skb(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - return dev_alloc_skb(sz); -#endif /* PLATFORM_FREEBSD */ } inline void _rtw_skb_free(struct sk_buff *skb) @@ -299,74 +158,39 @@ inline void _rtw_skb_free(struct sk_buff *skb) inline struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb) { -#ifdef PLATFORM_LINUX return skb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - return NULL; -#endif /* PLATFORM_FREEBSD */ } inline struct sk_buff *_rtw_skb_clone(struct sk_buff *skb) { -#ifdef PLATFORM_LINUX return skb_clone(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - return skb_clone(skb); -#endif /* PLATFORM_FREEBSD */ } inline struct sk_buff *_rtw_pskb_copy(struct sk_buff *skb) { -#ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) return pskb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); #else return skb_clone(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); #endif -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - return NULL; -#endif /* PLATFORM_FREEBSD */ } inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb) { -#if defined(PLATFORM_LINUX) skb->dev = ndev; return netif_rx(skb); -#elif defined(PLATFORM_FREEBSD) - return (*ndev->if_input)(ndev, skb); -#else - rtw_warn_on(1); - return -1; -#endif } #ifdef CONFIG_RTW_NAPI inline int _rtw_netif_receive_skb(_nic_hdl ndev, struct sk_buff *skb) { -#if defined(PLATFORM_LINUX) skb->dev = ndev; return netif_receive_skb(skb); -#else - rtw_warn_on(1); - return -1; -#endif } #ifdef CONFIG_RTW_GRO inline gro_result_t _rtw_napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) { -#if defined(PLATFORM_LINUX) return napi_gro_receive(napi, skb); -#else - rtw_warn_on(1); - return -1; -#endif } #endif /* CONFIG_RTW_GRO */ #endif /* CONFIG_RTW_NAPI */ @@ -382,31 +206,20 @@ void _rtw_skb_queue_purge(struct sk_buff_head *list) #ifdef CONFIG_USB_HCI inline void *_rtw_usb_buffer_alloc(struct usb_device *dev, size_t size, dma_addr_t *dma) { -#ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) return usb_alloc_coherent(dev, size, (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL), dma); #else return usb_buffer_alloc(dev, size, (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL), dma); #endif -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - return malloc(size, M_USBDEV, M_NOWAIT | M_ZERO); -#endif /* PLATFORM_FREEBSD */ } + inline void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr, dma_addr_t dma) { -#ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) usb_free_coherent(dev, size, addr, dma); #else usb_buffer_free(dev, size, addr, dma); #endif -#endif /* PLATFORM_LINUX */ - -#ifdef PLATFORM_FREEBSD - free(addr, M_USBDEV); -#endif /* PLATFORM_FREEBSD */ } #endif /* CONFIG_USB_HCI */ @@ -886,108 +699,31 @@ void rtw_mfree2d(void *pbuf, int h, int w, int size) void _rtw_memcpy(void *dst, const void *src, u32 sz) { - -#if defined(PLATFORM_LINUX) || defined (PLATFORM_FREEBSD) - memcpy(dst, src, sz); - -#endif - -#ifdef PLATFORM_WINDOWS - - NdisMoveMemory(dst, src, sz); - -#endif - } inline void _rtw_memmove(void *dst, const void *src, u32 sz) { -#if defined(PLATFORM_LINUX) memmove(dst, src, sz); -#else - #warning "no implementation\n" -#endif } int _rtw_memcmp(const void *dst, const void *src, u32 sz) { - -#if defined(PLATFORM_LINUX) || defined (PLATFORM_FREEBSD) /* under Linux/GNU/GLibc, the return value of memcmp for two same mem. chunk is 0 */ - if (!(memcmp(dst, src, sz))) return _TRUE; else return _FALSE; -#endif - - -#ifdef PLATFORM_WINDOWS - /* under Windows, the return value of NdisEqualMemory for two same mem. chunk is 1 */ - - if (NdisEqualMemory(dst, src, sz)) - return _TRUE; - else - return _FALSE; - -#endif - - - } void _rtw_memset(void *pbuf, int c, u32 sz) { - -#if defined(PLATFORM_LINUX) || defined (PLATFORM_FREEBSD) - memset(pbuf, c, sz); - -#endif - -#ifdef PLATFORM_WINDOWS -#if 0 - NdisZeroMemory(pbuf, sz); - if (c != 0) - memset(pbuf, c, sz); -#else - NdisFillMemory(pbuf, sz, c); -#endif -#endif - } -#ifdef PLATFORM_FREEBSD -static inline void __list_add(_list *pnew, _list *pprev, _list *pnext) -{ - pnext->prev = pnew; - pnew->next = pnext; - pnew->prev = pprev; - pprev->next = pnew; -} -#endif /* PLATFORM_FREEBSD */ - - void _rtw_init_listhead(_list *list) { - -#ifdef PLATFORM_LINUX - INIT_LIST_HEAD(list); - -#endif - -#ifdef PLATFORM_FREEBSD - list->next = list; - list->prev = list; -#endif -#ifdef PLATFORM_WINDOWS - - NdisInitializeListHead(list); - -#endif - } @@ -998,332 +734,87 @@ Otherwise, there will be racing condition. */ u32 rtw_is_list_empty(_list *phead) { - -#ifdef PLATFORM_LINUX - if (list_empty(phead)) return _TRUE; else return _FALSE; - -#endif -#ifdef PLATFORM_FREEBSD - - if (phead->next == phead) - return _TRUE; - else - return _FALSE; - -#endif - - -#ifdef PLATFORM_WINDOWS - - if (IsListEmpty(phead)) - return _TRUE; - else - return _FALSE; - -#endif - - } void rtw_list_insert_head(_list *plist, _list *phead) { - -#ifdef PLATFORM_LINUX list_add(plist, phead); -#endif - -#ifdef PLATFORM_FREEBSD - __list_add(plist, phead, phead->next); -#endif - -#ifdef PLATFORM_WINDOWS - InsertHeadList(phead, plist); -#endif } void rtw_list_insert_tail(_list *plist, _list *phead) { - -#ifdef PLATFORM_LINUX - list_add_tail(plist, phead); - -#endif -#ifdef PLATFORM_FREEBSD - - __list_add(plist, phead->prev, phead); - -#endif -#ifdef PLATFORM_WINDOWS - - InsertTailList(phead, plist); - -#endif - } -/* - -Caller must check if the list is empty before calling rtw_list_delete - -*/ - +/* Caller must check if the list is empty before calling rtw_list_delete */ void _rtw_init_sema(_sema *sema, int init_val) { - -#ifdef PLATFORM_LINUX - sema_init(sema, init_val); - -#endif -#ifdef PLATFORM_FREEBSD - sema_init(sema, init_val, "rtw_drv"); -#endif -#ifdef PLATFORM_OS_XP - - KeInitializeSemaphore(sema, init_val, SEMA_UPBND); /* count=0; */ - -#endif - -#ifdef PLATFORM_OS_CE - if (*sema == NULL) - *sema = CreateSemaphore(NULL, init_val, SEMA_UPBND, NULL); -#endif - } void _rtw_free_sema(_sema *sema) { -#ifdef PLATFORM_FREEBSD - sema_destroy(sema); -#endif -#ifdef PLATFORM_OS_CE - CloseHandle(*sema); -#endif - } void _rtw_up_sema(_sema *sema) { - -#ifdef PLATFORM_LINUX - up(sema); - -#endif -#ifdef PLATFORM_FREEBSD - sema_post(sema); -#endif -#ifdef PLATFORM_OS_XP - - KeReleaseSemaphore(sema, IO_NETWORK_INCREMENT, 1, FALSE); - -#endif - -#ifdef PLATFORM_OS_CE - ReleaseSemaphore(*sema, 1, NULL); -#endif } u32 _rtw_down_sema(_sema *sema) { - -#ifdef PLATFORM_LINUX - if (down_interruptible(sema)) return _FAIL; - else - return _SUCCESS; - -#endif -#ifdef PLATFORM_FREEBSD - sema_wait(sema); - return _SUCCESS; -#endif -#ifdef PLATFORM_OS_XP - - if (STATUS_SUCCESS == KeWaitForSingleObject(sema, Executive, KernelMode, TRUE, NULL)) - return _SUCCESS; - else - return _FAIL; -#endif - -#ifdef PLATFORM_OS_CE - if (WAIT_OBJECT_0 == WaitForSingleObject(*sema, INFINITE)) - return _SUCCESS; - else - return _FAIL; -#endif + return _SUCCESS; } void _rtw_mutex_init(_mutex *pmutex) { -#ifdef PLATFORM_LINUX - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) mutex_init(pmutex); #else init_MUTEX(pmutex); #endif - -#endif -#ifdef PLATFORM_FREEBSD - mtx_init(pmutex, "", NULL, MTX_DEF | MTX_RECURSE); -#endif -#ifdef PLATFORM_OS_XP - - KeInitializeMutex(pmutex, 0); - -#endif - -#ifdef PLATFORM_OS_CE - *pmutex = CreateMutex(NULL, _FALSE, NULL); -#endif } -void _rtw_mutex_free(_mutex *pmutex); void _rtw_mutex_free(_mutex *pmutex) { -#ifdef PLATFORM_LINUX - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) mutex_destroy(pmutex); -#else -#endif - -#ifdef PLATFORM_FREEBSD - sema_destroy(pmutex); -#endif - -#endif - -#ifdef PLATFORM_OS_XP - -#endif - -#ifdef PLATFORM_OS_CE - #endif } void _rtw_spinlock_free(_lock *plock) { -#ifdef PLATFORM_FREEBSD - mtx_destroy(plock); -#endif - -#ifdef PLATFORM_WINDOWS - - NdisFreeSpinLock(plock); - -#endif - } -#ifdef PLATFORM_FREEBSD -extern PADAPTER prtw_lock; - -void rtw_mtx_lock(_lock *plock) -{ - if (prtw_lock) - mtx_lock(&prtw_lock->glock); - else - printf("%s prtw_lock==NULL", __FUNCTION__); -} -void rtw_mtx_unlock(_lock *plock) -{ - if (prtw_lock) - mtx_unlock(&prtw_lock->glock); - else - printf("%s prtw_lock==NULL", __FUNCTION__); - -} -#endif /* PLATFORM_FREEBSD */ - void _rtw_spinlock(_lock *plock) { - -#ifdef PLATFORM_LINUX - spin_lock(plock); - -#endif -#ifdef PLATFORM_FREEBSD - mtx_lock(plock); -#endif -#ifdef PLATFORM_WINDOWS - - NdisAcquireSpinLock(plock); - -#endif - } void _rtw_spinunlock(_lock *plock) { - -#ifdef PLATFORM_LINUX - spin_unlock(plock); - -#endif -#ifdef PLATFORM_FREEBSD - mtx_unlock(plock); -#endif -#ifdef PLATFORM_WINDOWS - - NdisReleaseSpinLock(plock); - -#endif } - void _rtw_spinlock_ex(_lock *plock) { - -#ifdef PLATFORM_LINUX - spin_lock(plock); - -#endif -#ifdef PLATFORM_FREEBSD - mtx_lock(plock); -#endif -#ifdef PLATFORM_WINDOWS - - NdisDprAcquireSpinLock(plock); - -#endif - } void _rtw_spinunlock_ex(_lock *plock) { - -#ifdef PLATFORM_LINUX - spin_unlock(plock); - -#endif -#ifdef PLATFORM_FREEBSD - mtx_unlock(plock); -#endif -#ifdef PLATFORM_WINDOWS - - NdisDprReleaseSpinLock(plock); - -#endif } - - void _rtw_init_queue(_queue *pqueue) { _rtw_init_listhead(&(pqueue->queue)); @@ -1352,83 +843,32 @@ u32 rtw_end_of_queue_search(_list *head, _list *plist) u32 rtw_get_current_time(void) { - -#ifdef PLATFORM_LINUX return jiffies; -#endif -#ifdef PLATFORM_FREEBSD - struct timeval tvp; - getmicrotime(&tvp); - return tvp.tv_sec; -#endif -#ifdef PLATFORM_WINDOWS - LARGE_INTEGER SystemTime; - NdisGetCurrentSystemTime(&SystemTime); - return (u32)(SystemTime.LowPart);/* count of 100-nanosecond intervals */ -#endif } inline u32 rtw_systime_to_ms(u32 systime) { -#ifdef PLATFORM_LINUX return systime * 1000 / HZ; -#endif -#ifdef PLATFORM_FREEBSD - return systime * 1000; -#endif -#ifdef PLATFORM_WINDOWS - return systime / 10000 ; -#endif } inline u32 rtw_ms_to_systime(u32 ms) { -#ifdef PLATFORM_LINUX return ms * HZ / 1000; -#endif -#ifdef PLATFORM_FREEBSD - return ms / 1000; -#endif -#ifdef PLATFORM_WINDOWS - return ms * 10000 ; -#endif } /* the input parameter start use the same unit as returned by rtw_get_current_time */ inline s32 rtw_get_passing_time_ms(u32 start) { -#ifdef PLATFORM_LINUX return rtw_systime_to_ms(jiffies - start); -#endif -#ifdef PLATFORM_FREEBSD - return rtw_systime_to_ms(rtw_get_current_time()); -#endif -#ifdef PLATFORM_WINDOWS - LARGE_INTEGER SystemTime; - NdisGetCurrentSystemTime(&SystemTime); - return rtw_systime_to_ms((u32)(SystemTime.LowPart) - start) ; -#endif } inline s32 rtw_get_time_interval_ms(u32 start, u32 end) { -#ifdef PLATFORM_LINUX return rtw_systime_to_ms(end - start); -#endif -#ifdef PLATFORM_FREEBSD - return rtw_systime_to_ms(rtw_get_current_time()); -#endif -#ifdef PLATFORM_WINDOWS - return rtw_systime_to_ms(end - start); -#endif } - void rtw_sleep_schedulable(int ms) { - -#ifdef PLATFORM_LINUX - u32 delta; delta = (ms * HZ) / 1000; /* (ms) */ @@ -1439,26 +879,10 @@ void rtw_sleep_schedulable(int ms) if (schedule_timeout(delta) != 0) return ; return; - -#endif -#ifdef PLATFORM_FREEBSD - DELAY(ms * 1000); - return ; -#endif - -#ifdef PLATFORM_WINDOWS - - NdisMSleep(ms * 1000); /* (us)*1000=(ms) */ - -#endif - } - void rtw_msleep_os(int ms) { - -#ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) if (ms < 20) { unsigned long us = ms * 1000UL; @@ -1466,25 +890,9 @@ void rtw_msleep_os(int ms) } else #endif msleep((unsigned int)ms); - -#endif -#ifdef PLATFORM_FREEBSD - /* Delay for delay microseconds */ - DELAY(ms * 1000); - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisMSleep(ms * 1000); /* (us)*1000=(ms) */ - -#endif - - } void rtw_usleep_os(int us) { -#ifdef PLATFORM_LINUX - /* msleep((unsigned int)us); */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) usleep_range(us, us + 1); @@ -1494,129 +902,36 @@ void rtw_usleep_os(int us) else msleep((us / 1000) + 1); #endif -#endif - -#ifdef PLATFORM_FREEBSD - /* Delay for delay microseconds */ - DELAY(us); - - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisMSleep(us); /* (us) */ - -#endif - - } - #ifdef DBG_DELAY_OS void _rtw_mdelay_os(int ms, const char *func, const int line) { -#if 0 - if (ms > 10) - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); - rtw_msleep_os(ms); - return; -#endif - - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, ms); - -#if defined(PLATFORM_LINUX) - mdelay((unsigned long)ms); - -#elif defined(PLATFORM_WINDOWS) - - NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */ - -#endif - - } + void _rtw_udelay_os(int us, const char *func, const int line) { - -#if 0 - if (us > 1000) { - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); - rtw_usleep_os(us); - return; - } -#endif - - RTW_INFO("%s:%d %s(%d)\n", func, line, __FUNCTION__, us); - -#if defined(PLATFORM_LINUX) - udelay((unsigned long)us); - -#elif defined(PLATFORM_WINDOWS) - - NdisStallExecution(us); /* (us) */ - -#endif - } #else void rtw_mdelay_os(int ms) { - -#ifdef PLATFORM_LINUX - mdelay((unsigned long)ms); - -#endif -#ifdef PLATFORM_FREEBSD - DELAY(ms * 1000); - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisStallExecution(ms * 1000); /* (us)*1000=(ms) */ - -#endif - - } + void rtw_udelay_os(int us) { - -#ifdef PLATFORM_LINUX - udelay((unsigned long)us); - -#endif -#ifdef PLATFORM_FREEBSD - /* Delay for delay microseconds */ - DELAY(us); - return ; -#endif -#ifdef PLATFORM_WINDOWS - - NdisStallExecution(us); /* (us) */ - -#endif - } #endif void rtw_yield_os(void) { -#ifdef PLATFORM_LINUX yield(); -#endif -#ifdef PLATFORM_FREEBSD - yield(); -#endif -#ifdef PLATFORM_WINDOWS - SwitchToThread(); -#endif } #define RTW_SUSPEND_LOCK_NAME "rtw_wifi" @@ -1795,119 +1110,53 @@ inline void rtw_lock_resume_scan_timeout(u32 timeout_ms) inline void ATOMIC_SET(ATOMIC_T *v, int i) { -#ifdef PLATFORM_LINUX atomic_set(v, i); -#elif defined(PLATFORM_WINDOWS) - *v = i; /* other choice???? */ -#elif defined(PLATFORM_FREEBSD) - atomic_set_int(v, i); -#endif } inline int ATOMIC_READ(ATOMIC_T *v) { -#ifdef PLATFORM_LINUX return atomic_read(v); -#elif defined(PLATFORM_WINDOWS) - return *v; /* other choice???? */ -#elif defined(PLATFORM_FREEBSD) - return atomic_load_acq_32(v); -#endif } inline void ATOMIC_ADD(ATOMIC_T *v, int i) { -#ifdef PLATFORM_LINUX atomic_add(i, v); -#elif defined(PLATFORM_WINDOWS) - InterlockedAdd(v, i); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, i); -#endif } inline void ATOMIC_SUB(ATOMIC_T *v, int i) { -#ifdef PLATFORM_LINUX atomic_sub(i, v); -#elif defined(PLATFORM_WINDOWS) - InterlockedAdd(v, -i); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, i); -#endif } inline void ATOMIC_INC(ATOMIC_T *v) { -#ifdef PLATFORM_LINUX atomic_inc(v); -#elif defined(PLATFORM_WINDOWS) - InterlockedIncrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, 1); -#endif } inline void ATOMIC_DEC(ATOMIC_T *v) { -#ifdef PLATFORM_LINUX atomic_dec(v); -#elif defined(PLATFORM_WINDOWS) - InterlockedDecrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, 1); -#endif } inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) { -#ifdef PLATFORM_LINUX return atomic_add_return(i, v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedAdd(v, i); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, i); - return atomic_load_acq_32(v); -#endif } inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) { -#ifdef PLATFORM_LINUX return atomic_sub_return(i, v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedAdd(v, -i); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, i); - return atomic_load_acq_32(v); -#endif } inline int ATOMIC_INC_RETURN(ATOMIC_T *v) { -#ifdef PLATFORM_LINUX return atomic_inc_return(v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedIncrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, 1); - return atomic_load_acq_32(v); -#endif } inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) { -#ifdef PLATFORM_LINUX return atomic_dec_return(v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedDecrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, 1); - return atomic_load_acq_32(v); -#endif } - -#ifdef PLATFORM_LINUX /* * Open a file with the specific @param path, @param flag, @param mode * @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success @@ -2101,7 +1350,6 @@ static int storeToFile(const char *path, u8 *buf, u32 sz) } return ret; } -#endif /* PLATFORM_LINUX */ /* * Test if the specifi @param path is a file and readable @@ -2110,15 +1358,10 @@ static int storeToFile(const char *path, u8 *buf, u32 sz) */ int rtw_is_file_readable(const char *path) { -#ifdef PLATFORM_LINUX if (isFileReadable(path, NULL) == 0) return _TRUE; else return _FALSE; -#else - /* Todo... */ - return _FALSE; -#endif } /* @@ -2129,15 +1372,10 @@ int rtw_is_file_readable(const char *path) */ int rtw_is_file_readable_with_size(const char *path, u32 *sz) { -#ifdef PLATFORM_LINUX if (isFileReadable(path, sz) == 0) return _TRUE; else return _FALSE; -#else - /* Todo... */ - return _FALSE; -#endif } /* @@ -2149,13 +1387,9 @@ int rtw_is_file_readable_with_size(const char *path, u32 *sz) */ int rtw_retrieve_from_file(const char *path, u8 *buf, u32 sz) { -#ifdef PLATFORM_LINUX int ret = retriveFromFile(path, buf, sz); + return ret >= 0 ? ret : 0; -#else - /* Todo... */ - return 0; -#endif } /* @@ -2167,16 +1401,10 @@ int rtw_retrieve_from_file(const char *path, u8 *buf, u32 sz) */ int rtw_store_to_file(const char *path, u8 *buf, u32 sz) { -#ifdef PLATFORM_LINUX int ret = storeToFile(path, buf, sz); return ret >= 0 ? ret : 0; -#else - /* Todo... */ - return 0; -#endif } -#ifdef PLATFORM_LINUX struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv) { struct net_device *pnetdev; @@ -2302,77 +1530,6 @@ error: return -1; } -#endif - -#ifdef PLATFORM_FREEBSD -/* - * Copy a buffer from userspace and write into kernel address - * space. - * - * This emulation just calls the FreeBSD copyin function (to - * copy data from user space buffer into a kernel space buffer) - * and is designed to be used with the above io_write_wrapper. - * - * This function should return the number of bytes not copied. - * I.e. success results in a zero value. - * Negative error values are not returned. - */ -unsigned long -copy_from_user(void *to, const void *from, unsigned long n) -{ - if (copyin(from, to, n) != 0) { - /* Any errors will be treated as a failure - to copy any of the requested bytes */ - return n; - } - - return 0; -} - -unsigned long -copy_to_user(void *to, const void *from, unsigned long n) -{ - if (copyout(from, to, n) != 0) { - /* Any errors will be treated as a failure - to copy any of the requested bytes */ - return n; - } - - return 0; -} - - -/* - * The usb_register and usb_deregister functions are used to register - * usb drivers with the usb subsystem. In this compatibility layer - * emulation a list of drivers (struct usb_driver) is maintained - * and is used for probing/attaching etc. - * - * usb_register and usb_deregister simply call these functions. - */ -int -usb_register(struct usb_driver *driver) -{ - rtw_usb_linux_register(driver); - return 0; -} - - -int -usb_deregister(struct usb_driver *driver) -{ - rtw_usb_linux_deregister(driver); - return 0; -} - -void module_init_exit_wrapper(void *arg) -{ - int (*func)(void) = arg; - func(); - return; -} - -#endif /* PLATFORM_FREEBSD */ #ifdef CONFIG_PLATFORM_SPRD #ifdef do_div @@ -2383,30 +1540,17 @@ void module_init_exit_wrapper(void *arg) u64 rtw_modular64(u64 x, u64 y) { -#ifdef PLATFORM_LINUX return do_div(x, y); -#elif defined(PLATFORM_WINDOWS) - return x % y; -#elif defined(PLATFORM_FREEBSD) - return x % y; -#endif } u64 rtw_division64(u64 x, u64 y) { -#ifdef PLATFORM_LINUX do_div(x, y); return x; -#elif defined(PLATFORM_WINDOWS) - return x / y; -#elif defined(PLATFORM_FREEBSD) - return x / y; -#endif } inline u32 rtw_random32(void) { -#ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) return prandom_u32(); #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)) @@ -2416,11 +1560,6 @@ inline u32 rtw_random32(void) #else return random32(); #endif -#elif defined(PLATFORM_WINDOWS) -#error "to be implemented\n" -#elif defined(PLATFORM_FREEBSD) -#error "to be implemented\n" -#endif } void rtw_buf_free(u8 **buf, u32 *buf_len)