Changeset be1b1e68 in mainline


Ignore:
Timestamp:
2017-10-24T10:10:00Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
48adf0f
Parents:
cc92076
Message:

Enumerate OBIO by DDF.

Files:
3 added
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/Makefile.inc

    rcc92076 rbe1b1e68  
    4343        bus/pci/pciintel \
    4444        bus/isa \
     45        intctl/obio \
    4546        char/ns8250
    4647
    4748RD_DRV_CFG += \
    4849        bus/isa
    49 
    50 RD_SRVS_NON_ESSENTIAL +=
    51 
    52 RD_SRVS_ESSENTIAL += \
    53         $(USPACE_PATH)/srv/hw/irc/obio/obio
    5450
    5551SOURCES = \
  • uspace/Makefile

    rcc92076 rbe1b1e68  
    135135        srv/hid/remcons \
    136136        srv/hw/char/s3c24xx_uart \
    137         srv/hw/irc/obio \
    138137        srv/hid/rfb \
    139138        drv/audio/hdaudio \
     
    170169        drv/intctl/i8259 \
    171170        drv/intctl/icp-ic \
     171        drv/intctl/obio \
    172172        drv/nic/ne2k \
    173173        drv/nic/e1k \
  • uspace/drv/intctl/obio/Makefile

    rcc92076 rbe1b1e68  
    2828#
    2929
    30 USPACE_PREFIX = ../../../..
     30USPACE_PREFIX = ../../..
     31LIBS = $(LIBDRV_PREFIX)/libdrv.a
     32EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
    3133BINARY = obio
    3234
    3335SOURCES = \
     36        main.c \
    3437        obio.c
    3538
  • uspace/drv/intctl/obio/obio.c

    rcc92076 rbe1b1e68  
    4242 */
    4343
     44#include <align.h>
     45#include <as.h>
     46#include <async.h>
     47#include <ddf/driver.h>
     48#include <ddf/log.h>
     49#include <ddi.h>
     50#include <errno.h>
     51#include <inttypes.h>
    4452#include <ipc/irc.h>
    45 #include <loc.h>
    46 #include <as.h>
    47 #include <ddi.h>
    48 #include <align.h>
    49 #include <inttypes.h>
    5053#include <stdbool.h>
    51 #include <errno.h>
    52 #include <async.h>
    53 #include <align.h>
    54 #include <async.h>
    5554#include <stdio.h>
     55
     56#include "obio.h"
    5657
    5758#define NAME "obio"
     
    8889        while (1) {
    8990                int inr;
    90        
     91
    9192                callid = async_get_call(&call);
    9293                switch (IPC_GET_IMETHOD(call)) {
     
    112113}
    113114
    114 /** Initialize the OBIO driver.
    115  *
    116  * In the future, the OBIO driver should be integrated with the sun4u platform driver.
    117  */
    118 static bool obio_init(void)
     115/** Add OBIO device. */
     116int obio_add(obio_t *obio, obio_res_t *res)
    119117{
    120         category_id_t irc_cat;
    121         service_id_t svc_id;
     118        ddf_fun_t *fun_a = NULL;
    122119        int rc;
    123        
     120
    124121        base_phys = (uintptr_t) 0x1fe00000000ULL;
    125        
     122
    126123        int flags = AS_AREA_READ | AS_AREA_WRITE;
    127124        int retval = physmem_map(base_phys,
    128125            ALIGN_UP(OBIO_SIZE, PAGE_SIZE) >> PAGE_WIDTH, flags,
    129126            (void *) &base_virt);
    130        
     127
    131128        if (retval < 0) {
    132                 printf("%s: Error mapping OBIO registers\n", NAME);
    133                 return false;
     129                ddf_msg(LVL_ERROR, "Error mapping OBIO registers");
     130                rc = EIO;
     131                goto error;
    134132        }
    135        
    136         printf("%s: OBIO registers with base at 0x%" PRIun "\n", NAME, base_phys);
    137        
    138         async_set_fallback_port_handler(obio_connection, NULL);
    139        
    140         rc = loc_server_register(NAME);
     133
     134        ddf_msg(LVL_NOTE, "OBIO registers with base at 0x%" PRIun, base_phys);
     135
     136        fun_a = ddf_fun_create(obio->dev, fun_exposed, "a");
     137        if (fun_a == NULL) {
     138                ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
     139                rc = ENOMEM;
     140                goto error;
     141        }
     142
     143        ddf_fun_set_conn_handler(fun_a, obio_connection);
     144
     145        rc = ddf_fun_bind(fun_a);
    141146        if (rc != EOK) {
    142                 printf("%s: Failed registering server. (%d)\n", NAME, rc);
    143                 return false;
     147                ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc);
     148                goto error;
    144149        }
    145        
    146         rc = loc_service_register("irc/" NAME, &svc_id);
    147         if (rc != EOK) {
    148                 printf("%s: Failed registering service. (%d)\n", NAME, rc);
    149                 return false;
    150         }
    151        
    152         rc = loc_category_get_id("irc", &irc_cat, IPC_FLAG_BLOCKING);
    153         if (rc != EOK) {
    154                 printf("%s: Failed resolving category 'iplink' (%d).\n", NAME,
    155                     rc);
    156                 return false;
    157         }
    158        
    159         rc = loc_service_add_to_cat(svc_id, irc_cat);
    160         if (rc != EOK) {
    161                 printf("%s: Failed adding service to category (%d).\n", NAME,
    162                     rc);
    163                 return false;
    164         }
    165        
    166         return true;
     150
     151        rc = ddf_fun_add_to_category(fun_a, "irc");
     152        if (rc != EOK)
     153                goto error;
     154
     155        return EOK;
     156error:
     157        if (fun_a != NULL)
     158                ddf_fun_destroy(fun_a);
     159        return rc;
    167160}
    168161
    169 int main(int argc, char **argv)
     162/** Remove OBIO device */
     163int obio_remove(obio_t *obio)
    170164{
    171         printf("%s: HelenOS OBIO driver\n", NAME);
    172        
    173         if (!obio_init())
    174                 return -1;
    175        
    176         printf("%s: Accepting connections\n", NAME);
    177         task_retval(0);
    178         async_manager();
    179        
    180         /* Never reached */
    181         return 0;
     165        return ENOTSUP;
    182166}
     167
     168/** OBIO device gone */
     169int obio_gone(obio_t *obio)
     170{
     171        return ENOTSUP;
     172}
     173
    183174
    184175/**
  • uspace/drv/platform/sun4u/sun4u.c

    rcc92076 rbe1b1e68  
    8585        .name = NAME,
    8686        .driver_ops = &sun4u_ops
     87};
     88
     89static hw_resource_t obio_res[] = {
     90        {
     91                .type = MEM_RANGE,
     92                .res.mem_range = {
     93                        .address = PBM_BASE + PBM_PCI_CONFIG_BASE,
     94                        .size = PBM_PCI_CONFIG_SIZE,
     95                        .relative = false,
     96                        .endianness = LITTLE_ENDIAN
     97                }
     98        }
     99};
     100
     101static sun4u_fun_t obio_data = {
     102        .hw_resources = {
     103                .count = sizeof(obio_res) / sizeof(obio_res[0]),
     104                .resources = obio_res
     105        },
     106        .pio_window = {
     107                .mem = {
     108                        .base = PBM_BASE + PBM_PCI_MEM_BASE,
     109                        .size = PBM_PCI_MEM_SIZE
     110                }
     111        }
    87112};
    88113
     
    201226static bool sun4u_add_functions(ddf_dev_t *dev)
    202227{
     228        if (!sun4u_add_fun(dev, "obio", "ebus/obio", &obio_data))
     229                return false;
     230
    203231        return sun4u_add_fun(dev, "pci0", "intel_pci", &pci_data);
    204232}
Note: See TracChangeset for help on using the changeset viewer.