[1] | 1 | /* |
---|
| 2 | * kern/hal-arch.h - Architecture related Hardware Abstraction Layer |
---|
| 3 | * |
---|
| 4 | * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless |
---|
| 5 | * Copyright (c) 2011,2012 UPMC Sorbonne Universites |
---|
| 6 | * |
---|
| 7 | * This file is part of ALMOS-kernel. |
---|
| 8 | * |
---|
| 9 | * ALMOS-kernel is free software; you can redistribute it and/or modify it |
---|
| 10 | * under the terms of the GNU General Public License as published by |
---|
| 11 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 12 | * |
---|
| 13 | * ALMOS-kernel is distributed in the hope that it will be useful, but |
---|
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | * General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with ALMOS-kernel; if not, write to the Free Software Foundation, |
---|
| 20 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #ifndef _HAL_ARCH_H_ |
---|
| 24 | #define _HAL_ARCH_H_ |
---|
| 25 | |
---|
| 26 | #ifndef _SYSTEM_H_ |
---|
| 27 | #error hal-arch.h cannot be included directly, use system.h instead |
---|
| 28 | #endif |
---|
| 29 | |
---|
| 30 | #include <types.h> |
---|
| 31 | |
---|
| 32 | /** Used atructures */ |
---|
| 33 | struct cpu_s; |
---|
| 34 | struct cluster_s; |
---|
| 35 | struct irq_action_s; |
---|
| 36 | struct event_s; |
---|
| 37 | struct boot_info_s; |
---|
| 38 | struct dqdt_cluster_s; |
---|
| 39 | struct dqdt_attr_s; |
---|
| 40 | |
---|
| 41 | /** Provided structures, functions and macros */ |
---|
| 42 | #define ARCH_THREAD_PAGE_ORDER |
---|
| 43 | struct arch_cpu_s; |
---|
| 44 | struct arch_cluster_s; |
---|
| 45 | |
---|
| 46 | /* CPUs/CLUSTERs Numbers */ |
---|
| 47 | #define CLUSTER_NR |
---|
| 48 | #define CPU_PER_CLUSTER_NR |
---|
| 49 | uint_t arch_onln_cpu_nr(void); |
---|
| 50 | uint_t arch_onln_cluster_nr(void); |
---|
| 51 | uint_t arch_cpu_per_cluster(void); |
---|
| 52 | cid_t arch_boot_cid(void); |
---|
| 53 | |
---|
| 54 | static inline uint_t arch_cpu_gid(uint_t cid, uint_t lid); |
---|
| 55 | static inline uint_t arch_cpu_lid(uint_t cpu_gid); |
---|
| 56 | static inline uint_t arch_cpu_cid(uint_t cpu_gid); |
---|
| 57 | |
---|
| 58 | /* Architecture Initialization */ |
---|
| 59 | void arch_init(struct boot_info_s *info); |
---|
| 60 | void arch_memory_init(struct boot_info_s *info); |
---|
| 61 | error_t arch_dqdt_build(struct boot_info_s *info); |
---|
| 62 | |
---|
| 63 | /* Real time, Real clock timers */ |
---|
| 64 | #define CPU_CLOCK_TICK |
---|
| 65 | #define MSEC_PER_TICK |
---|
| 66 | #define CYCLES_PER_SECOND |
---|
| 67 | |
---|
| 68 | /* Architecture context */ |
---|
| 69 | error_t arch_cpu_init(struct cpu_s *cpu); |
---|
| 70 | |
---|
| 71 | /* IRQs, IPIs and others */ |
---|
| 72 | error_t arch_cpu_set_irq_entry(struct cpu_s *cpu, int irq_nr, struct irq_action_s *action); |
---|
| 73 | error_t arch_cpu_get_irq_entry(struct cpu_s *cpu, int irq_nr, struct irq_action_s **action); |
---|
| 74 | error_t arch_cpu_send_ipi(gid_t dest, uint32_t val); |
---|
| 75 | |
---|
| 76 | /* Specific architecture-dependent DQDT macros & functions */ |
---|
| 77 | #define DQDT_DIST_NOTSET 0 /* must be zero (c.f: see dqdt_attr_init in kern/dqdt.h) */ |
---|
| 78 | #define DQDT_DIST_DEFAULT 1 |
---|
| 79 | #define DQDT_DIST_RANDOM 2 |
---|
| 80 | |
---|
| 81 | uint_t arch_dqdt_distance(struct dqdt_cluster_s *c1, struct dqdt_cluster_s *c2, struct dqdt_attr_s *attr); |
---|
| 82 | |
---|
| 83 | /* Specific architecture depanding CPU operations */ |
---|
| 84 | typedef enum |
---|
| 85 | { |
---|
| 86 | ARCH_PWR_IDLE, |
---|
| 87 | ARCH_PWR_SLEEP, |
---|
| 88 | ARCH_PWR_SHUTDOWN |
---|
| 89 | } arch_power_state_t; |
---|
| 90 | |
---|
| 91 | error_t arch_set_power_state(struct cpu_s *cpu, arch_power_state_t state); |
---|
| 92 | |
---|
| 93 | /* Specific architecture depanding CLUSTER operations */ |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | /* Specific architecture implementation */ |
---|
| 97 | |
---|
| 98 | #define ARCH_HAS_BARRIERS |
---|
| 99 | |
---|
| 100 | sint_t arch_barrier_init(struct cluster_s *cluster, struct event_s *event, uint_t count); |
---|
| 101 | sint_t arch_barrier_wait(struct cluster_s *cluster, uint_t barrier_id); |
---|
| 102 | error_t arch_barrier_destroy(struct cluster_s *cluster, uint_t barrier_id); |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | #include <arch.h> |
---|
| 106 | |
---|
| 107 | #endif /* _HAL_CPU_H_ */ |
---|