4 #include <linux/spinlock.h>
8 * Definitions for talking to the RTAS on CHRP machines.
10 * Copyright (C) 2001 Peter Bergner
11 * Copyright (C) 2001 PPC 64 Team, IBM Corp
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
19 #define RTAS_UNKNOWN_SERVICE (-1)
20 #define RTAS_INSTANTIATE_MAX (1UL<<30) /* Don't instantiate rtas at/above this value */
23 * In general to call RTAS use rtas_token("string") to lookup
24 * an RTAS token for the given string (e.g. "event-scan").
25 * To actually perform the call use
26 * ret = rtas_call(token, n_in, n_out, ...)
27 * Where n_in is the number of input parameters and
28 * n_out is the number of output parameters
30 * If the "string" is invalid on this system, RTAS_UNKOWN_SERVICE
31 * will be returned as a token. rtas_call() does look for this
32 * token and error out gracefully so rtas_call(rtas_token("str"), ...)
33 * may be safely used for one-shot calls to RTAS.
37 typedef u32 rtas_arg_t;
47 rtas_arg_t *rets; /* Pointer to return values in args[]. */
51 unsigned long entry; /* physical address pointer */
52 unsigned long base; /* physical address pointer */
56 struct device_node *dev; /* virtual address pointer */
60 #define INTERNAL_ERROR 0x80000000 /* set bit 0 */
61 #define EPOW_WARNING 0x40000000 /* set bit 1 */
62 #define POWERMGM_EVENTS 0x20000000 /* set bit 2 */
63 #define HOTPLUG_EVENTS 0x10000000 /* set bit 3 */
64 #define EVENT_SCAN_ALL_EVENTS 0xf0000000
66 /* event-scan returns */
67 #define SEVERITY_FATAL 0x5
68 #define SEVERITY_ERROR 0x4
69 #define SEVERITY_ERROR_SYNC 0x3
70 #define SEVERITY_WARNING 0x2
71 #define SEVERITY_EVENT 0x1
72 #define SEVERITY_NO_ERROR 0x0
73 #define DISP_FULLY_RECOVERED 0x0
74 #define DISP_LIMITED_RECOVERY 0x1
75 #define DISP_NOT_RECOVERED 0x2
76 #define PART_PRESENT 0x0
77 #define PART_NOT_PRESENT 0x1
78 #define INITIATOR_UNKNOWN 0x0
79 #define INITIATOR_CPU 0x1
80 #define INITIATOR_PCI 0x2
81 #define INITIATOR_ISA 0x3
82 #define INITIATOR_MEMORY 0x4
83 #define INITIATOR_POWERMGM 0x5
84 #define TARGET_UNKNOWN 0x0
85 #define TARGET_CPU 0x1
86 #define TARGET_PCI 0x2
87 #define TARGET_ISA 0x3
88 #define TARGET_MEMORY 0x4
89 #define TARGET_POWERMGM 0x5
90 #define TYPE_RETRY 0x01
91 #define TYPE_TCE_ERR 0x02
92 #define TYPE_INTERN_DEV_FAIL 0x03
93 #define TYPE_TIMEOUT 0x04
94 #define TYPE_DATA_PARITY 0x05
95 #define TYPE_ADDR_PARITY 0x06
96 #define TYPE_CACHE_PARITY 0x07
97 #define TYPE_ADDR_INVALID 0x08
98 #define TYPE_ECC_UNCORR 0x09
99 #define TYPE_ECC_CORR 0x0a
100 #define TYPE_EPOW 0x40
101 /* I don't add PowerMGM events right now, this is a different topic */
102 #define TYPE_PMGM_POWER_SW_ON 0x60
103 #define TYPE_PMGM_POWER_SW_OFF 0x61
104 #define TYPE_PMGM_LID_OPEN 0x62
105 #define TYPE_PMGM_LID_CLOSE 0x63
106 #define TYPE_PMGM_SLEEP_BTN 0x64
107 #define TYPE_PMGM_WAKE_BTN 0x65
108 #define TYPE_PMGM_BATTERY_WARN 0x66
109 #define TYPE_PMGM_BATTERY_CRIT 0x67
110 #define TYPE_PMGM_SWITCH_TO_BAT 0x68
111 #define TYPE_PMGM_SWITCH_TO_AC 0x69
112 #define TYPE_PMGM_KBD_OR_MOUSE 0x6a
113 #define TYPE_PMGM_ENCLOS_OPEN 0x6b
114 #define TYPE_PMGM_ENCLOS_CLOSED 0x6c
115 #define TYPE_PMGM_RING_INDICATE 0x6d
116 #define TYPE_PMGM_LAN_ATTENTION 0x6e
117 #define TYPE_PMGM_TIME_ALARM 0x6f
118 #define TYPE_PMGM_CONFIG_CHANGE 0x70
119 #define TYPE_PMGM_SERVICE_PROC 0x71
121 struct rtas_error_log {
122 unsigned long version:8; /* Architectural version */
123 unsigned long severity:3; /* Severity level of error */
124 unsigned long disposition:2; /* Degree of recovery */
125 unsigned long extended:1; /* extended log present? */
126 unsigned long /* reserved */ :2; /* Reserved for future use */
127 unsigned long initiator:4; /* Initiator of event */
128 unsigned long target:4; /* Target of failed operation */
129 unsigned long type:8; /* General event or error*/
130 unsigned long extended_log_length:32; /* length in bytes */
131 unsigned char buffer[1]; /* allocated by klimit bump */
136 unsigned long length;
139 /* This struct is very similar but not identical to
140 * that needed by the rtas flash update.
141 * All we need to do for rtas is rewrite num_blocks
142 * into a version/length and translate the pointers
145 #define FLASH_BLOCKS_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct flash_block))
146 struct flash_block_list {
147 unsigned long num_blocks;
148 struct flash_block_list *next;
149 struct flash_block blocks[FLASH_BLOCKS_PER_NODE];
151 struct flash_block_list_header { /* just the header of flash_block_list */
152 unsigned long num_blocks;
153 struct flash_block_list *next;
155 extern struct flash_block_list_header rtas_firmware_flash_list;
157 extern struct rtas_t rtas;
159 extern void enter_rtas(struct rtas_args *);
160 extern int rtas_token(const char *service);
161 extern long rtas_call(int token, int, int, unsigned long *, ...);
162 extern void phys_call_rtas(int, int, int, ...);
163 extern void phys_call_rtas_display_status(char);
164 extern void call_rtas_display_status(char);
165 extern void rtas_restart(char *cmd);
166 extern void rtas_power_off(void);
167 extern void rtas_halt(void);
169 extern struct proc_dir_entry *rtas_proc_dir;
171 /* Some RTAS ops require a data buffer and that buffer must be < 4G.
172 * Rather than having a memory allocator, just use this buffer
173 * (get the lock first), make the RTAS call. Copy the data instead
174 * of holding the buffer for long.
176 #define RTAS_DATA_BUF_SIZE 1024
177 extern spinlock_t rtas_data_buf_lock;
178 extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
180 #endif /* _PPC64_RTAS_H */