Changeset b25970f in mainline for uspace/drv/platform/pc/pc.c
- Timestamp:
- 2018-10-29T14:11:39Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 94ab1fe
- Parents:
- 184f2f8a
- git-author:
- Jiri Svoboda <jiri@…> (2018-10-28 22:10:25)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-10-29 14:11:39)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/platform/pc/pc.c
r184f2f8a rb25970f 1 1 /* 2 * Copyright (c) 2018 Jiri Svoboda 2 3 * Copyright (c) 2010 Lenka Trochtova 3 4 * All rights reserved. … … 93 94 }; 94 95 95 static pc_fun_t pci_data = {96 static pc_fun_t sys_data = { 96 97 .hw_resources = { 97 98 sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]), … … 151 152 static ddf_dev_ops_t pc_fun_ops; 152 153 153 static bool 154 pc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id, 155 pc_fun_t *fun_proto) 156 { 157 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 158 154 static errno_t pc_add_sysbus(ddf_dev_t *dev) 155 { 159 156 ddf_fun_t *fnode = NULL; 160 157 errno_t rc; 161 158 159 ddf_msg(LVL_DEBUG, "Adding system bus."); 160 162 161 /* Create new device. */ 163 fnode = ddf_fun_create(dev, fun_inner, name); 164 if (fnode == NULL) 165 goto failure; 162 fnode = ddf_fun_create(dev, fun_inner, "sys"); 163 if (fnode == NULL) { 164 rc = ENOMEM; 165 goto error; 166 } 166 167 167 168 pc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(pc_fun_t)); 168 *fun = *fun_proto;169 170 /* Add match ID */171 rc = ddf_fun_add_match_id(fnode, str_match_id, 100);169 *fun = sys_data; 170 171 /* Add match IDs */ 172 rc = ddf_fun_add_match_id(fnode, "intel_pci", 100); 172 173 if (rc != EOK) 173 goto failure; 174 goto error; 175 176 rc = ddf_fun_add_match_id(fnode, "isa", 10); 177 if (rc != EOK) 178 goto error; 174 179 175 180 /* Set provided operations to the device. */ … … 177 182 178 183 /* Register function. */ 179 if (ddf_fun_bind(fnode) != EOK) { 180 ddf_msg(LVL_ERROR, "Failed binding function %s.", name); 181 goto failure; 182 } 183 184 return true; 185 186 failure: 184 rc = ddf_fun_bind(fnode); 185 if (rc != EOK) { 186 ddf_msg(LVL_ERROR, "Failed binding system bus function."); 187 goto error; 188 } 189 190 return EOK; 191 192 error: 187 193 if (fnode != NULL) 188 194 ddf_fun_destroy(fnode); 189 195 190 ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name); 191 192 return false; 193 } 194 195 static bool pc_add_functions(ddf_dev_t *dev) 196 { 197 return pc_add_fun(dev, "pci0", "intel_pci", &pci_data); 196 ddf_msg(LVL_ERROR, "Failed adding system bus."); 197 return rc; 198 } 199 200 static errno_t pc_add_functions(ddf_dev_t *dev) 201 { 202 errno_t rc; 203 204 rc = pc_add_sysbus(dev); 205 if (rc != EOK) 206 return rc; 207 208 return EOK; 198 209 } 199 210 … … 206 217 static errno_t pc_dev_add(ddf_dev_t *dev) 207 218 { 219 errno_t rc; 220 208 221 ddf_msg(LVL_DEBUG, "pc_dev_add, device handle = %d", 209 222 (int)ddf_dev_get_handle(dev)); 210 223 211 224 /* Register functions. */ 212 if (!pc_add_functions(dev)) { 225 rc = pc_add_functions(dev); 226 if (rc != EOK) { 213 227 ddf_msg(LVL_ERROR, "Failed to add functions for PC platform."); 228 return rc; 214 229 } 215 230
Note:
See TracChangeset
for help on using the changeset viewer.