-/* $OpenBSD: conf.c,v 1.53 2020/12/09 18:10:17 krw Exp $ */
+/* $OpenBSD: conf.c,v 1.54 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
#include <biosdev.h>
#include <dev/cons.h>
-const char version[] = "3.53";
+const char version[] = "3.54";
int debug = 1;
-/* $OpenBSD: conf.c,v 1.47 2020/12/09 18:10:18 krw Exp $ */
+/* $OpenBSD: conf.c,v 1.48 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 2004 Tom Cosgrove
#include <biosdev.h>
#include <dev/cons.h>
-const char version[] = "3.53";
+const char version[] = "3.54";
int debug = 1;
-/* $OpenBSD: conf.c,v 1.37 2022/06/20 02:22:05 yasuoka Exp $ */
+/* $OpenBSD: conf.c,v 1.38 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
#include "efidev.h"
#include "efipxe.h"
-const char version[] = "3.60";
+const char version[] = "3.61";
#ifdef EFI_DEBUG
int debug = 0;
-/* $OpenBSD: efiboot.c,v 1.39 2022/06/20 02:22:05 yasuoka Exp $ */
+/* $OpenBSD: efiboot.c,v 1.40 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
addbootarg(BOOTARG_EFIINFO, sizeof(bios_efiinfo), &bios_efiinfo);
}
+/* Vendor device path used to indicate the mmio UART on AMD SoCs. */
+#define AMDSOC_DEVPATH \
+ { 0xe76fd4e9, 0x0a30, 0x4ca9, \
+ { 0x95, 0x40, 0xd7, 0x99, 0x53, 0x4c, 0xc4, 0xff } }
+
+void
+efi_setconsdev(void)
+{
+ bios_consdev_t cd;
+ EFI_STATUS status;
+ UINT8 data[128];
+ UINTN size = sizeof(data);
+ EFI_DEVICE_PATH *dp = (void *)data;
+ VENDOR_DEVICE_PATH *vdp;
+ UART_DEVICE_PATH *udp;
+ EFI_GUID global = EFI_GLOBAL_VARIABLE;
+ EFI_GUID amdsoc = AMDSOC_DEVPATH;
+
+ memset(&cd, 0, sizeof(cd));
+ cd.consdev = cn_tab->cn_dev;
+ cd.conspeed = com_speed;
+ cd.consaddr = com_addr;
+
+ /*
+ * If the ConOut variable indicates we're using a serial
+ * console, use it to determine the baud rate.
+ */
+ status = RS->GetVariable(L"ConOut", &global, NULL, &size, &data);
+ if (status == EFI_SUCCESS) {
+ for (dp = (void *)data; !IsDevicePathEnd(dp);
+ dp = NextDevicePathNode(dp)) {
+ /*
+ * AMD Ryzen Embedded V1000 SoCs integrate a
+ * Synopsys DesignWare UART that is not
+ * compatible with the traditional 8250 UART
+ * found on the IBM PC. Pass the magic
+ * parameters to the kernel to make this UART
+ * work.
+ */
+ if (DevicePathType(dp) == HARDWARE_DEVICE_PATH &&
+ DevicePathSubType(dp) == HW_VENDOR_DP) {
+ vdp = (VENDOR_DEVICE_PATH *)dp;
+ if (efi_guidcmp(&vdp->Guid, &amdsoc) == 0) {
+ cd.consdev = makedev(8, 4);
+ cd.consaddr = *(uint64_t *)(vdp + 1);
+ cd.consfreq = 48000000;
+ cd.flags = BCD_MMIO;
+ cd.reg_width = 4;
+ cd.reg_shift = 2;
+ }
+ }
+
+ if (DevicePathType(dp) == MESSAGING_DEVICE_PATH &&
+ DevicePathSubType(dp) == MSG_UART_DP) {
+ udp = (UART_DEVICE_PATH *)dp;
+ if (cd.conspeed == -1)
+ cd.conspeed = udp->BaudRate;
+ }
+ }
+ }
+
+ addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd);
+}
+
void
_rtt(void)
{
-/* $OpenBSD: efiboot.h,v 1.4 2017/11/25 19:02:07 patrick Exp $ */
+/* $OpenBSD: efiboot.h,v 1.5 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
int Xgop_efi(void);
int Xexit_efi(void);
void efi_makebootargs(void);
+void efi_setconsdev(void);
int Xpoweroff_efi(void);
-/* $OpenBSD: exec_i386.c,v 1.8 2022/06/30 15:46:57 anton Exp $ */
+/* $OpenBSD: exec_i386.c,v 1.9 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 1997-1998 Michael Shalayeff
dev_t bootdev = bootdev_dip->bootdev;
size_t ac = BOOTARG_LEN;
caddr_t av = (caddr_t)BOOTARG_OFF;
- bios_oconsdev_t cd;
- extern int com_speed; /* from bioscons.c */
- extern int com_addr;
bios_ddb_t ddb;
extern int db_console;
bios_bootduid_t bootduid;
if ((av = alloc(ac)) == NULL)
panic("alloc for bootarg");
efi_makebootargs();
+ efi_setconsdev();
delta = DEFAULT_KERNEL_ADDRESS - efi_loadaddr;
if (sa_cleanup != NULL)
(*sa_cleanup)();
- cd.consdev = cn_tab->cn_dev;
- cd.conspeed = com_speed;
- cd.consaddr = com_addr;
- cd.consfreq = 0;
- addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd);
-
if (bootmac != NULL)
addbootarg(BOOTARG_BOOTMAC, sizeof(bios_bootmac_t), bootmac);
-/* $OpenBSD: exec_i386.c,v 1.36 2022/06/30 15:46:57 anton Exp $ */
+/* $OpenBSD: exec_i386.c,v 1.37 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 1997-1998 Michael Shalayeff
dev_t bootdev = bootdev_dip->bootdev;
size_t ac = BOOTARG_LEN;
caddr_t av = (caddr_t)BOOTARG_OFF;
- bios_oconsdev_t cd;
+ bios_consdev_t cd;
extern int com_speed; /* from bioscons.c */
extern int com_addr;
bios_ddb_t ddb;
if (sa_cleanup != NULL)
(*sa_cleanup)();
+ memset(&cd, 0, sizeof(cd));
cd.consdev = cn_tab->cn_dev;
cd.conspeed = com_speed;
cd.consaddr = com_addr;
- cd.consfreq = 0;
addbootarg(BOOTARG_CONSDEV, sizeof(cd), &cd);
if (bootmac != NULL)
-/* $OpenBSD: conf.c,v 1.52 2020/12/09 18:10:18 krw Exp $ */
+/* $OpenBSD: conf.c,v 1.53 2022/07/11 19:45:02 kettenis Exp $ */
/*
* Copyright (c) 2004 Tom Cosgrove
#include "pxeboot.h"
#include "pxe_net.h"
-const char version[] = "3.53";
+const char version[] = "3.54";
int debug = 0;
void (*sa_cleanup)(void) = pxe_shutdown;