From owner-svn-ports-all@freebsd.org Tue Oct 18 14:23:53 2016 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D1AA4C16CCD; Tue, 18 Oct 2016 14:23:53 +0000 (UTC) (envelope-from db@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0168AEC; Tue, 18 Oct 2016 14:23:53 +0000 (UTC) (envelope-from db@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9IENqQZ020976; Tue, 18 Oct 2016 14:23:52 GMT (envelope-from db@FreeBSD.org) Received: (from db@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9IENpha020959; Tue, 18 Oct 2016 14:23:51 GMT (envelope-from db@FreeBSD.org) Message-Id: <201610181423.u9IENpha020959@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: db set sender to db@FreeBSD.org using -f From: Diane Bruce Date: Tue, 18 Oct 2016 14:23:51 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r424162 - in head/sysutils: . u-boot-rpi3 u-boot-rpi3/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2016 14:23:53 -0000 Author: db Date: Tue Oct 18 14:23:50 2016 New Revision: 424162 URL: https://svnweb.freebsd.org/changeset/ports/424162 Log: Initial u-boot port for the Raspberry Pi 3 Added: head/sysutils/u-boot-rpi3/ head/sysutils/u-boot-rpi3/Makefile (contents, props changed) head/sysutils/u-boot-rpi3/distinfo (contents, props changed) head/sysutils/u-boot-rpi3/files/ head/sysutils/u-boot-rpi3/files/patch-api_api.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-api_api__storage.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-common_cmd__elf.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-common_cmd__fdt.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-common_cmd__nvedit.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-common_cmd__test.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-drivers_mmc_mmc.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi-common.h (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi.h (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-include_efi__api.h (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__console.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__disk.c (contents, props changed) head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__net.c (contents, props changed) head/sysutils/u-boot-rpi3/pkg-descr (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Tue Oct 18 13:43:45 2016 (r424161) +++ head/sysutils/Makefile Tue Oct 18 14:23:50 2016 (r424162) @@ -1130,6 +1130,7 @@ SUBDIR += u-boot-pine64 SUBDIR += u-boot-rpi SUBDIR += u-boot-rpi2 + SUBDIR += u-boot-rpi3 SUBDIR += u-boot-sinovoip-bpi-m3 SUBDIR += u-boot-utilite SUBDIR += u-boot-wandboard Added: head/sysutils/u-boot-rpi3/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/Makefile Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,59 @@ +# $FreeBSD$ + +PORTNAME= u-boot +PORTVERSION= 2016.09 +CATEGORIES= sysutils +MASTER_SITES= ftp://ftp.denx.de/pub/u-boot/ \ + LOCAL/db:bootfiles +PKGNAMESUFFIX= -rpi3 +DISTFILES= u-boot-${PORTVERSION}.tar.bz2 \ + rpi3-boot-files-2016.05.tar.bz2:bootfiles + +MAINTAINER= db@FreeBSD.org +COMMENT= Cross-build U-Boot loader for RPi3 + +LICENSE= GPLv2 + +BUILD_DEPENDS= aarch64-none-elf-gcc:devel/aarch64-none-elf-gcc + +NO_ARCH= yes + +WRKSRC= ${WRKDIR}/u-boot-${DISTVERSION} +USES= gmake tar:bzip2 +SSP_UNSAFE= yes # cross-LD does not support -fstack-protector + +WRK_BOOTFILES= ${WRKDIR}/rpi3-boot-files-2016.05 + +U_BOOT_DIR= share/u-boot/${PORTNAME}${PKGNAMESUFFIX} +PLIST_FILES= ${U_BOOT_DIR}/u-boot.bin \ + ${U_BOOT_DIR}/README \ + ${U_BOOT_DIR}/bootcode.bin \ + ${U_BOOT_DIR}/fixup.dat \ + ${U_BOOT_DIR}/fixup_cd.dat \ + ${U_BOOT_DIR}/fixup_db.dat \ + ${U_BOOT_DIR}/fixup_x.dat \ + ${U_BOOT_DIR}/start.elf \ + ${U_BOOT_DIR}/start_cd.elf \ + ${U_BOOT_DIR}/start_db.elf \ + ${U_BOOT_DIR}/start_x.elf \ + ${U_BOOT_DIR}/config.txt \ + ${U_BOOT_DIR}/LICENCE.broadcom +MAKE_ARGS+= ARCH=arm \ + CROSS_COMPILE=aarch64-none-elf- \ + CONFIG_EFI=y + +do-configure: + (cd ${WRKSRC}; ${GMAKE} rpi_3_defconfig) + +# The output of the u-boot build process is u-boot.bin. Older firmware +# versions require a standard header, but the recent versions (our case) +# are capable of booting u-boot.bin directly. Also copy the entire +# contents of the bootfiles distribution (these are proprietary binary +# files required to boot). +do-install: + ${MKDIR} ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR} + ${INSTALL_DATA} ${WRKSRC}/u-boot.bin ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/ + ${INSTALL_DATA} ${DESCR} ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR}/README + ${INSTALL_DATA} ${WRK_BOOTFILES}/* ${STAGEDIR}/${PREFIX}/${U_BOOT_DIR} + +.include Added: head/sysutils/u-boot-rpi3/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/distinfo Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,5 @@ +TIMESTAMP = 1476719881 +SHA256 (u-boot-2016.09.tar.bz2) = 994e7b9e0e350d9f91f5892d5e5bff00d3714a4962f520f78a64a461ef950ba9 +SIZE (u-boot-2016.09.tar.bz2) = 11790685 +SHA256 (rpi3-boot-files-2016.05.tar.bz2) = 8d5a2e453c9140d989133bc7cd991456138f4eb6c9722cd9eee4af4c1722e216 +SIZE (rpi3-boot-files-2016.05.tar.bz2) = 6905733 Added: head/sysutils/u-boot-rpi3/files/patch-api_api.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-api_api.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,79 @@ +--- api/api.c.orig 2015-04-13 14:53:03 UTC ++++ api/api.c +@@ -495,45 +495,47 @@ static int API_env_set(va_list ap) + */ + static int API_env_enum(va_list ap) + { +- int i, n; +- char *last, **next; ++ int i; ++ char *last, **next, *s; ++ ENTRY *match, search; ++ static char *buf; + + last = (char *)va_arg(ap, u_int32_t); + + if ((next = (char **)va_arg(ap, u_int32_t)) == NULL) + return API_EINVAL; + +- if (last == NULL) +- /* start over */ +- *next = ((char *)env_get_addr(0)); +- else { +- *next = last; +- +- for (i = 0; env_get_char(i) != '\0'; i = n + 1) { +- for (n = i; env_get_char(n) != '\0'; ++n) { +- if (n >= CONFIG_ENV_SIZE) { +- /* XXX shouldn't we set *next = NULL?? */ +- return 0; +- } +- } +- +- if (envmatch((uchar *)last, i) < 0) +- continue; +- +- /* try to get next name */ +- i = n + 1; +- if (env_get_char(i) == '\0') { +- /* no more left */ +- *next = NULL; +- return 0; +- } +- +- *next = ((char *)env_get_addr(i)); +- return 0; ++ /* ++ * This leverages realloc's behavior of growing but never shrinking the ++ * existing buffer. ++ */ ++ if (last == NULL) { ++ i = 0; ++ buf = realloc(buf, 512); /* Start with reasonable size buf. */ ++ } else { ++ buf = realloc(buf, strlen(last) + 1); ++ strcpy(buf, last); ++ if ((s = strchr(buf, '=')) != NULL) ++ *s = 0; ++ search.key = buf; ++ if ((i = hsearch_r(search, FIND, &match, &env_htab, 0)) == 0) { ++ i = API_EINVAL; ++ goto done; + } + } + ++ /* hmatch on empty string is effectively "get next entry after i". */ ++ if ((i = hmatch_r("", i, &match, &env_htab)) == 0) ++ goto done; ++ buf = realloc(buf, strlen(match->key) + strlen(match->data) + 2); ++ snprintf(buf, buflen, "%s=%s", match->key, match->data); ++ *next = buf; + return 0; ++done: ++ free(buf); ++ buf = NULL; ++ *next = NULL; ++ return i; + } + + /* Added: head/sysutils/u-boot-rpi3/files/patch-api_api__storage.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-api_api__storage.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,28 @@ +--- api/api_storage.c.orig 2015-04-13 14:53:03 UTC ++++ api/api_storage.c +@@ -107,10 +107,13 @@ static int dev_stor_get(int type, int fi + + if (first) { + di->cookie = (void *)get_dev(specs[type].name, 0); +- if (di->cookie == NULL) ++ if (di->cookie == NULL) { + return 0; +- else ++ } else { + found = 1; ++ if (specs[type].max_dev > 1) ++ *more = 1; ++ } + + } else { + for (i = 0; i < specs[type].max_dev; i++) +@@ -146,7 +149,8 @@ static int dev_stor_get(int type, int fi + dd = (block_dev_desc_t *)di->cookie; + if (dd->type == DEV_TYPE_UNKNOWN) { + debugf("device instance exists, but is not active.."); +- found = 0; ++ di->di_stor.block_count = 0; ++ di->di_stor.block_size = 0; + } else { + di->di_stor.block_count = dd->lba; + di->di_stor.block_size = dd->blksz; Added: head/sysutils/u-boot-rpi3/files/patch-common_cmd__elf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-common_cmd__elf.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,29 @@ +--- common/cmd_elf.c.orig 2015-04-13 14:53:03 UTC ++++ common/cmd_elf.c +@@ -35,22 +35,12 @@ static unsigned long do_bootelf_exec(ulo + unsigned long ret; + + /* +- * QNX images require the data cache is disabled. +- * Data cache is already flushed, so just turn it off. +- */ +- int dcache = dcache_status(); +- if (dcache) +- dcache_disable(); +- +- /* +- * pass address parameter as argv[0] (aka command name), +- * and all remaining args ++ * FreeBSD wants the caches enabled while ubldr runs, and as of r276397 ++ * the kernel can tolerate being entered with internal (but not external ++ * PL310) caches enabled on armv6/7 systems. So don't disable caches ++ * here, just launch the program directly. + */ + ret = entry(argc, argv); +- +- if (dcache) +- dcache_enable(); +- + return ret; + } + Added: head/sysutils/u-boot-rpi3/files/patch-common_cmd__fdt.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-common_cmd__fdt.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,11 @@ +--- common/cmd_fdt.c.orig 2015-04-13 14:53:03 UTC ++++ common/cmd_fdt.c +@@ -44,7 +44,7 @@ void set_working_fdt_addr(ulong addr) + + buf = map_sysmem(addr, 0); + working_fdt = buf; +- setenv_ulong("fdtaddr", addr); ++ setenv_hex("fdtaddr", addr); + } + + /* Added: head/sysutils/u-boot-rpi3/files/patch-common_cmd__nvedit.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-common_cmd__nvedit.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,11 @@ +--- common/cmd_nvedit.c.orig 2015-04-13 14:53:03 UTC ++++ common/cmd_nvedit.c +@@ -321,7 +321,7 @@ int setenv_hex(const char *varname, ulon + { + char str[17]; + +- sprintf(str, "%lx", value); ++ sprintf(str, "%#lx", value); + return setenv(varname, str); + } + Added: head/sysutils/u-boot-rpi3/files/patch-common_cmd__test.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-common_cmd__test.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,19 @@ +--- common/cmd_test.c.orig 2015-04-13 14:53:03 UTC ++++ common/cmd_test.c +@@ -65,9 +65,14 @@ static int do_test(cmd_tbl_t *cmdtp, int + char * const *ap; + int i, op, left, adv, expr, last_expr, last_unop, last_binop; + +- /* args? */ +- if (argc < 3) ++ /* ++ * If no args, that's bogus, return false. ++ * If op is -z and no other args, answer is Yes, string is empty. ++ */ ++ if (argc < 2) + return 1; ++ else if (argc == 2) ++ return !(strcmp(argv[1], "-z") == 0); + + #ifdef DEBUG + { Added: head/sysutils/u-boot-rpi3/files/patch-drivers_mmc_mmc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-drivers_mmc_mmc.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,80 @@ +--- drivers/mmc/mmc.c.orig 2015-04-13 14:53:03 UTC ++++ drivers/mmc/mmc.c +@@ -20,6 +20,7 @@ + + static struct list_head mmc_devices; + static int cur_dev_num = -1; ++static int mmc_error_print_max = -1; + + __weak int board_mmc_getwp(struct mmc *mmc) + { +@@ -1560,9 +1561,14 @@ void mmc_destroy(struct mmc *mmc) + block_dev_desc_t *mmc_get_dev(int dev) + { + struct mmc *mmc = find_mmc_device(dev); +- if (!mmc || mmc_init(mmc)) ++ if (!mmc) + return NULL; + ++ /* If mmc_init fails, mmc->block_dev will be of type ++ * DEV_TYPE_UNKNOWN with blksz and lba set to zero. ++ */ ++ mmc_init(mmc); ++ + return &mmc->block_dev; + } + #endif +@@ -1594,7 +1600,7 @@ int mmc_start_init(struct mmc *mmc) + err = mmc->cfg->ops->init(mmc); + + if (err) +- return err; ++ goto done; + + mmc->ddr_mode = 0; + mmc_set_bus_width(mmc, 1); +@@ -1604,7 +1610,7 @@ int mmc_start_init(struct mmc *mmc) + err = mmc_go_idle(mmc); + + if (err) +- return err; ++ goto done; + + /* The internal partition reset to user partition(0) at every CMD0*/ + mmc->part_num = 0; +@@ -1621,15 +1627,33 @@ int mmc_start_init(struct mmc *mmc) + + if (err && err != IN_PROGRESS) { + #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) +- printf("Card did not respond to voltage select!\n"); ++ if (mmc_error_print_max < 4) { ++ mmc_error_print_max++; ++ printf("Card did not respond to voltage select!\n"); ++ ++ if (mmc_error_print_max == 4) { ++ printf("Discarding further error messages\n"); ++ } ++ } + #endif +- return UNUSABLE_ERR; ++// return UNUSABLE_ERR; ++ goto done; + } + } + + if (err == IN_PROGRESS) + mmc->init_in_progress = 1; + ++done: ++ if (err) { ++ mmc->has_init = 0; ++ mmc->block_dev.type = DEV_TYPE_UNKNOWN; ++ mmc->block_dev.blksz = 0; ++ mmc->block_dev.lba = 0; ++ } else { ++ mmc->has_init = 1; ++ } ++ + return err; + } + Added: head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi-common.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi-common.h Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,66 @@ +--- include/configs/rpi-common.h.orig 2015-04-13 14:53:03 UTC ++++ include/configs/rpi-common.h +@@ -183,4 +183,63 @@ + + #define CONFIG_BOOTDELAY 2 + ++/***************************************************************************** ++ * FreeBSD customizations from here down. ++ ****************************************************************************/ ++ ++/* Add the API and ELF features needed for ubldr. */ ++#ifndef CONFIG_SPL_BUILD ++#define CONFIG_API ++#define CONFIG_CMD_ELF ++#define CONFIG_CMD_ENV_EXISTS ++#define CONFIG_EFI_PARTITION ++#endif ++ ++/* Turn off dcache. */ ++#ifndef CONFIG_SPL_BUILD ++#define CONFIG_SYS_DCACHE_OFF ++#define CONFIG_CMD_CACHE ++#endif ++ ++#ifndef CONFIG_SPL_BUILD ++#define CONFIG_SYS_MMC_MAX_DEVICE 1 ++#endif ++ ++/* Create a small(ish) boot environment for FreeBSD. */ ++#ifndef CONFIG_SPL_BUILD ++#undef CONFIG_EXTRA_ENV_SETTINGS ++#define CONFIG_EXTRA_ENV_SETTINGS \ ++ ENV_DEVICE_SETTINGS \ ++ "loadaddr=0x02000000\0" \ ++ "scriptaddr=0x00000000\0" \ ++ "pxefile_addr_r=0x00100000\0" \ ++ "kernel_addr_r=0x01000000\0" \ ++ "ramdisk_addr_r=0x02100000\0" \ ++ "Fatboot=" \ ++ "env exists loaderdev || env set loaderdev ${fatdev}; " \ ++ "env exists UserFatboot && run UserFatboot; " \ ++ "echo Booting from: ${fatdev} ${bootfile}; " \ ++ "fatload ${fatdev} ${loadaddr} ${bootfile} && bootelf ${loadaddr}; " \ ++ "\0" \ ++ "Netboot=" \ ++ "env exists ethact || usb start; " \ ++ "env exists loaderdev || env set loaderdev net; " \ ++ "env exists UserNetboot && run UserNetboot; " \ ++ "dhcp ${loadaddr} ${bootfile} && bootelf ${loadaddr}; " \ ++ "\0" \ ++ "preboot=" \ ++ "fdt addr 0x100; " \ ++ "env exists bootfile || env set bootfile ubldr; " \ ++ "env exists SetupFatdev && run SetupFatdev; " \ ++ "env exists UserPreboot && run UserPreboot; " \ ++ "\0" \ ++ "SetupFatdev=" \ ++ "env exists fatdev || env set fatdev 'mmc 0'; " \ ++ "\0" ++#undef CONFIG_BOOTCOMMAND ++#define CONFIG_BOOTCOMMAND "run Fatboot" ++#undef CONFIG_PREBOOT ++#define CONFIG_PREBOOT "run preboot" ++#endif ++ + #endif Added: head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-include_configs_rpi.h Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,17 @@ +--- include/configs/rpi.h.orig 2016-09-12 14:05:51 UTC ++++ include/configs/rpi.h +@@ -108,11 +108,13 @@ + #endif + + /* Console UART */ ++/* + #ifdef CONFIG_BCM2837 + #define CONFIG_BCM283X_MU_SERIAL + #else ++*/ + #define CONFIG_PL01X_SERIAL +-#endif ++/* #endif */ + #define CONFIG_CONS_INDEX 0 + #define CONFIG_BAUDRATE 115200 + Added: head/sysutils/u-boot-rpi3/files/patch-include_efi__api.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-include_efi__api.h Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,21 @@ +--- include/efi_api.h.orig 2016-09-12 14:05:51 UTC ++++ include/efi_api.h +@@ -264,6 +264,18 @@ struct efi_device_path { + u16 length; + }; + ++struct efi_mac_addr { ++ u8 addr[32]; ++}; ++ ++#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03 ++struct efi_device_path_mac_addr { ++ struct efi_device_path dp; ++ struct efi_mac_addr mac; ++ u8 if_type; ++}; ++ ++# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b + #define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04 + # define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04 + Added: head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__console.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__console.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,40 @@ +--- lib/efi_loader/efi_console.c.orig 2016-09-12 14:05:51 UTC ++++ lib/efi_loader/efi_console.c +@@ -9,9 +9,9 @@ + #include + #include + +-/* If we can't determine the console size, default to 80x24 */ ++/* If we can't determine the console size, default to 80x25 */ + static int console_columns = 80; +-static int console_rows = 24; ++static int console_rows = 25; + static bool console_size_queried; + + const efi_guid_t efi_guid_console_control = CONSOLE_CONTROL_GUID; +@@ -165,6 +165,8 @@ static efi_status_t EFIAPI efi_cout_quer + unsigned long mode_number, unsigned long *columns, + unsigned long *rows) + { ++ unsigned long current_mode; ++ + EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows); + + if (!console_size_queried) { +@@ -196,6 +198,16 @@ static efi_status_t EFIAPI efi_cout_quer + } + + out: ++ if (console_columns == 80 && console_rows == 25) ++ current_mode = 0; ++ else if (console_columns == 80 && console_rows == 50) ++ current_mode = 1; ++ else ++ current_mode = 2; ++ ++ if (mode_number != current_mode) ++ return EFI_EXIT(EFI_UNSUPPORTED); ++ + if (columns) + *columns = console_columns; + if (rows) Added: head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__disk.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__disk.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,126 @@ +--- lib/efi_loader/efi_disk.c.orig 2016-09-12 14:05:51 UTC ++++ lib/efi_loader/efi_disk.c +@@ -196,11 +196,13 @@ static void efi_disk_add_dev(const char + const char *if_typename, + const struct blk_desc *desc, + int dev_index, +- lbaint_t offset) ++ disk_partition_t *info, ++ int logical_partition) + { + struct efi_disk_obj *diskobj; + struct efi_device_path_file_path *dp; + int objlen = sizeof(*diskobj) + (sizeof(*dp) * 2); ++ static int mediaid = 0; + + /* Don't add empty devices */ + if (!desc->lba) +@@ -217,16 +219,28 @@ static void efi_disk_add_dev(const char + diskobj->ops = block_io_disk_template; + diskobj->ifname = if_typename; + diskobj->dev_index = dev_index; +- diskobj->offset = offset; ++ if (info) ++ diskobj->offset = info->start; ++ + diskobj->desc = desc; + + /* Fill in EFI IO Media info (for read/write callbacks) */ + diskobj->media.removable_media = desc->removable; + diskobj->media.media_present = 1; +- diskobj->media.block_size = desc->blksz; +- diskobj->media.io_align = desc->blksz; +- diskobj->media.last_block = desc->lba - offset; ++ diskobj->media.media_id = mediaid++; + diskobj->ops.media = &diskobj->media; ++ if (logical_partition) { ++ printf("Adding logical partition\n"); ++ diskobj->media.logical_partition = 1; ++ diskobj->media.block_size = info->blksz; ++ diskobj->media.io_align = info->blksz; ++ diskobj->media.last_block = info->size - 1; ++ } ++ else { ++ diskobj->media.block_size = desc->blksz; ++ diskobj->media.io_align = desc->blksz; ++ diskobj->media.last_block = desc->lba; ++ } + + /* Fill in device path */ + dp = (void*)&diskobj[1]; +@@ -261,8 +275,7 @@ static int efi_disk_create_eltorito(stru + while (!part_get_info(desc, part, &info)) { + snprintf(devname, sizeof(devname), "%s:%d", pdevname, + part); +- efi_disk_add_dev(devname, if_typename, desc, diskid, +- info.start); ++ efi_disk_add_dev(devname, if_typename, desc, diskid, 0, 0); + part++; + disks++; + } +@@ -271,6 +284,30 @@ static int efi_disk_create_eltorito(stru + return disks; + } + ++static int efi_disk_create_mbr(struct blk_desc *desc, ++ const struct blk_driver *cur_drvr, ++ int diskid) ++{ ++ int disks = 0; ++ char devname[32] = { 0 }; /* dp->str is u16[32] long */ ++ disk_partition_t info; ++ int part = 1; ++ ++ if (desc->part_type != PART_TYPE_DOS) ++ return 0; ++ ++ while (!part_get_info(desc, part, &info)) { ++ snprintf(devname, sizeof(devname), "%s%d:%d", cur_drvr->if_typename, ++ diskid, part); ++ ++ efi_disk_add_dev(devname, cur_drvr->if_typename, desc, diskid, &info, 1); ++ part++; ++ disks++; ++ } ++ ++ return disks; ++} ++ + /* + * U-Boot doesn't have a list of all online disk devices. So when running our + * EFI payload, we scan through all of the potentially available ones and +@@ -295,13 +332,14 @@ int efi_disk_register(void) + const char *if_typename = dev->driver->name; + + printf("Scanning disk %s...\n", dev->name); +- efi_disk_add_dev(dev->name, if_typename, desc, desc->devnum, 0); ++ efi_disk_add_dev(dev->name, if_typename, desc, desc->devnum, NULL, 0); + disks++; + + /* + * El Torito images show up as block devices in an EFI world, + * so let's create them here + */ ++ disks += efi_disk_create_mbr(desc, dev, desc->devnum); + disks += efi_disk_create_eltorito(desc, if_typename, + desc->devnum, dev->name); + } +@@ -331,15 +369,17 @@ int efi_disk_register(void) + + snprintf(devname, sizeof(devname), "%s%d", + if_typename, i); +- efi_disk_add_dev(devname, if_typename, desc, i, 0); ++ efi_disk_add_dev(devname, if_typename, desc, i, 0, 0); + disks++; + + /* + * El Torito images show up as block devices + * in an EFI world, so let's create them here + */ ++ disks += efi_disk_create_mbr(desc, cur_drvr, i); + disks += efi_disk_create_eltorito(desc, if_typename, + i, devname); ++ + } + } + #endif Added: head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__net.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/files/patch-lib_efi__loader_efi__net.c Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,48 @@ +--- lib/efi_loader/efi_net.c.orig 2016-09-12 14:05:51 UTC ++++ lib/efi_loader/efi_net.c +@@ -27,7 +27,8 @@ struct efi_net_obj { + struct efi_simple_network net; + struct efi_simple_network_mode net_mode; + /* Device path to the network adapter */ +- struct efi_device_path_file_path dp[2]; ++ struct efi_device_path_mac_addr dp_mac; ++ struct efi_device_path_file_path dp_end; + /* PXE struct to transmit dhcp data */ + struct efi_pxe pxe; + struct efi_pxe_mode pxe_mode; +@@ -198,7 +199,7 @@ static efi_status_t efi_net_open_dp(void + struct efi_simple_network *net = handle; + struct efi_net_obj *netobj = container_of(net, struct efi_net_obj, net); + +- *protocol_interface = netobj->dp; ++ *protocol_interface = &netobj->dp_mac; + + return EFI_SUCCESS; + } +@@ -229,11 +230,10 @@ void efi_net_set_dhcp_ack(void *pkt, int + int efi_net_register(void **handle) + { + struct efi_net_obj *netobj; +- struct efi_device_path_file_path dp_net = { +- .dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE, +- .dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH, ++ struct efi_device_path_mac_addr dp_net = { ++ .dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE, ++ .dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR, + .dp.length = sizeof(dp_net), +- .str = { 'N', 'e', 't' }, + }; + struct efi_device_path_file_path dp_end = { + .dp.type = DEVICE_PATH_TYPE_END, +@@ -272,8 +272,9 @@ int efi_net_register(void **handle) + netobj->net.receive = efi_net_receive; + netobj->net.mode = &netobj->net_mode; + netobj->net_mode.state = EFI_NETWORK_STARTED; +- netobj->dp[0] = dp_net; +- netobj->dp[1] = dp_end; ++ netobj->dp_mac = dp_net; ++ netobj->dp_end = dp_end; ++ memcpy(netobj->dp_mac.mac.addr, eth_get_ethaddr(), 6); + memcpy(netobj->net_mode.current_address.mac_addr, eth_get_ethaddr(), 6); + netobj->net_mode.max_packet_size = PKTSIZE; + Added: head/sysutils/u-boot-rpi3/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/u-boot-rpi3/pkg-descr Tue Oct 18 14:23:50 2016 (r424162) @@ -0,0 +1,3 @@ +U-Boot loader and related files for the RPi3 + +For general information about U-Boot see WWW: http://www.denx.de/wiki/U-Boot