diff --git a/src/add-ons/kernel/drivers/network/rtl8169/util.c b/src/add-ons/kernel/drivers/network/rtl8169/util.c index f0149c21a3..be99ababc5 100644 --- a/src/add-ons/kernel/drivers/network/rtl8169/util.c +++ b/src/add-ons/kernel/drivers/network/rtl8169/util.c @@ -1,13 +1,17 @@ +/* Realtek RTL8169 Family Driver + * Copyright (C) 2004 Marcus Overhagen . All rights reserved. + */ #include #include #include +//#define DEBUG + #include "debug.h" #include "util.h" -uint32 round_to_pagesize(uint32 size); - -uint32 round_to_pagesize(uint32 size) +static inline uint32 +round_to_pagesize(uint32 size) { return (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1); } @@ -20,18 +24,18 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *n area_id areaid; status_t rv; - LOG("allocating %ld bytes for %s\n", size, name); + TRACE("allocating %ld bytes for %s\n", size, name); size = round_to_pagesize(size); areaid = create_area(name, &virtadr, B_ANY_KERNEL_ADDRESS, size, B_FULL_LOCK | B_CONTIGUOUS, protection); if (areaid < B_OK) { - LOG("couldn't allocate area %s\n", name); + ERROR("couldn't allocate area %s\n", name); return B_ERROR; } rv = get_memory_map(virtadr, size, &pe, 1); if (rv < B_OK) { delete_area(areaid); - LOG("couldn't map %s\n", name); + ERROR("couldn't get mapping for %s\n", name); return B_ERROR; } memset(virtadr, 0, size); @@ -39,15 +43,10 @@ alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *n *virt = virtadr; if (phy) *phy = pe.address; - LOG("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address); + TRACE("area = %ld, size = %ld, virt = %p, phy = %p\n", areaid, size, virtadr, pe.address); 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 **virt, void *phy, size_t size, uint32 protection, const char *name) { @@ -56,20 +55,20 @@ map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name void *mapadr; area_id area; - LOG("mapping physical address %p with %ld bytes for %s\n", phy, size, name); + TRACE("mapping physical address %p with %ld bytes for %s\n", phy, size, name); offset = (uint32)phy & (B_PAGE_SIZE - 1); phyadr = (char *)phy - offset; size = round_to_pagesize(size + offset); area = map_physical_memory(name, phyadr, size, B_ANY_KERNEL_BLOCK_ADDRESS, protection, &mapadr); if (area < B_OK) { - LOG("mapping failed, error 0x%x (%s)\n", area, strerror(area)); + ERROR("mapping '%s' failed, error 0x%lx (%s)\n", name, area, strerror(area)); return area; } *virt = (char *)mapadr + offset; - LOG("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n", + TRACE("physical = %p, virtual = %p, offset = %ld, phyadr = %p, mapadr = %p, size = %ld, area = 0x%08lx\n", phy, *virt, offset, phyadr, mapadr, size, area); return area; diff --git a/src/add-ons/kernel/drivers/network/rtl8169/util.h b/src/add-ons/kernel/drivers/network/rtl8169/util.h index e261c5f12b..c7051f81b9 100644 --- a/src/add-ons/kernel/drivers/network/rtl8169/util.h +++ b/src/add-ons/kernel/drivers/network/rtl8169/util.h @@ -1,3 +1,6 @@ +/* Realtek RTL8169 Family Driver + * Copyright (C) 2004 Marcus Overhagen . All rights reserved. + */ #ifndef __UTIL_H #define __UTIL_H