source: trunk/kernel/arch/tsar/arch.h @ 1

Last change on this file since 1 was 1, checked in by alain, 5 years ago

First import

File size: 3.2 KB
Line 
1/*
2 * arch.h - architecture specific implementation of kernel's HAL
3 * (see kern/hal-arch.h)
4 *
5 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
6 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-kernel.
9 *
10 * ALMOS-kernel is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-kernel is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _ARCH_H_
25#define _ARCH_H_
26
27#include <config.h>
28#include <types.h>
29
30#ifndef _HAL_ARCH_H_
31#error arch.h connot be included directly, use system.h instead
32#endif
33
34/* Thread structure size */
35#undef  ARCH_THREAD_PAGE_ORDER
36#define ARCH_THREAD_PAGE_ORDER CONFIG_THREAD_PAGE_ORDER
37
38/* CPUs/CLUSTERs Numbers */
39#define CACHE_LINE_SIZE      CONFIG_CACHE_LINE_SIZE
40
41#undef CLUSTER_NR
42#define CLUSTER_NR           CONFIG_MAX_CLUSTER_NR
43
44#undef DEVICE_NR
45#define DEVICE_NR           CONFIG_MAX_DEVICE_NR
46
47#undef CPU_PER_CLUSTER
48#define CPU_PER_CLUSTER      CONFIG_MAX_CPU_PER_CLUSTER_NR
49
50#undef ARCH_HAS_BARRIERS
51#define ARCH_HAS_BARRIERS    CONFIG_ARCH_HAS_BARRIERS
52
53inline uint32_t arch_onln_cpu_nr();
54inline uint32_t arch_onln_cluster_nr();
55
56/* Timer parameters macros */
57#undef CPU_CLOCK_TICK
58#undef CYCLES_PER_SECOND
59#undef MSEC_PER_TICK
60
61#define CPU_CLOCK_TICK       1000000//80000
62#define MSEC_PER_TICK        1
63#define CYCLES_PER_SECOND    (1000*MSEC_PER_TICK*CPU_CLOCK_TICK)
64
65/* Terminals related macros */
66#define TTY_DEV_NR           CONFIG_TTY_MAX_DEV_NR
67#define TTY_BUFFER_DEPTH     CONFIG_TTY_BUFFER_DEPTH
68
69/* Structures definitions */
70struct irq_action_s;
71struct device_s;
72
73struct arch_cpu_s
74{
75        struct irq_action_s *irq_vector[CONFIG_CPU_IRQ_NR];
76};
77
78
79struct arch_entry_s
80{
81        uint32_t          arch_cid;
82        struct device_s * xicu;
83        struct device_s * dma;
84};
85
86typedef struct arch_entry_s *arch_entry_t;
87       
88extern struct arch_entry_s arch_entrys[CLUSTER_NR];
89
90
91static inline uint32_t arch_cpu_gid(uint32_t cid, uint32_t lid)
92{
93        return (cid * arch_cpu_per_cluster()) + lid;
94}
95
96static inline uint32_t arch_cpu_lid(uint32_t cpu_gid)
97{
98        return (cpu_gid % arch_cpu_per_cluster());
99}
100
101static inline uint32_t arch_cpu_cid(uint32_t cpu_gid)
102{
103        return (cpu_gid / arch_cpu_per_cluster());
104}
105
106static inline arch_entry_t get_arch_entry(uint32_t cid)
107{
108        return &arch_entrys[cid];
109}
110
111static inline uint32_t arch_clst_arch_cid(cid_t cid)
112{
113        //assert(cid <= arch_onln_cluster_nr());
114        if((cid > CLUSTER_NR) || (get_arch_entry(cid)->arch_cid == 0x55555555))
115        {
116                        cid = *((cid_t*)0x55555555);
117                        while(1);
118        }
119        return get_arch_entry(cid)->arch_cid;
120}
121
122
123extern cid_t Arch_cid_To_Almos_cid[CLUSTER_NR]; 
124static inline cid_t arch_clst_cid(uint32_t arch_cid)
125{
126        //assert(cid <= arch_onln_cluster_nr());
127        return Arch_cid_To_Almos_cid[arch_cid];
128}
129
130#endif  /* _ARCH_H_ */
Note: See TracBrowser for help on using the repository browser.