Changeset 59c0f478 in mainline for uspace/drv/block/isa-ide/main.c
- Timestamp:
- 2024-05-16T18:20:35Z (9 months ago)
- Branches:
- master
- Children:
- 646849b3
- Parents:
- 2791fbb7
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/isa-ide/main.c
r2791fbb7 r59c0f478 27 27 */ 28 28 29 /** @addtogroup ata_bd29 /** @addtogroup isa-ide 30 30 * @{ 31 31 */ … … 42 42 #include <device/hw_res_parsed.h> 43 43 44 #include " ata_bd.h"44 #include "isa-ide.h" 45 45 #include "main.h" 46 46 47 static errno_t ata_dev_add(ddf_dev_t *dev);48 static errno_t ata_dev_remove(ddf_dev_t *dev);49 static errno_t ata_dev_gone(ddf_dev_t *dev);50 static errno_t ata_fun_online(ddf_fun_t *fun);51 static errno_t ata_fun_offline(ddf_fun_t *fun);52 53 static void ata_bd_connection(ipc_call_t *, void *);47 static errno_t isa_ide_dev_add(ddf_dev_t *dev); 48 static errno_t isa_ide_dev_remove(ddf_dev_t *dev); 49 static errno_t isa_ide_dev_gone(ddf_dev_t *dev); 50 static errno_t isa_ide_fun_online(ddf_fun_t *fun); 51 static errno_t isa_ide_fun_offline(ddf_fun_t *fun); 52 53 static void isa_ide_connection(ipc_call_t *, void *); 54 54 55 55 static driver_ops_t driver_ops = { 56 .dev_add = & ata_dev_add,57 .dev_remove = & ata_dev_remove,58 .dev_gone = & ata_dev_gone,59 .fun_online = & ata_fun_online,60 .fun_offline = & ata_fun_offline56 .dev_add = &isa_ide_dev_add, 57 .dev_remove = &isa_ide_dev_remove, 58 .dev_gone = &isa_ide_dev_gone, 59 .fun_online = &isa_ide_fun_online, 60 .fun_offline = &isa_ide_fun_offline 61 61 }; 62 62 63 static driver_t ata_driver = {63 static driver_t isa_ide_driver = { 64 64 .name = NAME, 65 65 .driver_ops = &driver_ops 66 66 }; 67 67 68 static errno_t ata_get_res(ddf_dev_t *dev, ata_hwres_t *ata_res)68 static errno_t ata_get_res(ddf_dev_t *dev, isa_ide_hwres_t *ata_res) 69 69 { 70 70 async_sess_t *parent_sess; … … 121 121 * @return EOK on success or an error code. 122 122 */ 123 static errno_t ata_dev_add(ddf_dev_t *dev)124 { 125 ata_ctrl_t *ctrl;126 ata_hwres_t res;123 static errno_t isa_ide_dev_add(ddf_dev_t *dev) 124 { 125 isa_ide_ctrl_t *ctrl; 126 isa_ide_hwres_t res; 127 127 errno_t rc; 128 128 … … 133 133 } 134 134 135 ctrl = ddf_dev_data_alloc(dev, sizeof( ata_ctrl_t));135 ctrl = ddf_dev_data_alloc(dev, sizeof(isa_ide_ctrl_t)); 136 136 if (ctrl == NULL) { 137 137 ddf_msg(LVL_ERROR, "Failed allocating soft state."); … … 142 142 ctrl->dev = dev; 143 143 144 rc = ata_ctrl_init(ctrl, &res);144 rc = isa_ide_ctrl_init(ctrl, &res); 145 145 if (rc == ENOENT) 146 146 goto error; … … 157 157 } 158 158 159 static char * ata_fun_name(unsigned idx)159 static char *isa_ide_fun_name(unsigned idx) 160 160 { 161 161 char *fun_name; … … 167 167 } 168 168 169 errno_t ata_fun_create(ata_ctrl_t *ctrl, unsigned idx, void *charg)169 errno_t isa_ide_fun_create(isa_ide_ctrl_t *ctrl, unsigned idx, void *charg) 170 170 { 171 171 errno_t rc; 172 172 char *fun_name = NULL; 173 173 ddf_fun_t *fun = NULL; 174 ata_fun_t *afun = NULL;174 isa_ide_fun_t *ifun = NULL; 175 175 bool bound = false; 176 176 177 fun_name = ata_fun_name(idx);177 fun_name = isa_ide_fun_name(idx); 178 178 if (fun_name == NULL) { 179 179 ddf_msg(LVL_ERROR, "Out of memory."); … … 190 190 191 191 /* Allocate soft state */ 192 afun = ddf_fun_data_alloc(fun, sizeof(ata_fun_t));193 if ( afun == NULL) {192 ifun = ddf_fun_data_alloc(fun, sizeof(isa_ide_fun_t)); 193 if (ifun == NULL) { 194 194 ddf_msg(LVL_ERROR, "Failed allocating softstate."); 195 195 rc = ENOMEM; … … 197 197 } 198 198 199 afun->fun = fun;200 afun->charg = charg;199 ifun->fun = fun; 200 ifun->charg = charg; 201 201 202 202 /* Set up a connection handler. */ 203 ddf_fun_set_conn_handler(fun, ata_bd_connection);203 ddf_fun_set_conn_handler(fun, isa_ide_connection); 204 204 205 205 rc = ddf_fun_bind(fun); … … 232 232 } 233 233 234 errno_t ata_fun_remove(ata_ctrl_t *ctrl, unsigned idx)234 errno_t isa_ide_fun_remove(isa_ide_ctrl_t *ctrl, unsigned idx) 235 235 { 236 236 errno_t rc; 237 237 char *fun_name; 238 ata_fun_t *afun = ctrl->fun[idx];239 240 fun_name = ata_fun_name(idx);238 isa_ide_fun_t *ifun = ctrl->fun[idx]; 239 240 fun_name = isa_ide_fun_name(idx); 241 241 if (fun_name == NULL) { 242 242 ddf_msg(LVL_ERROR, "Out of memory."); … … 245 245 } 246 246 247 ddf_msg(LVL_DEBUG, " ata_fun_remove(%p, '%s')", afun, fun_name);248 rc = ddf_fun_offline( afun->fun);247 ddf_msg(LVL_DEBUG, "isa_ide_fun_remove(%p, '%s')", ifun, fun_name); 248 rc = ddf_fun_offline(ifun->fun); 249 249 if (rc != EOK) { 250 250 ddf_msg(LVL_ERROR, "Error offlining function '%s'.", fun_name); … … 252 252 } 253 253 254 rc = ddf_fun_unbind( afun->fun);254 rc = ddf_fun_unbind(ifun->fun); 255 255 if (rc != EOK) { 256 256 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 258 258 } 259 259 260 ddf_fun_destroy( afun->fun);260 ddf_fun_destroy(ifun->fun); 261 261 free(fun_name); 262 262 return EOK; … … 267 267 } 268 268 269 errno_t ata_fun_unbind(ata_ctrl_t *ctrl, unsigned idx)269 errno_t isa_ide_fun_unbind(isa_ide_ctrl_t *ctrl, unsigned idx) 270 270 { 271 271 errno_t rc; 272 272 char *fun_name; 273 ata_fun_t *afun = ctrl->fun[idx];274 275 fun_name = ata_fun_name(idx);273 isa_ide_fun_t *ifun = ctrl->fun[idx]; 274 275 fun_name = isa_ide_fun_name(idx); 276 276 if (fun_name == NULL) { 277 277 ddf_msg(LVL_ERROR, "Out of memory."); … … 280 280 } 281 281 282 ddf_msg(LVL_DEBUG, " ata_fun_unbind(%p, '%s')", afun, fun_name);283 rc = ddf_fun_unbind( afun->fun);282 ddf_msg(LVL_DEBUG, "isa_ide_fun_unbind(%p, '%s')", ifun, fun_name); 283 rc = ddf_fun_unbind(ifun->fun); 284 284 if (rc != EOK) { 285 285 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", fun_name); … … 287 287 } 288 288 289 ddf_fun_destroy( afun->fun);289 ddf_fun_destroy(ifun->fun); 290 290 free(fun_name); 291 291 return EOK; … … 296 296 } 297 297 298 static errno_t ata_dev_remove(ddf_dev_t *dev)299 { 300 ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);301 302 ddf_msg(LVL_DEBUG, " ata_dev_remove(%p)", dev);303 304 return ata_ctrl_remove(ctrl);305 } 306 307 static errno_t ata_dev_gone(ddf_dev_t *dev)308 { 309 ata_ctrl_t *ctrl = (ata_ctrl_t *)ddf_dev_data_get(dev);310 311 ddf_msg(LVL_DEBUG, " ata_dev_gone(%p)", dev);312 313 return ata_ctrl_gone(ctrl);314 } 315 316 static errno_t ata_fun_online(ddf_fun_t *fun)317 { 318 ddf_msg(LVL_DEBUG, " ata_fun_online()");298 static errno_t isa_ide_dev_remove(ddf_dev_t *dev) 299 { 300 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 301 302 ddf_msg(LVL_DEBUG, "isa_ide_dev_remove(%p)", dev); 303 304 return isa_ide_ctrl_remove(ctrl); 305 } 306 307 static errno_t isa_ide_dev_gone(ddf_dev_t *dev) 308 { 309 isa_ide_ctrl_t *ctrl = (isa_ide_ctrl_t *)ddf_dev_data_get(dev); 310 311 ddf_msg(LVL_DEBUG, "isa_ide_dev_gone(%p)", dev); 312 313 return isa_ide_ctrl_gone(ctrl); 314 } 315 316 static errno_t isa_ide_fun_online(ddf_fun_t *fun) 317 { 318 ddf_msg(LVL_DEBUG, "isa_ide_fun_online()"); 319 319 return ddf_fun_online(fun); 320 320 } 321 321 322 static errno_t ata_fun_offline(ddf_fun_t *fun)323 { 324 ddf_msg(LVL_DEBUG, " ata_fun_offline()");322 static errno_t isa_ide_fun_offline(ddf_fun_t *fun) 323 { 324 ddf_msg(LVL_DEBUG, "isa_ide_fun_offline()"); 325 325 return ddf_fun_offline(fun); 326 326 } 327 327 328 static void ata_bd_connection(ipc_call_t *icall, void *arg)329 { 330 ata_fun_t *afun;331 332 afun = (ata_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg);333 ata_connection(icall, afun->charg);328 static void isa_ide_connection(ipc_call_t *icall, void *arg) 329 { 330 isa_ide_fun_t *ifun; 331 332 ifun = (isa_ide_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg); 333 ata_connection(icall, ifun->charg); 334 334 } 335 335 336 336 int main(int argc, char *argv[]) 337 337 { 338 printf(NAME ": HelenOS ATA(PI)device driver\n");338 printf(NAME ": HelenOS ISA IDE device driver\n"); 339 339 ddf_log_init(NAME); 340 return ddf_driver_main(& ata_driver);340 return ddf_driver_main(&isa_ide_driver); 341 341 } 342 342
Note:
See TracChangeset
for help on using the changeset viewer.