Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
buldo committed Sep 27, 2023
1 parent 879ed0b commit 50e7b3f
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 304 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
cmake_minimum_required(VERSION 3.15)
project(demo C)
project(demo C CXX)

find_package(libusb REQUIRED)

#target_include_directories(demo ${libusb_INCLUDE_DIR})
add_executable(demo main.c)
add_executable(demo
os_dep/linux/usb_intf.c
main.cpp)
#target_include_directories(demo PRIVATE ${libusb_INCLUDE_DIR})
target_link_libraries(demo ${libusb_LIBRARIES})
target_link_libraries(demo ${libusb_LIBRARIES})
target_include_directories(demo PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>")
14 changes: 3 additions & 11 deletions include/basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@


#ifdef PLATFORM_LINUX
#include <linux/version.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/utsname.h>
#define IN
#define OUT
#define VOID void
Expand All @@ -94,11 +88,9 @@
#define USHORT u16
#define UINT u32
#define ULONG u32

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
typedef _Bool bool;
#endif


typedef unsigned int __kernel_size_t;
typedef int __kernel_ssize_t;
typedef __kernel_size_t SIZE_T;
typedef __kernel_ssize_t SSIZE_T;
#define FIELD_OFFSET(s, field) ((SSIZE_T)&((s *)(0))->field)
Expand Down
11 changes: 1 addition & 10 deletions include/osdep_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#ifndef __OSDEP_SERVICE_H_
#define __OSDEP_SERVICE_H_

#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#include <linux/sched/signal.h>
#endif

#define _FAIL 0
#define _SUCCESS 1
Expand All @@ -43,12 +39,7 @@
#endif

#ifdef PLATFORM_LINUX
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0))
#include <linux/sched/signal.h>
#include <linux/sched/types.h>
#endif
#include <osdep_service_linux.h>
#include <osdep_service_linux.h>
#endif

#ifdef PLATFORM_OS_XP
Expand Down
105 changes: 52 additions & 53 deletions include/osdep_service_bsd.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/******************************************************************************
*
* Copyright(c) 2007 - 2017 Realtek Corporation.
*
* 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.
*
*****************************************************************************/
/******************************************************************************
*
* Copyright(c) 2007 - 2017 Realtek Corporation.
*
* 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.
*
*****************************************************************************/
#ifndef __OSDEP_BSD_SERVICE_H_
#define __OSDEP_BSD_SERVICE_H_

Expand Down Expand Up @@ -107,7 +107,6 @@

#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
/* emulate a modern version */
#define LINUX_VERSION_CODE KERNEL_VERSION(2, 6, 35)

#define WIRELESS_EXT -1
#define HZ hz
Expand All @@ -129,10 +128,10 @@
*
*/
struct timer_list {
struct callout callout;
void (*function)(void *);
void *arg;
};
struct callout callout;
void (*function)(void *);
void *arg;
};

struct workqueue_struct;
struct work_struct;
Expand Down Expand Up @@ -659,42 +658,42 @@ __inline static void rtw_list_delete(_list *plist)
INIT_LIST_HEAD(plist);
}

static inline void timer_hdl(void *ctx)
{
_timer *timer = (_timer *)ctx;

rtw_mtx_lock(NULL);
if (callout_pending(&timer->callout)) {
/* callout was reset */
rtw_mtx_unlock(NULL);
return;
}

if (!callout_active(&timer->callout)) {
/* callout was stopped */
rtw_mtx_unlock(NULL);
return;
}

callout_deactivate(&timer->callout);

timer->function(timer->arg);

rtw_mtx_unlock(NULL);
}

static inline void _init_timer(_timer *ptimer, _nic_hdl padapter, void *pfunc, void *cntx)
{
ptimer->function = pfunc;
ptimer->arg = cntx;
callout_init(&ptimer->callout, CALLOUT_MPSAFE);
}

static inline void timer_hdl(void *ctx)
{
_timer *timer = (_timer *)ctx;

rtw_mtx_lock(NULL);
if (callout_pending(&timer->callout)) {
/* callout was reset */
rtw_mtx_unlock(NULL);
return;
}

if (!callout_active(&timer->callout)) {
/* callout was stopped */
rtw_mtx_unlock(NULL);
return;
}

callout_deactivate(&timer->callout);

timer->function(timer->arg);

rtw_mtx_unlock(NULL);
}

static inline void _init_timer(_timer *ptimer, _nic_hdl padapter, void *pfunc, void *cntx)
{
ptimer->function = pfunc;
ptimer->arg = cntx;
callout_init(&ptimer->callout, CALLOUT_MPSAFE);
}

__inline static void _set_timer(_timer *ptimer,u32 delay_time)
{
if (ptimer->function && ptimer->arg) {
if (ptimer->function && ptimer->arg) {
rtw_mtx_lock(NULL);
callout_reset(&ptimer->callout, delay_time, timer_hdl, ptimer);
callout_reset(&ptimer->callout, delay_time, timer_hdl, ptimer);
rtw_mtx_unlock(NULL);
}
}
Expand All @@ -704,7 +703,7 @@ __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)
rtw_mtx_lock(NULL);
callout_drain(&ptimer->callout);
rtw_mtx_unlock(NULL);
*bcancelled = 1; /* assume an pending timer to be canceled */
*bcancelled = 1; /* assume an pending timer to be canceled */
}

__inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)
Expand Down
Loading

0 comments on commit 50e7b3f

Please sign in to comment.