root/arch/ppc/kernel/mk_ramdisk.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 #include <stdio.h>
   2 
   3 extern long ce_exec_config[];
   4 
   5 main(int argc, char *argv[])
     /* [previous][next][first][last][top][bottom][index][help] */
   6 {
   7         FILE *out, *in;
   8         int i, cnt, pos;
   9         unsigned char *lp;
  10         unsigned char buf[4096];
  11         if (argc != 3)
  12         {
  13                 fprintf(stderr, "usage: %s <in-file> <out-file>\n", argv[0]);
  14                 exit(1);
  15         }
  16         if ((out = fopen(argv[2], "w")) == (FILE *)0)
  17         {
  18                 fprintf(stderr, "Can't create '%s'\n", argv[2]);
  19                 exit(1);
  20         }
  21         if ((in = fopen(argv[1], "r")) == (FILE *)0)
  22         {
  23                 fprintf(stderr, "Can't open '%s'\n", argv[1]);
  24                 exit(1);
  25         }
  26         fprintf(out, "#\n");
  27         fprintf(out, "# Miscellaneous data structures:\n");
  28         fprintf(out, "# WARNING - this file is automatically generated!\n");
  29         fprintf(out, "#\n");
  30         fprintf(out, "\n");
  31         fprintf(out, "\t.data\n");
  32         fprintf(out, "\t.globl builtin_ramdisk_image\n");
  33         fprintf(out, "builtin_ramdisk_image:\n");
  34         pos = 0;
  35         while (fread(buf, sizeof(buf), 1, in) == 1)
  36         {
  37                 cnt = 0;
  38                 lp = (unsigned char *)buf;
  39                 for (i = 0;  i < sizeof(buf);  i += 4)
  40                 {
  41                         if (cnt == 0)
  42                         {
  43                                 fprintf(out, "\t.long\t");
  44                         }
  45                         fprintf(out, "0x%02X%02X%02X%02X", lp[0], lp[1], lp[2], lp[3]);
  46                         lp += 4;
  47                         if (++cnt == 4)
  48                         {
  49                                 cnt = 0;
  50                                 fprintf(out, " # %x \n", pos+i-12);
  51                                 fflush(out);
  52                         } else
  53                         {
  54                                 fprintf(out, ",");
  55                         }
  56                 }
  57                 pos += sizeof(buf);
  58         }
  59         fprintf(out, "\t.globl builtin_ramdisk_size\n");
  60         fprintf(out, "builtin_ramdisk_size:\t.long\t0x%x\n", pos);
  61         fflush(out);
  62         fclose(out);
  63         exit(0);
  64 }
  65 

/* [previous][next][first][last][top][bottom][index][help] */