Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 45cbf897 in mainline


Ignore:
Timestamp:
2015-07-03T03:54:45Z (6 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
master
Children:
8fc61c8
Parents:
e6d7df1
Message:

ehci, libusbhost: Move malloc32 to libusbhost.

So it can be shared with other HCDs.
Make sure the memory is mapped before returning from malloc32.
Add poison.

Fixes non-cntl transfers for ehci

Location:
uspace
Files:
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_batch.c

    re6d7df1 r45cbf897  
    4242#include <usb/usb.h>
    4343#include <usb/debug.h>
     44#include <usb/host/utils/malloc32.h>
    4445
    4546#include "ehci_batch.h"
    4647#include "ehci_endpoint.h"
    47 #include "utils/malloc32.h"
    4848
    4949/* The buffer pointer list in the qTD is long enough to support a maximum
  • uspace/drv/bus/usb/ehci/ehci_endpoint.c

    re6d7df1 r45cbf897  
    3636#include <stdlib.h>
    3737#include <usb/debug.h>
     38#include <usb/host/utils/malloc32.h>
    3839
    39 #include "utils/malloc32.h"
    4040#include "ehci_endpoint.h"
    4141#include "hc.h"
  • uspace/drv/bus/usb/ehci/endpoint_list.c

    re6d7df1 r45cbf897  
    4040#include <usb/debug.h>
    4141
    42 #include "utils/malloc32.h"
    4342#include "endpoint_list.h"
    4443
  • uspace/drv/bus/usb/ehci/endpoint_list.h

    re6d7df1 r45cbf897  
    3939#include <fibril_synch.h>
    4040#include <sys/types.h>
     41#include <usb/host/utils/malloc32.h>
    4142
    4243#include "ehci_endpoint.h"
    4344#include "hw_struct/queue_head.h"
    44 #include "utils/malloc32.h"
    4545
    4646/** Structure maintains both EHCI queue and software list of active endpoints.*/
  • uspace/drv/bus/usb/ehci/hc.c

    re6d7df1 r45cbf897  
    4545#include <usb/debug.h>
    4646#include <usb/usb.h>
    47 
    48 //#include "ehci_endpoint.h"
     47#include <usb/host/utils/malloc32.h>
     48
    4949#include "ehci_batch.h"
    50 #include "utils/malloc32.h"
    5150
    5251#include "hc.h"
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    re6d7df1 r45cbf897  
    3838#include <sys/types.h>
    3939#include <usb/host/endpoint.h>
    40 
    41 #include "../utils/malloc32.h"
     40#include <usb/host/utils/malloc32.h>
     41
    4242#include "link_pointer.h"
    4343#include "transfer_descriptor.h"
  • uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.c

    re6d7df1 r45cbf897  
    3939
    4040#include <usb/usb.h>
     41#include <usb/host/utils/malloc32.h>
    4142
    42 #include "../utils/malloc32.h"
    4343#include "mem_access.h"
    4444#include "transfer_descriptor.h"
  • uspace/lib/usbhost/include/usb/host/utils/malloc32.h

    re6d7df1 r45cbf897  
    3535#define DRV_EHCI_UTILS_MALLOC32_H
    3636
     37#include <align.h>
    3738#include <as.h>
    3839#include <ddi.h>
     
    6566}
    6667
    67 /** Create 4KB page mapping
    68  *
    69  * @return Address of the mapped page, NULL on failure.
    70  */
    71 static inline void *get_page(void)
    72 {
    73         uintptr_t phys;
    74         void *address = AS_AREA_ANY;
    75 
    76         const int ret = dmamem_map_anonymous(EHCI_REQUIRED_PAGE_SIZE,
    77             DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
    78             &address);
    79 
    80         return ((ret == EOK) ? address : NULL);
    81 }
    82 
    83 static inline void return_page(void *page)
    84 {
    85         dmamem_unmap_anonymous(page);
    86 }
    87 
    8868/** Physical mallocator simulator
    8969 *
     
    9373static inline void * malloc32(size_t size)
    9474{
    95         assert(size < PAGE_SIZE);
    96         return get_page();
     75        uintptr_t phys;
     76        void *address = AS_AREA_ANY;
     77        size_t real_size = ALIGN_UP(size, PAGE_SIZE);
     78
     79        const int ret = dmamem_map_anonymous(real_size,
     80            DMAMEM_4GiB, AS_AREA_READ | AS_AREA_WRITE, 0, &phys,
     81            &address);
     82
     83        if (ret == EOK) {
     84                /* Poison, accessing it should be enough to make sure
     85                 * the location is mapped, but poison works better */
     86                memset(address, 0x5, real_size);
     87                return address;
     88        }
     89        return NULL;
    9790}
    9891
     
    10396static inline void free32(void *addr)
    10497{
    105         return_page(addr);
     98        dmamem_unmap_anonymous(addr);
    10699}
     100
     101/** Create 4KB page mapping
     102 *
     103 * @return Address of the mapped page, NULL on failure.
     104 */
     105static inline void *get_page()
     106{
     107        return malloc32(PAGE_SIZE);
     108}
     109
     110static inline void return_page(void *page)
     111{
     112        free32(page);
     113}
     114
    107115
    108116#endif
Note: See TracChangeset for help on using the changeset viewer.