2 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer,
12 * without modification.
13 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15 * redistribution must be conditioned upon including a substantially
16 * similar Disclaimer requirement for further binary redistribution.
17 * 3. Neither the names of the above-listed copyright holders nor the names
18 * of any contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
27 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGES.
36 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/cmn_err.h>
41 #include <sys/sunddi.h>
42 #include <sys/varargs.h>
51 #define ATH_MAX_HALMEM 1024
52 static struct ath_halfix ath_halfix
[ATH_MAX_HALMEM
];
54 /* HAL layer needs these definitions */
55 int ath_hal_dma_beacon_response_time
= 2; /* in TU's */
56 int ath_hal_sw_beacon_response_time
= 10; /* in TU's */
57 int ath_hal_additional_swba_backoff
= 0; /* in TU's */
60 * Print/log message support.
64 ath_hal_printf(struct ath_hal
*ah
, const char *fmt
, ...)
70 vcmn_err(CE_CONT
, fmt
, ap
);
75 * Delay n microseconds.
84 * ath_hal_malloc() and ath_hal_free() are called
85 * within ath_hal.o. We must record the size of
86 * the memory alloced, so ath_hal_free() can get
87 * the size and then calls kmem_free().
90 ath_hal_malloc(size_t size
)
95 for (i
= 0; i
< ATH_MAX_HALMEM
; i
++) {
96 if (ath_halfix
[i
].p
== NULL
)
99 if (i
>= ATH_MAX_HALMEM
) {
100 ath_problem("ath: ath_hal_malloc(): too many malloc\n");
103 p
= kmem_zalloc(size
, KM_SLEEP
);
105 ath_halfix
[i
].size
= size
;
106 ATH_DEBUG((ATH_DBG_OSDEP
, "ath: ath_hal_malloc(): "
107 "%d: p=%p, size=%d\n", i
, p
, size
));
112 ath_hal_free(void* p
)
115 for (i
= 0; i
< ATH_MAX_HALMEM
; i
++) {
116 if (ath_halfix
[i
].p
== p
)
119 if (i
>= ATH_MAX_HALMEM
) {
120 ath_problem("ath: ath_hal_free(): no record for %p\n", p
);
123 kmem_free(p
, ath_halfix
[i
].size
);
124 ath_halfix
[i
].p
= NULL
;
125 ATH_DEBUG((ATH_DBG_OSDEP
, "ath: ath_hal_free(): %d: p=%p, size=%d\n",
126 i
, p
, ath_halfix
[i
].size
));
130 ath_hal_memcpy(void *dst
, const void *src
, size_t n
)
137 ath_hal_memzero(void *dst
, size_t n
)
143 ath_halfix_init(void)
147 for (i
= 0; i
< ATH_MAX_HALMEM
; i
++)
148 ath_halfix
[i
].p
= NULL
;
152 ath_halfix_finit(void)
156 for (i
= 0; i
< ATH_MAX_HALMEM
; i
++)
157 if (ath_halfix
[i
].p
!= NULL
) {
158 kmem_free(ath_halfix
[i
].p
, ath_halfix
[i
].size
);
159 ATH_DEBUG((ATH_DBG_OSDEP
, "ath_halfix: "
160 "Free %d: p=%x size=%d\n",
161 i
, ath_halfix
[i
].p
, ath_halfix
[i
].size
));