Ignore:
Timestamp:
2011-01-07T16:42:00Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
93fb170c
Parents:
15701921
Message:

port_status refactoring, use flags instead of structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/root_hub/port_status.h

    r15701921 r8f748215  
    3535#define DRV_UHCI_TD_PORT_STATUS_H
    3636
     37#include <libarch/ddi.h>
    3738#include <stdint.h>
    3839
    39 struct port_register {
    40         uint8_t connected:1;
    41         uint8_t connect_change:1;
    42         uint8_t enabled:1;
    43         uint8_t enabled_change:1;
    44         uint8_t line:2;
    45         uint8_t resume:1;
    46         const uint8_t always_one:1; /* reserved */
     40typedef uint16_t port_status_t;
    4741
    48         uint8_t low_speed:1;
    49         uint8_t reset:1;
    50         uint8_t :2; /* reserved */
    51         uint8_t suspended:1;
    52         uint8_t :3; /* reserved */
    53         /* first byte */
    54 //      uint8_t :3; /* reserved */
    55 //      uint8_t suspended:1;
    56 //      uint8_t :2; /* reserved */
    57 //      uint8_t reset:1;
    58 //      uint8_t low_speed:1;
     42enum {
     43        STATUS_CONNECTED         = 1 << 0,
     44        STATUS_CONNECTED_CHANGED = 1 << 1,
     45        STATUS_ENABLED           = 1 << 2,
     46        STATUS_ENABLED_CHANGED   = 1 << 3,
     47        STATUS_LINE_D_PLUS       = 1 << 4,
     48        STATUS_LINE_D_MINUS      = 1 << 5,
     49        STATUS_RESUME            = 1 << 6,
     50        STATUS_ALWAYS_ONE        = 1 << 7,
    5951
    60         /* second byte */
    61 //      uint8_t :1; /* reserved */
    62 //      uint8_t resume:1;
    63 //      uint8_t line:2;
    64 //      uint8_t enabled_change:1;
    65 //      uint8_t enabled:1;
    66 //      uint8_t connect_change:1;
    67 //      uint8_t connected:1;
    68 } __attribute__((packed));
     52        STATUS_LOW_SPEED = 1 <<  8,
     53        STATUS_IN_RESET  = 1 <<  9,
     54        STATUS_SUSPEND   = 1 << 12,
     55};
    6956
    70 typedef union port_status {
    71         struct port_register status;
    72         uint16_t raw_value;
    73 } port_status_t;
     57static inline port_status_t port_status_read(port_status_t * address)
     58        { return pio_read_16(address); }
    7459
    75 void print_port_status( const port_status_t *status );
     60static inline void port_status_write(
     61  port_status_t * address, port_status_t value)
     62        { pio_write_16(address, value); }
     63
     64void print_port_status(const port_status_t status);
    7665#endif
    7766/**
Note: See TracChangeset for help on using the changeset viewer.