View | Details | Raw Unified | Return to bug 227313 | Differences between
and this patch

Collapse All | Expand All

(-)sys/boot/forth/loader.4th (+29 lines)
Lines 49-54 Link Here
49
49
50
only forth definitions
50
only forth definitions
51
51
52
: ibftpresent? ( -- flag ) \ Returns TRUE if iBFT is present, FALSE otherwise
53
	s" ibft.revision" getenv
54
	dup -1 = if
55
		drop false exit
56
	then
57
	2drop
58
	true
59
;
60
61
: ibftenabled? ( -- flag ) \ Returns TRUE if iBFT is enabled, FALSE otherwise
62
	s" ibft.disabled" getenv
63
	dup -1 <> if
64
		s" 0" compare 0<> if
65
			false exit
66
		then
67
	else
68
		drop
69
	then
70
	true
71
;
72
73
: ibftauto ( -- flag ) \ Set isboot_load="YES" is iBFT is present and enabled
74
	ibftenabled? if
75
		ibftpresent? if
76
        		     s" set isboot_load=YES" evaluate
77
		then
78
	then
79
;
80
52
: bootmsg ( -- )
81
: bootmsg ( -- )
53
  loader_color? dup ( -- bool bool )
82
  loader_color? dup ( -- bool bool )
54
  if 7 fg 4 bg then
83
  if 7 fg 4 bg then
(-)sys/boot/forth/loader.conf (+1 lines)
Lines 536-541 Link Here
536
amdtemp_load="NO"		# AMD K8/K10/K11 temperature monitor
536
amdtemp_load="NO"		# AMD K8/K10/K11 temperature monitor
537
tpm_load="NO"			# Trusted Platform Module
537
tpm_load="NO"			# Trusted Platform Module
538
wbwd_load="NO"			# Winbond watchdog
538
wbwd_load="NO"			# Winbond watchdog
539
isboot_Load="NO"		# iSCSI boot module
539
540
540
541
541
##############################################################
542
##############################################################
(-)sys/boot/forth/loader.rc (+3 lines)
Lines 15-20 Link Here
15
\ Tests for password -- executes autoboot first if a password was defined
15
\ Tests for password -- executes autoboot first if a password was defined
16
check-password
16
check-password
17
17
18
\ Check for iBFT and load isboot if present & not disabled
19
ibftauto
20
18
\ Uncomment to enable boot menu
21
\ Uncomment to enable boot menu
19
\ include /boot/beastie.4th
22
\ include /boot/beastie.4th
20
\ beastie-start
23
\ beastie-start
(-)sys/boot/i386/libi386/Makefile (+1 lines)
Lines 7-12 Link Here
7
	biospci.c biossmap.c bootinfo.c bootinfo32.c bootinfo64.c \
7
	biospci.c biossmap.c bootinfo.c bootinfo32.c bootinfo64.c \
8
	comconsole.c devicename.c elf32_freebsd.c \
8
	comconsole.c devicename.c elf32_freebsd.c \
9
	elf64_freebsd.c multiboot.c multiboot_tramp.S \
9
	elf64_freebsd.c multiboot.c multiboot_tramp.S \
10
	ibft.c \
10
	i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
11
	i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
11
	smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
12
	smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
12
.PATH:	${.CURDIR}/../../zfs
13
.PATH:	${.CURDIR}/../../zfs
(-)sys/boot/i386/libi386/ibft.c (+118 lines)
Line 0 Link Here
1
/*-
2
 * Copyright (c) 2018 Daniel O'Connor <darius@dons.net.au>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *	notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *	notice, this list of conditions and the following disclaimer in the
12
 *	documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
 * SUCH DAMAGE.
25
 */
26
27
#include <sys/cdefs.h>
28
__FBSDID("$FreeBSD$");
29
30
#include <stand.h>
31
#include <bootstrap.h>
32
#include <sys/endian.h>
33
34
#include "btxv86.h"
35
#include "ibft.h"
36
37
/*
38
 * Detect iBFT and export information about the iBFT into the
39
 * environment.
40
 */
