2 * Extended Boot Option ROM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Copyright IBM Corporation, 2007
19 * Authors: Anthony Liguori <aliguori@us.ibm.com>
26 int main(int argc
, char **argv
)
29 char buffer
[512], oldbuffer
[512];
34 printf("Usage: %s ROM OUTPUT\n", argv
[0]);
38 fin
= fopen(argv
[1], "rb");
39 fout
= fopen(argv
[2], "wb");
41 if (fin
== NULL
|| fout
== NULL
) {
42 fprintf(stderr
, "Could not open input/output files\n");
47 size
= fread(buffer
, 512, 1, fin
);
49 for (i
= 0; i
< 512; i
++)
53 if (fwrite(oldbuffer
, 512, 1, fout
) != 1) {
54 fprintf(stderr
, "Write failed\n");
59 memcpy(oldbuffer
, buffer
, 512);
64 fprintf(stderr
, "Failed to read from input file\n");
68 oldbuffer
[511] = -sum
;
70 if (fwrite(oldbuffer
, 512, 1, fout
) != 1) {
71 fprintf(stderr
, "Failed to write to output file\n");