| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#include "acpi.h" |
| 45 |
#include "accommon.h" |
| 46 |
#include "acdebug.h" |
| 47 |
|
| 48 |
|
| 49 |
#define _COMPONENT ACPI_CA_DEBUGGER |
| 50 |
ACPI_MODULE_NAME ("osgendbg") |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
static void |
| 56 |
AcpiDbRunRemoteDebugger ( |
| 57 |
char *BatchBuffer); |
| 58 |
|
| 59 |
|
| 60 |
static ACPI_MUTEX AcpiGbl_DbCommandReady; |
| 61 |
static ACPI_MUTEX AcpiGbl_DbCommandComplete; |
| 62 |
static BOOLEAN AcpiGbl_DbCommandSignalsInitialized = FALSE; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
static void |
| 79 |
AcpiDbRunRemoteDebugger ( |
| 80 |
char *BatchBuffer) |
| 81 |
{ |
| 82 |
ACPI_STATUS Status; |
| 83 |
char *Ptr = BatchBuffer; |
| 84 |
char *Cmd = Ptr; |
| 85 |
|
| 86 |
|
| 87 |
while (!AcpiGbl_DbTerminateLoop) |
| 88 |
{ |
| 89 |
if (BatchBuffer) |
| 90 |
{ |
| 91 |
if (*Ptr) |
| 92 |
{ |
| 93 |
while (*Ptr) |
| 94 |
{ |
| 95 |
if (*Ptr == ',') |
| 96 |
{ |
| 97 |
|
| 98 |
*Ptr = ' '; |
| 99 |
} |
| 100 |
else if (*Ptr == ';') |
| 101 |
{ |
| 102 |
*Ptr = '\0'; |
| 103 |
continue; |
| 104 |
} |
| 105 |
|
| 106 |
Ptr++; |
| 107 |
} |
| 108 |
|
| 109 |
AcpiUtSafeStrncpy (AcpiGbl_DbLineBuf, Cmd, ACPI_DB_LINE_BUFFER_SIZE); |
| 110 |
Ptr++; |
| 111 |
Cmd = Ptr; |
| 112 |
} |
| 113 |
else |
| 114 |
{ |
| 115 |
return; |
| 116 |
} |
| 117 |
} |
| 118 |
else |
| 119 |
{ |
| 120 |
|
| 121 |
|
| 122 |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
if (!AcpiGbl_MethodExecuting) |
| 127 |
{ |
| 128 |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); |
| 129 |
} |
| 130 |
else |
| 131 |
{ |
| 132 |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, |
| 138 |
ACPI_DB_LINE_BUFFER_SIZE, NULL); |
| 139 |
if (ACPI_FAILURE (Status)) |
| 140 |
{ |
| 141 |
return; |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); |
| 150 |
|
| 151 |
Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, |
| 152 |
ACPI_WAIT_FOREVER); |
| 153 |
if (ACPI_FAILURE (Status)) |
| 154 |
{ |
| 155 |
return; |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
ACPI_STATUS |
| 175 |
AcpiOsWaitCommandReady ( |
| 176 |
void) |
| 177 |
{ |
| 178 |
ACPI_STATUS Status = AE_OK; |
| 179 |
|
| 180 |
|
| 181 |
if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) |
| 182 |
{ |
| 183 |
Status = AE_TIME; |
| 184 |
|
| 185 |
while (Status == AE_TIME) |
| 186 |
{ |
| 187 |
if (AcpiGbl_DbTerminateLoop) |
| 188 |
{ |
| 189 |
Status = AE_CTRL_TERMINATE; |
| 190 |
} |
| 191 |
else |
| 192 |
{ |
| 193 |
Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, 1000); |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
else |
| 198 |
{ |
| 199 |
|
| 200 |
|
| 201 |
AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
if (!AcpiGbl_MethodExecuting) |
| 206 |
{ |
| 207 |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); |
| 208 |
} |
| 209 |
else |
| 210 |
{ |
| 211 |
AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, |
| 217 |
ACPI_DB_LINE_BUFFER_SIZE, NULL); |
| 218 |
} |
| 219 |
|
| 220 |
if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) |
| 221 |
{ |
| 222 |
ACPI_EXCEPTION ((AE_INFO, Status, |
| 223 |
"While parsing/handling command line")); |
| 224 |
} |
| 225 |
return (Status); |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
ACPI_STATUS |
| 243 |
AcpiOsNotifyCommandComplete ( |
| 244 |
void) |
| 245 |
{ |
| 246 |
|
| 247 |
if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) |
| 248 |
{ |
| 249 |
AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); |
| 250 |
} |
| 251 |
return (AE_OK); |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
ACPI_STATUS |
| 268 |
AcpiOsInitializeDebugger ( |
| 269 |
void) |
| 270 |
{ |
| 271 |
ACPI_STATUS Status; |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady); |
| 277 |
if (ACPI_FAILURE (Status)) |
| 278 |
{ |
| 279 |
return (Status); |
| 280 |
} |
| 281 |
Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete); |
| 282 |
if (ACPI_FAILURE (Status)) |
| 283 |
{ |
| 284 |
goto ErrorReady; |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, |
| 290 |
ACPI_WAIT_FOREVER); |
| 291 |
if (ACPI_FAILURE (Status)) |
| 292 |
{ |
| 293 |
goto ErrorComplete; |
| 294 |
} |
| 295 |
Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, |
| 296 |
ACPI_WAIT_FOREVER); |
| 297 |
if (ACPI_FAILURE (Status)) |
| 298 |
{ |
| 299 |
goto ErrorComplete; |
| 300 |
} |
| 301 |
|
| 302 |
AcpiGbl_DbCommandSignalsInitialized = TRUE; |
| 303 |
return (Status); |
| 304 |
|
| 305 |
ErrorComplete: |
| 306 |
AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); |
| 307 |
ErrorReady: |
| 308 |
AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); |
| 309 |
return (Status); |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
void |
| 326 |
AcpiOsTerminateDebugger ( |
| 327 |
void) |
| 328 |
{ |
| 329 |
|
| 330 |
if (AcpiGbl_DbCommandSignalsInitialized) |
| 331 |
{ |
| 332 |
AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); |
| 333 |
AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
void |
| 352 |
AcpiRunDebugger ( |
| 353 |
char *BatchBuffer) |
| 354 |
{ |
| 355 |
|
| 356 |
|
| 357 |
if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) |
| 358 |
{ |
| 359 |
AcpiDbRunRemoteDebugger (BatchBuffer); |
| 360 |
} |
| 361 |
else |
| 362 |
{ |
| 363 |
AcpiDbUserCommands (); |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
ACPI_EXPORT_SYMBOL (AcpiRunDebugger) |