Lines Matching refs:osh
75 static void osl_dma_lock(osl_t *osh);
76 static void osl_dma_unlock(osl_t *osh);
77 static void osl_dma_lock_init(osl_t *osh);
79 #define DMA_LOCK(osh) osl_dma_lock(osh) argument
80 #define DMA_UNLOCK(osh) osl_dma_unlock(osh) argument
81 #define DMA_LOCK_INIT(osh) osl_dma_lock_init(osh); argument
83 #define DMA_LOCK(osh) do { /* noop */ } while(0) argument
84 #define DMA_UNLOCK(osh) do { /* noop */ } while(0) argument
85 #define DMA_LOCK_INIT(osh) do { /* noop */ } while(0) argument
193 osl_dma_map_dump(osl_t *osh) in osl_dma_map_dump() argument
198 map_log = (dhd_map_log_t *)(osh->dhd_map_log); in osl_dma_map_dump()
199 unmap_log = (dhd_map_log_t *)(osh->dhd_unmap_log); in osl_dma_map_dump()
236 osl_dma_map_log_deinit(osl_t *osh) in osl_dma_map_log_deinit() argument
238 if (osh->dhd_map_log) { in osl_dma_map_log_deinit()
239 kfree(osh->dhd_map_log); in osl_dma_map_log_deinit()
240 osh->dhd_map_log = NULL; in osl_dma_map_log_deinit()
243 if (osh->dhd_unmap_log) { in osl_dma_map_log_deinit()
244 kfree(osh->dhd_unmap_log); in osl_dma_map_log_deinit()
245 osh->dhd_unmap_log = NULL; in osl_dma_map_log_deinit()
250 osl_dma_map_logging(osl_t *osh, void *handle, dmaaddr_t pa, uint32 len) in osl_dma_map_logging() argument
291 osl_t *osh; in osl_attach() local
295 if (!(osh = kmalloc(sizeof(osl_t), flags))) in osl_attach()
296 return osh; in osl_attach()
298 ASSERT(osh); in osl_attach()
300 bzero(osh, sizeof(osl_t)); in osl_attach()
303 if (!(osh->cmn = kmalloc(sizeof(osl_cmn_t), flags))) { in osl_attach()
304 kfree(osh); in osl_attach()
307 bzero(osh->cmn, sizeof(osl_cmn_t)); in osl_attach()
309 *osl_cmn = osh->cmn; in osl_attach()
310 atomic_set(&osh->cmn->malloced, 0); in osl_attach()
311 osh->cmn->dbgmem_list = NULL; in osl_attach()
312 spin_lock_init(&(osh->cmn->dbgmem_lock)); in osl_attach()
315 spin_lock_init(&(osh->cmn->pktlist_lock)); in osl_attach()
317 spin_lock_init(&(osh->cmn->pktalloc_lock)); in osl_attach()
320 osh->cmn = *osl_cmn; in osl_attach()
322 atomic_add(1, &osh->cmn->refcount); in osl_attach()
327 osh->failed = 0; in osl_attach()
328 osh->pdev = pdev; in osl_attach()
329 osh->pub.pkttag = pkttag; in osl_attach()
330 osh->bustype = bustype; in osl_attach()
331 osh->magic = OS_HANDLE_MAGIC; in osl_attach()
336 osh->pub.mmbus = TRUE; in osl_attach()
342 osh->pub.mmbus = FALSE; in osl_attach()
350 spin_lock_init(&osh->ctrace_lock); in osl_attach()
351 INIT_LIST_HEAD(&osh->ctrace_list); in osl_attach()
352 osh->ctrace_num = 0; in osl_attach()
355 DMA_LOCK_INIT(osh); in osl_attach()
366 osh->dhd_map_log = osl_dma_map_log_init(DHD_MAP_LOG_SIZE); in osl_attach()
367 if (osh->dhd_map_log == NULL) { in osl_attach()
371 osh->dhd_unmap_log = osl_dma_map_log_init(DHD_MAP_LOG_SIZE); in osl_attach()
372 if (osh->dhd_unmap_log == NULL) { in osl_attach()
377 return osh; in osl_attach()
380 void osl_set_bus_handle(osl_t *osh, void *bus_handle) in osl_set_bus_handle() argument
382 osh->bus_handle = bus_handle; in osl_set_bus_handle()
385 void* osl_get_bus_handle(osl_t *osh) in osl_get_bus_handle() argument
387 return osh->bus_handle; in osl_get_bus_handle()
391 void osl_set_bpt_cb(osl_t *osh, void *bpt_cb, void *bpt_ctx) in osl_set_bpt_cb() argument
393 if (osh) { in osl_set_bpt_cb()
394 osh->bpt_cb = (bpt_cb_fn)bpt_cb; in osl_set_bpt_cb()
395 osh->sih = bpt_ctx; in osl_set_bpt_cb()
401 osl_detach(osl_t *osh) in osl_detach() argument
403 if (osh == NULL) in osl_detach()
407 if (MEMORY_LEFTOVER(osh)) { in osl_detach()
411 printf("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh)); in osl_detach()
413 MALLOC_DUMP(osh, &b); in osl_detach()
421 osl_dma_map_log_deinit(osh); in osl_detach()
424 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_detach()
425 atomic_sub(1, &osh->cmn->refcount); in osl_detach()
426 if (atomic_read(&osh->cmn->refcount) == 0) { in osl_detach()
427 kfree(osh->cmn); in osl_detach()
429 kfree(osh); in osl_detach()
434 BCMFASTPATH(osl_flag_set)(osl_t *osh, uint32 mask) in BCMFASTPATH()
436 osh->flags |= mask; in BCMFASTPATH()
440 osl_flag_clr(osl_t *osh, uint32 mask) in osl_flag_clr() argument
442 osh->flags &= ~mask; in osl_flag_clr()
446 osl_is_flag_set(osl_t *osh, uint32 mask) in osl_is_flag_set() argument
448 return (osh->flags & mask); in osl_is_flag_set()
476 osl_pci_read_config(osl_t *osh, uint offset, uint size) in osl_pci_read_config() argument
481 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_pci_read_config()
487 pci_read_config_dword(osh->pdev, offset, &val); in osl_pci_read_config()
502 osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val) in osl_pci_write_config() argument
506 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_pci_write_config()
512 pci_write_config_dword(osh->pdev, offset, val); in osl_pci_write_config()
518 if (osl_pci_read_config(osh, offset, size) == val) in osl_pci_write_config()
532 osl_pci_bus(osl_t *osh) in osl_pci_bus() argument
534 ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); in osl_pci_bus()
537 return pci_domain_nr(((struct pci_dev *)osh->pdev)->bus); in osl_pci_bus()
539 return ((struct pci_dev *)osh->pdev)->bus->number; in osl_pci_bus()
545 osl_pci_slot(osl_t *osh) in osl_pci_slot() argument
547 ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); in osl_pci_slot()
550 return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn) + 1; in osl_pci_slot()
552 return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn); in osl_pci_slot()
558 osl_pcie_domain(osl_t *osh) in osl_pcie_domain() argument
560 ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); in osl_pcie_domain()
562 return pci_domain_nr(((struct pci_dev *)osh->pdev)->bus); in osl_pcie_domain()
567 osl_pcie_bus(osl_t *osh) in osl_pcie_bus() argument
569 ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); in osl_pcie_bus()
571 return ((struct pci_dev *)osh->pdev)->bus->number; in osl_pcie_bus()
576 osl_pci_device(osl_t *osh) in osl_pci_device() argument
578 ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); in osl_pci_device()
580 return osh->pdev; in osl_pci_device()
594 osl_malloc(osl_t *osh, uint size) in osl_malloc() argument
600 if (osh) in osl_malloc()
601 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_malloc()
628 if (osh) in osl_malloc()
629 atomic_add(size, &osh->cmn->malloced); in osl_malloc()
639 if (osh) in osl_malloc()
640 osh->failed++; in osl_malloc()
643 if (osh && osh->cmn) in osl_malloc()
644 atomic_add(size, &osh->cmn->malloced); in osl_malloc()
651 osl_mallocz(osl_t *osh, uint size) in osl_mallocz() argument
655 ptr = osl_malloc(osh, size); in osl_mallocz()
675 osl_mfree(osl_t *osh, void *addr, uint size) in osl_mfree() argument
697 if (osh && osh->cmn) { in osl_mfree()
698 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_mfree()
699 atomic_sub(size, &osh->cmn->malloced); in osl_mfree()
705 if (osh && osh->cmn) { in osl_mfree()
706 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_mfree()
708 ASSERT(size <= osl_malloced(osh)); in osl_mfree()
710 atomic_sub(size, &osh->cmn->malloced); in osl_mfree()
725 osl_vmalloc(osl_t *osh, uint size) in osl_vmalloc() argument
730 if (osh) in osl_vmalloc()
731 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_vmalloc()
733 if (osh) in osl_vmalloc()
734 osh->failed++; in osl_vmalloc()
737 if (osh && osh->cmn) in osl_vmalloc()
738 atomic_add(size, &osh->cmn->malloced); in osl_vmalloc()
745 osl_vmallocz(osl_t *osh, uint size) in osl_vmallocz() argument
749 ptr = osl_vmalloc(osh, size); in osl_vmallocz()
769 osl_vmfree(osl_t *osh, void *addr, uint size) in osl_vmfree() argument
771 if (osh && osh->cmn) { in osl_vmfree()
772 ASSERT(osh->magic == OS_HANDLE_MAGIC); in osl_vmfree()
774 ASSERT(size <= osl_malloced(osh)); in osl_vmfree()
776 atomic_sub(size, &osh->cmn->malloced); in osl_vmfree()
782 osl_check_memleak(osl_t *osh) in osl_check_memleak() argument
784 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_check_memleak()
785 if (atomic_read(&osh->cmn->refcount) == 1) in osl_check_memleak()
786 return (atomic_read(&osh->cmn->malloced)); in osl_check_memleak()
792 osl_malloced(osl_t *osh) in osl_malloced() argument
794 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_malloced()
795 return (atomic_read(&osh->cmn->malloced)); in osl_malloced()
799 osl_malloc_failed(osl_t *osh) in osl_malloc_failed() argument
801 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_malloc_failed()
802 return (osh->failed); in osl_malloc_failed()
807 osl_debug_malloc(osl_t *osh, uint size, int line, const char* file) in osl_debug_malloc() argument
817 if ((p = (bcm_mem_link_t*)osl_malloc(osh, sizeof(bcm_mem_link_t) + size)) == NULL) { in osl_debug_malloc()
821 if (osh) { in osl_debug_malloc()
822 OSL_MEMLIST_LOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_malloc()
827 p->osh = (void *)osh; in osl_debug_malloc()
840 if (osh) { in osl_debug_malloc()
842 p->next = osh->cmn->dbgmem_list; in osl_debug_malloc()
845 osh->cmn->dbgmem_list = p; in osl_debug_malloc()
846 OSL_MEMLIST_UNLOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_malloc()
853 osl_debug_mallocz(osl_t *osh, uint size, int line, const char* file) in osl_debug_mallocz() argument
857 ptr = osl_debug_malloc(osh, size, line, file); in osl_debug_mallocz()
867 osl_debug_mfree(osl_t *osh, void *addr, uint size, int line, const char* file) in osl_debug_mfree() argument
872 ASSERT(osh == NULL || osh->magic == OS_HANDLE_MAGIC); in osl_debug_mfree()
896 if (osh && ((osl_t*)p->osh)->cmn != osh->cmn) { in osl_debug_mfree()
898 ((osl_t*)p->osh)->cmn, osh->cmn); in osl_debug_mfree()
902 ASSERT(((osl_t*)p->osh)->cmn == osh->cmn); in osl_debug_mfree()
907 if (osh && osh->cmn) { in osl_debug_mfree()
908 OSL_MEMLIST_LOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_mfree()
913 if (osh->cmn->dbgmem_list == p) in osl_debug_mfree()
914 osh->cmn->dbgmem_list = p->next; in osl_debug_mfree()
919 if (osh && osh->cmn) { in osl_debug_mfree()
920 OSL_MEMLIST_UNLOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_mfree()
922 osl_mfree(osh, p, size + sizeof(bcm_mem_link_t)); in osl_debug_mfree()
926 osl_debug_vmalloc(osl_t *osh, uint size, int line, const char* file) in osl_debug_vmalloc() argument
936 if ((p = (bcm_mem_link_t*)osl_vmalloc(osh, sizeof(bcm_mem_link_t) + size)) == NULL) { in osl_debug_vmalloc()
940 if (osh) { in osl_debug_vmalloc()
941 OSL_MEMLIST_LOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_vmalloc()
946 p->osh = (void *)osh; in osl_debug_vmalloc()
959 if (osh) { in osl_debug_vmalloc()
961 p->next = osh->cmn->dbgvmem_list; in osl_debug_vmalloc()
964 osh->cmn->dbgvmem_list = p; in osl_debug_vmalloc()
965 OSL_MEMLIST_UNLOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_vmalloc()
972 osl_debug_vmallocz(osl_t *osh, uint size, int line, const char* file) in osl_debug_vmallocz() argument
976 ptr = osl_debug_vmalloc(osh, size, line, file); in osl_debug_vmallocz()
986 osl_debug_vmfree(osl_t *osh, void *addr, uint size, int line, const char* file) in osl_debug_vmfree() argument
991 ASSERT(osh == NULL || osh->magic == OS_HANDLE_MAGIC); in osl_debug_vmfree()
1008 if (osh && ((osl_t*)p->osh)->cmn != osh->cmn) { in osl_debug_vmfree()
1010 ((osl_t*)p->osh)->cmn, osh->cmn); in osl_debug_vmfree()
1013 ASSERT(((osl_t*)p->osh)->cmn == osh->cmn); in osl_debug_vmfree()
1018 if (osh && osh->cmn) { in osl_debug_vmfree()
1019 OSL_MEMLIST_LOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_vmfree()
1024 if (osh->cmn->dbgvmem_list == p) in osl_debug_vmfree()
1025 osh->cmn->dbgvmem_list = p->next; in osl_debug_vmfree()
1030 if (osh && osh->cmn) { in osl_debug_vmfree()
1031 OSL_MEMLIST_UNLOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_vmfree()
1033 osl_vmfree(osh, p, size + sizeof(bcm_mem_link_t)); in osl_debug_vmfree()
1037 osl_debug_memdump(osl_t *osh, struct bcmstrbuf *b) in osl_debug_memdump() argument
1042 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_debug_memdump()
1044 OSL_MEMLIST_LOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_memdump()
1046 if (osl_check_memleak(osh) && osh->cmn->dbgmem_list) { in osl_debug_memdump()
1052 for (p = osh->cmn->dbgmem_list; p; p = p->next) { in osl_debug_memdump()
1073 if (osl_check_memleak(osh) && osh->cmn->dbgvmem_list) { in osl_debug_memdump()
1079 for (p = osh->cmn->dbgvmem_list; p; p = p->next) { in osl_debug_memdump()
1101 OSL_MEMLIST_UNLOCK(&osh->cmn->dbgmem_lock, flags); in osl_debug_memdump()
1115 osl_dma_alloc_consistent(osl_t *osh, uint size, uint16 align_bits, uint *alloced, dmaaddr_t *pap) in osl_dma_alloc_consistent() argument
1119 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_dma_alloc_consistent()
1132 struct pci_dev *hwdev = osh->pdev; in osl_dma_alloc_consistent()
1156 osl_dma_free_consistent(osl_t *osh, void *va, uint size, dmaaddr_t pa) in osl_dma_free_consistent() argument
1161 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in osl_dma_free_consistent()
1168 pci_free_consistent(osh->pdev, size, va, paddr); in osl_dma_free_consistent()
1170 pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa); in osl_dma_free_consistent()
1183 BCMFASTPATH(osl_dma_flush)(osl_t *osh, void *va, uint size, int direction, void *p, in BCMFASTPATH()
1190 BCMFASTPATH(osl_dma_map)(osl_t *osh, void *va, uint size, int direction, void *p, in BCMFASTPATH()
1198 DMA_LOCK(osh); in BCMFASTPATH()
1200 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in BCMFASTPATH()
1203 map_addr = pci_map_single(osh->pdev, va, size, dir); in BCMFASTPATH()
1205 ret = pci_dma_mapping_error(osh->pdev, map_addr); in BCMFASTPATH()
1217 osl_dma_map_logging(osh, osh->dhd_map_log, ret_addr, size); in BCMFASTPATH()
1220 DMA_UNLOCK(osh); in BCMFASTPATH()
1226 BCMFASTPATH(osl_dma_unmap)(osl_t *osh, dmaaddr_t pa, uint size, int direction) in BCMFASTPATH()
1233 ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); in BCMFASTPATH()
1235 DMA_LOCK(osh); in BCMFASTPATH()
1240 osl_dma_map_logging(osh, osh->dhd_unmap_log, pa, size); in BCMFASTPATH()
1245 pci_unmap_single(osh->pdev, paddr, size, dir); in BCMFASTPATH()
1247 pci_unmap_single(osh->pdev, (uint32)pa, size, dir); in BCMFASTPATH()
1250 DMA_UNLOCK(osh); in BCMFASTPATH()
1260 extern void osl_preempt_disable(osl_t *osh) in osl_preempt_disable() argument
1265 extern void osl_preempt_enable(osl_t *osh) in osl_preempt_enable() argument
1437 osl_readb(osl_t *osh, volatile uint8 *r) in osl_readb() argument
1439 osl_rreg_fn_t rreg = ((osl_pubinfo_t*)osh)->rreg_fn; in osl_readb()
1440 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_readb()
1446 osl_readw(osl_t *osh, volatile uint16 *r) in osl_readw() argument
1448 osl_rreg_fn_t rreg = ((osl_pubinfo_t*)osh)->rreg_fn; in osl_readw()
1449 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_readw()
1455 osl_readl(osl_t *osh, volatile uint32 *r) in osl_readl() argument
1457 osl_rreg_fn_t rreg = ((osl_pubinfo_t*)osh)->rreg_fn; in osl_readl()
1458 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_readl()
1464 osl_writeb(osl_t *osh, volatile uint8 *r, uint8 v) in osl_writeb() argument
1466 osl_wreg_fn_t wreg = ((osl_pubinfo_t*)osh)->wreg_fn; in osl_writeb()
1467 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_writeb()
1473 osl_writew(osl_t *osh, volatile uint16 *r, uint16 v) in osl_writew() argument
1475 osl_wreg_fn_t wreg = ((osl_pubinfo_t*)osh)->wreg_fn; in osl_writew()
1476 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_writew()
1482 osl_writel(osl_t *osh, volatile uint32 *r, uint32 v) in osl_writel() argument
1484 osl_wreg_fn_t wreg = ((osl_pubinfo_t*)osh)->wreg_fn; in osl_writel()
1485 void *ctx = ((osl_pubinfo_t*)osh)->reg_ctx; in osl_writel()
1724 inline void osl_bpt_rreg(osl_t *osh, ulong addr, volatile void *v, uint size) in osl_bpt_rreg() argument
1752 if (osh && osh->sih && (in_si_clear == FALSE) && poll_timeout && osh->bpt_cb) { in osl_bpt_rreg()
1754 osh->bpt_cb((void *)osh->sih, (void *)addr); in osl_bpt_rreg()
1773 osl_timer_init(osl_t *osh, const char *name, void (*fn)(void *arg), void *arg) in osl_timer_init() argument
1802 osl_timer_add(osl_t *osh, osl_timer_t *t, uint32 ms, bool periodic) in osl_timer_add() argument
1826 osl_timer_update(osl_t *osh, osl_timer_t *t, uint32 ms, bool periodic) in osl_timer_update() argument
1851 osl_timer_del(osl_t *osh, osl_timer_t *t) in osl_timer_del() argument
1887 osl_spin_lock_init(osl_t *osh) in osl_spin_lock_init() argument
1892 spinlock_t * lock = MALLOC(osh, sizeof(spinlock_t) + 4); in osl_spin_lock_init()
1898 osl_spin_lock_deinit(osl_t *osh, void *lock) in osl_spin_lock_deinit() argument
1901 MFREE(osh, lock, sizeof(spinlock_t) + 4); in osl_spin_lock_deinit()
1979 osl_mutex_lock_init(osl_t *osh) in osl_mutex_lock_init() argument
1983 mtx = MALLOCZ(osh, sizeof(*mtx)); in osl_mutex_lock_init()
1991 osl_mutex_lock_deinit(osl_t *osh, void *mutex) in osl_mutex_lock_deinit() argument
1997 MFREE(osh, mtx, sizeof(struct mutex)); in osl_mutex_lock_deinit()
2024 osl_dma_lock(osl_t *osh) in osl_dma_lock() argument
2035 spin_lock(&osh->dma_lock); in osl_dma_lock()
2037 spin_lock_bh(&osh->dma_lock); in osl_dma_lock()
2038 osh->dma_lock_bh = TRUE; in osl_dma_lock()
2043 osl_dma_unlock(osl_t *osh) in osl_dma_unlock() argument
2045 if (unlikely(osh->dma_lock_bh)) { in osl_dma_unlock()
2046 osh->dma_lock_bh = FALSE; in osl_dma_unlock()
2047 spin_unlock_bh(&osh->dma_lock); in osl_dma_unlock()
2049 spin_unlock(&osh->dma_lock); in osl_dma_unlock()
2054 osl_dma_lock_init(osl_t *osh) in osl_dma_lock_init() argument
2056 spin_lock_init(&osh->dma_lock); in osl_dma_lock_init()
2057 osh->dma_lock_bh = FALSE; in osl_dma_lock_init()