Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset a416d070 in mainline


Ignore:
Timestamp:
2017-10-16T15:50:37Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
95c675b, b446b02
Parents:
1974f56a
Message:

Let ICP-IC be enumerated by the DDF.

Files:
3 added
5 edited
3 moved

Legend:

Unmodified
Added
Removed
  • .bzrignore

    r1974f56a ra416d070  
    1 *.ag.probe.[cs]
    21*.disasm
    32*.la
     
    205204uspace/dist/drv/hdaudio/
    206205uspace/dist/drv/i8042/
     206uspace/dist/drv/icp/
     207uspace/dist/drv/icp-ic/
    207208uspace/dist/drv/isa/
    208209uspace/dist/drv/kfb/
     
    212213uspace/dist/drv/pc/
    213214uspace/dist/drv/pciintel/
     215uspace/dist/drv/pl050/
    214216uspace/dist/drv/ps2mouse/
    215217uspace/dist/drv/root/
     
    274276uspace/drv/block/ata_bd/ata_bd
    275277uspace/drv/block/ddisk/ddisk
     278uspace/drv/bus/adb/cuda_adb/cuda_adb
    276279uspace/drv/bus/isa/isa
    277280uspace/drv/bus/pci/pciintel/pciintel
     
    293296uspace/drv/fb/amdm37x_dispc/amdm37x_dispc
    294297uspace/drv/fb/kfb/kfb
     298uspace/drv/intctl/icp-ic/icp-ic
    295299uspace/drv/nic/ar9271/ar9271
    296300uspace/drv/nic/e1k/e1k
     
    318322uspace/lib/c/arch/amd64/include/libarch/fibril_context.h
    319323uspace/lib/c/arch/amd64/include/libarch/istate_struct.h
     324uspace/lib/c/arch/arm32/_link-dlexe.ld
     325uspace/lib/c/arch/arm32/_link-loader.ld
     326uspace/lib/c/arch/arm32/_link-shlib.ld
     327uspace/lib/c/arch/arm32/_link.ld
    320328uspace/lib/c/arch/arm32/include/libarch/fibril_context.h
    321329uspace/lib/c/arch/arm32/include/libarch/istate_struct.h
     
    376384uspace/srv/hw/irc/apic/apic
    377385uspace/srv/hw/irc/i8259/i8259
    378 uspace/srv/hw/irc/icp-ic/icp-ic
    379386uspace/srv/hw/irc/obio/obio
    380387uspace/srv/klog/klog
  • boot/arch/arm32/Makefile.inc

    r1974f56a ra416d070  
    7676                char/atkbd \
    7777                char/ps2mouse \
     78                intctl/icp-ic \
    7879                platform/icp
    79         RD_SRVS_ESSENTIAL += \
    80                 $(USPACE_PATH)/srv/hw/irc/icp-ic/icp-ic
    8180endif
    8281
  • uspace/Makefile

    r1974f56a ra416d070  
    137137        srv/hw/irc/apic \
    138138        srv/hw/irc/i8259 \
    139         srv/hw/irc/icp-ic \
    140139        srv/hw/irc/obio \
    141140        srv/hid/rfb \
     
    170169        drv/fb/amdm37x_dispc \
    171170        drv/fb/kfb \
     171        drv/intctl/icp-ic \
    172172        drv/nic/ne2k \
    173173        drv/nic/e1k \
  • uspace/app/init/init.c

    r1974f56a ra416d070  
    340340        srv_start("/srv/apic");
    341341        srv_start("/srv/i8259");
    342         srv_start("/srv/icp-ic");
    343342        srv_start("/srv/obio");
    344343        srv_start("/srv/s3c24xx_uart");
  • uspace/drv/intctl/icp-ic/Makefile

    r1974f56a ra416d070  
    2727#
    2828
    29 USPACE_PREFIX = ../../../..
     29USPACE_PREFIX = ../../..
     30LIBS = $(LIBDRV_PREFIX)/libdrv.a
     31EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
    3032BINARY = icp-ic
    3133
    3234SOURCES = \
    33         icp-ic.c
     35        icp-ic.c \
     36        main.c
    3437
    3538include $(USPACE_PREFIX)/Makefile.common
  • uspace/drv/intctl/icp-ic/icp-ic.c

    r1974f56a ra416d070  
    3333/**
    3434 * @file icp-ic.c
    35  * @brief IntegratorCP interrupt controller driver.
     35 * @brief IntegratorCP interrupt controller driver
    3636 */
    3737
     
    3939#include <bitops.h>
    4040#include <ddi.h>
     41#include <ddf/log.h>
    4142#include <errno.h>
    42 #include <io/log.h>
    4343#include <ipc/irc.h>
    4444#include <loc.h>
    45 #include <sysinfo.h>
    46 #include <stdio.h>
    4745#include <stdint.h>
    48 #include <str.h>
    4946
     47#include "icp-ic.h"
    5048#include "icp-ic_hw.h"
    5149
    52 #define NAME  "icp-ic"
    53 
    5450enum {
    55         icp_pic_base = 0x14000000,
    5651        icpic_max_irq = 32
    5752};
    5853
    59 static icpic_regs_t *icpic_regs;
    60 
    61 static int icpic_enable_irq(sysarg_t irq)
     54static int icpic_enable_irq(icpic_t *icpic, sysarg_t irq)
    6255{
    6356        if (irq > icpic_max_irq)
    6457                return EINVAL;
    6558
    66         log_msg(LOG_DEFAULT, LVL_NOTE, "Enable IRQ %zu", irq);
     59        ddf_msg(LVL_NOTE, "Enable IRQ %zu", irq);
    6760
    68         pio_write_32(&icpic_regs->irq_enableset, BIT_V(uint32_t, irq));
     61        pio_write_32(&icpic->regs->irq_enableset, BIT_V(uint32_t, irq));
    6962        return EOK;
    7063}
    7164
    72 /** Handle one connection to i8259.
     65/** Client connection handler.
    7366 *
    7467 * @param iid   Hash of the request that opened the connection.
     
    8073        ipc_callid_t callid;
    8174        ipc_call_t call;
     75        icpic_t *icpic;
    8276
    8377        /*
     
    8579         */
    8680        async_answer_0(iid, EOK);
     81
     82        icpic = (icpic_t *)ddf_dev_data_get(ddf_fun_get_dev((ddf_fun_t *)arg));
    8783
    8884        while (true) {
     
    9894                case IRC_ENABLE_INTERRUPT:
    9995                        async_answer_0(callid,
    100                             icpic_enable_irq(IPC_GET_ARG1(call)));
     96                            icpic_enable_irq(icpic, IPC_GET_ARG1(call)));
    10197                        break;
    10298                case IRC_DISABLE_INTERRUPT:
     
    115111}
    116112
    117 static int icpic_init(void)
     113/** Add icp-ic device. */
     114int icpic_add(icpic_t *icpic, icpic_res_t *res)
    118115{
    119         char *platform = NULL;
    120         char *pstr = NULL;
    121         size_t platform_size;
    122         category_id_t irc_cat;
    123         service_id_t svc_id;
     116        ddf_fun_t *fun_a = NULL;
    124117        void *regs;
    125118        int rc;
    126119
    127         platform = sysinfo_get_data("platform", &platform_size);
    128         if (platform == NULL) {
    129                 log_msg(LOG_DEFAULT, LVL_ERROR, "Error getting platform type.");
    130                 rc = ENOENT;
     120        rc = pio_enable((void *)res->base, sizeof(icpic_regs_t), &regs);
     121        if (rc != EOK) {
     122                ddf_msg(LVL_ERROR, "Error enabling PIO");
    131123                goto error;
    132124        }
    133125
    134         pstr = str_ndup(platform, platform_size);
    135         if (pstr == NULL) {
    136                 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory.");
     126        icpic->regs = (icpic_regs_t *)regs;
     127
     128        fun_a = ddf_fun_create(icpic->dev, fun_exposed, "a");
     129        if (fun_a == NULL) {
     130                ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
    137131                rc = ENOMEM;
    138132                goto error;
    139133        }
    140134
    141         if (str_cmp(pstr, "integratorcp") != 0) {
    142                 log_msg(LOG_DEFAULT, LVL_ERROR, "Platform '%s' is not 'integratorcp'.",
     135        ddf_fun_set_conn_handler(fun_a, icpic_connection);
    143136
    144                     pstr);
    145                 rc = ENOENT;
     137        rc = ddf_fun_bind(fun_a);
     138        if (rc != EOK) {
     139                ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc);
    146140                goto error;
    147141        }
    148142
    149         rc = pio_enable((void *)icp_pic_base, sizeof(icpic_regs_t), &regs);
    150         if (rc != EOK) {
    151                 log_msg(LOG_DEFAULT, LVL_ERROR, "Error enabling PIO");
     143        rc = ddf_fun_add_to_category(fun_a, "irc");
     144        if (rc != EOK)
    152145                goto error;
    153         }
    154146
    155         icpic_regs = (icpic_regs_t *)regs;
    156 
    157         async_set_fallback_port_handler(icpic_connection, NULL);
    158 
    159         rc = loc_server_register(NAME);
    160         if (rc != EOK) {
    161                 printf("%s: Failed registering server. (%d)\n", NAME, rc);
    162                 return rc;
    163         }
    164 
    165         rc = loc_service_register("irc/" NAME, &svc_id);
    166         if (rc != EOK) {
    167                 printf("%s: Failed registering service. (%d)\n", NAME, rc);
    168                 return rc;
    169         }
    170 
    171         rc = loc_category_get_id("irc", &irc_cat, IPC_FLAG_BLOCKING);
    172         if (rc != EOK) {
    173                 printf("%s: Failed resolving category 'iplink' (%d).\n", NAME,
    174                     rc);
    175                 goto error;
    176         }
    177 
    178         rc = loc_service_add_to_cat(svc_id, irc_cat);
    179         if (rc != EOK) {
    180                 printf("%s: Failed adding service to category (%d).\n", NAME,
    181                     rc);
    182                 goto error;
    183         }
    184 
    185         free(platform);
    186         free(pstr);
    187147        return EOK;
    188148error:
    189         free(platform);
    190         free(pstr);
     149        if (fun_a != NULL)
     150                ddf_fun_destroy(fun_a);
    191151        return rc;
    192152}
    193153
    194 int main(int argc, char **argv)
     154/** Remove icp-ic device */
     155int icpic_remove(icpic_t *icpic)
    195156{
    196         int rc;
     157        return ENOTSUP;
     158}
    197159
    198         printf("%s: HelenOS IntegratorCP interrupt controller driver\n", NAME);
    199 
    200         rc = log_init(NAME);
    201         if (rc != EOK) {
    202                 printf(NAME ": Error connecting logging service.");
    203                 return 1;
    204         }
    205 
    206         if (icpic_init() != EOK)
    207                 return -1;
    208 
    209         log_msg(LOG_DEFAULT, LVL_NOTE, "%s: Accepting connections\n", NAME);
    210         task_retval(0);
    211         async_manager();
    212 
    213         /* Not reached */
    214         return 0;
     160/** icp-ic device gone */
     161int icpic_gone(icpic_t *icpic)
     162{
     163        return ENOTSUP;
    215164}
    216165
  • uspace/drv/platform/icp/icp.c

    r1974f56a ra416d070  
    5454        icp_kbd_irq = 3,
    5555        icp_mouse_base = 0x19000000,
    56         icp_mouse_irq = 4
     56        icp_mouse_irq = 4,
     57        icp_ic_base = 0x14000000
    5758};
    5859
     
    108109};
    109110
     111static hw_resource_t icp_ic_res[] = {
     112        {
     113                .type = MEM_RANGE,
     114                .res.mem_range = {
     115                        .address = icp_ic_base,
     116                        .size = 40,
     117                        .relative = false,
     118                        .endianness = LITTLE_ENDIAN
     119                }
     120        }
     121};
     122
    110123static pio_window_t icp_pio_window = {
    111124        .mem = {
     
    126139                sizeof(icp_mouse_res) / sizeof(icp_mouse_res[0]),
    127140                icp_mouse_res
     141        },
     142};
     143
     144static icp_fun_t icp_ic_fun_proto = {
     145        .hw_resources = {
     146                sizeof(icp_ic_res) / sizeof(icp_ic_res[0]),
     147                icp_ic_res
    128148        },
    129149};
     
    267287                return rc;
    268288
     289        rc = icp_add_fun(dev, "intctl", "integratorcp/intctl",
     290            &icp_ic_fun_proto);
     291        if (rc != EOK)
     292                return rc;
     293
    269294        return EOK;
    270295}
Note: See TracChangeset for help on using the changeset viewer.