Changeset fb2de0a in mainline


Ignore:
Timestamp:
2011-05-25T18:02: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:
1889786, d208f3f
Parents:
fcbcaae9
Message:

Replace slab allocator with simple alignment trick

slab allocator removed

Location:
uspace/drv/uhci-hcd
Files:
2 deleted
2 edited

Legend:

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

    rfcbcaae9 rfb2de0a  
    4848        root_hub.c \
    4949        hw_struct/transfer_descriptor.c \
    50         utils/slab.c \
    5150        pci.c \
    5251        batch.c
  • uspace/drv/uhci-hcd/utils/malloc32.h

    rfcbcaae9 rfb2de0a  
    4141#include <as.h>
    4242
    43 #include "slab.h"
    44 
    4543#define UHCI_STRCUTURES_ALIGNMENT 16
    4644#define UHCI_REQUIRED_PAGE_SIZE 4096
     
    7068 */
    7169static inline void * malloc32(size_t size) {
    72         if (size <= SLAB_ELEMENT_SIZE)
    73                 return slab_malloc_g();
    74         usb_log_warning("Requested %zu bytes, current allocator can't handle "
    75             "that amount, pray that the standard malloc will suffice.", size);
    76         return memalign(UHCI_STRCUTURES_ALIGNMENT, size);
     70        /* This works only when the host has less than 4GB of memory as
     71         * physical address needs to fit into 32 bits */
     72
     73        /* If we need more than one page there is no guarantee that the
     74         * memory will be continuous */
     75        if (size > PAGE_SIZE)
     76                return NULL;
     77        /* Calculate alignment to make sure the block won't cross page
     78         * boundary */
     79        size_t alignment = UHCI_STRCUTURES_ALIGNMENT;
     80        while (alignment < size)
     81                alignment *= 2;
     82        return memalign(alignment, size);
    7783}
    7884/*----------------------------------------------------------------------------*/
     
    8490        if (!addr)
    8591                return;
    86         if (slab_in_range_g(addr))
    87                 return slab_free_g(addr);
    8892        free(addr);
    8993}
Note: See TracChangeset for help on using the changeset viewer.