Changeset 95c675b in mainline for uspace/drv/intctl/icp-ic/icp-ic.c
- Timestamp:
- 2017-10-17T13:11:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 60af4cdb
- Parents:
- dbf32b1 (diff), a416d070 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/intctl/icp-ic/icp-ic.c
rdbf32b1 r95c675b 33 33 /** 34 34 * @file icp-ic.c 35 * @brief IntegratorCP interrupt controller driver .35 * @brief IntegratorCP interrupt controller driver 36 36 */ 37 37 … … 39 39 #include <bitops.h> 40 40 #include <ddi.h> 41 #include <ddf/log.h> 41 42 #include <errno.h> 42 #include <io/log.h>43 #include <ipc/services.h>44 43 #include <ipc/irc.h> 45 #include <ns.h> 46 #include <sysinfo.h> 47 #include <stdio.h> 44 #include <loc.h> 48 45 #include <stdint.h> 49 #include <str.h>50 46 47 #include "icp-ic.h" 51 48 #include "icp-ic_hw.h" 52 49 53 #define NAME "icp-ic"54 55 50 enum { 56 icp_pic_base = 0x14000000,57 51 icpic_max_irq = 32 58 52 }; 59 53 60 static icpic_regs_t *icpic_regs; 61 62 static int icpic_enable_irq(sysarg_t irq) 54 static int icpic_enable_irq(icpic_t *icpic, sysarg_t irq) 63 55 { 64 56 if (irq > icpic_max_irq) 65 57 return EINVAL; 66 58 67 log_msg(LOG_DEFAULT, LVL_NOTE, "Enable IRQ %d", irq);59 ddf_msg(LVL_NOTE, "Enable IRQ %zu", irq); 68 60 69 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)); 70 62 return EOK; 71 63 } 72 64 73 /** Handle one connection to i8259.65 /** Client connection handler. 74 66 * 75 67 * @param iid Hash of the request that opened the connection. … … 81 73 ipc_callid_t callid; 82 74 ipc_call_t call; 75 icpic_t *icpic; 83 76 84 77 /* … … 86 79 */ 87 80 async_answer_0(iid, EOK); 81 82 icpic = (icpic_t *)ddf_dev_data_get(ddf_fun_get_dev((ddf_fun_t *)arg)); 88 83 89 84 while (true) { … … 99 94 case IRC_ENABLE_INTERRUPT: 100 95 async_answer_0(callid, 101 icpic_enable_irq(IPC_GET_ARG1(call))); 96 icpic_enable_irq(icpic, IPC_GET_ARG1(call))); 97 break; 98 case IRC_DISABLE_INTERRUPT: 99 /* XXX TODO */ 100 async_answer_0(callid, EOK); 102 101 break; 103 102 case IRC_CLEAR_INTERRUPT: … … 112 111 } 113 112 114 static int icpic_init(void) 113 /** Add icp-ic device. */ 114 int icpic_add(icpic_t *icpic, icpic_res_t *res) 115 115 { 116 char *platform = NULL; 117 char *pstr = NULL; 118 size_t platform_size; 116 ddf_fun_t *fun_a = NULL; 119 117 void *regs; 120 118 int rc; 121 119 122 platform = sysinfo_get_data("platform", &platform_size); 123 if (platform == NULL) { 124 log_msg(LOG_DEFAULT, LVL_ERROR, "Error getting platform type."); 125 rc = ENOENT; 120 rc = pio_enable((void *)res->base, sizeof(icpic_regs_t), ®s); 121 if (rc != EOK) { 122 ddf_msg(LVL_ERROR, "Error enabling PIO"); 126 123 goto error; 127 124 } 128 125 129 pstr = str_ndup(platform, platform_size); 130 if (pstr == NULL) { 131 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'."); 132 131 rc = ENOMEM; 133 132 goto error; 134 133 } 135 134 136 if (str_cmp(pstr, "integratorcp") != 0) { 137 log_msg(LOG_DEFAULT, LVL_ERROR, "Platform '%s' is not 'integratorcp'.", 135 ddf_fun_set_conn_handler(fun_a, icpic_connection); 138 136 139 pstr); 140 rc = ENOENT; 137 rc = ddf_fun_bind(fun_a); 138 if (rc != EOK) { 139 ddf_msg(LVL_ERROR, "Failed binding function 'a'. (%d)", rc); 141 140 goto error; 142 141 } 143 142 144 rc = pio_enable((void *)icp_pic_base, sizeof(icpic_regs_t), ®s); 145 if (rc != EOK) { 146 log_msg(LOG_DEFAULT, LVL_ERROR, "Error enabling PIO"); 143 rc = ddf_fun_add_to_category(fun_a, "irc"); 144 if (rc != EOK) 147 145 goto error; 148 }149 146 150 icpic_regs = (icpic_regs_t *)regs;151 152 async_set_fallback_port_handler(icpic_connection, NULL);153 service_register(SERVICE_IRC);154 155 free(platform);156 free(pstr);157 147 return EOK; 158 148 error: 159 free(platform);160 free(pstr);149 if (fun_a != NULL) 150 ddf_fun_destroy(fun_a); 161 151 return rc; 162 152 } 163 153 164 int main(int argc, char **argv) 154 /** Remove icp-ic device */ 155 int icpic_remove(icpic_t *icpic) 165 156 { 166 int rc; 157 return ENOTSUP; 158 } 167 159 168 printf("%s: HelenOS IntegratorCP interrupt controller driver\n", NAME); 169 170 rc = log_init(NAME); 171 if (rc != EOK) { 172 printf(NAME ": Error connecting logging service."); 173 return 1; 174 } 175 176 if (icpic_init() != EOK) 177 return -1; 178 179 log_msg(LOG_DEFAULT, LVL_NOTE, "%s: Accepting connections\n", NAME); 180 task_retval(0); 181 async_manager(); 182 183 /* Not reached */ 184 return 0; 160 /** icp-ic device gone */ 161 int icpic_gone(icpic_t *icpic) 162 { 163 return ENOTSUP; 185 164 } 186 165
Note:
See TracChangeset
for help on using the changeset viewer.