Changeset 001b152 in mainline


Ignore:
Timestamp:
2011-03-23T23:04:22Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
30718cc2
Parents:
05ead5c
Message:

Use simple slab allocator for hw accessible memory

Location:
uspace/drv/uhci-hcd
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/Makefile

    r05ead5c r001b152  
    4040        root_hub.c \
    4141        hw_struct/transfer_descriptor.c \
     42        utils/slab.c \
    4243        pci.c \
    4344        batch.c
  • uspace/drv/uhci-hcd/hc.c

    r05ead5c r001b152  
    223223        ret = instance ? EOK : ENOMEM;
    224224        CHECK_RET_DEST_CMDS_RETURN(ret, "Failed to get frame list page.\n");
    225         usb_log_debug("Initialized frame list.\n");
     225        usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
    226226
    227227        /* Set all frames to point to the first queue head */
  • uspace/drv/uhci-hcd/transfer_list.c

    r05ead5c r001b152  
    5858        }
    5959        instance->queue_head_pa = addr_to_phys(instance->queue_head);
     60        usb_log_debug2("Transfer list %s setup with QH: %p(%p).\n",
     61            name, instance->queue_head, instance->queue_head_pa);
    6062
    6163        qh_init(instance->queue_head);
     
    118120        qh_set_next_qh(last_qh, pa);
    119121
     122        asm volatile ("": : :"memory");
     123//      asm volatile("clflush (%0)": : "r"(last_qh));
     124
    120125        /* Add to the driver list */
    121126        list_append(&batch->link, &instance->batch_list);
     
    159164        fibril_mutex_unlock(&instance->guard);
    160165
     166        async_usleep(1000);
    161167        while (!list_empty(&done)) {
    162168                link_t *item = done.next;
     
    212218                    == addr_to_phys(batch_qh(batch)));
    213219                instance->queue_head->next = batch_qh(batch)->next;
     220//              asm volatile("clflush (%0)" : : "r"(instance->queue_head));
    214221                qpos = "FIRST";
    215222        } else {
     
    220227                    == addr_to_phys(batch_qh(batch)));
    221228                batch_qh(prev)->next = batch_qh(batch)->next;
     229//              asm volatile("clflush (%0)" : : "r"(batch_qh(prev)));
    222230                qpos = "NOT FIRST";
    223231        }
     232        asm volatile ("": : :"memory");
    224233        /* Remove from the batch list */
    225234        list_remove(&batch->link);
  • uspace/drv/uhci-hcd/utils/malloc32.h

    r05ead5c r001b152  
    4040#include <as.h>
    4141
     42#include "slab.h"
     43
    4244#define UHCI_STRCUTURES_ALIGNMENT 16
    4345#define UHCI_REQUIRED_PAGE_SIZE 4096
     46
    4447
    4548/** Get physical address translation
     
    5457
    5558        uintptr_t result;
    56         int ret = as_get_physical_mapping(addr, &result);
     59        const int ret = as_get_physical_mapping(addr, &result);
     60        assert(ret == EOK);
    5761
    5862        if (ret != EOK)
     
    6670 * @return Address of the alligned and big enough memory place, NULL on failure.
    6771 */
    68 static inline void * malloc32(size_t size)
    69         { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); }
     72static inline void * malloc32(size_t size) {
     73        if (size <= SLAB_ELEMENT_SIZE)
     74                return slab_malloc_g();
     75        assert(false);
     76        return memalign(UHCI_STRCUTURES_ALIGNMENT, size);
     77}
    7078/*----------------------------------------------------------------------------*/
    7179/** Physical mallocator simulator
     
    7381 * @param[in] addr Address of the place allocated by malloc32
    7482 */
    75 static inline void free32(void *addr)
    76         { if (addr) free(addr); }
     83static inline void free32(void *addr) {
     84        if (!addr)
     85                return;
     86        if (slab_in_range_g(addr))
     87                return slab_free_g(addr);
     88        free(addr);
     89}
    7790/*----------------------------------------------------------------------------*/
    7891/** Create 4KB page mapping
     
    8295static inline void * get_page(void)
    8396{
    84         void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    85         assert(free_address);
     97        void *free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
     98        assert(free_address); /* TODO: remove this assert */
    8699        if (free_address == 0)
    87100                return NULL;
    88         void* ret =
    89           as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
     101        void *ret = as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    90102                  AS_AREA_READ | AS_AREA_WRITE);
    91103        if (ret != free_address)
Note: See TracChangeset for help on using the changeset viewer.