/[pupa]/pupa/util/i386/pc/pupa-setup.c
ViewVC logotype

Diff of /pupa/util/i386/pc/pupa-setup.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by okuji, Thu Jan 2 23:46:21 2003 UTC revision 1.3 by okuji, Mon Jan 6 00:01:35 2003 UTC
# Line 29  Line 29 
29  #include <pupa/machine/partition.h>  #include <pupa/machine/partition.h>
30  #include <pupa/machine/util/biosdisk.h>  #include <pupa/machine/util/biosdisk.h>
31  #include <pupa/machine/boot.h>  #include <pupa/machine/boot.h>
32    #include <pupa/machine/kernel.h>
33    
34  #include <stdio.h>  #include <stdio.h>
35  #include <unistd.h>  #include <unistd.h>
# Line 74  setup (const char *prefix, const char *d Line 75  setup (const char *prefix, const char *d
75    pupa_uint8_t *boot_drive;    pupa_uint8_t *boot_drive;
76    pupa_uint32_t *kernel_sector;    pupa_uint32_t *kernel_sector;
77    struct boot_blocklist *first_block, *block;    struct boot_blocklist *first_block, *block;
78      pupa_int32_t *install_dos_part, *install_bsd_part;
79      char *install_prefix;
80    char *tmp_img;    char *tmp_img;
81    int i;    int i;
82    unsigned long first_sector;    unsigned long first_sector;
# Line 172  setup (const char *prefix, const char *d Line 175  setup (const char *prefix, const char *d
175    first_block = (struct boot_blocklist *) (core_img    first_block = (struct boot_blocklist *) (core_img
176                                             + PUPA_DISK_SECTOR_SIZE                                             + PUPA_DISK_SECTOR_SIZE
177                                             - sizeof (*block));                                             - sizeof (*block));
178      
179      install_dos_part = (pupa_int32_t *) (core_img + PUPA_DISK_SECTOR_SIZE
180                                           + PUPA_KERNEL_MACHINE_INSTALL_DOS_PART);
181      install_bsd_part = (pupa_int32_t *) (core_img + PUPA_DISK_SECTOR_SIZE
182                                           + PUPA_KERNEL_MACHINE_INSTALL_BSD_PART);
183      install_prefix = (core_img + PUPA_DISK_SECTOR_SIZE
184                        + PUPA_KERNEL_MACHINE_PREFIX);
185    
186    /* Open the root device and the destination device.  */    /* Open the root device and the destination device.  */
187    root_dev = pupa_device_open (root);    root_dev = pupa_device_open (root);
188    if (! root_dev)    if (! root_dev)
# Line 227  setup (const char *prefix, const char *d Line 237  setup (const char *prefix, const char *d
237            block->start = 0;            block->start = 0;
238            block->len = 0;            block->len = 0;
239            block->segment = 0;            block->segment = 0;
240    
241              /* Embed information about the installed location.  */
242              if (root_dev->disk->partition)
243                {
244                  *install_dos_part
245                    = pupa_cpu_to_le32 (root_dev->disk->partition->dos_part);
246                  *install_bsd_part
247                    = pupa_cpu_to_le32 (root_dev->disk->partition->bsd_part);
248                }
249              else
250                *install_dos_part = *install_bsd_part = pupa_cpu_to_le32 (-1);
251    
252              strcpy (install_prefix, prefix);
253                        
254            /* Write the core image onto the disk.  */            /* Write the core image onto the disk.  */
255            if (pupa_disk_write (dest_dev->disk, 1, 0, core_size, core_img))            if (pupa_disk_write (dest_dev->disk, 1, 0, core_size, core_img))
# Line 363  setup (const char *prefix, const char *d Line 386  setup (const char *prefix, const char *d
386    else    else
387      *boot_drive = 0xFF;      *boot_drive = 0xFF;
388    
389    /* Write the first sector of the core image onto the disk.  */    /* Embed information about the installed location.  */
390      if (root_dev->disk->partition)
391        {
392          *install_dos_part
393            = pupa_cpu_to_le32 (root_dev->disk->partition->dos_part);
394          *install_bsd_part
395            = pupa_cpu_to_le32 (root_dev->disk->partition->bsd_part);
396        }
397      else
398        *install_dos_part = *install_bsd_part = pupa_cpu_to_le32 (-1);
399      
400      strcpy (install_prefix, prefix);
401      
402      /* Write the first two sectors of the core image onto the disk.  */
403    core_path = pupa_util_get_path (dir, core_file);    core_path = pupa_util_get_path (dir, core_file);
404    pupa_util_info ("opening the core image `%s'", core_path);    pupa_util_info ("opening the core image `%s'", core_path);
405    fp = fopen (core_path, "r+b");    fp = fopen (core_path, "r+b");
406    if (! fp)    if (! fp)
407      pupa_util_error ("Cannot open `%s'", core_path);      pupa_util_error ("Cannot open `%s'", core_path);
408    
409    pupa_util_write_image (core_img, PUPA_DISK_SECTOR_SIZE, fp);    pupa_util_write_image (core_img, PUPA_DISK_SECTOR_SIZE * 2, fp);
410    fclose (fp);    fclose (fp);
411    free (core_path);    free (core_path);
412    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26