diff options
author | Glen Barber <gjb@FreeBSD.org> | 2016-02-09 01:42:51 +0000 |
---|---|---|
committer | Glen Barber <gjb@FreeBSD.org> | 2016-02-09 01:42:51 +0000 |
commit | acbbf33c47fbbb90e2708f733bcc75763a5a9c72 (patch) | |
tree | 70f0e618229555b31fa72c4654cd22149f40460b /sys | |
parent | bcefcb026a4205dd03b397bcb544d86b6aa4bbfc (diff) | |
parent | 78a38b8f05f9dbb70ca12e0223ef52984f3aa65f (diff) | |
download | src-acbbf33c47fbbb90e2708f733bcc75763a5a9c72.tar.gz src-acbbf33c47fbbb90e2708f733bcc75763a5a9c72.zip |
MFH
Sponsored by: The FreeBSD Foundation
Notes
Notes:
svn path=/projects/release-pkg/; revision=295423
Diffstat (limited to 'sys')
-rw-r--r-- | sys/boot/Makefile.inc | 8 | ||||
-rw-r--r-- | sys/boot/efi/loader/arch/arm/ldscript.arm | 4 | ||||
-rw-r--r-- | sys/boot/efi/loader/main.c | 96 | ||||
-rw-r--r-- | sys/boot/ficl/words.c | 4 | ||||
-rw-r--r-- | sys/boot/i386/Makefile | 4 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_xpt.c | 2 | ||||
-rw-r--r-- | sys/conf/kmod.mk | 4 | ||||
-rw-r--r-- | sys/kern/init_main.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 2 |
9 files changed, 116 insertions, 10 deletions
diff --git a/sys/boot/Makefile.inc b/sys/boot/Makefile.inc index 3545446762df..17088d782da7 100644 --- a/sys/boot/Makefile.inc +++ b/sys/boot/Makefile.inc @@ -1,3 +1,11 @@ # $FreeBSD$ SSP_CFLAGS= + +.if ${MACHINE_CPUARCH} == "arm" +# Do not generate movt/movw, because the relocation fixup for them does not +# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8). +# Also, the fpu is not available in a standalone environment. +CFLAGS.clang+= -mllvm -arm-use-movt=0 +CFLAGS.clang+= -mfpu=none +.endif diff --git a/sys/boot/efi/loader/arch/arm/ldscript.arm b/sys/boot/efi/loader/arch/arm/ldscript.arm index 4dcf302b2213..8b4a6dc64b36 100644 --- a/sys/boot/efi/loader/arch/arm/ldscript.arm +++ b/sys/boot/efi/loader/arch/arm/ldscript.arm @@ -15,7 +15,7 @@ SECTIONS } =0 _etext = .; PROVIDE (etext = .); - . = ALIGN(4096); + . = ALIGN(16); .data : { *(.data *.data.*) @@ -24,6 +24,7 @@ SECTIONS *(.rodata.*) CONSTRUCTORS + . = ALIGN(4); PROVIDE (__bss_start = .); *(.sbss) *(.scommon) @@ -31,6 +32,7 @@ SECTIONS *(.dynbss) *(.bss) *(COMMON) + . = ALIGN(4); PROVIDE (__bss_end = .); } /* We want the small data sections together, so single-instruction offsets diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index 4c3bc7aa3ef6..361d3bbd473a 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -66,6 +66,7 @@ EFI_GUID hoblist = HOB_LIST_TABLE_GUID; EFI_GUID memtype = MEMORY_TYPE_INFORMATION_TABLE_GUID; EFI_GUID debugimg = DEBUG_IMAGE_INFO_TABLE_GUID; EFI_GUID fdtdtb = FDT_TABLE_GUID; +EFI_GUID inputid = SIMPLE_TEXT_INPUT_PROTOCOL; #ifdef EFI_ZFS_BOOT static void efi_zfs_probe(void); @@ -94,6 +95,88 @@ cp16to8(const CHAR16 *src, char *dst, size_t len) dst[i] = (char)src[i]; } +static int +has_keyboard(void) +{ + EFI_STATUS status; + EFI_DEVICE_PATH *path; + EFI_HANDLE *hin, *hin_end, *walker; + UINTN sz; + int retval = 0; + + /* + * Find all the handles that support the SIMPLE_TEXT_INPUT_PROTOCOL and + * do the typical dance to get the right sized buffer. + */ + sz = 0; + hin = NULL; + status = BS->LocateHandle(ByProtocol, &inputid, 0, &sz, 0); + if (status == EFI_BUFFER_TOO_SMALL) { + hin = (EFI_HANDLE *)malloc(sz); + status = BS->LocateHandle(ByProtocol, &inputid, 0, &sz, + hin); + if (EFI_ERROR(status)) + free(hin); + } + if (EFI_ERROR(status)) + return retval; + + /* + * Look at each of the handles. If it supports the device path protocol, + * use it to get the device path for this handle. Then see if that + * device path matches either the USB device path for keyboards or the + * legacy device path for keyboards. + */ + hin_end = &hin[sz / sizeof(*hin)]; + for (walker = hin; walker < hin_end; walker++) { + status = BS->HandleProtocol(*walker, &devid, (VOID **)&path); + if (EFI_ERROR(status)) + continue; + + while (!IsDevicePathEnd(path)) { + /* + * Check for the ACPI keyboard node. All PNP3xx nodes + * are keyboards of different flavors. Note: It is + * unclear of there's always a keyboard node when + * there's a keyboard controller, or if there's only one + * when a keyboard is detected at boot. + */ + if (DevicePathType(path) == ACPI_DEVICE_PATH && + (DevicePathSubType(path) == ACPI_DP || + DevicePathSubType(path) == ACPI_EXTENDED_DP)) { + ACPI_HID_DEVICE_PATH *acpi; + + acpi = (ACPI_HID_DEVICE_PATH *)(void *)path; + if ((EISA_ID_TO_NUM(acpi->HID) & 0xff00) == 0x300 && + (acpi->HID & 0xffff) == PNP_EISA_ID_CONST) { + retval = 1; + goto out; + } + /* + * Check for USB keyboard node, if present. Unlike a + * PS/2 keyboard, these definitely only appear when + * connected to the system. + */ + } else if (DevicePathType(path) == MESSAGING_DEVICE_PATH && + DevicePathSubType(path) == MSG_USB_CLASS_DP) { + USB_CLASS_DEVICE_PATH *usb; + + usb = (USB_CLASS_DEVICE_PATH *)(void *)path; + if (usb->DeviceClass == 3 && /* HID */ + usb->DeviceSubClass == 1 && /* Boot devices */ + usb->DeviceProtocol == 1) { /* Boot keyboards */ + retval = 1; + goto out; + } + } + path = NextDevicePathNode(path); + } + } +out: + free(hin); + return retval; +} + EFI_STATUS main(int argc, CHAR16 *argv[]) { @@ -104,6 +187,7 @@ main(int argc, CHAR16 *argv[]) struct devsw *dev; uint64_t pool_guid; UINTN k; + int has_kbd; archsw.arch_autoload = efi_autoload; archsw.arch_getdev = efi_getdev; @@ -115,6 +199,8 @@ main(int argc, CHAR16 *argv[]) archsw.arch_zfs_probe = efi_zfs_probe; #endif + has_kbd = has_keyboard(); + /* * XXX Chicken-and-egg problem; we want to have console output * early, but some console attributes may depend on reading from @@ -150,15 +236,19 @@ main(int argc, CHAR16 *argv[]) case 'D': howto |= RB_MULTIPLE; break; - case 'm': - howto |= RB_MUTE; - break; case 'h': howto |= RB_SERIAL; break; + case 'm': + howto |= RB_MUTE; + break; case 'p': howto |= RB_PAUSE; break; + case 'P': + if (!has_kbd) + howto |= RB_SERIAL | RB_MULTIPLE; + break; case 'r': howto |= RB_DFLTROOT; break; diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c index c32e352b7330..0e8f2c4c2fcd 100644 --- a/sys/boot/ficl/words.c +++ b/sys/boot/ficl/words.c @@ -4822,7 +4822,7 @@ WORDKIND ficlWordClassify(FICL_WORD *pFW) **************************************************************************/ static void ficlRandom(FICL_VM *pVM) { - PUSHINT(rand()); + PUSHUNS(random()); } @@ -4832,7 +4832,7 @@ static void ficlRandom(FICL_VM *pVM) **************************************************************************/ static void ficlSeedRandom(FICL_VM *pVM) { - srand(POPINT()); + srandom(POPUNS()); } #endif diff --git a/sys/boot/i386/Makefile b/sys/boot/i386/Makefile index d812d54e7016..0c3daed185ee 100644 --- a/sys/boot/i386/Makefile +++ b/sys/boot/i386/Makefile @@ -8,6 +8,10 @@ SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot \ # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr +.if ${MACHINE_CPUARCH} == "i386" +SUBDIR+= kgzldr +.endif + .if ${MK_ZFS} != "no" SUBDIR+= zfsboot gptzfsboot zfsloader .endif diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 7cffd67955f5..c0cc310dc5e8 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -1518,7 +1518,7 @@ out: } else if (cam_periph_error(done_ccb, 0, SF_RETRY_UA, &softc->saved_ccb) == ERESTART) { - return; + goto outr; } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { /* Don't wedge the queue */ xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index a79fe967b4d8..c0f034e2da46 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -249,9 +249,11 @@ _ILINKS+=x86 .endif CLEANFILES+=${_ILINKS} -all: objwarn ${PROG} +all: beforebuild .WAIT ${PROG} +beforebuild: objwarn beforedepend: ${_ILINKS} +beforebuild: ${_ILINKS} # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index d5f8f4ddbe31..d157d24055ae 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -479,7 +479,7 @@ proc0_init(void *dummy __unused) session0.s_leader = p; p->p_sysent = &null_sysvec; - p->p_flag = P_SYSTEM | P_INMEM; + p->p_flag = P_SYSTEM | P_INMEM | P_KTHREAD; p->p_flag2 = 0; p->p_state = PRS_NORMAL; knlist_init_mtx(&p->p_klist, &p->p_mtx); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 9abe08c037c5..34af264fd704 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1040,7 +1040,7 @@ fork_exit(void (*callout)(void *, struct trapframe *), void *arg, if (p->p_flag & P_KTHREAD) { printf("Kernel thread \"%s\" (pid %d) exited prematurely.\n", td->td_name, p->p_pid); - kproc_exit(0); + kthread_exit(); } mtx_assert(&Giant, MA_NOTOWNED); |