Skip to content

Commit bf55ca7

Browse files
author
Stefan Reinauer
committed
detok 1.0.2 merge commit II
git-svn-id: svn://coreboot.org/openbios/fcode-utils@104 f158a5a8-5612-0410-a976-696ce0be7e32
1 parent f33144f commit bf55ca7

2 files changed

Lines changed: 45 additions & 9 deletions

File tree

detok/decode.c

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
#include "detok.h"
4040
#include "stream.h"
41+
#include "addfcodes.h"
4142

4243
static int indent; /* Current level of indentation */
4344

@@ -125,8 +126,7 @@ static void pretty_print_string(void)
125126
static void decode_lines(void)
126127
{
127128
if (show_linenumbers) {
128-
printf("%6d: ",
129-
show_offsets ? token_streampos : linenum++);
129+
printf("%6d: ",show_offsets ? token_streampos : linenum++);
130130
}
131131
}
132132

@@ -384,6 +384,18 @@ static void blit(void)
384384
printf("0x%x\n", lit);
385385
}
386386

387+
static void double_length_literal(void)
388+
{
389+
u16 quadhh, quadhl, quadlh, quadll;
390+
391+
output_token();
392+
quadhh = get_num16();
393+
quadhl = get_num16();
394+
quadlh = get_num16();
395+
quadll = get_num16();
396+
printf("0x%04x.%04x.%04x.%04x\n", quadhh, quadhl, quadlh, quadll);
397+
}
398+
387399
static void offset16(void)
388400
{
389401
decode_default();
@@ -536,10 +548,28 @@ static void decode_token(u16 token)
536548
end_found = TRUE;
537549
decode_default();
538550
break;
551+
552+
#if 0 /* Fooey on C's petty limitations! */
553+
/* I'd like to be able to do this: */
554+
/* Special Functions */
555+
case *double_lit_code:
556+
double_length_literal();
557+
break;
558+
#endif /* Fooey on C's petty limitations! */
559+
539560
default:
561+
{
562+
/* Have to do this clumsy thing instead */
563+
if ( token == *double_lit_code )
564+
{
565+
double_length_literal();
566+
break;
567+
}
568+
540569
decode_default();
541570
}
542571
}
572+
}
543573

544574

545575
/* **************************************************************************
@@ -556,15 +586,18 @@ static void decode_token(u16 token)
556586
* Outputs:
557587
* Returned Value: NONE
558588
* Global/Static Variables:
559-
* offs16 FALSE if Starter was version1, else TRUE
589+
* offs16 FALSE if Starter was version1, TRUE for all
590+
* other valid Starters, otherwise unchanged.
560591
* fclen On error, gets set to reach end of input stream
561592
* Otherwise, gets set by decode_start()
562593
* Printout:
594+
* On error, print a new-line to finish previous token's line.
563595
*
564596
* Error Detection:
565597
* First byte not a valid FCode Start: Print message, restore
566598
* input pointer to initial value, set fclen to [(end of
567-
* input stream) - (input pointer)], return FALSE.
599+
* input stream) - (input pointer)], leave offs16 unchanged.
600+
* Return FALSE.
568601
*
569602
* Process Explanation:
570603
* This routine error-checks and dispatches to the routine that
@@ -578,18 +611,20 @@ static void decode_fcode_header(void)
578611
{
579612
long err_pos;
580613
u16 token;
614+
bool new_offs16 = TRUE;
581615

582616
err_pos = get_streampos();
583617
indent = 0;
584618
token = next_token();
585-
offs16 = TRUE;
619+
586620
switch (token) {
587621
case 0x0fd: /* version1 */
588-
offs16 = FALSE;
622+
new_offs16 = FALSE;
589623
case 0x0f0: /* start0 */
590624
case 0x0f1: /* start1 */
591625
case 0x0f2: /* start2 */
592626
case 0x0f3: /* start4 */
627+
offs16 = new_offs16;
593628
decode_start();
594629
break;
595630
default:

detok/detok.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "stream.h"
4646
#include "addfcodes.h"
4747

48-
#define DETOK_VERSION "1.0.0"
48+
#define DETOK_VERSION "1.0.2"
4949

5050
#define CORE_COPYR "(C) Copyright 2001-2006 Stefan Reinauer.\n" \
5151
"(C) Copyright 2006 coresystems GmbH <info@coresystems.de>"
@@ -69,8 +69,8 @@ static void print_copyright(bool is_error)
6969
CORE_COPYR "\n" IBM_COPYR "\n"
7070
"Written by Stefan Reinauer, <stepan@openbios.org>\n"
7171
"This program is free software; you may redistribute it "
72-
"under the terms of\nthe GNU General Public License v2. This "
73-
"program has absolutely no warranty.\n\n");
72+
"under the terms of\nthe GNU General Public License v2. "
73+
"This program has absolutely no warranty.\n\n");
7474

7575
pfunct = (is_error ? (vfunct) printf : printremark);
7676

@@ -190,3 +190,4 @@ int main(int argc, char **argv)
190190

191191
return 0;
192192
}
193+

0 commit comments

Comments
 (0)