Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h

    r9d58539 r0d4b110  
    3636
    3737#include <assert.h>
    38 #include <stdint.h>
     38#include <stdbool.h>
     39#include <sys/types.h>
    3940
    4041#include <usb/host/endpoint.h>
     
    4445
    4546#include "completion_codes.h"
     47#include "mem_access.h"
    4648
    4749/**
     
    116118{
    117119        assert(instance);
    118         return (instance->td_head & ED_TDHEAD_HALTED_FLAG)
    119             || (instance->status & ED_STATUS_K_FLAG);
     120        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_HALTED_FLAG)
     121            || (OHCI_MEM32_RD(instance->status) & ED_STATUS_K_FLAG);
     122}
     123
     124static inline void ed_clear_halt(ed_t *instance)
     125{
     126        assert(instance);
     127        OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_HALTED_FLAG);
    120128}
    121129
     
    128136{
    129137        assert(instance);
    130         return (instance->td_head & ED_TDHEAD_PTR_MASK)
    131             != (instance->td_tail & ED_TDTAIL_PTR_MASK);
     138        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_PTR_MASK)
     139            != (OHCI_MEM32_RD(instance->td_tail) & ED_TDTAIL_PTR_MASK);
    132140}
    133141
     
    141149        assert(instance);
    142150        const uintptr_t pa = addr_to_phys(td);
    143         instance->td_tail = pa & ED_TDTAIL_PTR_MASK;
     151        OHCI_MEM32_WR(instance->td_tail, pa & ED_TDTAIL_PTR_MASK);
     152}
     153
     154static inline uint32_t ed_tail_td(const ed_t *instance)
     155{
     156        assert(instance);
     157        return OHCI_MEM32_RD(instance->td_tail) & ED_TDTAIL_PTR_MASK;
     158}
     159
     160static inline uint32_t ed_head_td(const ed_t *instance)
     161{
     162        assert(instance);
     163        return OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_PTR_MASK;
    144164}
    145165
     
    155175        const uint32_t pa = addr_to_phys(next);
    156176        assert((pa & ED_NEXT_PTR_MASK) << ED_NEXT_PTR_SHIFT == pa);
    157         instance->next = pa;
     177        OHCI_MEM32_WR(instance->next, pa);
     178}
     179
     180static inline uint32_t ed_next(const ed_t *instance)
     181{
     182        assert(instance);
     183        return OHCI_MEM32_RD(instance->next) & ED_NEXT_PTR_MASK;
    158184}
    159185
     
    166192{
    167193        assert(instance);
    168         return (instance->td_head & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
     194        return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
    169195}
    170196
     
    178204        assert(instance);
    179205        if (toggle) {
    180                 instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
     206                OHCI_MEM32_SET(instance->td_head, ED_TDHEAD_TOGGLE_CARRY);
    181207        } else {
    182208                /* Clear halted flag when reseting toggle TODO: Why? */
    183                 instance->td_head &= ~ED_TDHEAD_TOGGLE_CARRY;
    184                 instance->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     209                OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_TOGGLE_CARRY);
     210                OHCI_MEM32_CLR(instance->td_head, ED_TDHEAD_HALTED_FLAG);
    185211        }
    186212}
Note: See TracChangeset for help on using the changeset viewer.