Deleted Added
full compact
cvdisasm.c (316303) cvdisasm.c (322877)
1/******************************************************************************
2 *
3 * Module Name: cvcompiler - ASL-/ASL+ converter functions
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *

--- 142 unchanged lines hidden (view full) ---

151
152#include <contrib/dev/acpica/compiler/aslcompiler.h>
153#include <contrib/dev/acpica/include/acparser.h>
154#include <contrib/dev/acpica/include/amlcode.h>
155#include <contrib/dev/acpica/include/acdebug.h>
156#include <contrib/dev/acpica/include/acconvert.h>
157
158
1/******************************************************************************
2 *
3 * Module Name: cvcompiler - ASL-/ASL+ converter functions
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *

--- 142 unchanged lines hidden (view full) ---

151
152#include <contrib/dev/acpica/compiler/aslcompiler.h>
153#include <contrib/dev/acpica/include/acparser.h>
154#include <contrib/dev/acpica/include/amlcode.h>
155#include <contrib/dev/acpica/include/acdebug.h>
156#include <contrib/dev/acpica/include/acconvert.h>
157
158
159/* Local prototypes */
160
159static void
160CvPrintInclude(
161 ACPI_FILE_NODE *FNode,
162 UINT32 Level);
163
164static BOOLEAN
165CvListIsSingleton (
166 ACPI_COMMENT_NODE *CommentList);

--- 26 unchanged lines hidden (view full) ---

