source: branches/reconfiguration/softs/mach/cpu.h

Last change on this file was 887, checked in by cfuguet, 12 years ago

reconf: add test for the recovery routing function on the dspin_router

  • The test performs a reconfiguration of a cycle-free contour around a blackhole in a 3x3 platform. The blackhole (faulty routers) is in the cluster (1,1).
  • Introduce a reconf:xicu driver in the softs directory. For now this driver contains only a getter/setter for the configuration registers in the reconf:vci_xicu.
File size: 3.1 KB
Line 
1/**
2 * \file cpu.h
3 * \date March 10, 2014
4 * \author Cesar Fuguet
5 * \brief MIPS32 processor core function definitions
6 */
7#ifndef _CPU_H
8#define _CPU_H
9
10#include <stdint.h>
11#include <hard_config.h>
12
13#define CLUSTER(x,y) (((x) << Y_WIDTH) | (y))
14#define CLUSTER_ID_BITS (X_WIDTH + Y_WIDTH)
15#define CLUSTER_OFFSET_BITS (40-CLUSTER_ID_BITS)
16#define CLUSTER_BASE(x,y) ((uint64_t)CLUSTER((x),(y)) << CLUSTER_OFFSET_BITS)
17
18/*
19 * Inline functions definition
20 */
21static inline unsigned int cpu_procid()
22{
23 register uint32_t ret asm("v0");
24 asm volatile ("mfc0 %[ret], $15,1" : [ret] "=r"(ret));
25 return (ret & 0x3FF);
26}
27
28static inline unsigned int cpu_cluster()
29{
30 return (cpu_procid() / NB_PROCS_MAX);
31}
32
33static inline unsigned int cpu_x()
34{
35 return (cpu_cluster() >> Y_WIDTH);
36}
37
38static inline unsigned int cpu_y()
39{
40 return (cpu_cluster() & ((1 << X_WIDTH) - 1));
41}
42
43static inline unsigned int cpu_l()
44{
45 return (cpu_procid() % NB_PROCS_MAX);
46}
47
48static inline unsigned int cpu_time()
49{
50 register uint32_t ret asm("v0");
51 asm volatile ("mfc0 %[ret], $9,0" : [ret] "=r"(ret));
52 return ret;
53};
54
55static inline unsigned int cpu_get_sp()
56{
57 register unsigned int ret asm("v0");
58 asm volatile ("move %[ret], $29" : [ret] "=r"(ret));
59 return ret;
60}
61
62static inline void cpu_set_sp(uint32_t sp)
63{
64 asm volatile ("move $29, %[addr] \n"
65 : /* no output */
66 : [addr] "r"(sp)
67 : "memory");
68}
69
70static inline void cpu_wait()
71{
72 asm volatile ("wait");
73}
74
75static inline void cpu_sync()
76{
77 asm volatile ("sync":::"memory");
78}
79
80static inline void cpu_sleep(uint32_t cycles)
81{
82 asm volatile (".set noreorder \n"
83 "1: \n"
84 "bnez %[c], 1b \n"
85 "addiu %[c], %[c], -1 \n"
86 ".set reorder \n"
87 : /* no output */
88 : [c] "r"(cycles));
89}
90
91static inline void cpu_set_ptpr(uint32_t ptpr)
92{
93 asm volatile ("mtc2 %[ptpr], $0\n"
94 : /* no output */
95 : [ptpr] "r"(ptpr)
96 : "memory");
97}
98
99static inline uint32_t cpu_get_ptpr()
100{
101 register uint32_t ret asm("v0");
102 asm volatile ("mfc2 %[ret], $0\n" : [ret] "=r"(ret));
103 return ret;
104}
105
106static inline uint32_t cpu_get_mmu_detr()
107{
108 register uint32_t ret asm("v0");
109 asm volatile ("mfc2 %[ret], $12\n" : [ret] "=r"(ret));
110 return ret;
111}
112
113static inline uint32_t cpu_get_cr_exccode()
114{
115 register uint32_t ret asm("v0");
116 asm volatile ("mfc0 %[ret], $13\n" : [ret] "=r"(ret));
117 return ((ret >> 2) & 0x1F);
118}
119
120static inline void cpu_set_wdt_max(uint32_t max)
121{
122 asm volatile ("mtc2 %[max], $26\n"
123 :
124 : [max] "r"(max)
125 : "memory");
126}
127
128static inline uint32_t cpu_get_wdt_max()
129{
130 register uint32_t ret asm("v0");
131 asm volatile ("mfc2 %[ret], $12\n" : [ret] "=r"(ret));
132 return ret;
133}
134
135#endif /* _CPU_H */
136
137/*
138 * vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
139 */
Note: See TracBrowser for help on using the repository browser.