1 /** @file 2 3 Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR> 4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR> 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #ifndef _GASKET_H_ 17 #define _GASKET_H_ 18 19 // 20 // EMU_THUNK_PROTOCOL gaskets (EFIAPI to UNIX ABI) 21 // 22 23 UINTN 24 EFIAPI 25 GasketSecWriteStdErr ( 26 IN UINT8 *Buffer, 27 IN UINTN NumberOfBytes 28 ); 29 30 EFI_STATUS 31 EFIAPI 32 GasketSecConfigStdIn ( 33 VOID 34 ); 35 36 UINTN 37 EFIAPI 38 GasketSecWriteStdOut ( 39 IN UINT8 *Buffer, 40 IN UINTN NumberOfBytes 41 ); 42 43 UINTN 44 EFIAPI 45 GasketSecReadStdIn ( 46 IN UINT8 *Buffer, 47 IN UINTN NumberOfBytes 48 ); 49 50 BOOLEAN 51 EFIAPI 52 GasketSecPollStdIn ( 53 VOID 54 ); 55 56 VOID * 57 EFIAPI 58 GasketSecMalloc ( 59 IN UINTN Size 60 ); 61 62 VOID * 63 EFIAPI 64 GasketSecValloc ( 65 IN UINTN Size 66 ); 67 68 BOOLEAN 69 EFIAPI 70 GasketSecFree ( 71 IN VOID *Ptr 72 ); 73 74 75 RETURN_STATUS 76 EFIAPI 77 GasketSecPeCoffGetEntryPoint ( 78 IN VOID *Pe32Data, 79 IN OUT VOID **EntryPoint 80 ); 81 82 VOID 83 EFIAPI 84 GasketSecPeCoffRelocateImageExtraAction ( 85 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 86 ); 87 88 VOID 89 EFIAPI 90 GasketSecPeCoffUnloadImageExtraAction ( 91 IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 92 ); 93 94 VOID 95 EFIAPI 96 GasketSecSetTimer ( 97 IN UINT64 PeriodMs, 98 IN EMU_SET_TIMER_CALLBACK CallBack 99 ); 100 101 VOID 102 EFIAPI 103 GasketSecEnableInterrupt ( 104 VOID 105 ); 106 107 VOID 108 EFIAPI 109 GasketSecDisableInterrupt ( 110 VOID 111 ); 112 113 UINT64 114 EFIAPI 115 GasketQueryPerformanceFrequency ( 116 VOID 117 ); 118 119 UINT64 120 EFIAPI 121 GasketQueryPerformanceCounter ( 122 VOID 123 ); 124 125 126 VOID 127 EFIAPI 128 GasketSecSleep ( 129 IN UINT64 Nanoseconds 130 ); 131 132 VOID 133 EFIAPI 134 GasketSecCpuSleep ( 135 VOID 136 ); 137 138 VOID 139 EFIAPI 140 GasketSecExit ( 141 UINTN Status 142 ); 143 144 VOID 145 EFIAPI 146 GasketSecGetTime ( 147 OUT EFI_TIME *Time, 148 OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL 149 ); 150 151 VOID 152 EFIAPI 153 GasketSecSetTime ( 154 IN EFI_TIME *Time 155 ); 156 157 EFI_STATUS 158 EFIAPI 159 GasketSecGetNextProtocol ( 160 IN BOOLEAN EmuBusDriver, 161 OUT EMU_IO_THUNK_PROTOCOL **Instance OPTIONAL 162 ); 163 164 165 // PPIs produced by SEC 166 167 168 EFI_STATUS 169 EFIAPI 170 GasketSecUnixPeiAutoScan ( 171 IN UINTN Index, 172 OUT EFI_PHYSICAL_ADDRESS *MemoryBase, 173 OUT UINT64 *MemorySize 174 ); 175 176 VOID * 177 EFIAPI 178 GasketSecEmuThunkAddress ( 179 VOID 180 ); 181 182 183 EFI_STATUS 184 EFIAPI 185 GasketSecUnixUnixFwhAddress ( 186 IN OUT UINT64 *FwhSize, 187 IN OUT EFI_PHYSICAL_ADDRESS *FwhBase 188 ); 189 190 191 192 // 193 // Reverse (UNIX to EFIAPI) gaskets 194 // 195 196 typedef 197 void 198 (EFIAPI *CALL_BACK) ( 199 UINT64 Delta 200 ); 201 202 UINTN 203 ReverseGasketUint64 ( 204 CALL_BACK CallBack, 205 UINT64 a 206 ); 207 208 UINTN 209 ReverseGasketUint64Uint64 ( 210 VOID *CallBack, 211 VOID *Context, 212 VOID *Key 213 ); 214 215 // 216 // Gasket functions for EFI_EMU_UGA_IO_PROTOCOL 217 // 218 219 220 EFI_STATUS 221 EFIAPI 222 GasketX11Size ( 223 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, 224 UINT32 Width, 225 UINT32 Height 226 ); 227 228 EFI_STATUS 229 EFIAPI 230 GasketX11CheckKey ( 231 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo 232 ); 233 234 EFI_STATUS 235 EFIAPI 236 GasketX11GetKey ( 237 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, 238 EFI_KEY_DATA *key 239 ); 240 241 EFI_STATUS 242 EFIAPI 243 GasketX11KeySetState ( 244 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, 245 EFI_KEY_TOGGLE_STATE *KeyToggleState 246 ); 247 248 EFI_STATUS 249 EFIAPI 250 GasketX11RegisterKeyNotify ( 251 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, 252 IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK MakeCallBack, 253 IN EMU_GRAPHICS_WINDOW_REGISTER_KEY_NOTIFY_CALLBACK BreakCallBack, 254 IN VOID *Context 255 ); 256 257 258 EFI_STATUS 259 EFIAPI 260 GasketX11Blt ( 261 IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindows, 262 IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, 263 IN EFI_UGA_BLT_OPERATION BltOperation, 264 IN EMU_GRAPHICS_WINDOWS__BLT_ARGS *Args 265 ); 266 267 EFI_STATUS 268 EFIAPI 269 GasketX11CheckPointer ( 270 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo 271 ); 272 273 EFI_STATUS 274 EFIAPI 275 GasketX11GetPointerState ( 276 EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsWindowsIo, 277 EFI_SIMPLE_POINTER_STATE *state 278 ); 279 280 EFI_STATUS 281 EFIAPI 282 GasketX11GraphicsWindowOpen ( 283 IN EMU_IO_THUNK_PROTOCOL *This 284 ); 285 286 EFI_STATUS 287 EFIAPI 288 GasketX11GraphicsWindowClose ( 289 IN EMU_IO_THUNK_PROTOCOL *This 290 ); 291 292 // Pthreads 293 294 UINTN 295 EFIAPI 296 GasketPthreadMutexLock ( 297 IN VOID *Mutex 298 ); 299 300 301 302 UINTN 303 EFIAPI 304 GasketPthreadMutexUnLock ( 305 IN VOID *Mutex 306 ); 307 308 309 UINTN 310 EFIAPI 311 GasketPthreadMutexTryLock ( 312 IN VOID *Mutex 313 ); 314 315 316 VOID * 317 EFIAPI 318 GasketPthreadMutexInit ( 319 IN VOID 320 ); 321 322 323 UINTN 324 EFIAPI 325 GasketPthreadMutexDestroy ( 326 IN VOID *Mutex 327 ); 328 329 330 UINTN 331 EFIAPI 332 GasketPthreadCreate ( 333 IN VOID *Thread, 334 IN VOID *Attribute, 335 IN THREAD_THUNK_THREAD_ENTRY Start, 336 IN VOID *Context 337 ); 338 339 VOID 340 EFIAPI 341 GasketPthreadExit ( 342 IN VOID *ValuePtr 343 ); 344 345 346 UINTN 347 EFIAPI 348 GasketPthreadSelf ( 349 VOID 350 ); 351 352 EFI_STATUS 353 EFIAPI 354 GasketPthreadOpen ( 355 IN EMU_IO_THUNK_PROTOCOL *This 356 ); 357 358 EFI_STATUS 359 EFIAPI 360 GasketPthreadClose ( 361 IN EMU_IO_THUNK_PROTOCOL *This 362 ); 363 364 365 // PosixFileSystem 366 367 EFI_STATUS 368 EFIAPI 369 GasketPosixOpenVolume ( 370 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, 371 OUT EFI_FILE_PROTOCOL **Root 372 ); 373 374 EFI_STATUS 375 EFIAPI 376 GasketPosixFileOpen ( 377 IN EFI_FILE_PROTOCOL *This, 378 OUT EFI_FILE_PROTOCOL **NewHandle, 379 IN CHAR16 *FileName, 380 IN UINT64 OpenMode, 381 IN UINT64 Attributes 382 ); 383 384 EFI_STATUS 385 EFIAPI 386 GasketPosixFileCLose ( 387 IN EFI_FILE_PROTOCOL *This 388 ); 389 390 EFI_STATUS 391 EFIAPI 392 GasketPosixFileDelete ( 393 IN EFI_FILE_PROTOCOL *This 394 ); 395 396 EFI_STATUS 397 EFIAPI 398 GasketPosixFileRead ( 399 IN EFI_FILE_PROTOCOL *This, 400 IN OUT UINTN *BufferSize, 401 OUT VOID *Buffer 402 ); 403 404 EFI_STATUS 405 EFIAPI 406 GasketPosixFileWrite ( 407 IN EFI_FILE_PROTOCOL *This, 408 IN OUT UINTN *BufferSize, 409 IN VOID *Buffer 410 ); 411 412 EFI_STATUS 413 EFIAPI 414 GasketPosixFileSetPossition ( 415 IN EFI_FILE_PROTOCOL *This, 416 IN UINT64 Position 417 ); 418 419 EFI_STATUS 420 EFIAPI 421 GasketPosixFileGetPossition ( 422 IN EFI_FILE_PROTOCOL *This, 423 OUT UINT64 *Position 424 ); 425 426 EFI_STATUS 427 EFIAPI 428 GasketPosixFileGetInfo ( 429 IN EFI_FILE_PROTOCOL *This, 430 IN EFI_GUID *InformationType, 431 IN OUT UINTN *BufferSize, 432 OUT VOID *Buffer 433 ); 434 435 EFI_STATUS 436 EFIAPI 437 GasketPosixFileSetInfo ( 438 IN EFI_FILE_PROTOCOL *This, 439 IN EFI_GUID *InformationType, 440 IN UINTN BufferSize, 441 IN VOID *Buffer 442 ); 443 444 EFI_STATUS 445 EFIAPI 446 GasketPosixFileFlush ( 447 IN EFI_FILE_PROTOCOL *This 448 ); 449 450 EFI_STATUS 451 EFIAPI 452 GasketPosixFileSystmeThunkOpen ( 453 IN EMU_IO_THUNK_PROTOCOL *This 454 ); 455 456 EFI_STATUS 457 EFIAPI 458 GasketPosixFileSystmeThunkClose ( 459 IN EMU_IO_THUNK_PROTOCOL *This 460 ); 461 462 EFI_STATUS 463 EFIAPI 464 GasketEmuBlockIoReset ( 465 IN EMU_BLOCK_IO_PROTOCOL *This, 466 IN BOOLEAN ExtendedVerification 467 ); 468 469 EFI_STATUS 470 EFIAPI 471 GasketEmuBlockIoReadBlocks ( 472 IN EMU_BLOCK_IO_PROTOCOL *This, 473 IN UINT32 MediaId, 474 IN EFI_LBA LBA, 475 IN OUT EFI_BLOCK_IO2_TOKEN *Token, 476 IN UINTN BufferSize, 477 OUT VOID *Buffer 478 ); 479 480 EFI_STATUS 481 EFIAPI 482 GasketEmuBlockIoWriteBlocks ( 483 IN EMU_BLOCK_IO_PROTOCOL *This, 484 IN UINT32 MediaId, 485 IN EFI_LBA LBA, 486 IN OUT EFI_BLOCK_IO2_TOKEN *Token, 487 IN UINTN BufferSize, 488 IN VOID *Buffer 489 ); 490 491 EFI_STATUS 492 EFIAPI 493 GasketEmuBlockIoFlushBlocks ( 494 IN EMU_BLOCK_IO_PROTOCOL *This, 495 IN OUT EFI_BLOCK_IO2_TOKEN *Token 496 ); 497 498 EFI_STATUS 499 EFIAPI 500 GasketEmuBlockIoCreateMapping ( 501 IN EMU_BLOCK_IO_PROTOCOL *This, 502 IN EFI_BLOCK_IO_MEDIA *Media 503 ); 504 505 EFI_STATUS 506 EFIAPI 507 GasketBlockIoThunkOpen ( 508 IN EMU_IO_THUNK_PROTOCOL *This 509 ); 510 511 EFI_STATUS 512 EFIAPI 513 GasketBlockIoThunkClose ( 514 IN EMU_IO_THUNK_PROTOCOL *This 515 ); 516 517 EFI_STATUS 518 EFIAPI 519 GasketSnpThunkOpen ( 520 IN EMU_IO_THUNK_PROTOCOL *This 521 ); 522 523 EFI_STATUS 524 EFIAPI 525 GasketSnpThunkClose ( 526 IN EMU_IO_THUNK_PROTOCOL *This 527 ); 528 529 EFI_STATUS 530 EFIAPI 531 GasketSnpCreateMapping ( 532 IN EMU_SNP_PROTOCOL *This, 533 IN EFI_SIMPLE_NETWORK_MODE *Media 534 ); 535 536 EFI_STATUS 537 EFIAPI 538 GasketSnpStart ( 539 IN EMU_SNP_PROTOCOL *This 540 ); 541 542 EFI_STATUS 543 EFIAPI 544 GasketSnpStop ( 545 IN EMU_SNP_PROTOCOL *This 546 ); 547 548 EFI_STATUS 549 EFIAPI 550 GasketSnpInitialize ( 551 IN EMU_SNP_PROTOCOL *This, 552 IN UINTN ExtraRxBufferSize OPTIONAL, 553 IN UINTN ExtraTxBufferSize OPTIONAL 554 ); 555 556 EFI_STATUS 557 EFIAPI 558 GasketSnpReset ( 559 IN EMU_SNP_PROTOCOL *This, 560 IN BOOLEAN ExtendedVerification 561 ); 562 563 EFI_STATUS 564 EFIAPI 565 GasketSnpShutdown ( 566 IN EMU_SNP_PROTOCOL *This 567 ); 568 569 EFI_STATUS 570 EFIAPI 571 GasketSnpReceiveFilters ( 572 IN EMU_SNP_PROTOCOL *This, 573 IN UINT32 Enable, 574 IN UINT32 Disable, 575 IN BOOLEAN ResetMCastFilter, 576 IN UINTN MCastFilterCnt OPTIONAL, 577 IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL 578 ); 579 580 EFI_STATUS 581 EFIAPI 582 GasketSnpStationAddress ( 583 IN EMU_SNP_PROTOCOL *This, 584 IN BOOLEAN Reset, 585 IN EFI_MAC_ADDRESS *New OPTIONAL 586 ); 587 588 EFI_STATUS 589 EFIAPI 590 GasketSnpStatistics ( 591 IN EMU_SNP_PROTOCOL *This, 592 IN BOOLEAN Reset, 593 IN OUT UINTN *StatisticsSize OPTIONAL, 594 OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL 595 ); 596 597 EFI_STATUS 598 EFIAPI 599 GasketSnpMCastIpToMac ( 600 IN EMU_SNP_PROTOCOL *This, 601 IN BOOLEAN IPv6, 602 IN EFI_IP_ADDRESS *IP, 603 OUT EFI_MAC_ADDRESS *MAC 604 ); 605 606 EFI_STATUS 607 EFIAPI 608 GasketSnpNvData ( 609 IN EMU_SNP_PROTOCOL *This, 610 IN BOOLEAN ReadWrite, 611 IN UINTN Offset, 612 IN UINTN BufferSize, 613 IN OUT VOID *Buffer 614 ); 615 616 EFI_STATUS 617 EFIAPI 618 GasketSnpGetStatus ( 619 IN EMU_SNP_PROTOCOL *This, 620 OUT UINT32 *InterruptStatus OPTIONAL, 621 OUT VOID **TxBuf OPTIONAL 622 ); 623 624 EFI_STATUS 625 EFIAPI 626 GasketSnpTransmit ( 627 IN EMU_SNP_PROTOCOL *This, 628 IN UINTN HeaderSize, 629 IN UINTN BufferSize, 630 IN VOID *Buffer, 631 IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, 632 IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, 633 IN UINT16 *Protocol OPTIONAL 634 ); 635 636 EFI_STATUS 637 EFIAPI 638 GasketSnpReceive ( 639 IN EMU_SNP_PROTOCOL *This, 640 OUT UINTN *HeaderSize OPTIONAL, 641 IN OUT UINTN *BufferSize, 642 OUT VOID *Buffer, 643 OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, 644 OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, 645 OUT UINT16 *Protocol OPTIONAL 646 ); 647 648 649 #endif 650 651 652