Changeset 1b78a7c1 in mainline
- Timestamp:
- 2017-07-24T13:36:09Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7dee9b7
- Parents:
- 2fa43d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/commands.c
r2fa43d1 r1b78a7c1 43 43 #include "hw_struct/context.h" 44 44 #include "hw_struct/trb.h" 45 46 #define TRB_SET_TCS(trb, tcs) (trb).control |= host2xhci(32, ((tcs &0x1) << 9)) 47 #define TRB_SET_TYPE(trb, type) (trb).control |= host2xhci(32, (type) << 10) 48 #define TRB_SET_EP(trb, ep) (trb).control |= host2xhci(32, ((ep) & 0x5) << 16) 49 #define TRB_SET_SUSP(trb, susp) (trb).control |= host2xhci(32, ((susp) & 0x1) << 23) 50 #define TRB_SET_SLOT(trb, slot) (trb).control |= host2xhci(32, (slot) << 24) 51 52 #define TRB_SET_ICTX(trb, phys) (trb).parameter |= host2xhci(32, phys_addr & (~0xF)) 53 54 #define TRB_GET_CODE(trb) XHCI_DWORD_EXTRACT((trb).status, 31, 24) 55 #define TRB_GET_SLOT(trb) XHCI_DWORD_EXTRACT((trb).control, 31, 24) 56 #define TRB_GET_PHYS(trb) (XHCI_QWORD_EXTRACT((trb).parameter, 63, 4) << 4) 45 57 46 58 int xhci_init_commands(xhci_hc_t *hc) … … 254 266 memset(&trb, 0, sizeof(trb)); 255 267 256 trb.control = host2xhci(32, XHCI_TRB_TYPE_NO_OP_CMD << 10);268 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_NO_OP_CMD); 257 269 258 270 cmd = add_cmd(hc, cmd); … … 268 280 memset(&trb, 0, sizeof(trb)); 269 281 270 trb.control = host2xhci(32, XHCI_TRB_TYPE_ENABLE_SLOT_CMD << 10);282 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_ENABLE_SLOT_CMD); 271 283 trb.control |= host2xhci(32, XHCI_REG_RD(hc->xecp, XHCI_EC_SP_SLOT_TYPE) << 16); 272 284 … … 284 296 memset(&trb, 0, sizeof(trb)); 285 297 286 trb.control = host2xhci(32, XHCI_TRB_TYPE_DISABLE_SLOT_CMD << 10);287 trb.control |= host2xhci(32, cmd->slot_id << 24);298 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_DISABLE_SLOT_CMD); 299 TRB_SET_SLOT(trb, cmd->slot_id); 288 300 289 301 add_cmd(hc, cmd); … … 308 320 309 321 uint64_t phys_addr = (uint64_t) addr_to_phys(cmd->ictx); 310 trb.parameter = host2xhci(32, phys_addr & (~0xF));322 TRB_SET_ICTX(trb, phys_addr); 311 323 312 324 /** … … 317 329 * that require their device descriptor to be read before such request. 318 330 */ 319 trb.control = host2xhci(32, XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD << 10);320 trb.control |= host2xhci(32, cmd->slot_id << 24);331 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_ADDRESS_DEVICE_CMD); 332 TRB_SET_SLOT(trb, cmd->slot_id); 321 333 322 334 cmd = add_cmd(hc, cmd); … … 335 347 336 348 uint64_t phys_addr = (uint64_t) addr_to_phys(cmd->ictx); 337 trb.parameter = host2xhci(32, phys_addr & (~0xF));338 339 trb.control = host2xhci(32, XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD << 10);340 trb.control |= host2xhci(32, cmd->slot_id << 24);349 TRB_SET_ICTX(trb, phys_addr); 350 351 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_CONFIGURE_ENDPOINT_CMD); 352 TRB_SET_SLOT(trb, cmd->slot_id); 341 353 342 354 cmd = add_cmd(hc, cmd); … … 361 373 362 374 uint64_t phys_addr = (uint64_t) addr_to_phys(cmd->ictx); 363 trb.parameter = host2xhci(32, phys_addr & (~0xF));364 365 trb.control = host2xhci(32, XHCI_TRB_TYPE_EVALUATE_CONTEXT_CMD << 10);366 trb.control |= host2xhci(32, cmd->slot_id << 24);375 TRB_SET_ICTX(trb, phys_addr); 376 377 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_EVALUATE_CONTEXT_CMD); 378 TRB_SET_SLOT(trb, cmd->slot_id); 367 379 368 380 cmd = add_cmd(hc, cmd); … … 383 395 memset(&trb, 0, sizeof(trb)); 384 396 385 trb.control = host2xhci(32, XHCI_TRB_TYPE_RESET_ENDPOINT_CMD << 10);386 trb.control |= host2xhci(32, (tcs & 0x1) << 9);387 trb.control |= host2xhci(32, (ep_id & 0x5) << 16);388 trb.control |= host2xhci(32, cmd->slot_id << 24);397 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_RESET_ENDPOINT_CMD); 398 TRB_SET_TCS(trb, tcs); 399 TRB_SET_EP(trb, ep_id); 400 TRB_SET_SLOT(trb, cmd->slot_id); 389 401 390 402 return enqueue_trb(hc, &trb, 0, 0); … … 399 411 memset(&trb, 0, sizeof(trb)); 400 412 401 trb.control = host2xhci(32, XHCI_TRB_TYPE_STOP_ENDPOINT_CMD << 10);402 trb.control |= host2xhci(32, (ep_id & 0x5) << 16);403 trb.control |= host2xhci(32, (susp & 0x1) << 23);404 trb.control |= host2xhci(32, cmd->slot_id << 24);413 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_STOP_ENDPOINT_CMD); 414 TRB_SET_EP(trb, ep_id); 415 TRB_SET_SUSP(trb, susp); 416 TRB_SET_SLOT(trb, cmd->slot_id); 405 417 406 418 cmd = add_cmd(hc, cmd); … … 417 429 memset(&trb, 0, sizeof(trb)); 418 430 419 trb.control = host2xhci(32, XHCI_TRB_TYPE_RESET_DEVICE_CMD << 10);420 trb.control |= host2xhci(32, cmd->slot_id << 24);431 TRB_SET_TYPE(trb, XHCI_TRB_TYPE_RESET_DEVICE_CMD); 432 TRB_SET_SLOT(trb, cmd->slot_id); 421 433 422 434 return enqueue_trb(hc, &trb, 0, 0); … … 432 444 433 445 int code; 434 uint32_t slot_id;435 446 uint64_t phys; 436 447 xhci_cmd_t *command; 437 448 xhci_trb_t *command_trb; 438 449 439 code = XHCI_DWORD_EXTRACT(trb->status, 31, 24);440 phys = XHCI_QWORD_EXTRACT(trb->parameter, 63, 4) << 4;450 code = TRB_GET_CODE(*trb); 451 phys = TRB_GET_PHYS(*trb);; 441 452 command = get_command(hc, phys); 442 453 if (command == NULL) { … … 451 462 452 463 command_trb = command->trb; 453 454 464 command->status = code; 455 456 slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24); 457 command->slot_id = slot_id; 465 command->slot_id = TRB_GET_SLOT(*trb); 458 466 459 467 usb_log_debug2("Completed command trb: %s", xhci_trb_str_type(TRB_TYPE(*command_trb)));
Note:
See TracChangeset
for help on using the changeset viewer.