Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst First try to bring evbarm installation clos...
details: https://anonhg.NetBSD.org/src/rev/456b131bf106
branches: trunk
changeset: 968566:456b131bf106
user: martin <martin%NetBSD.org@localhost>
date: Mon Jan 20 21:26:35 2020 +0000
description:
First try to bring evbarm installation closer to current reality.
diffstat:
usr.sbin/sysinst/README.md_defs | 26 +++++-
usr.sbin/sysinst/arch/evbarm/md.c | 185 +++++++++++++++++++------------------
usr.sbin/sysinst/arch/evbarm/md.h | 35 ++++++-
usr.sbin/sysinst/bsddisklabel.c | 55 ++++++++--
usr.sbin/sysinst/defs.h | 7 +-
usr.sbin/sysinst/disklabel.c | 12 ++-
usr.sbin/sysinst/mbr.c | 6 +-
usr.sbin/sysinst/part_edit.c | 6 +-
usr.sbin/sysinst/util.c | 149 +++++++++++++++++++++++++++---
9 files changed, 357 insertions(+), 124 deletions(-)
diffs (truncated from 848 to 300 lines):
diff -r 4c89405ee9e5 -r 456b131bf106 usr.sbin/sysinst/README.md_defs
--- a/usr.sbin/sysinst/README.md_defs Mon Jan 20 19:45:27 2020 +0000
+++ b/usr.sbin/sysinst/README.md_defs Mon Jan 20 21:26:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: README.md_defs,v 1.3 2019/12/10 06:25:50 isaki Exp $ */
+/* $NetBSD: README.md_defs,v 1.4 2020/01/20 21:26:35 martin Exp $ */
The following is trying to document the most important machine dependent
defines used in the sysinst code.
@@ -71,6 +71,24 @@
returns true if this setup needs boot blocks. Used for example on x86
when UEFI installs do not need any bootblocks, but BIOS ones do.
+MD_MAY_SWAP_TO may be undefined
+
+used like:
+
+ bool MD_MAY_SWAP_TO(const char *disk_name)
+
+returns true if the disk is usable as a swap device. Typical implementation
+in utils.c:may_swap_if_not_sdmmc.
+
+MD_SET_EXTRACT_FINALIZE may be undefined
+
+used like:
+
+ int MD_SET_EXTRACT_FINALIZE(int update)
+
+extracts any additional parts of the distribution. Returns an error code
+if something fails.
+
HAVE_PLAIN_DISKLABEL_BOOT may be undefined, only used on architectures
that have MBR as primary with disklabel as
@@ -90,3 +108,9 @@
offering the disklabel partitioning scheme. This allows ports to use
kernel translation for the disklabel ioctls (e.g. x68k uses Human68k
partitions this way).
+
+
+HAVE_GPT_BOOT defined if the architecture can boot from GPT
+
+NO_DISKLABEL_BOOT defined if the architecture can NOT boot
+ from a disklabel partitioned disk
diff -r 4c89405ee9e5 -r 456b131bf106 usr.sbin/sysinst/arch/evbarm/md.c
--- a/usr.sbin/sysinst/arch/evbarm/md.c Mon Jan 20 19:45:27 2020 +0000
+++ b/usr.sbin/sysinst/arch/evbarm/md.c Mon Jan 20 21:26:35 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: md.c,v 1.12 2020/01/09 17:06:46 martin Exp $ */
+/* $NetBSD: md.c,v 1.13 2020/01/20 21:26:35 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -81,8 +81,13 @@
void
md_init_set_status(int flags)
{
- if (boardtype == BOARD_TYPE_RPI)
- set_kernel_set(SET_KERNEL_RPI);
+
+ /*
+ * we will extract kernel variants and DTB files piecwise
+ * manually later, just fetch the kernel set, do not
+ * unpack it.
+ */
+ set_noextract_set(SET_KERNEL_1);
}
bool
@@ -111,10 +116,7 @@
pm->dlsize = ps->size_limit;
}
- if (boardtype == BOARD_TYPE_RPI)
- return set_bios_geom_with_mbr_guess(pm->parts);
-
- return true;
+ return edit_outer_parts(pm->parts);
}
/*
@@ -134,16 +136,13 @@
{
size_t i;
- if (boardtype == BOARD_TYPE_NORMAL)
- return true;
- if (boardtype == BOARD_TYPE_RPI) {
- for (i = 0; i < install->num; i++)
- if (install->infos[i].fs_type == FS_MSDOS)
- return true;
+ for (i = 0; i < install->num; i++)
+ if (install->infos[i].fs_type == FS_MSDOS)
+ return true;
- msg_display(MSG_nomsdospart);
- process_menu(MENU_ok, NULL);
- }
+ msg_display(MSG_nomsdospart);
+ process_menu(MENU_ok, NULL);
+
return false;
}
@@ -195,13 +194,43 @@
}
int
-md_post_extract(struct install_partition_desc *install)
+evbarm_extract_finalize(int update)
{
+ distinfo *dist;
char kernelbin[100];
+ int (*saved_fetch_fn)(const char *);
+#ifdef _LP64
+#define EFIBOOT "/usr/mdec/bootaa64.efi"
+#else
+#define EFIBOOT "/usr/mdec/bootarm.efi"
+#endif
+
+ dist = get_set_distinfo(SET_KERNEL_1);
+ if (dist == NULL)
+ return 0;
- if (boardtype == BOARD_TYPE_NORMAL)
+ saved_fetch_fn = fetch_fn;
+ extract_file_to(dist, false, "/", "./netbsd", false);
+ fetch_fn = NULL;
+ make_target_dir("/boot/EFI/boot");
+ if (target_file_exists_p(EFIBOOT))
+ cp_within_target(EFIBOOT, "/boot/EFI/boot", 0);
+
+ if (boardtype == BOARD_TYPE_ACPI) {
+ fetch_fn = saved_fetch_fn;
return 0;
+ }
+ if (boardtype == BOARD_TYPE_NORMAL) {
+ make_target_dir("/boot/dtb");
+ extract_file_to(dist, false, "/boot/dtb", "*.dt*", false);
+ extract_file_to(dist, false, "/boot", "./netbsd.ub", false);
+ fetch_fn = saved_fetch_fn;
+ return 0;
+ }
if (boardtype == BOARD_TYPE_RPI) {
+ extract_file_to(dist, false, "/boot", "./netbsd.img", false);
+ extract_file_to(dist, false, "/boot", "./bcm*.dtb", false);
+ fetch_fn = saved_fetch_fn;
snprintf(kernelbin, 100, "%s/netbsd.img", targetroot_mnt);
if (file_exists_p(kernelbin)) {
run_program(RUN_DISPLAY,
@@ -212,6 +241,14 @@
return 1;
}
}
+ fetch_fn = saved_fetch_fn;
+ return 0;
+}
+
+int
+md_post_extract(struct install_partition_desc *install)
+{
+
return 0;
}
@@ -252,86 +289,36 @@
struct mbr_partition *part;
int i, hasboot=0;
- if (boardtype == BOARD_TYPE_NORMAL)
- return 2;
- /* raspi code */
- if (boardtype == BOARD_TYPE_RPI) {
- for (ext = mbri; ext; ext = ext->extended) {
- part = ext->mbr.mbr_parts;
- for (i=0, hasboot=0; i < MBR_PART_COUNT; part++, i++) {
- if (part->mbrp_type != MBR_PTYPE_FAT16L &&
- part->mbrp_type != MBR_PTYPE_FAT32L)
- continue;
- hasboot = 1;
- break;
- }
- }
- if (!hasboot) {
- if (quiet)
- return 2;
- msg_display(MSG_nomsdospart);
- return ask_reedit(parts);
+ for (ext = mbri; ext; ext = ext->extended) {
+ part = ext->mbr.mbr_parts;
+ for (i=0, hasboot=0; i < MBR_PART_COUNT; part++, i++) {
+ if (part->mbrp_type != MBR_PTYPE_FAT16L &&
+ part->mbrp_type != MBR_PTYPE_FAT32L)
+ continue;
+ hasboot = 1;
+ break;
}
}
+ if (!hasboot) {
+ if (quiet)
+ return 2;
+ msg_display(MSG_nomsdospart);
+ return ask_reedit(parts);
+ }
+
return 2;
}
bool
md_parts_use_wholedisk(struct disk_partitions *parts)
{
- part_id nbsd, boot;
- struct disk_part_info info;
- daddr_t offset;
-
- /*
- * XXX - set (U)EFI install depending on boardtype
- */
-
- if (boardtype == BOARD_TYPE_NORMAL) {
- /* this keeps it from creating /boot as msdos */
- pm->bootsize = 0;
- return parts_use_wholedisk(parts, 0, NULL);
- }
-
- /* raspi code */
- if (boardtype == BOARD_TYPE_RPI) {
-
- for (boot = 0; boot < parts->num_part; boot++) {
- if (!parts->pscheme->get_part_info(parts, boot, &info))
- continue;
- if (info.nat_type == NULL)
- continue;
- if (info.nat_type->generic_ptype == PT_FAT)
- break;
- }
+ struct disk_part_info boot_part = {
+ .size = boardtype == BOARD_TYPE_NORMAL ?
+ PART_BOOT_LARGE/512 : PART_BOOT/512,
+ .fs_type = PART_BOOT_TYPE, .fs_sub_type = MBR_PTYPE_FAT16L,
+ };
- if (boot >= parts->num_part) {
- /* It's hopelessly corrupt, punt for now */
- msg_display(MSG_nomsdospart);
- process_menu(MENU_ok, NULL);
- return false;
- }
- pm->bootstart = info.start;
- pm->bootsize = info.size;
- offset = info.start + info.size + 1;
- memset(&info, 0, sizeof info);
- info.start = offset;
- info.size = parts->pscheme->max_free_space_at(parts, offset);
- info.nat_type = parts->pscheme->get_generic_part_type(PT_root);
- info.fs_type = FS_BSDFFS;
- info.fs_sub_type = 2;
-
- nbsd = parts->pscheme->add_partition(parts, &info, NULL);
- if (nbsd == NO_PART)
- return false;
-
- parts->pscheme->get_part_info(parts, nbsd, &info);
- pm->ptstart = info.start;
- pm->ptsize = info.size;
- return true;
- }
-
- return parts_use_wholedisk(parts, 0, NULL);
+ return parts_use_wholedisk(parts, 1, &boot_part);
}
/* returns false if no write-back of parts is required */
@@ -353,3 +340,23 @@
return true;
}
#endif
+
+void
+evbarm_part_defaults(struct pm_devs *my_pm, struct part_usage_info *infos,
+ size_t num_usage_infos)
+{
+ size_t i;
+
+ if (boardtype != BOARD_TYPE_NORMAL)
+ return;
+
+ for (i = 0; i < num_usage_infos; i++) {
+ if (infos[i].fs_type == PART_BOOT_TYPE &&
+ infos[i].mount != NULL &&
+ strcmp(infos[i].mount, PART_BOOT_MOUNT) == 0) {
+ infos[i].size = PART_BOOT_LARGE;
+ return;
+ }
+ }
+}
+
diff -r 4c89405ee9e5 -r 456b131bf106 usr.sbin/sysinst/arch/evbarm/md.h
--- a/usr.sbin/sysinst/arch/evbarm/md.h Mon Jan 20 19:45:27 2020 +0000
+++ b/usr.sbin/sysinst/arch/evbarm/md.h Mon Jan 20 21:26:35 2020 +0000
Home |
Main Index |
Thread Index |
Old Index