@@ -364,7 +364,12 @@ static void pnv_occ_register_types(void)
364
364
365
365
type_init (pnv_occ_register_types );
366
366
367
- /* From skiboot/hw/occ.c with tab to space conversion */
367
+ /*
368
+ * From skiboot/hw/occ.c with following changes:
369
+ * - tab to space conversion
370
+ * - Type conversions u8->uint8_t s8->int8_t __be16->uint16_t etc
371
+ * - __packed -> QEMU_PACKED
372
+ */
368
373
/* OCC Communication Area for PStates */
369
374
370
375
#define OPAL_DYNAMIC_DATA_OFFSET 0x0B80
@@ -384,20 +389,6 @@ type_init(pnv_occ_register_types);
384
389
#define FREQ_MAX_IN_DOMAIN 0
385
390
#define FREQ_MOST_RECENTLY_SET 1
386
391
387
- #define u8 uint8_t
388
- #define s8 int8_t
389
- #define u16 uint16_t
390
- #define s16 int16_t
391
- #define u32 uint32_t
392
- #define s32 int32_t
393
- #define u64 uint64_t
394
- #define s64 int64_t
395
- #define __be16 uint16_t
396
- #define __be32 uint32_t
397
- #ifndef __packed
398
- #define __packed QEMU_PACKED
399
- #endif /* !__packed */
400
-
401
392
/**
402
393
* OCC-OPAL Shared Memory Region
403
394
*
@@ -434,69 +425,69 @@ type_init(pnv_occ_register_types);
434
425
* @spare/reserved/pad: Unused data
435
426
*/
436
427
struct occ_pstate_table {
437
- u8 valid ;
438
- u8 version ;
439
- union __packed {
440
- struct __packed { /* Version 0x01 and 0x02 */
441
- u8 throttle ;
442
- s8 pstate_min ;
443
- s8 pstate_nom ;
444
- s8 pstate_turbo ;
445
- s8 pstate_ultra_turbo ;
446
- u8 spare ;
447
- u64 reserved ;
448
- struct __packed {
449
- s8 id ;
450
- u8 flags ;
451
- u8 vdd ;
452
- u8 vcs ;
453
- __be32 freq_khz ;
428
+ uint8_t valid ;
429
+ uint8_t version ;
430
+ union QEMU_PACKED {
431
+ struct QEMU_PACKED { /* Version 0x01 and 0x02 */
432
+ uint8_t throttle ;
433
+ int8_t pstate_min ;
434
+ int8_t pstate_nom ;
435
+ int8_t pstate_turbo ;
436
+ int8_t pstate_ultra_turbo ;
437
+ uint8_t spare ;
438
+ uint64_t reserved ;
439
+ struct QEMU_PACKED {
440
+ int8_t id ;
441
+ uint8_t flags ;
442
+ uint8_t vdd ;
443
+ uint8_t vcs ;
444
+ uint32_t freq_khz ;
454
445
} pstates [MAX_PSTATES ];
455
- s8 core_max [MAX_P8_CORES ];
456
- u8 pad [100 ];
446
+ int8_t core_max [MAX_P8_CORES ];
447
+ uint8_t pad [100 ];
457
448
} v2 ;
458
- struct __packed { /* Version 0x90 */
459
- u8 occ_role ;
460
- u8 pstate_min ;
461
- u8 pstate_nom ;
462
- u8 pstate_turbo ;
463
- u8 pstate_ultra_turbo ;
464
- u8 spare ;
465
- u64 reserved1 ;
466
- u64 reserved2 ;
467
- struct __packed {
468
- u8 id ;
469
- u8 flags ;
470
- u16 reserved ;
471
- __be32 freq_khz ;
449
+ struct QEMU_PACKED { /* Version 0x90 */
450
+ uint8_t occ_role ;
451
+ uint8_t pstate_min ;
452
+ uint8_t pstate_nom ;
453
+ uint8_t pstate_turbo ;
454
+ uint8_t pstate_ultra_turbo ;
455
+ uint8_t spare ;
456
+ uint64_t reserved1 ;
457
+ uint64_t reserved2 ;
458
+ struct QEMU_PACKED {
459
+ uint8_t id ;
460
+ uint8_t flags ;
461
+ uint16_t reserved ;
462
+ uint32_t freq_khz ;
472
463
} pstates [MAX_PSTATES ];
473
- u8 core_max [MAX_P9_CORES ];
474
- u8 pad [56 ];
464
+ uint8_t core_max [MAX_P9_CORES ];
465
+ uint8_t pad [56 ];
475
466
} v9 ;
476
- struct __packed { /* Version 0xA0 */
477
- u8 occ_role ;
478
- u8 pstate_min ;
479
- u8 pstate_fixed_freq ;
480
- u8 pstate_base ;
481
- u8 pstate_ultra_turbo ;
482
- u8 pstate_fmax ;
483
- u8 minor ;
484
- u8 pstate_bottom_throttle ;
485
- u8 spare ;
486
- u8 spare1 ;
487
- u32 reserved_32 ;
488
- u64 reserved_64 ;
489
- struct __packed {
490
- u8 id ;
491
- u8 valid ;
492
- u16 reserved ;
493
- __be32 freq_khz ;
467
+ struct QEMU_PACKED { /* Version 0xA0 */
468
+ uint8_t occ_role ;
469
+ uint8_t pstate_min ;
470
+ uint8_t pstate_fixed_freq ;
471
+ uint8_t pstate_base ;
472
+ uint8_t pstate_ultra_turbo ;
473
+ uint8_t pstate_fmax ;
474
+ uint8_t minor ;
475
+ uint8_t pstate_bottom_throttle ;
476
+ uint8_t spare ;
477
+ uint8_t spare1 ;
478
+ uint32_t reserved_32 ;
479
+ uint64_t reserved_64 ;
480
+ struct QEMU_PACKED {
481
+ uint8_t id ;
482
+ uint8_t valid ;
483
+ uint16_t reserved ;
484
+ uint32_t freq_khz ;
494
485
} pstates [MAX_PSTATES ];
495
- u8 core_max [MAX_P10_CORES ];
496
- u8 pad [48 ];
486
+ uint8_t core_max [MAX_P10_CORES ];
487
+ uint8_t pad [48 ];
497
488
} v10 ;
498
489
};
499
- } __packed ;
490
+ } QEMU_PACKED ;
500
491
501
492
/**
502
493
* OPAL-OCC Command Response Interface
@@ -531,13 +522,13 @@ struct occ_pstate_table {
531
522
* @spare: Unused byte
532
523
*/
533
524
struct opal_command_buffer {
534
- u8 flag ;
535
- u8 request_id ;
536
- u8 cmd ;
537
- u8 spare ;
538
- __be16 data_size ;
539
- u8 data [MAX_OPAL_CMD_DATA_LENGTH ];
540
- } __packed ;
525
+ uint8_t flag ;
526
+ uint8_t request_id ;
527
+ uint8_t cmd ;
528
+ uint8_t spare ;
529
+ uint16_t data_size ;
530
+ uint8_t data [MAX_OPAL_CMD_DATA_LENGTH ];
531
+ } QEMU_PACKED ;
541
532
542
533
/**
543
534
* OPAL-OCC Response Buffer
@@ -571,13 +562,13 @@ struct opal_command_buffer {
571
562
* @data: Response specific data
572
563
*/
573
564
struct occ_response_buffer {
574
- u8 flag ;
575
- u8 request_id ;
576
- u8 cmd ;
577
- u8 status ;
578
- __be16 data_size ;
579
- u8 data [MAX_OCC_RSP_DATA_LENGTH ];
580
- } __packed ;
565
+ uint8_t flag ;
566
+ uint8_t request_id ;
567
+ uint8_t cmd ;
568
+ uint8_t status ;
569
+ uint16_t data_size ;
570
+ uint8_t data [MAX_OCC_RSP_DATA_LENGTH ];
571
+ } QEMU_PACKED ;
581
572
582
573
/**
583
574
* OCC-OPAL Shared Memory Interface Dynamic Data Vx90
@@ -608,31 +599,31 @@ struct occ_response_buffer {
608
599
* @rsp: OCC Response Buffer
609
600
*/
610
601
struct occ_dynamic_data {
611
- u8 occ_state ;
612
- u8 major_version ;
613
- u8 minor_version ;
614
- u8 gpus_present ;
615
- union __packed {
616
- struct __packed { /* Version 0x90 */
617
- u8 spare1 ;
602
+ uint8_t occ_state ;
603
+ uint8_t major_version ;
604
+ uint8_t minor_version ;
605
+ uint8_t gpus_present ;
606
+ union QEMU_PACKED {
607
+ struct QEMU_PACKED { /* Version 0x90 */
608
+ uint8_t spare1 ;
618
609
} v9 ;
619
- struct __packed { /* Version 0xA0 */
620
- u8 wof_enabled ;
610
+ struct QEMU_PACKED { /* Version 0xA0 */
611
+ uint8_t wof_enabled ;
621
612
} v10 ;
622
613
};
623
- u8 cpu_throttle ;
624
- u8 mem_throttle ;
625
- u8 quick_pwr_drop ;
626
- u8 pwr_shifting_ratio ;
627
- u8 pwr_cap_type ;
628
- __be16 hard_min_pwr_cap ;
629
- __be16 max_pwr_cap ;
630
- __be16 cur_pwr_cap ;
631
- __be16 soft_min_pwr_cap ;
632
- u8 pad [110 ];
614
+ uint8_t cpu_throttle ;
615
+ uint8_t mem_throttle ;
616
+ uint8_t quick_pwr_drop ;
617
+ uint8_t pwr_shifting_ratio ;
618
+ uint8_t pwr_cap_type ;
619
+ uint16_t hard_min_pwr_cap ;
620
+ uint16_t max_pwr_cap ;
621
+ uint16_t cur_pwr_cap ;
622
+ uint16_t soft_min_pwr_cap ;
623
+ uint8_t pad [110 ];
633
624
struct opal_command_buffer cmd ;
634
625
struct occ_response_buffer rsp ;
635
- } __packed ;
626
+ } QEMU_PACKED ;
636
627
637
628
enum occ_response_status {
638
629
OCC_RSP_SUCCESS = 0x00 ,
0 commit comments