Changeset 17ceb72 in mainline for uspace/drv/uhci-hcd/utils


Ignore:
Timestamp:
2011-03-14T01:39:44Z (15 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6298d80
Parents:
3bd96bb
Message:

Doxygen

Location:
uspace/drv/uhci-hcd/utils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/utils/device_keeper.c

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
     
    4040
    4141/*----------------------------------------------------------------------------*/
    42 /** Initializes device keeper structure.
     42/** Initialize device keeper structure.
    4343 *
    4444 * @param[in] instance Memory place to initialize.
     45 *
     46 * Set all values to false/0.
    4547 */
    4648void device_keeper_init(device_keeper_t *instance)
     
    5860}
    5961/*----------------------------------------------------------------------------*/
    60 /** Attempts to obtain address 0, blocks.
     62/** Attempt to obtain address 0, blocks.
    6163 *
    6264 * @param[in] instance Device keeper structure to use.
     
    7678}
    7779/*----------------------------------------------------------------------------*/
    78 /** Attempts to obtain address 0, blocks.
     80/** Attempt to obtain address 0, blocks.
    7981 *
    8082 * @param[in] instance Device keeper structure to use.
     
    9092}
    9193/*----------------------------------------------------------------------------*/
    92 /** Checks setup data for signs of toggle reset.
     94/** Check setup packet data for signs of toggle reset.
    9395 *
    9496 * @param[in] instance Device keeper structure to use.
    9597 * @param[in] target Device to receive setup packet.
    9698 * @param[in] data Setup packet data.
     99 *
     100 * Really ugly one.
    97101 */
    98102void device_keeper_reset_if_need(
     
    105109            || !instance->devices[target.address].occupied) {
    106110                fibril_mutex_unlock(&instance->guard);
     111                usb_log_error("Invalid data when checking for toggle reset.\n");
    107112                return;
    108113        }
     
    130135}
    131136/*----------------------------------------------------------------------------*/
    132 /** Gets current value of endpoint toggle.
     137/** Get current value of endpoint toggle.
    133138 *
    134139 * @param[in] instance Device keeper structure to use.
     
    144149            || target.address >= USB_ADDRESS_COUNT || target.address < 0
    145150            || !instance->devices[target.address].occupied) {
     151                usb_log_error("Invalid data when asking for toggle value.\n");
    146152                ret = EINVAL;
    147153        } else {
    148                 ret =
    149                     (instance->devices[target.address].toggle_status
     154                ret = (instance->devices[target.address].toggle_status
    150155                        >> target.endpoint) & 1;
    151156        }
     
    154159}
    155160/*----------------------------------------------------------------------------*/
    156 /** Sets current value of endpoint toggle.
     161/** Set current value of endpoint toggle.
    157162 *
    158163 * @param[in] instance Device keeper structure to use.
    159164 * @param[in] target Device and endpoint used.
    160  * @param[in] toggle Current toggle value.
     165 * @param[in] toggle Toggle value.
    161166 * @return Error code.
    162167 */
     
    170175            || target.address >= USB_ADDRESS_COUNT || target.address < 0
    171176            || !instance->devices[target.address].occupied) {
     177                usb_log_error("Invalid data when setting toggle value.\n");
    172178                ret = EINVAL;
    173179        } else {
     
    183189}
    184190/*----------------------------------------------------------------------------*/
    185 /** Gets a free USB address
     191/** Get a free USB address
    186192 *
    187193 * @param[in] instance Device keeper structure to use.
     
    216222}
    217223/*----------------------------------------------------------------------------*/
    218 /** Binds USB address to devman handle.
     224/** Bind USB address to devman handle.
    219225 *
    220226 * @param[in] instance Device keeper structure to use.
     
    234240}
    235241/*----------------------------------------------------------------------------*/
    236 /** Releases used USB address.
     242/** Release used USB address.
    237243 *
    238244 * @param[in] instance Device keeper structure to use.
     
    251257}
    252258/*----------------------------------------------------------------------------*/
    253 /** Finds USB address associated with the device
     259/** Find USB address associated with the device
    254260 *
    255261 * @param[in] instance Device keeper structure to use.
     
    274280}
    275281/*----------------------------------------------------------------------------*/
    276 /** Gets speed associated with the address
     282/** Get speed associated with the address
    277283 *
    278284 * @param[in] instance Device keeper structure to use.
  • uspace/drv/uhci-hcd/utils/device_keeper.h

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
  • uspace/drv/uhci-hcd/utils/malloc32.h

    r3bd96bb r17ceb72  
    4343#define UHCI_REQUIRED_PAGE_SIZE 4096
    4444
     45/** Get physical address translation
     46 *
     47 * @param[in] addr Virtual address to translate
     48 * @return Physical address if exists, NULL otherwise.
     49 */
    4550static inline uintptr_t addr_to_phys(void *addr)
    4651{
     
    4853        int ret = as_get_physical_mapping(addr, &result);
    4954
    50         assert(ret == 0);
     55        if (ret != EOK)
     56                return 0;
    5157        return (result | ((uintptr_t)addr & 0xfff));
    5258}
    53 
     59/*----------------------------------------------------------------------------*/
     60/** Physical mallocator simulator
     61 *
     62 * @param[in] size Size of the required memory space
     63 * @return Address of the alligned and big enough memory place, NULL on failure.
     64 */
    5465static inline void * malloc32(size_t size)
    5566        { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); }
    56 
    57 static inline void * get_page()
     67/*----------------------------------------------------------------------------*/
     68/** Physical mallocator simulator
     69 *
     70 * @param[in] addr Address of the place allocated by malloc32
     71 */
     72static inline void free32(void *addr)
     73        { if (addr) free(addr); }
     74/*----------------------------------------------------------------------------*/
     75/** Create 4KB page mapping
     76 *
     77 * @return Address of the mapped page, NULL on failure.
     78 */
     79static inline void * get_page(void)
    5880{
    5981        void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    6082        assert(free_address);
    6183        if (free_address == 0)
    62                 return 0;
     84                return NULL;
    6385        void* ret =
    6486          as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    6587                  AS_AREA_READ | AS_AREA_WRITE);
    6688        if (ret != free_address)
    67                 return 0;
     89                return NULL;
    6890        return ret;
    6991}
    70 
    71 static inline void free32(void *addr)
    72         { if (addr) free(addr); }
    7392
    7493#endif
Note: See TracChangeset for help on using the changeset viewer.