|
|
1.1 root 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 <stdint.h>
14: #include <rtas.h>
15: #include "rtas_board.h"
16: #include <bmc.h>
17: #include <rtas_i2c_bmc.h>
18: #include <rtas_ipmi_bmc.h>
19: #include "libipmi.h"
20: #include <hw.h>
21:
22: void io_init(void);
1.1.1.2 ! root 23: short reg_get_flashside(void);
! 24: void rtas_init(void);
1.1 root 25:
26: typedef struct {
27: uint64_t r3;
28: uint64_t addr;
29: volatile uint64_t id;
30: } slave_t;
31:
32: volatile slave_t rtas_slave_interface;
33:
1.1.1.2 ! root 34: static void
1.1 root 35: rtas_slave_loop(volatile slave_t * pIface)
36: {
37: uint64_t mask = pIface->id;
38: pIface->id = 0;
39: while (pIface->id != mask); {
40: int dly = 0x1000;
41: while (dly--);
42: }
43: pIface->id = 0;
1.1.1.2 ! root 44: asm volatile (" mr 3,%0 ; mtctr %1 ; bctr "
! 45: ::"r"(pIface->r3), "r"(pIface->addr));
1.1 root 46: }
47:
48: void
49: rtas_fetch_slaves(rtas_args_t * pArgs)
50: {
51: int retVal = 0;
52: int idx = 0;
53: uint32_t mask = pArgs->args[0] & 0xFFFFFFFE;
54: uint64_t *rtas_slave_loop_ptr = (uint64_t *)rtas_slave_loop;
55: while (mask) {
56: if (mask & 0x1) {
57: rtas_slave_interface.id = idx | 0x100;
58: *(int *) 0x3fc0 = (int)(unsigned long) &rtas_slave_interface; // r3
59: *(int *) 0x3f80 = *rtas_slave_loop_ptr; // addr
60: *(int *) 0x3fa0 = idx | 0x100; // pid
61: while (rtas_slave_interface.id);
62: }
63: mask >>= 1;
64: idx++;
65: }
66: pArgs->args[pArgs->nargs] = retVal;
67: }
68:
69: void
70: rtas_start_cpu(rtas_args_t * pArgs)
71: {
72: int retVal = 0;
73: int idx = pArgs->args[0]; // pid
74: rtas_slave_interface.r3 = pArgs->args[2]; // r3
75: rtas_slave_interface.addr = pArgs->args[1]; // addr
76: asm(" sync ");
77: rtas_slave_interface.id = idx | 0x100; // pid
78: while (rtas_slave_interface.id);
79: pArgs->args[pArgs->nargs] = retVal;
80: }
81:
82: void
83: rtas_read_vpd(rtas_args_t * pArgs)
84: {
85: pArgs->args[pArgs->nargs] =
86: bmc_read_vpd((uint8_t *) (uint64_t) pArgs->args[2], pArgs->args[1],
87: pArgs->args[0]);
88: }
89:
90: void
91: rtas_write_vpd(rtas_args_t * pArgs)
92: {
93: pArgs->args[pArgs->nargs] =
94: bmc_write_vpd((uint8_t *) (uint64_t) pArgs->args[2], pArgs->args[1],
95: pArgs->args[0]);
96: }
97:
98: void
99: rtas_set_indicator(rtas_args_t * pArgs)
100: {
101: pArgs->args[pArgs->nargs] = -1;
102: }
103:
104: void
105: rtas_event_scan(rtas_args_t * pArgs)
106: {
107: pArgs->args[pArgs->nargs] = -1;
108: }
109:
110: void
111: rtas_stop_bootwatchdog(rtas_args_t * pArgs)
112: {
113: pArgs->args[pArgs->nargs] = bmc_stop_bootwatchdog();
114: }
115:
116: void
117: rtas_set_bootwatchdog(rtas_args_t * pArgs)
118: {
119: pArgs->args[pArgs->nargs] = bmc_set_bootwatchdog(pArgs->args[0]);
120: }
121:
122: void
123: rtas_set_flashside(rtas_args_t * pArgs)
124: {
125: pArgs->args[pArgs->nargs] = bmc_set_flashside(pArgs->args[0]);
126: }
127:
128: void
129: rtas_get_flashside(rtas_args_t * pArgs)
130: {
131: int retVal = bmc_get_flashside();
132: pArgs->args[pArgs->nargs] = retVal;
133: }
134:
135: void
136: rtas_flash_test(rtas_args_t * pArgs)
137: {
138: pArgs->args[pArgs->nargs] = -1;
139: }
140:
141: void
142: rtas_system_reboot(rtas_args_t * pArgs)
143: {
144: bmc_system_reboot();
145: pArgs->args[pArgs->nargs] = -1;
146: }
147:
148: void
149: rtas_power_off(rtas_args_t * pArgs)
150: {
151: bmc_power_off();
152: pArgs->args[pArgs->nargs] = -1;
153: }
154:
155: void
156: rtas_get_blade_descr(rtas_args_t * pArgs)
157: {
158: uint8_t *buffer = (uint8_t *) (uint64_t) pArgs->args[0];
159: uint32_t maxlen = pArgs->args[1];
160: uint32_t retlen = 0;
161: uint32_t retval = bmc_get_blade_descr(buffer, maxlen, &retlen);
162: pArgs->args[pArgs->nargs] = retlen;
163: pArgs->args[pArgs->nargs + 1] = retval;
164: }
165:
166: // for JS20 cannot read blade descr
1.1.1.2 ! root 167: static uint32_t
1.1 root 168: dummy_get_blade_descr(uint8_t *dst, uint32_t maxlen, uint32_t *len)
169: {
170: // to not have a warning we need to do _something_ with *dst and maxlen...
171: *dst = *dst;
172: maxlen = maxlen;
173: *len = 0;
174: return -1;
175: }
176:
177: /* read flashside from register */
178: short
179: reg_get_flashside(void)
180: {
181: short retVal;
182: uint8_t val = load8_ci(0xf4003fe3);
183: if (val & 0x80) {
184: // temp
185: retVal = 1;
186: } else {
187: // perm
188: retVal = 0;
189: }
190: return retVal;
191: }
192:
193: void
194: rtas_init(void)
195: {
196: io_init();
197: if (u4Flag) {
198: bmc_system_reboot = ipmi_system_reboot;
199: bmc_power_off = ipmi_power_off;
200: bmc_set_flashside = ipmi_set_flashside;
201: bmc_get_flashside = reg_get_flashside;
202: bmc_stop_bootwatchdog = ipmi_oem_stop_bootwatchdog;
203: bmc_set_bootwatchdog = ipmi_oem_set_bootwatchdog;
204: bmc_read_vpd = ipmi_oem_read_vpd;
205: bmc_write_vpd = ipmi_oem_write_vpd;
206: bmc_get_blade_descr = ipmi_oem_get_blade_descr;
207: } else {
208: bmc_system_reboot = i2c_system_reboot;
209: bmc_power_off = i2c_power_off;
210: bmc_set_flashside = i2c_set_flashside;
211: bmc_get_flashside = i2c_get_flashside;
212: bmc_stop_bootwatchdog = i2c_stop_bootwatchdog;
213: bmc_set_bootwatchdog = i2c_set_bootwatchdog;
214: bmc_read_vpd = i2c_read_vpd;
215: bmc_write_vpd = i2c_write_vpd;
216: bmc_get_blade_descr = dummy_get_blade_descr;
217: }
218: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.