Add Cserve_Get_VM_Time
[qemu-palcode.git] / protos.h
blob3ed13811f0c0b6014a5da6efa33cb4139e9d4d77
1 /* Declarations common the the C portions of the QEMU PALcode console.
3 Copyright (C) 2011 Richard Henderson
5 This file is part of QEMU PALcode.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the text
15 of the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef PROTOS_H
22 #define PROTOS_H 1
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include <stddef.h>
27 #include <string.h>
31 * Call_Pal functions.
34 static inline void wrent(void *cb, unsigned long which)
36 register void *a0 __asm__("$16") = cb;
37 register unsigned long a1 __asm__("$17") = which;
39 asm volatile ("call_pal 0x34"
40 : "+r"(a0), "+r"(a1)
41 : : "$1", "$22", "$23", "$24", "$25");
44 static inline unsigned long swpipl(unsigned long newipl)
46 register unsigned long v0 __asm__("$0");
47 register unsigned long a0 __asm__("$16") = newipl;
49 asm volatile ("call_pal 0x35"
50 : "=r"(v0), "+r"(a0)
51 : : "$1", "$22", "$23", "$24", "$25");
53 return v0;
56 static inline unsigned long rdps(void)
58 register unsigned long v0 __asm__("$0");
60 asm volatile ("call_pal 0x36"
61 : "=r"(v0) : : "$1", "$22", "$23", "$24", "$25");
63 return v0;
66 static inline void wrkgp(void)
68 asm volatile ("mov $29, $16\n\tcall_pal 0x37"
69 : : : "$16", "$1", "$22", "$23", "$24", "$25");
72 static inline unsigned long wtint(unsigned long skip)
74 register unsigned long v0 __asm__("$0");
75 register unsigned long a0 __asm__("$16") = skip;
77 asm volatile ("call_pal 0x3e"
78 : "=r"(v0), "+r"(a0)
79 : : "$1", "$22", "$23", "$24", "$25");
81 return v0;
84 /*
85 * Cserve functions.
88 static inline unsigned long ldq_p(unsigned long addr)
90 register unsigned long v0 __asm__("$0");
91 register unsigned long a0 __asm__("$16") = 1;
92 register unsigned long a1 __asm__("$17") = addr;
94 asm volatile ("call_pal 9"
95 : "=r"(v0), "+r"(a0), "+r"(a1) :
96 : "$18", "$19", "$20", "$21");
98 return v0;
101 static inline unsigned long stq_p(unsigned long port, unsigned long val)
103 register unsigned long v0 __asm__("$0");
104 register unsigned long a0 __asm__("$16") = 2;
105 register unsigned long a1 __asm__("$17") = port;
106 register unsigned long a2 __asm__("$18") = val;
108 asm volatile ("call_pal 9"
109 : "=r"(v0), "+r"(a0), "+r"(a1), "+r"(a2) :
110 : "$19", "$20", "$21");
112 return v0;
115 static inline unsigned long get_wall_time(void)
117 register unsigned long v0 __asm__("$0");
118 register unsigned long a0 __asm__("$16") = 3;
120 asm("call_pal 9" : "=r"(v0), "+r"(a0) : : "$17", "$18", "$19", "$20", "$21");
122 return v0;
125 static inline unsigned long get_alarm(void)
127 register unsigned long v0 __asm__("$0");
128 register unsigned long a0 __asm__("$16") = 4;
130 asm("call_pal 9" : "=r"(v0), "+r"(a0) : : "$17", "$18", "$19", "$20", "$21");
132 return v0;
135 static inline void set_alarm_rel(unsigned long nsec)
137 register unsigned long a0 __asm__("$16") = 5;
138 register unsigned long a1 __asm__("$17") = nsec;
140 asm volatile ("call_pal 9"
141 : "+r"(a0), "+r"(a1)
142 : : "$0", "$18", "$19", "$20", "$21");
145 static inline void set_alarm_abs(unsigned long nsec)
147 register unsigned long a0 __asm__("$16") = 6;
148 register unsigned long a1 __asm__("$17") = nsec;
150 asm volatile ("call_pal 9"
151 : "+r"(a0), "+r"(a1)
152 : : "$0", "$18", "$19", "$20", "$21");
156 * I/O functions
159 extern void *pci_io_base;
160 extern void *pci_mem_base;
162 static inline uint8_t inb(unsigned long port)
164 return *(volatile uint8_t *)(pci_io_base + port);
167 static inline uint16_t inw(unsigned long port)
169 return *(volatile uint16_t *)(pci_io_base + port);
172 static inline uint32_t inl(unsigned long port)
174 return *(volatile uint32_t *)(pci_io_base + port);
177 static inline void outb(uint8_t val, unsigned long port)
179 *(volatile uint8_t *)(pci_io_base + port) = val;
182 static inline void outw(uint16_t val, unsigned long port)
184 *(volatile uint16_t *)(pci_io_base + port) = val;
187 static inline void outl(uint32_t val, unsigned long port)
189 *(volatile uint32_t *)(pci_io_base + port) = val;
193 * CRB functions
196 extern unsigned long crb_dispatch(long select, long a1, long a2,
197 long a3, long a4);
198 extern unsigned long crb_fixup(unsigned long vptptr, unsigned long hwrpb);
201 * The Console
204 extern bool have_vga;
206 extern void do_console(void);
207 extern void entInt(void);
210 * Utils
213 extern int printf(const char *, ...);
214 extern void ndelay(unsigned long nsec);
216 static inline void udelay(unsigned long msec)
218 ndelay(msec * 1000);
222 * Initialization
224 extern void ps2port_setup(void);
225 extern void pci_setup(void);
226 extern void vgahw_init(void);
228 #endif /* PROTOS_H */