41
42
#define IBFT_ALIGN 16
43
#define IBFT_SIGNATURE "iBFT"
44
#define IBFT_SIGNATURE_LENGTH 4
45
#define IBFT_LOW_ADDR (512 * 1024)
46
#define IBFT_HIGH_ADDR (1024 * 1024)
47
#define IBFT_MAX_LEN (32 * 1024)
48
#define IBFT_IP_LEN 16
49
50
#define	IBFT_GET8(base, off) (*(uint8_t *)((base) + (off)))
51
#define	IBFT_GET16(base, off) (*(uint16_t *)((base) + (off)))
52
#define	IBFT_GET32(base, off) (*(uint32_t *)((base) + (off)))
53
54
static uint8_t
55
ibft_checksum(const caddr_t addr, const int len)
56
{
57
	uint8_t		sum;
58
	int		i;
59
60
	for (sum = 0, i = 0; i < len; i++)
61
		sum += IBFT_GET8(addr, i);
62
	return (sum);
63
}
64
65
static caddr_t
66
ibft_sigsearch(const caddr_t start, const caddr_t end)
67
{
68
	caddr_t		cp;
69
	uint32_t	tlen;
70
	uint8_t		sum;
71
72
	for (cp = start; cp < end; cp += IBFT_ALIGN) {
73
	    if (strncmp(cp, IBFT_SIGNATURE, IBFT_SIGNATURE_LENGTH) != 0)
74
		continue;
75
76
	    tlen = IBFT_GET32(cp, 4);
77
	    if (tlen > IBFT_MAX_LEN)
78
		continue;
79
80
	    sum = ibft_checksum(cp, tlen);
81
	    if (sum != 0)
82
		continue;
83
	  return (cp);
84
	}
85
	return (NULL);
86
}
87
88
void
89
ibft_detect(void)
90
{
91
    char 		tmp[20];
92
    caddr_t		cp;
93
94
    // XXX: Need to use ACPI for EFI
95
    cp = ibft_sigsearch(PTOV(IBFT_LOW_ADDR), PTOV(IBFT_HIGH_ADDR));
96
    if (cp == NULL)
97
	return;
98
99
    sprintf(tmp, "%d", IBFT_GET8(cp, 8));
100
    setenv("ibft.revision", tmp, 1);
101
    bzero(tmp, sizeof(tmp));
102
    strncpy(tmp, cp + 10, 6);
103
    setenv("ibft.oemid", tmp, 1);
104
    bzero(tmp, sizeof(tmp));
105
    strncpy(tmp, cp + 16, 8);
106
    setenv("ibft.oemtableid", tmp, 1);
107
}
108
109
static int
110
command_ibft(int argc, char **argv)
111
{
112
    ibft_detect();
113
114
    return 0;
115
}
116
117
COMMAND_SET(ibft, "ibft", "find iBFT block", command_ibft);
118
(-)sys/boot/i386/libi386/ibft.h (+33 lines)
Line 0 Link Here
1
/*-
2
 * Copyright (c) 2018 Daniel O'Connor <darius@dons.net.au>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
18
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
22
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
23
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
 * POSSIBILITY OF SUCH DAMAGE.
25
 *
26
 * $FreeBSD$
27
 */
28
#ifndef _IBFT_H_
29
#define	_IBFT_H_
30
31
void	ibft_detect(void);
32
33
#endif /* _IBFT_H_ */
(-)sys/boot/i386/loader/main.c (+4 lines)
Lines 44-49 Link Here
44
#include "common/bootargs.h"
44
#include "common/bootargs.h"
45
#include "libi386/libi386.h"
45
#include "libi386/libi386.h"
46
#include "libi386/smbios.h"
46
#include "libi386/smbios.h"
47
#include "libi386/ibft.h"
47
#include "btxv86.h"
48
#include "btxv86.h"
48
49
49
#ifdef LOADER_ZFS_SUPPORT
50
#ifdef LOADER_ZFS_SUPPORT
Lines 215-220 Link Here
215
    /* detect PCI BIOS for future reference */
216
    /* detect PCI BIOS for future reference */
216
    biospci_detect();
217
    biospci_detect();
217
218
219
    /* detect iBFT for future reference */
220
    ibft_detect();
221
218
    printf("\n%s", bootprog_info);
222
    printf("\n%s", bootprog_info);
219
223
220
    extract_currdev();				/* set $currdev and $loaddev */
224
    extract_currdev();				/* set $currdev and $loaddev */

Return to bug 227313