Lines Matching +full:os +full:- +full:code +full:- +full:offset
1 /*-
8 * 1. Redistributions of source code must retain the above copyright notice,
34 * Implementation of common BSD OS abstraction functions
49 ocs_config_read32(ocs_os_handle_t os, uint32_t reg) in ocs_config_read32() argument
51 return pci_read_config(os->dev, reg, 4); in ocs_config_read32()
55 ocs_config_read16(ocs_os_handle_t os, uint32_t reg) in ocs_config_read16() argument
57 return pci_read_config(os->dev, reg, 2); in ocs_config_read16()
61 ocs_config_read8(ocs_os_handle_t os, uint32_t reg) in ocs_config_read8() argument
63 return pci_read_config(os->dev, reg, 1); in ocs_config_read8()
67 ocs_config_write8(ocs_os_handle_t os, uint32_t reg, uint8_t val) in ocs_config_write8() argument
69 return pci_write_config(os->dev, reg, val, 1); in ocs_config_write8()
73 ocs_config_write16(ocs_os_handle_t os, uint32_t reg, uint16_t val) in ocs_config_write16() argument
75 return pci_write_config(os->dev, reg, val, 2); in ocs_config_write16()
79 ocs_config_write32(ocs_os_handle_t os, uint32_t reg, uint32_t val) in ocs_config_write32() argument
81 return pci_write_config(os->dev, reg, val, 4); in ocs_config_write32()
85 * @ingroup os
89 * PCI BARs which form a logical address. For example, a 64-bit address uses
94 * @param off Offset from the base address of the Register Set
103 reg = &ocs->reg[rset]; in ocs_reg_read32()
105 return bus_space_read_4(reg->btag, reg->bhandle, off); in ocs_reg_read32()
109 * @ingroup os
113 * PCI BARs which form a logical address. For example, a 64-bit address uses
118 * @param off Offset from the base address of the Register Set
127 reg = &ocs->reg[rset]; in ocs_reg_read16()
129 return bus_space_read_2(reg->btag, reg->bhandle, off); in ocs_reg_read16()
133 * @ingroup os
137 * PCI BARs which form a logical address. For example, a 64-bit address uses
142 * @param off Offset from the base address of the Register Set
151 reg = &ocs->reg[rset]; in ocs_reg_read8()
153 return bus_space_read_1(reg->btag, reg->bhandle, off); in ocs_reg_read8()
157 * @ingroup os
161 * PCI BARs which form a logical address. For example, a 64-bit address uses
166 * @param off Offset from the base address of the Register Set
176 reg = &ocs->reg[rset]; in ocs_reg_write32()
178 return bus_space_write_4(reg->btag, reg->bhandle, off, val); in ocs_reg_write32()
182 * @ingroup os
183 * @brief Write a 16-bit PCI register
186 * PCI BARs which form a logical address. For example, a 64-bit address uses
191 * @param off Offset from the base address of the Register Set
201 reg = &ocs->reg[rset]; in ocs_reg_write16()
203 return bus_space_write_2(reg->btag, reg->bhandle, off, val); in ocs_reg_write16()
207 * @ingroup os
208 * @brief Write a 8-bit PCI register
211 * PCI BARs which form a logical address. For example, a 64-bit address uses
216 * @param off Offset from the base address of the Register Set
226 reg = &ocs->reg[rset]; in ocs_reg_write8()
228 return bus_space_write_1(reg->btag, reg->bhandle, off, val); in ocs_reg_write8()
232 * @ingroup os
235 * @param os OS handle
242 ocs_malloc(ocs_os_handle_t os, size_t size, int32_t flags) in ocs_malloc() argument
252 long offset = 0; in ocs_malloc() local
255 linker_ddb_search_symbol_name(__builtin_return_address(1), nameb, sizeof(nameb), &offset); in ocs_malloc()
256 printf("A: %p %ld @ %s+%#lx\n", addr, size, nameb, offset); in ocs_malloc()
263 * @ingroup os
266 * @param os OS handle
273 ocs_free(ocs_os_handle_t os, void *addr, size_t size) in ocs_free() argument
301 dma->phys = 0; in ocs_dma_load()
303 dma->phys = seg->ds_addr; in ocs_dma_load()
308 * @ingroup os
311 * @param os Device abstraction
314 * @return 0 if memory is de-allocated, -1 otherwise
317 ocs_dma_free(ocs_os_handle_t os, ocs_dma_t *dma) in ocs_dma_free() argument
319 struct ocs_softc *ocs = os; in ocs_dma_free()
322 device_printf(ocs->dev, "%s: bad parameter(s) dma=%p\n", __func__, dma); in ocs_dma_free()
323 return -1; in ocs_dma_free()
326 if (dma->size == 0) { in ocs_dma_free()
330 if (dma->map) { in ocs_dma_free()
331 bus_dmamap_sync(dma->tag, dma->map, BUS_DMASYNC_POSTREAD | in ocs_dma_free()
333 bus_dmamap_unload(dma->tag, dma->map); in ocs_dma_free()
336 if (dma->virt) { in ocs_dma_free()
337 bus_dmamem_free(dma->tag, dma->virt, dma->map); in ocs_dma_free()
338 bus_dmamap_destroy(dma->tag, dma->map); in ocs_dma_free()
340 bus_dma_tag_destroy(dma->tag); in ocs_dma_free()
348 * @ingroup os
351 * @param os Device abstraction
359 ocs_dma_alloc(ocs_os_handle_t os, ocs_dma_t *dma, size_t size, size_t align) in ocs_dma_alloc() argument
361 struct ocs_softc *ocs = os; in ocs_dma_alloc()
364 device_printf(ocs->dev, "%s bad parameter(s) dma=%p size=%zd\n", in ocs_dma_alloc()
372 if (bus_dma_tag_create(ocs->dmat, align, 0, BUS_SPACE_MAXADDR, in ocs_dma_alloc()
374 size, 1, size, 0, NULL, NULL, &dma->tag)) { in ocs_dma_alloc()
375 device_printf(ocs->dev, "DMA tag allocation failed\n"); in ocs_dma_alloc()
379 dma->size = size; in ocs_dma_alloc()
382 if (bus_dmamem_alloc(dma->tag, &dma->virt, BUS_DMA_NOWAIT | BUS_DMA_COHERENT, in ocs_dma_alloc()
383 &dma->map)) { in ocs_dma_alloc()
384 device_printf(ocs->dev, "DMA memory allocation failed s=%zd a=%zd\n", size, align); in ocs_dma_alloc()
389 dma->alloc = dma->virt; in ocs_dma_alloc()
392 if (bus_dmamap_load(dma->tag, dma->map, dma->virt, dma->size, ocs_dma_load, in ocs_dma_alloc()
394 device_printf(ocs->dev, "DMA memory load failed\n"); in ocs_dma_alloc()
400 if (0 == dma->phys) { in ocs_dma_alloc()
401 device_printf(ocs->dev, "ocs_dma_load failed\n"); in ocs_dma_alloc()
410 * @ingroup os
418 * - BUS_DMASYNC_PREWRITE
419 * - BUS_DMASYNC_POSTREAD
424 bus_dmamap_sync(dma->tag, dma->map, flags); in ocs_dma_sync()
431 return -1; in ocs_dma_copy_in()
433 return -1; in ocs_dma_copy_in()
436 if (buffer_length > dma->size) in ocs_dma_copy_in()
437 buffer_length = dma->size; in ocs_dma_copy_in()
438 ocs_memcpy(dma->virt, buffer, buffer_length); in ocs_dma_copy_in()
439 dma->len = buffer_length; in ocs_dma_copy_in()
447 return -1; in ocs_dma_copy_out()
449 return -1; in ocs_dma_copy_out()
452 if (buffer_length > dma->len) in ocs_dma_copy_out()
453 buffer_length = dma->len; in ocs_dma_copy_out()
454 ocs_memcpy(buffer, dma->virt, buffer_length); in ocs_dma_copy_out()
459 * @ingroup os
466 ocs_lock_init(void *os, ocs_lock_t *lock, const char *name, ...) in ocs_lock_init() argument
471 ocs_vsnprintf(lock->name, MAX_LOCK_DESC_LEN, name, ap); in ocs_lock_init()
474 mtx_init(&lock->lock, lock->name, NULL, MTX_DEF); in ocs_lock_init()
511 * @return bit position or -1 if map is full
516 int32_t position = -1; in ocs_bitmap_find()
520 if (-1 != position) { in ocs_bitmap_find()
534 * @return bit position or -1
542 return -1; in ocs_bitmap_search()
576 p += snprintf(p, sizeof(buf) - (p - buf), "%s: ", DRV_NAME); in _ocs_log()
577 p += snprintf(p, sizeof(buf) - (p - buf), "%s:", func_name); in _ocs_log()
578 p += snprintf(p, sizeof(buf) - (p - buf), "%i:", line); in _ocs_log()
579 …p += snprintf(p, sizeof(buf) - (p - buf), "%s:", (ocs != NULL) ? device_get_nameunit(ocs->dev) : "… in _ocs_log()
580 p += vsnprintf(p, sizeof(buf) - (p - buf), fmt, ap); in _ocs_log()
604 thread->retval = (*thread->fctn)(thread->arg); in ocs_thread_call_fctn()
605 ocs_free(NULL, thread->name, ocs_strlen(thread->name+1)); in ocs_thread_call_fctn()
615 * @param os OS handle
623 * @return returns 0 for success, a negative error code value for failure.
627 ocs_thread_create(ocs_os_handle_t os, ocs_thread_t *thread, ocs_thread_fctn fctn, const char *name,… in ocs_thread_create() argument
633 thread->fctn = fctn; in ocs_thread_create()
634 thread->name = ocs_strdup(name); in ocs_thread_create()
635 if (thread->name == NULL) { in ocs_thread_create()
636 thread->name = "unknown"; in ocs_thread_create()
638 thread->arg = arg; in ocs_thread_create()
640 ocs_atomic_set(&thread->terminate, 0); in ocs_thread_create()
642 …rc = kthread_add(ocs_thread_call_fctn, thread, NULL, &thread->tcb, (start == OCS_THREAD_CREATE) ? … in ocs_thread_create()
655 * @return returns 0 for success, a negative error code value for failure.
661 thread_lock(thread->tcb); in ocs_thread_start()
662 sched_add(thread->tcb, SRQ_BORING); in ocs_thread_start()
678 return mythread->arg; in ocs_thread_get_arg()
689 * @return returns 0 for success, a negative error code value for failure.
695 ocs_atomic_set(&thread->terminate, 1); in ocs_thread_terminate()
705 * @return returns non-zero if a stop has been requested
710 return ocs_atomic_read(&thread->terminate); in ocs_thread_terminate_requested()
726 return thread->retval; in ocs_thread_get_retval()
755 return -1; in ocs_thread_setcpu()
770 ocs_vsnprintf(sem->name, sizeof(sem->name), name, ap); in ocs_sem_init()
773 sema_init(&sem->sem, val, sem->name); in ocs_sem_init()
778 * @ingroup os
784 * BSD handles this for us - arg is already in kernel space,
787 * @param os OS handle
794 void *ocs_ioctl_preprocess(ocs_os_handle_t os, void *arg, size_t size) in ocs_ioctl_preprocess() argument
800 * @ingroup os
808 * @param os OS handle
816 int32_t ocs_ioctl_postprocess(ocs_os_handle_t os, void *arg, void *kern_ptr, size_t size) in ocs_ioctl_postprocess() argument
822 * @ingroup os
833 * @param os OS handle
840 void ocs_ioctl_free(ocs_os_handle_t os, void *kern_ptr, size_t size) in ocs_ioctl_free() argument
845 void ocs_intr_disable(ocs_os_handle_t os) in ocs_intr_disable() argument
849 void ocs_intr_enable(ocs_os_handle_t os) in ocs_intr_enable() argument
886 *bus = pci_get_bus(ocs->dev); in ocs_get_bus_dev_func()
887 *dev = pci_get_slot(ocs->dev); in ocs_get_bus_dev_func()
888 *func= pci_get_function(ocs->dev); in ocs_get_bus_dev_func()
898 * @return returns 0 for success, a negative error code value for failure.
904 cpuinfo->num_cpus = mp_ncpus; in ocs_get_cpuinfo()
924 if (callout_pending(&timer->callout)) { in __ocs_callout()
929 if (!callout_active(&timer->callout)) { in __ocs_callout()
934 callout_deactivate(&timer->callout); in __ocs_callout()
936 if (timer->func) { in __ocs_callout()
937 timer->func(timer->data); in __ocs_callout()
942 ocs_setup_timer(ocs_os_handle_t os, ocs_timer_t *timer, void(*func)(void *arg), void *data, uint32_… in ocs_setup_timer() argument
949 return -1; in ocs_setup_timer()
952 if (!mtx_initialized(&timer->lock)) { in ocs_setup_timer()
953 mtx_init(&timer->lock, "ocs_timer", NULL, MTX_DEF); in ocs_setup_timer()
956 callout_init_mtx(&timer->callout, &timer->lock, 0); in ocs_setup_timer()
958 timer->func = func; in ocs_setup_timer()
959 timer->data = data; in ocs_setup_timer()
970 mtx_lock(&timer->lock); in ocs_setup_timer()
971 callout_reset(&timer->callout, hz, __ocs_callout, timer); in ocs_setup_timer()
972 mtx_unlock(&timer->lock); in ocs_setup_timer()
985 return -1; in ocs_mod_timer()
997 mtx_lock(&timer->lock); in ocs_mod_timer()
998 callout_reset(&timer->callout, hz, __ocs_callout, timer); in ocs_mod_timer()
999 mtx_unlock(&timer->lock); in ocs_mod_timer()
1007 return callout_active(&timer->callout); in ocs_timer_pending()
1014 mtx_lock(&timer->lock); in ocs_del_timer()
1015 callout_stop(&timer->callout); in ocs_del_timer()
1016 mtx_unlock(&timer->lock); in ocs_del_timer()
1041 ocs_save_ddump_all(OCS_DDUMP_FLAGS_WQES|OCS_DDUMP_FLAGS_CQES|OCS_DDUMP_FLAGS_MQES, -1, TRUE); in _ocs_assert()