[1] | 1 | /* |
---|
| 2 | * core.h - core descriptor and associated access functions définition |
---|
[19] | 3 | * |
---|
[1] | 4 | * Authors Ghassan Almaless (2008,2009,2010,2011,2012) |
---|
[68] | 5 | * Alain Greiner (2016,2017) |
---|
[1] | 6 | * |
---|
| 7 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 8 | * |
---|
| 9 | * This file is part of ALMOS-MKH. |
---|
| 10 | * |
---|
| 11 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 12 | * under the terms of the GNU General Public License as published by |
---|
| 13 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 14 | * |
---|
| 15 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #ifndef _CORE_H_ |
---|
| 26 | #define _CORE_H_ |
---|
| 27 | |
---|
[14] | 28 | #include <kernel_config.h> |
---|
[1] | 29 | #include <hal_types.h> |
---|
| 30 | #include <list.h> |
---|
| 31 | #include <rpc.h> |
---|
| 32 | #include <scheduler.h> |
---|
| 33 | |
---|
| 34 | /**** Forward declarations ****/ |
---|
| 35 | |
---|
| 36 | struct thread_s; |
---|
[5] | 37 | struct chdev_s; |
---|
[188] | 38 | enum pic_impl_e; |
---|
[1] | 39 | |
---|
| 40 | /**************************************************************************************** |
---|
[5] | 41 | * This structure defines the core descriptor. |
---|
[188] | 42 | * Besides the core identifiers (gid,lid), it contains an embedded private scheduler. |
---|
| 43 | * It contains an architecture specific extension to store the interrupt vector(s). |
---|
| 44 | * The core_init()function must allocate memory for this extension, depending on the |
---|
| 45 | * PIC device implementation type. |
---|
[1] | 46 | ***************************************************************************************/ |
---|
| 47 | |
---|
| 48 | typedef struct core_s |
---|
| 49 | { |
---|
| 50 | lid_t lid; /*! core local index in cluster */ |
---|
[19] | 51 | gid_t gid; /*! core global identifier (hardware index) */ |
---|
[367] | 52 | |
---|
[1] | 53 | uint64_t cycles; /*! total number of cycles (from hard reset) */ |
---|
| 54 | uint32_t time_stamp; /*! previous time stamp (read from register) */ |
---|
[367] | 55 | |
---|
[1] | 56 | uint32_t ticks_nr; /*! number of elapsed ticks */ |
---|
| 57 | uint32_t usage; /*! cumulated busy_percent (idle / total) */ |
---|
| 58 | uint32_t spurious_irqs; /*! for instrumentation... */ |
---|
| 59 | struct thread_s * thread_idle; /*! pointer on idle thread descriptor */ |
---|
[19] | 60 | struct thread_s * fpu_owner; /*! pointer on current FPU owner thread */ |
---|
[1] | 61 | uint32_t rand_last; /*! last computed random value */ |
---|
| 62 | scheduler_t scheduler; /*! embedded private scheduler */ |
---|
| 63 | |
---|
[188] | 64 | void * pic_extend; /*! PIC implementation specific extension */ |
---|
[19] | 65 | } |
---|
[1] | 66 | core_t; |
---|
| 67 | |
---|
[188] | 68 | /**************************************************************************************** |
---|
[1] | 69 | * This macro returns a pointer on the calling core descriptor. |
---|
[188] | 70 | ***************************************************************************************/ |
---|
[1] | 71 | |
---|
| 72 | #define CURRENT_CORE (CURRENT_THREAD->core) |
---|
| 73 | |
---|
| 74 | /*************************************************************************************** |
---|
[188] | 75 | * This function initializes a core descriptor. |
---|
[1] | 76 | * It makes the association [gid] <=> [lid], as defined in arch_info, via the |
---|
| 77 | * boot_info_t structure build by the bootloader in each cluster. |
---|
[188] | 78 | * It allocates memory for the PIC infrastructure specific core extension. |
---|
| 79 | * It does NOT initialize the <thread_idle> and the <pic_extend> fields, |
---|
| 80 | * that must be completed later. |
---|
[1] | 81 | *************************************************************************************** |
---|
| 82 | * @ core : pointer on core descriptor to initialise. |
---|
[188] | 83 | * @ lid : local core index in cluster. |
---|
| 84 | * @ gid : global core identifier (hardware index). |
---|
[1] | 85 | **************************************************************************************/ |
---|
[188] | 86 | void core_init( core_t * core, |
---|
| 87 | lid_t lid, |
---|
| 88 | gid_t gid ); |
---|
[1] | 89 | |
---|
| 90 | /*************************************************************************************** |
---|
| 91 | * This function returns a pseudo random number from the core descriptor |
---|
| 92 | * private random generator. |
---|
| 93 | *************************************************************************************** |
---|
| 94 | * @ core : pointer on core descriptor. |
---|
| 95 | * @ returns the pseudo random value. |
---|
| 96 | **************************************************************************************/ |
---|
| 97 | inline uint32_t core_get_rand( core_t * core ); |
---|
| 98 | |
---|
| 99 | /*************************************************************************************** |
---|
[101] | 100 | * This function returns the current date (seconds & micro-seconds) from |
---|
| 101 | * the 64 bits calling core cycles counter. |
---|
[1] | 102 | *************************************************************************************** |
---|
| 103 | * @ core : pointer on core descriptor. |
---|
| 104 | * @ tm_s : number of seconds. |
---|
| 105 | * @ tm_us : number of micro-seconds. |
---|
| 106 | **************************************************************************************/ |
---|
| 107 | void core_get_time( core_t * core, |
---|
| 108 | uint32_t * tm_s, |
---|
| 109 | uint32_t * tm_us ); |
---|
| 110 | |
---|
| 111 | /*************************************************************************************** |
---|
| 112 | * This function must be called at each TICK. |
---|
| 113 | * It updates the cycles and ticks counter in the calling core descriptor. |
---|
| 114 | * It handles all pending alarms depending on the ticks counter value. |
---|
[19] | 115 | * It handles the scheduling, depending on the ticks counter value. |
---|
[1] | 116 | * It handles the global DQDT update, depending on the ticks counter vakue. |
---|
| 117 | *************************************************************************************** |
---|
| 118 | * @ core : pointer on core descriptor. |
---|
| 119 | **************************************************************************************/ |
---|
| 120 | void core_clock( core_t * core ); |
---|
| 121 | |
---|
| 122 | /*************************************************************************************** |
---|
[19] | 123 | * This function updates the usage statistics for the calling core descriptor, |
---|
[1] | 124 | * based on the ratio between the idle_ticks and total_ticks. |
---|
| 125 | *************************************************************************************** |
---|
| 126 | * @ core : pointer on core descriptor. |
---|
| 127 | **************************************************************************************/ |
---|
| 128 | void core_compute_stats( core_t * core ); |
---|
| 129 | |
---|
| 130 | /*************************************************************************************** |
---|
[16] | 131 | * This function reset the usage statistics. |
---|
[1] | 132 | *************************************************************************************** |
---|
| 133 | * @ core : pointer on core descriptor. |
---|
| 134 | **************************************************************************************/ |
---|
| 135 | void core_reset_stats( core_t * core ); |
---|
| 136 | |
---|
| 137 | /*************************************************************************************** |
---|
| 138 | * This function set/reset a selected entry in one interrupt vector for a remote core. |
---|
| 139 | * The written value is an extended pointer on the "source" device (or the XPTR_NULL |
---|
[19] | 140 | * value in case of reset). As it uses remote access, this function can be called by |
---|
[1] | 141 | * any thread in any cluster. |
---|
| 142 | *************************************************************************************** |
---|
[5] | 143 | * @ core : local pointer on the core descriptor. |
---|
[1] | 144 | * @ irq_type : type of IRQ (HWI/WTI/PTI). |
---|
| 145 | * @ irq_id : index in the IRQ vector. |
---|
[5] | 146 | * @ chdev : local pointer on the "source" chdev descriptor. |
---|
[1] | 147 | **************************************************************************************/ |
---|
[5] | 148 | void core_set_irq_vector_entry( core_t * core, |
---|
| 149 | uint32_t irq_type, |
---|
| 150 | uint32_t irq_id, |
---|
| 151 | struct chdev_s * chdev ); |
---|
[1] | 152 | |
---|
| 153 | |
---|
| 154 | #endif /* _CORE_H_ */ |
---|