Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / atheros5000 / halsupport.c
blob8d72a30fa818e3585b1e0d58ccf9ebb770fad7c4
1 /*
3 Copyright (C) 2010-2012 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA.
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
27 #include <exec/memory.h>
29 #include <proto/exec.h>
30 #include <proto/timer.h>
32 #ifdef __AROS__
33 #include <aros/debug.h>
34 #endif
36 #include "device.h"
39 #ifdef AH_DEBUG
40 static int ath_hal_debug = 1;
41 #endif
43 int ath_hal_dma_beacon_response_time = 2; /* in TU's */
44 int ath_hal_sw_beacon_response_time = 10; /* in TU's */
45 int ath_hal_additional_swba_backoff = 0; /* in TU's */
47 struct DevBase *hal_dev_base;
49 #define base hal_dev_base
52 void ath_hal_vprintf(APTR ah, const char* fmt, va_list ap)
58 void ath_hal_printf(APTR ah, const char* fmt, ...)
64 void HALDEBUG(APTR ah, unsigned int mask, const char* fmt, ...)
66 va_list ap;
67 va_start(ap, fmt);
68 #ifdef __AROS__
69 kprintf("[atheros] ");
70 vkprintf(fmt, ap);
71 #else
72 ath_hal_vprintf(ah, fmt, ap);
73 #endif
74 va_end(ap);
79 const char *ath_hal_ether_sprintf(const UBYTE *mac)
81 static char etherbuf[18];
82 #if 0
83 snprintf(etherbuf, sizeof(etherbuf), "%02x:%02x:%02x:%02x:%02x:%02x",
84 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
85 #else
86 etherbuf[0] = '\0';
87 #endif
88 return etherbuf;
93 void ath_hal_delay(int n)
95 struct timeval time, end_time;
97 GetSysTime(&end_time);
98 time.tv_secs = 0;
99 time.tv_micro = n;
100 AddTime(&end_time, &time);
102 while(CmpTime(&end_time, &time) < 0)
103 GetSysTime(&time);
105 return;
110 ULONG ath_hal_getuptime(APTR ah)
112 struct timeval time;
114 GetSysTime(&time);
116 return time.tv_secs * 1000 + time.tv_micro / 1000;
121 void *ath_hal_malloc(size_t size)
123 return AllocVec(size, MEMF_PUBLIC | MEMF_CLEAR);
128 void ath_hal_free(void* p)
130 FreeVec(p);
135 void ath_hal_memzero(void *dst, size_t n)
137 UBYTE *buf = dst;
139 while(n-- != 0)
140 *buf++ = 0;
145 void *ath_hal_memcpy(void *dst, const void *src, size_t n)
147 CopyMem(src, dst, n);
149 return dst;
154 int ath_hal_memcmp(const void *a, const void *b, size_t n)
156 const UBYTE *ba = a, *bb = b;
158 while(n != 0 && *ba == *bb)
159 ba++, bb++;
160 return *ba - *bb;