diff --git a/src/add-ons/kernel/drivers/audio/echo/echo.cpp b/src/add-ons/kernel/drivers/audio/echo/echo.cpp index e95be7adb6..ca5f1e8e0f 100644 --- a/src/add-ons/kernel/drivers/audio/echo/echo.cpp +++ b/src/add-ons/kernel/drivers/audio/echo/echo.cpp @@ -49,8 +49,6 @@ char * names[NUM_CARDS*20+1]; extern device_hooks multi_hooks; -uint32 round_to_pagesize(uint32 size); -area_id map_mem(void **log, void *phy, size_t size, const char *name); int32 echo_int(void *arg); status_t init_hardware(void); status_t init_driver(void); @@ -327,39 +325,6 @@ echo_stream_delete(echo_stream *stream) } -uint32 round_to_pagesize(uint32 size) -{ - return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); -} - -/* This is not the most advanced method to map physical memory for io access. - * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS - * makes the whole offset calculation and relocation obsolete. But the code - * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. - */ -area_id -map_mem(void **log, void *phy, size_t size, const char *name) -{ - uint32 offset; - void *phyadr; - void *mapadr; - area_id area; - - LOG(("mapping physical address %p with %#x bytes for %s\n",phy,size,name)); - - offset = (uint32)phy & (B_PAGE_SIZE - 1); - phyadr = (void*)((uint32)phy - offset); - size = round_to_pagesize(size + offset); - area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); - *log = (void*) ((uint32)mapadr + offset); - - LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", - phy, *log, offset, phyadr, mapadr, size, area)); - - return area; -} - - /* Echo interrupt */ int32 echo_int(void *arg) diff --git a/src/add-ons/kernel/drivers/audio/echo/util.c b/src/add-ons/kernel/drivers/audio/echo/util.c index d71521def3..127fad7c01 100644 --- a/src/add-ons/kernel/drivers/audio/echo/util.c +++ b/src/add-ons/kernel/drivers/audio/echo/util.c @@ -86,3 +86,31 @@ area_id alloc_mem(void **phy, void **log, size_t size, const char *name) return areaid; } + +/* This is not the most advanced method to map physical memory for io access. + * Perhaps using B_ANY_KERNEL_ADDRESS instead of B_ANY_KERNEL_BLOCK_ADDRESS + * makes the whole offset calculation and relocation obsolete. But the code + * below does work, and I can't test if using B_ANY_KERNEL_ADDRESS also works. + */ +area_id +map_mem(void **log, void *phy, size_t size, const char *name) +{ + uint32 offset; + void *phyadr; + void *mapadr; + area_id area; + + LOG(("mapping physical address %p with %#x bytes for %s\n",phy,size,name)); + + offset = (uint32)phy & (B_PAGE_SIZE - 1); + phyadr = (void*)((uint32)phy - offset); + size = round_to_pagesize(size + offset); + area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, B_READ_AREA | B_WRITE_AREA, &mapadr); + *log = (void*) ((uint32)mapadr + offset); + + LOG(("physical = %p, logical = %p, offset = %#x, phyadr = %p, mapadr = %p, size = %#x, area = %#x\n", + phy, *log, offset, phyadr, mapadr, size, area)); + + return area; +} + diff --git a/src/add-ons/kernel/drivers/audio/echo/util.h b/src/add-ons/kernel/drivers/audio/echo/util.h index 02fb99225f..03e3f023dc 100644 --- a/src/add-ons/kernel/drivers/audio/echo/util.h +++ b/src/add-ons/kernel/drivers/audio/echo/util.h @@ -34,8 +34,6 @@ extern "C" { #include - - area_id alloc_mem(void **phy, void **log, size_t size, const char *name); cpu_status lock(void); @@ -43,6 +41,8 @@ void unlock(cpu_status status); extern spinlock slock; +area_id map_mem(void **log, void *phy, size_t size, const char *name); + #ifdef __cplusplus } #endif