Changeset 19d2ce01 in mainline for uspace/drv/char/sun4v-con


Ignore:
Timestamp:
2017-11-16T09:51:14Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
92232331
Parents:
ce96ec2
git-author:
Jiri Svoboda <jiri@…> (2017-11-15 21:50:05)
git-committer:
Jiri Svoboda <jiri@…> (2017-11-16 09:51:14)
Message:

Sun4v console driver can use hw_res for configuration.

Location:
uspace/drv/char/sun4v-con
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/sun4v-con/main.c

    rce96ec2 r19d2ce01  
    3232#include <ddf/driver.h>
    3333#include <ddf/log.h>
     34#include <device/hw_res_parsed.h>
    3435#include <errno.h>
    3536#include <stdio.h>
     
    5859};
    5960
     61static int sun4v_con_get_res(ddf_dev_t *dev, sun4v_con_res_t *res)
     62{
     63        async_sess_t *parent_sess;
     64        hw_res_list_parsed_t hw_res;
     65        int rc;
     66
     67        parent_sess = ddf_dev_parent_sess_get(dev);
     68        if (parent_sess == NULL)
     69                return ENOMEM;
     70
     71        hw_res_list_parsed_init(&hw_res);
     72        rc = hw_res_get_list_parsed(parent_sess, &hw_res, 0);
     73        if (rc != EOK)
     74                return rc;
     75
     76        if (hw_res.mem_ranges.count != 1) {
     77                rc = EINVAL;
     78                goto error;
     79        }
     80
     81        res->base = RNGABS(hw_res.mem_ranges.ranges[0]);
     82        return EOK;
     83error:
     84        hw_res_list_parsed_clean(&hw_res);
     85        return rc;
     86}
     87
     88
    6089static int sun4v_con_dev_add(ddf_dev_t *dev)
    6190{
    6291        sun4v_con_t *sun4v_con;
     92        sun4v_con_res_t res;
     93        int rc;
    6394
    6495        ddf_msg(LVL_DEBUG, "sun4v_con_dev_add(%p)", dev);
     
    71102        sun4v_con->dev = dev;
    72103
    73         return sun4v_con_add(sun4v_con);
     104        rc = sun4v_con_get_res(dev, &res);
     105        if (rc != EOK) {
     106                ddf_msg(LVL_ERROR, "Failed getting hardware resource list.\n");
     107                return EIO;
     108        }
     109
     110        return sun4v_con_add(sun4v_con, &res);
    74111}
    75112
  • uspace/drv/char/sun4v-con/sun4v-con.c

    rce96ec2 r19d2ce01  
    3838#include <ipc/char.h>
    3939#include <stdbool.h>
    40 #include <sysinfo.h>
    4140#include <thread.h>
    4241
     
    7271
    7372/** Add sun4v console device. */
    74 int sun4v_con_add(sun4v_con_t *con)
     73int sun4v_con_add(sun4v_con_t *con, sun4v_con_res_t *res)
    7574{
    7675        ddf_fun_t *fun = NULL;
    7776        int rc;
    7877
     78        con->res = *res;
    7979        input_buffer = (input_buffer_t) AS_AREA_ANY;
    8080
     
    8888        ddf_fun_set_conn_handler(fun, sun4v_con_connection);
    8989
    90         sysarg_t paddr;
    91         rc = sysinfo_get_value("niagara.inbuf.address", &paddr);
    92         if (rc != EOK) {
    93                 ddf_msg(LVL_ERROR, "niagara.inbuf.address not set (%d)", rc);
    94                 goto error;
    95         }
    96 
    97         rc = physmem_map(paddr, 1, AS_AREA_READ | AS_AREA_WRITE,
     90        rc = physmem_map(res->base, 1, AS_AREA_READ | AS_AREA_WRITE,
    9891            (void *) &input_buffer);
    9992        if (rc != EOK) {
  • uspace/drv/char/sun4v-con/sun4v-con.h

    rce96ec2 r19d2ce01  
    4141#include <stdint.h>
    4242
     43/** Sun4v console resources */
     44typedef struct {
     45        uintptr_t base;
     46} sun4v_con_res_t;
     47
    4348/** Sun4v console */
    4449typedef struct {
    4550        async_sess_t *client_sess;
    4651        ddf_dev_t *dev;
     52        sun4v_con_res_t res;
    4753} sun4v_con_t;
    4854
    49 extern int sun4v_con_init(sun4v_con_t *);
    50 extern void sun4v_con_write(uint8_t data);
    51 
    52 
    53 extern int sun4v_con_add(sun4v_con_t *);
     55extern int sun4v_con_add(sun4v_con_t *, sun4v_con_res_t *);
    5456extern int sun4v_con_remove(sun4v_con_t *);
    5557extern int sun4v_con_gone(sun4v_con_t *);
Note: See TracChangeset for help on using the changeset viewer.