These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / SLOF / slof / ppc64.c
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #include <cpu.h>
14
15 /* the exception frame should be page aligned
16  * the_exception_frame is used by the handler to store a copy of all
17  * registers after an exception; this copy can then be used by paflof's
18  * exception handler to printout a register dump */
19 cell the_exception_frame[0x400 / CELLSIZE] __attribute__ ((aligned(PAGE_SIZE)));;
20
21 /* the_client_frame is the register save area when starting a client */
22 cell the_client_frame[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
23 cell the_client_stack[0x8000 / CELLSIZE] __attribute__ ((aligned(0x100)));
24 /* THE forth stack */
25 cell the_data_stack[0x2000 / CELLSIZE] __attribute__ ((aligned(0x100)));
26 /* the forth return stack */
27 cell the_return_stack[0x2000 / CELLSIZE] __attribute__ ((aligned(0x100)));
28
29 /* forth stack and return-stack pointers */
30 cell *restrict dp;
31 cell *restrict rp;
32
33 /* terminal input buffer */
34 cell the_tib[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
35 /* temporary string buffers */
36 char the_pockets[NUMPOCKETS * POCKETSIZE] __attribute__ ((aligned(0x100)));
37
38 cell the_comp_buffer[0x1000 / CELLSIZE] __attribute__ ((aligned(0x100)));
39
40 cell the_heap[HEAP_SIZE / CELLSIZE] __attribute__ ((aligned(0x1000)));
41 cell *the_heap_start = &the_heap[0];
42 cell *the_heap_end = &the_heap[HEAP_SIZE / CELLSIZE];
43
44 extern void io_putchar(unsigned char);
45 extern unsigned long call_c(cell arg0, cell arg1, cell arg2, cell entry);
46
47
48 long
49 writeLogByte_wrapper(long x, long y)
50 {
51         unsigned long result;
52
53         SET_CI;
54         result = writeLogByte(x, y);
55         CLR_CI;
56
57         return result;
58 }
59
60
61 /**
62  * Standard write function for the libc.
63  *
64  * @param fd    file descriptor (should always be 1 or 2)
65  * @param buf   pointer to the array with the output characters
66  * @param count number of bytes to be written
67  * @return      the number of bytes that have been written successfully
68  */
69 int
70 write(int fd, const void *buf, int count)
71 {
72         int i;
73         char *ptr = (char *)buf;
74
75         if (fd != 1 && fd != 2)
76                 return 0;
77
78         for (i = 0; i < count; i++) {
79                 if (*ptr == '\n')
80                         io_putchar('\r');
81                 io_putchar(*ptr++);
82         }
83
84         return i;
85 }
86
87 /* This should probably be temporary until a better solution is found */
88 void
89 asm_cout(long Character, long UART, long NVRAM __attribute__((unused)))
90 {
91         if (UART)
92                 io_putchar(Character);
93 }