Forward compatibility: build relative-base link libraries where needed
[AROS.git] / arch / ppc-chrp / boot / openfirmware / include / support.h
blobc873d46ff6f6ab9319633a102126df2c56d86054
1 /*
2 * support.h
4 * Created on: Aug 13, 2008
5 * Author: misc
6 */
8 #ifndef SUPPORT_H_
9 #define SUPPORT_H_
11 #include <inttypes.h>
12 #include <stddef.h>
14 typedef struct __node {
15 struct __node *n_succ,
16 *n_pred;
17 } node_t;
19 typedef struct __list {
20 node_t *l_head,
21 *l_tail,
22 *l_tailpred;
23 } list_t;
25 struct of_region
27 uint8_t *base;
28 int32_t size;
31 static inline void new_list(list_t *l)
33 l->l_tailpred = (node_t *)l;
34 l->l_tail = NULL;
35 l->l_head = (node_t *)&l->l_tail;
38 static inline void add_head(list_t *l, node_t *n)
40 n->n_succ = l->l_head;
41 n->n_pred = (node_t *)&l->l_head;
43 l->l_head->n_pred = n;
44 l->l_head = n;
47 static inline void add_tail(list_t *l, node_t *n)
49 n->n_succ = (node_t *)&l->l_tail;
50 n->n_pred = l->l_tailpred;
52 l->l_tailpred->n_succ = n;
53 l->l_tailpred = n;
56 static inline node_t *remove(node_t *n)
58 n->n_pred->n_succ = n->n_succ;
59 n->n_succ->n_pred = n->n_pred;
61 return n;
64 typedef struct {
65 node_t m_node;
66 char *m_name;
67 char *m_str;
68 intptr_t m_lowest;
69 intptr_t m_highest;
70 list_t m_symbols;
71 } module_t;
73 typedef struct {
74 node_t s_node;
75 char *s_name;
76 intptr_t s_lowest;
77 intptr_t s_highest;
78 } symbol_t;
80 extern void *stdin;
81 extern void *stdout;
82 extern void *stderr;
84 int32_t strlen(const char *c);
85 int isblank(char c);
86 int isspace(char c);
87 int isdigit(char c);
88 int tolower(char c);
89 int strncasecmp(const char *s1, const char *s2, int max);
90 int strcasecmp(const char *s1, const char *s2);
91 int strncmp(const char *s1, const char *s2, int max);
92 void bzero(void *dest, int length);
93 void memcpy(void *dest, const void *src, int length);
94 int atoi(const char *str);
95 char *remove_path(const char *in);
97 void printf(char *str, ...);
98 void sprintf(char *dest, char *str, ...);
100 #define LOAD_SIZE (0x00500000)
102 #define KERNEL_PHYS_BASE 0x07800000
103 #define KERNEL_VIRT_BASE 0xff800000
105 #define MAX_BSS_SECTIONS 1024
108 static inline uint32_t rdmsr() {
109 uint32_t msr; asm volatile("mfmsr %0":"=r"(msr)); return msr;
112 static inline void wrmsr(uint32_t msr) {
113 asm volatile("mtmsr %0"::"r"(msr));
117 #define IBAT0U 528
118 #define IBAT0L 529
119 #define IBAT1U 530
120 #define IBAT1L 531
121 #define IBAT2U 532
122 #define IBAT2L 533
123 #define IBAT3U 534
124 #define IBAT3L 535
126 #define IBAT4U 560
127 #define IBAT4L 561
128 #define IBAT5U 562
129 #define IBAT5L 563
130 #define IBAT6U 564
131 #define IBAT6L 565
132 #define IBAT7U 566
133 #define IBAT7L 567
135 #define DBAT0U 536
136 #define DBAT0L 537
137 #define DBAT1U 538
138 #define DBAT1L 539
139 #define DBAT2U 540
140 #define DBAT2L 541
141 #define DBAT3U 542
142 #define DBAT3L 543
144 #define DBAT4U 568
145 #define DBAT4L 569
146 #define DBAT5U 570
147 #define DBAT5L 571
148 #define DBAT6U 572
149 #define DBAT6L 573
150 #define DBAT7U 574
151 #define DBAT7L 575
154 #define rdspr(reg) \
155 ({ unsigned long val; asm volatile("mfspr %0,%1":"=r"(val):"i"(reg)); val; })
157 #define wrspr(reg, val) \
158 do { asm volatile("mtspr %0,%1"::"i"(reg),"r"(val)); } while(0)
161 #define rddcr(reg) \
162 ({ unsigned long val; asm volatile("mfdcr %0,%1":"=r"(val):"i"(reg)); val; })
164 #define wrdcr(reg, val) \
165 do { asm volatile("mtdcr %0,%1"::"i"(reg),"r"(val)); } while(0)
167 #endif /* SUPPORT_H_ */