Changeset 5856b627 in mainline for uspace/drv


Ignore:
Timestamp:
2013-08-20T12:36:48Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
26e2de3
Parents:
0ee999d (diff), 4da8fdb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline changes.

Location:
uspace/drv
Files:
14 added
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/i8237.c

    r0ee999d r5856b627  
    3838#include <stdbool.h>
    3939#include <errno.h>
     40#include <ddi.h>
     41#include <ddf/log.h>
    4042#include <fibril_synch.h>
    4143#include <ddi.h>
     
    198200        .channels = {
    199201                /* The first chip 8-bit */
    200                 {
    201                         (uint8_t *) 0x00,
    202                         (uint8_t *) 0x01,
    203                         (uint8_t *) 0x87,
    204                         (uint8_t *) 0x0a,
    205                         (uint8_t *) 0x0b,
    206                         (uint8_t *) 0x0c,
    207                 },
    208                 {
    209                         (uint8_t *) 0x02,
    210                         (uint8_t *) 0x03,
    211                         (uint8_t *) 0x83,
    212                         (uint8_t *) 0x0a,
    213                         (uint8_t *) 0x0b,
    214                         (uint8_t *) 0x0c,
    215                 },
    216                 {
    217                         (uint8_t *) 0x04,
    218                         (uint8_t *) 0x05,
    219                         (uint8_t *) 0x81,
    220                         (uint8_t *) 0x0a,
    221                         (uint8_t *) 0x0b,
    222                         (uint8_t *) 0x0c,
    223                 },
    224                 {
    225                         (uint8_t *) 0x06,
    226                         (uint8_t *) 0x07,
    227                         (uint8_t *) 0x82,
    228                         (uint8_t *) 0x0a,
    229                         (uint8_t *) 0x0b,
    230                         (uint8_t *) 0x0c,
     202                { /* Channel 0 - Unusable*/
     203                        .offset_reg_address = (uint8_t *) 0x00,
     204                        .size_reg_address = (uint8_t *) 0x01,
     205                        .page_reg_address = (uint8_t *) 0x87,
     206                        .single_mask_address = (uint8_t *) 0x0a,
     207                        .mode_address = (uint8_t *) 0x0b,
     208                        .flip_flop_address = (uint8_t *) 0x0c,
     209                },
     210                { /* Channel 1 */
     211                        .offset_reg_address = (uint8_t *) 0x02,
     212                        .size_reg_address = (uint8_t *) 0x03,
     213                        .page_reg_address = (uint8_t *) 0x83,
     214                        .single_mask_address = (uint8_t *) 0x0a,
     215                        .mode_address = (uint8_t *) 0x0b,
     216                        .flip_flop_address = (uint8_t *) 0x0c,
     217                },
     218                { /* Channel 2 */
     219                        .offset_reg_address = (uint8_t *) 0x04,
     220                        .size_reg_address = (uint8_t *) 0x05,
     221                        .page_reg_address = (uint8_t *) 0x81,
     222                        .single_mask_address = (uint8_t *) 0x0a,
     223                        .mode_address = (uint8_t *) 0x0b,
     224                        .flip_flop_address = (uint8_t *) 0x0c,
     225                },
     226                { /* Channel 3 */
     227                        .offset_reg_address = (uint8_t *) 0x06,
     228                        .size_reg_address = (uint8_t *) 0x07,
     229                        .page_reg_address = (uint8_t *) 0x82,
     230                        .single_mask_address = (uint8_t *) 0x0a,
     231                        .mode_address = (uint8_t *) 0x0b,
     232                        .flip_flop_address = (uint8_t *) 0x0c,
    231233                },
    232234               
    233235                /* The second chip 16-bit */
    234                 {
    235                         (uint8_t *) 0xc0,
    236                         (uint8_t *) 0xc2,
    237                         (uint8_t *) 0x8f,
    238                         (uint8_t *) 0xd4,
    239                         (uint8_t *) 0xd6,
    240                         (uint8_t *) 0xd8,
    241                 },
    242                 {
    243                         (uint8_t *) 0xc4,
    244                         (uint8_t *) 0xc6,
    245                         (uint8_t *) 0x8b,
    246                         (uint8_t *) 0xd4,
    247                         (uint8_t *) 0xd6,
    248                         (uint8_t *) 0xd8,
    249                 },
    250                 {
    251                         (uint8_t *) 0xc8,
    252                         (uint8_t *) 0xca,
    253                         (uint8_t *) 0x89,
    254                         (uint8_t *) 0xd4,
    255                         (uint8_t *) 0xd6,
    256                         (uint8_t *) 0xd8,
    257                 },
    258                 {
    259                         (uint8_t *) 0xcc,
    260                         (uint8_t *) 0xce,
    261                         (uint8_t *) 0x8a,
    262                         (uint8_t *) 0xd4,
    263                         (uint8_t *) 0xd6,
    264                         (uint8_t *) 0xd8,
     236                { /* Channel 4 - Unusable */
     237                        .offset_reg_address = (uint8_t *) 0xc0,
     238                        .size_reg_address = (uint8_t *) 0xc2,
     239                        .page_reg_address = (uint8_t *) 0x8f,
     240                        .single_mask_address = (uint8_t *) 0xd4,
     241                        .mode_address = (uint8_t *) 0xd6,
     242                        .flip_flop_address = (uint8_t *) 0xd8,
     243                },
     244                { /* Channel 5 */
     245                        .offset_reg_address = (uint8_t *) 0xc4,
     246                        .size_reg_address = (uint8_t *) 0xc6,
     247                        .page_reg_address = (uint8_t *) 0x8b,
     248                        .single_mask_address = (uint8_t *) 0xd4,
     249                        .mode_address = (uint8_t *) 0xd6,
     250                        .flip_flop_address = (uint8_t *) 0xd8,
     251                },
     252                { /* Channel 6 */
     253                        .offset_reg_address = (uint8_t *) 0xc8,
     254                        .size_reg_address = (uint8_t *) 0xca,
     255                        .page_reg_address = (uint8_t *) 0x89,
     256                        .single_mask_address = (uint8_t *) 0xd4,
     257                        .mode_address = (uint8_t *) 0xd6,
     258                        .flip_flop_address = (uint8_t *) 0xd8,
     259                },
     260                { /* Channel 7 */
     261                        .offset_reg_address = (uint8_t *) 0xcc,
     262                        .size_reg_address = (uint8_t *) 0xce,
     263                        .page_reg_address = (uint8_t *) 0x8a,
     264                        .single_mask_address = (uint8_t *) 0xd4,
     265                        .mode_address = (uint8_t *) 0xd6,
     266                        .flip_flop_address = (uint8_t *) 0xd8,
    265267                },
    266268        },
     
    272274};
    273275
    274 /* Initialize I/O access to DMA controller I/O ports.
     276/** Initialize I/O access to DMA controller I/O ports.
    275277 *
    276278 * @param controller DMA Controller structure to initialize.
    277279 *
    278280 * @return Error code.
    279  *
    280281 */
    281282static inline int dma_controller_init(dma_controller_t *controller)
     
    304305       
    305306        return EOK;
     307}
     308
     309/** Helper function. Channels 4,5,6, and 7 are 8 bit DMA.
     310 * @pram channel DMA channel.
     311 * @reutrn True, if channel is 4,5,6, or 7, false otherwise.
     312 */
     313static inline bool is_dma16(unsigned channel)
     314{
     315        return (channel >= 4) && (channel < 8);
     316}
     317
     318/** Helper function. Channels 0,1,2, and 3 are 8 bit DMA.
     319 * @pram channel DMA channel.
     320 * @reutrn True, if channel is 0,1,2, or 3, false otherwise.
     321 */
     322static inline bool is_dma8(unsigned channel)
     323{
     324        return (channel < 4);
    306325}
    307326
     
    320339 *
    321340 * @return Error code.
    322  *
    323  */
    324 int dma_setup_channel(unsigned int channel, uint32_t pa, uint16_t size,
     341 */
     342int dma_channel_setup(unsigned int channel, uint32_t pa, uint32_t size,
    325343    uint8_t mode)
    326344{
     345        if (!is_dma8(channel) && !is_dma16(channel))
     346                return ENOENT;
     347
    327348        if ((channel == 0) || (channel == 4))
    328349                return ENOTSUP;
    329        
    330         if (channel > 7)
    331                 return ENOENT;
    332350       
    333351        /* DMA is limited to 24bit addresses. */
     
    336354       
    337355        /* 8 bit channels use only 4 bits from the page register. */
    338         if ((channel > 0) && (channel < 4) && (pa >= (1 << 20)))
     356        if (is_dma8(channel) && (pa >= (1 << 20)))
     357                return EINVAL;
     358
     359        /* Buffers cannot cross 64K page boundaries */
     360        if ((pa & 0xffff0000) != ((pa + size - 1) & 0xffff0000))
    339361                return EINVAL;
    340362       
     
    352374        ddf_msg(LVL_DEBUG, "Unspoiled address %#" PRIx32 " (size %" PRIu16 ")",
    353375            pa, size);
    354         if (channel > 4) {
     376        if (is_dma16(channel)) {
    355377                /* Size must be aligned to 16 bits */
    356378                if ((size & 1) != 0) {
     
    358380                        return EINVAL;
    359381                }
    360                
     382                /* Size is in 2byte words */
    361383                size >>= 1;
    362                
    363384                /* Address is fun: lower 16 bits need to be shifted by 1 */
    364385                pa = ((pa & 0xffff) >> 1) | (pa & 0xff0000);
     
    426447}
    427448
     449/** Query remaining buffer size.
     450 *
     451 * @param channel DMA Channel 1, 2, 3 for 8 bit transfers,
     452 *                    5, 6, 7 for 16 bit.
     453 * @param size    Place to store number of bytes pending in the assigned buffer.
     454 *
     455 * @return Error code.
     456 */
     457int dma_channel_remain(unsigned channel, size_t *size)
     458{
     459        assert(size);
     460        if (!is_dma8(channel) && !is_dma16(channel))
     461                return ENOENT;
     462       
     463        if ((channel == 0) || (channel == 4))
     464                return ENOTSUP;
     465       
     466        fibril_mutex_lock(&guard);
     467        if (!controller_8237.initialized) {
     468                fibril_mutex_unlock(&guard);
     469                return EIO;
     470        }
     471
     472        const dma_channel_t dma_channel = controller_8237.channels[channel];
     473        /* Get size - reset flip-flop */
     474        pio_write_8(dma_channel.flip_flop_address, 0);
     475       
     476        /* Low byte */
     477        const uint8_t value_low = pio_read_8(dma_channel.size_reg_address);
     478        ddf_msg(LVL_DEBUG2, "Read size low byte: %p:%x.",
     479            dma_channel.size_reg_address, value_low);
     480       
     481        /* High byte */
     482        const uint8_t value_high = pio_read_8(dma_channel.size_reg_address);
     483        ddf_msg(LVL_DEBUG2, "Read size high byte: %p:%x.",
     484            dma_channel.size_reg_address, value_high);
     485        fibril_mutex_unlock(&guard);
     486
     487        uint16_t remain = (value_high << 8 | value_low) ;
     488        /* 16 bit DMA size is in words,
     489         * the upper bits are bogus for 16bit transfers so we need to get
     490         * rid of them. Using limited type works well.*/
     491        if (is_dma16(channel))
     492                remain <<= 1;
     493        *size =  is_dma16(channel) ? remain + 2: remain + 1;
     494        return EOK;
     495}
    428496/**
    429497 * @}
  • uspace/drv/bus/isa/i8237.h

    r0ee999d r5856b627  
    3838#define DRV_BUS_ISA_I8237_H
    3939
    40 extern int dma_setup_channel(unsigned int, uint32_t, uint16_t, uint8_t);
     40extern int dma_channel_setup(unsigned, uint32_t, uint32_t, uint8_t);
     41extern int dma_channel_remain(unsigned, size_t *);
    4142
    4243#endif
  • uspace/drv/bus/isa/isa.c

    r0ee999d r5856b627  
    8585        fibril_mutex_t mutex;
    8686        ddf_fun_t *fnode;
     87        hw_resource_t resources[ISA_MAX_HW_RES];
    8788        hw_resource_list_t hw_resources;
    8889        link_t bus_link;
     
    103104static hw_resource_list_t *isa_get_fun_resources(ddf_fun_t *fnode)
    104105{
    105         isa_fun_t *fun = isa_fun(fnode);
    106         assert(fun != NULL);
    107 
    108         return &fun->hw_resources;
    109 }
    110 
    111 static bool isa_enable_fun_interrupt(ddf_fun_t *fnode)
     106        isa_fun_t *isa = isa_fun(fnode);
     107        assert(isa);
     108
     109        return &isa->hw_resources;
     110}
     111
     112static bool isa_fun_enable_interrupt(ddf_fun_t *fnode)
    112113{
    113114        /* This is an old ugly way, copied from pci driver */
    114115        assert(fnode);
    115         isa_fun_t *fun = isa_fun(fnode);
     116        isa_fun_t *isa = isa_fun(fnode);
     117        assert(isa);
    116118
    117119        sysarg_t apic;
     
    129131                return false;
    130132
    131         const hw_resource_list_t *res = &fun->hw_resources;
     133        const hw_resource_list_t *res = &isa->hw_resources;
    132134        assert(res);
    133135        for (size_t i = 0; i < res->count; ++i) {
     
    151153}
    152154
    153 static int isa_dma_channel_fun_setup(ddf_fun_t *fnode,
    154     unsigned int channel, uint32_t pa, uint16_t size, uint8_t mode)
     155static int isa_fun_setup_dma(ddf_fun_t *fnode,
     156    unsigned int channel, uint32_t pa, uint32_t size, uint8_t mode)
    155157{
    156158        assert(fnode);
    157         isa_fun_t *fun = isa_fun(fnode);
    158         const hw_resource_list_t *res = &fun->hw_resources;
     159        isa_fun_t *isa = isa_fun(fnode);
     160        assert(isa);
     161        const hw_resource_list_t *res = &isa->hw_resources;
    159162        assert(res);
    160        
    161         const unsigned int ch = channel;
     163
    162164        for (size_t i = 0; i < res->count; ++i) {
     165                /* Check for assigned channel */
    163166                if (((res->resources[i].type == DMA_CHANNEL_16) &&
    164                     (res->resources[i].res.dma_channel.dma16 == ch)) ||
     167                    (res->resources[i].res.dma_channel.dma16 == channel)) ||
    165168                    ((res->resources[i].type == DMA_CHANNEL_8) &&
    166                     (res->resources[i].res.dma_channel.dma8 == ch))) {
    167                         return dma_setup_channel(channel, pa, size, mode);
    168                 }
    169         }
    170        
     169                    (res->resources[i].res.dma_channel.dma8 == channel))) {
     170                        return dma_channel_setup(channel, pa, size, mode);
     171                }
     172        }
     173
     174        return EINVAL;
     175}
     176
     177static int isa_fun_remain_dma(ddf_fun_t *fnode,
     178    unsigned channel, size_t *size)
     179{
     180        assert(size);
     181        assert(fnode);
     182        isa_fun_t *isa = isa_fun(fnode);
     183        assert(isa);
     184        const hw_resource_list_t *res = &isa->hw_resources;
     185        assert(res);
     186
     187        for (size_t i = 0; i < res->count; ++i) {
     188                /* Check for assigned channel */
     189                if (((res->resources[i].type == DMA_CHANNEL_16) &&
     190                    (res->resources[i].res.dma_channel.dma16 == channel)) ||
     191                    ((res->resources[i].type == DMA_CHANNEL_8) &&
     192                    (res->resources[i].res.dma_channel.dma8 == channel))) {
     193                        return dma_channel_remain(channel, size);
     194                }
     195        }
     196
    171197        return EINVAL;
    172198}
     
    174200static hw_res_ops_t isa_fun_hw_res_ops = {
    175201        .get_resource_list = isa_get_fun_resources,
    176         .enable_interrupt = isa_enable_fun_interrupt,
    177         .dma_channel_setup = isa_dma_channel_fun_setup,
     202        .enable_interrupt = isa_fun_enable_interrupt,
     203        .dma_channel_setup = isa_fun_setup_dma,
     204        .dma_channel_remain = isa_fun_remain_dma,
    178205};
    179206
    180 static ddf_dev_ops_t isa_fun_ops;
     207static ddf_dev_ops_t isa_fun_ops= {
     208        .interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops,
     209};
    181210
    182211static int isa_dev_add(ddf_dev_t *dev);
     
    212241
    213242        fibril_mutex_initialize(&fun->mutex);
     243        fun->hw_resources.resources = fun->resources;
     244
    214245        fun->fnode = fnode;
    215246        return fun;
     
    270301{
    271302        char *line = str;
     303        *next = NULL;
    272304
    273305        if (str == NULL) {
    274                 *next = NULL;
    275306                return NULL;
    276307        }
     
    282313        if (*str != '\0') {
    283314                *next = str + 1;
    284         } else {
    285                 *next = NULL;
    286315        }
    287316
     
    310339        /* Get the name part of the rest of the line. */
    311340        strtok(line, ":");
    312 
    313         /* Allocate output buffer. */
    314         size_t size = str_size(line) + 1;
    315         char *name = malloc(size);
    316 
    317         if (name != NULL) {
    318                 /* Copy the result to the output buffer. */
    319                 str_cpy(name, size, line);
    320         }
    321 
    322         return name;
    323 }
    324 
    325 static inline char *skip_spaces(char *line)
     341        return line;
     342}
     343
     344static inline const char *skip_spaces(const char *line)
    326345{
    327346        /* Skip leading spaces. */
     
    332351}
    333352
    334 static void isa_fun_set_irq(isa_fun_t *fun, int irq)
     353static void isa_fun_add_irq(isa_fun_t *fun, int irq)
    335354{
    336355        size_t count = fun->hw_resources.count;
     
    348367}
    349368
    350 static void isa_fun_set_dma(isa_fun_t *fun, int dma)
     369static void isa_fun_add_dma(isa_fun_t *fun, int dma)
    351370{
    352371        size_t count = fun->hw_resources.count;
     
    381400}
    382401
    383 static void isa_fun_set_io_range(isa_fun_t *fun, size_t addr, size_t len)
     402static void isa_fun_add_io_range(isa_fun_t *fun, size_t addr, size_t len)
    384403{
    385404        size_t count = fun->hw_resources.count;
     
    400419}
    401420
    402 static void fun_parse_irq(isa_fun_t *fun, char *val)
     421static void fun_parse_irq(isa_fun_t *fun, const char *val)
    403422{
    404423        int irq = 0;
     
    409428
    410429        if (val != end)
    411                 isa_fun_set_irq(fun, irq);
    412 }
    413 
    414 static void fun_parse_dma(isa_fun_t *fun, char *val)
    415 {
    416         unsigned int dma = 0;
     430                isa_fun_add_irq(fun, irq);
     431}
     432
     433static void fun_parse_dma(isa_fun_t *fun, const char *val)
     434{
    417435        char *end = NULL;
    418436       
    419437        val = skip_spaces(val);
    420         dma = (unsigned int) strtol(val, &end, 10);
     438        const int dma = strtol(val, &end, 10);
    421439       
    422440        if (val != end)
    423                 isa_fun_set_dma(fun, dma);
    424 }
    425 
    426 static void fun_parse_io_range(isa_fun_t *fun, char *val)
     441                isa_fun_add_dma(fun, dma);
     442}
     443
     444static void fun_parse_io_range(isa_fun_t *fun, const char *val)
    427445{
    428446        size_t addr, len;
     
    441459                return;
    442460
    443         isa_fun_set_io_range(fun, addr, len);
    444 }
    445 
    446 static void get_match_id(char **id, char *val)
    447 {
    448         char *end = val;
     461        isa_fun_add_io_range(fun, addr, len);
     462}
     463
     464static void get_match_id(char **id, const char *val)
     465{
     466        const char *end = val;
    449467
    450468        while (!isspace(*end))
     
    456474}
    457475
    458 static void fun_parse_match_id(isa_fun_t *fun, char *val)
     476static void fun_parse_match_id(isa_fun_t *fun, const char *val)
    459477{
    460478        char *id = NULL;
    461         int score = 0;
    462479        char *end = NULL;
    463         int rc;
    464480
    465481        val = skip_spaces(val);
    466482
    467         score = (int)strtol(val, &end, 10);
     483        int score = (int)strtol(val, &end, 10);
    468484        if (val == end) {
    469485                ddf_msg(LVL_ERROR, "Cannot read match score for function "
     
    483499            "function %s", id, score, ddf_fun_get_name(fun->fnode));
    484500
    485         rc = ddf_fun_add_match_id(fun->fnode, id, score);
     501        int rc = ddf_fun_add_match_id(fun->fnode, id, score);
    486502        if (rc != EOK) {
    487503                ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
     
    492508}
    493509
    494 static bool prop_parse(isa_fun_t *fun, char *line, const char *prop,
    495     void (*read_fn)(isa_fun_t *, char *))
     510static bool prop_parse(isa_fun_t *fun, const char *line, const char *prop,
     511    void (*read_fn)(isa_fun_t *, const char *))
    496512{
    497513        size_t proplen = str_size(prop);
     
    508524}
    509525
    510 static void fun_prop_parse(isa_fun_t *fun, char *line)
     526static void fun_prop_parse(isa_fun_t *fun, const char *line)
    511527{
    512528        /* Skip leading spaces. */
     
    523539}
    524540
    525 static void fun_hw_res_alloc(isa_fun_t *fun)
    526 {
    527         fun->hw_resources.resources =
    528             (hw_resource_t *) malloc(sizeof(hw_resource_t) * ISA_MAX_HW_RES);
    529 }
    530 
    531 static void fun_hw_res_free(isa_fun_t *fun)
    532 {
    533         free(fun->hw_resources.resources);
    534         fun->hw_resources.resources = NULL;
    535 }
    536 
    537541static char *isa_fun_read_info(char *fun_conf, isa_bus_t *isa)
    538542{
    539543        char *line;
    540         char *fun_name = NULL;
    541544
    542545        /* Skip empty lines. */
    543         while (true) {
     546        do {
    544547                line = str_get_line(fun_conf, &fun_conf);
    545548
     
    549552                }
    550553
    551                 if (!line_empty(line))
    552                         break;
    553         }
     554        } while (line_empty(line));
    554555
    555556        /* Get device name. */
    556         fun_name = get_device_name(line);
     557        const char *fun_name = get_device_name(line);
    557558        if (fun_name == NULL)
    558559                return NULL;
    559560
    560561        isa_fun_t *fun = isa_fun_create(isa, fun_name);
    561         free(fun_name);
    562562        if (fun == NULL) {
    563563                return NULL;
    564564        }
    565 
    566         /* Allocate buffer for the list of hardware resources of the device. */
    567         fun_hw_res_alloc(fun);
    568565
    569566        /* Get properties of the device (match ids, irq and io range). */
     
    596593}
    597594
    598 static void fun_conf_parse(char *conf, isa_bus_t *isa)
    599 {
     595static void isa_functions_add(isa_bus_t *isa)
     596{
     597        char *conf = fun_conf_read(CHILD_FUN_CONF_PATH);
    600598        while (conf != NULL && *conf != '\0') {
    601599                conf = isa_fun_read_info(conf, isa);
    602600        }
    603 }
    604 
    605 static void isa_functions_add(isa_bus_t *isa)
    606 {
    607         char *fun_conf;
    608 
    609         fun_conf = fun_conf_read(CHILD_FUN_CONF_PATH);
    610         if (fun_conf != NULL) {
    611                 fun_conf_parse(fun_conf, isa);
    612                 free(fun_conf);
    613         }
     601        free(conf);
    614602}
    615603
    616604static int isa_dev_add(ddf_dev_t *dev)
    617605{
    618         isa_bus_t *isa;
    619 
    620606        ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d",
    621607            (int) ddf_dev_get_handle(dev));
    622608
    623         isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t));
     609        isa_bus_t *isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t));
    624610        if (isa == NULL)
    625611                return ENOMEM;
     
    658644{
    659645        isa_bus_t *isa = isa_bus(dev);
    660         int rc;
    661646
    662647        fibril_mutex_lock(&isa->mutex);
     
    666651                    isa_fun_t, bus_link);
    667652
    668                 rc = ddf_fun_offline(fun->fnode);
     653                int rc = ddf_fun_offline(fun->fnode);
    669654                if (rc != EOK) {
    670655                        fibril_mutex_unlock(&isa->mutex);
     
    682667                list_remove(&fun->bus_link);
    683668
    684                 fun_hw_res_free(fun);
    685669                ddf_fun_destroy(fun->fnode);
    686670        }
     
    709693}
    710694
    711 
    712 static void isa_init()
    713 {
     695int main(int argc, char *argv[])
     696{
     697        printf(NAME ": HelenOS ISA bus driver\n");
    714698        ddf_log_init(NAME);
    715         isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
    716 }
    717 
    718 int main(int argc, char *argv[])
    719 {
    720         printf(NAME ": HelenOS ISA bus driver\n");
    721         isa_init();
    722699        return ddf_driver_main(&isa_driver);
    723700}
  • uspace/drv/infrastructure/root/root.c

    r0ee999d r5856b627  
    208208        /*
    209209         * Register virtual devices root.
    210          * We ignore error occurrence because virtual devices shall not be
     210         * We warn on error occurrence because virtual devices shall not be
    211211         * vital for the system.
    212212         */
    213         (void) add_virtual_root_fun(dev);
     213        int res = add_virtual_root_fun(dev);
     214        if (res != EOK)
     215                ddf_msg(LVL_WARN, "Failed to add virtual child.");
    214216
    215217        /* Register root device's children. */
    216         int res = add_platform_fun(dev);
     218        res = add_platform_fun(dev);
    217219        if (EOK != res)
    218220                ddf_msg(LVL_ERROR, "Failed adding child device for platform.");
  • uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c

    r0ee999d r5856b627  
    4848
    4949typedef struct {
     50        const char *name;
     51        match_id_t match_id;
    5052        hw_resource_list_t hw_resources;
    5153} rootamdm37x_fun_t;
    5254
    53 /* See amdm37x TRM page. 3316 for these values */
    54 #define OHCI_BASE_ADDRESS  0x48064400
    55 #define OHCI_SIZE  1024
    56 #define EHCI_BASE_ADDRESS  0x48064800
    57 #define EHCI_SIZE  1024
     55/* See amdm37x TRM page 3316 for these values */
     56#define OHCI_BASE_ADDRESS   0x48064400
     57#define OHCI_SIZE   1024
     58#define EHCI_BASE_ADDRESS   0x48064800
     59#define EHCI_SIZE   1024
     60
     61/* See amdm37x TRM page 1813 for these values */
     62#define DSS_BASE_ADDRESS   0x48050000
     63#define DSS_SIZE   512
     64#define DISPC_BASE_ADDRESS   0x48050400
     65#define DISPC_SIZE   1024
     66#define VIDEO_ENC_BASE_ADDRESS   0x48050C00
     67#define VIDEO_ENC_SIZE   256
     68
    5869
    5970static hw_resource_t ohci_res[] = {
     
    8899};
    89100
    90 static const rootamdm37x_fun_t ohci = {
    91         .hw_resources = {
    92             .resources = ohci_res,
    93             .count = sizeof(ohci_res)/sizeof(ohci_res[0]),
    94         }
    95 };
    96 
    97 static const rootamdm37x_fun_t ehci = {
    98         .hw_resources = {
    99             .resources = ehci_res,
    100             .count = sizeof(ehci_res) / sizeof(ehci_res[0]),
    101         }
    102 };
     101static hw_resource_t disp_res[] = {
     102        {
     103                .type = MEM_RANGE,
     104                .res.io_range = {
     105                        .address = DSS_BASE_ADDRESS,
     106                        .size = DSS_SIZE,
     107                        .endianness = LITTLE_ENDIAN
     108                },
     109        },
     110        {
     111                .type = MEM_RANGE,
     112                .res.io_range = {
     113                        .address = DISPC_BASE_ADDRESS,
     114                        .size = DISPC_SIZE,
     115                        .endianness = LITTLE_ENDIAN
     116                },
     117        },
     118        {
     119                .type = MEM_RANGE,
     120                .res.io_range = {
     121                        .address = VIDEO_ENC_BASE_ADDRESS,
     122                        .size = VIDEO_ENC_SIZE,
     123                        .endianness = LITTLE_ENDIAN
     124                },
     125        },
     126        {
     127                .type = INTERRUPT,
     128                .res.interrupt = { .irq = 25 },
     129        },
     130};
     131
     132static const rootamdm37x_fun_t amdm37x_funcs[] = {
     133{
     134        .name = "ohci",
     135        .match_id = { .id = "usb/host=ohci", .score = 90 },
     136        .hw_resources = { .resources = ohci_res, .count = ARRAY_SIZE(ohci_res) }
     137},
     138{
     139        .name = "ehci",
     140        .match_id = { .id = "usb/host=ehci", .score = 90 },
     141        .hw_resources = { .resources = ehci_res, .count = ARRAY_SIZE(ehci_res) }
     142},
     143{
     144        .name = "fb",
     145        .match_id = { .id = "amdm37x&dispc", .score = 90 },
     146        .hw_resources = { .resources = disp_res, .count = ARRAY_SIZE(disp_res) }
     147},
     148};
     149
    103150
    104151static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode);
     
    114161};
    115162
    116 static int rootamdm37x_add_fun(ddf_dev_t *dev, const char *name,
    117     const char *str_match_id, const rootamdm37x_fun_t *fun)
    118 {
    119         ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
    120        
     163static int rootamdm37x_add_fun(ddf_dev_t *dev, const rootamdm37x_fun_t *fun)
     164{
     165        assert(dev);
     166        assert(fun);
     167
     168        ddf_msg(LVL_DEBUG, "Adding new function '%s'.", fun->name);
     169
    121170        /* Create new device function. */
    122         ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name);
     171        ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, fun->name);
    123172        if (fnode == NULL)
    124173                return ENOMEM;
    125174       
    126175        /* Add match id */
    127         int ret = ddf_fun_add_match_id(fnode, str_match_id, 100);
     176        int ret = ddf_fun_add_match_id(fnode,
     177            fun->match_id.id, fun->match_id.score);
    128178        if (ret != EOK) {
    129179                ddf_fun_destroy(fnode);
     
    146196        ret = ddf_fun_bind(fnode);
    147197        if (ret != EOK) {
    148                 ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
     198                ddf_msg(LVL_ERROR, "Failed binding function %s.", fun->name);
    149199                ddf_fun_destroy(fnode);
    150200                return ret;
     
    189239
    190240        /* Register functions */
    191         if (rootamdm37x_add_fun(dev, "ohci", "usb/host=ohci", &ohci) != EOK)
    192                 ddf_msg(LVL_ERROR, "Failed to add OHCI function for "
    193                     "BeagleBoard-xM platform.");
    194         if (rootamdm37x_add_fun(dev, "ehci", "usb/host=ehci", &ehci) != EOK)
    195                 ddf_msg(LVL_ERROR, "Failed to add EHCI function for "
    196                     "BeagleBoard-xM platform.");
    197         if (rootamdm37x_add_fun(dev, "dispc", "amdm37x&dispc", &ehci) != EOK)
    198                 ddf_msg(LVL_ERROR, "Failed to add dispc function for "
    199                     "BeagleBoard-xM platform.");
    200 
     241        for (unsigned i = 0; i < ARRAY_SIZE(amdm37x_funcs); ++i) {
     242                if (rootamdm37x_add_fun(dev, &amdm37x_funcs[i]) != EOK)
     243                        ddf_msg(LVL_ERROR, "Failed to add %s function for "
     244                            "BeagleBoard-xM platform.", amdm37x_funcs[i].name);
     245        }
    201246        return EOK;
    202247}
  • uspace/drv/infrastructure/rootamdm37x/uhh.h

    r0ee999d r5856b627  
    8585#define UHH_DEBUG_CSR_EHCI_SIMULATION_MODE_FLAG  (1 << 6)
    8686#define UHH_DEBUG_CSR_OHCI_CNTSEL_FLAG  (1 << 7)
    87 #define UHH_DEBUG_CSR_OHCI_GLOBAL_sUSPEND_FLAG  (1 << 16)
     87#define UHH_DEBUG_CSR_OHCI_GLOBAL_SUSPEND_FLAG  (1 << 16)
    8888#define UHH_DEBUG_CSR_OHCI_CCS1_FLAG  (1 << 17)
    8989#define UHH_DEBUG_CSR_OHCI_CCS2_FLAG  (1 << 18)
  • uspace/drv/nic/e1k/e1k.c

    r0ee999d r5856b627  
    5959#define E1000_DEFAULT_INTERRUPT_INTERVAL_USEC  250
    6060
    61 /* Must be power of 8 */
    62 #define E1000_RX_FRAME_COUNT  128
    63 #define E1000_TX_FRAME_COUNT  128
     61/* Must be power of 8 */ //TODO power or multiple? previous value was 128
     62#define E1000_RX_FRAME_COUNT  8
     63#define E1000_TX_FRAME_COUNT  8
    6464
    6565#define E1000_RECEIVE_ADDRESS  16
Note: See TracChangeset for help on using the changeset viewer.