1 /* 2 * dspbridge/mpu_api/inc/qosregistry.h 3 * 4 * DSP-BIOS Bridge driver support functions for TI OMAP processors. 5 * 6 * Copyright (C) 2007 Texas Instruments, Inc. 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU Lesser General Public License as published 10 * by the Free Software Foundation version 2.1 of the License. 11 * 12 * This program is distributed .as is. WITHOUT ANY WARRANTY of any kind, 13 * whether express or implied; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 */ 17 18 19 #ifndef __QOSTI_H__ 20 21 #define __QOSTI_H__ 22 23 #include <dbapi.h> 24 25 /* ============================================================================ 26 27 name TLoadMode 28 29 30 31 desc The node load mode for qos. 32 33 ============================================================================ */ 34 35 enum TLoadMode 36 { 37 38 EStaticLoad, 39 40 EDynamicLoad 41 }; 42 43 /* ============================================================================ 44 45 name CQosTI 46 47 48 49 desc An example class that uses the DSP BIOS/Bridge interfaces.and 50 51 demonstrates creating an xDAIS Socket Node on the DSP. It sends 52 53 messages and data buffers to the DSP, and then receives the qosd 54 55 data back from the DSP for display. 56 57 58 59 ============================================================================ 60 61 RHwaOmap iDsp ; 62 63 ============================================================================ 64 65 name TQosResourceID 66 67 68 69 desc List of available resource types 70 71 ============================================================================ 72 */ 73 74 typedef enum _QOSDATATYPE { 75 76 QOSDataType_Memory_DynLoad = 0, 77 78 QOSDataType_Memory_DynAlloc, 79 80 QOSDataType_Memory_Scratch, 81 82 QOSDataType_Processor_C55X, 83 84 QOSDataType_Processor_C6X, 85 86 QOSDataType_Peripheral_DMA, 87 88 QOSDataType_Stream, 89 90 QOSDataType_Component, 91 92 QOSDataType_Registry, 93 94 QOSDataType_DynDependentLibrary 95 } QOSDATATYPE; 96 97 #define QOS_USER_DATA_TYPE 0x80000000 /* Flag indicating a application-defined 98 data type ID */ 99 100 /* ============================================================================ 101 102 name QOSDATA 103 104 105 106 desc Generic data for resource management is described by the following 107 structure 108 109 ============================================================================ 110 */ 111 struct QOSDATA { 112 113 ULONG Id; 114 115 struct QOSDATA *Next; 116 117 ULONG(*TypeSpecific)(struct QOSDATA *DataObject, ULONG FunctionCode, 118 ULONG Parameter1); 119 /* ptr to type-specific func. */ 120 121 ULONG Size; /* size of data plus this header */ 122 123 char Data[]; 124 125 }; 126 127 // ============================================================================ 128 129 // name QOSFNTYPESPECIFIC 130 131 // 132 133 // desc Pointer to type-specific function handler for the data object 134 135 // ============================================================================ 136 137 typedef ULONG(*QOSFNTYPESPECIFIC)(struct QOSDATA *DataObject,ULONG FunctionCode, 138 ULONG Parameter1); 139 140 ULONG QOS_Memory_Scratch_FunctionHandler(struct QOSDATA *DataObject, 141 ULONG FunctionCode, ULONG Parameter1); 142 143 ULONG QOS_Memory_DynAlloc_FunctionHandler(struct QOSDATA *DataObject, 144 ULONG FunctionCode, ULONG Parameter1); 145 146 ULONG QOS_Memory_DynLoad_FunctionHandler(struct QOSDATA *DataObject, 147 ULONG FunctionCode, ULONG Parameter1); 148 149 ULONG QOS_Processor_FunctionHandler(struct QOSDATA *DataObject, 150 ULONG FunctionCode, ULONG Parameter1); 151 152 ULONG QOS_Resource_DefaultFunctionHandler(struct QOSDATA *DataObject, 153 ULONG FunctionCode, ULONG Parameter1); 154 155 ULONG QOS_Component_DefaultFunctionHandler(struct QOSDATA *DataObject, 156 ULONG FunctionCode, ULONG Parameter1); 157 158 ULONG QOS_DynDependentLibrary_FunctionHandler(struct QOSDATA *DataObject, 159 ULONG FunctionCode, ULONG Parameter1); 160 161 ULONG QOS_Registry_FunctionHandler(struct QOSDATA *DataObject, 162 ULONG FunctionCode, ULONG Parameter1); 163 164 /* ============================================================================ 165 166 name QOSREGISTRY 167 168 169 170 desc The QOSREGISTRY structure contains a list of all resources and 171 components in the system 172 173 174 ============================================================================ 175 */ 176 177 struct QOSREGISTRY { 178 179 struct QOSDATA data; 180 181 struct QOSDATA *ResourceRegistry; 182 183 struct QOSDATA *ComponentRegistry; 184 185 }; 186 187 // ============================================================================ 188 189 // name QOSRESOURCE_MEMORY 190 191 // 192 193 // desc System memory resources are characterized by the following structure 194 195 // ============================================================================ 196 197 struct QOSRESOURCE_MEMORY { 198 199 struct QOSDATA data; 200 201 UINT align; /* alignment of memory heap */ 202 203 UINT heapId; /* resource heap ID */ 204 205 UINT size; /* size of memory heap */ 206 207 UINT type; /* type of memory: prefer/require/scratch/persist */ 208 209 UINT allocated; /* size of heap in use (not free) */ 210 211 UINT largestfree; /* size of largest contiguous free block */ 212 213 UINT group; /* scratch group ID (only for scratch memory) */ 214 215 }; 216 217 /* ============================================================================ 218 219 name QOSRESOURCE_PROCESSOR 220 221 222 223 desc Each processor is described by its processor type, hardware 224 attributes, and available processing cycles (MIPS). 225 226 ============================================================================*/ 227 228 struct QOSRESOURCE_PROCESSOR { 229 230 struct QOSDATA data; 231 232 UINT MaxMips; /* max cpu cycles required for component */ 233 234 UINT TypicalMips; /* typical cpu cycles required */ 235 236 UINT MaxCycles; /* max cpu cycles for single iteration */ 237 238 UINT TypicalCycles; /* typical cpu cycles for single iteration */ 239 240 UINT Utilization; /* percentage of time cpu is idle */ 241 242 UINT currentLoad; 243 244 UINT predLoad; 245 246 UINT currDspFreq; 247 248 UINT predictedFreq; 249 250 }; 251 252 253 /* ============================================================================ 254 255 name QOSRESOURCE_STREAM 256 257 258 259 desc Bridge Streams are introduced as a QoS resource structure 260 261 ============================================================================ 262 */ 263 264 struct QOSRESOURCE_STREAM { 265 266 struct QOSDATA data; 267 268 struct DSP_STRMATTR Attrs; /* Stream attributes for this stream */ 269 270 UINT Direction; /* DSP_TONODE or DSP_FROMNODE */ 271 272 }; 273 274 struct QOSDYNDEPLIB { 275 276 struct QOSDATA data; 277 278 struct DSP_UUID depLibUuid; /* UUID of Dynamic Dependent Library */ 279 280 const CHAR *depLibPath; /* Path to Dynamic Dependent Library */ 281 282 }; 283 284 /* ============================================================================ 285 286 name QOSCOMPONENT 287 288 289 290 desc Bridge Streams are introduced as a QoS resource structure 291 292 ============================================================================ 293 */ 294 295 struct QOSCOMPONENT { 296 297 struct QOSDATA data; 298 299 UINT InUse; /* Count of instances of this component in use */ 300 301 UINT aTaskId; 302 303 UINT VariantID; 304 305 UINT InterfaceID; 306 307 struct DSP_UUID NodeUuid; 308 309 PVOID dynNodePath; 310 311 struct QOSDATA *resourceList; 312 313 struct QOSDYNDEPLIB *dynDepLibList; 314 315 }; 316 317 /* ============================================================================ 318 319 name Registry-specific QOS_FN_xxx definitions 320 321 322 323 desc These are defines for the registry-specific function codes 324 325 ============================================================================ 326 */ 327 328 #define QOS_FN_GetNumDynAllocMemHeaps 1 329 330 #define QOS_FN_HasAvailableResource 2 331 332 /* ============================================================================ 333 334 name Resource-specific QOS_FN_xxx definitions 335 336 337 338 desc These are defines for the resource-specific function codes 339 340 ============================================================================ 341 */ 342 343 #define QOS_FN_ResourceIsAvailable 1 344 345 #define QOS_FN_ResourceUpdateInfo 2 346 347 // ============================================================================ 348 349 /* name DSPRegistry_Create 350 351 352 353 Implementation 354 355 Creates empty Registry, then adds all the default system resources 356 357 Parameters 358 359 none 360 361 Return 362 363 QOSREGISTRY* ptr to new system registry 364 365 NULL Failure (out of memory) 366 367 Requirement Coverage 368 369 This method addresses requirement(s): SR10085 370 371 */ 372 373 struct QOSREGISTRY *DSPRegistry_Create(); 374 375 /* ============================================================================ 376 377 name DSPRegistry_Delete 378 379 380 381 Implementation 382 383 Deletes Registry and cleans up QoS Gateway & Registry objects that it 384 owns. 385 386 Parameters 387 388 registry ptr to previously created registry 389 390 Return 391 392 none 393 394 Requirement Coverage 395 396 This method addresses requirement(s): SR10085 397 398 */ 399 400 void DSPRegistry_Delete(struct QOSREGISTRY *registry); 401 402 /* ============================================================================ 403 404 name DSPRegistry_Find 405 406 407 408 Implementation 409 410 Finds resource(s) or component(s) that match the given Id. For 411 resources, each matching 412 413 resource's TypeSpecific function is called with the function 414 ID QOS_FN_ResourceUpdateInfo to 415 416 ensure that all resources have current data in their structures. 417 418 Parameters 419 420 Id requested Id 421 422 registry system registry 423 424 ResultList ptr to results array 425 426 Size ptr to ULONG number of entries available in array 427 428 Return 429 430 DSP_OK successful 431 432 DSP_ESIZE block for results is too small 433 434 DSP_ENOTFOUND item not found 435 436 Requirement Coverage 437 438 This method addresses requirement(s): SR10008 439 440 */ 441 442 DSP_STATUS DSPRegistry_Find(UINT Id, struct QOSREGISTRY *registry, 443 struct QOSDATA **ResultList, ULONG *Size); 444 445 /* ============================================================================ 446 447 name DSPRegistry_Add 448 449 450 451 Implementation 452 453 Add given resource or component to the list 454 455 Parameters 456 457 listhead system registry (in the case of adding resources or 458 components to the system) 459 460 or component (in the case of adding required resources 461 to a component) 462 463 entry entry to add in list 464 465 Return 466 467 DSP_STATUS Error code or DSP_SOK for success 468 469 Requirement Coverage 470 471 This method addresses requirement(s): SR10085 472 473 */ 474 475 DSP_STATUS DSPRegistry_Add(struct QOSDATA *listhead, struct QOSDATA *entry); 476 477 /* ============================================================================ 478 479 name DSPRegistry_Remove 480 481 482 483 Implementation 484 485 Removes given resource or component from the list 486 487 Parameters 488 489 listhead system registry (in the case of removing resources or 490 components from the system) 491 492 or component (in the case of removing required 493 resources from a component) 494 495 entry resource or component to remove 496 497 Return 498 499 DSP_STATUS Error code or DSP_SOK for success 500 501 Requirement Coverage 502 503 This method addresses requirement(s): SR10085 504 505 */ 506 507 DSP_STATUS DSPRegistry_Remove(struct QOSDATA *listhead, struct QOSDATA *entry); 508 509 /* ============================================================================ 510 511 name DSPQos_TypeSpecific 512 513 514 515 Implementation 516 517 Calls the type-specific function defined for this data type. 518 Internally, this is implemented 519 520 as a call to the QOSDATA structure's TypeSpecific() function. 521 522 Parameters 523 524 DataObject Far pointer to the structure for the data object 525 526 FunctionCode Type-specific function code 527 528 Parameter1 Function-specific parameter 529 530 Return 531 532 ULONG Function-specific return code. 533 534 Requirement Coverage 535 536 This method addresses requirement(s): SR10085, SR10008 537 538 */ 539 540 ULONG DSPQos_TypeSpecific(struct QOSDATA *DataObject, ULONG FunctionCode, 541 ULONG Parameter1); 542 543 /* ============================================================================ 544 545 name DSPComponent_Register 546 547 548 549 Implementation 550 551 Informs Registry that the given component is using system resources. 552 Internally, this 553 554 increments the InUse field of the QOSCOMPONENT structure. 555 556 Parameters 557 558 registry system registry 559 560 comp component using system resources 561 562 Return 563 564 DSP_STATUS Error code or DSP_SOK for success 565 566 Requirement Coverage 567 568 This method addresses requirement(s): SR10085 569 570 */ 571 572 DSP_STATUS DSPComponent_Register(struct QOSREGISTRY *registry, 573 struct QOSCOMPONENT *comp); 574 575 /* ============================================================================ 576 577 name DSPComponent_Unregister 578 579 580 581 Implementation 582 583 Informs Registry that component is no longer using system resources. 584 Internally, this 585 586 decrements the InUse field of the QOSCOMPONENT structure. 587 588 Parameters 589 590 registry system registry 591 592 comp component releasing system resources 593 594 Return 595 596 DSP_STATUS Error code or DSP_SOK for success 597 598 Requirement Coverage 599 600 This method addresses requirement(s): SR10085 601 602 */ 603 604 DSP_STATUS DSPComponent_Unregister(struct QOSREGISTRY *registry, 605 struct QOSCOMPONENT *comp); 606 607 /* ============================================================================ 608 609 name DSPData_Create 610 611 612 613 Implementation 614 615 Allocates and initializes a QOSDATA structure. 616 617 Parameters 618 619 id type of data 620 621 Return 622 623 QOSDATA * ptr to data structure or NULL for failure 624 625 Requirement Coverage 626 627 This method addresses requirement(s): 628 629 */ 630 631 struct QOSDATA *DSPData_Create(ULONG id); 632 633 /* ============================================================================ 634 635 name DSPData_Delete 636 637 638 639 Implementation 640 641 Deletes a QOSDATA structure, recursively deleting any associated lists. 642 643 Parameters 644 645 data ptr to data structure to delete 646 647 Return 648 649 DSP_STATUS Error code or DSP_SOK for success 650 651 Requirement Coverage 652 653 This method addresses requirement(s): 654 655 */ 656 657 DSP_STATUS DSPData_Delete(struct QOSDATA *data); 658 659 /* ============================================================================ 660 661 name DSPData_IsResource 662 663 664 665 Implementation 666 667 Determines whether a QOSDATA structure Id is a "resource" type ID. 668 669 Parameters 670 671 Id type ID to check 672 673 Return 674 675 bool TRUE for resources, FALSE otherwise. 676 677 Requirement Coverage 678 679 This method addresses requirement(s): 680 681 */ 682 683 bool DSPData_IsResource(ULONG Id); 684 685 #endif 686 687