~colinb/grub/cdbmain

« back to all changes in this revision

Viewing changes to util/i386/pc/grub-mkimage.c

  • Committer: Colin D Bennett
  • Date: 2008-08-03 03:57:46 UTC
  • mfrom: (820.8.1 trunk-clean)
  • Revision ID: colin@gibibit.com-20080803035746-0zn13x8oznory84l
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
  kernel_size = grub_util_get_image_size (kernel_path);
147
147
 
148
148
  total_module_size = sizeof (struct grub_module_info);
 
149
 
 
150
  if (memdisk_path)
 
151
    {
 
152
      memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512);
 
153
      grub_util_info ("the size of memory disk is 0x%x", memdisk_size);
 
154
      total_module_size += memdisk_size + sizeof (struct grub_module_header);
 
155
    }
 
156
 
149
157
  for (p = path_list; p; p = p->next)
150
158
    total_module_size += (grub_util_get_image_size (p->name)
151
159
                          + sizeof (struct grub_module_header));
152
160
 
153
161
  grub_util_info ("the total module size is 0x%x", total_module_size);
154
162
 
155
 
  if (memdisk_path)
156
 
    {
157
 
      memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512);
158
 
      grub_util_info ("the size of memory disk is 0x%x", memdisk_size);
159
 
    }
160
 
 
161
 
  kernel_img = xmalloc (kernel_size + total_module_size + memdisk_size);
 
163
  kernel_img = xmalloc (kernel_size + total_module_size);
162
164
  grub_util_load_image (kernel_path, kernel_img);
163
165
 
164
166
  if (GRUB_KERNEL_MACHINE_PREFIX + strlen (prefix) + 1 > GRUB_KERNEL_MACHINE_DATA_END)
180
182
      mod_size = grub_util_get_image_size (p->name);
181
183
      
182
184
      header = (struct grub_module_header *) (kernel_img + offset);
183
 
      header->offset = grub_cpu_to_le32 (sizeof (*header));
 
185
      header->type = grub_cpu_to_le32 (OBJ_TYPE_ELF);
184
186
      header->size = grub_cpu_to_le32 (mod_size + sizeof (*header));
185
187
      offset += sizeof (*header);
186
188
 
190
192
 
191
193
  if (memdisk_path)
192
194
    {
 
195
      struct grub_module_header *header;
 
196
      
 
197
      header = (struct grub_module_header *) (kernel_img + offset);
 
198
      header->type = grub_cpu_to_le32 (OBJ_TYPE_MEMDISK);
 
199
      header->size = grub_cpu_to_le32 (memdisk_size + sizeof (*header));
 
200
      offset += sizeof (*header);
 
201
 
193
202
      grub_util_load_image (memdisk_path, kernel_img + offset);
194
203
      offset += memdisk_size;
195
204
    }
196
205
 
197
 
  compress_kernel (kernel_img, kernel_size + total_module_size + memdisk_size,
 
206
  compress_kernel (kernel_img, kernel_size + total_module_size,
198
207
                   &core_img, &core_size);
199
208
 
200
209
  grub_util_info ("the core size is 0x%x", core_size);
229
238
    = grub_cpu_to_le32 (total_module_size);
230
239
  *((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE))
231
240
    = grub_cpu_to_le32 (kernel_size);
232
 
  *((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE))
233
 
    = grub_cpu_to_le32 (memdisk_size);
234
241
  *((grub_uint32_t *) (core_img + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE))
235
242
    = grub_cpu_to_le32 (core_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
236
243