LCOV - code coverage report
Current view: top level - include - opal-internal.h (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 8 8 100.0 %
Date: 2024-01-02 21:04:04 Functions: 1 1 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /*
       3                 :            :  * Internal header for OPAL API related things in skiboot
       4                 :            :  *
       5                 :            :  * Copyright 2013-2019 IBM Corp.
       6                 :            :  */
       7                 :            : 
       8                 :            : #ifndef __OPAL_INTERNAL_H
       9                 :            : #define __OPAL_INTERNAL_H
      10                 :            : 
      11                 :            : 
      12                 :            : #include <skiboot.h>
      13                 :            : 
      14                 :            : /* An opal table entry */
      15                 :            : struct opal_table_entry {
      16                 :            :         void    *func;
      17                 :            :         u32     token;
      18                 :            :         u32     nargs;
      19                 :            : };
      20                 :            : 
      21                 :            : #ifdef __CHECKER__
      22                 :            : #define __opal_func_test_arg(__func, __nargs) 0
      23                 :            : #else
      24                 :            : #define __opal_func_test_arg(__func, __nargs)                           \
      25                 :            :         sizeof(__func( __test_args##__nargs ))
      26                 :            : #endif
      27                 :            : 
      28                 :            : #define opal_call(__tok, __func, __nargs)                               \
      29                 :            : static struct opal_table_entry __e_##__func __used __section(".opal_table") = \
      30                 :            : { .func = __func, .token = __tok,                                       \
      31                 :            :   .nargs = __nargs + 0 * __opal_func_test_arg(__func, __nargs) }
      32                 :            : 
      33                 :            : /* Make sure function takes args they claim.  Look away now... */
      34                 :            : #define __test_args0
      35                 :            : #define __test_args1 0
      36                 :            : #define __test_args2 0,0
      37                 :            : #define __test_args3 0,0,0
      38                 :            : #define __test_args4 0,0,0,0
      39                 :            : #define __test_args5 0,0,0,0,0
      40                 :            : #define __test_args6 0,0,0,0,0,0
      41                 :            : #define __test_args7 0,0,0,0,0,0,0
      42                 :            : 
      43                 :            : extern struct opal_table_entry __opal_table_start[];
      44                 :            : extern struct opal_table_entry __opal_table_end[];
      45                 :            : 
      46                 :            : extern uint64_t opal_pending_events;
      47                 :            : 
      48                 :            : extern struct dt_node *opal_node;
      49                 :            : 
      50                 :            : extern void opal_table_init(void);
      51                 :            : extern void opal_update_pending_evt(uint64_t evt_mask, uint64_t evt_values);
      52                 :            : uint64_t opal_dynamic_event_alloc(void);
      53                 :            : void opal_dynamic_event_free(uint64_t event);
      54                 :            : extern void add_opal_node(void);
      55                 :            : 
      56                 :            : #define opal_register(token, func, nargs)                               \
      57                 :            :         __opal_register((token) + 0*__opal_func_test_arg(func, nargs),  \
      58                 :            :                         (func), (nargs))
      59                 :            : extern void __opal_register(uint64_t token, void *func, unsigned num_args);
      60                 :            : 
      61                 :            : int64_t opal_quiesce(uint32_t shutdown_type, int32_t cpu);
      62                 :            : 
      63                 :            : /* Warning: no locking at the moment, do at init time only
      64                 :            :  *
      65                 :            :  * XXX TODO: Add the big RCU-ish "opal API lock" to protect us here
      66                 :            :  * which will also be used for other things such as runtime updates
      67                 :            :  */
      68                 :            : extern void opal_add_poller(void (*poller)(void *data), void *data);
      69                 :            : extern void opal_del_poller(void (*poller)(void *data));
      70                 :            : extern void opal_run_pollers(void);
      71                 :            : 
      72                 :            : /*
      73                 :            :  * Warning: no locking, only call that from the init processor
      74                 :            :  */
      75                 :            : extern void opal_add_host_sync_notifier(bool (*notify)(void *data), void *data);
      76                 :            : extern void opal_del_host_sync_notifier(bool (*notify)(void *data), void *data);
      77                 :            : 
      78                 :            : /*
      79                 :            :  * Opal internal function prototype
      80                 :            :  */
      81                 :            : struct OpalHMIEvent;
      82                 :            : extern int occ_msg_queue_occ_reset(void);
      83                 :            : 
      84                 :            : extern unsigned long top_of_ram;
      85                 :            : 
      86                 :            : /*
      87                 :            :  * Returns true if the address is valid, false otherwise
      88                 :            :  *
      89                 :            :  * Checks if the passed address belongs to real address space
      90                 :            :  * or 0xc000... kernel address space. It also checks that
      91                 :            :  * addr <= total physical memory. The magic value 60 comes
      92                 :            :  * from 60 bit real address mentioned in section 5.7 of the
      93                 :            :  * Power ISA (Book 3S).
      94                 :            :  */
      95                 :         45 : static inline bool opal_addr_valid(const void *addr)
      96                 :            : {
      97                 :         45 :         unsigned long val = (unsigned long)addr;
      98                 :         45 :         if ((val >> 60) != 0xc && (val >> 60) != 0x0)
      99                 :          2 :                 return false;
     100                 :         43 :         val &= ~0xf000000000000000UL;
     101                 :         43 :         if (val > top_of_ram)
     102                 :          1 :                 return false;
     103                 :         42 :         return true;
     104                 :            : }
     105                 :            : 
     106                 :            : #endif /* __OPAL_INTERNAL_H */

Generated by: LCOV version 1.14