193 {
194 Previous = Current;
195 if (Current->Comment)
196 {
197 AcpiDmIndent(Level);
198 AcpiOsPrintf("%s\n", Current->Comment);
199 Current->Comment = NULL;
200 }
161static void
162CvPrintInclude(
163 ACPI_FILE_NODE *FNode,
164 UINT32 Level);
165
166static BOOLEAN
167CvListIsSingleton (
168 ACPI_COMMENT_NODE *CommentList);

--- 26 unchanged lines hidden (view full) ---

195 {
196 Previous = Current;
197 if (Current->Comment)
198 {
199 AcpiDmIndent(Level);
200 AcpiOsPrintf("%s\n", Current->Comment);
201 Current->Comment = NULL;
202 }
203
201 Current = Current->Next;
202 AcpiOsReleaseObject(AcpiGbl_RegCommentCache, Previous);
203 }
204}
205
206
207/*******************************************************************************
208 *
209 * FUNCTION: CvListIsSingleton
210 *
204 Current = Current->Next;
205 AcpiOsReleaseObject(AcpiGbl_RegCommentCache, Previous);
206 }
207}
208
209
210/*******************************************************************************
211 *
212 * FUNCTION: CvListIsSingleton
213 *
211 * PARAMETERS: CommentList -- check to see if this is a single item list.
214 * PARAMETERS: CommentList - check to see if this is a single item list.
212 *
213 * RETURN: BOOLEAN
214 *
215 * DESCRIPTION: Returns TRUE if CommentList only contains 1 node.
216 *
217 ******************************************************************************/
218
219static BOOLEAN
220CvListIsSingleton (
221 ACPI_COMMENT_NODE *CommentList)
222
223{
215 *
216 * RETURN: BOOLEAN
217 *
218 * DESCRIPTION: Returns TRUE if CommentList only contains 1 node.
219 *
220 ******************************************************************************/
221
222static BOOLEAN
223CvListIsSingleton (
224 ACPI_COMMENT_NODE *CommentList)
225
226{
227
224 if (!CommentList)
225 {
228 if (!CommentList)
229 {
226 return FALSE;
230 return (FALSE);
227 }
228 else if (CommentList->Next)
229 {
231 }
232 else if (CommentList->Next)
233 {
230 return FALSE;
234 return (FALSE);
231 }
232
235 }
236
233 return TRUE;
237 return (TRUE);
234}
235
236
237/*******************************************************************************
238 *
239 * FUNCTION: CvPrintOneCommentType
240 *
241 * PARAMETERS: Op

--- 28 unchanged lines hidden (view full) ---

270 {
271 CvPrintOneCommentList (Op->Common.CommentList, Level);
272 AcpiOsPrintf ("\n");
273 }
274 else
275 {
276 CvPrintOneCommentList (Op->Common.CommentList, Level);
277 }
238}
239
240
241/*******************************************************************************
242 *
243 * FUNCTION: CvPrintOneCommentType
244 *
245 * PARAMETERS: Op

--- 28 unchanged lines hidden (view full) ---

274 {
275 CvPrintOneCommentList (Op->Common.CommentList, Level);
276 AcpiOsPrintf ("\n");
277 }
278 else
279 {
280 CvPrintOneCommentList (Op->Common.CommentList, Level);
281 }
282
278 Op->Common.CommentList = NULL;
279 return;
280
281 case AML_COMMENT_ENDBLK:
282
283 if (Op->Common.EndBlkComment)
284 {
285 CvPrintOneCommentList (Op->Common.EndBlkComment, Level);

--- 23 unchanged lines hidden (view full) ---

309 break;
310
311 default:
312 return;
313 }
314
315 if (*CommentToPrint)
316 {
283 Op->Common.CommentList = NULL;
284 return;
285
286 case AML_COMMENT_ENDBLK:
287
288 if (Op->Common.EndBlkComment)
289 {
290 CvPrintOneCommentList (Op->Common.EndBlkComment, Level);

--- 23 unchanged lines hidden (view full) ---

314 break;
315
316 default:
317 return;
318 }
319
320 if (*CommentToPrint)
321 {
322 CommentExists = TRUE;
317 AcpiOsPrintf ("%s", *CommentToPrint);
318 *CommentToPrint = NULL;
319 }
320
321 if (CommentExists && EndStr)
322 {
323 AcpiOsPrintf ("%s", EndStr);
324 }
325}
326
327
328/*******************************************************************************
329 *
330 * FUNCTION: CvCloseBraceWriteComment
331 *
332 * PARAMETERS: Op
333 * Level
334 *
323 AcpiOsPrintf ("%s", *CommentToPrint);
324 *CommentToPrint = NULL;
325 }
326
327 if (CommentExists && EndStr)
328 {
329 AcpiOsPrintf ("%s", EndStr);
330 }
331}
332
333
334/*******************************************************************************
335 *
336 * FUNCTION: CvCloseBraceWriteComment
337 *
338 * PARAMETERS: Op
339 * Level
340 *
335 * RETURN: none
341 * RETURN: None
336 *
337 * DESCRIPTION: Print a close brace } and any open brace comments associated
338 * with this parse object.
339 * This is referred as ASL_CV_CLOSE_BRACE.
340 *
341 ******************************************************************************/
342
343void
344CvCloseBraceWriteComment(
345 ACPI_PARSE_OBJECT *Op,
346 UINT32 Level)
347{
342 *
343 * DESCRIPTION: Print a close brace } and any open brace comments associated
344 * with this parse object.
345 * This is referred as ASL_CV_CLOSE_BRACE.
346 *
347 ******************************************************************************/
348
349void
350CvCloseBraceWriteComment(
351 ACPI_PARSE_OBJECT *Op,
352 UINT32 Level)
353{
354
348 if (!Gbl_CaptureComments)
349 {
350 AcpiOsPrintf ("}");
351 return;
352 }
353
354 CvPrintOneCommentType (Op, AML_COMMENT_ENDBLK, NULL, Level);
355 AcpiOsPrintf ("}");
356 CvPrintOneCommentType (Op, AML_COMMENT_CLOSE_BRACE, NULL, Level);
357}
358
359
360/*******************************************************************************
361 *
362 * FUNCTION: CvCloseParenWriteComment
363 *
364 * PARAMETERS: Op
365 * Level
366 *
355 if (!Gbl_CaptureComments)
356 {
357 AcpiOsPrintf ("}");
358 return;
359 }
360
361 CvPrintOneCommentType (Op, AML_COMMENT_ENDBLK, NULL, Level);
362 AcpiOsPrintf ("}");
363 CvPrintOneCommentType (Op, AML_COMMENT_CLOSE_BRACE, NULL, Level);
364}
365
366
367/*******************************************************************************
368 *
369 * FUNCTION: CvCloseParenWriteComment
370 *
371 * PARAMETERS: Op
372 * Level
373 *
367 * RETURN: none
374 * RETURN: None
368 *
369 * DESCRIPTION: Print a closing paren ) and any end node comments associated
370 * with this parse object.
371 * This is referred as ASL_CV_CLOSE_PAREN.
372 *
373 ******************************************************************************/
374
375void
376CvCloseParenWriteComment(
377 ACPI_PARSE_OBJECT *Op,
378 UINT32 Level)
379{
375 *
376 * DESCRIPTION: Print a closing paren ) and any end node comments associated
377 * with this parse object.
378 * This is referred as ASL_CV_CLOSE_PAREN.
379 *
380 ******************************************************************************/
381
382void
383CvCloseParenWriteComment(
384 ACPI_PARSE_OBJECT *Op,
385 UINT32 Level)
386{
387
380 if (!Gbl_CaptureComments)
381 {
382 AcpiOsPrintf (")");
383 return;
384 }
385
386 /*
387 * If this op has a BLOCK_BRACE, then output the comment when the

--- 33 unchanged lines hidden (view full) ---

421 * This is referred as ASL_CV_FILE_HAS_SWITCHED.
422 *
423 ******************************************************************************/
424
425BOOLEAN
426CvFileHasSwitched(
427 ACPI_PARSE_OBJECT *Op)
428{
388 if (!Gbl_CaptureComments)
389 {
390 AcpiOsPrintf (")");
391 return;
392 }
393
394 /*
395 * If this op has a BLOCK_BRACE, then output the comment when the

--- 33 unchanged lines hidden (view full) ---

429 * This is referred as ASL_CV_FILE_HAS_SWITCHED.
430 *
431 ******************************************************************************/
432
433BOOLEAN
434CvFileHasSwitched(
435 ACPI_PARSE_OBJECT *Op)
436{
437
429 if (Op->Common.CvFilename &&
430 AcpiGbl_CurrentFilename &&
431 AcpiUtStricmp(Op->Common.CvFilename, AcpiGbl_CurrentFilename))
432 {
438 if (Op->Common.CvFilename &&
439 AcpiGbl_CurrentFilename &&
440 AcpiUtStricmp(Op->Common.CvFilename, AcpiGbl_CurrentFilename))
441 {
433 return TRUE;
442 return (TRUE);
434 }
443 }
435 return FALSE;
444
445 return (FALSE);
436}
437
438
439/*******************************************************************************
440 *
441 * FUNCTION: CvPrintInclude
442 *
443 * PARAMETERS: FNode - Write an Include statement for the file that is pointed

--- 9 unchanged lines hidden (view full) ---

453 *
454 ******************************************************************************/
455
456static void
457CvPrintInclude(
458 ACPI_FILE_NODE *FNode,
459 UINT32 Level)
460{
446}
447
448
449/*******************************************************************************
450 *
451 * FUNCTION: CvPrintInclude
452 *
453 * PARAMETERS: FNode - Write an Include statement for the file that is pointed

--- 9 unchanged lines hidden (view full) ---

463 *
464 ******************************************************************************/
465
466static void
467CvPrintInclude(
468 ACPI_FILE_NODE *FNode,
469 UINT32 Level)
470{
471
461 if (!FNode || FNode->IncludeWritten)
462 {
463 return;
464 }
465
472 if (!FNode || FNode->IncludeWritten)
473 {
474 return;
475 }
476
466 CvDbgPrint ("Writing include for %s within %s\n", FNode->Filename, FNode->Parent->Filename);
477 CvDbgPrint ("Writing include for %s within %s\n",
478 FNode->Filename, FNode->Parent->Filename);
467 AcpiOsRedirectOutput (FNode->Parent->File);
468 CvPrintOneCommentList (FNode->IncludeComment, Level);
479 AcpiOsRedirectOutput (FNode->Parent->File);
480 CvPrintOneCommentList (FNode->IncludeComment, Level);
481
469 AcpiDmIndent (Level);
470 AcpiOsPrintf ("Include (\"%s\")\n", FNode->Filename);
482 AcpiDmIndent (Level);
483 AcpiOsPrintf ("Include (\"%s\")\n", FNode->Filename);
471 CvDbgPrint ("emitted the following: Include (\"%s\")\n", FNode->Filename);
484 CvDbgPrint ("emitted the following: Include (\"%s\")\n",
485 FNode->Filename);
472 FNode->IncludeWritten = TRUE;
473}
474
475
476/*******************************************************************************
477 *
478 * FUNCTION: CvSwitchFiles
479 *
486 FNode->IncludeWritten = TRUE;
487}
488
489
490/*******************************************************************************
491 *
492 * FUNCTION: CvSwitchFiles
493 *
480 * PARAMETERS: Level - indentation level
494 * PARAMETERS: Level - indentation level
481 * Op
482 *
483 * RETURN: None
484 *
485 * DESCRIPTION: Switch the outputfile and write ASL Include statement. Note,
486 * this function emits actual ASL code rather than comments.
487 * This is referred as ASL_CV_SWITCH_FILES.
488 *
489 ******************************************************************************/
490
491void
492CvSwitchFiles(
493 UINT32 Level,
494 ACPI_PARSE_OBJECT *Op)
495{
496 char *Filename = Op->Common.CvFilename;
497 ACPI_FILE_NODE *FNode;
495 * Op
496 *
497 * RETURN: None
498 *
499 * DESCRIPTION: Switch the outputfile and write ASL Include statement. Note,
500 * this function emits actual ASL code rather than comments.
501 * This is referred as ASL_CV_SWITCH_FILES.
502 *
503 ******************************************************************************/
504
505void
506CvSwitchFiles(
507 UINT32 Level,
508 ACPI_PARSE_OBJECT *Op)
509{
510 char *Filename = Op->Common.CvFilename;
511 ACPI_FILE_NODE *FNode;
512 ACPI_FILE_NODE *Current;
498
513
499 CvDbgPrint ("Switching from %s to %s\n", AcpiGbl_CurrentFilename, Filename);
514
515 CvDbgPrint ("Switching from %s to %s\n", AcpiGbl_CurrentFilename,
516 Filename);
500 FNode = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
501 if (!FNode)
502 {
503 /*
504 * At this point, each Filename should exist in AcpiGbl_FileTreeRoot
505 * if it does not exist, then abort.
506 */
507 FlDeleteFile (ASL_FILE_AML_OUTPUT);
517 FNode = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
518 if (!FNode)
519 {
520 /*
521 * At this point, each Filename should exist in AcpiGbl_FileTreeRoot
522 * if it does not exist, then abort.
523 */
524 FlDeleteFile (ASL_FILE_AML_OUTPUT);
508 sprintf (MsgBuffer, "\"Cannot find %s\" - %s", Filename, strerror (errno));
509 AslCommonError (ASL_ERROR, ASL_MSG_OPEN, 0, 0, 0, 0, NULL, MsgBuffer);
525 sprintf (MsgBuffer, "\"Cannot find %s\" - %s",
526 Filename, strerror (errno));
527 AslCommonError (ASL_ERROR, ASL_MSG_OPEN, 0, 0, 0, 0,
528 NULL, MsgBuffer);
510 AslAbort ();
511 }
512
529 AslAbort ();
530 }
531
532 Current = FNode;
533
513 /*
514 * If the previous file is a descendent of the current file,
515 * make sure that Include statements from the current file
516 * to the previous have been emitted.
517 */
534 /*
535 * If the previous file is a descendent of the current file,
536 * make sure that Include statements from the current file
537 * to the previous have been emitted.
538 */
518 while (FNode &&
519 FNode->Parent &&
520 AcpiUtStricmp (FNode->Filename, AcpiGbl_CurrentFilename))
539 while (Current &&
540 Current->Parent &&
541 AcpiUtStricmp (Current->Filename, AcpiGbl_CurrentFilename))
521 {
542 {
522 CvPrintInclude (FNode, Level);
523 FNode = FNode->Parent;
543 CvPrintInclude (Current, Level);
544 Current = Current->Parent;
524 }
525
545 }
546
526 /* Redirect output to the Op->Common.CvFilename */
547 /* Redirect output to Op->Common.CvFilename */
527
548
528 FNode = CvFilenameExists (Filename, AcpiGbl_FileTreeRoot);
529 AcpiOsRedirectOutput (FNode->File);
530 AcpiGbl_CurrentFilename = FNode->Filename;
531}
549 AcpiOsRedirectOutput (FNode->File);
550 AcpiGbl_CurrentFilename = FNode->Filename;
551}